From d5e13a227cce49305fd51ddd4660c11995694425 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Wed, 2 Aug 2023 20:24:37 -0700 Subject: [PATCH 01/22] Fix #3497 --- src/bun.js/module_loader.zig | 4 ++++ src/js/thirdparty/utf-8-validate.js | 4 ++++ test/bun.lockb | Bin 148992 -> 150672 bytes .../utf-8-validate/utf-8-validate.test.ts | 9 +++++++++ test/package.json | 10 ++++++---- 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/js/thirdparty/utf-8-validate.js create mode 100644 test/js/first_party/utf-8-validate/utf-8-validate.test.ts diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index 7cc1f45749f774..d374101317b6ce 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -2245,6 +2245,7 @@ pub const ModuleLoader = struct { .@"isomorphic-fetch" => return jsSyntheticModule(.@"isomorphic-fetch", specifier), .@"node-fetch" => return jsSyntheticModule(.@"node-fetch", specifier), .@"@vercel/fetch" => return jsSyntheticModule(.vercel_fetch, specifier), + .@"utf-8-validate" => return jsSyntheticModule(.@"utf-8-validate", specifier), .undici => return jsSyntheticModule(.undici, specifier), .ws => return jsSyntheticModule(.ws, specifier), } @@ -2416,6 +2417,7 @@ pub const HardcodedModule = enum { @"isomorphic-fetch", @"node-fetch", @"@vercel/fetch", + @"utf-8-validate", // These are all not implemented yet, but are stubbed @"node:v8", @"node:trace_events", @@ -2496,6 +2498,7 @@ pub const HardcodedModule = enum { .{ "undici", HardcodedModule.undici }, .{ "ws", HardcodedModule.ws }, .{ "@vercel/fetch", HardcodedModule.@"@vercel/fetch" }, + .{ "utf-8-validate", HardcodedModule.@"utf-8-validate" }, }, ); pub const Alias = struct { @@ -2601,6 +2604,7 @@ pub const HardcodedModule = enum { .{ "worker_threads", .{ .path = "node:worker_threads" } }, .{ "ws", .{ .path = "ws" } }, .{ "ws/lib/websocket", .{ .path = "ws" } }, + .{ "utf-8-validate", .{ .path = "utf-8-validate" } }, .{ "zlib", .{ .path = "node:zlib" } }, // .{ "readable-stream", .{ .path = "node:stream" } }, // .{ "readable-stream/consumer", .{ .path = "node:stream/consumers" } }, diff --git a/src/js/thirdparty/utf-8-validate.js b/src/js/thirdparty/utf-8-validate.js new file mode 100644 index 00000000000000..fdb974d5902763 --- /dev/null +++ b/src/js/thirdparty/utf-8-validate.js @@ -0,0 +1,4 @@ +import { isUtf8 } from "node:buffer"; + +// https://github.com/websockets/utf-8-validate#api +export default isUtf8; diff --git a/test/bun.lockb b/test/bun.lockb index f6b48c1bb627da66a77ed03b7264c2fd60e458f2..735613c546f5ba4c91d66d3b611ab3c88d4caa74 100755 GIT binary patch delta 33536 zcmeHwcYIVu_x`;L3%P*+p(Z3i0)n&z5=b@}*rh`fLWdBfr2!!!of0VU(hGYD~ccJ6wq3rwM=Ts zpYkvovY}vg>Z3MR{FzC6qazi;PZUvVJ-0uysAU7K4SEiJp&27V*}V&Bm8F|{8D@-5 z$PF5qo-nE|c-B%4l=*oHSqX{hDM~lf{C1!;Yi#P+l%V89r6qW%7E}YR1DY~EB_l6a zaVw|bA667n#VF7il=fTvB=~?G`W$-5D%c6ij%_x}bplfp{3=j3n39{6ke-m75)PgX z)(545H9^_Va+IUn9tEw9_6zD`RH{MX186T|Z0!p!B7d}|g2jClkZUC(Znqqcj zDr%!er$HNoPJrA8)Pcd`I0b;RLCvH)km(Qp7-)Sr5`$2H4RirzN0L#B{82;#>4enu zw;+T}AyaOmlPvxW}jm}KXQF2mpGtm$s9v5g3Lla{PCo9TBFpCxMG(&JRC|x!oz!>ArqNq$Q?Y=;Rn<&KF?bkxv9=Tx4dX$8aTBBAoTesCNl3~IO3mE~o*j4#lpRXX9GAroyw=RnONP9X(pD*W z0~Js)FEt}SH!ELR1)lDwg)Gn+JS|=fs)4d$h?Qzy!qZ;Y{Y9`*Uq(VkW@@scq~s=! z!+~R!P&eHI}CgK3awl{w}kbK zwXC3YL_(f2uZ`igmXOnX-R?44&rKOSp3CDm;OVXWg!J@Othi&7!-7VqOjMqXH1yLm zlM`|g7!K%FfnKnwpOQN+FEu?^X=w80+v)YV3kuB+B#ll;W%u?XgAH?-#wVmJ$tfvW zK`Ghk@0s$App}t79_48MV3*OM+|*HeJaM?QGBeYMB40y(Z%_tsZeDT_Vor%P<&8i+ zxz1Eag8tP&+3@%11U+)DgF(k-B&Q~&VnoK}CT7BuKXf$W<}maafVtyS(iu4)f!A2B zlOfN}g#g!*&W6567o)yk!Lvh4z*lI9#9Sm;@GLS&xiquj*p$4{naR0IW@qtA`C#`* zGrL`P!vT+jvY!dL`58%Rsd@d7PlrUCdTl_x!EZxV9ErqegNB20o$G7zqhbvECz$<> z15f=oQI6etu!mlcyI?936kr3?RmUgf=z*0SYZ#Q2nVFV~o+l>cri8anO-@KkO3A`r zGQFqa5Nk_n0)0B#-z=AvlbSm=K~XmKG7QVg%*`8x#qkAnfB~H~3JImGqI}U?eCJWu zt@Jevo0yl9k&K*keT?>xg3=)eO`0_-C^aK5LiwP#8BwEx7#PY{@Em|wOu7(ta3G%m zrM%(*gO&lMy;rS3?%YpIg`oqDjv#c?(@@yji>)OpInJnP9Vi=^X*SelkP#6n6SH7u zu2L9pbTBVJD+Mc@q763q+`NRmak(kElaNotGC?cCB?Y;L;YyM&z#<(lYJ1l8yu+;L zu_28(wB>Z=WpZ2i5OD)xrAsGWbPW_cBDSr=}X^sAC8qJ5pVN;Wam*QpkYVqcf~zR+sB zY+6|nUE8U47lpN5>cgTKq5!+_^mD3HM3kRP{X!J_xom#r#CC|{h34;4=ZYwNzAp;# z87zwNxmsv-TsE7Bh_2(b_wZ1ZXfew_Qhh-b*Kye|f$u7I`9-RoMO0mvHXkG9gv~b5 zr;bBCE{Y**gxSy@vNEDiVuXmQ=ThGhh4oxo%L}{FH$>> z6#H)%MS%`25<}b8($yw_!%l0I)Yh7LcGjbv1lJXLs$Od=QP|L>P8P-Z+$OX}E;u}@ zkxScxJ(2Zsj2+tV;Alq~y{$0Jd+c(s-8;~s;(_H(m%3dP-s#f3v0!6WM5#Xh4t12! z8oTUa2;TO>t8t`#98#T`Qr{NE$hionFm}Od+i!IGU>4p-luAs&lAQT_FlvxwMO>Ob<_c0iGLr zGW50GNSS?W;m|7HVbp^*{7@@6)75C>9&qe8dJ50IV&)kkcov*#Ir5q}G`yluZ+ix~ zwj#D}q_zSnwpCsq5bs7}X1G)BB#Ogb_HlSn!3u#6Z9}RflniHi-f2`^UUyGtlfzu8 z?NFx*EyAU~E}|k_HhW_+Gs0Lg+V zBejD_wLvr9q6ibJN;9Kp2r-O8PjH-U;II(P6vcPB?8T6EWCv{(nv3X2r@eP`+*Y$v z?Lnjr=VRvEUkBGgmtR7P!=ML;+ENs@b=ju|nO)J|L8>KkF}PUQ&V!??tBbu2;K1O^ zj<4@fb477Gm%2=7PM3B9IrI+dM7P_vFxE!+>Mn;mNfbL>_OuX1=^}PHBkgOD>ZYeI zAQh#j+M`28?sTLK*>0o^y&A2o+`&j0xz8aLtC#)ZvaAgjXBVdUHCV>B8mj-4^Z zmV;w}8msIvlS3E;JM8g@?;iSY@scR)=F(1sXUJo9!ALa0+Er4|aFfI27>1pvJNMAy z?k=qcqKeCnzQ}1q!LbH?<<}%Q)_{ICbl7(>PhUK$;0epnLOb?oaC*O37ib?d7mN*imfn>9oDpQF!)pYQG^5wb6^Pp*yxd zR*Z!$++n-Flh_WGmmy>)%ZZ{?+)VU#+44J!nZ2FbOQ_T=8|<*v>>@n-IJLXc7u1Og z_ttgT*Mf8E;dB})!}VP8n!s-cM@J@sV=!XH?d7lwaB!Aiq*ja+yQ7DjX75%iWVJAG zm?bnDHKbnV_JW%W&KN=jn{9tL;o0A*l|ituNh3OYfJ5!1IK4jlfWi$#78+pONgbBI&>5fUQ`*cC?~F%!bH zK1Q9!_BA$y~Osb_P08O0I_!>r#oeOf3bbIQ`=%@>%n379iZ=Qk&)UEq_F-J z)X^uXr2H~>3>;Rqf~s5~?EwSz#UwJ)mN8JwOmJ#zATaE}T4_5nPPsAIw825Mk;)Q3jQ>#AM z5GuU=vh^J-W+prBGa>BEJzU$36jlY+jvKhjcZ=v0r`G;%YX)PoY6ajp${0z+{Ttvo zK3GxXBRs&E3x9yaUVjKf4oYL~L-Rz4}l+JfYDUDLMpe z7&esn2G6-CJ#VCY7M`VR3oZ5T{SuChH~qy4zSKtLV@*HN#XGsHJZcxK=}D2c=6l@V!w0x3K{AoU4Sxami#ezKK2 z5-CHr3MoVH{N>z;6f3s?sUCXSotI_RNAh-+^(7)@tOY5f=C-4()(Vg^WZRH3 zN>m?hl^Bdvv|iuyNEv!3kTUclQcamwfE1kzXJD^e500}|e-gEQmnx$3oLZAHm%WG8 zE&-fVFR&NGIe(0pIl*Z!PUF+ltO=3!z;r8>j})FP_0UuABBkeQzM0l8h_#||F}O+WsiJ?kfKTI^2YEBd!v>!9?h}(7F0y=m zw9Z+${en7J)Wm|K*n*`A24mTvqkhcr%k9TShfChecAq{)|!&E1#}E2;YtA1(3K*%OHi-M88T? z6%wo(3Mp0t{UW9Q2!QegfE_|G>pX&0zphV>_WAIsSA?k33nH}i>qaOWM%3xopHW(l z2-7c8mdh~PR}ftKMM_0Pfqs$FqC9|>P5^k_2xS8k0S?tvfEOv{R=aK{C@27U73iN= zQg-NGfE}1_=978=vjFBl3b3OBumiIJUZj*iO9mGy_2(J1r?S8lECS_4%7zvL?AQ{3 z7b*FrWN?+HlrICyh?7%lxyiiE>%KWVW`(A7fFA}<7 z2PiMnK;Q(xhEALGEGVyQQC56T&%KgTe%_Rmvc3x@e}Umeg`a_Pz$L&F@SyN2N|A;S zR#4H*FHLJgUf-18FxCD4zZCqt4P8fn0DH=?Z)7Tv(!wStPs(IdlP^tKF4)X(Vdj&1 zh|da)=x$?5NtwLMb8nVcg zKWECXrtYf+rFoX&Um5Yb7NzT#n)#%3=?kEguQKJNOs+P0QhH#mA$Kb;83|>bN!Nq& zB4u)e$&=Ot|AEPqvZ4=7{#ukB`ULr2pvO!-QYMe<{BSFAC8g_5ng#wZR24zfjX8E2 zwXwTr%v%49GQxf~_5O@fRg4$6z&DB6D_he%RMT{E>{x6^sU}pSt)M)>vHcX3~ zn-;e;Ee-+YT#PggyiDC!3;qY5McSF=NanEXgkUN=J7a4Nut#sIu-gmR7l-=75ZX0WrAqV&w) zc@WU!|5{H5v}7W{vAXV)0P?6;0Prf%Kd+?h(7gaXG~LW6H6H}r`dI#tPXfvURKx}r z0lY}r&|-icTLSPRCBKvmt`b_o$oTh3U@P20SN{7XP~W=mx#33#h8C`yrT_1ffa%bG zp9J&`>E9=Tf1d=*M}mK!1h_}x3b^U?|Mw?>kiY#Tur6Pejc&i`p$FU_eAwx?H}%KaWvA6MMmZ1TO5082r)4v@hbsj4!>!QE-Pv$d_><;;@%^^2-?Y zD{&ayad2G@$EZg|(cw5T`-qqL5!^A+;Ygh5{*{+ld?ZHwR-6I%Gq?d?#i-wlg0fy4E!NR z^%iTvZ30*0OpIDhB%FbPXJH_?8p8W53_J$|&&H^=#1?Sdz%@JMb1?8c3K?E4w^fxA<5_!;(Hgnd89s7=Hfa6f|^a4|-0CKlrV$(Q{C`+kX0gG8TSVBfE> z4_phO{tEkkgMGios3Br4xJ}?{{1&6O5(&S-zTaUVxG>@UJM6mz`+kp69byZ(ZQvSS zic#B$>`Sok57-ATQUv}H_he&ua{3=JYCEwP+()X{lVNI%>UwgT8YgF{V2^_BAVXB} z5jNFJKB+>`Ngk%)I0ap75Ok46HV9^yf#639y2%b@An0Beg2iPZh>~Y0_?dzMWg&=> z3(G>V%npIw4neH!V~1c+IS4jT&`YZ2An+&;K}tCY`pC5uY@(n>c?kN+gz^xK_JH7B z3I<4T4>e95C{sz|J5QMRodzeLAG2=!6pi(*MJ~b?yZ56d9q1Oka2Pv$$0rO$pjfv z3uK}!B*~YDN$!ztd_X42B9h7STaqcVgD=Qb`80^zdf?#3RyJ~C`%6`qf7q^I zz3m$h9$)v-kB^L+Q~t>sXPd3qd)N2-R(L#mveS+-U4y)z>U1I`Wm&@s1@9%Fe=;$s zNu`O?LrN`$1?GLUUhfN?lVAI&;+CUN)j$7mrG|&6_IaZ5*6#1r4sVqfI;hp}cT^d1 zDqqQ|6}qX(V*#%|Roi@F1jZ1FBZh_3L|02pQZsbqe!1(iymtMFL>*yKlw-~a6j5nt(Z($)AC;1hqtI^|Cjq2!PXCXEXLpa;}3Q8>2zyk znE$uFkw0kz?cYM{{-j~FOHaG4pC~DP7yJ*(uDt)d)eV=0#axo{ysH=n!~a~XuN2<6 zj1{u7vOsAM-mr}A|IdYQLRt5p^_l@<{m@Hky_+b5{kOi6KWW2l{EW>lvhGhBHrsWZ zkK4D)3;O-vO&rg^w)jee-6;s-E2hrP>O>to!!5Uvb~g=*RSQ-|7wKFBT-s|J%0qb0xIC z|GSy1-rw0v+_$S?vt9Qsb3fPqzkakczyJGdMdLR8rt7)Q-y6GKkKpdx)v(#F@%`UT zck2y%)ouLT+imlL`v$(Fxs{LL#`k|W?5>;cEw}!ArMJ!fEoxu?D>6|ex`_oM;$Qsh zgMVY--x&Be25wOdWchk|2Fx)2Xln99^6Y)8(|zd=T+ zUqiw-#`-nFl=1tu%BGC(8?!F_agqM&BgKiPj9=Q-qJZzmC7D8gHHiNy)~{s9SQ#6& z-t^;p$oR)UCsCT1Jxn!a_@5h`gQ;)AMPDPrX8mr6jSVAkT zzfj}L%d7+sYsxgFd1dR0hGm&Zv-dfstP0Xure3Zo#GXv2WaF3Q?DA* zhtR%$@rTf~nBxw0`Q&t!0{>;Sn zfGMkoG=KMimOls?jBqOfV9J4^kZ(@opArc0Z{_HXd8VvB(mw(8#(c=w!3Mx7fZkYW z%I-iq4dBHWs_{?3e;{9eQS*6I)(EmFWi&oBTg4z}61~AI`ZYy7$ z<;%38Kr5g%5C((;4j=+(1Kb4!0D(Y#paF0P&=9y2XbfEy2{Y6V z?mA%V0`&mC-u)k76YvV~D)0vICa@XU0=xyh1H21t1-1djzz$$1z^S$ycpumU>;v`# z>jAo)9u~k8z*8#Ta+OHT2A&3<0r=KEqnpvpNG$*uh@6s~Vw_U^k%VYq2fViv*bTf7 z>;d)y`($CE8rkFslAIjD0B-yFLwO4SZZs5V4TJ&VfJ2@vR9o0PBiTg;&Qx2tn<3d8 z;OoSE_xxMn1i%;9PXQkQj{$t6{0HC&uoPfiaLgIN3|I!}0)Roup9h!)a0YS4FeEtB zIOTf*y@9?!KmH;Er_3Or2jB!;KzpDA&=KeabOu@gErAdq6le{E1N^;_KL7=372wZQ zbOV|Jzd(Er;P1^80Mmd6fEhp`FjMJ;o*|JBOadkYQ-CZW8^{520Zy-UU<|E?0)x@7yMZCVYG4iU0zVFRtWCOrgRvH1^+m--RflOc*^7aE?14n`O&+Alf)$v~hY zictIm=o!GGW08&nMgpUO-T*feVm(m6$&YKn94?df-4B6fm)ZYmfE(btkOO1`^g#wd zM~9#sO=%7^1?mDEz&fCn056~-;0gQ=IZgW<_zXA%d<+}}rU7srC(g#zkEkolx<3K; zDR3P40{9U)4{)^30gSV60p=eAz64$Y4g=o+T!M}OoF1Ge94U?%dFGu2P5|ElUjp9) zbUNu-#x32~7@#YE2G}r1hm+jmE&3Z|zXF`()@6q+WdYj6vVQ;^X_lw12Dt~oQMYu< zAZ_R)Zmmjf5OOtPXBZ|$pqzF7fFD2~*9Lrnsz4Q>GQe9)Z%`kg7ElwY0aOF31I%aa z)B|`m1m#LZK9Gan0GJLzeNayCI{{9n29PxdWw12^*!uwhb;MshQ-8slQu2{?>Kx`TEDSh-cH)pJ(Bje{NT4@xhT z?gXvv2T-5J^#y1M%TV9SC*MphZ`?Ph$v#i1{oFTFUlz(;uRc!6$;h7sa23f1xC2fA z#slMkJRld~GRM#;0KFHuU&YS`-iO2kKp`*#c<`$9o;eWU3OFeHO0}~aYf(Y%8V$Xt zHR!j~Lk)=tZW$aJq2K#fLC%aH9Ru3o`a; zD7-1>JdH}XnLS<7@V@)k1ogVdrnU}t1alqyNWM??!?MgXYAYYEBkY}Zo`X#t7LL|i z$=1)P;p#=1_6#cHSkpM)5N|c4-uRkOY8ebGu*1puPzd87c|#%U(Antc&$Rpj3L(L* zsKAk^ik!ChWPZ2cj@dqXP8d5fN1jAc^?6x-4!W~aM$SP?o1xA@X)^TrZIMGp)P*{# z35J7r%1r3_9e@Hy;NFeTU+9zF_9G~S24fJga?01|sLiyqP@q9wZ>sH2i`(fz8PconFtmf-_;dDc9`336rv(BKa zwC}gG>n}dJ1`1(tID#fy2BAei>kzx8DJP3MfBZ{46k4HYt+4oC?$YFW=#q69UH+L3 zAARb2Z7LKo{J|j(<$_#|n*6O(=BDj`&%a!mVD=f=?6b`-zn-V|z?*I%^U3xOFhz{eNtj_p48h3@C&cbHqA2@9Pt<)ZQHM`(C{h zh(jz><>l`A*Y75#-4v-Vfaji&ejt9ukJMk0;%;W$uD0HdRB|dtp@SSCyL=!I9Q! zdK-P-J+x=frLWEYVh!sg&n<#otK?^ERNrb>Pk}1xCfV;fH4yI^?pO?GY>8me~)HVg$R76NfFdm@1YRJ!@Q+;gpYshDpz}AVEden6%IZc za`y9*!kVvaxmfiH3-Hx6UCU0ZIlKv4XDNC%NcJg3M#?mDr{(me7~Qe*Ws=GA%vC01rGL#a4fxD4tK$=69H$TJjfmKBzRna zbKS>sHC7g_K=sGv#TA$$=3#*ap5MmRaV>cG7gG=QUX%$hpi?^Wm8)J*t6ts;44J=m zT-%^~fB*Q)?X9`|aC(K|HnWMm^a5hEnwRu>Q4Pg+FflJ;D{U#Cei2nh%3UwQvd+?L z4LD>+G=mvYbA1q%G8x=mj)wocTfe+wEk|=zftYgQ_{k?8FGul;$0~BQeVpN zL3&w#y8hP0FJIl!~)7j54t(xNg;a;zf?>qXqx^FYS^0VO%ba_C0X z{h=JY3jRNezIdW9gtDjU#!xuR;G`r~SoJP$@{*qwdxrT$Zu=0!x&EYvrbrScHp_3y=gCT zh2{nV&#seGUV_=yNrru$dz$&z@m^XME)BtLPa7=ZYoVZ?kvl;A%OPN@!Ge|@pBcWf zTxDB{o^Q*i*1>q|=)|{_Q{5VUYinPkU>&ZQ`f}T4t;>!5rX**8j9rI5n8z^|ELuKw z%qfqC`$`lh%V|(hAD45eXC3F*v}$8au&?k2y4Ba$<+NRD^}FJ)2k&p7iFFG*y*fuB}L?k24iMDGowVoI(c%-(V}J5YIVC%k`pS^ zP}I*ls?x*T*=&>g#Lg0hc-d#ST3xPNueQN0JTS-1g{#*D*x^2`R< z+E7;b4^)Ds>p$QeGX6i%>?XI6`$m4syeDO4#D%SVJK1z2=AKdB@A`qhQ5G@K-;*zF zw4y3j-7AAOLAY0T+XUfYISIt3HIZvJsXpQ7IvA^*byk@<@eu>o35|6h@0nWAqwi8Z zp!EBWA3DmfH>siF*4d2b$J*D-)E>ndO~d$O*qwE11{T(U5ige|HzHI96=d zg!`W*UE~SYq_5?^Mup#oTW3S|n$UE9*xuEbO#KKvf#M#NOGpb<$YDDY&LanRwtU!m zyt{P1hUGFmT5f&~-;HAa^^KMfL*$w{M);<_wD2JMbLTzy| zGWtz8X;h3H@;dHIu6_`yZahGt?z8gI*VSqM)?t$Cw$1szg&2-UgQ?-hL&$?YWb-%B zpTua{^$m=fbxh><&du}hoci(!^t@#-?%(lMK&-K*y`pvP*O`H^`IS+7{IwyIKE%EIRI|==GHnaGt@M=-Y{4z4bueXvu@{Fw&>?yl?MBp~ zj*0{1DQMu<0V}t!pLLRD-h%my<}H|e)KJ7WspxBUwZJyI%dPV)=T4k7a?q5?JxkQ| z#Xd;xc}p$lXPtIgZ?5gj)>YRZgBBKRJp6_4lxN<;bZsgtybZ&X<7E4{Ri9w%)XTkt zR_uv7KOc?5oDc?2mqEt!*hR1U8)~#)fGss_kbK~6HNek2E3)AJULF~3?|XW%ew)Uj zHXfdRZ3hO)L#W(#e2{!>yXqq=y@UPdylnE08fz;XFE&nsST+KO28iI?xa1A0fi zJhdD07V)zByWrc$%jP>!cEr1CZCgydoct~_Z@%l0<{#6zW1>DEbDGlTU#AA`&M8xTeUqlMBY)18FKyg#yaD3()kbD zxL?Q`#IER%*UFIL@?n&<8uqsi3oUkivh$4@bJm-|hg-JN?vjnRtE~;+v@*wFq}5mB z%M4$$x6hOkAKrm`!v7xhrxT4ZSSMTTM6h0Sw~ydMhrZiaFQ=!^$SF_`yXKa!D_F-P zd)4av?Yvdvx9Xdnp3_3^U^~~`@^ys)@((IpbIaEi^ex})$m2407nHBL@9WC?zVEB< zmvg9h&HY{1yC~m>!nOBzUE!MhyPgv&>+D9|*WBNA1$}?FMyiIKvs>*`YFzN$lQmr3 z<(T)?zNPXwX3}$yT07i2m-I|j&!H1QST7C1&VMk&!+b5Ph@(;_F?f1aW>zBpDy8hjh^}S?C*_0gl2+G>V z=g4JyFcYuhJ+ltt8yH+wK9Xbhsa;20eczLqnxX%iM6YkNz4Co?j&#>$`pHm`}9{a?L)qW$m_| zjQ-vq5w=sESm{#xkBnaY93y|(r?!?|_N&cmwC8!Uxh=-!jSPwi!Xe!_>p3q)2JKgC z$*leA1C_4K*!a_abzgh;70NAwt|}d*e@_{lH|m~@%;c1yQTbUx`X5AI$pvL*<)vn3 zB&1su9=J+_r^o9hgP218=)AnF+`C%H$a8A-z$=x}iz@{|t>qdYTZ4^TtJ`{Oo{8f| zj!ennx#e>05!GMzu4B_S_OEMurmo!G-sZ9KMVIY4d*GGE{o3_8*(XXF1uci*4=y15e_zf&c&j delta 33500 zcmeHwdt6mT_x|2Tj<8WuQj?n^-c7kG91J^0yd@ysQo%G6;V1|K3V5mXplPXPMN>_g zn%B(K(yT1In5iYCrB>G4&8#%F%(Seu)Zg>$3y@#ytv4@!{M;X(vu3SXGqYyRn%T3D z>@)X2s+HcO-5=5B{_WoeH-6!TNyE0Zd*}B>V`^;bdt%OgqaJ8>e0uYbcHA=g#=`D4 zh1blov{28%J5-%flwx;LF_U|MT8dIS!9AidBQsY?tDz`$!1o5#K=-3G^FIW=3bZ5S z4M2^&Lo81orMHQuEa>lsBvqmU>;88{C z4{%2#Q1^IuesPiFQQn4t6Snvm!3uU>p^fBlmqlIK3LKF;8}49K3LIO z@XbIU01XB0Vj408wXsLrL0f|kfII-SJ_d{9bQ%mBJYdo%K|{cA0d49*A{GVMKvPf} zl892|-#{dgPRPm2%FGy-wHCo6P{8~`f69O8}(8QR+$%>MVZn5GOW(dv)rOO61F~)elD67#> z8y;qG1I5}Jp`O{$q0#P%?#v9-kqj4+cY!i43i92>2mu9gkdqlcGQU0Ktg|qqI6FMo zJ?UET9PUP-Y`Y#Pjq?Fz`3c!Mnc1i}rwA>8Zf#+7_K}vlzNd1&OoSnDe?C#Cc;R6xbzocu{eg_D%K!PEWhAq#|oXOE|WYM^WwV&#Y0!q?u|^GbwK zUw%e@K~9#UxQj-VV8E5QXrmv^KQ5%Ga3kxu6W+J59a- zl>HxU%6ovK+=$W`Q=thc9ar1re~vUN_zIK_yaP(dZ2)D%OU?ZIO@2&X-X!*`1kUF5 zn#1UCq|j=HdWz9|##&)`9wMPwxvit&H9yGdz2?^$trxk+jOX&W89co;DI+g02P^KF ztl02u_e5n}f}x*Rkd;w{z^D(sy3ng->br|digWUc6r0I^-AS*4#&z(p#;$%CFW55-Scjqxu zHiOr||Jucnk1eA4in6k+q3_qt@T>w#16G2v{>7jy_Y3qi4jh+a798U)&MwF*Qi{8Z z3hxL{F7uJy%89iORnhaKk_?&v%5^Qx zndvUXz2lKo!y(o!s1x+r@kp~=;kcZlF&T>Tc5kC&g#|^$qp%o034K) z!acDN-7He(r5gqoPbzd{MN>is8+=i5MsZ1zyXaozbEKz%)`m+;i;Rvd<8=XIKV4kw z+t}A(*0W@Y=qgx|QIt+5w-UXEL(iXHfXi0uy4p&ld z@Qep*cz-jkKM2Zr8-iYOILBp72p>_9HOcDbh)Gzuk@pGo;BF7@_?L9WJZHgd|39pl zVqdL>o^$($=+gV!8I*qcDaY`e72Zjs4SAHA-yD?w%q%M604o^?6_)D@N`G7V*fr?k zHgSxx!y9JM-laW};2okZC^s-yg9d`0%rodd&;alipbbG^0Oh<{V9NbaF$cKsSmdw! zp!VjP>z=H)%}X2%=qm~Xvinbc_^apded}~RwJdbc!WxS5dZ|Glhn4ze@*`v8GDpTo zcg*Ys#VmX_5anSm`(U^`Ud)L}(8`eNZ0N^0)Lmj$Q?7M!VP*=FkE#KDcWdy4nD6xR;vT zy=I=B^=K8~dLU2LYppBFTe#H0LTl+#mx&~N#)(-iUD^WN^;n-O%3>Va$KdFN8hTq- zW2WPN0zdW(bEpHwtX3{{xhQYt(!NIy);E?4aj4xyQfrs}YTU*;3%|CVypZT7Qd=je z3x(FkW#0q7ht9VVv%tF%*Tc!%w<49Ury3!KoqB2_QUmnVPe_f{Q^OGH$$BahbD*!D z@*veyPrX%{suQFr{dHLeQp1?iHX?;>2~BP6u$>AL744jAZ=r>|wAq+_^t+wC(Dr~c zA^?ioRk&LkekL~(95rjO675NF9M77 zHV%9JCUo?iMhV(2NHNf176xwx<>1gAaEHLrNH3PrLc=OKOo?1EE5@a*fQ+T>!vBVN zA22i@>W!e@)QVU}(m-%A$kUrw?-J$hUD_T~W<=%9%@n1#p@F7Xf-}tWkAflKXb75t zmqW4gnO;UaY2auwT7}c3nP)`byWq@DBTs8#I7FY*S_(LhPEApk8t(&!&3Ws?@qG(X z5$DvJ;1R^M85Z>i$GL#g;Ff{w0ZJG5Qk==%D?zd0NlQ8^Gz9co{pIbG@uk>qq~ z<;bBas1t?IOaaK2k|~su2t_az`L#$W|g{ z=pC=jb+or~OOZ;|%kHR@U4yl`kC@Y?lNS<3=Ceo{m7GM%sJKfk8=KR$lNS<(XeUxe zfktqdQ6LMc6upIKkTUdsMat0Y?l5KAy-3kx`uN-50*Cn+l3+i9)OGsIOn?g+vY2yi z9O`YNyt_+V4H*Ukqk|Av|09xmxa>X{`|I_P=#EsJesj1JDF%VD*lsa7%-0Bq7Kb40 zrPqNFRqqq!H@LLzkTEt9<}nU?O)O(ZJ)M|>TwjjV$)da`Z=+h0OFNDnt~>f_r(K6R z!t(kpKr05vQn0e6!~PWW^i||Yr50Ohg-0vhZZ%7kC%d>nrMR?TAZ1x&JqkxB7)gjL z+>+ejj9xKbmLSQg1`9C34}mil27iQoXP04*qDR)P;0${>Dc68wor)-ncW4JqO-u)H zP2q4OBDqXtfirr)3k%9zaO@+>B{;PA!J#{)KKg8~n~31hZGk3kVCB7CwtEuA>^@Fy z6S5FQbWIuLL$4W3e;~chGUBv9ZPVF@ajj>=|Hlg)%*`{ya3Lr$Inkl8Dqk}M8G_Qqwli8G5T=V=;N?I0xpixr@ey| z4btOF^M!jWV^q5ioY4{1kYCBsr;EWEqlO5xebhr#3~<_g@Cb>4$6lo$QqVxJ{Zp_i zf`e`J0g4_1XAB1xLM;q2Weg*hA6r3Bkvzz$t$;9DFTk6`kKphRG0`v5VVjU7eAArv zjY*0!P!F>D&}24386h(TTxGD^Dw2h7x>Ku@VyIv~@YVp1p3&>mR)S+&hzGQF!pzev zv)#~3BoB7lr=!9s-CfTih0#LMT_fYwUc&b#r*>^><#HF}u#HF+vu|?R7N?2|S@?kkdSc4|`~WSz#{`B`wR1---ly?H1nbJo3%zTRSO70XmENZ1!i+;W1y$0$FNkW2c>Ohe^ z!l`YBAV%+vKiqs`ps0Yb;~>LA?tSBZz|d7N0&`<0I7U6D=pcu!cA7p`S!u>x)2D)M zX_`pRa%#)dt!|>6ZGXC`fUwnIL#S{IW^)e~$!@28K7`$L-|j;SYXFC(g~QhLCgD30 zd$XIYnT$!R32^ith7)sO7dQ@*u>@*EDwll3b1b+h!&La$4bCV>&prdrTpb!a>_@@j zNg*OZYc(Iw2Ux_zM0Dc!oxP|W>JCc zMIb#B2zo zZn35|9BRK695$Q?$PGw!&@G|O--F|vhFt@20~>DS=?l1hG`P+p_2vZIQ^Q5_7^m&m z;bQg}r{>7040ZUe0NnL@CotJ#z%dZ%2NDeK}G+ z^wbfgdg`gzOe=R1Qig03Qih&)mX(`=l#wft>ZO<6TPbVh#$u<-N{}*gHz8%#GSVvB z2PwlAQ7QWbDWgQIQC5jDNa1l6Hm^s@X!k5qhF(gxDboZ}bS?rG_q?~jaUScBr?%7C z!nee!b;8#U=0bt^EC$CoQv~8TzCR%#wn1B_gx`s=AKg}O^n_Fkm)TI+a0%cp+*6{Q|lL0uo~mq#yvL?x|(6qX+Ss!ml%u)-*$SR?d{ zl=_&Wx*YROHwYoE^I4$0{+t@^>k6z0QKuI~Z0XnEp)?4grC)zV*>ePsevz_Vp4q;V zXUKI*MZ|=Dk z|C%WWwZV+}o`zzT$A|FH=r;hWZ8p_N$!{_F^HJt+1!(SDrXDHza+4k1{h|)1HMdCcn+n=8y_t1tD1rDYbugn zgN!C7f6=Mu0yg9Y!<(D+k+O%aOrDg<)+TRJ4-+id&Qu6D6-YU;Vojcu$vBfbOgSl& z@h1OwC{;Te`c6GTOFKc}4cgVLs5+&nn<=kOZDP)}hGO0{A0mtjH<()IqpEmyT0`C8 z$)?u%C9l{=7)(eY%IDQhd+@vq4$WJrw>IO1*nc zz3P;r`%L+LRs;8&g7Z->WsjQqq)g5=c~bV|aZ|p~l>c4op(4vHG7FxM()CNtd{Vmf zNl?mHnsQPmSD8F1J@B+Cf5xP1Ou7~nmq%fOY5s``FVaxZT_#V;irzE%^HCb~A@cn| zzc%$qncQ#k=c9HmxQ9)Je?wWtw`M)nDMjDmgB|$Z%>M)Bf?Hj{pgUnI{uQOl&-kbf zYD4YxKuu7}z1iA1l&g3nQ(m3w3x0J03tmEAZ~q@P$R4*bdmL`|IKrfnp!lam^Wz*! z&%{8^pyi)O@rtz>?N<{R3h_|jeD7i^UP#I+yP5TN)Av6#1y^GeSAn(zF2$zbQ*GCe zCiVXxtE6;Q_02vr$kUY(HND@yMhn|_Rc<*r{Z zhTVTPN=0t=d69COUC>QGx7;Vpo{!aY7O(lFpKK&M{W>o;Mn;Hsqh*0Z|cT!nwYb6z$#^-1aSRwhr%q_xMl z=#{-boT4O~ULs`x_X54L*T1sYXKXA*EO2IB+3Qz-HsFM*zQ?Dh$Wwl0um2a%4*$RJ z_1B$z&?{N2-kTzN?)4M)FH-O~7yZ6S6TgCc9^5BF-Ipew{K8MT_ob+xiM8O;_xXti zU#6&gMaGwD!skmru@&4t;r~^dcoAI5S1IaOViUORulz)duT#|hV(iyxBH(L3@d3DR zMA-f`u?^ge{VD1pu?yV9{eB|$K#KaUn0g>hv_9Y`_JcbjqQ6NKAAx)5n-uk^*avRr zH-4h~!4&nFC_9)Y;t%?X6X1RniHFj}L2%0srKl&wF>sF@@)H9Or>MV(MTgTw&%@~7 zw<+pL(eGRI58U(MeiQ0<=-;>K-*+kMX|Wbu`giExkrdlmMT|HyNcbE<2alwv_`m({ z(Lrz}->2ZOAUA=_{vI7Xnxfjp*rVv+QFIWTw+Q{ zHB@B$iUIr;{R0;!{7<5P;7U%WsLjMCaM>r(zf&n{3o-T-`gaQb1J_D~{f7R5oAFzU z+D7aGH}N<0@Ank7t(f{d`u98f2QFMhpGN<{J#;z+e~-Bj+|1MH-O{iIz5+fnvY!T$>WdGZNTwW(?H zNfiRO4T9_CS_;x_5HzR(flFr8fWW5)1Y0Rcl>S~2yhuTb7X)49CJM5>AZTHSpt~Gv zhakWX!3PxFAj4`xu#JKlH6cinyC|4g6M|T82vX!!ZwOj@L$IHMR2l69!ABH4NS1wl|GbAnK^SZ*RIk%7S=F1ag2 z?duu1#G7}`RBk+R)%E^;v~5+M_a3BcDN5-+Q0&A?DYM>*{0s%~1xcxL0c0M&WcgPW zvSI7x${(>4qA_gv0?9m;y|doT9E<<1(ac6JzRZ*7eeoOli#E6+xU@a~qcNUK=juN; zY_{vUyzb|h-0`k&CJV*7+r*CQ^>6MaxEFB;=hr3{!QTv zP}Wn~yMNo0|IHZAzklh%|E*!OUC-6V+d>y=JpZXNp3Bv+*{(;AYU^FZ6#u;*4YXdH|FD%A=$`Wl&m&`D>)rb0t*f?S|5oPV&u(1E3jbk! z#{Q4N@W1wip0R!epm(_O3a{lY1=qunaVKrH@kbft{^Y3q!52|8Bw(c z{2dv~T0c2ZE7I7eQ)azPn+lm_j4t!wHwpfa@Dj>Af3W5fHf*-*`E%D?5@S4<*ZsAu z{okJk$VK*o=kGMk2)2GfV%l}a6ytQd05Xqqfh+un_2CyJE>KVYVZ&y-9`lDeEHBX2 z)^B4}-bHMsr)AMzbIZLJ?#H3Ps3)ro(x6#2kyGyUhr67Bwr>kcrLH|GZ6om)BRVWeSHIR zvE9$))Ta=8|~9WBz*B<+=m@VgL8P_L#x-cb+5Y>2vfv zdi0+oyo553@grB4?GfB_?iT_V`FZbLPwV@?bA{&_r;9Zt9{pDtFPr-#G5;^?Hz4}= zf95Z(T@Eh{<&R=stcFEmV5I09*yIYX_~1$mT#11zF>oaYuEfBV7`PGx7bFG(eWRxH zZwK)^CwIvMcd1T3%qnNj8W+<;kWCGK#m&p&`NxL(m+7EGO&z{3#1~6>-CV64z97;s zzR}LQ>_7uUq}*c4_zMeoy;g5uf7P9eY#`WF%z%Im@b?4wrYf&2voQV=OlfJ#`1U)? z^5v7~%rgAxd1hmuu2e7+S2ieE0kks5UG8IIDAnYc<#J-(XDU(u)sOofaFhXP(mQzorn zGH3$k7l1u~#4H?!^iKc-hwtyxz^1@=04sXTlr=*-2jDf|EZZFE9=b$P7MQXY;BPQx zeD9z2wd43V;0AHXM zP}`=+$L~=SJ$(Cr9q>G`9(WOW8F&SF6?hHU2y6m)n8g-gEAS?;4JZdVPu>Q$13Q3s zft>(U%9!(WDAWX%H@O^hB!-)w+k%`lz` zaPE`c z%>d^N=SUL3X|WY}4tQRc--jb=RwB6ySOzQr9tYB3S2{2lSOu&Go&=r(IL$@@*}!lh z0~i6s0`Y(Y@CG!X9nchL1{^`XrNA^`GB6Ifh20&FL~m2U=gqw7>0(107HSBfoFiHftA2$zzy&|5(hK~GU@LADA*V12W$r3 z0GaLn1T1?R;MlP|b-j^S6R-o8u3An16eEy|3WR4tXbcCw43u*y2nYn| z$pD}sP#3rg@B_HZs{?us&;Y0p)C2s1s{!UW25kiJY6dzBlzb=<=E27d2%3O$vbF#? zH=04#60{Y-g^JcQLi+%W)>NPukOFiDt^>Fza&hD$nFJ&NTo8H!9K!aXU4R>aZa`PS z!&R~&GNVDGfJh($Xa}?f=#_9#dd6yil~CVm*oCx}$HuLOInlW?v0=8udOH9#wj+SH zJi3re7ngAcRu9nb04ujDwJc`^$p8)R4@xgoH-f$8{et@J9p^VY!ZOsi^2yVyqgDCr zT(!4n5Yo8E{H;3kq4#HXZiHQ9kzWLi14@92zyyHnM)mY`@OJ>yRNRQCB2fx39Hs!1 zf!hJDZg&EVqlpp;T*G(Eryf(gHM|N%j*ssBK$E+^dfleRMnpwKAvai#nWqNkG)J;F z6oMMG@Soc3#_cvWIvyG^@%kOVE^=nR{KW2n3A@^vInmKdXOv;i^W`&q4s~gfVN+vJ zBs#`eps}cxW`6nAEvaE%{cS25i*P`Hh+H&JO~tEYM@dTL_4Cz0ypWYPUv016Bkv}8 zSZXeh%VrH%A|94$FzTaaLmoj>%FK0Thi^jOpnHg#BZM0@&Uq`ZX+bi4)y z?QGfO!;AOf-9aeCu-U0nJg&A6o(+Y1P)O)8>iunNuYN;U&^te0?qf?U zNG|<(#tXxvuOD+vSMNxxt(Q&;9(lLUl$pIGaymprcZi5pR>;&vXvsP;F8kf7?MMKJe6`7XFv>%hMFL?!v7i%36`1{P| z4}A2_*ao_K2lmN2L~yzLNLjc4oEnUr_85Zp_{A*U$l&uDiI%YOmSIcK()%(2B*Z%8 zZ|Zw*hSaPPL6c!HP2TGz3zw+9)EN2d5|}hq9%Hedver^`#5#m<`q}3f{1(t4AH|}L zIrFS^QNcQF@UaH#4+qV7B^L@&MiA-kU*iRL-6ZEw)jE&xq`y1&OotthVh%-cfH3pr zCMe*&$4^MA3XYX^mZ6|^P+{07k;7UI3;PCbVBF}QuCnVg*gQ~9AlWHbLOsMfxp2Dc z{ov%C+irk5rzF%*`pPessl9AJ)RqxXr~$#&nT2or9BP@|y8`pw()5-YPhk4l7*6M%Cnpx;gSPhD zjDrYeujR19I+$>Mz}8Q9?mY9gX$6*$CepK9Z69u(WLPw-=b7i0HNPDS<{+FK@^#gR zzqU7^~sL~1v=_-Jffo`;_xgb z=R+~rI_U74sKBwOy64W;+toWaMDAjRM!mt-L5IHY#Cc7SP*Dauf>wfD^`BC5{()p*g8ma+o2At zO4fY-U6tN;>AwnLoGiPO43?8tsiV{oxo;H;Un_qj=^z`dMqajDxls+2BUYVf{zZ!*oWa`uKnRSL@>tmlEEo%6~dJJToF(VqusZc=ek5TW>=R z?$cQCtwS7N>z}jPcILhNQ4ww!T#k}uqi4|IRypGtH8t2gjIq@BP+B9`!h24cdYBe_ zWY`*5UULmB*V9$^10&0JptUSqqXvXn$KwU2__^bHc zUlE7240>jAZY=MJF__I*Oh?L_pM`_0LknM6^-=uv+na3RExo<2Fin<00oAXho^=Fd zX#5?$Kggfnq)P7zxfcqt>(F8y+(G=Cht?Y~@ArfCD}&_?XIS2(&ikatFOL_ZqudH%L0ciC>83|z?kgxWQrt{7GdkS$pyht8{RvVc~g~wbs%L_m$|pBuUW@dmGg6?yk|XJP+N}O zrPi;hH`GLKM0K&&DVLwzF|tSW!yn^E4J=E{gD^`Mub49Wd!H7&t8xZQzZc=X0>m-5 zAiEaTZM3EJp*~d#cgjR4sB`5Ik~K1Mx7F$vc^^b^*5RBpy;f!4;(y)5s-o8Mog(48 zW~1lKomrK0I!b>2B9=z$z|UX$Gh z@xu-qAT;6*zX&jS12kuRF;XURGnw z@_!N756VV}79M-TYygAq5k3`Qm9KDAF*c^sM{)`^rky;`q+ z=HRUb`n=We&$(S?=hxH#TX9!;(`#y}ZDm(^W(Rz!pMi-XbPYQ`{#4h;SLt;c&jPXz zmeyduZpJ3H`=l;&U*6Q+Pgl^lndaI%bfX#+yBJy;s%aE*+Eez_H|1tEm`B#3o8I%v zwl}-uz+y883z1P?RrGe`=Nr|Xwk|iwHLt4yaeuOH#7@9EgR}m`DZ$MbelgFcPBFIt z2}$zI>+pef%I444sCNhFgyJSVB`yNnBz*OiBztXw4-CynJ4DrzLzCqXn^E36opZ{9 zyO%|NorkA}Ddw)}mt-081}2eR#=fCWjk8YYT(|A9ZzIJmjm?HIC(HvpOUL(r_?|e| z*E{qoupQD(`0fo1X=E?iWHW};I+=5W)}wb~$p+lSvCzizsR=8|fX(V$n`xG9LND2T ziyCtt*T6i4L5IpyKgZc~4;<`#|F2wY*h7X6kPkw`T)=H$e}5CsvyKU^yI_W>n7W&xi2{6#IWj;-y@ip|7x8c(KD$OK zg#+aj2!pM|LVHKPu{f||bA1%!CKlu7E!V!KwhysR5gjqM`SqP^)rr>!MZYP$Iq2bS zYCwJKIMI`SO`mVjc_D6(J=0{nZE6$SCuy=bH1NwRc(A=D6cJ_}+WA@6#7{r#cMAJB zO#2Az^_Ab!> zZXkbSy8IqA#5zi}*7#AL5B8pE%i5#$N9(+F*{K4W!!r=`o+ zAhX?@Es+B)edGa0xTP4yB%t_X;h4D$q-qw1066|su1h+)Z2dA)6uiCFrCKfdvK*- zn2dP`n&+5eIZ1ARN9|zrzrD?HdVuWxuG-r&246g^eh-0YI5j|i@tztbgLbO@t0_!= zACKJscidNH7+;i}_jVr7M~J2J=uX`4th1p5PMwPGUlHfl?^(LSd2i=>&R3DrxeEbn zoj2{*u-l;pPmh1As;quH4^*4TyLVx!KJT4euc?RJ2!&YdgzJ?(a&8{yYBjH_qVwL# z^`iQnynYisZJnH*H+=EgJ!LN?R+ZQ9@PT-S8L}G>p69)}>opvTlK1ac17fYSx;O1F zd$L}`8-A&(>AW|0y{vw7uU}J7$H`xIV>QBPwtG(+zZPqcJlG~54gOCKfsM|U!MMh$)yWcf1Y=0_`qdV3f9@P z18X0e;U0YJ4OKZ;kCDAu);g^=arfTM^M*VzsY=5-&$iW}w|Cr8FLicR&ag3Z9?GU$ zN8mp9*v1b(J+NeMm4<$XE$-|cpYGbVuI--tY-;1N`hWVBTJJm5c;L0Ekx@S%s$1#7 zHM{Z67VkT|<+UHGJ>aMy>orX|ERk=um38@)<!sEpw?X9CdszOCL?>;eAd_KYFlELdsA#{{~vJERyhCw diff --git a/test/js/first_party/utf-8-validate/utf-8-validate.test.ts b/test/js/first_party/utf-8-validate/utf-8-validate.test.ts new file mode 100644 index 00000000000000..b6bff5513a76b2 --- /dev/null +++ b/test/js/first_party/utf-8-validate/utf-8-validate.test.ts @@ -0,0 +1,9 @@ +import { test, expect } from "bun:test"; +import { isUtf8 } from "node:buffer"; +import isValidUTF8 from "utf-8-validate"; + +test("utf-8-validate", () => { + expect(isValidUTF8).toBe(isUtf8); + expect(isValidUTF8(Buffer.from("😀"))).toBeTrue() + expect(isValidUTF8(Buffer.from([0xff]))).toBeFalse(); +}); diff --git a/test/package.json b/test/package.json index 3ab8d5143f3bd3..b2bfd85fb4457a 100644 --- a/test/package.json +++ b/test/package.json @@ -1,14 +1,15 @@ { "name": "test", "devDependencies": { - "@types/dedent": "0.7.0" + "@types/dedent": "0.7.0", + "@types/utf-8-validate": "^5.0.0", + "@types/react": "18.0.28", + "@types/react-dom": "18.0.11", + "@types/supertest": "2.0.12" }, "dependencies": { "@prisma/client": "5.0.0", "@swc/core": "1.3.38", - "@types/react": "18.0.28", - "@types/react-dom": "18.0.11", - "@types/supertest": "2.0.12", "bktree-fast": "0.0.7", "body-parser": "1.20.2", "comlink": "4.4.1", @@ -30,6 +31,7 @@ "svelte": "3.55.1", "typescript": "5.0.2", "undici": "5.20.0", + "utf-8-validate": "^6.0.3", "vitest": "0.32.2", "webpack": "5.88.0", "webpack-cli": "4.7.2" From 48ca2dfa7e9aff8139b8dc4520203d8b59db8704 Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Tue, 4 Jul 2023 09:54:11 -0700 Subject: [PATCH 02/22] Fix #3497 --- src/js/out/modules/node/worker_threads.js | 213 ------------------ .../{utf-8-validate.js => utf-8-validate.ts} | 0 2 files changed, 213 deletions(-) delete mode 100644 src/js/out/modules/node/worker_threads.js rename src/js/thirdparty/{utf-8-validate.js => utf-8-validate.ts} (100%) diff --git a/src/js/out/modules/node/worker_threads.js b/src/js/out/modules/node/worker_threads.js deleted file mode 100644 index 0f9dc1cee6a174..00000000000000 --- a/src/js/out/modules/node/worker_threads.js +++ /dev/null @@ -1,213 +0,0 @@ -var injectFakeEmitter = function(Class) { - function messageEventHandler(event) { - return event.data; - } - function errorEventHandler(event) { - return event.error; - } - const wrappedListener = Symbol("wrappedListener"); - function wrapped(run, listener) { - const callback = function(event) { - return listener(run(event)); - }; - return listener[wrappedListener] = callback, callback; - } - function functionForEventType(event, listener) { - switch (event) { - case "error": - case "messageerror": - return wrapped(errorEventHandler, listener); - default: - return wrapped(messageEventHandler, listener); - } - } - Class.prototype.on = function(event, listener) { - return this.addEventListener(event, functionForEventType(event, listener)), this; - }, Class.prototype.off = function(event, listener) { - if (listener) - this.removeEventListener(event, listener[wrappedListener] || listener); - else - this.removeEventListener(event); - return this; - }, Class.prototype.once = function(event, listener) { - return this.addEventListener(event, functionForEventType(event, listener), { once: !0 }), this; - }; - function EventClass(eventName) { - if (eventName === "error" || eventName === "messageerror") - return ErrorEvent; - return MessageEvent; - } - Class.prototype.emit = function(event, ...args) { - return this.dispatchEvent(new (EventClass(event))(event, ...args)), this; - }, Class.prototype.prependListener = Class.prototype.on, Class.prototype.prependOnceListener = Class.prototype.once; -}; -import EventEmitter from "node:events"; -function receiveMessageOnPort(port) { - let res = _receiveMessageOnPort(port); - if (!res) - return; - return { - message: res - }; -} -var fakeParentPort = function() { - const fake = Object.create(MessagePort.prototype); - return Object.defineProperty(fake, "onmessage", { - get() { - return self.onmessage; - }, - set(value) { - self.onmessage = value; - } - }), Object.defineProperty(fake, "onmessageerror", { - get() { - return self.onmessageerror; - }, - set(value) { - } - }), Object.defineProperty(fake, "postMessage", { - value(...args) { - return self.postMessage(...args); - } - }), Object.defineProperty(fake, "close", { - value() { - return process.exit(0); - } - }), Object.defineProperty(fake, "start", { - value() { - } - }), Object.defineProperty(fake, "unref", { - value() { - } - }), Object.defineProperty(fake, "ref", { - value() { - } - }), Object.defineProperty(fake, "hasRef", { - value() { - return !1; - } - }), Object.defineProperty(fake, "setEncoding", { - value() { - } - }), Object.defineProperty(fake, "addEventListener", { - value: self.addEventListener.bind(self) - }), Object.defineProperty(fake, "removeEventListener", { - value: self.removeEventListener.bind(self) - }), fake; -}; -function getEnvironmentData() { - return process.env; -} -function setEnvironmentData(env) { - process.env = env; -} -function markAsUntransferable() { - throw new Error("markAsUntransferable is not implemented"); -} -function moveMessagePortToContext() { - throw new Error("moveMessagePortToContext is not implemented"); -} -var { MessageChannel, BroadcastChannel } = globalThis, _MessagePort = globalThis.MessagePort; -injectFakeEmitter(_MessagePort); -var MessagePort = _MessagePort, isMainThread = Bun.isMainThread, [_workerData, _threadId, _receiveMessageOnPort] = globalThis[Symbol.for("Bun.lazy")]("worker_threads"), parentPort = isMainThread ? null : fakeParentPort(), resourceLimits = {}, workerData = _workerData, threadId = _threadId, SHARE_ENV = Symbol("nodejs.worker_threads.SHARE_ENV"), WebWorker = globalThis.Worker; - -class Worker extends EventEmitter { - #worker; - #performance; - #onExitPromise = void 0; - constructor(filename, options = {}) { - super(); - this.#worker = new WebWorker(filename, { - ...options - }), this.#worker.addEventListener("close", this.#onClose.bind(this)), this.#worker.addEventListener("error", this.#onError.bind(this)), this.#worker.addEventListener("message", this.#onMessage.bind(this)), this.#worker.addEventListener("messageerror", this.#onMessageError.bind(this)), this.#worker.addEventListener("open", this.#onOpen.bind(this)); - } - ref() { - this.#worker.ref(); - } - unref() { - this.#worker.unref(); - } - get stdin() { - return null; - } - get stdout() { - return null; - } - get stderr() { - return null; - } - get performance() { - return this.#performance ??= { - eventLoopUtilization() { - return {}; - } - }; - } - terminate() { - if (this.#onExitPromise) - return this.#onExitPromise; - const { resolve, promise } = Promise.withResolvers(); - return this.#worker.addEventListener("close", (event) => { - resolve(0); - }, { once: !0 }), this.#onExitPromise = promise; - } - postMessage(...args) { - return this.#worker.postMessage(...args); - } - #onClose() { - this.emit("exit"); - } - #onError(event) { - this.emit("error", event); - } - #onMessage(event) { - this.emit("message", event.data); - } - #onMessageError(event) { - this.emit("messageerror", event.error || event); - } - #onOpen() { - this.emit("online"); - } - getHeapSnapshot() { - return {}; - } -} -var worker_threads_default = { - Worker, - workerData, - parentPort, - resourceLimits, - isMainThread, - MessageChannel, - BroadcastChannel, - MessagePort, - getEnvironmentData, - setEnvironmentData, - getHeapSnapshot() { - return {}; - }, - markAsUntransferable, - moveMessagePortToContext, - receiveMessageOnPort, - SHARE_ENV, - threadId -}; -export { - workerData, - threadId, - setEnvironmentData, - resourceLimits, - receiveMessageOnPort, - parentPort, - moveMessagePortToContext, - markAsUntransferable, - isMainThread, - getEnvironmentData, - worker_threads_default as default, - Worker, - SHARE_ENV, - MessagePort, - MessageChannel, - BroadcastChannel -}; diff --git a/src/js/thirdparty/utf-8-validate.js b/src/js/thirdparty/utf-8-validate.ts similarity index 100% rename from src/js/thirdparty/utf-8-validate.js rename to src/js/thirdparty/utf-8-validate.ts From de82004cd8e1eb8ca0c77aeee4ac112259fd0d30 Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Tue, 4 Jul 2023 09:59:25 -0700 Subject: [PATCH 03/22] Run prettier --- test/js/first_party/utf-8-validate/utf-8-validate.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/first_party/utf-8-validate/utf-8-validate.test.ts b/test/js/first_party/utf-8-validate/utf-8-validate.test.ts index b6bff5513a76b2..33469c970de912 100644 --- a/test/js/first_party/utf-8-validate/utf-8-validate.test.ts +++ b/test/js/first_party/utf-8-validate/utf-8-validate.test.ts @@ -4,6 +4,6 @@ import isValidUTF8 from "utf-8-validate"; test("utf-8-validate", () => { expect(isValidUTF8).toBe(isUtf8); - expect(isValidUTF8(Buffer.from("😀"))).toBeTrue() + expect(isValidUTF8(Buffer.from("😀"))).toBeTrue(); expect(isValidUTF8(Buffer.from([0xff]))).toBeFalse(); }); From dbd0a71a9b9b9ca38038d4d555c07a2d6bbc78c7 Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Wed, 5 Jul 2023 09:58:51 -0700 Subject: [PATCH 04/22] Fix package.json --- test/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/package.json b/test/package.json index b2bfd85fb4457a..5fecb838b79b5b 100644 --- a/test/package.json +++ b/test/package.json @@ -2,7 +2,7 @@ "name": "test", "devDependencies": { "@types/dedent": "0.7.0", - "@types/utf-8-validate": "^5.0.0", + "@types/utf-8-validate": "5.0.0", "@types/react": "18.0.28", "@types/react-dom": "18.0.11", "@types/supertest": "2.0.12" @@ -31,7 +31,6 @@ "svelte": "3.55.1", "typescript": "5.0.2", "undici": "5.20.0", - "utf-8-validate": "^6.0.3", "vitest": "0.32.2", "webpack": "5.88.0", "webpack-cli": "4.7.2" From ce9db1215c177ca5f14d97d49a828aad2af6c8e3 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Wed, 2 Aug 2023 20:26:57 -0700 Subject: [PATCH 05/22] remove this too --- .vscode/launch.json | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 71baa8cd04c112..4a4cad0ef6ddf1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -143,20 +143,6 @@ "initCommands": ["process handle -p false -s false -n false SIGHUP"], "console": "internalConsole" }, - { - "type": "lldb", - "request": "launch", - "name": "RUN THE ASTRO", - "program": "bun-debug", - "args": ["/private/tmp/scratchpad_20230731T231120/satellite-singularity/node_modules/astro/astro.js", "dev"], - "cwd": "/tmp/scratchpad_20230731T231120/satellite-singularity", - "env": { - "FORCE_COLOR": "1", - "BUN_DEBUG_QUIET_LOGS": "1" - }, - "initCommands": ["process handle -p false -s false -n false SIGHUP"], - "console": "internalConsole" - }, { "type": "lldb", "request": "launch", From e30016928a9df8c168713ea78145e8b1130b879a Mon Sep 17 00:00:00 2001 From: dave caruso Date: Wed, 2 Aug 2023 20:29:14 -0700 Subject: [PATCH 06/22] yeah --- src/js/_codegen/build-modules.ts | 21 +- ...lModuleRegistry+createInternalModuleById.h | 3 + src/js/out/InternalModuleRegistry+enum.h | 5 +- .../InternalModuleRegistry+numberOfModules.h | 2 +- src/js/out/InternalModuleRegistryConstants.h | 522 +++++++++++++++++- src/js/out/ResolvedSourceTag.zig | 5 +- src/js/out/SyntheticModuleType.h | 5 +- src/js/thirdparty/utf-8-validate.ts | 4 +- 8 files changed, 548 insertions(+), 19 deletions(-) diff --git a/src/js/_codegen/build-modules.ts b/src/js/_codegen/build-modules.ts index 6537cb03b2bb41..d4a482e0568a30 100644 --- a/src/js/_codegen/build-modules.ts +++ b/src/js/_codegen/build-modules.ts @@ -281,18 +281,24 @@ fs.writeFileSync( ${moduleList .map( (id, n) => - `static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( + `// +static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( bundledOutputs.darwin.get(id.slice(0, -3)), - )}_s;`, + )}_s; +// +`, ) .join("\n")} #elif _WIN32 ${moduleList .map( (id, n) => - `static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( + `// +static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( bundledOutputs.win32.get(id.slice(0, -3)), - )}_s;`, + )}_s; +// +`, ) .join("\n")} #else @@ -300,9 +306,12 @@ fs.writeFileSync( ${moduleList .map( (id, n) => - `static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( + `// +static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( bundledOutputs.linux.get(id.slice(0, -3)), - )}_s;`, + )}_s; +// +`, ) .join("\n")} #endif diff --git a/src/js/out/InternalModuleRegistry+createInternalModuleById.h b/src/js/out/InternalModuleRegistry+createInternalModuleById.h index e64c71ff44f3d0..a5b13b0a470aae 100644 --- a/src/js/out/InternalModuleRegistry+createInternalModuleById.h +++ b/src/js/out/InternalModuleRegistry+createInternalModuleById.h @@ -164,6 +164,9 @@ JSValue InternalModuleRegistry::createInternalModuleById(JSGlobalObject* globalO case Field::ThirdpartyUndici: { INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "undici"_s, "thirdparty/undici.js"_s, InternalModuleRegistryConstants::ThirdpartyUndiciCode); } + case Field::ThirdpartyUtf8Validate: { + INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "utf-8-validate"_s, "thirdparty/utf-8-validate.js"_s, InternalModuleRegistryConstants::ThirdpartyUtf8ValidateCode); + } case Field::ThirdpartyVercelFetch: { INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "vercel_fetch"_s, "thirdparty/vercel_fetch.js"_s, InternalModuleRegistryConstants::ThirdpartyVercelFetchCode); } diff --git a/src/js/out/InternalModuleRegistry+enum.h b/src/js/out/InternalModuleRegistry+enum.h index 7d72e3d261081f..e454e4d4e4307b 100644 --- a/src/js/out/InternalModuleRegistry+enum.h +++ b/src/js/out/InternalModuleRegistry+enum.h @@ -52,6 +52,7 @@ ThirdpartyDetectLibcLinux = 50, ThirdpartyIsomorphicFetch = 51, ThirdpartyNodeFetch = 52, ThirdpartyUndici = 53, -ThirdpartyVercelFetch = 54, -ThirdpartyWS = 55, +ThirdpartyUtf8Validate = 54, +ThirdpartyVercelFetch = 55, +ThirdpartyWS = 56, diff --git a/src/js/out/InternalModuleRegistry+numberOfModules.h b/src/js/out/InternalModuleRegistry+numberOfModules.h index 67d159029849d9..517f9d237ff3ca 100644 --- a/src/js/out/InternalModuleRegistry+numberOfModules.h +++ b/src/js/out/InternalModuleRegistry+numberOfModules.h @@ -1 +1 @@ -#define BUN_INTERNAL_MODULE_COUNT 56 +#define BUN_INTERNAL_MODULE_COUNT 57 diff --git a/src/js/out/InternalModuleRegistryConstants.h b/src/js/out/InternalModuleRegistryConstants.h index fca9843124a4ea..b4bd0dae5c45e8 100644 --- a/src/js/out/InternalModuleRegistryConstants.h +++ b/src/js/out/InternalModuleRegistryConstants.h @@ -4,177 +4,693 @@ namespace InternalModuleRegistryConstants { #if __APPLE__ - static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";const FFIType={\"0\":0,\"1\":1,\"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\"7\":7,\"8\":8,\"9\":9,\"10\":10,\"11\":11,\"12\":12,\"13\":13,\"14\":14,\"15\":15,\"16\":16,\"17\":17,bool:11,c_int:5,c_uint:6,char:0,\"char*\":12,double:9,f32:10,f64:9,float:10,i16:3,i32:5,i64:7,i8:1,int:5,int16_t:3,int32_t:5,int64_t:7,int8_t:1,isize:7,u16:4,u32:6,u64:8,u8:2,uint16_t:4,uint32_t:6,uint64_t:8,uint8_t:2,usize:8,\"void*\":12,ptr:12,pointer:12,void:13,cstring:14,i64_fast:15,u64_fast:16,function:17,callback:17,fn:17};var ffi=globalThis.Bun.FFI;const ptr=(arg1,arg2)=>typeof arg2===\"undefined\"\?ffi.ptr(arg1):ffi.ptr(arg1,arg2),toBuffer=ffi.toBuffer,toArrayBuffer=ffi.toArrayBuffer,viewSource=ffi.viewSource,BunCString=ffi.CString,nativeLinkSymbols=ffi.linkSymbols,nativeDLOpen=ffi.dlopen,nativeCallback=ffi.callback,closeCallback=ffi.closeCallback;delete ffi.callback,delete ffi.closeCallback;class JSCallback{constructor(cb,options){const{ctx,ptr:ptr2}=nativeCallback(options,cb);this.#ctx=ctx,this.ptr=ptr2,this.#threadsafe=!!options\?.threadsafe}ptr;#ctx;#threadsafe;get threadsafe(){return this.#threadsafe}[Symbol.toPrimitive](){const{ptr:ptr2}=this;return typeof ptr2===\"number\"\?ptr2:0}close(){const ctx=this.#ctx;if(this.ptr=null,this.#ctx=null,ctx)closeCallback(ctx)}}class CString extends String{constructor(ptr2,byteOffset,byteLength){super(ptr2\?typeof byteLength===\"number\"&&Number.isSafeInteger(byteLength)\?new BunCString(ptr2,byteOffset||0,byteLength):new BunCString(ptr2):\"\");if(this.ptr=typeof ptr2===\"number\"\?ptr2:0,typeof byteOffset!==\"undefined\")this.byteOffset=byteOffset;if(typeof byteLength!==\"undefined\")this.byteLength=byteLength}ptr;byteOffset;byteLength;#cachedArrayBuffer;get arrayBuffer(){if(this.#cachedArrayBuffer)return this.#cachedArrayBuffer;if(!this.ptr)return this.#cachedArrayBuffer=new ArrayBuffer(0);return this.#cachedArrayBuffer=toArrayBuffer(this.ptr,this.byteOffset,this.byteLength)}}Object.defineProperty(globalThis,\"__GlobalBunCString\",{value:CString,enumerable:!1,configurable:!1});const ffiWrappers=new Array(18);var char=\"val|0\";ffiWrappers.fill(char),ffiWrappers[FFIType.uint8_t]=\"val<0\?0:val>=255\?255:val|0\",ffiWrappers[FFIType.int16_t]=\"val<=-32768\?-32768:val>=32768\?32768:val|0\",ffiWrappers[FFIType.uint16_t]=\"val<=0\?0:val>=65536\?65536:val|0\",ffiWrappers[FFIType.int32_t]=\"val|0\",ffiWrappers[FFIType.uint32_t]=\"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\",ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.int64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.uint64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`,ffiWrappers[FFIType.uint16_t]=`{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`,ffiWrappers[FFIType.double]=`{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`,ffiWrappers[FFIType.float]=ffiWrappers[10]=`{\n return Math.fround(val);\n}`,ffiWrappers[FFIType.bool]=`{\n return !!val;\n}`,Object.defineProperty(globalThis,\"__GlobalBunFFIPtrFunctionForWrapper\",{value:ptr,enumerable:!1,configurable:!0}),ffiWrappers[FFIType.cstring]=ffiWrappers[FFIType.pointer]=`{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`,ffiWrappers[FFIType.function]=`{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;function FFIBuilder(params,returnType,functionToCall,name){const hasReturnType=typeof FFIType[returnType]===\"number\"&&FFIType[returnType]!==FFIType.void;var paramNames=new Array(params.length),args=new Array(params.length);for(let i=0;i${wrapper})(p${i})`;else @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`)}var code=`functionToCall(${args.join(\", \")})`;if(hasReturnType)if(FFIType[returnType]===FFIType.cstring)code=`return new __GlobalBunCString(${code})`;else code=`return ${code}`;var func=new Function(\"functionToCall\",...paramNames,code);Object.defineProperty(func,\"name\",{value:name});var wrap;switch(paramNames.length){case 0:wrap=()=>func(functionToCall);break;case 1:wrap=(arg1)=>func(functionToCall,arg1);break;case 2:wrap=(arg1,arg2)=>func(functionToCall,arg1,arg2);break;case 3:wrap=(arg1,arg2,arg3)=>func(functionToCall,arg1,arg2,arg3);break;case 4:wrap=(arg1,arg2,arg3,arg4)=>func(functionToCall,arg1,arg2,arg3,arg4);break;case 5:wrap=(arg1,arg2,arg3,arg4,arg5)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5);break;case 6:wrap=(arg1,arg2,arg3,arg4,arg5,arg6)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6);break;case 7:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7);break;case 8:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);break;case 9:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);break;default:{wrap=(...args2)=>func(functionToCall,...args2);break}}return wrap.native=functionToCall,wrap.ptr=functionToCall.ptr,wrap}const native={dlopen:nativeDLOpen,callback:()=>{throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\")}};function dlopen(path,options){const result=nativeDLOpen(path,options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,path.includes(\"/\")\?`${key} (${path.split(\"/\").pop()})`:`${key} (${path})`);else result.symbols[key].native=result.symbols[key]}return result}function linkSymbols(options){const result=nativeLinkSymbols(options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,key);else result.symbols[key].native=result.symbols[key]}return result}var cFunctionI=0,cFunctionRegistry;function onCloseCFunction(close){close()}function CFunction(options){const identifier=`CFunction${cFunctionI++}`;var result=linkSymbols({[identifier]:options}),hasClosed=!1,close=result.close;return result.symbols[identifier].close=()=>{if(hasClosed||!close)return;hasClosed=!0,close(),close=void 0},cFunctionRegistry||=new FinalizationRegistry(onCloseCFunction),cFunctionRegistry.register(result.symbols[identifier],result.symbols[identifier].close),result.symbols[identifier]}const read=ffi.read;return{CFunction,CString,FFIType,JSCallback,dlopen,linkSymbols,native,ptr,read,suffix:\".dylib\",toArrayBuffer,toBuffer,viewSource}})\n"_s; + // +static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";const FFIType={\"0\":0,\"1\":1,\"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\"7\":7,\"8\":8,\"9\":9,\"10\":10,\"11\":11,\"12\":12,\"13\":13,\"14\":14,\"15\":15,\"16\":16,\"17\":17,bool:11,c_int:5,c_uint:6,char:0,\"char*\":12,double:9,f32:10,f64:9,float:10,i16:3,i32:5,i64:7,i8:1,int:5,int16_t:3,int32_t:5,int64_t:7,int8_t:1,isize:7,u16:4,u32:6,u64:8,u8:2,uint16_t:4,uint32_t:6,uint64_t:8,uint8_t:2,usize:8,\"void*\":12,ptr:12,pointer:12,void:13,cstring:14,i64_fast:15,u64_fast:16,function:17,callback:17,fn:17};var ffi=globalThis.Bun.FFI;const ptr=(arg1,arg2)=>typeof arg2===\"undefined\"\?ffi.ptr(arg1):ffi.ptr(arg1,arg2),toBuffer=ffi.toBuffer,toArrayBuffer=ffi.toArrayBuffer,viewSource=ffi.viewSource,BunCString=ffi.CString,nativeLinkSymbols=ffi.linkSymbols,nativeDLOpen=ffi.dlopen,nativeCallback=ffi.callback,closeCallback=ffi.closeCallback;delete ffi.callback,delete ffi.closeCallback;class JSCallback{constructor(cb,options){const{ctx,ptr:ptr2}=nativeCallback(options,cb);this.#ctx=ctx,this.ptr=ptr2,this.#threadsafe=!!options\?.threadsafe}ptr;#ctx;#threadsafe;get threadsafe(){return this.#threadsafe}[Symbol.toPrimitive](){const{ptr:ptr2}=this;return typeof ptr2===\"number\"\?ptr2:0}close(){const ctx=this.#ctx;if(this.ptr=null,this.#ctx=null,ctx)closeCallback(ctx)}}class CString extends String{constructor(ptr2,byteOffset,byteLength){super(ptr2\?typeof byteLength===\"number\"&&Number.isSafeInteger(byteLength)\?new BunCString(ptr2,byteOffset||0,byteLength):new BunCString(ptr2):\"\");if(this.ptr=typeof ptr2===\"number\"\?ptr2:0,typeof byteOffset!==\"undefined\")this.byteOffset=byteOffset;if(typeof byteLength!==\"undefined\")this.byteLength=byteLength}ptr;byteOffset;byteLength;#cachedArrayBuffer;get arrayBuffer(){if(this.#cachedArrayBuffer)return this.#cachedArrayBuffer;if(!this.ptr)return this.#cachedArrayBuffer=new ArrayBuffer(0);return this.#cachedArrayBuffer=toArrayBuffer(this.ptr,this.byteOffset,this.byteLength)}}Object.defineProperty(globalThis,\"__GlobalBunCString\",{value:CString,enumerable:!1,configurable:!1});const ffiWrappers=new Array(18);var char=\"val|0\";ffiWrappers.fill(char),ffiWrappers[FFIType.uint8_t]=\"val<0\?0:val>=255\?255:val|0\",ffiWrappers[FFIType.int16_t]=\"val<=-32768\?-32768:val>=32768\?32768:val|0\",ffiWrappers[FFIType.uint16_t]=\"val<=0\?0:val>=65536\?65536:val|0\",ffiWrappers[FFIType.int32_t]=\"val|0\",ffiWrappers[FFIType.uint32_t]=\"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\",ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.int64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.uint64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`,ffiWrappers[FFIType.uint16_t]=`{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`,ffiWrappers[FFIType.double]=`{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`,ffiWrappers[FFIType.float]=ffiWrappers[10]=`{\n return Math.fround(val);\n}`,ffiWrappers[FFIType.bool]=`{\n return !!val;\n}`,Object.defineProperty(globalThis,\"__GlobalBunFFIPtrFunctionForWrapper\",{value:ptr,enumerable:!1,configurable:!0}),ffiWrappers[FFIType.cstring]=ffiWrappers[FFIType.pointer]=`{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`,ffiWrappers[FFIType.function]=`{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;function FFIBuilder(params,returnType,functionToCall,name){const hasReturnType=typeof FFIType[returnType]===\"number\"&&FFIType[returnType]!==FFIType.void;var paramNames=new Array(params.length),args=new Array(params.length);for(let i=0;i${wrapper})(p${i})`;else @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`)}var code=`functionToCall(${args.join(\", \")})`;if(hasReturnType)if(FFIType[returnType]===FFIType.cstring)code=`return new __GlobalBunCString(${code})`;else code=`return ${code}`;var func=new Function(\"functionToCall\",...paramNames,code);Object.defineProperty(func,\"name\",{value:name});var wrap;switch(paramNames.length){case 0:wrap=()=>func(functionToCall);break;case 1:wrap=(arg1)=>func(functionToCall,arg1);break;case 2:wrap=(arg1,arg2)=>func(functionToCall,arg1,arg2);break;case 3:wrap=(arg1,arg2,arg3)=>func(functionToCall,arg1,arg2,arg3);break;case 4:wrap=(arg1,arg2,arg3,arg4)=>func(functionToCall,arg1,arg2,arg3,arg4);break;case 5:wrap=(arg1,arg2,arg3,arg4,arg5)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5);break;case 6:wrap=(arg1,arg2,arg3,arg4,arg5,arg6)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6);break;case 7:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7);break;case 8:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);break;case 9:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);break;default:{wrap=(...args2)=>func(functionToCall,...args2);break}}return wrap.native=functionToCall,wrap.ptr=functionToCall.ptr,wrap}const native={dlopen:nativeDLOpen,callback:()=>{throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\")}};function dlopen(path,options){const result=nativeDLOpen(path,options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,path.includes(\"/\")\?`${key} (${path.split(\"/\").pop()})`:`${key} (${path})`);else result.symbols[key].native=result.symbols[key]}return result}function linkSymbols(options){const result=nativeLinkSymbols(options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,key);else result.symbols[key].native=result.symbols[key]}return result}var cFunctionI=0,cFunctionRegistry;function onCloseCFunction(close){close()}function CFunction(options){const identifier=`CFunction${cFunctionI++}`;var result=linkSymbols({[identifier]:options}),hasClosed=!1,close=result.close;return result.symbols[identifier].close=()=>{if(hasClosed||!close)return;hasClosed=!0,close(),close=void 0},cFunctionRegistry||=new FinalizationRegistry(onCloseCFunction),cFunctionRegistry.register(result.symbols[identifier],result.symbols[identifier].close),result.symbols[identifier]}const read=ffi.read;return{CFunction,CString,FFIType,JSCallback,dlopen,linkSymbols,native,ptr,read,suffix:\".dylib\",toArrayBuffer,toBuffer,viewSource}})\n"_s; +// + +// static constexpr ASCIILiteral BunSqliteCode = "(function (){\"use strict\";var defineProperties=Object.defineProperties,toStringTag=Symbol.toStringTag,isArray=Array.isArray,isTypedArray=ArrayBuffer.isView;const constants={SQLITE_OPEN_READONLY:1,SQLITE_OPEN_READWRITE:2,SQLITE_OPEN_CREATE:4,SQLITE_OPEN_DELETEONCLOSE:8,SQLITE_OPEN_EXCLUSIVE:16,SQLITE_OPEN_AUTOPROXY:32,SQLITE_OPEN_URI:64,SQLITE_OPEN_MEMORY:128,SQLITE_OPEN_MAIN_DB:256,SQLITE_OPEN_TEMP_DB:512,SQLITE_OPEN_TRANSIENT_DB:1024,SQLITE_OPEN_MAIN_JOURNAL:2048,SQLITE_OPEN_TEMP_JOURNAL:4096,SQLITE_OPEN_SUBJOURNAL:8192,SQLITE_OPEN_SUPER_JOURNAL:16384,SQLITE_OPEN_NOMUTEX:32768,SQLITE_OPEN_FULLMUTEX:65536,SQLITE_OPEN_SHAREDCACHE:131072,SQLITE_OPEN_PRIVATECACHE:262144,SQLITE_OPEN_WAL:524288,SQLITE_OPEN_NOFOLLOW:16777216,SQLITE_OPEN_EXRESCODE:33554432,SQLITE_PREPARE_PERSISTENT:1,SQLITE_PREPARE_NORMALIZE:2,SQLITE_PREPARE_NO_VTAB:4};var SQL,controllers;class Statement{constructor(raw){switch(this.#raw=raw,raw.paramsCount){case 0:{this.get=this.#getNoArgs,this.all=this.#allNoArgs,this.values=this.#valuesNoArgs,this.run=this.#runNoArgs;break}default:{this.get=this.#get,this.all=this.#all,this.values=this.#values,this.run=this.#run;break}}}#raw;get;all;values;run;isFinalized=!1;toJSON(){return{sql:this.native.toString(),isFinalized:this.isFinalized,paramsCount:this.paramsCount,columnNames:this.columnNames}}get[toStringTag](){return`\"${this.native.toString()}\"`}toString(){return this.native.toString()}get native(){return this.#raw}#getNoArgs(){return this.#raw.get()}#allNoArgs(){return this.#raw.all()}#valuesNoArgs(){return this.#raw.values()}#runNoArgs(){this.#raw.run()}#get(...args){if(args.length===0)return this.#getNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.get(args):this.#raw.get(...args)}#all(...args){if(args.length===0)return this.#allNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.all(args):this.#raw.all(...args)}#values(...args){if(args.length===0)return this.#valuesNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.values(args):this.#raw.values(...args)}#run(...args){if(args.length===0)return this.#runNoArgs();var arg0=args[0];!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.run(args):this.#raw.run(...args)}get columnNames(){return this.#raw.columns}get paramsCount(){return this.#raw.paramsCount}finalize(...args){return this.isFinalized=!0,this.#raw.finalize(...args)}}var cachedCount=Symbol.for(\"Bun.Database.cache.count\");class Database{constructor(filenameGiven,options){if(typeof filenameGiven===\"undefined\");else if(typeof filenameGiven!==\"string\"){if(isTypedArray(filenameGiven)){this.#handle=Database.deserialize(filenameGiven,typeof options===\"object\"&&options\?!!options.readonly:((options|0)&constants.SQLITE_OPEN_READONLY)!=0),this.filename=\":memory:\";return}@throwTypeError(`Expected 'filename' to be a string, got '${typeof filenameGiven}'`)}var filename=typeof filenameGiven===\"string\"\?filenameGiven.trim():\":memory:\",flags=constants.SQLITE_OPEN_READWRITE|constants.SQLITE_OPEN_CREATE;if(typeof options===\"object\"&&options){if(flags=0,options.readonly)flags=constants.SQLITE_OPEN_READONLY;if(\"readOnly\"in options)@throwTypeError('Misspelled option \"readOnly\" should be \"readonly\"');if(options.create)flags=constants.SQLITE_OPEN_READWRITE|constants.SQLITE_OPEN_CREATE;if(options.readwrite)flags|=constants.SQLITE_OPEN_READWRITE}else if(typeof options===\"number\")flags=options;const anonymous=filename===\"\"||filename===\":memory:\";if(anonymous&&(flags&constants.SQLITE_OPEN_READONLY)!==0)throw new Error(\"Cannot open an anonymous database in read-only mode.\");if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");this.#handle=SQL.open(anonymous\?\":memory:\":filename,flags),this.filename=filename}#handle;#cachedQueriesKeys=[];#cachedQueriesLengths=[];#cachedQueriesValues=[];filename;get handle(){return this.#handle}get inTransaction(){return SQL.isInTransaction(this.#handle)}static open(filename,options){return new Database(filename,options)}loadExtension(name,entryPoint){return SQL.loadExtension(this.#handle,name,entryPoint)}serialize(optionalName){return SQL.serialize(this.#handle,optionalName||\"main\")}static deserialize(serialized,isReadOnly=!1){if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");return SQL.deserialize(serialized,isReadOnly)}static setCustomSQLite(path){if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");return SQL.setCustomSQLite(path)}close(){return this.clearQueryCache(),SQL.close(this.#handle)}clearQueryCache(){for(let item of this.#cachedQueriesValues)item.finalize();this.#cachedQueriesKeys.length=0,this.#cachedQueriesValues.length=0,this.#cachedQueriesLengths.length=0}run(query,...params){if(params.length===0){SQL.run(this.#handle,query);return}var arg0=params[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?SQL.run(this.#handle,query,params):SQL.run(this.#handle,query,...params)}prepare(query,params,flags){return new Statement(SQL.prepare(this.#handle,query,params,flags||0))}static MAX_QUERY_CACHE_SIZE=20;get[cachedCount](){return this.#cachedQueriesKeys.length}query(query){if(typeof query!==\"string\")@throwTypeError(`Expected 'query' to be a string, got '${typeof query}'`);if(query.length===0)throw new Error(\"SQL query cannot be empty.\");var index=this.#cachedQueriesLengths.indexOf(query.length);while(index!==-1){if(this.#cachedQueriesKeys[index]!==query){index=this.#cachedQueriesLengths.indexOf(query.length,index+1);continue}var stmt=this.#cachedQueriesValues[index];if(stmt.isFinalized)return this.#cachedQueriesValues[index]=this.prepare(query,void 0,willCache\?constants.SQLITE_PREPARE_PERSISTENT:0);return stmt}const willCache=this.#cachedQueriesKeys.length{let controller=(controllers||=new WeakMap).get(db);if(!controller){const shared={commit:db.prepare(\"COMMIT\",void 0,0),rollback:db.prepare(\"ROLLBACK\",void 0,0),savepoint:db.prepare(\"SAVEPOINT `\\t_bs3.\\t`\",void 0,0),release:db.prepare(\"RELEASE `\\t_bs3.\\t`\",void 0,0),rollbackTo:db.prepare(\"ROLLBACK TO `\\t_bs3.\\t`\",void 0,0)};controllers.set(db,controller={default:Object.assign({begin:db.prepare(\"BEGIN\",void 0,0)},shared),deferred:Object.assign({begin:db.prepare(\"BEGIN DEFERRED\",void 0,0)},shared),immediate:Object.assign({begin:db.prepare(\"BEGIN IMMEDIATE\",void 0,0)},shared),exclusive:Object.assign({begin:db.prepare(\"BEGIN EXCLUSIVE\",void 0,0)},shared)})}return controller},wrapTransaction=(fn,db,{begin,commit,rollback,savepoint,release,rollbackTo})=>function transaction(...args){let before,after,undo;if(db.inTransaction)before=savepoint,after=release,undo=rollbackTo;else before=begin,after=commit,undo=rollback;try{before.run();const result=fn.apply(this,args);return after.run(),result}catch(ex){if(db.inTransaction){if(undo.run(),undo!==rollback)after.run()}throw ex}};return{__esModule:!0,Database,Statement,constants,default:Database}})\n"_s; +// + +// static constexpr ASCIILiteral InternalSharedCode = "(function (){\"use strict\";class NotImplementedError extends Error{code;constructor(feature,issue){super(feature+\" is not yet implemented in Bun.\"+(issue\?\" Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/\"+issue:\"\"));this.name=\"NotImplementedError\",this.code=\"ERR_NOT_IMPLEMENTED\",hideFromStack(NotImplementedError)}}function throwNotImplemented(feature,issue){throw hideFromStack(throwNotImplemented),new NotImplementedError(feature,issue)}function hideFromStack(...fns){for(let fn of fns)Object.defineProperty(fn,\"name\",{value:\"::bunternal::\"})}return{NotImplementedError,throwNotImplemented,hideFromStack}})\n"_s; +// + +// static constexpr ASCIILiteral NodeAssertCode = "(function (){\"use strict\";const util=@getInternalField(@internalModuleRegistry,42)||@createInternalModuleById(42);var isDeepEqual=Bun.deepEquals,__commonJS=(cb,mod)=>function(){return mod||(0,cb[Object.keys(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_errors=__commonJS({\"assert/build/internal/errors.js\"(exports,module2){function _typeof(obj){return typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"\?_typeof=function(obj2){return typeof obj2}:_typeof=function(obj2){return obj2&&typeof Symbol==\"function\"&&obj2.constructor===Symbol&&obj2!==Symbol.prototype\?\"symbol\":typeof obj2},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))@throwTypeError(\"Cannot call a class as a function\")}function _possibleConstructorReturn(self,call){return call&&(_typeof(call)===\"object\"||typeof call==\"function\")\?call:_assertThisInitialized(self)}function _assertThisInitialized(self){if(self===void 0)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return self}function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf\?Object.getPrototypeOf:function(o2){return o2.__proto__||Object.getPrototypeOf(o2)},_getPrototypeOf(o)}function _inherits(subClass,superClass){if(typeof superClass!=\"function\"&&superClass!==null)@throwTypeError(\"Super expression must either be null or a function\");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),superClass&&_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){return _setPrototypeOf=Object.setPrototypeOf||function(o2,p2){return o2.__proto__=p2,o2},_setPrototypeOf(o,p)}var codes={},assert,util2;function createErrorType(code,message,Base){Base||(Base=Error);function getMessage(arg1,arg2,arg3){return typeof message==\"string\"\?message:message(arg1,arg2,arg3)}var NodeError=function(_Base){_inherits(NodeError2,_Base);function NodeError2(arg1,arg2,arg3){var _this;return _classCallCheck(this,NodeError2),_this=_possibleConstructorReturn(this,_getPrototypeOf(NodeError2).call(this,getMessage(arg1,arg2,arg3))),_this.code=code,_this}return NodeError2}(Base);codes[code]=NodeError}function oneOf(expected,thing){if(Array.isArray(expected)){var len=expected.length;return expected=expected.map(function(i){return String(i)}),len>2\?\"one of \".concat(thing,\" \").concat(expected.slice(0,len-1).join(\", \"),\", or \")+expected[len-1]:len===2\?\"one of \".concat(thing,\" \").concat(expected[0],\" or \").concat(expected[1]):\"of \".concat(thing,\" \").concat(expected[0])}else return\"of \".concat(thing,\" \").concat(String(expected))}function startsWith(str,search,pos){return str.substr(!pos||pos<0\?0:+pos,search.length)===search}function endsWith(str,search,this_len){return(this_len===void 0||this_len>str.length)&&(this_len=str.length),str.substring(this_len-search.length,this_len)===search}function includes(str,search,start){return typeof start!=\"number\"&&(start=0),start+search.length>str.length\?!1:str.indexOf(search,start)!==-1}createErrorType(\"ERR_AMBIGUOUS_ARGUMENT\",'The \"%s\" argument is ambiguous. %s',TypeError),createErrorType(\"ERR_INVALID_ARG_TYPE\",function(name,expected,actual){assert===void 0&&(assert=require_assert()),assert(typeof name==\"string\",\"'name' must be a string\");var determiner;typeof expected==\"string\"&&startsWith(expected,\"not \")\?(determiner=\"must not be\",expected=expected.replace(/^not /,\"\")):determiner=\"must be\";var msg;if(endsWith(name,\" argument\"))msg=\"The \".concat(name,\" \").concat(determiner,\" \").concat(oneOf(expected,\"type\"));else{var type=includes(name,\".\")\?\"property\":\"argument\";msg='The \"'.concat(name,'\" ').concat(type,\" \").concat(determiner,\" \").concat(oneOf(expected,\"type\"))}return msg+=\". Received type \".concat(_typeof(actual)),msg},TypeError),createErrorType(\"ERR_INVALID_ARG_VALUE\",function(name,value){var reason=arguments.length>2&&arguments[2]!==void 0\?arguments[2]:\"is invalid\",inspected=util2.inspect(value);return inspected.length>128&&(inspected=\"\".concat(inspected.slice(0,128),\"...\")),\"The argument '\".concat(name,\"' \").concat(reason,\". Received \").concat(inspected)},TypeError,RangeError),createErrorType(\"ERR_INVALID_RETURN_VALUE\",function(input,name,value){var type;return value&&value.constructor&&value.constructor.name\?type=\"instance of \".concat(value.constructor.name):type=\"type \".concat(_typeof(value)),\"Expected \".concat(input,' to be returned from the \"').concat(name,'\"')+\" function but got \".concat(type,\".\")},TypeError),createErrorType(\"ERR_MISSING_ARGS\",function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];assert===void 0&&(assert=require_assert()),assert(args.length>0,\"At least one arg needs to be specified\");var msg=\"The \",len=args.length;switch(args=args.map(function(a){return'\"'.concat(a,'\"')}),len){case 1:msg+=\"\".concat(args[0],\" argument\");break;case 2:msg+=\"\".concat(args[0],\" and \").concat(args[1],\" arguments\");break;default:msg+=args.slice(0,len-1).join(\", \"),msg+=\", and \".concat(args[len-1],\" arguments\");break}return\"\".concat(msg,\" must be specified\")},TypeError),module2.exports.codes=codes}}),require_assertion_error=__commonJS({\"assert/build/internal/assert/assertion_error.js\"(exports,module2){function _objectSpread(target){for(var i=1;istr.length)&&(this_len=str.length),str.substring(this_len-search.length,this_len)===search}function repeat(str,count){if(count=Math.floor(count),str.length==0||count==0)return\"\";var maxCount=str.length*count;for(count=Math.floor(Math.log(count)/Math.log(2));count;)str+=str,count--;return str+=str.substring(0,maxCount-str.length),str}var blue=\"\",green=\"\",red=\"\",white=\"\",kReadableOperator={deepStrictEqual:\"Expected values to be strictly deep-equal:\",strictEqual:\"Expected values to be strictly equal:\",strictEqualObject:'Expected \"actual\" to be reference-equal to \"expected\":',deepEqual:\"Expected values to be loosely deep-equal:\",equal:\"Expected values to be loosely equal:\",notDeepStrictEqual:'Expected \"actual\" not to be strictly deep-equal to:',notStrictEqual:'Expected \"actual\" to be strictly unequal to:',notStrictEqualObject:'Expected \"actual\" not to be reference-equal to \"expected\":',notDeepEqual:'Expected \"actual\" not to be loosely deep-equal to:',notEqual:'Expected \"actual\" to be loosely unequal to:',notIdentical:\"Values identical but not reference-equal:\"},kMaxShortLength=10;function copyError(source){var keys=Object.keys(source),target=Object.create(Object.getPrototypeOf(source));return keys.forEach(function(key){target[key]=source[key]}),Object.defineProperty(target,\"message\",{value:source.message}),target}function inspectValue(val){return inspect(val,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function createErrDiff(actual,expected,operator){var other=\"\",res=\"\",lastPos=0,end=\"\",skipped=!1,actualInspected=inspectValue(actual),actualLines=actualInspected.split(`\n`),expectedLines=inspectValue(expected).split(`\n`),i=0,indicator=\"\";if(operator===\"strictEqual\"&&_typeof(actual)===\"object\"&&_typeof(expected)===\"object\"&&actual!==null&&expected!==null&&(operator=\"strictEqualObject\"),actualLines.length===1&&expectedLines.length===1&&actualLines[0]!==expectedLines[0]){var inputLength=actualLines[0].length+expectedLines[0].length;if(inputLength<=kMaxShortLength){if((_typeof(actual)!==\"object\"||actual===null)&&(_typeof(expected)!==\"object\"||expected===null)&&(actual!==0||expected!==0))return\"\".concat(kReadableOperator[operator],`\n\n`)+\"\".concat(actualLines[0],\" !== \").concat(expectedLines[0],`\n`)}else if(operator!==\"strictEqualObject\"){var maxLength=process.stderr&&process.stderr.isTTY\?process.stderr.columns:80;if(inputLength2&&(indicator=`\n `.concat(repeat(\" \",i),\"^\"),i=0)}}}for(var a=actualLines[actualLines.length-1],b=expectedLines[expectedLines.length-1];a===b&&(i++<2\?end=`\n `.concat(a).concat(end):other=a,actualLines.pop(),expectedLines.pop(),!(actualLines.length===0||expectedLines.length===0));)a=actualLines[actualLines.length-1],b=expectedLines[expectedLines.length-1];var maxLines=Math.max(actualLines.length,expectedLines.length);if(maxLines===0){var _actualLines=actualInspected.split(`\n`);if(_actualLines.length>30)for(_actualLines[26]=\"\".concat(blue,\"...\").concat(white);_actualLines.length>27;)_actualLines.pop();return\"\".concat(kReadableOperator.notIdentical,`\n\n`).concat(_actualLines.join(`\n`),`\n`)}i>3&&(end=`\n`.concat(blue,\"...\").concat(white).concat(end),skipped=!0),other!==\"\"&&(end=`\n `.concat(other).concat(end),other=\"\");var printedLines=0,msg=kReadableOperator[operator]+`\n`.concat(green,\"+ actual\").concat(white,\" \").concat(red,\"- expected\").concat(white),skippedMsg=\" \".concat(blue,\"...\").concat(white,\" Lines skipped\");for(i=0;i1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(expectedLines[i-2]),printedLines++),res+=`\n `.concat(expectedLines[i-1]),printedLines++),lastPos=i,other+=`\n`.concat(red,\"-\").concat(white,\" \").concat(expectedLines[i]),printedLines++;else if(expectedLines.length1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(actualLines[i-2]),printedLines++),res+=`\n `.concat(actualLines[i-1]),printedLines++),lastPos=i,res+=`\n`.concat(green,\"+\").concat(white,\" \").concat(actualLines[i]),printedLines++;else{var expectedLine=expectedLines[i],actualLine=actualLines[i],divergingLines=actualLine!==expectedLine&&(!endsWith(actualLine,\",\")||actualLine.slice(0,-1)!==expectedLine);divergingLines&&endsWith(expectedLine,\",\")&&expectedLine.slice(0,-1)===actualLine&&(divergingLines=!1,actualLine+=\",\"),divergingLines\?(cur>1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(actualLines[i-2]),printedLines++),res+=`\n `.concat(actualLines[i-1]),printedLines++),lastPos=i,res+=`\n`.concat(green,\"+\").concat(white,\" \").concat(actualLine),other+=`\n`.concat(red,\"-\").concat(white,\" \").concat(expectedLine),printedLines+=2):(res+=other,other=\"\",(cur===1||i===0)&&(res+=`\n `.concat(actualLine),printedLines++))}if(printedLines>20&&i30)for(res[26]=\"\".concat(blue,\"...\").concat(white);res.length>27;)res.pop();res.length===1\?_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(base,\" \").concat(res[0]))):_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(base,`\n\n`).concat(res.join(`\n`),`\n`)))}else{var _res=inspectValue(actual),other=\"\",knownOperators=kReadableOperator[operator];operator===\"notDeepEqual\"||operator===\"notEqual\"\?(_res=\"\".concat(kReadableOperator[operator],`\n\n`).concat(_res),_res.length>1024&&(_res=\"\".concat(_res.slice(0,1021),\"...\"))):(other=\"\".concat(inspectValue(expected)),_res.length>512&&(_res=\"\".concat(_res.slice(0,509),\"...\")),other.length>512&&(other=\"\".concat(other.slice(0,509),\"...\")),operator===\"deepEqual\"||operator===\"equal\"\?_res=\"\".concat(knownOperators,`\n\n`).concat(_res,`\n\nshould equal\n\n`):other=\" \".concat(operator,\" \").concat(other)),_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(_res).concat(other)))}return Error.stackTraceLimit=limit,_this.generatedMessage=!message,Object.defineProperty(_assertThisInitialized(_this),\"name\",{value:\"AssertionError [ERR_ASSERTION]\",enumerable:!1,writable:!0,configurable:!0}),_this.code=\"ERR_ASSERTION\",_this.actual=actual,_this.expected=expected,_this.operator=operator,Error.captureStackTrace&&Error.captureStackTrace(_assertThisInitialized(_this),stackStartFn),_this.stack,_this.name=\"AssertionError\",_possibleConstructorReturn(_this)}return AssertionError2.prototype={},_inherits(AssertionError2,_Error),_createClass(AssertionError2,[{key:\"toString\",value:function(){return\"\".concat(this.name,\" [\").concat(this.code,\"]: \").concat(this.message)}},{key:inspect.custom,value:function(recurseTimes,ctx){return inspect(this,_objectSpread({},ctx,{customInspect:!1,depth:0}))}}]),AssertionError2}(_wrapNativeSuper(Error));module2.exports=AssertionError}}),require_assert=__commonJS({\"assert/build/assert.js\"(exports,module2){function _typeof(obj){return typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"\?_typeof=function(obj2){return typeof obj2}:_typeof=function(obj2){return obj2&&typeof Symbol==\"function\"&&obj2.constructor===Symbol&&obj2!==Symbol.prototype\?\"symbol\":typeof obj2},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))@throwTypeError(\"Cannot call a class as a function\")}var _require=require_errors(),_require$codes=_require.codes,ERR_AMBIGUOUS_ARGUMENT=_require$codes.ERR_AMBIGUOUS_ARGUMENT,ERR_INVALID_ARG_TYPE=_require$codes.ERR_INVALID_ARG_TYPE,ERR_INVALID_ARG_VALUE=_require$codes.ERR_INVALID_ARG_VALUE,ERR_INVALID_RETURN_VALUE=_require$codes.ERR_INVALID_RETURN_VALUE,ERR_MISSING_ARGS=_require$codes.ERR_MISSING_ARGS,AssertionError=require_assertion_error(),_require2=util,inspect=_require2.inspect,_require$types=util.types,isPromise=_require$types.isPromise,isRegExp=_require$types.isRegExp,objectAssign=Object.assign,objectIs=Object.is,errorCache=new Map,warned=!1,assert=module2.exports=ok,NO_EXCEPTION_SENTINEL={};function innerFail(obj){throw obj.message instanceof Error\?obj.message:new AssertionError(obj)}function fail(actual,expected,message,operator,stackStartFn){var argsLen=arguments.length,internalMessage;if(argsLen===0)internalMessage=\"Failed\";else if(argsLen===1)message=actual,actual=void 0;else{if(warned===!1){warned=!0;var warn=process.emitWarning\?process.emitWarning:console.warn.bind(console);warn(\"assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.\",\"DeprecationWarning\",\"DEP0094\")}argsLen===2&&(operator=\"!=\")}if(message instanceof Error)throw message;var errArgs={actual,expected,operator:operator===void 0\?\"fail\":operator,stackStartFn:stackStartFn||fail};message!==void 0&&(errArgs.message=message);var err=new AssertionError(errArgs);throw internalMessage&&(err.message=internalMessage,err.generatedMessage=!0),err}assert.fail=fail,assert.AssertionError=AssertionError;function innerOk(fn,argLen,value,message){if(!value){var generatedMessage=!1;if(argLen===0)generatedMessage=!0,message=\"No value argument passed to `assert.ok()`\";else if(message instanceof Error)throw message;var err=new AssertionError({actual:value,expected:!0,message,operator:\"==\",stackStartFn:fn});throw err.generatedMessage=generatedMessage,err}}function ok(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];innerOk.apply(void 0,[ok,args.length].concat(args))}assert.ok=ok,assert.equal=function equal(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");actual!=expected&&innerFail({actual,expected,message,operator:\"==\",stackStartFn:equal})},assert.notEqual=function notEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");actual==expected&&innerFail({actual,expected,message,operator:\"!=\",stackStartFn:notEqual})},assert.deepEqual=function deepEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!1)||innerFail({actual,expected,message,operator:\"deepEqual\",stackStartFn:deepEqual})},assert.notDeepEqual=function notDeepEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!1)&&innerFail({actual,expected,message,operator:\"notDeepEqual\",stackStartFn:notDeepEqual})},assert.deepStrictEqual=function deepStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!0)||innerFail({actual,expected,message,operator:\"deepStrictEqual\",stackStartFn:deepStrictEqual})},assert.notDeepStrictEqual=notDeepStrictEqual;function notDeepStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!0)&&innerFail({actual,expected,message,operator:\"notDeepStrictEqual\",stackStartFn:notDeepStrictEqual})}assert.strictEqual=function strictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");objectIs(actual,expected)||innerFail({actual,expected,message,operator:\"strictEqual\",stackStartFn:strictEqual})},assert.notStrictEqual=function notStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");objectIs(actual,expected)&&innerFail({actual,expected,message,operator:\"notStrictEqual\",stackStartFn:notStrictEqual})},assert.match=function match(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");if(!isRegExp(expected))throw new ERR_INVALID_ARG_TYPE(\"expected\",\"RegExp\",expected);expected.test(actual)||innerFail({actual,expected,message,operator:\"match\",stackStartFn:match})};var Comparison=function Comparison2(obj,keys,actual){var _this=this;_classCallCheck(this,Comparison2),keys.forEach(function(key){(key in obj)&&(actual!==void 0&&typeof actual[key]==\"string\"&&isRegExp(obj[key])&&obj[key].test(actual[key])\?_this[key]=actual[key]:_this[key]=obj[key])})};function compareExceptionKey(actual,expected,key,message,keys,fn){if(!(key in actual)||!isDeepEqual(actual[key],expected[key],!0)){if(!message){var a=new Comparison(actual,keys),b=new Comparison(expected,keys,actual),err=new AssertionError({actual:a,expected:b,operator:\"deepStrictEqual\",stackStartFn:fn});throw err.actual=actual,err.expected=expected,err.operator=fn.name,err}innerFail({actual,expected,message,operator:fn.name,stackStartFn:fn})}}function expectedException(actual,expected,msg,fn){if(typeof expected!=\"function\"){if(isRegExp(expected))return expected.test(actual);if(arguments.length===2)throw new ERR_INVALID_ARG_TYPE(\"expected\",[\"Function\",\"RegExp\"],expected);if(_typeof(actual)!==\"object\"||actual===null){var err=new AssertionError({actual,expected,message:msg,operator:\"deepStrictEqual\",stackStartFn:fn});throw err.operator=fn.name,err}var keys=Object.keys(expected);if(expected instanceof Error)keys.push(\"name\",\"message\");else if(keys.length===0)throw new ERR_INVALID_ARG_VALUE(\"error\",expected,\"may not be an empty object\");return keys.forEach(function(key){return typeof actual[key]==\"string\"&&isRegExp(expected[key])&&expected[key].test(actual[key])||compareExceptionKey(actual,expected,key,msg,keys,fn)}),!0}return expected.prototype!==void 0&&actual instanceof expected\?!0:Error.isPrototypeOf(expected)\?!1:expected.call({},actual)===!0}function getActual(fn){if(typeof fn!=\"function\")throw new ERR_INVALID_ARG_TYPE(\"fn\",\"Function\",fn);try{fn()}catch(e){return e}return NO_EXCEPTION_SENTINEL}function checkIsPromise(obj){return isPromise(obj)||obj!==null&&_typeof(obj)===\"object\"&&typeof obj.then==\"function\"&&typeof obj.catch==\"function\"}function waitForActual(promiseFn){return Promise.resolve().then(function(){var resultPromise;if(typeof promiseFn==\"function\"){if(resultPromise=promiseFn(),!checkIsPromise(resultPromise))throw new ERR_INVALID_RETURN_VALUE(\"instance of Promise\",\"promiseFn\",resultPromise)}else if(checkIsPromise(promiseFn))resultPromise=promiseFn;else throw new ERR_INVALID_ARG_TYPE(\"promiseFn\",[\"Function\",\"Promise\"],promiseFn);return Promise.resolve().then(function(){return resultPromise}).then(function(){return NO_EXCEPTION_SENTINEL}).catch(function(e){return e})})}function expectsError(stackStartFn,actual,error,message){if(typeof error==\"string\"){if(arguments.length===4)throw new ERR_INVALID_ARG_TYPE(\"error\",[\"Object\",\"Error\",\"Function\",\"RegExp\"],error);if(_typeof(actual)===\"object\"&&actual!==null){if(actual.message===error)throw new ERR_AMBIGUOUS_ARGUMENT(\"error/message\",'The error message \"'.concat(actual.message,'\" is identical to the message.'))}else if(actual===error)throw new ERR_AMBIGUOUS_ARGUMENT(\"error/message\",'The error \"'.concat(actual,'\" is identical to the message.'));message=error,error=void 0}else if(error!=null&&_typeof(error)!==\"object\"&&typeof error!=\"function\")throw new ERR_INVALID_ARG_TYPE(\"error\",[\"Object\",\"Error\",\"Function\",\"RegExp\"],error);if(actual===NO_EXCEPTION_SENTINEL){var details=\"\";error&&error.name&&(details+=\" (\".concat(error.name,\")\")),details+=message\?\": \".concat(message):\".\";var fnType=stackStartFn.name===\"rejects\"\?\"rejection\":\"exception\";innerFail({actual:void 0,expected:error,operator:stackStartFn.name,message:\"Missing expected \".concat(fnType).concat(details),stackStartFn})}if(error&&!expectedException(actual,error,message,stackStartFn))throw actual}function expectsNoError(stackStartFn,actual,error,message){if(actual!==NO_EXCEPTION_SENTINEL){if(typeof error==\"string\"&&(message=error,error=void 0),!error||expectedException(actual,error)){var details=message\?\": \".concat(message):\".\",fnType=stackStartFn.name===\"doesNotReject\"\?\"rejection\":\"exception\";innerFail({actual,expected:error,operator:stackStartFn.name,message:\"Got unwanted \".concat(fnType).concat(details,`\n`)+'Actual message: \"'.concat(actual&&actual.message,'\"'),stackStartFn})}throw actual}}assert.throws=function throws(promiseFn){for(var _len2=arguments.length,args=new Array(_len2>1\?_len2-1:0),_key2=1;_key2<_len2;_key2++)args[_key2-1]=arguments[_key2];expectsError.apply(void 0,[throws,getActual(promiseFn)].concat(args))},assert.rejects=function rejects(promiseFn){for(var _len3=arguments.length,args=new Array(_len3>1\?_len3-1:0),_key3=1;_key3<_len3;_key3++)args[_key3-1]=arguments[_key3];return waitForActual(promiseFn).then(function(result){return expectsError.apply(void 0,[rejects,result].concat(args))})},assert.doesNotThrow=function doesNotThrow(fn){for(var _len4=arguments.length,args=new Array(_len4>1\?_len4-1:0),_key4=1;_key4<_len4;_key4++)args[_key4-1]=arguments[_key4];expectsNoError.apply(void 0,[doesNotThrow,getActual(fn)].concat(args))},assert.doesNotReject=function doesNotReject(fn){for(var _len5=arguments.length,args=new Array(_len5>1\?_len5-1:0),_key5=1;_key5<_len5;_key5++)args[_key5-1]=arguments[_key5];return waitForActual(fn).then(function(result){return expectsNoError.apply(void 0,[doesNotReject,result].concat(args))})},assert.ifError=function ifError(err){if(err!=null){var message=\"ifError got unwanted exception: \";_typeof(err)===\"object\"&&typeof err.message==\"string\"\?err.message.length===0&&err.constructor\?message+=err.constructor.name:message+=err.message:message+=inspect(err);var newErr=new AssertionError({actual:err,expected:null,operator:\"ifError\",message,stackStartFn:ifError}),origStack=err.stack;if(typeof origStack==\"string\"){var tmp2=origStack.split(`\n`);tmp2.shift();for(var tmp1=newErr.stack.split(`\n`),i=0;i{var prev=get();set(context);try{return fn(...args)}catch(error){throw error}finally{set(prev)}}}enterWith(store){cleanupLater();var context=get();if(!context){set([this,store]);return}var{length}=context;for(var i=0;i-1)hasPrevious=!0,previous=context[i+1],context[i+1]=store;else context.push(this,store);set(context)}try{return callback(...args)}catch(e){throw e}finally{if(!this.#disableCalled){var context2=get();if(context2===context&&contextWasInit)set(void 0);else if(context2=context2.slice(),hasPrevious)context2[i+1]=previous,set(context2);else context2.splice(i,2),set(context2.length\?context2:void 0)}}}disable(){if(!this.#disableCalled){var context=get();if(context){var{length}=context;for(var i=0;i-1){try{child.kill(killSignal)}catch(err){child.emit(\"error\",err)}timeoutHolder.timeoutId=-1}}function spawn(file,args,options){options=normalizeSpawnArguments(file,args,options),validateTimeout(options.timeout),validateAbortSignal(options.signal,\"options.signal\");const killSignal2=sanitizeKillSignal(options.killSignal),child=new ChildProcess;if(child.spawn(options),options.timeout>0){let timeoutId=setTimeout(()=>{if(timeoutId){try{child.kill(killSignal2)}catch(err){child.emit(\"error\",err)}timeoutId=null}});child.once(\"exit\",()=>{if(timeoutId)clearTimeout(timeoutId),timeoutId=null})}if(options.signal){let onAbortListener2=function(){abortChildProcess(child,killSignal2,options.signal.reason)};var onAbortListener=onAbortListener2;const signal=options.signal;if(signal.aborted)process.nextTick(onAbortListener2);else signal.addEventListener(\"abort\",onAbortListener2,{once:!0}),child.once(\"exit\",()=>signal.removeEventListener(\"abort\",onAbortListener2))}return child}function execFile(file,args,options,callback){({file,args,options,callback}=normalizeExecFileArgs(file,args,options,callback)),options={encoding:\"utf8\",timeout:0,maxBuffer:MAX_BUFFER,killSignal:\"SIGTERM\",cwd:null,env:null,shell:!1,...options};const maxBuffer=options.maxBuffer;validateTimeout(options.timeout),validateMaxBuffer(maxBuffer),options.killSignal=sanitizeKillSignal(options.killSignal);const child=spawn(file,args,{cwd:options.cwd,env:options.env,shell:options.shell,signal:options.signal});let encoding;const _stdout=[],_stderr=[];if(options.encoding!==\"buffer\"&&BufferIsEncoding(options.encoding))encoding=options.encoding;else encoding=null;let stdoutLen=0,stderrLen=0,killed=!1,exited=!1,timeoutId,encodedStdoutLen,encodedStderrLen,ex=null,cmd=file;function exitHandler(code,signal){if(exited)return;if(exited=!0,timeoutId)clearTimeout(timeoutId),timeoutId=null;if(!callback)return;const readableEncoding=child\?.stdout\?.readableEncoding;let stdout,stderr;if(encoding||child.stdout&&readableEncoding)stdout=ArrayPrototypeJoin.call(_stdout,\"\");else stdout=BufferConcat(_stdout);if(encoding||child.stderr&&readableEncoding)stderr=ArrayPrototypeJoin.call(_stderr,\"\");else stderr=BufferConcat(_stderr);if(!ex&&code===0&&signal===null){callback(null,stdout,stderr);return}if(args\?.length)cmd+=` ${ArrayPrototypeJoin.call(args,\" \")}`;if(!ex){let message=`Command failed: ${cmd}`;if(stderr)message+=`\\n${stderr}`;ex=genericNodeError(message,{code,killed:child.killed||killed,signal})}ex.cmd=cmd,callback(ex,stdout,stderr)}function errorHandler(e){if(ex=e,child.stdout)child.stdout.destroy();if(child.stderr)child.stderr.destroy();exitHandler()}function kill(){if(child.stdout)child.stdout.destroy();if(child.stderr)child.stderr.destroy();killed=!0;try{child.kill(options.killSignal)}catch(e){ex=e,exitHandler()}}if(options.timeout>0)timeoutId=setTimeout(function delayedKill(){kill(),timeoutId=null},options.timeout);if(child.stdout){if(encoding)child.stdout.setEncoding(encoding);child.stdout.on(\"data\",maxBuffer===Infinity\?function onUnlimitedSizeBufferedData(chunk){ArrayPrototypePush.call(_stdout,chunk)}:encoding\?function onChildStdoutEncoded(chunk){if(stdoutLen+=chunk.length,stdoutLen*4>maxBuffer){const encoding2=child.stdout.readableEncoding,actualLen=Buffer.byteLength(chunk,encoding2);if(encodedStdoutLen===void 0)for(let i=0;i<_stdout.length;i++)encodedStdoutLen+=Buffer.byteLength(_stdout[i],encoding2);else encodedStdoutLen+=actualLen;const truncatedLen=maxBuffer-(encodedStdoutLen-actualLen);ArrayPrototypePush.call(_stdout,StringPrototypeSlice.apply(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stdout\"),kill()}else ArrayPrototypePush.call(_stdout,chunk)}:function onChildStdoutRaw(chunk){if(stdoutLen+=chunk.length,stdoutLen>maxBuffer){const truncatedLen=maxBuffer-(stdoutLen-chunk.length);ArrayPrototypePush.call(_stdout,chunk.slice(0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stdout\"),kill()}else ArrayPrototypePush.call(_stdout,chunk)})}if(child.stderr){if(encoding)child.stderr.setEncoding(encoding);child.stderr.on(\"data\",maxBuffer===Infinity\?function onUnlimitedSizeBufferedData(chunk){ArrayPrototypePush.call(_stderr,chunk)}:encoding\?function onChildStderrEncoded(chunk){if(stderrLen+=chunk.length,stderrLen*4>maxBuffer){const encoding2=child.stderr.readableEncoding,actualLen=Buffer.byteLength(chunk,encoding2);if(encodedStderrLen===void 0)for(let i=0;i<_stderr.length;i++)encodedStderrLen+=Buffer.byteLength(_stderr[i],encoding2);else encodedStderrLen+=actualLen;const truncatedLen=maxBuffer-(encodedStderrLen-actualLen);ArrayPrototypePush.call(_stderr,StringPrototypeSlice.call(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stderr\"),kill()}else ArrayPrototypePush.call(_stderr,chunk)}:function onChildStderrRaw(chunk){if(stderrLen+=chunk.length,stderrLen>maxBuffer){const truncatedLen=maxBuffer-(stderrLen-chunk.length);ArrayPrototypePush.call(_stderr,StringPrototypeSlice.call(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stderr\"),kill()}else ArrayPrototypePush.call(_stderr,chunk)})}return child.addListener(\"close\",exitHandler),child.addListener(\"error\",errorHandler),child}function exec(command,options,callback){const opts=normalizeExecArgs(command,options,callback);return execFile(opts.file,opts.options,opts.callback)}const customPromiseExecFunction=(orig)=>{return(...args)=>{let resolve,reject;const promise=new Promise((res,rej)=>{resolve=res,reject=rej});return promise.child=orig(...args,(err,stdout,stderr)=>{if(err!==null)err.stdout=stdout,err.stderr=stderr,reject(err);else resolve({stdout,stderr})}),promise}};ObjectDefineProperty(exec,promisify.custom,{__proto__:null,enumerable:!1,value:customPromiseExecFunction(exec)});function spawnSync(file,args,options){options={maxBuffer:MAX_BUFFER,...normalizeSpawnArguments(file,args,options)};const{maxBuffer,encoding}=options;validateTimeout(options.timeout),validateMaxBuffer(maxBuffer),options.killSignal=sanitizeKillSignal(options.killSignal);const stdio=options.stdio||\"pipe\",bunStdio=getBunStdioFromOptions(stdio);var{input}=options;if(input)if(ArrayBufferIsView(input))bunStdio[0]=input;else if(typeof input===\"string\")bunStdio[0]=Buffer.from(input,encoding||\"utf8\");else throw new ERR_INVALID_ARG_TYPE(\"options.stdio[0]\",[\"Buffer\",\"TypedArray\",\"DataView\",\"string\"],input);const{stdout,stderr,success,exitCode}=Bun.spawnSync({cmd:options.args,env:options.env||void 0,cwd:options.cwd||void 0,stdin:bunStdio[0],stdout:bunStdio[1],stderr:bunStdio[2]}),result={signal:null,status:exitCode,output:[null,stdout,stderr]};if(stdout&&encoding&&encoding!==\"buffer\")result.output[1]=result.output[1]\?.toString(encoding);if(stderr&&encoding&&encoding!==\"buffer\")result.output[2]=result.output[2]\?.toString(encoding);if(result.stdout=result.output[1],result.stderr=result.output[2],!success)result.error=new SystemError(result.output[2],options.file,\"spawnSync\",-1,result.status),result.error.spawnargs=ArrayPrototypeSlice.call(options.args,1);return result}function execFileSync(file,args,options){({file,args,options}=normalizeExecFileArgs(file,args,options));const ret=spawnSync(file,args,options),errArgs=[options.argv0||file];ArrayPrototypePush.apply(errArgs,args);const err=checkExecSyncError(ret,errArgs);if(err)throw err;return ret.stdout}function execSync(command,options){const opts=normalizeExecArgs(command,options,null),ret=spawnSync(opts.file,opts.options),err=checkExecSyncError(ret,void 0,command);if(err)throw err;return ret.stdout}function stdioStringToArray(stdio,channel){const options=[];switch(stdio){case\"ignore\":case\"overlapped\":case\"pipe\":ArrayPrototypePush.call(options,stdio,stdio,stdio);break;case\"inherit\":ArrayPrototypePush.call(options,0,1,2);break;default:throw new ERR_INVALID_ARG_VALUE(\"stdio\",stdio)}if(channel)ArrayPrototypePush.call(options,channel);return options}function fork(modulePath,args=[],options){modulePath=getValidatedPath(modulePath,\"modulePath\");let execArgv;if(args==null)args=[];else if(typeof args===\"object\"&&!ArrayIsArray(args))options=args,args=[];else validateArray(args,\"args\");if(options!=null)validateObject(options,\"options\");if(options={__proto__:null,...options,shell:!1},options.execPath=options.execPath||process.execPath,validateArgumentNullCheck(options.execPath,\"options.execPath\"),execArgv=options.execArgv||process.execArgv,validateArgumentsNullCheck(execArgv,\"options.execArgv\"),execArgv===process.execArgv&&process._eval!=null){const index=ArrayPrototypeLastIndexOf.call(execArgv,process._eval);if(index>0)execArgv=ArrayPrototypeSlice.call(execArgv),ArrayPrototypeSplice.call(execArgv,index-1,2)}if(args=[...execArgv,modulePath,...args],typeof options.stdio===\"string\")options.stdio=stdioStringToArray(options.stdio,\"ipc\");else if(!ArrayIsArray(options.stdio))options.stdio=stdioStringToArray(options.silent\?\"pipe\":\"inherit\",\"ipc\");else if(!ArrayPrototypeIncludes.call(options.stdio,\"ipc\"))throw new ERR_CHILD_PROCESS_IPC_REQUIRED(\"options.stdio\");return spawn(options.execPath,args,options)}function convertToValidSignal(signal){if(typeof signal===\"number\"&&getSignalsToNamesMapping()[signal])return signal;if(typeof signal===\"string\"){const signalName=signals[StringPrototypeToUpperCase.call(signal)];if(signalName)return signalName}throw new ERR_UNKNOWN_SIGNAL(signal)}function sanitizeKillSignal(killSignal2){if(typeof killSignal2===\"string\"||typeof killSignal2===\"number\")return convertToValidSignal(killSignal2);else if(killSignal2!=null)throw new ERR_INVALID_ARG_TYPE(\"options.killSignal\",[\"string\",\"number\"],killSignal2)}let signalsToNamesMapping;function getSignalsToNamesMapping(){if(signalsToNamesMapping!==void 0)return signalsToNamesMapping;signalsToNamesMapping=ObjectCreate(null);for(let key in signals)signalsToNamesMapping[signals[key]]=key;return signalsToNamesMapping}function normalizeExecFileArgs(file,args,options,callback){if(ArrayIsArray(args))args=ArrayPrototypeSlice.call(args);else if(args!=null&&typeof args===\"object\")callback=options,options=args,args=null;else if(typeof args===\"function\")callback=args,options=null,args=null;if(args==null)args=[];if(typeof options===\"function\")callback=options;else if(options!=null)validateObject(options,\"options\");if(options==null)options=kEmptyObject;if(callback!=null)validateFunction(callback,\"callback\");if(options.argv0!=null)validateString(options.argv0,\"options.argv0\"),validateArgumentNullCheck(options.argv0,\"options.argv0\");return{file,args,options,callback}}function normalizeExecArgs(command,options,callback){if(validateString(command,\"command\"),validateArgumentNullCheck(command,\"command\"),typeof options===\"function\")callback=options,options=void 0;return options={...options},options.shell=typeof options.shell===\"string\"\?options.shell:!0,{file:command,options,callback}}function normalizeSpawnArguments(file,args,options){if(validateString(file,\"file\"),validateArgumentNullCheck(file,\"file\"),file.length===0)throw new ERR_INVALID_ARG_VALUE(\"file\",file,\"cannot be empty\");if(ArrayIsArray(args))args=ArrayPrototypeSlice.call(args);else if(args==null)args=[];else if(typeof args!==\"object\")throw new ERR_INVALID_ARG_TYPE(\"args\",\"object\",args);else options=args,args=[];if(validateArgumentsNullCheck(args,\"args\"),options===void 0)options={};else validateObject(options,\"options\");let cwd=options.cwd;if(cwd!=null)cwd=getValidatedPath(cwd,\"options.cwd\");if(options.shell!=null&&typeof options.shell!==\"boolean\"&&typeof options.shell!==\"string\")throw new ERR_INVALID_ARG_TYPE(\"options.shell\",[\"boolean\",\"string\"],options.shell);if(options.argv0!=null)validateString(options.argv0,\"options.argv0\"),validateArgumentNullCheck(options.argv0,\"options.argv0\");if(options.shell){validateArgumentNullCheck(options.shell,\"options.shell\");const command=ArrayPrototypeJoin.call([file,...args],\" \");if(typeof options.shell===\"string\")file=options.shell;else file=\"sh\";args=[\"-c\",command]}if(typeof options.argv0===\"string\")ArrayPrototypeUnshift.call(args,options.argv0);else ArrayPrototypeUnshift.call(args,file);const envPairs=options.env||process.env;return{...options,file,args,cwd,envPairs}}function checkExecSyncError(ret,args,cmd){let err;if(ret.error)err=ret.error,ObjectAssign(err,ret);else if(ret.status!==0){let msg=\"Command failed: \";if(msg+=cmd||ArrayPrototypeJoin.call(args,\" \"),ret.stderr&&ret.stderr.length>0)msg+=`\\n${ret.stderr.toString()}`;err=genericNodeError(msg,ret)}return err}class ChildProcess extends EventEmitter{constructor(){super(...arguments)}#handle;#exited=!1;#closesNeeded=1;#closesGot=0;connected=!1;signalCode=null;exitCode=null;spawnfile;spawnargs;pid;channel;get killed(){if(this.#handle==null)return!1}#handleOnExit(exitCode,signalCode,err){if(this.#exited)return;if(signalCode)this.signalCode=signalCode;else this.exitCode=exitCode;if(this.#stdin)this.#stdin.destroy();if(this.#handle)this.#handle=null;if(exitCode<0){const err2=new SystemError(`Spawned process exited with error code: ${exitCode}`,void 0,\"spawn\",\"EUNKNOWN\",\"ERR_CHILD_PROCESS_UNKNOWN_ERROR\");if(this.spawnfile)err2.path=this.spawnfile;err2.spawnargs=ArrayPrototypeSlice.call(this.spawnargs,1),this.emit(\"error\",err2)}else this.emit(\"exit\",this.exitCode,this.signalCode);process.nextTick(flushStdio,this),this.#maybeClose(),this.#exited=!0,this.#stdioOptions=[\"destroyed\",\"destroyed\",\"destroyed\"]}#getBunSpawnIo(i,encoding){NativeWritable||=StreamModule.NativeWritable,ReadableFromWeb||=StreamModule.Readable.fromWeb;const io=this.#stdioOptions[i];switch(i){case 0:switch(io){case\"pipe\":return new NativeWritable(this.#handle.stdin);case\"inherit\":return process.stdin||null;case\"destroyed\":return new ShimmedStdin;default:return null}case 2:case 1:switch(io){case\"pipe\":return ReadableFromWeb(this.#handle[fdToStdioName(i)],{encoding});case\"inherit\":return process[fdToStdioName(i)]||null;case\"destroyed\":return new ShimmedStdioOutStream;default:return null}}}#stdin;#stdout;#stderr;#stdioObject;#encoding;#stdioOptions;#createStdioObject(){return Object.create(null,{0:{get:()=>this.stdin},1:{get:()=>this.stdout},2:{get:()=>this.stderr}})}get stdin(){return this.#stdin\?\?=this.#getBunSpawnIo(0,this.#encoding)}get stdout(){return this.#stdout\?\?=this.#getBunSpawnIo(1,this.#encoding)}get stderr(){return this.#stderr\?\?=this.#getBunSpawnIo(2,this.#encoding)}get stdio(){return this.#stdioObject\?\?=this.#createStdioObject()}spawn(options){validateObject(options,\"options\"),validateString(options.file,\"options.file\");var file=this.spawnfile=options.file,spawnargs;if(options.args==null)spawnargs=this.spawnargs=[];else validateArray(options.args,\"options.args\"),spawnargs=this.spawnargs=options.args;const stdio=options.stdio||[\"pipe\",\"pipe\",\"pipe\"],bunStdio=getBunStdioFromOptions(stdio);var env=options.envPairs||void 0;this.#encoding=options.encoding||void 0,this.#stdioOptions=bunStdio,this.#handle=Bun.spawn({cmd:spawnargs,stdin:bunStdio[0],stdout:bunStdio[1],stderr:bunStdio[2],cwd:options.cwd||void 0,env:env||process.env,onExit:(handle,exitCode,signalCode,err)=>{this.#handle=handle,this.pid=this.#handle.pid,process.nextTick((exitCode2,signalCode2,err2)=>this.#handleOnExit(exitCode2,signalCode2,err2),exitCode,signalCode,err)},lazy:!0}),this.pid=this.#handle.pid,onSpawnNT(this)}send(){console.log(\"ChildProcess.prototype.send() - Sorry! Not implemented yet\")}disconnect(){console.log(\"ChildProcess.prototype.disconnect() - Sorry! Not implemented yet\")}kill(sig){const signal=sig===0\?sig:convertToValidSignal(sig===void 0\?\"SIGTERM\":sig);if(this.#handle)this.#handle.kill(signal);return this.#maybeClose(),!0}#maybeClose(){if(this.#closesGot++,this.#closesGot===this.#closesNeeded)this.emit(\"close\",this.exitCode,this.signalCode)}ref(){if(this.#handle)this.#handle.ref()}unref(){if(this.#handle)this.#handle.unref()}}const nodeToBunLookup={ignore:null,pipe:\"pipe\",overlapped:\"pipe\",inherit:\"inherit\"};function nodeToBun(item){if(typeof item===\"number\")return item;else{const result=nodeToBunLookup[item];if(result===void 0)throw new Error(\"Invalid stdio option\");return result}}function fdToStdioName(fd){switch(fd){case 0:return\"stdin\";case 1:return\"stdout\";case 2:return\"stderr\";default:return null}}function getBunStdioFromOptions(stdio){return normalizeStdio(stdio).map((item)=>nodeToBun(item))}function normalizeStdio(stdio){if(typeof stdio===\"string\")switch(stdio){case\"ignore\":return[\"ignore\",\"ignore\",\"ignore\"];case\"pipe\":return[\"pipe\",\"pipe\",\"pipe\"];case\"inherit\":return[\"inherit\",\"inherit\",\"inherit\"];default:throw new ERR_INVALID_OPT_VALUE(\"stdio\",stdio)}else if(ArrayIsArray(stdio)){let processedStdio;if(stdio.length===0)processedStdio=[\"pipe\",\"pipe\",\"pipe\"];else if(stdio.length===1)processedStdio=[stdio[0],\"pipe\",\"pipe\"];else if(stdio.length===2)processedStdio=[stdio[0],stdio[1],\"pipe\"];else if(stdio.length>=3)processedStdio=[stdio[0],stdio[1],stdio[2]];return processedStdio.map((item)=>!item\?\"pipe\":item)}else throw new ERR_INVALID_OPT_VALUE(\"stdio\",stdio)}function flushStdio(subprocess){const stdio=subprocess.stdio;if(stdio==null)return;for(let i=0;i=0))throw new ERR_OUT_OF_RANGE(\"options.maxBuffer\",\"a positive number\",maxBuffer)}function validateArgumentNullCheck(arg,propName){if(typeof arg===\"string\"&&StringPrototypeIncludes.call(arg,\"\\0\"))throw new ERR_INVALID_ARG_VALUE(propName,arg,\"must be a string without null bytes\")}function validateArgumentsNullCheck(args,propName){for(let i=0;i=0))throw new ERR_OUT_OF_RANGE(\"timeout\",\"an unsigned integer\",timeout)}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}function validateFunction(value,name){if(typeof value!==\"function\")throw new ERR_INVALID_ARG_TYPE(name,\"Function\",value)}const validateAbortSignal=(signal,name)=>{if(signal!==void 0&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE(name,\"AbortSignal\",signal)},validateOneOf=(value,name,oneOf)=>{if(!ArrayPrototypeIncludes.call(oneOf,value)){const reason=\"must be one of: \"+ArrayPrototypeJoin.call(ArrayPrototypeMap.call(oneOf,(v)=>typeof v===\"string\"\?`'${v}'`:String(v)),\", \");throw new ERR_INVALID_ARG_VALUE(name,value,reason)}},validateObject=(value,name,options=null)=>{const allowArray=options\?.allowArray\?\?!1,allowFunction=options\?.allowFunction\?\?!1;if(!(options\?.nullable\?\?!1)&&value===null||!allowArray&&ArrayIsArray.call(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE(name,\"object\",value)},validateArray=(value,name,minLength=0)=>{if(!ArrayIsArray(value))throw new ERR_INVALID_ARG_TYPE(name,\"Array\",value);if(value.lengthfunction(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},require_safe_buffer=__commonJS({\"node_modules/safe-buffer/index.js\"(exports,module){var buffer=BufferModule,Buffer2=buffer.Buffer;function copyProps(src,dst){for(var key in src)dst[key]=src[key]}Buffer2.from&&Buffer2.alloc&&Buffer2.allocUnsafe&&Buffer2.allocUnsafeSlow\?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer);function SafeBuffer(arg,encodingOrOffset,length){return Buffer2(arg,encodingOrOffset,length)}SafeBuffer.prototype=Object.create(Buffer2.prototype),copyProps(Buffer2,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if(typeof arg==\"number\")@throwTypeError(\"Argument must not be a number\");return Buffer2(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");var buf=Buffer2(size);return fill!==void 0\?typeof encoding==\"string\"\?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf},SafeBuffer.allocUnsafe=function(size){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");return Buffer2(size)},SafeBuffer.allocUnsafeSlow=function(size){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");return buffer.SlowBuffer(size)}}}),require_browser=__commonJS({\"node_modules/randombytes/browser.js\"(exports,module){var MAX_BYTES=65536,MAX_UINT32=4294967295;function oldBrowser(){throw new Error(`Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11`)}var Buffer2=require_safe_buffer().Buffer,crypto2=globalCrypto;crypto2&&crypto2.getRandomValues\?module.exports=randomBytes:module.exports=oldBrowser;function randomBytes(size,cb){if(size>MAX_UINT32)@throwRangeError(\"requested too many random bytes\");var bytes=Buffer2.allocUnsafe(size);if(size>0)if(size>MAX_BYTES)for(var generated=0;generated=this._blockSize;){for(var i=this._blockOffset;i0;++j)this._length[j]+=carry,carry=this._length[j]/4294967296|0,carry>0&&(this._length[j]-=4294967296*carry);return this},HashBase.prototype._update=function(){throw new Error(\"_update is not implemented\")},HashBase.prototype.digest=function(encoding){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var digest=this._digest();encoding!==void 0&&(digest=digest.toString(encoding)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return digest},HashBase.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},module.exports=HashBase}}),require_md5=__commonJS({\"node_modules/md5.js/index.js\"(exports,module){var inherits=require_inherits_browser(),HashBase=require_hash_base(),Buffer2=require_safe_buffer().Buffer,ARRAY16=new Array(16);function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;i<16;++i)M[i]=this._block.readInt32LE(i*4);var a=this._a,b=this._b,c=this._c,d=this._d;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),b=fnF(b,c,d,a,M[15],1236535329,22),a=fnG(a,b,c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),b=fnG(b,c,d,a,M[12],2368359562,20),a=fnH(a,b,c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),b=fnH(b,c,d,a,M[2],3299628645,23),a=fnI(a,b,c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,d,a,M[9],3951481745,21),this._a=this._a+a|0,this._b=this._b+b|0,this._c=this._c+c|0,this._d=this._d+d|0},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer2.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer};function rotl(x,n){return x<>>32-n}function fnF(a,b,c,d,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+b|0}function fnG(a,b,c,d,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+b|0}function fnH(a,b,c,d,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+b|0}function fnI(a,b,c,d,m,k,s){return rotl(a+(c^(b|~d))+m+k|0,s)+b|0}module.exports=MD5}}),require_ripemd160=__commonJS({\"node_modules/ripemd160/index.js\"(exports,module){var Buffer2=Buffer,inherits=require_inherits_browser(),HashBase=require_hash_base(),ARRAY16=new Array(16),zl=[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],zr=[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],sl=[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],sr=[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],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;j<16;++j)words[j]=this._block.readInt32LE(j*4);for(var al=this._a|0,bl=this._b|0,cl=this._c|0,dl=this._d|0,el=this._e|0,ar=this._a|0,br=this._b|0,cr=this._c|0,dr=this._d|0,er=this._e|0,i=0;i<80;i+=1){var tl,tr;i<16\?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):i<32\?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):i<48\?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):i<64\?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}var t=this._b+cl+dr|0;this._b=this._c+dl+er|0,this._c=this._d+el+ar|0,this._d=this._e+al+br|0,this._e=this._a+bl+cr|0,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer2.alloc\?Buffer2.alloc(20):new Buffer2(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer};function rotl(x,n){return x<>>32-n}function fn1(a,b,c,d,e,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+e|0}function fn2(a,b,c,d,e,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+e|0}function fn3(a,b,c,d,e,m,k,s){return rotl(a+((b|~c)^d)+m+k|0,s)+e|0}function fn4(a,b,c,d,e,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+e|0}function fn5(a,b,c,d,e,m,k,s){return rotl(a+(b^(c|~d))+m+k|0,s)+e|0}module.exports=RIPEMD160}}),require_hash=__commonJS({\"node_modules/sha.js/hash.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer;function Hash(blockSize,finalSize){this._block=Buffer2.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}Hash.prototype={},Hash.prototype.update=function(data,enc){typeof data==\"string\"&&(enc=enc||\"utf8\",data=Buffer2.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=this._len*8;if(bits<=4294967295)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=(bits&4294967295)>>>0,highBits=(bits-lowBits)/4294967296;this._block.writeUInt32BE(highBits,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc\?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},module.exports=Hash}}),require_sha=__commonJS({\"node_modules/sha.js/sha.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return s===0\?b&c|~b&d:s===2\?b&c|b&d|c&d:b^c^d}Sha.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<80;++i)W2[i]=W2[i-3]^W2[i-8]^W2[i-14]^W2[i-16];for(var j=0;j<80;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W2[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha.prototype._hash=function(){var H=Buffer2.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},module.exports=Sha}}),require_sha1=__commonJS({\"node_modules/sha.js/sha1.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return s===0\?b&c|~b&d:s===2\?b&c|b&d|c&d:b^c^d}Sha1.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<80;++i)W2[i]=rotl1(W2[i-3]^W2[i-8]^W2[i-14]^W2[i-16]);for(var j=0;j<80;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W2[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha1.prototype._hash=function(){var H=Buffer2.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},module.exports=Sha1}}),require_sha256=__commonJS({\"node_modules/sha.js/sha256.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=new Array(64);function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}Sha256.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,f=this._f|0,g=this._g|0,h=this._h|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<64;++i)W2[i]=gamma1(W2[i-2])+W2[i-7]+gamma0(W2[i-15])+W2[i-16]|0;for(var j=0;j<64;++j){var T1=h+sigma1(e)+ch(e,f,g)+K[j]+W2[j]|0,T2=sigma0(a)+maj(a,b,c)|0;h=g,g=f,f=e,e=d+T1|0,d=c,c=b,b=a,a=T1+T2|0}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0,this._f=f+this._f|0,this._g=g+this._g|0,this._h=h+this._h|0},Sha256.prototype._hash=function(){var H=Buffer2.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256}}),require_sha224=__commonJS({\"node_modules/sha.js/sha224.js\"(exports,module){var inherits=require_inherits_browser(),Sha256=require_sha256(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,W=new Array(64);function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer2.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224}}),require_sha512=__commonJS({\"node_modules/sha.js/sha512.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=new Array(160);function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0>>0\?1:0}Sha512.prototype._update=function(M){for(var W2=this._w,ah=this._ah|0,bh=this._bh|0,ch=this._ch|0,dh=this._dh|0,eh=this._eh|0,fh=this._fh|0,gh=this._gh|0,hh=this._hh|0,al=this._al|0,bl=this._bl|0,cl=this._cl|0,dl=this._dl|0,el=this._el|0,fl=this._fl|0,gl=this._gl|0,hl=this._hl|0,i=0;i<32;i+=2)W2[i]=M.readInt32BE(i*4),W2[i+1]=M.readInt32BE(i*4+4);for(;i<160;i+=2){var xh=W2[i-30],xl=W2[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W2[i-4],xl=W2[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W2[i-14],Wi7l=W2[i-14+1],Wi16h=W2[i-32],Wi16l=W2[i-32+1],Wil=gamma0l+Wi7l|0,Wih=gamma0+Wi7h+getCarry(Wil,gamma0l)|0;Wil=Wil+gamma1l|0,Wih=Wih+gamma1+getCarry(Wil,gamma1l)|0,Wil=Wil+Wi16l|0,Wih=Wih+Wi16h+getCarry(Wil,Wi16l)|0,W2[i]=Wih,W2[i+1]=Wil}for(var j=0;j<160;j+=2){Wih=W2[j],Wil=W2[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=hl+sigma1l|0,t1h=hh+sigma1h+getCarry(t1l,hl)|0;t1l=t1l+chl|0,t1h=t1h+chh+getCarry(t1l,chl)|0,t1l=t1l+Kil|0,t1h=t1h+Kih+getCarry(t1l,Kil)|0,t1l=t1l+Wil|0,t1h=t1h+Wih+getCarry(t1l,Wil)|0;var t2l=sigma0l+majl|0,t2h=sigma0h+majh+getCarry(t2l,sigma0l)|0;hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=dl+t1l|0,eh=dh+t1h+getCarry(el,dl)|0,dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=t1l+t2l|0,ah=t1h+t2h+getCarry(al,t1l)|0}this._al=this._al+al|0,this._bl=this._bl+bl|0,this._cl=this._cl+cl|0,this._dl=this._dl+dl|0,this._el=this._el+el|0,this._fl=this._fl+fl|0,this._gl=this._gl+gl|0,this._hl=this._hl+hl|0,this._ah=this._ah+ah+getCarry(this._al,al)|0,this._bh=this._bh+bh+getCarry(this._bl,bl)|0,this._ch=this._ch+ch+getCarry(this._cl,cl)|0,this._dh=this._dh+dh+getCarry(this._dl,dl)|0,this._eh=this._eh+eh+getCarry(this._el,el)|0,this._fh=this._fh+fh+getCarry(this._fl,fl)|0,this._gh=this._gh+gh+getCarry(this._gl,gl)|0,this._hh=this._hh+hh+getCarry(this._hl,hl)|0},Sha512.prototype._hash=function(){var H=Buffer2.allocUnsafe(64);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512}}),require_sha384=__commonJS({\"node_modules/sha.js/sha384.js\"(exports,module){var inherits=require_inherits_browser(),SHA512=require_sha512(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,W=new Array(160);function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){var H=Buffer2.allocUnsafe(48);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384}}),require_sha2=__commonJS({\"node_modules/sha.js/index.js\"(exports,module){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+\" is not supported (we accept pull requests)\");return new Algorithm};exports.sha=require_sha(),exports.sha1=require_sha1(),exports.sha224=require_sha224(),exports.sha256=require_sha256(),exports.sha384=require_sha384(),exports.sha512=require_sha512()}}),require_cipher_base=__commonJS({\"node_modules/cipher-base/index.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,inherits=require_inherits_browser();function CipherBase(hashMode){StreamModule.Transform.call(this),this.hashMode=typeof hashMode==\"string\",this.hashMode\?this[hashMode]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}inherits(CipherBase,StreamModule.Transform),CipherBase.prototype.update=function(data,inputEnc,outputEnc){typeof data==\"string\"&&(data=Buffer2.from(data,inputEnc));var outData=this._update(data);return this.hashMode\?this:(outputEnc&&(outData=this._toString(outData,outputEnc)),outData)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},CipherBase.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},CipherBase.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},CipherBase.prototype._transform=function(data,_,next){var err;try{this.hashMode\?this._update(data):this.push(this._update(data))}catch(e){err=e}finally{next(err)}},CipherBase.prototype._flush=function(done){var err;try{this.push(this.__final())}catch(e){err=e}done(err)},CipherBase.prototype._finalOrDigest=function(outputEnc){var outData=this.__final()||Buffer2.alloc(0);return outputEnc&&(outData=this._toString(outData,outputEnc,!0)),outData},CipherBase.prototype._toString=function(value,enc,fin){if(this._decoder||(this._decoder=new StringDecoder(enc),this._encoding=enc),this._encoding!==enc)throw new Error(\"can't switch encodings\");var out=this._decoder.write(value);return fin&&(out+=this._decoder.end()),out},module.exports=CipherBase}}),require_browser2=__commonJS({\"node_modules/create-hash/browser.js\"(exports,module){const LazyHash=function Hash(algorithm,options){this._options=options,this._hasher=new CryptoHasher(algorithm,options),this._finalized=!1};LazyHash.prototype=Object.create(StreamModule.Transform.prototype),LazyHash.prototype.update=function update(data,encoding){return this._checkFinalized(),this._hasher.update(data,encoding),this},LazyHash.prototype.digest=function update(data,encoding){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(data,encoding)},LazyHash.prototype._checkFinalized=function _checkFinalized(){if(this._finalized){var err=new Error(\"Digest already called\");throw err.code=\"ERR_CRYPTO_HASH_FINALIZED\",err}},LazyHash.prototype.copy=function copy(){const copy=Object.create(LazyHash.prototype);return copy._options=this._options,copy._hasher=this._hasher.copy(),copy._finalized=this._finalized,copy};const lazyHashFullInitProto={__proto__:StreamModule.Transform.prototype,...LazyHash.prototype,_transform(data,encoding,callback){this.update(data,encoding),callback&&callback()},_flush(callback){this.push(this.digest()),callback()}},triggerMethods=[\"_events\",\"_eventsCount\",\"_final\",\"_maxListeners\",\"_maxListeners\",\"_read\",\"_undestroy\",\"_writableState\",\"_write\",\"_writev\",\"addListener\",\"asIndexedPairs\",\"closed\",\"compose\",\"constructor\",\"cork\",\"destroy\",\"destroyed\",\"drop\",\"emit\",\"end\",\"errored\",\"eventNames\",\"every\",\"filter\",\"find\",\"flatMap\",\"forEach\",\"getMaxListeners\",\"hasOwnProperty\",\"isPaused\",\"isPrototypeOf\",\"iterator\",\"listenerCount\",\"listeners\",\"map\",\"off\",\"on\",\"once\",\"pause\",\"pipe\",\"prependListener\",\"prependOnceListener\",\"propertyIsEnumerable\",\"push\",\"rawListeners\",\"read\",\"readable\",\"readableAborted\",\"readableBuffer\",\"readableDidRead\",\"readableEncoding\",\"readableEnded\",\"readableFlowing\",\"readableHighWaterMark\",\"readableLength\",\"readableObjectMode\",\"reduce\",\"removeAllListeners\",\"removeListener\",\"resume\",\"setDefaultEncoding\",\"setEncoding\",\"setMaxListeners\",\"some\",\"take\",\"toArray\",\"toLocaleString\",\"toString\",\"uncork\",\"unpipe\",\"unshift\",\"valueOf\",\"wrap\",\"writable\",\"writableBuffer\",\"writableCorked\",\"writableEnded\",\"writableFinished\",\"writableHighWaterMark\",\"writableLength\",\"writableNeedDrain\",\"writableObjectMode\",\"write\"];for(let method of triggerMethods)Object.defineProperty(LazyHash.prototype,method,{get(){return Object.setPrototypeOf(this,lazyHashFullInitProto),StreamModule.Transform.call(this,this._options),this[method]},enumerable:!1,configurable:!0});module.exports=function createHash(algorithm){return new LazyHash(algorithm)},module.exports.createHash=module.exports,module.exports.Hash=LazyHash}}),require_legacy=__commonJS({\"node_modules/create-hmac/legacy.js\"(exports,module){var inherits=require_inherits_browser(),Buffer2=require_safe_buffer().Buffer,Base=require_cipher_base(),ZEROS=Buffer2.alloc(128),blocksize=64;function Hmac(alg,key){Base.call(this,\"digest\"),typeof key==\"string\"&&(key=Buffer2.from(key)),this._alg=alg,this._key=key,key.length>blocksize\?key=alg(key):key.lengthblocksize){var hash=alg===\"rmd160\"\?new RIPEMD160:sha(alg);key=hash.update(key).digest()}else key.lengthMAX_ALLOC||keylen!==keylen)@throwTypeError(\"Bad key length\")}}}),require_default_encoding=__commonJS({\"node_modules/pbkdf2/lib/default-encoding.js\"(exports,module){var defaultEncoding;global.process&&global.process.browser\?defaultEncoding=\"utf-8\":global.process&&global.process.version\?(pVersionMajor=parseInt(process.version.split(\".\")[0].slice(1),10),defaultEncoding=pVersionMajor>=6\?\"utf-8\":\"binary\"):defaultEncoding=\"utf-8\";var pVersionMajor;module.exports=defaultEncoding}}),require_to_buffer=__commonJS({\"node_modules/pbkdf2/lib/to-buffer.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer;module.exports=function(thing,encoding,name){if(Buffer2.isBuffer(thing))return thing;if(typeof thing==\"string\")return Buffer2.from(thing,encoding);if(ArrayBuffer.isView(thing))return Buffer2.from(thing.buffer);@throwTypeError(name+\" must be a string, a Buffer, a typed array or a DataView\")}}}),require_sync_browser=__commonJS({\"node_modules/pbkdf2/lib/sync-browser.js\"(exports,module){var md5=require_md52(),RIPEMD160=require_ripemd160(),sha=require_sha2(),Buffer2=require_safe_buffer().Buffer,checkParameters=require_precondition(),defaultEncoding=require_default_encoding(),toBuffer=require_to_buffer(),ZEROS=Buffer2.alloc(128),sizes={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Hmac(alg,key,saltLen){var hash=getDigest(alg),blocksize=alg===\"sha512\"||alg===\"sha384\"\?128:64;key.length>blocksize\?key=hash(key):key.length>>0},exports.writeUInt32BE=function(bytes,value,off){bytes[0+off]=value>>>24,bytes[1+off]=value>>>16&255,bytes[2+off]=value>>>8&255,bytes[3+off]=value&255},exports.ip=function(inL,inR,out,off){for(var outL=0,outR=0,i=6;i>=0;i-=2){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>>j+i&1;for(var j=0;j<=24;j+=8)outL<<=1,outL|=inL>>>j+i&1}for(var i=6;i>=0;i-=2){for(var j=1;j<=25;j+=8)outR<<=1,outR|=inR>>>j+i&1;for(var j=1;j<=25;j+=8)outR<<=1,outR|=inL>>>j+i&1}out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.rip=function(inL,inR,out,off){for(var outL=0,outR=0,i=0;i<4;i++)for(var j=24;j>=0;j-=8)outL<<=1,outL|=inR>>>j+i&1,outL<<=1,outL|=inL>>>j+i&1;for(var i=4;i<8;i++)for(var j=24;j>=0;j-=8)outR<<=1,outR|=inR>>>j+i&1,outR<<=1,outR|=inL>>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.pc1=function(inL,inR,out,off){for(var outL=0,outR=0,i=7;i>=5;i--){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var j=0;j<=24;j+=8)outL<<=1,outL|=inL>>j+i&1}for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var i=1;i<=3;i++){for(var j=0;j<=24;j+=8)outR<<=1,outR|=inR>>j+i&1;for(var j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1}for(var j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.r28shl=function(num,shift){return num<>>28-shift};var pc2table=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];exports.pc2=function(inL,inR,out,off){for(var outL=0,outR=0,len=pc2table.length>>>1,i=0;i>>pc2table[i]&1;for(var i=len;i>>pc2table[i]&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.expand=function(r,out,off){var outL=0,outR=0;outL=(r&1)<<5|r>>>27;for(var i=23;i>=15;i-=4)outL<<=6,outL|=r>>>i&63;for(var i=11;i>=3;i-=4)outR|=r>>>i&63,outR<<=6;outR|=(r&31)<<1|r>>>31,out[off+0]=outL>>>0,out[off+1]=outR>>>0};var sTable=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];exports.substitute=function(inL,inR){for(var out=0,i=0;i<4;i++){var b=inL>>>18-i*6&63,sb=sTable[i*64+b];out<<=4,out|=sb}for(var i=0;i<4;i++){var b=inR>>>18-i*6&63,sb=sTable[256+i*64+b];out<<=4,out|=sb}return out>>>0};var permuteTable=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];exports.permute=function(num){for(var out=0,i=0;i>>permuteTable[i]&1;return out>>>0},exports.padSplit=function(num,size,group){for(var str=num.toString(2);str.length0;count--)inputOff+=this._buffer(data,inputOff),outputOff+=this._flushBuffer(out,outputOff);return inputOff+=this._buffer(data,inputOff),out},Cipher.prototype.final=function(buffer){var first;buffer&&(first=this.update(buffer));var last;return this.type===\"encrypt\"\?last=this._finalEncrypt():last=this._finalDecrypt(),first\?first.concat(last):last},Cipher.prototype._pad=function(buffer,off){if(off===0)return!1;for(;off>>1];kL=utils.r28shl(kL,shift),kR=utils.r28shl(kR,shift),utils.pc2(kL,kR,state.keys,i)}},DES.prototype._update=function(inp,inOff,out,outOff){var state=this._desState,l=utils.readUInt32BE(inp,inOff),r=utils.readUInt32BE(inp,inOff+4);utils.ip(l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],this.type===\"encrypt\"\?this._encrypt(state,l,r,state.tmp,0):this._decrypt(state,l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],utils.writeUInt32BE(out,l,outOff),utils.writeUInt32BE(out,r,outOff+4)},DES.prototype._pad=function(buffer,off){for(var value=buffer.length-off,i=off;i>>0,l=t}utils.rip(r,l,out,off)},DES.prototype._decrypt=function(state,lStart,rStart,out,off){for(var l=rStart,r=lStart,i=state.keys.length-2;i>=0;i-=2){var keyL=state.keys[i],keyR=state.keys[i+1];utils.expand(l,state.tmp,0),keyL^=state.tmp[0],keyR^=state.tmp[1];var s=utils.substitute(keyL,keyR),f=utils.permute(s),t=l;l=(r^f)>>>0,r=t}utils.rip(l,r,out,off)}}}),require_cbc=__commonJS({\"node_modules/des.js/lib/des/cbc.js\"(exports){var assert=require_minimalistic_assert(),inherits=require_inherits_browser(),proto={};function CBCState(iv){assert.equal(iv.length,8,\"Invalid IV length\"),this.iv=new Array(8);for(var i=0;i>i%8,self2._prev=shiftIn(self2._prev,decrypt\?bit:value);return out}function shiftIn(buffer,value){var len=buffer.length,i=-1,out=Buffer2.allocUnsafe(buffer.length);for(buffer=Buffer2.concat([buffer,Buffer2.from([value])]);++i>7;return out}exports.encrypt=function(self2,chunk,decrypt){for(var len=chunk.length,out=Buffer2.allocUnsafe(len),i=-1;++i>>24]^SUB_MIX1[s1>>>16&255]^SUB_MIX2[s2>>>8&255]^SUB_MIX3[s3&255]^keySchedule[ksRow++],t1=SUB_MIX0[s1>>>24]^SUB_MIX1[s2>>>16&255]^SUB_MIX2[s3>>>8&255]^SUB_MIX3[s0&255]^keySchedule[ksRow++],t2=SUB_MIX0[s2>>>24]^SUB_MIX1[s3>>>16&255]^SUB_MIX2[s0>>>8&255]^SUB_MIX3[s1&255]^keySchedule[ksRow++],t3=SUB_MIX0[s3>>>24]^SUB_MIX1[s0>>>16&255]^SUB_MIX2[s1>>>8&255]^SUB_MIX3[s2&255]^keySchedule[ksRow++],s0=t0,s1=t1,s2=t2,s3=t3;return t0=(SBOX[s0>>>24]<<24|SBOX[s1>>>16&255]<<16|SBOX[s2>>>8&255]<<8|SBOX[s3&255])^keySchedule[ksRow++],t1=(SBOX[s1>>>24]<<24|SBOX[s2>>>16&255]<<16|SBOX[s3>>>8&255]<<8|SBOX[s0&255])^keySchedule[ksRow++],t2=(SBOX[s2>>>24]<<24|SBOX[s3>>>16&255]<<16|SBOX[s0>>>8&255]<<8|SBOX[s1&255])^keySchedule[ksRow++],t3=(SBOX[s3>>>24]<<24|SBOX[s0>>>16&255]<<16|SBOX[s1>>>8&255]<<8|SBOX[s2&255])^keySchedule[ksRow++],t0=t0>>>0,t1=t1>>>0,t2=t2>>>0,t3=t3>>>0,[t0,t1,t2,t3]}var RCON=[0,1,2,4,8,16,32,64,128,27,54],G=function(){for(var d=new Array(256),j=0;j<256;j++)j<128\?d[j]=j<<1:d[j]=j<<1^283;for(var SBOX=[],INV_SBOX=[],SUB_MIX=[[],[],[],[]],INV_SUB_MIX=[[],[],[],[]],x=0,xi=0,i=0;i<256;++i){var sx=xi^xi<<1^xi<<2^xi<<3^xi<<4;sx=sx>>>8^sx&255^99,SBOX[x]=sx,INV_SBOX[sx]=x;var x2=d[x],x4=d[x2],x8=d[x4],t=d[sx]*257^sx*16843008;SUB_MIX[0][x]=t<<24|t>>>8,SUB_MIX[1][x]=t<<16|t>>>16,SUB_MIX[2][x]=t<<8|t>>>24,SUB_MIX[3][x]=t,t=x8*16843009^x4*65537^x2*257^x*16843008,INV_SUB_MIX[0][sx]=t<<24|t>>>8,INV_SUB_MIX[1][sx]=t<<16|t>>>16,INV_SUB_MIX[2][sx]=t<<8|t>>>24,INV_SUB_MIX[3][sx]=t,x===0\?x=xi=1:(x=x2^d[d[d[x8^x2]]],xi^=d[d[xi]])}return{SBOX,INV_SBOX,SUB_MIX,INV_SUB_MIX}}();function AES(key){this._key=asUInt32Array(key),this._reset()}AES.prototype={},AES.blockSize=16,AES.keySize=32,AES.prototype.blockSize=AES.blockSize,AES.prototype.keySize=AES.keySize,AES.prototype._reset=function(){for(var keyWords=this._key,keySize=keyWords.length,nRounds=keySize+6,ksRows=(nRounds+1)*4,keySchedule=[],k=0;k>>24,t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[t&255],t^=RCON[k/keySize|0]<<24):keySize>6&&k%keySize===4&&(t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[t&255]),keySchedule[k]=keySchedule[k-keySize]^t}for(var invKeySchedule=[],ik=0;ik>>24]]^G.INV_SUB_MIX[1][G.SBOX[tt>>>16&255]]^G.INV_SUB_MIX[2][G.SBOX[tt>>>8&255]]^G.INV_SUB_MIX[3][G.SBOX[tt&255]]}this._nRounds=nRounds,this._keySchedule=keySchedule,this._invKeySchedule=invKeySchedule},AES.prototype.encryptBlockRaw=function(M){return M=asUInt32Array(M),cryptBlock(M,this._keySchedule,G.SUB_MIX,G.SBOX,this._nRounds)},AES.prototype.encryptBlock=function(M){var out=this.encryptBlockRaw(M),buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[1],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[3],12),buf},AES.prototype.decryptBlock=function(M){M=asUInt32Array(M);var m1=M[1];M[1]=M[3],M[3]=m1;var out=cryptBlock(M,this._invKeySchedule,G.INV_SUB_MIX,G.INV_SBOX,this._nRounds),buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[3],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[1],12),buf},AES.prototype.scrub=function(){scrubVec(this._keySchedule),scrubVec(this._invKeySchedule),scrubVec(this._key)},module.exports.AES=AES}}),require_ghash=__commonJS({\"node_modules/browserify-aes/ghash.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,ZEROES=Buffer2.alloc(16,0);function toArray(buf){return[buf.readUInt32BE(0),buf.readUInt32BE(4),buf.readUInt32BE(8),buf.readUInt32BE(12)]}function fromArray(out){var buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0]>>>0,0),buf.writeUInt32BE(out[1]>>>0,4),buf.writeUInt32BE(out[2]>>>0,8),buf.writeUInt32BE(out[3]>>>0,12),buf}function GHASH(key){this.h=key,this.state=Buffer2.alloc(16,0),this.cache=Buffer2.allocUnsafe(0)}GHASH.prototype={},GHASH.prototype.ghash=function(block){for(var i=-1;++i0;j--)Vi[j]=Vi[j]>>>1|(Vi[j-1]&1)<<31;Vi[0]=Vi[0]>>>1,lsbVi&&(Vi[0]=Vi[0]^225<<24)}this.state=fromArray(Zi)},GHASH.prototype.update=function(buf){this.cache=Buffer2.concat([this.cache,buf]);for(var chunk;this.cache.length>=16;)chunk=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(chunk)},GHASH.prototype.final=function(abl,bl){return this.cache.length&&this.ghash(Buffer2.concat([this.cache,ZEROES],16)),this.ghash(fromArray([0,abl,0,bl])),this.state},module.exports=GHASH}}),require_authCipher=__commonJS({\"node_modules/browserify-aes/authCipher.js\"(exports,module){var aes=require_aes(),Buffer2=require_safe_buffer().Buffer,Transform=require_cipher_base(),inherits=require_inherits_browser(),GHASH=require_ghash(),xor=require_buffer_xor(),incr32=require_incr32();function xorTest(a,b){var out=0;a.length!==b.length&&out++;for(var len=Math.min(a.length,b.length),i=0;i0||ivLen>0;){var hash=new MD5;hash.update(tmp),hash.update(password),salt&&hash.update(salt),tmp=hash.digest();var used=0;if(keyLen>0){var keyStart=key.length-keyLen;used=Math.min(keyLen,tmp.length),tmp.copy(key,keyStart,0,used),keyLen-=used}if(used0){var ivStart=iv.length-ivLen,length=Math.min(ivLen,tmp.length-used);tmp.copy(iv,ivStart,used,used+length),ivLen-=length}}return tmp.fill(0),{key,iv}}module.exports=EVP_BytesToKey}}),require_encrypter=__commonJS({\"node_modules/browserify-aes/encrypter.js\"(exports){var MODES=require_modes(),AuthCipher=require_authCipher(),Buffer2=require_safe_buffer().Buffer,StreamCipher=require_streamCipher(),Transform=require_cipher_base(),aes=require_aes(),ebtk=require_evp_bytestokey(),inherits=require_inherits_browser();function Cipher(mode,key,iv){Transform.call(this),this._cache=new Splitter,this._cipher=new aes.AES(key),this._prev=Buffer2.from(iv),this._mode=mode,this._autopadding=!0}inherits(Cipher,Transform),Cipher.prototype._update=function(data){this._cache.add(data);for(var chunk,thing,out=[];chunk=this._cache.get();)thing=this._mode.encrypt(this,chunk),out.push(thing);return Buffer2.concat(out)};var PADDING=Buffer2.alloc(16,16);Cipher.prototype._final=function(){var chunk=this._cache.flush();if(this._autopadding)return chunk=this._mode.encrypt(this,chunk),this._cipher.scrub(),chunk;if(!chunk.equals(PADDING))throw this._cipher.scrub(),new Error(\"data not multiple of block length\")},Cipher.prototype.setAutoPadding=function(setTo){return this._autopadding=!!setTo,this};function Splitter(){this.cache=Buffer2.allocUnsafe(0)}Splitter.prototype={},Splitter.prototype.add=function(data){this.cache=Buffer2.concat([this.cache,data])},Splitter.prototype.get=function(){if(this.cache.length>15){var out=this.cache.slice(0,16);return this.cache=this.cache.slice(16),out}return null},Splitter.prototype.flush=function(){for(var len=16-this.cache.length,padBuff=Buffer2.allocUnsafe(len),i=-1;++i16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out}else if(this.cache.length>=16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out;return null},Splitter.prototype.flush=function(){if(this.cache.length)return this.cache};function unpad(last){var padded=last[15];if(padded<1||padded>16)throw new Error(\"unable to decrypt data\");for(var i=-1;++i0\?left:right},BN.min=function(left,right){return left.cmp(right)<0\?left:right},BN.prototype._init=function(number,base,endian){if(typeof number==\"number\")return this._initNumber(number,base,endian);if(typeof number==\"object\")return this._initArray(number,base,endian);base===\"hex\"&&(base=16),assert(base===(base|0)&&base>=2&&base<=36),number=number.toString().replace(/\\s+/g,\"\");var start=0;number[0]===\"-\"&&(start++,this.negative=1),start=0;i-=3)w=number[i]|number[i-1]<<8|number[i-2]<<16,this.words[j]|=w<>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);else if(endian===\"le\")for(i=0,j=0;i>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);return this.strip()};function parseHex4Bits(string,index){var c=string.charCodeAt(index);return c>=65&&c<=70\?c-55:c>=97&&c<=102\?c-87:c-48&15}function parseHexByte(string,lowerBound,index){var r=parseHex4Bits(string,index);return index-1>=lowerBound&&(r|=parseHex4Bits(string,index-1)<<4),r}BN.prototype._parseHex=function(number,start,endian){this.length=Math.ceil((number.length-start)/6),this.words=new Array(this.length);for(var i=0;i=start;i-=2)w=parseHexByte(number,start,i)<=18\?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8;else{var parseLength=number.length-start;for(i=parseLength%2===0\?start+1:start;i=18\?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8}this.strip()};function parseBase(str,start,end,mul){for(var r=0,len=Math.min(str.length,end),i=start;i=49\?r+=c-49+10:c>=17\?r+=c-17+10:r+=c}return r}BN.prototype._parseBase=function(number,base,start){this.words=[0],this.length=1;for(var limbLen=0,limbPow=1;limbPow<=67108863;limbPow*=base)limbLen++;limbLen--,limbPow=limbPow/base|0;for(var total=number.length-start,mod=total%limbLen,end=Math.min(total,total-mod)+start,word=0,i=start;i1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},BN.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},BN.prototype.inspect=function(){return(this.red\?\"\"};var zeros=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function(base,padding){base=base||10,padding=padding|0||1;var out;if(base===16||base===\"hex\"){out=\"\";for(var off=0,carry=0,i=0;i>>24-off&16777215,carry!==0||i!==this.length-1\?out=zeros[6-word.length]+word+out:out=word+out,off+=2,off>=26&&(off-=26,i--)}for(carry!==0&&(out=carry.toString(16)+out);out.length%padding!==0;)out=\"0\"+out;return this.negative!==0&&(out=\"-\"+out),out}if(base===(base|0)&&base>=2&&base<=36){var groupSize=groupSizes[base],groupBase=groupBases[base];out=\"\";var c=this.clone();for(c.negative=0;!c.isZero();){var r=c.modn(groupBase).toString(base);c=c.idivn(groupBase),c.isZero()\?out=r+out:out=zeros[groupSize-r.length]+r+out}for(this.isZero()&&(out=\"0\"+out);out.length%padding!==0;)out=\"0\"+out;return this.negative!==0&&(out=\"-\"+out),out}assert(!1,\"Base should be between 2 and 36\")},BN.prototype.toNumber=function(){var ret=this.words[0];return this.length===2\?ret+=this.words[1]*67108864:this.length===3&&this.words[2]===1\?ret+=4503599627370496+this.words[1]*67108864:this.length>2&&assert(!1,\"Number can only safely store up to 53 bits\"),this.negative!==0\?-ret:ret},BN.prototype.toJSON=function(){return this.toString(16)},BN.prototype.toBuffer=function(endian,length){return assert(typeof Buffer2<\"u\"),this.toArrayLike(Buffer2,endian,length)},BN.prototype.toArray=function(endian,length){return this.toArrayLike(Array,endian,length)},BN.prototype.toArrayLike=function(ArrayType,endian,length){var byteLength=this.byteLength(),reqLength=length||Math.max(1,byteLength);assert(byteLength<=reqLength,\"byte array longer than desired length\"),assert(reqLength>0,\"Requested array length <= 0\"),this.strip();var littleEndian=endian===\"le\",res=new ArrayType(reqLength),b,i,q=this.clone();if(littleEndian){for(i=0;!q.isZero();i++)b=q.andln(255),q.iushrn(8),res[i]=b;for(;i=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},BN.prototype._zeroBits=function(w){if(w===0)return 26;var t=w,r=0;return(t&8191)===0&&(r+=13,t>>>=13),(t&127)===0&&(r+=7,t>>>=7),(t&15)===0&&(r+=4,t>>>=4),(t&3)===0&&(r+=2,t>>>=2),(t&1)===0&&r++,r},BN.prototype.bitLength=function(){var w=this.words[this.length-1],hi=this._countBits(w);return(this.length-1)*26+hi};function toBitArray(num){for(var w=new Array(num.bitLength()),bit=0;bit>>wbit}return w}BN.prototype.zeroBits=function(){if(this.isZero())return 0;for(var r=0,i=0;inum.length\?this.clone().ior(num):num.clone().ior(this)},BN.prototype.uor=function(num){return this.length>num.length\?this.clone().iuor(num):num.clone().iuor(this)},BN.prototype.iuand=function(num){var b;this.length>num.length\?b=num:b=this;for(var i=0;inum.length\?this.clone().iand(num):num.clone().iand(this)},BN.prototype.uand=function(num){return this.length>num.length\?this.clone().iuand(num):num.clone().iuand(this)},BN.prototype.iuxor=function(num){var a,b;this.length>num.length\?(a=this,b=num):(a=num,b=this);for(var i=0;inum.length\?this.clone().ixor(num):num.clone().ixor(this)},BN.prototype.uxor=function(num){return this.length>num.length\?this.clone().iuxor(num):num.clone().iuxor(this)},BN.prototype.inotn=function(width){assert(typeof width==\"number\"&&width>=0);var bytesNeeded=Math.ceil(width/26)|0,bitsLeft=width%26;this._expand(bytesNeeded),bitsLeft>0&&bytesNeeded--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-bitsLeft),this.strip()},BN.prototype.notn=function(width){return this.clone().inotn(width)},BN.prototype.setn=function(bit,val){assert(typeof bit==\"number\"&&bit>=0);var off=bit/26|0,wbit=bit%26;return this._expand(off+1),val\?this.words[off]=this.words[off]|1<num.length\?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>>26;for(;carry!==0&&i>>26;if(this.length=a.length,carry!==0)this.words[this.length]=carry,this.length++;else if(a!==this)for(;inum.length\?this.clone().iadd(num):num.clone().iadd(this)},BN.prototype.isub=function(num){if(num.negative!==0){num.negative=0;var r=this.iadd(num);return num.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(num),this.negative=1,this._normSign();var cmp=this.cmp(num);if(cmp===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,b;cmp>0\?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>26,this.words[i]=r&67108863;for(;carry!==0&&i>26,this.words[i]=r&67108863;if(carry===0&&i>>26,rword=carry&67108863,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-self2.length+1);j<=maxJ;j++){var i=k-j|0;a=self2.words[i]|0,b=num.words[j]|0,r=a*b+rword,ncarry+=r/67108864|0,rword=r&67108863}out.words[k]=rword|0,carry=ncarry|0}return carry!==0\?out.words[k]=carry|0:out.length--,out.strip()}var comb10MulTo=function(self2,num,out){var a=self2.words,b=num.words,o=out.words,c=0,lo,mid,hi,a0=a[0]|0,al0=a0&8191,ah0=a0>>>13,a1=a[1]|0,al1=a1&8191,ah1=a1>>>13,a2=a[2]|0,al2=a2&8191,ah2=a2>>>13,a3=a[3]|0,al3=a3&8191,ah3=a3>>>13,a4=a[4]|0,al4=a4&8191,ah4=a4>>>13,a5=a[5]|0,al5=a5&8191,ah5=a5>>>13,a6=a[6]|0,al6=a6&8191,ah6=a6>>>13,a7=a[7]|0,al7=a7&8191,ah7=a7>>>13,a8=a[8]|0,al8=a8&8191,ah8=a8>>>13,a9=a[9]|0,al9=a9&8191,ah9=a9>>>13,b0=b[0]|0,bl0=b0&8191,bh0=b0>>>13,b1=b[1]|0,bl1=b1&8191,bh1=b1>>>13,b2=b[2]|0,bl2=b2&8191,bh2=b2>>>13,b3=b[3]|0,bl3=b3&8191,bh3=b3>>>13,b4=b[4]|0,bl4=b4&8191,bh4=b4>>>13,b5=b[5]|0,bl5=b5&8191,bh5=b5>>>13,b6=b[6]|0,bl6=b6&8191,bh6=b6>>>13,b7=b[7]|0,bl7=b7&8191,bh7=b7>>>13,b8=b[8]|0,bl8=b8&8191,bh8=b8>>>13,b9=b[9]|0,bl9=b9&8191,bh9=b9>>>13;out.negative=self2.negative^num.negative,out.length=19,lo=Math.imul(al0,bl0),mid=Math.imul(al0,bh0),mid=mid+Math.imul(ah0,bl0)|0,hi=Math.imul(ah0,bh0);var w0=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w0>>>26)|0,w0&=67108863,lo=Math.imul(al1,bl0),mid=Math.imul(al1,bh0),mid=mid+Math.imul(ah1,bl0)|0,hi=Math.imul(ah1,bh0),lo=lo+Math.imul(al0,bl1)|0,mid=mid+Math.imul(al0,bh1)|0,mid=mid+Math.imul(ah0,bl1)|0,hi=hi+Math.imul(ah0,bh1)|0;var w1=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w1>>>26)|0,w1&=67108863,lo=Math.imul(al2,bl0),mid=Math.imul(al2,bh0),mid=mid+Math.imul(ah2,bl0)|0,hi=Math.imul(ah2,bh0),lo=lo+Math.imul(al1,bl1)|0,mid=mid+Math.imul(al1,bh1)|0,mid=mid+Math.imul(ah1,bl1)|0,hi=hi+Math.imul(ah1,bh1)|0,lo=lo+Math.imul(al0,bl2)|0,mid=mid+Math.imul(al0,bh2)|0,mid=mid+Math.imul(ah0,bl2)|0,hi=hi+Math.imul(ah0,bh2)|0;var w2=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w2>>>26)|0,w2&=67108863,lo=Math.imul(al3,bl0),mid=Math.imul(al3,bh0),mid=mid+Math.imul(ah3,bl0)|0,hi=Math.imul(ah3,bh0),lo=lo+Math.imul(al2,bl1)|0,mid=mid+Math.imul(al2,bh1)|0,mid=mid+Math.imul(ah2,bl1)|0,hi=hi+Math.imul(ah2,bh1)|0,lo=lo+Math.imul(al1,bl2)|0,mid=mid+Math.imul(al1,bh2)|0,mid=mid+Math.imul(ah1,bl2)|0,hi=hi+Math.imul(ah1,bh2)|0,lo=lo+Math.imul(al0,bl3)|0,mid=mid+Math.imul(al0,bh3)|0,mid=mid+Math.imul(ah0,bl3)|0,hi=hi+Math.imul(ah0,bh3)|0;var w3=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w3>>>26)|0,w3&=67108863,lo=Math.imul(al4,bl0),mid=Math.imul(al4,bh0),mid=mid+Math.imul(ah4,bl0)|0,hi=Math.imul(ah4,bh0),lo=lo+Math.imul(al3,bl1)|0,mid=mid+Math.imul(al3,bh1)|0,mid=mid+Math.imul(ah3,bl1)|0,hi=hi+Math.imul(ah3,bh1)|0,lo=lo+Math.imul(al2,bl2)|0,mid=mid+Math.imul(al2,bh2)|0,mid=mid+Math.imul(ah2,bl2)|0,hi=hi+Math.imul(ah2,bh2)|0,lo=lo+Math.imul(al1,bl3)|0,mid=mid+Math.imul(al1,bh3)|0,mid=mid+Math.imul(ah1,bl3)|0,hi=hi+Math.imul(ah1,bh3)|0,lo=lo+Math.imul(al0,bl4)|0,mid=mid+Math.imul(al0,bh4)|0,mid=mid+Math.imul(ah0,bl4)|0,hi=hi+Math.imul(ah0,bh4)|0;var w4=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w4>>>26)|0,w4&=67108863,lo=Math.imul(al5,bl0),mid=Math.imul(al5,bh0),mid=mid+Math.imul(ah5,bl0)|0,hi=Math.imul(ah5,bh0),lo=lo+Math.imul(al4,bl1)|0,mid=mid+Math.imul(al4,bh1)|0,mid=mid+Math.imul(ah4,bl1)|0,hi=hi+Math.imul(ah4,bh1)|0,lo=lo+Math.imul(al3,bl2)|0,mid=mid+Math.imul(al3,bh2)|0,mid=mid+Math.imul(ah3,bl2)|0,hi=hi+Math.imul(ah3,bh2)|0,lo=lo+Math.imul(al2,bl3)|0,mid=mid+Math.imul(al2,bh3)|0,mid=mid+Math.imul(ah2,bl3)|0,hi=hi+Math.imul(ah2,bh3)|0,lo=lo+Math.imul(al1,bl4)|0,mid=mid+Math.imul(al1,bh4)|0,mid=mid+Math.imul(ah1,bl4)|0,hi=hi+Math.imul(ah1,bh4)|0,lo=lo+Math.imul(al0,bl5)|0,mid=mid+Math.imul(al0,bh5)|0,mid=mid+Math.imul(ah0,bl5)|0,hi=hi+Math.imul(ah0,bh5)|0;var w5=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w5>>>26)|0,w5&=67108863,lo=Math.imul(al6,bl0),mid=Math.imul(al6,bh0),mid=mid+Math.imul(ah6,bl0)|0,hi=Math.imul(ah6,bh0),lo=lo+Math.imul(al5,bl1)|0,mid=mid+Math.imul(al5,bh1)|0,mid=mid+Math.imul(ah5,bl1)|0,hi=hi+Math.imul(ah5,bh1)|0,lo=lo+Math.imul(al4,bl2)|0,mid=mid+Math.imul(al4,bh2)|0,mid=mid+Math.imul(ah4,bl2)|0,hi=hi+Math.imul(ah4,bh2)|0,lo=lo+Math.imul(al3,bl3)|0,mid=mid+Math.imul(al3,bh3)|0,mid=mid+Math.imul(ah3,bl3)|0,hi=hi+Math.imul(ah3,bh3)|0,lo=lo+Math.imul(al2,bl4)|0,mid=mid+Math.imul(al2,bh4)|0,mid=mid+Math.imul(ah2,bl4)|0,hi=hi+Math.imul(ah2,bh4)|0,lo=lo+Math.imul(al1,bl5)|0,mid=mid+Math.imul(al1,bh5)|0,mid=mid+Math.imul(ah1,bl5)|0,hi=hi+Math.imul(ah1,bh5)|0,lo=lo+Math.imul(al0,bl6)|0,mid=mid+Math.imul(al0,bh6)|0,mid=mid+Math.imul(ah0,bl6)|0,hi=hi+Math.imul(ah0,bh6)|0;var w6=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w6>>>26)|0,w6&=67108863,lo=Math.imul(al7,bl0),mid=Math.imul(al7,bh0),mid=mid+Math.imul(ah7,bl0)|0,hi=Math.imul(ah7,bh0),lo=lo+Math.imul(al6,bl1)|0,mid=mid+Math.imul(al6,bh1)|0,mid=mid+Math.imul(ah6,bl1)|0,hi=hi+Math.imul(ah6,bh1)|0,lo=lo+Math.imul(al5,bl2)|0,mid=mid+Math.imul(al5,bh2)|0,mid=mid+Math.imul(ah5,bl2)|0,hi=hi+Math.imul(ah5,bh2)|0,lo=lo+Math.imul(al4,bl3)|0,mid=mid+Math.imul(al4,bh3)|0,mid=mid+Math.imul(ah4,bl3)|0,hi=hi+Math.imul(ah4,bh3)|0,lo=lo+Math.imul(al3,bl4)|0,mid=mid+Math.imul(al3,bh4)|0,mid=mid+Math.imul(ah3,bl4)|0,hi=hi+Math.imul(ah3,bh4)|0,lo=lo+Math.imul(al2,bl5)|0,mid=mid+Math.imul(al2,bh5)|0,mid=mid+Math.imul(ah2,bl5)|0,hi=hi+Math.imul(ah2,bh5)|0,lo=lo+Math.imul(al1,bl6)|0,mid=mid+Math.imul(al1,bh6)|0,mid=mid+Math.imul(ah1,bl6)|0,hi=hi+Math.imul(ah1,bh6)|0,lo=lo+Math.imul(al0,bl7)|0,mid=mid+Math.imul(al0,bh7)|0,mid=mid+Math.imul(ah0,bl7)|0,hi=hi+Math.imul(ah0,bh7)|0;var w7=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w7>>>26)|0,w7&=67108863,lo=Math.imul(al8,bl0),mid=Math.imul(al8,bh0),mid=mid+Math.imul(ah8,bl0)|0,hi=Math.imul(ah8,bh0),lo=lo+Math.imul(al7,bl1)|0,mid=mid+Math.imul(al7,bh1)|0,mid=mid+Math.imul(ah7,bl1)|0,hi=hi+Math.imul(ah7,bh1)|0,lo=lo+Math.imul(al6,bl2)|0,mid=mid+Math.imul(al6,bh2)|0,mid=mid+Math.imul(ah6,bl2)|0,hi=hi+Math.imul(ah6,bh2)|0,lo=lo+Math.imul(al5,bl3)|0,mid=mid+Math.imul(al5,bh3)|0,mid=mid+Math.imul(ah5,bl3)|0,hi=hi+Math.imul(ah5,bh3)|0,lo=lo+Math.imul(al4,bl4)|0,mid=mid+Math.imul(al4,bh4)|0,mid=mid+Math.imul(ah4,bl4)|0,hi=hi+Math.imul(ah4,bh4)|0,lo=lo+Math.imul(al3,bl5)|0,mid=mid+Math.imul(al3,bh5)|0,mid=mid+Math.imul(ah3,bl5)|0,hi=hi+Math.imul(ah3,bh5)|0,lo=lo+Math.imul(al2,bl6)|0,mid=mid+Math.imul(al2,bh6)|0,mid=mid+Math.imul(ah2,bl6)|0,hi=hi+Math.imul(ah2,bh6)|0,lo=lo+Math.imul(al1,bl7)|0,mid=mid+Math.imul(al1,bh7)|0,mid=mid+Math.imul(ah1,bl7)|0,hi=hi+Math.imul(ah1,bh7)|0,lo=lo+Math.imul(al0,bl8)|0,mid=mid+Math.imul(al0,bh8)|0,mid=mid+Math.imul(ah0,bl8)|0,hi=hi+Math.imul(ah0,bh8)|0;var w8=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w8>>>26)|0,w8&=67108863,lo=Math.imul(al9,bl0),mid=Math.imul(al9,bh0),mid=mid+Math.imul(ah9,bl0)|0,hi=Math.imul(ah9,bh0),lo=lo+Math.imul(al8,bl1)|0,mid=mid+Math.imul(al8,bh1)|0,mid=mid+Math.imul(ah8,bl1)|0,hi=hi+Math.imul(ah8,bh1)|0,lo=lo+Math.imul(al7,bl2)|0,mid=mid+Math.imul(al7,bh2)|0,mid=mid+Math.imul(ah7,bl2)|0,hi=hi+Math.imul(ah7,bh2)|0,lo=lo+Math.imul(al6,bl3)|0,mid=mid+Math.imul(al6,bh3)|0,mid=mid+Math.imul(ah6,bl3)|0,hi=hi+Math.imul(ah6,bh3)|0,lo=lo+Math.imul(al5,bl4)|0,mid=mid+Math.imul(al5,bh4)|0,mid=mid+Math.imul(ah5,bl4)|0,hi=hi+Math.imul(ah5,bh4)|0,lo=lo+Math.imul(al4,bl5)|0,mid=mid+Math.imul(al4,bh5)|0,mid=mid+Math.imul(ah4,bl5)|0,hi=hi+Math.imul(ah4,bh5)|0,lo=lo+Math.imul(al3,bl6)|0,mid=mid+Math.imul(al3,bh6)|0,mid=mid+Math.imul(ah3,bl6)|0,hi=hi+Math.imul(ah3,bh6)|0,lo=lo+Math.imul(al2,bl7)|0,mid=mid+Math.imul(al2,bh7)|0,mid=mid+Math.imul(ah2,bl7)|0,hi=hi+Math.imul(ah2,bh7)|0,lo=lo+Math.imul(al1,bl8)|0,mid=mid+Math.imul(al1,bh8)|0,mid=mid+Math.imul(ah1,bl8)|0,hi=hi+Math.imul(ah1,bh8)|0,lo=lo+Math.imul(al0,bl9)|0,mid=mid+Math.imul(al0,bh9)|0,mid=mid+Math.imul(ah0,bl9)|0,hi=hi+Math.imul(ah0,bh9)|0;var w9=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w9>>>26)|0,w9&=67108863,lo=Math.imul(al9,bl1),mid=Math.imul(al9,bh1),mid=mid+Math.imul(ah9,bl1)|0,hi=Math.imul(ah9,bh1),lo=lo+Math.imul(al8,bl2)|0,mid=mid+Math.imul(al8,bh2)|0,mid=mid+Math.imul(ah8,bl2)|0,hi=hi+Math.imul(ah8,bh2)|0,lo=lo+Math.imul(al7,bl3)|0,mid=mid+Math.imul(al7,bh3)|0,mid=mid+Math.imul(ah7,bl3)|0,hi=hi+Math.imul(ah7,bh3)|0,lo=lo+Math.imul(al6,bl4)|0,mid=mid+Math.imul(al6,bh4)|0,mid=mid+Math.imul(ah6,bl4)|0,hi=hi+Math.imul(ah6,bh4)|0,lo=lo+Math.imul(al5,bl5)|0,mid=mid+Math.imul(al5,bh5)|0,mid=mid+Math.imul(ah5,bl5)|0,hi=hi+Math.imul(ah5,bh5)|0,lo=lo+Math.imul(al4,bl6)|0,mid=mid+Math.imul(al4,bh6)|0,mid=mid+Math.imul(ah4,bl6)|0,hi=hi+Math.imul(ah4,bh6)|0,lo=lo+Math.imul(al3,bl7)|0,mid=mid+Math.imul(al3,bh7)|0,mid=mid+Math.imul(ah3,bl7)|0,hi=hi+Math.imul(ah3,bh7)|0,lo=lo+Math.imul(al2,bl8)|0,mid=mid+Math.imul(al2,bh8)|0,mid=mid+Math.imul(ah2,bl8)|0,hi=hi+Math.imul(ah2,bh8)|0,lo=lo+Math.imul(al1,bl9)|0,mid=mid+Math.imul(al1,bh9)|0,mid=mid+Math.imul(ah1,bl9)|0,hi=hi+Math.imul(ah1,bh9)|0;var w10=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w10>>>26)|0,w10&=67108863,lo=Math.imul(al9,bl2),mid=Math.imul(al9,bh2),mid=mid+Math.imul(ah9,bl2)|0,hi=Math.imul(ah9,bh2),lo=lo+Math.imul(al8,bl3)|0,mid=mid+Math.imul(al8,bh3)|0,mid=mid+Math.imul(ah8,bl3)|0,hi=hi+Math.imul(ah8,bh3)|0,lo=lo+Math.imul(al7,bl4)|0,mid=mid+Math.imul(al7,bh4)|0,mid=mid+Math.imul(ah7,bl4)|0,hi=hi+Math.imul(ah7,bh4)|0,lo=lo+Math.imul(al6,bl5)|0,mid=mid+Math.imul(al6,bh5)|0,mid=mid+Math.imul(ah6,bl5)|0,hi=hi+Math.imul(ah6,bh5)|0,lo=lo+Math.imul(al5,bl6)|0,mid=mid+Math.imul(al5,bh6)|0,mid=mid+Math.imul(ah5,bl6)|0,hi=hi+Math.imul(ah5,bh6)|0,lo=lo+Math.imul(al4,bl7)|0,mid=mid+Math.imul(al4,bh7)|0,mid=mid+Math.imul(ah4,bl7)|0,hi=hi+Math.imul(ah4,bh7)|0,lo=lo+Math.imul(al3,bl8)|0,mid=mid+Math.imul(al3,bh8)|0,mid=mid+Math.imul(ah3,bl8)|0,hi=hi+Math.imul(ah3,bh8)|0,lo=lo+Math.imul(al2,bl9)|0,mid=mid+Math.imul(al2,bh9)|0,mid=mid+Math.imul(ah2,bl9)|0,hi=hi+Math.imul(ah2,bh9)|0;var w11=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w11>>>26)|0,w11&=67108863,lo=Math.imul(al9,bl3),mid=Math.imul(al9,bh3),mid=mid+Math.imul(ah9,bl3)|0,hi=Math.imul(ah9,bh3),lo=lo+Math.imul(al8,bl4)|0,mid=mid+Math.imul(al8,bh4)|0,mid=mid+Math.imul(ah8,bl4)|0,hi=hi+Math.imul(ah8,bh4)|0,lo=lo+Math.imul(al7,bl5)|0,mid=mid+Math.imul(al7,bh5)|0,mid=mid+Math.imul(ah7,bl5)|0,hi=hi+Math.imul(ah7,bh5)|0,lo=lo+Math.imul(al6,bl6)|0,mid=mid+Math.imul(al6,bh6)|0,mid=mid+Math.imul(ah6,bl6)|0,hi=hi+Math.imul(ah6,bh6)|0,lo=lo+Math.imul(al5,bl7)|0,mid=mid+Math.imul(al5,bh7)|0,mid=mid+Math.imul(ah5,bl7)|0,hi=hi+Math.imul(ah5,bh7)|0,lo=lo+Math.imul(al4,bl8)|0,mid=mid+Math.imul(al4,bh8)|0,mid=mid+Math.imul(ah4,bl8)|0,hi=hi+Math.imul(ah4,bh8)|0,lo=lo+Math.imul(al3,bl9)|0,mid=mid+Math.imul(al3,bh9)|0,mid=mid+Math.imul(ah3,bl9)|0,hi=hi+Math.imul(ah3,bh9)|0;var w12=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w12>>>26)|0,w12&=67108863,lo=Math.imul(al9,bl4),mid=Math.imul(al9,bh4),mid=mid+Math.imul(ah9,bl4)|0,hi=Math.imul(ah9,bh4),lo=lo+Math.imul(al8,bl5)|0,mid=mid+Math.imul(al8,bh5)|0,mid=mid+Math.imul(ah8,bl5)|0,hi=hi+Math.imul(ah8,bh5)|0,lo=lo+Math.imul(al7,bl6)|0,mid=mid+Math.imul(al7,bh6)|0,mid=mid+Math.imul(ah7,bl6)|0,hi=hi+Math.imul(ah7,bh6)|0,lo=lo+Math.imul(al6,bl7)|0,mid=mid+Math.imul(al6,bh7)|0,mid=mid+Math.imul(ah6,bl7)|0,hi=hi+Math.imul(ah6,bh7)|0,lo=lo+Math.imul(al5,bl8)|0,mid=mid+Math.imul(al5,bh8)|0,mid=mid+Math.imul(ah5,bl8)|0,hi=hi+Math.imul(ah5,bh8)|0,lo=lo+Math.imul(al4,bl9)|0,mid=mid+Math.imul(al4,bh9)|0,mid=mid+Math.imul(ah4,bl9)|0,hi=hi+Math.imul(ah4,bh9)|0;var w13=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w13>>>26)|0,w13&=67108863,lo=Math.imul(al9,bl5),mid=Math.imul(al9,bh5),mid=mid+Math.imul(ah9,bl5)|0,hi=Math.imul(ah9,bh5),lo=lo+Math.imul(al8,bl6)|0,mid=mid+Math.imul(al8,bh6)|0,mid=mid+Math.imul(ah8,bl6)|0,hi=hi+Math.imul(ah8,bh6)|0,lo=lo+Math.imul(al7,bl7)|0,mid=mid+Math.imul(al7,bh7)|0,mid=mid+Math.imul(ah7,bl7)|0,hi=hi+Math.imul(ah7,bh7)|0,lo=lo+Math.imul(al6,bl8)|0,mid=mid+Math.imul(al6,bh8)|0,mid=mid+Math.imul(ah6,bl8)|0,hi=hi+Math.imul(ah6,bh8)|0,lo=lo+Math.imul(al5,bl9)|0,mid=mid+Math.imul(al5,bh9)|0,mid=mid+Math.imul(ah5,bl9)|0,hi=hi+Math.imul(ah5,bh9)|0;var w14=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w14>>>26)|0,w14&=67108863,lo=Math.imul(al9,bl6),mid=Math.imul(al9,bh6),mid=mid+Math.imul(ah9,bl6)|0,hi=Math.imul(ah9,bh6),lo=lo+Math.imul(al8,bl7)|0,mid=mid+Math.imul(al8,bh7)|0,mid=mid+Math.imul(ah8,bl7)|0,hi=hi+Math.imul(ah8,bh7)|0,lo=lo+Math.imul(al7,bl8)|0,mid=mid+Math.imul(al7,bh8)|0,mid=mid+Math.imul(ah7,bl8)|0,hi=hi+Math.imul(ah7,bh8)|0,lo=lo+Math.imul(al6,bl9)|0,mid=mid+Math.imul(al6,bh9)|0,mid=mid+Math.imul(ah6,bl9)|0,hi=hi+Math.imul(ah6,bh9)|0;var w15=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w15>>>26)|0,w15&=67108863,lo=Math.imul(al9,bl7),mid=Math.imul(al9,bh7),mid=mid+Math.imul(ah9,bl7)|0,hi=Math.imul(ah9,bh7),lo=lo+Math.imul(al8,bl8)|0,mid=mid+Math.imul(al8,bh8)|0,mid=mid+Math.imul(ah8,bl8)|0,hi=hi+Math.imul(ah8,bh8)|0,lo=lo+Math.imul(al7,bl9)|0,mid=mid+Math.imul(al7,bh9)|0,mid=mid+Math.imul(ah7,bl9)|0,hi=hi+Math.imul(ah7,bh9)|0;var w16=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w16>>>26)|0,w16&=67108863,lo=Math.imul(al9,bl8),mid=Math.imul(al9,bh8),mid=mid+Math.imul(ah9,bl8)|0,hi=Math.imul(ah9,bh8),lo=lo+Math.imul(al8,bl9)|0,mid=mid+Math.imul(al8,bh9)|0,mid=mid+Math.imul(ah8,bl9)|0,hi=hi+Math.imul(ah8,bh9)|0;var w17=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w17>>>26)|0,w17&=67108863,lo=Math.imul(al9,bl9),mid=Math.imul(al9,bh9),mid=mid+Math.imul(ah9,bl9)|0,hi=Math.imul(ah9,bh9);var w18=(c+lo|0)+((mid&8191)<<13)|0;return c=(hi+(mid>>>13)|0)+(w18>>>26)|0,w18&=67108863,o[0]=w0,o[1]=w1,o[2]=w2,o[3]=w3,o[4]=w4,o[5]=w5,o[6]=w6,o[7]=w7,o[8]=w8,o[9]=w9,o[10]=w10,o[11]=w11,o[12]=w12,o[13]=w13,o[14]=w14,o[15]=w15,o[16]=w16,o[17]=w17,o[18]=w18,c!==0&&(o[19]=c,out.length++),out};Math.imul||(comb10MulTo=smallMulTo);function bigMulTo(self2,num,out){out.negative=num.negative^self2.negative,out.length=self2.length+num.length;for(var carry=0,hncarry=0,k=0;k>>26)|0,hncarry+=ncarry>>>26,ncarry&=67108863}out.words[k]=rword,carry=ncarry,ncarry=hncarry}return carry!==0\?out.words[k]=carry:out.length--,out.strip()}function jumboMulTo(self2,num,out){var fftm=new FFTM;return fftm.mulp(self2,num,out)}BN.prototype.mulTo=function(num,out){var res,len=this.length+num.length;return this.length===10&&num.length===10\?res=comb10MulTo(this,num,out):len<63\?res=smallMulTo(this,num,out):len<1024\?res=bigMulTo(this,num,out):res=jumboMulTo(this,num,out),res};function FFTM(x,y){this.x=x,this.y=y}FFTM.prototype={},FFTM.prototype.makeRBT=function(N){for(var t=new Array(N),l=BN.prototype._countBits(N)-1,i=0;i>=1;return rb},FFTM.prototype.permute=function(rbt,rws,iws,rtws,itws,N){for(var i=0;i>>1)i++;return 1<>>13,rws[2*i+1]=carry&8191,carry=carry>>>13;for(i=2*len;i>=26,carry+=w/67108864|0,carry+=lo>>>26,this.words[i]=lo&67108863}return carry!==0&&(this.words[i]=carry,this.length++),this},BN.prototype.muln=function(num){return this.clone().imuln(num)},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.imul(this.clone())},BN.prototype.pow=function(num){var w=toBitArray(num);if(w.length===0)return new BN(1);for(var res=this,i=0;i=0);var r=bits%26,s=(bits-r)/26,carryMask=67108863>>>26-r<<26-r,i;if(r!==0){var carry=0;for(i=0;i>>26-r}carry&&(this.words[i]=carry,this.length++)}if(s!==0){for(i=this.length-1;i>=0;i--)this.words[i+s]=this.words[i];for(i=0;i=0);var h;hint\?h=(hint-hint%26)/26:h=0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<s)for(this.length-=s,i=0;i=0&&(carry!==0||i>=h);i--){var word=this.words[i]|0;this.words[i]=carry<<26-r|word>>>r,carry=word&mask}return maskedWords&&carry!==0&&(maskedWords.words[maskedWords.length++]=carry),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function(bits,hint,extended){return assert(this.negative===0),this.iushrn(bits,hint,extended)},BN.prototype.shln=function(bits){return this.clone().ishln(bits)},BN.prototype.ushln=function(bits){return this.clone().iushln(bits)},BN.prototype.shrn=function(bits){return this.clone().ishrn(bits)},BN.prototype.ushrn=function(bits){return this.clone().iushrn(bits)},BN.prototype.testn=function(bit){assert(typeof bit==\"number\"&&bit>=0);var r=bit%26,s=(bit-r)/26,q=1<=0);var r=bits%26,s=(bits-r)/26;if(assert(this.negative===0,\"imaskn works only with positive numbers\"),this.length<=s)return this;if(r!==0&&s++,this.length=Math.min(s,this.length),r!==0){var mask=67108863^67108863>>>r<=67108864;i++)this.words[i]-=67108864,i===this.length-1\?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},BN.prototype.isubn=function(num){if(assert(typeof num==\"number\"),assert(num<67108864),num<0)return this.iaddn(-num);if(this.negative!==0)return this.negative=0,this.iaddn(num),this.negative=1,this;if(this.words[0]-=num,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(right/67108864|0),this.words[i+shift]=w&67108863}for(;i>26,this.words[i+shift]=w&67108863;if(carry===0)return this.strip();for(assert(carry===-1),carry=0,i=0;i>26,this.words[i]=w&67108863;return this.negative=1,this.strip()},BN.prototype._wordDiv=function(num,mode){var shift=this.length-num.length,a=this.clone(),b=num,bhi=b.words[b.length-1]|0,bhiBits=this._countBits(bhi);shift=26-bhiBits,shift!==0&&(b=b.ushln(shift),a.iushln(shift),bhi=b.words[b.length-1]|0);var m=a.length-b.length,q;if(mode!==\"mod\"){q=new BN(null),q.length=m+1,q.words=new Array(q.length);for(var i=0;i=0;j--){var qj=(a.words[b.length+j]|0)*67108864+(a.words[b.length+j-1]|0);for(qj=Math.min(qj/bhi|0,67108863),a._ishlnsubmul(b,qj,j);a.negative!==0;)qj--,a.negative=0,a._ishlnsubmul(b,1,j),a.isZero()||(a.negative^=1);q&&(q.words[j]=qj)}return q&&q.strip(),a.strip(),mode!==\"div\"&&shift!==0&&a.iushrn(shift),{div:q||null,mod:a}},BN.prototype.divmod=function(num,mode,positive){if(assert(!num.isZero()),this.isZero())return{div:new BN(0),mod:new BN(0)};var div,mod,res;return this.negative!==0&&num.negative===0\?(res=this.neg().divmod(num,mode),mode!==\"mod\"&&(div=res.div.neg()),mode!==\"div\"&&(mod=res.mod.neg(),positive&&mod.negative!==0&&mod.iadd(num)),{div,mod}):this.negative===0&&num.negative!==0\?(res=this.divmod(num.neg(),mode),mode!==\"mod\"&&(div=res.div.neg()),{div,mod:res.mod}):(this.negative&num.negative)!==0\?(res=this.neg().divmod(num.neg(),mode),mode!==\"div\"&&(mod=res.mod.neg(),positive&&mod.negative!==0&&mod.isub(num)),{div:res.div,mod}):num.length>this.length||this.cmp(num)<0\?{div:new BN(0),mod:this}:num.length===1\?mode===\"div\"\?{div:this.divn(num.words[0]),mod:null}:mode===\"mod\"\?{div:null,mod:new BN(this.modn(num.words[0]))}:{div:this.divn(num.words[0]),mod:new BN(this.modn(num.words[0]))}:this._wordDiv(num,mode)},BN.prototype.div=function(num){return this.divmod(num,\"div\",!1).div},BN.prototype.mod=function(num){return this.divmod(num,\"mod\",!1).mod},BN.prototype.umod=function(num){return this.divmod(num,\"mod\",!0).mod},BN.prototype.divRound=function(num){var dm=this.divmod(num);if(dm.mod.isZero())return dm.div;var mod=dm.div.negative!==0\?dm.mod.isub(num):dm.mod,half=num.ushrn(1),r2=num.andln(1),cmp=mod.cmp(half);return cmp<0||r2===1&&cmp===0\?dm.div:dm.div.negative!==0\?dm.div.isubn(1):dm.div.iaddn(1)},BN.prototype.modn=function(num){assert(num<=67108863);for(var p=(1<<26)%num,acc=0,i=this.length-1;i>=0;i--)acc=(p*acc+(this.words[i]|0))%num;return acc},BN.prototype.idivn=function(num){assert(num<=67108863);for(var carry=0,i=this.length-1;i>=0;i--){var w=(this.words[i]|0)+carry*67108864;this.words[i]=w/num|0,carry=w%num}return this.strip()},BN.prototype.divn=function(num){return this.clone().idivn(num)},BN.prototype.egcd=function(p){assert(p.negative===0),assert(!p.isZero());var x=this,y=p.clone();x.negative!==0\?x=x.umod(p):x=x.clone();for(var A=new BN(1),B=new BN(0),C=new BN(0),D=new BN(1),g=0;x.isEven()&&y.isEven();)x.iushrn(1),y.iushrn(1),++g;for(var yp=y.clone(),xp=x.clone();!x.isZero();){for(var i=0,im=1;(x.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0)for(x.iushrn(i);i-- >0;)(A.isOdd()||B.isOdd())&&(A.iadd(yp),B.isub(xp)),A.iushrn(1),B.iushrn(1);for(var j=0,jm=1;(y.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0)for(y.iushrn(j);j-- >0;)(C.isOdd()||D.isOdd())&&(C.iadd(yp),D.isub(xp)),C.iushrn(1),D.iushrn(1);x.cmp(y)>=0\?(x.isub(y),A.isub(C),B.isub(D)):(y.isub(x),C.isub(A),D.isub(B))}return{a:C,b:D,gcd:y.iushln(g)}},BN.prototype._invmp=function(p){assert(p.negative===0),assert(!p.isZero());var a=this,b=p.clone();a.negative!==0\?a=a.umod(p):a=a.clone();for(var x1=new BN(1),x2=new BN(0),delta=b.clone();a.cmpn(1)>0&&b.cmpn(1)>0;){for(var i=0,im=1;(a.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0)for(a.iushrn(i);i-- >0;)x1.isOdd()&&x1.iadd(delta),x1.iushrn(1);for(var j=0,jm=1;(b.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0)for(b.iushrn(j);j-- >0;)x2.isOdd()&&x2.iadd(delta),x2.iushrn(1);a.cmp(b)>=0\?(a.isub(b),x1.isub(x2)):(b.isub(a),x2.isub(x1))}var res;return a.cmpn(1)===0\?res=x1:res=x2,res.cmpn(0)<0&&res.iadd(p),res},BN.prototype.gcd=function(num){if(this.isZero())return num.abs();if(num.isZero())return this.abs();var a=this.clone(),b=num.clone();a.negative=0,b.negative=0;for(var shift=0;a.isEven()&&b.isEven();shift++)a.iushrn(1),b.iushrn(1);do{for(;a.isEven();)a.iushrn(1);for(;b.isEven();)b.iushrn(1);var r=a.cmp(b);if(r<0){var t=a;a=b,b=t}else if(r===0||b.cmpn(1)===0)break;a.isub(b)}while(!0);return b.iushln(shift)},BN.prototype.invm=function(num){return this.egcd(num).a.umod(num)},BN.prototype.isEven=function(){return(this.words[0]&1)===0},BN.prototype.isOdd=function(){return(this.words[0]&1)===1},BN.prototype.andln=function(num){return this.words[0]&num},BN.prototype.bincn=function(bit){assert(typeof bit==\"number\");var r=bit%26,s=(bit-r)/26,q=1<>>26,w&=67108863,this.words[i]=w}return carry!==0&&(this.words[i]=carry,this.length++),this},BN.prototype.isZero=function(){return this.length===1&&this.words[0]===0},BN.prototype.cmpn=function(num){var negative=num<0;if(this.negative!==0&&!negative)return-1;if(this.negative===0&&negative)return 1;this.strip();var res;if(this.length>1)res=1;else{negative&&(num=-num),assert(num<=67108863,\"Number is too big\");var w=this.words[0]|0;res=w===num\?0:wnum.length)return 1;if(this.length=0;i--){var a=this.words[i]|0,b=num.words[i]|0;if(a!==b){ab&&(res=1);break}}return res},BN.prototype.gtn=function(num){return this.cmpn(num)===1},BN.prototype.gt=function(num){return this.cmp(num)===1},BN.prototype.gten=function(num){return this.cmpn(num)>=0},BN.prototype.gte=function(num){return this.cmp(num)>=0},BN.prototype.ltn=function(num){return this.cmpn(num)===-1},BN.prototype.lt=function(num){return this.cmp(num)===-1},BN.prototype.lten=function(num){return this.cmpn(num)<=0},BN.prototype.lte=function(num){return this.cmp(num)<=0},BN.prototype.eqn=function(num){return this.cmpn(num)===0},BN.prototype.eq=function(num){return this.cmp(num)===0},BN.red=function(num){return new Red(num)},BN.prototype.toRed=function(ctx){return assert(!this.red,\"Already a number in reduction context\"),assert(this.negative===0,\"red works only with positives\"),ctx.convertTo(this)._forceRed(ctx)},BN.prototype.fromRed=function(){return assert(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},BN.prototype._forceRed=function(ctx){return this.red=ctx,this},BN.prototype.forceRed=function(ctx){return assert(!this.red,\"Already a number in reduction context\"),this._forceRed(ctx)},BN.prototype.redAdd=function(num){return assert(this.red,\"redAdd works only with red numbers\"),this.red.add(this,num)},BN.prototype.redIAdd=function(num){return assert(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,num)},BN.prototype.redSub=function(num){return assert(this.red,\"redSub works only with red numbers\"),this.red.sub(this,num)},BN.prototype.redISub=function(num){return assert(this.red,\"redISub works only with red numbers\"),this.red.isub(this,num)},BN.prototype.redShl=function(num){return assert(this.red,\"redShl works only with red numbers\"),this.red.shl(this,num)},BN.prototype.redMul=function(num){return assert(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,num),this.red.mul(this,num)},BN.prototype.redIMul=function(num){return assert(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,num),this.red.imul(this,num)},BN.prototype.redSqr=function(){return assert(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(num){return assert(this.red&&!num.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,num)};var primes={k256:null,p224:null,p192:null,p25519:null};function MPrime(name,p){this.name=name,this.p=new BN(p,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}MPrime.prototype={},MPrime.prototype._tmp=function(){var tmp=new BN(null);return tmp.words=new Array(Math.ceil(this.n/13)),tmp},MPrime.prototype.ireduce=function(num){var r=num,rlen;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),rlen=r.bitLength();while(rlen>this.n);var cmp=rlen0\?r.isub(this.p):r.strip!==void 0\?r.strip():r._strip(),r},MPrime.prototype.split=function(input,out){input.iushrn(this.n,0,out)},MPrime.prototype.imulK=function(num){return num.imul(this.k)};function K256(){MPrime.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var mask=4194303,outLen=Math.min(input.length,9),i=0;i>>22,prev=next}prev>>>=22,input.words[i-10]=prev,prev===0&&input.length>10\?input.length-=10:input.length-=9},K256.prototype.imulK=function(num){num.words[num.length]=0,num.words[num.length+1]=0,num.length+=2;for(var lo=0,i=0;i>>=26,num.words[i]=lo,carry=hi}return carry!==0&&(num.words[num.length++]=carry),num},BN._prime=function(name){if(primes[name])return primes[name];var prime2;if(name===\"k256\")prime2=new K256;else if(name===\"p224\")prime2=new P224;else if(name===\"p192\")prime2=new P192;else if(name===\"p25519\")prime2=new P25519;else throw new Error(\"Unknown prime \"+name);return primes[name]=prime2,prime2};function Red(m){if(typeof m==\"string\"){var prime=BN._prime(m);this.m=prime.p,this.prime=prime}else assert(m.gtn(1),\"modulus must be greater than 1\"),this.m=m,this.prime=null}Red.prototype={},Red.prototype._verify1=function(a){assert(a.negative===0,\"red works only with positives\"),assert(a.red,\"red works only with red numbers\")},Red.prototype._verify2=function(a,b){assert((a.negative|b.negative)===0,\"red works only with positives\"),assert(a.red&&a.red===b.red,\"red works only with red numbers\")},Red.prototype.imod=function(a){return this.prime\?this.prime.ireduce(a)._forceRed(this):a.umod(this.m)._forceRed(this)},Red.prototype.neg=function(a){return a.isZero()\?a.clone():this.m.sub(a)._forceRed(this)},Red.prototype.add=function(a,b){this._verify2(a,b);var res=a.add(b);return res.cmp(this.m)>=0&&res.isub(this.m),res._forceRed(this)},Red.prototype.iadd=function(a,b){this._verify2(a,b);var res=a.iadd(b);return res.cmp(this.m)>=0&&res.isub(this.m),res},Red.prototype.sub=function(a,b){this._verify2(a,b);var res=a.sub(b);return res.cmpn(0)<0&&res.iadd(this.m),res._forceRed(this)},Red.prototype.isub=function(a,b){this._verify2(a,b);var res=a.isub(b);return res.cmpn(0)<0&&res.iadd(this.m),res},Red.prototype.shl=function(a,num){return this._verify1(a),this.imod(a.ushln(num))},Red.prototype.imul=function(a,b){return this._verify2(a,b),this.imod(a.imul(b))},Red.prototype.mul=function(a,b){return this._verify2(a,b),this.imod(a.mul(b))},Red.prototype.isqr=function(a){return this.imul(a,a.clone())},Red.prototype.sqr=function(a){return this.mul(a,a)},Red.prototype.sqrt=function(a){if(a.isZero())return a.clone();var mod3=this.m.andln(3);if(assert(mod3%2===1),mod3===3){var pow=this.m.add(new BN(1)).iushrn(2);return this.pow(a,pow)}for(var q=this.m.subn(1),s=0;!q.isZero()&&q.andln(1)===0;)s++,q.iushrn(1);assert(!q.isZero());var one=new BN(1).toRed(this),nOne=one.redNeg(),lpow=this.m.subn(1).iushrn(1),z=this.m.bitLength();for(z=new BN(2*z*z).toRed(this);this.pow(z,lpow).cmp(nOne)!==0;)z.redIAdd(nOne);for(var c=this.pow(z,q),r=this.pow(a,q.addn(1).iushrn(1)),t=this.pow(a,q),m=s;t.cmp(one)!==0;){for(var tmp=t,i=0;tmp.cmp(one)!==0;i++)tmp=tmp.redSqr();assert(i=0;i--){for(var word=num.words[i],j=start-1;j>=0;j--){var bit=word>>j&1;if(res!==wnd[0]&&(res=this.sqr(res)),bit===0&¤t===0){currentLen=0;continue}current<<=1,current|=bit,currentLen++,!(currentLen!==windowSize&&(i!==0||j!==0))&&(res=this.mul(res,wnd[current]),currentLen=0,current=0)}start=26}return res},Red.prototype.convertTo=function(num){var r=num.umod(this.m);return r===num\?r.clone():r},Red.prototype.convertFrom=function(num){var res=num.clone();return res.red=null,res},BN.mont=function(num){return new Mont(num)};function Mont(m){Red.call(this,m),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new BN(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}inherits(Mont,Red),Mont.prototype.convertTo=function(num){return this.imod(num.ushln(this.shift))},Mont.prototype.convertFrom=function(num){var r=this.imod(num.mul(this.rinv));return r.red=null,r},Mont.prototype.imul=function(a,b){if(a.isZero()||b.isZero())return a.words[0]=0,a.length=1,a;var t=a.imul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0\?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.mul=function(a,b){if(a.isZero()||b.isZero())return new BN(0)._forceRed(this);var t=a.mul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0\?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.invm=function(a){var res=this.imod(a._invmp(this.m).mul(this.r2));return res._forceRed(this)}})(typeof module>\"u\"||module,exports)}}),require_bn2=require_bn,require_brorand=__commonJS({\"node_modules/brorand/index.js\"(exports,module){var r;module.exports=function(len){return r||(r=new Rand(null)),r.generate(len)};function Rand(rand){this.rand=rand}Rand.prototype={},module.exports.Rand=Rand,Rand.prototype.generate=function(len){return this._rand(len)},Rand.prototype._rand=function(n){var out=new Buffer(n);return crypto.getRandomValues(out),out}}}),require_mr=__commonJS({\"node_modules/miller-rabin/lib/mr.js\"(exports,module){var bn=require_bn2(),brorand=require_brorand();function MillerRabin(rand){this.rand=rand||new brorand.Rand}module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype={},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=Math.ceil(len/8);do var a=new bn(this.rand.generate(min_bytes));while(a.cmp(n)>=0);return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=Math.max(1,len/48|0));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;k>0;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(!(x.cmp(rone)===0||x.cmp(rn1)===0)){for(var i=1;i0;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(g.cmpn(1)!==0)return g;var x=a.toRed(red).redPow(d);if(!(x.cmp(rone)===0||x.cmp(rn1)===0)){for(var i=1;ibits;)num.ishrn(1);if(num.isEven()&&num.iadd(ONE),num.testn(1)||num.iadd(TWO),gen.cmp(TWO)){if(!gen.cmp(FIVE))for(;num.mod(TEN).cmp(THREE);)num.iadd(FOUR)}else for(;num.mod(TWENTYFOUR).cmp(ELEVEN);)num.iadd(FOUR);if(n2=num.shrn(1),simpleSieve(n2)&&simpleSieve(num)&&fermatTest(n2)&&fermatTest(num)&&millerRabin.test(n2)&&millerRabin.test(num))return num}}}}),require_primes=__commonJS({\"node_modules/diffie-hellman/lib/primes.json\"(exports,module){module.exports={modp1:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff\"},modp2:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff\"},modp5:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff\"},modp14:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff\"},modp15:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff\"},modp16:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff\"},modp17:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff\"},modp18:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff\"}}}}),require_dh=__commonJS({\"node_modules/diffie-hellman/lib/dh.js\"(exports,module){var BN=require_bn(),MillerRabin=require_mr(),millerRabin=new MillerRabin,TWENTYFOUR=new BN(24),ELEVEN=new BN(11),TEN=new BN(10),THREE=new BN(3),SEVEN=new BN(7),primes=require_generatePrime(),randomBytes=require_browser();module.exports=DH;function setPublicKey(pub,enc){return enc=enc||\"utf8\",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this._pub=new BN(pub),this}function setPrivateKey(priv,enc){return enc=enc||\"utf8\",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc)),this._priv=new BN(priv),this}var primeCache={};function checkPrime(prime,generator){var gen=generator.toString(\"hex\"),hex=[gen,prime.toString(16)].join(\"_\");if(hex in primeCache)return primeCache[hex];var error=0;if(prime.isEven()||!primes.simpleSieve||!primes.fermatTest(prime)||!millerRabin.test(prime))return error+=1,gen===\"02\"||gen===\"05\"\?error+=8:error+=4,primeCache[hex]=error,error;millerRabin.test(prime.shrn(1))||(error+=2);var rem;switch(gen){case\"02\":prime.mod(TWENTYFOUR).cmp(ELEVEN)&&(error+=8);break;case\"05\":rem=prime.mod(TEN),rem.cmp(THREE)&&rem.cmp(SEVEN)&&(error+=8);break;default:error+=4}return primeCache[hex]=error,error}function DH(prime,generator,malleable){this.setGenerator(generator),this.__prime=new BN(prime),this._prime=BN.mont(this.__prime),this._primeLen=prime.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,malleable\?(this.setPublicKey=setPublicKey,this.setPrivateKey=setPrivateKey):this._primeCode=8}DH.prototype={},Object.defineProperty(DH.prototype,\"verifyError\",{enumerable:!0,get:function(){return typeof this._primeCode!=\"number\"&&(this._primeCode=checkPrime(this.__prime,this.__gen)),this._primeCode}}),DH.prototype.generateKeys=function(){return this._priv||(this._priv=new BN(randomBytes(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},DH.prototype.computeSecret=function(other){other=new BN(other),other=other.toRed(this._prime);var secret=other.redPow(this._priv).fromRed(),out=new Buffer(secret.toArray()),prime=this.getPrime();if(out.length=0||!r.umod(priv.prime1)||!r.umod(priv.prime2));return r}function crt(msg,priv){var blinds=blind(priv),len=priv.modulus.byteLength(),blinded=new BN(msg).mul(blinds.blinder).umod(priv.modulus),c1=blinded.toRed(BN.mont(priv.prime1)),c2=blinded.toRed(BN.mont(priv.prime2)),qinv=priv.coefficient,p=priv.prime1,q=priv.prime2,m1=c1.redPow(priv.exponent1).fromRed(),m2=c2.redPow(priv.exponent2).fromRed(),h=m1.isub(m2).imul(qinv).umod(p).imul(q);return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer,\"be\",len)}crt.getr=getr,module.exports=crt}}),require_package=__commonJS({\"node_modules/elliptic/package.json\"(exports,module){module.exports={name:\"elliptic\",version:\"6.5.4\",description:\"EC cryptography\",main:\"lib/elliptic.js\",files:[\"lib\"],scripts:{lint:\"eslint lib test\",\"lint:fix\":\"npm run lint -- --fix\",unit:\"istanbul test _mocha --reporter=spec test/index.js\",test:\"npm run lint && npm run unit\",version:\"grunt dist && git add dist/\"},repository:{type:\"git\",url:\"git@github.com:indutny/elliptic\"},keywords:[\"EC\",\"Elliptic\",\"curve\",\"Cryptography\"],author:\"Fedor Indutny \",license:\"MIT\",bugs:{url:\"https://github.com/indutny/elliptic/issues\"},homepage:\"https://github.com/indutny/elliptic\",devDependencies:{brfs:\"^2.0.2\",coveralls:\"^3.1.0\",eslint:\"^7.6.0\",grunt:\"^1.2.1\",\"grunt-browserify\":\"^5.3.0\",\"grunt-cli\":\"^1.3.2\",\"grunt-contrib-connect\":\"^3.0.0\",\"grunt-contrib-copy\":\"^1.0.0\",\"grunt-contrib-uglify\":\"^5.0.0\",\"grunt-mocha-istanbul\":\"^5.0.2\",\"grunt-saucelabs\":\"^9.0.1\",istanbul:\"^0.4.5\",mocha:\"^8.0.1\"},dependencies:{\"bn.js\":\"^4.11.9\",brorand:\"^1.1.0\",\"hash.js\":\"^1.0.0\",\"hmac-drbg\":\"^1.0.1\",inherits:\"^2.0.4\",\"minimalistic-assert\":\"^1.0.1\",\"minimalistic-crypto-utils\":\"^1.0.1\"}}}}),require_bn4=require_bn,require_utils2=__commonJS({\"node_modules/minimalistic-crypto-utils/lib/utils.js\"(exports){var utils=exports;function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if(typeof msg!=\"string\"){for(var i=0;i>8,lo=c&255;hi\?res.push(hi,lo):res.push(lo)}return res}utils.toArray=toArray;function zero2(word){return word.length===1\?\"0\"+word:word}utils.zero2=zero2;function toHex(msg){for(var res=\"\",i=0;i(ws>>1)-1\?z=(ws>>1)-mod:z=mod,k.isubn(z)):z=0,naf[i]=z,k.iushrn(1)}return naf}utils.getNAF=getNAF;function getJSF(k1,k2){var jsf=[[],[]];k1=k1.clone(),k2=k2.clone();for(var d1=0,d2=0,m8;k1.cmpn(-d1)>0||k2.cmpn(-d2)>0;){var m14=k1.andln(3)+d1&3,m24=k2.andln(3)+d2&3;m14===3&&(m14=-1),m24===3&&(m24=-1);var u1;(m14&1)===0\?u1=0:(m8=k1.andln(7)+d1&7,(m8===3||m8===5)&&m24===2\?u1=-m14:u1=m14),jsf[0].push(u1);var u2;(m24&1)===0\?u2=0:(m8=k2.andln(7)+d2&7,(m8===3||m8===5)&&m14===2\?u2=-m24:u2=m24),jsf[1].push(u2),2*d1===u1+1&&(d1=1-d1),2*d2===u2+1&&(d2=1-d2),k1.iushrn(1),k2.iushrn(1)}return jsf}utils.getJSF=getJSF;function cachedProperty(obj,name,computer){var key=\"_\"+name;obj.prototype[name]=function(){return this[key]!==void 0\?this[key]:this[key]=computer.call(this)}}utils.cachedProperty=cachedProperty;function parseBytes(bytes){return typeof bytes==\"string\"\?utils.toArray(bytes,\"hex\"):bytes}utils.parseBytes=parseBytes;function intFromLE(bytes){return new BN(bytes,\"hex\",\"le\")}utils.intFromLE=intFromLE}}),require_base=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/base.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),getNAF=utils.getNAF,getJSF=utils.getJSF,assert=utils.assert;function BaseCurve(type,conf){this.type=type,this.p=new BN(conf.p,16),this.red=conf.prime\?BN.red(conf.prime):BN.mont(this.p),this.zero=new BN(0).toRed(this.red),this.one=new BN(1).toRed(this.red),this.two=new BN(2).toRed(this.red),this.n=conf.n&&new BN(conf.n,16),this.g=conf.g&&this.pointFromJSON(conf.g,conf.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n\?this.n.bitLength():0;var adjustCount=this.n&&this.p.div(this.n);!adjustCount||adjustCount.cmpn(100)>0\?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}module.exports=BaseCurve,BaseCurve.prototype={},BaseCurve.prototype.point=function(){throw new Error(\"Not implemented\")},BaseCurve.prototype.validate=function(){throw new Error(\"Not implemented\")},BaseCurve.prototype._fixedNafMul=function(p,k){assert(p.precomputed);var doubles=p._getDoubles(),naf=getNAF(k,1,this._bitLength),I=(1<=j;l--)nafW=(nafW<<1)+naf[l];repr.push(nafW)}for(var a=this.jpoint(null,null,null),b=this.jpoint(null,null,null),i=I;i>0;i--){for(j=0;j=0;i--){for(var l=0;i>=0&&naf[i]===0;i--)l++;if(i>=0&&l++,acc=acc.dblp(l),i<0)break;var z=naf[i];assert(z!==0),p.type===\"affine\"\?z>0\?acc=acc.mixedAdd(wnd[z-1>>1]):acc=acc.mixedAdd(wnd[-z-1>>1].neg()):z>0\?acc=acc.add(wnd[z-1>>1]):acc=acc.add(wnd[-z-1>>1].neg())}return p.type===\"affine\"\?acc.toP():acc},BaseCurve.prototype._wnafMulAdd=function(defW,points,coeffs,len,jacobianResult){var wndWidth=this._wnafT1,wnd=this._wnafT2,naf=this._wnafT3,max=0,i,j,p;for(i=0;i=1;i-=2){var a=i-1,b=i;if(wndWidth[a]!==1||wndWidth[b]!==1){naf[a]=getNAF(coeffs[a],wndWidth[a],this._bitLength),naf[b]=getNAF(coeffs[b],wndWidth[b],this._bitLength),max=Math.max(naf[a].length,max),max=Math.max(naf[b].length,max);continue}var comb=[points[a],null,null,points[b]];points[a].y.cmp(points[b].y)===0\?(comb[1]=points[a].add(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg())):points[a].y.cmp(points[b].y.redNeg())===0\?(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].add(points[b].neg())):(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg()));var index=[-3,-1,-5,-7,0,7,5,1,3],jsf=getJSF(coeffs[a],coeffs[b]);for(max=Math.max(jsf[0].length,max),naf[a]=new Array(max),naf[b]=new Array(max),j=0;j=0;i--){for(var k=0;i>=0;){var zero=!0;for(j=0;j=0&&k++,acc=acc.dblp(k),i<0)break;for(j=0;j0\?p=wnd[j][z-1>>1]:z<0&&(p=wnd[j][-z-1>>1].neg()),p.type===\"affine\"\?acc=acc.mixedAdd(p):acc=acc.add(p))}}for(i=0;i=Math.ceil((k.bitLength()+1)/doubles.step):!1},BasePoint.prototype._getDoubles=function(step,power){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var doubles=[this],acc=this,i=0;i=0&&(a2=a0,b2=b0),a1.negative&&(a1=a1.neg(),b1=b1.neg()),a2.negative&&(a2=a2.neg(),b2=b2.neg()),[{a:a1,b:b1},{a:a2,b:b2}]},ShortCurve.prototype._endoSplit=function(k){var basis=this.endo.basis,v1=basis[0],v2=basis[1],c1=v2.b.mul(k).divRound(this.n),c2=v1.b.neg().mul(k).divRound(this.n),p1=c1.mul(v1.a),p2=c2.mul(v2.a),q1=c1.mul(v1.b),q2=c2.mul(v2.b),k1=k.sub(p1).sub(p2),k2=q1.add(q2).neg();return{k1,k2}},ShortCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var y2=x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b),y=y2.redSqrt();if(y.redSqr().redSub(y2).cmp(this.zero)!==0)throw new Error(\"invalid point\");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},ShortCurve.prototype.validate=function(point){if(point.inf)return!0;var{x,y}=point,ax=this.a.redMul(x),rhs=x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);return y.redSqr().redISub(rhs).cmpn(0)===0},ShortCurve.prototype._endoWnafMulAdd=function(points,coeffs,jacobianResult){for(var npoints=this._endoWnafT1,ncoeffs=this._endoWnafT2,i=0;i\":\"\"},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(p){if(this.inf)return p;if(p.inf)return this;if(this.eq(p))return this.dbl();if(this.neg().eq(p))return this.curve.point(null,null);if(this.x.cmp(p.x)===0)return this.curve.point(null,null);var c=this.y.redSub(p.y);c.cmpn(0)!==0&&(c=c.redMul(this.x.redSub(p.x).redInvm()));var nx=c.redSqr().redISub(this.x).redISub(p.x),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.dbl=function(){if(this.inf)return this;var ys1=this.y.redAdd(this.y);if(ys1.cmpn(0)===0)return this.curve.point(null,null);var a=this.curve.a,x2=this.x.redSqr(),dyinv=ys1.redInvm(),c=x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv),nx=c.redSqr().redISub(this.x.redAdd(this.x)),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(k){return k=new BN(k,16),this.isInfinity()\?this:this._hasDoubles(k)\?this.curve._fixedNafMul(this,k):this.curve.endo\?this.curve._endoWnafMulAdd([this],[k]):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo\?this.curve._endoWnafMulAdd(points,coeffs):this.curve._wnafMulAdd(1,points,coeffs,2)},Point.prototype.jmulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo\?this.curve._endoWnafMulAdd(points,coeffs,!0):this.curve._wnafMulAdd(1,points,coeffs,2,!0)},Point.prototype.eq=function(p){return this===p||this.inf===p.inf&&(this.inf||this.x.cmp(p.x)===0&&this.y.cmp(p.y)===0)},Point.prototype.neg=function(_precompute){if(this.inf)return this;var res=this.curve.point(this.x,this.y.redNeg());if(_precompute&&this.precomputed){var pre=this.precomputed,negate=function(p){return p.neg()};res.precomputed={naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(negate)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(negate)}}}return res},Point.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var res=this.curve.jpoint(this.x,this.y,this.curve.one);return res};function JPoint(curve,x,y,z){Base.BasePoint.call(this,curve,\"jacobian\"),x===null&&y===null&&z===null\?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN(0)):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=new BN(z,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(x,y,z){return new JPoint(this,x,y,z)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var zinv=this.z.redInvm(),zinv2=zinv.redSqr(),ax=this.x.redMul(zinv2),ay=this.y.redMul(zinv2).redMul(zinv);return this.curve.point(ax,ay)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(p){if(this.isInfinity())return p;if(p.isInfinity())return this;var pz2=p.z.redSqr(),z2=this.z.redSqr(),u1=this.x.redMul(pz2),u2=p.x.redMul(z2),s1=this.y.redMul(pz2.redMul(p.z)),s2=p.y.redMul(z2.redMul(this.z)),h=u1.redSub(u2),r=s1.redSub(s2);if(h.cmpn(0)===0)return r.cmpn(0)!==0\?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(p.z).redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mixedAdd=function(p){if(this.isInfinity())return p.toJ();if(p.isInfinity())return this;var z2=this.z.redSqr(),u1=this.x,u2=p.x.redMul(z2),s1=this.y,s2=p.y.redMul(z2).redMul(this.z),h=u1.redSub(u2),r=s1.redSub(s2);if(h.cmpn(0)===0)return r.cmpn(0)!==0\?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.dblp=function(pow){if(pow===0)return this;if(this.isInfinity())return this;if(!pow)return this.dbl();var i;if(this.curve.zeroA||this.curve.threeA){var r=this;for(i=0;i=0)return!1;if(rx.redIAdd(t),this.x.cmp(rx)===0)return!0}},JPoint.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},JPoint.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),require_mont=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/mont.js\"(exports,module){var BN=require_bn4(),inherits=require_inherits_browser(),Base=require_base(),utils=require_utils3();function MontCurve(conf){Base.call(this,\"mont\",conf),this.a=new BN(conf.a,16).toRed(this.red),this.b=new BN(conf.b,16).toRed(this.red),this.i4=new BN(4).toRed(this.red).redInvm(),this.two=new BN(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(point){var x=point.normalize().x,x2=x.redSqr(),rhs=x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x),y=rhs.redSqrt();return y.redSqr().cmp(rhs)===0};function Point(curve,x,z){Base.BasePoint.call(this,curve,\"projective\"),x===null&&z===null\?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN(x,16),this.z=new BN(z,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits(Point,Base.BasePoint),MontCurve.prototype.decodePoint=function(bytes,enc){return this.point(utils.toArray(bytes,enc),1)},MontCurve.prototype.point=function(x,z){return new Point(this,x,z)},MontCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray(\"be\",this.curve.p.byteLength())},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1]||curve.one)},Point.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},Point.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Point.prototype.dbl=function(){var a=this.x.redAdd(this.z),aa=a.redSqr(),b=this.x.redSub(this.z),bb=b.redSqr(),c=aa.redSub(bb),nx=aa.redMul(bb),nz=c.redMul(bb.redAdd(this.curve.a24.redMul(c)));return this.curve.point(nx,nz)},Point.prototype.add=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.diffAdd=function(p,diff){var a=this.x.redAdd(this.z),b=this.x.redSub(this.z),c=p.x.redAdd(p.z),d=p.x.redSub(p.z),da=d.redMul(a),cb=c.redMul(b),nx=diff.z.redMul(da.redAdd(cb).redSqr()),nz=diff.x.redMul(da.redISub(cb).redSqr());return this.curve.point(nx,nz)},Point.prototype.mul=function(k){for(var t=k.clone(),a=this,b=this.curve.point(null,null),c=this,bits=[];t.cmpn(0)!==0;t.iushrn(1))bits.push(t.andln(1));for(var i=bits.length-1;i>=0;i--)bits[i]===0\?(a=a.diffAdd(b,c),b=b.dbl()):(b=a.diffAdd(b,c),a=a.dbl());return b},Point.prototype.mulAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.jumlAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.eq=function(other){return this.getX().cmp(other.getX())===0},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),require_edwards=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/edwards.js\"(exports,module){var utils=require_utils3(),BN=require_bn4(),inherits=require_inherits_browser(),Base=require_base(),assert=utils.assert;function EdwardsCurve(conf){this.twisted=(conf.a|0)!==1,this.mOneA=this.twisted&&(conf.a|0)===-1,this.extended=this.mOneA,Base.call(this,\"edwards\",conf),this.a=new BN(conf.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN(conf.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN(conf.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(conf.c|0)===1}inherits(EdwardsCurve,Base),module.exports=EdwardsCurve,EdwardsCurve.prototype._mulA=function(num){return this.mOneA\?num.redNeg():this.a.redMul(num)},EdwardsCurve.prototype._mulC=function(num){return this.oneC\?num:this.c.redMul(num)},EdwardsCurve.prototype.jpoint=function(x,y,z,t){return this.point(x,y,z,t)},EdwardsCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var x2=x.redSqr(),rhs=this.c2.redSub(this.a.redMul(x2)),lhs=this.one.redSub(this.c2.redMul(this.d).redMul(x2)),y2=rhs.redMul(lhs.redInvm()),y=y2.redSqrt();if(y.redSqr().redSub(y2).cmp(this.zero)!==0)throw new Error(\"invalid point\");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},EdwardsCurve.prototype.pointFromY=function(y,odd){y=new BN(y,16),y.red||(y=y.toRed(this.red));var y2=y.redSqr(),lhs=y2.redSub(this.c2),rhs=y2.redMul(this.d).redMul(this.c2).redSub(this.a),x2=lhs.redMul(rhs.redInvm());if(x2.cmp(this.zero)===0){if(odd)throw new Error(\"invalid point\");return this.point(this.zero,y)}var x=x2.redSqrt();if(x.redSqr().redSub(x2).cmp(this.zero)!==0)throw new Error(\"invalid point\");return x.fromRed().isOdd()!==odd&&(x=x.redNeg()),this.point(x,y)},EdwardsCurve.prototype.validate=function(point){if(point.isInfinity())return!0;point.normalize();var x2=point.x.redSqr(),y2=point.y.redSqr(),lhs=x2.redMul(this.a).redAdd(y2),rhs=this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));return lhs.cmp(rhs)===0};function Point(curve,x,y,z,t){Base.BasePoint.call(this,curve,\"projective\"),x===null&&y===null&&z===null\?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=z\?new BN(z,16):this.curve.one,this.t=t&&new BN(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}inherits(Point,Base.BasePoint),EdwardsCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},EdwardsCurve.prototype.point=function(x,y,z,t){return new Point(this,x,y,z,t)},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1],obj[2])},Point.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},Point.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},Point.prototype._extDbl=function(){var a=this.x.redSqr(),b=this.y.redSqr(),c=this.z.redSqr();c=c.redIAdd(c);var d=this.curve._mulA(a),e=this.x.redAdd(this.y).redSqr().redISub(a).redISub(b),g=d.redAdd(b),f=g.redSub(c),h=d.redSub(b),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projDbl=function(){var b=this.x.redAdd(this.y).redSqr(),c=this.x.redSqr(),d=this.y.redSqr(),nx,ny,nz,e,h,j;if(this.curve.twisted){e=this.curve._mulA(c);var f=e.redAdd(d);this.zOne\?(nx=b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)),ny=f.redMul(e.redSub(d)),nz=f.redSqr().redSub(f).redSub(f)):(h=this.z.redSqr(),j=f.redSub(h).redISub(h),nx=b.redSub(c).redISub(d).redMul(j),ny=f.redMul(e.redSub(d)),nz=f.redMul(j))}else e=c.redAdd(d),h=this.curve._mulC(this.z).redSqr(),j=e.redSub(h).redSub(h),nx=this.curve._mulC(b.redISub(e)).redMul(j),ny=this.curve._mulC(e).redMul(c.redISub(d)),nz=e.redMul(j);return this.curve.point(nx,ny,nz)},Point.prototype.dbl=function(){return this.isInfinity()\?this:this.curve.extended\?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(p){var a=this.y.redSub(this.x).redMul(p.y.redSub(p.x)),b=this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)),c=this.t.redMul(this.curve.dd).redMul(p.t),d=this.z.redMul(p.z.redAdd(p.z)),e=b.redSub(a),f=d.redSub(c),g=d.redAdd(c),h=b.redAdd(a),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projAdd=function(p){var a=this.z.redMul(p.z),b=a.redSqr(),c=this.x.redMul(p.x),d=this.y.redMul(p.y),e=this.curve.d.redMul(c).redMul(d),f=b.redSub(e),g=b.redAdd(e),tmp=this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d),nx=a.redMul(f).redMul(tmp),ny,nz;return this.curve.twisted\?(ny=a.redMul(g).redMul(d.redSub(this.curve._mulA(c))),nz=f.redMul(g)):(ny=a.redMul(g).redMul(d.redSub(c)),nz=this.curve._mulC(f).redMul(g)),this.curve.point(nx,ny,nz)},Point.prototype.add=function(p){return this.isInfinity()\?p:p.isInfinity()\?this:this.curve.extended\?this._extAdd(p):this._projAdd(p)},Point.prototype.mul=function(k){return this._hasDoubles(k)\?this.curve._fixedNafMul(this,k):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!1)},Point.prototype.jmulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var zi=this.z.redInvm();return this.x=this.x.redMul(zi),this.y=this.y.redMul(zi),this.t&&(this.t=this.t.redMul(zi)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(other){return this===other||this.getX().cmp(other.getX())===0&&this.getY().cmp(other.getY())===0},Point.prototype.eqXToP=function(x){var rx=x.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(rx)===0)return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(this.z);;){if(xc.iadd(this.curve.n),xc.cmp(this.curve.p)>=0)return!1;if(rx.redIAdd(t),this.x.cmp(rx)===0)return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add}}),require_curve=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/index.js\"(exports){var curve=exports;curve.base=require_base(),curve.short=require_short(),curve.mont=require_mont(),curve.edwards=require_edwards()}}),require_utils4=__commonJS({\"node_modules/hash.js/lib/hash/utils.js\"(exports){var assert=require_minimalistic_assert(),inherits=require_inherits_browser();exports.inherits=inherits;function isSurrogatePair(msg,i){return(msg.charCodeAt(i)&64512)!==55296||i<0||i+1>=msg.length\?!1:(msg.charCodeAt(i+1)&64512)===56320}function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if(typeof msg==\"string\")if(enc){if(enc===\"hex\")for(msg=msg.replace(/[^a-z0-9]+/gi,\"\"),msg.length%2!==0&&(msg=\"0\"+msg),i=0;i>6|192,res[p++]=c&63|128):isSurrogatePair(msg,i)\?(c=65536+((c&1023)<<10)+(msg.charCodeAt(++i)&1023),res[p++]=c>>18|240,res[p++]=c>>12&63|128,res[p++]=c>>6&63|128,res[p++]=c&63|128):(res[p++]=c>>12|224,res[p++]=c>>6&63|128,res[p++]=c&63|128)}else for(i=0;i>>24|w>>>8&65280|w<<8&16711680|(w&255)<<24;return res>>>0}exports.htonl=htonl;function toHex32(msg,endian){for(var res=\"\",i=0;i>>0}return res}exports.join32=join32;function split32(msg,endian){for(var res=new Array(msg.length*4),i=0,k=0;i>>24,res[k+1]=m>>>16&255,res[k+2]=m>>>8&255,res[k+3]=m&255):(res[k+3]=m>>>24,res[k+2]=m>>>16&255,res[k+1]=m>>>8&255,res[k]=m&255)}return res}exports.split32=split32;function rotr32(w,b){return w>>>b|w<<32-b}exports.rotr32=rotr32;function rotl32(w,b){return w<>>32-b}exports.rotl32=rotl32;function sum32(a,b){return a+b>>>0}exports.sum32=sum32;function sum32_3(a,b,c){return a+b+c>>>0}exports.sum32_3=sum32_3;function sum32_4(a,b,c,d){return a+b+c+d>>>0}exports.sum32_4=sum32_4;function sum32_5(a,b,c,d,e){return a+b+c+d+e>>>0}exports.sum32_5=sum32_5;function sum64(buf,pos,ah,al){var bh=buf[pos],bl=buf[pos+1],lo=al+bl>>>0,hi=(lo>>0,buf[pos+1]=lo}exports.sum64=sum64;function sum64_hi(ah,al,bh,bl){var lo=al+bl>>>0,hi=(lo>>0}exports.sum64_hi=sum64_hi;function sum64_lo(ah,al,bh,bl){var lo=al+bl;return lo>>>0}exports.sum64_lo=sum64_lo;function sum64_4_hi(ah,al,bh,bl,ch,cl,dh,dl){var carry=0,lo=al;lo=lo+bl>>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0}exports.sum64_4_hi=sum64_4_hi;function sum64_4_lo(ah,al,bh,bl,ch,cl,dh,dl){var lo=al+bl+cl+dl;return lo>>>0}exports.sum64_4_lo=sum64_4_lo;function sum64_5_hi(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var carry=0,lo=al;lo=lo+bl>>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0}exports.sum64_5_hi=sum64_5_hi;function sum64_5_lo(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var lo=al+bl+cl+dl+el;return lo>>>0}exports.sum64_5_lo=sum64_5_lo;function rotr64_hi(ah,al,num){var r=al<<32-num|ah>>>num;return r>>>0}exports.rotr64_hi=rotr64_hi;function rotr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}exports.rotr64_lo=rotr64_lo;function shr64_hi(ah,al,num){return ah>>>num}exports.shr64_hi=shr64_hi;function shr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}exports.shr64_lo=shr64_lo}}),require_common=__commonJS({\"node_modules/hash.js/lib/hash/common.js\"(exports){var utils=require_utils4(),assert=require_minimalistic_assert();function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian=\"big\",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}BlockHash.prototype={},exports.BlockHash=BlockHash,BlockHash.prototype.update=function(msg,enc){if(msg=utils.toArray(msg,enc),this.pending\?this.pending=this.pending.concat(msg):this.pending=msg,this.pendingTotal+=msg.length,this.pending.length>=this._delta8){msg=this.pending;var r=msg.length%this._delta8;this.pending=msg.slice(msg.length-r,msg.length),this.pending.length===0&&(this.pending=null),msg=utils.join32(msg,0,msg.length-r,this.endian);for(var i=0;i>>24&255,res[i++]=len>>>16&255,res[i++]=len>>>8&255,res[i++]=len&255}else for(res[i++]=len&255,res[i++]=len>>>8&255,res[i++]=len>>>16&255,res[i++]=len>>>24&255,res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=0,t=8;t>>3}exports.g0_256=g0_256;function g1_256(x){return rotr32(x,17)^rotr32(x,19)^x>>>10}exports.g1_256=g1_256}}),require__=__commonJS({\"node_modules/hash.js/lib/hash/sha/1.js\"(exports,module){var utils=require_utils4(),common=require_common(),shaCommon=require_common2(),rotl32=utils.rotl32,sum32=utils.sum32,sum32_5=utils.sum32_5,ft_1=shaCommon.ft_1,BlockHash=common.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils.inherits(SHA1,BlockHash),module.exports=SHA1,SHA1.blockSize=512,SHA1.outSize=160,SHA1.hmacStrength=80,SHA1.padLength=64,SHA1.prototype._update=function(msg,start){for(var W=this.W,i=0;i<16;i++)W[i]=msg[start+i];for(;ithis.blockSize&&(key=new this.Hash().update(key).digest()),assert(key.length<=this.blockSize);for(var i=key.length;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._init(entropy,nonce,pers)}HmacDRBG.prototype={},module.exports=HmacDRBG,HmacDRBG.prototype._init=function(entropy,nonce,pers){var seed=entropy.concat(nonce).concat(pers);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._update(entropy.concat(add||[])),this._reseed=1},HmacDRBG.prototype.generate=function(len,enc,add,addEnc){if(this._reseed>this.reseedInterval)throw new Error(\"Reseed is required\");typeof enc!=\"string\"&&(addEnc=add,add=enc,enc=null),add&&(add=utils.toArray(add,addEnc||\"hex\"),this._update(add));for(var temp=[];temp.length\"}}}),require_signature=__commonJS({\"node_modules/elliptic/lib/elliptic/ec/signature.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),assert=utils.assert;function Signature(options,enc){if(options instanceof Signature)return options;this._importDER(options,enc)||(assert(options.r&&options.s,\"Signature without r or s\"),this.r=new BN(options.r,16),this.s=new BN(options.s,16),options.recoveryParam===void 0\?this.recoveryParam=null:this.recoveryParam=options.recoveryParam)}Signature.prototype={},module.exports=Signature;function Position(){this.place=0}function getLength(buf,p){var initial=buf[p.place++];if(!(initial&128))return initial;var octetLen=initial&15;if(octetLen===0||octetLen>4)return!1;for(var val=0,i=0,off=p.place;i>>=0;return val<=127\?!1:(p.place=off,val)}function rmPadding(buf){for(var i=0,len=buf.length-1;!buf[i]&&!(buf[i+1]&128)&&i>>3);for(arr.push(octets|128);--octets;)arr.push(len>>>(octets<<3)&255);arr.push(len)}Signature.prototype.toDER=function(enc){var r=this.r.toArray(),s=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),s[0]&128&&(s=[0].concat(s)),r=rmPadding(r),s=rmPadding(s);!s[0]&&!(s[1]&128);)s=s.slice(1);var arr=[2];constructLength(arr,r.length),arr=arr.concat(r),arr.push(2),constructLength(arr,s.length);var backHalf=arr.concat(s),res=[48];return constructLength(res,backHalf.length),res=res.concat(backHalf),utils.encode(res,enc)}}}),require_ec=__commonJS({\"node_modules/elliptic/lib/elliptic/ec/index.js\"(exports,module){var BN=require_bn4(),HmacDRBG=require_hmac_drbg(),utils=require_utils3(),curves=require_curves(),rand=require_brorand(),assert=utils.assert,KeyPair=require_key(),Signature=require_signature();function EC(options){if(!(this instanceof EC))return new EC(options);typeof options==\"string\"&&(assert(Object.prototype.hasOwnProperty.call(curves,options),\"Unknown curve \"+options),options=curves[options]),options instanceof curves.PresetCurve&&(options={curve:options}),this.curve=options.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=options.curve.g,this.g.precompute(options.curve.n.bitLength()+1),this.hash=options.hash||options.curve.hash}EC.prototype={},module.exports=EC,EC.prototype.keyPair=function(options){return new KeyPair(this,options)},EC.prototype.keyFromPrivate=function(priv,enc){return KeyPair.fromPrivate(this,priv,enc)},EC.prototype.keyFromPublic=function(pub,enc){return KeyPair.fromPublic(this,pub,enc)},EC.prototype.genKeyPair=function(options){options||(options={});for(var drbg=new HmacDRBG({hash:this.hash,pers:options.pers,persEnc:options.persEnc||\"utf8\",entropy:options.entropy||rand(this.hash.hmacStrength),entropyEnc:options.entropy&&options.entropyEnc||\"utf8\",nonce:this.n.toArray()}),bytes=this.n.byteLength(),ns2=this.n.sub(new BN(2));;){var priv=new BN(drbg.generate(bytes));if(!(priv.cmp(ns2)>0))return priv.iaddn(1),this.keyFromPrivate(priv)}},EC.prototype._truncateToN=function(msg,truncOnly){var delta=msg.byteLength()*8-this.n.bitLength();return delta>0&&(msg=msg.ushrn(delta)),!truncOnly&&msg.cmp(this.n)>=0\?msg.sub(this.n):msg},EC.prototype.sign=function(msg,key,enc,options){typeof enc==\"object\"&&(options=enc,enc=null),options||(options={}),key=this.keyFromPrivate(key,enc),msg=this._truncateToN(new BN(msg,16));for(var bytes=this.n.byteLength(),bkey=key.getPrivate().toArray(\"be\",bytes),nonce=msg.toArray(\"be\",bytes),drbg=new HmacDRBG({hash:this.hash,entropy:bkey,nonce,pers:options.pers,persEnc:options.persEnc||\"utf8\"}),ns1=this.n.sub(new BN(1)),iter=0;;iter++){var k=options.k\?options.k(iter):new BN(drbg.generate(this.n.byteLength()));if(k=this._truncateToN(k,!0),!(k.cmpn(1)<=0||k.cmp(ns1)>=0)){var kp=this.g.mul(k);if(!kp.isInfinity()){var kpX=kp.getX(),r=kpX.umod(this.n);if(r.cmpn(0)!==0){var s=k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));if(s=s.umod(this.n),s.cmpn(0)!==0){var recoveryParam=(kp.getY().isOdd()\?1:0)|(kpX.cmp(r)!==0\?2:0);return options.canonical&&s.cmp(this.nh)>0&&(s=this.n.sub(s),recoveryParam^=1),new Signature({r,s,recoveryParam})}}}}}},EC.prototype.verify=function(msg,signature,key,enc){msg=this._truncateToN(new BN(msg,16)),key=this.keyFromPublic(key,enc),signature=new Signature(signature,\"hex\");var{r,s}=signature;if(r.cmpn(1)<0||r.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var sinv=s.invm(this.n),u1=sinv.mul(msg).umod(this.n),u2=sinv.mul(r).umod(this.n),p;return this.curve._maxwellTrick\?(p=this.g.jmulAdd(u1,key.getPublic(),u2),p.isInfinity()\?!1:p.eqXToP(r)):(p=this.g.mulAdd(u1,key.getPublic(),u2),p.isInfinity()\?!1:p.getX().umod(this.n).cmp(r)===0)},EC.prototype.recoverPubKey=function(msg,signature,j,enc){assert((3&j)===j,\"The recovery param is more than two bits\"),signature=new Signature(signature,enc);var n=this.n,e=new BN(msg),r=signature.r,s=signature.s,isYOdd=j&1,isSecondKey=j>>1;if(r.cmp(this.curve.p.umod(this.curve.n))>=0&&isSecondKey)throw new Error(\"Unable to find sencond key candinate\");isSecondKey\?r=this.curve.pointFromX(r.add(this.curve.n),isYOdd):r=this.curve.pointFromX(r,isYOdd);var rInv=signature.r.invm(n),s1=n.sub(e).mul(rInv).umod(n),s2=s.mul(rInv).umod(n);return this.g.mulAdd(s1,r,s2)},EC.prototype.getKeyRecoveryParam=function(e,signature,Q,enc){if(signature=new Signature(signature,enc),signature.recoveryParam!==null)return signature.recoveryParam;for(var i=0;i<4;i++){var Qprime;try{Qprime=this.recoverPubKey(e,signature,i)}catch{continue}if(Qprime.eq(Q))return i}throw new Error(\"Unable to find valid recovery factor\")}}}),require_key2=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/key.js\"(exports,module){var utils=require_utils3(),assert=utils.assert,parseBytes=utils.parseBytes,cachedProperty=utils.cachedProperty;function KeyPair(eddsa,params){this.eddsa=eddsa,this._secret=parseBytes(params.secret),eddsa.isPoint(params.pub)\?this._pub=params.pub:this._pubBytes=parseBytes(params.pub)}KeyPair.prototype={},KeyPair.fromPublic=function(eddsa,pub){return pub instanceof KeyPair\?pub:new KeyPair(eddsa,{pub})},KeyPair.fromSecret=function(eddsa,secret){return secret instanceof KeyPair\?secret:new KeyPair(eddsa,{secret})},KeyPair.prototype.secret=function(){return this._secret},cachedProperty(KeyPair,\"pubBytes\",function(){return this.eddsa.encodePoint(this.pub())}),cachedProperty(KeyPair,\"pub\",function(){return this._pubBytes\?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),cachedProperty(KeyPair,\"privBytes\",function(){var eddsa=this.eddsa,hash=this.hash(),lastIx=eddsa.encodingLength-1,a=hash.slice(0,eddsa.encodingLength);return a[0]&=248,a[lastIx]&=127,a[lastIx]|=64,a}),cachedProperty(KeyPair,\"priv\",function(){return this.eddsa.decodeInt(this.privBytes())}),cachedProperty(KeyPair,\"hash\",function(){return this.eddsa.hash().update(this.secret()).digest()}),cachedProperty(KeyPair,\"messagePrefix\",function(){return this.hash().slice(this.eddsa.encodingLength)}),KeyPair.prototype.sign=function(message){return assert(this._secret,\"KeyPair can only verify\"),this.eddsa.sign(message,this)},KeyPair.prototype.verify=function(message,sig){return this.eddsa.verify(message,sig,this)},KeyPair.prototype.getSecret=function(enc){return assert(this._secret,\"KeyPair is public only\"),utils.encode(this.secret(),enc)},KeyPair.prototype.getPublic=function(enc){return utils.encode(this.pubBytes(),enc)},module.exports=KeyPair}}),require_signature2=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/signature.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),assert=utils.assert,cachedProperty=utils.cachedProperty,parseBytes=utils.parseBytes;function Signature(eddsa,sig){this.eddsa=eddsa,typeof sig!=\"object\"&&(sig=parseBytes(sig)),Array.isArray(sig)&&(sig={R:sig.slice(0,eddsa.encodingLength),S:sig.slice(eddsa.encodingLength)}),assert(sig.R&&sig.S,\"Signature without R or S\"),eddsa.isPoint(sig.R)&&(this._R=sig.R),sig.S instanceof BN&&(this._S=sig.S),this._Rencoded=Array.isArray(sig.R)\?sig.R:sig.Rencoded,this._Sencoded=Array.isArray(sig.S)\?sig.S:sig.Sencoded}Signature.prototype={},cachedProperty(Signature,\"S\",function(){return this.eddsa.decodeInt(this.Sencoded())}),cachedProperty(Signature,\"R\",function(){return this.eddsa.decodePoint(this.Rencoded())}),cachedProperty(Signature,\"Rencoded\",function(){return this.eddsa.encodePoint(this.R())}),cachedProperty(Signature,\"Sencoded\",function(){return this.eddsa.encodeInt(this.S())}),Signature.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Signature.prototype.toHex=function(){return utils.encode(this.toBytes(),\"hex\").toUpperCase()},module.exports=Signature}}),require_eddsa=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/index.js\"(exports,module){var hash=require_hash2(),curves=require_curves(),utils=require_utils3(),assert=utils.assert,parseBytes=utils.parseBytes,KeyPair=require_key2(),Signature=require_signature2();function EDDSA(curve){if(assert(curve===\"ed25519\",\"only tested with ed25519 so far\"),!(this instanceof EDDSA))return new EDDSA(curve);curve=curves[curve].curve,this.curve=curve,this.g=curve.g,this.g.precompute(curve.n.bitLength()+1),this.pointClass=curve.point().constructor,this.encodingLength=Math.ceil(curve.n.bitLength()/8),this.hash=hash.sha512}EDDSA.prototype={},module.exports=EDDSA,EDDSA.prototype.sign=function(message,secret){message=parseBytes(message);var key=this.keyFromSecret(secret),r=this.hashInt(key.messagePrefix(),message),R=this.g.mul(r),Rencoded=this.encodePoint(R),s_=this.hashInt(Rencoded,key.pubBytes(),message).mul(key.priv()),S=r.add(s_).umod(this.curve.n);return this.makeSignature({R,S,Rencoded})},EDDSA.prototype.verify=function(message,sig,pub){message=parseBytes(message),sig=this.makeSignature(sig);var key=this.keyFromPublic(pub),h=this.hashInt(sig.Rencoded(),key.pubBytes(),message),SG=this.g.mul(sig.S()),RplusAh=sig.R().add(key.pub().mul(h));return RplusAh.eq(SG)},EDDSA.prototype.hashInt=function(){for(var hash2=this.hash(),i=0;i\"u\")@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof value);return Buffer2(value,encodingOrOffset,length)}),Safer.alloc||(Safer.alloc=function(size,fill,encoding){if(typeof size!=\"number\")@throwTypeError('The \"size\" argument must be of type number. Received type '+typeof size);if(size<0||size>=2*(1<<30))@throwRangeError('The value \"'+size+'\" is invalid for option \"size\"');var buf=Buffer2(size);return!fill||fill.length===0\?buf.fill(0):typeof encoding==\"string\"\?buf.fill(fill,encoding):buf.fill(fill),buf}),!safer.kStringMaxLength)try{safer.kStringMaxLength=MAX_STRING_LENGTH}catch{}safer.constants||(safer.constants={MAX_LENGTH:safer.kMaxLength},safer.kStringMaxLength&&(safer.constants.MAX_STRING_LENGTH=safer.kStringMaxLength)),module.exports=safer}}),require_reporter=__commonJS({\"node_modules/asn1.js/lib/asn1/base/reporter.js\"(exports){var inherits=require_inherits_browser();function Reporter(options){this._reporterState={obj:null,path:[],options:options||{},errors:[]}}Reporter.prototype={},exports.Reporter=Reporter,Reporter.prototype.isError=function(obj){return obj instanceof ReporterError},Reporter.prototype.save=function(){let state=this._reporterState;return{obj:state.obj,pathLen:state.path.length}},Reporter.prototype.restore=function(data){let state=this._reporterState;state.obj=data.obj,state.path=state.path.slice(0,data.pathLen)},Reporter.prototype.enterKey=function(key){return this._reporterState.path.push(key)},Reporter.prototype.exitKey=function(index){let state=this._reporterState;state.path=state.path.slice(0,index-1)},Reporter.prototype.leaveKey=function(index,key,value){let state=this._reporterState;this.exitKey(index),state.obj!==null&&(state.obj[key]=value)},Reporter.prototype.path=function(){return this._reporterState.path.join(\"/\")},Reporter.prototype.enterObject=function(){let state=this._reporterState,prev=state.obj;return state.obj={},prev},Reporter.prototype.leaveObject=function(prev){let state=this._reporterState,now=state.obj;return state.obj=prev,now},Reporter.prototype.error=function(msg){let err,state=this._reporterState,inherited=msg instanceof ReporterError;if(inherited\?err=msg:err=new ReporterError(state.path.map(function(elem){return\"[\"+JSON.stringify(elem)+\"]\"}).join(\"\"),msg.message||msg,msg.stack),!state.options.partial)throw err;return inherited||state.errors.push(err),err},Reporter.prototype.wrapResult=function(result){let state=this._reporterState;return state.options.partial\?{result:this.isError(result)\?null:result,errors:state.errors}:result};function ReporterError(path,msg){this.path=path,this.rethrow(msg)}inherits(ReporterError,Error),ReporterError.prototype.rethrow=function(msg){if(this.message=msg+\" at: \"+(this.path||\"(shallow)\"),Error.captureStackTrace&&Error.captureStackTrace(this,ReporterError),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}}}),require_buffer=__commonJS({\"node_modules/asn1.js/lib/asn1/base/buffer.js\"(exports){var inherits=require_inherits_browser(),Reporter=require_reporter().Reporter,Buffer2=require_safer().Buffer;function DecoderBuffer(base,options){if(Reporter.call(this,options),!Buffer2.isBuffer(base)){this.error(\"Input not Buffer\");return}this.base=base,this.offset=0,this.length=base.length}inherits(DecoderBuffer,Reporter),exports.DecoderBuffer=DecoderBuffer,DecoderBuffer.isDecoderBuffer=function(data){return data instanceof DecoderBuffer\?!0:typeof data==\"object\"&&Buffer2.isBuffer(data.base)&&data.constructor.name===\"DecoderBuffer\"&&typeof data.offset==\"number\"&&typeof data.length==\"number\"&&typeof data.save==\"function\"&&typeof data.restore==\"function\"&&typeof data.isEmpty==\"function\"&&typeof data.readUInt8==\"function\"&&typeof data.skip==\"function\"&&typeof data.raw==\"function\"},DecoderBuffer.prototype.save=function(){return{offset:this.offset,reporter:Reporter.prototype.save.call(this)}},DecoderBuffer.prototype.restore=function(save){let res=new DecoderBuffer(this.base);return res.offset=save.offset,res.length=this.offset,this.offset=save.offset,Reporter.prototype.restore.call(this,save.reporter),res},DecoderBuffer.prototype.isEmpty=function(){return this.offset===this.length},DecoderBuffer.prototype.readUInt8=function(fail){return this.offset+1<=this.length\?this.base.readUInt8(this.offset++,!0):this.error(fail||\"DecoderBuffer overrun\")},DecoderBuffer.prototype.skip=function(bytes,fail){if(!(this.offset+bytes<=this.length))return this.error(fail||\"DecoderBuffer overrun\");let res=new DecoderBuffer(this.base);return res._reporterState=this._reporterState,res.offset=this.offset,res.length=this.offset+bytes,this.offset+=bytes,res},DecoderBuffer.prototype.raw=function(save){return this.base.slice(save\?save.offset:this.offset,this.length)};function EncoderBuffer(value,reporter){if(Array.isArray(value))this.length=0,this.value=value.map(function(item){return EncoderBuffer.isEncoderBuffer(item)||(item=new EncoderBuffer(item,reporter)),this.length+=item.length,item},this);else if(typeof value==\"number\"){if(!(0<=value&&value<=255))return reporter.error(\"non-byte EncoderBuffer value\");this.value=value,this.length=1}else if(typeof value==\"string\")this.value=value,this.length=Buffer2.byteLength(value);else if(Buffer2.isBuffer(value))this.value=value,this.length=value.length;else return reporter.error(\"Unsupported type: \"+typeof value)}EncoderBuffer.prototype={},exports.EncoderBuffer=EncoderBuffer,EncoderBuffer.isEncoderBuffer=function(data){return data instanceof EncoderBuffer\?!0:typeof data==\"object\"&&data.constructor.name===\"EncoderBuffer\"&&typeof data.length==\"number\"&&typeof data.join==\"function\"},EncoderBuffer.prototype.join=function(out,offset){return out||(out=Buffer2.alloc(this.length)),offset||(offset=0),this.length===0||(Array.isArray(this.value)\?this.value.forEach(function(item){item.join(out,offset),offset+=item.length}):(typeof this.value==\"number\"\?out[offset]=this.value:typeof this.value==\"string\"\?out.write(this.value,offset):Buffer2.isBuffer(this.value)&&this.value.copy(out,offset),offset+=this.length)),out}}}),require_node=__commonJS({\"node_modules/asn1.js/lib/asn1/base/node.js\"(exports,module){var Reporter=require_reporter().Reporter,EncoderBuffer=require_buffer().EncoderBuffer,DecoderBuffer=require_buffer().DecoderBuffer,assert=require_minimalistic_assert(),tags=[\"seq\",\"seqof\",\"set\",\"setof\",\"objid\",\"bool\",\"gentime\",\"utctime\",\"null_\",\"enum\",\"int\",\"objDesc\",\"bitstr\",\"bmpstr\",\"charstr\",\"genstr\",\"graphstr\",\"ia5str\",\"iso646str\",\"numstr\",\"octstr\",\"printstr\",\"t61str\",\"unistr\",\"utf8str\",\"videostr\"],methods=[\"key\",\"obj\",\"use\",\"optional\",\"explicit\",\"implicit\",\"def\",\"choice\",\"any\",\"contains\"].concat(tags),overrided=[\"_peekTag\",\"_decodeTag\",\"_use\",\"_decodeStr\",\"_decodeObjid\",\"_decodeTime\",\"_decodeNull\",\"_decodeInt\",\"_decodeBool\",\"_decodeList\",\"_encodeComposite\",\"_encodeStr\",\"_encodeObjid\",\"_encodeTime\",\"_encodeNull\",\"_encodeInt\",\"_encodeBool\"];function Node(enc,parent,name){let state={};this._baseState=state,state.name=name,state.enc=enc,state.parent=parent||null,state.children=null,state.tag=null,state.args=null,state.reverseArgs=null,state.choice=null,state.optional=!1,state.any=!1,state.obj=!1,state.use=null,state.useDecoder=null,state.key=null,state.default=null,state.explicit=null,state.implicit=null,state.contains=null,state.parent||(state.children=[],this._wrap())}Node.prototype={},module.exports=Node;var stateProps=[\"enc\",\"parent\",\"children\",\"tag\",\"args\",\"reverseArgs\",\"choice\",\"optional\",\"any\",\"obj\",\"use\",\"alteredUse\",\"key\",\"default\",\"explicit\",\"implicit\",\"contains\"];Node.prototype.clone=function(){let state=this._baseState,cstate={};stateProps.forEach(function(prop){cstate[prop]=state[prop]});let res=new this.constructor(cstate.parent);return res._baseState=cstate,res},Node.prototype._wrap=function(){let state=this._baseState;methods.forEach(function(method){this[method]=function(){let clone=new this.constructor(this);return state.children.push(clone),clone[method].apply(clone,arguments)}},this)},Node.prototype._init=function(body){let state=this._baseState;assert(state.parent===null),body.call(this),state.children=state.children.filter(function(child){return child._baseState.parent===this},this),assert.equal(state.children.length,1,\"Root node can have only one child\")},Node.prototype._useArgs=function(args){let state=this._baseState,children=args.filter(function(arg){return arg instanceof this.constructor},this);args=args.filter(function(arg){return!(arg instanceof this.constructor)},this),children.length!==0&&(assert(state.children===null),state.children=children,children.forEach(function(child){child._baseState.parent=this},this)),args.length!==0&&(assert(state.args===null),state.args=args,state.reverseArgs=args.map(function(arg){if(typeof arg!=\"object\"||arg.constructor!==Object)return arg;let res={};return Object.keys(arg).forEach(function(key){key==(key|0)&&(key|=0);let value=arg[key];res[value]=key}),res}))},overrided.forEach(function(method){Node.prototype[method]=function(){let state=this._baseState;throw new Error(method+\" not implemented for encoding: \"+state.enc)}}),tags.forEach(function(tag){Node.prototype[tag]=function(){let state=this._baseState,args=Array.prototype.slice.call(arguments);return assert(state.tag===null),state.tag=tag,this._useArgs(args),this}}),Node.prototype.use=function(item){assert(item);let state=this._baseState;return assert(state.use===null),state.use=item,this},Node.prototype.optional=function(){let state=this._baseState;return state.optional=!0,this},Node.prototype.def=function(val){let state=this._baseState;return assert(state.default===null),state.default=val,state.optional=!0,this},Node.prototype.explicit=function(num){let state=this._baseState;return assert(state.explicit===null&&state.implicit===null),state.explicit=num,this},Node.prototype.implicit=function(num){let state=this._baseState;return assert(state.explicit===null&&state.implicit===null),state.implicit=num,this},Node.prototype.obj=function(){let state=this._baseState,args=Array.prototype.slice.call(arguments);return state.obj=!0,args.length!==0&&this._useArgs(args),this},Node.prototype.key=function(newKey){let state=this._baseState;return assert(state.key===null),state.key=newKey,this},Node.prototype.any=function(){let state=this._baseState;return state.any=!0,this},Node.prototype.choice=function(obj){let state=this._baseState;return assert(state.choice===null),state.choice=obj,this._useArgs(Object.keys(obj).map(function(key){return obj[key]})),this},Node.prototype.contains=function(item){let state=this._baseState;return assert(state.use===null),state.contains=item,this},Node.prototype._decode=function(input,options){let state=this._baseState;if(state.parent===null)return input.wrapResult(state.children[0]._decode(input,options));let result=state.default,present=!0,prevKey=null;if(state.key!==null&&(prevKey=input.enterKey(state.key)),state.optional){let tag=null;if(state.explicit!==null\?tag=state.explicit:state.implicit!==null\?tag=state.implicit:state.tag!==null&&(tag=state.tag),tag===null&&!state.any){let save=input.save();try{state.choice===null\?this._decodeGeneric(state.tag,input,options):this._decodeChoice(input,options),present=!0}catch{present=!1}input.restore(save)}else if(present=this._peekTag(input,tag,state.any),input.isError(present))return present}let prevObj;if(state.obj&&present&&(prevObj=input.enterObject()),present){if(state.explicit!==null){let explicit=this._decodeTag(input,state.explicit);if(input.isError(explicit))return explicit;input=explicit}let start=input.offset;if(state.use===null&&state.choice===null){let save;state.any&&(save=input.save());let body=this._decodeTag(input,state.implicit!==null\?state.implicit:state.tag,state.any);if(input.isError(body))return body;state.any\?result=input.raw(save):input=body}if(options&&options.track&&state.tag!==null&&options.track(input.path(),start,input.length,\"tagged\"),options&&options.track&&state.tag!==null&&options.track(input.path(),input.offset,input.length,\"content\"),state.any||(state.choice===null\?result=this._decodeGeneric(state.tag,input,options):result=this._decodeChoice(input,options)),input.isError(result))return result;if(!state.any&&state.choice===null&&state.children!==null&&state.children.forEach(function(child){child._decode(input,options)}),state.contains&&(state.tag===\"octstr\"||state.tag===\"bitstr\")){let data=new DecoderBuffer(result);result=this._getUse(state.contains,input._reporterState.obj)._decode(data,options)}}return state.obj&&present&&(result=input.leaveObject(prevObj)),state.key!==null&&(result!==null||present===!0)\?input.leaveKey(prevKey,state.key,result):prevKey!==null&&input.exitKey(prevKey),result},Node.prototype._decodeGeneric=function(tag,input,options){let state=this._baseState;return tag===\"seq\"||tag===\"set\"\?null:tag===\"seqof\"||tag===\"setof\"\?this._decodeList(input,tag,state.args[0],options):/str$/.test(tag)\?this._decodeStr(input,tag,options):tag===\"objid\"&&state.args\?this._decodeObjid(input,state.args[0],state.args[1],options):tag===\"objid\"\?this._decodeObjid(input,null,null,options):tag===\"gentime\"||tag===\"utctime\"\?this._decodeTime(input,tag,options):tag===\"null_\"\?this._decodeNull(input,options):tag===\"bool\"\?this._decodeBool(input,options):tag===\"objDesc\"\?this._decodeStr(input,tag,options):tag===\"int\"||tag===\"enum\"\?this._decodeInt(input,state.args&&state.args[0],options):state.use!==null\?this._getUse(state.use,input._reporterState.obj)._decode(input,options):input.error(\"unknown tag: \"+tag)},Node.prototype._getUse=function(entity,obj){let state=this._baseState;return state.useDecoder=this._use(entity,obj),assert(state.useDecoder._baseState.parent===null),state.useDecoder=state.useDecoder._baseState.children[0],state.implicit!==state.useDecoder._baseState.implicit&&(state.useDecoder=state.useDecoder.clone(),state.useDecoder._baseState.implicit=state.implicit),state.useDecoder},Node.prototype._decodeChoice=function(input,options){let state=this._baseState,result=null,match=!1;return Object.keys(state.choice).some(function(key){let save=input.save(),node=state.choice[key];try{let value=node._decode(input,options);if(input.isError(value))return!1;result={type:key,value},match=!0}catch{return input.restore(save),!1}return!0},this),match\?result:input.error(\"Choice not matched\")},Node.prototype._createEncoderBuffer=function(data){return new EncoderBuffer(data,this.reporter)},Node.prototype._encode=function(data,reporter,parent){let state=this._baseState;if(state.default!==null&&state.default===data)return;let result=this._encodeValue(data,reporter,parent);if(result!==void 0&&!this._skipDefault(result,reporter,parent))return result},Node.prototype._encodeValue=function(data,reporter,parent){let state=this._baseState;if(state.parent===null)return state.children[0]._encode(data,reporter||new Reporter);let result=null;if(this.reporter=reporter,state.optional&&data===void 0)if(state.default!==null)data=state.default;else return;let content=null,primitive=!1;if(state.any)result=this._createEncoderBuffer(data);else if(state.choice)result=this._encodeChoice(data,reporter);else if(state.contains)content=this._getUse(state.contains,parent)._encode(data,reporter),primitive=!0;else if(state.children)content=state.children.map(function(child){if(child._baseState.tag===\"null_\")return child._encode(null,reporter,data);if(child._baseState.key===null)return reporter.error(\"Child should have a key\");let prevKey=reporter.enterKey(child._baseState.key);if(typeof data!=\"object\")return reporter.error(\"Child expected, but input is not object\");let res=child._encode(data[child._baseState.key],reporter,data);return reporter.leaveKey(prevKey),res},this).filter(function(child){return child}),content=this._createEncoderBuffer(content);else if(state.tag===\"seqof\"||state.tag===\"setof\"){if(!(state.args&&state.args.length===1))return reporter.error(\"Too many args for : \"+state.tag);if(!Array.isArray(data))return reporter.error(\"seqof/setof, but data is not Array\");let child=this.clone();child._baseState.implicit=null,content=this._createEncoderBuffer(data.map(function(item){let state2=this._baseState;return this._getUse(state2.args[0],data)._encode(item,reporter)},child))}else state.use!==null\?result=this._getUse(state.use,parent)._encode(data,reporter):(content=this._encodePrimitive(state.tag,data),primitive=!0);if(!state.any&&state.choice===null){let tag=state.implicit!==null\?state.implicit:state.tag,cls=state.implicit===null\?\"universal\":\"context\";tag===null\?state.use===null&&reporter.error(\"Tag could be omitted only for .use()\"):state.use===null&&(result=this._encodeComposite(tag,primitive,cls,content))}return state.explicit!==null&&(result=this._encodeComposite(state.explicit,!1,\"context\",result)),result},Node.prototype._encodeChoice=function(data,reporter){let state=this._baseState,node=state.choice[data.type];return node||assert(!1,data.type+\" not found in \"+JSON.stringify(Object.keys(state.choice))),node._encode(data.value,reporter)},Node.prototype._encodePrimitive=function(tag,data){let state=this._baseState;if(/str$/.test(tag))return this._encodeStr(data,tag);if(tag===\"objid\"&&state.args)return this._encodeObjid(data,state.reverseArgs[0],state.args[1]);if(tag===\"objid\")return this._encodeObjid(data,null,null);if(tag===\"gentime\"||tag===\"utctime\")return this._encodeTime(data,tag);if(tag===\"null_\")return this._encodeNull();if(tag===\"int\"||tag===\"enum\")return this._encodeInt(data,state.args&&state.reverseArgs[0]);if(tag===\"bool\")return this._encodeBool(data);if(tag===\"objDesc\")return this._encodeStr(data,tag);throw new Error(\"Unsupported tag: \"+tag)},Node.prototype._isNumstr=function(str){return/^[0-9 ]*$/.test(str)},Node.prototype._isPrintstr=function(str){return/^[A-Za-z0-9 '()+,-./:=\?]*$/.test(str)}}}),require_der=__commonJS({\"node_modules/asn1.js/lib/asn1/constants/der.js\"(exports){function reverse(map){let res={};return Object.keys(map).forEach(function(key){(key|0)==key&&(key=key|0);let value=map[key];res[value]=key}),res}exports.tagClass={0:\"universal\",1:\"application\",2:\"context\",3:\"private\"},exports.tagClassByName=reverse(exports.tagClass),exports.tag={0:\"end\",1:\"bool\",2:\"int\",3:\"bitstr\",4:\"octstr\",5:\"null_\",6:\"objid\",7:\"objDesc\",8:\"external\",9:\"real\",10:\"enum\",11:\"embed\",12:\"utf8str\",13:\"relativeOid\",16:\"seq\",17:\"set\",18:\"numstr\",19:\"printstr\",20:\"t61str\",21:\"videostr\",22:\"ia5str\",23:\"utctime\",24:\"gentime\",25:\"graphstr\",26:\"iso646str\",27:\"genstr\",28:\"unistr\",29:\"charstr\",30:\"bmpstr\"},exports.tagByName=reverse(exports.tag)}}),require_der2=__commonJS({\"node_modules/asn1.js/lib/asn1/encoders/der.js\"(exports,module){var inherits=require_inherits_browser(),Buffer2=require_safer().Buffer,Node=require_node(),der=require_der();function DEREncoder(entity){this.enc=\"der\",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}DEREncoder.prototype={},module.exports=DEREncoder,DEREncoder.prototype.encode=function(data,reporter){return this.tree._encode(data,reporter).join()};function DERNode(parent){Node.call(this,\"der\",parent)}inherits(DERNode,Node),DERNode.prototype._encodeComposite=function(tag,primitive,cls,content){let encodedTag=encodeTag(tag,primitive,cls,this.reporter);if(content.length<128){let header2=Buffer2.alloc(2);return header2[0]=encodedTag,header2[1]=content.length,this._createEncoderBuffer([header2,content])}let lenOctets=1;for(let i=content.length;i>=256;i>>=8)lenOctets++;let header=Buffer2.alloc(2+lenOctets);header[0]=encodedTag,header[1]=128|lenOctets;for(let i=1+lenOctets,j=content.length;j>0;i--,j>>=8)header[i]=j&255;return this._createEncoderBuffer([header,content])},DERNode.prototype._encodeStr=function(str,tag){if(tag===\"bitstr\")return this._createEncoderBuffer([str.unused|0,str.data]);if(tag===\"bmpstr\"){let buf=Buffer2.alloc(str.length*2);for(let i=0;i=40)return this.reporter.error(\"Second objid identifier OOB\");id.splice(0,2,id[0]*40+id[1])}let size=0;for(let i=0;i=128;ident>>=7)size++}let objid=Buffer2.alloc(size),offset=objid.length-1;for(let i=id.length-1;i>=0;i--){let ident=id[i];for(objid[offset--]=ident&127;(ident>>=7)>0;)objid[offset--]=128|ident&127}return this._createEncoderBuffer(objid)};function two(num){return num<10\?\"0\"+num:num}DERNode.prototype._encodeTime=function(time,tag){let str,date=new Date(time);return tag===\"gentime\"\?str=[two(date.getUTCFullYear()),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),\"Z\"].join(\"\"):tag===\"utctime\"\?str=[two(date.getUTCFullYear()%100),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),\"Z\"].join(\"\"):this.reporter.error(\"Encoding \"+tag+\" time is not supported yet\"),this._encodeStr(str,\"octstr\")},DERNode.prototype._encodeNull=function(){return this._createEncoderBuffer(\"\")},DERNode.prototype._encodeInt=function(num,values){if(typeof num==\"string\"){if(!values)return this.reporter.error(\"String int or enum given, but no values map\");if(!values.hasOwnProperty(num))return this.reporter.error(\"Values map doesn't contain: \"+JSON.stringify(num));num=values[num]}if(typeof num!=\"number\"&&!Buffer2.isBuffer(num)){let numArray=num.toArray();!num.sign&&numArray[0]&128&&numArray.unshift(0),num=Buffer2.from(numArray)}if(Buffer2.isBuffer(num)){let size2=num.length;num.length===0&&size2++;let out2=Buffer2.alloc(size2);return num.copy(out2),num.length===0&&(out2[0]=0),this._createEncoderBuffer(out2)}if(num<128)return this._createEncoderBuffer(num);if(num<256)return this._createEncoderBuffer([0,num]);let size=1;for(let i=num;i>=256;i>>=8)size++;let out=new Array(size);for(let i=out.length-1;i>=0;i--)out[i]=num&255,num>>=8;return out[0]&128&&out.unshift(0),this._createEncoderBuffer(Buffer2.from(out))},DERNode.prototype._encodeBool=function(value){return this._createEncoderBuffer(value\?255:0)},DERNode.prototype._use=function(entity,obj){return typeof entity==\"function\"&&(entity=entity(obj)),entity._getEncoder(\"der\").tree},DERNode.prototype._skipDefault=function(dataBuffer,reporter,parent){let state=this._baseState,i;if(state.default===null)return!1;let data=dataBuffer.join();if(state.defaultBuffer===void 0&&(state.defaultBuffer=this._encodeValue(state.default,reporter,parent).join()),data.length!==state.defaultBuffer.length)return!1;for(i=0;i=31\?reporter.error(\"Multi-octet tag encoding unsupported\"):(primitive||(res|=32),res|=der.tagClassByName[cls||\"universal\"]<<6,res)}}}),require_pem=__commonJS({\"node_modules/asn1.js/lib/asn1/encoders/pem.js\"(exports,module){var inherits=require_inherits_browser(),DEREncoder=require_der2();function PEMEncoder(entity){DEREncoder.call(this,entity),this.enc=\"pem\"}inherits(PEMEncoder,DEREncoder),module.exports=PEMEncoder,PEMEncoder.prototype.encode=function(data,options){let p=DEREncoder.prototype.encode.call(this,data).toString(\"base64\"),out=[\"-----BEGIN \"+options.label+\"-----\"];for(let i=0;i>6],primitive=(tag&32)===0;if((tag&31)===31){let oct=tag;for(tag=0;(oct&128)===128;){if(oct=buf.readUInt8(fail),buf.isError(oct))return oct;tag<<=7,tag|=oct&127}}else tag&=31;let tagStr=der.tag[tag];return{cls,primitive,tag,tagStr}}function derDecodeLen(buf,primitive,fail){let len=buf.readUInt8(fail);if(buf.isError(len))return len;if(!primitive&&len===128)return null;if((len&128)===0)return len;let num=len&127;if(num>4)return buf.error(\"length octect is too long\");len=0;for(let i=0;i0&&bits.ishrn(shift),bits}function bits2octets(bits,q){bits=bits2int(bits,q),bits=bits.mod(q);var out=Buffer2.from(bits.toArray());if(out.length=q)throw new Error(\"invalid sig\")}module.exports=verify}}),require_browser8=__commonJS({\"node_modules/browserify-sign/browser/index.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,createHash=require_browser2(),inherits=require_inherits_browser(),sign=require_sign(),verify=require_verify(),algorithms=require_algorithms();Object.keys(algorithms).forEach(function(key){algorithms[key].id=Buffer2.from(algorithms[key].id,\"hex\"),algorithms[key.toLowerCase()]=algorithms[key]});function Sign(algorithm){StreamModule.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error(\"Unknown message digest\");this._hashType=data.hash,this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Sign,StreamModule.Writable),Sign.prototype._write=function(data,_,done){this._hash.update(data),done()},Sign.prototype.update=function(data,enc){return typeof data==\"string\"&&(data=Buffer2.from(data,enc)),this._hash.update(data),this},Sign.prototype.sign=function(key,enc){this.end();var hash=this._hash.digest(),sig=sign(hash,key,this._hashType,this._signType,this._tag);return enc\?sig.toString(enc):sig};function Verify(algorithm){StreamModule.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error(\"Unknown message digest\");this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Verify,StreamModule.Writable),Verify.prototype._write=function(data,_,done){this._hash.update(data),done()},Verify.prototype.update=function(data,enc){return typeof data==\"string\"&&(data=Buffer2.from(data,enc)),this._hash.update(data),this},Verify.prototype.verify=function(key,sig,enc){typeof sig==\"string\"&&(sig=Buffer2.from(sig,enc)),this.end();var hash=this._hash.digest();return verify(sig,hash,key,this._signType,this._tag)};function createSign(algorithm){return new Sign(algorithm)}function createVerify(algorithm){return new Verify(algorithm)}module.exports={Sign:createSign,Verify:createVerify,createSign,createVerify}}}),require_bn6=require_bn,require_browser9=__commonJS({\"node_modules/create-ecdh/browser.js\"(exports,module){var elliptic=require_elliptic(),BN=require_bn6();module.exports=function(curve){return new ECDH(curve)};var aliases={secp256k1:{name:\"secp256k1\",byteLength:32},secp224r1:{name:\"p224\",byteLength:28},prime256v1:{name:\"p256\",byteLength:32},prime192v1:{name:\"p192\",byteLength:24},ed25519:{name:\"ed25519\",byteLength:32},secp384r1:{name:\"p384\",byteLength:48},secp521r1:{name:\"p521\",byteLength:66}};aliases.p224=aliases.secp224r1,aliases.p256=aliases.secp256r1=aliases.prime256v1,aliases.p192=aliases.secp192r1=aliases.prime192v1,aliases.p384=aliases.secp384r1,aliases.p521=aliases.secp521r1;function ECDH(curve){this.curveType=aliases[curve],this.curveType||(this.curveType={name:curve}),this.curve=new elliptic.ec(this.curveType.name),this.keys=void 0}ECDH.prototype={},ECDH.prototype.generateKeys=function(enc,format){return this.keys=this.curve.genKeyPair(),this.getPublicKey(enc,format)},ECDH.prototype.computeSecret=function(other,inenc,enc){inenc=inenc||\"utf8\",Buffer.isBuffer(other)||(other=new Buffer(other,inenc));var otherPub=this.curve.keyFromPublic(other).getPublic(),out=otherPub.mul(this.keys.getPrivate()).getX();return formatReturnValue(out,enc,this.curveType.byteLength)},ECDH.prototype.getPublicKey=function(enc,format){var key=this.keys.getPublic(format===\"compressed\",!0);return format===\"hybrid\"&&(key[key.length-1]%2\?key[0]=7:key[0]=6),formatReturnValue(key,enc)},ECDH.prototype.getPrivateKey=function(enc){return formatReturnValue(this.keys.getPrivate(),enc)},ECDH.prototype.setPublicKey=function(pub,enc){return enc=enc||\"utf8\",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this.keys._importPublic(pub),this},ECDH.prototype.setPrivateKey=function(priv,enc){enc=enc||\"utf8\",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc));var _priv=new BN(priv);return _priv=_priv.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(_priv),this};function formatReturnValue(bn,enc,len){Array.isArray(bn)||(bn=bn.toArray());var buf=new Buffer(bn);if(len&&buf.length=0)throw new Error(\"data too long for modulus\")}else throw new Error(\"unknown padding\");return reverse\?crt(paddedMsg,key):withPublic(paddedMsg,key)};function oaep(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash(\"sha1\").update(Buffer2.alloc(0)).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error(\"message too long\");var ps=Buffer2.alloc(k-mLen-hLen2-2),dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer2.concat([iHash,ps,Buffer2.alloc(1,1),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new BN(Buffer2.concat([Buffer2.alloc(1),maskedSeed,maskedDb],k))}function pkcs1(key,msg,reverse){var mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error(\"message too long\");var ps;return reverse\?ps=Buffer2.alloc(k-mLen-3,255):ps=nonZero(k-mLen-3),new BN(Buffer2.concat([Buffer2.from([0,reverse\?1:2]),ps,Buffer2.alloc(1),msg],k))}function nonZero(len){for(var out=Buffer2.allocUnsafe(len),i=0,cache=randomBytes(len*2),cur=0,num;ik||new BN(enc).cmp(key.modulus)>=0)throw new Error(\"decryption error\");var msg;reverse\?msg=withPublic(new BN(enc),key):msg=crt(enc,key);var zBuffer=Buffer2.alloc(k-msg.length);if(msg=Buffer2.concat([zBuffer,msg],k),padding===4)return oaep(key,msg);if(padding===1)return pkcs1(key,msg,reverse);if(padding===3)return msg;throw new Error(\"unknown padding\")};function oaep(key,msg){var k=key.modulus.byteLength(),iHash=createHash(\"sha1\").update(Buffer2.alloc(0)).digest(),hLen=iHash.length;if(msg[0]!==0)throw new Error(\"decryption error\");var maskedSeed=msg.slice(1,hLen+1),maskedDb=msg.slice(hLen+1),seed=xor(maskedSeed,mgf(maskedDb,hLen)),db=xor(maskedDb,mgf(seed,k-hLen-1));if(compare(iHash,db.slice(0,hLen)))throw new Error(\"decryption error\");for(var i=hLen;db[i]===0;)i++;if(db[i++]!==1)throw new Error(\"decryption error\");return db.slice(i)}function pkcs1(key,msg,reverse){for(var p1=msg.slice(0,2),i=2,status=0;msg[i++]!==0;)if(i>=msg.length){status++;break}var ps=msg.slice(2,i-1);if((p1.toString(\"hex\")!==\"0002\"&&!reverse||p1.toString(\"hex\")!==\"0001\"&&reverse)&&status++,ps.length<8&&status++,status)throw new Error(\"decryption error\");return msg.slice(i)}function compare(a,b){a=Buffer2.from(a),b=Buffer2.from(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=Math.min(a.length,b.length));for(var i=-1;++ikMaxUint32||offset<0)@throwTypeError(\"offset must be a uint32\");if(offset>kBufferMaxLength||offset>length)@throwRangeError(\"offset out of range\")}function assertSize(size,offset,length){if(typeof size!=\"number\"||size!==size)@throwTypeError(\"size must be a number\");if(size>kMaxUint32||size<0)@throwTypeError(\"size must be a uint32\");if(size+offset>length||size>kBufferMaxLength)@throwRangeError(\"buffer too small\")}exports.randomFill=randomFill,exports.randomFillSync=randomFillSync;function randomFill(buf,offset,size,cb){if(!Buffer2.isBuffer(buf)&&!(buf instanceof global.Uint8Array))@throwTypeError('\"buf\" argument must be a Buffer or Uint8Array');if(typeof offset==\"function\")cb=offset,offset=0,size=buf.length;else if(typeof size==\"function\")cb=size,size=buf.length-offset;else if(typeof cb!=\"function\")@throwTypeError('\"cb\" argument must be a function');return assertOffset(offset,buf.length),assertSize(size,offset,buf.length),actualFill(buf,offset,size,cb)}function actualFill(buf,offset,size,cb){if(cb){randombytes(size,function(err,bytes2){if(err)return cb(err);bytes2.copy(buf,offset),cb(null,buf)});return}var bytes=randombytes(size);return bytes.copy(buf,offset),buf}function randomFillSync(buf,offset,size){if(typeof offset>\"u\"&&(offset=0),!Buffer2.isBuffer(buf)&&!(buf instanceof global.Uint8Array))@throwTypeError('\"buf\" argument must be a Buffer or Uint8Array');return assertOffset(offset,buf.length),size===void 0&&(size=buf.length-offset),assertSize(size,offset,buf.length),actualFill(buf,offset,size)}}}),require_crypto_browserify2=__commonJS({\"node_modules/crypto-browserify/index.js\"(exports){exports.randomBytes=exports.rng=exports.pseudoRandomBytes=exports.prng=require_browser(),exports.createHash=require_browser2(),exports.Hash=exports.createHash.Hash,exports.createHmac=exports.Hmac=require_browser3();var algos=require_algos(),algoKeys=Object.keys(algos),hashes=[\"sha1\",\"sha224\",\"sha256\",\"sha384\",\"sha512\",\"md5\",\"rmd160\"].concat(algoKeys);exports.getHashes=function(){return hashes};var p=require_browser4();exports.pbkdf2=p.pbkdf2,exports.pbkdf2Sync=p.pbkdf2Sync;var aes=require_browser6();exports.Cipher=aes.Cipher,exports.createCipher=aes.createCipher,exports.Cipheriv=aes.Cipheriv,exports.createCipheriv=aes.createCipheriv,exports.Decipher=aes.Decipher,exports.createDecipher=aes.createDecipher,exports.Decipheriv=aes.Decipheriv,exports.createDecipheriv=aes.createDecipheriv,exports.getCiphers=aes.getCiphers,exports.listCiphers=aes.listCiphers;var dh=require_browser7();exports.DiffieHellmanGroup=dh.DiffieHellmanGroup,exports.createDiffieHellmanGroup=dh.createDiffieHellmanGroup,exports.getDiffieHellman=dh.getDiffieHellman,exports.createDiffieHellman=dh.createDiffieHellman,exports.DiffieHellman=dh.DiffieHellman;var sign=require_browser8();exports.createSign=sign.createSign,exports.Sign=sign.Sign,exports.createVerify=sign.createVerify,exports.Verify=sign.Verify,exports.createECDH=require_browser9();var publicEncrypt=require_browser10();exports.publicEncrypt=publicEncrypt.publicEncrypt,exports.privateEncrypt=publicEncrypt.privateEncrypt,exports.publicDecrypt=publicEncrypt.publicDecrypt,exports.privateDecrypt=publicEncrypt.privateDecrypt,exports.getRandomValues=(values)=>crypto.getRandomValues(values);var rf=require_browser11();exports.randomFill=rf.randomFill,exports.randomFillSync=rf.randomFillSync,exports.createCredentials=function(){throw new Error([\"sorry, createCredentials is not implemented yet\",\"we accept pull requests\",\"https://github.com/crypto-browserify/crypto-browserify\"].join(`\n`))},exports.constants=@processBindingConstants.crypto}}),crypto_exports=require_crypto_browserify2(),DEFAULT_ENCODING=\"buffer\",getRandomValues=(array)=>crypto.getRandomValues(array),randomUUID=()=>crypto.randomUUID(),randomInt=(...args)=>crypto.randomInt(...args),timingSafeEqual=\"timingSafeEqual\"in crypto\?(a,b)=>{let{byteLength:byteLengthA}=a,{byteLength:byteLengthB}=b;if(typeof byteLengthA!=\"number\"||typeof byteLengthB!=\"number\")@throwTypeError(\"Input must be an array buffer view\");if(byteLengthA!==byteLengthB)@throwRangeError(\"Input buffers must have the same length\");return crypto.timingSafeEqual(a,b)}:void 0,scryptSync=\"scryptSync\"in crypto\?(password,salt,keylen,options)=>{let res=crypto.scryptSync(password,salt,keylen,options);return DEFAULT_ENCODING!==\"buffer\"\?new Buffer(res).toString(DEFAULT_ENCODING):new Buffer(res)}:void 0,scrypt=\"scryptSync\"in crypto\?function(password,salt,keylen,options,callback){if(typeof options==\"function\"&&(callback=options,options=void 0),typeof callback!=\"function\"){var err=@makeTypeError(\"callback must be a function\");throw err.code=\"ERR_INVALID_CALLBACK\",err}try{let result=crypto.scryptSync(password,salt,keylen,options);process.nextTick(callback,null,DEFAULT_ENCODING!==\"buffer\"\?new Buffer(result).toString(DEFAULT_ENCODING):new Buffer(result))}catch(err2){throw err2}}:void 0;timingSafeEqual&&(Object.defineProperty(timingSafeEqual,\"name\",{value:\"::bunternal::\"}),Object.defineProperty(scrypt,\"name\",{value:\"::bunternal::\"}),Object.defineProperty(scryptSync,\"name\",{value:\"::bunternal::\"}));const harcoded_curves=[\"p192\",\"p224\",\"p256\",\"p384\",\"p521\",\"curve25519\",\"ed25519\",\"secp256k1\",\"secp224r1\",\"prime256v1\",\"prime192v1\",\"ed25519\",\"secp384r1\",\"secp521r1\"];function getCurves(){return harcoded_curves}var webcrypto=crypto;__export(crypto_exports,{DEFAULT_ENCODING:()=>DEFAULT_ENCODING,getRandomValues:()=>getRandomValues,randomUUID:()=>randomUUID,randomInt:()=>randomInt,getCurves:()=>getCurves,scrypt:()=>scrypt,scryptSync:()=>scryptSync,timingSafeEqual:()=>timingSafeEqual,webcrypto:()=>webcrypto,subtle:()=>webcrypto.subtle}),$=crypto_exports;/*! safe-buffer. MIT License. Feross Aboukhadijeh */return $})\n"_s; +// + +// static constexpr ASCIILiteral NodeDgramCode = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function createSocket(){throwNotImplemented(\"node:dgram createSocket\",1630)}function Socket(){throwNotImplemented(\"node:dgram Socket\",1630)}function _createSocketHandle(){throwNotImplemented(\"node:dgram _createSocketHandle\",1630)}return $={createSocket,Socket,_createSocketHandle},hideFromStack(createSocket,Socket,_createSocketHandle),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use strict\";const SafeMap=Map,SafeFinalizationRegistry=FinalizationRegistry,ArrayPrototypeAt=(array,index)=>array[index],ArrayPrototypeIndexOf=(array,value)=>array.indexOf(value),ArrayPrototypePush=(array,value)=>array.push(value),ArrayPrototypeSplice=(array,start,deleteCount)=>array.splice(start,deleteCount),ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectSetPrototypeOf=Object.setPrototypeOf,SymbolHasInstance=Symbol.hasInstance,ReflectApply=Reflect.apply,PromiseResolve=Promise.resolve,PromiseReject=Promise.reject,PromisePrototypeThen=(promise,onFulfilled,onRejected)=>promise.then(onFulfilled,onRejected);class WeakReference extends WeakRef{constructor(){super(...arguments)}#refs=0;get(){return this.deref()}incRef(){return++this.#refs}decRef(){return--this.#refs}}class WeakRefMap extends SafeMap{constructor(){super(...arguments)}#finalizers=new SafeFinalizationRegistry((key)=>{this.delete(key)});set(key,value){return this.#finalizers.register(value,key),super.set(key,new WeakReference(value))}get(key){return super.get(key)\?.get()}incRef(key){return super.get(key)\?.incRef()}decRef(key){return super.get(key)\?.decRef()}}function markActive(channel2){ObjectSetPrototypeOf(channel2,ActiveChannel.prototype),channel2._subscribers=[],channel2._stores=new SafeMap}function maybeMarkInactive(channel2){if(!channel2._subscribers.length&&!channel2._stores.size)ObjectSetPrototypeOf(channel2,Channel.prototype),channel2._subscribers=void 0,channel2._stores=void 0}function defaultTransform(data){return data}function wrapStoreRun(store,data,next,transform=defaultTransform){return()=>{let context;try{context=transform(data)}catch(err){return process.nextTick(()=>reportError(err)),next()}return store.run(context,next)}}class ActiveChannel{subscribe(subscription){validateFunction(subscription,\"subscription\"),ArrayPrototypePush(this._subscribers,subscription),channels.incRef(this.name)}unsubscribe(subscription){const index=ArrayPrototypeIndexOf(this._subscribers,subscription);if(index===-1)return!1;return ArrayPrototypeSplice(this._subscribers,index,1),channels.decRef(this.name),maybeMarkInactive(this),!0}bindStore(store,transform){if(!this._stores.has(store))channels.incRef(this.name);this._stores.set(store,transform)}unbindStore(store){if(!this._stores.has(store))return!1;return this._stores.delete(store),channels.decRef(this.name),maybeMarkInactive(this),!0}get hasSubscribers(){return!0}publish(data){for(let i=0;i<(this._subscribers\?.length||0);i++)try{const onMessage=this._subscribers[i];onMessage(data,this.name)}catch(err){process.nextTick(()=>reportError(err))}}runStores(data,fn,thisArg,...args){let run=()=>{return this.publish(data),ReflectApply(fn,thisArg,args)};for(let entry of this._stores.entries()){const store=entry[0],transform=entry[1];run=wrapStoreRun(store,data,run,transform)}return run()}}class Channel{constructor(name){this._subscribers=void 0,this._stores=void 0,this.name=name,channels.set(name,this)}static[SymbolHasInstance](instance){const prototype=ObjectGetPrototypeOf(instance);return prototype===Channel.prototype||prototype===ActiveChannel.prototype}subscribe(subscription){markActive(this),this.subscribe(subscription)}unsubscribe(){return!1}bindStore(store,transform){markActive(this),this.bindStore(store,transform)}unbindStore(){return!1}get hasSubscribers(){return!1}publish(){}runStores(data,fn,thisArg,...args){return ReflectApply(fn,thisArg,args)}}const channels=new WeakRefMap;function channel(name){const channel2=channels.get(name);if(channel2)return channel2;if(typeof name!==\"string\"&&typeof name!==\"symbol\")throw new ERR_INVALID_ARG_TYPE(\"channel\",[\"string\",\"symbol\"],name);return new Channel(name)}function subscribe(name,subscription){return channel(name).subscribe(subscription)}function unsubscribe(name,subscription){return channel(name).unsubscribe(subscription)}function hasSubscribers(name){const channel2=channels.get(name);if(!channel2)return!1;return channel2.hasSubscribers}const traceEvents=[\"start\",\"end\",\"asyncStart\",\"asyncEnd\",\"error\"];function assertChannel(value,name){if(!(value instanceof Channel))throw new ERR_INVALID_ARG_TYPE(name,[\"Channel\"],value)}class TracingChannel{constructor(nameOrChannels){if(typeof nameOrChannels===\"string\")this.start=channel(`tracing:${nameOrChannels}:start`),this.end=channel(`tracing:${nameOrChannels}:end`),this.asyncStart=channel(`tracing:${nameOrChannels}:asyncStart`),this.asyncEnd=channel(`tracing:${nameOrChannels}:asyncEnd`),this.error=channel(`tracing:${nameOrChannels}:error`);else if(typeof nameOrChannels===\"object\"){const{start,end,asyncStart,asyncEnd,error}=nameOrChannels;assertChannel(start,\"nameOrChannels.start\"),assertChannel(end,\"nameOrChannels.end\"),assertChannel(asyncStart,\"nameOrChannels.asyncStart\"),assertChannel(asyncEnd,\"nameOrChannels.asyncEnd\"),assertChannel(error,\"nameOrChannels.error\"),this.start=start,this.end=end,this.asyncStart=asyncStart,this.asyncEnd=asyncEnd,this.error=error}else throw new ERR_INVALID_ARG_TYPE(\"nameOrChannels\",[\"string\",\"object\",\"Channel\"],nameOrChannels)}subscribe(handlers){for(let name of traceEvents){if(!handlers[name])continue;this[name]\?.subscribe(handlers[name])}}unsubscribe(handlers){let done=!0;for(let name of traceEvents){if(!handlers[name])continue;if(!this[name]\?.unsubscribe(handlers[name]))done=!1}return done}traceSync(fn,context={},thisArg,...args){const{start,end,error}=this;return start.runStores(context,()=>{try{const result=ReflectApply(fn,thisArg,args);return context.result=result,result}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}tracePromise(fn,context={},thisArg,...args){const{start,end,asyncStart,asyncEnd,error}=this;function reject(err){return context.error=err,error.publish(context),asyncStart.publish(context),asyncEnd.publish(context),PromiseReject(err)}function resolve(result){return context.result=result,asyncStart.publish(context),asyncEnd.publish(context),result}return start.runStores(context,()=>{try{let promise=ReflectApply(fn,thisArg,args);if(!(promise instanceof Promise))promise=PromiseResolve(promise);return PromisePrototypeThen(promise,resolve,reject)}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}traceCallback(fn,position=-1,context={},thisArg,...args){const{start,end,asyncStart,asyncEnd,error}=this;function wrappedCallback(err,res){if(err)context.error=err,error.publish(context);else context.result=res;asyncStart.runStores(context,()=>{try{if(callback)return ReflectApply(callback,this,arguments)}finally{asyncEnd.publish(context)}})}const callback=ArrayPrototypeAt(args,position);if(typeof callback!==\"function\")throw new ERR_INVALID_ARG_TYPE(\"callback\",[\"function\"],callback);return ArrayPrototypeSplice(args,position,1,wrappedCallback),start.runStores(context,()=>{try{return ReflectApply(fn,thisArg,args)}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}}function tracingChannel(nameOrChannels){return new TracingChannel(nameOrChannels)}class ERR_INVALID_ARG_TYPE extends TypeError{constructor(name,expected,actual){super(`The ${name} argument must be of type ${expected}. Received type ${typeof actual}`);this.code=\"ERR_INVALID_ARG_TYPE\"}}function validateFunction(callable,field){if(typeof callable!==\"function\")throw new ERR_INVALID_ARG_TYPE(field,\"Function\",callable);return callable}return{channel,hasSubscribers,subscribe,tracingChannel,unsubscribe,Channel}})\n"_s; +// + +// static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises}})\n"_s; +// + +// static constexpr ASCIILiteral NodeDNSPromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,12)||@createInternalModuleById(12)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeDomainCode = "(function (){\"use strict\";var EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),domain={};return domain.createDomain=domain.create=function(){var d=new EventEmitter;function emitError(e){d.emit(\"error\",e)}return d.add=function(emitter){emitter.on(\"error\",emitError)},d.remove=function(emitter){emitter.removeListener(\"error\",emitError)},d.bind=function(fn){return function(){var args=Array.prototype.slice.call(arguments);try{fn.apply(null,args)}catch(err){emitError(err)}}},d.intercept=function(fn){return function(err){if(err)emitError(err);else{var args=Array.prototype.slice.call(arguments,1);try{fn.apply(null,args)}catch(err2){emitError(err2)}}}},d.run=function(fn){try{fn()}catch(err){emitError(err)}return this},d.dispose=function(){return this.removeAllListeners(),this},d.enter=d.exit=function(){return this},d},domain})\n"_s; +// + +// static constexpr ASCIILiteral NodeEventsCode = "(function (){\"use strict\";const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),SymbolFor=Symbol.for,kCapture=Symbol(\"kCapture\"),kErrorMonitor=SymbolFor(\"events.errorMonitor\"),kMaxEventTargetListeners=Symbol(\"events.maxEventTargetListeners\"),kMaxEventTargetListenersWarned=Symbol(\"events.maxEventTargetListenersWarned\"),kWatermarkData=SymbolFor(\"nodejs.watermarkData\"),kRejection=SymbolFor(\"nodejs.rejection\"),captureRejectionSymbol=SymbolFor(\"nodejs.rejection\"),ArrayPrototypeSlice=Array.prototype.slice;var defaultMaxListeners=10;const EventEmitter=function EventEmitter(opts){if(this._events===void 0||this._events===this.__proto__._events)this._events={__proto__:null},this._eventsCount=0;if(this._maxListeners\?\?=void 0,this[kCapture]=opts\?.captureRejections\?Boolean(opts\?.captureRejections):EventEmitterPrototype[kCapture])this.emit=emitWithRejectionCapture},EventEmitterPrototype=EventEmitter.prototype={};EventEmitterPrototype._events=void 0,EventEmitterPrototype._eventsCount=0,EventEmitterPrototype._maxListeners=void 0,EventEmitterPrototype.setMaxListeners=function setMaxListeners(n){return validateNumber(n,\"setMaxListeners\",0),this._maxListeners=n,this},EventEmitterPrototype.getMaxListeners=function getMaxListeners(){return this._maxListeners\?\?defaultMaxListeners};function emitError(emitter,args){var{_events:events}=emitter;if(args[0]\?\?=new Error(\"Unhandled error.\"),!events)throw args[0];var errorMonitor=events[kErrorMonitor];if(errorMonitor)for(var handler of ArrayPrototypeSlice.call(errorMonitor))handler.apply(emitter,args);var handlers=events.error;if(!handlers)throw args[0];for(var handler of ArrayPrototypeSlice.call(handlers))handler.apply(emitter,args);return!0}function addCatch(emitter,promise,type,args){promise.then(void 0,function(err){process.nextTick(emitUnhandledRejectionOrErr,emitter,err,type,args)})}function emitUnhandledRejectionOrErr(emitter,err,type,args){if(typeof emitter[kRejection]===\"function\")emitter[kRejection](err,type,...args);else try{emitter[kCapture]=!1,emitter.emit(\"error\",err)}finally{emitter[kCapture]=!0}}const emitWithoutRejectionCapture=function emit(type,...args){if(type===\"error\")return emitError(this,args);var{_events:events}=this;if(events===void 0)return!1;var handlers=events[type];if(handlers===void 0)return!1;for(var handler of[...handlers])handler.apply(this,args);return!0},emitWithRejectionCapture=function emit(type,...args){if(type===\"error\")return emitError(this,args);var{_events:events}=this;if(events===void 0)return!1;var handlers=events[type];if(handlers===void 0)return!1;for(var handler of[...handlers]){var result=handler.apply(this,args);if(result!==void 0&&@isPromise(result))addCatch(this,result,type,args)}return!0};EventEmitterPrototype.emit=emitWithoutRejectionCapture,EventEmitterPrototype.addListener=function addListener(type,fn){checkListener(fn);var events=this._events;if(!events)events=this._events={__proto__:null},this._eventsCount=0;else if(events.newListener)this.emit(\"newListener\",type,fn.listener\?\?fn);var handlers=events[type];if(!handlers)events[type]=[fn],this._eventsCount++;else{handlers.push(fn);var m=this._maxListeners\?\?defaultMaxListeners;if(m>0&&handlers.length>m&&!handlers.warned)overflowWarning(this,type,handlers)}return this},EventEmitterPrototype.on=EventEmitterPrototype.addListener,EventEmitterPrototype.prependListener=function prependListener(type,fn){checkListener(fn);var events=this._events;if(!events)events=this._events={__proto__:null},this._eventsCount=0;else if(events.newListener)this.emit(\"newListener\",type,fn.listener\?\?fn);var handlers=events[type];if(!handlers)events[type]=[fn],this._eventsCount++;else{handlers.unshift(fn);var m=this._maxListeners\?\?defaultMaxListeners;if(m>0&&handlers.length>m&&!handlers.warned)overflowWarning(this,type,handlers)}return this};function overflowWarning(emitter,type,handlers){handlers.warned=!0;const warn=new Error(`Possible EventEmitter memory leak detected. ${handlers.length} ${String(type)} listeners `+`added to [${emitter.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);warn.name=\"MaxListenersExceededWarning\",warn.emitter=emitter,warn.type=type,warn.count=handlers.length,process.emitWarning(warn)}function onceWrapper(type,listener,...args){this.removeListener(type,listener),listener.apply(this,args)}EventEmitterPrototype.once=function once(type,fn){checkListener(fn);const bound=onceWrapper.bind(this,type,fn);return bound.listener=fn,this.addListener(type,bound),this},EventEmitterPrototype.prependOnceListener=function prependOnceListener(type,fn){checkListener(fn);const bound=onceWrapper.bind(this,type,fn);return bound.listener=fn,this.prependListener(type,bound),this},EventEmitterPrototype.removeListener=function removeListener(type,fn){checkListener(fn);var{_events:events}=this;if(!events)return this;var handlers=events[type];if(!handlers)return this;var length=handlers.length;let position=-1;for(let i=length-1;i>=0;i--)if(handlers[i]===fn||handlers[i].listener===fn){position=i;break}if(position<0)return this;if(position===0)handlers.shift();else handlers.splice(position,1);if(handlers.length===0)delete events[type],this._eventsCount--;return this},EventEmitterPrototype.off=EventEmitterPrototype.removeListener,EventEmitterPrototype.removeAllListeners=function removeAllListeners(type){var{_events:events}=this;if(type&&events){if(events[type])delete events[type],this._eventsCount--}else this._events={__proto__:null};return this},EventEmitterPrototype.listeners=function listeners(type){var{_events:events}=this;if(!events)return[];var handlers=events[type];if(!handlers)return[];return handlers.map((x)=>x.listener\?\?x)},EventEmitterPrototype.rawListeners=function rawListeners(type){var{_events}=this;if(!_events)return[];var handlers=_events[type];if(!handlers)return[];return handlers.slice()},EventEmitterPrototype.listenerCount=function listenerCount(type){var{_events:events}=this;if(!events)return 0;return events[type]\?.length\?\?0},EventEmitterPrototype.eventNames=function eventNames(){return this._eventsCount>0\?Reflect.ownKeys(this._events):[]},EventEmitterPrototype[kCapture]=!1;function once(emitter,type,options){var signal=options\?.signal;if(validateAbortSignal(signal,\"options.signal\"),signal\?.aborted)throw new AbortError(void 0,{cause:signal\?.reason});return new Promise((resolve,reject)=>{const errorListener=(err)=>{if(emitter.removeListener(type,resolver),signal!=null)eventTargetAgnosticRemoveListener(signal,\"abort\",abortListener);reject(err)},resolver=(...args)=>{if(typeof emitter.removeListener===\"function\")emitter.removeListener(\"error\",errorListener);if(signal!=null)eventTargetAgnosticRemoveListener(signal,\"abort\",abortListener);resolve(args)};if(eventTargetAgnosticAddListener(emitter,type,resolver,{once:!0}),type!==\"error\"&&typeof emitter.once===\"function\")emitter.once(\"error\",errorListener);function abortListener(){eventTargetAgnosticRemoveListener(emitter,type,resolver),eventTargetAgnosticRemoveListener(emitter,\"error\",errorListener),reject(new AbortError(void 0,{cause:signal\?.reason}))}if(signal!=null)eventTargetAgnosticAddListener(signal,\"abort\",abortListener,{once:!0})})}function on(emitter,type,options){var{signal,close,highWatermark=Number.MAX_SAFE_INTEGER,lowWatermark=1}=options||{};throwNotImplemented(\"events.on\",2679)}function getEventListeners(emitter,type){if(emitter instanceof EventTarget)throwNotImplemented(\"getEventListeners with an EventTarget\",2678);return emitter.listeners(type)}function setMaxListeners(n,...eventTargets){validateNumber(n,\"setMaxListeners\",0);var length;if(eventTargets&&(length=eventTargets.length))for(let i=0;imax||(min!=null||max!=null)&&Number.isNaN(value))throw new ERR_OUT_OF_RANGE(name,`${min!=null\?`>= ${min}`:\"\"}${min!=null&&max!=null\?\" && \":\"\"}${max!=null\?`<= ${max}`:\"\"}`,value)}function checkListener(listener){if(typeof listener!==\"function\")@throwTypeError(\"The listener must be a function\")}let AsyncResource=null;class EventEmitterAsyncResource extends EventEmitter{triggerAsyncId;asyncResource;constructor(options){if(!AsyncResource)AsyncResource=(@getInternalField(@internalModuleRegistry,5)||@createInternalModuleById(5)).AsyncResource;var{captureRejections=!1,triggerAsyncId,name=new.target.name,requireManualDestroy}=options||{};super({captureRejections});this.triggerAsyncId=triggerAsyncId\?\?0,this.asyncResource=new AsyncResource(name,{triggerAsyncId,requireManualDestroy})}emit(...args){this.asyncResource.runInAsyncScope(()=>super.emit(...args))}emitDestroy(){this.asyncResource.emitDestroy()}}return Object.defineProperties(EventEmitter,{captureRejections:{get(){return EventEmitterPrototype[kCapture]},set(value){validateBoolean(value,\"EventEmitter.captureRejections\"),EventEmitterPrototype[kCapture]=value},enumerable:!0},defaultMaxListeners:{enumerable:!0,get:()=>{return defaultMaxListeners},set:(arg)=>{validateNumber(arg,\"defaultMaxListeners\",0),defaultMaxListeners=arg}},kMaxEventTargetListeners:{value:kMaxEventTargetListeners,enumerable:!1,configurable:!1,writable:!1},kMaxEventTargetListenersWarned:{value:kMaxEventTargetListenersWarned,enumerable:!1,configurable:!1,writable:!1}}),Object.assign(EventEmitter,{once,on,getEventListeners,setMaxListeners,EventEmitter,usingDomains:!1,captureRejectionSymbol,EventEmitterAsyncResource,errorMonitor:kErrorMonitor,setMaxListeners,init:EventEmitter,listenerCount}),EventEmitter})\n"_s; +// + +// static constexpr ASCIILiteral NodeFSCode = "(function (){\"use strict\";var $,ReadStream,WriteStream;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),promises=@getInternalField(@internalModuleRegistry,17)||@createInternalModuleById(17),Stream=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34);var fs=Bun.fs();class FSWatcher extends EventEmitter{#watcher;#listener;constructor(path,options,listener){super();if(typeof options===\"function\")listener=options,options={};else if(typeof options===\"string\")options={encoding:options};if(typeof listener!==\"function\")listener=()=>{};this.#listener=listener;try{this.#watcher=fs.watch(path,options||{},this.#onEvent.bind(this))}catch(e){if(!e.message\?.startsWith(\"FileNotFound\"))throw e;const notFound=new Error(`ENOENT: no such file or directory, watch '${path}'`);throw notFound.code=\"ENOENT\",notFound.errno=-2,notFound.path=path,notFound.syscall=\"watch\",notFound.filename=path,notFound}}#onEvent(eventType,filenameOrError){if(eventType===\"error\"||eventType===\"close\")this.emit(eventType,filenameOrError);else this.emit(\"change\",eventType,filenameOrError),this.#listener(eventType,filenameOrError)}close(){this.#watcher\?.close(),this.#watcher=null}ref(){this.#watcher\?.ref()}unref(){this.#watcher\?.unref()}}var access=function access(...args){callbackify(fs.accessSync,args)},appendFile=function appendFile(...args){callbackify(fs.appendFileSync,args)},close=function close(...args){callbackify(fs.closeSync,args)},rm=function rm(...args){callbackify(fs.rmSync,args)},rmdir=function rmdir(...args){callbackify(fs.rmdirSync,args)},copyFile=function copyFile(...args){callbackify(fs.copyFileSync,args)},exists=function exists(...args){callbackify(fs.existsSync,args)},chown=function chown(...args){callbackify(fs.chownSync,args)},chmod=function chmod(...args){callbackify(fs.chmodSync,args)},fchmod=function fchmod(...args){callbackify(fs.fchmodSync,args)},fchown=function fchown(...args){callbackify(fs.fchownSync,args)},fstat=function fstat(...args){callbackify(fs.fstatSync,args)},fsync=function fsync(...args){callbackify(fs.fsyncSync,args)},ftruncate=function ftruncate(...args){callbackify(fs.ftruncateSync,args)},futimes=function futimes(...args){callbackify(fs.futimesSync,args)},lchmod=function lchmod(...args){callbackify(fs.lchmodSync,args)},lchown=function lchown(...args){callbackify(fs.lchownSync,args)},link=function link(...args){callbackify(fs.linkSync,args)},mkdir=function mkdir(...args){callbackify(fs.mkdirSync,args)},mkdtemp=function mkdtemp(...args){callbackify(fs.mkdtempSync,args)},open=function open(...args){callbackify(fs.openSync,args)},read=function read(...args){callbackify(fs.readSync,args)},write=function write(...args){callbackify(fs.writeSync,args)},readdir=function readdir(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.readdir(...args).then((result)=>callback(null,result),callback)},readFile=function readFile(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.readFile(...args).then((result)=>callback(null,result),callback)},writeFile=function writeFile(...args){callbackify(fs.writeFileSync,args)},readlink=function readlink(...args){callbackify(fs.readlinkSync,args)},realpath=function realpath(...args){callbackify(fs.realpathSync,args)},rename=function rename(...args){callbackify(fs.renameSync,args)},lstat=function lstat(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.lstat(...args).then((result)=>callback(null,result),callback)},stat=function stat(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.stat(...args).then((result)=>callback(null,result),callback)},symlink=function symlink(...args){callbackify(fs.symlinkSync,args)},truncate=function truncate(...args){callbackify(fs.truncateSync,args)},unlink=function unlink(...args){callbackify(fs.unlinkSync,args)},utimes=function utimes(...args){callbackify(fs.utimesSync,args)},lutimes=function lutimes(...args){callbackify(fs.lutimesSync,args)},accessSync=fs.accessSync.bind(fs),appendFileSync=fs.appendFileSync.bind(fs),closeSync=fs.closeSync.bind(fs),copyFileSync=fs.copyFileSync.bind(fs),existsSync=fs.existsSync.bind(fs),chownSync=fs.chownSync.bind(fs),chmodSync=fs.chmodSync.bind(fs),fchmodSync=fs.fchmodSync.bind(fs),fchownSync=fs.fchownSync.bind(fs),fstatSync=fs.fstatSync.bind(fs),fsyncSync=fs.fsyncSync.bind(fs),ftruncateSync=fs.ftruncateSync.bind(fs),futimesSync=fs.futimesSync.bind(fs),lchmodSync=fs.lchmodSync.bind(fs),lchownSync=fs.lchownSync.bind(fs),linkSync=fs.linkSync.bind(fs),lstatSync=fs.lstatSync.bind(fs),mkdirSync=fs.mkdirSync.bind(fs),mkdtempSync=fs.mkdtempSync.bind(fs),openSync=fs.openSync.bind(fs),readSync=fs.readSync.bind(fs),writeSync=fs.writeSync.bind(fs),readdirSync=fs.readdirSync.bind(fs),readFileSync=fs.readFileSync.bind(fs),writeFileSync=fs.writeFileSync.bind(fs),readlinkSync=fs.readlinkSync.bind(fs),realpathSync=fs.realpathSync.bind(fs),renameSync=fs.renameSync.bind(fs),statSync=fs.statSync.bind(fs),symlinkSync=fs.symlinkSync.bind(fs),truncateSync=fs.truncateSync.bind(fs),unlinkSync=fs.unlinkSync.bind(fs),utimesSync=fs.utimesSync.bind(fs),lutimesSync=fs.lutimesSync.bind(fs),rmSync=fs.rmSync.bind(fs),rmdirSync=fs.rmdirSync.bind(fs),writev=(fd,buffers,position,callback)=>{if(typeof position===\"function\")callback=position,position=null;queueMicrotask(()=>{try{var written=fs.writevSync(fd,buffers,position)}catch(e){callback(e)}callback(null,written,buffers)})},writevSync=fs.writevSync.bind(fs),readv=(fd,buffers,position,callback)=>{if(typeof position===\"function\")callback=position,position=null;queueMicrotask(()=>{try{var written=fs.readvSync(fd,buffers,position)}catch(e){callback(e)}callback(null,written,buffers)})},readvSync=fs.readvSync.bind(fs),Dirent=fs.Dirent,Stats=fs.Stats,watch=function watch(path,options,listener){return new FSWatcher(path,options,listener)};function callbackify(fsFunction,args){try{const result=fsFunction.apply(fs,args.slice(0,args.length-1)),callback=args[args.length-1];if(typeof callback===\"function\")queueMicrotask(()=>callback(null,result))}catch(e){const callback=args[args.length-1];if(typeof callback===\"function\")queueMicrotask(()=>callback(e))}}var readStreamPathFastPathSymbol=Symbol.for(\"Bun.Node.readStreamPathFastPath\");const readStreamSymbol=Symbol.for(\"Bun.NodeReadStream\"),readStreamPathOrFdSymbol=Symbol.for(\"Bun.NodeReadStreamPathOrFd\"),writeStreamSymbol=Symbol.for(\"Bun.NodeWriteStream\");var writeStreamPathFastPathSymbol=Symbol.for(\"Bun.NodeWriteStreamFastPath\"),writeStreamPathFastPathCallSymbol=Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"),kIoDone=Symbol.for(\"kIoDone\"),defaultReadStreamOptions={file:void 0,fd:void 0,flags:\"r\",encoding:void 0,mode:438,autoClose:!0,emitClose:!0,start:0,end:Infinity,highWaterMark:65536,fs:{read,open:(path,flags,mode,cb)=>{var fd;try{fd=openSync(path,flags,mode)}catch(e){cb(e);return}cb(null,fd)},openSync,close},autoDestroy:!0},ReadStreamClass;ReadStream=function(InternalReadStream){ReadStreamClass=InternalReadStream,Object.defineProperty(ReadStreamClass.prototype,Symbol.toStringTag,{value:\"ReadStream\",enumerable:!1});function ReadStream2(path,options){return new InternalReadStream(path,options)}return ReadStream2.prototype=InternalReadStream.prototype,Object.defineProperty(ReadStream2,Symbol.hasInstance,{value(instance){return instance instanceof InternalReadStream}})}(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2,Stream.Readable){constructor(pathOrFd,options=defaultReadStreamOptions){if(typeof options!==\"object\"||!options)@throwTypeError(\"Expected options to be an object\");var{flags=defaultReadStreamOptions.flags,encoding=defaultReadStreamOptions.encoding,mode=defaultReadStreamOptions.mode,autoClose=defaultReadStreamOptions.autoClose,emitClose=defaultReadStreamOptions.emitClose,start=defaultReadStreamOptions.start,end=defaultReadStreamOptions.end,autoDestroy=defaultReadStreamOptions.autoClose,fs:fs2=defaultReadStreamOptions.fs,highWaterMark=defaultReadStreamOptions.highWaterMark}=options;if(pathOrFd\?.constructor\?.name===\"URL\")pathOrFd=Bun.fileURLToPath(pathOrFd);var tempThis={};if(typeof pathOrFd===\"string\"){if(pathOrFd.startsWith(\"file://\"))pathOrFd=Bun.fileURLToPath(pathOrFd);if(pathOrFd.length===0)@throwTypeError(\"Expected path to be a non-empty string\");tempThis.path=tempThis.file=tempThis[readStreamPathOrFdSymbol]=pathOrFd}else if(typeof pathOrFd===\"number\"){if(pathOrFd|=0,pathOrFd<0)@throwTypeError(\"Expected fd to be a positive integer\");tempThis.fd=tempThis[readStreamPathOrFdSymbol]=pathOrFd,tempThis.autoClose=!1}else @throwTypeError(\"Expected a path or file descriptor\");if(!tempThis.fd)tempThis.fd=fs2.openSync(pathOrFd,flags,mode);var fileRef=Bun.file(tempThis.fd),stream=fileRef.stream(),native=@direct(stream);if(!native)throw new Error(\"no native readable stream\");var{stream:ptr}=native;super(ptr,{...options,encoding,autoDestroy,autoClose,emitClose,highWaterMark});if(Object.assign(this,tempThis),this.#fileRef=fileRef,this.end=end,this._read=this.#internalRead,this.start=start,this.flags=flags,this.mode=mode,this.emitClose=emitClose,this[readStreamPathFastPathSymbol]=start===0&&end===Infinity&&autoClose&&fs2===defaultReadStreamOptions.fs&&(encoding===\"buffer\"||encoding===\"binary\"||encoding==null||encoding===\"utf-8\"||encoding===\"utf8\"),this._readableState.autoClose=autoDestroy=autoClose,this._readableState.highWaterMark=highWaterMark,start!==void 0)this.pos=start}#fileRef;#fs;file;path;fd=null;flags;mode;start;end;pos;bytesRead=0;#fileSize=-1;_read;[readStreamSymbol]=!0;[readStreamPathOrFdSymbol];[readStreamPathFastPathSymbol];_construct(callback){if(super._construct)super._construct(callback);else callback();this.emit(\"open\",this.fd),this.emit(\"ready\")}_destroy(err,cb){super._destroy(err,cb);try{var fd=this.fd;if(this[readStreamPathFastPathSymbol]=!1,!fd)cb(err);else this.#fs.close(fd,(er)=>{cb(er||err)}),this.fd=null}catch(e){throw e}}close(cb){if(typeof cb===\"function\")eos_()(this,cb);this.destroy()}push(chunk){var bytesRead=chunk\?.length\?\?0;if(bytesRead>0){this.bytesRead+=bytesRead;var currPos=this.pos;if(currPos!==void 0){if(this.bytesReadthis.end)chunk=chunk.slice(0,this.end-this.start+1);return super.push(chunk,...rest)}var end=this.end;if(end!==void 0&&this.bytesRead>end){chunk=chunk.slice(0,end-currPos+1);var[_,...rest]=arguments;return this.pos=this.bytesRead,super.push(chunk,...rest)}this.pos=this.bytesRead}}return super.push(...arguments)}#internalRead(n){var{pos,end,bytesRead,fd,encoding}=this;if(n=pos!==void 0\?Math.min(end-pos+1,n):Math.min(end-bytesRead+1,n),n<=0){this.push(null);return}if(this.#fileSize===-1&&bytesRead===0&&pos===void 0){var stat2=fstatSync(fd);if(this.#fileSize=stat2.size,this.#fileSize>0&&n>this.#fileSize)n=this.#fileSize+1}this[kIoDone]=!1;var res=super._read(n);if(@isPromise(res)){var then=res\?.then;if(then&&@isCallable(then))then(()=>{if(this[kIoDone]=!0,this.destroyed)this.emit(kIoDone)},(er)=>{this[kIoDone]=!0,this.#errorOrDestroy(er)})}else if(this[kIoDone]=!0,this.destroyed)this.emit(kIoDone),this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"))}#errorOrDestroy(err,sync=null){var{_readableState:r={destroyed:!1,autoDestroy:!1},_writableState:w={destroyed:!1,autoDestroy:!1}}=this;if(w\?.destroyed||r\?.destroyed)return this;if(r\?.autoDestroy||w\?.autoDestroy)this.destroy(err);else if(err)this.emit(\"error\",err)}pause(){return this[readStreamPathFastPathSymbol]=!1,super.pause()}resume(){return this[readStreamPathFastPathSymbol]=!1,super.resume()}unshift(...args){return this[readStreamPathFastPathSymbol]=!1,super.unshift(...args)}pipe(dest,pipeOpts){if(this[readStreamPathFastPathSymbol]&&(pipeOpts\?.end\?\?!0)&&this._readableState\?.pipes\?.length===0){if((writeStreamPathFastPathSymbol in dest)&&dest[writeStreamPathFastPathSymbol]){if(dest[writeStreamPathFastPathCallSymbol](this,pipeOpts))return this}}return this[readStreamPathFastPathSymbol]=!1,super.pipe(dest,pipeOpts)}});function createReadStream(path,options){return new ReadStream(path,options)}var defaultWriteStreamOptions={fd:null,start:void 0,pos:void 0,encoding:void 0,flags:\"w\",mode:438,fs:{write,close,open,openSync}},WriteStreamClass;WriteStream=function(InternalWriteStream){WriteStreamClass=InternalWriteStream,Object.defineProperty(WriteStreamClass.prototype,Symbol.toStringTag,{value:\"WritesStream\",enumerable:!1});function WriteStream2(path,options){return new InternalWriteStream(path,options)}return WriteStream2.prototype=InternalWriteStream.prototype,Object.defineProperty(WriteStream2,Symbol.hasInstance,{value(instance){return instance instanceof InternalWriteStream}})}(class WriteStream2 extends Stream.NativeWritable{constructor(path,options=defaultWriteStreamOptions){if(!options)@throwTypeError(\"Expected options to be an object\");var{fs:fs2=defaultWriteStreamOptions.fs,start=defaultWriteStreamOptions.start,flags=defaultWriteStreamOptions.flags,mode=defaultWriteStreamOptions.mode,autoClose=!0,emitClose=!1,autoDestroy=autoClose,encoding=defaultWriteStreamOptions.encoding,fd=defaultWriteStreamOptions.fd,pos=defaultWriteStreamOptions.pos}=options,tempThis={};if(typeof path===\"string\"){if(path.length===0)@throwTypeError(\"Expected a non-empty path\");if(path.startsWith(\"file:\"))path=Bun.fileURLToPath(path);tempThis.path=path,tempThis.fd=null,tempThis[writeStreamPathFastPathSymbol]=autoClose&&(start===void 0||start===0)&&fs2.write===defaultWriteStreamOptions.fs.write&&fs2.close===defaultWriteStreamOptions.fs.close}else tempThis.fd=fd,tempThis[writeStreamPathFastPathSymbol]=!1;if(!tempThis.fd)tempThis.fd=fs2.openSync(path,flags,mode);super(tempThis.fd,{...options,decodeStrings:!1,autoDestroy,emitClose,fd:tempThis});if(Object.assign(this,tempThis),typeof fs2\?.write!==\"function\")@throwTypeError(\"Expected fs.write to be a function\");if(typeof fs2\?.close!==\"function\")@throwTypeError(\"Expected fs.close to be a function\");if(typeof fs2\?.open!==\"function\")@throwTypeError(\"Expected fs.open to be a function\");if(typeof path===\"object\"&&path){if(path instanceof URL)path=Bun.fileURLToPath(path)}if(typeof path!==\"string\"&&typeof fd!==\"number\")@throwTypeError(\"Expected a path or file descriptor\");if(this.start=start,this.#fs=fs2,this.flags=flags,this.mode=mode,this.start!==void 0)this.pos=this.start;if(encoding!==defaultWriteStreamOptions.encoding){if(this.setDefaultEncoding(encoding),encoding!==\"buffer\"&&encoding!==\"utf8\"&&encoding!==\"utf-8\"&&encoding!==\"binary\")this[writeStreamPathFastPathSymbol]=!1}}get autoClose(){return this._writableState.autoDestroy}set autoClose(val){this._writableState.autoDestroy=val}destroySoon=this.end;open(){}path;fd;flags;mode;#fs;bytesWritten=0;pos;[writeStreamPathFastPathSymbol];[writeStreamSymbol]=!0;start;[writeStreamPathFastPathCallSymbol](readStream,pipeOpts){if(!this[writeStreamPathFastPathSymbol])return!1;if(this.fd!==null)return this[writeStreamPathFastPathSymbol]=!1,!1;return this[kIoDone]=!1,readStream[kIoDone]=!1,Bun.write(this[writeStreamPathFastPathSymbol],readStream[readStreamPathOrFdSymbol]).then((bytesWritten)=>{readStream[kIoDone]=this[kIoDone]=!0,this.bytesWritten+=bytesWritten,readStream.bytesRead+=bytesWritten,this.end(),readStream.close()},(err)=>{readStream[kIoDone]=this[kIoDone]=!0,this.#errorOrDestroy(err),readStream.emit(\"error\",err)})}isBunFastPathEnabled(){return this[writeStreamPathFastPathSymbol]}disableBunFastPath(){this[writeStreamPathFastPathSymbol]=!1}#handleWrite(er,bytes){if(er)return this.#errorOrDestroy(er);this.bytesWritten+=bytes}#internalClose(err,cb){this[writeStreamPathFastPathSymbol]=!1;var fd=this.fd;this.#fs.close(fd,(er)=>{this.fd=null,cb(err||er)})}_construct(callback){if(typeof this.fd===\"number\"){callback();return}callback(),this.emit(\"open\",this.fd),this.emit(\"ready\")}_destroy(err,cb){if(this.fd===null)return cb(err);if(this[kIoDone]){this.once(kIoDone,()=>this.#internalClose(err,cb));return}this.#internalClose(err,cb)}[kIoDone]=!1;close(cb){if(cb){if(this.closed){process.nextTick(cb);return}this.on(\"close\",cb)}if(!this.autoClose)this.on(\"finish\",this.destroy);this.end()}write(chunk,encoding=this._writableState.defaultEncoding,cb){if(this[writeStreamPathFastPathSymbol]=!1,typeof chunk===\"string\")chunk=Buffer.from(chunk,encoding);var native=this.pos===void 0;return this[kIoDone]=!0,super.write(chunk,encoding,native\?(err,bytes)=>{if(this[kIoDone]=!1,this.#handleWrite(err,bytes),this.emit(kIoDone),cb)!err\?cb():cb(err)}:()=>{},native)}#internalWriteSlow(chunk,encoding,cb){this.#fs.write(this.fd,chunk,0,chunk.length,this.pos,(err,bytes)=>{this[kIoDone]=!1,this.#handleWrite(err,bytes),this.emit(kIoDone),!err\?cb():cb(err)})}end(chunk,encoding,cb){var native=this.pos===void 0;return super.end(chunk,encoding,cb,native)}_write=this.#internalWriteSlow;_writev=void 0;get pending(){return this.fd===null}_destroy(err,cb){this.close(err,cb)}#errorOrDestroy(err){var{_readableState:r={destroyed:!1,autoDestroy:!1},_writableState:w={destroyed:!1,autoDestroy:!1}}=this;if(w\?.destroyed||r\?.destroyed)return this;if(r\?.autoDestroy||w\?.autoDestroy)this.destroy(err);else if(err)this.emit(\"error\",err)}});function createWriteStream(path,options){return new WriteStream(path,options)}return Object.defineProperties(fs,{createReadStream:{value:createReadStream},createWriteStream:{value:createWriteStream},ReadStream:{value:ReadStream},WriteStream:{value:WriteStream}}),realpath.native=realpath,realpathSync.native=realpathSync,$={access,accessSync,appendFile,appendFileSync,chmod,chmodSync,chown,chownSync,close,closeSync,constants:promises.constants,copyFile,copyFileSync,createReadStream,createWriteStream,Dirent,exists,existsSync,fchmod,fchmodSync,fchown,fchownSync,fstat,fstatSync,fsync,fsyncSync,ftruncate,ftruncateSync,futimes,futimesSync,lchmod,lchmodSync,lchown,lchownSync,link,linkSync,lstat,lstatSync,lutimes,lutimesSync,mkdir,mkdirSync,mkdtemp,mkdtempSync,open,openSync,promises,read,readFile,readFileSync,readSync,readdir,readdirSync,readlink,readlinkSync,realpath,realpathSync,rename,renameSync,rm,rmSync,rmdir,rmdirSync,stat,statSync,Stats,symlink,symlinkSync,truncate,truncateSync,unlink,unlinkSync,utimes,utimesSync,write,writeFile,writeFileSync,writeSync,WriteStream,ReadStream,watch,FSWatcher,writev,writevSync,readv,readvSync,[Symbol.for(\"::bunternal::\")]:{ReadStreamClass,WriteStreamClass}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeFSPromisesCode = "(function (){\"use strict\";var $;const constants=@processBindingConstants.fs;var fs=Bun.fs();const notrace=\"::bunternal::\";var promisify={[notrace]:(fsFunction)=>{return async function(...args){return await 1,fsFunction.apply(fs,args)}}}[notrace];function watch(filename,options={}){if(filename instanceof URL)@throwTypeError(\"Watch URLs are not supported yet\");else if(Buffer.isBuffer(filename))filename=filename.toString();else if(typeof filename!==\"string\")@throwTypeError(\"Expected path to be a string or Buffer\");let nextEventResolve=null;if(typeof options===\"string\")options={encoding:options};const queue=@createFIFO(),watcher=fs.watch(filename,options||{},(eventType,filename2)=>{if(queue.push({eventType,filename:filename2}),nextEventResolve){const resolve=nextEventResolve;nextEventResolve=null,resolve()}});return{[Symbol.asyncIterator](){let closed=!1;return{async next(){while(!closed){let event;while(event=queue.shift()){if(event.eventType===\"close\")return closed=!0,{value:void 0,done:!0};if(event.eventType===\"error\")throw closed=!0,event.filename;return{value:event,done:!1}}const{promise,resolve}=Promise.withResolvers();nextEventResolve=resolve,await promise}return{value:void 0,done:!0}},return(){if(!closed){if(watcher.close(),closed=!0,nextEventResolve){const resolve=nextEventResolve;nextEventResolve=null,resolve()}}return{value:void 0,done:!0}}}}}}return $={access:promisify(fs.accessSync),appendFile:promisify(fs.appendFileSync),close:promisify(fs.closeSync),copyFile:promisify(fs.copyFileSync),exists:promisify(fs.existsSync),chown:promisify(fs.chownSync),chmod:promisify(fs.chmodSync),fchmod:promisify(fs.fchmodSync),fchown:promisify(fs.fchownSync),fstat:promisify(fs.fstatSync),fsync:promisify(fs.fsyncSync),ftruncate:promisify(fs.ftruncateSync),futimes:promisify(fs.futimesSync),lchmod:promisify(fs.lchmodSync),lchown:promisify(fs.lchownSync),link:promisify(fs.linkSync),lstat:fs.lstat.bind(fs),mkdir:promisify(fs.mkdirSync),mkdtemp:promisify(fs.mkdtempSync),open:promisify(fs.openSync),read:promisify(fs.readSync),write:promisify(fs.writeSync),readdir:fs.readdir.bind(fs),readFile:fs.readFile.bind(fs),writeFile:promisify(fs.writeFileSync),readlink:promisify(fs.readlinkSync),realpath:promisify(fs.realpathSync),rename:promisify(fs.renameSync),stat:fs.stat.bind(fs),symlink:promisify(fs.symlinkSync),truncate:promisify(fs.truncateSync),unlink:promisify(fs.unlinkSync),utimes:promisify(fs.utimesSync),lutimes:promisify(fs.lutimesSync),rm:promisify(fs.rmSync),rmdir:promisify(fs.rmdirSync),writev:(fd,buffers,position)=>{return new Promise((resolve,reject)=>{try{var bytesWritten=fs.writevSync(fd,buffers,position)}catch(err){reject(err);return}resolve({bytesWritten,buffers})})},readv:(fd,buffers,position)=>{return new Promise((resolve,reject)=>{try{var bytesRead=fs.readvSync(fd,buffers,position)}catch(err){reject(err);return}resolve({bytesRead,buffers})})},constants,watch},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttpCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{isTypedArray}=@requireNativeModule(\"node:util/types\"),{Duplex,Readable,Writable}=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),headerCharRegex=/[^\\t\\x20-\\x7e\\x80-\\xff]/;function checkInvalidHeaderChar(val){return RegExpPrototypeExec.call(headerCharRegex,val)!==null}const validateHeaderName=(name,label)=>{if(typeof name!==\"string\"||!name||!checkIsHttpToken(name))throw new Error(\"ERR_INVALID_HTTP_TOKEN\")},validateHeaderValue=(name,value)=>{if(value===void 0)throw new Error(\"ERR_HTTP_INVALID_HEADER_VALUE\");if(checkInvalidHeaderChar(value))throw new Error(\"ERR_INVALID_CHAR\")};function isIPv6(input){return new RegExp(\"^((\?:(\?:[0-9a-fA-F]{1,4}):){7}(\?:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){6}(\?:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){5}(\?::((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,2}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){4}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,1}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,3}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){3}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,2}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,4}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){2}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,3}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,5}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){1}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,4}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,6}|:)|(\?::((\?::(\?:[0-9a-fA-F]{1,4})){0,5}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(\?::(\?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})\?$\").test(input)}const{URL}=globalThis,globalReportError=globalThis.reportError,setTimeout=globalThis.setTimeout,fetch=Bun.fetch,nop=()=>{},kEmptyObject=Object.freeze(Object.create(null)),kOutHeaders=Symbol.for(\"kOutHeaders\"),kEndCalled=Symbol.for(\"kEndCalled\"),kAbortController=Symbol.for(\"kAbortController\"),kClearTimeout=Symbol(\"kClearTimeout\"),kCorked=Symbol.for(\"kCorked\"),searchParamsSymbol=Symbol.for(\"query\"),StringPrototypeSlice=String.prototype.slice,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeToUpperCase=String.prototype.toUpperCase,StringPrototypeIncludes=String.prototype.includes,StringPrototypeCharCodeAt=String.prototype.charCodeAt,StringPrototypeIndexOf=String.prototype.indexOf,ArrayIsArray=Array.isArray,RegExpPrototypeExec=RegExp.prototype.exec,ObjectAssign=Object.assign,ObjectPrototypeHasOwnProperty=Object.prototype.hasOwnProperty,INVALID_PATH_REGEX=/[^\\u0021-\\u00ff]/,NODE_HTTP_WARNING=\"WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\";var _defaultHTTPSAgent,kInternalRequest=Symbol(\"kInternalRequest\"),kInternalSocketData=Symbol.for(\"::bunternal::\");const kEmptyBuffer=Buffer.alloc(0);function isValidTLSArray(obj){if(typeof obj===\"string\"||isTypedArray(obj)||obj instanceof ArrayBuffer||obj instanceof Blob)return!0;if(Array.isArray(obj)){for(var i=0;i{this.close()}),host=port\?.host,port=port\?.port,typeof port\?.callback===\"function\")onListen=port\?.callback}if(typeof backlog===\"function\")onListen=backlog;const ResponseClass=this.#options.ServerResponse||ServerResponse,RequestClass=this.#options.IncomingMessage||IncomingMessage;try{const tls=this.#tls;if(tls)this.serverName=tls.serverName||host||\"localhost\";this.#server=Bun.serve({tls,port,hostname:host,websocket:{open(ws){ws.data.open(ws)},message(ws,message){ws.data.message(ws,message)},close(ws,code,reason){ws.data.close(ws,code,reason)},drain(ws){ws.data.drain(ws)}},fetch(req,_server){var pendingResponse,pendingError,rejectFunction,resolveFunction,reject=(err)=>{if(pendingError)return;if(pendingError=err,rejectFunction)rejectFunction(err)},reply=function(resp){if(pendingResponse)return;if(pendingResponse=resp,resolveFunction)resolveFunction(resp)};const http_req=new RequestClass(req),http_res=new ResponseClass({reply,req:http_req});if(http_req.once(\"error\",(err)=>reject(err)),http_res.once(\"error\",(err)=>reject(err)),req.headers.get(\"upgrade\")){const socket=new FakeSocket;socket[kInternalSocketData]=[_server,http_res,req],server.emit(\"upgrade\",http_req,socket,kEmptyBuffer)}else server.emit(\"request\",http_req,http_res);if(pendingError)throw pendingError;if(pendingResponse)return pendingResponse;return new Promise((resolve,reject2)=>{resolveFunction=resolve,rejectFunction=reject2})}}),setTimeout(emitListeningNextTick,1,this,onListen,null,this.#server.hostname,this.#server.port)}catch(err){setTimeout(emitListeningNextTick,1,this,onListen,err)}return this}setTimeout(msecs,callback){}}function assignHeaders(object,req){var headers=req.headers.toJSON();const rawHeaders=@newArrayWithSize(req.headers.count*2);var i=0;for(let key in headers)rawHeaders[i++]=key,rawHeaders[i++]=headers[key];object.headers=headers,object.rawHeaders=rawHeaders}function destroyBodyStreamNT(bodyStream){bodyStream.destroy()}var defaultIncomingOpts={type:\"request\"};function getDefaultHTTPSAgent(){return _defaultHTTPSAgent\?\?=new Agent({defaultPort:443,protocol:\"https:\"})}class IncomingMessage extends Readable{method;complete;constructor(req,defaultIncomingOpts2){const method=req.method;super();const url=new URL(req.url);var{type=\"request\",[kInternalRequest]:nodeReq}=defaultIncomingOpts2||{};this.#noBody=type===\"request\"\?method===\"GET\"||method===\"HEAD\"||method===\"TRACE\"||method===\"CONNECT\"||method===\"OPTIONS\"||(parseInt(req.headers.get(\"Content-Length\")||\"\")||0)===0:!1,this.#req=req,this.method=method,this.#type=type,this.complete=!!this.#noBody,this.#bodyStream=void 0;const socket=new FakeSocket;socket.remoteAddress=url.hostname,socket.remotePort=url.port,this.#fakeSocket=socket,this.url=url.pathname+url.search,this.#nodeReq=nodeReq,assignHeaders(this,req)}headers;rawHeaders;_consuming=!1;_dumped=!1;#bodyStream;#fakeSocket;#noBody=!1;#aborted=!1;#req;url;#type;#nodeReq;get req(){return this.#nodeReq}_construct(callback){if(this.#type===\"response\"||this.#noBody){callback();return}const contentLength=this.#req.headers.get(\"content-length\");if((contentLength\?parseInt(contentLength,10):0)===0){this.#noBody=!0,callback();return}callback()}async#consumeStream(reader){while(!0){var{done,value}=await reader.readMany();if(this.#aborted)return;if(done){this.push(null),this.destroy();break}for(var v of value)this.push(v)}}_read(size){if(this.#noBody)this.push(null),this.complete=!0;else if(this.#bodyStream==null){const reader=this.#req.body\?.getReader();if(!reader){this.push(null);return}this.#bodyStream=reader,this.#consumeStream(reader)}}get aborted(){return this.#aborted}#abort(){if(this.#aborted)return;this.#aborted=!0;var bodyStream=this.#bodyStream;if(!bodyStream)return;bodyStream.cancel(),this.complete=!0,this.#bodyStream=void 0,this.push(null)}get connection(){return this.#fakeSocket}get statusCode(){return this.#req.status}get statusMessage(){return STATUS_CODES[this.#req.status]}get httpVersion(){return\"1.1\"}get rawTrailers(){return[]}get httpVersionMajor(){return 1}get httpVersionMinor(){return 1}get trailers(){return kEmptyObject}get socket(){return this.#fakeSocket\?\?=new FakeSocket}set socket(val){this.#fakeSocket=val}setTimeout(msecs,callback){throw new Error(\"not implemented\")}}function emitErrorNt(msg,err,callback){if(callback(err),typeof msg.emit===\"function\"&&!msg._closed)msg.emit(\"error\",err)}function onError(self,err,cb){process.nextTick(()=>emitErrorNt(self,err,cb))}function write_(msg,chunk,encoding,callback,fromEnd){if(typeof callback!==\"function\")callback=nop;let len;if(chunk===null)throw new Error(\"ERR_STREAM_NULL_VALUES\");else if(typeof chunk===\"string\")len=Buffer.byteLength(chunk,encoding);else throw new Error(\"Invalid arg type for chunk\");let err;if(msg.finished)err=new Error(\"ERR_STREAM_WRITE_AFTER_END\");else if(msg.destroyed)err=new Error(\"ERR_STREAM_DESTROYED\");if(err){if(!msg.destroyed)onError(msg,err,callback);else process.nextTick(callback,err);return!1}if(!msg._header){if(fromEnd)msg._contentLength=len}if(!msg._hasBody)return process.nextTick(callback),!0;return!0}class OutgoingMessage extends Writable{constructor(){super(...arguments)}#headers;headersSent=!1;sendDate=!0;req;timeout;#finished=!1;[kEndCalled]=!1;#fakeSocket;#timeoutTimer;[kAbortController]=null;_implicitHeader(){}get headers(){if(!this.#headers)return kEmptyObject;return this.#headers.toJSON()}get shouldKeepAlive(){return!0}get chunkedEncoding(){return!1}set chunkedEncoding(value){}set shouldKeepAlive(value){}get useChunkedEncodingByDefault(){return!0}set useChunkedEncodingByDefault(value){}get socket(){return this.#fakeSocket\?\?=new FakeSocket}set socket(val){this.#fakeSocket=val}get connection(){return this.socket}get finished(){return this.#finished}appendHeader(name,value){var headers=this.#headers\?\?=new Headers;headers.append(name,value)}flushHeaders(){}getHeader(name){return getHeader(this.#headers,name)}getHeaders(){if(!this.#headers)return kEmptyObject;return this.#headers.toJSON()}getHeaderNames(){var headers=this.#headers;if(!headers)return[];return Array.from(headers.keys())}removeHeader(name){if(!this.#headers)return;this.#headers.delete(name)}setHeader(name,value){var headers=this.#headers\?\?=new Headers;return headers.set(name,value),this}hasHeader(name){if(!this.#headers)return!1;return this.#headers.has(name)}addTrailers(headers){throw new Error(\"not implemented\")}[kClearTimeout](){if(this.#timeoutTimer)clearTimeout(this.#timeoutTimer),this.removeAllListeners(\"timeout\"),this.#timeoutTimer=void 0}#onTimeout(){this.#timeoutTimer=void 0,this[kAbortController]\?.abort(),this.emit(\"timeout\")}setTimeout(msecs,callback){if(this.destroyed)return this;if(this.timeout=msecs=validateMsecs(msecs,\"msecs\"),clearTimeout(this.#timeoutTimer),msecs===0){if(callback!==void 0)validateFunction(callback,\"callback\"),this.removeListener(\"timeout\",callback);this.#timeoutTimer=void 0}else if(this.#timeoutTimer=setTimeout(this.#onTimeout.bind(this),msecs).unref(),callback!==void 0)validateFunction(callback,\"callback\"),this.once(\"timeout\",callback);return this}}let OriginalWriteHeadFn,OriginalImplicitHeadFn;class ServerResponse extends Writable{constructor({req,reply}){super();if(this.req=req,this._reply=reply,this.sendDate=!0,this.statusCode=200,this.headersSent=!1,this.statusMessage=void 0,this.#controller=void 0,this.#firstWrite=void 0,this._writableState.decodeStrings=!1,this.#deferred=void 0,req.method===\"HEAD\")this._hasBody=!1}req;_reply;sendDate;statusCode;#headers;headersSent=!1;statusMessage;#controller;#firstWrite;_sent100=!1;_defaultKeepAlive=!1;_removedConnection=!1;_removedContLen=!1;_hasBody=!0;#deferred=void 0;#finished=!1;_implicitHeader(){this.writeHead(this.statusCode)}_write(chunk,encoding,callback){if(!this.#firstWrite&&!this.headersSent){this.#firstWrite=chunk,callback();return}this.#ensureReadableStreamController((controller)=>{controller.write(chunk),callback()})}_writev(chunks,callback){if(chunks.length===1&&!this.headersSent&&!this.#firstWrite){this.#firstWrite=chunks[0].chunk,callback();return}this.#ensureReadableStreamController((controller)=>{for(let chunk of chunks)controller.write(chunk.chunk);callback()})}#ensureReadableStreamController(run){var thisController=this.#controller;if(thisController)return run(thisController);this.headersSent=!0;var firstWrite=this.#firstWrite;this.#firstWrite=void 0,this._reply(new Response(new ReadableStream({type:\"direct\",pull:(controller)=>{if(this.#controller=controller,firstWrite)controller.write(firstWrite);if(firstWrite=void 0,run(controller),!this.#finished)return new Promise((resolve)=>{this.#deferred=resolve})}}),{headers:this.#headers,status:this.statusCode,statusText:this.statusMessage\?\?STATUS_CODES[this.statusCode]}))}#drainHeadersIfObservable(){if(this._implicitHeader===OriginalImplicitHeadFn&&this.writeHead===OriginalWriteHeadFn)return;this._implicitHeader()}_final(callback){if(!this.headersSent){var data=this.#firstWrite||\"\";this.#firstWrite=void 0,this.#finished=!0,this.#drainHeadersIfObservable(),this._reply(new Response(data,{headers:this.#headers,status:this.statusCode,statusText:this.statusMessage\?\?STATUS_CODES[this.statusCode]})),callback&&callback();return}this.#finished=!0,this.#ensureReadableStreamController((controller)=>{controller.end(),callback();var deferred=this.#deferred;if(deferred)this.#deferred=void 0,deferred()})}writeProcessing(){throw new Error(\"not implemented\")}addTrailers(headers){throw new Error(\"not implemented\")}assignSocket(socket){throw new Error(\"not implemented\")}detachSocket(socket){throw new Error(\"not implemented\")}writeContinue(callback){throw new Error(\"not implemented\")}setTimeout(msecs,callback){throw new Error(\"not implemented\")}get shouldKeepAlive(){return!0}get chunkedEncoding(){return!1}set chunkedEncoding(value){}set shouldKeepAlive(value){}get useChunkedEncodingByDefault(){return!0}set useChunkedEncodingByDefault(value){}appendHeader(name,value){var headers=this.#headers\?\?=new Headers;headers.append(name,value)}flushHeaders(){}getHeader(name){return getHeader(this.#headers,name)}getHeaders(){var headers=this.#headers;if(!headers)return kEmptyObject;return headers.toJSON()}getHeaderNames(){var headers=this.#headers;if(!headers)return[];return Array.from(headers.keys())}removeHeader(name){if(!this.#headers)return;this.#headers.delete(name)}setHeader(name,value){var headers=this.#headers\?\?=new Headers;return headers.set(name,value),this}hasHeader(name){if(!this.#headers)return!1;return this.#headers.has(name)}writeHead(statusCode,statusMessage,headers){return _writeHead(statusCode,statusMessage,headers,this),this}}OriginalWriteHeadFn=ServerResponse.prototype.writeHead,OriginalImplicitHeadFn=ServerResponse.prototype._implicitHeader;class ClientRequest extends OutgoingMessage{#timeout;#res=null;#upgradeOrConnect=!1;#parser=null;#maxHeadersCount=null;#reusedSocket=!1;#host;#protocol;#method;#port;#useDefaultPort;#joinDuplicateHeaders;#maxHeaderSize;#agent=globalAgent;#path;#socketPath;#bodyChunks=null;#fetchRequest;#signal=null;[kAbortController]=null;#timeoutTimer=void 0;#options;#finished;get path(){return this.#path}get port(){return this.#port}get method(){return this.#method}get host(){return this.#host}get protocol(){return this.#protocol}_write(chunk,encoding,callback){if(!this.#bodyChunks){this.#bodyChunks=[chunk],callback();return}this.#bodyChunks.push(chunk),callback()}_writev(chunks,callback){if(!this.#bodyChunks){this.#bodyChunks=chunks,callback();return}this.#bodyChunks.push(...chunks),callback()}_final(callback){if(this.#finished=!0,this[kAbortController]=new AbortController,this[kAbortController].signal.addEventListener(\"abort\",()=>{this[kClearTimeout]()}),this.#signal\?.aborted)this[kAbortController].abort();var method=this.#method,body=Buffer.concat(this.#bodyChunks||[]);try{this.#fetchRequest=fetch(`${this.#protocol}//${this.#host}${this.#useDefaultPort\?\"\":\":\"+this.#port}${this.#path}`,{method,headers:this.getHeaders(),body:body&&method!==\"GET\"&&method!==\"HEAD\"&&method!==\"OPTIONS\"\?body:void 0,redirect:\"manual\",verbose:!1,signal:this[kAbortController].signal,timeout:!1}).then((response)=>{var res=this.#res=new IncomingMessage(response,{type:\"response\",[kInternalRequest]:this});this.emit(\"response\",res)}).catch((err)=>{this.emit(\"error\",err)}).finally(()=>{this.#fetchRequest=null,this[kClearTimeout]()})}catch(err){this.emit(\"error\",err)}finally{callback()}}get aborted(){return this.#signal\?.aborted||!!this[kAbortController]\?.signal.aborted}abort(){if(this.aborted)return;this[kAbortController].abort()}constructor(input,options,cb){super();if(typeof input===\"string\"){const urlStr=input;try{var urlObject=new URL(urlStr)}catch(e){@throwTypeError(`Invalid URL: ${urlStr}`)}input=urlToHttpOptions(urlObject)}else if(input&&typeof input===\"object\"&&input instanceof URL)input=urlToHttpOptions(input);else cb=options,options=input,input=null;if(typeof options===\"function\")cb=options,options=input||kEmptyObject;else options=ObjectAssign(input||{},options);var defaultAgent=options._defaultAgent||Agent.globalAgent;let protocol=options.protocol;if(!protocol)if(options.port===443)protocol=\"https:\";else protocol=defaultAgent.protocol||\"http:\";switch(this.#protocol=protocol,this.#agent\?.protocol){case void 0:break;case\"http:\":if(protocol===\"https:\"){defaultAgent=this.#agent=getDefaultHTTPSAgent();break}case\"https:\":if(protocol===\"https\"){defaultAgent=this.#agent=Agent.globalAgent;break}default:break}if(options.path){const path=String(options.path);if(RegExpPrototypeExec.call(INVALID_PATH_REGEX,path)!==null)throw new Error(\"Path contains unescaped characters\")}if(protocol!==\"http:\"&&protocol!==\"https:\"&&protocol){const expectedProtocol=defaultAgent\?.protocol\?\?\"http:\";throw new Error(`Protocol mismatch. Expected: ${expectedProtocol}. Got: ${protocol}`)}const defaultPort=protocol===\"https:\"\?443:80;this.#port=options.port||options.defaultPort||this.#agent\?.defaultPort||defaultPort,this.#useDefaultPort=this.#port===defaultPort;const host=this.#host=options.host=validateHost(options.hostname,\"hostname\")||validateHost(options.host,\"host\")||\"localhost\";this.#socketPath=options.socketPath;const signal=options.signal;if(signal)signal.addEventListener(\"abort\",()=>{this[kAbortController]\?.abort()}),this.#signal=signal;let method=options.method;const methodIsString=typeof method===\"string\";if(method!==null&&method!==void 0&&!methodIsString)throw new Error(\"ERR_INVALID_ARG_TYPE: options.method\");if(methodIsString&&method){if(!checkIsHttpToken(method))throw new Error(\"ERR_INVALID_HTTP_TOKEN: Method\");method=this.#method=StringPrototypeToUpperCase.call(method)}else method=this.#method=\"GET\";const _maxHeaderSize=options.maxHeaderSize;this.#maxHeaderSize=_maxHeaderSize;var _joinDuplicateHeaders=options.joinDuplicateHeaders;if(this.#joinDuplicateHeaders=_joinDuplicateHeaders,this.#path=options.path||\"/\",cb)this.once(\"response\",cb);this.#finished=!1,this.#res=null,this.#upgradeOrConnect=!1,this.#parser=null,this.#maxHeadersCount=null,this.#reusedSocket=!1,this.#host=host,this.#protocol=protocol;var timeout=options.timeout;if(timeout!==void 0&&timeout!==0)this.setTimeout(timeout,void 0);if(!ArrayIsArray(headers)){var headers=options.headers;if(headers)for(let key in headers)this.setHeader(key,headers[key]);var auth=options.auth;if(auth&&!this.getHeader(\"Authorization\"))this.setHeader(\"Authorization\",\"Basic \"+Buffer.from(auth).toString(\"base64\"))}var{signal:_signal,...optsWithoutSignal}=options;this.#options=optsWithoutSignal}setSocketKeepAlive(enable=!0,initialDelay=0){}setNoDelay(noDelay=!0){}[kClearTimeout](){if(this.#timeoutTimer)clearTimeout(this.#timeoutTimer),this.#timeoutTimer=void 0,this.removeAllListeners(\"timeout\")}#onTimeout(){this.#timeoutTimer=void 0,this[kAbortController]\?.abort(),this.emit(\"timeout\")}setTimeout(msecs,callback){if(this.destroyed)return this;if(this.timeout=msecs=validateMsecs(msecs,\"msecs\"),clearTimeout(this.#timeoutTimer),msecs===0){if(callback!==void 0)validateFunction(callback,\"callback\"),this.removeListener(\"timeout\",callback);this.#timeoutTimer=void 0}else if(this.#timeoutTimer=setTimeout(this.#onTimeout.bind(this),msecs).unref(),callback!==void 0)validateFunction(callback,\"callback\"),this.once(\"timeout\",callback);return this}}function urlToHttpOptions(url){var{protocol,hostname,hash,search,pathname,href,port,username,password}=url;return{protocol,hostname:typeof hostname===\"string\"&&StringPrototypeStartsWith.call(hostname,\"[\")\?StringPrototypeSlice.call(hostname,1,-1):hostname,hash,search,pathname,path:`${pathname||\"\"}${search||\"\"}`,href,port:port\?Number(port):protocol===\"https:\"\?443:protocol===\"http:\"\?80:void 0,auth:username||password\?`${decodeURIComponent(username)}:${decodeURIComponent(password)}`:void 0}}function validateHost(host,name){if(host!==null&&host!==void 0&&typeof host!==\"string\")throw new Error(\"Invalid arg type in options\");return host}const tokenRegExp=/^[\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]+$/;function checkIsHttpToken(val){return RegExpPrototypeExec.call(tokenRegExp,val)!==null}const METHODS=[\"ACL\",\"BIND\",\"CHECKOUT\",\"CONNECT\",\"COPY\",\"DELETE\",\"GET\",\"HEAD\",\"LINK\",\"LOCK\",\"M-SEARCH\",\"MERGE\",\"MKACTIVITY\",\"MKCALENDAR\",\"MKCOL\",\"MOVE\",\"NOTIFY\",\"OPTIONS\",\"PATCH\",\"POST\",\"PROPFIND\",\"PROPPATCH\",\"PURGE\",\"PUT\",\"REBIND\",\"REPORT\",\"SEARCH\",\"SOURCE\",\"SUBSCRIBE\",\"TRACE\",\"UNBIND\",\"UNLINK\",\"UNLOCK\",\"UNSUBSCRIBE\"],STATUS_CODES={100:\"Continue\",101:\"Switching Protocols\",102:\"Processing\",103:\"Early Hints\",200:\"OK\",201:\"Created\",202:\"Accepted\",203:\"Non-Authoritative Information\",204:\"No Content\",205:\"Reset Content\",206:\"Partial Content\",207:\"Multi-Status\",208:\"Already Reported\",226:\"IM Used\",300:\"Multiple Choices\",301:\"Moved Permanently\",302:\"Found\",303:\"See Other\",304:\"Not Modified\",305:\"Use Proxy\",307:\"Temporary Redirect\",308:\"Permanent Redirect\",400:\"Bad Request\",401:\"Unauthorized\",402:\"Payment Required\",403:\"Forbidden\",404:\"Not Found\",405:\"Method Not Allowed\",406:\"Not Acceptable\",407:\"Proxy Authentication Required\",408:\"Request Timeout\",409:\"Conflict\",410:\"Gone\",411:\"Length Required\",412:\"Precondition Failed\",413:\"Payload Too Large\",414:\"URI Too Long\",415:\"Unsupported Media Type\",416:\"Range Not Satisfiable\",417:\"Expectation Failed\",418:\"I'm a Teapot\",421:\"Misdirected Request\",422:\"Unprocessable Entity\",423:\"Locked\",424:\"Failed Dependency\",425:\"Too Early\",426:\"Upgrade Required\",428:\"Precondition Required\",429:\"Too Many Requests\",431:\"Request Header Fields Too Large\",451:\"Unavailable For Legal Reasons\",500:\"Internal Server Error\",501:\"Not Implemented\",502:\"Bad Gateway\",503:\"Service Unavailable\",504:\"Gateway Timeout\",505:\"HTTP Version Not Supported\",506:\"Variant Also Negotiates\",507:\"Insufficient Storage\",508:\"Loop Detected\",509:\"Bandwidth Limit Exceeded\",510:\"Not Extended\",511:\"Network Authentication Required\"};function _normalizeArgs(args){let arr;if(args.length===0)return arr=[{},null],arr;const arg0=args[0];let options={};if(typeof arg0===\"object\"&&arg0!==null)options=arg0;else if(options.port=arg0,args.length>1&&typeof args[1]===\"string\")options.host=args[1];const cb=args[args.length-1];if(typeof cb!==\"function\")arr=[options,null];else arr=[options,cb];return arr}function _writeHead(statusCode,reason,obj,response){if(statusCode|=0,statusCode<100||statusCode>999)throw new Error(\"status code must be between 100 and 999\");if(typeof reason===\"string\")response.statusMessage=reason;else{if(!response.statusMessage)response.statusMessage=STATUS_CODES[statusCode]||\"unknown\";obj=reason}response.statusCode=statusCode;{let k;if(Array.isArray(obj)){if(obj.length%2!==0)throw new Error(\"raw headers must have an even number of elements\");for(let n=0;n=100&&statusCode<=199)response._hasBody=!1}function request(url,options,cb){return new ClientRequest(url,options,cb)}function get(url,options,cb){const req=request(url,options,cb);return req.end(),req}var globalAgent=new Agent;return $={Agent,Server,METHODS,STATUS_CODES,createServer,ServerResponse,IncomingMessage,request,get,maxHeaderSize:16384,validateHeaderName,validateHeaderValue,setMaxIdleHTTPParsers(max){},globalAgent,ClientRequest,OutgoingMessage},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttp2Code = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function connect(){throwNotImplemented(\"node:http2 connect\",887)}const constants={NGHTTP2_ERR_FRAME_SIZE_ERROR:-522,NGHTTP2_SESSION_SERVER:0,NGHTTP2_SESSION_CLIENT:1,NGHTTP2_STREAM_STATE_IDLE:1,NGHTTP2_STREAM_STATE_OPEN:2,NGHTTP2_STREAM_STATE_RESERVED_LOCAL:3,NGHTTP2_STREAM_STATE_RESERVED_REMOTE:4,NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL:5,NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE:6,NGHTTP2_STREAM_STATE_CLOSED:7,NGHTTP2_FLAG_NONE:0,NGHTTP2_FLAG_END_STREAM:1,NGHTTP2_FLAG_END_HEADERS:4,NGHTTP2_FLAG_ACK:1,NGHTTP2_FLAG_PADDED:8,NGHTTP2_FLAG_PRIORITY:32,DEFAULT_SETTINGS_HEADER_TABLE_SIZE:4096,DEFAULT_SETTINGS_ENABLE_PUSH:1,DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS:4294967295,DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE:65535,DEFAULT_SETTINGS_MAX_FRAME_SIZE:16384,DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE:65535,DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL:0,MAX_MAX_FRAME_SIZE:16777215,MIN_MAX_FRAME_SIZE:16384,MAX_INITIAL_WINDOW_SIZE:2147483647,NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:1,NGHTTP2_SETTINGS_ENABLE_PUSH:2,NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:3,NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:4,NGHTTP2_SETTINGS_MAX_FRAME_SIZE:5,NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:6,NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:8,PADDING_STRATEGY_NONE:0,PADDING_STRATEGY_ALIGNED:1,PADDING_STRATEGY_MAX:2,PADDING_STRATEGY_CALLBACK:1,NGHTTP2_NO_ERROR:0,NGHTTP2_PROTOCOL_ERROR:1,NGHTTP2_INTERNAL_ERROR:2,NGHTTP2_FLOW_CONTROL_ERROR:3,NGHTTP2_SETTINGS_TIMEOUT:4,NGHTTP2_STREAM_CLOSED:5,NGHTTP2_FRAME_SIZE_ERROR:6,NGHTTP2_REFUSED_STREAM:7,NGHTTP2_CANCEL:8,NGHTTP2_COMPRESSION_ERROR:9,NGHTTP2_CONNECT_ERROR:10,NGHTTP2_ENHANCE_YOUR_CALM:11,NGHTTP2_INADEQUATE_SECURITY:12,NGHTTP2_HTTP_1_1_REQUIRED:13,NGHTTP2_DEFAULT_WEIGHT:16,HTTP2_HEADER_STATUS:\":status\",HTTP2_HEADER_METHOD:\":method\",HTTP2_HEADER_AUTHORITY:\":authority\",HTTP2_HEADER_SCHEME:\":scheme\",HTTP2_HEADER_PATH:\":path\",HTTP2_HEADER_PROTOCOL:\":protocol\",HTTP2_HEADER_ACCEPT_ENCODING:\"accept-encoding\",HTTP2_HEADER_ACCEPT_LANGUAGE:\"accept-language\",HTTP2_HEADER_ACCEPT_RANGES:\"accept-ranges\",HTTP2_HEADER_ACCEPT:\"accept\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS:\"access-control-allow-credentials\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS:\"access-control-allow-headers\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS:\"access-control-allow-methods\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN:\"access-control-allow-origin\",HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS:\"access-control-expose-headers\",HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS:\"access-control-request-headers\",HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD:\"access-control-request-method\",HTTP2_HEADER_AGE:\"age\",HTTP2_HEADER_AUTHORIZATION:\"authorization\",HTTP2_HEADER_CACHE_CONTROL:\"cache-control\",HTTP2_HEADER_CONNECTION:\"connection\",HTTP2_HEADER_CONTENT_DISPOSITION:\"content-disposition\",HTTP2_HEADER_CONTENT_ENCODING:\"content-encoding\",HTTP2_HEADER_CONTENT_LENGTH:\"content-length\",HTTP2_HEADER_CONTENT_TYPE:\"content-type\",HTTP2_HEADER_COOKIE:\"cookie\",HTTP2_HEADER_DATE:\"date\",HTTP2_HEADER_ETAG:\"etag\",HTTP2_HEADER_FORWARDED:\"forwarded\",HTTP2_HEADER_HOST:\"host\",HTTP2_HEADER_IF_MODIFIED_SINCE:\"if-modified-since\",HTTP2_HEADER_IF_NONE_MATCH:\"if-none-match\",HTTP2_HEADER_IF_RANGE:\"if-range\",HTTP2_HEADER_LAST_MODIFIED:\"last-modified\",HTTP2_HEADER_LINK:\"link\",HTTP2_HEADER_LOCATION:\"location\",HTTP2_HEADER_RANGE:\"range\",HTTP2_HEADER_REFERER:\"referer\",HTTP2_HEADER_SERVER:\"server\",HTTP2_HEADER_SET_COOKIE:\"set-cookie\",HTTP2_HEADER_STRICT_TRANSPORT_SECURITY:\"strict-transport-security\",HTTP2_HEADER_TRANSFER_ENCODING:\"transfer-encoding\",HTTP2_HEADER_TE:\"te\",HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS:\"upgrade-insecure-requests\",HTTP2_HEADER_UPGRADE:\"upgrade\",HTTP2_HEADER_USER_AGENT:\"user-agent\",HTTP2_HEADER_VARY:\"vary\",HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS:\"x-content-type-options\",HTTP2_HEADER_X_FRAME_OPTIONS:\"x-frame-options\",HTTP2_HEADER_KEEP_ALIVE:\"keep-alive\",HTTP2_HEADER_PROXY_CONNECTION:\"proxy-connection\",HTTP2_HEADER_X_XSS_PROTECTION:\"x-xss-protection\",HTTP2_HEADER_ALT_SVC:\"alt-svc\",HTTP2_HEADER_CONTENT_SECURITY_POLICY:\"content-security-policy\",HTTP2_HEADER_EARLY_DATA:\"early-data\",HTTP2_HEADER_EXPECT_CT:\"expect-ct\",HTTP2_HEADER_ORIGIN:\"origin\",HTTP2_HEADER_PURPOSE:\"purpose\",HTTP2_HEADER_TIMING_ALLOW_ORIGIN:\"timing-allow-origin\",HTTP2_HEADER_X_FORWARDED_FOR:\"x-forwarded-for\",HTTP2_HEADER_PRIORITY:\"priority\",HTTP2_HEADER_ACCEPT_CHARSET:\"accept-charset\",HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE:\"access-control-max-age\",HTTP2_HEADER_ALLOW:\"allow\",HTTP2_HEADER_CONTENT_LANGUAGE:\"content-language\",HTTP2_HEADER_CONTENT_LOCATION:\"content-location\",HTTP2_HEADER_CONTENT_MD5:\"content-md5\",HTTP2_HEADER_CONTENT_RANGE:\"content-range\",HTTP2_HEADER_DNT:\"dnt\",HTTP2_HEADER_EXPECT:\"expect\",HTTP2_HEADER_EXPIRES:\"expires\",HTTP2_HEADER_FROM:\"from\",HTTP2_HEADER_IF_MATCH:\"if-match\",HTTP2_HEADER_IF_UNMODIFIED_SINCE:\"if-unmodified-since\",HTTP2_HEADER_MAX_FORWARDS:\"max-forwards\",HTTP2_HEADER_PREFER:\"prefer\",HTTP2_HEADER_PROXY_AUTHENTICATE:\"proxy-authenticate\",HTTP2_HEADER_PROXY_AUTHORIZATION:\"proxy-authorization\",HTTP2_HEADER_REFRESH:\"refresh\",HTTP2_HEADER_RETRY_AFTER:\"retry-after\",HTTP2_HEADER_TRAILER:\"trailer\",HTTP2_HEADER_TK:\"tk\",HTTP2_HEADER_VIA:\"via\",HTTP2_HEADER_WARNING:\"warning\",HTTP2_HEADER_WWW_AUTHENTICATE:\"www-authenticate\",HTTP2_HEADER_HTTP2_SETTINGS:\"http2-settings\",HTTP2_METHOD_ACL:\"ACL\",HTTP2_METHOD_BASELINE_CONTROL:\"BASELINE-CONTROL\",HTTP2_METHOD_BIND:\"BIND\",HTTP2_METHOD_CHECKIN:\"CHECKIN\",HTTP2_METHOD_CHECKOUT:\"CHECKOUT\",HTTP2_METHOD_CONNECT:\"CONNECT\",HTTP2_METHOD_COPY:\"COPY\",HTTP2_METHOD_DELETE:\"DELETE\",HTTP2_METHOD_GET:\"GET\",HTTP2_METHOD_HEAD:\"HEAD\",HTTP2_METHOD_LABEL:\"LABEL\",HTTP2_METHOD_LINK:\"LINK\",HTTP2_METHOD_LOCK:\"LOCK\",HTTP2_METHOD_MERGE:\"MERGE\",HTTP2_METHOD_MKACTIVITY:\"MKACTIVITY\",HTTP2_METHOD_MKCALENDAR:\"MKCALENDAR\",HTTP2_METHOD_MKCOL:\"MKCOL\",HTTP2_METHOD_MKREDIRECTREF:\"MKREDIRECTREF\",HTTP2_METHOD_MKWORKSPACE:\"MKWORKSPACE\",HTTP2_METHOD_MOVE:\"MOVE\",HTTP2_METHOD_OPTIONS:\"OPTIONS\",HTTP2_METHOD_ORDERPATCH:\"ORDERPATCH\",HTTP2_METHOD_PATCH:\"PATCH\",HTTP2_METHOD_POST:\"POST\",HTTP2_METHOD_PRI:\"PRI\",HTTP2_METHOD_PROPFIND:\"PROPFIND\",HTTP2_METHOD_PROPPATCH:\"PROPPATCH\",HTTP2_METHOD_PUT:\"PUT\",HTTP2_METHOD_REBIND:\"REBIND\",HTTP2_METHOD_REPORT:\"REPORT\",HTTP2_METHOD_SEARCH:\"SEARCH\",HTTP2_METHOD_TRACE:\"TRACE\",HTTP2_METHOD_UNBIND:\"UNBIND\",HTTP2_METHOD_UNCHECKOUT:\"UNCHECKOUT\",HTTP2_METHOD_UNLINK:\"UNLINK\",HTTP2_METHOD_UNLOCK:\"UNLOCK\",HTTP2_METHOD_UPDATE:\"UPDATE\",HTTP2_METHOD_UPDATEREDIRECTREF:\"UPDATEREDIRECTREF\",HTTP2_METHOD_VERSION_CONTROL:\"VERSION-CONTROL\",HTTP_STATUS_CONTINUE:100,HTTP_STATUS_SWITCHING_PROTOCOLS:101,HTTP_STATUS_PROCESSING:102,HTTP_STATUS_EARLY_HINTS:103,HTTP_STATUS_OK:200,HTTP_STATUS_CREATED:201,HTTP_STATUS_ACCEPTED:202,HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION:203,HTTP_STATUS_NO_CONTENT:204,HTTP_STATUS_RESET_CONTENT:205,HTTP_STATUS_PARTIAL_CONTENT:206,HTTP_STATUS_MULTI_STATUS:207,HTTP_STATUS_ALREADY_REPORTED:208,HTTP_STATUS_IM_USED:226,HTTP_STATUS_MULTIPLE_CHOICES:300,HTTP_STATUS_MOVED_PERMANENTLY:301,HTTP_STATUS_FOUND:302,HTTP_STATUS_SEE_OTHER:303,HTTP_STATUS_NOT_MODIFIED:304,HTTP_STATUS_USE_PROXY:305,HTTP_STATUS_TEMPORARY_REDIRECT:307,HTTP_STATUS_PERMANENT_REDIRECT:308,HTTP_STATUS_BAD_REQUEST:400,HTTP_STATUS_UNAUTHORIZED:401,HTTP_STATUS_PAYMENT_REQUIRED:402,HTTP_STATUS_FORBIDDEN:403,HTTP_STATUS_NOT_FOUND:404,HTTP_STATUS_METHOD_NOT_ALLOWED:405,HTTP_STATUS_NOT_ACCEPTABLE:406,HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED:407,HTTP_STATUS_REQUEST_TIMEOUT:408,HTTP_STATUS_CONFLICT:409,HTTP_STATUS_GONE:410,HTTP_STATUS_LENGTH_REQUIRED:411,HTTP_STATUS_PRECONDITION_FAILED:412,HTTP_STATUS_PAYLOAD_TOO_LARGE:413,HTTP_STATUS_URI_TOO_LONG:414,HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE:415,HTTP_STATUS_RANGE_NOT_SATISFIABLE:416,HTTP_STATUS_EXPECTATION_FAILED:417,HTTP_STATUS_TEAPOT:418,HTTP_STATUS_MISDIRECTED_REQUEST:421,HTTP_STATUS_UNPROCESSABLE_ENTITY:422,HTTP_STATUS_LOCKED:423,HTTP_STATUS_FAILED_DEPENDENCY:424,HTTP_STATUS_TOO_EARLY:425,HTTP_STATUS_UPGRADE_REQUIRED:426,HTTP_STATUS_PRECONDITION_REQUIRED:428,HTTP_STATUS_TOO_MANY_REQUESTS:429,HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE:431,HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS:451,HTTP_STATUS_INTERNAL_SERVER_ERROR:500,HTTP_STATUS_NOT_IMPLEMENTED:501,HTTP_STATUS_BAD_GATEWAY:502,HTTP_STATUS_SERVICE_UNAVAILABLE:503,HTTP_STATUS_GATEWAY_TIMEOUT:504,HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED:505,HTTP_STATUS_VARIANT_ALSO_NEGOTIATES:506,HTTP_STATUS_INSUFFICIENT_STORAGE:507,HTTP_STATUS_LOOP_DETECTED:508,HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED:509,HTTP_STATUS_NOT_EXTENDED:510,HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED:511};function createServer(){throwNotImplemented(\"node:http2 createServer\",887)}function createSecureServer(){throwNotImplemented(\"node:http2 createSecureServer\",887)}function getDefaultSettings(){return{headerTableSize:4096,enablePush:!0,initialWindowSize:65535,maxFrameSize:16384,maxConcurrentStreams:4294967295,maxHeaderSize:65535,maxHeaderListSize:65535,enableConnectProtocol:!1}}function getPackedSettings(){return Buffer.alloc(0)}function getUnpackedSettings(){return Buffer.alloc(0)}const sensitiveHeaders=Symbol.for(\"nodejs.http2.sensitiveHeaders\");function Http2ServerRequest(){throwNotImplemented(\"node:http2 Http2ServerRequest\",887)}function Http2ServerResponse(){throwNotImplemented(\"node:http2 Http2ServerResponse\",887)}return $={constants,createServer,createSecureServer,getDefaultSettings,getPackedSettings,getUnpackedSettings,sensitiveHeaders,Http2ServerRequest,Http2ServerResponse,connect},hideFromStack([Http2ServerRequest,Http2ServerResponse,connect,createServer,createSecureServer,getDefaultSettings,getPackedSettings,getUnpackedSettings]),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttpsCode = "(function (){\"use strict\";const http=@getInternalField(@internalModuleRegistry,18)||@createInternalModuleById(18);function request(input,options,cb){if(input&&typeof input===\"object\"&&!(input instanceof URL))input.protocol\?\?=\"https:\";else if(typeof options===\"object\")options.protocol\?\?=\"https:\";return http.request(input,options,cb)}function get(input,options,cb){const req=request(input,options,cb);return req.end(),req}return{...http,get,request}})\n"_s; +// + +// static constexpr ASCIILiteral NodeInspectorCode = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15);function open(){throwNotImplemented(\"node:inspector open\",2445)}function close(){throwNotImplemented(\"node:inspector close\",2445)}function url(){throwNotImplemented(\"node:inspector url\",2445)}function waitForDebugger(){throwNotImplemented(\"node:inspector waitForDebugger\",2445)}class Session extends EventEmitter{constructor(){super();throwNotImplemented(\"node:inspector Session\",2445)}}return $={console:{...globalThis.console,context:{console:globalThis.console}},open,close,url,waitForDebugger,Session},hideFromStack(open,close,url,waitForDebugger,Session.prototype.constructor),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeNetCode = "(function (){\"use strict\";const{Duplex}=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),IPv4Reg=new RegExp(\"^((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$\"),IPv6Reg=new RegExp(\"^((\?:(\?:[0-9a-fA-F]{1,4}):){7}(\?:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){6}(\?:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){5}(\?::((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,2}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){4}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,1}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,3}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){3}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,2}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,4}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){2}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,3}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,5}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){1}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,4}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,6}|:)|(\?::((\?::(\?:[0-9a-fA-F]{1,4})){0,5}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(\?::(\?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})\?$\");function isIPv4(s){return IPv4Reg.test(s)}function isIPv6(s){return IPv6Reg.test(s)}function isIP(s){if(isIPv4(s))return 4;if(isIPv6(s))return 6;return 0}const{connect:bunConnect}=Bun;var{setTimeout}=globalThis;const bunTlsSymbol=Symbol.for(\"::buntls::\"),bunSocketServerHandlers=Symbol.for(\"::bunsocket_serverhandlers::\"),bunSocketServerConnections=Symbol.for(\"::bunnetserverconnections::\"),bunSocketServerOptions=Symbol.for(\"::bunnetserveroptions::\"),bunSocketInternal=Symbol.for(\"::bunnetsocketinternal::\"),bunTLSConnectOptions=Symbol.for(\"::buntlsconnectoptions::\");var SocketClass;const Socket=function(InternalSocket){return SocketClass=InternalSocket,Object.defineProperty(SocketClass.prototype,Symbol.toStringTag,{value:\"Socket\",enumerable:!1}),Object.defineProperty(function Socket(options){return new InternalSocket(options)},Symbol.hasInstance,{value(instance){return instance instanceof InternalSocket}})}(class Socket2 extends Duplex{static#Handlers={close:Socket2.#Close,connectError(socket,error){socket.data.emit(\"error\",error)},data({data:self},buffer){self.bytesRead+=buffer.length;const queue=self.#readQueue;if(queue.isEmpty()){if(self.push(buffer))return}queue.push(buffer)},drain:Socket2.#Drain,end:Socket2.#Close,error(socket,error){const self=socket.data,callback=self.#writeCallback;if(callback)self.#writeCallback=null,callback(error);self.emit(\"error\",error)},open(socket){const self=socket.data;socket.timeout(self.timeout),socket.ref(),self[bunSocketInternal]=socket,self.connecting=!1;const options=self[bunTLSConnectOptions];if(options){const{session}=options;if(session)self.setSession(session)}if(!self.#upgraded)self.emit(\"connect\",self);Socket2.#Drain(socket)},handshake(socket,success,verifyError){const{data:self}=socket;self._securePending=!1,self.secureConnecting=!1,self._secureEstablished=!!success,self.emit(\"secure\",self);const{checkServerIdentity}=self[bunTLSConnectOptions];if(!verifyError&&typeof checkServerIdentity===\"function\"&&self.servername){const cert=self.getPeerCertificate(!0);verifyError=checkServerIdentity(self.servername,cert)}if(self._requestCert||self._rejectUnauthorized){if(verifyError){if(self.authorized=!1,self.authorizationError=verifyError.code||verifyError.message,self._rejectUnauthorized){self.destroy(verifyError);return}}}else self.authorized=!0;self.emit(\"secureConnect\",verifyError)},timeout(socket){const self=socket.data;self.emit(\"timeout\",self)},binaryType:\"buffer\"};static#Close(socket){const self=socket.data;if(self.#closed)return;self.#closed=!0,self[bunSocketInternal]=null;const queue=self.#readQueue;if(queue.isEmpty()){if(self.push(null))return}queue.push(null)}static#Drain(socket){const self=socket.data,callback=self.#writeCallback;if(callback){const chunk=self.#writeChunk,written=socket.write(chunk);if(self.bytesWritten+=written,written=self.maxConnections){const data={localAddress:_socket.localAddress,localPort:_socket.localPort,localFamily:_socket.localFamily,remoteAddress:_socket.remoteAddress,remotePort:_socket.remotePort,remoteFamily:_socket.remoteFamily||\"IPv4\"};socket.end(),self.emit(\"drop\",data);return}if(!pauseOnConnect)_socket.resume();if(self[bunSocketServerConnections]++,typeof connectionListener==\"function\")if(InternalSocketClass.name===\"TLSSocket\")self.once(\"secureConnection\",()=>connectionListener(_socket));else connectionListener(_socket);self.emit(\"connection\",_socket)},handshake(socket,success,verifyError){const{data:self}=socket;if(self.emit(\"secure\",self),self._securePending=!1,self.secureConnecting=!1,self._secureEstablished=!!success,self._requestCert||self._rejectUnauthorized){if(verifyError){if(self.authorized=!1,self.authorizationError=verifyError.code||verifyError.message,self._rejectUnauthorized){self.destroy(verifyError);return}}}else self.authorized=!0;self.emit(\"secureConnection\",verifyError)},error(socket,error){Socket2.#Handlers.error(socket,error),this.data.emit(\"error\",error)},timeout:Socket2.#Handlers.timeout,connectError:Socket2.#Handlers.connectError,drain:Socket2.#Handlers.drain,binaryType:\"buffer\"};bytesRead=0;bytesWritten=0;#closed=!1;connecting=!1;localAddress=\"127.0.0.1\";#readQueue=@createFIFO();remotePort;[bunSocketInternal]=null;[bunTLSConnectOptions]=null;timeout=0;#writeCallback;#writeChunk;#pendingRead;isServer=!1;_handle;_parent;_parentWrap;#socket;#upgraded;constructor(options){const{socket,signal,write,read,allowHalfOpen=!1,...opts}=options||{};super({...opts,allowHalfOpen,readable:!0,writable:!0});if(this._handle=this,this._parent=this,this._parentWrap=this,this.#pendingRead=void 0,this.#upgraded=!1,socket instanceof Socket2)this.#socket=socket;signal\?.once(\"abort\",()=>this.destroy()),this.once(\"connect\",()=>this.emit(\"ready\"))}address(){return{address:this.localAddress,family:this.localFamily,port:this.localPort}}get bufferSize(){return this.writableLength}#attach(port,socket){if(this.remotePort=port,socket.data=this,socket.timeout(this.timeout),socket.ref(),this[bunSocketInternal]=socket,this.connecting=!1,!this.#upgraded)this.emit(\"connect\",this);Socket2.#Drain(socket)}connect(port,host,connectListener){var path,connection=this.#socket,_checkServerIdentity=void 0;if(typeof port===\"string\"){if(path=port,port=void 0,typeof host===\"function\")connectListener=host,host=void 0}else if(typeof host==\"function\"){if(typeof port===\"string\")path=port,port=void 0;connectListener=host,host=void 0}if(typeof port==\"object\"){var{port,host,path,socket,localAddress,localPort,family,hints,lookup,noDelay,keepAlive,keepAliveInitialDelay,requestCert,rejectUnauthorized,pauseOnConnect,servername,checkServerIdentity,session}=port;if(_checkServerIdentity=checkServerIdentity,this.servername=servername,socket)connection=socket}if(!pauseOnConnect)this.resume();this.connecting=!0,this.remotePort=port;const bunTLS=this[bunTlsSymbol];var tls=void 0;if(typeof bunTLS===\"function\"){if(tls=bunTLS.call(this,port,host,!0),this._requestCert=!0,this._rejectUnauthorized=rejectUnauthorized,tls){if(tls.rejectUnauthorized=rejectUnauthorized,tls.requestCert=!0,tls.session=session||tls.session,this.servername=tls.servername,tls.checkServerIdentity=_checkServerIdentity||tls.checkServerIdentity,this[bunTLSConnectOptions]=tls,!connection&&tls.socket)connection=tls.socket}if(connection){if(typeof connection!==\"object\"||!(connection instanceof Socket2)||typeof connection[bunTlsSymbol]===\"function\")@throwTypeError(\"socket must be an instance of net.Socket\")}if(this.authorized=!1,this.secureConnecting=!0,this._secureEstablished=!1,this._securePending=!0,connectListener)this.on(\"secureConnect\",connectListener)}else if(connectListener)this.on(\"connect\",connectListener);if(connection){const socket2=connection[bunSocketInternal];if(socket2){this.connecting=!0,this.#upgraded=!0;const result=socket2.upgradeTLS({data:this,tls,socket:Socket2.#Handlers});if(result){const[raw,tls2]=result;connection[bunSocketInternal]=raw,raw.timeout(raw.timeout),raw.connecting=!1,this[bunSocketInternal]=tls2}else throw this[bunSocketInternal]=null,new Error(\"Invalid socket\")}else connection.once(\"connect\",()=>{const socket3=connection[bunSocketInternal];if(!socket3)return;this.connecting=!0,this.#upgraded=!0;const result=socket3.upgradeTLS({data:this,tls,socket:Socket2.#Handlers});if(result){const[raw,tls2]=result;connection[bunSocketInternal]=raw,raw.timeout(raw.timeout),raw.connecting=!1,this[bunSocketInternal]=tls2}else throw this[bunSocketInternal]=null,new Error(\"Invalid socket\")})}else if(path)bunConnect({data:this,unix:path,socket:Socket2.#Handlers,tls}).catch((error)=>{this.emit(\"error\",error)});else bunConnect({data:this,hostname:host||\"localhost\",port,socket:Socket2.#Handlers,tls}).catch((error)=>{this.emit(\"error\",error)});return this}_destroy(err,callback){this[bunSocketInternal]\?.end(),callback(err)}_final(callback){this[bunSocketInternal]\?.end(),callback()}get localAddress(){return\"127.0.0.1\"}get localFamily(){return\"IPv4\"}get localPort(){return this[bunSocketInternal]\?.localPort}get pending(){return this.connecting}_read(size){const queue=this.#readQueue;let chunk;while(chunk=queue.peek()){if(!this.push(chunk))return;queue.shift()}}get readyState(){if(this.connecting)return\"opening\";if(this.readable)return this.writable\?\"open\":\"readOnly\";else return this.writable\?\"writeOnly\":\"closed\"}ref(){this[bunSocketInternal]\?.ref()}get remoteAddress(){return this[bunSocketInternal]\?.remoteAddress}get remoteFamily(){return\"IPv4\"}resetAndDestroy(){this[bunSocketInternal]\?.end()}setKeepAlive(enable=!1,initialDelay=0){return this}setNoDelay(noDelay=!0){return this}setTimeout(timeout,callback){if(this[bunSocketInternal]\?.timeout(timeout),this.timeout=timeout,callback)this.once(\"timeout\",callback);return this}unref(){this[bunSocketInternal]\?.unref()}_write(chunk,encoding,callback){if(typeof chunk==\"string\"&&encoding!==\"ascii\")chunk=Buffer.from(chunk,encoding);var written=this[bunSocketInternal]\?.write(chunk);if(written==chunk.length)callback();else if(this.#writeCallback)callback(new Error(\"overlapping _write()\"));else{if(written>0)if(typeof chunk==\"string\")chunk=chunk.slice(written);else chunk=chunk.subarray(written);this.#writeCallback=callback,this.#writeChunk=chunk}}});function createConnection(port,host,connectListener){if(typeof port===\"object\")return new Socket(port).connect(port,host,connectListener);return new Socket().connect(port,host,connectListener)}const connect=createConnection;class Server extends EventEmitter{#server;#listening=!1;[bunSocketServerConnections]=0;[bunSocketServerOptions];maxConnections=0;constructor(options,connectionListener){super();if(typeof options===\"function\")connectionListener=options,options={};else if(options==null||typeof options===\"object\")options={...options};else throw new Error(\"bun-net-polyfill: invalid arguments\");const{maxConnections}=options;this.maxConnections=Number.isSafeInteger(maxConnections)&&maxConnections>0\?maxConnections:0,options.connectionListener=connectionListener,this[bunSocketServerOptions]=options}ref(){return this.#server\?.ref(),this}unref(){return this.#server\?.unref(),this}close(callback){if(this.#server){if(this.#server.stop(!0),this.#server=null,this.#listening=!1,this[bunSocketServerConnections]=0,this.emit(\"close\"),typeof callback===\"function\")callback();return this}if(typeof callback===\"function\"){const error=new Error(\"Server is not running\");error.code=\"ERR_SERVER_NOT_RUNNING\",callback(error)}return this}address(){const server=this.#server;if(server){const unix=server.unix;if(unix)return unix;let address=server.hostname;const type=isIP(address),port=server.port;if(typeof port===\"number\")return{port,address,family:type\?`IPv${type}`:void 0};if(type)return{address,family:type\?`IPv${type}`:void 0};return address}return null}getConnections(callback){if(typeof callback===\"function\")callback(null,this.#server\?this[bunSocketServerConnections]:0);return this}listen(port,hostname,onListen){let backlog,path,exclusive=!1;if(typeof port===\"string\"){if(Number.isSafeInteger(hostname)){if(hostname>0)backlog=hostname}else if(typeof hostname===\"function\")onListen=hostname;path=port,hostname=void 0,port=void 0}else{if(typeof hostname===\"function\")onListen=hostname,hostname=void 0;if(typeof port===\"function\")onListen=port,port=0;else if(typeof port===\"object\"){const options=port;options.signal\?.addEventListener(\"abort\",()=>this.close()),hostname=options.host,exclusive=options.exclusive===!0;const path2=options.path;if(port=options.port,!Number.isSafeInteger(port)||port<0)if(path2)hostname=path2,port=void 0;else{let message='The argument \\'options\\' must have the property \"port\" or \"path\"';try{message=`${message}. Received ${JSON.stringify(options)}`}catch{}const error=@makeTypeError(message);throw error.code=\"ERR_INVALID_ARG_VALUE\",error}else if(!Number.isSafeInteger(port)||port<0)port=0;if(typeof port.callback===\"function\")onListen=port\?.callback}else if(!Number.isSafeInteger(port)||port<0)port=0;hostname=hostname||\"::\"}try{var tls=void 0,TLSSocketClass=void 0;const bunTLS=this[bunTlsSymbol],options=this[bunSocketServerOptions];if(typeof bunTLS===\"function\")[tls,TLSSocketClass]=bunTLS.call(this,port,hostname,!1),options.servername=tls.serverName,options.InternalSocketClass=TLSSocketClass;else options.InternalSocketClass=SocketClass;this.#server=Bun.listen(path\?{exclusive,unix:path,tls,socket:SocketClass[bunSocketServerHandlers]}:{exclusive,port,hostname,tls,socket:SocketClass[bunSocketServerHandlers]}),this.#server.data=this,this.#listening=!0,setTimeout(emitListeningNextTick,1,this,onListen)}catch(err){this.#listening=!1,setTimeout(emitErrorNextTick,1,this,err)}return this}}function emitErrorNextTick(self,error){self.emit(\"error\",error)}function emitListeningNextTick(self,onListen){if(typeof onListen===\"function\")try{onListen()}catch(err){self.emit(\"error\",err)}self.emit(\"listening\")}function createServer(options,connectionListener){return new Server(options,connectionListener)}return{createServer,Server,createConnection,connect,isIP,isIPv4,isIPv6,Socket,[Symbol.for(\"::bunternal::\")]:SocketClass}})\n"_s; +// + +// static constexpr ASCIILiteral NodeOSCode = "(function (){\"use strict\";var tmpdir=function(){var env=Bun.env;return tmpdir=function(){var path=env.TMPDIR||env.TMP||env.TEMP||\"/tmp\";const length=path.length;if(length>1&&path[length-1]===\"/\")path=path.slice(0,-1);return path},tmpdir()};function lazyCpus({cpus}){return()=>{const array=new Array(navigator.hardwareConcurrency);function populate(){const results=cpus(),length=results.length;array.length=length;for(let i=0;i= 0x80 (not a basic code point)\",\"invalid-input\":\"Invalid input\"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){@throwRangeError(errors[type])}function map(array,callback){const result=[];let length=array.length;while(length--)result[length]=callback(array[length]);return result}function mapDomain(domain,callback){const parts=domain.split(\"@\");let result=\"\";if(parts.length>1)result=parts[0]+\"@\",domain=parts[1];domain=domain.replace(regexSeparators,\".\");const labels=domain.split(\".\"),encoded=map(labels,callback).join(\".\");return result+encoded}function ucs2decode(string){const output=[];let counter=0;const length=string.length;while(counter=55296&&value<=56319&&counterString.fromCodePoint(...codePoints),basicToDigit=function(codePoint){if(codePoint>=48&&codePoint<58)return 26+(codePoint-48);if(codePoint>=65&&codePoint<91)return codePoint-65;if(codePoint>=97&&codePoint<123)return codePoint-97;return base},digitToBasic=function(digit,flag){return digit+22+75*(digit<26)-((flag!=0)<<5)},adapt=function(delta,numPoints,firstTime){let k=0;delta=firstTime\?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);for(;delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))},decode=function(input){const output=[],inputLength=input.length;let i=0,n=initialN,bias=initialBias,basic=input.lastIndexOf(delimiter);if(basic<0)basic=0;for(let j=0;j=128)error(\"not-basic\");output.push(input.charCodeAt(j))}for(let index=basic>0\?basic+1:0;index=inputLength)error(\"invalid-input\");const digit=basicToDigit(input.charCodeAt(index++));if(digit>=base)error(\"invalid-input\");if(digit>floor((maxInt-i)/w))error(\"overflow\");i+=digit*w;const t=k<=bias\?tMin:k>=bias+tMax\?tMax:k-bias;if(digitfloor(maxInt/baseMinusT))error(\"overflow\");w*=baseMinusT}const out=output.length+1;if(bias=adapt(i-oldi,out,oldi==0),floor(i/out)>maxInt-n)error(\"overflow\");n+=floor(i/out),i%=out,output.splice(i++,0,n)}return String.fromCodePoint(...output)},encode=function(input){const output=[];input=ucs2decode(input);const inputLength=input.length;let n=initialN,delta=0,bias=initialBias;for(let currentValue of input)if(currentValue<128)output.push(stringFromCharCode(currentValue));const basicLength=output.length;let handledCPCount=basicLength;if(basicLength)output.push(delimiter);while(handledCPCount=n&¤tValuefloor((maxInt-delta)/handledCPCountPlusOne))error(\"overflow\");delta+=(m-n)*handledCPCountPlusOne,n=m;for(let currentValue of input){if(currentValuemaxInt)error(\"overflow\");if(currentValue===n){let q=delta;for(let k=base;;k+=base){const t=k<=bias\?tMin:k>=bias+tMax\?tMax:k-bias;if(q()=>(mod||cb((mod={exports:{}}).exports,mod),mod.exports),Buffer=@requireNativeModule(\"node:buffer\").Buffer,require_object_keys=__commonJS((exports,module)=>{var objectKeys=Object.keys||function(){var hasOwnProperty=Object.prototype.hasOwnProperty,hasDontEnumBug=!{toString:null}.propertyIsEnumerable(\"toString\"),dontEnums=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],dontEnumsLength=dontEnums.length;return function(obj){if(typeof obj!==\"function\"&&(typeof obj!==\"object\"||obj===null))@throwTypeError(\"Object.keys called on non-object\");var result=[],prop,i;for(prop in obj)if(hasOwnProperty.call(obj,prop))result.push(prop);if(hasDontEnumBug){for(i=0;i{var ParsedQueryString=function(){},unescapeBuffer=function(s,decodeSpaces){var out=Buffer.allocUnsafe(s.length),state=0,n,m,hexchar,c;for(var inIndex=0,outIndex=0;;inIndex++){if(inIndex0){if(out[outIndex++]=37,state===2)out[outIndex++]=hexchar}break}switch(state){case 0:switch(c){case 37:n=0,m=0,state=1;break;case 43:if(decodeSpaces)c=32;default:out[outIndex++]=c;break}break;case 1:if(hexchar=c,n=unhexTable[c],!(n>=0)){out[outIndex++]=37,out[outIndex++]=c,state=0;break}state=2;break;case 2:if(state=0,m=unhexTable[c],!(m>=0)){out[outIndex++]=37,out[outIndex++]=hexchar,out[outIndex++]=c;break}out[outIndex++]=16*n+m;break}}return out.slice(0,outIndex)},qsUnescape=function(s,decodeSpaces){try{return decodeURIComponent(s)}catch(e){return QueryString.unescapeBuffer(s,decodeSpaces).toString()}},qsEscape=function(str){if(typeof str!==\"string\")if(typeof str===\"object\")str=String(str);else str+=\"\";var out=\"\",lastPos=0;for(var i2=0;i2>6]+hexTable[128|c&63];continue}if(c<55296||c>=57344){lastPos=i2+1,out+=hexTable[224|c>>12]+hexTable[128|c>>6&63]+hexTable[128|c&63];continue}++i2;var c2;if(i2>18]+hexTable[128|c>>12&63]+hexTable[128|c>>6&63]+hexTable[128|c&63]}if(lastPos===0)return str;if(lastPos0\?options.maxKeys:-1;var decode=QueryString.unescape;if(options&&typeof options.decodeURIComponent===\"function\")decode=options.decodeURIComponent;const customDecode=decode!==qsUnescape,keys=[];var posIdx=0,lastPos=0,sepIdx=0,eqIdx=0,key=\"\",value=\"\",keyEncoded=customDecode,valEncoded=customDecode,encodeCheck=0;for(var i2=0;i2sepLen||i2===0)if(indexOf(keys,key)===-1)obj[key]=value,keys[keys.length]=key;else{const curValue=obj[key]||\"\";if(curValue.pop)curValue[curValue.length]=value;else if(curValue)obj[key]=[curValue,value]}else if(i2===1)delete obj[key];if(--pairs===0)break;keyEncoded=valEncoded=customDecode,encodeCheck=0,key=value=\"\",posIdx=lastPos,lastPos=i2+1,sepIdx=eqIdx=0}continue}else if(sepIdx=0,!valEncoded)if(code===37)encodeCheck=1;else if(encodeCheck>0&&(code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102)){if(++encodeCheck===3)valEncoded=!0}else encodeCheck=0;if(eqIdx0&&(code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102)){if(++encodeCheck===3)keyEncoded=!0}else encodeCheck=0}if(code===43){if(eqIdx0)){if(lastPosObject.prototype.toString.call(arg)===\"[object Array]\",indexOf=(arr,searchElement,fromIndex)=>{var k;if(arr==null)@throwTypeError('\"arr\" is null or not defined');var o=Object(arr),len=o.length>>>0;if(len===0)return-1;var n=fromIndex|0;if(n>=len)return-1;k=Math.max(n>=0\?n:len-Math.abs(n),0);while(k{},SymbolAsyncIterator=Symbol.asyncIterator,SymbolIterator=Symbol.iterator,SymbolFor=Symbol.for,SymbolReplace=Symbol.replace,ArrayFrom=Array.from,ArrayIsArray=Array.isArray,ArrayPrototypeFilter=Array.prototype.filter,ArrayPrototypeSort=Array.prototype.sort,ArrayPrototypeIndexOf=Array.prototype.indexOf,ArrayPrototypeJoin=Array.prototype.join,ArrayPrototypeMap=Array.prototype.map,ArrayPrototypePop=Array.prototype.pop,ArrayPrototypePush=Array.prototype.push,ArrayPrototypeSlice=Array.prototype.slice,ArrayPrototypeSplice=Array.prototype.splice,ArrayPrototypeReverse=Array.prototype.reverse,ArrayPrototypeShift=Array.prototype.shift,ArrayPrototypeUnshift=Array.prototype.unshift,RegExpPrototypeExec=RegExp.prototype.exec,RegExpPrototypeSymbolReplace=RegExp.prototype[SymbolReplace],StringFromCharCode=String.fromCharCode,StringPrototypeCharCodeAt=String.prototype.charCodeAt,StringPrototypeCodePointAt=String.prototype.codePointAt,StringPrototypeSlice=String.prototype.slice,StringPrototypeToLowerCase=String.prototype.toLowerCase,StringPrototypeEndsWith=String.prototype.endsWith,StringPrototypeRepeat=String.prototype.repeat,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeTrim=String.prototype.trim,StringPrototypeNormalize=String.prototype.normalize,NumberIsNaN=Number.isNaN,NumberIsFinite=Number.isFinite,NumberIsInteger=Number.isInteger,NumberMAX_SAFE_INTEGER=Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER=Number.MIN_SAFE_INTEGER,MathCeil=Math.ceil,MathFloor=Math.floor,MathMax=Math.max,MathMaxApply=Math.max.apply,DateNow=Date.now,FunctionPrototype=Function.prototype,StringPrototype=String.prototype,StringPrototypeSymbolIterator=StringPrototype[SymbolIterator],StringIteratorPrototypeNext=StringPrototypeSymbolIterator.call(\"\").next,ObjectSetPrototypeOf=Object.setPrototypeOf,ObjectDefineProperty=Object.defineProperty,ObjectDefineProperties=Object.defineProperties,ObjectFreeze=Object.freeze,ObjectAssign=Object.assign,ObjectCreate=Object.create,ObjectKeys=Object.keys,ObjectSeal=Object.seal,createSafeIterator=(factory,next)=>{class SafeIterator{#iterator;constructor(iterable){this.#iterator=factory.call(iterable)}next(){return next.call(this.#iterator)}[SymbolIterator](){return this}}return ObjectSetPrototypeOf(SafeIterator.prototype,null),ObjectFreeze(SafeIterator.prototype),ObjectFreeze(SafeIterator),SafeIterator},SafeStringIterator=createSafeIterator(StringPrototypeSymbolIterator,StringIteratorPrototypeNext),isFullWidthCodePoint=(code)=>{return code>=4352&&(code<=4447||code===9001||code===9002||code>=11904&&code<=12871&&code!==12351||code>=12880&&code<=19903||code>=19968&&code<=42182||code>=43360&&code<=43388||code>=44032&&code<=55203||code>=63744&&code<=64255||code>=65040&&code<=65049||code>=65072&&code<=65131||code>=65281&&code<=65376||code>=65504&&code<=65510||code>=110592&&code<=110593||code>=127488&&code<=127569||code>=127744&&code<=128591||code>=131072&&code<=262141)},isZeroWidthCodePoint=(code)=>{return code<=31||code>=127&&code<=159||code>=768&&code<=879||code>=8203&&code<=8207||code>=8400&&code<=8447||code>=65024&&code<=65039||code>=65056&&code<=65071||code>=917760&&code<=917999},getStringWidth=function getStringWidth(str,removeControlChars=!0){var width=0;if(removeControlChars)str=stripVTControlCharacters(str);str=StringPrototypeNormalize.call(str,\"NFC\");for(var char of new SafeStringIterator(str)){var code=StringPrototypeCodePointAt.call(char,0);if(isFullWidthCodePoint(code))width+=2;else if(!isZeroWidthCodePoint(code))width++}return width},ansiPattern=\"[\\\\u001B\\\\u009B][[\\\\]()#;\?]*(\?:(\?:(\?:(\?:;[-a-zA-Z\\\\d\\\\/#&.:=\?%@~_]+)*|[a-zA-Z\\\\d]+(\?:;[-a-zA-Z\\\\d\\\\/#&.:=\?%@~_]*)*)\?\\\\u0007)|(\?:(\?:\\\\d{1,4}(\?:;\\\\d{0,4})*)\?[\\\\dA-PR-TZcf-ntqry=><~]))\",ansi=new RegExp(ansiPattern,\"g\");function stripVTControlCharacters(str){return validateString(str,\"str\"),RegExpPrototypeSymbolReplace.call(ansi,str,\"\")}var kCustomPromisifiedSymbol=SymbolFor(\"nodejs.util.promisify.custom\"),kCustomPromisifyArgsSymbol=Symbol(\"customPromisifyArgs\");function promisify(original){if(validateFunction(original,\"original\"),original[kCustomPromisifiedSymbol]){var fn=original[kCustomPromisifiedSymbol];return validateFunction(fn,\"util.promisify.custom\"),ObjectDefineProperty(fn,kCustomPromisifiedSymbol,{__proto__:null,value:fn,enumerable:!1,writable:!1,configurable:!0})}var argumentNames=original[kCustomPromisifyArgsSymbol];function fn(...args){return new Promise((resolve,reject)=>{ArrayPrototypePush.call(args,(err,...values)=>{if(err)return reject(err);if(argumentNames!==void 0&&values.length>1){var obj={};for(var i2=0;i2max)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}function validateUint32(value,name,positive=!1){if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE(name,\"number\",value);if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);var min=positive\?1:0,max=4294967295;if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}function CSI(strings,...args){var ret=`${kEscape}[`;for(var n=0;n1&&StringPrototypeCodePointAt.call(str,i-2)>=kUTF16SurrogateThreshold||StringPrototypeCodePointAt.call(str,i-1)>=kUTF16SurrogateThreshold)return 2;return 1}function charLengthAt(str,i){if(str.length<=i)return 1;return StringPrototypeCodePointAt.call(str,i)>=kUTF16SurrogateThreshold\?2:1}function*emitKeys(stream){while(!0){var ch=yield,s=ch,escaped=!1,keySeq=null,keyName,keyCtrl2=!1,keyMeta=!1,keyShift=!1;if(ch===kEscape){if(escaped=!0,s+=ch=yield,ch===kEscape)s+=ch=yield}if(escaped&&(ch===\"O\"||ch===\"[\")){var code=ch,modifier=0;if(ch===\"O\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")modifier=(ch>>0)-1,s+=ch=yield;code+=ch}else if(ch===\"[\"){if(s+=ch=yield,ch===\"[\")code+=ch,s+=ch=yield;var cmdStart=s.length-1;if(ch>=\"0\"&&ch<=\"9\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")s+=ch=yield}if(ch===\";\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")s+=yield}var cmd=StringPrototypeSlice.call(s,cmdStart),match;if(match=RegExpPrototypeExec.call(/^(\\d\\d\?)(;(\\d))\?([~^$])$/,cmd))code+=match[1]+match[4],modifier=(match[3]||1)-1;else if(match=RegExpPrototypeExec.call(/^((\\d;)\?(\\d))\?([A-Za-z])$/,cmd))code+=match[4],modifier=(match[3]||1)-1;else code+=cmd}switch(keyCtrl2=!!(modifier&4),keyMeta=!!(modifier&10),keyShift=!!(modifier&1),code){case\"[P\":keyName=\"f1\";break;case\"[Q\":keyName=\"f2\";break;case\"[R\":keyName=\"f3\";break;case\"[S\":keyName=\"f4\";break;case\"OP\":keyName=\"f1\";break;case\"OQ\":keyName=\"f2\";break;case\"OR\":keyName=\"f3\";break;case\"OS\":keyName=\"f4\";break;case\"[11~\":keyName=\"f1\";break;case\"[12~\":keyName=\"f2\";break;case\"[13~\":keyName=\"f3\";break;case\"[14~\":keyName=\"f4\";break;case\"[[A\":keyName=\"f1\";break;case\"[[B\":keyName=\"f2\";break;case\"[[C\":keyName=\"f3\";break;case\"[[D\":keyName=\"f4\";break;case\"[[E\":keyName=\"f5\";break;case\"[15~\":keyName=\"f5\";break;case\"[17~\":keyName=\"f6\";break;case\"[18~\":keyName=\"f7\";break;case\"[19~\":keyName=\"f8\";break;case\"[20~\":keyName=\"f9\";break;case\"[21~\":keyName=\"f10\";break;case\"[23~\":keyName=\"f11\";break;case\"[24~\":keyName=\"f12\";break;case\"[A\":keyName=\"up\";break;case\"[B\":keyName=\"down\";break;case\"[C\":keyName=\"right\";break;case\"[D\":keyName=\"left\";break;case\"[E\":keyName=\"clear\";break;case\"[F\":keyName=\"end\";break;case\"[H\":keyName=\"home\";break;case\"OA\":keyName=\"up\";break;case\"OB\":keyName=\"down\";break;case\"OC\":keyName=\"right\";break;case\"OD\":keyName=\"left\";break;case\"OE\":keyName=\"clear\";break;case\"OF\":keyName=\"end\";break;case\"OH\":keyName=\"home\";break;case\"[1~\":keyName=\"home\";break;case\"[2~\":keyName=\"insert\";break;case\"[3~\":keyName=\"delete\";break;case\"[4~\":keyName=\"end\";break;case\"[5~\":keyName=\"pageup\";break;case\"[6~\":keyName=\"pagedown\";break;case\"[[5~\":keyName=\"pageup\";break;case\"[[6~\":keyName=\"pagedown\";break;case\"[7~\":keyName=\"home\";break;case\"[8~\":keyName=\"end\";break;case\"[a\":keyName=\"up\",keyShift=!0;break;case\"[b\":keyName=\"down\",keyShift=!0;break;case\"[c\":keyName=\"right\",keyShift=!0;break;case\"[d\":keyName=\"left\",keyShift=!0;break;case\"[e\":keyName=\"clear\",keyShift=!0;break;case\"[2$\":keyName=\"insert\",keyShift=!0;break;case\"[3$\":keyName=\"delete\",keyShift=!0;break;case\"[5$\":keyName=\"pageup\",keyShift=!0;break;case\"[6$\":keyName=\"pagedown\",keyShift=!0;break;case\"[7$\":keyName=\"home\",keyShift=!0;break;case\"[8$\":keyName=\"end\",keyShift=!0;break;case\"Oa\":keyName=\"up\",keyCtrl2=!0;break;case\"Ob\":keyName=\"down\",keyCtrl2=!0;break;case\"Oc\":keyName=\"right\",keyCtrl2=!0;break;case\"Od\":keyName=\"left\",keyCtrl2=!0;break;case\"Oe\":keyName=\"clear\",keyCtrl2=!0;break;case\"[2^\":keyName=\"insert\",keyCtrl2=!0;break;case\"[3^\":keyName=\"delete\",keyCtrl2=!0;break;case\"[5^\":keyName=\"pageup\",keyCtrl2=!0;break;case\"[6^\":keyName=\"pagedown\",keyCtrl2=!0;break;case\"[7^\":keyName=\"home\",keyCtrl2=!0;break;case\"[8^\":keyName=\"end\",keyCtrl2=!0;break;case\"[Z\":keyName=\"tab\",keyShift=!0;break;default:keyName=\"undefined\";break}}else if(ch===\"\\r\")keyName=\"return\",keyMeta=escaped;else if(ch===\"\\n\")keyName=\"enter\",keyMeta=escaped;else if(ch===\"\\t\")keyName=\"tab\",keyMeta=escaped;else if(ch===\"\\b\"||ch===\"\\x7F\")keyName=\"backspace\",keyMeta=escaped;else if(ch===kEscape)keyName=\"escape\",keyMeta=escaped;else if(ch===\" \")keyName=\"space\",keyMeta=escaped;else if(!escaped&&ch<=\"\\x1A\")keyName=StringFromCharCode(StringPrototypeCharCodeAt.call(ch)+StringPrototypeCharCodeAt.call(\"a\")-1),keyCtrl2=!0;else if(RegExpPrototypeExec.call(/^[0-9A-Za-z]$/,ch)!==null)keyName=StringPrototypeToLowerCase.call(ch),keyShift=RegExpPrototypeExec.call(/^[A-Z]$/,ch)!==null,keyMeta=escaped;else if(escaped)keyName=ch.length\?void 0:\"escape\",keyMeta=!0;if(keySeq=s,s.length!==0&&(keyName!==void 0||escaped))stream.emit(\"keypress\",escaped\?void 0:s,{sequence:keySeq,name:keyName,ctrl:keyCtrl2,meta:keyMeta,shift:keyShift});else if(charLengthAt(s,0)===s.length)stream.emit(\"keypress\",s,{sequence:keySeq,name:keyName,ctrl:keyCtrl2,meta:keyMeta,shift:keyShift})}}function commonPrefix(strings){if(strings.length===0)return\"\";if(strings.length===1)return strings[0];var sorted=ArrayPrototypeSort.call(ArrayPrototypeSlice.call(strings)),min=sorted[0],max=sorted[sorted.length-1];for(var i=0;i0)data+=CSI`${dx}C`;if(dy<0)data+=CSI`${-dy}A`;else if(dy>0)data+=CSI`${dy}B`;return stream.write(data,callback)}function clearLine(stream,dir,callback){if(callback!==void 0)validateFunction(callback,\"callback\");if(stream===null||stream===void 0){if(typeof callback===\"function\")process.nextTick(callback,null);return!0}var type=dir<0\?kClearToLineBeginning:dir>0\?kClearToLineEnd:kClearLine;return stream.write(type,callback)}function clearScreenDown(stream,callback){if(callback!==void 0)validateFunction(callback,\"callback\");if(stream===null||stream===void 0){if(typeof callback===\"function\")process.nextTick(callback,null);return!0}return stream.write(kClearScreenDown,callback)}var KEYPRESS_DECODER=Symbol(\"keypress-decoder\"),ESCAPE_DECODER=Symbol(\"escape-decoder\"),ESCAPE_CODE_TIMEOUT=500;function emitKeypressEvents(stream,iface={}){if(stream[KEYPRESS_DECODER])return;stream[KEYPRESS_DECODER]=new StringDecoder(\"utf8\"),stream[ESCAPE_DECODER]=emitKeys(stream),stream[ESCAPE_DECODER].next();var triggerEscape=()=>stream[ESCAPE_DECODER].next(\"\"),{escapeCodeTimeout=ESCAPE_CODE_TIMEOUT}=iface,timeoutId;function onData2(input){if(stream.listenerCount(\"keypress\")>0){var string=stream[KEYPRESS_DECODER].write(input);if(string){clearTimeout(timeoutId),iface[kSawKeyPress]=charLengthAt(string,0)===string.length,iface.isCompletionEnabled=!1;var length=0;for(var character of new SafeStringIterator(string)){if(length+=character.length,length===string.length)iface.isCompletionEnabled=!0;try{if(stream[ESCAPE_DECODER].next(character),length===string.length&&character===kEscape)timeoutId=setTimeout(triggerEscape,escapeCodeTimeout)}catch(err){throw stream[ESCAPE_DECODER]=emitKeys(stream),stream[ESCAPE_DECODER].next(),err}}}}else stream.removeListener(\"data\",onData2),stream.on(\"newListener\",onNewListener)}function onNewListener(event){if(event===\"keypress\")stream.on(\"data\",onData2),stream.removeListener(\"newListener\",onNewListener)}if(stream.listenerCount(\"keypress\")>0)stream.on(\"data\",onData2);else stream.on(\"newListener\",onNewListener)}var kEmptyObject=ObjectFreeze(ObjectCreate(null)),kHistorySize=30,kMaxUndoRedoStackSize=2048,kMincrlfDelay=100,lineEnding=/\\r\?\\n|\\r(\?!\\n)/g,kMaxLengthOfKillRing=32,kLineObjectStream=Symbol(\"line object stream\"),kQuestionCancel=Symbol(\"kQuestionCancel\"),kQuestion=Symbol(\"kQuestion\"),kAddHistory=Symbol(\"_addHistory\"),kBeforeEdit=Symbol(\"_beforeEdit\"),kDecoder=Symbol(\"_decoder\"),kDeleteLeft=Symbol(\"_deleteLeft\"),kDeleteLineLeft=Symbol(\"_deleteLineLeft\"),kDeleteLineRight=Symbol(\"_deleteLineRight\"),kDeleteRight=Symbol(\"_deleteRight\"),kDeleteWordLeft=Symbol(\"_deleteWordLeft\"),kDeleteWordRight=Symbol(\"_deleteWordRight\"),kGetDisplayPos=Symbol(\"_getDisplayPos\"),kHistoryNext=Symbol(\"_historyNext\"),kHistoryPrev=Symbol(\"_historyPrev\"),kInsertString=Symbol(\"_insertString\"),kLine=Symbol(\"_line\"),kLine_buffer=Symbol(\"_line_buffer\"),kKillRing=Symbol(\"_killRing\"),kKillRingCursor=Symbol(\"_killRingCursor\"),kMoveCursor=Symbol(\"_moveCursor\"),kNormalWrite=Symbol(\"_normalWrite\"),kOldPrompt=Symbol(\"_oldPrompt\"),kOnLine=Symbol(\"_onLine\"),kPreviousKey=Symbol(\"_previousKey\"),kPrompt=Symbol(\"_prompt\"),kPushToKillRing=Symbol(\"_pushToKillRing\"),kPushToUndoStack=Symbol(\"_pushToUndoStack\"),kQuestionCallback=Symbol(\"_questionCallback\"),kRedo=Symbol(\"_redo\"),kRedoStack=Symbol(\"_redoStack\"),kRefreshLine=Symbol(\"_refreshLine\"),kSawKeyPress=Symbol(\"_sawKeyPress\"),kSawReturnAt=Symbol(\"_sawReturnAt\"),kSetRawMode=Symbol(\"_setRawMode\"),kTabComplete=Symbol(\"_tabComplete\"),kTabCompleter=Symbol(\"_tabCompleter\"),kTtyWrite=Symbol(\"_ttyWrite\"),kUndo=Symbol(\"_undo\"),kUndoStack=Symbol(\"_undoStack\"),kWordLeft=Symbol(\"_wordLeft\"),kWordRight=Symbol(\"_wordRight\"),kWriteToOutput=Symbol(\"_writeToOutput\"),kYank=Symbol(\"_yank\"),kYanking=Symbol(\"_yanking\"),kYankPop=Symbol(\"_yankPop\"),kFirstEventParam=Symbol(\"nodejs.kFirstEventParam\"),kOnSelfCloseWithTerminal=Symbol(\"_onSelfCloseWithTerminal\"),kOnSelfCloseWithoutTerminal=Symbol(\"_onSelfCloseWithoutTerminal\"),kOnKeyPress=Symbol(\"_onKeyPress\"),kOnError=Symbol(\"_onError\"),kOnData=Symbol(\"_onData\"),kOnEnd=Symbol(\"_onEnd\"),kOnTermEnd=Symbol(\"_onTermEnd\"),kOnResize=Symbol(\"_onResize\");function onSelfCloseWithTerminal(){var input=this.input,output=this.output;if(!input)throw new Error(\"Input not set, invalid state for readline!\");if(input.removeListener(\"keypress\",this[kOnKeyPress]),input.removeListener(\"error\",this[kOnError]),input.removeListener(\"end\",this[kOnTermEnd]),output!==null&&output!==void 0)output.removeListener(\"resize\",this[kOnResize])}function onSelfCloseWithoutTerminal(){var input=this.input;if(!input)throw new Error(\"Input not set, invalid state for readline!\");input.removeListener(\"data\",this[kOnData]),input.removeListener(\"error\",this[kOnError]),input.removeListener(\"end\",this[kOnEnd])}function onError(err){this.emit(\"error\",err)}function onData(data){debug(\"onData\"),this[kNormalWrite](data)}function onEnd(){if(debug(\"onEnd\"),typeof this[kLine_buffer]===\"string\"&&this[kLine_buffer].length>0)this.emit(\"line\",this[kLine_buffer]);this.close()}function onTermEnd(){if(debug(\"onTermEnd\"),typeof this.line===\"string\"&&this.line.length>0)this.emit(\"line\",this.line);this.close()}function onKeyPress(s,key){if(this[kTtyWrite](s,key),key&&key.sequence){var ch=StringPrototypeCodePointAt.call(key.sequence,0);if(ch>=55296&&ch<=57343)this[kRefreshLine]()}}function onResize(){this[kRefreshLine]()}function InterfaceConstructor(input,output,completer,terminal){if(!(this instanceof InterfaceConstructor))return new InterfaceConstructor(input,output,completer,terminal);EventEmitter.call(this),this[kOnSelfCloseWithoutTerminal]=onSelfCloseWithoutTerminal.bind(this),this[kOnSelfCloseWithTerminal]=onSelfCloseWithTerminal.bind(this),this[kOnError]=onError.bind(this),this[kOnData]=onData.bind(this),this[kOnEnd]=onEnd.bind(this),this[kOnTermEnd]=onTermEnd.bind(this),this[kOnKeyPress]=onKeyPress.bind(this),this[kOnResize]=onResize.bind(this),this[kSawReturnAt]=0,this.isCompletionEnabled=!0,this[kSawKeyPress]=!1,this[kPreviousKey]=null,this.escapeCodeTimeout=ESCAPE_CODE_TIMEOUT,this.tabSize=8;var history,historySize,removeHistoryDuplicates=!1,crlfDelay,prompt=\"> \",signal;if(input\?.input){output=input.output,completer=input.completer,terminal=input.terminal,history=input.history,historySize=input.historySize,signal=input.signal;var tabSize=input.tabSize;if(tabSize!==void 0)validateUint32(tabSize,\"tabSize\",!0),this.tabSize=tabSize;removeHistoryDuplicates=input.removeHistoryDuplicates;var inputPrompt=input.prompt;if(inputPrompt!==void 0)prompt=inputPrompt;var inputEscapeCodeTimeout=input.escapeCodeTimeout;if(inputEscapeCodeTimeout!==void 0)if(NumberIsFinite(inputEscapeCodeTimeout))this.escapeCodeTimeout=inputEscapeCodeTimeout;else throw new ERR_INVALID_ARG_VALUE(\"input.escapeCodeTimeout\",this.escapeCodeTimeout);if(signal)validateAbortSignal(signal,\"options.signal\");crlfDelay=input.crlfDelay,input=input.input}if(completer!==void 0&&typeof completer!==\"function\")throw new ERR_INVALID_ARG_VALUE(\"completer\",completer);if(history===void 0)history=[];else validateArray(history,\"history\");if(historySize===void 0)historySize=kHistorySize;if(typeof historySize!==\"number\"||NumberIsNaN(historySize)||historySize<0)throw new ERR_INVALID_ARG_VALUE(\"historySize\",historySize);if(terminal===void 0&&!(output===null||output===void 0))terminal=!!output.isTTY;if(this.line=\"\",this[kSubstringSearch]=null,this.output=output,this.input=input,this[kUndoStack]=[],this[kRedoStack]=[],this.history=history,this.historySize=historySize,this[kKillRing]=[],this[kKillRingCursor]=0,this.removeHistoryDuplicates=!!removeHistoryDuplicates,this.crlfDelay=crlfDelay\?MathMax(kMincrlfDelay,crlfDelay):kMincrlfDelay,this.completer=completer,this.setPrompt(prompt),this.terminal=!!terminal,this[kLineObjectStream]=void 0,input.on(\"error\",this[kOnError]),!this.terminal)input.on(\"data\",this[kOnData]),input.on(\"end\",this[kOnEnd]),this.once(\"close\",this[kOnSelfCloseWithoutTerminal]),this[kDecoder]=new StringDecoder(\"utf8\");else{if(emitKeypressEvents(input,this),input.on(\"keypress\",this[kOnKeyPress]),input.on(\"end\",this[kOnTermEnd]),this[kSetRawMode](!0),this.terminal=!0,this.cursor=0,this.historyIndex=-1,output!==null&&output!==void 0)output.on(\"resize\",this[kOnResize]);this.once(\"close\",this[kOnSelfCloseWithTerminal])}if(signal){var onAborted=(()=>this.close()).bind(this);if(signal.aborted)process.nextTick(onAborted);else signal.addEventListener(\"abort\",onAborted,{once:!0}),this.once(\"close\",()=>signal.removeEventListener(\"abort\",onAborted))}this.line=\"\",input.resume()}InterfaceConstructor.prototype={},ObjectSetPrototypeOf(InterfaceConstructor.prototype,EventEmitter.prototype);var _Interface=class Interface2 extends InterfaceConstructor{constructor(input,output,completer,terminal){super(input,output,completer,terminal)}get columns(){var output=this.output;if(output&&output.columns)return output.columns;return Infinity}setPrompt(prompt){this[kPrompt]=prompt}getPrompt(){return this[kPrompt]}[kSetRawMode](mode){var input=this.input,{setRawMode,wasInRawMode}=input;return debug(\"setRawMode\",mode,\"set!\"),wasInRawMode}prompt(preserveCursor){if(this.paused)this.resume();if(this.terminal&&process.env.TERM!==\"dumb\"){if(!preserveCursor)this.cursor=0;this[kRefreshLine]()}else this[kWriteToOutput](this[kPrompt])}[kQuestion](query,cb){if(this.closed)throw new ERR_USE_AFTER_CLOSE(\"readline\");if(this[kQuestionCallback])this.prompt();else this[kOldPrompt]=this[kPrompt],this.setPrompt(query),this[kQuestionCallback]=cb,this.prompt()}[kOnLine](line){if(this[kQuestionCallback]){var cb=this[kQuestionCallback];this[kQuestionCallback]=null,this.setPrompt(this[kOldPrompt]),cb(line)}else this.emit(\"line\",line)}[kBeforeEdit](oldText,oldCursor){this[kPushToUndoStack](oldText,oldCursor)}[kQuestionCancel](){if(this[kQuestionCallback])this[kQuestionCallback]=null,this.setPrompt(this[kOldPrompt]),this.clearLine()}[kWriteToOutput](stringToWrite){if(validateString(stringToWrite,\"stringToWrite\"),this.output!==null&&this.output!==void 0)this.output.write(stringToWrite)}[kAddHistory](){if(this.line.length===0)return\"\";if(this.historySize===0)return this.line;if(StringPrototypeTrim.call(this.line).length===0)return this.line;if(this.history.length===0||this.history[0]!==this.line){if(this.removeHistoryDuplicates){var dupIndex=ArrayPrototypeIndexOf.call(this.history,this.line);if(dupIndex!==-1)ArrayPrototypeSplice.call(this.history,dupIndex,1)}if(ArrayPrototypeUnshift.call(this.history,this.line),this.history.length>this.historySize)ArrayPrototypePop.call(this.history)}this.historyIndex=-1;var line=this.history[0];return this.emit(\"history\",this.history),line}[kRefreshLine](){var line=this[kPrompt]+this.line,dispPos=this[kGetDisplayPos](line),lineCols=dispPos.cols,lineRows=dispPos.rows,cursorPos=this.getCursorPos(),prevRows=this.prevRows||0;if(prevRows>0)moveCursor(this.output,0,-prevRows);if(cursorTo(this.output,0),clearScreenDown(this.output),this[kWriteToOutput](line),lineCols===0)this[kWriteToOutput](\" \");cursorTo(this.output,cursorPos.cols);var diff=lineRows-cursorPos.rows;if(diff>0)moveCursor(this.output,0,-diff);this.prevRows=cursorPos.rows}close(){if(this.closed)return;if(this.pause(),this.terminal)this[kSetRawMode](!1);this.closed=!0,this.emit(\"close\")}pause(){if(this.paused)return;return this.input.pause(),this.paused=!0,this.emit(\"pause\"),this}resume(){if(!this.paused)return;return this.input.resume(),this.paused=!1,this.emit(\"resume\"),this}write(d,key){if(this.paused)this.resume();if(this.terminal)this[kTtyWrite](d,key);else this[kNormalWrite](d)}[kNormalWrite](b){if(b===void 0)return;var string=this[kDecoder].write(b);if(this[kSawReturnAt]&&DateNow()-this[kSawReturnAt]<=this.crlfDelay){if(StringPrototypeCodePointAt.call(string)===10)string=StringPrototypeSlice.call(string,1);this[kSawReturnAt]=0}var newPartContainsEnding=RegExpPrototypeExec.call(lineEnding,string);if(newPartContainsEnding!==null){if(this[kLine_buffer])string=this[kLine_buffer]+string,this[kLine_buffer]=null,newPartContainsEnding=RegExpPrototypeExec.call(lineEnding,string);this[kSawReturnAt]=StringPrototypeEndsWith.call(string,\"\\r\")\?DateNow():0;var indexes=[0,newPartContainsEnding.index,lineEnding.lastIndex],nextMatch;while((nextMatch=RegExpPrototypeExec.call(lineEnding,string))!==null)ArrayPrototypePush.call(indexes,nextMatch.index,lineEnding.lastIndex);var lastIndex=indexes.length-1;this[kLine_buffer]=StringPrototypeSlice.call(string,indexes[lastIndex]);for(var i=1;ie!==\"\"));if(StringPrototypeStartsWith.call(prefix,completeOn)&&prefix.length>completeOn.length){this[kInsertString](StringPrototypeSlice.call(prefix,completeOn.length));return}else if(!StringPrototypeStartsWith.call(completeOn,prefix)){this.line=StringPrototypeSlice.call(this.line,0,this.cursor-completeOn.length)+prefix+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor=this.cursor-completeOn.length+prefix.length,this._refreshLine();return}if(!lastKeypressWasTab)return;this[kBeforeEdit](this.line,this.cursor);var completionsWidth=ArrayPrototypeMap.call(completions,(e)=>getStringWidth(e)),width=MathMaxApply(completionsWidth)+2,maxColumns=MathFloor(this.columns/width)||1;if(maxColumns===Infinity)maxColumns=1;var output=\"\\r\\n\",lineIndex=0,whitespace=0;for(var i=0;i0){var leading=StringPrototypeSlice.call(this.line,0,this.cursor),reversed=ArrayPrototypeJoin.call(ArrayPrototypeReverse.call(ArrayFrom(leading)),\"\"),match=RegExpPrototypeExec.call(/^\\s*(\?:[^\\w\\s]+|\\w+)\?/,reversed);this[kMoveCursor](-match[0].length)}}[kWordRight](){if(this.cursor0&&this.line.length>0){this[kBeforeEdit](this.line,this.cursor);var charSize=charLengthLeft(this.line,this.cursor);this.line=StringPrototypeSlice.call(this.line,0,this.cursor-charSize)+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor-=charSize,this[kRefreshLine]()}}[kDeleteRight](){if(this.cursor0){this[kBeforeEdit](this.line,this.cursor);var leading=StringPrototypeSlice.call(this.line,0,this.cursor),reversed=ArrayPrototypeJoin.call(ArrayPrototypeReverse.call(ArrayFrom(leading)),\"\"),match=RegExpPrototypeExec.call(/^\\s*(\?:[^\\w\\s]+|\\w+)\?/,reversed);leading=StringPrototypeSlice.call(leading,0,leading.length-match[0].length),this.line=leading+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor=leading.length,this[kRefreshLine]()}}[kDeleteWordRight](){if(this.cursorkMaxLengthOfKillRing)ArrayPrototypePop.call(this[kKillRing])}[kYank](){if(this[kKillRing].length>0)this[kYanking]=!0,this[kInsertString](this[kKillRing][this[kKillRingCursor]])}[kYankPop](){if(!this[kYanking])return;if(this[kKillRing].length>1){var lastYank=this[kKillRing][this[kKillRingCursor]];if(this[kKillRingCursor]++,this[kKillRingCursor]>=this[kKillRing].length)this[kKillRingCursor]=0;var currentYank=this[kKillRing][this[kKillRingCursor]],head=StringPrototypeSlice.call(this.line,0,this.cursor-lastYank.length),tail=StringPrototypeSlice.call(this.line,this.cursor);this.line=head+currentYank+tail,this.cursor=head.length+currentYank.length,this[kRefreshLine]()}}clearLine(){this[kMoveCursor](Infinity),this[kWriteToOutput](\"\\r\\n\"),this.line=\"\",this.cursor=0,this.prevRows=0}[kLine](){var line=this[kAddHistory]();this[kUndoStack]=[],this[kRedoStack]=[],this.clearLine(),this[kOnLine](line)}[kPushToUndoStack](text,cursor){if(ArrayPrototypePush.call(this[kUndoStack],{text,cursor})>kMaxUndoRedoStackSize)ArrayPrototypeShift.call(this[kUndoStack])}[kUndo](){if(this[kUndoStack].length<=0)return;ArrayPrototypePush.call(this[kRedoStack],{text:this.line,cursor:this.cursor});var entry=ArrayPrototypePop.call(this[kUndoStack]);this.line=entry.text,this.cursor=entry.cursor,this[kRefreshLine]()}[kRedo](){if(this[kRedoStack].length<=0)return;ArrayPrototypePush.call(this[kUndoStack],{text:this.line,cursor:this.cursor});var entry=ArrayPrototypePop.call(this[kRedoStack]);this.line=entry.text,this.cursor=entry.cursor,this[kRefreshLine]()}[kHistoryNext](){if(this.historyIndex>=0){this[kBeforeEdit](this.line,this.cursor);var search=this[kSubstringSearch]||\"\",index=this.historyIndex-1;while(index>=0&&(!StringPrototypeStartsWith.call(this.history[index],search)||this.line===this.history[index]))index--;if(index===-1)this.line=search;else this.line=this.history[index];this.historyIndex=index,this.cursor=this.line.length,this[kRefreshLine]()}}[kHistoryPrev](){if(this.historyIndexthis.line.length)this.cursor=this.line.length;var newPos=this.getCursorPos();if(oldPos.rows===newPos.rows){var diffWidth=newPos.cols-oldPos.cols;moveCursor(this.output,diffWidth,0)}else this[kRefreshLine]()}[kTtyWrite](s,key){var previousKey=this[kPreviousKey];key=key||kEmptyObject,this[kPreviousKey]=key;var{name:keyName,meta:keyMeta,ctrl:keyCtrl2,shift:keyShift,sequence:keySeq}=key;if(!keyMeta||keyName!==\"y\")this[kYanking]=!1;if((keyName===\"up\"||keyName===\"down\")&&!keyCtrl2&&!keyMeta&&!keyShift){if(this[kSubstringSearch]===null)this[kSubstringSearch]=StringPrototypeSlice.call(this.line,0,this.cursor)}else if(this[kSubstringSearch]!==null){if(this[kSubstringSearch]=null,this.history.length===this.historyIndex)this.historyIndex=-1}if(typeof keySeq===\"string\")switch(StringPrototypeCodePointAt.call(keySeq,0)){case 31:this[kUndo]();return;case 30:this[kRedo]();return;default:break}if(keyName===\"escape\")return;if(keyCtrl2&&keyShift)switch(keyName){case\"backspace\":this[kDeleteLineLeft]();break;case\"delete\":this[kDeleteLineRight]();break}else if(keyCtrl2)switch(keyName){case\"c\":if(this.listenerCount(\"SIGINT\")>0)this.emit(\"SIGINT\");else this.close();break;case\"h\":this[kDeleteLeft]();break;case\"d\":if(this.cursor===0&&this.line.length===0)this.close();else if(this.cursor0)this.emit(\"SIGTSTP\");else process.once(\"SIGCONT\",()=>{if(!this.paused)this.pause(),this.emit(\"SIGCONT\");this[kSetRawMode](!0),this[kRefreshLine]()}),this[kSetRawMode](!1),process.kill(process.pid,\"SIGTSTP\");break;case\"w\":case\"backspace\":this[kDeleteWordLeft]();break;case\"delete\":this[kDeleteWordRight]();break;case\"left\":this[kWordLeft]();break;case\"right\":this[kWordRight]();break}else if(keyMeta)switch(keyName){case\"b\":this[kWordLeft]();break;case\"f\":this[kWordRight]();break;case\"d\":case\"delete\":this[kDeleteWordRight]();break;case\"backspace\":this[kDeleteWordLeft]();break;case\"y\":this[kYankPop]();break}else{if(this[kSawReturnAt]&&keyName!==\"enter\")this[kSawReturnAt]=0;switch(keyName){case\"return\":this[kSawReturnAt]=DateNow(),this[kLine]();break;case\"enter\":if(this[kSawReturnAt]===0||DateNow()-this[kSawReturnAt]>this.crlfDelay)this[kLine]();this[kSawReturnAt]=0;break;case\"backspace\":this[kDeleteLeft]();break;case\"delete\":this[kDeleteRight]();break;case\"left\":this[kMoveCursor](-charLengthLeft(this.line,this.cursor));break;case\"right\":this[kMoveCursor](+charLengthAt(this.line,this.cursor));break;case\"home\":this[kMoveCursor]((-Infinity));break;case\"end\":this[kMoveCursor](Infinity);break;case\"up\":this[kHistoryPrev]();break;case\"down\":this[kHistoryNext]();break;case\"tab\":if(typeof this.completer===\"function\"&&this.isCompletionEnabled){var lastKeypressWasTab=previousKey&&previousKey.name===\"tab\";this[kTabComplete](lastKeypressWasTab);break}default:if(typeof s===\"string\"&&s){var nextMatch=RegExpPrototypeExec.call(lineEnding,s);if(nextMatch!==null){this[kInsertString](StringPrototypeSlice.call(s,0,nextMatch.index));var{lastIndex}=lineEnding;while((nextMatch=RegExpPrototypeExec.call(lineEnding,s))!==null)this[kLine](),this[kInsertString](StringPrototypeSlice.call(s,lastIndex,nextMatch.index)),{lastIndex}=lineEnding;if(lastIndex===s.length)this[kLine]()}else this[kInsertString](s)}}}}[SymbolAsyncIterator](){if(this[kLineObjectStream]===void 0)this[kLineObjectStream]=EventEmitter.on(this,\"line\",{close:[\"close\"],highWatermark:1024,[kFirstEventParam]:!0});return this[kLineObjectStream]}};function Interface(input,output,completer,terminal){if(!(this instanceof Interface))return new Interface(input,output,completer,terminal);if(input\?.input&&typeof input.completer===\"function\"&&input.completer.length!==2){var{completer}=input;input.completer=(v,cb)=>cb(null,completer(v))}else if(typeof completer===\"function\"&&completer.length!==2){var realCompleter=completer;completer=(v,cb)=>cb(null,realCompleter(v))}if(InterfaceConstructor.call(this,input,output,completer,terminal),process.env.TERM===\"dumb\")this._ttyWrite=_ttyWriteDumb.bind(this)}Interface.prototype={},ObjectSetPrototypeOf(Interface.prototype,_Interface.prototype),ObjectSetPrototypeOf(Interface,_Interface),Interface.prototype.question=function question(query,options,cb){if(cb=typeof options===\"function\"\?options:cb,options===null||typeof options!==\"object\")options=kEmptyObject;var signal=options\?.signal;if(signal){if(validateAbortSignal(signal,\"options.signal\"),signal.aborted)return;var onAbort=()=>{this[kQuestionCancel]()};signal.addEventListener(\"abort\",onAbort,{once:!0});var cleanup=()=>{signal.removeEventListener(\"abort\",onAbort)},originalCb=cb;cb=typeof cb===\"function\"\?(answer)=>{return cleanup(),originalCb(answer)}:cleanup}if(typeof cb===\"function\")this[kQuestion](query,cb)},Interface.prototype.question[promisify.custom]=function question(query,options){if(options===null||typeof options!==\"object\")options=kEmptyObject;var signal=options\?.signal;if(signal&&signal.aborted)return PromiseReject(new AbortError(void 0,{cause:signal.reason}));return new Promise((resolve,reject)=>{var cb=resolve;if(signal){var onAbort=()=>{reject(new AbortError(void 0,{cause:signal.reason}))};signal.addEventListener(\"abort\",onAbort,{once:!0}),cb=(answer)=>{signal.removeEventListener(\"abort\",onAbort),resolve(answer)}}this.question(query,options,cb)})};function createInterface(input,output,completer,terminal){return new Interface(input,output,completer,terminal)}ObjectDefineProperties(Interface.prototype,{[kSetRawMode]:{__proto__:null,get(){return this._setRawMode}},[kOnLine]:{__proto__:null,get(){return this._onLine}},[kWriteToOutput]:{__proto__:null,get(){return this._writeToOutput}},[kAddHistory]:{__proto__:null,get(){return this._addHistory}},[kRefreshLine]:{__proto__:null,get(){return this._refreshLine}},[kNormalWrite]:{__proto__:null,get(){return this._normalWrite}},[kInsertString]:{__proto__:null,get(){return this._insertString}},[kTabComplete]:{__proto__:null,get(){return this._tabComplete}},[kWordLeft]:{__proto__:null,get(){return this._wordLeft}},[kWordRight]:{__proto__:null,get(){return this._wordRight}},[kDeleteLeft]:{__proto__:null,get(){return this._deleteLeft}},[kDeleteRight]:{__proto__:null,get(){return this._deleteRight}},[kDeleteWordLeft]:{__proto__:null,get(){return this._deleteWordLeft}},[kDeleteWordRight]:{__proto__:null,get(){return this._deleteWordRight}},[kDeleteLineLeft]:{__proto__:null,get(){return this._deleteLineLeft}},[kDeleteLineRight]:{__proto__:null,get(){return this._deleteLineRight}},[kLine]:{__proto__:null,get(){return this._line}},[kHistoryNext]:{__proto__:null,get(){return this._historyNext}},[kHistoryPrev]:{__proto__:null,get(){return this._historyPrev}},[kGetDisplayPos]:{__proto__:null,get(){return this._getDisplayPos}},[kMoveCursor]:{__proto__:null,get(){return this._moveCursor}},[kTtyWrite]:{__proto__:null,get(){return this._ttyWrite}},_decoder:{__proto__:null,get(){return this[kDecoder]},set(value){this[kDecoder]=value}},_line_buffer:{__proto__:null,get(){return this[kLine_buffer]},set(value){this[kLine_buffer]=value}},_oldPrompt:{__proto__:null,get(){return this[kOldPrompt]},set(value){this[kOldPrompt]=value}},_previousKey:{__proto__:null,get(){return this[kPreviousKey]},set(value){this[kPreviousKey]=value}},_prompt:{__proto__:null,get(){return this[kPrompt]},set(value){this[kPrompt]=value}},_questionCallback:{__proto__:null,get(){return this[kQuestionCallback]},set(value){this[kQuestionCallback]=value}},_sawKeyPress:{__proto__:null,get(){return this[kSawKeyPress]},set(value){this[kSawKeyPress]=value}},_sawReturnAt:{__proto__:null,get(){return this[kSawReturnAt]},set(value){this[kSawReturnAt]=value}}}),Interface.prototype._setRawMode=_Interface.prototype[kSetRawMode],Interface.prototype._onLine=_Interface.prototype[kOnLine],Interface.prototype._writeToOutput=_Interface.prototype[kWriteToOutput],Interface.prototype._addHistory=_Interface.prototype[kAddHistory],Interface.prototype._refreshLine=_Interface.prototype[kRefreshLine],Interface.prototype._normalWrite=_Interface.prototype[kNormalWrite],Interface.prototype._insertString=_Interface.prototype[kInsertString],Interface.prototype._tabComplete=function(lastKeypressWasTab){this.pause();var string=StringPrototypeSlice.call(this.line,0,this.cursor);this.completer(string,(err,value)=>{if(this.resume(),err){this._writeToOutput(`Tab completion error: ${inspect(err)}`);return}this[kTabCompleter](lastKeypressWasTab,value)})},Interface.prototype._wordLeft=_Interface.prototype[kWordLeft],Interface.prototype._wordRight=_Interface.prototype[kWordRight],Interface.prototype._deleteLeft=_Interface.prototype[kDeleteLeft],Interface.prototype._deleteRight=_Interface.prototype[kDeleteRight],Interface.prototype._deleteWordLeft=_Interface.prototype[kDeleteWordLeft],Interface.prototype._deleteWordRight=_Interface.prototype[kDeleteWordRight],Interface.prototype._deleteLineLeft=_Interface.prototype[kDeleteLineLeft],Interface.prototype._deleteLineRight=_Interface.prototype[kDeleteLineRight],Interface.prototype._line=_Interface.prototype[kLine],Interface.prototype._historyNext=_Interface.prototype[kHistoryNext],Interface.prototype._historyPrev=_Interface.prototype[kHistoryPrev],Interface.prototype._getDisplayPos=_Interface.prototype[kGetDisplayPos],Interface.prototype._getCursorPos=_Interface.prototype.getCursorPos,Interface.prototype._moveCursor=_Interface.prototype[kMoveCursor],Interface.prototype._ttyWrite=_Interface.prototype[kTtyWrite];function _ttyWriteDumb(s,key){if(key=key||kEmptyObject,key.name===\"escape\")return;if(this[kSawReturnAt]&&key.name!==\"enter\")this[kSawReturnAt]=0;if(keyCtrl){if(key.name===\"c\"){if(this.listenerCount(\"SIGINT\")>0)this.emit(\"SIGINT\");else this.close();return}else if(key.name===\"d\"){this.close();return}}switch(key.name){case\"return\":this[kSawReturnAt]=DateNow(),this._line();break;case\"enter\":if(this[kSawReturnAt]===0||DateNow()-this[kSawReturnAt]>this.crlfDelay)this._line();this[kSawReturnAt]=0;break;default:if(typeof s===\"string\"&&s)this.line+=s,this.cursor+=s.length,this._writeToOutput(s)}}class Readline{#autoCommit=!1;#stream;#todo=[];constructor(stream,options=void 0){if(isWritable\?\?=(@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34)).isWritable,!isWritable(stream))throw new ERR_INVALID_ARG_TYPE(\"stream\",\"Writable\",stream);if(this.#stream=stream,options\?.autoCommit!=null)validateBoolean(options.autoCommit,\"options.autoCommit\"),this.#autoCommit=options.autoCommit}cursorTo(x,y=void 0){if(validateInteger(x,\"x\"),y!=null)validateInteger(y,\"y\");var data=y==null\?CSI`${x+1}G`:CSI`${y+1};${x+1}H`;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data);return this}moveCursor(dx,dy){if(dx||dy){validateInteger(dx,\"dx\"),validateInteger(dy,\"dy\");var data=\"\";if(dx<0)data+=CSI`${-dx}D`;else if(dx>0)data+=CSI`${dx}C`;if(dy<0)data+=CSI`${-dy}A`;else if(dy>0)data+=CSI`${dy}B`;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data)}return this}clearLine(dir){validateInteger(dir,\"dir\",-1,1);var data=dir<0\?kClearToLineBeginning:dir>0\?kClearToLineEnd:kClearLine;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data);return this}clearScreenDown(){if(this.#autoCommit)process.nextTick(()=>this.#stream.write(kClearScreenDown));else ArrayPrototypePush.call(this.#todo,kClearScreenDown);return this}commit(){return new Promise((resolve)=>{this.#stream.write(ArrayPrototypeJoin.call(this.#todo,\"\"),resolve),this.#todo=[]})}rollback(){return this.#todo=[],this}}var PromisesInterface=class Interface2 extends _Interface{constructor(input,output,completer,terminal){super(input,output,completer,terminal)}question(query,options=kEmptyObject){var signal=options\?.signal;if(signal){if(validateAbortSignal(signal,\"options.signal\"),signal.aborted)return PromiseReject(new AbortError(void 0,{cause:signal.reason}))}return new Promise((resolve,reject)=>{var cb=resolve;if(options\?.signal){var onAbort=()=>{this[kQuestionCancel](),reject(new AbortError(void 0,{cause:signal.reason}))};signal.addEventListener(\"abort\",onAbort,{once:!0}),cb=(answer)=>{signal.removeEventListener(\"abort\",onAbort),resolve(answer)}}this[kQuestion](query,cb)})}};return $={Interface,clearLine,clearScreenDown,createInterface,cursorTo,emitKeypressEvents,moveCursor,promises:{Readline,Interface:PromisesInterface,createInterface(input,output,completer,terminal){return new PromisesInterface(input,output,completer,terminal)}},[SymbolFor(\"__BUN_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__\")]:{CSI,utils:{getStringWidth,stripVTControlCharacters}}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeReadlinePromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,30)||@createInternalModuleById(30)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeReplCode = "(function (){\"use strict\";var $;const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function REPLServer(){throwNotImplemented(\"node:repl REPLServer\")}function Recoverable(){throwNotImplemented(\"node:repl Recoverable\")}var REPL_MODE_SLOPPY=0,REPL_MODE_STRICT=1;function start(){throwNotImplemented(\"node:repl\")}return $={lines:[],context:globalThis,historyIndex:-1,cursor:0,historySize:1000,removeHistoryDuplicates:!1,crlfDelay:100,completer:()=>{throwNotImplemented(\"node:repl\")},history:[],_initialPrompt:\"> \",terminal:!0,input:new Proxy({},{get(){throwNotImplemented(\"node:repl\")},has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{return},set(){throwNotImplemented(\"node:repl\")}}),line:\"\",eval:()=>{throwNotImplemented(\"node:repl\")},isCompletionEnabled:!0,escapeCodeTimeout:500,tabSize:8,breakEvalOnSigint:!0,useGlobal:!0,underscoreAssigned:!1,last:void 0,_domain:void 0,allowBlockingCompletions:!1,useColors:!0,output:new Proxy({},{get(){throwNotImplemented(\"node:repl\")},has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{return},set(){throwNotImplemented(\"node:repl\")}})},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamConsumersCode = "(function (){\"use strict\";const{readableStreamToArrayBuffer:arrayBuffer,readableStreamToText:text}=Bun,json=(stream)=>Bun.readableStreamToText(stream).then(JSON.parse),buffer=async(readableStream)=>{return new Buffer(await arrayBuffer(readableStream))},blob=Bun.readableStreamToBlob;return{arrayBuffer,text,json,buffer,blob}})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamCode = "(function (){\"use strict\";const EE=globalThis[globalThis.Symbol.for('Bun.lazy')](\"events\"),StringDecoder=@requireNativeModule(\"node:string_decoder\").StringDecoder;var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require2(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},runOnNextTick=process.nextTick;function isReadableStream(value){return typeof value===\"object\"&&value!==null&&value instanceof ReadableStream}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}const validateObject=(value,name,options=null)=>{const allowArray=options\?.allowArray\?\?!1,allowFunction=options\?.allowFunction\?\?!1;if(!(options\?.nullable\?\?!1)&&value===null||!allowArray&&ArrayIsArray(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE(name,\"Object\",value)};function validateString(value,name){if(typeof value!==\"string\")throw new ERR_INVALID_ARG_TYPE(name,\"string\",value)}var ArrayIsArray=Array.isArray;function ERR_INVALID_ARG_TYPE(name,type,value){return new Error(`The argument '${name}' is invalid. Received '${value}' for type '${type}'`)}function ERR_INVALID_ARG_VALUE(name,value,reason){return new Error(`The value '${value}' is invalid for argument '${name}'. Reason: ${reason}`)}var require_primordials=__commonJS({\"node_modules/readable-stream/lib/ours/primordials.js\"(exports2,module){module.exports={ArrayIsArray(self){return Array.isArray(self)},ArrayPrototypeIncludes(self,el){return self.includes(el)},ArrayPrototypeIndexOf(self,el){return self.indexOf(el)},ArrayPrototypeJoin(self,sep){return self.join(sep)},ArrayPrototypeMap(self,fn){return self.map(fn)},ArrayPrototypePop(self,el){return self.pop(el)},ArrayPrototypePush(self,el){return self.push(el)},ArrayPrototypeSlice(self,start,end){return self.slice(start,end)},Error,FunctionPrototypeCall(fn,thisArgs,...args){return fn.call(thisArgs,...args)},FunctionPrototypeSymbolHasInstance(self,instance){return Function.prototype[Symbol.hasInstance].call(self,instance)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(self,props){return Object.defineProperties(self,props)},ObjectDefineProperty(self,name,prop){return Object.defineProperty(self,name,prop)},ObjectGetOwnPropertyDescriptor(self,name){return Object.getOwnPropertyDescriptor(self,name)},ObjectKeys(obj){return Object.keys(obj)},ObjectSetPrototypeOf(target,proto){return Object.setPrototypeOf(target,proto)},Promise,PromisePrototypeCatch(self,fn){return self.catch(fn)},PromisePrototypeThen(self,thenFn,catchFn){return self.then(thenFn,catchFn)},PromiseReject(err){return Promise.reject(err)},ReflectApply:Reflect.apply,RegExpPrototypeTest(self,value){return self.test(value)},SafeSet:Set,String,StringPrototypeSlice(self,start,end){return self.slice(start,end)},StringPrototypeToLowerCase(self){return self.toLowerCase()},StringPrototypeToUpperCase(self){return self.toUpperCase()},StringPrototypeTrim(self){return self.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(self,buf,len){return self.set(buf,len)},Uint8Array}}}),require_util=__commonJS({\"node_modules/readable-stream/lib/ours/util.js\"(exports2,module){var AsyncFunction=Object.getPrototypeOf(async function(){}).constructor,isBlob=typeof Blob!==\"undefined\"\?function isBlob2(b){return b instanceof Blob}:function isBlob2(b){return!1},AggregateError=class extends Error{constructor(errors){if(!Array.isArray(errors))@throwTypeError(`Expected input to be an Array, got ${typeof errors}`);let message=\"\";for(let i=0;i{resolve=res,reject=rej}),resolve,reject}},promisify(fn){return new Promise((resolve,reject)=>{fn((err,...args)=>{if(err)return reject(err);return resolve(...args)})})},debuglog(){return function(){}},format(format,...args){return format.replace(/%([sdifj])/g,function(...[_unused,type]){const replacement=args.shift();if(type===\"f\")return replacement.toFixed(6);else if(type===\"j\")return JSON.stringify(replacement);else if(type===\"s\"&&typeof replacement===\"object\")return`${replacement.constructor!==Object\?replacement.constructor.name:\"\"} {}`.trim();else return replacement.toString()})},inspect(value){switch(typeof value){case\"string\":if(value.includes(\"'\")){if(!value.includes('\"'))return`\"${value}\"`;else if(!value.includes(\"`\")&&!value.includes(\"${\"))return`\\`${value}\\``}return`'${value}'`;case\"number\":if(isNaN(value))return\"NaN\";else if(Object.is(value,-0))return String(value);return value;case\"bigint\":return`${String(value)}n`;case\"boolean\":case\"undefined\":return String(value);case\"object\":return\"{}\"}},types:{isAsyncFunction(fn){return fn instanceof AsyncFunction},isArrayBufferView(arr){return ArrayBuffer.isView(arr)}},isBlob},module.exports.promisify.custom=Symbol.for(\"nodejs.util.promisify.custom\")}}),require_errors=__commonJS({\"node_modules/readable-stream/lib/ours/errors.js\"(exports2,module){var{format,inspect,AggregateError:CustomAggregateError}=require_util(),AggregateError=globalThis.AggregateError||CustomAggregateError,kIsNodeError=Symbol(\"kIsNodeError\"),kTypes=[\"string\",\"function\",\"number\",\"object\",\"Function\",\"Object\",\"boolean\",\"bigint\",\"symbol\"],classRegExp=/^([A-Z][a-z0-9]*)+$/,nodeInternalPrefix=\"__node_internal_\",codes={};function assert(value,message){if(!value)throw new codes.ERR_INTERNAL_ASSERTION(message)}function addNumericalSeparator(val){let res=\"\",i=val.length;const start=val[0]===\"-\"\?1:0;for(;i>=start+4;i-=3)res=`_${val.slice(i-3,i)}${res}`;return`${val.slice(0,i)}${res}`}function getMessage(key,msg,args){if(typeof msg===\"function\")return assert(msg.length<=args.length,`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${msg.length}).`),msg(...args);const expectedLength=(msg.match(/%[dfijoOs]/g)||[]).length;if(assert(expectedLength===args.length,`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`),args.length===0)return msg;return format(msg,...args)}function E(code,message,Base){if(!Base)Base=Error;class NodeError extends Base{constructor(...args){super(getMessage(code,message,args))}toString(){return`${this.name} [${code}]: ${this.message}`}}Object.defineProperties(NodeError.prototype,{name:{value:Base.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${code}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),NodeError.prototype.code=code,NodeError.prototype[kIsNodeError]=!0,codes[code]=NodeError}function hideStackFrames(fn){const hidden=nodeInternalPrefix+fn.name;return Object.defineProperty(fn,\"name\",{value:hidden}),fn}function aggregateTwoErrors(innerError,outerError){if(innerError&&outerError&&innerError!==outerError){if(Array.isArray(outerError.errors))return outerError.errors.push(innerError),outerError;const err=new AggregateError([outerError,innerError],outerError.message);return err.code=outerError.code,err}return innerError||outerError}var AbortError2=class extends Error{constructor(message=\"The operation was aborted\",options=void 0){if(options!==void 0&&typeof options!==\"object\")throw new codes.ERR_INVALID_ARG_TYPE(\"options\",\"Object\",options);super(message,options);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};E(\"ERR_ASSERTION\",\"%s\",Error),E(\"ERR_INVALID_ARG_TYPE\",(name,expected,actual)=>{if(assert(typeof name===\"string\",\"'name' must be a string\"),!Array.isArray(expected))expected=[expected];let msg=\"The \";if(name.endsWith(\" argument\"))msg+=`${name} `;else msg+=`\"${name}\" ${name.includes(\".\")\?\"property\":\"argument\"} `;msg+=\"must be \";const types=[],instances=[],other=[];for(let value of expected)if(assert(typeof value===\"string\",\"All expected entries have to be of type string\"),kTypes.includes(value))types.push(value.toLowerCase());else if(classRegExp.test(value))instances.push(value);else assert(value!==\"object\",'The value \"object\" should be written as \"Object\"'),other.push(value);if(instances.length>0){const pos=types.indexOf(\"object\");if(pos!==-1)types.splice(types,pos,1),instances.push(\"Object\")}if(types.length>0){switch(types.length){case 1:msg+=`of type ${types[0]}`;break;case 2:msg+=`one of type ${types[0]} or ${types[1]}`;break;default:{const last=types.pop();msg+=`one of type ${types.join(\", \")}, or ${last}`}}if(instances.length>0||other.length>0)msg+=\" or \"}if(instances.length>0){switch(instances.length){case 1:msg+=`an instance of ${instances[0]}`;break;case 2:msg+=`an instance of ${instances[0]} or ${instances[1]}`;break;default:{const last=instances.pop();msg+=`an instance of ${instances.join(\", \")}, or ${last}`}}if(other.length>0)msg+=\" or \"}switch(other.length){case 0:break;case 1:if(other[0].toLowerCase()!==other[0])msg+=\"an \";msg+=`${other[0]}`;break;case 2:msg+=`one of ${other[0]} or ${other[1]}`;break;default:{const last=other.pop();msg+=`one of ${other.join(\", \")}, or ${last}`}}if(actual==null)msg+=`. Received ${actual}`;else if(typeof actual===\"function\"&&actual.name)msg+=`. Received function ${actual.name}`;else if(typeof actual===\"object\"){var _actual$constructor;if((_actual$constructor=actual.constructor)!==null&&_actual$constructor!==void 0&&_actual$constructor.name)msg+=`. Received an instance of ${actual.constructor.name}`;else{const inspected=inspect(actual,{depth:-1});msg+=`. Received ${inspected}`}}else{let inspected=inspect(actual,{colors:!1});if(inspected.length>25)inspected=`${inspected.slice(0,25)}...`;msg+=`. Received type ${typeof actual} (${inspected})`}return msg},TypeError),E(\"ERR_INVALID_ARG_VALUE\",(name,value,reason=\"is invalid\")=>{let inspected=inspect(value);if(inspected.length>128)inspected=inspected.slice(0,128)+\"...\";return`The ${name.includes(\".\")\?\"property\":\"argument\"} '${name}' ${reason}. Received ${inspected}`},TypeError),E(\"ERR_INVALID_RETURN_VALUE\",(input,name,value)=>{var _value$constructor;const type=value!==null&&value!==void 0&&(_value$constructor=value.constructor)!==null&&_value$constructor!==void 0&&_value$constructor.name\?`instance of ${value.constructor.name}`:`type ${typeof value}`;return`Expected ${input} to be returned from the \"${name}\" function but got ${type}.`},TypeError),E(\"ERR_MISSING_ARGS\",(...args)=>{assert(args.length>0,\"At least one arg needs to be specified\");let msg;const len=args.length;switch(args=(Array.isArray(args)\?args:[args]).map((a)=>`\"${a}\"`).join(\" or \"),len){case 1:msg+=`The ${args[0]} argument`;break;case 2:msg+=`The ${args[0]} and ${args[1]} arguments`;break;default:{const last=args.pop();msg+=`The ${args.join(\", \")}, and ${last} arguments`}break}return`${msg} must be specified`},TypeError),E(\"ERR_OUT_OF_RANGE\",(str,range,input)=>{assert(range,'Missing \"range\" argument');let received;if(Number.isInteger(input)&&Math.abs(input)>4294967296)received=addNumericalSeparator(String(input));else if(typeof input===\"bigint\"){if(received=String(input),input>2n**32n||input<-(2n**32n))received=addNumericalSeparator(received);received+=\"n\"}else received=inspect(input);return`The value of \"${str}\" is out of range. It must be ${range}. Received ${received}`},RangeError),E(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\",Error),E(\"ERR_METHOD_NOT_IMPLEMENTED\",\"The %s method is not implemented\",Error),E(\"ERR_STREAM_ALREADY_FINISHED\",\"Cannot call %s after a stream was finished\",Error),E(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\",Error),E(\"ERR_STREAM_DESTROYED\",\"Cannot call %s after a stream was destroyed\",Error),E(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),E(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\",Error),E(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\",Error),E(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\",Error),E(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\",Error),E(\"ERR_UNKNOWN_ENCODING\",\"Unknown encoding: %s\",TypeError),module.exports={AbortError:AbortError2,aggregateTwoErrors:hideStackFrames(aggregateTwoErrors),hideStackFrames,codes}}}),require_validators=__commonJS({\"node_modules/readable-stream/lib/internal/validators.js\"(exports2,module){var{ArrayIsArray:ArrayIsArray2,ArrayPrototypeIncludes,ArrayPrototypeJoin,ArrayPrototypeMap,NumberIsInteger,NumberMAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER,NumberParseInt,RegExpPrototypeTest,String:String2,StringPrototypeToUpperCase,StringPrototypeTrim}=require_primordials(),{hideStackFrames,codes:{ERR_SOCKET_BAD_PORT,ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2,ERR_OUT_OF_RANGE,ERR_UNKNOWN_SIGNAL}}=require_errors(),{normalizeEncoding}=require_util(),{isAsyncFunction,isArrayBufferView}=require_util().types,signals={};function isInt32(value){return value===(value|0)}function isUint32(value){return value===value>>>0}var octalReg=/^[0-7]+$/,modeDesc=\"must be a 32-bit unsigned integer or an octal string\";function parseFileMode(value,name,def){if(typeof value===\"undefined\")value=def;if(typeof value===\"string\"){if(!RegExpPrototypeTest(octalReg,value))throw new ERR_INVALID_ARG_VALUE2(name,value,modeDesc);value=NumberParseInt(value,8)}return validateInt32(value,name,0,4294967295),value}var validateInteger=hideStackFrames((value,name,min=NumberMIN_SAFE_INTEGER,max=NumberMAX_SAFE_INTEGER)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}),validateInt32=hideStackFrames((value,name,min=-2147483648,max=2147483647)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!isInt32(value)){if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}),validateUint32=hideStackFrames((value,name,positive)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!isUint32(value)){if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);throw new ERR_OUT_OF_RANGE(name,`>= ${positive\?1:0} && < 4294967296`,value)}if(positive&&value===0)throw new ERR_OUT_OF_RANGE(name,\">= 1 && < 4294967296\",value)});function validateString2(value,name){if(typeof value!==\"string\")throw new ERR_INVALID_ARG_TYPE2(name,\"string\",value)}function validateNumber(value,name){if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value)}var validateOneOf=hideStackFrames((value,name,oneOf)=>{if(!ArrayPrototypeIncludes(oneOf,value)){const reason=\"must be one of: \"+ArrayPrototypeJoin(ArrayPrototypeMap(oneOf,(v)=>typeof v===\"string\"\?`'${v}'`:String2(v)),\", \");throw new ERR_INVALID_ARG_VALUE2(name,value,reason)}});function validateBoolean2(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE2(name,\"boolean\",value)}var validateObject2=hideStackFrames((value,name,options)=>{const useDefaultOptions=options==null,allowArray=useDefaultOptions\?!1:options.allowArray,allowFunction=useDefaultOptions\?!1:options.allowFunction;if(!(useDefaultOptions\?!1:options.nullable)&&value===null||!allowArray&&ArrayIsArray2(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE2(name,\"Object\",value)}),validateArray=hideStackFrames((value,name,minLength=0)=>{if(!ArrayIsArray2(value))throw new ERR_INVALID_ARG_TYPE2(name,\"Array\",value);if(value.length{if(!isArrayBufferView(buffer))throw new ERR_INVALID_ARG_TYPE2(name,[\"Buffer\",\"TypedArray\",\"DataView\"],buffer)});function validateEncoding(data,encoding){const normalizedEncoding=normalizeEncoding(encoding),length=data.length;if(normalizedEncoding===\"hex\"&&length%2!==0)throw new ERR_INVALID_ARG_VALUE2(\"encoding\",encoding,`is invalid for data of length ${length}`)}function validatePort(port,name=\"Port\",allowZero=!0){if(typeof port!==\"number\"&&typeof port!==\"string\"||typeof port===\"string\"&&StringPrototypeTrim(port).length===0||+port!==+port>>>0||port>65535||port===0&&!allowZero)throw new ERR_SOCKET_BAD_PORT(name,port,allowZero);return port|0}var validateAbortSignal=hideStackFrames((signal,name)=>{if(signal!==void 0&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE2(name,\"AbortSignal\",signal)}),validateFunction=hideStackFrames((value,name)=>{if(typeof value!==\"function\")throw new ERR_INVALID_ARG_TYPE2(name,\"Function\",value)}),validatePlainFunction=hideStackFrames((value,name)=>{if(typeof value!==\"function\"||isAsyncFunction(value))throw new ERR_INVALID_ARG_TYPE2(name,\"Function\",value)}),validateUndefined=hideStackFrames((value,name)=>{if(value!==void 0)throw new ERR_INVALID_ARG_TYPE2(name,\"undefined\",value)});module.exports={isInt32,isUint32,parseFileMode,validateArray,validateBoolean:validateBoolean2,validateBuffer,validateEncoding,validateFunction,validateInt32,validateInteger,validateNumber,validateObject:validateObject2,validateOneOf,validatePlainFunction,validatePort,validateSignalName,validateString:validateString2,validateUint32,validateUndefined,validateAbortSignal}}}),require_utils=__commonJS({\"node_modules/readable-stream/lib/internal/streams/utils.js\"(exports2,module){var{Symbol:Symbol2,SymbolAsyncIterator,SymbolIterator}=require_primordials(),kDestroyed=Symbol2(\"kDestroyed\"),kIsErrored=Symbol2(\"kIsErrored\"),kIsReadable=Symbol2(\"kIsReadable\"),kIsDisturbed=Symbol2(\"kIsDisturbed\");function isReadableNodeStream(obj,strict=!1){var _obj$_readableState;return!!(obj&&typeof obj.pipe===\"function\"&&typeof obj.on===\"function\"&&(!strict||typeof obj.pause===\"function\"&&typeof obj.resume===\"function\")&&(!obj._writableState||((_obj$_readableState=obj._readableState)===null||_obj$_readableState===void 0\?void 0:_obj$_readableState.readable)!==!1)&&(!obj._writableState||obj._readableState))}function isWritableNodeStream(obj){var _obj$_writableState;return!!(obj&&typeof obj.write===\"function\"&&typeof obj.on===\"function\"&&(!obj._readableState||((_obj$_writableState=obj._writableState)===null||_obj$_writableState===void 0\?void 0:_obj$_writableState.writable)!==!1))}function isDuplexNodeStream(obj){return!!(obj&&typeof obj.pipe===\"function\"&&obj._readableState&&typeof obj.on===\"function\"&&typeof obj.write===\"function\")}function isNodeStream(obj){return obj&&(obj._readableState||obj._writableState||typeof obj.write===\"function\"&&typeof obj.on===\"function\"||typeof obj.pipe===\"function\"&&typeof obj.on===\"function\")}function isIterable(obj,isAsync){if(obj==null)return!1;if(isAsync===!0)return typeof obj[SymbolAsyncIterator]===\"function\";if(isAsync===!1)return typeof obj[SymbolIterator]===\"function\";return typeof obj[SymbolAsyncIterator]===\"function\"||typeof obj[SymbolIterator]===\"function\"}function isDestroyed(stream){if(!isNodeStream(stream))return null;const{_writableState:wState,_readableState:rState}=stream,state=wState||rState;return!!(stream.destroyed||stream[kDestroyed]||state!==null&&state!==void 0&&state.destroyed)}function isWritableEnded(stream){if(!isWritableNodeStream(stream))return null;if(stream.writableEnded===!0)return!0;const wState=stream._writableState;if(wState!==null&&wState!==void 0&&wState.errored)return!1;if(typeof(wState===null||wState===void 0\?void 0:wState.ended)!==\"boolean\")return null;return wState.ended}function isWritableFinished(stream,strict){if(!isWritableNodeStream(stream))return null;if(stream.writableFinished===!0)return!0;const wState=stream._writableState;if(wState!==null&&wState!==void 0&&wState.errored)return!1;if(typeof(wState===null||wState===void 0\?void 0:wState.finished)!==\"boolean\")return null;return!!(wState.finished||strict===!1&&wState.ended===!0&&wState.length===0)}function isReadableEnded(stream){if(!isReadableNodeStream(stream))return null;if(stream.readableEnded===!0)return!0;const rState=stream._readableState;if(!rState||rState.errored)return!1;if(typeof(rState===null||rState===void 0\?void 0:rState.ended)!==\"boolean\")return null;return rState.ended}function isReadableFinished(stream,strict){if(!isReadableNodeStream(stream))return null;const rState=stream._readableState;if(rState!==null&&rState!==void 0&&rState.errored)return!1;if(typeof(rState===null||rState===void 0\?void 0:rState.endEmitted)!==\"boolean\")return null;return!!(rState.endEmitted||strict===!1&&rState.ended===!0&&rState.length===0)}function isReadable(stream){if(stream&&stream[kIsReadable]!=null)return stream[kIsReadable];if(typeof(stream===null||stream===void 0\?void 0:stream.readable)!==\"boolean\")return null;if(isDestroyed(stream))return!1;return isReadableNodeStream(stream)&&stream.readable&&!isReadableFinished(stream)}function isWritable(stream){if(typeof(stream===null||stream===void 0\?void 0:stream.writable)!==\"boolean\")return null;if(isDestroyed(stream))return!1;return isWritableNodeStream(stream)&&stream.writable&&!isWritableEnded(stream)}function isFinished(stream,opts){if(!isNodeStream(stream))return null;if(isDestroyed(stream))return!0;if((opts===null||opts===void 0\?void 0:opts.readable)!==!1&&isReadable(stream))return!1;if((opts===null||opts===void 0\?void 0:opts.writable)!==!1&&isWritable(stream))return!1;return!0}function isWritableErrored(stream){var _stream$_writableStat,_stream$_writableStat2;if(!isNodeStream(stream))return null;if(stream.writableErrored)return stream.writableErrored;return(_stream$_writableStat=(_stream$_writableStat2=stream._writableState)===null||_stream$_writableStat2===void 0\?void 0:_stream$_writableStat2.errored)!==null&&_stream$_writableStat!==void 0\?_stream$_writableStat:null}function isReadableErrored(stream){var _stream$_readableStat,_stream$_readableStat2;if(!isNodeStream(stream))return null;if(stream.readableErrored)return stream.readableErrored;return(_stream$_readableStat=(_stream$_readableStat2=stream._readableState)===null||_stream$_readableStat2===void 0\?void 0:_stream$_readableStat2.errored)!==null&&_stream$_readableStat!==void 0\?_stream$_readableStat:null}function isClosed(stream){if(!isNodeStream(stream))return null;if(typeof stream.closed===\"boolean\")return stream.closed;const{_writableState:wState,_readableState:rState}=stream;if(typeof(wState===null||wState===void 0\?void 0:wState.closed)===\"boolean\"||typeof(rState===null||rState===void 0\?void 0:rState.closed)===\"boolean\")return(wState===null||wState===void 0\?void 0:wState.closed)||(rState===null||rState===void 0\?void 0:rState.closed);if(typeof stream._closed===\"boolean\"&&isOutgoingMessage(stream))return stream._closed;return null}function isOutgoingMessage(stream){return typeof stream._closed===\"boolean\"&&typeof stream._defaultKeepAlive===\"boolean\"&&typeof stream._removedConnection===\"boolean\"&&typeof stream._removedContLen===\"boolean\"}function isServerResponse(stream){return typeof stream._sent100===\"boolean\"&&isOutgoingMessage(stream)}function isServerRequest(stream){var _stream$req;return typeof stream._consuming===\"boolean\"&&typeof stream._dumped===\"boolean\"&&((_stream$req=stream.req)===null||_stream$req===void 0\?void 0:_stream$req.upgradeOrConnect)===void 0}function willEmitClose(stream){if(!isNodeStream(stream))return null;const{_writableState:wState,_readableState:rState}=stream,state=wState||rState;return!state&&isServerResponse(stream)||!!(state&&state.autoDestroy&&state.emitClose&&state.closed===!1)}function isDisturbed(stream){var _stream$kIsDisturbed;return!!(stream&&((_stream$kIsDisturbed=stream[kIsDisturbed])!==null&&_stream$kIsDisturbed!==void 0\?_stream$kIsDisturbed:stream.readableDidRead||stream.readableAborted))}function isErrored(stream){var _ref,_ref2,_ref3,_ref4,_ref5,_stream$kIsErrored,_stream$_readableStat3,_stream$_writableStat3,_stream$_readableStat4,_stream$_writableStat4;return!!(stream&&((_ref=(_ref2=(_ref3=(_ref4=(_ref5=(_stream$kIsErrored=stream[kIsErrored])!==null&&_stream$kIsErrored!==void 0\?_stream$kIsErrored:stream.readableErrored)!==null&&_ref5!==void 0\?_ref5:stream.writableErrored)!==null&&_ref4!==void 0\?_ref4:(_stream$_readableStat3=stream._readableState)===null||_stream$_readableStat3===void 0\?void 0:_stream$_readableStat3.errorEmitted)!==null&&_ref3!==void 0\?_ref3:(_stream$_writableStat3=stream._writableState)===null||_stream$_writableStat3===void 0\?void 0:_stream$_writableStat3.errorEmitted)!==null&&_ref2!==void 0\?_ref2:(_stream$_readableStat4=stream._readableState)===null||_stream$_readableStat4===void 0\?void 0:_stream$_readableStat4.errored)!==null&&_ref!==void 0\?_ref:(_stream$_writableStat4=stream._writableState)===null||_stream$_writableStat4===void 0\?void 0:_stream$_writableStat4.errored))}module.exports={kDestroyed,isDisturbed,kIsDisturbed,isErrored,kIsErrored,isReadable,kIsReadable,isClosed,isDestroyed,isDuplexNodeStream,isFinished,isIterable,isReadableNodeStream,isReadableEnded,isReadableFinished,isReadableErrored,isNodeStream,isWritable,isWritableNodeStream,isWritableEnded,isWritableFinished,isWritableErrored,isServerRequest,isServerResponse,willEmitClose}}}),require_end_of_stream=__commonJS({\"node_modules/readable-stream/lib/internal/streams/end-of-stream.js\"(exports2,module){var{AbortError:AbortError2,codes}=require_errors(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_STREAM_PREMATURE_CLOSE}=codes,{once}=require_util(),{validateAbortSignal,validateFunction,validateObject:validateObject2}=require_validators(),{Promise:Promise2}=require_primordials(),{isClosed,isReadable,isReadableNodeStream,isReadableFinished,isReadableErrored,isWritable,isWritableNodeStream,isWritableFinished,isWritableErrored,isNodeStream,willEmitClose:_willEmitClose}=require_utils();function isRequest(stream){return stream.setHeader&&typeof stream.abort===\"function\"}var nop=()=>{};function eos(stream,options,callback){var _options$readable,_options$writable;if(arguments.length===2)callback=options,options={};else if(options==null)options={};else validateObject2(options,\"options\");validateFunction(callback,\"callback\"),validateAbortSignal(options.signal,\"options.signal\"),callback=once(callback);const readable=(_options$readable=options.readable)!==null&&_options$readable!==void 0\?_options$readable:isReadableNodeStream(stream),writable=(_options$writable=options.writable)!==null&&_options$writable!==void 0\?_options$writable:isWritableNodeStream(stream);if(!isNodeStream(stream))throw new ERR_INVALID_ARG_TYPE2(\"stream\",\"Stream\",stream);const{_writableState:wState,_readableState:rState}=stream,onlegacyfinish=()=>{if(!stream.writable)onfinish()};let willEmitClose=_willEmitClose(stream)&&isReadableNodeStream(stream)===readable&&isWritableNodeStream(stream)===writable,writableFinished=isWritableFinished(stream,!1);const onfinish=()=>{if(writableFinished=!0,stream.destroyed)willEmitClose=!1;if(willEmitClose&&(!stream.readable||readable))return;if(!readable||readableFinished)callback.call(stream)};let readableFinished=isReadableFinished(stream,!1);const onend=()=>{if(readableFinished=!0,stream.destroyed)willEmitClose=!1;if(willEmitClose&&(!stream.writable||writable))return;if(!writable||writableFinished)callback.call(stream)},onerror=(err)=>{callback.call(stream,err)};let closed=isClosed(stream);const onclose=()=>{closed=!0;const errored=isWritableErrored(stream)||isReadableErrored(stream);if(errored&&typeof errored!==\"boolean\")return callback.call(stream,errored);if(readable&&!readableFinished&&isReadableNodeStream(stream,!0)){if(!isReadableFinished(stream,!1))return callback.call(stream,new ERR_STREAM_PREMATURE_CLOSE)}if(writable&&!writableFinished){if(!isWritableFinished(stream,!1))return callback.call(stream,new ERR_STREAM_PREMATURE_CLOSE)}callback.call(stream)},onrequest=()=>{stream.req.on(\"finish\",onfinish)};if(isRequest(stream)){if(stream.on(\"complete\",onfinish),!willEmitClose)stream.on(\"abort\",onclose);if(stream.req)onrequest();else stream.on(\"request\",onrequest)}else if(writable&&!wState)stream.on(\"end\",onlegacyfinish),stream.on(\"close\",onlegacyfinish);if(!willEmitClose&&typeof stream.aborted===\"boolean\")stream.on(\"aborted\",onclose);if(stream.on(\"end\",onend),stream.on(\"finish\",onfinish),options.error!==!1)stream.on(\"error\",onerror);if(stream.on(\"close\",onclose),closed)runOnNextTick(onclose);else if(wState!==null&&wState!==void 0&&wState.errorEmitted||rState!==null&&rState!==void 0&&rState.errorEmitted){if(!willEmitClose)runOnNextTick(onclose)}else if(!readable&&(!willEmitClose||isReadable(stream))&&(writableFinished||isWritable(stream)===!1))runOnNextTick(onclose);else if(!writable&&(!willEmitClose||isWritable(stream))&&(readableFinished||isReadable(stream)===!1))runOnNextTick(onclose);else if(rState&&stream.req&&stream.aborted)runOnNextTick(onclose);const cleanup=()=>{if(callback=nop,stream.removeListener(\"aborted\",onclose),stream.removeListener(\"complete\",onfinish),stream.removeListener(\"abort\",onclose),stream.removeListener(\"request\",onrequest),stream.req)stream.req.removeListener(\"finish\",onfinish);stream.removeListener(\"end\",onlegacyfinish),stream.removeListener(\"close\",onlegacyfinish),stream.removeListener(\"finish\",onfinish),stream.removeListener(\"end\",onend),stream.removeListener(\"error\",onerror),stream.removeListener(\"close\",onclose)};if(options.signal&&!closed){const abort=()=>{const endCallback=callback;cleanup(),endCallback.call(stream,new AbortError2(void 0,{cause:options.signal.reason}))};if(options.signal.aborted)runOnNextTick(abort);else{const originalCallback=callback;callback=once((...args)=>{options.signal.removeEventListener(\"abort\",abort),originalCallback.apply(stream,args)}),options.signal.addEventListener(\"abort\",abort)}}return cleanup}function finished2(stream,opts){return new Promise2((resolve,reject)=>{eos(stream,opts,(err)=>{if(err)reject(err);else resolve()})})}module.exports=eos,module.exports.finished=finished2}}),require_operators=__commonJS({\"node_modules/readable-stream/lib/internal/streams/operators.js\"(exports2,module){var{codes:{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_MISSING_ARGS,ERR_OUT_OF_RANGE},AbortError:AbortError2}=require_errors(),{validateAbortSignal,validateInteger,validateObject:validateObject2}=require_validators(),kWeakHandler=require_primordials().Symbol(\"kWeak\"),{finished:finished2}=require_end_of_stream(),{ArrayPrototypePush,MathFloor,Number:Number2,NumberIsNaN,Promise:Promise2,PromiseReject,PromisePrototypeCatch,Symbol:Symbol2}=require_primordials(),kEmpty=Symbol2(\"kEmpty\"),kEof=Symbol2(\"kEof\");function map(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");let concurrency=1;if((options===null||options===void 0\?void 0:options.concurrency)!=null)concurrency=MathFloor(options.concurrency);return validateInteger(concurrency,\"concurrency\",1),async function*map2(){var _options$signal,_options$signal2;const ac=new AbortController,stream=this,queue=[],signal=ac.signal,signalOpt={signal},abort=()=>ac.abort();if(options!==null&&options!==void 0&&(_options$signal=options.signal)!==null&&_options$signal!==void 0&&_options$signal.aborted)abort();options===null||options===void 0||(_options$signal2=options.signal)===null||_options$signal2===void 0||_options$signal2.addEventListener(\"abort\",abort);let next,resume,done=!1;function onDone(){done=!0}async function pump(){try{for await(let val of stream){var _val;if(done)return;if(signal.aborted)throw new AbortError2;try{val=fn(val,signalOpt)}catch(err){val=PromiseReject(err)}if(val===kEmpty)continue;if(typeof((_val=val)===null||_val===void 0\?void 0:_val.catch)===\"function\")val.catch(onDone);if(queue.push(val),next)next(),next=null;if(!done&&queue.length&&queue.length>=concurrency)await new Promise2((resolve)=>{resume=resolve})}queue.push(kEof)}catch(err){const val=PromiseReject(err);PromisePrototypeCatch(val,onDone),queue.push(val)}finally{var _options$signal3;if(done=!0,next)next(),next=null;options===null||options===void 0||(_options$signal3=options.signal)===null||_options$signal3===void 0||_options$signal3.removeEventListener(\"abort\",abort)}}pump();try{while(!0){while(queue.length>0){const val=await queue[0];if(val===kEof)return;if(signal.aborted)throw new AbortError2;if(val!==kEmpty)yield val;if(queue.shift(),resume)resume(),resume=null}await new Promise2((resolve)=>{next=resolve})}}finally{if(ac.abort(),done=!0,resume)resume(),resume=null}}.call(this)}function asIndexedPairs(options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return async function*asIndexedPairs2(){let index=0;for await(let val of this){var _options$signal4;if(options!==null&&options!==void 0&&(_options$signal4=options.signal)!==null&&_options$signal4!==void 0&&_options$signal4.aborted)throw new AbortError2({cause:options.signal.reason});yield[index++,val]}}.call(this)}async function some(fn,options=void 0){for await(let unused of filter.call(this,fn,options))return!0;return!1}async function every(fn,options=void 0){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);return!await some.call(this,async(...args)=>{return!await fn(...args)},options)}async function find(fn,options){for await(let result of filter.call(this,fn,options))return result;return}async function forEach(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);async function forEachFn(value,options2){return await fn(value,options2),kEmpty}for await(let unused of map.call(this,forEachFn,options));}function filter(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);async function filterFn(value,options2){if(await fn(value,options2))return value;return kEmpty}return map.call(this,filterFn,options)}var ReduceAwareErrMissingArgs=class extends ERR_MISSING_ARGS{constructor(){super(\"reduce\");this.message=\"Reduce of an empty stream requires an initial value\"}};async function reduce(reducer,initialValue,options){var _options$signal5;if(typeof reducer!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"reducer\",[\"Function\",\"AsyncFunction\"],reducer);if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");let hasInitialValue=arguments.length>1;if(options!==null&&options!==void 0&&(_options$signal5=options.signal)!==null&&_options$signal5!==void 0&&_options$signal5.aborted){const err=new AbortError2(void 0,{cause:options.signal.reason});throw this.once(\"error\",()=>{}),await finished2(this.destroy(err)),err}const ac=new AbortController,signal=ac.signal;if(options!==null&&options!==void 0&&options.signal){const opts={once:!0,[kWeakHandler]:this};options.signal.addEventListener(\"abort\",()=>ac.abort(),opts)}let gotAnyItemFromStream=!1;try{for await(let value of this){var _options$signal6;if(gotAnyItemFromStream=!0,options!==null&&options!==void 0&&(_options$signal6=options.signal)!==null&&_options$signal6!==void 0&&_options$signal6.aborted)throw new AbortError2;if(!hasInitialValue)initialValue=value,hasInitialValue=!0;else initialValue=await reducer(initialValue,value,{signal})}if(!gotAnyItemFromStream&&!hasInitialValue)throw new ReduceAwareErrMissingArgs}finally{ac.abort()}return initialValue}async function toArray(options){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");const result=[];for await(let val of this){var _options$signal7;if(options!==null&&options!==void 0&&(_options$signal7=options.signal)!==null&&_options$signal7!==void 0&&_options$signal7.aborted)throw new AbortError2(void 0,{cause:options.signal.reason});ArrayPrototypePush(result,val)}return result}function flatMap(fn,options){const values=map.call(this,fn,options);return async function*flatMap2(){for await(let val of values)yield*val}.call(this)}function toIntegerOrInfinity(number){if(number=Number2(number),NumberIsNaN(number))return 0;if(number<0)throw new ERR_OUT_OF_RANGE(\"number\",\">= 0\",number);return number}function drop(number,options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return number=toIntegerOrInfinity(number),async function*drop2(){var _options$signal8;if(options!==null&&options!==void 0&&(_options$signal8=options.signal)!==null&&_options$signal8!==void 0&&_options$signal8.aborted)throw new AbortError2;for await(let val of this){var _options$signal9;if(options!==null&&options!==void 0&&(_options$signal9=options.signal)!==null&&_options$signal9!==void 0&&_options$signal9.aborted)throw new AbortError2;if(number--<=0)yield val}}.call(this)}function take(number,options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return number=toIntegerOrInfinity(number),async function*take2(){var _options$signal10;if(options!==null&&options!==void 0&&(_options$signal10=options.signal)!==null&&_options$signal10!==void 0&&_options$signal10.aborted)throw new AbortError2;for await(let val of this){var _options$signal11;if(options!==null&&options!==void 0&&(_options$signal11=options.signal)!==null&&_options$signal11!==void 0&&_options$signal11.aborted)throw new AbortError2;if(number-- >0)yield val;else return}}.call(this)}module.exports.streamReturningOperators={asIndexedPairs,drop,filter,flatMap,map,take},module.exports.promiseReturningOperators={every,forEach,reduce,toArray,some,find}}}),require_destroy=__commonJS({\"node_modules/readable-stream/lib/internal/streams/destroy.js\"(exports2,module){var{aggregateTwoErrors,codes:{ERR_MULTIPLE_CALLBACK},AbortError:AbortError2}=require_errors(),{Symbol:Symbol2}=require_primordials(),{kDestroyed,isDestroyed,isFinished,isServerRequest}=require_utils(),kDestroy=\"#kDestroy\",kConstruct=\"#kConstruct\";function checkError(err,w,r){if(err){if(err.stack,w&&!w.errored)w.errored=err;if(r&&!r.errored)r.errored=err}}function destroy2(err,cb){const r=this._readableState,w=this._writableState,s=w||r;if(w&&w.destroyed||r&&r.destroyed){if(typeof cb===\"function\")cb();return this}if(checkError(err,w,r),w)w.destroyed=!0;if(r)r.destroyed=!0;if(!s.constructed)this.once(kDestroy,(er)=>{_destroy(this,aggregateTwoErrors(er,err),cb)});else _destroy(this,err,cb);return this}function _destroy(self,err,cb){let called=!1;function onDestroy(err2){if(called)return;called=!0;const{_readableState:r,_writableState:w}=self;if(checkError(err2,w,r),w)w.closed=!0;if(r)r.closed=!0;if(typeof cb===\"function\")cb(err2);if(err2)runOnNextTick(emitErrorCloseNT,self,err2);else runOnNextTick(emitCloseNT,self)}try{self._destroy(err||null,onDestroy)}catch(err2){onDestroy(err2)}}function emitErrorCloseNT(self,err){emitErrorNT(self,err),emitCloseNT(self)}function emitCloseNT(self){const{_readableState:r,_writableState:w}=self;if(w)w.closeEmitted=!0;if(r)r.closeEmitted=!0;if(w&&w.emitClose||r&&r.emitClose)self.emit(\"close\")}function emitErrorNT(self,err){const r=self\?._readableState,w=self\?._writableState;if(w\?.errorEmitted||r\?.errorEmitted)return;if(w)w.errorEmitted=!0;if(r)r.errorEmitted=!0;self\?.emit\?.(\"error\",err)}function undestroy(){const r=this._readableState,w=this._writableState;if(r)r.constructed=!0,r.closed=!1,r.closeEmitted=!1,r.destroyed=!1,r.errored=null,r.errorEmitted=!1,r.reading=!1,r.ended=r.readable===!1,r.endEmitted=r.readable===!1;if(w)w.constructed=!0,w.destroyed=!1,w.closed=!1,w.closeEmitted=!1,w.errored=null,w.errorEmitted=!1,w.finalCalled=!1,w.prefinished=!1,w.ended=w.writable===!1,w.ending=w.writable===!1,w.finished=w.writable===!1}function errorOrDestroy2(stream,err,sync){const r=stream\?._readableState,w=stream\?._writableState;if(w&&w.destroyed||r&&r.destroyed)return this;if(r&&r.autoDestroy||w&&w.autoDestroy)stream.destroy(err);else if(err){if(Error.captureStackTrace(err),w&&!w.errored)w.errored=err;if(r&&!r.errored)r.errored=err;if(sync)runOnNextTick(emitErrorNT,stream,err);else emitErrorNT(stream,err)}}function construct(stream,cb){if(typeof stream._construct!==\"function\")return;const{_readableState:r,_writableState:w}=stream;if(r)r.constructed=!1;if(w)w.constructed=!1;if(stream.once(kConstruct,cb),stream.listenerCount(kConstruct)>1)return;runOnNextTick(constructNT,stream)}function constructNT(stream){let called=!1;function onConstruct(err){if(called){errorOrDestroy2(stream,err!==null&&err!==void 0\?err:new ERR_MULTIPLE_CALLBACK);return}called=!0;const{_readableState:r,_writableState:w}=stream,s=w||r;if(r)r.constructed=!0;if(w)w.constructed=!0;if(s.destroyed)stream.emit(kDestroy,err);else if(err)errorOrDestroy2(stream,err,!0);else runOnNextTick(emitConstructNT,stream)}try{stream._construct(onConstruct)}catch(err){onConstruct(err)}}function emitConstructNT(stream){stream.emit(kConstruct)}function isRequest(stream){return stream&&stream.setHeader&&typeof stream.abort===\"function\"}function emitCloseLegacy(stream){stream.emit(\"close\")}function emitErrorCloseLegacy(stream,err){stream.emit(\"error\",err),runOnNextTick(emitCloseLegacy,stream)}function destroyer(stream,err){if(!stream||isDestroyed(stream))return;if(!err&&!isFinished(stream))err=new AbortError2;if(isServerRequest(stream))stream.socket=null,stream.destroy(err);else if(isRequest(stream))stream.abort();else if(isRequest(stream.req))stream.req.abort();else if(typeof stream.destroy===\"function\")stream.destroy(err);else if(typeof stream.close===\"function\")stream.close();else if(err)runOnNextTick(emitErrorCloseLegacy,stream);else runOnNextTick(emitCloseLegacy,stream);if(!stream.destroyed)stream[kDestroyed]=!0}module.exports={construct,destroyer,destroy:destroy2,undestroy,errorOrDestroy:errorOrDestroy2}}}),require_legacy=__commonJS({\"node_modules/readable-stream/lib/internal/streams/legacy.js\"(exports2,module){var{ArrayIsArray:ArrayIsArray2,ObjectSetPrototypeOf}=require_primordials();function Stream(options){if(!(this instanceof Stream))return new Stream(options);EE.call(this,options)}Stream.prototype={},ObjectSetPrototypeOf(Stream.prototype,EE.prototype),ObjectSetPrototypeOf(Stream,EE),Stream.prototype.pipe=function(dest,options){const source=this;function ondata(chunk){if(dest.writable&&dest.write(chunk)===!1&&source.pause)source.pause()}source.on(\"data\",ondata);function ondrain(){if(source.readable&&source.resume)source.resume()}if(dest.on(\"drain\",ondrain),!dest._isStdio&&(!options||options.end!==!1))source.on(\"end\",onend),source.on(\"close\",onclose);let didOnEnd=!1;function onend(){if(didOnEnd)return;didOnEnd=!0,dest.end()}function onclose(){if(didOnEnd)return;if(didOnEnd=!0,typeof dest.destroy===\"function\")dest.destroy()}function onerror(er){if(cleanup(),EE.listenerCount(this,\"error\")===0)this.emit(\"error\",er)}prependListener(source,\"error\",onerror),prependListener(dest,\"error\",onerror);function cleanup(){source.removeListener(\"data\",ondata),dest.removeListener(\"drain\",ondrain),source.removeListener(\"end\",onend),source.removeListener(\"close\",onclose),source.removeListener(\"error\",onerror),dest.removeListener(\"error\",onerror),source.removeListener(\"end\",cleanup),source.removeListener(\"close\",cleanup),dest.removeListener(\"close\",cleanup)}return source.on(\"end\",cleanup),source.on(\"close\",cleanup),dest.on(\"close\",cleanup),dest.emit(\"pipe\",source),dest};function prependListener(emitter,event,fn){if(typeof emitter.prependListener===\"function\")return emitter.prependListener(event,fn);if(!emitter._events||!emitter._events[event])emitter.on(event,fn);else if(ArrayIsArray2(emitter._events[event]))emitter._events[event].unshift(fn);else emitter._events[event]=[fn,emitter._events[event]]}module.exports={Stream,prependListener}}}),require_add_abort_signal=__commonJS({\"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js\"(exports2,module){var{AbortError:AbortError2,codes}=require_errors(),eos=require_end_of_stream(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2}=codes,validateAbortSignal=(signal,name)=>{if(typeof signal!==\"object\"||!(\"aborted\"in signal))throw new ERR_INVALID_ARG_TYPE2(name,\"AbortSignal\",signal)};function isNodeStream(obj){return!!(obj&&typeof obj.pipe===\"function\")}module.exports.addAbortSignal=function addAbortSignal(signal,stream){if(validateAbortSignal(signal,\"signal\"),!isNodeStream(stream))throw new ERR_INVALID_ARG_TYPE2(\"stream\",\"stream.Stream\",stream);return module.exports.addAbortSignalNoValidate(signal,stream)},module.exports.addAbortSignalNoValidate=function(signal,stream){if(typeof signal!==\"object\"||!(\"aborted\"in signal))return stream;const onAbort=()=>{stream.destroy(new AbortError2(void 0,{cause:signal.reason}))};if(signal.aborted)onAbort();else signal.addEventListener(\"abort\",onAbort),eos(stream,()=>signal.removeEventListener(\"abort\",onAbort));return stream}}}),require_state=__commonJS({\"node_modules/readable-stream/lib/internal/streams/state.js\"(exports2,module){var{MathFloor,NumberIsInteger}=require_primordials(),{ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2}=require_errors().codes;function highWaterMarkFrom(options,isDuplex,duplexKey){return options.highWaterMark!=null\?options.highWaterMark:isDuplex\?options[duplexKey]:null}function getDefaultHighWaterMark(objectMode){return objectMode\?16:16384}function getHighWaterMark(state,options,duplexKey,isDuplex){const hwm=highWaterMarkFrom(options,isDuplex,duplexKey);if(hwm!=null){if(!NumberIsInteger(hwm)||hwm<0){const name=isDuplex\?`options.${duplexKey}`:\"options.highWaterMark\";throw new ERR_INVALID_ARG_VALUE2(name,hwm)}return MathFloor(hwm)}return getDefaultHighWaterMark(state.objectMode)}module.exports={getHighWaterMark,getDefaultHighWaterMark}}}),require_from=__commonJS({\"node_modules/readable-stream/lib/internal/streams/from.js\"(exports2,module){var{PromisePrototypeThen,SymbolAsyncIterator,SymbolIterator}=require_primordials(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_STREAM_NULL_VALUES}=require_errors().codes;function from(Readable,iterable,opts){let iterator;if(typeof iterable===\"string\"||iterable instanceof Buffer)return new Readable({objectMode:!0,...opts,read(){this.push(iterable),this.push(null)}});let isAsync;if(iterable&&iterable[SymbolAsyncIterator])isAsync=!0,iterator=iterable[SymbolAsyncIterator]();else if(iterable&&iterable[SymbolIterator])isAsync=!1,iterator=iterable[SymbolIterator]();else throw new ERR_INVALID_ARG_TYPE2(\"iterable\",[\"Iterable\"],iterable);const readable=new Readable({objectMode:!0,highWaterMark:1,...opts});let reading=!1;readable._read=function(){if(!reading)reading=!0,next()},readable._destroy=function(error,cb){PromisePrototypeThen(close(error),()=>runOnNextTick(cb,error),(e)=>runOnNextTick(cb,e||error))};async function close(error){const hadError=error!==void 0&&error!==null,hasThrow=typeof iterator.throw===\"function\";if(hadError&&hasThrow){const{value,done}=await iterator.throw(error);if(await value,done)return}if(typeof iterator.return===\"function\"){const{value}=await iterator.return();await value}}async function next(){for(;;){try{const{value,done}=isAsync\?await iterator.next():iterator.next();if(done)readable.push(null);else{const res=value&&typeof value.then===\"function\"\?await value:value;if(res===null)throw reading=!1,new ERR_STREAM_NULL_VALUES;else if(readable.push(res))continue;else reading=!1}}catch(err){readable.destroy(err)}break}}return readable}module.exports=from}}),_ReadableFromWeb,_ReadableFromWebForUndici,require_readable=__commonJS({\"node_modules/readable-stream/lib/internal/streams/readable.js\"(exports2,module){var{ArrayPrototypeIndexOf,NumberIsInteger,NumberIsNaN,NumberParseInt,ObjectDefineProperties,ObjectKeys,ObjectSetPrototypeOf,Promise:Promise2,SafeSet,SymbolAsyncIterator,Symbol:Symbol2}=require_primordials(),ReadableState=globalThis[globalThis.Symbol.for('Bun.lazy')](\"bun:stream\").ReadableState,{Stream,prependListener}=require_legacy();function Readable(options){if(!(this instanceof Readable))return new Readable(options);const isDuplex=this instanceof require_duplex();if(this._readableState=new ReadableState(options,this,isDuplex),options){const{read,destroy:destroy2,construct,signal}=options;if(typeof read===\"function\")this._read=read;if(typeof destroy2===\"function\")this._destroy=destroy2;if(typeof construct===\"function\")this._construct=construct;if(signal&&!isDuplex)addAbortSignal(signal,this)}Stream.call(this,options),destroyImpl.construct(this,()=>{if(this._readableState.needReadable)maybeReadMore(this,this._readableState)})}Readable.prototype={},ObjectSetPrototypeOf(Readable.prototype,Stream.prototype),ObjectSetPrototypeOf(Readable,Stream),Readable.prototype.on=function(ev,fn){const res=Stream.prototype.on.call(this,ev,fn),state=this._readableState;if(ev===\"data\"){if(state.readableListening=this.listenerCount(\"readable\")>0,state.flowing!==!1)this.resume()}else if(ev===\"readable\"){if(!state.endEmitted&&!state.readableListening){if(state.readableListening=state.needReadable=!0,state.flowing=!1,state.emittedReadable=!1,state.length)emitReadable(this,state);else if(!state.reading)runOnNextTick(nReadingNextTick,this)}else if(state.endEmitted);}return res};class ReadableFromWeb extends Readable{#reader;#closed;#pendingChunks;#stream;constructor(options,stream){const{objectMode,highWaterMark,encoding,signal}=options;super({objectMode,highWaterMark,encoding,signal});this.#pendingChunks=[],this.#reader=void 0,this.#stream=stream,this.#closed=!1}#drainPending(){var pendingChunks=this.#pendingChunks,pendingChunksI=0,pendingChunksCount=pendingChunks.length;for(;pendingChunksI0)this.#pendingChunks=[];return!1}#handleDone(reader){reader.releaseLock(),this.#reader=void 0,this.#closed=!0,this.push(null);return}async _read(){var stream=this.#stream,reader=this.#reader;if(stream)reader=this.#reader=stream.getReader(),this.#stream=void 0;else if(this.#drainPending())return;var deferredError;try{do{var done=!1,value;const firstResult=reader.readMany();if(@isPromise(firstResult)){if({done,value}=await firstResult,this.#closed){this.#pendingChunks.push(...value);return}}else({done,value}=firstResult);if(done){this.#handleDone(reader);return}if(!this.push(value[0])){this.#pendingChunks=value.slice(1);return}for(let i=1,count=value.length;i{this.#closed=!0,callback(error)});return}try{callback(error)}catch(error2){globalThis.reportError(error2)}}}_ReadableFromWebForUndici=ReadableFromWeb;function newStreamReadableFromReadableStream(readableStream,options={}){if(!isReadableStream(readableStream))throw new ERR_INVALID_ARG_TYPE2(\"readableStream\",\"ReadableStream\",readableStream);validateObject2(options,\"options\");const{highWaterMark,encoding,objectMode=!1,signal}=options;if(encoding!==void 0&&!Buffer.isEncoding(encoding))throw new ERR_INVALID_ARG_VALUE(encoding,\"options.encoding\");return validateBoolean(objectMode,\"options.objectMode\"),getNativeReadableStream(Readable,readableStream,options)||new ReadableFromWeb({highWaterMark,encoding,objectMode,signal},readableStream)}module.exports=Readable,_ReadableFromWeb=newStreamReadableFromReadableStream;var{addAbortSignal}=require_add_abort_signal(),eos=require_end_of_stream();const{maybeReadMore:_maybeReadMore,resume,emitReadable:_emitReadable,onEofChunk}=globalThis[globalThis.Symbol.for('Bun.lazy')](\"bun:stream\");function maybeReadMore(stream,state){process.nextTick(_maybeReadMore,stream,state)}function emitReadable(stream,state){_emitReadable(stream,state)}var destroyImpl=require_destroy(),{aggregateTwoErrors,codes:{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_METHOD_NOT_IMPLEMENTED,ERR_OUT_OF_RANGE,ERR_STREAM_PUSH_AFTER_EOF,ERR_STREAM_UNSHIFT_AFTER_END_EVENT}}=require_errors(),{validateObject:validateObject2}=require_validators(),from=require_from(),nop=()=>{},{errorOrDestroy:errorOrDestroy2}=destroyImpl;Readable.prototype.destroy=destroyImpl.destroy,Readable.prototype._undestroy=destroyImpl.undestroy,Readable.prototype._destroy=function(err,cb){cb(err)},Readable.prototype[EE.captureRejectionSymbol]=function(err){this.destroy(err)},Readable.prototype.push=function(chunk,encoding){return readableAddChunk(this,chunk,encoding,!1)},Readable.prototype.unshift=function(chunk,encoding){return readableAddChunk(this,chunk,encoding,!0)};function readableAddChunk(stream,chunk,encoding,addToFront){const state=stream._readableState;let err;if(!state.objectMode){if(typeof chunk===\"string\"){if(encoding=encoding||state.defaultEncoding,state.encoding!==encoding)if(addToFront&&state.encoding)chunk=Buffer.from(chunk,encoding).toString(state.encoding);else chunk=Buffer.from(chunk,encoding),encoding=\"\"}else if(chunk instanceof Buffer)encoding=\"\";else if(Stream._isUint8Array(chunk)){if(addToFront||!state.decoder)chunk=Stream._uint8ArrayToBuffer(chunk);encoding=\"\"}else if(chunk!=null)err=new ERR_INVALID_ARG_TYPE2(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],chunk)}if(err)errorOrDestroy2(stream,err);else if(chunk===null)state.reading=!1,onEofChunk(stream,state);else if(state.objectMode||chunk&&chunk.length>0)if(addToFront)if(state.endEmitted)errorOrDestroy2(stream,new ERR_STREAM_UNSHIFT_AFTER_END_EVENT);else if(state.destroyed||state.errored)return!1;else addChunk(stream,state,chunk,!0);else if(state.ended)errorOrDestroy2(stream,new ERR_STREAM_PUSH_AFTER_EOF);else if(state.destroyed||state.errored)return!1;else if(state.reading=!1,state.decoder&&!encoding)if(chunk=state.decoder.write(chunk),state.objectMode||chunk.length!==0)addChunk(stream,state,chunk,!1);else maybeReadMore(stream,state);else addChunk(stream,state,chunk,!1);else if(!addToFront)state.reading=!1,maybeReadMore(stream,state);return!state.ended&&(state.length0){if(state.multiAwaitDrain)state.awaitDrainWriters.clear();else state.awaitDrainWriters=null;state.dataEmitted=!0,stream.emit(\"data\",chunk)}else{if(state.length+=state.objectMode\?1:chunk.length,addToFront)state.buffer.unshift(chunk);else state.buffer.push(chunk);if(state.needReadable)emitReadable(stream,state)}maybeReadMore(stream,state)}Readable.prototype.isPaused=function(){const state=this._readableState;return state.paused===!0||state.flowing===!1},Readable.prototype.setEncoding=function(enc){const decoder=new StringDecoder(enc);this._readableState.decoder=decoder,this._readableState.encoding=this._readableState.decoder.encoding;const buffer=this._readableState.buffer;let content=\"\";for(let i=buffer.length;i>0;i--)content+=decoder.write(buffer.shift());if(content!==\"\")buffer.push(content);return this._readableState.length=content.length,this};var MAX_HWM=1073741824;function computeNewHighWaterMark(n){if(n>MAX_HWM)throw new ERR_OUT_OF_RANGE(\"size\",\"<= 1GiB\",n);else n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++;return n}function howMuchToRead(n,state){if(n<=0||state.length===0&&state.ended)return 0;if(state.objectMode)return 1;if(NumberIsNaN(n)){if(state.flowing&&state.length)return state.buffer.first().length;return state.length}if(n<=state.length)return n;return state.ended\?state.length:0}Readable.prototype.read=function(n){if(!NumberIsInteger(n))n=NumberParseInt(n,10);const state=this._readableState,nOrig=n;if(n>state.highWaterMark)state.highWaterMark=computeNewHighWaterMark(n);if(n!==0)state.emittedReadable=!1;if(n===0&&state.needReadable&&((state.highWaterMark!==0\?state.length>=state.highWaterMark:state.length>0)||state.ended)){if(state.length===0&&state.ended)endReadable(this);else emitReadable(this,state);return null}if(n=howMuchToRead(n,state),n===0&&state.ended){if(state.length===0)endReadable(this);return null}let doRead=state.needReadable;if(state.length===0||state.length-n0)ret=fromList(n,state);else ret=null;if(ret===null)state.needReadable=state.length<=state.highWaterMark,n=0;else if(state.length-=n,state.multiAwaitDrain)state.awaitDrainWriters.clear();else state.awaitDrainWriters=null;if(state.length===0){if(!state.ended)state.needReadable=!0;if(nOrig!==n&&state.ended)endReadable(this)}if(ret!==null&&!state.errorEmitted&&!state.closeEmitted)state.dataEmitted=!0,this.emit(\"data\",ret);return ret},Readable.prototype._read=function(n){throw new ERR_METHOD_NOT_IMPLEMENTED(\"_read()\")},Readable.prototype.pipe=function(dest,pipeOpts){const src=this,state=this._readableState;if(state.pipes.length===1){if(!state.multiAwaitDrain)state.multiAwaitDrain=!0,state.awaitDrainWriters=new SafeSet(state.awaitDrainWriters\?[state.awaitDrainWriters]:[])}state.pipes.push(dest);const endFn=(!pipeOpts||pipeOpts.end!==!1)&&dest!==process.stdout&&dest!==process.stderr\?onend:unpipe;if(state.endEmitted)runOnNextTick(endFn);else src.once(\"end\",endFn);dest.on(\"unpipe\",onunpipe);function onunpipe(readable,unpipeInfo){if(readable===src){if(unpipeInfo&&unpipeInfo.hasUnpiped===!1)unpipeInfo.hasUnpiped=!0,cleanup()}}function onend(){dest.end()}let ondrain,cleanedUp=!1;function cleanup(){if(dest.removeListener(\"close\",onclose),dest.removeListener(\"finish\",onfinish),ondrain)dest.removeListener(\"drain\",ondrain);if(dest.removeListener(\"error\",onerror),dest.removeListener(\"unpipe\",onunpipe),src.removeListener(\"end\",onend),src.removeListener(\"end\",unpipe),src.removeListener(\"data\",ondata),cleanedUp=!0,ondrain&&state.awaitDrainWriters&&(!dest._writableState||dest._writableState.needDrain))ondrain()}function pause(){if(!cleanedUp){if(state.pipes.length===1&&state.pipes[0]===dest)state.awaitDrainWriters=dest,state.multiAwaitDrain=!1;else if(state.pipes.length>1&&state.pipes.includes(dest))state.awaitDrainWriters.add(dest);src.pause()}if(!ondrain)ondrain=pipeOnDrain(src,dest),dest.on(\"drain\",ondrain)}src.on(\"data\",ondata);function ondata(chunk){if(dest.write(chunk)===!1)pause()}function onerror(er){if(unpipe(),dest.removeListener(\"error\",onerror),dest.listenerCount(\"error\")===0){const s=dest._writableState||dest._readableState;if(s&&!s.errorEmitted)errorOrDestroy2(dest,er);else dest.emit(\"error\",er)}}prependListener(dest,\"error\",onerror);function onclose(){dest.removeListener(\"finish\",onfinish),unpipe()}dest.once(\"close\",onclose);function onfinish(){dest.removeListener(\"close\",onclose),unpipe()}dest.once(\"finish\",onfinish);function unpipe(){src.unpipe(dest)}if(dest.emit(\"pipe\",src),dest.writableNeedDrain===!0){if(state.flowing)pause()}else if(!state.flowing)src.resume();return dest};function pipeOnDrain(src,dest){return function pipeOnDrainFunctionResult(){const state=src._readableState;if(state.awaitDrainWriters===dest)state.awaitDrainWriters=null;else if(state.multiAwaitDrain)state.awaitDrainWriters.delete(dest);if((!state.awaitDrainWriters||state.awaitDrainWriters.size===0)&&src.listenerCount(\"data\"))src.resume()}}Readable.prototype.unpipe=function(dest){const state=this._readableState,unpipeInfo={hasUnpiped:!1};if(state.pipes.length===0)return this;if(!dest){const dests=state.pipes;state.pipes=[],this.pause();for(let i=0;i0,state.resumeScheduled&&state.paused===!1)state.flowing=!0;else if(self.listenerCount(\"data\")>0)self.resume();else if(!state.readableListening)state.flowing=null}function nReadingNextTick(self){self.read(0)}Readable.prototype.resume=function(){const state=this._readableState;if(!state.flowing)state.flowing=!state.readableListening,resume(this,state);return state.paused=!1,this},Readable.prototype.pause=function(){if(this._readableState.flowing!==!1)this._readableState.flowing=!1,this.emit(\"pause\");return this._readableState.paused=!0,this},Readable.prototype.wrap=function(stream){let paused=!1;stream.on(\"data\",(chunk)=>{if(!this.push(chunk)&&stream.pause)paused=!0,stream.pause()}),stream.on(\"end\",()=>{this.push(null)}),stream.on(\"error\",(err)=>{errorOrDestroy2(this,err)}),stream.on(\"close\",()=>{this.destroy()}),stream.on(\"destroy\",()=>{this.destroy()}),this._read=()=>{if(paused&&stream.resume)paused=!1,stream.resume()};const streamKeys=ObjectKeys(stream);for(let j=1;j{error=err\?aggregateTwoErrors(error,err):null,callback(),callback=nop});try{while(!0){const chunk=stream.destroyed\?null:stream.read();if(chunk!==null)yield chunk;else if(error)throw error;else if(error===null)return;else await new Promise2(next)}}catch(err){throw error=aggregateTwoErrors(error,err),error}finally{if((error||(options===null||options===void 0\?void 0:options.destroyOnReturn)!==!1)&&(error===void 0||stream._readableState.autoDestroy))destroyImpl.destroyer(stream,null);else stream.off(\"readable\",next),cleanup()}}ObjectDefineProperties(Readable.prototype,{readable:{get(){const r=this._readableState;return!!r&&r.readable!==!1&&!r.destroyed&&!r.errorEmitted&&!r.endEmitted},set(val){if(this._readableState)this._readableState.readable=!!val}},readableDidRead:{enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{enumerable:!1,get:function(){return this._readableState.flowing},set:function(state){if(this._readableState)this._readableState.flowing=state}},readableLength:{enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{enumerable:!1,get(){return this._readableState\?this._readableState.objectMode:!1}},readableEncoding:{enumerable:!1,get(){return this._readableState\?this._readableState.encoding:null}},errored:{enumerable:!1,get(){return this._readableState\?this._readableState.errored:null}},closed:{get(){return this._readableState\?this._readableState.closed:!1}},destroyed:{enumerable:!1,get(){return this._readableState\?this._readableState.destroyed:!1},set(value){if(!this._readableState)return;this._readableState.destroyed=value}},readableEnded:{enumerable:!1,get(){return this._readableState\?this._readableState.endEmitted:!1}}}),Readable._fromList=fromList;function fromList(n,state){if(state.length===0)return null;let ret;if(state.objectMode)ret=state.buffer.shift();else if(!n||n>=state.length){if(state.decoder)ret=state.buffer.join(\"\");else if(state.buffer.length===1)ret=state.buffer.first();else ret=state.buffer.concat(state.length);state.buffer.clear()}else ret=state.buffer.consume(n,state.decoder);return ret}function endReadable(stream){const state=stream._readableState;if(!state.endEmitted)state.ended=!0,runOnNextTick(endReadableNT,state,stream)}function endReadableNT(state,stream){if(!state.errored&&!state.closeEmitted&&!state.endEmitted&&state.length===0){if(state.endEmitted=!0,stream.emit(\"end\"),stream.writable&&stream.allowHalfOpen===!1)runOnNextTick(endWritableNT,stream);else if(state.autoDestroy){const wState=stream._writableState;if(!wState||wState.autoDestroy&&(wState.finished||wState.writable===!1))stream.destroy()}}}function endWritableNT(stream){if(stream.writable&&!stream.writableEnded&&!stream.destroyed)stream.end()}Readable.from=function(iterable,opts){return from(Readable,iterable,opts)};var webStreamsAdapters={newStreamReadableFromReadableStream,newReadableStreamFromStreamReadable(streamReadable,options={}){if(typeof streamReadable\?._readableState!==\"object\")throw new ERR_INVALID_ARG_TYPE2(\"streamReadable\",\"stream.Readable\",streamReadable);var{isDestroyed,isReadable}=require_utils();if(isDestroyed(streamReadable)||!isReadable(streamReadable)){const readable=new ReadableStream;return readable.cancel(),readable}const{readableObjectMode:objectMode,readableHighWaterMark:highWaterMark}=streamReadable,strategy=((strategy2)=>{if(strategy2)return strategy2;if(objectMode)return new CountQueuingStrategy({highWaterMark});return{highWaterMark}})(options\?.strategy);let controller;function onData(chunk){if(controller.enqueue(chunk),controller.desiredSize<=0)streamReadable.pause()}streamReadable.pause();const cleanup=finished(streamReadable,(error)=>{if(error\?.code===\"ERR_STREAM_PREMATURE_CLOSE\")error=new AbortError(void 0,{cause:error});if(cleanup(),streamReadable.on(\"error\",()=>{}),error)return controller.error(error);controller.close()});return streamReadable.on(\"data\",onData),new ReadableStream({start(c){controller=c},pull(){streamReadable.resume()},cancel(reason){destroy(streamReadable,reason)}},strategy)}};Readable.fromWeb=function(readableStream,options){return webStreamsAdapters.newStreamReadableFromReadableStream(readableStream,options)},Readable.toWeb=function(streamReadable,options){return webStreamsAdapters.newReadableStreamFromStreamReadable(streamReadable,options)},Readable.wrap=function(src,options){var _ref,_src$readableObjectMo;return new Readable({objectMode:(_ref=(_src$readableObjectMo=src.readableObjectMode)!==null&&_src$readableObjectMo!==void 0\?_src$readableObjectMo:src.objectMode)!==null&&_ref!==void 0\?_ref:!0,...options,destroy(err,callback){destroyImpl.destroyer(src,err),callback(err)}}).wrap(src)}}}),require_writable=__commonJS({\"node_modules/readable-stream/lib/internal/streams/writable.js\"(exports2,module){var{ArrayPrototypeSlice,Error:Error2,FunctionPrototypeSymbolHasInstance,ObjectDefineProperty,ObjectDefineProperties,ObjectSetPrototypeOf,StringPrototypeToLowerCase,Symbol:Symbol2,SymbolHasInstance}=require_primordials(),Stream=require_legacy().Stream,destroyImpl=require_destroy(),{addAbortSignal}=require_add_abort_signal(),{getHighWaterMark,getDefaultHighWaterMark}=require_state(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_METHOD_NOT_IMPLEMENTED,ERR_MULTIPLE_CALLBACK,ERR_STREAM_CANNOT_PIPE,ERR_STREAM_DESTROYED,ERR_STREAM_ALREADY_FINISHED,ERR_STREAM_NULL_VALUES,ERR_STREAM_WRITE_AFTER_END,ERR_UNKNOWN_ENCODING}=require_errors().codes,{errorOrDestroy:errorOrDestroy2}=destroyImpl;function Writable2(options={}){const isDuplex=this instanceof require_duplex();if(!isDuplex&&!FunctionPrototypeSymbolHasInstance(Writable2,this))return new Writable2(options);if(this._writableState=new WritableState(options,this,isDuplex),options){if(typeof options.write===\"function\")this._write=options.write;if(typeof options.writev===\"function\")this._writev=options.writev;if(typeof options.destroy===\"function\")this._destroy=options.destroy;if(typeof options.final===\"function\")this._final=options.final;if(typeof options.construct===\"function\")this._construct=options.construct;if(options.signal)addAbortSignal(options.signal,this)}Stream.call(this,options),destroyImpl.construct(this,()=>{const state=this._writableState;if(!state.writing)clearBuffer(this,state);finishMaybe(this,state)})}Writable2.prototype={},ObjectSetPrototypeOf(Writable2.prototype,Stream.prototype),ObjectSetPrototypeOf(Writable2,Stream),module.exports=Writable2;function nop(){}var kOnFinished=Symbol2(\"kOnFinished\");function WritableState(options,stream,isDuplex){if(typeof isDuplex!==\"boolean\")isDuplex=stream instanceof require_duplex();if(this.objectMode=!!(options&&options.objectMode),isDuplex)this.objectMode=this.objectMode||!!(options&&options.writableObjectMode);this.highWaterMark=options\?getHighWaterMark(this,options,\"writableHighWaterMark\",isDuplex):getDefaultHighWaterMark(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const noDecode=!!(options&&options.decodeStrings===!1);this.decodeStrings=!noDecode,this.defaultEncoding=options&&options.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=onwrite.bind(void 0,stream),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,resetBuffer(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!options||options.emitClose!==!1,this.autoDestroy=!options||options.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[kOnFinished]=[]}WritableState.prototype={};function resetBuffer(state){state.buffered=[],state.bufferedIndex=0,state.allBuffers=!0,state.allNoop=!0}WritableState.prototype.getBuffer=function getBuffer(){return ArrayPrototypeSlice(this.buffered,this.bufferedIndex)},ObjectDefineProperty(WritableState.prototype,\"bufferedRequestCount\",{get(){return this.buffered.length-this.bufferedIndex}}),ObjectDefineProperty(Writable2,SymbolHasInstance,{value:function(object){if(FunctionPrototypeSymbolHasInstance(this,object))return!0;if(this!==Writable2)return!1;return object&&object._writableState instanceof WritableState}}),Writable2.prototype.pipe=function(){errorOrDestroy2(this,new ERR_STREAM_CANNOT_PIPE)};function _write(stream,chunk,encoding,cb){const state=stream._writableState;if(typeof encoding===\"function\")cb=encoding,encoding=state.defaultEncoding;else{if(!encoding)encoding=state.defaultEncoding;else if(encoding!==\"buffer\"&&!Buffer.isEncoding(encoding))throw new ERR_UNKNOWN_ENCODING(encoding);if(typeof cb!==\"function\")cb=nop}if(chunk===null)throw new ERR_STREAM_NULL_VALUES;else if(!state.objectMode)if(typeof chunk===\"string\"){if(state.decodeStrings!==!1)chunk=Buffer.from(chunk,encoding),encoding=\"buffer\"}else if(chunk instanceof Buffer)encoding=\"buffer\";else if(Stream._isUint8Array(chunk))chunk=Stream._uint8ArrayToBuffer(chunk),encoding=\"buffer\";else throw new ERR_INVALID_ARG_TYPE2(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],chunk);let err;if(state.ending)err=new ERR_STREAM_WRITE_AFTER_END;else if(state.destroyed)err=new ERR_STREAM_DESTROYED(\"write\");if(err)return runOnNextTick(cb,err),errorOrDestroy2(stream,err,!0),err;return state.pendingcb++,writeOrBuffer(stream,state,chunk,encoding,cb)}Writable2.prototype.write=function(chunk,encoding,cb){return _write(this,chunk,encoding,cb)===!0},Writable2.prototype.cork=function(){this._writableState.corked++},Writable2.prototype.uncork=function(){const state=this._writableState;if(state.corked){if(state.corked--,!state.writing)clearBuffer(this,state)}},Writable2.prototype.setDefaultEncoding=function setDefaultEncoding(encoding){if(typeof encoding===\"string\")encoding=StringPrototypeToLowerCase(encoding);if(!Buffer.isEncoding(encoding))throw new ERR_UNKNOWN_ENCODING(encoding);return this._writableState.defaultEncoding=encoding,this};function writeOrBuffer(stream,state,chunk,encoding,callback){const len=state.objectMode\?1:chunk.length;state.length+=len;const ret=state.lengthstate.bufferedIndex)clearBuffer(stream,state);if(sync)if(state.afterWriteTickInfo!==null&&state.afterWriteTickInfo.cb===cb)state.afterWriteTickInfo.count++;else state.afterWriteTickInfo={count:1,cb,stream,state},runOnNextTick(afterWriteTick,state.afterWriteTickInfo);else afterWrite(stream,state,1,cb)}}function afterWriteTick({stream,state,count,cb}){return state.afterWriteTickInfo=null,afterWrite(stream,state,count,cb)}function afterWrite(stream,state,count,cb){if(!state.ending&&!stream.destroyed&&state.length===0&&state.needDrain)state.needDrain=!1,stream.emit(\"drain\");while(count-- >0)state.pendingcb--,cb();if(state.destroyed)errorBuffer(state);finishMaybe(stream,state)}function errorBuffer(state){if(state.writing)return;for(let n=state.bufferedIndex;n1&&stream._writev){state.pendingcb-=bufferedLength-1;const callback=state.allNoop\?nop:(err)=>{for(let n=i;n256)buffered.splice(0,i),state.bufferedIndex=0;else state.bufferedIndex=i}state.bufferProcessing=!1}Writable2.prototype._write=function(chunk,encoding,cb){if(this._writev)this._writev([{chunk,encoding}],cb);else throw new ERR_METHOD_NOT_IMPLEMENTED(\"_write()\")},Writable2.prototype._writev=null,Writable2.prototype.end=function(chunk,encoding,cb,native=!1){const state=this._writableState;if(typeof chunk===\"function\")cb=chunk,chunk=null,encoding=null;else if(typeof encoding===\"function\")cb=encoding,encoding=null;let err;if(chunk!==null&&chunk!==void 0){let ret;if(!native)ret=_write(this,chunk,encoding);else ret=this.write(chunk,encoding);if(ret instanceof Error2)err=ret}if(state.corked)state.corked=1,this.uncork();if(err)this.emit(\"error\",err);else if(!state.errored&&!state.ending)state.ending=!0,finishMaybe(this,state,!0),state.ended=!0;else if(state.finished)err=new ERR_STREAM_ALREADY_FINISHED(\"end\");else if(state.destroyed)err=new ERR_STREAM_DESTROYED(\"end\");if(typeof cb===\"function\")if(err||state.finished)runOnNextTick(cb,err);else state[kOnFinished].push(cb);return this};function needFinish(state,tag){var needFinish2=state.ending&&!state.destroyed&&state.constructed&&state.length===0&&!state.errored&&state.buffered.length===0&&!state.finished&&!state.writing&&!state.errorEmitted&&!state.closeEmitted;return needFinish2}function callFinal(stream,state){let called=!1;function onFinish(err){if(called){errorOrDestroy2(stream,err!==null&&err!==void 0\?err:ERR_MULTIPLE_CALLBACK());return}if(called=!0,state.pendingcb--,err){const onfinishCallbacks=state[kOnFinished].splice(0);for(let i=0;i{if(needFinish(state2))finish(stream2,state2);else state2.pendingcb--},stream,state);else if(needFinish(state))state.pendingcb++,finish(stream,state)}}function finish(stream,state){state.pendingcb--,state.finished=!0;const onfinishCallbacks=state[kOnFinished].splice(0);for(let i=0;i{if(val!=null)throw new ERR_INVALID_RETURN_VALUE(\"nully\",\"body\",val)},(err)=>{destroyer(d,err)});return d=new Duplexify({objectMode:!0,readable:!1,write,final(cb){final(async()=>{try{await promise,runOnNextTick(cb,null)}catch(err){runOnNextTick(cb,err)}})},destroy:destroy2})}throw new ERR_INVALID_RETURN_VALUE(\"Iterable, AsyncIterable or AsyncFunction\",name,value)}if(isBlob(body))return duplexify(body.arrayBuffer());if(isIterable(body))return from(Duplexify,body,{objectMode:!0,writable:!1});if(typeof(body===null||body===void 0\?void 0:body.writable)===\"object\"||typeof(body===null||body===void 0\?void 0:body.readable)===\"object\"){const readable=body!==null&&body!==void 0&&body.readable\?isReadableNodeStream(body===null||body===void 0\?void 0:body.readable)\?body===null||body===void 0\?void 0:body.readable:duplexify(body.readable):void 0,writable=body!==null&&body!==void 0&&body.writable\?isWritableNodeStream(body===null||body===void 0\?void 0:body.writable)\?body===null||body===void 0\?void 0:body.writable:duplexify(body.writable):void 0;return _duplexify({readable,writable})}const then=body===null||body===void 0\?void 0:body.then;if(typeof then===\"function\"){let d;return FunctionPrototypeCall(then,body,(val)=>{if(val!=null)d.push(val);d.push(null)},(err)=>{destroyer(d,err)}),d=new Duplexify({objectMode:!0,writable:!1,read(){}})}throw new ERR_INVALID_ARG_TYPE2(name,[\"Blob\",\"ReadableStream\",\"WritableStream\",\"Stream\",\"Iterable\",\"AsyncIterable\",\"Function\",\"{ readable, writable } pair\",\"Promise\"],body)};function fromAsyncGen(fn){let{promise,resolve}=createDeferredPromise();const ac=new AbortController,signal=ac.signal;return{value:fn(async function*(){while(!0){const _promise=promise;promise=null;const{chunk,done,cb}=await _promise;if(runOnNextTick(cb),done)return;if(signal.aborted)throw new AbortError2(void 0,{cause:signal.reason});({promise,resolve}=createDeferredPromise()),yield chunk}}(),{signal}),write(chunk,encoding,cb){const _resolve=resolve;resolve=null,_resolve({chunk,done:!1,cb})},final(cb){const _resolve=resolve;resolve=null,_resolve({done:!0,cb})},destroy(err,cb){ac.abort(),cb(err)}}}function _duplexify(pair){const r=pair.readable&&typeof pair.readable.read!==\"function\"\?Readable.wrap(pair.readable):pair.readable,w=pair.writable;let readable=!!isReadable(r),writable=!!isWritable(w),ondrain,onfinish,onreadable,onclose,d;function onfinished(err){const cb=onclose;if(onclose=null,cb)cb(err);else if(err)d.destroy(err);else if(!readable&&!writable)d.destroy()}if(d=new Duplexify({readableObjectMode:!!(r!==null&&r!==void 0&&r.readableObjectMode),writableObjectMode:!!(w!==null&&w!==void 0&&w.writableObjectMode),readable,writable}),writable)eos(w,(err)=>{if(writable=!1,err)destroyer(r,err);onfinished(err)}),d._write=function(chunk,encoding,callback){if(w.write(chunk,encoding))callback();else ondrain=callback},d._final=function(callback){w.end(),onfinish=callback},w.on(\"drain\",function(){if(ondrain){const cb=ondrain;ondrain=null,cb()}}),w.on(\"finish\",function(){if(onfinish){const cb=onfinish;onfinish=null,cb()}});if(readable)eos(r,(err)=>{if(readable=!1,err)destroyer(r,err);onfinished(err)}),r.on(\"readable\",function(){if(onreadable){const cb=onreadable;onreadable=null,cb()}}),r.on(\"end\",function(){d.push(null)}),d._read=function(){while(!0){const buf=r.read();if(buf===null){onreadable=d._read;return}if(!d.push(buf))return}};return d._destroy=function(err,callback){if(!err&&onclose!==null)err=new AbortError2;if(onreadable=null,ondrain=null,onfinish=null,onclose===null)callback(err);else onclose=callback,destroyer(w,err),destroyer(r,err)},d}}}),require_duplex=__commonJS({\"node_modules/readable-stream/lib/internal/streams/duplex.js\"(exports2,module){var{ObjectDefineProperties,ObjectGetOwnPropertyDescriptor,ObjectKeys,ObjectSetPrototypeOf}=require_primordials(),Readable=require_readable();function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);if(Readable.call(this,options),Writable.call(this,options),options){if(this.allowHalfOpen=options.allowHalfOpen!==!1,options.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(options.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}Duplex.prototype={},module.exports=Duplex,ObjectSetPrototypeOf(Duplex.prototype,Readable.prototype),ObjectSetPrototypeOf(Duplex,Readable);for(var method in Writable.prototype)if(!Duplex.prototype[method])Duplex.prototype[method]=Writable.prototype[method];ObjectDefineProperties(Duplex.prototype,{writable:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writable\"),writableHighWaterMark:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableHighWaterMark\"),writableObjectMode:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableObjectMode\"),writableBuffer:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableBuffer\"),writableLength:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableLength\"),writableFinished:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableFinished\"),writableCorked:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableCorked\"),writableEnded:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableEnded\"),writableNeedDrain:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableNeedDrain\"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(value){if(this._readableState&&this._writableState)this._readableState.destroyed=value,this._writableState.destroyed=value}}});var webStreamsAdapters;function lazyWebStreams(){if(webStreamsAdapters===void 0)webStreamsAdapters={};return webStreamsAdapters}Duplex.fromWeb=function(pair,options){return lazyWebStreams().newStreamDuplexFromReadableWritablePair(pair,options)},Duplex.toWeb=function(duplex){return lazyWebStreams().newReadableWritablePairFromDuplex(duplex)};var duplexify;Duplex.from=function(body){if(!duplexify)duplexify=require_duplexify();return duplexify(body,\"body\")}}}),require_transform=__commonJS({\"node_modules/readable-stream/lib/internal/streams/transform.js\"(exports2,module){var{ObjectSetPrototypeOf,Symbol:Symbol2}=require_primordials(),{ERR_METHOD_NOT_IMPLEMENTED}=require_errors().codes,Duplex=require_duplex();function Transform(options){if(!(this instanceof Transform))return new Transform(options);if(Duplex.call(this,options),this._readableState.sync=!1,this[kCallback]=null,options){if(typeof options.transform===\"function\")this._transform=options.transform;if(typeof options.flush===\"function\")this._flush=options.flush}this.on(\"prefinish\",prefinish.bind(this))}Transform.prototype={},ObjectSetPrototypeOf(Transform.prototype,Duplex.prototype),ObjectSetPrototypeOf(Transform,Duplex),module.exports=Transform;var kCallback=Symbol2(\"kCallback\");function final(cb){if(typeof this._flush===\"function\"&&!this.destroyed)this._flush((er,data)=>{if(er){if(cb)cb(er);else this.destroy(er);return}if(data!=null)this.push(data);if(this.push(null),cb)cb()});else if(this.push(null),cb)cb()}function prefinish(){if(this._final!==final)final.call(this)}Transform.prototype._final=final,Transform.prototype._transform=function(chunk,encoding,callback){throw new ERR_METHOD_NOT_IMPLEMENTED(\"_transform()\")},Transform.prototype._write=function(chunk,encoding,callback){const rState=this._readableState,wState=this._writableState,length=rState.length;this._transform(chunk,encoding,(err,val)=>{if(err){callback(err);return}if(val!=null)this.push(val);if(wState.ended||length===rState.length||rState.length{finished2=!0});const cleanup=eos(stream,{readable:reading,writable:writing},(err)=>{finished2=!err});return{destroy:(err)=>{if(finished2)return;finished2=!0,destroyImpl.destroyer(stream,err||new ERR_STREAM_DESTROYED(\"pipe\"))},cleanup}}function popCallback(streams){return validateFunction(streams[streams.length-1],\"streams[stream.length - 1]\"),streams.pop()}function makeAsyncIterable(val){if(isIterable(val))return val;else if(isReadableNodeStream(val))return fromReadable(val);throw new ERR_INVALID_ARG_TYPE2(\"val\",[\"Readable\",\"Iterable\",\"AsyncIterable\"],val)}async function*fromReadable(val){if(!Readable)Readable=require_readable();yield*Readable.prototype[SymbolAsyncIterator].call(val)}async function pump(iterable,writable,finish,{end}){let error,onresolve=null;const resume=(err)=>{if(err)error=err;if(onresolve){const callback=onresolve;onresolve=null,callback()}},wait=()=>new Promise2((resolve,reject)=>{if(error)reject(error);else onresolve=()=>{if(error)reject(error);else resolve()}});writable.on(\"drain\",resume);const cleanup=eos(writable,{readable:!1},resume);try{if(writable.writableNeedDrain)await wait();for await(let chunk of iterable)if(!writable.write(chunk))await wait();if(end)writable.end();await wait(),finish()}catch(err){finish(error!==err\?aggregateTwoErrors(error,err):err)}finally{cleanup(),writable.off(\"drain\",resume)}}function pipeline(...streams){return pipelineImpl(streams,once(popCallback(streams)))}function pipelineImpl(streams,callback,opts){if(streams.length===1&&ArrayIsArray2(streams[0]))streams=streams[0];if(streams.length<2)throw new ERR_MISSING_ARGS(\"streams\");const ac=new AbortController,signal=ac.signal,outerSignal=opts===null||opts===void 0\?void 0:opts.signal,lastStreamCleanup=[];validateAbortSignal(outerSignal,\"options.signal\");function abort(){finishImpl(new AbortError2)}outerSignal===null||outerSignal===void 0||outerSignal.addEventListener(\"abort\",abort);let error,value;const destroys=[];let finishCount=0;function finish(err){finishImpl(err,--finishCount===0)}function finishImpl(err,final){if(err&&(!error||error.code===\"ERR_STREAM_PREMATURE_CLOSE\"))error=err;if(!error&&!final)return;while(destroys.length)destroys.shift()(error);if(outerSignal===null||outerSignal===void 0||outerSignal.removeEventListener(\"abort\",abort),ac.abort(),final){if(!error)lastStreamCleanup.forEach((fn)=>fn());runOnNextTick(callback,error,value)}}let ret;for(let i=0;i0,end=reading||(opts===null||opts===void 0\?void 0:opts.end)!==!1,isLastStream=i===streams.length-1;if(isNodeStream(stream)){let onError=function(err){if(err&&err.name!==\"AbortError\"&&err.code!==\"ERR_STREAM_PREMATURE_CLOSE\")finish(err)};if(end){const{destroy:destroy2,cleanup}=destroyer(stream,reading,writing);if(destroys.push(destroy2),isReadable(stream)&&isLastStream)lastStreamCleanup.push(cleanup)}if(stream.on(\"error\",onError),isReadable(stream)&&isLastStream)lastStreamCleanup.push(()=>{stream.removeListener(\"error\",onError)})}if(i===0)if(typeof stream===\"function\"){if(ret=stream({signal}),!isIterable(ret))throw new ERR_INVALID_RETURN_VALUE(\"Iterable, AsyncIterable or Stream\",\"source\",ret)}else if(isIterable(stream)||isReadableNodeStream(stream))ret=stream;else ret=Duplex.from(stream);else if(typeof stream===\"function\")if(ret=makeAsyncIterable(ret),ret=stream(ret,{signal}),reading){if(!isIterable(ret,!0))throw new ERR_INVALID_RETURN_VALUE(\"AsyncIterable\",`transform[${i-1}]`,ret)}else{var _ret;if(!PassThrough)PassThrough=require_passthrough();const pt=new PassThrough({objectMode:!0}),then=(_ret=ret)===null||_ret===void 0\?void 0:_ret.then;if(typeof then===\"function\")finishCount++,then.call(ret,(val)=>{if(value=val,val!=null)pt.write(val);if(end)pt.end();runOnNextTick(finish)},(err)=>{pt.destroy(err),runOnNextTick(finish,err)});else if(isIterable(ret,!0))finishCount++,pump(ret,pt,finish,{end});else throw new ERR_INVALID_RETURN_VALUE(\"AsyncIterable or Promise\",\"destination\",ret);ret=pt;const{destroy:destroy2,cleanup}=destroyer(ret,!1,!0);if(destroys.push(destroy2),isLastStream)lastStreamCleanup.push(cleanup)}else if(isNodeStream(stream)){if(isReadableNodeStream(ret)){finishCount+=2;const cleanup=pipe(ret,stream,finish,{end});if(isReadable(stream)&&isLastStream)lastStreamCleanup.push(cleanup)}else if(isIterable(ret))finishCount++,pump(ret,stream,finish,{end});else throw new ERR_INVALID_ARG_TYPE2(\"val\",[\"Readable\",\"Iterable\",\"AsyncIterable\"],ret);ret=stream}else ret=Duplex.from(stream)}if(signal!==null&&signal!==void 0&&signal.aborted||outerSignal!==null&&outerSignal!==void 0&&outerSignal.aborted)runOnNextTick(abort);return ret}function pipe(src,dst,finish,{end}){if(src.pipe(dst,{end}),end)src.once(\"end\",()=>dst.end());else finish();return eos(src,{readable:!0,writable:!1},(err)=>{const rState=src._readableState;if(err&&err.code===\"ERR_STREAM_PREMATURE_CLOSE\"&&rState&&rState.ended&&!rState.errored&&!rState.errorEmitted)src.once(\"end\",finish).once(\"error\",finish);else finish(err)}),eos(dst,{readable:!1,writable:!0},finish)}module.exports={pipelineImpl,pipeline}}}),require_compose=__commonJS({\"node_modules/readable-stream/lib/internal/streams/compose.js\"(exports2,module){var{pipeline}=require_pipeline(),Duplex=require_duplex(),{destroyer}=require_destroy(),{isNodeStream,isReadable,isWritable}=require_utils(),{AbortError:AbortError2,codes:{ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2,ERR_MISSING_ARGS}}=require_errors();module.exports=function compose(...streams){if(streams.length===0)throw new ERR_MISSING_ARGS(\"streams\");if(streams.length===1)return Duplex.from(streams[0]);const orgStreams=[...streams];if(typeof streams[0]===\"function\")streams[0]=Duplex.from(streams[0]);if(typeof streams[streams.length-1]===\"function\"){const idx=streams.length-1;streams[idx]=Duplex.from(streams[idx])}for(let n=0;n0&&!isWritable(streams[n]))throw new ERR_INVALID_ARG_VALUE2(`streams[${n}]`,orgStreams[n],\"must be writable\")}let ondrain,onfinish,onreadable,onclose,d;function onfinished(err){const cb=onclose;if(onclose=null,cb)cb(err);else if(err)d.destroy(err);else if(!readable&&!writable)d.destroy()}const head=streams[0],tail=pipeline(streams,onfinished),writable=!!isWritable(head),readable=!!isReadable(tail);if(d=new Duplex({writableObjectMode:!!(head!==null&&head!==void 0&&head.writableObjectMode),readableObjectMode:!!(tail!==null&&tail!==void 0&&tail.writableObjectMode),writable,readable}),writable)d._write=function(chunk,encoding,callback){if(head.write(chunk,encoding))callback();else ondrain=callback},d._final=function(callback){head.end(),onfinish=callback},head.on(\"drain\",function(){if(ondrain){const cb=ondrain;ondrain=null,cb()}}),tail.on(\"finish\",function(){if(onfinish){const cb=onfinish;onfinish=null,cb()}});if(readable)tail.on(\"readable\",function(){if(onreadable){const cb=onreadable;onreadable=null,cb()}}),tail.on(\"end\",function(){d.push(null)}),d._read=function(){while(!0){const buf=tail.read();if(buf===null){onreadable=d._read;return}if(!d.push(buf))return}};return d._destroy=function(err,callback){if(!err&&onclose!==null)err=new AbortError2;if(onreadable=null,ondrain=null,onfinish=null,onclose===null)callback(err);else onclose=callback,destroyer(tail,err)},d}}}),require_promises=__commonJS({\"node_modules/readable-stream/lib/stream/promises.js\"(exports2,module){var{ArrayPrototypePop,Promise:Promise2}=require_primordials(),{isIterable,isNodeStream}=require_utils(),{pipelineImpl:pl}=require_pipeline(),{finished:finished2}=require_end_of_stream();function pipeline(...streams){return new Promise2((resolve,reject)=>{let signal,end;const lastArg=streams[streams.length-1];if(lastArg&&typeof lastArg===\"object\"&&!isNodeStream(lastArg)&&!isIterable(lastArg)){const options=ArrayPrototypePop(streams);signal=options.signal,end=options.end}pl(streams,(err,value)=>{if(err)reject(err);else resolve(value)},{signal,end})})}module.exports={finished:finished2,pipeline}}}),require_stream=__commonJS({\"node_modules/readable-stream/lib/stream.js\"(exports2,module){var{ObjectDefineProperty,ObjectKeys,ReflectApply}=require_primordials(),{promisify:{custom:customPromisify}}=require_util(),{streamReturningOperators,promiseReturningOperators}=require_operators(),{codes:{ERR_ILLEGAL_CONSTRUCTOR}}=require_errors(),compose=require_compose(),{pipeline}=require_pipeline(),{destroyer}=require_destroy(),eos=require_end_of_stream(),promises2=require_promises(),utils=require_utils(),Stream=module.exports=require_legacy().Stream;Stream.isDisturbed=utils.isDisturbed,Stream.isErrored=utils.isErrored,Stream.isWritable=utils.isWritable,Stream.isReadable=utils.isReadable,Stream.Readable=require_readable();for(let key of ObjectKeys(streamReturningOperators)){let fn=function(...args){if(new.target)throw ERR_ILLEGAL_CONSTRUCTOR();return Stream.Readable.from(ReflectApply(op,this,args))};const op=streamReturningOperators[key];ObjectDefineProperty(fn,\"name\",{value:op.name}),ObjectDefineProperty(fn,\"length\",{value:op.length}),ObjectDefineProperty(Stream.Readable.prototype,key,{value:fn,enumerable:!1,configurable:!0,writable:!0})}for(let key of ObjectKeys(promiseReturningOperators)){let fn=function(...args){if(new.target)throw ERR_ILLEGAL_CONSTRUCTOR();return ReflectApply(op,this,args)};const op=promiseReturningOperators[key];ObjectDefineProperty(fn,\"name\",{value:op.name}),ObjectDefineProperty(fn,\"length\",{value:op.length}),ObjectDefineProperty(Stream.Readable.prototype,key,{value:fn,enumerable:!1,configurable:!0,writable:!0})}Stream.Writable=require_writable(),Stream.Duplex=require_duplex(),Stream.Transform=require_transform(),Stream.PassThrough=require_passthrough(),Stream.pipeline=pipeline;var{addAbortSignal}=require_add_abort_signal();Stream.addAbortSignal=addAbortSignal,Stream.finished=eos,Stream.destroy=destroyer,Stream.compose=compose,ObjectDefineProperty(Stream,\"promises\",{configurable:!0,enumerable:!0,get(){return promises2}}),ObjectDefineProperty(pipeline,customPromisify,{enumerable:!0,get(){return promises2.pipeline}}),ObjectDefineProperty(eos,customPromisify,{enumerable:!0,get(){return promises2.finished}}),Stream.Stream=Stream,Stream._isUint8Array=function isUint8Array(value){return value instanceof Uint8Array},Stream._uint8ArrayToBuffer=function _uint8ArrayToBuffer(chunk){return new Buffer(chunk.buffer,chunk.byteOffset,chunk.byteLength)}}});function createNativeStreamReadable(nativeType,Readable){var[pull,start,cancel,setClose,deinit,updateRef,drainFn]=globalThis[globalThis.Symbol.for('Bun.lazy')](nativeType),closer=[!1],handleNumberResult=function(nativeReadable,result,view,isClosed){if(result>0){const slice=view.subarray(0,result),remainder=view.subarray(result);if(slice.byteLength>0)nativeReadable.push(slice);if(isClosed)nativeReadable.push(null);return remainder.byteLength>0\?remainder:void 0}if(isClosed)nativeReadable.push(null);return view},handleArrayBufferViewResult=function(nativeReadable,result,view,isClosed){if(result.byteLength>0)nativeReadable.push(result);if(isClosed)nativeReadable.push(null);return view},DYNAMICALLY_ADJUST_CHUNK_SIZE=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!==\"1\";const finalizer=new FinalizationRegistry((ptr)=>ptr&&deinit(ptr)),MIN_BUFFER_SIZE=512;var NativeReadable=class NativeReadable2 extends Readable{#bunNativePtr;#refCount=1;#constructed=!1;#remainingChunk=void 0;#highWaterMark;#pendingRead=!1;#hasResized=!DYNAMICALLY_ADJUST_CHUNK_SIZE;#unregisterToken;constructor(ptr,options={}){super(options);if(typeof options.highWaterMark===\"number\")this.#highWaterMark=options.highWaterMark;else this.#highWaterMark=262144;this.#bunNativePtr=ptr,this.#constructed=!1,this.#remainingChunk=void 0,this.#pendingRead=!1,this.#unregisterToken={},finalizer.register(this,this.#bunNativePtr,this.#unregisterToken)}_read(maxToRead){if(this.#pendingRead)return;var ptr=this.#bunNativePtr;if(ptr===0){this.push(null);return}if(!this.#constructed)this.#internalConstruct(ptr);return this.#internalRead(this.#getRemainingChunk(maxToRead),ptr)}#internalConstruct(ptr){this.#constructed=!0;const result=start(ptr,this.#highWaterMark);if(typeof result===\"number\"&&result>1)this.#hasResized=!0,this.#highWaterMark=Math.min(this.#highWaterMark,result);if(drainFn){const drainResult=drainFn(ptr);if((drainResult\?.byteLength\?\?0)>0)this.push(drainResult)}}#getRemainingChunk(maxToRead=this.#highWaterMark){var chunk=this.#remainingChunk;if(chunk\?.byteLength\?\?0MIN_BUFFER_SIZE\?maxToRead:MIN_BUFFER_SIZE;this.#remainingChunk=chunk=new Buffer(size)}return chunk}#handleResult(result,view,isClosed){if(typeof result===\"number\"){if(result>=this.#highWaterMark&&!this.#hasResized&&!isClosed)this.#highWaterMark*=2,this.#hasResized=!0;return handleNumberResult(this,result,view,isClosed)}else if(typeof result===\"boolean\")return process.nextTick(()=>{this.push(null)}),view\?.byteLength\?\?0>0\?view:void 0;else if(ArrayBuffer.isView(result)){if(result.byteLength>=this.#highWaterMark&&!this.#hasResized&&!isClosed)this.#highWaterMark*=2,this.#hasResized=!0;return handleArrayBufferViewResult(this,result,view,isClosed)}else throw new Error(\"Invalid result from pull\")}#internalRead(view,ptr){closer[0]=!1;var result=pull(ptr,view,closer);if(@isPromise(result))return this.#pendingRead=!0,result.then((result2)=>{this.#pendingRead=!1,this.#remainingChunk=this.#handleResult(result2,view,closer[0])},(reason)=>{errorOrDestroy(this,reason)});else this.#remainingChunk=this.#handleResult(result,view,closer[0])}_destroy(error,callback){var ptr=this.#bunNativePtr;if(ptr===0){callback(error);return}if(finalizer.unregister(this.#unregisterToken),this.#bunNativePtr=0,updateRef)updateRef(ptr,!1);cancel(ptr,error),callback(error)}ref(){var ptr=this.#bunNativePtr;if(ptr===0)return;if(this.#refCount++===0)updateRef(ptr,!0)}unref(){var ptr=this.#bunNativePtr;if(ptr===0)return;if(this.#refCount--===1)updateRef(ptr,!1)}};if(!updateRef)NativeReadable.prototype.ref=void 0,NativeReadable.prototype.unref=void 0;return NativeReadable}var nativeReadableStreamPrototypes={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0};function getNativeReadableStreamPrototype(nativeType,Readable){return nativeReadableStreamPrototypes[nativeType]||=createNativeStreamReadable(nativeType,Readable)}function getNativeReadableStream(Readable,stream,options){if(!(stream&&typeof stream===\"object\"&&stream instanceof ReadableStream))return;const native=@direct(stream);if(!native)return;const{stream:ptr,data:type}=native;return new(getNativeReadableStreamPrototype(type,Readable))(ptr,options)}var Writable=require_writable(),NativeWritable=class NativeWritable2 extends Writable{#pathOrFdOrSink;#fileSink;#native=!0;_construct;_destroy;_final;constructor(pathOrFdOrSink,options={}){super(options);this._construct=this.#internalConstruct,this._destroy=this.#internalDestroy,this._final=this.#internalFinal,this.#pathOrFdOrSink=pathOrFdOrSink}#internalConstruct(cb){this._writableState.constructed=!0,this.constructed=!0,cb()}#lazyConstruct(){if(typeof this.#pathOrFdOrSink===\"object\")if(typeof this.#pathOrFdOrSink.write===\"function\")this.#fileSink=this.#pathOrFdOrSink;else throw new Error(\"Invalid FileSink\");else this.#fileSink=Bun.file(this.#pathOrFdOrSink).writer()}write(chunk,encoding,cb,native=this.#native){if(!native)return this.#native=!1,super.write(chunk,encoding,cb);if(!this.#fileSink)this.#lazyConstruct();var fileSink=this.#fileSink,result=fileSink.write(chunk);if(@isPromise(result))return result.then(()=>{this.emit(\"drain\"),fileSink.flush(!0)}),!1;if(fileSink.flush(!0),cb)cb(null,chunk.byteLength);return!0}end(chunk,encoding,cb,native=this.#native){return super.end(chunk,encoding,cb,native)}#internalDestroy(error,cb){if(this._writableState.destroyed=!0,cb)cb(error)}#internalFinal(cb){if(this.#fileSink)this.#fileSink.end();if(cb)cb()}ref(){if(!this.#fileSink)this.#lazyConstruct();this.#fileSink.ref()}unref(){if(!this.#fileSink)return;this.#fileSink.unref()}};const exports=require_stream(),promises=require_promises();return exports._getNativeReadableStreamPrototype=getNativeReadableStreamPrototype,exports.NativeWritable=NativeWritable,Object.defineProperty(exports,\"promises\",{configurable:!0,enumerable:!0,get(){return promises}}),exports[Symbol.for(\"::bunternal::\")]={_ReadableFromWeb,_ReadableFromWebForUndici},exports.eos=require_end_of_stream(),exports})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamPromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamWebCode = "(function (){\"use strict\";return{ReadableStream,ReadableStreamDefaultReader,ReadableStreamBYOBReader,ReadableStreamBYOBRequest,ReadableByteStreamController,ReadableStreamDefaultController,TransformStream,TransformStreamDefaultController,WritableStream,WritableStreamDefaultWriter,WritableStreamDefaultController,ByteLengthQueuingStrategy,CountQueuingStrategy}})\n"_s; +// + +// static constexpr ASCIILiteral NodeTimersCode = "(function (){\"use strict\";return{setTimeout,clearTimeout,setInterval,setImmediate,clearInterval,clearImmediate}})\n"_s; +// + +// static constexpr ASCIILiteral NodeTimersPromisesCode = "(function (){\"use strict\";var $;const symbolAsyncIterator=Symbol.asyncIterator;class ERR_INVALID_ARG_TYPE extends Error{constructor(name,expected,actual){super(`${name} must be ${expected}, ${typeof actual} given`);this.code=\"ERR_INVALID_ARG_TYPE\"}}class AbortError extends Error{constructor(){super(\"The operation was aborted\");this.code=\"ABORT_ERR\"}}function validateObject(object,name){if(object===null||typeof object!==\"object\")throw new ERR_INVALID_ARG_TYPE(name,\"Object\",object)}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}function validateAbortSignal(signal,name){if(typeof signal!==\"undefined\"&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE(name,\"AbortSignal\",signal)}function asyncIterator({next:nextFunction,return:returnFunction}){const result={};if(typeof nextFunction===\"function\")result.next=nextFunction;if(typeof returnFunction===\"function\")result.return=returnFunction;return result[symbolAsyncIterator]=function(){return this},result}function setTimeoutPromise(after=1,value,options={}){const arguments_=[].concat(value\?\?[]);try{validateObject(options,\"options\")}catch(error){return Promise.reject(error)}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return Promise.reject(error)}try{validateBoolean(reference,\"options.ref\")}catch(error){return Promise.reject(error)}if(signal\?.aborted)return Promise.reject(new AbortError);let onCancel;const returnValue=new Promise((resolve,reject)=>{const timeout=setTimeout(()=>resolve(value),after,...arguments_);if(!reference)timeout\?.unref\?.();if(signal)onCancel=()=>{clearTimeout(timeout),reject(new AbortError)},signal.addEventListener(\"abort\",onCancel)});if(typeof onCancel!==\"undefined\")returnValue.finally(()=>signal.removeEventListener(\"abort\",onCancel));return returnValue}function setImmediatePromise(value,options={}){try{validateObject(options,\"options\")}catch(error){return Promise.reject(error)}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return Promise.reject(error)}try{validateBoolean(reference,\"options.ref\")}catch(error){return Promise.reject(error)}if(signal\?.aborted)return Promise.reject(new AbortError);let onCancel;const returnValue=new Promise((resolve,reject)=>{const immediate=setImmediate(()=>resolve(value));if(!reference)immediate\?.unref\?.();if(signal)onCancel=()=>{clearImmediate(immediate),reject(new AbortError)},signal.addEventListener(\"abort\",onCancel)});if(typeof onCancel!==\"undefined\")returnValue.finally(()=>signal.removeEventListener(\"abort\",onCancel));return returnValue}function setIntervalPromise(after=1,value,options={}){try{validateObject(options,\"options\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}try{validateBoolean(reference,\"options.ref\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}if(signal\?.aborted)return asyncIterator({next:function(){return Promise.reject(new AbortError)}});let onCancel,interval;try{let notYielded=0,callback;if(interval=setInterval(()=>{if(notYielded++,callback)callback(),callback=void 0},after),!reference)interval\?.unref\?.();if(signal)onCancel=()=>{if(clearInterval(interval),callback)callback(),callback=void 0},signal.addEventListener(\"abort\",onCancel);return asyncIterator({next:function(){return new Promise((resolve,reject)=>{if(!signal\?.aborted)if(notYielded===0)callback=resolve;else resolve();else if(notYielded===0)reject(new AbortError);else resolve()}).then(()=>{if(notYielded>0)return notYielded=notYielded-1,{done:!1,value};return{done:!0}})},return:function(){return clearInterval(interval),signal\?.removeEventListener(\"abort\",onCancel),Promise.resolve({})}})}catch(error){return asyncIterator({next:function(){clearInterval(interval),signal\?.removeEventListener(\"abort\",onCancel)}})}}return $={setTimeout:setTimeoutPromise,setImmediate:setImmediatePromise,setInterval:setIntervalPromise,scheduler:{wait:(delay,options)=>setTimeoutPromise(delay,void 0,options),yield:setImmediatePromise}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeTLSCode = "(function (){\"use strict\";const{isArrayBufferView,isTypedArray}=@requireNativeModule(\"node:util/types\"),net=@getInternalField(@internalModuleRegistry,22)||@createInternalModuleById(22),{Server:NetServer,[Symbol.for(\"::bunternal::\")]:InternalTCPSocket}=net,bunSocketInternal=Symbol.for(\"::bunnetsocketinternal::\"),{rootCertificates,canonicalizeIP}=globalThis[globalThis.Symbol.for('Bun.lazy')](\"internal/tls\"),SymbolReplace=Symbol.replace,RegExpPrototypeSymbolReplace=RegExp.prototype[SymbolReplace],RegExpPrototypeExec=RegExp.prototype.exec,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeSlice=String.prototype.slice,StringPrototypeIncludes=String.prototype.includes,StringPrototypeSplit=String.prototype.split,StringPrototypeIndexOf=String.prototype.indexOf,StringPrototypeSubstring=String.prototype.substring,StringPrototypeEndsWith=String.prototype.endsWith,StringFromCharCode=String.fromCharCode,StringPrototypeCharCodeAt=String.prototype.charCodeAt,ArrayPrototypeIncludes=Array.prototype.includes,ArrayPrototypeJoin=Array.prototype.join,ArrayPrototypeForEach=Array.prototype.forEach,ArrayPrototypePush=Array.prototype.push,ArrayPrototypeSome=Array.prototype.some,ArrayPrototypeReduce=Array.prototype.reduce;function parseCertString(){throwNotImplemented(\"Not implemented\")}function isValidTLSArray(obj){if(typeof obj===\"string\"||isTypedArray(obj)||obj instanceof ArrayBuffer||obj instanceof Blob)return!0;if(Array.isArray(obj)){for(var i=0;iRegExpPrototypeExec.call(/[^\\u0021-\\u007F]/u,s)!==null;if(ArrayPrototypeSome.call(patternParts,isBad))return!1;for(let i=hostParts.length-1;i>0;i-=1)if(hostParts[i]!==patternParts[i])return!1;const hostSubdomain=hostParts[0],patternSubdomain=patternParts[0],patternSubdomainParts=StringPrototypeSplit.call(patternSubdomain,\"*\");if(patternSubdomainParts.length===1||StringPrototypeIncludes.call(patternSubdomain,\"xn--\"))return hostSubdomain===patternSubdomain;if(!wildcards)return!1;if(patternSubdomainParts.length>2)return!1;if(patternParts.length<=2)return!1;const{0:prefix,1:suffix}=patternSubdomainParts;if(prefix.length+suffix.length>hostSubdomain.length)return!1;if(!StringPrototypeStartsWith.call(hostSubdomain,prefix))return!1;if(!StringPrototypeEndsWith.call(hostSubdomain,suffix))return!1;return!0}const jsonStringPattern=/^\"(\?:[^\"\\\\\\u0000-\\u001f]|\\\\(\?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4}))*\"/;function splitEscapedAltNames(altNames){const result=[];let currentToken=\"\",offset=0;while(offset!==altNames.length){const nextSep=StringPrototypeIndexOf.call(altNames,\", \",offset),nextQuote=StringPrototypeIndexOf.call(altNames,'\"',offset);if(nextQuote!==-1&&(nextSep===-1||nextQuote{if(StringPrototypeStartsWith.call(name,\"DNS:\"))ArrayPrototypePush.call(dnsNames,StringPrototypeSlice.call(name,4));else if(StringPrototypeStartsWith.call(name,\"IP Address:\"))ArrayPrototypePush.call(ips,canonicalizeIP(StringPrototypeSlice.call(name,11)))})}let valid=!1,reason=\"Unknown reason\";if(hostname=unfqdn(hostname),net.isIP(hostname)){if(valid=ArrayPrototypeIncludes.call(ips,canonicalizeIP(hostname)),!valid)reason=`IP: ${hostname} is not in the cert's list: `+ArrayPrototypeJoin.call(ips,\", \")}else if(dnsNames.length>0||subject\?.CN){const hostParts=splitHost(hostname),wildcard=(pattern)=>check(hostParts,pattern,!0);if(dnsNames.length>0){if(valid=ArrayPrototypeSome.call(dnsNames,wildcard),!valid)reason=`Host: ${hostname}. is not in the cert's altnames: ${altNames}`}else{const cn=subject.CN;if(Array.isArray(cn))valid=ArrayPrototypeSome.call(cn,wildcard);else if(cn)valid=wildcard(cn);if(!valid)reason=`Host: ${hostname}. is not cert's CN: ${cn}`}}else reason=\"Cert does not contain a DNS name\";if(!valid){let error=new Error(`ERR_TLS_CERT_ALTNAME_INVALID: Hostname/IP does not match certificate's altnames: ${reason}`);return error.name=\"ERR_TLS_CERT_ALTNAME_INVALID\",error.reason=reason,error.host=host,error.cert=cert,error}}var InternalSecureContext=class SecureContext2{context;constructor(options){const context={};if(options){let key=options.key;if(key){if(!isValidTLSArray(key))@throwTypeError(\"key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.key=key}let cert=options.cert;if(cert){if(!isValidTLSArray(cert))@throwTypeError(\"cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.cert=cert}let ca=options.ca;if(ca){if(!isValidTLSArray(ca))@throwTypeError(\"ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.ca=ca}let passphrase=options.passphrase;if(passphrase&&typeof passphrase!==\"string\")@throwTypeError(\"passphrase argument must be an string\");this.passphrase=passphrase;let servername=options.servername;if(servername&&typeof servername!==\"string\")@throwTypeError(\"servername argument must be an string\");this.servername=servername;let secureOptions=options.secureOptions||0;if(secureOptions&&typeof secureOptions!==\"number\")@throwTypeError(\"secureOptions argument must be an number\");this.secureOptions=secureOptions}this.context=context}};function SecureContext(options){return new InternalSecureContext(options)}function createSecureContext(options){return new SecureContext(options)}function translatePeerCertificate(c){if(!c)return null;if(c.issuerCertificate!=null&&c.issuerCertificate!==c)c.issuerCertificate=translatePeerCertificate(c.issuerCertificate);if(c.infoAccess!=null){const info=c.infoAccess;c.infoAccess={__proto__:null},RegExpPrototypeSymbolReplace.call(/([^\\n:]*):([^\\n]*)(\?:\\n|$)/g,info,(all,key,val)=>{if(val.charCodeAt(0)===34)val=JSONParse(val);if(key in c.infoAccess)ArrayPrototypePush.call(c.infoAccess[key],val);else c.infoAccess[key]=[val]})}return c}const buntls=Symbol.for(\"::buntls::\");var SocketClass;const TLSSocket=function(InternalTLSSocket){return SocketClass=InternalTLSSocket,Object.defineProperty(SocketClass.prototype,Symbol.toStringTag,{value:\"TLSSocket\",enumerable:!1}),Object.defineProperty(function Socket(options){return new InternalTLSSocket(options)},Symbol.hasInstance,{value(instance){return instance instanceof InternalTLSSocket}})}(class TLSSocket2 extends InternalTCPSocket{#secureContext;ALPNProtocols;#socket;#checkServerIdentity;#session;constructor(socket,options){super(socket instanceof InternalTCPSocket\?options:options||socket);if(options=options||socket||{},typeof options===\"object\"){const{ALPNProtocols}=options;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,this);if(socket instanceof InternalTCPSocket)this.#socket=socket}this.#secureContext=options.secureContext||createSecureContext(options),this.authorized=!1,this.secureConnecting=!0,this._secureEstablished=!1,this._securePending=!0,this.#checkServerIdentity=options.checkServerIdentity||checkServerIdentity,this.#session=options.session||null}_secureEstablished=!1;_securePending=!0;_newSessionPending;_controlReleased;secureConnecting=!1;_SNICallback;servername;authorized=!1;authorizationError;#renegotiationDisabled=!1;encrypted=!0;_start(){this.connect()}getSession(){return this[bunSocketInternal]\?.getSession()}getEphemeralKeyInfo(){return this[bunSocketInternal]\?.getEphemeralKeyInfo()}getCipher(){return this[bunSocketInternal]\?.getCipher()}getSharedSigalgs(){return this[bunSocketInternal]\?.getSharedSigalgs()}getProtocol(){return this[bunSocketInternal]\?.getTLSVersion()}getFinished(){return this[bunSocketInternal]\?.getTLSFinishedMessage()||void 0}getPeerFinished(){return this[bunSocketInternal]\?.getTLSPeerFinishedMessage()||void 0}isSessionReused(){return!!this.#session}renegotiate(){if(this.#renegotiationDisabled){const error=new Error(\"ERR_TLS_RENEGOTIATION_DISABLED: TLS session renegotiation disabled for this socket\");throw error.name=\"ERR_TLS_RENEGOTIATION_DISABLED\",error}throw Error(\"Not implented in Bun yet\")}disableRenegotiation(){this.#renegotiationDisabled=!0}getTLSTicket(){return this[bunSocketInternal]\?.getTLSTicket()}exportKeyingMaterial(length,label,context){if(context)return this[bunSocketInternal]\?.exportKeyingMaterial(length,label,context);return this[bunSocketInternal]\?.exportKeyingMaterial(length,label)}setMaxSendFragment(size){return this[bunSocketInternal]\?.setMaxSendFragment(size)||!1}enableTrace(){}setServername(name){if(this.isServer){let error=new Error(\"ERR_TLS_SNI_FROM_SERVER: Cannot issue SNI from a TLS server-side socket\");throw error.name=\"ERR_TLS_SNI_FROM_SERVER\",error}this.servername=name,this[bunSocketInternal]\?.setServername(name)}setSession(session){if(this.#session=session,typeof session===\"string\")session=Buffer.from(session,\"latin1\");return this[bunSocketInternal]\?.setSession(session)}getPeerCertificate(abbreviated){const cert=arguments.length<1\?this[bunSocketInternal]\?.getPeerCertificate():this[bunSocketInternal]\?.getPeerCertificate(abbreviated);if(cert)return translatePeerCertificate(cert)}getCertificate(){const cert=this[bunSocketInternal]\?.getCertificate();if(cert)return translatePeerCertificate(cert)}getPeerX509Certificate(){throw Error(\"Not implented in Bun yet\")}getX509Certificate(){throw Error(\"Not implented in Bun yet\")}get alpnProtocol(){return this[bunSocketInternal]\?.alpnProtocol}[buntls](port,host2){return{socket:this.#socket,ALPNProtocols:this.ALPNProtocols,serverName:this.servername||host2||\"localhost\",checkServerIdentity:this.#checkServerIdentity,session:this.#session,...this.#secureContext}}});class Server extends NetServer{key;cert;ca;passphrase;secureOptions;_rejectUnauthorized;_requestCert;servername;ALPNProtocols;constructor(options,secureConnectionListener){super(options,secureConnectionListener);this.setSecureContext(options)}setSecureContext(options){if(options instanceof InternalSecureContext)options=options.context;if(options){const{ALPNProtocols}=options;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,this);let key=options.key;if(key){if(!isValidTLSArray(key))@throwTypeError(\"key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.key=key}let cert=options.cert;if(cert){if(!isValidTLSArray(cert))@throwTypeError(\"cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.cert=cert}let ca=options.ca;if(ca){if(!isValidTLSArray(ca))@throwTypeError(\"ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.ca=ca}let passphrase=options.passphrase;if(passphrase&&typeof passphrase!==\"string\")@throwTypeError(\"passphrase argument must be an string\");this.passphrase=passphrase;let servername=options.servername;if(servername&&typeof servername!==\"string\")@throwTypeError(\"servername argument must be an string\");this.servername=servername;let secureOptions=options.secureOptions||0;if(secureOptions&&typeof secureOptions!==\"number\")@throwTypeError(\"secureOptions argument must be an number\");this.secureOptions=secureOptions;const requestCert=options.requestCert||!1;if(requestCert)this._requestCert=requestCert;else this._requestCert=void 0;const rejectUnauthorized=options.rejectUnauthorized||!1;if(rejectUnauthorized)this._rejectUnauthorized=rejectUnauthorized;else this._rejectUnauthorized=void 0}}getTicketKeys(){throw Error(\"Not implented in Bun yet\")}setTicketKeys(){throw Error(\"Not implented in Bun yet\")}[buntls](port,host2,isClient){return[{serverName:this.servername||host2||\"localhost\",key:this.key,cert:this.cert,ca:this.ca,passphrase:this.passphrase,secureOptions:this.secureOptions,rejectUnauthorized:isClient\?!1:this._rejectUnauthorized,requestCert:isClient\?!1:this._requestCert,ALPNProtocols:this.ALPNProtocols},SocketClass]}}function createServer(options,connectionListener){return new Server(options,connectionListener)}const CLIENT_RENEG_LIMIT=3,CLIENT_RENEG_WINDOW=600,DEFAULT_ECDH_CURVE=\"auto\",DEFAULT_CIPHERS=\"DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256\",DEFAULT_MIN_VERSION=\"TLSv1.2\",DEFAULT_MAX_VERSION=\"TLSv1.3\",createConnection=(port,host2,connectListener)=>{if(typeof port===\"object\"){port.checkServerIdentity;const{ALPNProtocols}=port;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,port);return new TLSSocket(port).connect(port,host2,connectListener)}return new TLSSocket().connect(port,host2,connectListener)},connect=createConnection;function getCiphers(){return DEFAULT_CIPHERS.split(\":\")}function convertProtocols(protocols){const lens=new Array(protocols.length),buff=Buffer.allocUnsafe(ArrayPrototypeReduce.call(protocols,(p,c,i)=>{const len=Buffer.byteLength(c);if(len>255)@throwRangeError(\"The byte length of the protocol at index \"+`${i} exceeds the maximum length.`,\"<= 255\",len,!0);return lens[i]=len,p+1+len},0));let offset=0;for(let i=0,c=protocols.length;i\",'\"',\"`\",\" \",\"\\r\",\"\\n\",\"\\t\"],unwise=[\"{\",\"}\",\"|\",\"\\\\\",\"^\",\"`\"].concat(delims),autoEscape=[\"'\"].concat(unwise),nonHostChars=[\"%\",\"/\",\"\?\",\";\",\"#\"].concat(autoEscape),hostEndingChars=[\"/\",\"\?\",\"#\"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,\"javascript:\":!0},hostlessProtocol={javascript:!0,\"javascript:\":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,\"http:\":!0,\"https:\":!0,\"ftp:\":!0,\"gopher:\":!0,\"file:\":!0};function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&typeof url===\"object\"&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(typeof url!==\"string\")@throwTypeError(\"Parameter 'url' must be a string, not \"+typeof url);var queryIndex=url.indexOf(\"\?\"),splitter=queryIndex!==-1&&queryIndex127)newpart+=\"x\";else newpart+=part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(hostnamePartStart);if(bit)validParts.push(bit[1]),notHost.unshift(bit[2]);if(notHost.length)rest=\"/\"+notHost.join(\".\")+rest;this.hostname=validParts.join(\".\");break}}}}if(this.hostname.length>hostnameMaxLen)this.hostname=\"\";else this.hostname=this.hostname.toLowerCase();if(!ipv6Hostname)this.hostname=new URL(\"http://\"+this.hostname).hostname;var p=this.port\?\":\"+this.port:\"\",h=this.hostname||\"\";if(this.host=h+p,this.href+=this.host,ipv6Hostname){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),rest[0]!==\"/\")rest=\"/\"+rest}}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length;i0\?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.hostname=authInHost.shift(),result.host=result.hostname}if(result.search=relative.search,result.query=relative.query,result.pathname!==null||result.search!==null)result.path=(result.pathname\?result.pathname:\"\")+(result.search\?result.search:\"\");return result.href=result.format(),result}if(!srcPath.length){if(result.pathname=null,result.search)result.path=\"/\"+result.search;else result.path=null;return result.href=result.format(),result}var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&(last===\".\"||last===\"..\")||last===\"\",up=0;for(var i=srcPath.length;i>=0;i--)if(last=srcPath[i],last===\".\")srcPath.splice(i,1);else if(last===\"..\")srcPath.splice(i,1),up++;else if(up)srcPath.splice(i,1),up--;if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift(\"..\");if(mustEndAbs&&srcPath[0]!==\"\"&&(!srcPath[0]||srcPath[0].charAt(0)!==\"/\"))srcPath.unshift(\"\");if(hasTrailingSlash&&srcPath.join(\"/\").substr(-1)!==\"/\")srcPath.push(\"\");var isAbsolute=srcPath[0]===\"\"||srcPath[0]&&srcPath[0].charAt(0)===\"/\";if(psychotic){result.hostname=isAbsolute\?\"\":srcPath.length\?srcPath.shift():\"\",result.host=result.hostname;var authInHost=result.host&&result.host.indexOf(\"@\")>0\?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.hostname=authInHost.shift(),result.host=result.hostname}if(mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute)srcPath.unshift(\"\");if(srcPath.length>0)result.pathname=srcPath.join(\"/\");else result.pathname=null,result.path=null;if(result.pathname!==null||result.search!==null)result.path=(result.pathname\?result.pathname:\"\")+(result.search\?result.search:\"\");return result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=portPattern.exec(host);if(port){if(port=port[0],port!==\":\")this.port=port.substr(1);host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};function urlToHttpOptions(url){const options={protocol:url.protocol,hostname:typeof url.hostname===\"string\"&&url.hostname.startsWith(\"[\")\?url.hostname.slice(1,-1):url.hostname,hash:url.hash,search:url.search,pathname:url.pathname,path:`${url.pathname||\"\"}${url.search||\"\"}`,href:url.href};if(url.port!==\"\")options.port=Number(url.port);if(url.username||url.password)options.auth=`${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;return options}const pathToFileURL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"pathToFileURL\"),fileURLToPath=globalThis[globalThis.Symbol.for('Bun.lazy')](\"fileURLToPath\");return{parse:urlParse,resolve:urlResolve,resolveObject:urlResolveObject,format:urlFormat,Url,URLSearchParams,URL,pathToFileURL,fileURLToPath,urlToHttpOptions}})\n"_s; +// + +// static constexpr ASCIILiteral NodeUtilCode = "(function (){\"use strict\";const types=@requireNativeModule(\"node:util/types\");var cjs_exports={};function isBufferInterface({copy,fill,readUint8}){return typeof copy===\"function\"&&typeof fill===\"function\"&&typeof readUint8===\"function\"}function isBuffer(value){return Buffer.isBuffer(value)||typeof value===\"object\"&&isBufferInterface(value||{})}function isFunction(value){return typeof value===\"function\"}const deepEquals=Bun.deepEquals,isDeepStrictEqual=(a,b)=>deepEquals(a,b,!0);var getOwnPropertyDescriptors=Object.getOwnPropertyDescriptors,formatRegExp=/%[sdj%]/g;function format(f){if(!isString(f)){var objects=[];for(var i=0;i=len)return x2;switch(x2){case\"%s\":return String(args[i++]);case\"%d\":return Number(args[i++]);case\"%j\":try{return JSON.stringify(args[i++])}catch(_){return\"[Circular]\"}default:return x2}});for(var x=args[i];i=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts))ctx.showHidden=opts;else if(opts)_extend(ctx,opts);if(isUndefined(ctx.showHidden))ctx.showHidden=!1;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=!1;if(isUndefined(ctx.customInspect))ctx.customInspect=!0;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:\"cyan\",number:\"yellow\",boolean:\"yellow\",undefined:\"grey\",null:\"bold\",string:\"green\",date:\"magenta\",regexp:\"red\"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style)return\"\\x1B[\"+inspect.colors[style][0]+\"m\"+str+\"\\x1B[\"+inspect.colors[style][1]+\"m\";else return str}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};return array.forEach(function(val,idx){hash[val]=!0}),hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret))ret=formatValue(ctx,ret,recurseTimes);return ret}var primitive=formatPrimitive(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=arrayToHash(keys);if(ctx.showHidden)keys=Object.getOwnPropertyNames(value);if(isError(value)&&(keys.indexOf(\"message\")>=0||keys.indexOf(\"description\")>=0))return formatError(value);if(keys.length===0){if(isFunction(value)){var name=value.name\?\": \"+value.name:\"\";return ctx.stylize(\"[Function\"+name+\"]\",\"special\")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),\"regexp\");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),\"date\");if(isError(value))return formatError(value)}var base=\"\",array=!1,braces=[\"{\",\"}\"];if(@isArray(value))array=!0,braces=[\"[\",\"]\"];if(isFunction(value)){var n=value.name\?\": \"+value.name:\"\";base=\" [Function\"+n+\"]\"}if(isRegExp(value))base=\" \"+RegExp.prototype.toString.call(value);if(isDate(value))base=\" \"+Date.prototype.toUTCString.call(value);if(isError(value))base=\" \"+formatError(value);if(keys.length===0&&(!array||value.length==0))return braces[0]+base+braces[1];if(recurseTimes<0)if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),\"regexp\");else return ctx.stylize(\"[Object]\",\"special\");ctx.seen.push(value);var output;if(array)output=formatArray(ctx,value,recurseTimes,visibleKeys,keys);else output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)});return ctx.seen.pop(),reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize(\"undefined\",\"undefined\");if(isString(value)){var simple=\"'\"+JSON.stringify(value).replace(/^\"|\"$/g,\"\").replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"')+\"'\";return ctx.stylize(simple,\"string\")}if(isNumber(value))return ctx.stylize(\"\"+value,\"number\");if(isBoolean(value))return ctx.stylize(\"\"+value,\"boolean\");if(isNull(value))return ctx.stylize(\"null\",\"null\")}function formatError(value){return\"[\"+Error.prototype.toString.call(value)+\"]\"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i-1)if(array)str=str.split(\"\\n\").map(function(line){return\" \"+line}).join(\"\\n\").substr(2);else str=\"\\n\"+str.split(\"\\n\").map(function(line){return\" \"+line}).join(\"\\n\")}else str=ctx.stylize(\"[Circular]\",\"special\");if(isUndefined(name)){if(array&&key.match(/^\\d+$/))return str;if(name=JSON.stringify(\"\"+key),name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/))name=name.substr(1,name.length-2),name=ctx.stylize(name,\"name\");else name=name.replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"').replace(/(^\"|\"$)/g,\"'\"),name=ctx.stylize(name,\"string\")}return name+\": \"+str}function reduceToSingleString(output,base,braces){var numLinesEst=0,length=output.reduce(function(prev,cur){if(numLinesEst++,cur.indexOf(\"\\n\")>=0)numLinesEst++;return prev+cur.replace(/\\u001b\\[\\d\\d\?m/g,\"\").length+1},0);if(length>60)return braces[0]+(base===\"\"\?\"\":base+\"\\n \")+\" \"+output.join(\",\\n \")+\" \"+braces[1];return braces[0]+base+\" \"+output.join(\", \")+\" \"+braces[1]}function isBoolean(arg){return typeof arg===\"boolean\"}function isNull(arg){return arg===null}function isNullOrUndefined(arg){return arg==null}function isNumber(arg){return typeof arg===\"number\"}function isString(arg){return typeof arg===\"string\"}function isSymbol(arg){return typeof arg===\"symbol\"}function isUndefined(arg){return arg===void 0}var isRegExp=types.isRegExp;function isObject(arg){return typeof arg===\"object\"&&arg!==null}var{isDate,isNativeError:isError}=types;function isPrimitive(arg){return arg===null||typeof arg===\"boolean\"||typeof arg===\"number\"||typeof arg===\"string\"||typeof arg===\"symbol\"||typeof arg===\"undefined\"}function pad(n){return n<10\?\"0\"+n.toString(10):n.toString(10)}var months=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];function timestamp(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(\":\");return[d.getDate(),months[d.getMonth()],time].join(\" \")}var log=function log(){console.log(\"%s - %s\",timestamp(),format.apply(cjs_exports,arguments))},inherits=function inherits(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})},_extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add),i=keys.length;while(i--)origin[keys[i]]=add[keys[i]];return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}var kCustomPromisifiedSymbol=Symbol.for(\"util.promisify.custom\"),promisify=function promisify(original){if(typeof original!==\"function\")@throwTypeError('The \"original\" argument must be of type Function');if(kCustomPromisifiedSymbol&&original[kCustomPromisifiedSymbol]){var fn=original[kCustomPromisifiedSymbol];if(typeof fn!==\"function\")@throwTypeError('The \"util.promisify.custom\" argument must be of type Function');return Object.defineProperty(fn,kCustomPromisifiedSymbol,{value:fn,enumerable:!1,writable:!1,configurable:!0}),fn}function fn(){var promiseResolve,promiseReject,promise=new Promise(function(resolve,reject){promiseResolve=resolve,promiseReject=reject}),args=[];for(var i=0;i{return(input+\"\").toWellFormed()};return Object.assign(cjs_exports,{format,deprecate,debuglog,_extend,inspect,types,isArray:@isArray,isBoolean,isNull,isNullOrUndefined,isNumber,isString,isSymbol,isUndefined,isRegExp,isObject,isDate,isFunction,isError,isPrimitive,isBuffer,log,inherits,toUSVString,promisify,callbackify,isDeepStrictEqual,TextDecoder,TextEncoder})})\n"_s; +// + +// static constexpr ASCIILiteral NodeV8Code = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),jsc=@requireNativeModule(\"bun:jsc\");function notimpl(message){throwNotImplemented(\"node:v8 \"+message)}class Deserializer{constructor(){notimpl(\"Deserializer\")}}class Serializer{constructor(){notimpl(\"Serializer\")}}class DefaultDeserializer extends Deserializer{constructor(){super(...arguments)}}class DefaultSerializer extends Serializer{constructor(){super(...arguments)}}class GCProfiler{constructor(){notimpl(\"GCProfiler\")}}function cachedDataVersionTag(){notimpl(\"cachedDataVersionTag\")}function getHeapSnapshot(){notimpl(\"getHeapSnapshot\")}function getHeapStatistics(){notimpl(\"getHeapStatistics\")}function getHeapSpaceStatistics(){notimpl(\"getHeapSpaceStatistics\")}function getHeapCodeStatistics(){notimpl(\"getHeapCodeStatistics\")}function setFlagsFromString(){notimpl(\"setFlagsFromString\")}function deserialize(value){return jsc.deserialize(value)}function takeCoverage(){notimpl(\"takeCoverage\")}function stopCoverage(){notimpl(\"stopCoverage\")}function serialize(arg1){return jsc.serialize(arg1,{binaryType:\"nodebuffer\"})}function writeHeapSnapshot(){notimpl(\"writeHeapSnapshot\")}function setHeapSnapshotNearHeapLimit(){notimpl(\"setHeapSnapshotNearHeapLimit\")}return $={cachedDataVersionTag,getHeapSnapshot,getHeapStatistics,getHeapSpaceStatistics,getHeapCodeStatistics,setFlagsFromString,deserialize,takeCoverage,stopCoverage,serialize,writeHeapSnapshot,setHeapSnapshotNearHeapLimit,promiseHooks:{createHook:()=>{notimpl(\"createHook\")},onInit:()=>{notimpl(\"onInit\")},onBefore:()=>{notimpl(\"onBefore\")},onAfter:()=>{notimpl(\"onAfter\")},onSettled:()=>{notimpl(\"onSettled\")}},startupSnapshot:{addDeserializeCallback:()=>notimpl(\"addDeserializeCallback\"),addSerializeCallback:()=>notimpl(\"addSerializeCallback\"),setDeserializeMainFunction:()=>notimpl(\"setDeserializeMainFunction\"),isBuildingSnapshot:()=>notimpl(\"isBuildingSnapshot\")},Deserializer,Serializer},hideFromStack(notimpl,cachedDataVersionTag,getHeapSnapshot,getHeapStatistics,getHeapSpaceStatistics,getHeapCodeStatistics,setFlagsFromString,deserialize,takeCoverage,stopCoverage,serialize,writeHeapSnapshot,setHeapSnapshotNearHeapLimit,Deserializer,Serializer,DefaultDeserializer,DefaultSerializer,GCProfiler),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeVMCode = "(function (){\"use strict\";const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),vm=globalThis[globalThis.Symbol.for('Bun.lazy')](\"vm\"),{createContext,isContext,Script,runInNewContext,runInThisContext}=vm;function runInContext(code,context,options){return new Script(code,options).runInContext(context)}function compileFunction(){throwNotImplemented(\"node:vm compileFunction\")}function measureMemory(){throwNotImplemented(\"node:vm measureMemory\")}class Module{constructor(){throwNotImplemented(\"node:vm Module\")}}class SourceTextModule{constructor(){throwNotImplemented(\"node:vm Module\")}}class SyntheticModule{constructor(){throwNotImplemented(\"node:vm Module\")}}return{createContext,runInContext,runInNewContext,runInThisContext,isContext,compileFunction,measureMemory,Script,Module,SourceTextModule,SyntheticModule}})\n"_s; +// + +// static constexpr ASCIILiteral NodeWasiCode = "(function (){\"use strict\";const nodeFsConstants=@processBindingConstants.fs;var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require2(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_types=__commonJS({\"node_modules/wasi-js/dist/types.js\"(exports){Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.WASIKillError=exports.WASIExitError=exports.WASIError=void 0;var WASIError=class extends Error{constructor(errno){super();this.errno=errno,Object.setPrototypeOf(this,WASIError.prototype)}};exports.WASIError=WASIError;var WASIExitError=class extends Error{constructor(code){super(`WASI Exit error: ${code}`);this.code=code,Object.setPrototypeOf(this,WASIExitError.prototype)}};exports.WASIExitError=WASIExitError;var WASIKillError=class extends Error{constructor(signal){super(`WASI Kill signal: ${signal}`);this.signal=signal,Object.setPrototypeOf(this,WASIKillError.prototype)}};exports.WASIKillError=WASIKillError}}),require_constants=__commonJS({\"node_modules/wasi-js/dist/constants.js\"(exports){Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.WASI_ENOMSG=exports.WASI_ENOMEM=exports.WASI_ENOLINK=exports.WASI_ENOLCK=exports.WASI_ENOEXEC=exports.WASI_ENOENT=exports.WASI_ENODEV=exports.WASI_ENOBUFS=exports.WASI_ENFILE=exports.WASI_ENETUNREACH=exports.WASI_ENETRESET=exports.WASI_ENETDOWN=exports.WASI_ENAMETOOLONG=exports.WASI_EMULTIHOP=exports.WASI_EMSGSIZE=exports.WASI_EMLINK=exports.WASI_EMFILE=exports.WASI_ELOOP=exports.WASI_EISDIR=exports.WASI_EISCONN=exports.WASI_EIO=exports.WASI_EINVAL=exports.WASI_EINTR=exports.WASI_EINPROGRESS=exports.WASI_EILSEQ=exports.WASI_EIDRM=exports.WASI_EHOSTUNREACH=exports.WASI_EFBIG=exports.WASI_EFAULT=exports.WASI_EEXIST=exports.WASI_EDQUOT=exports.WASI_EDOM=exports.WASI_EDESTADDRREQ=exports.WASI_EDEADLK=exports.WASI_ECONNRESET=exports.WASI_ECONNREFUSED=exports.WASI_ECONNABORTED=exports.WASI_ECHILD=exports.WASI_ECANCELED=exports.WASI_EBUSY=exports.WASI_EBADMSG=exports.WASI_EBADF=exports.WASI_EALREADY=exports.WASI_EAGAIN=exports.WASI_EAFNOSUPPORT=exports.WASI_EADDRNOTAVAIL=exports.WASI_EADDRINUSE=exports.WASI_EACCES=exports.WASI_E2BIG=exports.WASI_ESUCCESS=void 0,exports.WASI_SIGVTALRM=exports.WASI_SIGUSR2=exports.WASI_SIGUSR1=exports.WASI_SIGURG=exports.WASI_SIGTTOU=exports.WASI_SIGTTIN=exports.WASI_SIGTSTP=exports.WASI_SIGTRAP=exports.WASI_SIGTERM=exports.WASI_SIGSTOP=exports.WASI_SIGSEGV=exports.WASI_SIGQUIT=exports.WASI_SIGPIPE=exports.WASI_SIGKILL=exports.WASI_SIGINT=exports.WASI_SIGILL=exports.WASI_SIGHUP=exports.WASI_SIGFPE=exports.WASI_SIGCONT=exports.WASI_SIGCHLD=exports.WASI_SIGBUS=exports.WASI_SIGALRM=exports.WASI_SIGABRT=exports.WASI_ENOTCAPABLE=exports.WASI_EXDEV=exports.WASI_ETXTBSY=exports.WASI_ETIMEDOUT=exports.WASI_ESTALE=exports.WASI_ESRCH=exports.WASI_ESPIPE=exports.WASI_EROFS=exports.WASI_ERANGE=exports.WASI_EPROTOTYPE=exports.WASI_EPROTONOSUPPORT=exports.WASI_EPROTO=exports.WASI_EPIPE=exports.WASI_EPERM=exports.WASI_EOWNERDEAD=exports.WASI_EOVERFLOW=exports.WASI_ENXIO=exports.WASI_ENOTTY=exports.WASI_ENOTSUP=exports.WASI_ENOTSOCK=exports.WASI_ENOTRECOVERABLE=exports.WASI_ENOTEMPTY=exports.WASI_ENOTDIR=exports.WASI_ENOTCONN=exports.WASI_ENOSYS=exports.WASI_ENOSPC=exports.WASI_ENOPROTOOPT=void 0,exports.RIGHTS_REGULAR_FILE_BASE=exports.RIGHTS_CHARACTER_DEVICE_INHERITING=exports.RIGHTS_CHARACTER_DEVICE_BASE=exports.RIGHTS_BLOCK_DEVICE_INHERITING=exports.RIGHTS_BLOCK_DEVICE_BASE=exports.RIGHTS_ALL=exports.WASI_RIGHT_SOCK_SHUTDOWN=exports.WASI_RIGHT_POLL_FD_READWRITE=exports.WASI_RIGHT_PATH_UNLINK_FILE=exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY=exports.WASI_RIGHT_PATH_SYMLINK=exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES=exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE=exports.WASI_RIGHT_FD_FILESTAT_GET=exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES=exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE=exports.WASI_RIGHT_PATH_FILESTAT_GET=exports.WASI_RIGHT_PATH_RENAME_TARGET=exports.WASI_RIGHT_PATH_RENAME_SOURCE=exports.WASI_RIGHT_PATH_READLINK=exports.WASI_RIGHT_FD_READDIR=exports.WASI_RIGHT_PATH_OPEN=exports.WASI_RIGHT_PATH_LINK_TARGET=exports.WASI_RIGHT_PATH_LINK_SOURCE=exports.WASI_RIGHT_PATH_CREATE_FILE=exports.WASI_RIGHT_PATH_CREATE_DIRECTORY=exports.WASI_RIGHT_FD_ALLOCATE=exports.WASI_RIGHT_FD_ADVISE=exports.WASI_RIGHT_FD_WRITE=exports.WASI_RIGHT_FD_TELL=exports.WASI_RIGHT_FD_SYNC=exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS=exports.WASI_RIGHT_FD_SEEK=exports.WASI_RIGHT_FD_READ=exports.WASI_RIGHT_FD_DATASYNC=exports.WASI_FDFLAG_SYNC=exports.WASI_FDFLAG_RSYNC=exports.WASI_FDFLAG_NONBLOCK=exports.WASI_FDFLAG_DSYNC=exports.WASI_FDFLAG_APPEND=exports.WASI_FILETYPE_SYMBOLIC_LINK=exports.WASI_FILETYPE_SOCKET_STREAM=exports.WASI_FILETYPE_SOCKET_DGRAM=exports.WASI_FILETYPE_REGULAR_FILE=exports.WASI_FILETYPE_DIRECTORY=exports.WASI_FILETYPE_CHARACTER_DEVICE=exports.WASI_FILETYPE_BLOCK_DEVICE=exports.WASI_FILETYPE_UNKNOWN=exports.WASI_SIGXFSZ=exports.WASI_SIGXCPU=void 0,exports.SIGNAL_MAP=exports.ERROR_MAP=exports.WASI_WHENCE_END=exports.WASI_WHENCE_CUR=exports.WASI_WHENCE_SET=exports.WASI_STDERR_FILENO=exports.WASI_STDOUT_FILENO=exports.WASI_STDIN_FILENO=exports.WASI_DIRCOOKIE_START=exports.WASI_PREOPENTYPE_DIR=exports.WASI_O_TRUNC=exports.WASI_O_EXCL=exports.WASI_O_DIRECTORY=exports.WASI_O_CREAT=exports.WASI_FILESTAT_SET_MTIM_NOW=exports.WASI_FILESTAT_SET_MTIM=exports.WASI_FILESTAT_SET_ATIM_NOW=exports.WASI_FILESTAT_SET_ATIM=exports.WASI_EVENTTYPE_FD_WRITE=exports.WASI_EVENTTYPE_FD_READ=exports.WASI_EVENTTYPE_CLOCK=exports.WASI_CLOCK_THREAD_CPUTIME_ID=exports.WASI_CLOCK_PROCESS_CPUTIME_ID=exports.WASI_CLOCK_MONOTONIC=exports.WASI_CLOCK_REALTIME=exports.RIGHTS_TTY_INHERITING=exports.RIGHTS_TTY_BASE=exports.RIGHTS_SOCKET_INHERITING=exports.RIGHTS_SOCKET_BASE=exports.RIGHTS_DIRECTORY_INHERITING=exports.RIGHTS_DIRECTORY_BASE=exports.RIGHTS_REGULAR_FILE_INHERITING=void 0,exports.WASI_ESUCCESS=0,exports.WASI_E2BIG=1,exports.WASI_EACCES=2,exports.WASI_EADDRINUSE=3,exports.WASI_EADDRNOTAVAIL=4,exports.WASI_EAFNOSUPPORT=5,exports.WASI_EAGAIN=6,exports.WASI_EALREADY=7,exports.WASI_EBADF=8,exports.WASI_EBADMSG=9,exports.WASI_EBUSY=10,exports.WASI_ECANCELED=11,exports.WASI_ECHILD=12,exports.WASI_ECONNABORTED=13,exports.WASI_ECONNREFUSED=14,exports.WASI_ECONNRESET=15,exports.WASI_EDEADLK=16,exports.WASI_EDESTADDRREQ=17,exports.WASI_EDOM=18,exports.WASI_EDQUOT=19,exports.WASI_EEXIST=20,exports.WASI_EFAULT=21,exports.WASI_EFBIG=22,exports.WASI_EHOSTUNREACH=23,exports.WASI_EIDRM=24,exports.WASI_EILSEQ=25,exports.WASI_EINPROGRESS=26,exports.WASI_EINTR=27,exports.WASI_EINVAL=28,exports.WASI_EIO=29,exports.WASI_EISCONN=30,exports.WASI_EISDIR=31,exports.WASI_ELOOP=32,exports.WASI_EMFILE=33,exports.WASI_EMLINK=34,exports.WASI_EMSGSIZE=35,exports.WASI_EMULTIHOP=36,exports.WASI_ENAMETOOLONG=37,exports.WASI_ENETDOWN=38,exports.WASI_ENETRESET=39,exports.WASI_ENETUNREACH=40,exports.WASI_ENFILE=41,exports.WASI_ENOBUFS=42,exports.WASI_ENODEV=43,exports.WASI_ENOENT=44,exports.WASI_ENOEXEC=45,exports.WASI_ENOLCK=46,exports.WASI_ENOLINK=47,exports.WASI_ENOMEM=48,exports.WASI_ENOMSG=49,exports.WASI_ENOPROTOOPT=50,exports.WASI_ENOSPC=51,exports.WASI_ENOSYS=52,exports.WASI_ENOTCONN=53,exports.WASI_ENOTDIR=54,exports.WASI_ENOTEMPTY=55,exports.WASI_ENOTRECOVERABLE=56,exports.WASI_ENOTSOCK=57,exports.WASI_ENOTSUP=58,exports.WASI_ENOTTY=59,exports.WASI_ENXIO=60,exports.WASI_EOVERFLOW=61,exports.WASI_EOWNERDEAD=62,exports.WASI_EPERM=63,exports.WASI_EPIPE=64,exports.WASI_EPROTO=65,exports.WASI_EPROTONOSUPPORT=66,exports.WASI_EPROTOTYPE=67,exports.WASI_ERANGE=68,exports.WASI_EROFS=69,exports.WASI_ESPIPE=70,exports.WASI_ESRCH=71,exports.WASI_ESTALE=72,exports.WASI_ETIMEDOUT=73,exports.WASI_ETXTBSY=74,exports.WASI_EXDEV=75,exports.WASI_ENOTCAPABLE=76,exports.WASI_SIGABRT=0,exports.WASI_SIGALRM=1,exports.WASI_SIGBUS=2,exports.WASI_SIGCHLD=3,exports.WASI_SIGCONT=4,exports.WASI_SIGFPE=5,exports.WASI_SIGHUP=6,exports.WASI_SIGILL=7,exports.WASI_SIGINT=8,exports.WASI_SIGKILL=9,exports.WASI_SIGPIPE=10,exports.WASI_SIGQUIT=11,exports.WASI_SIGSEGV=12,exports.WASI_SIGSTOP=13,exports.WASI_SIGTERM=14,exports.WASI_SIGTRAP=15,exports.WASI_SIGTSTP=16,exports.WASI_SIGTTIN=17,exports.WASI_SIGTTOU=18,exports.WASI_SIGURG=19,exports.WASI_SIGUSR1=20,exports.WASI_SIGUSR2=21,exports.WASI_SIGVTALRM=22,exports.WASI_SIGXCPU=23,exports.WASI_SIGXFSZ=24,exports.WASI_FILETYPE_UNKNOWN=0,exports.WASI_FILETYPE_BLOCK_DEVICE=1,exports.WASI_FILETYPE_CHARACTER_DEVICE=2,exports.WASI_FILETYPE_DIRECTORY=3,exports.WASI_FILETYPE_REGULAR_FILE=4,exports.WASI_FILETYPE_SOCKET_DGRAM=5,exports.WASI_FILETYPE_SOCKET_STREAM=6,exports.WASI_FILETYPE_SYMBOLIC_LINK=7,exports.WASI_FDFLAG_APPEND=1,exports.WASI_FDFLAG_DSYNC=2,exports.WASI_FDFLAG_NONBLOCK=4,exports.WASI_FDFLAG_RSYNC=8,exports.WASI_FDFLAG_SYNC=16,exports.WASI_RIGHT_FD_DATASYNC=BigInt(1),exports.WASI_RIGHT_FD_READ=BigInt(2),exports.WASI_RIGHT_FD_SEEK=BigInt(4),exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS=BigInt(8),exports.WASI_RIGHT_FD_SYNC=BigInt(16),exports.WASI_RIGHT_FD_TELL=BigInt(32),exports.WASI_RIGHT_FD_WRITE=BigInt(64),exports.WASI_RIGHT_FD_ADVISE=BigInt(128),exports.WASI_RIGHT_FD_ALLOCATE=BigInt(256),exports.WASI_RIGHT_PATH_CREATE_DIRECTORY=BigInt(512),exports.WASI_RIGHT_PATH_CREATE_FILE=BigInt(1024),exports.WASI_RIGHT_PATH_LINK_SOURCE=BigInt(2048),exports.WASI_RIGHT_PATH_LINK_TARGET=BigInt(4096),exports.WASI_RIGHT_PATH_OPEN=BigInt(8192),exports.WASI_RIGHT_FD_READDIR=BigInt(16384),exports.WASI_RIGHT_PATH_READLINK=BigInt(32768),exports.WASI_RIGHT_PATH_RENAME_SOURCE=BigInt(65536),exports.WASI_RIGHT_PATH_RENAME_TARGET=BigInt(131072),exports.WASI_RIGHT_PATH_FILESTAT_GET=BigInt(262144),exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE=BigInt(524288),exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES=BigInt(1048576),exports.WASI_RIGHT_FD_FILESTAT_GET=BigInt(2097152),exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE=BigInt(4194304),exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES=BigInt(8388608),exports.WASI_RIGHT_PATH_SYMLINK=BigInt(16777216),exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY=BigInt(33554432),exports.WASI_RIGHT_PATH_UNLINK_FILE=BigInt(67108864),exports.WASI_RIGHT_POLL_FD_READWRITE=BigInt(134217728),exports.WASI_RIGHT_SOCK_SHUTDOWN=BigInt(268435456),exports.RIGHTS_ALL=exports.WASI_RIGHT_FD_DATASYNC|exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_SEEK|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_TELL|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_FD_ALLOCATE|exports.WASI_RIGHT_PATH_CREATE_DIRECTORY|exports.WASI_RIGHT_PATH_CREATE_FILE|exports.WASI_RIGHT_PATH_LINK_SOURCE|exports.WASI_RIGHT_PATH_LINK_TARGET|exports.WASI_RIGHT_PATH_OPEN|exports.WASI_RIGHT_FD_READDIR|exports.WASI_RIGHT_PATH_READLINK|exports.WASI_RIGHT_PATH_RENAME_SOURCE|exports.WASI_RIGHT_PATH_RENAME_TARGET|exports.WASI_RIGHT_PATH_FILESTAT_GET|exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_SYMLINK|exports.WASI_RIGHT_PATH_UNLINK_FILE|exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY|exports.WASI_RIGHT_POLL_FD_READWRITE|exports.WASI_RIGHT_SOCK_SHUTDOWN,exports.RIGHTS_BLOCK_DEVICE_BASE=exports.RIGHTS_ALL,exports.RIGHTS_BLOCK_DEVICE_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_CHARACTER_DEVICE_BASE=exports.RIGHTS_ALL,exports.RIGHTS_CHARACTER_DEVICE_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_REGULAR_FILE_BASE=exports.WASI_RIGHT_FD_DATASYNC|exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_SEEK|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_TELL|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_FD_ALLOCATE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_REGULAR_FILE_INHERITING=BigInt(0),exports.RIGHTS_DIRECTORY_BASE=exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_PATH_CREATE_DIRECTORY|exports.WASI_RIGHT_PATH_CREATE_FILE|exports.WASI_RIGHT_PATH_LINK_SOURCE|exports.WASI_RIGHT_PATH_LINK_TARGET|exports.WASI_RIGHT_PATH_OPEN|exports.WASI_RIGHT_FD_READDIR|exports.WASI_RIGHT_PATH_READLINK|exports.WASI_RIGHT_PATH_RENAME_SOURCE|exports.WASI_RIGHT_PATH_RENAME_TARGET|exports.WASI_RIGHT_PATH_FILESTAT_GET|exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_PATH_SYMLINK|exports.WASI_RIGHT_PATH_UNLINK_FILE|exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_DIRECTORY_INHERITING=exports.RIGHTS_DIRECTORY_BASE|exports.RIGHTS_REGULAR_FILE_BASE,exports.RIGHTS_SOCKET_BASE=exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_POLL_FD_READWRITE|exports.WASI_RIGHT_SOCK_SHUTDOWN,exports.RIGHTS_SOCKET_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_TTY_BASE=exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_TTY_INHERITING=BigInt(0),exports.WASI_CLOCK_REALTIME=0,exports.WASI_CLOCK_MONOTONIC=1,exports.WASI_CLOCK_PROCESS_CPUTIME_ID=2,exports.WASI_CLOCK_THREAD_CPUTIME_ID=3,exports.WASI_EVENTTYPE_CLOCK=0,exports.WASI_EVENTTYPE_FD_READ=1,exports.WASI_EVENTTYPE_FD_WRITE=2,exports.WASI_FILESTAT_SET_ATIM=1<<0,exports.WASI_FILESTAT_SET_ATIM_NOW=1<<1,exports.WASI_FILESTAT_SET_MTIM=1<<2,exports.WASI_FILESTAT_SET_MTIM_NOW=1<<3,exports.WASI_O_CREAT=1<<0,exports.WASI_O_DIRECTORY=1<<1,exports.WASI_O_EXCL=1<<2,exports.WASI_O_TRUNC=1<<3,exports.WASI_PREOPENTYPE_DIR=0,exports.WASI_DIRCOOKIE_START=0,exports.WASI_STDIN_FILENO=0,exports.WASI_STDOUT_FILENO=1,exports.WASI_STDERR_FILENO=2,exports.WASI_WHENCE_SET=0,exports.WASI_WHENCE_CUR=1,exports.WASI_WHENCE_END=2,exports.ERROR_MAP={E2BIG:exports.WASI_E2BIG,EACCES:exports.WASI_EACCES,EADDRINUSE:exports.WASI_EADDRINUSE,EADDRNOTAVAIL:exports.WASI_EADDRNOTAVAIL,EAFNOSUPPORT:exports.WASI_EAFNOSUPPORT,EALREADY:exports.WASI_EALREADY,EAGAIN:exports.WASI_EAGAIN,EBADF:exports.WASI_EBADF,EBADMSG:exports.WASI_EBADMSG,EBUSY:exports.WASI_EBUSY,ECANCELED:exports.WASI_ECANCELED,ECHILD:exports.WASI_ECHILD,ECONNABORTED:exports.WASI_ECONNABORTED,ECONNREFUSED:exports.WASI_ECONNREFUSED,ECONNRESET:exports.WASI_ECONNRESET,EDEADLOCK:exports.WASI_EDEADLK,EDESTADDRREQ:exports.WASI_EDESTADDRREQ,EDOM:exports.WASI_EDOM,EDQUOT:exports.WASI_EDQUOT,EEXIST:exports.WASI_EEXIST,EFAULT:exports.WASI_EFAULT,EFBIG:exports.WASI_EFBIG,EHOSTDOWN:exports.WASI_EHOSTUNREACH,EHOSTUNREACH:exports.WASI_EHOSTUNREACH,EIDRM:exports.WASI_EIDRM,EILSEQ:exports.WASI_EILSEQ,EINPROGRESS:exports.WASI_EINPROGRESS,EINTR:exports.WASI_EINTR,EINVAL:exports.WASI_EINVAL,EIO:exports.WASI_EIO,EISCONN:exports.WASI_EISCONN,EISDIR:exports.WASI_EISDIR,ELOOP:exports.WASI_ELOOP,EMFILE:exports.WASI_EMFILE,EMLINK:exports.WASI_EMLINK,EMSGSIZE:exports.WASI_EMSGSIZE,EMULTIHOP:exports.WASI_EMULTIHOP,ENAMETOOLONG:exports.WASI_ENAMETOOLONG,ENETDOWN:exports.WASI_ENETDOWN,ENETRESET:exports.WASI_ENETRESET,ENETUNREACH:exports.WASI_ENETUNREACH,ENFILE:exports.WASI_ENFILE,ENOBUFS:exports.WASI_ENOBUFS,ENODEV:exports.WASI_ENODEV,ENOENT:exports.WASI_ENOENT,ENOEXEC:exports.WASI_ENOEXEC,ENOLCK:exports.WASI_ENOLCK,ENOLINK:exports.WASI_ENOLINK,ENOMEM:exports.WASI_ENOMEM,ENOMSG:exports.WASI_ENOMSG,ENOPROTOOPT:exports.WASI_ENOPROTOOPT,ENOSPC:exports.WASI_ENOSPC,ENOSYS:exports.WASI_ENOSYS,ENOTCONN:exports.WASI_ENOTCONN,ENOTDIR:exports.WASI_ENOTDIR,ENOTEMPTY:exports.WASI_ENOTEMPTY,ENOTRECOVERABLE:exports.WASI_ENOTRECOVERABLE,ENOTSOCK:exports.WASI_ENOTSOCK,ENOTTY:exports.WASI_ENOTTY,ENXIO:exports.WASI_ENXIO,EOVERFLOW:exports.WASI_EOVERFLOW,EOWNERDEAD:exports.WASI_EOWNERDEAD,EPERM:exports.WASI_EPERM,EPIPE:exports.WASI_EPIPE,EPROTO:exports.WASI_EPROTO,EPROTONOSUPPORT:exports.WASI_EPROTONOSUPPORT,EPROTOTYPE:exports.WASI_EPROTOTYPE,ERANGE:exports.WASI_ERANGE,EROFS:exports.WASI_EROFS,ESPIPE:exports.WASI_ESPIPE,ESRCH:exports.WASI_ESRCH,ESTALE:exports.WASI_ESTALE,ETIMEDOUT:exports.WASI_ETIMEDOUT,ETXTBSY:exports.WASI_ETXTBSY,EXDEV:exports.WASI_EXDEV},exports.SIGNAL_MAP={[exports.WASI_SIGHUP]:\"SIGHUP\",[exports.WASI_SIGINT]:\"SIGINT\",[exports.WASI_SIGQUIT]:\"SIGQUIT\",[exports.WASI_SIGILL]:\"SIGILL\",[exports.WASI_SIGTRAP]:\"SIGTRAP\",[exports.WASI_SIGABRT]:\"SIGABRT\",[exports.WASI_SIGBUS]:\"SIGBUS\",[exports.WASI_SIGFPE]:\"SIGFPE\",[exports.WASI_SIGKILL]:\"SIGKILL\",[exports.WASI_SIGUSR1]:\"SIGUSR1\",[exports.WASI_SIGSEGV]:\"SIGSEGV\",[exports.WASI_SIGUSR2]:\"SIGUSR2\",[exports.WASI_SIGPIPE]:\"SIGPIPE\",[exports.WASI_SIGALRM]:\"SIGALRM\",[exports.WASI_SIGTERM]:\"SIGTERM\",[exports.WASI_SIGCHLD]:\"SIGCHLD\",[exports.WASI_SIGCONT]:\"SIGCONT\",[exports.WASI_SIGSTOP]:\"SIGSTOP\",[exports.WASI_SIGTSTP]:\"SIGTSTP\",[exports.WASI_SIGTTIN]:\"SIGTTIN\",[exports.WASI_SIGTTOU]:\"SIGTTOU\",[exports.WASI_SIGURG]:\"SIGURG\",[exports.WASI_SIGXCPU]:\"SIGXCPU\",[exports.WASI_SIGXFSZ]:\"SIGXFSZ\",[exports.WASI_SIGVTALRM]:\"SIGVTALRM\"}}}),require_wasi=__commonJS({\"node_modules/wasi-js/dist/wasi.js\"(exports){var __importDefault=exports&&exports.__importDefault||function(mod){return mod&&mod.__esModule\?mod:{default:mod}};let fs;Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.SOCKET_DEFAULT_RIGHTS=void 0;var log=()=>{},logOpen=()=>{},SC_OPEN_MAX=32768,types_1=require_types(),constants_1=require_constants(),STDIN_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_SYNC|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE,STDOUT_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_SYNC|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE,STDERR_DEFAULT_RIGHTS=STDOUT_DEFAULT_RIGHTS;exports.SOCKET_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE|constants_1.WASI_RIGHT_FD_FDSTAT_SET_FLAGS;var msToNs=(ms)=>{const msInt=Math.trunc(ms),decimal=BigInt(Math.round((ms-msInt)*1e6));return BigInt(msInt)*BigInt(1e6)+decimal},nsToMs=(ns)=>{if(typeof ns===\"number\")ns=Math.trunc(ns);const nsInt=BigInt(ns);return Number(nsInt/BigInt(1e6))},wrap=(f)=>(...args)=>{try{return f(...args)}catch(err){let e=err;while(e.prev!=null)e=e.prev;if(e\?.code&&typeof e\?.code===\"string\")return constants_1.ERROR_MAP[e.code]||constants_1.WASI_EINVAL;if(e instanceof types_1.WASIError)return e.errno;throw e}},stat=(wasi,fd)=>{const entry=wasi.FD_MAP.get(fd);if(!entry)throw new types_1.WASIError(constants_1.WASI_EBADF);if(entry.filetype===void 0){const stats=wasi.fstatSync(entry.real),{filetype,rightsBase,rightsInheriting}=translateFileAttributes(wasi,fd,stats);if(entry.filetype=filetype,!entry.rights)entry.rights={base:rightsBase,inheriting:rightsInheriting}}return entry},translateFileAttributes=(wasi,fd,stats)=>{switch(!0){case stats.isBlockDevice():return{filetype:constants_1.WASI_FILETYPE_BLOCK_DEVICE,rightsBase:constants_1.RIGHTS_BLOCK_DEVICE_BASE,rightsInheriting:constants_1.RIGHTS_BLOCK_DEVICE_INHERITING};case stats.isCharacterDevice():{const filetype=constants_1.WASI_FILETYPE_CHARACTER_DEVICE;if(fd!==void 0&&wasi.bindings.isTTY(fd))return{filetype,rightsBase:constants_1.RIGHTS_TTY_BASE,rightsInheriting:constants_1.RIGHTS_TTY_INHERITING};return{filetype,rightsBase:constants_1.RIGHTS_CHARACTER_DEVICE_BASE,rightsInheriting:constants_1.RIGHTS_CHARACTER_DEVICE_INHERITING}}case stats.isDirectory():return{filetype:constants_1.WASI_FILETYPE_DIRECTORY,rightsBase:constants_1.RIGHTS_DIRECTORY_BASE,rightsInheriting:constants_1.RIGHTS_DIRECTORY_INHERITING};case stats.isFIFO():return{filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rightsBase:constants_1.RIGHTS_SOCKET_BASE,rightsInheriting:constants_1.RIGHTS_SOCKET_INHERITING};case stats.isFile():return{filetype:constants_1.WASI_FILETYPE_REGULAR_FILE,rightsBase:constants_1.RIGHTS_REGULAR_FILE_BASE,rightsInheriting:constants_1.RIGHTS_REGULAR_FILE_INHERITING};case stats.isSocket():return{filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rightsBase:constants_1.RIGHTS_SOCKET_BASE,rightsInheriting:constants_1.RIGHTS_SOCKET_INHERITING};case stats.isSymbolicLink():return{filetype:constants_1.WASI_FILETYPE_SYMBOLIC_LINK,rightsBase:BigInt(0),rightsInheriting:BigInt(0)};default:return{filetype:constants_1.WASI_FILETYPE_UNKNOWN,rightsBase:BigInt(0),rightsInheriting:BigInt(0)}}},warnedAboutSleep=!1,defaultConfig;function getDefaults(){if(defaultConfig)return defaultConfig;const defaultBindings={hrtime:()=>process.hrtime.bigint(),exit:(code)=>{process.exit(code)},kill:(signal)=>{process.kill(process.pid,signal)},randomFillSync:(array)=>crypto.getRandomValues(array),isTTY:(fd)=>@requireNativeModule(\"node:tty\").isatty(fd),fs:Bun.fs(),path:@getInternalField(@internalModuleRegistry,25)||@createInternalModuleById(25)};return defaultConfig={args:[],env:{},preopens:{},bindings:defaultBindings,sleep:(ms)=>{Bun.sleepSync(ms)}}}var WASI=class WASI2{constructor(wasiConfig={}){const defaultConfig2=getDefaults();this.lastStdin=0,this.sleep=wasiConfig.sleep||defaultConfig2.sleep,this.getStdin=wasiConfig.getStdin,this.sendStdout=wasiConfig.sendStdout,this.sendStderr=wasiConfig.sendStderr;let preopens=wasiConfig.preopens\?\?defaultConfig2.preopens;this.env=wasiConfig.env\?\?defaultConfig2.env;const args=wasiConfig.args\?\?defaultConfig2.args;this.memory=void 0,this.view=void 0,this.bindings=wasiConfig.bindings||defaultConfig2.bindings;const bindings2=this.bindings;fs=bindings2.fs,this.FD_MAP=new Map([[constants_1.WASI_STDIN_FILENO,{real:0,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDIN_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stdin\"}],[constants_1.WASI_STDOUT_FILENO,{real:1,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDOUT_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stdout\"}],[constants_1.WASI_STDERR_FILENO,{real:2,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDERR_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stderr\"}]]);const path=bindings2.path;for(let[k,v]of Object.entries(preopens)){const real=fs.openSync(v,nodeFsConstants.O_RDONLY),newfd=this.getUnusedFileDescriptor();this.FD_MAP.set(newfd,{real,filetype:constants_1.WASI_FILETYPE_DIRECTORY,rights:{base:constants_1.RIGHTS_DIRECTORY_BASE,inheriting:constants_1.RIGHTS_DIRECTORY_INHERITING},fakePath:k,path:v})}const getiovs=(iovs,iovsLen)=>{this.refreshMemory();const{view,memory}=this,{buffer}=memory,{byteLength}=buffer;if(iovsLen===1){const ptr=iovs,buf=view.getUint32(ptr,!0);let bufLen=view.getUint32(ptr+4,!0);if(bufLen>byteLength-buf)console.log({buf,bufLen,total_memory:byteLength}),log(\"getiovs: warning -- truncating buffer to fit in memory\"),bufLen=Math.min(bufLen,Math.max(0,byteLength-buf));try{return[new Uint8Array(buffer,buf,bufLen)]}catch(err){throw console.warn(\"WASI.getiovs -- invalid buffer\",err),new types_1.WASIError(constants_1.WASI_EINVAL)}}const buffers=[];buffers.length=iovsLen;for(let i=0,ptr=iovs;ibyteLength-buf)console.log({buf,bufLen,total_memory:byteLength}),log(\"getiovs: warning -- truncating buffer to fit in memory\"),bufLen=Math.min(bufLen,Math.max(0,byteLength-buf));try{buffers[i]=new Uint8Array(buffer,buf,bufLen)}catch(err){throw console.warn(\"WASI.getiovs -- invalid buffer\",err),new types_1.WASIError(constants_1.WASI_EINVAL)}}return buffers},CHECK_FD=(fd,rights)=>{const stats=stat(this,fd);if(rights!==BigInt(0)&&(stats.rights.base&rights)===BigInt(0))throw new types_1.WASIError(constants_1.WASI_EPERM);return stats},CPUTIME_START=Bun.nanoseconds(),timeOrigin=Math.trunc(performance.timeOrigin*1e6),now=(clockId)=>{switch(clockId){case constants_1.WASI_CLOCK_MONOTONIC:return Bun.nanoseconds();case constants_1.WASI_CLOCK_REALTIME:return Bun.nanoseconds()+timeOrigin;case constants_1.WASI_CLOCK_PROCESS_CPUTIME_ID:case constants_1.WASI_CLOCK_THREAD_CPUTIME_ID:return Bun.nanoseconds()-CPUTIME_START;default:return null}};if(this.wasiImport={args_get:(argv,argvBuf)=>{this.refreshMemory();let coffset=argv,offset=argvBuf;return args.forEach((a)=>{this.view.setUint32(coffset,offset,!0),coffset+=4,offset+=Buffer.from(this.memory.buffer).write(`${a}\\0`,offset)}),constants_1.WASI_ESUCCESS},args_sizes_get:(argc,argvBufSize)=>{this.refreshMemory(),this.view.setUint32(argc,args.length,!0);const size=args.reduce((acc,a)=>acc+Buffer.byteLength(a)+1,0);return this.view.setUint32(argvBufSize,size,!0),constants_1.WASI_ESUCCESS},environ_get:(environ,environBuf)=>{this.refreshMemory();let coffset=environ,offset=environBuf;return Object.entries(this.env).forEach(([key,value])=>{this.view.setUint32(coffset,offset,!0),coffset+=4,offset+=Buffer.from(this.memory.buffer).write(`${key}=${value}\\0`,offset)}),constants_1.WASI_ESUCCESS},environ_sizes_get:(environCount,environBufSize)=>{this.refreshMemory();const envProcessed=Object.entries(this.env).map(([key,value])=>`${key}=${value}\\0`),size=envProcessed.reduce((acc,e)=>acc+Buffer.byteLength(e),0);return this.view.setUint32(environCount,envProcessed.length,!0),this.view.setUint32(environBufSize,size,!0),constants_1.WASI_ESUCCESS},clock_res_get:(clockId,resolution)=>{let res;switch(clockId){case constants_1.WASI_CLOCK_MONOTONIC:case constants_1.WASI_CLOCK_PROCESS_CPUTIME_ID:case constants_1.WASI_CLOCK_THREAD_CPUTIME_ID:{res=BigInt(1);break}case constants_1.WASI_CLOCK_REALTIME:{res=BigInt(1000);break}}if(!res)throw Error(\"invalid clockId\");return this.view.setBigUint64(resolution,res),constants_1.WASI_ESUCCESS},clock_time_get:(clockId,_precision,time)=>{this.refreshMemory();const n=now(clockId);if(n===null)return constants_1.WASI_EINVAL;return this.view.setBigUint64(time,BigInt(n),!0),constants_1.WASI_ESUCCESS},fd_advise:wrap((fd,_offset,_len,_advice)=>{return CHECK_FD(fd,constants_1.WASI_RIGHT_FD_ADVISE),constants_1.WASI_ENOSYS}),fd_allocate:wrap((fd,_offset,_len)=>{return CHECK_FD(fd,constants_1.WASI_RIGHT_FD_ALLOCATE),constants_1.WASI_ENOSYS}),fd_close:wrap((fd)=>{const stats=CHECK_FD(fd,BigInt(0));return fs.closeSync(stats.real),this.FD_MAP.delete(fd),constants_1.WASI_ESUCCESS}),fd_datasync:wrap((fd)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_DATASYNC);return fs.fdatasyncSync(stats.real),constants_1.WASI_ESUCCESS}),fd_fdstat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,BigInt(0));if(this.refreshMemory(),stats.filetype==null)throw Error(\"stats.filetype must be set\");return this.view.setUint8(bufPtr,stats.filetype),this.view.setUint16(bufPtr+2,0,!0),this.view.setUint16(bufPtr+4,0,!0),this.view.setBigUint64(bufPtr+8,BigInt(stats.rights.base),!0),this.view.setBigUint64(bufPtr+8+8,BigInt(stats.rights.inheriting),!0),constants_1.WASI_ESUCCESS}),fd_fdstat_set_flags:wrap((fd,flags)=>{if(CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FDSTAT_SET_FLAGS),this.wasiImport.sock_fcntlSetFlags(fd,flags)==0)return constants_1.WASI_ESUCCESS;return constants_1.WASI_ENOSYS}),fd_fdstat_set_rights:wrap((fd,fsRightsBase,fsRightsInheriting)=>{const stats=CHECK_FD(fd,BigInt(0));if((stats.rights.base|fsRightsBase)>stats.rights.base)return constants_1.WASI_EPERM;if((stats.rights.inheriting|fsRightsInheriting)>stats.rights.inheriting)return constants_1.WASI_EPERM;return stats.rights.base=fsRightsBase,stats.rights.inheriting=fsRightsInheriting,constants_1.WASI_ESUCCESS}),fd_filestat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_GET),rstats=this.fstatSync(stats.real);if(this.refreshMemory(),this.view.setBigUint64(bufPtr,BigInt(rstats.dev),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,stats.filetype==null)throw Error(\"stats.filetype must be set\");return this.view.setUint8(bufPtr,stats.filetype),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.nlink),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.size),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.atimeMs),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.mtimeMs),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.ctimeMs),!0),constants_1.WASI_ESUCCESS}),fd_filestat_set_size:wrap((fd,stSize)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_SET_SIZE);return fs.ftruncateSync(stats.real,Number(stSize)),constants_1.WASI_ESUCCESS}),fd_filestat_set_times:wrap((fd,stAtim,stMtim,fstflags)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_SET_TIMES),rstats=this.fstatSync(stats.real);let{atime:atim,mtime:mtim}=rstats;const n=nsToMs(now(constants_1.WASI_CLOCK_REALTIME)),atimflags=constants_1.WASI_FILESTAT_SET_ATIM|constants_1.WASI_FILESTAT_SET_ATIM_NOW;if((fstflags&atimflags)===atimflags)return constants_1.WASI_EINVAL;const mtimflags=constants_1.WASI_FILESTAT_SET_MTIM|constants_1.WASI_FILESTAT_SET_MTIM_NOW;if((fstflags&mtimflags)===mtimflags)return constants_1.WASI_EINVAL;if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM)===constants_1.WASI_FILESTAT_SET_ATIM)atim=nsToMs(stAtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM_NOW)===constants_1.WASI_FILESTAT_SET_ATIM_NOW)atim=n;if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM)===constants_1.WASI_FILESTAT_SET_MTIM)mtim=nsToMs(stMtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM_NOW)===constants_1.WASI_FILESTAT_SET_MTIM_NOW)mtim=n;return fs.futimesSync(stats.real,new Date(atim),new Date(mtim)),constants_1.WASI_ESUCCESS}),fd_prestat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,BigInt(0));return this.refreshMemory(),this.view.setUint8(bufPtr,constants_1.WASI_PREOPENTYPE_DIR),this.view.setUint32(bufPtr+4,Buffer.byteLength(stats.fakePath\?\?stats.path\?\?\"\"),!0),constants_1.WASI_ESUCCESS}),fd_prestat_dir_name:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,BigInt(0));return this.refreshMemory(),Buffer.from(this.memory.buffer).write(stats.fakePath\?\?stats.path\?\?\"\",pathPtr,pathLen,\"utf8\"),constants_1.WASI_ESUCCESS}),fd_pwrite:wrap((fd,iovs,iovsLen,offset,nwritten)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_SEEK);let written=0;return getiovs(iovs,iovsLen).forEach((iov)=>{let w=0;while(w{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_WRITE),IS_STDOUT=fd==constants_1.WASI_STDOUT_FILENO,IS_STDERR=fd==constants_1.WASI_STDERR_FILENO;let written=0;return getiovs(iovs,iovsLen).forEach((iov)=>{if(iov.byteLength==0)return;if(IS_STDOUT&&this.sendStdout!=null)this.sendStdout(iov),written+=iov.byteLength;else if(IS_STDERR&&this.sendStderr!=null)this.sendStderr(iov),written+=iov.byteLength;else{let w=0;while(w{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_SEEK);let read=0;outer:for(let iov of getiovs(iovs,iovsLen)){let r=0;while(r{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READ),IS_STDIN=fd==constants_1.WASI_STDIN_FILENO;let read=0;outer:for(let iov of getiovs(iovs,iovsLen)){let r=0;while(r0)this.lastStdin=(new Date()).valueOf()}}else{if(this.sleep==null&&!warnedAboutSleep)warnedAboutSleep=!0,console.log(\"(cpu waiting for stdin: please define a way to sleep!) \");try{rr=fs.readSync(stats.real,iov,r,length,position)}catch(_err){}if(rr==0)this.shortPause();else this.lastStdin=(new Date()).valueOf()}else rr=fs.readSync(stats.real,iov,r,length,position);if(stats.filetype==constants_1.WASI_FILETYPE_REGULAR_FILE)stats.offset=(stats.offset\?stats.offset:BigInt(0))+BigInt(rr);if(r+=rr,read+=rr,rr===0||rr{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READDIR);this.refreshMemory();const entries=fs.readdirSync(stats.path,{withFileTypes:!0}),startPtr=bufPtr;for(let i=Number(cookie);ibufLen)break;if(this.view.setBigUint64(bufPtr,BigInt(i+1),!0),bufPtr+=8,bufPtr-startPtr>bufLen)break;const rstats=fs.lstatSync(path.resolve(stats.path,entry.name));if(this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,bufPtr-startPtr>bufLen)break;if(this.view.setUint32(bufPtr,nameLength,!0),bufPtr+=4,bufPtr-startPtr>bufLen)break;let filetype;switch(!0){case rstats.isBlockDevice():filetype=constants_1.WASI_FILETYPE_BLOCK_DEVICE;break;case rstats.isCharacterDevice():filetype=constants_1.WASI_FILETYPE_CHARACTER_DEVICE;break;case rstats.isDirectory():filetype=constants_1.WASI_FILETYPE_DIRECTORY;break;case rstats.isFIFO():filetype=constants_1.WASI_FILETYPE_SOCKET_STREAM;break;case rstats.isFile():filetype=constants_1.WASI_FILETYPE_REGULAR_FILE;break;case rstats.isSocket():filetype=constants_1.WASI_FILETYPE_SOCKET_STREAM;break;case rstats.isSymbolicLink():filetype=constants_1.WASI_FILETYPE_SYMBOLIC_LINK;break;default:filetype=constants_1.WASI_FILETYPE_UNKNOWN;break}if(this.view.setUint8(bufPtr,filetype),bufPtr+=1,bufPtr+=3,bufPtr+nameLength>=startPtr+bufLen)break;Buffer.from(this.memory.buffer).write(entry.name,bufPtr),bufPtr+=nameLength}const bufused=bufPtr-startPtr;return this.view.setUint32(bufusedPtr,Math.min(bufused,bufLen),!0),constants_1.WASI_ESUCCESS}),fd_renumber:wrap((from,to)=>{return CHECK_FD(from,BigInt(0)),CHECK_FD(to,BigInt(0)),fs.closeSync(this.FD_MAP.get(from).real),this.FD_MAP.set(from,this.FD_MAP.get(to)),this.FD_MAP.delete(to),constants_1.WASI_ESUCCESS}),fd_seek:wrap((fd,offset,whence,newOffsetPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_SEEK);switch(this.refreshMemory(),whence){case constants_1.WASI_WHENCE_CUR:stats.offset=(stats.offset\?stats.offset:BigInt(0))+BigInt(offset);break;case constants_1.WASI_WHENCE_END:const{size}=this.fstatSync(stats.real);stats.offset=BigInt(size)+BigInt(offset);break;case constants_1.WASI_WHENCE_SET:stats.offset=BigInt(offset);break}if(stats.offset==null)throw Error(\"stats.offset must be defined\");return this.view.setBigUint64(newOffsetPtr,stats.offset,!0),constants_1.WASI_ESUCCESS}),fd_tell:wrap((fd,offsetPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_TELL);if(this.refreshMemory(),!stats.offset)stats.offset=BigInt(0);return this.view.setBigUint64(offsetPtr,stats.offset,!0),constants_1.WASI_ESUCCESS}),fd_sync:wrap((fd)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_SYNC);return fs.fsyncSync(stats.real),constants_1.WASI_ESUCCESS}),path_create_directory:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_CREATE_DIRECTORY);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.mkdirSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),path_filestat_get:wrap((fd,flags,pathPtr,pathLen,bufPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_FILESTAT_GET);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();let rstats;if(flags)rstats=fs.statSync(path.resolve(stats.path,p));else rstats=fs.lstatSync(path.resolve(stats.path,p));return this.view.setBigUint64(bufPtr,BigInt(rstats.dev),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,this.view.setUint8(bufPtr,translateFileAttributes(this,void 0,rstats).filetype),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.nlink),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.size),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.atime.getTime()*1e6),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.mtime.getTime()*1e6),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ctime.getTime()*1e6),!0),constants_1.WASI_ESUCCESS}),path_filestat_set_times:wrap((fd,_dirflags,pathPtr,pathLen,stAtim,stMtim,fstflags)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_FILESTAT_SET_TIMES);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const rstats=this.fstatSync(stats.real);let{atime:atim,mtime:mtim}=rstats;const n=nsToMs(now(constants_1.WASI_CLOCK_REALTIME)),atimflags=constants_1.WASI_FILESTAT_SET_ATIM|constants_1.WASI_FILESTAT_SET_ATIM_NOW;if((fstflags&atimflags)===atimflags)return constants_1.WASI_EINVAL;const mtimflags=constants_1.WASI_FILESTAT_SET_MTIM|constants_1.WASI_FILESTAT_SET_MTIM_NOW;if((fstflags&mtimflags)===mtimflags)return constants_1.WASI_EINVAL;if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM)===constants_1.WASI_FILESTAT_SET_ATIM)atim=nsToMs(stAtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM_NOW)===constants_1.WASI_FILESTAT_SET_ATIM_NOW)atim=n;if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM)===constants_1.WASI_FILESTAT_SET_MTIM)mtim=nsToMs(stMtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM_NOW)===constants_1.WASI_FILESTAT_SET_MTIM_NOW)mtim=n;const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.utimesSync(path.resolve(stats.path,p),new Date(atim),new Date(mtim)),constants_1.WASI_ESUCCESS}),path_link:wrap((oldFd,_oldFlags,oldPath,oldPathLen,newFd,newPath,newPathLen)=>{const ostats=CHECK_FD(oldFd,constants_1.WASI_RIGHT_PATH_LINK_SOURCE),nstats=CHECK_FD(newFd,constants_1.WASI_RIGHT_PATH_LINK_TARGET);if(!ostats.path||!nstats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.linkSync(path.resolve(ostats.path,op),path.resolve(nstats.path,np)),constants_1.WASI_ESUCCESS}),path_open:wrap((dirfd,_dirflags,pathPtr,pathLen,oflags,fsRightsBase,fsRightsInheriting,fsFlags,fdPtr)=>{try{const stats=CHECK_FD(dirfd,constants_1.WASI_RIGHT_PATH_OPEN);fsRightsBase=BigInt(fsRightsBase),fsRightsInheriting=BigInt(fsRightsInheriting);const read=(fsRightsBase&(constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_READDIR))!==BigInt(0),write=(fsRightsBase&(constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_ALLOCATE|constants_1.WASI_RIGHT_FD_FILESTAT_SET_SIZE))!==BigInt(0);let noflags;if(write&&read)noflags=nodeFsConstants.O_RDWR;else if(read)noflags=nodeFsConstants.O_RDONLY;else if(write)noflags=nodeFsConstants.O_WRONLY;let neededBase=fsRightsBase|constants_1.WASI_RIGHT_PATH_OPEN,neededInheriting=fsRightsBase|fsRightsInheriting;if((oflags&constants_1.WASI_O_CREAT)!==0)noflags|=nodeFsConstants.O_CREAT,neededBase|=constants_1.WASI_RIGHT_PATH_CREATE_FILE;if((oflags&constants_1.WASI_O_DIRECTORY)!==0)noflags|=nodeFsConstants.O_DIRECTORY;if((oflags&constants_1.WASI_O_EXCL)!==0)noflags|=nodeFsConstants.O_EXCL;if((oflags&constants_1.WASI_O_TRUNC)!==0)noflags|=nodeFsConstants.O_TRUNC,neededBase|=constants_1.WASI_RIGHT_PATH_FILESTAT_SET_SIZE;if((fsFlags&constants_1.WASI_FDFLAG_APPEND)!==0)noflags|=nodeFsConstants.O_APPEND;if((fsFlags&constants_1.WASI_FDFLAG_DSYNC)!==0){if(nodeFsConstants.O_DSYNC)noflags|=nodeFsConstants.O_DSYNC;else noflags|=nodeFsConstants.O_SYNC;neededInheriting|=constants_1.WASI_RIGHT_FD_DATASYNC}if((fsFlags&constants_1.WASI_FDFLAG_NONBLOCK)!==0)noflags|=nodeFsConstants.O_NONBLOCK;if((fsFlags&constants_1.WASI_FDFLAG_RSYNC)!==0){if(nodeFsConstants.O_RSYNC)noflags|=nodeFsConstants.O_RSYNC;else noflags|=nodeFsConstants.O_SYNC;neededInheriting|=constants_1.WASI_RIGHT_FD_SYNC}if((fsFlags&constants_1.WASI_FDFLAG_SYNC)!==0)noflags|=nodeFsConstants.O_SYNC,neededInheriting|=constants_1.WASI_RIGHT_FD_SYNC;if(write&&(noflags&(nodeFsConstants.O_APPEND|nodeFsConstants.O_TRUNC))===0)neededInheriting|=constants_1.WASI_RIGHT_FD_SEEK;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();if(p==\"dev/tty\")return this.view.setUint32(fdPtr,constants_1.WASI_STDIN_FILENO,!0),constants_1.WASI_ESUCCESS;if(logOpen(\"path_open\",p),p.startsWith(\"proc/\"))throw new types_1.WASIError(constants_1.WASI_EBADF);const fullUnresolved=path.resolve(p);let full;try{full=fs.realpathSync(fullUnresolved)}catch(e){if(e\?.code===\"ENOENT\")full=fullUnresolved;else throw e}let isDirectory;if(write)try{isDirectory=fs.statSync(full).isDirectory()}catch(_err){}let realfd;if(!write&&isDirectory)realfd=fs.openSync(full,nodeFsConstants.O_RDONLY);else realfd=fs.openSync(full,noflags);const newfd=this.getUnusedFileDescriptor();this.FD_MAP.set(newfd,{real:realfd,filetype:void 0,rights:{base:neededBase,inheriting:neededInheriting},path:full}),stat(this,newfd),this.view.setUint32(fdPtr,newfd,!0)}catch(e){console.error(e)}return constants_1.WASI_ESUCCESS}),path_readlink:wrap((fd,pathPtr,pathLen,buf,bufLen,bufused)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_READLINK);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString(),full=path.resolve(stats.path,p),r=fs.readlinkSync(full),used=Buffer.from(this.memory.buffer).write(r,buf,bufLen);return this.view.setUint32(bufused,used,!0),constants_1.WASI_ESUCCESS}),path_remove_directory:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_REMOVE_DIRECTORY);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.rmdirSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),path_rename:wrap((oldFd,oldPath,oldPathLen,newFd,newPath,newPathLen)=>{const ostats=CHECK_FD(oldFd,constants_1.WASI_RIGHT_PATH_RENAME_SOURCE),nstats=CHECK_FD(newFd,constants_1.WASI_RIGHT_PATH_RENAME_TARGET);if(!ostats.path||!nstats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.renameSync(path.resolve(ostats.path,op),path.resolve(nstats.path,np)),constants_1.WASI_ESUCCESS}),path_symlink:wrap((oldPath,oldPathLen,fd,newPath,newPathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_SYMLINK);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.symlinkSync(op,path.resolve(stats.path,np)),constants_1.WASI_ESUCCESS}),path_unlink_file:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_UNLINK_FILE);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.unlinkSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),poll_oneoff:(sin,sout,nsubscriptions,neventsPtr)=>{let nevents=0,name=\"\",waitTimeNs=BigInt(0),fd=-1,fd_type=\"read\",fd_timeout_ms=0;const startNs=BigInt(bindings2.hrtime());this.refreshMemory();let last_sin=sin;for(let i=0;iwaitTimeNs)waitTimeNs=waitNs}this.view.setBigUint64(sout,userdata,!0),sout+=8,this.view.setUint16(sout,e,!0),sout+=2,this.view.setUint8(sout,constants_1.WASI_EVENTTYPE_CLOCK),sout+=1,sout+=5,nevents+=1;break}case constants_1.WASI_EVENTTYPE_FD_READ:case constants_1.WASI_EVENTTYPE_FD_WRITE:{if(fd=this.view.getUint32(sin,!0),fd_type=type==constants_1.WASI_EVENTTYPE_FD_READ\?\"read\":\"write\",sin+=4,log(name,\"fd =\",fd),sin+=28,this.view.setBigUint64(sout,userdata,!0),sout+=8,this.view.setUint16(sout,constants_1.WASI_ENOSYS,!0),sout+=2,this.view.setUint8(sout,type),sout+=1,sout+=5,nevents+=1,fd==constants_1.WASI_STDIN_FILENO&&constants_1.WASI_EVENTTYPE_FD_READ==type)this.shortPause();break}default:return constants_1.WASI_EINVAL}if(sin-last_sin!=48)console.warn(\"*** BUG in wasi-js in poll_oneoff \",{i,sin,last_sin,diff:sin-last_sin});last_sin=sin}if(this.view.setUint32(neventsPtr,nevents,!0),nevents==2&&fd>=0){const r=this.wasiImport.sock_pollSocket(fd,fd_type,fd_timeout_ms);if(r!=constants_1.WASI_ENOSYS)return r}if(waitTimeNs>0){if(waitTimeNs-=Bun.nanoseconds()-timeOrigin,waitTimeNs>=1e6){if(this.sleep==null&&!warnedAboutSleep)warnedAboutSleep=!0,console.log(\"(100% cpu burning waiting for stdin: please define a way to sleep!) \");if(this.sleep!=null){const ms=nsToMs(waitTimeNs);this.sleep(ms)}else{const end=BigInt(bindings2.hrtime())+waitTimeNs;while(BigInt(bindings2.hrtime()){return bindings2.exit(rval),constants_1.WASI_ESUCCESS},proc_raise:(sig)=>{if(!(sig in constants_1.SIGNAL_MAP))return constants_1.WASI_EINVAL;return bindings2.kill(constants_1.SIGNAL_MAP[sig]),constants_1.WASI_ESUCCESS},random_get:(bufPtr,bufLen)=>{return this.refreshMemory(),crypto.getRandomValues(this.memory.buffer,bufPtr,bufLen),bufLen},sched_yield(){return constants_1.WASI_ESUCCESS},sock_recv(){return constants_1.WASI_ENOSYS},sock_send(){return constants_1.WASI_ENOSYS},sock_shutdown(){return constants_1.WASI_ENOSYS},sock_fcntlSetFlags(_fd,_flags){return constants_1.WASI_ENOSYS},sock_pollSocket(_fd,_eventtype,_timeout_ms){return constants_1.WASI_ENOSYS}},log.enabled)Object.keys(this.wasiImport).forEach((key)=>{const prevImport=this.wasiImport[key];this.wasiImport[key]=function(...args2){log(key,args2);try{let result=prevImport(...args2);return log(\"result\",result),result}catch(e){throw log(\"error: \",e),e}}})}getState(){return{env:this.env,FD_MAP:this.FD_MAP,bindings}}setState(state){this.env=state.env,this.FD_MAP=state.FD_MAP,bindings=state.bindings}fstatSync(real_fd){if(real_fd<=2)try{return fs.fstatSync(real_fd)}catch(_){const now=new Date;return{dev:0,mode:8592,nlink:1,uid:0,gid:0,rdev:0,blksize:65536,ino:0,size:0,blocks:0,atimeMs:now.valueOf(),mtimeMs:now.valueOf(),ctimeMs:now.valueOf(),birthtimeMs:0,atime:new Date,mtime:new Date,ctime:new Date,birthtime:new Date(0)}}return fs.fstatSync(real_fd)}shortPause(){if(this.sleep==null)return;if((new Date()).valueOf()-this.lastStdin>2000)this.sleep(50)}getUnusedFileDescriptor(start=3){let fd=start;while(this.FD_MAP.has(fd))fd+=1;if(fd>SC_OPEN_MAX)throw Error(\"no available file descriptors\");return fd}refreshMemory(){if(!this.view||this.view.buffer.byteLength===0)this.view=new DataView(this.memory.buffer)}setMemory(memory){this.memory=memory}start(instance,memory){const exports2=instance.exports;if(exports2===null||typeof exports2!==\"object\")throw new Error(`instance.exports must be an Object. Received ${exports2}.`);if(memory==null){if(memory=exports2.memory,!(memory instanceof WebAssembly.Memory))throw new Error(`instance.exports.memory must be a WebAssembly.Memory. Recceived ${memory}.`)}if(this.setMemory(memory),exports2._start)exports2._start()}getImports(module2){let namespace=null;const imports=WebAssembly.Module.imports(module2);for(let imp of imports){if(imp.kind!==\"function\")continue;if(!imp.module.startsWith(\"wasi_\"))continue;namespace=imp.module;break}switch(namespace){case\"wasi_unstable\":return{wasi_unstable:this.wasiImport};case\"wasi_snapshot_preview1\":return{wasi_snapshot_preview1:this.wasiImport};default:throw new Error(\"No WASI namespace found. Only wasi_unstable and wasi_snapshot_preview1 are supported.\\n\\nList of imports:\\n\\n\"+imports.map(({name,kind,module})=>`${module}:${name} (${kind})`).join(\"\\n\")+\"\\n\")}}initWasiFdInfo(){if(this.env.WASI_FD_INFO!=null){const fdInfo=JSON.parse(this.env.WASI_FD_INFO);for(let wasi_fd in fdInfo){console.log(wasi_fd);const fd=parseInt(wasi_fd);if(this.FD_MAP.has(fd))continue;const real=fdInfo[wasi_fd];try{this.fstatSync(real)}catch(_err){console.log(\"discarding \",{wasi_fd,real});continue}const file={real,filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rights:{base:STDIN_DEFAULT_RIGHTS,inheriting:BigInt(0)}};this.FD_MAP.set(fd,file)}console.log(\"after initWasiFdInfo: \",this.FD_MAP),console.log(\"fdInfo = \",fdInfo)}else console.log(\"no WASI_FD_INFO\")}};exports.default=WASI}});return{WASI:require_wasi().default}})\n"_s; +// + +// static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const{MessageChannel,BroadcastChannel}=globalThis;function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort,EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\"),parentPort=isMainThread\?null:fakeParentPort(),resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throw new Error(\"markAsUntransferable is not implemented\")}function moveMessagePortToContext(){throw new Error(\"moveMessagePortToContext is not implemented\")}const SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),WebWorker=globalThis.Worker;class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();this.#worker=new WebWorker(filename,{...options}),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return{}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.#worker.addEventListener(\"close\",(event)=>{resolve(0)},{once:!0}),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(){this.emit(\"exit\")}#onError(event){this.emit(\"error\",event)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error||event)}#onOpen(){this.emit(\"online\")}getHeapSnapshot(){return{}}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeZlibCode = "(function (){\"use strict\";const assert=@getInternalField(@internalModuleRegistry,3)||@createInternalModuleById(3),BufferModule=@requireNativeModule(\"node:buffer\"),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),Util=@getInternalField(@internalModuleRegistry,42)||@createInternalModuleById(42);var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_zstream=__commonJS({\"node_modules/pako/lib/zlib/zstream.js\"(exports,module2){function ZStream(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}module2.exports=ZStream}}),require_common=__commonJS({\"node_modules/pako/lib/utils/common.js\"(exports){var TYPED_OK=typeof Uint8Array!==\"undefined\"&&typeof Uint16Array!==\"undefined\"&&typeof Int32Array!==\"undefined\";function _has(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}exports.assign=function(obj){var sources=Array.prototype.slice.call(arguments,1);while(sources.length){var source=sources.shift();if(!source)continue;if(typeof source!==\"object\")@throwTypeError(source+\"must be non-object\");for(var p in source)if(_has(source,p))obj[p]=source[p]}return obj},exports.shrinkBuf=function(buf,size){if(buf.length===size)return buf;if(buf.subarray)return buf.subarray(0,size);return buf.length=size,buf};var fnTyped={arraySet:function(dest,src,src_offs,len,dest_offs){if(src.subarray&&dest.subarray){dest.set(src.subarray(src_offs,src_offs+len),dest_offs);return}for(var i=0;i=0)buf[len]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH=3,MAX_MATCH=258,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],DIST_CODE_LEN=512,static_ltree=new Array((L_CODES+2)*2);zero(static_ltree);var static_dtree=new Array(D_CODES*2);zero(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero(_dist_code);var _length_code=new Array(MAX_MATCH-MIN_MATCH+1);zero(_length_code);var base_length=new Array(LENGTH_CODES);zero(base_length);var base_dist=new Array(D_CODES);zero(base_dist);function StaticTreeDesc(static_tree,extra_bits,extra_base,elems,max_length){this.static_tree=static_tree,this.extra_bits=extra_bits,this.extra_base=extra_base,this.elems=elems,this.max_length=max_length,this.has_stree=static_tree&&static_tree.length}var static_l_desc,static_d_desc,static_bl_desc;function TreeDesc(dyn_tree,stat_desc){this.dyn_tree=dyn_tree,this.max_code=0,this.stat_desc=stat_desc}function d_code(dist){return dist<256\?_dist_code[dist]:_dist_code[256+(dist>>>7)]}function put_short(s,w){s.pending_buf[s.pending++]=w&255,s.pending_buf[s.pending++]=w>>>8&255}function send_bits(s,value,length){if(s.bi_valid>Buf_size-length)s.bi_buf|=value<>Buf_size-s.bi_valid,s.bi_valid+=length-Buf_size;else s.bi_buf|=value<>>=1,res<<=1;while(--len>0);return res>>>1}function bi_flush(s){if(s.bi_valid===16)put_short(s,s.bi_buf),s.bi_buf=0,s.bi_valid=0;else if(s.bi_valid>=8)s.pending_buf[s.pending++]=s.bi_buf&255,s.bi_buf>>=8,s.bi_valid-=8}function gen_bitlen(s,desc){var{dyn_tree:tree,max_code}=desc,stree=desc.stat_desc.static_tree,has_stree=desc.stat_desc.has_stree,extra=desc.stat_desc.extra_bits,base=desc.stat_desc.extra_base,max_length=desc.stat_desc.max_length,h,n,m,bits,xbits,f,overflow=0;for(bits=0;bits<=MAX_BITS;bits++)s.bl_count[bits]=0;tree[s.heap[s.heap_max]*2+1]=0;for(h=s.heap_max+1;hmax_length)bits=max_length,overflow++;if(tree[n*2+1]=bits,n>max_code)continue;if(s.bl_count[bits]++,xbits=0,n>=base)xbits=extra[n-base];if(f=tree[n*2],s.opt_len+=f*(bits+xbits),has_stree)s.static_len+=f*(stree[n*2+1]+xbits)}if(overflow===0)return;do{bits=max_length-1;while(s.bl_count[bits]===0)bits--;s.bl_count[bits]--,s.bl_count[bits+1]+=2,s.bl_count[max_length]--,overflow-=2}while(overflow>0);for(bits=max_length;bits!==0;bits--){n=s.bl_count[bits];while(n!==0){if(m=s.heap[--h],m>max_code)continue;if(tree[m*2+1]!==bits)s.opt_len+=(bits-tree[m*2+1])*tree[m*2],tree[m*2+1]=bits;n--}}}function gen_codes(tree,max_code,bl_count){var next_code=new Array(MAX_BITS+1),code=0,bits,n;for(bits=1;bits<=MAX_BITS;bits++)next_code[bits]=code=code+bl_count[bits-1]<<1;for(n=0;n<=max_code;n++){var len=tree[n*2+1];if(len===0)continue;tree[n*2]=bi_reverse(next_code[len]++,len)}}function tr_static_init(){var n,bits,length,code,dist,bl_count=new Array(MAX_BITS+1);length=0;for(code=0;code>=7;for(;code8)put_short(s,s.bi_buf);else if(s.bi_valid>0)s.pending_buf[s.pending++]=s.bi_buf;s.bi_buf=0,s.bi_valid=0}function copy_block(s,buf,len,header){if(bi_windup(s),header)put_short(s,len),put_short(s,~len);utils.arraySet(s.pending_buf,s.window,buf,len,s.pending),s.pending+=len}function smaller(tree,n,m,depth){var _n2=n*2,_m2=m*2;return tree[_n2]>1;n>=1;n--)pqdownheap(s,tree,n);node=elems;do n=s.heap[1],s.heap[1]=s.heap[s.heap_len--],pqdownheap(s,tree,1),m=s.heap[1],s.heap[--s.heap_max]=n,s.heap[--s.heap_max]=m,tree[node*2]=tree[n*2]+tree[m*2],s.depth[node]=(s.depth[n]>=s.depth[m]\?s.depth[n]:s.depth[m])+1,tree[n*2+1]=tree[m*2+1]=node,s.heap[1]=node++,pqdownheap(s,tree,1);while(s.heap_len>=2);s.heap[--s.heap_max]=s.heap[1],gen_bitlen(s,desc),gen_codes(tree,max_code,s.bl_count)}function scan_tree(s,tree,max_code){var n,prevlen=-1,curlen,nextlen=tree[1],count=0,max_count=7,min_count=4;if(nextlen===0)max_count=138,min_count=3;tree[(max_code+1)*2+1]=65535;for(n=0;n<=max_code;n++){if(curlen=nextlen,nextlen=tree[(n+1)*2+1],++count=3;max_blindex--)if(s.bl_tree[bl_order[max_blindex]*2+1]!==0)break;return s.opt_len+=3*(max_blindex+1)+5+5+4,max_blindex}function send_all_trees(s,lcodes,dcodes,blcodes){var rank;send_bits(s,lcodes-257,5),send_bits(s,dcodes-1,5),send_bits(s,blcodes-4,4);for(rank=0;rank>>=1)if(black_mask&1&&s.dyn_ltree[n*2]!==0)return Z_BINARY;if(s.dyn_ltree[18]!==0||s.dyn_ltree[20]!==0||s.dyn_ltree[26]!==0)return Z_TEXT;for(n=32;n0){if(s.strm.data_type===Z_UNKNOWN)s.strm.data_type=detect_data_type(s);if(build_tree(s,s.l_desc),build_tree(s,s.d_desc),max_blindex=build_bl_tree(s),opt_lenb=s.opt_len+3+7>>>3,static_lenb=s.static_len+3+7>>>3,static_lenb<=opt_lenb)opt_lenb=static_lenb}else opt_lenb=static_lenb=stored_len+5;if(stored_len+4<=opt_lenb&&buf!==-1)_tr_stored_block(s,buf,stored_len,last);else if(s.strategy===Z_FIXED||static_lenb===opt_lenb)send_bits(s,(STATIC_TREES<<1)+(last\?1:0),3),compress_block(s,static_ltree,static_dtree);else send_bits(s,(DYN_TREES<<1)+(last\?1:0),3),send_all_trees(s,s.l_desc.max_code+1,s.d_desc.max_code+1,max_blindex+1),compress_block(s,s.dyn_ltree,s.dyn_dtree);if(init_block(s),last)bi_windup(s)}function _tr_tally(s,dist,lc){if(s.pending_buf[s.d_buf+s.last_lit*2]=dist>>>8&255,s.pending_buf[s.d_buf+s.last_lit*2+1]=dist&255,s.pending_buf[s.l_buf+s.last_lit]=lc&255,s.last_lit++,dist===0)s.dyn_ltree[lc*2]++;else s.matches++,dist--,s.dyn_ltree[(_length_code[lc]+LITERALS+1)*2]++,s.dyn_dtree[d_code(dist)*2]++;return s.last_lit===s.lit_bufsize-1}exports._tr_init=_tr_init,exports._tr_stored_block=_tr_stored_block,exports._tr_flush_block=_tr_flush_block,exports._tr_tally=_tr_tally,exports._tr_align=_tr_align}}),require_adler32=__commonJS({\"node_modules/pako/lib/zlib/adler32.js\"(exports,module2){function adler32(adler,buf,len,pos){var s1=adler&65535|0,s2=adler>>>16&65535|0,n=0;while(len!==0){n=len>2000\?2000:len,len-=n;do s1=s1+buf[pos++]|0,s2=s2+s1|0;while(--n);s1%=65521,s2%=65521}return s1|s2<<16|0}module2.exports=adler32}}),require_crc32=__commonJS({\"node_modules/pako/lib/zlib/crc32.js\"(exports,module2){function makeTable(){var c,table=[];for(var n=0;n<256;n++){c=n;for(var k=0;k<8;k++)c=c&1\?3988292384^c>>>1:c>>>1;table[n]=c}return table}var crcTable=makeTable();function crc32(crc,buf,len,pos){var t=crcTable,end=pos+len;crc^=-1;for(var i=pos;i>>8^t[(crc^buf[i])&255];return crc^-1}module2.exports=crc32}}),require_messages=__commonJS({\"node_modules/pako/lib/zlib/messages.js\"(exports,module2){module2.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}}}),require_deflate=__commonJS({\"node_modules/pako/lib/zlib/deflate.js\"(exports){var utils=require_common(),trees=require_trees(),adler32=require_adler32(),crc32=require_crc32(),msg=require_messages(),Z_NO_FLUSH=0,Z_PARTIAL_FLUSH=1,Z_FULL_FLUSH=3,Z_FINISH=4,Z_BLOCK=5,Z_OK=0,Z_STREAM_END=1,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_BUF_ERROR=-5,Z_DEFAULT_COMPRESSION=-1,Z_FILTERED=1,Z_HUFFMAN_ONLY=2,Z_RLE=3,Z_FIXED=4,Z_DEFAULT_STRATEGY=0,Z_UNKNOWN=2,Z_DEFLATED=8,MAX_MEM_LEVEL=9,MAX_WBITS=15,DEF_MEM_LEVEL=8,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3;function err(strm,errorCode){return strm.msg=msg[errorCode],errorCode}function rank(f){return(f<<1)-(f>4\?9:0)}function zero(buf){var len=buf.length;while(--len>=0)buf[len]=0}function flush_pending(strm){var s=strm.state,len=s.pending;if(len>strm.avail_out)len=strm.avail_out;if(len===0)return;if(utils.arraySet(strm.output,s.pending_buf,s.pending_out,len,strm.next_out),strm.next_out+=len,s.pending_out+=len,strm.total_out+=len,strm.avail_out-=len,s.pending-=len,s.pending===0)s.pending_out=0}function flush_block_only(s,last){trees._tr_flush_block(s,s.block_start>=0\?s.block_start:-1,s.strstart-s.block_start,last),s.block_start=s.strstart,flush_pending(s.strm)}function put_byte(s,b){s.pending_buf[s.pending++]=b}function putShortMSB(s,b){s.pending_buf[s.pending++]=b>>>8&255,s.pending_buf[s.pending++]=b&255}function read_buf(strm,buf,start,size){var len=strm.avail_in;if(len>size)len=size;if(len===0)return 0;if(strm.avail_in-=len,utils.arraySet(buf,strm.input,strm.next_in,len,start),strm.state.wrap===1)strm.adler=adler32(strm.adler,buf,len,start);else if(strm.state.wrap===2)strm.adler=crc32(strm.adler,buf,len,start);return strm.next_in+=len,strm.total_in+=len,len}function longest_match(s,cur_match){var{max_chain_length:chain_length,strstart:scan}=s,match,len,best_len=s.prev_length,nice_match=s.nice_match,limit=s.strstart>s.w_size-MIN_LOOKAHEAD\?s.strstart-(s.w_size-MIN_LOOKAHEAD):0,_win=s.window,wmask=s.w_mask,prev=s.prev,strend=s.strstart+MAX_MATCH,scan_end1=_win[scan+best_len-1],scan_end=_win[scan+best_len];if(s.prev_length>=s.good_match)chain_length>>=2;if(nice_match>s.lookahead)nice_match=s.lookahead;do{if(match=cur_match,_win[match+best_len]!==scan_end||_win[match+best_len-1]!==scan_end1||_win[match]!==_win[scan]||_win[++match]!==_win[scan+1])continue;scan+=2,match++;do;while(_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&scanbest_len){if(s.match_start=cur_match,best_len=len,len>=nice_match)break;scan_end1=_win[scan+best_len-1],scan_end=_win[scan+best_len]}}while((cur_match=prev[cur_match&wmask])>limit&&--chain_length!==0);if(best_len<=s.lookahead)return best_len;return s.lookahead}function fill_window(s){var _w_size=s.w_size,p,n,m,more,str;do{if(more=s.window_size-s.lookahead-s.strstart,s.strstart>=_w_size+(_w_size-MIN_LOOKAHEAD)){utils.arraySet(s.window,s.window,_w_size,_w_size,0),s.match_start-=_w_size,s.strstart-=_w_size,s.block_start-=_w_size,n=s.hash_size,p=n;do m=s.head[--p],s.head[p]=m>=_w_size\?m-_w_size:0;while(--n);n=_w_size,p=n;do m=s.prev[--p],s.prev[p]=m>=_w_size\?m-_w_size:0;while(--n);more+=_w_size}if(s.strm.avail_in===0)break;if(n=read_buf(s.strm,s.window,s.strstart+s.lookahead,more),s.lookahead+=n,s.lookahead+s.insert>=MIN_MATCH){str=s.strstart-s.insert,s.ins_h=s.window[str],s.ins_h=(s.ins_h<s.pending_buf_size-5)max_block_size=s.pending_buf_size-5;for(;;){if(s.lookahead<=1){if(fill_window(s),s.lookahead===0&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead===0)break}s.strstart+=s.lookahead,s.lookahead=0;var max_start=s.block_start+max_block_size;if(s.strstart===0||s.strstart>=max_start){if(s.lookahead=s.strstart-max_start,s.strstart=max_start,flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}if(s.strstart-s.block_start>=s.w_size-MIN_LOOKAHEAD){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.strstart>s.block_start){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_NEED_MORE}function deflate_fast(s,flush){var hash_head,bflush;for(;;){if(s.lookahead=MIN_MATCH)s.ins_h=(s.ins_h<=MIN_MATCH)if(bflush=trees._tr_tally(s,s.strstart-s.match_start,s.match_length-MIN_MATCH),s.lookahead-=s.match_length,s.match_length<=s.max_lazy_match&&s.lookahead>=MIN_MATCH){s.match_length--;do s.strstart++,s.ins_h=(s.ins_h<=MIN_MATCH)s.ins_h=(s.ins_h<4096))s.match_length=MIN_MATCH-1}if(s.prev_length>=MIN_MATCH&&s.match_length<=s.prev_length){max_insert=s.strstart+s.lookahead-MIN_MATCH,bflush=trees._tr_tally(s,s.strstart-1-s.prev_match,s.prev_length-MIN_MATCH),s.lookahead-=s.prev_length-1,s.prev_length-=2;do if(++s.strstart<=max_insert)s.ins_h=(s.ins_h<=MIN_MATCH&&s.strstart>0){if(scan=s.strstart-1,prev=_win[scan],prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]){strend=s.strstart+MAX_MATCH;do;while(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&scans.lookahead)s.match_length=s.lookahead}}if(s.match_length>=MIN_MATCH)bflush=trees._tr_tally(s,1,s.match_length-MIN_MATCH),s.lookahead-=s.match_length,s.strstart+=s.match_length,s.match_length=0;else bflush=trees._tr_tally(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++;if(bflush){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_huff(s,flush){var bflush;for(;;){if(s.lookahead===0){if(fill_window(s),s.lookahead===0){if(flush===Z_NO_FLUSH)return BS_NEED_MORE;break}}if(s.match_length=0,bflush=trees._tr_tally(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++,bflush){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function Config(good_length,max_lazy,nice_length,max_chain,func){this.good_length=good_length,this.max_lazy=max_lazy,this.nice_length=nice_length,this.max_chain=max_chain,this.func=func}var configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(s){s.window_size=2*s.w_size,zero(s.head),s.max_lazy_match=configuration_table[s.level].max_lazy,s.good_match=configuration_table[s.level].good_length,s.nice_match=configuration_table[s.level].nice_length,s.max_chain_length=configuration_table[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=MIN_MATCH-1,s.match_available=0,s.ins_h=0}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new utils.Buf16(HEAP_SIZE*2),this.dyn_dtree=new utils.Buf16((2*D_CODES+1)*2),this.bl_tree=new utils.Buf16((2*BL_CODES+1)*2),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new utils.Buf16(MAX_BITS+1),this.heap=new utils.Buf16(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new utils.Buf16(2*L_CODES+1),zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflateResetKeep(strm){var s;if(!strm||!strm.state)return err(strm,Z_STREAM_ERROR);if(strm.total_in=strm.total_out=0,strm.data_type=Z_UNKNOWN,s=strm.state,s.pending=0,s.pending_out=0,s.wrap<0)s.wrap=-s.wrap;return s.status=s.wrap\?INIT_STATE:BUSY_STATE,strm.adler=s.wrap===2\?0:1,s.last_flush=Z_NO_FLUSH,trees._tr_init(s),Z_OK}function deflateReset(strm){var ret=deflateResetKeep(strm);if(ret===Z_OK)lm_init(strm.state);return ret}function deflateSetHeader(strm,head){if(!strm||!strm.state)return Z_STREAM_ERROR;if(strm.state.wrap!==2)return Z_STREAM_ERROR;return strm.state.gzhead=head,Z_OK}function deflateInit2(strm,level,method,windowBits,memLevel,strategy){if(!strm)return Z_STREAM_ERROR;var wrap=1;if(level===Z_DEFAULT_COMPRESSION)level=6;if(windowBits<0)wrap=0,windowBits=-windowBits;else if(windowBits>15)wrap=2,windowBits-=16;if(memLevel<1||memLevel>MAX_MEM_LEVEL||method!==Z_DEFLATED||windowBits<8||windowBits>15||level<0||level>9||strategy<0||strategy>Z_FIXED)return err(strm,Z_STREAM_ERROR);if(windowBits===8)windowBits=9;var s=new DeflateState;return strm.state=s,s.strm=strm,s.wrap=wrap,s.gzhead=null,s.w_bits=windowBits,s.w_size=1<Z_BLOCK||flush<0)return strm\?err(strm,Z_STREAM_ERROR):Z_STREAM_ERROR;if(s=strm.state,!strm.output||!strm.input&&strm.avail_in!==0||s.status===FINISH_STATE&&flush!==Z_FINISH)return err(strm,strm.avail_out===0\?Z_BUF_ERROR:Z_STREAM_ERROR);if(s.strm=strm,old_flush=s.last_flush,s.last_flush=flush,s.status===INIT_STATE)if(s.wrap===2)if(strm.adler=0,put_byte(s,31),put_byte(s,139),put_byte(s,8),!s.gzhead)put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,s.level===9\?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2\?4:0),put_byte(s,OS_CODE),s.status=BUSY_STATE;else{if(put_byte(s,(s.gzhead.text\?1:0)+(s.gzhead.hcrc\?2:0)+(!s.gzhead.extra\?0:4)+(!s.gzhead.name\?0:8)+(!s.gzhead.comment\?0:16)),put_byte(s,s.gzhead.time&255),put_byte(s,s.gzhead.time>>8&255),put_byte(s,s.gzhead.time>>16&255),put_byte(s,s.gzhead.time>>24&255),put_byte(s,s.level===9\?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2\?4:0),put_byte(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length)put_byte(s,s.gzhead.extra.length&255),put_byte(s,s.gzhead.extra.length>>8&255);if(s.gzhead.hcrc)strm.adler=crc32(strm.adler,s.pending_buf,s.pending,0);s.gzindex=0,s.status=EXTRA_STATE}else{var header=Z_DEFLATED+(s.w_bits-8<<4)<<8,level_flags=-1;if(s.strategy>=Z_HUFFMAN_ONLY||s.level<2)level_flags=0;else if(s.level<6)level_flags=1;else if(s.level===6)level_flags=2;else level_flags=3;if(header|=level_flags<<6,s.strstart!==0)header|=PRESET_DICT;if(header+=31-header%31,s.status=BUSY_STATE,putShortMSB(s,header),s.strstart!==0)putShortMSB(s,strm.adler>>>16),putShortMSB(s,strm.adler&65535);strm.adler=1}if(s.status===EXTRA_STATE)if(s.gzhead.extra){beg=s.pending;while(s.gzindex<(s.gzhead.extra.length&65535)){if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size)break}put_byte(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++}if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(s.gzindex===s.gzhead.extra.length)s.gzindex=0,s.status=NAME_STATE}else s.status=NAME_STATE;if(s.status===NAME_STATE)if(s.gzhead.name){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.gzindex=0,s.status=COMMENT_STATE}else s.status=COMMENT_STATE;if(s.status===COMMENT_STATE)if(s.gzhead.comment){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.status=HCRC_STATE}else s.status=HCRC_STATE;if(s.status===HCRC_STATE)if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size)flush_pending(strm);if(s.pending+2<=s.pending_buf_size)put_byte(s,strm.adler&255),put_byte(s,strm.adler>>8&255),strm.adler=0,s.status=BUSY_STATE}else s.status=BUSY_STATE;if(s.pending!==0){if(flush_pending(strm),strm.avail_out===0)return s.last_flush=-1,Z_OK}else if(strm.avail_in===0&&rank(flush)<=rank(old_flush)&&flush!==Z_FINISH)return err(strm,Z_BUF_ERROR);if(s.status===FINISH_STATE&&strm.avail_in!==0)return err(strm,Z_BUF_ERROR);if(strm.avail_in!==0||s.lookahead!==0||flush!==Z_NO_FLUSH&&s.status!==FINISH_STATE){var bstate=s.strategy===Z_HUFFMAN_ONLY\?deflate_huff(s,flush):s.strategy===Z_RLE\?deflate_rle(s,flush):configuration_table[s.level].func(s,flush);if(bstate===BS_FINISH_STARTED||bstate===BS_FINISH_DONE)s.status=FINISH_STATE;if(bstate===BS_NEED_MORE||bstate===BS_FINISH_STARTED){if(strm.avail_out===0)s.last_flush=-1;return Z_OK}if(bstate===BS_BLOCK_DONE){if(flush===Z_PARTIAL_FLUSH)trees._tr_align(s);else if(flush!==Z_BLOCK){if(trees._tr_stored_block(s,0,0,!1),flush===Z_FULL_FLUSH){if(zero(s.head),s.lookahead===0)s.strstart=0,s.block_start=0,s.insert=0}}if(flush_pending(strm),strm.avail_out===0)return s.last_flush=-1,Z_OK}}if(flush!==Z_FINISH)return Z_OK;if(s.wrap<=0)return Z_STREAM_END;if(s.wrap===2)put_byte(s,strm.adler&255),put_byte(s,strm.adler>>8&255),put_byte(s,strm.adler>>16&255),put_byte(s,strm.adler>>24&255),put_byte(s,strm.total_in&255),put_byte(s,strm.total_in>>8&255),put_byte(s,strm.total_in>>16&255),put_byte(s,strm.total_in>>24&255);else putShortMSB(s,strm.adler>>>16),putShortMSB(s,strm.adler&65535);if(flush_pending(strm),s.wrap>0)s.wrap=-s.wrap;return s.pending!==0\?Z_OK:Z_STREAM_END}function deflateEnd(strm){var status;if(!strm||!strm.state)return Z_STREAM_ERROR;if(status=strm.state.status,status!==INIT_STATE&&status!==EXTRA_STATE&&status!==NAME_STATE&&status!==COMMENT_STATE&&status!==HCRC_STATE&&status!==BUSY_STATE&&status!==FINISH_STATE)return err(strm,Z_STREAM_ERROR);return strm.state=null,status===BUSY_STATE\?err(strm,Z_DATA_ERROR):Z_OK}function deflateSetDictionary(strm,dictionary){var dictLength=dictionary.length,s,str,n,wrap,avail,next,input,tmpDict;if(!strm||!strm.state)return Z_STREAM_ERROR;if(s=strm.state,wrap=s.wrap,wrap===2||wrap===1&&s.status!==INIT_STATE||s.lookahead)return Z_STREAM_ERROR;if(wrap===1)strm.adler=adler32(strm.adler,dictionary,dictLength,0);if(s.wrap=0,dictLength>=s.w_size){if(wrap===0)zero(s.head),s.strstart=0,s.block_start=0,s.insert=0;tmpDict=new utils.Buf8(s.w_size),utils.arraySet(tmpDict,dictionary,dictLength-s.w_size,s.w_size,0),dictionary=tmpDict,dictLength=s.w_size}avail=strm.avail_in,next=strm.next_in,input=strm.input,strm.avail_in=dictLength,strm.next_in=0,strm.input=dictionary,fill_window(s);while(s.lookahead>=MIN_MATCH){str=s.strstart,n=s.lookahead-(MIN_MATCH-1);do s.ins_h=(s.ins_h<>>24,hold>>>=op,bits-=op,op=here>>>16&255,op===0)output[_out++]=here&65535;else if(op&16){if(len=here&65535,op&=15,op){if(bits>>=op,bits-=op}if(bits<15)hold+=input[_in++]<>>24,hold>>>=op,bits-=op,op=here>>>16&255,op&16){if(dist=here&65535,op&=15,bitsdmax){strm.msg=\"invalid distance too far back\",state.mode=BAD;break top}if(hold>>>=op,bits-=op,op=_out-beg,dist>op){if(op=dist-op,op>whave){if(state.sane){strm.msg=\"invalid distance too far back\",state.mode=BAD;break top}}if(from=0,from_source=s_window,wnext===0){if(from+=wsize-op,op2)output[_out++]=from_source[from++],output[_out++]=from_source[from++],output[_out++]=from_source[from++],len-=3;if(len){if(output[_out++]=from_source[from++],len>1)output[_out++]=from_source[from++]}}else{from=_out-dist;do output[_out++]=output[from++],output[_out++]=output[from++],output[_out++]=output[from++],len-=3;while(len>2);if(len){if(output[_out++]=output[from++],len>1)output[_out++]=output[from++]}}}else if((op&64)===0){here=dcode[(here&65535)+(hold&(1<>3,_in-=len,bits-=len<<3,hold&=(1<=1;max--)if(count[max]!==0)break;if(root>max)root=max;if(max===0)return table[table_index++]=1<<24|64<<16|0,table[table_index++]=1<<24|64<<16|0,opts.bits=1,0;for(min=1;min0&&(type===CODES||max!==1))return-1;offs[1]=0;for(len=1;lenENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;for(;;){if(here_bits=len-drop,work[sym]end)here_op=extra[extra_index+work[sym]],here_val=base[base_index+work[sym]];else here_op=96,here_val=0;incr=1<>drop)+fill]=here_bits<<24|here_op<<16|here_val|0;while(fill!==0);incr=1<>=1;if(incr!==0)huff&=incr-1,huff+=incr;else huff=0;if(sym++,--count[len]===0){if(len===max)break;len=lens[lens_index+work[sym]]}if(len>root&&(huff&mask)!==low){if(drop===0)drop=root;next+=min,curr=len-drop,left=1<ENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;low=huff&mask,table[low]=root<<24|curr<<16|next-table_index|0}}if(huff!==0)table[next+huff]=len-drop<<24|64<<16|0;return opts.bits=root,0}}}),require_inflate=__commonJS({\"node_modules/pako/lib/zlib/inflate.js\"(exports){var utils=require_common(),adler32=require_adler32(),crc32=require_crc32(),inflate_fast=require_inffast(),inflate_table=require_inftrees(),CODES=0,LENS=1,DISTS=2,Z_FINISH=4,Z_BLOCK=5,Z_TREES=6,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR=-5,Z_DEFLATED=8,HEAD=1,FLAGS=2,TIME=3,OS=4,EXLEN=5,EXTRA=6,NAME=7,COMMENT=8,HCRC=9,DICTID=10,DICT=11,TYPE=12,TYPEDO=13,STORED=14,COPY_=15,COPY=16,TABLE=17,LENLENS=18,CODELENS=19,LEN_=20,LEN=21,LENEXT=22,DIST=23,DISTEXT=24,MATCH=25,LIT=26,CHECK=27,LENGTH=28,DONE=29,BAD=30,MEM=31,SYNC=32,ENOUGH_LENS=852,ENOUGH_DISTS=592,MAX_WBITS=15,DEF_WBITS=MAX_WBITS;function zswap32(q){return(q>>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function InflateState(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new utils.Buf16(320),this.work=new utils.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateResetKeep(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;if(state=strm.state,strm.total_in=strm.total_out=state.total=0,strm.msg=\"\",state.wrap)strm.adler=state.wrap&1;return state.mode=HEAD,state.last=0,state.havedict=0,state.dmax=32768,state.head=null,state.hold=0,state.bits=0,state.lencode=state.lendyn=new utils.Buf32(ENOUGH_LENS),state.distcode=state.distdyn=new utils.Buf32(ENOUGH_DISTS),state.sane=1,state.back=-1,Z_OK}function inflateReset(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;return state=strm.state,state.wsize=0,state.whave=0,state.wnext=0,inflateResetKeep(strm)}function inflateReset2(strm,windowBits){var wrap,state;if(!strm||!strm.state)return Z_STREAM_ERROR;if(state=strm.state,windowBits<0)wrap=0,windowBits=-windowBits;else if(wrap=(windowBits>>4)+1,windowBits<48)windowBits&=15;if(windowBits&&(windowBits<8||windowBits>15))return Z_STREAM_ERROR;if(state.window!==null&&state.wbits!==windowBits)state.window=null;return state.wrap=wrap,state.wbits=windowBits,inflateReset(strm)}function inflateInit2(strm,windowBits){var ret,state;if(!strm)return Z_STREAM_ERROR;if(state=new InflateState,strm.state=state,state.window=null,ret=inflateReset2(strm,windowBits),ret!==Z_OK)strm.state=null;return ret}function inflateInit(strm){return inflateInit2(strm,DEF_WBITS)}var virgin=!0,lenfix,distfix;function fixedtables(state){if(virgin){var sym;lenfix=new utils.Buf32(512),distfix=new utils.Buf32(32),sym=0;while(sym<144)state.lens[sym++]=8;while(sym<256)state.lens[sym++]=9;while(sym<280)state.lens[sym++]=7;while(sym<288)state.lens[sym++]=8;inflate_table(LENS,state.lens,0,288,lenfix,0,state.work,{bits:9}),sym=0;while(sym<32)state.lens[sym++]=5;inflate_table(DISTS,state.lens,0,32,distfix,0,state.work,{bits:5}),virgin=!1}state.lencode=lenfix,state.lenbits=9,state.distcode=distfix,state.distbits=5}function updatewindow(strm,src,end,copy){var dist,state=strm.state;if(state.window===null)state.wsize=1<=state.wsize)utils.arraySet(state.window,src,end-state.wsize,state.wsize,0),state.wnext=0,state.whave=state.wsize;else{if(dist=state.wsize-state.wnext,dist>copy)dist=copy;if(utils.arraySet(state.window,src,end-copy,dist,state.wnext),copy-=dist,copy)utils.arraySet(state.window,src,end-copy,copy,0),state.wnext=copy,state.whave=state.wsize;else{if(state.wnext+=dist,state.wnext===state.wsize)state.wnext=0;if(state.whave>>8&255,state.check=crc32(state.check,hbuf,2,0),hold=0,bits=0,state.mode=FLAGS;break}if(state.flags=0,state.head)state.head.done=!1;if(!(state.wrap&1)||(((hold&255)<<8)+(hold>>8))%31){strm.msg=\"incorrect header check\",state.mode=BAD;break}if((hold&15)!==Z_DEFLATED){strm.msg=\"unknown compression method\",state.mode=BAD;break}if(hold>>>=4,bits-=4,len=(hold&15)+8,state.wbits===0)state.wbits=len;else if(len>state.wbits){strm.msg=\"invalid window size\",state.mode=BAD;break}state.dmax=1<>8&1;if(state.flags&512)hbuf[0]=hold&255,hbuf[1]=hold>>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0,state.mode=TIME;case TIME:while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>8&255,hbuf[2]=hold>>>16&255,hbuf[3]=hold>>>24&255,state.check=crc32(state.check,hbuf,4,0);hold=0,bits=0,state.mode=OS;case OS:while(bits<16){if(have===0)break inf_leave;have--,hold+=input[next++]<>8;if(state.flags&512)hbuf[0]=hold&255,hbuf[1]=hold>>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0,state.mode=EXLEN;case EXLEN:if(state.flags&1024){while(bits<16){if(have===0)break inf_leave;have--,hold+=input[next++]<>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0}else if(state.head)state.head.extra=null;state.mode=EXTRA;case EXTRA:if(state.flags&1024){if(copy=state.length,copy>have)copy=have;if(copy){if(state.head){if(len=state.head.extra_len-state.length,!state.head.extra)state.head.extra=new Array(state.head.extra_len);utils.arraySet(state.head.extra,input,next,copy,len)}if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy,next+=copy,state.length-=copy}if(state.length)break inf_leave}state.length=0,state.mode=NAME;case NAME:if(state.flags&2048){if(have===0)break inf_leave;copy=0;do if(len=input[next+copy++],state.head&&len&&state.length<65536)state.head.name+=String.fromCharCode(len);while(len&©>9&1,state.head.done=!0;strm.adler=state.check=0,state.mode=TYPE;break;case DICTID:while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=bits&7,bits-=bits&7,state.mode=CHECK;break}while(bits<3){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=1,bits-=1,hold&3){case 0:state.mode=STORED;break;case 1:if(fixedtables(state),state.mode=LEN_,flush===Z_TREES){hold>>>=2,bits-=2;break inf_leave}break;case 2:state.mode=TABLE;break;case 3:strm.msg=\"invalid block type\",state.mode=BAD}hold>>>=2,bits-=2;break;case STORED:hold>>>=bits&7,bits-=bits&7;while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>16^65535)){strm.msg=\"invalid stored block lengths\",state.mode=BAD;break}if(state.length=hold&65535,hold=0,bits=0,state.mode=COPY_,flush===Z_TREES)break inf_leave;case COPY_:state.mode=COPY;case COPY:if(copy=state.length,copy){if(copy>have)copy=have;if(copy>left)copy=left;if(copy===0)break inf_leave;utils.arraySet(output,input,next,copy,put),have-=copy,next+=copy,left-=copy,put+=copy,state.length-=copy;break}state.mode=TYPE;break;case TABLE:while(bits<14){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=5,bits-=5,state.ndist=(hold&31)+1,hold>>>=5,bits-=5,state.ncode=(hold&15)+4,hold>>>=4,bits-=4,state.nlen>286||state.ndist>30){strm.msg=\"too many length or distance symbols\",state.mode=BAD;break}state.have=0,state.mode=LENLENS;case LENLENS:while(state.have>>=3,bits-=3}while(state.have<19)state.lens[order[state.have++]]=0;if(state.lencode=state.lendyn,state.lenbits=7,opts={bits:state.lenbits},ret=inflate_table(CODES,state.lens,0,19,state.lencode,0,state.work,opts),state.lenbits=opts.bits,ret){strm.msg=\"invalid code lengths set\",state.mode=BAD;break}state.have=0,state.mode=CODELENS;case CODELENS:while(state.have>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=here_bits,bits-=here_bits,state.lens[state.have++]=here_val;else{if(here_val===16){n=here_bits+2;while(bits>>=here_bits,bits-=here_bits,state.have===0){strm.msg=\"invalid bit length repeat\",state.mode=BAD;break}len=state.lens[state.have-1],copy=3+(hold&3),hold>>>=2,bits-=2}else if(here_val===17){n=here_bits+3;while(bits>>=here_bits,bits-=here_bits,len=0,copy=3+(hold&7),hold>>>=3,bits-=3}else{n=here_bits+7;while(bits>>=here_bits,bits-=here_bits,len=0,copy=11+(hold&127),hold>>>=7,bits-=7}if(state.have+copy>state.nlen+state.ndist){strm.msg=\"invalid bit length repeat\",state.mode=BAD;break}while(copy--)state.lens[state.have++]=len}}if(state.mode===BAD)break;if(state.lens[256]===0){strm.msg=\"invalid code -- missing end-of-block\",state.mode=BAD;break}if(state.lenbits=9,opts={bits:state.lenbits},ret=inflate_table(LENS,state.lens,0,state.nlen,state.lencode,0,state.work,opts),state.lenbits=opts.bits,ret){strm.msg=\"invalid literal/lengths set\",state.mode=BAD;break}if(state.distbits=6,state.distcode=state.distdyn,opts={bits:state.distbits},ret=inflate_table(DISTS,state.lens,state.nlen,state.ndist,state.distcode,0,state.work,opts),state.distbits=opts.bits,ret){strm.msg=\"invalid distances set\",state.mode=BAD;break}if(state.mode=LEN_,flush===Z_TREES)break inf_leave;case LEN_:state.mode=LEN;case LEN:if(have>=6&&left>=258){if(strm.next_out=put,strm.avail_out=left,strm.next_in=next,strm.avail_in=have,state.hold=hold,state.bits=bits,inflate_fast(strm,_out),put=strm.next_out,output=strm.output,left=strm.avail_out,next=strm.next_in,input=strm.input,have=strm.avail_in,hold=state.hold,bits=state.bits,state.mode===TYPE)state.back=-1;break}state.back=0;for(;;){if(here=state.lencode[hold&(1<>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>last_bits)],here_bits=here>>>24,here_op=here>>>16&255,here_val=here&65535,last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=last_bits,bits-=last_bits,state.back+=last_bits}if(hold>>>=here_bits,bits-=here_bits,state.back+=here_bits,state.length=here_val,here_op===0){state.mode=LIT;break}if(here_op&32){state.back=-1,state.mode=TYPE;break}if(here_op&64){strm.msg=\"invalid literal/length code\",state.mode=BAD;break}state.extra=here_op&15,state.mode=LENEXT;case LENEXT:if(state.extra){n=state.extra;while(bits>>=state.extra,bits-=state.extra,state.back+=state.extra}state.was=state.length,state.mode=DIST;case DIST:for(;;){if(here=state.distcode[hold&(1<>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>last_bits)],here_bits=here>>>24,here_op=here>>>16&255,here_val=here&65535,last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=last_bits,bits-=last_bits,state.back+=last_bits}if(hold>>>=here_bits,bits-=here_bits,state.back+=here_bits,here_op&64){strm.msg=\"invalid distance code\",state.mode=BAD;break}state.offset=here_val,state.extra=here_op&15,state.mode=DISTEXT;case DISTEXT:if(state.extra){n=state.extra;while(bits>>=state.extra,bits-=state.extra,state.back+=state.extra}if(state.offset>state.dmax){strm.msg=\"invalid distance too far back\",state.mode=BAD;break}state.mode=MATCH;case MATCH:if(left===0)break inf_leave;if(copy=_out-left,state.offset>copy){if(copy=state.offset-copy,copy>state.whave){if(state.sane){strm.msg=\"invalid distance too far back\",state.mode=BAD;break}}if(copy>state.wnext)copy-=state.wnext,from=state.wsize-copy;else from=state.wnext-copy;if(copy>state.length)copy=state.length;from_source=state.window}else from_source=output,from=put-state.offset,copy=state.length;if(copy>left)copy=left;left-=copy,state.length-=copy;do output[put++]=from_source[from++];while(--copy);if(state.length===0)state.mode=LEN;break;case LIT:if(left===0)break inf_leave;output[put++]=state.length,left--,state.mode=LEN;break;case CHECK:if(state.wrap){while(bits<32){if(have===0)break inf_leave;have--,hold|=input[next++]<exports.UNZIP)@throwTypeError(\"Bad argument\");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=mode,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}Zlib.prototype={},Zlib.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}if(this.pending_close=!1,assert(this.init_done,\"close before init\"),assert(this.mode<=exports.UNZIP),this.mode===exports.DEFLATE||this.mode===exports.GZIP||this.mode===exports.DEFLATERAW)zlib_deflate.deflateEnd(this.strm);else if(this.mode===exports.INFLATE||this.mode===exports.GUNZIP||this.mode===exports.INFLATERAW||this.mode===exports.UNZIP)zlib_inflate.inflateEnd(this.strm);this.mode=exports.NONE,this.dictionary=null},Zlib.prototype.write=function(flush,input,in_off,in_len,out,out_off,out_len){return this._write(!0,flush,input,in_off,in_len,out,out_off,out_len)},Zlib.prototype.writeSync=function(flush,input,in_off,in_len,out,out_off,out_len){return this._write(!1,flush,input,in_off,in_len,out,out_off,out_len)},Zlib.prototype._write=function(async,flush,input,in_off,in_len,out,out_off,out_len){if(assert.equal(arguments.length,8),assert(this.init_done,\"write before init\"),assert(this.mode!==exports.NONE,\"already finalized\"),assert.equal(!1,this.write_in_progress,\"write already in progress\"),assert.equal(!1,this.pending_close,\"close is pending\"),this.write_in_progress=!0,assert.equal(!1,flush===void 0,\"must provide flush value\"),this.write_in_progress=!0,flush!==exports.Z_NO_FLUSH&&flush!==exports.Z_PARTIAL_FLUSH&&flush!==exports.Z_SYNC_FLUSH&&flush!==exports.Z_FULL_FLUSH&&flush!==exports.Z_FINISH&&flush!==exports.Z_BLOCK)throw new Error(\"Invalid flush value\");if(input==null)input=Buffer.alloc(0),in_len=0,in_off=0;if(this.strm.avail_in=in_len,this.strm.input=input,this.strm.next_in=in_off,this.strm.avail_out=out_len,this.strm.output=out,this.strm.next_out=out_off,this.flush=flush,!async){if(this._process(),this._checkError())return this._afterSync();return}var self=this;return process.nextTick(function(){self._process(),self._after()}),this},Zlib.prototype._afterSync=function(){var avail_out=this.strm.avail_out,avail_in=this.strm.avail_in;return this.write_in_progress=!1,[avail_in,avail_out]},Zlib.prototype._process=function(){var next_expected_header_byte=null;switch(this.mode){case exports.DEFLATE:case exports.GZIP:case exports.DEFLATERAW:this.err=zlib_deflate.deflate(this.strm,this.flush);break;case exports.UNZIP:if(this.strm.avail_in>0)next_expected_header_byte=this.strm.next_in;switch(this.gzip_id_bytes_read){case 0:if(next_expected_header_byte===null)break;if(this.strm.input[next_expected_header_byte]===GZIP_HEADER_ID1){if(this.gzip_id_bytes_read=1,next_expected_header_byte++,this.strm.avail_in===1)break}else{this.mode=exports.INFLATE;break}case 1:if(next_expected_header_byte===null)break;if(this.strm.input[next_expected_header_byte]===GZIP_HEADER_ID2)this.gzip_id_bytes_read=2,this.mode=exports.GUNZIP;else this.mode=exports.INFLATE;break;default:throw new Error(\"invalid number of gzip magic number bytes read\")}case exports.INFLATE:case exports.GUNZIP:case exports.INFLATERAW:if(this.err=zlib_inflate.inflate(this.strm,this.flush),this.err===exports.Z_NEED_DICT&&this.dictionary){if(this.err=zlib_inflate.inflateSetDictionary(this.strm,this.dictionary),this.err===exports.Z_OK)this.err=zlib_inflate.inflate(this.strm,this.flush);else if(this.err===exports.Z_DATA_ERROR)this.err=exports.Z_NEED_DICT}while(this.strm.avail_in>0&&this.mode===exports.GUNZIP&&this.err===exports.Z_STREAM_END&&this.strm.next_in[0]!==0)this.reset(),this.err=zlib_inflate.inflate(this.strm,this.flush);break;default:throw new Error(\"Unknown mode \"+this.mode)}},Zlib.prototype._checkError=function(){switch(this.err){case exports.Z_OK:case exports.Z_BUF_ERROR:if(this.strm.avail_out!==0&&this.flush===exports.Z_FINISH)return this._error(\"unexpected end of file\"),!1;break;case exports.Z_STREAM_END:break;case exports.Z_NEED_DICT:if(this.dictionary==null)this._error(\"Missing dictionary\");else this._error(\"Bad dictionary\");return!1;default:return this._error(\"Zlib error\"),!1}return!0},Zlib.prototype._after=function(){if(!this._checkError())return;var avail_out=this.strm.avail_out,avail_in=this.strm.avail_in;if(this.write_in_progress=!1,this.callback(avail_in,avail_out),this.pending_close)this.close()},Zlib.prototype._error=function(message){if(this.strm.msg)message=this.strm.msg;if(this.onerror(message,this.err),this.write_in_progress=!1,this.pending_close)this.close()},Zlib.prototype.init=function(windowBits,level,memLevel,strategy,dictionary){assert(arguments.length===4||arguments.length===5,\"init(windowBits, level, memLevel, strategy, [dictionary])\"),assert(windowBits>=8&&windowBits<=15,\"invalid windowBits\"),assert(level>=-1&&level<=9,\"invalid compression level\"),assert(memLevel>=1&&memLevel<=9,\"invalid memlevel\"),assert(strategy===exports.Z_FILTERED||strategy===exports.Z_HUFFMAN_ONLY||strategy===exports.Z_RLE||strategy===exports.Z_FIXED||strategy===exports.Z_DEFAULT_STRATEGY,\"invalid strategy\"),this._init(level,windowBits,memLevel,strategy,dictionary),this._setDictionary()},Zlib.prototype.params=function(){throw new Error(\"deflateParams Not supported\")},Zlib.prototype.reset=function(){this._reset(),this._setDictionary()},Zlib.prototype._init=function(level,windowBits,memLevel,strategy,dictionary){if(this.level=level,this.windowBits=windowBits,this.memLevel=memLevel,this.strategy=strategy,this.flush=exports.Z_NO_FLUSH,this.err=exports.Z_OK,this.mode===exports.GZIP||this.mode===exports.GUNZIP)this.windowBits+=16;if(this.mode===exports.UNZIP)this.windowBits+=32;if(this.mode===exports.DEFLATERAW||this.mode===exports.INFLATERAW)this.windowBits=-1*this.windowBits;switch(this.strm=new Zstream,this.mode){case exports.DEFLATE:case exports.GZIP:case exports.DEFLATERAW:this.err=zlib_deflate.deflateInit2(this.strm,this.level,exports.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case exports.INFLATE:case exports.GUNZIP:case exports.INFLATERAW:case exports.UNZIP:this.err=zlib_inflate.inflateInit2(this.strm,this.windowBits);break;default:throw new Error(\"Unknown mode \"+this.mode)}if(this.err!==exports.Z_OK)this._error(\"Init error\");this.dictionary=dictionary,this.write_in_progress=!1,this.init_done=!0},Zlib.prototype._setDictionary=function(){if(this.dictionary==null)return;switch(this.err=exports.Z_OK,this.mode){case exports.DEFLATE:case exports.DEFLATERAW:this.err=zlib_deflate.deflateSetDictionary(this.strm,this.dictionary);break;default:break}if(this.err!==exports.Z_OK)this._error(\"Failed to set dictionary\")},Zlib.prototype._reset=function(){switch(this.err=exports.Z_OK,this.mode){case exports.DEFLATE:case exports.DEFLATERAW:case exports.GZIP:this.err=zlib_deflate.deflateReset(this.strm);break;case exports.INFLATE:case exports.INFLATERAW:case exports.GUNZIP:this.err=zlib_inflate.inflateReset(this.strm);break;default:break}if(this.err!==exports.Z_OK)this._error(\"Failed to reset stream\")},exports.Zlib=Zlib}}),require_lib=__commonJS({\"node_modules/browserify-zlib/lib/index.js\"(exports){var Buffer2=BufferModule.Buffer,Transform=StreamModule.Transform,binding=require_binding(),util=Util,kMaxLength=BufferModule.kMaxLength,kRangeErrorMessage=\"Cannot create final Buffer. It would be larger than 0x\"+kMaxLength.toString(16)+\" bytes\";binding.Z_MIN_WINDOWBITS=8,binding.Z_MAX_WINDOWBITS=15,binding.Z_DEFAULT_WINDOWBITS=15,binding.Z_MIN_CHUNK=64,binding.Z_MAX_CHUNK=Infinity,binding.Z_DEFAULT_CHUNK=16384,binding.Z_MIN_MEMLEVEL=1,binding.Z_MAX_MEMLEVEL=9,binding.Z_DEFAULT_MEMLEVEL=8,binding.Z_MIN_LEVEL=-1,binding.Z_MAX_LEVEL=9,binding.Z_DEFAULT_LEVEL=binding.Z_DEFAULT_COMPRESSION;var bkeys=Object.keys(binding);for(bk=0;bk=kMaxLength)err=new RangeError(kRangeErrorMessage);else buf=Buffer2.concat(buffers,nread);buffers=[],engine.close(),callback(err,buf)}}function zlibBufferSync(engine,buffer){if(typeof buffer===\"string\")buffer=Buffer2.from(buffer);if(!Buffer2.isBuffer(buffer))@throwTypeError(\"Not a string or buffer\");var flushFlag=engine._finishFlushFlag;return engine._processChunk(buffer,flushFlag)}function Deflate(opts){if(!(this instanceof Deflate))return new Deflate(opts);Zlib.call(this,opts,binding.DEFLATE)}function Inflate(opts){if(!(this instanceof Inflate))return new Inflate(opts);Zlib.call(this,opts,binding.INFLATE)}function Gzip(opts){if(!(this instanceof Gzip))return new Gzip(opts);Zlib.call(this,opts,binding.GZIP)}function Gunzip(opts){if(!(this instanceof Gunzip))return new Gunzip(opts);Zlib.call(this,opts,binding.GUNZIP)}function DeflateRaw(opts){if(!(this instanceof DeflateRaw))return new DeflateRaw(opts);Zlib.call(this,opts,binding.DEFLATERAW)}function InflateRaw(opts){if(!(this instanceof InflateRaw))return new InflateRaw(opts);Zlib.call(this,opts,binding.INFLATERAW)}function Unzip(opts){if(!(this instanceof Unzip))return new Unzip(opts);Zlib.call(this,opts,binding.UNZIP)}function isValidFlushFlag(flag){return flag===binding.Z_NO_FLUSH||flag===binding.Z_PARTIAL_FLUSH||flag===binding.Z_SYNC_FLUSH||flag===binding.Z_FULL_FLUSH||flag===binding.Z_FINISH||flag===binding.Z_BLOCK}function Zlib(opts,mode){var _this=this;if(this._opts=opts=opts||{},this._chunkSize=opts.chunkSize||exports.Z_DEFAULT_CHUNK,Transform.call(this,opts),opts.flush&&!isValidFlushFlag(opts.flush))throw new Error(\"Invalid flush flag: \"+opts.flush);if(opts.finishFlush&&!isValidFlushFlag(opts.finishFlush))throw new Error(\"Invalid flush flag: \"+opts.finishFlush);if(this._flushFlag=opts.flush||binding.Z_NO_FLUSH,this._finishFlushFlag=typeof opts.finishFlush!==\"undefined\"\?opts.finishFlush:binding.Z_FINISH,opts.chunkSize){if(opts.chunkSizeexports.Z_MAX_CHUNK)throw new Error(\"Invalid chunk size: \"+opts.chunkSize)}if(opts.windowBits){if(opts.windowBitsexports.Z_MAX_WINDOWBITS)throw new Error(\"Invalid windowBits: \"+opts.windowBits)}if(opts.level){if(opts.levelexports.Z_MAX_LEVEL)throw new Error(\"Invalid compression level: \"+opts.level)}if(opts.memLevel){if(opts.memLevelexports.Z_MAX_MEMLEVEL)throw new Error(\"Invalid memLevel: \"+opts.memLevel)}if(opts.strategy){if(opts.strategy!=exports.Z_FILTERED&&opts.strategy!=exports.Z_HUFFMAN_ONLY&&opts.strategy!=exports.Z_RLE&&opts.strategy!=exports.Z_FIXED&&opts.strategy!=exports.Z_DEFAULT_STRATEGY)throw new Error(\"Invalid strategy: \"+opts.strategy)}if(opts.dictionary){if(!Buffer2.isBuffer(opts.dictionary))throw new Error(\"Invalid dictionary: it should be a Buffer instance\")}this._handle=new binding.Zlib(mode);var self=this;this._hadError=!1,this._handle.onerror=function(message,errno){_close(self),self._hadError=!0;var error=new Error(message);error.errno=errno,error.code=exports.codes[errno],self.emit(\"error\",error)};var level=exports.Z_DEFAULT_COMPRESSION;if(typeof opts.level===\"number\")level=opts.level;var strategy=exports.Z_DEFAULT_STRATEGY;if(typeof opts.strategy===\"number\")strategy=opts.strategy;this._handle.init(opts.windowBits||exports.Z_DEFAULT_WINDOWBITS,level,opts.memLevel||exports.Z_DEFAULT_MEMLEVEL,strategy,opts.dictionary),this._buffer=Buffer2.allocUnsafe(this._chunkSize),this._offset=0,this._level=level,this._strategy=strategy,this.once(\"end\",this.close),Object.defineProperty(this,\"_closed\",{get:function(){return!_this._handle},configurable:!0,enumerable:!0})}util.inherits(Zlib,Transform),Zlib.prototype.params=function(level,strategy,callback){if(levelexports.Z_MAX_LEVEL)@throwRangeError(\"Invalid compression level: \"+level);if(strategy!=exports.Z_FILTERED&&strategy!=exports.Z_HUFFMAN_ONLY&&strategy!=exports.Z_RLE&&strategy!=exports.Z_FIXED&&strategy!=exports.Z_DEFAULT_STRATEGY)@throwTypeError(\"Invalid strategy: \"+strategy);if(this._level!==level||this._strategy!==strategy){var self=this;this.flush(binding.Z_SYNC_FLUSH,function(){if(assert(self._handle,\"zlib binding closed\"),self._handle.params(level,strategy),!self._hadError){if(self._level=level,self._strategy=strategy,callback)callback()}})}else process.nextTick(callback)},Zlib.prototype.reset=function(){return assert(this._handle,\"zlib binding closed\"),this._handle.reset()},Zlib.prototype._flush=function(callback){this._transform(Buffer2.alloc(0),\"\",callback)},Zlib.prototype.flush=function(kind,callback){var _this2=this,ws=this._writableState;if(typeof kind===\"function\"||kind===void 0&&!callback)callback=kind,kind=binding.Z_FULL_FLUSH;if(ws.ended){if(callback)process.nextTick(callback)}else if(ws.ending){if(callback)this.once(\"end\",callback)}else if(ws.needDrain){if(callback)this.once(\"drain\",function(){return _this2.flush(kind,callback)})}else this._flushFlag=kind,this.write(Buffer2.alloc(0),\"\",callback)},Zlib.prototype.close=function(callback){_close(this,callback),process.nextTick(emitCloseNT,this)};function _close(engine,callback){if(callback)process.nextTick(callback);if(!engine._handle)return;engine._handle.close(),engine._handle=null}function emitCloseNT(self){self.emit(\"close\")}Zlib.prototype._transform=function(chunk,encoding,cb){var flushFlag,ws=this._writableState,ending=ws.ending||ws.ended,last=ending&&(!chunk||ws.length===chunk.length);if(chunk!==null&&!Buffer2.isBuffer(chunk))return cb(new Error(\"invalid input\"));if(!this._handle)return cb(new Error(\"zlib binding closed\"));if(last)flushFlag=this._finishFlushFlag;else if(flushFlag=this._flushFlag,chunk.length>=ws.length)this._flushFlag=this._opts.flush||binding.Z_NO_FLUSH;this._processChunk(chunk,flushFlag,cb)},Zlib.prototype._processChunk=function(chunk,flushFlag,cb){var availInBefore=chunk&&chunk.length,availOutBefore=this._chunkSize-this._offset,inOff=0,self=this,async=typeof cb===\"function\";if(!async){var buffers=[],nread=0,error;this.on(\"error\",function(er){error=er}),assert(this._handle,\"zlib binding closed\");do var res=this._handle.writeSync(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore);while(!this._hadError&&callback(res[0],res[1]));if(this._hadError)throw error;if(nread>=kMaxLength)_close(this),@throwRangeError(kRangeErrorMessage);var buf=Buffer2.concat(buffers,nread);return _close(this),buf}assert(this._handle,\"zlib binding closed\");var req=this._handle.write(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore);req.buffer=chunk,req.callback=callback;function callback(availInAfter,availOutAfter){if(this)this.buffer=null,this.callback=null;if(self._hadError)return;var have=availOutBefore-availOutAfter;if(assert(have>=0,\"have should not go down\"),have>0){var out=self._buffer.slice(self._offset,self._offset+have);if(self._offset+=have,async)self.push(out);else buffers.push(out),nread+=out.length}if(availOutAfter===0||self._offset>=self._chunkSize)availOutBefore=self._chunkSize,self._offset=0,self._buffer=Buffer2.allocUnsafe(self._chunkSize);if(availOutAfter===0){if(inOff+=availInBefore-availInAfter,availInBefore=availInAfter,!async)return!0;var newReq=self._handle.write(flushFlag,chunk,inOff,availInBefore,self._buffer,self._offset,self._chunkSize);newReq.callback=callback,newReq.buffer=chunk;return}if(!async)return!1;cb()}},util.inherits(Deflate,Zlib),util.inherits(Inflate,Zlib),util.inherits(Gzip,Zlib),util.inherits(Gunzip,Zlib),util.inherits(DeflateRaw,Zlib),util.inherits(InflateRaw,Zlib),util.inherits(Unzip,Zlib)}});return require_lib()})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDepdCode = "(function (){\"use strict\";var $=function depd(namespace){if(!namespace)@throwTypeError(\"argument namespace is required\");function deprecate(message){}return deprecate._file=void 0,deprecate._ignored=!0,deprecate._namespace=namespace,deprecate._traced=!1,deprecate._warned=Object.create(null),deprecate.function=wrapfunction,deprecate.property=wrapproperty,deprecate};function wrapfunction(fn,message){if(typeof fn!==\"function\")@throwTypeError(\"argument fn must be a function\");return fn}function wrapproperty(obj,prop,message){if(!obj||typeof obj!==\"object\"&&typeof obj!==\"function\")@throwTypeError(\"argument obj must be object\");var descriptor=Object.getOwnPropertyDescriptor(obj,prop);if(!descriptor)@throwTypeError(\"must call property on owner object\");if(!descriptor.configurable)@throwTypeError(\"property must be configurable\")}return $})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDetectLibcCode = "(function (){\"use strict\";function family(){return Promise.resolve(familySync())}function familySync(){return null}const GLIBC=\"glibc\",MUSL=\"musl\";function versionAsync(){return Promise.resolve(version())}function version(){return null}function isNonGlibcLinuxSync(){return!1}function isNonGlibcLinux(){return Promise.resolve(isNonGlibcLinuxSync())}return{GLIBC,MUSL,family,familySync,isNonGlibcLinux,isNonGlibcLinuxSync,version,versionAsync}})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDetectLibcLinuxCode = "(function (){\"use strict\";function family(){return Promise.resolve(familySync())}function familySync(){return GLIBC}const GLIBC=\"glibc\",MUSL=\"musl\";function versionAsync(){return Promise.resolve(version())}function version(){return\"2.29\"}function isNonGlibcLinuxSync(){return!1}function isNonGlibcLinux(){return Promise.resolve(isNonGlibcLinuxSync())}return{GLIBC,MUSL,family,familySync,isNonGlibcLinux,isNonGlibcLinuxSync,version,versionAsync}})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyIsomorphicFetchCode = "(function (){\"use strict\";return globalThis.fetch})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyNodeFetchCode = "(function (){\"use strict\";const{Headers,Request,Response,Blob,File=Blob,FormData}=globalThis,realFetch=Bun.fetch;function fetch(...args){return realFetch(...args)}class AbortError extends DOMException{constructor(message){super(message,\"AbortError\")}}class FetchBaseError extends Error{constructor(message,type){super(message);this.type=type}}class FetchError extends FetchBaseError{constructor(message,type,systemError){super(message,type);this.code=systemError\?.code}}function blobFrom(path,options){return Promise.resolve(Bun.file(data))}function blobFromSync(path,options){return Bun.file(data)}var fileFrom=blobFrom,fileFromSync=blobFromSync;function isRedirect(code){return code===301||code===302||code===303||code===307||code===308}return Object.assign(fetch,{AbortError,Blob,FetchBaseError,FetchError,File,FormData,Headers,Request,Response,blobFrom,blobFromSync,fileFrom,fileFromSync,isRedirect,fetch})})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyUndiciCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),{Readable}=StreamModule,{_ReadableFromWebForUndici:ReadableFromWeb}=StreamModule[Symbol.for(\"::bunternal::\")],ObjectCreate=Object.create,kEmptyObject=ObjectCreate(null);var fetch=Bun.fetch,Response=globalThis.Response,Headers=globalThis.Headers,Request=globalThis.Request,URLSearchParams=globalThis.URLSearchParams,URL=globalThis.URL;class File extends Blob{constructor(){super(...arguments)}}class FileReader extends EventTarget{constructor(){throw new Error(\"Not implemented yet!\")}}var FormData=globalThis.FormData;function notImplemented(){throw new Error(\"Not implemented in bun\")}class BodyReadable extends ReadableFromWeb{#response;#bodyUsed;constructor(response,options={}){var{body}=response;if(!body)throw new Error(\"Response body is null\");super(options,body);this.#response=response,this.#bodyUsed=response.bodyUsed}get bodyUsed(){return this.#bodyUsed}#consume(){if(this.#bodyUsed)@throwTypeError(\"unusable\");this.#bodyUsed=!0}async arrayBuffer(){return this.#consume(),await this.#response.arrayBuffer()}async blob(){return this.#consume(),await this.#response.blob()}async formData(){return this.#consume(),await this.#response.formData()}async json(){return this.#consume(),await this.#response.json()}async text(){return this.#consume(),await this.#response.text()}}async function request(url,options={method:\"GET\",signal:null,headers:null,query:null,reset:!1,throwOnError:!1,body:null}){let{method=\"GET\",headers:inputHeaders,query,signal,reset=!1,throwOnError=!1,body:inputBody,maxRedirections}=options;if(typeof url===\"string\"){if(query)url=new URL(url)}else if(typeof url===\"object\"&&url!==null){if(!(url instanceof URL))throw new Error(\"not implemented\")}else @throwTypeError(\"url must be a string, URL, or UrlObject\");if(typeof url===\"string\"&&query)url=new URL(url);if(typeof url===\"object\"&&url!==null&&query){if(query)url.search=new URLSearchParams(query).toString()}if(method=method&&typeof method===\"string\"\?method.toUpperCase():null,inputBody&&(method===\"GET\"||method===\"HEAD\"))throw new Error(\"Body not allowed for GET or HEAD requests\");if(inputBody&&inputBody.read&&inputBody instanceof Readable){let data=\"\";inputBody.setEncoding(\"utf8\");for await(let chunk of stream)data+=chunk;inputBody=(new TextEncoder()).encode(data)}if(maxRedirections!==void 0&&Number.isNaN(maxRedirections))throw new Error(\"maxRedirections must be a number if defined\");if(signal&&!(signal instanceof AbortSignal))throw new Error(\"signal must be an instance of AbortSignal\");let resp;const{status:statusCode,headers,trailers}=resp=await fetch(url,{signal,mode:\"cors\",method,headers:inputHeaders||kEmptyObject,body:inputBody,redirect:maxRedirections===\"undefined\"||maxRedirections>0\?\"follow\":\"manual\",keepalive:!reset});if(throwOnError&&statusCode>=400&&statusCode<600)throw new Error(`Request failed with status code ${statusCode}`);const body=resp.body\?new BodyReadable(resp):null;return{statusCode,headers:headers.toJSON(),body,trailers,opaque:kEmptyObject,context:kEmptyObject}}function stream(){throw new Error(\"Not implemented in bun\")}function pipeline(){throw new Error(\"Not implemented in bun\")}function connect(){throw new Error(\"Not implemented in bun\")}function upgrade(){throw new Error(\"Not implemented in bun\")}class MockClient{constructor(){throw new Error(\"Not implemented in bun\")}}class MockPool{constructor(){throw new Error(\"Not implemented in bun\")}}class MockAgent{constructor(){throw new Error(\"Not implemented in bun\")}}function mockErrors(){throw new Error(\"Not implemented in bun\")}function Undici(){throw new Error(\"Not implemented in bun\")}class Dispatcher extends EventEmitter{constructor(){super(...arguments)}}class Agent extends Dispatcher{constructor(){super(...arguments)}}class Pool extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}class BalancedPool extends Dispatcher{constructor(){super(...arguments)}}class Client extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}return Undici.Dispatcher=Dispatcher,Undici.Pool=Pool,Undici.BalancedPool=BalancedPool,Undici.Client=Client,Undici.Agent=Agent,Undici.buildConnector=Undici.errors=Undici.setGlobalDispatcher=Undici.getGlobalDispatcher=Undici.request=Undici.stream=Undici.pipeline=Undici.connect=Undici.upgrade=Undici.MockClient=Undici.MockPool=Undici.MockAgent=Undici.mockErrors=notImplemented,Undici.fetch=fetch,{fetch,Response,Headers,Request,URLSearchParams,URL,File,FileReader,FormData,request,stream,pipeline,connect,upgrade,MockClient,MockPool,MockAgent,mockErrors,Dispatcher,Pool,BalancedPool,Client,Agent,Undici}})\n"_s; +// + +// +static constexpr ASCIILiteral ThirdpartyUtf8ValidateCode = "(function (){\"use strict\";return @requireNativeModule(\"node:buffer\").isUtf8})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyVercelFetchCode = "(function (){\"use strict\";var $=(wrapper=Bun.fetch)=>{async function vercelFetch(url,opts={}){if(opts.body&&typeof opts.body===\"object\"&&(!(\"buffer\"in opts.body)||typeof opts.body.buffer!==\"object\"||!(opts.body.buffer instanceof ArrayBuffer))){if(opts.body=JSON.stringify(opts.body),!opts.headers)opts.headers=new Headers;opts.headers.set(\"Content-Type\",\"application/json\")}try{return await wrapper(url,opts)}catch(err){if(typeof err===\"string\")err=new Error(err);throw err.url=url,err.opts=opts,err}}return vercelFetch.default=vercelFetch,vercelFetch};return $})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyWSCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),http=@getInternalField(@internalModuleRegistry,18)||@createInternalModuleById(18),kBunInternals=Symbol.for(\"::bunternal::\"),readyStates=[\"CONNECTING\",\"OPEN\",\"CLOSING\",\"CLOSED\"],encoder=new TextEncoder,eventIds={open:1,close:2,message:3,error:4,ping:5,pong:6},emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}class BunWebSocket extends EventEmitter{static CONNECTING=0;static OPEN=1;static CLOSING=2;static CLOSED=3;#ws;#paused=!1;#fragments=!1;#binaryType=\"nodebuffer\";#eventId=0;constructor(url,protocols,options){super();let ws=this.#ws=new WebSocket(url,protocols);ws.binaryType=\"nodebuffer\"}on(event,listener){if(event===\"unexpected-response\"||event===\"upgrade\"||event===\"redirect\")emitWarning(event,\"ws.WebSocket '\"+event+\"' event is not implemented in bun\");const mask=1<{this.emit(\"open\")});else if(event===\"close\")this.#ws.addEventListener(\"close\",({code,reason,wasClean})=>{this.emit(\"close\",code,reason,wasClean)});else if(event===\"message\")this.#ws.addEventListener(\"message\",({data})=>{const isBinary=typeof data!==\"string\";if(isBinary)this.emit(\"message\",this.#fragments\?[data]:data,isBinary);else{let encoded=encoder.encode(data);if(this.#binaryType!==\"arraybuffer\")encoded=Buffer.from(encoded.buffer,encoded.byteOffset,encoded.byteLength);this.emit(\"message\",this.#fragments\?[encoded]:encoded,isBinary)}});else if(event===\"error\")this.#ws.addEventListener(\"error\",(err)=>{this.emit(\"error\",err)});else if(event===\"ping\")this.#ws.addEventListener(\"ping\",({data})=>{this.emit(\"ping\",data)});else if(event===\"pong\")this.#ws.addEventListener(\"pong\",({data})=>{this.emit(\"pong\",data)})}return super.on(event,listener)}send(data,opts,cb){try{this.#ws.send(data,opts\?.compress)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}close(code,reason){this.#ws.close(code,reason)}terminate(){this.#ws.terminate()}get url(){return this.#ws.url}get readyState(){return this.#ws.readyState}get binaryType(){return this.#binaryType}set binaryType(value){if(value===\"nodebuffer\"||value===\"arraybuffer\")this.#ws.binaryType=this.#binaryType=value,this.#fragments=!1;else if(value===\"fragments\")this.#ws.binaryType=\"nodebuffer\",this.#binaryType=\"fragments\",this.#fragments=!0;else throw new Error(`Invalid binaryType: ${value}`)}get protocol(){return this.#ws.protocol}get extensions(){return this.#ws.extensions}addEventListener(type,listener,options){this.#ws.addEventListener(type,listener,options)}removeEventListener(type,listener){this.#ws.removeEventListener(type,listener)}get onopen(){return this.#ws.onopen}set onopen(value){this.#ws.onopen=value}get onerror(){return this.#ws.onerror}set onerror(value){this.#ws.onerror=value}get onclose(){return this.#ws.onclose}set onclose(value){this.#ws.onclose=value}get onmessage(){return this.#ws.onmessage}set onmessage(value){this.#ws.onmessage=value}get bufferedAmount(){return this.#ws.bufferedAmount}get isPaused(){return this.#paused}ping(data,mask,cb){if(typeof data===\"function\")cb=data,data=mask=void 0;else if(typeof mask===\"function\")cb=mask,mask=void 0;if(typeof data===\"number\")data=data.toString();try{this.#ws.ping(data)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}pong(data,mask,cb){if(typeof data===\"function\")cb=data,data=mask=void 0;else if(typeof mask===\"function\")cb=mask,mask=void 0;if(typeof data===\"number\")data=data.toString();try{this.#ws.pong(data)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}pause(){switch(this.readyState){case WebSocket.CONNECTING:case WebSocket.CLOSED:return}this.#paused=!0,emitWarning(\"pause()\",\"ws.WebSocket.pause() is not implemented in bun\")}resume(){switch(this.readyState){case WebSocket.CONNECTING:case WebSocket.CLOSED:return}this.#paused=!1,emitWarning(\"resume()\",\"ws.WebSocket.resume() is not implemented in bun\")}}Object.defineProperty(BunWebSocket,\"name\",{value:\"WebSocket\"});const wsKeyRegex=/^[+/0-9A-Za-z]{22}==$/,wsTokenChars=[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,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function subprotocolParse(header){const protocols=new Set;let start=-1,end=-1,i=0;for(i;i{const body=http.STATUS_CODES[426];res.writeHead(426,{\"Content-Length\":body.length,\"Content-Type\":\"text/plain\"}),res.end(body)}),this._server.listen(options.port,options.host,options.backlog,callback);else if(options.server)this._server=options.server;if(this._server){const emitConnection=this.emit.bind(this,\"connection\"),emitListening=this.emit.bind(this,\"listening\"),emitError=this.emit.bind(this,\"error\"),doUpgrade=(req,socket,head)=>{this.handleUpgrade(req,socket,head,emitConnection)};this._server.on(\"listening\",emitListening),this._server.on(\"error\",emitError),this._server.on(\"upgrade\",doUpgrade),this._removeListeners=()=>{this._server.removeListener(\"upgrade\",doUpgrade),this._server.removeListener(\"listening\",emitListening),this._server.removeListener(\"error\",emitError)}}if(options.perMessageDeflate===!0)options.perMessageDeflate={};if(options.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=options,this._state=RUNNING}address(){if(this.options.noServer)throw new Error('The server is operating in \"noServer\" mode');if(!this._server)return null;return this._server.address()}close(cb){if(this._state===CLOSED){if(cb)this.once(\"close\",()=>{cb(new Error(\"The server is not running\"))});process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this);return}if(cb)this.once(\"close\",cb);if(this._state===CLOSING)return;if(this._state=CLOSING,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this);else this._shouldEmitClose=!0;else process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this)}else{const server=this._server;this._removeListeners(),this._removeListeners=this._server=null,server.close(()=>{this._state=CLOSED,this.emit(\"close\")})}}shouldHandle(req){if(this.options.path){const index=req.url.indexOf(\"\?\");if((index!==-1\?req.url.slice(0,index):req.url)!==this.options.path)return!1}return!0}completeUpgrade(extensions,key,protocols,request,socket,head,cb){const[server,response,req]=socket[kBunInternals];if(this._state>RUNNING)return abortHandshake(response,503);let protocol=\"\";if(protocols.size)protocol=this.options.handleProtocols\?this.options.handleProtocols(protocols,request):protocols.values().next().value;const ws=new BunWebSocketMocked(request.url,protocol,extensions,\"nodebuffer\"),headers=[\"HTTP/1.1 101 Switching Protocols\",\"Upgrade: websocket\",\"Connection: Upgrade\"];if(this.emit(\"headers\",headers,request),server.upgrade(req,{data:ws[kBunInternals]})){if(response._reply(void 0),this.clients)this.clients.add(ws),ws.on(\"close\",()=>{if(this.clients.delete(ws),this._shouldEmitClose&&!this.clients.size)process.nextTick(wsEmitClose,this)});cb(ws,request)}else abortHandshake(response,500)}handleUpgrade(req,socket,head,cb){const[_,response]=socket[kBunInternals],key=req.headers[\"sec-websocket-key\"],version=+req.headers[\"sec-websocket-version\"];if(req.method!==\"GET\"){abortHandshakeOrEmitwsClientError(this,req,response,socket,405,\"Invalid HTTP method\");return}if(req.headers.upgrade.toLowerCase()!==\"websocket\"){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Invalid Upgrade header\");return}if(!key||!wsKeyRegex.test(key)){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Missing or invalid Sec-WebSocket-Key header\");return}if(version!==8&&version!==13){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Missing or invalid Sec-WebSocket-Version header\");return}if(!this.shouldHandle(req)){abortHandshake(response,400);return}const secWebSocketProtocol=req.headers[\"sec-websocket-protocol\"];let protocols=new Set;if(secWebSocketProtocol!==void 0)try{protocols=subprotocolParse(secWebSocketProtocol)}catch(err){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Invalid Sec-WebSocket-Protocol header\");return}const extensions={};if(this.options.verifyClient){const info={origin:req.headers[`${version===8\?\"sec-websocket-origin\":\"origin\"}`],secure:!!(req.socket.authorized||req.socket.encrypted),req};if(this.options.verifyClient.length===2){this.options.verifyClient(info,(verified,code,message,headers)=>{if(!verified)return abortHandshake(response,code||401,message,headers);this.completeUpgrade(extensions,key,protocols,req,socket,head,cb)});return}if(!this.options.verifyClient(info))return abortHandshake(response,401)}this.completeUpgrade(extensions,key,protocols,req,socket,head,cb)}}Object.defineProperty(BunWebSocket,\"CONNECTING\",{enumerable:!0,value:readyStates.indexOf(\"CONNECTING\")}),Object.defineProperty(BunWebSocket.prototype,\"CONNECTING\",{enumerable:!0,value:readyStates.indexOf(\"CONNECTING\")}),Object.defineProperty(BunWebSocket,\"OPEN\",{enumerable:!0,value:readyStates.indexOf(\"OPEN\")}),Object.defineProperty(BunWebSocket.prototype,\"OPEN\",{enumerable:!0,value:readyStates.indexOf(\"OPEN\")}),Object.defineProperty(BunWebSocket,\"CLOSING\",{enumerable:!0,value:readyStates.indexOf(\"CLOSING\")}),Object.defineProperty(BunWebSocket.prototype,\"CLOSING\",{enumerable:!0,value:readyStates.indexOf(\"CLOSING\")}),Object.defineProperty(BunWebSocket,\"CLOSED\",{enumerable:!0,value:readyStates.indexOf(\"CLOSED\")}),Object.defineProperty(BunWebSocket.prototype,\"CLOSED\",{enumerable:!0,value:readyStates.indexOf(\"CLOSED\")});class Sender{constructor(){throw new Error(\"Not supported yet in Bun\")}}class Receiver{constructor(){throw new Error(\"Not supported yet in Bun\")}}var createWebSocketStream=(ws)=>{throw new Error(\"Not supported yet in Bun\")};return Object.assign(BunWebSocket,{createWebSocketStream,Receiver,Sender,WebSocket:BunWebSocket,Server:WebSocketServer,WebSocketServer})})\n"_s; +// + #elif _WIN32 - static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";const FFIType={\"0\":0,\"1\":1,\"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\"7\":7,\"8\":8,\"9\":9,\"10\":10,\"11\":11,\"12\":12,\"13\":13,\"14\":14,\"15\":15,\"16\":16,\"17\":17,bool:11,c_int:5,c_uint:6,char:0,\"char*\":12,double:9,f32:10,f64:9,float:10,i16:3,i32:5,i64:7,i8:1,int:5,int16_t:3,int32_t:5,int64_t:7,int8_t:1,isize:7,u16:4,u32:6,u64:8,u8:2,uint16_t:4,uint32_t:6,uint64_t:8,uint8_t:2,usize:8,\"void*\":12,ptr:12,pointer:12,void:13,cstring:14,i64_fast:15,u64_fast:16,function:17,callback:17,fn:17};var ffi=globalThis.Bun.FFI;const ptr=(arg1,arg2)=>typeof arg2===\"undefined\"\?ffi.ptr(arg1):ffi.ptr(arg1,arg2),toBuffer=ffi.toBuffer,toArrayBuffer=ffi.toArrayBuffer,viewSource=ffi.viewSource,BunCString=ffi.CString,nativeLinkSymbols=ffi.linkSymbols,nativeDLOpen=ffi.dlopen,nativeCallback=ffi.callback,closeCallback=ffi.closeCallback;delete ffi.callback,delete ffi.closeCallback;class JSCallback{constructor(cb,options){const{ctx,ptr:ptr2}=nativeCallback(options,cb);this.#ctx=ctx,this.ptr=ptr2,this.#threadsafe=!!options\?.threadsafe}ptr;#ctx;#threadsafe;get threadsafe(){return this.#threadsafe}[Symbol.toPrimitive](){const{ptr:ptr2}=this;return typeof ptr2===\"number\"\?ptr2:0}close(){const ctx=this.#ctx;if(this.ptr=null,this.#ctx=null,ctx)closeCallback(ctx)}}class CString extends String{constructor(ptr2,byteOffset,byteLength){super(ptr2\?typeof byteLength===\"number\"&&Number.isSafeInteger(byteLength)\?new BunCString(ptr2,byteOffset||0,byteLength):new BunCString(ptr2):\"\");if(this.ptr=typeof ptr2===\"number\"\?ptr2:0,typeof byteOffset!==\"undefined\")this.byteOffset=byteOffset;if(typeof byteLength!==\"undefined\")this.byteLength=byteLength}ptr;byteOffset;byteLength;#cachedArrayBuffer;get arrayBuffer(){if(this.#cachedArrayBuffer)return this.#cachedArrayBuffer;if(!this.ptr)return this.#cachedArrayBuffer=new ArrayBuffer(0);return this.#cachedArrayBuffer=toArrayBuffer(this.ptr,this.byteOffset,this.byteLength)}}Object.defineProperty(globalThis,\"__GlobalBunCString\",{value:CString,enumerable:!1,configurable:!1});const ffiWrappers=new Array(18);var char=\"val|0\";ffiWrappers.fill(char),ffiWrappers[FFIType.uint8_t]=\"val<0\?0:val>=255\?255:val|0\",ffiWrappers[FFIType.int16_t]=\"val<=-32768\?-32768:val>=32768\?32768:val|0\",ffiWrappers[FFIType.uint16_t]=\"val<=0\?0:val>=65536\?65536:val|0\",ffiWrappers[FFIType.int32_t]=\"val|0\",ffiWrappers[FFIType.uint32_t]=\"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\",ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.int64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.uint64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`,ffiWrappers[FFIType.uint16_t]=`{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`,ffiWrappers[FFIType.double]=`{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`,ffiWrappers[FFIType.float]=ffiWrappers[10]=`{\n return Math.fround(val);\n}`,ffiWrappers[FFIType.bool]=`{\n return !!val;\n}`,Object.defineProperty(globalThis,\"__GlobalBunFFIPtrFunctionForWrapper\",{value:ptr,enumerable:!1,configurable:!0}),ffiWrappers[FFIType.cstring]=ffiWrappers[FFIType.pointer]=`{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`,ffiWrappers[FFIType.function]=`{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;function FFIBuilder(params,returnType,functionToCall,name){const hasReturnType=typeof FFIType[returnType]===\"number\"&&FFIType[returnType]!==FFIType.void;var paramNames=new Array(params.length),args=new Array(params.length);for(let i=0;i${wrapper})(p${i})`;else @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`)}var code=`functionToCall(${args.join(\", \")})`;if(hasReturnType)if(FFIType[returnType]===FFIType.cstring)code=`return new __GlobalBunCString(${code})`;else code=`return ${code}`;var func=new Function(\"functionToCall\",...paramNames,code);Object.defineProperty(func,\"name\",{value:name});var wrap;switch(paramNames.length){case 0:wrap=()=>func(functionToCall);break;case 1:wrap=(arg1)=>func(functionToCall,arg1);break;case 2:wrap=(arg1,arg2)=>func(functionToCall,arg1,arg2);break;case 3:wrap=(arg1,arg2,arg3)=>func(functionToCall,arg1,arg2,arg3);break;case 4:wrap=(arg1,arg2,arg3,arg4)=>func(functionToCall,arg1,arg2,arg3,arg4);break;case 5:wrap=(arg1,arg2,arg3,arg4,arg5)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5);break;case 6:wrap=(arg1,arg2,arg3,arg4,arg5,arg6)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6);break;case 7:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7);break;case 8:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);break;case 9:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);break;default:{wrap=(...args2)=>func(functionToCall,...args2);break}}return wrap.native=functionToCall,wrap.ptr=functionToCall.ptr,wrap}const native={dlopen:nativeDLOpen,callback:()=>{throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\")}};function dlopen(path,options){const result=nativeDLOpen(path,options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,path.includes(\"/\")\?`${key} (${path.split(\"/\").pop()})`:`${key} (${path})`);else result.symbols[key].native=result.symbols[key]}return result}function linkSymbols(options){const result=nativeLinkSymbols(options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,key);else result.symbols[key].native=result.symbols[key]}return result}var cFunctionI=0,cFunctionRegistry;function onCloseCFunction(close){close()}function CFunction(options){const identifier=`CFunction${cFunctionI++}`;var result=linkSymbols({[identifier]:options}),hasClosed=!1,close=result.close;return result.symbols[identifier].close=()=>{if(hasClosed||!close)return;hasClosed=!0,close(),close=void 0},cFunctionRegistry||=new FinalizationRegistry(onCloseCFunction),cFunctionRegistry.register(result.symbols[identifier],result.symbols[identifier].close),result.symbols[identifier]}const read=ffi.read;return{CFunction,CString,FFIType,JSCallback,dlopen,linkSymbols,native,ptr,read,suffix:\".dll\",toArrayBuffer,toBuffer,viewSource}})\n"_s; + // +static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";const FFIType={\"0\":0,\"1\":1,\"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\"7\":7,\"8\":8,\"9\":9,\"10\":10,\"11\":11,\"12\":12,\"13\":13,\"14\":14,\"15\":15,\"16\":16,\"17\":17,bool:11,c_int:5,c_uint:6,char:0,\"char*\":12,double:9,f32:10,f64:9,float:10,i16:3,i32:5,i64:7,i8:1,int:5,int16_t:3,int32_t:5,int64_t:7,int8_t:1,isize:7,u16:4,u32:6,u64:8,u8:2,uint16_t:4,uint32_t:6,uint64_t:8,uint8_t:2,usize:8,\"void*\":12,ptr:12,pointer:12,void:13,cstring:14,i64_fast:15,u64_fast:16,function:17,callback:17,fn:17};var ffi=globalThis.Bun.FFI;const ptr=(arg1,arg2)=>typeof arg2===\"undefined\"\?ffi.ptr(arg1):ffi.ptr(arg1,arg2),toBuffer=ffi.toBuffer,toArrayBuffer=ffi.toArrayBuffer,viewSource=ffi.viewSource,BunCString=ffi.CString,nativeLinkSymbols=ffi.linkSymbols,nativeDLOpen=ffi.dlopen,nativeCallback=ffi.callback,closeCallback=ffi.closeCallback;delete ffi.callback,delete ffi.closeCallback;class JSCallback{constructor(cb,options){const{ctx,ptr:ptr2}=nativeCallback(options,cb);this.#ctx=ctx,this.ptr=ptr2,this.#threadsafe=!!options\?.threadsafe}ptr;#ctx;#threadsafe;get threadsafe(){return this.#threadsafe}[Symbol.toPrimitive](){const{ptr:ptr2}=this;return typeof ptr2===\"number\"\?ptr2:0}close(){const ctx=this.#ctx;if(this.ptr=null,this.#ctx=null,ctx)closeCallback(ctx)}}class CString extends String{constructor(ptr2,byteOffset,byteLength){super(ptr2\?typeof byteLength===\"number\"&&Number.isSafeInteger(byteLength)\?new BunCString(ptr2,byteOffset||0,byteLength):new BunCString(ptr2):\"\");if(this.ptr=typeof ptr2===\"number\"\?ptr2:0,typeof byteOffset!==\"undefined\")this.byteOffset=byteOffset;if(typeof byteLength!==\"undefined\")this.byteLength=byteLength}ptr;byteOffset;byteLength;#cachedArrayBuffer;get arrayBuffer(){if(this.#cachedArrayBuffer)return this.#cachedArrayBuffer;if(!this.ptr)return this.#cachedArrayBuffer=new ArrayBuffer(0);return this.#cachedArrayBuffer=toArrayBuffer(this.ptr,this.byteOffset,this.byteLength)}}Object.defineProperty(globalThis,\"__GlobalBunCString\",{value:CString,enumerable:!1,configurable:!1});const ffiWrappers=new Array(18);var char=\"val|0\";ffiWrappers.fill(char),ffiWrappers[FFIType.uint8_t]=\"val<0\?0:val>=255\?255:val|0\",ffiWrappers[FFIType.int16_t]=\"val<=-32768\?-32768:val>=32768\?32768:val|0\",ffiWrappers[FFIType.uint16_t]=\"val<=0\?0:val>=65536\?65536:val|0\",ffiWrappers[FFIType.int32_t]=\"val|0\",ffiWrappers[FFIType.uint32_t]=\"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\",ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.int64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.uint64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`,ffiWrappers[FFIType.uint16_t]=`{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`,ffiWrappers[FFIType.double]=`{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`,ffiWrappers[FFIType.float]=ffiWrappers[10]=`{\n return Math.fround(val);\n}`,ffiWrappers[FFIType.bool]=`{\n return !!val;\n}`,Object.defineProperty(globalThis,\"__GlobalBunFFIPtrFunctionForWrapper\",{value:ptr,enumerable:!1,configurable:!0}),ffiWrappers[FFIType.cstring]=ffiWrappers[FFIType.pointer]=`{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`,ffiWrappers[FFIType.function]=`{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;function FFIBuilder(params,returnType,functionToCall,name){const hasReturnType=typeof FFIType[returnType]===\"number\"&&FFIType[returnType]!==FFIType.void;var paramNames=new Array(params.length),args=new Array(params.length);for(let i=0;i${wrapper})(p${i})`;else @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`)}var code=`functionToCall(${args.join(\", \")})`;if(hasReturnType)if(FFIType[returnType]===FFIType.cstring)code=`return new __GlobalBunCString(${code})`;else code=`return ${code}`;var func=new Function(\"functionToCall\",...paramNames,code);Object.defineProperty(func,\"name\",{value:name});var wrap;switch(paramNames.length){case 0:wrap=()=>func(functionToCall);break;case 1:wrap=(arg1)=>func(functionToCall,arg1);break;case 2:wrap=(arg1,arg2)=>func(functionToCall,arg1,arg2);break;case 3:wrap=(arg1,arg2,arg3)=>func(functionToCall,arg1,arg2,arg3);break;case 4:wrap=(arg1,arg2,arg3,arg4)=>func(functionToCall,arg1,arg2,arg3,arg4);break;case 5:wrap=(arg1,arg2,arg3,arg4,arg5)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5);break;case 6:wrap=(arg1,arg2,arg3,arg4,arg5,arg6)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6);break;case 7:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7);break;case 8:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);break;case 9:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);break;default:{wrap=(...args2)=>func(functionToCall,...args2);break}}return wrap.native=functionToCall,wrap.ptr=functionToCall.ptr,wrap}const native={dlopen:nativeDLOpen,callback:()=>{throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\")}};function dlopen(path,options){const result=nativeDLOpen(path,options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,path.includes(\"/\")\?`${key} (${path.split(\"/\").pop()})`:`${key} (${path})`);else result.symbols[key].native=result.symbols[key]}return result}function linkSymbols(options){const result=nativeLinkSymbols(options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,key);else result.symbols[key].native=result.symbols[key]}return result}var cFunctionI=0,cFunctionRegistry;function onCloseCFunction(close){close()}function CFunction(options){const identifier=`CFunction${cFunctionI++}`;var result=linkSymbols({[identifier]:options}),hasClosed=!1,close=result.close;return result.symbols[identifier].close=()=>{if(hasClosed||!close)return;hasClosed=!0,close(),close=void 0},cFunctionRegistry||=new FinalizationRegistry(onCloseCFunction),cFunctionRegistry.register(result.symbols[identifier],result.symbols[identifier].close),result.symbols[identifier]}const read=ffi.read;return{CFunction,CString,FFIType,JSCallback,dlopen,linkSymbols,native,ptr,read,suffix:\".dll\",toArrayBuffer,toBuffer,viewSource}})\n"_s; +// + +// static constexpr ASCIILiteral BunSqliteCode = "(function (){\"use strict\";var defineProperties=Object.defineProperties,toStringTag=Symbol.toStringTag,isArray=Array.isArray,isTypedArray=ArrayBuffer.isView;const constants={SQLITE_OPEN_READONLY:1,SQLITE_OPEN_READWRITE:2,SQLITE_OPEN_CREATE:4,SQLITE_OPEN_DELETEONCLOSE:8,SQLITE_OPEN_EXCLUSIVE:16,SQLITE_OPEN_AUTOPROXY:32,SQLITE_OPEN_URI:64,SQLITE_OPEN_MEMORY:128,SQLITE_OPEN_MAIN_DB:256,SQLITE_OPEN_TEMP_DB:512,SQLITE_OPEN_TRANSIENT_DB:1024,SQLITE_OPEN_MAIN_JOURNAL:2048,SQLITE_OPEN_TEMP_JOURNAL:4096,SQLITE_OPEN_SUBJOURNAL:8192,SQLITE_OPEN_SUPER_JOURNAL:16384,SQLITE_OPEN_NOMUTEX:32768,SQLITE_OPEN_FULLMUTEX:65536,SQLITE_OPEN_SHAREDCACHE:131072,SQLITE_OPEN_PRIVATECACHE:262144,SQLITE_OPEN_WAL:524288,SQLITE_OPEN_NOFOLLOW:16777216,SQLITE_OPEN_EXRESCODE:33554432,SQLITE_PREPARE_PERSISTENT:1,SQLITE_PREPARE_NORMALIZE:2,SQLITE_PREPARE_NO_VTAB:4};var SQL,controllers;class Statement{constructor(raw){switch(this.#raw=raw,raw.paramsCount){case 0:{this.get=this.#getNoArgs,this.all=this.#allNoArgs,this.values=this.#valuesNoArgs,this.run=this.#runNoArgs;break}default:{this.get=this.#get,this.all=this.#all,this.values=this.#values,this.run=this.#run;break}}}#raw;get;all;values;run;isFinalized=!1;toJSON(){return{sql:this.native.toString(),isFinalized:this.isFinalized,paramsCount:this.paramsCount,columnNames:this.columnNames}}get[toStringTag](){return`\"${this.native.toString()}\"`}toString(){return this.native.toString()}get native(){return this.#raw}#getNoArgs(){return this.#raw.get()}#allNoArgs(){return this.#raw.all()}#valuesNoArgs(){return this.#raw.values()}#runNoArgs(){this.#raw.run()}#get(...args){if(args.length===0)return this.#getNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.get(args):this.#raw.get(...args)}#all(...args){if(args.length===0)return this.#allNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.all(args):this.#raw.all(...args)}#values(...args){if(args.length===0)return this.#valuesNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.values(args):this.#raw.values(...args)}#run(...args){if(args.length===0)return this.#runNoArgs();var arg0=args[0];!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.run(args):this.#raw.run(...args)}get columnNames(){return this.#raw.columns}get paramsCount(){return this.#raw.paramsCount}finalize(...args){return this.isFinalized=!0,this.#raw.finalize(...args)}}var cachedCount=Symbol.for(\"Bun.Database.cache.count\");class Database{constructor(filenameGiven,options){if(typeof filenameGiven===\"undefined\");else if(typeof filenameGiven!==\"string\"){if(isTypedArray(filenameGiven)){this.#handle=Database.deserialize(filenameGiven,typeof options===\"object\"&&options\?!!options.readonly:((options|0)&constants.SQLITE_OPEN_READONLY)!=0),this.filename=\":memory:\";return}@throwTypeError(`Expected 'filename' to be a string, got '${typeof filenameGiven}'`)}var filename=typeof filenameGiven===\"string\"\?filenameGiven.trim():\":memory:\",flags=constants.SQLITE_OPEN_READWRITE|constants.SQLITE_OPEN_CREATE;if(typeof options===\"object\"&&options){if(flags=0,options.readonly)flags=constants.SQLITE_OPEN_READONLY;if(\"readOnly\"in options)@throwTypeError('Misspelled option \"readOnly\" should be \"readonly\"');if(options.create)flags=constants.SQLITE_OPEN_READWRITE|constants.SQLITE_OPEN_CREATE;if(options.readwrite)flags|=constants.SQLITE_OPEN_READWRITE}else if(typeof options===\"number\")flags=options;const anonymous=filename===\"\"||filename===\":memory:\";if(anonymous&&(flags&constants.SQLITE_OPEN_READONLY)!==0)throw new Error(\"Cannot open an anonymous database in read-only mode.\");if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");this.#handle=SQL.open(anonymous\?\":memory:\":filename,flags),this.filename=filename}#handle;#cachedQueriesKeys=[];#cachedQueriesLengths=[];#cachedQueriesValues=[];filename;get handle(){return this.#handle}get inTransaction(){return SQL.isInTransaction(this.#handle)}static open(filename,options){return new Database(filename,options)}loadExtension(name,entryPoint){return SQL.loadExtension(this.#handle,name,entryPoint)}serialize(optionalName){return SQL.serialize(this.#handle,optionalName||\"main\")}static deserialize(serialized,isReadOnly=!1){if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");return SQL.deserialize(serialized,isReadOnly)}static setCustomSQLite(path){if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");return SQL.setCustomSQLite(path)}close(){return this.clearQueryCache(),SQL.close(this.#handle)}clearQueryCache(){for(let item of this.#cachedQueriesValues)item.finalize();this.#cachedQueriesKeys.length=0,this.#cachedQueriesValues.length=0,this.#cachedQueriesLengths.length=0}run(query,...params){if(params.length===0){SQL.run(this.#handle,query);return}var arg0=params[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?SQL.run(this.#handle,query,params):SQL.run(this.#handle,query,...params)}prepare(query,params,flags){return new Statement(SQL.prepare(this.#handle,query,params,flags||0))}static MAX_QUERY_CACHE_SIZE=20;get[cachedCount](){return this.#cachedQueriesKeys.length}query(query){if(typeof query!==\"string\")@throwTypeError(`Expected 'query' to be a string, got '${typeof query}'`);if(query.length===0)throw new Error(\"SQL query cannot be empty.\");var index=this.#cachedQueriesLengths.indexOf(query.length);while(index!==-1){if(this.#cachedQueriesKeys[index]!==query){index=this.#cachedQueriesLengths.indexOf(query.length,index+1);continue}var stmt=this.#cachedQueriesValues[index];if(stmt.isFinalized)return this.#cachedQueriesValues[index]=this.prepare(query,void 0,willCache\?constants.SQLITE_PREPARE_PERSISTENT:0);return stmt}const willCache=this.#cachedQueriesKeys.length{let controller=(controllers||=new WeakMap).get(db);if(!controller){const shared={commit:db.prepare(\"COMMIT\",void 0,0),rollback:db.prepare(\"ROLLBACK\",void 0,0),savepoint:db.prepare(\"SAVEPOINT `\\t_bs3.\\t`\",void 0,0),release:db.prepare(\"RELEASE `\\t_bs3.\\t`\",void 0,0),rollbackTo:db.prepare(\"ROLLBACK TO `\\t_bs3.\\t`\",void 0,0)};controllers.set(db,controller={default:Object.assign({begin:db.prepare(\"BEGIN\",void 0,0)},shared),deferred:Object.assign({begin:db.prepare(\"BEGIN DEFERRED\",void 0,0)},shared),immediate:Object.assign({begin:db.prepare(\"BEGIN IMMEDIATE\",void 0,0)},shared),exclusive:Object.assign({begin:db.prepare(\"BEGIN EXCLUSIVE\",void 0,0)},shared)})}return controller},wrapTransaction=(fn,db,{begin,commit,rollback,savepoint,release,rollbackTo})=>function transaction(...args){let before,after,undo;if(db.inTransaction)before=savepoint,after=release,undo=rollbackTo;else before=begin,after=commit,undo=rollback;try{before.run();const result=fn.apply(this,args);return after.run(),result}catch(ex){if(db.inTransaction){if(undo.run(),undo!==rollback)after.run()}throw ex}};return{__esModule:!0,Database,Statement,constants,default:Database}})\n"_s; +// + +// static constexpr ASCIILiteral InternalSharedCode = "(function (){\"use strict\";class NotImplementedError extends Error{code;constructor(feature,issue){super(feature+\" is not yet implemented in Bun.\"+(issue\?\" Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/\"+issue:\"\"));this.name=\"NotImplementedError\",this.code=\"ERR_NOT_IMPLEMENTED\",hideFromStack(NotImplementedError)}}function throwNotImplemented(feature,issue){throw hideFromStack(throwNotImplemented),new NotImplementedError(feature,issue)}function hideFromStack(...fns){for(let fn of fns)Object.defineProperty(fn,\"name\",{value:\"::bunternal::\"})}return{NotImplementedError,throwNotImplemented,hideFromStack}})\n"_s; +// + +// static constexpr ASCIILiteral NodeAssertCode = "(function (){\"use strict\";const util=@getInternalField(@internalModuleRegistry,42)||@createInternalModuleById(42);var isDeepEqual=Bun.deepEquals,__commonJS=(cb,mod)=>function(){return mod||(0,cb[Object.keys(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_errors=__commonJS({\"assert/build/internal/errors.js\"(exports,module2){function _typeof(obj){return typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"\?_typeof=function(obj2){return typeof obj2}:_typeof=function(obj2){return obj2&&typeof Symbol==\"function\"&&obj2.constructor===Symbol&&obj2!==Symbol.prototype\?\"symbol\":typeof obj2},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))@throwTypeError(\"Cannot call a class as a function\")}function _possibleConstructorReturn(self,call){return call&&(_typeof(call)===\"object\"||typeof call==\"function\")\?call:_assertThisInitialized(self)}function _assertThisInitialized(self){if(self===void 0)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return self}function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf\?Object.getPrototypeOf:function(o2){return o2.__proto__||Object.getPrototypeOf(o2)},_getPrototypeOf(o)}function _inherits(subClass,superClass){if(typeof superClass!=\"function\"&&superClass!==null)@throwTypeError(\"Super expression must either be null or a function\");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),superClass&&_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){return _setPrototypeOf=Object.setPrototypeOf||function(o2,p2){return o2.__proto__=p2,o2},_setPrototypeOf(o,p)}var codes={},assert,util2;function createErrorType(code,message,Base){Base||(Base=Error);function getMessage(arg1,arg2,arg3){return typeof message==\"string\"\?message:message(arg1,arg2,arg3)}var NodeError=function(_Base){_inherits(NodeError2,_Base);function NodeError2(arg1,arg2,arg3){var _this;return _classCallCheck(this,NodeError2),_this=_possibleConstructorReturn(this,_getPrototypeOf(NodeError2).call(this,getMessage(arg1,arg2,arg3))),_this.code=code,_this}return NodeError2}(Base);codes[code]=NodeError}function oneOf(expected,thing){if(Array.isArray(expected)){var len=expected.length;return expected=expected.map(function(i){return String(i)}),len>2\?\"one of \".concat(thing,\" \").concat(expected.slice(0,len-1).join(\", \"),\", or \")+expected[len-1]:len===2\?\"one of \".concat(thing,\" \").concat(expected[0],\" or \").concat(expected[1]):\"of \".concat(thing,\" \").concat(expected[0])}else return\"of \".concat(thing,\" \").concat(String(expected))}function startsWith(str,search,pos){return str.substr(!pos||pos<0\?0:+pos,search.length)===search}function endsWith(str,search,this_len){return(this_len===void 0||this_len>str.length)&&(this_len=str.length),str.substring(this_len-search.length,this_len)===search}function includes(str,search,start){return typeof start!=\"number\"&&(start=0),start+search.length>str.length\?!1:str.indexOf(search,start)!==-1}createErrorType(\"ERR_AMBIGUOUS_ARGUMENT\",'The \"%s\" argument is ambiguous. %s',TypeError),createErrorType(\"ERR_INVALID_ARG_TYPE\",function(name,expected,actual){assert===void 0&&(assert=require_assert()),assert(typeof name==\"string\",\"'name' must be a string\");var determiner;typeof expected==\"string\"&&startsWith(expected,\"not \")\?(determiner=\"must not be\",expected=expected.replace(/^not /,\"\")):determiner=\"must be\";var msg;if(endsWith(name,\" argument\"))msg=\"The \".concat(name,\" \").concat(determiner,\" \").concat(oneOf(expected,\"type\"));else{var type=includes(name,\".\")\?\"property\":\"argument\";msg='The \"'.concat(name,'\" ').concat(type,\" \").concat(determiner,\" \").concat(oneOf(expected,\"type\"))}return msg+=\". Received type \".concat(_typeof(actual)),msg},TypeError),createErrorType(\"ERR_INVALID_ARG_VALUE\",function(name,value){var reason=arguments.length>2&&arguments[2]!==void 0\?arguments[2]:\"is invalid\",inspected=util2.inspect(value);return inspected.length>128&&(inspected=\"\".concat(inspected.slice(0,128),\"...\")),\"The argument '\".concat(name,\"' \").concat(reason,\". Received \").concat(inspected)},TypeError,RangeError),createErrorType(\"ERR_INVALID_RETURN_VALUE\",function(input,name,value){var type;return value&&value.constructor&&value.constructor.name\?type=\"instance of \".concat(value.constructor.name):type=\"type \".concat(_typeof(value)),\"Expected \".concat(input,' to be returned from the \"').concat(name,'\"')+\" function but got \".concat(type,\".\")},TypeError),createErrorType(\"ERR_MISSING_ARGS\",function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];assert===void 0&&(assert=require_assert()),assert(args.length>0,\"At least one arg needs to be specified\");var msg=\"The \",len=args.length;switch(args=args.map(function(a){return'\"'.concat(a,'\"')}),len){case 1:msg+=\"\".concat(args[0],\" argument\");break;case 2:msg+=\"\".concat(args[0],\" and \").concat(args[1],\" arguments\");break;default:msg+=args.slice(0,len-1).join(\", \"),msg+=\", and \".concat(args[len-1],\" arguments\");break}return\"\".concat(msg,\" must be specified\")},TypeError),module2.exports.codes=codes}}),require_assertion_error=__commonJS({\"assert/build/internal/assert/assertion_error.js\"(exports,module2){function _objectSpread(target){for(var i=1;istr.length)&&(this_len=str.length),str.substring(this_len-search.length,this_len)===search}function repeat(str,count){if(count=Math.floor(count),str.length==0||count==0)return\"\";var maxCount=str.length*count;for(count=Math.floor(Math.log(count)/Math.log(2));count;)str+=str,count--;return str+=str.substring(0,maxCount-str.length),str}var blue=\"\",green=\"\",red=\"\",white=\"\",kReadableOperator={deepStrictEqual:\"Expected values to be strictly deep-equal:\",strictEqual:\"Expected values to be strictly equal:\",strictEqualObject:'Expected \"actual\" to be reference-equal to \"expected\":',deepEqual:\"Expected values to be loosely deep-equal:\",equal:\"Expected values to be loosely equal:\",notDeepStrictEqual:'Expected \"actual\" not to be strictly deep-equal to:',notStrictEqual:'Expected \"actual\" to be strictly unequal to:',notStrictEqualObject:'Expected \"actual\" not to be reference-equal to \"expected\":',notDeepEqual:'Expected \"actual\" not to be loosely deep-equal to:',notEqual:'Expected \"actual\" to be loosely unequal to:',notIdentical:\"Values identical but not reference-equal:\"},kMaxShortLength=10;function copyError(source){var keys=Object.keys(source),target=Object.create(Object.getPrototypeOf(source));return keys.forEach(function(key){target[key]=source[key]}),Object.defineProperty(target,\"message\",{value:source.message}),target}function inspectValue(val){return inspect(val,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function createErrDiff(actual,expected,operator){var other=\"\",res=\"\",lastPos=0,end=\"\",skipped=!1,actualInspected=inspectValue(actual),actualLines=actualInspected.split(`\n`),expectedLines=inspectValue(expected).split(`\n`),i=0,indicator=\"\";if(operator===\"strictEqual\"&&_typeof(actual)===\"object\"&&_typeof(expected)===\"object\"&&actual!==null&&expected!==null&&(operator=\"strictEqualObject\"),actualLines.length===1&&expectedLines.length===1&&actualLines[0]!==expectedLines[0]){var inputLength=actualLines[0].length+expectedLines[0].length;if(inputLength<=kMaxShortLength){if((_typeof(actual)!==\"object\"||actual===null)&&(_typeof(expected)!==\"object\"||expected===null)&&(actual!==0||expected!==0))return\"\".concat(kReadableOperator[operator],`\n\n`)+\"\".concat(actualLines[0],\" !== \").concat(expectedLines[0],`\n`)}else if(operator!==\"strictEqualObject\"){var maxLength=process.stderr&&process.stderr.isTTY\?process.stderr.columns:80;if(inputLength2&&(indicator=`\n `.concat(repeat(\" \",i),\"^\"),i=0)}}}for(var a=actualLines[actualLines.length-1],b=expectedLines[expectedLines.length-1];a===b&&(i++<2\?end=`\n `.concat(a).concat(end):other=a,actualLines.pop(),expectedLines.pop(),!(actualLines.length===0||expectedLines.length===0));)a=actualLines[actualLines.length-1],b=expectedLines[expectedLines.length-1];var maxLines=Math.max(actualLines.length,expectedLines.length);if(maxLines===0){var _actualLines=actualInspected.split(`\n`);if(_actualLines.length>30)for(_actualLines[26]=\"\".concat(blue,\"...\").concat(white);_actualLines.length>27;)_actualLines.pop();return\"\".concat(kReadableOperator.notIdentical,`\n\n`).concat(_actualLines.join(`\n`),`\n`)}i>3&&(end=`\n`.concat(blue,\"...\").concat(white).concat(end),skipped=!0),other!==\"\"&&(end=`\n `.concat(other).concat(end),other=\"\");var printedLines=0,msg=kReadableOperator[operator]+`\n`.concat(green,\"+ actual\").concat(white,\" \").concat(red,\"- expected\").concat(white),skippedMsg=\" \".concat(blue,\"...\").concat(white,\" Lines skipped\");for(i=0;i1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(expectedLines[i-2]),printedLines++),res+=`\n `.concat(expectedLines[i-1]),printedLines++),lastPos=i,other+=`\n`.concat(red,\"-\").concat(white,\" \").concat(expectedLines[i]),printedLines++;else if(expectedLines.length1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(actualLines[i-2]),printedLines++),res+=`\n `.concat(actualLines[i-1]),printedLines++),lastPos=i,res+=`\n`.concat(green,\"+\").concat(white,\" \").concat(actualLines[i]),printedLines++;else{var expectedLine=expectedLines[i],actualLine=actualLines[i],divergingLines=actualLine!==expectedLine&&(!endsWith(actualLine,\",\")||actualLine.slice(0,-1)!==expectedLine);divergingLines&&endsWith(expectedLine,\",\")&&expectedLine.slice(0,-1)===actualLine&&(divergingLines=!1,actualLine+=\",\"),divergingLines\?(cur>1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(actualLines[i-2]),printedLines++),res+=`\n `.concat(actualLines[i-1]),printedLines++),lastPos=i,res+=`\n`.concat(green,\"+\").concat(white,\" \").concat(actualLine),other+=`\n`.concat(red,\"-\").concat(white,\" \").concat(expectedLine),printedLines+=2):(res+=other,other=\"\",(cur===1||i===0)&&(res+=`\n `.concat(actualLine),printedLines++))}if(printedLines>20&&i30)for(res[26]=\"\".concat(blue,\"...\").concat(white);res.length>27;)res.pop();res.length===1\?_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(base,\" \").concat(res[0]))):_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(base,`\n\n`).concat(res.join(`\n`),`\n`)))}else{var _res=inspectValue(actual),other=\"\",knownOperators=kReadableOperator[operator];operator===\"notDeepEqual\"||operator===\"notEqual\"\?(_res=\"\".concat(kReadableOperator[operator],`\n\n`).concat(_res),_res.length>1024&&(_res=\"\".concat(_res.slice(0,1021),\"...\"))):(other=\"\".concat(inspectValue(expected)),_res.length>512&&(_res=\"\".concat(_res.slice(0,509),\"...\")),other.length>512&&(other=\"\".concat(other.slice(0,509),\"...\")),operator===\"deepEqual\"||operator===\"equal\"\?_res=\"\".concat(knownOperators,`\n\n`).concat(_res,`\n\nshould equal\n\n`):other=\" \".concat(operator,\" \").concat(other)),_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(_res).concat(other)))}return Error.stackTraceLimit=limit,_this.generatedMessage=!message,Object.defineProperty(_assertThisInitialized(_this),\"name\",{value:\"AssertionError [ERR_ASSERTION]\",enumerable:!1,writable:!0,configurable:!0}),_this.code=\"ERR_ASSERTION\",_this.actual=actual,_this.expected=expected,_this.operator=operator,Error.captureStackTrace&&Error.captureStackTrace(_assertThisInitialized(_this),stackStartFn),_this.stack,_this.name=\"AssertionError\",_possibleConstructorReturn(_this)}return AssertionError2.prototype={},_inherits(AssertionError2,_Error),_createClass(AssertionError2,[{key:\"toString\",value:function(){return\"\".concat(this.name,\" [\").concat(this.code,\"]: \").concat(this.message)}},{key:inspect.custom,value:function(recurseTimes,ctx){return inspect(this,_objectSpread({},ctx,{customInspect:!1,depth:0}))}}]),AssertionError2}(_wrapNativeSuper(Error));module2.exports=AssertionError}}),require_assert=__commonJS({\"assert/build/assert.js\"(exports,module2){function _typeof(obj){return typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"\?_typeof=function(obj2){return typeof obj2}:_typeof=function(obj2){return obj2&&typeof Symbol==\"function\"&&obj2.constructor===Symbol&&obj2!==Symbol.prototype\?\"symbol\":typeof obj2},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))@throwTypeError(\"Cannot call a class as a function\")}var _require=require_errors(),_require$codes=_require.codes,ERR_AMBIGUOUS_ARGUMENT=_require$codes.ERR_AMBIGUOUS_ARGUMENT,ERR_INVALID_ARG_TYPE=_require$codes.ERR_INVALID_ARG_TYPE,ERR_INVALID_ARG_VALUE=_require$codes.ERR_INVALID_ARG_VALUE,ERR_INVALID_RETURN_VALUE=_require$codes.ERR_INVALID_RETURN_VALUE,ERR_MISSING_ARGS=_require$codes.ERR_MISSING_ARGS,AssertionError=require_assertion_error(),_require2=util,inspect=_require2.inspect,_require$types=util.types,isPromise=_require$types.isPromise,isRegExp=_require$types.isRegExp,objectAssign=Object.assign,objectIs=Object.is,errorCache=new Map,warned=!1,assert=module2.exports=ok,NO_EXCEPTION_SENTINEL={};function innerFail(obj){throw obj.message instanceof Error\?obj.message:new AssertionError(obj)}function fail(actual,expected,message,operator,stackStartFn){var argsLen=arguments.length,internalMessage;if(argsLen===0)internalMessage=\"Failed\";else if(argsLen===1)message=actual,actual=void 0;else{if(warned===!1){warned=!0;var warn=process.emitWarning\?process.emitWarning:console.warn.bind(console);warn(\"assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.\",\"DeprecationWarning\",\"DEP0094\")}argsLen===2&&(operator=\"!=\")}if(message instanceof Error)throw message;var errArgs={actual,expected,operator:operator===void 0\?\"fail\":operator,stackStartFn:stackStartFn||fail};message!==void 0&&(errArgs.message=message);var err=new AssertionError(errArgs);throw internalMessage&&(err.message=internalMessage,err.generatedMessage=!0),err}assert.fail=fail,assert.AssertionError=AssertionError;function innerOk(fn,argLen,value,message){if(!value){var generatedMessage=!1;if(argLen===0)generatedMessage=!0,message=\"No value argument passed to `assert.ok()`\";else if(message instanceof Error)throw message;var err=new AssertionError({actual:value,expected:!0,message,operator:\"==\",stackStartFn:fn});throw err.generatedMessage=generatedMessage,err}}function ok(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];innerOk.apply(void 0,[ok,args.length].concat(args))}assert.ok=ok,assert.equal=function equal(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");actual!=expected&&innerFail({actual,expected,message,operator:\"==\",stackStartFn:equal})},assert.notEqual=function notEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");actual==expected&&innerFail({actual,expected,message,operator:\"!=\",stackStartFn:notEqual})},assert.deepEqual=function deepEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!1)||innerFail({actual,expected,message,operator:\"deepEqual\",stackStartFn:deepEqual})},assert.notDeepEqual=function notDeepEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!1)&&innerFail({actual,expected,message,operator:\"notDeepEqual\",stackStartFn:notDeepEqual})},assert.deepStrictEqual=function deepStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!0)||innerFail({actual,expected,message,operator:\"deepStrictEqual\",stackStartFn:deepStrictEqual})},assert.notDeepStrictEqual=notDeepStrictEqual;function notDeepStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!0)&&innerFail({actual,expected,message,operator:\"notDeepStrictEqual\",stackStartFn:notDeepStrictEqual})}assert.strictEqual=function strictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");objectIs(actual,expected)||innerFail({actual,expected,message,operator:\"strictEqual\",stackStartFn:strictEqual})},assert.notStrictEqual=function notStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");objectIs(actual,expected)&&innerFail({actual,expected,message,operator:\"notStrictEqual\",stackStartFn:notStrictEqual})},assert.match=function match(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");if(!isRegExp(expected))throw new ERR_INVALID_ARG_TYPE(\"expected\",\"RegExp\",expected);expected.test(actual)||innerFail({actual,expected,message,operator:\"match\",stackStartFn:match})};var Comparison=function Comparison2(obj,keys,actual){var _this=this;_classCallCheck(this,Comparison2),keys.forEach(function(key){(key in obj)&&(actual!==void 0&&typeof actual[key]==\"string\"&&isRegExp(obj[key])&&obj[key].test(actual[key])\?_this[key]=actual[key]:_this[key]=obj[key])})};function compareExceptionKey(actual,expected,key,message,keys,fn){if(!(key in actual)||!isDeepEqual(actual[key],expected[key],!0)){if(!message){var a=new Comparison(actual,keys),b=new Comparison(expected,keys,actual),err=new AssertionError({actual:a,expected:b,operator:\"deepStrictEqual\",stackStartFn:fn});throw err.actual=actual,err.expected=expected,err.operator=fn.name,err}innerFail({actual,expected,message,operator:fn.name,stackStartFn:fn})}}function expectedException(actual,expected,msg,fn){if(typeof expected!=\"function\"){if(isRegExp(expected))return expected.test(actual);if(arguments.length===2)throw new ERR_INVALID_ARG_TYPE(\"expected\",[\"Function\",\"RegExp\"],expected);if(_typeof(actual)!==\"object\"||actual===null){var err=new AssertionError({actual,expected,message:msg,operator:\"deepStrictEqual\",stackStartFn:fn});throw err.operator=fn.name,err}var keys=Object.keys(expected);if(expected instanceof Error)keys.push(\"name\",\"message\");else if(keys.length===0)throw new ERR_INVALID_ARG_VALUE(\"error\",expected,\"may not be an empty object\");return keys.forEach(function(key){return typeof actual[key]==\"string\"&&isRegExp(expected[key])&&expected[key].test(actual[key])||compareExceptionKey(actual,expected,key,msg,keys,fn)}),!0}return expected.prototype!==void 0&&actual instanceof expected\?!0:Error.isPrototypeOf(expected)\?!1:expected.call({},actual)===!0}function getActual(fn){if(typeof fn!=\"function\")throw new ERR_INVALID_ARG_TYPE(\"fn\",\"Function\",fn);try{fn()}catch(e){return e}return NO_EXCEPTION_SENTINEL}function checkIsPromise(obj){return isPromise(obj)||obj!==null&&_typeof(obj)===\"object\"&&typeof obj.then==\"function\"&&typeof obj.catch==\"function\"}function waitForActual(promiseFn){return Promise.resolve().then(function(){var resultPromise;if(typeof promiseFn==\"function\"){if(resultPromise=promiseFn(),!checkIsPromise(resultPromise))throw new ERR_INVALID_RETURN_VALUE(\"instance of Promise\",\"promiseFn\",resultPromise)}else if(checkIsPromise(promiseFn))resultPromise=promiseFn;else throw new ERR_INVALID_ARG_TYPE(\"promiseFn\",[\"Function\",\"Promise\"],promiseFn);return Promise.resolve().then(function(){return resultPromise}).then(function(){return NO_EXCEPTION_SENTINEL}).catch(function(e){return e})})}function expectsError(stackStartFn,actual,error,message){if(typeof error==\"string\"){if(arguments.length===4)throw new ERR_INVALID_ARG_TYPE(\"error\",[\"Object\",\"Error\",\"Function\",\"RegExp\"],error);if(_typeof(actual)===\"object\"&&actual!==null){if(actual.message===error)throw new ERR_AMBIGUOUS_ARGUMENT(\"error/message\",'The error message \"'.concat(actual.message,'\" is identical to the message.'))}else if(actual===error)throw new ERR_AMBIGUOUS_ARGUMENT(\"error/message\",'The error \"'.concat(actual,'\" is identical to the message.'));message=error,error=void 0}else if(error!=null&&_typeof(error)!==\"object\"&&typeof error!=\"function\")throw new ERR_INVALID_ARG_TYPE(\"error\",[\"Object\",\"Error\",\"Function\",\"RegExp\"],error);if(actual===NO_EXCEPTION_SENTINEL){var details=\"\";error&&error.name&&(details+=\" (\".concat(error.name,\")\")),details+=message\?\": \".concat(message):\".\";var fnType=stackStartFn.name===\"rejects\"\?\"rejection\":\"exception\";innerFail({actual:void 0,expected:error,operator:stackStartFn.name,message:\"Missing expected \".concat(fnType).concat(details),stackStartFn})}if(error&&!expectedException(actual,error,message,stackStartFn))throw actual}function expectsNoError(stackStartFn,actual,error,message){if(actual!==NO_EXCEPTION_SENTINEL){if(typeof error==\"string\"&&(message=error,error=void 0),!error||expectedException(actual,error)){var details=message\?\": \".concat(message):\".\",fnType=stackStartFn.name===\"doesNotReject\"\?\"rejection\":\"exception\";innerFail({actual,expected:error,operator:stackStartFn.name,message:\"Got unwanted \".concat(fnType).concat(details,`\n`)+'Actual message: \"'.concat(actual&&actual.message,'\"'),stackStartFn})}throw actual}}assert.throws=function throws(promiseFn){for(var _len2=arguments.length,args=new Array(_len2>1\?_len2-1:0),_key2=1;_key2<_len2;_key2++)args[_key2-1]=arguments[_key2];expectsError.apply(void 0,[throws,getActual(promiseFn)].concat(args))},assert.rejects=function rejects(promiseFn){for(var _len3=arguments.length,args=new Array(_len3>1\?_len3-1:0),_key3=1;_key3<_len3;_key3++)args[_key3-1]=arguments[_key3];return waitForActual(promiseFn).then(function(result){return expectsError.apply(void 0,[rejects,result].concat(args))})},assert.doesNotThrow=function doesNotThrow(fn){for(var _len4=arguments.length,args=new Array(_len4>1\?_len4-1:0),_key4=1;_key4<_len4;_key4++)args[_key4-1]=arguments[_key4];expectsNoError.apply(void 0,[doesNotThrow,getActual(fn)].concat(args))},assert.doesNotReject=function doesNotReject(fn){for(var _len5=arguments.length,args=new Array(_len5>1\?_len5-1:0),_key5=1;_key5<_len5;_key5++)args[_key5-1]=arguments[_key5];return waitForActual(fn).then(function(result){return expectsNoError.apply(void 0,[doesNotReject,result].concat(args))})},assert.ifError=function ifError(err){if(err!=null){var message=\"ifError got unwanted exception: \";_typeof(err)===\"object\"&&typeof err.message==\"string\"\?err.message.length===0&&err.constructor\?message+=err.constructor.name:message+=err.message:message+=inspect(err);var newErr=new AssertionError({actual:err,expected:null,operator:\"ifError\",message,stackStartFn:ifError}),origStack=err.stack;if(typeof origStack==\"string\"){var tmp2=origStack.split(`\n`);tmp2.shift();for(var tmp1=newErr.stack.split(`\n`),i=0;i{var prev=get();set(context);try{return fn(...args)}catch(error){throw error}finally{set(prev)}}}enterWith(store){cleanupLater();var context=get();if(!context){set([this,store]);return}var{length}=context;for(var i=0;i-1)hasPrevious=!0,previous=context[i+1],context[i+1]=store;else context.push(this,store);set(context)}try{return callback(...args)}catch(e){throw e}finally{if(!this.#disableCalled){var context2=get();if(context2===context&&contextWasInit)set(void 0);else if(context2=context2.slice(),hasPrevious)context2[i+1]=previous,set(context2);else context2.splice(i,2),set(context2.length\?context2:void 0)}}}disable(){if(!this.#disableCalled){var context=get();if(context){var{length}=context;for(var i=0;i-1){try{child.kill(killSignal)}catch(err){child.emit(\"error\",err)}timeoutHolder.timeoutId=-1}}function spawn(file,args,options){options=normalizeSpawnArguments(file,args,options),validateTimeout(options.timeout),validateAbortSignal(options.signal,\"options.signal\");const killSignal2=sanitizeKillSignal(options.killSignal),child=new ChildProcess;if(child.spawn(options),options.timeout>0){let timeoutId=setTimeout(()=>{if(timeoutId){try{child.kill(killSignal2)}catch(err){child.emit(\"error\",err)}timeoutId=null}});child.once(\"exit\",()=>{if(timeoutId)clearTimeout(timeoutId),timeoutId=null})}if(options.signal){let onAbortListener2=function(){abortChildProcess(child,killSignal2,options.signal.reason)};var onAbortListener=onAbortListener2;const signal=options.signal;if(signal.aborted)process.nextTick(onAbortListener2);else signal.addEventListener(\"abort\",onAbortListener2,{once:!0}),child.once(\"exit\",()=>signal.removeEventListener(\"abort\",onAbortListener2))}return child}function execFile(file,args,options,callback){({file,args,options,callback}=normalizeExecFileArgs(file,args,options,callback)),options={encoding:\"utf8\",timeout:0,maxBuffer:MAX_BUFFER,killSignal:\"SIGTERM\",cwd:null,env:null,shell:!1,...options};const maxBuffer=options.maxBuffer;validateTimeout(options.timeout),validateMaxBuffer(maxBuffer),options.killSignal=sanitizeKillSignal(options.killSignal);const child=spawn(file,args,{cwd:options.cwd,env:options.env,shell:options.shell,signal:options.signal});let encoding;const _stdout=[],_stderr=[];if(options.encoding!==\"buffer\"&&BufferIsEncoding(options.encoding))encoding=options.encoding;else encoding=null;let stdoutLen=0,stderrLen=0,killed=!1,exited=!1,timeoutId,encodedStdoutLen,encodedStderrLen,ex=null,cmd=file;function exitHandler(code,signal){if(exited)return;if(exited=!0,timeoutId)clearTimeout(timeoutId),timeoutId=null;if(!callback)return;const readableEncoding=child\?.stdout\?.readableEncoding;let stdout,stderr;if(encoding||child.stdout&&readableEncoding)stdout=ArrayPrototypeJoin.call(_stdout,\"\");else stdout=BufferConcat(_stdout);if(encoding||child.stderr&&readableEncoding)stderr=ArrayPrototypeJoin.call(_stderr,\"\");else stderr=BufferConcat(_stderr);if(!ex&&code===0&&signal===null){callback(null,stdout,stderr);return}if(args\?.length)cmd+=` ${ArrayPrototypeJoin.call(args,\" \")}`;if(!ex){let message=`Command failed: ${cmd}`;if(stderr)message+=`\\n${stderr}`;ex=genericNodeError(message,{code,killed:child.killed||killed,signal})}ex.cmd=cmd,callback(ex,stdout,stderr)}function errorHandler(e){if(ex=e,child.stdout)child.stdout.destroy();if(child.stderr)child.stderr.destroy();exitHandler()}function kill(){if(child.stdout)child.stdout.destroy();if(child.stderr)child.stderr.destroy();killed=!0;try{child.kill(options.killSignal)}catch(e){ex=e,exitHandler()}}if(options.timeout>0)timeoutId=setTimeout(function delayedKill(){kill(),timeoutId=null},options.timeout);if(child.stdout){if(encoding)child.stdout.setEncoding(encoding);child.stdout.on(\"data\",maxBuffer===Infinity\?function onUnlimitedSizeBufferedData(chunk){ArrayPrototypePush.call(_stdout,chunk)}:encoding\?function onChildStdoutEncoded(chunk){if(stdoutLen+=chunk.length,stdoutLen*4>maxBuffer){const encoding2=child.stdout.readableEncoding,actualLen=Buffer.byteLength(chunk,encoding2);if(encodedStdoutLen===void 0)for(let i=0;i<_stdout.length;i++)encodedStdoutLen+=Buffer.byteLength(_stdout[i],encoding2);else encodedStdoutLen+=actualLen;const truncatedLen=maxBuffer-(encodedStdoutLen-actualLen);ArrayPrototypePush.call(_stdout,StringPrototypeSlice.apply(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stdout\"),kill()}else ArrayPrototypePush.call(_stdout,chunk)}:function onChildStdoutRaw(chunk){if(stdoutLen+=chunk.length,stdoutLen>maxBuffer){const truncatedLen=maxBuffer-(stdoutLen-chunk.length);ArrayPrototypePush.call(_stdout,chunk.slice(0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stdout\"),kill()}else ArrayPrototypePush.call(_stdout,chunk)})}if(child.stderr){if(encoding)child.stderr.setEncoding(encoding);child.stderr.on(\"data\",maxBuffer===Infinity\?function onUnlimitedSizeBufferedData(chunk){ArrayPrototypePush.call(_stderr,chunk)}:encoding\?function onChildStderrEncoded(chunk){if(stderrLen+=chunk.length,stderrLen*4>maxBuffer){const encoding2=child.stderr.readableEncoding,actualLen=Buffer.byteLength(chunk,encoding2);if(encodedStderrLen===void 0)for(let i=0;i<_stderr.length;i++)encodedStderrLen+=Buffer.byteLength(_stderr[i],encoding2);else encodedStderrLen+=actualLen;const truncatedLen=maxBuffer-(encodedStderrLen-actualLen);ArrayPrototypePush.call(_stderr,StringPrototypeSlice.call(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stderr\"),kill()}else ArrayPrototypePush.call(_stderr,chunk)}:function onChildStderrRaw(chunk){if(stderrLen+=chunk.length,stderrLen>maxBuffer){const truncatedLen=maxBuffer-(stderrLen-chunk.length);ArrayPrototypePush.call(_stderr,StringPrototypeSlice.call(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stderr\"),kill()}else ArrayPrototypePush.call(_stderr,chunk)})}return child.addListener(\"close\",exitHandler),child.addListener(\"error\",errorHandler),child}function exec(command,options,callback){const opts=normalizeExecArgs(command,options,callback);return execFile(opts.file,opts.options,opts.callback)}const customPromiseExecFunction=(orig)=>{return(...args)=>{let resolve,reject;const promise=new Promise((res,rej)=>{resolve=res,reject=rej});return promise.child=orig(...args,(err,stdout,stderr)=>{if(err!==null)err.stdout=stdout,err.stderr=stderr,reject(err);else resolve({stdout,stderr})}),promise}};ObjectDefineProperty(exec,promisify.custom,{__proto__:null,enumerable:!1,value:customPromiseExecFunction(exec)});function spawnSync(file,args,options){options={maxBuffer:MAX_BUFFER,...normalizeSpawnArguments(file,args,options)};const{maxBuffer,encoding}=options;validateTimeout(options.timeout),validateMaxBuffer(maxBuffer),options.killSignal=sanitizeKillSignal(options.killSignal);const stdio=options.stdio||\"pipe\",bunStdio=getBunStdioFromOptions(stdio);var{input}=options;if(input)if(ArrayBufferIsView(input))bunStdio[0]=input;else if(typeof input===\"string\")bunStdio[0]=Buffer.from(input,encoding||\"utf8\");else throw new ERR_INVALID_ARG_TYPE(\"options.stdio[0]\",[\"Buffer\",\"TypedArray\",\"DataView\",\"string\"],input);const{stdout,stderr,success,exitCode}=Bun.spawnSync({cmd:options.args,env:options.env||void 0,cwd:options.cwd||void 0,stdin:bunStdio[0],stdout:bunStdio[1],stderr:bunStdio[2]}),result={signal:null,status:exitCode,output:[null,stdout,stderr]};if(stdout&&encoding&&encoding!==\"buffer\")result.output[1]=result.output[1]\?.toString(encoding);if(stderr&&encoding&&encoding!==\"buffer\")result.output[2]=result.output[2]\?.toString(encoding);if(result.stdout=result.output[1],result.stderr=result.output[2],!success)result.error=new SystemError(result.output[2],options.file,\"spawnSync\",-1,result.status),result.error.spawnargs=ArrayPrototypeSlice.call(options.args,1);return result}function execFileSync(file,args,options){({file,args,options}=normalizeExecFileArgs(file,args,options));const ret=spawnSync(file,args,options),errArgs=[options.argv0||file];ArrayPrototypePush.apply(errArgs,args);const err=checkExecSyncError(ret,errArgs);if(err)throw err;return ret.stdout}function execSync(command,options){const opts=normalizeExecArgs(command,options,null),ret=spawnSync(opts.file,opts.options),err=checkExecSyncError(ret,void 0,command);if(err)throw err;return ret.stdout}function stdioStringToArray(stdio,channel){const options=[];switch(stdio){case\"ignore\":case\"overlapped\":case\"pipe\":ArrayPrototypePush.call(options,stdio,stdio,stdio);break;case\"inherit\":ArrayPrototypePush.call(options,0,1,2);break;default:throw new ERR_INVALID_ARG_VALUE(\"stdio\",stdio)}if(channel)ArrayPrototypePush.call(options,channel);return options}function fork(modulePath,args=[],options){modulePath=getValidatedPath(modulePath,\"modulePath\");let execArgv;if(args==null)args=[];else if(typeof args===\"object\"&&!ArrayIsArray(args))options=args,args=[];else validateArray(args,\"args\");if(options!=null)validateObject(options,\"options\");if(options={__proto__:null,...options,shell:!1},options.execPath=options.execPath||process.execPath,validateArgumentNullCheck(options.execPath,\"options.execPath\"),execArgv=options.execArgv||process.execArgv,validateArgumentsNullCheck(execArgv,\"options.execArgv\"),execArgv===process.execArgv&&process._eval!=null){const index=ArrayPrototypeLastIndexOf.call(execArgv,process._eval);if(index>0)execArgv=ArrayPrototypeSlice.call(execArgv),ArrayPrototypeSplice.call(execArgv,index-1,2)}if(args=[...execArgv,modulePath,...args],typeof options.stdio===\"string\")options.stdio=stdioStringToArray(options.stdio,\"ipc\");else if(!ArrayIsArray(options.stdio))options.stdio=stdioStringToArray(options.silent\?\"pipe\":\"inherit\",\"ipc\");else if(!ArrayPrototypeIncludes.call(options.stdio,\"ipc\"))throw new ERR_CHILD_PROCESS_IPC_REQUIRED(\"options.stdio\");return spawn(options.execPath,args,options)}function convertToValidSignal(signal){if(typeof signal===\"number\"&&getSignalsToNamesMapping()[signal])return signal;if(typeof signal===\"string\"){const signalName=signals[StringPrototypeToUpperCase.call(signal)];if(signalName)return signalName}throw new ERR_UNKNOWN_SIGNAL(signal)}function sanitizeKillSignal(killSignal2){if(typeof killSignal2===\"string\"||typeof killSignal2===\"number\")return convertToValidSignal(killSignal2);else if(killSignal2!=null)throw new ERR_INVALID_ARG_TYPE(\"options.killSignal\",[\"string\",\"number\"],killSignal2)}let signalsToNamesMapping;function getSignalsToNamesMapping(){if(signalsToNamesMapping!==void 0)return signalsToNamesMapping;signalsToNamesMapping=ObjectCreate(null);for(let key in signals)signalsToNamesMapping[signals[key]]=key;return signalsToNamesMapping}function normalizeExecFileArgs(file,args,options,callback){if(ArrayIsArray(args))args=ArrayPrototypeSlice.call(args);else if(args!=null&&typeof args===\"object\")callback=options,options=args,args=null;else if(typeof args===\"function\")callback=args,options=null,args=null;if(args==null)args=[];if(typeof options===\"function\")callback=options;else if(options!=null)validateObject(options,\"options\");if(options==null)options=kEmptyObject;if(callback!=null)validateFunction(callback,\"callback\");if(options.argv0!=null)validateString(options.argv0,\"options.argv0\"),validateArgumentNullCheck(options.argv0,\"options.argv0\");return{file,args,options,callback}}function normalizeExecArgs(command,options,callback){if(validateString(command,\"command\"),validateArgumentNullCheck(command,\"command\"),typeof options===\"function\")callback=options,options=void 0;return options={...options},options.shell=typeof options.shell===\"string\"\?options.shell:!0,{file:command,options,callback}}function normalizeSpawnArguments(file,args,options){if(validateString(file,\"file\"),validateArgumentNullCheck(file,\"file\"),file.length===0)throw new ERR_INVALID_ARG_VALUE(\"file\",file,\"cannot be empty\");if(ArrayIsArray(args))args=ArrayPrototypeSlice.call(args);else if(args==null)args=[];else if(typeof args!==\"object\")throw new ERR_INVALID_ARG_TYPE(\"args\",\"object\",args);else options=args,args=[];if(validateArgumentsNullCheck(args,\"args\"),options===void 0)options={};else validateObject(options,\"options\");let cwd=options.cwd;if(cwd!=null)cwd=getValidatedPath(cwd,\"options.cwd\");if(options.shell!=null&&typeof options.shell!==\"boolean\"&&typeof options.shell!==\"string\")throw new ERR_INVALID_ARG_TYPE(\"options.shell\",[\"boolean\",\"string\"],options.shell);if(options.argv0!=null)validateString(options.argv0,\"options.argv0\"),validateArgumentNullCheck(options.argv0,\"options.argv0\");if(options.shell){validateArgumentNullCheck(options.shell,\"options.shell\");const command=ArrayPrototypeJoin.call([file,...args],\" \");if(typeof options.shell===\"string\")file=options.shell;else file=\"sh\";args=[\"-c\",command]}if(typeof options.argv0===\"string\")ArrayPrototypeUnshift.call(args,options.argv0);else ArrayPrototypeUnshift.call(args,file);const envPairs=options.env||process.env;return{...options,file,args,cwd,envPairs}}function checkExecSyncError(ret,args,cmd){let err;if(ret.error)err=ret.error,ObjectAssign(err,ret);else if(ret.status!==0){let msg=\"Command failed: \";if(msg+=cmd||ArrayPrototypeJoin.call(args,\" \"),ret.stderr&&ret.stderr.length>0)msg+=`\\n${ret.stderr.toString()}`;err=genericNodeError(msg,ret)}return err}class ChildProcess extends EventEmitter{constructor(){super(...arguments)}#handle;#exited=!1;#closesNeeded=1;#closesGot=0;connected=!1;signalCode=null;exitCode=null;spawnfile;spawnargs;pid;channel;get killed(){if(this.#handle==null)return!1}#handleOnExit(exitCode,signalCode,err){if(this.#exited)return;if(signalCode)this.signalCode=signalCode;else this.exitCode=exitCode;if(this.#stdin)this.#stdin.destroy();if(this.#handle)this.#handle=null;if(exitCode<0){const err2=new SystemError(`Spawned process exited with error code: ${exitCode}`,void 0,\"spawn\",\"EUNKNOWN\",\"ERR_CHILD_PROCESS_UNKNOWN_ERROR\");if(this.spawnfile)err2.path=this.spawnfile;err2.spawnargs=ArrayPrototypeSlice.call(this.spawnargs,1),this.emit(\"error\",err2)}else this.emit(\"exit\",this.exitCode,this.signalCode);process.nextTick(flushStdio,this),this.#maybeClose(),this.#exited=!0,this.#stdioOptions=[\"destroyed\",\"destroyed\",\"destroyed\"]}#getBunSpawnIo(i,encoding){NativeWritable||=StreamModule.NativeWritable,ReadableFromWeb||=StreamModule.Readable.fromWeb;const io=this.#stdioOptions[i];switch(i){case 0:switch(io){case\"pipe\":return new NativeWritable(this.#handle.stdin);case\"inherit\":return process.stdin||null;case\"destroyed\":return new ShimmedStdin;default:return null}case 2:case 1:switch(io){case\"pipe\":return ReadableFromWeb(this.#handle[fdToStdioName(i)],{encoding});case\"inherit\":return process[fdToStdioName(i)]||null;case\"destroyed\":return new ShimmedStdioOutStream;default:return null}}}#stdin;#stdout;#stderr;#stdioObject;#encoding;#stdioOptions;#createStdioObject(){return Object.create(null,{0:{get:()=>this.stdin},1:{get:()=>this.stdout},2:{get:()=>this.stderr}})}get stdin(){return this.#stdin\?\?=this.#getBunSpawnIo(0,this.#encoding)}get stdout(){return this.#stdout\?\?=this.#getBunSpawnIo(1,this.#encoding)}get stderr(){return this.#stderr\?\?=this.#getBunSpawnIo(2,this.#encoding)}get stdio(){return this.#stdioObject\?\?=this.#createStdioObject()}spawn(options){validateObject(options,\"options\"),validateString(options.file,\"options.file\");var file=this.spawnfile=options.file,spawnargs;if(options.args==null)spawnargs=this.spawnargs=[];else validateArray(options.args,\"options.args\"),spawnargs=this.spawnargs=options.args;const stdio=options.stdio||[\"pipe\",\"pipe\",\"pipe\"],bunStdio=getBunStdioFromOptions(stdio);var env=options.envPairs||void 0;this.#encoding=options.encoding||void 0,this.#stdioOptions=bunStdio,this.#handle=Bun.spawn({cmd:spawnargs,stdin:bunStdio[0],stdout:bunStdio[1],stderr:bunStdio[2],cwd:options.cwd||void 0,env:env||process.env,onExit:(handle,exitCode,signalCode,err)=>{this.#handle=handle,this.pid=this.#handle.pid,process.nextTick((exitCode2,signalCode2,err2)=>this.#handleOnExit(exitCode2,signalCode2,err2),exitCode,signalCode,err)},lazy:!0}),this.pid=this.#handle.pid,onSpawnNT(this)}send(){console.log(\"ChildProcess.prototype.send() - Sorry! Not implemented yet\")}disconnect(){console.log(\"ChildProcess.prototype.disconnect() - Sorry! Not implemented yet\")}kill(sig){const signal=sig===0\?sig:convertToValidSignal(sig===void 0\?\"SIGTERM\":sig);if(this.#handle)this.#handle.kill(signal);return this.#maybeClose(),!0}#maybeClose(){if(this.#closesGot++,this.#closesGot===this.#closesNeeded)this.emit(\"close\",this.exitCode,this.signalCode)}ref(){if(this.#handle)this.#handle.ref()}unref(){if(this.#handle)this.#handle.unref()}}const nodeToBunLookup={ignore:null,pipe:\"pipe\",overlapped:\"pipe\",inherit:\"inherit\"};function nodeToBun(item){if(typeof item===\"number\")return item;else{const result=nodeToBunLookup[item];if(result===void 0)throw new Error(\"Invalid stdio option\");return result}}function fdToStdioName(fd){switch(fd){case 0:return\"stdin\";case 1:return\"stdout\";case 2:return\"stderr\";default:return null}}function getBunStdioFromOptions(stdio){return normalizeStdio(stdio).map((item)=>nodeToBun(item))}function normalizeStdio(stdio){if(typeof stdio===\"string\")switch(stdio){case\"ignore\":return[\"ignore\",\"ignore\",\"ignore\"];case\"pipe\":return[\"pipe\",\"pipe\",\"pipe\"];case\"inherit\":return[\"inherit\",\"inherit\",\"inherit\"];default:throw new ERR_INVALID_OPT_VALUE(\"stdio\",stdio)}else if(ArrayIsArray(stdio)){let processedStdio;if(stdio.length===0)processedStdio=[\"pipe\",\"pipe\",\"pipe\"];else if(stdio.length===1)processedStdio=[stdio[0],\"pipe\",\"pipe\"];else if(stdio.length===2)processedStdio=[stdio[0],stdio[1],\"pipe\"];else if(stdio.length>=3)processedStdio=[stdio[0],stdio[1],stdio[2]];return processedStdio.map((item)=>!item\?\"pipe\":item)}else throw new ERR_INVALID_OPT_VALUE(\"stdio\",stdio)}function flushStdio(subprocess){const stdio=subprocess.stdio;if(stdio==null)return;for(let i=0;i=0))throw new ERR_OUT_OF_RANGE(\"options.maxBuffer\",\"a positive number\",maxBuffer)}function validateArgumentNullCheck(arg,propName){if(typeof arg===\"string\"&&StringPrototypeIncludes.call(arg,\"\\0\"))throw new ERR_INVALID_ARG_VALUE(propName,arg,\"must be a string without null bytes\")}function validateArgumentsNullCheck(args,propName){for(let i=0;i=0))throw new ERR_OUT_OF_RANGE(\"timeout\",\"an unsigned integer\",timeout)}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}function validateFunction(value,name){if(typeof value!==\"function\")throw new ERR_INVALID_ARG_TYPE(name,\"Function\",value)}const validateAbortSignal=(signal,name)=>{if(signal!==void 0&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE(name,\"AbortSignal\",signal)},validateOneOf=(value,name,oneOf)=>{if(!ArrayPrototypeIncludes.call(oneOf,value)){const reason=\"must be one of: \"+ArrayPrototypeJoin.call(ArrayPrototypeMap.call(oneOf,(v)=>typeof v===\"string\"\?`'${v}'`:String(v)),\", \");throw new ERR_INVALID_ARG_VALUE(name,value,reason)}},validateObject=(value,name,options=null)=>{const allowArray=options\?.allowArray\?\?!1,allowFunction=options\?.allowFunction\?\?!1;if(!(options\?.nullable\?\?!1)&&value===null||!allowArray&&ArrayIsArray.call(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE(name,\"object\",value)},validateArray=(value,name,minLength=0)=>{if(!ArrayIsArray(value))throw new ERR_INVALID_ARG_TYPE(name,\"Array\",value);if(value.lengthfunction(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},require_safe_buffer=__commonJS({\"node_modules/safe-buffer/index.js\"(exports,module){var buffer=BufferModule,Buffer2=buffer.Buffer;function copyProps(src,dst){for(var key in src)dst[key]=src[key]}Buffer2.from&&Buffer2.alloc&&Buffer2.allocUnsafe&&Buffer2.allocUnsafeSlow\?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer);function SafeBuffer(arg,encodingOrOffset,length){return Buffer2(arg,encodingOrOffset,length)}SafeBuffer.prototype=Object.create(Buffer2.prototype),copyProps(Buffer2,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if(typeof arg==\"number\")@throwTypeError(\"Argument must not be a number\");return Buffer2(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");var buf=Buffer2(size);return fill!==void 0\?typeof encoding==\"string\"\?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf},SafeBuffer.allocUnsafe=function(size){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");return Buffer2(size)},SafeBuffer.allocUnsafeSlow=function(size){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");return buffer.SlowBuffer(size)}}}),require_browser=__commonJS({\"node_modules/randombytes/browser.js\"(exports,module){var MAX_BYTES=65536,MAX_UINT32=4294967295;function oldBrowser(){throw new Error(`Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11`)}var Buffer2=require_safe_buffer().Buffer,crypto2=globalCrypto;crypto2&&crypto2.getRandomValues\?module.exports=randomBytes:module.exports=oldBrowser;function randomBytes(size,cb){if(size>MAX_UINT32)@throwRangeError(\"requested too many random bytes\");var bytes=Buffer2.allocUnsafe(size);if(size>0)if(size>MAX_BYTES)for(var generated=0;generated=this._blockSize;){for(var i=this._blockOffset;i0;++j)this._length[j]+=carry,carry=this._length[j]/4294967296|0,carry>0&&(this._length[j]-=4294967296*carry);return this},HashBase.prototype._update=function(){throw new Error(\"_update is not implemented\")},HashBase.prototype.digest=function(encoding){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var digest=this._digest();encoding!==void 0&&(digest=digest.toString(encoding)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return digest},HashBase.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},module.exports=HashBase}}),require_md5=__commonJS({\"node_modules/md5.js/index.js\"(exports,module){var inherits=require_inherits_browser(),HashBase=require_hash_base(),Buffer2=require_safe_buffer().Buffer,ARRAY16=new Array(16);function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;i<16;++i)M[i]=this._block.readInt32LE(i*4);var a=this._a,b=this._b,c=this._c,d=this._d;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),b=fnF(b,c,d,a,M[15],1236535329,22),a=fnG(a,b,c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),b=fnG(b,c,d,a,M[12],2368359562,20),a=fnH(a,b,c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),b=fnH(b,c,d,a,M[2],3299628645,23),a=fnI(a,b,c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,d,a,M[9],3951481745,21),this._a=this._a+a|0,this._b=this._b+b|0,this._c=this._c+c|0,this._d=this._d+d|0},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer2.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer};function rotl(x,n){return x<>>32-n}function fnF(a,b,c,d,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+b|0}function fnG(a,b,c,d,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+b|0}function fnH(a,b,c,d,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+b|0}function fnI(a,b,c,d,m,k,s){return rotl(a+(c^(b|~d))+m+k|0,s)+b|0}module.exports=MD5}}),require_ripemd160=__commonJS({\"node_modules/ripemd160/index.js\"(exports,module){var Buffer2=Buffer,inherits=require_inherits_browser(),HashBase=require_hash_base(),ARRAY16=new Array(16),zl=[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],zr=[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],sl=[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],sr=[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],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;j<16;++j)words[j]=this._block.readInt32LE(j*4);for(var al=this._a|0,bl=this._b|0,cl=this._c|0,dl=this._d|0,el=this._e|0,ar=this._a|0,br=this._b|0,cr=this._c|0,dr=this._d|0,er=this._e|0,i=0;i<80;i+=1){var tl,tr;i<16\?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):i<32\?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):i<48\?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):i<64\?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}var t=this._b+cl+dr|0;this._b=this._c+dl+er|0,this._c=this._d+el+ar|0,this._d=this._e+al+br|0,this._e=this._a+bl+cr|0,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer2.alloc\?Buffer2.alloc(20):new Buffer2(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer};function rotl(x,n){return x<>>32-n}function fn1(a,b,c,d,e,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+e|0}function fn2(a,b,c,d,e,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+e|0}function fn3(a,b,c,d,e,m,k,s){return rotl(a+((b|~c)^d)+m+k|0,s)+e|0}function fn4(a,b,c,d,e,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+e|0}function fn5(a,b,c,d,e,m,k,s){return rotl(a+(b^(c|~d))+m+k|0,s)+e|0}module.exports=RIPEMD160}}),require_hash=__commonJS({\"node_modules/sha.js/hash.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer;function Hash(blockSize,finalSize){this._block=Buffer2.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}Hash.prototype={},Hash.prototype.update=function(data,enc){typeof data==\"string\"&&(enc=enc||\"utf8\",data=Buffer2.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=this._len*8;if(bits<=4294967295)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=(bits&4294967295)>>>0,highBits=(bits-lowBits)/4294967296;this._block.writeUInt32BE(highBits,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc\?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},module.exports=Hash}}),require_sha=__commonJS({\"node_modules/sha.js/sha.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return s===0\?b&c|~b&d:s===2\?b&c|b&d|c&d:b^c^d}Sha.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<80;++i)W2[i]=W2[i-3]^W2[i-8]^W2[i-14]^W2[i-16];for(var j=0;j<80;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W2[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha.prototype._hash=function(){var H=Buffer2.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},module.exports=Sha}}),require_sha1=__commonJS({\"node_modules/sha.js/sha1.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return s===0\?b&c|~b&d:s===2\?b&c|b&d|c&d:b^c^d}Sha1.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<80;++i)W2[i]=rotl1(W2[i-3]^W2[i-8]^W2[i-14]^W2[i-16]);for(var j=0;j<80;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W2[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha1.prototype._hash=function(){var H=Buffer2.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},module.exports=Sha1}}),require_sha256=__commonJS({\"node_modules/sha.js/sha256.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=new Array(64);function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}Sha256.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,f=this._f|0,g=this._g|0,h=this._h|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<64;++i)W2[i]=gamma1(W2[i-2])+W2[i-7]+gamma0(W2[i-15])+W2[i-16]|0;for(var j=0;j<64;++j){var T1=h+sigma1(e)+ch(e,f,g)+K[j]+W2[j]|0,T2=sigma0(a)+maj(a,b,c)|0;h=g,g=f,f=e,e=d+T1|0,d=c,c=b,b=a,a=T1+T2|0}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0,this._f=f+this._f|0,this._g=g+this._g|0,this._h=h+this._h|0},Sha256.prototype._hash=function(){var H=Buffer2.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256}}),require_sha224=__commonJS({\"node_modules/sha.js/sha224.js\"(exports,module){var inherits=require_inherits_browser(),Sha256=require_sha256(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,W=new Array(64);function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer2.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224}}),require_sha512=__commonJS({\"node_modules/sha.js/sha512.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=new Array(160);function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0>>0\?1:0}Sha512.prototype._update=function(M){for(var W2=this._w,ah=this._ah|0,bh=this._bh|0,ch=this._ch|0,dh=this._dh|0,eh=this._eh|0,fh=this._fh|0,gh=this._gh|0,hh=this._hh|0,al=this._al|0,bl=this._bl|0,cl=this._cl|0,dl=this._dl|0,el=this._el|0,fl=this._fl|0,gl=this._gl|0,hl=this._hl|0,i=0;i<32;i+=2)W2[i]=M.readInt32BE(i*4),W2[i+1]=M.readInt32BE(i*4+4);for(;i<160;i+=2){var xh=W2[i-30],xl=W2[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W2[i-4],xl=W2[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W2[i-14],Wi7l=W2[i-14+1],Wi16h=W2[i-32],Wi16l=W2[i-32+1],Wil=gamma0l+Wi7l|0,Wih=gamma0+Wi7h+getCarry(Wil,gamma0l)|0;Wil=Wil+gamma1l|0,Wih=Wih+gamma1+getCarry(Wil,gamma1l)|0,Wil=Wil+Wi16l|0,Wih=Wih+Wi16h+getCarry(Wil,Wi16l)|0,W2[i]=Wih,W2[i+1]=Wil}for(var j=0;j<160;j+=2){Wih=W2[j],Wil=W2[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=hl+sigma1l|0,t1h=hh+sigma1h+getCarry(t1l,hl)|0;t1l=t1l+chl|0,t1h=t1h+chh+getCarry(t1l,chl)|0,t1l=t1l+Kil|0,t1h=t1h+Kih+getCarry(t1l,Kil)|0,t1l=t1l+Wil|0,t1h=t1h+Wih+getCarry(t1l,Wil)|0;var t2l=sigma0l+majl|0,t2h=sigma0h+majh+getCarry(t2l,sigma0l)|0;hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=dl+t1l|0,eh=dh+t1h+getCarry(el,dl)|0,dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=t1l+t2l|0,ah=t1h+t2h+getCarry(al,t1l)|0}this._al=this._al+al|0,this._bl=this._bl+bl|0,this._cl=this._cl+cl|0,this._dl=this._dl+dl|0,this._el=this._el+el|0,this._fl=this._fl+fl|0,this._gl=this._gl+gl|0,this._hl=this._hl+hl|0,this._ah=this._ah+ah+getCarry(this._al,al)|0,this._bh=this._bh+bh+getCarry(this._bl,bl)|0,this._ch=this._ch+ch+getCarry(this._cl,cl)|0,this._dh=this._dh+dh+getCarry(this._dl,dl)|0,this._eh=this._eh+eh+getCarry(this._el,el)|0,this._fh=this._fh+fh+getCarry(this._fl,fl)|0,this._gh=this._gh+gh+getCarry(this._gl,gl)|0,this._hh=this._hh+hh+getCarry(this._hl,hl)|0},Sha512.prototype._hash=function(){var H=Buffer2.allocUnsafe(64);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512}}),require_sha384=__commonJS({\"node_modules/sha.js/sha384.js\"(exports,module){var inherits=require_inherits_browser(),SHA512=require_sha512(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,W=new Array(160);function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){var H=Buffer2.allocUnsafe(48);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384}}),require_sha2=__commonJS({\"node_modules/sha.js/index.js\"(exports,module){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+\" is not supported (we accept pull requests)\");return new Algorithm};exports.sha=require_sha(),exports.sha1=require_sha1(),exports.sha224=require_sha224(),exports.sha256=require_sha256(),exports.sha384=require_sha384(),exports.sha512=require_sha512()}}),require_cipher_base=__commonJS({\"node_modules/cipher-base/index.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,inherits=require_inherits_browser();function CipherBase(hashMode){StreamModule.Transform.call(this),this.hashMode=typeof hashMode==\"string\",this.hashMode\?this[hashMode]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}inherits(CipherBase,StreamModule.Transform),CipherBase.prototype.update=function(data,inputEnc,outputEnc){typeof data==\"string\"&&(data=Buffer2.from(data,inputEnc));var outData=this._update(data);return this.hashMode\?this:(outputEnc&&(outData=this._toString(outData,outputEnc)),outData)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},CipherBase.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},CipherBase.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},CipherBase.prototype._transform=function(data,_,next){var err;try{this.hashMode\?this._update(data):this.push(this._update(data))}catch(e){err=e}finally{next(err)}},CipherBase.prototype._flush=function(done){var err;try{this.push(this.__final())}catch(e){err=e}done(err)},CipherBase.prototype._finalOrDigest=function(outputEnc){var outData=this.__final()||Buffer2.alloc(0);return outputEnc&&(outData=this._toString(outData,outputEnc,!0)),outData},CipherBase.prototype._toString=function(value,enc,fin){if(this._decoder||(this._decoder=new StringDecoder(enc),this._encoding=enc),this._encoding!==enc)throw new Error(\"can't switch encodings\");var out=this._decoder.write(value);return fin&&(out+=this._decoder.end()),out},module.exports=CipherBase}}),require_browser2=__commonJS({\"node_modules/create-hash/browser.js\"(exports,module){const LazyHash=function Hash(algorithm,options){this._options=options,this._hasher=new CryptoHasher(algorithm,options),this._finalized=!1};LazyHash.prototype=Object.create(StreamModule.Transform.prototype),LazyHash.prototype.update=function update(data,encoding){return this._checkFinalized(),this._hasher.update(data,encoding),this},LazyHash.prototype.digest=function update(data,encoding){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(data,encoding)},LazyHash.prototype._checkFinalized=function _checkFinalized(){if(this._finalized){var err=new Error(\"Digest already called\");throw err.code=\"ERR_CRYPTO_HASH_FINALIZED\",err}},LazyHash.prototype.copy=function copy(){const copy=Object.create(LazyHash.prototype);return copy._options=this._options,copy._hasher=this._hasher.copy(),copy._finalized=this._finalized,copy};const lazyHashFullInitProto={__proto__:StreamModule.Transform.prototype,...LazyHash.prototype,_transform(data,encoding,callback){this.update(data,encoding),callback&&callback()},_flush(callback){this.push(this.digest()),callback()}},triggerMethods=[\"_events\",\"_eventsCount\",\"_final\",\"_maxListeners\",\"_maxListeners\",\"_read\",\"_undestroy\",\"_writableState\",\"_write\",\"_writev\",\"addListener\",\"asIndexedPairs\",\"closed\",\"compose\",\"constructor\",\"cork\",\"destroy\",\"destroyed\",\"drop\",\"emit\",\"end\",\"errored\",\"eventNames\",\"every\",\"filter\",\"find\",\"flatMap\",\"forEach\",\"getMaxListeners\",\"hasOwnProperty\",\"isPaused\",\"isPrototypeOf\",\"iterator\",\"listenerCount\",\"listeners\",\"map\",\"off\",\"on\",\"once\",\"pause\",\"pipe\",\"prependListener\",\"prependOnceListener\",\"propertyIsEnumerable\",\"push\",\"rawListeners\",\"read\",\"readable\",\"readableAborted\",\"readableBuffer\",\"readableDidRead\",\"readableEncoding\",\"readableEnded\",\"readableFlowing\",\"readableHighWaterMark\",\"readableLength\",\"readableObjectMode\",\"reduce\",\"removeAllListeners\",\"removeListener\",\"resume\",\"setDefaultEncoding\",\"setEncoding\",\"setMaxListeners\",\"some\",\"take\",\"toArray\",\"toLocaleString\",\"toString\",\"uncork\",\"unpipe\",\"unshift\",\"valueOf\",\"wrap\",\"writable\",\"writableBuffer\",\"writableCorked\",\"writableEnded\",\"writableFinished\",\"writableHighWaterMark\",\"writableLength\",\"writableNeedDrain\",\"writableObjectMode\",\"write\"];for(let method of triggerMethods)Object.defineProperty(LazyHash.prototype,method,{get(){return Object.setPrototypeOf(this,lazyHashFullInitProto),StreamModule.Transform.call(this,this._options),this[method]},enumerable:!1,configurable:!0});module.exports=function createHash(algorithm){return new LazyHash(algorithm)},module.exports.createHash=module.exports,module.exports.Hash=LazyHash}}),require_legacy=__commonJS({\"node_modules/create-hmac/legacy.js\"(exports,module){var inherits=require_inherits_browser(),Buffer2=require_safe_buffer().Buffer,Base=require_cipher_base(),ZEROS=Buffer2.alloc(128),blocksize=64;function Hmac(alg,key){Base.call(this,\"digest\"),typeof key==\"string\"&&(key=Buffer2.from(key)),this._alg=alg,this._key=key,key.length>blocksize\?key=alg(key):key.lengthblocksize){var hash=alg===\"rmd160\"\?new RIPEMD160:sha(alg);key=hash.update(key).digest()}else key.lengthMAX_ALLOC||keylen!==keylen)@throwTypeError(\"Bad key length\")}}}),require_default_encoding=__commonJS({\"node_modules/pbkdf2/lib/default-encoding.js\"(exports,module){var defaultEncoding;global.process&&global.process.browser\?defaultEncoding=\"utf-8\":global.process&&global.process.version\?(pVersionMajor=parseInt(process.version.split(\".\")[0].slice(1),10),defaultEncoding=pVersionMajor>=6\?\"utf-8\":\"binary\"):defaultEncoding=\"utf-8\";var pVersionMajor;module.exports=defaultEncoding}}),require_to_buffer=__commonJS({\"node_modules/pbkdf2/lib/to-buffer.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer;module.exports=function(thing,encoding,name){if(Buffer2.isBuffer(thing))return thing;if(typeof thing==\"string\")return Buffer2.from(thing,encoding);if(ArrayBuffer.isView(thing))return Buffer2.from(thing.buffer);@throwTypeError(name+\" must be a string, a Buffer, a typed array or a DataView\")}}}),require_sync_browser=__commonJS({\"node_modules/pbkdf2/lib/sync-browser.js\"(exports,module){var md5=require_md52(),RIPEMD160=require_ripemd160(),sha=require_sha2(),Buffer2=require_safe_buffer().Buffer,checkParameters=require_precondition(),defaultEncoding=require_default_encoding(),toBuffer=require_to_buffer(),ZEROS=Buffer2.alloc(128),sizes={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Hmac(alg,key,saltLen){var hash=getDigest(alg),blocksize=alg===\"sha512\"||alg===\"sha384\"\?128:64;key.length>blocksize\?key=hash(key):key.length>>0},exports.writeUInt32BE=function(bytes,value,off){bytes[0+off]=value>>>24,bytes[1+off]=value>>>16&255,bytes[2+off]=value>>>8&255,bytes[3+off]=value&255},exports.ip=function(inL,inR,out,off){for(var outL=0,outR=0,i=6;i>=0;i-=2){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>>j+i&1;for(var j=0;j<=24;j+=8)outL<<=1,outL|=inL>>>j+i&1}for(var i=6;i>=0;i-=2){for(var j=1;j<=25;j+=8)outR<<=1,outR|=inR>>>j+i&1;for(var j=1;j<=25;j+=8)outR<<=1,outR|=inL>>>j+i&1}out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.rip=function(inL,inR,out,off){for(var outL=0,outR=0,i=0;i<4;i++)for(var j=24;j>=0;j-=8)outL<<=1,outL|=inR>>>j+i&1,outL<<=1,outL|=inL>>>j+i&1;for(var i=4;i<8;i++)for(var j=24;j>=0;j-=8)outR<<=1,outR|=inR>>>j+i&1,outR<<=1,outR|=inL>>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.pc1=function(inL,inR,out,off){for(var outL=0,outR=0,i=7;i>=5;i--){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var j=0;j<=24;j+=8)outL<<=1,outL|=inL>>j+i&1}for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var i=1;i<=3;i++){for(var j=0;j<=24;j+=8)outR<<=1,outR|=inR>>j+i&1;for(var j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1}for(var j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.r28shl=function(num,shift){return num<>>28-shift};var pc2table=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];exports.pc2=function(inL,inR,out,off){for(var outL=0,outR=0,len=pc2table.length>>>1,i=0;i>>pc2table[i]&1;for(var i=len;i>>pc2table[i]&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.expand=function(r,out,off){var outL=0,outR=0;outL=(r&1)<<5|r>>>27;for(var i=23;i>=15;i-=4)outL<<=6,outL|=r>>>i&63;for(var i=11;i>=3;i-=4)outR|=r>>>i&63,outR<<=6;outR|=(r&31)<<1|r>>>31,out[off+0]=outL>>>0,out[off+1]=outR>>>0};var sTable=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];exports.substitute=function(inL,inR){for(var out=0,i=0;i<4;i++){var b=inL>>>18-i*6&63,sb=sTable[i*64+b];out<<=4,out|=sb}for(var i=0;i<4;i++){var b=inR>>>18-i*6&63,sb=sTable[256+i*64+b];out<<=4,out|=sb}return out>>>0};var permuteTable=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];exports.permute=function(num){for(var out=0,i=0;i>>permuteTable[i]&1;return out>>>0},exports.padSplit=function(num,size,group){for(var str=num.toString(2);str.length0;count--)inputOff+=this._buffer(data,inputOff),outputOff+=this._flushBuffer(out,outputOff);return inputOff+=this._buffer(data,inputOff),out},Cipher.prototype.final=function(buffer){var first;buffer&&(first=this.update(buffer));var last;return this.type===\"encrypt\"\?last=this._finalEncrypt():last=this._finalDecrypt(),first\?first.concat(last):last},Cipher.prototype._pad=function(buffer,off){if(off===0)return!1;for(;off>>1];kL=utils.r28shl(kL,shift),kR=utils.r28shl(kR,shift),utils.pc2(kL,kR,state.keys,i)}},DES.prototype._update=function(inp,inOff,out,outOff){var state=this._desState,l=utils.readUInt32BE(inp,inOff),r=utils.readUInt32BE(inp,inOff+4);utils.ip(l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],this.type===\"encrypt\"\?this._encrypt(state,l,r,state.tmp,0):this._decrypt(state,l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],utils.writeUInt32BE(out,l,outOff),utils.writeUInt32BE(out,r,outOff+4)},DES.prototype._pad=function(buffer,off){for(var value=buffer.length-off,i=off;i>>0,l=t}utils.rip(r,l,out,off)},DES.prototype._decrypt=function(state,lStart,rStart,out,off){for(var l=rStart,r=lStart,i=state.keys.length-2;i>=0;i-=2){var keyL=state.keys[i],keyR=state.keys[i+1];utils.expand(l,state.tmp,0),keyL^=state.tmp[0],keyR^=state.tmp[1];var s=utils.substitute(keyL,keyR),f=utils.permute(s),t=l;l=(r^f)>>>0,r=t}utils.rip(l,r,out,off)}}}),require_cbc=__commonJS({\"node_modules/des.js/lib/des/cbc.js\"(exports){var assert=require_minimalistic_assert(),inherits=require_inherits_browser(),proto={};function CBCState(iv){assert.equal(iv.length,8,\"Invalid IV length\"),this.iv=new Array(8);for(var i=0;i>i%8,self2._prev=shiftIn(self2._prev,decrypt\?bit:value);return out}function shiftIn(buffer,value){var len=buffer.length,i=-1,out=Buffer2.allocUnsafe(buffer.length);for(buffer=Buffer2.concat([buffer,Buffer2.from([value])]);++i>7;return out}exports.encrypt=function(self2,chunk,decrypt){for(var len=chunk.length,out=Buffer2.allocUnsafe(len),i=-1;++i>>24]^SUB_MIX1[s1>>>16&255]^SUB_MIX2[s2>>>8&255]^SUB_MIX3[s3&255]^keySchedule[ksRow++],t1=SUB_MIX0[s1>>>24]^SUB_MIX1[s2>>>16&255]^SUB_MIX2[s3>>>8&255]^SUB_MIX3[s0&255]^keySchedule[ksRow++],t2=SUB_MIX0[s2>>>24]^SUB_MIX1[s3>>>16&255]^SUB_MIX2[s0>>>8&255]^SUB_MIX3[s1&255]^keySchedule[ksRow++],t3=SUB_MIX0[s3>>>24]^SUB_MIX1[s0>>>16&255]^SUB_MIX2[s1>>>8&255]^SUB_MIX3[s2&255]^keySchedule[ksRow++],s0=t0,s1=t1,s2=t2,s3=t3;return t0=(SBOX[s0>>>24]<<24|SBOX[s1>>>16&255]<<16|SBOX[s2>>>8&255]<<8|SBOX[s3&255])^keySchedule[ksRow++],t1=(SBOX[s1>>>24]<<24|SBOX[s2>>>16&255]<<16|SBOX[s3>>>8&255]<<8|SBOX[s0&255])^keySchedule[ksRow++],t2=(SBOX[s2>>>24]<<24|SBOX[s3>>>16&255]<<16|SBOX[s0>>>8&255]<<8|SBOX[s1&255])^keySchedule[ksRow++],t3=(SBOX[s3>>>24]<<24|SBOX[s0>>>16&255]<<16|SBOX[s1>>>8&255]<<8|SBOX[s2&255])^keySchedule[ksRow++],t0=t0>>>0,t1=t1>>>0,t2=t2>>>0,t3=t3>>>0,[t0,t1,t2,t3]}var RCON=[0,1,2,4,8,16,32,64,128,27,54],G=function(){for(var d=new Array(256),j=0;j<256;j++)j<128\?d[j]=j<<1:d[j]=j<<1^283;for(var SBOX=[],INV_SBOX=[],SUB_MIX=[[],[],[],[]],INV_SUB_MIX=[[],[],[],[]],x=0,xi=0,i=0;i<256;++i){var sx=xi^xi<<1^xi<<2^xi<<3^xi<<4;sx=sx>>>8^sx&255^99,SBOX[x]=sx,INV_SBOX[sx]=x;var x2=d[x],x4=d[x2],x8=d[x4],t=d[sx]*257^sx*16843008;SUB_MIX[0][x]=t<<24|t>>>8,SUB_MIX[1][x]=t<<16|t>>>16,SUB_MIX[2][x]=t<<8|t>>>24,SUB_MIX[3][x]=t,t=x8*16843009^x4*65537^x2*257^x*16843008,INV_SUB_MIX[0][sx]=t<<24|t>>>8,INV_SUB_MIX[1][sx]=t<<16|t>>>16,INV_SUB_MIX[2][sx]=t<<8|t>>>24,INV_SUB_MIX[3][sx]=t,x===0\?x=xi=1:(x=x2^d[d[d[x8^x2]]],xi^=d[d[xi]])}return{SBOX,INV_SBOX,SUB_MIX,INV_SUB_MIX}}();function AES(key){this._key=asUInt32Array(key),this._reset()}AES.prototype={},AES.blockSize=16,AES.keySize=32,AES.prototype.blockSize=AES.blockSize,AES.prototype.keySize=AES.keySize,AES.prototype._reset=function(){for(var keyWords=this._key,keySize=keyWords.length,nRounds=keySize+6,ksRows=(nRounds+1)*4,keySchedule=[],k=0;k>>24,t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[t&255],t^=RCON[k/keySize|0]<<24):keySize>6&&k%keySize===4&&(t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[t&255]),keySchedule[k]=keySchedule[k-keySize]^t}for(var invKeySchedule=[],ik=0;ik>>24]]^G.INV_SUB_MIX[1][G.SBOX[tt>>>16&255]]^G.INV_SUB_MIX[2][G.SBOX[tt>>>8&255]]^G.INV_SUB_MIX[3][G.SBOX[tt&255]]}this._nRounds=nRounds,this._keySchedule=keySchedule,this._invKeySchedule=invKeySchedule},AES.prototype.encryptBlockRaw=function(M){return M=asUInt32Array(M),cryptBlock(M,this._keySchedule,G.SUB_MIX,G.SBOX,this._nRounds)},AES.prototype.encryptBlock=function(M){var out=this.encryptBlockRaw(M),buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[1],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[3],12),buf},AES.prototype.decryptBlock=function(M){M=asUInt32Array(M);var m1=M[1];M[1]=M[3],M[3]=m1;var out=cryptBlock(M,this._invKeySchedule,G.INV_SUB_MIX,G.INV_SBOX,this._nRounds),buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[3],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[1],12),buf},AES.prototype.scrub=function(){scrubVec(this._keySchedule),scrubVec(this._invKeySchedule),scrubVec(this._key)},module.exports.AES=AES}}),require_ghash=__commonJS({\"node_modules/browserify-aes/ghash.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,ZEROES=Buffer2.alloc(16,0);function toArray(buf){return[buf.readUInt32BE(0),buf.readUInt32BE(4),buf.readUInt32BE(8),buf.readUInt32BE(12)]}function fromArray(out){var buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0]>>>0,0),buf.writeUInt32BE(out[1]>>>0,4),buf.writeUInt32BE(out[2]>>>0,8),buf.writeUInt32BE(out[3]>>>0,12),buf}function GHASH(key){this.h=key,this.state=Buffer2.alloc(16,0),this.cache=Buffer2.allocUnsafe(0)}GHASH.prototype={},GHASH.prototype.ghash=function(block){for(var i=-1;++i0;j--)Vi[j]=Vi[j]>>>1|(Vi[j-1]&1)<<31;Vi[0]=Vi[0]>>>1,lsbVi&&(Vi[0]=Vi[0]^225<<24)}this.state=fromArray(Zi)},GHASH.prototype.update=function(buf){this.cache=Buffer2.concat([this.cache,buf]);for(var chunk;this.cache.length>=16;)chunk=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(chunk)},GHASH.prototype.final=function(abl,bl){return this.cache.length&&this.ghash(Buffer2.concat([this.cache,ZEROES],16)),this.ghash(fromArray([0,abl,0,bl])),this.state},module.exports=GHASH}}),require_authCipher=__commonJS({\"node_modules/browserify-aes/authCipher.js\"(exports,module){var aes=require_aes(),Buffer2=require_safe_buffer().Buffer,Transform=require_cipher_base(),inherits=require_inherits_browser(),GHASH=require_ghash(),xor=require_buffer_xor(),incr32=require_incr32();function xorTest(a,b){var out=0;a.length!==b.length&&out++;for(var len=Math.min(a.length,b.length),i=0;i0||ivLen>0;){var hash=new MD5;hash.update(tmp),hash.update(password),salt&&hash.update(salt),tmp=hash.digest();var used=0;if(keyLen>0){var keyStart=key.length-keyLen;used=Math.min(keyLen,tmp.length),tmp.copy(key,keyStart,0,used),keyLen-=used}if(used0){var ivStart=iv.length-ivLen,length=Math.min(ivLen,tmp.length-used);tmp.copy(iv,ivStart,used,used+length),ivLen-=length}}return tmp.fill(0),{key,iv}}module.exports=EVP_BytesToKey}}),require_encrypter=__commonJS({\"node_modules/browserify-aes/encrypter.js\"(exports){var MODES=require_modes(),AuthCipher=require_authCipher(),Buffer2=require_safe_buffer().Buffer,StreamCipher=require_streamCipher(),Transform=require_cipher_base(),aes=require_aes(),ebtk=require_evp_bytestokey(),inherits=require_inherits_browser();function Cipher(mode,key,iv){Transform.call(this),this._cache=new Splitter,this._cipher=new aes.AES(key),this._prev=Buffer2.from(iv),this._mode=mode,this._autopadding=!0}inherits(Cipher,Transform),Cipher.prototype._update=function(data){this._cache.add(data);for(var chunk,thing,out=[];chunk=this._cache.get();)thing=this._mode.encrypt(this,chunk),out.push(thing);return Buffer2.concat(out)};var PADDING=Buffer2.alloc(16,16);Cipher.prototype._final=function(){var chunk=this._cache.flush();if(this._autopadding)return chunk=this._mode.encrypt(this,chunk),this._cipher.scrub(),chunk;if(!chunk.equals(PADDING))throw this._cipher.scrub(),new Error(\"data not multiple of block length\")},Cipher.prototype.setAutoPadding=function(setTo){return this._autopadding=!!setTo,this};function Splitter(){this.cache=Buffer2.allocUnsafe(0)}Splitter.prototype={},Splitter.prototype.add=function(data){this.cache=Buffer2.concat([this.cache,data])},Splitter.prototype.get=function(){if(this.cache.length>15){var out=this.cache.slice(0,16);return this.cache=this.cache.slice(16),out}return null},Splitter.prototype.flush=function(){for(var len=16-this.cache.length,padBuff=Buffer2.allocUnsafe(len),i=-1;++i16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out}else if(this.cache.length>=16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out;return null},Splitter.prototype.flush=function(){if(this.cache.length)return this.cache};function unpad(last){var padded=last[15];if(padded<1||padded>16)throw new Error(\"unable to decrypt data\");for(var i=-1;++i0\?left:right},BN.min=function(left,right){return left.cmp(right)<0\?left:right},BN.prototype._init=function(number,base,endian){if(typeof number==\"number\")return this._initNumber(number,base,endian);if(typeof number==\"object\")return this._initArray(number,base,endian);base===\"hex\"&&(base=16),assert(base===(base|0)&&base>=2&&base<=36),number=number.toString().replace(/\\s+/g,\"\");var start=0;number[0]===\"-\"&&(start++,this.negative=1),start=0;i-=3)w=number[i]|number[i-1]<<8|number[i-2]<<16,this.words[j]|=w<>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);else if(endian===\"le\")for(i=0,j=0;i>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);return this.strip()};function parseHex4Bits(string,index){var c=string.charCodeAt(index);return c>=65&&c<=70\?c-55:c>=97&&c<=102\?c-87:c-48&15}function parseHexByte(string,lowerBound,index){var r=parseHex4Bits(string,index);return index-1>=lowerBound&&(r|=parseHex4Bits(string,index-1)<<4),r}BN.prototype._parseHex=function(number,start,endian){this.length=Math.ceil((number.length-start)/6),this.words=new Array(this.length);for(var i=0;i=start;i-=2)w=parseHexByte(number,start,i)<=18\?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8;else{var parseLength=number.length-start;for(i=parseLength%2===0\?start+1:start;i=18\?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8}this.strip()};function parseBase(str,start,end,mul){for(var r=0,len=Math.min(str.length,end),i=start;i=49\?r+=c-49+10:c>=17\?r+=c-17+10:r+=c}return r}BN.prototype._parseBase=function(number,base,start){this.words=[0],this.length=1;for(var limbLen=0,limbPow=1;limbPow<=67108863;limbPow*=base)limbLen++;limbLen--,limbPow=limbPow/base|0;for(var total=number.length-start,mod=total%limbLen,end=Math.min(total,total-mod)+start,word=0,i=start;i1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},BN.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},BN.prototype.inspect=function(){return(this.red\?\"\"};var zeros=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function(base,padding){base=base||10,padding=padding|0||1;var out;if(base===16||base===\"hex\"){out=\"\";for(var off=0,carry=0,i=0;i>>24-off&16777215,carry!==0||i!==this.length-1\?out=zeros[6-word.length]+word+out:out=word+out,off+=2,off>=26&&(off-=26,i--)}for(carry!==0&&(out=carry.toString(16)+out);out.length%padding!==0;)out=\"0\"+out;return this.negative!==0&&(out=\"-\"+out),out}if(base===(base|0)&&base>=2&&base<=36){var groupSize=groupSizes[base],groupBase=groupBases[base];out=\"\";var c=this.clone();for(c.negative=0;!c.isZero();){var r=c.modn(groupBase).toString(base);c=c.idivn(groupBase),c.isZero()\?out=r+out:out=zeros[groupSize-r.length]+r+out}for(this.isZero()&&(out=\"0\"+out);out.length%padding!==0;)out=\"0\"+out;return this.negative!==0&&(out=\"-\"+out),out}assert(!1,\"Base should be between 2 and 36\")},BN.prototype.toNumber=function(){var ret=this.words[0];return this.length===2\?ret+=this.words[1]*67108864:this.length===3&&this.words[2]===1\?ret+=4503599627370496+this.words[1]*67108864:this.length>2&&assert(!1,\"Number can only safely store up to 53 bits\"),this.negative!==0\?-ret:ret},BN.prototype.toJSON=function(){return this.toString(16)},BN.prototype.toBuffer=function(endian,length){return assert(typeof Buffer2<\"u\"),this.toArrayLike(Buffer2,endian,length)},BN.prototype.toArray=function(endian,length){return this.toArrayLike(Array,endian,length)},BN.prototype.toArrayLike=function(ArrayType,endian,length){var byteLength=this.byteLength(),reqLength=length||Math.max(1,byteLength);assert(byteLength<=reqLength,\"byte array longer than desired length\"),assert(reqLength>0,\"Requested array length <= 0\"),this.strip();var littleEndian=endian===\"le\",res=new ArrayType(reqLength),b,i,q=this.clone();if(littleEndian){for(i=0;!q.isZero();i++)b=q.andln(255),q.iushrn(8),res[i]=b;for(;i=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},BN.prototype._zeroBits=function(w){if(w===0)return 26;var t=w,r=0;return(t&8191)===0&&(r+=13,t>>>=13),(t&127)===0&&(r+=7,t>>>=7),(t&15)===0&&(r+=4,t>>>=4),(t&3)===0&&(r+=2,t>>>=2),(t&1)===0&&r++,r},BN.prototype.bitLength=function(){var w=this.words[this.length-1],hi=this._countBits(w);return(this.length-1)*26+hi};function toBitArray(num){for(var w=new Array(num.bitLength()),bit=0;bit>>wbit}return w}BN.prototype.zeroBits=function(){if(this.isZero())return 0;for(var r=0,i=0;inum.length\?this.clone().ior(num):num.clone().ior(this)},BN.prototype.uor=function(num){return this.length>num.length\?this.clone().iuor(num):num.clone().iuor(this)},BN.prototype.iuand=function(num){var b;this.length>num.length\?b=num:b=this;for(var i=0;inum.length\?this.clone().iand(num):num.clone().iand(this)},BN.prototype.uand=function(num){return this.length>num.length\?this.clone().iuand(num):num.clone().iuand(this)},BN.prototype.iuxor=function(num){var a,b;this.length>num.length\?(a=this,b=num):(a=num,b=this);for(var i=0;inum.length\?this.clone().ixor(num):num.clone().ixor(this)},BN.prototype.uxor=function(num){return this.length>num.length\?this.clone().iuxor(num):num.clone().iuxor(this)},BN.prototype.inotn=function(width){assert(typeof width==\"number\"&&width>=0);var bytesNeeded=Math.ceil(width/26)|0,bitsLeft=width%26;this._expand(bytesNeeded),bitsLeft>0&&bytesNeeded--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-bitsLeft),this.strip()},BN.prototype.notn=function(width){return this.clone().inotn(width)},BN.prototype.setn=function(bit,val){assert(typeof bit==\"number\"&&bit>=0);var off=bit/26|0,wbit=bit%26;return this._expand(off+1),val\?this.words[off]=this.words[off]|1<num.length\?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>>26;for(;carry!==0&&i>>26;if(this.length=a.length,carry!==0)this.words[this.length]=carry,this.length++;else if(a!==this)for(;inum.length\?this.clone().iadd(num):num.clone().iadd(this)},BN.prototype.isub=function(num){if(num.negative!==0){num.negative=0;var r=this.iadd(num);return num.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(num),this.negative=1,this._normSign();var cmp=this.cmp(num);if(cmp===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,b;cmp>0\?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>26,this.words[i]=r&67108863;for(;carry!==0&&i>26,this.words[i]=r&67108863;if(carry===0&&i>>26,rword=carry&67108863,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-self2.length+1);j<=maxJ;j++){var i=k-j|0;a=self2.words[i]|0,b=num.words[j]|0,r=a*b+rword,ncarry+=r/67108864|0,rword=r&67108863}out.words[k]=rword|0,carry=ncarry|0}return carry!==0\?out.words[k]=carry|0:out.length--,out.strip()}var comb10MulTo=function(self2,num,out){var a=self2.words,b=num.words,o=out.words,c=0,lo,mid,hi,a0=a[0]|0,al0=a0&8191,ah0=a0>>>13,a1=a[1]|0,al1=a1&8191,ah1=a1>>>13,a2=a[2]|0,al2=a2&8191,ah2=a2>>>13,a3=a[3]|0,al3=a3&8191,ah3=a3>>>13,a4=a[4]|0,al4=a4&8191,ah4=a4>>>13,a5=a[5]|0,al5=a5&8191,ah5=a5>>>13,a6=a[6]|0,al6=a6&8191,ah6=a6>>>13,a7=a[7]|0,al7=a7&8191,ah7=a7>>>13,a8=a[8]|0,al8=a8&8191,ah8=a8>>>13,a9=a[9]|0,al9=a9&8191,ah9=a9>>>13,b0=b[0]|0,bl0=b0&8191,bh0=b0>>>13,b1=b[1]|0,bl1=b1&8191,bh1=b1>>>13,b2=b[2]|0,bl2=b2&8191,bh2=b2>>>13,b3=b[3]|0,bl3=b3&8191,bh3=b3>>>13,b4=b[4]|0,bl4=b4&8191,bh4=b4>>>13,b5=b[5]|0,bl5=b5&8191,bh5=b5>>>13,b6=b[6]|0,bl6=b6&8191,bh6=b6>>>13,b7=b[7]|0,bl7=b7&8191,bh7=b7>>>13,b8=b[8]|0,bl8=b8&8191,bh8=b8>>>13,b9=b[9]|0,bl9=b9&8191,bh9=b9>>>13;out.negative=self2.negative^num.negative,out.length=19,lo=Math.imul(al0,bl0),mid=Math.imul(al0,bh0),mid=mid+Math.imul(ah0,bl0)|0,hi=Math.imul(ah0,bh0);var w0=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w0>>>26)|0,w0&=67108863,lo=Math.imul(al1,bl0),mid=Math.imul(al1,bh0),mid=mid+Math.imul(ah1,bl0)|0,hi=Math.imul(ah1,bh0),lo=lo+Math.imul(al0,bl1)|0,mid=mid+Math.imul(al0,bh1)|0,mid=mid+Math.imul(ah0,bl1)|0,hi=hi+Math.imul(ah0,bh1)|0;var w1=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w1>>>26)|0,w1&=67108863,lo=Math.imul(al2,bl0),mid=Math.imul(al2,bh0),mid=mid+Math.imul(ah2,bl0)|0,hi=Math.imul(ah2,bh0),lo=lo+Math.imul(al1,bl1)|0,mid=mid+Math.imul(al1,bh1)|0,mid=mid+Math.imul(ah1,bl1)|0,hi=hi+Math.imul(ah1,bh1)|0,lo=lo+Math.imul(al0,bl2)|0,mid=mid+Math.imul(al0,bh2)|0,mid=mid+Math.imul(ah0,bl2)|0,hi=hi+Math.imul(ah0,bh2)|0;var w2=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w2>>>26)|0,w2&=67108863,lo=Math.imul(al3,bl0),mid=Math.imul(al3,bh0),mid=mid+Math.imul(ah3,bl0)|0,hi=Math.imul(ah3,bh0),lo=lo+Math.imul(al2,bl1)|0,mid=mid+Math.imul(al2,bh1)|0,mid=mid+Math.imul(ah2,bl1)|0,hi=hi+Math.imul(ah2,bh1)|0,lo=lo+Math.imul(al1,bl2)|0,mid=mid+Math.imul(al1,bh2)|0,mid=mid+Math.imul(ah1,bl2)|0,hi=hi+Math.imul(ah1,bh2)|0,lo=lo+Math.imul(al0,bl3)|0,mid=mid+Math.imul(al0,bh3)|0,mid=mid+Math.imul(ah0,bl3)|0,hi=hi+Math.imul(ah0,bh3)|0;var w3=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w3>>>26)|0,w3&=67108863,lo=Math.imul(al4,bl0),mid=Math.imul(al4,bh0),mid=mid+Math.imul(ah4,bl0)|0,hi=Math.imul(ah4,bh0),lo=lo+Math.imul(al3,bl1)|0,mid=mid+Math.imul(al3,bh1)|0,mid=mid+Math.imul(ah3,bl1)|0,hi=hi+Math.imul(ah3,bh1)|0,lo=lo+Math.imul(al2,bl2)|0,mid=mid+Math.imul(al2,bh2)|0,mid=mid+Math.imul(ah2,bl2)|0,hi=hi+Math.imul(ah2,bh2)|0,lo=lo+Math.imul(al1,bl3)|0,mid=mid+Math.imul(al1,bh3)|0,mid=mid+Math.imul(ah1,bl3)|0,hi=hi+Math.imul(ah1,bh3)|0,lo=lo+Math.imul(al0,bl4)|0,mid=mid+Math.imul(al0,bh4)|0,mid=mid+Math.imul(ah0,bl4)|0,hi=hi+Math.imul(ah0,bh4)|0;var w4=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w4>>>26)|0,w4&=67108863,lo=Math.imul(al5,bl0),mid=Math.imul(al5,bh0),mid=mid+Math.imul(ah5,bl0)|0,hi=Math.imul(ah5,bh0),lo=lo+Math.imul(al4,bl1)|0,mid=mid+Math.imul(al4,bh1)|0,mid=mid+Math.imul(ah4,bl1)|0,hi=hi+Math.imul(ah4,bh1)|0,lo=lo+Math.imul(al3,bl2)|0,mid=mid+Math.imul(al3,bh2)|0,mid=mid+Math.imul(ah3,bl2)|0,hi=hi+Math.imul(ah3,bh2)|0,lo=lo+Math.imul(al2,bl3)|0,mid=mid+Math.imul(al2,bh3)|0,mid=mid+Math.imul(ah2,bl3)|0,hi=hi+Math.imul(ah2,bh3)|0,lo=lo+Math.imul(al1,bl4)|0,mid=mid+Math.imul(al1,bh4)|0,mid=mid+Math.imul(ah1,bl4)|0,hi=hi+Math.imul(ah1,bh4)|0,lo=lo+Math.imul(al0,bl5)|0,mid=mid+Math.imul(al0,bh5)|0,mid=mid+Math.imul(ah0,bl5)|0,hi=hi+Math.imul(ah0,bh5)|0;var w5=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w5>>>26)|0,w5&=67108863,lo=Math.imul(al6,bl0),mid=Math.imul(al6,bh0),mid=mid+Math.imul(ah6,bl0)|0,hi=Math.imul(ah6,bh0),lo=lo+Math.imul(al5,bl1)|0,mid=mid+Math.imul(al5,bh1)|0,mid=mid+Math.imul(ah5,bl1)|0,hi=hi+Math.imul(ah5,bh1)|0,lo=lo+Math.imul(al4,bl2)|0,mid=mid+Math.imul(al4,bh2)|0,mid=mid+Math.imul(ah4,bl2)|0,hi=hi+Math.imul(ah4,bh2)|0,lo=lo+Math.imul(al3,bl3)|0,mid=mid+Math.imul(al3,bh3)|0,mid=mid+Math.imul(ah3,bl3)|0,hi=hi+Math.imul(ah3,bh3)|0,lo=lo+Math.imul(al2,bl4)|0,mid=mid+Math.imul(al2,bh4)|0,mid=mid+Math.imul(ah2,bl4)|0,hi=hi+Math.imul(ah2,bh4)|0,lo=lo+Math.imul(al1,bl5)|0,mid=mid+Math.imul(al1,bh5)|0,mid=mid+Math.imul(ah1,bl5)|0,hi=hi+Math.imul(ah1,bh5)|0,lo=lo+Math.imul(al0,bl6)|0,mid=mid+Math.imul(al0,bh6)|0,mid=mid+Math.imul(ah0,bl6)|0,hi=hi+Math.imul(ah0,bh6)|0;var w6=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w6>>>26)|0,w6&=67108863,lo=Math.imul(al7,bl0),mid=Math.imul(al7,bh0),mid=mid+Math.imul(ah7,bl0)|0,hi=Math.imul(ah7,bh0),lo=lo+Math.imul(al6,bl1)|0,mid=mid+Math.imul(al6,bh1)|0,mid=mid+Math.imul(ah6,bl1)|0,hi=hi+Math.imul(ah6,bh1)|0,lo=lo+Math.imul(al5,bl2)|0,mid=mid+Math.imul(al5,bh2)|0,mid=mid+Math.imul(ah5,bl2)|0,hi=hi+Math.imul(ah5,bh2)|0,lo=lo+Math.imul(al4,bl3)|0,mid=mid+Math.imul(al4,bh3)|0,mid=mid+Math.imul(ah4,bl3)|0,hi=hi+Math.imul(ah4,bh3)|0,lo=lo+Math.imul(al3,bl4)|0,mid=mid+Math.imul(al3,bh4)|0,mid=mid+Math.imul(ah3,bl4)|0,hi=hi+Math.imul(ah3,bh4)|0,lo=lo+Math.imul(al2,bl5)|0,mid=mid+Math.imul(al2,bh5)|0,mid=mid+Math.imul(ah2,bl5)|0,hi=hi+Math.imul(ah2,bh5)|0,lo=lo+Math.imul(al1,bl6)|0,mid=mid+Math.imul(al1,bh6)|0,mid=mid+Math.imul(ah1,bl6)|0,hi=hi+Math.imul(ah1,bh6)|0,lo=lo+Math.imul(al0,bl7)|0,mid=mid+Math.imul(al0,bh7)|0,mid=mid+Math.imul(ah0,bl7)|0,hi=hi+Math.imul(ah0,bh7)|0;var w7=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w7>>>26)|0,w7&=67108863,lo=Math.imul(al8,bl0),mid=Math.imul(al8,bh0),mid=mid+Math.imul(ah8,bl0)|0,hi=Math.imul(ah8,bh0),lo=lo+Math.imul(al7,bl1)|0,mid=mid+Math.imul(al7,bh1)|0,mid=mid+Math.imul(ah7,bl1)|0,hi=hi+Math.imul(ah7,bh1)|0,lo=lo+Math.imul(al6,bl2)|0,mid=mid+Math.imul(al6,bh2)|0,mid=mid+Math.imul(ah6,bl2)|0,hi=hi+Math.imul(ah6,bh2)|0,lo=lo+Math.imul(al5,bl3)|0,mid=mid+Math.imul(al5,bh3)|0,mid=mid+Math.imul(ah5,bl3)|0,hi=hi+Math.imul(ah5,bh3)|0,lo=lo+Math.imul(al4,bl4)|0,mid=mid+Math.imul(al4,bh4)|0,mid=mid+Math.imul(ah4,bl4)|0,hi=hi+Math.imul(ah4,bh4)|0,lo=lo+Math.imul(al3,bl5)|0,mid=mid+Math.imul(al3,bh5)|0,mid=mid+Math.imul(ah3,bl5)|0,hi=hi+Math.imul(ah3,bh5)|0,lo=lo+Math.imul(al2,bl6)|0,mid=mid+Math.imul(al2,bh6)|0,mid=mid+Math.imul(ah2,bl6)|0,hi=hi+Math.imul(ah2,bh6)|0,lo=lo+Math.imul(al1,bl7)|0,mid=mid+Math.imul(al1,bh7)|0,mid=mid+Math.imul(ah1,bl7)|0,hi=hi+Math.imul(ah1,bh7)|0,lo=lo+Math.imul(al0,bl8)|0,mid=mid+Math.imul(al0,bh8)|0,mid=mid+Math.imul(ah0,bl8)|0,hi=hi+Math.imul(ah0,bh8)|0;var w8=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w8>>>26)|0,w8&=67108863,lo=Math.imul(al9,bl0),mid=Math.imul(al9,bh0),mid=mid+Math.imul(ah9,bl0)|0,hi=Math.imul(ah9,bh0),lo=lo+Math.imul(al8,bl1)|0,mid=mid+Math.imul(al8,bh1)|0,mid=mid+Math.imul(ah8,bl1)|0,hi=hi+Math.imul(ah8,bh1)|0,lo=lo+Math.imul(al7,bl2)|0,mid=mid+Math.imul(al7,bh2)|0,mid=mid+Math.imul(ah7,bl2)|0,hi=hi+Math.imul(ah7,bh2)|0,lo=lo+Math.imul(al6,bl3)|0,mid=mid+Math.imul(al6,bh3)|0,mid=mid+Math.imul(ah6,bl3)|0,hi=hi+Math.imul(ah6,bh3)|0,lo=lo+Math.imul(al5,bl4)|0,mid=mid+Math.imul(al5,bh4)|0,mid=mid+Math.imul(ah5,bl4)|0,hi=hi+Math.imul(ah5,bh4)|0,lo=lo+Math.imul(al4,bl5)|0,mid=mid+Math.imul(al4,bh5)|0,mid=mid+Math.imul(ah4,bl5)|0,hi=hi+Math.imul(ah4,bh5)|0,lo=lo+Math.imul(al3,bl6)|0,mid=mid+Math.imul(al3,bh6)|0,mid=mid+Math.imul(ah3,bl6)|0,hi=hi+Math.imul(ah3,bh6)|0,lo=lo+Math.imul(al2,bl7)|0,mid=mid+Math.imul(al2,bh7)|0,mid=mid+Math.imul(ah2,bl7)|0,hi=hi+Math.imul(ah2,bh7)|0,lo=lo+Math.imul(al1,bl8)|0,mid=mid+Math.imul(al1,bh8)|0,mid=mid+Math.imul(ah1,bl8)|0,hi=hi+Math.imul(ah1,bh8)|0,lo=lo+Math.imul(al0,bl9)|0,mid=mid+Math.imul(al0,bh9)|0,mid=mid+Math.imul(ah0,bl9)|0,hi=hi+Math.imul(ah0,bh9)|0;var w9=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w9>>>26)|0,w9&=67108863,lo=Math.imul(al9,bl1),mid=Math.imul(al9,bh1),mid=mid+Math.imul(ah9,bl1)|0,hi=Math.imul(ah9,bh1),lo=lo+Math.imul(al8,bl2)|0,mid=mid+Math.imul(al8,bh2)|0,mid=mid+Math.imul(ah8,bl2)|0,hi=hi+Math.imul(ah8,bh2)|0,lo=lo+Math.imul(al7,bl3)|0,mid=mid+Math.imul(al7,bh3)|0,mid=mid+Math.imul(ah7,bl3)|0,hi=hi+Math.imul(ah7,bh3)|0,lo=lo+Math.imul(al6,bl4)|0,mid=mid+Math.imul(al6,bh4)|0,mid=mid+Math.imul(ah6,bl4)|0,hi=hi+Math.imul(ah6,bh4)|0,lo=lo+Math.imul(al5,bl5)|0,mid=mid+Math.imul(al5,bh5)|0,mid=mid+Math.imul(ah5,bl5)|0,hi=hi+Math.imul(ah5,bh5)|0,lo=lo+Math.imul(al4,bl6)|0,mid=mid+Math.imul(al4,bh6)|0,mid=mid+Math.imul(ah4,bl6)|0,hi=hi+Math.imul(ah4,bh6)|0,lo=lo+Math.imul(al3,bl7)|0,mid=mid+Math.imul(al3,bh7)|0,mid=mid+Math.imul(ah3,bl7)|0,hi=hi+Math.imul(ah3,bh7)|0,lo=lo+Math.imul(al2,bl8)|0,mid=mid+Math.imul(al2,bh8)|0,mid=mid+Math.imul(ah2,bl8)|0,hi=hi+Math.imul(ah2,bh8)|0,lo=lo+Math.imul(al1,bl9)|0,mid=mid+Math.imul(al1,bh9)|0,mid=mid+Math.imul(ah1,bl9)|0,hi=hi+Math.imul(ah1,bh9)|0;var w10=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w10>>>26)|0,w10&=67108863,lo=Math.imul(al9,bl2),mid=Math.imul(al9,bh2),mid=mid+Math.imul(ah9,bl2)|0,hi=Math.imul(ah9,bh2),lo=lo+Math.imul(al8,bl3)|0,mid=mid+Math.imul(al8,bh3)|0,mid=mid+Math.imul(ah8,bl3)|0,hi=hi+Math.imul(ah8,bh3)|0,lo=lo+Math.imul(al7,bl4)|0,mid=mid+Math.imul(al7,bh4)|0,mid=mid+Math.imul(ah7,bl4)|0,hi=hi+Math.imul(ah7,bh4)|0,lo=lo+Math.imul(al6,bl5)|0,mid=mid+Math.imul(al6,bh5)|0,mid=mid+Math.imul(ah6,bl5)|0,hi=hi+Math.imul(ah6,bh5)|0,lo=lo+Math.imul(al5,bl6)|0,mid=mid+Math.imul(al5,bh6)|0,mid=mid+Math.imul(ah5,bl6)|0,hi=hi+Math.imul(ah5,bh6)|0,lo=lo+Math.imul(al4,bl7)|0,mid=mid+Math.imul(al4,bh7)|0,mid=mid+Math.imul(ah4,bl7)|0,hi=hi+Math.imul(ah4,bh7)|0,lo=lo+Math.imul(al3,bl8)|0,mid=mid+Math.imul(al3,bh8)|0,mid=mid+Math.imul(ah3,bl8)|0,hi=hi+Math.imul(ah3,bh8)|0,lo=lo+Math.imul(al2,bl9)|0,mid=mid+Math.imul(al2,bh9)|0,mid=mid+Math.imul(ah2,bl9)|0,hi=hi+Math.imul(ah2,bh9)|0;var w11=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w11>>>26)|0,w11&=67108863,lo=Math.imul(al9,bl3),mid=Math.imul(al9,bh3),mid=mid+Math.imul(ah9,bl3)|0,hi=Math.imul(ah9,bh3),lo=lo+Math.imul(al8,bl4)|0,mid=mid+Math.imul(al8,bh4)|0,mid=mid+Math.imul(ah8,bl4)|0,hi=hi+Math.imul(ah8,bh4)|0,lo=lo+Math.imul(al7,bl5)|0,mid=mid+Math.imul(al7,bh5)|0,mid=mid+Math.imul(ah7,bl5)|0,hi=hi+Math.imul(ah7,bh5)|0,lo=lo+Math.imul(al6,bl6)|0,mid=mid+Math.imul(al6,bh6)|0,mid=mid+Math.imul(ah6,bl6)|0,hi=hi+Math.imul(ah6,bh6)|0,lo=lo+Math.imul(al5,bl7)|0,mid=mid+Math.imul(al5,bh7)|0,mid=mid+Math.imul(ah5,bl7)|0,hi=hi+Math.imul(ah5,bh7)|0,lo=lo+Math.imul(al4,bl8)|0,mid=mid+Math.imul(al4,bh8)|0,mid=mid+Math.imul(ah4,bl8)|0,hi=hi+Math.imul(ah4,bh8)|0,lo=lo+Math.imul(al3,bl9)|0,mid=mid+Math.imul(al3,bh9)|0,mid=mid+Math.imul(ah3,bl9)|0,hi=hi+Math.imul(ah3,bh9)|0;var w12=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w12>>>26)|0,w12&=67108863,lo=Math.imul(al9,bl4),mid=Math.imul(al9,bh4),mid=mid+Math.imul(ah9,bl4)|0,hi=Math.imul(ah9,bh4),lo=lo+Math.imul(al8,bl5)|0,mid=mid+Math.imul(al8,bh5)|0,mid=mid+Math.imul(ah8,bl5)|0,hi=hi+Math.imul(ah8,bh5)|0,lo=lo+Math.imul(al7,bl6)|0,mid=mid+Math.imul(al7,bh6)|0,mid=mid+Math.imul(ah7,bl6)|0,hi=hi+Math.imul(ah7,bh6)|0,lo=lo+Math.imul(al6,bl7)|0,mid=mid+Math.imul(al6,bh7)|0,mid=mid+Math.imul(ah6,bl7)|0,hi=hi+Math.imul(ah6,bh7)|0,lo=lo+Math.imul(al5,bl8)|0,mid=mid+Math.imul(al5,bh8)|0,mid=mid+Math.imul(ah5,bl8)|0,hi=hi+Math.imul(ah5,bh8)|0,lo=lo+Math.imul(al4,bl9)|0,mid=mid+Math.imul(al4,bh9)|0,mid=mid+Math.imul(ah4,bl9)|0,hi=hi+Math.imul(ah4,bh9)|0;var w13=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w13>>>26)|0,w13&=67108863,lo=Math.imul(al9,bl5),mid=Math.imul(al9,bh5),mid=mid+Math.imul(ah9,bl5)|0,hi=Math.imul(ah9,bh5),lo=lo+Math.imul(al8,bl6)|0,mid=mid+Math.imul(al8,bh6)|0,mid=mid+Math.imul(ah8,bl6)|0,hi=hi+Math.imul(ah8,bh6)|0,lo=lo+Math.imul(al7,bl7)|0,mid=mid+Math.imul(al7,bh7)|0,mid=mid+Math.imul(ah7,bl7)|0,hi=hi+Math.imul(ah7,bh7)|0,lo=lo+Math.imul(al6,bl8)|0,mid=mid+Math.imul(al6,bh8)|0,mid=mid+Math.imul(ah6,bl8)|0,hi=hi+Math.imul(ah6,bh8)|0,lo=lo+Math.imul(al5,bl9)|0,mid=mid+Math.imul(al5,bh9)|0,mid=mid+Math.imul(ah5,bl9)|0,hi=hi+Math.imul(ah5,bh9)|0;var w14=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w14>>>26)|0,w14&=67108863,lo=Math.imul(al9,bl6),mid=Math.imul(al9,bh6),mid=mid+Math.imul(ah9,bl6)|0,hi=Math.imul(ah9,bh6),lo=lo+Math.imul(al8,bl7)|0,mid=mid+Math.imul(al8,bh7)|0,mid=mid+Math.imul(ah8,bl7)|0,hi=hi+Math.imul(ah8,bh7)|0,lo=lo+Math.imul(al7,bl8)|0,mid=mid+Math.imul(al7,bh8)|0,mid=mid+Math.imul(ah7,bl8)|0,hi=hi+Math.imul(ah7,bh8)|0,lo=lo+Math.imul(al6,bl9)|0,mid=mid+Math.imul(al6,bh9)|0,mid=mid+Math.imul(ah6,bl9)|0,hi=hi+Math.imul(ah6,bh9)|0;var w15=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w15>>>26)|0,w15&=67108863,lo=Math.imul(al9,bl7),mid=Math.imul(al9,bh7),mid=mid+Math.imul(ah9,bl7)|0,hi=Math.imul(ah9,bh7),lo=lo+Math.imul(al8,bl8)|0,mid=mid+Math.imul(al8,bh8)|0,mid=mid+Math.imul(ah8,bl8)|0,hi=hi+Math.imul(ah8,bh8)|0,lo=lo+Math.imul(al7,bl9)|0,mid=mid+Math.imul(al7,bh9)|0,mid=mid+Math.imul(ah7,bl9)|0,hi=hi+Math.imul(ah7,bh9)|0;var w16=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w16>>>26)|0,w16&=67108863,lo=Math.imul(al9,bl8),mid=Math.imul(al9,bh8),mid=mid+Math.imul(ah9,bl8)|0,hi=Math.imul(ah9,bh8),lo=lo+Math.imul(al8,bl9)|0,mid=mid+Math.imul(al8,bh9)|0,mid=mid+Math.imul(ah8,bl9)|0,hi=hi+Math.imul(ah8,bh9)|0;var w17=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w17>>>26)|0,w17&=67108863,lo=Math.imul(al9,bl9),mid=Math.imul(al9,bh9),mid=mid+Math.imul(ah9,bl9)|0,hi=Math.imul(ah9,bh9);var w18=(c+lo|0)+((mid&8191)<<13)|0;return c=(hi+(mid>>>13)|0)+(w18>>>26)|0,w18&=67108863,o[0]=w0,o[1]=w1,o[2]=w2,o[3]=w3,o[4]=w4,o[5]=w5,o[6]=w6,o[7]=w7,o[8]=w8,o[9]=w9,o[10]=w10,o[11]=w11,o[12]=w12,o[13]=w13,o[14]=w14,o[15]=w15,o[16]=w16,o[17]=w17,o[18]=w18,c!==0&&(o[19]=c,out.length++),out};Math.imul||(comb10MulTo=smallMulTo);function bigMulTo(self2,num,out){out.negative=num.negative^self2.negative,out.length=self2.length+num.length;for(var carry=0,hncarry=0,k=0;k>>26)|0,hncarry+=ncarry>>>26,ncarry&=67108863}out.words[k]=rword,carry=ncarry,ncarry=hncarry}return carry!==0\?out.words[k]=carry:out.length--,out.strip()}function jumboMulTo(self2,num,out){var fftm=new FFTM;return fftm.mulp(self2,num,out)}BN.prototype.mulTo=function(num,out){var res,len=this.length+num.length;return this.length===10&&num.length===10\?res=comb10MulTo(this,num,out):len<63\?res=smallMulTo(this,num,out):len<1024\?res=bigMulTo(this,num,out):res=jumboMulTo(this,num,out),res};function FFTM(x,y){this.x=x,this.y=y}FFTM.prototype={},FFTM.prototype.makeRBT=function(N){for(var t=new Array(N),l=BN.prototype._countBits(N)-1,i=0;i>=1;return rb},FFTM.prototype.permute=function(rbt,rws,iws,rtws,itws,N){for(var i=0;i>>1)i++;return 1<>>13,rws[2*i+1]=carry&8191,carry=carry>>>13;for(i=2*len;i>=26,carry+=w/67108864|0,carry+=lo>>>26,this.words[i]=lo&67108863}return carry!==0&&(this.words[i]=carry,this.length++),this},BN.prototype.muln=function(num){return this.clone().imuln(num)},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.imul(this.clone())},BN.prototype.pow=function(num){var w=toBitArray(num);if(w.length===0)return new BN(1);for(var res=this,i=0;i=0);var r=bits%26,s=(bits-r)/26,carryMask=67108863>>>26-r<<26-r,i;if(r!==0){var carry=0;for(i=0;i>>26-r}carry&&(this.words[i]=carry,this.length++)}if(s!==0){for(i=this.length-1;i>=0;i--)this.words[i+s]=this.words[i];for(i=0;i=0);var h;hint\?h=(hint-hint%26)/26:h=0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<s)for(this.length-=s,i=0;i=0&&(carry!==0||i>=h);i--){var word=this.words[i]|0;this.words[i]=carry<<26-r|word>>>r,carry=word&mask}return maskedWords&&carry!==0&&(maskedWords.words[maskedWords.length++]=carry),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function(bits,hint,extended){return assert(this.negative===0),this.iushrn(bits,hint,extended)},BN.prototype.shln=function(bits){return this.clone().ishln(bits)},BN.prototype.ushln=function(bits){return this.clone().iushln(bits)},BN.prototype.shrn=function(bits){return this.clone().ishrn(bits)},BN.prototype.ushrn=function(bits){return this.clone().iushrn(bits)},BN.prototype.testn=function(bit){assert(typeof bit==\"number\"&&bit>=0);var r=bit%26,s=(bit-r)/26,q=1<=0);var r=bits%26,s=(bits-r)/26;if(assert(this.negative===0,\"imaskn works only with positive numbers\"),this.length<=s)return this;if(r!==0&&s++,this.length=Math.min(s,this.length),r!==0){var mask=67108863^67108863>>>r<=67108864;i++)this.words[i]-=67108864,i===this.length-1\?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},BN.prototype.isubn=function(num){if(assert(typeof num==\"number\"),assert(num<67108864),num<0)return this.iaddn(-num);if(this.negative!==0)return this.negative=0,this.iaddn(num),this.negative=1,this;if(this.words[0]-=num,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(right/67108864|0),this.words[i+shift]=w&67108863}for(;i>26,this.words[i+shift]=w&67108863;if(carry===0)return this.strip();for(assert(carry===-1),carry=0,i=0;i>26,this.words[i]=w&67108863;return this.negative=1,this.strip()},BN.prototype._wordDiv=function(num,mode){var shift=this.length-num.length,a=this.clone(),b=num,bhi=b.words[b.length-1]|0,bhiBits=this._countBits(bhi);shift=26-bhiBits,shift!==0&&(b=b.ushln(shift),a.iushln(shift),bhi=b.words[b.length-1]|0);var m=a.length-b.length,q;if(mode!==\"mod\"){q=new BN(null),q.length=m+1,q.words=new Array(q.length);for(var i=0;i=0;j--){var qj=(a.words[b.length+j]|0)*67108864+(a.words[b.length+j-1]|0);for(qj=Math.min(qj/bhi|0,67108863),a._ishlnsubmul(b,qj,j);a.negative!==0;)qj--,a.negative=0,a._ishlnsubmul(b,1,j),a.isZero()||(a.negative^=1);q&&(q.words[j]=qj)}return q&&q.strip(),a.strip(),mode!==\"div\"&&shift!==0&&a.iushrn(shift),{div:q||null,mod:a}},BN.prototype.divmod=function(num,mode,positive){if(assert(!num.isZero()),this.isZero())return{div:new BN(0),mod:new BN(0)};var div,mod,res;return this.negative!==0&&num.negative===0\?(res=this.neg().divmod(num,mode),mode!==\"mod\"&&(div=res.div.neg()),mode!==\"div\"&&(mod=res.mod.neg(),positive&&mod.negative!==0&&mod.iadd(num)),{div,mod}):this.negative===0&&num.negative!==0\?(res=this.divmod(num.neg(),mode),mode!==\"mod\"&&(div=res.div.neg()),{div,mod:res.mod}):(this.negative&num.negative)!==0\?(res=this.neg().divmod(num.neg(),mode),mode!==\"div\"&&(mod=res.mod.neg(),positive&&mod.negative!==0&&mod.isub(num)),{div:res.div,mod}):num.length>this.length||this.cmp(num)<0\?{div:new BN(0),mod:this}:num.length===1\?mode===\"div\"\?{div:this.divn(num.words[0]),mod:null}:mode===\"mod\"\?{div:null,mod:new BN(this.modn(num.words[0]))}:{div:this.divn(num.words[0]),mod:new BN(this.modn(num.words[0]))}:this._wordDiv(num,mode)},BN.prototype.div=function(num){return this.divmod(num,\"div\",!1).div},BN.prototype.mod=function(num){return this.divmod(num,\"mod\",!1).mod},BN.prototype.umod=function(num){return this.divmod(num,\"mod\",!0).mod},BN.prototype.divRound=function(num){var dm=this.divmod(num);if(dm.mod.isZero())return dm.div;var mod=dm.div.negative!==0\?dm.mod.isub(num):dm.mod,half=num.ushrn(1),r2=num.andln(1),cmp=mod.cmp(half);return cmp<0||r2===1&&cmp===0\?dm.div:dm.div.negative!==0\?dm.div.isubn(1):dm.div.iaddn(1)},BN.prototype.modn=function(num){assert(num<=67108863);for(var p=(1<<26)%num,acc=0,i=this.length-1;i>=0;i--)acc=(p*acc+(this.words[i]|0))%num;return acc},BN.prototype.idivn=function(num){assert(num<=67108863);for(var carry=0,i=this.length-1;i>=0;i--){var w=(this.words[i]|0)+carry*67108864;this.words[i]=w/num|0,carry=w%num}return this.strip()},BN.prototype.divn=function(num){return this.clone().idivn(num)},BN.prototype.egcd=function(p){assert(p.negative===0),assert(!p.isZero());var x=this,y=p.clone();x.negative!==0\?x=x.umod(p):x=x.clone();for(var A=new BN(1),B=new BN(0),C=new BN(0),D=new BN(1),g=0;x.isEven()&&y.isEven();)x.iushrn(1),y.iushrn(1),++g;for(var yp=y.clone(),xp=x.clone();!x.isZero();){for(var i=0,im=1;(x.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0)for(x.iushrn(i);i-- >0;)(A.isOdd()||B.isOdd())&&(A.iadd(yp),B.isub(xp)),A.iushrn(1),B.iushrn(1);for(var j=0,jm=1;(y.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0)for(y.iushrn(j);j-- >0;)(C.isOdd()||D.isOdd())&&(C.iadd(yp),D.isub(xp)),C.iushrn(1),D.iushrn(1);x.cmp(y)>=0\?(x.isub(y),A.isub(C),B.isub(D)):(y.isub(x),C.isub(A),D.isub(B))}return{a:C,b:D,gcd:y.iushln(g)}},BN.prototype._invmp=function(p){assert(p.negative===0),assert(!p.isZero());var a=this,b=p.clone();a.negative!==0\?a=a.umod(p):a=a.clone();for(var x1=new BN(1),x2=new BN(0),delta=b.clone();a.cmpn(1)>0&&b.cmpn(1)>0;){for(var i=0,im=1;(a.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0)for(a.iushrn(i);i-- >0;)x1.isOdd()&&x1.iadd(delta),x1.iushrn(1);for(var j=0,jm=1;(b.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0)for(b.iushrn(j);j-- >0;)x2.isOdd()&&x2.iadd(delta),x2.iushrn(1);a.cmp(b)>=0\?(a.isub(b),x1.isub(x2)):(b.isub(a),x2.isub(x1))}var res;return a.cmpn(1)===0\?res=x1:res=x2,res.cmpn(0)<0&&res.iadd(p),res},BN.prototype.gcd=function(num){if(this.isZero())return num.abs();if(num.isZero())return this.abs();var a=this.clone(),b=num.clone();a.negative=0,b.negative=0;for(var shift=0;a.isEven()&&b.isEven();shift++)a.iushrn(1),b.iushrn(1);do{for(;a.isEven();)a.iushrn(1);for(;b.isEven();)b.iushrn(1);var r=a.cmp(b);if(r<0){var t=a;a=b,b=t}else if(r===0||b.cmpn(1)===0)break;a.isub(b)}while(!0);return b.iushln(shift)},BN.prototype.invm=function(num){return this.egcd(num).a.umod(num)},BN.prototype.isEven=function(){return(this.words[0]&1)===0},BN.prototype.isOdd=function(){return(this.words[0]&1)===1},BN.prototype.andln=function(num){return this.words[0]&num},BN.prototype.bincn=function(bit){assert(typeof bit==\"number\");var r=bit%26,s=(bit-r)/26,q=1<>>26,w&=67108863,this.words[i]=w}return carry!==0&&(this.words[i]=carry,this.length++),this},BN.prototype.isZero=function(){return this.length===1&&this.words[0]===0},BN.prototype.cmpn=function(num){var negative=num<0;if(this.negative!==0&&!negative)return-1;if(this.negative===0&&negative)return 1;this.strip();var res;if(this.length>1)res=1;else{negative&&(num=-num),assert(num<=67108863,\"Number is too big\");var w=this.words[0]|0;res=w===num\?0:wnum.length)return 1;if(this.length=0;i--){var a=this.words[i]|0,b=num.words[i]|0;if(a!==b){ab&&(res=1);break}}return res},BN.prototype.gtn=function(num){return this.cmpn(num)===1},BN.prototype.gt=function(num){return this.cmp(num)===1},BN.prototype.gten=function(num){return this.cmpn(num)>=0},BN.prototype.gte=function(num){return this.cmp(num)>=0},BN.prototype.ltn=function(num){return this.cmpn(num)===-1},BN.prototype.lt=function(num){return this.cmp(num)===-1},BN.prototype.lten=function(num){return this.cmpn(num)<=0},BN.prototype.lte=function(num){return this.cmp(num)<=0},BN.prototype.eqn=function(num){return this.cmpn(num)===0},BN.prototype.eq=function(num){return this.cmp(num)===0},BN.red=function(num){return new Red(num)},BN.prototype.toRed=function(ctx){return assert(!this.red,\"Already a number in reduction context\"),assert(this.negative===0,\"red works only with positives\"),ctx.convertTo(this)._forceRed(ctx)},BN.prototype.fromRed=function(){return assert(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},BN.prototype._forceRed=function(ctx){return this.red=ctx,this},BN.prototype.forceRed=function(ctx){return assert(!this.red,\"Already a number in reduction context\"),this._forceRed(ctx)},BN.prototype.redAdd=function(num){return assert(this.red,\"redAdd works only with red numbers\"),this.red.add(this,num)},BN.prototype.redIAdd=function(num){return assert(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,num)},BN.prototype.redSub=function(num){return assert(this.red,\"redSub works only with red numbers\"),this.red.sub(this,num)},BN.prototype.redISub=function(num){return assert(this.red,\"redISub works only with red numbers\"),this.red.isub(this,num)},BN.prototype.redShl=function(num){return assert(this.red,\"redShl works only with red numbers\"),this.red.shl(this,num)},BN.prototype.redMul=function(num){return assert(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,num),this.red.mul(this,num)},BN.prototype.redIMul=function(num){return assert(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,num),this.red.imul(this,num)},BN.prototype.redSqr=function(){return assert(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(num){return assert(this.red&&!num.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,num)};var primes={k256:null,p224:null,p192:null,p25519:null};function MPrime(name,p){this.name=name,this.p=new BN(p,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}MPrime.prototype={},MPrime.prototype._tmp=function(){var tmp=new BN(null);return tmp.words=new Array(Math.ceil(this.n/13)),tmp},MPrime.prototype.ireduce=function(num){var r=num,rlen;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),rlen=r.bitLength();while(rlen>this.n);var cmp=rlen0\?r.isub(this.p):r.strip!==void 0\?r.strip():r._strip(),r},MPrime.prototype.split=function(input,out){input.iushrn(this.n,0,out)},MPrime.prototype.imulK=function(num){return num.imul(this.k)};function K256(){MPrime.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var mask=4194303,outLen=Math.min(input.length,9),i=0;i>>22,prev=next}prev>>>=22,input.words[i-10]=prev,prev===0&&input.length>10\?input.length-=10:input.length-=9},K256.prototype.imulK=function(num){num.words[num.length]=0,num.words[num.length+1]=0,num.length+=2;for(var lo=0,i=0;i>>=26,num.words[i]=lo,carry=hi}return carry!==0&&(num.words[num.length++]=carry),num},BN._prime=function(name){if(primes[name])return primes[name];var prime2;if(name===\"k256\")prime2=new K256;else if(name===\"p224\")prime2=new P224;else if(name===\"p192\")prime2=new P192;else if(name===\"p25519\")prime2=new P25519;else throw new Error(\"Unknown prime \"+name);return primes[name]=prime2,prime2};function Red(m){if(typeof m==\"string\"){var prime=BN._prime(m);this.m=prime.p,this.prime=prime}else assert(m.gtn(1),\"modulus must be greater than 1\"),this.m=m,this.prime=null}Red.prototype={},Red.prototype._verify1=function(a){assert(a.negative===0,\"red works only with positives\"),assert(a.red,\"red works only with red numbers\")},Red.prototype._verify2=function(a,b){assert((a.negative|b.negative)===0,\"red works only with positives\"),assert(a.red&&a.red===b.red,\"red works only with red numbers\")},Red.prototype.imod=function(a){return this.prime\?this.prime.ireduce(a)._forceRed(this):a.umod(this.m)._forceRed(this)},Red.prototype.neg=function(a){return a.isZero()\?a.clone():this.m.sub(a)._forceRed(this)},Red.prototype.add=function(a,b){this._verify2(a,b);var res=a.add(b);return res.cmp(this.m)>=0&&res.isub(this.m),res._forceRed(this)},Red.prototype.iadd=function(a,b){this._verify2(a,b);var res=a.iadd(b);return res.cmp(this.m)>=0&&res.isub(this.m),res},Red.prototype.sub=function(a,b){this._verify2(a,b);var res=a.sub(b);return res.cmpn(0)<0&&res.iadd(this.m),res._forceRed(this)},Red.prototype.isub=function(a,b){this._verify2(a,b);var res=a.isub(b);return res.cmpn(0)<0&&res.iadd(this.m),res},Red.prototype.shl=function(a,num){return this._verify1(a),this.imod(a.ushln(num))},Red.prototype.imul=function(a,b){return this._verify2(a,b),this.imod(a.imul(b))},Red.prototype.mul=function(a,b){return this._verify2(a,b),this.imod(a.mul(b))},Red.prototype.isqr=function(a){return this.imul(a,a.clone())},Red.prototype.sqr=function(a){return this.mul(a,a)},Red.prototype.sqrt=function(a){if(a.isZero())return a.clone();var mod3=this.m.andln(3);if(assert(mod3%2===1),mod3===3){var pow=this.m.add(new BN(1)).iushrn(2);return this.pow(a,pow)}for(var q=this.m.subn(1),s=0;!q.isZero()&&q.andln(1)===0;)s++,q.iushrn(1);assert(!q.isZero());var one=new BN(1).toRed(this),nOne=one.redNeg(),lpow=this.m.subn(1).iushrn(1),z=this.m.bitLength();for(z=new BN(2*z*z).toRed(this);this.pow(z,lpow).cmp(nOne)!==0;)z.redIAdd(nOne);for(var c=this.pow(z,q),r=this.pow(a,q.addn(1).iushrn(1)),t=this.pow(a,q),m=s;t.cmp(one)!==0;){for(var tmp=t,i=0;tmp.cmp(one)!==0;i++)tmp=tmp.redSqr();assert(i=0;i--){for(var word=num.words[i],j=start-1;j>=0;j--){var bit=word>>j&1;if(res!==wnd[0]&&(res=this.sqr(res)),bit===0&¤t===0){currentLen=0;continue}current<<=1,current|=bit,currentLen++,!(currentLen!==windowSize&&(i!==0||j!==0))&&(res=this.mul(res,wnd[current]),currentLen=0,current=0)}start=26}return res},Red.prototype.convertTo=function(num){var r=num.umod(this.m);return r===num\?r.clone():r},Red.prototype.convertFrom=function(num){var res=num.clone();return res.red=null,res},BN.mont=function(num){return new Mont(num)};function Mont(m){Red.call(this,m),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new BN(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}inherits(Mont,Red),Mont.prototype.convertTo=function(num){return this.imod(num.ushln(this.shift))},Mont.prototype.convertFrom=function(num){var r=this.imod(num.mul(this.rinv));return r.red=null,r},Mont.prototype.imul=function(a,b){if(a.isZero()||b.isZero())return a.words[0]=0,a.length=1,a;var t=a.imul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0\?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.mul=function(a,b){if(a.isZero()||b.isZero())return new BN(0)._forceRed(this);var t=a.mul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0\?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.invm=function(a){var res=this.imod(a._invmp(this.m).mul(this.r2));return res._forceRed(this)}})(typeof module>\"u\"||module,exports)}}),require_bn2=require_bn,require_brorand=__commonJS({\"node_modules/brorand/index.js\"(exports,module){var r;module.exports=function(len){return r||(r=new Rand(null)),r.generate(len)};function Rand(rand){this.rand=rand}Rand.prototype={},module.exports.Rand=Rand,Rand.prototype.generate=function(len){return this._rand(len)},Rand.prototype._rand=function(n){var out=new Buffer(n);return crypto.getRandomValues(out),out}}}),require_mr=__commonJS({\"node_modules/miller-rabin/lib/mr.js\"(exports,module){var bn=require_bn2(),brorand=require_brorand();function MillerRabin(rand){this.rand=rand||new brorand.Rand}module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype={},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=Math.ceil(len/8);do var a=new bn(this.rand.generate(min_bytes));while(a.cmp(n)>=0);return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=Math.max(1,len/48|0));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;k>0;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(!(x.cmp(rone)===0||x.cmp(rn1)===0)){for(var i=1;i0;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(g.cmpn(1)!==0)return g;var x=a.toRed(red).redPow(d);if(!(x.cmp(rone)===0||x.cmp(rn1)===0)){for(var i=1;ibits;)num.ishrn(1);if(num.isEven()&&num.iadd(ONE),num.testn(1)||num.iadd(TWO),gen.cmp(TWO)){if(!gen.cmp(FIVE))for(;num.mod(TEN).cmp(THREE);)num.iadd(FOUR)}else for(;num.mod(TWENTYFOUR).cmp(ELEVEN);)num.iadd(FOUR);if(n2=num.shrn(1),simpleSieve(n2)&&simpleSieve(num)&&fermatTest(n2)&&fermatTest(num)&&millerRabin.test(n2)&&millerRabin.test(num))return num}}}}),require_primes=__commonJS({\"node_modules/diffie-hellman/lib/primes.json\"(exports,module){module.exports={modp1:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff\"},modp2:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff\"},modp5:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff\"},modp14:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff\"},modp15:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff\"},modp16:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff\"},modp17:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff\"},modp18:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff\"}}}}),require_dh=__commonJS({\"node_modules/diffie-hellman/lib/dh.js\"(exports,module){var BN=require_bn(),MillerRabin=require_mr(),millerRabin=new MillerRabin,TWENTYFOUR=new BN(24),ELEVEN=new BN(11),TEN=new BN(10),THREE=new BN(3),SEVEN=new BN(7),primes=require_generatePrime(),randomBytes=require_browser();module.exports=DH;function setPublicKey(pub,enc){return enc=enc||\"utf8\",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this._pub=new BN(pub),this}function setPrivateKey(priv,enc){return enc=enc||\"utf8\",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc)),this._priv=new BN(priv),this}var primeCache={};function checkPrime(prime,generator){var gen=generator.toString(\"hex\"),hex=[gen,prime.toString(16)].join(\"_\");if(hex in primeCache)return primeCache[hex];var error=0;if(prime.isEven()||!primes.simpleSieve||!primes.fermatTest(prime)||!millerRabin.test(prime))return error+=1,gen===\"02\"||gen===\"05\"\?error+=8:error+=4,primeCache[hex]=error,error;millerRabin.test(prime.shrn(1))||(error+=2);var rem;switch(gen){case\"02\":prime.mod(TWENTYFOUR).cmp(ELEVEN)&&(error+=8);break;case\"05\":rem=prime.mod(TEN),rem.cmp(THREE)&&rem.cmp(SEVEN)&&(error+=8);break;default:error+=4}return primeCache[hex]=error,error}function DH(prime,generator,malleable){this.setGenerator(generator),this.__prime=new BN(prime),this._prime=BN.mont(this.__prime),this._primeLen=prime.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,malleable\?(this.setPublicKey=setPublicKey,this.setPrivateKey=setPrivateKey):this._primeCode=8}DH.prototype={},Object.defineProperty(DH.prototype,\"verifyError\",{enumerable:!0,get:function(){return typeof this._primeCode!=\"number\"&&(this._primeCode=checkPrime(this.__prime,this.__gen)),this._primeCode}}),DH.prototype.generateKeys=function(){return this._priv||(this._priv=new BN(randomBytes(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},DH.prototype.computeSecret=function(other){other=new BN(other),other=other.toRed(this._prime);var secret=other.redPow(this._priv).fromRed(),out=new Buffer(secret.toArray()),prime=this.getPrime();if(out.length=0||!r.umod(priv.prime1)||!r.umod(priv.prime2));return r}function crt(msg,priv){var blinds=blind(priv),len=priv.modulus.byteLength(),blinded=new BN(msg).mul(blinds.blinder).umod(priv.modulus),c1=blinded.toRed(BN.mont(priv.prime1)),c2=blinded.toRed(BN.mont(priv.prime2)),qinv=priv.coefficient,p=priv.prime1,q=priv.prime2,m1=c1.redPow(priv.exponent1).fromRed(),m2=c2.redPow(priv.exponent2).fromRed(),h=m1.isub(m2).imul(qinv).umod(p).imul(q);return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer,\"be\",len)}crt.getr=getr,module.exports=crt}}),require_package=__commonJS({\"node_modules/elliptic/package.json\"(exports,module){module.exports={name:\"elliptic\",version:\"6.5.4\",description:\"EC cryptography\",main:\"lib/elliptic.js\",files:[\"lib\"],scripts:{lint:\"eslint lib test\",\"lint:fix\":\"npm run lint -- --fix\",unit:\"istanbul test _mocha --reporter=spec test/index.js\",test:\"npm run lint && npm run unit\",version:\"grunt dist && git add dist/\"},repository:{type:\"git\",url:\"git@github.com:indutny/elliptic\"},keywords:[\"EC\",\"Elliptic\",\"curve\",\"Cryptography\"],author:\"Fedor Indutny \",license:\"MIT\",bugs:{url:\"https://github.com/indutny/elliptic/issues\"},homepage:\"https://github.com/indutny/elliptic\",devDependencies:{brfs:\"^2.0.2\",coveralls:\"^3.1.0\",eslint:\"^7.6.0\",grunt:\"^1.2.1\",\"grunt-browserify\":\"^5.3.0\",\"grunt-cli\":\"^1.3.2\",\"grunt-contrib-connect\":\"^3.0.0\",\"grunt-contrib-copy\":\"^1.0.0\",\"grunt-contrib-uglify\":\"^5.0.0\",\"grunt-mocha-istanbul\":\"^5.0.2\",\"grunt-saucelabs\":\"^9.0.1\",istanbul:\"^0.4.5\",mocha:\"^8.0.1\"},dependencies:{\"bn.js\":\"^4.11.9\",brorand:\"^1.1.0\",\"hash.js\":\"^1.0.0\",\"hmac-drbg\":\"^1.0.1\",inherits:\"^2.0.4\",\"minimalistic-assert\":\"^1.0.1\",\"minimalistic-crypto-utils\":\"^1.0.1\"}}}}),require_bn4=require_bn,require_utils2=__commonJS({\"node_modules/minimalistic-crypto-utils/lib/utils.js\"(exports){var utils=exports;function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if(typeof msg!=\"string\"){for(var i=0;i>8,lo=c&255;hi\?res.push(hi,lo):res.push(lo)}return res}utils.toArray=toArray;function zero2(word){return word.length===1\?\"0\"+word:word}utils.zero2=zero2;function toHex(msg){for(var res=\"\",i=0;i(ws>>1)-1\?z=(ws>>1)-mod:z=mod,k.isubn(z)):z=0,naf[i]=z,k.iushrn(1)}return naf}utils.getNAF=getNAF;function getJSF(k1,k2){var jsf=[[],[]];k1=k1.clone(),k2=k2.clone();for(var d1=0,d2=0,m8;k1.cmpn(-d1)>0||k2.cmpn(-d2)>0;){var m14=k1.andln(3)+d1&3,m24=k2.andln(3)+d2&3;m14===3&&(m14=-1),m24===3&&(m24=-1);var u1;(m14&1)===0\?u1=0:(m8=k1.andln(7)+d1&7,(m8===3||m8===5)&&m24===2\?u1=-m14:u1=m14),jsf[0].push(u1);var u2;(m24&1)===0\?u2=0:(m8=k2.andln(7)+d2&7,(m8===3||m8===5)&&m14===2\?u2=-m24:u2=m24),jsf[1].push(u2),2*d1===u1+1&&(d1=1-d1),2*d2===u2+1&&(d2=1-d2),k1.iushrn(1),k2.iushrn(1)}return jsf}utils.getJSF=getJSF;function cachedProperty(obj,name,computer){var key=\"_\"+name;obj.prototype[name]=function(){return this[key]!==void 0\?this[key]:this[key]=computer.call(this)}}utils.cachedProperty=cachedProperty;function parseBytes(bytes){return typeof bytes==\"string\"\?utils.toArray(bytes,\"hex\"):bytes}utils.parseBytes=parseBytes;function intFromLE(bytes){return new BN(bytes,\"hex\",\"le\")}utils.intFromLE=intFromLE}}),require_base=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/base.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),getNAF=utils.getNAF,getJSF=utils.getJSF,assert=utils.assert;function BaseCurve(type,conf){this.type=type,this.p=new BN(conf.p,16),this.red=conf.prime\?BN.red(conf.prime):BN.mont(this.p),this.zero=new BN(0).toRed(this.red),this.one=new BN(1).toRed(this.red),this.two=new BN(2).toRed(this.red),this.n=conf.n&&new BN(conf.n,16),this.g=conf.g&&this.pointFromJSON(conf.g,conf.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n\?this.n.bitLength():0;var adjustCount=this.n&&this.p.div(this.n);!adjustCount||adjustCount.cmpn(100)>0\?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}module.exports=BaseCurve,BaseCurve.prototype={},BaseCurve.prototype.point=function(){throw new Error(\"Not implemented\")},BaseCurve.prototype.validate=function(){throw new Error(\"Not implemented\")},BaseCurve.prototype._fixedNafMul=function(p,k){assert(p.precomputed);var doubles=p._getDoubles(),naf=getNAF(k,1,this._bitLength),I=(1<=j;l--)nafW=(nafW<<1)+naf[l];repr.push(nafW)}for(var a=this.jpoint(null,null,null),b=this.jpoint(null,null,null),i=I;i>0;i--){for(j=0;j=0;i--){for(var l=0;i>=0&&naf[i]===0;i--)l++;if(i>=0&&l++,acc=acc.dblp(l),i<0)break;var z=naf[i];assert(z!==0),p.type===\"affine\"\?z>0\?acc=acc.mixedAdd(wnd[z-1>>1]):acc=acc.mixedAdd(wnd[-z-1>>1].neg()):z>0\?acc=acc.add(wnd[z-1>>1]):acc=acc.add(wnd[-z-1>>1].neg())}return p.type===\"affine\"\?acc.toP():acc},BaseCurve.prototype._wnafMulAdd=function(defW,points,coeffs,len,jacobianResult){var wndWidth=this._wnafT1,wnd=this._wnafT2,naf=this._wnafT3,max=0,i,j,p;for(i=0;i=1;i-=2){var a=i-1,b=i;if(wndWidth[a]!==1||wndWidth[b]!==1){naf[a]=getNAF(coeffs[a],wndWidth[a],this._bitLength),naf[b]=getNAF(coeffs[b],wndWidth[b],this._bitLength),max=Math.max(naf[a].length,max),max=Math.max(naf[b].length,max);continue}var comb=[points[a],null,null,points[b]];points[a].y.cmp(points[b].y)===0\?(comb[1]=points[a].add(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg())):points[a].y.cmp(points[b].y.redNeg())===0\?(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].add(points[b].neg())):(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg()));var index=[-3,-1,-5,-7,0,7,5,1,3],jsf=getJSF(coeffs[a],coeffs[b]);for(max=Math.max(jsf[0].length,max),naf[a]=new Array(max),naf[b]=new Array(max),j=0;j=0;i--){for(var k=0;i>=0;){var zero=!0;for(j=0;j=0&&k++,acc=acc.dblp(k),i<0)break;for(j=0;j0\?p=wnd[j][z-1>>1]:z<0&&(p=wnd[j][-z-1>>1].neg()),p.type===\"affine\"\?acc=acc.mixedAdd(p):acc=acc.add(p))}}for(i=0;i=Math.ceil((k.bitLength()+1)/doubles.step):!1},BasePoint.prototype._getDoubles=function(step,power){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var doubles=[this],acc=this,i=0;i=0&&(a2=a0,b2=b0),a1.negative&&(a1=a1.neg(),b1=b1.neg()),a2.negative&&(a2=a2.neg(),b2=b2.neg()),[{a:a1,b:b1},{a:a2,b:b2}]},ShortCurve.prototype._endoSplit=function(k){var basis=this.endo.basis,v1=basis[0],v2=basis[1],c1=v2.b.mul(k).divRound(this.n),c2=v1.b.neg().mul(k).divRound(this.n),p1=c1.mul(v1.a),p2=c2.mul(v2.a),q1=c1.mul(v1.b),q2=c2.mul(v2.b),k1=k.sub(p1).sub(p2),k2=q1.add(q2).neg();return{k1,k2}},ShortCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var y2=x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b),y=y2.redSqrt();if(y.redSqr().redSub(y2).cmp(this.zero)!==0)throw new Error(\"invalid point\");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},ShortCurve.prototype.validate=function(point){if(point.inf)return!0;var{x,y}=point,ax=this.a.redMul(x),rhs=x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);return y.redSqr().redISub(rhs).cmpn(0)===0},ShortCurve.prototype._endoWnafMulAdd=function(points,coeffs,jacobianResult){for(var npoints=this._endoWnafT1,ncoeffs=this._endoWnafT2,i=0;i\":\"\"},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(p){if(this.inf)return p;if(p.inf)return this;if(this.eq(p))return this.dbl();if(this.neg().eq(p))return this.curve.point(null,null);if(this.x.cmp(p.x)===0)return this.curve.point(null,null);var c=this.y.redSub(p.y);c.cmpn(0)!==0&&(c=c.redMul(this.x.redSub(p.x).redInvm()));var nx=c.redSqr().redISub(this.x).redISub(p.x),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.dbl=function(){if(this.inf)return this;var ys1=this.y.redAdd(this.y);if(ys1.cmpn(0)===0)return this.curve.point(null,null);var a=this.curve.a,x2=this.x.redSqr(),dyinv=ys1.redInvm(),c=x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv),nx=c.redSqr().redISub(this.x.redAdd(this.x)),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(k){return k=new BN(k,16),this.isInfinity()\?this:this._hasDoubles(k)\?this.curve._fixedNafMul(this,k):this.curve.endo\?this.curve._endoWnafMulAdd([this],[k]):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo\?this.curve._endoWnafMulAdd(points,coeffs):this.curve._wnafMulAdd(1,points,coeffs,2)},Point.prototype.jmulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo\?this.curve._endoWnafMulAdd(points,coeffs,!0):this.curve._wnafMulAdd(1,points,coeffs,2,!0)},Point.prototype.eq=function(p){return this===p||this.inf===p.inf&&(this.inf||this.x.cmp(p.x)===0&&this.y.cmp(p.y)===0)},Point.prototype.neg=function(_precompute){if(this.inf)return this;var res=this.curve.point(this.x,this.y.redNeg());if(_precompute&&this.precomputed){var pre=this.precomputed,negate=function(p){return p.neg()};res.precomputed={naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(negate)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(negate)}}}return res},Point.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var res=this.curve.jpoint(this.x,this.y,this.curve.one);return res};function JPoint(curve,x,y,z){Base.BasePoint.call(this,curve,\"jacobian\"),x===null&&y===null&&z===null\?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN(0)):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=new BN(z,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(x,y,z){return new JPoint(this,x,y,z)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var zinv=this.z.redInvm(),zinv2=zinv.redSqr(),ax=this.x.redMul(zinv2),ay=this.y.redMul(zinv2).redMul(zinv);return this.curve.point(ax,ay)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(p){if(this.isInfinity())return p;if(p.isInfinity())return this;var pz2=p.z.redSqr(),z2=this.z.redSqr(),u1=this.x.redMul(pz2),u2=p.x.redMul(z2),s1=this.y.redMul(pz2.redMul(p.z)),s2=p.y.redMul(z2.redMul(this.z)),h=u1.redSub(u2),r=s1.redSub(s2);if(h.cmpn(0)===0)return r.cmpn(0)!==0\?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(p.z).redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mixedAdd=function(p){if(this.isInfinity())return p.toJ();if(p.isInfinity())return this;var z2=this.z.redSqr(),u1=this.x,u2=p.x.redMul(z2),s1=this.y,s2=p.y.redMul(z2).redMul(this.z),h=u1.redSub(u2),r=s1.redSub(s2);if(h.cmpn(0)===0)return r.cmpn(0)!==0\?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.dblp=function(pow){if(pow===0)return this;if(this.isInfinity())return this;if(!pow)return this.dbl();var i;if(this.curve.zeroA||this.curve.threeA){var r=this;for(i=0;i=0)return!1;if(rx.redIAdd(t),this.x.cmp(rx)===0)return!0}},JPoint.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},JPoint.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),require_mont=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/mont.js\"(exports,module){var BN=require_bn4(),inherits=require_inherits_browser(),Base=require_base(),utils=require_utils3();function MontCurve(conf){Base.call(this,\"mont\",conf),this.a=new BN(conf.a,16).toRed(this.red),this.b=new BN(conf.b,16).toRed(this.red),this.i4=new BN(4).toRed(this.red).redInvm(),this.two=new BN(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(point){var x=point.normalize().x,x2=x.redSqr(),rhs=x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x),y=rhs.redSqrt();return y.redSqr().cmp(rhs)===0};function Point(curve,x,z){Base.BasePoint.call(this,curve,\"projective\"),x===null&&z===null\?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN(x,16),this.z=new BN(z,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits(Point,Base.BasePoint),MontCurve.prototype.decodePoint=function(bytes,enc){return this.point(utils.toArray(bytes,enc),1)},MontCurve.prototype.point=function(x,z){return new Point(this,x,z)},MontCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray(\"be\",this.curve.p.byteLength())},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1]||curve.one)},Point.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},Point.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Point.prototype.dbl=function(){var a=this.x.redAdd(this.z),aa=a.redSqr(),b=this.x.redSub(this.z),bb=b.redSqr(),c=aa.redSub(bb),nx=aa.redMul(bb),nz=c.redMul(bb.redAdd(this.curve.a24.redMul(c)));return this.curve.point(nx,nz)},Point.prototype.add=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.diffAdd=function(p,diff){var a=this.x.redAdd(this.z),b=this.x.redSub(this.z),c=p.x.redAdd(p.z),d=p.x.redSub(p.z),da=d.redMul(a),cb=c.redMul(b),nx=diff.z.redMul(da.redAdd(cb).redSqr()),nz=diff.x.redMul(da.redISub(cb).redSqr());return this.curve.point(nx,nz)},Point.prototype.mul=function(k){for(var t=k.clone(),a=this,b=this.curve.point(null,null),c=this,bits=[];t.cmpn(0)!==0;t.iushrn(1))bits.push(t.andln(1));for(var i=bits.length-1;i>=0;i--)bits[i]===0\?(a=a.diffAdd(b,c),b=b.dbl()):(b=a.diffAdd(b,c),a=a.dbl());return b},Point.prototype.mulAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.jumlAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.eq=function(other){return this.getX().cmp(other.getX())===0},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),require_edwards=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/edwards.js\"(exports,module){var utils=require_utils3(),BN=require_bn4(),inherits=require_inherits_browser(),Base=require_base(),assert=utils.assert;function EdwardsCurve(conf){this.twisted=(conf.a|0)!==1,this.mOneA=this.twisted&&(conf.a|0)===-1,this.extended=this.mOneA,Base.call(this,\"edwards\",conf),this.a=new BN(conf.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN(conf.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN(conf.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(conf.c|0)===1}inherits(EdwardsCurve,Base),module.exports=EdwardsCurve,EdwardsCurve.prototype._mulA=function(num){return this.mOneA\?num.redNeg():this.a.redMul(num)},EdwardsCurve.prototype._mulC=function(num){return this.oneC\?num:this.c.redMul(num)},EdwardsCurve.prototype.jpoint=function(x,y,z,t){return this.point(x,y,z,t)},EdwardsCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var x2=x.redSqr(),rhs=this.c2.redSub(this.a.redMul(x2)),lhs=this.one.redSub(this.c2.redMul(this.d).redMul(x2)),y2=rhs.redMul(lhs.redInvm()),y=y2.redSqrt();if(y.redSqr().redSub(y2).cmp(this.zero)!==0)throw new Error(\"invalid point\");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},EdwardsCurve.prototype.pointFromY=function(y,odd){y=new BN(y,16),y.red||(y=y.toRed(this.red));var y2=y.redSqr(),lhs=y2.redSub(this.c2),rhs=y2.redMul(this.d).redMul(this.c2).redSub(this.a),x2=lhs.redMul(rhs.redInvm());if(x2.cmp(this.zero)===0){if(odd)throw new Error(\"invalid point\");return this.point(this.zero,y)}var x=x2.redSqrt();if(x.redSqr().redSub(x2).cmp(this.zero)!==0)throw new Error(\"invalid point\");return x.fromRed().isOdd()!==odd&&(x=x.redNeg()),this.point(x,y)},EdwardsCurve.prototype.validate=function(point){if(point.isInfinity())return!0;point.normalize();var x2=point.x.redSqr(),y2=point.y.redSqr(),lhs=x2.redMul(this.a).redAdd(y2),rhs=this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));return lhs.cmp(rhs)===0};function Point(curve,x,y,z,t){Base.BasePoint.call(this,curve,\"projective\"),x===null&&y===null&&z===null\?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=z\?new BN(z,16):this.curve.one,this.t=t&&new BN(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}inherits(Point,Base.BasePoint),EdwardsCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},EdwardsCurve.prototype.point=function(x,y,z,t){return new Point(this,x,y,z,t)},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1],obj[2])},Point.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},Point.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},Point.prototype._extDbl=function(){var a=this.x.redSqr(),b=this.y.redSqr(),c=this.z.redSqr();c=c.redIAdd(c);var d=this.curve._mulA(a),e=this.x.redAdd(this.y).redSqr().redISub(a).redISub(b),g=d.redAdd(b),f=g.redSub(c),h=d.redSub(b),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projDbl=function(){var b=this.x.redAdd(this.y).redSqr(),c=this.x.redSqr(),d=this.y.redSqr(),nx,ny,nz,e,h,j;if(this.curve.twisted){e=this.curve._mulA(c);var f=e.redAdd(d);this.zOne\?(nx=b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)),ny=f.redMul(e.redSub(d)),nz=f.redSqr().redSub(f).redSub(f)):(h=this.z.redSqr(),j=f.redSub(h).redISub(h),nx=b.redSub(c).redISub(d).redMul(j),ny=f.redMul(e.redSub(d)),nz=f.redMul(j))}else e=c.redAdd(d),h=this.curve._mulC(this.z).redSqr(),j=e.redSub(h).redSub(h),nx=this.curve._mulC(b.redISub(e)).redMul(j),ny=this.curve._mulC(e).redMul(c.redISub(d)),nz=e.redMul(j);return this.curve.point(nx,ny,nz)},Point.prototype.dbl=function(){return this.isInfinity()\?this:this.curve.extended\?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(p){var a=this.y.redSub(this.x).redMul(p.y.redSub(p.x)),b=this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)),c=this.t.redMul(this.curve.dd).redMul(p.t),d=this.z.redMul(p.z.redAdd(p.z)),e=b.redSub(a),f=d.redSub(c),g=d.redAdd(c),h=b.redAdd(a),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projAdd=function(p){var a=this.z.redMul(p.z),b=a.redSqr(),c=this.x.redMul(p.x),d=this.y.redMul(p.y),e=this.curve.d.redMul(c).redMul(d),f=b.redSub(e),g=b.redAdd(e),tmp=this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d),nx=a.redMul(f).redMul(tmp),ny,nz;return this.curve.twisted\?(ny=a.redMul(g).redMul(d.redSub(this.curve._mulA(c))),nz=f.redMul(g)):(ny=a.redMul(g).redMul(d.redSub(c)),nz=this.curve._mulC(f).redMul(g)),this.curve.point(nx,ny,nz)},Point.prototype.add=function(p){return this.isInfinity()\?p:p.isInfinity()\?this:this.curve.extended\?this._extAdd(p):this._projAdd(p)},Point.prototype.mul=function(k){return this._hasDoubles(k)\?this.curve._fixedNafMul(this,k):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!1)},Point.prototype.jmulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var zi=this.z.redInvm();return this.x=this.x.redMul(zi),this.y=this.y.redMul(zi),this.t&&(this.t=this.t.redMul(zi)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(other){return this===other||this.getX().cmp(other.getX())===0&&this.getY().cmp(other.getY())===0},Point.prototype.eqXToP=function(x){var rx=x.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(rx)===0)return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(this.z);;){if(xc.iadd(this.curve.n),xc.cmp(this.curve.p)>=0)return!1;if(rx.redIAdd(t),this.x.cmp(rx)===0)return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add}}),require_curve=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/index.js\"(exports){var curve=exports;curve.base=require_base(),curve.short=require_short(),curve.mont=require_mont(),curve.edwards=require_edwards()}}),require_utils4=__commonJS({\"node_modules/hash.js/lib/hash/utils.js\"(exports){var assert=require_minimalistic_assert(),inherits=require_inherits_browser();exports.inherits=inherits;function isSurrogatePair(msg,i){return(msg.charCodeAt(i)&64512)!==55296||i<0||i+1>=msg.length\?!1:(msg.charCodeAt(i+1)&64512)===56320}function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if(typeof msg==\"string\")if(enc){if(enc===\"hex\")for(msg=msg.replace(/[^a-z0-9]+/gi,\"\"),msg.length%2!==0&&(msg=\"0\"+msg),i=0;i>6|192,res[p++]=c&63|128):isSurrogatePair(msg,i)\?(c=65536+((c&1023)<<10)+(msg.charCodeAt(++i)&1023),res[p++]=c>>18|240,res[p++]=c>>12&63|128,res[p++]=c>>6&63|128,res[p++]=c&63|128):(res[p++]=c>>12|224,res[p++]=c>>6&63|128,res[p++]=c&63|128)}else for(i=0;i>>24|w>>>8&65280|w<<8&16711680|(w&255)<<24;return res>>>0}exports.htonl=htonl;function toHex32(msg,endian){for(var res=\"\",i=0;i>>0}return res}exports.join32=join32;function split32(msg,endian){for(var res=new Array(msg.length*4),i=0,k=0;i>>24,res[k+1]=m>>>16&255,res[k+2]=m>>>8&255,res[k+3]=m&255):(res[k+3]=m>>>24,res[k+2]=m>>>16&255,res[k+1]=m>>>8&255,res[k]=m&255)}return res}exports.split32=split32;function rotr32(w,b){return w>>>b|w<<32-b}exports.rotr32=rotr32;function rotl32(w,b){return w<>>32-b}exports.rotl32=rotl32;function sum32(a,b){return a+b>>>0}exports.sum32=sum32;function sum32_3(a,b,c){return a+b+c>>>0}exports.sum32_3=sum32_3;function sum32_4(a,b,c,d){return a+b+c+d>>>0}exports.sum32_4=sum32_4;function sum32_5(a,b,c,d,e){return a+b+c+d+e>>>0}exports.sum32_5=sum32_5;function sum64(buf,pos,ah,al){var bh=buf[pos],bl=buf[pos+1],lo=al+bl>>>0,hi=(lo>>0,buf[pos+1]=lo}exports.sum64=sum64;function sum64_hi(ah,al,bh,bl){var lo=al+bl>>>0,hi=(lo>>0}exports.sum64_hi=sum64_hi;function sum64_lo(ah,al,bh,bl){var lo=al+bl;return lo>>>0}exports.sum64_lo=sum64_lo;function sum64_4_hi(ah,al,bh,bl,ch,cl,dh,dl){var carry=0,lo=al;lo=lo+bl>>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0}exports.sum64_4_hi=sum64_4_hi;function sum64_4_lo(ah,al,bh,bl,ch,cl,dh,dl){var lo=al+bl+cl+dl;return lo>>>0}exports.sum64_4_lo=sum64_4_lo;function sum64_5_hi(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var carry=0,lo=al;lo=lo+bl>>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0}exports.sum64_5_hi=sum64_5_hi;function sum64_5_lo(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var lo=al+bl+cl+dl+el;return lo>>>0}exports.sum64_5_lo=sum64_5_lo;function rotr64_hi(ah,al,num){var r=al<<32-num|ah>>>num;return r>>>0}exports.rotr64_hi=rotr64_hi;function rotr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}exports.rotr64_lo=rotr64_lo;function shr64_hi(ah,al,num){return ah>>>num}exports.shr64_hi=shr64_hi;function shr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}exports.shr64_lo=shr64_lo}}),require_common=__commonJS({\"node_modules/hash.js/lib/hash/common.js\"(exports){var utils=require_utils4(),assert=require_minimalistic_assert();function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian=\"big\",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}BlockHash.prototype={},exports.BlockHash=BlockHash,BlockHash.prototype.update=function(msg,enc){if(msg=utils.toArray(msg,enc),this.pending\?this.pending=this.pending.concat(msg):this.pending=msg,this.pendingTotal+=msg.length,this.pending.length>=this._delta8){msg=this.pending;var r=msg.length%this._delta8;this.pending=msg.slice(msg.length-r,msg.length),this.pending.length===0&&(this.pending=null),msg=utils.join32(msg,0,msg.length-r,this.endian);for(var i=0;i>>24&255,res[i++]=len>>>16&255,res[i++]=len>>>8&255,res[i++]=len&255}else for(res[i++]=len&255,res[i++]=len>>>8&255,res[i++]=len>>>16&255,res[i++]=len>>>24&255,res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=0,t=8;t>>3}exports.g0_256=g0_256;function g1_256(x){return rotr32(x,17)^rotr32(x,19)^x>>>10}exports.g1_256=g1_256}}),require__=__commonJS({\"node_modules/hash.js/lib/hash/sha/1.js\"(exports,module){var utils=require_utils4(),common=require_common(),shaCommon=require_common2(),rotl32=utils.rotl32,sum32=utils.sum32,sum32_5=utils.sum32_5,ft_1=shaCommon.ft_1,BlockHash=common.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils.inherits(SHA1,BlockHash),module.exports=SHA1,SHA1.blockSize=512,SHA1.outSize=160,SHA1.hmacStrength=80,SHA1.padLength=64,SHA1.prototype._update=function(msg,start){for(var W=this.W,i=0;i<16;i++)W[i]=msg[start+i];for(;ithis.blockSize&&(key=new this.Hash().update(key).digest()),assert(key.length<=this.blockSize);for(var i=key.length;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._init(entropy,nonce,pers)}HmacDRBG.prototype={},module.exports=HmacDRBG,HmacDRBG.prototype._init=function(entropy,nonce,pers){var seed=entropy.concat(nonce).concat(pers);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._update(entropy.concat(add||[])),this._reseed=1},HmacDRBG.prototype.generate=function(len,enc,add,addEnc){if(this._reseed>this.reseedInterval)throw new Error(\"Reseed is required\");typeof enc!=\"string\"&&(addEnc=add,add=enc,enc=null),add&&(add=utils.toArray(add,addEnc||\"hex\"),this._update(add));for(var temp=[];temp.length\"}}}),require_signature=__commonJS({\"node_modules/elliptic/lib/elliptic/ec/signature.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),assert=utils.assert;function Signature(options,enc){if(options instanceof Signature)return options;this._importDER(options,enc)||(assert(options.r&&options.s,\"Signature without r or s\"),this.r=new BN(options.r,16),this.s=new BN(options.s,16),options.recoveryParam===void 0\?this.recoveryParam=null:this.recoveryParam=options.recoveryParam)}Signature.prototype={},module.exports=Signature;function Position(){this.place=0}function getLength(buf,p){var initial=buf[p.place++];if(!(initial&128))return initial;var octetLen=initial&15;if(octetLen===0||octetLen>4)return!1;for(var val=0,i=0,off=p.place;i>>=0;return val<=127\?!1:(p.place=off,val)}function rmPadding(buf){for(var i=0,len=buf.length-1;!buf[i]&&!(buf[i+1]&128)&&i>>3);for(arr.push(octets|128);--octets;)arr.push(len>>>(octets<<3)&255);arr.push(len)}Signature.prototype.toDER=function(enc){var r=this.r.toArray(),s=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),s[0]&128&&(s=[0].concat(s)),r=rmPadding(r),s=rmPadding(s);!s[0]&&!(s[1]&128);)s=s.slice(1);var arr=[2];constructLength(arr,r.length),arr=arr.concat(r),arr.push(2),constructLength(arr,s.length);var backHalf=arr.concat(s),res=[48];return constructLength(res,backHalf.length),res=res.concat(backHalf),utils.encode(res,enc)}}}),require_ec=__commonJS({\"node_modules/elliptic/lib/elliptic/ec/index.js\"(exports,module){var BN=require_bn4(),HmacDRBG=require_hmac_drbg(),utils=require_utils3(),curves=require_curves(),rand=require_brorand(),assert=utils.assert,KeyPair=require_key(),Signature=require_signature();function EC(options){if(!(this instanceof EC))return new EC(options);typeof options==\"string\"&&(assert(Object.prototype.hasOwnProperty.call(curves,options),\"Unknown curve \"+options),options=curves[options]),options instanceof curves.PresetCurve&&(options={curve:options}),this.curve=options.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=options.curve.g,this.g.precompute(options.curve.n.bitLength()+1),this.hash=options.hash||options.curve.hash}EC.prototype={},module.exports=EC,EC.prototype.keyPair=function(options){return new KeyPair(this,options)},EC.prototype.keyFromPrivate=function(priv,enc){return KeyPair.fromPrivate(this,priv,enc)},EC.prototype.keyFromPublic=function(pub,enc){return KeyPair.fromPublic(this,pub,enc)},EC.prototype.genKeyPair=function(options){options||(options={});for(var drbg=new HmacDRBG({hash:this.hash,pers:options.pers,persEnc:options.persEnc||\"utf8\",entropy:options.entropy||rand(this.hash.hmacStrength),entropyEnc:options.entropy&&options.entropyEnc||\"utf8\",nonce:this.n.toArray()}),bytes=this.n.byteLength(),ns2=this.n.sub(new BN(2));;){var priv=new BN(drbg.generate(bytes));if(!(priv.cmp(ns2)>0))return priv.iaddn(1),this.keyFromPrivate(priv)}},EC.prototype._truncateToN=function(msg,truncOnly){var delta=msg.byteLength()*8-this.n.bitLength();return delta>0&&(msg=msg.ushrn(delta)),!truncOnly&&msg.cmp(this.n)>=0\?msg.sub(this.n):msg},EC.prototype.sign=function(msg,key,enc,options){typeof enc==\"object\"&&(options=enc,enc=null),options||(options={}),key=this.keyFromPrivate(key,enc),msg=this._truncateToN(new BN(msg,16));for(var bytes=this.n.byteLength(),bkey=key.getPrivate().toArray(\"be\",bytes),nonce=msg.toArray(\"be\",bytes),drbg=new HmacDRBG({hash:this.hash,entropy:bkey,nonce,pers:options.pers,persEnc:options.persEnc||\"utf8\"}),ns1=this.n.sub(new BN(1)),iter=0;;iter++){var k=options.k\?options.k(iter):new BN(drbg.generate(this.n.byteLength()));if(k=this._truncateToN(k,!0),!(k.cmpn(1)<=0||k.cmp(ns1)>=0)){var kp=this.g.mul(k);if(!kp.isInfinity()){var kpX=kp.getX(),r=kpX.umod(this.n);if(r.cmpn(0)!==0){var s=k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));if(s=s.umod(this.n),s.cmpn(0)!==0){var recoveryParam=(kp.getY().isOdd()\?1:0)|(kpX.cmp(r)!==0\?2:0);return options.canonical&&s.cmp(this.nh)>0&&(s=this.n.sub(s),recoveryParam^=1),new Signature({r,s,recoveryParam})}}}}}},EC.prototype.verify=function(msg,signature,key,enc){msg=this._truncateToN(new BN(msg,16)),key=this.keyFromPublic(key,enc),signature=new Signature(signature,\"hex\");var{r,s}=signature;if(r.cmpn(1)<0||r.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var sinv=s.invm(this.n),u1=sinv.mul(msg).umod(this.n),u2=sinv.mul(r).umod(this.n),p;return this.curve._maxwellTrick\?(p=this.g.jmulAdd(u1,key.getPublic(),u2),p.isInfinity()\?!1:p.eqXToP(r)):(p=this.g.mulAdd(u1,key.getPublic(),u2),p.isInfinity()\?!1:p.getX().umod(this.n).cmp(r)===0)},EC.prototype.recoverPubKey=function(msg,signature,j,enc){assert((3&j)===j,\"The recovery param is more than two bits\"),signature=new Signature(signature,enc);var n=this.n,e=new BN(msg),r=signature.r,s=signature.s,isYOdd=j&1,isSecondKey=j>>1;if(r.cmp(this.curve.p.umod(this.curve.n))>=0&&isSecondKey)throw new Error(\"Unable to find sencond key candinate\");isSecondKey\?r=this.curve.pointFromX(r.add(this.curve.n),isYOdd):r=this.curve.pointFromX(r,isYOdd);var rInv=signature.r.invm(n),s1=n.sub(e).mul(rInv).umod(n),s2=s.mul(rInv).umod(n);return this.g.mulAdd(s1,r,s2)},EC.prototype.getKeyRecoveryParam=function(e,signature,Q,enc){if(signature=new Signature(signature,enc),signature.recoveryParam!==null)return signature.recoveryParam;for(var i=0;i<4;i++){var Qprime;try{Qprime=this.recoverPubKey(e,signature,i)}catch{continue}if(Qprime.eq(Q))return i}throw new Error(\"Unable to find valid recovery factor\")}}}),require_key2=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/key.js\"(exports,module){var utils=require_utils3(),assert=utils.assert,parseBytes=utils.parseBytes,cachedProperty=utils.cachedProperty;function KeyPair(eddsa,params){this.eddsa=eddsa,this._secret=parseBytes(params.secret),eddsa.isPoint(params.pub)\?this._pub=params.pub:this._pubBytes=parseBytes(params.pub)}KeyPair.prototype={},KeyPair.fromPublic=function(eddsa,pub){return pub instanceof KeyPair\?pub:new KeyPair(eddsa,{pub})},KeyPair.fromSecret=function(eddsa,secret){return secret instanceof KeyPair\?secret:new KeyPair(eddsa,{secret})},KeyPair.prototype.secret=function(){return this._secret},cachedProperty(KeyPair,\"pubBytes\",function(){return this.eddsa.encodePoint(this.pub())}),cachedProperty(KeyPair,\"pub\",function(){return this._pubBytes\?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),cachedProperty(KeyPair,\"privBytes\",function(){var eddsa=this.eddsa,hash=this.hash(),lastIx=eddsa.encodingLength-1,a=hash.slice(0,eddsa.encodingLength);return a[0]&=248,a[lastIx]&=127,a[lastIx]|=64,a}),cachedProperty(KeyPair,\"priv\",function(){return this.eddsa.decodeInt(this.privBytes())}),cachedProperty(KeyPair,\"hash\",function(){return this.eddsa.hash().update(this.secret()).digest()}),cachedProperty(KeyPair,\"messagePrefix\",function(){return this.hash().slice(this.eddsa.encodingLength)}),KeyPair.prototype.sign=function(message){return assert(this._secret,\"KeyPair can only verify\"),this.eddsa.sign(message,this)},KeyPair.prototype.verify=function(message,sig){return this.eddsa.verify(message,sig,this)},KeyPair.prototype.getSecret=function(enc){return assert(this._secret,\"KeyPair is public only\"),utils.encode(this.secret(),enc)},KeyPair.prototype.getPublic=function(enc){return utils.encode(this.pubBytes(),enc)},module.exports=KeyPair}}),require_signature2=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/signature.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),assert=utils.assert,cachedProperty=utils.cachedProperty,parseBytes=utils.parseBytes;function Signature(eddsa,sig){this.eddsa=eddsa,typeof sig!=\"object\"&&(sig=parseBytes(sig)),Array.isArray(sig)&&(sig={R:sig.slice(0,eddsa.encodingLength),S:sig.slice(eddsa.encodingLength)}),assert(sig.R&&sig.S,\"Signature without R or S\"),eddsa.isPoint(sig.R)&&(this._R=sig.R),sig.S instanceof BN&&(this._S=sig.S),this._Rencoded=Array.isArray(sig.R)\?sig.R:sig.Rencoded,this._Sencoded=Array.isArray(sig.S)\?sig.S:sig.Sencoded}Signature.prototype={},cachedProperty(Signature,\"S\",function(){return this.eddsa.decodeInt(this.Sencoded())}),cachedProperty(Signature,\"R\",function(){return this.eddsa.decodePoint(this.Rencoded())}),cachedProperty(Signature,\"Rencoded\",function(){return this.eddsa.encodePoint(this.R())}),cachedProperty(Signature,\"Sencoded\",function(){return this.eddsa.encodeInt(this.S())}),Signature.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Signature.prototype.toHex=function(){return utils.encode(this.toBytes(),\"hex\").toUpperCase()},module.exports=Signature}}),require_eddsa=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/index.js\"(exports,module){var hash=require_hash2(),curves=require_curves(),utils=require_utils3(),assert=utils.assert,parseBytes=utils.parseBytes,KeyPair=require_key2(),Signature=require_signature2();function EDDSA(curve){if(assert(curve===\"ed25519\",\"only tested with ed25519 so far\"),!(this instanceof EDDSA))return new EDDSA(curve);curve=curves[curve].curve,this.curve=curve,this.g=curve.g,this.g.precompute(curve.n.bitLength()+1),this.pointClass=curve.point().constructor,this.encodingLength=Math.ceil(curve.n.bitLength()/8),this.hash=hash.sha512}EDDSA.prototype={},module.exports=EDDSA,EDDSA.prototype.sign=function(message,secret){message=parseBytes(message);var key=this.keyFromSecret(secret),r=this.hashInt(key.messagePrefix(),message),R=this.g.mul(r),Rencoded=this.encodePoint(R),s_=this.hashInt(Rencoded,key.pubBytes(),message).mul(key.priv()),S=r.add(s_).umod(this.curve.n);return this.makeSignature({R,S,Rencoded})},EDDSA.prototype.verify=function(message,sig,pub){message=parseBytes(message),sig=this.makeSignature(sig);var key=this.keyFromPublic(pub),h=this.hashInt(sig.Rencoded(),key.pubBytes(),message),SG=this.g.mul(sig.S()),RplusAh=sig.R().add(key.pub().mul(h));return RplusAh.eq(SG)},EDDSA.prototype.hashInt=function(){for(var hash2=this.hash(),i=0;i\"u\")@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof value);return Buffer2(value,encodingOrOffset,length)}),Safer.alloc||(Safer.alloc=function(size,fill,encoding){if(typeof size!=\"number\")@throwTypeError('The \"size\" argument must be of type number. Received type '+typeof size);if(size<0||size>=2*(1<<30))@throwRangeError('The value \"'+size+'\" is invalid for option \"size\"');var buf=Buffer2(size);return!fill||fill.length===0\?buf.fill(0):typeof encoding==\"string\"\?buf.fill(fill,encoding):buf.fill(fill),buf}),!safer.kStringMaxLength)try{safer.kStringMaxLength=MAX_STRING_LENGTH}catch{}safer.constants||(safer.constants={MAX_LENGTH:safer.kMaxLength},safer.kStringMaxLength&&(safer.constants.MAX_STRING_LENGTH=safer.kStringMaxLength)),module.exports=safer}}),require_reporter=__commonJS({\"node_modules/asn1.js/lib/asn1/base/reporter.js\"(exports){var inherits=require_inherits_browser();function Reporter(options){this._reporterState={obj:null,path:[],options:options||{},errors:[]}}Reporter.prototype={},exports.Reporter=Reporter,Reporter.prototype.isError=function(obj){return obj instanceof ReporterError},Reporter.prototype.save=function(){let state=this._reporterState;return{obj:state.obj,pathLen:state.path.length}},Reporter.prototype.restore=function(data){let state=this._reporterState;state.obj=data.obj,state.path=state.path.slice(0,data.pathLen)},Reporter.prototype.enterKey=function(key){return this._reporterState.path.push(key)},Reporter.prototype.exitKey=function(index){let state=this._reporterState;state.path=state.path.slice(0,index-1)},Reporter.prototype.leaveKey=function(index,key,value){let state=this._reporterState;this.exitKey(index),state.obj!==null&&(state.obj[key]=value)},Reporter.prototype.path=function(){return this._reporterState.path.join(\"/\")},Reporter.prototype.enterObject=function(){let state=this._reporterState,prev=state.obj;return state.obj={},prev},Reporter.prototype.leaveObject=function(prev){let state=this._reporterState,now=state.obj;return state.obj=prev,now},Reporter.prototype.error=function(msg){let err,state=this._reporterState,inherited=msg instanceof ReporterError;if(inherited\?err=msg:err=new ReporterError(state.path.map(function(elem){return\"[\"+JSON.stringify(elem)+\"]\"}).join(\"\"),msg.message||msg,msg.stack),!state.options.partial)throw err;return inherited||state.errors.push(err),err},Reporter.prototype.wrapResult=function(result){let state=this._reporterState;return state.options.partial\?{result:this.isError(result)\?null:result,errors:state.errors}:result};function ReporterError(path,msg){this.path=path,this.rethrow(msg)}inherits(ReporterError,Error),ReporterError.prototype.rethrow=function(msg){if(this.message=msg+\" at: \"+(this.path||\"(shallow)\"),Error.captureStackTrace&&Error.captureStackTrace(this,ReporterError),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}}}),require_buffer=__commonJS({\"node_modules/asn1.js/lib/asn1/base/buffer.js\"(exports){var inherits=require_inherits_browser(),Reporter=require_reporter().Reporter,Buffer2=require_safer().Buffer;function DecoderBuffer(base,options){if(Reporter.call(this,options),!Buffer2.isBuffer(base)){this.error(\"Input not Buffer\");return}this.base=base,this.offset=0,this.length=base.length}inherits(DecoderBuffer,Reporter),exports.DecoderBuffer=DecoderBuffer,DecoderBuffer.isDecoderBuffer=function(data){return data instanceof DecoderBuffer\?!0:typeof data==\"object\"&&Buffer2.isBuffer(data.base)&&data.constructor.name===\"DecoderBuffer\"&&typeof data.offset==\"number\"&&typeof data.length==\"number\"&&typeof data.save==\"function\"&&typeof data.restore==\"function\"&&typeof data.isEmpty==\"function\"&&typeof data.readUInt8==\"function\"&&typeof data.skip==\"function\"&&typeof data.raw==\"function\"},DecoderBuffer.prototype.save=function(){return{offset:this.offset,reporter:Reporter.prototype.save.call(this)}},DecoderBuffer.prototype.restore=function(save){let res=new DecoderBuffer(this.base);return res.offset=save.offset,res.length=this.offset,this.offset=save.offset,Reporter.prototype.restore.call(this,save.reporter),res},DecoderBuffer.prototype.isEmpty=function(){return this.offset===this.length},DecoderBuffer.prototype.readUInt8=function(fail){return this.offset+1<=this.length\?this.base.readUInt8(this.offset++,!0):this.error(fail||\"DecoderBuffer overrun\")},DecoderBuffer.prototype.skip=function(bytes,fail){if(!(this.offset+bytes<=this.length))return this.error(fail||\"DecoderBuffer overrun\");let res=new DecoderBuffer(this.base);return res._reporterState=this._reporterState,res.offset=this.offset,res.length=this.offset+bytes,this.offset+=bytes,res},DecoderBuffer.prototype.raw=function(save){return this.base.slice(save\?save.offset:this.offset,this.length)};function EncoderBuffer(value,reporter){if(Array.isArray(value))this.length=0,this.value=value.map(function(item){return EncoderBuffer.isEncoderBuffer(item)||(item=new EncoderBuffer(item,reporter)),this.length+=item.length,item},this);else if(typeof value==\"number\"){if(!(0<=value&&value<=255))return reporter.error(\"non-byte EncoderBuffer value\");this.value=value,this.length=1}else if(typeof value==\"string\")this.value=value,this.length=Buffer2.byteLength(value);else if(Buffer2.isBuffer(value))this.value=value,this.length=value.length;else return reporter.error(\"Unsupported type: \"+typeof value)}EncoderBuffer.prototype={},exports.EncoderBuffer=EncoderBuffer,EncoderBuffer.isEncoderBuffer=function(data){return data instanceof EncoderBuffer\?!0:typeof data==\"object\"&&data.constructor.name===\"EncoderBuffer\"&&typeof data.length==\"number\"&&typeof data.join==\"function\"},EncoderBuffer.prototype.join=function(out,offset){return out||(out=Buffer2.alloc(this.length)),offset||(offset=0),this.length===0||(Array.isArray(this.value)\?this.value.forEach(function(item){item.join(out,offset),offset+=item.length}):(typeof this.value==\"number\"\?out[offset]=this.value:typeof this.value==\"string\"\?out.write(this.value,offset):Buffer2.isBuffer(this.value)&&this.value.copy(out,offset),offset+=this.length)),out}}}),require_node=__commonJS({\"node_modules/asn1.js/lib/asn1/base/node.js\"(exports,module){var Reporter=require_reporter().Reporter,EncoderBuffer=require_buffer().EncoderBuffer,DecoderBuffer=require_buffer().DecoderBuffer,assert=require_minimalistic_assert(),tags=[\"seq\",\"seqof\",\"set\",\"setof\",\"objid\",\"bool\",\"gentime\",\"utctime\",\"null_\",\"enum\",\"int\",\"objDesc\",\"bitstr\",\"bmpstr\",\"charstr\",\"genstr\",\"graphstr\",\"ia5str\",\"iso646str\",\"numstr\",\"octstr\",\"printstr\",\"t61str\",\"unistr\",\"utf8str\",\"videostr\"],methods=[\"key\",\"obj\",\"use\",\"optional\",\"explicit\",\"implicit\",\"def\",\"choice\",\"any\",\"contains\"].concat(tags),overrided=[\"_peekTag\",\"_decodeTag\",\"_use\",\"_decodeStr\",\"_decodeObjid\",\"_decodeTime\",\"_decodeNull\",\"_decodeInt\",\"_decodeBool\",\"_decodeList\",\"_encodeComposite\",\"_encodeStr\",\"_encodeObjid\",\"_encodeTime\",\"_encodeNull\",\"_encodeInt\",\"_encodeBool\"];function Node(enc,parent,name){let state={};this._baseState=state,state.name=name,state.enc=enc,state.parent=parent||null,state.children=null,state.tag=null,state.args=null,state.reverseArgs=null,state.choice=null,state.optional=!1,state.any=!1,state.obj=!1,state.use=null,state.useDecoder=null,state.key=null,state.default=null,state.explicit=null,state.implicit=null,state.contains=null,state.parent||(state.children=[],this._wrap())}Node.prototype={},module.exports=Node;var stateProps=[\"enc\",\"parent\",\"children\",\"tag\",\"args\",\"reverseArgs\",\"choice\",\"optional\",\"any\",\"obj\",\"use\",\"alteredUse\",\"key\",\"default\",\"explicit\",\"implicit\",\"contains\"];Node.prototype.clone=function(){let state=this._baseState,cstate={};stateProps.forEach(function(prop){cstate[prop]=state[prop]});let res=new this.constructor(cstate.parent);return res._baseState=cstate,res},Node.prototype._wrap=function(){let state=this._baseState;methods.forEach(function(method){this[method]=function(){let clone=new this.constructor(this);return state.children.push(clone),clone[method].apply(clone,arguments)}},this)},Node.prototype._init=function(body){let state=this._baseState;assert(state.parent===null),body.call(this),state.children=state.children.filter(function(child){return child._baseState.parent===this},this),assert.equal(state.children.length,1,\"Root node can have only one child\")},Node.prototype._useArgs=function(args){let state=this._baseState,children=args.filter(function(arg){return arg instanceof this.constructor},this);args=args.filter(function(arg){return!(arg instanceof this.constructor)},this),children.length!==0&&(assert(state.children===null),state.children=children,children.forEach(function(child){child._baseState.parent=this},this)),args.length!==0&&(assert(state.args===null),state.args=args,state.reverseArgs=args.map(function(arg){if(typeof arg!=\"object\"||arg.constructor!==Object)return arg;let res={};return Object.keys(arg).forEach(function(key){key==(key|0)&&(key|=0);let value=arg[key];res[value]=key}),res}))},overrided.forEach(function(method){Node.prototype[method]=function(){let state=this._baseState;throw new Error(method+\" not implemented for encoding: \"+state.enc)}}),tags.forEach(function(tag){Node.prototype[tag]=function(){let state=this._baseState,args=Array.prototype.slice.call(arguments);return assert(state.tag===null),state.tag=tag,this._useArgs(args),this}}),Node.prototype.use=function(item){assert(item);let state=this._baseState;return assert(state.use===null),state.use=item,this},Node.prototype.optional=function(){let state=this._baseState;return state.optional=!0,this},Node.prototype.def=function(val){let state=this._baseState;return assert(state.default===null),state.default=val,state.optional=!0,this},Node.prototype.explicit=function(num){let state=this._baseState;return assert(state.explicit===null&&state.implicit===null),state.explicit=num,this},Node.prototype.implicit=function(num){let state=this._baseState;return assert(state.explicit===null&&state.implicit===null),state.implicit=num,this},Node.prototype.obj=function(){let state=this._baseState,args=Array.prototype.slice.call(arguments);return state.obj=!0,args.length!==0&&this._useArgs(args),this},Node.prototype.key=function(newKey){let state=this._baseState;return assert(state.key===null),state.key=newKey,this},Node.prototype.any=function(){let state=this._baseState;return state.any=!0,this},Node.prototype.choice=function(obj){let state=this._baseState;return assert(state.choice===null),state.choice=obj,this._useArgs(Object.keys(obj).map(function(key){return obj[key]})),this},Node.prototype.contains=function(item){let state=this._baseState;return assert(state.use===null),state.contains=item,this},Node.prototype._decode=function(input,options){let state=this._baseState;if(state.parent===null)return input.wrapResult(state.children[0]._decode(input,options));let result=state.default,present=!0,prevKey=null;if(state.key!==null&&(prevKey=input.enterKey(state.key)),state.optional){let tag=null;if(state.explicit!==null\?tag=state.explicit:state.implicit!==null\?tag=state.implicit:state.tag!==null&&(tag=state.tag),tag===null&&!state.any){let save=input.save();try{state.choice===null\?this._decodeGeneric(state.tag,input,options):this._decodeChoice(input,options),present=!0}catch{present=!1}input.restore(save)}else if(present=this._peekTag(input,tag,state.any),input.isError(present))return present}let prevObj;if(state.obj&&present&&(prevObj=input.enterObject()),present){if(state.explicit!==null){let explicit=this._decodeTag(input,state.explicit);if(input.isError(explicit))return explicit;input=explicit}let start=input.offset;if(state.use===null&&state.choice===null){let save;state.any&&(save=input.save());let body=this._decodeTag(input,state.implicit!==null\?state.implicit:state.tag,state.any);if(input.isError(body))return body;state.any\?result=input.raw(save):input=body}if(options&&options.track&&state.tag!==null&&options.track(input.path(),start,input.length,\"tagged\"),options&&options.track&&state.tag!==null&&options.track(input.path(),input.offset,input.length,\"content\"),state.any||(state.choice===null\?result=this._decodeGeneric(state.tag,input,options):result=this._decodeChoice(input,options)),input.isError(result))return result;if(!state.any&&state.choice===null&&state.children!==null&&state.children.forEach(function(child){child._decode(input,options)}),state.contains&&(state.tag===\"octstr\"||state.tag===\"bitstr\")){let data=new DecoderBuffer(result);result=this._getUse(state.contains,input._reporterState.obj)._decode(data,options)}}return state.obj&&present&&(result=input.leaveObject(prevObj)),state.key!==null&&(result!==null||present===!0)\?input.leaveKey(prevKey,state.key,result):prevKey!==null&&input.exitKey(prevKey),result},Node.prototype._decodeGeneric=function(tag,input,options){let state=this._baseState;return tag===\"seq\"||tag===\"set\"\?null:tag===\"seqof\"||tag===\"setof\"\?this._decodeList(input,tag,state.args[0],options):/str$/.test(tag)\?this._decodeStr(input,tag,options):tag===\"objid\"&&state.args\?this._decodeObjid(input,state.args[0],state.args[1],options):tag===\"objid\"\?this._decodeObjid(input,null,null,options):tag===\"gentime\"||tag===\"utctime\"\?this._decodeTime(input,tag,options):tag===\"null_\"\?this._decodeNull(input,options):tag===\"bool\"\?this._decodeBool(input,options):tag===\"objDesc\"\?this._decodeStr(input,tag,options):tag===\"int\"||tag===\"enum\"\?this._decodeInt(input,state.args&&state.args[0],options):state.use!==null\?this._getUse(state.use,input._reporterState.obj)._decode(input,options):input.error(\"unknown tag: \"+tag)},Node.prototype._getUse=function(entity,obj){let state=this._baseState;return state.useDecoder=this._use(entity,obj),assert(state.useDecoder._baseState.parent===null),state.useDecoder=state.useDecoder._baseState.children[0],state.implicit!==state.useDecoder._baseState.implicit&&(state.useDecoder=state.useDecoder.clone(),state.useDecoder._baseState.implicit=state.implicit),state.useDecoder},Node.prototype._decodeChoice=function(input,options){let state=this._baseState,result=null,match=!1;return Object.keys(state.choice).some(function(key){let save=input.save(),node=state.choice[key];try{let value=node._decode(input,options);if(input.isError(value))return!1;result={type:key,value},match=!0}catch{return input.restore(save),!1}return!0},this),match\?result:input.error(\"Choice not matched\")},Node.prototype._createEncoderBuffer=function(data){return new EncoderBuffer(data,this.reporter)},Node.prototype._encode=function(data,reporter,parent){let state=this._baseState;if(state.default!==null&&state.default===data)return;let result=this._encodeValue(data,reporter,parent);if(result!==void 0&&!this._skipDefault(result,reporter,parent))return result},Node.prototype._encodeValue=function(data,reporter,parent){let state=this._baseState;if(state.parent===null)return state.children[0]._encode(data,reporter||new Reporter);let result=null;if(this.reporter=reporter,state.optional&&data===void 0)if(state.default!==null)data=state.default;else return;let content=null,primitive=!1;if(state.any)result=this._createEncoderBuffer(data);else if(state.choice)result=this._encodeChoice(data,reporter);else if(state.contains)content=this._getUse(state.contains,parent)._encode(data,reporter),primitive=!0;else if(state.children)content=state.children.map(function(child){if(child._baseState.tag===\"null_\")return child._encode(null,reporter,data);if(child._baseState.key===null)return reporter.error(\"Child should have a key\");let prevKey=reporter.enterKey(child._baseState.key);if(typeof data!=\"object\")return reporter.error(\"Child expected, but input is not object\");let res=child._encode(data[child._baseState.key],reporter,data);return reporter.leaveKey(prevKey),res},this).filter(function(child){return child}),content=this._createEncoderBuffer(content);else if(state.tag===\"seqof\"||state.tag===\"setof\"){if(!(state.args&&state.args.length===1))return reporter.error(\"Too many args for : \"+state.tag);if(!Array.isArray(data))return reporter.error(\"seqof/setof, but data is not Array\");let child=this.clone();child._baseState.implicit=null,content=this._createEncoderBuffer(data.map(function(item){let state2=this._baseState;return this._getUse(state2.args[0],data)._encode(item,reporter)},child))}else state.use!==null\?result=this._getUse(state.use,parent)._encode(data,reporter):(content=this._encodePrimitive(state.tag,data),primitive=!0);if(!state.any&&state.choice===null){let tag=state.implicit!==null\?state.implicit:state.tag,cls=state.implicit===null\?\"universal\":\"context\";tag===null\?state.use===null&&reporter.error(\"Tag could be omitted only for .use()\"):state.use===null&&(result=this._encodeComposite(tag,primitive,cls,content))}return state.explicit!==null&&(result=this._encodeComposite(state.explicit,!1,\"context\",result)),result},Node.prototype._encodeChoice=function(data,reporter){let state=this._baseState,node=state.choice[data.type];return node||assert(!1,data.type+\" not found in \"+JSON.stringify(Object.keys(state.choice))),node._encode(data.value,reporter)},Node.prototype._encodePrimitive=function(tag,data){let state=this._baseState;if(/str$/.test(tag))return this._encodeStr(data,tag);if(tag===\"objid\"&&state.args)return this._encodeObjid(data,state.reverseArgs[0],state.args[1]);if(tag===\"objid\")return this._encodeObjid(data,null,null);if(tag===\"gentime\"||tag===\"utctime\")return this._encodeTime(data,tag);if(tag===\"null_\")return this._encodeNull();if(tag===\"int\"||tag===\"enum\")return this._encodeInt(data,state.args&&state.reverseArgs[0]);if(tag===\"bool\")return this._encodeBool(data);if(tag===\"objDesc\")return this._encodeStr(data,tag);throw new Error(\"Unsupported tag: \"+tag)},Node.prototype._isNumstr=function(str){return/^[0-9 ]*$/.test(str)},Node.prototype._isPrintstr=function(str){return/^[A-Za-z0-9 '()+,-./:=\?]*$/.test(str)}}}),require_der=__commonJS({\"node_modules/asn1.js/lib/asn1/constants/der.js\"(exports){function reverse(map){let res={};return Object.keys(map).forEach(function(key){(key|0)==key&&(key=key|0);let value=map[key];res[value]=key}),res}exports.tagClass={0:\"universal\",1:\"application\",2:\"context\",3:\"private\"},exports.tagClassByName=reverse(exports.tagClass),exports.tag={0:\"end\",1:\"bool\",2:\"int\",3:\"bitstr\",4:\"octstr\",5:\"null_\",6:\"objid\",7:\"objDesc\",8:\"external\",9:\"real\",10:\"enum\",11:\"embed\",12:\"utf8str\",13:\"relativeOid\",16:\"seq\",17:\"set\",18:\"numstr\",19:\"printstr\",20:\"t61str\",21:\"videostr\",22:\"ia5str\",23:\"utctime\",24:\"gentime\",25:\"graphstr\",26:\"iso646str\",27:\"genstr\",28:\"unistr\",29:\"charstr\",30:\"bmpstr\"},exports.tagByName=reverse(exports.tag)}}),require_der2=__commonJS({\"node_modules/asn1.js/lib/asn1/encoders/der.js\"(exports,module){var inherits=require_inherits_browser(),Buffer2=require_safer().Buffer,Node=require_node(),der=require_der();function DEREncoder(entity){this.enc=\"der\",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}DEREncoder.prototype={},module.exports=DEREncoder,DEREncoder.prototype.encode=function(data,reporter){return this.tree._encode(data,reporter).join()};function DERNode(parent){Node.call(this,\"der\",parent)}inherits(DERNode,Node),DERNode.prototype._encodeComposite=function(tag,primitive,cls,content){let encodedTag=encodeTag(tag,primitive,cls,this.reporter);if(content.length<128){let header2=Buffer2.alloc(2);return header2[0]=encodedTag,header2[1]=content.length,this._createEncoderBuffer([header2,content])}let lenOctets=1;for(let i=content.length;i>=256;i>>=8)lenOctets++;let header=Buffer2.alloc(2+lenOctets);header[0]=encodedTag,header[1]=128|lenOctets;for(let i=1+lenOctets,j=content.length;j>0;i--,j>>=8)header[i]=j&255;return this._createEncoderBuffer([header,content])},DERNode.prototype._encodeStr=function(str,tag){if(tag===\"bitstr\")return this._createEncoderBuffer([str.unused|0,str.data]);if(tag===\"bmpstr\"){let buf=Buffer2.alloc(str.length*2);for(let i=0;i=40)return this.reporter.error(\"Second objid identifier OOB\");id.splice(0,2,id[0]*40+id[1])}let size=0;for(let i=0;i=128;ident>>=7)size++}let objid=Buffer2.alloc(size),offset=objid.length-1;for(let i=id.length-1;i>=0;i--){let ident=id[i];for(objid[offset--]=ident&127;(ident>>=7)>0;)objid[offset--]=128|ident&127}return this._createEncoderBuffer(objid)};function two(num){return num<10\?\"0\"+num:num}DERNode.prototype._encodeTime=function(time,tag){let str,date=new Date(time);return tag===\"gentime\"\?str=[two(date.getUTCFullYear()),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),\"Z\"].join(\"\"):tag===\"utctime\"\?str=[two(date.getUTCFullYear()%100),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),\"Z\"].join(\"\"):this.reporter.error(\"Encoding \"+tag+\" time is not supported yet\"),this._encodeStr(str,\"octstr\")},DERNode.prototype._encodeNull=function(){return this._createEncoderBuffer(\"\")},DERNode.prototype._encodeInt=function(num,values){if(typeof num==\"string\"){if(!values)return this.reporter.error(\"String int or enum given, but no values map\");if(!values.hasOwnProperty(num))return this.reporter.error(\"Values map doesn't contain: \"+JSON.stringify(num));num=values[num]}if(typeof num!=\"number\"&&!Buffer2.isBuffer(num)){let numArray=num.toArray();!num.sign&&numArray[0]&128&&numArray.unshift(0),num=Buffer2.from(numArray)}if(Buffer2.isBuffer(num)){let size2=num.length;num.length===0&&size2++;let out2=Buffer2.alloc(size2);return num.copy(out2),num.length===0&&(out2[0]=0),this._createEncoderBuffer(out2)}if(num<128)return this._createEncoderBuffer(num);if(num<256)return this._createEncoderBuffer([0,num]);let size=1;for(let i=num;i>=256;i>>=8)size++;let out=new Array(size);for(let i=out.length-1;i>=0;i--)out[i]=num&255,num>>=8;return out[0]&128&&out.unshift(0),this._createEncoderBuffer(Buffer2.from(out))},DERNode.prototype._encodeBool=function(value){return this._createEncoderBuffer(value\?255:0)},DERNode.prototype._use=function(entity,obj){return typeof entity==\"function\"&&(entity=entity(obj)),entity._getEncoder(\"der\").tree},DERNode.prototype._skipDefault=function(dataBuffer,reporter,parent){let state=this._baseState,i;if(state.default===null)return!1;let data=dataBuffer.join();if(state.defaultBuffer===void 0&&(state.defaultBuffer=this._encodeValue(state.default,reporter,parent).join()),data.length!==state.defaultBuffer.length)return!1;for(i=0;i=31\?reporter.error(\"Multi-octet tag encoding unsupported\"):(primitive||(res|=32),res|=der.tagClassByName[cls||\"universal\"]<<6,res)}}}),require_pem=__commonJS({\"node_modules/asn1.js/lib/asn1/encoders/pem.js\"(exports,module){var inherits=require_inherits_browser(),DEREncoder=require_der2();function PEMEncoder(entity){DEREncoder.call(this,entity),this.enc=\"pem\"}inherits(PEMEncoder,DEREncoder),module.exports=PEMEncoder,PEMEncoder.prototype.encode=function(data,options){let p=DEREncoder.prototype.encode.call(this,data).toString(\"base64\"),out=[\"-----BEGIN \"+options.label+\"-----\"];for(let i=0;i>6],primitive=(tag&32)===0;if((tag&31)===31){let oct=tag;for(tag=0;(oct&128)===128;){if(oct=buf.readUInt8(fail),buf.isError(oct))return oct;tag<<=7,tag|=oct&127}}else tag&=31;let tagStr=der.tag[tag];return{cls,primitive,tag,tagStr}}function derDecodeLen(buf,primitive,fail){let len=buf.readUInt8(fail);if(buf.isError(len))return len;if(!primitive&&len===128)return null;if((len&128)===0)return len;let num=len&127;if(num>4)return buf.error(\"length octect is too long\");len=0;for(let i=0;i0&&bits.ishrn(shift),bits}function bits2octets(bits,q){bits=bits2int(bits,q),bits=bits.mod(q);var out=Buffer2.from(bits.toArray());if(out.length=q)throw new Error(\"invalid sig\")}module.exports=verify}}),require_browser8=__commonJS({\"node_modules/browserify-sign/browser/index.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,createHash=require_browser2(),inherits=require_inherits_browser(),sign=require_sign(),verify=require_verify(),algorithms=require_algorithms();Object.keys(algorithms).forEach(function(key){algorithms[key].id=Buffer2.from(algorithms[key].id,\"hex\"),algorithms[key.toLowerCase()]=algorithms[key]});function Sign(algorithm){StreamModule.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error(\"Unknown message digest\");this._hashType=data.hash,this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Sign,StreamModule.Writable),Sign.prototype._write=function(data,_,done){this._hash.update(data),done()},Sign.prototype.update=function(data,enc){return typeof data==\"string\"&&(data=Buffer2.from(data,enc)),this._hash.update(data),this},Sign.prototype.sign=function(key,enc){this.end();var hash=this._hash.digest(),sig=sign(hash,key,this._hashType,this._signType,this._tag);return enc\?sig.toString(enc):sig};function Verify(algorithm){StreamModule.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error(\"Unknown message digest\");this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Verify,StreamModule.Writable),Verify.prototype._write=function(data,_,done){this._hash.update(data),done()},Verify.prototype.update=function(data,enc){return typeof data==\"string\"&&(data=Buffer2.from(data,enc)),this._hash.update(data),this},Verify.prototype.verify=function(key,sig,enc){typeof sig==\"string\"&&(sig=Buffer2.from(sig,enc)),this.end();var hash=this._hash.digest();return verify(sig,hash,key,this._signType,this._tag)};function createSign(algorithm){return new Sign(algorithm)}function createVerify(algorithm){return new Verify(algorithm)}module.exports={Sign:createSign,Verify:createVerify,createSign,createVerify}}}),require_bn6=require_bn,require_browser9=__commonJS({\"node_modules/create-ecdh/browser.js\"(exports,module){var elliptic=require_elliptic(),BN=require_bn6();module.exports=function(curve){return new ECDH(curve)};var aliases={secp256k1:{name:\"secp256k1\",byteLength:32},secp224r1:{name:\"p224\",byteLength:28},prime256v1:{name:\"p256\",byteLength:32},prime192v1:{name:\"p192\",byteLength:24},ed25519:{name:\"ed25519\",byteLength:32},secp384r1:{name:\"p384\",byteLength:48},secp521r1:{name:\"p521\",byteLength:66}};aliases.p224=aliases.secp224r1,aliases.p256=aliases.secp256r1=aliases.prime256v1,aliases.p192=aliases.secp192r1=aliases.prime192v1,aliases.p384=aliases.secp384r1,aliases.p521=aliases.secp521r1;function ECDH(curve){this.curveType=aliases[curve],this.curveType||(this.curveType={name:curve}),this.curve=new elliptic.ec(this.curveType.name),this.keys=void 0}ECDH.prototype={},ECDH.prototype.generateKeys=function(enc,format){return this.keys=this.curve.genKeyPair(),this.getPublicKey(enc,format)},ECDH.prototype.computeSecret=function(other,inenc,enc){inenc=inenc||\"utf8\",Buffer.isBuffer(other)||(other=new Buffer(other,inenc));var otherPub=this.curve.keyFromPublic(other).getPublic(),out=otherPub.mul(this.keys.getPrivate()).getX();return formatReturnValue(out,enc,this.curveType.byteLength)},ECDH.prototype.getPublicKey=function(enc,format){var key=this.keys.getPublic(format===\"compressed\",!0);return format===\"hybrid\"&&(key[key.length-1]%2\?key[0]=7:key[0]=6),formatReturnValue(key,enc)},ECDH.prototype.getPrivateKey=function(enc){return formatReturnValue(this.keys.getPrivate(),enc)},ECDH.prototype.setPublicKey=function(pub,enc){return enc=enc||\"utf8\",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this.keys._importPublic(pub),this},ECDH.prototype.setPrivateKey=function(priv,enc){enc=enc||\"utf8\",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc));var _priv=new BN(priv);return _priv=_priv.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(_priv),this};function formatReturnValue(bn,enc,len){Array.isArray(bn)||(bn=bn.toArray());var buf=new Buffer(bn);if(len&&buf.length=0)throw new Error(\"data too long for modulus\")}else throw new Error(\"unknown padding\");return reverse\?crt(paddedMsg,key):withPublic(paddedMsg,key)};function oaep(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash(\"sha1\").update(Buffer2.alloc(0)).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error(\"message too long\");var ps=Buffer2.alloc(k-mLen-hLen2-2),dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer2.concat([iHash,ps,Buffer2.alloc(1,1),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new BN(Buffer2.concat([Buffer2.alloc(1),maskedSeed,maskedDb],k))}function pkcs1(key,msg,reverse){var mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error(\"message too long\");var ps;return reverse\?ps=Buffer2.alloc(k-mLen-3,255):ps=nonZero(k-mLen-3),new BN(Buffer2.concat([Buffer2.from([0,reverse\?1:2]),ps,Buffer2.alloc(1),msg],k))}function nonZero(len){for(var out=Buffer2.allocUnsafe(len),i=0,cache=randomBytes(len*2),cur=0,num;ik||new BN(enc).cmp(key.modulus)>=0)throw new Error(\"decryption error\");var msg;reverse\?msg=withPublic(new BN(enc),key):msg=crt(enc,key);var zBuffer=Buffer2.alloc(k-msg.length);if(msg=Buffer2.concat([zBuffer,msg],k),padding===4)return oaep(key,msg);if(padding===1)return pkcs1(key,msg,reverse);if(padding===3)return msg;throw new Error(\"unknown padding\")};function oaep(key,msg){var k=key.modulus.byteLength(),iHash=createHash(\"sha1\").update(Buffer2.alloc(0)).digest(),hLen=iHash.length;if(msg[0]!==0)throw new Error(\"decryption error\");var maskedSeed=msg.slice(1,hLen+1),maskedDb=msg.slice(hLen+1),seed=xor(maskedSeed,mgf(maskedDb,hLen)),db=xor(maskedDb,mgf(seed,k-hLen-1));if(compare(iHash,db.slice(0,hLen)))throw new Error(\"decryption error\");for(var i=hLen;db[i]===0;)i++;if(db[i++]!==1)throw new Error(\"decryption error\");return db.slice(i)}function pkcs1(key,msg,reverse){for(var p1=msg.slice(0,2),i=2,status=0;msg[i++]!==0;)if(i>=msg.length){status++;break}var ps=msg.slice(2,i-1);if((p1.toString(\"hex\")!==\"0002\"&&!reverse||p1.toString(\"hex\")!==\"0001\"&&reverse)&&status++,ps.length<8&&status++,status)throw new Error(\"decryption error\");return msg.slice(i)}function compare(a,b){a=Buffer2.from(a),b=Buffer2.from(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=Math.min(a.length,b.length));for(var i=-1;++ikMaxUint32||offset<0)@throwTypeError(\"offset must be a uint32\");if(offset>kBufferMaxLength||offset>length)@throwRangeError(\"offset out of range\")}function assertSize(size,offset,length){if(typeof size!=\"number\"||size!==size)@throwTypeError(\"size must be a number\");if(size>kMaxUint32||size<0)@throwTypeError(\"size must be a uint32\");if(size+offset>length||size>kBufferMaxLength)@throwRangeError(\"buffer too small\")}exports.randomFill=randomFill,exports.randomFillSync=randomFillSync;function randomFill(buf,offset,size,cb){if(!Buffer2.isBuffer(buf)&&!(buf instanceof global.Uint8Array))@throwTypeError('\"buf\" argument must be a Buffer or Uint8Array');if(typeof offset==\"function\")cb=offset,offset=0,size=buf.length;else if(typeof size==\"function\")cb=size,size=buf.length-offset;else if(typeof cb!=\"function\")@throwTypeError('\"cb\" argument must be a function');return assertOffset(offset,buf.length),assertSize(size,offset,buf.length),actualFill(buf,offset,size,cb)}function actualFill(buf,offset,size,cb){if(cb){randombytes(size,function(err,bytes2){if(err)return cb(err);bytes2.copy(buf,offset),cb(null,buf)});return}var bytes=randombytes(size);return bytes.copy(buf,offset),buf}function randomFillSync(buf,offset,size){if(typeof offset>\"u\"&&(offset=0),!Buffer2.isBuffer(buf)&&!(buf instanceof global.Uint8Array))@throwTypeError('\"buf\" argument must be a Buffer or Uint8Array');return assertOffset(offset,buf.length),size===void 0&&(size=buf.length-offset),assertSize(size,offset,buf.length),actualFill(buf,offset,size)}}}),require_crypto_browserify2=__commonJS({\"node_modules/crypto-browserify/index.js\"(exports){exports.randomBytes=exports.rng=exports.pseudoRandomBytes=exports.prng=require_browser(),exports.createHash=require_browser2(),exports.Hash=exports.createHash.Hash,exports.createHmac=exports.Hmac=require_browser3();var algos=require_algos(),algoKeys=Object.keys(algos),hashes=[\"sha1\",\"sha224\",\"sha256\",\"sha384\",\"sha512\",\"md5\",\"rmd160\"].concat(algoKeys);exports.getHashes=function(){return hashes};var p=require_browser4();exports.pbkdf2=p.pbkdf2,exports.pbkdf2Sync=p.pbkdf2Sync;var aes=require_browser6();exports.Cipher=aes.Cipher,exports.createCipher=aes.createCipher,exports.Cipheriv=aes.Cipheriv,exports.createCipheriv=aes.createCipheriv,exports.Decipher=aes.Decipher,exports.createDecipher=aes.createDecipher,exports.Decipheriv=aes.Decipheriv,exports.createDecipheriv=aes.createDecipheriv,exports.getCiphers=aes.getCiphers,exports.listCiphers=aes.listCiphers;var dh=require_browser7();exports.DiffieHellmanGroup=dh.DiffieHellmanGroup,exports.createDiffieHellmanGroup=dh.createDiffieHellmanGroup,exports.getDiffieHellman=dh.getDiffieHellman,exports.createDiffieHellman=dh.createDiffieHellman,exports.DiffieHellman=dh.DiffieHellman;var sign=require_browser8();exports.createSign=sign.createSign,exports.Sign=sign.Sign,exports.createVerify=sign.createVerify,exports.Verify=sign.Verify,exports.createECDH=require_browser9();var publicEncrypt=require_browser10();exports.publicEncrypt=publicEncrypt.publicEncrypt,exports.privateEncrypt=publicEncrypt.privateEncrypt,exports.publicDecrypt=publicEncrypt.publicDecrypt,exports.privateDecrypt=publicEncrypt.privateDecrypt,exports.getRandomValues=(values)=>crypto.getRandomValues(values);var rf=require_browser11();exports.randomFill=rf.randomFill,exports.randomFillSync=rf.randomFillSync,exports.createCredentials=function(){throw new Error([\"sorry, createCredentials is not implemented yet\",\"we accept pull requests\",\"https://github.com/crypto-browserify/crypto-browserify\"].join(`\n`))},exports.constants=@processBindingConstants.crypto}}),crypto_exports=require_crypto_browserify2(),DEFAULT_ENCODING=\"buffer\",getRandomValues=(array)=>crypto.getRandomValues(array),randomUUID=()=>crypto.randomUUID(),randomInt=(...args)=>crypto.randomInt(...args),timingSafeEqual=\"timingSafeEqual\"in crypto\?(a,b)=>{let{byteLength:byteLengthA}=a,{byteLength:byteLengthB}=b;if(typeof byteLengthA!=\"number\"||typeof byteLengthB!=\"number\")@throwTypeError(\"Input must be an array buffer view\");if(byteLengthA!==byteLengthB)@throwRangeError(\"Input buffers must have the same length\");return crypto.timingSafeEqual(a,b)}:void 0,scryptSync=\"scryptSync\"in crypto\?(password,salt,keylen,options)=>{let res=crypto.scryptSync(password,salt,keylen,options);return DEFAULT_ENCODING!==\"buffer\"\?new Buffer(res).toString(DEFAULT_ENCODING):new Buffer(res)}:void 0,scrypt=\"scryptSync\"in crypto\?function(password,salt,keylen,options,callback){if(typeof options==\"function\"&&(callback=options,options=void 0),typeof callback!=\"function\"){var err=@makeTypeError(\"callback must be a function\");throw err.code=\"ERR_INVALID_CALLBACK\",err}try{let result=crypto.scryptSync(password,salt,keylen,options);process.nextTick(callback,null,DEFAULT_ENCODING!==\"buffer\"\?new Buffer(result).toString(DEFAULT_ENCODING):new Buffer(result))}catch(err2){throw err2}}:void 0;timingSafeEqual&&(Object.defineProperty(timingSafeEqual,\"name\",{value:\"::bunternal::\"}),Object.defineProperty(scrypt,\"name\",{value:\"::bunternal::\"}),Object.defineProperty(scryptSync,\"name\",{value:\"::bunternal::\"}));const harcoded_curves=[\"p192\",\"p224\",\"p256\",\"p384\",\"p521\",\"curve25519\",\"ed25519\",\"secp256k1\",\"secp224r1\",\"prime256v1\",\"prime192v1\",\"ed25519\",\"secp384r1\",\"secp521r1\"];function getCurves(){return harcoded_curves}var webcrypto=crypto;__export(crypto_exports,{DEFAULT_ENCODING:()=>DEFAULT_ENCODING,getRandomValues:()=>getRandomValues,randomUUID:()=>randomUUID,randomInt:()=>randomInt,getCurves:()=>getCurves,scrypt:()=>scrypt,scryptSync:()=>scryptSync,timingSafeEqual:()=>timingSafeEqual,webcrypto:()=>webcrypto,subtle:()=>webcrypto.subtle}),$=crypto_exports;/*! safe-buffer. MIT License. Feross Aboukhadijeh */return $})\n"_s; +// + +// static constexpr ASCIILiteral NodeDgramCode = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function createSocket(){throwNotImplemented(\"node:dgram createSocket\",1630)}function Socket(){throwNotImplemented(\"node:dgram Socket\",1630)}function _createSocketHandle(){throwNotImplemented(\"node:dgram _createSocketHandle\",1630)}return $={createSocket,Socket,_createSocketHandle},hideFromStack(createSocket,Socket,_createSocketHandle),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use strict\";const SafeMap=Map,SafeFinalizationRegistry=FinalizationRegistry,ArrayPrototypeAt=(array,index)=>array[index],ArrayPrototypeIndexOf=(array,value)=>array.indexOf(value),ArrayPrototypePush=(array,value)=>array.push(value),ArrayPrototypeSplice=(array,start,deleteCount)=>array.splice(start,deleteCount),ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectSetPrototypeOf=Object.setPrototypeOf,SymbolHasInstance=Symbol.hasInstance,ReflectApply=Reflect.apply,PromiseResolve=Promise.resolve,PromiseReject=Promise.reject,PromisePrototypeThen=(promise,onFulfilled,onRejected)=>promise.then(onFulfilled,onRejected);class WeakReference extends WeakRef{constructor(){super(...arguments)}#refs=0;get(){return this.deref()}incRef(){return++this.#refs}decRef(){return--this.#refs}}class WeakRefMap extends SafeMap{constructor(){super(...arguments)}#finalizers=new SafeFinalizationRegistry((key)=>{this.delete(key)});set(key,value){return this.#finalizers.register(value,key),super.set(key,new WeakReference(value))}get(key){return super.get(key)\?.get()}incRef(key){return super.get(key)\?.incRef()}decRef(key){return super.get(key)\?.decRef()}}function markActive(channel2){ObjectSetPrototypeOf(channel2,ActiveChannel.prototype),channel2._subscribers=[],channel2._stores=new SafeMap}function maybeMarkInactive(channel2){if(!channel2._subscribers.length&&!channel2._stores.size)ObjectSetPrototypeOf(channel2,Channel.prototype),channel2._subscribers=void 0,channel2._stores=void 0}function defaultTransform(data){return data}function wrapStoreRun(store,data,next,transform=defaultTransform){return()=>{let context;try{context=transform(data)}catch(err){return process.nextTick(()=>reportError(err)),next()}return store.run(context,next)}}class ActiveChannel{subscribe(subscription){validateFunction(subscription,\"subscription\"),ArrayPrototypePush(this._subscribers,subscription),channels.incRef(this.name)}unsubscribe(subscription){const index=ArrayPrototypeIndexOf(this._subscribers,subscription);if(index===-1)return!1;return ArrayPrototypeSplice(this._subscribers,index,1),channels.decRef(this.name),maybeMarkInactive(this),!0}bindStore(store,transform){if(!this._stores.has(store))channels.incRef(this.name);this._stores.set(store,transform)}unbindStore(store){if(!this._stores.has(store))return!1;return this._stores.delete(store),channels.decRef(this.name),maybeMarkInactive(this),!0}get hasSubscribers(){return!0}publish(data){for(let i=0;i<(this._subscribers\?.length||0);i++)try{const onMessage=this._subscribers[i];onMessage(data,this.name)}catch(err){process.nextTick(()=>reportError(err))}}runStores(data,fn,thisArg,...args){let run=()=>{return this.publish(data),ReflectApply(fn,thisArg,args)};for(let entry of this._stores.entries()){const store=entry[0],transform=entry[1];run=wrapStoreRun(store,data,run,transform)}return run()}}class Channel{constructor(name){this._subscribers=void 0,this._stores=void 0,this.name=name,channels.set(name,this)}static[SymbolHasInstance](instance){const prototype=ObjectGetPrototypeOf(instance);return prototype===Channel.prototype||prototype===ActiveChannel.prototype}subscribe(subscription){markActive(this),this.subscribe(subscription)}unsubscribe(){return!1}bindStore(store,transform){markActive(this),this.bindStore(store,transform)}unbindStore(){return!1}get hasSubscribers(){return!1}publish(){}runStores(data,fn,thisArg,...args){return ReflectApply(fn,thisArg,args)}}const channels=new WeakRefMap;function channel(name){const channel2=channels.get(name);if(channel2)return channel2;if(typeof name!==\"string\"&&typeof name!==\"symbol\")throw new ERR_INVALID_ARG_TYPE(\"channel\",[\"string\",\"symbol\"],name);return new Channel(name)}function subscribe(name,subscription){return channel(name).subscribe(subscription)}function unsubscribe(name,subscription){return channel(name).unsubscribe(subscription)}function hasSubscribers(name){const channel2=channels.get(name);if(!channel2)return!1;return channel2.hasSubscribers}const traceEvents=[\"start\",\"end\",\"asyncStart\",\"asyncEnd\",\"error\"];function assertChannel(value,name){if(!(value instanceof Channel))throw new ERR_INVALID_ARG_TYPE(name,[\"Channel\"],value)}class TracingChannel{constructor(nameOrChannels){if(typeof nameOrChannels===\"string\")this.start=channel(`tracing:${nameOrChannels}:start`),this.end=channel(`tracing:${nameOrChannels}:end`),this.asyncStart=channel(`tracing:${nameOrChannels}:asyncStart`),this.asyncEnd=channel(`tracing:${nameOrChannels}:asyncEnd`),this.error=channel(`tracing:${nameOrChannels}:error`);else if(typeof nameOrChannels===\"object\"){const{start,end,asyncStart,asyncEnd,error}=nameOrChannels;assertChannel(start,\"nameOrChannels.start\"),assertChannel(end,\"nameOrChannels.end\"),assertChannel(asyncStart,\"nameOrChannels.asyncStart\"),assertChannel(asyncEnd,\"nameOrChannels.asyncEnd\"),assertChannel(error,\"nameOrChannels.error\"),this.start=start,this.end=end,this.asyncStart=asyncStart,this.asyncEnd=asyncEnd,this.error=error}else throw new ERR_INVALID_ARG_TYPE(\"nameOrChannels\",[\"string\",\"object\",\"Channel\"],nameOrChannels)}subscribe(handlers){for(let name of traceEvents){if(!handlers[name])continue;this[name]\?.subscribe(handlers[name])}}unsubscribe(handlers){let done=!0;for(let name of traceEvents){if(!handlers[name])continue;if(!this[name]\?.unsubscribe(handlers[name]))done=!1}return done}traceSync(fn,context={},thisArg,...args){const{start,end,error}=this;return start.runStores(context,()=>{try{const result=ReflectApply(fn,thisArg,args);return context.result=result,result}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}tracePromise(fn,context={},thisArg,...args){const{start,end,asyncStart,asyncEnd,error}=this;function reject(err){return context.error=err,error.publish(context),asyncStart.publish(context),asyncEnd.publish(context),PromiseReject(err)}function resolve(result){return context.result=result,asyncStart.publish(context),asyncEnd.publish(context),result}return start.runStores(context,()=>{try{let promise=ReflectApply(fn,thisArg,args);if(!(promise instanceof Promise))promise=PromiseResolve(promise);return PromisePrototypeThen(promise,resolve,reject)}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}traceCallback(fn,position=-1,context={},thisArg,...args){const{start,end,asyncStart,asyncEnd,error}=this;function wrappedCallback(err,res){if(err)context.error=err,error.publish(context);else context.result=res;asyncStart.runStores(context,()=>{try{if(callback)return ReflectApply(callback,this,arguments)}finally{asyncEnd.publish(context)}})}const callback=ArrayPrototypeAt(args,position);if(typeof callback!==\"function\")throw new ERR_INVALID_ARG_TYPE(\"callback\",[\"function\"],callback);return ArrayPrototypeSplice(args,position,1,wrappedCallback),start.runStores(context,()=>{try{return ReflectApply(fn,thisArg,args)}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}}function tracingChannel(nameOrChannels){return new TracingChannel(nameOrChannels)}class ERR_INVALID_ARG_TYPE extends TypeError{constructor(name,expected,actual){super(`The ${name} argument must be of type ${expected}. Received type ${typeof actual}`);this.code=\"ERR_INVALID_ARG_TYPE\"}}function validateFunction(callable,field){if(typeof callable!==\"function\")throw new ERR_INVALID_ARG_TYPE(field,\"Function\",callable);return callable}return{channel,hasSubscribers,subscribe,tracingChannel,unsubscribe,Channel}})\n"_s; +// + +// static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises}})\n"_s; +// + +// static constexpr ASCIILiteral NodeDNSPromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,12)||@createInternalModuleById(12)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeDomainCode = "(function (){\"use strict\";var EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),domain={};return domain.createDomain=domain.create=function(){var d=new EventEmitter;function emitError(e){d.emit(\"error\",e)}return d.add=function(emitter){emitter.on(\"error\",emitError)},d.remove=function(emitter){emitter.removeListener(\"error\",emitError)},d.bind=function(fn){return function(){var args=Array.prototype.slice.call(arguments);try{fn.apply(null,args)}catch(err){emitError(err)}}},d.intercept=function(fn){return function(err){if(err)emitError(err);else{var args=Array.prototype.slice.call(arguments,1);try{fn.apply(null,args)}catch(err2){emitError(err2)}}}},d.run=function(fn){try{fn()}catch(err){emitError(err)}return this},d.dispose=function(){return this.removeAllListeners(),this},d.enter=d.exit=function(){return this},d},domain})\n"_s; +// + +// static constexpr ASCIILiteral NodeEventsCode = "(function (){\"use strict\";const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),SymbolFor=Symbol.for,kCapture=Symbol(\"kCapture\"),kErrorMonitor=SymbolFor(\"events.errorMonitor\"),kMaxEventTargetListeners=Symbol(\"events.maxEventTargetListeners\"),kMaxEventTargetListenersWarned=Symbol(\"events.maxEventTargetListenersWarned\"),kWatermarkData=SymbolFor(\"nodejs.watermarkData\"),kRejection=SymbolFor(\"nodejs.rejection\"),captureRejectionSymbol=SymbolFor(\"nodejs.rejection\"),ArrayPrototypeSlice=Array.prototype.slice;var defaultMaxListeners=10;const EventEmitter=function EventEmitter(opts){if(this._events===void 0||this._events===this.__proto__._events)this._events={__proto__:null},this._eventsCount=0;if(this._maxListeners\?\?=void 0,this[kCapture]=opts\?.captureRejections\?Boolean(opts\?.captureRejections):EventEmitterPrototype[kCapture])this.emit=emitWithRejectionCapture},EventEmitterPrototype=EventEmitter.prototype={};EventEmitterPrototype._events=void 0,EventEmitterPrototype._eventsCount=0,EventEmitterPrototype._maxListeners=void 0,EventEmitterPrototype.setMaxListeners=function setMaxListeners(n){return validateNumber(n,\"setMaxListeners\",0),this._maxListeners=n,this},EventEmitterPrototype.getMaxListeners=function getMaxListeners(){return this._maxListeners\?\?defaultMaxListeners};function emitError(emitter,args){var{_events:events}=emitter;if(args[0]\?\?=new Error(\"Unhandled error.\"),!events)throw args[0];var errorMonitor=events[kErrorMonitor];if(errorMonitor)for(var handler of ArrayPrototypeSlice.call(errorMonitor))handler.apply(emitter,args);var handlers=events.error;if(!handlers)throw args[0];for(var handler of ArrayPrototypeSlice.call(handlers))handler.apply(emitter,args);return!0}function addCatch(emitter,promise,type,args){promise.then(void 0,function(err){process.nextTick(emitUnhandledRejectionOrErr,emitter,err,type,args)})}function emitUnhandledRejectionOrErr(emitter,err,type,args){if(typeof emitter[kRejection]===\"function\")emitter[kRejection](err,type,...args);else try{emitter[kCapture]=!1,emitter.emit(\"error\",err)}finally{emitter[kCapture]=!0}}const emitWithoutRejectionCapture=function emit(type,...args){if(type===\"error\")return emitError(this,args);var{_events:events}=this;if(events===void 0)return!1;var handlers=events[type];if(handlers===void 0)return!1;for(var handler of[...handlers])handler.apply(this,args);return!0},emitWithRejectionCapture=function emit(type,...args){if(type===\"error\")return emitError(this,args);var{_events:events}=this;if(events===void 0)return!1;var handlers=events[type];if(handlers===void 0)return!1;for(var handler of[...handlers]){var result=handler.apply(this,args);if(result!==void 0&&@isPromise(result))addCatch(this,result,type,args)}return!0};EventEmitterPrototype.emit=emitWithoutRejectionCapture,EventEmitterPrototype.addListener=function addListener(type,fn){checkListener(fn);var events=this._events;if(!events)events=this._events={__proto__:null},this._eventsCount=0;else if(events.newListener)this.emit(\"newListener\",type,fn.listener\?\?fn);var handlers=events[type];if(!handlers)events[type]=[fn],this._eventsCount++;else{handlers.push(fn);var m=this._maxListeners\?\?defaultMaxListeners;if(m>0&&handlers.length>m&&!handlers.warned)overflowWarning(this,type,handlers)}return this},EventEmitterPrototype.on=EventEmitterPrototype.addListener,EventEmitterPrototype.prependListener=function prependListener(type,fn){checkListener(fn);var events=this._events;if(!events)events=this._events={__proto__:null},this._eventsCount=0;else if(events.newListener)this.emit(\"newListener\",type,fn.listener\?\?fn);var handlers=events[type];if(!handlers)events[type]=[fn],this._eventsCount++;else{handlers.unshift(fn);var m=this._maxListeners\?\?defaultMaxListeners;if(m>0&&handlers.length>m&&!handlers.warned)overflowWarning(this,type,handlers)}return this};function overflowWarning(emitter,type,handlers){handlers.warned=!0;const warn=new Error(`Possible EventEmitter memory leak detected. ${handlers.length} ${String(type)} listeners `+`added to [${emitter.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);warn.name=\"MaxListenersExceededWarning\",warn.emitter=emitter,warn.type=type,warn.count=handlers.length,process.emitWarning(warn)}function onceWrapper(type,listener,...args){this.removeListener(type,listener),listener.apply(this,args)}EventEmitterPrototype.once=function once(type,fn){checkListener(fn);const bound=onceWrapper.bind(this,type,fn);return bound.listener=fn,this.addListener(type,bound),this},EventEmitterPrototype.prependOnceListener=function prependOnceListener(type,fn){checkListener(fn);const bound=onceWrapper.bind(this,type,fn);return bound.listener=fn,this.prependListener(type,bound),this},EventEmitterPrototype.removeListener=function removeListener(type,fn){checkListener(fn);var{_events:events}=this;if(!events)return this;var handlers=events[type];if(!handlers)return this;var length=handlers.length;let position=-1;for(let i=length-1;i>=0;i--)if(handlers[i]===fn||handlers[i].listener===fn){position=i;break}if(position<0)return this;if(position===0)handlers.shift();else handlers.splice(position,1);if(handlers.length===0)delete events[type],this._eventsCount--;return this},EventEmitterPrototype.off=EventEmitterPrototype.removeListener,EventEmitterPrototype.removeAllListeners=function removeAllListeners(type){var{_events:events}=this;if(type&&events){if(events[type])delete events[type],this._eventsCount--}else this._events={__proto__:null};return this},EventEmitterPrototype.listeners=function listeners(type){var{_events:events}=this;if(!events)return[];var handlers=events[type];if(!handlers)return[];return handlers.map((x)=>x.listener\?\?x)},EventEmitterPrototype.rawListeners=function rawListeners(type){var{_events}=this;if(!_events)return[];var handlers=_events[type];if(!handlers)return[];return handlers.slice()},EventEmitterPrototype.listenerCount=function listenerCount(type){var{_events:events}=this;if(!events)return 0;return events[type]\?.length\?\?0},EventEmitterPrototype.eventNames=function eventNames(){return this._eventsCount>0\?Reflect.ownKeys(this._events):[]},EventEmitterPrototype[kCapture]=!1;function once(emitter,type,options){var signal=options\?.signal;if(validateAbortSignal(signal,\"options.signal\"),signal\?.aborted)throw new AbortError(void 0,{cause:signal\?.reason});return new Promise((resolve,reject)=>{const errorListener=(err)=>{if(emitter.removeListener(type,resolver),signal!=null)eventTargetAgnosticRemoveListener(signal,\"abort\",abortListener);reject(err)},resolver=(...args)=>{if(typeof emitter.removeListener===\"function\")emitter.removeListener(\"error\",errorListener);if(signal!=null)eventTargetAgnosticRemoveListener(signal,\"abort\",abortListener);resolve(args)};if(eventTargetAgnosticAddListener(emitter,type,resolver,{once:!0}),type!==\"error\"&&typeof emitter.once===\"function\")emitter.once(\"error\",errorListener);function abortListener(){eventTargetAgnosticRemoveListener(emitter,type,resolver),eventTargetAgnosticRemoveListener(emitter,\"error\",errorListener),reject(new AbortError(void 0,{cause:signal\?.reason}))}if(signal!=null)eventTargetAgnosticAddListener(signal,\"abort\",abortListener,{once:!0})})}function on(emitter,type,options){var{signal,close,highWatermark=Number.MAX_SAFE_INTEGER,lowWatermark=1}=options||{};throwNotImplemented(\"events.on\",2679)}function getEventListeners(emitter,type){if(emitter instanceof EventTarget)throwNotImplemented(\"getEventListeners with an EventTarget\",2678);return emitter.listeners(type)}function setMaxListeners(n,...eventTargets){validateNumber(n,\"setMaxListeners\",0);var length;if(eventTargets&&(length=eventTargets.length))for(let i=0;imax||(min!=null||max!=null)&&Number.isNaN(value))throw new ERR_OUT_OF_RANGE(name,`${min!=null\?`>= ${min}`:\"\"}${min!=null&&max!=null\?\" && \":\"\"}${max!=null\?`<= ${max}`:\"\"}`,value)}function checkListener(listener){if(typeof listener!==\"function\")@throwTypeError(\"The listener must be a function\")}let AsyncResource=null;class EventEmitterAsyncResource extends EventEmitter{triggerAsyncId;asyncResource;constructor(options){if(!AsyncResource)AsyncResource=(@getInternalField(@internalModuleRegistry,5)||@createInternalModuleById(5)).AsyncResource;var{captureRejections=!1,triggerAsyncId,name=new.target.name,requireManualDestroy}=options||{};super({captureRejections});this.triggerAsyncId=triggerAsyncId\?\?0,this.asyncResource=new AsyncResource(name,{triggerAsyncId,requireManualDestroy})}emit(...args){this.asyncResource.runInAsyncScope(()=>super.emit(...args))}emitDestroy(){this.asyncResource.emitDestroy()}}return Object.defineProperties(EventEmitter,{captureRejections:{get(){return EventEmitterPrototype[kCapture]},set(value){validateBoolean(value,\"EventEmitter.captureRejections\"),EventEmitterPrototype[kCapture]=value},enumerable:!0},defaultMaxListeners:{enumerable:!0,get:()=>{return defaultMaxListeners},set:(arg)=>{validateNumber(arg,\"defaultMaxListeners\",0),defaultMaxListeners=arg}},kMaxEventTargetListeners:{value:kMaxEventTargetListeners,enumerable:!1,configurable:!1,writable:!1},kMaxEventTargetListenersWarned:{value:kMaxEventTargetListenersWarned,enumerable:!1,configurable:!1,writable:!1}}),Object.assign(EventEmitter,{once,on,getEventListeners,setMaxListeners,EventEmitter,usingDomains:!1,captureRejectionSymbol,EventEmitterAsyncResource,errorMonitor:kErrorMonitor,setMaxListeners,init:EventEmitter,listenerCount}),EventEmitter})\n"_s; +// + +// static constexpr ASCIILiteral NodeFSCode = "(function (){\"use strict\";var $,ReadStream,WriteStream;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),promises=@getInternalField(@internalModuleRegistry,17)||@createInternalModuleById(17),Stream=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34);var fs=Bun.fs();class FSWatcher extends EventEmitter{#watcher;#listener;constructor(path,options,listener){super();if(typeof options===\"function\")listener=options,options={};else if(typeof options===\"string\")options={encoding:options};if(typeof listener!==\"function\")listener=()=>{};this.#listener=listener;try{this.#watcher=fs.watch(path,options||{},this.#onEvent.bind(this))}catch(e){if(!e.message\?.startsWith(\"FileNotFound\"))throw e;const notFound=new Error(`ENOENT: no such file or directory, watch '${path}'`);throw notFound.code=\"ENOENT\",notFound.errno=-2,notFound.path=path,notFound.syscall=\"watch\",notFound.filename=path,notFound}}#onEvent(eventType,filenameOrError){if(eventType===\"error\"||eventType===\"close\")this.emit(eventType,filenameOrError);else this.emit(\"change\",eventType,filenameOrError),this.#listener(eventType,filenameOrError)}close(){this.#watcher\?.close(),this.#watcher=null}ref(){this.#watcher\?.ref()}unref(){this.#watcher\?.unref()}}var access=function access(...args){callbackify(fs.accessSync,args)},appendFile=function appendFile(...args){callbackify(fs.appendFileSync,args)},close=function close(...args){callbackify(fs.closeSync,args)},rm=function rm(...args){callbackify(fs.rmSync,args)},rmdir=function rmdir(...args){callbackify(fs.rmdirSync,args)},copyFile=function copyFile(...args){callbackify(fs.copyFileSync,args)},exists=function exists(...args){callbackify(fs.existsSync,args)},chown=function chown(...args){callbackify(fs.chownSync,args)},chmod=function chmod(...args){callbackify(fs.chmodSync,args)},fchmod=function fchmod(...args){callbackify(fs.fchmodSync,args)},fchown=function fchown(...args){callbackify(fs.fchownSync,args)},fstat=function fstat(...args){callbackify(fs.fstatSync,args)},fsync=function fsync(...args){callbackify(fs.fsyncSync,args)},ftruncate=function ftruncate(...args){callbackify(fs.ftruncateSync,args)},futimes=function futimes(...args){callbackify(fs.futimesSync,args)},lchmod=function lchmod(...args){callbackify(fs.lchmodSync,args)},lchown=function lchown(...args){callbackify(fs.lchownSync,args)},link=function link(...args){callbackify(fs.linkSync,args)},mkdir=function mkdir(...args){callbackify(fs.mkdirSync,args)},mkdtemp=function mkdtemp(...args){callbackify(fs.mkdtempSync,args)},open=function open(...args){callbackify(fs.openSync,args)},read=function read(...args){callbackify(fs.readSync,args)},write=function write(...args){callbackify(fs.writeSync,args)},readdir=function readdir(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.readdir(...args).then((result)=>callback(null,result),callback)},readFile=function readFile(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.readFile(...args).then((result)=>callback(null,result),callback)},writeFile=function writeFile(...args){callbackify(fs.writeFileSync,args)},readlink=function readlink(...args){callbackify(fs.readlinkSync,args)},realpath=function realpath(...args){callbackify(fs.realpathSync,args)},rename=function rename(...args){callbackify(fs.renameSync,args)},lstat=function lstat(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.lstat(...args).then((result)=>callback(null,result),callback)},stat=function stat(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.stat(...args).then((result)=>callback(null,result),callback)},symlink=function symlink(...args){callbackify(fs.symlinkSync,args)},truncate=function truncate(...args){callbackify(fs.truncateSync,args)},unlink=function unlink(...args){callbackify(fs.unlinkSync,args)},utimes=function utimes(...args){callbackify(fs.utimesSync,args)},lutimes=function lutimes(...args){callbackify(fs.lutimesSync,args)},accessSync=fs.accessSync.bind(fs),appendFileSync=fs.appendFileSync.bind(fs),closeSync=fs.closeSync.bind(fs),copyFileSync=fs.copyFileSync.bind(fs),existsSync=fs.existsSync.bind(fs),chownSync=fs.chownSync.bind(fs),chmodSync=fs.chmodSync.bind(fs),fchmodSync=fs.fchmodSync.bind(fs),fchownSync=fs.fchownSync.bind(fs),fstatSync=fs.fstatSync.bind(fs),fsyncSync=fs.fsyncSync.bind(fs),ftruncateSync=fs.ftruncateSync.bind(fs),futimesSync=fs.futimesSync.bind(fs),lchmodSync=fs.lchmodSync.bind(fs),lchownSync=fs.lchownSync.bind(fs),linkSync=fs.linkSync.bind(fs),lstatSync=fs.lstatSync.bind(fs),mkdirSync=fs.mkdirSync.bind(fs),mkdtempSync=fs.mkdtempSync.bind(fs),openSync=fs.openSync.bind(fs),readSync=fs.readSync.bind(fs),writeSync=fs.writeSync.bind(fs),readdirSync=fs.readdirSync.bind(fs),readFileSync=fs.readFileSync.bind(fs),writeFileSync=fs.writeFileSync.bind(fs),readlinkSync=fs.readlinkSync.bind(fs),realpathSync=fs.realpathSync.bind(fs),renameSync=fs.renameSync.bind(fs),statSync=fs.statSync.bind(fs),symlinkSync=fs.symlinkSync.bind(fs),truncateSync=fs.truncateSync.bind(fs),unlinkSync=fs.unlinkSync.bind(fs),utimesSync=fs.utimesSync.bind(fs),lutimesSync=fs.lutimesSync.bind(fs),rmSync=fs.rmSync.bind(fs),rmdirSync=fs.rmdirSync.bind(fs),writev=(fd,buffers,position,callback)=>{if(typeof position===\"function\")callback=position,position=null;queueMicrotask(()=>{try{var written=fs.writevSync(fd,buffers,position)}catch(e){callback(e)}callback(null,written,buffers)})},writevSync=fs.writevSync.bind(fs),readv=(fd,buffers,position,callback)=>{if(typeof position===\"function\")callback=position,position=null;queueMicrotask(()=>{try{var written=fs.readvSync(fd,buffers,position)}catch(e){callback(e)}callback(null,written,buffers)})},readvSync=fs.readvSync.bind(fs),Dirent=fs.Dirent,Stats=fs.Stats,watch=function watch(path,options,listener){return new FSWatcher(path,options,listener)};function callbackify(fsFunction,args){try{const result=fsFunction.apply(fs,args.slice(0,args.length-1)),callback=args[args.length-1];if(typeof callback===\"function\")queueMicrotask(()=>callback(null,result))}catch(e){const callback=args[args.length-1];if(typeof callback===\"function\")queueMicrotask(()=>callback(e))}}var readStreamPathFastPathSymbol=Symbol.for(\"Bun.Node.readStreamPathFastPath\");const readStreamSymbol=Symbol.for(\"Bun.NodeReadStream\"),readStreamPathOrFdSymbol=Symbol.for(\"Bun.NodeReadStreamPathOrFd\"),writeStreamSymbol=Symbol.for(\"Bun.NodeWriteStream\");var writeStreamPathFastPathSymbol=Symbol.for(\"Bun.NodeWriteStreamFastPath\"),writeStreamPathFastPathCallSymbol=Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"),kIoDone=Symbol.for(\"kIoDone\"),defaultReadStreamOptions={file:void 0,fd:void 0,flags:\"r\",encoding:void 0,mode:438,autoClose:!0,emitClose:!0,start:0,end:Infinity,highWaterMark:65536,fs:{read,open:(path,flags,mode,cb)=>{var fd;try{fd=openSync(path,flags,mode)}catch(e){cb(e);return}cb(null,fd)},openSync,close},autoDestroy:!0},ReadStreamClass;ReadStream=function(InternalReadStream){ReadStreamClass=InternalReadStream,Object.defineProperty(ReadStreamClass.prototype,Symbol.toStringTag,{value:\"ReadStream\",enumerable:!1});function ReadStream2(path,options){return new InternalReadStream(path,options)}return ReadStream2.prototype=InternalReadStream.prototype,Object.defineProperty(ReadStream2,Symbol.hasInstance,{value(instance){return instance instanceof InternalReadStream}})}(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2,Stream.Readable){constructor(pathOrFd,options=defaultReadStreamOptions){if(typeof options!==\"object\"||!options)@throwTypeError(\"Expected options to be an object\");var{flags=defaultReadStreamOptions.flags,encoding=defaultReadStreamOptions.encoding,mode=defaultReadStreamOptions.mode,autoClose=defaultReadStreamOptions.autoClose,emitClose=defaultReadStreamOptions.emitClose,start=defaultReadStreamOptions.start,end=defaultReadStreamOptions.end,autoDestroy=defaultReadStreamOptions.autoClose,fs:fs2=defaultReadStreamOptions.fs,highWaterMark=defaultReadStreamOptions.highWaterMark}=options;if(pathOrFd\?.constructor\?.name===\"URL\")pathOrFd=Bun.fileURLToPath(pathOrFd);var tempThis={};if(typeof pathOrFd===\"string\"){if(pathOrFd.startsWith(\"file://\"))pathOrFd=Bun.fileURLToPath(pathOrFd);if(pathOrFd.length===0)@throwTypeError(\"Expected path to be a non-empty string\");tempThis.path=tempThis.file=tempThis[readStreamPathOrFdSymbol]=pathOrFd}else if(typeof pathOrFd===\"number\"){if(pathOrFd|=0,pathOrFd<0)@throwTypeError(\"Expected fd to be a positive integer\");tempThis.fd=tempThis[readStreamPathOrFdSymbol]=pathOrFd,tempThis.autoClose=!1}else @throwTypeError(\"Expected a path or file descriptor\");if(!tempThis.fd)tempThis.fd=fs2.openSync(pathOrFd,flags,mode);var fileRef=Bun.file(tempThis.fd),stream=fileRef.stream(),native=@direct(stream);if(!native)throw new Error(\"no native readable stream\");var{stream:ptr}=native;super(ptr,{...options,encoding,autoDestroy,autoClose,emitClose,highWaterMark});if(Object.assign(this,tempThis),this.#fileRef=fileRef,this.end=end,this._read=this.#internalRead,this.start=start,this.flags=flags,this.mode=mode,this.emitClose=emitClose,this[readStreamPathFastPathSymbol]=start===0&&end===Infinity&&autoClose&&fs2===defaultReadStreamOptions.fs&&(encoding===\"buffer\"||encoding===\"binary\"||encoding==null||encoding===\"utf-8\"||encoding===\"utf8\"),this._readableState.autoClose=autoDestroy=autoClose,this._readableState.highWaterMark=highWaterMark,start!==void 0)this.pos=start}#fileRef;#fs;file;path;fd=null;flags;mode;start;end;pos;bytesRead=0;#fileSize=-1;_read;[readStreamSymbol]=!0;[readStreamPathOrFdSymbol];[readStreamPathFastPathSymbol];_construct(callback){if(super._construct)super._construct(callback);else callback();this.emit(\"open\",this.fd),this.emit(\"ready\")}_destroy(err,cb){super._destroy(err,cb);try{var fd=this.fd;if(this[readStreamPathFastPathSymbol]=!1,!fd)cb(err);else this.#fs.close(fd,(er)=>{cb(er||err)}),this.fd=null}catch(e){throw e}}close(cb){if(typeof cb===\"function\")eos_()(this,cb);this.destroy()}push(chunk){var bytesRead=chunk\?.length\?\?0;if(bytesRead>0){this.bytesRead+=bytesRead;var currPos=this.pos;if(currPos!==void 0){if(this.bytesReadthis.end)chunk=chunk.slice(0,this.end-this.start+1);return super.push(chunk,...rest)}var end=this.end;if(end!==void 0&&this.bytesRead>end){chunk=chunk.slice(0,end-currPos+1);var[_,...rest]=arguments;return this.pos=this.bytesRead,super.push(chunk,...rest)}this.pos=this.bytesRead}}return super.push(...arguments)}#internalRead(n){var{pos,end,bytesRead,fd,encoding}=this;if(n=pos!==void 0\?Math.min(end-pos+1,n):Math.min(end-bytesRead+1,n),n<=0){this.push(null);return}if(this.#fileSize===-1&&bytesRead===0&&pos===void 0){var stat2=fstatSync(fd);if(this.#fileSize=stat2.size,this.#fileSize>0&&n>this.#fileSize)n=this.#fileSize+1}this[kIoDone]=!1;var res=super._read(n);if(@isPromise(res)){var then=res\?.then;if(then&&@isCallable(then))then(()=>{if(this[kIoDone]=!0,this.destroyed)this.emit(kIoDone)},(er)=>{this[kIoDone]=!0,this.#errorOrDestroy(er)})}else if(this[kIoDone]=!0,this.destroyed)this.emit(kIoDone),this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"))}#errorOrDestroy(err,sync=null){var{_readableState:r={destroyed:!1,autoDestroy:!1},_writableState:w={destroyed:!1,autoDestroy:!1}}=this;if(w\?.destroyed||r\?.destroyed)return this;if(r\?.autoDestroy||w\?.autoDestroy)this.destroy(err);else if(err)this.emit(\"error\",err)}pause(){return this[readStreamPathFastPathSymbol]=!1,super.pause()}resume(){return this[readStreamPathFastPathSymbol]=!1,super.resume()}unshift(...args){return this[readStreamPathFastPathSymbol]=!1,super.unshift(...args)}pipe(dest,pipeOpts){if(this[readStreamPathFastPathSymbol]&&(pipeOpts\?.end\?\?!0)&&this._readableState\?.pipes\?.length===0){if((writeStreamPathFastPathSymbol in dest)&&dest[writeStreamPathFastPathSymbol]){if(dest[writeStreamPathFastPathCallSymbol](this,pipeOpts))return this}}return this[readStreamPathFastPathSymbol]=!1,super.pipe(dest,pipeOpts)}});function createReadStream(path,options){return new ReadStream(path,options)}var defaultWriteStreamOptions={fd:null,start:void 0,pos:void 0,encoding:void 0,flags:\"w\",mode:438,fs:{write,close,open,openSync}},WriteStreamClass;WriteStream=function(InternalWriteStream){WriteStreamClass=InternalWriteStream,Object.defineProperty(WriteStreamClass.prototype,Symbol.toStringTag,{value:\"WritesStream\",enumerable:!1});function WriteStream2(path,options){return new InternalWriteStream(path,options)}return WriteStream2.prototype=InternalWriteStream.prototype,Object.defineProperty(WriteStream2,Symbol.hasInstance,{value(instance){return instance instanceof InternalWriteStream}})}(class WriteStream2 extends Stream.NativeWritable{constructor(path,options=defaultWriteStreamOptions){if(!options)@throwTypeError(\"Expected options to be an object\");var{fs:fs2=defaultWriteStreamOptions.fs,start=defaultWriteStreamOptions.start,flags=defaultWriteStreamOptions.flags,mode=defaultWriteStreamOptions.mode,autoClose=!0,emitClose=!1,autoDestroy=autoClose,encoding=defaultWriteStreamOptions.encoding,fd=defaultWriteStreamOptions.fd,pos=defaultWriteStreamOptions.pos}=options,tempThis={};if(typeof path===\"string\"){if(path.length===0)@throwTypeError(\"Expected a non-empty path\");if(path.startsWith(\"file:\"))path=Bun.fileURLToPath(path);tempThis.path=path,tempThis.fd=null,tempThis[writeStreamPathFastPathSymbol]=autoClose&&(start===void 0||start===0)&&fs2.write===defaultWriteStreamOptions.fs.write&&fs2.close===defaultWriteStreamOptions.fs.close}else tempThis.fd=fd,tempThis[writeStreamPathFastPathSymbol]=!1;if(!tempThis.fd)tempThis.fd=fs2.openSync(path,flags,mode);super(tempThis.fd,{...options,decodeStrings:!1,autoDestroy,emitClose,fd:tempThis});if(Object.assign(this,tempThis),typeof fs2\?.write!==\"function\")@throwTypeError(\"Expected fs.write to be a function\");if(typeof fs2\?.close!==\"function\")@throwTypeError(\"Expected fs.close to be a function\");if(typeof fs2\?.open!==\"function\")@throwTypeError(\"Expected fs.open to be a function\");if(typeof path===\"object\"&&path){if(path instanceof URL)path=Bun.fileURLToPath(path)}if(typeof path!==\"string\"&&typeof fd!==\"number\")@throwTypeError(\"Expected a path or file descriptor\");if(this.start=start,this.#fs=fs2,this.flags=flags,this.mode=mode,this.start!==void 0)this.pos=this.start;if(encoding!==defaultWriteStreamOptions.encoding){if(this.setDefaultEncoding(encoding),encoding!==\"buffer\"&&encoding!==\"utf8\"&&encoding!==\"utf-8\"&&encoding!==\"binary\")this[writeStreamPathFastPathSymbol]=!1}}get autoClose(){return this._writableState.autoDestroy}set autoClose(val){this._writableState.autoDestroy=val}destroySoon=this.end;open(){}path;fd;flags;mode;#fs;bytesWritten=0;pos;[writeStreamPathFastPathSymbol];[writeStreamSymbol]=!0;start;[writeStreamPathFastPathCallSymbol](readStream,pipeOpts){if(!this[writeStreamPathFastPathSymbol])return!1;if(this.fd!==null)return this[writeStreamPathFastPathSymbol]=!1,!1;return this[kIoDone]=!1,readStream[kIoDone]=!1,Bun.write(this[writeStreamPathFastPathSymbol],readStream[readStreamPathOrFdSymbol]).then((bytesWritten)=>{readStream[kIoDone]=this[kIoDone]=!0,this.bytesWritten+=bytesWritten,readStream.bytesRead+=bytesWritten,this.end(),readStream.close()},(err)=>{readStream[kIoDone]=this[kIoDone]=!0,this.#errorOrDestroy(err),readStream.emit(\"error\",err)})}isBunFastPathEnabled(){return this[writeStreamPathFastPathSymbol]}disableBunFastPath(){this[writeStreamPathFastPathSymbol]=!1}#handleWrite(er,bytes){if(er)return this.#errorOrDestroy(er);this.bytesWritten+=bytes}#internalClose(err,cb){this[writeStreamPathFastPathSymbol]=!1;var fd=this.fd;this.#fs.close(fd,(er)=>{this.fd=null,cb(err||er)})}_construct(callback){if(typeof this.fd===\"number\"){callback();return}callback(),this.emit(\"open\",this.fd),this.emit(\"ready\")}_destroy(err,cb){if(this.fd===null)return cb(err);if(this[kIoDone]){this.once(kIoDone,()=>this.#internalClose(err,cb));return}this.#internalClose(err,cb)}[kIoDone]=!1;close(cb){if(cb){if(this.closed){process.nextTick(cb);return}this.on(\"close\",cb)}if(!this.autoClose)this.on(\"finish\",this.destroy);this.end()}write(chunk,encoding=this._writableState.defaultEncoding,cb){if(this[writeStreamPathFastPathSymbol]=!1,typeof chunk===\"string\")chunk=Buffer.from(chunk,encoding);var native=this.pos===void 0;return this[kIoDone]=!0,super.write(chunk,encoding,native\?(err,bytes)=>{if(this[kIoDone]=!1,this.#handleWrite(err,bytes),this.emit(kIoDone),cb)!err\?cb():cb(err)}:()=>{},native)}#internalWriteSlow(chunk,encoding,cb){this.#fs.write(this.fd,chunk,0,chunk.length,this.pos,(err,bytes)=>{this[kIoDone]=!1,this.#handleWrite(err,bytes),this.emit(kIoDone),!err\?cb():cb(err)})}end(chunk,encoding,cb){var native=this.pos===void 0;return super.end(chunk,encoding,cb,native)}_write=this.#internalWriteSlow;_writev=void 0;get pending(){return this.fd===null}_destroy(err,cb){this.close(err,cb)}#errorOrDestroy(err){var{_readableState:r={destroyed:!1,autoDestroy:!1},_writableState:w={destroyed:!1,autoDestroy:!1}}=this;if(w\?.destroyed||r\?.destroyed)return this;if(r\?.autoDestroy||w\?.autoDestroy)this.destroy(err);else if(err)this.emit(\"error\",err)}});function createWriteStream(path,options){return new WriteStream(path,options)}return Object.defineProperties(fs,{createReadStream:{value:createReadStream},createWriteStream:{value:createWriteStream},ReadStream:{value:ReadStream},WriteStream:{value:WriteStream}}),realpath.native=realpath,realpathSync.native=realpathSync,$={access,accessSync,appendFile,appendFileSync,chmod,chmodSync,chown,chownSync,close,closeSync,constants:promises.constants,copyFile,copyFileSync,createReadStream,createWriteStream,Dirent,exists,existsSync,fchmod,fchmodSync,fchown,fchownSync,fstat,fstatSync,fsync,fsyncSync,ftruncate,ftruncateSync,futimes,futimesSync,lchmod,lchmodSync,lchown,lchownSync,link,linkSync,lstat,lstatSync,lutimes,lutimesSync,mkdir,mkdirSync,mkdtemp,mkdtempSync,open,openSync,promises,read,readFile,readFileSync,readSync,readdir,readdirSync,readlink,readlinkSync,realpath,realpathSync,rename,renameSync,rm,rmSync,rmdir,rmdirSync,stat,statSync,Stats,symlink,symlinkSync,truncate,truncateSync,unlink,unlinkSync,utimes,utimesSync,write,writeFile,writeFileSync,writeSync,WriteStream,ReadStream,watch,FSWatcher,writev,writevSync,readv,readvSync,[Symbol.for(\"::bunternal::\")]:{ReadStreamClass,WriteStreamClass}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeFSPromisesCode = "(function (){\"use strict\";var $;const constants=@processBindingConstants.fs;var fs=Bun.fs();const notrace=\"::bunternal::\";var promisify={[notrace]:(fsFunction)=>{return async function(...args){return await 1,fsFunction.apply(fs,args)}}}[notrace];function watch(filename,options={}){if(filename instanceof URL)@throwTypeError(\"Watch URLs are not supported yet\");else if(Buffer.isBuffer(filename))filename=filename.toString();else if(typeof filename!==\"string\")@throwTypeError(\"Expected path to be a string or Buffer\");let nextEventResolve=null;if(typeof options===\"string\")options={encoding:options};const queue=@createFIFO(),watcher=fs.watch(filename,options||{},(eventType,filename2)=>{if(queue.push({eventType,filename:filename2}),nextEventResolve){const resolve=nextEventResolve;nextEventResolve=null,resolve()}});return{[Symbol.asyncIterator](){let closed=!1;return{async next(){while(!closed){let event;while(event=queue.shift()){if(event.eventType===\"close\")return closed=!0,{value:void 0,done:!0};if(event.eventType===\"error\")throw closed=!0,event.filename;return{value:event,done:!1}}const{promise,resolve}=Promise.withResolvers();nextEventResolve=resolve,await promise}return{value:void 0,done:!0}},return(){if(!closed){if(watcher.close(),closed=!0,nextEventResolve){const resolve=nextEventResolve;nextEventResolve=null,resolve()}}return{value:void 0,done:!0}}}}}}return $={access:promisify(fs.accessSync),appendFile:promisify(fs.appendFileSync),close:promisify(fs.closeSync),copyFile:promisify(fs.copyFileSync),exists:promisify(fs.existsSync),chown:promisify(fs.chownSync),chmod:promisify(fs.chmodSync),fchmod:promisify(fs.fchmodSync),fchown:promisify(fs.fchownSync),fstat:promisify(fs.fstatSync),fsync:promisify(fs.fsyncSync),ftruncate:promisify(fs.ftruncateSync),futimes:promisify(fs.futimesSync),lchmod:promisify(fs.lchmodSync),lchown:promisify(fs.lchownSync),link:promisify(fs.linkSync),lstat:fs.lstat.bind(fs),mkdir:promisify(fs.mkdirSync),mkdtemp:promisify(fs.mkdtempSync),open:promisify(fs.openSync),read:promisify(fs.readSync),write:promisify(fs.writeSync),readdir:fs.readdir.bind(fs),readFile:fs.readFile.bind(fs),writeFile:promisify(fs.writeFileSync),readlink:promisify(fs.readlinkSync),realpath:promisify(fs.realpathSync),rename:promisify(fs.renameSync),stat:fs.stat.bind(fs),symlink:promisify(fs.symlinkSync),truncate:promisify(fs.truncateSync),unlink:promisify(fs.unlinkSync),utimes:promisify(fs.utimesSync),lutimes:promisify(fs.lutimesSync),rm:promisify(fs.rmSync),rmdir:promisify(fs.rmdirSync),writev:(fd,buffers,position)=>{return new Promise((resolve,reject)=>{try{var bytesWritten=fs.writevSync(fd,buffers,position)}catch(err){reject(err);return}resolve({bytesWritten,buffers})})},readv:(fd,buffers,position)=>{return new Promise((resolve,reject)=>{try{var bytesRead=fs.readvSync(fd,buffers,position)}catch(err){reject(err);return}resolve({bytesRead,buffers})})},constants,watch},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttpCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{isTypedArray}=@requireNativeModule(\"node:util/types\"),{Duplex,Readable,Writable}=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),headerCharRegex=/[^\\t\\x20-\\x7e\\x80-\\xff]/;function checkInvalidHeaderChar(val){return RegExpPrototypeExec.call(headerCharRegex,val)!==null}const validateHeaderName=(name,label)=>{if(typeof name!==\"string\"||!name||!checkIsHttpToken(name))throw new Error(\"ERR_INVALID_HTTP_TOKEN\")},validateHeaderValue=(name,value)=>{if(value===void 0)throw new Error(\"ERR_HTTP_INVALID_HEADER_VALUE\");if(checkInvalidHeaderChar(value))throw new Error(\"ERR_INVALID_CHAR\")};function isIPv6(input){return new RegExp(\"^((\?:(\?:[0-9a-fA-F]{1,4}):){7}(\?:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){6}(\?:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){5}(\?::((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,2}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){4}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,1}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,3}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){3}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,2}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,4}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){2}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,3}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,5}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){1}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,4}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,6}|:)|(\?::((\?::(\?:[0-9a-fA-F]{1,4})){0,5}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(\?::(\?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})\?$\").test(input)}const{URL}=globalThis,globalReportError=globalThis.reportError,setTimeout=globalThis.setTimeout,fetch=Bun.fetch,nop=()=>{},kEmptyObject=Object.freeze(Object.create(null)),kOutHeaders=Symbol.for(\"kOutHeaders\"),kEndCalled=Symbol.for(\"kEndCalled\"),kAbortController=Symbol.for(\"kAbortController\"),kClearTimeout=Symbol(\"kClearTimeout\"),kCorked=Symbol.for(\"kCorked\"),searchParamsSymbol=Symbol.for(\"query\"),StringPrototypeSlice=String.prototype.slice,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeToUpperCase=String.prototype.toUpperCase,StringPrototypeIncludes=String.prototype.includes,StringPrototypeCharCodeAt=String.prototype.charCodeAt,StringPrototypeIndexOf=String.prototype.indexOf,ArrayIsArray=Array.isArray,RegExpPrototypeExec=RegExp.prototype.exec,ObjectAssign=Object.assign,ObjectPrototypeHasOwnProperty=Object.prototype.hasOwnProperty,INVALID_PATH_REGEX=/[^\\u0021-\\u00ff]/,NODE_HTTP_WARNING=\"WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\";var _defaultHTTPSAgent,kInternalRequest=Symbol(\"kInternalRequest\"),kInternalSocketData=Symbol.for(\"::bunternal::\");const kEmptyBuffer=Buffer.alloc(0);function isValidTLSArray(obj){if(typeof obj===\"string\"||isTypedArray(obj)||obj instanceof ArrayBuffer||obj instanceof Blob)return!0;if(Array.isArray(obj)){for(var i=0;i{this.close()}),host=port\?.host,port=port\?.port,typeof port\?.callback===\"function\")onListen=port\?.callback}if(typeof backlog===\"function\")onListen=backlog;const ResponseClass=this.#options.ServerResponse||ServerResponse,RequestClass=this.#options.IncomingMessage||IncomingMessage;try{const tls=this.#tls;if(tls)this.serverName=tls.serverName||host||\"localhost\";this.#server=Bun.serve({tls,port,hostname:host,websocket:{open(ws){ws.data.open(ws)},message(ws,message){ws.data.message(ws,message)},close(ws,code,reason){ws.data.close(ws,code,reason)},drain(ws){ws.data.drain(ws)}},fetch(req,_server){var pendingResponse,pendingError,rejectFunction,resolveFunction,reject=(err)=>{if(pendingError)return;if(pendingError=err,rejectFunction)rejectFunction(err)},reply=function(resp){if(pendingResponse)return;if(pendingResponse=resp,resolveFunction)resolveFunction(resp)};const http_req=new RequestClass(req),http_res=new ResponseClass({reply,req:http_req});if(http_req.once(\"error\",(err)=>reject(err)),http_res.once(\"error\",(err)=>reject(err)),req.headers.get(\"upgrade\")){const socket=new FakeSocket;socket[kInternalSocketData]=[_server,http_res,req],server.emit(\"upgrade\",http_req,socket,kEmptyBuffer)}else server.emit(\"request\",http_req,http_res);if(pendingError)throw pendingError;if(pendingResponse)return pendingResponse;return new Promise((resolve,reject2)=>{resolveFunction=resolve,rejectFunction=reject2})}}),setTimeout(emitListeningNextTick,1,this,onListen,null,this.#server.hostname,this.#server.port)}catch(err){setTimeout(emitListeningNextTick,1,this,onListen,err)}return this}setTimeout(msecs,callback){}}function assignHeaders(object,req){var headers=req.headers.toJSON();const rawHeaders=@newArrayWithSize(req.headers.count*2);var i=0;for(let key in headers)rawHeaders[i++]=key,rawHeaders[i++]=headers[key];object.headers=headers,object.rawHeaders=rawHeaders}function destroyBodyStreamNT(bodyStream){bodyStream.destroy()}var defaultIncomingOpts={type:\"request\"};function getDefaultHTTPSAgent(){return _defaultHTTPSAgent\?\?=new Agent({defaultPort:443,protocol:\"https:\"})}class IncomingMessage extends Readable{method;complete;constructor(req,defaultIncomingOpts2){const method=req.method;super();const url=new URL(req.url);var{type=\"request\",[kInternalRequest]:nodeReq}=defaultIncomingOpts2||{};this.#noBody=type===\"request\"\?method===\"GET\"||method===\"HEAD\"||method===\"TRACE\"||method===\"CONNECT\"||method===\"OPTIONS\"||(parseInt(req.headers.get(\"Content-Length\")||\"\")||0)===0:!1,this.#req=req,this.method=method,this.#type=type,this.complete=!!this.#noBody,this.#bodyStream=void 0;const socket=new FakeSocket;socket.remoteAddress=url.hostname,socket.remotePort=url.port,this.#fakeSocket=socket,this.url=url.pathname+url.search,this.#nodeReq=nodeReq,assignHeaders(this,req)}headers;rawHeaders;_consuming=!1;_dumped=!1;#bodyStream;#fakeSocket;#noBody=!1;#aborted=!1;#req;url;#type;#nodeReq;get req(){return this.#nodeReq}_construct(callback){if(this.#type===\"response\"||this.#noBody){callback();return}const contentLength=this.#req.headers.get(\"content-length\");if((contentLength\?parseInt(contentLength,10):0)===0){this.#noBody=!0,callback();return}callback()}async#consumeStream(reader){while(!0){var{done,value}=await reader.readMany();if(this.#aborted)return;if(done){this.push(null),this.destroy();break}for(var v of value)this.push(v)}}_read(size){if(this.#noBody)this.push(null),this.complete=!0;else if(this.#bodyStream==null){const reader=this.#req.body\?.getReader();if(!reader){this.push(null);return}this.#bodyStream=reader,this.#consumeStream(reader)}}get aborted(){return this.#aborted}#abort(){if(this.#aborted)return;this.#aborted=!0;var bodyStream=this.#bodyStream;if(!bodyStream)return;bodyStream.cancel(),this.complete=!0,this.#bodyStream=void 0,this.push(null)}get connection(){return this.#fakeSocket}get statusCode(){return this.#req.status}get statusMessage(){return STATUS_CODES[this.#req.status]}get httpVersion(){return\"1.1\"}get rawTrailers(){return[]}get httpVersionMajor(){return 1}get httpVersionMinor(){return 1}get trailers(){return kEmptyObject}get socket(){return this.#fakeSocket\?\?=new FakeSocket}set socket(val){this.#fakeSocket=val}setTimeout(msecs,callback){throw new Error(\"not implemented\")}}function emitErrorNt(msg,err,callback){if(callback(err),typeof msg.emit===\"function\"&&!msg._closed)msg.emit(\"error\",err)}function onError(self,err,cb){process.nextTick(()=>emitErrorNt(self,err,cb))}function write_(msg,chunk,encoding,callback,fromEnd){if(typeof callback!==\"function\")callback=nop;let len;if(chunk===null)throw new Error(\"ERR_STREAM_NULL_VALUES\");else if(typeof chunk===\"string\")len=Buffer.byteLength(chunk,encoding);else throw new Error(\"Invalid arg type for chunk\");let err;if(msg.finished)err=new Error(\"ERR_STREAM_WRITE_AFTER_END\");else if(msg.destroyed)err=new Error(\"ERR_STREAM_DESTROYED\");if(err){if(!msg.destroyed)onError(msg,err,callback);else process.nextTick(callback,err);return!1}if(!msg._header){if(fromEnd)msg._contentLength=len}if(!msg._hasBody)return process.nextTick(callback),!0;return!0}class OutgoingMessage extends Writable{constructor(){super(...arguments)}#headers;headersSent=!1;sendDate=!0;req;timeout;#finished=!1;[kEndCalled]=!1;#fakeSocket;#timeoutTimer;[kAbortController]=null;_implicitHeader(){}get headers(){if(!this.#headers)return kEmptyObject;return this.#headers.toJSON()}get shouldKeepAlive(){return!0}get chunkedEncoding(){return!1}set chunkedEncoding(value){}set shouldKeepAlive(value){}get useChunkedEncodingByDefault(){return!0}set useChunkedEncodingByDefault(value){}get socket(){return this.#fakeSocket\?\?=new FakeSocket}set socket(val){this.#fakeSocket=val}get connection(){return this.socket}get finished(){return this.#finished}appendHeader(name,value){var headers=this.#headers\?\?=new Headers;headers.append(name,value)}flushHeaders(){}getHeader(name){return getHeader(this.#headers,name)}getHeaders(){if(!this.#headers)return kEmptyObject;return this.#headers.toJSON()}getHeaderNames(){var headers=this.#headers;if(!headers)return[];return Array.from(headers.keys())}removeHeader(name){if(!this.#headers)return;this.#headers.delete(name)}setHeader(name,value){var headers=this.#headers\?\?=new Headers;return headers.set(name,value),this}hasHeader(name){if(!this.#headers)return!1;return this.#headers.has(name)}addTrailers(headers){throw new Error(\"not implemented\")}[kClearTimeout](){if(this.#timeoutTimer)clearTimeout(this.#timeoutTimer),this.removeAllListeners(\"timeout\"),this.#timeoutTimer=void 0}#onTimeout(){this.#timeoutTimer=void 0,this[kAbortController]\?.abort(),this.emit(\"timeout\")}setTimeout(msecs,callback){if(this.destroyed)return this;if(this.timeout=msecs=validateMsecs(msecs,\"msecs\"),clearTimeout(this.#timeoutTimer),msecs===0){if(callback!==void 0)validateFunction(callback,\"callback\"),this.removeListener(\"timeout\",callback);this.#timeoutTimer=void 0}else if(this.#timeoutTimer=setTimeout(this.#onTimeout.bind(this),msecs).unref(),callback!==void 0)validateFunction(callback,\"callback\"),this.once(\"timeout\",callback);return this}}let OriginalWriteHeadFn,OriginalImplicitHeadFn;class ServerResponse extends Writable{constructor({req,reply}){super();if(this.req=req,this._reply=reply,this.sendDate=!0,this.statusCode=200,this.headersSent=!1,this.statusMessage=void 0,this.#controller=void 0,this.#firstWrite=void 0,this._writableState.decodeStrings=!1,this.#deferred=void 0,req.method===\"HEAD\")this._hasBody=!1}req;_reply;sendDate;statusCode;#headers;headersSent=!1;statusMessage;#controller;#firstWrite;_sent100=!1;_defaultKeepAlive=!1;_removedConnection=!1;_removedContLen=!1;_hasBody=!0;#deferred=void 0;#finished=!1;_implicitHeader(){this.writeHead(this.statusCode)}_write(chunk,encoding,callback){if(!this.#firstWrite&&!this.headersSent){this.#firstWrite=chunk,callback();return}this.#ensureReadableStreamController((controller)=>{controller.write(chunk),callback()})}_writev(chunks,callback){if(chunks.length===1&&!this.headersSent&&!this.#firstWrite){this.#firstWrite=chunks[0].chunk,callback();return}this.#ensureReadableStreamController((controller)=>{for(let chunk of chunks)controller.write(chunk.chunk);callback()})}#ensureReadableStreamController(run){var thisController=this.#controller;if(thisController)return run(thisController);this.headersSent=!0;var firstWrite=this.#firstWrite;this.#firstWrite=void 0,this._reply(new Response(new ReadableStream({type:\"direct\",pull:(controller)=>{if(this.#controller=controller,firstWrite)controller.write(firstWrite);if(firstWrite=void 0,run(controller),!this.#finished)return new Promise((resolve)=>{this.#deferred=resolve})}}),{headers:this.#headers,status:this.statusCode,statusText:this.statusMessage\?\?STATUS_CODES[this.statusCode]}))}#drainHeadersIfObservable(){if(this._implicitHeader===OriginalImplicitHeadFn&&this.writeHead===OriginalWriteHeadFn)return;this._implicitHeader()}_final(callback){if(!this.headersSent){var data=this.#firstWrite||\"\";this.#firstWrite=void 0,this.#finished=!0,this.#drainHeadersIfObservable(),this._reply(new Response(data,{headers:this.#headers,status:this.statusCode,statusText:this.statusMessage\?\?STATUS_CODES[this.statusCode]})),callback&&callback();return}this.#finished=!0,this.#ensureReadableStreamController((controller)=>{controller.end(),callback();var deferred=this.#deferred;if(deferred)this.#deferred=void 0,deferred()})}writeProcessing(){throw new Error(\"not implemented\")}addTrailers(headers){throw new Error(\"not implemented\")}assignSocket(socket){throw new Error(\"not implemented\")}detachSocket(socket){throw new Error(\"not implemented\")}writeContinue(callback){throw new Error(\"not implemented\")}setTimeout(msecs,callback){throw new Error(\"not implemented\")}get shouldKeepAlive(){return!0}get chunkedEncoding(){return!1}set chunkedEncoding(value){}set shouldKeepAlive(value){}get useChunkedEncodingByDefault(){return!0}set useChunkedEncodingByDefault(value){}appendHeader(name,value){var headers=this.#headers\?\?=new Headers;headers.append(name,value)}flushHeaders(){}getHeader(name){return getHeader(this.#headers,name)}getHeaders(){var headers=this.#headers;if(!headers)return kEmptyObject;return headers.toJSON()}getHeaderNames(){var headers=this.#headers;if(!headers)return[];return Array.from(headers.keys())}removeHeader(name){if(!this.#headers)return;this.#headers.delete(name)}setHeader(name,value){var headers=this.#headers\?\?=new Headers;return headers.set(name,value),this}hasHeader(name){if(!this.#headers)return!1;return this.#headers.has(name)}writeHead(statusCode,statusMessage,headers){return _writeHead(statusCode,statusMessage,headers,this),this}}OriginalWriteHeadFn=ServerResponse.prototype.writeHead,OriginalImplicitHeadFn=ServerResponse.prototype._implicitHeader;class ClientRequest extends OutgoingMessage{#timeout;#res=null;#upgradeOrConnect=!1;#parser=null;#maxHeadersCount=null;#reusedSocket=!1;#host;#protocol;#method;#port;#useDefaultPort;#joinDuplicateHeaders;#maxHeaderSize;#agent=globalAgent;#path;#socketPath;#bodyChunks=null;#fetchRequest;#signal=null;[kAbortController]=null;#timeoutTimer=void 0;#options;#finished;get path(){return this.#path}get port(){return this.#port}get method(){return this.#method}get host(){return this.#host}get protocol(){return this.#protocol}_write(chunk,encoding,callback){if(!this.#bodyChunks){this.#bodyChunks=[chunk],callback();return}this.#bodyChunks.push(chunk),callback()}_writev(chunks,callback){if(!this.#bodyChunks){this.#bodyChunks=chunks,callback();return}this.#bodyChunks.push(...chunks),callback()}_final(callback){if(this.#finished=!0,this[kAbortController]=new AbortController,this[kAbortController].signal.addEventListener(\"abort\",()=>{this[kClearTimeout]()}),this.#signal\?.aborted)this[kAbortController].abort();var method=this.#method,body=Buffer.concat(this.#bodyChunks||[]);try{this.#fetchRequest=fetch(`${this.#protocol}//${this.#host}${this.#useDefaultPort\?\"\":\":\"+this.#port}${this.#path}`,{method,headers:this.getHeaders(),body:body&&method!==\"GET\"&&method!==\"HEAD\"&&method!==\"OPTIONS\"\?body:void 0,redirect:\"manual\",verbose:!1,signal:this[kAbortController].signal,timeout:!1}).then((response)=>{var res=this.#res=new IncomingMessage(response,{type:\"response\",[kInternalRequest]:this});this.emit(\"response\",res)}).catch((err)=>{this.emit(\"error\",err)}).finally(()=>{this.#fetchRequest=null,this[kClearTimeout]()})}catch(err){this.emit(\"error\",err)}finally{callback()}}get aborted(){return this.#signal\?.aborted||!!this[kAbortController]\?.signal.aborted}abort(){if(this.aborted)return;this[kAbortController].abort()}constructor(input,options,cb){super();if(typeof input===\"string\"){const urlStr=input;try{var urlObject=new URL(urlStr)}catch(e){@throwTypeError(`Invalid URL: ${urlStr}`)}input=urlToHttpOptions(urlObject)}else if(input&&typeof input===\"object\"&&input instanceof URL)input=urlToHttpOptions(input);else cb=options,options=input,input=null;if(typeof options===\"function\")cb=options,options=input||kEmptyObject;else options=ObjectAssign(input||{},options);var defaultAgent=options._defaultAgent||Agent.globalAgent;let protocol=options.protocol;if(!protocol)if(options.port===443)protocol=\"https:\";else protocol=defaultAgent.protocol||\"http:\";switch(this.#protocol=protocol,this.#agent\?.protocol){case void 0:break;case\"http:\":if(protocol===\"https:\"){defaultAgent=this.#agent=getDefaultHTTPSAgent();break}case\"https:\":if(protocol===\"https\"){defaultAgent=this.#agent=Agent.globalAgent;break}default:break}if(options.path){const path=String(options.path);if(RegExpPrototypeExec.call(INVALID_PATH_REGEX,path)!==null)throw new Error(\"Path contains unescaped characters\")}if(protocol!==\"http:\"&&protocol!==\"https:\"&&protocol){const expectedProtocol=defaultAgent\?.protocol\?\?\"http:\";throw new Error(`Protocol mismatch. Expected: ${expectedProtocol}. Got: ${protocol}`)}const defaultPort=protocol===\"https:\"\?443:80;this.#port=options.port||options.defaultPort||this.#agent\?.defaultPort||defaultPort,this.#useDefaultPort=this.#port===defaultPort;const host=this.#host=options.host=validateHost(options.hostname,\"hostname\")||validateHost(options.host,\"host\")||\"localhost\";this.#socketPath=options.socketPath;const signal=options.signal;if(signal)signal.addEventListener(\"abort\",()=>{this[kAbortController]\?.abort()}),this.#signal=signal;let method=options.method;const methodIsString=typeof method===\"string\";if(method!==null&&method!==void 0&&!methodIsString)throw new Error(\"ERR_INVALID_ARG_TYPE: options.method\");if(methodIsString&&method){if(!checkIsHttpToken(method))throw new Error(\"ERR_INVALID_HTTP_TOKEN: Method\");method=this.#method=StringPrototypeToUpperCase.call(method)}else method=this.#method=\"GET\";const _maxHeaderSize=options.maxHeaderSize;this.#maxHeaderSize=_maxHeaderSize;var _joinDuplicateHeaders=options.joinDuplicateHeaders;if(this.#joinDuplicateHeaders=_joinDuplicateHeaders,this.#path=options.path||\"/\",cb)this.once(\"response\",cb);this.#finished=!1,this.#res=null,this.#upgradeOrConnect=!1,this.#parser=null,this.#maxHeadersCount=null,this.#reusedSocket=!1,this.#host=host,this.#protocol=protocol;var timeout=options.timeout;if(timeout!==void 0&&timeout!==0)this.setTimeout(timeout,void 0);if(!ArrayIsArray(headers)){var headers=options.headers;if(headers)for(let key in headers)this.setHeader(key,headers[key]);var auth=options.auth;if(auth&&!this.getHeader(\"Authorization\"))this.setHeader(\"Authorization\",\"Basic \"+Buffer.from(auth).toString(\"base64\"))}var{signal:_signal,...optsWithoutSignal}=options;this.#options=optsWithoutSignal}setSocketKeepAlive(enable=!0,initialDelay=0){}setNoDelay(noDelay=!0){}[kClearTimeout](){if(this.#timeoutTimer)clearTimeout(this.#timeoutTimer),this.#timeoutTimer=void 0,this.removeAllListeners(\"timeout\")}#onTimeout(){this.#timeoutTimer=void 0,this[kAbortController]\?.abort(),this.emit(\"timeout\")}setTimeout(msecs,callback){if(this.destroyed)return this;if(this.timeout=msecs=validateMsecs(msecs,\"msecs\"),clearTimeout(this.#timeoutTimer),msecs===0){if(callback!==void 0)validateFunction(callback,\"callback\"),this.removeListener(\"timeout\",callback);this.#timeoutTimer=void 0}else if(this.#timeoutTimer=setTimeout(this.#onTimeout.bind(this),msecs).unref(),callback!==void 0)validateFunction(callback,\"callback\"),this.once(\"timeout\",callback);return this}}function urlToHttpOptions(url){var{protocol,hostname,hash,search,pathname,href,port,username,password}=url;return{protocol,hostname:typeof hostname===\"string\"&&StringPrototypeStartsWith.call(hostname,\"[\")\?StringPrototypeSlice.call(hostname,1,-1):hostname,hash,search,pathname,path:`${pathname||\"\"}${search||\"\"}`,href,port:port\?Number(port):protocol===\"https:\"\?443:protocol===\"http:\"\?80:void 0,auth:username||password\?`${decodeURIComponent(username)}:${decodeURIComponent(password)}`:void 0}}function validateHost(host,name){if(host!==null&&host!==void 0&&typeof host!==\"string\")throw new Error(\"Invalid arg type in options\");return host}const tokenRegExp=/^[\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]+$/;function checkIsHttpToken(val){return RegExpPrototypeExec.call(tokenRegExp,val)!==null}const METHODS=[\"ACL\",\"BIND\",\"CHECKOUT\",\"CONNECT\",\"COPY\",\"DELETE\",\"GET\",\"HEAD\",\"LINK\",\"LOCK\",\"M-SEARCH\",\"MERGE\",\"MKACTIVITY\",\"MKCALENDAR\",\"MKCOL\",\"MOVE\",\"NOTIFY\",\"OPTIONS\",\"PATCH\",\"POST\",\"PROPFIND\",\"PROPPATCH\",\"PURGE\",\"PUT\",\"REBIND\",\"REPORT\",\"SEARCH\",\"SOURCE\",\"SUBSCRIBE\",\"TRACE\",\"UNBIND\",\"UNLINK\",\"UNLOCK\",\"UNSUBSCRIBE\"],STATUS_CODES={100:\"Continue\",101:\"Switching Protocols\",102:\"Processing\",103:\"Early Hints\",200:\"OK\",201:\"Created\",202:\"Accepted\",203:\"Non-Authoritative Information\",204:\"No Content\",205:\"Reset Content\",206:\"Partial Content\",207:\"Multi-Status\",208:\"Already Reported\",226:\"IM Used\",300:\"Multiple Choices\",301:\"Moved Permanently\",302:\"Found\",303:\"See Other\",304:\"Not Modified\",305:\"Use Proxy\",307:\"Temporary Redirect\",308:\"Permanent Redirect\",400:\"Bad Request\",401:\"Unauthorized\",402:\"Payment Required\",403:\"Forbidden\",404:\"Not Found\",405:\"Method Not Allowed\",406:\"Not Acceptable\",407:\"Proxy Authentication Required\",408:\"Request Timeout\",409:\"Conflict\",410:\"Gone\",411:\"Length Required\",412:\"Precondition Failed\",413:\"Payload Too Large\",414:\"URI Too Long\",415:\"Unsupported Media Type\",416:\"Range Not Satisfiable\",417:\"Expectation Failed\",418:\"I'm a Teapot\",421:\"Misdirected Request\",422:\"Unprocessable Entity\",423:\"Locked\",424:\"Failed Dependency\",425:\"Too Early\",426:\"Upgrade Required\",428:\"Precondition Required\",429:\"Too Many Requests\",431:\"Request Header Fields Too Large\",451:\"Unavailable For Legal Reasons\",500:\"Internal Server Error\",501:\"Not Implemented\",502:\"Bad Gateway\",503:\"Service Unavailable\",504:\"Gateway Timeout\",505:\"HTTP Version Not Supported\",506:\"Variant Also Negotiates\",507:\"Insufficient Storage\",508:\"Loop Detected\",509:\"Bandwidth Limit Exceeded\",510:\"Not Extended\",511:\"Network Authentication Required\"};function _normalizeArgs(args){let arr;if(args.length===0)return arr=[{},null],arr;const arg0=args[0];let options={};if(typeof arg0===\"object\"&&arg0!==null)options=arg0;else if(options.port=arg0,args.length>1&&typeof args[1]===\"string\")options.host=args[1];const cb=args[args.length-1];if(typeof cb!==\"function\")arr=[options,null];else arr=[options,cb];return arr}function _writeHead(statusCode,reason,obj,response){if(statusCode|=0,statusCode<100||statusCode>999)throw new Error(\"status code must be between 100 and 999\");if(typeof reason===\"string\")response.statusMessage=reason;else{if(!response.statusMessage)response.statusMessage=STATUS_CODES[statusCode]||\"unknown\";obj=reason}response.statusCode=statusCode;{let k;if(Array.isArray(obj)){if(obj.length%2!==0)throw new Error(\"raw headers must have an even number of elements\");for(let n=0;n=100&&statusCode<=199)response._hasBody=!1}function request(url,options,cb){return new ClientRequest(url,options,cb)}function get(url,options,cb){const req=request(url,options,cb);return req.end(),req}var globalAgent=new Agent;return $={Agent,Server,METHODS,STATUS_CODES,createServer,ServerResponse,IncomingMessage,request,get,maxHeaderSize:16384,validateHeaderName,validateHeaderValue,setMaxIdleHTTPParsers(max){},globalAgent,ClientRequest,OutgoingMessage},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttp2Code = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function connect(){throwNotImplemented(\"node:http2 connect\",887)}const constants={NGHTTP2_ERR_FRAME_SIZE_ERROR:-522,NGHTTP2_SESSION_SERVER:0,NGHTTP2_SESSION_CLIENT:1,NGHTTP2_STREAM_STATE_IDLE:1,NGHTTP2_STREAM_STATE_OPEN:2,NGHTTP2_STREAM_STATE_RESERVED_LOCAL:3,NGHTTP2_STREAM_STATE_RESERVED_REMOTE:4,NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL:5,NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE:6,NGHTTP2_STREAM_STATE_CLOSED:7,NGHTTP2_FLAG_NONE:0,NGHTTP2_FLAG_END_STREAM:1,NGHTTP2_FLAG_END_HEADERS:4,NGHTTP2_FLAG_ACK:1,NGHTTP2_FLAG_PADDED:8,NGHTTP2_FLAG_PRIORITY:32,DEFAULT_SETTINGS_HEADER_TABLE_SIZE:4096,DEFAULT_SETTINGS_ENABLE_PUSH:1,DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS:4294967295,DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE:65535,DEFAULT_SETTINGS_MAX_FRAME_SIZE:16384,DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE:65535,DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL:0,MAX_MAX_FRAME_SIZE:16777215,MIN_MAX_FRAME_SIZE:16384,MAX_INITIAL_WINDOW_SIZE:2147483647,NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:1,NGHTTP2_SETTINGS_ENABLE_PUSH:2,NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:3,NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:4,NGHTTP2_SETTINGS_MAX_FRAME_SIZE:5,NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:6,NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:8,PADDING_STRATEGY_NONE:0,PADDING_STRATEGY_ALIGNED:1,PADDING_STRATEGY_MAX:2,PADDING_STRATEGY_CALLBACK:1,NGHTTP2_NO_ERROR:0,NGHTTP2_PROTOCOL_ERROR:1,NGHTTP2_INTERNAL_ERROR:2,NGHTTP2_FLOW_CONTROL_ERROR:3,NGHTTP2_SETTINGS_TIMEOUT:4,NGHTTP2_STREAM_CLOSED:5,NGHTTP2_FRAME_SIZE_ERROR:6,NGHTTP2_REFUSED_STREAM:7,NGHTTP2_CANCEL:8,NGHTTP2_COMPRESSION_ERROR:9,NGHTTP2_CONNECT_ERROR:10,NGHTTP2_ENHANCE_YOUR_CALM:11,NGHTTP2_INADEQUATE_SECURITY:12,NGHTTP2_HTTP_1_1_REQUIRED:13,NGHTTP2_DEFAULT_WEIGHT:16,HTTP2_HEADER_STATUS:\":status\",HTTP2_HEADER_METHOD:\":method\",HTTP2_HEADER_AUTHORITY:\":authority\",HTTP2_HEADER_SCHEME:\":scheme\",HTTP2_HEADER_PATH:\":path\",HTTP2_HEADER_PROTOCOL:\":protocol\",HTTP2_HEADER_ACCEPT_ENCODING:\"accept-encoding\",HTTP2_HEADER_ACCEPT_LANGUAGE:\"accept-language\",HTTP2_HEADER_ACCEPT_RANGES:\"accept-ranges\",HTTP2_HEADER_ACCEPT:\"accept\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS:\"access-control-allow-credentials\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS:\"access-control-allow-headers\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS:\"access-control-allow-methods\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN:\"access-control-allow-origin\",HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS:\"access-control-expose-headers\",HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS:\"access-control-request-headers\",HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD:\"access-control-request-method\",HTTP2_HEADER_AGE:\"age\",HTTP2_HEADER_AUTHORIZATION:\"authorization\",HTTP2_HEADER_CACHE_CONTROL:\"cache-control\",HTTP2_HEADER_CONNECTION:\"connection\",HTTP2_HEADER_CONTENT_DISPOSITION:\"content-disposition\",HTTP2_HEADER_CONTENT_ENCODING:\"content-encoding\",HTTP2_HEADER_CONTENT_LENGTH:\"content-length\",HTTP2_HEADER_CONTENT_TYPE:\"content-type\",HTTP2_HEADER_COOKIE:\"cookie\",HTTP2_HEADER_DATE:\"date\",HTTP2_HEADER_ETAG:\"etag\",HTTP2_HEADER_FORWARDED:\"forwarded\",HTTP2_HEADER_HOST:\"host\",HTTP2_HEADER_IF_MODIFIED_SINCE:\"if-modified-since\",HTTP2_HEADER_IF_NONE_MATCH:\"if-none-match\",HTTP2_HEADER_IF_RANGE:\"if-range\",HTTP2_HEADER_LAST_MODIFIED:\"last-modified\",HTTP2_HEADER_LINK:\"link\",HTTP2_HEADER_LOCATION:\"location\",HTTP2_HEADER_RANGE:\"range\",HTTP2_HEADER_REFERER:\"referer\",HTTP2_HEADER_SERVER:\"server\",HTTP2_HEADER_SET_COOKIE:\"set-cookie\",HTTP2_HEADER_STRICT_TRANSPORT_SECURITY:\"strict-transport-security\",HTTP2_HEADER_TRANSFER_ENCODING:\"transfer-encoding\",HTTP2_HEADER_TE:\"te\",HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS:\"upgrade-insecure-requests\",HTTP2_HEADER_UPGRADE:\"upgrade\",HTTP2_HEADER_USER_AGENT:\"user-agent\",HTTP2_HEADER_VARY:\"vary\",HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS:\"x-content-type-options\",HTTP2_HEADER_X_FRAME_OPTIONS:\"x-frame-options\",HTTP2_HEADER_KEEP_ALIVE:\"keep-alive\",HTTP2_HEADER_PROXY_CONNECTION:\"proxy-connection\",HTTP2_HEADER_X_XSS_PROTECTION:\"x-xss-protection\",HTTP2_HEADER_ALT_SVC:\"alt-svc\",HTTP2_HEADER_CONTENT_SECURITY_POLICY:\"content-security-policy\",HTTP2_HEADER_EARLY_DATA:\"early-data\",HTTP2_HEADER_EXPECT_CT:\"expect-ct\",HTTP2_HEADER_ORIGIN:\"origin\",HTTP2_HEADER_PURPOSE:\"purpose\",HTTP2_HEADER_TIMING_ALLOW_ORIGIN:\"timing-allow-origin\",HTTP2_HEADER_X_FORWARDED_FOR:\"x-forwarded-for\",HTTP2_HEADER_PRIORITY:\"priority\",HTTP2_HEADER_ACCEPT_CHARSET:\"accept-charset\",HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE:\"access-control-max-age\",HTTP2_HEADER_ALLOW:\"allow\",HTTP2_HEADER_CONTENT_LANGUAGE:\"content-language\",HTTP2_HEADER_CONTENT_LOCATION:\"content-location\",HTTP2_HEADER_CONTENT_MD5:\"content-md5\",HTTP2_HEADER_CONTENT_RANGE:\"content-range\",HTTP2_HEADER_DNT:\"dnt\",HTTP2_HEADER_EXPECT:\"expect\",HTTP2_HEADER_EXPIRES:\"expires\",HTTP2_HEADER_FROM:\"from\",HTTP2_HEADER_IF_MATCH:\"if-match\",HTTP2_HEADER_IF_UNMODIFIED_SINCE:\"if-unmodified-since\",HTTP2_HEADER_MAX_FORWARDS:\"max-forwards\",HTTP2_HEADER_PREFER:\"prefer\",HTTP2_HEADER_PROXY_AUTHENTICATE:\"proxy-authenticate\",HTTP2_HEADER_PROXY_AUTHORIZATION:\"proxy-authorization\",HTTP2_HEADER_REFRESH:\"refresh\",HTTP2_HEADER_RETRY_AFTER:\"retry-after\",HTTP2_HEADER_TRAILER:\"trailer\",HTTP2_HEADER_TK:\"tk\",HTTP2_HEADER_VIA:\"via\",HTTP2_HEADER_WARNING:\"warning\",HTTP2_HEADER_WWW_AUTHENTICATE:\"www-authenticate\",HTTP2_HEADER_HTTP2_SETTINGS:\"http2-settings\",HTTP2_METHOD_ACL:\"ACL\",HTTP2_METHOD_BASELINE_CONTROL:\"BASELINE-CONTROL\",HTTP2_METHOD_BIND:\"BIND\",HTTP2_METHOD_CHECKIN:\"CHECKIN\",HTTP2_METHOD_CHECKOUT:\"CHECKOUT\",HTTP2_METHOD_CONNECT:\"CONNECT\",HTTP2_METHOD_COPY:\"COPY\",HTTP2_METHOD_DELETE:\"DELETE\",HTTP2_METHOD_GET:\"GET\",HTTP2_METHOD_HEAD:\"HEAD\",HTTP2_METHOD_LABEL:\"LABEL\",HTTP2_METHOD_LINK:\"LINK\",HTTP2_METHOD_LOCK:\"LOCK\",HTTP2_METHOD_MERGE:\"MERGE\",HTTP2_METHOD_MKACTIVITY:\"MKACTIVITY\",HTTP2_METHOD_MKCALENDAR:\"MKCALENDAR\",HTTP2_METHOD_MKCOL:\"MKCOL\",HTTP2_METHOD_MKREDIRECTREF:\"MKREDIRECTREF\",HTTP2_METHOD_MKWORKSPACE:\"MKWORKSPACE\",HTTP2_METHOD_MOVE:\"MOVE\",HTTP2_METHOD_OPTIONS:\"OPTIONS\",HTTP2_METHOD_ORDERPATCH:\"ORDERPATCH\",HTTP2_METHOD_PATCH:\"PATCH\",HTTP2_METHOD_POST:\"POST\",HTTP2_METHOD_PRI:\"PRI\",HTTP2_METHOD_PROPFIND:\"PROPFIND\",HTTP2_METHOD_PROPPATCH:\"PROPPATCH\",HTTP2_METHOD_PUT:\"PUT\",HTTP2_METHOD_REBIND:\"REBIND\",HTTP2_METHOD_REPORT:\"REPORT\",HTTP2_METHOD_SEARCH:\"SEARCH\",HTTP2_METHOD_TRACE:\"TRACE\",HTTP2_METHOD_UNBIND:\"UNBIND\",HTTP2_METHOD_UNCHECKOUT:\"UNCHECKOUT\",HTTP2_METHOD_UNLINK:\"UNLINK\",HTTP2_METHOD_UNLOCK:\"UNLOCK\",HTTP2_METHOD_UPDATE:\"UPDATE\",HTTP2_METHOD_UPDATEREDIRECTREF:\"UPDATEREDIRECTREF\",HTTP2_METHOD_VERSION_CONTROL:\"VERSION-CONTROL\",HTTP_STATUS_CONTINUE:100,HTTP_STATUS_SWITCHING_PROTOCOLS:101,HTTP_STATUS_PROCESSING:102,HTTP_STATUS_EARLY_HINTS:103,HTTP_STATUS_OK:200,HTTP_STATUS_CREATED:201,HTTP_STATUS_ACCEPTED:202,HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION:203,HTTP_STATUS_NO_CONTENT:204,HTTP_STATUS_RESET_CONTENT:205,HTTP_STATUS_PARTIAL_CONTENT:206,HTTP_STATUS_MULTI_STATUS:207,HTTP_STATUS_ALREADY_REPORTED:208,HTTP_STATUS_IM_USED:226,HTTP_STATUS_MULTIPLE_CHOICES:300,HTTP_STATUS_MOVED_PERMANENTLY:301,HTTP_STATUS_FOUND:302,HTTP_STATUS_SEE_OTHER:303,HTTP_STATUS_NOT_MODIFIED:304,HTTP_STATUS_USE_PROXY:305,HTTP_STATUS_TEMPORARY_REDIRECT:307,HTTP_STATUS_PERMANENT_REDIRECT:308,HTTP_STATUS_BAD_REQUEST:400,HTTP_STATUS_UNAUTHORIZED:401,HTTP_STATUS_PAYMENT_REQUIRED:402,HTTP_STATUS_FORBIDDEN:403,HTTP_STATUS_NOT_FOUND:404,HTTP_STATUS_METHOD_NOT_ALLOWED:405,HTTP_STATUS_NOT_ACCEPTABLE:406,HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED:407,HTTP_STATUS_REQUEST_TIMEOUT:408,HTTP_STATUS_CONFLICT:409,HTTP_STATUS_GONE:410,HTTP_STATUS_LENGTH_REQUIRED:411,HTTP_STATUS_PRECONDITION_FAILED:412,HTTP_STATUS_PAYLOAD_TOO_LARGE:413,HTTP_STATUS_URI_TOO_LONG:414,HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE:415,HTTP_STATUS_RANGE_NOT_SATISFIABLE:416,HTTP_STATUS_EXPECTATION_FAILED:417,HTTP_STATUS_TEAPOT:418,HTTP_STATUS_MISDIRECTED_REQUEST:421,HTTP_STATUS_UNPROCESSABLE_ENTITY:422,HTTP_STATUS_LOCKED:423,HTTP_STATUS_FAILED_DEPENDENCY:424,HTTP_STATUS_TOO_EARLY:425,HTTP_STATUS_UPGRADE_REQUIRED:426,HTTP_STATUS_PRECONDITION_REQUIRED:428,HTTP_STATUS_TOO_MANY_REQUESTS:429,HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE:431,HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS:451,HTTP_STATUS_INTERNAL_SERVER_ERROR:500,HTTP_STATUS_NOT_IMPLEMENTED:501,HTTP_STATUS_BAD_GATEWAY:502,HTTP_STATUS_SERVICE_UNAVAILABLE:503,HTTP_STATUS_GATEWAY_TIMEOUT:504,HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED:505,HTTP_STATUS_VARIANT_ALSO_NEGOTIATES:506,HTTP_STATUS_INSUFFICIENT_STORAGE:507,HTTP_STATUS_LOOP_DETECTED:508,HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED:509,HTTP_STATUS_NOT_EXTENDED:510,HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED:511};function createServer(){throwNotImplemented(\"node:http2 createServer\",887)}function createSecureServer(){throwNotImplemented(\"node:http2 createSecureServer\",887)}function getDefaultSettings(){return{headerTableSize:4096,enablePush:!0,initialWindowSize:65535,maxFrameSize:16384,maxConcurrentStreams:4294967295,maxHeaderSize:65535,maxHeaderListSize:65535,enableConnectProtocol:!1}}function getPackedSettings(){return Buffer.alloc(0)}function getUnpackedSettings(){return Buffer.alloc(0)}const sensitiveHeaders=Symbol.for(\"nodejs.http2.sensitiveHeaders\");function Http2ServerRequest(){throwNotImplemented(\"node:http2 Http2ServerRequest\",887)}function Http2ServerResponse(){throwNotImplemented(\"node:http2 Http2ServerResponse\",887)}return $={constants,createServer,createSecureServer,getDefaultSettings,getPackedSettings,getUnpackedSettings,sensitiveHeaders,Http2ServerRequest,Http2ServerResponse,connect},hideFromStack([Http2ServerRequest,Http2ServerResponse,connect,createServer,createSecureServer,getDefaultSettings,getPackedSettings,getUnpackedSettings]),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttpsCode = "(function (){\"use strict\";const http=@getInternalField(@internalModuleRegistry,18)||@createInternalModuleById(18);function request(input,options,cb){if(input&&typeof input===\"object\"&&!(input instanceof URL))input.protocol\?\?=\"https:\";else if(typeof options===\"object\")options.protocol\?\?=\"https:\";return http.request(input,options,cb)}function get(input,options,cb){const req=request(input,options,cb);return req.end(),req}return{...http,get,request}})\n"_s; +// + +// static constexpr ASCIILiteral NodeInspectorCode = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15);function open(){throwNotImplemented(\"node:inspector open\",2445)}function close(){throwNotImplemented(\"node:inspector close\",2445)}function url(){throwNotImplemented(\"node:inspector url\",2445)}function waitForDebugger(){throwNotImplemented(\"node:inspector waitForDebugger\",2445)}class Session extends EventEmitter{constructor(){super();throwNotImplemented(\"node:inspector Session\",2445)}}return $={console:{...globalThis.console,context:{console:globalThis.console}},open,close,url,waitForDebugger,Session},hideFromStack(open,close,url,waitForDebugger,Session.prototype.constructor),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeNetCode = "(function (){\"use strict\";const{Duplex}=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),IPv4Reg=new RegExp(\"^((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$\"),IPv6Reg=new RegExp(\"^((\?:(\?:[0-9a-fA-F]{1,4}):){7}(\?:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){6}(\?:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){5}(\?::((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,2}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){4}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,1}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,3}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){3}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,2}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,4}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){2}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,3}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,5}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){1}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,4}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,6}|:)|(\?::((\?::(\?:[0-9a-fA-F]{1,4})){0,5}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(\?::(\?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})\?$\");function isIPv4(s){return IPv4Reg.test(s)}function isIPv6(s){return IPv6Reg.test(s)}function isIP(s){if(isIPv4(s))return 4;if(isIPv6(s))return 6;return 0}const{connect:bunConnect}=Bun;var{setTimeout}=globalThis;const bunTlsSymbol=Symbol.for(\"::buntls::\"),bunSocketServerHandlers=Symbol.for(\"::bunsocket_serverhandlers::\"),bunSocketServerConnections=Symbol.for(\"::bunnetserverconnections::\"),bunSocketServerOptions=Symbol.for(\"::bunnetserveroptions::\"),bunSocketInternal=Symbol.for(\"::bunnetsocketinternal::\"),bunTLSConnectOptions=Symbol.for(\"::buntlsconnectoptions::\");var SocketClass;const Socket=function(InternalSocket){return SocketClass=InternalSocket,Object.defineProperty(SocketClass.prototype,Symbol.toStringTag,{value:\"Socket\",enumerable:!1}),Object.defineProperty(function Socket(options){return new InternalSocket(options)},Symbol.hasInstance,{value(instance){return instance instanceof InternalSocket}})}(class Socket2 extends Duplex{static#Handlers={close:Socket2.#Close,connectError(socket,error){socket.data.emit(\"error\",error)},data({data:self},buffer){self.bytesRead+=buffer.length;const queue=self.#readQueue;if(queue.isEmpty()){if(self.push(buffer))return}queue.push(buffer)},drain:Socket2.#Drain,end:Socket2.#Close,error(socket,error){const self=socket.data,callback=self.#writeCallback;if(callback)self.#writeCallback=null,callback(error);self.emit(\"error\",error)},open(socket){const self=socket.data;socket.timeout(self.timeout),socket.ref(),self[bunSocketInternal]=socket,self.connecting=!1;const options=self[bunTLSConnectOptions];if(options){const{session}=options;if(session)self.setSession(session)}if(!self.#upgraded)self.emit(\"connect\",self);Socket2.#Drain(socket)},handshake(socket,success,verifyError){const{data:self}=socket;self._securePending=!1,self.secureConnecting=!1,self._secureEstablished=!!success,self.emit(\"secure\",self);const{checkServerIdentity}=self[bunTLSConnectOptions];if(!verifyError&&typeof checkServerIdentity===\"function\"&&self.servername){const cert=self.getPeerCertificate(!0);verifyError=checkServerIdentity(self.servername,cert)}if(self._requestCert||self._rejectUnauthorized){if(verifyError){if(self.authorized=!1,self.authorizationError=verifyError.code||verifyError.message,self._rejectUnauthorized){self.destroy(verifyError);return}}}else self.authorized=!0;self.emit(\"secureConnect\",verifyError)},timeout(socket){const self=socket.data;self.emit(\"timeout\",self)},binaryType:\"buffer\"};static#Close(socket){const self=socket.data;if(self.#closed)return;self.#closed=!0,self[bunSocketInternal]=null;const queue=self.#readQueue;if(queue.isEmpty()){if(self.push(null))return}queue.push(null)}static#Drain(socket){const self=socket.data,callback=self.#writeCallback;if(callback){const chunk=self.#writeChunk,written=socket.write(chunk);if(self.bytesWritten+=written,written=self.maxConnections){const data={localAddress:_socket.localAddress,localPort:_socket.localPort,localFamily:_socket.localFamily,remoteAddress:_socket.remoteAddress,remotePort:_socket.remotePort,remoteFamily:_socket.remoteFamily||\"IPv4\"};socket.end(),self.emit(\"drop\",data);return}if(!pauseOnConnect)_socket.resume();if(self[bunSocketServerConnections]++,typeof connectionListener==\"function\")if(InternalSocketClass.name===\"TLSSocket\")self.once(\"secureConnection\",()=>connectionListener(_socket));else connectionListener(_socket);self.emit(\"connection\",_socket)},handshake(socket,success,verifyError){const{data:self}=socket;if(self.emit(\"secure\",self),self._securePending=!1,self.secureConnecting=!1,self._secureEstablished=!!success,self._requestCert||self._rejectUnauthorized){if(verifyError){if(self.authorized=!1,self.authorizationError=verifyError.code||verifyError.message,self._rejectUnauthorized){self.destroy(verifyError);return}}}else self.authorized=!0;self.emit(\"secureConnection\",verifyError)},error(socket,error){Socket2.#Handlers.error(socket,error),this.data.emit(\"error\",error)},timeout:Socket2.#Handlers.timeout,connectError:Socket2.#Handlers.connectError,drain:Socket2.#Handlers.drain,binaryType:\"buffer\"};bytesRead=0;bytesWritten=0;#closed=!1;connecting=!1;localAddress=\"127.0.0.1\";#readQueue=@createFIFO();remotePort;[bunSocketInternal]=null;[bunTLSConnectOptions]=null;timeout=0;#writeCallback;#writeChunk;#pendingRead;isServer=!1;_handle;_parent;_parentWrap;#socket;#upgraded;constructor(options){const{socket,signal,write,read,allowHalfOpen=!1,...opts}=options||{};super({...opts,allowHalfOpen,readable:!0,writable:!0});if(this._handle=this,this._parent=this,this._parentWrap=this,this.#pendingRead=void 0,this.#upgraded=!1,socket instanceof Socket2)this.#socket=socket;signal\?.once(\"abort\",()=>this.destroy()),this.once(\"connect\",()=>this.emit(\"ready\"))}address(){return{address:this.localAddress,family:this.localFamily,port:this.localPort}}get bufferSize(){return this.writableLength}#attach(port,socket){if(this.remotePort=port,socket.data=this,socket.timeout(this.timeout),socket.ref(),this[bunSocketInternal]=socket,this.connecting=!1,!this.#upgraded)this.emit(\"connect\",this);Socket2.#Drain(socket)}connect(port,host,connectListener){var path,connection=this.#socket,_checkServerIdentity=void 0;if(typeof port===\"string\"){if(path=port,port=void 0,typeof host===\"function\")connectListener=host,host=void 0}else if(typeof host==\"function\"){if(typeof port===\"string\")path=port,port=void 0;connectListener=host,host=void 0}if(typeof port==\"object\"){var{port,host,path,socket,localAddress,localPort,family,hints,lookup,noDelay,keepAlive,keepAliveInitialDelay,requestCert,rejectUnauthorized,pauseOnConnect,servername,checkServerIdentity,session}=port;if(_checkServerIdentity=checkServerIdentity,this.servername=servername,socket)connection=socket}if(!pauseOnConnect)this.resume();this.connecting=!0,this.remotePort=port;const bunTLS=this[bunTlsSymbol];var tls=void 0;if(typeof bunTLS===\"function\"){if(tls=bunTLS.call(this,port,host,!0),this._requestCert=!0,this._rejectUnauthorized=rejectUnauthorized,tls){if(tls.rejectUnauthorized=rejectUnauthorized,tls.requestCert=!0,tls.session=session||tls.session,this.servername=tls.servername,tls.checkServerIdentity=_checkServerIdentity||tls.checkServerIdentity,this[bunTLSConnectOptions]=tls,!connection&&tls.socket)connection=tls.socket}if(connection){if(typeof connection!==\"object\"||!(connection instanceof Socket2)||typeof connection[bunTlsSymbol]===\"function\")@throwTypeError(\"socket must be an instance of net.Socket\")}if(this.authorized=!1,this.secureConnecting=!0,this._secureEstablished=!1,this._securePending=!0,connectListener)this.on(\"secureConnect\",connectListener)}else if(connectListener)this.on(\"connect\",connectListener);if(connection){const socket2=connection[bunSocketInternal];if(socket2){this.connecting=!0,this.#upgraded=!0;const result=socket2.upgradeTLS({data:this,tls,socket:Socket2.#Handlers});if(result){const[raw,tls2]=result;connection[bunSocketInternal]=raw,raw.timeout(raw.timeout),raw.connecting=!1,this[bunSocketInternal]=tls2}else throw this[bunSocketInternal]=null,new Error(\"Invalid socket\")}else connection.once(\"connect\",()=>{const socket3=connection[bunSocketInternal];if(!socket3)return;this.connecting=!0,this.#upgraded=!0;const result=socket3.upgradeTLS({data:this,tls,socket:Socket2.#Handlers});if(result){const[raw,tls2]=result;connection[bunSocketInternal]=raw,raw.timeout(raw.timeout),raw.connecting=!1,this[bunSocketInternal]=tls2}else throw this[bunSocketInternal]=null,new Error(\"Invalid socket\")})}else if(path)bunConnect({data:this,unix:path,socket:Socket2.#Handlers,tls}).catch((error)=>{this.emit(\"error\",error)});else bunConnect({data:this,hostname:host||\"localhost\",port,socket:Socket2.#Handlers,tls}).catch((error)=>{this.emit(\"error\",error)});return this}_destroy(err,callback){this[bunSocketInternal]\?.end(),callback(err)}_final(callback){this[bunSocketInternal]\?.end(),callback()}get localAddress(){return\"127.0.0.1\"}get localFamily(){return\"IPv4\"}get localPort(){return this[bunSocketInternal]\?.localPort}get pending(){return this.connecting}_read(size){const queue=this.#readQueue;let chunk;while(chunk=queue.peek()){if(!this.push(chunk))return;queue.shift()}}get readyState(){if(this.connecting)return\"opening\";if(this.readable)return this.writable\?\"open\":\"readOnly\";else return this.writable\?\"writeOnly\":\"closed\"}ref(){this[bunSocketInternal]\?.ref()}get remoteAddress(){return this[bunSocketInternal]\?.remoteAddress}get remoteFamily(){return\"IPv4\"}resetAndDestroy(){this[bunSocketInternal]\?.end()}setKeepAlive(enable=!1,initialDelay=0){return this}setNoDelay(noDelay=!0){return this}setTimeout(timeout,callback){if(this[bunSocketInternal]\?.timeout(timeout),this.timeout=timeout,callback)this.once(\"timeout\",callback);return this}unref(){this[bunSocketInternal]\?.unref()}_write(chunk,encoding,callback){if(typeof chunk==\"string\"&&encoding!==\"ascii\")chunk=Buffer.from(chunk,encoding);var written=this[bunSocketInternal]\?.write(chunk);if(written==chunk.length)callback();else if(this.#writeCallback)callback(new Error(\"overlapping _write()\"));else{if(written>0)if(typeof chunk==\"string\")chunk=chunk.slice(written);else chunk=chunk.subarray(written);this.#writeCallback=callback,this.#writeChunk=chunk}}});function createConnection(port,host,connectListener){if(typeof port===\"object\")return new Socket(port).connect(port,host,connectListener);return new Socket().connect(port,host,connectListener)}const connect=createConnection;class Server extends EventEmitter{#server;#listening=!1;[bunSocketServerConnections]=0;[bunSocketServerOptions];maxConnections=0;constructor(options,connectionListener){super();if(typeof options===\"function\")connectionListener=options,options={};else if(options==null||typeof options===\"object\")options={...options};else throw new Error(\"bun-net-polyfill: invalid arguments\");const{maxConnections}=options;this.maxConnections=Number.isSafeInteger(maxConnections)&&maxConnections>0\?maxConnections:0,options.connectionListener=connectionListener,this[bunSocketServerOptions]=options}ref(){return this.#server\?.ref(),this}unref(){return this.#server\?.unref(),this}close(callback){if(this.#server){if(this.#server.stop(!0),this.#server=null,this.#listening=!1,this[bunSocketServerConnections]=0,this.emit(\"close\"),typeof callback===\"function\")callback();return this}if(typeof callback===\"function\"){const error=new Error(\"Server is not running\");error.code=\"ERR_SERVER_NOT_RUNNING\",callback(error)}return this}address(){const server=this.#server;if(server){const unix=server.unix;if(unix)return unix;let address=server.hostname;const type=isIP(address),port=server.port;if(typeof port===\"number\")return{port,address,family:type\?`IPv${type}`:void 0};if(type)return{address,family:type\?`IPv${type}`:void 0};return address}return null}getConnections(callback){if(typeof callback===\"function\")callback(null,this.#server\?this[bunSocketServerConnections]:0);return this}listen(port,hostname,onListen){let backlog,path,exclusive=!1;if(typeof port===\"string\"){if(Number.isSafeInteger(hostname)){if(hostname>0)backlog=hostname}else if(typeof hostname===\"function\")onListen=hostname;path=port,hostname=void 0,port=void 0}else{if(typeof hostname===\"function\")onListen=hostname,hostname=void 0;if(typeof port===\"function\")onListen=port,port=0;else if(typeof port===\"object\"){const options=port;options.signal\?.addEventListener(\"abort\",()=>this.close()),hostname=options.host,exclusive=options.exclusive===!0;const path2=options.path;if(port=options.port,!Number.isSafeInteger(port)||port<0)if(path2)hostname=path2,port=void 0;else{let message='The argument \\'options\\' must have the property \"port\" or \"path\"';try{message=`${message}. Received ${JSON.stringify(options)}`}catch{}const error=@makeTypeError(message);throw error.code=\"ERR_INVALID_ARG_VALUE\",error}else if(!Number.isSafeInteger(port)||port<0)port=0;if(typeof port.callback===\"function\")onListen=port\?.callback}else if(!Number.isSafeInteger(port)||port<0)port=0;hostname=hostname||\"::\"}try{var tls=void 0,TLSSocketClass=void 0;const bunTLS=this[bunTlsSymbol],options=this[bunSocketServerOptions];if(typeof bunTLS===\"function\")[tls,TLSSocketClass]=bunTLS.call(this,port,hostname,!1),options.servername=tls.serverName,options.InternalSocketClass=TLSSocketClass;else options.InternalSocketClass=SocketClass;this.#server=Bun.listen(path\?{exclusive,unix:path,tls,socket:SocketClass[bunSocketServerHandlers]}:{exclusive,port,hostname,tls,socket:SocketClass[bunSocketServerHandlers]}),this.#server.data=this,this.#listening=!0,setTimeout(emitListeningNextTick,1,this,onListen)}catch(err){this.#listening=!1,setTimeout(emitErrorNextTick,1,this,err)}return this}}function emitErrorNextTick(self,error){self.emit(\"error\",error)}function emitListeningNextTick(self,onListen){if(typeof onListen===\"function\")try{onListen()}catch(err){self.emit(\"error\",err)}self.emit(\"listening\")}function createServer(options,connectionListener){return new Server(options,connectionListener)}return{createServer,Server,createConnection,connect,isIP,isIPv4,isIPv6,Socket,[Symbol.for(\"::bunternal::\")]:SocketClass}})\n"_s; +// + +// static constexpr ASCIILiteral NodeOSCode = "(function (){\"use strict\";var tmpdir=function(){var env=Bun.env;return tmpdir=function(){var path=env.TMPDIR||env.TMP||env.TEMP||\"/tmp\";const length=path.length;if(length>1&&path[length-1]===\"/\")path=path.slice(0,-1);return path},tmpdir()};function lazyCpus({cpus}){return()=>{const array=new Array(navigator.hardwareConcurrency);function populate(){const results=cpus(),length=results.length;array.length=length;for(let i=0;i= 0x80 (not a basic code point)\",\"invalid-input\":\"Invalid input\"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){@throwRangeError(errors[type])}function map(array,callback){const result=[];let length=array.length;while(length--)result[length]=callback(array[length]);return result}function mapDomain(domain,callback){const parts=domain.split(\"@\");let result=\"\";if(parts.length>1)result=parts[0]+\"@\",domain=parts[1];domain=domain.replace(regexSeparators,\".\");const labels=domain.split(\".\"),encoded=map(labels,callback).join(\".\");return result+encoded}function ucs2decode(string){const output=[];let counter=0;const length=string.length;while(counter=55296&&value<=56319&&counterString.fromCodePoint(...codePoints),basicToDigit=function(codePoint){if(codePoint>=48&&codePoint<58)return 26+(codePoint-48);if(codePoint>=65&&codePoint<91)return codePoint-65;if(codePoint>=97&&codePoint<123)return codePoint-97;return base},digitToBasic=function(digit,flag){return digit+22+75*(digit<26)-((flag!=0)<<5)},adapt=function(delta,numPoints,firstTime){let k=0;delta=firstTime\?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);for(;delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))},decode=function(input){const output=[],inputLength=input.length;let i=0,n=initialN,bias=initialBias,basic=input.lastIndexOf(delimiter);if(basic<0)basic=0;for(let j=0;j=128)error(\"not-basic\");output.push(input.charCodeAt(j))}for(let index=basic>0\?basic+1:0;index=inputLength)error(\"invalid-input\");const digit=basicToDigit(input.charCodeAt(index++));if(digit>=base)error(\"invalid-input\");if(digit>floor((maxInt-i)/w))error(\"overflow\");i+=digit*w;const t=k<=bias\?tMin:k>=bias+tMax\?tMax:k-bias;if(digitfloor(maxInt/baseMinusT))error(\"overflow\");w*=baseMinusT}const out=output.length+1;if(bias=adapt(i-oldi,out,oldi==0),floor(i/out)>maxInt-n)error(\"overflow\");n+=floor(i/out),i%=out,output.splice(i++,0,n)}return String.fromCodePoint(...output)},encode=function(input){const output=[];input=ucs2decode(input);const inputLength=input.length;let n=initialN,delta=0,bias=initialBias;for(let currentValue of input)if(currentValue<128)output.push(stringFromCharCode(currentValue));const basicLength=output.length;let handledCPCount=basicLength;if(basicLength)output.push(delimiter);while(handledCPCount=n&¤tValuefloor((maxInt-delta)/handledCPCountPlusOne))error(\"overflow\");delta+=(m-n)*handledCPCountPlusOne,n=m;for(let currentValue of input){if(currentValuemaxInt)error(\"overflow\");if(currentValue===n){let q=delta;for(let k=base;;k+=base){const t=k<=bias\?tMin:k>=bias+tMax\?tMax:k-bias;if(q()=>(mod||cb((mod={exports:{}}).exports,mod),mod.exports),Buffer=@requireNativeModule(\"node:buffer\").Buffer,require_object_keys=__commonJS((exports,module)=>{var objectKeys=Object.keys||function(){var hasOwnProperty=Object.prototype.hasOwnProperty,hasDontEnumBug=!{toString:null}.propertyIsEnumerable(\"toString\"),dontEnums=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],dontEnumsLength=dontEnums.length;return function(obj){if(typeof obj!==\"function\"&&(typeof obj!==\"object\"||obj===null))@throwTypeError(\"Object.keys called on non-object\");var result=[],prop,i;for(prop in obj)if(hasOwnProperty.call(obj,prop))result.push(prop);if(hasDontEnumBug){for(i=0;i{var ParsedQueryString=function(){},unescapeBuffer=function(s,decodeSpaces){var out=Buffer.allocUnsafe(s.length),state=0,n,m,hexchar,c;for(var inIndex=0,outIndex=0;;inIndex++){if(inIndex0){if(out[outIndex++]=37,state===2)out[outIndex++]=hexchar}break}switch(state){case 0:switch(c){case 37:n=0,m=0,state=1;break;case 43:if(decodeSpaces)c=32;default:out[outIndex++]=c;break}break;case 1:if(hexchar=c,n=unhexTable[c],!(n>=0)){out[outIndex++]=37,out[outIndex++]=c,state=0;break}state=2;break;case 2:if(state=0,m=unhexTable[c],!(m>=0)){out[outIndex++]=37,out[outIndex++]=hexchar,out[outIndex++]=c;break}out[outIndex++]=16*n+m;break}}return out.slice(0,outIndex)},qsUnescape=function(s,decodeSpaces){try{return decodeURIComponent(s)}catch(e){return QueryString.unescapeBuffer(s,decodeSpaces).toString()}},qsEscape=function(str){if(typeof str!==\"string\")if(typeof str===\"object\")str=String(str);else str+=\"\";var out=\"\",lastPos=0;for(var i2=0;i2>6]+hexTable[128|c&63];continue}if(c<55296||c>=57344){lastPos=i2+1,out+=hexTable[224|c>>12]+hexTable[128|c>>6&63]+hexTable[128|c&63];continue}++i2;var c2;if(i2>18]+hexTable[128|c>>12&63]+hexTable[128|c>>6&63]+hexTable[128|c&63]}if(lastPos===0)return str;if(lastPos0\?options.maxKeys:-1;var decode=QueryString.unescape;if(options&&typeof options.decodeURIComponent===\"function\")decode=options.decodeURIComponent;const customDecode=decode!==qsUnescape,keys=[];var posIdx=0,lastPos=0,sepIdx=0,eqIdx=0,key=\"\",value=\"\",keyEncoded=customDecode,valEncoded=customDecode,encodeCheck=0;for(var i2=0;i2sepLen||i2===0)if(indexOf(keys,key)===-1)obj[key]=value,keys[keys.length]=key;else{const curValue=obj[key]||\"\";if(curValue.pop)curValue[curValue.length]=value;else if(curValue)obj[key]=[curValue,value]}else if(i2===1)delete obj[key];if(--pairs===0)break;keyEncoded=valEncoded=customDecode,encodeCheck=0,key=value=\"\",posIdx=lastPos,lastPos=i2+1,sepIdx=eqIdx=0}continue}else if(sepIdx=0,!valEncoded)if(code===37)encodeCheck=1;else if(encodeCheck>0&&(code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102)){if(++encodeCheck===3)valEncoded=!0}else encodeCheck=0;if(eqIdx0&&(code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102)){if(++encodeCheck===3)keyEncoded=!0}else encodeCheck=0}if(code===43){if(eqIdx0)){if(lastPosObject.prototype.toString.call(arg)===\"[object Array]\",indexOf=(arr,searchElement,fromIndex)=>{var k;if(arr==null)@throwTypeError('\"arr\" is null or not defined');var o=Object(arr),len=o.length>>>0;if(len===0)return-1;var n=fromIndex|0;if(n>=len)return-1;k=Math.max(n>=0\?n:len-Math.abs(n),0);while(k{},SymbolAsyncIterator=Symbol.asyncIterator,SymbolIterator=Symbol.iterator,SymbolFor=Symbol.for,SymbolReplace=Symbol.replace,ArrayFrom=Array.from,ArrayIsArray=Array.isArray,ArrayPrototypeFilter=Array.prototype.filter,ArrayPrototypeSort=Array.prototype.sort,ArrayPrototypeIndexOf=Array.prototype.indexOf,ArrayPrototypeJoin=Array.prototype.join,ArrayPrototypeMap=Array.prototype.map,ArrayPrototypePop=Array.prototype.pop,ArrayPrototypePush=Array.prototype.push,ArrayPrototypeSlice=Array.prototype.slice,ArrayPrototypeSplice=Array.prototype.splice,ArrayPrototypeReverse=Array.prototype.reverse,ArrayPrototypeShift=Array.prototype.shift,ArrayPrototypeUnshift=Array.prototype.unshift,RegExpPrototypeExec=RegExp.prototype.exec,RegExpPrototypeSymbolReplace=RegExp.prototype[SymbolReplace],StringFromCharCode=String.fromCharCode,StringPrototypeCharCodeAt=String.prototype.charCodeAt,StringPrototypeCodePointAt=String.prototype.codePointAt,StringPrototypeSlice=String.prototype.slice,StringPrototypeToLowerCase=String.prototype.toLowerCase,StringPrototypeEndsWith=String.prototype.endsWith,StringPrototypeRepeat=String.prototype.repeat,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeTrim=String.prototype.trim,StringPrototypeNormalize=String.prototype.normalize,NumberIsNaN=Number.isNaN,NumberIsFinite=Number.isFinite,NumberIsInteger=Number.isInteger,NumberMAX_SAFE_INTEGER=Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER=Number.MIN_SAFE_INTEGER,MathCeil=Math.ceil,MathFloor=Math.floor,MathMax=Math.max,MathMaxApply=Math.max.apply,DateNow=Date.now,FunctionPrototype=Function.prototype,StringPrototype=String.prototype,StringPrototypeSymbolIterator=StringPrototype[SymbolIterator],StringIteratorPrototypeNext=StringPrototypeSymbolIterator.call(\"\").next,ObjectSetPrototypeOf=Object.setPrototypeOf,ObjectDefineProperty=Object.defineProperty,ObjectDefineProperties=Object.defineProperties,ObjectFreeze=Object.freeze,ObjectAssign=Object.assign,ObjectCreate=Object.create,ObjectKeys=Object.keys,ObjectSeal=Object.seal,createSafeIterator=(factory,next)=>{class SafeIterator{#iterator;constructor(iterable){this.#iterator=factory.call(iterable)}next(){return next.call(this.#iterator)}[SymbolIterator](){return this}}return ObjectSetPrototypeOf(SafeIterator.prototype,null),ObjectFreeze(SafeIterator.prototype),ObjectFreeze(SafeIterator),SafeIterator},SafeStringIterator=createSafeIterator(StringPrototypeSymbolIterator,StringIteratorPrototypeNext),isFullWidthCodePoint=(code)=>{return code>=4352&&(code<=4447||code===9001||code===9002||code>=11904&&code<=12871&&code!==12351||code>=12880&&code<=19903||code>=19968&&code<=42182||code>=43360&&code<=43388||code>=44032&&code<=55203||code>=63744&&code<=64255||code>=65040&&code<=65049||code>=65072&&code<=65131||code>=65281&&code<=65376||code>=65504&&code<=65510||code>=110592&&code<=110593||code>=127488&&code<=127569||code>=127744&&code<=128591||code>=131072&&code<=262141)},isZeroWidthCodePoint=(code)=>{return code<=31||code>=127&&code<=159||code>=768&&code<=879||code>=8203&&code<=8207||code>=8400&&code<=8447||code>=65024&&code<=65039||code>=65056&&code<=65071||code>=917760&&code<=917999},getStringWidth=function getStringWidth(str,removeControlChars=!0){var width=0;if(removeControlChars)str=stripVTControlCharacters(str);str=StringPrototypeNormalize.call(str,\"NFC\");for(var char of new SafeStringIterator(str)){var code=StringPrototypeCodePointAt.call(char,0);if(isFullWidthCodePoint(code))width+=2;else if(!isZeroWidthCodePoint(code))width++}return width},ansiPattern=\"[\\\\u001B\\\\u009B][[\\\\]()#;\?]*(\?:(\?:(\?:(\?:;[-a-zA-Z\\\\d\\\\/#&.:=\?%@~_]+)*|[a-zA-Z\\\\d]+(\?:;[-a-zA-Z\\\\d\\\\/#&.:=\?%@~_]*)*)\?\\\\u0007)|(\?:(\?:\\\\d{1,4}(\?:;\\\\d{0,4})*)\?[\\\\dA-PR-TZcf-ntqry=><~]))\",ansi=new RegExp(ansiPattern,\"g\");function stripVTControlCharacters(str){return validateString(str,\"str\"),RegExpPrototypeSymbolReplace.call(ansi,str,\"\")}var kCustomPromisifiedSymbol=SymbolFor(\"nodejs.util.promisify.custom\"),kCustomPromisifyArgsSymbol=Symbol(\"customPromisifyArgs\");function promisify(original){if(validateFunction(original,\"original\"),original[kCustomPromisifiedSymbol]){var fn=original[kCustomPromisifiedSymbol];return validateFunction(fn,\"util.promisify.custom\"),ObjectDefineProperty(fn,kCustomPromisifiedSymbol,{__proto__:null,value:fn,enumerable:!1,writable:!1,configurable:!0})}var argumentNames=original[kCustomPromisifyArgsSymbol];function fn(...args){return new Promise((resolve,reject)=>{ArrayPrototypePush.call(args,(err,...values)=>{if(err)return reject(err);if(argumentNames!==void 0&&values.length>1){var obj={};for(var i2=0;i2max)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}function validateUint32(value,name,positive=!1){if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE(name,\"number\",value);if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);var min=positive\?1:0,max=4294967295;if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}function CSI(strings,...args){var ret=`${kEscape}[`;for(var n=0;n1&&StringPrototypeCodePointAt.call(str,i-2)>=kUTF16SurrogateThreshold||StringPrototypeCodePointAt.call(str,i-1)>=kUTF16SurrogateThreshold)return 2;return 1}function charLengthAt(str,i){if(str.length<=i)return 1;return StringPrototypeCodePointAt.call(str,i)>=kUTF16SurrogateThreshold\?2:1}function*emitKeys(stream){while(!0){var ch=yield,s=ch,escaped=!1,keySeq=null,keyName,keyCtrl2=!1,keyMeta=!1,keyShift=!1;if(ch===kEscape){if(escaped=!0,s+=ch=yield,ch===kEscape)s+=ch=yield}if(escaped&&(ch===\"O\"||ch===\"[\")){var code=ch,modifier=0;if(ch===\"O\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")modifier=(ch>>0)-1,s+=ch=yield;code+=ch}else if(ch===\"[\"){if(s+=ch=yield,ch===\"[\")code+=ch,s+=ch=yield;var cmdStart=s.length-1;if(ch>=\"0\"&&ch<=\"9\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")s+=ch=yield}if(ch===\";\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")s+=yield}var cmd=StringPrototypeSlice.call(s,cmdStart),match;if(match=RegExpPrototypeExec.call(/^(\\d\\d\?)(;(\\d))\?([~^$])$/,cmd))code+=match[1]+match[4],modifier=(match[3]||1)-1;else if(match=RegExpPrototypeExec.call(/^((\\d;)\?(\\d))\?([A-Za-z])$/,cmd))code+=match[4],modifier=(match[3]||1)-1;else code+=cmd}switch(keyCtrl2=!!(modifier&4),keyMeta=!!(modifier&10),keyShift=!!(modifier&1),code){case\"[P\":keyName=\"f1\";break;case\"[Q\":keyName=\"f2\";break;case\"[R\":keyName=\"f3\";break;case\"[S\":keyName=\"f4\";break;case\"OP\":keyName=\"f1\";break;case\"OQ\":keyName=\"f2\";break;case\"OR\":keyName=\"f3\";break;case\"OS\":keyName=\"f4\";break;case\"[11~\":keyName=\"f1\";break;case\"[12~\":keyName=\"f2\";break;case\"[13~\":keyName=\"f3\";break;case\"[14~\":keyName=\"f4\";break;case\"[[A\":keyName=\"f1\";break;case\"[[B\":keyName=\"f2\";break;case\"[[C\":keyName=\"f3\";break;case\"[[D\":keyName=\"f4\";break;case\"[[E\":keyName=\"f5\";break;case\"[15~\":keyName=\"f5\";break;case\"[17~\":keyName=\"f6\";break;case\"[18~\":keyName=\"f7\";break;case\"[19~\":keyName=\"f8\";break;case\"[20~\":keyName=\"f9\";break;case\"[21~\":keyName=\"f10\";break;case\"[23~\":keyName=\"f11\";break;case\"[24~\":keyName=\"f12\";break;case\"[A\":keyName=\"up\";break;case\"[B\":keyName=\"down\";break;case\"[C\":keyName=\"right\";break;case\"[D\":keyName=\"left\";break;case\"[E\":keyName=\"clear\";break;case\"[F\":keyName=\"end\";break;case\"[H\":keyName=\"home\";break;case\"OA\":keyName=\"up\";break;case\"OB\":keyName=\"down\";break;case\"OC\":keyName=\"right\";break;case\"OD\":keyName=\"left\";break;case\"OE\":keyName=\"clear\";break;case\"OF\":keyName=\"end\";break;case\"OH\":keyName=\"home\";break;case\"[1~\":keyName=\"home\";break;case\"[2~\":keyName=\"insert\";break;case\"[3~\":keyName=\"delete\";break;case\"[4~\":keyName=\"end\";break;case\"[5~\":keyName=\"pageup\";break;case\"[6~\":keyName=\"pagedown\";break;case\"[[5~\":keyName=\"pageup\";break;case\"[[6~\":keyName=\"pagedown\";break;case\"[7~\":keyName=\"home\";break;case\"[8~\":keyName=\"end\";break;case\"[a\":keyName=\"up\",keyShift=!0;break;case\"[b\":keyName=\"down\",keyShift=!0;break;case\"[c\":keyName=\"right\",keyShift=!0;break;case\"[d\":keyName=\"left\",keyShift=!0;break;case\"[e\":keyName=\"clear\",keyShift=!0;break;case\"[2$\":keyName=\"insert\",keyShift=!0;break;case\"[3$\":keyName=\"delete\",keyShift=!0;break;case\"[5$\":keyName=\"pageup\",keyShift=!0;break;case\"[6$\":keyName=\"pagedown\",keyShift=!0;break;case\"[7$\":keyName=\"home\",keyShift=!0;break;case\"[8$\":keyName=\"end\",keyShift=!0;break;case\"Oa\":keyName=\"up\",keyCtrl2=!0;break;case\"Ob\":keyName=\"down\",keyCtrl2=!0;break;case\"Oc\":keyName=\"right\",keyCtrl2=!0;break;case\"Od\":keyName=\"left\",keyCtrl2=!0;break;case\"Oe\":keyName=\"clear\",keyCtrl2=!0;break;case\"[2^\":keyName=\"insert\",keyCtrl2=!0;break;case\"[3^\":keyName=\"delete\",keyCtrl2=!0;break;case\"[5^\":keyName=\"pageup\",keyCtrl2=!0;break;case\"[6^\":keyName=\"pagedown\",keyCtrl2=!0;break;case\"[7^\":keyName=\"home\",keyCtrl2=!0;break;case\"[8^\":keyName=\"end\",keyCtrl2=!0;break;case\"[Z\":keyName=\"tab\",keyShift=!0;break;default:keyName=\"undefined\";break}}else if(ch===\"\\r\")keyName=\"return\",keyMeta=escaped;else if(ch===\"\\n\")keyName=\"enter\",keyMeta=escaped;else if(ch===\"\\t\")keyName=\"tab\",keyMeta=escaped;else if(ch===\"\\b\"||ch===\"\\x7F\")keyName=\"backspace\",keyMeta=escaped;else if(ch===kEscape)keyName=\"escape\",keyMeta=escaped;else if(ch===\" \")keyName=\"space\",keyMeta=escaped;else if(!escaped&&ch<=\"\\x1A\")keyName=StringFromCharCode(StringPrototypeCharCodeAt.call(ch)+StringPrototypeCharCodeAt.call(\"a\")-1),keyCtrl2=!0;else if(RegExpPrototypeExec.call(/^[0-9A-Za-z]$/,ch)!==null)keyName=StringPrototypeToLowerCase.call(ch),keyShift=RegExpPrototypeExec.call(/^[A-Z]$/,ch)!==null,keyMeta=escaped;else if(escaped)keyName=ch.length\?void 0:\"escape\",keyMeta=!0;if(keySeq=s,s.length!==0&&(keyName!==void 0||escaped))stream.emit(\"keypress\",escaped\?void 0:s,{sequence:keySeq,name:keyName,ctrl:keyCtrl2,meta:keyMeta,shift:keyShift});else if(charLengthAt(s,0)===s.length)stream.emit(\"keypress\",s,{sequence:keySeq,name:keyName,ctrl:keyCtrl2,meta:keyMeta,shift:keyShift})}}function commonPrefix(strings){if(strings.length===0)return\"\";if(strings.length===1)return strings[0];var sorted=ArrayPrototypeSort.call(ArrayPrototypeSlice.call(strings)),min=sorted[0],max=sorted[sorted.length-1];for(var i=0;i0)data+=CSI`${dx}C`;if(dy<0)data+=CSI`${-dy}A`;else if(dy>0)data+=CSI`${dy}B`;return stream.write(data,callback)}function clearLine(stream,dir,callback){if(callback!==void 0)validateFunction(callback,\"callback\");if(stream===null||stream===void 0){if(typeof callback===\"function\")process.nextTick(callback,null);return!0}var type=dir<0\?kClearToLineBeginning:dir>0\?kClearToLineEnd:kClearLine;return stream.write(type,callback)}function clearScreenDown(stream,callback){if(callback!==void 0)validateFunction(callback,\"callback\");if(stream===null||stream===void 0){if(typeof callback===\"function\")process.nextTick(callback,null);return!0}return stream.write(kClearScreenDown,callback)}var KEYPRESS_DECODER=Symbol(\"keypress-decoder\"),ESCAPE_DECODER=Symbol(\"escape-decoder\"),ESCAPE_CODE_TIMEOUT=500;function emitKeypressEvents(stream,iface={}){if(stream[KEYPRESS_DECODER])return;stream[KEYPRESS_DECODER]=new StringDecoder(\"utf8\"),stream[ESCAPE_DECODER]=emitKeys(stream),stream[ESCAPE_DECODER].next();var triggerEscape=()=>stream[ESCAPE_DECODER].next(\"\"),{escapeCodeTimeout=ESCAPE_CODE_TIMEOUT}=iface,timeoutId;function onData2(input){if(stream.listenerCount(\"keypress\")>0){var string=stream[KEYPRESS_DECODER].write(input);if(string){clearTimeout(timeoutId),iface[kSawKeyPress]=charLengthAt(string,0)===string.length,iface.isCompletionEnabled=!1;var length=0;for(var character of new SafeStringIterator(string)){if(length+=character.length,length===string.length)iface.isCompletionEnabled=!0;try{if(stream[ESCAPE_DECODER].next(character),length===string.length&&character===kEscape)timeoutId=setTimeout(triggerEscape,escapeCodeTimeout)}catch(err){throw stream[ESCAPE_DECODER]=emitKeys(stream),stream[ESCAPE_DECODER].next(),err}}}}else stream.removeListener(\"data\",onData2),stream.on(\"newListener\",onNewListener)}function onNewListener(event){if(event===\"keypress\")stream.on(\"data\",onData2),stream.removeListener(\"newListener\",onNewListener)}if(stream.listenerCount(\"keypress\")>0)stream.on(\"data\",onData2);else stream.on(\"newListener\",onNewListener)}var kEmptyObject=ObjectFreeze(ObjectCreate(null)),kHistorySize=30,kMaxUndoRedoStackSize=2048,kMincrlfDelay=100,lineEnding=/\\r\?\\n|\\r(\?!\\n)/g,kMaxLengthOfKillRing=32,kLineObjectStream=Symbol(\"line object stream\"),kQuestionCancel=Symbol(\"kQuestionCancel\"),kQuestion=Symbol(\"kQuestion\"),kAddHistory=Symbol(\"_addHistory\"),kBeforeEdit=Symbol(\"_beforeEdit\"),kDecoder=Symbol(\"_decoder\"),kDeleteLeft=Symbol(\"_deleteLeft\"),kDeleteLineLeft=Symbol(\"_deleteLineLeft\"),kDeleteLineRight=Symbol(\"_deleteLineRight\"),kDeleteRight=Symbol(\"_deleteRight\"),kDeleteWordLeft=Symbol(\"_deleteWordLeft\"),kDeleteWordRight=Symbol(\"_deleteWordRight\"),kGetDisplayPos=Symbol(\"_getDisplayPos\"),kHistoryNext=Symbol(\"_historyNext\"),kHistoryPrev=Symbol(\"_historyPrev\"),kInsertString=Symbol(\"_insertString\"),kLine=Symbol(\"_line\"),kLine_buffer=Symbol(\"_line_buffer\"),kKillRing=Symbol(\"_killRing\"),kKillRingCursor=Symbol(\"_killRingCursor\"),kMoveCursor=Symbol(\"_moveCursor\"),kNormalWrite=Symbol(\"_normalWrite\"),kOldPrompt=Symbol(\"_oldPrompt\"),kOnLine=Symbol(\"_onLine\"),kPreviousKey=Symbol(\"_previousKey\"),kPrompt=Symbol(\"_prompt\"),kPushToKillRing=Symbol(\"_pushToKillRing\"),kPushToUndoStack=Symbol(\"_pushToUndoStack\"),kQuestionCallback=Symbol(\"_questionCallback\"),kRedo=Symbol(\"_redo\"),kRedoStack=Symbol(\"_redoStack\"),kRefreshLine=Symbol(\"_refreshLine\"),kSawKeyPress=Symbol(\"_sawKeyPress\"),kSawReturnAt=Symbol(\"_sawReturnAt\"),kSetRawMode=Symbol(\"_setRawMode\"),kTabComplete=Symbol(\"_tabComplete\"),kTabCompleter=Symbol(\"_tabCompleter\"),kTtyWrite=Symbol(\"_ttyWrite\"),kUndo=Symbol(\"_undo\"),kUndoStack=Symbol(\"_undoStack\"),kWordLeft=Symbol(\"_wordLeft\"),kWordRight=Symbol(\"_wordRight\"),kWriteToOutput=Symbol(\"_writeToOutput\"),kYank=Symbol(\"_yank\"),kYanking=Symbol(\"_yanking\"),kYankPop=Symbol(\"_yankPop\"),kFirstEventParam=Symbol(\"nodejs.kFirstEventParam\"),kOnSelfCloseWithTerminal=Symbol(\"_onSelfCloseWithTerminal\"),kOnSelfCloseWithoutTerminal=Symbol(\"_onSelfCloseWithoutTerminal\"),kOnKeyPress=Symbol(\"_onKeyPress\"),kOnError=Symbol(\"_onError\"),kOnData=Symbol(\"_onData\"),kOnEnd=Symbol(\"_onEnd\"),kOnTermEnd=Symbol(\"_onTermEnd\"),kOnResize=Symbol(\"_onResize\");function onSelfCloseWithTerminal(){var input=this.input,output=this.output;if(!input)throw new Error(\"Input not set, invalid state for readline!\");if(input.removeListener(\"keypress\",this[kOnKeyPress]),input.removeListener(\"error\",this[kOnError]),input.removeListener(\"end\",this[kOnTermEnd]),output!==null&&output!==void 0)output.removeListener(\"resize\",this[kOnResize])}function onSelfCloseWithoutTerminal(){var input=this.input;if(!input)throw new Error(\"Input not set, invalid state for readline!\");input.removeListener(\"data\",this[kOnData]),input.removeListener(\"error\",this[kOnError]),input.removeListener(\"end\",this[kOnEnd])}function onError(err){this.emit(\"error\",err)}function onData(data){debug(\"onData\"),this[kNormalWrite](data)}function onEnd(){if(debug(\"onEnd\"),typeof this[kLine_buffer]===\"string\"&&this[kLine_buffer].length>0)this.emit(\"line\",this[kLine_buffer]);this.close()}function onTermEnd(){if(debug(\"onTermEnd\"),typeof this.line===\"string\"&&this.line.length>0)this.emit(\"line\",this.line);this.close()}function onKeyPress(s,key){if(this[kTtyWrite](s,key),key&&key.sequence){var ch=StringPrototypeCodePointAt.call(key.sequence,0);if(ch>=55296&&ch<=57343)this[kRefreshLine]()}}function onResize(){this[kRefreshLine]()}function InterfaceConstructor(input,output,completer,terminal){if(!(this instanceof InterfaceConstructor))return new InterfaceConstructor(input,output,completer,terminal);EventEmitter.call(this),this[kOnSelfCloseWithoutTerminal]=onSelfCloseWithoutTerminal.bind(this),this[kOnSelfCloseWithTerminal]=onSelfCloseWithTerminal.bind(this),this[kOnError]=onError.bind(this),this[kOnData]=onData.bind(this),this[kOnEnd]=onEnd.bind(this),this[kOnTermEnd]=onTermEnd.bind(this),this[kOnKeyPress]=onKeyPress.bind(this),this[kOnResize]=onResize.bind(this),this[kSawReturnAt]=0,this.isCompletionEnabled=!0,this[kSawKeyPress]=!1,this[kPreviousKey]=null,this.escapeCodeTimeout=ESCAPE_CODE_TIMEOUT,this.tabSize=8;var history,historySize,removeHistoryDuplicates=!1,crlfDelay,prompt=\"> \",signal;if(input\?.input){output=input.output,completer=input.completer,terminal=input.terminal,history=input.history,historySize=input.historySize,signal=input.signal;var tabSize=input.tabSize;if(tabSize!==void 0)validateUint32(tabSize,\"tabSize\",!0),this.tabSize=tabSize;removeHistoryDuplicates=input.removeHistoryDuplicates;var inputPrompt=input.prompt;if(inputPrompt!==void 0)prompt=inputPrompt;var inputEscapeCodeTimeout=input.escapeCodeTimeout;if(inputEscapeCodeTimeout!==void 0)if(NumberIsFinite(inputEscapeCodeTimeout))this.escapeCodeTimeout=inputEscapeCodeTimeout;else throw new ERR_INVALID_ARG_VALUE(\"input.escapeCodeTimeout\",this.escapeCodeTimeout);if(signal)validateAbortSignal(signal,\"options.signal\");crlfDelay=input.crlfDelay,input=input.input}if(completer!==void 0&&typeof completer!==\"function\")throw new ERR_INVALID_ARG_VALUE(\"completer\",completer);if(history===void 0)history=[];else validateArray(history,\"history\");if(historySize===void 0)historySize=kHistorySize;if(typeof historySize!==\"number\"||NumberIsNaN(historySize)||historySize<0)throw new ERR_INVALID_ARG_VALUE(\"historySize\",historySize);if(terminal===void 0&&!(output===null||output===void 0))terminal=!!output.isTTY;if(this.line=\"\",this[kSubstringSearch]=null,this.output=output,this.input=input,this[kUndoStack]=[],this[kRedoStack]=[],this.history=history,this.historySize=historySize,this[kKillRing]=[],this[kKillRingCursor]=0,this.removeHistoryDuplicates=!!removeHistoryDuplicates,this.crlfDelay=crlfDelay\?MathMax(kMincrlfDelay,crlfDelay):kMincrlfDelay,this.completer=completer,this.setPrompt(prompt),this.terminal=!!terminal,this[kLineObjectStream]=void 0,input.on(\"error\",this[kOnError]),!this.terminal)input.on(\"data\",this[kOnData]),input.on(\"end\",this[kOnEnd]),this.once(\"close\",this[kOnSelfCloseWithoutTerminal]),this[kDecoder]=new StringDecoder(\"utf8\");else{if(emitKeypressEvents(input,this),input.on(\"keypress\",this[kOnKeyPress]),input.on(\"end\",this[kOnTermEnd]),this[kSetRawMode](!0),this.terminal=!0,this.cursor=0,this.historyIndex=-1,output!==null&&output!==void 0)output.on(\"resize\",this[kOnResize]);this.once(\"close\",this[kOnSelfCloseWithTerminal])}if(signal){var onAborted=(()=>this.close()).bind(this);if(signal.aborted)process.nextTick(onAborted);else signal.addEventListener(\"abort\",onAborted,{once:!0}),this.once(\"close\",()=>signal.removeEventListener(\"abort\",onAborted))}this.line=\"\",input.resume()}InterfaceConstructor.prototype={},ObjectSetPrototypeOf(InterfaceConstructor.prototype,EventEmitter.prototype);var _Interface=class Interface2 extends InterfaceConstructor{constructor(input,output,completer,terminal){super(input,output,completer,terminal)}get columns(){var output=this.output;if(output&&output.columns)return output.columns;return Infinity}setPrompt(prompt){this[kPrompt]=prompt}getPrompt(){return this[kPrompt]}[kSetRawMode](mode){var input=this.input,{setRawMode,wasInRawMode}=input;return debug(\"setRawMode\",mode,\"set!\"),wasInRawMode}prompt(preserveCursor){if(this.paused)this.resume();if(this.terminal&&process.env.TERM!==\"dumb\"){if(!preserveCursor)this.cursor=0;this[kRefreshLine]()}else this[kWriteToOutput](this[kPrompt])}[kQuestion](query,cb){if(this.closed)throw new ERR_USE_AFTER_CLOSE(\"readline\");if(this[kQuestionCallback])this.prompt();else this[kOldPrompt]=this[kPrompt],this.setPrompt(query),this[kQuestionCallback]=cb,this.prompt()}[kOnLine](line){if(this[kQuestionCallback]){var cb=this[kQuestionCallback];this[kQuestionCallback]=null,this.setPrompt(this[kOldPrompt]),cb(line)}else this.emit(\"line\",line)}[kBeforeEdit](oldText,oldCursor){this[kPushToUndoStack](oldText,oldCursor)}[kQuestionCancel](){if(this[kQuestionCallback])this[kQuestionCallback]=null,this.setPrompt(this[kOldPrompt]),this.clearLine()}[kWriteToOutput](stringToWrite){if(validateString(stringToWrite,\"stringToWrite\"),this.output!==null&&this.output!==void 0)this.output.write(stringToWrite)}[kAddHistory](){if(this.line.length===0)return\"\";if(this.historySize===0)return this.line;if(StringPrototypeTrim.call(this.line).length===0)return this.line;if(this.history.length===0||this.history[0]!==this.line){if(this.removeHistoryDuplicates){var dupIndex=ArrayPrototypeIndexOf.call(this.history,this.line);if(dupIndex!==-1)ArrayPrototypeSplice.call(this.history,dupIndex,1)}if(ArrayPrototypeUnshift.call(this.history,this.line),this.history.length>this.historySize)ArrayPrototypePop.call(this.history)}this.historyIndex=-1;var line=this.history[0];return this.emit(\"history\",this.history),line}[kRefreshLine](){var line=this[kPrompt]+this.line,dispPos=this[kGetDisplayPos](line),lineCols=dispPos.cols,lineRows=dispPos.rows,cursorPos=this.getCursorPos(),prevRows=this.prevRows||0;if(prevRows>0)moveCursor(this.output,0,-prevRows);if(cursorTo(this.output,0),clearScreenDown(this.output),this[kWriteToOutput](line),lineCols===0)this[kWriteToOutput](\" \");cursorTo(this.output,cursorPos.cols);var diff=lineRows-cursorPos.rows;if(diff>0)moveCursor(this.output,0,-diff);this.prevRows=cursorPos.rows}close(){if(this.closed)return;if(this.pause(),this.terminal)this[kSetRawMode](!1);this.closed=!0,this.emit(\"close\")}pause(){if(this.paused)return;return this.input.pause(),this.paused=!0,this.emit(\"pause\"),this}resume(){if(!this.paused)return;return this.input.resume(),this.paused=!1,this.emit(\"resume\"),this}write(d,key){if(this.paused)this.resume();if(this.terminal)this[kTtyWrite](d,key);else this[kNormalWrite](d)}[kNormalWrite](b){if(b===void 0)return;var string=this[kDecoder].write(b);if(this[kSawReturnAt]&&DateNow()-this[kSawReturnAt]<=this.crlfDelay){if(StringPrototypeCodePointAt.call(string)===10)string=StringPrototypeSlice.call(string,1);this[kSawReturnAt]=0}var newPartContainsEnding=RegExpPrototypeExec.call(lineEnding,string);if(newPartContainsEnding!==null){if(this[kLine_buffer])string=this[kLine_buffer]+string,this[kLine_buffer]=null,newPartContainsEnding=RegExpPrototypeExec.call(lineEnding,string);this[kSawReturnAt]=StringPrototypeEndsWith.call(string,\"\\r\")\?DateNow():0;var indexes=[0,newPartContainsEnding.index,lineEnding.lastIndex],nextMatch;while((nextMatch=RegExpPrototypeExec.call(lineEnding,string))!==null)ArrayPrototypePush.call(indexes,nextMatch.index,lineEnding.lastIndex);var lastIndex=indexes.length-1;this[kLine_buffer]=StringPrototypeSlice.call(string,indexes[lastIndex]);for(var i=1;ie!==\"\"));if(StringPrototypeStartsWith.call(prefix,completeOn)&&prefix.length>completeOn.length){this[kInsertString](StringPrototypeSlice.call(prefix,completeOn.length));return}else if(!StringPrototypeStartsWith.call(completeOn,prefix)){this.line=StringPrototypeSlice.call(this.line,0,this.cursor-completeOn.length)+prefix+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor=this.cursor-completeOn.length+prefix.length,this._refreshLine();return}if(!lastKeypressWasTab)return;this[kBeforeEdit](this.line,this.cursor);var completionsWidth=ArrayPrototypeMap.call(completions,(e)=>getStringWidth(e)),width=MathMaxApply(completionsWidth)+2,maxColumns=MathFloor(this.columns/width)||1;if(maxColumns===Infinity)maxColumns=1;var output=\"\\r\\n\",lineIndex=0,whitespace=0;for(var i=0;i0){var leading=StringPrototypeSlice.call(this.line,0,this.cursor),reversed=ArrayPrototypeJoin.call(ArrayPrototypeReverse.call(ArrayFrom(leading)),\"\"),match=RegExpPrototypeExec.call(/^\\s*(\?:[^\\w\\s]+|\\w+)\?/,reversed);this[kMoveCursor](-match[0].length)}}[kWordRight](){if(this.cursor0&&this.line.length>0){this[kBeforeEdit](this.line,this.cursor);var charSize=charLengthLeft(this.line,this.cursor);this.line=StringPrototypeSlice.call(this.line,0,this.cursor-charSize)+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor-=charSize,this[kRefreshLine]()}}[kDeleteRight](){if(this.cursor0){this[kBeforeEdit](this.line,this.cursor);var leading=StringPrototypeSlice.call(this.line,0,this.cursor),reversed=ArrayPrototypeJoin.call(ArrayPrototypeReverse.call(ArrayFrom(leading)),\"\"),match=RegExpPrototypeExec.call(/^\\s*(\?:[^\\w\\s]+|\\w+)\?/,reversed);leading=StringPrototypeSlice.call(leading,0,leading.length-match[0].length),this.line=leading+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor=leading.length,this[kRefreshLine]()}}[kDeleteWordRight](){if(this.cursorkMaxLengthOfKillRing)ArrayPrototypePop.call(this[kKillRing])}[kYank](){if(this[kKillRing].length>0)this[kYanking]=!0,this[kInsertString](this[kKillRing][this[kKillRingCursor]])}[kYankPop](){if(!this[kYanking])return;if(this[kKillRing].length>1){var lastYank=this[kKillRing][this[kKillRingCursor]];if(this[kKillRingCursor]++,this[kKillRingCursor]>=this[kKillRing].length)this[kKillRingCursor]=0;var currentYank=this[kKillRing][this[kKillRingCursor]],head=StringPrototypeSlice.call(this.line,0,this.cursor-lastYank.length),tail=StringPrototypeSlice.call(this.line,this.cursor);this.line=head+currentYank+tail,this.cursor=head.length+currentYank.length,this[kRefreshLine]()}}clearLine(){this[kMoveCursor](Infinity),this[kWriteToOutput](\"\\r\\n\"),this.line=\"\",this.cursor=0,this.prevRows=0}[kLine](){var line=this[kAddHistory]();this[kUndoStack]=[],this[kRedoStack]=[],this.clearLine(),this[kOnLine](line)}[kPushToUndoStack](text,cursor){if(ArrayPrototypePush.call(this[kUndoStack],{text,cursor})>kMaxUndoRedoStackSize)ArrayPrototypeShift.call(this[kUndoStack])}[kUndo](){if(this[kUndoStack].length<=0)return;ArrayPrototypePush.call(this[kRedoStack],{text:this.line,cursor:this.cursor});var entry=ArrayPrototypePop.call(this[kUndoStack]);this.line=entry.text,this.cursor=entry.cursor,this[kRefreshLine]()}[kRedo](){if(this[kRedoStack].length<=0)return;ArrayPrototypePush.call(this[kUndoStack],{text:this.line,cursor:this.cursor});var entry=ArrayPrototypePop.call(this[kRedoStack]);this.line=entry.text,this.cursor=entry.cursor,this[kRefreshLine]()}[kHistoryNext](){if(this.historyIndex>=0){this[kBeforeEdit](this.line,this.cursor);var search=this[kSubstringSearch]||\"\",index=this.historyIndex-1;while(index>=0&&(!StringPrototypeStartsWith.call(this.history[index],search)||this.line===this.history[index]))index--;if(index===-1)this.line=search;else this.line=this.history[index];this.historyIndex=index,this.cursor=this.line.length,this[kRefreshLine]()}}[kHistoryPrev](){if(this.historyIndexthis.line.length)this.cursor=this.line.length;var newPos=this.getCursorPos();if(oldPos.rows===newPos.rows){var diffWidth=newPos.cols-oldPos.cols;moveCursor(this.output,diffWidth,0)}else this[kRefreshLine]()}[kTtyWrite](s,key){var previousKey=this[kPreviousKey];key=key||kEmptyObject,this[kPreviousKey]=key;var{name:keyName,meta:keyMeta,ctrl:keyCtrl2,shift:keyShift,sequence:keySeq}=key;if(!keyMeta||keyName!==\"y\")this[kYanking]=!1;if((keyName===\"up\"||keyName===\"down\")&&!keyCtrl2&&!keyMeta&&!keyShift){if(this[kSubstringSearch]===null)this[kSubstringSearch]=StringPrototypeSlice.call(this.line,0,this.cursor)}else if(this[kSubstringSearch]!==null){if(this[kSubstringSearch]=null,this.history.length===this.historyIndex)this.historyIndex=-1}if(typeof keySeq===\"string\")switch(StringPrototypeCodePointAt.call(keySeq,0)){case 31:this[kUndo]();return;case 30:this[kRedo]();return;default:break}if(keyName===\"escape\")return;if(keyCtrl2&&keyShift)switch(keyName){case\"backspace\":this[kDeleteLineLeft]();break;case\"delete\":this[kDeleteLineRight]();break}else if(keyCtrl2)switch(keyName){case\"c\":if(this.listenerCount(\"SIGINT\")>0)this.emit(\"SIGINT\");else this.close();break;case\"h\":this[kDeleteLeft]();break;case\"d\":if(this.cursor===0&&this.line.length===0)this.close();else if(this.cursorthis.crlfDelay)this[kLine]();this[kSawReturnAt]=0;break;case\"backspace\":this[kDeleteLeft]();break;case\"delete\":this[kDeleteRight]();break;case\"left\":this[kMoveCursor](-charLengthLeft(this.line,this.cursor));break;case\"right\":this[kMoveCursor](+charLengthAt(this.line,this.cursor));break;case\"home\":this[kMoveCursor]((-Infinity));break;case\"end\":this[kMoveCursor](Infinity);break;case\"up\":this[kHistoryPrev]();break;case\"down\":this[kHistoryNext]();break;case\"tab\":if(typeof this.completer===\"function\"&&this.isCompletionEnabled){var lastKeypressWasTab=previousKey&&previousKey.name===\"tab\";this[kTabComplete](lastKeypressWasTab);break}default:if(typeof s===\"string\"&&s){var nextMatch=RegExpPrototypeExec.call(lineEnding,s);if(nextMatch!==null){this[kInsertString](StringPrototypeSlice.call(s,0,nextMatch.index));var{lastIndex}=lineEnding;while((nextMatch=RegExpPrototypeExec.call(lineEnding,s))!==null)this[kLine](),this[kInsertString](StringPrototypeSlice.call(s,lastIndex,nextMatch.index)),{lastIndex}=lineEnding;if(lastIndex===s.length)this[kLine]()}else this[kInsertString](s)}}}}[SymbolAsyncIterator](){if(this[kLineObjectStream]===void 0)this[kLineObjectStream]=EventEmitter.on(this,\"line\",{close:[\"close\"],highWatermark:1024,[kFirstEventParam]:!0});return this[kLineObjectStream]}};function Interface(input,output,completer,terminal){if(!(this instanceof Interface))return new Interface(input,output,completer,terminal);if(input\?.input&&typeof input.completer===\"function\"&&input.completer.length!==2){var{completer}=input;input.completer=(v,cb)=>cb(null,completer(v))}else if(typeof completer===\"function\"&&completer.length!==2){var realCompleter=completer;completer=(v,cb)=>cb(null,realCompleter(v))}if(InterfaceConstructor.call(this,input,output,completer,terminal),process.env.TERM===\"dumb\")this._ttyWrite=_ttyWriteDumb.bind(this)}Interface.prototype={},ObjectSetPrototypeOf(Interface.prototype,_Interface.prototype),ObjectSetPrototypeOf(Interface,_Interface),Interface.prototype.question=function question(query,options,cb){if(cb=typeof options===\"function\"\?options:cb,options===null||typeof options!==\"object\")options=kEmptyObject;var signal=options\?.signal;if(signal){if(validateAbortSignal(signal,\"options.signal\"),signal.aborted)return;var onAbort=()=>{this[kQuestionCancel]()};signal.addEventListener(\"abort\",onAbort,{once:!0});var cleanup=()=>{signal.removeEventListener(\"abort\",onAbort)},originalCb=cb;cb=typeof cb===\"function\"\?(answer)=>{return cleanup(),originalCb(answer)}:cleanup}if(typeof cb===\"function\")this[kQuestion](query,cb)},Interface.prototype.question[promisify.custom]=function question(query,options){if(options===null||typeof options!==\"object\")options=kEmptyObject;var signal=options\?.signal;if(signal&&signal.aborted)return PromiseReject(new AbortError(void 0,{cause:signal.reason}));return new Promise((resolve,reject)=>{var cb=resolve;if(signal){var onAbort=()=>{reject(new AbortError(void 0,{cause:signal.reason}))};signal.addEventListener(\"abort\",onAbort,{once:!0}),cb=(answer)=>{signal.removeEventListener(\"abort\",onAbort),resolve(answer)}}this.question(query,options,cb)})};function createInterface(input,output,completer,terminal){return new Interface(input,output,completer,terminal)}ObjectDefineProperties(Interface.prototype,{[kSetRawMode]:{__proto__:null,get(){return this._setRawMode}},[kOnLine]:{__proto__:null,get(){return this._onLine}},[kWriteToOutput]:{__proto__:null,get(){return this._writeToOutput}},[kAddHistory]:{__proto__:null,get(){return this._addHistory}},[kRefreshLine]:{__proto__:null,get(){return this._refreshLine}},[kNormalWrite]:{__proto__:null,get(){return this._normalWrite}},[kInsertString]:{__proto__:null,get(){return this._insertString}},[kTabComplete]:{__proto__:null,get(){return this._tabComplete}},[kWordLeft]:{__proto__:null,get(){return this._wordLeft}},[kWordRight]:{__proto__:null,get(){return this._wordRight}},[kDeleteLeft]:{__proto__:null,get(){return this._deleteLeft}},[kDeleteRight]:{__proto__:null,get(){return this._deleteRight}},[kDeleteWordLeft]:{__proto__:null,get(){return this._deleteWordLeft}},[kDeleteWordRight]:{__proto__:null,get(){return this._deleteWordRight}},[kDeleteLineLeft]:{__proto__:null,get(){return this._deleteLineLeft}},[kDeleteLineRight]:{__proto__:null,get(){return this._deleteLineRight}},[kLine]:{__proto__:null,get(){return this._line}},[kHistoryNext]:{__proto__:null,get(){return this._historyNext}},[kHistoryPrev]:{__proto__:null,get(){return this._historyPrev}},[kGetDisplayPos]:{__proto__:null,get(){return this._getDisplayPos}},[kMoveCursor]:{__proto__:null,get(){return this._moveCursor}},[kTtyWrite]:{__proto__:null,get(){return this._ttyWrite}},_decoder:{__proto__:null,get(){return this[kDecoder]},set(value){this[kDecoder]=value}},_line_buffer:{__proto__:null,get(){return this[kLine_buffer]},set(value){this[kLine_buffer]=value}},_oldPrompt:{__proto__:null,get(){return this[kOldPrompt]},set(value){this[kOldPrompt]=value}},_previousKey:{__proto__:null,get(){return this[kPreviousKey]},set(value){this[kPreviousKey]=value}},_prompt:{__proto__:null,get(){return this[kPrompt]},set(value){this[kPrompt]=value}},_questionCallback:{__proto__:null,get(){return this[kQuestionCallback]},set(value){this[kQuestionCallback]=value}},_sawKeyPress:{__proto__:null,get(){return this[kSawKeyPress]},set(value){this[kSawKeyPress]=value}},_sawReturnAt:{__proto__:null,get(){return this[kSawReturnAt]},set(value){this[kSawReturnAt]=value}}}),Interface.prototype._setRawMode=_Interface.prototype[kSetRawMode],Interface.prototype._onLine=_Interface.prototype[kOnLine],Interface.prototype._writeToOutput=_Interface.prototype[kWriteToOutput],Interface.prototype._addHistory=_Interface.prototype[kAddHistory],Interface.prototype._refreshLine=_Interface.prototype[kRefreshLine],Interface.prototype._normalWrite=_Interface.prototype[kNormalWrite],Interface.prototype._insertString=_Interface.prototype[kInsertString],Interface.prototype._tabComplete=function(lastKeypressWasTab){this.pause();var string=StringPrototypeSlice.call(this.line,0,this.cursor);this.completer(string,(err,value)=>{if(this.resume(),err){this._writeToOutput(`Tab completion error: ${inspect(err)}`);return}this[kTabCompleter](lastKeypressWasTab,value)})},Interface.prototype._wordLeft=_Interface.prototype[kWordLeft],Interface.prototype._wordRight=_Interface.prototype[kWordRight],Interface.prototype._deleteLeft=_Interface.prototype[kDeleteLeft],Interface.prototype._deleteRight=_Interface.prototype[kDeleteRight],Interface.prototype._deleteWordLeft=_Interface.prototype[kDeleteWordLeft],Interface.prototype._deleteWordRight=_Interface.prototype[kDeleteWordRight],Interface.prototype._deleteLineLeft=_Interface.prototype[kDeleteLineLeft],Interface.prototype._deleteLineRight=_Interface.prototype[kDeleteLineRight],Interface.prototype._line=_Interface.prototype[kLine],Interface.prototype._historyNext=_Interface.prototype[kHistoryNext],Interface.prototype._historyPrev=_Interface.prototype[kHistoryPrev],Interface.prototype._getDisplayPos=_Interface.prototype[kGetDisplayPos],Interface.prototype._getCursorPos=_Interface.prototype.getCursorPos,Interface.prototype._moveCursor=_Interface.prototype[kMoveCursor],Interface.prototype._ttyWrite=_Interface.prototype[kTtyWrite];function _ttyWriteDumb(s,key){if(key=key||kEmptyObject,key.name===\"escape\")return;if(this[kSawReturnAt]&&key.name!==\"enter\")this[kSawReturnAt]=0;if(keyCtrl){if(key.name===\"c\"){if(this.listenerCount(\"SIGINT\")>0)this.emit(\"SIGINT\");else this.close();return}else if(key.name===\"d\"){this.close();return}}switch(key.name){case\"return\":this[kSawReturnAt]=DateNow(),this._line();break;case\"enter\":if(this[kSawReturnAt]===0||DateNow()-this[kSawReturnAt]>this.crlfDelay)this._line();this[kSawReturnAt]=0;break;default:if(typeof s===\"string\"&&s)this.line+=s,this.cursor+=s.length,this._writeToOutput(s)}}class Readline{#autoCommit=!1;#stream;#todo=[];constructor(stream,options=void 0){if(isWritable\?\?=(@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34)).isWritable,!isWritable(stream))throw new ERR_INVALID_ARG_TYPE(\"stream\",\"Writable\",stream);if(this.#stream=stream,options\?.autoCommit!=null)validateBoolean(options.autoCommit,\"options.autoCommit\"),this.#autoCommit=options.autoCommit}cursorTo(x,y=void 0){if(validateInteger(x,\"x\"),y!=null)validateInteger(y,\"y\");var data=y==null\?CSI`${x+1}G`:CSI`${y+1};${x+1}H`;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data);return this}moveCursor(dx,dy){if(dx||dy){validateInteger(dx,\"dx\"),validateInteger(dy,\"dy\");var data=\"\";if(dx<0)data+=CSI`${-dx}D`;else if(dx>0)data+=CSI`${dx}C`;if(dy<0)data+=CSI`${-dy}A`;else if(dy>0)data+=CSI`${dy}B`;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data)}return this}clearLine(dir){validateInteger(dir,\"dir\",-1,1);var data=dir<0\?kClearToLineBeginning:dir>0\?kClearToLineEnd:kClearLine;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data);return this}clearScreenDown(){if(this.#autoCommit)process.nextTick(()=>this.#stream.write(kClearScreenDown));else ArrayPrototypePush.call(this.#todo,kClearScreenDown);return this}commit(){return new Promise((resolve)=>{this.#stream.write(ArrayPrototypeJoin.call(this.#todo,\"\"),resolve),this.#todo=[]})}rollback(){return this.#todo=[],this}}var PromisesInterface=class Interface2 extends _Interface{constructor(input,output,completer,terminal){super(input,output,completer,terminal)}question(query,options=kEmptyObject){var signal=options\?.signal;if(signal){if(validateAbortSignal(signal,\"options.signal\"),signal.aborted)return PromiseReject(new AbortError(void 0,{cause:signal.reason}))}return new Promise((resolve,reject)=>{var cb=resolve;if(options\?.signal){var onAbort=()=>{this[kQuestionCancel](),reject(new AbortError(void 0,{cause:signal.reason}))};signal.addEventListener(\"abort\",onAbort,{once:!0}),cb=(answer)=>{signal.removeEventListener(\"abort\",onAbort),resolve(answer)}}this[kQuestion](query,cb)})}};return $={Interface,clearLine,clearScreenDown,createInterface,cursorTo,emitKeypressEvents,moveCursor,promises:{Readline,Interface:PromisesInterface,createInterface(input,output,completer,terminal){return new PromisesInterface(input,output,completer,terminal)}},[SymbolFor(\"__BUN_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__\")]:{CSI,utils:{getStringWidth,stripVTControlCharacters}}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeReadlinePromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,30)||@createInternalModuleById(30)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeReplCode = "(function (){\"use strict\";var $;const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function REPLServer(){throwNotImplemented(\"node:repl REPLServer\")}function Recoverable(){throwNotImplemented(\"node:repl Recoverable\")}var REPL_MODE_SLOPPY=0,REPL_MODE_STRICT=1;function start(){throwNotImplemented(\"node:repl\")}return $={lines:[],context:globalThis,historyIndex:-1,cursor:0,historySize:1000,removeHistoryDuplicates:!1,crlfDelay:100,completer:()=>{throwNotImplemented(\"node:repl\")},history:[],_initialPrompt:\"> \",terminal:!0,input:new Proxy({},{get(){throwNotImplemented(\"node:repl\")},has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{return},set(){throwNotImplemented(\"node:repl\")}}),line:\"\",eval:()=>{throwNotImplemented(\"node:repl\")},isCompletionEnabled:!0,escapeCodeTimeout:500,tabSize:8,breakEvalOnSigint:!0,useGlobal:!0,underscoreAssigned:!1,last:void 0,_domain:void 0,allowBlockingCompletions:!1,useColors:!0,output:new Proxy({},{get(){throwNotImplemented(\"node:repl\")},has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{return},set(){throwNotImplemented(\"node:repl\")}})},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamConsumersCode = "(function (){\"use strict\";const{readableStreamToArrayBuffer:arrayBuffer,readableStreamToText:text}=Bun,json=(stream)=>Bun.readableStreamToText(stream).then(JSON.parse),buffer=async(readableStream)=>{return new Buffer(await arrayBuffer(readableStream))},blob=Bun.readableStreamToBlob;return{arrayBuffer,text,json,buffer,blob}})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamCode = "(function (){\"use strict\";const EE=globalThis[globalThis.Symbol.for('Bun.lazy')](\"events\"),StringDecoder=@requireNativeModule(\"node:string_decoder\").StringDecoder;var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require2(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},runOnNextTick=process.nextTick;function isReadableStream(value){return typeof value===\"object\"&&value!==null&&value instanceof ReadableStream}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}const validateObject=(value,name,options=null)=>{const allowArray=options\?.allowArray\?\?!1,allowFunction=options\?.allowFunction\?\?!1;if(!(options\?.nullable\?\?!1)&&value===null||!allowArray&&ArrayIsArray(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE(name,\"Object\",value)};function validateString(value,name){if(typeof value!==\"string\")throw new ERR_INVALID_ARG_TYPE(name,\"string\",value)}var ArrayIsArray=Array.isArray;function ERR_INVALID_ARG_TYPE(name,type,value){return new Error(`The argument '${name}' is invalid. Received '${value}' for type '${type}'`)}function ERR_INVALID_ARG_VALUE(name,value,reason){return new Error(`The value '${value}' is invalid for argument '${name}'. Reason: ${reason}`)}var require_primordials=__commonJS({\"node_modules/readable-stream/lib/ours/primordials.js\"(exports2,module){module.exports={ArrayIsArray(self){return Array.isArray(self)},ArrayPrototypeIncludes(self,el){return self.includes(el)},ArrayPrototypeIndexOf(self,el){return self.indexOf(el)},ArrayPrototypeJoin(self,sep){return self.join(sep)},ArrayPrototypeMap(self,fn){return self.map(fn)},ArrayPrototypePop(self,el){return self.pop(el)},ArrayPrototypePush(self,el){return self.push(el)},ArrayPrototypeSlice(self,start,end){return self.slice(start,end)},Error,FunctionPrototypeCall(fn,thisArgs,...args){return fn.call(thisArgs,...args)},FunctionPrototypeSymbolHasInstance(self,instance){return Function.prototype[Symbol.hasInstance].call(self,instance)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(self,props){return Object.defineProperties(self,props)},ObjectDefineProperty(self,name,prop){return Object.defineProperty(self,name,prop)},ObjectGetOwnPropertyDescriptor(self,name){return Object.getOwnPropertyDescriptor(self,name)},ObjectKeys(obj){return Object.keys(obj)},ObjectSetPrototypeOf(target,proto){return Object.setPrototypeOf(target,proto)},Promise,PromisePrototypeCatch(self,fn){return self.catch(fn)},PromisePrototypeThen(self,thenFn,catchFn){return self.then(thenFn,catchFn)},PromiseReject(err){return Promise.reject(err)},ReflectApply:Reflect.apply,RegExpPrototypeTest(self,value){return self.test(value)},SafeSet:Set,String,StringPrototypeSlice(self,start,end){return self.slice(start,end)},StringPrototypeToLowerCase(self){return self.toLowerCase()},StringPrototypeToUpperCase(self){return self.toUpperCase()},StringPrototypeTrim(self){return self.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(self,buf,len){return self.set(buf,len)},Uint8Array}}}),require_util=__commonJS({\"node_modules/readable-stream/lib/ours/util.js\"(exports2,module){var AsyncFunction=Object.getPrototypeOf(async function(){}).constructor,isBlob=typeof Blob!==\"undefined\"\?function isBlob2(b){return b instanceof Blob}:function isBlob2(b){return!1},AggregateError=class extends Error{constructor(errors){if(!Array.isArray(errors))@throwTypeError(`Expected input to be an Array, got ${typeof errors}`);let message=\"\";for(let i=0;i{resolve=res,reject=rej}),resolve,reject}},promisify(fn){return new Promise((resolve,reject)=>{fn((err,...args)=>{if(err)return reject(err);return resolve(...args)})})},debuglog(){return function(){}},format(format,...args){return format.replace(/%([sdifj])/g,function(...[_unused,type]){const replacement=args.shift();if(type===\"f\")return replacement.toFixed(6);else if(type===\"j\")return JSON.stringify(replacement);else if(type===\"s\"&&typeof replacement===\"object\")return`${replacement.constructor!==Object\?replacement.constructor.name:\"\"} {}`.trim();else return replacement.toString()})},inspect(value){switch(typeof value){case\"string\":if(value.includes(\"'\")){if(!value.includes('\"'))return`\"${value}\"`;else if(!value.includes(\"`\")&&!value.includes(\"${\"))return`\\`${value}\\``}return`'${value}'`;case\"number\":if(isNaN(value))return\"NaN\";else if(Object.is(value,-0))return String(value);return value;case\"bigint\":return`${String(value)}n`;case\"boolean\":case\"undefined\":return String(value);case\"object\":return\"{}\"}},types:{isAsyncFunction(fn){return fn instanceof AsyncFunction},isArrayBufferView(arr){return ArrayBuffer.isView(arr)}},isBlob},module.exports.promisify.custom=Symbol.for(\"nodejs.util.promisify.custom\")}}),require_errors=__commonJS({\"node_modules/readable-stream/lib/ours/errors.js\"(exports2,module){var{format,inspect,AggregateError:CustomAggregateError}=require_util(),AggregateError=globalThis.AggregateError||CustomAggregateError,kIsNodeError=Symbol(\"kIsNodeError\"),kTypes=[\"string\",\"function\",\"number\",\"object\",\"Function\",\"Object\",\"boolean\",\"bigint\",\"symbol\"],classRegExp=/^([A-Z][a-z0-9]*)+$/,nodeInternalPrefix=\"__node_internal_\",codes={};function assert(value,message){if(!value)throw new codes.ERR_INTERNAL_ASSERTION(message)}function addNumericalSeparator(val){let res=\"\",i=val.length;const start=val[0]===\"-\"\?1:0;for(;i>=start+4;i-=3)res=`_${val.slice(i-3,i)}${res}`;return`${val.slice(0,i)}${res}`}function getMessage(key,msg,args){if(typeof msg===\"function\")return assert(msg.length<=args.length,`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${msg.length}).`),msg(...args);const expectedLength=(msg.match(/%[dfijoOs]/g)||[]).length;if(assert(expectedLength===args.length,`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`),args.length===0)return msg;return format(msg,...args)}function E(code,message,Base){if(!Base)Base=Error;class NodeError extends Base{constructor(...args){super(getMessage(code,message,args))}toString(){return`${this.name} [${code}]: ${this.message}`}}Object.defineProperties(NodeError.prototype,{name:{value:Base.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${code}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),NodeError.prototype.code=code,NodeError.prototype[kIsNodeError]=!0,codes[code]=NodeError}function hideStackFrames(fn){const hidden=nodeInternalPrefix+fn.name;return Object.defineProperty(fn,\"name\",{value:hidden}),fn}function aggregateTwoErrors(innerError,outerError){if(innerError&&outerError&&innerError!==outerError){if(Array.isArray(outerError.errors))return outerError.errors.push(innerError),outerError;const err=new AggregateError([outerError,innerError],outerError.message);return err.code=outerError.code,err}return innerError||outerError}var AbortError2=class extends Error{constructor(message=\"The operation was aborted\",options=void 0){if(options!==void 0&&typeof options!==\"object\")throw new codes.ERR_INVALID_ARG_TYPE(\"options\",\"Object\",options);super(message,options);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};E(\"ERR_ASSERTION\",\"%s\",Error),E(\"ERR_INVALID_ARG_TYPE\",(name,expected,actual)=>{if(assert(typeof name===\"string\",\"'name' must be a string\"),!Array.isArray(expected))expected=[expected];let msg=\"The \";if(name.endsWith(\" argument\"))msg+=`${name} `;else msg+=`\"${name}\" ${name.includes(\".\")\?\"property\":\"argument\"} `;msg+=\"must be \";const types=[],instances=[],other=[];for(let value of expected)if(assert(typeof value===\"string\",\"All expected entries have to be of type string\"),kTypes.includes(value))types.push(value.toLowerCase());else if(classRegExp.test(value))instances.push(value);else assert(value!==\"object\",'The value \"object\" should be written as \"Object\"'),other.push(value);if(instances.length>0){const pos=types.indexOf(\"object\");if(pos!==-1)types.splice(types,pos,1),instances.push(\"Object\")}if(types.length>0){switch(types.length){case 1:msg+=`of type ${types[0]}`;break;case 2:msg+=`one of type ${types[0]} or ${types[1]}`;break;default:{const last=types.pop();msg+=`one of type ${types.join(\", \")}, or ${last}`}}if(instances.length>0||other.length>0)msg+=\" or \"}if(instances.length>0){switch(instances.length){case 1:msg+=`an instance of ${instances[0]}`;break;case 2:msg+=`an instance of ${instances[0]} or ${instances[1]}`;break;default:{const last=instances.pop();msg+=`an instance of ${instances.join(\", \")}, or ${last}`}}if(other.length>0)msg+=\" or \"}switch(other.length){case 0:break;case 1:if(other[0].toLowerCase()!==other[0])msg+=\"an \";msg+=`${other[0]}`;break;case 2:msg+=`one of ${other[0]} or ${other[1]}`;break;default:{const last=other.pop();msg+=`one of ${other.join(\", \")}, or ${last}`}}if(actual==null)msg+=`. Received ${actual}`;else if(typeof actual===\"function\"&&actual.name)msg+=`. Received function ${actual.name}`;else if(typeof actual===\"object\"){var _actual$constructor;if((_actual$constructor=actual.constructor)!==null&&_actual$constructor!==void 0&&_actual$constructor.name)msg+=`. Received an instance of ${actual.constructor.name}`;else{const inspected=inspect(actual,{depth:-1});msg+=`. Received ${inspected}`}}else{let inspected=inspect(actual,{colors:!1});if(inspected.length>25)inspected=`${inspected.slice(0,25)}...`;msg+=`. Received type ${typeof actual} (${inspected})`}return msg},TypeError),E(\"ERR_INVALID_ARG_VALUE\",(name,value,reason=\"is invalid\")=>{let inspected=inspect(value);if(inspected.length>128)inspected=inspected.slice(0,128)+\"...\";return`The ${name.includes(\".\")\?\"property\":\"argument\"} '${name}' ${reason}. Received ${inspected}`},TypeError),E(\"ERR_INVALID_RETURN_VALUE\",(input,name,value)=>{var _value$constructor;const type=value!==null&&value!==void 0&&(_value$constructor=value.constructor)!==null&&_value$constructor!==void 0&&_value$constructor.name\?`instance of ${value.constructor.name}`:`type ${typeof value}`;return`Expected ${input} to be returned from the \"${name}\" function but got ${type}.`},TypeError),E(\"ERR_MISSING_ARGS\",(...args)=>{assert(args.length>0,\"At least one arg needs to be specified\");let msg;const len=args.length;switch(args=(Array.isArray(args)\?args:[args]).map((a)=>`\"${a}\"`).join(\" or \"),len){case 1:msg+=`The ${args[0]} argument`;break;case 2:msg+=`The ${args[0]} and ${args[1]} arguments`;break;default:{const last=args.pop();msg+=`The ${args.join(\", \")}, and ${last} arguments`}break}return`${msg} must be specified`},TypeError),E(\"ERR_OUT_OF_RANGE\",(str,range,input)=>{assert(range,'Missing \"range\" argument');let received;if(Number.isInteger(input)&&Math.abs(input)>4294967296)received=addNumericalSeparator(String(input));else if(typeof input===\"bigint\"){if(received=String(input),input>2n**32n||input<-(2n**32n))received=addNumericalSeparator(received);received+=\"n\"}else received=inspect(input);return`The value of \"${str}\" is out of range. It must be ${range}. Received ${received}`},RangeError),E(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\",Error),E(\"ERR_METHOD_NOT_IMPLEMENTED\",\"The %s method is not implemented\",Error),E(\"ERR_STREAM_ALREADY_FINISHED\",\"Cannot call %s after a stream was finished\",Error),E(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\",Error),E(\"ERR_STREAM_DESTROYED\",\"Cannot call %s after a stream was destroyed\",Error),E(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),E(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\",Error),E(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\",Error),E(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\",Error),E(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\",Error),E(\"ERR_UNKNOWN_ENCODING\",\"Unknown encoding: %s\",TypeError),module.exports={AbortError:AbortError2,aggregateTwoErrors:hideStackFrames(aggregateTwoErrors),hideStackFrames,codes}}}),require_validators=__commonJS({\"node_modules/readable-stream/lib/internal/validators.js\"(exports2,module){var{ArrayIsArray:ArrayIsArray2,ArrayPrototypeIncludes,ArrayPrototypeJoin,ArrayPrototypeMap,NumberIsInteger,NumberMAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER,NumberParseInt,RegExpPrototypeTest,String:String2,StringPrototypeToUpperCase,StringPrototypeTrim}=require_primordials(),{hideStackFrames,codes:{ERR_SOCKET_BAD_PORT,ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2,ERR_OUT_OF_RANGE,ERR_UNKNOWN_SIGNAL}}=require_errors(),{normalizeEncoding}=require_util(),{isAsyncFunction,isArrayBufferView}=require_util().types,signals={};function isInt32(value){return value===(value|0)}function isUint32(value){return value===value>>>0}var octalReg=/^[0-7]+$/,modeDesc=\"must be a 32-bit unsigned integer or an octal string\";function parseFileMode(value,name,def){if(typeof value===\"undefined\")value=def;if(typeof value===\"string\"){if(!RegExpPrototypeTest(octalReg,value))throw new ERR_INVALID_ARG_VALUE2(name,value,modeDesc);value=NumberParseInt(value,8)}return validateInt32(value,name,0,4294967295),value}var validateInteger=hideStackFrames((value,name,min=NumberMIN_SAFE_INTEGER,max=NumberMAX_SAFE_INTEGER)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}),validateInt32=hideStackFrames((value,name,min=-2147483648,max=2147483647)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!isInt32(value)){if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}),validateUint32=hideStackFrames((value,name,positive)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!isUint32(value)){if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);throw new ERR_OUT_OF_RANGE(name,`>= ${positive\?1:0} && < 4294967296`,value)}if(positive&&value===0)throw new ERR_OUT_OF_RANGE(name,\">= 1 && < 4294967296\",value)});function validateString2(value,name){if(typeof value!==\"string\")throw new ERR_INVALID_ARG_TYPE2(name,\"string\",value)}function validateNumber(value,name){if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value)}var validateOneOf=hideStackFrames((value,name,oneOf)=>{if(!ArrayPrototypeIncludes(oneOf,value)){const reason=\"must be one of: \"+ArrayPrototypeJoin(ArrayPrototypeMap(oneOf,(v)=>typeof v===\"string\"\?`'${v}'`:String2(v)),\", \");throw new ERR_INVALID_ARG_VALUE2(name,value,reason)}});function validateBoolean2(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE2(name,\"boolean\",value)}var validateObject2=hideStackFrames((value,name,options)=>{const useDefaultOptions=options==null,allowArray=useDefaultOptions\?!1:options.allowArray,allowFunction=useDefaultOptions\?!1:options.allowFunction;if(!(useDefaultOptions\?!1:options.nullable)&&value===null||!allowArray&&ArrayIsArray2(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE2(name,\"Object\",value)}),validateArray=hideStackFrames((value,name,minLength=0)=>{if(!ArrayIsArray2(value))throw new ERR_INVALID_ARG_TYPE2(name,\"Array\",value);if(value.length{if(!isArrayBufferView(buffer))throw new ERR_INVALID_ARG_TYPE2(name,[\"Buffer\",\"TypedArray\",\"DataView\"],buffer)});function validateEncoding(data,encoding){const normalizedEncoding=normalizeEncoding(encoding),length=data.length;if(normalizedEncoding===\"hex\"&&length%2!==0)throw new ERR_INVALID_ARG_VALUE2(\"encoding\",encoding,`is invalid for data of length ${length}`)}function validatePort(port,name=\"Port\",allowZero=!0){if(typeof port!==\"number\"&&typeof port!==\"string\"||typeof port===\"string\"&&StringPrototypeTrim(port).length===0||+port!==+port>>>0||port>65535||port===0&&!allowZero)throw new ERR_SOCKET_BAD_PORT(name,port,allowZero);return port|0}var validateAbortSignal=hideStackFrames((signal,name)=>{if(signal!==void 0&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE2(name,\"AbortSignal\",signal)}),validateFunction=hideStackFrames((value,name)=>{if(typeof value!==\"function\")throw new ERR_INVALID_ARG_TYPE2(name,\"Function\",value)}),validatePlainFunction=hideStackFrames((value,name)=>{if(typeof value!==\"function\"||isAsyncFunction(value))throw new ERR_INVALID_ARG_TYPE2(name,\"Function\",value)}),validateUndefined=hideStackFrames((value,name)=>{if(value!==void 0)throw new ERR_INVALID_ARG_TYPE2(name,\"undefined\",value)});module.exports={isInt32,isUint32,parseFileMode,validateArray,validateBoolean:validateBoolean2,validateBuffer,validateEncoding,validateFunction,validateInt32,validateInteger,validateNumber,validateObject:validateObject2,validateOneOf,validatePlainFunction,validatePort,validateSignalName,validateString:validateString2,validateUint32,validateUndefined,validateAbortSignal}}}),require_utils=__commonJS({\"node_modules/readable-stream/lib/internal/streams/utils.js\"(exports2,module){var{Symbol:Symbol2,SymbolAsyncIterator,SymbolIterator}=require_primordials(),kDestroyed=Symbol2(\"kDestroyed\"),kIsErrored=Symbol2(\"kIsErrored\"),kIsReadable=Symbol2(\"kIsReadable\"),kIsDisturbed=Symbol2(\"kIsDisturbed\");function isReadableNodeStream(obj,strict=!1){var _obj$_readableState;return!!(obj&&typeof obj.pipe===\"function\"&&typeof obj.on===\"function\"&&(!strict||typeof obj.pause===\"function\"&&typeof obj.resume===\"function\")&&(!obj._writableState||((_obj$_readableState=obj._readableState)===null||_obj$_readableState===void 0\?void 0:_obj$_readableState.readable)!==!1)&&(!obj._writableState||obj._readableState))}function isWritableNodeStream(obj){var _obj$_writableState;return!!(obj&&typeof obj.write===\"function\"&&typeof obj.on===\"function\"&&(!obj._readableState||((_obj$_writableState=obj._writableState)===null||_obj$_writableState===void 0\?void 0:_obj$_writableState.writable)!==!1))}function isDuplexNodeStream(obj){return!!(obj&&typeof obj.pipe===\"function\"&&obj._readableState&&typeof obj.on===\"function\"&&typeof obj.write===\"function\")}function isNodeStream(obj){return obj&&(obj._readableState||obj._writableState||typeof obj.write===\"function\"&&typeof obj.on===\"function\"||typeof obj.pipe===\"function\"&&typeof obj.on===\"function\")}function isIterable(obj,isAsync){if(obj==null)return!1;if(isAsync===!0)return typeof obj[SymbolAsyncIterator]===\"function\";if(isAsync===!1)return typeof obj[SymbolIterator]===\"function\";return typeof obj[SymbolAsyncIterator]===\"function\"||typeof obj[SymbolIterator]===\"function\"}function isDestroyed(stream){if(!isNodeStream(stream))return null;const{_writableState:wState,_readableState:rState}=stream,state=wState||rState;return!!(stream.destroyed||stream[kDestroyed]||state!==null&&state!==void 0&&state.destroyed)}function isWritableEnded(stream){if(!isWritableNodeStream(stream))return null;if(stream.writableEnded===!0)return!0;const wState=stream._writableState;if(wState!==null&&wState!==void 0&&wState.errored)return!1;if(typeof(wState===null||wState===void 0\?void 0:wState.ended)!==\"boolean\")return null;return wState.ended}function isWritableFinished(stream,strict){if(!isWritableNodeStream(stream))return null;if(stream.writableFinished===!0)return!0;const wState=stream._writableState;if(wState!==null&&wState!==void 0&&wState.errored)return!1;if(typeof(wState===null||wState===void 0\?void 0:wState.finished)!==\"boolean\")return null;return!!(wState.finished||strict===!1&&wState.ended===!0&&wState.length===0)}function isReadableEnded(stream){if(!isReadableNodeStream(stream))return null;if(stream.readableEnded===!0)return!0;const rState=stream._readableState;if(!rState||rState.errored)return!1;if(typeof(rState===null||rState===void 0\?void 0:rState.ended)!==\"boolean\")return null;return rState.ended}function isReadableFinished(stream,strict){if(!isReadableNodeStream(stream))return null;const rState=stream._readableState;if(rState!==null&&rState!==void 0&&rState.errored)return!1;if(typeof(rState===null||rState===void 0\?void 0:rState.endEmitted)!==\"boolean\")return null;return!!(rState.endEmitted||strict===!1&&rState.ended===!0&&rState.length===0)}function isReadable(stream){if(stream&&stream[kIsReadable]!=null)return stream[kIsReadable];if(typeof(stream===null||stream===void 0\?void 0:stream.readable)!==\"boolean\")return null;if(isDestroyed(stream))return!1;return isReadableNodeStream(stream)&&stream.readable&&!isReadableFinished(stream)}function isWritable(stream){if(typeof(stream===null||stream===void 0\?void 0:stream.writable)!==\"boolean\")return null;if(isDestroyed(stream))return!1;return isWritableNodeStream(stream)&&stream.writable&&!isWritableEnded(stream)}function isFinished(stream,opts){if(!isNodeStream(stream))return null;if(isDestroyed(stream))return!0;if((opts===null||opts===void 0\?void 0:opts.readable)!==!1&&isReadable(stream))return!1;if((opts===null||opts===void 0\?void 0:opts.writable)!==!1&&isWritable(stream))return!1;return!0}function isWritableErrored(stream){var _stream$_writableStat,_stream$_writableStat2;if(!isNodeStream(stream))return null;if(stream.writableErrored)return stream.writableErrored;return(_stream$_writableStat=(_stream$_writableStat2=stream._writableState)===null||_stream$_writableStat2===void 0\?void 0:_stream$_writableStat2.errored)!==null&&_stream$_writableStat!==void 0\?_stream$_writableStat:null}function isReadableErrored(stream){var _stream$_readableStat,_stream$_readableStat2;if(!isNodeStream(stream))return null;if(stream.readableErrored)return stream.readableErrored;return(_stream$_readableStat=(_stream$_readableStat2=stream._readableState)===null||_stream$_readableStat2===void 0\?void 0:_stream$_readableStat2.errored)!==null&&_stream$_readableStat!==void 0\?_stream$_readableStat:null}function isClosed(stream){if(!isNodeStream(stream))return null;if(typeof stream.closed===\"boolean\")return stream.closed;const{_writableState:wState,_readableState:rState}=stream;if(typeof(wState===null||wState===void 0\?void 0:wState.closed)===\"boolean\"||typeof(rState===null||rState===void 0\?void 0:rState.closed)===\"boolean\")return(wState===null||wState===void 0\?void 0:wState.closed)||(rState===null||rState===void 0\?void 0:rState.closed);if(typeof stream._closed===\"boolean\"&&isOutgoingMessage(stream))return stream._closed;return null}function isOutgoingMessage(stream){return typeof stream._closed===\"boolean\"&&typeof stream._defaultKeepAlive===\"boolean\"&&typeof stream._removedConnection===\"boolean\"&&typeof stream._removedContLen===\"boolean\"}function isServerResponse(stream){return typeof stream._sent100===\"boolean\"&&isOutgoingMessage(stream)}function isServerRequest(stream){var _stream$req;return typeof stream._consuming===\"boolean\"&&typeof stream._dumped===\"boolean\"&&((_stream$req=stream.req)===null||_stream$req===void 0\?void 0:_stream$req.upgradeOrConnect)===void 0}function willEmitClose(stream){if(!isNodeStream(stream))return null;const{_writableState:wState,_readableState:rState}=stream,state=wState||rState;return!state&&isServerResponse(stream)||!!(state&&state.autoDestroy&&state.emitClose&&state.closed===!1)}function isDisturbed(stream){var _stream$kIsDisturbed;return!!(stream&&((_stream$kIsDisturbed=stream[kIsDisturbed])!==null&&_stream$kIsDisturbed!==void 0\?_stream$kIsDisturbed:stream.readableDidRead||stream.readableAborted))}function isErrored(stream){var _ref,_ref2,_ref3,_ref4,_ref5,_stream$kIsErrored,_stream$_readableStat3,_stream$_writableStat3,_stream$_readableStat4,_stream$_writableStat4;return!!(stream&&((_ref=(_ref2=(_ref3=(_ref4=(_ref5=(_stream$kIsErrored=stream[kIsErrored])!==null&&_stream$kIsErrored!==void 0\?_stream$kIsErrored:stream.readableErrored)!==null&&_ref5!==void 0\?_ref5:stream.writableErrored)!==null&&_ref4!==void 0\?_ref4:(_stream$_readableStat3=stream._readableState)===null||_stream$_readableStat3===void 0\?void 0:_stream$_readableStat3.errorEmitted)!==null&&_ref3!==void 0\?_ref3:(_stream$_writableStat3=stream._writableState)===null||_stream$_writableStat3===void 0\?void 0:_stream$_writableStat3.errorEmitted)!==null&&_ref2!==void 0\?_ref2:(_stream$_readableStat4=stream._readableState)===null||_stream$_readableStat4===void 0\?void 0:_stream$_readableStat4.errored)!==null&&_ref!==void 0\?_ref:(_stream$_writableStat4=stream._writableState)===null||_stream$_writableStat4===void 0\?void 0:_stream$_writableStat4.errored))}module.exports={kDestroyed,isDisturbed,kIsDisturbed,isErrored,kIsErrored,isReadable,kIsReadable,isClosed,isDestroyed,isDuplexNodeStream,isFinished,isIterable,isReadableNodeStream,isReadableEnded,isReadableFinished,isReadableErrored,isNodeStream,isWritable,isWritableNodeStream,isWritableEnded,isWritableFinished,isWritableErrored,isServerRequest,isServerResponse,willEmitClose}}}),require_end_of_stream=__commonJS({\"node_modules/readable-stream/lib/internal/streams/end-of-stream.js\"(exports2,module){var{AbortError:AbortError2,codes}=require_errors(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_STREAM_PREMATURE_CLOSE}=codes,{once}=require_util(),{validateAbortSignal,validateFunction,validateObject:validateObject2}=require_validators(),{Promise:Promise2}=require_primordials(),{isClosed,isReadable,isReadableNodeStream,isReadableFinished,isReadableErrored,isWritable,isWritableNodeStream,isWritableFinished,isWritableErrored,isNodeStream,willEmitClose:_willEmitClose}=require_utils();function isRequest(stream){return stream.setHeader&&typeof stream.abort===\"function\"}var nop=()=>{};function eos(stream,options,callback){var _options$readable,_options$writable;if(arguments.length===2)callback=options,options={};else if(options==null)options={};else validateObject2(options,\"options\");validateFunction(callback,\"callback\"),validateAbortSignal(options.signal,\"options.signal\"),callback=once(callback);const readable=(_options$readable=options.readable)!==null&&_options$readable!==void 0\?_options$readable:isReadableNodeStream(stream),writable=(_options$writable=options.writable)!==null&&_options$writable!==void 0\?_options$writable:isWritableNodeStream(stream);if(!isNodeStream(stream))throw new ERR_INVALID_ARG_TYPE2(\"stream\",\"Stream\",stream);const{_writableState:wState,_readableState:rState}=stream,onlegacyfinish=()=>{if(!stream.writable)onfinish()};let willEmitClose=_willEmitClose(stream)&&isReadableNodeStream(stream)===readable&&isWritableNodeStream(stream)===writable,writableFinished=isWritableFinished(stream,!1);const onfinish=()=>{if(writableFinished=!0,stream.destroyed)willEmitClose=!1;if(willEmitClose&&(!stream.readable||readable))return;if(!readable||readableFinished)callback.call(stream)};let readableFinished=isReadableFinished(stream,!1);const onend=()=>{if(readableFinished=!0,stream.destroyed)willEmitClose=!1;if(willEmitClose&&(!stream.writable||writable))return;if(!writable||writableFinished)callback.call(stream)},onerror=(err)=>{callback.call(stream,err)};let closed=isClosed(stream);const onclose=()=>{closed=!0;const errored=isWritableErrored(stream)||isReadableErrored(stream);if(errored&&typeof errored!==\"boolean\")return callback.call(stream,errored);if(readable&&!readableFinished&&isReadableNodeStream(stream,!0)){if(!isReadableFinished(stream,!1))return callback.call(stream,new ERR_STREAM_PREMATURE_CLOSE)}if(writable&&!writableFinished){if(!isWritableFinished(stream,!1))return callback.call(stream,new ERR_STREAM_PREMATURE_CLOSE)}callback.call(stream)},onrequest=()=>{stream.req.on(\"finish\",onfinish)};if(isRequest(stream)){if(stream.on(\"complete\",onfinish),!willEmitClose)stream.on(\"abort\",onclose);if(stream.req)onrequest();else stream.on(\"request\",onrequest)}else if(writable&&!wState)stream.on(\"end\",onlegacyfinish),stream.on(\"close\",onlegacyfinish);if(!willEmitClose&&typeof stream.aborted===\"boolean\")stream.on(\"aborted\",onclose);if(stream.on(\"end\",onend),stream.on(\"finish\",onfinish),options.error!==!1)stream.on(\"error\",onerror);if(stream.on(\"close\",onclose),closed)runOnNextTick(onclose);else if(wState!==null&&wState!==void 0&&wState.errorEmitted||rState!==null&&rState!==void 0&&rState.errorEmitted){if(!willEmitClose)runOnNextTick(onclose)}else if(!readable&&(!willEmitClose||isReadable(stream))&&(writableFinished||isWritable(stream)===!1))runOnNextTick(onclose);else if(!writable&&(!willEmitClose||isWritable(stream))&&(readableFinished||isReadable(stream)===!1))runOnNextTick(onclose);else if(rState&&stream.req&&stream.aborted)runOnNextTick(onclose);const cleanup=()=>{if(callback=nop,stream.removeListener(\"aborted\",onclose),stream.removeListener(\"complete\",onfinish),stream.removeListener(\"abort\",onclose),stream.removeListener(\"request\",onrequest),stream.req)stream.req.removeListener(\"finish\",onfinish);stream.removeListener(\"end\",onlegacyfinish),stream.removeListener(\"close\",onlegacyfinish),stream.removeListener(\"finish\",onfinish),stream.removeListener(\"end\",onend),stream.removeListener(\"error\",onerror),stream.removeListener(\"close\",onclose)};if(options.signal&&!closed){const abort=()=>{const endCallback=callback;cleanup(),endCallback.call(stream,new AbortError2(void 0,{cause:options.signal.reason}))};if(options.signal.aborted)runOnNextTick(abort);else{const originalCallback=callback;callback=once((...args)=>{options.signal.removeEventListener(\"abort\",abort),originalCallback.apply(stream,args)}),options.signal.addEventListener(\"abort\",abort)}}return cleanup}function finished2(stream,opts){return new Promise2((resolve,reject)=>{eos(stream,opts,(err)=>{if(err)reject(err);else resolve()})})}module.exports=eos,module.exports.finished=finished2}}),require_operators=__commonJS({\"node_modules/readable-stream/lib/internal/streams/operators.js\"(exports2,module){var{codes:{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_MISSING_ARGS,ERR_OUT_OF_RANGE},AbortError:AbortError2}=require_errors(),{validateAbortSignal,validateInteger,validateObject:validateObject2}=require_validators(),kWeakHandler=require_primordials().Symbol(\"kWeak\"),{finished:finished2}=require_end_of_stream(),{ArrayPrototypePush,MathFloor,Number:Number2,NumberIsNaN,Promise:Promise2,PromiseReject,PromisePrototypeCatch,Symbol:Symbol2}=require_primordials(),kEmpty=Symbol2(\"kEmpty\"),kEof=Symbol2(\"kEof\");function map(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");let concurrency=1;if((options===null||options===void 0\?void 0:options.concurrency)!=null)concurrency=MathFloor(options.concurrency);return validateInteger(concurrency,\"concurrency\",1),async function*map2(){var _options$signal,_options$signal2;const ac=new AbortController,stream=this,queue=[],signal=ac.signal,signalOpt={signal},abort=()=>ac.abort();if(options!==null&&options!==void 0&&(_options$signal=options.signal)!==null&&_options$signal!==void 0&&_options$signal.aborted)abort();options===null||options===void 0||(_options$signal2=options.signal)===null||_options$signal2===void 0||_options$signal2.addEventListener(\"abort\",abort);let next,resume,done=!1;function onDone(){done=!0}async function pump(){try{for await(let val of stream){var _val;if(done)return;if(signal.aborted)throw new AbortError2;try{val=fn(val,signalOpt)}catch(err){val=PromiseReject(err)}if(val===kEmpty)continue;if(typeof((_val=val)===null||_val===void 0\?void 0:_val.catch)===\"function\")val.catch(onDone);if(queue.push(val),next)next(),next=null;if(!done&&queue.length&&queue.length>=concurrency)await new Promise2((resolve)=>{resume=resolve})}queue.push(kEof)}catch(err){const val=PromiseReject(err);PromisePrototypeCatch(val,onDone),queue.push(val)}finally{var _options$signal3;if(done=!0,next)next(),next=null;options===null||options===void 0||(_options$signal3=options.signal)===null||_options$signal3===void 0||_options$signal3.removeEventListener(\"abort\",abort)}}pump();try{while(!0){while(queue.length>0){const val=await queue[0];if(val===kEof)return;if(signal.aborted)throw new AbortError2;if(val!==kEmpty)yield val;if(queue.shift(),resume)resume(),resume=null}await new Promise2((resolve)=>{next=resolve})}}finally{if(ac.abort(),done=!0,resume)resume(),resume=null}}.call(this)}function asIndexedPairs(options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return async function*asIndexedPairs2(){let index=0;for await(let val of this){var _options$signal4;if(options!==null&&options!==void 0&&(_options$signal4=options.signal)!==null&&_options$signal4!==void 0&&_options$signal4.aborted)throw new AbortError2({cause:options.signal.reason});yield[index++,val]}}.call(this)}async function some(fn,options=void 0){for await(let unused of filter.call(this,fn,options))return!0;return!1}async function every(fn,options=void 0){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);return!await some.call(this,async(...args)=>{return!await fn(...args)},options)}async function find(fn,options){for await(let result of filter.call(this,fn,options))return result;return}async function forEach(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);async function forEachFn(value,options2){return await fn(value,options2),kEmpty}for await(let unused of map.call(this,forEachFn,options));}function filter(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);async function filterFn(value,options2){if(await fn(value,options2))return value;return kEmpty}return map.call(this,filterFn,options)}var ReduceAwareErrMissingArgs=class extends ERR_MISSING_ARGS{constructor(){super(\"reduce\");this.message=\"Reduce of an empty stream requires an initial value\"}};async function reduce(reducer,initialValue,options){var _options$signal5;if(typeof reducer!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"reducer\",[\"Function\",\"AsyncFunction\"],reducer);if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");let hasInitialValue=arguments.length>1;if(options!==null&&options!==void 0&&(_options$signal5=options.signal)!==null&&_options$signal5!==void 0&&_options$signal5.aborted){const err=new AbortError2(void 0,{cause:options.signal.reason});throw this.once(\"error\",()=>{}),await finished2(this.destroy(err)),err}const ac=new AbortController,signal=ac.signal;if(options!==null&&options!==void 0&&options.signal){const opts={once:!0,[kWeakHandler]:this};options.signal.addEventListener(\"abort\",()=>ac.abort(),opts)}let gotAnyItemFromStream=!1;try{for await(let value of this){var _options$signal6;if(gotAnyItemFromStream=!0,options!==null&&options!==void 0&&(_options$signal6=options.signal)!==null&&_options$signal6!==void 0&&_options$signal6.aborted)throw new AbortError2;if(!hasInitialValue)initialValue=value,hasInitialValue=!0;else initialValue=await reducer(initialValue,value,{signal})}if(!gotAnyItemFromStream&&!hasInitialValue)throw new ReduceAwareErrMissingArgs}finally{ac.abort()}return initialValue}async function toArray(options){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");const result=[];for await(let val of this){var _options$signal7;if(options!==null&&options!==void 0&&(_options$signal7=options.signal)!==null&&_options$signal7!==void 0&&_options$signal7.aborted)throw new AbortError2(void 0,{cause:options.signal.reason});ArrayPrototypePush(result,val)}return result}function flatMap(fn,options){const values=map.call(this,fn,options);return async function*flatMap2(){for await(let val of values)yield*val}.call(this)}function toIntegerOrInfinity(number){if(number=Number2(number),NumberIsNaN(number))return 0;if(number<0)throw new ERR_OUT_OF_RANGE(\"number\",\">= 0\",number);return number}function drop(number,options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return number=toIntegerOrInfinity(number),async function*drop2(){var _options$signal8;if(options!==null&&options!==void 0&&(_options$signal8=options.signal)!==null&&_options$signal8!==void 0&&_options$signal8.aborted)throw new AbortError2;for await(let val of this){var _options$signal9;if(options!==null&&options!==void 0&&(_options$signal9=options.signal)!==null&&_options$signal9!==void 0&&_options$signal9.aborted)throw new AbortError2;if(number--<=0)yield val}}.call(this)}function take(number,options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return number=toIntegerOrInfinity(number),async function*take2(){var _options$signal10;if(options!==null&&options!==void 0&&(_options$signal10=options.signal)!==null&&_options$signal10!==void 0&&_options$signal10.aborted)throw new AbortError2;for await(let val of this){var _options$signal11;if(options!==null&&options!==void 0&&(_options$signal11=options.signal)!==null&&_options$signal11!==void 0&&_options$signal11.aborted)throw new AbortError2;if(number-- >0)yield val;else return}}.call(this)}module.exports.streamReturningOperators={asIndexedPairs,drop,filter,flatMap,map,take},module.exports.promiseReturningOperators={every,forEach,reduce,toArray,some,find}}}),require_destroy=__commonJS({\"node_modules/readable-stream/lib/internal/streams/destroy.js\"(exports2,module){var{aggregateTwoErrors,codes:{ERR_MULTIPLE_CALLBACK},AbortError:AbortError2}=require_errors(),{Symbol:Symbol2}=require_primordials(),{kDestroyed,isDestroyed,isFinished,isServerRequest}=require_utils(),kDestroy=\"#kDestroy\",kConstruct=\"#kConstruct\";function checkError(err,w,r){if(err){if(err.stack,w&&!w.errored)w.errored=err;if(r&&!r.errored)r.errored=err}}function destroy2(err,cb){const r=this._readableState,w=this._writableState,s=w||r;if(w&&w.destroyed||r&&r.destroyed){if(typeof cb===\"function\")cb();return this}if(checkError(err,w,r),w)w.destroyed=!0;if(r)r.destroyed=!0;if(!s.constructed)this.once(kDestroy,(er)=>{_destroy(this,aggregateTwoErrors(er,err),cb)});else _destroy(this,err,cb);return this}function _destroy(self,err,cb){let called=!1;function onDestroy(err2){if(called)return;called=!0;const{_readableState:r,_writableState:w}=self;if(checkError(err2,w,r),w)w.closed=!0;if(r)r.closed=!0;if(typeof cb===\"function\")cb(err2);if(err2)runOnNextTick(emitErrorCloseNT,self,err2);else runOnNextTick(emitCloseNT,self)}try{self._destroy(err||null,onDestroy)}catch(err2){onDestroy(err2)}}function emitErrorCloseNT(self,err){emitErrorNT(self,err),emitCloseNT(self)}function emitCloseNT(self){const{_readableState:r,_writableState:w}=self;if(w)w.closeEmitted=!0;if(r)r.closeEmitted=!0;if(w&&w.emitClose||r&&r.emitClose)self.emit(\"close\")}function emitErrorNT(self,err){const r=self\?._readableState,w=self\?._writableState;if(w\?.errorEmitted||r\?.errorEmitted)return;if(w)w.errorEmitted=!0;if(r)r.errorEmitted=!0;self\?.emit\?.(\"error\",err)}function undestroy(){const r=this._readableState,w=this._writableState;if(r)r.constructed=!0,r.closed=!1,r.closeEmitted=!1,r.destroyed=!1,r.errored=null,r.errorEmitted=!1,r.reading=!1,r.ended=r.readable===!1,r.endEmitted=r.readable===!1;if(w)w.constructed=!0,w.destroyed=!1,w.closed=!1,w.closeEmitted=!1,w.errored=null,w.errorEmitted=!1,w.finalCalled=!1,w.prefinished=!1,w.ended=w.writable===!1,w.ending=w.writable===!1,w.finished=w.writable===!1}function errorOrDestroy2(stream,err,sync){const r=stream\?._readableState,w=stream\?._writableState;if(w&&w.destroyed||r&&r.destroyed)return this;if(r&&r.autoDestroy||w&&w.autoDestroy)stream.destroy(err);else if(err){if(Error.captureStackTrace(err),w&&!w.errored)w.errored=err;if(r&&!r.errored)r.errored=err;if(sync)runOnNextTick(emitErrorNT,stream,err);else emitErrorNT(stream,err)}}function construct(stream,cb){if(typeof stream._construct!==\"function\")return;const{_readableState:r,_writableState:w}=stream;if(r)r.constructed=!1;if(w)w.constructed=!1;if(stream.once(kConstruct,cb),stream.listenerCount(kConstruct)>1)return;runOnNextTick(constructNT,stream)}function constructNT(stream){let called=!1;function onConstruct(err){if(called){errorOrDestroy2(stream,err!==null&&err!==void 0\?err:new ERR_MULTIPLE_CALLBACK);return}called=!0;const{_readableState:r,_writableState:w}=stream,s=w||r;if(r)r.constructed=!0;if(w)w.constructed=!0;if(s.destroyed)stream.emit(kDestroy,err);else if(err)errorOrDestroy2(stream,err,!0);else runOnNextTick(emitConstructNT,stream)}try{stream._construct(onConstruct)}catch(err){onConstruct(err)}}function emitConstructNT(stream){stream.emit(kConstruct)}function isRequest(stream){return stream&&stream.setHeader&&typeof stream.abort===\"function\"}function emitCloseLegacy(stream){stream.emit(\"close\")}function emitErrorCloseLegacy(stream,err){stream.emit(\"error\",err),runOnNextTick(emitCloseLegacy,stream)}function destroyer(stream,err){if(!stream||isDestroyed(stream))return;if(!err&&!isFinished(stream))err=new AbortError2;if(isServerRequest(stream))stream.socket=null,stream.destroy(err);else if(isRequest(stream))stream.abort();else if(isRequest(stream.req))stream.req.abort();else if(typeof stream.destroy===\"function\")stream.destroy(err);else if(typeof stream.close===\"function\")stream.close();else if(err)runOnNextTick(emitErrorCloseLegacy,stream);else runOnNextTick(emitCloseLegacy,stream);if(!stream.destroyed)stream[kDestroyed]=!0}module.exports={construct,destroyer,destroy:destroy2,undestroy,errorOrDestroy:errorOrDestroy2}}}),require_legacy=__commonJS({\"node_modules/readable-stream/lib/internal/streams/legacy.js\"(exports2,module){var{ArrayIsArray:ArrayIsArray2,ObjectSetPrototypeOf}=require_primordials();function Stream(options){if(!(this instanceof Stream))return new Stream(options);EE.call(this,options)}Stream.prototype={},ObjectSetPrototypeOf(Stream.prototype,EE.prototype),ObjectSetPrototypeOf(Stream,EE),Stream.prototype.pipe=function(dest,options){const source=this;function ondata(chunk){if(dest.writable&&dest.write(chunk)===!1&&source.pause)source.pause()}source.on(\"data\",ondata);function ondrain(){if(source.readable&&source.resume)source.resume()}if(dest.on(\"drain\",ondrain),!dest._isStdio&&(!options||options.end!==!1))source.on(\"end\",onend),source.on(\"close\",onclose);let didOnEnd=!1;function onend(){if(didOnEnd)return;didOnEnd=!0,dest.end()}function onclose(){if(didOnEnd)return;if(didOnEnd=!0,typeof dest.destroy===\"function\")dest.destroy()}function onerror(er){if(cleanup(),EE.listenerCount(this,\"error\")===0)this.emit(\"error\",er)}prependListener(source,\"error\",onerror),prependListener(dest,\"error\",onerror);function cleanup(){source.removeListener(\"data\",ondata),dest.removeListener(\"drain\",ondrain),source.removeListener(\"end\",onend),source.removeListener(\"close\",onclose),source.removeListener(\"error\",onerror),dest.removeListener(\"error\",onerror),source.removeListener(\"end\",cleanup),source.removeListener(\"close\",cleanup),dest.removeListener(\"close\",cleanup)}return source.on(\"end\",cleanup),source.on(\"close\",cleanup),dest.on(\"close\",cleanup),dest.emit(\"pipe\",source),dest};function prependListener(emitter,event,fn){if(typeof emitter.prependListener===\"function\")return emitter.prependListener(event,fn);if(!emitter._events||!emitter._events[event])emitter.on(event,fn);else if(ArrayIsArray2(emitter._events[event]))emitter._events[event].unshift(fn);else emitter._events[event]=[fn,emitter._events[event]]}module.exports={Stream,prependListener}}}),require_add_abort_signal=__commonJS({\"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js\"(exports2,module){var{AbortError:AbortError2,codes}=require_errors(),eos=require_end_of_stream(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2}=codes,validateAbortSignal=(signal,name)=>{if(typeof signal!==\"object\"||!(\"aborted\"in signal))throw new ERR_INVALID_ARG_TYPE2(name,\"AbortSignal\",signal)};function isNodeStream(obj){return!!(obj&&typeof obj.pipe===\"function\")}module.exports.addAbortSignal=function addAbortSignal(signal,stream){if(validateAbortSignal(signal,\"signal\"),!isNodeStream(stream))throw new ERR_INVALID_ARG_TYPE2(\"stream\",\"stream.Stream\",stream);return module.exports.addAbortSignalNoValidate(signal,stream)},module.exports.addAbortSignalNoValidate=function(signal,stream){if(typeof signal!==\"object\"||!(\"aborted\"in signal))return stream;const onAbort=()=>{stream.destroy(new AbortError2(void 0,{cause:signal.reason}))};if(signal.aborted)onAbort();else signal.addEventListener(\"abort\",onAbort),eos(stream,()=>signal.removeEventListener(\"abort\",onAbort));return stream}}}),require_state=__commonJS({\"node_modules/readable-stream/lib/internal/streams/state.js\"(exports2,module){var{MathFloor,NumberIsInteger}=require_primordials(),{ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2}=require_errors().codes;function highWaterMarkFrom(options,isDuplex,duplexKey){return options.highWaterMark!=null\?options.highWaterMark:isDuplex\?options[duplexKey]:null}function getDefaultHighWaterMark(objectMode){return objectMode\?16:16384}function getHighWaterMark(state,options,duplexKey,isDuplex){const hwm=highWaterMarkFrom(options,isDuplex,duplexKey);if(hwm!=null){if(!NumberIsInteger(hwm)||hwm<0){const name=isDuplex\?`options.${duplexKey}`:\"options.highWaterMark\";throw new ERR_INVALID_ARG_VALUE2(name,hwm)}return MathFloor(hwm)}return getDefaultHighWaterMark(state.objectMode)}module.exports={getHighWaterMark,getDefaultHighWaterMark}}}),require_from=__commonJS({\"node_modules/readable-stream/lib/internal/streams/from.js\"(exports2,module){var{PromisePrototypeThen,SymbolAsyncIterator,SymbolIterator}=require_primordials(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_STREAM_NULL_VALUES}=require_errors().codes;function from(Readable,iterable,opts){let iterator;if(typeof iterable===\"string\"||iterable instanceof Buffer)return new Readable({objectMode:!0,...opts,read(){this.push(iterable),this.push(null)}});let isAsync;if(iterable&&iterable[SymbolAsyncIterator])isAsync=!0,iterator=iterable[SymbolAsyncIterator]();else if(iterable&&iterable[SymbolIterator])isAsync=!1,iterator=iterable[SymbolIterator]();else throw new ERR_INVALID_ARG_TYPE2(\"iterable\",[\"Iterable\"],iterable);const readable=new Readable({objectMode:!0,highWaterMark:1,...opts});let reading=!1;readable._read=function(){if(!reading)reading=!0,next()},readable._destroy=function(error,cb){PromisePrototypeThen(close(error),()=>runOnNextTick(cb,error),(e)=>runOnNextTick(cb,e||error))};async function close(error){const hadError=error!==void 0&&error!==null,hasThrow=typeof iterator.throw===\"function\";if(hadError&&hasThrow){const{value,done}=await iterator.throw(error);if(await value,done)return}if(typeof iterator.return===\"function\"){const{value}=await iterator.return();await value}}async function next(){for(;;){try{const{value,done}=isAsync\?await iterator.next():iterator.next();if(done)readable.push(null);else{const res=value&&typeof value.then===\"function\"\?await value:value;if(res===null)throw reading=!1,new ERR_STREAM_NULL_VALUES;else if(readable.push(res))continue;else reading=!1}}catch(err){readable.destroy(err)}break}}return readable}module.exports=from}}),_ReadableFromWeb,_ReadableFromWebForUndici,require_readable=__commonJS({\"node_modules/readable-stream/lib/internal/streams/readable.js\"(exports2,module){var{ArrayPrototypeIndexOf,NumberIsInteger,NumberIsNaN,NumberParseInt,ObjectDefineProperties,ObjectKeys,ObjectSetPrototypeOf,Promise:Promise2,SafeSet,SymbolAsyncIterator,Symbol:Symbol2}=require_primordials(),ReadableState=globalThis[globalThis.Symbol.for('Bun.lazy')](\"bun:stream\").ReadableState,{Stream,prependListener}=require_legacy();function Readable(options){if(!(this instanceof Readable))return new Readable(options);const isDuplex=this instanceof require_duplex();if(this._readableState=new ReadableState(options,this,isDuplex),options){const{read,destroy:destroy2,construct,signal}=options;if(typeof read===\"function\")this._read=read;if(typeof destroy2===\"function\")this._destroy=destroy2;if(typeof construct===\"function\")this._construct=construct;if(signal&&!isDuplex)addAbortSignal(signal,this)}Stream.call(this,options),destroyImpl.construct(this,()=>{if(this._readableState.needReadable)maybeReadMore(this,this._readableState)})}Readable.prototype={},ObjectSetPrototypeOf(Readable.prototype,Stream.prototype),ObjectSetPrototypeOf(Readable,Stream),Readable.prototype.on=function(ev,fn){const res=Stream.prototype.on.call(this,ev,fn),state=this._readableState;if(ev===\"data\"){if(state.readableListening=this.listenerCount(\"readable\")>0,state.flowing!==!1)this.resume()}else if(ev===\"readable\"){if(!state.endEmitted&&!state.readableListening){if(state.readableListening=state.needReadable=!0,state.flowing=!1,state.emittedReadable=!1,state.length)emitReadable(this,state);else if(!state.reading)runOnNextTick(nReadingNextTick,this)}else if(state.endEmitted);}return res};class ReadableFromWeb extends Readable{#reader;#closed;#pendingChunks;#stream;constructor(options,stream){const{objectMode,highWaterMark,encoding,signal}=options;super({objectMode,highWaterMark,encoding,signal});this.#pendingChunks=[],this.#reader=void 0,this.#stream=stream,this.#closed=!1}#drainPending(){var pendingChunks=this.#pendingChunks,pendingChunksI=0,pendingChunksCount=pendingChunks.length;for(;pendingChunksI0)this.#pendingChunks=[];return!1}#handleDone(reader){reader.releaseLock(),this.#reader=void 0,this.#closed=!0,this.push(null);return}async _read(){var stream=this.#stream,reader=this.#reader;if(stream)reader=this.#reader=stream.getReader(),this.#stream=void 0;else if(this.#drainPending())return;var deferredError;try{do{var done=!1,value;const firstResult=reader.readMany();if(@isPromise(firstResult)){if({done,value}=await firstResult,this.#closed){this.#pendingChunks.push(...value);return}}else({done,value}=firstResult);if(done){this.#handleDone(reader);return}if(!this.push(value[0])){this.#pendingChunks=value.slice(1);return}for(let i=1,count=value.length;i{this.#closed=!0,callback(error)});return}try{callback(error)}catch(error2){globalThis.reportError(error2)}}}_ReadableFromWebForUndici=ReadableFromWeb;function newStreamReadableFromReadableStream(readableStream,options={}){if(!isReadableStream(readableStream))throw new ERR_INVALID_ARG_TYPE2(\"readableStream\",\"ReadableStream\",readableStream);validateObject2(options,\"options\");const{highWaterMark,encoding,objectMode=!1,signal}=options;if(encoding!==void 0&&!Buffer.isEncoding(encoding))throw new ERR_INVALID_ARG_VALUE(encoding,\"options.encoding\");return validateBoolean(objectMode,\"options.objectMode\"),getNativeReadableStream(Readable,readableStream,options)||new ReadableFromWeb({highWaterMark,encoding,objectMode,signal},readableStream)}module.exports=Readable,_ReadableFromWeb=newStreamReadableFromReadableStream;var{addAbortSignal}=require_add_abort_signal(),eos=require_end_of_stream();const{maybeReadMore:_maybeReadMore,resume,emitReadable:_emitReadable,onEofChunk}=globalThis[globalThis.Symbol.for('Bun.lazy')](\"bun:stream\");function maybeReadMore(stream,state){process.nextTick(_maybeReadMore,stream,state)}function emitReadable(stream,state){_emitReadable(stream,state)}var destroyImpl=require_destroy(),{aggregateTwoErrors,codes:{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_METHOD_NOT_IMPLEMENTED,ERR_OUT_OF_RANGE,ERR_STREAM_PUSH_AFTER_EOF,ERR_STREAM_UNSHIFT_AFTER_END_EVENT}}=require_errors(),{validateObject:validateObject2}=require_validators(),from=require_from(),nop=()=>{},{errorOrDestroy:errorOrDestroy2}=destroyImpl;Readable.prototype.destroy=destroyImpl.destroy,Readable.prototype._undestroy=destroyImpl.undestroy,Readable.prototype._destroy=function(err,cb){cb(err)},Readable.prototype[EE.captureRejectionSymbol]=function(err){this.destroy(err)},Readable.prototype.push=function(chunk,encoding){return readableAddChunk(this,chunk,encoding,!1)},Readable.prototype.unshift=function(chunk,encoding){return readableAddChunk(this,chunk,encoding,!0)};function readableAddChunk(stream,chunk,encoding,addToFront){const state=stream._readableState;let err;if(!state.objectMode){if(typeof chunk===\"string\"){if(encoding=encoding||state.defaultEncoding,state.encoding!==encoding)if(addToFront&&state.encoding)chunk=Buffer.from(chunk,encoding).toString(state.encoding);else chunk=Buffer.from(chunk,encoding),encoding=\"\"}else if(chunk instanceof Buffer)encoding=\"\";else if(Stream._isUint8Array(chunk)){if(addToFront||!state.decoder)chunk=Stream._uint8ArrayToBuffer(chunk);encoding=\"\"}else if(chunk!=null)err=new ERR_INVALID_ARG_TYPE2(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],chunk)}if(err)errorOrDestroy2(stream,err);else if(chunk===null)state.reading=!1,onEofChunk(stream,state);else if(state.objectMode||chunk&&chunk.length>0)if(addToFront)if(state.endEmitted)errorOrDestroy2(stream,new ERR_STREAM_UNSHIFT_AFTER_END_EVENT);else if(state.destroyed||state.errored)return!1;else addChunk(stream,state,chunk,!0);else if(state.ended)errorOrDestroy2(stream,new ERR_STREAM_PUSH_AFTER_EOF);else if(state.destroyed||state.errored)return!1;else if(state.reading=!1,state.decoder&&!encoding)if(chunk=state.decoder.write(chunk),state.objectMode||chunk.length!==0)addChunk(stream,state,chunk,!1);else maybeReadMore(stream,state);else addChunk(stream,state,chunk,!1);else if(!addToFront)state.reading=!1,maybeReadMore(stream,state);return!state.ended&&(state.length0){if(state.multiAwaitDrain)state.awaitDrainWriters.clear();else state.awaitDrainWriters=null;state.dataEmitted=!0,stream.emit(\"data\",chunk)}else{if(state.length+=state.objectMode\?1:chunk.length,addToFront)state.buffer.unshift(chunk);else state.buffer.push(chunk);if(state.needReadable)emitReadable(stream,state)}maybeReadMore(stream,state)}Readable.prototype.isPaused=function(){const state=this._readableState;return state.paused===!0||state.flowing===!1},Readable.prototype.setEncoding=function(enc){const decoder=new StringDecoder(enc);this._readableState.decoder=decoder,this._readableState.encoding=this._readableState.decoder.encoding;const buffer=this._readableState.buffer;let content=\"\";for(let i=buffer.length;i>0;i--)content+=decoder.write(buffer.shift());if(content!==\"\")buffer.push(content);return this._readableState.length=content.length,this};var MAX_HWM=1073741824;function computeNewHighWaterMark(n){if(n>MAX_HWM)throw new ERR_OUT_OF_RANGE(\"size\",\"<= 1GiB\",n);else n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++;return n}function howMuchToRead(n,state){if(n<=0||state.length===0&&state.ended)return 0;if(state.objectMode)return 1;if(NumberIsNaN(n)){if(state.flowing&&state.length)return state.buffer.first().length;return state.length}if(n<=state.length)return n;return state.ended\?state.length:0}Readable.prototype.read=function(n){if(!NumberIsInteger(n))n=NumberParseInt(n,10);const state=this._readableState,nOrig=n;if(n>state.highWaterMark)state.highWaterMark=computeNewHighWaterMark(n);if(n!==0)state.emittedReadable=!1;if(n===0&&state.needReadable&&((state.highWaterMark!==0\?state.length>=state.highWaterMark:state.length>0)||state.ended)){if(state.length===0&&state.ended)endReadable(this);else emitReadable(this,state);return null}if(n=howMuchToRead(n,state),n===0&&state.ended){if(state.length===0)endReadable(this);return null}let doRead=state.needReadable;if(state.length===0||state.length-n0)ret=fromList(n,state);else ret=null;if(ret===null)state.needReadable=state.length<=state.highWaterMark,n=0;else if(state.length-=n,state.multiAwaitDrain)state.awaitDrainWriters.clear();else state.awaitDrainWriters=null;if(state.length===0){if(!state.ended)state.needReadable=!0;if(nOrig!==n&&state.ended)endReadable(this)}if(ret!==null&&!state.errorEmitted&&!state.closeEmitted)state.dataEmitted=!0,this.emit(\"data\",ret);return ret},Readable.prototype._read=function(n){throw new ERR_METHOD_NOT_IMPLEMENTED(\"_read()\")},Readable.prototype.pipe=function(dest,pipeOpts){const src=this,state=this._readableState;if(state.pipes.length===1){if(!state.multiAwaitDrain)state.multiAwaitDrain=!0,state.awaitDrainWriters=new SafeSet(state.awaitDrainWriters\?[state.awaitDrainWriters]:[])}state.pipes.push(dest);const endFn=(!pipeOpts||pipeOpts.end!==!1)&&dest!==process.stdout&&dest!==process.stderr\?onend:unpipe;if(state.endEmitted)runOnNextTick(endFn);else src.once(\"end\",endFn);dest.on(\"unpipe\",onunpipe);function onunpipe(readable,unpipeInfo){if(readable===src){if(unpipeInfo&&unpipeInfo.hasUnpiped===!1)unpipeInfo.hasUnpiped=!0,cleanup()}}function onend(){dest.end()}let ondrain,cleanedUp=!1;function cleanup(){if(dest.removeListener(\"close\",onclose),dest.removeListener(\"finish\",onfinish),ondrain)dest.removeListener(\"drain\",ondrain);if(dest.removeListener(\"error\",onerror),dest.removeListener(\"unpipe\",onunpipe),src.removeListener(\"end\",onend),src.removeListener(\"end\",unpipe),src.removeListener(\"data\",ondata),cleanedUp=!0,ondrain&&state.awaitDrainWriters&&(!dest._writableState||dest._writableState.needDrain))ondrain()}function pause(){if(!cleanedUp){if(state.pipes.length===1&&state.pipes[0]===dest)state.awaitDrainWriters=dest,state.multiAwaitDrain=!1;else if(state.pipes.length>1&&state.pipes.includes(dest))state.awaitDrainWriters.add(dest);src.pause()}if(!ondrain)ondrain=pipeOnDrain(src,dest),dest.on(\"drain\",ondrain)}src.on(\"data\",ondata);function ondata(chunk){if(dest.write(chunk)===!1)pause()}function onerror(er){if(unpipe(),dest.removeListener(\"error\",onerror),dest.listenerCount(\"error\")===0){const s=dest._writableState||dest._readableState;if(s&&!s.errorEmitted)errorOrDestroy2(dest,er);else dest.emit(\"error\",er)}}prependListener(dest,\"error\",onerror);function onclose(){dest.removeListener(\"finish\",onfinish),unpipe()}dest.once(\"close\",onclose);function onfinish(){dest.removeListener(\"close\",onclose),unpipe()}dest.once(\"finish\",onfinish);function unpipe(){src.unpipe(dest)}if(dest.emit(\"pipe\",src),dest.writableNeedDrain===!0){if(state.flowing)pause()}else if(!state.flowing)src.resume();return dest};function pipeOnDrain(src,dest){return function pipeOnDrainFunctionResult(){const state=src._readableState;if(state.awaitDrainWriters===dest)state.awaitDrainWriters=null;else if(state.multiAwaitDrain)state.awaitDrainWriters.delete(dest);if((!state.awaitDrainWriters||state.awaitDrainWriters.size===0)&&src.listenerCount(\"data\"))src.resume()}}Readable.prototype.unpipe=function(dest){const state=this._readableState,unpipeInfo={hasUnpiped:!1};if(state.pipes.length===0)return this;if(!dest){const dests=state.pipes;state.pipes=[],this.pause();for(let i=0;i0,state.resumeScheduled&&state.paused===!1)state.flowing=!0;else if(self.listenerCount(\"data\")>0)self.resume();else if(!state.readableListening)state.flowing=null}function nReadingNextTick(self){self.read(0)}Readable.prototype.resume=function(){const state=this._readableState;if(!state.flowing)state.flowing=!state.readableListening,resume(this,state);return state.paused=!1,this},Readable.prototype.pause=function(){if(this._readableState.flowing!==!1)this._readableState.flowing=!1,this.emit(\"pause\");return this._readableState.paused=!0,this},Readable.prototype.wrap=function(stream){let paused=!1;stream.on(\"data\",(chunk)=>{if(!this.push(chunk)&&stream.pause)paused=!0,stream.pause()}),stream.on(\"end\",()=>{this.push(null)}),stream.on(\"error\",(err)=>{errorOrDestroy2(this,err)}),stream.on(\"close\",()=>{this.destroy()}),stream.on(\"destroy\",()=>{this.destroy()}),this._read=()=>{if(paused&&stream.resume)paused=!1,stream.resume()};const streamKeys=ObjectKeys(stream);for(let j=1;j{error=err\?aggregateTwoErrors(error,err):null,callback(),callback=nop});try{while(!0){const chunk=stream.destroyed\?null:stream.read();if(chunk!==null)yield chunk;else if(error)throw error;else if(error===null)return;else await new Promise2(next)}}catch(err){throw error=aggregateTwoErrors(error,err),error}finally{if((error||(options===null||options===void 0\?void 0:options.destroyOnReturn)!==!1)&&(error===void 0||stream._readableState.autoDestroy))destroyImpl.destroyer(stream,null);else stream.off(\"readable\",next),cleanup()}}ObjectDefineProperties(Readable.prototype,{readable:{get(){const r=this._readableState;return!!r&&r.readable!==!1&&!r.destroyed&&!r.errorEmitted&&!r.endEmitted},set(val){if(this._readableState)this._readableState.readable=!!val}},readableDidRead:{enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{enumerable:!1,get:function(){return this._readableState.flowing},set:function(state){if(this._readableState)this._readableState.flowing=state}},readableLength:{enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{enumerable:!1,get(){return this._readableState\?this._readableState.objectMode:!1}},readableEncoding:{enumerable:!1,get(){return this._readableState\?this._readableState.encoding:null}},errored:{enumerable:!1,get(){return this._readableState\?this._readableState.errored:null}},closed:{get(){return this._readableState\?this._readableState.closed:!1}},destroyed:{enumerable:!1,get(){return this._readableState\?this._readableState.destroyed:!1},set(value){if(!this._readableState)return;this._readableState.destroyed=value}},readableEnded:{enumerable:!1,get(){return this._readableState\?this._readableState.endEmitted:!1}}}),Readable._fromList=fromList;function fromList(n,state){if(state.length===0)return null;let ret;if(state.objectMode)ret=state.buffer.shift();else if(!n||n>=state.length){if(state.decoder)ret=state.buffer.join(\"\");else if(state.buffer.length===1)ret=state.buffer.first();else ret=state.buffer.concat(state.length);state.buffer.clear()}else ret=state.buffer.consume(n,state.decoder);return ret}function endReadable(stream){const state=stream._readableState;if(!state.endEmitted)state.ended=!0,runOnNextTick(endReadableNT,state,stream)}function endReadableNT(state,stream){if(!state.errored&&!state.closeEmitted&&!state.endEmitted&&state.length===0){if(state.endEmitted=!0,stream.emit(\"end\"),stream.writable&&stream.allowHalfOpen===!1)runOnNextTick(endWritableNT,stream);else if(state.autoDestroy){const wState=stream._writableState;if(!wState||wState.autoDestroy&&(wState.finished||wState.writable===!1))stream.destroy()}}}function endWritableNT(stream){if(stream.writable&&!stream.writableEnded&&!stream.destroyed)stream.end()}Readable.from=function(iterable,opts){return from(Readable,iterable,opts)};var webStreamsAdapters={newStreamReadableFromReadableStream,newReadableStreamFromStreamReadable(streamReadable,options={}){if(typeof streamReadable\?._readableState!==\"object\")throw new ERR_INVALID_ARG_TYPE2(\"streamReadable\",\"stream.Readable\",streamReadable);var{isDestroyed,isReadable}=require_utils();if(isDestroyed(streamReadable)||!isReadable(streamReadable)){const readable=new ReadableStream;return readable.cancel(),readable}const{readableObjectMode:objectMode,readableHighWaterMark:highWaterMark}=streamReadable,strategy=((strategy2)=>{if(strategy2)return strategy2;if(objectMode)return new CountQueuingStrategy({highWaterMark});return{highWaterMark}})(options\?.strategy);let controller;function onData(chunk){if(controller.enqueue(chunk),controller.desiredSize<=0)streamReadable.pause()}streamReadable.pause();const cleanup=finished(streamReadable,(error)=>{if(error\?.code===\"ERR_STREAM_PREMATURE_CLOSE\")error=new AbortError(void 0,{cause:error});if(cleanup(),streamReadable.on(\"error\",()=>{}),error)return controller.error(error);controller.close()});return streamReadable.on(\"data\",onData),new ReadableStream({start(c){controller=c},pull(){streamReadable.resume()},cancel(reason){destroy(streamReadable,reason)}},strategy)}};Readable.fromWeb=function(readableStream,options){return webStreamsAdapters.newStreamReadableFromReadableStream(readableStream,options)},Readable.toWeb=function(streamReadable,options){return webStreamsAdapters.newReadableStreamFromStreamReadable(streamReadable,options)},Readable.wrap=function(src,options){var _ref,_src$readableObjectMo;return new Readable({objectMode:(_ref=(_src$readableObjectMo=src.readableObjectMode)!==null&&_src$readableObjectMo!==void 0\?_src$readableObjectMo:src.objectMode)!==null&&_ref!==void 0\?_ref:!0,...options,destroy(err,callback){destroyImpl.destroyer(src,err),callback(err)}}).wrap(src)}}}),require_writable=__commonJS({\"node_modules/readable-stream/lib/internal/streams/writable.js\"(exports2,module){var{ArrayPrototypeSlice,Error:Error2,FunctionPrototypeSymbolHasInstance,ObjectDefineProperty,ObjectDefineProperties,ObjectSetPrototypeOf,StringPrototypeToLowerCase,Symbol:Symbol2,SymbolHasInstance}=require_primordials(),Stream=require_legacy().Stream,destroyImpl=require_destroy(),{addAbortSignal}=require_add_abort_signal(),{getHighWaterMark,getDefaultHighWaterMark}=require_state(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_METHOD_NOT_IMPLEMENTED,ERR_MULTIPLE_CALLBACK,ERR_STREAM_CANNOT_PIPE,ERR_STREAM_DESTROYED,ERR_STREAM_ALREADY_FINISHED,ERR_STREAM_NULL_VALUES,ERR_STREAM_WRITE_AFTER_END,ERR_UNKNOWN_ENCODING}=require_errors().codes,{errorOrDestroy:errorOrDestroy2}=destroyImpl;function Writable2(options={}){const isDuplex=this instanceof require_duplex();if(!isDuplex&&!FunctionPrototypeSymbolHasInstance(Writable2,this))return new Writable2(options);if(this._writableState=new WritableState(options,this,isDuplex),options){if(typeof options.write===\"function\")this._write=options.write;if(typeof options.writev===\"function\")this._writev=options.writev;if(typeof options.destroy===\"function\")this._destroy=options.destroy;if(typeof options.final===\"function\")this._final=options.final;if(typeof options.construct===\"function\")this._construct=options.construct;if(options.signal)addAbortSignal(options.signal,this)}Stream.call(this,options),destroyImpl.construct(this,()=>{const state=this._writableState;if(!state.writing)clearBuffer(this,state);finishMaybe(this,state)})}Writable2.prototype={},ObjectSetPrototypeOf(Writable2.prototype,Stream.prototype),ObjectSetPrototypeOf(Writable2,Stream),module.exports=Writable2;function nop(){}var kOnFinished=Symbol2(\"kOnFinished\");function WritableState(options,stream,isDuplex){if(typeof isDuplex!==\"boolean\")isDuplex=stream instanceof require_duplex();if(this.objectMode=!!(options&&options.objectMode),isDuplex)this.objectMode=this.objectMode||!!(options&&options.writableObjectMode);this.highWaterMark=options\?getHighWaterMark(this,options,\"writableHighWaterMark\",isDuplex):getDefaultHighWaterMark(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const noDecode=!!(options&&options.decodeStrings===!1);this.decodeStrings=!noDecode,this.defaultEncoding=options&&options.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=onwrite.bind(void 0,stream),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,resetBuffer(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!options||options.emitClose!==!1,this.autoDestroy=!options||options.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[kOnFinished]=[]}WritableState.prototype={};function resetBuffer(state){state.buffered=[],state.bufferedIndex=0,state.allBuffers=!0,state.allNoop=!0}WritableState.prototype.getBuffer=function getBuffer(){return ArrayPrototypeSlice(this.buffered,this.bufferedIndex)},ObjectDefineProperty(WritableState.prototype,\"bufferedRequestCount\",{get(){return this.buffered.length-this.bufferedIndex}}),ObjectDefineProperty(Writable2,SymbolHasInstance,{value:function(object){if(FunctionPrototypeSymbolHasInstance(this,object))return!0;if(this!==Writable2)return!1;return object&&object._writableState instanceof WritableState}}),Writable2.prototype.pipe=function(){errorOrDestroy2(this,new ERR_STREAM_CANNOT_PIPE)};function _write(stream,chunk,encoding,cb){const state=stream._writableState;if(typeof encoding===\"function\")cb=encoding,encoding=state.defaultEncoding;else{if(!encoding)encoding=state.defaultEncoding;else if(encoding!==\"buffer\"&&!Buffer.isEncoding(encoding))throw new ERR_UNKNOWN_ENCODING(encoding);if(typeof cb!==\"function\")cb=nop}if(chunk===null)throw new ERR_STREAM_NULL_VALUES;else if(!state.objectMode)if(typeof chunk===\"string\"){if(state.decodeStrings!==!1)chunk=Buffer.from(chunk,encoding),encoding=\"buffer\"}else if(chunk instanceof Buffer)encoding=\"buffer\";else if(Stream._isUint8Array(chunk))chunk=Stream._uint8ArrayToBuffer(chunk),encoding=\"buffer\";else throw new ERR_INVALID_ARG_TYPE2(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],chunk);let err;if(state.ending)err=new ERR_STREAM_WRITE_AFTER_END;else if(state.destroyed)err=new ERR_STREAM_DESTROYED(\"write\");if(err)return runOnNextTick(cb,err),errorOrDestroy2(stream,err,!0),err;return state.pendingcb++,writeOrBuffer(stream,state,chunk,encoding,cb)}Writable2.prototype.write=function(chunk,encoding,cb){return _write(this,chunk,encoding,cb)===!0},Writable2.prototype.cork=function(){this._writableState.corked++},Writable2.prototype.uncork=function(){const state=this._writableState;if(state.corked){if(state.corked--,!state.writing)clearBuffer(this,state)}},Writable2.prototype.setDefaultEncoding=function setDefaultEncoding(encoding){if(typeof encoding===\"string\")encoding=StringPrototypeToLowerCase(encoding);if(!Buffer.isEncoding(encoding))throw new ERR_UNKNOWN_ENCODING(encoding);return this._writableState.defaultEncoding=encoding,this};function writeOrBuffer(stream,state,chunk,encoding,callback){const len=state.objectMode\?1:chunk.length;state.length+=len;const ret=state.lengthstate.bufferedIndex)clearBuffer(stream,state);if(sync)if(state.afterWriteTickInfo!==null&&state.afterWriteTickInfo.cb===cb)state.afterWriteTickInfo.count++;else state.afterWriteTickInfo={count:1,cb,stream,state},runOnNextTick(afterWriteTick,state.afterWriteTickInfo);else afterWrite(stream,state,1,cb)}}function afterWriteTick({stream,state,count,cb}){return state.afterWriteTickInfo=null,afterWrite(stream,state,count,cb)}function afterWrite(stream,state,count,cb){if(!state.ending&&!stream.destroyed&&state.length===0&&state.needDrain)state.needDrain=!1,stream.emit(\"drain\");while(count-- >0)state.pendingcb--,cb();if(state.destroyed)errorBuffer(state);finishMaybe(stream,state)}function errorBuffer(state){if(state.writing)return;for(let n=state.bufferedIndex;n1&&stream._writev){state.pendingcb-=bufferedLength-1;const callback=state.allNoop\?nop:(err)=>{for(let n=i;n256)buffered.splice(0,i),state.bufferedIndex=0;else state.bufferedIndex=i}state.bufferProcessing=!1}Writable2.prototype._write=function(chunk,encoding,cb){if(this._writev)this._writev([{chunk,encoding}],cb);else throw new ERR_METHOD_NOT_IMPLEMENTED(\"_write()\")},Writable2.prototype._writev=null,Writable2.prototype.end=function(chunk,encoding,cb,native=!1){const state=this._writableState;if(typeof chunk===\"function\")cb=chunk,chunk=null,encoding=null;else if(typeof encoding===\"function\")cb=encoding,encoding=null;let err;if(chunk!==null&&chunk!==void 0){let ret;if(!native)ret=_write(this,chunk,encoding);else ret=this.write(chunk,encoding);if(ret instanceof Error2)err=ret}if(state.corked)state.corked=1,this.uncork();if(err)this.emit(\"error\",err);else if(!state.errored&&!state.ending)state.ending=!0,finishMaybe(this,state,!0),state.ended=!0;else if(state.finished)err=new ERR_STREAM_ALREADY_FINISHED(\"end\");else if(state.destroyed)err=new ERR_STREAM_DESTROYED(\"end\");if(typeof cb===\"function\")if(err||state.finished)runOnNextTick(cb,err);else state[kOnFinished].push(cb);return this};function needFinish(state,tag){var needFinish2=state.ending&&!state.destroyed&&state.constructed&&state.length===0&&!state.errored&&state.buffered.length===0&&!state.finished&&!state.writing&&!state.errorEmitted&&!state.closeEmitted;return needFinish2}function callFinal(stream,state){let called=!1;function onFinish(err){if(called){errorOrDestroy2(stream,err!==null&&err!==void 0\?err:ERR_MULTIPLE_CALLBACK());return}if(called=!0,state.pendingcb--,err){const onfinishCallbacks=state[kOnFinished].splice(0);for(let i=0;i{if(needFinish(state2))finish(stream2,state2);else state2.pendingcb--},stream,state);else if(needFinish(state))state.pendingcb++,finish(stream,state)}}function finish(stream,state){state.pendingcb--,state.finished=!0;const onfinishCallbacks=state[kOnFinished].splice(0);for(let i=0;i{if(val!=null)throw new ERR_INVALID_RETURN_VALUE(\"nully\",\"body\",val)},(err)=>{destroyer(d,err)});return d=new Duplexify({objectMode:!0,readable:!1,write,final(cb){final(async()=>{try{await promise,runOnNextTick(cb,null)}catch(err){runOnNextTick(cb,err)}})},destroy:destroy2})}throw new ERR_INVALID_RETURN_VALUE(\"Iterable, AsyncIterable or AsyncFunction\",name,value)}if(isBlob(body))return duplexify(body.arrayBuffer());if(isIterable(body))return from(Duplexify,body,{objectMode:!0,writable:!1});if(typeof(body===null||body===void 0\?void 0:body.writable)===\"object\"||typeof(body===null||body===void 0\?void 0:body.readable)===\"object\"){const readable=body!==null&&body!==void 0&&body.readable\?isReadableNodeStream(body===null||body===void 0\?void 0:body.readable)\?body===null||body===void 0\?void 0:body.readable:duplexify(body.readable):void 0,writable=body!==null&&body!==void 0&&body.writable\?isWritableNodeStream(body===null||body===void 0\?void 0:body.writable)\?body===null||body===void 0\?void 0:body.writable:duplexify(body.writable):void 0;return _duplexify({readable,writable})}const then=body===null||body===void 0\?void 0:body.then;if(typeof then===\"function\"){let d;return FunctionPrototypeCall(then,body,(val)=>{if(val!=null)d.push(val);d.push(null)},(err)=>{destroyer(d,err)}),d=new Duplexify({objectMode:!0,writable:!1,read(){}})}throw new ERR_INVALID_ARG_TYPE2(name,[\"Blob\",\"ReadableStream\",\"WritableStream\",\"Stream\",\"Iterable\",\"AsyncIterable\",\"Function\",\"{ readable, writable } pair\",\"Promise\"],body)};function fromAsyncGen(fn){let{promise,resolve}=createDeferredPromise();const ac=new AbortController,signal=ac.signal;return{value:fn(async function*(){while(!0){const _promise=promise;promise=null;const{chunk,done,cb}=await _promise;if(runOnNextTick(cb),done)return;if(signal.aborted)throw new AbortError2(void 0,{cause:signal.reason});({promise,resolve}=createDeferredPromise()),yield chunk}}(),{signal}),write(chunk,encoding,cb){const _resolve=resolve;resolve=null,_resolve({chunk,done:!1,cb})},final(cb){const _resolve=resolve;resolve=null,_resolve({done:!0,cb})},destroy(err,cb){ac.abort(),cb(err)}}}function _duplexify(pair){const r=pair.readable&&typeof pair.readable.read!==\"function\"\?Readable.wrap(pair.readable):pair.readable,w=pair.writable;let readable=!!isReadable(r),writable=!!isWritable(w),ondrain,onfinish,onreadable,onclose,d;function onfinished(err){const cb=onclose;if(onclose=null,cb)cb(err);else if(err)d.destroy(err);else if(!readable&&!writable)d.destroy()}if(d=new Duplexify({readableObjectMode:!!(r!==null&&r!==void 0&&r.readableObjectMode),writableObjectMode:!!(w!==null&&w!==void 0&&w.writableObjectMode),readable,writable}),writable)eos(w,(err)=>{if(writable=!1,err)destroyer(r,err);onfinished(err)}),d._write=function(chunk,encoding,callback){if(w.write(chunk,encoding))callback();else ondrain=callback},d._final=function(callback){w.end(),onfinish=callback},w.on(\"drain\",function(){if(ondrain){const cb=ondrain;ondrain=null,cb()}}),w.on(\"finish\",function(){if(onfinish){const cb=onfinish;onfinish=null,cb()}});if(readable)eos(r,(err)=>{if(readable=!1,err)destroyer(r,err);onfinished(err)}),r.on(\"readable\",function(){if(onreadable){const cb=onreadable;onreadable=null,cb()}}),r.on(\"end\",function(){d.push(null)}),d._read=function(){while(!0){const buf=r.read();if(buf===null){onreadable=d._read;return}if(!d.push(buf))return}};return d._destroy=function(err,callback){if(!err&&onclose!==null)err=new AbortError2;if(onreadable=null,ondrain=null,onfinish=null,onclose===null)callback(err);else onclose=callback,destroyer(w,err),destroyer(r,err)},d}}}),require_duplex=__commonJS({\"node_modules/readable-stream/lib/internal/streams/duplex.js\"(exports2,module){var{ObjectDefineProperties,ObjectGetOwnPropertyDescriptor,ObjectKeys,ObjectSetPrototypeOf}=require_primordials(),Readable=require_readable();function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);if(Readable.call(this,options),Writable.call(this,options),options){if(this.allowHalfOpen=options.allowHalfOpen!==!1,options.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(options.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}Duplex.prototype={},module.exports=Duplex,ObjectSetPrototypeOf(Duplex.prototype,Readable.prototype),ObjectSetPrototypeOf(Duplex,Readable);for(var method in Writable.prototype)if(!Duplex.prototype[method])Duplex.prototype[method]=Writable.prototype[method];ObjectDefineProperties(Duplex.prototype,{writable:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writable\"),writableHighWaterMark:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableHighWaterMark\"),writableObjectMode:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableObjectMode\"),writableBuffer:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableBuffer\"),writableLength:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableLength\"),writableFinished:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableFinished\"),writableCorked:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableCorked\"),writableEnded:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableEnded\"),writableNeedDrain:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableNeedDrain\"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(value){if(this._readableState&&this._writableState)this._readableState.destroyed=value,this._writableState.destroyed=value}}});var webStreamsAdapters;function lazyWebStreams(){if(webStreamsAdapters===void 0)webStreamsAdapters={};return webStreamsAdapters}Duplex.fromWeb=function(pair,options){return lazyWebStreams().newStreamDuplexFromReadableWritablePair(pair,options)},Duplex.toWeb=function(duplex){return lazyWebStreams().newReadableWritablePairFromDuplex(duplex)};var duplexify;Duplex.from=function(body){if(!duplexify)duplexify=require_duplexify();return duplexify(body,\"body\")}}}),require_transform=__commonJS({\"node_modules/readable-stream/lib/internal/streams/transform.js\"(exports2,module){var{ObjectSetPrototypeOf,Symbol:Symbol2}=require_primordials(),{ERR_METHOD_NOT_IMPLEMENTED}=require_errors().codes,Duplex=require_duplex();function Transform(options){if(!(this instanceof Transform))return new Transform(options);if(Duplex.call(this,options),this._readableState.sync=!1,this[kCallback]=null,options){if(typeof options.transform===\"function\")this._transform=options.transform;if(typeof options.flush===\"function\")this._flush=options.flush}this.on(\"prefinish\",prefinish.bind(this))}Transform.prototype={},ObjectSetPrototypeOf(Transform.prototype,Duplex.prototype),ObjectSetPrototypeOf(Transform,Duplex),module.exports=Transform;var kCallback=Symbol2(\"kCallback\");function final(cb){if(typeof this._flush===\"function\"&&!this.destroyed)this._flush((er,data)=>{if(er){if(cb)cb(er);else this.destroy(er);return}if(data!=null)this.push(data);if(this.push(null),cb)cb()});else if(this.push(null),cb)cb()}function prefinish(){if(this._final!==final)final.call(this)}Transform.prototype._final=final,Transform.prototype._transform=function(chunk,encoding,callback){throw new ERR_METHOD_NOT_IMPLEMENTED(\"_transform()\")},Transform.prototype._write=function(chunk,encoding,callback){const rState=this._readableState,wState=this._writableState,length=rState.length;this._transform(chunk,encoding,(err,val)=>{if(err){callback(err);return}if(val!=null)this.push(val);if(wState.ended||length===rState.length||rState.length{finished2=!0});const cleanup=eos(stream,{readable:reading,writable:writing},(err)=>{finished2=!err});return{destroy:(err)=>{if(finished2)return;finished2=!0,destroyImpl.destroyer(stream,err||new ERR_STREAM_DESTROYED(\"pipe\"))},cleanup}}function popCallback(streams){return validateFunction(streams[streams.length-1],\"streams[stream.length - 1]\"),streams.pop()}function makeAsyncIterable(val){if(isIterable(val))return val;else if(isReadableNodeStream(val))return fromReadable(val);throw new ERR_INVALID_ARG_TYPE2(\"val\",[\"Readable\",\"Iterable\",\"AsyncIterable\"],val)}async function*fromReadable(val){if(!Readable)Readable=require_readable();yield*Readable.prototype[SymbolAsyncIterator].call(val)}async function pump(iterable,writable,finish,{end}){let error,onresolve=null;const resume=(err)=>{if(err)error=err;if(onresolve){const callback=onresolve;onresolve=null,callback()}},wait=()=>new Promise2((resolve,reject)=>{if(error)reject(error);else onresolve=()=>{if(error)reject(error);else resolve()}});writable.on(\"drain\",resume);const cleanup=eos(writable,{readable:!1},resume);try{if(writable.writableNeedDrain)await wait();for await(let chunk of iterable)if(!writable.write(chunk))await wait();if(end)writable.end();await wait(),finish()}catch(err){finish(error!==err\?aggregateTwoErrors(error,err):err)}finally{cleanup(),writable.off(\"drain\",resume)}}function pipeline(...streams){return pipelineImpl(streams,once(popCallback(streams)))}function pipelineImpl(streams,callback,opts){if(streams.length===1&&ArrayIsArray2(streams[0]))streams=streams[0];if(streams.length<2)throw new ERR_MISSING_ARGS(\"streams\");const ac=new AbortController,signal=ac.signal,outerSignal=opts===null||opts===void 0\?void 0:opts.signal,lastStreamCleanup=[];validateAbortSignal(outerSignal,\"options.signal\");function abort(){finishImpl(new AbortError2)}outerSignal===null||outerSignal===void 0||outerSignal.addEventListener(\"abort\",abort);let error,value;const destroys=[];let finishCount=0;function finish(err){finishImpl(err,--finishCount===0)}function finishImpl(err,final){if(err&&(!error||error.code===\"ERR_STREAM_PREMATURE_CLOSE\"))error=err;if(!error&&!final)return;while(destroys.length)destroys.shift()(error);if(outerSignal===null||outerSignal===void 0||outerSignal.removeEventListener(\"abort\",abort),ac.abort(),final){if(!error)lastStreamCleanup.forEach((fn)=>fn());runOnNextTick(callback,error,value)}}let ret;for(let i=0;i0,end=reading||(opts===null||opts===void 0\?void 0:opts.end)!==!1,isLastStream=i===streams.length-1;if(isNodeStream(stream)){let onError=function(err){if(err&&err.name!==\"AbortError\"&&err.code!==\"ERR_STREAM_PREMATURE_CLOSE\")finish(err)};if(end){const{destroy:destroy2,cleanup}=destroyer(stream,reading,writing);if(destroys.push(destroy2),isReadable(stream)&&isLastStream)lastStreamCleanup.push(cleanup)}if(stream.on(\"error\",onError),isReadable(stream)&&isLastStream)lastStreamCleanup.push(()=>{stream.removeListener(\"error\",onError)})}if(i===0)if(typeof stream===\"function\"){if(ret=stream({signal}),!isIterable(ret))throw new ERR_INVALID_RETURN_VALUE(\"Iterable, AsyncIterable or Stream\",\"source\",ret)}else if(isIterable(stream)||isReadableNodeStream(stream))ret=stream;else ret=Duplex.from(stream);else if(typeof stream===\"function\")if(ret=makeAsyncIterable(ret),ret=stream(ret,{signal}),reading){if(!isIterable(ret,!0))throw new ERR_INVALID_RETURN_VALUE(\"AsyncIterable\",`transform[${i-1}]`,ret)}else{var _ret;if(!PassThrough)PassThrough=require_passthrough();const pt=new PassThrough({objectMode:!0}),then=(_ret=ret)===null||_ret===void 0\?void 0:_ret.then;if(typeof then===\"function\")finishCount++,then.call(ret,(val)=>{if(value=val,val!=null)pt.write(val);if(end)pt.end();runOnNextTick(finish)},(err)=>{pt.destroy(err),runOnNextTick(finish,err)});else if(isIterable(ret,!0))finishCount++,pump(ret,pt,finish,{end});else throw new ERR_INVALID_RETURN_VALUE(\"AsyncIterable or Promise\",\"destination\",ret);ret=pt;const{destroy:destroy2,cleanup}=destroyer(ret,!1,!0);if(destroys.push(destroy2),isLastStream)lastStreamCleanup.push(cleanup)}else if(isNodeStream(stream)){if(isReadableNodeStream(ret)){finishCount+=2;const cleanup=pipe(ret,stream,finish,{end});if(isReadable(stream)&&isLastStream)lastStreamCleanup.push(cleanup)}else if(isIterable(ret))finishCount++,pump(ret,stream,finish,{end});else throw new ERR_INVALID_ARG_TYPE2(\"val\",[\"Readable\",\"Iterable\",\"AsyncIterable\"],ret);ret=stream}else ret=Duplex.from(stream)}if(signal!==null&&signal!==void 0&&signal.aborted||outerSignal!==null&&outerSignal!==void 0&&outerSignal.aborted)runOnNextTick(abort);return ret}function pipe(src,dst,finish,{end}){if(src.pipe(dst,{end}),end)src.once(\"end\",()=>dst.end());else finish();return eos(src,{readable:!0,writable:!1},(err)=>{const rState=src._readableState;if(err&&err.code===\"ERR_STREAM_PREMATURE_CLOSE\"&&rState&&rState.ended&&!rState.errored&&!rState.errorEmitted)src.once(\"end\",finish).once(\"error\",finish);else finish(err)}),eos(dst,{readable:!1,writable:!0},finish)}module.exports={pipelineImpl,pipeline}}}),require_compose=__commonJS({\"node_modules/readable-stream/lib/internal/streams/compose.js\"(exports2,module){var{pipeline}=require_pipeline(),Duplex=require_duplex(),{destroyer}=require_destroy(),{isNodeStream,isReadable,isWritable}=require_utils(),{AbortError:AbortError2,codes:{ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2,ERR_MISSING_ARGS}}=require_errors();module.exports=function compose(...streams){if(streams.length===0)throw new ERR_MISSING_ARGS(\"streams\");if(streams.length===1)return Duplex.from(streams[0]);const orgStreams=[...streams];if(typeof streams[0]===\"function\")streams[0]=Duplex.from(streams[0]);if(typeof streams[streams.length-1]===\"function\"){const idx=streams.length-1;streams[idx]=Duplex.from(streams[idx])}for(let n=0;n0&&!isWritable(streams[n]))throw new ERR_INVALID_ARG_VALUE2(`streams[${n}]`,orgStreams[n],\"must be writable\")}let ondrain,onfinish,onreadable,onclose,d;function onfinished(err){const cb=onclose;if(onclose=null,cb)cb(err);else if(err)d.destroy(err);else if(!readable&&!writable)d.destroy()}const head=streams[0],tail=pipeline(streams,onfinished),writable=!!isWritable(head),readable=!!isReadable(tail);if(d=new Duplex({writableObjectMode:!!(head!==null&&head!==void 0&&head.writableObjectMode),readableObjectMode:!!(tail!==null&&tail!==void 0&&tail.writableObjectMode),writable,readable}),writable)d._write=function(chunk,encoding,callback){if(head.write(chunk,encoding))callback();else ondrain=callback},d._final=function(callback){head.end(),onfinish=callback},head.on(\"drain\",function(){if(ondrain){const cb=ondrain;ondrain=null,cb()}}),tail.on(\"finish\",function(){if(onfinish){const cb=onfinish;onfinish=null,cb()}});if(readable)tail.on(\"readable\",function(){if(onreadable){const cb=onreadable;onreadable=null,cb()}}),tail.on(\"end\",function(){d.push(null)}),d._read=function(){while(!0){const buf=tail.read();if(buf===null){onreadable=d._read;return}if(!d.push(buf))return}};return d._destroy=function(err,callback){if(!err&&onclose!==null)err=new AbortError2;if(onreadable=null,ondrain=null,onfinish=null,onclose===null)callback(err);else onclose=callback,destroyer(tail,err)},d}}}),require_promises=__commonJS({\"node_modules/readable-stream/lib/stream/promises.js\"(exports2,module){var{ArrayPrototypePop,Promise:Promise2}=require_primordials(),{isIterable,isNodeStream}=require_utils(),{pipelineImpl:pl}=require_pipeline(),{finished:finished2}=require_end_of_stream();function pipeline(...streams){return new Promise2((resolve,reject)=>{let signal,end;const lastArg=streams[streams.length-1];if(lastArg&&typeof lastArg===\"object\"&&!isNodeStream(lastArg)&&!isIterable(lastArg)){const options=ArrayPrototypePop(streams);signal=options.signal,end=options.end}pl(streams,(err,value)=>{if(err)reject(err);else resolve(value)},{signal,end})})}module.exports={finished:finished2,pipeline}}}),require_stream=__commonJS({\"node_modules/readable-stream/lib/stream.js\"(exports2,module){var{ObjectDefineProperty,ObjectKeys,ReflectApply}=require_primordials(),{promisify:{custom:customPromisify}}=require_util(),{streamReturningOperators,promiseReturningOperators}=require_operators(),{codes:{ERR_ILLEGAL_CONSTRUCTOR}}=require_errors(),compose=require_compose(),{pipeline}=require_pipeline(),{destroyer}=require_destroy(),eos=require_end_of_stream(),promises2=require_promises(),utils=require_utils(),Stream=module.exports=require_legacy().Stream;Stream.isDisturbed=utils.isDisturbed,Stream.isErrored=utils.isErrored,Stream.isWritable=utils.isWritable,Stream.isReadable=utils.isReadable,Stream.Readable=require_readable();for(let key of ObjectKeys(streamReturningOperators)){let fn=function(...args){if(new.target)throw ERR_ILLEGAL_CONSTRUCTOR();return Stream.Readable.from(ReflectApply(op,this,args))};const op=streamReturningOperators[key];ObjectDefineProperty(fn,\"name\",{value:op.name}),ObjectDefineProperty(fn,\"length\",{value:op.length}),ObjectDefineProperty(Stream.Readable.prototype,key,{value:fn,enumerable:!1,configurable:!0,writable:!0})}for(let key of ObjectKeys(promiseReturningOperators)){let fn=function(...args){if(new.target)throw ERR_ILLEGAL_CONSTRUCTOR();return ReflectApply(op,this,args)};const op=promiseReturningOperators[key];ObjectDefineProperty(fn,\"name\",{value:op.name}),ObjectDefineProperty(fn,\"length\",{value:op.length}),ObjectDefineProperty(Stream.Readable.prototype,key,{value:fn,enumerable:!1,configurable:!0,writable:!0})}Stream.Writable=require_writable(),Stream.Duplex=require_duplex(),Stream.Transform=require_transform(),Stream.PassThrough=require_passthrough(),Stream.pipeline=pipeline;var{addAbortSignal}=require_add_abort_signal();Stream.addAbortSignal=addAbortSignal,Stream.finished=eos,Stream.destroy=destroyer,Stream.compose=compose,ObjectDefineProperty(Stream,\"promises\",{configurable:!0,enumerable:!0,get(){return promises2}}),ObjectDefineProperty(pipeline,customPromisify,{enumerable:!0,get(){return promises2.pipeline}}),ObjectDefineProperty(eos,customPromisify,{enumerable:!0,get(){return promises2.finished}}),Stream.Stream=Stream,Stream._isUint8Array=function isUint8Array(value){return value instanceof Uint8Array},Stream._uint8ArrayToBuffer=function _uint8ArrayToBuffer(chunk){return new Buffer(chunk.buffer,chunk.byteOffset,chunk.byteLength)}}});function createNativeStreamReadable(nativeType,Readable){var[pull,start,cancel,setClose,deinit,updateRef,drainFn]=globalThis[globalThis.Symbol.for('Bun.lazy')](nativeType),closer=[!1],handleNumberResult=function(nativeReadable,result,view,isClosed){if(result>0){const slice=view.subarray(0,result),remainder=view.subarray(result);if(slice.byteLength>0)nativeReadable.push(slice);if(isClosed)nativeReadable.push(null);return remainder.byteLength>0\?remainder:void 0}if(isClosed)nativeReadable.push(null);return view},handleArrayBufferViewResult=function(nativeReadable,result,view,isClosed){if(result.byteLength>0)nativeReadable.push(result);if(isClosed)nativeReadable.push(null);return view},DYNAMICALLY_ADJUST_CHUNK_SIZE=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!==\"1\";const finalizer=new FinalizationRegistry((ptr)=>ptr&&deinit(ptr)),MIN_BUFFER_SIZE=512;var NativeReadable=class NativeReadable2 extends Readable{#bunNativePtr;#refCount=1;#constructed=!1;#remainingChunk=void 0;#highWaterMark;#pendingRead=!1;#hasResized=!DYNAMICALLY_ADJUST_CHUNK_SIZE;#unregisterToken;constructor(ptr,options={}){super(options);if(typeof options.highWaterMark===\"number\")this.#highWaterMark=options.highWaterMark;else this.#highWaterMark=262144;this.#bunNativePtr=ptr,this.#constructed=!1,this.#remainingChunk=void 0,this.#pendingRead=!1,this.#unregisterToken={},finalizer.register(this,this.#bunNativePtr,this.#unregisterToken)}_read(maxToRead){if(this.#pendingRead)return;var ptr=this.#bunNativePtr;if(ptr===0){this.push(null);return}if(!this.#constructed)this.#internalConstruct(ptr);return this.#internalRead(this.#getRemainingChunk(maxToRead),ptr)}#internalConstruct(ptr){this.#constructed=!0;const result=start(ptr,this.#highWaterMark);if(typeof result===\"number\"&&result>1)this.#hasResized=!0,this.#highWaterMark=Math.min(this.#highWaterMark,result);if(drainFn){const drainResult=drainFn(ptr);if((drainResult\?.byteLength\?\?0)>0)this.push(drainResult)}}#getRemainingChunk(maxToRead=this.#highWaterMark){var chunk=this.#remainingChunk;if(chunk\?.byteLength\?\?0MIN_BUFFER_SIZE\?maxToRead:MIN_BUFFER_SIZE;this.#remainingChunk=chunk=new Buffer(size)}return chunk}#handleResult(result,view,isClosed){if(typeof result===\"number\"){if(result>=this.#highWaterMark&&!this.#hasResized&&!isClosed)this.#highWaterMark*=2,this.#hasResized=!0;return handleNumberResult(this,result,view,isClosed)}else if(typeof result===\"boolean\")return process.nextTick(()=>{this.push(null)}),view\?.byteLength\?\?0>0\?view:void 0;else if(ArrayBuffer.isView(result)){if(result.byteLength>=this.#highWaterMark&&!this.#hasResized&&!isClosed)this.#highWaterMark*=2,this.#hasResized=!0;return handleArrayBufferViewResult(this,result,view,isClosed)}else throw new Error(\"Invalid result from pull\")}#internalRead(view,ptr){closer[0]=!1;var result=pull(ptr,view,closer);if(@isPromise(result))return this.#pendingRead=!0,result.then((result2)=>{this.#pendingRead=!1,this.#remainingChunk=this.#handleResult(result2,view,closer[0])},(reason)=>{errorOrDestroy(this,reason)});else this.#remainingChunk=this.#handleResult(result,view,closer[0])}_destroy(error,callback){var ptr=this.#bunNativePtr;if(ptr===0){callback(error);return}if(finalizer.unregister(this.#unregisterToken),this.#bunNativePtr=0,updateRef)updateRef(ptr,!1);cancel(ptr,error),callback(error)}ref(){var ptr=this.#bunNativePtr;if(ptr===0)return;if(this.#refCount++===0)updateRef(ptr,!0)}unref(){var ptr=this.#bunNativePtr;if(ptr===0)return;if(this.#refCount--===1)updateRef(ptr,!1)}};if(!updateRef)NativeReadable.prototype.ref=void 0,NativeReadable.prototype.unref=void 0;return NativeReadable}var nativeReadableStreamPrototypes={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0};function getNativeReadableStreamPrototype(nativeType,Readable){return nativeReadableStreamPrototypes[nativeType]||=createNativeStreamReadable(nativeType,Readable)}function getNativeReadableStream(Readable,stream,options){if(!(stream&&typeof stream===\"object\"&&stream instanceof ReadableStream))return;const native=@direct(stream);if(!native)return;const{stream:ptr,data:type}=native;return new(getNativeReadableStreamPrototype(type,Readable))(ptr,options)}var Writable=require_writable(),NativeWritable=class NativeWritable2 extends Writable{#pathOrFdOrSink;#fileSink;#native=!0;_construct;_destroy;_final;constructor(pathOrFdOrSink,options={}){super(options);this._construct=this.#internalConstruct,this._destroy=this.#internalDestroy,this._final=this.#internalFinal,this.#pathOrFdOrSink=pathOrFdOrSink}#internalConstruct(cb){this._writableState.constructed=!0,this.constructed=!0,cb()}#lazyConstruct(){if(typeof this.#pathOrFdOrSink===\"object\")if(typeof this.#pathOrFdOrSink.write===\"function\")this.#fileSink=this.#pathOrFdOrSink;else throw new Error(\"Invalid FileSink\");else this.#fileSink=Bun.file(this.#pathOrFdOrSink).writer()}write(chunk,encoding,cb,native=this.#native){if(!native)return this.#native=!1,super.write(chunk,encoding,cb);if(!this.#fileSink)this.#lazyConstruct();var fileSink=this.#fileSink,result=fileSink.write(chunk);if(@isPromise(result))return result.then(()=>{this.emit(\"drain\"),fileSink.flush(!0)}),!1;if(fileSink.flush(!0),cb)cb(null,chunk.byteLength);return!0}end(chunk,encoding,cb,native=this.#native){return super.end(chunk,encoding,cb,native)}#internalDestroy(error,cb){if(this._writableState.destroyed=!0,cb)cb(error)}#internalFinal(cb){if(this.#fileSink)this.#fileSink.end();if(cb)cb()}ref(){if(!this.#fileSink)this.#lazyConstruct();this.#fileSink.ref()}unref(){if(!this.#fileSink)return;this.#fileSink.unref()}};const exports=require_stream(),promises=require_promises();return exports._getNativeReadableStreamPrototype=getNativeReadableStreamPrototype,exports.NativeWritable=NativeWritable,Object.defineProperty(exports,\"promises\",{configurable:!0,enumerable:!0,get(){return promises}}),exports[Symbol.for(\"::bunternal::\")]={_ReadableFromWeb,_ReadableFromWebForUndici},exports.eos=require_end_of_stream(),exports})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamPromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamWebCode = "(function (){\"use strict\";return{ReadableStream,ReadableStreamDefaultReader,ReadableStreamBYOBReader,ReadableStreamBYOBRequest,ReadableByteStreamController,ReadableStreamDefaultController,TransformStream,TransformStreamDefaultController,WritableStream,WritableStreamDefaultWriter,WritableStreamDefaultController,ByteLengthQueuingStrategy,CountQueuingStrategy}})\n"_s; +// + +// static constexpr ASCIILiteral NodeTimersCode = "(function (){\"use strict\";return{setTimeout,clearTimeout,setInterval,setImmediate,clearInterval,clearImmediate}})\n"_s; +// + +// static constexpr ASCIILiteral NodeTimersPromisesCode = "(function (){\"use strict\";var $;const symbolAsyncIterator=Symbol.asyncIterator;class ERR_INVALID_ARG_TYPE extends Error{constructor(name,expected,actual){super(`${name} must be ${expected}, ${typeof actual} given`);this.code=\"ERR_INVALID_ARG_TYPE\"}}class AbortError extends Error{constructor(){super(\"The operation was aborted\");this.code=\"ABORT_ERR\"}}function validateObject(object,name){if(object===null||typeof object!==\"object\")throw new ERR_INVALID_ARG_TYPE(name,\"Object\",object)}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}function validateAbortSignal(signal,name){if(typeof signal!==\"undefined\"&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE(name,\"AbortSignal\",signal)}function asyncIterator({next:nextFunction,return:returnFunction}){const result={};if(typeof nextFunction===\"function\")result.next=nextFunction;if(typeof returnFunction===\"function\")result.return=returnFunction;return result[symbolAsyncIterator]=function(){return this},result}function setTimeoutPromise(after=1,value,options={}){const arguments_=[].concat(value\?\?[]);try{validateObject(options,\"options\")}catch(error){return Promise.reject(error)}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return Promise.reject(error)}try{validateBoolean(reference,\"options.ref\")}catch(error){return Promise.reject(error)}if(signal\?.aborted)return Promise.reject(new AbortError);let onCancel;const returnValue=new Promise((resolve,reject)=>{const timeout=setTimeout(()=>resolve(value),after,...arguments_);if(!reference)timeout\?.unref\?.();if(signal)onCancel=()=>{clearTimeout(timeout),reject(new AbortError)},signal.addEventListener(\"abort\",onCancel)});if(typeof onCancel!==\"undefined\")returnValue.finally(()=>signal.removeEventListener(\"abort\",onCancel));return returnValue}function setImmediatePromise(value,options={}){try{validateObject(options,\"options\")}catch(error){return Promise.reject(error)}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return Promise.reject(error)}try{validateBoolean(reference,\"options.ref\")}catch(error){return Promise.reject(error)}if(signal\?.aborted)return Promise.reject(new AbortError);let onCancel;const returnValue=new Promise((resolve,reject)=>{const immediate=setImmediate(()=>resolve(value));if(!reference)immediate\?.unref\?.();if(signal)onCancel=()=>{clearImmediate(immediate),reject(new AbortError)},signal.addEventListener(\"abort\",onCancel)});if(typeof onCancel!==\"undefined\")returnValue.finally(()=>signal.removeEventListener(\"abort\",onCancel));return returnValue}function setIntervalPromise(after=1,value,options={}){try{validateObject(options,\"options\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}try{validateBoolean(reference,\"options.ref\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}if(signal\?.aborted)return asyncIterator({next:function(){return Promise.reject(new AbortError)}});let onCancel,interval;try{let notYielded=0,callback;if(interval=setInterval(()=>{if(notYielded++,callback)callback(),callback=void 0},after),!reference)interval\?.unref\?.();if(signal)onCancel=()=>{if(clearInterval(interval),callback)callback(),callback=void 0},signal.addEventListener(\"abort\",onCancel);return asyncIterator({next:function(){return new Promise((resolve,reject)=>{if(!signal\?.aborted)if(notYielded===0)callback=resolve;else resolve();else if(notYielded===0)reject(new AbortError);else resolve()}).then(()=>{if(notYielded>0)return notYielded=notYielded-1,{done:!1,value};return{done:!0}})},return:function(){return clearInterval(interval),signal\?.removeEventListener(\"abort\",onCancel),Promise.resolve({})}})}catch(error){return asyncIterator({next:function(){clearInterval(interval),signal\?.removeEventListener(\"abort\",onCancel)}})}}return $={setTimeout:setTimeoutPromise,setImmediate:setImmediatePromise,setInterval:setIntervalPromise,scheduler:{wait:(delay,options)=>setTimeoutPromise(delay,void 0,options),yield:setImmediatePromise}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeTLSCode = "(function (){\"use strict\";const{isArrayBufferView,isTypedArray}=@requireNativeModule(\"node:util/types\"),net=@getInternalField(@internalModuleRegistry,22)||@createInternalModuleById(22),{Server:NetServer,[Symbol.for(\"::bunternal::\")]:InternalTCPSocket}=net,bunSocketInternal=Symbol.for(\"::bunnetsocketinternal::\"),{rootCertificates,canonicalizeIP}=globalThis[globalThis.Symbol.for('Bun.lazy')](\"internal/tls\"),SymbolReplace=Symbol.replace,RegExpPrototypeSymbolReplace=RegExp.prototype[SymbolReplace],RegExpPrototypeExec=RegExp.prototype.exec,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeSlice=String.prototype.slice,StringPrototypeIncludes=String.prototype.includes,StringPrototypeSplit=String.prototype.split,StringPrototypeIndexOf=String.prototype.indexOf,StringPrototypeSubstring=String.prototype.substring,StringPrototypeEndsWith=String.prototype.endsWith,StringFromCharCode=String.fromCharCode,StringPrototypeCharCodeAt=String.prototype.charCodeAt,ArrayPrototypeIncludes=Array.prototype.includes,ArrayPrototypeJoin=Array.prototype.join,ArrayPrototypeForEach=Array.prototype.forEach,ArrayPrototypePush=Array.prototype.push,ArrayPrototypeSome=Array.prototype.some,ArrayPrototypeReduce=Array.prototype.reduce;function parseCertString(){throwNotImplemented(\"Not implemented\")}function isValidTLSArray(obj){if(typeof obj===\"string\"||isTypedArray(obj)||obj instanceof ArrayBuffer||obj instanceof Blob)return!0;if(Array.isArray(obj)){for(var i=0;iRegExpPrototypeExec.call(/[^\\u0021-\\u007F]/u,s)!==null;if(ArrayPrototypeSome.call(patternParts,isBad))return!1;for(let i=hostParts.length-1;i>0;i-=1)if(hostParts[i]!==patternParts[i])return!1;const hostSubdomain=hostParts[0],patternSubdomain=patternParts[0],patternSubdomainParts=StringPrototypeSplit.call(patternSubdomain,\"*\");if(patternSubdomainParts.length===1||StringPrototypeIncludes.call(patternSubdomain,\"xn--\"))return hostSubdomain===patternSubdomain;if(!wildcards)return!1;if(patternSubdomainParts.length>2)return!1;if(patternParts.length<=2)return!1;const{0:prefix,1:suffix}=patternSubdomainParts;if(prefix.length+suffix.length>hostSubdomain.length)return!1;if(!StringPrototypeStartsWith.call(hostSubdomain,prefix))return!1;if(!StringPrototypeEndsWith.call(hostSubdomain,suffix))return!1;return!0}const jsonStringPattern=/^\"(\?:[^\"\\\\\\u0000-\\u001f]|\\\\(\?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4}))*\"/;function splitEscapedAltNames(altNames){const result=[];let currentToken=\"\",offset=0;while(offset!==altNames.length){const nextSep=StringPrototypeIndexOf.call(altNames,\", \",offset),nextQuote=StringPrototypeIndexOf.call(altNames,'\"',offset);if(nextQuote!==-1&&(nextSep===-1||nextQuote{if(StringPrototypeStartsWith.call(name,\"DNS:\"))ArrayPrototypePush.call(dnsNames,StringPrototypeSlice.call(name,4));else if(StringPrototypeStartsWith.call(name,\"IP Address:\"))ArrayPrototypePush.call(ips,canonicalizeIP(StringPrototypeSlice.call(name,11)))})}let valid=!1,reason=\"Unknown reason\";if(hostname=unfqdn(hostname),net.isIP(hostname)){if(valid=ArrayPrototypeIncludes.call(ips,canonicalizeIP(hostname)),!valid)reason=`IP: ${hostname} is not in the cert's list: `+ArrayPrototypeJoin.call(ips,\", \")}else if(dnsNames.length>0||subject\?.CN){const hostParts=splitHost(hostname),wildcard=(pattern)=>check(hostParts,pattern,!0);if(dnsNames.length>0){if(valid=ArrayPrototypeSome.call(dnsNames,wildcard),!valid)reason=`Host: ${hostname}. is not in the cert's altnames: ${altNames}`}else{const cn=subject.CN;if(Array.isArray(cn))valid=ArrayPrototypeSome.call(cn,wildcard);else if(cn)valid=wildcard(cn);if(!valid)reason=`Host: ${hostname}. is not cert's CN: ${cn}`}}else reason=\"Cert does not contain a DNS name\";if(!valid){let error=new Error(`ERR_TLS_CERT_ALTNAME_INVALID: Hostname/IP does not match certificate's altnames: ${reason}`);return error.name=\"ERR_TLS_CERT_ALTNAME_INVALID\",error.reason=reason,error.host=host,error.cert=cert,error}}var InternalSecureContext=class SecureContext2{context;constructor(options){const context={};if(options){let key=options.key;if(key){if(!isValidTLSArray(key))@throwTypeError(\"key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.key=key}let cert=options.cert;if(cert){if(!isValidTLSArray(cert))@throwTypeError(\"cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.cert=cert}let ca=options.ca;if(ca){if(!isValidTLSArray(ca))@throwTypeError(\"ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.ca=ca}let passphrase=options.passphrase;if(passphrase&&typeof passphrase!==\"string\")@throwTypeError(\"passphrase argument must be an string\");this.passphrase=passphrase;let servername=options.servername;if(servername&&typeof servername!==\"string\")@throwTypeError(\"servername argument must be an string\");this.servername=servername;let secureOptions=options.secureOptions||0;if(secureOptions&&typeof secureOptions!==\"number\")@throwTypeError(\"secureOptions argument must be an number\");this.secureOptions=secureOptions}this.context=context}};function SecureContext(options){return new InternalSecureContext(options)}function createSecureContext(options){return new SecureContext(options)}function translatePeerCertificate(c){if(!c)return null;if(c.issuerCertificate!=null&&c.issuerCertificate!==c)c.issuerCertificate=translatePeerCertificate(c.issuerCertificate);if(c.infoAccess!=null){const info=c.infoAccess;c.infoAccess={__proto__:null},RegExpPrototypeSymbolReplace.call(/([^\\n:]*):([^\\n]*)(\?:\\n|$)/g,info,(all,key,val)=>{if(val.charCodeAt(0)===34)val=JSONParse(val);if(key in c.infoAccess)ArrayPrototypePush.call(c.infoAccess[key],val);else c.infoAccess[key]=[val]})}return c}const buntls=Symbol.for(\"::buntls::\");var SocketClass;const TLSSocket=function(InternalTLSSocket){return SocketClass=InternalTLSSocket,Object.defineProperty(SocketClass.prototype,Symbol.toStringTag,{value:\"TLSSocket\",enumerable:!1}),Object.defineProperty(function Socket(options){return new InternalTLSSocket(options)},Symbol.hasInstance,{value(instance){return instance instanceof InternalTLSSocket}})}(class TLSSocket2 extends InternalTCPSocket{#secureContext;ALPNProtocols;#socket;#checkServerIdentity;#session;constructor(socket,options){super(socket instanceof InternalTCPSocket\?options:options||socket);if(options=options||socket||{},typeof options===\"object\"){const{ALPNProtocols}=options;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,this);if(socket instanceof InternalTCPSocket)this.#socket=socket}this.#secureContext=options.secureContext||createSecureContext(options),this.authorized=!1,this.secureConnecting=!0,this._secureEstablished=!1,this._securePending=!0,this.#checkServerIdentity=options.checkServerIdentity||checkServerIdentity,this.#session=options.session||null}_secureEstablished=!1;_securePending=!0;_newSessionPending;_controlReleased;secureConnecting=!1;_SNICallback;servername;authorized=!1;authorizationError;#renegotiationDisabled=!1;encrypted=!0;_start(){this.connect()}getSession(){return this[bunSocketInternal]\?.getSession()}getEphemeralKeyInfo(){return this[bunSocketInternal]\?.getEphemeralKeyInfo()}getCipher(){return this[bunSocketInternal]\?.getCipher()}getSharedSigalgs(){return this[bunSocketInternal]\?.getSharedSigalgs()}getProtocol(){return this[bunSocketInternal]\?.getTLSVersion()}getFinished(){return this[bunSocketInternal]\?.getTLSFinishedMessage()||void 0}getPeerFinished(){return this[bunSocketInternal]\?.getTLSPeerFinishedMessage()||void 0}isSessionReused(){return!!this.#session}renegotiate(){if(this.#renegotiationDisabled){const error=new Error(\"ERR_TLS_RENEGOTIATION_DISABLED: TLS session renegotiation disabled for this socket\");throw error.name=\"ERR_TLS_RENEGOTIATION_DISABLED\",error}throw Error(\"Not implented in Bun yet\")}disableRenegotiation(){this.#renegotiationDisabled=!0}getTLSTicket(){return this[bunSocketInternal]\?.getTLSTicket()}exportKeyingMaterial(length,label,context){if(context)return this[bunSocketInternal]\?.exportKeyingMaterial(length,label,context);return this[bunSocketInternal]\?.exportKeyingMaterial(length,label)}setMaxSendFragment(size){return this[bunSocketInternal]\?.setMaxSendFragment(size)||!1}enableTrace(){}setServername(name){if(this.isServer){let error=new Error(\"ERR_TLS_SNI_FROM_SERVER: Cannot issue SNI from a TLS server-side socket\");throw error.name=\"ERR_TLS_SNI_FROM_SERVER\",error}this.servername=name,this[bunSocketInternal]\?.setServername(name)}setSession(session){if(this.#session=session,typeof session===\"string\")session=Buffer.from(session,\"latin1\");return this[bunSocketInternal]\?.setSession(session)}getPeerCertificate(abbreviated){const cert=arguments.length<1\?this[bunSocketInternal]\?.getPeerCertificate():this[bunSocketInternal]\?.getPeerCertificate(abbreviated);if(cert)return translatePeerCertificate(cert)}getCertificate(){const cert=this[bunSocketInternal]\?.getCertificate();if(cert)return translatePeerCertificate(cert)}getPeerX509Certificate(){throw Error(\"Not implented in Bun yet\")}getX509Certificate(){throw Error(\"Not implented in Bun yet\")}get alpnProtocol(){return this[bunSocketInternal]\?.alpnProtocol}[buntls](port,host2){return{socket:this.#socket,ALPNProtocols:this.ALPNProtocols,serverName:this.servername||host2||\"localhost\",checkServerIdentity:this.#checkServerIdentity,session:this.#session,...this.#secureContext}}});class Server extends NetServer{key;cert;ca;passphrase;secureOptions;_rejectUnauthorized;_requestCert;servername;ALPNProtocols;constructor(options,secureConnectionListener){super(options,secureConnectionListener);this.setSecureContext(options)}setSecureContext(options){if(options instanceof InternalSecureContext)options=options.context;if(options){const{ALPNProtocols}=options;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,this);let key=options.key;if(key){if(!isValidTLSArray(key))@throwTypeError(\"key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.key=key}let cert=options.cert;if(cert){if(!isValidTLSArray(cert))@throwTypeError(\"cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.cert=cert}let ca=options.ca;if(ca){if(!isValidTLSArray(ca))@throwTypeError(\"ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.ca=ca}let passphrase=options.passphrase;if(passphrase&&typeof passphrase!==\"string\")@throwTypeError(\"passphrase argument must be an string\");this.passphrase=passphrase;let servername=options.servername;if(servername&&typeof servername!==\"string\")@throwTypeError(\"servername argument must be an string\");this.servername=servername;let secureOptions=options.secureOptions||0;if(secureOptions&&typeof secureOptions!==\"number\")@throwTypeError(\"secureOptions argument must be an number\");this.secureOptions=secureOptions;const requestCert=options.requestCert||!1;if(requestCert)this._requestCert=requestCert;else this._requestCert=void 0;const rejectUnauthorized=options.rejectUnauthorized||!1;if(rejectUnauthorized)this._rejectUnauthorized=rejectUnauthorized;else this._rejectUnauthorized=void 0}}getTicketKeys(){throw Error(\"Not implented in Bun yet\")}setTicketKeys(){throw Error(\"Not implented in Bun yet\")}[buntls](port,host2,isClient){return[{serverName:this.servername||host2||\"localhost\",key:this.key,cert:this.cert,ca:this.ca,passphrase:this.passphrase,secureOptions:this.secureOptions,rejectUnauthorized:isClient\?!1:this._rejectUnauthorized,requestCert:isClient\?!1:this._requestCert,ALPNProtocols:this.ALPNProtocols},SocketClass]}}function createServer(options,connectionListener){return new Server(options,connectionListener)}const CLIENT_RENEG_LIMIT=3,CLIENT_RENEG_WINDOW=600,DEFAULT_ECDH_CURVE=\"auto\",DEFAULT_CIPHERS=\"DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256\",DEFAULT_MIN_VERSION=\"TLSv1.2\",DEFAULT_MAX_VERSION=\"TLSv1.3\",createConnection=(port,host2,connectListener)=>{if(typeof port===\"object\"){port.checkServerIdentity;const{ALPNProtocols}=port;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,port);return new TLSSocket(port).connect(port,host2,connectListener)}return new TLSSocket().connect(port,host2,connectListener)},connect=createConnection;function getCiphers(){return DEFAULT_CIPHERS.split(\":\")}function convertProtocols(protocols){const lens=new Array(protocols.length),buff=Buffer.allocUnsafe(ArrayPrototypeReduce.call(protocols,(p,c,i)=>{const len=Buffer.byteLength(c);if(len>255)@throwRangeError(\"The byte length of the protocol at index \"+`${i} exceeds the maximum length.`,\"<= 255\",len,!0);return lens[i]=len,p+1+len},0));let offset=0;for(let i=0,c=protocols.length;i\",'\"',\"`\",\" \",\"\\r\",\"\\n\",\"\\t\"],unwise=[\"{\",\"}\",\"|\",\"\\\\\",\"^\",\"`\"].concat(delims),autoEscape=[\"'\"].concat(unwise),nonHostChars=[\"%\",\"/\",\"\?\",\";\",\"#\"].concat(autoEscape),hostEndingChars=[\"/\",\"\?\",\"#\"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,\"javascript:\":!0},hostlessProtocol={javascript:!0,\"javascript:\":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,\"http:\":!0,\"https:\":!0,\"ftp:\":!0,\"gopher:\":!0,\"file:\":!0};function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&typeof url===\"object\"&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(typeof url!==\"string\")@throwTypeError(\"Parameter 'url' must be a string, not \"+typeof url);var queryIndex=url.indexOf(\"\?\"),splitter=queryIndex!==-1&&queryIndex127)newpart+=\"x\";else newpart+=part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(hostnamePartStart);if(bit)validParts.push(bit[1]),notHost.unshift(bit[2]);if(notHost.length)rest=\"/\"+notHost.join(\".\")+rest;this.hostname=validParts.join(\".\");break}}}}if(this.hostname.length>hostnameMaxLen)this.hostname=\"\";else this.hostname=this.hostname.toLowerCase();if(!ipv6Hostname)this.hostname=new URL(\"http://\"+this.hostname).hostname;var p=this.port\?\":\"+this.port:\"\",h=this.hostname||\"\";if(this.host=h+p,this.href+=this.host,ipv6Hostname){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),rest[0]!==\"/\")rest=\"/\"+rest}}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length;i0\?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.hostname=authInHost.shift(),result.host=result.hostname}if(result.search=relative.search,result.query=relative.query,result.pathname!==null||result.search!==null)result.path=(result.pathname\?result.pathname:\"\")+(result.search\?result.search:\"\");return result.href=result.format(),result}if(!srcPath.length){if(result.pathname=null,result.search)result.path=\"/\"+result.search;else result.path=null;return result.href=result.format(),result}var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&(last===\".\"||last===\"..\")||last===\"\",up=0;for(var i=srcPath.length;i>=0;i--)if(last=srcPath[i],last===\".\")srcPath.splice(i,1);else if(last===\"..\")srcPath.splice(i,1),up++;else if(up)srcPath.splice(i,1),up--;if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift(\"..\");if(mustEndAbs&&srcPath[0]!==\"\"&&(!srcPath[0]||srcPath[0].charAt(0)!==\"/\"))srcPath.unshift(\"\");if(hasTrailingSlash&&srcPath.join(\"/\").substr(-1)!==\"/\")srcPath.push(\"\");var isAbsolute=srcPath[0]===\"\"||srcPath[0]&&srcPath[0].charAt(0)===\"/\";if(psychotic){result.hostname=isAbsolute\?\"\":srcPath.length\?srcPath.shift():\"\",result.host=result.hostname;var authInHost=result.host&&result.host.indexOf(\"@\")>0\?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.hostname=authInHost.shift(),result.host=result.hostname}if(mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute)srcPath.unshift(\"\");if(srcPath.length>0)result.pathname=srcPath.join(\"/\");else result.pathname=null,result.path=null;if(result.pathname!==null||result.search!==null)result.path=(result.pathname\?result.pathname:\"\")+(result.search\?result.search:\"\");return result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=portPattern.exec(host);if(port){if(port=port[0],port!==\":\")this.port=port.substr(1);host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};function urlToHttpOptions(url){const options={protocol:url.protocol,hostname:typeof url.hostname===\"string\"&&url.hostname.startsWith(\"[\")\?url.hostname.slice(1,-1):url.hostname,hash:url.hash,search:url.search,pathname:url.pathname,path:`${url.pathname||\"\"}${url.search||\"\"}`,href:url.href};if(url.port!==\"\")options.port=Number(url.port);if(url.username||url.password)options.auth=`${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;return options}const pathToFileURL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"pathToFileURL\"),fileURLToPath=globalThis[globalThis.Symbol.for('Bun.lazy')](\"fileURLToPath\");return{parse:urlParse,resolve:urlResolve,resolveObject:urlResolveObject,format:urlFormat,Url,URLSearchParams,URL,pathToFileURL,fileURLToPath,urlToHttpOptions}})\n"_s; +// + +// static constexpr ASCIILiteral NodeUtilCode = "(function (){\"use strict\";const types=@requireNativeModule(\"node:util/types\");var cjs_exports={};function isBufferInterface({copy,fill,readUint8}){return typeof copy===\"function\"&&typeof fill===\"function\"&&typeof readUint8===\"function\"}function isBuffer(value){return Buffer.isBuffer(value)||typeof value===\"object\"&&isBufferInterface(value||{})}function isFunction(value){return typeof value===\"function\"}const deepEquals=Bun.deepEquals,isDeepStrictEqual=(a,b)=>deepEquals(a,b,!0);var getOwnPropertyDescriptors=Object.getOwnPropertyDescriptors,formatRegExp=/%[sdj%]/g;function format(f){if(!isString(f)){var objects=[];for(var i=0;i=len)return x2;switch(x2){case\"%s\":return String(args[i++]);case\"%d\":return Number(args[i++]);case\"%j\":try{return JSON.stringify(args[i++])}catch(_){return\"[Circular]\"}default:return x2}});for(var x=args[i];i=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts))ctx.showHidden=opts;else if(opts)_extend(ctx,opts);if(isUndefined(ctx.showHidden))ctx.showHidden=!1;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=!1;if(isUndefined(ctx.customInspect))ctx.customInspect=!0;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:\"cyan\",number:\"yellow\",boolean:\"yellow\",undefined:\"grey\",null:\"bold\",string:\"green\",date:\"magenta\",regexp:\"red\"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style)return\"\\x1B[\"+inspect.colors[style][0]+\"m\"+str+\"\\x1B[\"+inspect.colors[style][1]+\"m\";else return str}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};return array.forEach(function(val,idx){hash[val]=!0}),hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret))ret=formatValue(ctx,ret,recurseTimes);return ret}var primitive=formatPrimitive(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=arrayToHash(keys);if(ctx.showHidden)keys=Object.getOwnPropertyNames(value);if(isError(value)&&(keys.indexOf(\"message\")>=0||keys.indexOf(\"description\")>=0))return formatError(value);if(keys.length===0){if(isFunction(value)){var name=value.name\?\": \"+value.name:\"\";return ctx.stylize(\"[Function\"+name+\"]\",\"special\")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),\"regexp\");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),\"date\");if(isError(value))return formatError(value)}var base=\"\",array=!1,braces=[\"{\",\"}\"];if(@isArray(value))array=!0,braces=[\"[\",\"]\"];if(isFunction(value)){var n=value.name\?\": \"+value.name:\"\";base=\" [Function\"+n+\"]\"}if(isRegExp(value))base=\" \"+RegExp.prototype.toString.call(value);if(isDate(value))base=\" \"+Date.prototype.toUTCString.call(value);if(isError(value))base=\" \"+formatError(value);if(keys.length===0&&(!array||value.length==0))return braces[0]+base+braces[1];if(recurseTimes<0)if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),\"regexp\");else return ctx.stylize(\"[Object]\",\"special\");ctx.seen.push(value);var output;if(array)output=formatArray(ctx,value,recurseTimes,visibleKeys,keys);else output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)});return ctx.seen.pop(),reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize(\"undefined\",\"undefined\");if(isString(value)){var simple=\"'\"+JSON.stringify(value).replace(/^\"|\"$/g,\"\").replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"')+\"'\";return ctx.stylize(simple,\"string\")}if(isNumber(value))return ctx.stylize(\"\"+value,\"number\");if(isBoolean(value))return ctx.stylize(\"\"+value,\"boolean\");if(isNull(value))return ctx.stylize(\"null\",\"null\")}function formatError(value){return\"[\"+Error.prototype.toString.call(value)+\"]\"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i-1)if(array)str=str.split(\"\\n\").map(function(line){return\" \"+line}).join(\"\\n\").substr(2);else str=\"\\n\"+str.split(\"\\n\").map(function(line){return\" \"+line}).join(\"\\n\")}else str=ctx.stylize(\"[Circular]\",\"special\");if(isUndefined(name)){if(array&&key.match(/^\\d+$/))return str;if(name=JSON.stringify(\"\"+key),name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/))name=name.substr(1,name.length-2),name=ctx.stylize(name,\"name\");else name=name.replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"').replace(/(^\"|\"$)/g,\"'\"),name=ctx.stylize(name,\"string\")}return name+\": \"+str}function reduceToSingleString(output,base,braces){var numLinesEst=0,length=output.reduce(function(prev,cur){if(numLinesEst++,cur.indexOf(\"\\n\")>=0)numLinesEst++;return prev+cur.replace(/\\u001b\\[\\d\\d\?m/g,\"\").length+1},0);if(length>60)return braces[0]+(base===\"\"\?\"\":base+\"\\n \")+\" \"+output.join(\",\\n \")+\" \"+braces[1];return braces[0]+base+\" \"+output.join(\", \")+\" \"+braces[1]}function isBoolean(arg){return typeof arg===\"boolean\"}function isNull(arg){return arg===null}function isNullOrUndefined(arg){return arg==null}function isNumber(arg){return typeof arg===\"number\"}function isString(arg){return typeof arg===\"string\"}function isSymbol(arg){return typeof arg===\"symbol\"}function isUndefined(arg){return arg===void 0}var isRegExp=types.isRegExp;function isObject(arg){return typeof arg===\"object\"&&arg!==null}var{isDate,isNativeError:isError}=types;function isPrimitive(arg){return arg===null||typeof arg===\"boolean\"||typeof arg===\"number\"||typeof arg===\"string\"||typeof arg===\"symbol\"||typeof arg===\"undefined\"}function pad(n){return n<10\?\"0\"+n.toString(10):n.toString(10)}var months=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];function timestamp(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(\":\");return[d.getDate(),months[d.getMonth()],time].join(\" \")}var log=function log(){console.log(\"%s - %s\",timestamp(),format.apply(cjs_exports,arguments))},inherits=function inherits(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})},_extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add),i=keys.length;while(i--)origin[keys[i]]=add[keys[i]];return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}var kCustomPromisifiedSymbol=Symbol.for(\"util.promisify.custom\"),promisify=function promisify(original){if(typeof original!==\"function\")@throwTypeError('The \"original\" argument must be of type Function');if(kCustomPromisifiedSymbol&&original[kCustomPromisifiedSymbol]){var fn=original[kCustomPromisifiedSymbol];if(typeof fn!==\"function\")@throwTypeError('The \"util.promisify.custom\" argument must be of type Function');return Object.defineProperty(fn,kCustomPromisifiedSymbol,{value:fn,enumerable:!1,writable:!1,configurable:!0}),fn}function fn(){var promiseResolve,promiseReject,promise=new Promise(function(resolve,reject){promiseResolve=resolve,promiseReject=reject}),args=[];for(var i=0;i{return(input+\"\").toWellFormed()};return Object.assign(cjs_exports,{format,deprecate,debuglog,_extend,inspect,types,isArray:@isArray,isBoolean,isNull,isNullOrUndefined,isNumber,isString,isSymbol,isUndefined,isRegExp,isObject,isDate,isFunction,isError,isPrimitive,isBuffer,log,inherits,toUSVString,promisify,callbackify,isDeepStrictEqual,TextDecoder,TextEncoder})})\n"_s; +// + +// static constexpr ASCIILiteral NodeV8Code = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),jsc=@requireNativeModule(\"bun:jsc\");function notimpl(message){throwNotImplemented(\"node:v8 \"+message)}class Deserializer{constructor(){notimpl(\"Deserializer\")}}class Serializer{constructor(){notimpl(\"Serializer\")}}class DefaultDeserializer extends Deserializer{constructor(){super(...arguments)}}class DefaultSerializer extends Serializer{constructor(){super(...arguments)}}class GCProfiler{constructor(){notimpl(\"GCProfiler\")}}function cachedDataVersionTag(){notimpl(\"cachedDataVersionTag\")}function getHeapSnapshot(){notimpl(\"getHeapSnapshot\")}function getHeapStatistics(){notimpl(\"getHeapStatistics\")}function getHeapSpaceStatistics(){notimpl(\"getHeapSpaceStatistics\")}function getHeapCodeStatistics(){notimpl(\"getHeapCodeStatistics\")}function setFlagsFromString(){notimpl(\"setFlagsFromString\")}function deserialize(value){return jsc.deserialize(value)}function takeCoverage(){notimpl(\"takeCoverage\")}function stopCoverage(){notimpl(\"stopCoverage\")}function serialize(arg1){return jsc.serialize(arg1,{binaryType:\"nodebuffer\"})}function writeHeapSnapshot(){notimpl(\"writeHeapSnapshot\")}function setHeapSnapshotNearHeapLimit(){notimpl(\"setHeapSnapshotNearHeapLimit\")}return $={cachedDataVersionTag,getHeapSnapshot,getHeapStatistics,getHeapSpaceStatistics,getHeapCodeStatistics,setFlagsFromString,deserialize,takeCoverage,stopCoverage,serialize,writeHeapSnapshot,setHeapSnapshotNearHeapLimit,promiseHooks:{createHook:()=>{notimpl(\"createHook\")},onInit:()=>{notimpl(\"onInit\")},onBefore:()=>{notimpl(\"onBefore\")},onAfter:()=>{notimpl(\"onAfter\")},onSettled:()=>{notimpl(\"onSettled\")}},startupSnapshot:{addDeserializeCallback:()=>notimpl(\"addDeserializeCallback\"),addSerializeCallback:()=>notimpl(\"addSerializeCallback\"),setDeserializeMainFunction:()=>notimpl(\"setDeserializeMainFunction\"),isBuildingSnapshot:()=>notimpl(\"isBuildingSnapshot\")},Deserializer,Serializer},hideFromStack(notimpl,cachedDataVersionTag,getHeapSnapshot,getHeapStatistics,getHeapSpaceStatistics,getHeapCodeStatistics,setFlagsFromString,deserialize,takeCoverage,stopCoverage,serialize,writeHeapSnapshot,setHeapSnapshotNearHeapLimit,Deserializer,Serializer,DefaultDeserializer,DefaultSerializer,GCProfiler),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeVMCode = "(function (){\"use strict\";const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),vm=globalThis[globalThis.Symbol.for('Bun.lazy')](\"vm\"),{createContext,isContext,Script,runInNewContext,runInThisContext}=vm;function runInContext(code,context,options){return new Script(code,options).runInContext(context)}function compileFunction(){throwNotImplemented(\"node:vm compileFunction\")}function measureMemory(){throwNotImplemented(\"node:vm measureMemory\")}class Module{constructor(){throwNotImplemented(\"node:vm Module\")}}class SourceTextModule{constructor(){throwNotImplemented(\"node:vm Module\")}}class SyntheticModule{constructor(){throwNotImplemented(\"node:vm Module\")}}return{createContext,runInContext,runInNewContext,runInThisContext,isContext,compileFunction,measureMemory,Script,Module,SourceTextModule,SyntheticModule}})\n"_s; +// + +// static constexpr ASCIILiteral NodeWasiCode = "(function (){\"use strict\";const nodeFsConstants=@processBindingConstants.fs;var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require2(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_types=__commonJS({\"node_modules/wasi-js/dist/types.js\"(exports){Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.WASIKillError=exports.WASIExitError=exports.WASIError=void 0;var WASIError=class extends Error{constructor(errno){super();this.errno=errno,Object.setPrototypeOf(this,WASIError.prototype)}};exports.WASIError=WASIError;var WASIExitError=class extends Error{constructor(code){super(`WASI Exit error: ${code}`);this.code=code,Object.setPrototypeOf(this,WASIExitError.prototype)}};exports.WASIExitError=WASIExitError;var WASIKillError=class extends Error{constructor(signal){super(`WASI Kill signal: ${signal}`);this.signal=signal,Object.setPrototypeOf(this,WASIKillError.prototype)}};exports.WASIKillError=WASIKillError}}),require_constants=__commonJS({\"node_modules/wasi-js/dist/constants.js\"(exports){Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.WASI_ENOMSG=exports.WASI_ENOMEM=exports.WASI_ENOLINK=exports.WASI_ENOLCK=exports.WASI_ENOEXEC=exports.WASI_ENOENT=exports.WASI_ENODEV=exports.WASI_ENOBUFS=exports.WASI_ENFILE=exports.WASI_ENETUNREACH=exports.WASI_ENETRESET=exports.WASI_ENETDOWN=exports.WASI_ENAMETOOLONG=exports.WASI_EMULTIHOP=exports.WASI_EMSGSIZE=exports.WASI_EMLINK=exports.WASI_EMFILE=exports.WASI_ELOOP=exports.WASI_EISDIR=exports.WASI_EISCONN=exports.WASI_EIO=exports.WASI_EINVAL=exports.WASI_EINTR=exports.WASI_EINPROGRESS=exports.WASI_EILSEQ=exports.WASI_EIDRM=exports.WASI_EHOSTUNREACH=exports.WASI_EFBIG=exports.WASI_EFAULT=exports.WASI_EEXIST=exports.WASI_EDQUOT=exports.WASI_EDOM=exports.WASI_EDESTADDRREQ=exports.WASI_EDEADLK=exports.WASI_ECONNRESET=exports.WASI_ECONNREFUSED=exports.WASI_ECONNABORTED=exports.WASI_ECHILD=exports.WASI_ECANCELED=exports.WASI_EBUSY=exports.WASI_EBADMSG=exports.WASI_EBADF=exports.WASI_EALREADY=exports.WASI_EAGAIN=exports.WASI_EAFNOSUPPORT=exports.WASI_EADDRNOTAVAIL=exports.WASI_EADDRINUSE=exports.WASI_EACCES=exports.WASI_E2BIG=exports.WASI_ESUCCESS=void 0,exports.WASI_SIGVTALRM=exports.WASI_SIGUSR2=exports.WASI_SIGUSR1=exports.WASI_SIGURG=exports.WASI_SIGTTOU=exports.WASI_SIGTTIN=exports.WASI_SIGTSTP=exports.WASI_SIGTRAP=exports.WASI_SIGTERM=exports.WASI_SIGSTOP=exports.WASI_SIGSEGV=exports.WASI_SIGQUIT=exports.WASI_SIGPIPE=exports.WASI_SIGKILL=exports.WASI_SIGINT=exports.WASI_SIGILL=exports.WASI_SIGHUP=exports.WASI_SIGFPE=exports.WASI_SIGCONT=exports.WASI_SIGCHLD=exports.WASI_SIGBUS=exports.WASI_SIGALRM=exports.WASI_SIGABRT=exports.WASI_ENOTCAPABLE=exports.WASI_EXDEV=exports.WASI_ETXTBSY=exports.WASI_ETIMEDOUT=exports.WASI_ESTALE=exports.WASI_ESRCH=exports.WASI_ESPIPE=exports.WASI_EROFS=exports.WASI_ERANGE=exports.WASI_EPROTOTYPE=exports.WASI_EPROTONOSUPPORT=exports.WASI_EPROTO=exports.WASI_EPIPE=exports.WASI_EPERM=exports.WASI_EOWNERDEAD=exports.WASI_EOVERFLOW=exports.WASI_ENXIO=exports.WASI_ENOTTY=exports.WASI_ENOTSUP=exports.WASI_ENOTSOCK=exports.WASI_ENOTRECOVERABLE=exports.WASI_ENOTEMPTY=exports.WASI_ENOTDIR=exports.WASI_ENOTCONN=exports.WASI_ENOSYS=exports.WASI_ENOSPC=exports.WASI_ENOPROTOOPT=void 0,exports.RIGHTS_REGULAR_FILE_BASE=exports.RIGHTS_CHARACTER_DEVICE_INHERITING=exports.RIGHTS_CHARACTER_DEVICE_BASE=exports.RIGHTS_BLOCK_DEVICE_INHERITING=exports.RIGHTS_BLOCK_DEVICE_BASE=exports.RIGHTS_ALL=exports.WASI_RIGHT_SOCK_SHUTDOWN=exports.WASI_RIGHT_POLL_FD_READWRITE=exports.WASI_RIGHT_PATH_UNLINK_FILE=exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY=exports.WASI_RIGHT_PATH_SYMLINK=exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES=exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE=exports.WASI_RIGHT_FD_FILESTAT_GET=exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES=exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE=exports.WASI_RIGHT_PATH_FILESTAT_GET=exports.WASI_RIGHT_PATH_RENAME_TARGET=exports.WASI_RIGHT_PATH_RENAME_SOURCE=exports.WASI_RIGHT_PATH_READLINK=exports.WASI_RIGHT_FD_READDIR=exports.WASI_RIGHT_PATH_OPEN=exports.WASI_RIGHT_PATH_LINK_TARGET=exports.WASI_RIGHT_PATH_LINK_SOURCE=exports.WASI_RIGHT_PATH_CREATE_FILE=exports.WASI_RIGHT_PATH_CREATE_DIRECTORY=exports.WASI_RIGHT_FD_ALLOCATE=exports.WASI_RIGHT_FD_ADVISE=exports.WASI_RIGHT_FD_WRITE=exports.WASI_RIGHT_FD_TELL=exports.WASI_RIGHT_FD_SYNC=exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS=exports.WASI_RIGHT_FD_SEEK=exports.WASI_RIGHT_FD_READ=exports.WASI_RIGHT_FD_DATASYNC=exports.WASI_FDFLAG_SYNC=exports.WASI_FDFLAG_RSYNC=exports.WASI_FDFLAG_NONBLOCK=exports.WASI_FDFLAG_DSYNC=exports.WASI_FDFLAG_APPEND=exports.WASI_FILETYPE_SYMBOLIC_LINK=exports.WASI_FILETYPE_SOCKET_STREAM=exports.WASI_FILETYPE_SOCKET_DGRAM=exports.WASI_FILETYPE_REGULAR_FILE=exports.WASI_FILETYPE_DIRECTORY=exports.WASI_FILETYPE_CHARACTER_DEVICE=exports.WASI_FILETYPE_BLOCK_DEVICE=exports.WASI_FILETYPE_UNKNOWN=exports.WASI_SIGXFSZ=exports.WASI_SIGXCPU=void 0,exports.SIGNAL_MAP=exports.ERROR_MAP=exports.WASI_WHENCE_END=exports.WASI_WHENCE_CUR=exports.WASI_WHENCE_SET=exports.WASI_STDERR_FILENO=exports.WASI_STDOUT_FILENO=exports.WASI_STDIN_FILENO=exports.WASI_DIRCOOKIE_START=exports.WASI_PREOPENTYPE_DIR=exports.WASI_O_TRUNC=exports.WASI_O_EXCL=exports.WASI_O_DIRECTORY=exports.WASI_O_CREAT=exports.WASI_FILESTAT_SET_MTIM_NOW=exports.WASI_FILESTAT_SET_MTIM=exports.WASI_FILESTAT_SET_ATIM_NOW=exports.WASI_FILESTAT_SET_ATIM=exports.WASI_EVENTTYPE_FD_WRITE=exports.WASI_EVENTTYPE_FD_READ=exports.WASI_EVENTTYPE_CLOCK=exports.WASI_CLOCK_THREAD_CPUTIME_ID=exports.WASI_CLOCK_PROCESS_CPUTIME_ID=exports.WASI_CLOCK_MONOTONIC=exports.WASI_CLOCK_REALTIME=exports.RIGHTS_TTY_INHERITING=exports.RIGHTS_TTY_BASE=exports.RIGHTS_SOCKET_INHERITING=exports.RIGHTS_SOCKET_BASE=exports.RIGHTS_DIRECTORY_INHERITING=exports.RIGHTS_DIRECTORY_BASE=exports.RIGHTS_REGULAR_FILE_INHERITING=void 0,exports.WASI_ESUCCESS=0,exports.WASI_E2BIG=1,exports.WASI_EACCES=2,exports.WASI_EADDRINUSE=3,exports.WASI_EADDRNOTAVAIL=4,exports.WASI_EAFNOSUPPORT=5,exports.WASI_EAGAIN=6,exports.WASI_EALREADY=7,exports.WASI_EBADF=8,exports.WASI_EBADMSG=9,exports.WASI_EBUSY=10,exports.WASI_ECANCELED=11,exports.WASI_ECHILD=12,exports.WASI_ECONNABORTED=13,exports.WASI_ECONNREFUSED=14,exports.WASI_ECONNRESET=15,exports.WASI_EDEADLK=16,exports.WASI_EDESTADDRREQ=17,exports.WASI_EDOM=18,exports.WASI_EDQUOT=19,exports.WASI_EEXIST=20,exports.WASI_EFAULT=21,exports.WASI_EFBIG=22,exports.WASI_EHOSTUNREACH=23,exports.WASI_EIDRM=24,exports.WASI_EILSEQ=25,exports.WASI_EINPROGRESS=26,exports.WASI_EINTR=27,exports.WASI_EINVAL=28,exports.WASI_EIO=29,exports.WASI_EISCONN=30,exports.WASI_EISDIR=31,exports.WASI_ELOOP=32,exports.WASI_EMFILE=33,exports.WASI_EMLINK=34,exports.WASI_EMSGSIZE=35,exports.WASI_EMULTIHOP=36,exports.WASI_ENAMETOOLONG=37,exports.WASI_ENETDOWN=38,exports.WASI_ENETRESET=39,exports.WASI_ENETUNREACH=40,exports.WASI_ENFILE=41,exports.WASI_ENOBUFS=42,exports.WASI_ENODEV=43,exports.WASI_ENOENT=44,exports.WASI_ENOEXEC=45,exports.WASI_ENOLCK=46,exports.WASI_ENOLINK=47,exports.WASI_ENOMEM=48,exports.WASI_ENOMSG=49,exports.WASI_ENOPROTOOPT=50,exports.WASI_ENOSPC=51,exports.WASI_ENOSYS=52,exports.WASI_ENOTCONN=53,exports.WASI_ENOTDIR=54,exports.WASI_ENOTEMPTY=55,exports.WASI_ENOTRECOVERABLE=56,exports.WASI_ENOTSOCK=57,exports.WASI_ENOTSUP=58,exports.WASI_ENOTTY=59,exports.WASI_ENXIO=60,exports.WASI_EOVERFLOW=61,exports.WASI_EOWNERDEAD=62,exports.WASI_EPERM=63,exports.WASI_EPIPE=64,exports.WASI_EPROTO=65,exports.WASI_EPROTONOSUPPORT=66,exports.WASI_EPROTOTYPE=67,exports.WASI_ERANGE=68,exports.WASI_EROFS=69,exports.WASI_ESPIPE=70,exports.WASI_ESRCH=71,exports.WASI_ESTALE=72,exports.WASI_ETIMEDOUT=73,exports.WASI_ETXTBSY=74,exports.WASI_EXDEV=75,exports.WASI_ENOTCAPABLE=76,exports.WASI_SIGABRT=0,exports.WASI_SIGALRM=1,exports.WASI_SIGBUS=2,exports.WASI_SIGCHLD=3,exports.WASI_SIGCONT=4,exports.WASI_SIGFPE=5,exports.WASI_SIGHUP=6,exports.WASI_SIGILL=7,exports.WASI_SIGINT=8,exports.WASI_SIGKILL=9,exports.WASI_SIGPIPE=10,exports.WASI_SIGQUIT=11,exports.WASI_SIGSEGV=12,exports.WASI_SIGSTOP=13,exports.WASI_SIGTERM=14,exports.WASI_SIGTRAP=15,exports.WASI_SIGTSTP=16,exports.WASI_SIGTTIN=17,exports.WASI_SIGTTOU=18,exports.WASI_SIGURG=19,exports.WASI_SIGUSR1=20,exports.WASI_SIGUSR2=21,exports.WASI_SIGVTALRM=22,exports.WASI_SIGXCPU=23,exports.WASI_SIGXFSZ=24,exports.WASI_FILETYPE_UNKNOWN=0,exports.WASI_FILETYPE_BLOCK_DEVICE=1,exports.WASI_FILETYPE_CHARACTER_DEVICE=2,exports.WASI_FILETYPE_DIRECTORY=3,exports.WASI_FILETYPE_REGULAR_FILE=4,exports.WASI_FILETYPE_SOCKET_DGRAM=5,exports.WASI_FILETYPE_SOCKET_STREAM=6,exports.WASI_FILETYPE_SYMBOLIC_LINK=7,exports.WASI_FDFLAG_APPEND=1,exports.WASI_FDFLAG_DSYNC=2,exports.WASI_FDFLAG_NONBLOCK=4,exports.WASI_FDFLAG_RSYNC=8,exports.WASI_FDFLAG_SYNC=16,exports.WASI_RIGHT_FD_DATASYNC=BigInt(1),exports.WASI_RIGHT_FD_READ=BigInt(2),exports.WASI_RIGHT_FD_SEEK=BigInt(4),exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS=BigInt(8),exports.WASI_RIGHT_FD_SYNC=BigInt(16),exports.WASI_RIGHT_FD_TELL=BigInt(32),exports.WASI_RIGHT_FD_WRITE=BigInt(64),exports.WASI_RIGHT_FD_ADVISE=BigInt(128),exports.WASI_RIGHT_FD_ALLOCATE=BigInt(256),exports.WASI_RIGHT_PATH_CREATE_DIRECTORY=BigInt(512),exports.WASI_RIGHT_PATH_CREATE_FILE=BigInt(1024),exports.WASI_RIGHT_PATH_LINK_SOURCE=BigInt(2048),exports.WASI_RIGHT_PATH_LINK_TARGET=BigInt(4096),exports.WASI_RIGHT_PATH_OPEN=BigInt(8192),exports.WASI_RIGHT_FD_READDIR=BigInt(16384),exports.WASI_RIGHT_PATH_READLINK=BigInt(32768),exports.WASI_RIGHT_PATH_RENAME_SOURCE=BigInt(65536),exports.WASI_RIGHT_PATH_RENAME_TARGET=BigInt(131072),exports.WASI_RIGHT_PATH_FILESTAT_GET=BigInt(262144),exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE=BigInt(524288),exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES=BigInt(1048576),exports.WASI_RIGHT_FD_FILESTAT_GET=BigInt(2097152),exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE=BigInt(4194304),exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES=BigInt(8388608),exports.WASI_RIGHT_PATH_SYMLINK=BigInt(16777216),exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY=BigInt(33554432),exports.WASI_RIGHT_PATH_UNLINK_FILE=BigInt(67108864),exports.WASI_RIGHT_POLL_FD_READWRITE=BigInt(134217728),exports.WASI_RIGHT_SOCK_SHUTDOWN=BigInt(268435456),exports.RIGHTS_ALL=exports.WASI_RIGHT_FD_DATASYNC|exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_SEEK|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_TELL|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_FD_ALLOCATE|exports.WASI_RIGHT_PATH_CREATE_DIRECTORY|exports.WASI_RIGHT_PATH_CREATE_FILE|exports.WASI_RIGHT_PATH_LINK_SOURCE|exports.WASI_RIGHT_PATH_LINK_TARGET|exports.WASI_RIGHT_PATH_OPEN|exports.WASI_RIGHT_FD_READDIR|exports.WASI_RIGHT_PATH_READLINK|exports.WASI_RIGHT_PATH_RENAME_SOURCE|exports.WASI_RIGHT_PATH_RENAME_TARGET|exports.WASI_RIGHT_PATH_FILESTAT_GET|exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_SYMLINK|exports.WASI_RIGHT_PATH_UNLINK_FILE|exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY|exports.WASI_RIGHT_POLL_FD_READWRITE|exports.WASI_RIGHT_SOCK_SHUTDOWN,exports.RIGHTS_BLOCK_DEVICE_BASE=exports.RIGHTS_ALL,exports.RIGHTS_BLOCK_DEVICE_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_CHARACTER_DEVICE_BASE=exports.RIGHTS_ALL,exports.RIGHTS_CHARACTER_DEVICE_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_REGULAR_FILE_BASE=exports.WASI_RIGHT_FD_DATASYNC|exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_SEEK|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_TELL|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_FD_ALLOCATE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_REGULAR_FILE_INHERITING=BigInt(0),exports.RIGHTS_DIRECTORY_BASE=exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_PATH_CREATE_DIRECTORY|exports.WASI_RIGHT_PATH_CREATE_FILE|exports.WASI_RIGHT_PATH_LINK_SOURCE|exports.WASI_RIGHT_PATH_LINK_TARGET|exports.WASI_RIGHT_PATH_OPEN|exports.WASI_RIGHT_FD_READDIR|exports.WASI_RIGHT_PATH_READLINK|exports.WASI_RIGHT_PATH_RENAME_SOURCE|exports.WASI_RIGHT_PATH_RENAME_TARGET|exports.WASI_RIGHT_PATH_FILESTAT_GET|exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_PATH_SYMLINK|exports.WASI_RIGHT_PATH_UNLINK_FILE|exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_DIRECTORY_INHERITING=exports.RIGHTS_DIRECTORY_BASE|exports.RIGHTS_REGULAR_FILE_BASE,exports.RIGHTS_SOCKET_BASE=exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_POLL_FD_READWRITE|exports.WASI_RIGHT_SOCK_SHUTDOWN,exports.RIGHTS_SOCKET_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_TTY_BASE=exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_TTY_INHERITING=BigInt(0),exports.WASI_CLOCK_REALTIME=0,exports.WASI_CLOCK_MONOTONIC=1,exports.WASI_CLOCK_PROCESS_CPUTIME_ID=2,exports.WASI_CLOCK_THREAD_CPUTIME_ID=3,exports.WASI_EVENTTYPE_CLOCK=0,exports.WASI_EVENTTYPE_FD_READ=1,exports.WASI_EVENTTYPE_FD_WRITE=2,exports.WASI_FILESTAT_SET_ATIM=1<<0,exports.WASI_FILESTAT_SET_ATIM_NOW=1<<1,exports.WASI_FILESTAT_SET_MTIM=1<<2,exports.WASI_FILESTAT_SET_MTIM_NOW=1<<3,exports.WASI_O_CREAT=1<<0,exports.WASI_O_DIRECTORY=1<<1,exports.WASI_O_EXCL=1<<2,exports.WASI_O_TRUNC=1<<3,exports.WASI_PREOPENTYPE_DIR=0,exports.WASI_DIRCOOKIE_START=0,exports.WASI_STDIN_FILENO=0,exports.WASI_STDOUT_FILENO=1,exports.WASI_STDERR_FILENO=2,exports.WASI_WHENCE_SET=0,exports.WASI_WHENCE_CUR=1,exports.WASI_WHENCE_END=2,exports.ERROR_MAP={E2BIG:exports.WASI_E2BIG,EACCES:exports.WASI_EACCES,EADDRINUSE:exports.WASI_EADDRINUSE,EADDRNOTAVAIL:exports.WASI_EADDRNOTAVAIL,EAFNOSUPPORT:exports.WASI_EAFNOSUPPORT,EALREADY:exports.WASI_EALREADY,EAGAIN:exports.WASI_EAGAIN,EBADF:exports.WASI_EBADF,EBADMSG:exports.WASI_EBADMSG,EBUSY:exports.WASI_EBUSY,ECANCELED:exports.WASI_ECANCELED,ECHILD:exports.WASI_ECHILD,ECONNABORTED:exports.WASI_ECONNABORTED,ECONNREFUSED:exports.WASI_ECONNREFUSED,ECONNRESET:exports.WASI_ECONNRESET,EDEADLOCK:exports.WASI_EDEADLK,EDESTADDRREQ:exports.WASI_EDESTADDRREQ,EDOM:exports.WASI_EDOM,EDQUOT:exports.WASI_EDQUOT,EEXIST:exports.WASI_EEXIST,EFAULT:exports.WASI_EFAULT,EFBIG:exports.WASI_EFBIG,EHOSTDOWN:exports.WASI_EHOSTUNREACH,EHOSTUNREACH:exports.WASI_EHOSTUNREACH,EIDRM:exports.WASI_EIDRM,EILSEQ:exports.WASI_EILSEQ,EINPROGRESS:exports.WASI_EINPROGRESS,EINTR:exports.WASI_EINTR,EINVAL:exports.WASI_EINVAL,EIO:exports.WASI_EIO,EISCONN:exports.WASI_EISCONN,EISDIR:exports.WASI_EISDIR,ELOOP:exports.WASI_ELOOP,EMFILE:exports.WASI_EMFILE,EMLINK:exports.WASI_EMLINK,EMSGSIZE:exports.WASI_EMSGSIZE,EMULTIHOP:exports.WASI_EMULTIHOP,ENAMETOOLONG:exports.WASI_ENAMETOOLONG,ENETDOWN:exports.WASI_ENETDOWN,ENETRESET:exports.WASI_ENETRESET,ENETUNREACH:exports.WASI_ENETUNREACH,ENFILE:exports.WASI_ENFILE,ENOBUFS:exports.WASI_ENOBUFS,ENODEV:exports.WASI_ENODEV,ENOENT:exports.WASI_ENOENT,ENOEXEC:exports.WASI_ENOEXEC,ENOLCK:exports.WASI_ENOLCK,ENOLINK:exports.WASI_ENOLINK,ENOMEM:exports.WASI_ENOMEM,ENOMSG:exports.WASI_ENOMSG,ENOPROTOOPT:exports.WASI_ENOPROTOOPT,ENOSPC:exports.WASI_ENOSPC,ENOSYS:exports.WASI_ENOSYS,ENOTCONN:exports.WASI_ENOTCONN,ENOTDIR:exports.WASI_ENOTDIR,ENOTEMPTY:exports.WASI_ENOTEMPTY,ENOTRECOVERABLE:exports.WASI_ENOTRECOVERABLE,ENOTSOCK:exports.WASI_ENOTSOCK,ENOTTY:exports.WASI_ENOTTY,ENXIO:exports.WASI_ENXIO,EOVERFLOW:exports.WASI_EOVERFLOW,EOWNERDEAD:exports.WASI_EOWNERDEAD,EPERM:exports.WASI_EPERM,EPIPE:exports.WASI_EPIPE,EPROTO:exports.WASI_EPROTO,EPROTONOSUPPORT:exports.WASI_EPROTONOSUPPORT,EPROTOTYPE:exports.WASI_EPROTOTYPE,ERANGE:exports.WASI_ERANGE,EROFS:exports.WASI_EROFS,ESPIPE:exports.WASI_ESPIPE,ESRCH:exports.WASI_ESRCH,ESTALE:exports.WASI_ESTALE,ETIMEDOUT:exports.WASI_ETIMEDOUT,ETXTBSY:exports.WASI_ETXTBSY,EXDEV:exports.WASI_EXDEV},exports.SIGNAL_MAP={[exports.WASI_SIGHUP]:\"SIGHUP\",[exports.WASI_SIGINT]:\"SIGINT\",[exports.WASI_SIGQUIT]:\"SIGQUIT\",[exports.WASI_SIGILL]:\"SIGILL\",[exports.WASI_SIGTRAP]:\"SIGTRAP\",[exports.WASI_SIGABRT]:\"SIGABRT\",[exports.WASI_SIGBUS]:\"SIGBUS\",[exports.WASI_SIGFPE]:\"SIGFPE\",[exports.WASI_SIGKILL]:\"SIGKILL\",[exports.WASI_SIGUSR1]:\"SIGUSR1\",[exports.WASI_SIGSEGV]:\"SIGSEGV\",[exports.WASI_SIGUSR2]:\"SIGUSR2\",[exports.WASI_SIGPIPE]:\"SIGPIPE\",[exports.WASI_SIGALRM]:\"SIGALRM\",[exports.WASI_SIGTERM]:\"SIGTERM\",[exports.WASI_SIGCHLD]:\"SIGCHLD\",[exports.WASI_SIGCONT]:\"SIGCONT\",[exports.WASI_SIGSTOP]:\"SIGSTOP\",[exports.WASI_SIGTSTP]:\"SIGTSTP\",[exports.WASI_SIGTTIN]:\"SIGTTIN\",[exports.WASI_SIGTTOU]:\"SIGTTOU\",[exports.WASI_SIGURG]:\"SIGURG\",[exports.WASI_SIGXCPU]:\"SIGXCPU\",[exports.WASI_SIGXFSZ]:\"SIGXFSZ\",[exports.WASI_SIGVTALRM]:\"SIGVTALRM\"}}}),require_wasi=__commonJS({\"node_modules/wasi-js/dist/wasi.js\"(exports){var __importDefault=exports&&exports.__importDefault||function(mod){return mod&&mod.__esModule\?mod:{default:mod}};let fs;Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.SOCKET_DEFAULT_RIGHTS=void 0;var log=()=>{},logOpen=()=>{},SC_OPEN_MAX=32768,types_1=require_types(),constants_1=require_constants(),STDIN_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_SYNC|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE,STDOUT_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_SYNC|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE,STDERR_DEFAULT_RIGHTS=STDOUT_DEFAULT_RIGHTS;exports.SOCKET_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE|constants_1.WASI_RIGHT_FD_FDSTAT_SET_FLAGS;var msToNs=(ms)=>{const msInt=Math.trunc(ms),decimal=BigInt(Math.round((ms-msInt)*1e6));return BigInt(msInt)*BigInt(1e6)+decimal},nsToMs=(ns)=>{if(typeof ns===\"number\")ns=Math.trunc(ns);const nsInt=BigInt(ns);return Number(nsInt/BigInt(1e6))},wrap=(f)=>(...args)=>{try{return f(...args)}catch(err){let e=err;while(e.prev!=null)e=e.prev;if(e\?.code&&typeof e\?.code===\"string\")return constants_1.ERROR_MAP[e.code]||constants_1.WASI_EINVAL;if(e instanceof types_1.WASIError)return e.errno;throw e}},stat=(wasi,fd)=>{const entry=wasi.FD_MAP.get(fd);if(!entry)throw new types_1.WASIError(constants_1.WASI_EBADF);if(entry.filetype===void 0){const stats=wasi.fstatSync(entry.real),{filetype,rightsBase,rightsInheriting}=translateFileAttributes(wasi,fd,stats);if(entry.filetype=filetype,!entry.rights)entry.rights={base:rightsBase,inheriting:rightsInheriting}}return entry},translateFileAttributes=(wasi,fd,stats)=>{switch(!0){case stats.isBlockDevice():return{filetype:constants_1.WASI_FILETYPE_BLOCK_DEVICE,rightsBase:constants_1.RIGHTS_BLOCK_DEVICE_BASE,rightsInheriting:constants_1.RIGHTS_BLOCK_DEVICE_INHERITING};case stats.isCharacterDevice():{const filetype=constants_1.WASI_FILETYPE_CHARACTER_DEVICE;if(fd!==void 0&&wasi.bindings.isTTY(fd))return{filetype,rightsBase:constants_1.RIGHTS_TTY_BASE,rightsInheriting:constants_1.RIGHTS_TTY_INHERITING};return{filetype,rightsBase:constants_1.RIGHTS_CHARACTER_DEVICE_BASE,rightsInheriting:constants_1.RIGHTS_CHARACTER_DEVICE_INHERITING}}case stats.isDirectory():return{filetype:constants_1.WASI_FILETYPE_DIRECTORY,rightsBase:constants_1.RIGHTS_DIRECTORY_BASE,rightsInheriting:constants_1.RIGHTS_DIRECTORY_INHERITING};case stats.isFIFO():return{filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rightsBase:constants_1.RIGHTS_SOCKET_BASE,rightsInheriting:constants_1.RIGHTS_SOCKET_INHERITING};case stats.isFile():return{filetype:constants_1.WASI_FILETYPE_REGULAR_FILE,rightsBase:constants_1.RIGHTS_REGULAR_FILE_BASE,rightsInheriting:constants_1.RIGHTS_REGULAR_FILE_INHERITING};case stats.isSocket():return{filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rightsBase:constants_1.RIGHTS_SOCKET_BASE,rightsInheriting:constants_1.RIGHTS_SOCKET_INHERITING};case stats.isSymbolicLink():return{filetype:constants_1.WASI_FILETYPE_SYMBOLIC_LINK,rightsBase:BigInt(0),rightsInheriting:BigInt(0)};default:return{filetype:constants_1.WASI_FILETYPE_UNKNOWN,rightsBase:BigInt(0),rightsInheriting:BigInt(0)}}},warnedAboutSleep=!1,defaultConfig;function getDefaults(){if(defaultConfig)return defaultConfig;const defaultBindings={hrtime:()=>process.hrtime.bigint(),exit:(code)=>{process.exit(code)},kill:(signal)=>{process.kill(process.pid,signal)},randomFillSync:(array)=>crypto.getRandomValues(array),isTTY:(fd)=>@requireNativeModule(\"node:tty\").isatty(fd),fs:Bun.fs(),path:@getInternalField(@internalModuleRegistry,25)||@createInternalModuleById(25)};return defaultConfig={args:[],env:{},preopens:{},bindings:defaultBindings,sleep:(ms)=>{Bun.sleepSync(ms)}}}var WASI=class WASI2{constructor(wasiConfig={}){const defaultConfig2=getDefaults();this.lastStdin=0,this.sleep=wasiConfig.sleep||defaultConfig2.sleep,this.getStdin=wasiConfig.getStdin,this.sendStdout=wasiConfig.sendStdout,this.sendStderr=wasiConfig.sendStderr;let preopens=wasiConfig.preopens\?\?defaultConfig2.preopens;this.env=wasiConfig.env\?\?defaultConfig2.env;const args=wasiConfig.args\?\?defaultConfig2.args;this.memory=void 0,this.view=void 0,this.bindings=wasiConfig.bindings||defaultConfig2.bindings;const bindings2=this.bindings;fs=bindings2.fs,this.FD_MAP=new Map([[constants_1.WASI_STDIN_FILENO,{real:0,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDIN_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stdin\"}],[constants_1.WASI_STDOUT_FILENO,{real:1,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDOUT_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stdout\"}],[constants_1.WASI_STDERR_FILENO,{real:2,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDERR_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stderr\"}]]);const path=bindings2.path;for(let[k,v]of Object.entries(preopens)){const real=fs.openSync(v,nodeFsConstants.O_RDONLY),newfd=this.getUnusedFileDescriptor();this.FD_MAP.set(newfd,{real,filetype:constants_1.WASI_FILETYPE_DIRECTORY,rights:{base:constants_1.RIGHTS_DIRECTORY_BASE,inheriting:constants_1.RIGHTS_DIRECTORY_INHERITING},fakePath:k,path:v})}const getiovs=(iovs,iovsLen)=>{this.refreshMemory();const{view,memory}=this,{buffer}=memory,{byteLength}=buffer;if(iovsLen===1){const ptr=iovs,buf=view.getUint32(ptr,!0);let bufLen=view.getUint32(ptr+4,!0);if(bufLen>byteLength-buf)console.log({buf,bufLen,total_memory:byteLength}),log(\"getiovs: warning -- truncating buffer to fit in memory\"),bufLen=Math.min(bufLen,Math.max(0,byteLength-buf));try{return[new Uint8Array(buffer,buf,bufLen)]}catch(err){throw console.warn(\"WASI.getiovs -- invalid buffer\",err),new types_1.WASIError(constants_1.WASI_EINVAL)}}const buffers=[];buffers.length=iovsLen;for(let i=0,ptr=iovs;ibyteLength-buf)console.log({buf,bufLen,total_memory:byteLength}),log(\"getiovs: warning -- truncating buffer to fit in memory\"),bufLen=Math.min(bufLen,Math.max(0,byteLength-buf));try{buffers[i]=new Uint8Array(buffer,buf,bufLen)}catch(err){throw console.warn(\"WASI.getiovs -- invalid buffer\",err),new types_1.WASIError(constants_1.WASI_EINVAL)}}return buffers},CHECK_FD=(fd,rights)=>{const stats=stat(this,fd);if(rights!==BigInt(0)&&(stats.rights.base&rights)===BigInt(0))throw new types_1.WASIError(constants_1.WASI_EPERM);return stats},CPUTIME_START=Bun.nanoseconds(),timeOrigin=Math.trunc(performance.timeOrigin*1e6),now=(clockId)=>{switch(clockId){case constants_1.WASI_CLOCK_MONOTONIC:return Bun.nanoseconds();case constants_1.WASI_CLOCK_REALTIME:return Bun.nanoseconds()+timeOrigin;case constants_1.WASI_CLOCK_PROCESS_CPUTIME_ID:case constants_1.WASI_CLOCK_THREAD_CPUTIME_ID:return Bun.nanoseconds()-CPUTIME_START;default:return null}};if(this.wasiImport={args_get:(argv,argvBuf)=>{this.refreshMemory();let coffset=argv,offset=argvBuf;return args.forEach((a)=>{this.view.setUint32(coffset,offset,!0),coffset+=4,offset+=Buffer.from(this.memory.buffer).write(`${a}\\0`,offset)}),constants_1.WASI_ESUCCESS},args_sizes_get:(argc,argvBufSize)=>{this.refreshMemory(),this.view.setUint32(argc,args.length,!0);const size=args.reduce((acc,a)=>acc+Buffer.byteLength(a)+1,0);return this.view.setUint32(argvBufSize,size,!0),constants_1.WASI_ESUCCESS},environ_get:(environ,environBuf)=>{this.refreshMemory();let coffset=environ,offset=environBuf;return Object.entries(this.env).forEach(([key,value])=>{this.view.setUint32(coffset,offset,!0),coffset+=4,offset+=Buffer.from(this.memory.buffer).write(`${key}=${value}\\0`,offset)}),constants_1.WASI_ESUCCESS},environ_sizes_get:(environCount,environBufSize)=>{this.refreshMemory();const envProcessed=Object.entries(this.env).map(([key,value])=>`${key}=${value}\\0`),size=envProcessed.reduce((acc,e)=>acc+Buffer.byteLength(e),0);return this.view.setUint32(environCount,envProcessed.length,!0),this.view.setUint32(environBufSize,size,!0),constants_1.WASI_ESUCCESS},clock_res_get:(clockId,resolution)=>{let res;switch(clockId){case constants_1.WASI_CLOCK_MONOTONIC:case constants_1.WASI_CLOCK_PROCESS_CPUTIME_ID:case constants_1.WASI_CLOCK_THREAD_CPUTIME_ID:{res=BigInt(1);break}case constants_1.WASI_CLOCK_REALTIME:{res=BigInt(1000);break}}if(!res)throw Error(\"invalid clockId\");return this.view.setBigUint64(resolution,res),constants_1.WASI_ESUCCESS},clock_time_get:(clockId,_precision,time)=>{this.refreshMemory();const n=now(clockId);if(n===null)return constants_1.WASI_EINVAL;return this.view.setBigUint64(time,BigInt(n),!0),constants_1.WASI_ESUCCESS},fd_advise:wrap((fd,_offset,_len,_advice)=>{return CHECK_FD(fd,constants_1.WASI_RIGHT_FD_ADVISE),constants_1.WASI_ENOSYS}),fd_allocate:wrap((fd,_offset,_len)=>{return CHECK_FD(fd,constants_1.WASI_RIGHT_FD_ALLOCATE),constants_1.WASI_ENOSYS}),fd_close:wrap((fd)=>{const stats=CHECK_FD(fd,BigInt(0));return fs.closeSync(stats.real),this.FD_MAP.delete(fd),constants_1.WASI_ESUCCESS}),fd_datasync:wrap((fd)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_DATASYNC);return fs.fdatasyncSync(stats.real),constants_1.WASI_ESUCCESS}),fd_fdstat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,BigInt(0));if(this.refreshMemory(),stats.filetype==null)throw Error(\"stats.filetype must be set\");return this.view.setUint8(bufPtr,stats.filetype),this.view.setUint16(bufPtr+2,0,!0),this.view.setUint16(bufPtr+4,0,!0),this.view.setBigUint64(bufPtr+8,BigInt(stats.rights.base),!0),this.view.setBigUint64(bufPtr+8+8,BigInt(stats.rights.inheriting),!0),constants_1.WASI_ESUCCESS}),fd_fdstat_set_flags:wrap((fd,flags)=>{if(CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FDSTAT_SET_FLAGS),this.wasiImport.sock_fcntlSetFlags(fd,flags)==0)return constants_1.WASI_ESUCCESS;return constants_1.WASI_ENOSYS}),fd_fdstat_set_rights:wrap((fd,fsRightsBase,fsRightsInheriting)=>{const stats=CHECK_FD(fd,BigInt(0));if((stats.rights.base|fsRightsBase)>stats.rights.base)return constants_1.WASI_EPERM;if((stats.rights.inheriting|fsRightsInheriting)>stats.rights.inheriting)return constants_1.WASI_EPERM;return stats.rights.base=fsRightsBase,stats.rights.inheriting=fsRightsInheriting,constants_1.WASI_ESUCCESS}),fd_filestat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_GET),rstats=this.fstatSync(stats.real);if(this.refreshMemory(),this.view.setBigUint64(bufPtr,BigInt(rstats.dev),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,stats.filetype==null)throw Error(\"stats.filetype must be set\");return this.view.setUint8(bufPtr,stats.filetype),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.nlink),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.size),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.atimeMs),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.mtimeMs),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.ctimeMs),!0),constants_1.WASI_ESUCCESS}),fd_filestat_set_size:wrap((fd,stSize)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_SET_SIZE);return fs.ftruncateSync(stats.real,Number(stSize)),constants_1.WASI_ESUCCESS}),fd_filestat_set_times:wrap((fd,stAtim,stMtim,fstflags)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_SET_TIMES),rstats=this.fstatSync(stats.real);let{atime:atim,mtime:mtim}=rstats;const n=nsToMs(now(constants_1.WASI_CLOCK_REALTIME)),atimflags=constants_1.WASI_FILESTAT_SET_ATIM|constants_1.WASI_FILESTAT_SET_ATIM_NOW;if((fstflags&atimflags)===atimflags)return constants_1.WASI_EINVAL;const mtimflags=constants_1.WASI_FILESTAT_SET_MTIM|constants_1.WASI_FILESTAT_SET_MTIM_NOW;if((fstflags&mtimflags)===mtimflags)return constants_1.WASI_EINVAL;if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM)===constants_1.WASI_FILESTAT_SET_ATIM)atim=nsToMs(stAtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM_NOW)===constants_1.WASI_FILESTAT_SET_ATIM_NOW)atim=n;if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM)===constants_1.WASI_FILESTAT_SET_MTIM)mtim=nsToMs(stMtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM_NOW)===constants_1.WASI_FILESTAT_SET_MTIM_NOW)mtim=n;return fs.futimesSync(stats.real,new Date(atim),new Date(mtim)),constants_1.WASI_ESUCCESS}),fd_prestat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,BigInt(0));return this.refreshMemory(),this.view.setUint8(bufPtr,constants_1.WASI_PREOPENTYPE_DIR),this.view.setUint32(bufPtr+4,Buffer.byteLength(stats.fakePath\?\?stats.path\?\?\"\"),!0),constants_1.WASI_ESUCCESS}),fd_prestat_dir_name:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,BigInt(0));return this.refreshMemory(),Buffer.from(this.memory.buffer).write(stats.fakePath\?\?stats.path\?\?\"\",pathPtr,pathLen,\"utf8\"),constants_1.WASI_ESUCCESS}),fd_pwrite:wrap((fd,iovs,iovsLen,offset,nwritten)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_SEEK);let written=0;return getiovs(iovs,iovsLen).forEach((iov)=>{let w=0;while(w{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_WRITE),IS_STDOUT=fd==constants_1.WASI_STDOUT_FILENO,IS_STDERR=fd==constants_1.WASI_STDERR_FILENO;let written=0;return getiovs(iovs,iovsLen).forEach((iov)=>{if(iov.byteLength==0)return;if(IS_STDOUT&&this.sendStdout!=null)this.sendStdout(iov),written+=iov.byteLength;else if(IS_STDERR&&this.sendStderr!=null)this.sendStderr(iov),written+=iov.byteLength;else{let w=0;while(w{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_SEEK);let read=0;outer:for(let iov of getiovs(iovs,iovsLen)){let r=0;while(r{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READ),IS_STDIN=fd==constants_1.WASI_STDIN_FILENO;let read=0;outer:for(let iov of getiovs(iovs,iovsLen)){let r=0;while(r0)this.lastStdin=(new Date()).valueOf()}}else{if(this.sleep==null&&!warnedAboutSleep)warnedAboutSleep=!0,console.log(\"(cpu waiting for stdin: please define a way to sleep!) \");try{rr=fs.readSync(stats.real,iov,r,length,position)}catch(_err){}if(rr==0)this.shortPause();else this.lastStdin=(new Date()).valueOf()}else rr=fs.readSync(stats.real,iov,r,length,position);if(stats.filetype==constants_1.WASI_FILETYPE_REGULAR_FILE)stats.offset=(stats.offset\?stats.offset:BigInt(0))+BigInt(rr);if(r+=rr,read+=rr,rr===0||rr{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READDIR);this.refreshMemory();const entries=fs.readdirSync(stats.path,{withFileTypes:!0}),startPtr=bufPtr;for(let i=Number(cookie);ibufLen)break;if(this.view.setBigUint64(bufPtr,BigInt(i+1),!0),bufPtr+=8,bufPtr-startPtr>bufLen)break;const rstats=fs.lstatSync(path.resolve(stats.path,entry.name));if(this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,bufPtr-startPtr>bufLen)break;if(this.view.setUint32(bufPtr,nameLength,!0),bufPtr+=4,bufPtr-startPtr>bufLen)break;let filetype;switch(!0){case rstats.isBlockDevice():filetype=constants_1.WASI_FILETYPE_BLOCK_DEVICE;break;case rstats.isCharacterDevice():filetype=constants_1.WASI_FILETYPE_CHARACTER_DEVICE;break;case rstats.isDirectory():filetype=constants_1.WASI_FILETYPE_DIRECTORY;break;case rstats.isFIFO():filetype=constants_1.WASI_FILETYPE_SOCKET_STREAM;break;case rstats.isFile():filetype=constants_1.WASI_FILETYPE_REGULAR_FILE;break;case rstats.isSocket():filetype=constants_1.WASI_FILETYPE_SOCKET_STREAM;break;case rstats.isSymbolicLink():filetype=constants_1.WASI_FILETYPE_SYMBOLIC_LINK;break;default:filetype=constants_1.WASI_FILETYPE_UNKNOWN;break}if(this.view.setUint8(bufPtr,filetype),bufPtr+=1,bufPtr+=3,bufPtr+nameLength>=startPtr+bufLen)break;Buffer.from(this.memory.buffer).write(entry.name,bufPtr),bufPtr+=nameLength}const bufused=bufPtr-startPtr;return this.view.setUint32(bufusedPtr,Math.min(bufused,bufLen),!0),constants_1.WASI_ESUCCESS}),fd_renumber:wrap((from,to)=>{return CHECK_FD(from,BigInt(0)),CHECK_FD(to,BigInt(0)),fs.closeSync(this.FD_MAP.get(from).real),this.FD_MAP.set(from,this.FD_MAP.get(to)),this.FD_MAP.delete(to),constants_1.WASI_ESUCCESS}),fd_seek:wrap((fd,offset,whence,newOffsetPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_SEEK);switch(this.refreshMemory(),whence){case constants_1.WASI_WHENCE_CUR:stats.offset=(stats.offset\?stats.offset:BigInt(0))+BigInt(offset);break;case constants_1.WASI_WHENCE_END:const{size}=this.fstatSync(stats.real);stats.offset=BigInt(size)+BigInt(offset);break;case constants_1.WASI_WHENCE_SET:stats.offset=BigInt(offset);break}if(stats.offset==null)throw Error(\"stats.offset must be defined\");return this.view.setBigUint64(newOffsetPtr,stats.offset,!0),constants_1.WASI_ESUCCESS}),fd_tell:wrap((fd,offsetPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_TELL);if(this.refreshMemory(),!stats.offset)stats.offset=BigInt(0);return this.view.setBigUint64(offsetPtr,stats.offset,!0),constants_1.WASI_ESUCCESS}),fd_sync:wrap((fd)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_SYNC);return fs.fsyncSync(stats.real),constants_1.WASI_ESUCCESS}),path_create_directory:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_CREATE_DIRECTORY);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.mkdirSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),path_filestat_get:wrap((fd,flags,pathPtr,pathLen,bufPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_FILESTAT_GET);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();let rstats;if(flags)rstats=fs.statSync(path.resolve(stats.path,p));else rstats=fs.lstatSync(path.resolve(stats.path,p));return this.view.setBigUint64(bufPtr,BigInt(rstats.dev),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,this.view.setUint8(bufPtr,translateFileAttributes(this,void 0,rstats).filetype),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.nlink),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.size),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.atime.getTime()*1e6),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.mtime.getTime()*1e6),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ctime.getTime()*1e6),!0),constants_1.WASI_ESUCCESS}),path_filestat_set_times:wrap((fd,_dirflags,pathPtr,pathLen,stAtim,stMtim,fstflags)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_FILESTAT_SET_TIMES);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const rstats=this.fstatSync(stats.real);let{atime:atim,mtime:mtim}=rstats;const n=nsToMs(now(constants_1.WASI_CLOCK_REALTIME)),atimflags=constants_1.WASI_FILESTAT_SET_ATIM|constants_1.WASI_FILESTAT_SET_ATIM_NOW;if((fstflags&atimflags)===atimflags)return constants_1.WASI_EINVAL;const mtimflags=constants_1.WASI_FILESTAT_SET_MTIM|constants_1.WASI_FILESTAT_SET_MTIM_NOW;if((fstflags&mtimflags)===mtimflags)return constants_1.WASI_EINVAL;if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM)===constants_1.WASI_FILESTAT_SET_ATIM)atim=nsToMs(stAtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM_NOW)===constants_1.WASI_FILESTAT_SET_ATIM_NOW)atim=n;if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM)===constants_1.WASI_FILESTAT_SET_MTIM)mtim=nsToMs(stMtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM_NOW)===constants_1.WASI_FILESTAT_SET_MTIM_NOW)mtim=n;const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.utimesSync(path.resolve(stats.path,p),new Date(atim),new Date(mtim)),constants_1.WASI_ESUCCESS}),path_link:wrap((oldFd,_oldFlags,oldPath,oldPathLen,newFd,newPath,newPathLen)=>{const ostats=CHECK_FD(oldFd,constants_1.WASI_RIGHT_PATH_LINK_SOURCE),nstats=CHECK_FD(newFd,constants_1.WASI_RIGHT_PATH_LINK_TARGET);if(!ostats.path||!nstats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.linkSync(path.resolve(ostats.path,op),path.resolve(nstats.path,np)),constants_1.WASI_ESUCCESS}),path_open:wrap((dirfd,_dirflags,pathPtr,pathLen,oflags,fsRightsBase,fsRightsInheriting,fsFlags,fdPtr)=>{try{const stats=CHECK_FD(dirfd,constants_1.WASI_RIGHT_PATH_OPEN);fsRightsBase=BigInt(fsRightsBase),fsRightsInheriting=BigInt(fsRightsInheriting);const read=(fsRightsBase&(constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_READDIR))!==BigInt(0),write=(fsRightsBase&(constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_ALLOCATE|constants_1.WASI_RIGHT_FD_FILESTAT_SET_SIZE))!==BigInt(0);let noflags;if(write&&read)noflags=nodeFsConstants.O_RDWR;else if(read)noflags=nodeFsConstants.O_RDONLY;else if(write)noflags=nodeFsConstants.O_WRONLY;let neededBase=fsRightsBase|constants_1.WASI_RIGHT_PATH_OPEN,neededInheriting=fsRightsBase|fsRightsInheriting;if((oflags&constants_1.WASI_O_CREAT)!==0)noflags|=nodeFsConstants.O_CREAT,neededBase|=constants_1.WASI_RIGHT_PATH_CREATE_FILE;if((oflags&constants_1.WASI_O_DIRECTORY)!==0)noflags|=nodeFsConstants.O_DIRECTORY;if((oflags&constants_1.WASI_O_EXCL)!==0)noflags|=nodeFsConstants.O_EXCL;if((oflags&constants_1.WASI_O_TRUNC)!==0)noflags|=nodeFsConstants.O_TRUNC,neededBase|=constants_1.WASI_RIGHT_PATH_FILESTAT_SET_SIZE;if((fsFlags&constants_1.WASI_FDFLAG_APPEND)!==0)noflags|=nodeFsConstants.O_APPEND;if((fsFlags&constants_1.WASI_FDFLAG_DSYNC)!==0){if(nodeFsConstants.O_DSYNC)noflags|=nodeFsConstants.O_DSYNC;else noflags|=nodeFsConstants.O_SYNC;neededInheriting|=constants_1.WASI_RIGHT_FD_DATASYNC}if((fsFlags&constants_1.WASI_FDFLAG_NONBLOCK)!==0)noflags|=nodeFsConstants.O_NONBLOCK;if((fsFlags&constants_1.WASI_FDFLAG_RSYNC)!==0){if(nodeFsConstants.O_RSYNC)noflags|=nodeFsConstants.O_RSYNC;else noflags|=nodeFsConstants.O_SYNC;neededInheriting|=constants_1.WASI_RIGHT_FD_SYNC}if((fsFlags&constants_1.WASI_FDFLAG_SYNC)!==0)noflags|=nodeFsConstants.O_SYNC,neededInheriting|=constants_1.WASI_RIGHT_FD_SYNC;if(write&&(noflags&(nodeFsConstants.O_APPEND|nodeFsConstants.O_TRUNC))===0)neededInheriting|=constants_1.WASI_RIGHT_FD_SEEK;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();if(p==\"dev/tty\")return this.view.setUint32(fdPtr,constants_1.WASI_STDIN_FILENO,!0),constants_1.WASI_ESUCCESS;if(logOpen(\"path_open\",p),p.startsWith(\"proc/\"))throw new types_1.WASIError(constants_1.WASI_EBADF);const fullUnresolved=path.resolve(p);let full;try{full=fs.realpathSync(fullUnresolved)}catch(e){if(e\?.code===\"ENOENT\")full=fullUnresolved;else throw e}let isDirectory;if(write)try{isDirectory=fs.statSync(full).isDirectory()}catch(_err){}let realfd;if(!write&&isDirectory)realfd=fs.openSync(full,nodeFsConstants.O_RDONLY);else realfd=fs.openSync(full,noflags);const newfd=this.getUnusedFileDescriptor();this.FD_MAP.set(newfd,{real:realfd,filetype:void 0,rights:{base:neededBase,inheriting:neededInheriting},path:full}),stat(this,newfd),this.view.setUint32(fdPtr,newfd,!0)}catch(e){console.error(e)}return constants_1.WASI_ESUCCESS}),path_readlink:wrap((fd,pathPtr,pathLen,buf,bufLen,bufused)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_READLINK);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString(),full=path.resolve(stats.path,p),r=fs.readlinkSync(full),used=Buffer.from(this.memory.buffer).write(r,buf,bufLen);return this.view.setUint32(bufused,used,!0),constants_1.WASI_ESUCCESS}),path_remove_directory:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_REMOVE_DIRECTORY);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.rmdirSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),path_rename:wrap((oldFd,oldPath,oldPathLen,newFd,newPath,newPathLen)=>{const ostats=CHECK_FD(oldFd,constants_1.WASI_RIGHT_PATH_RENAME_SOURCE),nstats=CHECK_FD(newFd,constants_1.WASI_RIGHT_PATH_RENAME_TARGET);if(!ostats.path||!nstats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.renameSync(path.resolve(ostats.path,op),path.resolve(nstats.path,np)),constants_1.WASI_ESUCCESS}),path_symlink:wrap((oldPath,oldPathLen,fd,newPath,newPathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_SYMLINK);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.symlinkSync(op,path.resolve(stats.path,np)),constants_1.WASI_ESUCCESS}),path_unlink_file:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_UNLINK_FILE);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.unlinkSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),poll_oneoff:(sin,sout,nsubscriptions,neventsPtr)=>{let nevents=0,name=\"\",waitTimeNs=BigInt(0),fd=-1,fd_type=\"read\",fd_timeout_ms=0;const startNs=BigInt(bindings2.hrtime());this.refreshMemory();let last_sin=sin;for(let i=0;iwaitTimeNs)waitTimeNs=waitNs}this.view.setBigUint64(sout,userdata,!0),sout+=8,this.view.setUint16(sout,e,!0),sout+=2,this.view.setUint8(sout,constants_1.WASI_EVENTTYPE_CLOCK),sout+=1,sout+=5,nevents+=1;break}case constants_1.WASI_EVENTTYPE_FD_READ:case constants_1.WASI_EVENTTYPE_FD_WRITE:{if(fd=this.view.getUint32(sin,!0),fd_type=type==constants_1.WASI_EVENTTYPE_FD_READ\?\"read\":\"write\",sin+=4,log(name,\"fd =\",fd),sin+=28,this.view.setBigUint64(sout,userdata,!0),sout+=8,this.view.setUint16(sout,constants_1.WASI_ENOSYS,!0),sout+=2,this.view.setUint8(sout,type),sout+=1,sout+=5,nevents+=1,fd==constants_1.WASI_STDIN_FILENO&&constants_1.WASI_EVENTTYPE_FD_READ==type)this.shortPause();break}default:return constants_1.WASI_EINVAL}if(sin-last_sin!=48)console.warn(\"*** BUG in wasi-js in poll_oneoff \",{i,sin,last_sin,diff:sin-last_sin});last_sin=sin}if(this.view.setUint32(neventsPtr,nevents,!0),nevents==2&&fd>=0){const r=this.wasiImport.sock_pollSocket(fd,fd_type,fd_timeout_ms);if(r!=constants_1.WASI_ENOSYS)return r}if(waitTimeNs>0){if(waitTimeNs-=Bun.nanoseconds()-timeOrigin,waitTimeNs>=1e6){if(this.sleep==null&&!warnedAboutSleep)warnedAboutSleep=!0,console.log(\"(100% cpu burning waiting for stdin: please define a way to sleep!) \");if(this.sleep!=null){const ms=nsToMs(waitTimeNs);this.sleep(ms)}else{const end=BigInt(bindings2.hrtime())+waitTimeNs;while(BigInt(bindings2.hrtime()){return bindings2.exit(rval),constants_1.WASI_ESUCCESS},proc_raise:(sig)=>{if(!(sig in constants_1.SIGNAL_MAP))return constants_1.WASI_EINVAL;return bindings2.kill(constants_1.SIGNAL_MAP[sig]),constants_1.WASI_ESUCCESS},random_get:(bufPtr,bufLen)=>{return this.refreshMemory(),crypto.getRandomValues(this.memory.buffer,bufPtr,bufLen),bufLen},sched_yield(){return constants_1.WASI_ESUCCESS},sock_recv(){return constants_1.WASI_ENOSYS},sock_send(){return constants_1.WASI_ENOSYS},sock_shutdown(){return constants_1.WASI_ENOSYS},sock_fcntlSetFlags(_fd,_flags){return constants_1.WASI_ENOSYS},sock_pollSocket(_fd,_eventtype,_timeout_ms){return constants_1.WASI_ENOSYS}},log.enabled)Object.keys(this.wasiImport).forEach((key)=>{const prevImport=this.wasiImport[key];this.wasiImport[key]=function(...args2){log(key,args2);try{let result=prevImport(...args2);return log(\"result\",result),result}catch(e){throw log(\"error: \",e),e}}})}getState(){return{env:this.env,FD_MAP:this.FD_MAP,bindings}}setState(state){this.env=state.env,this.FD_MAP=state.FD_MAP,bindings=state.bindings}fstatSync(real_fd){if(real_fd<=2)try{return fs.fstatSync(real_fd)}catch(_){const now=new Date;return{dev:0,mode:8592,nlink:1,uid:0,gid:0,rdev:0,blksize:65536,ino:0,size:0,blocks:0,atimeMs:now.valueOf(),mtimeMs:now.valueOf(),ctimeMs:now.valueOf(),birthtimeMs:0,atime:new Date,mtime:new Date,ctime:new Date,birthtime:new Date(0)}}return fs.fstatSync(real_fd)}shortPause(){if(this.sleep==null)return;if((new Date()).valueOf()-this.lastStdin>2000)this.sleep(50)}getUnusedFileDescriptor(start=3){let fd=start;while(this.FD_MAP.has(fd))fd+=1;if(fd>SC_OPEN_MAX)throw Error(\"no available file descriptors\");return fd}refreshMemory(){if(!this.view||this.view.buffer.byteLength===0)this.view=new DataView(this.memory.buffer)}setMemory(memory){this.memory=memory}start(instance,memory){const exports2=instance.exports;if(exports2===null||typeof exports2!==\"object\")throw new Error(`instance.exports must be an Object. Received ${exports2}.`);if(memory==null){if(memory=exports2.memory,!(memory instanceof WebAssembly.Memory))throw new Error(`instance.exports.memory must be a WebAssembly.Memory. Recceived ${memory}.`)}if(this.setMemory(memory),exports2._start)exports2._start()}getImports(module2){let namespace=null;const imports=WebAssembly.Module.imports(module2);for(let imp of imports){if(imp.kind!==\"function\")continue;if(!imp.module.startsWith(\"wasi_\"))continue;namespace=imp.module;break}switch(namespace){case\"wasi_unstable\":return{wasi_unstable:this.wasiImport};case\"wasi_snapshot_preview1\":return{wasi_snapshot_preview1:this.wasiImport};default:throw new Error(\"No WASI namespace found. Only wasi_unstable and wasi_snapshot_preview1 are supported.\\n\\nList of imports:\\n\\n\"+imports.map(({name,kind,module})=>`${module}:${name} (${kind})`).join(\"\\n\")+\"\\n\")}}initWasiFdInfo(){if(this.env.WASI_FD_INFO!=null){const fdInfo=JSON.parse(this.env.WASI_FD_INFO);for(let wasi_fd in fdInfo){console.log(wasi_fd);const fd=parseInt(wasi_fd);if(this.FD_MAP.has(fd))continue;const real=fdInfo[wasi_fd];try{this.fstatSync(real)}catch(_err){console.log(\"discarding \",{wasi_fd,real});continue}const file={real,filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rights:{base:STDIN_DEFAULT_RIGHTS,inheriting:BigInt(0)}};this.FD_MAP.set(fd,file)}console.log(\"after initWasiFdInfo: \",this.FD_MAP),console.log(\"fdInfo = \",fdInfo)}else console.log(\"no WASI_FD_INFO\")}};exports.default=WASI}});return{WASI:require_wasi().default}})\n"_s; +// + +// static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const{MessageChannel,BroadcastChannel}=globalThis;function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort,EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\"),parentPort=isMainThread\?null:fakeParentPort(),resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throw new Error(\"markAsUntransferable is not implemented\")}function moveMessagePortToContext(){throw new Error(\"moveMessagePortToContext is not implemented\")}const SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),WebWorker=globalThis.Worker;class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();this.#worker=new WebWorker(filename,{...options}),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return{}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.#worker.addEventListener(\"close\",(event)=>{resolve(0)},{once:!0}),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(){this.emit(\"exit\")}#onError(event){this.emit(\"error\",event)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error||event)}#onOpen(){this.emit(\"online\")}getHeapSnapshot(){return{}}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeZlibCode = "(function (){\"use strict\";const assert=@getInternalField(@internalModuleRegistry,3)||@createInternalModuleById(3),BufferModule=@requireNativeModule(\"node:buffer\"),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),Util=@getInternalField(@internalModuleRegistry,42)||@createInternalModuleById(42);var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_zstream=__commonJS({\"node_modules/pako/lib/zlib/zstream.js\"(exports,module2){function ZStream(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}module2.exports=ZStream}}),require_common=__commonJS({\"node_modules/pako/lib/utils/common.js\"(exports){var TYPED_OK=typeof Uint8Array!==\"undefined\"&&typeof Uint16Array!==\"undefined\"&&typeof Int32Array!==\"undefined\";function _has(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}exports.assign=function(obj){var sources=Array.prototype.slice.call(arguments,1);while(sources.length){var source=sources.shift();if(!source)continue;if(typeof source!==\"object\")@throwTypeError(source+\"must be non-object\");for(var p in source)if(_has(source,p))obj[p]=source[p]}return obj},exports.shrinkBuf=function(buf,size){if(buf.length===size)return buf;if(buf.subarray)return buf.subarray(0,size);return buf.length=size,buf};var fnTyped={arraySet:function(dest,src,src_offs,len,dest_offs){if(src.subarray&&dest.subarray){dest.set(src.subarray(src_offs,src_offs+len),dest_offs);return}for(var i=0;i=0)buf[len]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH=3,MAX_MATCH=258,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],DIST_CODE_LEN=512,static_ltree=new Array((L_CODES+2)*2);zero(static_ltree);var static_dtree=new Array(D_CODES*2);zero(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero(_dist_code);var _length_code=new Array(MAX_MATCH-MIN_MATCH+1);zero(_length_code);var base_length=new Array(LENGTH_CODES);zero(base_length);var base_dist=new Array(D_CODES);zero(base_dist);function StaticTreeDesc(static_tree,extra_bits,extra_base,elems,max_length){this.static_tree=static_tree,this.extra_bits=extra_bits,this.extra_base=extra_base,this.elems=elems,this.max_length=max_length,this.has_stree=static_tree&&static_tree.length}var static_l_desc,static_d_desc,static_bl_desc;function TreeDesc(dyn_tree,stat_desc){this.dyn_tree=dyn_tree,this.max_code=0,this.stat_desc=stat_desc}function d_code(dist){return dist<256\?_dist_code[dist]:_dist_code[256+(dist>>>7)]}function put_short(s,w){s.pending_buf[s.pending++]=w&255,s.pending_buf[s.pending++]=w>>>8&255}function send_bits(s,value,length){if(s.bi_valid>Buf_size-length)s.bi_buf|=value<>Buf_size-s.bi_valid,s.bi_valid+=length-Buf_size;else s.bi_buf|=value<>>=1,res<<=1;while(--len>0);return res>>>1}function bi_flush(s){if(s.bi_valid===16)put_short(s,s.bi_buf),s.bi_buf=0,s.bi_valid=0;else if(s.bi_valid>=8)s.pending_buf[s.pending++]=s.bi_buf&255,s.bi_buf>>=8,s.bi_valid-=8}function gen_bitlen(s,desc){var{dyn_tree:tree,max_code}=desc,stree=desc.stat_desc.static_tree,has_stree=desc.stat_desc.has_stree,extra=desc.stat_desc.extra_bits,base=desc.stat_desc.extra_base,max_length=desc.stat_desc.max_length,h,n,m,bits,xbits,f,overflow=0;for(bits=0;bits<=MAX_BITS;bits++)s.bl_count[bits]=0;tree[s.heap[s.heap_max]*2+1]=0;for(h=s.heap_max+1;hmax_length)bits=max_length,overflow++;if(tree[n*2+1]=bits,n>max_code)continue;if(s.bl_count[bits]++,xbits=0,n>=base)xbits=extra[n-base];if(f=tree[n*2],s.opt_len+=f*(bits+xbits),has_stree)s.static_len+=f*(stree[n*2+1]+xbits)}if(overflow===0)return;do{bits=max_length-1;while(s.bl_count[bits]===0)bits--;s.bl_count[bits]--,s.bl_count[bits+1]+=2,s.bl_count[max_length]--,overflow-=2}while(overflow>0);for(bits=max_length;bits!==0;bits--){n=s.bl_count[bits];while(n!==0){if(m=s.heap[--h],m>max_code)continue;if(tree[m*2+1]!==bits)s.opt_len+=(bits-tree[m*2+1])*tree[m*2],tree[m*2+1]=bits;n--}}}function gen_codes(tree,max_code,bl_count){var next_code=new Array(MAX_BITS+1),code=0,bits,n;for(bits=1;bits<=MAX_BITS;bits++)next_code[bits]=code=code+bl_count[bits-1]<<1;for(n=0;n<=max_code;n++){var len=tree[n*2+1];if(len===0)continue;tree[n*2]=bi_reverse(next_code[len]++,len)}}function tr_static_init(){var n,bits,length,code,dist,bl_count=new Array(MAX_BITS+1);length=0;for(code=0;code>=7;for(;code8)put_short(s,s.bi_buf);else if(s.bi_valid>0)s.pending_buf[s.pending++]=s.bi_buf;s.bi_buf=0,s.bi_valid=0}function copy_block(s,buf,len,header){if(bi_windup(s),header)put_short(s,len),put_short(s,~len);utils.arraySet(s.pending_buf,s.window,buf,len,s.pending),s.pending+=len}function smaller(tree,n,m,depth){var _n2=n*2,_m2=m*2;return tree[_n2]>1;n>=1;n--)pqdownheap(s,tree,n);node=elems;do n=s.heap[1],s.heap[1]=s.heap[s.heap_len--],pqdownheap(s,tree,1),m=s.heap[1],s.heap[--s.heap_max]=n,s.heap[--s.heap_max]=m,tree[node*2]=tree[n*2]+tree[m*2],s.depth[node]=(s.depth[n]>=s.depth[m]\?s.depth[n]:s.depth[m])+1,tree[n*2+1]=tree[m*2+1]=node,s.heap[1]=node++,pqdownheap(s,tree,1);while(s.heap_len>=2);s.heap[--s.heap_max]=s.heap[1],gen_bitlen(s,desc),gen_codes(tree,max_code,s.bl_count)}function scan_tree(s,tree,max_code){var n,prevlen=-1,curlen,nextlen=tree[1],count=0,max_count=7,min_count=4;if(nextlen===0)max_count=138,min_count=3;tree[(max_code+1)*2+1]=65535;for(n=0;n<=max_code;n++){if(curlen=nextlen,nextlen=tree[(n+1)*2+1],++count=3;max_blindex--)if(s.bl_tree[bl_order[max_blindex]*2+1]!==0)break;return s.opt_len+=3*(max_blindex+1)+5+5+4,max_blindex}function send_all_trees(s,lcodes,dcodes,blcodes){var rank;send_bits(s,lcodes-257,5),send_bits(s,dcodes-1,5),send_bits(s,blcodes-4,4);for(rank=0;rank>>=1)if(black_mask&1&&s.dyn_ltree[n*2]!==0)return Z_BINARY;if(s.dyn_ltree[18]!==0||s.dyn_ltree[20]!==0||s.dyn_ltree[26]!==0)return Z_TEXT;for(n=32;n0){if(s.strm.data_type===Z_UNKNOWN)s.strm.data_type=detect_data_type(s);if(build_tree(s,s.l_desc),build_tree(s,s.d_desc),max_blindex=build_bl_tree(s),opt_lenb=s.opt_len+3+7>>>3,static_lenb=s.static_len+3+7>>>3,static_lenb<=opt_lenb)opt_lenb=static_lenb}else opt_lenb=static_lenb=stored_len+5;if(stored_len+4<=opt_lenb&&buf!==-1)_tr_stored_block(s,buf,stored_len,last);else if(s.strategy===Z_FIXED||static_lenb===opt_lenb)send_bits(s,(STATIC_TREES<<1)+(last\?1:0),3),compress_block(s,static_ltree,static_dtree);else send_bits(s,(DYN_TREES<<1)+(last\?1:0),3),send_all_trees(s,s.l_desc.max_code+1,s.d_desc.max_code+1,max_blindex+1),compress_block(s,s.dyn_ltree,s.dyn_dtree);if(init_block(s),last)bi_windup(s)}function _tr_tally(s,dist,lc){if(s.pending_buf[s.d_buf+s.last_lit*2]=dist>>>8&255,s.pending_buf[s.d_buf+s.last_lit*2+1]=dist&255,s.pending_buf[s.l_buf+s.last_lit]=lc&255,s.last_lit++,dist===0)s.dyn_ltree[lc*2]++;else s.matches++,dist--,s.dyn_ltree[(_length_code[lc]+LITERALS+1)*2]++,s.dyn_dtree[d_code(dist)*2]++;return s.last_lit===s.lit_bufsize-1}exports._tr_init=_tr_init,exports._tr_stored_block=_tr_stored_block,exports._tr_flush_block=_tr_flush_block,exports._tr_tally=_tr_tally,exports._tr_align=_tr_align}}),require_adler32=__commonJS({\"node_modules/pako/lib/zlib/adler32.js\"(exports,module2){function adler32(adler,buf,len,pos){var s1=adler&65535|0,s2=adler>>>16&65535|0,n=0;while(len!==0){n=len>2000\?2000:len,len-=n;do s1=s1+buf[pos++]|0,s2=s2+s1|0;while(--n);s1%=65521,s2%=65521}return s1|s2<<16|0}module2.exports=adler32}}),require_crc32=__commonJS({\"node_modules/pako/lib/zlib/crc32.js\"(exports,module2){function makeTable(){var c,table=[];for(var n=0;n<256;n++){c=n;for(var k=0;k<8;k++)c=c&1\?3988292384^c>>>1:c>>>1;table[n]=c}return table}var crcTable=makeTable();function crc32(crc,buf,len,pos){var t=crcTable,end=pos+len;crc^=-1;for(var i=pos;i>>8^t[(crc^buf[i])&255];return crc^-1}module2.exports=crc32}}),require_messages=__commonJS({\"node_modules/pako/lib/zlib/messages.js\"(exports,module2){module2.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}}}),require_deflate=__commonJS({\"node_modules/pako/lib/zlib/deflate.js\"(exports){var utils=require_common(),trees=require_trees(),adler32=require_adler32(),crc32=require_crc32(),msg=require_messages(),Z_NO_FLUSH=0,Z_PARTIAL_FLUSH=1,Z_FULL_FLUSH=3,Z_FINISH=4,Z_BLOCK=5,Z_OK=0,Z_STREAM_END=1,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_BUF_ERROR=-5,Z_DEFAULT_COMPRESSION=-1,Z_FILTERED=1,Z_HUFFMAN_ONLY=2,Z_RLE=3,Z_FIXED=4,Z_DEFAULT_STRATEGY=0,Z_UNKNOWN=2,Z_DEFLATED=8,MAX_MEM_LEVEL=9,MAX_WBITS=15,DEF_MEM_LEVEL=8,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3;function err(strm,errorCode){return strm.msg=msg[errorCode],errorCode}function rank(f){return(f<<1)-(f>4\?9:0)}function zero(buf){var len=buf.length;while(--len>=0)buf[len]=0}function flush_pending(strm){var s=strm.state,len=s.pending;if(len>strm.avail_out)len=strm.avail_out;if(len===0)return;if(utils.arraySet(strm.output,s.pending_buf,s.pending_out,len,strm.next_out),strm.next_out+=len,s.pending_out+=len,strm.total_out+=len,strm.avail_out-=len,s.pending-=len,s.pending===0)s.pending_out=0}function flush_block_only(s,last){trees._tr_flush_block(s,s.block_start>=0\?s.block_start:-1,s.strstart-s.block_start,last),s.block_start=s.strstart,flush_pending(s.strm)}function put_byte(s,b){s.pending_buf[s.pending++]=b}function putShortMSB(s,b){s.pending_buf[s.pending++]=b>>>8&255,s.pending_buf[s.pending++]=b&255}function read_buf(strm,buf,start,size){var len=strm.avail_in;if(len>size)len=size;if(len===0)return 0;if(strm.avail_in-=len,utils.arraySet(buf,strm.input,strm.next_in,len,start),strm.state.wrap===1)strm.adler=adler32(strm.adler,buf,len,start);else if(strm.state.wrap===2)strm.adler=crc32(strm.adler,buf,len,start);return strm.next_in+=len,strm.total_in+=len,len}function longest_match(s,cur_match){var{max_chain_length:chain_length,strstart:scan}=s,match,len,best_len=s.prev_length,nice_match=s.nice_match,limit=s.strstart>s.w_size-MIN_LOOKAHEAD\?s.strstart-(s.w_size-MIN_LOOKAHEAD):0,_win=s.window,wmask=s.w_mask,prev=s.prev,strend=s.strstart+MAX_MATCH,scan_end1=_win[scan+best_len-1],scan_end=_win[scan+best_len];if(s.prev_length>=s.good_match)chain_length>>=2;if(nice_match>s.lookahead)nice_match=s.lookahead;do{if(match=cur_match,_win[match+best_len]!==scan_end||_win[match+best_len-1]!==scan_end1||_win[match]!==_win[scan]||_win[++match]!==_win[scan+1])continue;scan+=2,match++;do;while(_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&scanbest_len){if(s.match_start=cur_match,best_len=len,len>=nice_match)break;scan_end1=_win[scan+best_len-1],scan_end=_win[scan+best_len]}}while((cur_match=prev[cur_match&wmask])>limit&&--chain_length!==0);if(best_len<=s.lookahead)return best_len;return s.lookahead}function fill_window(s){var _w_size=s.w_size,p,n,m,more,str;do{if(more=s.window_size-s.lookahead-s.strstart,s.strstart>=_w_size+(_w_size-MIN_LOOKAHEAD)){utils.arraySet(s.window,s.window,_w_size,_w_size,0),s.match_start-=_w_size,s.strstart-=_w_size,s.block_start-=_w_size,n=s.hash_size,p=n;do m=s.head[--p],s.head[p]=m>=_w_size\?m-_w_size:0;while(--n);n=_w_size,p=n;do m=s.prev[--p],s.prev[p]=m>=_w_size\?m-_w_size:0;while(--n);more+=_w_size}if(s.strm.avail_in===0)break;if(n=read_buf(s.strm,s.window,s.strstart+s.lookahead,more),s.lookahead+=n,s.lookahead+s.insert>=MIN_MATCH){str=s.strstart-s.insert,s.ins_h=s.window[str],s.ins_h=(s.ins_h<s.pending_buf_size-5)max_block_size=s.pending_buf_size-5;for(;;){if(s.lookahead<=1){if(fill_window(s),s.lookahead===0&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead===0)break}s.strstart+=s.lookahead,s.lookahead=0;var max_start=s.block_start+max_block_size;if(s.strstart===0||s.strstart>=max_start){if(s.lookahead=s.strstart-max_start,s.strstart=max_start,flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}if(s.strstart-s.block_start>=s.w_size-MIN_LOOKAHEAD){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.strstart>s.block_start){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_NEED_MORE}function deflate_fast(s,flush){var hash_head,bflush;for(;;){if(s.lookahead=MIN_MATCH)s.ins_h=(s.ins_h<=MIN_MATCH)if(bflush=trees._tr_tally(s,s.strstart-s.match_start,s.match_length-MIN_MATCH),s.lookahead-=s.match_length,s.match_length<=s.max_lazy_match&&s.lookahead>=MIN_MATCH){s.match_length--;do s.strstart++,s.ins_h=(s.ins_h<=MIN_MATCH)s.ins_h=(s.ins_h<4096))s.match_length=MIN_MATCH-1}if(s.prev_length>=MIN_MATCH&&s.match_length<=s.prev_length){max_insert=s.strstart+s.lookahead-MIN_MATCH,bflush=trees._tr_tally(s,s.strstart-1-s.prev_match,s.prev_length-MIN_MATCH),s.lookahead-=s.prev_length-1,s.prev_length-=2;do if(++s.strstart<=max_insert)s.ins_h=(s.ins_h<=MIN_MATCH&&s.strstart>0){if(scan=s.strstart-1,prev=_win[scan],prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]){strend=s.strstart+MAX_MATCH;do;while(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&scans.lookahead)s.match_length=s.lookahead}}if(s.match_length>=MIN_MATCH)bflush=trees._tr_tally(s,1,s.match_length-MIN_MATCH),s.lookahead-=s.match_length,s.strstart+=s.match_length,s.match_length=0;else bflush=trees._tr_tally(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++;if(bflush){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_huff(s,flush){var bflush;for(;;){if(s.lookahead===0){if(fill_window(s),s.lookahead===0){if(flush===Z_NO_FLUSH)return BS_NEED_MORE;break}}if(s.match_length=0,bflush=trees._tr_tally(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++,bflush){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function Config(good_length,max_lazy,nice_length,max_chain,func){this.good_length=good_length,this.max_lazy=max_lazy,this.nice_length=nice_length,this.max_chain=max_chain,this.func=func}var configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(s){s.window_size=2*s.w_size,zero(s.head),s.max_lazy_match=configuration_table[s.level].max_lazy,s.good_match=configuration_table[s.level].good_length,s.nice_match=configuration_table[s.level].nice_length,s.max_chain_length=configuration_table[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=MIN_MATCH-1,s.match_available=0,s.ins_h=0}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new utils.Buf16(HEAP_SIZE*2),this.dyn_dtree=new utils.Buf16((2*D_CODES+1)*2),this.bl_tree=new utils.Buf16((2*BL_CODES+1)*2),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new utils.Buf16(MAX_BITS+1),this.heap=new utils.Buf16(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new utils.Buf16(2*L_CODES+1),zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflateResetKeep(strm){var s;if(!strm||!strm.state)return err(strm,Z_STREAM_ERROR);if(strm.total_in=strm.total_out=0,strm.data_type=Z_UNKNOWN,s=strm.state,s.pending=0,s.pending_out=0,s.wrap<0)s.wrap=-s.wrap;return s.status=s.wrap\?INIT_STATE:BUSY_STATE,strm.adler=s.wrap===2\?0:1,s.last_flush=Z_NO_FLUSH,trees._tr_init(s),Z_OK}function deflateReset(strm){var ret=deflateResetKeep(strm);if(ret===Z_OK)lm_init(strm.state);return ret}function deflateSetHeader(strm,head){if(!strm||!strm.state)return Z_STREAM_ERROR;if(strm.state.wrap!==2)return Z_STREAM_ERROR;return strm.state.gzhead=head,Z_OK}function deflateInit2(strm,level,method,windowBits,memLevel,strategy){if(!strm)return Z_STREAM_ERROR;var wrap=1;if(level===Z_DEFAULT_COMPRESSION)level=6;if(windowBits<0)wrap=0,windowBits=-windowBits;else if(windowBits>15)wrap=2,windowBits-=16;if(memLevel<1||memLevel>MAX_MEM_LEVEL||method!==Z_DEFLATED||windowBits<8||windowBits>15||level<0||level>9||strategy<0||strategy>Z_FIXED)return err(strm,Z_STREAM_ERROR);if(windowBits===8)windowBits=9;var s=new DeflateState;return strm.state=s,s.strm=strm,s.wrap=wrap,s.gzhead=null,s.w_bits=windowBits,s.w_size=1<Z_BLOCK||flush<0)return strm\?err(strm,Z_STREAM_ERROR):Z_STREAM_ERROR;if(s=strm.state,!strm.output||!strm.input&&strm.avail_in!==0||s.status===FINISH_STATE&&flush!==Z_FINISH)return err(strm,strm.avail_out===0\?Z_BUF_ERROR:Z_STREAM_ERROR);if(s.strm=strm,old_flush=s.last_flush,s.last_flush=flush,s.status===INIT_STATE)if(s.wrap===2)if(strm.adler=0,put_byte(s,31),put_byte(s,139),put_byte(s,8),!s.gzhead)put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,s.level===9\?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2\?4:0),put_byte(s,OS_CODE),s.status=BUSY_STATE;else{if(put_byte(s,(s.gzhead.text\?1:0)+(s.gzhead.hcrc\?2:0)+(!s.gzhead.extra\?0:4)+(!s.gzhead.name\?0:8)+(!s.gzhead.comment\?0:16)),put_byte(s,s.gzhead.time&255),put_byte(s,s.gzhead.time>>8&255),put_byte(s,s.gzhead.time>>16&255),put_byte(s,s.gzhead.time>>24&255),put_byte(s,s.level===9\?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2\?4:0),put_byte(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length)put_byte(s,s.gzhead.extra.length&255),put_byte(s,s.gzhead.extra.length>>8&255);if(s.gzhead.hcrc)strm.adler=crc32(strm.adler,s.pending_buf,s.pending,0);s.gzindex=0,s.status=EXTRA_STATE}else{var header=Z_DEFLATED+(s.w_bits-8<<4)<<8,level_flags=-1;if(s.strategy>=Z_HUFFMAN_ONLY||s.level<2)level_flags=0;else if(s.level<6)level_flags=1;else if(s.level===6)level_flags=2;else level_flags=3;if(header|=level_flags<<6,s.strstart!==0)header|=PRESET_DICT;if(header+=31-header%31,s.status=BUSY_STATE,putShortMSB(s,header),s.strstart!==0)putShortMSB(s,strm.adler>>>16),putShortMSB(s,strm.adler&65535);strm.adler=1}if(s.status===EXTRA_STATE)if(s.gzhead.extra){beg=s.pending;while(s.gzindex<(s.gzhead.extra.length&65535)){if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size)break}put_byte(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++}if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(s.gzindex===s.gzhead.extra.length)s.gzindex=0,s.status=NAME_STATE}else s.status=NAME_STATE;if(s.status===NAME_STATE)if(s.gzhead.name){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.gzindex=0,s.status=COMMENT_STATE}else s.status=COMMENT_STATE;if(s.status===COMMENT_STATE)if(s.gzhead.comment){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.status=HCRC_STATE}else s.status=HCRC_STATE;if(s.status===HCRC_STATE)if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size)flush_pending(strm);if(s.pending+2<=s.pending_buf_size)put_byte(s,strm.adler&255),put_byte(s,strm.adler>>8&255),strm.adler=0,s.status=BUSY_STATE}else s.status=BUSY_STATE;if(s.pending!==0){if(flush_pending(strm),strm.avail_out===0)return s.last_flush=-1,Z_OK}else if(strm.avail_in===0&&rank(flush)<=rank(old_flush)&&flush!==Z_FINISH)return err(strm,Z_BUF_ERROR);if(s.status===FINISH_STATE&&strm.avail_in!==0)return err(strm,Z_BUF_ERROR);if(strm.avail_in!==0||s.lookahead!==0||flush!==Z_NO_FLUSH&&s.status!==FINISH_STATE){var bstate=s.strategy===Z_HUFFMAN_ONLY\?deflate_huff(s,flush):s.strategy===Z_RLE\?deflate_rle(s,flush):configuration_table[s.level].func(s,flush);if(bstate===BS_FINISH_STARTED||bstate===BS_FINISH_DONE)s.status=FINISH_STATE;if(bstate===BS_NEED_MORE||bstate===BS_FINISH_STARTED){if(strm.avail_out===0)s.last_flush=-1;return Z_OK}if(bstate===BS_BLOCK_DONE){if(flush===Z_PARTIAL_FLUSH)trees._tr_align(s);else if(flush!==Z_BLOCK){if(trees._tr_stored_block(s,0,0,!1),flush===Z_FULL_FLUSH){if(zero(s.head),s.lookahead===0)s.strstart=0,s.block_start=0,s.insert=0}}if(flush_pending(strm),strm.avail_out===0)return s.last_flush=-1,Z_OK}}if(flush!==Z_FINISH)return Z_OK;if(s.wrap<=0)return Z_STREAM_END;if(s.wrap===2)put_byte(s,strm.adler&255),put_byte(s,strm.adler>>8&255),put_byte(s,strm.adler>>16&255),put_byte(s,strm.adler>>24&255),put_byte(s,strm.total_in&255),put_byte(s,strm.total_in>>8&255),put_byte(s,strm.total_in>>16&255),put_byte(s,strm.total_in>>24&255);else putShortMSB(s,strm.adler>>>16),putShortMSB(s,strm.adler&65535);if(flush_pending(strm),s.wrap>0)s.wrap=-s.wrap;return s.pending!==0\?Z_OK:Z_STREAM_END}function deflateEnd(strm){var status;if(!strm||!strm.state)return Z_STREAM_ERROR;if(status=strm.state.status,status!==INIT_STATE&&status!==EXTRA_STATE&&status!==NAME_STATE&&status!==COMMENT_STATE&&status!==HCRC_STATE&&status!==BUSY_STATE&&status!==FINISH_STATE)return err(strm,Z_STREAM_ERROR);return strm.state=null,status===BUSY_STATE\?err(strm,Z_DATA_ERROR):Z_OK}function deflateSetDictionary(strm,dictionary){var dictLength=dictionary.length,s,str,n,wrap,avail,next,input,tmpDict;if(!strm||!strm.state)return Z_STREAM_ERROR;if(s=strm.state,wrap=s.wrap,wrap===2||wrap===1&&s.status!==INIT_STATE||s.lookahead)return Z_STREAM_ERROR;if(wrap===1)strm.adler=adler32(strm.adler,dictionary,dictLength,0);if(s.wrap=0,dictLength>=s.w_size){if(wrap===0)zero(s.head),s.strstart=0,s.block_start=0,s.insert=0;tmpDict=new utils.Buf8(s.w_size),utils.arraySet(tmpDict,dictionary,dictLength-s.w_size,s.w_size,0),dictionary=tmpDict,dictLength=s.w_size}avail=strm.avail_in,next=strm.next_in,input=strm.input,strm.avail_in=dictLength,strm.next_in=0,strm.input=dictionary,fill_window(s);while(s.lookahead>=MIN_MATCH){str=s.strstart,n=s.lookahead-(MIN_MATCH-1);do s.ins_h=(s.ins_h<>>24,hold>>>=op,bits-=op,op=here>>>16&255,op===0)output[_out++]=here&65535;else if(op&16){if(len=here&65535,op&=15,op){if(bits>>=op,bits-=op}if(bits<15)hold+=input[_in++]<>>24,hold>>>=op,bits-=op,op=here>>>16&255,op&16){if(dist=here&65535,op&=15,bitsdmax){strm.msg=\"invalid distance too far back\",state.mode=BAD;break top}if(hold>>>=op,bits-=op,op=_out-beg,dist>op){if(op=dist-op,op>whave){if(state.sane){strm.msg=\"invalid distance too far back\",state.mode=BAD;break top}}if(from=0,from_source=s_window,wnext===0){if(from+=wsize-op,op2)output[_out++]=from_source[from++],output[_out++]=from_source[from++],output[_out++]=from_source[from++],len-=3;if(len){if(output[_out++]=from_source[from++],len>1)output[_out++]=from_source[from++]}}else{from=_out-dist;do output[_out++]=output[from++],output[_out++]=output[from++],output[_out++]=output[from++],len-=3;while(len>2);if(len){if(output[_out++]=output[from++],len>1)output[_out++]=output[from++]}}}else if((op&64)===0){here=dcode[(here&65535)+(hold&(1<>3,_in-=len,bits-=len<<3,hold&=(1<=1;max--)if(count[max]!==0)break;if(root>max)root=max;if(max===0)return table[table_index++]=1<<24|64<<16|0,table[table_index++]=1<<24|64<<16|0,opts.bits=1,0;for(min=1;min0&&(type===CODES||max!==1))return-1;offs[1]=0;for(len=1;lenENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;for(;;){if(here_bits=len-drop,work[sym]end)here_op=extra[extra_index+work[sym]],here_val=base[base_index+work[sym]];else here_op=96,here_val=0;incr=1<>drop)+fill]=here_bits<<24|here_op<<16|here_val|0;while(fill!==0);incr=1<>=1;if(incr!==0)huff&=incr-1,huff+=incr;else huff=0;if(sym++,--count[len]===0){if(len===max)break;len=lens[lens_index+work[sym]]}if(len>root&&(huff&mask)!==low){if(drop===0)drop=root;next+=min,curr=len-drop,left=1<ENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;low=huff&mask,table[low]=root<<24|curr<<16|next-table_index|0}}if(huff!==0)table[next+huff]=len-drop<<24|64<<16|0;return opts.bits=root,0}}}),require_inflate=__commonJS({\"node_modules/pako/lib/zlib/inflate.js\"(exports){var utils=require_common(),adler32=require_adler32(),crc32=require_crc32(),inflate_fast=require_inffast(),inflate_table=require_inftrees(),CODES=0,LENS=1,DISTS=2,Z_FINISH=4,Z_BLOCK=5,Z_TREES=6,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR=-5,Z_DEFLATED=8,HEAD=1,FLAGS=2,TIME=3,OS=4,EXLEN=5,EXTRA=6,NAME=7,COMMENT=8,HCRC=9,DICTID=10,DICT=11,TYPE=12,TYPEDO=13,STORED=14,COPY_=15,COPY=16,TABLE=17,LENLENS=18,CODELENS=19,LEN_=20,LEN=21,LENEXT=22,DIST=23,DISTEXT=24,MATCH=25,LIT=26,CHECK=27,LENGTH=28,DONE=29,BAD=30,MEM=31,SYNC=32,ENOUGH_LENS=852,ENOUGH_DISTS=592,MAX_WBITS=15,DEF_WBITS=MAX_WBITS;function zswap32(q){return(q>>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function InflateState(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new utils.Buf16(320),this.work=new utils.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateResetKeep(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;if(state=strm.state,strm.total_in=strm.total_out=state.total=0,strm.msg=\"\",state.wrap)strm.adler=state.wrap&1;return state.mode=HEAD,state.last=0,state.havedict=0,state.dmax=32768,state.head=null,state.hold=0,state.bits=0,state.lencode=state.lendyn=new utils.Buf32(ENOUGH_LENS),state.distcode=state.distdyn=new utils.Buf32(ENOUGH_DISTS),state.sane=1,state.back=-1,Z_OK}function inflateReset(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;return state=strm.state,state.wsize=0,state.whave=0,state.wnext=0,inflateResetKeep(strm)}function inflateReset2(strm,windowBits){var wrap,state;if(!strm||!strm.state)return Z_STREAM_ERROR;if(state=strm.state,windowBits<0)wrap=0,windowBits=-windowBits;else if(wrap=(windowBits>>4)+1,windowBits<48)windowBits&=15;if(windowBits&&(windowBits<8||windowBits>15))return Z_STREAM_ERROR;if(state.window!==null&&state.wbits!==windowBits)state.window=null;return state.wrap=wrap,state.wbits=windowBits,inflateReset(strm)}function inflateInit2(strm,windowBits){var ret,state;if(!strm)return Z_STREAM_ERROR;if(state=new InflateState,strm.state=state,state.window=null,ret=inflateReset2(strm,windowBits),ret!==Z_OK)strm.state=null;return ret}function inflateInit(strm){return inflateInit2(strm,DEF_WBITS)}var virgin=!0,lenfix,distfix;function fixedtables(state){if(virgin){var sym;lenfix=new utils.Buf32(512),distfix=new utils.Buf32(32),sym=0;while(sym<144)state.lens[sym++]=8;while(sym<256)state.lens[sym++]=9;while(sym<280)state.lens[sym++]=7;while(sym<288)state.lens[sym++]=8;inflate_table(LENS,state.lens,0,288,lenfix,0,state.work,{bits:9}),sym=0;while(sym<32)state.lens[sym++]=5;inflate_table(DISTS,state.lens,0,32,distfix,0,state.work,{bits:5}),virgin=!1}state.lencode=lenfix,state.lenbits=9,state.distcode=distfix,state.distbits=5}function updatewindow(strm,src,end,copy){var dist,state=strm.state;if(state.window===null)state.wsize=1<=state.wsize)utils.arraySet(state.window,src,end-state.wsize,state.wsize,0),state.wnext=0,state.whave=state.wsize;else{if(dist=state.wsize-state.wnext,dist>copy)dist=copy;if(utils.arraySet(state.window,src,end-copy,dist,state.wnext),copy-=dist,copy)utils.arraySet(state.window,src,end-copy,copy,0),state.wnext=copy,state.whave=state.wsize;else{if(state.wnext+=dist,state.wnext===state.wsize)state.wnext=0;if(state.whave>>8&255,state.check=crc32(state.check,hbuf,2,0),hold=0,bits=0,state.mode=FLAGS;break}if(state.flags=0,state.head)state.head.done=!1;if(!(state.wrap&1)||(((hold&255)<<8)+(hold>>8))%31){strm.msg=\"incorrect header check\",state.mode=BAD;break}if((hold&15)!==Z_DEFLATED){strm.msg=\"unknown compression method\",state.mode=BAD;break}if(hold>>>=4,bits-=4,len=(hold&15)+8,state.wbits===0)state.wbits=len;else if(len>state.wbits){strm.msg=\"invalid window size\",state.mode=BAD;break}state.dmax=1<>8&1;if(state.flags&512)hbuf[0]=hold&255,hbuf[1]=hold>>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0,state.mode=TIME;case TIME:while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>8&255,hbuf[2]=hold>>>16&255,hbuf[3]=hold>>>24&255,state.check=crc32(state.check,hbuf,4,0);hold=0,bits=0,state.mode=OS;case OS:while(bits<16){if(have===0)break inf_leave;have--,hold+=input[next++]<>8;if(state.flags&512)hbuf[0]=hold&255,hbuf[1]=hold>>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0,state.mode=EXLEN;case EXLEN:if(state.flags&1024){while(bits<16){if(have===0)break inf_leave;have--,hold+=input[next++]<>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0}else if(state.head)state.head.extra=null;state.mode=EXTRA;case EXTRA:if(state.flags&1024){if(copy=state.length,copy>have)copy=have;if(copy){if(state.head){if(len=state.head.extra_len-state.length,!state.head.extra)state.head.extra=new Array(state.head.extra_len);utils.arraySet(state.head.extra,input,next,copy,len)}if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy,next+=copy,state.length-=copy}if(state.length)break inf_leave}state.length=0,state.mode=NAME;case NAME:if(state.flags&2048){if(have===0)break inf_leave;copy=0;do if(len=input[next+copy++],state.head&&len&&state.length<65536)state.head.name+=String.fromCharCode(len);while(len&©>9&1,state.head.done=!0;strm.adler=state.check=0,state.mode=TYPE;break;case DICTID:while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=bits&7,bits-=bits&7,state.mode=CHECK;break}while(bits<3){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=1,bits-=1,hold&3){case 0:state.mode=STORED;break;case 1:if(fixedtables(state),state.mode=LEN_,flush===Z_TREES){hold>>>=2,bits-=2;break inf_leave}break;case 2:state.mode=TABLE;break;case 3:strm.msg=\"invalid block type\",state.mode=BAD}hold>>>=2,bits-=2;break;case STORED:hold>>>=bits&7,bits-=bits&7;while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>16^65535)){strm.msg=\"invalid stored block lengths\",state.mode=BAD;break}if(state.length=hold&65535,hold=0,bits=0,state.mode=COPY_,flush===Z_TREES)break inf_leave;case COPY_:state.mode=COPY;case COPY:if(copy=state.length,copy){if(copy>have)copy=have;if(copy>left)copy=left;if(copy===0)break inf_leave;utils.arraySet(output,input,next,copy,put),have-=copy,next+=copy,left-=copy,put+=copy,state.length-=copy;break}state.mode=TYPE;break;case TABLE:while(bits<14){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=5,bits-=5,state.ndist=(hold&31)+1,hold>>>=5,bits-=5,state.ncode=(hold&15)+4,hold>>>=4,bits-=4,state.nlen>286||state.ndist>30){strm.msg=\"too many length or distance symbols\",state.mode=BAD;break}state.have=0,state.mode=LENLENS;case LENLENS:while(state.have>>=3,bits-=3}while(state.have<19)state.lens[order[state.have++]]=0;if(state.lencode=state.lendyn,state.lenbits=7,opts={bits:state.lenbits},ret=inflate_table(CODES,state.lens,0,19,state.lencode,0,state.work,opts),state.lenbits=opts.bits,ret){strm.msg=\"invalid code lengths set\",state.mode=BAD;break}state.have=0,state.mode=CODELENS;case CODELENS:while(state.have>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=here_bits,bits-=here_bits,state.lens[state.have++]=here_val;else{if(here_val===16){n=here_bits+2;while(bits>>=here_bits,bits-=here_bits,state.have===0){strm.msg=\"invalid bit length repeat\",state.mode=BAD;break}len=state.lens[state.have-1],copy=3+(hold&3),hold>>>=2,bits-=2}else if(here_val===17){n=here_bits+3;while(bits>>=here_bits,bits-=here_bits,len=0,copy=3+(hold&7),hold>>>=3,bits-=3}else{n=here_bits+7;while(bits>>=here_bits,bits-=here_bits,len=0,copy=11+(hold&127),hold>>>=7,bits-=7}if(state.have+copy>state.nlen+state.ndist){strm.msg=\"invalid bit length repeat\",state.mode=BAD;break}while(copy--)state.lens[state.have++]=len}}if(state.mode===BAD)break;if(state.lens[256]===0){strm.msg=\"invalid code -- missing end-of-block\",state.mode=BAD;break}if(state.lenbits=9,opts={bits:state.lenbits},ret=inflate_table(LENS,state.lens,0,state.nlen,state.lencode,0,state.work,opts),state.lenbits=opts.bits,ret){strm.msg=\"invalid literal/lengths set\",state.mode=BAD;break}if(state.distbits=6,state.distcode=state.distdyn,opts={bits:state.distbits},ret=inflate_table(DISTS,state.lens,state.nlen,state.ndist,state.distcode,0,state.work,opts),state.distbits=opts.bits,ret){strm.msg=\"invalid distances set\",state.mode=BAD;break}if(state.mode=LEN_,flush===Z_TREES)break inf_leave;case LEN_:state.mode=LEN;case LEN:if(have>=6&&left>=258){if(strm.next_out=put,strm.avail_out=left,strm.next_in=next,strm.avail_in=have,state.hold=hold,state.bits=bits,inflate_fast(strm,_out),put=strm.next_out,output=strm.output,left=strm.avail_out,next=strm.next_in,input=strm.input,have=strm.avail_in,hold=state.hold,bits=state.bits,state.mode===TYPE)state.back=-1;break}state.back=0;for(;;){if(here=state.lencode[hold&(1<>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>last_bits)],here_bits=here>>>24,here_op=here>>>16&255,here_val=here&65535,last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=last_bits,bits-=last_bits,state.back+=last_bits}if(hold>>>=here_bits,bits-=here_bits,state.back+=here_bits,state.length=here_val,here_op===0){state.mode=LIT;break}if(here_op&32){state.back=-1,state.mode=TYPE;break}if(here_op&64){strm.msg=\"invalid literal/length code\",state.mode=BAD;break}state.extra=here_op&15,state.mode=LENEXT;case LENEXT:if(state.extra){n=state.extra;while(bits>>=state.extra,bits-=state.extra,state.back+=state.extra}state.was=state.length,state.mode=DIST;case DIST:for(;;){if(here=state.distcode[hold&(1<>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>last_bits)],here_bits=here>>>24,here_op=here>>>16&255,here_val=here&65535,last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=last_bits,bits-=last_bits,state.back+=last_bits}if(hold>>>=here_bits,bits-=here_bits,state.back+=here_bits,here_op&64){strm.msg=\"invalid distance code\",state.mode=BAD;break}state.offset=here_val,state.extra=here_op&15,state.mode=DISTEXT;case DISTEXT:if(state.extra){n=state.extra;while(bits>>=state.extra,bits-=state.extra,state.back+=state.extra}if(state.offset>state.dmax){strm.msg=\"invalid distance too far back\",state.mode=BAD;break}state.mode=MATCH;case MATCH:if(left===0)break inf_leave;if(copy=_out-left,state.offset>copy){if(copy=state.offset-copy,copy>state.whave){if(state.sane){strm.msg=\"invalid distance too far back\",state.mode=BAD;break}}if(copy>state.wnext)copy-=state.wnext,from=state.wsize-copy;else from=state.wnext-copy;if(copy>state.length)copy=state.length;from_source=state.window}else from_source=output,from=put-state.offset,copy=state.length;if(copy>left)copy=left;left-=copy,state.length-=copy;do output[put++]=from_source[from++];while(--copy);if(state.length===0)state.mode=LEN;break;case LIT:if(left===0)break inf_leave;output[put++]=state.length,left--,state.mode=LEN;break;case CHECK:if(state.wrap){while(bits<32){if(have===0)break inf_leave;have--,hold|=input[next++]<exports.UNZIP)@throwTypeError(\"Bad argument\");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=mode,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}Zlib.prototype={},Zlib.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}if(this.pending_close=!1,assert(this.init_done,\"close before init\"),assert(this.mode<=exports.UNZIP),this.mode===exports.DEFLATE||this.mode===exports.GZIP||this.mode===exports.DEFLATERAW)zlib_deflate.deflateEnd(this.strm);else if(this.mode===exports.INFLATE||this.mode===exports.GUNZIP||this.mode===exports.INFLATERAW||this.mode===exports.UNZIP)zlib_inflate.inflateEnd(this.strm);this.mode=exports.NONE,this.dictionary=null},Zlib.prototype.write=function(flush,input,in_off,in_len,out,out_off,out_len){return this._write(!0,flush,input,in_off,in_len,out,out_off,out_len)},Zlib.prototype.writeSync=function(flush,input,in_off,in_len,out,out_off,out_len){return this._write(!1,flush,input,in_off,in_len,out,out_off,out_len)},Zlib.prototype._write=function(async,flush,input,in_off,in_len,out,out_off,out_len){if(assert.equal(arguments.length,8),assert(this.init_done,\"write before init\"),assert(this.mode!==exports.NONE,\"already finalized\"),assert.equal(!1,this.write_in_progress,\"write already in progress\"),assert.equal(!1,this.pending_close,\"close is pending\"),this.write_in_progress=!0,assert.equal(!1,flush===void 0,\"must provide flush value\"),this.write_in_progress=!0,flush!==exports.Z_NO_FLUSH&&flush!==exports.Z_PARTIAL_FLUSH&&flush!==exports.Z_SYNC_FLUSH&&flush!==exports.Z_FULL_FLUSH&&flush!==exports.Z_FINISH&&flush!==exports.Z_BLOCK)throw new Error(\"Invalid flush value\");if(input==null)input=Buffer.alloc(0),in_len=0,in_off=0;if(this.strm.avail_in=in_len,this.strm.input=input,this.strm.next_in=in_off,this.strm.avail_out=out_len,this.strm.output=out,this.strm.next_out=out_off,this.flush=flush,!async){if(this._process(),this._checkError())return this._afterSync();return}var self=this;return process.nextTick(function(){self._process(),self._after()}),this},Zlib.prototype._afterSync=function(){var avail_out=this.strm.avail_out,avail_in=this.strm.avail_in;return this.write_in_progress=!1,[avail_in,avail_out]},Zlib.prototype._process=function(){var next_expected_header_byte=null;switch(this.mode){case exports.DEFLATE:case exports.GZIP:case exports.DEFLATERAW:this.err=zlib_deflate.deflate(this.strm,this.flush);break;case exports.UNZIP:if(this.strm.avail_in>0)next_expected_header_byte=this.strm.next_in;switch(this.gzip_id_bytes_read){case 0:if(next_expected_header_byte===null)break;if(this.strm.input[next_expected_header_byte]===GZIP_HEADER_ID1){if(this.gzip_id_bytes_read=1,next_expected_header_byte++,this.strm.avail_in===1)break}else{this.mode=exports.INFLATE;break}case 1:if(next_expected_header_byte===null)break;if(this.strm.input[next_expected_header_byte]===GZIP_HEADER_ID2)this.gzip_id_bytes_read=2,this.mode=exports.GUNZIP;else this.mode=exports.INFLATE;break;default:throw new Error(\"invalid number of gzip magic number bytes read\")}case exports.INFLATE:case exports.GUNZIP:case exports.INFLATERAW:if(this.err=zlib_inflate.inflate(this.strm,this.flush),this.err===exports.Z_NEED_DICT&&this.dictionary){if(this.err=zlib_inflate.inflateSetDictionary(this.strm,this.dictionary),this.err===exports.Z_OK)this.err=zlib_inflate.inflate(this.strm,this.flush);else if(this.err===exports.Z_DATA_ERROR)this.err=exports.Z_NEED_DICT}while(this.strm.avail_in>0&&this.mode===exports.GUNZIP&&this.err===exports.Z_STREAM_END&&this.strm.next_in[0]!==0)this.reset(),this.err=zlib_inflate.inflate(this.strm,this.flush);break;default:throw new Error(\"Unknown mode \"+this.mode)}},Zlib.prototype._checkError=function(){switch(this.err){case exports.Z_OK:case exports.Z_BUF_ERROR:if(this.strm.avail_out!==0&&this.flush===exports.Z_FINISH)return this._error(\"unexpected end of file\"),!1;break;case exports.Z_STREAM_END:break;case exports.Z_NEED_DICT:if(this.dictionary==null)this._error(\"Missing dictionary\");else this._error(\"Bad dictionary\");return!1;default:return this._error(\"Zlib error\"),!1}return!0},Zlib.prototype._after=function(){if(!this._checkError())return;var avail_out=this.strm.avail_out,avail_in=this.strm.avail_in;if(this.write_in_progress=!1,this.callback(avail_in,avail_out),this.pending_close)this.close()},Zlib.prototype._error=function(message){if(this.strm.msg)message=this.strm.msg;if(this.onerror(message,this.err),this.write_in_progress=!1,this.pending_close)this.close()},Zlib.prototype.init=function(windowBits,level,memLevel,strategy,dictionary){assert(arguments.length===4||arguments.length===5,\"init(windowBits, level, memLevel, strategy, [dictionary])\"),assert(windowBits>=8&&windowBits<=15,\"invalid windowBits\"),assert(level>=-1&&level<=9,\"invalid compression level\"),assert(memLevel>=1&&memLevel<=9,\"invalid memlevel\"),assert(strategy===exports.Z_FILTERED||strategy===exports.Z_HUFFMAN_ONLY||strategy===exports.Z_RLE||strategy===exports.Z_FIXED||strategy===exports.Z_DEFAULT_STRATEGY,\"invalid strategy\"),this._init(level,windowBits,memLevel,strategy,dictionary),this._setDictionary()},Zlib.prototype.params=function(){throw new Error(\"deflateParams Not supported\")},Zlib.prototype.reset=function(){this._reset(),this._setDictionary()},Zlib.prototype._init=function(level,windowBits,memLevel,strategy,dictionary){if(this.level=level,this.windowBits=windowBits,this.memLevel=memLevel,this.strategy=strategy,this.flush=exports.Z_NO_FLUSH,this.err=exports.Z_OK,this.mode===exports.GZIP||this.mode===exports.GUNZIP)this.windowBits+=16;if(this.mode===exports.UNZIP)this.windowBits+=32;if(this.mode===exports.DEFLATERAW||this.mode===exports.INFLATERAW)this.windowBits=-1*this.windowBits;switch(this.strm=new Zstream,this.mode){case exports.DEFLATE:case exports.GZIP:case exports.DEFLATERAW:this.err=zlib_deflate.deflateInit2(this.strm,this.level,exports.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case exports.INFLATE:case exports.GUNZIP:case exports.INFLATERAW:case exports.UNZIP:this.err=zlib_inflate.inflateInit2(this.strm,this.windowBits);break;default:throw new Error(\"Unknown mode \"+this.mode)}if(this.err!==exports.Z_OK)this._error(\"Init error\");this.dictionary=dictionary,this.write_in_progress=!1,this.init_done=!0},Zlib.prototype._setDictionary=function(){if(this.dictionary==null)return;switch(this.err=exports.Z_OK,this.mode){case exports.DEFLATE:case exports.DEFLATERAW:this.err=zlib_deflate.deflateSetDictionary(this.strm,this.dictionary);break;default:break}if(this.err!==exports.Z_OK)this._error(\"Failed to set dictionary\")},Zlib.prototype._reset=function(){switch(this.err=exports.Z_OK,this.mode){case exports.DEFLATE:case exports.DEFLATERAW:case exports.GZIP:this.err=zlib_deflate.deflateReset(this.strm);break;case exports.INFLATE:case exports.INFLATERAW:case exports.GUNZIP:this.err=zlib_inflate.inflateReset(this.strm);break;default:break}if(this.err!==exports.Z_OK)this._error(\"Failed to reset stream\")},exports.Zlib=Zlib}}),require_lib=__commonJS({\"node_modules/browserify-zlib/lib/index.js\"(exports){var Buffer2=BufferModule.Buffer,Transform=StreamModule.Transform,binding=require_binding(),util=Util,kMaxLength=BufferModule.kMaxLength,kRangeErrorMessage=\"Cannot create final Buffer. It would be larger than 0x\"+kMaxLength.toString(16)+\" bytes\";binding.Z_MIN_WINDOWBITS=8,binding.Z_MAX_WINDOWBITS=15,binding.Z_DEFAULT_WINDOWBITS=15,binding.Z_MIN_CHUNK=64,binding.Z_MAX_CHUNK=Infinity,binding.Z_DEFAULT_CHUNK=16384,binding.Z_MIN_MEMLEVEL=1,binding.Z_MAX_MEMLEVEL=9,binding.Z_DEFAULT_MEMLEVEL=8,binding.Z_MIN_LEVEL=-1,binding.Z_MAX_LEVEL=9,binding.Z_DEFAULT_LEVEL=binding.Z_DEFAULT_COMPRESSION;var bkeys=Object.keys(binding);for(bk=0;bk=kMaxLength)err=new RangeError(kRangeErrorMessage);else buf=Buffer2.concat(buffers,nread);buffers=[],engine.close(),callback(err,buf)}}function zlibBufferSync(engine,buffer){if(typeof buffer===\"string\")buffer=Buffer2.from(buffer);if(!Buffer2.isBuffer(buffer))@throwTypeError(\"Not a string or buffer\");var flushFlag=engine._finishFlushFlag;return engine._processChunk(buffer,flushFlag)}function Deflate(opts){if(!(this instanceof Deflate))return new Deflate(opts);Zlib.call(this,opts,binding.DEFLATE)}function Inflate(opts){if(!(this instanceof Inflate))return new Inflate(opts);Zlib.call(this,opts,binding.INFLATE)}function Gzip(opts){if(!(this instanceof Gzip))return new Gzip(opts);Zlib.call(this,opts,binding.GZIP)}function Gunzip(opts){if(!(this instanceof Gunzip))return new Gunzip(opts);Zlib.call(this,opts,binding.GUNZIP)}function DeflateRaw(opts){if(!(this instanceof DeflateRaw))return new DeflateRaw(opts);Zlib.call(this,opts,binding.DEFLATERAW)}function InflateRaw(opts){if(!(this instanceof InflateRaw))return new InflateRaw(opts);Zlib.call(this,opts,binding.INFLATERAW)}function Unzip(opts){if(!(this instanceof Unzip))return new Unzip(opts);Zlib.call(this,opts,binding.UNZIP)}function isValidFlushFlag(flag){return flag===binding.Z_NO_FLUSH||flag===binding.Z_PARTIAL_FLUSH||flag===binding.Z_SYNC_FLUSH||flag===binding.Z_FULL_FLUSH||flag===binding.Z_FINISH||flag===binding.Z_BLOCK}function Zlib(opts,mode){var _this=this;if(this._opts=opts=opts||{},this._chunkSize=opts.chunkSize||exports.Z_DEFAULT_CHUNK,Transform.call(this,opts),opts.flush&&!isValidFlushFlag(opts.flush))throw new Error(\"Invalid flush flag: \"+opts.flush);if(opts.finishFlush&&!isValidFlushFlag(opts.finishFlush))throw new Error(\"Invalid flush flag: \"+opts.finishFlush);if(this._flushFlag=opts.flush||binding.Z_NO_FLUSH,this._finishFlushFlag=typeof opts.finishFlush!==\"undefined\"\?opts.finishFlush:binding.Z_FINISH,opts.chunkSize){if(opts.chunkSizeexports.Z_MAX_CHUNK)throw new Error(\"Invalid chunk size: \"+opts.chunkSize)}if(opts.windowBits){if(opts.windowBitsexports.Z_MAX_WINDOWBITS)throw new Error(\"Invalid windowBits: \"+opts.windowBits)}if(opts.level){if(opts.levelexports.Z_MAX_LEVEL)throw new Error(\"Invalid compression level: \"+opts.level)}if(opts.memLevel){if(opts.memLevelexports.Z_MAX_MEMLEVEL)throw new Error(\"Invalid memLevel: \"+opts.memLevel)}if(opts.strategy){if(opts.strategy!=exports.Z_FILTERED&&opts.strategy!=exports.Z_HUFFMAN_ONLY&&opts.strategy!=exports.Z_RLE&&opts.strategy!=exports.Z_FIXED&&opts.strategy!=exports.Z_DEFAULT_STRATEGY)throw new Error(\"Invalid strategy: \"+opts.strategy)}if(opts.dictionary){if(!Buffer2.isBuffer(opts.dictionary))throw new Error(\"Invalid dictionary: it should be a Buffer instance\")}this._handle=new binding.Zlib(mode);var self=this;this._hadError=!1,this._handle.onerror=function(message,errno){_close(self),self._hadError=!0;var error=new Error(message);error.errno=errno,error.code=exports.codes[errno],self.emit(\"error\",error)};var level=exports.Z_DEFAULT_COMPRESSION;if(typeof opts.level===\"number\")level=opts.level;var strategy=exports.Z_DEFAULT_STRATEGY;if(typeof opts.strategy===\"number\")strategy=opts.strategy;this._handle.init(opts.windowBits||exports.Z_DEFAULT_WINDOWBITS,level,opts.memLevel||exports.Z_DEFAULT_MEMLEVEL,strategy,opts.dictionary),this._buffer=Buffer2.allocUnsafe(this._chunkSize),this._offset=0,this._level=level,this._strategy=strategy,this.once(\"end\",this.close),Object.defineProperty(this,\"_closed\",{get:function(){return!_this._handle},configurable:!0,enumerable:!0})}util.inherits(Zlib,Transform),Zlib.prototype.params=function(level,strategy,callback){if(levelexports.Z_MAX_LEVEL)@throwRangeError(\"Invalid compression level: \"+level);if(strategy!=exports.Z_FILTERED&&strategy!=exports.Z_HUFFMAN_ONLY&&strategy!=exports.Z_RLE&&strategy!=exports.Z_FIXED&&strategy!=exports.Z_DEFAULT_STRATEGY)@throwTypeError(\"Invalid strategy: \"+strategy);if(this._level!==level||this._strategy!==strategy){var self=this;this.flush(binding.Z_SYNC_FLUSH,function(){if(assert(self._handle,\"zlib binding closed\"),self._handle.params(level,strategy),!self._hadError){if(self._level=level,self._strategy=strategy,callback)callback()}})}else process.nextTick(callback)},Zlib.prototype.reset=function(){return assert(this._handle,\"zlib binding closed\"),this._handle.reset()},Zlib.prototype._flush=function(callback){this._transform(Buffer2.alloc(0),\"\",callback)},Zlib.prototype.flush=function(kind,callback){var _this2=this,ws=this._writableState;if(typeof kind===\"function\"||kind===void 0&&!callback)callback=kind,kind=binding.Z_FULL_FLUSH;if(ws.ended){if(callback)process.nextTick(callback)}else if(ws.ending){if(callback)this.once(\"end\",callback)}else if(ws.needDrain){if(callback)this.once(\"drain\",function(){return _this2.flush(kind,callback)})}else this._flushFlag=kind,this.write(Buffer2.alloc(0),\"\",callback)},Zlib.prototype.close=function(callback){_close(this,callback),process.nextTick(emitCloseNT,this)};function _close(engine,callback){if(callback)process.nextTick(callback);if(!engine._handle)return;engine._handle.close(),engine._handle=null}function emitCloseNT(self){self.emit(\"close\")}Zlib.prototype._transform=function(chunk,encoding,cb){var flushFlag,ws=this._writableState,ending=ws.ending||ws.ended,last=ending&&(!chunk||ws.length===chunk.length);if(chunk!==null&&!Buffer2.isBuffer(chunk))return cb(new Error(\"invalid input\"));if(!this._handle)return cb(new Error(\"zlib binding closed\"));if(last)flushFlag=this._finishFlushFlag;else if(flushFlag=this._flushFlag,chunk.length>=ws.length)this._flushFlag=this._opts.flush||binding.Z_NO_FLUSH;this._processChunk(chunk,flushFlag,cb)},Zlib.prototype._processChunk=function(chunk,flushFlag,cb){var availInBefore=chunk&&chunk.length,availOutBefore=this._chunkSize-this._offset,inOff=0,self=this,async=typeof cb===\"function\";if(!async){var buffers=[],nread=0,error;this.on(\"error\",function(er){error=er}),assert(this._handle,\"zlib binding closed\");do var res=this._handle.writeSync(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore);while(!this._hadError&&callback(res[0],res[1]));if(this._hadError)throw error;if(nread>=kMaxLength)_close(this),@throwRangeError(kRangeErrorMessage);var buf=Buffer2.concat(buffers,nread);return _close(this),buf}assert(this._handle,\"zlib binding closed\");var req=this._handle.write(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore);req.buffer=chunk,req.callback=callback;function callback(availInAfter,availOutAfter){if(this)this.buffer=null,this.callback=null;if(self._hadError)return;var have=availOutBefore-availOutAfter;if(assert(have>=0,\"have should not go down\"),have>0){var out=self._buffer.slice(self._offset,self._offset+have);if(self._offset+=have,async)self.push(out);else buffers.push(out),nread+=out.length}if(availOutAfter===0||self._offset>=self._chunkSize)availOutBefore=self._chunkSize,self._offset=0,self._buffer=Buffer2.allocUnsafe(self._chunkSize);if(availOutAfter===0){if(inOff+=availInBefore-availInAfter,availInBefore=availInAfter,!async)return!0;var newReq=self._handle.write(flushFlag,chunk,inOff,availInBefore,self._buffer,self._offset,self._chunkSize);newReq.callback=callback,newReq.buffer=chunk;return}if(!async)return!1;cb()}},util.inherits(Deflate,Zlib),util.inherits(Inflate,Zlib),util.inherits(Gzip,Zlib),util.inherits(Gunzip,Zlib),util.inherits(DeflateRaw,Zlib),util.inherits(InflateRaw,Zlib),util.inherits(Unzip,Zlib)}});return require_lib()})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDepdCode = "(function (){\"use strict\";var $=function depd(namespace){if(!namespace)@throwTypeError(\"argument namespace is required\");function deprecate(message){}return deprecate._file=void 0,deprecate._ignored=!0,deprecate._namespace=namespace,deprecate._traced=!1,deprecate._warned=Object.create(null),deprecate.function=wrapfunction,deprecate.property=wrapproperty,deprecate};function wrapfunction(fn,message){if(typeof fn!==\"function\")@throwTypeError(\"argument fn must be a function\");return fn}function wrapproperty(obj,prop,message){if(!obj||typeof obj!==\"object\"&&typeof obj!==\"function\")@throwTypeError(\"argument obj must be object\");var descriptor=Object.getOwnPropertyDescriptor(obj,prop);if(!descriptor)@throwTypeError(\"must call property on owner object\");if(!descriptor.configurable)@throwTypeError(\"property must be configurable\")}return $})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDetectLibcCode = "(function (){\"use strict\";function family(){return Promise.resolve(familySync())}function familySync(){return null}const GLIBC=\"glibc\",MUSL=\"musl\";function versionAsync(){return Promise.resolve(version())}function version(){return null}function isNonGlibcLinuxSync(){return!1}function isNonGlibcLinux(){return Promise.resolve(isNonGlibcLinuxSync())}return{GLIBC,MUSL,family,familySync,isNonGlibcLinux,isNonGlibcLinuxSync,version,versionAsync}})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDetectLibcLinuxCode = "(function (){\"use strict\";function family(){return Promise.resolve(familySync())}function familySync(){return GLIBC}const GLIBC=\"glibc\",MUSL=\"musl\";function versionAsync(){return Promise.resolve(version())}function version(){return\"2.29\"}function isNonGlibcLinuxSync(){return!1}function isNonGlibcLinux(){return Promise.resolve(isNonGlibcLinuxSync())}return{GLIBC,MUSL,family,familySync,isNonGlibcLinux,isNonGlibcLinuxSync,version,versionAsync}})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyIsomorphicFetchCode = "(function (){\"use strict\";return globalThis.fetch})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyNodeFetchCode = "(function (){\"use strict\";const{Headers,Request,Response,Blob,File=Blob,FormData}=globalThis,realFetch=Bun.fetch;function fetch(...args){return realFetch(...args)}class AbortError extends DOMException{constructor(message){super(message,\"AbortError\")}}class FetchBaseError extends Error{constructor(message,type){super(message);this.type=type}}class FetchError extends FetchBaseError{constructor(message,type,systemError){super(message,type);this.code=systemError\?.code}}function blobFrom(path,options){return Promise.resolve(Bun.file(data))}function blobFromSync(path,options){return Bun.file(data)}var fileFrom=blobFrom,fileFromSync=blobFromSync;function isRedirect(code){return code===301||code===302||code===303||code===307||code===308}return Object.assign(fetch,{AbortError,Blob,FetchBaseError,FetchError,File,FormData,Headers,Request,Response,blobFrom,blobFromSync,fileFrom,fileFromSync,isRedirect,fetch})})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyUndiciCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),{Readable}=StreamModule,{_ReadableFromWebForUndici:ReadableFromWeb}=StreamModule[Symbol.for(\"::bunternal::\")],ObjectCreate=Object.create,kEmptyObject=ObjectCreate(null);var fetch=Bun.fetch,Response=globalThis.Response,Headers=globalThis.Headers,Request=globalThis.Request,URLSearchParams=globalThis.URLSearchParams,URL=globalThis.URL;class File extends Blob{constructor(){super(...arguments)}}class FileReader extends EventTarget{constructor(){throw new Error(\"Not implemented yet!\")}}var FormData=globalThis.FormData;function notImplemented(){throw new Error(\"Not implemented in bun\")}class BodyReadable extends ReadableFromWeb{#response;#bodyUsed;constructor(response,options={}){var{body}=response;if(!body)throw new Error(\"Response body is null\");super(options,body);this.#response=response,this.#bodyUsed=response.bodyUsed}get bodyUsed(){return this.#bodyUsed}#consume(){if(this.#bodyUsed)@throwTypeError(\"unusable\");this.#bodyUsed=!0}async arrayBuffer(){return this.#consume(),await this.#response.arrayBuffer()}async blob(){return this.#consume(),await this.#response.blob()}async formData(){return this.#consume(),await this.#response.formData()}async json(){return this.#consume(),await this.#response.json()}async text(){return this.#consume(),await this.#response.text()}}async function request(url,options={method:\"GET\",signal:null,headers:null,query:null,reset:!1,throwOnError:!1,body:null}){let{method=\"GET\",headers:inputHeaders,query,signal,reset=!1,throwOnError=!1,body:inputBody,maxRedirections}=options;if(typeof url===\"string\"){if(query)url=new URL(url)}else if(typeof url===\"object\"&&url!==null){if(!(url instanceof URL))throw new Error(\"not implemented\")}else @throwTypeError(\"url must be a string, URL, or UrlObject\");if(typeof url===\"string\"&&query)url=new URL(url);if(typeof url===\"object\"&&url!==null&&query){if(query)url.search=new URLSearchParams(query).toString()}if(method=method&&typeof method===\"string\"\?method.toUpperCase():null,inputBody&&(method===\"GET\"||method===\"HEAD\"))throw new Error(\"Body not allowed for GET or HEAD requests\");if(inputBody&&inputBody.read&&inputBody instanceof Readable){let data=\"\";inputBody.setEncoding(\"utf8\");for await(let chunk of stream)data+=chunk;inputBody=(new TextEncoder()).encode(data)}if(maxRedirections!==void 0&&Number.isNaN(maxRedirections))throw new Error(\"maxRedirections must be a number if defined\");if(signal&&!(signal instanceof AbortSignal))throw new Error(\"signal must be an instance of AbortSignal\");let resp;const{status:statusCode,headers,trailers}=resp=await fetch(url,{signal,mode:\"cors\",method,headers:inputHeaders||kEmptyObject,body:inputBody,redirect:maxRedirections===\"undefined\"||maxRedirections>0\?\"follow\":\"manual\",keepalive:!reset});if(throwOnError&&statusCode>=400&&statusCode<600)throw new Error(`Request failed with status code ${statusCode}`);const body=resp.body\?new BodyReadable(resp):null;return{statusCode,headers:headers.toJSON(),body,trailers,opaque:kEmptyObject,context:kEmptyObject}}function stream(){throw new Error(\"Not implemented in bun\")}function pipeline(){throw new Error(\"Not implemented in bun\")}function connect(){throw new Error(\"Not implemented in bun\")}function upgrade(){throw new Error(\"Not implemented in bun\")}class MockClient{constructor(){throw new Error(\"Not implemented in bun\")}}class MockPool{constructor(){throw new Error(\"Not implemented in bun\")}}class MockAgent{constructor(){throw new Error(\"Not implemented in bun\")}}function mockErrors(){throw new Error(\"Not implemented in bun\")}function Undici(){throw new Error(\"Not implemented in bun\")}class Dispatcher extends EventEmitter{constructor(){super(...arguments)}}class Agent extends Dispatcher{constructor(){super(...arguments)}}class Pool extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}class BalancedPool extends Dispatcher{constructor(){super(...arguments)}}class Client extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}return Undici.Dispatcher=Dispatcher,Undici.Pool=Pool,Undici.BalancedPool=BalancedPool,Undici.Client=Client,Undici.Agent=Agent,Undici.buildConnector=Undici.errors=Undici.setGlobalDispatcher=Undici.getGlobalDispatcher=Undici.request=Undici.stream=Undici.pipeline=Undici.connect=Undici.upgrade=Undici.MockClient=Undici.MockPool=Undici.MockAgent=Undici.mockErrors=notImplemented,Undici.fetch=fetch,{fetch,Response,Headers,Request,URLSearchParams,URL,File,FileReader,FormData,request,stream,pipeline,connect,upgrade,MockClient,MockPool,MockAgent,mockErrors,Dispatcher,Pool,BalancedPool,Client,Agent,Undici}})\n"_s; +// + +// +static constexpr ASCIILiteral ThirdpartyUtf8ValidateCode = "(function (){\"use strict\";return @requireNativeModule(\"node:buffer\").isUtf8})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyVercelFetchCode = "(function (){\"use strict\";var $=(wrapper=Bun.fetch)=>{async function vercelFetch(url,opts={}){if(opts.body&&typeof opts.body===\"object\"&&(!(\"buffer\"in opts.body)||typeof opts.body.buffer!==\"object\"||!(opts.body.buffer instanceof ArrayBuffer))){if(opts.body=JSON.stringify(opts.body),!opts.headers)opts.headers=new Headers;opts.headers.set(\"Content-Type\",\"application/json\")}try{return await wrapper(url,opts)}catch(err){if(typeof err===\"string\")err=new Error(err);throw err.url=url,err.opts=opts,err}}return vercelFetch.default=vercelFetch,vercelFetch};return $})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyWSCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),http=@getInternalField(@internalModuleRegistry,18)||@createInternalModuleById(18),kBunInternals=Symbol.for(\"::bunternal::\"),readyStates=[\"CONNECTING\",\"OPEN\",\"CLOSING\",\"CLOSED\"],encoder=new TextEncoder,eventIds={open:1,close:2,message:3,error:4,ping:5,pong:6},emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}class BunWebSocket extends EventEmitter{static CONNECTING=0;static OPEN=1;static CLOSING=2;static CLOSED=3;#ws;#paused=!1;#fragments=!1;#binaryType=\"nodebuffer\";#eventId=0;constructor(url,protocols,options){super();let ws=this.#ws=new WebSocket(url,protocols);ws.binaryType=\"nodebuffer\"}on(event,listener){if(event===\"unexpected-response\"||event===\"upgrade\"||event===\"redirect\")emitWarning(event,\"ws.WebSocket '\"+event+\"' event is not implemented in bun\");const mask=1<{this.emit(\"open\")});else if(event===\"close\")this.#ws.addEventListener(\"close\",({code,reason,wasClean})=>{this.emit(\"close\",code,reason,wasClean)});else if(event===\"message\")this.#ws.addEventListener(\"message\",({data})=>{const isBinary=typeof data!==\"string\";if(isBinary)this.emit(\"message\",this.#fragments\?[data]:data,isBinary);else{let encoded=encoder.encode(data);if(this.#binaryType!==\"arraybuffer\")encoded=Buffer.from(encoded.buffer,encoded.byteOffset,encoded.byteLength);this.emit(\"message\",this.#fragments\?[encoded]:encoded,isBinary)}});else if(event===\"error\")this.#ws.addEventListener(\"error\",(err)=>{this.emit(\"error\",err)});else if(event===\"ping\")this.#ws.addEventListener(\"ping\",({data})=>{this.emit(\"ping\",data)});else if(event===\"pong\")this.#ws.addEventListener(\"pong\",({data})=>{this.emit(\"pong\",data)})}return super.on(event,listener)}send(data,opts,cb){try{this.#ws.send(data,opts\?.compress)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}close(code,reason){this.#ws.close(code,reason)}terminate(){this.#ws.terminate()}get url(){return this.#ws.url}get readyState(){return this.#ws.readyState}get binaryType(){return this.#binaryType}set binaryType(value){if(value===\"nodebuffer\"||value===\"arraybuffer\")this.#ws.binaryType=this.#binaryType=value,this.#fragments=!1;else if(value===\"fragments\")this.#ws.binaryType=\"nodebuffer\",this.#binaryType=\"fragments\",this.#fragments=!0;else throw new Error(`Invalid binaryType: ${value}`)}get protocol(){return this.#ws.protocol}get extensions(){return this.#ws.extensions}addEventListener(type,listener,options){this.#ws.addEventListener(type,listener,options)}removeEventListener(type,listener){this.#ws.removeEventListener(type,listener)}get onopen(){return this.#ws.onopen}set onopen(value){this.#ws.onopen=value}get onerror(){return this.#ws.onerror}set onerror(value){this.#ws.onerror=value}get onclose(){return this.#ws.onclose}set onclose(value){this.#ws.onclose=value}get onmessage(){return this.#ws.onmessage}set onmessage(value){this.#ws.onmessage=value}get bufferedAmount(){return this.#ws.bufferedAmount}get isPaused(){return this.#paused}ping(data,mask,cb){if(typeof data===\"function\")cb=data,data=mask=void 0;else if(typeof mask===\"function\")cb=mask,mask=void 0;if(typeof data===\"number\")data=data.toString();try{this.#ws.ping(data)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}pong(data,mask,cb){if(typeof data===\"function\")cb=data,data=mask=void 0;else if(typeof mask===\"function\")cb=mask,mask=void 0;if(typeof data===\"number\")data=data.toString();try{this.#ws.pong(data)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}pause(){switch(this.readyState){case WebSocket.CONNECTING:case WebSocket.CLOSED:return}this.#paused=!0,emitWarning(\"pause()\",\"ws.WebSocket.pause() is not implemented in bun\")}resume(){switch(this.readyState){case WebSocket.CONNECTING:case WebSocket.CLOSED:return}this.#paused=!1,emitWarning(\"resume()\",\"ws.WebSocket.resume() is not implemented in bun\")}}Object.defineProperty(BunWebSocket,\"name\",{value:\"WebSocket\"});const wsKeyRegex=/^[+/0-9A-Za-z]{22}==$/,wsTokenChars=[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,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function subprotocolParse(header){const protocols=new Set;let start=-1,end=-1,i=0;for(i;i{const body=http.STATUS_CODES[426];res.writeHead(426,{\"Content-Length\":body.length,\"Content-Type\":\"text/plain\"}),res.end(body)}),this._server.listen(options.port,options.host,options.backlog,callback);else if(options.server)this._server=options.server;if(this._server){const emitConnection=this.emit.bind(this,\"connection\"),emitListening=this.emit.bind(this,\"listening\"),emitError=this.emit.bind(this,\"error\"),doUpgrade=(req,socket,head)=>{this.handleUpgrade(req,socket,head,emitConnection)};this._server.on(\"listening\",emitListening),this._server.on(\"error\",emitError),this._server.on(\"upgrade\",doUpgrade),this._removeListeners=()=>{this._server.removeListener(\"upgrade\",doUpgrade),this._server.removeListener(\"listening\",emitListening),this._server.removeListener(\"error\",emitError)}}if(options.perMessageDeflate===!0)options.perMessageDeflate={};if(options.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=options,this._state=RUNNING}address(){if(this.options.noServer)throw new Error('The server is operating in \"noServer\" mode');if(!this._server)return null;return this._server.address()}close(cb){if(this._state===CLOSED){if(cb)this.once(\"close\",()=>{cb(new Error(\"The server is not running\"))});process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this);return}if(cb)this.once(\"close\",cb);if(this._state===CLOSING)return;if(this._state=CLOSING,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this);else this._shouldEmitClose=!0;else process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this)}else{const server=this._server;this._removeListeners(),this._removeListeners=this._server=null,server.close(()=>{this._state=CLOSED,this.emit(\"close\")})}}shouldHandle(req){if(this.options.path){const index=req.url.indexOf(\"\?\");if((index!==-1\?req.url.slice(0,index):req.url)!==this.options.path)return!1}return!0}completeUpgrade(extensions,key,protocols,request,socket,head,cb){const[server,response,req]=socket[kBunInternals];if(this._state>RUNNING)return abortHandshake(response,503);let protocol=\"\";if(protocols.size)protocol=this.options.handleProtocols\?this.options.handleProtocols(protocols,request):protocols.values().next().value;const ws=new BunWebSocketMocked(request.url,protocol,extensions,\"nodebuffer\"),headers=[\"HTTP/1.1 101 Switching Protocols\",\"Upgrade: websocket\",\"Connection: Upgrade\"];if(this.emit(\"headers\",headers,request),server.upgrade(req,{data:ws[kBunInternals]})){if(response._reply(void 0),this.clients)this.clients.add(ws),ws.on(\"close\",()=>{if(this.clients.delete(ws),this._shouldEmitClose&&!this.clients.size)process.nextTick(wsEmitClose,this)});cb(ws,request)}else abortHandshake(response,500)}handleUpgrade(req,socket,head,cb){const[_,response]=socket[kBunInternals],key=req.headers[\"sec-websocket-key\"],version=+req.headers[\"sec-websocket-version\"];if(req.method!==\"GET\"){abortHandshakeOrEmitwsClientError(this,req,response,socket,405,\"Invalid HTTP method\");return}if(req.headers.upgrade.toLowerCase()!==\"websocket\"){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Invalid Upgrade header\");return}if(!key||!wsKeyRegex.test(key)){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Missing or invalid Sec-WebSocket-Key header\");return}if(version!==8&&version!==13){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Missing or invalid Sec-WebSocket-Version header\");return}if(!this.shouldHandle(req)){abortHandshake(response,400);return}const secWebSocketProtocol=req.headers[\"sec-websocket-protocol\"];let protocols=new Set;if(secWebSocketProtocol!==void 0)try{protocols=subprotocolParse(secWebSocketProtocol)}catch(err){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Invalid Sec-WebSocket-Protocol header\");return}const extensions={};if(this.options.verifyClient){const info={origin:req.headers[`${version===8\?\"sec-websocket-origin\":\"origin\"}`],secure:!!(req.socket.authorized||req.socket.encrypted),req};if(this.options.verifyClient.length===2){this.options.verifyClient(info,(verified,code,message,headers)=>{if(!verified)return abortHandshake(response,code||401,message,headers);this.completeUpgrade(extensions,key,protocols,req,socket,head,cb)});return}if(!this.options.verifyClient(info))return abortHandshake(response,401)}this.completeUpgrade(extensions,key,protocols,req,socket,head,cb)}}Object.defineProperty(BunWebSocket,\"CONNECTING\",{enumerable:!0,value:readyStates.indexOf(\"CONNECTING\")}),Object.defineProperty(BunWebSocket.prototype,\"CONNECTING\",{enumerable:!0,value:readyStates.indexOf(\"CONNECTING\")}),Object.defineProperty(BunWebSocket,\"OPEN\",{enumerable:!0,value:readyStates.indexOf(\"OPEN\")}),Object.defineProperty(BunWebSocket.prototype,\"OPEN\",{enumerable:!0,value:readyStates.indexOf(\"OPEN\")}),Object.defineProperty(BunWebSocket,\"CLOSING\",{enumerable:!0,value:readyStates.indexOf(\"CLOSING\")}),Object.defineProperty(BunWebSocket.prototype,\"CLOSING\",{enumerable:!0,value:readyStates.indexOf(\"CLOSING\")}),Object.defineProperty(BunWebSocket,\"CLOSED\",{enumerable:!0,value:readyStates.indexOf(\"CLOSED\")}),Object.defineProperty(BunWebSocket.prototype,\"CLOSED\",{enumerable:!0,value:readyStates.indexOf(\"CLOSED\")});class Sender{constructor(){throw new Error(\"Not supported yet in Bun\")}}class Receiver{constructor(){throw new Error(\"Not supported yet in Bun\")}}var createWebSocketStream=(ws)=>{throw new Error(\"Not supported yet in Bun\")};return Object.assign(BunWebSocket,{createWebSocketStream,Receiver,Sender,WebSocket:BunWebSocket,Server:WebSocketServer,WebSocketServer})})\n"_s; +// + #else // Not 100% accurate, but basically inlining linux on non-windows non-mac platforms. - static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";const FFIType={\"0\":0,\"1\":1,\"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\"7\":7,\"8\":8,\"9\":9,\"10\":10,\"11\":11,\"12\":12,\"13\":13,\"14\":14,\"15\":15,\"16\":16,\"17\":17,bool:11,c_int:5,c_uint:6,char:0,\"char*\":12,double:9,f32:10,f64:9,float:10,i16:3,i32:5,i64:7,i8:1,int:5,int16_t:3,int32_t:5,int64_t:7,int8_t:1,isize:7,u16:4,u32:6,u64:8,u8:2,uint16_t:4,uint32_t:6,uint64_t:8,uint8_t:2,usize:8,\"void*\":12,ptr:12,pointer:12,void:13,cstring:14,i64_fast:15,u64_fast:16,function:17,callback:17,fn:17};var ffi=globalThis.Bun.FFI;const ptr=(arg1,arg2)=>typeof arg2===\"undefined\"\?ffi.ptr(arg1):ffi.ptr(arg1,arg2),toBuffer=ffi.toBuffer,toArrayBuffer=ffi.toArrayBuffer,viewSource=ffi.viewSource,BunCString=ffi.CString,nativeLinkSymbols=ffi.linkSymbols,nativeDLOpen=ffi.dlopen,nativeCallback=ffi.callback,closeCallback=ffi.closeCallback;delete ffi.callback,delete ffi.closeCallback;class JSCallback{constructor(cb,options){const{ctx,ptr:ptr2}=nativeCallback(options,cb);this.#ctx=ctx,this.ptr=ptr2,this.#threadsafe=!!options\?.threadsafe}ptr;#ctx;#threadsafe;get threadsafe(){return this.#threadsafe}[Symbol.toPrimitive](){const{ptr:ptr2}=this;return typeof ptr2===\"number\"\?ptr2:0}close(){const ctx=this.#ctx;if(this.ptr=null,this.#ctx=null,ctx)closeCallback(ctx)}}class CString extends String{constructor(ptr2,byteOffset,byteLength){super(ptr2\?typeof byteLength===\"number\"&&Number.isSafeInteger(byteLength)\?new BunCString(ptr2,byteOffset||0,byteLength):new BunCString(ptr2):\"\");if(this.ptr=typeof ptr2===\"number\"\?ptr2:0,typeof byteOffset!==\"undefined\")this.byteOffset=byteOffset;if(typeof byteLength!==\"undefined\")this.byteLength=byteLength}ptr;byteOffset;byteLength;#cachedArrayBuffer;get arrayBuffer(){if(this.#cachedArrayBuffer)return this.#cachedArrayBuffer;if(!this.ptr)return this.#cachedArrayBuffer=new ArrayBuffer(0);return this.#cachedArrayBuffer=toArrayBuffer(this.ptr,this.byteOffset,this.byteLength)}}Object.defineProperty(globalThis,\"__GlobalBunCString\",{value:CString,enumerable:!1,configurable:!1});const ffiWrappers=new Array(18);var char=\"val|0\";ffiWrappers.fill(char),ffiWrappers[FFIType.uint8_t]=\"val<0\?0:val>=255\?255:val|0\",ffiWrappers[FFIType.int16_t]=\"val<=-32768\?-32768:val>=32768\?32768:val|0\",ffiWrappers[FFIType.uint16_t]=\"val<=0\?0:val>=65536\?65536:val|0\",ffiWrappers[FFIType.int32_t]=\"val|0\",ffiWrappers[FFIType.uint32_t]=\"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\",ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.int64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.uint64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`,ffiWrappers[FFIType.uint16_t]=`{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`,ffiWrappers[FFIType.double]=`{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`,ffiWrappers[FFIType.float]=ffiWrappers[10]=`{\n return Math.fround(val);\n}`,ffiWrappers[FFIType.bool]=`{\n return !!val;\n}`,Object.defineProperty(globalThis,\"__GlobalBunFFIPtrFunctionForWrapper\",{value:ptr,enumerable:!1,configurable:!0}),ffiWrappers[FFIType.cstring]=ffiWrappers[FFIType.pointer]=`{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`,ffiWrappers[FFIType.function]=`{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;function FFIBuilder(params,returnType,functionToCall,name){const hasReturnType=typeof FFIType[returnType]===\"number\"&&FFIType[returnType]!==FFIType.void;var paramNames=new Array(params.length),args=new Array(params.length);for(let i=0;i${wrapper})(p${i})`;else @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`)}var code=`functionToCall(${args.join(\", \")})`;if(hasReturnType)if(FFIType[returnType]===FFIType.cstring)code=`return new __GlobalBunCString(${code})`;else code=`return ${code}`;var func=new Function(\"functionToCall\",...paramNames,code);Object.defineProperty(func,\"name\",{value:name});var wrap;switch(paramNames.length){case 0:wrap=()=>func(functionToCall);break;case 1:wrap=(arg1)=>func(functionToCall,arg1);break;case 2:wrap=(arg1,arg2)=>func(functionToCall,arg1,arg2);break;case 3:wrap=(arg1,arg2,arg3)=>func(functionToCall,arg1,arg2,arg3);break;case 4:wrap=(arg1,arg2,arg3,arg4)=>func(functionToCall,arg1,arg2,arg3,arg4);break;case 5:wrap=(arg1,arg2,arg3,arg4,arg5)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5);break;case 6:wrap=(arg1,arg2,arg3,arg4,arg5,arg6)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6);break;case 7:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7);break;case 8:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);break;case 9:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);break;default:{wrap=(...args2)=>func(functionToCall,...args2);break}}return wrap.native=functionToCall,wrap.ptr=functionToCall.ptr,wrap}const native={dlopen:nativeDLOpen,callback:()=>{throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\")}};function dlopen(path,options){const result=nativeDLOpen(path,options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,path.includes(\"/\")\?`${key} (${path.split(\"/\").pop()})`:`${key} (${path})`);else result.symbols[key].native=result.symbols[key]}return result}function linkSymbols(options){const result=nativeLinkSymbols(options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,key);else result.symbols[key].native=result.symbols[key]}return result}var cFunctionI=0,cFunctionRegistry;function onCloseCFunction(close){close()}function CFunction(options){const identifier=`CFunction${cFunctionI++}`;var result=linkSymbols({[identifier]:options}),hasClosed=!1,close=result.close;return result.symbols[identifier].close=()=>{if(hasClosed||!close)return;hasClosed=!0,close(),close=void 0},cFunctionRegistry||=new FinalizationRegistry(onCloseCFunction),cFunctionRegistry.register(result.symbols[identifier],result.symbols[identifier].close),result.symbols[identifier]}const read=ffi.read;return{CFunction,CString,FFIType,JSCallback,dlopen,linkSymbols,native,ptr,read,suffix:\".so\",toArrayBuffer,toBuffer,viewSource}})\n"_s; + // +static constexpr ASCIILiteral BunFFICode = "(function (){\"use strict\";const FFIType={\"0\":0,\"1\":1,\"2\":2,\"3\":3,\"4\":4,\"5\":5,\"6\":6,\"7\":7,\"8\":8,\"9\":9,\"10\":10,\"11\":11,\"12\":12,\"13\":13,\"14\":14,\"15\":15,\"16\":16,\"17\":17,bool:11,c_int:5,c_uint:6,char:0,\"char*\":12,double:9,f32:10,f64:9,float:10,i16:3,i32:5,i64:7,i8:1,int:5,int16_t:3,int32_t:5,int64_t:7,int8_t:1,isize:7,u16:4,u32:6,u64:8,u8:2,uint16_t:4,uint32_t:6,uint64_t:8,uint8_t:2,usize:8,\"void*\":12,ptr:12,pointer:12,void:13,cstring:14,i64_fast:15,u64_fast:16,function:17,callback:17,fn:17};var ffi=globalThis.Bun.FFI;const ptr=(arg1,arg2)=>typeof arg2===\"undefined\"\?ffi.ptr(arg1):ffi.ptr(arg1,arg2),toBuffer=ffi.toBuffer,toArrayBuffer=ffi.toArrayBuffer,viewSource=ffi.viewSource,BunCString=ffi.CString,nativeLinkSymbols=ffi.linkSymbols,nativeDLOpen=ffi.dlopen,nativeCallback=ffi.callback,closeCallback=ffi.closeCallback;delete ffi.callback,delete ffi.closeCallback;class JSCallback{constructor(cb,options){const{ctx,ptr:ptr2}=nativeCallback(options,cb);this.#ctx=ctx,this.ptr=ptr2,this.#threadsafe=!!options\?.threadsafe}ptr;#ctx;#threadsafe;get threadsafe(){return this.#threadsafe}[Symbol.toPrimitive](){const{ptr:ptr2}=this;return typeof ptr2===\"number\"\?ptr2:0}close(){const ctx=this.#ctx;if(this.ptr=null,this.#ctx=null,ctx)closeCallback(ctx)}}class CString extends String{constructor(ptr2,byteOffset,byteLength){super(ptr2\?typeof byteLength===\"number\"&&Number.isSafeInteger(byteLength)\?new BunCString(ptr2,byteOffset||0,byteLength):new BunCString(ptr2):\"\");if(this.ptr=typeof ptr2===\"number\"\?ptr2:0,typeof byteOffset!==\"undefined\")this.byteOffset=byteOffset;if(typeof byteLength!==\"undefined\")this.byteLength=byteLength}ptr;byteOffset;byteLength;#cachedArrayBuffer;get arrayBuffer(){if(this.#cachedArrayBuffer)return this.#cachedArrayBuffer;if(!this.ptr)return this.#cachedArrayBuffer=new ArrayBuffer(0);return this.#cachedArrayBuffer=toArrayBuffer(this.ptr,this.byteOffset,this.byteLength)}}Object.defineProperty(globalThis,\"__GlobalBunCString\",{value:CString,enumerable:!1,configurable:!1});const ffiWrappers=new Array(18);var char=\"val|0\";ffiWrappers.fill(char),ffiWrappers[FFIType.uint8_t]=\"val<0\?0:val>=255\?255:val|0\",ffiWrappers[FFIType.int16_t]=\"val<=-32768\?-32768:val>=32768\?32768:val|0\",ffiWrappers[FFIType.uint16_t]=\"val<=0\?0:val>=65536\?65536:val|0\",ffiWrappers[FFIType.int32_t]=\"val|0\",ffiWrappers[FFIType.uint32_t]=\"val<=0\?0:val>=0xffffffff\?0xffffffff:+val||0\",ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.i64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(-Number.MAX_SAFE_INTEGER)) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= 0) {\n return Number(val).valueOf() || 0;\n }\n\n return val;\n }\n\n return !val \? 0 : +val || 0;\n}`,ffiWrappers[FFIType.int64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.uint64_t]=`{\n if (typeof val === \"bigint\") {\n return val;\n }\n\n if (typeof val === \"number\") {\n return val <= 0 \? BigInt(0) : BigInt(val || 0);\n }\n\n return BigInt(+val || 0);\n}`,ffiWrappers[FFIType.u64_fast]=`{\n if (typeof val === \"bigint\") {\n if (val <= BigInt(Number.MAX_SAFE_INTEGER) && val >= BigInt(0)) return Number(val);\n return val;\n }\n\n return typeof val === \"number\" \? (val <= 0 \? 0 : +val || 0) : +val || 0;\n}`,ffiWrappers[FFIType.uint16_t]=`{\n const ret = (typeof val === \"bigint\" \? Number(val) : val) | 0;\n return ret <= 0 \? 0 : ret > 0xffff \? 0xffff : ret;\n}`,ffiWrappers[FFIType.double]=`{\n if (typeof val === \"bigint\") {\n if (val.valueOf() < BigInt(Number.MAX_VALUE)) {\n return Math.abs(Number(val).valueOf()) + 0.00000000000001 - 0.00000000000001;\n }\n }\n\n if (!val) {\n return 0 + 0.00000000000001 - 0.00000000000001;\n }\n\n return val + 0.00000000000001 - 0.00000000000001;\n}`,ffiWrappers[FFIType.float]=ffiWrappers[10]=`{\n return Math.fround(val);\n}`,ffiWrappers[FFIType.bool]=`{\n return !!val;\n}`,Object.defineProperty(globalThis,\"__GlobalBunFFIPtrFunctionForWrapper\",{value:ptr,enumerable:!1,configurable:!0}),ffiWrappers[FFIType.cstring]=ffiWrappers[FFIType.pointer]=`{\n if (typeof val === \"number\") return val;\n if (!val) {\n return null;\n }\n\n if (ArrayBuffer.isView(val) || val instanceof ArrayBuffer) {\n return __GlobalBunFFIPtrFunctionForWrapper(val);\n }\n\n if (typeof val === \"string\") {\n throw new TypeError(\"To convert a string to a pointer, encode it as a buffer\");\n }\n\n throw new TypeError(\\`Unable to convert \\${ val } to a pointer\\`);\n}`,ffiWrappers[FFIType.function]=`{\n if (typeof val === \"number\") {\n return val;\n }\n\n if (typeof val === \"bigint\") {\n return Number(val);\n }\n\n var ptr = val && val.ptr;\n\n if (!ptr) {\n throw new TypeError(\"Expected function to be a JSCallback or a number\");\n }\n\n return ptr;\n}`;function FFIBuilder(params,returnType,functionToCall,name){const hasReturnType=typeof FFIType[returnType]===\"number\"&&FFIType[returnType]!==FFIType.void;var paramNames=new Array(params.length),args=new Array(params.length);for(let i=0;i${wrapper})(p${i})`;else @throwTypeError(`Unsupported type ${params[i]}. Must be one of: ${Object.keys(FFIType).sort().join(\", \")}`)}var code=`functionToCall(${args.join(\", \")})`;if(hasReturnType)if(FFIType[returnType]===FFIType.cstring)code=`return new __GlobalBunCString(${code})`;else code=`return ${code}`;var func=new Function(\"functionToCall\",...paramNames,code);Object.defineProperty(func,\"name\",{value:name});var wrap;switch(paramNames.length){case 0:wrap=()=>func(functionToCall);break;case 1:wrap=(arg1)=>func(functionToCall,arg1);break;case 2:wrap=(arg1,arg2)=>func(functionToCall,arg1,arg2);break;case 3:wrap=(arg1,arg2,arg3)=>func(functionToCall,arg1,arg2,arg3);break;case 4:wrap=(arg1,arg2,arg3,arg4)=>func(functionToCall,arg1,arg2,arg3,arg4);break;case 5:wrap=(arg1,arg2,arg3,arg4,arg5)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5);break;case 6:wrap=(arg1,arg2,arg3,arg4,arg5,arg6)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6);break;case 7:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7);break;case 8:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8);break;case 9:wrap=(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)=>func(functionToCall,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);break;default:{wrap=(...args2)=>func(functionToCall,...args2);break}}return wrap.native=functionToCall,wrap.ptr=functionToCall.ptr,wrap}const native={dlopen:nativeDLOpen,callback:()=>{throw new Error(\"Deprecated. Use new JSCallback(options, fn) instead\")}};function dlopen(path,options){const result=nativeDLOpen(path,options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,path.includes(\"/\")\?`${key} (${path.split(\"/\").pop()})`:`${key} (${path})`);else result.symbols[key].native=result.symbols[key]}return result}function linkSymbols(options){const result=nativeLinkSymbols(options);for(let key in result.symbols){var symbol=result.symbols[key];if(options[key]\?.args\?.length||FFIType[options[key]\?.returns]===FFIType.cstring)result.symbols[key]=FFIBuilder(options[key].args\?\?[],options[key].returns\?\?FFIType.void,symbol,key);else result.symbols[key].native=result.symbols[key]}return result}var cFunctionI=0,cFunctionRegistry;function onCloseCFunction(close){close()}function CFunction(options){const identifier=`CFunction${cFunctionI++}`;var result=linkSymbols({[identifier]:options}),hasClosed=!1,close=result.close;return result.symbols[identifier].close=()=>{if(hasClosed||!close)return;hasClosed=!0,close(),close=void 0},cFunctionRegistry||=new FinalizationRegistry(onCloseCFunction),cFunctionRegistry.register(result.symbols[identifier],result.symbols[identifier].close),result.symbols[identifier]}const read=ffi.read;return{CFunction,CString,FFIType,JSCallback,dlopen,linkSymbols,native,ptr,read,suffix:\".so\",toArrayBuffer,toBuffer,viewSource}})\n"_s; +// + +// static constexpr ASCIILiteral BunSqliteCode = "(function (){\"use strict\";var defineProperties=Object.defineProperties,toStringTag=Symbol.toStringTag,isArray=Array.isArray,isTypedArray=ArrayBuffer.isView;const constants={SQLITE_OPEN_READONLY:1,SQLITE_OPEN_READWRITE:2,SQLITE_OPEN_CREATE:4,SQLITE_OPEN_DELETEONCLOSE:8,SQLITE_OPEN_EXCLUSIVE:16,SQLITE_OPEN_AUTOPROXY:32,SQLITE_OPEN_URI:64,SQLITE_OPEN_MEMORY:128,SQLITE_OPEN_MAIN_DB:256,SQLITE_OPEN_TEMP_DB:512,SQLITE_OPEN_TRANSIENT_DB:1024,SQLITE_OPEN_MAIN_JOURNAL:2048,SQLITE_OPEN_TEMP_JOURNAL:4096,SQLITE_OPEN_SUBJOURNAL:8192,SQLITE_OPEN_SUPER_JOURNAL:16384,SQLITE_OPEN_NOMUTEX:32768,SQLITE_OPEN_FULLMUTEX:65536,SQLITE_OPEN_SHAREDCACHE:131072,SQLITE_OPEN_PRIVATECACHE:262144,SQLITE_OPEN_WAL:524288,SQLITE_OPEN_NOFOLLOW:16777216,SQLITE_OPEN_EXRESCODE:33554432,SQLITE_PREPARE_PERSISTENT:1,SQLITE_PREPARE_NORMALIZE:2,SQLITE_PREPARE_NO_VTAB:4};var SQL,controllers;class Statement{constructor(raw){switch(this.#raw=raw,raw.paramsCount){case 0:{this.get=this.#getNoArgs,this.all=this.#allNoArgs,this.values=this.#valuesNoArgs,this.run=this.#runNoArgs;break}default:{this.get=this.#get,this.all=this.#all,this.values=this.#values,this.run=this.#run;break}}}#raw;get;all;values;run;isFinalized=!1;toJSON(){return{sql:this.native.toString(),isFinalized:this.isFinalized,paramsCount:this.paramsCount,columnNames:this.columnNames}}get[toStringTag](){return`\"${this.native.toString()}\"`}toString(){return this.native.toString()}get native(){return this.#raw}#getNoArgs(){return this.#raw.get()}#allNoArgs(){return this.#raw.all()}#valuesNoArgs(){return this.#raw.values()}#runNoArgs(){this.#raw.run()}#get(...args){if(args.length===0)return this.#getNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.get(args):this.#raw.get(...args)}#all(...args){if(args.length===0)return this.#allNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.all(args):this.#raw.all(...args)}#values(...args){if(args.length===0)return this.#valuesNoArgs();var arg0=args[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.values(args):this.#raw.values(...args)}#run(...args){if(args.length===0)return this.#runNoArgs();var arg0=args[0];!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?this.#raw.run(args):this.#raw.run(...args)}get columnNames(){return this.#raw.columns}get paramsCount(){return this.#raw.paramsCount}finalize(...args){return this.isFinalized=!0,this.#raw.finalize(...args)}}var cachedCount=Symbol.for(\"Bun.Database.cache.count\");class Database{constructor(filenameGiven,options){if(typeof filenameGiven===\"undefined\");else if(typeof filenameGiven!==\"string\"){if(isTypedArray(filenameGiven)){this.#handle=Database.deserialize(filenameGiven,typeof options===\"object\"&&options\?!!options.readonly:((options|0)&constants.SQLITE_OPEN_READONLY)!=0),this.filename=\":memory:\";return}@throwTypeError(`Expected 'filename' to be a string, got '${typeof filenameGiven}'`)}var filename=typeof filenameGiven===\"string\"\?filenameGiven.trim():\":memory:\",flags=constants.SQLITE_OPEN_READWRITE|constants.SQLITE_OPEN_CREATE;if(typeof options===\"object\"&&options){if(flags=0,options.readonly)flags=constants.SQLITE_OPEN_READONLY;if(\"readOnly\"in options)@throwTypeError('Misspelled option \"readOnly\" should be \"readonly\"');if(options.create)flags=constants.SQLITE_OPEN_READWRITE|constants.SQLITE_OPEN_CREATE;if(options.readwrite)flags|=constants.SQLITE_OPEN_READWRITE}else if(typeof options===\"number\")flags=options;const anonymous=filename===\"\"||filename===\":memory:\";if(anonymous&&(flags&constants.SQLITE_OPEN_READONLY)!==0)throw new Error(\"Cannot open an anonymous database in read-only mode.\");if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");this.#handle=SQL.open(anonymous\?\":memory:\":filename,flags),this.filename=filename}#handle;#cachedQueriesKeys=[];#cachedQueriesLengths=[];#cachedQueriesValues=[];filename;get handle(){return this.#handle}get inTransaction(){return SQL.isInTransaction(this.#handle)}static open(filename,options){return new Database(filename,options)}loadExtension(name,entryPoint){return SQL.loadExtension(this.#handle,name,entryPoint)}serialize(optionalName){return SQL.serialize(this.#handle,optionalName||\"main\")}static deserialize(serialized,isReadOnly=!1){if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");return SQL.deserialize(serialized,isReadOnly)}static setCustomSQLite(path){if(!SQL)SQL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"sqlite\");return SQL.setCustomSQLite(path)}close(){return this.clearQueryCache(),SQL.close(this.#handle)}clearQueryCache(){for(let item of this.#cachedQueriesValues)item.finalize();this.#cachedQueriesKeys.length=0,this.#cachedQueriesValues.length=0,this.#cachedQueriesLengths.length=0}run(query,...params){if(params.length===0){SQL.run(this.#handle,query);return}var arg0=params[0];return!isArray(arg0)&&(!arg0||typeof arg0!==\"object\"||isTypedArray(arg0))\?SQL.run(this.#handle,query,params):SQL.run(this.#handle,query,...params)}prepare(query,params,flags){return new Statement(SQL.prepare(this.#handle,query,params,flags||0))}static MAX_QUERY_CACHE_SIZE=20;get[cachedCount](){return this.#cachedQueriesKeys.length}query(query){if(typeof query!==\"string\")@throwTypeError(`Expected 'query' to be a string, got '${typeof query}'`);if(query.length===0)throw new Error(\"SQL query cannot be empty.\");var index=this.#cachedQueriesLengths.indexOf(query.length);while(index!==-1){if(this.#cachedQueriesKeys[index]!==query){index=this.#cachedQueriesLengths.indexOf(query.length,index+1);continue}var stmt=this.#cachedQueriesValues[index];if(stmt.isFinalized)return this.#cachedQueriesValues[index]=this.prepare(query,void 0,willCache\?constants.SQLITE_PREPARE_PERSISTENT:0);return stmt}const willCache=this.#cachedQueriesKeys.length{let controller=(controllers||=new WeakMap).get(db);if(!controller){const shared={commit:db.prepare(\"COMMIT\",void 0,0),rollback:db.prepare(\"ROLLBACK\",void 0,0),savepoint:db.prepare(\"SAVEPOINT `\\t_bs3.\\t`\",void 0,0),release:db.prepare(\"RELEASE `\\t_bs3.\\t`\",void 0,0),rollbackTo:db.prepare(\"ROLLBACK TO `\\t_bs3.\\t`\",void 0,0)};controllers.set(db,controller={default:Object.assign({begin:db.prepare(\"BEGIN\",void 0,0)},shared),deferred:Object.assign({begin:db.prepare(\"BEGIN DEFERRED\",void 0,0)},shared),immediate:Object.assign({begin:db.prepare(\"BEGIN IMMEDIATE\",void 0,0)},shared),exclusive:Object.assign({begin:db.prepare(\"BEGIN EXCLUSIVE\",void 0,0)},shared)})}return controller},wrapTransaction=(fn,db,{begin,commit,rollback,savepoint,release,rollbackTo})=>function transaction(...args){let before,after,undo;if(db.inTransaction)before=savepoint,after=release,undo=rollbackTo;else before=begin,after=commit,undo=rollback;try{before.run();const result=fn.apply(this,args);return after.run(),result}catch(ex){if(db.inTransaction){if(undo.run(),undo!==rollback)after.run()}throw ex}};return{__esModule:!0,Database,Statement,constants,default:Database}})\n"_s; +// + +// static constexpr ASCIILiteral InternalSharedCode = "(function (){\"use strict\";class NotImplementedError extends Error{code;constructor(feature,issue){super(feature+\" is not yet implemented in Bun.\"+(issue\?\" Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/\"+issue:\"\"));this.name=\"NotImplementedError\",this.code=\"ERR_NOT_IMPLEMENTED\",hideFromStack(NotImplementedError)}}function throwNotImplemented(feature,issue){throw hideFromStack(throwNotImplemented),new NotImplementedError(feature,issue)}function hideFromStack(...fns){for(let fn of fns)Object.defineProperty(fn,\"name\",{value:\"::bunternal::\"})}return{NotImplementedError,throwNotImplemented,hideFromStack}})\n"_s; +// + +// static constexpr ASCIILiteral NodeAssertCode = "(function (){\"use strict\";const util=@getInternalField(@internalModuleRegistry,42)||@createInternalModuleById(42);var isDeepEqual=Bun.deepEquals,__commonJS=(cb,mod)=>function(){return mod||(0,cb[Object.keys(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_errors=__commonJS({\"assert/build/internal/errors.js\"(exports,module2){function _typeof(obj){return typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"\?_typeof=function(obj2){return typeof obj2}:_typeof=function(obj2){return obj2&&typeof Symbol==\"function\"&&obj2.constructor===Symbol&&obj2!==Symbol.prototype\?\"symbol\":typeof obj2},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))@throwTypeError(\"Cannot call a class as a function\")}function _possibleConstructorReturn(self,call){return call&&(_typeof(call)===\"object\"||typeof call==\"function\")\?call:_assertThisInitialized(self)}function _assertThisInitialized(self){if(self===void 0)throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");return self}function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf\?Object.getPrototypeOf:function(o2){return o2.__proto__||Object.getPrototypeOf(o2)},_getPrototypeOf(o)}function _inherits(subClass,superClass){if(typeof superClass!=\"function\"&&superClass!==null)@throwTypeError(\"Super expression must either be null or a function\");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),superClass&&_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){return _setPrototypeOf=Object.setPrototypeOf||function(o2,p2){return o2.__proto__=p2,o2},_setPrototypeOf(o,p)}var codes={},assert,util2;function createErrorType(code,message,Base){Base||(Base=Error);function getMessage(arg1,arg2,arg3){return typeof message==\"string\"\?message:message(arg1,arg2,arg3)}var NodeError=function(_Base){_inherits(NodeError2,_Base);function NodeError2(arg1,arg2,arg3){var _this;return _classCallCheck(this,NodeError2),_this=_possibleConstructorReturn(this,_getPrototypeOf(NodeError2).call(this,getMessage(arg1,arg2,arg3))),_this.code=code,_this}return NodeError2}(Base);codes[code]=NodeError}function oneOf(expected,thing){if(Array.isArray(expected)){var len=expected.length;return expected=expected.map(function(i){return String(i)}),len>2\?\"one of \".concat(thing,\" \").concat(expected.slice(0,len-1).join(\", \"),\", or \")+expected[len-1]:len===2\?\"one of \".concat(thing,\" \").concat(expected[0],\" or \").concat(expected[1]):\"of \".concat(thing,\" \").concat(expected[0])}else return\"of \".concat(thing,\" \").concat(String(expected))}function startsWith(str,search,pos){return str.substr(!pos||pos<0\?0:+pos,search.length)===search}function endsWith(str,search,this_len){return(this_len===void 0||this_len>str.length)&&(this_len=str.length),str.substring(this_len-search.length,this_len)===search}function includes(str,search,start){return typeof start!=\"number\"&&(start=0),start+search.length>str.length\?!1:str.indexOf(search,start)!==-1}createErrorType(\"ERR_AMBIGUOUS_ARGUMENT\",'The \"%s\" argument is ambiguous. %s',TypeError),createErrorType(\"ERR_INVALID_ARG_TYPE\",function(name,expected,actual){assert===void 0&&(assert=require_assert()),assert(typeof name==\"string\",\"'name' must be a string\");var determiner;typeof expected==\"string\"&&startsWith(expected,\"not \")\?(determiner=\"must not be\",expected=expected.replace(/^not /,\"\")):determiner=\"must be\";var msg;if(endsWith(name,\" argument\"))msg=\"The \".concat(name,\" \").concat(determiner,\" \").concat(oneOf(expected,\"type\"));else{var type=includes(name,\".\")\?\"property\":\"argument\";msg='The \"'.concat(name,'\" ').concat(type,\" \").concat(determiner,\" \").concat(oneOf(expected,\"type\"))}return msg+=\". Received type \".concat(_typeof(actual)),msg},TypeError),createErrorType(\"ERR_INVALID_ARG_VALUE\",function(name,value){var reason=arguments.length>2&&arguments[2]!==void 0\?arguments[2]:\"is invalid\",inspected=util2.inspect(value);return inspected.length>128&&(inspected=\"\".concat(inspected.slice(0,128),\"...\")),\"The argument '\".concat(name,\"' \").concat(reason,\". Received \").concat(inspected)},TypeError,RangeError),createErrorType(\"ERR_INVALID_RETURN_VALUE\",function(input,name,value){var type;return value&&value.constructor&&value.constructor.name\?type=\"instance of \".concat(value.constructor.name):type=\"type \".concat(_typeof(value)),\"Expected \".concat(input,' to be returned from the \"').concat(name,'\"')+\" function but got \".concat(type,\".\")},TypeError),createErrorType(\"ERR_MISSING_ARGS\",function(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];assert===void 0&&(assert=require_assert()),assert(args.length>0,\"At least one arg needs to be specified\");var msg=\"The \",len=args.length;switch(args=args.map(function(a){return'\"'.concat(a,'\"')}),len){case 1:msg+=\"\".concat(args[0],\" argument\");break;case 2:msg+=\"\".concat(args[0],\" and \").concat(args[1],\" arguments\");break;default:msg+=args.slice(0,len-1).join(\", \"),msg+=\", and \".concat(args[len-1],\" arguments\");break}return\"\".concat(msg,\" must be specified\")},TypeError),module2.exports.codes=codes}}),require_assertion_error=__commonJS({\"assert/build/internal/assert/assertion_error.js\"(exports,module2){function _objectSpread(target){for(var i=1;istr.length)&&(this_len=str.length),str.substring(this_len-search.length,this_len)===search}function repeat(str,count){if(count=Math.floor(count),str.length==0||count==0)return\"\";var maxCount=str.length*count;for(count=Math.floor(Math.log(count)/Math.log(2));count;)str+=str,count--;return str+=str.substring(0,maxCount-str.length),str}var blue=\"\",green=\"\",red=\"\",white=\"\",kReadableOperator={deepStrictEqual:\"Expected values to be strictly deep-equal:\",strictEqual:\"Expected values to be strictly equal:\",strictEqualObject:'Expected \"actual\" to be reference-equal to \"expected\":',deepEqual:\"Expected values to be loosely deep-equal:\",equal:\"Expected values to be loosely equal:\",notDeepStrictEqual:'Expected \"actual\" not to be strictly deep-equal to:',notStrictEqual:'Expected \"actual\" to be strictly unequal to:',notStrictEqualObject:'Expected \"actual\" not to be reference-equal to \"expected\":',notDeepEqual:'Expected \"actual\" not to be loosely deep-equal to:',notEqual:'Expected \"actual\" to be loosely unequal to:',notIdentical:\"Values identical but not reference-equal:\"},kMaxShortLength=10;function copyError(source){var keys=Object.keys(source),target=Object.create(Object.getPrototypeOf(source));return keys.forEach(function(key){target[key]=source[key]}),Object.defineProperty(target,\"message\",{value:source.message}),target}function inspectValue(val){return inspect(val,{compact:!1,customInspect:!1,depth:1000,maxArrayLength:Infinity,showHidden:!1,breakLength:Infinity,showProxy:!1,sorted:!0,getters:!0})}function createErrDiff(actual,expected,operator){var other=\"\",res=\"\",lastPos=0,end=\"\",skipped=!1,actualInspected=inspectValue(actual),actualLines=actualInspected.split(`\n`),expectedLines=inspectValue(expected).split(`\n`),i=0,indicator=\"\";if(operator===\"strictEqual\"&&_typeof(actual)===\"object\"&&_typeof(expected)===\"object\"&&actual!==null&&expected!==null&&(operator=\"strictEqualObject\"),actualLines.length===1&&expectedLines.length===1&&actualLines[0]!==expectedLines[0]){var inputLength=actualLines[0].length+expectedLines[0].length;if(inputLength<=kMaxShortLength){if((_typeof(actual)!==\"object\"||actual===null)&&(_typeof(expected)!==\"object\"||expected===null)&&(actual!==0||expected!==0))return\"\".concat(kReadableOperator[operator],`\n\n`)+\"\".concat(actualLines[0],\" !== \").concat(expectedLines[0],`\n`)}else if(operator!==\"strictEqualObject\"){var maxLength=process.stderr&&process.stderr.isTTY\?process.stderr.columns:80;if(inputLength2&&(indicator=`\n `.concat(repeat(\" \",i),\"^\"),i=0)}}}for(var a=actualLines[actualLines.length-1],b=expectedLines[expectedLines.length-1];a===b&&(i++<2\?end=`\n `.concat(a).concat(end):other=a,actualLines.pop(),expectedLines.pop(),!(actualLines.length===0||expectedLines.length===0));)a=actualLines[actualLines.length-1],b=expectedLines[expectedLines.length-1];var maxLines=Math.max(actualLines.length,expectedLines.length);if(maxLines===0){var _actualLines=actualInspected.split(`\n`);if(_actualLines.length>30)for(_actualLines[26]=\"\".concat(blue,\"...\").concat(white);_actualLines.length>27;)_actualLines.pop();return\"\".concat(kReadableOperator.notIdentical,`\n\n`).concat(_actualLines.join(`\n`),`\n`)}i>3&&(end=`\n`.concat(blue,\"...\").concat(white).concat(end),skipped=!0),other!==\"\"&&(end=`\n `.concat(other).concat(end),other=\"\");var printedLines=0,msg=kReadableOperator[operator]+`\n`.concat(green,\"+ actual\").concat(white,\" \").concat(red,\"- expected\").concat(white),skippedMsg=\" \".concat(blue,\"...\").concat(white,\" Lines skipped\");for(i=0;i1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(expectedLines[i-2]),printedLines++),res+=`\n `.concat(expectedLines[i-1]),printedLines++),lastPos=i,other+=`\n`.concat(red,\"-\").concat(white,\" \").concat(expectedLines[i]),printedLines++;else if(expectedLines.length1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(actualLines[i-2]),printedLines++),res+=`\n `.concat(actualLines[i-1]),printedLines++),lastPos=i,res+=`\n`.concat(green,\"+\").concat(white,\" \").concat(actualLines[i]),printedLines++;else{var expectedLine=expectedLines[i],actualLine=actualLines[i],divergingLines=actualLine!==expectedLine&&(!endsWith(actualLine,\",\")||actualLine.slice(0,-1)!==expectedLine);divergingLines&&endsWith(expectedLine,\",\")&&expectedLine.slice(0,-1)===actualLine&&(divergingLines=!1,actualLine+=\",\"),divergingLines\?(cur>1&&i>2&&(cur>4\?(res+=`\n`.concat(blue,\"...\").concat(white),skipped=!0):cur>3&&(res+=`\n `.concat(actualLines[i-2]),printedLines++),res+=`\n `.concat(actualLines[i-1]),printedLines++),lastPos=i,res+=`\n`.concat(green,\"+\").concat(white,\" \").concat(actualLine),other+=`\n`.concat(red,\"-\").concat(white,\" \").concat(expectedLine),printedLines+=2):(res+=other,other=\"\",(cur===1||i===0)&&(res+=`\n `.concat(actualLine),printedLines++))}if(printedLines>20&&i30)for(res[26]=\"\".concat(blue,\"...\").concat(white);res.length>27;)res.pop();res.length===1\?_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(base,\" \").concat(res[0]))):_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(base,`\n\n`).concat(res.join(`\n`),`\n`)))}else{var _res=inspectValue(actual),other=\"\",knownOperators=kReadableOperator[operator];operator===\"notDeepEqual\"||operator===\"notEqual\"\?(_res=\"\".concat(kReadableOperator[operator],`\n\n`).concat(_res),_res.length>1024&&(_res=\"\".concat(_res.slice(0,1021),\"...\"))):(other=\"\".concat(inspectValue(expected)),_res.length>512&&(_res=\"\".concat(_res.slice(0,509),\"...\")),other.length>512&&(other=\"\".concat(other.slice(0,509),\"...\")),operator===\"deepEqual\"||operator===\"equal\"\?_res=\"\".concat(knownOperators,`\n\n`).concat(_res,`\n\nshould equal\n\n`):other=\" \".concat(operator,\" \").concat(other)),_this=_possibleConstructorReturn(this,_getPrototypeOf(AssertionError2).call(this,\"\".concat(_res).concat(other)))}return Error.stackTraceLimit=limit,_this.generatedMessage=!message,Object.defineProperty(_assertThisInitialized(_this),\"name\",{value:\"AssertionError [ERR_ASSERTION]\",enumerable:!1,writable:!0,configurable:!0}),_this.code=\"ERR_ASSERTION\",_this.actual=actual,_this.expected=expected,_this.operator=operator,Error.captureStackTrace&&Error.captureStackTrace(_assertThisInitialized(_this),stackStartFn),_this.stack,_this.name=\"AssertionError\",_possibleConstructorReturn(_this)}return AssertionError2.prototype={},_inherits(AssertionError2,_Error),_createClass(AssertionError2,[{key:\"toString\",value:function(){return\"\".concat(this.name,\" [\").concat(this.code,\"]: \").concat(this.message)}},{key:inspect.custom,value:function(recurseTimes,ctx){return inspect(this,_objectSpread({},ctx,{customInspect:!1,depth:0}))}}]),AssertionError2}(_wrapNativeSuper(Error));module2.exports=AssertionError}}),require_assert=__commonJS({\"assert/build/assert.js\"(exports,module2){function _typeof(obj){return typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"\?_typeof=function(obj2){return typeof obj2}:_typeof=function(obj2){return obj2&&typeof Symbol==\"function\"&&obj2.constructor===Symbol&&obj2!==Symbol.prototype\?\"symbol\":typeof obj2},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))@throwTypeError(\"Cannot call a class as a function\")}var _require=require_errors(),_require$codes=_require.codes,ERR_AMBIGUOUS_ARGUMENT=_require$codes.ERR_AMBIGUOUS_ARGUMENT,ERR_INVALID_ARG_TYPE=_require$codes.ERR_INVALID_ARG_TYPE,ERR_INVALID_ARG_VALUE=_require$codes.ERR_INVALID_ARG_VALUE,ERR_INVALID_RETURN_VALUE=_require$codes.ERR_INVALID_RETURN_VALUE,ERR_MISSING_ARGS=_require$codes.ERR_MISSING_ARGS,AssertionError=require_assertion_error(),_require2=util,inspect=_require2.inspect,_require$types=util.types,isPromise=_require$types.isPromise,isRegExp=_require$types.isRegExp,objectAssign=Object.assign,objectIs=Object.is,errorCache=new Map,warned=!1,assert=module2.exports=ok,NO_EXCEPTION_SENTINEL={};function innerFail(obj){throw obj.message instanceof Error\?obj.message:new AssertionError(obj)}function fail(actual,expected,message,operator,stackStartFn){var argsLen=arguments.length,internalMessage;if(argsLen===0)internalMessage=\"Failed\";else if(argsLen===1)message=actual,actual=void 0;else{if(warned===!1){warned=!0;var warn=process.emitWarning\?process.emitWarning:console.warn.bind(console);warn(\"assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.\",\"DeprecationWarning\",\"DEP0094\")}argsLen===2&&(operator=\"!=\")}if(message instanceof Error)throw message;var errArgs={actual,expected,operator:operator===void 0\?\"fail\":operator,stackStartFn:stackStartFn||fail};message!==void 0&&(errArgs.message=message);var err=new AssertionError(errArgs);throw internalMessage&&(err.message=internalMessage,err.generatedMessage=!0),err}assert.fail=fail,assert.AssertionError=AssertionError;function innerOk(fn,argLen,value,message){if(!value){var generatedMessage=!1;if(argLen===0)generatedMessage=!0,message=\"No value argument passed to `assert.ok()`\";else if(message instanceof Error)throw message;var err=new AssertionError({actual:value,expected:!0,message,operator:\"==\",stackStartFn:fn});throw err.generatedMessage=generatedMessage,err}}function ok(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];innerOk.apply(void 0,[ok,args.length].concat(args))}assert.ok=ok,assert.equal=function equal(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");actual!=expected&&innerFail({actual,expected,message,operator:\"==\",stackStartFn:equal})},assert.notEqual=function notEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");actual==expected&&innerFail({actual,expected,message,operator:\"!=\",stackStartFn:notEqual})},assert.deepEqual=function deepEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!1)||innerFail({actual,expected,message,operator:\"deepEqual\",stackStartFn:deepEqual})},assert.notDeepEqual=function notDeepEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!1)&&innerFail({actual,expected,message,operator:\"notDeepEqual\",stackStartFn:notDeepEqual})},assert.deepStrictEqual=function deepStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!0)||innerFail({actual,expected,message,operator:\"deepStrictEqual\",stackStartFn:deepStrictEqual})},assert.notDeepStrictEqual=notDeepStrictEqual;function notDeepStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");isDeepEqual(actual,expected,!0)&&innerFail({actual,expected,message,operator:\"notDeepStrictEqual\",stackStartFn:notDeepStrictEqual})}assert.strictEqual=function strictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");objectIs(actual,expected)||innerFail({actual,expected,message,operator:\"strictEqual\",stackStartFn:strictEqual})},assert.notStrictEqual=function notStrictEqual(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");objectIs(actual,expected)&&innerFail({actual,expected,message,operator:\"notStrictEqual\",stackStartFn:notStrictEqual})},assert.match=function match(actual,expected,message){if(arguments.length<2)throw new ERR_MISSING_ARGS(\"actual\",\"expected\");if(!isRegExp(expected))throw new ERR_INVALID_ARG_TYPE(\"expected\",\"RegExp\",expected);expected.test(actual)||innerFail({actual,expected,message,operator:\"match\",stackStartFn:match})};var Comparison=function Comparison2(obj,keys,actual){var _this=this;_classCallCheck(this,Comparison2),keys.forEach(function(key){(key in obj)&&(actual!==void 0&&typeof actual[key]==\"string\"&&isRegExp(obj[key])&&obj[key].test(actual[key])\?_this[key]=actual[key]:_this[key]=obj[key])})};function compareExceptionKey(actual,expected,key,message,keys,fn){if(!(key in actual)||!isDeepEqual(actual[key],expected[key],!0)){if(!message){var a=new Comparison(actual,keys),b=new Comparison(expected,keys,actual),err=new AssertionError({actual:a,expected:b,operator:\"deepStrictEqual\",stackStartFn:fn});throw err.actual=actual,err.expected=expected,err.operator=fn.name,err}innerFail({actual,expected,message,operator:fn.name,stackStartFn:fn})}}function expectedException(actual,expected,msg,fn){if(typeof expected!=\"function\"){if(isRegExp(expected))return expected.test(actual);if(arguments.length===2)throw new ERR_INVALID_ARG_TYPE(\"expected\",[\"Function\",\"RegExp\"],expected);if(_typeof(actual)!==\"object\"||actual===null){var err=new AssertionError({actual,expected,message:msg,operator:\"deepStrictEqual\",stackStartFn:fn});throw err.operator=fn.name,err}var keys=Object.keys(expected);if(expected instanceof Error)keys.push(\"name\",\"message\");else if(keys.length===0)throw new ERR_INVALID_ARG_VALUE(\"error\",expected,\"may not be an empty object\");return keys.forEach(function(key){return typeof actual[key]==\"string\"&&isRegExp(expected[key])&&expected[key].test(actual[key])||compareExceptionKey(actual,expected,key,msg,keys,fn)}),!0}return expected.prototype!==void 0&&actual instanceof expected\?!0:Error.isPrototypeOf(expected)\?!1:expected.call({},actual)===!0}function getActual(fn){if(typeof fn!=\"function\")throw new ERR_INVALID_ARG_TYPE(\"fn\",\"Function\",fn);try{fn()}catch(e){return e}return NO_EXCEPTION_SENTINEL}function checkIsPromise(obj){return isPromise(obj)||obj!==null&&_typeof(obj)===\"object\"&&typeof obj.then==\"function\"&&typeof obj.catch==\"function\"}function waitForActual(promiseFn){return Promise.resolve().then(function(){var resultPromise;if(typeof promiseFn==\"function\"){if(resultPromise=promiseFn(),!checkIsPromise(resultPromise))throw new ERR_INVALID_RETURN_VALUE(\"instance of Promise\",\"promiseFn\",resultPromise)}else if(checkIsPromise(promiseFn))resultPromise=promiseFn;else throw new ERR_INVALID_ARG_TYPE(\"promiseFn\",[\"Function\",\"Promise\"],promiseFn);return Promise.resolve().then(function(){return resultPromise}).then(function(){return NO_EXCEPTION_SENTINEL}).catch(function(e){return e})})}function expectsError(stackStartFn,actual,error,message){if(typeof error==\"string\"){if(arguments.length===4)throw new ERR_INVALID_ARG_TYPE(\"error\",[\"Object\",\"Error\",\"Function\",\"RegExp\"],error);if(_typeof(actual)===\"object\"&&actual!==null){if(actual.message===error)throw new ERR_AMBIGUOUS_ARGUMENT(\"error/message\",'The error message \"'.concat(actual.message,'\" is identical to the message.'))}else if(actual===error)throw new ERR_AMBIGUOUS_ARGUMENT(\"error/message\",'The error \"'.concat(actual,'\" is identical to the message.'));message=error,error=void 0}else if(error!=null&&_typeof(error)!==\"object\"&&typeof error!=\"function\")throw new ERR_INVALID_ARG_TYPE(\"error\",[\"Object\",\"Error\",\"Function\",\"RegExp\"],error);if(actual===NO_EXCEPTION_SENTINEL){var details=\"\";error&&error.name&&(details+=\" (\".concat(error.name,\")\")),details+=message\?\": \".concat(message):\".\";var fnType=stackStartFn.name===\"rejects\"\?\"rejection\":\"exception\";innerFail({actual:void 0,expected:error,operator:stackStartFn.name,message:\"Missing expected \".concat(fnType).concat(details),stackStartFn})}if(error&&!expectedException(actual,error,message,stackStartFn))throw actual}function expectsNoError(stackStartFn,actual,error,message){if(actual!==NO_EXCEPTION_SENTINEL){if(typeof error==\"string\"&&(message=error,error=void 0),!error||expectedException(actual,error)){var details=message\?\": \".concat(message):\".\",fnType=stackStartFn.name===\"doesNotReject\"\?\"rejection\":\"exception\";innerFail({actual,expected:error,operator:stackStartFn.name,message:\"Got unwanted \".concat(fnType).concat(details,`\n`)+'Actual message: \"'.concat(actual&&actual.message,'\"'),stackStartFn})}throw actual}}assert.throws=function throws(promiseFn){for(var _len2=arguments.length,args=new Array(_len2>1\?_len2-1:0),_key2=1;_key2<_len2;_key2++)args[_key2-1]=arguments[_key2];expectsError.apply(void 0,[throws,getActual(promiseFn)].concat(args))},assert.rejects=function rejects(promiseFn){for(var _len3=arguments.length,args=new Array(_len3>1\?_len3-1:0),_key3=1;_key3<_len3;_key3++)args[_key3-1]=arguments[_key3];return waitForActual(promiseFn).then(function(result){return expectsError.apply(void 0,[rejects,result].concat(args))})},assert.doesNotThrow=function doesNotThrow(fn){for(var _len4=arguments.length,args=new Array(_len4>1\?_len4-1:0),_key4=1;_key4<_len4;_key4++)args[_key4-1]=arguments[_key4];expectsNoError.apply(void 0,[doesNotThrow,getActual(fn)].concat(args))},assert.doesNotReject=function doesNotReject(fn){for(var _len5=arguments.length,args=new Array(_len5>1\?_len5-1:0),_key5=1;_key5<_len5;_key5++)args[_key5-1]=arguments[_key5];return waitForActual(fn).then(function(result){return expectsNoError.apply(void 0,[doesNotReject,result].concat(args))})},assert.ifError=function ifError(err){if(err!=null){var message=\"ifError got unwanted exception: \";_typeof(err)===\"object\"&&typeof err.message==\"string\"\?err.message.length===0&&err.constructor\?message+=err.constructor.name:message+=err.message:message+=inspect(err);var newErr=new AssertionError({actual:err,expected:null,operator:\"ifError\",message,stackStartFn:ifError}),origStack=err.stack;if(typeof origStack==\"string\"){var tmp2=origStack.split(`\n`);tmp2.shift();for(var tmp1=newErr.stack.split(`\n`),i=0;i{var prev=get();set(context);try{return fn(...args)}catch(error){throw error}finally{set(prev)}}}enterWith(store){cleanupLater();var context=get();if(!context){set([this,store]);return}var{length}=context;for(var i=0;i-1)hasPrevious=!0,previous=context[i+1],context[i+1]=store;else context.push(this,store);set(context)}try{return callback(...args)}catch(e){throw e}finally{if(!this.#disableCalled){var context2=get();if(context2===context&&contextWasInit)set(void 0);else if(context2=context2.slice(),hasPrevious)context2[i+1]=previous,set(context2);else context2.splice(i,2),set(context2.length\?context2:void 0)}}}disable(){if(!this.#disableCalled){var context=get();if(context){var{length}=context;for(var i=0;i-1){try{child.kill(killSignal)}catch(err){child.emit(\"error\",err)}timeoutHolder.timeoutId=-1}}function spawn(file,args,options){options=normalizeSpawnArguments(file,args,options),validateTimeout(options.timeout),validateAbortSignal(options.signal,\"options.signal\");const killSignal2=sanitizeKillSignal(options.killSignal),child=new ChildProcess;if(child.spawn(options),options.timeout>0){let timeoutId=setTimeout(()=>{if(timeoutId){try{child.kill(killSignal2)}catch(err){child.emit(\"error\",err)}timeoutId=null}});child.once(\"exit\",()=>{if(timeoutId)clearTimeout(timeoutId),timeoutId=null})}if(options.signal){let onAbortListener2=function(){abortChildProcess(child,killSignal2,options.signal.reason)};var onAbortListener=onAbortListener2;const signal=options.signal;if(signal.aborted)process.nextTick(onAbortListener2);else signal.addEventListener(\"abort\",onAbortListener2,{once:!0}),child.once(\"exit\",()=>signal.removeEventListener(\"abort\",onAbortListener2))}return child}function execFile(file,args,options,callback){({file,args,options,callback}=normalizeExecFileArgs(file,args,options,callback)),options={encoding:\"utf8\",timeout:0,maxBuffer:MAX_BUFFER,killSignal:\"SIGTERM\",cwd:null,env:null,shell:!1,...options};const maxBuffer=options.maxBuffer;validateTimeout(options.timeout),validateMaxBuffer(maxBuffer),options.killSignal=sanitizeKillSignal(options.killSignal);const child=spawn(file,args,{cwd:options.cwd,env:options.env,shell:options.shell,signal:options.signal});let encoding;const _stdout=[],_stderr=[];if(options.encoding!==\"buffer\"&&BufferIsEncoding(options.encoding))encoding=options.encoding;else encoding=null;let stdoutLen=0,stderrLen=0,killed=!1,exited=!1,timeoutId,encodedStdoutLen,encodedStderrLen,ex=null,cmd=file;function exitHandler(code,signal){if(exited)return;if(exited=!0,timeoutId)clearTimeout(timeoutId),timeoutId=null;if(!callback)return;const readableEncoding=child\?.stdout\?.readableEncoding;let stdout,stderr;if(encoding||child.stdout&&readableEncoding)stdout=ArrayPrototypeJoin.call(_stdout,\"\");else stdout=BufferConcat(_stdout);if(encoding||child.stderr&&readableEncoding)stderr=ArrayPrototypeJoin.call(_stderr,\"\");else stderr=BufferConcat(_stderr);if(!ex&&code===0&&signal===null){callback(null,stdout,stderr);return}if(args\?.length)cmd+=` ${ArrayPrototypeJoin.call(args,\" \")}`;if(!ex){let message=`Command failed: ${cmd}`;if(stderr)message+=`\\n${stderr}`;ex=genericNodeError(message,{code,killed:child.killed||killed,signal})}ex.cmd=cmd,callback(ex,stdout,stderr)}function errorHandler(e){if(ex=e,child.stdout)child.stdout.destroy();if(child.stderr)child.stderr.destroy();exitHandler()}function kill(){if(child.stdout)child.stdout.destroy();if(child.stderr)child.stderr.destroy();killed=!0;try{child.kill(options.killSignal)}catch(e){ex=e,exitHandler()}}if(options.timeout>0)timeoutId=setTimeout(function delayedKill(){kill(),timeoutId=null},options.timeout);if(child.stdout){if(encoding)child.stdout.setEncoding(encoding);child.stdout.on(\"data\",maxBuffer===Infinity\?function onUnlimitedSizeBufferedData(chunk){ArrayPrototypePush.call(_stdout,chunk)}:encoding\?function onChildStdoutEncoded(chunk){if(stdoutLen+=chunk.length,stdoutLen*4>maxBuffer){const encoding2=child.stdout.readableEncoding,actualLen=Buffer.byteLength(chunk,encoding2);if(encodedStdoutLen===void 0)for(let i=0;i<_stdout.length;i++)encodedStdoutLen+=Buffer.byteLength(_stdout[i],encoding2);else encodedStdoutLen+=actualLen;const truncatedLen=maxBuffer-(encodedStdoutLen-actualLen);ArrayPrototypePush.call(_stdout,StringPrototypeSlice.apply(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stdout\"),kill()}else ArrayPrototypePush.call(_stdout,chunk)}:function onChildStdoutRaw(chunk){if(stdoutLen+=chunk.length,stdoutLen>maxBuffer){const truncatedLen=maxBuffer-(stdoutLen-chunk.length);ArrayPrototypePush.call(_stdout,chunk.slice(0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stdout\"),kill()}else ArrayPrototypePush.call(_stdout,chunk)})}if(child.stderr){if(encoding)child.stderr.setEncoding(encoding);child.stderr.on(\"data\",maxBuffer===Infinity\?function onUnlimitedSizeBufferedData(chunk){ArrayPrototypePush.call(_stderr,chunk)}:encoding\?function onChildStderrEncoded(chunk){if(stderrLen+=chunk.length,stderrLen*4>maxBuffer){const encoding2=child.stderr.readableEncoding,actualLen=Buffer.byteLength(chunk,encoding2);if(encodedStderrLen===void 0)for(let i=0;i<_stderr.length;i++)encodedStderrLen+=Buffer.byteLength(_stderr[i],encoding2);else encodedStderrLen+=actualLen;const truncatedLen=maxBuffer-(encodedStderrLen-actualLen);ArrayPrototypePush.call(_stderr,StringPrototypeSlice.call(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stderr\"),kill()}else ArrayPrototypePush.call(_stderr,chunk)}:function onChildStderrRaw(chunk){if(stderrLen+=chunk.length,stderrLen>maxBuffer){const truncatedLen=maxBuffer-(stderrLen-chunk.length);ArrayPrototypePush.call(_stderr,StringPrototypeSlice.call(chunk,0,truncatedLen)),ex=new ERR_CHILD_PROCESS_STDIO_MAXBUFFER(\"stderr\"),kill()}else ArrayPrototypePush.call(_stderr,chunk)})}return child.addListener(\"close\",exitHandler),child.addListener(\"error\",errorHandler),child}function exec(command,options,callback){const opts=normalizeExecArgs(command,options,callback);return execFile(opts.file,opts.options,opts.callback)}const customPromiseExecFunction=(orig)=>{return(...args)=>{let resolve,reject;const promise=new Promise((res,rej)=>{resolve=res,reject=rej});return promise.child=orig(...args,(err,stdout,stderr)=>{if(err!==null)err.stdout=stdout,err.stderr=stderr,reject(err);else resolve({stdout,stderr})}),promise}};ObjectDefineProperty(exec,promisify.custom,{__proto__:null,enumerable:!1,value:customPromiseExecFunction(exec)});function spawnSync(file,args,options){options={maxBuffer:MAX_BUFFER,...normalizeSpawnArguments(file,args,options)};const{maxBuffer,encoding}=options;validateTimeout(options.timeout),validateMaxBuffer(maxBuffer),options.killSignal=sanitizeKillSignal(options.killSignal);const stdio=options.stdio||\"pipe\",bunStdio=getBunStdioFromOptions(stdio);var{input}=options;if(input)if(ArrayBufferIsView(input))bunStdio[0]=input;else if(typeof input===\"string\")bunStdio[0]=Buffer.from(input,encoding||\"utf8\");else throw new ERR_INVALID_ARG_TYPE(\"options.stdio[0]\",[\"Buffer\",\"TypedArray\",\"DataView\",\"string\"],input);const{stdout,stderr,success,exitCode}=Bun.spawnSync({cmd:options.args,env:options.env||void 0,cwd:options.cwd||void 0,stdin:bunStdio[0],stdout:bunStdio[1],stderr:bunStdio[2]}),result={signal:null,status:exitCode,output:[null,stdout,stderr]};if(stdout&&encoding&&encoding!==\"buffer\")result.output[1]=result.output[1]\?.toString(encoding);if(stderr&&encoding&&encoding!==\"buffer\")result.output[2]=result.output[2]\?.toString(encoding);if(result.stdout=result.output[1],result.stderr=result.output[2],!success)result.error=new SystemError(result.output[2],options.file,\"spawnSync\",-1,result.status),result.error.spawnargs=ArrayPrototypeSlice.call(options.args,1);return result}function execFileSync(file,args,options){({file,args,options}=normalizeExecFileArgs(file,args,options));const ret=spawnSync(file,args,options),errArgs=[options.argv0||file];ArrayPrototypePush.apply(errArgs,args);const err=checkExecSyncError(ret,errArgs);if(err)throw err;return ret.stdout}function execSync(command,options){const opts=normalizeExecArgs(command,options,null),ret=spawnSync(opts.file,opts.options),err=checkExecSyncError(ret,void 0,command);if(err)throw err;return ret.stdout}function stdioStringToArray(stdio,channel){const options=[];switch(stdio){case\"ignore\":case\"overlapped\":case\"pipe\":ArrayPrototypePush.call(options,stdio,stdio,stdio);break;case\"inherit\":ArrayPrototypePush.call(options,0,1,2);break;default:throw new ERR_INVALID_ARG_VALUE(\"stdio\",stdio)}if(channel)ArrayPrototypePush.call(options,channel);return options}function fork(modulePath,args=[],options){modulePath=getValidatedPath(modulePath,\"modulePath\");let execArgv;if(args==null)args=[];else if(typeof args===\"object\"&&!ArrayIsArray(args))options=args,args=[];else validateArray(args,\"args\");if(options!=null)validateObject(options,\"options\");if(options={__proto__:null,...options,shell:!1},options.execPath=options.execPath||process.execPath,validateArgumentNullCheck(options.execPath,\"options.execPath\"),execArgv=options.execArgv||process.execArgv,validateArgumentsNullCheck(execArgv,\"options.execArgv\"),execArgv===process.execArgv&&process._eval!=null){const index=ArrayPrototypeLastIndexOf.call(execArgv,process._eval);if(index>0)execArgv=ArrayPrototypeSlice.call(execArgv),ArrayPrototypeSplice.call(execArgv,index-1,2)}if(args=[...execArgv,modulePath,...args],typeof options.stdio===\"string\")options.stdio=stdioStringToArray(options.stdio,\"ipc\");else if(!ArrayIsArray(options.stdio))options.stdio=stdioStringToArray(options.silent\?\"pipe\":\"inherit\",\"ipc\");else if(!ArrayPrototypeIncludes.call(options.stdio,\"ipc\"))throw new ERR_CHILD_PROCESS_IPC_REQUIRED(\"options.stdio\");return spawn(options.execPath,args,options)}function convertToValidSignal(signal){if(typeof signal===\"number\"&&getSignalsToNamesMapping()[signal])return signal;if(typeof signal===\"string\"){const signalName=signals[StringPrototypeToUpperCase.call(signal)];if(signalName)return signalName}throw new ERR_UNKNOWN_SIGNAL(signal)}function sanitizeKillSignal(killSignal2){if(typeof killSignal2===\"string\"||typeof killSignal2===\"number\")return convertToValidSignal(killSignal2);else if(killSignal2!=null)throw new ERR_INVALID_ARG_TYPE(\"options.killSignal\",[\"string\",\"number\"],killSignal2)}let signalsToNamesMapping;function getSignalsToNamesMapping(){if(signalsToNamesMapping!==void 0)return signalsToNamesMapping;signalsToNamesMapping=ObjectCreate(null);for(let key in signals)signalsToNamesMapping[signals[key]]=key;return signalsToNamesMapping}function normalizeExecFileArgs(file,args,options,callback){if(ArrayIsArray(args))args=ArrayPrototypeSlice.call(args);else if(args!=null&&typeof args===\"object\")callback=options,options=args,args=null;else if(typeof args===\"function\")callback=args,options=null,args=null;if(args==null)args=[];if(typeof options===\"function\")callback=options;else if(options!=null)validateObject(options,\"options\");if(options==null)options=kEmptyObject;if(callback!=null)validateFunction(callback,\"callback\");if(options.argv0!=null)validateString(options.argv0,\"options.argv0\"),validateArgumentNullCheck(options.argv0,\"options.argv0\");return{file,args,options,callback}}function normalizeExecArgs(command,options,callback){if(validateString(command,\"command\"),validateArgumentNullCheck(command,\"command\"),typeof options===\"function\")callback=options,options=void 0;return options={...options},options.shell=typeof options.shell===\"string\"\?options.shell:!0,{file:command,options,callback}}function normalizeSpawnArguments(file,args,options){if(validateString(file,\"file\"),validateArgumentNullCheck(file,\"file\"),file.length===0)throw new ERR_INVALID_ARG_VALUE(\"file\",file,\"cannot be empty\");if(ArrayIsArray(args))args=ArrayPrototypeSlice.call(args);else if(args==null)args=[];else if(typeof args!==\"object\")throw new ERR_INVALID_ARG_TYPE(\"args\",\"object\",args);else options=args,args=[];if(validateArgumentsNullCheck(args,\"args\"),options===void 0)options={};else validateObject(options,\"options\");let cwd=options.cwd;if(cwd!=null)cwd=getValidatedPath(cwd,\"options.cwd\");if(options.shell!=null&&typeof options.shell!==\"boolean\"&&typeof options.shell!==\"string\")throw new ERR_INVALID_ARG_TYPE(\"options.shell\",[\"boolean\",\"string\"],options.shell);if(options.argv0!=null)validateString(options.argv0,\"options.argv0\"),validateArgumentNullCheck(options.argv0,\"options.argv0\");if(options.shell){validateArgumentNullCheck(options.shell,\"options.shell\");const command=ArrayPrototypeJoin.call([file,...args],\" \");if(typeof options.shell===\"string\")file=options.shell;else file=\"sh\";args=[\"-c\",command]}if(typeof options.argv0===\"string\")ArrayPrototypeUnshift.call(args,options.argv0);else ArrayPrototypeUnshift.call(args,file);const envPairs=options.env||process.env;return{...options,file,args,cwd,envPairs}}function checkExecSyncError(ret,args,cmd){let err;if(ret.error)err=ret.error,ObjectAssign(err,ret);else if(ret.status!==0){let msg=\"Command failed: \";if(msg+=cmd||ArrayPrototypeJoin.call(args,\" \"),ret.stderr&&ret.stderr.length>0)msg+=`\\n${ret.stderr.toString()}`;err=genericNodeError(msg,ret)}return err}class ChildProcess extends EventEmitter{constructor(){super(...arguments)}#handle;#exited=!1;#closesNeeded=1;#closesGot=0;connected=!1;signalCode=null;exitCode=null;spawnfile;spawnargs;pid;channel;get killed(){if(this.#handle==null)return!1}#handleOnExit(exitCode,signalCode,err){if(this.#exited)return;if(signalCode)this.signalCode=signalCode;else this.exitCode=exitCode;if(this.#stdin)this.#stdin.destroy();if(this.#handle)this.#handle=null;if(exitCode<0){const err2=new SystemError(`Spawned process exited with error code: ${exitCode}`,void 0,\"spawn\",\"EUNKNOWN\",\"ERR_CHILD_PROCESS_UNKNOWN_ERROR\");if(this.spawnfile)err2.path=this.spawnfile;err2.spawnargs=ArrayPrototypeSlice.call(this.spawnargs,1),this.emit(\"error\",err2)}else this.emit(\"exit\",this.exitCode,this.signalCode);process.nextTick(flushStdio,this),this.#maybeClose(),this.#exited=!0,this.#stdioOptions=[\"destroyed\",\"destroyed\",\"destroyed\"]}#getBunSpawnIo(i,encoding){NativeWritable||=StreamModule.NativeWritable,ReadableFromWeb||=StreamModule.Readable.fromWeb;const io=this.#stdioOptions[i];switch(i){case 0:switch(io){case\"pipe\":return new NativeWritable(this.#handle.stdin);case\"inherit\":return process.stdin||null;case\"destroyed\":return new ShimmedStdin;default:return null}case 2:case 1:switch(io){case\"pipe\":return ReadableFromWeb(this.#handle[fdToStdioName(i)],{encoding});case\"inherit\":return process[fdToStdioName(i)]||null;case\"destroyed\":return new ShimmedStdioOutStream;default:return null}}}#stdin;#stdout;#stderr;#stdioObject;#encoding;#stdioOptions;#createStdioObject(){return Object.create(null,{0:{get:()=>this.stdin},1:{get:()=>this.stdout},2:{get:()=>this.stderr}})}get stdin(){return this.#stdin\?\?=this.#getBunSpawnIo(0,this.#encoding)}get stdout(){return this.#stdout\?\?=this.#getBunSpawnIo(1,this.#encoding)}get stderr(){return this.#stderr\?\?=this.#getBunSpawnIo(2,this.#encoding)}get stdio(){return this.#stdioObject\?\?=this.#createStdioObject()}spawn(options){validateObject(options,\"options\"),validateString(options.file,\"options.file\");var file=this.spawnfile=options.file,spawnargs;if(options.args==null)spawnargs=this.spawnargs=[];else validateArray(options.args,\"options.args\"),spawnargs=this.spawnargs=options.args;const stdio=options.stdio||[\"pipe\",\"pipe\",\"pipe\"],bunStdio=getBunStdioFromOptions(stdio);var env=options.envPairs||void 0;this.#encoding=options.encoding||void 0,this.#stdioOptions=bunStdio,this.#handle=Bun.spawn({cmd:spawnargs,stdin:bunStdio[0],stdout:bunStdio[1],stderr:bunStdio[2],cwd:options.cwd||void 0,env:env||process.env,onExit:(handle,exitCode,signalCode,err)=>{this.#handle=handle,this.pid=this.#handle.pid,process.nextTick((exitCode2,signalCode2,err2)=>this.#handleOnExit(exitCode2,signalCode2,err2),exitCode,signalCode,err)},lazy:!0}),this.pid=this.#handle.pid,onSpawnNT(this)}send(){console.log(\"ChildProcess.prototype.send() - Sorry! Not implemented yet\")}disconnect(){console.log(\"ChildProcess.prototype.disconnect() - Sorry! Not implemented yet\")}kill(sig){const signal=sig===0\?sig:convertToValidSignal(sig===void 0\?\"SIGTERM\":sig);if(this.#handle)this.#handle.kill(signal);return this.#maybeClose(),!0}#maybeClose(){if(this.#closesGot++,this.#closesGot===this.#closesNeeded)this.emit(\"close\",this.exitCode,this.signalCode)}ref(){if(this.#handle)this.#handle.ref()}unref(){if(this.#handle)this.#handle.unref()}}const nodeToBunLookup={ignore:null,pipe:\"pipe\",overlapped:\"pipe\",inherit:\"inherit\"};function nodeToBun(item){if(typeof item===\"number\")return item;else{const result=nodeToBunLookup[item];if(result===void 0)throw new Error(\"Invalid stdio option\");return result}}function fdToStdioName(fd){switch(fd){case 0:return\"stdin\";case 1:return\"stdout\";case 2:return\"stderr\";default:return null}}function getBunStdioFromOptions(stdio){return normalizeStdio(stdio).map((item)=>nodeToBun(item))}function normalizeStdio(stdio){if(typeof stdio===\"string\")switch(stdio){case\"ignore\":return[\"ignore\",\"ignore\",\"ignore\"];case\"pipe\":return[\"pipe\",\"pipe\",\"pipe\"];case\"inherit\":return[\"inherit\",\"inherit\",\"inherit\"];default:throw new ERR_INVALID_OPT_VALUE(\"stdio\",stdio)}else if(ArrayIsArray(stdio)){let processedStdio;if(stdio.length===0)processedStdio=[\"pipe\",\"pipe\",\"pipe\"];else if(stdio.length===1)processedStdio=[stdio[0],\"pipe\",\"pipe\"];else if(stdio.length===2)processedStdio=[stdio[0],stdio[1],\"pipe\"];else if(stdio.length>=3)processedStdio=[stdio[0],stdio[1],stdio[2]];return processedStdio.map((item)=>!item\?\"pipe\":item)}else throw new ERR_INVALID_OPT_VALUE(\"stdio\",stdio)}function flushStdio(subprocess){const stdio=subprocess.stdio;if(stdio==null)return;for(let i=0;i=0))throw new ERR_OUT_OF_RANGE(\"options.maxBuffer\",\"a positive number\",maxBuffer)}function validateArgumentNullCheck(arg,propName){if(typeof arg===\"string\"&&StringPrototypeIncludes.call(arg,\"\\0\"))throw new ERR_INVALID_ARG_VALUE(propName,arg,\"must be a string without null bytes\")}function validateArgumentsNullCheck(args,propName){for(let i=0;i=0))throw new ERR_OUT_OF_RANGE(\"timeout\",\"an unsigned integer\",timeout)}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}function validateFunction(value,name){if(typeof value!==\"function\")throw new ERR_INVALID_ARG_TYPE(name,\"Function\",value)}const validateAbortSignal=(signal,name)=>{if(signal!==void 0&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE(name,\"AbortSignal\",signal)},validateOneOf=(value,name,oneOf)=>{if(!ArrayPrototypeIncludes.call(oneOf,value)){const reason=\"must be one of: \"+ArrayPrototypeJoin.call(ArrayPrototypeMap.call(oneOf,(v)=>typeof v===\"string\"\?`'${v}'`:String(v)),\", \");throw new ERR_INVALID_ARG_VALUE(name,value,reason)}},validateObject=(value,name,options=null)=>{const allowArray=options\?.allowArray\?\?!1,allowFunction=options\?.allowFunction\?\?!1;if(!(options\?.nullable\?\?!1)&&value===null||!allowArray&&ArrayIsArray.call(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE(name,\"object\",value)},validateArray=(value,name,minLength=0)=>{if(!ArrayIsArray(value))throw new ERR_INVALID_ARG_TYPE(name,\"Array\",value);if(value.lengthfunction(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},require_safe_buffer=__commonJS({\"node_modules/safe-buffer/index.js\"(exports,module){var buffer=BufferModule,Buffer2=buffer.Buffer;function copyProps(src,dst){for(var key in src)dst[key]=src[key]}Buffer2.from&&Buffer2.alloc&&Buffer2.allocUnsafe&&Buffer2.allocUnsafeSlow\?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer);function SafeBuffer(arg,encodingOrOffset,length){return Buffer2(arg,encodingOrOffset,length)}SafeBuffer.prototype=Object.create(Buffer2.prototype),copyProps(Buffer2,SafeBuffer),SafeBuffer.from=function(arg,encodingOrOffset,length){if(typeof arg==\"number\")@throwTypeError(\"Argument must not be a number\");return Buffer2(arg,encodingOrOffset,length)},SafeBuffer.alloc=function(size,fill,encoding){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");var buf=Buffer2(size);return fill!==void 0\?typeof encoding==\"string\"\?buf.fill(fill,encoding):buf.fill(fill):buf.fill(0),buf},SafeBuffer.allocUnsafe=function(size){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");return Buffer2(size)},SafeBuffer.allocUnsafeSlow=function(size){if(typeof size!=\"number\")@throwTypeError(\"Argument must be a number\");return buffer.SlowBuffer(size)}}}),require_browser=__commonJS({\"node_modules/randombytes/browser.js\"(exports,module){var MAX_BYTES=65536,MAX_UINT32=4294967295;function oldBrowser(){throw new Error(`Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11`)}var Buffer2=require_safe_buffer().Buffer,crypto2=globalCrypto;crypto2&&crypto2.getRandomValues\?module.exports=randomBytes:module.exports=oldBrowser;function randomBytes(size,cb){if(size>MAX_UINT32)@throwRangeError(\"requested too many random bytes\");var bytes=Buffer2.allocUnsafe(size);if(size>0)if(size>MAX_BYTES)for(var generated=0;generated=this._blockSize;){for(var i=this._blockOffset;i0;++j)this._length[j]+=carry,carry=this._length[j]/4294967296|0,carry>0&&(this._length[j]-=4294967296*carry);return this},HashBase.prototype._update=function(){throw new Error(\"_update is not implemented\")},HashBase.prototype.digest=function(encoding){if(this._finalized)throw new Error(\"Digest already called\");this._finalized=!0;var digest=this._digest();encoding!==void 0&&(digest=digest.toString(encoding)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return digest},HashBase.prototype._digest=function(){throw new Error(\"_digest is not implemented\")},module.exports=HashBase}}),require_md5=__commonJS({\"node_modules/md5.js/index.js\"(exports,module){var inherits=require_inherits_browser(),HashBase=require_hash_base(),Buffer2=require_safe_buffer().Buffer,ARRAY16=new Array(16);function MD5(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}inherits(MD5,HashBase),MD5.prototype._update=function(){for(var M=ARRAY16,i=0;i<16;++i)M[i]=this._block.readInt32LE(i*4);var a=this._a,b=this._b,c=this._c,d=this._d;a=fnF(a,b,c,d,M[0],3614090360,7),d=fnF(d,a,b,c,M[1],3905402710,12),c=fnF(c,d,a,b,M[2],606105819,17),b=fnF(b,c,d,a,M[3],3250441966,22),a=fnF(a,b,c,d,M[4],4118548399,7),d=fnF(d,a,b,c,M[5],1200080426,12),c=fnF(c,d,a,b,M[6],2821735955,17),b=fnF(b,c,d,a,M[7],4249261313,22),a=fnF(a,b,c,d,M[8],1770035416,7),d=fnF(d,a,b,c,M[9],2336552879,12),c=fnF(c,d,a,b,M[10],4294925233,17),b=fnF(b,c,d,a,M[11],2304563134,22),a=fnF(a,b,c,d,M[12],1804603682,7),d=fnF(d,a,b,c,M[13],4254626195,12),c=fnF(c,d,a,b,M[14],2792965006,17),b=fnF(b,c,d,a,M[15],1236535329,22),a=fnG(a,b,c,d,M[1],4129170786,5),d=fnG(d,a,b,c,M[6],3225465664,9),c=fnG(c,d,a,b,M[11],643717713,14),b=fnG(b,c,d,a,M[0],3921069994,20),a=fnG(a,b,c,d,M[5],3593408605,5),d=fnG(d,a,b,c,M[10],38016083,9),c=fnG(c,d,a,b,M[15],3634488961,14),b=fnG(b,c,d,a,M[4],3889429448,20),a=fnG(a,b,c,d,M[9],568446438,5),d=fnG(d,a,b,c,M[14],3275163606,9),c=fnG(c,d,a,b,M[3],4107603335,14),b=fnG(b,c,d,a,M[8],1163531501,20),a=fnG(a,b,c,d,M[13],2850285829,5),d=fnG(d,a,b,c,M[2],4243563512,9),c=fnG(c,d,a,b,M[7],1735328473,14),b=fnG(b,c,d,a,M[12],2368359562,20),a=fnH(a,b,c,d,M[5],4294588738,4),d=fnH(d,a,b,c,M[8],2272392833,11),c=fnH(c,d,a,b,M[11],1839030562,16),b=fnH(b,c,d,a,M[14],4259657740,23),a=fnH(a,b,c,d,M[1],2763975236,4),d=fnH(d,a,b,c,M[4],1272893353,11),c=fnH(c,d,a,b,M[7],4139469664,16),b=fnH(b,c,d,a,M[10],3200236656,23),a=fnH(a,b,c,d,M[13],681279174,4),d=fnH(d,a,b,c,M[0],3936430074,11),c=fnH(c,d,a,b,M[3],3572445317,16),b=fnH(b,c,d,a,M[6],76029189,23),a=fnH(a,b,c,d,M[9],3654602809,4),d=fnH(d,a,b,c,M[12],3873151461,11),c=fnH(c,d,a,b,M[15],530742520,16),b=fnH(b,c,d,a,M[2],3299628645,23),a=fnI(a,b,c,d,M[0],4096336452,6),d=fnI(d,a,b,c,M[7],1126891415,10),c=fnI(c,d,a,b,M[14],2878612391,15),b=fnI(b,c,d,a,M[5],4237533241,21),a=fnI(a,b,c,d,M[12],1700485571,6),d=fnI(d,a,b,c,M[3],2399980690,10),c=fnI(c,d,a,b,M[10],4293915773,15),b=fnI(b,c,d,a,M[1],2240044497,21),a=fnI(a,b,c,d,M[8],1873313359,6),d=fnI(d,a,b,c,M[15],4264355552,10),c=fnI(c,d,a,b,M[6],2734768916,15),b=fnI(b,c,d,a,M[13],1309151649,21),a=fnI(a,b,c,d,M[4],4149444226,6),d=fnI(d,a,b,c,M[11],3174756917,10),c=fnI(c,d,a,b,M[2],718787259,15),b=fnI(b,c,d,a,M[9],3951481745,21),this._a=this._a+a|0,this._b=this._b+b|0,this._c=this._c+c|0,this._d=this._d+d|0},MD5.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer2.allocUnsafe(16);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer};function rotl(x,n){return x<>>32-n}function fnF(a,b,c,d,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+b|0}function fnG(a,b,c,d,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+b|0}function fnH(a,b,c,d,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+b|0}function fnI(a,b,c,d,m,k,s){return rotl(a+(c^(b|~d))+m+k|0,s)+b|0}module.exports=MD5}}),require_ripemd160=__commonJS({\"node_modules/ripemd160/index.js\"(exports,module){var Buffer2=Buffer,inherits=require_inherits_browser(),HashBase=require_hash_base(),ARRAY16=new Array(16),zl=[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],zr=[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],sl=[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],sr=[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],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];function RIPEMD160(){HashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}inherits(RIPEMD160,HashBase),RIPEMD160.prototype._update=function(){for(var words=ARRAY16,j=0;j<16;++j)words[j]=this._block.readInt32LE(j*4);for(var al=this._a|0,bl=this._b|0,cl=this._c|0,dl=this._d|0,el=this._e|0,ar=this._a|0,br=this._b|0,cr=this._c|0,dr=this._d|0,er=this._e|0,i=0;i<80;i+=1){var tl,tr;i<16\?(tl=fn1(al,bl,cl,dl,el,words[zl[i]],hl[0],sl[i]),tr=fn5(ar,br,cr,dr,er,words[zr[i]],hr[0],sr[i])):i<32\?(tl=fn2(al,bl,cl,dl,el,words[zl[i]],hl[1],sl[i]),tr=fn4(ar,br,cr,dr,er,words[zr[i]],hr[1],sr[i])):i<48\?(tl=fn3(al,bl,cl,dl,el,words[zl[i]],hl[2],sl[i]),tr=fn3(ar,br,cr,dr,er,words[zr[i]],hr[2],sr[i])):i<64\?(tl=fn4(al,bl,cl,dl,el,words[zl[i]],hl[3],sl[i]),tr=fn2(ar,br,cr,dr,er,words[zr[i]],hr[3],sr[i])):(tl=fn5(al,bl,cl,dl,el,words[zl[i]],hl[4],sl[i]),tr=fn1(ar,br,cr,dr,er,words[zr[i]],hr[4],sr[i])),al=el,el=dl,dl=rotl(cl,10),cl=bl,bl=tl,ar=er,er=dr,dr=rotl(cr,10),cr=br,br=tr}var t=this._b+cl+dr|0;this._b=this._c+dl+er|0,this._c=this._d+el+ar|0,this._d=this._e+al+br|0,this._e=this._a+bl+cr|0,this._a=t},RIPEMD160.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var buffer=Buffer2.alloc\?Buffer2.alloc(20):new Buffer2(20);return buffer.writeInt32LE(this._a,0),buffer.writeInt32LE(this._b,4),buffer.writeInt32LE(this._c,8),buffer.writeInt32LE(this._d,12),buffer.writeInt32LE(this._e,16),buffer};function rotl(x,n){return x<>>32-n}function fn1(a,b,c,d,e,m,k,s){return rotl(a+(b^c^d)+m+k|0,s)+e|0}function fn2(a,b,c,d,e,m,k,s){return rotl(a+(b&c|~b&d)+m+k|0,s)+e|0}function fn3(a,b,c,d,e,m,k,s){return rotl(a+((b|~c)^d)+m+k|0,s)+e|0}function fn4(a,b,c,d,e,m,k,s){return rotl(a+(b&d|c&~d)+m+k|0,s)+e|0}function fn5(a,b,c,d,e,m,k,s){return rotl(a+(b^(c|~d))+m+k|0,s)+e|0}module.exports=RIPEMD160}}),require_hash=__commonJS({\"node_modules/sha.js/hash.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer;function Hash(blockSize,finalSize){this._block=Buffer2.alloc(blockSize),this._finalSize=finalSize,this._blockSize=blockSize,this._len=0}Hash.prototype={},Hash.prototype.update=function(data,enc){typeof data==\"string\"&&(enc=enc||\"utf8\",data=Buffer2.from(data,enc));for(var block=this._block,blockSize=this._blockSize,length=data.length,accum=this._len,offset=0;offset=this._finalSize&&(this._update(this._block),this._block.fill(0));var bits=this._len*8;if(bits<=4294967295)this._block.writeUInt32BE(bits,this._blockSize-4);else{var lowBits=(bits&4294967295)>>>0,highBits=(bits-lowBits)/4294967296;this._block.writeUInt32BE(highBits,this._blockSize-8),this._block.writeUInt32BE(lowBits,this._blockSize-4)}this._update(this._block);var hash=this._hash();return enc\?hash.toString(enc):hash},Hash.prototype._update=function(){throw new Error(\"_update must be implemented by subclass\")},module.exports=Hash}}),require_sha=__commonJS({\"node_modules/sha.js/sha.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha,Hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return s===0\?b&c|~b&d:s===2\?b&c|b&d|c&d:b^c^d}Sha.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<80;++i)W2[i]=W2[i-3]^W2[i-8]^W2[i-14]^W2[i-16];for(var j=0;j<80;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W2[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha.prototype._hash=function(){var H=Buffer2.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},module.exports=Sha}}),require_sha1=__commonJS({\"node_modules/sha.js/sha1.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha1(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha1,Hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function rotl1(num){return num<<1|num>>>31}function rotl5(num){return num<<5|num>>>27}function rotl30(num){return num<<30|num>>>2}function ft(s,b,c,d){return s===0\?b&c|~b&d:s===2\?b&c|b&d|c&d:b^c^d}Sha1.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<80;++i)W2[i]=rotl1(W2[i-3]^W2[i-8]^W2[i-14]^W2[i-16]);for(var j=0;j<80;++j){var s=~~(j/20),t=rotl5(a)+ft(s,b,c,d)+e+W2[j]+K[s]|0;e=d,d=c,c=rotl30(b),b=a,a=t}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0},Sha1.prototype._hash=function(){var H=Buffer2.allocUnsafe(20);return H.writeInt32BE(this._a|0,0),H.writeInt32BE(this._b|0,4),H.writeInt32BE(this._c|0,8),H.writeInt32BE(this._d|0,12),H.writeInt32BE(this._e|0,16),H},module.exports=Sha1}}),require_sha256=__commonJS({\"node_modules/sha.js/sha256.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],W=new Array(64);function Sha256(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha256,Hash),Sha256.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x){return(x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10)}function sigma1(x){return(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7)}function gamma0(x){return(x>>>7|x<<25)^(x>>>18|x<<14)^x>>>3}function gamma1(x){return(x>>>17|x<<15)^(x>>>19|x<<13)^x>>>10}Sha256.prototype._update=function(M){for(var W2=this._w,a=this._a|0,b=this._b|0,c=this._c|0,d=this._d|0,e=this._e|0,f=this._f|0,g=this._g|0,h=this._h|0,i=0;i<16;++i)W2[i]=M.readInt32BE(i*4);for(;i<64;++i)W2[i]=gamma1(W2[i-2])+W2[i-7]+gamma0(W2[i-15])+W2[i-16]|0;for(var j=0;j<64;++j){var T1=h+sigma1(e)+ch(e,f,g)+K[j]+W2[j]|0,T2=sigma0(a)+maj(a,b,c)|0;h=g,g=f,f=e,e=d+T1|0,d=c,c=b,b=a,a=T1+T2|0}this._a=a+this._a|0,this._b=b+this._b|0,this._c=c+this._c|0,this._d=d+this._d|0,this._e=e+this._e|0,this._f=f+this._f|0,this._g=g+this._g|0,this._h=h+this._h|0},Sha256.prototype._hash=function(){var H=Buffer2.allocUnsafe(32);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H.writeInt32BE(this._h,28),H},module.exports=Sha256}}),require_sha224=__commonJS({\"node_modules/sha.js/sha224.js\"(exports,module){var inherits=require_inherits_browser(),Sha256=require_sha256(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,W=new Array(64);function Sha224(){this.init(),this._w=W,Hash.call(this,64,56)}inherits(Sha224,Sha256),Sha224.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},Sha224.prototype._hash=function(){var H=Buffer2.allocUnsafe(28);return H.writeInt32BE(this._a,0),H.writeInt32BE(this._b,4),H.writeInt32BE(this._c,8),H.writeInt32BE(this._d,12),H.writeInt32BE(this._e,16),H.writeInt32BE(this._f,20),H.writeInt32BE(this._g,24),H},module.exports=Sha224}}),require_sha512=__commonJS({\"node_modules/sha.js/sha512.js\"(exports,module){var inherits=require_inherits_browser(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],W=new Array(160);function Sha512(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha512,Hash),Sha512.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Ch(x,y,z){return z^x&(y^z)}function maj(x,y,z){return x&y|z&(x|y)}function sigma0(x,xl){return(x>>>28|xl<<4)^(xl>>>2|x<<30)^(xl>>>7|x<<25)}function sigma1(x,xl){return(x>>>14|xl<<18)^(x>>>18|xl<<14)^(xl>>>9|x<<23)}function Gamma0(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^x>>>7}function Gamma0l(x,xl){return(x>>>1|xl<<31)^(x>>>8|xl<<24)^(x>>>7|xl<<25)}function Gamma1(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^x>>>6}function Gamma1l(x,xl){return(x>>>19|xl<<13)^(xl>>>29|x<<3)^(x>>>6|xl<<26)}function getCarry(a,b){return a>>>0>>0\?1:0}Sha512.prototype._update=function(M){for(var W2=this._w,ah=this._ah|0,bh=this._bh|0,ch=this._ch|0,dh=this._dh|0,eh=this._eh|0,fh=this._fh|0,gh=this._gh|0,hh=this._hh|0,al=this._al|0,bl=this._bl|0,cl=this._cl|0,dl=this._dl|0,el=this._el|0,fl=this._fl|0,gl=this._gl|0,hl=this._hl|0,i=0;i<32;i+=2)W2[i]=M.readInt32BE(i*4),W2[i+1]=M.readInt32BE(i*4+4);for(;i<160;i+=2){var xh=W2[i-30],xl=W2[i-30+1],gamma0=Gamma0(xh,xl),gamma0l=Gamma0l(xl,xh);xh=W2[i-4],xl=W2[i-4+1];var gamma1=Gamma1(xh,xl),gamma1l=Gamma1l(xl,xh),Wi7h=W2[i-14],Wi7l=W2[i-14+1],Wi16h=W2[i-32],Wi16l=W2[i-32+1],Wil=gamma0l+Wi7l|0,Wih=gamma0+Wi7h+getCarry(Wil,gamma0l)|0;Wil=Wil+gamma1l|0,Wih=Wih+gamma1+getCarry(Wil,gamma1l)|0,Wil=Wil+Wi16l|0,Wih=Wih+Wi16h+getCarry(Wil,Wi16l)|0,W2[i]=Wih,W2[i+1]=Wil}for(var j=0;j<160;j+=2){Wih=W2[j],Wil=W2[j+1];var majh=maj(ah,bh,ch),majl=maj(al,bl,cl),sigma0h=sigma0(ah,al),sigma0l=sigma0(al,ah),sigma1h=sigma1(eh,el),sigma1l=sigma1(el,eh),Kih=K[j],Kil=K[j+1],chh=Ch(eh,fh,gh),chl=Ch(el,fl,gl),t1l=hl+sigma1l|0,t1h=hh+sigma1h+getCarry(t1l,hl)|0;t1l=t1l+chl|0,t1h=t1h+chh+getCarry(t1l,chl)|0,t1l=t1l+Kil|0,t1h=t1h+Kih+getCarry(t1l,Kil)|0,t1l=t1l+Wil|0,t1h=t1h+Wih+getCarry(t1l,Wil)|0;var t2l=sigma0l+majl|0,t2h=sigma0h+majh+getCarry(t2l,sigma0l)|0;hh=gh,hl=gl,gh=fh,gl=fl,fh=eh,fl=el,el=dl+t1l|0,eh=dh+t1h+getCarry(el,dl)|0,dh=ch,dl=cl,ch=bh,cl=bl,bh=ah,bl=al,al=t1l+t2l|0,ah=t1h+t2h+getCarry(al,t1l)|0}this._al=this._al+al|0,this._bl=this._bl+bl|0,this._cl=this._cl+cl|0,this._dl=this._dl+dl|0,this._el=this._el+el|0,this._fl=this._fl+fl|0,this._gl=this._gl+gl|0,this._hl=this._hl+hl|0,this._ah=this._ah+ah+getCarry(this._al,al)|0,this._bh=this._bh+bh+getCarry(this._bl,bl)|0,this._ch=this._ch+ch+getCarry(this._cl,cl)|0,this._dh=this._dh+dh+getCarry(this._dl,dl)|0,this._eh=this._eh+eh+getCarry(this._el,el)|0,this._fh=this._fh+fh+getCarry(this._fl,fl)|0,this._gh=this._gh+gh+getCarry(this._gl,gl)|0,this._hh=this._hh+hh+getCarry(this._hl,hl)|0},Sha512.prototype._hash=function(){var H=Buffer2.allocUnsafe(64);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),writeInt64BE(this._gh,this._gl,48),writeInt64BE(this._hh,this._hl,56),H},module.exports=Sha512}}),require_sha384=__commonJS({\"node_modules/sha.js/sha384.js\"(exports,module){var inherits=require_inherits_browser(),SHA512=require_sha512(),Hash=require_hash(),Buffer2=require_safe_buffer().Buffer,W=new Array(160);function Sha384(){this.init(),this._w=W,Hash.call(this,128,112)}inherits(Sha384,SHA512),Sha384.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Sha384.prototype._hash=function(){var H=Buffer2.allocUnsafe(48);function writeInt64BE(h,l,offset){H.writeInt32BE(h,offset),H.writeInt32BE(l,offset+4)}return writeInt64BE(this._ah,this._al,0),writeInt64BE(this._bh,this._bl,8),writeInt64BE(this._ch,this._cl,16),writeInt64BE(this._dh,this._dl,24),writeInt64BE(this._eh,this._el,32),writeInt64BE(this._fh,this._fl,40),H},module.exports=Sha384}}),require_sha2=__commonJS({\"node_modules/sha.js/index.js\"(exports,module){var exports=module.exports=function(algorithm){algorithm=algorithm.toLowerCase();var Algorithm=exports[algorithm];if(!Algorithm)throw new Error(algorithm+\" is not supported (we accept pull requests)\");return new Algorithm};exports.sha=require_sha(),exports.sha1=require_sha1(),exports.sha224=require_sha224(),exports.sha256=require_sha256(),exports.sha384=require_sha384(),exports.sha512=require_sha512()}}),require_cipher_base=__commonJS({\"node_modules/cipher-base/index.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,inherits=require_inherits_browser();function CipherBase(hashMode){StreamModule.Transform.call(this),this.hashMode=typeof hashMode==\"string\",this.hashMode\?this[hashMode]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}inherits(CipherBase,StreamModule.Transform),CipherBase.prototype.update=function(data,inputEnc,outputEnc){typeof data==\"string\"&&(data=Buffer2.from(data,inputEnc));var outData=this._update(data);return this.hashMode\?this:(outputEnc&&(outData=this._toString(outData,outputEnc)),outData)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error(\"trying to get auth tag in unsupported state\")},CipherBase.prototype.setAuthTag=function(){throw new Error(\"trying to set auth tag in unsupported state\")},CipherBase.prototype.setAAD=function(){throw new Error(\"trying to set aad in unsupported state\")},CipherBase.prototype._transform=function(data,_,next){var err;try{this.hashMode\?this._update(data):this.push(this._update(data))}catch(e){err=e}finally{next(err)}},CipherBase.prototype._flush=function(done){var err;try{this.push(this.__final())}catch(e){err=e}done(err)},CipherBase.prototype._finalOrDigest=function(outputEnc){var outData=this.__final()||Buffer2.alloc(0);return outputEnc&&(outData=this._toString(outData,outputEnc,!0)),outData},CipherBase.prototype._toString=function(value,enc,fin){if(this._decoder||(this._decoder=new StringDecoder(enc),this._encoding=enc),this._encoding!==enc)throw new Error(\"can't switch encodings\");var out=this._decoder.write(value);return fin&&(out+=this._decoder.end()),out},module.exports=CipherBase}}),require_browser2=__commonJS({\"node_modules/create-hash/browser.js\"(exports,module){const LazyHash=function Hash(algorithm,options){this._options=options,this._hasher=new CryptoHasher(algorithm,options),this._finalized=!1};LazyHash.prototype=Object.create(StreamModule.Transform.prototype),LazyHash.prototype.update=function update(data,encoding){return this._checkFinalized(),this._hasher.update(data,encoding),this},LazyHash.prototype.digest=function update(data,encoding){return this._checkFinalized(),this._finalized=!0,this._hasher.digest(data,encoding)},LazyHash.prototype._checkFinalized=function _checkFinalized(){if(this._finalized){var err=new Error(\"Digest already called\");throw err.code=\"ERR_CRYPTO_HASH_FINALIZED\",err}},LazyHash.prototype.copy=function copy(){const copy=Object.create(LazyHash.prototype);return copy._options=this._options,copy._hasher=this._hasher.copy(),copy._finalized=this._finalized,copy};const lazyHashFullInitProto={__proto__:StreamModule.Transform.prototype,...LazyHash.prototype,_transform(data,encoding,callback){this.update(data,encoding),callback&&callback()},_flush(callback){this.push(this.digest()),callback()}},triggerMethods=[\"_events\",\"_eventsCount\",\"_final\",\"_maxListeners\",\"_maxListeners\",\"_read\",\"_undestroy\",\"_writableState\",\"_write\",\"_writev\",\"addListener\",\"asIndexedPairs\",\"closed\",\"compose\",\"constructor\",\"cork\",\"destroy\",\"destroyed\",\"drop\",\"emit\",\"end\",\"errored\",\"eventNames\",\"every\",\"filter\",\"find\",\"flatMap\",\"forEach\",\"getMaxListeners\",\"hasOwnProperty\",\"isPaused\",\"isPrototypeOf\",\"iterator\",\"listenerCount\",\"listeners\",\"map\",\"off\",\"on\",\"once\",\"pause\",\"pipe\",\"prependListener\",\"prependOnceListener\",\"propertyIsEnumerable\",\"push\",\"rawListeners\",\"read\",\"readable\",\"readableAborted\",\"readableBuffer\",\"readableDidRead\",\"readableEncoding\",\"readableEnded\",\"readableFlowing\",\"readableHighWaterMark\",\"readableLength\",\"readableObjectMode\",\"reduce\",\"removeAllListeners\",\"removeListener\",\"resume\",\"setDefaultEncoding\",\"setEncoding\",\"setMaxListeners\",\"some\",\"take\",\"toArray\",\"toLocaleString\",\"toString\",\"uncork\",\"unpipe\",\"unshift\",\"valueOf\",\"wrap\",\"writable\",\"writableBuffer\",\"writableCorked\",\"writableEnded\",\"writableFinished\",\"writableHighWaterMark\",\"writableLength\",\"writableNeedDrain\",\"writableObjectMode\",\"write\"];for(let method of triggerMethods)Object.defineProperty(LazyHash.prototype,method,{get(){return Object.setPrototypeOf(this,lazyHashFullInitProto),StreamModule.Transform.call(this,this._options),this[method]},enumerable:!1,configurable:!0});module.exports=function createHash(algorithm){return new LazyHash(algorithm)},module.exports.createHash=module.exports,module.exports.Hash=LazyHash}}),require_legacy=__commonJS({\"node_modules/create-hmac/legacy.js\"(exports,module){var inherits=require_inherits_browser(),Buffer2=require_safe_buffer().Buffer,Base=require_cipher_base(),ZEROS=Buffer2.alloc(128),blocksize=64;function Hmac(alg,key){Base.call(this,\"digest\"),typeof key==\"string\"&&(key=Buffer2.from(key)),this._alg=alg,this._key=key,key.length>blocksize\?key=alg(key):key.lengthblocksize){var hash=alg===\"rmd160\"\?new RIPEMD160:sha(alg);key=hash.update(key).digest()}else key.lengthMAX_ALLOC||keylen!==keylen)@throwTypeError(\"Bad key length\")}}}),require_default_encoding=__commonJS({\"node_modules/pbkdf2/lib/default-encoding.js\"(exports,module){var defaultEncoding;global.process&&global.process.browser\?defaultEncoding=\"utf-8\":global.process&&global.process.version\?(pVersionMajor=parseInt(process.version.split(\".\")[0].slice(1),10),defaultEncoding=pVersionMajor>=6\?\"utf-8\":\"binary\"):defaultEncoding=\"utf-8\";var pVersionMajor;module.exports=defaultEncoding}}),require_to_buffer=__commonJS({\"node_modules/pbkdf2/lib/to-buffer.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer;module.exports=function(thing,encoding,name){if(Buffer2.isBuffer(thing))return thing;if(typeof thing==\"string\")return Buffer2.from(thing,encoding);if(ArrayBuffer.isView(thing))return Buffer2.from(thing.buffer);@throwTypeError(name+\" must be a string, a Buffer, a typed array or a DataView\")}}}),require_sync_browser=__commonJS({\"node_modules/pbkdf2/lib/sync-browser.js\"(exports,module){var md5=require_md52(),RIPEMD160=require_ripemd160(),sha=require_sha2(),Buffer2=require_safe_buffer().Buffer,checkParameters=require_precondition(),defaultEncoding=require_default_encoding(),toBuffer=require_to_buffer(),ZEROS=Buffer2.alloc(128),sizes={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Hmac(alg,key,saltLen){var hash=getDigest(alg),blocksize=alg===\"sha512\"||alg===\"sha384\"\?128:64;key.length>blocksize\?key=hash(key):key.length>>0},exports.writeUInt32BE=function(bytes,value,off){bytes[0+off]=value>>>24,bytes[1+off]=value>>>16&255,bytes[2+off]=value>>>8&255,bytes[3+off]=value&255},exports.ip=function(inL,inR,out,off){for(var outL=0,outR=0,i=6;i>=0;i-=2){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>>j+i&1;for(var j=0;j<=24;j+=8)outL<<=1,outL|=inL>>>j+i&1}for(var i=6;i>=0;i-=2){for(var j=1;j<=25;j+=8)outR<<=1,outR|=inR>>>j+i&1;for(var j=1;j<=25;j+=8)outR<<=1,outR|=inL>>>j+i&1}out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.rip=function(inL,inR,out,off){for(var outL=0,outR=0,i=0;i<4;i++)for(var j=24;j>=0;j-=8)outL<<=1,outL|=inR>>>j+i&1,outL<<=1,outL|=inL>>>j+i&1;for(var i=4;i<8;i++)for(var j=24;j>=0;j-=8)outR<<=1,outR|=inR>>>j+i&1,outR<<=1,outR|=inL>>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.pc1=function(inL,inR,out,off){for(var outL=0,outR=0,i=7;i>=5;i--){for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var j=0;j<=24;j+=8)outL<<=1,outL|=inL>>j+i&1}for(var j=0;j<=24;j+=8)outL<<=1,outL|=inR>>j+i&1;for(var i=1;i<=3;i++){for(var j=0;j<=24;j+=8)outR<<=1,outR|=inR>>j+i&1;for(var j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1}for(var j=0;j<=24;j+=8)outR<<=1,outR|=inL>>j+i&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.r28shl=function(num,shift){return num<>>28-shift};var pc2table=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];exports.pc2=function(inL,inR,out,off){for(var outL=0,outR=0,len=pc2table.length>>>1,i=0;i>>pc2table[i]&1;for(var i=len;i>>pc2table[i]&1;out[off+0]=outL>>>0,out[off+1]=outR>>>0},exports.expand=function(r,out,off){var outL=0,outR=0;outL=(r&1)<<5|r>>>27;for(var i=23;i>=15;i-=4)outL<<=6,outL|=r>>>i&63;for(var i=11;i>=3;i-=4)outR|=r>>>i&63,outR<<=6;outR|=(r&31)<<1|r>>>31,out[off+0]=outL>>>0,out[off+1]=outR>>>0};var sTable=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];exports.substitute=function(inL,inR){for(var out=0,i=0;i<4;i++){var b=inL>>>18-i*6&63,sb=sTable[i*64+b];out<<=4,out|=sb}for(var i=0;i<4;i++){var b=inR>>>18-i*6&63,sb=sTable[256+i*64+b];out<<=4,out|=sb}return out>>>0};var permuteTable=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];exports.permute=function(num){for(var out=0,i=0;i>>permuteTable[i]&1;return out>>>0},exports.padSplit=function(num,size,group){for(var str=num.toString(2);str.length0;count--)inputOff+=this._buffer(data,inputOff),outputOff+=this._flushBuffer(out,outputOff);return inputOff+=this._buffer(data,inputOff),out},Cipher.prototype.final=function(buffer){var first;buffer&&(first=this.update(buffer));var last;return this.type===\"encrypt\"\?last=this._finalEncrypt():last=this._finalDecrypt(),first\?first.concat(last):last},Cipher.prototype._pad=function(buffer,off){if(off===0)return!1;for(;off>>1];kL=utils.r28shl(kL,shift),kR=utils.r28shl(kR,shift),utils.pc2(kL,kR,state.keys,i)}},DES.prototype._update=function(inp,inOff,out,outOff){var state=this._desState,l=utils.readUInt32BE(inp,inOff),r=utils.readUInt32BE(inp,inOff+4);utils.ip(l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],this.type===\"encrypt\"\?this._encrypt(state,l,r,state.tmp,0):this._decrypt(state,l,r,state.tmp,0),l=state.tmp[0],r=state.tmp[1],utils.writeUInt32BE(out,l,outOff),utils.writeUInt32BE(out,r,outOff+4)},DES.prototype._pad=function(buffer,off){for(var value=buffer.length-off,i=off;i>>0,l=t}utils.rip(r,l,out,off)},DES.prototype._decrypt=function(state,lStart,rStart,out,off){for(var l=rStart,r=lStart,i=state.keys.length-2;i>=0;i-=2){var keyL=state.keys[i],keyR=state.keys[i+1];utils.expand(l,state.tmp,0),keyL^=state.tmp[0],keyR^=state.tmp[1];var s=utils.substitute(keyL,keyR),f=utils.permute(s),t=l;l=(r^f)>>>0,r=t}utils.rip(l,r,out,off)}}}),require_cbc=__commonJS({\"node_modules/des.js/lib/des/cbc.js\"(exports){var assert=require_minimalistic_assert(),inherits=require_inherits_browser(),proto={};function CBCState(iv){assert.equal(iv.length,8,\"Invalid IV length\"),this.iv=new Array(8);for(var i=0;i>i%8,self2._prev=shiftIn(self2._prev,decrypt\?bit:value);return out}function shiftIn(buffer,value){var len=buffer.length,i=-1,out=Buffer2.allocUnsafe(buffer.length);for(buffer=Buffer2.concat([buffer,Buffer2.from([value])]);++i>7;return out}exports.encrypt=function(self2,chunk,decrypt){for(var len=chunk.length,out=Buffer2.allocUnsafe(len),i=-1;++i>>24]^SUB_MIX1[s1>>>16&255]^SUB_MIX2[s2>>>8&255]^SUB_MIX3[s3&255]^keySchedule[ksRow++],t1=SUB_MIX0[s1>>>24]^SUB_MIX1[s2>>>16&255]^SUB_MIX2[s3>>>8&255]^SUB_MIX3[s0&255]^keySchedule[ksRow++],t2=SUB_MIX0[s2>>>24]^SUB_MIX1[s3>>>16&255]^SUB_MIX2[s0>>>8&255]^SUB_MIX3[s1&255]^keySchedule[ksRow++],t3=SUB_MIX0[s3>>>24]^SUB_MIX1[s0>>>16&255]^SUB_MIX2[s1>>>8&255]^SUB_MIX3[s2&255]^keySchedule[ksRow++],s0=t0,s1=t1,s2=t2,s3=t3;return t0=(SBOX[s0>>>24]<<24|SBOX[s1>>>16&255]<<16|SBOX[s2>>>8&255]<<8|SBOX[s3&255])^keySchedule[ksRow++],t1=(SBOX[s1>>>24]<<24|SBOX[s2>>>16&255]<<16|SBOX[s3>>>8&255]<<8|SBOX[s0&255])^keySchedule[ksRow++],t2=(SBOX[s2>>>24]<<24|SBOX[s3>>>16&255]<<16|SBOX[s0>>>8&255]<<8|SBOX[s1&255])^keySchedule[ksRow++],t3=(SBOX[s3>>>24]<<24|SBOX[s0>>>16&255]<<16|SBOX[s1>>>8&255]<<8|SBOX[s2&255])^keySchedule[ksRow++],t0=t0>>>0,t1=t1>>>0,t2=t2>>>0,t3=t3>>>0,[t0,t1,t2,t3]}var RCON=[0,1,2,4,8,16,32,64,128,27,54],G=function(){for(var d=new Array(256),j=0;j<256;j++)j<128\?d[j]=j<<1:d[j]=j<<1^283;for(var SBOX=[],INV_SBOX=[],SUB_MIX=[[],[],[],[]],INV_SUB_MIX=[[],[],[],[]],x=0,xi=0,i=0;i<256;++i){var sx=xi^xi<<1^xi<<2^xi<<3^xi<<4;sx=sx>>>8^sx&255^99,SBOX[x]=sx,INV_SBOX[sx]=x;var x2=d[x],x4=d[x2],x8=d[x4],t=d[sx]*257^sx*16843008;SUB_MIX[0][x]=t<<24|t>>>8,SUB_MIX[1][x]=t<<16|t>>>16,SUB_MIX[2][x]=t<<8|t>>>24,SUB_MIX[3][x]=t,t=x8*16843009^x4*65537^x2*257^x*16843008,INV_SUB_MIX[0][sx]=t<<24|t>>>8,INV_SUB_MIX[1][sx]=t<<16|t>>>16,INV_SUB_MIX[2][sx]=t<<8|t>>>24,INV_SUB_MIX[3][sx]=t,x===0\?x=xi=1:(x=x2^d[d[d[x8^x2]]],xi^=d[d[xi]])}return{SBOX,INV_SBOX,SUB_MIX,INV_SUB_MIX}}();function AES(key){this._key=asUInt32Array(key),this._reset()}AES.prototype={},AES.blockSize=16,AES.keySize=32,AES.prototype.blockSize=AES.blockSize,AES.prototype.keySize=AES.keySize,AES.prototype._reset=function(){for(var keyWords=this._key,keySize=keyWords.length,nRounds=keySize+6,ksRows=(nRounds+1)*4,keySchedule=[],k=0;k>>24,t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[t&255],t^=RCON[k/keySize|0]<<24):keySize>6&&k%keySize===4&&(t=G.SBOX[t>>>24]<<24|G.SBOX[t>>>16&255]<<16|G.SBOX[t>>>8&255]<<8|G.SBOX[t&255]),keySchedule[k]=keySchedule[k-keySize]^t}for(var invKeySchedule=[],ik=0;ik>>24]]^G.INV_SUB_MIX[1][G.SBOX[tt>>>16&255]]^G.INV_SUB_MIX[2][G.SBOX[tt>>>8&255]]^G.INV_SUB_MIX[3][G.SBOX[tt&255]]}this._nRounds=nRounds,this._keySchedule=keySchedule,this._invKeySchedule=invKeySchedule},AES.prototype.encryptBlockRaw=function(M){return M=asUInt32Array(M),cryptBlock(M,this._keySchedule,G.SUB_MIX,G.SBOX,this._nRounds)},AES.prototype.encryptBlock=function(M){var out=this.encryptBlockRaw(M),buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[1],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[3],12),buf},AES.prototype.decryptBlock=function(M){M=asUInt32Array(M);var m1=M[1];M[1]=M[3],M[3]=m1;var out=cryptBlock(M,this._invKeySchedule,G.INV_SUB_MIX,G.INV_SBOX,this._nRounds),buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0],0),buf.writeUInt32BE(out[3],4),buf.writeUInt32BE(out[2],8),buf.writeUInt32BE(out[1],12),buf},AES.prototype.scrub=function(){scrubVec(this._keySchedule),scrubVec(this._invKeySchedule),scrubVec(this._key)},module.exports.AES=AES}}),require_ghash=__commonJS({\"node_modules/browserify-aes/ghash.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,ZEROES=Buffer2.alloc(16,0);function toArray(buf){return[buf.readUInt32BE(0),buf.readUInt32BE(4),buf.readUInt32BE(8),buf.readUInt32BE(12)]}function fromArray(out){var buf=Buffer2.allocUnsafe(16);return buf.writeUInt32BE(out[0]>>>0,0),buf.writeUInt32BE(out[1]>>>0,4),buf.writeUInt32BE(out[2]>>>0,8),buf.writeUInt32BE(out[3]>>>0,12),buf}function GHASH(key){this.h=key,this.state=Buffer2.alloc(16,0),this.cache=Buffer2.allocUnsafe(0)}GHASH.prototype={},GHASH.prototype.ghash=function(block){for(var i=-1;++i0;j--)Vi[j]=Vi[j]>>>1|(Vi[j-1]&1)<<31;Vi[0]=Vi[0]>>>1,lsbVi&&(Vi[0]=Vi[0]^225<<24)}this.state=fromArray(Zi)},GHASH.prototype.update=function(buf){this.cache=Buffer2.concat([this.cache,buf]);for(var chunk;this.cache.length>=16;)chunk=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(chunk)},GHASH.prototype.final=function(abl,bl){return this.cache.length&&this.ghash(Buffer2.concat([this.cache,ZEROES],16)),this.ghash(fromArray([0,abl,0,bl])),this.state},module.exports=GHASH}}),require_authCipher=__commonJS({\"node_modules/browserify-aes/authCipher.js\"(exports,module){var aes=require_aes(),Buffer2=require_safe_buffer().Buffer,Transform=require_cipher_base(),inherits=require_inherits_browser(),GHASH=require_ghash(),xor=require_buffer_xor(),incr32=require_incr32();function xorTest(a,b){var out=0;a.length!==b.length&&out++;for(var len=Math.min(a.length,b.length),i=0;i0||ivLen>0;){var hash=new MD5;hash.update(tmp),hash.update(password),salt&&hash.update(salt),tmp=hash.digest();var used=0;if(keyLen>0){var keyStart=key.length-keyLen;used=Math.min(keyLen,tmp.length),tmp.copy(key,keyStart,0,used),keyLen-=used}if(used0){var ivStart=iv.length-ivLen,length=Math.min(ivLen,tmp.length-used);tmp.copy(iv,ivStart,used,used+length),ivLen-=length}}return tmp.fill(0),{key,iv}}module.exports=EVP_BytesToKey}}),require_encrypter=__commonJS({\"node_modules/browserify-aes/encrypter.js\"(exports){var MODES=require_modes(),AuthCipher=require_authCipher(),Buffer2=require_safe_buffer().Buffer,StreamCipher=require_streamCipher(),Transform=require_cipher_base(),aes=require_aes(),ebtk=require_evp_bytestokey(),inherits=require_inherits_browser();function Cipher(mode,key,iv){Transform.call(this),this._cache=new Splitter,this._cipher=new aes.AES(key),this._prev=Buffer2.from(iv),this._mode=mode,this._autopadding=!0}inherits(Cipher,Transform),Cipher.prototype._update=function(data){this._cache.add(data);for(var chunk,thing,out=[];chunk=this._cache.get();)thing=this._mode.encrypt(this,chunk),out.push(thing);return Buffer2.concat(out)};var PADDING=Buffer2.alloc(16,16);Cipher.prototype._final=function(){var chunk=this._cache.flush();if(this._autopadding)return chunk=this._mode.encrypt(this,chunk),this._cipher.scrub(),chunk;if(!chunk.equals(PADDING))throw this._cipher.scrub(),new Error(\"data not multiple of block length\")},Cipher.prototype.setAutoPadding=function(setTo){return this._autopadding=!!setTo,this};function Splitter(){this.cache=Buffer2.allocUnsafe(0)}Splitter.prototype={},Splitter.prototype.add=function(data){this.cache=Buffer2.concat([this.cache,data])},Splitter.prototype.get=function(){if(this.cache.length>15){var out=this.cache.slice(0,16);return this.cache=this.cache.slice(16),out}return null},Splitter.prototype.flush=function(){for(var len=16-this.cache.length,padBuff=Buffer2.allocUnsafe(len),i=-1;++i16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out}else if(this.cache.length>=16)return out=this.cache.slice(0,16),this.cache=this.cache.slice(16),out;return null},Splitter.prototype.flush=function(){if(this.cache.length)return this.cache};function unpad(last){var padded=last[15];if(padded<1||padded>16)throw new Error(\"unable to decrypt data\");for(var i=-1;++i0\?left:right},BN.min=function(left,right){return left.cmp(right)<0\?left:right},BN.prototype._init=function(number,base,endian){if(typeof number==\"number\")return this._initNumber(number,base,endian);if(typeof number==\"object\")return this._initArray(number,base,endian);base===\"hex\"&&(base=16),assert(base===(base|0)&&base>=2&&base<=36),number=number.toString().replace(/\\s+/g,\"\");var start=0;number[0]===\"-\"&&(start++,this.negative=1),start=0;i-=3)w=number[i]|number[i-1]<<8|number[i-2]<<16,this.words[j]|=w<>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);else if(endian===\"le\")for(i=0,j=0;i>>26-off&67108863,off+=24,off>=26&&(off-=26,j++);return this.strip()};function parseHex4Bits(string,index){var c=string.charCodeAt(index);return c>=65&&c<=70\?c-55:c>=97&&c<=102\?c-87:c-48&15}function parseHexByte(string,lowerBound,index){var r=parseHex4Bits(string,index);return index-1>=lowerBound&&(r|=parseHex4Bits(string,index-1)<<4),r}BN.prototype._parseHex=function(number,start,endian){this.length=Math.ceil((number.length-start)/6),this.words=new Array(this.length);for(var i=0;i=start;i-=2)w=parseHexByte(number,start,i)<=18\?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8;else{var parseLength=number.length-start;for(i=parseLength%2===0\?start+1:start;i=18\?(off-=18,j+=1,this.words[j]|=w>>>26):off+=8}this.strip()};function parseBase(str,start,end,mul){for(var r=0,len=Math.min(str.length,end),i=start;i=49\?r+=c-49+10:c>=17\?r+=c-17+10:r+=c}return r}BN.prototype._parseBase=function(number,base,start){this.words=[0],this.length=1;for(var limbLen=0,limbPow=1;limbPow<=67108863;limbPow*=base)limbLen++;limbLen--,limbPow=limbPow/base|0;for(var total=number.length-start,mod=total%limbLen,end=Math.min(total,total-mod)+start,word=0,i=start;i1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},BN.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},BN.prototype.inspect=function(){return(this.red\?\"\"};var zeros=[\"\",\"0\",\"00\",\"000\",\"0000\",\"00000\",\"000000\",\"0000000\",\"00000000\",\"000000000\",\"0000000000\",\"00000000000\",\"000000000000\",\"0000000000000\",\"00000000000000\",\"000000000000000\",\"0000000000000000\",\"00000000000000000\",\"000000000000000000\",\"0000000000000000000\",\"00000000000000000000\",\"000000000000000000000\",\"0000000000000000000000\",\"00000000000000000000000\",\"000000000000000000000000\",\"0000000000000000000000000\"],groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function(base,padding){base=base||10,padding=padding|0||1;var out;if(base===16||base===\"hex\"){out=\"\";for(var off=0,carry=0,i=0;i>>24-off&16777215,carry!==0||i!==this.length-1\?out=zeros[6-word.length]+word+out:out=word+out,off+=2,off>=26&&(off-=26,i--)}for(carry!==0&&(out=carry.toString(16)+out);out.length%padding!==0;)out=\"0\"+out;return this.negative!==0&&(out=\"-\"+out),out}if(base===(base|0)&&base>=2&&base<=36){var groupSize=groupSizes[base],groupBase=groupBases[base];out=\"\";var c=this.clone();for(c.negative=0;!c.isZero();){var r=c.modn(groupBase).toString(base);c=c.idivn(groupBase),c.isZero()\?out=r+out:out=zeros[groupSize-r.length]+r+out}for(this.isZero()&&(out=\"0\"+out);out.length%padding!==0;)out=\"0\"+out;return this.negative!==0&&(out=\"-\"+out),out}assert(!1,\"Base should be between 2 and 36\")},BN.prototype.toNumber=function(){var ret=this.words[0];return this.length===2\?ret+=this.words[1]*67108864:this.length===3&&this.words[2]===1\?ret+=4503599627370496+this.words[1]*67108864:this.length>2&&assert(!1,\"Number can only safely store up to 53 bits\"),this.negative!==0\?-ret:ret},BN.prototype.toJSON=function(){return this.toString(16)},BN.prototype.toBuffer=function(endian,length){return assert(typeof Buffer2<\"u\"),this.toArrayLike(Buffer2,endian,length)},BN.prototype.toArray=function(endian,length){return this.toArrayLike(Array,endian,length)},BN.prototype.toArrayLike=function(ArrayType,endian,length){var byteLength=this.byteLength(),reqLength=length||Math.max(1,byteLength);assert(byteLength<=reqLength,\"byte array longer than desired length\"),assert(reqLength>0,\"Requested array length <= 0\"),this.strip();var littleEndian=endian===\"le\",res=new ArrayType(reqLength),b,i,q=this.clone();if(littleEndian){for(i=0;!q.isZero();i++)b=q.andln(255),q.iushrn(8),res[i]=b;for(;i=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},BN.prototype._zeroBits=function(w){if(w===0)return 26;var t=w,r=0;return(t&8191)===0&&(r+=13,t>>>=13),(t&127)===0&&(r+=7,t>>>=7),(t&15)===0&&(r+=4,t>>>=4),(t&3)===0&&(r+=2,t>>>=2),(t&1)===0&&r++,r},BN.prototype.bitLength=function(){var w=this.words[this.length-1],hi=this._countBits(w);return(this.length-1)*26+hi};function toBitArray(num){for(var w=new Array(num.bitLength()),bit=0;bit>>wbit}return w}BN.prototype.zeroBits=function(){if(this.isZero())return 0;for(var r=0,i=0;inum.length\?this.clone().ior(num):num.clone().ior(this)},BN.prototype.uor=function(num){return this.length>num.length\?this.clone().iuor(num):num.clone().iuor(this)},BN.prototype.iuand=function(num){var b;this.length>num.length\?b=num:b=this;for(var i=0;inum.length\?this.clone().iand(num):num.clone().iand(this)},BN.prototype.uand=function(num){return this.length>num.length\?this.clone().iuand(num):num.clone().iuand(this)},BN.prototype.iuxor=function(num){var a,b;this.length>num.length\?(a=this,b=num):(a=num,b=this);for(var i=0;inum.length\?this.clone().ixor(num):num.clone().ixor(this)},BN.prototype.uxor=function(num){return this.length>num.length\?this.clone().iuxor(num):num.clone().iuxor(this)},BN.prototype.inotn=function(width){assert(typeof width==\"number\"&&width>=0);var bytesNeeded=Math.ceil(width/26)|0,bitsLeft=width%26;this._expand(bytesNeeded),bitsLeft>0&&bytesNeeded--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-bitsLeft),this.strip()},BN.prototype.notn=function(width){return this.clone().inotn(width)},BN.prototype.setn=function(bit,val){assert(typeof bit==\"number\"&&bit>=0);var off=bit/26|0,wbit=bit%26;return this._expand(off+1),val\?this.words[off]=this.words[off]|1<num.length\?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>>26;for(;carry!==0&&i>>26;if(this.length=a.length,carry!==0)this.words[this.length]=carry,this.length++;else if(a!==this)for(;inum.length\?this.clone().iadd(num):num.clone().iadd(this)},BN.prototype.isub=function(num){if(num.negative!==0){num.negative=0;var r=this.iadd(num);return num.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(num),this.negative=1,this._normSign();var cmp=this.cmp(num);if(cmp===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,b;cmp>0\?(a=this,b=num):(a=num,b=this);for(var carry=0,i=0;i>26,this.words[i]=r&67108863;for(;carry!==0&&i>26,this.words[i]=r&67108863;if(carry===0&&i>>26,rword=carry&67108863,maxJ=Math.min(k,num.length-1),j=Math.max(0,k-self2.length+1);j<=maxJ;j++){var i=k-j|0;a=self2.words[i]|0,b=num.words[j]|0,r=a*b+rword,ncarry+=r/67108864|0,rword=r&67108863}out.words[k]=rword|0,carry=ncarry|0}return carry!==0\?out.words[k]=carry|0:out.length--,out.strip()}var comb10MulTo=function(self2,num,out){var a=self2.words,b=num.words,o=out.words,c=0,lo,mid,hi,a0=a[0]|0,al0=a0&8191,ah0=a0>>>13,a1=a[1]|0,al1=a1&8191,ah1=a1>>>13,a2=a[2]|0,al2=a2&8191,ah2=a2>>>13,a3=a[3]|0,al3=a3&8191,ah3=a3>>>13,a4=a[4]|0,al4=a4&8191,ah4=a4>>>13,a5=a[5]|0,al5=a5&8191,ah5=a5>>>13,a6=a[6]|0,al6=a6&8191,ah6=a6>>>13,a7=a[7]|0,al7=a7&8191,ah7=a7>>>13,a8=a[8]|0,al8=a8&8191,ah8=a8>>>13,a9=a[9]|0,al9=a9&8191,ah9=a9>>>13,b0=b[0]|0,bl0=b0&8191,bh0=b0>>>13,b1=b[1]|0,bl1=b1&8191,bh1=b1>>>13,b2=b[2]|0,bl2=b2&8191,bh2=b2>>>13,b3=b[3]|0,bl3=b3&8191,bh3=b3>>>13,b4=b[4]|0,bl4=b4&8191,bh4=b4>>>13,b5=b[5]|0,bl5=b5&8191,bh5=b5>>>13,b6=b[6]|0,bl6=b6&8191,bh6=b6>>>13,b7=b[7]|0,bl7=b7&8191,bh7=b7>>>13,b8=b[8]|0,bl8=b8&8191,bh8=b8>>>13,b9=b[9]|0,bl9=b9&8191,bh9=b9>>>13;out.negative=self2.negative^num.negative,out.length=19,lo=Math.imul(al0,bl0),mid=Math.imul(al0,bh0),mid=mid+Math.imul(ah0,bl0)|0,hi=Math.imul(ah0,bh0);var w0=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w0>>>26)|0,w0&=67108863,lo=Math.imul(al1,bl0),mid=Math.imul(al1,bh0),mid=mid+Math.imul(ah1,bl0)|0,hi=Math.imul(ah1,bh0),lo=lo+Math.imul(al0,bl1)|0,mid=mid+Math.imul(al0,bh1)|0,mid=mid+Math.imul(ah0,bl1)|0,hi=hi+Math.imul(ah0,bh1)|0;var w1=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w1>>>26)|0,w1&=67108863,lo=Math.imul(al2,bl0),mid=Math.imul(al2,bh0),mid=mid+Math.imul(ah2,bl0)|0,hi=Math.imul(ah2,bh0),lo=lo+Math.imul(al1,bl1)|0,mid=mid+Math.imul(al1,bh1)|0,mid=mid+Math.imul(ah1,bl1)|0,hi=hi+Math.imul(ah1,bh1)|0,lo=lo+Math.imul(al0,bl2)|0,mid=mid+Math.imul(al0,bh2)|0,mid=mid+Math.imul(ah0,bl2)|0,hi=hi+Math.imul(ah0,bh2)|0;var w2=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w2>>>26)|0,w2&=67108863,lo=Math.imul(al3,bl0),mid=Math.imul(al3,bh0),mid=mid+Math.imul(ah3,bl0)|0,hi=Math.imul(ah3,bh0),lo=lo+Math.imul(al2,bl1)|0,mid=mid+Math.imul(al2,bh1)|0,mid=mid+Math.imul(ah2,bl1)|0,hi=hi+Math.imul(ah2,bh1)|0,lo=lo+Math.imul(al1,bl2)|0,mid=mid+Math.imul(al1,bh2)|0,mid=mid+Math.imul(ah1,bl2)|0,hi=hi+Math.imul(ah1,bh2)|0,lo=lo+Math.imul(al0,bl3)|0,mid=mid+Math.imul(al0,bh3)|0,mid=mid+Math.imul(ah0,bl3)|0,hi=hi+Math.imul(ah0,bh3)|0;var w3=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w3>>>26)|0,w3&=67108863,lo=Math.imul(al4,bl0),mid=Math.imul(al4,bh0),mid=mid+Math.imul(ah4,bl0)|0,hi=Math.imul(ah4,bh0),lo=lo+Math.imul(al3,bl1)|0,mid=mid+Math.imul(al3,bh1)|0,mid=mid+Math.imul(ah3,bl1)|0,hi=hi+Math.imul(ah3,bh1)|0,lo=lo+Math.imul(al2,bl2)|0,mid=mid+Math.imul(al2,bh2)|0,mid=mid+Math.imul(ah2,bl2)|0,hi=hi+Math.imul(ah2,bh2)|0,lo=lo+Math.imul(al1,bl3)|0,mid=mid+Math.imul(al1,bh3)|0,mid=mid+Math.imul(ah1,bl3)|0,hi=hi+Math.imul(ah1,bh3)|0,lo=lo+Math.imul(al0,bl4)|0,mid=mid+Math.imul(al0,bh4)|0,mid=mid+Math.imul(ah0,bl4)|0,hi=hi+Math.imul(ah0,bh4)|0;var w4=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w4>>>26)|0,w4&=67108863,lo=Math.imul(al5,bl0),mid=Math.imul(al5,bh0),mid=mid+Math.imul(ah5,bl0)|0,hi=Math.imul(ah5,bh0),lo=lo+Math.imul(al4,bl1)|0,mid=mid+Math.imul(al4,bh1)|0,mid=mid+Math.imul(ah4,bl1)|0,hi=hi+Math.imul(ah4,bh1)|0,lo=lo+Math.imul(al3,bl2)|0,mid=mid+Math.imul(al3,bh2)|0,mid=mid+Math.imul(ah3,bl2)|0,hi=hi+Math.imul(ah3,bh2)|0,lo=lo+Math.imul(al2,bl3)|0,mid=mid+Math.imul(al2,bh3)|0,mid=mid+Math.imul(ah2,bl3)|0,hi=hi+Math.imul(ah2,bh3)|0,lo=lo+Math.imul(al1,bl4)|0,mid=mid+Math.imul(al1,bh4)|0,mid=mid+Math.imul(ah1,bl4)|0,hi=hi+Math.imul(ah1,bh4)|0,lo=lo+Math.imul(al0,bl5)|0,mid=mid+Math.imul(al0,bh5)|0,mid=mid+Math.imul(ah0,bl5)|0,hi=hi+Math.imul(ah0,bh5)|0;var w5=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w5>>>26)|0,w5&=67108863,lo=Math.imul(al6,bl0),mid=Math.imul(al6,bh0),mid=mid+Math.imul(ah6,bl0)|0,hi=Math.imul(ah6,bh0),lo=lo+Math.imul(al5,bl1)|0,mid=mid+Math.imul(al5,bh1)|0,mid=mid+Math.imul(ah5,bl1)|0,hi=hi+Math.imul(ah5,bh1)|0,lo=lo+Math.imul(al4,bl2)|0,mid=mid+Math.imul(al4,bh2)|0,mid=mid+Math.imul(ah4,bl2)|0,hi=hi+Math.imul(ah4,bh2)|0,lo=lo+Math.imul(al3,bl3)|0,mid=mid+Math.imul(al3,bh3)|0,mid=mid+Math.imul(ah3,bl3)|0,hi=hi+Math.imul(ah3,bh3)|0,lo=lo+Math.imul(al2,bl4)|0,mid=mid+Math.imul(al2,bh4)|0,mid=mid+Math.imul(ah2,bl4)|0,hi=hi+Math.imul(ah2,bh4)|0,lo=lo+Math.imul(al1,bl5)|0,mid=mid+Math.imul(al1,bh5)|0,mid=mid+Math.imul(ah1,bl5)|0,hi=hi+Math.imul(ah1,bh5)|0,lo=lo+Math.imul(al0,bl6)|0,mid=mid+Math.imul(al0,bh6)|0,mid=mid+Math.imul(ah0,bl6)|0,hi=hi+Math.imul(ah0,bh6)|0;var w6=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w6>>>26)|0,w6&=67108863,lo=Math.imul(al7,bl0),mid=Math.imul(al7,bh0),mid=mid+Math.imul(ah7,bl0)|0,hi=Math.imul(ah7,bh0),lo=lo+Math.imul(al6,bl1)|0,mid=mid+Math.imul(al6,bh1)|0,mid=mid+Math.imul(ah6,bl1)|0,hi=hi+Math.imul(ah6,bh1)|0,lo=lo+Math.imul(al5,bl2)|0,mid=mid+Math.imul(al5,bh2)|0,mid=mid+Math.imul(ah5,bl2)|0,hi=hi+Math.imul(ah5,bh2)|0,lo=lo+Math.imul(al4,bl3)|0,mid=mid+Math.imul(al4,bh3)|0,mid=mid+Math.imul(ah4,bl3)|0,hi=hi+Math.imul(ah4,bh3)|0,lo=lo+Math.imul(al3,bl4)|0,mid=mid+Math.imul(al3,bh4)|0,mid=mid+Math.imul(ah3,bl4)|0,hi=hi+Math.imul(ah3,bh4)|0,lo=lo+Math.imul(al2,bl5)|0,mid=mid+Math.imul(al2,bh5)|0,mid=mid+Math.imul(ah2,bl5)|0,hi=hi+Math.imul(ah2,bh5)|0,lo=lo+Math.imul(al1,bl6)|0,mid=mid+Math.imul(al1,bh6)|0,mid=mid+Math.imul(ah1,bl6)|0,hi=hi+Math.imul(ah1,bh6)|0,lo=lo+Math.imul(al0,bl7)|0,mid=mid+Math.imul(al0,bh7)|0,mid=mid+Math.imul(ah0,bl7)|0,hi=hi+Math.imul(ah0,bh7)|0;var w7=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w7>>>26)|0,w7&=67108863,lo=Math.imul(al8,bl0),mid=Math.imul(al8,bh0),mid=mid+Math.imul(ah8,bl0)|0,hi=Math.imul(ah8,bh0),lo=lo+Math.imul(al7,bl1)|0,mid=mid+Math.imul(al7,bh1)|0,mid=mid+Math.imul(ah7,bl1)|0,hi=hi+Math.imul(ah7,bh1)|0,lo=lo+Math.imul(al6,bl2)|0,mid=mid+Math.imul(al6,bh2)|0,mid=mid+Math.imul(ah6,bl2)|0,hi=hi+Math.imul(ah6,bh2)|0,lo=lo+Math.imul(al5,bl3)|0,mid=mid+Math.imul(al5,bh3)|0,mid=mid+Math.imul(ah5,bl3)|0,hi=hi+Math.imul(ah5,bh3)|0,lo=lo+Math.imul(al4,bl4)|0,mid=mid+Math.imul(al4,bh4)|0,mid=mid+Math.imul(ah4,bl4)|0,hi=hi+Math.imul(ah4,bh4)|0,lo=lo+Math.imul(al3,bl5)|0,mid=mid+Math.imul(al3,bh5)|0,mid=mid+Math.imul(ah3,bl5)|0,hi=hi+Math.imul(ah3,bh5)|0,lo=lo+Math.imul(al2,bl6)|0,mid=mid+Math.imul(al2,bh6)|0,mid=mid+Math.imul(ah2,bl6)|0,hi=hi+Math.imul(ah2,bh6)|0,lo=lo+Math.imul(al1,bl7)|0,mid=mid+Math.imul(al1,bh7)|0,mid=mid+Math.imul(ah1,bl7)|0,hi=hi+Math.imul(ah1,bh7)|0,lo=lo+Math.imul(al0,bl8)|0,mid=mid+Math.imul(al0,bh8)|0,mid=mid+Math.imul(ah0,bl8)|0,hi=hi+Math.imul(ah0,bh8)|0;var w8=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w8>>>26)|0,w8&=67108863,lo=Math.imul(al9,bl0),mid=Math.imul(al9,bh0),mid=mid+Math.imul(ah9,bl0)|0,hi=Math.imul(ah9,bh0),lo=lo+Math.imul(al8,bl1)|0,mid=mid+Math.imul(al8,bh1)|0,mid=mid+Math.imul(ah8,bl1)|0,hi=hi+Math.imul(ah8,bh1)|0,lo=lo+Math.imul(al7,bl2)|0,mid=mid+Math.imul(al7,bh2)|0,mid=mid+Math.imul(ah7,bl2)|0,hi=hi+Math.imul(ah7,bh2)|0,lo=lo+Math.imul(al6,bl3)|0,mid=mid+Math.imul(al6,bh3)|0,mid=mid+Math.imul(ah6,bl3)|0,hi=hi+Math.imul(ah6,bh3)|0,lo=lo+Math.imul(al5,bl4)|0,mid=mid+Math.imul(al5,bh4)|0,mid=mid+Math.imul(ah5,bl4)|0,hi=hi+Math.imul(ah5,bh4)|0,lo=lo+Math.imul(al4,bl5)|0,mid=mid+Math.imul(al4,bh5)|0,mid=mid+Math.imul(ah4,bl5)|0,hi=hi+Math.imul(ah4,bh5)|0,lo=lo+Math.imul(al3,bl6)|0,mid=mid+Math.imul(al3,bh6)|0,mid=mid+Math.imul(ah3,bl6)|0,hi=hi+Math.imul(ah3,bh6)|0,lo=lo+Math.imul(al2,bl7)|0,mid=mid+Math.imul(al2,bh7)|0,mid=mid+Math.imul(ah2,bl7)|0,hi=hi+Math.imul(ah2,bh7)|0,lo=lo+Math.imul(al1,bl8)|0,mid=mid+Math.imul(al1,bh8)|0,mid=mid+Math.imul(ah1,bl8)|0,hi=hi+Math.imul(ah1,bh8)|0,lo=lo+Math.imul(al0,bl9)|0,mid=mid+Math.imul(al0,bh9)|0,mid=mid+Math.imul(ah0,bl9)|0,hi=hi+Math.imul(ah0,bh9)|0;var w9=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w9>>>26)|0,w9&=67108863,lo=Math.imul(al9,bl1),mid=Math.imul(al9,bh1),mid=mid+Math.imul(ah9,bl1)|0,hi=Math.imul(ah9,bh1),lo=lo+Math.imul(al8,bl2)|0,mid=mid+Math.imul(al8,bh2)|0,mid=mid+Math.imul(ah8,bl2)|0,hi=hi+Math.imul(ah8,bh2)|0,lo=lo+Math.imul(al7,bl3)|0,mid=mid+Math.imul(al7,bh3)|0,mid=mid+Math.imul(ah7,bl3)|0,hi=hi+Math.imul(ah7,bh3)|0,lo=lo+Math.imul(al6,bl4)|0,mid=mid+Math.imul(al6,bh4)|0,mid=mid+Math.imul(ah6,bl4)|0,hi=hi+Math.imul(ah6,bh4)|0,lo=lo+Math.imul(al5,bl5)|0,mid=mid+Math.imul(al5,bh5)|0,mid=mid+Math.imul(ah5,bl5)|0,hi=hi+Math.imul(ah5,bh5)|0,lo=lo+Math.imul(al4,bl6)|0,mid=mid+Math.imul(al4,bh6)|0,mid=mid+Math.imul(ah4,bl6)|0,hi=hi+Math.imul(ah4,bh6)|0,lo=lo+Math.imul(al3,bl7)|0,mid=mid+Math.imul(al3,bh7)|0,mid=mid+Math.imul(ah3,bl7)|0,hi=hi+Math.imul(ah3,bh7)|0,lo=lo+Math.imul(al2,bl8)|0,mid=mid+Math.imul(al2,bh8)|0,mid=mid+Math.imul(ah2,bl8)|0,hi=hi+Math.imul(ah2,bh8)|0,lo=lo+Math.imul(al1,bl9)|0,mid=mid+Math.imul(al1,bh9)|0,mid=mid+Math.imul(ah1,bl9)|0,hi=hi+Math.imul(ah1,bh9)|0;var w10=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w10>>>26)|0,w10&=67108863,lo=Math.imul(al9,bl2),mid=Math.imul(al9,bh2),mid=mid+Math.imul(ah9,bl2)|0,hi=Math.imul(ah9,bh2),lo=lo+Math.imul(al8,bl3)|0,mid=mid+Math.imul(al8,bh3)|0,mid=mid+Math.imul(ah8,bl3)|0,hi=hi+Math.imul(ah8,bh3)|0,lo=lo+Math.imul(al7,bl4)|0,mid=mid+Math.imul(al7,bh4)|0,mid=mid+Math.imul(ah7,bl4)|0,hi=hi+Math.imul(ah7,bh4)|0,lo=lo+Math.imul(al6,bl5)|0,mid=mid+Math.imul(al6,bh5)|0,mid=mid+Math.imul(ah6,bl5)|0,hi=hi+Math.imul(ah6,bh5)|0,lo=lo+Math.imul(al5,bl6)|0,mid=mid+Math.imul(al5,bh6)|0,mid=mid+Math.imul(ah5,bl6)|0,hi=hi+Math.imul(ah5,bh6)|0,lo=lo+Math.imul(al4,bl7)|0,mid=mid+Math.imul(al4,bh7)|0,mid=mid+Math.imul(ah4,bl7)|0,hi=hi+Math.imul(ah4,bh7)|0,lo=lo+Math.imul(al3,bl8)|0,mid=mid+Math.imul(al3,bh8)|0,mid=mid+Math.imul(ah3,bl8)|0,hi=hi+Math.imul(ah3,bh8)|0,lo=lo+Math.imul(al2,bl9)|0,mid=mid+Math.imul(al2,bh9)|0,mid=mid+Math.imul(ah2,bl9)|0,hi=hi+Math.imul(ah2,bh9)|0;var w11=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w11>>>26)|0,w11&=67108863,lo=Math.imul(al9,bl3),mid=Math.imul(al9,bh3),mid=mid+Math.imul(ah9,bl3)|0,hi=Math.imul(ah9,bh3),lo=lo+Math.imul(al8,bl4)|0,mid=mid+Math.imul(al8,bh4)|0,mid=mid+Math.imul(ah8,bl4)|0,hi=hi+Math.imul(ah8,bh4)|0,lo=lo+Math.imul(al7,bl5)|0,mid=mid+Math.imul(al7,bh5)|0,mid=mid+Math.imul(ah7,bl5)|0,hi=hi+Math.imul(ah7,bh5)|0,lo=lo+Math.imul(al6,bl6)|0,mid=mid+Math.imul(al6,bh6)|0,mid=mid+Math.imul(ah6,bl6)|0,hi=hi+Math.imul(ah6,bh6)|0,lo=lo+Math.imul(al5,bl7)|0,mid=mid+Math.imul(al5,bh7)|0,mid=mid+Math.imul(ah5,bl7)|0,hi=hi+Math.imul(ah5,bh7)|0,lo=lo+Math.imul(al4,bl8)|0,mid=mid+Math.imul(al4,bh8)|0,mid=mid+Math.imul(ah4,bl8)|0,hi=hi+Math.imul(ah4,bh8)|0,lo=lo+Math.imul(al3,bl9)|0,mid=mid+Math.imul(al3,bh9)|0,mid=mid+Math.imul(ah3,bl9)|0,hi=hi+Math.imul(ah3,bh9)|0;var w12=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w12>>>26)|0,w12&=67108863,lo=Math.imul(al9,bl4),mid=Math.imul(al9,bh4),mid=mid+Math.imul(ah9,bl4)|0,hi=Math.imul(ah9,bh4),lo=lo+Math.imul(al8,bl5)|0,mid=mid+Math.imul(al8,bh5)|0,mid=mid+Math.imul(ah8,bl5)|0,hi=hi+Math.imul(ah8,bh5)|0,lo=lo+Math.imul(al7,bl6)|0,mid=mid+Math.imul(al7,bh6)|0,mid=mid+Math.imul(ah7,bl6)|0,hi=hi+Math.imul(ah7,bh6)|0,lo=lo+Math.imul(al6,bl7)|0,mid=mid+Math.imul(al6,bh7)|0,mid=mid+Math.imul(ah6,bl7)|0,hi=hi+Math.imul(ah6,bh7)|0,lo=lo+Math.imul(al5,bl8)|0,mid=mid+Math.imul(al5,bh8)|0,mid=mid+Math.imul(ah5,bl8)|0,hi=hi+Math.imul(ah5,bh8)|0,lo=lo+Math.imul(al4,bl9)|0,mid=mid+Math.imul(al4,bh9)|0,mid=mid+Math.imul(ah4,bl9)|0,hi=hi+Math.imul(ah4,bh9)|0;var w13=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w13>>>26)|0,w13&=67108863,lo=Math.imul(al9,bl5),mid=Math.imul(al9,bh5),mid=mid+Math.imul(ah9,bl5)|0,hi=Math.imul(ah9,bh5),lo=lo+Math.imul(al8,bl6)|0,mid=mid+Math.imul(al8,bh6)|0,mid=mid+Math.imul(ah8,bl6)|0,hi=hi+Math.imul(ah8,bh6)|0,lo=lo+Math.imul(al7,bl7)|0,mid=mid+Math.imul(al7,bh7)|0,mid=mid+Math.imul(ah7,bl7)|0,hi=hi+Math.imul(ah7,bh7)|0,lo=lo+Math.imul(al6,bl8)|0,mid=mid+Math.imul(al6,bh8)|0,mid=mid+Math.imul(ah6,bl8)|0,hi=hi+Math.imul(ah6,bh8)|0,lo=lo+Math.imul(al5,bl9)|0,mid=mid+Math.imul(al5,bh9)|0,mid=mid+Math.imul(ah5,bl9)|0,hi=hi+Math.imul(ah5,bh9)|0;var w14=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w14>>>26)|0,w14&=67108863,lo=Math.imul(al9,bl6),mid=Math.imul(al9,bh6),mid=mid+Math.imul(ah9,bl6)|0,hi=Math.imul(ah9,bh6),lo=lo+Math.imul(al8,bl7)|0,mid=mid+Math.imul(al8,bh7)|0,mid=mid+Math.imul(ah8,bl7)|0,hi=hi+Math.imul(ah8,bh7)|0,lo=lo+Math.imul(al7,bl8)|0,mid=mid+Math.imul(al7,bh8)|0,mid=mid+Math.imul(ah7,bl8)|0,hi=hi+Math.imul(ah7,bh8)|0,lo=lo+Math.imul(al6,bl9)|0,mid=mid+Math.imul(al6,bh9)|0,mid=mid+Math.imul(ah6,bl9)|0,hi=hi+Math.imul(ah6,bh9)|0;var w15=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w15>>>26)|0,w15&=67108863,lo=Math.imul(al9,bl7),mid=Math.imul(al9,bh7),mid=mid+Math.imul(ah9,bl7)|0,hi=Math.imul(ah9,bh7),lo=lo+Math.imul(al8,bl8)|0,mid=mid+Math.imul(al8,bh8)|0,mid=mid+Math.imul(ah8,bl8)|0,hi=hi+Math.imul(ah8,bh8)|0,lo=lo+Math.imul(al7,bl9)|0,mid=mid+Math.imul(al7,bh9)|0,mid=mid+Math.imul(ah7,bl9)|0,hi=hi+Math.imul(ah7,bh9)|0;var w16=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w16>>>26)|0,w16&=67108863,lo=Math.imul(al9,bl8),mid=Math.imul(al9,bh8),mid=mid+Math.imul(ah9,bl8)|0,hi=Math.imul(ah9,bh8),lo=lo+Math.imul(al8,bl9)|0,mid=mid+Math.imul(al8,bh9)|0,mid=mid+Math.imul(ah8,bl9)|0,hi=hi+Math.imul(ah8,bh9)|0;var w17=(c+lo|0)+((mid&8191)<<13)|0;c=(hi+(mid>>>13)|0)+(w17>>>26)|0,w17&=67108863,lo=Math.imul(al9,bl9),mid=Math.imul(al9,bh9),mid=mid+Math.imul(ah9,bl9)|0,hi=Math.imul(ah9,bh9);var w18=(c+lo|0)+((mid&8191)<<13)|0;return c=(hi+(mid>>>13)|0)+(w18>>>26)|0,w18&=67108863,o[0]=w0,o[1]=w1,o[2]=w2,o[3]=w3,o[4]=w4,o[5]=w5,o[6]=w6,o[7]=w7,o[8]=w8,o[9]=w9,o[10]=w10,o[11]=w11,o[12]=w12,o[13]=w13,o[14]=w14,o[15]=w15,o[16]=w16,o[17]=w17,o[18]=w18,c!==0&&(o[19]=c,out.length++),out};Math.imul||(comb10MulTo=smallMulTo);function bigMulTo(self2,num,out){out.negative=num.negative^self2.negative,out.length=self2.length+num.length;for(var carry=0,hncarry=0,k=0;k>>26)|0,hncarry+=ncarry>>>26,ncarry&=67108863}out.words[k]=rword,carry=ncarry,ncarry=hncarry}return carry!==0\?out.words[k]=carry:out.length--,out.strip()}function jumboMulTo(self2,num,out){var fftm=new FFTM;return fftm.mulp(self2,num,out)}BN.prototype.mulTo=function(num,out){var res,len=this.length+num.length;return this.length===10&&num.length===10\?res=comb10MulTo(this,num,out):len<63\?res=smallMulTo(this,num,out):len<1024\?res=bigMulTo(this,num,out):res=jumboMulTo(this,num,out),res};function FFTM(x,y){this.x=x,this.y=y}FFTM.prototype={},FFTM.prototype.makeRBT=function(N){for(var t=new Array(N),l=BN.prototype._countBits(N)-1,i=0;i>=1;return rb},FFTM.prototype.permute=function(rbt,rws,iws,rtws,itws,N){for(var i=0;i>>1)i++;return 1<>>13,rws[2*i+1]=carry&8191,carry=carry>>>13;for(i=2*len;i>=26,carry+=w/67108864|0,carry+=lo>>>26,this.words[i]=lo&67108863}return carry!==0&&(this.words[i]=carry,this.length++),this},BN.prototype.muln=function(num){return this.clone().imuln(num)},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.imul(this.clone())},BN.prototype.pow=function(num){var w=toBitArray(num);if(w.length===0)return new BN(1);for(var res=this,i=0;i=0);var r=bits%26,s=(bits-r)/26,carryMask=67108863>>>26-r<<26-r,i;if(r!==0){var carry=0;for(i=0;i>>26-r}carry&&(this.words[i]=carry,this.length++)}if(s!==0){for(i=this.length-1;i>=0;i--)this.words[i+s]=this.words[i];for(i=0;i=0);var h;hint\?h=(hint-hint%26)/26:h=0;var r=bits%26,s=Math.min((bits-r)/26,this.length),mask=67108863^67108863>>>r<s)for(this.length-=s,i=0;i=0&&(carry!==0||i>=h);i--){var word=this.words[i]|0;this.words[i]=carry<<26-r|word>>>r,carry=word&mask}return maskedWords&&carry!==0&&(maskedWords.words[maskedWords.length++]=carry),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function(bits,hint,extended){return assert(this.negative===0),this.iushrn(bits,hint,extended)},BN.prototype.shln=function(bits){return this.clone().ishln(bits)},BN.prototype.ushln=function(bits){return this.clone().iushln(bits)},BN.prototype.shrn=function(bits){return this.clone().ishrn(bits)},BN.prototype.ushrn=function(bits){return this.clone().iushrn(bits)},BN.prototype.testn=function(bit){assert(typeof bit==\"number\"&&bit>=0);var r=bit%26,s=(bit-r)/26,q=1<=0);var r=bits%26,s=(bits-r)/26;if(assert(this.negative===0,\"imaskn works only with positive numbers\"),this.length<=s)return this;if(r!==0&&s++,this.length=Math.min(s,this.length),r!==0){var mask=67108863^67108863>>>r<=67108864;i++)this.words[i]-=67108864,i===this.length-1\?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},BN.prototype.isubn=function(num){if(assert(typeof num==\"number\"),assert(num<67108864),num<0)return this.iaddn(-num);if(this.negative!==0)return this.negative=0,this.iaddn(num),this.negative=1,this;if(this.words[0]-=num,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(right/67108864|0),this.words[i+shift]=w&67108863}for(;i>26,this.words[i+shift]=w&67108863;if(carry===0)return this.strip();for(assert(carry===-1),carry=0,i=0;i>26,this.words[i]=w&67108863;return this.negative=1,this.strip()},BN.prototype._wordDiv=function(num,mode){var shift=this.length-num.length,a=this.clone(),b=num,bhi=b.words[b.length-1]|0,bhiBits=this._countBits(bhi);shift=26-bhiBits,shift!==0&&(b=b.ushln(shift),a.iushln(shift),bhi=b.words[b.length-1]|0);var m=a.length-b.length,q;if(mode!==\"mod\"){q=new BN(null),q.length=m+1,q.words=new Array(q.length);for(var i=0;i=0;j--){var qj=(a.words[b.length+j]|0)*67108864+(a.words[b.length+j-1]|0);for(qj=Math.min(qj/bhi|0,67108863),a._ishlnsubmul(b,qj,j);a.negative!==0;)qj--,a.negative=0,a._ishlnsubmul(b,1,j),a.isZero()||(a.negative^=1);q&&(q.words[j]=qj)}return q&&q.strip(),a.strip(),mode!==\"div\"&&shift!==0&&a.iushrn(shift),{div:q||null,mod:a}},BN.prototype.divmod=function(num,mode,positive){if(assert(!num.isZero()),this.isZero())return{div:new BN(0),mod:new BN(0)};var div,mod,res;return this.negative!==0&&num.negative===0\?(res=this.neg().divmod(num,mode),mode!==\"mod\"&&(div=res.div.neg()),mode!==\"div\"&&(mod=res.mod.neg(),positive&&mod.negative!==0&&mod.iadd(num)),{div,mod}):this.negative===0&&num.negative!==0\?(res=this.divmod(num.neg(),mode),mode!==\"mod\"&&(div=res.div.neg()),{div,mod:res.mod}):(this.negative&num.negative)!==0\?(res=this.neg().divmod(num.neg(),mode),mode!==\"div\"&&(mod=res.mod.neg(),positive&&mod.negative!==0&&mod.isub(num)),{div:res.div,mod}):num.length>this.length||this.cmp(num)<0\?{div:new BN(0),mod:this}:num.length===1\?mode===\"div\"\?{div:this.divn(num.words[0]),mod:null}:mode===\"mod\"\?{div:null,mod:new BN(this.modn(num.words[0]))}:{div:this.divn(num.words[0]),mod:new BN(this.modn(num.words[0]))}:this._wordDiv(num,mode)},BN.prototype.div=function(num){return this.divmod(num,\"div\",!1).div},BN.prototype.mod=function(num){return this.divmod(num,\"mod\",!1).mod},BN.prototype.umod=function(num){return this.divmod(num,\"mod\",!0).mod},BN.prototype.divRound=function(num){var dm=this.divmod(num);if(dm.mod.isZero())return dm.div;var mod=dm.div.negative!==0\?dm.mod.isub(num):dm.mod,half=num.ushrn(1),r2=num.andln(1),cmp=mod.cmp(half);return cmp<0||r2===1&&cmp===0\?dm.div:dm.div.negative!==0\?dm.div.isubn(1):dm.div.iaddn(1)},BN.prototype.modn=function(num){assert(num<=67108863);for(var p=(1<<26)%num,acc=0,i=this.length-1;i>=0;i--)acc=(p*acc+(this.words[i]|0))%num;return acc},BN.prototype.idivn=function(num){assert(num<=67108863);for(var carry=0,i=this.length-1;i>=0;i--){var w=(this.words[i]|0)+carry*67108864;this.words[i]=w/num|0,carry=w%num}return this.strip()},BN.prototype.divn=function(num){return this.clone().idivn(num)},BN.prototype.egcd=function(p){assert(p.negative===0),assert(!p.isZero());var x=this,y=p.clone();x.negative!==0\?x=x.umod(p):x=x.clone();for(var A=new BN(1),B=new BN(0),C=new BN(0),D=new BN(1),g=0;x.isEven()&&y.isEven();)x.iushrn(1),y.iushrn(1),++g;for(var yp=y.clone(),xp=x.clone();!x.isZero();){for(var i=0,im=1;(x.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0)for(x.iushrn(i);i-- >0;)(A.isOdd()||B.isOdd())&&(A.iadd(yp),B.isub(xp)),A.iushrn(1),B.iushrn(1);for(var j=0,jm=1;(y.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0)for(y.iushrn(j);j-- >0;)(C.isOdd()||D.isOdd())&&(C.iadd(yp),D.isub(xp)),C.iushrn(1),D.iushrn(1);x.cmp(y)>=0\?(x.isub(y),A.isub(C),B.isub(D)):(y.isub(x),C.isub(A),D.isub(B))}return{a:C,b:D,gcd:y.iushln(g)}},BN.prototype._invmp=function(p){assert(p.negative===0),assert(!p.isZero());var a=this,b=p.clone();a.negative!==0\?a=a.umod(p):a=a.clone();for(var x1=new BN(1),x2=new BN(0),delta=b.clone();a.cmpn(1)>0&&b.cmpn(1)>0;){for(var i=0,im=1;(a.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0)for(a.iushrn(i);i-- >0;)x1.isOdd()&&x1.iadd(delta),x1.iushrn(1);for(var j=0,jm=1;(b.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0)for(b.iushrn(j);j-- >0;)x2.isOdd()&&x2.iadd(delta),x2.iushrn(1);a.cmp(b)>=0\?(a.isub(b),x1.isub(x2)):(b.isub(a),x2.isub(x1))}var res;return a.cmpn(1)===0\?res=x1:res=x2,res.cmpn(0)<0&&res.iadd(p),res},BN.prototype.gcd=function(num){if(this.isZero())return num.abs();if(num.isZero())return this.abs();var a=this.clone(),b=num.clone();a.negative=0,b.negative=0;for(var shift=0;a.isEven()&&b.isEven();shift++)a.iushrn(1),b.iushrn(1);do{for(;a.isEven();)a.iushrn(1);for(;b.isEven();)b.iushrn(1);var r=a.cmp(b);if(r<0){var t=a;a=b,b=t}else if(r===0||b.cmpn(1)===0)break;a.isub(b)}while(!0);return b.iushln(shift)},BN.prototype.invm=function(num){return this.egcd(num).a.umod(num)},BN.prototype.isEven=function(){return(this.words[0]&1)===0},BN.prototype.isOdd=function(){return(this.words[0]&1)===1},BN.prototype.andln=function(num){return this.words[0]&num},BN.prototype.bincn=function(bit){assert(typeof bit==\"number\");var r=bit%26,s=(bit-r)/26,q=1<>>26,w&=67108863,this.words[i]=w}return carry!==0&&(this.words[i]=carry,this.length++),this},BN.prototype.isZero=function(){return this.length===1&&this.words[0]===0},BN.prototype.cmpn=function(num){var negative=num<0;if(this.negative!==0&&!negative)return-1;if(this.negative===0&&negative)return 1;this.strip();var res;if(this.length>1)res=1;else{negative&&(num=-num),assert(num<=67108863,\"Number is too big\");var w=this.words[0]|0;res=w===num\?0:wnum.length)return 1;if(this.length=0;i--){var a=this.words[i]|0,b=num.words[i]|0;if(a!==b){ab&&(res=1);break}}return res},BN.prototype.gtn=function(num){return this.cmpn(num)===1},BN.prototype.gt=function(num){return this.cmp(num)===1},BN.prototype.gten=function(num){return this.cmpn(num)>=0},BN.prototype.gte=function(num){return this.cmp(num)>=0},BN.prototype.ltn=function(num){return this.cmpn(num)===-1},BN.prototype.lt=function(num){return this.cmp(num)===-1},BN.prototype.lten=function(num){return this.cmpn(num)<=0},BN.prototype.lte=function(num){return this.cmp(num)<=0},BN.prototype.eqn=function(num){return this.cmpn(num)===0},BN.prototype.eq=function(num){return this.cmp(num)===0},BN.red=function(num){return new Red(num)},BN.prototype.toRed=function(ctx){return assert(!this.red,\"Already a number in reduction context\"),assert(this.negative===0,\"red works only with positives\"),ctx.convertTo(this)._forceRed(ctx)},BN.prototype.fromRed=function(){return assert(this.red,\"fromRed works only with numbers in reduction context\"),this.red.convertFrom(this)},BN.prototype._forceRed=function(ctx){return this.red=ctx,this},BN.prototype.forceRed=function(ctx){return assert(!this.red,\"Already a number in reduction context\"),this._forceRed(ctx)},BN.prototype.redAdd=function(num){return assert(this.red,\"redAdd works only with red numbers\"),this.red.add(this,num)},BN.prototype.redIAdd=function(num){return assert(this.red,\"redIAdd works only with red numbers\"),this.red.iadd(this,num)},BN.prototype.redSub=function(num){return assert(this.red,\"redSub works only with red numbers\"),this.red.sub(this,num)},BN.prototype.redISub=function(num){return assert(this.red,\"redISub works only with red numbers\"),this.red.isub(this,num)},BN.prototype.redShl=function(num){return assert(this.red,\"redShl works only with red numbers\"),this.red.shl(this,num)},BN.prototype.redMul=function(num){return assert(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,num),this.red.mul(this,num)},BN.prototype.redIMul=function(num){return assert(this.red,\"redMul works only with red numbers\"),this.red._verify2(this,num),this.red.imul(this,num)},BN.prototype.redSqr=function(){return assert(this.red,\"redSqr works only with red numbers\"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,\"redISqr works only with red numbers\"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,\"redSqrt works only with red numbers\"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,\"redInvm works only with red numbers\"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,\"redNeg works only with red numbers\"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(num){return assert(this.red&&!num.red,\"redPow(normalNum)\"),this.red._verify1(this),this.red.pow(this,num)};var primes={k256:null,p224:null,p192:null,p25519:null};function MPrime(name,p){this.name=name,this.p=new BN(p,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}MPrime.prototype={},MPrime.prototype._tmp=function(){var tmp=new BN(null);return tmp.words=new Array(Math.ceil(this.n/13)),tmp},MPrime.prototype.ireduce=function(num){var r=num,rlen;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),rlen=r.bitLength();while(rlen>this.n);var cmp=rlen0\?r.isub(this.p):r.strip!==void 0\?r.strip():r._strip(),r},MPrime.prototype.split=function(input,out){input.iushrn(this.n,0,out)},MPrime.prototype.imulK=function(num){return num.imul(this.k)};function K256(){MPrime.call(this,\"k256\",\"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f\")}inherits(K256,MPrime),K256.prototype.split=function(input,output){for(var mask=4194303,outLen=Math.min(input.length,9),i=0;i>>22,prev=next}prev>>>=22,input.words[i-10]=prev,prev===0&&input.length>10\?input.length-=10:input.length-=9},K256.prototype.imulK=function(num){num.words[num.length]=0,num.words[num.length+1]=0,num.length+=2;for(var lo=0,i=0;i>>=26,num.words[i]=lo,carry=hi}return carry!==0&&(num.words[num.length++]=carry),num},BN._prime=function(name){if(primes[name])return primes[name];var prime2;if(name===\"k256\")prime2=new K256;else if(name===\"p224\")prime2=new P224;else if(name===\"p192\")prime2=new P192;else if(name===\"p25519\")prime2=new P25519;else throw new Error(\"Unknown prime \"+name);return primes[name]=prime2,prime2};function Red(m){if(typeof m==\"string\"){var prime=BN._prime(m);this.m=prime.p,this.prime=prime}else assert(m.gtn(1),\"modulus must be greater than 1\"),this.m=m,this.prime=null}Red.prototype={},Red.prototype._verify1=function(a){assert(a.negative===0,\"red works only with positives\"),assert(a.red,\"red works only with red numbers\")},Red.prototype._verify2=function(a,b){assert((a.negative|b.negative)===0,\"red works only with positives\"),assert(a.red&&a.red===b.red,\"red works only with red numbers\")},Red.prototype.imod=function(a){return this.prime\?this.prime.ireduce(a)._forceRed(this):a.umod(this.m)._forceRed(this)},Red.prototype.neg=function(a){return a.isZero()\?a.clone():this.m.sub(a)._forceRed(this)},Red.prototype.add=function(a,b){this._verify2(a,b);var res=a.add(b);return res.cmp(this.m)>=0&&res.isub(this.m),res._forceRed(this)},Red.prototype.iadd=function(a,b){this._verify2(a,b);var res=a.iadd(b);return res.cmp(this.m)>=0&&res.isub(this.m),res},Red.prototype.sub=function(a,b){this._verify2(a,b);var res=a.sub(b);return res.cmpn(0)<0&&res.iadd(this.m),res._forceRed(this)},Red.prototype.isub=function(a,b){this._verify2(a,b);var res=a.isub(b);return res.cmpn(0)<0&&res.iadd(this.m),res},Red.prototype.shl=function(a,num){return this._verify1(a),this.imod(a.ushln(num))},Red.prototype.imul=function(a,b){return this._verify2(a,b),this.imod(a.imul(b))},Red.prototype.mul=function(a,b){return this._verify2(a,b),this.imod(a.mul(b))},Red.prototype.isqr=function(a){return this.imul(a,a.clone())},Red.prototype.sqr=function(a){return this.mul(a,a)},Red.prototype.sqrt=function(a){if(a.isZero())return a.clone();var mod3=this.m.andln(3);if(assert(mod3%2===1),mod3===3){var pow=this.m.add(new BN(1)).iushrn(2);return this.pow(a,pow)}for(var q=this.m.subn(1),s=0;!q.isZero()&&q.andln(1)===0;)s++,q.iushrn(1);assert(!q.isZero());var one=new BN(1).toRed(this),nOne=one.redNeg(),lpow=this.m.subn(1).iushrn(1),z=this.m.bitLength();for(z=new BN(2*z*z).toRed(this);this.pow(z,lpow).cmp(nOne)!==0;)z.redIAdd(nOne);for(var c=this.pow(z,q),r=this.pow(a,q.addn(1).iushrn(1)),t=this.pow(a,q),m=s;t.cmp(one)!==0;){for(var tmp=t,i=0;tmp.cmp(one)!==0;i++)tmp=tmp.redSqr();assert(i=0;i--){for(var word=num.words[i],j=start-1;j>=0;j--){var bit=word>>j&1;if(res!==wnd[0]&&(res=this.sqr(res)),bit===0&¤t===0){currentLen=0;continue}current<<=1,current|=bit,currentLen++,!(currentLen!==windowSize&&(i!==0||j!==0))&&(res=this.mul(res,wnd[current]),currentLen=0,current=0)}start=26}return res},Red.prototype.convertTo=function(num){var r=num.umod(this.m);return r===num\?r.clone():r},Red.prototype.convertFrom=function(num){var res=num.clone();return res.red=null,res},BN.mont=function(num){return new Mont(num)};function Mont(m){Red.call(this,m),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new BN(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}inherits(Mont,Red),Mont.prototype.convertTo=function(num){return this.imod(num.ushln(this.shift))},Mont.prototype.convertFrom=function(num){var r=this.imod(num.mul(this.rinv));return r.red=null,r},Mont.prototype.imul=function(a,b){if(a.isZero()||b.isZero())return a.words[0]=0,a.length=1,a;var t=a.imul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0\?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.mul=function(a,b){if(a.isZero()||b.isZero())return new BN(0)._forceRed(this);var t=a.mul(b),c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=t.isub(c).iushrn(this.shift),res=u;return u.cmp(this.m)>=0\?res=u.isub(this.m):u.cmpn(0)<0&&(res=u.iadd(this.m)),res._forceRed(this)},Mont.prototype.invm=function(a){var res=this.imod(a._invmp(this.m).mul(this.r2));return res._forceRed(this)}})(typeof module>\"u\"||module,exports)}}),require_bn2=require_bn,require_brorand=__commonJS({\"node_modules/brorand/index.js\"(exports,module){var r;module.exports=function(len){return r||(r=new Rand(null)),r.generate(len)};function Rand(rand){this.rand=rand}Rand.prototype={},module.exports.Rand=Rand,Rand.prototype.generate=function(len){return this._rand(len)},Rand.prototype._rand=function(n){var out=new Buffer(n);return crypto.getRandomValues(out),out}}}),require_mr=__commonJS({\"node_modules/miller-rabin/lib/mr.js\"(exports,module){var bn=require_bn2(),brorand=require_brorand();function MillerRabin(rand){this.rand=rand||new brorand.Rand}module.exports=MillerRabin,MillerRabin.create=function(rand){return new MillerRabin(rand)},MillerRabin.prototype={},MillerRabin.prototype._randbelow=function(n){var len=n.bitLength(),min_bytes=Math.ceil(len/8);do var a=new bn(this.rand.generate(min_bytes));while(a.cmp(n)>=0);return a},MillerRabin.prototype._randrange=function(start,stop){var size=stop.sub(start);return start.add(this._randbelow(size))},MillerRabin.prototype.test=function(n,k,cb){var len=n.bitLength(),red=bn.mont(n),rone=new bn(1).toRed(red);k||(k=Math.max(1,len/48|0));for(var n1=n.subn(1),s=0;!n1.testn(s);s++);for(var d=n.shrn(s),rn1=n1.toRed(red),prime=!0;k>0;k--){var a=this._randrange(new bn(2),n1);cb&&cb(a);var x=a.toRed(red).redPow(d);if(!(x.cmp(rone)===0||x.cmp(rn1)===0)){for(var i=1;i0;k--){var a=this._randrange(new bn(2),n1),g=n.gcd(a);if(g.cmpn(1)!==0)return g;var x=a.toRed(red).redPow(d);if(!(x.cmp(rone)===0||x.cmp(rn1)===0)){for(var i=1;ibits;)num.ishrn(1);if(num.isEven()&&num.iadd(ONE),num.testn(1)||num.iadd(TWO),gen.cmp(TWO)){if(!gen.cmp(FIVE))for(;num.mod(TEN).cmp(THREE);)num.iadd(FOUR)}else for(;num.mod(TWENTYFOUR).cmp(ELEVEN);)num.iadd(FOUR);if(n2=num.shrn(1),simpleSieve(n2)&&simpleSieve(num)&&fermatTest(n2)&&fermatTest(num)&&millerRabin.test(n2)&&millerRabin.test(num))return num}}}}),require_primes=__commonJS({\"node_modules/diffie-hellman/lib/primes.json\"(exports,module){module.exports={modp1:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff\"},modp2:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff\"},modp5:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff\"},modp14:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff\"},modp15:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff\"},modp16:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff\"},modp17:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff\"},modp18:{gen:\"02\",prime:\"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff\"}}}}),require_dh=__commonJS({\"node_modules/diffie-hellman/lib/dh.js\"(exports,module){var BN=require_bn(),MillerRabin=require_mr(),millerRabin=new MillerRabin,TWENTYFOUR=new BN(24),ELEVEN=new BN(11),TEN=new BN(10),THREE=new BN(3),SEVEN=new BN(7),primes=require_generatePrime(),randomBytes=require_browser();module.exports=DH;function setPublicKey(pub,enc){return enc=enc||\"utf8\",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this._pub=new BN(pub),this}function setPrivateKey(priv,enc){return enc=enc||\"utf8\",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc)),this._priv=new BN(priv),this}var primeCache={};function checkPrime(prime,generator){var gen=generator.toString(\"hex\"),hex=[gen,prime.toString(16)].join(\"_\");if(hex in primeCache)return primeCache[hex];var error=0;if(prime.isEven()||!primes.simpleSieve||!primes.fermatTest(prime)||!millerRabin.test(prime))return error+=1,gen===\"02\"||gen===\"05\"\?error+=8:error+=4,primeCache[hex]=error,error;millerRabin.test(prime.shrn(1))||(error+=2);var rem;switch(gen){case\"02\":prime.mod(TWENTYFOUR).cmp(ELEVEN)&&(error+=8);break;case\"05\":rem=prime.mod(TEN),rem.cmp(THREE)&&rem.cmp(SEVEN)&&(error+=8);break;default:error+=4}return primeCache[hex]=error,error}function DH(prime,generator,malleable){this.setGenerator(generator),this.__prime=new BN(prime),this._prime=BN.mont(this.__prime),this._primeLen=prime.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,malleable\?(this.setPublicKey=setPublicKey,this.setPrivateKey=setPrivateKey):this._primeCode=8}DH.prototype={},Object.defineProperty(DH.prototype,\"verifyError\",{enumerable:!0,get:function(){return typeof this._primeCode!=\"number\"&&(this._primeCode=checkPrime(this.__prime,this.__gen)),this._primeCode}}),DH.prototype.generateKeys=function(){return this._priv||(this._priv=new BN(randomBytes(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},DH.prototype.computeSecret=function(other){other=new BN(other),other=other.toRed(this._prime);var secret=other.redPow(this._priv).fromRed(),out=new Buffer(secret.toArray()),prime=this.getPrime();if(out.length=0||!r.umod(priv.prime1)||!r.umod(priv.prime2));return r}function crt(msg,priv){var blinds=blind(priv),len=priv.modulus.byteLength(),blinded=new BN(msg).mul(blinds.blinder).umod(priv.modulus),c1=blinded.toRed(BN.mont(priv.prime1)),c2=blinded.toRed(BN.mont(priv.prime2)),qinv=priv.coefficient,p=priv.prime1,q=priv.prime2,m1=c1.redPow(priv.exponent1).fromRed(),m2=c2.redPow(priv.exponent2).fromRed(),h=m1.isub(m2).imul(qinv).umod(p).imul(q);return m2.iadd(h).imul(blinds.unblinder).umod(priv.modulus).toArrayLike(Buffer,\"be\",len)}crt.getr=getr,module.exports=crt}}),require_package=__commonJS({\"node_modules/elliptic/package.json\"(exports,module){module.exports={name:\"elliptic\",version:\"6.5.4\",description:\"EC cryptography\",main:\"lib/elliptic.js\",files:[\"lib\"],scripts:{lint:\"eslint lib test\",\"lint:fix\":\"npm run lint -- --fix\",unit:\"istanbul test _mocha --reporter=spec test/index.js\",test:\"npm run lint && npm run unit\",version:\"grunt dist && git add dist/\"},repository:{type:\"git\",url:\"git@github.com:indutny/elliptic\"},keywords:[\"EC\",\"Elliptic\",\"curve\",\"Cryptography\"],author:\"Fedor Indutny \",license:\"MIT\",bugs:{url:\"https://github.com/indutny/elliptic/issues\"},homepage:\"https://github.com/indutny/elliptic\",devDependencies:{brfs:\"^2.0.2\",coveralls:\"^3.1.0\",eslint:\"^7.6.0\",grunt:\"^1.2.1\",\"grunt-browserify\":\"^5.3.0\",\"grunt-cli\":\"^1.3.2\",\"grunt-contrib-connect\":\"^3.0.0\",\"grunt-contrib-copy\":\"^1.0.0\",\"grunt-contrib-uglify\":\"^5.0.0\",\"grunt-mocha-istanbul\":\"^5.0.2\",\"grunt-saucelabs\":\"^9.0.1\",istanbul:\"^0.4.5\",mocha:\"^8.0.1\"},dependencies:{\"bn.js\":\"^4.11.9\",brorand:\"^1.1.0\",\"hash.js\":\"^1.0.0\",\"hmac-drbg\":\"^1.0.1\",inherits:\"^2.0.4\",\"minimalistic-assert\":\"^1.0.1\",\"minimalistic-crypto-utils\":\"^1.0.1\"}}}}),require_bn4=require_bn,require_utils2=__commonJS({\"node_modules/minimalistic-crypto-utils/lib/utils.js\"(exports){var utils=exports;function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if(typeof msg!=\"string\"){for(var i=0;i>8,lo=c&255;hi\?res.push(hi,lo):res.push(lo)}return res}utils.toArray=toArray;function zero2(word){return word.length===1\?\"0\"+word:word}utils.zero2=zero2;function toHex(msg){for(var res=\"\",i=0;i(ws>>1)-1\?z=(ws>>1)-mod:z=mod,k.isubn(z)):z=0,naf[i]=z,k.iushrn(1)}return naf}utils.getNAF=getNAF;function getJSF(k1,k2){var jsf=[[],[]];k1=k1.clone(),k2=k2.clone();for(var d1=0,d2=0,m8;k1.cmpn(-d1)>0||k2.cmpn(-d2)>0;){var m14=k1.andln(3)+d1&3,m24=k2.andln(3)+d2&3;m14===3&&(m14=-1),m24===3&&(m24=-1);var u1;(m14&1)===0\?u1=0:(m8=k1.andln(7)+d1&7,(m8===3||m8===5)&&m24===2\?u1=-m14:u1=m14),jsf[0].push(u1);var u2;(m24&1)===0\?u2=0:(m8=k2.andln(7)+d2&7,(m8===3||m8===5)&&m14===2\?u2=-m24:u2=m24),jsf[1].push(u2),2*d1===u1+1&&(d1=1-d1),2*d2===u2+1&&(d2=1-d2),k1.iushrn(1),k2.iushrn(1)}return jsf}utils.getJSF=getJSF;function cachedProperty(obj,name,computer){var key=\"_\"+name;obj.prototype[name]=function(){return this[key]!==void 0\?this[key]:this[key]=computer.call(this)}}utils.cachedProperty=cachedProperty;function parseBytes(bytes){return typeof bytes==\"string\"\?utils.toArray(bytes,\"hex\"):bytes}utils.parseBytes=parseBytes;function intFromLE(bytes){return new BN(bytes,\"hex\",\"le\")}utils.intFromLE=intFromLE}}),require_base=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/base.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),getNAF=utils.getNAF,getJSF=utils.getJSF,assert=utils.assert;function BaseCurve(type,conf){this.type=type,this.p=new BN(conf.p,16),this.red=conf.prime\?BN.red(conf.prime):BN.mont(this.p),this.zero=new BN(0).toRed(this.red),this.one=new BN(1).toRed(this.red),this.two=new BN(2).toRed(this.red),this.n=conf.n&&new BN(conf.n,16),this.g=conf.g&&this.pointFromJSON(conf.g,conf.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n\?this.n.bitLength():0;var adjustCount=this.n&&this.p.div(this.n);!adjustCount||adjustCount.cmpn(100)>0\?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}module.exports=BaseCurve,BaseCurve.prototype={},BaseCurve.prototype.point=function(){throw new Error(\"Not implemented\")},BaseCurve.prototype.validate=function(){throw new Error(\"Not implemented\")},BaseCurve.prototype._fixedNafMul=function(p,k){assert(p.precomputed);var doubles=p._getDoubles(),naf=getNAF(k,1,this._bitLength),I=(1<=j;l--)nafW=(nafW<<1)+naf[l];repr.push(nafW)}for(var a=this.jpoint(null,null,null),b=this.jpoint(null,null,null),i=I;i>0;i--){for(j=0;j=0;i--){for(var l=0;i>=0&&naf[i]===0;i--)l++;if(i>=0&&l++,acc=acc.dblp(l),i<0)break;var z=naf[i];assert(z!==0),p.type===\"affine\"\?z>0\?acc=acc.mixedAdd(wnd[z-1>>1]):acc=acc.mixedAdd(wnd[-z-1>>1].neg()):z>0\?acc=acc.add(wnd[z-1>>1]):acc=acc.add(wnd[-z-1>>1].neg())}return p.type===\"affine\"\?acc.toP():acc},BaseCurve.prototype._wnafMulAdd=function(defW,points,coeffs,len,jacobianResult){var wndWidth=this._wnafT1,wnd=this._wnafT2,naf=this._wnafT3,max=0,i,j,p;for(i=0;i=1;i-=2){var a=i-1,b=i;if(wndWidth[a]!==1||wndWidth[b]!==1){naf[a]=getNAF(coeffs[a],wndWidth[a],this._bitLength),naf[b]=getNAF(coeffs[b],wndWidth[b],this._bitLength),max=Math.max(naf[a].length,max),max=Math.max(naf[b].length,max);continue}var comb=[points[a],null,null,points[b]];points[a].y.cmp(points[b].y)===0\?(comb[1]=points[a].add(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg())):points[a].y.cmp(points[b].y.redNeg())===0\?(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].add(points[b].neg())):(comb[1]=points[a].toJ().mixedAdd(points[b]),comb[2]=points[a].toJ().mixedAdd(points[b].neg()));var index=[-3,-1,-5,-7,0,7,5,1,3],jsf=getJSF(coeffs[a],coeffs[b]);for(max=Math.max(jsf[0].length,max),naf[a]=new Array(max),naf[b]=new Array(max),j=0;j=0;i--){for(var k=0;i>=0;){var zero=!0;for(j=0;j=0&&k++,acc=acc.dblp(k),i<0)break;for(j=0;j0\?p=wnd[j][z-1>>1]:z<0&&(p=wnd[j][-z-1>>1].neg()),p.type===\"affine\"\?acc=acc.mixedAdd(p):acc=acc.add(p))}}for(i=0;i=Math.ceil((k.bitLength()+1)/doubles.step):!1},BasePoint.prototype._getDoubles=function(step,power){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var doubles=[this],acc=this,i=0;i=0&&(a2=a0,b2=b0),a1.negative&&(a1=a1.neg(),b1=b1.neg()),a2.negative&&(a2=a2.neg(),b2=b2.neg()),[{a:a1,b:b1},{a:a2,b:b2}]},ShortCurve.prototype._endoSplit=function(k){var basis=this.endo.basis,v1=basis[0],v2=basis[1],c1=v2.b.mul(k).divRound(this.n),c2=v1.b.neg().mul(k).divRound(this.n),p1=c1.mul(v1.a),p2=c2.mul(v2.a),q1=c1.mul(v1.b),q2=c2.mul(v2.b),k1=k.sub(p1).sub(p2),k2=q1.add(q2).neg();return{k1,k2}},ShortCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var y2=x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b),y=y2.redSqrt();if(y.redSqr().redSub(y2).cmp(this.zero)!==0)throw new Error(\"invalid point\");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},ShortCurve.prototype.validate=function(point){if(point.inf)return!0;var{x,y}=point,ax=this.a.redMul(x),rhs=x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b);return y.redSqr().redISub(rhs).cmpn(0)===0},ShortCurve.prototype._endoWnafMulAdd=function(points,coeffs,jacobianResult){for(var npoints=this._endoWnafT1,ncoeffs=this._endoWnafT2,i=0;i\":\"\"},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(p){if(this.inf)return p;if(p.inf)return this;if(this.eq(p))return this.dbl();if(this.neg().eq(p))return this.curve.point(null,null);if(this.x.cmp(p.x)===0)return this.curve.point(null,null);var c=this.y.redSub(p.y);c.cmpn(0)!==0&&(c=c.redMul(this.x.redSub(p.x).redInvm()));var nx=c.redSqr().redISub(this.x).redISub(p.x),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.dbl=function(){if(this.inf)return this;var ys1=this.y.redAdd(this.y);if(ys1.cmpn(0)===0)return this.curve.point(null,null);var a=this.curve.a,x2=this.x.redSqr(),dyinv=ys1.redInvm(),c=x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv),nx=c.redSqr().redISub(this.x.redAdd(this.x)),ny=c.redMul(this.x.redSub(nx)).redISub(this.y);return this.curve.point(nx,ny)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(k){return k=new BN(k,16),this.isInfinity()\?this:this._hasDoubles(k)\?this.curve._fixedNafMul(this,k):this.curve.endo\?this.curve._endoWnafMulAdd([this],[k]):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo\?this.curve._endoWnafMulAdd(points,coeffs):this.curve._wnafMulAdd(1,points,coeffs,2)},Point.prototype.jmulAdd=function(k1,p2,k2){var points=[this,p2],coeffs=[k1,k2];return this.curve.endo\?this.curve._endoWnafMulAdd(points,coeffs,!0):this.curve._wnafMulAdd(1,points,coeffs,2,!0)},Point.prototype.eq=function(p){return this===p||this.inf===p.inf&&(this.inf||this.x.cmp(p.x)===0&&this.y.cmp(p.y)===0)},Point.prototype.neg=function(_precompute){if(this.inf)return this;var res=this.curve.point(this.x,this.y.redNeg());if(_precompute&&this.precomputed){var pre=this.precomputed,negate=function(p){return p.neg()};res.precomputed={naf:pre.naf&&{wnd:pre.naf.wnd,points:pre.naf.points.map(negate)},doubles:pre.doubles&&{step:pre.doubles.step,points:pre.doubles.points.map(negate)}}}return res},Point.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var res=this.curve.jpoint(this.x,this.y,this.curve.one);return res};function JPoint(curve,x,y,z){Base.BasePoint.call(this,curve,\"jacobian\"),x===null&&y===null&&z===null\?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN(0)):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=new BN(z,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits(JPoint,Base.BasePoint),ShortCurve.prototype.jpoint=function(x,y,z){return new JPoint(this,x,y,z)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var zinv=this.z.redInvm(),zinv2=zinv.redSqr(),ax=this.x.redMul(zinv2),ay=this.y.redMul(zinv2).redMul(zinv);return this.curve.point(ax,ay)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(p){if(this.isInfinity())return p;if(p.isInfinity())return this;var pz2=p.z.redSqr(),z2=this.z.redSqr(),u1=this.x.redMul(pz2),u2=p.x.redMul(z2),s1=this.y.redMul(pz2.redMul(p.z)),s2=p.y.redMul(z2.redMul(this.z)),h=u1.redSub(u2),r=s1.redSub(s2);if(h.cmpn(0)===0)return r.cmpn(0)!==0\?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(p.z).redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.mixedAdd=function(p){if(this.isInfinity())return p.toJ();if(p.isInfinity())return this;var z2=this.z.redSqr(),u1=this.x,u2=p.x.redMul(z2),s1=this.y,s2=p.y.redMul(z2).redMul(this.z),h=u1.redSub(u2),r=s1.redSub(s2);if(h.cmpn(0)===0)return r.cmpn(0)!==0\?this.curve.jpoint(null,null,null):this.dbl();var h2=h.redSqr(),h3=h2.redMul(h),v=u1.redMul(h2),nx=r.redSqr().redIAdd(h3).redISub(v).redISub(v),ny=r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)),nz=this.z.redMul(h);return this.curve.jpoint(nx,ny,nz)},JPoint.prototype.dblp=function(pow){if(pow===0)return this;if(this.isInfinity())return this;if(!pow)return this.dbl();var i;if(this.curve.zeroA||this.curve.threeA){var r=this;for(i=0;i=0)return!1;if(rx.redIAdd(t),this.x.cmp(rx)===0)return!0}},JPoint.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},JPoint.prototype.isInfinity=function(){return this.z.cmpn(0)===0}}}),require_mont=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/mont.js\"(exports,module){var BN=require_bn4(),inherits=require_inherits_browser(),Base=require_base(),utils=require_utils3();function MontCurve(conf){Base.call(this,\"mont\",conf),this.a=new BN(conf.a,16).toRed(this.red),this.b=new BN(conf.b,16).toRed(this.red),this.i4=new BN(4).toRed(this.red).redInvm(),this.two=new BN(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}inherits(MontCurve,Base),module.exports=MontCurve,MontCurve.prototype.validate=function(point){var x=point.normalize().x,x2=x.redSqr(),rhs=x2.redMul(x).redAdd(x2.redMul(this.a)).redAdd(x),y=rhs.redSqrt();return y.redSqr().cmp(rhs)===0};function Point(curve,x,z){Base.BasePoint.call(this,curve,\"projective\"),x===null&&z===null\?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new BN(x,16),this.z=new BN(z,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}inherits(Point,Base.BasePoint),MontCurve.prototype.decodePoint=function(bytes,enc){return this.point(utils.toArray(bytes,enc),1)},MontCurve.prototype.point=function(x,z){return new Point(this,x,z)},MontCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray(\"be\",this.curve.p.byteLength())},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1]||curve.one)},Point.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},Point.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Point.prototype.dbl=function(){var a=this.x.redAdd(this.z),aa=a.redSqr(),b=this.x.redSub(this.z),bb=b.redSqr(),c=aa.redSub(bb),nx=aa.redMul(bb),nz=c.redMul(bb.redAdd(this.curve.a24.redMul(c)));return this.curve.point(nx,nz)},Point.prototype.add=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.diffAdd=function(p,diff){var a=this.x.redAdd(this.z),b=this.x.redSub(this.z),c=p.x.redAdd(p.z),d=p.x.redSub(p.z),da=d.redMul(a),cb=c.redMul(b),nx=diff.z.redMul(da.redAdd(cb).redSqr()),nz=diff.x.redMul(da.redISub(cb).redSqr());return this.curve.point(nx,nz)},Point.prototype.mul=function(k){for(var t=k.clone(),a=this,b=this.curve.point(null,null),c=this,bits=[];t.cmpn(0)!==0;t.iushrn(1))bits.push(t.andln(1));for(var i=bits.length-1;i>=0;i--)bits[i]===0\?(a=a.diffAdd(b,c),b=b.dbl()):(b=a.diffAdd(b,c),a=a.dbl());return b},Point.prototype.mulAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.jumlAdd=function(){throw new Error(\"Not supported on Montgomery curve\")},Point.prototype.eq=function(other){return this.getX().cmp(other.getX())===0},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}}}),require_edwards=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/edwards.js\"(exports,module){var utils=require_utils3(),BN=require_bn4(),inherits=require_inherits_browser(),Base=require_base(),assert=utils.assert;function EdwardsCurve(conf){this.twisted=(conf.a|0)!==1,this.mOneA=this.twisted&&(conf.a|0)===-1,this.extended=this.mOneA,Base.call(this,\"edwards\",conf),this.a=new BN(conf.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new BN(conf.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new BN(conf.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(conf.c|0)===1}inherits(EdwardsCurve,Base),module.exports=EdwardsCurve,EdwardsCurve.prototype._mulA=function(num){return this.mOneA\?num.redNeg():this.a.redMul(num)},EdwardsCurve.prototype._mulC=function(num){return this.oneC\?num:this.c.redMul(num)},EdwardsCurve.prototype.jpoint=function(x,y,z,t){return this.point(x,y,z,t)},EdwardsCurve.prototype.pointFromX=function(x,odd){x=new BN(x,16),x.red||(x=x.toRed(this.red));var x2=x.redSqr(),rhs=this.c2.redSub(this.a.redMul(x2)),lhs=this.one.redSub(this.c2.redMul(this.d).redMul(x2)),y2=rhs.redMul(lhs.redInvm()),y=y2.redSqrt();if(y.redSqr().redSub(y2).cmp(this.zero)!==0)throw new Error(\"invalid point\");var isOdd=y.fromRed().isOdd();return(odd&&!isOdd||!odd&&isOdd)&&(y=y.redNeg()),this.point(x,y)},EdwardsCurve.prototype.pointFromY=function(y,odd){y=new BN(y,16),y.red||(y=y.toRed(this.red));var y2=y.redSqr(),lhs=y2.redSub(this.c2),rhs=y2.redMul(this.d).redMul(this.c2).redSub(this.a),x2=lhs.redMul(rhs.redInvm());if(x2.cmp(this.zero)===0){if(odd)throw new Error(\"invalid point\");return this.point(this.zero,y)}var x=x2.redSqrt();if(x.redSqr().redSub(x2).cmp(this.zero)!==0)throw new Error(\"invalid point\");return x.fromRed().isOdd()!==odd&&(x=x.redNeg()),this.point(x,y)},EdwardsCurve.prototype.validate=function(point){if(point.isInfinity())return!0;point.normalize();var x2=point.x.redSqr(),y2=point.y.redSqr(),lhs=x2.redMul(this.a).redAdd(y2),rhs=this.c2.redMul(this.one.redAdd(this.d.redMul(x2).redMul(y2)));return lhs.cmp(rhs)===0};function Point(curve,x,y,z,t){Base.BasePoint.call(this,curve,\"projective\"),x===null&&y===null&&z===null\?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new BN(x,16),this.y=new BN(y,16),this.z=z\?new BN(z,16):this.curve.one,this.t=t&&new BN(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}inherits(Point,Base.BasePoint),EdwardsCurve.prototype.pointFromJSON=function(obj){return Point.fromJSON(this,obj)},EdwardsCurve.prototype.point=function(x,y,z,t){return new Point(this,x,y,z,t)},Point.fromJSON=function(curve,obj){return new Point(curve,obj[0],obj[1],obj[2])},Point.prototype.inspect=function(){return this.isInfinity()\?\"\":\"\"},Point.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},Point.prototype._extDbl=function(){var a=this.x.redSqr(),b=this.y.redSqr(),c=this.z.redSqr();c=c.redIAdd(c);var d=this.curve._mulA(a),e=this.x.redAdd(this.y).redSqr().redISub(a).redISub(b),g=d.redAdd(b),f=g.redSub(c),h=d.redSub(b),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projDbl=function(){var b=this.x.redAdd(this.y).redSqr(),c=this.x.redSqr(),d=this.y.redSqr(),nx,ny,nz,e,h,j;if(this.curve.twisted){e=this.curve._mulA(c);var f=e.redAdd(d);this.zOne\?(nx=b.redSub(c).redSub(d).redMul(f.redSub(this.curve.two)),ny=f.redMul(e.redSub(d)),nz=f.redSqr().redSub(f).redSub(f)):(h=this.z.redSqr(),j=f.redSub(h).redISub(h),nx=b.redSub(c).redISub(d).redMul(j),ny=f.redMul(e.redSub(d)),nz=f.redMul(j))}else e=c.redAdd(d),h=this.curve._mulC(this.z).redSqr(),j=e.redSub(h).redSub(h),nx=this.curve._mulC(b.redISub(e)).redMul(j),ny=this.curve._mulC(e).redMul(c.redISub(d)),nz=e.redMul(j);return this.curve.point(nx,ny,nz)},Point.prototype.dbl=function(){return this.isInfinity()\?this:this.curve.extended\?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(p){var a=this.y.redSub(this.x).redMul(p.y.redSub(p.x)),b=this.y.redAdd(this.x).redMul(p.y.redAdd(p.x)),c=this.t.redMul(this.curve.dd).redMul(p.t),d=this.z.redMul(p.z.redAdd(p.z)),e=b.redSub(a),f=d.redSub(c),g=d.redAdd(c),h=b.redAdd(a),nx=e.redMul(f),ny=g.redMul(h),nt=e.redMul(h),nz=f.redMul(g);return this.curve.point(nx,ny,nz,nt)},Point.prototype._projAdd=function(p){var a=this.z.redMul(p.z),b=a.redSqr(),c=this.x.redMul(p.x),d=this.y.redMul(p.y),e=this.curve.d.redMul(c).redMul(d),f=b.redSub(e),g=b.redAdd(e),tmp=this.x.redAdd(this.y).redMul(p.x.redAdd(p.y)).redISub(c).redISub(d),nx=a.redMul(f).redMul(tmp),ny,nz;return this.curve.twisted\?(ny=a.redMul(g).redMul(d.redSub(this.curve._mulA(c))),nz=f.redMul(g)):(ny=a.redMul(g).redMul(d.redSub(c)),nz=this.curve._mulC(f).redMul(g)),this.curve.point(nx,ny,nz)},Point.prototype.add=function(p){return this.isInfinity()\?p:p.isInfinity()\?this:this.curve.extended\?this._extAdd(p):this._projAdd(p)},Point.prototype.mul=function(k){return this._hasDoubles(k)\?this.curve._fixedNafMul(this,k):this.curve._wnafMul(this,k)},Point.prototype.mulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!1)},Point.prototype.jmulAdd=function(k1,p,k2){return this.curve._wnafMulAdd(1,[this,p],[k1,k2],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var zi=this.z.redInvm();return this.x=this.x.redMul(zi),this.y=this.y.redMul(zi),this.t&&(this.t=this.t.redMul(zi)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(other){return this===other||this.getX().cmp(other.getX())===0&&this.getY().cmp(other.getY())===0},Point.prototype.eqXToP=function(x){var rx=x.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(rx)===0)return!0;for(var xc=x.clone(),t=this.curve.redN.redMul(this.z);;){if(xc.iadd(this.curve.n),xc.cmp(this.curve.p)>=0)return!1;if(rx.redIAdd(t),this.x.cmp(rx)===0)return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add}}),require_curve=__commonJS({\"node_modules/elliptic/lib/elliptic/curve/index.js\"(exports){var curve=exports;curve.base=require_base(),curve.short=require_short(),curve.mont=require_mont(),curve.edwards=require_edwards()}}),require_utils4=__commonJS({\"node_modules/hash.js/lib/hash/utils.js\"(exports){var assert=require_minimalistic_assert(),inherits=require_inherits_browser();exports.inherits=inherits;function isSurrogatePair(msg,i){return(msg.charCodeAt(i)&64512)!==55296||i<0||i+1>=msg.length\?!1:(msg.charCodeAt(i+1)&64512)===56320}function toArray(msg,enc){if(Array.isArray(msg))return msg.slice();if(!msg)return[];var res=[];if(typeof msg==\"string\")if(enc){if(enc===\"hex\")for(msg=msg.replace(/[^a-z0-9]+/gi,\"\"),msg.length%2!==0&&(msg=\"0\"+msg),i=0;i>6|192,res[p++]=c&63|128):isSurrogatePair(msg,i)\?(c=65536+((c&1023)<<10)+(msg.charCodeAt(++i)&1023),res[p++]=c>>18|240,res[p++]=c>>12&63|128,res[p++]=c>>6&63|128,res[p++]=c&63|128):(res[p++]=c>>12|224,res[p++]=c>>6&63|128,res[p++]=c&63|128)}else for(i=0;i>>24|w>>>8&65280|w<<8&16711680|(w&255)<<24;return res>>>0}exports.htonl=htonl;function toHex32(msg,endian){for(var res=\"\",i=0;i>>0}return res}exports.join32=join32;function split32(msg,endian){for(var res=new Array(msg.length*4),i=0,k=0;i>>24,res[k+1]=m>>>16&255,res[k+2]=m>>>8&255,res[k+3]=m&255):(res[k+3]=m>>>24,res[k+2]=m>>>16&255,res[k+1]=m>>>8&255,res[k]=m&255)}return res}exports.split32=split32;function rotr32(w,b){return w>>>b|w<<32-b}exports.rotr32=rotr32;function rotl32(w,b){return w<>>32-b}exports.rotl32=rotl32;function sum32(a,b){return a+b>>>0}exports.sum32=sum32;function sum32_3(a,b,c){return a+b+c>>>0}exports.sum32_3=sum32_3;function sum32_4(a,b,c,d){return a+b+c+d>>>0}exports.sum32_4=sum32_4;function sum32_5(a,b,c,d,e){return a+b+c+d+e>>>0}exports.sum32_5=sum32_5;function sum64(buf,pos,ah,al){var bh=buf[pos],bl=buf[pos+1],lo=al+bl>>>0,hi=(lo>>0,buf[pos+1]=lo}exports.sum64=sum64;function sum64_hi(ah,al,bh,bl){var lo=al+bl>>>0,hi=(lo>>0}exports.sum64_hi=sum64_hi;function sum64_lo(ah,al,bh,bl){var lo=al+bl;return lo>>>0}exports.sum64_lo=sum64_lo;function sum64_4_hi(ah,al,bh,bl,ch,cl,dh,dl){var carry=0,lo=al;lo=lo+bl>>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0}exports.sum64_4_hi=sum64_4_hi;function sum64_4_lo(ah,al,bh,bl,ch,cl,dh,dl){var lo=al+bl+cl+dl;return lo>>>0}exports.sum64_4_lo=sum64_4_lo;function sum64_5_hi(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var carry=0,lo=al;lo=lo+bl>>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0,carry+=lo>>0}exports.sum64_5_hi=sum64_5_hi;function sum64_5_lo(ah,al,bh,bl,ch,cl,dh,dl,eh,el){var lo=al+bl+cl+dl+el;return lo>>>0}exports.sum64_5_lo=sum64_5_lo;function rotr64_hi(ah,al,num){var r=al<<32-num|ah>>>num;return r>>>0}exports.rotr64_hi=rotr64_hi;function rotr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}exports.rotr64_lo=rotr64_lo;function shr64_hi(ah,al,num){return ah>>>num}exports.shr64_hi=shr64_hi;function shr64_lo(ah,al,num){var r=ah<<32-num|al>>>num;return r>>>0}exports.shr64_lo=shr64_lo}}),require_common=__commonJS({\"node_modules/hash.js/lib/hash/common.js\"(exports){var utils=require_utils4(),assert=require_minimalistic_assert();function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian=\"big\",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}BlockHash.prototype={},exports.BlockHash=BlockHash,BlockHash.prototype.update=function(msg,enc){if(msg=utils.toArray(msg,enc),this.pending\?this.pending=this.pending.concat(msg):this.pending=msg,this.pendingTotal+=msg.length,this.pending.length>=this._delta8){msg=this.pending;var r=msg.length%this._delta8;this.pending=msg.slice(msg.length-r,msg.length),this.pending.length===0&&(this.pending=null),msg=utils.join32(msg,0,msg.length-r,this.endian);for(var i=0;i>>24&255,res[i++]=len>>>16&255,res[i++]=len>>>8&255,res[i++]=len&255}else for(res[i++]=len&255,res[i++]=len>>>8&255,res[i++]=len>>>16&255,res[i++]=len>>>24&255,res[i++]=0,res[i++]=0,res[i++]=0,res[i++]=0,t=8;t>>3}exports.g0_256=g0_256;function g1_256(x){return rotr32(x,17)^rotr32(x,19)^x>>>10}exports.g1_256=g1_256}}),require__=__commonJS({\"node_modules/hash.js/lib/hash/sha/1.js\"(exports,module){var utils=require_utils4(),common=require_common(),shaCommon=require_common2(),rotl32=utils.rotl32,sum32=utils.sum32,sum32_5=utils.sum32_5,ft_1=shaCommon.ft_1,BlockHash=common.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils.inherits(SHA1,BlockHash),module.exports=SHA1,SHA1.blockSize=512,SHA1.outSize=160,SHA1.hmacStrength=80,SHA1.padLength=64,SHA1.prototype._update=function(msg,start){for(var W=this.W,i=0;i<16;i++)W[i]=msg[start+i];for(;ithis.blockSize&&(key=new this.Hash().update(key).digest()),assert(key.length<=this.blockSize);for(var i=key.length;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._init(entropy,nonce,pers)}HmacDRBG.prototype={},module.exports=HmacDRBG,HmacDRBG.prototype._init=function(entropy,nonce,pers){var seed=entropy.concat(nonce).concat(pers);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,\"Not enough entropy. Minimum is: \"+this.minEntropy+\" bits\"),this._update(entropy.concat(add||[])),this._reseed=1},HmacDRBG.prototype.generate=function(len,enc,add,addEnc){if(this._reseed>this.reseedInterval)throw new Error(\"Reseed is required\");typeof enc!=\"string\"&&(addEnc=add,add=enc,enc=null),add&&(add=utils.toArray(add,addEnc||\"hex\"),this._update(add));for(var temp=[];temp.length\"}}}),require_signature=__commonJS({\"node_modules/elliptic/lib/elliptic/ec/signature.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),assert=utils.assert;function Signature(options,enc){if(options instanceof Signature)return options;this._importDER(options,enc)||(assert(options.r&&options.s,\"Signature without r or s\"),this.r=new BN(options.r,16),this.s=new BN(options.s,16),options.recoveryParam===void 0\?this.recoveryParam=null:this.recoveryParam=options.recoveryParam)}Signature.prototype={},module.exports=Signature;function Position(){this.place=0}function getLength(buf,p){var initial=buf[p.place++];if(!(initial&128))return initial;var octetLen=initial&15;if(octetLen===0||octetLen>4)return!1;for(var val=0,i=0,off=p.place;i>>=0;return val<=127\?!1:(p.place=off,val)}function rmPadding(buf){for(var i=0,len=buf.length-1;!buf[i]&&!(buf[i+1]&128)&&i>>3);for(arr.push(octets|128);--octets;)arr.push(len>>>(octets<<3)&255);arr.push(len)}Signature.prototype.toDER=function(enc){var r=this.r.toArray(),s=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),s[0]&128&&(s=[0].concat(s)),r=rmPadding(r),s=rmPadding(s);!s[0]&&!(s[1]&128);)s=s.slice(1);var arr=[2];constructLength(arr,r.length),arr=arr.concat(r),arr.push(2),constructLength(arr,s.length);var backHalf=arr.concat(s),res=[48];return constructLength(res,backHalf.length),res=res.concat(backHalf),utils.encode(res,enc)}}}),require_ec=__commonJS({\"node_modules/elliptic/lib/elliptic/ec/index.js\"(exports,module){var BN=require_bn4(),HmacDRBG=require_hmac_drbg(),utils=require_utils3(),curves=require_curves(),rand=require_brorand(),assert=utils.assert,KeyPair=require_key(),Signature=require_signature();function EC(options){if(!(this instanceof EC))return new EC(options);typeof options==\"string\"&&(assert(Object.prototype.hasOwnProperty.call(curves,options),\"Unknown curve \"+options),options=curves[options]),options instanceof curves.PresetCurve&&(options={curve:options}),this.curve=options.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=options.curve.g,this.g.precompute(options.curve.n.bitLength()+1),this.hash=options.hash||options.curve.hash}EC.prototype={},module.exports=EC,EC.prototype.keyPair=function(options){return new KeyPair(this,options)},EC.prototype.keyFromPrivate=function(priv,enc){return KeyPair.fromPrivate(this,priv,enc)},EC.prototype.keyFromPublic=function(pub,enc){return KeyPair.fromPublic(this,pub,enc)},EC.prototype.genKeyPair=function(options){options||(options={});for(var drbg=new HmacDRBG({hash:this.hash,pers:options.pers,persEnc:options.persEnc||\"utf8\",entropy:options.entropy||rand(this.hash.hmacStrength),entropyEnc:options.entropy&&options.entropyEnc||\"utf8\",nonce:this.n.toArray()}),bytes=this.n.byteLength(),ns2=this.n.sub(new BN(2));;){var priv=new BN(drbg.generate(bytes));if(!(priv.cmp(ns2)>0))return priv.iaddn(1),this.keyFromPrivate(priv)}},EC.prototype._truncateToN=function(msg,truncOnly){var delta=msg.byteLength()*8-this.n.bitLength();return delta>0&&(msg=msg.ushrn(delta)),!truncOnly&&msg.cmp(this.n)>=0\?msg.sub(this.n):msg},EC.prototype.sign=function(msg,key,enc,options){typeof enc==\"object\"&&(options=enc,enc=null),options||(options={}),key=this.keyFromPrivate(key,enc),msg=this._truncateToN(new BN(msg,16));for(var bytes=this.n.byteLength(),bkey=key.getPrivate().toArray(\"be\",bytes),nonce=msg.toArray(\"be\",bytes),drbg=new HmacDRBG({hash:this.hash,entropy:bkey,nonce,pers:options.pers,persEnc:options.persEnc||\"utf8\"}),ns1=this.n.sub(new BN(1)),iter=0;;iter++){var k=options.k\?options.k(iter):new BN(drbg.generate(this.n.byteLength()));if(k=this._truncateToN(k,!0),!(k.cmpn(1)<=0||k.cmp(ns1)>=0)){var kp=this.g.mul(k);if(!kp.isInfinity()){var kpX=kp.getX(),r=kpX.umod(this.n);if(r.cmpn(0)!==0){var s=k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg));if(s=s.umod(this.n),s.cmpn(0)!==0){var recoveryParam=(kp.getY().isOdd()\?1:0)|(kpX.cmp(r)!==0\?2:0);return options.canonical&&s.cmp(this.nh)>0&&(s=this.n.sub(s),recoveryParam^=1),new Signature({r,s,recoveryParam})}}}}}},EC.prototype.verify=function(msg,signature,key,enc){msg=this._truncateToN(new BN(msg,16)),key=this.keyFromPublic(key,enc),signature=new Signature(signature,\"hex\");var{r,s}=signature;if(r.cmpn(1)<0||r.cmp(this.n)>=0||s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var sinv=s.invm(this.n),u1=sinv.mul(msg).umod(this.n),u2=sinv.mul(r).umod(this.n),p;return this.curve._maxwellTrick\?(p=this.g.jmulAdd(u1,key.getPublic(),u2),p.isInfinity()\?!1:p.eqXToP(r)):(p=this.g.mulAdd(u1,key.getPublic(),u2),p.isInfinity()\?!1:p.getX().umod(this.n).cmp(r)===0)},EC.prototype.recoverPubKey=function(msg,signature,j,enc){assert((3&j)===j,\"The recovery param is more than two bits\"),signature=new Signature(signature,enc);var n=this.n,e=new BN(msg),r=signature.r,s=signature.s,isYOdd=j&1,isSecondKey=j>>1;if(r.cmp(this.curve.p.umod(this.curve.n))>=0&&isSecondKey)throw new Error(\"Unable to find sencond key candinate\");isSecondKey\?r=this.curve.pointFromX(r.add(this.curve.n),isYOdd):r=this.curve.pointFromX(r,isYOdd);var rInv=signature.r.invm(n),s1=n.sub(e).mul(rInv).umod(n),s2=s.mul(rInv).umod(n);return this.g.mulAdd(s1,r,s2)},EC.prototype.getKeyRecoveryParam=function(e,signature,Q,enc){if(signature=new Signature(signature,enc),signature.recoveryParam!==null)return signature.recoveryParam;for(var i=0;i<4;i++){var Qprime;try{Qprime=this.recoverPubKey(e,signature,i)}catch{continue}if(Qprime.eq(Q))return i}throw new Error(\"Unable to find valid recovery factor\")}}}),require_key2=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/key.js\"(exports,module){var utils=require_utils3(),assert=utils.assert,parseBytes=utils.parseBytes,cachedProperty=utils.cachedProperty;function KeyPair(eddsa,params){this.eddsa=eddsa,this._secret=parseBytes(params.secret),eddsa.isPoint(params.pub)\?this._pub=params.pub:this._pubBytes=parseBytes(params.pub)}KeyPair.prototype={},KeyPair.fromPublic=function(eddsa,pub){return pub instanceof KeyPair\?pub:new KeyPair(eddsa,{pub})},KeyPair.fromSecret=function(eddsa,secret){return secret instanceof KeyPair\?secret:new KeyPair(eddsa,{secret})},KeyPair.prototype.secret=function(){return this._secret},cachedProperty(KeyPair,\"pubBytes\",function(){return this.eddsa.encodePoint(this.pub())}),cachedProperty(KeyPair,\"pub\",function(){return this._pubBytes\?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),cachedProperty(KeyPair,\"privBytes\",function(){var eddsa=this.eddsa,hash=this.hash(),lastIx=eddsa.encodingLength-1,a=hash.slice(0,eddsa.encodingLength);return a[0]&=248,a[lastIx]&=127,a[lastIx]|=64,a}),cachedProperty(KeyPair,\"priv\",function(){return this.eddsa.decodeInt(this.privBytes())}),cachedProperty(KeyPair,\"hash\",function(){return this.eddsa.hash().update(this.secret()).digest()}),cachedProperty(KeyPair,\"messagePrefix\",function(){return this.hash().slice(this.eddsa.encodingLength)}),KeyPair.prototype.sign=function(message){return assert(this._secret,\"KeyPair can only verify\"),this.eddsa.sign(message,this)},KeyPair.prototype.verify=function(message,sig){return this.eddsa.verify(message,sig,this)},KeyPair.prototype.getSecret=function(enc){return assert(this._secret,\"KeyPair is public only\"),utils.encode(this.secret(),enc)},KeyPair.prototype.getPublic=function(enc){return utils.encode(this.pubBytes(),enc)},module.exports=KeyPair}}),require_signature2=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/signature.js\"(exports,module){var BN=require_bn4(),utils=require_utils3(),assert=utils.assert,cachedProperty=utils.cachedProperty,parseBytes=utils.parseBytes;function Signature(eddsa,sig){this.eddsa=eddsa,typeof sig!=\"object\"&&(sig=parseBytes(sig)),Array.isArray(sig)&&(sig={R:sig.slice(0,eddsa.encodingLength),S:sig.slice(eddsa.encodingLength)}),assert(sig.R&&sig.S,\"Signature without R or S\"),eddsa.isPoint(sig.R)&&(this._R=sig.R),sig.S instanceof BN&&(this._S=sig.S),this._Rencoded=Array.isArray(sig.R)\?sig.R:sig.Rencoded,this._Sencoded=Array.isArray(sig.S)\?sig.S:sig.Sencoded}Signature.prototype={},cachedProperty(Signature,\"S\",function(){return this.eddsa.decodeInt(this.Sencoded())}),cachedProperty(Signature,\"R\",function(){return this.eddsa.decodePoint(this.Rencoded())}),cachedProperty(Signature,\"Rencoded\",function(){return this.eddsa.encodePoint(this.R())}),cachedProperty(Signature,\"Sencoded\",function(){return this.eddsa.encodeInt(this.S())}),Signature.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Signature.prototype.toHex=function(){return utils.encode(this.toBytes(),\"hex\").toUpperCase()},module.exports=Signature}}),require_eddsa=__commonJS({\"node_modules/elliptic/lib/elliptic/eddsa/index.js\"(exports,module){var hash=require_hash2(),curves=require_curves(),utils=require_utils3(),assert=utils.assert,parseBytes=utils.parseBytes,KeyPair=require_key2(),Signature=require_signature2();function EDDSA(curve){if(assert(curve===\"ed25519\",\"only tested with ed25519 so far\"),!(this instanceof EDDSA))return new EDDSA(curve);curve=curves[curve].curve,this.curve=curve,this.g=curve.g,this.g.precompute(curve.n.bitLength()+1),this.pointClass=curve.point().constructor,this.encodingLength=Math.ceil(curve.n.bitLength()/8),this.hash=hash.sha512}EDDSA.prototype={},module.exports=EDDSA,EDDSA.prototype.sign=function(message,secret){message=parseBytes(message);var key=this.keyFromSecret(secret),r=this.hashInt(key.messagePrefix(),message),R=this.g.mul(r),Rencoded=this.encodePoint(R),s_=this.hashInt(Rencoded,key.pubBytes(),message).mul(key.priv()),S=r.add(s_).umod(this.curve.n);return this.makeSignature({R,S,Rencoded})},EDDSA.prototype.verify=function(message,sig,pub){message=parseBytes(message),sig=this.makeSignature(sig);var key=this.keyFromPublic(pub),h=this.hashInt(sig.Rencoded(),key.pubBytes(),message),SG=this.g.mul(sig.S()),RplusAh=sig.R().add(key.pub().mul(h));return RplusAh.eq(SG)},EDDSA.prototype.hashInt=function(){for(var hash2=this.hash(),i=0;i\"u\")@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \"+typeof value);return Buffer2(value,encodingOrOffset,length)}),Safer.alloc||(Safer.alloc=function(size,fill,encoding){if(typeof size!=\"number\")@throwTypeError('The \"size\" argument must be of type number. Received type '+typeof size);if(size<0||size>=2*(1<<30))@throwRangeError('The value \"'+size+'\" is invalid for option \"size\"');var buf=Buffer2(size);return!fill||fill.length===0\?buf.fill(0):typeof encoding==\"string\"\?buf.fill(fill,encoding):buf.fill(fill),buf}),!safer.kStringMaxLength)try{safer.kStringMaxLength=MAX_STRING_LENGTH}catch{}safer.constants||(safer.constants={MAX_LENGTH:safer.kMaxLength},safer.kStringMaxLength&&(safer.constants.MAX_STRING_LENGTH=safer.kStringMaxLength)),module.exports=safer}}),require_reporter=__commonJS({\"node_modules/asn1.js/lib/asn1/base/reporter.js\"(exports){var inherits=require_inherits_browser();function Reporter(options){this._reporterState={obj:null,path:[],options:options||{},errors:[]}}Reporter.prototype={},exports.Reporter=Reporter,Reporter.prototype.isError=function(obj){return obj instanceof ReporterError},Reporter.prototype.save=function(){let state=this._reporterState;return{obj:state.obj,pathLen:state.path.length}},Reporter.prototype.restore=function(data){let state=this._reporterState;state.obj=data.obj,state.path=state.path.slice(0,data.pathLen)},Reporter.prototype.enterKey=function(key){return this._reporterState.path.push(key)},Reporter.prototype.exitKey=function(index){let state=this._reporterState;state.path=state.path.slice(0,index-1)},Reporter.prototype.leaveKey=function(index,key,value){let state=this._reporterState;this.exitKey(index),state.obj!==null&&(state.obj[key]=value)},Reporter.prototype.path=function(){return this._reporterState.path.join(\"/\")},Reporter.prototype.enterObject=function(){let state=this._reporterState,prev=state.obj;return state.obj={},prev},Reporter.prototype.leaveObject=function(prev){let state=this._reporterState,now=state.obj;return state.obj=prev,now},Reporter.prototype.error=function(msg){let err,state=this._reporterState,inherited=msg instanceof ReporterError;if(inherited\?err=msg:err=new ReporterError(state.path.map(function(elem){return\"[\"+JSON.stringify(elem)+\"]\"}).join(\"\"),msg.message||msg,msg.stack),!state.options.partial)throw err;return inherited||state.errors.push(err),err},Reporter.prototype.wrapResult=function(result){let state=this._reporterState;return state.options.partial\?{result:this.isError(result)\?null:result,errors:state.errors}:result};function ReporterError(path,msg){this.path=path,this.rethrow(msg)}inherits(ReporterError,Error),ReporterError.prototype.rethrow=function(msg){if(this.message=msg+\" at: \"+(this.path||\"(shallow)\"),Error.captureStackTrace&&Error.captureStackTrace(this,ReporterError),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}}}),require_buffer=__commonJS({\"node_modules/asn1.js/lib/asn1/base/buffer.js\"(exports){var inherits=require_inherits_browser(),Reporter=require_reporter().Reporter,Buffer2=require_safer().Buffer;function DecoderBuffer(base,options){if(Reporter.call(this,options),!Buffer2.isBuffer(base)){this.error(\"Input not Buffer\");return}this.base=base,this.offset=0,this.length=base.length}inherits(DecoderBuffer,Reporter),exports.DecoderBuffer=DecoderBuffer,DecoderBuffer.isDecoderBuffer=function(data){return data instanceof DecoderBuffer\?!0:typeof data==\"object\"&&Buffer2.isBuffer(data.base)&&data.constructor.name===\"DecoderBuffer\"&&typeof data.offset==\"number\"&&typeof data.length==\"number\"&&typeof data.save==\"function\"&&typeof data.restore==\"function\"&&typeof data.isEmpty==\"function\"&&typeof data.readUInt8==\"function\"&&typeof data.skip==\"function\"&&typeof data.raw==\"function\"},DecoderBuffer.prototype.save=function(){return{offset:this.offset,reporter:Reporter.prototype.save.call(this)}},DecoderBuffer.prototype.restore=function(save){let res=new DecoderBuffer(this.base);return res.offset=save.offset,res.length=this.offset,this.offset=save.offset,Reporter.prototype.restore.call(this,save.reporter),res},DecoderBuffer.prototype.isEmpty=function(){return this.offset===this.length},DecoderBuffer.prototype.readUInt8=function(fail){return this.offset+1<=this.length\?this.base.readUInt8(this.offset++,!0):this.error(fail||\"DecoderBuffer overrun\")},DecoderBuffer.prototype.skip=function(bytes,fail){if(!(this.offset+bytes<=this.length))return this.error(fail||\"DecoderBuffer overrun\");let res=new DecoderBuffer(this.base);return res._reporterState=this._reporterState,res.offset=this.offset,res.length=this.offset+bytes,this.offset+=bytes,res},DecoderBuffer.prototype.raw=function(save){return this.base.slice(save\?save.offset:this.offset,this.length)};function EncoderBuffer(value,reporter){if(Array.isArray(value))this.length=0,this.value=value.map(function(item){return EncoderBuffer.isEncoderBuffer(item)||(item=new EncoderBuffer(item,reporter)),this.length+=item.length,item},this);else if(typeof value==\"number\"){if(!(0<=value&&value<=255))return reporter.error(\"non-byte EncoderBuffer value\");this.value=value,this.length=1}else if(typeof value==\"string\")this.value=value,this.length=Buffer2.byteLength(value);else if(Buffer2.isBuffer(value))this.value=value,this.length=value.length;else return reporter.error(\"Unsupported type: \"+typeof value)}EncoderBuffer.prototype={},exports.EncoderBuffer=EncoderBuffer,EncoderBuffer.isEncoderBuffer=function(data){return data instanceof EncoderBuffer\?!0:typeof data==\"object\"&&data.constructor.name===\"EncoderBuffer\"&&typeof data.length==\"number\"&&typeof data.join==\"function\"},EncoderBuffer.prototype.join=function(out,offset){return out||(out=Buffer2.alloc(this.length)),offset||(offset=0),this.length===0||(Array.isArray(this.value)\?this.value.forEach(function(item){item.join(out,offset),offset+=item.length}):(typeof this.value==\"number\"\?out[offset]=this.value:typeof this.value==\"string\"\?out.write(this.value,offset):Buffer2.isBuffer(this.value)&&this.value.copy(out,offset),offset+=this.length)),out}}}),require_node=__commonJS({\"node_modules/asn1.js/lib/asn1/base/node.js\"(exports,module){var Reporter=require_reporter().Reporter,EncoderBuffer=require_buffer().EncoderBuffer,DecoderBuffer=require_buffer().DecoderBuffer,assert=require_minimalistic_assert(),tags=[\"seq\",\"seqof\",\"set\",\"setof\",\"objid\",\"bool\",\"gentime\",\"utctime\",\"null_\",\"enum\",\"int\",\"objDesc\",\"bitstr\",\"bmpstr\",\"charstr\",\"genstr\",\"graphstr\",\"ia5str\",\"iso646str\",\"numstr\",\"octstr\",\"printstr\",\"t61str\",\"unistr\",\"utf8str\",\"videostr\"],methods=[\"key\",\"obj\",\"use\",\"optional\",\"explicit\",\"implicit\",\"def\",\"choice\",\"any\",\"contains\"].concat(tags),overrided=[\"_peekTag\",\"_decodeTag\",\"_use\",\"_decodeStr\",\"_decodeObjid\",\"_decodeTime\",\"_decodeNull\",\"_decodeInt\",\"_decodeBool\",\"_decodeList\",\"_encodeComposite\",\"_encodeStr\",\"_encodeObjid\",\"_encodeTime\",\"_encodeNull\",\"_encodeInt\",\"_encodeBool\"];function Node(enc,parent,name){let state={};this._baseState=state,state.name=name,state.enc=enc,state.parent=parent||null,state.children=null,state.tag=null,state.args=null,state.reverseArgs=null,state.choice=null,state.optional=!1,state.any=!1,state.obj=!1,state.use=null,state.useDecoder=null,state.key=null,state.default=null,state.explicit=null,state.implicit=null,state.contains=null,state.parent||(state.children=[],this._wrap())}Node.prototype={},module.exports=Node;var stateProps=[\"enc\",\"parent\",\"children\",\"tag\",\"args\",\"reverseArgs\",\"choice\",\"optional\",\"any\",\"obj\",\"use\",\"alteredUse\",\"key\",\"default\",\"explicit\",\"implicit\",\"contains\"];Node.prototype.clone=function(){let state=this._baseState,cstate={};stateProps.forEach(function(prop){cstate[prop]=state[prop]});let res=new this.constructor(cstate.parent);return res._baseState=cstate,res},Node.prototype._wrap=function(){let state=this._baseState;methods.forEach(function(method){this[method]=function(){let clone=new this.constructor(this);return state.children.push(clone),clone[method].apply(clone,arguments)}},this)},Node.prototype._init=function(body){let state=this._baseState;assert(state.parent===null),body.call(this),state.children=state.children.filter(function(child){return child._baseState.parent===this},this),assert.equal(state.children.length,1,\"Root node can have only one child\")},Node.prototype._useArgs=function(args){let state=this._baseState,children=args.filter(function(arg){return arg instanceof this.constructor},this);args=args.filter(function(arg){return!(arg instanceof this.constructor)},this),children.length!==0&&(assert(state.children===null),state.children=children,children.forEach(function(child){child._baseState.parent=this},this)),args.length!==0&&(assert(state.args===null),state.args=args,state.reverseArgs=args.map(function(arg){if(typeof arg!=\"object\"||arg.constructor!==Object)return arg;let res={};return Object.keys(arg).forEach(function(key){key==(key|0)&&(key|=0);let value=arg[key];res[value]=key}),res}))},overrided.forEach(function(method){Node.prototype[method]=function(){let state=this._baseState;throw new Error(method+\" not implemented for encoding: \"+state.enc)}}),tags.forEach(function(tag){Node.prototype[tag]=function(){let state=this._baseState,args=Array.prototype.slice.call(arguments);return assert(state.tag===null),state.tag=tag,this._useArgs(args),this}}),Node.prototype.use=function(item){assert(item);let state=this._baseState;return assert(state.use===null),state.use=item,this},Node.prototype.optional=function(){let state=this._baseState;return state.optional=!0,this},Node.prototype.def=function(val){let state=this._baseState;return assert(state.default===null),state.default=val,state.optional=!0,this},Node.prototype.explicit=function(num){let state=this._baseState;return assert(state.explicit===null&&state.implicit===null),state.explicit=num,this},Node.prototype.implicit=function(num){let state=this._baseState;return assert(state.explicit===null&&state.implicit===null),state.implicit=num,this},Node.prototype.obj=function(){let state=this._baseState,args=Array.prototype.slice.call(arguments);return state.obj=!0,args.length!==0&&this._useArgs(args),this},Node.prototype.key=function(newKey){let state=this._baseState;return assert(state.key===null),state.key=newKey,this},Node.prototype.any=function(){let state=this._baseState;return state.any=!0,this},Node.prototype.choice=function(obj){let state=this._baseState;return assert(state.choice===null),state.choice=obj,this._useArgs(Object.keys(obj).map(function(key){return obj[key]})),this},Node.prototype.contains=function(item){let state=this._baseState;return assert(state.use===null),state.contains=item,this},Node.prototype._decode=function(input,options){let state=this._baseState;if(state.parent===null)return input.wrapResult(state.children[0]._decode(input,options));let result=state.default,present=!0,prevKey=null;if(state.key!==null&&(prevKey=input.enterKey(state.key)),state.optional){let tag=null;if(state.explicit!==null\?tag=state.explicit:state.implicit!==null\?tag=state.implicit:state.tag!==null&&(tag=state.tag),tag===null&&!state.any){let save=input.save();try{state.choice===null\?this._decodeGeneric(state.tag,input,options):this._decodeChoice(input,options),present=!0}catch{present=!1}input.restore(save)}else if(present=this._peekTag(input,tag,state.any),input.isError(present))return present}let prevObj;if(state.obj&&present&&(prevObj=input.enterObject()),present){if(state.explicit!==null){let explicit=this._decodeTag(input,state.explicit);if(input.isError(explicit))return explicit;input=explicit}let start=input.offset;if(state.use===null&&state.choice===null){let save;state.any&&(save=input.save());let body=this._decodeTag(input,state.implicit!==null\?state.implicit:state.tag,state.any);if(input.isError(body))return body;state.any\?result=input.raw(save):input=body}if(options&&options.track&&state.tag!==null&&options.track(input.path(),start,input.length,\"tagged\"),options&&options.track&&state.tag!==null&&options.track(input.path(),input.offset,input.length,\"content\"),state.any||(state.choice===null\?result=this._decodeGeneric(state.tag,input,options):result=this._decodeChoice(input,options)),input.isError(result))return result;if(!state.any&&state.choice===null&&state.children!==null&&state.children.forEach(function(child){child._decode(input,options)}),state.contains&&(state.tag===\"octstr\"||state.tag===\"bitstr\")){let data=new DecoderBuffer(result);result=this._getUse(state.contains,input._reporterState.obj)._decode(data,options)}}return state.obj&&present&&(result=input.leaveObject(prevObj)),state.key!==null&&(result!==null||present===!0)\?input.leaveKey(prevKey,state.key,result):prevKey!==null&&input.exitKey(prevKey),result},Node.prototype._decodeGeneric=function(tag,input,options){let state=this._baseState;return tag===\"seq\"||tag===\"set\"\?null:tag===\"seqof\"||tag===\"setof\"\?this._decodeList(input,tag,state.args[0],options):/str$/.test(tag)\?this._decodeStr(input,tag,options):tag===\"objid\"&&state.args\?this._decodeObjid(input,state.args[0],state.args[1],options):tag===\"objid\"\?this._decodeObjid(input,null,null,options):tag===\"gentime\"||tag===\"utctime\"\?this._decodeTime(input,tag,options):tag===\"null_\"\?this._decodeNull(input,options):tag===\"bool\"\?this._decodeBool(input,options):tag===\"objDesc\"\?this._decodeStr(input,tag,options):tag===\"int\"||tag===\"enum\"\?this._decodeInt(input,state.args&&state.args[0],options):state.use!==null\?this._getUse(state.use,input._reporterState.obj)._decode(input,options):input.error(\"unknown tag: \"+tag)},Node.prototype._getUse=function(entity,obj){let state=this._baseState;return state.useDecoder=this._use(entity,obj),assert(state.useDecoder._baseState.parent===null),state.useDecoder=state.useDecoder._baseState.children[0],state.implicit!==state.useDecoder._baseState.implicit&&(state.useDecoder=state.useDecoder.clone(),state.useDecoder._baseState.implicit=state.implicit),state.useDecoder},Node.prototype._decodeChoice=function(input,options){let state=this._baseState,result=null,match=!1;return Object.keys(state.choice).some(function(key){let save=input.save(),node=state.choice[key];try{let value=node._decode(input,options);if(input.isError(value))return!1;result={type:key,value},match=!0}catch{return input.restore(save),!1}return!0},this),match\?result:input.error(\"Choice not matched\")},Node.prototype._createEncoderBuffer=function(data){return new EncoderBuffer(data,this.reporter)},Node.prototype._encode=function(data,reporter,parent){let state=this._baseState;if(state.default!==null&&state.default===data)return;let result=this._encodeValue(data,reporter,parent);if(result!==void 0&&!this._skipDefault(result,reporter,parent))return result},Node.prototype._encodeValue=function(data,reporter,parent){let state=this._baseState;if(state.parent===null)return state.children[0]._encode(data,reporter||new Reporter);let result=null;if(this.reporter=reporter,state.optional&&data===void 0)if(state.default!==null)data=state.default;else return;let content=null,primitive=!1;if(state.any)result=this._createEncoderBuffer(data);else if(state.choice)result=this._encodeChoice(data,reporter);else if(state.contains)content=this._getUse(state.contains,parent)._encode(data,reporter),primitive=!0;else if(state.children)content=state.children.map(function(child){if(child._baseState.tag===\"null_\")return child._encode(null,reporter,data);if(child._baseState.key===null)return reporter.error(\"Child should have a key\");let prevKey=reporter.enterKey(child._baseState.key);if(typeof data!=\"object\")return reporter.error(\"Child expected, but input is not object\");let res=child._encode(data[child._baseState.key],reporter,data);return reporter.leaveKey(prevKey),res},this).filter(function(child){return child}),content=this._createEncoderBuffer(content);else if(state.tag===\"seqof\"||state.tag===\"setof\"){if(!(state.args&&state.args.length===1))return reporter.error(\"Too many args for : \"+state.tag);if(!Array.isArray(data))return reporter.error(\"seqof/setof, but data is not Array\");let child=this.clone();child._baseState.implicit=null,content=this._createEncoderBuffer(data.map(function(item){let state2=this._baseState;return this._getUse(state2.args[0],data)._encode(item,reporter)},child))}else state.use!==null\?result=this._getUse(state.use,parent)._encode(data,reporter):(content=this._encodePrimitive(state.tag,data),primitive=!0);if(!state.any&&state.choice===null){let tag=state.implicit!==null\?state.implicit:state.tag,cls=state.implicit===null\?\"universal\":\"context\";tag===null\?state.use===null&&reporter.error(\"Tag could be omitted only for .use()\"):state.use===null&&(result=this._encodeComposite(tag,primitive,cls,content))}return state.explicit!==null&&(result=this._encodeComposite(state.explicit,!1,\"context\",result)),result},Node.prototype._encodeChoice=function(data,reporter){let state=this._baseState,node=state.choice[data.type];return node||assert(!1,data.type+\" not found in \"+JSON.stringify(Object.keys(state.choice))),node._encode(data.value,reporter)},Node.prototype._encodePrimitive=function(tag,data){let state=this._baseState;if(/str$/.test(tag))return this._encodeStr(data,tag);if(tag===\"objid\"&&state.args)return this._encodeObjid(data,state.reverseArgs[0],state.args[1]);if(tag===\"objid\")return this._encodeObjid(data,null,null);if(tag===\"gentime\"||tag===\"utctime\")return this._encodeTime(data,tag);if(tag===\"null_\")return this._encodeNull();if(tag===\"int\"||tag===\"enum\")return this._encodeInt(data,state.args&&state.reverseArgs[0]);if(tag===\"bool\")return this._encodeBool(data);if(tag===\"objDesc\")return this._encodeStr(data,tag);throw new Error(\"Unsupported tag: \"+tag)},Node.prototype._isNumstr=function(str){return/^[0-9 ]*$/.test(str)},Node.prototype._isPrintstr=function(str){return/^[A-Za-z0-9 '()+,-./:=\?]*$/.test(str)}}}),require_der=__commonJS({\"node_modules/asn1.js/lib/asn1/constants/der.js\"(exports){function reverse(map){let res={};return Object.keys(map).forEach(function(key){(key|0)==key&&(key=key|0);let value=map[key];res[value]=key}),res}exports.tagClass={0:\"universal\",1:\"application\",2:\"context\",3:\"private\"},exports.tagClassByName=reverse(exports.tagClass),exports.tag={0:\"end\",1:\"bool\",2:\"int\",3:\"bitstr\",4:\"octstr\",5:\"null_\",6:\"objid\",7:\"objDesc\",8:\"external\",9:\"real\",10:\"enum\",11:\"embed\",12:\"utf8str\",13:\"relativeOid\",16:\"seq\",17:\"set\",18:\"numstr\",19:\"printstr\",20:\"t61str\",21:\"videostr\",22:\"ia5str\",23:\"utctime\",24:\"gentime\",25:\"graphstr\",26:\"iso646str\",27:\"genstr\",28:\"unistr\",29:\"charstr\",30:\"bmpstr\"},exports.tagByName=reverse(exports.tag)}}),require_der2=__commonJS({\"node_modules/asn1.js/lib/asn1/encoders/der.js\"(exports,module){var inherits=require_inherits_browser(),Buffer2=require_safer().Buffer,Node=require_node(),der=require_der();function DEREncoder(entity){this.enc=\"der\",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}DEREncoder.prototype={},module.exports=DEREncoder,DEREncoder.prototype.encode=function(data,reporter){return this.tree._encode(data,reporter).join()};function DERNode(parent){Node.call(this,\"der\",parent)}inherits(DERNode,Node),DERNode.prototype._encodeComposite=function(tag,primitive,cls,content){let encodedTag=encodeTag(tag,primitive,cls,this.reporter);if(content.length<128){let header2=Buffer2.alloc(2);return header2[0]=encodedTag,header2[1]=content.length,this._createEncoderBuffer([header2,content])}let lenOctets=1;for(let i=content.length;i>=256;i>>=8)lenOctets++;let header=Buffer2.alloc(2+lenOctets);header[0]=encodedTag,header[1]=128|lenOctets;for(let i=1+lenOctets,j=content.length;j>0;i--,j>>=8)header[i]=j&255;return this._createEncoderBuffer([header,content])},DERNode.prototype._encodeStr=function(str,tag){if(tag===\"bitstr\")return this._createEncoderBuffer([str.unused|0,str.data]);if(tag===\"bmpstr\"){let buf=Buffer2.alloc(str.length*2);for(let i=0;i=40)return this.reporter.error(\"Second objid identifier OOB\");id.splice(0,2,id[0]*40+id[1])}let size=0;for(let i=0;i=128;ident>>=7)size++}let objid=Buffer2.alloc(size),offset=objid.length-1;for(let i=id.length-1;i>=0;i--){let ident=id[i];for(objid[offset--]=ident&127;(ident>>=7)>0;)objid[offset--]=128|ident&127}return this._createEncoderBuffer(objid)};function two(num){return num<10\?\"0\"+num:num}DERNode.prototype._encodeTime=function(time,tag){let str,date=new Date(time);return tag===\"gentime\"\?str=[two(date.getUTCFullYear()),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),\"Z\"].join(\"\"):tag===\"utctime\"\?str=[two(date.getUTCFullYear()%100),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),\"Z\"].join(\"\"):this.reporter.error(\"Encoding \"+tag+\" time is not supported yet\"),this._encodeStr(str,\"octstr\")},DERNode.prototype._encodeNull=function(){return this._createEncoderBuffer(\"\")},DERNode.prototype._encodeInt=function(num,values){if(typeof num==\"string\"){if(!values)return this.reporter.error(\"String int or enum given, but no values map\");if(!values.hasOwnProperty(num))return this.reporter.error(\"Values map doesn't contain: \"+JSON.stringify(num));num=values[num]}if(typeof num!=\"number\"&&!Buffer2.isBuffer(num)){let numArray=num.toArray();!num.sign&&numArray[0]&128&&numArray.unshift(0),num=Buffer2.from(numArray)}if(Buffer2.isBuffer(num)){let size2=num.length;num.length===0&&size2++;let out2=Buffer2.alloc(size2);return num.copy(out2),num.length===0&&(out2[0]=0),this._createEncoderBuffer(out2)}if(num<128)return this._createEncoderBuffer(num);if(num<256)return this._createEncoderBuffer([0,num]);let size=1;for(let i=num;i>=256;i>>=8)size++;let out=new Array(size);for(let i=out.length-1;i>=0;i--)out[i]=num&255,num>>=8;return out[0]&128&&out.unshift(0),this._createEncoderBuffer(Buffer2.from(out))},DERNode.prototype._encodeBool=function(value){return this._createEncoderBuffer(value\?255:0)},DERNode.prototype._use=function(entity,obj){return typeof entity==\"function\"&&(entity=entity(obj)),entity._getEncoder(\"der\").tree},DERNode.prototype._skipDefault=function(dataBuffer,reporter,parent){let state=this._baseState,i;if(state.default===null)return!1;let data=dataBuffer.join();if(state.defaultBuffer===void 0&&(state.defaultBuffer=this._encodeValue(state.default,reporter,parent).join()),data.length!==state.defaultBuffer.length)return!1;for(i=0;i=31\?reporter.error(\"Multi-octet tag encoding unsupported\"):(primitive||(res|=32),res|=der.tagClassByName[cls||\"universal\"]<<6,res)}}}),require_pem=__commonJS({\"node_modules/asn1.js/lib/asn1/encoders/pem.js\"(exports,module){var inherits=require_inherits_browser(),DEREncoder=require_der2();function PEMEncoder(entity){DEREncoder.call(this,entity),this.enc=\"pem\"}inherits(PEMEncoder,DEREncoder),module.exports=PEMEncoder,PEMEncoder.prototype.encode=function(data,options){let p=DEREncoder.prototype.encode.call(this,data).toString(\"base64\"),out=[\"-----BEGIN \"+options.label+\"-----\"];for(let i=0;i>6],primitive=(tag&32)===0;if((tag&31)===31){let oct=tag;for(tag=0;(oct&128)===128;){if(oct=buf.readUInt8(fail),buf.isError(oct))return oct;tag<<=7,tag|=oct&127}}else tag&=31;let tagStr=der.tag[tag];return{cls,primitive,tag,tagStr}}function derDecodeLen(buf,primitive,fail){let len=buf.readUInt8(fail);if(buf.isError(len))return len;if(!primitive&&len===128)return null;if((len&128)===0)return len;let num=len&127;if(num>4)return buf.error(\"length octect is too long\");len=0;for(let i=0;i0&&bits.ishrn(shift),bits}function bits2octets(bits,q){bits=bits2int(bits,q),bits=bits.mod(q);var out=Buffer2.from(bits.toArray());if(out.length=q)throw new Error(\"invalid sig\")}module.exports=verify}}),require_browser8=__commonJS({\"node_modules/browserify-sign/browser/index.js\"(exports,module){var Buffer2=require_safe_buffer().Buffer,createHash=require_browser2(),inherits=require_inherits_browser(),sign=require_sign(),verify=require_verify(),algorithms=require_algorithms();Object.keys(algorithms).forEach(function(key){algorithms[key].id=Buffer2.from(algorithms[key].id,\"hex\"),algorithms[key.toLowerCase()]=algorithms[key]});function Sign(algorithm){StreamModule.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error(\"Unknown message digest\");this._hashType=data.hash,this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Sign,StreamModule.Writable),Sign.prototype._write=function(data,_,done){this._hash.update(data),done()},Sign.prototype.update=function(data,enc){return typeof data==\"string\"&&(data=Buffer2.from(data,enc)),this._hash.update(data),this},Sign.prototype.sign=function(key,enc){this.end();var hash=this._hash.digest(),sig=sign(hash,key,this._hashType,this._signType,this._tag);return enc\?sig.toString(enc):sig};function Verify(algorithm){StreamModule.Writable.call(this);var data=algorithms[algorithm];if(!data)throw new Error(\"Unknown message digest\");this._hash=createHash(data.hash),this._tag=data.id,this._signType=data.sign}inherits(Verify,StreamModule.Writable),Verify.prototype._write=function(data,_,done){this._hash.update(data),done()},Verify.prototype.update=function(data,enc){return typeof data==\"string\"&&(data=Buffer2.from(data,enc)),this._hash.update(data),this},Verify.prototype.verify=function(key,sig,enc){typeof sig==\"string\"&&(sig=Buffer2.from(sig,enc)),this.end();var hash=this._hash.digest();return verify(sig,hash,key,this._signType,this._tag)};function createSign(algorithm){return new Sign(algorithm)}function createVerify(algorithm){return new Verify(algorithm)}module.exports={Sign:createSign,Verify:createVerify,createSign,createVerify}}}),require_bn6=require_bn,require_browser9=__commonJS({\"node_modules/create-ecdh/browser.js\"(exports,module){var elliptic=require_elliptic(),BN=require_bn6();module.exports=function(curve){return new ECDH(curve)};var aliases={secp256k1:{name:\"secp256k1\",byteLength:32},secp224r1:{name:\"p224\",byteLength:28},prime256v1:{name:\"p256\",byteLength:32},prime192v1:{name:\"p192\",byteLength:24},ed25519:{name:\"ed25519\",byteLength:32},secp384r1:{name:\"p384\",byteLength:48},secp521r1:{name:\"p521\",byteLength:66}};aliases.p224=aliases.secp224r1,aliases.p256=aliases.secp256r1=aliases.prime256v1,aliases.p192=aliases.secp192r1=aliases.prime192v1,aliases.p384=aliases.secp384r1,aliases.p521=aliases.secp521r1;function ECDH(curve){this.curveType=aliases[curve],this.curveType||(this.curveType={name:curve}),this.curve=new elliptic.ec(this.curveType.name),this.keys=void 0}ECDH.prototype={},ECDH.prototype.generateKeys=function(enc,format){return this.keys=this.curve.genKeyPair(),this.getPublicKey(enc,format)},ECDH.prototype.computeSecret=function(other,inenc,enc){inenc=inenc||\"utf8\",Buffer.isBuffer(other)||(other=new Buffer(other,inenc));var otherPub=this.curve.keyFromPublic(other).getPublic(),out=otherPub.mul(this.keys.getPrivate()).getX();return formatReturnValue(out,enc,this.curveType.byteLength)},ECDH.prototype.getPublicKey=function(enc,format){var key=this.keys.getPublic(format===\"compressed\",!0);return format===\"hybrid\"&&(key[key.length-1]%2\?key[0]=7:key[0]=6),formatReturnValue(key,enc)},ECDH.prototype.getPrivateKey=function(enc){return formatReturnValue(this.keys.getPrivate(),enc)},ECDH.prototype.setPublicKey=function(pub,enc){return enc=enc||\"utf8\",Buffer.isBuffer(pub)||(pub=new Buffer(pub,enc)),this.keys._importPublic(pub),this},ECDH.prototype.setPrivateKey=function(priv,enc){enc=enc||\"utf8\",Buffer.isBuffer(priv)||(priv=new Buffer(priv,enc));var _priv=new BN(priv);return _priv=_priv.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(_priv),this};function formatReturnValue(bn,enc,len){Array.isArray(bn)||(bn=bn.toArray());var buf=new Buffer(bn);if(len&&buf.length=0)throw new Error(\"data too long for modulus\")}else throw new Error(\"unknown padding\");return reverse\?crt(paddedMsg,key):withPublic(paddedMsg,key)};function oaep(key,msg){var k=key.modulus.byteLength(),mLen=msg.length,iHash=createHash(\"sha1\").update(Buffer2.alloc(0)).digest(),hLen=iHash.length,hLen2=2*hLen;if(mLen>k-hLen2-2)throw new Error(\"message too long\");var ps=Buffer2.alloc(k-mLen-hLen2-2),dblen=k-hLen-1,seed=randomBytes(hLen),maskedDb=xor(Buffer2.concat([iHash,ps,Buffer2.alloc(1,1),msg],dblen),mgf(seed,dblen)),maskedSeed=xor(seed,mgf(maskedDb,hLen));return new BN(Buffer2.concat([Buffer2.alloc(1),maskedSeed,maskedDb],k))}function pkcs1(key,msg,reverse){var mLen=msg.length,k=key.modulus.byteLength();if(mLen>k-11)throw new Error(\"message too long\");var ps;return reverse\?ps=Buffer2.alloc(k-mLen-3,255):ps=nonZero(k-mLen-3),new BN(Buffer2.concat([Buffer2.from([0,reverse\?1:2]),ps,Buffer2.alloc(1),msg],k))}function nonZero(len){for(var out=Buffer2.allocUnsafe(len),i=0,cache=randomBytes(len*2),cur=0,num;ik||new BN(enc).cmp(key.modulus)>=0)throw new Error(\"decryption error\");var msg;reverse\?msg=withPublic(new BN(enc),key):msg=crt(enc,key);var zBuffer=Buffer2.alloc(k-msg.length);if(msg=Buffer2.concat([zBuffer,msg],k),padding===4)return oaep(key,msg);if(padding===1)return pkcs1(key,msg,reverse);if(padding===3)return msg;throw new Error(\"unknown padding\")};function oaep(key,msg){var k=key.modulus.byteLength(),iHash=createHash(\"sha1\").update(Buffer2.alloc(0)).digest(),hLen=iHash.length;if(msg[0]!==0)throw new Error(\"decryption error\");var maskedSeed=msg.slice(1,hLen+1),maskedDb=msg.slice(hLen+1),seed=xor(maskedSeed,mgf(maskedDb,hLen)),db=xor(maskedDb,mgf(seed,k-hLen-1));if(compare(iHash,db.slice(0,hLen)))throw new Error(\"decryption error\");for(var i=hLen;db[i]===0;)i++;if(db[i++]!==1)throw new Error(\"decryption error\");return db.slice(i)}function pkcs1(key,msg,reverse){for(var p1=msg.slice(0,2),i=2,status=0;msg[i++]!==0;)if(i>=msg.length){status++;break}var ps=msg.slice(2,i-1);if((p1.toString(\"hex\")!==\"0002\"&&!reverse||p1.toString(\"hex\")!==\"0001\"&&reverse)&&status++,ps.length<8&&status++,status)throw new Error(\"decryption error\");return msg.slice(i)}function compare(a,b){a=Buffer2.from(a),b=Buffer2.from(b);var dif=0,len=a.length;a.length!==b.length&&(dif++,len=Math.min(a.length,b.length));for(var i=-1;++ikMaxUint32||offset<0)@throwTypeError(\"offset must be a uint32\");if(offset>kBufferMaxLength||offset>length)@throwRangeError(\"offset out of range\")}function assertSize(size,offset,length){if(typeof size!=\"number\"||size!==size)@throwTypeError(\"size must be a number\");if(size>kMaxUint32||size<0)@throwTypeError(\"size must be a uint32\");if(size+offset>length||size>kBufferMaxLength)@throwRangeError(\"buffer too small\")}exports.randomFill=randomFill,exports.randomFillSync=randomFillSync;function randomFill(buf,offset,size,cb){if(!Buffer2.isBuffer(buf)&&!(buf instanceof global.Uint8Array))@throwTypeError('\"buf\" argument must be a Buffer or Uint8Array');if(typeof offset==\"function\")cb=offset,offset=0,size=buf.length;else if(typeof size==\"function\")cb=size,size=buf.length-offset;else if(typeof cb!=\"function\")@throwTypeError('\"cb\" argument must be a function');return assertOffset(offset,buf.length),assertSize(size,offset,buf.length),actualFill(buf,offset,size,cb)}function actualFill(buf,offset,size,cb){if(cb){randombytes(size,function(err,bytes2){if(err)return cb(err);bytes2.copy(buf,offset),cb(null,buf)});return}var bytes=randombytes(size);return bytes.copy(buf,offset),buf}function randomFillSync(buf,offset,size){if(typeof offset>\"u\"&&(offset=0),!Buffer2.isBuffer(buf)&&!(buf instanceof global.Uint8Array))@throwTypeError('\"buf\" argument must be a Buffer or Uint8Array');return assertOffset(offset,buf.length),size===void 0&&(size=buf.length-offset),assertSize(size,offset,buf.length),actualFill(buf,offset,size)}}}),require_crypto_browserify2=__commonJS({\"node_modules/crypto-browserify/index.js\"(exports){exports.randomBytes=exports.rng=exports.pseudoRandomBytes=exports.prng=require_browser(),exports.createHash=require_browser2(),exports.Hash=exports.createHash.Hash,exports.createHmac=exports.Hmac=require_browser3();var algos=require_algos(),algoKeys=Object.keys(algos),hashes=[\"sha1\",\"sha224\",\"sha256\",\"sha384\",\"sha512\",\"md5\",\"rmd160\"].concat(algoKeys);exports.getHashes=function(){return hashes};var p=require_browser4();exports.pbkdf2=p.pbkdf2,exports.pbkdf2Sync=p.pbkdf2Sync;var aes=require_browser6();exports.Cipher=aes.Cipher,exports.createCipher=aes.createCipher,exports.Cipheriv=aes.Cipheriv,exports.createCipheriv=aes.createCipheriv,exports.Decipher=aes.Decipher,exports.createDecipher=aes.createDecipher,exports.Decipheriv=aes.Decipheriv,exports.createDecipheriv=aes.createDecipheriv,exports.getCiphers=aes.getCiphers,exports.listCiphers=aes.listCiphers;var dh=require_browser7();exports.DiffieHellmanGroup=dh.DiffieHellmanGroup,exports.createDiffieHellmanGroup=dh.createDiffieHellmanGroup,exports.getDiffieHellman=dh.getDiffieHellman,exports.createDiffieHellman=dh.createDiffieHellman,exports.DiffieHellman=dh.DiffieHellman;var sign=require_browser8();exports.createSign=sign.createSign,exports.Sign=sign.Sign,exports.createVerify=sign.createVerify,exports.Verify=sign.Verify,exports.createECDH=require_browser9();var publicEncrypt=require_browser10();exports.publicEncrypt=publicEncrypt.publicEncrypt,exports.privateEncrypt=publicEncrypt.privateEncrypt,exports.publicDecrypt=publicEncrypt.publicDecrypt,exports.privateDecrypt=publicEncrypt.privateDecrypt,exports.getRandomValues=(values)=>crypto.getRandomValues(values);var rf=require_browser11();exports.randomFill=rf.randomFill,exports.randomFillSync=rf.randomFillSync,exports.createCredentials=function(){throw new Error([\"sorry, createCredentials is not implemented yet\",\"we accept pull requests\",\"https://github.com/crypto-browserify/crypto-browserify\"].join(`\n`))},exports.constants=@processBindingConstants.crypto}}),crypto_exports=require_crypto_browserify2(),DEFAULT_ENCODING=\"buffer\",getRandomValues=(array)=>crypto.getRandomValues(array),randomUUID=()=>crypto.randomUUID(),randomInt=(...args)=>crypto.randomInt(...args),timingSafeEqual=\"timingSafeEqual\"in crypto\?(a,b)=>{let{byteLength:byteLengthA}=a,{byteLength:byteLengthB}=b;if(typeof byteLengthA!=\"number\"||typeof byteLengthB!=\"number\")@throwTypeError(\"Input must be an array buffer view\");if(byteLengthA!==byteLengthB)@throwRangeError(\"Input buffers must have the same length\");return crypto.timingSafeEqual(a,b)}:void 0,scryptSync=\"scryptSync\"in crypto\?(password,salt,keylen,options)=>{let res=crypto.scryptSync(password,salt,keylen,options);return DEFAULT_ENCODING!==\"buffer\"\?new Buffer(res).toString(DEFAULT_ENCODING):new Buffer(res)}:void 0,scrypt=\"scryptSync\"in crypto\?function(password,salt,keylen,options,callback){if(typeof options==\"function\"&&(callback=options,options=void 0),typeof callback!=\"function\"){var err=@makeTypeError(\"callback must be a function\");throw err.code=\"ERR_INVALID_CALLBACK\",err}try{let result=crypto.scryptSync(password,salt,keylen,options);process.nextTick(callback,null,DEFAULT_ENCODING!==\"buffer\"\?new Buffer(result).toString(DEFAULT_ENCODING):new Buffer(result))}catch(err2){throw err2}}:void 0;timingSafeEqual&&(Object.defineProperty(timingSafeEqual,\"name\",{value:\"::bunternal::\"}),Object.defineProperty(scrypt,\"name\",{value:\"::bunternal::\"}),Object.defineProperty(scryptSync,\"name\",{value:\"::bunternal::\"}));const harcoded_curves=[\"p192\",\"p224\",\"p256\",\"p384\",\"p521\",\"curve25519\",\"ed25519\",\"secp256k1\",\"secp224r1\",\"prime256v1\",\"prime192v1\",\"ed25519\",\"secp384r1\",\"secp521r1\"];function getCurves(){return harcoded_curves}var webcrypto=crypto;__export(crypto_exports,{DEFAULT_ENCODING:()=>DEFAULT_ENCODING,getRandomValues:()=>getRandomValues,randomUUID:()=>randomUUID,randomInt:()=>randomInt,getCurves:()=>getCurves,scrypt:()=>scrypt,scryptSync:()=>scryptSync,timingSafeEqual:()=>timingSafeEqual,webcrypto:()=>webcrypto,subtle:()=>webcrypto.subtle}),$=crypto_exports;/*! safe-buffer. MIT License. Feross Aboukhadijeh */return $})\n"_s; +// + +// static constexpr ASCIILiteral NodeDgramCode = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function createSocket(){throwNotImplemented(\"node:dgram createSocket\",1630)}function Socket(){throwNotImplemented(\"node:dgram Socket\",1630)}function _createSocketHandle(){throwNotImplemented(\"node:dgram _createSocketHandle\",1630)}return $={createSocket,Socket,_createSocketHandle},hideFromStack(createSocket,Socket,_createSocketHandle),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeDiagnosticsChannelCode = "(function (){\"use strict\";const SafeMap=Map,SafeFinalizationRegistry=FinalizationRegistry,ArrayPrototypeAt=(array,index)=>array[index],ArrayPrototypeIndexOf=(array,value)=>array.indexOf(value),ArrayPrototypePush=(array,value)=>array.push(value),ArrayPrototypeSplice=(array,start,deleteCount)=>array.splice(start,deleteCount),ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectSetPrototypeOf=Object.setPrototypeOf,SymbolHasInstance=Symbol.hasInstance,ReflectApply=Reflect.apply,PromiseResolve=Promise.resolve,PromiseReject=Promise.reject,PromisePrototypeThen=(promise,onFulfilled,onRejected)=>promise.then(onFulfilled,onRejected);class WeakReference extends WeakRef{constructor(){super(...arguments)}#refs=0;get(){return this.deref()}incRef(){return++this.#refs}decRef(){return--this.#refs}}class WeakRefMap extends SafeMap{constructor(){super(...arguments)}#finalizers=new SafeFinalizationRegistry((key)=>{this.delete(key)});set(key,value){return this.#finalizers.register(value,key),super.set(key,new WeakReference(value))}get(key){return super.get(key)\?.get()}incRef(key){return super.get(key)\?.incRef()}decRef(key){return super.get(key)\?.decRef()}}function markActive(channel2){ObjectSetPrototypeOf(channel2,ActiveChannel.prototype),channel2._subscribers=[],channel2._stores=new SafeMap}function maybeMarkInactive(channel2){if(!channel2._subscribers.length&&!channel2._stores.size)ObjectSetPrototypeOf(channel2,Channel.prototype),channel2._subscribers=void 0,channel2._stores=void 0}function defaultTransform(data){return data}function wrapStoreRun(store,data,next,transform=defaultTransform){return()=>{let context;try{context=transform(data)}catch(err){return process.nextTick(()=>reportError(err)),next()}return store.run(context,next)}}class ActiveChannel{subscribe(subscription){validateFunction(subscription,\"subscription\"),ArrayPrototypePush(this._subscribers,subscription),channels.incRef(this.name)}unsubscribe(subscription){const index=ArrayPrototypeIndexOf(this._subscribers,subscription);if(index===-1)return!1;return ArrayPrototypeSplice(this._subscribers,index,1),channels.decRef(this.name),maybeMarkInactive(this),!0}bindStore(store,transform){if(!this._stores.has(store))channels.incRef(this.name);this._stores.set(store,transform)}unbindStore(store){if(!this._stores.has(store))return!1;return this._stores.delete(store),channels.decRef(this.name),maybeMarkInactive(this),!0}get hasSubscribers(){return!0}publish(data){for(let i=0;i<(this._subscribers\?.length||0);i++)try{const onMessage=this._subscribers[i];onMessage(data,this.name)}catch(err){process.nextTick(()=>reportError(err))}}runStores(data,fn,thisArg,...args){let run=()=>{return this.publish(data),ReflectApply(fn,thisArg,args)};for(let entry of this._stores.entries()){const store=entry[0],transform=entry[1];run=wrapStoreRun(store,data,run,transform)}return run()}}class Channel{constructor(name){this._subscribers=void 0,this._stores=void 0,this.name=name,channels.set(name,this)}static[SymbolHasInstance](instance){const prototype=ObjectGetPrototypeOf(instance);return prototype===Channel.prototype||prototype===ActiveChannel.prototype}subscribe(subscription){markActive(this),this.subscribe(subscription)}unsubscribe(){return!1}bindStore(store,transform){markActive(this),this.bindStore(store,transform)}unbindStore(){return!1}get hasSubscribers(){return!1}publish(){}runStores(data,fn,thisArg,...args){return ReflectApply(fn,thisArg,args)}}const channels=new WeakRefMap;function channel(name){const channel2=channels.get(name);if(channel2)return channel2;if(typeof name!==\"string\"&&typeof name!==\"symbol\")throw new ERR_INVALID_ARG_TYPE(\"channel\",[\"string\",\"symbol\"],name);return new Channel(name)}function subscribe(name,subscription){return channel(name).subscribe(subscription)}function unsubscribe(name,subscription){return channel(name).unsubscribe(subscription)}function hasSubscribers(name){const channel2=channels.get(name);if(!channel2)return!1;return channel2.hasSubscribers}const traceEvents=[\"start\",\"end\",\"asyncStart\",\"asyncEnd\",\"error\"];function assertChannel(value,name){if(!(value instanceof Channel))throw new ERR_INVALID_ARG_TYPE(name,[\"Channel\"],value)}class TracingChannel{constructor(nameOrChannels){if(typeof nameOrChannels===\"string\")this.start=channel(`tracing:${nameOrChannels}:start`),this.end=channel(`tracing:${nameOrChannels}:end`),this.asyncStart=channel(`tracing:${nameOrChannels}:asyncStart`),this.asyncEnd=channel(`tracing:${nameOrChannels}:asyncEnd`),this.error=channel(`tracing:${nameOrChannels}:error`);else if(typeof nameOrChannels===\"object\"){const{start,end,asyncStart,asyncEnd,error}=nameOrChannels;assertChannel(start,\"nameOrChannels.start\"),assertChannel(end,\"nameOrChannels.end\"),assertChannel(asyncStart,\"nameOrChannels.asyncStart\"),assertChannel(asyncEnd,\"nameOrChannels.asyncEnd\"),assertChannel(error,\"nameOrChannels.error\"),this.start=start,this.end=end,this.asyncStart=asyncStart,this.asyncEnd=asyncEnd,this.error=error}else throw new ERR_INVALID_ARG_TYPE(\"nameOrChannels\",[\"string\",\"object\",\"Channel\"],nameOrChannels)}subscribe(handlers){for(let name of traceEvents){if(!handlers[name])continue;this[name]\?.subscribe(handlers[name])}}unsubscribe(handlers){let done=!0;for(let name of traceEvents){if(!handlers[name])continue;if(!this[name]\?.unsubscribe(handlers[name]))done=!1}return done}traceSync(fn,context={},thisArg,...args){const{start,end,error}=this;return start.runStores(context,()=>{try{const result=ReflectApply(fn,thisArg,args);return context.result=result,result}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}tracePromise(fn,context={},thisArg,...args){const{start,end,asyncStart,asyncEnd,error}=this;function reject(err){return context.error=err,error.publish(context),asyncStart.publish(context),asyncEnd.publish(context),PromiseReject(err)}function resolve(result){return context.result=result,asyncStart.publish(context),asyncEnd.publish(context),result}return start.runStores(context,()=>{try{let promise=ReflectApply(fn,thisArg,args);if(!(promise instanceof Promise))promise=PromiseResolve(promise);return PromisePrototypeThen(promise,resolve,reject)}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}traceCallback(fn,position=-1,context={},thisArg,...args){const{start,end,asyncStart,asyncEnd,error}=this;function wrappedCallback(err,res){if(err)context.error=err,error.publish(context);else context.result=res;asyncStart.runStores(context,()=>{try{if(callback)return ReflectApply(callback,this,arguments)}finally{asyncEnd.publish(context)}})}const callback=ArrayPrototypeAt(args,position);if(typeof callback!==\"function\")throw new ERR_INVALID_ARG_TYPE(\"callback\",[\"function\"],callback);return ArrayPrototypeSplice(args,position,1,wrappedCallback),start.runStores(context,()=>{try{return ReflectApply(fn,thisArg,args)}catch(err){throw context.error=err,error.publish(context),err}finally{end.publish(context)}})}}function tracingChannel(nameOrChannels){return new TracingChannel(nameOrChannels)}class ERR_INVALID_ARG_TYPE extends TypeError{constructor(name,expected,actual){super(`The ${name} argument must be of type ${expected}. Received type ${typeof actual}`);this.code=\"ERR_INVALID_ARG_TYPE\"}}function validateFunction(callable,field){if(typeof callable!==\"function\")throw new ERR_INVALID_ARG_TYPE(field,\"Function\",callable);return callable}return{channel,hasSubscribers,subscribe,tracingChannel,unsubscribe,Channel}})\n"_s; +// + +// static constexpr ASCIILiteral NodeDNSCode = "(function (){\"use strict\";const dns=Bun.dns;function lookup(domain,options,callback){if(typeof options==\"function\")callback=options;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");if(typeof options==\"number\")options={family:options};dns.lookup(domain,options).then((res)=>{if(res.sort((a,b)=>a.family-b.family),options\?.all)callback(null,res.map(mapLookupAll));else{const[{address,family}]=res;callback(null,address,family)}},(error)=>{callback(error)})}function resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}function lookupService(address,port,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");callback(null,address,port)}var InternalResolver=class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype,rrtype=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(mapResolveX));break;default:callback(null,results);break}},(error)=>{callback(error)})}resolve4(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:4}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(mapResolveX))},(error)=>{callback(error)})}resolve6(hostname,options,callback){if(typeof options==\"function\")callback=options,options=null;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.lookup(hostname,{family:6}).then((addresses)=>{callback(null,options\?.ttl\?addresses:addresses.map(({address})=>address))},(error)=>{callback(error)})}resolveAny(hostname,callback){callback(null,[])}resolveCname(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCname(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveMx(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveMx(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNaptr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNaptr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveNs(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveNs(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolvePtr(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolvePtr(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSrv(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSrv(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveCaa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveCaa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveTxt(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveTxt(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}resolveSoa(hostname,callback){if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolveSoa(hostname,callback).then((results)=>{callback(null,results)},(error)=>{callback(error)})}reverse(ip,callback){callback(null,[])}setServers(servers){}};function resolve(hostname,rrtype,callback){if(typeof rrtype==\"function\")callback=rrtype;if(typeof callback!=\"function\")@throwTypeError(\"callback must be a function\");dns.resolve(hostname).then((results)=>{switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":callback(null,hostname,results.map(({address})=>address));break;default:callback(null,results);break}},(error)=>{callback(error)})}function Resolver(options){return new InternalResolver(options)}Resolver.prototype={},Object.setPrototypeOf(Resolver.prototype,InternalResolver.prototype),Object.setPrototypeOf(Resolver,InternalResolver);var{resolve,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNaptr,resolveNs,resolvePtr,resolveSoa,resolveSrv,reverse,resolveTxt}=InternalResolver.prototype;function setDefaultResultOrder(){}function setServers(){}const promisifyLookup=(res)=>{res.sort((a,b)=>a.family-b.family);const[{address,family}]=res;return{address,family}},mapLookupAll=(res)=>{const{address,family}=res;return{address,family}},promisifyLookupAll=(res)=>{return res.sort((a,b)=>a.family-b.family),res.map(mapLookupAll)},mapResolveX=(a)=>a.address,promisifyResolveX=(res)=>{return res\?.map(mapResolveX)},promises={lookup(domain,options){if(options\?.all)return dns.lookup(domain,options).then(promisifyLookupAll);return dns.lookup(domain,options).then(promisifyLookup)},lookupService(address,port){return Promise.resolve([])},resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}},resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)},resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)},resolveSrv(hostname){return dns.resolveSrv(hostname)},resolveTxt(hostname){return dns.resolveTxt(hostname)},resolveSoa(hostname){return dns.resolveSoa(hostname)},resolveNaptr(hostname){return dns.resolveNaptr(hostname)},resolveMx(hostname){return dns.resolveMx(hostname)},resolveCaa(hostname){return dns.resolveCaa(hostname)},resolveNs(hostname){return dns.resolveNs(hostname)},resolvePtr(hostname){return dns.resolvePtr(hostname)},resolveCname(hostname){return dns.resolveCname(hostname)},Resolver:class Resolver2{constructor(options){}cancel(){}getServers(){return[]}resolve(hostname,rrtype){if(typeof rrtype!==\"string\")rrtype=null;switch(rrtype\?.toLowerCase()){case\"a\":case\"aaaa\":return dns.resolve(hostname,rrtype).then(promisifyLookup);default:return dns.resolve(hostname,rrtype)}}resolve4(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:4});return dns.lookup(hostname,{family:4}).then(promisifyResolveX)}resolve6(hostname,options){if(options\?.ttl)return dns.lookup(hostname,{family:6});return dns.lookup(hostname,{family:6}).then(promisifyResolveX)}resolveAny(hostname){return Promise.resolve([])}resolveCname(hostname){return dns.resolveCname(hostname)}resolveMx(hostname){return dns.resolveMx(hostname)}resolveNaptr(hostname){return dns.resolveNaptr(hostname)}resolveNs(hostname){return dns.resolveNs(hostname)}resolvePtr(hostname){return dns.resolvePtr(hostname)}resolveSoa(hostname){return dns.resolveSoa(hostname)}resolveSrv(hostname){return dns.resolveSrv(hostname)}resolveCaa(hostname){return dns.resolveCaa(hostname)}resolveTxt(hostname){return dns.resolveTxt(hostname)}reverse(ip){return Promise.resolve([])}setServers(servers){}}};for(let key of[\"resolveAny\",\"reverse\"])promises[key]=()=>Promise.resolve(void 0);return{ADDRCONFIG:0,ALL:1,V4MAPPED:2,NODATA:\"DNS_ENODATA\",FORMERR:\"DNS_EFORMERR\",SERVFAIL:\"DNS_ESERVFAIL\",NOTFOUND:\"DNS_ENOTFOUND\",NOTIMP:\"DNS_ENOTIMP\",REFUSED:\"DNS_EREFUSED\",BADQUERY:\"DNS_EBADQUERY\",BADNAME:\"DNS_EBADNAME\",BADFAMILY:\"DNS_EBADFAMILY\",BADRESP:\"DNS_EBADRESP\",CONNREFUSED:\"DNS_ECONNREFUSED\",TIMEOUT:\"DNS_ETIMEOUT\",EOF:\"DNS_EEOF\",FILE:\"DNS_EFILE\",NOMEM:\"DNS_ENOMEM\",DESTRUCTION:\"DNS_EDESTRUCTION\",BADSTR:\"DNS_EBADSTR\",BADFLAGS:\"DNS_EBADFLAGS\",NONAME:\"DNS_ENONAME\",BADHINTS:\"DNS_EBADHINTS\",NOTINITIALIZED:\"DNS_ENOTINITIALIZED\",LOADIPHLPAPI:\"DNS_ELOADIPHLPAPI\",ADDRGETNETWORKPARAMS:\"DNS_EADDRGETNETWORKPARAMS\",CANCELLED:\"DNS_ECANCELLED\",lookup,lookupService,Resolver,setServers,setDefaultResultOrder,resolve,reverse,resolve4,resolve6,resolveAny,resolveCname,resolveCaa,resolveMx,resolveNs,resolvePtr,resolveSoa,resolveSrv,resolveTxt,resolveNaptr,promises}})\n"_s; +// + +// static constexpr ASCIILiteral NodeDNSPromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,12)||@createInternalModuleById(12)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeDomainCode = "(function (){\"use strict\";var EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),domain={};return domain.createDomain=domain.create=function(){var d=new EventEmitter;function emitError(e){d.emit(\"error\",e)}return d.add=function(emitter){emitter.on(\"error\",emitError)},d.remove=function(emitter){emitter.removeListener(\"error\",emitError)},d.bind=function(fn){return function(){var args=Array.prototype.slice.call(arguments);try{fn.apply(null,args)}catch(err){emitError(err)}}},d.intercept=function(fn){return function(err){if(err)emitError(err);else{var args=Array.prototype.slice.call(arguments,1);try{fn.apply(null,args)}catch(err2){emitError(err2)}}}},d.run=function(fn){try{fn()}catch(err){emitError(err)}return this},d.dispose=function(){return this.removeAllListeners(),this},d.enter=d.exit=function(){return this},d},domain})\n"_s; +// + +// static constexpr ASCIILiteral NodeEventsCode = "(function (){\"use strict\";const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),SymbolFor=Symbol.for,kCapture=Symbol(\"kCapture\"),kErrorMonitor=SymbolFor(\"events.errorMonitor\"),kMaxEventTargetListeners=Symbol(\"events.maxEventTargetListeners\"),kMaxEventTargetListenersWarned=Symbol(\"events.maxEventTargetListenersWarned\"),kWatermarkData=SymbolFor(\"nodejs.watermarkData\"),kRejection=SymbolFor(\"nodejs.rejection\"),captureRejectionSymbol=SymbolFor(\"nodejs.rejection\"),ArrayPrototypeSlice=Array.prototype.slice;var defaultMaxListeners=10;const EventEmitter=function EventEmitter(opts){if(this._events===void 0||this._events===this.__proto__._events)this._events={__proto__:null},this._eventsCount=0;if(this._maxListeners\?\?=void 0,this[kCapture]=opts\?.captureRejections\?Boolean(opts\?.captureRejections):EventEmitterPrototype[kCapture])this.emit=emitWithRejectionCapture},EventEmitterPrototype=EventEmitter.prototype={};EventEmitterPrototype._events=void 0,EventEmitterPrototype._eventsCount=0,EventEmitterPrototype._maxListeners=void 0,EventEmitterPrototype.setMaxListeners=function setMaxListeners(n){return validateNumber(n,\"setMaxListeners\",0),this._maxListeners=n,this},EventEmitterPrototype.getMaxListeners=function getMaxListeners(){return this._maxListeners\?\?defaultMaxListeners};function emitError(emitter,args){var{_events:events}=emitter;if(args[0]\?\?=new Error(\"Unhandled error.\"),!events)throw args[0];var errorMonitor=events[kErrorMonitor];if(errorMonitor)for(var handler of ArrayPrototypeSlice.call(errorMonitor))handler.apply(emitter,args);var handlers=events.error;if(!handlers)throw args[0];for(var handler of ArrayPrototypeSlice.call(handlers))handler.apply(emitter,args);return!0}function addCatch(emitter,promise,type,args){promise.then(void 0,function(err){process.nextTick(emitUnhandledRejectionOrErr,emitter,err,type,args)})}function emitUnhandledRejectionOrErr(emitter,err,type,args){if(typeof emitter[kRejection]===\"function\")emitter[kRejection](err,type,...args);else try{emitter[kCapture]=!1,emitter.emit(\"error\",err)}finally{emitter[kCapture]=!0}}const emitWithoutRejectionCapture=function emit(type,...args){if(type===\"error\")return emitError(this,args);var{_events:events}=this;if(events===void 0)return!1;var handlers=events[type];if(handlers===void 0)return!1;for(var handler of[...handlers])handler.apply(this,args);return!0},emitWithRejectionCapture=function emit(type,...args){if(type===\"error\")return emitError(this,args);var{_events:events}=this;if(events===void 0)return!1;var handlers=events[type];if(handlers===void 0)return!1;for(var handler of[...handlers]){var result=handler.apply(this,args);if(result!==void 0&&@isPromise(result))addCatch(this,result,type,args)}return!0};EventEmitterPrototype.emit=emitWithoutRejectionCapture,EventEmitterPrototype.addListener=function addListener(type,fn){checkListener(fn);var events=this._events;if(!events)events=this._events={__proto__:null},this._eventsCount=0;else if(events.newListener)this.emit(\"newListener\",type,fn.listener\?\?fn);var handlers=events[type];if(!handlers)events[type]=[fn],this._eventsCount++;else{handlers.push(fn);var m=this._maxListeners\?\?defaultMaxListeners;if(m>0&&handlers.length>m&&!handlers.warned)overflowWarning(this,type,handlers)}return this},EventEmitterPrototype.on=EventEmitterPrototype.addListener,EventEmitterPrototype.prependListener=function prependListener(type,fn){checkListener(fn);var events=this._events;if(!events)events=this._events={__proto__:null},this._eventsCount=0;else if(events.newListener)this.emit(\"newListener\",type,fn.listener\?\?fn);var handlers=events[type];if(!handlers)events[type]=[fn],this._eventsCount++;else{handlers.unshift(fn);var m=this._maxListeners\?\?defaultMaxListeners;if(m>0&&handlers.length>m&&!handlers.warned)overflowWarning(this,type,handlers)}return this};function overflowWarning(emitter,type,handlers){handlers.warned=!0;const warn=new Error(`Possible EventEmitter memory leak detected. ${handlers.length} ${String(type)} listeners `+`added to [${emitter.constructor.name}]. Use emitter.setMaxListeners() to increase limit`);warn.name=\"MaxListenersExceededWarning\",warn.emitter=emitter,warn.type=type,warn.count=handlers.length,process.emitWarning(warn)}function onceWrapper(type,listener,...args){this.removeListener(type,listener),listener.apply(this,args)}EventEmitterPrototype.once=function once(type,fn){checkListener(fn);const bound=onceWrapper.bind(this,type,fn);return bound.listener=fn,this.addListener(type,bound),this},EventEmitterPrototype.prependOnceListener=function prependOnceListener(type,fn){checkListener(fn);const bound=onceWrapper.bind(this,type,fn);return bound.listener=fn,this.prependListener(type,bound),this},EventEmitterPrototype.removeListener=function removeListener(type,fn){checkListener(fn);var{_events:events}=this;if(!events)return this;var handlers=events[type];if(!handlers)return this;var length=handlers.length;let position=-1;for(let i=length-1;i>=0;i--)if(handlers[i]===fn||handlers[i].listener===fn){position=i;break}if(position<0)return this;if(position===0)handlers.shift();else handlers.splice(position,1);if(handlers.length===0)delete events[type],this._eventsCount--;return this},EventEmitterPrototype.off=EventEmitterPrototype.removeListener,EventEmitterPrototype.removeAllListeners=function removeAllListeners(type){var{_events:events}=this;if(type&&events){if(events[type])delete events[type],this._eventsCount--}else this._events={__proto__:null};return this},EventEmitterPrototype.listeners=function listeners(type){var{_events:events}=this;if(!events)return[];var handlers=events[type];if(!handlers)return[];return handlers.map((x)=>x.listener\?\?x)},EventEmitterPrototype.rawListeners=function rawListeners(type){var{_events}=this;if(!_events)return[];var handlers=_events[type];if(!handlers)return[];return handlers.slice()},EventEmitterPrototype.listenerCount=function listenerCount(type){var{_events:events}=this;if(!events)return 0;return events[type]\?.length\?\?0},EventEmitterPrototype.eventNames=function eventNames(){return this._eventsCount>0\?Reflect.ownKeys(this._events):[]},EventEmitterPrototype[kCapture]=!1;function once(emitter,type,options){var signal=options\?.signal;if(validateAbortSignal(signal,\"options.signal\"),signal\?.aborted)throw new AbortError(void 0,{cause:signal\?.reason});return new Promise((resolve,reject)=>{const errorListener=(err)=>{if(emitter.removeListener(type,resolver),signal!=null)eventTargetAgnosticRemoveListener(signal,\"abort\",abortListener);reject(err)},resolver=(...args)=>{if(typeof emitter.removeListener===\"function\")emitter.removeListener(\"error\",errorListener);if(signal!=null)eventTargetAgnosticRemoveListener(signal,\"abort\",abortListener);resolve(args)};if(eventTargetAgnosticAddListener(emitter,type,resolver,{once:!0}),type!==\"error\"&&typeof emitter.once===\"function\")emitter.once(\"error\",errorListener);function abortListener(){eventTargetAgnosticRemoveListener(emitter,type,resolver),eventTargetAgnosticRemoveListener(emitter,\"error\",errorListener),reject(new AbortError(void 0,{cause:signal\?.reason}))}if(signal!=null)eventTargetAgnosticAddListener(signal,\"abort\",abortListener,{once:!0})})}function on(emitter,type,options){var{signal,close,highWatermark=Number.MAX_SAFE_INTEGER,lowWatermark=1}=options||{};throwNotImplemented(\"events.on\",2679)}function getEventListeners(emitter,type){if(emitter instanceof EventTarget)throwNotImplemented(\"getEventListeners with an EventTarget\",2678);return emitter.listeners(type)}function setMaxListeners(n,...eventTargets){validateNumber(n,\"setMaxListeners\",0);var length;if(eventTargets&&(length=eventTargets.length))for(let i=0;imax||(min!=null||max!=null)&&Number.isNaN(value))throw new ERR_OUT_OF_RANGE(name,`${min!=null\?`>= ${min}`:\"\"}${min!=null&&max!=null\?\" && \":\"\"}${max!=null\?`<= ${max}`:\"\"}`,value)}function checkListener(listener){if(typeof listener!==\"function\")@throwTypeError(\"The listener must be a function\")}let AsyncResource=null;class EventEmitterAsyncResource extends EventEmitter{triggerAsyncId;asyncResource;constructor(options){if(!AsyncResource)AsyncResource=(@getInternalField(@internalModuleRegistry,5)||@createInternalModuleById(5)).AsyncResource;var{captureRejections=!1,triggerAsyncId,name=new.target.name,requireManualDestroy}=options||{};super({captureRejections});this.triggerAsyncId=triggerAsyncId\?\?0,this.asyncResource=new AsyncResource(name,{triggerAsyncId,requireManualDestroy})}emit(...args){this.asyncResource.runInAsyncScope(()=>super.emit(...args))}emitDestroy(){this.asyncResource.emitDestroy()}}return Object.defineProperties(EventEmitter,{captureRejections:{get(){return EventEmitterPrototype[kCapture]},set(value){validateBoolean(value,\"EventEmitter.captureRejections\"),EventEmitterPrototype[kCapture]=value},enumerable:!0},defaultMaxListeners:{enumerable:!0,get:()=>{return defaultMaxListeners},set:(arg)=>{validateNumber(arg,\"defaultMaxListeners\",0),defaultMaxListeners=arg}},kMaxEventTargetListeners:{value:kMaxEventTargetListeners,enumerable:!1,configurable:!1,writable:!1},kMaxEventTargetListenersWarned:{value:kMaxEventTargetListenersWarned,enumerable:!1,configurable:!1,writable:!1}}),Object.assign(EventEmitter,{once,on,getEventListeners,setMaxListeners,EventEmitter,usingDomains:!1,captureRejectionSymbol,EventEmitterAsyncResource,errorMonitor:kErrorMonitor,setMaxListeners,init:EventEmitter,listenerCount}),EventEmitter})\n"_s; +// + +// static constexpr ASCIILiteral NodeFSCode = "(function (){\"use strict\";var $,ReadStream,WriteStream;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),promises=@getInternalField(@internalModuleRegistry,17)||@createInternalModuleById(17),Stream=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34);var fs=Bun.fs();class FSWatcher extends EventEmitter{#watcher;#listener;constructor(path,options,listener){super();if(typeof options===\"function\")listener=options,options={};else if(typeof options===\"string\")options={encoding:options};if(typeof listener!==\"function\")listener=()=>{};this.#listener=listener;try{this.#watcher=fs.watch(path,options||{},this.#onEvent.bind(this))}catch(e){if(!e.message\?.startsWith(\"FileNotFound\"))throw e;const notFound=new Error(`ENOENT: no such file or directory, watch '${path}'`);throw notFound.code=\"ENOENT\",notFound.errno=-2,notFound.path=path,notFound.syscall=\"watch\",notFound.filename=path,notFound}}#onEvent(eventType,filenameOrError){if(eventType===\"error\"||eventType===\"close\")this.emit(eventType,filenameOrError);else this.emit(\"change\",eventType,filenameOrError),this.#listener(eventType,filenameOrError)}close(){this.#watcher\?.close(),this.#watcher=null}ref(){this.#watcher\?.ref()}unref(){this.#watcher\?.unref()}}var access=function access(...args){callbackify(fs.accessSync,args)},appendFile=function appendFile(...args){callbackify(fs.appendFileSync,args)},close=function close(...args){callbackify(fs.closeSync,args)},rm=function rm(...args){callbackify(fs.rmSync,args)},rmdir=function rmdir(...args){callbackify(fs.rmdirSync,args)},copyFile=function copyFile(...args){callbackify(fs.copyFileSync,args)},exists=function exists(...args){callbackify(fs.existsSync,args)},chown=function chown(...args){callbackify(fs.chownSync,args)},chmod=function chmod(...args){callbackify(fs.chmodSync,args)},fchmod=function fchmod(...args){callbackify(fs.fchmodSync,args)},fchown=function fchown(...args){callbackify(fs.fchownSync,args)},fstat=function fstat(...args){callbackify(fs.fstatSync,args)},fsync=function fsync(...args){callbackify(fs.fsyncSync,args)},ftruncate=function ftruncate(...args){callbackify(fs.ftruncateSync,args)},futimes=function futimes(...args){callbackify(fs.futimesSync,args)},lchmod=function lchmod(...args){callbackify(fs.lchmodSync,args)},lchown=function lchown(...args){callbackify(fs.lchownSync,args)},link=function link(...args){callbackify(fs.linkSync,args)},mkdir=function mkdir(...args){callbackify(fs.mkdirSync,args)},mkdtemp=function mkdtemp(...args){callbackify(fs.mkdtempSync,args)},open=function open(...args){callbackify(fs.openSync,args)},read=function read(...args){callbackify(fs.readSync,args)},write=function write(...args){callbackify(fs.writeSync,args)},readdir=function readdir(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.readdir(...args).then((result)=>callback(null,result),callback)},readFile=function readFile(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.readFile(...args).then((result)=>callback(null,result),callback)},writeFile=function writeFile(...args){callbackify(fs.writeFileSync,args)},readlink=function readlink(...args){callbackify(fs.readlinkSync,args)},realpath=function realpath(...args){callbackify(fs.realpathSync,args)},rename=function rename(...args){callbackify(fs.renameSync,args)},lstat=function lstat(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.lstat(...args).then((result)=>callback(null,result),callback)},stat=function stat(...args){const callback=args[args.length-1];if(typeof callback!==\"function\")@throwTypeError(\"Callback must be a function\");fs.stat(...args).then((result)=>callback(null,result),callback)},symlink=function symlink(...args){callbackify(fs.symlinkSync,args)},truncate=function truncate(...args){callbackify(fs.truncateSync,args)},unlink=function unlink(...args){callbackify(fs.unlinkSync,args)},utimes=function utimes(...args){callbackify(fs.utimesSync,args)},lutimes=function lutimes(...args){callbackify(fs.lutimesSync,args)},accessSync=fs.accessSync.bind(fs),appendFileSync=fs.appendFileSync.bind(fs),closeSync=fs.closeSync.bind(fs),copyFileSync=fs.copyFileSync.bind(fs),existsSync=fs.existsSync.bind(fs),chownSync=fs.chownSync.bind(fs),chmodSync=fs.chmodSync.bind(fs),fchmodSync=fs.fchmodSync.bind(fs),fchownSync=fs.fchownSync.bind(fs),fstatSync=fs.fstatSync.bind(fs),fsyncSync=fs.fsyncSync.bind(fs),ftruncateSync=fs.ftruncateSync.bind(fs),futimesSync=fs.futimesSync.bind(fs),lchmodSync=fs.lchmodSync.bind(fs),lchownSync=fs.lchownSync.bind(fs),linkSync=fs.linkSync.bind(fs),lstatSync=fs.lstatSync.bind(fs),mkdirSync=fs.mkdirSync.bind(fs),mkdtempSync=fs.mkdtempSync.bind(fs),openSync=fs.openSync.bind(fs),readSync=fs.readSync.bind(fs),writeSync=fs.writeSync.bind(fs),readdirSync=fs.readdirSync.bind(fs),readFileSync=fs.readFileSync.bind(fs),writeFileSync=fs.writeFileSync.bind(fs),readlinkSync=fs.readlinkSync.bind(fs),realpathSync=fs.realpathSync.bind(fs),renameSync=fs.renameSync.bind(fs),statSync=fs.statSync.bind(fs),symlinkSync=fs.symlinkSync.bind(fs),truncateSync=fs.truncateSync.bind(fs),unlinkSync=fs.unlinkSync.bind(fs),utimesSync=fs.utimesSync.bind(fs),lutimesSync=fs.lutimesSync.bind(fs),rmSync=fs.rmSync.bind(fs),rmdirSync=fs.rmdirSync.bind(fs),writev=(fd,buffers,position,callback)=>{if(typeof position===\"function\")callback=position,position=null;queueMicrotask(()=>{try{var written=fs.writevSync(fd,buffers,position)}catch(e){callback(e)}callback(null,written,buffers)})},writevSync=fs.writevSync.bind(fs),readv=(fd,buffers,position,callback)=>{if(typeof position===\"function\")callback=position,position=null;queueMicrotask(()=>{try{var written=fs.readvSync(fd,buffers,position)}catch(e){callback(e)}callback(null,written,buffers)})},readvSync=fs.readvSync.bind(fs),Dirent=fs.Dirent,Stats=fs.Stats,watch=function watch(path,options,listener){return new FSWatcher(path,options,listener)};function callbackify(fsFunction,args){try{const result=fsFunction.apply(fs,args.slice(0,args.length-1)),callback=args[args.length-1];if(typeof callback===\"function\")queueMicrotask(()=>callback(null,result))}catch(e){const callback=args[args.length-1];if(typeof callback===\"function\")queueMicrotask(()=>callback(e))}}var readStreamPathFastPathSymbol=Symbol.for(\"Bun.Node.readStreamPathFastPath\");const readStreamSymbol=Symbol.for(\"Bun.NodeReadStream\"),readStreamPathOrFdSymbol=Symbol.for(\"Bun.NodeReadStreamPathOrFd\"),writeStreamSymbol=Symbol.for(\"Bun.NodeWriteStream\");var writeStreamPathFastPathSymbol=Symbol.for(\"Bun.NodeWriteStreamFastPath\"),writeStreamPathFastPathCallSymbol=Symbol.for(\"Bun.NodeWriteStreamFastPathCall\"),kIoDone=Symbol.for(\"kIoDone\"),defaultReadStreamOptions={file:void 0,fd:void 0,flags:\"r\",encoding:void 0,mode:438,autoClose:!0,emitClose:!0,start:0,end:Infinity,highWaterMark:65536,fs:{read,open:(path,flags,mode,cb)=>{var fd;try{fd=openSync(path,flags,mode)}catch(e){cb(e);return}cb(null,fd)},openSync,close},autoDestroy:!0},ReadStreamClass;ReadStream=function(InternalReadStream){ReadStreamClass=InternalReadStream,Object.defineProperty(ReadStreamClass.prototype,Symbol.toStringTag,{value:\"ReadStream\",enumerable:!1});function ReadStream2(path,options){return new InternalReadStream(path,options)}return ReadStream2.prototype=InternalReadStream.prototype,Object.defineProperty(ReadStream2,Symbol.hasInstance,{value(instance){return instance instanceof InternalReadStream}})}(class ReadStream2 extends Stream._getNativeReadableStreamPrototype(2,Stream.Readable){constructor(pathOrFd,options=defaultReadStreamOptions){if(typeof options!==\"object\"||!options)@throwTypeError(\"Expected options to be an object\");var{flags=defaultReadStreamOptions.flags,encoding=defaultReadStreamOptions.encoding,mode=defaultReadStreamOptions.mode,autoClose=defaultReadStreamOptions.autoClose,emitClose=defaultReadStreamOptions.emitClose,start=defaultReadStreamOptions.start,end=defaultReadStreamOptions.end,autoDestroy=defaultReadStreamOptions.autoClose,fs:fs2=defaultReadStreamOptions.fs,highWaterMark=defaultReadStreamOptions.highWaterMark}=options;if(pathOrFd\?.constructor\?.name===\"URL\")pathOrFd=Bun.fileURLToPath(pathOrFd);var tempThis={};if(typeof pathOrFd===\"string\"){if(pathOrFd.startsWith(\"file://\"))pathOrFd=Bun.fileURLToPath(pathOrFd);if(pathOrFd.length===0)@throwTypeError(\"Expected path to be a non-empty string\");tempThis.path=tempThis.file=tempThis[readStreamPathOrFdSymbol]=pathOrFd}else if(typeof pathOrFd===\"number\"){if(pathOrFd|=0,pathOrFd<0)@throwTypeError(\"Expected fd to be a positive integer\");tempThis.fd=tempThis[readStreamPathOrFdSymbol]=pathOrFd,tempThis.autoClose=!1}else @throwTypeError(\"Expected a path or file descriptor\");if(!tempThis.fd)tempThis.fd=fs2.openSync(pathOrFd,flags,mode);var fileRef=Bun.file(tempThis.fd),stream=fileRef.stream(),native=@direct(stream);if(!native)throw new Error(\"no native readable stream\");var{stream:ptr}=native;super(ptr,{...options,encoding,autoDestroy,autoClose,emitClose,highWaterMark});if(Object.assign(this,tempThis),this.#fileRef=fileRef,this.end=end,this._read=this.#internalRead,this.start=start,this.flags=flags,this.mode=mode,this.emitClose=emitClose,this[readStreamPathFastPathSymbol]=start===0&&end===Infinity&&autoClose&&fs2===defaultReadStreamOptions.fs&&(encoding===\"buffer\"||encoding===\"binary\"||encoding==null||encoding===\"utf-8\"||encoding===\"utf8\"),this._readableState.autoClose=autoDestroy=autoClose,this._readableState.highWaterMark=highWaterMark,start!==void 0)this.pos=start}#fileRef;#fs;file;path;fd=null;flags;mode;start;end;pos;bytesRead=0;#fileSize=-1;_read;[readStreamSymbol]=!0;[readStreamPathOrFdSymbol];[readStreamPathFastPathSymbol];_construct(callback){if(super._construct)super._construct(callback);else callback();this.emit(\"open\",this.fd),this.emit(\"ready\")}_destroy(err,cb){super._destroy(err,cb);try{var fd=this.fd;if(this[readStreamPathFastPathSymbol]=!1,!fd)cb(err);else this.#fs.close(fd,(er)=>{cb(er||err)}),this.fd=null}catch(e){throw e}}close(cb){if(typeof cb===\"function\")eos_()(this,cb);this.destroy()}push(chunk){var bytesRead=chunk\?.length\?\?0;if(bytesRead>0){this.bytesRead+=bytesRead;var currPos=this.pos;if(currPos!==void 0){if(this.bytesReadthis.end)chunk=chunk.slice(0,this.end-this.start+1);return super.push(chunk,...rest)}var end=this.end;if(end!==void 0&&this.bytesRead>end){chunk=chunk.slice(0,end-currPos+1);var[_,...rest]=arguments;return this.pos=this.bytesRead,super.push(chunk,...rest)}this.pos=this.bytesRead}}return super.push(...arguments)}#internalRead(n){var{pos,end,bytesRead,fd,encoding}=this;if(n=pos!==void 0\?Math.min(end-pos+1,n):Math.min(end-bytesRead+1,n),n<=0){this.push(null);return}if(this.#fileSize===-1&&bytesRead===0&&pos===void 0){var stat2=fstatSync(fd);if(this.#fileSize=stat2.size,this.#fileSize>0&&n>this.#fileSize)n=this.#fileSize+1}this[kIoDone]=!1;var res=super._read(n);if(@isPromise(res)){var then=res\?.then;if(then&&@isCallable(then))then(()=>{if(this[kIoDone]=!0,this.destroyed)this.emit(kIoDone)},(er)=>{this[kIoDone]=!0,this.#errorOrDestroy(er)})}else if(this[kIoDone]=!0,this.destroyed)this.emit(kIoDone),this.#errorOrDestroy(new Error(\"ERR_STREAM_PREMATURE_CLOSE\"))}#errorOrDestroy(err,sync=null){var{_readableState:r={destroyed:!1,autoDestroy:!1},_writableState:w={destroyed:!1,autoDestroy:!1}}=this;if(w\?.destroyed||r\?.destroyed)return this;if(r\?.autoDestroy||w\?.autoDestroy)this.destroy(err);else if(err)this.emit(\"error\",err)}pause(){return this[readStreamPathFastPathSymbol]=!1,super.pause()}resume(){return this[readStreamPathFastPathSymbol]=!1,super.resume()}unshift(...args){return this[readStreamPathFastPathSymbol]=!1,super.unshift(...args)}pipe(dest,pipeOpts){if(this[readStreamPathFastPathSymbol]&&(pipeOpts\?.end\?\?!0)&&this._readableState\?.pipes\?.length===0){if((writeStreamPathFastPathSymbol in dest)&&dest[writeStreamPathFastPathSymbol]){if(dest[writeStreamPathFastPathCallSymbol](this,pipeOpts))return this}}return this[readStreamPathFastPathSymbol]=!1,super.pipe(dest,pipeOpts)}});function createReadStream(path,options){return new ReadStream(path,options)}var defaultWriteStreamOptions={fd:null,start:void 0,pos:void 0,encoding:void 0,flags:\"w\",mode:438,fs:{write,close,open,openSync}},WriteStreamClass;WriteStream=function(InternalWriteStream){WriteStreamClass=InternalWriteStream,Object.defineProperty(WriteStreamClass.prototype,Symbol.toStringTag,{value:\"WritesStream\",enumerable:!1});function WriteStream2(path,options){return new InternalWriteStream(path,options)}return WriteStream2.prototype=InternalWriteStream.prototype,Object.defineProperty(WriteStream2,Symbol.hasInstance,{value(instance){return instance instanceof InternalWriteStream}})}(class WriteStream2 extends Stream.NativeWritable{constructor(path,options=defaultWriteStreamOptions){if(!options)@throwTypeError(\"Expected options to be an object\");var{fs:fs2=defaultWriteStreamOptions.fs,start=defaultWriteStreamOptions.start,flags=defaultWriteStreamOptions.flags,mode=defaultWriteStreamOptions.mode,autoClose=!0,emitClose=!1,autoDestroy=autoClose,encoding=defaultWriteStreamOptions.encoding,fd=defaultWriteStreamOptions.fd,pos=defaultWriteStreamOptions.pos}=options,tempThis={};if(typeof path===\"string\"){if(path.length===0)@throwTypeError(\"Expected a non-empty path\");if(path.startsWith(\"file:\"))path=Bun.fileURLToPath(path);tempThis.path=path,tempThis.fd=null,tempThis[writeStreamPathFastPathSymbol]=autoClose&&(start===void 0||start===0)&&fs2.write===defaultWriteStreamOptions.fs.write&&fs2.close===defaultWriteStreamOptions.fs.close}else tempThis.fd=fd,tempThis[writeStreamPathFastPathSymbol]=!1;if(!tempThis.fd)tempThis.fd=fs2.openSync(path,flags,mode);super(tempThis.fd,{...options,decodeStrings:!1,autoDestroy,emitClose,fd:tempThis});if(Object.assign(this,tempThis),typeof fs2\?.write!==\"function\")@throwTypeError(\"Expected fs.write to be a function\");if(typeof fs2\?.close!==\"function\")@throwTypeError(\"Expected fs.close to be a function\");if(typeof fs2\?.open!==\"function\")@throwTypeError(\"Expected fs.open to be a function\");if(typeof path===\"object\"&&path){if(path instanceof URL)path=Bun.fileURLToPath(path)}if(typeof path!==\"string\"&&typeof fd!==\"number\")@throwTypeError(\"Expected a path or file descriptor\");if(this.start=start,this.#fs=fs2,this.flags=flags,this.mode=mode,this.start!==void 0)this.pos=this.start;if(encoding!==defaultWriteStreamOptions.encoding){if(this.setDefaultEncoding(encoding),encoding!==\"buffer\"&&encoding!==\"utf8\"&&encoding!==\"utf-8\"&&encoding!==\"binary\")this[writeStreamPathFastPathSymbol]=!1}}get autoClose(){return this._writableState.autoDestroy}set autoClose(val){this._writableState.autoDestroy=val}destroySoon=this.end;open(){}path;fd;flags;mode;#fs;bytesWritten=0;pos;[writeStreamPathFastPathSymbol];[writeStreamSymbol]=!0;start;[writeStreamPathFastPathCallSymbol](readStream,pipeOpts){if(!this[writeStreamPathFastPathSymbol])return!1;if(this.fd!==null)return this[writeStreamPathFastPathSymbol]=!1,!1;return this[kIoDone]=!1,readStream[kIoDone]=!1,Bun.write(this[writeStreamPathFastPathSymbol],readStream[readStreamPathOrFdSymbol]).then((bytesWritten)=>{readStream[kIoDone]=this[kIoDone]=!0,this.bytesWritten+=bytesWritten,readStream.bytesRead+=bytesWritten,this.end(),readStream.close()},(err)=>{readStream[kIoDone]=this[kIoDone]=!0,this.#errorOrDestroy(err),readStream.emit(\"error\",err)})}isBunFastPathEnabled(){return this[writeStreamPathFastPathSymbol]}disableBunFastPath(){this[writeStreamPathFastPathSymbol]=!1}#handleWrite(er,bytes){if(er)return this.#errorOrDestroy(er);this.bytesWritten+=bytes}#internalClose(err,cb){this[writeStreamPathFastPathSymbol]=!1;var fd=this.fd;this.#fs.close(fd,(er)=>{this.fd=null,cb(err||er)})}_construct(callback){if(typeof this.fd===\"number\"){callback();return}callback(),this.emit(\"open\",this.fd),this.emit(\"ready\")}_destroy(err,cb){if(this.fd===null)return cb(err);if(this[kIoDone]){this.once(kIoDone,()=>this.#internalClose(err,cb));return}this.#internalClose(err,cb)}[kIoDone]=!1;close(cb){if(cb){if(this.closed){process.nextTick(cb);return}this.on(\"close\",cb)}if(!this.autoClose)this.on(\"finish\",this.destroy);this.end()}write(chunk,encoding=this._writableState.defaultEncoding,cb){if(this[writeStreamPathFastPathSymbol]=!1,typeof chunk===\"string\")chunk=Buffer.from(chunk,encoding);var native=this.pos===void 0;return this[kIoDone]=!0,super.write(chunk,encoding,native\?(err,bytes)=>{if(this[kIoDone]=!1,this.#handleWrite(err,bytes),this.emit(kIoDone),cb)!err\?cb():cb(err)}:()=>{},native)}#internalWriteSlow(chunk,encoding,cb){this.#fs.write(this.fd,chunk,0,chunk.length,this.pos,(err,bytes)=>{this[kIoDone]=!1,this.#handleWrite(err,bytes),this.emit(kIoDone),!err\?cb():cb(err)})}end(chunk,encoding,cb){var native=this.pos===void 0;return super.end(chunk,encoding,cb,native)}_write=this.#internalWriteSlow;_writev=void 0;get pending(){return this.fd===null}_destroy(err,cb){this.close(err,cb)}#errorOrDestroy(err){var{_readableState:r={destroyed:!1,autoDestroy:!1},_writableState:w={destroyed:!1,autoDestroy:!1}}=this;if(w\?.destroyed||r\?.destroyed)return this;if(r\?.autoDestroy||w\?.autoDestroy)this.destroy(err);else if(err)this.emit(\"error\",err)}});function createWriteStream(path,options){return new WriteStream(path,options)}return Object.defineProperties(fs,{createReadStream:{value:createReadStream},createWriteStream:{value:createWriteStream},ReadStream:{value:ReadStream},WriteStream:{value:WriteStream}}),realpath.native=realpath,realpathSync.native=realpathSync,$={access,accessSync,appendFile,appendFileSync,chmod,chmodSync,chown,chownSync,close,closeSync,constants:promises.constants,copyFile,copyFileSync,createReadStream,createWriteStream,Dirent,exists,existsSync,fchmod,fchmodSync,fchown,fchownSync,fstat,fstatSync,fsync,fsyncSync,ftruncate,ftruncateSync,futimes,futimesSync,lchmod,lchmodSync,lchown,lchownSync,link,linkSync,lstat,lstatSync,lutimes,lutimesSync,mkdir,mkdirSync,mkdtemp,mkdtempSync,open,openSync,promises,read,readFile,readFileSync,readSync,readdir,readdirSync,readlink,readlinkSync,realpath,realpathSync,rename,renameSync,rm,rmSync,rmdir,rmdirSync,stat,statSync,Stats,symlink,symlinkSync,truncate,truncateSync,unlink,unlinkSync,utimes,utimesSync,write,writeFile,writeFileSync,writeSync,WriteStream,ReadStream,watch,FSWatcher,writev,writevSync,readv,readvSync,[Symbol.for(\"::bunternal::\")]:{ReadStreamClass,WriteStreamClass}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeFSPromisesCode = "(function (){\"use strict\";var $;const constants=@processBindingConstants.fs;var fs=Bun.fs();const notrace=\"::bunternal::\";var promisify={[notrace]:(fsFunction)=>{return async function(...args){return await 1,fsFunction.apply(fs,args)}}}[notrace];function watch(filename,options={}){if(filename instanceof URL)@throwTypeError(\"Watch URLs are not supported yet\");else if(Buffer.isBuffer(filename))filename=filename.toString();else if(typeof filename!==\"string\")@throwTypeError(\"Expected path to be a string or Buffer\");let nextEventResolve=null;if(typeof options===\"string\")options={encoding:options};const queue=@createFIFO(),watcher=fs.watch(filename,options||{},(eventType,filename2)=>{if(queue.push({eventType,filename:filename2}),nextEventResolve){const resolve=nextEventResolve;nextEventResolve=null,resolve()}});return{[Symbol.asyncIterator](){let closed=!1;return{async next(){while(!closed){let event;while(event=queue.shift()){if(event.eventType===\"close\")return closed=!0,{value:void 0,done:!0};if(event.eventType===\"error\")throw closed=!0,event.filename;return{value:event,done:!1}}const{promise,resolve}=Promise.withResolvers();nextEventResolve=resolve,await promise}return{value:void 0,done:!0}},return(){if(!closed){if(watcher.close(),closed=!0,nextEventResolve){const resolve=nextEventResolve;nextEventResolve=null,resolve()}}return{value:void 0,done:!0}}}}}}return $={access:promisify(fs.accessSync),appendFile:promisify(fs.appendFileSync),close:promisify(fs.closeSync),copyFile:promisify(fs.copyFileSync),exists:promisify(fs.existsSync),chown:promisify(fs.chownSync),chmod:promisify(fs.chmodSync),fchmod:promisify(fs.fchmodSync),fchown:promisify(fs.fchownSync),fstat:promisify(fs.fstatSync),fsync:promisify(fs.fsyncSync),ftruncate:promisify(fs.ftruncateSync),futimes:promisify(fs.futimesSync),lchmod:promisify(fs.lchmodSync),lchown:promisify(fs.lchownSync),link:promisify(fs.linkSync),lstat:fs.lstat.bind(fs),mkdir:promisify(fs.mkdirSync),mkdtemp:promisify(fs.mkdtempSync),open:promisify(fs.openSync),read:promisify(fs.readSync),write:promisify(fs.writeSync),readdir:fs.readdir.bind(fs),readFile:fs.readFile.bind(fs),writeFile:promisify(fs.writeFileSync),readlink:promisify(fs.readlinkSync),realpath:promisify(fs.realpathSync),rename:promisify(fs.renameSync),stat:fs.stat.bind(fs),symlink:promisify(fs.symlinkSync),truncate:promisify(fs.truncateSync),unlink:promisify(fs.unlinkSync),utimes:promisify(fs.utimesSync),lutimes:promisify(fs.lutimesSync),rm:promisify(fs.rmSync),rmdir:promisify(fs.rmdirSync),writev:(fd,buffers,position)=>{return new Promise((resolve,reject)=>{try{var bytesWritten=fs.writevSync(fd,buffers,position)}catch(err){reject(err);return}resolve({bytesWritten,buffers})})},readv:(fd,buffers,position)=>{return new Promise((resolve,reject)=>{try{var bytesRead=fs.readvSync(fd,buffers,position)}catch(err){reject(err);return}resolve({bytesRead,buffers})})},constants,watch},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttpCode = "(function (){\"use strict\";var $;const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),{isTypedArray}=@requireNativeModule(\"node:util/types\"),{Duplex,Readable,Writable}=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),headerCharRegex=/[^\\t\\x20-\\x7e\\x80-\\xff]/;function checkInvalidHeaderChar(val){return RegExpPrototypeExec.call(headerCharRegex,val)!==null}const validateHeaderName=(name,label)=>{if(typeof name!==\"string\"||!name||!checkIsHttpToken(name))throw new Error(\"ERR_INVALID_HTTP_TOKEN\")},validateHeaderValue=(name,value)=>{if(value===void 0)throw new Error(\"ERR_HTTP_INVALID_HEADER_VALUE\");if(checkInvalidHeaderChar(value))throw new Error(\"ERR_INVALID_CHAR\")};function isIPv6(input){return new RegExp(\"^((\?:(\?:[0-9a-fA-F]{1,4}):){7}(\?:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){6}(\?:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){5}(\?::((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,2}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){4}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,1}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,3}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){3}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,2}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,4}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){2}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,3}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,5}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){1}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,4}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,6}|:)|(\?::((\?::(\?:[0-9a-fA-F]{1,4})){0,5}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(\?::(\?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})\?$\").test(input)}const{URL}=globalThis,globalReportError=globalThis.reportError,setTimeout=globalThis.setTimeout,fetch=Bun.fetch,nop=()=>{},kEmptyObject=Object.freeze(Object.create(null)),kOutHeaders=Symbol.for(\"kOutHeaders\"),kEndCalled=Symbol.for(\"kEndCalled\"),kAbortController=Symbol.for(\"kAbortController\"),kClearTimeout=Symbol(\"kClearTimeout\"),kCorked=Symbol.for(\"kCorked\"),searchParamsSymbol=Symbol.for(\"query\"),StringPrototypeSlice=String.prototype.slice,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeToUpperCase=String.prototype.toUpperCase,StringPrototypeIncludes=String.prototype.includes,StringPrototypeCharCodeAt=String.prototype.charCodeAt,StringPrototypeIndexOf=String.prototype.indexOf,ArrayIsArray=Array.isArray,RegExpPrototypeExec=RegExp.prototype.exec,ObjectAssign=Object.assign,ObjectPrototypeHasOwnProperty=Object.prototype.hasOwnProperty,INVALID_PATH_REGEX=/[^\\u0021-\\u00ff]/,NODE_HTTP_WARNING=\"WARN: Agent is mostly unused in Bun's implementation of http. If you see strange behavior, this is probably the cause.\";var _defaultHTTPSAgent,kInternalRequest=Symbol(\"kInternalRequest\"),kInternalSocketData=Symbol.for(\"::bunternal::\");const kEmptyBuffer=Buffer.alloc(0);function isValidTLSArray(obj){if(typeof obj===\"string\"||isTypedArray(obj)||obj instanceof ArrayBuffer||obj instanceof Blob)return!0;if(Array.isArray(obj)){for(var i=0;i{this.close()}),host=port\?.host,port=port\?.port,typeof port\?.callback===\"function\")onListen=port\?.callback}if(typeof backlog===\"function\")onListen=backlog;const ResponseClass=this.#options.ServerResponse||ServerResponse,RequestClass=this.#options.IncomingMessage||IncomingMessage;try{const tls=this.#tls;if(tls)this.serverName=tls.serverName||host||\"localhost\";this.#server=Bun.serve({tls,port,hostname:host,websocket:{open(ws){ws.data.open(ws)},message(ws,message){ws.data.message(ws,message)},close(ws,code,reason){ws.data.close(ws,code,reason)},drain(ws){ws.data.drain(ws)}},fetch(req,_server){var pendingResponse,pendingError,rejectFunction,resolveFunction,reject=(err)=>{if(pendingError)return;if(pendingError=err,rejectFunction)rejectFunction(err)},reply=function(resp){if(pendingResponse)return;if(pendingResponse=resp,resolveFunction)resolveFunction(resp)};const http_req=new RequestClass(req),http_res=new ResponseClass({reply,req:http_req});if(http_req.once(\"error\",(err)=>reject(err)),http_res.once(\"error\",(err)=>reject(err)),req.headers.get(\"upgrade\")){const socket=new FakeSocket;socket[kInternalSocketData]=[_server,http_res,req],server.emit(\"upgrade\",http_req,socket,kEmptyBuffer)}else server.emit(\"request\",http_req,http_res);if(pendingError)throw pendingError;if(pendingResponse)return pendingResponse;return new Promise((resolve,reject2)=>{resolveFunction=resolve,rejectFunction=reject2})}}),setTimeout(emitListeningNextTick,1,this,onListen,null,this.#server.hostname,this.#server.port)}catch(err){setTimeout(emitListeningNextTick,1,this,onListen,err)}return this}setTimeout(msecs,callback){}}function assignHeaders(object,req){var headers=req.headers.toJSON();const rawHeaders=@newArrayWithSize(req.headers.count*2);var i=0;for(let key in headers)rawHeaders[i++]=key,rawHeaders[i++]=headers[key];object.headers=headers,object.rawHeaders=rawHeaders}function destroyBodyStreamNT(bodyStream){bodyStream.destroy()}var defaultIncomingOpts={type:\"request\"};function getDefaultHTTPSAgent(){return _defaultHTTPSAgent\?\?=new Agent({defaultPort:443,protocol:\"https:\"})}class IncomingMessage extends Readable{method;complete;constructor(req,defaultIncomingOpts2){const method=req.method;super();const url=new URL(req.url);var{type=\"request\",[kInternalRequest]:nodeReq}=defaultIncomingOpts2||{};this.#noBody=type===\"request\"\?method===\"GET\"||method===\"HEAD\"||method===\"TRACE\"||method===\"CONNECT\"||method===\"OPTIONS\"||(parseInt(req.headers.get(\"Content-Length\")||\"\")||0)===0:!1,this.#req=req,this.method=method,this.#type=type,this.complete=!!this.#noBody,this.#bodyStream=void 0;const socket=new FakeSocket;socket.remoteAddress=url.hostname,socket.remotePort=url.port,this.#fakeSocket=socket,this.url=url.pathname+url.search,this.#nodeReq=nodeReq,assignHeaders(this,req)}headers;rawHeaders;_consuming=!1;_dumped=!1;#bodyStream;#fakeSocket;#noBody=!1;#aborted=!1;#req;url;#type;#nodeReq;get req(){return this.#nodeReq}_construct(callback){if(this.#type===\"response\"||this.#noBody){callback();return}const contentLength=this.#req.headers.get(\"content-length\");if((contentLength\?parseInt(contentLength,10):0)===0){this.#noBody=!0,callback();return}callback()}async#consumeStream(reader){while(!0){var{done,value}=await reader.readMany();if(this.#aborted)return;if(done){this.push(null),this.destroy();break}for(var v of value)this.push(v)}}_read(size){if(this.#noBody)this.push(null),this.complete=!0;else if(this.#bodyStream==null){const reader=this.#req.body\?.getReader();if(!reader){this.push(null);return}this.#bodyStream=reader,this.#consumeStream(reader)}}get aborted(){return this.#aborted}#abort(){if(this.#aborted)return;this.#aborted=!0;var bodyStream=this.#bodyStream;if(!bodyStream)return;bodyStream.cancel(),this.complete=!0,this.#bodyStream=void 0,this.push(null)}get connection(){return this.#fakeSocket}get statusCode(){return this.#req.status}get statusMessage(){return STATUS_CODES[this.#req.status]}get httpVersion(){return\"1.1\"}get rawTrailers(){return[]}get httpVersionMajor(){return 1}get httpVersionMinor(){return 1}get trailers(){return kEmptyObject}get socket(){return this.#fakeSocket\?\?=new FakeSocket}set socket(val){this.#fakeSocket=val}setTimeout(msecs,callback){throw new Error(\"not implemented\")}}function emitErrorNt(msg,err,callback){if(callback(err),typeof msg.emit===\"function\"&&!msg._closed)msg.emit(\"error\",err)}function onError(self,err,cb){process.nextTick(()=>emitErrorNt(self,err,cb))}function write_(msg,chunk,encoding,callback,fromEnd){if(typeof callback!==\"function\")callback=nop;let len;if(chunk===null)throw new Error(\"ERR_STREAM_NULL_VALUES\");else if(typeof chunk===\"string\")len=Buffer.byteLength(chunk,encoding);else throw new Error(\"Invalid arg type for chunk\");let err;if(msg.finished)err=new Error(\"ERR_STREAM_WRITE_AFTER_END\");else if(msg.destroyed)err=new Error(\"ERR_STREAM_DESTROYED\");if(err){if(!msg.destroyed)onError(msg,err,callback);else process.nextTick(callback,err);return!1}if(!msg._header){if(fromEnd)msg._contentLength=len}if(!msg._hasBody)return process.nextTick(callback),!0;return!0}class OutgoingMessage extends Writable{constructor(){super(...arguments)}#headers;headersSent=!1;sendDate=!0;req;timeout;#finished=!1;[kEndCalled]=!1;#fakeSocket;#timeoutTimer;[kAbortController]=null;_implicitHeader(){}get headers(){if(!this.#headers)return kEmptyObject;return this.#headers.toJSON()}get shouldKeepAlive(){return!0}get chunkedEncoding(){return!1}set chunkedEncoding(value){}set shouldKeepAlive(value){}get useChunkedEncodingByDefault(){return!0}set useChunkedEncodingByDefault(value){}get socket(){return this.#fakeSocket\?\?=new FakeSocket}set socket(val){this.#fakeSocket=val}get connection(){return this.socket}get finished(){return this.#finished}appendHeader(name,value){var headers=this.#headers\?\?=new Headers;headers.append(name,value)}flushHeaders(){}getHeader(name){return getHeader(this.#headers,name)}getHeaders(){if(!this.#headers)return kEmptyObject;return this.#headers.toJSON()}getHeaderNames(){var headers=this.#headers;if(!headers)return[];return Array.from(headers.keys())}removeHeader(name){if(!this.#headers)return;this.#headers.delete(name)}setHeader(name,value){var headers=this.#headers\?\?=new Headers;return headers.set(name,value),this}hasHeader(name){if(!this.#headers)return!1;return this.#headers.has(name)}addTrailers(headers){throw new Error(\"not implemented\")}[kClearTimeout](){if(this.#timeoutTimer)clearTimeout(this.#timeoutTimer),this.removeAllListeners(\"timeout\"),this.#timeoutTimer=void 0}#onTimeout(){this.#timeoutTimer=void 0,this[kAbortController]\?.abort(),this.emit(\"timeout\")}setTimeout(msecs,callback){if(this.destroyed)return this;if(this.timeout=msecs=validateMsecs(msecs,\"msecs\"),clearTimeout(this.#timeoutTimer),msecs===0){if(callback!==void 0)validateFunction(callback,\"callback\"),this.removeListener(\"timeout\",callback);this.#timeoutTimer=void 0}else if(this.#timeoutTimer=setTimeout(this.#onTimeout.bind(this),msecs).unref(),callback!==void 0)validateFunction(callback,\"callback\"),this.once(\"timeout\",callback);return this}}let OriginalWriteHeadFn,OriginalImplicitHeadFn;class ServerResponse extends Writable{constructor({req,reply}){super();if(this.req=req,this._reply=reply,this.sendDate=!0,this.statusCode=200,this.headersSent=!1,this.statusMessage=void 0,this.#controller=void 0,this.#firstWrite=void 0,this._writableState.decodeStrings=!1,this.#deferred=void 0,req.method===\"HEAD\")this._hasBody=!1}req;_reply;sendDate;statusCode;#headers;headersSent=!1;statusMessage;#controller;#firstWrite;_sent100=!1;_defaultKeepAlive=!1;_removedConnection=!1;_removedContLen=!1;_hasBody=!0;#deferred=void 0;#finished=!1;_implicitHeader(){this.writeHead(this.statusCode)}_write(chunk,encoding,callback){if(!this.#firstWrite&&!this.headersSent){this.#firstWrite=chunk,callback();return}this.#ensureReadableStreamController((controller)=>{controller.write(chunk),callback()})}_writev(chunks,callback){if(chunks.length===1&&!this.headersSent&&!this.#firstWrite){this.#firstWrite=chunks[0].chunk,callback();return}this.#ensureReadableStreamController((controller)=>{for(let chunk of chunks)controller.write(chunk.chunk);callback()})}#ensureReadableStreamController(run){var thisController=this.#controller;if(thisController)return run(thisController);this.headersSent=!0;var firstWrite=this.#firstWrite;this.#firstWrite=void 0,this._reply(new Response(new ReadableStream({type:\"direct\",pull:(controller)=>{if(this.#controller=controller,firstWrite)controller.write(firstWrite);if(firstWrite=void 0,run(controller),!this.#finished)return new Promise((resolve)=>{this.#deferred=resolve})}}),{headers:this.#headers,status:this.statusCode,statusText:this.statusMessage\?\?STATUS_CODES[this.statusCode]}))}#drainHeadersIfObservable(){if(this._implicitHeader===OriginalImplicitHeadFn&&this.writeHead===OriginalWriteHeadFn)return;this._implicitHeader()}_final(callback){if(!this.headersSent){var data=this.#firstWrite||\"\";this.#firstWrite=void 0,this.#finished=!0,this.#drainHeadersIfObservable(),this._reply(new Response(data,{headers:this.#headers,status:this.statusCode,statusText:this.statusMessage\?\?STATUS_CODES[this.statusCode]})),callback&&callback();return}this.#finished=!0,this.#ensureReadableStreamController((controller)=>{controller.end(),callback();var deferred=this.#deferred;if(deferred)this.#deferred=void 0,deferred()})}writeProcessing(){throw new Error(\"not implemented\")}addTrailers(headers){throw new Error(\"not implemented\")}assignSocket(socket){throw new Error(\"not implemented\")}detachSocket(socket){throw new Error(\"not implemented\")}writeContinue(callback){throw new Error(\"not implemented\")}setTimeout(msecs,callback){throw new Error(\"not implemented\")}get shouldKeepAlive(){return!0}get chunkedEncoding(){return!1}set chunkedEncoding(value){}set shouldKeepAlive(value){}get useChunkedEncodingByDefault(){return!0}set useChunkedEncodingByDefault(value){}appendHeader(name,value){var headers=this.#headers\?\?=new Headers;headers.append(name,value)}flushHeaders(){}getHeader(name){return getHeader(this.#headers,name)}getHeaders(){var headers=this.#headers;if(!headers)return kEmptyObject;return headers.toJSON()}getHeaderNames(){var headers=this.#headers;if(!headers)return[];return Array.from(headers.keys())}removeHeader(name){if(!this.#headers)return;this.#headers.delete(name)}setHeader(name,value){var headers=this.#headers\?\?=new Headers;return headers.set(name,value),this}hasHeader(name){if(!this.#headers)return!1;return this.#headers.has(name)}writeHead(statusCode,statusMessage,headers){return _writeHead(statusCode,statusMessage,headers,this),this}}OriginalWriteHeadFn=ServerResponse.prototype.writeHead,OriginalImplicitHeadFn=ServerResponse.prototype._implicitHeader;class ClientRequest extends OutgoingMessage{#timeout;#res=null;#upgradeOrConnect=!1;#parser=null;#maxHeadersCount=null;#reusedSocket=!1;#host;#protocol;#method;#port;#useDefaultPort;#joinDuplicateHeaders;#maxHeaderSize;#agent=globalAgent;#path;#socketPath;#bodyChunks=null;#fetchRequest;#signal=null;[kAbortController]=null;#timeoutTimer=void 0;#options;#finished;get path(){return this.#path}get port(){return this.#port}get method(){return this.#method}get host(){return this.#host}get protocol(){return this.#protocol}_write(chunk,encoding,callback){if(!this.#bodyChunks){this.#bodyChunks=[chunk],callback();return}this.#bodyChunks.push(chunk),callback()}_writev(chunks,callback){if(!this.#bodyChunks){this.#bodyChunks=chunks,callback();return}this.#bodyChunks.push(...chunks),callback()}_final(callback){if(this.#finished=!0,this[kAbortController]=new AbortController,this[kAbortController].signal.addEventListener(\"abort\",()=>{this[kClearTimeout]()}),this.#signal\?.aborted)this[kAbortController].abort();var method=this.#method,body=Buffer.concat(this.#bodyChunks||[]);try{this.#fetchRequest=fetch(`${this.#protocol}//${this.#host}${this.#useDefaultPort\?\"\":\":\"+this.#port}${this.#path}`,{method,headers:this.getHeaders(),body:body&&method!==\"GET\"&&method!==\"HEAD\"&&method!==\"OPTIONS\"\?body:void 0,redirect:\"manual\",verbose:!1,signal:this[kAbortController].signal,timeout:!1}).then((response)=>{var res=this.#res=new IncomingMessage(response,{type:\"response\",[kInternalRequest]:this});this.emit(\"response\",res)}).catch((err)=>{this.emit(\"error\",err)}).finally(()=>{this.#fetchRequest=null,this[kClearTimeout]()})}catch(err){this.emit(\"error\",err)}finally{callback()}}get aborted(){return this.#signal\?.aborted||!!this[kAbortController]\?.signal.aborted}abort(){if(this.aborted)return;this[kAbortController].abort()}constructor(input,options,cb){super();if(typeof input===\"string\"){const urlStr=input;try{var urlObject=new URL(urlStr)}catch(e){@throwTypeError(`Invalid URL: ${urlStr}`)}input=urlToHttpOptions(urlObject)}else if(input&&typeof input===\"object\"&&input instanceof URL)input=urlToHttpOptions(input);else cb=options,options=input,input=null;if(typeof options===\"function\")cb=options,options=input||kEmptyObject;else options=ObjectAssign(input||{},options);var defaultAgent=options._defaultAgent||Agent.globalAgent;let protocol=options.protocol;if(!protocol)if(options.port===443)protocol=\"https:\";else protocol=defaultAgent.protocol||\"http:\";switch(this.#protocol=protocol,this.#agent\?.protocol){case void 0:break;case\"http:\":if(protocol===\"https:\"){defaultAgent=this.#agent=getDefaultHTTPSAgent();break}case\"https:\":if(protocol===\"https\"){defaultAgent=this.#agent=Agent.globalAgent;break}default:break}if(options.path){const path=String(options.path);if(RegExpPrototypeExec.call(INVALID_PATH_REGEX,path)!==null)throw new Error(\"Path contains unescaped characters\")}if(protocol!==\"http:\"&&protocol!==\"https:\"&&protocol){const expectedProtocol=defaultAgent\?.protocol\?\?\"http:\";throw new Error(`Protocol mismatch. Expected: ${expectedProtocol}. Got: ${protocol}`)}const defaultPort=protocol===\"https:\"\?443:80;this.#port=options.port||options.defaultPort||this.#agent\?.defaultPort||defaultPort,this.#useDefaultPort=this.#port===defaultPort;const host=this.#host=options.host=validateHost(options.hostname,\"hostname\")||validateHost(options.host,\"host\")||\"localhost\";this.#socketPath=options.socketPath;const signal=options.signal;if(signal)signal.addEventListener(\"abort\",()=>{this[kAbortController]\?.abort()}),this.#signal=signal;let method=options.method;const methodIsString=typeof method===\"string\";if(method!==null&&method!==void 0&&!methodIsString)throw new Error(\"ERR_INVALID_ARG_TYPE: options.method\");if(methodIsString&&method){if(!checkIsHttpToken(method))throw new Error(\"ERR_INVALID_HTTP_TOKEN: Method\");method=this.#method=StringPrototypeToUpperCase.call(method)}else method=this.#method=\"GET\";const _maxHeaderSize=options.maxHeaderSize;this.#maxHeaderSize=_maxHeaderSize;var _joinDuplicateHeaders=options.joinDuplicateHeaders;if(this.#joinDuplicateHeaders=_joinDuplicateHeaders,this.#path=options.path||\"/\",cb)this.once(\"response\",cb);this.#finished=!1,this.#res=null,this.#upgradeOrConnect=!1,this.#parser=null,this.#maxHeadersCount=null,this.#reusedSocket=!1,this.#host=host,this.#protocol=protocol;var timeout=options.timeout;if(timeout!==void 0&&timeout!==0)this.setTimeout(timeout,void 0);if(!ArrayIsArray(headers)){var headers=options.headers;if(headers)for(let key in headers)this.setHeader(key,headers[key]);var auth=options.auth;if(auth&&!this.getHeader(\"Authorization\"))this.setHeader(\"Authorization\",\"Basic \"+Buffer.from(auth).toString(\"base64\"))}var{signal:_signal,...optsWithoutSignal}=options;this.#options=optsWithoutSignal}setSocketKeepAlive(enable=!0,initialDelay=0){}setNoDelay(noDelay=!0){}[kClearTimeout](){if(this.#timeoutTimer)clearTimeout(this.#timeoutTimer),this.#timeoutTimer=void 0,this.removeAllListeners(\"timeout\")}#onTimeout(){this.#timeoutTimer=void 0,this[kAbortController]\?.abort(),this.emit(\"timeout\")}setTimeout(msecs,callback){if(this.destroyed)return this;if(this.timeout=msecs=validateMsecs(msecs,\"msecs\"),clearTimeout(this.#timeoutTimer),msecs===0){if(callback!==void 0)validateFunction(callback,\"callback\"),this.removeListener(\"timeout\",callback);this.#timeoutTimer=void 0}else if(this.#timeoutTimer=setTimeout(this.#onTimeout.bind(this),msecs).unref(),callback!==void 0)validateFunction(callback,\"callback\"),this.once(\"timeout\",callback);return this}}function urlToHttpOptions(url){var{protocol,hostname,hash,search,pathname,href,port,username,password}=url;return{protocol,hostname:typeof hostname===\"string\"&&StringPrototypeStartsWith.call(hostname,\"[\")\?StringPrototypeSlice.call(hostname,1,-1):hostname,hash,search,pathname,path:`${pathname||\"\"}${search||\"\"}`,href,port:port\?Number(port):protocol===\"https:\"\?443:protocol===\"http:\"\?80:void 0,auth:username||password\?`${decodeURIComponent(username)}:${decodeURIComponent(password)}`:void 0}}function validateHost(host,name){if(host!==null&&host!==void 0&&typeof host!==\"string\")throw new Error(\"Invalid arg type in options\");return host}const tokenRegExp=/^[\\^_`a-zA-Z\\-0-9!#$%&'*+.|~]+$/;function checkIsHttpToken(val){return RegExpPrototypeExec.call(tokenRegExp,val)!==null}const METHODS=[\"ACL\",\"BIND\",\"CHECKOUT\",\"CONNECT\",\"COPY\",\"DELETE\",\"GET\",\"HEAD\",\"LINK\",\"LOCK\",\"M-SEARCH\",\"MERGE\",\"MKACTIVITY\",\"MKCALENDAR\",\"MKCOL\",\"MOVE\",\"NOTIFY\",\"OPTIONS\",\"PATCH\",\"POST\",\"PROPFIND\",\"PROPPATCH\",\"PURGE\",\"PUT\",\"REBIND\",\"REPORT\",\"SEARCH\",\"SOURCE\",\"SUBSCRIBE\",\"TRACE\",\"UNBIND\",\"UNLINK\",\"UNLOCK\",\"UNSUBSCRIBE\"],STATUS_CODES={100:\"Continue\",101:\"Switching Protocols\",102:\"Processing\",103:\"Early Hints\",200:\"OK\",201:\"Created\",202:\"Accepted\",203:\"Non-Authoritative Information\",204:\"No Content\",205:\"Reset Content\",206:\"Partial Content\",207:\"Multi-Status\",208:\"Already Reported\",226:\"IM Used\",300:\"Multiple Choices\",301:\"Moved Permanently\",302:\"Found\",303:\"See Other\",304:\"Not Modified\",305:\"Use Proxy\",307:\"Temporary Redirect\",308:\"Permanent Redirect\",400:\"Bad Request\",401:\"Unauthorized\",402:\"Payment Required\",403:\"Forbidden\",404:\"Not Found\",405:\"Method Not Allowed\",406:\"Not Acceptable\",407:\"Proxy Authentication Required\",408:\"Request Timeout\",409:\"Conflict\",410:\"Gone\",411:\"Length Required\",412:\"Precondition Failed\",413:\"Payload Too Large\",414:\"URI Too Long\",415:\"Unsupported Media Type\",416:\"Range Not Satisfiable\",417:\"Expectation Failed\",418:\"I'm a Teapot\",421:\"Misdirected Request\",422:\"Unprocessable Entity\",423:\"Locked\",424:\"Failed Dependency\",425:\"Too Early\",426:\"Upgrade Required\",428:\"Precondition Required\",429:\"Too Many Requests\",431:\"Request Header Fields Too Large\",451:\"Unavailable For Legal Reasons\",500:\"Internal Server Error\",501:\"Not Implemented\",502:\"Bad Gateway\",503:\"Service Unavailable\",504:\"Gateway Timeout\",505:\"HTTP Version Not Supported\",506:\"Variant Also Negotiates\",507:\"Insufficient Storage\",508:\"Loop Detected\",509:\"Bandwidth Limit Exceeded\",510:\"Not Extended\",511:\"Network Authentication Required\"};function _normalizeArgs(args){let arr;if(args.length===0)return arr=[{},null],arr;const arg0=args[0];let options={};if(typeof arg0===\"object\"&&arg0!==null)options=arg0;else if(options.port=arg0,args.length>1&&typeof args[1]===\"string\")options.host=args[1];const cb=args[args.length-1];if(typeof cb!==\"function\")arr=[options,null];else arr=[options,cb];return arr}function _writeHead(statusCode,reason,obj,response){if(statusCode|=0,statusCode<100||statusCode>999)throw new Error(\"status code must be between 100 and 999\");if(typeof reason===\"string\")response.statusMessage=reason;else{if(!response.statusMessage)response.statusMessage=STATUS_CODES[statusCode]||\"unknown\";obj=reason}response.statusCode=statusCode;{let k;if(Array.isArray(obj)){if(obj.length%2!==0)throw new Error(\"raw headers must have an even number of elements\");for(let n=0;n=100&&statusCode<=199)response._hasBody=!1}function request(url,options,cb){return new ClientRequest(url,options,cb)}function get(url,options,cb){const req=request(url,options,cb);return req.end(),req}var globalAgent=new Agent;return $={Agent,Server,METHODS,STATUS_CODES,createServer,ServerResponse,IncomingMessage,request,get,maxHeaderSize:16384,validateHeaderName,validateHeaderValue,setMaxIdleHTTPParsers(max){},globalAgent,ClientRequest,OutgoingMessage},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttp2Code = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function connect(){throwNotImplemented(\"node:http2 connect\",887)}const constants={NGHTTP2_ERR_FRAME_SIZE_ERROR:-522,NGHTTP2_SESSION_SERVER:0,NGHTTP2_SESSION_CLIENT:1,NGHTTP2_STREAM_STATE_IDLE:1,NGHTTP2_STREAM_STATE_OPEN:2,NGHTTP2_STREAM_STATE_RESERVED_LOCAL:3,NGHTTP2_STREAM_STATE_RESERVED_REMOTE:4,NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL:5,NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE:6,NGHTTP2_STREAM_STATE_CLOSED:7,NGHTTP2_FLAG_NONE:0,NGHTTP2_FLAG_END_STREAM:1,NGHTTP2_FLAG_END_HEADERS:4,NGHTTP2_FLAG_ACK:1,NGHTTP2_FLAG_PADDED:8,NGHTTP2_FLAG_PRIORITY:32,DEFAULT_SETTINGS_HEADER_TABLE_SIZE:4096,DEFAULT_SETTINGS_ENABLE_PUSH:1,DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS:4294967295,DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE:65535,DEFAULT_SETTINGS_MAX_FRAME_SIZE:16384,DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE:65535,DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL:0,MAX_MAX_FRAME_SIZE:16777215,MIN_MAX_FRAME_SIZE:16384,MAX_INITIAL_WINDOW_SIZE:2147483647,NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:1,NGHTTP2_SETTINGS_ENABLE_PUSH:2,NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS:3,NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:4,NGHTTP2_SETTINGS_MAX_FRAME_SIZE:5,NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:6,NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL:8,PADDING_STRATEGY_NONE:0,PADDING_STRATEGY_ALIGNED:1,PADDING_STRATEGY_MAX:2,PADDING_STRATEGY_CALLBACK:1,NGHTTP2_NO_ERROR:0,NGHTTP2_PROTOCOL_ERROR:1,NGHTTP2_INTERNAL_ERROR:2,NGHTTP2_FLOW_CONTROL_ERROR:3,NGHTTP2_SETTINGS_TIMEOUT:4,NGHTTP2_STREAM_CLOSED:5,NGHTTP2_FRAME_SIZE_ERROR:6,NGHTTP2_REFUSED_STREAM:7,NGHTTP2_CANCEL:8,NGHTTP2_COMPRESSION_ERROR:9,NGHTTP2_CONNECT_ERROR:10,NGHTTP2_ENHANCE_YOUR_CALM:11,NGHTTP2_INADEQUATE_SECURITY:12,NGHTTP2_HTTP_1_1_REQUIRED:13,NGHTTP2_DEFAULT_WEIGHT:16,HTTP2_HEADER_STATUS:\":status\",HTTP2_HEADER_METHOD:\":method\",HTTP2_HEADER_AUTHORITY:\":authority\",HTTP2_HEADER_SCHEME:\":scheme\",HTTP2_HEADER_PATH:\":path\",HTTP2_HEADER_PROTOCOL:\":protocol\",HTTP2_HEADER_ACCEPT_ENCODING:\"accept-encoding\",HTTP2_HEADER_ACCEPT_LANGUAGE:\"accept-language\",HTTP2_HEADER_ACCEPT_RANGES:\"accept-ranges\",HTTP2_HEADER_ACCEPT:\"accept\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS:\"access-control-allow-credentials\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS:\"access-control-allow-headers\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS:\"access-control-allow-methods\",HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN:\"access-control-allow-origin\",HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS:\"access-control-expose-headers\",HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS:\"access-control-request-headers\",HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD:\"access-control-request-method\",HTTP2_HEADER_AGE:\"age\",HTTP2_HEADER_AUTHORIZATION:\"authorization\",HTTP2_HEADER_CACHE_CONTROL:\"cache-control\",HTTP2_HEADER_CONNECTION:\"connection\",HTTP2_HEADER_CONTENT_DISPOSITION:\"content-disposition\",HTTP2_HEADER_CONTENT_ENCODING:\"content-encoding\",HTTP2_HEADER_CONTENT_LENGTH:\"content-length\",HTTP2_HEADER_CONTENT_TYPE:\"content-type\",HTTP2_HEADER_COOKIE:\"cookie\",HTTP2_HEADER_DATE:\"date\",HTTP2_HEADER_ETAG:\"etag\",HTTP2_HEADER_FORWARDED:\"forwarded\",HTTP2_HEADER_HOST:\"host\",HTTP2_HEADER_IF_MODIFIED_SINCE:\"if-modified-since\",HTTP2_HEADER_IF_NONE_MATCH:\"if-none-match\",HTTP2_HEADER_IF_RANGE:\"if-range\",HTTP2_HEADER_LAST_MODIFIED:\"last-modified\",HTTP2_HEADER_LINK:\"link\",HTTP2_HEADER_LOCATION:\"location\",HTTP2_HEADER_RANGE:\"range\",HTTP2_HEADER_REFERER:\"referer\",HTTP2_HEADER_SERVER:\"server\",HTTP2_HEADER_SET_COOKIE:\"set-cookie\",HTTP2_HEADER_STRICT_TRANSPORT_SECURITY:\"strict-transport-security\",HTTP2_HEADER_TRANSFER_ENCODING:\"transfer-encoding\",HTTP2_HEADER_TE:\"te\",HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS:\"upgrade-insecure-requests\",HTTP2_HEADER_UPGRADE:\"upgrade\",HTTP2_HEADER_USER_AGENT:\"user-agent\",HTTP2_HEADER_VARY:\"vary\",HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS:\"x-content-type-options\",HTTP2_HEADER_X_FRAME_OPTIONS:\"x-frame-options\",HTTP2_HEADER_KEEP_ALIVE:\"keep-alive\",HTTP2_HEADER_PROXY_CONNECTION:\"proxy-connection\",HTTP2_HEADER_X_XSS_PROTECTION:\"x-xss-protection\",HTTP2_HEADER_ALT_SVC:\"alt-svc\",HTTP2_HEADER_CONTENT_SECURITY_POLICY:\"content-security-policy\",HTTP2_HEADER_EARLY_DATA:\"early-data\",HTTP2_HEADER_EXPECT_CT:\"expect-ct\",HTTP2_HEADER_ORIGIN:\"origin\",HTTP2_HEADER_PURPOSE:\"purpose\",HTTP2_HEADER_TIMING_ALLOW_ORIGIN:\"timing-allow-origin\",HTTP2_HEADER_X_FORWARDED_FOR:\"x-forwarded-for\",HTTP2_HEADER_PRIORITY:\"priority\",HTTP2_HEADER_ACCEPT_CHARSET:\"accept-charset\",HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE:\"access-control-max-age\",HTTP2_HEADER_ALLOW:\"allow\",HTTP2_HEADER_CONTENT_LANGUAGE:\"content-language\",HTTP2_HEADER_CONTENT_LOCATION:\"content-location\",HTTP2_HEADER_CONTENT_MD5:\"content-md5\",HTTP2_HEADER_CONTENT_RANGE:\"content-range\",HTTP2_HEADER_DNT:\"dnt\",HTTP2_HEADER_EXPECT:\"expect\",HTTP2_HEADER_EXPIRES:\"expires\",HTTP2_HEADER_FROM:\"from\",HTTP2_HEADER_IF_MATCH:\"if-match\",HTTP2_HEADER_IF_UNMODIFIED_SINCE:\"if-unmodified-since\",HTTP2_HEADER_MAX_FORWARDS:\"max-forwards\",HTTP2_HEADER_PREFER:\"prefer\",HTTP2_HEADER_PROXY_AUTHENTICATE:\"proxy-authenticate\",HTTP2_HEADER_PROXY_AUTHORIZATION:\"proxy-authorization\",HTTP2_HEADER_REFRESH:\"refresh\",HTTP2_HEADER_RETRY_AFTER:\"retry-after\",HTTP2_HEADER_TRAILER:\"trailer\",HTTP2_HEADER_TK:\"tk\",HTTP2_HEADER_VIA:\"via\",HTTP2_HEADER_WARNING:\"warning\",HTTP2_HEADER_WWW_AUTHENTICATE:\"www-authenticate\",HTTP2_HEADER_HTTP2_SETTINGS:\"http2-settings\",HTTP2_METHOD_ACL:\"ACL\",HTTP2_METHOD_BASELINE_CONTROL:\"BASELINE-CONTROL\",HTTP2_METHOD_BIND:\"BIND\",HTTP2_METHOD_CHECKIN:\"CHECKIN\",HTTP2_METHOD_CHECKOUT:\"CHECKOUT\",HTTP2_METHOD_CONNECT:\"CONNECT\",HTTP2_METHOD_COPY:\"COPY\",HTTP2_METHOD_DELETE:\"DELETE\",HTTP2_METHOD_GET:\"GET\",HTTP2_METHOD_HEAD:\"HEAD\",HTTP2_METHOD_LABEL:\"LABEL\",HTTP2_METHOD_LINK:\"LINK\",HTTP2_METHOD_LOCK:\"LOCK\",HTTP2_METHOD_MERGE:\"MERGE\",HTTP2_METHOD_MKACTIVITY:\"MKACTIVITY\",HTTP2_METHOD_MKCALENDAR:\"MKCALENDAR\",HTTP2_METHOD_MKCOL:\"MKCOL\",HTTP2_METHOD_MKREDIRECTREF:\"MKREDIRECTREF\",HTTP2_METHOD_MKWORKSPACE:\"MKWORKSPACE\",HTTP2_METHOD_MOVE:\"MOVE\",HTTP2_METHOD_OPTIONS:\"OPTIONS\",HTTP2_METHOD_ORDERPATCH:\"ORDERPATCH\",HTTP2_METHOD_PATCH:\"PATCH\",HTTP2_METHOD_POST:\"POST\",HTTP2_METHOD_PRI:\"PRI\",HTTP2_METHOD_PROPFIND:\"PROPFIND\",HTTP2_METHOD_PROPPATCH:\"PROPPATCH\",HTTP2_METHOD_PUT:\"PUT\",HTTP2_METHOD_REBIND:\"REBIND\",HTTP2_METHOD_REPORT:\"REPORT\",HTTP2_METHOD_SEARCH:\"SEARCH\",HTTP2_METHOD_TRACE:\"TRACE\",HTTP2_METHOD_UNBIND:\"UNBIND\",HTTP2_METHOD_UNCHECKOUT:\"UNCHECKOUT\",HTTP2_METHOD_UNLINK:\"UNLINK\",HTTP2_METHOD_UNLOCK:\"UNLOCK\",HTTP2_METHOD_UPDATE:\"UPDATE\",HTTP2_METHOD_UPDATEREDIRECTREF:\"UPDATEREDIRECTREF\",HTTP2_METHOD_VERSION_CONTROL:\"VERSION-CONTROL\",HTTP_STATUS_CONTINUE:100,HTTP_STATUS_SWITCHING_PROTOCOLS:101,HTTP_STATUS_PROCESSING:102,HTTP_STATUS_EARLY_HINTS:103,HTTP_STATUS_OK:200,HTTP_STATUS_CREATED:201,HTTP_STATUS_ACCEPTED:202,HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION:203,HTTP_STATUS_NO_CONTENT:204,HTTP_STATUS_RESET_CONTENT:205,HTTP_STATUS_PARTIAL_CONTENT:206,HTTP_STATUS_MULTI_STATUS:207,HTTP_STATUS_ALREADY_REPORTED:208,HTTP_STATUS_IM_USED:226,HTTP_STATUS_MULTIPLE_CHOICES:300,HTTP_STATUS_MOVED_PERMANENTLY:301,HTTP_STATUS_FOUND:302,HTTP_STATUS_SEE_OTHER:303,HTTP_STATUS_NOT_MODIFIED:304,HTTP_STATUS_USE_PROXY:305,HTTP_STATUS_TEMPORARY_REDIRECT:307,HTTP_STATUS_PERMANENT_REDIRECT:308,HTTP_STATUS_BAD_REQUEST:400,HTTP_STATUS_UNAUTHORIZED:401,HTTP_STATUS_PAYMENT_REQUIRED:402,HTTP_STATUS_FORBIDDEN:403,HTTP_STATUS_NOT_FOUND:404,HTTP_STATUS_METHOD_NOT_ALLOWED:405,HTTP_STATUS_NOT_ACCEPTABLE:406,HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED:407,HTTP_STATUS_REQUEST_TIMEOUT:408,HTTP_STATUS_CONFLICT:409,HTTP_STATUS_GONE:410,HTTP_STATUS_LENGTH_REQUIRED:411,HTTP_STATUS_PRECONDITION_FAILED:412,HTTP_STATUS_PAYLOAD_TOO_LARGE:413,HTTP_STATUS_URI_TOO_LONG:414,HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE:415,HTTP_STATUS_RANGE_NOT_SATISFIABLE:416,HTTP_STATUS_EXPECTATION_FAILED:417,HTTP_STATUS_TEAPOT:418,HTTP_STATUS_MISDIRECTED_REQUEST:421,HTTP_STATUS_UNPROCESSABLE_ENTITY:422,HTTP_STATUS_LOCKED:423,HTTP_STATUS_FAILED_DEPENDENCY:424,HTTP_STATUS_TOO_EARLY:425,HTTP_STATUS_UPGRADE_REQUIRED:426,HTTP_STATUS_PRECONDITION_REQUIRED:428,HTTP_STATUS_TOO_MANY_REQUESTS:429,HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE:431,HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS:451,HTTP_STATUS_INTERNAL_SERVER_ERROR:500,HTTP_STATUS_NOT_IMPLEMENTED:501,HTTP_STATUS_BAD_GATEWAY:502,HTTP_STATUS_SERVICE_UNAVAILABLE:503,HTTP_STATUS_GATEWAY_TIMEOUT:504,HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED:505,HTTP_STATUS_VARIANT_ALSO_NEGOTIATES:506,HTTP_STATUS_INSUFFICIENT_STORAGE:507,HTTP_STATUS_LOOP_DETECTED:508,HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED:509,HTTP_STATUS_NOT_EXTENDED:510,HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED:511};function createServer(){throwNotImplemented(\"node:http2 createServer\",887)}function createSecureServer(){throwNotImplemented(\"node:http2 createSecureServer\",887)}function getDefaultSettings(){return{headerTableSize:4096,enablePush:!0,initialWindowSize:65535,maxFrameSize:16384,maxConcurrentStreams:4294967295,maxHeaderSize:65535,maxHeaderListSize:65535,enableConnectProtocol:!1}}function getPackedSettings(){return Buffer.alloc(0)}function getUnpackedSettings(){return Buffer.alloc(0)}const sensitiveHeaders=Symbol.for(\"nodejs.http2.sensitiveHeaders\");function Http2ServerRequest(){throwNotImplemented(\"node:http2 Http2ServerRequest\",887)}function Http2ServerResponse(){throwNotImplemented(\"node:http2 Http2ServerResponse\",887)}return $={constants,createServer,createSecureServer,getDefaultSettings,getPackedSettings,getUnpackedSettings,sensitiveHeaders,Http2ServerRequest,Http2ServerResponse,connect},hideFromStack([Http2ServerRequest,Http2ServerResponse,connect,createServer,createSecureServer,getDefaultSettings,getPackedSettings,getUnpackedSettings]),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeHttpsCode = "(function (){\"use strict\";const http=@getInternalField(@internalModuleRegistry,18)||@createInternalModuleById(18);function request(input,options,cb){if(input&&typeof input===\"object\"&&!(input instanceof URL))input.protocol\?\?=\"https:\";else if(typeof options===\"object\")options.protocol\?\?=\"https:\";return http.request(input,options,cb)}function get(input,options,cb){const req=request(input,options,cb);return req.end(),req}return{...http,get,request}})\n"_s; +// + +// static constexpr ASCIILiteral NodeInspectorCode = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15);function open(){throwNotImplemented(\"node:inspector open\",2445)}function close(){throwNotImplemented(\"node:inspector close\",2445)}function url(){throwNotImplemented(\"node:inspector url\",2445)}function waitForDebugger(){throwNotImplemented(\"node:inspector waitForDebugger\",2445)}class Session extends EventEmitter{constructor(){super();throwNotImplemented(\"node:inspector Session\",2445)}}return $={console:{...globalThis.console,context:{console:globalThis.console}},open,close,url,waitForDebugger,Session},hideFromStack(open,close,url,waitForDebugger,Session.prototype.constructor),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeNetCode = "(function (){\"use strict\";const{Duplex}=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),IPv4Reg=new RegExp(\"^((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$\"),IPv6Reg=new RegExp(\"^((\?:(\?:[0-9a-fA-F]{1,4}):){7}(\?:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){6}(\?:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|:(\?:[0-9a-fA-F]{1,4})|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){5}(\?::((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,2}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){4}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,1}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,3}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){3}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,2}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,4}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){2}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,3}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,5}|:)|(\?:(\?:[0-9a-fA-F]{1,4}):){1}(\?:(:(\?:[0-9a-fA-F]{1,4})){0,4}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(:(\?:[0-9a-fA-F]{1,4})){1,6}|:)|(\?::((\?::(\?:[0-9a-fA-F]{1,4})){0,5}:((\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[.]){3}(\?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|(\?::(\?:[0-9a-fA-F]{1,4})){1,7}|:)))(%[0-9a-zA-Z-.:]{1,})\?$\");function isIPv4(s){return IPv4Reg.test(s)}function isIPv6(s){return IPv6Reg.test(s)}function isIP(s){if(isIPv4(s))return 4;if(isIPv6(s))return 6;return 0}const{connect:bunConnect}=Bun;var{setTimeout}=globalThis;const bunTlsSymbol=Symbol.for(\"::buntls::\"),bunSocketServerHandlers=Symbol.for(\"::bunsocket_serverhandlers::\"),bunSocketServerConnections=Symbol.for(\"::bunnetserverconnections::\"),bunSocketServerOptions=Symbol.for(\"::bunnetserveroptions::\"),bunSocketInternal=Symbol.for(\"::bunnetsocketinternal::\"),bunTLSConnectOptions=Symbol.for(\"::buntlsconnectoptions::\");var SocketClass;const Socket=function(InternalSocket){return SocketClass=InternalSocket,Object.defineProperty(SocketClass.prototype,Symbol.toStringTag,{value:\"Socket\",enumerable:!1}),Object.defineProperty(function Socket(options){return new InternalSocket(options)},Symbol.hasInstance,{value(instance){return instance instanceof InternalSocket}})}(class Socket2 extends Duplex{static#Handlers={close:Socket2.#Close,connectError(socket,error){socket.data.emit(\"error\",error)},data({data:self},buffer){self.bytesRead+=buffer.length;const queue=self.#readQueue;if(queue.isEmpty()){if(self.push(buffer))return}queue.push(buffer)},drain:Socket2.#Drain,end:Socket2.#Close,error(socket,error){const self=socket.data,callback=self.#writeCallback;if(callback)self.#writeCallback=null,callback(error);self.emit(\"error\",error)},open(socket){const self=socket.data;socket.timeout(self.timeout),socket.ref(),self[bunSocketInternal]=socket,self.connecting=!1;const options=self[bunTLSConnectOptions];if(options){const{session}=options;if(session)self.setSession(session)}if(!self.#upgraded)self.emit(\"connect\",self);Socket2.#Drain(socket)},handshake(socket,success,verifyError){const{data:self}=socket;self._securePending=!1,self.secureConnecting=!1,self._secureEstablished=!!success,self.emit(\"secure\",self);const{checkServerIdentity}=self[bunTLSConnectOptions];if(!verifyError&&typeof checkServerIdentity===\"function\"&&self.servername){const cert=self.getPeerCertificate(!0);verifyError=checkServerIdentity(self.servername,cert)}if(self._requestCert||self._rejectUnauthorized){if(verifyError){if(self.authorized=!1,self.authorizationError=verifyError.code||verifyError.message,self._rejectUnauthorized){self.destroy(verifyError);return}}}else self.authorized=!0;self.emit(\"secureConnect\",verifyError)},timeout(socket){const self=socket.data;self.emit(\"timeout\",self)},binaryType:\"buffer\"};static#Close(socket){const self=socket.data;if(self.#closed)return;self.#closed=!0,self[bunSocketInternal]=null;const queue=self.#readQueue;if(queue.isEmpty()){if(self.push(null))return}queue.push(null)}static#Drain(socket){const self=socket.data,callback=self.#writeCallback;if(callback){const chunk=self.#writeChunk,written=socket.write(chunk);if(self.bytesWritten+=written,written=self.maxConnections){const data={localAddress:_socket.localAddress,localPort:_socket.localPort,localFamily:_socket.localFamily,remoteAddress:_socket.remoteAddress,remotePort:_socket.remotePort,remoteFamily:_socket.remoteFamily||\"IPv4\"};socket.end(),self.emit(\"drop\",data);return}if(!pauseOnConnect)_socket.resume();if(self[bunSocketServerConnections]++,typeof connectionListener==\"function\")if(InternalSocketClass.name===\"TLSSocket\")self.once(\"secureConnection\",()=>connectionListener(_socket));else connectionListener(_socket);self.emit(\"connection\",_socket)},handshake(socket,success,verifyError){const{data:self}=socket;if(self.emit(\"secure\",self),self._securePending=!1,self.secureConnecting=!1,self._secureEstablished=!!success,self._requestCert||self._rejectUnauthorized){if(verifyError){if(self.authorized=!1,self.authorizationError=verifyError.code||verifyError.message,self._rejectUnauthorized){self.destroy(verifyError);return}}}else self.authorized=!0;self.emit(\"secureConnection\",verifyError)},error(socket,error){Socket2.#Handlers.error(socket,error),this.data.emit(\"error\",error)},timeout:Socket2.#Handlers.timeout,connectError:Socket2.#Handlers.connectError,drain:Socket2.#Handlers.drain,binaryType:\"buffer\"};bytesRead=0;bytesWritten=0;#closed=!1;connecting=!1;localAddress=\"127.0.0.1\";#readQueue=@createFIFO();remotePort;[bunSocketInternal]=null;[bunTLSConnectOptions]=null;timeout=0;#writeCallback;#writeChunk;#pendingRead;isServer=!1;_handle;_parent;_parentWrap;#socket;#upgraded;constructor(options){const{socket,signal,write,read,allowHalfOpen=!1,...opts}=options||{};super({...opts,allowHalfOpen,readable:!0,writable:!0});if(this._handle=this,this._parent=this,this._parentWrap=this,this.#pendingRead=void 0,this.#upgraded=!1,socket instanceof Socket2)this.#socket=socket;signal\?.once(\"abort\",()=>this.destroy()),this.once(\"connect\",()=>this.emit(\"ready\"))}address(){return{address:this.localAddress,family:this.localFamily,port:this.localPort}}get bufferSize(){return this.writableLength}#attach(port,socket){if(this.remotePort=port,socket.data=this,socket.timeout(this.timeout),socket.ref(),this[bunSocketInternal]=socket,this.connecting=!1,!this.#upgraded)this.emit(\"connect\",this);Socket2.#Drain(socket)}connect(port,host,connectListener){var path,connection=this.#socket,_checkServerIdentity=void 0;if(typeof port===\"string\"){if(path=port,port=void 0,typeof host===\"function\")connectListener=host,host=void 0}else if(typeof host==\"function\"){if(typeof port===\"string\")path=port,port=void 0;connectListener=host,host=void 0}if(typeof port==\"object\"){var{port,host,path,socket,localAddress,localPort,family,hints,lookup,noDelay,keepAlive,keepAliveInitialDelay,requestCert,rejectUnauthorized,pauseOnConnect,servername,checkServerIdentity,session}=port;if(_checkServerIdentity=checkServerIdentity,this.servername=servername,socket)connection=socket}if(!pauseOnConnect)this.resume();this.connecting=!0,this.remotePort=port;const bunTLS=this[bunTlsSymbol];var tls=void 0;if(typeof bunTLS===\"function\"){if(tls=bunTLS.call(this,port,host,!0),this._requestCert=!0,this._rejectUnauthorized=rejectUnauthorized,tls){if(tls.rejectUnauthorized=rejectUnauthorized,tls.requestCert=!0,tls.session=session||tls.session,this.servername=tls.servername,tls.checkServerIdentity=_checkServerIdentity||tls.checkServerIdentity,this[bunTLSConnectOptions]=tls,!connection&&tls.socket)connection=tls.socket}if(connection){if(typeof connection!==\"object\"||!(connection instanceof Socket2)||typeof connection[bunTlsSymbol]===\"function\")@throwTypeError(\"socket must be an instance of net.Socket\")}if(this.authorized=!1,this.secureConnecting=!0,this._secureEstablished=!1,this._securePending=!0,connectListener)this.on(\"secureConnect\",connectListener)}else if(connectListener)this.on(\"connect\",connectListener);if(connection){const socket2=connection[bunSocketInternal];if(socket2){this.connecting=!0,this.#upgraded=!0;const result=socket2.upgradeTLS({data:this,tls,socket:Socket2.#Handlers});if(result){const[raw,tls2]=result;connection[bunSocketInternal]=raw,raw.timeout(raw.timeout),raw.connecting=!1,this[bunSocketInternal]=tls2}else throw this[bunSocketInternal]=null,new Error(\"Invalid socket\")}else connection.once(\"connect\",()=>{const socket3=connection[bunSocketInternal];if(!socket3)return;this.connecting=!0,this.#upgraded=!0;const result=socket3.upgradeTLS({data:this,tls,socket:Socket2.#Handlers});if(result){const[raw,tls2]=result;connection[bunSocketInternal]=raw,raw.timeout(raw.timeout),raw.connecting=!1,this[bunSocketInternal]=tls2}else throw this[bunSocketInternal]=null,new Error(\"Invalid socket\")})}else if(path)bunConnect({data:this,unix:path,socket:Socket2.#Handlers,tls}).catch((error)=>{this.emit(\"error\",error)});else bunConnect({data:this,hostname:host||\"localhost\",port,socket:Socket2.#Handlers,tls}).catch((error)=>{this.emit(\"error\",error)});return this}_destroy(err,callback){this[bunSocketInternal]\?.end(),callback(err)}_final(callback){this[bunSocketInternal]\?.end(),callback()}get localAddress(){return\"127.0.0.1\"}get localFamily(){return\"IPv4\"}get localPort(){return this[bunSocketInternal]\?.localPort}get pending(){return this.connecting}_read(size){const queue=this.#readQueue;let chunk;while(chunk=queue.peek()){if(!this.push(chunk))return;queue.shift()}}get readyState(){if(this.connecting)return\"opening\";if(this.readable)return this.writable\?\"open\":\"readOnly\";else return this.writable\?\"writeOnly\":\"closed\"}ref(){this[bunSocketInternal]\?.ref()}get remoteAddress(){return this[bunSocketInternal]\?.remoteAddress}get remoteFamily(){return\"IPv4\"}resetAndDestroy(){this[bunSocketInternal]\?.end()}setKeepAlive(enable=!1,initialDelay=0){return this}setNoDelay(noDelay=!0){return this}setTimeout(timeout,callback){if(this[bunSocketInternal]\?.timeout(timeout),this.timeout=timeout,callback)this.once(\"timeout\",callback);return this}unref(){this[bunSocketInternal]\?.unref()}_write(chunk,encoding,callback){if(typeof chunk==\"string\"&&encoding!==\"ascii\")chunk=Buffer.from(chunk,encoding);var written=this[bunSocketInternal]\?.write(chunk);if(written==chunk.length)callback();else if(this.#writeCallback)callback(new Error(\"overlapping _write()\"));else{if(written>0)if(typeof chunk==\"string\")chunk=chunk.slice(written);else chunk=chunk.subarray(written);this.#writeCallback=callback,this.#writeChunk=chunk}}});function createConnection(port,host,connectListener){if(typeof port===\"object\")return new Socket(port).connect(port,host,connectListener);return new Socket().connect(port,host,connectListener)}const connect=createConnection;class Server extends EventEmitter{#server;#listening=!1;[bunSocketServerConnections]=0;[bunSocketServerOptions];maxConnections=0;constructor(options,connectionListener){super();if(typeof options===\"function\")connectionListener=options,options={};else if(options==null||typeof options===\"object\")options={...options};else throw new Error(\"bun-net-polyfill: invalid arguments\");const{maxConnections}=options;this.maxConnections=Number.isSafeInteger(maxConnections)&&maxConnections>0\?maxConnections:0,options.connectionListener=connectionListener,this[bunSocketServerOptions]=options}ref(){return this.#server\?.ref(),this}unref(){return this.#server\?.unref(),this}close(callback){if(this.#server){if(this.#server.stop(!0),this.#server=null,this.#listening=!1,this[bunSocketServerConnections]=0,this.emit(\"close\"),typeof callback===\"function\")callback();return this}if(typeof callback===\"function\"){const error=new Error(\"Server is not running\");error.code=\"ERR_SERVER_NOT_RUNNING\",callback(error)}return this}address(){const server=this.#server;if(server){const unix=server.unix;if(unix)return unix;let address=server.hostname;const type=isIP(address),port=server.port;if(typeof port===\"number\")return{port,address,family:type\?`IPv${type}`:void 0};if(type)return{address,family:type\?`IPv${type}`:void 0};return address}return null}getConnections(callback){if(typeof callback===\"function\")callback(null,this.#server\?this[bunSocketServerConnections]:0);return this}listen(port,hostname,onListen){let backlog,path,exclusive=!1;if(typeof port===\"string\"){if(Number.isSafeInteger(hostname)){if(hostname>0)backlog=hostname}else if(typeof hostname===\"function\")onListen=hostname;path=port,hostname=void 0,port=void 0}else{if(typeof hostname===\"function\")onListen=hostname,hostname=void 0;if(typeof port===\"function\")onListen=port,port=0;else if(typeof port===\"object\"){const options=port;options.signal\?.addEventListener(\"abort\",()=>this.close()),hostname=options.host,exclusive=options.exclusive===!0;const path2=options.path;if(port=options.port,!Number.isSafeInteger(port)||port<0)if(path2)hostname=path2,port=void 0;else{let message='The argument \\'options\\' must have the property \"port\" or \"path\"';try{message=`${message}. Received ${JSON.stringify(options)}`}catch{}const error=@makeTypeError(message);throw error.code=\"ERR_INVALID_ARG_VALUE\",error}else if(!Number.isSafeInteger(port)||port<0)port=0;if(typeof port.callback===\"function\")onListen=port\?.callback}else if(!Number.isSafeInteger(port)||port<0)port=0;hostname=hostname||\"::\"}try{var tls=void 0,TLSSocketClass=void 0;const bunTLS=this[bunTlsSymbol],options=this[bunSocketServerOptions];if(typeof bunTLS===\"function\")[tls,TLSSocketClass]=bunTLS.call(this,port,hostname,!1),options.servername=tls.serverName,options.InternalSocketClass=TLSSocketClass;else options.InternalSocketClass=SocketClass;this.#server=Bun.listen(path\?{exclusive,unix:path,tls,socket:SocketClass[bunSocketServerHandlers]}:{exclusive,port,hostname,tls,socket:SocketClass[bunSocketServerHandlers]}),this.#server.data=this,this.#listening=!0,setTimeout(emitListeningNextTick,1,this,onListen)}catch(err){this.#listening=!1,setTimeout(emitErrorNextTick,1,this,err)}return this}}function emitErrorNextTick(self,error){self.emit(\"error\",error)}function emitListeningNextTick(self,onListen){if(typeof onListen===\"function\")try{onListen()}catch(err){self.emit(\"error\",err)}self.emit(\"listening\")}function createServer(options,connectionListener){return new Server(options,connectionListener)}return{createServer,Server,createConnection,connect,isIP,isIPv4,isIPv6,Socket,[Symbol.for(\"::bunternal::\")]:SocketClass}})\n"_s; +// + +// static constexpr ASCIILiteral NodeOSCode = "(function (){\"use strict\";var tmpdir=function(){var env=Bun.env;return tmpdir=function(){var path=env.TMPDIR||env.TMP||env.TEMP||\"/tmp\";const length=path.length;if(length>1&&path[length-1]===\"/\")path=path.slice(0,-1);return path},tmpdir()};function lazyCpus({cpus}){return()=>{const array=new Array(navigator.hardwareConcurrency);function populate(){const results=cpus(),length=results.length;array.length=length;for(let i=0;i= 0x80 (not a basic code point)\",\"invalid-input\":\"Invalid input\"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(type){@throwRangeError(errors[type])}function map(array,callback){const result=[];let length=array.length;while(length--)result[length]=callback(array[length]);return result}function mapDomain(domain,callback){const parts=domain.split(\"@\");let result=\"\";if(parts.length>1)result=parts[0]+\"@\",domain=parts[1];domain=domain.replace(regexSeparators,\".\");const labels=domain.split(\".\"),encoded=map(labels,callback).join(\".\");return result+encoded}function ucs2decode(string){const output=[];let counter=0;const length=string.length;while(counter=55296&&value<=56319&&counterString.fromCodePoint(...codePoints),basicToDigit=function(codePoint){if(codePoint>=48&&codePoint<58)return 26+(codePoint-48);if(codePoint>=65&&codePoint<91)return codePoint-65;if(codePoint>=97&&codePoint<123)return codePoint-97;return base},digitToBasic=function(digit,flag){return digit+22+75*(digit<26)-((flag!=0)<<5)},adapt=function(delta,numPoints,firstTime){let k=0;delta=firstTime\?floor(delta/damp):delta>>1,delta+=floor(delta/numPoints);for(;delta>baseMinusTMin*tMax>>1;k+=base)delta=floor(delta/baseMinusTMin);return floor(k+(baseMinusTMin+1)*delta/(delta+skew))},decode=function(input){const output=[],inputLength=input.length;let i=0,n=initialN,bias=initialBias,basic=input.lastIndexOf(delimiter);if(basic<0)basic=0;for(let j=0;j=128)error(\"not-basic\");output.push(input.charCodeAt(j))}for(let index=basic>0\?basic+1:0;index=inputLength)error(\"invalid-input\");const digit=basicToDigit(input.charCodeAt(index++));if(digit>=base)error(\"invalid-input\");if(digit>floor((maxInt-i)/w))error(\"overflow\");i+=digit*w;const t=k<=bias\?tMin:k>=bias+tMax\?tMax:k-bias;if(digitfloor(maxInt/baseMinusT))error(\"overflow\");w*=baseMinusT}const out=output.length+1;if(bias=adapt(i-oldi,out,oldi==0),floor(i/out)>maxInt-n)error(\"overflow\");n+=floor(i/out),i%=out,output.splice(i++,0,n)}return String.fromCodePoint(...output)},encode=function(input){const output=[];input=ucs2decode(input);const inputLength=input.length;let n=initialN,delta=0,bias=initialBias;for(let currentValue of input)if(currentValue<128)output.push(stringFromCharCode(currentValue));const basicLength=output.length;let handledCPCount=basicLength;if(basicLength)output.push(delimiter);while(handledCPCount=n&¤tValuefloor((maxInt-delta)/handledCPCountPlusOne))error(\"overflow\");delta+=(m-n)*handledCPCountPlusOne,n=m;for(let currentValue of input){if(currentValuemaxInt)error(\"overflow\");if(currentValue===n){let q=delta;for(let k=base;;k+=base){const t=k<=bias\?tMin:k>=bias+tMax\?tMax:k-bias;if(q()=>(mod||cb((mod={exports:{}}).exports,mod),mod.exports),Buffer=@requireNativeModule(\"node:buffer\").Buffer,require_object_keys=__commonJS((exports,module)=>{var objectKeys=Object.keys||function(){var hasOwnProperty=Object.prototype.hasOwnProperty,hasDontEnumBug=!{toString:null}.propertyIsEnumerable(\"toString\"),dontEnums=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],dontEnumsLength=dontEnums.length;return function(obj){if(typeof obj!==\"function\"&&(typeof obj!==\"object\"||obj===null))@throwTypeError(\"Object.keys called on non-object\");var result=[],prop,i;for(prop in obj)if(hasOwnProperty.call(obj,prop))result.push(prop);if(hasDontEnumBug){for(i=0;i{var ParsedQueryString=function(){},unescapeBuffer=function(s,decodeSpaces){var out=Buffer.allocUnsafe(s.length),state=0,n,m,hexchar,c;for(var inIndex=0,outIndex=0;;inIndex++){if(inIndex0){if(out[outIndex++]=37,state===2)out[outIndex++]=hexchar}break}switch(state){case 0:switch(c){case 37:n=0,m=0,state=1;break;case 43:if(decodeSpaces)c=32;default:out[outIndex++]=c;break}break;case 1:if(hexchar=c,n=unhexTable[c],!(n>=0)){out[outIndex++]=37,out[outIndex++]=c,state=0;break}state=2;break;case 2:if(state=0,m=unhexTable[c],!(m>=0)){out[outIndex++]=37,out[outIndex++]=hexchar,out[outIndex++]=c;break}out[outIndex++]=16*n+m;break}}return out.slice(0,outIndex)},qsUnescape=function(s,decodeSpaces){try{return decodeURIComponent(s)}catch(e){return QueryString.unescapeBuffer(s,decodeSpaces).toString()}},qsEscape=function(str){if(typeof str!==\"string\")if(typeof str===\"object\")str=String(str);else str+=\"\";var out=\"\",lastPos=0;for(var i2=0;i2>6]+hexTable[128|c&63];continue}if(c<55296||c>=57344){lastPos=i2+1,out+=hexTable[224|c>>12]+hexTable[128|c>>6&63]+hexTable[128|c&63];continue}++i2;var c2;if(i2>18]+hexTable[128|c>>12&63]+hexTable[128|c>>6&63]+hexTable[128|c&63]}if(lastPos===0)return str;if(lastPos0\?options.maxKeys:-1;var decode=QueryString.unescape;if(options&&typeof options.decodeURIComponent===\"function\")decode=options.decodeURIComponent;const customDecode=decode!==qsUnescape,keys=[];var posIdx=0,lastPos=0,sepIdx=0,eqIdx=0,key=\"\",value=\"\",keyEncoded=customDecode,valEncoded=customDecode,encodeCheck=0;for(var i2=0;i2sepLen||i2===0)if(indexOf(keys,key)===-1)obj[key]=value,keys[keys.length]=key;else{const curValue=obj[key]||\"\";if(curValue.pop)curValue[curValue.length]=value;else if(curValue)obj[key]=[curValue,value]}else if(i2===1)delete obj[key];if(--pairs===0)break;keyEncoded=valEncoded=customDecode,encodeCheck=0,key=value=\"\",posIdx=lastPos,lastPos=i2+1,sepIdx=eqIdx=0}continue}else if(sepIdx=0,!valEncoded)if(code===37)encodeCheck=1;else if(encodeCheck>0&&(code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102)){if(++encodeCheck===3)valEncoded=!0}else encodeCheck=0;if(eqIdx0&&(code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102)){if(++encodeCheck===3)keyEncoded=!0}else encodeCheck=0}if(code===43){if(eqIdx0)){if(lastPosObject.prototype.toString.call(arg)===\"[object Array]\",indexOf=(arr,searchElement,fromIndex)=>{var k;if(arr==null)@throwTypeError('\"arr\" is null or not defined');var o=Object(arr),len=o.length>>>0;if(len===0)return-1;var n=fromIndex|0;if(n>=len)return-1;k=Math.max(n>=0\?n:len-Math.abs(n),0);while(k{},SymbolAsyncIterator=Symbol.asyncIterator,SymbolIterator=Symbol.iterator,SymbolFor=Symbol.for,SymbolReplace=Symbol.replace,ArrayFrom=Array.from,ArrayIsArray=Array.isArray,ArrayPrototypeFilter=Array.prototype.filter,ArrayPrototypeSort=Array.prototype.sort,ArrayPrototypeIndexOf=Array.prototype.indexOf,ArrayPrototypeJoin=Array.prototype.join,ArrayPrototypeMap=Array.prototype.map,ArrayPrototypePop=Array.prototype.pop,ArrayPrototypePush=Array.prototype.push,ArrayPrototypeSlice=Array.prototype.slice,ArrayPrototypeSplice=Array.prototype.splice,ArrayPrototypeReverse=Array.prototype.reverse,ArrayPrototypeShift=Array.prototype.shift,ArrayPrototypeUnshift=Array.prototype.unshift,RegExpPrototypeExec=RegExp.prototype.exec,RegExpPrototypeSymbolReplace=RegExp.prototype[SymbolReplace],StringFromCharCode=String.fromCharCode,StringPrototypeCharCodeAt=String.prototype.charCodeAt,StringPrototypeCodePointAt=String.prototype.codePointAt,StringPrototypeSlice=String.prototype.slice,StringPrototypeToLowerCase=String.prototype.toLowerCase,StringPrototypeEndsWith=String.prototype.endsWith,StringPrototypeRepeat=String.prototype.repeat,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeTrim=String.prototype.trim,StringPrototypeNormalize=String.prototype.normalize,NumberIsNaN=Number.isNaN,NumberIsFinite=Number.isFinite,NumberIsInteger=Number.isInteger,NumberMAX_SAFE_INTEGER=Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER=Number.MIN_SAFE_INTEGER,MathCeil=Math.ceil,MathFloor=Math.floor,MathMax=Math.max,MathMaxApply=Math.max.apply,DateNow=Date.now,FunctionPrototype=Function.prototype,StringPrototype=String.prototype,StringPrototypeSymbolIterator=StringPrototype[SymbolIterator],StringIteratorPrototypeNext=StringPrototypeSymbolIterator.call(\"\").next,ObjectSetPrototypeOf=Object.setPrototypeOf,ObjectDefineProperty=Object.defineProperty,ObjectDefineProperties=Object.defineProperties,ObjectFreeze=Object.freeze,ObjectAssign=Object.assign,ObjectCreate=Object.create,ObjectKeys=Object.keys,ObjectSeal=Object.seal,createSafeIterator=(factory,next)=>{class SafeIterator{#iterator;constructor(iterable){this.#iterator=factory.call(iterable)}next(){return next.call(this.#iterator)}[SymbolIterator](){return this}}return ObjectSetPrototypeOf(SafeIterator.prototype,null),ObjectFreeze(SafeIterator.prototype),ObjectFreeze(SafeIterator),SafeIterator},SafeStringIterator=createSafeIterator(StringPrototypeSymbolIterator,StringIteratorPrototypeNext),isFullWidthCodePoint=(code)=>{return code>=4352&&(code<=4447||code===9001||code===9002||code>=11904&&code<=12871&&code!==12351||code>=12880&&code<=19903||code>=19968&&code<=42182||code>=43360&&code<=43388||code>=44032&&code<=55203||code>=63744&&code<=64255||code>=65040&&code<=65049||code>=65072&&code<=65131||code>=65281&&code<=65376||code>=65504&&code<=65510||code>=110592&&code<=110593||code>=127488&&code<=127569||code>=127744&&code<=128591||code>=131072&&code<=262141)},isZeroWidthCodePoint=(code)=>{return code<=31||code>=127&&code<=159||code>=768&&code<=879||code>=8203&&code<=8207||code>=8400&&code<=8447||code>=65024&&code<=65039||code>=65056&&code<=65071||code>=917760&&code<=917999},getStringWidth=function getStringWidth(str,removeControlChars=!0){var width=0;if(removeControlChars)str=stripVTControlCharacters(str);str=StringPrototypeNormalize.call(str,\"NFC\");for(var char of new SafeStringIterator(str)){var code=StringPrototypeCodePointAt.call(char,0);if(isFullWidthCodePoint(code))width+=2;else if(!isZeroWidthCodePoint(code))width++}return width},ansiPattern=\"[\\\\u001B\\\\u009B][[\\\\]()#;\?]*(\?:(\?:(\?:(\?:;[-a-zA-Z\\\\d\\\\/#&.:=\?%@~_]+)*|[a-zA-Z\\\\d]+(\?:;[-a-zA-Z\\\\d\\\\/#&.:=\?%@~_]*)*)\?\\\\u0007)|(\?:(\?:\\\\d{1,4}(\?:;\\\\d{0,4})*)\?[\\\\dA-PR-TZcf-ntqry=><~]))\",ansi=new RegExp(ansiPattern,\"g\");function stripVTControlCharacters(str){return validateString(str,\"str\"),RegExpPrototypeSymbolReplace.call(ansi,str,\"\")}var kCustomPromisifiedSymbol=SymbolFor(\"nodejs.util.promisify.custom\"),kCustomPromisifyArgsSymbol=Symbol(\"customPromisifyArgs\");function promisify(original){if(validateFunction(original,\"original\"),original[kCustomPromisifiedSymbol]){var fn=original[kCustomPromisifiedSymbol];return validateFunction(fn,\"util.promisify.custom\"),ObjectDefineProperty(fn,kCustomPromisifiedSymbol,{__proto__:null,value:fn,enumerable:!1,writable:!1,configurable:!0})}var argumentNames=original[kCustomPromisifyArgsSymbol];function fn(...args){return new Promise((resolve,reject)=>{ArrayPrototypePush.call(args,(err,...values)=>{if(err)return reject(err);if(argumentNames!==void 0&&values.length>1){var obj={};for(var i2=0;i2max)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}function validateUint32(value,name,positive=!1){if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE(name,\"number\",value);if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);var min=positive\?1:0,max=4294967295;if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}function CSI(strings,...args){var ret=`${kEscape}[`;for(var n=0;n1&&StringPrototypeCodePointAt.call(str,i-2)>=kUTF16SurrogateThreshold||StringPrototypeCodePointAt.call(str,i-1)>=kUTF16SurrogateThreshold)return 2;return 1}function charLengthAt(str,i){if(str.length<=i)return 1;return StringPrototypeCodePointAt.call(str,i)>=kUTF16SurrogateThreshold\?2:1}function*emitKeys(stream){while(!0){var ch=yield,s=ch,escaped=!1,keySeq=null,keyName,keyCtrl2=!1,keyMeta=!1,keyShift=!1;if(ch===kEscape){if(escaped=!0,s+=ch=yield,ch===kEscape)s+=ch=yield}if(escaped&&(ch===\"O\"||ch===\"[\")){var code=ch,modifier=0;if(ch===\"O\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")modifier=(ch>>0)-1,s+=ch=yield;code+=ch}else if(ch===\"[\"){if(s+=ch=yield,ch===\"[\")code+=ch,s+=ch=yield;var cmdStart=s.length-1;if(ch>=\"0\"&&ch<=\"9\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")s+=ch=yield}if(ch===\";\"){if(s+=ch=yield,ch>=\"0\"&&ch<=\"9\")s+=yield}var cmd=StringPrototypeSlice.call(s,cmdStart),match;if(match=RegExpPrototypeExec.call(/^(\\d\\d\?)(;(\\d))\?([~^$])$/,cmd))code+=match[1]+match[4],modifier=(match[3]||1)-1;else if(match=RegExpPrototypeExec.call(/^((\\d;)\?(\\d))\?([A-Za-z])$/,cmd))code+=match[4],modifier=(match[3]||1)-1;else code+=cmd}switch(keyCtrl2=!!(modifier&4),keyMeta=!!(modifier&10),keyShift=!!(modifier&1),code){case\"[P\":keyName=\"f1\";break;case\"[Q\":keyName=\"f2\";break;case\"[R\":keyName=\"f3\";break;case\"[S\":keyName=\"f4\";break;case\"OP\":keyName=\"f1\";break;case\"OQ\":keyName=\"f2\";break;case\"OR\":keyName=\"f3\";break;case\"OS\":keyName=\"f4\";break;case\"[11~\":keyName=\"f1\";break;case\"[12~\":keyName=\"f2\";break;case\"[13~\":keyName=\"f3\";break;case\"[14~\":keyName=\"f4\";break;case\"[[A\":keyName=\"f1\";break;case\"[[B\":keyName=\"f2\";break;case\"[[C\":keyName=\"f3\";break;case\"[[D\":keyName=\"f4\";break;case\"[[E\":keyName=\"f5\";break;case\"[15~\":keyName=\"f5\";break;case\"[17~\":keyName=\"f6\";break;case\"[18~\":keyName=\"f7\";break;case\"[19~\":keyName=\"f8\";break;case\"[20~\":keyName=\"f9\";break;case\"[21~\":keyName=\"f10\";break;case\"[23~\":keyName=\"f11\";break;case\"[24~\":keyName=\"f12\";break;case\"[A\":keyName=\"up\";break;case\"[B\":keyName=\"down\";break;case\"[C\":keyName=\"right\";break;case\"[D\":keyName=\"left\";break;case\"[E\":keyName=\"clear\";break;case\"[F\":keyName=\"end\";break;case\"[H\":keyName=\"home\";break;case\"OA\":keyName=\"up\";break;case\"OB\":keyName=\"down\";break;case\"OC\":keyName=\"right\";break;case\"OD\":keyName=\"left\";break;case\"OE\":keyName=\"clear\";break;case\"OF\":keyName=\"end\";break;case\"OH\":keyName=\"home\";break;case\"[1~\":keyName=\"home\";break;case\"[2~\":keyName=\"insert\";break;case\"[3~\":keyName=\"delete\";break;case\"[4~\":keyName=\"end\";break;case\"[5~\":keyName=\"pageup\";break;case\"[6~\":keyName=\"pagedown\";break;case\"[[5~\":keyName=\"pageup\";break;case\"[[6~\":keyName=\"pagedown\";break;case\"[7~\":keyName=\"home\";break;case\"[8~\":keyName=\"end\";break;case\"[a\":keyName=\"up\",keyShift=!0;break;case\"[b\":keyName=\"down\",keyShift=!0;break;case\"[c\":keyName=\"right\",keyShift=!0;break;case\"[d\":keyName=\"left\",keyShift=!0;break;case\"[e\":keyName=\"clear\",keyShift=!0;break;case\"[2$\":keyName=\"insert\",keyShift=!0;break;case\"[3$\":keyName=\"delete\",keyShift=!0;break;case\"[5$\":keyName=\"pageup\",keyShift=!0;break;case\"[6$\":keyName=\"pagedown\",keyShift=!0;break;case\"[7$\":keyName=\"home\",keyShift=!0;break;case\"[8$\":keyName=\"end\",keyShift=!0;break;case\"Oa\":keyName=\"up\",keyCtrl2=!0;break;case\"Ob\":keyName=\"down\",keyCtrl2=!0;break;case\"Oc\":keyName=\"right\",keyCtrl2=!0;break;case\"Od\":keyName=\"left\",keyCtrl2=!0;break;case\"Oe\":keyName=\"clear\",keyCtrl2=!0;break;case\"[2^\":keyName=\"insert\",keyCtrl2=!0;break;case\"[3^\":keyName=\"delete\",keyCtrl2=!0;break;case\"[5^\":keyName=\"pageup\",keyCtrl2=!0;break;case\"[6^\":keyName=\"pagedown\",keyCtrl2=!0;break;case\"[7^\":keyName=\"home\",keyCtrl2=!0;break;case\"[8^\":keyName=\"end\",keyCtrl2=!0;break;case\"[Z\":keyName=\"tab\",keyShift=!0;break;default:keyName=\"undefined\";break}}else if(ch===\"\\r\")keyName=\"return\",keyMeta=escaped;else if(ch===\"\\n\")keyName=\"enter\",keyMeta=escaped;else if(ch===\"\\t\")keyName=\"tab\",keyMeta=escaped;else if(ch===\"\\b\"||ch===\"\\x7F\")keyName=\"backspace\",keyMeta=escaped;else if(ch===kEscape)keyName=\"escape\",keyMeta=escaped;else if(ch===\" \")keyName=\"space\",keyMeta=escaped;else if(!escaped&&ch<=\"\\x1A\")keyName=StringFromCharCode(StringPrototypeCharCodeAt.call(ch)+StringPrototypeCharCodeAt.call(\"a\")-1),keyCtrl2=!0;else if(RegExpPrototypeExec.call(/^[0-9A-Za-z]$/,ch)!==null)keyName=StringPrototypeToLowerCase.call(ch),keyShift=RegExpPrototypeExec.call(/^[A-Z]$/,ch)!==null,keyMeta=escaped;else if(escaped)keyName=ch.length\?void 0:\"escape\",keyMeta=!0;if(keySeq=s,s.length!==0&&(keyName!==void 0||escaped))stream.emit(\"keypress\",escaped\?void 0:s,{sequence:keySeq,name:keyName,ctrl:keyCtrl2,meta:keyMeta,shift:keyShift});else if(charLengthAt(s,0)===s.length)stream.emit(\"keypress\",s,{sequence:keySeq,name:keyName,ctrl:keyCtrl2,meta:keyMeta,shift:keyShift})}}function commonPrefix(strings){if(strings.length===0)return\"\";if(strings.length===1)return strings[0];var sorted=ArrayPrototypeSort.call(ArrayPrototypeSlice.call(strings)),min=sorted[0],max=sorted[sorted.length-1];for(var i=0;i0)data+=CSI`${dx}C`;if(dy<0)data+=CSI`${-dy}A`;else if(dy>0)data+=CSI`${dy}B`;return stream.write(data,callback)}function clearLine(stream,dir,callback){if(callback!==void 0)validateFunction(callback,\"callback\");if(stream===null||stream===void 0){if(typeof callback===\"function\")process.nextTick(callback,null);return!0}var type=dir<0\?kClearToLineBeginning:dir>0\?kClearToLineEnd:kClearLine;return stream.write(type,callback)}function clearScreenDown(stream,callback){if(callback!==void 0)validateFunction(callback,\"callback\");if(stream===null||stream===void 0){if(typeof callback===\"function\")process.nextTick(callback,null);return!0}return stream.write(kClearScreenDown,callback)}var KEYPRESS_DECODER=Symbol(\"keypress-decoder\"),ESCAPE_DECODER=Symbol(\"escape-decoder\"),ESCAPE_CODE_TIMEOUT=500;function emitKeypressEvents(stream,iface={}){if(stream[KEYPRESS_DECODER])return;stream[KEYPRESS_DECODER]=new StringDecoder(\"utf8\"),stream[ESCAPE_DECODER]=emitKeys(stream),stream[ESCAPE_DECODER].next();var triggerEscape=()=>stream[ESCAPE_DECODER].next(\"\"),{escapeCodeTimeout=ESCAPE_CODE_TIMEOUT}=iface,timeoutId;function onData2(input){if(stream.listenerCount(\"keypress\")>0){var string=stream[KEYPRESS_DECODER].write(input);if(string){clearTimeout(timeoutId),iface[kSawKeyPress]=charLengthAt(string,0)===string.length,iface.isCompletionEnabled=!1;var length=0;for(var character of new SafeStringIterator(string)){if(length+=character.length,length===string.length)iface.isCompletionEnabled=!0;try{if(stream[ESCAPE_DECODER].next(character),length===string.length&&character===kEscape)timeoutId=setTimeout(triggerEscape,escapeCodeTimeout)}catch(err){throw stream[ESCAPE_DECODER]=emitKeys(stream),stream[ESCAPE_DECODER].next(),err}}}}else stream.removeListener(\"data\",onData2),stream.on(\"newListener\",onNewListener)}function onNewListener(event){if(event===\"keypress\")stream.on(\"data\",onData2),stream.removeListener(\"newListener\",onNewListener)}if(stream.listenerCount(\"keypress\")>0)stream.on(\"data\",onData2);else stream.on(\"newListener\",onNewListener)}var kEmptyObject=ObjectFreeze(ObjectCreate(null)),kHistorySize=30,kMaxUndoRedoStackSize=2048,kMincrlfDelay=100,lineEnding=/\\r\?\\n|\\r(\?!\\n)/g,kMaxLengthOfKillRing=32,kLineObjectStream=Symbol(\"line object stream\"),kQuestionCancel=Symbol(\"kQuestionCancel\"),kQuestion=Symbol(\"kQuestion\"),kAddHistory=Symbol(\"_addHistory\"),kBeforeEdit=Symbol(\"_beforeEdit\"),kDecoder=Symbol(\"_decoder\"),kDeleteLeft=Symbol(\"_deleteLeft\"),kDeleteLineLeft=Symbol(\"_deleteLineLeft\"),kDeleteLineRight=Symbol(\"_deleteLineRight\"),kDeleteRight=Symbol(\"_deleteRight\"),kDeleteWordLeft=Symbol(\"_deleteWordLeft\"),kDeleteWordRight=Symbol(\"_deleteWordRight\"),kGetDisplayPos=Symbol(\"_getDisplayPos\"),kHistoryNext=Symbol(\"_historyNext\"),kHistoryPrev=Symbol(\"_historyPrev\"),kInsertString=Symbol(\"_insertString\"),kLine=Symbol(\"_line\"),kLine_buffer=Symbol(\"_line_buffer\"),kKillRing=Symbol(\"_killRing\"),kKillRingCursor=Symbol(\"_killRingCursor\"),kMoveCursor=Symbol(\"_moveCursor\"),kNormalWrite=Symbol(\"_normalWrite\"),kOldPrompt=Symbol(\"_oldPrompt\"),kOnLine=Symbol(\"_onLine\"),kPreviousKey=Symbol(\"_previousKey\"),kPrompt=Symbol(\"_prompt\"),kPushToKillRing=Symbol(\"_pushToKillRing\"),kPushToUndoStack=Symbol(\"_pushToUndoStack\"),kQuestionCallback=Symbol(\"_questionCallback\"),kRedo=Symbol(\"_redo\"),kRedoStack=Symbol(\"_redoStack\"),kRefreshLine=Symbol(\"_refreshLine\"),kSawKeyPress=Symbol(\"_sawKeyPress\"),kSawReturnAt=Symbol(\"_sawReturnAt\"),kSetRawMode=Symbol(\"_setRawMode\"),kTabComplete=Symbol(\"_tabComplete\"),kTabCompleter=Symbol(\"_tabCompleter\"),kTtyWrite=Symbol(\"_ttyWrite\"),kUndo=Symbol(\"_undo\"),kUndoStack=Symbol(\"_undoStack\"),kWordLeft=Symbol(\"_wordLeft\"),kWordRight=Symbol(\"_wordRight\"),kWriteToOutput=Symbol(\"_writeToOutput\"),kYank=Symbol(\"_yank\"),kYanking=Symbol(\"_yanking\"),kYankPop=Symbol(\"_yankPop\"),kFirstEventParam=Symbol(\"nodejs.kFirstEventParam\"),kOnSelfCloseWithTerminal=Symbol(\"_onSelfCloseWithTerminal\"),kOnSelfCloseWithoutTerminal=Symbol(\"_onSelfCloseWithoutTerminal\"),kOnKeyPress=Symbol(\"_onKeyPress\"),kOnError=Symbol(\"_onError\"),kOnData=Symbol(\"_onData\"),kOnEnd=Symbol(\"_onEnd\"),kOnTermEnd=Symbol(\"_onTermEnd\"),kOnResize=Symbol(\"_onResize\");function onSelfCloseWithTerminal(){var input=this.input,output=this.output;if(!input)throw new Error(\"Input not set, invalid state for readline!\");if(input.removeListener(\"keypress\",this[kOnKeyPress]),input.removeListener(\"error\",this[kOnError]),input.removeListener(\"end\",this[kOnTermEnd]),output!==null&&output!==void 0)output.removeListener(\"resize\",this[kOnResize])}function onSelfCloseWithoutTerminal(){var input=this.input;if(!input)throw new Error(\"Input not set, invalid state for readline!\");input.removeListener(\"data\",this[kOnData]),input.removeListener(\"error\",this[kOnError]),input.removeListener(\"end\",this[kOnEnd])}function onError(err){this.emit(\"error\",err)}function onData(data){debug(\"onData\"),this[kNormalWrite](data)}function onEnd(){if(debug(\"onEnd\"),typeof this[kLine_buffer]===\"string\"&&this[kLine_buffer].length>0)this.emit(\"line\",this[kLine_buffer]);this.close()}function onTermEnd(){if(debug(\"onTermEnd\"),typeof this.line===\"string\"&&this.line.length>0)this.emit(\"line\",this.line);this.close()}function onKeyPress(s,key){if(this[kTtyWrite](s,key),key&&key.sequence){var ch=StringPrototypeCodePointAt.call(key.sequence,0);if(ch>=55296&&ch<=57343)this[kRefreshLine]()}}function onResize(){this[kRefreshLine]()}function InterfaceConstructor(input,output,completer,terminal){if(!(this instanceof InterfaceConstructor))return new InterfaceConstructor(input,output,completer,terminal);EventEmitter.call(this),this[kOnSelfCloseWithoutTerminal]=onSelfCloseWithoutTerminal.bind(this),this[kOnSelfCloseWithTerminal]=onSelfCloseWithTerminal.bind(this),this[kOnError]=onError.bind(this),this[kOnData]=onData.bind(this),this[kOnEnd]=onEnd.bind(this),this[kOnTermEnd]=onTermEnd.bind(this),this[kOnKeyPress]=onKeyPress.bind(this),this[kOnResize]=onResize.bind(this),this[kSawReturnAt]=0,this.isCompletionEnabled=!0,this[kSawKeyPress]=!1,this[kPreviousKey]=null,this.escapeCodeTimeout=ESCAPE_CODE_TIMEOUT,this.tabSize=8;var history,historySize,removeHistoryDuplicates=!1,crlfDelay,prompt=\"> \",signal;if(input\?.input){output=input.output,completer=input.completer,terminal=input.terminal,history=input.history,historySize=input.historySize,signal=input.signal;var tabSize=input.tabSize;if(tabSize!==void 0)validateUint32(tabSize,\"tabSize\",!0),this.tabSize=tabSize;removeHistoryDuplicates=input.removeHistoryDuplicates;var inputPrompt=input.prompt;if(inputPrompt!==void 0)prompt=inputPrompt;var inputEscapeCodeTimeout=input.escapeCodeTimeout;if(inputEscapeCodeTimeout!==void 0)if(NumberIsFinite(inputEscapeCodeTimeout))this.escapeCodeTimeout=inputEscapeCodeTimeout;else throw new ERR_INVALID_ARG_VALUE(\"input.escapeCodeTimeout\",this.escapeCodeTimeout);if(signal)validateAbortSignal(signal,\"options.signal\");crlfDelay=input.crlfDelay,input=input.input}if(completer!==void 0&&typeof completer!==\"function\")throw new ERR_INVALID_ARG_VALUE(\"completer\",completer);if(history===void 0)history=[];else validateArray(history,\"history\");if(historySize===void 0)historySize=kHistorySize;if(typeof historySize!==\"number\"||NumberIsNaN(historySize)||historySize<0)throw new ERR_INVALID_ARG_VALUE(\"historySize\",historySize);if(terminal===void 0&&!(output===null||output===void 0))terminal=!!output.isTTY;if(this.line=\"\",this[kSubstringSearch]=null,this.output=output,this.input=input,this[kUndoStack]=[],this[kRedoStack]=[],this.history=history,this.historySize=historySize,this[kKillRing]=[],this[kKillRingCursor]=0,this.removeHistoryDuplicates=!!removeHistoryDuplicates,this.crlfDelay=crlfDelay\?MathMax(kMincrlfDelay,crlfDelay):kMincrlfDelay,this.completer=completer,this.setPrompt(prompt),this.terminal=!!terminal,this[kLineObjectStream]=void 0,input.on(\"error\",this[kOnError]),!this.terminal)input.on(\"data\",this[kOnData]),input.on(\"end\",this[kOnEnd]),this.once(\"close\",this[kOnSelfCloseWithoutTerminal]),this[kDecoder]=new StringDecoder(\"utf8\");else{if(emitKeypressEvents(input,this),input.on(\"keypress\",this[kOnKeyPress]),input.on(\"end\",this[kOnTermEnd]),this[kSetRawMode](!0),this.terminal=!0,this.cursor=0,this.historyIndex=-1,output!==null&&output!==void 0)output.on(\"resize\",this[kOnResize]);this.once(\"close\",this[kOnSelfCloseWithTerminal])}if(signal){var onAborted=(()=>this.close()).bind(this);if(signal.aborted)process.nextTick(onAborted);else signal.addEventListener(\"abort\",onAborted,{once:!0}),this.once(\"close\",()=>signal.removeEventListener(\"abort\",onAborted))}this.line=\"\",input.resume()}InterfaceConstructor.prototype={},ObjectSetPrototypeOf(InterfaceConstructor.prototype,EventEmitter.prototype);var _Interface=class Interface2 extends InterfaceConstructor{constructor(input,output,completer,terminal){super(input,output,completer,terminal)}get columns(){var output=this.output;if(output&&output.columns)return output.columns;return Infinity}setPrompt(prompt){this[kPrompt]=prompt}getPrompt(){return this[kPrompt]}[kSetRawMode](mode){var input=this.input,{setRawMode,wasInRawMode}=input;return debug(\"setRawMode\",mode,\"set!\"),wasInRawMode}prompt(preserveCursor){if(this.paused)this.resume();if(this.terminal&&process.env.TERM!==\"dumb\"){if(!preserveCursor)this.cursor=0;this[kRefreshLine]()}else this[kWriteToOutput](this[kPrompt])}[kQuestion](query,cb){if(this.closed)throw new ERR_USE_AFTER_CLOSE(\"readline\");if(this[kQuestionCallback])this.prompt();else this[kOldPrompt]=this[kPrompt],this.setPrompt(query),this[kQuestionCallback]=cb,this.prompt()}[kOnLine](line){if(this[kQuestionCallback]){var cb=this[kQuestionCallback];this[kQuestionCallback]=null,this.setPrompt(this[kOldPrompt]),cb(line)}else this.emit(\"line\",line)}[kBeforeEdit](oldText,oldCursor){this[kPushToUndoStack](oldText,oldCursor)}[kQuestionCancel](){if(this[kQuestionCallback])this[kQuestionCallback]=null,this.setPrompt(this[kOldPrompt]),this.clearLine()}[kWriteToOutput](stringToWrite){if(validateString(stringToWrite,\"stringToWrite\"),this.output!==null&&this.output!==void 0)this.output.write(stringToWrite)}[kAddHistory](){if(this.line.length===0)return\"\";if(this.historySize===0)return this.line;if(StringPrototypeTrim.call(this.line).length===0)return this.line;if(this.history.length===0||this.history[0]!==this.line){if(this.removeHistoryDuplicates){var dupIndex=ArrayPrototypeIndexOf.call(this.history,this.line);if(dupIndex!==-1)ArrayPrototypeSplice.call(this.history,dupIndex,1)}if(ArrayPrototypeUnshift.call(this.history,this.line),this.history.length>this.historySize)ArrayPrototypePop.call(this.history)}this.historyIndex=-1;var line=this.history[0];return this.emit(\"history\",this.history),line}[kRefreshLine](){var line=this[kPrompt]+this.line,dispPos=this[kGetDisplayPos](line),lineCols=dispPos.cols,lineRows=dispPos.rows,cursorPos=this.getCursorPos(),prevRows=this.prevRows||0;if(prevRows>0)moveCursor(this.output,0,-prevRows);if(cursorTo(this.output,0),clearScreenDown(this.output),this[kWriteToOutput](line),lineCols===0)this[kWriteToOutput](\" \");cursorTo(this.output,cursorPos.cols);var diff=lineRows-cursorPos.rows;if(diff>0)moveCursor(this.output,0,-diff);this.prevRows=cursorPos.rows}close(){if(this.closed)return;if(this.pause(),this.terminal)this[kSetRawMode](!1);this.closed=!0,this.emit(\"close\")}pause(){if(this.paused)return;return this.input.pause(),this.paused=!0,this.emit(\"pause\"),this}resume(){if(!this.paused)return;return this.input.resume(),this.paused=!1,this.emit(\"resume\"),this}write(d,key){if(this.paused)this.resume();if(this.terminal)this[kTtyWrite](d,key);else this[kNormalWrite](d)}[kNormalWrite](b){if(b===void 0)return;var string=this[kDecoder].write(b);if(this[kSawReturnAt]&&DateNow()-this[kSawReturnAt]<=this.crlfDelay){if(StringPrototypeCodePointAt.call(string)===10)string=StringPrototypeSlice.call(string,1);this[kSawReturnAt]=0}var newPartContainsEnding=RegExpPrototypeExec.call(lineEnding,string);if(newPartContainsEnding!==null){if(this[kLine_buffer])string=this[kLine_buffer]+string,this[kLine_buffer]=null,newPartContainsEnding=RegExpPrototypeExec.call(lineEnding,string);this[kSawReturnAt]=StringPrototypeEndsWith.call(string,\"\\r\")\?DateNow():0;var indexes=[0,newPartContainsEnding.index,lineEnding.lastIndex],nextMatch;while((nextMatch=RegExpPrototypeExec.call(lineEnding,string))!==null)ArrayPrototypePush.call(indexes,nextMatch.index,lineEnding.lastIndex);var lastIndex=indexes.length-1;this[kLine_buffer]=StringPrototypeSlice.call(string,indexes[lastIndex]);for(var i=1;ie!==\"\"));if(StringPrototypeStartsWith.call(prefix,completeOn)&&prefix.length>completeOn.length){this[kInsertString](StringPrototypeSlice.call(prefix,completeOn.length));return}else if(!StringPrototypeStartsWith.call(completeOn,prefix)){this.line=StringPrototypeSlice.call(this.line,0,this.cursor-completeOn.length)+prefix+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor=this.cursor-completeOn.length+prefix.length,this._refreshLine();return}if(!lastKeypressWasTab)return;this[kBeforeEdit](this.line,this.cursor);var completionsWidth=ArrayPrototypeMap.call(completions,(e)=>getStringWidth(e)),width=MathMaxApply(completionsWidth)+2,maxColumns=MathFloor(this.columns/width)||1;if(maxColumns===Infinity)maxColumns=1;var output=\"\\r\\n\",lineIndex=0,whitespace=0;for(var i=0;i0){var leading=StringPrototypeSlice.call(this.line,0,this.cursor),reversed=ArrayPrototypeJoin.call(ArrayPrototypeReverse.call(ArrayFrom(leading)),\"\"),match=RegExpPrototypeExec.call(/^\\s*(\?:[^\\w\\s]+|\\w+)\?/,reversed);this[kMoveCursor](-match[0].length)}}[kWordRight](){if(this.cursor0&&this.line.length>0){this[kBeforeEdit](this.line,this.cursor);var charSize=charLengthLeft(this.line,this.cursor);this.line=StringPrototypeSlice.call(this.line,0,this.cursor-charSize)+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor-=charSize,this[kRefreshLine]()}}[kDeleteRight](){if(this.cursor0){this[kBeforeEdit](this.line,this.cursor);var leading=StringPrototypeSlice.call(this.line,0,this.cursor),reversed=ArrayPrototypeJoin.call(ArrayPrototypeReverse.call(ArrayFrom(leading)),\"\"),match=RegExpPrototypeExec.call(/^\\s*(\?:[^\\w\\s]+|\\w+)\?/,reversed);leading=StringPrototypeSlice.call(leading,0,leading.length-match[0].length),this.line=leading+StringPrototypeSlice.call(this.line,this.cursor,this.line.length),this.cursor=leading.length,this[kRefreshLine]()}}[kDeleteWordRight](){if(this.cursorkMaxLengthOfKillRing)ArrayPrototypePop.call(this[kKillRing])}[kYank](){if(this[kKillRing].length>0)this[kYanking]=!0,this[kInsertString](this[kKillRing][this[kKillRingCursor]])}[kYankPop](){if(!this[kYanking])return;if(this[kKillRing].length>1){var lastYank=this[kKillRing][this[kKillRingCursor]];if(this[kKillRingCursor]++,this[kKillRingCursor]>=this[kKillRing].length)this[kKillRingCursor]=0;var currentYank=this[kKillRing][this[kKillRingCursor]],head=StringPrototypeSlice.call(this.line,0,this.cursor-lastYank.length),tail=StringPrototypeSlice.call(this.line,this.cursor);this.line=head+currentYank+tail,this.cursor=head.length+currentYank.length,this[kRefreshLine]()}}clearLine(){this[kMoveCursor](Infinity),this[kWriteToOutput](\"\\r\\n\"),this.line=\"\",this.cursor=0,this.prevRows=0}[kLine](){var line=this[kAddHistory]();this[kUndoStack]=[],this[kRedoStack]=[],this.clearLine(),this[kOnLine](line)}[kPushToUndoStack](text,cursor){if(ArrayPrototypePush.call(this[kUndoStack],{text,cursor})>kMaxUndoRedoStackSize)ArrayPrototypeShift.call(this[kUndoStack])}[kUndo](){if(this[kUndoStack].length<=0)return;ArrayPrototypePush.call(this[kRedoStack],{text:this.line,cursor:this.cursor});var entry=ArrayPrototypePop.call(this[kUndoStack]);this.line=entry.text,this.cursor=entry.cursor,this[kRefreshLine]()}[kRedo](){if(this[kRedoStack].length<=0)return;ArrayPrototypePush.call(this[kUndoStack],{text:this.line,cursor:this.cursor});var entry=ArrayPrototypePop.call(this[kRedoStack]);this.line=entry.text,this.cursor=entry.cursor,this[kRefreshLine]()}[kHistoryNext](){if(this.historyIndex>=0){this[kBeforeEdit](this.line,this.cursor);var search=this[kSubstringSearch]||\"\",index=this.historyIndex-1;while(index>=0&&(!StringPrototypeStartsWith.call(this.history[index],search)||this.line===this.history[index]))index--;if(index===-1)this.line=search;else this.line=this.history[index];this.historyIndex=index,this.cursor=this.line.length,this[kRefreshLine]()}}[kHistoryPrev](){if(this.historyIndexthis.line.length)this.cursor=this.line.length;var newPos=this.getCursorPos();if(oldPos.rows===newPos.rows){var diffWidth=newPos.cols-oldPos.cols;moveCursor(this.output,diffWidth,0)}else this[kRefreshLine]()}[kTtyWrite](s,key){var previousKey=this[kPreviousKey];key=key||kEmptyObject,this[kPreviousKey]=key;var{name:keyName,meta:keyMeta,ctrl:keyCtrl2,shift:keyShift,sequence:keySeq}=key;if(!keyMeta||keyName!==\"y\")this[kYanking]=!1;if((keyName===\"up\"||keyName===\"down\")&&!keyCtrl2&&!keyMeta&&!keyShift){if(this[kSubstringSearch]===null)this[kSubstringSearch]=StringPrototypeSlice.call(this.line,0,this.cursor)}else if(this[kSubstringSearch]!==null){if(this[kSubstringSearch]=null,this.history.length===this.historyIndex)this.historyIndex=-1}if(typeof keySeq===\"string\")switch(StringPrototypeCodePointAt.call(keySeq,0)){case 31:this[kUndo]();return;case 30:this[kRedo]();return;default:break}if(keyName===\"escape\")return;if(keyCtrl2&&keyShift)switch(keyName){case\"backspace\":this[kDeleteLineLeft]();break;case\"delete\":this[kDeleteLineRight]();break}else if(keyCtrl2)switch(keyName){case\"c\":if(this.listenerCount(\"SIGINT\")>0)this.emit(\"SIGINT\");else this.close();break;case\"h\":this[kDeleteLeft]();break;case\"d\":if(this.cursor===0&&this.line.length===0)this.close();else if(this.cursor0)this.emit(\"SIGTSTP\");else process.once(\"SIGCONT\",()=>{if(!this.paused)this.pause(),this.emit(\"SIGCONT\");this[kSetRawMode](!0),this[kRefreshLine]()}),this[kSetRawMode](!1),process.kill(process.pid,\"SIGTSTP\");break;case\"w\":case\"backspace\":this[kDeleteWordLeft]();break;case\"delete\":this[kDeleteWordRight]();break;case\"left\":this[kWordLeft]();break;case\"right\":this[kWordRight]();break}else if(keyMeta)switch(keyName){case\"b\":this[kWordLeft]();break;case\"f\":this[kWordRight]();break;case\"d\":case\"delete\":this[kDeleteWordRight]();break;case\"backspace\":this[kDeleteWordLeft]();break;case\"y\":this[kYankPop]();break}else{if(this[kSawReturnAt]&&keyName!==\"enter\")this[kSawReturnAt]=0;switch(keyName){case\"return\":this[kSawReturnAt]=DateNow(),this[kLine]();break;case\"enter\":if(this[kSawReturnAt]===0||DateNow()-this[kSawReturnAt]>this.crlfDelay)this[kLine]();this[kSawReturnAt]=0;break;case\"backspace\":this[kDeleteLeft]();break;case\"delete\":this[kDeleteRight]();break;case\"left\":this[kMoveCursor](-charLengthLeft(this.line,this.cursor));break;case\"right\":this[kMoveCursor](+charLengthAt(this.line,this.cursor));break;case\"home\":this[kMoveCursor]((-Infinity));break;case\"end\":this[kMoveCursor](Infinity);break;case\"up\":this[kHistoryPrev]();break;case\"down\":this[kHistoryNext]();break;case\"tab\":if(typeof this.completer===\"function\"&&this.isCompletionEnabled){var lastKeypressWasTab=previousKey&&previousKey.name===\"tab\";this[kTabComplete](lastKeypressWasTab);break}default:if(typeof s===\"string\"&&s){var nextMatch=RegExpPrototypeExec.call(lineEnding,s);if(nextMatch!==null){this[kInsertString](StringPrototypeSlice.call(s,0,nextMatch.index));var{lastIndex}=lineEnding;while((nextMatch=RegExpPrototypeExec.call(lineEnding,s))!==null)this[kLine](),this[kInsertString](StringPrototypeSlice.call(s,lastIndex,nextMatch.index)),{lastIndex}=lineEnding;if(lastIndex===s.length)this[kLine]()}else this[kInsertString](s)}}}}[SymbolAsyncIterator](){if(this[kLineObjectStream]===void 0)this[kLineObjectStream]=EventEmitter.on(this,\"line\",{close:[\"close\"],highWatermark:1024,[kFirstEventParam]:!0});return this[kLineObjectStream]}};function Interface(input,output,completer,terminal){if(!(this instanceof Interface))return new Interface(input,output,completer,terminal);if(input\?.input&&typeof input.completer===\"function\"&&input.completer.length!==2){var{completer}=input;input.completer=(v,cb)=>cb(null,completer(v))}else if(typeof completer===\"function\"&&completer.length!==2){var realCompleter=completer;completer=(v,cb)=>cb(null,realCompleter(v))}if(InterfaceConstructor.call(this,input,output,completer,terminal),process.env.TERM===\"dumb\")this._ttyWrite=_ttyWriteDumb.bind(this)}Interface.prototype={},ObjectSetPrototypeOf(Interface.prototype,_Interface.prototype),ObjectSetPrototypeOf(Interface,_Interface),Interface.prototype.question=function question(query,options,cb){if(cb=typeof options===\"function\"\?options:cb,options===null||typeof options!==\"object\")options=kEmptyObject;var signal=options\?.signal;if(signal){if(validateAbortSignal(signal,\"options.signal\"),signal.aborted)return;var onAbort=()=>{this[kQuestionCancel]()};signal.addEventListener(\"abort\",onAbort,{once:!0});var cleanup=()=>{signal.removeEventListener(\"abort\",onAbort)},originalCb=cb;cb=typeof cb===\"function\"\?(answer)=>{return cleanup(),originalCb(answer)}:cleanup}if(typeof cb===\"function\")this[kQuestion](query,cb)},Interface.prototype.question[promisify.custom]=function question(query,options){if(options===null||typeof options!==\"object\")options=kEmptyObject;var signal=options\?.signal;if(signal&&signal.aborted)return PromiseReject(new AbortError(void 0,{cause:signal.reason}));return new Promise((resolve,reject)=>{var cb=resolve;if(signal){var onAbort=()=>{reject(new AbortError(void 0,{cause:signal.reason}))};signal.addEventListener(\"abort\",onAbort,{once:!0}),cb=(answer)=>{signal.removeEventListener(\"abort\",onAbort),resolve(answer)}}this.question(query,options,cb)})};function createInterface(input,output,completer,terminal){return new Interface(input,output,completer,terminal)}ObjectDefineProperties(Interface.prototype,{[kSetRawMode]:{__proto__:null,get(){return this._setRawMode}},[kOnLine]:{__proto__:null,get(){return this._onLine}},[kWriteToOutput]:{__proto__:null,get(){return this._writeToOutput}},[kAddHistory]:{__proto__:null,get(){return this._addHistory}},[kRefreshLine]:{__proto__:null,get(){return this._refreshLine}},[kNormalWrite]:{__proto__:null,get(){return this._normalWrite}},[kInsertString]:{__proto__:null,get(){return this._insertString}},[kTabComplete]:{__proto__:null,get(){return this._tabComplete}},[kWordLeft]:{__proto__:null,get(){return this._wordLeft}},[kWordRight]:{__proto__:null,get(){return this._wordRight}},[kDeleteLeft]:{__proto__:null,get(){return this._deleteLeft}},[kDeleteRight]:{__proto__:null,get(){return this._deleteRight}},[kDeleteWordLeft]:{__proto__:null,get(){return this._deleteWordLeft}},[kDeleteWordRight]:{__proto__:null,get(){return this._deleteWordRight}},[kDeleteLineLeft]:{__proto__:null,get(){return this._deleteLineLeft}},[kDeleteLineRight]:{__proto__:null,get(){return this._deleteLineRight}},[kLine]:{__proto__:null,get(){return this._line}},[kHistoryNext]:{__proto__:null,get(){return this._historyNext}},[kHistoryPrev]:{__proto__:null,get(){return this._historyPrev}},[kGetDisplayPos]:{__proto__:null,get(){return this._getDisplayPos}},[kMoveCursor]:{__proto__:null,get(){return this._moveCursor}},[kTtyWrite]:{__proto__:null,get(){return this._ttyWrite}},_decoder:{__proto__:null,get(){return this[kDecoder]},set(value){this[kDecoder]=value}},_line_buffer:{__proto__:null,get(){return this[kLine_buffer]},set(value){this[kLine_buffer]=value}},_oldPrompt:{__proto__:null,get(){return this[kOldPrompt]},set(value){this[kOldPrompt]=value}},_previousKey:{__proto__:null,get(){return this[kPreviousKey]},set(value){this[kPreviousKey]=value}},_prompt:{__proto__:null,get(){return this[kPrompt]},set(value){this[kPrompt]=value}},_questionCallback:{__proto__:null,get(){return this[kQuestionCallback]},set(value){this[kQuestionCallback]=value}},_sawKeyPress:{__proto__:null,get(){return this[kSawKeyPress]},set(value){this[kSawKeyPress]=value}},_sawReturnAt:{__proto__:null,get(){return this[kSawReturnAt]},set(value){this[kSawReturnAt]=value}}}),Interface.prototype._setRawMode=_Interface.prototype[kSetRawMode],Interface.prototype._onLine=_Interface.prototype[kOnLine],Interface.prototype._writeToOutput=_Interface.prototype[kWriteToOutput],Interface.prototype._addHistory=_Interface.prototype[kAddHistory],Interface.prototype._refreshLine=_Interface.prototype[kRefreshLine],Interface.prototype._normalWrite=_Interface.prototype[kNormalWrite],Interface.prototype._insertString=_Interface.prototype[kInsertString],Interface.prototype._tabComplete=function(lastKeypressWasTab){this.pause();var string=StringPrototypeSlice.call(this.line,0,this.cursor);this.completer(string,(err,value)=>{if(this.resume(),err){this._writeToOutput(`Tab completion error: ${inspect(err)}`);return}this[kTabCompleter](lastKeypressWasTab,value)})},Interface.prototype._wordLeft=_Interface.prototype[kWordLeft],Interface.prototype._wordRight=_Interface.prototype[kWordRight],Interface.prototype._deleteLeft=_Interface.prototype[kDeleteLeft],Interface.prototype._deleteRight=_Interface.prototype[kDeleteRight],Interface.prototype._deleteWordLeft=_Interface.prototype[kDeleteWordLeft],Interface.prototype._deleteWordRight=_Interface.prototype[kDeleteWordRight],Interface.prototype._deleteLineLeft=_Interface.prototype[kDeleteLineLeft],Interface.prototype._deleteLineRight=_Interface.prototype[kDeleteLineRight],Interface.prototype._line=_Interface.prototype[kLine],Interface.prototype._historyNext=_Interface.prototype[kHistoryNext],Interface.prototype._historyPrev=_Interface.prototype[kHistoryPrev],Interface.prototype._getDisplayPos=_Interface.prototype[kGetDisplayPos],Interface.prototype._getCursorPos=_Interface.prototype.getCursorPos,Interface.prototype._moveCursor=_Interface.prototype[kMoveCursor],Interface.prototype._ttyWrite=_Interface.prototype[kTtyWrite];function _ttyWriteDumb(s,key){if(key=key||kEmptyObject,key.name===\"escape\")return;if(this[kSawReturnAt]&&key.name!==\"enter\")this[kSawReturnAt]=0;if(keyCtrl){if(key.name===\"c\"){if(this.listenerCount(\"SIGINT\")>0)this.emit(\"SIGINT\");else this.close();return}else if(key.name===\"d\"){this.close();return}}switch(key.name){case\"return\":this[kSawReturnAt]=DateNow(),this._line();break;case\"enter\":if(this[kSawReturnAt]===0||DateNow()-this[kSawReturnAt]>this.crlfDelay)this._line();this[kSawReturnAt]=0;break;default:if(typeof s===\"string\"&&s)this.line+=s,this.cursor+=s.length,this._writeToOutput(s)}}class Readline{#autoCommit=!1;#stream;#todo=[];constructor(stream,options=void 0){if(isWritable\?\?=(@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34)).isWritable,!isWritable(stream))throw new ERR_INVALID_ARG_TYPE(\"stream\",\"Writable\",stream);if(this.#stream=stream,options\?.autoCommit!=null)validateBoolean(options.autoCommit,\"options.autoCommit\"),this.#autoCommit=options.autoCommit}cursorTo(x,y=void 0){if(validateInteger(x,\"x\"),y!=null)validateInteger(y,\"y\");var data=y==null\?CSI`${x+1}G`:CSI`${y+1};${x+1}H`;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data);return this}moveCursor(dx,dy){if(dx||dy){validateInteger(dx,\"dx\"),validateInteger(dy,\"dy\");var data=\"\";if(dx<0)data+=CSI`${-dx}D`;else if(dx>0)data+=CSI`${dx}C`;if(dy<0)data+=CSI`${-dy}A`;else if(dy>0)data+=CSI`${dy}B`;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data)}return this}clearLine(dir){validateInteger(dir,\"dir\",-1,1);var data=dir<0\?kClearToLineBeginning:dir>0\?kClearToLineEnd:kClearLine;if(this.#autoCommit)process.nextTick(()=>this.#stream.write(data));else ArrayPrototypePush.call(this.#todo,data);return this}clearScreenDown(){if(this.#autoCommit)process.nextTick(()=>this.#stream.write(kClearScreenDown));else ArrayPrototypePush.call(this.#todo,kClearScreenDown);return this}commit(){return new Promise((resolve)=>{this.#stream.write(ArrayPrototypeJoin.call(this.#todo,\"\"),resolve),this.#todo=[]})}rollback(){return this.#todo=[],this}}var PromisesInterface=class Interface2 extends _Interface{constructor(input,output,completer,terminal){super(input,output,completer,terminal)}question(query,options=kEmptyObject){var signal=options\?.signal;if(signal){if(validateAbortSignal(signal,\"options.signal\"),signal.aborted)return PromiseReject(new AbortError(void 0,{cause:signal.reason}))}return new Promise((resolve,reject)=>{var cb=resolve;if(options\?.signal){var onAbort=()=>{this[kQuestionCancel](),reject(new AbortError(void 0,{cause:signal.reason}))};signal.addEventListener(\"abort\",onAbort,{once:!0}),cb=(answer)=>{signal.removeEventListener(\"abort\",onAbort),resolve(answer)}}this[kQuestion](query,cb)})}};return $={Interface,clearLine,clearScreenDown,createInterface,cursorTo,emitKeypressEvents,moveCursor,promises:{Readline,Interface:PromisesInterface,createInterface(input,output,completer,terminal){return new PromisesInterface(input,output,completer,terminal)}},[SymbolFor(\"__BUN_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__\")]:{CSI,utils:{getStringWidth,stripVTControlCharacters}}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeReadlinePromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,30)||@createInternalModuleById(30)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeReplCode = "(function (){\"use strict\";var $;const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2);function REPLServer(){throwNotImplemented(\"node:repl REPLServer\")}function Recoverable(){throwNotImplemented(\"node:repl Recoverable\")}var REPL_MODE_SLOPPY=0,REPL_MODE_STRICT=1;function start(){throwNotImplemented(\"node:repl\")}return $={lines:[],context:globalThis,historyIndex:-1,cursor:0,historySize:1000,removeHistoryDuplicates:!1,crlfDelay:100,completer:()=>{throwNotImplemented(\"node:repl\")},history:[],_initialPrompt:\"> \",terminal:!0,input:new Proxy({},{get(){throwNotImplemented(\"node:repl\")},has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{return},set(){throwNotImplemented(\"node:repl\")}}),line:\"\",eval:()=>{throwNotImplemented(\"node:repl\")},isCompletionEnabled:!0,escapeCodeTimeout:500,tabSize:8,breakEvalOnSigint:!0,useGlobal:!0,underscoreAssigned:!1,last:void 0,_domain:void 0,allowBlockingCompletions:!1,useColors:!0,output:new Proxy({},{get(){throwNotImplemented(\"node:repl\")},has:()=>!1,ownKeys:()=>[],getOwnPropertyDescriptor:()=>{return},set(){throwNotImplemented(\"node:repl\")}})},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamConsumersCode = "(function (){\"use strict\";const{readableStreamToArrayBuffer:arrayBuffer,readableStreamToText:text}=Bun,json=(stream)=>Bun.readableStreamToText(stream).then(JSON.parse),buffer=async(readableStream)=>{return new Buffer(await arrayBuffer(readableStream))},blob=Bun.readableStreamToBlob;return{arrayBuffer,text,json,buffer,blob}})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamCode = "(function (){\"use strict\";const EE=globalThis[globalThis.Symbol.for('Bun.lazy')](\"events\"),StringDecoder=@requireNativeModule(\"node:string_decoder\").StringDecoder;var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require2(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},runOnNextTick=process.nextTick;function isReadableStream(value){return typeof value===\"object\"&&value!==null&&value instanceof ReadableStream}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}const validateObject=(value,name,options=null)=>{const allowArray=options\?.allowArray\?\?!1,allowFunction=options\?.allowFunction\?\?!1;if(!(options\?.nullable\?\?!1)&&value===null||!allowArray&&ArrayIsArray(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE(name,\"Object\",value)};function validateString(value,name){if(typeof value!==\"string\")throw new ERR_INVALID_ARG_TYPE(name,\"string\",value)}var ArrayIsArray=Array.isArray;function ERR_INVALID_ARG_TYPE(name,type,value){return new Error(`The argument '${name}' is invalid. Received '${value}' for type '${type}'`)}function ERR_INVALID_ARG_VALUE(name,value,reason){return new Error(`The value '${value}' is invalid for argument '${name}'. Reason: ${reason}`)}var require_primordials=__commonJS({\"node_modules/readable-stream/lib/ours/primordials.js\"(exports2,module){module.exports={ArrayIsArray(self){return Array.isArray(self)},ArrayPrototypeIncludes(self,el){return self.includes(el)},ArrayPrototypeIndexOf(self,el){return self.indexOf(el)},ArrayPrototypeJoin(self,sep){return self.join(sep)},ArrayPrototypeMap(self,fn){return self.map(fn)},ArrayPrototypePop(self,el){return self.pop(el)},ArrayPrototypePush(self,el){return self.push(el)},ArrayPrototypeSlice(self,start,end){return self.slice(start,end)},Error,FunctionPrototypeCall(fn,thisArgs,...args){return fn.call(thisArgs,...args)},FunctionPrototypeSymbolHasInstance(self,instance){return Function.prototype[Symbol.hasInstance].call(self,instance)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(self,props){return Object.defineProperties(self,props)},ObjectDefineProperty(self,name,prop){return Object.defineProperty(self,name,prop)},ObjectGetOwnPropertyDescriptor(self,name){return Object.getOwnPropertyDescriptor(self,name)},ObjectKeys(obj){return Object.keys(obj)},ObjectSetPrototypeOf(target,proto){return Object.setPrototypeOf(target,proto)},Promise,PromisePrototypeCatch(self,fn){return self.catch(fn)},PromisePrototypeThen(self,thenFn,catchFn){return self.then(thenFn,catchFn)},PromiseReject(err){return Promise.reject(err)},ReflectApply:Reflect.apply,RegExpPrototypeTest(self,value){return self.test(value)},SafeSet:Set,String,StringPrototypeSlice(self,start,end){return self.slice(start,end)},StringPrototypeToLowerCase(self){return self.toLowerCase()},StringPrototypeToUpperCase(self){return self.toUpperCase()},StringPrototypeTrim(self){return self.trim()},Symbol,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(self,buf,len){return self.set(buf,len)},Uint8Array}}}),require_util=__commonJS({\"node_modules/readable-stream/lib/ours/util.js\"(exports2,module){var AsyncFunction=Object.getPrototypeOf(async function(){}).constructor,isBlob=typeof Blob!==\"undefined\"\?function isBlob2(b){return b instanceof Blob}:function isBlob2(b){return!1},AggregateError=class extends Error{constructor(errors){if(!Array.isArray(errors))@throwTypeError(`Expected input to be an Array, got ${typeof errors}`);let message=\"\";for(let i=0;i{resolve=res,reject=rej}),resolve,reject}},promisify(fn){return new Promise((resolve,reject)=>{fn((err,...args)=>{if(err)return reject(err);return resolve(...args)})})},debuglog(){return function(){}},format(format,...args){return format.replace(/%([sdifj])/g,function(...[_unused,type]){const replacement=args.shift();if(type===\"f\")return replacement.toFixed(6);else if(type===\"j\")return JSON.stringify(replacement);else if(type===\"s\"&&typeof replacement===\"object\")return`${replacement.constructor!==Object\?replacement.constructor.name:\"\"} {}`.trim();else return replacement.toString()})},inspect(value){switch(typeof value){case\"string\":if(value.includes(\"'\")){if(!value.includes('\"'))return`\"${value}\"`;else if(!value.includes(\"`\")&&!value.includes(\"${\"))return`\\`${value}\\``}return`'${value}'`;case\"number\":if(isNaN(value))return\"NaN\";else if(Object.is(value,-0))return String(value);return value;case\"bigint\":return`${String(value)}n`;case\"boolean\":case\"undefined\":return String(value);case\"object\":return\"{}\"}},types:{isAsyncFunction(fn){return fn instanceof AsyncFunction},isArrayBufferView(arr){return ArrayBuffer.isView(arr)}},isBlob},module.exports.promisify.custom=Symbol.for(\"nodejs.util.promisify.custom\")}}),require_errors=__commonJS({\"node_modules/readable-stream/lib/ours/errors.js\"(exports2,module){var{format,inspect,AggregateError:CustomAggregateError}=require_util(),AggregateError=globalThis.AggregateError||CustomAggregateError,kIsNodeError=Symbol(\"kIsNodeError\"),kTypes=[\"string\",\"function\",\"number\",\"object\",\"Function\",\"Object\",\"boolean\",\"bigint\",\"symbol\"],classRegExp=/^([A-Z][a-z0-9]*)+$/,nodeInternalPrefix=\"__node_internal_\",codes={};function assert(value,message){if(!value)throw new codes.ERR_INTERNAL_ASSERTION(message)}function addNumericalSeparator(val){let res=\"\",i=val.length;const start=val[0]===\"-\"\?1:0;for(;i>=start+4;i-=3)res=`_${val.slice(i-3,i)}${res}`;return`${val.slice(0,i)}${res}`}function getMessage(key,msg,args){if(typeof msg===\"function\")return assert(msg.length<=args.length,`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${msg.length}).`),msg(...args);const expectedLength=(msg.match(/%[dfijoOs]/g)||[]).length;if(assert(expectedLength===args.length,`Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`),args.length===0)return msg;return format(msg,...args)}function E(code,message,Base){if(!Base)Base=Error;class NodeError extends Base{constructor(...args){super(getMessage(code,message,args))}toString(){return`${this.name} [${code}]: ${this.message}`}}Object.defineProperties(NodeError.prototype,{name:{value:Base.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${code}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),NodeError.prototype.code=code,NodeError.prototype[kIsNodeError]=!0,codes[code]=NodeError}function hideStackFrames(fn){const hidden=nodeInternalPrefix+fn.name;return Object.defineProperty(fn,\"name\",{value:hidden}),fn}function aggregateTwoErrors(innerError,outerError){if(innerError&&outerError&&innerError!==outerError){if(Array.isArray(outerError.errors))return outerError.errors.push(innerError),outerError;const err=new AggregateError([outerError,innerError],outerError.message);return err.code=outerError.code,err}return innerError||outerError}var AbortError2=class extends Error{constructor(message=\"The operation was aborted\",options=void 0){if(options!==void 0&&typeof options!==\"object\")throw new codes.ERR_INVALID_ARG_TYPE(\"options\",\"Object\",options);super(message,options);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};E(\"ERR_ASSERTION\",\"%s\",Error),E(\"ERR_INVALID_ARG_TYPE\",(name,expected,actual)=>{if(assert(typeof name===\"string\",\"'name' must be a string\"),!Array.isArray(expected))expected=[expected];let msg=\"The \";if(name.endsWith(\" argument\"))msg+=`${name} `;else msg+=`\"${name}\" ${name.includes(\".\")\?\"property\":\"argument\"} `;msg+=\"must be \";const types=[],instances=[],other=[];for(let value of expected)if(assert(typeof value===\"string\",\"All expected entries have to be of type string\"),kTypes.includes(value))types.push(value.toLowerCase());else if(classRegExp.test(value))instances.push(value);else assert(value!==\"object\",'The value \"object\" should be written as \"Object\"'),other.push(value);if(instances.length>0){const pos=types.indexOf(\"object\");if(pos!==-1)types.splice(types,pos,1),instances.push(\"Object\")}if(types.length>0){switch(types.length){case 1:msg+=`of type ${types[0]}`;break;case 2:msg+=`one of type ${types[0]} or ${types[1]}`;break;default:{const last=types.pop();msg+=`one of type ${types.join(\", \")}, or ${last}`}}if(instances.length>0||other.length>0)msg+=\" or \"}if(instances.length>0){switch(instances.length){case 1:msg+=`an instance of ${instances[0]}`;break;case 2:msg+=`an instance of ${instances[0]} or ${instances[1]}`;break;default:{const last=instances.pop();msg+=`an instance of ${instances.join(\", \")}, or ${last}`}}if(other.length>0)msg+=\" or \"}switch(other.length){case 0:break;case 1:if(other[0].toLowerCase()!==other[0])msg+=\"an \";msg+=`${other[0]}`;break;case 2:msg+=`one of ${other[0]} or ${other[1]}`;break;default:{const last=other.pop();msg+=`one of ${other.join(\", \")}, or ${last}`}}if(actual==null)msg+=`. Received ${actual}`;else if(typeof actual===\"function\"&&actual.name)msg+=`. Received function ${actual.name}`;else if(typeof actual===\"object\"){var _actual$constructor;if((_actual$constructor=actual.constructor)!==null&&_actual$constructor!==void 0&&_actual$constructor.name)msg+=`. Received an instance of ${actual.constructor.name}`;else{const inspected=inspect(actual,{depth:-1});msg+=`. Received ${inspected}`}}else{let inspected=inspect(actual,{colors:!1});if(inspected.length>25)inspected=`${inspected.slice(0,25)}...`;msg+=`. Received type ${typeof actual} (${inspected})`}return msg},TypeError),E(\"ERR_INVALID_ARG_VALUE\",(name,value,reason=\"is invalid\")=>{let inspected=inspect(value);if(inspected.length>128)inspected=inspected.slice(0,128)+\"...\";return`The ${name.includes(\".\")\?\"property\":\"argument\"} '${name}' ${reason}. Received ${inspected}`},TypeError),E(\"ERR_INVALID_RETURN_VALUE\",(input,name,value)=>{var _value$constructor;const type=value!==null&&value!==void 0&&(_value$constructor=value.constructor)!==null&&_value$constructor!==void 0&&_value$constructor.name\?`instance of ${value.constructor.name}`:`type ${typeof value}`;return`Expected ${input} to be returned from the \"${name}\" function but got ${type}.`},TypeError),E(\"ERR_MISSING_ARGS\",(...args)=>{assert(args.length>0,\"At least one arg needs to be specified\");let msg;const len=args.length;switch(args=(Array.isArray(args)\?args:[args]).map((a)=>`\"${a}\"`).join(\" or \"),len){case 1:msg+=`The ${args[0]} argument`;break;case 2:msg+=`The ${args[0]} and ${args[1]} arguments`;break;default:{const last=args.pop();msg+=`The ${args.join(\", \")}, and ${last} arguments`}break}return`${msg} must be specified`},TypeError),E(\"ERR_OUT_OF_RANGE\",(str,range,input)=>{assert(range,'Missing \"range\" argument');let received;if(Number.isInteger(input)&&Math.abs(input)>4294967296)received=addNumericalSeparator(String(input));else if(typeof input===\"bigint\"){if(received=String(input),input>2n**32n||input<-(2n**32n))received=addNumericalSeparator(received);received+=\"n\"}else received=inspect(input);return`The value of \"${str}\" is out of range. It must be ${range}. Received ${received}`},RangeError),E(\"ERR_MULTIPLE_CALLBACK\",\"Callback called multiple times\",Error),E(\"ERR_METHOD_NOT_IMPLEMENTED\",\"The %s method is not implemented\",Error),E(\"ERR_STREAM_ALREADY_FINISHED\",\"Cannot call %s after a stream was finished\",Error),E(\"ERR_STREAM_CANNOT_PIPE\",\"Cannot pipe, not readable\",Error),E(\"ERR_STREAM_DESTROYED\",\"Cannot call %s after a stream was destroyed\",Error),E(\"ERR_STREAM_NULL_VALUES\",\"May not write null values to stream\",TypeError),E(\"ERR_STREAM_PREMATURE_CLOSE\",\"Premature close\",Error),E(\"ERR_STREAM_PUSH_AFTER_EOF\",\"stream.push() after EOF\",Error),E(\"ERR_STREAM_UNSHIFT_AFTER_END_EVENT\",\"stream.unshift() after end event\",Error),E(\"ERR_STREAM_WRITE_AFTER_END\",\"write after end\",Error),E(\"ERR_UNKNOWN_ENCODING\",\"Unknown encoding: %s\",TypeError),module.exports={AbortError:AbortError2,aggregateTwoErrors:hideStackFrames(aggregateTwoErrors),hideStackFrames,codes}}}),require_validators=__commonJS({\"node_modules/readable-stream/lib/internal/validators.js\"(exports2,module){var{ArrayIsArray:ArrayIsArray2,ArrayPrototypeIncludes,ArrayPrototypeJoin,ArrayPrototypeMap,NumberIsInteger,NumberMAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER,NumberParseInt,RegExpPrototypeTest,String:String2,StringPrototypeToUpperCase,StringPrototypeTrim}=require_primordials(),{hideStackFrames,codes:{ERR_SOCKET_BAD_PORT,ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2,ERR_OUT_OF_RANGE,ERR_UNKNOWN_SIGNAL}}=require_errors(),{normalizeEncoding}=require_util(),{isAsyncFunction,isArrayBufferView}=require_util().types,signals={};function isInt32(value){return value===(value|0)}function isUint32(value){return value===value>>>0}var octalReg=/^[0-7]+$/,modeDesc=\"must be a 32-bit unsigned integer or an octal string\";function parseFileMode(value,name,def){if(typeof value===\"undefined\")value=def;if(typeof value===\"string\"){if(!RegExpPrototypeTest(octalReg,value))throw new ERR_INVALID_ARG_VALUE2(name,value,modeDesc);value=NumberParseInt(value,8)}return validateInt32(value,name,0,4294967295),value}var validateInteger=hideStackFrames((value,name,min=NumberMIN_SAFE_INTEGER,max=NumberMAX_SAFE_INTEGER)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}),validateInt32=hideStackFrames((value,name,min=-2147483648,max=2147483647)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!isInt32(value)){if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}if(valuemax)throw new ERR_OUT_OF_RANGE(name,`>= ${min} && <= ${max}`,value)}),validateUint32=hideStackFrames((value,name,positive)=>{if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value);if(!isUint32(value)){if(!NumberIsInteger(value))throw new ERR_OUT_OF_RANGE(name,\"an integer\",value);throw new ERR_OUT_OF_RANGE(name,`>= ${positive\?1:0} && < 4294967296`,value)}if(positive&&value===0)throw new ERR_OUT_OF_RANGE(name,\">= 1 && < 4294967296\",value)});function validateString2(value,name){if(typeof value!==\"string\")throw new ERR_INVALID_ARG_TYPE2(name,\"string\",value)}function validateNumber(value,name){if(typeof value!==\"number\")throw new ERR_INVALID_ARG_TYPE2(name,\"number\",value)}var validateOneOf=hideStackFrames((value,name,oneOf)=>{if(!ArrayPrototypeIncludes(oneOf,value)){const reason=\"must be one of: \"+ArrayPrototypeJoin(ArrayPrototypeMap(oneOf,(v)=>typeof v===\"string\"\?`'${v}'`:String2(v)),\", \");throw new ERR_INVALID_ARG_VALUE2(name,value,reason)}});function validateBoolean2(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE2(name,\"boolean\",value)}var validateObject2=hideStackFrames((value,name,options)=>{const useDefaultOptions=options==null,allowArray=useDefaultOptions\?!1:options.allowArray,allowFunction=useDefaultOptions\?!1:options.allowFunction;if(!(useDefaultOptions\?!1:options.nullable)&&value===null||!allowArray&&ArrayIsArray2(value)||typeof value!==\"object\"&&(!allowFunction||typeof value!==\"function\"))throw new ERR_INVALID_ARG_TYPE2(name,\"Object\",value)}),validateArray=hideStackFrames((value,name,minLength=0)=>{if(!ArrayIsArray2(value))throw new ERR_INVALID_ARG_TYPE2(name,\"Array\",value);if(value.length{if(!isArrayBufferView(buffer))throw new ERR_INVALID_ARG_TYPE2(name,[\"Buffer\",\"TypedArray\",\"DataView\"],buffer)});function validateEncoding(data,encoding){const normalizedEncoding=normalizeEncoding(encoding),length=data.length;if(normalizedEncoding===\"hex\"&&length%2!==0)throw new ERR_INVALID_ARG_VALUE2(\"encoding\",encoding,`is invalid for data of length ${length}`)}function validatePort(port,name=\"Port\",allowZero=!0){if(typeof port!==\"number\"&&typeof port!==\"string\"||typeof port===\"string\"&&StringPrototypeTrim(port).length===0||+port!==+port>>>0||port>65535||port===0&&!allowZero)throw new ERR_SOCKET_BAD_PORT(name,port,allowZero);return port|0}var validateAbortSignal=hideStackFrames((signal,name)=>{if(signal!==void 0&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE2(name,\"AbortSignal\",signal)}),validateFunction=hideStackFrames((value,name)=>{if(typeof value!==\"function\")throw new ERR_INVALID_ARG_TYPE2(name,\"Function\",value)}),validatePlainFunction=hideStackFrames((value,name)=>{if(typeof value!==\"function\"||isAsyncFunction(value))throw new ERR_INVALID_ARG_TYPE2(name,\"Function\",value)}),validateUndefined=hideStackFrames((value,name)=>{if(value!==void 0)throw new ERR_INVALID_ARG_TYPE2(name,\"undefined\",value)});module.exports={isInt32,isUint32,parseFileMode,validateArray,validateBoolean:validateBoolean2,validateBuffer,validateEncoding,validateFunction,validateInt32,validateInteger,validateNumber,validateObject:validateObject2,validateOneOf,validatePlainFunction,validatePort,validateSignalName,validateString:validateString2,validateUint32,validateUndefined,validateAbortSignal}}}),require_utils=__commonJS({\"node_modules/readable-stream/lib/internal/streams/utils.js\"(exports2,module){var{Symbol:Symbol2,SymbolAsyncIterator,SymbolIterator}=require_primordials(),kDestroyed=Symbol2(\"kDestroyed\"),kIsErrored=Symbol2(\"kIsErrored\"),kIsReadable=Symbol2(\"kIsReadable\"),kIsDisturbed=Symbol2(\"kIsDisturbed\");function isReadableNodeStream(obj,strict=!1){var _obj$_readableState;return!!(obj&&typeof obj.pipe===\"function\"&&typeof obj.on===\"function\"&&(!strict||typeof obj.pause===\"function\"&&typeof obj.resume===\"function\")&&(!obj._writableState||((_obj$_readableState=obj._readableState)===null||_obj$_readableState===void 0\?void 0:_obj$_readableState.readable)!==!1)&&(!obj._writableState||obj._readableState))}function isWritableNodeStream(obj){var _obj$_writableState;return!!(obj&&typeof obj.write===\"function\"&&typeof obj.on===\"function\"&&(!obj._readableState||((_obj$_writableState=obj._writableState)===null||_obj$_writableState===void 0\?void 0:_obj$_writableState.writable)!==!1))}function isDuplexNodeStream(obj){return!!(obj&&typeof obj.pipe===\"function\"&&obj._readableState&&typeof obj.on===\"function\"&&typeof obj.write===\"function\")}function isNodeStream(obj){return obj&&(obj._readableState||obj._writableState||typeof obj.write===\"function\"&&typeof obj.on===\"function\"||typeof obj.pipe===\"function\"&&typeof obj.on===\"function\")}function isIterable(obj,isAsync){if(obj==null)return!1;if(isAsync===!0)return typeof obj[SymbolAsyncIterator]===\"function\";if(isAsync===!1)return typeof obj[SymbolIterator]===\"function\";return typeof obj[SymbolAsyncIterator]===\"function\"||typeof obj[SymbolIterator]===\"function\"}function isDestroyed(stream){if(!isNodeStream(stream))return null;const{_writableState:wState,_readableState:rState}=stream,state=wState||rState;return!!(stream.destroyed||stream[kDestroyed]||state!==null&&state!==void 0&&state.destroyed)}function isWritableEnded(stream){if(!isWritableNodeStream(stream))return null;if(stream.writableEnded===!0)return!0;const wState=stream._writableState;if(wState!==null&&wState!==void 0&&wState.errored)return!1;if(typeof(wState===null||wState===void 0\?void 0:wState.ended)!==\"boolean\")return null;return wState.ended}function isWritableFinished(stream,strict){if(!isWritableNodeStream(stream))return null;if(stream.writableFinished===!0)return!0;const wState=stream._writableState;if(wState!==null&&wState!==void 0&&wState.errored)return!1;if(typeof(wState===null||wState===void 0\?void 0:wState.finished)!==\"boolean\")return null;return!!(wState.finished||strict===!1&&wState.ended===!0&&wState.length===0)}function isReadableEnded(stream){if(!isReadableNodeStream(stream))return null;if(stream.readableEnded===!0)return!0;const rState=stream._readableState;if(!rState||rState.errored)return!1;if(typeof(rState===null||rState===void 0\?void 0:rState.ended)!==\"boolean\")return null;return rState.ended}function isReadableFinished(stream,strict){if(!isReadableNodeStream(stream))return null;const rState=stream._readableState;if(rState!==null&&rState!==void 0&&rState.errored)return!1;if(typeof(rState===null||rState===void 0\?void 0:rState.endEmitted)!==\"boolean\")return null;return!!(rState.endEmitted||strict===!1&&rState.ended===!0&&rState.length===0)}function isReadable(stream){if(stream&&stream[kIsReadable]!=null)return stream[kIsReadable];if(typeof(stream===null||stream===void 0\?void 0:stream.readable)!==\"boolean\")return null;if(isDestroyed(stream))return!1;return isReadableNodeStream(stream)&&stream.readable&&!isReadableFinished(stream)}function isWritable(stream){if(typeof(stream===null||stream===void 0\?void 0:stream.writable)!==\"boolean\")return null;if(isDestroyed(stream))return!1;return isWritableNodeStream(stream)&&stream.writable&&!isWritableEnded(stream)}function isFinished(stream,opts){if(!isNodeStream(stream))return null;if(isDestroyed(stream))return!0;if((opts===null||opts===void 0\?void 0:opts.readable)!==!1&&isReadable(stream))return!1;if((opts===null||opts===void 0\?void 0:opts.writable)!==!1&&isWritable(stream))return!1;return!0}function isWritableErrored(stream){var _stream$_writableStat,_stream$_writableStat2;if(!isNodeStream(stream))return null;if(stream.writableErrored)return stream.writableErrored;return(_stream$_writableStat=(_stream$_writableStat2=stream._writableState)===null||_stream$_writableStat2===void 0\?void 0:_stream$_writableStat2.errored)!==null&&_stream$_writableStat!==void 0\?_stream$_writableStat:null}function isReadableErrored(stream){var _stream$_readableStat,_stream$_readableStat2;if(!isNodeStream(stream))return null;if(stream.readableErrored)return stream.readableErrored;return(_stream$_readableStat=(_stream$_readableStat2=stream._readableState)===null||_stream$_readableStat2===void 0\?void 0:_stream$_readableStat2.errored)!==null&&_stream$_readableStat!==void 0\?_stream$_readableStat:null}function isClosed(stream){if(!isNodeStream(stream))return null;if(typeof stream.closed===\"boolean\")return stream.closed;const{_writableState:wState,_readableState:rState}=stream;if(typeof(wState===null||wState===void 0\?void 0:wState.closed)===\"boolean\"||typeof(rState===null||rState===void 0\?void 0:rState.closed)===\"boolean\")return(wState===null||wState===void 0\?void 0:wState.closed)||(rState===null||rState===void 0\?void 0:rState.closed);if(typeof stream._closed===\"boolean\"&&isOutgoingMessage(stream))return stream._closed;return null}function isOutgoingMessage(stream){return typeof stream._closed===\"boolean\"&&typeof stream._defaultKeepAlive===\"boolean\"&&typeof stream._removedConnection===\"boolean\"&&typeof stream._removedContLen===\"boolean\"}function isServerResponse(stream){return typeof stream._sent100===\"boolean\"&&isOutgoingMessage(stream)}function isServerRequest(stream){var _stream$req;return typeof stream._consuming===\"boolean\"&&typeof stream._dumped===\"boolean\"&&((_stream$req=stream.req)===null||_stream$req===void 0\?void 0:_stream$req.upgradeOrConnect)===void 0}function willEmitClose(stream){if(!isNodeStream(stream))return null;const{_writableState:wState,_readableState:rState}=stream,state=wState||rState;return!state&&isServerResponse(stream)||!!(state&&state.autoDestroy&&state.emitClose&&state.closed===!1)}function isDisturbed(stream){var _stream$kIsDisturbed;return!!(stream&&((_stream$kIsDisturbed=stream[kIsDisturbed])!==null&&_stream$kIsDisturbed!==void 0\?_stream$kIsDisturbed:stream.readableDidRead||stream.readableAborted))}function isErrored(stream){var _ref,_ref2,_ref3,_ref4,_ref5,_stream$kIsErrored,_stream$_readableStat3,_stream$_writableStat3,_stream$_readableStat4,_stream$_writableStat4;return!!(stream&&((_ref=(_ref2=(_ref3=(_ref4=(_ref5=(_stream$kIsErrored=stream[kIsErrored])!==null&&_stream$kIsErrored!==void 0\?_stream$kIsErrored:stream.readableErrored)!==null&&_ref5!==void 0\?_ref5:stream.writableErrored)!==null&&_ref4!==void 0\?_ref4:(_stream$_readableStat3=stream._readableState)===null||_stream$_readableStat3===void 0\?void 0:_stream$_readableStat3.errorEmitted)!==null&&_ref3!==void 0\?_ref3:(_stream$_writableStat3=stream._writableState)===null||_stream$_writableStat3===void 0\?void 0:_stream$_writableStat3.errorEmitted)!==null&&_ref2!==void 0\?_ref2:(_stream$_readableStat4=stream._readableState)===null||_stream$_readableStat4===void 0\?void 0:_stream$_readableStat4.errored)!==null&&_ref!==void 0\?_ref:(_stream$_writableStat4=stream._writableState)===null||_stream$_writableStat4===void 0\?void 0:_stream$_writableStat4.errored))}module.exports={kDestroyed,isDisturbed,kIsDisturbed,isErrored,kIsErrored,isReadable,kIsReadable,isClosed,isDestroyed,isDuplexNodeStream,isFinished,isIterable,isReadableNodeStream,isReadableEnded,isReadableFinished,isReadableErrored,isNodeStream,isWritable,isWritableNodeStream,isWritableEnded,isWritableFinished,isWritableErrored,isServerRequest,isServerResponse,willEmitClose}}}),require_end_of_stream=__commonJS({\"node_modules/readable-stream/lib/internal/streams/end-of-stream.js\"(exports2,module){var{AbortError:AbortError2,codes}=require_errors(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_STREAM_PREMATURE_CLOSE}=codes,{once}=require_util(),{validateAbortSignal,validateFunction,validateObject:validateObject2}=require_validators(),{Promise:Promise2}=require_primordials(),{isClosed,isReadable,isReadableNodeStream,isReadableFinished,isReadableErrored,isWritable,isWritableNodeStream,isWritableFinished,isWritableErrored,isNodeStream,willEmitClose:_willEmitClose}=require_utils();function isRequest(stream){return stream.setHeader&&typeof stream.abort===\"function\"}var nop=()=>{};function eos(stream,options,callback){var _options$readable,_options$writable;if(arguments.length===2)callback=options,options={};else if(options==null)options={};else validateObject2(options,\"options\");validateFunction(callback,\"callback\"),validateAbortSignal(options.signal,\"options.signal\"),callback=once(callback);const readable=(_options$readable=options.readable)!==null&&_options$readable!==void 0\?_options$readable:isReadableNodeStream(stream),writable=(_options$writable=options.writable)!==null&&_options$writable!==void 0\?_options$writable:isWritableNodeStream(stream);if(!isNodeStream(stream))throw new ERR_INVALID_ARG_TYPE2(\"stream\",\"Stream\",stream);const{_writableState:wState,_readableState:rState}=stream,onlegacyfinish=()=>{if(!stream.writable)onfinish()};let willEmitClose=_willEmitClose(stream)&&isReadableNodeStream(stream)===readable&&isWritableNodeStream(stream)===writable,writableFinished=isWritableFinished(stream,!1);const onfinish=()=>{if(writableFinished=!0,stream.destroyed)willEmitClose=!1;if(willEmitClose&&(!stream.readable||readable))return;if(!readable||readableFinished)callback.call(stream)};let readableFinished=isReadableFinished(stream,!1);const onend=()=>{if(readableFinished=!0,stream.destroyed)willEmitClose=!1;if(willEmitClose&&(!stream.writable||writable))return;if(!writable||writableFinished)callback.call(stream)},onerror=(err)=>{callback.call(stream,err)};let closed=isClosed(stream);const onclose=()=>{closed=!0;const errored=isWritableErrored(stream)||isReadableErrored(stream);if(errored&&typeof errored!==\"boolean\")return callback.call(stream,errored);if(readable&&!readableFinished&&isReadableNodeStream(stream,!0)){if(!isReadableFinished(stream,!1))return callback.call(stream,new ERR_STREAM_PREMATURE_CLOSE)}if(writable&&!writableFinished){if(!isWritableFinished(stream,!1))return callback.call(stream,new ERR_STREAM_PREMATURE_CLOSE)}callback.call(stream)},onrequest=()=>{stream.req.on(\"finish\",onfinish)};if(isRequest(stream)){if(stream.on(\"complete\",onfinish),!willEmitClose)stream.on(\"abort\",onclose);if(stream.req)onrequest();else stream.on(\"request\",onrequest)}else if(writable&&!wState)stream.on(\"end\",onlegacyfinish),stream.on(\"close\",onlegacyfinish);if(!willEmitClose&&typeof stream.aborted===\"boolean\")stream.on(\"aborted\",onclose);if(stream.on(\"end\",onend),stream.on(\"finish\",onfinish),options.error!==!1)stream.on(\"error\",onerror);if(stream.on(\"close\",onclose),closed)runOnNextTick(onclose);else if(wState!==null&&wState!==void 0&&wState.errorEmitted||rState!==null&&rState!==void 0&&rState.errorEmitted){if(!willEmitClose)runOnNextTick(onclose)}else if(!readable&&(!willEmitClose||isReadable(stream))&&(writableFinished||isWritable(stream)===!1))runOnNextTick(onclose);else if(!writable&&(!willEmitClose||isWritable(stream))&&(readableFinished||isReadable(stream)===!1))runOnNextTick(onclose);else if(rState&&stream.req&&stream.aborted)runOnNextTick(onclose);const cleanup=()=>{if(callback=nop,stream.removeListener(\"aborted\",onclose),stream.removeListener(\"complete\",onfinish),stream.removeListener(\"abort\",onclose),stream.removeListener(\"request\",onrequest),stream.req)stream.req.removeListener(\"finish\",onfinish);stream.removeListener(\"end\",onlegacyfinish),stream.removeListener(\"close\",onlegacyfinish),stream.removeListener(\"finish\",onfinish),stream.removeListener(\"end\",onend),stream.removeListener(\"error\",onerror),stream.removeListener(\"close\",onclose)};if(options.signal&&!closed){const abort=()=>{const endCallback=callback;cleanup(),endCallback.call(stream,new AbortError2(void 0,{cause:options.signal.reason}))};if(options.signal.aborted)runOnNextTick(abort);else{const originalCallback=callback;callback=once((...args)=>{options.signal.removeEventListener(\"abort\",abort),originalCallback.apply(stream,args)}),options.signal.addEventListener(\"abort\",abort)}}return cleanup}function finished2(stream,opts){return new Promise2((resolve,reject)=>{eos(stream,opts,(err)=>{if(err)reject(err);else resolve()})})}module.exports=eos,module.exports.finished=finished2}}),require_operators=__commonJS({\"node_modules/readable-stream/lib/internal/streams/operators.js\"(exports2,module){var{codes:{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_MISSING_ARGS,ERR_OUT_OF_RANGE},AbortError:AbortError2}=require_errors(),{validateAbortSignal,validateInteger,validateObject:validateObject2}=require_validators(),kWeakHandler=require_primordials().Symbol(\"kWeak\"),{finished:finished2}=require_end_of_stream(),{ArrayPrototypePush,MathFloor,Number:Number2,NumberIsNaN,Promise:Promise2,PromiseReject,PromisePrototypeCatch,Symbol:Symbol2}=require_primordials(),kEmpty=Symbol2(\"kEmpty\"),kEof=Symbol2(\"kEof\");function map(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");let concurrency=1;if((options===null||options===void 0\?void 0:options.concurrency)!=null)concurrency=MathFloor(options.concurrency);return validateInteger(concurrency,\"concurrency\",1),async function*map2(){var _options$signal,_options$signal2;const ac=new AbortController,stream=this,queue=[],signal=ac.signal,signalOpt={signal},abort=()=>ac.abort();if(options!==null&&options!==void 0&&(_options$signal=options.signal)!==null&&_options$signal!==void 0&&_options$signal.aborted)abort();options===null||options===void 0||(_options$signal2=options.signal)===null||_options$signal2===void 0||_options$signal2.addEventListener(\"abort\",abort);let next,resume,done=!1;function onDone(){done=!0}async function pump(){try{for await(let val of stream){var _val;if(done)return;if(signal.aborted)throw new AbortError2;try{val=fn(val,signalOpt)}catch(err){val=PromiseReject(err)}if(val===kEmpty)continue;if(typeof((_val=val)===null||_val===void 0\?void 0:_val.catch)===\"function\")val.catch(onDone);if(queue.push(val),next)next(),next=null;if(!done&&queue.length&&queue.length>=concurrency)await new Promise2((resolve)=>{resume=resolve})}queue.push(kEof)}catch(err){const val=PromiseReject(err);PromisePrototypeCatch(val,onDone),queue.push(val)}finally{var _options$signal3;if(done=!0,next)next(),next=null;options===null||options===void 0||(_options$signal3=options.signal)===null||_options$signal3===void 0||_options$signal3.removeEventListener(\"abort\",abort)}}pump();try{while(!0){while(queue.length>0){const val=await queue[0];if(val===kEof)return;if(signal.aborted)throw new AbortError2;if(val!==kEmpty)yield val;if(queue.shift(),resume)resume(),resume=null}await new Promise2((resolve)=>{next=resolve})}}finally{if(ac.abort(),done=!0,resume)resume(),resume=null}}.call(this)}function asIndexedPairs(options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return async function*asIndexedPairs2(){let index=0;for await(let val of this){var _options$signal4;if(options!==null&&options!==void 0&&(_options$signal4=options.signal)!==null&&_options$signal4!==void 0&&_options$signal4.aborted)throw new AbortError2({cause:options.signal.reason});yield[index++,val]}}.call(this)}async function some(fn,options=void 0){for await(let unused of filter.call(this,fn,options))return!0;return!1}async function every(fn,options=void 0){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);return!await some.call(this,async(...args)=>{return!await fn(...args)},options)}async function find(fn,options){for await(let result of filter.call(this,fn,options))return result;return}async function forEach(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);async function forEachFn(value,options2){return await fn(value,options2),kEmpty}for await(let unused of map.call(this,forEachFn,options));}function filter(fn,options){if(typeof fn!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"fn\",[\"Function\",\"AsyncFunction\"],fn);async function filterFn(value,options2){if(await fn(value,options2))return value;return kEmpty}return map.call(this,filterFn,options)}var ReduceAwareErrMissingArgs=class extends ERR_MISSING_ARGS{constructor(){super(\"reduce\");this.message=\"Reduce of an empty stream requires an initial value\"}};async function reduce(reducer,initialValue,options){var _options$signal5;if(typeof reducer!==\"function\")throw new ERR_INVALID_ARG_TYPE2(\"reducer\",[\"Function\",\"AsyncFunction\"],reducer);if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");let hasInitialValue=arguments.length>1;if(options!==null&&options!==void 0&&(_options$signal5=options.signal)!==null&&_options$signal5!==void 0&&_options$signal5.aborted){const err=new AbortError2(void 0,{cause:options.signal.reason});throw this.once(\"error\",()=>{}),await finished2(this.destroy(err)),err}const ac=new AbortController,signal=ac.signal;if(options!==null&&options!==void 0&&options.signal){const opts={once:!0,[kWeakHandler]:this};options.signal.addEventListener(\"abort\",()=>ac.abort(),opts)}let gotAnyItemFromStream=!1;try{for await(let value of this){var _options$signal6;if(gotAnyItemFromStream=!0,options!==null&&options!==void 0&&(_options$signal6=options.signal)!==null&&_options$signal6!==void 0&&_options$signal6.aborted)throw new AbortError2;if(!hasInitialValue)initialValue=value,hasInitialValue=!0;else initialValue=await reducer(initialValue,value,{signal})}if(!gotAnyItemFromStream&&!hasInitialValue)throw new ReduceAwareErrMissingArgs}finally{ac.abort()}return initialValue}async function toArray(options){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");const result=[];for await(let val of this){var _options$signal7;if(options!==null&&options!==void 0&&(_options$signal7=options.signal)!==null&&_options$signal7!==void 0&&_options$signal7.aborted)throw new AbortError2(void 0,{cause:options.signal.reason});ArrayPrototypePush(result,val)}return result}function flatMap(fn,options){const values=map.call(this,fn,options);return async function*flatMap2(){for await(let val of values)yield*val}.call(this)}function toIntegerOrInfinity(number){if(number=Number2(number),NumberIsNaN(number))return 0;if(number<0)throw new ERR_OUT_OF_RANGE(\"number\",\">= 0\",number);return number}function drop(number,options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return number=toIntegerOrInfinity(number),async function*drop2(){var _options$signal8;if(options!==null&&options!==void 0&&(_options$signal8=options.signal)!==null&&_options$signal8!==void 0&&_options$signal8.aborted)throw new AbortError2;for await(let val of this){var _options$signal9;if(options!==null&&options!==void 0&&(_options$signal9=options.signal)!==null&&_options$signal9!==void 0&&_options$signal9.aborted)throw new AbortError2;if(number--<=0)yield val}}.call(this)}function take(number,options=void 0){if(options!=null)validateObject2(options,\"options\");if((options===null||options===void 0\?void 0:options.signal)!=null)validateAbortSignal(options.signal,\"options.signal\");return number=toIntegerOrInfinity(number),async function*take2(){var _options$signal10;if(options!==null&&options!==void 0&&(_options$signal10=options.signal)!==null&&_options$signal10!==void 0&&_options$signal10.aborted)throw new AbortError2;for await(let val of this){var _options$signal11;if(options!==null&&options!==void 0&&(_options$signal11=options.signal)!==null&&_options$signal11!==void 0&&_options$signal11.aborted)throw new AbortError2;if(number-- >0)yield val;else return}}.call(this)}module.exports.streamReturningOperators={asIndexedPairs,drop,filter,flatMap,map,take},module.exports.promiseReturningOperators={every,forEach,reduce,toArray,some,find}}}),require_destroy=__commonJS({\"node_modules/readable-stream/lib/internal/streams/destroy.js\"(exports2,module){var{aggregateTwoErrors,codes:{ERR_MULTIPLE_CALLBACK},AbortError:AbortError2}=require_errors(),{Symbol:Symbol2}=require_primordials(),{kDestroyed,isDestroyed,isFinished,isServerRequest}=require_utils(),kDestroy=\"#kDestroy\",kConstruct=\"#kConstruct\";function checkError(err,w,r){if(err){if(err.stack,w&&!w.errored)w.errored=err;if(r&&!r.errored)r.errored=err}}function destroy2(err,cb){const r=this._readableState,w=this._writableState,s=w||r;if(w&&w.destroyed||r&&r.destroyed){if(typeof cb===\"function\")cb();return this}if(checkError(err,w,r),w)w.destroyed=!0;if(r)r.destroyed=!0;if(!s.constructed)this.once(kDestroy,(er)=>{_destroy(this,aggregateTwoErrors(er,err),cb)});else _destroy(this,err,cb);return this}function _destroy(self,err,cb){let called=!1;function onDestroy(err2){if(called)return;called=!0;const{_readableState:r,_writableState:w}=self;if(checkError(err2,w,r),w)w.closed=!0;if(r)r.closed=!0;if(typeof cb===\"function\")cb(err2);if(err2)runOnNextTick(emitErrorCloseNT,self,err2);else runOnNextTick(emitCloseNT,self)}try{self._destroy(err||null,onDestroy)}catch(err2){onDestroy(err2)}}function emitErrorCloseNT(self,err){emitErrorNT(self,err),emitCloseNT(self)}function emitCloseNT(self){const{_readableState:r,_writableState:w}=self;if(w)w.closeEmitted=!0;if(r)r.closeEmitted=!0;if(w&&w.emitClose||r&&r.emitClose)self.emit(\"close\")}function emitErrorNT(self,err){const r=self\?._readableState,w=self\?._writableState;if(w\?.errorEmitted||r\?.errorEmitted)return;if(w)w.errorEmitted=!0;if(r)r.errorEmitted=!0;self\?.emit\?.(\"error\",err)}function undestroy(){const r=this._readableState,w=this._writableState;if(r)r.constructed=!0,r.closed=!1,r.closeEmitted=!1,r.destroyed=!1,r.errored=null,r.errorEmitted=!1,r.reading=!1,r.ended=r.readable===!1,r.endEmitted=r.readable===!1;if(w)w.constructed=!0,w.destroyed=!1,w.closed=!1,w.closeEmitted=!1,w.errored=null,w.errorEmitted=!1,w.finalCalled=!1,w.prefinished=!1,w.ended=w.writable===!1,w.ending=w.writable===!1,w.finished=w.writable===!1}function errorOrDestroy2(stream,err,sync){const r=stream\?._readableState,w=stream\?._writableState;if(w&&w.destroyed||r&&r.destroyed)return this;if(r&&r.autoDestroy||w&&w.autoDestroy)stream.destroy(err);else if(err){if(Error.captureStackTrace(err),w&&!w.errored)w.errored=err;if(r&&!r.errored)r.errored=err;if(sync)runOnNextTick(emitErrorNT,stream,err);else emitErrorNT(stream,err)}}function construct(stream,cb){if(typeof stream._construct!==\"function\")return;const{_readableState:r,_writableState:w}=stream;if(r)r.constructed=!1;if(w)w.constructed=!1;if(stream.once(kConstruct,cb),stream.listenerCount(kConstruct)>1)return;runOnNextTick(constructNT,stream)}function constructNT(stream){let called=!1;function onConstruct(err){if(called){errorOrDestroy2(stream,err!==null&&err!==void 0\?err:new ERR_MULTIPLE_CALLBACK);return}called=!0;const{_readableState:r,_writableState:w}=stream,s=w||r;if(r)r.constructed=!0;if(w)w.constructed=!0;if(s.destroyed)stream.emit(kDestroy,err);else if(err)errorOrDestroy2(stream,err,!0);else runOnNextTick(emitConstructNT,stream)}try{stream._construct(onConstruct)}catch(err){onConstruct(err)}}function emitConstructNT(stream){stream.emit(kConstruct)}function isRequest(stream){return stream&&stream.setHeader&&typeof stream.abort===\"function\"}function emitCloseLegacy(stream){stream.emit(\"close\")}function emitErrorCloseLegacy(stream,err){stream.emit(\"error\",err),runOnNextTick(emitCloseLegacy,stream)}function destroyer(stream,err){if(!stream||isDestroyed(stream))return;if(!err&&!isFinished(stream))err=new AbortError2;if(isServerRequest(stream))stream.socket=null,stream.destroy(err);else if(isRequest(stream))stream.abort();else if(isRequest(stream.req))stream.req.abort();else if(typeof stream.destroy===\"function\")stream.destroy(err);else if(typeof stream.close===\"function\")stream.close();else if(err)runOnNextTick(emitErrorCloseLegacy,stream);else runOnNextTick(emitCloseLegacy,stream);if(!stream.destroyed)stream[kDestroyed]=!0}module.exports={construct,destroyer,destroy:destroy2,undestroy,errorOrDestroy:errorOrDestroy2}}}),require_legacy=__commonJS({\"node_modules/readable-stream/lib/internal/streams/legacy.js\"(exports2,module){var{ArrayIsArray:ArrayIsArray2,ObjectSetPrototypeOf}=require_primordials();function Stream(options){if(!(this instanceof Stream))return new Stream(options);EE.call(this,options)}Stream.prototype={},ObjectSetPrototypeOf(Stream.prototype,EE.prototype),ObjectSetPrototypeOf(Stream,EE),Stream.prototype.pipe=function(dest,options){const source=this;function ondata(chunk){if(dest.writable&&dest.write(chunk)===!1&&source.pause)source.pause()}source.on(\"data\",ondata);function ondrain(){if(source.readable&&source.resume)source.resume()}if(dest.on(\"drain\",ondrain),!dest._isStdio&&(!options||options.end!==!1))source.on(\"end\",onend),source.on(\"close\",onclose);let didOnEnd=!1;function onend(){if(didOnEnd)return;didOnEnd=!0,dest.end()}function onclose(){if(didOnEnd)return;if(didOnEnd=!0,typeof dest.destroy===\"function\")dest.destroy()}function onerror(er){if(cleanup(),EE.listenerCount(this,\"error\")===0)this.emit(\"error\",er)}prependListener(source,\"error\",onerror),prependListener(dest,\"error\",onerror);function cleanup(){source.removeListener(\"data\",ondata),dest.removeListener(\"drain\",ondrain),source.removeListener(\"end\",onend),source.removeListener(\"close\",onclose),source.removeListener(\"error\",onerror),dest.removeListener(\"error\",onerror),source.removeListener(\"end\",cleanup),source.removeListener(\"close\",cleanup),dest.removeListener(\"close\",cleanup)}return source.on(\"end\",cleanup),source.on(\"close\",cleanup),dest.on(\"close\",cleanup),dest.emit(\"pipe\",source),dest};function prependListener(emitter,event,fn){if(typeof emitter.prependListener===\"function\")return emitter.prependListener(event,fn);if(!emitter._events||!emitter._events[event])emitter.on(event,fn);else if(ArrayIsArray2(emitter._events[event]))emitter._events[event].unshift(fn);else emitter._events[event]=[fn,emitter._events[event]]}module.exports={Stream,prependListener}}}),require_add_abort_signal=__commonJS({\"node_modules/readable-stream/lib/internal/streams/add-abort-signal.js\"(exports2,module){var{AbortError:AbortError2,codes}=require_errors(),eos=require_end_of_stream(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2}=codes,validateAbortSignal=(signal,name)=>{if(typeof signal!==\"object\"||!(\"aborted\"in signal))throw new ERR_INVALID_ARG_TYPE2(name,\"AbortSignal\",signal)};function isNodeStream(obj){return!!(obj&&typeof obj.pipe===\"function\")}module.exports.addAbortSignal=function addAbortSignal(signal,stream){if(validateAbortSignal(signal,\"signal\"),!isNodeStream(stream))throw new ERR_INVALID_ARG_TYPE2(\"stream\",\"stream.Stream\",stream);return module.exports.addAbortSignalNoValidate(signal,stream)},module.exports.addAbortSignalNoValidate=function(signal,stream){if(typeof signal!==\"object\"||!(\"aborted\"in signal))return stream;const onAbort=()=>{stream.destroy(new AbortError2(void 0,{cause:signal.reason}))};if(signal.aborted)onAbort();else signal.addEventListener(\"abort\",onAbort),eos(stream,()=>signal.removeEventListener(\"abort\",onAbort));return stream}}}),require_state=__commonJS({\"node_modules/readable-stream/lib/internal/streams/state.js\"(exports2,module){var{MathFloor,NumberIsInteger}=require_primordials(),{ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2}=require_errors().codes;function highWaterMarkFrom(options,isDuplex,duplexKey){return options.highWaterMark!=null\?options.highWaterMark:isDuplex\?options[duplexKey]:null}function getDefaultHighWaterMark(objectMode){return objectMode\?16:16384}function getHighWaterMark(state,options,duplexKey,isDuplex){const hwm=highWaterMarkFrom(options,isDuplex,duplexKey);if(hwm!=null){if(!NumberIsInteger(hwm)||hwm<0){const name=isDuplex\?`options.${duplexKey}`:\"options.highWaterMark\";throw new ERR_INVALID_ARG_VALUE2(name,hwm)}return MathFloor(hwm)}return getDefaultHighWaterMark(state.objectMode)}module.exports={getHighWaterMark,getDefaultHighWaterMark}}}),require_from=__commonJS({\"node_modules/readable-stream/lib/internal/streams/from.js\"(exports2,module){var{PromisePrototypeThen,SymbolAsyncIterator,SymbolIterator}=require_primordials(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_STREAM_NULL_VALUES}=require_errors().codes;function from(Readable,iterable,opts){let iterator;if(typeof iterable===\"string\"||iterable instanceof Buffer)return new Readable({objectMode:!0,...opts,read(){this.push(iterable),this.push(null)}});let isAsync;if(iterable&&iterable[SymbolAsyncIterator])isAsync=!0,iterator=iterable[SymbolAsyncIterator]();else if(iterable&&iterable[SymbolIterator])isAsync=!1,iterator=iterable[SymbolIterator]();else throw new ERR_INVALID_ARG_TYPE2(\"iterable\",[\"Iterable\"],iterable);const readable=new Readable({objectMode:!0,highWaterMark:1,...opts});let reading=!1;readable._read=function(){if(!reading)reading=!0,next()},readable._destroy=function(error,cb){PromisePrototypeThen(close(error),()=>runOnNextTick(cb,error),(e)=>runOnNextTick(cb,e||error))};async function close(error){const hadError=error!==void 0&&error!==null,hasThrow=typeof iterator.throw===\"function\";if(hadError&&hasThrow){const{value,done}=await iterator.throw(error);if(await value,done)return}if(typeof iterator.return===\"function\"){const{value}=await iterator.return();await value}}async function next(){for(;;){try{const{value,done}=isAsync\?await iterator.next():iterator.next();if(done)readable.push(null);else{const res=value&&typeof value.then===\"function\"\?await value:value;if(res===null)throw reading=!1,new ERR_STREAM_NULL_VALUES;else if(readable.push(res))continue;else reading=!1}}catch(err){readable.destroy(err)}break}}return readable}module.exports=from}}),_ReadableFromWeb,_ReadableFromWebForUndici,require_readable=__commonJS({\"node_modules/readable-stream/lib/internal/streams/readable.js\"(exports2,module){var{ArrayPrototypeIndexOf,NumberIsInteger,NumberIsNaN,NumberParseInt,ObjectDefineProperties,ObjectKeys,ObjectSetPrototypeOf,Promise:Promise2,SafeSet,SymbolAsyncIterator,Symbol:Symbol2}=require_primordials(),ReadableState=globalThis[globalThis.Symbol.for('Bun.lazy')](\"bun:stream\").ReadableState,{Stream,prependListener}=require_legacy();function Readable(options){if(!(this instanceof Readable))return new Readable(options);const isDuplex=this instanceof require_duplex();if(this._readableState=new ReadableState(options,this,isDuplex),options){const{read,destroy:destroy2,construct,signal}=options;if(typeof read===\"function\")this._read=read;if(typeof destroy2===\"function\")this._destroy=destroy2;if(typeof construct===\"function\")this._construct=construct;if(signal&&!isDuplex)addAbortSignal(signal,this)}Stream.call(this,options),destroyImpl.construct(this,()=>{if(this._readableState.needReadable)maybeReadMore(this,this._readableState)})}Readable.prototype={},ObjectSetPrototypeOf(Readable.prototype,Stream.prototype),ObjectSetPrototypeOf(Readable,Stream),Readable.prototype.on=function(ev,fn){const res=Stream.prototype.on.call(this,ev,fn),state=this._readableState;if(ev===\"data\"){if(state.readableListening=this.listenerCount(\"readable\")>0,state.flowing!==!1)this.resume()}else if(ev===\"readable\"){if(!state.endEmitted&&!state.readableListening){if(state.readableListening=state.needReadable=!0,state.flowing=!1,state.emittedReadable=!1,state.length)emitReadable(this,state);else if(!state.reading)runOnNextTick(nReadingNextTick,this)}else if(state.endEmitted);}return res};class ReadableFromWeb extends Readable{#reader;#closed;#pendingChunks;#stream;constructor(options,stream){const{objectMode,highWaterMark,encoding,signal}=options;super({objectMode,highWaterMark,encoding,signal});this.#pendingChunks=[],this.#reader=void 0,this.#stream=stream,this.#closed=!1}#drainPending(){var pendingChunks=this.#pendingChunks,pendingChunksI=0,pendingChunksCount=pendingChunks.length;for(;pendingChunksI0)this.#pendingChunks=[];return!1}#handleDone(reader){reader.releaseLock(),this.#reader=void 0,this.#closed=!0,this.push(null);return}async _read(){var stream=this.#stream,reader=this.#reader;if(stream)reader=this.#reader=stream.getReader(),this.#stream=void 0;else if(this.#drainPending())return;var deferredError;try{do{var done=!1,value;const firstResult=reader.readMany();if(@isPromise(firstResult)){if({done,value}=await firstResult,this.#closed){this.#pendingChunks.push(...value);return}}else({done,value}=firstResult);if(done){this.#handleDone(reader);return}if(!this.push(value[0])){this.#pendingChunks=value.slice(1);return}for(let i=1,count=value.length;i{this.#closed=!0,callback(error)});return}try{callback(error)}catch(error2){globalThis.reportError(error2)}}}_ReadableFromWebForUndici=ReadableFromWeb;function newStreamReadableFromReadableStream(readableStream,options={}){if(!isReadableStream(readableStream))throw new ERR_INVALID_ARG_TYPE2(\"readableStream\",\"ReadableStream\",readableStream);validateObject2(options,\"options\");const{highWaterMark,encoding,objectMode=!1,signal}=options;if(encoding!==void 0&&!Buffer.isEncoding(encoding))throw new ERR_INVALID_ARG_VALUE(encoding,\"options.encoding\");return validateBoolean(objectMode,\"options.objectMode\"),getNativeReadableStream(Readable,readableStream,options)||new ReadableFromWeb({highWaterMark,encoding,objectMode,signal},readableStream)}module.exports=Readable,_ReadableFromWeb=newStreamReadableFromReadableStream;var{addAbortSignal}=require_add_abort_signal(),eos=require_end_of_stream();const{maybeReadMore:_maybeReadMore,resume,emitReadable:_emitReadable,onEofChunk}=globalThis[globalThis.Symbol.for('Bun.lazy')](\"bun:stream\");function maybeReadMore(stream,state){process.nextTick(_maybeReadMore,stream,state)}function emitReadable(stream,state){_emitReadable(stream,state)}var destroyImpl=require_destroy(),{aggregateTwoErrors,codes:{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_METHOD_NOT_IMPLEMENTED,ERR_OUT_OF_RANGE,ERR_STREAM_PUSH_AFTER_EOF,ERR_STREAM_UNSHIFT_AFTER_END_EVENT}}=require_errors(),{validateObject:validateObject2}=require_validators(),from=require_from(),nop=()=>{},{errorOrDestroy:errorOrDestroy2}=destroyImpl;Readable.prototype.destroy=destroyImpl.destroy,Readable.prototype._undestroy=destroyImpl.undestroy,Readable.prototype._destroy=function(err,cb){cb(err)},Readable.prototype[EE.captureRejectionSymbol]=function(err){this.destroy(err)},Readable.prototype.push=function(chunk,encoding){return readableAddChunk(this,chunk,encoding,!1)},Readable.prototype.unshift=function(chunk,encoding){return readableAddChunk(this,chunk,encoding,!0)};function readableAddChunk(stream,chunk,encoding,addToFront){const state=stream._readableState;let err;if(!state.objectMode){if(typeof chunk===\"string\"){if(encoding=encoding||state.defaultEncoding,state.encoding!==encoding)if(addToFront&&state.encoding)chunk=Buffer.from(chunk,encoding).toString(state.encoding);else chunk=Buffer.from(chunk,encoding),encoding=\"\"}else if(chunk instanceof Buffer)encoding=\"\";else if(Stream._isUint8Array(chunk)){if(addToFront||!state.decoder)chunk=Stream._uint8ArrayToBuffer(chunk);encoding=\"\"}else if(chunk!=null)err=new ERR_INVALID_ARG_TYPE2(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],chunk)}if(err)errorOrDestroy2(stream,err);else if(chunk===null)state.reading=!1,onEofChunk(stream,state);else if(state.objectMode||chunk&&chunk.length>0)if(addToFront)if(state.endEmitted)errorOrDestroy2(stream,new ERR_STREAM_UNSHIFT_AFTER_END_EVENT);else if(state.destroyed||state.errored)return!1;else addChunk(stream,state,chunk,!0);else if(state.ended)errorOrDestroy2(stream,new ERR_STREAM_PUSH_AFTER_EOF);else if(state.destroyed||state.errored)return!1;else if(state.reading=!1,state.decoder&&!encoding)if(chunk=state.decoder.write(chunk),state.objectMode||chunk.length!==0)addChunk(stream,state,chunk,!1);else maybeReadMore(stream,state);else addChunk(stream,state,chunk,!1);else if(!addToFront)state.reading=!1,maybeReadMore(stream,state);return!state.ended&&(state.length0){if(state.multiAwaitDrain)state.awaitDrainWriters.clear();else state.awaitDrainWriters=null;state.dataEmitted=!0,stream.emit(\"data\",chunk)}else{if(state.length+=state.objectMode\?1:chunk.length,addToFront)state.buffer.unshift(chunk);else state.buffer.push(chunk);if(state.needReadable)emitReadable(stream,state)}maybeReadMore(stream,state)}Readable.prototype.isPaused=function(){const state=this._readableState;return state.paused===!0||state.flowing===!1},Readable.prototype.setEncoding=function(enc){const decoder=new StringDecoder(enc);this._readableState.decoder=decoder,this._readableState.encoding=this._readableState.decoder.encoding;const buffer=this._readableState.buffer;let content=\"\";for(let i=buffer.length;i>0;i--)content+=decoder.write(buffer.shift());if(content!==\"\")buffer.push(content);return this._readableState.length=content.length,this};var MAX_HWM=1073741824;function computeNewHighWaterMark(n){if(n>MAX_HWM)throw new ERR_OUT_OF_RANGE(\"size\",\"<= 1GiB\",n);else n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++;return n}function howMuchToRead(n,state){if(n<=0||state.length===0&&state.ended)return 0;if(state.objectMode)return 1;if(NumberIsNaN(n)){if(state.flowing&&state.length)return state.buffer.first().length;return state.length}if(n<=state.length)return n;return state.ended\?state.length:0}Readable.prototype.read=function(n){if(!NumberIsInteger(n))n=NumberParseInt(n,10);const state=this._readableState,nOrig=n;if(n>state.highWaterMark)state.highWaterMark=computeNewHighWaterMark(n);if(n!==0)state.emittedReadable=!1;if(n===0&&state.needReadable&&((state.highWaterMark!==0\?state.length>=state.highWaterMark:state.length>0)||state.ended)){if(state.length===0&&state.ended)endReadable(this);else emitReadable(this,state);return null}if(n=howMuchToRead(n,state),n===0&&state.ended){if(state.length===0)endReadable(this);return null}let doRead=state.needReadable;if(state.length===0||state.length-n0)ret=fromList(n,state);else ret=null;if(ret===null)state.needReadable=state.length<=state.highWaterMark,n=0;else if(state.length-=n,state.multiAwaitDrain)state.awaitDrainWriters.clear();else state.awaitDrainWriters=null;if(state.length===0){if(!state.ended)state.needReadable=!0;if(nOrig!==n&&state.ended)endReadable(this)}if(ret!==null&&!state.errorEmitted&&!state.closeEmitted)state.dataEmitted=!0,this.emit(\"data\",ret);return ret},Readable.prototype._read=function(n){throw new ERR_METHOD_NOT_IMPLEMENTED(\"_read()\")},Readable.prototype.pipe=function(dest,pipeOpts){const src=this,state=this._readableState;if(state.pipes.length===1){if(!state.multiAwaitDrain)state.multiAwaitDrain=!0,state.awaitDrainWriters=new SafeSet(state.awaitDrainWriters\?[state.awaitDrainWriters]:[])}state.pipes.push(dest);const endFn=(!pipeOpts||pipeOpts.end!==!1)&&dest!==process.stdout&&dest!==process.stderr\?onend:unpipe;if(state.endEmitted)runOnNextTick(endFn);else src.once(\"end\",endFn);dest.on(\"unpipe\",onunpipe);function onunpipe(readable,unpipeInfo){if(readable===src){if(unpipeInfo&&unpipeInfo.hasUnpiped===!1)unpipeInfo.hasUnpiped=!0,cleanup()}}function onend(){dest.end()}let ondrain,cleanedUp=!1;function cleanup(){if(dest.removeListener(\"close\",onclose),dest.removeListener(\"finish\",onfinish),ondrain)dest.removeListener(\"drain\",ondrain);if(dest.removeListener(\"error\",onerror),dest.removeListener(\"unpipe\",onunpipe),src.removeListener(\"end\",onend),src.removeListener(\"end\",unpipe),src.removeListener(\"data\",ondata),cleanedUp=!0,ondrain&&state.awaitDrainWriters&&(!dest._writableState||dest._writableState.needDrain))ondrain()}function pause(){if(!cleanedUp){if(state.pipes.length===1&&state.pipes[0]===dest)state.awaitDrainWriters=dest,state.multiAwaitDrain=!1;else if(state.pipes.length>1&&state.pipes.includes(dest))state.awaitDrainWriters.add(dest);src.pause()}if(!ondrain)ondrain=pipeOnDrain(src,dest),dest.on(\"drain\",ondrain)}src.on(\"data\",ondata);function ondata(chunk){if(dest.write(chunk)===!1)pause()}function onerror(er){if(unpipe(),dest.removeListener(\"error\",onerror),dest.listenerCount(\"error\")===0){const s=dest._writableState||dest._readableState;if(s&&!s.errorEmitted)errorOrDestroy2(dest,er);else dest.emit(\"error\",er)}}prependListener(dest,\"error\",onerror);function onclose(){dest.removeListener(\"finish\",onfinish),unpipe()}dest.once(\"close\",onclose);function onfinish(){dest.removeListener(\"close\",onclose),unpipe()}dest.once(\"finish\",onfinish);function unpipe(){src.unpipe(dest)}if(dest.emit(\"pipe\",src),dest.writableNeedDrain===!0){if(state.flowing)pause()}else if(!state.flowing)src.resume();return dest};function pipeOnDrain(src,dest){return function pipeOnDrainFunctionResult(){const state=src._readableState;if(state.awaitDrainWriters===dest)state.awaitDrainWriters=null;else if(state.multiAwaitDrain)state.awaitDrainWriters.delete(dest);if((!state.awaitDrainWriters||state.awaitDrainWriters.size===0)&&src.listenerCount(\"data\"))src.resume()}}Readable.prototype.unpipe=function(dest){const state=this._readableState,unpipeInfo={hasUnpiped:!1};if(state.pipes.length===0)return this;if(!dest){const dests=state.pipes;state.pipes=[],this.pause();for(let i=0;i0,state.resumeScheduled&&state.paused===!1)state.flowing=!0;else if(self.listenerCount(\"data\")>0)self.resume();else if(!state.readableListening)state.flowing=null}function nReadingNextTick(self){self.read(0)}Readable.prototype.resume=function(){const state=this._readableState;if(!state.flowing)state.flowing=!state.readableListening,resume(this,state);return state.paused=!1,this},Readable.prototype.pause=function(){if(this._readableState.flowing!==!1)this._readableState.flowing=!1,this.emit(\"pause\");return this._readableState.paused=!0,this},Readable.prototype.wrap=function(stream){let paused=!1;stream.on(\"data\",(chunk)=>{if(!this.push(chunk)&&stream.pause)paused=!0,stream.pause()}),stream.on(\"end\",()=>{this.push(null)}),stream.on(\"error\",(err)=>{errorOrDestroy2(this,err)}),stream.on(\"close\",()=>{this.destroy()}),stream.on(\"destroy\",()=>{this.destroy()}),this._read=()=>{if(paused&&stream.resume)paused=!1,stream.resume()};const streamKeys=ObjectKeys(stream);for(let j=1;j{error=err\?aggregateTwoErrors(error,err):null,callback(),callback=nop});try{while(!0){const chunk=stream.destroyed\?null:stream.read();if(chunk!==null)yield chunk;else if(error)throw error;else if(error===null)return;else await new Promise2(next)}}catch(err){throw error=aggregateTwoErrors(error,err),error}finally{if((error||(options===null||options===void 0\?void 0:options.destroyOnReturn)!==!1)&&(error===void 0||stream._readableState.autoDestroy))destroyImpl.destroyer(stream,null);else stream.off(\"readable\",next),cleanup()}}ObjectDefineProperties(Readable.prototype,{readable:{get(){const r=this._readableState;return!!r&&r.readable!==!1&&!r.destroyed&&!r.errorEmitted&&!r.endEmitted},set(val){if(this._readableState)this._readableState.readable=!!val}},readableDidRead:{enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{enumerable:!1,get:function(){return this._readableState.flowing},set:function(state){if(this._readableState)this._readableState.flowing=state}},readableLength:{enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{enumerable:!1,get(){return this._readableState\?this._readableState.objectMode:!1}},readableEncoding:{enumerable:!1,get(){return this._readableState\?this._readableState.encoding:null}},errored:{enumerable:!1,get(){return this._readableState\?this._readableState.errored:null}},closed:{get(){return this._readableState\?this._readableState.closed:!1}},destroyed:{enumerable:!1,get(){return this._readableState\?this._readableState.destroyed:!1},set(value){if(!this._readableState)return;this._readableState.destroyed=value}},readableEnded:{enumerable:!1,get(){return this._readableState\?this._readableState.endEmitted:!1}}}),Readable._fromList=fromList;function fromList(n,state){if(state.length===0)return null;let ret;if(state.objectMode)ret=state.buffer.shift();else if(!n||n>=state.length){if(state.decoder)ret=state.buffer.join(\"\");else if(state.buffer.length===1)ret=state.buffer.first();else ret=state.buffer.concat(state.length);state.buffer.clear()}else ret=state.buffer.consume(n,state.decoder);return ret}function endReadable(stream){const state=stream._readableState;if(!state.endEmitted)state.ended=!0,runOnNextTick(endReadableNT,state,stream)}function endReadableNT(state,stream){if(!state.errored&&!state.closeEmitted&&!state.endEmitted&&state.length===0){if(state.endEmitted=!0,stream.emit(\"end\"),stream.writable&&stream.allowHalfOpen===!1)runOnNextTick(endWritableNT,stream);else if(state.autoDestroy){const wState=stream._writableState;if(!wState||wState.autoDestroy&&(wState.finished||wState.writable===!1))stream.destroy()}}}function endWritableNT(stream){if(stream.writable&&!stream.writableEnded&&!stream.destroyed)stream.end()}Readable.from=function(iterable,opts){return from(Readable,iterable,opts)};var webStreamsAdapters={newStreamReadableFromReadableStream,newReadableStreamFromStreamReadable(streamReadable,options={}){if(typeof streamReadable\?._readableState!==\"object\")throw new ERR_INVALID_ARG_TYPE2(\"streamReadable\",\"stream.Readable\",streamReadable);var{isDestroyed,isReadable}=require_utils();if(isDestroyed(streamReadable)||!isReadable(streamReadable)){const readable=new ReadableStream;return readable.cancel(),readable}const{readableObjectMode:objectMode,readableHighWaterMark:highWaterMark}=streamReadable,strategy=((strategy2)=>{if(strategy2)return strategy2;if(objectMode)return new CountQueuingStrategy({highWaterMark});return{highWaterMark}})(options\?.strategy);let controller;function onData(chunk){if(controller.enqueue(chunk),controller.desiredSize<=0)streamReadable.pause()}streamReadable.pause();const cleanup=finished(streamReadable,(error)=>{if(error\?.code===\"ERR_STREAM_PREMATURE_CLOSE\")error=new AbortError(void 0,{cause:error});if(cleanup(),streamReadable.on(\"error\",()=>{}),error)return controller.error(error);controller.close()});return streamReadable.on(\"data\",onData),new ReadableStream({start(c){controller=c},pull(){streamReadable.resume()},cancel(reason){destroy(streamReadable,reason)}},strategy)}};Readable.fromWeb=function(readableStream,options){return webStreamsAdapters.newStreamReadableFromReadableStream(readableStream,options)},Readable.toWeb=function(streamReadable,options){return webStreamsAdapters.newReadableStreamFromStreamReadable(streamReadable,options)},Readable.wrap=function(src,options){var _ref,_src$readableObjectMo;return new Readable({objectMode:(_ref=(_src$readableObjectMo=src.readableObjectMode)!==null&&_src$readableObjectMo!==void 0\?_src$readableObjectMo:src.objectMode)!==null&&_ref!==void 0\?_ref:!0,...options,destroy(err,callback){destroyImpl.destroyer(src,err),callback(err)}}).wrap(src)}}}),require_writable=__commonJS({\"node_modules/readable-stream/lib/internal/streams/writable.js\"(exports2,module){var{ArrayPrototypeSlice,Error:Error2,FunctionPrototypeSymbolHasInstance,ObjectDefineProperty,ObjectDefineProperties,ObjectSetPrototypeOf,StringPrototypeToLowerCase,Symbol:Symbol2,SymbolHasInstance}=require_primordials(),Stream=require_legacy().Stream,destroyImpl=require_destroy(),{addAbortSignal}=require_add_abort_signal(),{getHighWaterMark,getDefaultHighWaterMark}=require_state(),{ERR_INVALID_ARG_TYPE:ERR_INVALID_ARG_TYPE2,ERR_METHOD_NOT_IMPLEMENTED,ERR_MULTIPLE_CALLBACK,ERR_STREAM_CANNOT_PIPE,ERR_STREAM_DESTROYED,ERR_STREAM_ALREADY_FINISHED,ERR_STREAM_NULL_VALUES,ERR_STREAM_WRITE_AFTER_END,ERR_UNKNOWN_ENCODING}=require_errors().codes,{errorOrDestroy:errorOrDestroy2}=destroyImpl;function Writable2(options={}){const isDuplex=this instanceof require_duplex();if(!isDuplex&&!FunctionPrototypeSymbolHasInstance(Writable2,this))return new Writable2(options);if(this._writableState=new WritableState(options,this,isDuplex),options){if(typeof options.write===\"function\")this._write=options.write;if(typeof options.writev===\"function\")this._writev=options.writev;if(typeof options.destroy===\"function\")this._destroy=options.destroy;if(typeof options.final===\"function\")this._final=options.final;if(typeof options.construct===\"function\")this._construct=options.construct;if(options.signal)addAbortSignal(options.signal,this)}Stream.call(this,options),destroyImpl.construct(this,()=>{const state=this._writableState;if(!state.writing)clearBuffer(this,state);finishMaybe(this,state)})}Writable2.prototype={},ObjectSetPrototypeOf(Writable2.prototype,Stream.prototype),ObjectSetPrototypeOf(Writable2,Stream),module.exports=Writable2;function nop(){}var kOnFinished=Symbol2(\"kOnFinished\");function WritableState(options,stream,isDuplex){if(typeof isDuplex!==\"boolean\")isDuplex=stream instanceof require_duplex();if(this.objectMode=!!(options&&options.objectMode),isDuplex)this.objectMode=this.objectMode||!!(options&&options.writableObjectMode);this.highWaterMark=options\?getHighWaterMark(this,options,\"writableHighWaterMark\",isDuplex):getDefaultHighWaterMark(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;const noDecode=!!(options&&options.decodeStrings===!1);this.decodeStrings=!noDecode,this.defaultEncoding=options&&options.defaultEncoding||\"utf8\",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=onwrite.bind(void 0,stream),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,resetBuffer(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!options||options.emitClose!==!1,this.autoDestroy=!options||options.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[kOnFinished]=[]}WritableState.prototype={};function resetBuffer(state){state.buffered=[],state.bufferedIndex=0,state.allBuffers=!0,state.allNoop=!0}WritableState.prototype.getBuffer=function getBuffer(){return ArrayPrototypeSlice(this.buffered,this.bufferedIndex)},ObjectDefineProperty(WritableState.prototype,\"bufferedRequestCount\",{get(){return this.buffered.length-this.bufferedIndex}}),ObjectDefineProperty(Writable2,SymbolHasInstance,{value:function(object){if(FunctionPrototypeSymbolHasInstance(this,object))return!0;if(this!==Writable2)return!1;return object&&object._writableState instanceof WritableState}}),Writable2.prototype.pipe=function(){errorOrDestroy2(this,new ERR_STREAM_CANNOT_PIPE)};function _write(stream,chunk,encoding,cb){const state=stream._writableState;if(typeof encoding===\"function\")cb=encoding,encoding=state.defaultEncoding;else{if(!encoding)encoding=state.defaultEncoding;else if(encoding!==\"buffer\"&&!Buffer.isEncoding(encoding))throw new ERR_UNKNOWN_ENCODING(encoding);if(typeof cb!==\"function\")cb=nop}if(chunk===null)throw new ERR_STREAM_NULL_VALUES;else if(!state.objectMode)if(typeof chunk===\"string\"){if(state.decodeStrings!==!1)chunk=Buffer.from(chunk,encoding),encoding=\"buffer\"}else if(chunk instanceof Buffer)encoding=\"buffer\";else if(Stream._isUint8Array(chunk))chunk=Stream._uint8ArrayToBuffer(chunk),encoding=\"buffer\";else throw new ERR_INVALID_ARG_TYPE2(\"chunk\",[\"string\",\"Buffer\",\"Uint8Array\"],chunk);let err;if(state.ending)err=new ERR_STREAM_WRITE_AFTER_END;else if(state.destroyed)err=new ERR_STREAM_DESTROYED(\"write\");if(err)return runOnNextTick(cb,err),errorOrDestroy2(stream,err,!0),err;return state.pendingcb++,writeOrBuffer(stream,state,chunk,encoding,cb)}Writable2.prototype.write=function(chunk,encoding,cb){return _write(this,chunk,encoding,cb)===!0},Writable2.prototype.cork=function(){this._writableState.corked++},Writable2.prototype.uncork=function(){const state=this._writableState;if(state.corked){if(state.corked--,!state.writing)clearBuffer(this,state)}},Writable2.prototype.setDefaultEncoding=function setDefaultEncoding(encoding){if(typeof encoding===\"string\")encoding=StringPrototypeToLowerCase(encoding);if(!Buffer.isEncoding(encoding))throw new ERR_UNKNOWN_ENCODING(encoding);return this._writableState.defaultEncoding=encoding,this};function writeOrBuffer(stream,state,chunk,encoding,callback){const len=state.objectMode\?1:chunk.length;state.length+=len;const ret=state.lengthstate.bufferedIndex)clearBuffer(stream,state);if(sync)if(state.afterWriteTickInfo!==null&&state.afterWriteTickInfo.cb===cb)state.afterWriteTickInfo.count++;else state.afterWriteTickInfo={count:1,cb,stream,state},runOnNextTick(afterWriteTick,state.afterWriteTickInfo);else afterWrite(stream,state,1,cb)}}function afterWriteTick({stream,state,count,cb}){return state.afterWriteTickInfo=null,afterWrite(stream,state,count,cb)}function afterWrite(stream,state,count,cb){if(!state.ending&&!stream.destroyed&&state.length===0&&state.needDrain)state.needDrain=!1,stream.emit(\"drain\");while(count-- >0)state.pendingcb--,cb();if(state.destroyed)errorBuffer(state);finishMaybe(stream,state)}function errorBuffer(state){if(state.writing)return;for(let n=state.bufferedIndex;n1&&stream._writev){state.pendingcb-=bufferedLength-1;const callback=state.allNoop\?nop:(err)=>{for(let n=i;n256)buffered.splice(0,i),state.bufferedIndex=0;else state.bufferedIndex=i}state.bufferProcessing=!1}Writable2.prototype._write=function(chunk,encoding,cb){if(this._writev)this._writev([{chunk,encoding}],cb);else throw new ERR_METHOD_NOT_IMPLEMENTED(\"_write()\")},Writable2.prototype._writev=null,Writable2.prototype.end=function(chunk,encoding,cb,native=!1){const state=this._writableState;if(typeof chunk===\"function\")cb=chunk,chunk=null,encoding=null;else if(typeof encoding===\"function\")cb=encoding,encoding=null;let err;if(chunk!==null&&chunk!==void 0){let ret;if(!native)ret=_write(this,chunk,encoding);else ret=this.write(chunk,encoding);if(ret instanceof Error2)err=ret}if(state.corked)state.corked=1,this.uncork();if(err)this.emit(\"error\",err);else if(!state.errored&&!state.ending)state.ending=!0,finishMaybe(this,state,!0),state.ended=!0;else if(state.finished)err=new ERR_STREAM_ALREADY_FINISHED(\"end\");else if(state.destroyed)err=new ERR_STREAM_DESTROYED(\"end\");if(typeof cb===\"function\")if(err||state.finished)runOnNextTick(cb,err);else state[kOnFinished].push(cb);return this};function needFinish(state,tag){var needFinish2=state.ending&&!state.destroyed&&state.constructed&&state.length===0&&!state.errored&&state.buffered.length===0&&!state.finished&&!state.writing&&!state.errorEmitted&&!state.closeEmitted;return needFinish2}function callFinal(stream,state){let called=!1;function onFinish(err){if(called){errorOrDestroy2(stream,err!==null&&err!==void 0\?err:ERR_MULTIPLE_CALLBACK());return}if(called=!0,state.pendingcb--,err){const onfinishCallbacks=state[kOnFinished].splice(0);for(let i=0;i{if(needFinish(state2))finish(stream2,state2);else state2.pendingcb--},stream,state);else if(needFinish(state))state.pendingcb++,finish(stream,state)}}function finish(stream,state){state.pendingcb--,state.finished=!0;const onfinishCallbacks=state[kOnFinished].splice(0);for(let i=0;i{if(val!=null)throw new ERR_INVALID_RETURN_VALUE(\"nully\",\"body\",val)},(err)=>{destroyer(d,err)});return d=new Duplexify({objectMode:!0,readable:!1,write,final(cb){final(async()=>{try{await promise,runOnNextTick(cb,null)}catch(err){runOnNextTick(cb,err)}})},destroy:destroy2})}throw new ERR_INVALID_RETURN_VALUE(\"Iterable, AsyncIterable or AsyncFunction\",name,value)}if(isBlob(body))return duplexify(body.arrayBuffer());if(isIterable(body))return from(Duplexify,body,{objectMode:!0,writable:!1});if(typeof(body===null||body===void 0\?void 0:body.writable)===\"object\"||typeof(body===null||body===void 0\?void 0:body.readable)===\"object\"){const readable=body!==null&&body!==void 0&&body.readable\?isReadableNodeStream(body===null||body===void 0\?void 0:body.readable)\?body===null||body===void 0\?void 0:body.readable:duplexify(body.readable):void 0,writable=body!==null&&body!==void 0&&body.writable\?isWritableNodeStream(body===null||body===void 0\?void 0:body.writable)\?body===null||body===void 0\?void 0:body.writable:duplexify(body.writable):void 0;return _duplexify({readable,writable})}const then=body===null||body===void 0\?void 0:body.then;if(typeof then===\"function\"){let d;return FunctionPrototypeCall(then,body,(val)=>{if(val!=null)d.push(val);d.push(null)},(err)=>{destroyer(d,err)}),d=new Duplexify({objectMode:!0,writable:!1,read(){}})}throw new ERR_INVALID_ARG_TYPE2(name,[\"Blob\",\"ReadableStream\",\"WritableStream\",\"Stream\",\"Iterable\",\"AsyncIterable\",\"Function\",\"{ readable, writable } pair\",\"Promise\"],body)};function fromAsyncGen(fn){let{promise,resolve}=createDeferredPromise();const ac=new AbortController,signal=ac.signal;return{value:fn(async function*(){while(!0){const _promise=promise;promise=null;const{chunk,done,cb}=await _promise;if(runOnNextTick(cb),done)return;if(signal.aborted)throw new AbortError2(void 0,{cause:signal.reason});({promise,resolve}=createDeferredPromise()),yield chunk}}(),{signal}),write(chunk,encoding,cb){const _resolve=resolve;resolve=null,_resolve({chunk,done:!1,cb})},final(cb){const _resolve=resolve;resolve=null,_resolve({done:!0,cb})},destroy(err,cb){ac.abort(),cb(err)}}}function _duplexify(pair){const r=pair.readable&&typeof pair.readable.read!==\"function\"\?Readable.wrap(pair.readable):pair.readable,w=pair.writable;let readable=!!isReadable(r),writable=!!isWritable(w),ondrain,onfinish,onreadable,onclose,d;function onfinished(err){const cb=onclose;if(onclose=null,cb)cb(err);else if(err)d.destroy(err);else if(!readable&&!writable)d.destroy()}if(d=new Duplexify({readableObjectMode:!!(r!==null&&r!==void 0&&r.readableObjectMode),writableObjectMode:!!(w!==null&&w!==void 0&&w.writableObjectMode),readable,writable}),writable)eos(w,(err)=>{if(writable=!1,err)destroyer(r,err);onfinished(err)}),d._write=function(chunk,encoding,callback){if(w.write(chunk,encoding))callback();else ondrain=callback},d._final=function(callback){w.end(),onfinish=callback},w.on(\"drain\",function(){if(ondrain){const cb=ondrain;ondrain=null,cb()}}),w.on(\"finish\",function(){if(onfinish){const cb=onfinish;onfinish=null,cb()}});if(readable)eos(r,(err)=>{if(readable=!1,err)destroyer(r,err);onfinished(err)}),r.on(\"readable\",function(){if(onreadable){const cb=onreadable;onreadable=null,cb()}}),r.on(\"end\",function(){d.push(null)}),d._read=function(){while(!0){const buf=r.read();if(buf===null){onreadable=d._read;return}if(!d.push(buf))return}};return d._destroy=function(err,callback){if(!err&&onclose!==null)err=new AbortError2;if(onreadable=null,ondrain=null,onfinish=null,onclose===null)callback(err);else onclose=callback,destroyer(w,err),destroyer(r,err)},d}}}),require_duplex=__commonJS({\"node_modules/readable-stream/lib/internal/streams/duplex.js\"(exports2,module){var{ObjectDefineProperties,ObjectGetOwnPropertyDescriptor,ObjectKeys,ObjectSetPrototypeOf}=require_primordials(),Readable=require_readable();function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);if(Readable.call(this,options),Writable.call(this,options),options){if(this.allowHalfOpen=options.allowHalfOpen!==!1,options.readable===!1)this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0;if(options.writable===!1)this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0}else this.allowHalfOpen=!0}Duplex.prototype={},module.exports=Duplex,ObjectSetPrototypeOf(Duplex.prototype,Readable.prototype),ObjectSetPrototypeOf(Duplex,Readable);for(var method in Writable.prototype)if(!Duplex.prototype[method])Duplex.prototype[method]=Writable.prototype[method];ObjectDefineProperties(Duplex.prototype,{writable:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writable\"),writableHighWaterMark:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableHighWaterMark\"),writableObjectMode:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableObjectMode\"),writableBuffer:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableBuffer\"),writableLength:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableLength\"),writableFinished:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableFinished\"),writableCorked:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableCorked\"),writableEnded:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableEnded\"),writableNeedDrain:ObjectGetOwnPropertyDescriptor(Writable.prototype,\"writableNeedDrain\"),destroyed:{get(){if(this._readableState===void 0||this._writableState===void 0)return!1;return this._readableState.destroyed&&this._writableState.destroyed},set(value){if(this._readableState&&this._writableState)this._readableState.destroyed=value,this._writableState.destroyed=value}}});var webStreamsAdapters;function lazyWebStreams(){if(webStreamsAdapters===void 0)webStreamsAdapters={};return webStreamsAdapters}Duplex.fromWeb=function(pair,options){return lazyWebStreams().newStreamDuplexFromReadableWritablePair(pair,options)},Duplex.toWeb=function(duplex){return lazyWebStreams().newReadableWritablePairFromDuplex(duplex)};var duplexify;Duplex.from=function(body){if(!duplexify)duplexify=require_duplexify();return duplexify(body,\"body\")}}}),require_transform=__commonJS({\"node_modules/readable-stream/lib/internal/streams/transform.js\"(exports2,module){var{ObjectSetPrototypeOf,Symbol:Symbol2}=require_primordials(),{ERR_METHOD_NOT_IMPLEMENTED}=require_errors().codes,Duplex=require_duplex();function Transform(options){if(!(this instanceof Transform))return new Transform(options);if(Duplex.call(this,options),this._readableState.sync=!1,this[kCallback]=null,options){if(typeof options.transform===\"function\")this._transform=options.transform;if(typeof options.flush===\"function\")this._flush=options.flush}this.on(\"prefinish\",prefinish.bind(this))}Transform.prototype={},ObjectSetPrototypeOf(Transform.prototype,Duplex.prototype),ObjectSetPrototypeOf(Transform,Duplex),module.exports=Transform;var kCallback=Symbol2(\"kCallback\");function final(cb){if(typeof this._flush===\"function\"&&!this.destroyed)this._flush((er,data)=>{if(er){if(cb)cb(er);else this.destroy(er);return}if(data!=null)this.push(data);if(this.push(null),cb)cb()});else if(this.push(null),cb)cb()}function prefinish(){if(this._final!==final)final.call(this)}Transform.prototype._final=final,Transform.prototype._transform=function(chunk,encoding,callback){throw new ERR_METHOD_NOT_IMPLEMENTED(\"_transform()\")},Transform.prototype._write=function(chunk,encoding,callback){const rState=this._readableState,wState=this._writableState,length=rState.length;this._transform(chunk,encoding,(err,val)=>{if(err){callback(err);return}if(val!=null)this.push(val);if(wState.ended||length===rState.length||rState.length{finished2=!0});const cleanup=eos(stream,{readable:reading,writable:writing},(err)=>{finished2=!err});return{destroy:(err)=>{if(finished2)return;finished2=!0,destroyImpl.destroyer(stream,err||new ERR_STREAM_DESTROYED(\"pipe\"))},cleanup}}function popCallback(streams){return validateFunction(streams[streams.length-1],\"streams[stream.length - 1]\"),streams.pop()}function makeAsyncIterable(val){if(isIterable(val))return val;else if(isReadableNodeStream(val))return fromReadable(val);throw new ERR_INVALID_ARG_TYPE2(\"val\",[\"Readable\",\"Iterable\",\"AsyncIterable\"],val)}async function*fromReadable(val){if(!Readable)Readable=require_readable();yield*Readable.prototype[SymbolAsyncIterator].call(val)}async function pump(iterable,writable,finish,{end}){let error,onresolve=null;const resume=(err)=>{if(err)error=err;if(onresolve){const callback=onresolve;onresolve=null,callback()}},wait=()=>new Promise2((resolve,reject)=>{if(error)reject(error);else onresolve=()=>{if(error)reject(error);else resolve()}});writable.on(\"drain\",resume);const cleanup=eos(writable,{readable:!1},resume);try{if(writable.writableNeedDrain)await wait();for await(let chunk of iterable)if(!writable.write(chunk))await wait();if(end)writable.end();await wait(),finish()}catch(err){finish(error!==err\?aggregateTwoErrors(error,err):err)}finally{cleanup(),writable.off(\"drain\",resume)}}function pipeline(...streams){return pipelineImpl(streams,once(popCallback(streams)))}function pipelineImpl(streams,callback,opts){if(streams.length===1&&ArrayIsArray2(streams[0]))streams=streams[0];if(streams.length<2)throw new ERR_MISSING_ARGS(\"streams\");const ac=new AbortController,signal=ac.signal,outerSignal=opts===null||opts===void 0\?void 0:opts.signal,lastStreamCleanup=[];validateAbortSignal(outerSignal,\"options.signal\");function abort(){finishImpl(new AbortError2)}outerSignal===null||outerSignal===void 0||outerSignal.addEventListener(\"abort\",abort);let error,value;const destroys=[];let finishCount=0;function finish(err){finishImpl(err,--finishCount===0)}function finishImpl(err,final){if(err&&(!error||error.code===\"ERR_STREAM_PREMATURE_CLOSE\"))error=err;if(!error&&!final)return;while(destroys.length)destroys.shift()(error);if(outerSignal===null||outerSignal===void 0||outerSignal.removeEventListener(\"abort\",abort),ac.abort(),final){if(!error)lastStreamCleanup.forEach((fn)=>fn());runOnNextTick(callback,error,value)}}let ret;for(let i=0;i0,end=reading||(opts===null||opts===void 0\?void 0:opts.end)!==!1,isLastStream=i===streams.length-1;if(isNodeStream(stream)){let onError=function(err){if(err&&err.name!==\"AbortError\"&&err.code!==\"ERR_STREAM_PREMATURE_CLOSE\")finish(err)};if(end){const{destroy:destroy2,cleanup}=destroyer(stream,reading,writing);if(destroys.push(destroy2),isReadable(stream)&&isLastStream)lastStreamCleanup.push(cleanup)}if(stream.on(\"error\",onError),isReadable(stream)&&isLastStream)lastStreamCleanup.push(()=>{stream.removeListener(\"error\",onError)})}if(i===0)if(typeof stream===\"function\"){if(ret=stream({signal}),!isIterable(ret))throw new ERR_INVALID_RETURN_VALUE(\"Iterable, AsyncIterable or Stream\",\"source\",ret)}else if(isIterable(stream)||isReadableNodeStream(stream))ret=stream;else ret=Duplex.from(stream);else if(typeof stream===\"function\")if(ret=makeAsyncIterable(ret),ret=stream(ret,{signal}),reading){if(!isIterable(ret,!0))throw new ERR_INVALID_RETURN_VALUE(\"AsyncIterable\",`transform[${i-1}]`,ret)}else{var _ret;if(!PassThrough)PassThrough=require_passthrough();const pt=new PassThrough({objectMode:!0}),then=(_ret=ret)===null||_ret===void 0\?void 0:_ret.then;if(typeof then===\"function\")finishCount++,then.call(ret,(val)=>{if(value=val,val!=null)pt.write(val);if(end)pt.end();runOnNextTick(finish)},(err)=>{pt.destroy(err),runOnNextTick(finish,err)});else if(isIterable(ret,!0))finishCount++,pump(ret,pt,finish,{end});else throw new ERR_INVALID_RETURN_VALUE(\"AsyncIterable or Promise\",\"destination\",ret);ret=pt;const{destroy:destroy2,cleanup}=destroyer(ret,!1,!0);if(destroys.push(destroy2),isLastStream)lastStreamCleanup.push(cleanup)}else if(isNodeStream(stream)){if(isReadableNodeStream(ret)){finishCount+=2;const cleanup=pipe(ret,stream,finish,{end});if(isReadable(stream)&&isLastStream)lastStreamCleanup.push(cleanup)}else if(isIterable(ret))finishCount++,pump(ret,stream,finish,{end});else throw new ERR_INVALID_ARG_TYPE2(\"val\",[\"Readable\",\"Iterable\",\"AsyncIterable\"],ret);ret=stream}else ret=Duplex.from(stream)}if(signal!==null&&signal!==void 0&&signal.aborted||outerSignal!==null&&outerSignal!==void 0&&outerSignal.aborted)runOnNextTick(abort);return ret}function pipe(src,dst,finish,{end}){if(src.pipe(dst,{end}),end)src.once(\"end\",()=>dst.end());else finish();return eos(src,{readable:!0,writable:!1},(err)=>{const rState=src._readableState;if(err&&err.code===\"ERR_STREAM_PREMATURE_CLOSE\"&&rState&&rState.ended&&!rState.errored&&!rState.errorEmitted)src.once(\"end\",finish).once(\"error\",finish);else finish(err)}),eos(dst,{readable:!1,writable:!0},finish)}module.exports={pipelineImpl,pipeline}}}),require_compose=__commonJS({\"node_modules/readable-stream/lib/internal/streams/compose.js\"(exports2,module){var{pipeline}=require_pipeline(),Duplex=require_duplex(),{destroyer}=require_destroy(),{isNodeStream,isReadable,isWritable}=require_utils(),{AbortError:AbortError2,codes:{ERR_INVALID_ARG_VALUE:ERR_INVALID_ARG_VALUE2,ERR_MISSING_ARGS}}=require_errors();module.exports=function compose(...streams){if(streams.length===0)throw new ERR_MISSING_ARGS(\"streams\");if(streams.length===1)return Duplex.from(streams[0]);const orgStreams=[...streams];if(typeof streams[0]===\"function\")streams[0]=Duplex.from(streams[0]);if(typeof streams[streams.length-1]===\"function\"){const idx=streams.length-1;streams[idx]=Duplex.from(streams[idx])}for(let n=0;n0&&!isWritable(streams[n]))throw new ERR_INVALID_ARG_VALUE2(`streams[${n}]`,orgStreams[n],\"must be writable\")}let ondrain,onfinish,onreadable,onclose,d;function onfinished(err){const cb=onclose;if(onclose=null,cb)cb(err);else if(err)d.destroy(err);else if(!readable&&!writable)d.destroy()}const head=streams[0],tail=pipeline(streams,onfinished),writable=!!isWritable(head),readable=!!isReadable(tail);if(d=new Duplex({writableObjectMode:!!(head!==null&&head!==void 0&&head.writableObjectMode),readableObjectMode:!!(tail!==null&&tail!==void 0&&tail.writableObjectMode),writable,readable}),writable)d._write=function(chunk,encoding,callback){if(head.write(chunk,encoding))callback();else ondrain=callback},d._final=function(callback){head.end(),onfinish=callback},head.on(\"drain\",function(){if(ondrain){const cb=ondrain;ondrain=null,cb()}}),tail.on(\"finish\",function(){if(onfinish){const cb=onfinish;onfinish=null,cb()}});if(readable)tail.on(\"readable\",function(){if(onreadable){const cb=onreadable;onreadable=null,cb()}}),tail.on(\"end\",function(){d.push(null)}),d._read=function(){while(!0){const buf=tail.read();if(buf===null){onreadable=d._read;return}if(!d.push(buf))return}};return d._destroy=function(err,callback){if(!err&&onclose!==null)err=new AbortError2;if(onreadable=null,ondrain=null,onfinish=null,onclose===null)callback(err);else onclose=callback,destroyer(tail,err)},d}}}),require_promises=__commonJS({\"node_modules/readable-stream/lib/stream/promises.js\"(exports2,module){var{ArrayPrototypePop,Promise:Promise2}=require_primordials(),{isIterable,isNodeStream}=require_utils(),{pipelineImpl:pl}=require_pipeline(),{finished:finished2}=require_end_of_stream();function pipeline(...streams){return new Promise2((resolve,reject)=>{let signal,end;const lastArg=streams[streams.length-1];if(lastArg&&typeof lastArg===\"object\"&&!isNodeStream(lastArg)&&!isIterable(lastArg)){const options=ArrayPrototypePop(streams);signal=options.signal,end=options.end}pl(streams,(err,value)=>{if(err)reject(err);else resolve(value)},{signal,end})})}module.exports={finished:finished2,pipeline}}}),require_stream=__commonJS({\"node_modules/readable-stream/lib/stream.js\"(exports2,module){var{ObjectDefineProperty,ObjectKeys,ReflectApply}=require_primordials(),{promisify:{custom:customPromisify}}=require_util(),{streamReturningOperators,promiseReturningOperators}=require_operators(),{codes:{ERR_ILLEGAL_CONSTRUCTOR}}=require_errors(),compose=require_compose(),{pipeline}=require_pipeline(),{destroyer}=require_destroy(),eos=require_end_of_stream(),promises2=require_promises(),utils=require_utils(),Stream=module.exports=require_legacy().Stream;Stream.isDisturbed=utils.isDisturbed,Stream.isErrored=utils.isErrored,Stream.isWritable=utils.isWritable,Stream.isReadable=utils.isReadable,Stream.Readable=require_readable();for(let key of ObjectKeys(streamReturningOperators)){let fn=function(...args){if(new.target)throw ERR_ILLEGAL_CONSTRUCTOR();return Stream.Readable.from(ReflectApply(op,this,args))};const op=streamReturningOperators[key];ObjectDefineProperty(fn,\"name\",{value:op.name}),ObjectDefineProperty(fn,\"length\",{value:op.length}),ObjectDefineProperty(Stream.Readable.prototype,key,{value:fn,enumerable:!1,configurable:!0,writable:!0})}for(let key of ObjectKeys(promiseReturningOperators)){let fn=function(...args){if(new.target)throw ERR_ILLEGAL_CONSTRUCTOR();return ReflectApply(op,this,args)};const op=promiseReturningOperators[key];ObjectDefineProperty(fn,\"name\",{value:op.name}),ObjectDefineProperty(fn,\"length\",{value:op.length}),ObjectDefineProperty(Stream.Readable.prototype,key,{value:fn,enumerable:!1,configurable:!0,writable:!0})}Stream.Writable=require_writable(),Stream.Duplex=require_duplex(),Stream.Transform=require_transform(),Stream.PassThrough=require_passthrough(),Stream.pipeline=pipeline;var{addAbortSignal}=require_add_abort_signal();Stream.addAbortSignal=addAbortSignal,Stream.finished=eos,Stream.destroy=destroyer,Stream.compose=compose,ObjectDefineProperty(Stream,\"promises\",{configurable:!0,enumerable:!0,get(){return promises2}}),ObjectDefineProperty(pipeline,customPromisify,{enumerable:!0,get(){return promises2.pipeline}}),ObjectDefineProperty(eos,customPromisify,{enumerable:!0,get(){return promises2.finished}}),Stream.Stream=Stream,Stream._isUint8Array=function isUint8Array(value){return value instanceof Uint8Array},Stream._uint8ArrayToBuffer=function _uint8ArrayToBuffer(chunk){return new Buffer(chunk.buffer,chunk.byteOffset,chunk.byteLength)}}});function createNativeStreamReadable(nativeType,Readable){var[pull,start,cancel,setClose,deinit,updateRef,drainFn]=globalThis[globalThis.Symbol.for('Bun.lazy')](nativeType),closer=[!1],handleNumberResult=function(nativeReadable,result,view,isClosed){if(result>0){const slice=view.subarray(0,result),remainder=view.subarray(result);if(slice.byteLength>0)nativeReadable.push(slice);if(isClosed)nativeReadable.push(null);return remainder.byteLength>0\?remainder:void 0}if(isClosed)nativeReadable.push(null);return view},handleArrayBufferViewResult=function(nativeReadable,result,view,isClosed){if(result.byteLength>0)nativeReadable.push(result);if(isClosed)nativeReadable.push(null);return view},DYNAMICALLY_ADJUST_CHUNK_SIZE=process.env.BUN_DISABLE_DYNAMIC_CHUNK_SIZE!==\"1\";const finalizer=new FinalizationRegistry((ptr)=>ptr&&deinit(ptr)),MIN_BUFFER_SIZE=512;var NativeReadable=class NativeReadable2 extends Readable{#bunNativePtr;#refCount=1;#constructed=!1;#remainingChunk=void 0;#highWaterMark;#pendingRead=!1;#hasResized=!DYNAMICALLY_ADJUST_CHUNK_SIZE;#unregisterToken;constructor(ptr,options={}){super(options);if(typeof options.highWaterMark===\"number\")this.#highWaterMark=options.highWaterMark;else this.#highWaterMark=262144;this.#bunNativePtr=ptr,this.#constructed=!1,this.#remainingChunk=void 0,this.#pendingRead=!1,this.#unregisterToken={},finalizer.register(this,this.#bunNativePtr,this.#unregisterToken)}_read(maxToRead){if(this.#pendingRead)return;var ptr=this.#bunNativePtr;if(ptr===0){this.push(null);return}if(!this.#constructed)this.#internalConstruct(ptr);return this.#internalRead(this.#getRemainingChunk(maxToRead),ptr)}#internalConstruct(ptr){this.#constructed=!0;const result=start(ptr,this.#highWaterMark);if(typeof result===\"number\"&&result>1)this.#hasResized=!0,this.#highWaterMark=Math.min(this.#highWaterMark,result);if(drainFn){const drainResult=drainFn(ptr);if((drainResult\?.byteLength\?\?0)>0)this.push(drainResult)}}#getRemainingChunk(maxToRead=this.#highWaterMark){var chunk=this.#remainingChunk;if(chunk\?.byteLength\?\?0MIN_BUFFER_SIZE\?maxToRead:MIN_BUFFER_SIZE;this.#remainingChunk=chunk=new Buffer(size)}return chunk}#handleResult(result,view,isClosed){if(typeof result===\"number\"){if(result>=this.#highWaterMark&&!this.#hasResized&&!isClosed)this.#highWaterMark*=2,this.#hasResized=!0;return handleNumberResult(this,result,view,isClosed)}else if(typeof result===\"boolean\")return process.nextTick(()=>{this.push(null)}),view\?.byteLength\?\?0>0\?view:void 0;else if(ArrayBuffer.isView(result)){if(result.byteLength>=this.#highWaterMark&&!this.#hasResized&&!isClosed)this.#highWaterMark*=2,this.#hasResized=!0;return handleArrayBufferViewResult(this,result,view,isClosed)}else throw new Error(\"Invalid result from pull\")}#internalRead(view,ptr){closer[0]=!1;var result=pull(ptr,view,closer);if(@isPromise(result))return this.#pendingRead=!0,result.then((result2)=>{this.#pendingRead=!1,this.#remainingChunk=this.#handleResult(result2,view,closer[0])},(reason)=>{errorOrDestroy(this,reason)});else this.#remainingChunk=this.#handleResult(result,view,closer[0])}_destroy(error,callback){var ptr=this.#bunNativePtr;if(ptr===0){callback(error);return}if(finalizer.unregister(this.#unregisterToken),this.#bunNativePtr=0,updateRef)updateRef(ptr,!1);cancel(ptr,error),callback(error)}ref(){var ptr=this.#bunNativePtr;if(ptr===0)return;if(this.#refCount++===0)updateRef(ptr,!0)}unref(){var ptr=this.#bunNativePtr;if(ptr===0)return;if(this.#refCount--===1)updateRef(ptr,!1)}};if(!updateRef)NativeReadable.prototype.ref=void 0,NativeReadable.prototype.unref=void 0;return NativeReadable}var nativeReadableStreamPrototypes={0:void 0,1:void 0,2:void 0,3:void 0,4:void 0,5:void 0};function getNativeReadableStreamPrototype(nativeType,Readable){return nativeReadableStreamPrototypes[nativeType]||=createNativeStreamReadable(nativeType,Readable)}function getNativeReadableStream(Readable,stream,options){if(!(stream&&typeof stream===\"object\"&&stream instanceof ReadableStream))return;const native=@direct(stream);if(!native)return;const{stream:ptr,data:type}=native;return new(getNativeReadableStreamPrototype(type,Readable))(ptr,options)}var Writable=require_writable(),NativeWritable=class NativeWritable2 extends Writable{#pathOrFdOrSink;#fileSink;#native=!0;_construct;_destroy;_final;constructor(pathOrFdOrSink,options={}){super(options);this._construct=this.#internalConstruct,this._destroy=this.#internalDestroy,this._final=this.#internalFinal,this.#pathOrFdOrSink=pathOrFdOrSink}#internalConstruct(cb){this._writableState.constructed=!0,this.constructed=!0,cb()}#lazyConstruct(){if(typeof this.#pathOrFdOrSink===\"object\")if(typeof this.#pathOrFdOrSink.write===\"function\")this.#fileSink=this.#pathOrFdOrSink;else throw new Error(\"Invalid FileSink\");else this.#fileSink=Bun.file(this.#pathOrFdOrSink).writer()}write(chunk,encoding,cb,native=this.#native){if(!native)return this.#native=!1,super.write(chunk,encoding,cb);if(!this.#fileSink)this.#lazyConstruct();var fileSink=this.#fileSink,result=fileSink.write(chunk);if(@isPromise(result))return result.then(()=>{this.emit(\"drain\"),fileSink.flush(!0)}),!1;if(fileSink.flush(!0),cb)cb(null,chunk.byteLength);return!0}end(chunk,encoding,cb,native=this.#native){return super.end(chunk,encoding,cb,native)}#internalDestroy(error,cb){if(this._writableState.destroyed=!0,cb)cb(error)}#internalFinal(cb){if(this.#fileSink)this.#fileSink.end();if(cb)cb()}ref(){if(!this.#fileSink)this.#lazyConstruct();this.#fileSink.ref()}unref(){if(!this.#fileSink)return;this.#fileSink.unref()}};const exports=require_stream(),promises=require_promises();return exports._getNativeReadableStreamPrototype=getNativeReadableStreamPrototype,exports.NativeWritable=NativeWritable,Object.defineProperty(exports,\"promises\",{configurable:!0,enumerable:!0,get(){return promises}}),exports[Symbol.for(\"::bunternal::\")]={_ReadableFromWeb,_ReadableFromWebForUndici},exports.eos=require_end_of_stream(),exports})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamPromisesCode = "(function (){\"use strict\";return(@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34)).promises})\n"_s; +// + +// static constexpr ASCIILiteral NodeStreamWebCode = "(function (){\"use strict\";return{ReadableStream,ReadableStreamDefaultReader,ReadableStreamBYOBReader,ReadableStreamBYOBRequest,ReadableByteStreamController,ReadableStreamDefaultController,TransformStream,TransformStreamDefaultController,WritableStream,WritableStreamDefaultWriter,WritableStreamDefaultController,ByteLengthQueuingStrategy,CountQueuingStrategy}})\n"_s; +// + +// static constexpr ASCIILiteral NodeTimersCode = "(function (){\"use strict\";return{setTimeout,clearTimeout,setInterval,setImmediate,clearInterval,clearImmediate}})\n"_s; +// + +// static constexpr ASCIILiteral NodeTimersPromisesCode = "(function (){\"use strict\";var $;const symbolAsyncIterator=Symbol.asyncIterator;class ERR_INVALID_ARG_TYPE extends Error{constructor(name,expected,actual){super(`${name} must be ${expected}, ${typeof actual} given`);this.code=\"ERR_INVALID_ARG_TYPE\"}}class AbortError extends Error{constructor(){super(\"The operation was aborted\");this.code=\"ABORT_ERR\"}}function validateObject(object,name){if(object===null||typeof object!==\"object\")throw new ERR_INVALID_ARG_TYPE(name,\"Object\",object)}function validateBoolean(value,name){if(typeof value!==\"boolean\")throw new ERR_INVALID_ARG_TYPE(name,\"boolean\",value)}function validateAbortSignal(signal,name){if(typeof signal!==\"undefined\"&&(signal===null||typeof signal!==\"object\"||!(\"aborted\"in signal)))throw new ERR_INVALID_ARG_TYPE(name,\"AbortSignal\",signal)}function asyncIterator({next:nextFunction,return:returnFunction}){const result={};if(typeof nextFunction===\"function\")result.next=nextFunction;if(typeof returnFunction===\"function\")result.return=returnFunction;return result[symbolAsyncIterator]=function(){return this},result}function setTimeoutPromise(after=1,value,options={}){const arguments_=[].concat(value\?\?[]);try{validateObject(options,\"options\")}catch(error){return Promise.reject(error)}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return Promise.reject(error)}try{validateBoolean(reference,\"options.ref\")}catch(error){return Promise.reject(error)}if(signal\?.aborted)return Promise.reject(new AbortError);let onCancel;const returnValue=new Promise((resolve,reject)=>{const timeout=setTimeout(()=>resolve(value),after,...arguments_);if(!reference)timeout\?.unref\?.();if(signal)onCancel=()=>{clearTimeout(timeout),reject(new AbortError)},signal.addEventListener(\"abort\",onCancel)});if(typeof onCancel!==\"undefined\")returnValue.finally(()=>signal.removeEventListener(\"abort\",onCancel));return returnValue}function setImmediatePromise(value,options={}){try{validateObject(options,\"options\")}catch(error){return Promise.reject(error)}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return Promise.reject(error)}try{validateBoolean(reference,\"options.ref\")}catch(error){return Promise.reject(error)}if(signal\?.aborted)return Promise.reject(new AbortError);let onCancel;const returnValue=new Promise((resolve,reject)=>{const immediate=setImmediate(()=>resolve(value));if(!reference)immediate\?.unref\?.();if(signal)onCancel=()=>{clearImmediate(immediate),reject(new AbortError)},signal.addEventListener(\"abort\",onCancel)});if(typeof onCancel!==\"undefined\")returnValue.finally(()=>signal.removeEventListener(\"abort\",onCancel));return returnValue}function setIntervalPromise(after=1,value,options={}){try{validateObject(options,\"options\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}const{signal,ref:reference=!0}=options;try{validateAbortSignal(signal,\"options.signal\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}try{validateBoolean(reference,\"options.ref\")}catch(error){return asyncIterator({next:function(){return Promise.reject(error)}})}if(signal\?.aborted)return asyncIterator({next:function(){return Promise.reject(new AbortError)}});let onCancel,interval;try{let notYielded=0,callback;if(interval=setInterval(()=>{if(notYielded++,callback)callback(),callback=void 0},after),!reference)interval\?.unref\?.();if(signal)onCancel=()=>{if(clearInterval(interval),callback)callback(),callback=void 0},signal.addEventListener(\"abort\",onCancel);return asyncIterator({next:function(){return new Promise((resolve,reject)=>{if(!signal\?.aborted)if(notYielded===0)callback=resolve;else resolve();else if(notYielded===0)reject(new AbortError);else resolve()}).then(()=>{if(notYielded>0)return notYielded=notYielded-1,{done:!1,value};return{done:!0}})},return:function(){return clearInterval(interval),signal\?.removeEventListener(\"abort\",onCancel),Promise.resolve({})}})}catch(error){return asyncIterator({next:function(){clearInterval(interval),signal\?.removeEventListener(\"abort\",onCancel)}})}}return $={setTimeout:setTimeoutPromise,setImmediate:setImmediatePromise,setInterval:setIntervalPromise,scheduler:{wait:(delay,options)=>setTimeoutPromise(delay,void 0,options),yield:setImmediatePromise}},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeTLSCode = "(function (){\"use strict\";const{isArrayBufferView,isTypedArray}=@requireNativeModule(\"node:util/types\"),net=@getInternalField(@internalModuleRegistry,22)||@createInternalModuleById(22),{Server:NetServer,[Symbol.for(\"::bunternal::\")]:InternalTCPSocket}=net,bunSocketInternal=Symbol.for(\"::bunnetsocketinternal::\"),{rootCertificates,canonicalizeIP}=globalThis[globalThis.Symbol.for('Bun.lazy')](\"internal/tls\"),SymbolReplace=Symbol.replace,RegExpPrototypeSymbolReplace=RegExp.prototype[SymbolReplace],RegExpPrototypeExec=RegExp.prototype.exec,StringPrototypeStartsWith=String.prototype.startsWith,StringPrototypeSlice=String.prototype.slice,StringPrototypeIncludes=String.prototype.includes,StringPrototypeSplit=String.prototype.split,StringPrototypeIndexOf=String.prototype.indexOf,StringPrototypeSubstring=String.prototype.substring,StringPrototypeEndsWith=String.prototype.endsWith,StringFromCharCode=String.fromCharCode,StringPrototypeCharCodeAt=String.prototype.charCodeAt,ArrayPrototypeIncludes=Array.prototype.includes,ArrayPrototypeJoin=Array.prototype.join,ArrayPrototypeForEach=Array.prototype.forEach,ArrayPrototypePush=Array.prototype.push,ArrayPrototypeSome=Array.prototype.some,ArrayPrototypeReduce=Array.prototype.reduce;function parseCertString(){throwNotImplemented(\"Not implemented\")}function isValidTLSArray(obj){if(typeof obj===\"string\"||isTypedArray(obj)||obj instanceof ArrayBuffer||obj instanceof Blob)return!0;if(Array.isArray(obj)){for(var i=0;iRegExpPrototypeExec.call(/[^\\u0021-\\u007F]/u,s)!==null;if(ArrayPrototypeSome.call(patternParts,isBad))return!1;for(let i=hostParts.length-1;i>0;i-=1)if(hostParts[i]!==patternParts[i])return!1;const hostSubdomain=hostParts[0],patternSubdomain=patternParts[0],patternSubdomainParts=StringPrototypeSplit.call(patternSubdomain,\"*\");if(patternSubdomainParts.length===1||StringPrototypeIncludes.call(patternSubdomain,\"xn--\"))return hostSubdomain===patternSubdomain;if(!wildcards)return!1;if(patternSubdomainParts.length>2)return!1;if(patternParts.length<=2)return!1;const{0:prefix,1:suffix}=patternSubdomainParts;if(prefix.length+suffix.length>hostSubdomain.length)return!1;if(!StringPrototypeStartsWith.call(hostSubdomain,prefix))return!1;if(!StringPrototypeEndsWith.call(hostSubdomain,suffix))return!1;return!0}const jsonStringPattern=/^\"(\?:[^\"\\\\\\u0000-\\u001f]|\\\\(\?:[\"\\\\/bfnrt]|u[0-9a-fA-F]{4}))*\"/;function splitEscapedAltNames(altNames){const result=[];let currentToken=\"\",offset=0;while(offset!==altNames.length){const nextSep=StringPrototypeIndexOf.call(altNames,\", \",offset),nextQuote=StringPrototypeIndexOf.call(altNames,'\"',offset);if(nextQuote!==-1&&(nextSep===-1||nextQuote{if(StringPrototypeStartsWith.call(name,\"DNS:\"))ArrayPrototypePush.call(dnsNames,StringPrototypeSlice.call(name,4));else if(StringPrototypeStartsWith.call(name,\"IP Address:\"))ArrayPrototypePush.call(ips,canonicalizeIP(StringPrototypeSlice.call(name,11)))})}let valid=!1,reason=\"Unknown reason\";if(hostname=unfqdn(hostname),net.isIP(hostname)){if(valid=ArrayPrototypeIncludes.call(ips,canonicalizeIP(hostname)),!valid)reason=`IP: ${hostname} is not in the cert's list: `+ArrayPrototypeJoin.call(ips,\", \")}else if(dnsNames.length>0||subject\?.CN){const hostParts=splitHost(hostname),wildcard=(pattern)=>check(hostParts,pattern,!0);if(dnsNames.length>0){if(valid=ArrayPrototypeSome.call(dnsNames,wildcard),!valid)reason=`Host: ${hostname}. is not in the cert's altnames: ${altNames}`}else{const cn=subject.CN;if(Array.isArray(cn))valid=ArrayPrototypeSome.call(cn,wildcard);else if(cn)valid=wildcard(cn);if(!valid)reason=`Host: ${hostname}. is not cert's CN: ${cn}`}}else reason=\"Cert does not contain a DNS name\";if(!valid){let error=new Error(`ERR_TLS_CERT_ALTNAME_INVALID: Hostname/IP does not match certificate's altnames: ${reason}`);return error.name=\"ERR_TLS_CERT_ALTNAME_INVALID\",error.reason=reason,error.host=host,error.cert=cert,error}}var InternalSecureContext=class SecureContext2{context;constructor(options){const context={};if(options){let key=options.key;if(key){if(!isValidTLSArray(key))@throwTypeError(\"key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.key=key}let cert=options.cert;if(cert){if(!isValidTLSArray(cert))@throwTypeError(\"cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.cert=cert}let ca=options.ca;if(ca){if(!isValidTLSArray(ca))@throwTypeError(\"ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.ca=ca}let passphrase=options.passphrase;if(passphrase&&typeof passphrase!==\"string\")@throwTypeError(\"passphrase argument must be an string\");this.passphrase=passphrase;let servername=options.servername;if(servername&&typeof servername!==\"string\")@throwTypeError(\"servername argument must be an string\");this.servername=servername;let secureOptions=options.secureOptions||0;if(secureOptions&&typeof secureOptions!==\"number\")@throwTypeError(\"secureOptions argument must be an number\");this.secureOptions=secureOptions}this.context=context}};function SecureContext(options){return new InternalSecureContext(options)}function createSecureContext(options){return new SecureContext(options)}function translatePeerCertificate(c){if(!c)return null;if(c.issuerCertificate!=null&&c.issuerCertificate!==c)c.issuerCertificate=translatePeerCertificate(c.issuerCertificate);if(c.infoAccess!=null){const info=c.infoAccess;c.infoAccess={__proto__:null},RegExpPrototypeSymbolReplace.call(/([^\\n:]*):([^\\n]*)(\?:\\n|$)/g,info,(all,key,val)=>{if(val.charCodeAt(0)===34)val=JSONParse(val);if(key in c.infoAccess)ArrayPrototypePush.call(c.infoAccess[key],val);else c.infoAccess[key]=[val]})}return c}const buntls=Symbol.for(\"::buntls::\");var SocketClass;const TLSSocket=function(InternalTLSSocket){return SocketClass=InternalTLSSocket,Object.defineProperty(SocketClass.prototype,Symbol.toStringTag,{value:\"TLSSocket\",enumerable:!1}),Object.defineProperty(function Socket(options){return new InternalTLSSocket(options)},Symbol.hasInstance,{value(instance){return instance instanceof InternalTLSSocket}})}(class TLSSocket2 extends InternalTCPSocket{#secureContext;ALPNProtocols;#socket;#checkServerIdentity;#session;constructor(socket,options){super(socket instanceof InternalTCPSocket\?options:options||socket);if(options=options||socket||{},typeof options===\"object\"){const{ALPNProtocols}=options;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,this);if(socket instanceof InternalTCPSocket)this.#socket=socket}this.#secureContext=options.secureContext||createSecureContext(options),this.authorized=!1,this.secureConnecting=!0,this._secureEstablished=!1,this._securePending=!0,this.#checkServerIdentity=options.checkServerIdentity||checkServerIdentity,this.#session=options.session||null}_secureEstablished=!1;_securePending=!0;_newSessionPending;_controlReleased;secureConnecting=!1;_SNICallback;servername;authorized=!1;authorizationError;#renegotiationDisabled=!1;encrypted=!0;_start(){this.connect()}getSession(){return this[bunSocketInternal]\?.getSession()}getEphemeralKeyInfo(){return this[bunSocketInternal]\?.getEphemeralKeyInfo()}getCipher(){return this[bunSocketInternal]\?.getCipher()}getSharedSigalgs(){return this[bunSocketInternal]\?.getSharedSigalgs()}getProtocol(){return this[bunSocketInternal]\?.getTLSVersion()}getFinished(){return this[bunSocketInternal]\?.getTLSFinishedMessage()||void 0}getPeerFinished(){return this[bunSocketInternal]\?.getTLSPeerFinishedMessage()||void 0}isSessionReused(){return!!this.#session}renegotiate(){if(this.#renegotiationDisabled){const error=new Error(\"ERR_TLS_RENEGOTIATION_DISABLED: TLS session renegotiation disabled for this socket\");throw error.name=\"ERR_TLS_RENEGOTIATION_DISABLED\",error}throw Error(\"Not implented in Bun yet\")}disableRenegotiation(){this.#renegotiationDisabled=!0}getTLSTicket(){return this[bunSocketInternal]\?.getTLSTicket()}exportKeyingMaterial(length,label,context){if(context)return this[bunSocketInternal]\?.exportKeyingMaterial(length,label,context);return this[bunSocketInternal]\?.exportKeyingMaterial(length,label)}setMaxSendFragment(size){return this[bunSocketInternal]\?.setMaxSendFragment(size)||!1}enableTrace(){}setServername(name){if(this.isServer){let error=new Error(\"ERR_TLS_SNI_FROM_SERVER: Cannot issue SNI from a TLS server-side socket\");throw error.name=\"ERR_TLS_SNI_FROM_SERVER\",error}this.servername=name,this[bunSocketInternal]\?.setServername(name)}setSession(session){if(this.#session=session,typeof session===\"string\")session=Buffer.from(session,\"latin1\");return this[bunSocketInternal]\?.setSession(session)}getPeerCertificate(abbreviated){const cert=arguments.length<1\?this[bunSocketInternal]\?.getPeerCertificate():this[bunSocketInternal]\?.getPeerCertificate(abbreviated);if(cert)return translatePeerCertificate(cert)}getCertificate(){const cert=this[bunSocketInternal]\?.getCertificate();if(cert)return translatePeerCertificate(cert)}getPeerX509Certificate(){throw Error(\"Not implented in Bun yet\")}getX509Certificate(){throw Error(\"Not implented in Bun yet\")}get alpnProtocol(){return this[bunSocketInternal]\?.alpnProtocol}[buntls](port,host2){return{socket:this.#socket,ALPNProtocols:this.ALPNProtocols,serverName:this.servername||host2||\"localhost\",checkServerIdentity:this.#checkServerIdentity,session:this.#session,...this.#secureContext}}});class Server extends NetServer{key;cert;ca;passphrase;secureOptions;_rejectUnauthorized;_requestCert;servername;ALPNProtocols;constructor(options,secureConnectionListener){super(options,secureConnectionListener);this.setSecureContext(options)}setSecureContext(options){if(options instanceof InternalSecureContext)options=options.context;if(options){const{ALPNProtocols}=options;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,this);let key=options.key;if(key){if(!isValidTLSArray(key))@throwTypeError(\"key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.key=key}let cert=options.cert;if(cert){if(!isValidTLSArray(cert))@throwTypeError(\"cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.cert=cert}let ca=options.ca;if(ca){if(!isValidTLSArray(ca))@throwTypeError(\"ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile\");this.ca=ca}let passphrase=options.passphrase;if(passphrase&&typeof passphrase!==\"string\")@throwTypeError(\"passphrase argument must be an string\");this.passphrase=passphrase;let servername=options.servername;if(servername&&typeof servername!==\"string\")@throwTypeError(\"servername argument must be an string\");this.servername=servername;let secureOptions=options.secureOptions||0;if(secureOptions&&typeof secureOptions!==\"number\")@throwTypeError(\"secureOptions argument must be an number\");this.secureOptions=secureOptions;const requestCert=options.requestCert||!1;if(requestCert)this._requestCert=requestCert;else this._requestCert=void 0;const rejectUnauthorized=options.rejectUnauthorized||!1;if(rejectUnauthorized)this._rejectUnauthorized=rejectUnauthorized;else this._rejectUnauthorized=void 0}}getTicketKeys(){throw Error(\"Not implented in Bun yet\")}setTicketKeys(){throw Error(\"Not implented in Bun yet\")}[buntls](port,host2,isClient){return[{serverName:this.servername||host2||\"localhost\",key:this.key,cert:this.cert,ca:this.ca,passphrase:this.passphrase,secureOptions:this.secureOptions,rejectUnauthorized:isClient\?!1:this._rejectUnauthorized,requestCert:isClient\?!1:this._requestCert,ALPNProtocols:this.ALPNProtocols},SocketClass]}}function createServer(options,connectionListener){return new Server(options,connectionListener)}const CLIENT_RENEG_LIMIT=3,CLIENT_RENEG_WINDOW=600,DEFAULT_ECDH_CURVE=\"auto\",DEFAULT_CIPHERS=\"DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256\",DEFAULT_MIN_VERSION=\"TLSv1.2\",DEFAULT_MAX_VERSION=\"TLSv1.3\",createConnection=(port,host2,connectListener)=>{if(typeof port===\"object\"){port.checkServerIdentity;const{ALPNProtocols}=port;if(ALPNProtocols)convertALPNProtocols(ALPNProtocols,port);return new TLSSocket(port).connect(port,host2,connectListener)}return new TLSSocket().connect(port,host2,connectListener)},connect=createConnection;function getCiphers(){return DEFAULT_CIPHERS.split(\":\")}function convertProtocols(protocols){const lens=new Array(protocols.length),buff=Buffer.allocUnsafe(ArrayPrototypeReduce.call(protocols,(p,c,i)=>{const len=Buffer.byteLength(c);if(len>255)@throwRangeError(\"The byte length of the protocol at index \"+`${i} exceeds the maximum length.`,\"<= 255\",len,!0);return lens[i]=len,p+1+len},0));let offset=0;for(let i=0,c=protocols.length;i\",'\"',\"`\",\" \",\"\\r\",\"\\n\",\"\\t\"],unwise=[\"{\",\"}\",\"|\",\"\\\\\",\"^\",\"`\"].concat(delims),autoEscape=[\"'\"].concat(unwise),nonHostChars=[\"%\",\"/\",\"\?\",\";\",\"#\"].concat(autoEscape),hostEndingChars=[\"/\",\"\?\",\"#\"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,\"javascript:\":!0},hostlessProtocol={javascript:!0,\"javascript:\":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,\"http:\":!0,\"https:\":!0,\"ftp:\":!0,\"gopher:\":!0,\"file:\":!0};function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&typeof url===\"object\"&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(typeof url!==\"string\")@throwTypeError(\"Parameter 'url' must be a string, not \"+typeof url);var queryIndex=url.indexOf(\"\?\"),splitter=queryIndex!==-1&&queryIndex127)newpart+=\"x\";else newpart+=part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(hostnamePartStart);if(bit)validParts.push(bit[1]),notHost.unshift(bit[2]);if(notHost.length)rest=\"/\"+notHost.join(\".\")+rest;this.hostname=validParts.join(\".\");break}}}}if(this.hostname.length>hostnameMaxLen)this.hostname=\"\";else this.hostname=this.hostname.toLowerCase();if(!ipv6Hostname)this.hostname=new URL(\"http://\"+this.hostname).hostname;var p=this.port\?\":\"+this.port:\"\",h=this.hostname||\"\";if(this.host=h+p,this.href+=this.host,ipv6Hostname){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),rest[0]!==\"/\")rest=\"/\"+rest}}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length;i0\?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.hostname=authInHost.shift(),result.host=result.hostname}if(result.search=relative.search,result.query=relative.query,result.pathname!==null||result.search!==null)result.path=(result.pathname\?result.pathname:\"\")+(result.search\?result.search:\"\");return result.href=result.format(),result}if(!srcPath.length){if(result.pathname=null,result.search)result.path=\"/\"+result.search;else result.path=null;return result.href=result.format(),result}var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&(last===\".\"||last===\"..\")||last===\"\",up=0;for(var i=srcPath.length;i>=0;i--)if(last=srcPath[i],last===\".\")srcPath.splice(i,1);else if(last===\"..\")srcPath.splice(i,1),up++;else if(up)srcPath.splice(i,1),up--;if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift(\"..\");if(mustEndAbs&&srcPath[0]!==\"\"&&(!srcPath[0]||srcPath[0].charAt(0)!==\"/\"))srcPath.unshift(\"\");if(hasTrailingSlash&&srcPath.join(\"/\").substr(-1)!==\"/\")srcPath.push(\"\");var isAbsolute=srcPath[0]===\"\"||srcPath[0]&&srcPath[0].charAt(0)===\"/\";if(psychotic){result.hostname=isAbsolute\?\"\":srcPath.length\?srcPath.shift():\"\",result.host=result.hostname;var authInHost=result.host&&result.host.indexOf(\"@\")>0\?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.hostname=authInHost.shift(),result.host=result.hostname}if(mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute)srcPath.unshift(\"\");if(srcPath.length>0)result.pathname=srcPath.join(\"/\");else result.pathname=null,result.path=null;if(result.pathname!==null||result.search!==null)result.path=(result.pathname\?result.pathname:\"\")+(result.search\?result.search:\"\");return result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result},Url.prototype.parseHost=function(){var host=this.host,port=portPattern.exec(host);if(port){if(port=port[0],port!==\":\")this.port=port.substr(1);host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};function urlToHttpOptions(url){const options={protocol:url.protocol,hostname:typeof url.hostname===\"string\"&&url.hostname.startsWith(\"[\")\?url.hostname.slice(1,-1):url.hostname,hash:url.hash,search:url.search,pathname:url.pathname,path:`${url.pathname||\"\"}${url.search||\"\"}`,href:url.href};if(url.port!==\"\")options.port=Number(url.port);if(url.username||url.password)options.auth=`${decodeURIComponent(url.username)}:${decodeURIComponent(url.password)}`;return options}const pathToFileURL=globalThis[globalThis.Symbol.for('Bun.lazy')](\"pathToFileURL\"),fileURLToPath=globalThis[globalThis.Symbol.for('Bun.lazy')](\"fileURLToPath\");return{parse:urlParse,resolve:urlResolve,resolveObject:urlResolveObject,format:urlFormat,Url,URLSearchParams,URL,pathToFileURL,fileURLToPath,urlToHttpOptions}})\n"_s; +// + +// static constexpr ASCIILiteral NodeUtilCode = "(function (){\"use strict\";const types=@requireNativeModule(\"node:util/types\");var cjs_exports={};function isBufferInterface({copy,fill,readUint8}){return typeof copy===\"function\"&&typeof fill===\"function\"&&typeof readUint8===\"function\"}function isBuffer(value){return Buffer.isBuffer(value)||typeof value===\"object\"&&isBufferInterface(value||{})}function isFunction(value){return typeof value===\"function\"}const deepEquals=Bun.deepEquals,isDeepStrictEqual=(a,b)=>deepEquals(a,b,!0);var getOwnPropertyDescriptors=Object.getOwnPropertyDescriptors,formatRegExp=/%[sdj%]/g;function format(f){if(!isString(f)){var objects=[];for(var i=0;i=len)return x2;switch(x2){case\"%s\":return String(args[i++]);case\"%d\":return Number(args[i++]);case\"%j\":try{return JSON.stringify(args[i++])}catch(_){return\"[Circular]\"}default:return x2}});for(var x=args[i];i=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts))ctx.showHidden=opts;else if(opts)_extend(ctx,opts);if(isUndefined(ctx.showHidden))ctx.showHidden=!1;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=!1;if(isUndefined(ctx.customInspect))ctx.customInspect=!0;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:\"cyan\",number:\"yellow\",boolean:\"yellow\",undefined:\"grey\",null:\"bold\",string:\"green\",date:\"magenta\",regexp:\"red\"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style)return\"\\x1B[\"+inspect.colors[style][0]+\"m\"+str+\"\\x1B[\"+inspect.colors[style][1]+\"m\";else return str}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};return array.forEach(function(val,idx){hash[val]=!0}),hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret))ret=formatValue(ctx,ret,recurseTimes);return ret}var primitive=formatPrimitive(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=arrayToHash(keys);if(ctx.showHidden)keys=Object.getOwnPropertyNames(value);if(isError(value)&&(keys.indexOf(\"message\")>=0||keys.indexOf(\"description\")>=0))return formatError(value);if(keys.length===0){if(isFunction(value)){var name=value.name\?\": \"+value.name:\"\";return ctx.stylize(\"[Function\"+name+\"]\",\"special\")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),\"regexp\");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),\"date\");if(isError(value))return formatError(value)}var base=\"\",array=!1,braces=[\"{\",\"}\"];if(@isArray(value))array=!0,braces=[\"[\",\"]\"];if(isFunction(value)){var n=value.name\?\": \"+value.name:\"\";base=\" [Function\"+n+\"]\"}if(isRegExp(value))base=\" \"+RegExp.prototype.toString.call(value);if(isDate(value))base=\" \"+Date.prototype.toUTCString.call(value);if(isError(value))base=\" \"+formatError(value);if(keys.length===0&&(!array||value.length==0))return braces[0]+base+braces[1];if(recurseTimes<0)if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),\"regexp\");else return ctx.stylize(\"[Object]\",\"special\");ctx.seen.push(value);var output;if(array)output=formatArray(ctx,value,recurseTimes,visibleKeys,keys);else output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)});return ctx.seen.pop(),reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize(\"undefined\",\"undefined\");if(isString(value)){var simple=\"'\"+JSON.stringify(value).replace(/^\"|\"$/g,\"\").replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"')+\"'\";return ctx.stylize(simple,\"string\")}if(isNumber(value))return ctx.stylize(\"\"+value,\"number\");if(isBoolean(value))return ctx.stylize(\"\"+value,\"boolean\");if(isNull(value))return ctx.stylize(\"null\",\"null\")}function formatError(value){return\"[\"+Error.prototype.toString.call(value)+\"]\"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i-1)if(array)str=str.split(\"\\n\").map(function(line){return\" \"+line}).join(\"\\n\").substr(2);else str=\"\\n\"+str.split(\"\\n\").map(function(line){return\" \"+line}).join(\"\\n\")}else str=ctx.stylize(\"[Circular]\",\"special\");if(isUndefined(name)){if(array&&key.match(/^\\d+$/))return str;if(name=JSON.stringify(\"\"+key),name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/))name=name.substr(1,name.length-2),name=ctx.stylize(name,\"name\");else name=name.replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"').replace(/(^\"|\"$)/g,\"'\"),name=ctx.stylize(name,\"string\")}return name+\": \"+str}function reduceToSingleString(output,base,braces){var numLinesEst=0,length=output.reduce(function(prev,cur){if(numLinesEst++,cur.indexOf(\"\\n\")>=0)numLinesEst++;return prev+cur.replace(/\\u001b\\[\\d\\d\?m/g,\"\").length+1},0);if(length>60)return braces[0]+(base===\"\"\?\"\":base+\"\\n \")+\" \"+output.join(\",\\n \")+\" \"+braces[1];return braces[0]+base+\" \"+output.join(\", \")+\" \"+braces[1]}function isBoolean(arg){return typeof arg===\"boolean\"}function isNull(arg){return arg===null}function isNullOrUndefined(arg){return arg==null}function isNumber(arg){return typeof arg===\"number\"}function isString(arg){return typeof arg===\"string\"}function isSymbol(arg){return typeof arg===\"symbol\"}function isUndefined(arg){return arg===void 0}var isRegExp=types.isRegExp;function isObject(arg){return typeof arg===\"object\"&&arg!==null}var{isDate,isNativeError:isError}=types;function isPrimitive(arg){return arg===null||typeof arg===\"boolean\"||typeof arg===\"number\"||typeof arg===\"string\"||typeof arg===\"symbol\"||typeof arg===\"undefined\"}function pad(n){return n<10\?\"0\"+n.toString(10):n.toString(10)}var months=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];function timestamp(){var d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(\":\");return[d.getDate(),months[d.getMonth()],time].join(\" \")}var log=function log(){console.log(\"%s - %s\",timestamp(),format.apply(cjs_exports,arguments))},inherits=function inherits(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})},_extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add),i=keys.length;while(i--)origin[keys[i]]=add[keys[i]];return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}var kCustomPromisifiedSymbol=Symbol.for(\"util.promisify.custom\"),promisify=function promisify(original){if(typeof original!==\"function\")@throwTypeError('The \"original\" argument must be of type Function');if(kCustomPromisifiedSymbol&&original[kCustomPromisifiedSymbol]){var fn=original[kCustomPromisifiedSymbol];if(typeof fn!==\"function\")@throwTypeError('The \"util.promisify.custom\" argument must be of type Function');return Object.defineProperty(fn,kCustomPromisifiedSymbol,{value:fn,enumerable:!1,writable:!1,configurable:!0}),fn}function fn(){var promiseResolve,promiseReject,promise=new Promise(function(resolve,reject){promiseResolve=resolve,promiseReject=reject}),args=[];for(var i=0;i{return(input+\"\").toWellFormed()};return Object.assign(cjs_exports,{format,deprecate,debuglog,_extend,inspect,types,isArray:@isArray,isBoolean,isNull,isNullOrUndefined,isNumber,isString,isSymbol,isUndefined,isRegExp,isObject,isDate,isFunction,isError,isPrimitive,isBuffer,log,inherits,toUSVString,promisify,callbackify,isDeepStrictEqual,TextDecoder,TextEncoder})})\n"_s; +// + +// static constexpr ASCIILiteral NodeV8Code = "(function (){\"use strict\";var $;const{hideFromStack,throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),jsc=@requireNativeModule(\"bun:jsc\");function notimpl(message){throwNotImplemented(\"node:v8 \"+message)}class Deserializer{constructor(){notimpl(\"Deserializer\")}}class Serializer{constructor(){notimpl(\"Serializer\")}}class DefaultDeserializer extends Deserializer{constructor(){super(...arguments)}}class DefaultSerializer extends Serializer{constructor(){super(...arguments)}}class GCProfiler{constructor(){notimpl(\"GCProfiler\")}}function cachedDataVersionTag(){notimpl(\"cachedDataVersionTag\")}function getHeapSnapshot(){notimpl(\"getHeapSnapshot\")}function getHeapStatistics(){notimpl(\"getHeapStatistics\")}function getHeapSpaceStatistics(){notimpl(\"getHeapSpaceStatistics\")}function getHeapCodeStatistics(){notimpl(\"getHeapCodeStatistics\")}function setFlagsFromString(){notimpl(\"setFlagsFromString\")}function deserialize(value){return jsc.deserialize(value)}function takeCoverage(){notimpl(\"takeCoverage\")}function stopCoverage(){notimpl(\"stopCoverage\")}function serialize(arg1){return jsc.serialize(arg1,{binaryType:\"nodebuffer\"})}function writeHeapSnapshot(){notimpl(\"writeHeapSnapshot\")}function setHeapSnapshotNearHeapLimit(){notimpl(\"setHeapSnapshotNearHeapLimit\")}return $={cachedDataVersionTag,getHeapSnapshot,getHeapStatistics,getHeapSpaceStatistics,getHeapCodeStatistics,setFlagsFromString,deserialize,takeCoverage,stopCoverage,serialize,writeHeapSnapshot,setHeapSnapshotNearHeapLimit,promiseHooks:{createHook:()=>{notimpl(\"createHook\")},onInit:()=>{notimpl(\"onInit\")},onBefore:()=>{notimpl(\"onBefore\")},onAfter:()=>{notimpl(\"onAfter\")},onSettled:()=>{notimpl(\"onSettled\")}},startupSnapshot:{addDeserializeCallback:()=>notimpl(\"addDeserializeCallback\"),addSerializeCallback:()=>notimpl(\"addSerializeCallback\"),setDeserializeMainFunction:()=>notimpl(\"setDeserializeMainFunction\"),isBuildingSnapshot:()=>notimpl(\"isBuildingSnapshot\")},Deserializer,Serializer},hideFromStack(notimpl,cachedDataVersionTag,getHeapSnapshot,getHeapStatistics,getHeapSpaceStatistics,getHeapCodeStatistics,setFlagsFromString,deserialize,takeCoverage,stopCoverage,serialize,writeHeapSnapshot,setHeapSnapshotNearHeapLimit,Deserializer,Serializer,DefaultDeserializer,DefaultSerializer,GCProfiler),$})\n"_s; +// + +// static constexpr ASCIILiteral NodeVMCode = "(function (){\"use strict\";const{throwNotImplemented}=@getInternalField(@internalModuleRegistry,2)||@createInternalModuleById(2),vm=globalThis[globalThis.Symbol.for('Bun.lazy')](\"vm\"),{createContext,isContext,Script,runInNewContext,runInThisContext}=vm;function runInContext(code,context,options){return new Script(code,options).runInContext(context)}function compileFunction(){throwNotImplemented(\"node:vm compileFunction\")}function measureMemory(){throwNotImplemented(\"node:vm measureMemory\")}class Module{constructor(){throwNotImplemented(\"node:vm Module\")}}class SourceTextModule{constructor(){throwNotImplemented(\"node:vm Module\")}}class SyntheticModule{constructor(){throwNotImplemented(\"node:vm Module\")}}return{createContext,runInContext,runInNewContext,runInThisContext,isContext,compileFunction,measureMemory,Script,Module,SourceTextModule,SyntheticModule}})\n"_s; +// + +// static constexpr ASCIILiteral NodeWasiCode = "(function (){\"use strict\";const nodeFsConstants=@processBindingConstants.fs;var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require2(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_types=__commonJS({\"node_modules/wasi-js/dist/types.js\"(exports){Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.WASIKillError=exports.WASIExitError=exports.WASIError=void 0;var WASIError=class extends Error{constructor(errno){super();this.errno=errno,Object.setPrototypeOf(this,WASIError.prototype)}};exports.WASIError=WASIError;var WASIExitError=class extends Error{constructor(code){super(`WASI Exit error: ${code}`);this.code=code,Object.setPrototypeOf(this,WASIExitError.prototype)}};exports.WASIExitError=WASIExitError;var WASIKillError=class extends Error{constructor(signal){super(`WASI Kill signal: ${signal}`);this.signal=signal,Object.setPrototypeOf(this,WASIKillError.prototype)}};exports.WASIKillError=WASIKillError}}),require_constants=__commonJS({\"node_modules/wasi-js/dist/constants.js\"(exports){Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.WASI_ENOMSG=exports.WASI_ENOMEM=exports.WASI_ENOLINK=exports.WASI_ENOLCK=exports.WASI_ENOEXEC=exports.WASI_ENOENT=exports.WASI_ENODEV=exports.WASI_ENOBUFS=exports.WASI_ENFILE=exports.WASI_ENETUNREACH=exports.WASI_ENETRESET=exports.WASI_ENETDOWN=exports.WASI_ENAMETOOLONG=exports.WASI_EMULTIHOP=exports.WASI_EMSGSIZE=exports.WASI_EMLINK=exports.WASI_EMFILE=exports.WASI_ELOOP=exports.WASI_EISDIR=exports.WASI_EISCONN=exports.WASI_EIO=exports.WASI_EINVAL=exports.WASI_EINTR=exports.WASI_EINPROGRESS=exports.WASI_EILSEQ=exports.WASI_EIDRM=exports.WASI_EHOSTUNREACH=exports.WASI_EFBIG=exports.WASI_EFAULT=exports.WASI_EEXIST=exports.WASI_EDQUOT=exports.WASI_EDOM=exports.WASI_EDESTADDRREQ=exports.WASI_EDEADLK=exports.WASI_ECONNRESET=exports.WASI_ECONNREFUSED=exports.WASI_ECONNABORTED=exports.WASI_ECHILD=exports.WASI_ECANCELED=exports.WASI_EBUSY=exports.WASI_EBADMSG=exports.WASI_EBADF=exports.WASI_EALREADY=exports.WASI_EAGAIN=exports.WASI_EAFNOSUPPORT=exports.WASI_EADDRNOTAVAIL=exports.WASI_EADDRINUSE=exports.WASI_EACCES=exports.WASI_E2BIG=exports.WASI_ESUCCESS=void 0,exports.WASI_SIGVTALRM=exports.WASI_SIGUSR2=exports.WASI_SIGUSR1=exports.WASI_SIGURG=exports.WASI_SIGTTOU=exports.WASI_SIGTTIN=exports.WASI_SIGTSTP=exports.WASI_SIGTRAP=exports.WASI_SIGTERM=exports.WASI_SIGSTOP=exports.WASI_SIGSEGV=exports.WASI_SIGQUIT=exports.WASI_SIGPIPE=exports.WASI_SIGKILL=exports.WASI_SIGINT=exports.WASI_SIGILL=exports.WASI_SIGHUP=exports.WASI_SIGFPE=exports.WASI_SIGCONT=exports.WASI_SIGCHLD=exports.WASI_SIGBUS=exports.WASI_SIGALRM=exports.WASI_SIGABRT=exports.WASI_ENOTCAPABLE=exports.WASI_EXDEV=exports.WASI_ETXTBSY=exports.WASI_ETIMEDOUT=exports.WASI_ESTALE=exports.WASI_ESRCH=exports.WASI_ESPIPE=exports.WASI_EROFS=exports.WASI_ERANGE=exports.WASI_EPROTOTYPE=exports.WASI_EPROTONOSUPPORT=exports.WASI_EPROTO=exports.WASI_EPIPE=exports.WASI_EPERM=exports.WASI_EOWNERDEAD=exports.WASI_EOVERFLOW=exports.WASI_ENXIO=exports.WASI_ENOTTY=exports.WASI_ENOTSUP=exports.WASI_ENOTSOCK=exports.WASI_ENOTRECOVERABLE=exports.WASI_ENOTEMPTY=exports.WASI_ENOTDIR=exports.WASI_ENOTCONN=exports.WASI_ENOSYS=exports.WASI_ENOSPC=exports.WASI_ENOPROTOOPT=void 0,exports.RIGHTS_REGULAR_FILE_BASE=exports.RIGHTS_CHARACTER_DEVICE_INHERITING=exports.RIGHTS_CHARACTER_DEVICE_BASE=exports.RIGHTS_BLOCK_DEVICE_INHERITING=exports.RIGHTS_BLOCK_DEVICE_BASE=exports.RIGHTS_ALL=exports.WASI_RIGHT_SOCK_SHUTDOWN=exports.WASI_RIGHT_POLL_FD_READWRITE=exports.WASI_RIGHT_PATH_UNLINK_FILE=exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY=exports.WASI_RIGHT_PATH_SYMLINK=exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES=exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE=exports.WASI_RIGHT_FD_FILESTAT_GET=exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES=exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE=exports.WASI_RIGHT_PATH_FILESTAT_GET=exports.WASI_RIGHT_PATH_RENAME_TARGET=exports.WASI_RIGHT_PATH_RENAME_SOURCE=exports.WASI_RIGHT_PATH_READLINK=exports.WASI_RIGHT_FD_READDIR=exports.WASI_RIGHT_PATH_OPEN=exports.WASI_RIGHT_PATH_LINK_TARGET=exports.WASI_RIGHT_PATH_LINK_SOURCE=exports.WASI_RIGHT_PATH_CREATE_FILE=exports.WASI_RIGHT_PATH_CREATE_DIRECTORY=exports.WASI_RIGHT_FD_ALLOCATE=exports.WASI_RIGHT_FD_ADVISE=exports.WASI_RIGHT_FD_WRITE=exports.WASI_RIGHT_FD_TELL=exports.WASI_RIGHT_FD_SYNC=exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS=exports.WASI_RIGHT_FD_SEEK=exports.WASI_RIGHT_FD_READ=exports.WASI_RIGHT_FD_DATASYNC=exports.WASI_FDFLAG_SYNC=exports.WASI_FDFLAG_RSYNC=exports.WASI_FDFLAG_NONBLOCK=exports.WASI_FDFLAG_DSYNC=exports.WASI_FDFLAG_APPEND=exports.WASI_FILETYPE_SYMBOLIC_LINK=exports.WASI_FILETYPE_SOCKET_STREAM=exports.WASI_FILETYPE_SOCKET_DGRAM=exports.WASI_FILETYPE_REGULAR_FILE=exports.WASI_FILETYPE_DIRECTORY=exports.WASI_FILETYPE_CHARACTER_DEVICE=exports.WASI_FILETYPE_BLOCK_DEVICE=exports.WASI_FILETYPE_UNKNOWN=exports.WASI_SIGXFSZ=exports.WASI_SIGXCPU=void 0,exports.SIGNAL_MAP=exports.ERROR_MAP=exports.WASI_WHENCE_END=exports.WASI_WHENCE_CUR=exports.WASI_WHENCE_SET=exports.WASI_STDERR_FILENO=exports.WASI_STDOUT_FILENO=exports.WASI_STDIN_FILENO=exports.WASI_DIRCOOKIE_START=exports.WASI_PREOPENTYPE_DIR=exports.WASI_O_TRUNC=exports.WASI_O_EXCL=exports.WASI_O_DIRECTORY=exports.WASI_O_CREAT=exports.WASI_FILESTAT_SET_MTIM_NOW=exports.WASI_FILESTAT_SET_MTIM=exports.WASI_FILESTAT_SET_ATIM_NOW=exports.WASI_FILESTAT_SET_ATIM=exports.WASI_EVENTTYPE_FD_WRITE=exports.WASI_EVENTTYPE_FD_READ=exports.WASI_EVENTTYPE_CLOCK=exports.WASI_CLOCK_THREAD_CPUTIME_ID=exports.WASI_CLOCK_PROCESS_CPUTIME_ID=exports.WASI_CLOCK_MONOTONIC=exports.WASI_CLOCK_REALTIME=exports.RIGHTS_TTY_INHERITING=exports.RIGHTS_TTY_BASE=exports.RIGHTS_SOCKET_INHERITING=exports.RIGHTS_SOCKET_BASE=exports.RIGHTS_DIRECTORY_INHERITING=exports.RIGHTS_DIRECTORY_BASE=exports.RIGHTS_REGULAR_FILE_INHERITING=void 0,exports.WASI_ESUCCESS=0,exports.WASI_E2BIG=1,exports.WASI_EACCES=2,exports.WASI_EADDRINUSE=3,exports.WASI_EADDRNOTAVAIL=4,exports.WASI_EAFNOSUPPORT=5,exports.WASI_EAGAIN=6,exports.WASI_EALREADY=7,exports.WASI_EBADF=8,exports.WASI_EBADMSG=9,exports.WASI_EBUSY=10,exports.WASI_ECANCELED=11,exports.WASI_ECHILD=12,exports.WASI_ECONNABORTED=13,exports.WASI_ECONNREFUSED=14,exports.WASI_ECONNRESET=15,exports.WASI_EDEADLK=16,exports.WASI_EDESTADDRREQ=17,exports.WASI_EDOM=18,exports.WASI_EDQUOT=19,exports.WASI_EEXIST=20,exports.WASI_EFAULT=21,exports.WASI_EFBIG=22,exports.WASI_EHOSTUNREACH=23,exports.WASI_EIDRM=24,exports.WASI_EILSEQ=25,exports.WASI_EINPROGRESS=26,exports.WASI_EINTR=27,exports.WASI_EINVAL=28,exports.WASI_EIO=29,exports.WASI_EISCONN=30,exports.WASI_EISDIR=31,exports.WASI_ELOOP=32,exports.WASI_EMFILE=33,exports.WASI_EMLINK=34,exports.WASI_EMSGSIZE=35,exports.WASI_EMULTIHOP=36,exports.WASI_ENAMETOOLONG=37,exports.WASI_ENETDOWN=38,exports.WASI_ENETRESET=39,exports.WASI_ENETUNREACH=40,exports.WASI_ENFILE=41,exports.WASI_ENOBUFS=42,exports.WASI_ENODEV=43,exports.WASI_ENOENT=44,exports.WASI_ENOEXEC=45,exports.WASI_ENOLCK=46,exports.WASI_ENOLINK=47,exports.WASI_ENOMEM=48,exports.WASI_ENOMSG=49,exports.WASI_ENOPROTOOPT=50,exports.WASI_ENOSPC=51,exports.WASI_ENOSYS=52,exports.WASI_ENOTCONN=53,exports.WASI_ENOTDIR=54,exports.WASI_ENOTEMPTY=55,exports.WASI_ENOTRECOVERABLE=56,exports.WASI_ENOTSOCK=57,exports.WASI_ENOTSUP=58,exports.WASI_ENOTTY=59,exports.WASI_ENXIO=60,exports.WASI_EOVERFLOW=61,exports.WASI_EOWNERDEAD=62,exports.WASI_EPERM=63,exports.WASI_EPIPE=64,exports.WASI_EPROTO=65,exports.WASI_EPROTONOSUPPORT=66,exports.WASI_EPROTOTYPE=67,exports.WASI_ERANGE=68,exports.WASI_EROFS=69,exports.WASI_ESPIPE=70,exports.WASI_ESRCH=71,exports.WASI_ESTALE=72,exports.WASI_ETIMEDOUT=73,exports.WASI_ETXTBSY=74,exports.WASI_EXDEV=75,exports.WASI_ENOTCAPABLE=76,exports.WASI_SIGABRT=0,exports.WASI_SIGALRM=1,exports.WASI_SIGBUS=2,exports.WASI_SIGCHLD=3,exports.WASI_SIGCONT=4,exports.WASI_SIGFPE=5,exports.WASI_SIGHUP=6,exports.WASI_SIGILL=7,exports.WASI_SIGINT=8,exports.WASI_SIGKILL=9,exports.WASI_SIGPIPE=10,exports.WASI_SIGQUIT=11,exports.WASI_SIGSEGV=12,exports.WASI_SIGSTOP=13,exports.WASI_SIGTERM=14,exports.WASI_SIGTRAP=15,exports.WASI_SIGTSTP=16,exports.WASI_SIGTTIN=17,exports.WASI_SIGTTOU=18,exports.WASI_SIGURG=19,exports.WASI_SIGUSR1=20,exports.WASI_SIGUSR2=21,exports.WASI_SIGVTALRM=22,exports.WASI_SIGXCPU=23,exports.WASI_SIGXFSZ=24,exports.WASI_FILETYPE_UNKNOWN=0,exports.WASI_FILETYPE_BLOCK_DEVICE=1,exports.WASI_FILETYPE_CHARACTER_DEVICE=2,exports.WASI_FILETYPE_DIRECTORY=3,exports.WASI_FILETYPE_REGULAR_FILE=4,exports.WASI_FILETYPE_SOCKET_DGRAM=5,exports.WASI_FILETYPE_SOCKET_STREAM=6,exports.WASI_FILETYPE_SYMBOLIC_LINK=7,exports.WASI_FDFLAG_APPEND=1,exports.WASI_FDFLAG_DSYNC=2,exports.WASI_FDFLAG_NONBLOCK=4,exports.WASI_FDFLAG_RSYNC=8,exports.WASI_FDFLAG_SYNC=16,exports.WASI_RIGHT_FD_DATASYNC=BigInt(1),exports.WASI_RIGHT_FD_READ=BigInt(2),exports.WASI_RIGHT_FD_SEEK=BigInt(4),exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS=BigInt(8),exports.WASI_RIGHT_FD_SYNC=BigInt(16),exports.WASI_RIGHT_FD_TELL=BigInt(32),exports.WASI_RIGHT_FD_WRITE=BigInt(64),exports.WASI_RIGHT_FD_ADVISE=BigInt(128),exports.WASI_RIGHT_FD_ALLOCATE=BigInt(256),exports.WASI_RIGHT_PATH_CREATE_DIRECTORY=BigInt(512),exports.WASI_RIGHT_PATH_CREATE_FILE=BigInt(1024),exports.WASI_RIGHT_PATH_LINK_SOURCE=BigInt(2048),exports.WASI_RIGHT_PATH_LINK_TARGET=BigInt(4096),exports.WASI_RIGHT_PATH_OPEN=BigInt(8192),exports.WASI_RIGHT_FD_READDIR=BigInt(16384),exports.WASI_RIGHT_PATH_READLINK=BigInt(32768),exports.WASI_RIGHT_PATH_RENAME_SOURCE=BigInt(65536),exports.WASI_RIGHT_PATH_RENAME_TARGET=BigInt(131072),exports.WASI_RIGHT_PATH_FILESTAT_GET=BigInt(262144),exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE=BigInt(524288),exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES=BigInt(1048576),exports.WASI_RIGHT_FD_FILESTAT_GET=BigInt(2097152),exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE=BigInt(4194304),exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES=BigInt(8388608),exports.WASI_RIGHT_PATH_SYMLINK=BigInt(16777216),exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY=BigInt(33554432),exports.WASI_RIGHT_PATH_UNLINK_FILE=BigInt(67108864),exports.WASI_RIGHT_POLL_FD_READWRITE=BigInt(134217728),exports.WASI_RIGHT_SOCK_SHUTDOWN=BigInt(268435456),exports.RIGHTS_ALL=exports.WASI_RIGHT_FD_DATASYNC|exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_SEEK|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_TELL|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_FD_ALLOCATE|exports.WASI_RIGHT_PATH_CREATE_DIRECTORY|exports.WASI_RIGHT_PATH_CREATE_FILE|exports.WASI_RIGHT_PATH_LINK_SOURCE|exports.WASI_RIGHT_PATH_LINK_TARGET|exports.WASI_RIGHT_PATH_OPEN|exports.WASI_RIGHT_FD_READDIR|exports.WASI_RIGHT_PATH_READLINK|exports.WASI_RIGHT_PATH_RENAME_SOURCE|exports.WASI_RIGHT_PATH_RENAME_TARGET|exports.WASI_RIGHT_PATH_FILESTAT_GET|exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_SYMLINK|exports.WASI_RIGHT_PATH_UNLINK_FILE|exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY|exports.WASI_RIGHT_POLL_FD_READWRITE|exports.WASI_RIGHT_SOCK_SHUTDOWN,exports.RIGHTS_BLOCK_DEVICE_BASE=exports.RIGHTS_ALL,exports.RIGHTS_BLOCK_DEVICE_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_CHARACTER_DEVICE_BASE=exports.RIGHTS_ALL,exports.RIGHTS_CHARACTER_DEVICE_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_REGULAR_FILE_BASE=exports.WASI_RIGHT_FD_DATASYNC|exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_SEEK|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_TELL|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_FD_ALLOCATE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_SIZE|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_REGULAR_FILE_INHERITING=BigInt(0),exports.RIGHTS_DIRECTORY_BASE=exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_SYNC|exports.WASI_RIGHT_FD_ADVISE|exports.WASI_RIGHT_PATH_CREATE_DIRECTORY|exports.WASI_RIGHT_PATH_CREATE_FILE|exports.WASI_RIGHT_PATH_LINK_SOURCE|exports.WASI_RIGHT_PATH_LINK_TARGET|exports.WASI_RIGHT_PATH_OPEN|exports.WASI_RIGHT_FD_READDIR|exports.WASI_RIGHT_PATH_READLINK|exports.WASI_RIGHT_PATH_RENAME_SOURCE|exports.WASI_RIGHT_PATH_RENAME_TARGET|exports.WASI_RIGHT_PATH_FILESTAT_GET|exports.WASI_RIGHT_PATH_FILESTAT_SET_SIZE|exports.WASI_RIGHT_PATH_FILESTAT_SET_TIMES|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_FD_FILESTAT_SET_TIMES|exports.WASI_RIGHT_PATH_SYMLINK|exports.WASI_RIGHT_PATH_UNLINK_FILE|exports.WASI_RIGHT_PATH_REMOVE_DIRECTORY|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_DIRECTORY_INHERITING=exports.RIGHTS_DIRECTORY_BASE|exports.RIGHTS_REGULAR_FILE_BASE,exports.RIGHTS_SOCKET_BASE=exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_POLL_FD_READWRITE|exports.WASI_RIGHT_SOCK_SHUTDOWN,exports.RIGHTS_SOCKET_INHERITING=exports.RIGHTS_ALL,exports.RIGHTS_TTY_BASE=exports.WASI_RIGHT_FD_READ|exports.WASI_RIGHT_FD_FDSTAT_SET_FLAGS|exports.WASI_RIGHT_FD_WRITE|exports.WASI_RIGHT_FD_FILESTAT_GET|exports.WASI_RIGHT_POLL_FD_READWRITE,exports.RIGHTS_TTY_INHERITING=BigInt(0),exports.WASI_CLOCK_REALTIME=0,exports.WASI_CLOCK_MONOTONIC=1,exports.WASI_CLOCK_PROCESS_CPUTIME_ID=2,exports.WASI_CLOCK_THREAD_CPUTIME_ID=3,exports.WASI_EVENTTYPE_CLOCK=0,exports.WASI_EVENTTYPE_FD_READ=1,exports.WASI_EVENTTYPE_FD_WRITE=2,exports.WASI_FILESTAT_SET_ATIM=1<<0,exports.WASI_FILESTAT_SET_ATIM_NOW=1<<1,exports.WASI_FILESTAT_SET_MTIM=1<<2,exports.WASI_FILESTAT_SET_MTIM_NOW=1<<3,exports.WASI_O_CREAT=1<<0,exports.WASI_O_DIRECTORY=1<<1,exports.WASI_O_EXCL=1<<2,exports.WASI_O_TRUNC=1<<3,exports.WASI_PREOPENTYPE_DIR=0,exports.WASI_DIRCOOKIE_START=0,exports.WASI_STDIN_FILENO=0,exports.WASI_STDOUT_FILENO=1,exports.WASI_STDERR_FILENO=2,exports.WASI_WHENCE_SET=0,exports.WASI_WHENCE_CUR=1,exports.WASI_WHENCE_END=2,exports.ERROR_MAP={E2BIG:exports.WASI_E2BIG,EACCES:exports.WASI_EACCES,EADDRINUSE:exports.WASI_EADDRINUSE,EADDRNOTAVAIL:exports.WASI_EADDRNOTAVAIL,EAFNOSUPPORT:exports.WASI_EAFNOSUPPORT,EALREADY:exports.WASI_EALREADY,EAGAIN:exports.WASI_EAGAIN,EBADF:exports.WASI_EBADF,EBADMSG:exports.WASI_EBADMSG,EBUSY:exports.WASI_EBUSY,ECANCELED:exports.WASI_ECANCELED,ECHILD:exports.WASI_ECHILD,ECONNABORTED:exports.WASI_ECONNABORTED,ECONNREFUSED:exports.WASI_ECONNREFUSED,ECONNRESET:exports.WASI_ECONNRESET,EDEADLOCK:exports.WASI_EDEADLK,EDESTADDRREQ:exports.WASI_EDESTADDRREQ,EDOM:exports.WASI_EDOM,EDQUOT:exports.WASI_EDQUOT,EEXIST:exports.WASI_EEXIST,EFAULT:exports.WASI_EFAULT,EFBIG:exports.WASI_EFBIG,EHOSTDOWN:exports.WASI_EHOSTUNREACH,EHOSTUNREACH:exports.WASI_EHOSTUNREACH,EIDRM:exports.WASI_EIDRM,EILSEQ:exports.WASI_EILSEQ,EINPROGRESS:exports.WASI_EINPROGRESS,EINTR:exports.WASI_EINTR,EINVAL:exports.WASI_EINVAL,EIO:exports.WASI_EIO,EISCONN:exports.WASI_EISCONN,EISDIR:exports.WASI_EISDIR,ELOOP:exports.WASI_ELOOP,EMFILE:exports.WASI_EMFILE,EMLINK:exports.WASI_EMLINK,EMSGSIZE:exports.WASI_EMSGSIZE,EMULTIHOP:exports.WASI_EMULTIHOP,ENAMETOOLONG:exports.WASI_ENAMETOOLONG,ENETDOWN:exports.WASI_ENETDOWN,ENETRESET:exports.WASI_ENETRESET,ENETUNREACH:exports.WASI_ENETUNREACH,ENFILE:exports.WASI_ENFILE,ENOBUFS:exports.WASI_ENOBUFS,ENODEV:exports.WASI_ENODEV,ENOENT:exports.WASI_ENOENT,ENOEXEC:exports.WASI_ENOEXEC,ENOLCK:exports.WASI_ENOLCK,ENOLINK:exports.WASI_ENOLINK,ENOMEM:exports.WASI_ENOMEM,ENOMSG:exports.WASI_ENOMSG,ENOPROTOOPT:exports.WASI_ENOPROTOOPT,ENOSPC:exports.WASI_ENOSPC,ENOSYS:exports.WASI_ENOSYS,ENOTCONN:exports.WASI_ENOTCONN,ENOTDIR:exports.WASI_ENOTDIR,ENOTEMPTY:exports.WASI_ENOTEMPTY,ENOTRECOVERABLE:exports.WASI_ENOTRECOVERABLE,ENOTSOCK:exports.WASI_ENOTSOCK,ENOTTY:exports.WASI_ENOTTY,ENXIO:exports.WASI_ENXIO,EOVERFLOW:exports.WASI_EOVERFLOW,EOWNERDEAD:exports.WASI_EOWNERDEAD,EPERM:exports.WASI_EPERM,EPIPE:exports.WASI_EPIPE,EPROTO:exports.WASI_EPROTO,EPROTONOSUPPORT:exports.WASI_EPROTONOSUPPORT,EPROTOTYPE:exports.WASI_EPROTOTYPE,ERANGE:exports.WASI_ERANGE,EROFS:exports.WASI_EROFS,ESPIPE:exports.WASI_ESPIPE,ESRCH:exports.WASI_ESRCH,ESTALE:exports.WASI_ESTALE,ETIMEDOUT:exports.WASI_ETIMEDOUT,ETXTBSY:exports.WASI_ETXTBSY,EXDEV:exports.WASI_EXDEV},exports.SIGNAL_MAP={[exports.WASI_SIGHUP]:\"SIGHUP\",[exports.WASI_SIGINT]:\"SIGINT\",[exports.WASI_SIGQUIT]:\"SIGQUIT\",[exports.WASI_SIGILL]:\"SIGILL\",[exports.WASI_SIGTRAP]:\"SIGTRAP\",[exports.WASI_SIGABRT]:\"SIGABRT\",[exports.WASI_SIGBUS]:\"SIGBUS\",[exports.WASI_SIGFPE]:\"SIGFPE\",[exports.WASI_SIGKILL]:\"SIGKILL\",[exports.WASI_SIGUSR1]:\"SIGUSR1\",[exports.WASI_SIGSEGV]:\"SIGSEGV\",[exports.WASI_SIGUSR2]:\"SIGUSR2\",[exports.WASI_SIGPIPE]:\"SIGPIPE\",[exports.WASI_SIGALRM]:\"SIGALRM\",[exports.WASI_SIGTERM]:\"SIGTERM\",[exports.WASI_SIGCHLD]:\"SIGCHLD\",[exports.WASI_SIGCONT]:\"SIGCONT\",[exports.WASI_SIGSTOP]:\"SIGSTOP\",[exports.WASI_SIGTSTP]:\"SIGTSTP\",[exports.WASI_SIGTTIN]:\"SIGTTIN\",[exports.WASI_SIGTTOU]:\"SIGTTOU\",[exports.WASI_SIGURG]:\"SIGURG\",[exports.WASI_SIGXCPU]:\"SIGXCPU\",[exports.WASI_SIGXFSZ]:\"SIGXFSZ\",[exports.WASI_SIGVTALRM]:\"SIGVTALRM\"}}}),require_wasi=__commonJS({\"node_modules/wasi-js/dist/wasi.js\"(exports){var __importDefault=exports&&exports.__importDefault||function(mod){return mod&&mod.__esModule\?mod:{default:mod}};let fs;Object.defineProperty(exports,\"__esModule\",{value:!0}),exports.SOCKET_DEFAULT_RIGHTS=void 0;var log=()=>{},logOpen=()=>{},SC_OPEN_MAX=32768,types_1=require_types(),constants_1=require_constants(),STDIN_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_SYNC|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE,STDOUT_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_SYNC|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE,STDERR_DEFAULT_RIGHTS=STDOUT_DEFAULT_RIGHTS;exports.SOCKET_DEFAULT_RIGHTS=constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_ADVISE|constants_1.WASI_RIGHT_FD_FILESTAT_GET|constants_1.WASI_RIGHT_POLL_FD_READWRITE|constants_1.WASI_RIGHT_FD_FDSTAT_SET_FLAGS;var msToNs=(ms)=>{const msInt=Math.trunc(ms),decimal=BigInt(Math.round((ms-msInt)*1e6));return BigInt(msInt)*BigInt(1e6)+decimal},nsToMs=(ns)=>{if(typeof ns===\"number\")ns=Math.trunc(ns);const nsInt=BigInt(ns);return Number(nsInt/BigInt(1e6))},wrap=(f)=>(...args)=>{try{return f(...args)}catch(err){let e=err;while(e.prev!=null)e=e.prev;if(e\?.code&&typeof e\?.code===\"string\")return constants_1.ERROR_MAP[e.code]||constants_1.WASI_EINVAL;if(e instanceof types_1.WASIError)return e.errno;throw e}},stat=(wasi,fd)=>{const entry=wasi.FD_MAP.get(fd);if(!entry)throw new types_1.WASIError(constants_1.WASI_EBADF);if(entry.filetype===void 0){const stats=wasi.fstatSync(entry.real),{filetype,rightsBase,rightsInheriting}=translateFileAttributes(wasi,fd,stats);if(entry.filetype=filetype,!entry.rights)entry.rights={base:rightsBase,inheriting:rightsInheriting}}return entry},translateFileAttributes=(wasi,fd,stats)=>{switch(!0){case stats.isBlockDevice():return{filetype:constants_1.WASI_FILETYPE_BLOCK_DEVICE,rightsBase:constants_1.RIGHTS_BLOCK_DEVICE_BASE,rightsInheriting:constants_1.RIGHTS_BLOCK_DEVICE_INHERITING};case stats.isCharacterDevice():{const filetype=constants_1.WASI_FILETYPE_CHARACTER_DEVICE;if(fd!==void 0&&wasi.bindings.isTTY(fd))return{filetype,rightsBase:constants_1.RIGHTS_TTY_BASE,rightsInheriting:constants_1.RIGHTS_TTY_INHERITING};return{filetype,rightsBase:constants_1.RIGHTS_CHARACTER_DEVICE_BASE,rightsInheriting:constants_1.RIGHTS_CHARACTER_DEVICE_INHERITING}}case stats.isDirectory():return{filetype:constants_1.WASI_FILETYPE_DIRECTORY,rightsBase:constants_1.RIGHTS_DIRECTORY_BASE,rightsInheriting:constants_1.RIGHTS_DIRECTORY_INHERITING};case stats.isFIFO():return{filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rightsBase:constants_1.RIGHTS_SOCKET_BASE,rightsInheriting:constants_1.RIGHTS_SOCKET_INHERITING};case stats.isFile():return{filetype:constants_1.WASI_FILETYPE_REGULAR_FILE,rightsBase:constants_1.RIGHTS_REGULAR_FILE_BASE,rightsInheriting:constants_1.RIGHTS_REGULAR_FILE_INHERITING};case stats.isSocket():return{filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rightsBase:constants_1.RIGHTS_SOCKET_BASE,rightsInheriting:constants_1.RIGHTS_SOCKET_INHERITING};case stats.isSymbolicLink():return{filetype:constants_1.WASI_FILETYPE_SYMBOLIC_LINK,rightsBase:BigInt(0),rightsInheriting:BigInt(0)};default:return{filetype:constants_1.WASI_FILETYPE_UNKNOWN,rightsBase:BigInt(0),rightsInheriting:BigInt(0)}}},warnedAboutSleep=!1,defaultConfig;function getDefaults(){if(defaultConfig)return defaultConfig;const defaultBindings={hrtime:()=>process.hrtime.bigint(),exit:(code)=>{process.exit(code)},kill:(signal)=>{process.kill(process.pid,signal)},randomFillSync:(array)=>crypto.getRandomValues(array),isTTY:(fd)=>@requireNativeModule(\"node:tty\").isatty(fd),fs:Bun.fs(),path:@getInternalField(@internalModuleRegistry,25)||@createInternalModuleById(25)};return defaultConfig={args:[],env:{},preopens:{},bindings:defaultBindings,sleep:(ms)=>{Bun.sleepSync(ms)}}}var WASI=class WASI2{constructor(wasiConfig={}){const defaultConfig2=getDefaults();this.lastStdin=0,this.sleep=wasiConfig.sleep||defaultConfig2.sleep,this.getStdin=wasiConfig.getStdin,this.sendStdout=wasiConfig.sendStdout,this.sendStderr=wasiConfig.sendStderr;let preopens=wasiConfig.preopens\?\?defaultConfig2.preopens;this.env=wasiConfig.env\?\?defaultConfig2.env;const args=wasiConfig.args\?\?defaultConfig2.args;this.memory=void 0,this.view=void 0,this.bindings=wasiConfig.bindings||defaultConfig2.bindings;const bindings2=this.bindings;fs=bindings2.fs,this.FD_MAP=new Map([[constants_1.WASI_STDIN_FILENO,{real:0,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDIN_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stdin\"}],[constants_1.WASI_STDOUT_FILENO,{real:1,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDOUT_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stdout\"}],[constants_1.WASI_STDERR_FILENO,{real:2,filetype:constants_1.WASI_FILETYPE_CHARACTER_DEVICE,rights:{base:STDERR_DEFAULT_RIGHTS,inheriting:BigInt(0)},path:\"/dev/stderr\"}]]);const path=bindings2.path;for(let[k,v]of Object.entries(preopens)){const real=fs.openSync(v,nodeFsConstants.O_RDONLY),newfd=this.getUnusedFileDescriptor();this.FD_MAP.set(newfd,{real,filetype:constants_1.WASI_FILETYPE_DIRECTORY,rights:{base:constants_1.RIGHTS_DIRECTORY_BASE,inheriting:constants_1.RIGHTS_DIRECTORY_INHERITING},fakePath:k,path:v})}const getiovs=(iovs,iovsLen)=>{this.refreshMemory();const{view,memory}=this,{buffer}=memory,{byteLength}=buffer;if(iovsLen===1){const ptr=iovs,buf=view.getUint32(ptr,!0);let bufLen=view.getUint32(ptr+4,!0);if(bufLen>byteLength-buf)console.log({buf,bufLen,total_memory:byteLength}),log(\"getiovs: warning -- truncating buffer to fit in memory\"),bufLen=Math.min(bufLen,Math.max(0,byteLength-buf));try{return[new Uint8Array(buffer,buf,bufLen)]}catch(err){throw console.warn(\"WASI.getiovs -- invalid buffer\",err),new types_1.WASIError(constants_1.WASI_EINVAL)}}const buffers=[];buffers.length=iovsLen;for(let i=0,ptr=iovs;ibyteLength-buf)console.log({buf,bufLen,total_memory:byteLength}),log(\"getiovs: warning -- truncating buffer to fit in memory\"),bufLen=Math.min(bufLen,Math.max(0,byteLength-buf));try{buffers[i]=new Uint8Array(buffer,buf,bufLen)}catch(err){throw console.warn(\"WASI.getiovs -- invalid buffer\",err),new types_1.WASIError(constants_1.WASI_EINVAL)}}return buffers},CHECK_FD=(fd,rights)=>{const stats=stat(this,fd);if(rights!==BigInt(0)&&(stats.rights.base&rights)===BigInt(0))throw new types_1.WASIError(constants_1.WASI_EPERM);return stats},CPUTIME_START=Bun.nanoseconds(),timeOrigin=Math.trunc(performance.timeOrigin*1e6),now=(clockId)=>{switch(clockId){case constants_1.WASI_CLOCK_MONOTONIC:return Bun.nanoseconds();case constants_1.WASI_CLOCK_REALTIME:return Bun.nanoseconds()+timeOrigin;case constants_1.WASI_CLOCK_PROCESS_CPUTIME_ID:case constants_1.WASI_CLOCK_THREAD_CPUTIME_ID:return Bun.nanoseconds()-CPUTIME_START;default:return null}};if(this.wasiImport={args_get:(argv,argvBuf)=>{this.refreshMemory();let coffset=argv,offset=argvBuf;return args.forEach((a)=>{this.view.setUint32(coffset,offset,!0),coffset+=4,offset+=Buffer.from(this.memory.buffer).write(`${a}\\0`,offset)}),constants_1.WASI_ESUCCESS},args_sizes_get:(argc,argvBufSize)=>{this.refreshMemory(),this.view.setUint32(argc,args.length,!0);const size=args.reduce((acc,a)=>acc+Buffer.byteLength(a)+1,0);return this.view.setUint32(argvBufSize,size,!0),constants_1.WASI_ESUCCESS},environ_get:(environ,environBuf)=>{this.refreshMemory();let coffset=environ,offset=environBuf;return Object.entries(this.env).forEach(([key,value])=>{this.view.setUint32(coffset,offset,!0),coffset+=4,offset+=Buffer.from(this.memory.buffer).write(`${key}=${value}\\0`,offset)}),constants_1.WASI_ESUCCESS},environ_sizes_get:(environCount,environBufSize)=>{this.refreshMemory();const envProcessed=Object.entries(this.env).map(([key,value])=>`${key}=${value}\\0`),size=envProcessed.reduce((acc,e)=>acc+Buffer.byteLength(e),0);return this.view.setUint32(environCount,envProcessed.length,!0),this.view.setUint32(environBufSize,size,!0),constants_1.WASI_ESUCCESS},clock_res_get:(clockId,resolution)=>{let res;switch(clockId){case constants_1.WASI_CLOCK_MONOTONIC:case constants_1.WASI_CLOCK_PROCESS_CPUTIME_ID:case constants_1.WASI_CLOCK_THREAD_CPUTIME_ID:{res=BigInt(1);break}case constants_1.WASI_CLOCK_REALTIME:{res=BigInt(1000);break}}if(!res)throw Error(\"invalid clockId\");return this.view.setBigUint64(resolution,res),constants_1.WASI_ESUCCESS},clock_time_get:(clockId,_precision,time)=>{this.refreshMemory();const n=now(clockId);if(n===null)return constants_1.WASI_EINVAL;return this.view.setBigUint64(time,BigInt(n),!0),constants_1.WASI_ESUCCESS},fd_advise:wrap((fd,_offset,_len,_advice)=>{return CHECK_FD(fd,constants_1.WASI_RIGHT_FD_ADVISE),constants_1.WASI_ENOSYS}),fd_allocate:wrap((fd,_offset,_len)=>{return CHECK_FD(fd,constants_1.WASI_RIGHT_FD_ALLOCATE),constants_1.WASI_ENOSYS}),fd_close:wrap((fd)=>{const stats=CHECK_FD(fd,BigInt(0));return fs.closeSync(stats.real),this.FD_MAP.delete(fd),constants_1.WASI_ESUCCESS}),fd_datasync:wrap((fd)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_DATASYNC);return fs.fdatasyncSync(stats.real),constants_1.WASI_ESUCCESS}),fd_fdstat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,BigInt(0));if(this.refreshMemory(),stats.filetype==null)throw Error(\"stats.filetype must be set\");return this.view.setUint8(bufPtr,stats.filetype),this.view.setUint16(bufPtr+2,0,!0),this.view.setUint16(bufPtr+4,0,!0),this.view.setBigUint64(bufPtr+8,BigInt(stats.rights.base),!0),this.view.setBigUint64(bufPtr+8+8,BigInt(stats.rights.inheriting),!0),constants_1.WASI_ESUCCESS}),fd_fdstat_set_flags:wrap((fd,flags)=>{if(CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FDSTAT_SET_FLAGS),this.wasiImport.sock_fcntlSetFlags(fd,flags)==0)return constants_1.WASI_ESUCCESS;return constants_1.WASI_ENOSYS}),fd_fdstat_set_rights:wrap((fd,fsRightsBase,fsRightsInheriting)=>{const stats=CHECK_FD(fd,BigInt(0));if((stats.rights.base|fsRightsBase)>stats.rights.base)return constants_1.WASI_EPERM;if((stats.rights.inheriting|fsRightsInheriting)>stats.rights.inheriting)return constants_1.WASI_EPERM;return stats.rights.base=fsRightsBase,stats.rights.inheriting=fsRightsInheriting,constants_1.WASI_ESUCCESS}),fd_filestat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_GET),rstats=this.fstatSync(stats.real);if(this.refreshMemory(),this.view.setBigUint64(bufPtr,BigInt(rstats.dev),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,stats.filetype==null)throw Error(\"stats.filetype must be set\");return this.view.setUint8(bufPtr,stats.filetype),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.nlink),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.size),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.atimeMs),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.mtimeMs),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,msToNs(rstats.ctimeMs),!0),constants_1.WASI_ESUCCESS}),fd_filestat_set_size:wrap((fd,stSize)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_SET_SIZE);return fs.ftruncateSync(stats.real,Number(stSize)),constants_1.WASI_ESUCCESS}),fd_filestat_set_times:wrap((fd,stAtim,stMtim,fstflags)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_FILESTAT_SET_TIMES),rstats=this.fstatSync(stats.real);let{atime:atim,mtime:mtim}=rstats;const n=nsToMs(now(constants_1.WASI_CLOCK_REALTIME)),atimflags=constants_1.WASI_FILESTAT_SET_ATIM|constants_1.WASI_FILESTAT_SET_ATIM_NOW;if((fstflags&atimflags)===atimflags)return constants_1.WASI_EINVAL;const mtimflags=constants_1.WASI_FILESTAT_SET_MTIM|constants_1.WASI_FILESTAT_SET_MTIM_NOW;if((fstflags&mtimflags)===mtimflags)return constants_1.WASI_EINVAL;if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM)===constants_1.WASI_FILESTAT_SET_ATIM)atim=nsToMs(stAtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM_NOW)===constants_1.WASI_FILESTAT_SET_ATIM_NOW)atim=n;if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM)===constants_1.WASI_FILESTAT_SET_MTIM)mtim=nsToMs(stMtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM_NOW)===constants_1.WASI_FILESTAT_SET_MTIM_NOW)mtim=n;return fs.futimesSync(stats.real,new Date(atim),new Date(mtim)),constants_1.WASI_ESUCCESS}),fd_prestat_get:wrap((fd,bufPtr)=>{const stats=CHECK_FD(fd,BigInt(0));return this.refreshMemory(),this.view.setUint8(bufPtr,constants_1.WASI_PREOPENTYPE_DIR),this.view.setUint32(bufPtr+4,Buffer.byteLength(stats.fakePath\?\?stats.path\?\?\"\"),!0),constants_1.WASI_ESUCCESS}),fd_prestat_dir_name:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,BigInt(0));return this.refreshMemory(),Buffer.from(this.memory.buffer).write(stats.fakePath\?\?stats.path\?\?\"\",pathPtr,pathLen,\"utf8\"),constants_1.WASI_ESUCCESS}),fd_pwrite:wrap((fd,iovs,iovsLen,offset,nwritten)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_SEEK);let written=0;return getiovs(iovs,iovsLen).forEach((iov)=>{let w=0;while(w{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_WRITE),IS_STDOUT=fd==constants_1.WASI_STDOUT_FILENO,IS_STDERR=fd==constants_1.WASI_STDERR_FILENO;let written=0;return getiovs(iovs,iovsLen).forEach((iov)=>{if(iov.byteLength==0)return;if(IS_STDOUT&&this.sendStdout!=null)this.sendStdout(iov),written+=iov.byteLength;else if(IS_STDERR&&this.sendStderr!=null)this.sendStderr(iov),written+=iov.byteLength;else{let w=0;while(w{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_SEEK);let read=0;outer:for(let iov of getiovs(iovs,iovsLen)){let r=0;while(r{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READ),IS_STDIN=fd==constants_1.WASI_STDIN_FILENO;let read=0;outer:for(let iov of getiovs(iovs,iovsLen)){let r=0;while(r0)this.lastStdin=(new Date()).valueOf()}}else{if(this.sleep==null&&!warnedAboutSleep)warnedAboutSleep=!0,console.log(\"(cpu waiting for stdin: please define a way to sleep!) \");try{rr=fs.readSync(stats.real,iov,r,length,position)}catch(_err){}if(rr==0)this.shortPause();else this.lastStdin=(new Date()).valueOf()}else rr=fs.readSync(stats.real,iov,r,length,position);if(stats.filetype==constants_1.WASI_FILETYPE_REGULAR_FILE)stats.offset=(stats.offset\?stats.offset:BigInt(0))+BigInt(rr);if(r+=rr,read+=rr,rr===0||rr{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_READDIR);this.refreshMemory();const entries=fs.readdirSync(stats.path,{withFileTypes:!0}),startPtr=bufPtr;for(let i=Number(cookie);ibufLen)break;if(this.view.setBigUint64(bufPtr,BigInt(i+1),!0),bufPtr+=8,bufPtr-startPtr>bufLen)break;const rstats=fs.lstatSync(path.resolve(stats.path,entry.name));if(this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,bufPtr-startPtr>bufLen)break;if(this.view.setUint32(bufPtr,nameLength,!0),bufPtr+=4,bufPtr-startPtr>bufLen)break;let filetype;switch(!0){case rstats.isBlockDevice():filetype=constants_1.WASI_FILETYPE_BLOCK_DEVICE;break;case rstats.isCharacterDevice():filetype=constants_1.WASI_FILETYPE_CHARACTER_DEVICE;break;case rstats.isDirectory():filetype=constants_1.WASI_FILETYPE_DIRECTORY;break;case rstats.isFIFO():filetype=constants_1.WASI_FILETYPE_SOCKET_STREAM;break;case rstats.isFile():filetype=constants_1.WASI_FILETYPE_REGULAR_FILE;break;case rstats.isSocket():filetype=constants_1.WASI_FILETYPE_SOCKET_STREAM;break;case rstats.isSymbolicLink():filetype=constants_1.WASI_FILETYPE_SYMBOLIC_LINK;break;default:filetype=constants_1.WASI_FILETYPE_UNKNOWN;break}if(this.view.setUint8(bufPtr,filetype),bufPtr+=1,bufPtr+=3,bufPtr+nameLength>=startPtr+bufLen)break;Buffer.from(this.memory.buffer).write(entry.name,bufPtr),bufPtr+=nameLength}const bufused=bufPtr-startPtr;return this.view.setUint32(bufusedPtr,Math.min(bufused,bufLen),!0),constants_1.WASI_ESUCCESS}),fd_renumber:wrap((from,to)=>{return CHECK_FD(from,BigInt(0)),CHECK_FD(to,BigInt(0)),fs.closeSync(this.FD_MAP.get(from).real),this.FD_MAP.set(from,this.FD_MAP.get(to)),this.FD_MAP.delete(to),constants_1.WASI_ESUCCESS}),fd_seek:wrap((fd,offset,whence,newOffsetPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_SEEK);switch(this.refreshMemory(),whence){case constants_1.WASI_WHENCE_CUR:stats.offset=(stats.offset\?stats.offset:BigInt(0))+BigInt(offset);break;case constants_1.WASI_WHENCE_END:const{size}=this.fstatSync(stats.real);stats.offset=BigInt(size)+BigInt(offset);break;case constants_1.WASI_WHENCE_SET:stats.offset=BigInt(offset);break}if(stats.offset==null)throw Error(\"stats.offset must be defined\");return this.view.setBigUint64(newOffsetPtr,stats.offset,!0),constants_1.WASI_ESUCCESS}),fd_tell:wrap((fd,offsetPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_TELL);if(this.refreshMemory(),!stats.offset)stats.offset=BigInt(0);return this.view.setBigUint64(offsetPtr,stats.offset,!0),constants_1.WASI_ESUCCESS}),fd_sync:wrap((fd)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_FD_SYNC);return fs.fsyncSync(stats.real),constants_1.WASI_ESUCCESS}),path_create_directory:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_CREATE_DIRECTORY);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.mkdirSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),path_filestat_get:wrap((fd,flags,pathPtr,pathLen,bufPtr)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_FILESTAT_GET);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();let rstats;if(flags)rstats=fs.statSync(path.resolve(stats.path,p));else rstats=fs.lstatSync(path.resolve(stats.path,p));return this.view.setBigUint64(bufPtr,BigInt(rstats.dev),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ino),!0),bufPtr+=8,this.view.setUint8(bufPtr,translateFileAttributes(this,void 0,rstats).filetype),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.nlink),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.size),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.atime.getTime()*1e6),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.mtime.getTime()*1e6),!0),bufPtr+=8,this.view.setBigUint64(bufPtr,BigInt(rstats.ctime.getTime()*1e6),!0),constants_1.WASI_ESUCCESS}),path_filestat_set_times:wrap((fd,_dirflags,pathPtr,pathLen,stAtim,stMtim,fstflags)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_FILESTAT_SET_TIMES);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const rstats=this.fstatSync(stats.real);let{atime:atim,mtime:mtim}=rstats;const n=nsToMs(now(constants_1.WASI_CLOCK_REALTIME)),atimflags=constants_1.WASI_FILESTAT_SET_ATIM|constants_1.WASI_FILESTAT_SET_ATIM_NOW;if((fstflags&atimflags)===atimflags)return constants_1.WASI_EINVAL;const mtimflags=constants_1.WASI_FILESTAT_SET_MTIM|constants_1.WASI_FILESTAT_SET_MTIM_NOW;if((fstflags&mtimflags)===mtimflags)return constants_1.WASI_EINVAL;if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM)===constants_1.WASI_FILESTAT_SET_ATIM)atim=nsToMs(stAtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_ATIM_NOW)===constants_1.WASI_FILESTAT_SET_ATIM_NOW)atim=n;if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM)===constants_1.WASI_FILESTAT_SET_MTIM)mtim=nsToMs(stMtim);else if((fstflags&constants_1.WASI_FILESTAT_SET_MTIM_NOW)===constants_1.WASI_FILESTAT_SET_MTIM_NOW)mtim=n;const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.utimesSync(path.resolve(stats.path,p),new Date(atim),new Date(mtim)),constants_1.WASI_ESUCCESS}),path_link:wrap((oldFd,_oldFlags,oldPath,oldPathLen,newFd,newPath,newPathLen)=>{const ostats=CHECK_FD(oldFd,constants_1.WASI_RIGHT_PATH_LINK_SOURCE),nstats=CHECK_FD(newFd,constants_1.WASI_RIGHT_PATH_LINK_TARGET);if(!ostats.path||!nstats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.linkSync(path.resolve(ostats.path,op),path.resolve(nstats.path,np)),constants_1.WASI_ESUCCESS}),path_open:wrap((dirfd,_dirflags,pathPtr,pathLen,oflags,fsRightsBase,fsRightsInheriting,fsFlags,fdPtr)=>{try{const stats=CHECK_FD(dirfd,constants_1.WASI_RIGHT_PATH_OPEN);fsRightsBase=BigInt(fsRightsBase),fsRightsInheriting=BigInt(fsRightsInheriting);const read=(fsRightsBase&(constants_1.WASI_RIGHT_FD_READ|constants_1.WASI_RIGHT_FD_READDIR))!==BigInt(0),write=(fsRightsBase&(constants_1.WASI_RIGHT_FD_DATASYNC|constants_1.WASI_RIGHT_FD_WRITE|constants_1.WASI_RIGHT_FD_ALLOCATE|constants_1.WASI_RIGHT_FD_FILESTAT_SET_SIZE))!==BigInt(0);let noflags;if(write&&read)noflags=nodeFsConstants.O_RDWR;else if(read)noflags=nodeFsConstants.O_RDONLY;else if(write)noflags=nodeFsConstants.O_WRONLY;let neededBase=fsRightsBase|constants_1.WASI_RIGHT_PATH_OPEN,neededInheriting=fsRightsBase|fsRightsInheriting;if((oflags&constants_1.WASI_O_CREAT)!==0)noflags|=nodeFsConstants.O_CREAT,neededBase|=constants_1.WASI_RIGHT_PATH_CREATE_FILE;if((oflags&constants_1.WASI_O_DIRECTORY)!==0)noflags|=nodeFsConstants.O_DIRECTORY;if((oflags&constants_1.WASI_O_EXCL)!==0)noflags|=nodeFsConstants.O_EXCL;if((oflags&constants_1.WASI_O_TRUNC)!==0)noflags|=nodeFsConstants.O_TRUNC,neededBase|=constants_1.WASI_RIGHT_PATH_FILESTAT_SET_SIZE;if((fsFlags&constants_1.WASI_FDFLAG_APPEND)!==0)noflags|=nodeFsConstants.O_APPEND;if((fsFlags&constants_1.WASI_FDFLAG_DSYNC)!==0){if(nodeFsConstants.O_DSYNC)noflags|=nodeFsConstants.O_DSYNC;else noflags|=nodeFsConstants.O_SYNC;neededInheriting|=constants_1.WASI_RIGHT_FD_DATASYNC}if((fsFlags&constants_1.WASI_FDFLAG_NONBLOCK)!==0)noflags|=nodeFsConstants.O_NONBLOCK;if((fsFlags&constants_1.WASI_FDFLAG_RSYNC)!==0){if(nodeFsConstants.O_RSYNC)noflags|=nodeFsConstants.O_RSYNC;else noflags|=nodeFsConstants.O_SYNC;neededInheriting|=constants_1.WASI_RIGHT_FD_SYNC}if((fsFlags&constants_1.WASI_FDFLAG_SYNC)!==0)noflags|=nodeFsConstants.O_SYNC,neededInheriting|=constants_1.WASI_RIGHT_FD_SYNC;if(write&&(noflags&(nodeFsConstants.O_APPEND|nodeFsConstants.O_TRUNC))===0)neededInheriting|=constants_1.WASI_RIGHT_FD_SEEK;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();if(p==\"dev/tty\")return this.view.setUint32(fdPtr,constants_1.WASI_STDIN_FILENO,!0),constants_1.WASI_ESUCCESS;if(logOpen(\"path_open\",p),p.startsWith(\"proc/\"))throw new types_1.WASIError(constants_1.WASI_EBADF);const fullUnresolved=path.resolve(p);let full;try{full=fs.realpathSync(fullUnresolved)}catch(e){if(e\?.code===\"ENOENT\")full=fullUnresolved;else throw e}let isDirectory;if(write)try{isDirectory=fs.statSync(full).isDirectory()}catch(_err){}let realfd;if(!write&&isDirectory)realfd=fs.openSync(full,nodeFsConstants.O_RDONLY);else realfd=fs.openSync(full,noflags);const newfd=this.getUnusedFileDescriptor();this.FD_MAP.set(newfd,{real:realfd,filetype:void 0,rights:{base:neededBase,inheriting:neededInheriting},path:full}),stat(this,newfd),this.view.setUint32(fdPtr,newfd,!0)}catch(e){console.error(e)}return constants_1.WASI_ESUCCESS}),path_readlink:wrap((fd,pathPtr,pathLen,buf,bufLen,bufused)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_READLINK);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString(),full=path.resolve(stats.path,p),r=fs.readlinkSync(full),used=Buffer.from(this.memory.buffer).write(r,buf,bufLen);return this.view.setUint32(bufused,used,!0),constants_1.WASI_ESUCCESS}),path_remove_directory:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_REMOVE_DIRECTORY);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.rmdirSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),path_rename:wrap((oldFd,oldPath,oldPathLen,newFd,newPath,newPathLen)=>{const ostats=CHECK_FD(oldFd,constants_1.WASI_RIGHT_PATH_RENAME_SOURCE),nstats=CHECK_FD(newFd,constants_1.WASI_RIGHT_PATH_RENAME_TARGET);if(!ostats.path||!nstats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.renameSync(path.resolve(ostats.path,op),path.resolve(nstats.path,np)),constants_1.WASI_ESUCCESS}),path_symlink:wrap((oldPath,oldPathLen,fd,newPath,newPathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_SYMLINK);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const op=Buffer.from(this.memory.buffer,oldPath,oldPathLen).toString(),np=Buffer.from(this.memory.buffer,newPath,newPathLen).toString();return fs.symlinkSync(op,path.resolve(stats.path,np)),constants_1.WASI_ESUCCESS}),path_unlink_file:wrap((fd,pathPtr,pathLen)=>{const stats=CHECK_FD(fd,constants_1.WASI_RIGHT_PATH_UNLINK_FILE);if(!stats.path)return constants_1.WASI_EINVAL;this.refreshMemory();const p=Buffer.from(this.memory.buffer,pathPtr,pathLen).toString();return fs.unlinkSync(path.resolve(stats.path,p)),constants_1.WASI_ESUCCESS}),poll_oneoff:(sin,sout,nsubscriptions,neventsPtr)=>{let nevents=0,name=\"\",waitTimeNs=BigInt(0),fd=-1,fd_type=\"read\",fd_timeout_ms=0;const startNs=BigInt(bindings2.hrtime());this.refreshMemory();let last_sin=sin;for(let i=0;iwaitTimeNs)waitTimeNs=waitNs}this.view.setBigUint64(sout,userdata,!0),sout+=8,this.view.setUint16(sout,e,!0),sout+=2,this.view.setUint8(sout,constants_1.WASI_EVENTTYPE_CLOCK),sout+=1,sout+=5,nevents+=1;break}case constants_1.WASI_EVENTTYPE_FD_READ:case constants_1.WASI_EVENTTYPE_FD_WRITE:{if(fd=this.view.getUint32(sin,!0),fd_type=type==constants_1.WASI_EVENTTYPE_FD_READ\?\"read\":\"write\",sin+=4,log(name,\"fd =\",fd),sin+=28,this.view.setBigUint64(sout,userdata,!0),sout+=8,this.view.setUint16(sout,constants_1.WASI_ENOSYS,!0),sout+=2,this.view.setUint8(sout,type),sout+=1,sout+=5,nevents+=1,fd==constants_1.WASI_STDIN_FILENO&&constants_1.WASI_EVENTTYPE_FD_READ==type)this.shortPause();break}default:return constants_1.WASI_EINVAL}if(sin-last_sin!=48)console.warn(\"*** BUG in wasi-js in poll_oneoff \",{i,sin,last_sin,diff:sin-last_sin});last_sin=sin}if(this.view.setUint32(neventsPtr,nevents,!0),nevents==2&&fd>=0){const r=this.wasiImport.sock_pollSocket(fd,fd_type,fd_timeout_ms);if(r!=constants_1.WASI_ENOSYS)return r}if(waitTimeNs>0){if(waitTimeNs-=Bun.nanoseconds()-timeOrigin,waitTimeNs>=1e6){if(this.sleep==null&&!warnedAboutSleep)warnedAboutSleep=!0,console.log(\"(100% cpu burning waiting for stdin: please define a way to sleep!) \");if(this.sleep!=null){const ms=nsToMs(waitTimeNs);this.sleep(ms)}else{const end=BigInt(bindings2.hrtime())+waitTimeNs;while(BigInt(bindings2.hrtime()){return bindings2.exit(rval),constants_1.WASI_ESUCCESS},proc_raise:(sig)=>{if(!(sig in constants_1.SIGNAL_MAP))return constants_1.WASI_EINVAL;return bindings2.kill(constants_1.SIGNAL_MAP[sig]),constants_1.WASI_ESUCCESS},random_get:(bufPtr,bufLen)=>{return this.refreshMemory(),crypto.getRandomValues(this.memory.buffer,bufPtr,bufLen),bufLen},sched_yield(){return constants_1.WASI_ESUCCESS},sock_recv(){return constants_1.WASI_ENOSYS},sock_send(){return constants_1.WASI_ENOSYS},sock_shutdown(){return constants_1.WASI_ENOSYS},sock_fcntlSetFlags(_fd,_flags){return constants_1.WASI_ENOSYS},sock_pollSocket(_fd,_eventtype,_timeout_ms){return constants_1.WASI_ENOSYS}},log.enabled)Object.keys(this.wasiImport).forEach((key)=>{const prevImport=this.wasiImport[key];this.wasiImport[key]=function(...args2){log(key,args2);try{let result=prevImport(...args2);return log(\"result\",result),result}catch(e){throw log(\"error: \",e),e}}})}getState(){return{env:this.env,FD_MAP:this.FD_MAP,bindings}}setState(state){this.env=state.env,this.FD_MAP=state.FD_MAP,bindings=state.bindings}fstatSync(real_fd){if(real_fd<=2)try{return fs.fstatSync(real_fd)}catch(_){const now=new Date;return{dev:0,mode:8592,nlink:1,uid:0,gid:0,rdev:0,blksize:65536,ino:0,size:0,blocks:0,atimeMs:now.valueOf(),mtimeMs:now.valueOf(),ctimeMs:now.valueOf(),birthtimeMs:0,atime:new Date,mtime:new Date,ctime:new Date,birthtime:new Date(0)}}return fs.fstatSync(real_fd)}shortPause(){if(this.sleep==null)return;if((new Date()).valueOf()-this.lastStdin>2000)this.sleep(50)}getUnusedFileDescriptor(start=3){let fd=start;while(this.FD_MAP.has(fd))fd+=1;if(fd>SC_OPEN_MAX)throw Error(\"no available file descriptors\");return fd}refreshMemory(){if(!this.view||this.view.buffer.byteLength===0)this.view=new DataView(this.memory.buffer)}setMemory(memory){this.memory=memory}start(instance,memory){const exports2=instance.exports;if(exports2===null||typeof exports2!==\"object\")throw new Error(`instance.exports must be an Object. Received ${exports2}.`);if(memory==null){if(memory=exports2.memory,!(memory instanceof WebAssembly.Memory))throw new Error(`instance.exports.memory must be a WebAssembly.Memory. Recceived ${memory}.`)}if(this.setMemory(memory),exports2._start)exports2._start()}getImports(module2){let namespace=null;const imports=WebAssembly.Module.imports(module2);for(let imp of imports){if(imp.kind!==\"function\")continue;if(!imp.module.startsWith(\"wasi_\"))continue;namespace=imp.module;break}switch(namespace){case\"wasi_unstable\":return{wasi_unstable:this.wasiImport};case\"wasi_snapshot_preview1\":return{wasi_snapshot_preview1:this.wasiImport};default:throw new Error(\"No WASI namespace found. Only wasi_unstable and wasi_snapshot_preview1 are supported.\\n\\nList of imports:\\n\\n\"+imports.map(({name,kind,module})=>`${module}:${name} (${kind})`).join(\"\\n\")+\"\\n\")}}initWasiFdInfo(){if(this.env.WASI_FD_INFO!=null){const fdInfo=JSON.parse(this.env.WASI_FD_INFO);for(let wasi_fd in fdInfo){console.log(wasi_fd);const fd=parseInt(wasi_fd);if(this.FD_MAP.has(fd))continue;const real=fdInfo[wasi_fd];try{this.fstatSync(real)}catch(_err){console.log(\"discarding \",{wasi_fd,real});continue}const file={real,filetype:constants_1.WASI_FILETYPE_SOCKET_STREAM,rights:{base:STDIN_DEFAULT_RIGHTS,inheriting:BigInt(0)}};this.FD_MAP.set(fd,file)}console.log(\"after initWasiFdInfo: \",this.FD_MAP),console.log(\"fdInfo = \",fdInfo)}else console.log(\"no WASI_FD_INFO\")}};exports.default=WASI}});return{WASI:require_wasi().default}})\n"_s; +// + +// static constexpr ASCIILiteral NodeWorkerThreadsCode = "(function (){\"use strict\";var $;const{MessageChannel,BroadcastChannel}=globalThis;function injectFakeEmitter(Class){function messageEventHandler(event){return event.data}function errorEventHandler(event){return event.error}const wrappedListener=Symbol(\"wrappedListener\");function wrapped(run,listener){const callback=function(event){return listener(run(event))};return listener[wrappedListener]=callback,callback}function functionForEventType(event,listener){switch(event){case\"error\":case\"messageerror\":return wrapped(errorEventHandler,listener);default:return wrapped(messageEventHandler,listener)}}Class.prototype.on=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener)),this},Class.prototype.off=function(event,listener){if(listener)this.removeEventListener(event,listener[wrappedListener]||listener);else this.removeEventListener(event);return this},Class.prototype.once=function(event,listener){return this.addEventListener(event,functionForEventType(event,listener),{once:!0}),this};function EventClass(eventName){if(eventName===\"error\"||eventName===\"messageerror\")return ErrorEvent;return MessageEvent}Class.prototype.emit=function(event,...args){return this.dispatchEvent(new(EventClass(event))(event,...args)),this},Class.prototype.prependListener=Class.prototype.on,Class.prototype.prependOnceListener=Class.prototype.once}const _MessagePort=globalThis.MessagePort;injectFakeEmitter(_MessagePort);const MessagePort=_MessagePort,EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),isMainThread=Bun.isMainThread;let[_workerData,_threadId,_receiveMessageOnPort]=globalThis[globalThis.Symbol.for('Bun.lazy')](\"worker_threads\"),parentPort=isMainThread\?null:fakeParentPort(),resourceLimits={},workerData=_workerData,threadId=_threadId;function receiveMessageOnPort(port){let res=_receiveMessageOnPort(port);if(!res)return;return{message:res}}function fakeParentPort(){const fake=Object.create(MessagePort.prototype);return Object.defineProperty(fake,\"onmessage\",{get(){return self.onmessage},set(value){self.onmessage=value}}),Object.defineProperty(fake,\"onmessageerror\",{get(){return self.onmessageerror},set(value){}}),Object.defineProperty(fake,\"postMessage\",{value(...args){return self.postMessage(...args)}}),Object.defineProperty(fake,\"close\",{value(){return process.exit(0)}}),Object.defineProperty(fake,\"start\",{value(){}}),Object.defineProperty(fake,\"unref\",{value(){}}),Object.defineProperty(fake,\"ref\",{value(){}}),Object.defineProperty(fake,\"hasRef\",{value(){return!1}}),Object.defineProperty(fake,\"setEncoding\",{value(){}}),Object.defineProperty(fake,\"addEventListener\",{value:self.addEventListener.bind(self)}),Object.defineProperty(fake,\"removeEventListener\",{value:self.removeEventListener.bind(self)}),fake}function getEnvironmentData(){return process.env}function setEnvironmentData(env){process.env=env}function markAsUntransferable(){throw new Error(\"markAsUntransferable is not implemented\")}function moveMessagePortToContext(){throw new Error(\"moveMessagePortToContext is not implemented\")}const SHARE_ENV=Symbol(\"nodejs.worker_threads.SHARE_ENV\"),WebWorker=globalThis.Worker;class Worker extends EventEmitter{#worker;#performance;#onExitPromise=void 0;constructor(filename,options={}){super();this.#worker=new WebWorker(filename,{...options}),this.#worker.addEventListener(\"close\",this.#onClose.bind(this)),this.#worker.addEventListener(\"error\",this.#onError.bind(this)),this.#worker.addEventListener(\"message\",this.#onMessage.bind(this)),this.#worker.addEventListener(\"messageerror\",this.#onMessageError.bind(this)),this.#worker.addEventListener(\"open\",this.#onOpen.bind(this))}ref(){this.#worker.ref()}unref(){this.#worker.unref()}get stdin(){return null}get stdout(){return null}get stderr(){return null}get performance(){return this.#performance\?\?={eventLoopUtilization(){return{}}}}terminate(){if(this.#onExitPromise)return this.#onExitPromise;const{resolve,promise}=Promise.withResolvers();return this.#worker.addEventListener(\"close\",(event)=>{resolve(0)},{once:!0}),this.#onExitPromise=promise}postMessage(...args){return this.#worker.postMessage(...args)}#onClose(){this.emit(\"exit\")}#onError(event){this.emit(\"error\",event)}#onMessage(event){this.emit(\"message\",event.data)}#onMessageError(event){this.emit(\"messageerror\",event.error||event)}#onOpen(){this.emit(\"online\")}getHeapSnapshot(){return{}}}return $={Worker,workerData,parentPort,resourceLimits,isMainThread,MessageChannel,BroadcastChannel,MessagePort,getEnvironmentData,setEnvironmentData,getHeapSnapshot(){return{}},markAsUntransferable,moveMessagePortToContext,receiveMessageOnPort,SHARE_ENV,threadId},$})\n"_s; +// + +// static constexpr ASCIILiteral NodeZlibCode = "(function (){\"use strict\";const assert=@getInternalField(@internalModuleRegistry,3)||@createInternalModuleById(3),BufferModule=@requireNativeModule(\"node:buffer\"),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),Util=@getInternalField(@internalModuleRegistry,42)||@createInternalModuleById(42);var __getOwnPropNames=Object.getOwnPropertyNames,__commonJS=(cb,mod)=>function __require(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports},require_zstream=__commonJS({\"node_modules/pako/lib/zlib/zstream.js\"(exports,module2){function ZStream(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}module2.exports=ZStream}}),require_common=__commonJS({\"node_modules/pako/lib/utils/common.js\"(exports){var TYPED_OK=typeof Uint8Array!==\"undefined\"&&typeof Uint16Array!==\"undefined\"&&typeof Int32Array!==\"undefined\";function _has(obj,key){return Object.prototype.hasOwnProperty.call(obj,key)}exports.assign=function(obj){var sources=Array.prototype.slice.call(arguments,1);while(sources.length){var source=sources.shift();if(!source)continue;if(typeof source!==\"object\")@throwTypeError(source+\"must be non-object\");for(var p in source)if(_has(source,p))obj[p]=source[p]}return obj},exports.shrinkBuf=function(buf,size){if(buf.length===size)return buf;if(buf.subarray)return buf.subarray(0,size);return buf.length=size,buf};var fnTyped={arraySet:function(dest,src,src_offs,len,dest_offs){if(src.subarray&&dest.subarray){dest.set(src.subarray(src_offs,src_offs+len),dest_offs);return}for(var i=0;i=0)buf[len]=0}var STORED_BLOCK=0,STATIC_TREES=1,DYN_TREES=2,MIN_MATCH=3,MAX_MATCH=258,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,Buf_size=16,MAX_BL_BITS=7,END_BLOCK=256,REP_3_6=16,REPZ_3_10=17,REPZ_11_138=18,extra_lbits=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],extra_dbits=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],DIST_CODE_LEN=512,static_ltree=new Array((L_CODES+2)*2);zero(static_ltree);var static_dtree=new Array(D_CODES*2);zero(static_dtree);var _dist_code=new Array(DIST_CODE_LEN);zero(_dist_code);var _length_code=new Array(MAX_MATCH-MIN_MATCH+1);zero(_length_code);var base_length=new Array(LENGTH_CODES);zero(base_length);var base_dist=new Array(D_CODES);zero(base_dist);function StaticTreeDesc(static_tree,extra_bits,extra_base,elems,max_length){this.static_tree=static_tree,this.extra_bits=extra_bits,this.extra_base=extra_base,this.elems=elems,this.max_length=max_length,this.has_stree=static_tree&&static_tree.length}var static_l_desc,static_d_desc,static_bl_desc;function TreeDesc(dyn_tree,stat_desc){this.dyn_tree=dyn_tree,this.max_code=0,this.stat_desc=stat_desc}function d_code(dist){return dist<256\?_dist_code[dist]:_dist_code[256+(dist>>>7)]}function put_short(s,w){s.pending_buf[s.pending++]=w&255,s.pending_buf[s.pending++]=w>>>8&255}function send_bits(s,value,length){if(s.bi_valid>Buf_size-length)s.bi_buf|=value<>Buf_size-s.bi_valid,s.bi_valid+=length-Buf_size;else s.bi_buf|=value<>>=1,res<<=1;while(--len>0);return res>>>1}function bi_flush(s){if(s.bi_valid===16)put_short(s,s.bi_buf),s.bi_buf=0,s.bi_valid=0;else if(s.bi_valid>=8)s.pending_buf[s.pending++]=s.bi_buf&255,s.bi_buf>>=8,s.bi_valid-=8}function gen_bitlen(s,desc){var{dyn_tree:tree,max_code}=desc,stree=desc.stat_desc.static_tree,has_stree=desc.stat_desc.has_stree,extra=desc.stat_desc.extra_bits,base=desc.stat_desc.extra_base,max_length=desc.stat_desc.max_length,h,n,m,bits,xbits,f,overflow=0;for(bits=0;bits<=MAX_BITS;bits++)s.bl_count[bits]=0;tree[s.heap[s.heap_max]*2+1]=0;for(h=s.heap_max+1;hmax_length)bits=max_length,overflow++;if(tree[n*2+1]=bits,n>max_code)continue;if(s.bl_count[bits]++,xbits=0,n>=base)xbits=extra[n-base];if(f=tree[n*2],s.opt_len+=f*(bits+xbits),has_stree)s.static_len+=f*(stree[n*2+1]+xbits)}if(overflow===0)return;do{bits=max_length-1;while(s.bl_count[bits]===0)bits--;s.bl_count[bits]--,s.bl_count[bits+1]+=2,s.bl_count[max_length]--,overflow-=2}while(overflow>0);for(bits=max_length;bits!==0;bits--){n=s.bl_count[bits];while(n!==0){if(m=s.heap[--h],m>max_code)continue;if(tree[m*2+1]!==bits)s.opt_len+=(bits-tree[m*2+1])*tree[m*2],tree[m*2+1]=bits;n--}}}function gen_codes(tree,max_code,bl_count){var next_code=new Array(MAX_BITS+1),code=0,bits,n;for(bits=1;bits<=MAX_BITS;bits++)next_code[bits]=code=code+bl_count[bits-1]<<1;for(n=0;n<=max_code;n++){var len=tree[n*2+1];if(len===0)continue;tree[n*2]=bi_reverse(next_code[len]++,len)}}function tr_static_init(){var n,bits,length,code,dist,bl_count=new Array(MAX_BITS+1);length=0;for(code=0;code>=7;for(;code8)put_short(s,s.bi_buf);else if(s.bi_valid>0)s.pending_buf[s.pending++]=s.bi_buf;s.bi_buf=0,s.bi_valid=0}function copy_block(s,buf,len,header){if(bi_windup(s),header)put_short(s,len),put_short(s,~len);utils.arraySet(s.pending_buf,s.window,buf,len,s.pending),s.pending+=len}function smaller(tree,n,m,depth){var _n2=n*2,_m2=m*2;return tree[_n2]>1;n>=1;n--)pqdownheap(s,tree,n);node=elems;do n=s.heap[1],s.heap[1]=s.heap[s.heap_len--],pqdownheap(s,tree,1),m=s.heap[1],s.heap[--s.heap_max]=n,s.heap[--s.heap_max]=m,tree[node*2]=tree[n*2]+tree[m*2],s.depth[node]=(s.depth[n]>=s.depth[m]\?s.depth[n]:s.depth[m])+1,tree[n*2+1]=tree[m*2+1]=node,s.heap[1]=node++,pqdownheap(s,tree,1);while(s.heap_len>=2);s.heap[--s.heap_max]=s.heap[1],gen_bitlen(s,desc),gen_codes(tree,max_code,s.bl_count)}function scan_tree(s,tree,max_code){var n,prevlen=-1,curlen,nextlen=tree[1],count=0,max_count=7,min_count=4;if(nextlen===0)max_count=138,min_count=3;tree[(max_code+1)*2+1]=65535;for(n=0;n<=max_code;n++){if(curlen=nextlen,nextlen=tree[(n+1)*2+1],++count=3;max_blindex--)if(s.bl_tree[bl_order[max_blindex]*2+1]!==0)break;return s.opt_len+=3*(max_blindex+1)+5+5+4,max_blindex}function send_all_trees(s,lcodes,dcodes,blcodes){var rank;send_bits(s,lcodes-257,5),send_bits(s,dcodes-1,5),send_bits(s,blcodes-4,4);for(rank=0;rank>>=1)if(black_mask&1&&s.dyn_ltree[n*2]!==0)return Z_BINARY;if(s.dyn_ltree[18]!==0||s.dyn_ltree[20]!==0||s.dyn_ltree[26]!==0)return Z_TEXT;for(n=32;n0){if(s.strm.data_type===Z_UNKNOWN)s.strm.data_type=detect_data_type(s);if(build_tree(s,s.l_desc),build_tree(s,s.d_desc),max_blindex=build_bl_tree(s),opt_lenb=s.opt_len+3+7>>>3,static_lenb=s.static_len+3+7>>>3,static_lenb<=opt_lenb)opt_lenb=static_lenb}else opt_lenb=static_lenb=stored_len+5;if(stored_len+4<=opt_lenb&&buf!==-1)_tr_stored_block(s,buf,stored_len,last);else if(s.strategy===Z_FIXED||static_lenb===opt_lenb)send_bits(s,(STATIC_TREES<<1)+(last\?1:0),3),compress_block(s,static_ltree,static_dtree);else send_bits(s,(DYN_TREES<<1)+(last\?1:0),3),send_all_trees(s,s.l_desc.max_code+1,s.d_desc.max_code+1,max_blindex+1),compress_block(s,s.dyn_ltree,s.dyn_dtree);if(init_block(s),last)bi_windup(s)}function _tr_tally(s,dist,lc){if(s.pending_buf[s.d_buf+s.last_lit*2]=dist>>>8&255,s.pending_buf[s.d_buf+s.last_lit*2+1]=dist&255,s.pending_buf[s.l_buf+s.last_lit]=lc&255,s.last_lit++,dist===0)s.dyn_ltree[lc*2]++;else s.matches++,dist--,s.dyn_ltree[(_length_code[lc]+LITERALS+1)*2]++,s.dyn_dtree[d_code(dist)*2]++;return s.last_lit===s.lit_bufsize-1}exports._tr_init=_tr_init,exports._tr_stored_block=_tr_stored_block,exports._tr_flush_block=_tr_flush_block,exports._tr_tally=_tr_tally,exports._tr_align=_tr_align}}),require_adler32=__commonJS({\"node_modules/pako/lib/zlib/adler32.js\"(exports,module2){function adler32(adler,buf,len,pos){var s1=adler&65535|0,s2=adler>>>16&65535|0,n=0;while(len!==0){n=len>2000\?2000:len,len-=n;do s1=s1+buf[pos++]|0,s2=s2+s1|0;while(--n);s1%=65521,s2%=65521}return s1|s2<<16|0}module2.exports=adler32}}),require_crc32=__commonJS({\"node_modules/pako/lib/zlib/crc32.js\"(exports,module2){function makeTable(){var c,table=[];for(var n=0;n<256;n++){c=n;for(var k=0;k<8;k++)c=c&1\?3988292384^c>>>1:c>>>1;table[n]=c}return table}var crcTable=makeTable();function crc32(crc,buf,len,pos){var t=crcTable,end=pos+len;crc^=-1;for(var i=pos;i>>8^t[(crc^buf[i])&255];return crc^-1}module2.exports=crc32}}),require_messages=__commonJS({\"node_modules/pako/lib/zlib/messages.js\"(exports,module2){module2.exports={2:\"need dictionary\",1:\"stream end\",0:\"\",\"-1\":\"file error\",\"-2\":\"stream error\",\"-3\":\"data error\",\"-4\":\"insufficient memory\",\"-5\":\"buffer error\",\"-6\":\"incompatible version\"}}}),require_deflate=__commonJS({\"node_modules/pako/lib/zlib/deflate.js\"(exports){var utils=require_common(),trees=require_trees(),adler32=require_adler32(),crc32=require_crc32(),msg=require_messages(),Z_NO_FLUSH=0,Z_PARTIAL_FLUSH=1,Z_FULL_FLUSH=3,Z_FINISH=4,Z_BLOCK=5,Z_OK=0,Z_STREAM_END=1,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_BUF_ERROR=-5,Z_DEFAULT_COMPRESSION=-1,Z_FILTERED=1,Z_HUFFMAN_ONLY=2,Z_RLE=3,Z_FIXED=4,Z_DEFAULT_STRATEGY=0,Z_UNKNOWN=2,Z_DEFLATED=8,MAX_MEM_LEVEL=9,MAX_WBITS=15,DEF_MEM_LEVEL=8,LENGTH_CODES=29,LITERALS=256,L_CODES=LITERALS+1+LENGTH_CODES,D_CODES=30,BL_CODES=19,HEAP_SIZE=2*L_CODES+1,MAX_BITS=15,MIN_MATCH=3,MAX_MATCH=258,MIN_LOOKAHEAD=MAX_MATCH+MIN_MATCH+1,PRESET_DICT=32,INIT_STATE=42,EXTRA_STATE=69,NAME_STATE=73,COMMENT_STATE=91,HCRC_STATE=103,BUSY_STATE=113,FINISH_STATE=666,BS_NEED_MORE=1,BS_BLOCK_DONE=2,BS_FINISH_STARTED=3,BS_FINISH_DONE=4,OS_CODE=3;function err(strm,errorCode){return strm.msg=msg[errorCode],errorCode}function rank(f){return(f<<1)-(f>4\?9:0)}function zero(buf){var len=buf.length;while(--len>=0)buf[len]=0}function flush_pending(strm){var s=strm.state,len=s.pending;if(len>strm.avail_out)len=strm.avail_out;if(len===0)return;if(utils.arraySet(strm.output,s.pending_buf,s.pending_out,len,strm.next_out),strm.next_out+=len,s.pending_out+=len,strm.total_out+=len,strm.avail_out-=len,s.pending-=len,s.pending===0)s.pending_out=0}function flush_block_only(s,last){trees._tr_flush_block(s,s.block_start>=0\?s.block_start:-1,s.strstart-s.block_start,last),s.block_start=s.strstart,flush_pending(s.strm)}function put_byte(s,b){s.pending_buf[s.pending++]=b}function putShortMSB(s,b){s.pending_buf[s.pending++]=b>>>8&255,s.pending_buf[s.pending++]=b&255}function read_buf(strm,buf,start,size){var len=strm.avail_in;if(len>size)len=size;if(len===0)return 0;if(strm.avail_in-=len,utils.arraySet(buf,strm.input,strm.next_in,len,start),strm.state.wrap===1)strm.adler=adler32(strm.adler,buf,len,start);else if(strm.state.wrap===2)strm.adler=crc32(strm.adler,buf,len,start);return strm.next_in+=len,strm.total_in+=len,len}function longest_match(s,cur_match){var{max_chain_length:chain_length,strstart:scan}=s,match,len,best_len=s.prev_length,nice_match=s.nice_match,limit=s.strstart>s.w_size-MIN_LOOKAHEAD\?s.strstart-(s.w_size-MIN_LOOKAHEAD):0,_win=s.window,wmask=s.w_mask,prev=s.prev,strend=s.strstart+MAX_MATCH,scan_end1=_win[scan+best_len-1],scan_end=_win[scan+best_len];if(s.prev_length>=s.good_match)chain_length>>=2;if(nice_match>s.lookahead)nice_match=s.lookahead;do{if(match=cur_match,_win[match+best_len]!==scan_end||_win[match+best_len-1]!==scan_end1||_win[match]!==_win[scan]||_win[++match]!==_win[scan+1])continue;scan+=2,match++;do;while(_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&_win[++scan]===_win[++match]&&scanbest_len){if(s.match_start=cur_match,best_len=len,len>=nice_match)break;scan_end1=_win[scan+best_len-1],scan_end=_win[scan+best_len]}}while((cur_match=prev[cur_match&wmask])>limit&&--chain_length!==0);if(best_len<=s.lookahead)return best_len;return s.lookahead}function fill_window(s){var _w_size=s.w_size,p,n,m,more,str;do{if(more=s.window_size-s.lookahead-s.strstart,s.strstart>=_w_size+(_w_size-MIN_LOOKAHEAD)){utils.arraySet(s.window,s.window,_w_size,_w_size,0),s.match_start-=_w_size,s.strstart-=_w_size,s.block_start-=_w_size,n=s.hash_size,p=n;do m=s.head[--p],s.head[p]=m>=_w_size\?m-_w_size:0;while(--n);n=_w_size,p=n;do m=s.prev[--p],s.prev[p]=m>=_w_size\?m-_w_size:0;while(--n);more+=_w_size}if(s.strm.avail_in===0)break;if(n=read_buf(s.strm,s.window,s.strstart+s.lookahead,more),s.lookahead+=n,s.lookahead+s.insert>=MIN_MATCH){str=s.strstart-s.insert,s.ins_h=s.window[str],s.ins_h=(s.ins_h<s.pending_buf_size-5)max_block_size=s.pending_buf_size-5;for(;;){if(s.lookahead<=1){if(fill_window(s),s.lookahead===0&&flush===Z_NO_FLUSH)return BS_NEED_MORE;if(s.lookahead===0)break}s.strstart+=s.lookahead,s.lookahead=0;var max_start=s.block_start+max_block_size;if(s.strstart===0||s.strstart>=max_start){if(s.lookahead=s.strstart-max_start,s.strstart=max_start,flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}if(s.strstart-s.block_start>=s.w_size-MIN_LOOKAHEAD){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.strstart>s.block_start){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_NEED_MORE}function deflate_fast(s,flush){var hash_head,bflush;for(;;){if(s.lookahead=MIN_MATCH)s.ins_h=(s.ins_h<=MIN_MATCH)if(bflush=trees._tr_tally(s,s.strstart-s.match_start,s.match_length-MIN_MATCH),s.lookahead-=s.match_length,s.match_length<=s.max_lazy_match&&s.lookahead>=MIN_MATCH){s.match_length--;do s.strstart++,s.ins_h=(s.ins_h<=MIN_MATCH)s.ins_h=(s.ins_h<4096))s.match_length=MIN_MATCH-1}if(s.prev_length>=MIN_MATCH&&s.match_length<=s.prev_length){max_insert=s.strstart+s.lookahead-MIN_MATCH,bflush=trees._tr_tally(s,s.strstart-1-s.prev_match,s.prev_length-MIN_MATCH),s.lookahead-=s.prev_length-1,s.prev_length-=2;do if(++s.strstart<=max_insert)s.ins_h=(s.ins_h<=MIN_MATCH&&s.strstart>0){if(scan=s.strstart-1,prev=_win[scan],prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]){strend=s.strstart+MAX_MATCH;do;while(prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&prev===_win[++scan]&&scans.lookahead)s.match_length=s.lookahead}}if(s.match_length>=MIN_MATCH)bflush=trees._tr_tally(s,1,s.match_length-MIN_MATCH),s.lookahead-=s.match_length,s.strstart+=s.match_length,s.match_length=0;else bflush=trees._tr_tally(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++;if(bflush){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function deflate_huff(s,flush){var bflush;for(;;){if(s.lookahead===0){if(fill_window(s),s.lookahead===0){if(flush===Z_NO_FLUSH)return BS_NEED_MORE;break}}if(s.match_length=0,bflush=trees._tr_tally(s,0,s.window[s.strstart]),s.lookahead--,s.strstart++,bflush){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}}if(s.insert=0,flush===Z_FINISH){if(flush_block_only(s,!0),s.strm.avail_out===0)return BS_FINISH_STARTED;return BS_FINISH_DONE}if(s.last_lit){if(flush_block_only(s,!1),s.strm.avail_out===0)return BS_NEED_MORE}return BS_BLOCK_DONE}function Config(good_length,max_lazy,nice_length,max_chain,func){this.good_length=good_length,this.max_lazy=max_lazy,this.nice_length=nice_length,this.max_chain=max_chain,this.func=func}var configuration_table=[new Config(0,0,0,0,deflate_stored),new Config(4,4,8,4,deflate_fast),new Config(4,5,16,8,deflate_fast),new Config(4,6,32,32,deflate_fast),new Config(4,4,16,16,deflate_slow),new Config(8,16,32,32,deflate_slow),new Config(8,16,128,128,deflate_slow),new Config(8,32,128,256,deflate_slow),new Config(32,128,258,1024,deflate_slow),new Config(32,258,258,4096,deflate_slow)];function lm_init(s){s.window_size=2*s.w_size,zero(s.head),s.max_lazy_match=configuration_table[s.level].max_lazy,s.good_match=configuration_table[s.level].good_length,s.nice_match=configuration_table[s.level].nice_length,s.max_chain_length=configuration_table[s.level].max_chain,s.strstart=0,s.block_start=0,s.lookahead=0,s.insert=0,s.match_length=s.prev_length=MIN_MATCH-1,s.match_available=0,s.ins_h=0}function DeflateState(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Z_DEFLATED,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new utils.Buf16(HEAP_SIZE*2),this.dyn_dtree=new utils.Buf16((2*D_CODES+1)*2),this.bl_tree=new utils.Buf16((2*BL_CODES+1)*2),zero(this.dyn_ltree),zero(this.dyn_dtree),zero(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new utils.Buf16(MAX_BITS+1),this.heap=new utils.Buf16(2*L_CODES+1),zero(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new utils.Buf16(2*L_CODES+1),zero(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function deflateResetKeep(strm){var s;if(!strm||!strm.state)return err(strm,Z_STREAM_ERROR);if(strm.total_in=strm.total_out=0,strm.data_type=Z_UNKNOWN,s=strm.state,s.pending=0,s.pending_out=0,s.wrap<0)s.wrap=-s.wrap;return s.status=s.wrap\?INIT_STATE:BUSY_STATE,strm.adler=s.wrap===2\?0:1,s.last_flush=Z_NO_FLUSH,trees._tr_init(s),Z_OK}function deflateReset(strm){var ret=deflateResetKeep(strm);if(ret===Z_OK)lm_init(strm.state);return ret}function deflateSetHeader(strm,head){if(!strm||!strm.state)return Z_STREAM_ERROR;if(strm.state.wrap!==2)return Z_STREAM_ERROR;return strm.state.gzhead=head,Z_OK}function deflateInit2(strm,level,method,windowBits,memLevel,strategy){if(!strm)return Z_STREAM_ERROR;var wrap=1;if(level===Z_DEFAULT_COMPRESSION)level=6;if(windowBits<0)wrap=0,windowBits=-windowBits;else if(windowBits>15)wrap=2,windowBits-=16;if(memLevel<1||memLevel>MAX_MEM_LEVEL||method!==Z_DEFLATED||windowBits<8||windowBits>15||level<0||level>9||strategy<0||strategy>Z_FIXED)return err(strm,Z_STREAM_ERROR);if(windowBits===8)windowBits=9;var s=new DeflateState;return strm.state=s,s.strm=strm,s.wrap=wrap,s.gzhead=null,s.w_bits=windowBits,s.w_size=1<Z_BLOCK||flush<0)return strm\?err(strm,Z_STREAM_ERROR):Z_STREAM_ERROR;if(s=strm.state,!strm.output||!strm.input&&strm.avail_in!==0||s.status===FINISH_STATE&&flush!==Z_FINISH)return err(strm,strm.avail_out===0\?Z_BUF_ERROR:Z_STREAM_ERROR);if(s.strm=strm,old_flush=s.last_flush,s.last_flush=flush,s.status===INIT_STATE)if(s.wrap===2)if(strm.adler=0,put_byte(s,31),put_byte(s,139),put_byte(s,8),!s.gzhead)put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,0),put_byte(s,s.level===9\?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2\?4:0),put_byte(s,OS_CODE),s.status=BUSY_STATE;else{if(put_byte(s,(s.gzhead.text\?1:0)+(s.gzhead.hcrc\?2:0)+(!s.gzhead.extra\?0:4)+(!s.gzhead.name\?0:8)+(!s.gzhead.comment\?0:16)),put_byte(s,s.gzhead.time&255),put_byte(s,s.gzhead.time>>8&255),put_byte(s,s.gzhead.time>>16&255),put_byte(s,s.gzhead.time>>24&255),put_byte(s,s.level===9\?2:s.strategy>=Z_HUFFMAN_ONLY||s.level<2\?4:0),put_byte(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length)put_byte(s,s.gzhead.extra.length&255),put_byte(s,s.gzhead.extra.length>>8&255);if(s.gzhead.hcrc)strm.adler=crc32(strm.adler,s.pending_buf,s.pending,0);s.gzindex=0,s.status=EXTRA_STATE}else{var header=Z_DEFLATED+(s.w_bits-8<<4)<<8,level_flags=-1;if(s.strategy>=Z_HUFFMAN_ONLY||s.level<2)level_flags=0;else if(s.level<6)level_flags=1;else if(s.level===6)level_flags=2;else level_flags=3;if(header|=level_flags<<6,s.strstart!==0)header|=PRESET_DICT;if(header+=31-header%31,s.status=BUSY_STATE,putShortMSB(s,header),s.strstart!==0)putShortMSB(s,strm.adler>>>16),putShortMSB(s,strm.adler&65535);strm.adler=1}if(s.status===EXTRA_STATE)if(s.gzhead.extra){beg=s.pending;while(s.gzindex<(s.gzhead.extra.length&65535)){if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size)break}put_byte(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++}if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(s.gzindex===s.gzhead.extra.length)s.gzindex=0,s.status=NAME_STATE}else s.status=NAME_STATE;if(s.status===NAME_STATE)if(s.gzhead.name){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.gzindex=0,s.status=COMMENT_STATE}else s.status=COMMENT_STATE;if(s.status===COMMENT_STATE)if(s.gzhead.comment){beg=s.pending;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>beg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(flush_pending(strm),beg=s.pending,s.pending===s.pending_buf_size){val=1;break}}if(s.gzindexbeg)strm.adler=crc32(strm.adler,s.pending_buf,s.pending-beg,beg);if(val===0)s.status=HCRC_STATE}else s.status=HCRC_STATE;if(s.status===HCRC_STATE)if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size)flush_pending(strm);if(s.pending+2<=s.pending_buf_size)put_byte(s,strm.adler&255),put_byte(s,strm.adler>>8&255),strm.adler=0,s.status=BUSY_STATE}else s.status=BUSY_STATE;if(s.pending!==0){if(flush_pending(strm),strm.avail_out===0)return s.last_flush=-1,Z_OK}else if(strm.avail_in===0&&rank(flush)<=rank(old_flush)&&flush!==Z_FINISH)return err(strm,Z_BUF_ERROR);if(s.status===FINISH_STATE&&strm.avail_in!==0)return err(strm,Z_BUF_ERROR);if(strm.avail_in!==0||s.lookahead!==0||flush!==Z_NO_FLUSH&&s.status!==FINISH_STATE){var bstate=s.strategy===Z_HUFFMAN_ONLY\?deflate_huff(s,flush):s.strategy===Z_RLE\?deflate_rle(s,flush):configuration_table[s.level].func(s,flush);if(bstate===BS_FINISH_STARTED||bstate===BS_FINISH_DONE)s.status=FINISH_STATE;if(bstate===BS_NEED_MORE||bstate===BS_FINISH_STARTED){if(strm.avail_out===0)s.last_flush=-1;return Z_OK}if(bstate===BS_BLOCK_DONE){if(flush===Z_PARTIAL_FLUSH)trees._tr_align(s);else if(flush!==Z_BLOCK){if(trees._tr_stored_block(s,0,0,!1),flush===Z_FULL_FLUSH){if(zero(s.head),s.lookahead===0)s.strstart=0,s.block_start=0,s.insert=0}}if(flush_pending(strm),strm.avail_out===0)return s.last_flush=-1,Z_OK}}if(flush!==Z_FINISH)return Z_OK;if(s.wrap<=0)return Z_STREAM_END;if(s.wrap===2)put_byte(s,strm.adler&255),put_byte(s,strm.adler>>8&255),put_byte(s,strm.adler>>16&255),put_byte(s,strm.adler>>24&255),put_byte(s,strm.total_in&255),put_byte(s,strm.total_in>>8&255),put_byte(s,strm.total_in>>16&255),put_byte(s,strm.total_in>>24&255);else putShortMSB(s,strm.adler>>>16),putShortMSB(s,strm.adler&65535);if(flush_pending(strm),s.wrap>0)s.wrap=-s.wrap;return s.pending!==0\?Z_OK:Z_STREAM_END}function deflateEnd(strm){var status;if(!strm||!strm.state)return Z_STREAM_ERROR;if(status=strm.state.status,status!==INIT_STATE&&status!==EXTRA_STATE&&status!==NAME_STATE&&status!==COMMENT_STATE&&status!==HCRC_STATE&&status!==BUSY_STATE&&status!==FINISH_STATE)return err(strm,Z_STREAM_ERROR);return strm.state=null,status===BUSY_STATE\?err(strm,Z_DATA_ERROR):Z_OK}function deflateSetDictionary(strm,dictionary){var dictLength=dictionary.length,s,str,n,wrap,avail,next,input,tmpDict;if(!strm||!strm.state)return Z_STREAM_ERROR;if(s=strm.state,wrap=s.wrap,wrap===2||wrap===1&&s.status!==INIT_STATE||s.lookahead)return Z_STREAM_ERROR;if(wrap===1)strm.adler=adler32(strm.adler,dictionary,dictLength,0);if(s.wrap=0,dictLength>=s.w_size){if(wrap===0)zero(s.head),s.strstart=0,s.block_start=0,s.insert=0;tmpDict=new utils.Buf8(s.w_size),utils.arraySet(tmpDict,dictionary,dictLength-s.w_size,s.w_size,0),dictionary=tmpDict,dictLength=s.w_size}avail=strm.avail_in,next=strm.next_in,input=strm.input,strm.avail_in=dictLength,strm.next_in=0,strm.input=dictionary,fill_window(s);while(s.lookahead>=MIN_MATCH){str=s.strstart,n=s.lookahead-(MIN_MATCH-1);do s.ins_h=(s.ins_h<>>24,hold>>>=op,bits-=op,op=here>>>16&255,op===0)output[_out++]=here&65535;else if(op&16){if(len=here&65535,op&=15,op){if(bits>>=op,bits-=op}if(bits<15)hold+=input[_in++]<>>24,hold>>>=op,bits-=op,op=here>>>16&255,op&16){if(dist=here&65535,op&=15,bitsdmax){strm.msg=\"invalid distance too far back\",state.mode=BAD;break top}if(hold>>>=op,bits-=op,op=_out-beg,dist>op){if(op=dist-op,op>whave){if(state.sane){strm.msg=\"invalid distance too far back\",state.mode=BAD;break top}}if(from=0,from_source=s_window,wnext===0){if(from+=wsize-op,op2)output[_out++]=from_source[from++],output[_out++]=from_source[from++],output[_out++]=from_source[from++],len-=3;if(len){if(output[_out++]=from_source[from++],len>1)output[_out++]=from_source[from++]}}else{from=_out-dist;do output[_out++]=output[from++],output[_out++]=output[from++],output[_out++]=output[from++],len-=3;while(len>2);if(len){if(output[_out++]=output[from++],len>1)output[_out++]=output[from++]}}}else if((op&64)===0){here=dcode[(here&65535)+(hold&(1<>3,_in-=len,bits-=len<<3,hold&=(1<=1;max--)if(count[max]!==0)break;if(root>max)root=max;if(max===0)return table[table_index++]=1<<24|64<<16|0,table[table_index++]=1<<24|64<<16|0,opts.bits=1,0;for(min=1;min0&&(type===CODES||max!==1))return-1;offs[1]=0;for(len=1;lenENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;for(;;){if(here_bits=len-drop,work[sym]end)here_op=extra[extra_index+work[sym]],here_val=base[base_index+work[sym]];else here_op=96,here_val=0;incr=1<>drop)+fill]=here_bits<<24|here_op<<16|here_val|0;while(fill!==0);incr=1<>=1;if(incr!==0)huff&=incr-1,huff+=incr;else huff=0;if(sym++,--count[len]===0){if(len===max)break;len=lens[lens_index+work[sym]]}if(len>root&&(huff&mask)!==low){if(drop===0)drop=root;next+=min,curr=len-drop,left=1<ENOUGH_LENS||type===DISTS&&used>ENOUGH_DISTS)return 1;low=huff&mask,table[low]=root<<24|curr<<16|next-table_index|0}}if(huff!==0)table[next+huff]=len-drop<<24|64<<16|0;return opts.bits=root,0}}}),require_inflate=__commonJS({\"node_modules/pako/lib/zlib/inflate.js\"(exports){var utils=require_common(),adler32=require_adler32(),crc32=require_crc32(),inflate_fast=require_inffast(),inflate_table=require_inftrees(),CODES=0,LENS=1,DISTS=2,Z_FINISH=4,Z_BLOCK=5,Z_TREES=6,Z_OK=0,Z_STREAM_END=1,Z_NEED_DICT=2,Z_STREAM_ERROR=-2,Z_DATA_ERROR=-3,Z_MEM_ERROR=-4,Z_BUF_ERROR=-5,Z_DEFLATED=8,HEAD=1,FLAGS=2,TIME=3,OS=4,EXLEN=5,EXTRA=6,NAME=7,COMMENT=8,HCRC=9,DICTID=10,DICT=11,TYPE=12,TYPEDO=13,STORED=14,COPY_=15,COPY=16,TABLE=17,LENLENS=18,CODELENS=19,LEN_=20,LEN=21,LENEXT=22,DIST=23,DISTEXT=24,MATCH=25,LIT=26,CHECK=27,LENGTH=28,DONE=29,BAD=30,MEM=31,SYNC=32,ENOUGH_LENS=852,ENOUGH_DISTS=592,MAX_WBITS=15,DEF_WBITS=MAX_WBITS;function zswap32(q){return(q>>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function InflateState(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new utils.Buf16(320),this.work=new utils.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function inflateResetKeep(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;if(state=strm.state,strm.total_in=strm.total_out=state.total=0,strm.msg=\"\",state.wrap)strm.adler=state.wrap&1;return state.mode=HEAD,state.last=0,state.havedict=0,state.dmax=32768,state.head=null,state.hold=0,state.bits=0,state.lencode=state.lendyn=new utils.Buf32(ENOUGH_LENS),state.distcode=state.distdyn=new utils.Buf32(ENOUGH_DISTS),state.sane=1,state.back=-1,Z_OK}function inflateReset(strm){var state;if(!strm||!strm.state)return Z_STREAM_ERROR;return state=strm.state,state.wsize=0,state.whave=0,state.wnext=0,inflateResetKeep(strm)}function inflateReset2(strm,windowBits){var wrap,state;if(!strm||!strm.state)return Z_STREAM_ERROR;if(state=strm.state,windowBits<0)wrap=0,windowBits=-windowBits;else if(wrap=(windowBits>>4)+1,windowBits<48)windowBits&=15;if(windowBits&&(windowBits<8||windowBits>15))return Z_STREAM_ERROR;if(state.window!==null&&state.wbits!==windowBits)state.window=null;return state.wrap=wrap,state.wbits=windowBits,inflateReset(strm)}function inflateInit2(strm,windowBits){var ret,state;if(!strm)return Z_STREAM_ERROR;if(state=new InflateState,strm.state=state,state.window=null,ret=inflateReset2(strm,windowBits),ret!==Z_OK)strm.state=null;return ret}function inflateInit(strm){return inflateInit2(strm,DEF_WBITS)}var virgin=!0,lenfix,distfix;function fixedtables(state){if(virgin){var sym;lenfix=new utils.Buf32(512),distfix=new utils.Buf32(32),sym=0;while(sym<144)state.lens[sym++]=8;while(sym<256)state.lens[sym++]=9;while(sym<280)state.lens[sym++]=7;while(sym<288)state.lens[sym++]=8;inflate_table(LENS,state.lens,0,288,lenfix,0,state.work,{bits:9}),sym=0;while(sym<32)state.lens[sym++]=5;inflate_table(DISTS,state.lens,0,32,distfix,0,state.work,{bits:5}),virgin=!1}state.lencode=lenfix,state.lenbits=9,state.distcode=distfix,state.distbits=5}function updatewindow(strm,src,end,copy){var dist,state=strm.state;if(state.window===null)state.wsize=1<=state.wsize)utils.arraySet(state.window,src,end-state.wsize,state.wsize,0),state.wnext=0,state.whave=state.wsize;else{if(dist=state.wsize-state.wnext,dist>copy)dist=copy;if(utils.arraySet(state.window,src,end-copy,dist,state.wnext),copy-=dist,copy)utils.arraySet(state.window,src,end-copy,copy,0),state.wnext=copy,state.whave=state.wsize;else{if(state.wnext+=dist,state.wnext===state.wsize)state.wnext=0;if(state.whave>>8&255,state.check=crc32(state.check,hbuf,2,0),hold=0,bits=0,state.mode=FLAGS;break}if(state.flags=0,state.head)state.head.done=!1;if(!(state.wrap&1)||(((hold&255)<<8)+(hold>>8))%31){strm.msg=\"incorrect header check\",state.mode=BAD;break}if((hold&15)!==Z_DEFLATED){strm.msg=\"unknown compression method\",state.mode=BAD;break}if(hold>>>=4,bits-=4,len=(hold&15)+8,state.wbits===0)state.wbits=len;else if(len>state.wbits){strm.msg=\"invalid window size\",state.mode=BAD;break}state.dmax=1<>8&1;if(state.flags&512)hbuf[0]=hold&255,hbuf[1]=hold>>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0,state.mode=TIME;case TIME:while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>8&255,hbuf[2]=hold>>>16&255,hbuf[3]=hold>>>24&255,state.check=crc32(state.check,hbuf,4,0);hold=0,bits=0,state.mode=OS;case OS:while(bits<16){if(have===0)break inf_leave;have--,hold+=input[next++]<>8;if(state.flags&512)hbuf[0]=hold&255,hbuf[1]=hold>>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0,state.mode=EXLEN;case EXLEN:if(state.flags&1024){while(bits<16){if(have===0)break inf_leave;have--,hold+=input[next++]<>>8&255,state.check=crc32(state.check,hbuf,2,0);hold=0,bits=0}else if(state.head)state.head.extra=null;state.mode=EXTRA;case EXTRA:if(state.flags&1024){if(copy=state.length,copy>have)copy=have;if(copy){if(state.head){if(len=state.head.extra_len-state.length,!state.head.extra)state.head.extra=new Array(state.head.extra_len);utils.arraySet(state.head.extra,input,next,copy,len)}if(state.flags&512)state.check=crc32(state.check,input,copy,next);have-=copy,next+=copy,state.length-=copy}if(state.length)break inf_leave}state.length=0,state.mode=NAME;case NAME:if(state.flags&2048){if(have===0)break inf_leave;copy=0;do if(len=input[next+copy++],state.head&&len&&state.length<65536)state.head.name+=String.fromCharCode(len);while(len&©>9&1,state.head.done=!0;strm.adler=state.check=0,state.mode=TYPE;break;case DICTID:while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=bits&7,bits-=bits&7,state.mode=CHECK;break}while(bits<3){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=1,bits-=1,hold&3){case 0:state.mode=STORED;break;case 1:if(fixedtables(state),state.mode=LEN_,flush===Z_TREES){hold>>>=2,bits-=2;break inf_leave}break;case 2:state.mode=TABLE;break;case 3:strm.msg=\"invalid block type\",state.mode=BAD}hold>>>=2,bits-=2;break;case STORED:hold>>>=bits&7,bits-=bits&7;while(bits<32){if(have===0)break inf_leave;have--,hold+=input[next++]<>>16^65535)){strm.msg=\"invalid stored block lengths\",state.mode=BAD;break}if(state.length=hold&65535,hold=0,bits=0,state.mode=COPY_,flush===Z_TREES)break inf_leave;case COPY_:state.mode=COPY;case COPY:if(copy=state.length,copy){if(copy>have)copy=have;if(copy>left)copy=left;if(copy===0)break inf_leave;utils.arraySet(output,input,next,copy,put),have-=copy,next+=copy,left-=copy,put+=copy,state.length-=copy;break}state.mode=TYPE;break;case TABLE:while(bits<14){if(have===0)break inf_leave;have--,hold+=input[next++]<>>=5,bits-=5,state.ndist=(hold&31)+1,hold>>>=5,bits-=5,state.ncode=(hold&15)+4,hold>>>=4,bits-=4,state.nlen>286||state.ndist>30){strm.msg=\"too many length or distance symbols\",state.mode=BAD;break}state.have=0,state.mode=LENLENS;case LENLENS:while(state.have>>=3,bits-=3}while(state.have<19)state.lens[order[state.have++]]=0;if(state.lencode=state.lendyn,state.lenbits=7,opts={bits:state.lenbits},ret=inflate_table(CODES,state.lens,0,19,state.lencode,0,state.work,opts),state.lenbits=opts.bits,ret){strm.msg=\"invalid code lengths set\",state.mode=BAD;break}state.have=0,state.mode=CODELENS;case CODELENS:while(state.have>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=here_bits,bits-=here_bits,state.lens[state.have++]=here_val;else{if(here_val===16){n=here_bits+2;while(bits>>=here_bits,bits-=here_bits,state.have===0){strm.msg=\"invalid bit length repeat\",state.mode=BAD;break}len=state.lens[state.have-1],copy=3+(hold&3),hold>>>=2,bits-=2}else if(here_val===17){n=here_bits+3;while(bits>>=here_bits,bits-=here_bits,len=0,copy=3+(hold&7),hold>>>=3,bits-=3}else{n=here_bits+7;while(bits>>=here_bits,bits-=here_bits,len=0,copy=11+(hold&127),hold>>>=7,bits-=7}if(state.have+copy>state.nlen+state.ndist){strm.msg=\"invalid bit length repeat\",state.mode=BAD;break}while(copy--)state.lens[state.have++]=len}}if(state.mode===BAD)break;if(state.lens[256]===0){strm.msg=\"invalid code -- missing end-of-block\",state.mode=BAD;break}if(state.lenbits=9,opts={bits:state.lenbits},ret=inflate_table(LENS,state.lens,0,state.nlen,state.lencode,0,state.work,opts),state.lenbits=opts.bits,ret){strm.msg=\"invalid literal/lengths set\",state.mode=BAD;break}if(state.distbits=6,state.distcode=state.distdyn,opts={bits:state.distbits},ret=inflate_table(DISTS,state.lens,state.nlen,state.ndist,state.distcode,0,state.work,opts),state.distbits=opts.bits,ret){strm.msg=\"invalid distances set\",state.mode=BAD;break}if(state.mode=LEN_,flush===Z_TREES)break inf_leave;case LEN_:state.mode=LEN;case LEN:if(have>=6&&left>=258){if(strm.next_out=put,strm.avail_out=left,strm.next_in=next,strm.avail_in=have,state.hold=hold,state.bits=bits,inflate_fast(strm,_out),put=strm.next_out,output=strm.output,left=strm.avail_out,next=strm.next_in,input=strm.input,have=strm.avail_in,hold=state.hold,bits=state.bits,state.mode===TYPE)state.back=-1;break}state.back=0;for(;;){if(here=state.lencode[hold&(1<>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>last_bits)],here_bits=here>>>24,here_op=here>>>16&255,here_val=here&65535,last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=last_bits,bits-=last_bits,state.back+=last_bits}if(hold>>>=here_bits,bits-=here_bits,state.back+=here_bits,state.length=here_val,here_op===0){state.mode=LIT;break}if(here_op&32){state.back=-1,state.mode=TYPE;break}if(here_op&64){strm.msg=\"invalid literal/length code\",state.mode=BAD;break}state.extra=here_op&15,state.mode=LENEXT;case LENEXT:if(state.extra){n=state.extra;while(bits>>=state.extra,bits-=state.extra,state.back+=state.extra}state.was=state.length,state.mode=DIST;case DIST:for(;;){if(here=state.distcode[hold&(1<>>24,here_op=here>>>16&255,here_val=here&65535,here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>last_bits)],here_bits=here>>>24,here_op=here>>>16&255,here_val=here&65535,last_bits+here_bits<=bits)break;if(have===0)break inf_leave;have--,hold+=input[next++]<>>=last_bits,bits-=last_bits,state.back+=last_bits}if(hold>>>=here_bits,bits-=here_bits,state.back+=here_bits,here_op&64){strm.msg=\"invalid distance code\",state.mode=BAD;break}state.offset=here_val,state.extra=here_op&15,state.mode=DISTEXT;case DISTEXT:if(state.extra){n=state.extra;while(bits>>=state.extra,bits-=state.extra,state.back+=state.extra}if(state.offset>state.dmax){strm.msg=\"invalid distance too far back\",state.mode=BAD;break}state.mode=MATCH;case MATCH:if(left===0)break inf_leave;if(copy=_out-left,state.offset>copy){if(copy=state.offset-copy,copy>state.whave){if(state.sane){strm.msg=\"invalid distance too far back\",state.mode=BAD;break}}if(copy>state.wnext)copy-=state.wnext,from=state.wsize-copy;else from=state.wnext-copy;if(copy>state.length)copy=state.length;from_source=state.window}else from_source=output,from=put-state.offset,copy=state.length;if(copy>left)copy=left;left-=copy,state.length-=copy;do output[put++]=from_source[from++];while(--copy);if(state.length===0)state.mode=LEN;break;case LIT:if(left===0)break inf_leave;output[put++]=state.length,left--,state.mode=LEN;break;case CHECK:if(state.wrap){while(bits<32){if(have===0)break inf_leave;have--,hold|=input[next++]<exports.UNZIP)@throwTypeError(\"Bad argument\");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=mode,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}Zlib.prototype={},Zlib.prototype.close=function(){if(this.write_in_progress){this.pending_close=!0;return}if(this.pending_close=!1,assert(this.init_done,\"close before init\"),assert(this.mode<=exports.UNZIP),this.mode===exports.DEFLATE||this.mode===exports.GZIP||this.mode===exports.DEFLATERAW)zlib_deflate.deflateEnd(this.strm);else if(this.mode===exports.INFLATE||this.mode===exports.GUNZIP||this.mode===exports.INFLATERAW||this.mode===exports.UNZIP)zlib_inflate.inflateEnd(this.strm);this.mode=exports.NONE,this.dictionary=null},Zlib.prototype.write=function(flush,input,in_off,in_len,out,out_off,out_len){return this._write(!0,flush,input,in_off,in_len,out,out_off,out_len)},Zlib.prototype.writeSync=function(flush,input,in_off,in_len,out,out_off,out_len){return this._write(!1,flush,input,in_off,in_len,out,out_off,out_len)},Zlib.prototype._write=function(async,flush,input,in_off,in_len,out,out_off,out_len){if(assert.equal(arguments.length,8),assert(this.init_done,\"write before init\"),assert(this.mode!==exports.NONE,\"already finalized\"),assert.equal(!1,this.write_in_progress,\"write already in progress\"),assert.equal(!1,this.pending_close,\"close is pending\"),this.write_in_progress=!0,assert.equal(!1,flush===void 0,\"must provide flush value\"),this.write_in_progress=!0,flush!==exports.Z_NO_FLUSH&&flush!==exports.Z_PARTIAL_FLUSH&&flush!==exports.Z_SYNC_FLUSH&&flush!==exports.Z_FULL_FLUSH&&flush!==exports.Z_FINISH&&flush!==exports.Z_BLOCK)throw new Error(\"Invalid flush value\");if(input==null)input=Buffer.alloc(0),in_len=0,in_off=0;if(this.strm.avail_in=in_len,this.strm.input=input,this.strm.next_in=in_off,this.strm.avail_out=out_len,this.strm.output=out,this.strm.next_out=out_off,this.flush=flush,!async){if(this._process(),this._checkError())return this._afterSync();return}var self=this;return process.nextTick(function(){self._process(),self._after()}),this},Zlib.prototype._afterSync=function(){var avail_out=this.strm.avail_out,avail_in=this.strm.avail_in;return this.write_in_progress=!1,[avail_in,avail_out]},Zlib.prototype._process=function(){var next_expected_header_byte=null;switch(this.mode){case exports.DEFLATE:case exports.GZIP:case exports.DEFLATERAW:this.err=zlib_deflate.deflate(this.strm,this.flush);break;case exports.UNZIP:if(this.strm.avail_in>0)next_expected_header_byte=this.strm.next_in;switch(this.gzip_id_bytes_read){case 0:if(next_expected_header_byte===null)break;if(this.strm.input[next_expected_header_byte]===GZIP_HEADER_ID1){if(this.gzip_id_bytes_read=1,next_expected_header_byte++,this.strm.avail_in===1)break}else{this.mode=exports.INFLATE;break}case 1:if(next_expected_header_byte===null)break;if(this.strm.input[next_expected_header_byte]===GZIP_HEADER_ID2)this.gzip_id_bytes_read=2,this.mode=exports.GUNZIP;else this.mode=exports.INFLATE;break;default:throw new Error(\"invalid number of gzip magic number bytes read\")}case exports.INFLATE:case exports.GUNZIP:case exports.INFLATERAW:if(this.err=zlib_inflate.inflate(this.strm,this.flush),this.err===exports.Z_NEED_DICT&&this.dictionary){if(this.err=zlib_inflate.inflateSetDictionary(this.strm,this.dictionary),this.err===exports.Z_OK)this.err=zlib_inflate.inflate(this.strm,this.flush);else if(this.err===exports.Z_DATA_ERROR)this.err=exports.Z_NEED_DICT}while(this.strm.avail_in>0&&this.mode===exports.GUNZIP&&this.err===exports.Z_STREAM_END&&this.strm.next_in[0]!==0)this.reset(),this.err=zlib_inflate.inflate(this.strm,this.flush);break;default:throw new Error(\"Unknown mode \"+this.mode)}},Zlib.prototype._checkError=function(){switch(this.err){case exports.Z_OK:case exports.Z_BUF_ERROR:if(this.strm.avail_out!==0&&this.flush===exports.Z_FINISH)return this._error(\"unexpected end of file\"),!1;break;case exports.Z_STREAM_END:break;case exports.Z_NEED_DICT:if(this.dictionary==null)this._error(\"Missing dictionary\");else this._error(\"Bad dictionary\");return!1;default:return this._error(\"Zlib error\"),!1}return!0},Zlib.prototype._after=function(){if(!this._checkError())return;var avail_out=this.strm.avail_out,avail_in=this.strm.avail_in;if(this.write_in_progress=!1,this.callback(avail_in,avail_out),this.pending_close)this.close()},Zlib.prototype._error=function(message){if(this.strm.msg)message=this.strm.msg;if(this.onerror(message,this.err),this.write_in_progress=!1,this.pending_close)this.close()},Zlib.prototype.init=function(windowBits,level,memLevel,strategy,dictionary){assert(arguments.length===4||arguments.length===5,\"init(windowBits, level, memLevel, strategy, [dictionary])\"),assert(windowBits>=8&&windowBits<=15,\"invalid windowBits\"),assert(level>=-1&&level<=9,\"invalid compression level\"),assert(memLevel>=1&&memLevel<=9,\"invalid memlevel\"),assert(strategy===exports.Z_FILTERED||strategy===exports.Z_HUFFMAN_ONLY||strategy===exports.Z_RLE||strategy===exports.Z_FIXED||strategy===exports.Z_DEFAULT_STRATEGY,\"invalid strategy\"),this._init(level,windowBits,memLevel,strategy,dictionary),this._setDictionary()},Zlib.prototype.params=function(){throw new Error(\"deflateParams Not supported\")},Zlib.prototype.reset=function(){this._reset(),this._setDictionary()},Zlib.prototype._init=function(level,windowBits,memLevel,strategy,dictionary){if(this.level=level,this.windowBits=windowBits,this.memLevel=memLevel,this.strategy=strategy,this.flush=exports.Z_NO_FLUSH,this.err=exports.Z_OK,this.mode===exports.GZIP||this.mode===exports.GUNZIP)this.windowBits+=16;if(this.mode===exports.UNZIP)this.windowBits+=32;if(this.mode===exports.DEFLATERAW||this.mode===exports.INFLATERAW)this.windowBits=-1*this.windowBits;switch(this.strm=new Zstream,this.mode){case exports.DEFLATE:case exports.GZIP:case exports.DEFLATERAW:this.err=zlib_deflate.deflateInit2(this.strm,this.level,exports.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case exports.INFLATE:case exports.GUNZIP:case exports.INFLATERAW:case exports.UNZIP:this.err=zlib_inflate.inflateInit2(this.strm,this.windowBits);break;default:throw new Error(\"Unknown mode \"+this.mode)}if(this.err!==exports.Z_OK)this._error(\"Init error\");this.dictionary=dictionary,this.write_in_progress=!1,this.init_done=!0},Zlib.prototype._setDictionary=function(){if(this.dictionary==null)return;switch(this.err=exports.Z_OK,this.mode){case exports.DEFLATE:case exports.DEFLATERAW:this.err=zlib_deflate.deflateSetDictionary(this.strm,this.dictionary);break;default:break}if(this.err!==exports.Z_OK)this._error(\"Failed to set dictionary\")},Zlib.prototype._reset=function(){switch(this.err=exports.Z_OK,this.mode){case exports.DEFLATE:case exports.DEFLATERAW:case exports.GZIP:this.err=zlib_deflate.deflateReset(this.strm);break;case exports.INFLATE:case exports.INFLATERAW:case exports.GUNZIP:this.err=zlib_inflate.inflateReset(this.strm);break;default:break}if(this.err!==exports.Z_OK)this._error(\"Failed to reset stream\")},exports.Zlib=Zlib}}),require_lib=__commonJS({\"node_modules/browserify-zlib/lib/index.js\"(exports){var Buffer2=BufferModule.Buffer,Transform=StreamModule.Transform,binding=require_binding(),util=Util,kMaxLength=BufferModule.kMaxLength,kRangeErrorMessage=\"Cannot create final Buffer. It would be larger than 0x\"+kMaxLength.toString(16)+\" bytes\";binding.Z_MIN_WINDOWBITS=8,binding.Z_MAX_WINDOWBITS=15,binding.Z_DEFAULT_WINDOWBITS=15,binding.Z_MIN_CHUNK=64,binding.Z_MAX_CHUNK=Infinity,binding.Z_DEFAULT_CHUNK=16384,binding.Z_MIN_MEMLEVEL=1,binding.Z_MAX_MEMLEVEL=9,binding.Z_DEFAULT_MEMLEVEL=8,binding.Z_MIN_LEVEL=-1,binding.Z_MAX_LEVEL=9,binding.Z_DEFAULT_LEVEL=binding.Z_DEFAULT_COMPRESSION;var bkeys=Object.keys(binding);for(bk=0;bk=kMaxLength)err=new RangeError(kRangeErrorMessage);else buf=Buffer2.concat(buffers,nread);buffers=[],engine.close(),callback(err,buf)}}function zlibBufferSync(engine,buffer){if(typeof buffer===\"string\")buffer=Buffer2.from(buffer);if(!Buffer2.isBuffer(buffer))@throwTypeError(\"Not a string or buffer\");var flushFlag=engine._finishFlushFlag;return engine._processChunk(buffer,flushFlag)}function Deflate(opts){if(!(this instanceof Deflate))return new Deflate(opts);Zlib.call(this,opts,binding.DEFLATE)}function Inflate(opts){if(!(this instanceof Inflate))return new Inflate(opts);Zlib.call(this,opts,binding.INFLATE)}function Gzip(opts){if(!(this instanceof Gzip))return new Gzip(opts);Zlib.call(this,opts,binding.GZIP)}function Gunzip(opts){if(!(this instanceof Gunzip))return new Gunzip(opts);Zlib.call(this,opts,binding.GUNZIP)}function DeflateRaw(opts){if(!(this instanceof DeflateRaw))return new DeflateRaw(opts);Zlib.call(this,opts,binding.DEFLATERAW)}function InflateRaw(opts){if(!(this instanceof InflateRaw))return new InflateRaw(opts);Zlib.call(this,opts,binding.INFLATERAW)}function Unzip(opts){if(!(this instanceof Unzip))return new Unzip(opts);Zlib.call(this,opts,binding.UNZIP)}function isValidFlushFlag(flag){return flag===binding.Z_NO_FLUSH||flag===binding.Z_PARTIAL_FLUSH||flag===binding.Z_SYNC_FLUSH||flag===binding.Z_FULL_FLUSH||flag===binding.Z_FINISH||flag===binding.Z_BLOCK}function Zlib(opts,mode){var _this=this;if(this._opts=opts=opts||{},this._chunkSize=opts.chunkSize||exports.Z_DEFAULT_CHUNK,Transform.call(this,opts),opts.flush&&!isValidFlushFlag(opts.flush))throw new Error(\"Invalid flush flag: \"+opts.flush);if(opts.finishFlush&&!isValidFlushFlag(opts.finishFlush))throw new Error(\"Invalid flush flag: \"+opts.finishFlush);if(this._flushFlag=opts.flush||binding.Z_NO_FLUSH,this._finishFlushFlag=typeof opts.finishFlush!==\"undefined\"\?opts.finishFlush:binding.Z_FINISH,opts.chunkSize){if(opts.chunkSizeexports.Z_MAX_CHUNK)throw new Error(\"Invalid chunk size: \"+opts.chunkSize)}if(opts.windowBits){if(opts.windowBitsexports.Z_MAX_WINDOWBITS)throw new Error(\"Invalid windowBits: \"+opts.windowBits)}if(opts.level){if(opts.levelexports.Z_MAX_LEVEL)throw new Error(\"Invalid compression level: \"+opts.level)}if(opts.memLevel){if(opts.memLevelexports.Z_MAX_MEMLEVEL)throw new Error(\"Invalid memLevel: \"+opts.memLevel)}if(opts.strategy){if(opts.strategy!=exports.Z_FILTERED&&opts.strategy!=exports.Z_HUFFMAN_ONLY&&opts.strategy!=exports.Z_RLE&&opts.strategy!=exports.Z_FIXED&&opts.strategy!=exports.Z_DEFAULT_STRATEGY)throw new Error(\"Invalid strategy: \"+opts.strategy)}if(opts.dictionary){if(!Buffer2.isBuffer(opts.dictionary))throw new Error(\"Invalid dictionary: it should be a Buffer instance\")}this._handle=new binding.Zlib(mode);var self=this;this._hadError=!1,this._handle.onerror=function(message,errno){_close(self),self._hadError=!0;var error=new Error(message);error.errno=errno,error.code=exports.codes[errno],self.emit(\"error\",error)};var level=exports.Z_DEFAULT_COMPRESSION;if(typeof opts.level===\"number\")level=opts.level;var strategy=exports.Z_DEFAULT_STRATEGY;if(typeof opts.strategy===\"number\")strategy=opts.strategy;this._handle.init(opts.windowBits||exports.Z_DEFAULT_WINDOWBITS,level,opts.memLevel||exports.Z_DEFAULT_MEMLEVEL,strategy,opts.dictionary),this._buffer=Buffer2.allocUnsafe(this._chunkSize),this._offset=0,this._level=level,this._strategy=strategy,this.once(\"end\",this.close),Object.defineProperty(this,\"_closed\",{get:function(){return!_this._handle},configurable:!0,enumerable:!0})}util.inherits(Zlib,Transform),Zlib.prototype.params=function(level,strategy,callback){if(levelexports.Z_MAX_LEVEL)@throwRangeError(\"Invalid compression level: \"+level);if(strategy!=exports.Z_FILTERED&&strategy!=exports.Z_HUFFMAN_ONLY&&strategy!=exports.Z_RLE&&strategy!=exports.Z_FIXED&&strategy!=exports.Z_DEFAULT_STRATEGY)@throwTypeError(\"Invalid strategy: \"+strategy);if(this._level!==level||this._strategy!==strategy){var self=this;this.flush(binding.Z_SYNC_FLUSH,function(){if(assert(self._handle,\"zlib binding closed\"),self._handle.params(level,strategy),!self._hadError){if(self._level=level,self._strategy=strategy,callback)callback()}})}else process.nextTick(callback)},Zlib.prototype.reset=function(){return assert(this._handle,\"zlib binding closed\"),this._handle.reset()},Zlib.prototype._flush=function(callback){this._transform(Buffer2.alloc(0),\"\",callback)},Zlib.prototype.flush=function(kind,callback){var _this2=this,ws=this._writableState;if(typeof kind===\"function\"||kind===void 0&&!callback)callback=kind,kind=binding.Z_FULL_FLUSH;if(ws.ended){if(callback)process.nextTick(callback)}else if(ws.ending){if(callback)this.once(\"end\",callback)}else if(ws.needDrain){if(callback)this.once(\"drain\",function(){return _this2.flush(kind,callback)})}else this._flushFlag=kind,this.write(Buffer2.alloc(0),\"\",callback)},Zlib.prototype.close=function(callback){_close(this,callback),process.nextTick(emitCloseNT,this)};function _close(engine,callback){if(callback)process.nextTick(callback);if(!engine._handle)return;engine._handle.close(),engine._handle=null}function emitCloseNT(self){self.emit(\"close\")}Zlib.prototype._transform=function(chunk,encoding,cb){var flushFlag,ws=this._writableState,ending=ws.ending||ws.ended,last=ending&&(!chunk||ws.length===chunk.length);if(chunk!==null&&!Buffer2.isBuffer(chunk))return cb(new Error(\"invalid input\"));if(!this._handle)return cb(new Error(\"zlib binding closed\"));if(last)flushFlag=this._finishFlushFlag;else if(flushFlag=this._flushFlag,chunk.length>=ws.length)this._flushFlag=this._opts.flush||binding.Z_NO_FLUSH;this._processChunk(chunk,flushFlag,cb)},Zlib.prototype._processChunk=function(chunk,flushFlag,cb){var availInBefore=chunk&&chunk.length,availOutBefore=this._chunkSize-this._offset,inOff=0,self=this,async=typeof cb===\"function\";if(!async){var buffers=[],nread=0,error;this.on(\"error\",function(er){error=er}),assert(this._handle,\"zlib binding closed\");do var res=this._handle.writeSync(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore);while(!this._hadError&&callback(res[0],res[1]));if(this._hadError)throw error;if(nread>=kMaxLength)_close(this),@throwRangeError(kRangeErrorMessage);var buf=Buffer2.concat(buffers,nread);return _close(this),buf}assert(this._handle,\"zlib binding closed\");var req=this._handle.write(flushFlag,chunk,inOff,availInBefore,this._buffer,this._offset,availOutBefore);req.buffer=chunk,req.callback=callback;function callback(availInAfter,availOutAfter){if(this)this.buffer=null,this.callback=null;if(self._hadError)return;var have=availOutBefore-availOutAfter;if(assert(have>=0,\"have should not go down\"),have>0){var out=self._buffer.slice(self._offset,self._offset+have);if(self._offset+=have,async)self.push(out);else buffers.push(out),nread+=out.length}if(availOutAfter===0||self._offset>=self._chunkSize)availOutBefore=self._chunkSize,self._offset=0,self._buffer=Buffer2.allocUnsafe(self._chunkSize);if(availOutAfter===0){if(inOff+=availInBefore-availInAfter,availInBefore=availInAfter,!async)return!0;var newReq=self._handle.write(flushFlag,chunk,inOff,availInBefore,self._buffer,self._offset,self._chunkSize);newReq.callback=callback,newReq.buffer=chunk;return}if(!async)return!1;cb()}},util.inherits(Deflate,Zlib),util.inherits(Inflate,Zlib),util.inherits(Gzip,Zlib),util.inherits(Gunzip,Zlib),util.inherits(DeflateRaw,Zlib),util.inherits(InflateRaw,Zlib),util.inherits(Unzip,Zlib)}});return require_lib()})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDepdCode = "(function (){\"use strict\";var $=function depd(namespace){if(!namespace)@throwTypeError(\"argument namespace is required\");function deprecate(message){}return deprecate._file=void 0,deprecate._ignored=!0,deprecate._namespace=namespace,deprecate._traced=!1,deprecate._warned=Object.create(null),deprecate.function=wrapfunction,deprecate.property=wrapproperty,deprecate};function wrapfunction(fn,message){if(typeof fn!==\"function\")@throwTypeError(\"argument fn must be a function\");return fn}function wrapproperty(obj,prop,message){if(!obj||typeof obj!==\"object\"&&typeof obj!==\"function\")@throwTypeError(\"argument obj must be object\");var descriptor=Object.getOwnPropertyDescriptor(obj,prop);if(!descriptor)@throwTypeError(\"must call property on owner object\");if(!descriptor.configurable)@throwTypeError(\"property must be configurable\")}return $})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDetectLibcCode = "(function (){\"use strict\";function family(){return Promise.resolve(familySync())}function familySync(){return null}const GLIBC=\"glibc\",MUSL=\"musl\";function versionAsync(){return Promise.resolve(version())}function version(){return null}function isNonGlibcLinuxSync(){return!1}function isNonGlibcLinux(){return Promise.resolve(isNonGlibcLinuxSync())}return{GLIBC,MUSL,family,familySync,isNonGlibcLinux,isNonGlibcLinuxSync,version,versionAsync}})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyDetectLibcLinuxCode = "(function (){\"use strict\";function family(){return Promise.resolve(familySync())}function familySync(){return GLIBC}const GLIBC=\"glibc\",MUSL=\"musl\";function versionAsync(){return Promise.resolve(version())}function version(){return\"2.29\"}function isNonGlibcLinuxSync(){return!1}function isNonGlibcLinux(){return Promise.resolve(isNonGlibcLinuxSync())}return{GLIBC,MUSL,family,familySync,isNonGlibcLinux,isNonGlibcLinuxSync,version,versionAsync}})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyIsomorphicFetchCode = "(function (){\"use strict\";return globalThis.fetch})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyNodeFetchCode = "(function (){\"use strict\";const{Headers,Request,Response,Blob,File=Blob,FormData}=globalThis,realFetch=Bun.fetch;function fetch(...args){return realFetch(...args)}class AbortError extends DOMException{constructor(message){super(message,\"AbortError\")}}class FetchBaseError extends Error{constructor(message,type){super(message);this.type=type}}class FetchError extends FetchBaseError{constructor(message,type,systemError){super(message,type);this.code=systemError\?.code}}function blobFrom(path,options){return Promise.resolve(Bun.file(data))}function blobFromSync(path,options){return Bun.file(data)}var fileFrom=blobFrom,fileFromSync=blobFromSync;function isRedirect(code){return code===301||code===302||code===303||code===307||code===308}return Object.assign(fetch,{AbortError,Blob,FetchBaseError,FetchError,File,FormData,Headers,Request,Response,blobFrom,blobFromSync,fileFrom,fileFromSync,isRedirect,fetch})})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyUndiciCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),{Readable}=StreamModule,{_ReadableFromWebForUndici:ReadableFromWeb}=StreamModule[Symbol.for(\"::bunternal::\")],ObjectCreate=Object.create,kEmptyObject=ObjectCreate(null);var fetch=Bun.fetch,Response=globalThis.Response,Headers=globalThis.Headers,Request=globalThis.Request,URLSearchParams=globalThis.URLSearchParams,URL=globalThis.URL;class File extends Blob{constructor(){super(...arguments)}}class FileReader extends EventTarget{constructor(){throw new Error(\"Not implemented yet!\")}}var FormData=globalThis.FormData;function notImplemented(){throw new Error(\"Not implemented in bun\")}class BodyReadable extends ReadableFromWeb{#response;#bodyUsed;constructor(response,options={}){var{body}=response;if(!body)throw new Error(\"Response body is null\");super(options,body);this.#response=response,this.#bodyUsed=response.bodyUsed}get bodyUsed(){return this.#bodyUsed}#consume(){if(this.#bodyUsed)@throwTypeError(\"unusable\");this.#bodyUsed=!0}async arrayBuffer(){return this.#consume(),await this.#response.arrayBuffer()}async blob(){return this.#consume(),await this.#response.blob()}async formData(){return this.#consume(),await this.#response.formData()}async json(){return this.#consume(),await this.#response.json()}async text(){return this.#consume(),await this.#response.text()}}async function request(url,options={method:\"GET\",signal:null,headers:null,query:null,reset:!1,throwOnError:!1,body:null}){let{method=\"GET\",headers:inputHeaders,query,signal,reset=!1,throwOnError=!1,body:inputBody,maxRedirections}=options;if(typeof url===\"string\"){if(query)url=new URL(url)}else if(typeof url===\"object\"&&url!==null){if(!(url instanceof URL))throw new Error(\"not implemented\")}else @throwTypeError(\"url must be a string, URL, or UrlObject\");if(typeof url===\"string\"&&query)url=new URL(url);if(typeof url===\"object\"&&url!==null&&query){if(query)url.search=new URLSearchParams(query).toString()}if(method=method&&typeof method===\"string\"\?method.toUpperCase():null,inputBody&&(method===\"GET\"||method===\"HEAD\"))throw new Error(\"Body not allowed for GET or HEAD requests\");if(inputBody&&inputBody.read&&inputBody instanceof Readable){let data=\"\";inputBody.setEncoding(\"utf8\");for await(let chunk of stream)data+=chunk;inputBody=(new TextEncoder()).encode(data)}if(maxRedirections!==void 0&&Number.isNaN(maxRedirections))throw new Error(\"maxRedirections must be a number if defined\");if(signal&&!(signal instanceof AbortSignal))throw new Error(\"signal must be an instance of AbortSignal\");let resp;const{status:statusCode,headers,trailers}=resp=await fetch(url,{signal,mode:\"cors\",method,headers:inputHeaders||kEmptyObject,body:inputBody,redirect:maxRedirections===\"undefined\"||maxRedirections>0\?\"follow\":\"manual\",keepalive:!reset});if(throwOnError&&statusCode>=400&&statusCode<600)throw new Error(`Request failed with status code ${statusCode}`);const body=resp.body\?new BodyReadable(resp):null;return{statusCode,headers:headers.toJSON(),body,trailers,opaque:kEmptyObject,context:kEmptyObject}}function stream(){throw new Error(\"Not implemented in bun\")}function pipeline(){throw new Error(\"Not implemented in bun\")}function connect(){throw new Error(\"Not implemented in bun\")}function upgrade(){throw new Error(\"Not implemented in bun\")}class MockClient{constructor(){throw new Error(\"Not implemented in bun\")}}class MockPool{constructor(){throw new Error(\"Not implemented in bun\")}}class MockAgent{constructor(){throw new Error(\"Not implemented in bun\")}}function mockErrors(){throw new Error(\"Not implemented in bun\")}function Undici(){throw new Error(\"Not implemented in bun\")}class Dispatcher extends EventEmitter{constructor(){super(...arguments)}}class Agent extends Dispatcher{constructor(){super(...arguments)}}class Pool extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}class BalancedPool extends Dispatcher{constructor(){super(...arguments)}}class Client extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}return Undici.Dispatcher=Dispatcher,Undici.Pool=Pool,Undici.BalancedPool=BalancedPool,Undici.Client=Client,Undici.Agent=Agent,Undici.buildConnector=Undici.errors=Undici.setGlobalDispatcher=Undici.getGlobalDispatcher=Undici.request=Undici.stream=Undici.pipeline=Undici.connect=Undici.upgrade=Undici.MockClient=Undici.MockPool=Undici.MockAgent=Undici.mockErrors=notImplemented,Undici.fetch=fetch,{fetch,Response,Headers,Request,URLSearchParams,URL,File,FileReader,FormData,request,stream,pipeline,connect,upgrade,MockClient,MockPool,MockAgent,mockErrors,Dispatcher,Pool,BalancedPool,Client,Agent,Undici}})\n"_s; +// + +// +static constexpr ASCIILiteral ThirdpartyUtf8ValidateCode = "(function (){\"use strict\";return @requireNativeModule(\"node:buffer\").isUtf8})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyVercelFetchCode = "(function (){\"use strict\";var $=(wrapper=Bun.fetch)=>{async function vercelFetch(url,opts={}){if(opts.body&&typeof opts.body===\"object\"&&(!(\"buffer\"in opts.body)||typeof opts.body.buffer!==\"object\"||!(opts.body.buffer instanceof ArrayBuffer))){if(opts.body=JSON.stringify(opts.body),!opts.headers)opts.headers=new Headers;opts.headers.set(\"Content-Type\",\"application/json\")}try{return await wrapper(url,opts)}catch(err){if(typeof err===\"string\")err=new Error(err);throw err.url=url,err.opts=opts,err}}return vercelFetch.default=vercelFetch,vercelFetch};return $})\n"_s; +// + +// static constexpr ASCIILiteral ThirdpartyWSCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),http=@getInternalField(@internalModuleRegistry,18)||@createInternalModuleById(18),kBunInternals=Symbol.for(\"::bunternal::\"),readyStates=[\"CONNECTING\",\"OPEN\",\"CLOSING\",\"CLOSED\"],encoder=new TextEncoder,eventIds={open:1,close:2,message:3,error:4,ping:5,pong:6},emittedWarnings=new Set;function emitWarning(type,message){if(emittedWarnings.has(type))return;emittedWarnings.add(type),console.warn(\"[bun] Warning:\",message)}class BunWebSocket extends EventEmitter{static CONNECTING=0;static OPEN=1;static CLOSING=2;static CLOSED=3;#ws;#paused=!1;#fragments=!1;#binaryType=\"nodebuffer\";#eventId=0;constructor(url,protocols,options){super();let ws=this.#ws=new WebSocket(url,protocols);ws.binaryType=\"nodebuffer\"}on(event,listener){if(event===\"unexpected-response\"||event===\"upgrade\"||event===\"redirect\")emitWarning(event,\"ws.WebSocket '\"+event+\"' event is not implemented in bun\");const mask=1<{this.emit(\"open\")});else if(event===\"close\")this.#ws.addEventListener(\"close\",({code,reason,wasClean})=>{this.emit(\"close\",code,reason,wasClean)});else if(event===\"message\")this.#ws.addEventListener(\"message\",({data})=>{const isBinary=typeof data!==\"string\";if(isBinary)this.emit(\"message\",this.#fragments\?[data]:data,isBinary);else{let encoded=encoder.encode(data);if(this.#binaryType!==\"arraybuffer\")encoded=Buffer.from(encoded.buffer,encoded.byteOffset,encoded.byteLength);this.emit(\"message\",this.#fragments\?[encoded]:encoded,isBinary)}});else if(event===\"error\")this.#ws.addEventListener(\"error\",(err)=>{this.emit(\"error\",err)});else if(event===\"ping\")this.#ws.addEventListener(\"ping\",({data})=>{this.emit(\"ping\",data)});else if(event===\"pong\")this.#ws.addEventListener(\"pong\",({data})=>{this.emit(\"pong\",data)})}return super.on(event,listener)}send(data,opts,cb){try{this.#ws.send(data,opts\?.compress)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}close(code,reason){this.#ws.close(code,reason)}terminate(){this.#ws.terminate()}get url(){return this.#ws.url}get readyState(){return this.#ws.readyState}get binaryType(){return this.#binaryType}set binaryType(value){if(value===\"nodebuffer\"||value===\"arraybuffer\")this.#ws.binaryType=this.#binaryType=value,this.#fragments=!1;else if(value===\"fragments\")this.#ws.binaryType=\"nodebuffer\",this.#binaryType=\"fragments\",this.#fragments=!0;else throw new Error(`Invalid binaryType: ${value}`)}get protocol(){return this.#ws.protocol}get extensions(){return this.#ws.extensions}addEventListener(type,listener,options){this.#ws.addEventListener(type,listener,options)}removeEventListener(type,listener){this.#ws.removeEventListener(type,listener)}get onopen(){return this.#ws.onopen}set onopen(value){this.#ws.onopen=value}get onerror(){return this.#ws.onerror}set onerror(value){this.#ws.onerror=value}get onclose(){return this.#ws.onclose}set onclose(value){this.#ws.onclose=value}get onmessage(){return this.#ws.onmessage}set onmessage(value){this.#ws.onmessage=value}get bufferedAmount(){return this.#ws.bufferedAmount}get isPaused(){return this.#paused}ping(data,mask,cb){if(typeof data===\"function\")cb=data,data=mask=void 0;else if(typeof mask===\"function\")cb=mask,mask=void 0;if(typeof data===\"number\")data=data.toString();try{this.#ws.ping(data)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}pong(data,mask,cb){if(typeof data===\"function\")cb=data,data=mask=void 0;else if(typeof mask===\"function\")cb=mask,mask=void 0;if(typeof data===\"number\")data=data.toString();try{this.#ws.pong(data)}catch(error){typeof cb===\"function\"&&cb(error);return}typeof cb===\"function\"&&cb()}pause(){switch(this.readyState){case WebSocket.CONNECTING:case WebSocket.CLOSED:return}this.#paused=!0,emitWarning(\"pause()\",\"ws.WebSocket.pause() is not implemented in bun\")}resume(){switch(this.readyState){case WebSocket.CONNECTING:case WebSocket.CLOSED:return}this.#paused=!1,emitWarning(\"resume()\",\"ws.WebSocket.resume() is not implemented in bun\")}}Object.defineProperty(BunWebSocket,\"name\",{value:\"WebSocket\"});const wsKeyRegex=/^[+/0-9A-Za-z]{22}==$/,wsTokenChars=[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,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function subprotocolParse(header){const protocols=new Set;let start=-1,end=-1,i=0;for(i;i{const body=http.STATUS_CODES[426];res.writeHead(426,{\"Content-Length\":body.length,\"Content-Type\":\"text/plain\"}),res.end(body)}),this._server.listen(options.port,options.host,options.backlog,callback);else if(options.server)this._server=options.server;if(this._server){const emitConnection=this.emit.bind(this,\"connection\"),emitListening=this.emit.bind(this,\"listening\"),emitError=this.emit.bind(this,\"error\"),doUpgrade=(req,socket,head)=>{this.handleUpgrade(req,socket,head,emitConnection)};this._server.on(\"listening\",emitListening),this._server.on(\"error\",emitError),this._server.on(\"upgrade\",doUpgrade),this._removeListeners=()=>{this._server.removeListener(\"upgrade\",doUpgrade),this._server.removeListener(\"listening\",emitListening),this._server.removeListener(\"error\",emitError)}}if(options.perMessageDeflate===!0)options.perMessageDeflate={};if(options.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=options,this._state=RUNNING}address(){if(this.options.noServer)throw new Error('The server is operating in \"noServer\" mode');if(!this._server)return null;return this._server.address()}close(cb){if(this._state===CLOSED){if(cb)this.once(\"close\",()=>{cb(new Error(\"The server is not running\"))});process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this);return}if(cb)this.once(\"close\",cb);if(this._state===CLOSING)return;if(this._state=CLOSING,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this);else this._shouldEmitClose=!0;else process.nextTick((server)=>{server._state=CLOSED,server.emit(\"close\")},this)}else{const server=this._server;this._removeListeners(),this._removeListeners=this._server=null,server.close(()=>{this._state=CLOSED,this.emit(\"close\")})}}shouldHandle(req){if(this.options.path){const index=req.url.indexOf(\"\?\");if((index!==-1\?req.url.slice(0,index):req.url)!==this.options.path)return!1}return!0}completeUpgrade(extensions,key,protocols,request,socket,head,cb){const[server,response,req]=socket[kBunInternals];if(this._state>RUNNING)return abortHandshake(response,503);let protocol=\"\";if(protocols.size)protocol=this.options.handleProtocols\?this.options.handleProtocols(protocols,request):protocols.values().next().value;const ws=new BunWebSocketMocked(request.url,protocol,extensions,\"nodebuffer\"),headers=[\"HTTP/1.1 101 Switching Protocols\",\"Upgrade: websocket\",\"Connection: Upgrade\"];if(this.emit(\"headers\",headers,request),server.upgrade(req,{data:ws[kBunInternals]})){if(response._reply(void 0),this.clients)this.clients.add(ws),ws.on(\"close\",()=>{if(this.clients.delete(ws),this._shouldEmitClose&&!this.clients.size)process.nextTick(wsEmitClose,this)});cb(ws,request)}else abortHandshake(response,500)}handleUpgrade(req,socket,head,cb){const[_,response]=socket[kBunInternals],key=req.headers[\"sec-websocket-key\"],version=+req.headers[\"sec-websocket-version\"];if(req.method!==\"GET\"){abortHandshakeOrEmitwsClientError(this,req,response,socket,405,\"Invalid HTTP method\");return}if(req.headers.upgrade.toLowerCase()!==\"websocket\"){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Invalid Upgrade header\");return}if(!key||!wsKeyRegex.test(key)){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Missing or invalid Sec-WebSocket-Key header\");return}if(version!==8&&version!==13){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Missing or invalid Sec-WebSocket-Version header\");return}if(!this.shouldHandle(req)){abortHandshake(response,400);return}const secWebSocketProtocol=req.headers[\"sec-websocket-protocol\"];let protocols=new Set;if(secWebSocketProtocol!==void 0)try{protocols=subprotocolParse(secWebSocketProtocol)}catch(err){abortHandshakeOrEmitwsClientError(this,req,response,socket,400,\"Invalid Sec-WebSocket-Protocol header\");return}const extensions={};if(this.options.verifyClient){const info={origin:req.headers[`${version===8\?\"sec-websocket-origin\":\"origin\"}`],secure:!!(req.socket.authorized||req.socket.encrypted),req};if(this.options.verifyClient.length===2){this.options.verifyClient(info,(verified,code,message,headers)=>{if(!verified)return abortHandshake(response,code||401,message,headers);this.completeUpgrade(extensions,key,protocols,req,socket,head,cb)});return}if(!this.options.verifyClient(info))return abortHandshake(response,401)}this.completeUpgrade(extensions,key,protocols,req,socket,head,cb)}}Object.defineProperty(BunWebSocket,\"CONNECTING\",{enumerable:!0,value:readyStates.indexOf(\"CONNECTING\")}),Object.defineProperty(BunWebSocket.prototype,\"CONNECTING\",{enumerable:!0,value:readyStates.indexOf(\"CONNECTING\")}),Object.defineProperty(BunWebSocket,\"OPEN\",{enumerable:!0,value:readyStates.indexOf(\"OPEN\")}),Object.defineProperty(BunWebSocket.prototype,\"OPEN\",{enumerable:!0,value:readyStates.indexOf(\"OPEN\")}),Object.defineProperty(BunWebSocket,\"CLOSING\",{enumerable:!0,value:readyStates.indexOf(\"CLOSING\")}),Object.defineProperty(BunWebSocket.prototype,\"CLOSING\",{enumerable:!0,value:readyStates.indexOf(\"CLOSING\")}),Object.defineProperty(BunWebSocket,\"CLOSED\",{enumerable:!0,value:readyStates.indexOf(\"CLOSED\")}),Object.defineProperty(BunWebSocket.prototype,\"CLOSED\",{enumerable:!0,value:readyStates.indexOf(\"CLOSED\")});class Sender{constructor(){throw new Error(\"Not supported yet in Bun\")}}class Receiver{constructor(){throw new Error(\"Not supported yet in Bun\")}}var createWebSocketStream=(ws)=>{throw new Error(\"Not supported yet in Bun\")};return Object.assign(BunWebSocket,{createWebSocketStream,Receiver,Sender,WebSocket:BunWebSocket,Server:WebSocketServer,WebSocketServer})})\n"_s; +// + #endif } diff --git a/src/js/out/ResolvedSourceTag.zig b/src/js/out/ResolvedSourceTag.zig index 6627f35a24a646..cfbb31e0a1861b 100644 --- a/src/js/out/ResolvedSourceTag.zig +++ b/src/js/out/ResolvedSourceTag.zig @@ -63,8 +63,9 @@ pub const ResolvedSourceTag = enum(u32) { @"isomorphic-fetch" = 563, @"node-fetch" = 564, @"undici" = 565, - @"vercel_fetch" = 566, - @"ws" = 567, + @"utf-8-validate" = 566, + @"vercel_fetch" = 567, + @"ws" = 568, // Native modules run through a different system using ESM registry. @"bun:jsc" = 1024, @"node:buffer" = 1025, diff --git a/src/js/out/SyntheticModuleType.h b/src/js/out/SyntheticModuleType.h index 43dc45f7b4cff1..08488dec3fe77d 100644 --- a/src/js/out/SyntheticModuleType.h +++ b/src/js/out/SyntheticModuleType.h @@ -63,8 +63,9 @@ enum SyntheticModuleType : uint32_t { ThirdpartyIsomorphicFetch = 563, ThirdpartyNodeFetch = 564, ThirdpartyUndici = 565, - ThirdpartyVercelFetch = 566, - ThirdpartyWS = 567, + ThirdpartyUtf8Validate = 566, + ThirdpartyVercelFetch = 567, + ThirdpartyWS = 568, // Native modules run through the same system, but with different underlying initializers. // They also have bit 10 set to differentiate them from JS builtins. diff --git a/src/js/thirdparty/utf-8-validate.ts b/src/js/thirdparty/utf-8-validate.ts index fdb974d5902763..fcab46ff1736d8 100644 --- a/src/js/thirdparty/utf-8-validate.ts +++ b/src/js/thirdparty/utf-8-validate.ts @@ -1,4 +1,2 @@ -import { isUtf8 } from "node:buffer"; - // https://github.com/websockets/utf-8-validate#api -export default isUtf8; +export default require('node:buffer').isUtf8; From d3025656c46a77f67740befdd05719ba0e71edf1 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 2 Aug 2023 21:55:47 -0700 Subject: [PATCH 07/22] Fix missing tests --- test/js/node/buffer.test.js | 5068 +++++++++++++++++------------------ 1 file changed, 2533 insertions(+), 2535 deletions(-) diff --git a/test/js/node/buffer.test.js b/test/js/node/buffer.test.js index e7b59113e2466c..863f3129ce0797 100644 --- a/test/js/node/buffer.test.js +++ b/test/js/node/buffer.test.js @@ -1,2540 +1,2538 @@ -// import { Buffer, SlowBuffer, isAscii, isUtf8 } from "buffer"; +import { Buffer, SlowBuffer, isAscii, isUtf8 } from "buffer"; import { describe, it, expect, beforeEach, afterEach } from "bun:test"; import { gc } from "harness"; -// console.log("0"); -// const BufferModule = await import("buffer"); -console.log("1"); -// beforeEach(() => gc()); -// afterEach(() => gc()); +const BufferModule = await import("buffer"); +beforeEach(() => gc()); +afterEach(() => gc()); it("isAscii", () => { - // expect(isAscii(new Buffer("abc"))).toBeTrue(); - // expect(isAscii(new Buffer(""))).toBeTrue(); - // expect(isAscii(new Buffer([32, 32, 128]))).toBeFalse(); - // expect(isAscii(new Buffer("What did the 🦊 say?"))).toBeFalse(); - // expect(isAscii(new Buffer("").buffer)).toBeTrue(); - // expect(isAscii(new Buffer([32, 32, 128]).buffer)).toBeFalse(); -}); - -// it("isUtf8", () => { -// expect(isUtf8(new Buffer("abc"))).toBeTrue(); -// expect(isAscii(new Buffer(""))).toBeTrue(); -// expect(isUtf8(new Buffer("What did the 🦊 say?"))).toBeTrue(); -// expect(isUtf8(new Buffer([129, 129, 129]))).toBeFalse(); - -// expect(isUtf8(new Buffer("abc").buffer)).toBeTrue(); -// expect(isAscii(new Buffer("").buffer)).toBeTrue(); -// expect(isUtf8(new Buffer("What did the 🦊 say?").buffer)).toBeTrue(); -// expect(isUtf8(new Buffer([129, 129, 129]).buffer)).toBeFalse(); -// }); - -// // https://github.com/oven-sh/bun/issues/2052 -// it("Buffer global is settable", () => { -// var prevBuffer = globalThis.Buffer; -// globalThis.Buffer = 42; -// expect(globalThis.Buffer).toBe(42); -// globalThis.Buffer = prevBuffer; -// expect(globalThis.Buffer).toBe(BufferModule.Buffer); -// expect(globalThis.Buffer).toBe(prevBuffer); -// }); - -// it("length overflow", () => { -// // Verify the maximum Uint8Array size. There is no concrete limit by spec. The -// // internal limits should be updated if this fails. -// expect(() => new Uint8Array(2 ** 32 + 1)).toThrow(/length/); -// }); - -// it("truncate input values", () => { -// const b = Buffer.allocUnsafe(1024); -// expect(b.length).toBe(1024); - -// b[0] = -1; -// expect(b[0]).toBe(255); - -// for (let i = 0; i < 1024; i++) { -// b[i] = i; -// } - -// for (let i = 0; i < 1024; i++) { -// expect(i % 256).toBe(b[i]); -// } -// }); - -// it("Buffer.allocUnsafe()", () => { -// const c = Buffer.allocUnsafe(512); -// expect(c.length).toBe(512); -// }); - -// it("Buffer.from()", () => { -// const d = Buffer.from([]); -// expect(d.length).toBe(0); -// }); - -// it("offset properties", () => { -// const b = Buffer.alloc(128); -// expect(b.length).toBe(128); -// expect(b.byteOffset).toBe(0); -// expect(b.offset).toBe(0); -// }); - -// it("creating a Buffer from a Uint32Array", () => { -// const ui32 = new Uint32Array(4).fill(42); -// const e = Buffer.from(ui32); -// for (const [index, value] of e.entries()) { -// expect(value).toBe(ui32[index]); -// } -// }); - -// it("creating a Buffer from a Uint32Array (old constructor)", () => { -// const ui32 = new Uint32Array(4).fill(42); -// const e = Buffer(ui32); -// for (const [key, value] of e.entries()) { -// expect(value).toBe(ui32[key]); -// } -// }); - -// it("invalid encoding", () => { -// const b = Buffer.allocUnsafe(64); -// // Test invalid encoding for Buffer.toString -// expect(() => b.toString("invalid")).toThrow(/encoding/); -// // Invalid encoding for Buffer.write -// expect(() => b.write("test string", 0, 5, "invalid")).toThrow(/encoding/); -// // Unsupported arguments for Buffer.write -// expect(() => b.write("test", "utf8", 0)).toThrow(/invalid/i); -// }); - -// it("create 0-length buffers", () => { -// Buffer.from(""); -// Buffer.from("", "ascii"); -// Buffer.from("", "latin1"); -// Buffer.alloc(0); -// Buffer.allocUnsafe(0); -// new Buffer(""); -// new Buffer("", "ascii"); -// new Buffer("", "latin1"); -// new Buffer("", "binary"); -// Buffer(0); -// }); - -// it("write() beyond end of buffer", () => { -// const b = Buffer.allocUnsafe(64); -// // Try to write a 0-length string beyond the end of b -// expect(() => b.write("", 2048)).toThrow(RangeError); -// // Throw when writing to negative offset -// expect(() => b.write("a", -1)).toThrow(RangeError); -// // Throw when writing past bounds from the pool -// expect(() => b.write("a", 2048)).toThrow(RangeError); -// // Throw when writing to negative offset -// expect(() => b.write("a", -1)).toThrow(RangeError); -// // Offset points to the end of the buffer and does not throw. -// // (see https://github.com/nodejs/node/issues/8127). -// Buffer.alloc(1).write("", 1, 0); -// }); - -// it("copy() beyond end of buffer", () => { -// const b = Buffer.allocUnsafe(64); -// // Try to copy 0 bytes worth of data into an empty buffer -// b.copy(Buffer.alloc(0), 0, 0, 0); -// // Try to copy 0 bytes past the end of the target buffer -// b.copy(Buffer.alloc(0), 1, 1, 1); -// b.copy(Buffer.alloc(1), 1, 1, 1); -// // Try to copy 0 bytes from past the end of the source buffer -// b.copy(Buffer.alloc(1), 0, 2048, 2048); -// }); - -// it("smart defaults and ability to pass string values as offset", () => { -// const writeTest = Buffer.from("abcdes"); -// writeTest.write("n", "ascii"); -// expect(() => writeTest.write("o", "1", "ascii")).toThrow(/offset/); -// writeTest.write("o", 1, "ascii"); -// writeTest.write("d", 2, "ascii"); -// writeTest.write("e", 3, "ascii"); -// writeTest.write("j", 4, "ascii"); -// expect(writeTest.toString()).toBe("nodejs"); -// }); - -// it("ASCII slice", () => { -// const buf = Buffer.allocUnsafe(256); -// const str = "hello world"; -// for (let i = 0; i < str.length; i++) { -// buf[i] = str.charCodeAt(i); -// } -// expect(buf.toString("ascii", 0, str.length)).toBe(str); - -// const offset = 100; -// expect(buf.write(str, offset, "ascii")).toBe(str.length); -// expect(buf.toString("ascii", offset, offset + str.length)).toBe(str); - -// const slice1 = buf.slice(offset, offset + str.length); -// const slice2 = buf.slice(offset, offset + str.length); -// for (let i = 0; i < str.length; i++) { -// expect(slice1[i]).toBe(slice2[i]); -// } -// }); - -// it("UTF-8 slice", () => { -// const b = Buffer.allocUnsafe(256); -// const utf8String = "¡hέlló wôrld!"; -// const offset = 100; - -// b.write(utf8String, 0, Buffer.byteLength(utf8String), "utf8"); -// expect(b.toString("utf8", 0, Buffer.byteLength(utf8String))).toBe(utf8String); - -// expect(b.write(utf8String, offset, "utf8")).toBe(Buffer.byteLength(utf8String)); -// expect(b.toString("utf8", offset, offset + Buffer.byteLength(utf8String))).toBe(utf8String); - -// const sliceA = b.slice(offset, offset + Buffer.byteLength(utf8String)); -// const sliceB = b.slice(offset, offset + Buffer.byteLength(utf8String)); -// for (let i = 0; i < Buffer.byteLength(utf8String); i++) { -// expect(sliceA[i]).toBe(sliceB[i]); -// } - -// const slice = b.slice(100, 150); -// expect(slice.length).toBe(50); -// for (let i = 0; i < 50; i++) { -// expect(b[100 + i]).toBe(slice[i]); -// } -// }); - -// it("only top level parent propagates from allocPool", () => { -// const b = Buffer.allocUnsafe(5); -// const c = b.slice(0, 4); -// const d = c.slice(0, 2); -// expect(b.parent).toBe(c.parent); -// expect(b.parent).toBe(d.parent); -// }); - -// it("only top level parent propagates from a non-pooled instance", () => { -// const b = Buffer.allocUnsafeSlow(5); -// const c = b.slice(0, 4); -// const d = c.slice(0, 2); -// expect(c.parent).toBe(d.parent); -// }); - -// it("UTF-8 write() & slice()", () => { -// const testValue = "\u00F6\u65E5\u672C\u8A9E"; // ö日本語 -// const buffer = Buffer.allocUnsafe(32); -// const size = buffer.write(testValue, 0, "utf8"); -// const slice = buffer.toString("utf8", 0, size); -// expect(slice).toBe(testValue); -// }); - -// it("triple slice", () => { -// const a = Buffer.allocUnsafe(8); -// for (let i = 0; i < 8; i++) a[i] = i; -// const b = a.slice(4, 8); -// expect(b[0]).toBe(4); -// expect(b[1]).toBe(5); -// expect(b[2]).toBe(6); -// expect(b[3]).toBe(7); -// const c = b.slice(2, 4); -// expect(c[0]).toBe(6); -// expect(c[1]).toBe(7); -// }); - -// it("Buffer.from() with encoding", () => { -// const b = Buffer.from([23, 42, 255]); -// expect(b.length).toBe(3); -// expect(b[0]).toBe(23); -// expect(b[1]).toBe(42); -// expect(b[2]).toBe(255); -// expect(Buffer.from(b)).toStrictEqual(b); - -// // Test for proper UTF-8 Encoding -// expect(Buffer.from("über")).toStrictEqual(Buffer.from([195, 188, 98, 101, 114])); - -// // Test for proper ascii Encoding, length should be 4 -// expect(Buffer.from("über", "ascii")).toStrictEqual(Buffer.from([252, 98, 101, 114])); - -// ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => { -// // Test for proper UTF16LE encoding, length should be 8 -// expect(Buffer.from("über", encoding)).toStrictEqual(Buffer.from([252, 0, 98, 0, 101, 0, 114, 0])); - -// // Length should be 12 -// const b = Buffer.from("привет", encoding); -// expect(b).toStrictEqual(Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])); -// expect(b.toString(encoding)).toBe("привет"); - -// const c = Buffer.from([0, 0, 0, 0, 0]); -// expect(c.length).toBe(5); -// expect(c.write("あいうえお", encoding)).toBe(4); -// expect(c).toStrictEqual(Buffer.from([0x42, 0x30, 0x44, 0x30, 0x00])); -// }); - -// const c = Buffer.from("\uD83D\uDC4D", "utf-16le"); // THUMBS UP SIGN (U+1F44D) -// expect(c.length).toBe(4); -// expect(c).toStrictEqual(Buffer.from("3DD84DDC", "hex")); -// }); - -// it("construction from arrayish object", () => { -// const arrayIsh = { 0: 0, 1: 1, 2: 2, 3: 3, length: 4 }; -// expect(Buffer.from(arrayIsh)).toStrictEqual(Buffer.from([0, 1, 2, 3])); -// const strArrayIsh = { 0: "0", 1: "1", 2: "2", 3: "3", length: 4 }; -// expect(Buffer.from(strArrayIsh)).toStrictEqual(Buffer.from([0, 1, 2, 3])); -// }); - -// it("toString('base64')", () => { -// expect(Buffer.from("Man").toString("base64")).toBe("TWFu"); -// expect(Buffer.from("Woman").toString("base64")).toBe("V29tYW4="); -// }); - -// it("toString('base64url')", () => { -// expect(Buffer.from("Man").toString("base64url")).toBe("TWFu"); -// expect(Buffer.from("Woman").toString("base64url")).toBe("V29tYW4"); -// }); - -// it("regular and URL-safe base64 work both ways", () => { -// const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]; -// expect(Buffer.from("//++/++/++//", "base64")).toStrictEqual(Buffer.from(expected)); -// expect(Buffer.from("__--_--_--__", "base64")).toStrictEqual(Buffer.from(expected)); -// expect(Buffer.from("//++/++/++//", "base64url")).toStrictEqual(Buffer.from(expected)); -// expect(Buffer.from("__--_--_--__", "base64url")).toStrictEqual(Buffer.from(expected)); -// }); - -// it("regular and URL-safe base64 work both ways with padding", () => { -// const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff, 0xfb]; -// expect(Buffer.from("//++/++/++//+w==", "base64")).toStrictEqual(Buffer.from(expected)); -// expect(Buffer.from("//++/++/++//+w==", "base64")).toStrictEqual(Buffer.from(expected)); -// expect(Buffer.from("//++/++/++//+w==", "base64url")).toStrictEqual(Buffer.from(expected)); -// expect(Buffer.from("//++/++/++//+w==", "base64url")).toStrictEqual(Buffer.from(expected)); -// }); - -// it("big example (base64 & base64url)", () => { -// const quote = -// "Man is distinguished, not only by his reason, but by this " + -// "singular passion from other animals, which is a lust " + -// "of the mind, that by a perseverance of delight in the " + -// "continued and indefatigable generation of knowledge, " + -// "exceeds the short vehemence of any carnal pleasure."; -// const expected = -// "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb" + -// "24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci" + -// "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQ" + -// "gYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu" + -// "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ" + -// "GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm" + -// "5hbCBwbGVhc3VyZS4="; - -// expect(Buffer.from(quote).toString("base64")).toBe(expected); -// expect(Buffer.from(quote).toString("base64url")).toBe( -// expected.replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", ""), -// ); -// }); - -// function forEachBase64(label, test) { -// ["base64", "base64url"].forEach(encoding => it(`${label} (${encoding})`, test.bind(null, encoding))); -// } - -// forEachBase64("big example", encoding => { -// const quote = -// "Man is distinguished, not only by his reason, but by this " + -// "singular passion from other animals, which is a lust " + -// "of the mind, that by a perseverance of delight in the " + -// "continued and indefatigable generation of knowledge, " + -// "exceeds the short vehemence of any carnal pleasure."; -// const expected = -// "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb" + -// "24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci" + -// "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQ" + -// "gYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu" + -// "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ" + -// "GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm" + -// "5hbCBwbGVhc3VyZS4="; - -// const b = Buffer.allocUnsafe(1024); -// expect(b.write(expected, 0, encoding)).toBe(quote.length); -// expect(b.toString("ascii", 0, quote.length)).toBe(quote); - -// // Check that the base64 decoder ignores whitespace -// const white = -// `${expected.slice(0, 60)} \n` + -// `${expected.slice(60, 120)} \n` + -// `${expected.slice(120, 180)} \n` + -// `${expected.slice(180, 240)} \n` + -// `${expected.slice(240, 300)}\n` + -// `${expected.slice(300, 360)}\n`; -// const c = Buffer.allocUnsafe(1024); -// expect(c.write(white, 0, encoding)).toBe(quote.length); -// expect(c.toString("ascii", 0, quote.length)).toBe(quote); - -// // Check that the base64 decoder on the constructor works -// // even in the presence of whitespace. -// const d = Buffer.from(white, encoding); -// expect(d.length).toBe(quote.length); -// expect(d.toString("ascii", 0, quote.length)).toBe(quote); - -// // Check that the base64 decoder ignores illegal chars -// const illegal = -// expected.slice(0, 60) + -// " \x80" + -// expected.slice(60, 120) + -// " \xff" + -// expected.slice(120, 180) + -// " \x00" + -// expected.slice(180, 240) + -// " \x98" + -// expected.slice(240, 300) + -// "\x03" + -// expected.slice(300, 360); -// const e = Buffer.from(illegal, encoding); -// expect(e.length).toBe(quote.length); -// expect(e.toString("ascii", 0, quote.length)).toBe(quote); -// }); - -// forEachBase64("padding", encoding => { -// expect(Buffer.from("", encoding).toString()).toBe(""); -// expect(Buffer.from("K", encoding).toString()).toBe(""); -// // multiple-of-4 with padding -// expect(Buffer.from("Kg==", encoding).toString()).toBe("*"); -// expect(Buffer.from("Kio=", encoding).toString()).toBe("*".repeat(2)); -// expect(Buffer.from("Kioq", encoding).toString()).toBe("*".repeat(3)); -// expect(Buffer.from("KioqKg==", encoding).toString()).toBe("*".repeat(4)); -// expect(Buffer.from("KioqKio=", encoding).toString()).toBe("*".repeat(5)); -// expect(Buffer.from("KioqKioq", encoding).toString()).toBe("*".repeat(6)); -// expect(Buffer.from("KioqKioqKg==", encoding).toString()).toBe("*".repeat(7)); -// expect(Buffer.from("KioqKioqKio=", encoding).toString()).toBe("*".repeat(8)); -// expect(Buffer.from("KioqKioqKioq", encoding).toString()).toBe("*".repeat(9)); -// expect(Buffer.from("KioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(10)); -// expect(Buffer.from("KioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(11)); -// expect(Buffer.from("KioqKioqKioqKioq", encoding).toString()).toBe("*".repeat(12)); -// expect(Buffer.from("KioqKioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(13)); -// expect(Buffer.from("KioqKioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(14)); -// expect(Buffer.from("KioqKioqKioqKioqKioq", encoding).toString()).toBe("*".repeat(15)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(16)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(17)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKioq", encoding).toString()).toBe("*".repeat(18)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(19)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(20)); -// // No padding, not a multiple of 4 -// expect(Buffer.from("Kg", encoding).toString()).toBe("*"); -// expect(Buffer.from("Kio", encoding).toString()).toBe("*".repeat(2)); -// expect(Buffer.from("KioqKg", encoding).toString()).toBe("*".repeat(4)); -// expect(Buffer.from("KioqKio", encoding).toString()).toBe("*".repeat(5)); -// expect(Buffer.from("KioqKioqKg", encoding).toString()).toBe("*".repeat(7)); -// expect(Buffer.from("KioqKioqKio", encoding).toString()).toBe("*".repeat(8)); -// expect(Buffer.from("KioqKioqKioqKg", encoding).toString()).toBe("*".repeat(10)); -// expect(Buffer.from("KioqKioqKioqKio", encoding).toString()).toBe("*".repeat(11)); -// expect(Buffer.from("KioqKioqKioqKioqKg", encoding).toString()).toBe("*".repeat(13)); -// expect(Buffer.from("KioqKioqKioqKioqKio", encoding).toString()).toBe("*".repeat(14)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKg", encoding).toString()).toBe("*".repeat(16)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKio", encoding).toString()).toBe("*".repeat(17)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKioqKg", encoding).toString()).toBe("*".repeat(19)); -// expect(Buffer.from("KioqKioqKioqKioqKioqKioqKio", encoding).toString()).toBe("*".repeat(20)); -// // Handle padding graciously, multiple-of-4 or not -// expect(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==", encoding).length).toBe(32); -// expect(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw==", encoding).length).toBe(32); -// expect(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=", encoding).length).toBe(32); -// expect(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw=", encoding).length).toBe(32); -// expect(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw", encoding).length).toBe(32); -// expect(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw", encoding).length).toBe(32); -// expect(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==", encoding).length).toBe(31); -// expect(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=", encoding).length).toBe(31); -// expect(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg", encoding).length).toBe(31); -// }); - -// it("encodes single '.' character in UTF-16", () => { -// const padded = Buffer.from("//4uAA==", "base64"); -// expect(padded[0]).toBe(0xff); -// expect(padded[1]).toBe(0xfe); -// expect(padded[2]).toBe(0x2e); -// expect(padded[3]).toBe(0x00); -// expect(padded.toString("base64")).toBe("//4uAA=="); - -// const dot = Buffer.from("//4uAA", "base64url"); -// expect(dot[0]).toBe(0xff); -// expect(dot[1]).toBe(0xfe); -// expect(dot[2]).toBe(0x2e); -// expect(dot[3]).toBe(0x00); -// expect(dot.toString("base64url")).toBe("__4uAA"); -// }); - -// // https://github.com/joyent/node/issues/402 -// it("writing base64 at a position > 0 should not mangle the result", () => { -// const segments = ["TWFkbmVzcz8h", "IFRoaXM=", "IGlz", "IG5vZGUuanMh"]; -// const b = Buffer.allocUnsafe(64); -// let pos = 0; - -// for (let i = 0; i < segments.length; ++i) { -// pos += b.write(segments[i], pos, "base64"); -// } -// expect(b.toString("latin1", 0, pos)).toBe("Madness?! This is node.js!"); -// }); - -// // https://github.com/joyent/node/issues/402 -// it("writing base64url at a position > 0 should not mangle the result", () => { -// const segments = ["TWFkbmVzcz8h", "IFRoaXM", "IGlz", "IG5vZGUuanMh"]; -// const b = Buffer.allocUnsafe(64); -// let pos = 0; - -// for (let i = 0; i < segments.length; ++i) { -// pos += b.write(segments[i], pos, "base64url"); -// } -// expect(b.toString("latin1", 0, pos)).toBe("Madness?! This is node.js!"); -// }); - -// it("regression tests from Node.js", () => { -// // Regression test for https://github.com/nodejs/node/issues/3496. -// expect(Buffer.from("=bad".repeat(1e4), "base64").length).toBe(0); -// // Regression test for https://github.com/nodejs/node/issues/11987. -// expect(Buffer.from("w0 ", "base64")).toStrictEqual(Buffer.from("w0", "base64")); -// // Regression test for https://github.com/nodejs/node/issues/13657. -// expect(Buffer.from(" YWJvcnVtLg", "base64")).toStrictEqual(Buffer.from("YWJvcnVtLg", "base64")); -// // issue GH-3416 -// Buffer.from(Buffer.allocUnsafe(0), 0, 0); -// // Regression test for https://github.com/nodejs/node-v0.x-archive/issues/5482: -// // should throw but not assert in C++ land. -// expect(() => Buffer.from("", "buffer")).toThrow(/encoding/); -// }); - -// it("creating buffers larger than pool size", () => { -// const l = Buffer.poolSize + 5; -// const s = "h".repeat(l); -// const b = Buffer.from(s); - -// for (let i = 0; i < l; i++) { -// expect(b[i]).toBe("h".charCodeAt(0)); -// } - -// const sb = b.toString(); -// expect(sb.length).toBe(s.length); -// expect(sb).toBe(s); -// }); - -// it("hex toString()", () => { -// const hexb = Buffer.allocUnsafe(256); -// for (let i = 0; i < 256; i++) { -// hexb[i] = i; -// } -// const hexStr = hexb.toString("hex"); -// expect(hexStr).toBe( -// "000102030405060708090a0b0c0d0e0f" + -// "101112131415161718191a1b1c1d1e1f" + -// "202122232425262728292a2b2c2d2e2f" + -// "303132333435363738393a3b3c3d3e3f" + -// "404142434445464748494a4b4c4d4e4f" + -// "505152535455565758595a5b5c5d5e5f" + -// "606162636465666768696a6b6c6d6e6f" + -// "707172737475767778797a7b7c7d7e7f" + -// "808182838485868788898a8b8c8d8e8f" + -// "909192939495969798999a9b9c9d9e9f" + -// "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" + -// "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + -// "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + -// "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + -// "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + -// "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", -// ); - -// const hexb2 = Buffer.from(hexStr, "hex"); -// for (let i = 0; i < 256; i++) { -// expect(hexb2[i]).toBe(hexb[i]); -// } -// }); - -// it("single hex character is discarded", () => { -// expect(Buffer.from("A", "hex").length).toBe(0); -// }); - -// it("if a trailing character is discarded, rest of string is processed", () => { -// expect(Buffer.from("Abx", "hex")).toEqual(Buffer.from("Ab", "hex")); -// }); - -// it("single base64 char encodes as 0", () => { -// expect(Buffer.from("A", "base64").length).toBe(0); -// }); - -// it("invalid slice end", () => { -// const b = Buffer.from([1, 2, 3, 4, 5]); -// const b2 = b.toString("hex", 1, 10000); -// const b3 = b.toString("hex", 1, 5); -// const b4 = b.toString("hex", 1); -// expect(b2).toBe(b3); -// expect(b2).toBe(b4); -// }); - -// it("slice()", () => { -// function buildBuffer(data) { -// if (Array.isArray(data)) { -// const buffer = Buffer.allocUnsafe(data.length); -// data.forEach((v, k) => (buffer[k] = v)); -// return buffer; -// } -// return null; -// } - -// const x = buildBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]); -// expect(x).toStrictEqual(Buffer.from([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72])); - -// const a = x.slice(4); -// expect(a.length).toBe(5); -// expect(a[0]).toBe(0x6f); -// expect(a[1]).toBe(0xa3); -// expect(a[2]).toBe(0x62); -// expect(a[3]).toBe(0x61); -// expect(a[4]).toBe(0x72); - -// const b = x.slice(0); -// expect(b.length).toBe(x.length); - -// const c = x.slice(0, 4); -// expect(c.length).toBe(4); -// expect(c[0]).toBe(0x81); -// expect(c[1]).toBe(0xa3); - -// const d = x.slice(0, 9); -// expect(d.length).toBe(9); - -// const e = x.slice(1, 4); -// expect(e.length).toBe(3); -// expect(e[0]).toBe(0xa3); - -// const f = x.slice(2, 4); -// expect(f.length).toBe(2); -// expect(f[0]).toBe(0x66); -// expect(f[1]).toBe(0x6f); -// }); - -// function forEachUnicode(label, test) { -// ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => it(`${label} (${encoding})`, test.bind(null, encoding))); -// } - -// forEachUnicode("write()", encoding => { -// const b = Buffer.allocUnsafe(10); -// b.write("あいうえお", encoding); -// expect(b.toString(encoding)).toBe("あいうえお"); -// }); - -// forEachUnicode("write() with offset", encoding => { -// const b = Buffer.allocUnsafe(11); -// b.write("あいうえお", 1, encoding); -// expect(b.toString(encoding, 1)).toBe("あいうえお"); -// }); - -// it("latin1 encoding should write only one byte per character", () => { -// const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]); -// b.write(String.fromCharCode(0xffff), 0, "latin1"); -// expect(b[0]).toBe(0xff); -// expect(b[1]).toBe(0xad); -// expect(b[2]).toBe(0xbe); -// expect(b[3]).toBe(0xef); -// b.write(String.fromCharCode(0xaaee), 0, "latin1"); -// expect(b[0]).toBe(0xee); -// expect(b[1]).toBe(0xad); -// expect(b[2]).toBe(0xbe); -// expect(b[3]).toBe(0xef); -// }); - -// it("binary encoding should write only one byte per character", () => { -// const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]); -// b.write(String.fromCharCode(0xffff), 0, "latin1"); -// expect(b[0]).toBe(0xff); -// expect(b[1]).toBe(0xad); -// expect(b[2]).toBe(0xbe); -// expect(b[3]).toBe(0xef); -// b.write(String.fromCharCode(0xaaee), 0, "latin1"); -// expect(b[0]).toBe(0xee); -// expect(b[1]).toBe(0xad); -// expect(b[2]).toBe(0xbe); -// expect(b[3]).toBe(0xef); -// }); - -// it("UTF-8 string includes null character", () => { -// // https://github.com/nodejs/node-v0.x-archive/pull/1210 -// expect(Buffer.from("\0").length).toBe(1); -// expect(Buffer.from("\0\0").length).toBe(2); -// }); - -// it("truncate write() at character boundary", () => { -// const buf = Buffer.allocUnsafe(2); -// expect(buf.write("")).toBe(0); // 0bytes -// expect(buf.write("\0")).toBe(1); // 1byte (v8 adds null terminator) -// expect(buf.write("a\0")).toBe(2); // 1byte * 2 -// expect(buf.write("あ")).toBe(0); // 3bytes -// expect(buf.write("\0あ")).toBe(1); // 1byte + 3bytes -// expect(buf.write("\0\0あ")).toBe(2); // 1byte * 2 + 3bytes - -// const buf2 = Buffer.allocUnsafe(10); -// expect(buf2.write("あいう")).toBe(9); // 3bytes * 3 (v8 adds null term.) -// expect(buf2.write("あいう\0")).toBe(10); // 3bytes * 3 + 1byte -// }); - -// it("write() with maxLength", () => { -// // https://github.com/nodejs/node-v0.x-archive/issues/243 -// const buf = Buffer.allocUnsafe(4); -// buf.fill(0xff); -// expect(buf.write("abcd", 1, 2, "utf8")).toBe(2); -// expect(buf[0]).toBe(0xff); -// expect(buf[1]).toBe(0x61); -// expect(buf[2]).toBe(0x62); -// expect(buf[3]).toBe(0xff); - -// buf.fill(0xff); -// expect(buf.write("abcd", 1, 4)).toBe(3); -// expect(buf[0]).toBe(0xff); -// expect(buf[1]).toBe(0x61); -// expect(buf[2]).toBe(0x62); -// expect(buf[3]).toBe(0x63); - -// buf.fill(0xff); -// expect(buf.write("abcd", 1, 2, "utf8")).toBe(2); -// expect(buf[0]).toBe(0xff); -// expect(buf[1]).toBe(0x61); -// expect(buf[2]).toBe(0x62); -// expect(buf[3]).toBe(0xff); - -// buf.fill(0xff); -// expect(buf.write("abcdef", 1, 2, "hex")).toBe(2); -// expect(buf[0]).toBe(0xff); -// expect(buf[1]).toBe(0xab); -// expect(buf[2]).toBe(0xcd); -// expect(buf[3]).toBe(0xff); - -// ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => { -// buf.fill(0xff); -// expect(buf.write("abcd", 0, 2, encoding)).toBe(2); -// expect(buf[0]).toBe(0x61); -// expect(buf[1]).toBe(0x00); -// expect(buf[2]).toBe(0xff); -// expect(buf[3]).toBe(0xff); -// }); -// }); - -// it("offset returns are correct", () => { -// const b = Buffer.allocUnsafe(16); -// expect(b.writeUInt32LE(0, 0)).toBe(4); -// expect(b.writeUInt16LE(0, 4)).toBe(6); -// expect(b.writeUInt8(0, 6)).toBe(7); -// expect(b.writeInt8(0, 7)).toBe(8); -// expect(b.writeDoubleLE(0, 8)).toBe(16); -// }); - -// it("unmatched surrogates should not produce invalid utf8 output", () => { -// // ef bf bd = utf-8 representation of unicode replacement character -// // see https://codereview.chromium.org/121173009/ -// let buf = Buffer.from("ab\ud800cd", "utf8"); -// expect(buf[0]).toBe(0x61); -// expect(buf[1]).toBe(0x62); -// expect(buf[2]).toBe(0xef); -// expect(buf[3]).toBe(0xbf); -// expect(buf[4]).toBe(0xbd); -// expect(buf[5]).toBe(0x63); -// expect(buf[6]).toBe(0x64); - -// buf = Buffer.from("abcd\ud800", "utf8"); -// expect(buf[0]).toBe(0x61); -// expect(buf[1]).toBe(0x62); -// expect(buf[2]).toBe(0x63); -// expect(buf[3]).toBe(0x64); -// expect(buf[4]).toBe(0xef); -// expect(buf[5]).toBe(0xbf); -// expect(buf[6]).toBe(0xbd); - -// buf = Buffer.from("\ud800abcd", "utf8"); -// expect(buf[0]).toBe(0xef); -// expect(buf[1]).toBe(0xbf); -// expect(buf[2]).toBe(0xbd); -// expect(buf[3]).toBe(0x61); -// expect(buf[4]).toBe(0x62); -// expect(buf[5]).toBe(0x63); -// expect(buf[6]).toBe(0x64); -// }); - -// it("buffer overrun", () => { -// const buf = Buffer.from([0, 0, 0, 0, 0]); // length: 5 -// const sub = buf.slice(0, 4); // length: 4 -// expect(sub.write("12345", "latin1")).toBe(4); -// expect(buf[4]).toBe(0); -// expect(sub.write("12345", "binary")).toBe(4); -// expect(buf[4]).toBe(0); -// }); - -// it("alloc with fill option", () => { -// const buf = Buffer.alloc(5, "800A", "hex"); -// expect(buf[0]).toBe(128); -// expect(buf[1]).toBe(10); -// expect(buf[2]).toBe(128); -// expect(buf[3]).toBe(10); -// expect(buf[4]).toBe(128); -// }); - -// // https://github.com/joyent/node/issues/1758 -// it("check for fractional length args, junk length args, etc.", () => { -// // Call .fill() first, stops valgrind warning about uninitialized memory reads. -// Buffer.allocUnsafe(3.3).fill().toString(); -// // Throws bad argument error in commit 43cb4ec -// Buffer.alloc(3.3).fill().toString(); -// expect(Buffer.allocUnsafe(3.3).length).toBe(3); -// expect(Buffer.from({ length: 3.3 }).length).toBe(3); -// expect(Buffer.from({ length: "BAM" }).length).toBe(0); -// // Make sure that strings are not coerced to numbers. -// expect(Buffer.from("99").length).toBe(2); -// expect(Buffer.from("13.37").length).toBe(5); -// // Ensure that the length argument is respected. -// ["ascii", "utf8", "hex", "base64", "latin1", "binary"].forEach(enc => { -// expect(Buffer.allocUnsafe(1).write("aaaaaa", 0, 1, enc)).toBe(1); -// }); -// // Regression test, guard against buffer overrun in the base64 decoder. -// const a = Buffer.allocUnsafe(3); -// const b = Buffer.from("xxx"); -// a.write("aaaaaaaa", "base64"); -// expect(b.toString()).toBe("xxx"); -// }); - -// it("buffer overflow", () => { -// // issue GH-5587 -// expect(() => Buffer.alloc(8).writeFloatLE(0, 5)).toThrow(RangeError); -// expect(() => Buffer.alloc(16).writeDoubleLE(0, 9)).toThrow(RangeError); -// // Attempt to overflow buffers, similar to previous bug in array buffers -// expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff)).toThrow(RangeError); -// expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff)).toThrow(RangeError); -// // Ensure negative values can't get past offset -// expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1)).toThrow(RangeError); -// expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1)).toThrow(RangeError); -// }); - -// it("common write{U}IntLE/BE()", () => { -// let buf = Buffer.allocUnsafe(3); -// buf.writeUIntLE(0x123456, 0, 3); -// expect(buf.toJSON().data).toEqual([0x56, 0x34, 0x12]); -// expect(buf.readUIntLE(0, 3)).toBe(0x123456); - -// buf.fill(0xff); -// buf.writeUIntBE(0x123456, 0, 3); -// expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56]); -// expect(buf.readUIntBE(0, 3)).toBe(0x123456); - -// buf.fill(0xff); -// buf.writeIntLE(0x123456, 0, 3); -// expect(buf.toJSON().data).toEqual([0x56, 0x34, 0x12]); -// expect(buf.readIntLE(0, 3)).toBe(0x123456); - -// buf.fill(0xff); -// buf.writeIntBE(0x123456, 0, 3); -// expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56]); -// expect(buf.readIntBE(0, 3)).toBe(0x123456); - -// buf.fill(0xff); -// buf.writeIntLE(-0x123456, 0, 3); -// expect(buf.toJSON().data).toEqual([0xaa, 0xcb, 0xed]); -// expect(buf.readIntLE(0, 3)).toBe(-0x123456); - -// buf.fill(0xff); -// buf.writeIntBE(-0x123456, 0, 3); -// expect(buf.toJSON().data).toEqual([0xed, 0xcb, 0xaa]); -// expect(buf.readIntBE(0, 3)).toBe(-0x123456); - -// buf.fill(0xff); -// buf.writeIntLE(-0x123400, 0, 3); -// expect(buf.toJSON().data).toEqual([0x00, 0xcc, 0xed]); -// expect(buf.readIntLE(0, 3)).toBe(-0x123400); - -// buf.fill(0xff); -// buf.writeIntBE(-0x123400, 0, 3); -// expect(buf.toJSON().data).toEqual([0xed, 0xcc, 0x00]); -// expect(buf.readIntBE(0, 3)).toBe(-0x123400); - -// buf.fill(0xff); -// buf.writeIntLE(-0x120000, 0, 3); -// expect(buf.toJSON().data).toEqual([0x00, 0x00, 0xee]); -// expect(buf.readIntLE(0, 3)).toBe(-0x120000); - -// buf.fill(0xff); -// buf.writeIntBE(-0x120000, 0, 3); -// expect(buf.toJSON().data).toEqual([0xee, 0x00, 0x00]); -// expect(buf.readIntBE(0, 3)).toBe(-0x120000); - -// buf = Buffer.allocUnsafe(5); -// buf.writeUIntLE(0x1234567890, 0, 5); -// expect(buf.toJSON().data).toEqual([0x90, 0x78, 0x56, 0x34, 0x12]); -// expect(buf.readUIntLE(0, 5)).toBe(0x1234567890); - -// buf.fill(0xff); -// buf.writeUIntBE(0x1234567890, 0, 5); -// expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56, 0x78, 0x90]); -// expect(buf.readUIntBE(0, 5)).toBe(0x1234567890); - -// buf.fill(0xff); -// buf.writeIntLE(0x1234567890, 0, 5); -// expect(buf.toJSON().data).toEqual([0x90, 0x78, 0x56, 0x34, 0x12]); -// expect(buf.readIntLE(0, 5)).toBe(0x1234567890); - -// buf.fill(0xff); -// buf.writeIntBE(0x1234567890, 0, 5); -// expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56, 0x78, 0x90]); -// expect(buf.readIntBE(0, 5)).toBe(0x1234567890); - -// buf.fill(0xff); -// buf.writeIntLE(-0x1234567890, 0, 5); -// expect(buf.toJSON().data).toEqual([0x70, 0x87, 0xa9, 0xcb, 0xed]); -// expect(buf.readIntLE(0, 5)).toBe(-0x1234567890); - -// buf.fill(0xff); -// buf.writeIntBE(-0x1234567890, 0, 5); -// expect(buf.toJSON().data).toEqual([0xed, 0xcb, 0xa9, 0x87, 0x70]); -// expect(buf.readIntBE(0, 5)).toBe(-0x1234567890); - -// buf.fill(0xff); -// buf.writeIntLE(-0x0012000000, 0, 5); -// expect(buf.toJSON().data).toEqual([0x00, 0x00, 0x00, 0xee, 0xff]); -// expect(buf.readIntLE(0, 5)).toBe(-0x0012000000); - -// buf.fill(0xff); -// buf.writeIntBE(-0x0012000000, 0, 5); -// expect(buf.toJSON().data).toEqual([0xff, 0xee, 0x00, 0x00, 0x00]); -// expect(buf.readIntBE(0, 5)).toBe(-0x0012000000); -// }); - -// it("construct buffer from buffer", () => { -// // Regression test for https://github.com/nodejs/node-v0.x-archive/issues/6111. -// // Constructing a buffer from another buffer should a) work, and b) not corrupt -// // the source buffer. -// const a = [...Array(128).keys()]; // [0, 1, 2, 3, ... 126, 127] -// const b = Buffer.from(a); -// const c = Buffer.from(b); -// expect(b.length).toBe(a.length); -// expect(c.length).toBe(a.length); -// for (let i = 0, k = a.length; i < k; ++i) { -// expect(a[i]).toBe(i); -// expect(b[i]).toBe(i); -// expect(c[i]).toBe(i); -// } -// }); - -// it("truncation after decode", () => { -// const crypto = require("crypto"); - -// expect(crypto.createHash("sha1").update(Buffer.from("YW55=======", "base64")).digest("hex")).toBe( -// crypto.createHash("sha1").update(Buffer.from("YW55", "base64")).digest("hex"), -// ); -// }); - -// it("Buffer,poolSize", () => { -// const ps = Buffer.poolSize; -// Buffer.poolSize = 0; -// expect(Buffer.allocUnsafe(1).parent instanceof ArrayBuffer).toBe(true); -// Buffer.poolSize = ps; - -// expect(() => Buffer.allocUnsafe(10).copy()).toThrow(TypeError); - -// expect(() => Buffer.from()).toThrow(TypeError); -// expect(() => Buffer.from(null)).toThrow(TypeError); -// }); - -// it("prototype getters should not throw", () => { -// expect(Buffer.prototype.parent).toBeUndefined(); -// expect(Buffer.prototype.offset).toBeUndefined(); -// expect(SlowBuffer.prototype.parent).toBeUndefined(); -// expect(SlowBuffer.prototype.offset).toBeUndefined(); -// }); - -// it("large negative Buffer length inputs should not affect pool offset", () => { -// // Use the fromArrayLike() variant here because it's more lenient -// // about its input and passes the length directly to allocate(). -// expect(Buffer.from({ length: -Buffer.poolSize })).toStrictEqual(Buffer.from("")); -// expect(Buffer.from({ length: -100 })).toStrictEqual(Buffer.from("")); - -// // Check pool offset after that by trying to write string into the pool. -// Buffer.from("abc"); -// }); - -// it("ParseArrayIndex() should handle full uint32", () => { -// expect(() => Buffer.from(new ArrayBuffer(0), -1 >>> 0)).toThrow(RangeError); -// }); - -// it("ParseArrayIndex() should reject values that don't fit in a 32 bits size_t", () => { -// expect(() => { -// const a = Buffer.alloc(1); -// const b = Buffer.alloc(1); -// a.copy(b, 0, 0x100000000, 0x100000001); -// }).toThrow(RangeError); -// }); - -// it("unpooled buffer (replaces SlowBuffer)", () => { -// const ubuf = Buffer.allocUnsafeSlow(10); -// expect(ubuf).toBeTruthy(); -// expect(ubuf.buffer).toBeTruthy(); -// expect(ubuf.buffer.byteLength).toBe(10); -// }); - -// it("verify that an empty ArrayBuffer does not throw", () => { -// Buffer.from(new ArrayBuffer()); -// }); - -// it("alloc() should throw on non-numeric size", () => { -// expect(() => Buffer.alloc({ valueOf: () => 1 })).toThrow(TypeError); -// expect(() => Buffer.alloc({ valueOf: () => -1 })).toThrow(TypeError); -// }); - -// it("toLocaleString()", () => { -// const buf = Buffer.from("test"); -// expect(buf.toLocaleString()).toBe(buf.toString()); -// // expect(Buffer.prototype.toLocaleString).toBe(Buffer.prototype.toString); -// }); - -// it("alloc() should throw on invalid data", () => { -// expect(() => Buffer.alloc(0x1000, "This is not correctly encoded", "hex")).toThrow(TypeError); -// expect(() => Buffer.alloc(0x1000, "c", "hex")).toThrow(TypeError); -// expect(() => Buffer.alloc(1, Buffer.alloc(0))).toThrow(TypeError); -// expect(() => Buffer.alloc(40, "x", 20)).toThrow(TypeError); -// }); - -// it("Buffer.toJSON()", () => { -// expect(JSON.stringify(Buffer.from("hello"))).toBe( -// JSON.stringify({ -// type: "Buffer", -// data: [104, 101, 108, 108, 111], -// }), -// ); -// }); - -// it("buffer", () => { -// var buf = new Buffer(20); -// gc(); -// // if this fails or infinitely loops, it means there is a memory issue with the JSC::Structure object -// expect(Object.keys(buf).length > 0).toBe(true); -// gc(); -// expect(buf.write("hello world ")).toBe(12); -// expect(buf.write("hello world ", "utf8")).toBe(12); - -// gc(); -// expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world "); -// gc(); -// expect(buf.toString("base64url", 0, "hello world ".length)).toBe(btoa("hello world ")); -// gc(); -// expect(buf instanceof Uint8Array).toBe(true); -// gc(); -// expect(buf instanceof Buffer).toBe(true); -// gc(); -// expect(buf.slice() instanceof Uint8Array).toBe(true); -// gc(); -// expect(buf.slice(0, 1) instanceof Buffer).toBe(true); -// gc(); -// expect(buf.slice(0, 1) instanceof Uint8Array).toBe(true); -// gc(); -// expect(buf.slice(0, 1) instanceof Buffer).toBe(true); -// gc(); -// expect(buf.slice(0, 0).length).toBe(0); -// }); - -// it("Buffer", () => { -// var inputs = ["hello world", "hello world".repeat(100), `😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`]; -// var good = inputs.map(a => new TextEncoder().encode(a)); -// for (let i = 0; i < inputs.length; i++) { -// var input = inputs[i]; -// expect(new Buffer(input).toString("utf8")).toBe(inputs[i]); -// gc(); -// expect(Array.from(new Buffer(input)).join(",")).toBe(good[i].join(",")); -// gc(); -// expect(Buffer.byteLength(input)).toBe(good[i].length); -// gc(); -// expect(Buffer.from(input).byteLength).toBe(Buffer.byteLength(input)); -// } -// }); - -// it("Buffer.byteLength", () => { -// expect(Buffer.byteLength("😀😃😄😁😆😅😂🤣☺️😊😊😇")).toBe( -// new TextEncoder().encode("😀😃😄😁😆😅😂🤣☺️😊😊😇").byteLength, -// ); -// }); - -// it("Buffer.isBuffer", () => { -// expect(Buffer.isBuffer(new Buffer(1))).toBe(true); -// gc(); -// expect(Buffer.isBuffer(new Buffer(0))).toBe(true); -// gc(); -// expect(Buffer.isBuffer(new Uint8Array(0))).toBe(false); -// gc(); -// expect(Buffer.isBuffer(new Uint8Array(1))).toBe(false); -// gc(); -// var a = new Uint8Array(1); -// gc(); -// expect(Buffer.isBuffer(a)).toBe(false); -// gc(); -// a = new Buffer(a.buffer); -// gc(); -// expect(Buffer.isBuffer(a)).toBe(true); -// gc(); -// expect(a instanceof Buffer).toBe(true); -// expect(a instanceof Uint8Array).toBe(true); -// expect(new Uint8Array(0) instanceof Buffer).toBe(false); - -// // DOMJIT -// for (let i = 0; i < 9000; i++) { -// if (!Buffer.isBuffer(a)) { -// throw new Error("Buffer.isBuffer failed"); -// } - -// if (Buffer.isBuffer("wat")) { -// throw new Error("Buffer.isBuffer failed"); -// } -// } -// }); - -// it("writeInt", () => { -// var buf = new Buffer(1024); -// var data = new DataView(buf.buffer); -// buf.writeInt32BE(100); -// expect(data.getInt32(0, false)).toBe(100); -// buf.writeInt32BE(100); -// expect(data.getInt32(0, false)).toBe(100); -// var childBuf = buf.subarray(0, 4); -// expect(data.getInt32(0, false)).toBe(100); -// expect(childBuf.readInt32BE(0, false)).toBe(100); -// }); - -// it("Buffer.from", () => { -// expect(Buffer.from("hello world").toString("utf8")).toBe("hello world"); -// expect(Buffer.from("hello world", "ascii").toString("utf8")).toBe("hello world"); -// expect(Buffer.from("hello world", "latin1").toString("utf8")).toBe("hello world"); -// gc(); -// expect(Buffer.from([254]).join(",")).toBe("254"); - -// expect(Buffer.from([254], "utf8").join(",")).toBe("254"); -// expect(Buffer.from([254], "utf-8").join(",")).toBe("254"); -// expect(Buffer.from([254], "latin").join(",")).toBe("254"); -// expect(Buffer.from([254], "uc2").join(",")).toBe("254"); -// expect(Buffer.from([254], "utf16").join(",")).toBe("254"); -// expect(Buffer.isBuffer(Buffer.from([254], "utf16"))).toBe(true); - -// expect(() => Buffer.from(123).join(",")).toThrow(); - -// expect(Buffer.from({ length: 124 }).join(",")).toBe(Uint8Array.from({ length: 124 }).join(",")); - -// expect(Buffer.from(new ArrayBuffer(1024), 0, 512).join(",")).toBe(new Uint8Array(512).join(",")); - -// expect(Buffer.from(new Buffer(new ArrayBuffer(1024), 0, 512)).join(",")).toBe(new Uint8Array(512).join(",")); -// gc(); -// }); - -// it("Buffer.from latin1 vs ascii", () => { -// const simpleBuffer = Buffer.from("\xa4", "binary"); -// expect(simpleBuffer.toString("latin1")).toBe("¤"); -// expect(simpleBuffer.toString("ascii")).toBe("$"); -// gc(); -// const asciiBuffer = Buffer.from("\xa4", "ascii"); -// expect(asciiBuffer.toString("latin1")).toBe("¤"); -// expect(asciiBuffer.toString("ascii")).toBe("$"); -// gc(); -// }); - -// it("Buffer.equals", () => { -// var a = new Uint8Array(10); -// a[2] = 1; -// var b = new Uint8Array(10); -// b[2] = 1; -// a = new Buffer(a.buffer); -// b = new Buffer(b.buffer); -// expect(a.equals(b)).toBe(true); -// b[2] = 0; -// expect(a.equals(b)).toBe(false); -// }); - -// it("Buffer.compare", () => { -// var a = new Uint8Array(10); -// a[2] = 1; -// var b = new Uint8Array(10); -// b[2] = 1; -// a = new Buffer(a.buffer); -// b = new Buffer(b.buffer); -// expect(a.compare(b)).toBe(0); -// b[2] = 0; -// expect(a.compare(b)).toBe(1); -// expect(b.compare(a)).toBe(-1); - -// const buf = Buffer.from("0123456789", "utf8"); -// const expectedSameBufs = [ -// [buf.slice(-10, 10), Buffer.from("0123456789", "utf8")], -// [buf.slice(-20, 10), Buffer.from("0123456789", "utf8")], -// [buf.slice(-20, -10), Buffer.from("", "utf8")], -// [buf.slice(), Buffer.from("0123456789", "utf8")], -// [buf.slice(0), Buffer.from("0123456789", "utf8")], -// [buf.slice(0, 0), Buffer.from("", "utf8")], -// [buf.slice(undefined), Buffer.from("0123456789", "utf8")], -// [buf.slice("foobar"), Buffer.from("0123456789", "utf8")], -// [buf.slice(undefined, undefined), Buffer.from("0123456789", "utf8")], -// [buf.slice(2), Buffer.from("23456789", "utf8")], -// [buf.slice(5), Buffer.from("56789", "utf8")], -// [buf.slice(10), Buffer.from("", "utf8")], -// [buf.slice(5, 8), Buffer.from("567", "utf8")], -// [buf.slice(8, -1), Buffer.from("8", "utf8")], -// [buf.slice(-10), Buffer.from("0123456789", "utf8")], -// [buf.slice(0, -9), Buffer.from("0", "utf8")], -// [buf.slice(0, -10), Buffer.from("", "utf8")], -// [buf.slice(0, -1), Buffer.from("012345678", "utf8")], -// [buf.slice(2, -2), Buffer.from("234567", "utf8")], -// [buf.slice(0, 65536), Buffer.from("0123456789", "utf8")], -// [buf.slice(65536, 0), Buffer.from("", "utf8")], -// [buf.slice(-5, -8), Buffer.from("", "utf8")], -// [buf.slice(-5, -3), Buffer.from("56", "utf8")], -// [buf.slice(-10, 10), Buffer.from("0123456789", "utf8")], -// [buf.slice("0", "1"), Buffer.from("0", "utf8")], -// [buf.slice("-5", "10"), Buffer.from("56789", "utf8")], -// [buf.slice("-10", "10"), Buffer.from("0123456789", "utf8")], -// [buf.slice("-10", "-5"), Buffer.from("01234", "utf8")], -// [buf.slice("-10", "-0"), Buffer.from("", "utf8")], -// [buf.slice("111"), Buffer.from("", "utf8")], -// [buf.slice("0", "-111"), Buffer.from("", "utf8")], -// ]; - -// for (let i = 0, s = buf.toString(); i < buf.length; ++i) { -// expectedSameBufs.push( -// [buf.slice(i), Buffer.from(s.slice(i))], -// [buf.slice(0, i), Buffer.from(s.slice(0, i))], -// [buf.slice(-i), Buffer.from(s.slice(-i))], -// [buf.slice(0, -i), Buffer.from(s.slice(0, -i))], -// ); -// } - -// expectedSameBufs.forEach(([buf1, buf2]) => { -// expect(Buffer.compare(buf1, buf2)).toBe(0); -// }); - -// { -// const buf = Buffer.from([ -// 1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0, 0, 0, 18, 184, 6, 0, 175, 29, 0, 8, 11, 1, 0, 0, -// ]); -// const chunk1 = Buffer.from([1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0]); -// const chunk2 = Buffer.from([0, 0, 18, 184, 6, 0, 175, 29, 0, 8, 11, 1, 0, 0]); -// const middle = buf.length / 2; - -// expect(JSON.stringify(buf.slice(0, middle))).toBe(JSON.stringify(chunk1)); -// expect(JSON.stringify(buf.slice(middle))).toBe(JSON.stringify(chunk2)); -// } -// }); - -// it("Buffer.copy", () => { -// var array1 = new Uint8Array(128); -// array1.fill(100); -// array1 = new Buffer(array1.buffer); -// var array2 = new Uint8Array(128); -// array2.fill(200); -// array2 = new Buffer(array2.buffer); -// var array3 = new Uint8Array(128); -// array3 = new Buffer(array3.buffer); -// gc(); -// expect(array1.copy(array2)).toBe(128); -// expect(array1.join("")).toBe(array2.join("")); - -// { -// // Create two `Buffer` instances. -// const buf1 = Buffer.allocUnsafe(26); -// const buf2 = Buffer.allocUnsafe(26).fill("!"); - -// for (let i = 0; i < 26; i++) { -// // 97 is the decimal ASCII value for 'a'. -// buf1[i] = i + 97; -// } - -// // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`. -// buf1.copy(buf2, 8, 16, 20); -// expect(buf2.toString("ascii", 0, 25)).toBe("!!!!!!!!qrst!!!!!!!!!!!!!"); -// } - -// { -// const buf = Buffer.allocUnsafe(26); - -// for (let i = 0; i < 26; i++) { -// // 97 is the decimal ASCII value for 'a'. -// buf[i] = i + 97; -// } - -// buf.copy(buf, 0, 4, 10); -// expect(buf.toString()).toBe("efghijghijklmnopqrstuvwxyz"); -// } -// }); - -// export function fillRepeating(dstBuffer, start, end) { -// let len = dstBuffer.length, // important: use indices length, not byte-length -// sLen = end - start, -// p = sLen; // set initial position = source sequence length - -// // step 2: copy existing data doubling segment length per iteration -// while (p < len) { -// if (p + sLen > len) sLen = len - p; // if not power of 2, truncate last segment -// dstBuffer.copyWithin(p, start, sLen); // internal copy -// p += sLen; // add current length to offset -// sLen <<= 1; // double length for next segment -// } -// } - -// describe("Buffer.fill string", () => { -// for (let text of ["hello world", "1234567890", "\uD83D\uDE00", "😀😃😄😁😆😅😂🤣☺️😊😊😇"]) { -// it(text, () => { -// var input = new Buffer(1024); -// input.fill(text); -// var demo = new Uint8Array(1024); -// var encoded = new TextEncoder().encode(text); - -// demo.set(encoded); -// fillRepeating(demo, 0, encoded.length); -// expect(input.join("")).toBe(demo.join("")); -// }); -// } -// }); - -// it("Buffer.fill 1 char string", () => { -// var input = new Buffer(1024); -// input.fill("h"); -// var demo = new Uint8Array(1024); -// var encoded = new TextEncoder().encode("h"); - -// demo.set(encoded); -// fillRepeating(demo, 0, encoded.length); -// expect(input.join("")).toBe(demo.join("")); -// }); - -// it("Buffer.concat", () => { -// var array1 = new Uint8Array(128); -// array1.fill(100); -// var array2 = new Uint8Array(128); -// array2.fill(200); -// var array3 = new Uint8Array(128); -// array3.fill(300); -// gc(); -// expect(Buffer.concat([array1, array2, array3]).join("")).toBe(array1.join("") + array2.join("") + array3.join("")); -// expect(Buffer.concat([array1, array2, array3], 222).length).toBe(222); -// expect(Buffer.concat([array1, array2, array3], 222).subarray(0, 128).join("")).toBe("100".repeat(128)); -// expect(Buffer.concat([array1, array2, array3], 222).subarray(129, 222).join("")).toBe("200".repeat(222 - 129)); -// }); - -// it("read", () => { -// var buf = new Buffer(1024); -// var data = new DataView(buf.buffer); -// function reset() { -// new Uint8Array(buf.buffer).fill(0); -// } -// data.setBigInt64(0, BigInt(1000), false); -// expect(buf.readBigInt64BE(0)).toBe(BigInt(1000)); -// reset(); - -// data.setBigInt64(0, BigInt(1000), true); -// expect(buf.readBigInt64LE(0)).toBe(BigInt(1000)); -// reset(); - -// data.setBigUint64(0, BigInt(1000), false); -// expect(buf.readBigUInt64BE(0)).toBe(BigInt(1000)); -// reset(); - -// data.setBigUint64(0, BigInt(1000), true); -// expect(buf.readBigUInt64LE(0)).toBe(BigInt(1000)); -// reset(); - -// data.setFloat64(0, 1000, false); -// expect(buf.readDoubleBE(0)).toBe(1000); -// reset(); - -// data.setFloat64(0, 1000, true); -// expect(buf.readDoubleLE(0)).toBe(1000); -// reset(); - -// data.setFloat32(0, 1000, false); -// expect(buf.readFloatBE(0)).toBe(1000); -// reset(); - -// data.setFloat32(0, 1000, true); -// expect(buf.readFloatLE(0)).toBe(1000); -// reset(); - -// data.setInt16(0, 1000, false); -// expect(buf.readInt16BE(0)).toBe(1000); -// reset(); - -// data.setInt16(0, 1000, true); -// expect(buf.readInt16LE(0)).toBe(1000); -// reset(); - -// data.setInt32(0, 1000, false); -// expect(buf.readInt32BE(0)).toBe(1000); -// reset(); - -// data.setInt32(0, 1000, true); -// expect(buf.readInt32LE(0)).toBe(1000); -// reset(); - -// data.setInt8(0, 100, false); -// expect(buf.readInt8(0)).toBe(100); -// reset(); - -// data.setUint16(0, 1000, false); -// expect(buf.readUInt16BE(0)).toBe(1000); -// reset(); - -// data.setUint16(0, 1000, true); -// expect(buf.readUInt16LE(0)).toBe(1000); -// reset(); - -// data.setUint32(0, 1000, false); -// expect(buf.readUInt32BE(0)).toBe(1000); -// reset(); - -// data.setUint32(0, 1000, true); -// expect(buf.readUInt32LE(0)).toBe(1000); -// reset(); - -// data.setUint8(0, 255, false); -// expect(buf.readUInt8(0)).toBe(255); -// reset(); - -// data.setUint8(0, 255, false); -// expect(buf.readUInt8(0)).toBe(255); -// reset(); -// }); - -// // this is for checking the simd code path -// it("write long utf16 string works", () => { -// const long = "😀😃😄😁😆😅😂🤣☺️😊😊😇".repeat(200); -// const buf = Buffer.alloc(long.length * 2); -// buf.write(long, 0, "utf16le"); -// expect(buf.toString("utf16le")).toBe(long); -// for (let offset = 0; offset < long.length; offset += 48) { -// expect(buf.toString("utf16le", offset, offset + 4)).toBe("😀"); -// expect(buf.toString("utf16le", offset, offset + 8)).toBe("😀😃"); -// expect(buf.toString("utf16le", offset, offset + 12)).toBe("😀😃😄"); -// expect(buf.toString("utf16le", offset, offset + 16)).toBe("😀😃😄😁"); -// expect(buf.toString("utf16le", offset, offset + 20)).toBe("😀😃😄😁😆"); -// expect(buf.toString("utf16le", offset, offset + 24)).toBe("😀😃😄😁😆😅"); -// expect(buf.toString("utf16le", offset, offset + 28)).toBe("😀😃😄😁😆😅😂"); -// expect(buf.toString("utf16le", offset, offset + 32)).toBe("😀😃😄😁😆😅😂🤣"); -// expect(buf.toString("utf16le", offset, offset + 36)).toBe("😀😃😄😁😆😅😂🤣☺️"); -// expect(buf.toString("utf16le", offset, offset + 40)).toBe("😀😃😄😁😆😅😂🤣☺️😊"); -// expect(buf.toString("utf16le", offset, offset + 44)).toBe("😀😃😄😁😆😅😂🤣☺️😊😊"); -// expect(buf.toString("utf16le", offset, offset + 48)).toBe("😀😃😄😁😆😅😂🤣☺️😊😊😇"); -// } -// }); - -// it("write", () => { -// const resultMap = new Map([ -// ["utf8", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], -// ["ucs2", Buffer.from([102, 0, 111, 0, 111, 0, 0, 0, 0])], -// ["ascii", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], -// ["latin1", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], -// ["binary", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], -// ["utf16le", Buffer.from([102, 0, 111, 0, 111, 0, 0, 0, 0])], -// ["base64", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], -// ["base64url", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], -// ["hex", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], -// ]); - -// let buf = Buffer.alloc(9); -// function reset() { -// new Uint8Array(buf.buffer).fill(0); -// } - -// // utf8, ucs2, ascii, latin1, utf16le -// const encodings = ["utf8", "utf-8", "ucs2", "ucs-2", "ascii", "latin1", "binary", "utf16le", "utf-16le"]; - -// encodings -// .reduce((es, e) => es.concat(e, e.toUpperCase()), []) -// .forEach(encoding => { -// reset(); - -// const len = Buffer.byteLength("foo", encoding); -// expect(buf.write("foo", 0, len, encoding)).toBe(len); - -// if (encoding.includes("-")) encoding = encoding.replace("-", ""); - -// expect(buf).toStrictEqual(resultMap.get(encoding.toLowerCase())); -// }); - -// // base64 -// ["base64", "BASE64", "base64url", "BASE64URL"].forEach(encoding => { -// reset(); - -// const len = Buffer.byteLength("Zm9v", encoding); - -// expect(buf.write("Zm9v", 0, len, encoding)).toBe(len); -// expect(buf).toStrictEqual(resultMap.get(encoding.toLowerCase())); -// }); - -// // hex -// ["hex", "HEX"].forEach(encoding => { -// reset(); -// const len = Buffer.byteLength("666f6f", encoding); - -// expect(buf.write("666f6f", 0, len, encoding)).toBe(len); -// expect(buf).toStrictEqual(resultMap.get(encoding.toLowerCase())); -// }); - -// // UCS-2 overflow CVE-2018-12115 -// for (let i = 1; i < 4; i++) { -// // Allocate two Buffers sequentially off the pool. Run more than once in case -// // we hit the end of the pool and don't get sequential allocations -// const x = Buffer.allocUnsafe(4).fill(0); -// const y = Buffer.allocUnsafe(4).fill(1); -// // Should not write anything, pos 3 doesn't have enough room for a 16-bit char -// expect(x.write("ыыыыыы", 3, "ucs2")).toBe(0); -// // CVE-2018-12115 experienced via buffer overrun to next block in the pool -// expect(Buffer.compare(y, Buffer.alloc(4, 1))).toBe(0); -// } - -// // // Should not write any data when there is no space for 16-bit chars -// const z = Buffer.alloc(4, 0); -// expect(z.write("\u0001", 3, "ucs2")).toBe(0); -// expect(Buffer.compare(z, Buffer.alloc(4, 0))).toBe(0); -// // Make sure longer strings are written up to the buffer end. -// expect(z.write("abcd", 2)).toBe(2); -// expect([...z]).toStrictEqual([0, 0, 0x61, 0x62]); - -// //Large overrun could corrupt the process with utf8 -// expect(Buffer.alloc(4).write("a".repeat(100), 3, "utf8")).toBe(1); - -// // Large overrun could corrupt the process -// expect(Buffer.alloc(4).write("ыыыыыы".repeat(100), 3, "utf16le")).toBe(0); - -// { -// // .write() does not affect the byte after the written-to slice of the Buffer. -// // Refs: https://github.com/nodejs/node/issues/26422 -// const buf = Buffer.alloc(8); -// expect(buf.write("ыы", 1, "utf16le")).toBe(4); -// expect([...buf]).toStrictEqual([0, 0x4b, 0x04, 0x4b, 0x04, 0, 0, 0]); -// } -// }); - -// it("includes", () => { -// const buf = Buffer.from("this is a buffer"); - -// expect(buf.includes("this")).toBe(true); -// expect(buf.includes("is")).toBe(true); -// expect(buf.includes(Buffer.from("a buffer"))).toBe(true); -// expect(buf.includes(97)).toBe(true); -// expect(buf.includes(Buffer.from("a buffer example"))).toBe(false); -// expect(buf.includes(Buffer.from("a buffer example").slice(0, 8))).toBe(true); -// expect(buf.includes("this", 4)).toBe(false); -// }); - -// it("indexOf", () => { -// const buf = Buffer.from("this is a buffer"); - -// expect(buf.indexOf("this")).toBe(0); -// expect(buf.indexOf("is")).toBe(2); -// expect(buf.indexOf(Buffer.from("a buffer"))).toBe(8); -// expect(buf.indexOf(97)).toBe(8); -// expect(buf.indexOf(Buffer.from("a buffer example"))).toBe(-1); -// expect(buf.indexOf(Buffer.from("a buffer example").slice(0, 8))).toBe(8); - -// const utf16Buffer = Buffer.from("\u039a\u0391\u03a3\u03a3\u0395", "utf16le"); - -// expect(utf16Buffer.indexOf("\u03a3", 0, "utf16le")).toBe(4); -// expect(utf16Buffer.indexOf("\u03a3", -4, "utf16le")).toBe(6); - -// const b = Buffer.from("abcdef"); - -// // Passing a value that's a number, but not a valid byte. -// // Prints: 2, equivalent to searching for 99 or 'c'. -// expect(b.indexOf(99.9)).toBe(2); -// expect(b.indexOf(256 + 99)).toBe(2); - -// // Passing a byteOffset that coerces to NaN or 0. -// // Prints: 1, searching the whole buffer. -// expect(b.indexOf("b", undefined)).toBe(1); -// expect(b.indexOf("b", {})).toBe(1); -// expect(b.indexOf("b", null)).toBe(1); -// expect(b.indexOf("b", [])).toBe(1); -// }); - -// it("lastIndexOf", () => { -// const buf = Buffer.from("this buffer is a buffer"); - -// expect(buf.lastIndexOf("this")).toBe(0); -// expect(buf.lastIndexOf("this", 0)).toBe(0); -// expect(buf.lastIndexOf("this", -1000)).toBe(-1); -// expect(buf.lastIndexOf("buffer")).toBe(17); -// expect(buf.lastIndexOf(Buffer.from("buffer"))).toBe(17); -// expect(buf.lastIndexOf(97)).toBe(15); -// expect(buf.lastIndexOf(Buffer.from("yolo"))).toBe(-1); -// expect(buf.lastIndexOf("buffer", 5)).toBe(5); -// expect(buf.lastIndexOf("buffer", 4)).toBe(-1); - -// const utf16Buffer = Buffer.from("\u039a\u0391\u03a3\u03a3\u0395", "utf16le"); - -// expect(utf16Buffer.lastIndexOf("\u03a3", undefined, "utf16le")).toBe(6); -// expect(utf16Buffer.lastIndexOf("\u03a3", -5, "utf16le")).toBe(4); - -// const b = Buffer.from("abcdef"); - -// // Passing a value that's a number, but not a valid byte. -// // Prints: 2, equivalent to searching for 99 or 'c'. -// expect(b.lastIndexOf(99.9)).toBe(2); -// expect(b.lastIndexOf(256 + 99)).toBe(2); - -// // Passing a byteOffset that coerces to NaN or 0. -// // Prints: 1, searching the whole buffer. -// expect(b.lastIndexOf("b", undefined)).toBe(1); -// expect(b.lastIndexOf("b", {})).toBe(1); - -// // Passing a byteOffset that coerces to 0. -// // Prints: -1, equivalent to passing 0. -// expect(b.lastIndexOf("b", null)).toBe(-1); -// expect(b.lastIndexOf("b", [])).toBe(-1); -// }); - -// for (let fn of [Buffer.prototype.slice, Buffer.prototype.subarray]) { -// it(`Buffer.${fn.name}`, () => { -// const buf = new Buffer("buffer"); -// const slice = fn.call(buf, 1, 3); -// expect(slice.toString()).toBe("uf"); -// const slice2 = fn.call(slice, 100); -// expect(slice2.toString()).toBe(""); - -// const slice3 = fn.call(slice, -1); -// expect(slice3.toString()).toBe("f"); -// }); -// } - -// it("Buffer.from(base64)", () => { -// const buf = Buffer.from("aGVsbG8gd29ybGQ=", "base64"); -// expect(buf.toString()).toBe("hello world"); - -// expect(Buffer.from(btoa('console.log("hello world")\n'), "base64").toString()).toBe('console.log("hello world")\n'); -// }); - -// it("Buffer.swap16", () => { -// const examples = [ -// ["", ""], -// ["a1", "1a"], -// ["a1b2", "1a2b"], -// ]; - -// for (let i = 0; i < examples.length; i++) { -// const input = examples[i][0]; -// const output = examples[i][1]; -// const buf = Buffer.from(input, "utf-8"); - -// const ref = buf.swap16(); -// expect(ref instanceof Buffer).toBe(true); -// expect(buf.toString()).toBe(output); -// } - -// const buf = Buffer.from("123", "utf-8"); -// try { -// buf.swap16(); -// expect(false).toBe(true); -// } catch (exception) { -// expect(exception.message).toBe("Buffer size must be a multiple of 16-bits"); -// } -// }); - -// it("Buffer.swap32", () => { -// const examples = [ -// ["", ""], -// ["a1b2", "2b1a"], -// ["a1b2c3d4", "2b1a4d3c"], -// ]; - -// for (let i = 0; i < examples.length; i++) { -// const input = examples[i][0]; -// const output = examples[i][1]; -// const buf = Buffer.from(input, "utf-8"); - -// const ref = buf.swap32(); -// expect(ref instanceof Buffer).toBe(true); -// expect(buf.toString()).toBe(output); -// } - -// const buf = Buffer.from("12345", "utf-8"); -// try { -// buf.swap32(); -// expect(false).toBe(true); -// } catch (exception) { -// expect(exception.message).toBe("Buffer size must be a multiple of 32-bits"); -// } -// }); - -// it("Buffer.swap64", () => { -// const examples = [ -// ["", ""], -// ["a1b2c3d4", "4d3c2b1a"], -// ["a1b2c3d4e5f6g7h8", "4d3c2b1a8h7g6f5e"], -// ]; - -// for (let i = 0; i < examples.length; i++) { -// const input = examples[i][0]; -// const output = examples[i][1]; -// const buf = Buffer.from(input, "utf-8"); - -// const ref = buf.swap64(); -// expect(ref instanceof Buffer).toBe(true); -// expect(buf.toString()).toBe(output); -// } - -// const buf = Buffer.from("123456789", "utf-8"); -// try { -// buf.swap64(); -// expect(false).toBe(true); -// } catch (exception) { -// expect(exception.message).toBe("Buffer size must be a multiple of 64-bits"); -// } -// }); - -// it("Buffer.toString regessions", () => { -// expect( -// Buffer.from([65, 0]) -// .toString("utf16le") -// .split("") -// .map(x => x.charCodeAt(0)), -// ).toEqual([65]); -// expect(Buffer.from([65, 0]).toString("base64")).toBe("QQA="); -// expect(Buffer.from('{"alg":"RS256","typ":"JWT"}', "latin1").toString("latin1")).toBe('{"alg":"RS256","typ":"JWT"}'); -// expect(Buffer.from('{"alg":"RS256","typ":"JWT"}', "utf8").toString("utf8")).toBe('{"alg":"RS256","typ":"JWT"}'); -// }); - -// it("Buffer.toString(utf16le)", () => { -// const buf = Buffer.from("hello world", "utf16le"); -// expect(buf.toString("utf16le")).toBe("hello world"); -// expect(buf.toString("utf16le", 0, 5)).toBe("he"); -// }); - -// it("Buffer.toString(binary)", () => { -// var x = Buffer.from(" { -// { -// const buf = Buffer.from("hello world"); -// expect(buf.toString("base64")).toBe("aGVsbG8gd29ybGQ="); -// } - -// { -// expect(Buffer.from(`console.log("hello world")\n`).toString("base64")).toBe(btoa('console.log("hello world")\n')); -// } -// }); - -// it("Buffer can be mocked", () => { -// function MockBuffer() { -// const noop = function () {}; -// const res = Buffer.alloc(0); -// for (const op in Buffer.prototype) { -// if (typeof res[op] === "function") { -// res[op] = noop; -// } -// } -// return res; -// } - -// const buf = MockBuffer(); - -// expect(() => { -// buf.write("hello world"); -// buf.writeUint16BE(0); -// buf.writeUint32BE(0); -// buf.writeBigInt64BE(0); -// buf.writeBigUInt64BE(0); -// buf.writeBigInt64LE(0); -// buf.writeBigUInt64LE(0); -// }).not.toThrow(); -// }); - -// it("constants", () => { -// expect(BufferModule.constants.MAX_LENGTH).toBe(4294967296); -// expect(BufferModule.constants.MAX_STRING_LENGTH).toBe(536870888); -// expect(BufferModule.default.constants.MAX_LENGTH).toBe(4294967296); -// expect(BufferModule.default.constants.MAX_STRING_LENGTH).toBe(536870888); -// }); - -// it("File", () => { -// expect(BufferModule.File).toBe(Blob); -// }); - -// it("transcode", () => { -// expect(typeof BufferModule.transcode).toBe("undefined"); - -// // This is a masqueradesAsUndefined function -// expect(() => BufferModule.transcode()).toThrow("Not implemented"); -// }); - -// it("Buffer.from (Node.js test/test-buffer-from.js)", () => { -// const checkString = "test"; - -// const check = Buffer.from(checkString); - -// class MyString extends String { -// constructor() { -// super(checkString); -// } -// } - -// class MyPrimitive { -// [Symbol.toPrimitive]() { -// return checkString; -// } -// } - -// class MyBadPrimitive { -// [Symbol.toPrimitive]() { -// return 1; -// } -// } - -// expect(Buffer.from(new String(checkString))).toStrictEqual(check); -// expect(Buffer.from(new MyString())).toStrictEqual(check); -// expect(Buffer.from(new MyPrimitive())).toStrictEqual(check); - -// [ -// {}, -// new Boolean(true), -// { -// valueOf() { -// return null; -// }, -// }, -// { -// valueOf() { -// return undefined; -// }, -// }, -// { valueOf: null }, -// Object.create(null), -// new Number(true), -// new MyBadPrimitive(), -// Symbol(), -// 5n, -// (one, two, three) => {}, -// undefined, -// null, -// ].forEach(input => { -// expect(() => Buffer.from(input)).toThrow(); -// expect(() => Buffer.from(input, "hex")).toThrow(); -// }); - -// expect(() => Buffer.allocUnsafe(10)).not.toThrow(); // Should not throw. -// expect(() => Buffer.from("deadbeaf", "hex")).not.toThrow(); // Should not throw. -// }); - -// it("new Buffer() (Node.js test/test-buffer-new.js)", () => { -// const LENGTH = 16; - -// const ab = new ArrayBuffer(LENGTH); -// const dv = new DataView(ab); -// const ui = new Uint8Array(ab); -// const buf = Buffer.from(ab); - -// expect(buf instanceof Buffer).toBe(true); -// // expect(buf.parent, buf.buffer); -// expect(buf.buffer).toBe(ab); -// expect(buf.length).toBe(ab.byteLength); - -// buf.fill(0xc); -// for (let i = 0; i < LENGTH; i++) { -// expect(ui[i]).toBe(0xc); -// ui[i] = 0xf; -// expect(buf[i]).toBe(0xf); -// } - -// buf.writeUInt32LE(0xf00, 0); -// buf.writeUInt32BE(0xb47, 4); -// buf.writeDoubleLE(3.1415, 8); -// expect(dv.getUint32(0, true)).toBe(0xf00); -// expect(dv.getUint32(4)).toBe(0xb47); -// expect(dv.getFloat64(8, true)).toBe(3.1415); - -// // Now test protecting users from doing stupid things - -// // expect(function () { -// // function AB() {} -// // Object.setPrototypeOf(AB, ArrayBuffer); -// // Object.setPrototypeOf(AB.prototype, ArrayBuffer.prototype); -// // // Buffer.from(new AB()); -// // }).toThrow(); -// // console.log(origAB !== ab); - -// // Test the byteOffset and length arguments -// { -// const ab = new Uint8Array(5); -// ab[0] = 1; -// ab[1] = 2; -// ab[2] = 3; -// ab[3] = 4; -// ab[4] = 5; -// const buf = Buffer.from(ab.buffer, 1, 3); -// expect(buf.length).toBe(3); -// expect(buf[0]).toBe(2); -// expect(buf[1]).toBe(3); -// expect(buf[2]).toBe(4); -// buf[0] = 9; -// expect(ab[1]).toBe(9); - -// expect(() => Buffer.from(ab.buffer, 6)).toThrow(); -// expect(() => Buffer.from(ab.buffer, 3, 6)).toThrow(); -// } - -// // Test the deprecated Buffer() version also -// { -// const ab = new Uint8Array(5); -// ab[0] = 1; -// ab[1] = 2; -// ab[2] = 3; -// ab[3] = 4; -// ab[4] = 5; -// const buf = Buffer(ab.buffer, 1, 3); -// expect(buf.length).toBe(3); -// expect(buf[0]).toBe(2); -// expect(buf[1]).toBe(3); -// expect(buf[2]).toBe(4); -// buf[0] = 9; -// expect(ab[1]).toBe(9); - -// expect(() => Buffer(ab.buffer, 6)).toThrow(); -// expect(() => Buffer(ab.buffer, 3, 6)).toThrow(); -// } - -// { -// // If byteOffset is not numeric, it defaults to 0. -// const ab = new ArrayBuffer(10); -// const expected = Buffer.from(ab, 0); -// expect(Buffer.from(ab, "fhqwhgads")).toStrictEqual(expected); -// expect(Buffer.from(ab, NaN)).toStrictEqual(expected); -// expect(Buffer.from(ab, {})).toStrictEqual(expected); -// expect(Buffer.from(ab, [])).toStrictEqual(expected); - -// // If byteOffset can be converted to a number, it will be. -// expect(Buffer.from(ab, [1])).toStrictEqual(Buffer.from(ab, 1)); - -// // If byteOffset is Infinity, throw. -// expect(() => { -// Buffer.from(ab, Infinity); -// }).toThrow(); -// } - -// { -// // If length is not numeric, it defaults to 0. -// const ab = new ArrayBuffer(10); -// const expected = Buffer.from(ab, 0, 0); -// expect(Buffer.from(ab, 0, "fhqwhgads")).toStrictEqual(expected); -// expect(Buffer.from(ab, 0, NaN)).toStrictEqual(expected); -// expect(Buffer.from(ab, 0, {})).toStrictEqual(expected); -// expect(Buffer.from(ab, 0, [])).toStrictEqual(expected); - -// // If length can be converted to a number, it will be. -// expect(Buffer.from(ab, 0, [1])).toStrictEqual(Buffer.from(ab, 0, 1)); - -// // If length is Infinity, throw. -// expect(() => Buffer.from(ab, 0, Infinity)).toThrow(); -// } - -// // Test an array like entry with the length set to NaN. -// expect(Buffer.from({ length: NaN })).toStrictEqual(Buffer.alloc(0)); -// }); - -// it("Buffer.fill (Node.js tests)", () => { -// "use strict"; -// const SIZE = 28; - -// const buf1 = Buffer.allocUnsafe(SIZE); -// const buf2 = Buffer.allocUnsafe(SIZE); - -// function bufReset() { -// buf1.fill(0); -// buf2.fill(0); -// } - -// // This is mostly accurate. Except write() won't write partial bytes to the -// // string while fill() blindly copies bytes into memory. To account for that an -// // error will be thrown if not all the data can be written, and the SIZE has -// // been massaged to work with the input characters. -// function writeToFill(string, offset, end, encoding) { -// if (typeof offset === "string") { -// encoding = offset; -// offset = 0; -// end = buf2.length; -// } else if (typeof end === "string") { -// encoding = end; -// end = buf2.length; -// } else if (end === undefined) { -// end = buf2.length; -// } - -// // Should never be reached. -// if (offset < 0 || end > buf2.length) throw new ERR_OUT_OF_RANGE(); - -// if (end <= offset) return buf2; - -// offset >>>= 0; -// end >>>= 0; -// expect(offset <= buf2.length).toBe(true); - -// // Convert "end" to "length" (which write understands). -// const length = end - offset < 0 ? 0 : end - offset; - -// let wasZero = false; -// do { -// const written = buf2.write(string, offset, length, encoding); -// offset += written; -// // Safety check in case write falls into infinite loop. -// if (written === 0) { -// if (wasZero) throw new Error("Could not write all data to Buffer at " + offset); -// else wasZero = true; -// } -// } while (offset < buf2.length); - -// return buf2; -// } - -// function testBufs(string, offset, length, encoding) { -// bufReset(); -// buf1.fill.apply(buf1, arguments); -// // Swap bytes on BE archs for ucs2 encoding. -// expect(buf1.fill.apply(buf1, arguments)).toStrictEqual(writeToFill.apply(null, arguments)); -// } - -// // Default encoding -// testBufs("abc"); -// testBufs("\u0222aa"); -// testBufs("a\u0234b\u0235c\u0236"); -// testBufs("abc", 4); -// testBufs("abc", 5); -// testBufs("abc", SIZE); -// testBufs("\u0222aa", 2); -// testBufs("\u0222aa", 8); -// testBufs("a\u0234b\u0235c\u0236", 4); -// testBufs("a\u0234b\u0235c\u0236", 12); -// testBufs("abc", 4, 1); -// testBufs("abc", 5, 1); -// testBufs("\u0222aa", 8, 1); -// testBufs("a\u0234b\u0235c\u0236", 4, 1); -// testBufs("a\u0234b\u0235c\u0236", 12, 1); - -// // UTF8 -// testBufs("abc", "utf8"); -// testBufs("\u0222aa", "utf8"); -// testBufs("a\u0234b\u0235c\u0236", "utf8"); -// testBufs("abc", 4, "utf8"); -// testBufs("abc", 5, "utf8"); -// testBufs("abc", SIZE, "utf8"); -// testBufs("\u0222aa", 2, "utf8"); -// testBufs("\u0222aa", 8, "utf8"); -// testBufs("a\u0234b\u0235c\u0236", 4, "utf8"); -// testBufs("a\u0234b\u0235c\u0236", 12, "utf8"); -// testBufs("abc", 4, 1, "utf8"); -// testBufs("abc", 5, 1, "utf8"); -// testBufs("\u0222aa", 8, 1, "utf8"); -// testBufs("a\u0234b\u0235c\u0236", 4, 1, "utf8"); -// testBufs("a\u0234b\u0235c\u0236", 12, 1, "utf8"); -// expect(Buffer.allocUnsafe(1).fill(0).fill("\u0222")[0]).toBe(0xc8); - -// // BINARY -// testBufs("abc", "binary"); -// testBufs("\u0222aa", "binary"); -// testBufs("a\u0234b\u0235c\u0236", "binary"); -// testBufs("abc", 4, "binary"); -// testBufs("abc", 5, "binary"); -// testBufs("abc", SIZE, "binary"); -// testBufs("\u0222aa", 2, "binary"); -// testBufs("\u0222aa", 8, "binary"); -// testBufs("a\u0234b\u0235c\u0236", 4, "binary"); -// testBufs("a\u0234b\u0235c\u0236", 12, "binary"); -// testBufs("abc", 4, 1, "binary"); -// testBufs("abc", 5, 1, "binary"); -// testBufs("\u0222aa", 8, 1, "binary"); -// testBufs("a\u0234b\u0235c\u0236", 4, 1, "binary"); -// testBufs("a\u0234b\u0235c\u0236", 12, 1, "binary"); - -// // LATIN1 -// testBufs("abc", "latin1"); -// testBufs("\u0222aa", "latin1"); -// testBufs("a\u0234b\u0235c\u0236", "latin1"); -// testBufs("abc", 4, "latin1"); -// testBufs("abc", 5, "latin1"); -// testBufs("abc", SIZE, "latin1"); -// testBufs("\u0222aa", 2, "latin1"); -// testBufs("\u0222aa", 8, "latin1"); -// testBufs("a\u0234b\u0235c\u0236", 4, "latin1"); -// testBufs("a\u0234b\u0235c\u0236", 12, "latin1"); -// testBufs("abc", 4, 1, "latin1"); -// testBufs("abc", 5, 1, "latin1"); -// testBufs("\u0222aa", 8, 1, "latin1"); -// testBufs("a\u0234b\u0235c\u0236", 4, 1, "latin1"); -// testBufs("a\u0234b\u0235c\u0236", 12, 1, "latin1"); - -// // UCS2 -// testBufs("abc", "ucs2"); -// testBufs("\u0222aa", "ucs2"); -// testBufs("a\u0234b\u0235c\u0236", "ucs2"); -// testBufs("abc", 4, "ucs2"); -// testBufs("abc", SIZE, "ucs2"); -// testBufs("\u0222aa", 2, "ucs2"); -// testBufs("\u0222aa", 8, "ucs2"); -// testBufs("a\u0234b\u0235c\u0236", 4, "ucs2"); -// testBufs("a\u0234b\u0235c\u0236", 12, "ucs2"); -// testBufs("abc", 4, 1, "ucs2"); -// testBufs("abc", 5, 1, "ucs2"); -// testBufs("\u0222aa", 8, 1, "ucs2"); -// testBufs("a\u0234b\u0235c\u0236", 4, 1, "ucs2"); -// testBufs("a\u0234b\u0235c\u0236", 12, 1, "ucs2"); -// expect(Buffer.allocUnsafe(1).fill("\u0222", "ucs2")[0]).toBe(0x22); - -// // HEX -// testBufs("616263", "hex"); -// testBufs("c8a26161", "hex"); -// testBufs("61c8b462c8b563c8b6", "hex"); -// testBufs("616263", 4, "hex"); -// testBufs("616263", 5, "hex"); -// testBufs("616263", SIZE, "hex"); -// testBufs("c8a26161", 2, "hex"); -// testBufs("c8a26161", 8, "hex"); -// testBufs("61c8b462c8b563c8b6", 4, "hex"); -// testBufs("61c8b462c8b563c8b6", 12, "hex"); -// testBufs("616263", 4, 1, "hex"); -// testBufs("616263", 5, 1, "hex"); -// testBufs("c8a26161", 8, 1, "hex"); -// testBufs("61c8b462c8b563c8b6", 4, 1, "hex"); -// testBufs("61c8b462c8b563c8b6", 12, 1, "hex"); - -// expect(() => { -// const buf = Buffer.allocUnsafe(SIZE); - -// buf.fill("yKJh", "hex"); -// }).toThrow(); - -// expect(() => { -// const buf = Buffer.allocUnsafe(SIZE); - -// buf.fill("\u0222", "hex"); -// }).toThrow(); - -// // BASE64 -// testBufs("YWJj", "base64"); -// testBufs("yKJhYQ==", "base64"); -// testBufs("Yci0Ysi1Y8i2", "base64"); -// testBufs("YWJj", 4, "base64"); -// testBufs("YWJj", SIZE, "base64"); -// testBufs("yKJhYQ==", 2, "base64"); -// testBufs("yKJhYQ==", 8, "base64"); -// testBufs("Yci0Ysi1Y8i2", 4, "base64"); -// testBufs("Yci0Ysi1Y8i2", 12, "base64"); -// testBufs("YWJj", 4, 1, "base64"); -// testBufs("YWJj", 5, 1, "base64"); -// testBufs("yKJhYQ==", 8, 1, "base64"); -// testBufs("Yci0Ysi1Y8i2", 4, 1, "base64"); -// testBufs("Yci0Ysi1Y8i2", 12, 1, "base64"); - -// // BASE64URL -// testBufs("YWJj", "base64url"); -// testBufs("yKJhYQ", "base64url"); -// testBufs("Yci0Ysi1Y8i2", "base64url"); -// testBufs("YWJj", 4, "base64url"); -// testBufs("YWJj", SIZE, "base64url"); -// testBufs("yKJhYQ", 2, "base64url"); -// testBufs("yKJhYQ", 8, "base64url"); -// testBufs("Yci0Ysi1Y8i2", 4, "base64url"); -// testBufs("Yci0Ysi1Y8i2", 12, "base64url"); -// testBufs("YWJj", 4, 1, "base64url"); -// testBufs("YWJj", 5, 1, "base64url"); -// testBufs("yKJhYQ", 8, 1, "base64url"); -// testBufs("Yci0Ysi1Y8i2", 4, 1, "base64url"); -// testBufs("Yci0Ysi1Y8i2", 12, 1, "base64url"); -// }); - -// it("fill() repeat pattern", () => { -// function genBuffer(size, args) { -// const b = Buffer.allocUnsafe(size); -// return b.fill(0).fill.apply(b, args); -// } - -// const buf2Fill = Buffer.allocUnsafe(1).fill(2); -// expect(genBuffer(4, [buf2Fill])).toStrictEqual(Buffer.from([2, 2, 2, 2])); -// expect(genBuffer(4, [buf2Fill, 1])).toStrictEqual(Buffer.from([0, 2, 2, 2])); -// expect(genBuffer(4, [buf2Fill, 1, 3])).toStrictEqual(Buffer.from([0, 2, 2, 0])); -// expect(genBuffer(4, [buf2Fill, 1, 1])).toStrictEqual(Buffer.from([0, 0, 0, 0])); -// const hexBufFill = Buffer.allocUnsafe(2).fill(0).fill("0102", "hex"); -// expect(genBuffer(4, [hexBufFill])).toStrictEqual(Buffer.from([1, 2, 1, 2])); -// expect(genBuffer(4, [hexBufFill, 1])).toStrictEqual(Buffer.from([0, 1, 2, 1])); -// expect(genBuffer(4, [hexBufFill, 1, 3])).toStrictEqual(Buffer.from([0, 1, 2, 0])); -// expect(genBuffer(4, [hexBufFill, 1, 1])).toStrictEqual(Buffer.from([0, 0, 0, 0])); -// }); - -// it("fill() should throw on invalid arguments", () => { -// // Check exceptions -// const buf = Buffer.allocUnsafe(16); -// expect(() => buf.fill(0, -1)).toThrow(RangeError); -// expect(() => buf.fill(0, 0, buf.length + 1)).toThrow(RangeError); -// expect(() => buf.fill("", -1)).toThrow(RangeError); -// expect(() => buf.fill("", 0, buf.length + 1)).toThrow(RangeError); -// expect(() => buf.fill("", 1, -1)).toThrow(RangeError); -// expect(() => buf.fill("a", 0, buf.length, "node rocks!")).toThrow(TypeError); -// expect(() => buf.fill("a", 0, 0, NaN)).toThrow(TypeError); -// expect(() => buf.fill("a", 0, 0, false)).toThrow(TypeError); -// expect(() => buf.fill("a", 0, 0, "foo")).toThrow(TypeError); - -// // Make sure these throw. -// expect(() => Buffer.allocUnsafe(8).fill("a", -1)).toThrow(); -// expect(() => Buffer.allocUnsafe(8).fill("a", 0, 9)).toThrow(); -// }); - -// it("fill() should not hang indefinitely", () => { -// // Make sure this doesn't hang indefinitely. -// Buffer.allocUnsafe(8).fill(""); -// Buffer.alloc(8, ""); -// }); - -// it("fill() repeat byte", () => { -// const buf = Buffer.alloc(64, 10); -// for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe(10); - -// buf.fill(11, 0, buf.length >> 1); -// for (let i = 0; i < buf.length >> 1; i++) expect(buf[i]).toBe(11); -// for (let i = (buf.length >> 1) + 1; i < buf.length; i++) expect(buf[i]).toBe(10); - -// buf.fill("h"); -// for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe("h".charCodeAt(0)); - -// buf.fill(0); -// for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe(0); - -// buf.fill(null); -// for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe(0); - -// buf.fill(1, 16, 32); -// for (let i = 0; i < 16; i++) expect(buf[i]).toBe(0); -// for (let i = 16; i < 32; i++) expect(buf[i]).toBe(1); -// for (let i = 32; i < buf.length; i++) expect(buf[i]).toBe(0); -// }); - -// it("alloc() repeat pattern", () => { -// const buf = Buffer.alloc(10, "abc"); -// expect(buf.toString()).toBe("abcabcabca"); -// buf.fill("է"); -// expect(buf.toString()).toBe("էէէէէ"); -// }); - -// it("fill() should properly check `start` & `end`", () => { -// // // Testing process.binding. Make sure "start" is properly checked for range -// // // errors. -// // expect(() => internalBinding("buffer").fill(Buffer.alloc(1), 1, -1, 0, 1)).toThrow(RangeError); - -// // Make sure "end" is properly checked, even if it's magically mangled using -// // Symbol.toPrimitive. -// expect(() => { -// const end = { -// [Symbol.toPrimitive]() { -// return 1; -// }, -// }; -// Buffer.alloc(1).fill(Buffer.alloc(1), 0, end); -// }).toThrow(TypeError); - -// // Testing process.binding. Make sure "end" is properly checked for range -// // errors. -// // expect(() => internalBinding("buffer").fill(Buffer.alloc(1), 1, 1, -2, 1)).toThrow(RangeError); -// }); - -// it("bypassing `length` should not cause an abort", () => { -// const buf = Buffer.from("w00t"); -// expect(buf).toStrictEqual(Buffer.from([119, 48, 48, 116])); -// Object.defineProperty(buf, "length", { -// value: 1337, -// enumerable: true, -// }); -// // Node.js throws here, but we can handle it just fine -// buf.fill(""); -// expect(buf).toStrictEqual(Buffer.from([0, 0, 0, 0])); -// }); - -// it("allocUnsafeSlow().fill()", () => { -// expect(Buffer.allocUnsafeSlow(16).fill("ab", "utf16le")).toStrictEqual( -// Buffer.from("61006200610062006100620061006200", "hex"), -// ); - -// expect(Buffer.allocUnsafeSlow(15).fill("ab", "utf16le")).toStrictEqual( -// Buffer.from("610062006100620061006200610062", "hex"), -// ); - -// expect(Buffer.allocUnsafeSlow(16).fill("ab", "utf16le")).toStrictEqual( -// Buffer.from("61006200610062006100620061006200", "hex"), -// ); -// expect(Buffer.allocUnsafeSlow(16).fill("a", "utf16le")).toStrictEqual( -// Buffer.from("61006100610061006100610061006100", "hex"), -// ); - -// expect(Buffer.allocUnsafeSlow(16).fill("a", "utf16le").toString("utf16le")).toBe("a".repeat(8)); -// expect(Buffer.allocUnsafeSlow(16).fill("a", "latin1").toString("latin1")).toBe("a".repeat(16)); -// expect(Buffer.allocUnsafeSlow(16).fill("a", "utf8").toString("utf8")).toBe("a".repeat(16)); - -// expect(Buffer.allocUnsafeSlow(16).fill("Љ", "utf16le").toString("utf16le")).toBe("Љ".repeat(8)); -// expect(Buffer.allocUnsafeSlow(16).fill("Љ", "latin1").toString("latin1")).toBe("\t".repeat(16)); -// expect(Buffer.allocUnsafeSlow(16).fill("Љ", "utf8").toString("utf8")).toBe("Љ".repeat(8)); - -// expect(() => { -// const buf = Buffer.from("a".repeat(1000)); - -// buf.fill("This is not correctly encoded", "hex"); -// }).toThrow(); -// }); - -// it("ArrayBuffer.isView()", () => { -// expect(ArrayBuffer.isView(new Buffer(10))).toBe(true); -// expect(ArrayBuffer.isView(new SlowBuffer(10))).toBe(true); -// expect(ArrayBuffer.isView(Buffer.alloc(10))).toBe(true); -// expect(ArrayBuffer.isView(Buffer.allocUnsafe(10))).toBe(true); -// expect(ArrayBuffer.isView(Buffer.allocUnsafeSlow(10))).toBe(true); -// expect(ArrayBuffer.isView(Buffer.from(""))).toBe(true); -// }); - -// it("Buffer.byteLength()", () => { -// expect(() => Buffer.byteLength(32, "latin1")).toThrow(TypeError); -// expect(() => Buffer.byteLength(NaN, "utf8")).toThrow(TypeError); -// expect(() => Buffer.byteLength({}, "latin1")).toThrow(TypeError); -// expect(() => Buffer.byteLength()).toThrow(TypeError); - -// expect(Buffer.byteLength("", undefined, true)).toBe(0); - -// // buffer -// const incomplete = Buffer.from([0xe4, 0xb8, 0xad, 0xe6, 0x96]); -// expect(Buffer.byteLength(incomplete)).toBe(5); -// const ascii = Buffer.from("abc"); -// expect(Buffer.byteLength(ascii)).toBe(3); - -// // ArrayBuffer -// const buffer = new ArrayBuffer(8); -// expect(Buffer.byteLength(buffer)).toBe(8); - -// // TypedArray -// const int8 = new Int8Array(8); -// expect(Buffer.byteLength(int8)).toBe(8); -// const uint8 = new Uint8Array(8); -// expect(Buffer.byteLength(uint8)).toBe(8); -// const uintc8 = new Uint8ClampedArray(2); -// expect(Buffer.byteLength(uintc8)).toBe(2); -// const int16 = new Int16Array(8); -// expect(Buffer.byteLength(int16)).toBe(16); -// const uint16 = new Uint16Array(8); -// expect(Buffer.byteLength(uint16)).toBe(16); -// const int32 = new Int32Array(8); -// expect(Buffer.byteLength(int32)).toBe(32); -// const uint32 = new Uint32Array(8); -// expect(Buffer.byteLength(uint32)).toBe(32); -// const float32 = new Float32Array(8); -// expect(Buffer.byteLength(float32)).toBe(32); -// const float64 = new Float64Array(8); -// expect(Buffer.byteLength(float64)).toBe(64); - -// // DataView -// const dv = new DataView(new ArrayBuffer(2)); -// expect(Buffer.byteLength(dv)).toBe(2); - -// // Special case: zero length string -// expect(Buffer.byteLength("", "ascii")).toBe(0); -// expect(Buffer.byteLength("", "HeX")).toBe(0); - -// // utf8 -// expect(Buffer.byteLength("∑éllö wørl∂!", "utf-8")).toBe(19); -// expect(Buffer.byteLength("κλμνξο", "utf8")).toBe(12); -// expect(Buffer.byteLength("挵挶挷挸挹", "utf-8")).toBe(15); -// expect(Buffer.byteLength("𠝹𠱓𠱸", "UTF8")).toBe(12); -// // Without an encoding, utf8 should be assumed -// expect(Buffer.byteLength("hey there")).toBe(9); -// expect(Buffer.byteLength("𠱸挶νξ#xx :)")).toBe(17); -// expect(Buffer.byteLength("hello world", "")).toBe(11); -// // It should also be assumed with unrecognized encoding -// expect(Buffer.byteLength("hello world", "abc")).toBe(11); -// expect(Buffer.byteLength("ßœ∑≈", "unkn0wn enc0ding")).toBe(10); - -// // base64 -// expect(Buffer.byteLength("aGVsbG8gd29ybGQ=", "base64")).toBe(11); -// expect(Buffer.byteLength("aGVsbG8gd29ybGQ=", "BASE64")).toBe(11); -// expect(Buffer.byteLength("bm9kZS5qcyByb2NrcyE=", "base64")).toBe(14); -// expect(Buffer.byteLength("aGkk", "base64")).toBe(3); -// expect(Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==", "base64")).toBe(25); -// // base64url -// expect(Buffer.byteLength("aGVsbG8gd29ybGQ", "base64url")).toBe(11); -// expect(Buffer.byteLength("aGVsbG8gd29ybGQ", "BASE64URL")).toBe(11); -// expect(Buffer.byteLength("bm9kZS5qcyByb2NrcyE", "base64url")).toBe(14); -// expect(Buffer.byteLength("aGkk", "base64url")).toBe(3); -// expect(Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw", "base64url")).toBe(25); -// // special padding -// expect(Buffer.byteLength("aaa=", "base64")).toBe(2); -// expect(Buffer.byteLength("aaaa==", "base64")).toBe(3); -// expect(Buffer.byteLength("aaa=", "base64url")).toBe(2); -// expect(Buffer.byteLength("aaaa==", "base64url")).toBe(3); -// expect(Buffer.byteLength("Il était tué", "utf8")).toBe(14); -// expect(Buffer.byteLength("Il était tué")).toBe(14); - -// ["ascii", "latin1", "binary"] -// .reduce((es, e) => es.concat(e, e.toUpperCase()), []) -// .forEach(encoding => { -// expect(Buffer.byteLength("Il était tué", encoding)).toBe(12); -// }); - -// ["ucs2", "ucs-2", "utf16le", "utf-16le"] -// .reduce((es, e) => es.concat(e, e.toUpperCase()), []) -// .forEach(encoding => { -// expect(Buffer.byteLength("Il était tué", encoding)).toBe(24); -// }); - -// // Test that ArrayBuffer from a different context is detected correctly -// // const arrayBuf = vm.runInNewContext("new ArrayBuffer()"); -// // expect(Buffer.byteLength(arrayBuf)).toBe(0); - -// // Verify that invalid encodings are treated as utf8 -// for (let i = 1; i < 10; i++) { -// const encoding = String(i).repeat(i); - -// expect(Buffer.isEncoding(encoding)).toBe(false); -// expect(Buffer.byteLength("foo", encoding)).toBe(Buffer.byteLength("foo", "utf8")); -// } -// }); - -// it("Buffer.toString(encoding, start, end)", () => { -// const buf = Buffer.from("0123456789", "utf8"); - -// expect(buf.toString()).toStrictEqual("0123456789"); -// expect(buf.toString("utf8")).toStrictEqual("0123456789"); -// expect(buf.toString("utf8", 3)).toStrictEqual("3456789"); -// expect(buf.toString("utf8", 3, 4)).toStrictEqual("3"); - -// expect(buf.toString("utf8", 3, 100)).toStrictEqual("3456789"); -// expect(buf.toString("utf8", 3, 1)).toStrictEqual(""); -// expect(buf.toString("utf8", 100, 200)).toStrictEqual(""); -// expect(buf.toString("utf8", 100, 1)).toStrictEqual(""); -// }); - -// it("Buffer.toString(offset, length, encoding)", () => { -// const buf = Buffer.from("0123456789", "utf8"); - -// expect(buf.toString(3, 6, "utf8")).toStrictEqual("345678"); -// expect(buf.toString(3, 100, "utf8")).toStrictEqual("3456789"); -// expect(buf.toString(100, 200, "utf8")).toStrictEqual(""); -// expect(buf.toString(100, 50, "utf8")).toStrictEqual(""); -// }); - -// it("Buffer.asciiSlice())", () => { -// const buf = Buffer.from("0123456789", "ascii"); - -// expect(buf.asciiSlice()).toStrictEqual("0123456789"); -// expect(buf.asciiSlice(3)).toStrictEqual("3456789"); -// expect(buf.asciiSlice(3, 4)).toStrictEqual("3"); -// }); - -// it("Buffer.latin1Slice()", () => { -// const buf = Buffer.from("âéö", "latin1"); - -// expect(buf.latin1Slice()).toStrictEqual("âéö"); -// expect(buf.latin1Slice(1)).toStrictEqual("éö"); -// expect(buf.latin1Slice(1, 2)).toStrictEqual("é"); -// }); - -// it("Buffer.utf8Slice()", () => { -// const buf = Buffer.from("あいうえお", "utf8"); - -// expect(buf.utf8Slice()).toStrictEqual("あいうえお"); -// expect(buf.utf8Slice(3)).toStrictEqual("いうえお"); -// expect(buf.utf8Slice(3, 6)).toStrictEqual("い"); -// }); - -// it("Buffer.hexSlice()", () => { -// const buf = Buffer.from("0123456789", "utf8"); - -// expect(buf.hexSlice()).toStrictEqual("30313233343536373839"); -// expect(buf.hexSlice(3)).toStrictEqual("33343536373839"); -// expect(buf.hexSlice(3, 4)).toStrictEqual("33"); -// }); - -// it("Buffer.ucs2Slice()", () => { -// const buf = Buffer.from("あいうえお", "ucs2"); - -// expect(buf.ucs2Slice()).toStrictEqual("あいうえお"); -// expect(buf.ucs2Slice(2)).toStrictEqual("いうえお"); -// expect(buf.ucs2Slice(2, 6)).toStrictEqual("いう"); -// }); - -// it("Buffer.base64Slice()", () => { -// const buf = Buffer.from("0123456789", "utf8"); - -// expect(buf.base64Slice()).toStrictEqual("MDEyMzQ1Njc4OQ=="); -// expect(buf.base64Slice(3)).toStrictEqual("MzQ1Njc4OQ=="); -// expect(buf.base64Slice(3, 4)).toStrictEqual("Mw=="); -// }); - -// it("Buffer.base64urlSlice()", () => { -// const buf = Buffer.from("0123456789", "utf8"); - -// expect(buf.base64urlSlice()).toStrictEqual("MDEyMzQ1Njc4OQ"); -// expect(buf.base64urlSlice(3)).toStrictEqual("MzQ1Njc4OQ"); -// expect(buf.base64urlSlice(3, 4)).toStrictEqual("Mw"); -// }); - -// it("should not crash on invalid UTF-8 byte sequence", () => { -// const buf = Buffer.from([0xc0, 0xfd]); -// expect(buf.length).toBe(2); -// const str = buf.toString(); -// expect(str.length).toBe(2); -// expect(str).toBe("\uFFFD\uFFFD"); -// }); - -// it("should not crash on invalid UTF-8 byte sequence with ASCII head", () => { -// const buf = Buffer.from([0x42, 0xc0, 0xfd]); -// expect(buf.length).toBe(3); -// const str = buf.toString(); -// expect(str.length).toBe(3); -// expect(str).toBe("B\uFFFD\uFFFD"); -// }); - -// it("should not perform out-of-bound access on invalid UTF-8 byte sequence", () => { -// const buf = Buffer.from([0x01, 0x9a, 0x84, 0x13, 0x12, 0x11, 0x10, 0x09]).subarray(2); -// expect(buf.length).toBe(6); -// const str = buf.toString(); -// expect(str.length).toBe(6); -// expect(str).toBe("\uFFFD\x13\x12\x11\x10\x09"); -// }); - -// it("repro #2063", () => { -// const buf = Buffer.from( -// "eyJlbWFpbCI6Ijg3MTg4NDYxN0BxcS5jb20iLCJpZCI6OCwicm9sZSI6Im5vcm1hbCIsImlhdCI6MTY3NjI4NDQyMSwiZXhwIjoxNjc2ODg5MjIxfQ", -// "base64", -// ); -// expect(buf.length).toBe(85); -// expect(buf[82]).toBe(50); -// expect(buf[83]).toBe(49); -// expect(buf[84]).toBe(125); -// }); - -// it("inspect() should exist", () => { -// expect(Buffer.prototype.inspect).toBeInstanceOf(Function); -// expect(new Buffer("123").inspect()).toBe(Bun.inspect(new Buffer("123"))); -// }); - -// it("read alias", () => { -// var buf = new Buffer(1024); -// var data = new DataView(buf.buffer); - -// data.setUint8(0, 200, false); - -// expect(buf.readUint8(0)).toBe(buf.readUInt8(0)); -// expect(buf.readUintBE(0, 4)).toBe(buf.readUIntBE(0, 4)); -// expect(buf.readUintLE(0, 4)).toBe(buf.readUIntLE(0, 4)); -// expect(buf.readUint16BE(0)).toBe(buf.readUInt16BE(0)); -// expect(buf.readUint16LE(0)).toBe(buf.readUInt16LE(0)); -// expect(buf.readUint32BE(0)).toBe(buf.readUInt32BE(0)); -// expect(buf.readUint32LE(0)).toBe(buf.readUInt32LE(0)); -// expect(buf.readBigUint64BE(0)).toBe(buf.readBigUInt64BE(0)); -// expect(buf.readBigUint64LE(0)).toBe(buf.readBigUInt64LE(0)); -// }); - -// it("write alias", () => { -// var buf = new Buffer(1024); -// var buf2 = new Buffer(1024); - -// function reset() { -// new Uint8Array(buf.buffer).fill(0); -// new Uint8Array(buf2.buffer).fill(0); -// } - -// function shouldBeSame(name, name2, ...args) { -// buf[name].call(buf, ...args); -// buf2[name2].call(buf2, ...args); - -// expect(buf).toStrictEqual(buf2); -// reset(); -// } - -// shouldBeSame("writeUint8", "writeUInt8", 10); -// shouldBeSame("writeUintBE", "writeUIntBE", 10, 0, 4); -// shouldBeSame("writeUintLE", "writeUIntLE", 10, 0, 4); -// shouldBeSame("writeUint16BE", "writeUInt16BE", 1000); -// shouldBeSame("writeUint16LE", "writeUInt16LE", 1000); -// shouldBeSame("writeUint32BE", "writeUInt32BE", 1000); -// shouldBeSame("writeUint32LE", "writeUInt32LE", 1000); -// shouldBeSame("writeBigUint64BE", "writeBigUInt64BE", BigInt(1000)); -// shouldBeSame("writeBigUint64LE", "writeBigUInt64LE", BigInt(1000)); -// }); + expect(isAscii(new Buffer("abc"))).toBeTrue(); + expect(isAscii(new Buffer(""))).toBeTrue(); + expect(isAscii(new Buffer([32, 32, 128]))).toBeFalse(); + expect(isAscii(new Buffer("What did the 🦊 say?"))).toBeFalse(); + expect(isAscii(new Buffer("").buffer)).toBeTrue(); + expect(isAscii(new Buffer([32, 32, 128]).buffer)).toBeFalse(); +}); + +it("isUtf8", () => { + expect(isUtf8(new Buffer("abc"))).toBeTrue(); + expect(isAscii(new Buffer(""))).toBeTrue(); + expect(isUtf8(new Buffer("What did the 🦊 say?"))).toBeTrue(); + expect(isUtf8(new Buffer([129, 129, 129]))).toBeFalse(); + + expect(isUtf8(new Buffer("abc").buffer)).toBeTrue(); + expect(isAscii(new Buffer("").buffer)).toBeTrue(); + expect(isUtf8(new Buffer("What did the 🦊 say?").buffer)).toBeTrue(); + expect(isUtf8(new Buffer([129, 129, 129]).buffer)).toBeFalse(); +}); + +// https://github.com/oven-sh/bun/issues/2052 +it("Buffer global is settable", () => { + var prevBuffer = globalThis.Buffer; + globalThis.Buffer = 42; + expect(globalThis.Buffer).toBe(42); + globalThis.Buffer = prevBuffer; + expect(globalThis.Buffer).toBe(BufferModule.Buffer); + expect(globalThis.Buffer).toBe(prevBuffer); +}); + +it("length overflow", () => { + // Verify the maximum Uint8Array size. There is no concrete limit by spec. The + // internal limits should be updated if this fails. + expect(() => new Uint8Array(2 ** 32 + 1)).toThrow(/length/); +}); + +it("truncate input values", () => { + const b = Buffer.allocUnsafe(1024); + expect(b.length).toBe(1024); + + b[0] = -1; + expect(b[0]).toBe(255); + + for (let i = 0; i < 1024; i++) { + b[i] = i; + } + + for (let i = 0; i < 1024; i++) { + expect(i % 256).toBe(b[i]); + } +}); + +it("Buffer.allocUnsafe()", () => { + const c = Buffer.allocUnsafe(512); + expect(c.length).toBe(512); +}); + +it("Buffer.from()", () => { + const d = Buffer.from([]); + expect(d.length).toBe(0); +}); + +it("offset properties", () => { + const b = Buffer.alloc(128); + expect(b.length).toBe(128); + expect(b.byteOffset).toBe(0); + expect(b.offset).toBe(0); +}); + +it("creating a Buffer from a Uint32Array", () => { + const ui32 = new Uint32Array(4).fill(42); + const e = Buffer.from(ui32); + for (const [index, value] of e.entries()) { + expect(value).toBe(ui32[index]); + } +}); + +it("creating a Buffer from a Uint32Array (old constructor)", () => { + const ui32 = new Uint32Array(4).fill(42); + const e = Buffer(ui32); + for (const [key, value] of e.entries()) { + expect(value).toBe(ui32[key]); + } +}); + +it("invalid encoding", () => { + const b = Buffer.allocUnsafe(64); + // Test invalid encoding for Buffer.toString + expect(() => b.toString("invalid")).toThrow(/encoding/); + // Invalid encoding for Buffer.write + expect(() => b.write("test string", 0, 5, "invalid")).toThrow(/encoding/); + // Unsupported arguments for Buffer.write + expect(() => b.write("test", "utf8", 0)).toThrow(/invalid/i); +}); + +it("create 0-length buffers", () => { + Buffer.from(""); + Buffer.from("", "ascii"); + Buffer.from("", "latin1"); + Buffer.alloc(0); + Buffer.allocUnsafe(0); + new Buffer(""); + new Buffer("", "ascii"); + new Buffer("", "latin1"); + new Buffer("", "binary"); + Buffer(0); +}); + +it("write() beyond end of buffer", () => { + const b = Buffer.allocUnsafe(64); + // Try to write a 0-length string beyond the end of b + expect(() => b.write("", 2048)).toThrow(RangeError); + // Throw when writing to negative offset + expect(() => b.write("a", -1)).toThrow(RangeError); + // Throw when writing past bounds from the pool + expect(() => b.write("a", 2048)).toThrow(RangeError); + // Throw when writing to negative offset + expect(() => b.write("a", -1)).toThrow(RangeError); + // Offset points to the end of the buffer and does not throw. + // (see https://github.com/nodejs/node/issues/8127). + Buffer.alloc(1).write("", 1, 0); +}); + +it("copy() beyond end of buffer", () => { + const b = Buffer.allocUnsafe(64); + // Try to copy 0 bytes worth of data into an empty buffer + b.copy(Buffer.alloc(0), 0, 0, 0); + // Try to copy 0 bytes past the end of the target buffer + b.copy(Buffer.alloc(0), 1, 1, 1); + b.copy(Buffer.alloc(1), 1, 1, 1); + // Try to copy 0 bytes from past the end of the source buffer + b.copy(Buffer.alloc(1), 0, 2048, 2048); +}); + +it("smart defaults and ability to pass string values as offset", () => { + const writeTest = Buffer.from("abcdes"); + writeTest.write("n", "ascii"); + expect(() => writeTest.write("o", "1", "ascii")).toThrow(/offset/); + writeTest.write("o", 1, "ascii"); + writeTest.write("d", 2, "ascii"); + writeTest.write("e", 3, "ascii"); + writeTest.write("j", 4, "ascii"); + expect(writeTest.toString()).toBe("nodejs"); +}); + +it("ASCII slice", () => { + const buf = Buffer.allocUnsafe(256); + const str = "hello world"; + for (let i = 0; i < str.length; i++) { + buf[i] = str.charCodeAt(i); + } + expect(buf.toString("ascii", 0, str.length)).toBe(str); + + const offset = 100; + expect(buf.write(str, offset, "ascii")).toBe(str.length); + expect(buf.toString("ascii", offset, offset + str.length)).toBe(str); + + const slice1 = buf.slice(offset, offset + str.length); + const slice2 = buf.slice(offset, offset + str.length); + for (let i = 0; i < str.length; i++) { + expect(slice1[i]).toBe(slice2[i]); + } +}); + +it("UTF-8 slice", () => { + const b = Buffer.allocUnsafe(256); + const utf8String = "¡hέlló wôrld!"; + const offset = 100; + + b.write(utf8String, 0, Buffer.byteLength(utf8String), "utf8"); + expect(b.toString("utf8", 0, Buffer.byteLength(utf8String))).toBe(utf8String); + + expect(b.write(utf8String, offset, "utf8")).toBe(Buffer.byteLength(utf8String)); + expect(b.toString("utf8", offset, offset + Buffer.byteLength(utf8String))).toBe(utf8String); + + const sliceA = b.slice(offset, offset + Buffer.byteLength(utf8String)); + const sliceB = b.slice(offset, offset + Buffer.byteLength(utf8String)); + for (let i = 0; i < Buffer.byteLength(utf8String); i++) { + expect(sliceA[i]).toBe(sliceB[i]); + } + + const slice = b.slice(100, 150); + expect(slice.length).toBe(50); + for (let i = 0; i < 50; i++) { + expect(b[100 + i]).toBe(slice[i]); + } +}); + +it("only top level parent propagates from allocPool", () => { + const b = Buffer.allocUnsafe(5); + const c = b.slice(0, 4); + const d = c.slice(0, 2); + expect(b.parent).toBe(c.parent); + expect(b.parent).toBe(d.parent); +}); + +it("only top level parent propagates from a non-pooled instance", () => { + const b = Buffer.allocUnsafeSlow(5); + const c = b.slice(0, 4); + const d = c.slice(0, 2); + expect(c.parent).toBe(d.parent); +}); + +it("UTF-8 write() & slice()", () => { + const testValue = "\u00F6\u65E5\u672C\u8A9E"; // ö日本語 + const buffer = Buffer.allocUnsafe(32); + const size = buffer.write(testValue, 0, "utf8"); + const slice = buffer.toString("utf8", 0, size); + expect(slice).toBe(testValue); +}); + +it("triple slice", () => { + const a = Buffer.allocUnsafe(8); + for (let i = 0; i < 8; i++) a[i] = i; + const b = a.slice(4, 8); + expect(b[0]).toBe(4); + expect(b[1]).toBe(5); + expect(b[2]).toBe(6); + expect(b[3]).toBe(7); + const c = b.slice(2, 4); + expect(c[0]).toBe(6); + expect(c[1]).toBe(7); +}); + +it("Buffer.from() with encoding", () => { + const b = Buffer.from([23, 42, 255]); + expect(b.length).toBe(3); + expect(b[0]).toBe(23); + expect(b[1]).toBe(42); + expect(b[2]).toBe(255); + expect(Buffer.from(b)).toStrictEqual(b); + + // Test for proper UTF-8 Encoding + expect(Buffer.from("über")).toStrictEqual(Buffer.from([195, 188, 98, 101, 114])); + + // Test for proper ascii Encoding, length should be 4 + expect(Buffer.from("über", "ascii")).toStrictEqual(Buffer.from([252, 98, 101, 114])); + + ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => { + // Test for proper UTF16LE encoding, length should be 8 + expect(Buffer.from("über", encoding)).toStrictEqual(Buffer.from([252, 0, 98, 0, 101, 0, 114, 0])); + + // Length should be 12 + const b = Buffer.from("привет", encoding); + expect(b).toStrictEqual(Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4])); + expect(b.toString(encoding)).toBe("привет"); + + const c = Buffer.from([0, 0, 0, 0, 0]); + expect(c.length).toBe(5); + expect(c.write("あいうえお", encoding)).toBe(4); + expect(c).toStrictEqual(Buffer.from([0x42, 0x30, 0x44, 0x30, 0x00])); + }); + + const c = Buffer.from("\uD83D\uDC4D", "utf-16le"); // THUMBS UP SIGN (U+1F44D) + expect(c.length).toBe(4); + expect(c).toStrictEqual(Buffer.from("3DD84DDC", "hex")); +}); + +it("construction from arrayish object", () => { + const arrayIsh = { 0: 0, 1: 1, 2: 2, 3: 3, length: 4 }; + expect(Buffer.from(arrayIsh)).toStrictEqual(Buffer.from([0, 1, 2, 3])); + const strArrayIsh = { 0: "0", 1: "1", 2: "2", 3: "3", length: 4 }; + expect(Buffer.from(strArrayIsh)).toStrictEqual(Buffer.from([0, 1, 2, 3])); +}); + +it("toString('base64')", () => { + expect(Buffer.from("Man").toString("base64")).toBe("TWFu"); + expect(Buffer.from("Woman").toString("base64")).toBe("V29tYW4="); +}); + +it("toString('base64url')", () => { + expect(Buffer.from("Man").toString("base64url")).toBe("TWFu"); + expect(Buffer.from("Woman").toString("base64url")).toBe("V29tYW4"); +}); + +it("regular and URL-safe base64 work both ways", () => { + const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]; + expect(Buffer.from("//++/++/++//", "base64")).toStrictEqual(Buffer.from(expected)); + expect(Buffer.from("__--_--_--__", "base64")).toStrictEqual(Buffer.from(expected)); + expect(Buffer.from("//++/++/++//", "base64url")).toStrictEqual(Buffer.from(expected)); + expect(Buffer.from("__--_--_--__", "base64url")).toStrictEqual(Buffer.from(expected)); +}); + +it("regular and URL-safe base64 work both ways with padding", () => { + const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff, 0xfb]; + expect(Buffer.from("//++/++/++//+w==", "base64")).toStrictEqual(Buffer.from(expected)); + expect(Buffer.from("//++/++/++//+w==", "base64")).toStrictEqual(Buffer.from(expected)); + expect(Buffer.from("//++/++/++//+w==", "base64url")).toStrictEqual(Buffer.from(expected)); + expect(Buffer.from("//++/++/++//+w==", "base64url")).toStrictEqual(Buffer.from(expected)); +}); + +it("big example (base64 & base64url)", () => { + const quote = + "Man is distinguished, not only by his reason, but by this " + + "singular passion from other animals, which is a lust " + + "of the mind, that by a perseverance of delight in the " + + "continued and indefatigable generation of knowledge, " + + "exceeds the short vehemence of any carnal pleasure."; + const expected = + "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb" + + "24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci" + + "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQ" + + "gYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu" + + "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ" + + "GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm" + + "5hbCBwbGVhc3VyZS4="; + + expect(Buffer.from(quote).toString("base64")).toBe(expected); + expect(Buffer.from(quote).toString("base64url")).toBe( + expected.replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", ""), + ); +}); + +function forEachBase64(label, test) { + ["base64", "base64url"].forEach(encoding => it(`${label} (${encoding})`, test.bind(null, encoding))); +} + +forEachBase64("big example", encoding => { + const quote = + "Man is distinguished, not only by his reason, but by this " + + "singular passion from other animals, which is a lust " + + "of the mind, that by a perseverance of delight in the " + + "continued and indefatigable generation of knowledge, " + + "exceeds the short vehemence of any carnal pleasure."; + const expected = + "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb" + + "24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlci" + + "BhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQ" + + "gYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGlu" + + "dWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZ" + + "GdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm" + + "5hbCBwbGVhc3VyZS4="; + + const b = Buffer.allocUnsafe(1024); + expect(b.write(expected, 0, encoding)).toBe(quote.length); + expect(b.toString("ascii", 0, quote.length)).toBe(quote); + + // Check that the base64 decoder ignores whitespace + const white = + `${expected.slice(0, 60)} \n` + + `${expected.slice(60, 120)} \n` + + `${expected.slice(120, 180)} \n` + + `${expected.slice(180, 240)} \n` + + `${expected.slice(240, 300)}\n` + + `${expected.slice(300, 360)}\n`; + const c = Buffer.allocUnsafe(1024); + expect(c.write(white, 0, encoding)).toBe(quote.length); + expect(c.toString("ascii", 0, quote.length)).toBe(quote); + + // Check that the base64 decoder on the constructor works + // even in the presence of whitespace. + const d = Buffer.from(white, encoding); + expect(d.length).toBe(quote.length); + expect(d.toString("ascii", 0, quote.length)).toBe(quote); + + // Check that the base64 decoder ignores illegal chars + const illegal = + expected.slice(0, 60) + + " \x80" + + expected.slice(60, 120) + + " \xff" + + expected.slice(120, 180) + + " \x00" + + expected.slice(180, 240) + + " \x98" + + expected.slice(240, 300) + + "\x03" + + expected.slice(300, 360); + const e = Buffer.from(illegal, encoding); + expect(e.length).toBe(quote.length); + expect(e.toString("ascii", 0, quote.length)).toBe(quote); +}); + +forEachBase64("padding", encoding => { + expect(Buffer.from("", encoding).toString()).toBe(""); + expect(Buffer.from("K", encoding).toString()).toBe(""); + // multiple-of-4 with padding + expect(Buffer.from("Kg==", encoding).toString()).toBe("*"); + expect(Buffer.from("Kio=", encoding).toString()).toBe("*".repeat(2)); + expect(Buffer.from("Kioq", encoding).toString()).toBe("*".repeat(3)); + expect(Buffer.from("KioqKg==", encoding).toString()).toBe("*".repeat(4)); + expect(Buffer.from("KioqKio=", encoding).toString()).toBe("*".repeat(5)); + expect(Buffer.from("KioqKioq", encoding).toString()).toBe("*".repeat(6)); + expect(Buffer.from("KioqKioqKg==", encoding).toString()).toBe("*".repeat(7)); + expect(Buffer.from("KioqKioqKio=", encoding).toString()).toBe("*".repeat(8)); + expect(Buffer.from("KioqKioqKioq", encoding).toString()).toBe("*".repeat(9)); + expect(Buffer.from("KioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(10)); + expect(Buffer.from("KioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(11)); + expect(Buffer.from("KioqKioqKioqKioq", encoding).toString()).toBe("*".repeat(12)); + expect(Buffer.from("KioqKioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(13)); + expect(Buffer.from("KioqKioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(14)); + expect(Buffer.from("KioqKioqKioqKioqKioq", encoding).toString()).toBe("*".repeat(15)); + expect(Buffer.from("KioqKioqKioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(16)); + expect(Buffer.from("KioqKioqKioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(17)); + expect(Buffer.from("KioqKioqKioqKioqKioqKioq", encoding).toString()).toBe("*".repeat(18)); + expect(Buffer.from("KioqKioqKioqKioqKioqKioqKg==", encoding).toString()).toBe("*".repeat(19)); + expect(Buffer.from("KioqKioqKioqKioqKioqKioqKio=", encoding).toString()).toBe("*".repeat(20)); + // No padding, not a multiple of 4 + expect(Buffer.from("Kg", encoding).toString()).toBe("*"); + expect(Buffer.from("Kio", encoding).toString()).toBe("*".repeat(2)); + expect(Buffer.from("KioqKg", encoding).toString()).toBe("*".repeat(4)); + expect(Buffer.from("KioqKio", encoding).toString()).toBe("*".repeat(5)); + expect(Buffer.from("KioqKioqKg", encoding).toString()).toBe("*".repeat(7)); + expect(Buffer.from("KioqKioqKio", encoding).toString()).toBe("*".repeat(8)); + expect(Buffer.from("KioqKioqKioqKg", encoding).toString()).toBe("*".repeat(10)); + expect(Buffer.from("KioqKioqKioqKio", encoding).toString()).toBe("*".repeat(11)); + expect(Buffer.from("KioqKioqKioqKioqKg", encoding).toString()).toBe("*".repeat(13)); + expect(Buffer.from("KioqKioqKioqKioqKio", encoding).toString()).toBe("*".repeat(14)); + expect(Buffer.from("KioqKioqKioqKioqKioqKg", encoding).toString()).toBe("*".repeat(16)); + expect(Buffer.from("KioqKioqKioqKioqKioqKio", encoding).toString()).toBe("*".repeat(17)); + expect(Buffer.from("KioqKioqKioqKioqKioqKioqKg", encoding).toString()).toBe("*".repeat(19)); + expect(Buffer.from("KioqKioqKioqKioqKioqKioqKio", encoding).toString()).toBe("*".repeat(20)); + // Handle padding graciously, multiple-of-4 or not + expect(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==", encoding).length).toBe(32); + expect(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw==", encoding).length).toBe(32); + expect(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=", encoding).length).toBe(32); + expect(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw=", encoding).length).toBe(32); + expect(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw", encoding).length).toBe(32); + expect(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw", encoding).length).toBe(32); + expect(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==", encoding).length).toBe(31); + expect(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=", encoding).length).toBe(31); + expect(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg", encoding).length).toBe(31); +}); + +it("encodes single '.' character in UTF-16", () => { + const padded = Buffer.from("//4uAA==", "base64"); + expect(padded[0]).toBe(0xff); + expect(padded[1]).toBe(0xfe); + expect(padded[2]).toBe(0x2e); + expect(padded[3]).toBe(0x00); + expect(padded.toString("base64")).toBe("//4uAA=="); + + const dot = Buffer.from("//4uAA", "base64url"); + expect(dot[0]).toBe(0xff); + expect(dot[1]).toBe(0xfe); + expect(dot[2]).toBe(0x2e); + expect(dot[3]).toBe(0x00); + expect(dot.toString("base64url")).toBe("__4uAA"); +}); + +// https://github.com/joyent/node/issues/402 +it("writing base64 at a position > 0 should not mangle the result", () => { + const segments = ["TWFkbmVzcz8h", "IFRoaXM=", "IGlz", "IG5vZGUuanMh"]; + const b = Buffer.allocUnsafe(64); + let pos = 0; + + for (let i = 0; i < segments.length; ++i) { + pos += b.write(segments[i], pos, "base64"); + } + expect(b.toString("latin1", 0, pos)).toBe("Madness?! This is node.js!"); +}); + +// https://github.com/joyent/node/issues/402 +it("writing base64url at a position > 0 should not mangle the result", () => { + const segments = ["TWFkbmVzcz8h", "IFRoaXM", "IGlz", "IG5vZGUuanMh"]; + const b = Buffer.allocUnsafe(64); + let pos = 0; + + for (let i = 0; i < segments.length; ++i) { + pos += b.write(segments[i], pos, "base64url"); + } + expect(b.toString("latin1", 0, pos)).toBe("Madness?! This is node.js!"); +}); + +it("regression tests from Node.js", () => { + // Regression test for https://github.com/nodejs/node/issues/3496. + expect(Buffer.from("=bad".repeat(1e4), "base64").length).toBe(0); + // Regression test for https://github.com/nodejs/node/issues/11987. + expect(Buffer.from("w0 ", "base64")).toStrictEqual(Buffer.from("w0", "base64")); + // Regression test for https://github.com/nodejs/node/issues/13657. + expect(Buffer.from(" YWJvcnVtLg", "base64")).toStrictEqual(Buffer.from("YWJvcnVtLg", "base64")); + // issue GH-3416 + Buffer.from(Buffer.allocUnsafe(0), 0, 0); + // Regression test for https://github.com/nodejs/node-v0.x-archive/issues/5482: + // should throw but not assert in C++ land. + expect(() => Buffer.from("", "buffer")).toThrow(/encoding/); +}); + +it("creating buffers larger than pool size", () => { + const l = Buffer.poolSize + 5; + const s = "h".repeat(l); + const b = Buffer.from(s); + + for (let i = 0; i < l; i++) { + expect(b[i]).toBe("h".charCodeAt(0)); + } + + const sb = b.toString(); + expect(sb.length).toBe(s.length); + expect(sb).toBe(s); +}); + +it("hex toString()", () => { + const hexb = Buffer.allocUnsafe(256); + for (let i = 0; i < 256; i++) { + hexb[i] = i; + } + const hexStr = hexb.toString("hex"); + expect(hexStr).toBe( + "000102030405060708090a0b0c0d0e0f" + + "101112131415161718191a1b1c1d1e1f" + + "202122232425262728292a2b2c2d2e2f" + + "303132333435363738393a3b3c3d3e3f" + + "404142434445464748494a4b4c4d4e4f" + + "505152535455565758595a5b5c5d5e5f" + + "606162636465666768696a6b6c6d6e6f" + + "707172737475767778797a7b7c7d7e7f" + + "808182838485868788898a8b8c8d8e8f" + + "909192939495969798999a9b9c9d9e9f" + + "a0a1a2a3a4a5a6a7a8a9aaabacadaeaf" + + "b0b1b2b3b4b5b6b7b8b9babbbcbdbebf" + + "c0c1c2c3c4c5c6c7c8c9cacbcccdcecf" + + "d0d1d2d3d4d5d6d7d8d9dadbdcdddedf" + + "e0e1e2e3e4e5e6e7e8e9eaebecedeeef" + + "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", + ); + + const hexb2 = Buffer.from(hexStr, "hex"); + for (let i = 0; i < 256; i++) { + expect(hexb2[i]).toBe(hexb[i]); + } +}); + +it("single hex character is discarded", () => { + expect(Buffer.from("A", "hex").length).toBe(0); +}); + +it("if a trailing character is discarded, rest of string is processed", () => { + expect(Buffer.from("Abx", "hex")).toEqual(Buffer.from("Ab", "hex")); +}); + +it("single base64 char encodes as 0", () => { + expect(Buffer.from("A", "base64").length).toBe(0); +}); + +it("invalid slice end", () => { + const b = Buffer.from([1, 2, 3, 4, 5]); + const b2 = b.toString("hex", 1, 10000); + const b3 = b.toString("hex", 1, 5); + const b4 = b.toString("hex", 1); + expect(b2).toBe(b3); + expect(b2).toBe(b4); +}); + +it("slice()", () => { + function buildBuffer(data) { + if (Array.isArray(data)) { + const buffer = Buffer.allocUnsafe(data.length); + data.forEach((v, k) => (buffer[k] = v)); + return buffer; + } + return null; + } + + const x = buildBuffer([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72]); + expect(x).toStrictEqual(Buffer.from([0x81, 0xa3, 0x66, 0x6f, 0x6f, 0xa3, 0x62, 0x61, 0x72])); + + const a = x.slice(4); + expect(a.length).toBe(5); + expect(a[0]).toBe(0x6f); + expect(a[1]).toBe(0xa3); + expect(a[2]).toBe(0x62); + expect(a[3]).toBe(0x61); + expect(a[4]).toBe(0x72); + + const b = x.slice(0); + expect(b.length).toBe(x.length); + + const c = x.slice(0, 4); + expect(c.length).toBe(4); + expect(c[0]).toBe(0x81); + expect(c[1]).toBe(0xa3); + + const d = x.slice(0, 9); + expect(d.length).toBe(9); + + const e = x.slice(1, 4); + expect(e.length).toBe(3); + expect(e[0]).toBe(0xa3); + + const f = x.slice(2, 4); + expect(f.length).toBe(2); + expect(f[0]).toBe(0x66); + expect(f[1]).toBe(0x6f); +}); + +function forEachUnicode(label, test) { + ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => it(`${label} (${encoding})`, test.bind(null, encoding))); +} + +forEachUnicode("write()", encoding => { + const b = Buffer.allocUnsafe(10); + b.write("あいうえお", encoding); + expect(b.toString(encoding)).toBe("あいうえお"); +}); + +forEachUnicode("write() with offset", encoding => { + const b = Buffer.allocUnsafe(11); + b.write("あいうえお", 1, encoding); + expect(b.toString(encoding, 1)).toBe("あいうえお"); +}); + +it("latin1 encoding should write only one byte per character", () => { + const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]); + b.write(String.fromCharCode(0xffff), 0, "latin1"); + expect(b[0]).toBe(0xff); + expect(b[1]).toBe(0xad); + expect(b[2]).toBe(0xbe); + expect(b[3]).toBe(0xef); + b.write(String.fromCharCode(0xaaee), 0, "latin1"); + expect(b[0]).toBe(0xee); + expect(b[1]).toBe(0xad); + expect(b[2]).toBe(0xbe); + expect(b[3]).toBe(0xef); +}); + +it("binary encoding should write only one byte per character", () => { + const b = Buffer.from([0xde, 0xad, 0xbe, 0xef]); + b.write(String.fromCharCode(0xffff), 0, "latin1"); + expect(b[0]).toBe(0xff); + expect(b[1]).toBe(0xad); + expect(b[2]).toBe(0xbe); + expect(b[3]).toBe(0xef); + b.write(String.fromCharCode(0xaaee), 0, "latin1"); + expect(b[0]).toBe(0xee); + expect(b[1]).toBe(0xad); + expect(b[2]).toBe(0xbe); + expect(b[3]).toBe(0xef); +}); + +it("UTF-8 string includes null character", () => { + // https://github.com/nodejs/node-v0.x-archive/pull/1210 + expect(Buffer.from("\0").length).toBe(1); + expect(Buffer.from("\0\0").length).toBe(2); +}); + +it("truncate write() at character boundary", () => { + const buf = Buffer.allocUnsafe(2); + expect(buf.write("")).toBe(0); // 0bytes + expect(buf.write("\0")).toBe(1); // 1byte (v8 adds null terminator) + expect(buf.write("a\0")).toBe(2); // 1byte * 2 + expect(buf.write("あ")).toBe(0); // 3bytes + expect(buf.write("\0あ")).toBe(1); // 1byte + 3bytes + expect(buf.write("\0\0あ")).toBe(2); // 1byte * 2 + 3bytes + + const buf2 = Buffer.allocUnsafe(10); + expect(buf2.write("あいう")).toBe(9); // 3bytes * 3 (v8 adds null term.) + expect(buf2.write("あいう\0")).toBe(10); // 3bytes * 3 + 1byte +}); + +it("write() with maxLength", () => { + // https://github.com/nodejs/node-v0.x-archive/issues/243 + const buf = Buffer.allocUnsafe(4); + buf.fill(0xff); + expect(buf.write("abcd", 1, 2, "utf8")).toBe(2); + expect(buf[0]).toBe(0xff); + expect(buf[1]).toBe(0x61); + expect(buf[2]).toBe(0x62); + expect(buf[3]).toBe(0xff); + + buf.fill(0xff); + expect(buf.write("abcd", 1, 4)).toBe(3); + expect(buf[0]).toBe(0xff); + expect(buf[1]).toBe(0x61); + expect(buf[2]).toBe(0x62); + expect(buf[3]).toBe(0x63); + + buf.fill(0xff); + expect(buf.write("abcd", 1, 2, "utf8")).toBe(2); + expect(buf[0]).toBe(0xff); + expect(buf[1]).toBe(0x61); + expect(buf[2]).toBe(0x62); + expect(buf[3]).toBe(0xff); + + buf.fill(0xff); + expect(buf.write("abcdef", 1, 2, "hex")).toBe(2); + expect(buf[0]).toBe(0xff); + expect(buf[1]).toBe(0xab); + expect(buf[2]).toBe(0xcd); + expect(buf[3]).toBe(0xff); + + ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => { + buf.fill(0xff); + expect(buf.write("abcd", 0, 2, encoding)).toBe(2); + expect(buf[0]).toBe(0x61); + expect(buf[1]).toBe(0x00); + expect(buf[2]).toBe(0xff); + expect(buf[3]).toBe(0xff); + }); +}); + +it("offset returns are correct", () => { + const b = Buffer.allocUnsafe(16); + expect(b.writeUInt32LE(0, 0)).toBe(4); + expect(b.writeUInt16LE(0, 4)).toBe(6); + expect(b.writeUInt8(0, 6)).toBe(7); + expect(b.writeInt8(0, 7)).toBe(8); + expect(b.writeDoubleLE(0, 8)).toBe(16); +}); + +it("unmatched surrogates should not produce invalid utf8 output", () => { + // ef bf bd = utf-8 representation of unicode replacement character + // see https://codereview.chromium.org/121173009/ + let buf = Buffer.from("ab\ud800cd", "utf8"); + expect(buf[0]).toBe(0x61); + expect(buf[1]).toBe(0x62); + expect(buf[2]).toBe(0xef); + expect(buf[3]).toBe(0xbf); + expect(buf[4]).toBe(0xbd); + expect(buf[5]).toBe(0x63); + expect(buf[6]).toBe(0x64); + + buf = Buffer.from("abcd\ud800", "utf8"); + expect(buf[0]).toBe(0x61); + expect(buf[1]).toBe(0x62); + expect(buf[2]).toBe(0x63); + expect(buf[3]).toBe(0x64); + expect(buf[4]).toBe(0xef); + expect(buf[5]).toBe(0xbf); + expect(buf[6]).toBe(0xbd); + + buf = Buffer.from("\ud800abcd", "utf8"); + expect(buf[0]).toBe(0xef); + expect(buf[1]).toBe(0xbf); + expect(buf[2]).toBe(0xbd); + expect(buf[3]).toBe(0x61); + expect(buf[4]).toBe(0x62); + expect(buf[5]).toBe(0x63); + expect(buf[6]).toBe(0x64); +}); + +it("buffer overrun", () => { + const buf = Buffer.from([0, 0, 0, 0, 0]); // length: 5 + const sub = buf.slice(0, 4); // length: 4 + expect(sub.write("12345", "latin1")).toBe(4); + expect(buf[4]).toBe(0); + expect(sub.write("12345", "binary")).toBe(4); + expect(buf[4]).toBe(0); +}); + +it("alloc with fill option", () => { + const buf = Buffer.alloc(5, "800A", "hex"); + expect(buf[0]).toBe(128); + expect(buf[1]).toBe(10); + expect(buf[2]).toBe(128); + expect(buf[3]).toBe(10); + expect(buf[4]).toBe(128); +}); + +// https://github.com/joyent/node/issues/1758 +it("check for fractional length args, junk length args, etc.", () => { + // Call .fill() first, stops valgrind warning about uninitialized memory reads. + Buffer.allocUnsafe(3.3).fill().toString(); + // Throws bad argument error in commit 43cb4ec + Buffer.alloc(3.3).fill().toString(); + expect(Buffer.allocUnsafe(3.3).length).toBe(3); + expect(Buffer.from({ length: 3.3 }).length).toBe(3); + expect(Buffer.from({ length: "BAM" }).length).toBe(0); + // Make sure that strings are not coerced to numbers. + expect(Buffer.from("99").length).toBe(2); + expect(Buffer.from("13.37").length).toBe(5); + // Ensure that the length argument is respected. + ["ascii", "utf8", "hex", "base64", "latin1", "binary"].forEach(enc => { + expect(Buffer.allocUnsafe(1).write("aaaaaa", 0, 1, enc)).toBe(1); + }); + // Regression test, guard against buffer overrun in the base64 decoder. + const a = Buffer.allocUnsafe(3); + const b = Buffer.from("xxx"); + a.write("aaaaaaaa", "base64"); + expect(b.toString()).toBe("xxx"); +}); + +it("buffer overflow", () => { + // issue GH-5587 + expect(() => Buffer.alloc(8).writeFloatLE(0, 5)).toThrow(RangeError); + expect(() => Buffer.alloc(16).writeDoubleLE(0, 9)).toThrow(RangeError); + // Attempt to overflow buffers, similar to previous bug in array buffers + expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff)).toThrow(RangeError); + expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff)).toThrow(RangeError); + // Ensure negative values can't get past offset + expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1)).toThrow(RangeError); + expect(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1)).toThrow(RangeError); +}); + +it("common write{U}IntLE/BE()", () => { + let buf = Buffer.allocUnsafe(3); + buf.writeUIntLE(0x123456, 0, 3); + expect(buf.toJSON().data).toEqual([0x56, 0x34, 0x12]); + expect(buf.readUIntLE(0, 3)).toBe(0x123456); + + buf.fill(0xff); + buf.writeUIntBE(0x123456, 0, 3); + expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56]); + expect(buf.readUIntBE(0, 3)).toBe(0x123456); + + buf.fill(0xff); + buf.writeIntLE(0x123456, 0, 3); + expect(buf.toJSON().data).toEqual([0x56, 0x34, 0x12]); + expect(buf.readIntLE(0, 3)).toBe(0x123456); + + buf.fill(0xff); + buf.writeIntBE(0x123456, 0, 3); + expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56]); + expect(buf.readIntBE(0, 3)).toBe(0x123456); + + buf.fill(0xff); + buf.writeIntLE(-0x123456, 0, 3); + expect(buf.toJSON().data).toEqual([0xaa, 0xcb, 0xed]); + expect(buf.readIntLE(0, 3)).toBe(-0x123456); + + buf.fill(0xff); + buf.writeIntBE(-0x123456, 0, 3); + expect(buf.toJSON().data).toEqual([0xed, 0xcb, 0xaa]); + expect(buf.readIntBE(0, 3)).toBe(-0x123456); + + buf.fill(0xff); + buf.writeIntLE(-0x123400, 0, 3); + expect(buf.toJSON().data).toEqual([0x00, 0xcc, 0xed]); + expect(buf.readIntLE(0, 3)).toBe(-0x123400); + + buf.fill(0xff); + buf.writeIntBE(-0x123400, 0, 3); + expect(buf.toJSON().data).toEqual([0xed, 0xcc, 0x00]); + expect(buf.readIntBE(0, 3)).toBe(-0x123400); + + buf.fill(0xff); + buf.writeIntLE(-0x120000, 0, 3); + expect(buf.toJSON().data).toEqual([0x00, 0x00, 0xee]); + expect(buf.readIntLE(0, 3)).toBe(-0x120000); + + buf.fill(0xff); + buf.writeIntBE(-0x120000, 0, 3); + expect(buf.toJSON().data).toEqual([0xee, 0x00, 0x00]); + expect(buf.readIntBE(0, 3)).toBe(-0x120000); + + buf = Buffer.allocUnsafe(5); + buf.writeUIntLE(0x1234567890, 0, 5); + expect(buf.toJSON().data).toEqual([0x90, 0x78, 0x56, 0x34, 0x12]); + expect(buf.readUIntLE(0, 5)).toBe(0x1234567890); + + buf.fill(0xff); + buf.writeUIntBE(0x1234567890, 0, 5); + expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56, 0x78, 0x90]); + expect(buf.readUIntBE(0, 5)).toBe(0x1234567890); + + buf.fill(0xff); + buf.writeIntLE(0x1234567890, 0, 5); + expect(buf.toJSON().data).toEqual([0x90, 0x78, 0x56, 0x34, 0x12]); + expect(buf.readIntLE(0, 5)).toBe(0x1234567890); + + buf.fill(0xff); + buf.writeIntBE(0x1234567890, 0, 5); + expect(buf.toJSON().data).toEqual([0x12, 0x34, 0x56, 0x78, 0x90]); + expect(buf.readIntBE(0, 5)).toBe(0x1234567890); + + buf.fill(0xff); + buf.writeIntLE(-0x1234567890, 0, 5); + expect(buf.toJSON().data).toEqual([0x70, 0x87, 0xa9, 0xcb, 0xed]); + expect(buf.readIntLE(0, 5)).toBe(-0x1234567890); + + buf.fill(0xff); + buf.writeIntBE(-0x1234567890, 0, 5); + expect(buf.toJSON().data).toEqual([0xed, 0xcb, 0xa9, 0x87, 0x70]); + expect(buf.readIntBE(0, 5)).toBe(-0x1234567890); + + buf.fill(0xff); + buf.writeIntLE(-0x0012000000, 0, 5); + expect(buf.toJSON().data).toEqual([0x00, 0x00, 0x00, 0xee, 0xff]); + expect(buf.readIntLE(0, 5)).toBe(-0x0012000000); + + buf.fill(0xff); + buf.writeIntBE(-0x0012000000, 0, 5); + expect(buf.toJSON().data).toEqual([0xff, 0xee, 0x00, 0x00, 0x00]); + expect(buf.readIntBE(0, 5)).toBe(-0x0012000000); +}); + +it("construct buffer from buffer", () => { + // Regression test for https://github.com/nodejs/node-v0.x-archive/issues/6111. + // Constructing a buffer from another buffer should a) work, and b) not corrupt + // the source buffer. + const a = [...Array(128).keys()]; // [0, 1, 2, 3, ... 126, 127] + const b = Buffer.from(a); + const c = Buffer.from(b); + expect(b.length).toBe(a.length); + expect(c.length).toBe(a.length); + for (let i = 0, k = a.length; i < k; ++i) { + expect(a[i]).toBe(i); + expect(b[i]).toBe(i); + expect(c[i]).toBe(i); + } +}); + +it("truncation after decode", () => { + const crypto = require("crypto"); + + expect(crypto.createHash("sha1").update(Buffer.from("YW55=======", "base64")).digest("hex")).toBe( + crypto.createHash("sha1").update(Buffer.from("YW55", "base64")).digest("hex"), + ); +}); + +it("Buffer,poolSize", () => { + const ps = Buffer.poolSize; + Buffer.poolSize = 0; + expect(Buffer.allocUnsafe(1).parent instanceof ArrayBuffer).toBe(true); + Buffer.poolSize = ps; + + expect(() => Buffer.allocUnsafe(10).copy()).toThrow(TypeError); + + expect(() => Buffer.from()).toThrow(TypeError); + expect(() => Buffer.from(null)).toThrow(TypeError); +}); + +it("prototype getters should not throw", () => { + expect(Buffer.prototype.parent).toBeUndefined(); + expect(Buffer.prototype.offset).toBeUndefined(); + expect(SlowBuffer.prototype.parent).toBeUndefined(); + expect(SlowBuffer.prototype.offset).toBeUndefined(); +}); + +it("large negative Buffer length inputs should not affect pool offset", () => { + // Use the fromArrayLike() variant here because it's more lenient + // about its input and passes the length directly to allocate(). + expect(Buffer.from({ length: -Buffer.poolSize })).toStrictEqual(Buffer.from("")); + expect(Buffer.from({ length: -100 })).toStrictEqual(Buffer.from("")); + + // Check pool offset after that by trying to write string into the pool. + Buffer.from("abc"); +}); + +it("ParseArrayIndex() should handle full uint32", () => { + expect(() => Buffer.from(new ArrayBuffer(0), -1 >>> 0)).toThrow(RangeError); +}); + +it("ParseArrayIndex() should reject values that don't fit in a 32 bits size_t", () => { + expect(() => { + const a = Buffer.alloc(1); + const b = Buffer.alloc(1); + a.copy(b, 0, 0x100000000, 0x100000001); + }).toThrow(RangeError); +}); + +it("unpooled buffer (replaces SlowBuffer)", () => { + const ubuf = Buffer.allocUnsafeSlow(10); + expect(ubuf).toBeTruthy(); + expect(ubuf.buffer).toBeTruthy(); + expect(ubuf.buffer.byteLength).toBe(10); +}); + +it("verify that an empty ArrayBuffer does not throw", () => { + Buffer.from(new ArrayBuffer()); +}); + +it("alloc() should throw on non-numeric size", () => { + expect(() => Buffer.alloc({ valueOf: () => 1 })).toThrow(TypeError); + expect(() => Buffer.alloc({ valueOf: () => -1 })).toThrow(TypeError); +}); + +it("toLocaleString()", () => { + const buf = Buffer.from("test"); + expect(buf.toLocaleString()).toBe(buf.toString()); + // expect(Buffer.prototype.toLocaleString).toBe(Buffer.prototype.toString); +}); + +it("alloc() should throw on invalid data", () => { + expect(() => Buffer.alloc(0x1000, "This is not correctly encoded", "hex")).toThrow(TypeError); + expect(() => Buffer.alloc(0x1000, "c", "hex")).toThrow(TypeError); + expect(() => Buffer.alloc(1, Buffer.alloc(0))).toThrow(TypeError); + expect(() => Buffer.alloc(40, "x", 20)).toThrow(TypeError); +}); + +it("Buffer.toJSON()", () => { + expect(JSON.stringify(Buffer.from("hello"))).toBe( + JSON.stringify({ + type: "Buffer", + data: [104, 101, 108, 108, 111], + }), + ); +}); + +it("buffer", () => { + var buf = new Buffer(20); + gc(); + // if this fails or infinitely loops, it means there is a memory issue with the JSC::Structure object + expect(Object.keys(buf).length > 0).toBe(true); + gc(); + expect(buf.write("hello world ")).toBe(12); + expect(buf.write("hello world ", "utf8")).toBe(12); + + gc(); + expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world "); + gc(); + expect(buf.toString("base64url", 0, "hello world ".length)).toBe(btoa("hello world ")); + gc(); + expect(buf instanceof Uint8Array).toBe(true); + gc(); + expect(buf instanceof Buffer).toBe(true); + gc(); + expect(buf.slice() instanceof Uint8Array).toBe(true); + gc(); + expect(buf.slice(0, 1) instanceof Buffer).toBe(true); + gc(); + expect(buf.slice(0, 1) instanceof Uint8Array).toBe(true); + gc(); + expect(buf.slice(0, 1) instanceof Buffer).toBe(true); + gc(); + expect(buf.slice(0, 0).length).toBe(0); +}); + +it("Buffer", () => { + var inputs = ["hello world", "hello world".repeat(100), `😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`]; + var good = inputs.map(a => new TextEncoder().encode(a)); + for (let i = 0; i < inputs.length; i++) { + var input = inputs[i]; + expect(new Buffer(input).toString("utf8")).toBe(inputs[i]); + gc(); + expect(Array.from(new Buffer(input)).join(",")).toBe(good[i].join(",")); + gc(); + expect(Buffer.byteLength(input)).toBe(good[i].length); + gc(); + expect(Buffer.from(input).byteLength).toBe(Buffer.byteLength(input)); + } +}); + +it("Buffer.byteLength", () => { + expect(Buffer.byteLength("😀😃😄😁😆😅😂🤣☺️😊😊😇")).toBe( + new TextEncoder().encode("😀😃😄😁😆😅😂🤣☺️😊😊😇").byteLength, + ); +}); + +it("Buffer.isBuffer", () => { + expect(Buffer.isBuffer(new Buffer(1))).toBe(true); + gc(); + expect(Buffer.isBuffer(new Buffer(0))).toBe(true); + gc(); + expect(Buffer.isBuffer(new Uint8Array(0))).toBe(false); + gc(); + expect(Buffer.isBuffer(new Uint8Array(1))).toBe(false); + gc(); + var a = new Uint8Array(1); + gc(); + expect(Buffer.isBuffer(a)).toBe(false); + gc(); + a = new Buffer(a.buffer); + gc(); + expect(Buffer.isBuffer(a)).toBe(true); + gc(); + expect(a instanceof Buffer).toBe(true); + expect(a instanceof Uint8Array).toBe(true); + expect(new Uint8Array(0) instanceof Buffer).toBe(false); + + // DOMJIT + for (let i = 0; i < 9000; i++) { + if (!Buffer.isBuffer(a)) { + throw new Error("Buffer.isBuffer failed"); + } + + if (Buffer.isBuffer("wat")) { + throw new Error("Buffer.isBuffer failed"); + } + } +}); + +it("writeInt", () => { + var buf = new Buffer(1024); + var data = new DataView(buf.buffer); + buf.writeInt32BE(100); + expect(data.getInt32(0, false)).toBe(100); + buf.writeInt32BE(100); + expect(data.getInt32(0, false)).toBe(100); + var childBuf = buf.subarray(0, 4); + expect(data.getInt32(0, false)).toBe(100); + expect(childBuf.readInt32BE(0, false)).toBe(100); +}); + +it("Buffer.from", () => { + expect(Buffer.from("hello world").toString("utf8")).toBe("hello world"); + expect(Buffer.from("hello world", "ascii").toString("utf8")).toBe("hello world"); + expect(Buffer.from("hello world", "latin1").toString("utf8")).toBe("hello world"); + gc(); + expect(Buffer.from([254]).join(",")).toBe("254"); + + expect(Buffer.from([254], "utf8").join(",")).toBe("254"); + expect(Buffer.from([254], "utf-8").join(",")).toBe("254"); + expect(Buffer.from([254], "latin").join(",")).toBe("254"); + expect(Buffer.from([254], "uc2").join(",")).toBe("254"); + expect(Buffer.from([254], "utf16").join(",")).toBe("254"); + expect(Buffer.isBuffer(Buffer.from([254], "utf16"))).toBe(true); + + expect(() => Buffer.from(123).join(",")).toThrow(); + + expect(Buffer.from({ length: 124 }).join(",")).toBe(Uint8Array.from({ length: 124 }).join(",")); + + expect(Buffer.from(new ArrayBuffer(1024), 0, 512).join(",")).toBe(new Uint8Array(512).join(",")); + + expect(Buffer.from(new Buffer(new ArrayBuffer(1024), 0, 512)).join(",")).toBe(new Uint8Array(512).join(",")); + gc(); +}); + +it("Buffer.from latin1 vs ascii", () => { + const simpleBuffer = Buffer.from("\xa4", "binary"); + expect(simpleBuffer.toString("latin1")).toBe("¤"); + expect(simpleBuffer.toString("ascii")).toBe("$"); + gc(); + const asciiBuffer = Buffer.from("\xa4", "ascii"); + expect(asciiBuffer.toString("latin1")).toBe("¤"); + expect(asciiBuffer.toString("ascii")).toBe("$"); + gc(); +}); + +it("Buffer.equals", () => { + var a = new Uint8Array(10); + a[2] = 1; + var b = new Uint8Array(10); + b[2] = 1; + a = new Buffer(a.buffer); + b = new Buffer(b.buffer); + expect(a.equals(b)).toBe(true); + b[2] = 0; + expect(a.equals(b)).toBe(false); +}); + +it("Buffer.compare", () => { + var a = new Uint8Array(10); + a[2] = 1; + var b = new Uint8Array(10); + b[2] = 1; + a = new Buffer(a.buffer); + b = new Buffer(b.buffer); + expect(a.compare(b)).toBe(0); + b[2] = 0; + expect(a.compare(b)).toBe(1); + expect(b.compare(a)).toBe(-1); + + const buf = Buffer.from("0123456789", "utf8"); + const expectedSameBufs = [ + [buf.slice(-10, 10), Buffer.from("0123456789", "utf8")], + [buf.slice(-20, 10), Buffer.from("0123456789", "utf8")], + [buf.slice(-20, -10), Buffer.from("", "utf8")], + [buf.slice(), Buffer.from("0123456789", "utf8")], + [buf.slice(0), Buffer.from("0123456789", "utf8")], + [buf.slice(0, 0), Buffer.from("", "utf8")], + [buf.slice(undefined), Buffer.from("0123456789", "utf8")], + [buf.slice("foobar"), Buffer.from("0123456789", "utf8")], + [buf.slice(undefined, undefined), Buffer.from("0123456789", "utf8")], + [buf.slice(2), Buffer.from("23456789", "utf8")], + [buf.slice(5), Buffer.from("56789", "utf8")], + [buf.slice(10), Buffer.from("", "utf8")], + [buf.slice(5, 8), Buffer.from("567", "utf8")], + [buf.slice(8, -1), Buffer.from("8", "utf8")], + [buf.slice(-10), Buffer.from("0123456789", "utf8")], + [buf.slice(0, -9), Buffer.from("0", "utf8")], + [buf.slice(0, -10), Buffer.from("", "utf8")], + [buf.slice(0, -1), Buffer.from("012345678", "utf8")], + [buf.slice(2, -2), Buffer.from("234567", "utf8")], + [buf.slice(0, 65536), Buffer.from("0123456789", "utf8")], + [buf.slice(65536, 0), Buffer.from("", "utf8")], + [buf.slice(-5, -8), Buffer.from("", "utf8")], + [buf.slice(-5, -3), Buffer.from("56", "utf8")], + [buf.slice(-10, 10), Buffer.from("0123456789", "utf8")], + [buf.slice("0", "1"), Buffer.from("0", "utf8")], + [buf.slice("-5", "10"), Buffer.from("56789", "utf8")], + [buf.slice("-10", "10"), Buffer.from("0123456789", "utf8")], + [buf.slice("-10", "-5"), Buffer.from("01234", "utf8")], + [buf.slice("-10", "-0"), Buffer.from("", "utf8")], + [buf.slice("111"), Buffer.from("", "utf8")], + [buf.slice("0", "-111"), Buffer.from("", "utf8")], + ]; + + for (let i = 0, s = buf.toString(); i < buf.length; ++i) { + expectedSameBufs.push( + [buf.slice(i), Buffer.from(s.slice(i))], + [buf.slice(0, i), Buffer.from(s.slice(0, i))], + [buf.slice(-i), Buffer.from(s.slice(-i))], + [buf.slice(0, -i), Buffer.from(s.slice(0, -i))], + ); + } + + expectedSameBufs.forEach(([buf1, buf2]) => { + expect(Buffer.compare(buf1, buf2)).toBe(0); + }); + + { + const buf = Buffer.from([ + 1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0, 0, 0, 18, 184, 6, 0, 175, 29, 0, 8, 11, 1, 0, 0, + ]); + const chunk1 = Buffer.from([1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0]); + const chunk2 = Buffer.from([0, 0, 18, 184, 6, 0, 175, 29, 0, 8, 11, 1, 0, 0]); + const middle = buf.length / 2; + + expect(JSON.stringify(buf.slice(0, middle))).toBe(JSON.stringify(chunk1)); + expect(JSON.stringify(buf.slice(middle))).toBe(JSON.stringify(chunk2)); + } +}); + +it("Buffer.copy", () => { + var array1 = new Uint8Array(128); + array1.fill(100); + array1 = new Buffer(array1.buffer); + var array2 = new Uint8Array(128); + array2.fill(200); + array2 = new Buffer(array2.buffer); + var array3 = new Uint8Array(128); + array3 = new Buffer(array3.buffer); + gc(); + expect(array1.copy(array2)).toBe(128); + expect(array1.join("")).toBe(array2.join("")); + + { + // Create two `Buffer` instances. + const buf1 = Buffer.allocUnsafe(26); + const buf2 = Buffer.allocUnsafe(26).fill("!"); + + for (let i = 0; i < 26; i++) { + // 97 is the decimal ASCII value for 'a'. + buf1[i] = i + 97; + } + + // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`. + buf1.copy(buf2, 8, 16, 20); + expect(buf2.toString("ascii", 0, 25)).toBe("!!!!!!!!qrst!!!!!!!!!!!!!"); + } + + { + const buf = Buffer.allocUnsafe(26); + + for (let i = 0; i < 26; i++) { + // 97 is the decimal ASCII value for 'a'. + buf[i] = i + 97; + } + + buf.copy(buf, 0, 4, 10); + expect(buf.toString()).toBe("efghijghijklmnopqrstuvwxyz"); + } +}); + +export function fillRepeating(dstBuffer, start, end) { + let len = dstBuffer.length, // important: use indices length, not byte-length + sLen = end - start, + p = sLen; // set initial position = source sequence length + + // step 2: copy existing data doubling segment length per iteration + while (p < len) { + if (p + sLen > len) sLen = len - p; // if not power of 2, truncate last segment + dstBuffer.copyWithin(p, start, sLen); // internal copy + p += sLen; // add current length to offset + sLen <<= 1; // double length for next segment + } +} + +describe("Buffer.fill string", () => { + for (let text of ["hello world", "1234567890", "\uD83D\uDE00", "😀😃😄😁😆😅😂🤣☺️😊😊😇"]) { + it(text, () => { + var input = new Buffer(1024); + input.fill(text); + var demo = new Uint8Array(1024); + var encoded = new TextEncoder().encode(text); + + demo.set(encoded); + fillRepeating(demo, 0, encoded.length); + expect(input.join("")).toBe(demo.join("")); + }); + } +}); + +it("Buffer.fill 1 char string", () => { + var input = new Buffer(1024); + input.fill("h"); + var demo = new Uint8Array(1024); + var encoded = new TextEncoder().encode("h"); + + demo.set(encoded); + fillRepeating(demo, 0, encoded.length); + expect(input.join("")).toBe(demo.join("")); +}); + +it("Buffer.concat", () => { + var array1 = new Uint8Array(128); + array1.fill(100); + var array2 = new Uint8Array(128); + array2.fill(200); + var array3 = new Uint8Array(128); + array3.fill(300); + gc(); + expect(Buffer.concat([array1, array2, array3]).join("")).toBe(array1.join("") + array2.join("") + array3.join("")); + expect(Buffer.concat([array1, array2, array3], 222).length).toBe(222); + expect(Buffer.concat([array1, array2, array3], 222).subarray(0, 128).join("")).toBe("100".repeat(128)); + expect(Buffer.concat([array1, array2, array3], 222).subarray(129, 222).join("")).toBe("200".repeat(222 - 129)); +}); + +it("read", () => { + var buf = new Buffer(1024); + var data = new DataView(buf.buffer); + function reset() { + new Uint8Array(buf.buffer).fill(0); + } + data.setBigInt64(0, BigInt(1000), false); + expect(buf.readBigInt64BE(0)).toBe(BigInt(1000)); + reset(); + + data.setBigInt64(0, BigInt(1000), true); + expect(buf.readBigInt64LE(0)).toBe(BigInt(1000)); + reset(); + + data.setBigUint64(0, BigInt(1000), false); + expect(buf.readBigUInt64BE(0)).toBe(BigInt(1000)); + reset(); + + data.setBigUint64(0, BigInt(1000), true); + expect(buf.readBigUInt64LE(0)).toBe(BigInt(1000)); + reset(); + + data.setFloat64(0, 1000, false); + expect(buf.readDoubleBE(0)).toBe(1000); + reset(); + + data.setFloat64(0, 1000, true); + expect(buf.readDoubleLE(0)).toBe(1000); + reset(); + + data.setFloat32(0, 1000, false); + expect(buf.readFloatBE(0)).toBe(1000); + reset(); + + data.setFloat32(0, 1000, true); + expect(buf.readFloatLE(0)).toBe(1000); + reset(); + + data.setInt16(0, 1000, false); + expect(buf.readInt16BE(0)).toBe(1000); + reset(); + + data.setInt16(0, 1000, true); + expect(buf.readInt16LE(0)).toBe(1000); + reset(); + + data.setInt32(0, 1000, false); + expect(buf.readInt32BE(0)).toBe(1000); + reset(); + + data.setInt32(0, 1000, true); + expect(buf.readInt32LE(0)).toBe(1000); + reset(); + + data.setInt8(0, 100, false); + expect(buf.readInt8(0)).toBe(100); + reset(); + + data.setUint16(0, 1000, false); + expect(buf.readUInt16BE(0)).toBe(1000); + reset(); + + data.setUint16(0, 1000, true); + expect(buf.readUInt16LE(0)).toBe(1000); + reset(); + + data.setUint32(0, 1000, false); + expect(buf.readUInt32BE(0)).toBe(1000); + reset(); + + data.setUint32(0, 1000, true); + expect(buf.readUInt32LE(0)).toBe(1000); + reset(); + + data.setUint8(0, 255, false); + expect(buf.readUInt8(0)).toBe(255); + reset(); + + data.setUint8(0, 255, false); + expect(buf.readUInt8(0)).toBe(255); + reset(); +}); + +// this is for checking the simd code path +it("write long utf16 string works", () => { + const long = "😀😃😄😁😆😅😂🤣☺️😊😊😇".repeat(200); + const buf = Buffer.alloc(long.length * 2); + buf.write(long, 0, "utf16le"); + expect(buf.toString("utf16le")).toBe(long); + for (let offset = 0; offset < long.length; offset += 48) { + expect(buf.toString("utf16le", offset, offset + 4)).toBe("😀"); + expect(buf.toString("utf16le", offset, offset + 8)).toBe("😀😃"); + expect(buf.toString("utf16le", offset, offset + 12)).toBe("😀😃😄"); + expect(buf.toString("utf16le", offset, offset + 16)).toBe("😀😃😄😁"); + expect(buf.toString("utf16le", offset, offset + 20)).toBe("😀😃😄😁😆"); + expect(buf.toString("utf16le", offset, offset + 24)).toBe("😀😃😄😁😆😅"); + expect(buf.toString("utf16le", offset, offset + 28)).toBe("😀😃😄😁😆😅😂"); + expect(buf.toString("utf16le", offset, offset + 32)).toBe("😀😃😄😁😆😅😂🤣"); + expect(buf.toString("utf16le", offset, offset + 36)).toBe("😀😃😄😁😆😅😂🤣☺️"); + expect(buf.toString("utf16le", offset, offset + 40)).toBe("😀😃😄😁😆😅😂🤣☺️😊"); + expect(buf.toString("utf16le", offset, offset + 44)).toBe("😀😃😄😁😆😅😂🤣☺️😊😊"); + expect(buf.toString("utf16le", offset, offset + 48)).toBe("😀😃😄😁😆😅😂🤣☺️😊😊😇"); + } +}); + +it("write", () => { + const resultMap = new Map([ + ["utf8", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], + ["ucs2", Buffer.from([102, 0, 111, 0, 111, 0, 0, 0, 0])], + ["ascii", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], + ["latin1", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], + ["binary", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], + ["utf16le", Buffer.from([102, 0, 111, 0, 111, 0, 0, 0, 0])], + ["base64", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], + ["base64url", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], + ["hex", Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])], + ]); + + let buf = Buffer.alloc(9); + function reset() { + new Uint8Array(buf.buffer).fill(0); + } + + // utf8, ucs2, ascii, latin1, utf16le + const encodings = ["utf8", "utf-8", "ucs2", "ucs-2", "ascii", "latin1", "binary", "utf16le", "utf-16le"]; + + encodings + .reduce((es, e) => es.concat(e, e.toUpperCase()), []) + .forEach(encoding => { + reset(); + + const len = Buffer.byteLength("foo", encoding); + expect(buf.write("foo", 0, len, encoding)).toBe(len); + + if (encoding.includes("-")) encoding = encoding.replace("-", ""); + + expect(buf).toStrictEqual(resultMap.get(encoding.toLowerCase())); + }); + + // base64 + ["base64", "BASE64", "base64url", "BASE64URL"].forEach(encoding => { + reset(); + + const len = Buffer.byteLength("Zm9v", encoding); + + expect(buf.write("Zm9v", 0, len, encoding)).toBe(len); + expect(buf).toStrictEqual(resultMap.get(encoding.toLowerCase())); + }); + + // hex + ["hex", "HEX"].forEach(encoding => { + reset(); + const len = Buffer.byteLength("666f6f", encoding); + + expect(buf.write("666f6f", 0, len, encoding)).toBe(len); + expect(buf).toStrictEqual(resultMap.get(encoding.toLowerCase())); + }); + + // UCS-2 overflow CVE-2018-12115 + for (let i = 1; i < 4; i++) { + // Allocate two Buffers sequentially off the pool. Run more than once in case + // we hit the end of the pool and don't get sequential allocations + const x = Buffer.allocUnsafe(4).fill(0); + const y = Buffer.allocUnsafe(4).fill(1); + // Should not write anything, pos 3 doesn't have enough room for a 16-bit char + expect(x.write("ыыыыыы", 3, "ucs2")).toBe(0); + // CVE-2018-12115 experienced via buffer overrun to next block in the pool + expect(Buffer.compare(y, Buffer.alloc(4, 1))).toBe(0); + } + + // // Should not write any data when there is no space for 16-bit chars + const z = Buffer.alloc(4, 0); + expect(z.write("\u0001", 3, "ucs2")).toBe(0); + expect(Buffer.compare(z, Buffer.alloc(4, 0))).toBe(0); + // Make sure longer strings are written up to the buffer end. + expect(z.write("abcd", 2)).toBe(2); + expect([...z]).toStrictEqual([0, 0, 0x61, 0x62]); + + //Large overrun could corrupt the process with utf8 + expect(Buffer.alloc(4).write("a".repeat(100), 3, "utf8")).toBe(1); + + // Large overrun could corrupt the process + expect(Buffer.alloc(4).write("ыыыыыы".repeat(100), 3, "utf16le")).toBe(0); + + { + // .write() does not affect the byte after the written-to slice of the Buffer. + // Refs: https://github.com/nodejs/node/issues/26422 + const buf = Buffer.alloc(8); + expect(buf.write("ыы", 1, "utf16le")).toBe(4); + expect([...buf]).toStrictEqual([0, 0x4b, 0x04, 0x4b, 0x04, 0, 0, 0]); + } +}); + +it("includes", () => { + const buf = Buffer.from("this is a buffer"); + + expect(buf.includes("this")).toBe(true); + expect(buf.includes("is")).toBe(true); + expect(buf.includes(Buffer.from("a buffer"))).toBe(true); + expect(buf.includes(97)).toBe(true); + expect(buf.includes(Buffer.from("a buffer example"))).toBe(false); + expect(buf.includes(Buffer.from("a buffer example").slice(0, 8))).toBe(true); + expect(buf.includes("this", 4)).toBe(false); +}); + +it("indexOf", () => { + const buf = Buffer.from("this is a buffer"); + + expect(buf.indexOf("this")).toBe(0); + expect(buf.indexOf("is")).toBe(2); + expect(buf.indexOf(Buffer.from("a buffer"))).toBe(8); + expect(buf.indexOf(97)).toBe(8); + expect(buf.indexOf(Buffer.from("a buffer example"))).toBe(-1); + expect(buf.indexOf(Buffer.from("a buffer example").slice(0, 8))).toBe(8); + + const utf16Buffer = Buffer.from("\u039a\u0391\u03a3\u03a3\u0395", "utf16le"); + + expect(utf16Buffer.indexOf("\u03a3", 0, "utf16le")).toBe(4); + expect(utf16Buffer.indexOf("\u03a3", -4, "utf16le")).toBe(6); + + const b = Buffer.from("abcdef"); + + // Passing a value that's a number, but not a valid byte. + // Prints: 2, equivalent to searching for 99 or 'c'. + expect(b.indexOf(99.9)).toBe(2); + expect(b.indexOf(256 + 99)).toBe(2); + + // Passing a byteOffset that coerces to NaN or 0. + // Prints: 1, searching the whole buffer. + expect(b.indexOf("b", undefined)).toBe(1); + expect(b.indexOf("b", {})).toBe(1); + expect(b.indexOf("b", null)).toBe(1); + expect(b.indexOf("b", [])).toBe(1); +}); + +it("lastIndexOf", () => { + const buf = Buffer.from("this buffer is a buffer"); + + expect(buf.lastIndexOf("this")).toBe(0); + expect(buf.lastIndexOf("this", 0)).toBe(0); + expect(buf.lastIndexOf("this", -1000)).toBe(-1); + expect(buf.lastIndexOf("buffer")).toBe(17); + expect(buf.lastIndexOf(Buffer.from("buffer"))).toBe(17); + expect(buf.lastIndexOf(97)).toBe(15); + expect(buf.lastIndexOf(Buffer.from("yolo"))).toBe(-1); + expect(buf.lastIndexOf("buffer", 5)).toBe(5); + expect(buf.lastIndexOf("buffer", 4)).toBe(-1); + + const utf16Buffer = Buffer.from("\u039a\u0391\u03a3\u03a3\u0395", "utf16le"); + + expect(utf16Buffer.lastIndexOf("\u03a3", undefined, "utf16le")).toBe(6); + expect(utf16Buffer.lastIndexOf("\u03a3", -5, "utf16le")).toBe(4); + + const b = Buffer.from("abcdef"); + + // Passing a value that's a number, but not a valid byte. + // Prints: 2, equivalent to searching for 99 or 'c'. + expect(b.lastIndexOf(99.9)).toBe(2); + expect(b.lastIndexOf(256 + 99)).toBe(2); + + // Passing a byteOffset that coerces to NaN or 0. + // Prints: 1, searching the whole buffer. + expect(b.lastIndexOf("b", undefined)).toBe(1); + expect(b.lastIndexOf("b", {})).toBe(1); + + // Passing a byteOffset that coerces to 0. + // Prints: -1, equivalent to passing 0. + expect(b.lastIndexOf("b", null)).toBe(-1); + expect(b.lastIndexOf("b", [])).toBe(-1); +}); + +for (let fn of [Buffer.prototype.slice, Buffer.prototype.subarray]) { + it(`Buffer.${fn.name}`, () => { + const buf = new Buffer("buffer"); + const slice = fn.call(buf, 1, 3); + expect(slice.toString()).toBe("uf"); + const slice2 = fn.call(slice, 100); + expect(slice2.toString()).toBe(""); + + const slice3 = fn.call(slice, -1); + expect(slice3.toString()).toBe("f"); + }); +} + +it("Buffer.from(base64)", () => { + const buf = Buffer.from("aGVsbG8gd29ybGQ=", "base64"); + expect(buf.toString()).toBe("hello world"); + + expect(Buffer.from(btoa('console.log("hello world")\n'), "base64").toString()).toBe('console.log("hello world")\n'); +}); + +it("Buffer.swap16", () => { + const examples = [ + ["", ""], + ["a1", "1a"], + ["a1b2", "1a2b"], + ]; + + for (let i = 0; i < examples.length; i++) { + const input = examples[i][0]; + const output = examples[i][1]; + const buf = Buffer.from(input, "utf-8"); + + const ref = buf.swap16(); + expect(ref instanceof Buffer).toBe(true); + expect(buf.toString()).toBe(output); + } + + const buf = Buffer.from("123", "utf-8"); + try { + buf.swap16(); + expect(false).toBe(true); + } catch (exception) { + expect(exception.message).toBe("Buffer size must be a multiple of 16-bits"); + } +}); + +it("Buffer.swap32", () => { + const examples = [ + ["", ""], + ["a1b2", "2b1a"], + ["a1b2c3d4", "2b1a4d3c"], + ]; + + for (let i = 0; i < examples.length; i++) { + const input = examples[i][0]; + const output = examples[i][1]; + const buf = Buffer.from(input, "utf-8"); + + const ref = buf.swap32(); + expect(ref instanceof Buffer).toBe(true); + expect(buf.toString()).toBe(output); + } + + const buf = Buffer.from("12345", "utf-8"); + try { + buf.swap32(); + expect(false).toBe(true); + } catch (exception) { + expect(exception.message).toBe("Buffer size must be a multiple of 32-bits"); + } +}); + +it("Buffer.swap64", () => { + const examples = [ + ["", ""], + ["a1b2c3d4", "4d3c2b1a"], + ["a1b2c3d4e5f6g7h8", "4d3c2b1a8h7g6f5e"], + ]; + + for (let i = 0; i < examples.length; i++) { + const input = examples[i][0]; + const output = examples[i][1]; + const buf = Buffer.from(input, "utf-8"); + + const ref = buf.swap64(); + expect(ref instanceof Buffer).toBe(true); + expect(buf.toString()).toBe(output); + } + + const buf = Buffer.from("123456789", "utf-8"); + try { + buf.swap64(); + expect(false).toBe(true); + } catch (exception) { + expect(exception.message).toBe("Buffer size must be a multiple of 64-bits"); + } +}); + +it("Buffer.toString regessions", () => { + expect( + Buffer.from([65, 0]) + .toString("utf16le") + .split("") + .map(x => x.charCodeAt(0)), + ).toEqual([65]); + expect(Buffer.from([65, 0]).toString("base64")).toBe("QQA="); + expect(Buffer.from('{"alg":"RS256","typ":"JWT"}', "latin1").toString("latin1")).toBe('{"alg":"RS256","typ":"JWT"}'); + expect(Buffer.from('{"alg":"RS256","typ":"JWT"}', "utf8").toString("utf8")).toBe('{"alg":"RS256","typ":"JWT"}'); +}); + +it("Buffer.toString(utf16le)", () => { + const buf = Buffer.from("hello world", "utf16le"); + expect(buf.toString("utf16le")).toBe("hello world"); + expect(buf.toString("utf16le", 0, 5)).toBe("he"); +}); + +it("Buffer.toString(binary)", () => { + var x = Buffer.from(" { + { + const buf = Buffer.from("hello world"); + expect(buf.toString("base64")).toBe("aGVsbG8gd29ybGQ="); + } + + { + expect(Buffer.from(`console.log("hello world")\n`).toString("base64")).toBe(btoa('console.log("hello world")\n')); + } +}); + +it("Buffer can be mocked", () => { + function MockBuffer() { + const noop = function () {}; + const res = Buffer.alloc(0); + for (const op in Buffer.prototype) { + if (typeof res[op] === "function") { + res[op] = noop; + } + } + return res; + } + + const buf = MockBuffer(); + + expect(() => { + buf.write("hello world"); + buf.writeUint16BE(0); + buf.writeUint32BE(0); + buf.writeBigInt64BE(0); + buf.writeBigUInt64BE(0); + buf.writeBigInt64LE(0); + buf.writeBigUInt64LE(0); + }).not.toThrow(); +}); + +it("constants", () => { + expect(BufferModule.constants.MAX_LENGTH).toBe(4294967296); + expect(BufferModule.constants.MAX_STRING_LENGTH).toBe(536870888); + expect(BufferModule.default.constants.MAX_LENGTH).toBe(4294967296); + expect(BufferModule.default.constants.MAX_STRING_LENGTH).toBe(536870888); +}); + +it("File", () => { + expect(BufferModule.File).toBe(Blob); +}); + +it("transcode", () => { + expect(typeof BufferModule.transcode).toBe("undefined"); + + // This is a masqueradesAsUndefined function + expect(() => BufferModule.transcode()).toThrow("Not implemented"); +}); + +it("Buffer.from (Node.js test/test-buffer-from.js)", () => { + const checkString = "test"; + + const check = Buffer.from(checkString); + + class MyString extends String { + constructor() { + super(checkString); + } + } + + class MyPrimitive { + [Symbol.toPrimitive]() { + return checkString; + } + } + + class MyBadPrimitive { + [Symbol.toPrimitive]() { + return 1; + } + } + + expect(Buffer.from(new String(checkString))).toStrictEqual(check); + expect(Buffer.from(new MyString())).toStrictEqual(check); + expect(Buffer.from(new MyPrimitive())).toStrictEqual(check); + + [ + {}, + new Boolean(true), + { + valueOf() { + return null; + }, + }, + { + valueOf() { + return undefined; + }, + }, + { valueOf: null }, + Object.create(null), + new Number(true), + new MyBadPrimitive(), + Symbol(), + 5n, + (one, two, three) => {}, + undefined, + null, + ].forEach(input => { + expect(() => Buffer.from(input)).toThrow(); + expect(() => Buffer.from(input, "hex")).toThrow(); + }); + + expect(() => Buffer.allocUnsafe(10)).not.toThrow(); // Should not throw. + expect(() => Buffer.from("deadbeaf", "hex")).not.toThrow(); // Should not throw. +}); + +it("new Buffer() (Node.js test/test-buffer-new.js)", () => { + const LENGTH = 16; + + const ab = new ArrayBuffer(LENGTH); + const dv = new DataView(ab); + const ui = new Uint8Array(ab); + const buf = Buffer.from(ab); + + expect(buf instanceof Buffer).toBe(true); + // expect(buf.parent, buf.buffer); + expect(buf.buffer).toBe(ab); + expect(buf.length).toBe(ab.byteLength); + + buf.fill(0xc); + for (let i = 0; i < LENGTH; i++) { + expect(ui[i]).toBe(0xc); + ui[i] = 0xf; + expect(buf[i]).toBe(0xf); + } + + buf.writeUInt32LE(0xf00, 0); + buf.writeUInt32BE(0xb47, 4); + buf.writeDoubleLE(3.1415, 8); + expect(dv.getUint32(0, true)).toBe(0xf00); + expect(dv.getUint32(4)).toBe(0xb47); + expect(dv.getFloat64(8, true)).toBe(3.1415); + + // Now test protecting users from doing stupid things + + // expect(function () { + // function AB() {} + // Object.setPrototypeOf(AB, ArrayBuffer); + // Object.setPrototypeOf(AB.prototype, ArrayBuffer.prototype); + // // Buffer.from(new AB()); + // }).toThrow(); + // console.log(origAB !== ab); + + // Test the byteOffset and length arguments + { + const ab = new Uint8Array(5); + ab[0] = 1; + ab[1] = 2; + ab[2] = 3; + ab[3] = 4; + ab[4] = 5; + const buf = Buffer.from(ab.buffer, 1, 3); + expect(buf.length).toBe(3); + expect(buf[0]).toBe(2); + expect(buf[1]).toBe(3); + expect(buf[2]).toBe(4); + buf[0] = 9; + expect(ab[1]).toBe(9); + + expect(() => Buffer.from(ab.buffer, 6)).toThrow(); + expect(() => Buffer.from(ab.buffer, 3, 6)).toThrow(); + } + + // Test the deprecated Buffer() version also + { + const ab = new Uint8Array(5); + ab[0] = 1; + ab[1] = 2; + ab[2] = 3; + ab[3] = 4; + ab[4] = 5; + const buf = Buffer(ab.buffer, 1, 3); + expect(buf.length).toBe(3); + expect(buf[0]).toBe(2); + expect(buf[1]).toBe(3); + expect(buf[2]).toBe(4); + buf[0] = 9; + expect(ab[1]).toBe(9); + + expect(() => Buffer(ab.buffer, 6)).toThrow(); + expect(() => Buffer(ab.buffer, 3, 6)).toThrow(); + } + + { + // If byteOffset is not numeric, it defaults to 0. + const ab = new ArrayBuffer(10); + const expected = Buffer.from(ab, 0); + expect(Buffer.from(ab, "fhqwhgads")).toStrictEqual(expected); + expect(Buffer.from(ab, NaN)).toStrictEqual(expected); + expect(Buffer.from(ab, {})).toStrictEqual(expected); + expect(Buffer.from(ab, [])).toStrictEqual(expected); + + // If byteOffset can be converted to a number, it will be. + expect(Buffer.from(ab, [1])).toStrictEqual(Buffer.from(ab, 1)); + + // If byteOffset is Infinity, throw. + expect(() => { + Buffer.from(ab, Infinity); + }).toThrow(); + } + + { + // If length is not numeric, it defaults to 0. + const ab = new ArrayBuffer(10); + const expected = Buffer.from(ab, 0, 0); + expect(Buffer.from(ab, 0, "fhqwhgads")).toStrictEqual(expected); + expect(Buffer.from(ab, 0, NaN)).toStrictEqual(expected); + expect(Buffer.from(ab, 0, {})).toStrictEqual(expected); + expect(Buffer.from(ab, 0, [])).toStrictEqual(expected); + + // If length can be converted to a number, it will be. + expect(Buffer.from(ab, 0, [1])).toStrictEqual(Buffer.from(ab, 0, 1)); + + // If length is Infinity, throw. + expect(() => Buffer.from(ab, 0, Infinity)).toThrow(); + } + + // Test an array like entry with the length set to NaN. + expect(Buffer.from({ length: NaN })).toStrictEqual(Buffer.alloc(0)); +}); + +it("Buffer.fill (Node.js tests)", () => { + "use strict"; + const SIZE = 28; + + const buf1 = Buffer.allocUnsafe(SIZE); + const buf2 = Buffer.allocUnsafe(SIZE); + + function bufReset() { + buf1.fill(0); + buf2.fill(0); + } + + // This is mostly accurate. Except write() won't write partial bytes to the + // string while fill() blindly copies bytes into memory. To account for that an + // error will be thrown if not all the data can be written, and the SIZE has + // been massaged to work with the input characters. + function writeToFill(string, offset, end, encoding) { + if (typeof offset === "string") { + encoding = offset; + offset = 0; + end = buf2.length; + } else if (typeof end === "string") { + encoding = end; + end = buf2.length; + } else if (end === undefined) { + end = buf2.length; + } + + // Should never be reached. + if (offset < 0 || end > buf2.length) throw new ERR_OUT_OF_RANGE(); + + if (end <= offset) return buf2; + + offset >>>= 0; + end >>>= 0; + expect(offset <= buf2.length).toBe(true); + + // Convert "end" to "length" (which write understands). + const length = end - offset < 0 ? 0 : end - offset; + + let wasZero = false; + do { + const written = buf2.write(string, offset, length, encoding); + offset += written; + // Safety check in case write falls into infinite loop. + if (written === 0) { + if (wasZero) throw new Error("Could not write all data to Buffer at " + offset); + else wasZero = true; + } + } while (offset < buf2.length); + + return buf2; + } + + function testBufs(string, offset, length, encoding) { + bufReset(); + buf1.fill.apply(buf1, arguments); + // Swap bytes on BE archs for ucs2 encoding. + expect(buf1.fill.apply(buf1, arguments)).toStrictEqual(writeToFill.apply(null, arguments)); + } + + // Default encoding + testBufs("abc"); + testBufs("\u0222aa"); + testBufs("a\u0234b\u0235c\u0236"); + testBufs("abc", 4); + testBufs("abc", 5); + testBufs("abc", SIZE); + testBufs("\u0222aa", 2); + testBufs("\u0222aa", 8); + testBufs("a\u0234b\u0235c\u0236", 4); + testBufs("a\u0234b\u0235c\u0236", 12); + testBufs("abc", 4, 1); + testBufs("abc", 5, 1); + testBufs("\u0222aa", 8, 1); + testBufs("a\u0234b\u0235c\u0236", 4, 1); + testBufs("a\u0234b\u0235c\u0236", 12, 1); + + // UTF8 + testBufs("abc", "utf8"); + testBufs("\u0222aa", "utf8"); + testBufs("a\u0234b\u0235c\u0236", "utf8"); + testBufs("abc", 4, "utf8"); + testBufs("abc", 5, "utf8"); + testBufs("abc", SIZE, "utf8"); + testBufs("\u0222aa", 2, "utf8"); + testBufs("\u0222aa", 8, "utf8"); + testBufs("a\u0234b\u0235c\u0236", 4, "utf8"); + testBufs("a\u0234b\u0235c\u0236", 12, "utf8"); + testBufs("abc", 4, 1, "utf8"); + testBufs("abc", 5, 1, "utf8"); + testBufs("\u0222aa", 8, 1, "utf8"); + testBufs("a\u0234b\u0235c\u0236", 4, 1, "utf8"); + testBufs("a\u0234b\u0235c\u0236", 12, 1, "utf8"); + expect(Buffer.allocUnsafe(1).fill(0).fill("\u0222")[0]).toBe(0xc8); + + // BINARY + testBufs("abc", "binary"); + testBufs("\u0222aa", "binary"); + testBufs("a\u0234b\u0235c\u0236", "binary"); + testBufs("abc", 4, "binary"); + testBufs("abc", 5, "binary"); + testBufs("abc", SIZE, "binary"); + testBufs("\u0222aa", 2, "binary"); + testBufs("\u0222aa", 8, "binary"); + testBufs("a\u0234b\u0235c\u0236", 4, "binary"); + testBufs("a\u0234b\u0235c\u0236", 12, "binary"); + testBufs("abc", 4, 1, "binary"); + testBufs("abc", 5, 1, "binary"); + testBufs("\u0222aa", 8, 1, "binary"); + testBufs("a\u0234b\u0235c\u0236", 4, 1, "binary"); + testBufs("a\u0234b\u0235c\u0236", 12, 1, "binary"); + + // LATIN1 + testBufs("abc", "latin1"); + testBufs("\u0222aa", "latin1"); + testBufs("a\u0234b\u0235c\u0236", "latin1"); + testBufs("abc", 4, "latin1"); + testBufs("abc", 5, "latin1"); + testBufs("abc", SIZE, "latin1"); + testBufs("\u0222aa", 2, "latin1"); + testBufs("\u0222aa", 8, "latin1"); + testBufs("a\u0234b\u0235c\u0236", 4, "latin1"); + testBufs("a\u0234b\u0235c\u0236", 12, "latin1"); + testBufs("abc", 4, 1, "latin1"); + testBufs("abc", 5, 1, "latin1"); + testBufs("\u0222aa", 8, 1, "latin1"); + testBufs("a\u0234b\u0235c\u0236", 4, 1, "latin1"); + testBufs("a\u0234b\u0235c\u0236", 12, 1, "latin1"); + + // UCS2 + testBufs("abc", "ucs2"); + testBufs("\u0222aa", "ucs2"); + testBufs("a\u0234b\u0235c\u0236", "ucs2"); + testBufs("abc", 4, "ucs2"); + testBufs("abc", SIZE, "ucs2"); + testBufs("\u0222aa", 2, "ucs2"); + testBufs("\u0222aa", 8, "ucs2"); + testBufs("a\u0234b\u0235c\u0236", 4, "ucs2"); + testBufs("a\u0234b\u0235c\u0236", 12, "ucs2"); + testBufs("abc", 4, 1, "ucs2"); + testBufs("abc", 5, 1, "ucs2"); + testBufs("\u0222aa", 8, 1, "ucs2"); + testBufs("a\u0234b\u0235c\u0236", 4, 1, "ucs2"); + testBufs("a\u0234b\u0235c\u0236", 12, 1, "ucs2"); + expect(Buffer.allocUnsafe(1).fill("\u0222", "ucs2")[0]).toBe(0x22); + + // HEX + testBufs("616263", "hex"); + testBufs("c8a26161", "hex"); + testBufs("61c8b462c8b563c8b6", "hex"); + testBufs("616263", 4, "hex"); + testBufs("616263", 5, "hex"); + testBufs("616263", SIZE, "hex"); + testBufs("c8a26161", 2, "hex"); + testBufs("c8a26161", 8, "hex"); + testBufs("61c8b462c8b563c8b6", 4, "hex"); + testBufs("61c8b462c8b563c8b6", 12, "hex"); + testBufs("616263", 4, 1, "hex"); + testBufs("616263", 5, 1, "hex"); + testBufs("c8a26161", 8, 1, "hex"); + testBufs("61c8b462c8b563c8b6", 4, 1, "hex"); + testBufs("61c8b462c8b563c8b6", 12, 1, "hex"); + + expect(() => { + const buf = Buffer.allocUnsafe(SIZE); + + buf.fill("yKJh", "hex"); + }).toThrow(); + + expect(() => { + const buf = Buffer.allocUnsafe(SIZE); + + buf.fill("\u0222", "hex"); + }).toThrow(); + + // BASE64 + testBufs("YWJj", "base64"); + testBufs("yKJhYQ==", "base64"); + testBufs("Yci0Ysi1Y8i2", "base64"); + testBufs("YWJj", 4, "base64"); + testBufs("YWJj", SIZE, "base64"); + testBufs("yKJhYQ==", 2, "base64"); + testBufs("yKJhYQ==", 8, "base64"); + testBufs("Yci0Ysi1Y8i2", 4, "base64"); + testBufs("Yci0Ysi1Y8i2", 12, "base64"); + testBufs("YWJj", 4, 1, "base64"); + testBufs("YWJj", 5, 1, "base64"); + testBufs("yKJhYQ==", 8, 1, "base64"); + testBufs("Yci0Ysi1Y8i2", 4, 1, "base64"); + testBufs("Yci0Ysi1Y8i2", 12, 1, "base64"); + + // BASE64URL + testBufs("YWJj", "base64url"); + testBufs("yKJhYQ", "base64url"); + testBufs("Yci0Ysi1Y8i2", "base64url"); + testBufs("YWJj", 4, "base64url"); + testBufs("YWJj", SIZE, "base64url"); + testBufs("yKJhYQ", 2, "base64url"); + testBufs("yKJhYQ", 8, "base64url"); + testBufs("Yci0Ysi1Y8i2", 4, "base64url"); + testBufs("Yci0Ysi1Y8i2", 12, "base64url"); + testBufs("YWJj", 4, 1, "base64url"); + testBufs("YWJj", 5, 1, "base64url"); + testBufs("yKJhYQ", 8, 1, "base64url"); + testBufs("Yci0Ysi1Y8i2", 4, 1, "base64url"); + testBufs("Yci0Ysi1Y8i2", 12, 1, "base64url"); +}); + +it("fill() repeat pattern", () => { + function genBuffer(size, args) { + const b = Buffer.allocUnsafe(size); + return b.fill(0).fill.apply(b, args); + } + + const buf2Fill = Buffer.allocUnsafe(1).fill(2); + expect(genBuffer(4, [buf2Fill])).toStrictEqual(Buffer.from([2, 2, 2, 2])); + expect(genBuffer(4, [buf2Fill, 1])).toStrictEqual(Buffer.from([0, 2, 2, 2])); + expect(genBuffer(4, [buf2Fill, 1, 3])).toStrictEqual(Buffer.from([0, 2, 2, 0])); + expect(genBuffer(4, [buf2Fill, 1, 1])).toStrictEqual(Buffer.from([0, 0, 0, 0])); + const hexBufFill = Buffer.allocUnsafe(2).fill(0).fill("0102", "hex"); + expect(genBuffer(4, [hexBufFill])).toStrictEqual(Buffer.from([1, 2, 1, 2])); + expect(genBuffer(4, [hexBufFill, 1])).toStrictEqual(Buffer.from([0, 1, 2, 1])); + expect(genBuffer(4, [hexBufFill, 1, 3])).toStrictEqual(Buffer.from([0, 1, 2, 0])); + expect(genBuffer(4, [hexBufFill, 1, 1])).toStrictEqual(Buffer.from([0, 0, 0, 0])); +}); + +it("fill() should throw on invalid arguments", () => { + // Check exceptions + const buf = Buffer.allocUnsafe(16); + expect(() => buf.fill(0, -1)).toThrow(RangeError); + expect(() => buf.fill(0, 0, buf.length + 1)).toThrow(RangeError); + expect(() => buf.fill("", -1)).toThrow(RangeError); + expect(() => buf.fill("", 0, buf.length + 1)).toThrow(RangeError); + expect(() => buf.fill("", 1, -1)).toThrow(RangeError); + expect(() => buf.fill("a", 0, buf.length, "node rocks!")).toThrow(TypeError); + expect(() => buf.fill("a", 0, 0, NaN)).toThrow(TypeError); + expect(() => buf.fill("a", 0, 0, false)).toThrow(TypeError); + expect(() => buf.fill("a", 0, 0, "foo")).toThrow(TypeError); + + // Make sure these throw. + expect(() => Buffer.allocUnsafe(8).fill("a", -1)).toThrow(); + expect(() => Buffer.allocUnsafe(8).fill("a", 0, 9)).toThrow(); +}); + +it("fill() should not hang indefinitely", () => { + // Make sure this doesn't hang indefinitely. + Buffer.allocUnsafe(8).fill(""); + Buffer.alloc(8, ""); +}); + +it("fill() repeat byte", () => { + const buf = Buffer.alloc(64, 10); + for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe(10); + + buf.fill(11, 0, buf.length >> 1); + for (let i = 0; i < buf.length >> 1; i++) expect(buf[i]).toBe(11); + for (let i = (buf.length >> 1) + 1; i < buf.length; i++) expect(buf[i]).toBe(10); + + buf.fill("h"); + for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe("h".charCodeAt(0)); + + buf.fill(0); + for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe(0); + + buf.fill(null); + for (let i = 0; i < buf.length; i++) expect(buf[i]).toBe(0); + + buf.fill(1, 16, 32); + for (let i = 0; i < 16; i++) expect(buf[i]).toBe(0); + for (let i = 16; i < 32; i++) expect(buf[i]).toBe(1); + for (let i = 32; i < buf.length; i++) expect(buf[i]).toBe(0); +}); + +it("alloc() repeat pattern", () => { + const buf = Buffer.alloc(10, "abc"); + expect(buf.toString()).toBe("abcabcabca"); + buf.fill("է"); + expect(buf.toString()).toBe("էէէէէ"); +}); + +it("fill() should properly check `start` & `end`", () => { + // // Testing process.binding. Make sure "start" is properly checked for range + // // errors. + // expect(() => internalBinding("buffer").fill(Buffer.alloc(1), 1, -1, 0, 1)).toThrow(RangeError); + + // Make sure "end" is properly checked, even if it's magically mangled using + // Symbol.toPrimitive. + expect(() => { + const end = { + [Symbol.toPrimitive]() { + return 1; + }, + }; + Buffer.alloc(1).fill(Buffer.alloc(1), 0, end); + }).toThrow(TypeError); + + // Testing process.binding. Make sure "end" is properly checked for range + // errors. + // expect(() => internalBinding("buffer").fill(Buffer.alloc(1), 1, 1, -2, 1)).toThrow(RangeError); +}); + +it("bypassing `length` should not cause an abort", () => { + const buf = Buffer.from("w00t"); + expect(buf).toStrictEqual(Buffer.from([119, 48, 48, 116])); + Object.defineProperty(buf, "length", { + value: 1337, + enumerable: true, + }); + // Node.js throws here, but we can handle it just fine + buf.fill(""); + expect(buf).toStrictEqual(Buffer.from([0, 0, 0, 0])); +}); + +it("allocUnsafeSlow().fill()", () => { + expect(Buffer.allocUnsafeSlow(16).fill("ab", "utf16le")).toStrictEqual( + Buffer.from("61006200610062006100620061006200", "hex"), + ); + + expect(Buffer.allocUnsafeSlow(15).fill("ab", "utf16le")).toStrictEqual( + Buffer.from("610062006100620061006200610062", "hex"), + ); + + expect(Buffer.allocUnsafeSlow(16).fill("ab", "utf16le")).toStrictEqual( + Buffer.from("61006200610062006100620061006200", "hex"), + ); + expect(Buffer.allocUnsafeSlow(16).fill("a", "utf16le")).toStrictEqual( + Buffer.from("61006100610061006100610061006100", "hex"), + ); + + expect(Buffer.allocUnsafeSlow(16).fill("a", "utf16le").toString("utf16le")).toBe("a".repeat(8)); + expect(Buffer.allocUnsafeSlow(16).fill("a", "latin1").toString("latin1")).toBe("a".repeat(16)); + expect(Buffer.allocUnsafeSlow(16).fill("a", "utf8").toString("utf8")).toBe("a".repeat(16)); + + expect(Buffer.allocUnsafeSlow(16).fill("Љ", "utf16le").toString("utf16le")).toBe("Љ".repeat(8)); + expect(Buffer.allocUnsafeSlow(16).fill("Љ", "latin1").toString("latin1")).toBe("\t".repeat(16)); + expect(Buffer.allocUnsafeSlow(16).fill("Љ", "utf8").toString("utf8")).toBe("Љ".repeat(8)); + + expect(() => { + const buf = Buffer.from("a".repeat(1000)); + + buf.fill("This is not correctly encoded", "hex"); + }).toThrow(); +}); + +it("ArrayBuffer.isView()", () => { + expect(ArrayBuffer.isView(new Buffer(10))).toBe(true); + expect(ArrayBuffer.isView(new SlowBuffer(10))).toBe(true); + expect(ArrayBuffer.isView(Buffer.alloc(10))).toBe(true); + expect(ArrayBuffer.isView(Buffer.allocUnsafe(10))).toBe(true); + expect(ArrayBuffer.isView(Buffer.allocUnsafeSlow(10))).toBe(true); + expect(ArrayBuffer.isView(Buffer.from(""))).toBe(true); +}); + +it("Buffer.byteLength()", () => { + expect(() => Buffer.byteLength(32, "latin1")).toThrow(TypeError); + expect(() => Buffer.byteLength(NaN, "utf8")).toThrow(TypeError); + expect(() => Buffer.byteLength({}, "latin1")).toThrow(TypeError); + expect(() => Buffer.byteLength()).toThrow(TypeError); + + expect(Buffer.byteLength("", undefined, true)).toBe(0); + + // buffer + const incomplete = Buffer.from([0xe4, 0xb8, 0xad, 0xe6, 0x96]); + expect(Buffer.byteLength(incomplete)).toBe(5); + const ascii = Buffer.from("abc"); + expect(Buffer.byteLength(ascii)).toBe(3); + + // ArrayBuffer + const buffer = new ArrayBuffer(8); + expect(Buffer.byteLength(buffer)).toBe(8); + + // TypedArray + const int8 = new Int8Array(8); + expect(Buffer.byteLength(int8)).toBe(8); + const uint8 = new Uint8Array(8); + expect(Buffer.byteLength(uint8)).toBe(8); + const uintc8 = new Uint8ClampedArray(2); + expect(Buffer.byteLength(uintc8)).toBe(2); + const int16 = new Int16Array(8); + expect(Buffer.byteLength(int16)).toBe(16); + const uint16 = new Uint16Array(8); + expect(Buffer.byteLength(uint16)).toBe(16); + const int32 = new Int32Array(8); + expect(Buffer.byteLength(int32)).toBe(32); + const uint32 = new Uint32Array(8); + expect(Buffer.byteLength(uint32)).toBe(32); + const float32 = new Float32Array(8); + expect(Buffer.byteLength(float32)).toBe(32); + const float64 = new Float64Array(8); + expect(Buffer.byteLength(float64)).toBe(64); + + // DataView + const dv = new DataView(new ArrayBuffer(2)); + expect(Buffer.byteLength(dv)).toBe(2); + + // Special case: zero length string + expect(Buffer.byteLength("", "ascii")).toBe(0); + expect(Buffer.byteLength("", "HeX")).toBe(0); + + // utf8 + expect(Buffer.byteLength("∑éllö wørl∂!", "utf-8")).toBe(19); + expect(Buffer.byteLength("κλμνξο", "utf8")).toBe(12); + expect(Buffer.byteLength("挵挶挷挸挹", "utf-8")).toBe(15); + expect(Buffer.byteLength("𠝹𠱓𠱸", "UTF8")).toBe(12); + // Without an encoding, utf8 should be assumed + expect(Buffer.byteLength("hey there")).toBe(9); + expect(Buffer.byteLength("𠱸挶νξ#xx :)")).toBe(17); + expect(Buffer.byteLength("hello world", "")).toBe(11); + // It should also be assumed with unrecognized encoding + expect(Buffer.byteLength("hello world", "abc")).toBe(11); + expect(Buffer.byteLength("ßœ∑≈", "unkn0wn enc0ding")).toBe(10); + + // base64 + expect(Buffer.byteLength("aGVsbG8gd29ybGQ=", "base64")).toBe(11); + expect(Buffer.byteLength("aGVsbG8gd29ybGQ=", "BASE64")).toBe(11); + expect(Buffer.byteLength("bm9kZS5qcyByb2NrcyE=", "base64")).toBe(14); + expect(Buffer.byteLength("aGkk", "base64")).toBe(3); + expect(Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==", "base64")).toBe(25); + // base64url + expect(Buffer.byteLength("aGVsbG8gd29ybGQ", "base64url")).toBe(11); + expect(Buffer.byteLength("aGVsbG8gd29ybGQ", "BASE64URL")).toBe(11); + expect(Buffer.byteLength("bm9kZS5qcyByb2NrcyE", "base64url")).toBe(14); + expect(Buffer.byteLength("aGkk", "base64url")).toBe(3); + expect(Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw", "base64url")).toBe(25); + // special padding + expect(Buffer.byteLength("aaa=", "base64")).toBe(2); + expect(Buffer.byteLength("aaaa==", "base64")).toBe(3); + expect(Buffer.byteLength("aaa=", "base64url")).toBe(2); + expect(Buffer.byteLength("aaaa==", "base64url")).toBe(3); + expect(Buffer.byteLength("Il était tué", "utf8")).toBe(14); + expect(Buffer.byteLength("Il était tué")).toBe(14); + + ["ascii", "latin1", "binary"] + .reduce((es, e) => es.concat(e, e.toUpperCase()), []) + .forEach(encoding => { + expect(Buffer.byteLength("Il était tué", encoding)).toBe(12); + }); + + ["ucs2", "ucs-2", "utf16le", "utf-16le"] + .reduce((es, e) => es.concat(e, e.toUpperCase()), []) + .forEach(encoding => { + expect(Buffer.byteLength("Il était tué", encoding)).toBe(24); + }); + + // Test that ArrayBuffer from a different context is detected correctly + // const arrayBuf = vm.runInNewContext("new ArrayBuffer()"); + // expect(Buffer.byteLength(arrayBuf)).toBe(0); + + // Verify that invalid encodings are treated as utf8 + for (let i = 1; i < 10; i++) { + const encoding = String(i).repeat(i); + + expect(Buffer.isEncoding(encoding)).toBe(false); + expect(Buffer.byteLength("foo", encoding)).toBe(Buffer.byteLength("foo", "utf8")); + } +}); + +it("Buffer.toString(encoding, start, end)", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.toString()).toStrictEqual("0123456789"); + expect(buf.toString("utf8")).toStrictEqual("0123456789"); + expect(buf.toString("utf8", 3)).toStrictEqual("3456789"); + expect(buf.toString("utf8", 3, 4)).toStrictEqual("3"); + + expect(buf.toString("utf8", 3, 100)).toStrictEqual("3456789"); + expect(buf.toString("utf8", 3, 1)).toStrictEqual(""); + expect(buf.toString("utf8", 100, 200)).toStrictEqual(""); + expect(buf.toString("utf8", 100, 1)).toStrictEqual(""); +}); + +it("Buffer.toString(offset, length, encoding)", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.toString(3, 6, "utf8")).toStrictEqual("345678"); + expect(buf.toString(3, 100, "utf8")).toStrictEqual("3456789"); + expect(buf.toString(100, 200, "utf8")).toStrictEqual(""); + expect(buf.toString(100, 50, "utf8")).toStrictEqual(""); +}); + +it("Buffer.asciiSlice())", () => { + const buf = Buffer.from("0123456789", "ascii"); + + expect(buf.asciiSlice()).toStrictEqual("0123456789"); + expect(buf.asciiSlice(3)).toStrictEqual("3456789"); + expect(buf.asciiSlice(3, 4)).toStrictEqual("3"); +}); + +it("Buffer.latin1Slice()", () => { + const buf = Buffer.from("âéö", "latin1"); + + expect(buf.latin1Slice()).toStrictEqual("âéö"); + expect(buf.latin1Slice(1)).toStrictEqual("éö"); + expect(buf.latin1Slice(1, 2)).toStrictEqual("é"); +}); + +it("Buffer.utf8Slice()", () => { + const buf = Buffer.from("あいうえお", "utf8"); + + expect(buf.utf8Slice()).toStrictEqual("あいうえお"); + expect(buf.utf8Slice(3)).toStrictEqual("いうえお"); + expect(buf.utf8Slice(3, 6)).toStrictEqual("い"); +}); + +it("Buffer.hexSlice()", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.hexSlice()).toStrictEqual("30313233343536373839"); + expect(buf.hexSlice(3)).toStrictEqual("33343536373839"); + expect(buf.hexSlice(3, 4)).toStrictEqual("33"); +}); + +it("Buffer.ucs2Slice()", () => { + const buf = Buffer.from("あいうえお", "ucs2"); + + expect(buf.ucs2Slice()).toStrictEqual("あいうえお"); + expect(buf.ucs2Slice(2)).toStrictEqual("いうえお"); + expect(buf.ucs2Slice(2, 6)).toStrictEqual("いう"); +}); + +it("Buffer.base64Slice()", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.base64Slice()).toStrictEqual("MDEyMzQ1Njc4OQ=="); + expect(buf.base64Slice(3)).toStrictEqual("MzQ1Njc4OQ=="); + expect(buf.base64Slice(3, 4)).toStrictEqual("Mw=="); +}); + +it("Buffer.base64urlSlice()", () => { + const buf = Buffer.from("0123456789", "utf8"); + + expect(buf.base64urlSlice()).toStrictEqual("MDEyMzQ1Njc4OQ"); + expect(buf.base64urlSlice(3)).toStrictEqual("MzQ1Njc4OQ"); + expect(buf.base64urlSlice(3, 4)).toStrictEqual("Mw"); +}); + +it("should not crash on invalid UTF-8 byte sequence", () => { + const buf = Buffer.from([0xc0, 0xfd]); + expect(buf.length).toBe(2); + const str = buf.toString(); + expect(str.length).toBe(2); + expect(str).toBe("\uFFFD\uFFFD"); +}); + +it("should not crash on invalid UTF-8 byte sequence with ASCII head", () => { + const buf = Buffer.from([0x42, 0xc0, 0xfd]); + expect(buf.length).toBe(3); + const str = buf.toString(); + expect(str.length).toBe(3); + expect(str).toBe("B\uFFFD\uFFFD"); +}); + +it("should not perform out-of-bound access on invalid UTF-8 byte sequence", () => { + const buf = Buffer.from([0x01, 0x9a, 0x84, 0x13, 0x12, 0x11, 0x10, 0x09]).subarray(2); + expect(buf.length).toBe(6); + const str = buf.toString(); + expect(str.length).toBe(6); + expect(str).toBe("\uFFFD\x13\x12\x11\x10\x09"); +}); + +it("repro #2063", () => { + const buf = Buffer.from( + "eyJlbWFpbCI6Ijg3MTg4NDYxN0BxcS5jb20iLCJpZCI6OCwicm9sZSI6Im5vcm1hbCIsImlhdCI6MTY3NjI4NDQyMSwiZXhwIjoxNjc2ODg5MjIxfQ", + "base64", + ); + expect(buf.length).toBe(85); + expect(buf[82]).toBe(50); + expect(buf[83]).toBe(49); + expect(buf[84]).toBe(125); +}); + +it("inspect() should exist", () => { + expect(Buffer.prototype.inspect).toBeInstanceOf(Function); + expect(new Buffer("123").inspect()).toBe(Bun.inspect(new Buffer("123"))); +}); + +it("read alias", () => { + var buf = new Buffer(1024); + var data = new DataView(buf.buffer); + + data.setUint8(0, 200, false); + + expect(buf.readUint8(0)).toBe(buf.readUInt8(0)); + expect(buf.readUintBE(0, 4)).toBe(buf.readUIntBE(0, 4)); + expect(buf.readUintLE(0, 4)).toBe(buf.readUIntLE(0, 4)); + expect(buf.readUint16BE(0)).toBe(buf.readUInt16BE(0)); + expect(buf.readUint16LE(0)).toBe(buf.readUInt16LE(0)); + expect(buf.readUint32BE(0)).toBe(buf.readUInt32BE(0)); + expect(buf.readUint32LE(0)).toBe(buf.readUInt32LE(0)); + expect(buf.readBigUint64BE(0)).toBe(buf.readBigUInt64BE(0)); + expect(buf.readBigUint64LE(0)).toBe(buf.readBigUInt64LE(0)); +}); + +it("write alias", () => { + var buf = new Buffer(1024); + var buf2 = new Buffer(1024); + + function reset() { + new Uint8Array(buf.buffer).fill(0); + new Uint8Array(buf2.buffer).fill(0); + } + + function shouldBeSame(name, name2, ...args) { + buf[name].call(buf, ...args); + buf2[name2].call(buf2, ...args); + + expect(buf).toStrictEqual(buf2); + reset(); + } + + shouldBeSame("writeUint8", "writeUInt8", 10); + shouldBeSame("writeUintBE", "writeUIntBE", 10, 0, 4); + shouldBeSame("writeUintLE", "writeUIntLE", 10, 0, 4); + shouldBeSame("writeUint16BE", "writeUInt16BE", 1000); + shouldBeSame("writeUint16LE", "writeUInt16LE", 1000); + shouldBeSame("writeUint32BE", "writeUInt32BE", 1000); + shouldBeSame("writeUint32LE", "writeUInt32LE", 1000); + shouldBeSame("writeBigUint64BE", "writeBigUInt64BE", BigInt(1000)); + shouldBeSame("writeBigUint64LE", "writeBigUInt64LE", BigInt(1000)); +}); From 061b32626b7f30fef2121f3d955482fb569a9840 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:30:46 -0700 Subject: [PATCH 08/22] Use native for utf-8-validate --- src/bun.js/modules/UTF8ValidateModule.h | 20 +++++++++++++++++++ src/bun.js/modules/_NativeModule.h | 3 ++- ...lModuleRegistry+createInternalModuleById.h | 3 --- src/js/out/InternalModuleRegistry+enum.h | 5 ++--- .../InternalModuleRegistry+numberOfModules.h | 2 +- src/js/out/InternalModuleRegistryConstants.h | 12 ----------- src/js/out/NativeModuleImpl.h | 1 + src/js/out/ResolvedSourceTag.zig | 6 +++--- src/js/out/SyntheticModuleType.h | 6 +++--- src/js/thirdparty/utf-8-validate.ts | 2 -- .../utf-8-validate/utf-8-validate.test.ts | 2 -- 11 files changed, 32 insertions(+), 30 deletions(-) create mode 100644 src/bun.js/modules/UTF8ValidateModule.h delete mode 100644 src/js/thirdparty/utf-8-validate.ts diff --git a/src/bun.js/modules/UTF8ValidateModule.h b/src/bun.js/modules/UTF8ValidateModule.h new file mode 100644 index 00000000000000..18f309e6308d6e --- /dev/null +++ b/src/bun.js/modules/UTF8ValidateModule.h @@ -0,0 +1,20 @@ + +using namespace JSC; +using namespace WebCore; + +namespace Zig { +inline void +generateNativeModule_UTF8Validate(JSC::JSGlobalObject *globalObject, + JSC::Identifier moduleKey, + Vector &exportNames, + JSC::MarkedArgumentBuffer &exportValues) { + auto &vm = globalObject->vm(); + + exportNames.append(vm.propertyNames->defaultKeyword); + exportValues.append(JSC::JSFunction::create( + vm, globalObject, 1, "utf8Validate"_s, jsBufferConstructorFunction_isUtf8, + ImplementationVisibility::Public, NoIntrinsic, + jsBufferConstructorFunction_isUtf8)); +} + +} // namespace Zig diff --git a/src/bun.js/modules/_NativeModule.h b/src/bun.js/modules/_NativeModule.h index 01a112d0b35811..96eb9ad9d2a5b2 100644 --- a/src/bun.js/modules/_NativeModule.h +++ b/src/bun.js/modules/_NativeModule.h @@ -31,7 +31,8 @@ macro("node:process"_s, NodeProcess) \ macro("node:string_decoder"_s, NodeStringDecoder) \ macro("node:tty"_s, NodeTTY) \ - macro("node:util/types"_s, NodeUtilTypes) \ + macro("node:util/types"_s, NodeUtilTypes) \ + macro("utf-8-validate"_s, UTF8Validate) \ #if ASSERT_ENABLED diff --git a/src/js/out/InternalModuleRegistry+createInternalModuleById.h b/src/js/out/InternalModuleRegistry+createInternalModuleById.h index a5b13b0a470aae..e64c71ff44f3d0 100644 --- a/src/js/out/InternalModuleRegistry+createInternalModuleById.h +++ b/src/js/out/InternalModuleRegistry+createInternalModuleById.h @@ -164,9 +164,6 @@ JSValue InternalModuleRegistry::createInternalModuleById(JSGlobalObject* globalO case Field::ThirdpartyUndici: { INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "undici"_s, "thirdparty/undici.js"_s, InternalModuleRegistryConstants::ThirdpartyUndiciCode); } - case Field::ThirdpartyUtf8Validate: { - INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "utf-8-validate"_s, "thirdparty/utf-8-validate.js"_s, InternalModuleRegistryConstants::ThirdpartyUtf8ValidateCode); - } case Field::ThirdpartyVercelFetch: { INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "vercel_fetch"_s, "thirdparty/vercel_fetch.js"_s, InternalModuleRegistryConstants::ThirdpartyVercelFetchCode); } diff --git a/src/js/out/InternalModuleRegistry+enum.h b/src/js/out/InternalModuleRegistry+enum.h index e454e4d4e4307b..7d72e3d261081f 100644 --- a/src/js/out/InternalModuleRegistry+enum.h +++ b/src/js/out/InternalModuleRegistry+enum.h @@ -52,7 +52,6 @@ ThirdpartyDetectLibcLinux = 50, ThirdpartyIsomorphicFetch = 51, ThirdpartyNodeFetch = 52, ThirdpartyUndici = 53, -ThirdpartyUtf8Validate = 54, -ThirdpartyVercelFetch = 55, -ThirdpartyWS = 56, +ThirdpartyVercelFetch = 54, +ThirdpartyWS = 55, diff --git a/src/js/out/InternalModuleRegistry+numberOfModules.h b/src/js/out/InternalModuleRegistry+numberOfModules.h index 517f9d237ff3ca..67d159029849d9 100644 --- a/src/js/out/InternalModuleRegistry+numberOfModules.h +++ b/src/js/out/InternalModuleRegistry+numberOfModules.h @@ -1 +1 @@ -#define BUN_INTERNAL_MODULE_COUNT 57 +#define BUN_INTERNAL_MODULE_COUNT 56 diff --git a/src/js/out/InternalModuleRegistryConstants.h b/src/js/out/InternalModuleRegistryConstants.h index b4bd0dae5c45e8..4872d356366bc1 100644 --- a/src/js/out/InternalModuleRegistryConstants.h +++ b/src/js/out/InternalModuleRegistryConstants.h @@ -220,10 +220,6 @@ static constexpr ASCIILiteral ThirdpartyNodeFetchCode = "(function (){\"use stri static constexpr ASCIILiteral ThirdpartyUndiciCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),{Readable}=StreamModule,{_ReadableFromWebForUndici:ReadableFromWeb}=StreamModule[Symbol.for(\"::bunternal::\")],ObjectCreate=Object.create,kEmptyObject=ObjectCreate(null);var fetch=Bun.fetch,Response=globalThis.Response,Headers=globalThis.Headers,Request=globalThis.Request,URLSearchParams=globalThis.URLSearchParams,URL=globalThis.URL;class File extends Blob{constructor(){super(...arguments)}}class FileReader extends EventTarget{constructor(){throw new Error(\"Not implemented yet!\")}}var FormData=globalThis.FormData;function notImplemented(){throw new Error(\"Not implemented in bun\")}class BodyReadable extends ReadableFromWeb{#response;#bodyUsed;constructor(response,options={}){var{body}=response;if(!body)throw new Error(\"Response body is null\");super(options,body);this.#response=response,this.#bodyUsed=response.bodyUsed}get bodyUsed(){return this.#bodyUsed}#consume(){if(this.#bodyUsed)@throwTypeError(\"unusable\");this.#bodyUsed=!0}async arrayBuffer(){return this.#consume(),await this.#response.arrayBuffer()}async blob(){return this.#consume(),await this.#response.blob()}async formData(){return this.#consume(),await this.#response.formData()}async json(){return this.#consume(),await this.#response.json()}async text(){return this.#consume(),await this.#response.text()}}async function request(url,options={method:\"GET\",signal:null,headers:null,query:null,reset:!1,throwOnError:!1,body:null}){let{method=\"GET\",headers:inputHeaders,query,signal,reset=!1,throwOnError=!1,body:inputBody,maxRedirections}=options;if(typeof url===\"string\"){if(query)url=new URL(url)}else if(typeof url===\"object\"&&url!==null){if(!(url instanceof URL))throw new Error(\"not implemented\")}else @throwTypeError(\"url must be a string, URL, or UrlObject\");if(typeof url===\"string\"&&query)url=new URL(url);if(typeof url===\"object\"&&url!==null&&query){if(query)url.search=new URLSearchParams(query).toString()}if(method=method&&typeof method===\"string\"\?method.toUpperCase():null,inputBody&&(method===\"GET\"||method===\"HEAD\"))throw new Error(\"Body not allowed for GET or HEAD requests\");if(inputBody&&inputBody.read&&inputBody instanceof Readable){let data=\"\";inputBody.setEncoding(\"utf8\");for await(let chunk of stream)data+=chunk;inputBody=(new TextEncoder()).encode(data)}if(maxRedirections!==void 0&&Number.isNaN(maxRedirections))throw new Error(\"maxRedirections must be a number if defined\");if(signal&&!(signal instanceof AbortSignal))throw new Error(\"signal must be an instance of AbortSignal\");let resp;const{status:statusCode,headers,trailers}=resp=await fetch(url,{signal,mode:\"cors\",method,headers:inputHeaders||kEmptyObject,body:inputBody,redirect:maxRedirections===\"undefined\"||maxRedirections>0\?\"follow\":\"manual\",keepalive:!reset});if(throwOnError&&statusCode>=400&&statusCode<600)throw new Error(`Request failed with status code ${statusCode}`);const body=resp.body\?new BodyReadable(resp):null;return{statusCode,headers:headers.toJSON(),body,trailers,opaque:kEmptyObject,context:kEmptyObject}}function stream(){throw new Error(\"Not implemented in bun\")}function pipeline(){throw new Error(\"Not implemented in bun\")}function connect(){throw new Error(\"Not implemented in bun\")}function upgrade(){throw new Error(\"Not implemented in bun\")}class MockClient{constructor(){throw new Error(\"Not implemented in bun\")}}class MockPool{constructor(){throw new Error(\"Not implemented in bun\")}}class MockAgent{constructor(){throw new Error(\"Not implemented in bun\")}}function mockErrors(){throw new Error(\"Not implemented in bun\")}function Undici(){throw new Error(\"Not implemented in bun\")}class Dispatcher extends EventEmitter{constructor(){super(...arguments)}}class Agent extends Dispatcher{constructor(){super(...arguments)}}class Pool extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}class BalancedPool extends Dispatcher{constructor(){super(...arguments)}}class Client extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}return Undici.Dispatcher=Dispatcher,Undici.Pool=Pool,Undici.BalancedPool=BalancedPool,Undici.Client=Client,Undici.Agent=Agent,Undici.buildConnector=Undici.errors=Undici.setGlobalDispatcher=Undici.getGlobalDispatcher=Undici.request=Undici.stream=Undici.pipeline=Undici.connect=Undici.upgrade=Undici.MockClient=Undici.MockPool=Undici.MockAgent=Undici.mockErrors=notImplemented,Undici.fetch=fetch,{fetch,Response,Headers,Request,URLSearchParams,URL,File,FileReader,FormData,request,stream,pipeline,connect,upgrade,MockClient,MockPool,MockAgent,mockErrors,Dispatcher,Pool,BalancedPool,Client,Agent,Undici}})\n"_s; // -// -static constexpr ASCIILiteral ThirdpartyUtf8ValidateCode = "(function (){\"use strict\";return @requireNativeModule(\"node:buffer\").isUtf8})\n"_s; -// - // static constexpr ASCIILiteral ThirdpartyVercelFetchCode = "(function (){\"use strict\";var $=(wrapper=Bun.fetch)=>{async function vercelFetch(url,opts={}){if(opts.body&&typeof opts.body===\"object\"&&(!(\"buffer\"in opts.body)||typeof opts.body.buffer!==\"object\"||!(opts.body.buffer instanceof ArrayBuffer))){if(opts.body=JSON.stringify(opts.body),!opts.headers)opts.headers=new Headers;opts.headers.set(\"Content-Type\",\"application/json\")}try{return await wrapper(url,opts)}catch(err){if(typeof err===\"string\")err=new Error(err);throw err.url=url,err.opts=opts,err}}return vercelFetch.default=vercelFetch,vercelFetch};return $})\n"_s; // @@ -449,10 +445,6 @@ static constexpr ASCIILiteral ThirdpartyNodeFetchCode = "(function (){\"use stri static constexpr ASCIILiteral ThirdpartyUndiciCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),{Readable}=StreamModule,{_ReadableFromWebForUndici:ReadableFromWeb}=StreamModule[Symbol.for(\"::bunternal::\")],ObjectCreate=Object.create,kEmptyObject=ObjectCreate(null);var fetch=Bun.fetch,Response=globalThis.Response,Headers=globalThis.Headers,Request=globalThis.Request,URLSearchParams=globalThis.URLSearchParams,URL=globalThis.URL;class File extends Blob{constructor(){super(...arguments)}}class FileReader extends EventTarget{constructor(){throw new Error(\"Not implemented yet!\")}}var FormData=globalThis.FormData;function notImplemented(){throw new Error(\"Not implemented in bun\")}class BodyReadable extends ReadableFromWeb{#response;#bodyUsed;constructor(response,options={}){var{body}=response;if(!body)throw new Error(\"Response body is null\");super(options,body);this.#response=response,this.#bodyUsed=response.bodyUsed}get bodyUsed(){return this.#bodyUsed}#consume(){if(this.#bodyUsed)@throwTypeError(\"unusable\");this.#bodyUsed=!0}async arrayBuffer(){return this.#consume(),await this.#response.arrayBuffer()}async blob(){return this.#consume(),await this.#response.blob()}async formData(){return this.#consume(),await this.#response.formData()}async json(){return this.#consume(),await this.#response.json()}async text(){return this.#consume(),await this.#response.text()}}async function request(url,options={method:\"GET\",signal:null,headers:null,query:null,reset:!1,throwOnError:!1,body:null}){let{method=\"GET\",headers:inputHeaders,query,signal,reset=!1,throwOnError=!1,body:inputBody,maxRedirections}=options;if(typeof url===\"string\"){if(query)url=new URL(url)}else if(typeof url===\"object\"&&url!==null){if(!(url instanceof URL))throw new Error(\"not implemented\")}else @throwTypeError(\"url must be a string, URL, or UrlObject\");if(typeof url===\"string\"&&query)url=new URL(url);if(typeof url===\"object\"&&url!==null&&query){if(query)url.search=new URLSearchParams(query).toString()}if(method=method&&typeof method===\"string\"\?method.toUpperCase():null,inputBody&&(method===\"GET\"||method===\"HEAD\"))throw new Error(\"Body not allowed for GET or HEAD requests\");if(inputBody&&inputBody.read&&inputBody instanceof Readable){let data=\"\";inputBody.setEncoding(\"utf8\");for await(let chunk of stream)data+=chunk;inputBody=(new TextEncoder()).encode(data)}if(maxRedirections!==void 0&&Number.isNaN(maxRedirections))throw new Error(\"maxRedirections must be a number if defined\");if(signal&&!(signal instanceof AbortSignal))throw new Error(\"signal must be an instance of AbortSignal\");let resp;const{status:statusCode,headers,trailers}=resp=await fetch(url,{signal,mode:\"cors\",method,headers:inputHeaders||kEmptyObject,body:inputBody,redirect:maxRedirections===\"undefined\"||maxRedirections>0\?\"follow\":\"manual\",keepalive:!reset});if(throwOnError&&statusCode>=400&&statusCode<600)throw new Error(`Request failed with status code ${statusCode}`);const body=resp.body\?new BodyReadable(resp):null;return{statusCode,headers:headers.toJSON(),body,trailers,opaque:kEmptyObject,context:kEmptyObject}}function stream(){throw new Error(\"Not implemented in bun\")}function pipeline(){throw new Error(\"Not implemented in bun\")}function connect(){throw new Error(\"Not implemented in bun\")}function upgrade(){throw new Error(\"Not implemented in bun\")}class MockClient{constructor(){throw new Error(\"Not implemented in bun\")}}class MockPool{constructor(){throw new Error(\"Not implemented in bun\")}}class MockAgent{constructor(){throw new Error(\"Not implemented in bun\")}}function mockErrors(){throw new Error(\"Not implemented in bun\")}function Undici(){throw new Error(\"Not implemented in bun\")}class Dispatcher extends EventEmitter{constructor(){super(...arguments)}}class Agent extends Dispatcher{constructor(){super(...arguments)}}class Pool extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}class BalancedPool extends Dispatcher{constructor(){super(...arguments)}}class Client extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}return Undici.Dispatcher=Dispatcher,Undici.Pool=Pool,Undici.BalancedPool=BalancedPool,Undici.Client=Client,Undici.Agent=Agent,Undici.buildConnector=Undici.errors=Undici.setGlobalDispatcher=Undici.getGlobalDispatcher=Undici.request=Undici.stream=Undici.pipeline=Undici.connect=Undici.upgrade=Undici.MockClient=Undici.MockPool=Undici.MockAgent=Undici.mockErrors=notImplemented,Undici.fetch=fetch,{fetch,Response,Headers,Request,URLSearchParams,URL,File,FileReader,FormData,request,stream,pipeline,connect,upgrade,MockClient,MockPool,MockAgent,mockErrors,Dispatcher,Pool,BalancedPool,Client,Agent,Undici}})\n"_s; // -// -static constexpr ASCIILiteral ThirdpartyUtf8ValidateCode = "(function (){\"use strict\";return @requireNativeModule(\"node:buffer\").isUtf8})\n"_s; -// - // static constexpr ASCIILiteral ThirdpartyVercelFetchCode = "(function (){\"use strict\";var $=(wrapper=Bun.fetch)=>{async function vercelFetch(url,opts={}){if(opts.body&&typeof opts.body===\"object\"&&(!(\"buffer\"in opts.body)||typeof opts.body.buffer!==\"object\"||!(opts.body.buffer instanceof ArrayBuffer))){if(opts.body=JSON.stringify(opts.body),!opts.headers)opts.headers=new Headers;opts.headers.set(\"Content-Type\",\"application/json\")}try{return await wrapper(url,opts)}catch(err){if(typeof err===\"string\")err=new Error(err);throw err.url=url,err.opts=opts,err}}return vercelFetch.default=vercelFetch,vercelFetch};return $})\n"_s; // @@ -679,10 +671,6 @@ static constexpr ASCIILiteral ThirdpartyNodeFetchCode = "(function (){\"use stri static constexpr ASCIILiteral ThirdpartyUndiciCode = "(function (){\"use strict\";const EventEmitter=@getInternalField(@internalModuleRegistry,15)||@createInternalModuleById(15),StreamModule=@getInternalField(@internalModuleRegistry,34)||@createInternalModuleById(34),{Readable}=StreamModule,{_ReadableFromWebForUndici:ReadableFromWeb}=StreamModule[Symbol.for(\"::bunternal::\")],ObjectCreate=Object.create,kEmptyObject=ObjectCreate(null);var fetch=Bun.fetch,Response=globalThis.Response,Headers=globalThis.Headers,Request=globalThis.Request,URLSearchParams=globalThis.URLSearchParams,URL=globalThis.URL;class File extends Blob{constructor(){super(...arguments)}}class FileReader extends EventTarget{constructor(){throw new Error(\"Not implemented yet!\")}}var FormData=globalThis.FormData;function notImplemented(){throw new Error(\"Not implemented in bun\")}class BodyReadable extends ReadableFromWeb{#response;#bodyUsed;constructor(response,options={}){var{body}=response;if(!body)throw new Error(\"Response body is null\");super(options,body);this.#response=response,this.#bodyUsed=response.bodyUsed}get bodyUsed(){return this.#bodyUsed}#consume(){if(this.#bodyUsed)@throwTypeError(\"unusable\");this.#bodyUsed=!0}async arrayBuffer(){return this.#consume(),await this.#response.arrayBuffer()}async blob(){return this.#consume(),await this.#response.blob()}async formData(){return this.#consume(),await this.#response.formData()}async json(){return this.#consume(),await this.#response.json()}async text(){return this.#consume(),await this.#response.text()}}async function request(url,options={method:\"GET\",signal:null,headers:null,query:null,reset:!1,throwOnError:!1,body:null}){let{method=\"GET\",headers:inputHeaders,query,signal,reset=!1,throwOnError=!1,body:inputBody,maxRedirections}=options;if(typeof url===\"string\"){if(query)url=new URL(url)}else if(typeof url===\"object\"&&url!==null){if(!(url instanceof URL))throw new Error(\"not implemented\")}else @throwTypeError(\"url must be a string, URL, or UrlObject\");if(typeof url===\"string\"&&query)url=new URL(url);if(typeof url===\"object\"&&url!==null&&query){if(query)url.search=new URLSearchParams(query).toString()}if(method=method&&typeof method===\"string\"\?method.toUpperCase():null,inputBody&&(method===\"GET\"||method===\"HEAD\"))throw new Error(\"Body not allowed for GET or HEAD requests\");if(inputBody&&inputBody.read&&inputBody instanceof Readable){let data=\"\";inputBody.setEncoding(\"utf8\");for await(let chunk of stream)data+=chunk;inputBody=(new TextEncoder()).encode(data)}if(maxRedirections!==void 0&&Number.isNaN(maxRedirections))throw new Error(\"maxRedirections must be a number if defined\");if(signal&&!(signal instanceof AbortSignal))throw new Error(\"signal must be an instance of AbortSignal\");let resp;const{status:statusCode,headers,trailers}=resp=await fetch(url,{signal,mode:\"cors\",method,headers:inputHeaders||kEmptyObject,body:inputBody,redirect:maxRedirections===\"undefined\"||maxRedirections>0\?\"follow\":\"manual\",keepalive:!reset});if(throwOnError&&statusCode>=400&&statusCode<600)throw new Error(`Request failed with status code ${statusCode}`);const body=resp.body\?new BodyReadable(resp):null;return{statusCode,headers:headers.toJSON(),body,trailers,opaque:kEmptyObject,context:kEmptyObject}}function stream(){throw new Error(\"Not implemented in bun\")}function pipeline(){throw new Error(\"Not implemented in bun\")}function connect(){throw new Error(\"Not implemented in bun\")}function upgrade(){throw new Error(\"Not implemented in bun\")}class MockClient{constructor(){throw new Error(\"Not implemented in bun\")}}class MockPool{constructor(){throw new Error(\"Not implemented in bun\")}}class MockAgent{constructor(){throw new Error(\"Not implemented in bun\")}}function mockErrors(){throw new Error(\"Not implemented in bun\")}function Undici(){throw new Error(\"Not implemented in bun\")}class Dispatcher extends EventEmitter{constructor(){super(...arguments)}}class Agent extends Dispatcher{constructor(){super(...arguments)}}class Pool extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}class BalancedPool extends Dispatcher{constructor(){super(...arguments)}}class Client extends Dispatcher{constructor(){super(...arguments)}request(){throw new Error(\"Not implemented in bun\")}}return Undici.Dispatcher=Dispatcher,Undici.Pool=Pool,Undici.BalancedPool=BalancedPool,Undici.Client=Client,Undici.Agent=Agent,Undici.buildConnector=Undici.errors=Undici.setGlobalDispatcher=Undici.getGlobalDispatcher=Undici.request=Undici.stream=Undici.pipeline=Undici.connect=Undici.upgrade=Undici.MockClient=Undici.MockPool=Undici.MockAgent=Undici.mockErrors=notImplemented,Undici.fetch=fetch,{fetch,Response,Headers,Request,URLSearchParams,URL,File,FileReader,FormData,request,stream,pipeline,connect,upgrade,MockClient,MockPool,MockAgent,mockErrors,Dispatcher,Pool,BalancedPool,Client,Agent,Undici}})\n"_s; // -// -static constexpr ASCIILiteral ThirdpartyUtf8ValidateCode = "(function (){\"use strict\";return @requireNativeModule(\"node:buffer\").isUtf8})\n"_s; -// - // static constexpr ASCIILiteral ThirdpartyVercelFetchCode = "(function (){\"use strict\";var $=(wrapper=Bun.fetch)=>{async function vercelFetch(url,opts={}){if(opts.body&&typeof opts.body===\"object\"&&(!(\"buffer\"in opts.body)||typeof opts.body.buffer!==\"object\"||!(opts.body.buffer instanceof ArrayBuffer))){if(opts.body=JSON.stringify(opts.body),!opts.headers)opts.headers=new Headers;opts.headers.set(\"Content-Type\",\"application/json\")}try{return await wrapper(url,opts)}catch(err){if(typeof err===\"string\")err=new Error(err);throw err.url=url,err.opts=opts,err}}return vercelFetch.default=vercelFetch,vercelFetch};return $})\n"_s; // diff --git a/src/js/out/NativeModuleImpl.h b/src/js/out/NativeModuleImpl.h index 8669a8b086e503..f519e7d7de0044 100644 --- a/src/js/out/NativeModuleImpl.h +++ b/src/js/out/NativeModuleImpl.h @@ -6,3 +6,4 @@ #include "../../bun.js/modules/NodeStringDecoderModule.h" #include "../../bun.js/modules/NodeTTYModule.h" #include "../../bun.js/modules/NodeUtilTypesModule.h" +#include "../../bun.js/modules/UTF8ValidateModule.h" diff --git a/src/js/out/ResolvedSourceTag.zig b/src/js/out/ResolvedSourceTag.zig index cfbb31e0a1861b..f054d09d77b615 100644 --- a/src/js/out/ResolvedSourceTag.zig +++ b/src/js/out/ResolvedSourceTag.zig @@ -63,9 +63,8 @@ pub const ResolvedSourceTag = enum(u32) { @"isomorphic-fetch" = 563, @"node-fetch" = 564, @"undici" = 565, - @"utf-8-validate" = 566, - @"vercel_fetch" = 567, - @"ws" = 568, + @"vercel_fetch" = 566, + @"ws" = 567, // Native modules run through a different system using ESM registry. @"bun:jsc" = 1024, @"node:buffer" = 1025, @@ -75,4 +74,5 @@ pub const ResolvedSourceTag = enum(u32) { @"node:string_decoder" = 1029, @"node:tty" = 1030, @"node:util/types" = 1031, + @"utf-8-validate" = 1032, }; diff --git a/src/js/out/SyntheticModuleType.h b/src/js/out/SyntheticModuleType.h index 08488dec3fe77d..12ec073ad61a47 100644 --- a/src/js/out/SyntheticModuleType.h +++ b/src/js/out/SyntheticModuleType.h @@ -63,9 +63,8 @@ enum SyntheticModuleType : uint32_t { ThirdpartyIsomorphicFetch = 563, ThirdpartyNodeFetch = 564, ThirdpartyUndici = 565, - ThirdpartyUtf8Validate = 566, - ThirdpartyVercelFetch = 567, - ThirdpartyWS = 568, + ThirdpartyVercelFetch = 566, + ThirdpartyWS = 567, // Native modules run through the same system, but with different underlying initializers. // They also have bit 10 set to differentiate them from JS builtins. @@ -78,5 +77,6 @@ enum SyntheticModuleType : uint32_t { NodeStringDecoder = 1029, NodeTTY = 1030, NodeUtilTypes = 1031, + UTF8Validate = 1032, }; diff --git a/src/js/thirdparty/utf-8-validate.ts b/src/js/thirdparty/utf-8-validate.ts deleted file mode 100644 index fcab46ff1736d8..00000000000000 --- a/src/js/thirdparty/utf-8-validate.ts +++ /dev/null @@ -1,2 +0,0 @@ -// https://github.com/websockets/utf-8-validate#api -export default require('node:buffer').isUtf8; diff --git a/test/js/first_party/utf-8-validate/utf-8-validate.test.ts b/test/js/first_party/utf-8-validate/utf-8-validate.test.ts index 33469c970de912..781f9df8458f14 100644 --- a/test/js/first_party/utf-8-validate/utf-8-validate.test.ts +++ b/test/js/first_party/utf-8-validate/utf-8-validate.test.ts @@ -1,9 +1,7 @@ import { test, expect } from "bun:test"; -import { isUtf8 } from "node:buffer"; import isValidUTF8 from "utf-8-validate"; test("utf-8-validate", () => { - expect(isValidUTF8).toBe(isUtf8); expect(isValidUTF8(Buffer.from("😀"))).toBeTrue(); expect(isValidUTF8(Buffer.from([0xff]))).toBeFalse(); }); From 8efa67cc1ebeea349d2df10321bef49655dcf3bc Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:31:55 -0700 Subject: [PATCH 09/22] Add module ID names to builtins --- src/bun.js/bindings/ModuleLoader.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index 2e4dfa88e5bc84..88fd5b9e0cf687 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -436,12 +436,14 @@ JSValue fetchCommonJSModule( default: { if (tag & SyntheticModuleType::InternalModuleRegistryFlag) { constexpr auto mask = (SyntheticModuleType::InternalModuleRegistryFlag - 1); + auto result = globalObject->internalModuleRegistry()->requireId(globalObject, vm, static_cast(tag & mask)); + RETURN_IF_EXCEPTION(scope, {}); + target->putDirect( vm, builtinNames.exportsPublicName(), - globalObject->internalModuleRegistry()->requireId(globalObject, vm, static_cast(tag & mask)), + result, JSC::PropertyAttribute::ReadOnly | 0); - RETURN_IF_EXCEPTION(scope, {}); RELEASE_AND_RETURN(scope, target); } else { RELEASE_AND_RETURN(scope, jsNumber(-1)); @@ -592,8 +594,7 @@ static JSValue fetchESMSourceCode( default: { if (tag & SyntheticModuleType::InternalModuleRegistryFlag) { constexpr auto mask = (SyntheticModuleType::InternalModuleRegistryFlag - 1); - auto* internalModule = jsCast(globalObject->internalModuleRegistry()->requireId(globalObject, vm, static_cast(tag & mask))); - auto source = JSC::SourceCode(JSC::SyntheticSourceProvider::create(generateInternalModuleSourceCode(globalObject, internalModule), JSC::SourceOrigin(), WTFMove(moduleKey))); + auto source = JSC::SourceCode(JSC::SyntheticSourceProvider::create(generateInternalModuleSourceCode(globalObject, static_cast(tag & mask)), JSC::SourceOrigin(URL(makeString("builtins://", moduleKey))), moduleKey)); return rejectOrResolve(JSSourceCode::create(vm, WTFMove(source))); } else { auto&& provider = Zig::SourceProvider::create(globalObject, res->result.value, JSC::SourceProviderSourceType::Module, true); From 4459be4a7ef1c886585026331da9297da269e4c3 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:32:27 -0700 Subject: [PATCH 10/22] Defer evaluation of ESM & CJS modules until link time --- src/bun.js/bindings/ModuleLoader.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index 88fd5b9e0cf687..67ea9508e6b3a2 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -65,19 +65,25 @@ static JSC::JSInternalPromise* resolvedInternalPromise(JSC::JSGlobalObject* glob } // Converts an object from InternalModuleRegistry into { ...obj, default: obj } -JSC::SyntheticSourceProvider::SyntheticSourceGenerator -generateInternalModuleSourceCode(JSC::JSGlobalObject* globalObject, JSC::JSObject* object) +static JSC::SyntheticSourceProvider::SyntheticSourceGenerator +generateInternalModuleSourceCode(JSC::JSGlobalObject* globalObject, InternalModuleRegistry::Field moduleId) { - return [object](JSC::JSGlobalObject* lexicalGlobalObject, + return [moduleId](JSC::JSGlobalObject* lexicalGlobalObject, JSC::Identifier moduleKey, Vector& exportNames, JSC::MarkedArgumentBuffer& exportValues) -> void { JSC::VM& vm = lexicalGlobalObject->vm(); - GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); - JSC::EnsureStillAliveScope stillAlive(object); - + GlobalObject* globalObject = jsCast(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); + auto* object = jsCast(globalObject->internalModuleRegistry()->requireId(globalObject, vm, moduleId)); + if (!object) { + return; + } + RETURN_IF_EXCEPTION(throwScope, {}); + + JSC::EnsureStillAliveScope stillAlive(object); + PropertyNameArray properties(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); object->getPropertyNames(globalObject, properties, DontEnumPropertiesMode::Exclude); From a21972d6b181705e8c8ce3562dcf9d6f2f8e007e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:32:36 -0700 Subject: [PATCH 11/22] Use builtin name for exports in plugins --- src/bun.js/bindings/ModuleLoader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index 67ea9508e6b3a2..2c8b956123b70f 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -108,7 +108,8 @@ static OnLoadResult handleOnLoadObjectResult(Zig::GlobalObject* globalObject, JS OnLoadResult result {}; result.type = OnLoadResultTypeObject; JSC::VM& vm = globalObject->vm(); - if (JSC::JSValue exportsValue = object->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "exports"_s))) { + auto& builtinNames = WebCore::builtinNames(vm); + if (JSC::JSValue exportsValue = object->getIfPropertyExists(globalObject, builtinNames.exportsPublicName())) { if (exportsValue.isObject()) { result.value.object = exportsValue; return result; From cbcc29581d32e34b4fcb5d541bf469d6ce8976bb Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:32:54 -0700 Subject: [PATCH 12/22] Add module IDs to builtins --- .../bindings/InternalModuleRegistry.cpp | 65 ++++++++++--------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/src/bun.js/bindings/InternalModuleRegistry.cpp b/src/bun.js/bindings/InternalModuleRegistry.cpp index 552e9fbfe3edd7..e6b574d7b351cd 100644 --- a/src/bun.js/bindings/InternalModuleRegistry.cpp +++ b/src/bun.js/bindings/InternalModuleRegistry.cpp @@ -16,33 +16,34 @@ namespace Bun { // JS builtin that acts as a module. In debug mode, we use a different implementation that reads // from the developer's filesystem. This allows reloading code without recompiling bindings. -#define INTERNAL_MODULE_REGISTRY_GENERATE_(globalObject, vm, SOURCE, moduleName) \ - auto throwScope = DECLARE_THROW_SCOPE(vm); \ - \ - SourceCode source = JSC::makeSource(SOURCE, SourceOrigin(WTF::URL("builtin://" #moduleName ".js"_s)), #moduleName ".js"_s); \ - \ - JSFunction* func \ - = JSFunction::create( \ - vm, \ - createBuiltinExecutable( \ - vm, source, \ - Identifier(), \ - ImplementationVisibility::Public, \ - ConstructorKind::None, \ - ConstructAbility::CannotConstruct) \ - ->link(vm, nullptr, source), \ - static_cast(globalObject)); \ - \ - JSC::MarkedArgumentBuffer argList; \ - \ - JSValue result = JSC::call( \ - globalObject, \ - func, \ - JSC::getCallData(func), \ - globalObject, JSC::MarkedArgumentBuffer()); \ - \ - RETURN_IF_EXCEPTION(throwScope, {}); \ - ASSERT_INTERNAL_MODULE(result, moduleName); \ +#define INTERNAL_MODULE_REGISTRY_GENERATE_(globalObject, vm, SOURCE, moduleName) \ + auto throwScope = DECLARE_THROW_SCOPE(vm); \ + auto&& origin = SourceOrigin(WTF::URL(makeString("builtin://"_s, moduleName))); \ + SourceCode source = JSC::makeSource(SOURCE, origin, moduleName); \ + \ + JSFunction* func \ + = JSFunction::create( \ + vm, \ + createBuiltinExecutable( \ + vm, source, \ + Identifier(), \ + ImplementationVisibility::Public, \ + ConstructorKind::None, \ + ConstructAbility::CannotConstruct) \ + ->link(vm, nullptr, source), \ + static_cast(globalObject)); \ + \ + RETURN_IF_EXCEPTION(throwScope, {}); \ + \ + JSC::MarkedArgumentBuffer argList; \ + JSValue result = JSC::call( \ + globalObject, \ + func, \ + JSC::getCallData(func), \ + globalObject, JSC::MarkedArgumentBuffer()); \ + \ + RETURN_IF_EXCEPTION(throwScope, {}); \ + ASSERT_INTERNAL_MODULE(result, moduleName); \ return result; #if BUN_DEBUG @@ -129,11 +130,15 @@ JSValue InternalModuleRegistry::requireId(JSGlobalObject* globalObject, VM& vm, // so we want to write it to the internal field when loaded. JSC_DEFINE_HOST_FUNCTION(InternalModuleRegistry::jsCreateInternalModuleById, (JSGlobalObject * lexicalGlobalObject, CallFrame* callframe)) { + auto& vm = lexicalGlobalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); auto id = callframe->argument(0).toUInt32(lexicalGlobalObject); + auto registry = static_cast(lexicalGlobalObject)->internalModuleRegistry(); - auto module = registry->createInternalModuleById(lexicalGlobalObject, lexicalGlobalObject->vm(), static_cast(id)); - registry->internalField(static_cast(id)).set(lexicalGlobalObject->vm(), registry, module); - return JSValue::encode(module); + auto mod = registry->createInternalModuleById(lexicalGlobalObject, vm, static_cast(id)); + RETURN_IF_EXCEPTION(throwScope, {}); + registry->internalField(static_cast(id)).set(vm, registry, mod); + return JSValue::encode(mod); } } // namespace Bun From 1d8eb6079f4e59f449b18cb555aa083563b4e7d7 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 2 Aug 2023 23:33:04 -0700 Subject: [PATCH 13/22] Update JSC build with new flag --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index ea7a6a1e7cfff3..b0514217273837 100644 --- a/Makefile +++ b/Makefile @@ -1192,6 +1192,7 @@ jsc-build-mac-compile: -DPORT="JSCOnly" \ -DENABLE_STATIC_JSC=ON \ -DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \ + -DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \ -DCMAKE_BUILD_TYPE=Release \ -DUSE_THIN_ARCHIVES=OFF \ -DBUN_FAST_TLS=ON \ @@ -1214,6 +1215,7 @@ jsc-build-mac-compile-lto: -DPORT="JSCOnly" \ -DENABLE_STATIC_JSC=ON \ -DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \ + -DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \ -DCMAKE_BUILD_TYPE=Release \ -DUSE_THIN_ARCHIVES=OFF \ -DBUN_FAST_TLS=ON \ @@ -1241,6 +1243,7 @@ jsc-build-mac-compile-debug: -DUSE_THIN_ARCHIVES=OFF \ -DENABLE_FTL_JIT=ON \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \ -G Ninja \ $(CMAKE_FLAGS_WITHOUT_RELEASE) \ -DPTHREAD_JIT_PERMISSIONS_API=1 \ @@ -1264,6 +1267,7 @@ jsc-build-linux-compile-config: -DENABLE_FTL_JIT=ON \ -DENABLE_REMOTE_INSPECTOR=ON \ -DJSEXPORT_PRIVATE=WTF_EXPORT_DECLARATION \ + -DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \ -USE_VISIBILITY_ATTRIBUTE=1 \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -G Ninja \ From af57b38d922716c71d2b243b39632bc08ce71d48 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 01:56:11 -0700 Subject: [PATCH 14/22] WebKit upgrade fixes --- src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 4 ++-- src/bun.js/bindings/webcore/HTTPParsers.cpp | 8 ++++---- src/bun.js/bindings/webcore/ParsedContentType.cpp | 8 ++++---- src/bun.js/modules/BunJSCModule.h | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index b177a1b6f1fecd..b4c806a2d6c2bf 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -1088,7 +1088,7 @@ static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlo // This rowBuffer is a stack allocation. MarkedVector rowBuffer; - rowBuffer.fill(count, [&](JSValue* value) -> void { + rowBuffer.fill(vm, count, [&](JSValue* value) -> void { // Loop 1. Fill the rowBuffer with values from SQLite for (int i = 0; i < count; i++, value++) { switch (sqlite3_column_type(stmt, i)) { @@ -1139,7 +1139,7 @@ static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlo result = JSC::constructEmptyObject(vm, structure); // TODO: Add .forEach to MarkedVector<>. When JSC assertions are enabled, this function will fail. - rowBuffer.fill(count, [&](JSValue* value) -> void { + rowBuffer.fill(vm, count, [&](JSValue* value) -> void { // Loop 2. fill the rowBuffer with values from SQLite for (unsigned int i = 0; i < count; i++, value++) { result->putDirectOffset(vm, i, *value); diff --git a/src/bun.js/bindings/webcore/HTTPParsers.cpp b/src/bun.js/bindings/webcore/HTTPParsers.cpp index f2c4ff989c70d9..66aec49254fdac 100644 --- a/src/bun.js/bindings/webcore/HTTPParsers.cpp +++ b/src/bun.js/bindings/webcore/HTTPParsers.cpp @@ -543,7 +543,7 @@ XSSProtectionDisposition parseXSSProtectionHeader(const String& header, String& ContentTypeOptionsDisposition parseContentTypeOptionsHeader(StringView header) { StringView leftToken = header.left(header.find(',')); - if (equalLettersIgnoringASCIICase(leftToken.trim(isJSONOrHTTPWhitespace), "nosniff"_s)) + if (equalLettersIgnoringASCIICase(leftToken.trim(isASCIIWhitespaceWithoutFF), "nosniff"_s)) return ContentTypeOptionsDisposition::Nosniff; return ContentTypeOptionsDisposition::None; } @@ -602,7 +602,7 @@ XFrameOptionsDisposition parseXFrameOptionsHeader(StringView header) // return result; // for (auto value : StringView(headerValue).split(',')) { -// auto trimmedValue = value.trim(isJSONOrHTTPWhitespace); +// auto trimmedValue = value.trim(isASCIIWhitespaceWithoutFF); // if (trimmedValue == "\"cache\""_s) // result.add(ClearSiteDataValue::Cache); // else if (trimmedValue == "\"cookies\""_s) @@ -632,7 +632,7 @@ bool parseRange(StringView range, RangeAllowWhitespace allowWhitespace, long lon if (!startsWithLettersIgnoringASCIICase(range, "bytes"_s)) return false; - auto byteRange = range.substring(bytesLength).trim(isJSONOrHTTPWhitespace); + auto byteRange = range.substring(bytesLength).trim(isASCIIWhitespaceWithoutFF); if (!byteRange.startsWith('=')) return false; @@ -962,7 +962,7 @@ bool isSafeMethod(const String& method) CrossOriginResourcePolicy parseCrossOriginResourcePolicyHeader(StringView header) { - auto trimmedHeader = header.trim(isJSONOrHTTPWhitespace); + auto trimmedHeader = header.trim(isASCIIWhitespaceWithoutFF); if (trimmedHeader.isEmpty()) return CrossOriginResourcePolicy::None; diff --git a/src/bun.js/bindings/webcore/ParsedContentType.cpp b/src/bun.js/bindings/webcore/ParsedContentType.cpp index c4773b3ee91693..38e0f532c17d03 100644 --- a/src/bun.js/bindings/webcore/ParsedContentType.cpp +++ b/src/bun.js/bindings/webcore/ParsedContentType.cpp @@ -40,7 +40,7 @@ namespace WebCore { static void skipSpaces(StringView input, unsigned& startIndex) { - while (startIndex < input.length() && isJSONOrHTTPWhitespace(input[startIndex])) + while (startIndex < input.length() && isASCIIWhitespaceWithoutFF(input[startIndex])) ++startIndex; } @@ -78,7 +78,7 @@ static StringView parseToken(StringView input, unsigned& startIndex, CharacterMe while (input[tokenEnd - 1] == ' ') --tokenEnd; } else { - while (isJSONOrHTTPWhitespace(input[tokenEnd - 1])) + while (isASCIIWhitespaceWithoutFF(input[tokenEnd - 1])) --tokenEnd; } } @@ -328,7 +328,7 @@ bool ParsedContentType::parseContentType(Mode mode) std::optional ParsedContentType::create(const String& contentType, Mode mode) { - ParsedContentType parsedContentType(mode == Mode::Rfc2045 ? contentType : contentType.trim(isJSONOrHTTPWhitespace)); + ParsedContentType parsedContentType(mode == Mode::Rfc2045 ? contentType : contentType.trim(isASCIIWhitespaceWithoutFF)); if (!parsedContentType.parseContentType(mode)) return std::nullopt; return { WTFMove(parsedContentType) }; @@ -368,7 +368,7 @@ void ParsedContentType::setContentType(String&& contentRange, Mode mode) { m_mimeType = WTFMove(contentRange); if (mode == Mode::MimeSniff) - m_mimeType = StringView(m_mimeType).trim(isJSONOrHTTPWhitespace).convertToASCIILowercase(); + m_mimeType = StringView(m_mimeType).trim(isASCIIWhitespaceWithoutFF).convertToASCIILowercase(); else m_mimeType = m_mimeType.trim(deprecatedIsSpaceOrNewline); } diff --git a/src/bun.js/modules/BunJSCModule.h b/src/bun.js/modules/BunJSCModule.h index c5350fcd76c008..0569c135e8144a 100644 --- a/src/bun.js/modules/BunJSCModule.h +++ b/src/bun.js/modules/BunJSCModule.h @@ -311,7 +311,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSamplingProfilerStackTraces, globalObject, scope, createError(globalObject, "Sampling profiler was never started"_s))); - WTF::String jsonString = vm.samplingProfiler()->stackTracesAsJSON(); + WTF::String jsonString = vm.samplingProfiler()->stackTracesAsJSON()->toJSONString(); JSC::EncodedJSValue result = JSC::JSValue::encode(JSONParse(globalObject, jsonString)); scope.releaseAssertNoException(); @@ -520,7 +520,7 @@ JSC_DEFINE_HOST_FUNCTION(functionRunProfiler, (JSGlobalObject * globalObject, samplingProfiler.reportTopBytecodes(byteCodes); JSValue stackTraces = - JSONParse(globalObject, samplingProfiler.stackTracesAsJSON()); + JSONParse(globalObject, samplingProfiler.stackTracesAsJSON()->toJSONString()); samplingProfiler.shutdown(); samplingProfiler.clearData(); From ccc8dd44bfb99163bfaae0b09d4f0bfed2467c14 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 02:09:39 -0700 Subject: [PATCH 15/22] Update WebKit --- src/bun.js/WebKit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit index 284095ff91529d..99e3ead622f188 160000 --- a/src/bun.js/WebKit +++ b/src/bun.js/WebKit @@ -1 +1 @@ -Subproject commit 284095ff91529df883cf5ab30d66048a3207bade +Subproject commit 99e3ead622f1882f83584a730bf4ee67311e85a5 From 09e6a3d5db4bca7776dd78b4a2b251b78b651f57 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 02:12:25 -0700 Subject: [PATCH 16/22] prettier --- src/js/_codegen/build-modules.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/js/_codegen/build-modules.ts b/src/js/_codegen/build-modules.ts index d4a482e0568a30..f18bee0333aedc 100644 --- a/src/js/_codegen/build-modules.ts +++ b/src/js/_codegen/build-modules.ts @@ -282,9 +282,7 @@ fs.writeFileSync( .map( (id, n) => `// -static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( - bundledOutputs.darwin.get(id.slice(0, -3)), - )}_s; +static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString(bundledOutputs.darwin.get(id.slice(0, -3)))}_s; // `, ) @@ -294,9 +292,7 @@ static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( .map( (id, n) => `// -static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( - bundledOutputs.win32.get(id.slice(0, -3)), - )}_s; +static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString(bundledOutputs.win32.get(id.slice(0, -3)))}_s; // `, ) @@ -307,9 +303,7 @@ static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( .map( (id, n) => `// -static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString( - bundledOutputs.linux.get(id.slice(0, -3)), - )}_s; +static constexpr ASCIILiteral ${idToEnumName(id)}Code = ${fmtCPPString(bundledOutputs.linux.get(id.slice(0, -3)))}_s; // `, ) From ab0f84057717eed2ca47736009cfa5dd71213041 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 12:28:29 -0700 Subject: [PATCH 17/22] Upgrade WebKit --- .github/workflows/bun-linux-aarch64.yml | 2 +- .github/workflows/bun-linux-build.yml | 4 ++-- .github/workflows/bun-mac-aarch64.yml | 16 ++++++++-------- .github/workflows/bun-mac-x64-baseline.yml | 16 ++++++++-------- .github/workflows/bun-mac-x64.yml | 16 ++++++++-------- Dockerfile | 2 +- bun.lockb | Bin 73269 -> 73269 bytes package.json | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml index aaeda6c4e16215..14560e07e9ce4c 100644 --- a/.github/workflows/bun-linux-aarch64.yml +++ b/.github/workflows/bun-linux-aarch64.yml @@ -36,7 +36,7 @@ jobs: arch: aarch64 build_arch: arm64 runner: linux-arm64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-linux-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-linux-arm64-lto.tar.gz" webkit_basename: "bun-webkit-linux-arm64-lto" build_machine_arch: aarch64 diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml index 9ad92e6b19e6cd..acee135f0211c8 100644 --- a/.github/workflows/bun-linux-build.yml +++ b/.github/workflows/bun-linux-build.yml @@ -46,7 +46,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 - cpu: nehalem @@ -54,7 +54,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml index 7fa73017c0f866..90fabb785419d3 100644 --- a/.github/workflows/bun-mac-aarch64.yml +++ b/.github/workflows/bun-mac-aarch64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: native @@ -152,7 +152,7 @@ jobs: tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 dependencies: true compile_obj: true @@ -257,7 +257,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -265,14 +265,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" - cpu: native arch: aarch64 tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 package: bun-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml index bd75ec20212e42..f053ebb6abc758 100644 --- a/.github/workflows/bun-mac-x64-baseline.yml +++ b/.github/workflows/bun-mac-x64-baseline.yml @@ -117,7 +117,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: nehalem @@ -135,7 +135,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -258,7 +258,7 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -266,14 +266,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml index 371486effedf8d..f93b72e8f24dc9 100644 --- a/.github/workflows/bun-mac-x64.yml +++ b/.github/workflows/bun-mac-x64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: haswell @@ -126,7 +126,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: haswell @@ -144,7 +144,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -260,7 +260,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" - cpu: haswell arch: x86_64 tag: bun-darwin-x64 @@ -268,14 +268,14 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-july23/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index 304bf680d961cc..db6523e049bace 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ARG ARCH=x86_64 ARG BUILD_MACHINE_ARCH=x86_64 ARG TRIPLET=${ARCH}-linux-gnu ARG BUILDARCH=amd64 -ARG WEBKIT_TAG=2023-july23 +ARG WEBKIT_TAG=2023-aug3 ARG ZIG_TAG=jul1 ARG ZIG_VERSION="0.11.0-dev.4006+bf827d0b5" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" diff --git a/bun.lockb b/bun.lockb index 19dd97bbddcc5e6e0013c392df8a28ea45e98258..5d5dbaed5b03c51c5cc13960ed5e6d34acff0a84 100755 GIT binary patch delta 4726 zcmdnGhh^&?mI-Y_Y0=-Y4Lxx4>I&F+nUQaqD) zNNEUI2O2UnG9bX_1w1QMIQn0nkvVqn_l3z9cqArg7%CtH1Y{*AuQZfL2wX6h4gqA~SP-iM^b#{Zo(L2?tI#>$O*|Xmx$9?W}!x=Plov{<+T= zdL-Qa>E3O(nm1DYilcUi@?96{Ba_O!{M8!&*-oBYB~iaKBQ)idjg zny+_!iKR)EPKc5pnt#tF>YGqzvRI=2wta}VL859EFSQ!}NO!W*Hh!kT2 zs%r!$6&?nLhUA<~y{uxOAw-IS^cEDQ)|ZrIrWSECGcfQ24FLOsLkGvDF17!=ZrfU#9C1`Kvd4h9A;Xz-^N=Va!UFffz@#dv{Yp!lSr zSUo)~!DB}~O?`*cVo>mB73)?e*5~Fha08P*A2g`Jf^-zCA1I5V_SQp!fsQ@~SquvP zqRiZ)#I$+_hNR3qc*zA3q@!3pw8*5p#ZY_e$+Z|1go(-dMR~wNWPvyX11B^AlPFeC ziDtZdK@OZG2`Sj-0BK+)3NFl0#py8_mmkJxS^?V@0Y(*)wQ)_a6=dX|o-fF#K%QRq=`RFHuy=Z+3@~6GNHg+o KPZMH1&kX>MKrk!- delta 4746 zcmdnGhh^&?mI-&J~6%M-+OY@ed`1g}9@JLL~ zFjPPY2*^rKUTG+g5V&Ayf#3v)NKV!?LYC!`*qmYX)!pGh=EGaES93TuH}Zs;y6{FN zeiV_k^_~#;eB->dH{x5~&2uu>d%2y{cm6iRCQX@t?96FTuGN3-cW`14pEvtR;mOH! zt0d~>wr>e+$p5;1lCh_))h4+!6K0FEH|%*>&bZHGj*r-hS%q#V&bHoo{OrxM;w$Zv zZJW%5IcD8q^D(>sEOW1Abg3KAkBkf~K*+!_6^LPg<%#!-7lr}7fp%_8jz=VY!#_p% z9+|J`d8U2wyx)^&oqw>4@$bSt9@>&OL)X-r1?{?KQ6QcwH??l!)AWybs@AJyhEMjb zmZ+E6V31UB?cigR(9HMD9HAy`TWjp>OSYAnu{5>1Gwyf(o_z0PHs__jI}3&O=%^pc z)Zu*|BR#24JoV|n9jWyj8JC0=RZfcFWeovaHWj8 z&kwyD#;;#GOK{A5exBFc{dnyDZ<1y{yJvkr{&ueZ_mq;hUD8jq zq@!3pK^M~2G4-J4ANHW3t;JA#>jyUYCF=<#5E_R9F#VAn{E#X-sWdYuh2fqu0|PfS zRi_q{E>=&8W-92d2R1B7cQq9(hT2xbLo<`jHy*cZ6RmpsK>1+5IMRbU@K(8ddYWjOYMzQHk0*sT1wrO(UM}_GL0*r#w-w80PkgSbsdaWQM_w;;0 jMg{WpvQK{@$f%-Dq%Ws8$S|r+e<01syFE>a@jN#Gusk9= diff --git a/package.json b/package.json index 9da688e5fccba4..24496789e32c7e 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@types/ws": "^8.5.5", "@typescript-eslint/eslint-plugin": "^5.31.0", "@typescript-eslint/parser": "^5.31.0", - "bun-webkit": "0.0.1-3a53c6af693c5f387de752b0c793ac1ab5f0a164" + "bun-webkit": "0.0.1-99e3ead622f1882f83584a730bf4ee67311e85a5" }, "version": "0.0.0", "prettier": "./.prettierrc.cjs" From 71212543ab3cf7a96e64955440f55e304d780211 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 12:45:59 -0700 Subject: [PATCH 18/22] bump --- src/bun.js/modules/BunJSCModule.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bun.js/modules/BunJSCModule.h b/src/bun.js/modules/BunJSCModule.h index 0569c135e8144a..d7548dcdfcc698 100644 --- a/src/bun.js/modules/BunJSCModule.h +++ b/src/bun.js/modules/BunJSCModule.h @@ -47,6 +47,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartRemoteDebugger, #if ENABLE(REMOTE_INSPECTOR) static const char *defaultHost = "127.0.0.1\0"; static uint16_t defaultPort = 9230; // node + 1 + auto &vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); @@ -311,7 +312,8 @@ JSC_DEFINE_HOST_FUNCTION(functionSamplingProfilerStackTraces, globalObject, scope, createError(globalObject, "Sampling profiler was never started"_s))); - WTF::String jsonString = vm.samplingProfiler()->stackTracesAsJSON()->toJSONString(); + WTF::String jsonString = + vm.samplingProfiler()->stackTracesAsJSON()->toJSONString(); JSC::EncodedJSValue result = JSC::JSValue::encode(JSONParse(globalObject, jsonString)); scope.releaseAssertNoException(); @@ -519,8 +521,8 @@ JSC_DEFINE_HOST_FUNCTION(functionRunProfiler, (JSGlobalObject * globalObject, StringPrintStream byteCodes; samplingProfiler.reportTopBytecodes(byteCodes); - JSValue stackTraces = - JSONParse(globalObject, samplingProfiler.stackTracesAsJSON()->toJSONString()); + JSValue stackTraces = JSONParse( + globalObject, samplingProfiler.stackTracesAsJSON()->toJSONString()); samplingProfiler.shutdown(); samplingProfiler.clearData(); From bfd049561325bd425f4dfa69bb8d20600e5674a2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 14:44:03 -0700 Subject: [PATCH 19/22] Update once again --- .github/workflows/bun-linux-aarch64.yml | 2 +- .github/workflows/bun-linux-build.yml | 4 ++-- .github/workflows/bun-mac-aarch64.yml | 16 ++++++++-------- .github/workflows/bun-mac-x64-baseline.yml | 16 ++++++++-------- .github/workflows/bun-mac-x64.yml | 16 ++++++++-------- Dockerfile | 2 +- bun.lockb | Bin 73269 -> 73269 bytes package.json | 2 +- src/bun.js/WebKit | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml index 14560e07e9ce4c..f40c0b5b558311 100644 --- a/.github/workflows/bun-linux-aarch64.yml +++ b/.github/workflows/bun-linux-aarch64.yml @@ -36,7 +36,7 @@ jobs: arch: aarch64 build_arch: arm64 runner: linux-arm64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-linux-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-linux-arm64-lto.tar.gz" webkit_basename: "bun-webkit-linux-arm64-lto" build_machine_arch: aarch64 diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml index acee135f0211c8..02c9b94ebd9b18 100644 --- a/.github/workflows/bun-linux-build.yml +++ b/.github/workflows/bun-linux-build.yml @@ -46,7 +46,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 - cpu: nehalem @@ -54,7 +54,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml index 90fabb785419d3..8946f109d16681 100644 --- a/.github/workflows/bun-mac-aarch64.yml +++ b/.github/workflows/bun-mac-aarch64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: native @@ -152,7 +152,7 @@ jobs: tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 dependencies: true compile_obj: true @@ -257,7 +257,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -265,14 +265,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" - cpu: native arch: aarch64 tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 package: bun-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml index f053ebb6abc758..83feeaf2033ab9 100644 --- a/.github/workflows/bun-mac-x64-baseline.yml +++ b/.github/workflows/bun-mac-x64-baseline.yml @@ -117,7 +117,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: nehalem @@ -135,7 +135,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -258,7 +258,7 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -266,14 +266,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml index f93b72e8f24dc9..d76a4abb5daa27 100644 --- a/.github/workflows/bun-mac-x64.yml +++ b/.github/workflows/bun-mac-x64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: haswell @@ -126,7 +126,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: haswell @@ -144,7 +144,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -260,7 +260,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" - cpu: haswell arch: x86_64 tag: bun-darwin-x64 @@ -268,14 +268,14 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-1/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/Dockerfile b/Dockerfile index db6523e049bace..7e829ef30b8025 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ARG ARCH=x86_64 ARG BUILD_MACHINE_ARCH=x86_64 ARG TRIPLET=${ARCH}-linux-gnu ARG BUILDARCH=amd64 -ARG WEBKIT_TAG=2023-aug3 +ARG WEBKIT_TAG=2023-aug3-1 ARG ZIG_TAG=jul1 ARG ZIG_VERSION="0.11.0-dev.4006+bf827d0b5" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" diff --git a/bun.lockb b/bun.lockb index 5d5dbaed5b03c51c5cc13960ed5e6d34acff0a84..4fd85fa55102ab150de335db5526e3142e3f3146 100755 GIT binary patch delta 4697 zcmdnGhh^&?mI-+>7^oOzfh zaUg(oh~DaKX?5!3hwNoUCbtEXyOY zIm76yyMt-QyTAa^CoNUk6=5B#jf6}RHchK}`sOQR^%rB)^AoPjkh65wJ+QL6I;2FM z@zd`0*QRBpDxY!|QPaNIx8~>~pUHEpBlYNhbC7cD7*Dm?1 zwyKobb@Tn~$%{f7UmgE2d&Lf>*0bT~pXcZ8kC=H#)b#UJ&5cEzS`I+xFfuT32mtBn zFsA`&7LiNa4KrOU!{#4<`QB^!(sRfAgTHw&hu@3cc55#`w~$@&?cU&S?yZsuT20Aw zFSqn~+&>t+WsmTk*LNCM%C0CWXxaR?T7$R#-Cib;sUXj1vNABlnd%uZ5Glq4RM!Y} z8xI3RLvl{0URE*C5F*7udJBqDOX^E9Q;WEn85sD1hJXcAQ1na zv;>bG^}t}Do$qj33<~K*z}OP22L`(&2Ll5aH271Cb29Tv7#PZdV!S{xP<+x-tezg0 z;IX5groO{vF(~-6igha!bL(>$xPeKZ4;s`EK{|?o;vW>pbhj94Z~Z`63=00D%-o{H zG=_SHq|7{cHh~J#Q4ARVpx~#!#ZY_eA;Cbhk3m70n4Djf2Q+7aI0FMGG(JfctEWUW zKD{6ZPLhNaY;%A#u>J%mbTqMgY=U$Y1I9n7=*8ng+B&8lchJz*VyM0Kpwy2RCv>qG zYH$6(2EQaQ{&A#Ctf2r()v3ivrI|S?4EK~77`UOSnrtyp`;TnRRM1;bHJ^~@n0m^C zkUWc__5#~~0~!38^<*R@P$Dc&%`HnU0=E4P5$!~B#Nh2eax}x5R}|>2rpW~OPIZ#?eMCRXwEg941I)7S7bifR*Syk1Fq)%5p*jAGN71Q@3f zYtQ7sj|$Th1Q-RUzXMuGsxGeSwStV?)AI!x70J@dKK+Ft@wQHHlmUjx18GLy?P)@c G=eYr-s6@R0 delta 4697 zcmdnGhh^&?mI-Y_Y0=-Y4Lxx4>I&F+nU&OFS4 zhRmC%@N7}x=zn=e=GeX87baiek(iuesDKaUg(oh~DaKX?5!3hwNoUCbtEXyOY zIm76yyF<~6%*^>E_Hx4ZPd$1k95~sm*Iv1z)%CTuv-aVgw|r;%=RRNPk#P5?d$-+c z-bnQ;j@li{cU`29Oe*v8S8M!dJ9%!EME%Z;)SQhw1rF_H(2F*CBgx%n$yOBHIKS-P zUD87kKrn#JbyNS?R1U_8;7 zduzd|^F79D%JmX_^+qe#z6{zj*|%Dve(z?n)o=eNE;lsK45{>LIHb_OQe?gMT=$$# z5u;<;^D_f@ru)x{6<|-)zSOa`>Rwj^`?(o%WfCkLYPv>3?&an{=P)uba0meD=`g1O zX_h2AR^E{NYU!Wn#TQLJ%Cx&&bCHC~m14tZ=N3lA-MX&JRoz!Bus}%iRnM#|YQEkb zzPZa1`AKcJ=<6&TE zNY2UB%PIyMLZlc-Z$VLNNqtFXY7sXx0|P(M5U^lsYH~&;0|T;w1+){Zhr61Fmf*3Y z9vBR?^Bqo$K_R^e7+YfXz+ji;U|`^a27hXCPG(*S14B7bj29>diceaK)ziZgJa*L6 z)OWZn1_ggsv2JBzZhZ~|H!$h*L4z71NJlYH{Db0{?iNGstse-BLBU^?nOl^Y#!%0Y zl$i(5CQv~-iUGqP6#VqJ7;0}lBp68cF(?QVlknjwV)*O^}Xa!1xChy?9(mTgTMn4jS5847Il&l={))gf13C?X4f! z;Fko(KaP}%H55RpI<+{dG&3iK;hr)B12;5PlPv~n|BN`sI* zi=p-c?FSb$6a*nfAs9eyi#Okxe$!jsGSxUWF~!WtD9zBq!YIwc*wn%#(cIV|Da|A` z)y&-3&@k1)G|_bPjmI6@#44VCP=HZ&`Wk*lQEeiP*DFb{n*LspQEWPs0OJ&5?U@|- zQDJ(50HfgacR&kC)x|ZvR*;c Date: Thu, 3 Aug 2023 15:29:17 -0700 Subject: [PATCH 20/22] Add visitAdditionalChildren, remove .fill() usage --- src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 137 ++++++++++-------- 1 file changed, 73 insertions(+), 64 deletions(-) diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index b4c806a2d6c2bf..d42f01019463fd 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -175,6 +175,8 @@ class JSSQLStatement : public JSC::JSNonFinalObject { } DECLARE_VISIT_CHILDREN; DECLARE_EXPORT_INFO; + template void visitAdditionalChildren(Visitor&); + template static void visitOutputConstraints(JSCell*, Visitor&); // static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); @@ -263,6 +265,8 @@ static void initializeColumnNames(JSC::JSGlobalObject* lexicalGlobalObject, JSSQ if (LIKELY(!anyHoles)) { Structure* structure = globalObject.structureCache().emptyObjectStructureForPrototype(&globalObject, globalObject.objectPrototype(), columnNames->size()); + vm.writeBarrier(castedThis, structure); + for (const auto& propertyName : *columnNames) { structure = Structure::addPropertyTransition(vm, structure, propertyName, 0, offset); } @@ -423,8 +427,10 @@ static JSC::JSValue rebindObject(JSC::JSGlobalObject* globalObject, JSC::JSValue JSValue value; if (LIKELY(!slot.isTaintedByOpaqueObject())) value = slot.getValue(globalObject, propertyName); - else + else { value = target->get(globalObject, propertyName); + RETURN_IF_EXCEPTION(scope, JSValue()); + } // Ensure this gets freed on scope clear auto utf8 = WTF::String(propertyName.string()).utf8(); @@ -1075,76 +1081,57 @@ static inline JSC::JSValue constructResultObject(JSC::JSGlobalObject* lexicalGlo auto* stmt = castedThis->stmt; if (auto* structure = castedThis->_structure.get()) { - RELEASE_ASSERT(count <= 64); - // It looks a little silly doing these two loops right? - // - // The code that does putDirectOffset has to be very careful about time between GC allocations - // while the object is not fully initialized. - // - // So we do two loops - // 1. The first loop to fill all the values from SQLite into a MarkedVector. - // 2. The second loop to actually put them into the object. - - // This rowBuffer is a stack allocation. - MarkedVector rowBuffer; - - rowBuffer.fill(vm, count, [&](JSValue* value) -> void { - // Loop 1. Fill the rowBuffer with values from SQLite - for (int i = 0; i < count; i++, value++) { - switch (sqlite3_column_type(stmt, i)) { - case SQLITE_INTEGER: { - // https://github.com/oven-sh/bun/issues/1536 - *value = jsNumber(sqlite3_column_int64(stmt, i)); - break; - } - case SQLITE_FLOAT: { - *value = jsNumber(sqlite3_column_double(stmt, i)); - break; - } - // > Note that the SQLITE_TEXT constant was also used in SQLite version - // > 2 for a completely different meaning. Software that links against - // > both SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, - // > not SQLITE_TEXT. - case SQLITE3_TEXT: { - size_t len = sqlite3_column_bytes(stmt, i); - const unsigned char* text = len > 0 ? sqlite3_column_text(stmt, i) : nullptr; - - if (len > 64) { - *value = JSC::JSValue::decode(Bun__encoding__toStringUTF8(text, len, lexicalGlobalObject)); - continue; - } - - *value = jsString(vm, WTF::String::fromUTF8(text, len)); - break; - } - case SQLITE_BLOB: { - size_t len = sqlite3_column_bytes(stmt, i); - const void* blob = len > 0 ? sqlite3_column_blob(stmt, i) : nullptr; - JSC::JSUint8Array* array = JSC::JSUint8Array::createUninitialized(lexicalGlobalObject, lexicalGlobalObject->m_typedArrayUint8.get(lexicalGlobalObject), len); + result = JSC::constructEmptyObject(vm, structure); - if (LIKELY(blob && len)) - memcpy(array->vector(), blob, len); + for (unsigned int i = 0; i < count; i++) { + JSValue value; - *value = array; - break; - } - default: { - *value = jsNull(); - break; - } + // Loop 1. Fill the rowBuffer with values from SQLite + switch (sqlite3_column_type(stmt, i)) { + case SQLITE_INTEGER: { + // https://github.com/oven-sh/bun/issues/1536 + value = jsNumber(sqlite3_column_int64(stmt, i)); + break; + } + case SQLITE_FLOAT: { + value = jsNumber(sqlite3_column_double(stmt, i)); + break; + } + // > Note that the SQLITE_TEXT constant was also used in SQLite version + // > 2 for a completely different meaning. Software that links against + // > both SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, + // > not SQLITE_TEXT. + case SQLITE3_TEXT: { + size_t len = sqlite3_column_bytes(stmt, i); + const unsigned char* text = len > 0 ? sqlite3_column_text(stmt, i) : nullptr; + + if (len > 64) { + value = JSC::JSValue::decode(Bun__encoding__toStringUTF8(text, len, lexicalGlobalObject)); + continue; } + + value = jsString(vm, WTF::String::fromUTF8(text, len)); + break; } - }); + case SQLITE_BLOB: { + size_t len = sqlite3_column_bytes(stmt, i); + const void* blob = len > 0 ? sqlite3_column_blob(stmt, i) : nullptr; + JSC::JSUint8Array* array = JSC::JSUint8Array::createUninitialized(lexicalGlobalObject, lexicalGlobalObject->m_typedArrayUint8.get(lexicalGlobalObject), len); - result = JSC::constructEmptyObject(vm, structure); + if (LIKELY(blob && len)) + memcpy(array->vector(), blob, len); - // TODO: Add .forEach to MarkedVector<>. When JSC assertions are enabled, this function will fail. - rowBuffer.fill(vm, count, [&](JSValue* value) -> void { - // Loop 2. fill the rowBuffer with values from SQLite - for (unsigned int i = 0; i < count; i++, value++) { - result->putDirectOffset(vm, i, *value); + value = array; + break; + } + default: { + value = jsNull(); + break; } - }); + } + + result->putDirectOffset(vm, i, value); + } } else { if (count <= 64) { @@ -1697,4 +1684,26 @@ void JSSQLStatement::visitChildrenImpl(JSCell* cell, Visitor& visitor) } DEFINE_VISIT_CHILDREN(JSSQLStatement); + +template +void JSSQLStatement::visitAdditionalChildren(Visitor& visitor) +{ + JSSQLStatement* thisObject = this; + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + + visitor.append(thisObject->_structure); + visitor.append(thisObject->_prototype); +} + +template +void JSSQLStatement::visitOutputConstraints(JSCell* cell, Visitor& visitor) +{ + auto* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitOutputConstraints(thisObject, visitor); + thisObject->visitAdditionalChildren(visitor); +} + +template void JSSQLStatement::visitOutputConstraints(JSCell*, AbstractSlotVisitor&); +template void JSSQLStatement::visitOutputConstraints(JSCell*, SlotVisitor&); } From 56d434c99d01c11ca55bb13024487c2f76fd03cb Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:29:55 -0700 Subject: [PATCH 21/22] Update process.test.js --- test/js/node/process/process.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index 908485422a9e6d..04b823825ad551 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -66,7 +66,7 @@ it("process.hrtime.bigint()", () => { }); it("process.release", () => { - expect(process.release.name).toBe("bun"); + expect(process.release.name).toBe("node"); expect(process.release.sourceUrl).toContain( `https://github.com/oven-sh/bun/release/bun-v${process.versions.bun}/bun-${process.platform}-${ { arm64: "aarch64", x64: "x64" }[process.arch] || process.arch From 8764f0516a53ae27a26e76723c8917b20866790b Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:31:01 -0700 Subject: [PATCH 22/22] Update fs.test.ts --- test/js/node/fs/fs.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 0b18d215644962..17c010fb63abb2 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -1483,7 +1483,7 @@ it("fs.constants", () => { expect(constants.O_NOFOLLOW).toBeDefined(); expect(constants.O_SYNC).toBeDefined(); expect(constants.O_DSYNC).toBeDefined(); - expect(constants.O_SYMLINK).toBeDefined(); + if (process.platform === "darwin") expect(constants.O_SYMLINK).toBeDefined(); // expect(constants.O_DIRECT).toBeDefined(); expect(constants.O_NONBLOCK).toBeDefined(); expect(constants.S_IFMT).toBeDefined();