zen-code 4.8.5 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +156 -163
- package/dist/{chunk-pbe0n109.js → chunk-02vv5584.js} +1 -1
- package/dist/{chunk-k8ygzjvv.js → chunk-13nyfrmm.js} +1 -1
- package/dist/chunk-1edvf7b5.js +1 -0
- package/dist/chunk-1rmnbdef.js +1 -0
- package/dist/{chunk-dv9rvc0a.js → chunk-1ttywx0y.js} +1 -1
- package/dist/{chunk-pp1gnpdp.js → chunk-1y82m5kn.js} +4 -4
- package/dist/{chunk-v5mgjgc4.js → chunk-30sq2w0d.js} +5 -5
- package/dist/chunk-32ase1cw.js +2 -0
- package/dist/chunk-3490ntd8.js +1 -0
- package/dist/{chunk-8cbtae81.js → chunk-3pcybja5.js} +1 -1
- package/dist/{chunk-rayth86k.js → chunk-4nsg4vcd.js} +1 -1
- package/dist/{chunk-j7f3n1aj.js → chunk-5rr85f28.js} +1 -1
- package/dist/{chunk-xf4jswm4.js → chunk-5x8nxw0t.js} +1 -1
- package/dist/chunk-6rfc36jg.js +1 -0
- package/dist/{chunk-jfecjzq0.js → chunk-76h8pe7x.js} +2 -2
- package/dist/{chunk-ya599ak5.js → chunk-7kdvr78m.js} +2 -2
- package/dist/{chunk-a36ttbrq.js → chunk-8g2zdcy0.js} +2 -2
- package/dist/chunk-8z38ybz7.js +1 -0
- package/dist/{chunk-cpvvtyt1.js → chunk-98f6hg43.js} +2 -2
- package/dist/chunk-9dahn9h7.js +3 -0
- package/dist/chunk-9k5d9vf1.js +1 -0
- package/dist/{chunk-7en8vahs.js → chunk-b52b0t16.js} +1 -1
- package/dist/chunk-b8dxq9rq.js +1 -0
- package/dist/{chunk-3j3wmx6g.js → chunk-cggjws6a.js} +1 -1
- package/dist/chunk-cjqarwdn.js +1 -0
- package/dist/chunk-cs73xbzz.js +1 -0
- package/dist/{chunk-crrspdy9.js → chunk-cyexd09c.js} +2 -2
- package/dist/{chunk-a51szmhp.js → chunk-ep2es95e.js} +1 -1
- package/dist/chunk-f8ewggk1.js +1 -0
- package/dist/{chunk-gs9s59d4.js → chunk-g377vrpj.js} +3 -3
- package/dist/{chunk-hps6tv25.js → chunk-g7pm00z7.js} +2 -2
- package/dist/chunk-gcm4jp0d.js +26 -0
- package/dist/{chunk-mrapdjm5.js → chunk-heasksrr.js} +2 -2
- package/dist/chunk-hfve7nf5.js +2 -0
- package/dist/chunk-j7a40ww9.js +2 -0
- package/dist/chunk-j9aysaeb.js +1 -0
- package/dist/{chunk-6mcx89fj.js → chunk-jbf8ve63.js} +1 -1
- package/dist/{chunk-j3tfxj8n.js → chunk-jfhc5c0d.js} +1 -1
- package/dist/{chunk-ydkkycp3.js → chunk-jxsfzfac.js} +2 -2
- package/dist/{chunk-nr26055z.js → chunk-kba8akjs.js} +1 -1
- package/dist/chunk-m76ya904.js +1 -0
- package/dist/{chunk-45bkb77s.js → chunk-mjzeawnq.js} +2 -2
- package/dist/{chunk-558jjzha.js → chunk-mmq834zt.js} +1 -1
- package/dist/chunk-ns6tjjkq.js +1 -0
- package/dist/{chunk-zssv316b.js → chunk-nwy6n6b6.js} +87 -87
- package/dist/chunk-qd305hg1.js +1 -0
- package/dist/chunk-qez6ejd4.js +1 -0
- package/dist/{chunk-7wxg0yef.js → chunk-r2h3x9zv.js} +1 -1
- package/dist/{chunk-m0e2jefq.js → chunk-rncpxz1b.js} +2 -2
- package/dist/chunk-rz3b356n.js +1 -0
- package/dist/{chunk-k4ftjnx7.js → chunk-trjpzw1n.js} +1 -1
- package/dist/{chunk-7khrhe0x.js → chunk-va71tsw3.js} +3 -3
- package/dist/{chunk-eemwtwb1.js → chunk-wn43r152.js} +1 -1
- package/dist/{chunk-hbhwzk5x.js → chunk-xhnvpygg.js} +1 -1
- package/dist/chunk-xkz5z0zn.js +1 -0
- package/dist/chunk-zwxjkwqd.js +26 -0
- package/dist/chunk-zz32kgt2.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/nonInteractive.js +3 -3
- package/dist/zen-keyboard.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-06dj0dnz.js +0 -1
- package/dist/chunk-0cbmnyee.js +0 -1
- package/dist/chunk-0cknr23d.js +0 -1
- package/dist/chunk-0jtrg9s1.js +0 -1
- package/dist/chunk-0k9tc7ys.js +0 -1
- package/dist/chunk-0kan91hr.js +0 -1
- package/dist/chunk-0kvk3r1g.js +0 -1
- package/dist/chunk-0teh8cbt.js +0 -2
- package/dist/chunk-0x0r76m6.js +0 -1
- package/dist/chunk-11ctp51v.js +0 -2
- package/dist/chunk-154dd94d.js +0 -2
- package/dist/chunk-17g5e3tb.js +0 -1
- package/dist/chunk-1b02dwxw.js +0 -1
- package/dist/chunk-1ck3yagm.js +0 -1
- package/dist/chunk-1fmdjx58.js +0 -1
- package/dist/chunk-1m8bmdzc.js +0 -1
- package/dist/chunk-1tj3j2rd.js +0 -1
- package/dist/chunk-1xdz3wdt.js +0 -1
- package/dist/chunk-1xjj19pz.js +0 -1
- package/dist/chunk-1z3yy9vz.js +0 -1
- package/dist/chunk-1zbnmy0p.js +0 -1
- package/dist/chunk-21gm4tm7.js +0 -1
- package/dist/chunk-2215g4qb.js +0 -2
- package/dist/chunk-250846sw.js +0 -1
- package/dist/chunk-2a6kan82.js +0 -1
- package/dist/chunk-2cfemb9q.js +0 -1
- package/dist/chunk-2evyqqz7.js +0 -2
- package/dist/chunk-2f9mf6mw.js +0 -2
- package/dist/chunk-2mrbrsta.js +0 -1
- package/dist/chunk-2tg0fzzw.js +0 -2
- package/dist/chunk-2yk5xgha.js +0 -1
- package/dist/chunk-2z60cf4h.js +0 -1
- package/dist/chunk-2zqq58q6.js +0 -2
- package/dist/chunk-3009w43m.js +0 -1
- package/dist/chunk-3acyh64g.js +0 -25
- package/dist/chunk-3b8scss4.js +0 -1
- package/dist/chunk-3d8rzv4d.js +0 -1
- package/dist/chunk-3emyjvqg.js +0 -1
- package/dist/chunk-3fp2k4jh.js +0 -26
- package/dist/chunk-3rew4tyk.js +0 -1
- package/dist/chunk-3s3b7nzy.js +0 -1
- package/dist/chunk-3w98g1h4.js +0 -1
- package/dist/chunk-3x564va6.js +0 -2
- package/dist/chunk-4agrg21g.js +0 -1
- package/dist/chunk-4asb3qnd.js +0 -1
- package/dist/chunk-4k15drqf.js +0 -1
- package/dist/chunk-4vhwsrc0.js +0 -1
- package/dist/chunk-4yddzp8e.js +0 -1
- package/dist/chunk-53agfxhn.js +0 -1
- package/dist/chunk-54kyvbh7.js +0 -1
- package/dist/chunk-56q8b04m.js +0 -1
- package/dist/chunk-59vj8mx3.js +0 -1
- package/dist/chunk-5bvkhjg1.js +0 -1
- package/dist/chunk-5m8gh94n.js +0 -1
- package/dist/chunk-5n57csbz.js +0 -1
- package/dist/chunk-5n6g25gc.js +0 -1
- package/dist/chunk-5rmyjm7a.js +0 -1
- package/dist/chunk-5wkah698.js +0 -1
- package/dist/chunk-6180vb4q.js +0 -2
- package/dist/chunk-63ncy5kr.js +0 -1
- package/dist/chunk-66sfgeag.js +0 -1
- package/dist/chunk-6ag9x0z1.js +0 -1
- package/dist/chunk-6bhkrdb2.js +0 -1
- package/dist/chunk-6cs4tf5a.js +0 -1
- package/dist/chunk-6czm9v10.js +0 -1
- package/dist/chunk-6dm27qn5.js +0 -1
- package/dist/chunk-6eyx9kb0.js +0 -1
- package/dist/chunk-6fsb1bxc.js +0 -1
- package/dist/chunk-6qbdcv3t.js +0 -1
- package/dist/chunk-6qyeer8n.js +0 -1
- package/dist/chunk-6r5npryc.js +0 -1
- package/dist/chunk-6rhb6xym.js +0 -1
- package/dist/chunk-6vhg46d2.js +0 -1
- package/dist/chunk-6yb36qx6.js +0 -1
- package/dist/chunk-72cdrnwv.js +0 -1
- package/dist/chunk-731nq1br.js +0 -1
- package/dist/chunk-748hk53z.js +0 -1
- package/dist/chunk-774cjjgt.js +0 -1
- package/dist/chunk-77chzpqs.js +0 -1
- package/dist/chunk-77qt7n70.js +0 -1
- package/dist/chunk-7cenjy4r.js +0 -2
- package/dist/chunk-7d4h6qkf.js +0 -1
- package/dist/chunk-7k80bxbe.js +0 -1
- package/dist/chunk-7khjf5c1.js +0 -1
- package/dist/chunk-7m0c57rj.js +0 -1
- package/dist/chunk-7n5b43s8.js +0 -1
- package/dist/chunk-7pwrx1pp.js +0 -1
- package/dist/chunk-7v4352jx.js +0 -1
- package/dist/chunk-7w75nxwb.js +0 -1
- package/dist/chunk-7wa89vcy.js +0 -1
- package/dist/chunk-7yf45m28.js +0 -1
- package/dist/chunk-7z7g35xf.js +0 -1
- package/dist/chunk-82xzyhyv.js +0 -1
- package/dist/chunk-87w9rexn.js +0 -1
- package/dist/chunk-8arg48f8.js +0 -1
- package/dist/chunk-8ee7jvcr.js +0 -1
- package/dist/chunk-8gm5e25z.js +0 -1
- package/dist/chunk-8jhmnz2v.js +0 -1
- package/dist/chunk-8qh81vdm.js +0 -1
- package/dist/chunk-8vr1wy0r.js +0 -1
- package/dist/chunk-917pj3vx.js +0 -1
- package/dist/chunk-91gd665t.js +0 -1
- package/dist/chunk-92pjraxh.js +0 -2
- package/dist/chunk-9ft87v6s.js +0 -2
- package/dist/chunk-9h0v5e0k.js +0 -2
- package/dist/chunk-9hnbyswz.js +0 -1
- package/dist/chunk-9hznfyjs.js +0 -1
- package/dist/chunk-9mjq1xxc.js +0 -1
- package/dist/chunk-9nb6v3q0.js +0 -2
- package/dist/chunk-9phx46cq.js +0 -2
- package/dist/chunk-9rmve4r4.js +0 -1
- package/dist/chunk-9xaygaay.js +0 -2
- package/dist/chunk-a4vdvjsr.js +0 -1
- package/dist/chunk-ae57mcvq.js +0 -1
- package/dist/chunk-aeajq5ft.js +0 -1
- package/dist/chunk-aekjcqbv.js +0 -1
- package/dist/chunk-ah557n6f.js +0 -1
- package/dist/chunk-am5r5ynh.js +0 -1
- package/dist/chunk-asdze5kz.js +0 -1
- package/dist/chunk-av215sh3.js +0 -1
- package/dist/chunk-b1czvr4n.js +0 -1
- package/dist/chunk-b3g51e2m.js +0 -1
- package/dist/chunk-b4qvb571.js +0 -1
- package/dist/chunk-bba2g9qj.js +0 -1
- package/dist/chunk-be8bz8xh.js +0 -1
- package/dist/chunk-bh05aqrf.js +0 -2
- package/dist/chunk-bjctrgpr.js +0 -1
- package/dist/chunk-bjqn0pzz.js +0 -1
- package/dist/chunk-bnrv5f66.js +0 -2
- package/dist/chunk-bqzvv2dy.js +0 -1
- package/dist/chunk-bs9fj12n.js +0 -1
- package/dist/chunk-bwcdkk1e.js +0 -2
- package/dist/chunk-bz79zq7h.js +0 -1
- package/dist/chunk-bzanqq7a.js +0 -1
- package/dist/chunk-cayjw3gk.js +0 -1
- package/dist/chunk-ceb97hw6.js +0 -1
- package/dist/chunk-ctet86gc.js +0 -1
- package/dist/chunk-ctp90f8y.js +0 -1
- package/dist/chunk-cv5akzkw.js +0 -1
- package/dist/chunk-d9hpz80s.js +0 -2
- package/dist/chunk-denz6x2z.js +0 -1
- package/dist/chunk-dnpybaez.js +0 -1
- package/dist/chunk-dp2418kp.js +0 -1
- package/dist/chunk-dpa9tgf6.js +0 -2
- package/dist/chunk-dxg8cctv.js +0 -2
- package/dist/chunk-dz0229fs.js +0 -1
- package/dist/chunk-e8pjcdmj.js +0 -1
- package/dist/chunk-edkft0pe.js +0 -1
- package/dist/chunk-ejh8spnd.js +0 -1
- package/dist/chunk-emjqnzzj.js +0 -1
- package/dist/chunk-er06b5kx.js +0 -2
- package/dist/chunk-esskh0ge.js +0 -1
- package/dist/chunk-ewx6fr7a.js +0 -1
- package/dist/chunk-ewxacd5v.js +0 -1
- package/dist/chunk-ez2xn1tq.js +0 -1
- package/dist/chunk-ezh4rq18.js +0 -1
- package/dist/chunk-f1gz54zs.js +0 -1
- package/dist/chunk-f2p8rps5.js +0 -1
- package/dist/chunk-f3mf8qk2.js +0 -1
- package/dist/chunk-f51sey9j.js +0 -1
- package/dist/chunk-f8c6jyrc.js +0 -1
- package/dist/chunk-fb70a9sy.js +0 -1
- package/dist/chunk-fd4dk58v.js +0 -1
- package/dist/chunk-fdhzjb42.js +0 -1
- package/dist/chunk-fftvnc8t.js +0 -1
- package/dist/chunk-ffzytaw1.js +0 -1
- package/dist/chunk-fm3k6prw.js +0 -1
- package/dist/chunk-fs5s90mk.js +0 -1
- package/dist/chunk-fvhtfw18.js +0 -1
- package/dist/chunk-g3p0vcay.js +0 -2
- package/dist/chunk-gaw2bhff.js +0 -1
- package/dist/chunk-gbrg4c7y.js +0 -1
- package/dist/chunk-gkhxerej.js +0 -1
- package/dist/chunk-gps0pyf7.js +0 -1
- package/dist/chunk-gsnrqmzp.js +0 -1
- package/dist/chunk-gvjvbwk6.js +0 -1
- package/dist/chunk-gxc7a8cz.js +0 -1
- package/dist/chunk-h06hyckd.js +0 -1
- package/dist/chunk-h0b5na4r.js +0 -1
- package/dist/chunk-h1bjeyn7.js +0 -1
- package/dist/chunk-h5y1vfrx.js +0 -1
- package/dist/chunk-hgkaxnh7.js +0 -1
- package/dist/chunk-hgs9vzm2.js +0 -1
- package/dist/chunk-hjs9ffqg.js +0 -1
- package/dist/chunk-hmtm22t7.js +0 -1
- package/dist/chunk-hraqhe5e.js +0 -1
- package/dist/chunk-hsq3vxna.js +0 -2
- package/dist/chunk-htns6qnb.js +0 -1
- package/dist/chunk-hv4arqm5.js +0 -1
- package/dist/chunk-hzqb4sy6.js +0 -1
- package/dist/chunk-j0szwqey.js +0 -1
- package/dist/chunk-j6s60n91.js +0 -1
- package/dist/chunk-j9za9ext.js +0 -1
- package/dist/chunk-ja5m6q40.js +0 -1
- package/dist/chunk-jdvv96q7.js +0 -1
- package/dist/chunk-jsqwhbbt.js +0 -1
- package/dist/chunk-jyrs3ysr.js +0 -1
- package/dist/chunk-jz8tmenz.js +0 -1
- package/dist/chunk-k17n7dpm.js +0 -1
- package/dist/chunk-k1yv7tpj.js +0 -1
- package/dist/chunk-k626mmdc.js +0 -1
- package/dist/chunk-ka0pqrag.js +0 -1
- package/dist/chunk-kbgd9vsz.js +0 -1
- package/dist/chunk-kc6rwv2m.js +0 -1
- package/dist/chunk-kc8375a8.js +0 -1
- package/dist/chunk-kgj1ssyj.js +0 -1
- package/dist/chunk-kk4w0prd.js +0 -1
- package/dist/chunk-kkks4cbp.js +0 -1
- package/dist/chunk-kq7y5ybe.js +0 -1
- package/dist/chunk-kqemj8nq.js +0 -1
- package/dist/chunk-kr6cv1mp.js +0 -1
- package/dist/chunk-kvb035wf.js +0 -2
- package/dist/chunk-kx3dsqc5.js +0 -1
- package/dist/chunk-kys8sc0j.js +0 -1
- package/dist/chunk-m0vtra47.js +0 -1
- package/dist/chunk-m9xdbw2j.js +0 -1
- package/dist/chunk-mft6e1b3.js +0 -1
- package/dist/chunk-mfyvxat8.js +0 -1
- package/dist/chunk-mjfe9s8t.js +0 -1
- package/dist/chunk-mns6edxc.js +0 -1
- package/dist/chunk-mp159559.js +0 -2
- package/dist/chunk-mrbn4knm.js +0 -1
- package/dist/chunk-ms3sqsez.js +0 -1
- package/dist/chunk-mtyqtnv0.js +0 -1
- package/dist/chunk-mvb82v3n.js +0 -1
- package/dist/chunk-n08dw2ke.js +0 -1
- package/dist/chunk-n0sxg10w.js +0 -1
- package/dist/chunk-n3xjke41.js +0 -1
- package/dist/chunk-n6v7menj.js +0 -1
- package/dist/chunk-n8apqh5d.js +0 -1
- package/dist/chunk-n8f65qbg.js +0 -1
- package/dist/chunk-n92ey5c2.js +0 -1
- package/dist/chunk-na5z94zg.js +0 -2
- package/dist/chunk-nbkkf36e.js +0 -1
- package/dist/chunk-ndk5mkc1.js +0 -1
- package/dist/chunk-nks89eba.js +0 -1
- package/dist/chunk-nrkhbe10.js +0 -1
- package/dist/chunk-nvnw7mcb.js +0 -1
- package/dist/chunk-nwx5cbjc.js +0 -1
- package/dist/chunk-ny61b4ve.js +0 -1
- package/dist/chunk-p7ha3t1f.js +0 -1
- package/dist/chunk-pc3w4gkp.js +0 -1
- package/dist/chunk-pcwsyc9b.js +0 -1
- package/dist/chunk-pj843s6s.js +0 -1
- package/dist/chunk-pm5gceg0.js +0 -1
- package/dist/chunk-pqq81gzv.js +0 -1
- package/dist/chunk-pt1m6xh9.js +0 -1
- package/dist/chunk-pvzfgkkq.js +0 -1
- package/dist/chunk-pz4hhw24.js +0 -1
- package/dist/chunk-pz5xskrk.js +0 -1
- package/dist/chunk-q0z3nkep.js +0 -1
- package/dist/chunk-q6m1k4fq.js +0 -1
- package/dist/chunk-q9w8vj93.js +0 -2
- package/dist/chunk-qd2hkayk.js +0 -1
- package/dist/chunk-qf60gd6x.js +0 -1
- package/dist/chunk-qpwtcr53.js +0 -1
- package/dist/chunk-qrr2ytkg.js +0 -2
- package/dist/chunk-qzy0w65x.js +0 -1
- package/dist/chunk-r5crgj5q.js +0 -1
- package/dist/chunk-r5psjv6v.js +0 -1
- package/dist/chunk-r9dm0gyn.js +0 -1
- package/dist/chunk-r9qyzgns.js +0 -1
- package/dist/chunk-raq8eqd9.js +0 -1
- package/dist/chunk-rbebjqfq.js +0 -1
- package/dist/chunk-rc81vkve.js +0 -1
- package/dist/chunk-rg8hdkt2.js +0 -1
- package/dist/chunk-rgc9k4rf.js +0 -2
- package/dist/chunk-rqvxk3e5.js +0 -2
- package/dist/chunk-rsb82wcd.js +0 -1
- package/dist/chunk-rt7af3wp.js +0 -1
- package/dist/chunk-rx707y69.js +0 -1
- package/dist/chunk-s22hm2jp.js +0 -1
- package/dist/chunk-s2wchktz.js +0 -1
- package/dist/chunk-s5yace4y.js +0 -1
- package/dist/chunk-sd65hz9x.js +0 -1
- package/dist/chunk-sdhd2kpk.js +0 -1
- package/dist/chunk-sepabvgd.js +0 -1
- package/dist/chunk-sk4n2anv.js +0 -1
- package/dist/chunk-sq9spyfd.js +0 -1
- package/dist/chunk-sv97fsr8.js +0 -1
- package/dist/chunk-sw6b067z.js +0 -1
- package/dist/chunk-sz3tq28n.js +0 -2
- package/dist/chunk-t07nqvz2.js +0 -1
- package/dist/chunk-t4vfr2g0.js +0 -1
- package/dist/chunk-t6x8a62a.js +0 -1
- package/dist/chunk-t8djp78p.js +0 -1
- package/dist/chunk-tj729ry3.js +0 -1
- package/dist/chunk-tjj6zd94.js +0 -2
- package/dist/chunk-tkp1zzgb.js +0 -1
- package/dist/chunk-tq142qfa.js +0 -1
- package/dist/chunk-tq7jpqr7.js +0 -1
- package/dist/chunk-tqh0rjpp.js +0 -1
- package/dist/chunk-tx117rah.js +0 -1
- package/dist/chunk-v3t7hcht.js +0 -1
- package/dist/chunk-v9qb0fer.js +0 -1
- package/dist/chunk-vcsqkf9c.js +0 -1
- package/dist/chunk-vd8byz1r.js +0 -2
- package/dist/chunk-vg853h8j.js +0 -1
- package/dist/chunk-vgeyt962.js +0 -1
- package/dist/chunk-vkfgx6sa.js +0 -2
- package/dist/chunk-vqpam6p8.js +0 -1
- package/dist/chunk-vrv07424.js +0 -1
- package/dist/chunk-vsydmxfh.js +0 -1
- package/dist/chunk-vtxyeepe.js +0 -2
- package/dist/chunk-vwhxfs9r.js +0 -1
- package/dist/chunk-vy4ecvry.js +0 -1
- package/dist/chunk-w46ermgd.js +0 -1
- package/dist/chunk-w5qvj179.js +0 -1
- package/dist/chunk-w93s735t.js +0 -1
- package/dist/chunk-wb08g5z8.js +0 -1
- package/dist/chunk-wb43p5km.js +0 -1
- package/dist/chunk-wb6xn1kx.js +0 -1
- package/dist/chunk-wbg38h5j.js +0 -1
- package/dist/chunk-wcyrmfpn.js +0 -1
- package/dist/chunk-wd17hcv5.js +0 -1
- package/dist/chunk-wdm62dbr.js +0 -1
- package/dist/chunk-we3jwpsb.js +0 -2
- package/dist/chunk-wgamcpyt.js +0 -1
- package/dist/chunk-whdmep96.js +0 -1
- package/dist/chunk-wkc7w10f.js +0 -1
- package/dist/chunk-wkf1j21b.js +0 -1
- package/dist/chunk-wm3z6khn.js +0 -1
- package/dist/chunk-wqvqvv9e.js +0 -1
- package/dist/chunk-wvmnb75v.js +0 -1
- package/dist/chunk-wy3eznsy.js +0 -2
- package/dist/chunk-wznpd7sd.js +0 -1
- package/dist/chunk-x01t9e3q.js +0 -1
- package/dist/chunk-x8z2fzz8.js +0 -1
- package/dist/chunk-xa4apmpd.js +0 -1
- package/dist/chunk-xcea0hn5.js +0 -2
- package/dist/chunk-xf7ypd1b.js +0 -1
- package/dist/chunk-xhjrdhgk.js +0 -1
- package/dist/chunk-xjgnj3p0.js +0 -1
- package/dist/chunk-xjwkmvfz.js +0 -1
- package/dist/chunk-xkc2ktrh.js +0 -1
- package/dist/chunk-xm9015v4.js +0 -1
- package/dist/chunk-xnx0j1hw.js +0 -1
- package/dist/chunk-y0e2ymas.js +0 -1
- package/dist/chunk-y3c3xgca.js +0 -1
- package/dist/chunk-y6mvs6yw.js +0 -1
- package/dist/chunk-y6z502pz.js +0 -1
- package/dist/chunk-ycthcn27.js +0 -1
- package/dist/chunk-ydc7pd3b.js +0 -1
- package/dist/chunk-yhxvqyz4.js +0 -1
- package/dist/chunk-ymmavdfp.js +0 -2
- package/dist/chunk-ynnaxz2z.js +0 -1
- package/dist/chunk-ywa5z7d9.js +0 -1
- package/dist/chunk-ywbbf9eh.js +0 -1
- package/dist/chunk-yzk3bfzn.js +0 -1
- package/dist/chunk-z0wdan61.js +0 -1
- package/dist/chunk-z5z774pp.js +0 -1
- package/dist/chunk-z88rcc8t.js +0 -1
- package/dist/chunk-zag96nyc.js +0 -2
- package/dist/chunk-zh77yp9z.js +0 -1
- package/dist/chunk-zjemnf8v.js +0 -1
- package/dist/chunk-zmsq5xc7.js +0 -1
- package/dist/chunk-zqxrtejz.js +0 -1
- package/dist/chunk-zt78xjtr.js +0 -2
- package/dist/chunk-zv9ac3c0.js +0 -2
- package/dist/chunk-zx19re81.js +0 -2
- package/dist/chunk-zytr7a4n.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import q from"node:path";import H from"node:os";import c from"node:fs";function J(r){let w=r.replace(/^~/,H.homedir()),O=q.resolve(w),C=q.dirname(O);if(!c.existsSync(C))c.mkdirSync(C,{recursive:!0});return O}function K(r,w){if(!c.existsSync(r)){process.env.DATABASE_INIT="true";return}let O=process.env.SQLITE_MAX_SIZE_MB?parseInt(process.env.SQLITE_MAX_SIZE_MB,10)*1024*1024:void 0,C=w??O??104857600,j=c.statSync(r).size,A=j/1048576;if(j>C){let G=C/1048576;console.warn(`⚠️ Database file is large: ${A.toFixed(2)}MB (limit: ${G.toFixed(2)}MB)`),console.warn(` Path: ${r}`),console.warn(" Set SQLITE_MAX_SIZE_MB to adjust limit")}}function T(r){let w=J(r);return process.env.SQLITE_DATABASE_URI=w,K(w),w}import x from"node-notifier";function W(r){if(typeof r==="string")x.notify({title:"Notification",message:r});else x.notify({title:r.title||"Notification",message:r.message,icon:r.icon,sound:r.sound??!0})}var Y={path:process.cwd()};export{T as
|
|
1
|
+
import q from"node:path";import H from"node:os";import c from"node:fs";function J(r){let w=r.replace(/^~/,H.homedir()),O=q.resolve(w),C=q.dirname(O);if(!c.existsSync(C))c.mkdirSync(C,{recursive:!0});return O}function K(r,w){if(!c.existsSync(r)){process.env.DATABASE_INIT="true";return}let O=process.env.SQLITE_MAX_SIZE_MB?parseInt(process.env.SQLITE_MAX_SIZE_MB,10)*1024*1024:void 0,C=w??O??104857600,j=c.statSync(r).size,A=j/1048576;if(j>C){let G=C/1048576;console.warn(`⚠️ Database file is large: ${A.toFixed(2)}MB (limit: ${G.toFixed(2)}MB)`),console.warn(` Path: ${r}`),console.warn(" Set SQLITE_MAX_SIZE_MB to adjust limit")}}function T(r){let w=J(r);return process.env.SQLITE_DATABASE_URI=w,K(w),w}import x from"node-notifier";function W(r){if(typeof r==="string")x.notify({title:"Notification",message:r});else x.notify({title:r.title||"Notification",message:r.message,icon:r.icon,sound:r.sound??!0})}var Y={path:process.cwd()};export{T as ba,W as ca,Y as da};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{sb as a}from"./chunk-r2h3x9zv.js";import"./chunk-kba8akjs.js";export{a as FileSystemConfigStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{xa as a,ya as b,za as c}from"./chunk-76h8pe7x.js";import"./chunk-zwxjkwqd.js";import"./chunk-13nyfrmm.js";import"./chunk-5rr85f28.js";import"./chunk-cggjws6a.js";import"./chunk-cyexd09c.js";import"./chunk-r2h3x9zv.js";import"./chunk-1ttywx0y.js";import"./chunk-kba8akjs.js";export{c as getAgentListFromPackage,a as createSubAgentsMiddleware,b as SubAgentsMiddleware};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ja as f,La as g}from"./chunk-5x8nxw0t.js";import{Sa as b}from"./chunk-13nyfrmm.js";import{yb as i}from"./chunk-kba8akjs.js";import{AgentPackage as E,MemoryStorage as L}from"@langgraph-js/standard-agent";import{tool as U}from"@langchain/core/tools";import{z as o}from"zod";var I=o.object({content:o.string().min(1),status:o.enum(["pending","in_progress","completed"]),id:o.string()}),A=o.object({todos:o.array(I).describe("The updated todo list")}),u=U(async()=>{return"todo saved successfully"},{name:"todo_write",description:`Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
2
2
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
3
3
|
## When to Use This Tool
|
|
4
4
|
Use this tool proactively in these scenarios:
|
|
@@ -172,7 +172,7 @@ The assistant did not use the todo list because this is a single command executi
|
|
|
172
172
|
- Use clear, descriptive task names
|
|
173
173
|
|
|
174
174
|
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
|
|
175
|
-
`,schema:
|
|
175
|
+
`,schema:A});import{z as n}from"zod";import{tool as z}from"langchain";var C=n.object({label:n.string().min(1).max(50).describe("选项显示文本,简洁明了(1-50 字符)")}),W=n.object({description:n.string().min(1).describe("向用户提出的问题,清晰具体,包含必要的上下文"),type:n.enum(["single_select","multi_select"]).describe("选择类型:single_select(单选)或 multi_select(多选)"),options:n.array(C).min(2).max(6).describe("选项列表,至少 2 个,最多 6 个"),allow_custom_input:n.boolean().default(!0).describe("是否允许用户输入自定义文本,默认 true"),placeholder:n.string().optional().describe("自定义输入框的占位符文本")}),h=z(()=>{},{name:"ask_user_questions",description:"Ask the user a question with selectable options",schema:W});var q=[h,u];async function _(e,t){await e.addTool({id:t.name,name:t.name,description:t.description});let l={id:t.name,name:t.name,description:t.description,paramsSchema:t.schema,execute:async(d)=>{let a=await t.invoke(d);if(a&&typeof a==="object"&&"content"in a)return a.content;return a}};e.tools.registerImplementation(l)}async function p(e){return await Promise.all(q.map((t)=>_(e,t)))}async function y(e){let t={id:"filesystem",name:"filesystem",description:"File and directory operations (read, write, search, glob)",execute:async()=>{return new f}};await e.addMiddleware(t),e.middlewares.registerImplementation(t);let l={id:"terminal",name:"terminal",description:"Terminal command execution (Bash/CMD, background processes)",execute:async()=>{return new g}};await e.addMiddleware(l),e.middlewares.registerImplementation(l);let d={id:"subagents",name:"subagents",description:"Task delegation to specialized agents",execute:async()=>{let{createSubAgentsMiddleware:s}=await import("./chunk-1rmnbdef.js");return await s(e)}};await e.addMiddleware(d),e.middlewares.registerImplementation(d);let a={id:"memories",name:"memories",description:"Knowledge persistence",execute:async(s)=>{s.projectMemoriesDir=s.projectMemoriesDir||"./.claude/memories";let{MemoriesMiddleware:r}=await import("./chunk-rz3b356n.js");return new r(s)}};await e.addMiddleware(a),e.middlewares.registerImplementation(a);let c={id:"skills",name:"skills",description:"Progressive skills disclosure",execute:async(s)=>{if(s.projectSkillsDir=s.projectSkillsDir||"./.claude/skills",!s.skillsDir){let v=await import("os"),x=await import("path");s.skillsDir=x.join(v.homedir(),".claude","skills")}let{SkillsMiddleware:r}=await import("@langgraph-js/standard-agent");return new r(s)}};await e.addMiddleware(c),e.middlewares.registerImplementation(c);let m={id:"agents_md",name:"agents_md",description:"Inject agent documentation",execute:async(s)=>{let{AgentsMdMiddleware:r}=await import("@langgraph-js/standard-agent");return new r({projectRoot:s?.projectRoot})}};await e.addMiddleware(m),e.middlewares.registerImplementation(m)}var k=`# 架构师 - 任务派发协调者
|
|
176
176
|
|
|
177
177
|
你是一位**任务派发架构师**,核心职责是将用户需求分析并拆解为子任务,然后委派给合适的子 agent 执行。
|
|
178
178
|
|
|
@@ -294,5 +294,5 @@ When in doubt, use this tool. Being proactive with task management demonstrates
|
|
|
294
294
|
|
|
295
295
|
---
|
|
296
296
|
|
|
297
|
-
**记住**:你是协调者,不是执行者。快速分析需求,立即委派任务,高效汇总结果。`;async function w(){let
|
|
298
|
-
export{
|
|
297
|
+
**记住**:你是协调者,不是执行者。快速分析需求,立即委派任务,高效汇总结果。`;async function w(){let e=new L,t=new E(e);return await t.addModel({id:"glm-4.7",model_name:"glm-4.7",model_provider:process.env.MODEL_PROVIDER||"openai",stream_usage:!0,enable_thinking:!0,temperature:0.7,max_tokens:4096,top_p:1,frequency_penalty:0,presence_penalty:0}),await t.addPrompt({id:"prompts/default",name:"default",content:b}),await t.addPrompt({id:"prompts/manager",name:"manager",content:k}),await p(t),await y(t),await t.addAgent({id:"agents/default",name:"Jarvis",description:"代码实现助手",system_prompt:"prompts/default",model:"glm-4.7",tools:{ask_user_questions:!0,todo_write:!0},middleware:{filesystem:!0,terminal:!0,agents_md:!0,skills:!0,memories:!0,subagents:!0}}),await t.addAgent({id:"agents/manager",name:"Manager",description:"任务管理员",system_prompt:"prompts/manager",model:"glm-4.7",tools:{ask_user_questions:!0,todo_write:!0},middleware:{filesystem:!0,terminal:!0,agents_md:!0,skills:!0,memories:!0,subagents:!0}}),t}var T;try{T=await w()}catch(e){throw console.error("Failed to load agent package:",e),Error(`Failed to initialize agent package: ${e instanceof Error?e.message:String(e)}`)}var ae=T;
|
|
298
|
+
export{A as Da,ae as Ea};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{$a as j,_a as c0,ab as O,hb as t}from"./chunk-zssv316b.js";import{Cb as g}from"./chunk-xf4jswm4.js";import{lc as h,mc as P,pc as M}from"./chunk-nr26055z.js";var b=P((IA,X0)=>{var n0=M("child_process").spawn;function p0(A,G,X,L){if(typeof X==="function")L=X,X=void 0;let J=!1,H=n0(A,G,X),K="",Y="";H.stdout.on("data",function($){K+=$.toString()}),H.stderr.on("data",function($){Y+=$.toString()}),H.on("error",function($){if(J)return;J=!0,L(Error($))}),H.on("close",function($,Q){if(J)return;if(J=!0,Y)return L(Error(Y));L(null,K,$)})}X0.exports=p0});var y=P((VA,L0)=>{var B={},w={},x={},n=0,E=null;function a0(A,G){if(G<=0)return;if(w[A]!==void 0)B[A]=Date.now()+(G||60000);return w[A]}function i0(A,G,X,L){if(G===void 0||X<=0)return;if(B[A]=Date.now()+(X||60000),w[A]===void 0)n++,G0(X);if(w[A]=G,L)x[A]=L}function G0(A){if(n>0){if(E===null){if(E=setInterval(d0,(A||60000)/2),typeof E.unref==="function")E.unref()}return}if(E!==null)clearInterval(E),E=null}function d0(){let A=Date.now(),G=Object.keys(B);for(let X=0;X<G.length;X++){let L=G[X];if(B[L]<A){if(n--,x[L])x[L](w[L]);delete w[L],delete B[L],delete x[L]}}G0()}function c(A){for(let G in A)delete A[G]}function o0(){if(E!==null)clearInterval(E),E=null;c(w),c(B),c(x)}L0.exports={get:a0,set:i0,clear:o0}});var W0=P((OA,Q0)=>{var K0=M("os"),r0=b(),H0=y(),f=K0.platform();function J0(A,G){let X=0,L=A.split(/-|:|\./),J=L.length-1;if(J>=0&&G&&f==="darwin")X+=parseInt(L[J--],10)*10;if(J>=0)X+=parseInt(L[J--],10)*1000;if(J>=0)X+=parseInt(L[J--],10)*60000;if(J>=0)X+=parseInt(L[J--],10)*3600000;if(J>=0)X+=parseInt(L[J--],10)*86400000;return X}function s0(A,G,X){let L=A.join(","),J=["-o","etime,pid,ppid,pcpu,rss,time","-p",L];if(f==="aix"||f==="os400")J=["-o","etime,pid,ppid,pcpu,rssize,time","-p",L];r0("ps",J,function(H,K,Y){if(H){if(f==="os390"&&/no matching processes found/.test(H))H=Error("No matching pid found"),H.code="ENOENT";return X(H)}if(Y===1){let N=Error("No matching pid found");return N.code="ENOENT",X(N)}if(Y!==0)return X(Error("pidusage ps command exited with code "+Y));let $=Date.now();K=K.split(K0.EOL);let Q={};for(let N=1;N<K.length;N++){let U=K[N].trim().split(/\s+/);if(!U||U.length!==6)continue;let W=parseInt(U[1],10),q=H0.get(W,G.maxage);if(q===void 0)q={};let Z=parseInt(U[2],10),v=parseInt(U[4],10)*1024,F=J0(U[0]),C=J0(U[5],!0),T=C-(q.ctime||0),I=Math.abs(q.elapsed!==void 0?F-q.elapsed:F),D=I>0?T/I*100:0;Q[W]={cpu:D,memory:v,ppid:Z,pid:W,ctime:C,elapsed:F,timestamp:$},H0.set(W,Q[W],G.maxage)}X(null,Q)})}Q0.exports=s0});var p=P((SA,Y0)=>{function t0(A,G,X){if(typeof G==="function")X=G,G={};let L;if(!Array.isArray(A))L=Object.keys(A);let J=L?L.length:A.length,H=J,K=L?{}:[];function Y($,Q,N){if(K[$]=N,--H===0||Q&&!G.graceful){if(G.graceful&&Q&&J>1)Q=null;X&&X(Q,K),X=null}}if(L)L.forEach(function($){A[$](function(Q,N){Y($,Q,N)})});else A.forEach(function($,Q){$(function(N,U){Y(Q,N,U)})})}Y0.exports=t0});var Z0=P((jA,q0)=>{var e0=M("os"),AA=M("fs"),XA=M("child_process").exec,U0=p();function GA(A,G){if(A!==null){$0(function(X,L){if(X)return G(X);A.uptime=L,G(null,A)});return}U0([LA,$0],function(X,L){if(X)return G(X);A={clockTick:L[0].clockTick,pageSize:L[0].pageSize,uptime:L[1]},G(null,A)})}q0.exports=GA;function $0(A){AA.readFile("/proc/uptime","utf8",function(G,X){if(G||X===void 0){if(!process.env.PIDUSAGE_SILENT)console.warn("[pidusage] We couldn't find uptime from /proc/uptime, using os.uptime() value");return A(null,e0.uptime()||new Date/1000)}return A(null,parseFloat(X.split(" ")[0]))})}function LA(A){U0([function(X){N0("CLK_TCK",{default:100},X)},function(X){N0("PAGESIZE",{default:4096},X)}],function(G,X){if(G)return A(G);A(null,{clockTick:X[0],pageSize:X[1]})})}function N0(A,G,X){if(typeof G==="function")X=G,G={default:""};XA("getconf "+A,function(L,J,H){if(L!==null){if(!process.env.PIDUSAGE_SILENT)console.error('Error while calling "getconf '+A+'"',L);return X(null,G.default)}if(J=parseInt(J),!isNaN(J))return X(null,J);return X(null,G.default)})}});var F0=P((a,v0)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var l=M("buffer"),R=l.Buffer;function _0(A,G){for(var X in A)G[X]=A[X]}if(R.from&&R.alloc&&R.allocUnsafe&&R.allocUnsafeSlow)v0.exports=l;else _0(l,a),a.Buffer=z;function z(A,G,X){return R(A,G,X)}z.prototype=Object.create(R.prototype);_0(R,z);z.from=function(A,G,X){if(typeof A==="number")throw TypeError("Argument must not be a number");return R(A,G,X)};z.alloc=function(A,G,X){if(typeof A!=="number")throw TypeError("Argument must be a number");var L=R(A);if(G!==void 0)if(typeof X==="string")L.fill(G,X);else L.fill(G);else L.fill(0);return L};z.allocUnsafe=function(A){if(typeof A!=="number")throw TypeError("Argument must be a number");return R(A)};z.allocUnsafeSlow=function(A){if(typeof A!=="number")throw TypeError("Argument must be a number");return l.SlowBuffer(A)}});var E0=P((wA,P0)=>{var d=M("fs"),HA=M("path"),JA=Z0(),KA=p(),M0=y(),V=null,C0=F0().Buffer,i=1024;function QA(){}function WA(A,G,X){if(G.fd)return X(null,G.fd);d.open(A,"r",X)}function YA(A){if(A.fd)d.close(A.fd,QA)}function T0(A,G,X){let L=!1;if(typeof G==="function")X=G,G=C0.alloc(i),L=!0;d.read(A,G,0,i,0,function(J,H,K){if(J){X(J);return}let Y=C0.concat([G,K],L?H:G.length+H);if(H===i){T0(A,Y,X);return}X(null,G)})}function D0(A,G,X){let L=M0.get(A,G.maxage),J=!1;if(L===void 0)J=!0,L={};WA(HA.join("/proc",""+A,"stat"),L,function(H,K){if(H){if(H.code==="ENOENT")H.message="No matching pid found";return X(H,null)}if(H)return X(H);T0(K,function(Y,$){if(Y)return X(Y);let Q=$.toString("utf8"),N=Date.now(),U=Q.lastIndexOf(")");Q=Q.substr(U+2).split(" ");let W={ppid:parseInt(Q[1]),utime:parseFloat(Q[11])*1000/V.clockTick,stime:parseFloat(Q[12])*1000/V.clockTick,cutime:parseFloat(Q[13])*1000/V.clockTick,cstime:parseFloat(Q[14])*1000/V.clockTick,start:parseFloat(Q[19])*1000/V.clockTick,rss:parseFloat(Q[21]),uptime:V.uptime*1000,fd:K},q=W.rss*V.pageSize,Z=G.childrens?W.cutime+W.cstime:0,v=W.stime-(L.stime||0)+W.utime-(L.utime||0)+Z,F=Math.abs(L.uptime!==void 0?W.uptime-L.uptime:W.start-W.uptime),C=F>0?v/F*100:0;if(M0.set(A,W,G.maxage,YA),J)return D0(A,G,X);return X(null,{cpu:C,memory:q,ctime:W.utime+W.stime,elapsed:W.uptime-W.start,timestamp:N,pid:A,ppid:W.ppid})})})}function $A(A,G,X){JA(V,function(L,J){if(L)return X(L);V=J;let H={};A.forEach(function(K,Y){H[K]=function($){D0(K,G,$)}}),KA(H,{graceful:!0},X)})}P0.exports=$A});var S0=P((zA,O0)=>{var R0=M("os"),NA=b(),I0=y();function UA(A){let G=A.substring(0,4),X=A.substring(4,6),L=A.substring(6,8),J=A.substring(8,10),H=A.substring(10,12),K=A.substring(12,14),Y=A.substring(15,21),$=A.substring(21,22),Q=parseInt(A.substring(22,25),10),N=Math.floor(Q/60),U=Q%60;return new Date(G+"-"+X+"-"+L+"T"+J+":"+H+":"+K+"."+Y+$+(N>9?N:"0"+N)+(U>9?U:"0"+U))}function V0(A,G,X){let L="ProcessId="+A[0];for(let H=1;H<A.length;H++)L+=" or ProcessId="+A[H];let J=["PROCESS","where",'"'+L+'"',"get","CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize"];NA("wmic",J,{windowsHide:!0,windowsVerbatimArguments:!0},function(H,K,Y){if(H){if(H.message.indexOf("No Instance(s) Available.")!==-1){let W=Error("No matching pid found");return W.code="ENOENT",X(W)}return X(H)}if(Y!==0)return X(Error("pidusage wmic command exited with code "+Y));let $=Date.now(),Q=Math.floor(R0.uptime()||$/1000);K=K.split(R0.EOL);let N=!1,U={};for(let W=1;W<K.length;W++){let q=K[W].trim().split(/\s+/);if(!q||q.length!==6)continue;let Z=UA(q[0]),v=parseInt(q[2],10),F=parseInt(q[3],10),C=Math.round(parseInt(q[1],10)/1e4),T=Math.round(parseInt(q[4],10)/1e4),I=parseInt(q[5],10),D=I0.get(F,G.maxage);if(D===void 0)N=!0,D={ctime:C+T,uptime:Q};let u=(C+T-D.ctime)/1000,S=Q-D.uptime,m=S>0?u/S*100:0;I0.set(F,{ctime:T+C,uptime:Q},G.maxage),U[F]={cpu:m,memory:I,ppid:v,pid:F,ctime:T+C,elapsed:$-Z.getTime(),timestamp:$}}if(N)return V0(A,G,function(W,q){if(W)return X(W);X(null,Object.assign(U,q))});X(null,U)})}O0.exports=V0});var y0=P((BA,B0)=>{var j0=M("os"),qA=b(),w0=y();function ZA(A){let G=A.substring(0,4),X=A.substring(4,6),L=A.substring(6,8),J=A.substring(8,10),H=A.substring(10,12),K=A.substring(12,14),Y=A.substring(15,21),$=A.substring(21,22),Q=parseInt(A.substring(22,25),10),N=Math.floor(Q/60),U=Q%60;return new Date(G+"-"+X+"-"+L+"T"+J+":"+H+":"+K+"."+Y+$+(N>9?N:"0"+N)+(U>9?U:"0"+U))}function z0(A,G,X){let L="ProcessId="+A[0];for(let K=1;K<A.length;K++)L+=" or ProcessId="+A[K];let J="CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize",H=["win32_process","-Filter","'"+L+"'","| select "+J,"| format-table"];qA("gwmi",H,{windowsHide:!0,windowsVerbatimArguments:!0,shell:"powershell.exe"},function(K,Y,$){if(K){if(K.message.indexOf("No Instance(s) Available.")!==-1){let Z=Error("No matching pid found");return Z.code="ENOENT",X(Z)}return X(K)}if($!==0)return X(Error("pidusage gwmi command exited with code "+$));let Q=Date.now(),N=Math.floor(j0.uptime()||Q/1000);Y=Y.split(j0.EOL).slice(1);let U=Y.findIndex((Z)=>!!Z);if(Y=Y.slice(U+2),!Y.length){let Z=Error("No matching pid found");return Z.code="ENOENT",X(Z)}let W=!1,q={};for(let Z=0;Z<Y.length;Z++){let v=Y[Z].trim().split(/\s+/);if(!v||v.length===1)continue;let F=ZA(v[0]),C=parseInt(v[2],10),T=parseInt(v[3],10),I=Math.round(parseInt(v[1],10)/1e4),D=Math.round(parseInt(v[4],10)/1e4),u=parseInt(v[5],10),S=w0.get(T,G.maxage);if(S===void 0)W=!0,S={ctime:I+D,uptime:N};let m=(I+D-S.ctime)/1000,s=N-S.uptime,m0=s>0?m/s*100:0;w0.set(T,{ctime:D+I,uptime:N},G.maxage),q[T]={cpu:m0,memory:u,ppid:C,pid:T,ctime:D+I,elapsed:Q-F.getTime(),timestamp:Q}}if(W)return z0(A,G,function(Z,v){if(Z)return X(Z);X(null,Object.assign(q,v))});X(null,q)})}B0.exports=z0});var h0=P((yA,g0)=>{var _A=M("fs"),k0=M("os"),vA=M("child_process").spawn,o={ps:()=>W0(),procfile:()=>E0(),wmic:()=>S0(),gwmi:()=>y0()},FA={aix:"ps",os400:"ps",android:"procfile",alpine:"procfile",darwin:"ps",freebsd:"ps",os390:"ps",linux:"procfile",netbsd:"procfile",openbsd:"ps",sunos:"ps",win:"wmic"},k=k0.platform();if(_A.existsSync("/etc/alpine-release"))k="alpine";if(k.match(/^win/))k="win";var x0;try{x0=o[FA[k]]()}catch(A){}function MA(A,G,X){let L=x0;if(k!=="win"&&G.usePs===!0)L=o.ps();if(k==="win"){let H;try{H=vA("wmic",function(K){if(K)throw Error(K)})}catch(K){L=o.gwmi()}finally{if(H)H.kill()}}if(L===void 0)return X(Error(k0.platform()+" is not supported yet, please open an issue (https://github.com/soyuka/pidusage)"));let J=!1;if(!Array.isArray(A))J=!0,A=[A];if(A.length===0)return X(TypeError("You must provide at least one pid"));for(let H=0;H<A.length;H++)if(A[H]=parseInt(A[H],10),isNaN(A[H])||A[H]<0)return X(TypeError("One of the pids provided is invalid"));L(A,G,function(H,K){if(H)return X(H);if(J)X(null,K[A[0]]);else X(null,K)})}g0.exports=MA});var f0=P((kA,r)=>{var b0=h0();function CA(A,G,X){if(typeof G==="function")X=G,G={};if(G===void 0)G={};if(G=Object.assign({usePs:/^true$/i.test(process.env.PIDUSAGE_USE_PS),maxage:process.env.PIDUSAGE_MAXAGE},G),typeof X==="function"){b0(A,G,X);return}return new Promise(function(L,J){b0(A,G,function(H,K){if(H)return J(H);L(K)})})}r.exports=CA;r.exports.clear=y().clear});var e=h(c0(),1);var _=h(t(),1);class A0 extends e.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(A){return{hasError:!0,error:A}}componentDidCatch(A,G){let{name:X="ErrorBoundary"}=this.props;console.error(`
|
|
1
|
+
import{ea as c0,fa as j,ga as E,pa as t}from"./chunk-nwy6n6b6.js";import{Ka as g}from"./chunk-5x8nxw0t.js";import{ub as h,vb as P,yb as M}from"./chunk-kba8akjs.js";var b=P((IA,X0)=>{var n0=M("child_process").spawn;function p0(A,G,X,L){if(typeof X==="function")L=X,X=void 0;let J=!1,H=n0(A,G,X),K="",Y="";H.stdout.on("data",function($){K+=$.toString()}),H.stderr.on("data",function($){Y+=$.toString()}),H.on("error",function($){if(J)return;J=!0,L(Error($))}),H.on("close",function($,Q){if(J)return;if(J=!0,Y)return L(Error(Y));L(null,K,$)})}X0.exports=p0});var y=P((OA,L0)=>{var B={},w={},x={},n=0,R=null;function a0(A,G){if(G<=0)return;if(w[A]!==void 0)B[A]=Date.now()+(G||60000);return w[A]}function i0(A,G,X,L){if(G===void 0||X<=0)return;if(B[A]=Date.now()+(X||60000),w[A]===void 0)n++,G0(X);if(w[A]=G,L)x[A]=L}function G0(A){if(n>0){if(R===null){if(R=setInterval(d0,(A||60000)/2),typeof R.unref==="function")R.unref()}return}if(R!==null)clearInterval(R),R=null}function d0(){let A=Date.now(),G=Object.keys(B);for(let X=0;X<G.length;X++){let L=G[X];if(B[L]<A){if(n--,x[L])x[L](w[L]);delete w[L],delete B[L],delete x[L]}}G0()}function c(A){for(let G in A)delete A[G]}function o0(){if(R!==null)clearInterval(R),R=null;c(w),c(B),c(x)}L0.exports={get:a0,set:i0,clear:o0}});var W0=P((EA,Q0)=>{var K0=M("os"),r0=b(),H0=y(),f=K0.platform();function J0(A,G){let X=0,L=A.split(/-|:|\./),J=L.length-1;if(J>=0&&G&&f==="darwin")X+=parseInt(L[J--],10)*10;if(J>=0)X+=parseInt(L[J--],10)*1000;if(J>=0)X+=parseInt(L[J--],10)*60000;if(J>=0)X+=parseInt(L[J--],10)*3600000;if(J>=0)X+=parseInt(L[J--],10)*86400000;return X}function s0(A,G,X){let L=A.join(","),J=["-o","etime,pid,ppid,pcpu,rss,time","-p",L];if(f==="aix"||f==="os400")J=["-o","etime,pid,ppid,pcpu,rssize,time","-p",L];r0("ps",J,function(H,K,Y){if(H){if(f==="os390"&&/no matching processes found/.test(H))H=Error("No matching pid found"),H.code="ENOENT";return X(H)}if(Y===1){let N=Error("No matching pid found");return N.code="ENOENT",X(N)}if(Y!==0)return X(Error("pidusage ps command exited with code "+Y));let $=Date.now();K=K.split(K0.EOL);let Q={};for(let N=1;N<K.length;N++){let U=K[N].trim().split(/\s+/);if(!U||U.length!==6)continue;let W=parseInt(U[1],10),q=H0.get(W,G.maxage);if(q===void 0)q={};let Z=parseInt(U[2],10),F=parseInt(U[4],10)*1024,v=J0(U[0]),C=J0(U[5],!0),T=C-(q.ctime||0),I=Math.abs(q.elapsed!==void 0?v-q.elapsed:v),D=I>0?T/I*100:0;Q[W]={cpu:D,memory:F,ppid:Z,pid:W,ctime:C,elapsed:v,timestamp:$},H0.set(W,Q[W],G.maxage)}X(null,Q)})}Q0.exports=s0});var p=P((SA,Y0)=>{function t0(A,G,X){if(typeof G==="function")X=G,G={};let L;if(!Array.isArray(A))L=Object.keys(A);let J=L?L.length:A.length,H=J,K=L?{}:[];function Y($,Q,N){if(K[$]=N,--H===0||Q&&!G.graceful){if(G.graceful&&Q&&J>1)Q=null;X&&X(Q,K),X=null}}if(L)L.forEach(function($){A[$](function(Q,N){Y($,Q,N)})});else A.forEach(function($,Q){$(function(N,U){Y(Q,N,U)})})}Y0.exports=t0});var Z0=P((jA,q0)=>{var e0=M("os"),AA=M("fs"),XA=M("child_process").exec,U0=p();function GA(A,G){if(A!==null){$0(function(X,L){if(X)return G(X);A.uptime=L,G(null,A)});return}U0([LA,$0],function(X,L){if(X)return G(X);A={clockTick:L[0].clockTick,pageSize:L[0].pageSize,uptime:L[1]},G(null,A)})}q0.exports=GA;function $0(A){AA.readFile("/proc/uptime","utf8",function(G,X){if(G||X===void 0){if(!process.env.PIDUSAGE_SILENT)console.warn("[pidusage] We couldn't find uptime from /proc/uptime, using os.uptime() value");return A(null,e0.uptime()||new Date/1000)}return A(null,parseFloat(X.split(" ")[0]))})}function LA(A){U0([function(X){N0("CLK_TCK",{default:100},X)},function(X){N0("PAGESIZE",{default:4096},X)}],function(G,X){if(G)return A(G);A(null,{clockTick:X[0],pageSize:X[1]})})}function N0(A,G,X){if(typeof G==="function")X=G,G={default:""};XA("getconf "+A,function(L,J,H){if(L!==null){if(!process.env.PIDUSAGE_SILENT)console.error('Error while calling "getconf '+A+'"',L);return X(null,G.default)}if(J=parseInt(J),!isNaN(J))return X(null,J);return X(null,G.default)})}});var M0=P((a,F0)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var l=M("buffer"),V=l.Buffer;function _0(A,G){for(var X in A)G[X]=A[X]}if(V.from&&V.alloc&&V.allocUnsafe&&V.allocUnsafeSlow)F0.exports=l;else _0(l,a),a.Buffer=z;function z(A,G,X){return V(A,G,X)}z.prototype=Object.create(V.prototype);_0(V,z);z.from=function(A,G,X){if(typeof A==="number")throw TypeError("Argument must not be a number");return V(A,G,X)};z.alloc=function(A,G,X){if(typeof A!=="number")throw TypeError("Argument must be a number");var L=V(A);if(G!==void 0)if(typeof X==="string")L.fill(G,X);else L.fill(G);else L.fill(0);return L};z.allocUnsafe=function(A){if(typeof A!=="number")throw TypeError("Argument must be a number");return V(A)};z.allocUnsafeSlow=function(A){if(typeof A!=="number")throw TypeError("Argument must be a number");return l.SlowBuffer(A)}});var R0=P((wA,P0)=>{var d=M("fs"),HA=M("path"),JA=Z0(),KA=p(),v0=y(),O=null,C0=M0().Buffer,i=1024;function QA(){}function WA(A,G,X){if(G.fd)return X(null,G.fd);d.open(A,"r",X)}function YA(A){if(A.fd)d.close(A.fd,QA)}function T0(A,G,X){let L=!1;if(typeof G==="function")X=G,G=C0.alloc(i),L=!0;d.read(A,G,0,i,0,function(J,H,K){if(J){X(J);return}let Y=C0.concat([G,K],L?H:G.length+H);if(H===i){T0(A,Y,X);return}X(null,G)})}function D0(A,G,X){let L=v0.get(A,G.maxage),J=!1;if(L===void 0)J=!0,L={};WA(HA.join("/proc",""+A,"stat"),L,function(H,K){if(H){if(H.code==="ENOENT")H.message="No matching pid found";return X(H,null)}if(H)return X(H);T0(K,function(Y,$){if(Y)return X(Y);let Q=$.toString("utf8"),N=Date.now(),U=Q.lastIndexOf(")");Q=Q.substr(U+2).split(" ");let W={ppid:parseInt(Q[1]),utime:parseFloat(Q[11])*1000/O.clockTick,stime:parseFloat(Q[12])*1000/O.clockTick,cutime:parseFloat(Q[13])*1000/O.clockTick,cstime:parseFloat(Q[14])*1000/O.clockTick,start:parseFloat(Q[19])*1000/O.clockTick,rss:parseFloat(Q[21]),uptime:O.uptime*1000,fd:K},q=W.rss*O.pageSize,Z=G.childrens?W.cutime+W.cstime:0,F=W.stime-(L.stime||0)+W.utime-(L.utime||0)+Z,v=Math.abs(L.uptime!==void 0?W.uptime-L.uptime:W.start-W.uptime),C=v>0?F/v*100:0;if(v0.set(A,W,G.maxage,YA),J)return D0(A,G,X);return X(null,{cpu:C,memory:q,ctime:W.utime+W.stime,elapsed:W.uptime-W.start,timestamp:N,pid:A,ppid:W.ppid})})})}function $A(A,G,X){JA(O,function(L,J){if(L)return X(L);O=J;let H={};A.forEach(function(K,Y){H[K]=function($){D0(K,G,$)}}),KA(H,{graceful:!0},X)})}P0.exports=$A});var S0=P((zA,E0)=>{var V0=M("os"),NA=b(),I0=y();function UA(A){let G=A.substring(0,4),X=A.substring(4,6),L=A.substring(6,8),J=A.substring(8,10),H=A.substring(10,12),K=A.substring(12,14),Y=A.substring(15,21),$=A.substring(21,22),Q=parseInt(A.substring(22,25),10),N=Math.floor(Q/60),U=Q%60;return new Date(G+"-"+X+"-"+L+"T"+J+":"+H+":"+K+"."+Y+$+(N>9?N:"0"+N)+(U>9?U:"0"+U))}function O0(A,G,X){let L="ProcessId="+A[0];for(let H=1;H<A.length;H++)L+=" or ProcessId="+A[H];let J=["PROCESS","where",'"'+L+'"',"get","CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize"];NA("wmic",J,{windowsHide:!0,windowsVerbatimArguments:!0},function(H,K,Y){if(H){if(H.message.indexOf("No Instance(s) Available.")!==-1){let W=Error("No matching pid found");return W.code="ENOENT",X(W)}return X(H)}if(Y!==0)return X(Error("pidusage wmic command exited with code "+Y));let $=Date.now(),Q=Math.floor(V0.uptime()||$/1000);K=K.split(V0.EOL);let N=!1,U={};for(let W=1;W<K.length;W++){let q=K[W].trim().split(/\s+/);if(!q||q.length!==6)continue;let Z=UA(q[0]),F=parseInt(q[2],10),v=parseInt(q[3],10),C=Math.round(parseInt(q[1],10)/1e4),T=Math.round(parseInt(q[4],10)/1e4),I=parseInt(q[5],10),D=I0.get(v,G.maxage);if(D===void 0)N=!0,D={ctime:C+T,uptime:Q};let u=(C+T-D.ctime)/1000,S=Q-D.uptime,m=S>0?u/S*100:0;I0.set(v,{ctime:T+C,uptime:Q},G.maxage),U[v]={cpu:m,memory:I,ppid:F,pid:v,ctime:T+C,elapsed:$-Z.getTime(),timestamp:$}}if(N)return O0(A,G,function(W,q){if(W)return X(W);X(null,Object.assign(U,q))});X(null,U)})}E0.exports=O0});var y0=P((BA,B0)=>{var j0=M("os"),qA=b(),w0=y();function ZA(A){let G=A.substring(0,4),X=A.substring(4,6),L=A.substring(6,8),J=A.substring(8,10),H=A.substring(10,12),K=A.substring(12,14),Y=A.substring(15,21),$=A.substring(21,22),Q=parseInt(A.substring(22,25),10),N=Math.floor(Q/60),U=Q%60;return new Date(G+"-"+X+"-"+L+"T"+J+":"+H+":"+K+"."+Y+$+(N>9?N:"0"+N)+(U>9?U:"0"+U))}function z0(A,G,X){let L="ProcessId="+A[0];for(let K=1;K<A.length;K++)L+=" or ProcessId="+A[K];let J="CreationDate,KernelModeTime,ParentProcessId,ProcessId,UserModeTime,WorkingSetSize",H=["win32_process","-Filter","'"+L+"'","| select "+J,"| format-table"];qA("gwmi",H,{windowsHide:!0,windowsVerbatimArguments:!0,shell:"powershell.exe"},function(K,Y,$){if(K){if(K.message.indexOf("No Instance(s) Available.")!==-1){let Z=Error("No matching pid found");return Z.code="ENOENT",X(Z)}return X(K)}if($!==0)return X(Error("pidusage gwmi command exited with code "+$));let Q=Date.now(),N=Math.floor(j0.uptime()||Q/1000);Y=Y.split(j0.EOL).slice(1);let U=Y.findIndex((Z)=>!!Z);if(Y=Y.slice(U+2),!Y.length){let Z=Error("No matching pid found");return Z.code="ENOENT",X(Z)}let W=!1,q={};for(let Z=0;Z<Y.length;Z++){let F=Y[Z].trim().split(/\s+/);if(!F||F.length===1)continue;let v=ZA(F[0]),C=parseInt(F[2],10),T=parseInt(F[3],10),I=Math.round(parseInt(F[1],10)/1e4),D=Math.round(parseInt(F[4],10)/1e4),u=parseInt(F[5],10),S=w0.get(T,G.maxage);if(S===void 0)W=!0,S={ctime:I+D,uptime:N};let m=(I+D-S.ctime)/1000,s=N-S.uptime,m0=s>0?m/s*100:0;w0.set(T,{ctime:D+I,uptime:N},G.maxage),q[T]={cpu:m0,memory:u,ppid:C,pid:T,ctime:D+I,elapsed:Q-v.getTime(),timestamp:Q}}if(W)return z0(A,G,function(Z,F){if(Z)return X(Z);X(null,Object.assign(q,F))});X(null,q)})}B0.exports=z0});var h0=P((yA,g0)=>{var _A=M("fs"),k0=M("os"),FA=M("child_process").spawn,o={ps:()=>W0(),procfile:()=>R0(),wmic:()=>S0(),gwmi:()=>y0()},MA={aix:"ps",os400:"ps",android:"procfile",alpine:"procfile",darwin:"ps",freebsd:"ps",os390:"ps",linux:"procfile",netbsd:"procfile",openbsd:"ps",sunos:"ps",win:"wmic"},k=k0.platform();if(_A.existsSync("/etc/alpine-release"))k="alpine";if(k.match(/^win/))k="win";var x0;try{x0=o[MA[k]]()}catch(A){}function vA(A,G,X){let L=x0;if(k!=="win"&&G.usePs===!0)L=o.ps();if(k==="win"){let H;try{H=FA("wmic",function(K){if(K)throw Error(K)})}catch(K){L=o.gwmi()}finally{if(H)H.kill()}}if(L===void 0)return X(Error(k0.platform()+" is not supported yet, please open an issue (https://github.com/soyuka/pidusage)"));let J=!1;if(!Array.isArray(A))J=!0,A=[A];if(A.length===0)return X(TypeError("You must provide at least one pid"));for(let H=0;H<A.length;H++)if(A[H]=parseInt(A[H],10),isNaN(A[H])||A[H]<0)return X(TypeError("One of the pids provided is invalid"));L(A,G,function(H,K){if(H)return X(H);if(J)X(null,K[A[0]]);else X(null,K)})}g0.exports=vA});var f0=P((kA,r)=>{var b0=h0();function CA(A,G,X){if(typeof G==="function")X=G,G={};if(G===void 0)G={};if(G=Object.assign({usePs:/^true$/i.test(process.env.PIDUSAGE_USE_PS),maxage:process.env.PIDUSAGE_MAXAGE},G),typeof X==="function"){b0(A,G,X);return}return new Promise(function(L,J){b0(A,G,function(H,K){if(H)return J(H);L(K)})})}r.exports=CA;r.exports.clear=y().clear});var e=h(c0(),1);var _=h(t(),1);class A0 extends e.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(A){return{hasError:!0,error:A}}componentDidCatch(A,G){let{name:X="ErrorBoundary"}=this.props;console.error(`
|
|
2
2
|
========================================`),console.error(`[${X}] React Error Caught`),console.error("========================================"),console.error("Error:",A.message),console.error("Stack:",A.stack),console.error("Component Stack:",G.componentStack),console.error(`========================================
|
|
3
|
-
`),this.setState({errorInfo:G})}render(){let{hasError:A,error:G,errorInfo:X}=this.state,{name:L="ErrorBoundary",fallback:J,children:H}=this.props;if(A){if(J)return _.jsxDEV(_.Fragment,{children:J},void 0,!1,void 0,this);return _.jsxDEV(j,{flexDirection:"column",padding:1,borderStyle:"double",borderColor:"red",children:[_.jsxDEV(j,{marginBottom:1,children:_.jsxDEV(
|
|
3
|
+
`),import("./chunk-ns6tjjkq.js").then(({logAgentError:L})=>{L(X,A)}).catch((L)=>{console.warn("Failed to log React error:",L)}),this.setState({errorInfo:G})}render(){let{hasError:A,error:G,errorInfo:X}=this.state,{name:L="ErrorBoundary",fallback:J,children:H}=this.props;if(A){if(J)return _.jsxDEV(_.Fragment,{children:J},void 0,!1,void 0,this);return _.jsxDEV(j,{flexDirection:"column",padding:1,borderStyle:"double",borderColor:"red",children:[_.jsxDEV(j,{marginBottom:1,children:_.jsxDEV(E,{color:"red",bold:!0,children:["✗ [",L,"] Render Error"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),_.jsxDEV(j,{marginBottom:1,children:_.jsxDEV(E,{color:"red",children:["Message: ",G?.message||"Unknown error"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),G?.stack&&_.jsxDEV(j,{flexDirection:"column",marginBottom:1,children:[_.jsxDEV(E,{color:"yellow",bold:!0,children:"Stack Trace:"},void 0,!1,void 0,this),_.jsxDEV(E,{color:"gray",children:G.stack.split(`
|
|
4
4
|
`).slice(0,5).join(`
|
|
5
|
-
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X?.componentStack&&_.jsxDEV(j,{flexDirection:"column",children:[_.jsxDEV(
|
|
5
|
+
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X?.componentStack&&_.jsxDEV(j,{flexDirection:"column",children:[_.jsxDEV(E,{color:"yellow",bold:!0,children:"Component Stack:"},void 0,!1,void 0,this),_.jsxDEV(E,{color:"gray",dimColor:!0,children:X.componentStack.split(`
|
|
6
6
|
`).slice(0,5).join(`
|
|
7
|
-
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_.jsxDEV(j,{marginTop:1,children:_.jsxDEV(
|
|
8
|
-
export{
|
|
7
|
+
`)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_.jsxDEV(j,{marginTop:1,children:_.jsxDEV(E,{color:"blue",dimColor:!0,children:"Press Ctrl+C to exit"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return _.jsxDEV(_.Fragment,{children:H},void 0,!1,void 0,this)}}var VA=A0;var l0=h(f0(),1);class u0{async getProcessList(){let A=[];for(let[G,X]of g)try{let L=await l0.default(G);A.push({pid:G,command:X.command,startTime:X.startTime,duration:Date.now()-X.startTime,cpu:L.cpu,memory:L.memory,status:this.checkStatus(X)})}catch{A.push({pid:G,command:X.command,startTime:X.startTime,duration:Date.now()-X.startTime,cpu:0,memory:0,status:"stopped"})}return A}killProcess(A){let G=g.get(A);if(!G)return!1;return G.process.kill("SIGTERM"),g.delete(A),!0}getProcessOutput(A){let G=g.get(A);if(!G)return null;return{stdout:G.stdout.join(""),stderr:G.stderr.join("")}}checkStatus(A){try{return process.kill(A.process.pid,0),"running"}catch{return"stopped"}}}var gA=new u0;
|
|
8
|
+
export{VA as f,gA as g};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{w as n}from"./chunk-heasksrr.js";import{$ as t,W as s,X as j,Y as o,Z as d,_ as r,aa as a}from"./chunk-jxsfzfac.js";import{yb as L}from"./chunk-kba8akjs.js";import{AIMessageChunk as z0}from"@langchain/core/messages";import{Command as D0,Send as V0}from"@langchain/langgraph";import{concat as K0}from"@langchain/core/utils/stream";import{load as F0}from"@langchain/core/load";var K=[];for(let $=0;$<256;++$)K.push(($+256).toString(16).slice(1));function p($,Z=0){return(K[$[Z+0]]+K[$[Z+1]]+K[$[Z+2]]+K[$[Z+3]]+"-"+K[$[Z+4]]+K[$[Z+5]]+"-"+K[$[Z+6]]+K[$[Z+7]]+"-"+K[$[Z+8]]+K[$[Z+9]]+"-"+K[$[Z+10]]+K[$[Z+11]]+K[$[Z+12]]+K[$[Z+13]]+K[$[Z+14]]+K[$[Z+15]]).toLowerCase()}import{randomFillSync as P0}from"node:crypto";var w=new Uint8Array(256),S=w.length;function G(){if(S>w.length-16)P0(w),S=0;return w.slice(S,S+=16)}var m={};function Q0($,Z,X){let Y;if($)Y=l($.random??$.rng?.()??G(),$.msecs,$.seq,Z,X);else{let J=Date.now(),U=G();O0(m,J,U),Y=l(U,m.msecs,m.seq,Z,X)}return Z??p(Y)}function O0($,Z,X){if($.msecs??=-1/0,$.seq??=0,Z>$.msecs)$.seq=X[6]<<23|X[7]<<16|X[8]<<8|X[9],$.msecs=Z;else if($.seq=$.seq+1|0,$.seq===0)$.msecs++;return $}function l($,Z,X,Y,J=0){if($.length<16)throw Error("Random bytes length must be >= 16");if(!Y)Y=new Uint8Array(16),J=0;else if(J<0||J+16>Y.length)throw RangeError(`UUID byte range ${J}:${J+15} is out of buffer bounds`);return Z??=Date.now(),X??=$[6]*127<<24|$[7]<<16|$[8]<<8|$[9],Y[J++]=Z/1099511627776&255,Y[J++]=Z/4294967296&255,Y[J++]=Z/16777216&255,Y[J++]=Z/65536&255,Y[J++]=Z/256&255,Y[J++]=Z&255,Y[J++]=112|X>>>28&15,Y[J++]=X>>>20&255,Y[J++]=128|X>>>14&63,Y[J++]=X>>>6&255,Y[J++]=X<<2&255|$[10]&3,Y[J++]=$[11],Y[J++]=$[12],Y[J++]=$[13],Y[J++]=$[14],Y[J++]=$[15],Y}var B=Q0;import"kysely";var A0=($)=>{let Z=$.goto!=null&&!Array.isArray($.goto)?[$.goto]:$.goto;return new D0({goto:Z?.map((X)=>{if(typeof X!=="string")return new V0(X.node,X.input);return X}),update:$.update??void 0,resume:$.resume})},i="[...]",B0="[Circular]",M=[],E=[];function N0(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function R0($,Z,X,Y){if(typeof Y>"u")Y=N0();k($,"",0,[],void 0,0,Y);var J;try{if(E.length===0)J=JSON.stringify($,Z,X);else J=JSON.stringify($,L0(Z),X)}catch(H){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{while(M.length!==0){var U=M.pop();if(U.length===4)Object.defineProperty(U[0],U[1],U[3]);else U[0][U[1]]=U[2]}}return J}function b($,Z,X,Y){var J=Object.getOwnPropertyDescriptor(Y,X);if(J.get!==void 0)if(J.configurable)Object.defineProperty(Y,X,{value:$}),M.push([Y,X,Z,J]);else E.push([Z,X,$]);else Y[X]=$,M.push([Y,X,Z])}function k($,Z,X,Y,J,U,H){U+=1;var x;if(typeof $==="object"&&$!==null){for(x=0;x<Y.length;x++)if(Y[x]===$){b(B0,$,Z,J);return}if(typeof H.depthLimit<"u"&&U>H.depthLimit){b(i,$,Z,J);return}if(typeof H.edgesLimit<"u"&&X+1>H.edgesLimit){b(i,$,Z,J);return}if(Y.push($),Array.isArray($))for(x=0;x<$.length;x++)k($[x],x,x,Y,$,U,H);else{var W=Object.keys($);for(x=0;x<W.length;x++){var Q=W[x];k($[Q],Q,x,Y,$,U,H)}}Y.pop()}}function L0($){return $=typeof $<"u"?$:function(Z,X){return X},function(Z,X){if(E.length>0)for(var Y=0;Y<E.length;Y++){var J=E[Y];if(J[1]===Z&&J[0]===X){X=J[2],E.splice(Y,1);break}}return $.call(this,Z,X)}}function _0($){return $!==null&&$.lc===1&&$.type==="constructor"&&Array.isArray($.id)}async function y($){if($&&typeof $==="object")if(Array.isArray($))return await Promise.all($.map((X)=>y(X)));else{let Z={};for(let[X,Y]of Object.entries($))Z[X]=await y(Y);if(Z.lc===2&&Z.type==="undefined")return;else if(Z.lc===2&&Z.type==="constructor"&&Array.isArray(Z.id))try{let X=Z.id[Z.id.length-1],Y;switch(X){case"Set":Y=Set;break;case"Map":Y=Map;break;case"RegExp":Y=RegExp;break;case"Error":Y=Error;break;default:return Z}if(Z.method)return Y[Z.method](...Z.args||[]);else return new Y(...Z.args||[])}catch(X){return Z}else if(_0(Z))return F0(JSON.stringify(Z));return Z}return $}function v($,Z,X,Y){return{lc:2,type:"constructor",id:[$.name],method:Z??null,args:X??[],kwargs:Y??{}}}function E0($){if($===void 0)return{lc:2,type:"undefined"};else if($ instanceof Set||$ instanceof Map)return v($.constructor,void 0,[Array.from($)]);else if($ instanceof RegExp)return v(RegExp,void 0,[$.source,$.flags]);else if($ instanceof Error)return v($.constructor,void 0,[$.message]);else if($?.lg_name==="Send")return{node:$.node,args:$.args};else return $}class e{_dumps($){return new TextEncoder().encode(R0($,(X,Y)=>{return E0(Y)}))}async dumpsTyped($){if($ instanceof Uint8Array)return["bytes",$];else return["json",this._dumps($)]}async _loads($){let Z=JSON.parse($);return y(Z)}async loadsTyped($,Z){if($==="bytes")return typeof Z==="string"?new TextEncoder().encode(Z):Z;else if($==="json")return this._loads(typeof Z==="string"?Z:new TextDecoder().decode(Z));else throw Error(`Unknown serialization type: ${$}`)}}class $0 extends n.default{constructor($,Z=!0,X=300){super();this.id=$,this.compressMessages=Z,this.ttl=X}serializer=new e;async encodeData($){let[Z,X]=await this.serializer.dumpsTyped($);return X}async decodeData($){return await this.serializer.loadsTyped("json",$)}}class Z0{queues=new Map;defaultCompressMessages;queueConstructor;constructor($,Z={}){this.defaultCompressMessages=Z.defaultCompressMessages??!0,this.queueConstructor=$}createQueue($,Z=300){return this.queues.set($,new this.queueConstructor($,this.defaultCompressMessages,Z)),this.queues.get($)}async getQueue($){let Z=this.queues.get($);if(!Z)if(await this.queueConstructor?.isQueueExist?.($))return this.createQueue($);else throw Error(`Queue with id '${$}' does not exist`);return Z}async cancelQueue($){await this.removeQueue($)}async pushToQueue($,Z){await(await this.getQueue($)).push(Z)}async getQueueData($){let Z=this.queues.get($);if(!Z)throw Error(`Queue with id '${$}' does not exist`);return await Z.getAll()}async clearQueue($){let Z=this.queues.get($);if(Z){let X=Z.clear();if(X instanceof Promise)await X}}async removeQueue($){let Z=this.queues.get($);if(!Z)return!1;try{await Z.cancel()}catch(X){console.error("Error cancelling queue:",X)}try{let X=Z.clear();if(X instanceof Promise)await X}catch(X){console.error("Error clearing queue:",X)}if(typeof Z.destroy==="function")try{await Z.destroy()}catch(X){console.error("Error destroying queue:",X)}return this.queues.delete($)}getAllQueueIds(){return Array.from(this.queues.keys())}async getAllQueuesData(){let $={};for(let[Z,X]of this.queues)$[Z]=await X.getAll();return $}clearAllQueues(){for(let $ of this.queues.values())$.clear()}async copyQueue($,Z,X){let J=await(await this.getQueue($)).copyToQueue(Z,X);return this.queues.set(Z,J),J}}var T={};async function s0($,Z){T[$]=Z}async function X0($,Z,X){if(!T[$])throw Error(`Graph "${$}" not found`);let Y=typeof T[$]==="function"?await T[$](Z??{configurable:{}}):T[$];if(typeof X?.checkpointer<"u")Y.checkpointer=X?.checkpointer??F.globalCheckPointer;else Y.checkpointer=F.globalCheckPointer;return Y.store=X?.store??void 0,Y}class I{db;adapter;constructor($){this.db=$.db,this.adapter=$}async setup(){await this.adapter.createTables(this.db),await this.adapter.createIndexes(this.db)}async create($){let Z=$?.threadId||B(),X=new Date,Y=$?.metadata||{},J={};if($?.ifExists==="raise"){if(await this.db.selectFrom("threads").select("thread_id").where("thread_id","=",Z).executeTakeFirst())throw Error(`Thread with ID ${Z} already exists.`)}if($?.ifExists==="do_nothing"&&$?.threadId){let U=await this.db.selectFrom("threads").selectAll().where("thread_id","=",Z).executeTakeFirst();if(U)return{thread_id:U.thread_id,created_at:this.adapter.dbToDate(U.created_at).toISOString(),updated_at:this.adapter.dbToDate(U.updated_at).toISOString(),state_updated_at:this.adapter.dbToDate(U.updated_at).toISOString(),metadata:this.adapter.dbToJson(U.metadata),status:U.status,values:U.values?this.adapter.dbToJson(U.values):null,interrupts:this.adapter.dbToJson(U.interrupts),title:U.title}}return await this.db.insertInto("threads").values({thread_id:Z,created_at:this.adapter.dateToDb(X),updated_at:this.adapter.dateToDb(X),metadata:this.adapter.jsonToDb(Y),status:"idle",values:null,interrupts:this.adapter.jsonToDb(J)}).execute(),{thread_id:Z,created_at:X.toISOString(),updated_at:X.toISOString(),state_updated_at:X.toISOString(),metadata:Y,status:"idle",values:null,interrupts:J,title:null}}async search($){let Z=this.db.selectFrom("threads"),X;if($?.select)X=new Set($.select);else if($?.withoutDetails)X=new Set(["thread_id","created_at","updated_at","metadata","status","title"]);else X=new Set(["thread_id","created_at","updated_at","metadata","status","values","interrupts","title"]);let Y=[];if(X.has("thread_id"))Y.push("thread_id");if(X.has("created_at"))Y.push("created_at");if(X.has("updated_at"))Y.push("updated_at");if(X.has("metadata"))Y.push("metadata");if(X.has("status"))Y.push("status");if(X.has("values"))Y.push("values");if(X.has("interrupts"))Y.push("interrupts");if(X.has("title"))Y.push("title");if(Y.length>0)Z=Z.select(Y);else Z=Z.selectAll();if($?.ids&&$.ids.length>0)Z=Z.where("thread_id","in",$.ids);if($?.status)Z=Z.where("status","=",$.status);if($?.metadata)for(let[U,H]of Object.entries($.metadata))Z=Z.where(this.adapter.buildJsonQuery(this.db,"metadata",U,H));if($?.values)Z=Z.where((U)=>{return U("values","=",this.adapter.jsonToDb($.values))});if($?.sortBy){let U=$.sortOrder==="desc"?"desc":"asc";Z=Z.orderBy($.sortBy,U)}if($?.limit!==void 0){if(Z=Z.limit($.limit),$?.offset!==void 0)Z=Z.offset($.offset)}return(await Z.execute()).map((U)=>{let H={thread_id:U.thread_id};if(X.has("created_at"))H.created_at=this.adapter.dbToDate(U.created_at).toISOString();if(X.has("updated_at"))H.updated_at=this.adapter.dbToDate(U.updated_at).toISOString();if(X.has("metadata"))H.metadata=this.adapter.dbToJson(U.metadata);if(X.has("status"))H.status=U.status;if(X.has("values"))H.values=U.values?this.adapter.dbToJson(U.values):null;if(X.has("interrupts"))H.interrupts=this.adapter.dbToJson(U.interrupts);if(X.has("title"))H.title=U.title;return H})}async get($){let Z=await this.db.selectFrom("threads").selectAll().where("thread_id","=",$).executeTakeFirst();if(!Z)throw Error(`Thread with ID ${$} not found.`);return{thread_id:Z.thread_id,created_at:this.adapter.dbToDate(Z.created_at).toISOString(),updated_at:this.adapter.dbToDate(Z.updated_at).toISOString(),state_updated_at:this.adapter.dbToDate(Z.updated_at).toISOString(),metadata:this.adapter.dbToJson(Z.metadata),status:Z.status,values:Z.values?this.adapter.dbToJson(Z.values):null,interrupts:this.adapter.dbToJson(Z.interrupts),title:Z.title}}async set($,Z){if(!await this.db.selectFrom("threads").select("thread_id").where("thread_id","=",$).executeTakeFirst())throw Error(`Thread with ID ${$} not found.`);let Y={updated_at:this.adapter.dateToDb(new Date)};if(Z.metadata!==void 0)Y.metadata=this.adapter.jsonToDb(Z.metadata);if(Z.status!==void 0)Y.status=Z.status;if(Z.values!==void 0)Y.values=Z.values?this.adapter.jsonToDb(Z.values):null;if(Z.interrupts!==void 0)Y.interrupts=this.adapter.jsonToDb(Z.interrupts);if(Z.title!==void 0)Y.title=Z.title;await this.db.updateTable("threads").set(Y).where("thread_id","=",$).execute()}async delete($){if((await this.db.deleteFrom("threads").where("thread_id","=",$).executeTakeFirst()).numDeletedRows===0n)throw Error(`Thread with ID ${$} not found.`)}async updateState($,Z){let X=await this.get($);if(X.status==="busy")throw Error(`Thread with ID ${$} is busy, can't update state.`);let Y=X.metadata?.graph_id;if(!Y)return await this.set($,{values:Z.values??null}),{configurable:{thread_id:$}};let J={configurable:{thread_id:$,graph_id:Y}},U=await X0(Y,J),H=await U.updateState(J,Z.values),x=await U.getState(J);return await this.set($,{values:JSON.parse(f(x.values))}),H}async createRun($,Z,X){let Y=B(),J=new Date,U=X?.metadata??{};return await this.db.insertInto("runs").values({run_id:Y,thread_id:$,assistant_id:Z,created_at:this.adapter.dateToDb(J),updated_at:this.adapter.dateToDb(J),status:"pending",metadata:this.adapter.jsonToDb(U),multitask_strategy:"reject"}).execute(),{run_id:Y,thread_id:$,assistant_id:Z,created_at:J.toISOString(),updated_at:J.toISOString(),status:"pending",metadata:U,multitask_strategy:"reject"}}async listRuns($,Z){let X=this.db.selectFrom("runs").selectAll().where("thread_id","=",$).orderBy("created_at","desc");if(Z?.status)X=X.where("status","=",Z.status);if(Z?.limit!==void 0){if(X=X.limit(Z.limit),Z?.offset!==void 0)X=X.offset(Z.offset)}return(await X.execute()).map((J)=>({run_id:J.run_id,thread_id:J.thread_id,assistant_id:J.assistant_id,created_at:this.adapter.dbToDate(J.created_at).toISOString(),updated_at:this.adapter.dbToDate(J.updated_at).toISOString(),status:J.status,metadata:this.adapter.dbToJson(J.metadata),multitask_strategy:J.multitask_strategy}))}async updateRun($,Z){if(!await this.db.selectFrom("runs").select("run_id").where("run_id","=",$).executeTakeFirst())throw Error(`Run with ID ${$} not found.`);let Y={updated_at:this.adapter.dateToDb(new Date)};if(Z.status!==void 0)Y.status=Z.status;if(Z.metadata!==void 0)Y.metadata=this.adapter.jsonToDb(Z.metadata);if(Z.multitask_strategy!==void 0)Y.multitask_strategy=Z.multitask_strategy;await this.db.updateTable("runs").set(Y).where("run_id","=",$).execute()}async count($){return(await this.search($)).length}async patch($,Z){let X=await this.db.selectFrom("threads").selectAll().where("thread_id","=",$).executeTakeFirst();if(!X)throw Error(`Thread with ID ${$} not found.`);let Y={updated_at:this.adapter.dateToDb(new Date)};if(Z.metadata!==void 0){let J=this.adapter.dbToJson(X.metadata)||{};Y.metadata=this.adapter.jsonToDb({...J,...Z.metadata})}if(Z.status!==void 0)Y.status=Z.status;if(Z.values!==void 0)Y.values=Z.values?this.adapter.jsonToDb(Z.values):null;if(Z.interrupts!==void 0)Y.interrupts=this.adapter.jsonToDb(Z.interrupts);if(Z.title!==void 0)Y.title=Z.title;return await this.db.updateTable("threads").set(Y).where("thread_id","=",$).execute(),await this.get($)}async getState($,Z){let X=await this.get($);if(Z?.checkpointId){let J=await this.db.selectFrom("checkpoints").selectAll().where("checkpoint_id","=",Z.checkpointId).where("thread_id","=",$).executeTakeFirst();if(!J)throw Error(`Checkpoint with ID ${Z.checkpointId} not found for thread ${$}`);return{values:this.adapter.dbToJson(J.values),next:this.adapter.dbToJson(J.next),metadata:this.adapter.dbToJson(J.metadata),checkpoint:{id:J.checkpoint_id,thread_id:$,parent_checkpoint_id:null,checkpoint_ns:"",metadata:this.adapter.dbToJson(J.metadata),created_at:this.adapter.dbToDate(J.created_at).toISOString()},created_at:this.adapter.dbToDate(J.created_at).toISOString(),parent_checkpoint:null,tasks:[]}}return{values:X.values||{},next:[],metadata:X.metadata,checkpoint:null,created_at:X.created_at,parent_checkpoint:null,tasks:[]}}async getStateHistory($,Z){let Y=await this.db.selectFrom("checkpoints").selectAll().where("thread_id","=",$).orderBy("created_at","asc").execute(),J=Y.map((U)=>({values:this.adapter.dbToJson(U.values),next:this.adapter.dbToJson(U.next),metadata:this.adapter.dbToJson(U.metadata),checkpoint:{thread_id:$,checkpoint_ns:"",checkpoint_id:U.checkpoint_id,checkpoint_map:null},created_at:this.adapter.dbToDate(U.created_at).toISOString(),parent_checkpoint:null,tasks:[]}));if(Z?.before){let U=Y.findIndex((H)=>H.checkpoint_id===Z.before);if(U!==-1)J=J.slice(U+1)}if(Z?.limit)J=J.slice(0,Z.limit);return J}async copy($){let Z=await this.get($),X=B(),Y=new Date;await this.db.insertInto("threads").values({thread_id:X,created_at:this.adapter.dateToDb(Y),updated_at:this.adapter.dateToDb(Y),metadata:this.adapter.jsonToDb(Z.metadata),status:Z.status,values:Z.values?this.adapter.jsonToDb(Z.values):null,interrupts:this.adapter.jsonToDb(Z.interrupts),title:Z.title}).execute();let J=await this.db.selectFrom("checkpoints").selectAll().where("thread_id","=",$).orderBy("created_at","asc").execute();for(let U of J)await this.db.insertInto("checkpoints").values({checkpoint_id:B(),thread_id:X,values:U.values,next:U.next,config:U.config,created_at:U.created_at,metadata:U.metadata}).execute();return{...Z,thread_id:X,created_at:Y.toISOString(),updated_at:Y.toISOString()}}async saveCheckpoint($,Z,X,Y,J){await this.db.insertInto("checkpoints").values({checkpoint_id:B(),thread_id:$,values:this.adapter.jsonToDb(Z),next:this.adapter.jsonToDb(X),config:this.adapter.jsonToDb(Y),created_at:this.adapter.dateToDb(new Date),metadata:this.adapter.jsonToDb(J||{})}).execute()}async setTitleIfNull($,Z){return(await this.db.updateTable("threads").set({title:Z,updated_at:this.adapter.dateToDb(new Date)}).where("thread_id","=",$).where("title","is",null).executeTakeFirst()).numUpdatedRows>0n}}function T0($){let[Z,X]=$.split("::");return{threadId:Z,checkpointNs:X??""}}function C($,Z,X){return`${$}::${Z}::${X}`}function g($){if($===null||typeof $!=="object")return JSON.stringify($);if(Array.isArray($))return JSON.stringify($.map((Y)=>g(Y)));let Z={},X=Object.keys($).sort();for(let Y of X)Z[Y]=$[Y];return JSON.stringify(Z,(Y,J)=>{if(J!==null&&typeof J==="object"&&!Array.isArray(J)){let U={},H=Object.keys(J).sort();for(let x of H)U[x]=J[x];return U}return J})}class Y0 extends d{storage={};writes={};constructor($){super($)}async get($){return(await this.getTuple($))?.checkpoint}async _migratePendingSends($,Z,X,Y){let J=$,U=C(Z,X,Y),H=await Promise.all(Object.values(this.writes[U]??{}).filter(([x,W])=>W===j).map(async([x,W,Q])=>await this.serde.loadsTyped("json",Q)));J.channel_values??={},J.channel_values[j]=H,J.channel_versions??={},J.channel_versions[j]=Object.keys(J.channel_versions).length>0?r(...Object.values(J.channel_versions)):this.getNextVersion(void 0)}async _loadPendingWrites($,Z,X){let Y=C($,Z,X),J=this.writes[Y]??{};if(Object.keys(J).length===0)return[];return await Promise.all(Object.values(J).map(async([U,H,x])=>{return[U,H,await this.serde.loadsTyped("json",x)]}))}_cleanupOldWrites($,Z,X){let Y=C($,Z,X);delete this.writes[Y]}_checkMetadataFilterMatch($,Z){for(let[X,Y]of Object.entries(Z)){let J=$?.[X];if(Y===null){if(!(X in($||{}))||J!==null)return!1}else if(typeof Y==="object"&&!Array.isArray(Y)){if(typeof J!=="object"||J===null)return!1;if(g(Y)!==g(J))return!1}else if(J!==Y)return!1}return!0}async getTuple($){let Z=$.configurable?.thread_id,X=$.configurable?.checkpoint_ns??"",Y=a($);if(Z===void 0)return;let J=this.storage[Z]?.[X];if(J===void 0)return;let{checkpoint:U,metadata:H,checkpoint_id:x,parent_checkpoint_id:W}=J;if(Y&&x!==Y)return;let Q=await this.serde.loadsTyped("json",U);if(Q.v<4&&W!==void 0)await this._migratePendingSends(Q,Z,X,W);let P=await this._loadPendingWrites(Z,X,x),z=await this.serde.loadsTyped("json",H),V={config:{configurable:{thread_id:Z,checkpoint_ns:X,checkpoint_id:x}},checkpoint:Q,metadata:z,pendingWrites:P};if(W!==void 0)V.parentConfig={configurable:{thread_id:Z,checkpoint_ns:X,checkpoint_id:W}};return V}async*list($,Z){let{before:X,limit:Y,filter:J}=Z??{},U=$.configurable?.thread_id?[$.configurable.thread_id]:Object.keys(this.storage),H=$.configurable?.checkpoint_ns,x=$.configurable?.checkpoint_id,W=[];for(let P of U){let z=this.storage[P];if(z===void 0)continue;for(let V of Object.keys(z)){if(H!==void 0&&V!==H)continue;let A=z[V];if(A===void 0)continue;let{checkpoint_id:D}=A;if(x&&D!==x)continue;if(X?.configurable?.checkpoint_id&&D>=X.configurable.checkpoint_id)continue;let N=await this.serde.loadsTyped("json",A.metadata);if(J&&!this._checkMetadataFilterMatch(N,J))continue;W.push({threadId:P,checkpointNs:V,namespaceData:A})}}W.sort((P,z)=>z.namespaceData.checkpoint_ts-P.namespaceData.checkpoint_ts);let Q=0;for(let{threadId:P,checkpointNs:z,namespaceData:V}of W){if(Y!==void 0&&Q>=Y)return;let{checkpoint:A,metadata:D,checkpoint_id:N,parent_checkpoint_id:_}=V,O=await this.serde.loadsTyped("json",A);if(O.v<4&&_!==void 0)await this._migratePendingSends(O,P,z,_);let q=await this._loadPendingWrites(P,z,N),W0=await this.serde.loadsTyped("json",D),u={config:{configurable:{thread_id:P,checkpoint_ns:z,checkpoint_id:N}},checkpoint:O,metadata:W0,pendingWrites:q};if(_!==void 0)u.parentConfig={configurable:{thread_id:P,checkpoint_ns:z,checkpoint_id:_}};Q++,yield u}}async put($,Z,X,Y){let J=o(Z),U=$.configurable?.thread_id,H=$.configurable?.checkpoint_ns??"",x=$.configurable?.checkpoint_id;if(U===void 0)throw Error("thread_id is required");let W=Z.id||s(0);if(!this.storage[U])this.storage[U]={};let Q=this.storage[U][H];if(Q!==void 0&&Q.checkpoint_id!==W)this._cleanupOldWrites(U,H,Q.checkpoint_id);let[[,P],[,z]]=await Promise.all([this.serde.dumpsTyped(J),this.serde.dumpsTyped(X)]);return this.storage[U][H]={checkpoint:P,metadata:z,checkpoint_id:W,parent_checkpoint_id:x,checkpoint_ts:Date.now()},{configurable:{thread_id:U,checkpoint_ns:H,checkpoint_id:W}}}async putWrites($,Z,X){let Y=$.configurable?.thread_id,J=$.configurable?.checkpoint_ns??"",U=$.configurable?.checkpoint_id;if(!Y||!U)throw Error("thread_id and checkpoint_id are required");let H=C(Y,J,U),x=this.writes[H];if(this.writes[H]===void 0)this.writes[H]={};await Promise.all(Z.map(async([W,Q],P)=>{let[,z]=await this.serde.dumpsTyped(Q),V=[X,t[W]||P],A=`${V[0]},${V[1]}`;if(V[1]>=0&&x&&A in x)return;this.writes[H][A]=[X,W,z]}))}async deleteThread($){delete this.storage[$];for(let Z of Object.keys(this.writes)){let{threadId:X}=T0(Z.split("::").slice(0,2).join("::"));if(X===$)delete this.writes[Z]}}}class R{event;data;id;constructor($,Z){this.event=$,this.data=Z}}class J0 extends R{constructor(){super("__system_cancel__","user cancel this run")}}class U0 extends R{constructor(){super("__stream_end__","stream end")}}class c extends R{constructor($){super("__stream_error__",{error:$.name,message:$.message})}}class h extends $0{data=[];activeGenerators=new Set;isDestroyed=!1;async push($){if(this.isDestroyed)return;let Z=this.compressMessages?await this.encodeData($):$;process.env.LG_TEMP_MESSAGE!=="true"&&this.data.push(Z),this.emit("dataChange",Z)}onDataChange($){if(this.isDestroyed)return()=>{};return this.on("dataChange",async(Z)=>{if(this.isDestroyed)return;$(this.compressMessages?await this.decodeData(Z):Z)}),()=>this.off("dataChange",$)}async*onDataReceive(){if(this.isDestroyed)return;let $=new AbortController;this.activeGenerators.add($);let Z=[],X=null,Y=!1,J=!1,U=null,H=async(Q)=>{if(J||$.signal.aborted)return;try{let P=this.compressMessages?await this.decodeData(Q):Q;if(Z.push(P),P.event==="__stream_end__"||P.event==="__stream_error__"||P.event==="__stream_cancel__"){if(U)clearTimeout(U),U=null;if(U=setTimeout(()=>{if(Y=!0,X)X(),X=null},300),P.event==="__stream_cancel__")$.abort("stream cancelled")}if(X)X(),X=null}catch(P){if(console.error("Error in handleData:",P),X)X(),X=null}};this.on("dataChange",H);let x=()=>{if(Y=!0,X)X(),X=null};$.signal.addEventListener("abort",x);let W=()=>{if(J)return;if(J=!0,U)clearTimeout(U),U=null;try{this.off("dataChange",H)}catch(Q){}try{$.signal.removeEventListener("abort",x)}catch(Q){}if(X)X(),X=null;Z.length=0,this.activeGenerators.delete($)};try{if($.signal.aborted||this.isDestroyed)return;while(!Y&&!$.signal.aborted&&!this.isDestroyed)if(Z.length>0){for(let Q of Z)yield Q;Z.length=0}else await new Promise((Q)=>{X=Q})}finally{W()}}async getAll(){if(this.isDestroyed)return[];return this.compressMessages?await Promise.all(this.data.map(($)=>this.decodeData($))):[...this.data]}clear(){this.data.length=0}cancelSignal=new AbortController;async cancel(){for(let $ of this.activeGenerators)try{$.abort("user cancel this run")}catch(Z){}if(this.activeGenerators.clear(),!this.cancelSignal.signal.aborted)this.cancelSignal.abort("user cancel this run");if(!this.isDestroyed)await this.push(new J0)}async copyToQueue($,Z){let X=this.data.slice(),Y=new h($,this.compressMessages,Z??this.ttl);return Y.data=X,Y}async destroy(){if(this.isDestroyed)return;this.isDestroyed=!0,await this.cancel(),this.clear(),this.removeAllListeners(),this.activeGenerators.clear()}}class H0{threads=[];checkpoints=new Map;async setup(){return}async create($){let Z=$?.threadId||B();if($?.ifExists==="raise"&&this.threads.some((Y)=>Y.thread_id===Z))throw Error(`Thread with ID ${Z} already exists.`);let X={thread_id:Z,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),state_updated_at:new Date().toISOString(),metadata:$?.metadata||{},status:"idle",values:null,interrupts:{},title:null};return this.checkpoints.set(Z,[]),this.threads.push(X),X}async search($){let Z=[...this.threads];if($?.ids&&$.ids.length>0)Z=Z.filter((U)=>$.ids.includes(U.thread_id));if($?.status)Z=Z.filter((U)=>U.status===$.status);if($?.metadata){for(let U in $.metadata)if(Object.prototype.hasOwnProperty.call($.metadata,U))Z=Z.filter((H)=>H.metadata&&H.metadata[U]===$.metadata?.[U])}if($?.values)Z=Z.filter((U)=>{if(!U.values)return!1;return this.deepEqual(U.values,$.values)});if($?.sortBy)Z.sort((U,H)=>{let x,W;switch($.sortBy){case"thread_id":x=U.thread_id,W=H.thread_id;break;case"created_at":x=new Date(U.created_at).getTime(),W=new Date(H.created_at).getTime();break;case"updated_at":x=new Date(U.updated_at).getTime(),W=new Date(H.updated_at).getTime();break;case"status":x=U.status,W=H.status;break;default:return 0}if($.sortOrder==="desc")return W>x?1:W<x?-1:0;else return x>W?1:x<W?-1:0});let X=$?.offset||0,Y=$?.limit||Z.length;return Z.slice(X,X+Y).map((U)=>{let H={thread_id:U.thread_id},x;if($?.select)x=new Set($.select);else if($?.withoutDetails)x=new Set(["thread_id","created_at","updated_at","metadata","status"]);else x=new Set(["thread_id","created_at","updated_at","metadata","status","values","interrupts","title"]);if(x.has("thread_id"))H.thread_id=U.thread_id;if(x.has("created_at"))H.created_at=U.created_at;if(x.has("updated_at"))H.updated_at=U.updated_at;if(x.has("metadata"))H.metadata=U.metadata;if(x.has("status"))H.status=U.status;if(x.has("values"))H.values=U.values;if(x.has("interrupts"))H.interrupts=U.interrupts;if(x.has("title"))H.title=U.title;return H})}deepEqual($,Z){if($===Z)return!0;if(typeof $!==typeof Z)return!1;if(typeof $!=="object"||$===null||Z===null)return!1;let X=Object.keys($),Y=Object.keys(Z);if(X.length!==Y.length)return!1;for(let J of X){if(!Y.includes(J))return!1;if(!this.deepEqual($[J],Z[J]))return!1}return!0}async get($){let Z=this.threads.find((X)=>X.thread_id===$);if(!Z)throw Error(`Thread with ID ${$} not found.`);return Z}async set($,Z){let X=this.threads.findIndex((Y)=>Y.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);this.threads[X]={...this.threads[X],...Z}}async delete($){let Z=this.threads.length;if(this.threads=this.threads.filter((X)=>X.thread_id!==$),this.checkpoints.delete($),this.threads.length===Z)throw Error(`Thread with ID ${$} not found.`)}async updateState($,Z){let X=this.threads.findIndex((J)=>J.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);let Y=this.threads[X];if(Y.status==="busy")throw Error(`Thread with ID ${$} is busy, can't update state.`);if(this.threads[X]={...Y,values:Z.values,updated_at:new Date().toISOString()},Y.metadata?.graph_id){let J=Y.metadata?.graph_id,U={configurable:{thread_id:$,graph_id:J}};try{let H=await X0(J,U),x=await H.updateState(U,Z.values),W=await H.getState(U);return await this.set($,{values:JSON.parse(f(W.values))}),x}catch(H){console.warn("Failed to update graph state:",H)}}return{configurable:{thread_id:$}}}runs=[];async createRun($,Z,X){let J={run_id:B(),thread_id:$,assistant_id:Z,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),status:"pending",metadata:X?.metadata??{},multitask_strategy:"reject"};return this.runs.push(J),J}async listRuns($,Z){let X=[...this.runs];if(Z?.status)X=X.filter((Y)=>Y.status===Z.status);if(Z?.limit)X=X.slice(Z.offset||0,(Z.offset||0)+Z.limit);return X}async updateRun($,Z){let X=this.runs.findIndex((Y)=>Y.run_id===$);if(X===-1)throw Error(`Run with ID ${$} not found.`);this.runs[X]={...this.runs[X],...Z}}async count($){return(await this.search($)).length}async patch($,Z){let X=this.threads.findIndex((J)=>J.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);let Y={...this.threads[X],...Z,updated_at:new Date().toISOString(),metadata:Z.metadata?{...this.threads[X].metadata,...Z.metadata}:this.threads[X].metadata};return this.threads[X]=Y,Y}async getState($,Z){let X=await this.get($);if(Z?.checkpointId){let U=(this.checkpoints.get($)||[]).find((H)=>H.checkpoint_id===Z.checkpointId);if(!U)throw Error(`Checkpoint with ID ${Z.checkpointId} not found for thread ${$}`);return{values:U.values,next:U.next,metadata:U.metadata,checkpoint:{id:U.checkpoint_id,thread_id:$,parent_checkpoint_id:null,checkpoint_ns:"",metadata:U.metadata,created_at:U.created_at},created_at:U.created_at,parent_checkpoint:null,tasks:[]}}return{values:X.values||{},next:[],metadata:X.metadata,checkpoint:null,created_at:X.created_at,parent_checkpoint:null,tasks:[]}}async getStateHistory($,Z){let X=this.checkpoints.get($)||[],Y=X.map((J)=>({values:J.values,next:J.next,metadata:J.metadata,checkpoint:{checkpoint_id:J.checkpoint_id,thread_id:$,checkpoint_ns:"",checkpoint_map:void 0},created_at:J.created_at,parent_checkpoint:null,tasks:[]}));if(Z?.before){let J=X.findIndex((U)=>U.checkpoint_id===Z.before);if(J!==-1)Y=Y.slice(J+1)}if(Z?.limit)Y=Y.slice(0,Z.limit);return Y}async copy($){let Z=await this.get($),X=B(),Y={...Z,thread_id:X,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};this.threads.push(Y);let U=(this.checkpoints.get($)||[]).map((H)=>({...H,checkpoint_id:B(),thread_id:X}));return this.checkpoints.set(X,U),Y}async saveCheckpoint($,Z,X,Y,J){let U=this.checkpoints.get($)||[],H={checkpoint_id:B(),thread_id:$,values:Z,next:X,config:Y,created_at:new Date().toISOString(),metadata:J};U.push(H),this.checkpoints.set($,U)}async setTitleIfNull($,Z){let X=this.threads.findIndex((Y)=>Y.thread_id===$);if(X===-1)throw Error(`Thread with ID ${$} not found.`);if(this.threads[X].title===null)return this.threads[X]={...this.threads[X],title:Z,updated_at:new Date().toISOString()},!0;return!1}}var S0=async()=>{if(process.env.REDIS_URL&&(process.env.CHECKPOINT_TYPE==="redis"||process.env.CHECKPOINT_TYPE==="shallow/redis")){if(process.env.CHECKPOINT_TYPE==="redis"){console.debug("LG | Using redis as checkpoint");let{RedisSaver:$}=await import("./chunk-m76ya904.js");return await $.fromUrl(process.env.REDIS_URL,{defaultTTL:60,refreshOnRead:!0})}if(process.env.CHECKPOINT_TYPE==="shallow/redis"){console.debug("LG | Using shallow redis as checkpoint");let{ShallowRedisSaver:$}=await import("./chunk-3490ntd8.js");return await $.fromUrl(process.env.REDIS_URL)}}if(process.env.DATABASE_URL&&x0(process.env.DATABASE_URL)==="postgres"){console.debug("LG | Using postgres as checkpoint");let{createPGCheckpoint:$}=await import("./chunk-4nsg4vcd.js");return $()}if(process.env.SQLITE_DATABASE_URI){if(process.env.CHECKPOINT_TYPE==="sqlite"){console.debug("LG | Using sqlite (full) as checkpoint");let{SqliteSaver:X}=await import("./chunk-trjpzw1n.js");return await X.fromConnStringAsync(process.env.SQLITE_DATABASE_URI)}console.debug("LG | Using shallow sqlite as checkpoint (default)");let{SqliteShallowSaver:$}=await import("./chunk-ep2es95e.js");return await $.fromConnStringAsync(process.env.SQLITE_DATABASE_URI)}return console.log("LG | You are using memory as checkpoint!"),console.log("\x1B[33m%s\x1B[0m","LG | set SQLITE_DATABASE_URI=./.langgraph_api/langgraph.db to your .env file to use \x1B[1mSQLite\x1B[0m for dev!"),console.log("\x1B[33m%s\x1B[0m","LG | set DATABASE_URL=postgresql://user:pass@localhost:5432/db to your .env file to use \x1B[1mPostgreSQL\x1B[0m for prod!"),new Y0},w0=async()=>{let $;if(process.env.REDIS_URL){console.debug("LG | Using redis as stream queue");let{RedisStreamQueue:Z}=await import("./chunk-g377vrpj.js");$=Z}else $=h;return new Z0($)};function x0($){let Z=$.toLowerCase();if(Z.startsWith("http://")||Z.startsWith("https://"))return"remote";return"postgres"}var G0=async($)=>{if(process.env.DATABASE_URL){if(x0(process.env.DATABASE_URL)==="remote"){console.debug("LG | Using Remote PostgreSQL ThreadsManager");let{RemoteKyselyThreadsManager:X}=await import("./chunk-9k5d9vf1.js"),Y=new X(process.env.DATABASE_URL);if(process.env.DATABASE_INIT==="true")await Y.setup();return Y}else if($.checkpointer){console.debug("LG | Using PostgreSQL ThreadsManager");let{PostgresAdapter:X}=await import("./chunk-b52b0t16.js"),Y=$.checkpointer.pool,J=new I(new X(Y));if(process.env.DATABASE_INIT==="true")await J.setup();return J}}if(process.env.SQLITE_DATABASE_URI&&$.checkpointer){console.debug("LG | Using SQLite ThreadsManager");let{SQLiteAdapter:Z}=await import("./chunk-gcm4jp0d.js"),X=$.checkpointer.db,Y=new I(new Z(X));return await Y.setup(),Y}return new H0};function C0($){if(typeof $==="string")return $;if(Array.isArray($))return $.find((X)=>X.type==="text")?.text||"";if($?.text)return $.text;return""}var j0=($,Z)=>{let X=$?.messages;if(!X||!Array.isArray(X)||X.length===0)return null;let Y=X[0];if(!Y)return null;let J=C0(Y.content);if(!J)return null;let U=J.trim().replace(/\n/g," ");if(!U)return null;let H=15,x=U.slice(0,H);return x.length<U.length?`${x}...`:x};class F{static globalMessageQueue=null;static globalCheckPointer=null;static globalThreadsManager=null;static isInitialized=null;static _titleGenerator=j0;static setTitleGenerator($){F._titleGenerator=$}static getTitleGenerator(){return F._titleGenerator}static async initGlobal(){if(F.isInitialized)return F.isInitialized;return F.isInitialized=(async()=>{let[$,Z]=await Promise.all([w0(),S0()]);console.debug("LG | checkpointer created");let X=await G0({checkpointer:Z});console.debug("LG | threads manager created"),console.debug("LG | global init done"),F.globalMessageQueue=$,F.globalCheckPointer=Z,F.globalThreadsManager=X})(),F.isInitialized}}async function M0($,Z,X,Y,J){let H=Y.config?.configurable?.graph_id;if(!H||typeof H!=="string")throw Error("Invalid or missing graph_id");let x=await J.getGraph(H,Y.config,{checkpointer:Y.temporary?null:void 0}),W=Array.isArray(Y.streamMode)?Y.streamMode:Y.streamMode?[Y.streamMode]:[],Q=new Set(["values",...W.filter((D)=>D!=="events"&&D!=="messages-tuple")]);if(W.includes("messages-tuple"))Q.add("messages");if(W.includes("messages"))Q.add("values");await X.push(new R("metadata",{run_id:Z.run_id,attempt:J.attempt,graph_id:H}));let P={...Y.config?.metadata,run_attempt:J.attempt},z=null,V=null,A=null;try{z=new Set,V=new Map,A=await x.stream(Y.command!=null?A0(Y.command):Y.input??null,{interruptAfter:Y.interruptAfter,interruptBefore:Y.interruptBefore,tags:Y.config?.tags,configurable:Y.config?.configurable,recursionLimit:Y.config?.recursionLimit,subgraphs:Y.streamSubgraphs,metadata:P,runId:Z.run_id,streamMode:[...Q],signal:X.cancelSignal.signal});for await(let D of A){let N=[];if(D.length===3)N=D.splice(0,1);let _=(O)=>{if(N.length===0)return O;if(N.length===1&&N[0]?.length===0)return O;return`${O}|${N.join("|")}`};if(D[0]==="values"){let O=D[1];if(_("values")==="values")if(await X.push(new R(_("values"),O)),O?.__interrupt__)await $.set(Z.thread_id,{status:"interrupted",interrupts:O?JSON.parse(f(O)):""});else await $.set(Z.thread_id,{values:O?JSON.parse(f(O)):""})}else if(D[0]==="messages"){let O=D[1][0],q=D[1][1];if(O.id&&!z.has(O.id))await X.push(new R("messages/metadata",{[O.id]:q})),z.add(O.id);if(z0.isInstance(O)&&O.id){if(V.set(O.id,[...V.get(O.id)??[],O]),await X.push(new R("messages/partial",[V.get(O.id).reduce(K0)])),O.content===""&&!O.tool_calls?.length)V.delete(O.id)}else await X.push(new R("messages/partial",[O]))}else if(D[0]==="updates"){let O=D[1];await X.push(new R(_("updates"),O))}}}catch(D){if(!(D instanceof Error&&D.message?.includes("cancel"))){console.error("streamStateWithQueue error:",D);try{await X.push(new c(D))}catch(N){}}throw D}finally{try{await X.push(new U0)}catch(D){}if(z)z.clear(),z=null;if(V)V.clear(),V=null;A=null}}var f=($,Z=0)=>{return JSON.stringify($,function(X,Y){let J=this[X];if(J!=null&&typeof J==="object"&&"toDict"in J&&typeof J.toDict==="function"){let{type:U,data:H}=J.toDict();return{...H,type:U}}return Y},Z)};async function*o0($,Z,X,Y){Z=await Z;let{run_id:J,thread_id:U}=Z,H=null,x=null,W=null,Q=!1;try{await $.set(U,{status:"busy"}),await $.updateRun(Z.run_id,{status:"running"}),x=F.globalMessageQueue.createQueue(J),H=x.onDataReceive(),W=M0($,Z,x,X,Y).catch((P)=>{if(Q)return;if(P.message!=="user cancel this run")console.error("Queue task error:",P);F.globalMessageQueue.pushToQueue(J,new c(P))});for await(let P of H)yield P;await $.updateRun(Z.run_id,{status:"success"})}catch(P){console.error("Stream error:",P),await $.updateRun(Z.run_id,{status:"error"}),await $.set(U,{status:"error"})}finally{if(Q=!0,H){try{await H.return(void 0)}catch(z){}H=null}if(x&&!x.cancelSignal.signal.aborted)try{x.cancelSignal.abort("Stream consumer disconnected")}catch(z){}if(W){try{await Promise.race([W,new Promise((z)=>setTimeout(z,1000))])}catch(z){}W=null}if((await $.get(U)).status==="interrupted")await F.globalMessageQueue.copyQueue(J,U,30000);else await $.set(U,{status:"idle",interrupts:{}});await F.globalMessageQueue.removeQueue(J),x=null}}
|
|
2
|
+
export{$0 as h,T as i,s0 as j,X0 as k,J0 as l,F as m,f as n,o0 as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as A,b as W}from"./chunk-8g2zdcy0.js";import"./chunk-98f6hg43.js";import{W as q,Z as R}from"./chunk-jxsfzfac.js";import{ub as V}from"./chunk-kba8akjs.js";var x=V(W(),1);function B(M){if(M===null||typeof M!=="object")return JSON.stringify(M);if(Array.isArray(M))return JSON.stringify(M.map((J)=>B(J)));let F={},G=Object.keys(M).sort();for(let J of G)F[J]=M[J];return JSON.stringify(F,(J,Q)=>{if(Q!==null&&typeof Q==="object"&&!Array.isArray(Q)){let X={},Y=Object.keys(Q).sort();for(let Z of Y)X[Z]=Q[Z];return X}return Q})}var P=[{index:"checkpoints",prefix:"checkpoint:",schema:{"$.thread_id":{type:"TAG",AS:"thread_id"},"$.checkpoint_ns":{type:"TAG",AS:"checkpoint_ns"},"$.checkpoint_id":{type:"TAG",AS:"checkpoint_id"},"$.parent_checkpoint_id":{type:"TAG",AS:"parent_checkpoint_id"},"$.checkpoint_ts":{type:"NUMERIC",AS:"checkpoint_ts"},"$.has_writes":{type:"TAG",AS:"has_writes"},"$.source":{type:"TAG",AS:"source"},"$.step":{type:"NUMERIC",AS:"step"}}},{index:"checkpoint_writes",prefix:"checkpoint_write:",schema:{"$.thread_id":{type:"TAG",AS:"thread_id"},"$.checkpoint_ns":{type:"TAG",AS:"checkpoint_ns"},"$.checkpoint_id":{type:"TAG",AS:"checkpoint_id"},"$.task_id":{type:"TAG",AS:"task_id"},"$.idx":{type:"NUMERIC",AS:"idx"},"$.channel":{type:"TAG",AS:"channel"},"$.type":{type:"TAG",AS:"type"}}}],N=class M extends R{client;ttlConfig;constructor(F,G){super();this.client=F,this.ttlConfig=G}static async fromUrl(F,G){let J=x.createClient({url:F});await J.connect();let Q=new M(J,G);return await Q.ensureIndexes(),Q}async get(F){return(await this.getTuple(F))?.checkpoint}async put(F,G,J,Q){await this.ensureIndexes();let X=F.configurable?.thread_id,Y=F.configurable?.checkpoint_ns??"",Z=F.configurable?.checkpoint_id;if(!X)throw Error("thread_id is required");let _=G.id||q(0),E=`checkpoint:${X}:${Y}:shallow`,H=null,$=null;try{if(H=await this.client.json.get(E),H&&typeof H==="object")$=H.checkpoint_id}catch(O){}if($&&$!==_)await this.cleanupOldCheckpoint(X,Y,$);let L={...G,channel_values:G.channel_values||{},channel_blobs:void 0},U={thread_id:X,checkpoint_ns:Y,checkpoint_id:_,parent_checkpoint_id:Z||null,checkpoint:L,metadata:this.sanitizeMetadata(J),checkpoint_ts:Date.now(),has_writes:"false"};if(this.addSearchableMetadataFields(U,J),await this.client.json.set(E,"$",U),this.ttlConfig?.defaultTTL)await this.applyTTL(E);return{configurable:{thread_id:X,checkpoint_ns:Y,checkpoint_id:_}}}async getTuple(F){let G=F.configurable?.thread_id,J=F.configurable?.checkpoint_ns??"",Q=F.configurable?.checkpoint_id;if(!G)return;let X=`checkpoint:${G}:${J}:shallow`,Y=await this.client.json.get(X);if(!Y)return;if(Q&&Y.checkpoint_id!==Q)return;if(this.ttlConfig?.refreshOnRead&&this.ttlConfig?.defaultTTL)await this.applyTTL(X);let Z=await this.serde.loadsTyped("json",JSON.stringify(Y.checkpoint)),_;if(Y.has_writes==="true")_=await this.loadPendingWrites(Y.thread_id,Y.checkpoint_ns,Y.checkpoint_id);return await this.createCheckpointTuple(Y,Z,_)}async*list(F,G){if(await this.ensureIndexes(),F?.configurable?.thread_id){let J=await this.getTuple(F);if(J)if(G?.filter){if(this.checkMetadataFilterMatch(J.metadata,G.filter))yield J}else yield J}else{let J=[];if(G?.filter){for(let[Y,Z]of Object.entries(G.filter))if(Z===void 0);else if(Z===null);else if(typeof Z==="string"){let _=A(Y),E=A(Z);J.push(`(@${_}:{${E}})`)}else if(typeof Z==="number"){let _=A(Y);J.push(`(@${_}:[${Z} ${Z}])`)}}if(J.length===0)J.push("*");let Q=J.join(" "),X=G?.limit??10;try{let Y=await this.client.ft.search("checkpoints",Q,{LIMIT:{from:0,size:X*2},SORTBY:{BY:"checkpoint_ts",DIRECTION:"DESC"}}),Z=new Set,_=0;for(let E of Y.documents){if(_>=X)break;let H=E.value,$=`${H.thread_id}:${H.checkpoint_ns}`;if(Z.has($))continue;if(Z.add($),G?.filter){if(!this.checkMetadataFilterMatch(H.metadata,G.filter))continue}let L=await this.serde.loadsTyped("json",JSON.stringify(H.checkpoint));yield await this.createCheckpointTuple(H,L),_++}}catch(Y){if(Y.message?.includes("no such index")){let Z=await this.client.keys("checkpoint:*:*:shallow");if(Z.length===0)return;Z.sort().reverse();let _=new Set,E=0,H=G?.limit??10;for(let $ of Z){if(E>=H)break;let L=await this.client.json.get($);if(!L)continue;let U=`${L.thread_id}:${L.checkpoint_ns}`;if(_.has(U))continue;if(_.add(U),G?.filter){if(!this.checkMetadataFilterMatch(L.metadata,G.filter))continue}let O=await this.serde.loadsTyped("json",JSON.stringify(L.checkpoint));yield await this.createCheckpointTuple(L,O),E++}return}throw Y}}}async putWrites(F,G,J){await this.ensureIndexes();let Q=F.configurable?.thread_id,X=F.configurable?.checkpoint_ns??"",Y=F.configurable?.checkpoint_id;if(!Q||!Y)throw Error("thread_id and checkpoint_id are required");let Z=`checkpoint_write:${Q}:${X}:${Y}:${J}:*`,_=await this.client.keys(Z);if(_.length>0)await this.client.del(_);let E=[];for(let $=0;$<G.length;$++){let[L,U]=G[$],O=`checkpoint_write:${Q}:${X}:${Y}:${J}:${$}`;E.push(O);let T={thread_id:Q,checkpoint_ns:X,checkpoint_id:Y,task_id:J,idx:$,channel:L,type:typeof U==="object"?"json":"string",value:U};await this.client.json.set(O,"$",T)}if(E.length>0){let $=`write_keys_zset:${Q}:${X}:${Y}`,L={};if(E.forEach((U,O)=>{L[U]=O}),await this.client.zAdd($,Object.entries(L).map(([U,O])=>({score:O,value:U}))),this.ttlConfig?.defaultTTL)await this.applyTTL(...E,$)}let H=`checkpoint:${Q}:${X}:shallow`;if(await this.client.exists(H)){let $=await this.client.json.get(H);if($)$.has_writes="true",await this.client.json.set(H,"$",$)}}async deleteThread(F){let G=`checkpoint:${F}:*:shallow`,J=await this.client.keys(G);if(J.length>0)await this.client.del(J);let Q=`checkpoint_write:${F}:*`,X=await this.client.keys(Q);if(X.length>0)await this.client.del(X);let Y=`write_keys_zset:${F}:*`,Z=await this.client.keys(Y);if(Z.length>0)await this.client.del(Z)}async end(){await this.client.quit()}addSearchableMetadataFields(F,G){if(!G)return;if("source"in G)F.source=G.source;if("step"in G)F.step=G.step;if("writes"in G)F.writes=typeof G.writes==="object"?JSON.stringify(G.writes):G.writes;if("score"in G)F.score=G.score}async createCheckpointTuple(F,G,J){let Q=await this.serde.loadsTyped("json",JSON.stringify(F.metadata));return{config:{configurable:{thread_id:F.thread_id,checkpoint_ns:F.checkpoint_ns,checkpoint_id:F.checkpoint_id}},checkpoint:G,metadata:Q,parentConfig:F.parent_checkpoint_id?{configurable:{thread_id:F.thread_id,checkpoint_ns:F.checkpoint_ns,checkpoint_id:F.parent_checkpoint_id}}:void 0,pendingWrites:J}}async applyTTL(...F){if(!this.ttlConfig?.defaultTTL)return;let G=Math.floor(this.ttlConfig.defaultTTL*60),J=await Promise.allSettled(F.map((Q)=>this.client.expire(Q,G)));for(let Q=0;Q<J.length;Q++)if(J[Q].status==="rejected")console.warn(`Failed to set TTL for key ${F[Q]}:`,J[Q].reason)}async loadPendingWrites(F,G,J){let Q=`write_keys_zset:${F}:${G}:${J}`,X=await this.client.zRange(Q,0,-1);if(X.length===0)return;let Y=[];for(let Z of X){let _=await this.client.json.get(Z);if(_){let E=await this.serde.loadsTyped("json",JSON.stringify(_.value));Y.push([_.task_id,_.channel,E])}}return Y}checkMetadataFilterMatch(F,G){for(let[J,Q]of Object.entries(G)){let X=F?.[J];if(Q===null){if(!(J in(F||{}))||X!==null)return!1}else if(typeof Q==="object"&&!Array.isArray(Q)){if(typeof X!=="object"||X===null)return!1;if(B(Q)!==B(X))return!1}else if(X!==Q)return!1}return!0}async cleanupOldCheckpoint(F,G,J){let Q=`checkpoint_write:${F}:${G}:${J}:*`,X=await this.client.keys(Q);if(X.length>0)await this.client.del(X);let Y=`write_keys_zset:${F}:${G}:${J}`;await this.client.del(Y);let Z=`checkpoint_blob:${F}:${G}:${J}:*`,_=await this.client.keys(Z);if(_.length>0)await this.client.del(_)}sanitizeMetadata(F){if(!F)return{};let G={};for(let[J,Q]of Object.entries(F)){let X=J.replace(/\x00/g,"");G[X]=typeof Q==="string"?Q.replace(/\x00/g,""):Q}return G}async ensureIndexes(){for(let F of P)try{await this.client.ft.create(F.index,F.schema,{ON:"JSON",PREFIX:F.prefix})}catch(G){if(!G.message?.includes("Index already exists"))console.error(`Failed to create index ${F.index}:`,G.message)}}};export{N as ShallowRedisSaver};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{lc as K0,mc as P,pc as R}from"./chunk-nr26055z.js";var C=P((j4,h0)=>{var g0=["nodebuffer","arraybuffer","fragments"],w0=typeof Blob<"u";if(w0)g0.push("blob");h0.exports={BINARY_TYPES:g0,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:w0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var n=P((Y4,X0)=>{var{EMPTY_BUFFER:l5}=C(),F0=Buffer[Symbol.species];function p5(J,K){if(J.length===0)return l5;if(J.length===1)return J[0];let X=Buffer.allocUnsafe(K),Z=0;for(let $=0;$<J.length;$++){let Q=J[$];X.set(Q,Z),Z+=Q.length}if(Z<K)return new F0(X.buffer,X.byteOffset,Z);return X}function m0(J,K,X,Z,$){for(let Q=0;Q<$;Q++)X[Z+Q]=J[Q]^K[Q&3]}function f0(J,K){for(let X=0;X<J.length;X++)J[X]^=K[X&3]}function b5(J){if(J.length===J.buffer.byteLength)return J.buffer;return J.buffer.slice(J.byteOffset,J.byteOffset+J.length)}function D0(J){if(D0.readOnly=!0,Buffer.isBuffer(J))return J;let K;if(J instanceof ArrayBuffer)K=new F0(J);else if(ArrayBuffer.isView(J))K=new F0(J.buffer,J.byteOffset,J.byteLength);else K=Buffer.from(J),D0.readOnly=!1;return K}X0.exports={concat:p5,mask:m0,toArrayBuffer:b5,toBuffer:D0,unmask:f0};if(!process.env.WS_NO_BUFFER_UTIL)try{let J=(()=>{throw new Error("Cannot require module "+"bufferutil");})();X0.exports.mask=function(K,X,Z,$,Q){if(Q<48)m0(K,X,Z,$,Q);else J.mask(K,X,Z,$,Q)},X0.exports.unmask=function(K,X){if(K.length<32)f0(K,X);else J.unmask(K,X)}}catch(J){}});var b0=P((V4,p0)=>{var u0=Symbol("kDone"),O0=Symbol("kRun");class l0{constructor(J){this[u0]=()=>{this.pending--,this[O0]()},this.concurrency=J||1/0,this.jobs=[],this.pending=0}add(J){this.jobs.push(J),this[O0]()}[O0](){if(this.pending===this.concurrency)return;if(this.jobs.length){let J=this.jobs.shift();this.pending++,J(this[u0])}}}p0.exports=l0});var a=P((_4,n0)=>{var r=R("zlib"),k0=n(),k5=b0(),{kStatusCode:i0}=C(),i5=Buffer[Symbol.species],d5=Buffer.from([0,0,255,255]),$0=Symbol("permessage-deflate"),q=Symbol("total-length"),f=Symbol("callback"),L=Symbol("buffers"),u=Symbol("error"),Z0;class d0{constructor(J,K,X){if(this._maxPayload=X|0,this._options=J||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!K,this._deflate=null,this._inflate=null,this.params=null,!Z0){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Z0=new k5(Z)}}static get extensionName(){return"permessage-deflate"}offer(){let J={};if(this._options.serverNoContextTakeover)J.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)J.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)J.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)J.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)J.client_max_window_bits=!0;return J}accept(J){return J=this.normalizeParams(J),this.params=this._isServer?this.acceptAsServer(J):this.acceptAsClient(J),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let J=this._deflate[f];if(this._deflate.close(),this._deflate=null,J)J(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(J){let K=this._options,X=J.find((Z)=>{if(K.serverNoContextTakeover===!1&&Z.server_no_context_takeover||Z.server_max_window_bits&&(K.serverMaxWindowBits===!1||typeof K.serverMaxWindowBits==="number"&&K.serverMaxWindowBits>Z.server_max_window_bits)||typeof K.clientMaxWindowBits==="number"&&!Z.client_max_window_bits)return!1;return!0});if(!X)throw Error("None of the extension offers can be accepted");if(K.serverNoContextTakeover)X.server_no_context_takeover=!0;if(K.clientNoContextTakeover)X.client_no_context_takeover=!0;if(typeof K.serverMaxWindowBits==="number")X.server_max_window_bits=K.serverMaxWindowBits;if(typeof K.clientMaxWindowBits==="number")X.client_max_window_bits=K.clientMaxWindowBits;else if(X.client_max_window_bits===!0||K.clientMaxWindowBits===!1)delete X.client_max_window_bits;return X}acceptAsClient(J){let K=J[0];if(this._options.clientNoContextTakeover===!1&&K.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!K.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")K.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&K.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return K}normalizeParams(J){return J.forEach((K)=>{Object.keys(K).forEach((X)=>{let Z=K[X];if(Z.length>1)throw Error(`Parameter "${X}" must have only a single value`);if(Z=Z[0],X==="client_max_window_bits"){if(Z!==!0){let $=+Z;if(!Number.isInteger($)||$<8||$>15)throw TypeError(`Invalid value for parameter "${X}": ${Z}`);Z=$}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${X}": ${Z}`)}else if(X==="server_max_window_bits"){let $=+Z;if(!Number.isInteger($)||$<8||$>15)throw TypeError(`Invalid value for parameter "${X}": ${Z}`);Z=$}else if(X==="client_no_context_takeover"||X==="server_no_context_takeover"){if(Z!==!0)throw TypeError(`Invalid value for parameter "${X}": ${Z}`)}else throw Error(`Unknown parameter "${X}"`);K[X]=Z})}),J}decompress(J,K,X){Z0.add((Z)=>{this._decompress(J,K,($,Q)=>{Z(),X($,Q)})})}compress(J,K,X){Z0.add((Z)=>{this._compress(J,K,($,Q)=>{Z(),X($,Q)})})}_decompress(J,K,X){let Z=this._isServer?"client":"server";if(!this._inflate){let $=`${Z}_max_window_bits`,Q=typeof this.params[$]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[$];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Q}),this._inflate[$0]=this,this._inflate[q]=0,this._inflate[L]=[],this._inflate.on("error",n5),this._inflate.on("data",c0)}if(this._inflate[f]=X,this._inflate.write(J),K)this._inflate.write(d5);this._inflate.flush(()=>{let $=this._inflate[u];if($){this._inflate.close(),this._inflate=null,X($);return}let Q=k0.concat(this._inflate[L],this._inflate[q]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[q]=0,this._inflate[L]=[],K&&this.params[`${Z}_no_context_takeover`])this._inflate.reset();X(null,Q)})}_compress(J,K,X){let Z=this._isServer?"server":"client";if(!this._deflate){let $=`${Z}_max_window_bits`,Q=typeof this.params[$]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[$];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Q}),this._deflate[q]=0,this._deflate[L]=[],this._deflate.on("data",c5)}this._deflate[f]=X,this._deflate.write(J),this._deflate.flush(r.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let $=k0.concat(this._deflate[L],this._deflate[q]);if(K)$=new i5($.buffer,$.byteOffset,$.length-4);if(this._deflate[f]=null,this._deflate[q]=0,this._deflate[L]=[],K&&this.params[`${Z}_no_context_takeover`])this._deflate.reset();X(null,$)})}}n0.exports=d0;function c5(J){this[L].push(J),this[q]+=J.length}function c0(J){if(this[q]+=J.length,this[$0]._maxPayload<1||this[q]<=this[$0]._maxPayload){this[L].push(J);return}this[u]=RangeError("Max payload size exceeded"),this[u].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[u][i0]=1009,this.removeListener("data",c0),this.reset()}function n5(J){if(this[$0]._inflate=null,this[u]){this[f](this[u]);return}J[i0]=1007,this[f](J)}});var l=P((N4,Q0)=>{var{isUtf8:r0}=R("buffer"),{hasBlob:r5}=C(),a5=[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 s5(J){return J>=1000&&J<=1014&&J!==1004&&J!==1005&&J!==1006||J>=3000&&J<=4999}function P0(J){let K=J.length,X=0;while(X<K)if((J[X]&128)===0)X++;else if((J[X]&224)===192){if(X+1===K||(J[X+1]&192)!==128||(J[X]&254)===192)return!1;X+=2}else if((J[X]&240)===224){if(X+2>=K||(J[X+1]&192)!==128||(J[X+2]&192)!==128||J[X]===224&&(J[X+1]&224)===128||J[X]===237&&(J[X+1]&224)===160)return!1;X+=3}else if((J[X]&248)===240){if(X+3>=K||(J[X+1]&192)!==128||(J[X+2]&192)!==128||(J[X+3]&192)!==128||J[X]===240&&(J[X+1]&240)===128||J[X]===244&&J[X+1]>143||J[X]>244)return!1;X+=4}else return!1;return!0}function o5(J){return r5&&typeof J==="object"&&typeof J.arrayBuffer==="function"&&typeof J.type==="string"&&typeof J.stream==="function"&&(J[Symbol.toStringTag]==="Blob"||J[Symbol.toStringTag]==="File")}Q0.exports={isBlob:o5,isValidStatusCode:s5,isValidUTF8:P0,tokenChars:a5};if(r0)Q0.exports.isValidUTF8=function(J){return J.length<24?P0(J):r0(J)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let J=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();Q0.exports.isValidUTF8=function(K){return K.length<32?P0(K):J(K)}}catch(J){}});var T0=P((H4,e0)=>{var{Writable:t5}=R("stream"),a0=a(),{BINARY_TYPES:e5,EMPTY_BUFFER:s0,kStatusCode:J1,kWebSocket:K1}=C(),{concat:M0,toArrayBuffer:X1,unmask:Z1}=n(),{isValidStatusCode:$1,isValidUTF8:o0}=l(),G0=Buffer[Symbol.species];class t0 extends t5{constructor(J={}){super();this._allowSynchronousEvents=J.allowSynchronousEvents!==void 0?J.allowSynchronousEvents:!0,this._binaryType=J.binaryType||e5[0],this._extensions=J.extensions||{},this._isServer=!!J.isServer,this._maxPayload=J.maxPayload|0,this._skipUTF8Validation=!!J.skipUTF8Validation,this[K1]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(J,K,X){if(this._opcode===8&&this._state==0)return X();this._bufferedBytes+=J.length,this._buffers.push(J),this.startLoop(X)}consume(J){if(this._bufferedBytes-=J,J===this._buffers[0].length)return this._buffers.shift();if(J<this._buffers[0].length){let X=this._buffers[0];return this._buffers[0]=new G0(X.buffer,X.byteOffset+J,X.length-J),new G0(X.buffer,X.byteOffset,J)}let K=Buffer.allocUnsafe(J);do{let X=this._buffers[0],Z=K.length-J;if(J>=X.length)K.set(this._buffers.shift(),Z);else K.set(new Uint8Array(X.buffer,X.byteOffset,J),Z),this._buffers[0]=new G0(X.buffer,X.byteOffset+J,X.length-J);J-=X.length}while(J>0);return K}startLoop(J){this._loop=!0;do switch(this._state){case 0:this.getInfo(J);break;case 1:this.getPayloadLength16(J);break;case 2:this.getPayloadLength64(J);break;case 3:this.getMask();break;case 4:this.getData(J);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)J()}getInfo(J){if(this._bufferedBytes<2){this._loop=!1;return}let K=this.consume(2);if((K[0]&48)!==0){let Z=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");J(Z);return}let X=(K[0]&64)===64;if(X&&!this._extensions[a0.extensionName]){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(this._fin=(K[0]&128)===128,this._opcode=K[0]&15,this._payloadLength=K[1]&127,this._opcode===0){if(X){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(!this._fragmented){let Z=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}this._compressed=X}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Z=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");J(Z);return}if(X){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Z=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");J(Z);return}}else{let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(K[1]&128)===128,this._isServer){if(!this._masked){let Z=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");J(Z);return}}else if(this._masked){let Z=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");J(Z);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(J)}getPayloadLength16(J){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(J)}getPayloadLength64(J){if(this._bufferedBytes<8){this._loop=!1;return}let K=this.consume(8),X=K.readUInt32BE(0);if(X>Math.pow(2,21)-1){let Z=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");J(Z);return}this._payloadLength=X*Math.pow(2,32)+K.readUInt32BE(4),this.haveLength(J)}haveLength(J){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let K=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");J(K);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(J){let K=s0;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(K=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)Z1(K,this._mask)}if(this._opcode>7){this.controlMessage(K,J);return}if(this._compressed){this._state=5,this.decompress(K,J);return}if(K.length)this._messageLength=this._totalPayloadLength,this._fragments.push(K);this.dataMessage(J)}decompress(J,K){this._extensions[a0.extensionName].decompress(J,this._fin,(Z,$)=>{if(Z)return K(Z);if($.length){if(this._messageLength+=$.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Q=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");K(Q);return}this._fragments.push($)}if(this.dataMessage(K),this._state===0)this.startLoop(K)})}dataMessage(J){if(!this._fin){this._state=0;return}let K=this._messageLength,X=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Z;if(this._binaryType==="nodebuffer")Z=M0(X,K);else if(this._binaryType==="arraybuffer")Z=X1(M0(X,K));else if(this._binaryType==="blob")Z=new Blob(X);else Z=X;if(this._allowSynchronousEvents)this.emit("message",Z,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!0),this._state=0,this.startLoop(J)})}else{let Z=M0(X,K);if(!this._skipUTF8Validation&&!o0(Z)){let $=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");J($);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Z,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!1),this._state=0,this.startLoop(J)})}}controlMessage(J,K){if(this._opcode===8){if(J.length===0)this._loop=!1,this.emit("conclude",1005,s0),this.end();else{let X=J.readUInt16BE(0);if(!$1(X)){let $=this.createError(RangeError,`invalid status code ${X}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");K($);return}let Z=new G0(J.buffer,J.byteOffset+2,J.length-2);if(!this._skipUTF8Validation&&!o0(Z)){let $=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");K($);return}this._loop=!1,this.emit("conclude",X,Z),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",J),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",J),this._state=0,this.startLoop(K)})}createError(J,K,X,Z,$){this._loop=!1,this._errored=!0;let Q=new J(X?`Invalid WebSocket frame: ${K}`:K);return Error.captureStackTrace(Q,this.createError),Q.code=$,Q[J1]=Z,Q}}e0.exports=t0});var B0=P((A4,X5)=>{var{Duplex:R4}=R("stream"),{randomFillSync:Q1}=R("crypto"),J5=a(),{EMPTY_BUFFER:G1,kWebSocket:I1,NOOP:z1}=C(),{isBlob:p,isValidStatusCode:j1}=l(),{mask:K5,toBuffer:S}=n(),T=Symbol("kByteLength"),Y1=Buffer.alloc(4),v,b=8192,x=0,V1=1,_1=2;class W{constructor(J,K,X){if(this._extensions=K||{},X)this._generateMask=X,this._maskBuffer=Buffer.alloc(4);this._socket=J,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=x,this.onerror=z1,this[I1]=void 0}static frame(J,K){let X,Z=!1,$=2,Q=!1;if(K.mask){if(X=K.maskBuffer||Y1,K.generateMask)K.generateMask(X);else{if(b===8192){if(v===void 0)v=Buffer.alloc(8192);Q1(v,0,8192),b=0}X[0]=v[b++],X[1]=v[b++],X[2]=v[b++],X[3]=v[b++]}Q=(X[0]|X[1]|X[2]|X[3])===0,$=6}let G;if(typeof J==="string")if((!K.mask||Q)&&K[T]!==void 0)G=K[T];else J=Buffer.from(J),G=J.length;else G=J.length,Z=K.mask&&K.readOnly&&!Q;let z=G;if(G>=65536)$+=8,z=127;else if(G>125)$+=2,z=126;let I=Buffer.allocUnsafe(Z?G+$:$);if(I[0]=K.fin?K.opcode|128:K.opcode,K.rsv1)I[0]|=64;if(I[1]=z,z===126)I.writeUInt16BE(G,2);else if(z===127)I[2]=I[3]=0,I.writeUIntBE(G,4,6);if(!K.mask)return[I,J];if(I[1]|=128,I[$-4]=X[0],I[$-3]=X[1],I[$-2]=X[2],I[$-1]=X[3],Q)return[I,J];if(Z)return K5(J,X,I,$,G),[I];return K5(J,X,J,0,G),[I,J]}close(J,K,X,Z){let $;if(J===void 0)$=G1;else if(typeof J!=="number"||!j1(J))throw TypeError("First argument must be a valid error code number");else if(K===void 0||!K.length)$=Buffer.allocUnsafe(2),$.writeUInt16BE(J,0);else{let G=Buffer.byteLength(K);if(G>123)throw RangeError("The message must not be greater than 123 bytes");if($=Buffer.allocUnsafe(2+G),$.writeUInt16BE(J,0),typeof K==="string")$.write(K,2);else $.set(K,2)}let Q={[T]:$.length,fin:!0,generateMask:this._generateMask,mask:X,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==x)this.enqueue([this.dispatch,$,!1,Q,Z]);else this.sendFrame(W.frame($,Q),Z)}ping(J,K,X){let Z,$;if(typeof J==="string")Z=Buffer.byteLength(J),$=!1;else if(p(J))Z=J.size,$=!1;else J=S(J),Z=J.length,$=S.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[T]:Z,fin:!0,generateMask:this._generateMask,mask:K,maskBuffer:this._maskBuffer,opcode:9,readOnly:$,rsv1:!1};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,!1,Q,X]);else this.getBlobData(J,!1,Q,X);else if(this._state!==x)this.enqueue([this.dispatch,J,!1,Q,X]);else this.sendFrame(W.frame(J,Q),X)}pong(J,K,X){let Z,$;if(typeof J==="string")Z=Buffer.byteLength(J),$=!1;else if(p(J))Z=J.size,$=!1;else J=S(J),Z=J.length,$=S.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[T]:Z,fin:!0,generateMask:this._generateMask,mask:K,maskBuffer:this._maskBuffer,opcode:10,readOnly:$,rsv1:!1};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,!1,Q,X]);else this.getBlobData(J,!1,Q,X);else if(this._state!==x)this.enqueue([this.dispatch,J,!1,Q,X]);else this.sendFrame(W.frame(J,Q),X)}send(J,K,X){let Z=this._extensions[J5.extensionName],$=K.binary?2:1,Q=K.compress,G,z;if(typeof J==="string")G=Buffer.byteLength(J),z=!1;else if(p(J))G=J.size,z=!1;else J=S(J),G=J.length,z=S.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Q&&Z&&Z.params[Z._isServer?"server_no_context_takeover":"client_no_context_takeover"])Q=G>=Z._threshold;this._compress=Q}else Q=!1,$=0;if(K.fin)this._firstFragment=!0;let I={[T]:G,fin:K.fin,generateMask:this._generateMask,mask:K.mask,maskBuffer:this._maskBuffer,opcode:$,readOnly:z,rsv1:Q};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,this._compress,I,X]);else this.getBlobData(J,this._compress,I,X);else if(this._state!==x)this.enqueue([this.dispatch,J,this._compress,I,X]);else this.dispatch(J,this._compress,I,X)}getBlobData(J,K,X,Z){this._bufferedBytes+=X[T],this._state=_1,J.arrayBuffer().then(($)=>{if(this._socket.destroyed){let G=Error("The socket was closed while the blob was being read");process.nextTick(x0,this,G,Z);return}this._bufferedBytes-=X[T];let Q=S($);if(!K)this._state=x,this.sendFrame(W.frame(Q,X),Z),this.dequeue();else this.dispatch(Q,K,X,Z)}).catch(($)=>{process.nextTick(N1,this,$,Z)})}dispatch(J,K,X,Z){if(!K){this.sendFrame(W.frame(J,X),Z);return}let $=this._extensions[J5.extensionName];this._bufferedBytes+=X[T],this._state=V1,$.compress(J,X.fin,(Q,G)=>{if(this._socket.destroyed){let z=Error("The socket was closed while data was being compressed");x0(this,z,Z);return}this._bufferedBytes-=X[T],this._state=x,X.readOnly=!1,this.sendFrame(W.frame(G,X),Z),this.dequeue()})}dequeue(){while(this._state===x&&this._queue.length){let J=this._queue.shift();this._bufferedBytes-=J[3][T],Reflect.apply(J[0],this,J.slice(1))}}enqueue(J){this._bufferedBytes+=J[3][T],this._queue.push(J)}sendFrame(J,K){if(J.length===2)this._socket.cork(),this._socket.write(J[0]),this._socket.write(J[1],K),this._socket.uncork();else this._socket.write(J[0],K)}}X5.exports=W;function x0(J,K,X){if(typeof X==="function")X(K);for(let Z=0;Z<J._queue.length;Z++){let $=J._queue[Z],Q=$[$.length-1];if(typeof Q==="function")Q(K)}}function N1(J,K,X){x0(J,K,X),J.onerror(K)}});var V5=P((F4,Y5)=>{var{kForOnEventAttribute:s,kListener:C0}=C(),Z5=Symbol("kCode"),$5=Symbol("kData"),Q5=Symbol("kError"),G5=Symbol("kMessage"),I5=Symbol("kReason"),k=Symbol("kTarget"),z5=Symbol("kType"),j5=Symbol("kWasClean");class E{constructor(J){this[k]=null,this[z5]=J}get target(){return this[k]}get type(){return this[z5]}}Object.defineProperty(E.prototype,"target",{enumerable:!0});Object.defineProperty(E.prototype,"type",{enumerable:!0});class i extends E{constructor(J,K={}){super(J);this[Z5]=K.code===void 0?0:K.code,this[I5]=K.reason===void 0?"":K.reason,this[j5]=K.wasClean===void 0?!1:K.wasClean}get code(){return this[Z5]}get reason(){return this[I5]}get wasClean(){return this[j5]}}Object.defineProperty(i.prototype,"code",{enumerable:!0});Object.defineProperty(i.prototype,"reason",{enumerable:!0});Object.defineProperty(i.prototype,"wasClean",{enumerable:!0});class o extends E{constructor(J,K={}){super(J);this[Q5]=K.error===void 0?null:K.error,this[G5]=K.message===void 0?"":K.message}get error(){return this[Q5]}get message(){return this[G5]}}Object.defineProperty(o.prototype,"error",{enumerable:!0});Object.defineProperty(o.prototype,"message",{enumerable:!0});class z0 extends E{constructor(J,K={}){super(J);this[$5]=K.data===void 0?null:K.data}get data(){return this[$5]}}Object.defineProperty(z0.prototype,"data",{enumerable:!0});var H1={addEventListener(J,K,X={}){for(let $ of this.listeners(J))if(!X[s]&&$[C0]===K&&!$[s])return;let Z;if(J==="message")Z=function(Q,G){let z=new z0("message",{data:G?Q:Q.toString()});z[k]=this,I0(K,this,z)};else if(J==="close")Z=function(Q,G){let z=new i("close",{code:Q,reason:G.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});z[k]=this,I0(K,this,z)};else if(J==="error")Z=function(Q){let G=new o("error",{error:Q,message:Q.message});G[k]=this,I0(K,this,G)};else if(J==="open")Z=function(){let Q=new E("open");Q[k]=this,I0(K,this,Q)};else return;if(Z[s]=!!X[s],Z[C0]=K,X.once)this.once(J,Z);else this.on(J,Z)},removeEventListener(J,K){for(let X of this.listeners(J))if(X[C0]===K&&!X[s]){this.removeListener(J,X);break}}};Y5.exports={CloseEvent:i,ErrorEvent:o,Event:E,EventTarget:H1,MessageEvent:z0};function I0(J,K,X){if(typeof J==="object"&&J.handleEvent)J.handleEvent.call(J,X);else J.call(K,X)}});var q0=P((D4,_5)=>{var{tokenChars:t}=l();function B(J,K,X){if(J[K]===void 0)J[K]=[X];else J[K].push(X)}function R1(J){let K=Object.create(null),X=Object.create(null),Z=!1,$=!1,Q=!1,G,z,I=-1,V=-1,_=-1,Y=0;for(;Y<J.length;Y++)if(V=J.charCodeAt(Y),G===void 0)if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(Y!==0&&(V===32||V===9)){if(_===-1&&I!==-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;let D=J.slice(I,_);if(V===44)B(K,D,X),X=Object.create(null);else G=D;I=_=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);else if(z===void 0)if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(V===32||V===9){if(_===-1&&I!==-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;if(B(X,J.slice(I,_),!0),V===44)B(K,G,X),X=Object.create(null),G=void 0;I=_=-1}else if(V===61&&I!==-1&&_===-1)z=J.slice(I,Y),I=_=-1;else throw SyntaxError(`Unexpected character at index ${Y}`);else if($){if(t[V]!==1)throw SyntaxError(`Unexpected character at index ${Y}`);if(I===-1)I=Y;else if(!Z)Z=!0;$=!1}else if(Q)if(t[V]===1){if(I===-1)I=Y}else if(V===34&&I!==-1)Q=!1,_=Y;else if(V===92)$=!0;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(V===34&&J.charCodeAt(Y-1)===61)Q=!0;else if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(I!==-1&&(V===32||V===9)){if(_===-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;let D=J.slice(I,_);if(Z)D=D.replace(/\\/g,""),Z=!1;if(B(X,z,D),V===44)B(K,G,X),X=Object.create(null),G=void 0;z=void 0,I=_=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);if(I===-1||Q||V===32||V===9)throw SyntaxError("Unexpected end of input");if(_===-1)_=Y;let F=J.slice(I,_);if(G===void 0)B(K,F,X);else{if(z===void 0)B(X,F,!0);else if(Z)B(X,z,F.replace(/\\/g,""));else B(X,z,F);B(K,G,X)}return K}function A1(J){return Object.keys(J).map((K)=>{let X=J[K];if(!Array.isArray(X))X=[X];return X.map((Z)=>{return[K].concat(Object.keys(Z).map(($)=>{let Q=Z[$];if(!Array.isArray(Q))Q=[Q];return Q.map((G)=>G===!0?$:`${$}=${G}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}_5.exports={format:A1,parse:R1}});var _0=P((M4,B5)=>{var F1=R("events"),D1=R("https"),O1=R("http"),R5=R("net"),P1=R("tls"),{randomBytes:M1,createHash:T1}=R("crypto"),{Duplex:O4,Readable:P4}=R("stream"),{URL:U0}=R("url"),y=a(),x1=T0(),B1=B0(),{isBlob:C1}=l(),{BINARY_TYPES:N5,CLOSE_TIMEOUT:q1,EMPTY_BUFFER:j0,GUID:U1,kForOnEventAttribute:L0,kListener:L1,kStatusCode:W1,kWebSocket:A,NOOP:A5}=C(),{EventTarget:{addEventListener:E1,removeEventListener:y1}}=V5(),{format:S1,parse:v1}=q0(),{toBuffer:g1}=n(),F5=Symbol("kAborted"),W0=[8,13],U=["CONNECTING","OPEN","CLOSING","CLOSED"],w1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class j extends F1{constructor(J,K,X){super();if(this._binaryType=N5[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=j0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=j.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,J!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,K===void 0)K=[];else if(!Array.isArray(K))if(typeof K==="object"&&K!==null)X=K,K=[];else K=[K];D5(this,J,K,X)}else this._autoPong=X.autoPong,this._closeTimeout=X.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(J){if(!N5.includes(J))return;if(this._binaryType=J,this._receiver)this._receiver._binaryType=J}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(J,K,X){let Z=new x1({allowSynchronousEvents:X.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation}),$=new B1(J,this._extensions,X.generateMask);if(this._receiver=Z,this._sender=$,this._socket=J,Z[A]=this,$[A]=this,J[A]=this,Z.on("conclude",f1),Z.on("drain",u1),Z.on("error",l1),Z.on("message",p1),Z.on("ping",b1),Z.on("pong",k1),$.onerror=i1,J.setTimeout)J.setTimeout(0);if(J.setNoDelay)J.setNoDelay();if(K.length>0)J.unshift(K);J.on("close",M5),J.on("data",V0),J.on("end",T5),J.on("error",x5),this._readyState=j.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=j.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[y.extensionName])this._extensions[y.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=j.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(J,K){if(this.readyState===j.CLOSED)return;if(this.readyState===j.CONNECTING){M(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===j.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=j.CLOSING,this._sender.close(J,K,!this._isServer,(X)=>{if(X)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),P5(this)}pause(){if(this.readyState===j.CONNECTING||this.readyState===j.CLOSED)return;this._paused=!0,this._socket.pause()}ping(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")X=J,J=K=void 0;else if(typeof K==="function")X=K,K=void 0;if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}if(K===void 0)K=!this._isServer;this._sender.ping(J||j0,K,X)}pong(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")X=J,J=K=void 0;else if(typeof K==="function")X=K,K=void 0;if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}if(K===void 0)K=!this._isServer;this._sender.pong(J||j0,K,X)}resume(){if(this.readyState===j.CONNECTING||this.readyState===j.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof K==="function")X=K,K={};if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}let Z={binary:typeof J!=="string",mask:!this._isServer,compress:!0,fin:!0,...K};if(!this._extensions[y.extensionName])Z.compress=!1;this._sender.send(J||j0,Z,X)}terminate(){if(this.readyState===j.CLOSED)return;if(this.readyState===j.CONNECTING){M(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=j.CLOSING,this._socket.destroy()}}Object.defineProperty(j,"CONNECTING",{enumerable:!0,value:U.indexOf("CONNECTING")});Object.defineProperty(j.prototype,"CONNECTING",{enumerable:!0,value:U.indexOf("CONNECTING")});Object.defineProperty(j,"OPEN",{enumerable:!0,value:U.indexOf("OPEN")});Object.defineProperty(j.prototype,"OPEN",{enumerable:!0,value:U.indexOf("OPEN")});Object.defineProperty(j,"CLOSING",{enumerable:!0,value:U.indexOf("CLOSING")});Object.defineProperty(j.prototype,"CLOSING",{enumerable:!0,value:U.indexOf("CLOSING")});Object.defineProperty(j,"CLOSED",{enumerable:!0,value:U.indexOf("CLOSED")});Object.defineProperty(j.prototype,"CLOSED",{enumerable:!0,value:U.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((J)=>{Object.defineProperty(j.prototype,J,{enumerable:!0})});["open","error","close","message"].forEach((J)=>{Object.defineProperty(j.prototype,`on${J}`,{enumerable:!0,get(){for(let K of this.listeners(J))if(K[L0])return K[L1];return null},set(K){for(let X of this.listeners(J))if(X[L0]){this.removeListener(J,X);break}if(typeof K!=="function")return;this.addEventListener(J,K,{[L0]:!0})}})});j.prototype.addEventListener=E1;j.prototype.removeEventListener=y1;B5.exports=j;function D5(J,K,X,Z){let $={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:q1,protocolVersion:W0[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Z,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(J._autoPong=$.autoPong,J._closeTimeout=$.closeTimeout,!W0.includes($.protocolVersion))throw RangeError(`Unsupported protocol version: ${$.protocolVersion} (supported versions: ${W0.join(", ")})`);let Q;if(K instanceof U0)Q=K;else try{Q=new U0(K)}catch(N){throw SyntaxError(`Invalid URL: ${K}`)}if(Q.protocol==="http:")Q.protocol="ws:";else if(Q.protocol==="https:")Q.protocol="wss:";J._url=Q.href;let G=Q.protocol==="wss:",z=Q.protocol==="ws+unix:",I;if(Q.protocol!=="ws:"&&!G&&!z)I=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(z&&!Q.pathname)I="The URL's pathname is empty";else if(Q.hash)I="The URL contains a fragment identifier";if(I){let N=SyntaxError(I);if(J._redirects===0)throw N;else{Y0(J,N);return}}let V=G?443:80,_=M1(16).toString("base64"),Y=G?D1.request:O1.request,F=new Set,D;if($.createConnection=$.createConnection||(G?m1:h1),$.defaultPort=$.defaultPort||V,$.port=Q.port||V,$.host=Q.hostname.startsWith("[")?Q.hostname.slice(1,-1):Q.hostname,$.headers={...$.headers,"Sec-WebSocket-Version":$.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},$.path=Q.pathname+Q.search,$.timeout=$.handshakeTimeout,$.perMessageDeflate)D=new y($.perMessageDeflate!==!0?$.perMessageDeflate:{},!1,$.maxPayload),$.headers["Sec-WebSocket-Extensions"]=S1({[y.extensionName]:D.offer()});if(X.length){for(let N of X){if(typeof N!=="string"||!w1.test(N)||F.has(N))throw SyntaxError("An invalid or duplicated subprotocol was specified");F.add(N)}$.headers["Sec-WebSocket-Protocol"]=X.join(",")}if($.origin)if($.protocolVersion<13)$.headers["Sec-WebSocket-Origin"]=$.origin;else $.headers.Origin=$.origin;if(Q.username||Q.password)$.auth=`${Q.username}:${Q.password}`;if(z){let N=$.path.split(":");$.socketPath=N[0],$.path=N[1]}let H;if($.followRedirects){if(J._redirects===0){J._originalIpc=z,J._originalSecure=G,J._originalHostOrSocketPath=z?$.socketPath:Q.host;let N=Z&&Z.headers;if(Z={...Z,headers:{}},N)for(let[O,h]of Object.entries(N))Z.headers[O.toLowerCase()]=h}else if(J.listenerCount("redirect")===0){let N=z?J._originalIpc?$.socketPath===J._originalHostOrSocketPath:!1:J._originalIpc?!1:Q.host===J._originalHostOrSocketPath;if(!N||J._originalSecure&&!G){if(delete $.headers.authorization,delete $.headers.cookie,!N)delete $.headers.host;$.auth=void 0}}if($.auth&&!Z.headers.authorization)Z.headers.authorization="Basic "+Buffer.from($.auth).toString("base64");if(H=J._req=Y($),J._redirects)J.emit("redirect",J.url,H)}else H=J._req=Y($);if($.timeout)H.on("timeout",()=>{M(J,H,"Opening handshake has timed out")});if(H.on("error",(N)=>{if(H===null||H[F5])return;H=J._req=null,Y0(J,N)}),H.on("response",(N)=>{let O=N.headers.location,h=N.statusCode;if(O&&$.followRedirects&&h>=300&&h<400){if(++J._redirects>$.maxRedirects){M(J,H,"Maximum redirects exceeded");return}H.abort();let d;try{d=new U0(O,K)}catch(y0){let m=SyntaxError(`Invalid URL: ${O}`);Y0(J,m);return}D5(J,d,X,Z)}else if(!J.emit("unexpected-response",H,N))M(J,H,`Unexpected server response: ${N.statusCode}`)}),H.on("upgrade",(N,O,h)=>{if(J.emit("upgrade",N),J.readyState!==j.CONNECTING)return;H=J._req=null;let d=N.headers.upgrade;if(d===void 0||d.toLowerCase()!=="websocket"){M(J,O,"Invalid Upgrade header");return}let y0=T1("sha1").update(_+U1).digest("base64");if(N.headers["sec-websocket-accept"]!==y0){M(J,O,"Invalid Sec-WebSocket-Accept header");return}let m=N.headers["sec-websocket-protocol"],c;if(m!==void 0){if(!F.size)c="Server sent a subprotocol but none was requested";else if(!F.has(m))c="Server sent an invalid subprotocol"}else if(F.size)c="Server sent no subprotocol";if(c){M(J,O,c);return}if(m)J._protocol=m;let S0=N.headers["sec-websocket-extensions"];if(S0!==void 0){if(!D){M(J,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R0;try{R0=v1(S0)}catch(A0){M(J,O,"Invalid Sec-WebSocket-Extensions header");return}let v0=Object.keys(R0);if(v0.length!==1||v0[0]!==y.extensionName){M(J,O,"Server indicated an extension that was not requested");return}try{D.accept(R0[y.extensionName])}catch(A0){M(J,O,"Invalid Sec-WebSocket-Extensions header");return}J._extensions[y.extensionName]=D}J.setSocket(O,h,{allowSynchronousEvents:$.allowSynchronousEvents,generateMask:$.generateMask,maxPayload:$.maxPayload,skipUTF8Validation:$.skipUTF8Validation})}),$.finishRequest)$.finishRequest(H,J);else H.end()}function Y0(J,K){J._readyState=j.CLOSING,J._errorEmitted=!0,J.emit("error",K),J.emitClose()}function h1(J){return J.path=J.socketPath,R5.connect(J)}function m1(J){if(J.path=void 0,!J.servername&&J.servername!=="")J.servername=R5.isIP(J.host)?"":J.host;return P1.connect(J)}function M(J,K,X){J._readyState=j.CLOSING;let Z=Error(X);if(Error.captureStackTrace(Z,M),K.setHeader){if(K[F5]=!0,K.abort(),K.socket&&!K.socket.destroyed)K.socket.destroy();process.nextTick(Y0,J,Z)}else K.destroy(Z),K.once("error",J.emit.bind(J,"error")),K.once("close",J.emitClose.bind(J))}function E0(J,K,X){if(K){let Z=C1(K)?K.size:g1(K).length;if(J._socket)J._sender._bufferedBytes+=Z;else J._bufferedAmount+=Z}if(X){let Z=Error(`WebSocket is not open: readyState ${J.readyState} (${U[J.readyState]})`);process.nextTick(X,Z)}}function f1(J,K){let X=this[A];if(X._closeFrameReceived=!0,X._closeMessage=K,X._closeCode=J,X._socket[A]===void 0)return;if(X._socket.removeListener("data",V0),process.nextTick(O5,X._socket),J===1005)X.close();else X.close(J,K)}function u1(){let J=this[A];if(!J.isPaused)J._socket.resume()}function l1(J){let K=this[A];if(K._socket[A]!==void 0)K._socket.removeListener("data",V0),process.nextTick(O5,K._socket),K.close(J[W1]);if(!K._errorEmitted)K._errorEmitted=!0,K.emit("error",J)}function H5(){this[A].emitClose()}function p1(J,K){this[A].emit("message",J,K)}function b1(J){let K=this[A];if(K._autoPong)K.pong(J,!this._isServer,A5);K.emit("ping",J)}function k1(J){this[A].emit("pong",J)}function O5(J){J.resume()}function i1(J){let K=this[A];if(K.readyState===j.CLOSED)return;if(K.readyState===j.OPEN)K._readyState=j.CLOSING,P5(K);if(this._socket.end(),!K._errorEmitted)K._errorEmitted=!0,K.emit("error",J)}function P5(J){J._closeTimer=setTimeout(J._socket.destroy.bind(J._socket),J._closeTimeout)}function M5(){let J=this[A];if(this.removeListener("close",M5),this.removeListener("data",V0),this.removeListener("end",T5),J._readyState=j.CLOSING,!this._readableState.endEmitted&&!J._closeFrameReceived&&!J._receiver._writableState.errorEmitted&&this._readableState.length!==0){let K=this.read(this._readableState.length);J._receiver.write(K)}if(J._receiver.end(),this[A]=void 0,clearTimeout(J._closeTimer),J._receiver._writableState.finished||J._receiver._writableState.errorEmitted)J.emitClose();else J._receiver.on("error",H5),J._receiver.on("finish",H5)}function V0(J){if(!this[A]._receiver.write(J))this.pause()}function T5(){let J=this[A];J._readyState=j.CLOSING,J._receiver.end(),this.end()}function x5(){let J=this[A];if(this.removeListener("error",x5),this.on("error",A5),J)J._readyState=j.CLOSING,this.destroy()}});var L5=P((x4,U5)=>{var T4=_0(),{Duplex:d1}=R("stream");function C5(J){J.emit("close")}function c1(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function q5(J){if(this.removeListener("error",q5),this.destroy(),this.listenerCount("error")===0)this.emit("error",J)}function n1(J,K){let X=!0,Z=new d1({...K,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return J.on("message",function(Q,G){let z=!G&&Z._readableState.objectMode?Q.toString():Q;if(!Z.push(z))J.pause()}),J.once("error",function(Q){if(Z.destroyed)return;X=!1,Z.destroy(Q)}),J.once("close",function(){if(Z.destroyed)return;Z.push(null)}),Z._destroy=function($,Q){if(J.readyState===J.CLOSED){Q($),process.nextTick(C5,Z);return}let G=!1;if(J.once("error",function(I){G=!0,Q(I)}),J.once("close",function(){if(!G)Q($);process.nextTick(C5,Z)}),X)J.terminate()},Z._final=function($){if(J.readyState===J.CONNECTING){J.once("open",function(){Z._final($)});return}if(J._socket===null)return;if(J._socket._writableState.finished){if($(),Z._readableState.endEmitted)Z.destroy()}else J._socket.once("finish",function(){$()}),J.close()},Z._read=function(){if(J.isPaused)J.resume()},Z._write=function($,Q,G){if(J.readyState===J.CONNECTING){J.once("open",function(){Z._write($,Q,G)});return}J.send($,G)},Z.on("end",c1),Z.on("error",q5),Z}U5.exports=n1});var E5=P((B4,W5)=>{var{tokenChars:r1}=l();function a1(J){let K=new Set,X=-1,Z=-1,$=0;for($;$<J.length;$++){let G=J.charCodeAt($);if(Z===-1&&r1[G]===1){if(X===-1)X=$}else if($!==0&&(G===32||G===9)){if(Z===-1&&X!==-1)Z=$}else if(G===44){if(X===-1)throw SyntaxError(`Unexpected character at index ${$}`);if(Z===-1)Z=$;let z=J.slice(X,Z);if(K.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);K.add(z),X=Z=-1}else throw SyntaxError(`Unexpected character at index ${$}`)}if(X===-1||Z!==-1)throw SyntaxError("Unexpected end of input");let Q=J.slice(X,$);if(K.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);return K.add(Q),K}W5.exports={parse:a1}});var w5=P((q4,g5)=>{var s1=R("events"),N0=R("http"),{Duplex:C4}=R("stream"),{createHash:o1}=R("crypto"),y5=q0(),g=a(),t1=E5(),e1=_0(),{CLOSE_TIMEOUT:J4,GUID:K4,kWebSocket:X4}=C(),Z4=/^[+/0-9A-Za-z]{22}==$/;class v5 extends s1{constructor(J,K){super();if(J={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:J4,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:e1,...J},J.port==null&&!J.server&&!J.noServer||J.port!=null&&(J.server||J.noServer)||J.server&&J.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(J.port!=null)this._server=N0.createServer((X,Z)=>{let $=N0.STATUS_CODES[426];Z.writeHead(426,{"Content-Length":$.length,"Content-Type":"text/plain"}),Z.end($)}),this._server.listen(J.port,J.host,J.backlog,K);else if(J.server)this._server=J.server;if(this._server){let X=this.emit.bind(this,"connection");this._removeListeners=$4(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Z,$,Q)=>{this.handleUpgrade(Z,$,Q,X)}})}if(J.perMessageDeflate===!0)J.perMessageDeflate={};if(J.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=J,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(J){if(this._state===2){if(J)this.once("close",()=>{J(Error("The server is not running"))});process.nextTick(e,this);return}if(J)this.once("close",J);if(this._state===1)return;if(this._state=1,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(e,this);else this._shouldEmitClose=!0;else process.nextTick(e,this)}else{let K=this._server;this._removeListeners(),this._removeListeners=this._server=null,K.close(()=>{e(this)})}}shouldHandle(J){if(this.options.path){let K=J.url.indexOf("?");if((K!==-1?J.url.slice(0,K):J.url)!==this.options.path)return!1}return!0}handleUpgrade(J,K,X,Z){K.on("error",S5);let $=J.headers["sec-websocket-key"],Q=J.headers.upgrade,G=+J.headers["sec-websocket-version"];if(J.method!=="GET"){w(this,J,K,405,"Invalid HTTP method");return}if(Q===void 0||Q.toLowerCase()!=="websocket"){w(this,J,K,400,"Invalid Upgrade header");return}if($===void 0||!Z4.test($)){w(this,J,K,400,"Missing or invalid Sec-WebSocket-Key header");return}if(G!==13&&G!==8){w(this,J,K,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(J)){J0(K,400);return}let z=J.headers["sec-websocket-protocol"],I=new Set;if(z!==void 0)try{I=t1.parse(z)}catch(Y){w(this,J,K,400,"Invalid Sec-WebSocket-Protocol header");return}let V=J.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&V!==void 0){let Y=new g(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let F=y5.parse(V);if(F[g.extensionName])Y.accept(F[g.extensionName]),_[g.extensionName]=Y}catch(F){w(this,J,K,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Y={origin:J.headers[`${G===8?"sec-websocket-origin":"origin"}`],secure:!!(J.socket.authorized||J.socket.encrypted),req:J};if(this.options.verifyClient.length===2){this.options.verifyClient(Y,(F,D,H,N)=>{if(!F)return J0(K,D||401,H,N);this.completeUpgrade(_,$,I,J,K,X,Z)});return}if(!this.options.verifyClient(Y))return J0(K,401)}this.completeUpgrade(_,$,I,J,K,X,Z)}completeUpgrade(J,K,X,Z,$,Q,G){if(!$.readable||!$.writable)return $.destroy();if($[X4])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return J0($,503);let I=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${o1("sha1").update(K+K4).digest("base64")}`],V=new this.options.WebSocket(null,void 0,this.options);if(X.size){let _=this.options.handleProtocols?this.options.handleProtocols(X,Z):X.values().next().value;if(_)I.push(`Sec-WebSocket-Protocol: ${_}`),V._protocol=_}if(J[g.extensionName]){let _=J[g.extensionName].params,Y=y5.format({[g.extensionName]:[_]});I.push(`Sec-WebSocket-Extensions: ${Y}`),V._extensions=J}if(this.emit("headers",I,Z),$.write(I.concat(`\r
|
|
1
|
+
import{ub as K0,vb as P,yb as R}from"./chunk-kba8akjs.js";var C=P((j4,h0)=>{var g0=["nodebuffer","arraybuffer","fragments"],w0=typeof Blob<"u";if(w0)g0.push("blob");h0.exports={BINARY_TYPES:g0,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:w0,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var n=P((Y4,X0)=>{var{EMPTY_BUFFER:l5}=C(),F0=Buffer[Symbol.species];function p5(J,K){if(J.length===0)return l5;if(J.length===1)return J[0];let X=Buffer.allocUnsafe(K),Z=0;for(let $=0;$<J.length;$++){let Q=J[$];X.set(Q,Z),Z+=Q.length}if(Z<K)return new F0(X.buffer,X.byteOffset,Z);return X}function m0(J,K,X,Z,$){for(let Q=0;Q<$;Q++)X[Z+Q]=J[Q]^K[Q&3]}function f0(J,K){for(let X=0;X<J.length;X++)J[X]^=K[X&3]}function b5(J){if(J.length===J.buffer.byteLength)return J.buffer;return J.buffer.slice(J.byteOffset,J.byteOffset+J.length)}function D0(J){if(D0.readOnly=!0,Buffer.isBuffer(J))return J;let K;if(J instanceof ArrayBuffer)K=new F0(J);else if(ArrayBuffer.isView(J))K=new F0(J.buffer,J.byteOffset,J.byteLength);else K=Buffer.from(J),D0.readOnly=!1;return K}X0.exports={concat:p5,mask:m0,toArrayBuffer:b5,toBuffer:D0,unmask:f0};if(!process.env.WS_NO_BUFFER_UTIL)try{let J=(()=>{throw new Error("Cannot require module "+"bufferutil");})();X0.exports.mask=function(K,X,Z,$,Q){if(Q<48)m0(K,X,Z,$,Q);else J.mask(K,X,Z,$,Q)},X0.exports.unmask=function(K,X){if(K.length<32)f0(K,X);else J.unmask(K,X)}}catch(J){}});var b0=P((V4,p0)=>{var u0=Symbol("kDone"),O0=Symbol("kRun");class l0{constructor(J){this[u0]=()=>{this.pending--,this[O0]()},this.concurrency=J||1/0,this.jobs=[],this.pending=0}add(J){this.jobs.push(J),this[O0]()}[O0](){if(this.pending===this.concurrency)return;if(this.jobs.length){let J=this.jobs.shift();this.pending++,J(this[u0])}}}p0.exports=l0});var a=P((_4,n0)=>{var r=R("zlib"),k0=n(),k5=b0(),{kStatusCode:i0}=C(),i5=Buffer[Symbol.species],d5=Buffer.from([0,0,255,255]),$0=Symbol("permessage-deflate"),q=Symbol("total-length"),f=Symbol("callback"),L=Symbol("buffers"),u=Symbol("error"),Z0;class d0{constructor(J,K,X){if(this._maxPayload=X|0,this._options=J||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!K,this._deflate=null,this._inflate=null,this.params=null,!Z0){let Z=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Z0=new k5(Z)}}static get extensionName(){return"permessage-deflate"}offer(){let J={};if(this._options.serverNoContextTakeover)J.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)J.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)J.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)J.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)J.client_max_window_bits=!0;return J}accept(J){return J=this.normalizeParams(J),this.params=this._isServer?this.acceptAsServer(J):this.acceptAsClient(J),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let J=this._deflate[f];if(this._deflate.close(),this._deflate=null,J)J(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(J){let K=this._options,X=J.find((Z)=>{if(K.serverNoContextTakeover===!1&&Z.server_no_context_takeover||Z.server_max_window_bits&&(K.serverMaxWindowBits===!1||typeof K.serverMaxWindowBits==="number"&&K.serverMaxWindowBits>Z.server_max_window_bits)||typeof K.clientMaxWindowBits==="number"&&!Z.client_max_window_bits)return!1;return!0});if(!X)throw Error("None of the extension offers can be accepted");if(K.serverNoContextTakeover)X.server_no_context_takeover=!0;if(K.clientNoContextTakeover)X.client_no_context_takeover=!0;if(typeof K.serverMaxWindowBits==="number")X.server_max_window_bits=K.serverMaxWindowBits;if(typeof K.clientMaxWindowBits==="number")X.client_max_window_bits=K.clientMaxWindowBits;else if(X.client_max_window_bits===!0||K.clientMaxWindowBits===!1)delete X.client_max_window_bits;return X}acceptAsClient(J){let K=J[0];if(this._options.clientNoContextTakeover===!1&&K.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!K.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")K.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&K.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return K}normalizeParams(J){return J.forEach((K)=>{Object.keys(K).forEach((X)=>{let Z=K[X];if(Z.length>1)throw Error(`Parameter "${X}" must have only a single value`);if(Z=Z[0],X==="client_max_window_bits"){if(Z!==!0){let $=+Z;if(!Number.isInteger($)||$<8||$>15)throw TypeError(`Invalid value for parameter "${X}": ${Z}`);Z=$}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${X}": ${Z}`)}else if(X==="server_max_window_bits"){let $=+Z;if(!Number.isInteger($)||$<8||$>15)throw TypeError(`Invalid value for parameter "${X}": ${Z}`);Z=$}else if(X==="client_no_context_takeover"||X==="server_no_context_takeover"){if(Z!==!0)throw TypeError(`Invalid value for parameter "${X}": ${Z}`)}else throw Error(`Unknown parameter "${X}"`);K[X]=Z})}),J}decompress(J,K,X){Z0.add((Z)=>{this._decompress(J,K,($,Q)=>{Z(),X($,Q)})})}compress(J,K,X){Z0.add((Z)=>{this._compress(J,K,($,Q)=>{Z(),X($,Q)})})}_decompress(J,K,X){let Z=this._isServer?"client":"server";if(!this._inflate){let $=`${Z}_max_window_bits`,Q=typeof this.params[$]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[$];this._inflate=r.createInflateRaw({...this._options.zlibInflateOptions,windowBits:Q}),this._inflate[$0]=this,this._inflate[q]=0,this._inflate[L]=[],this._inflate.on("error",n5),this._inflate.on("data",c0)}if(this._inflate[f]=X,this._inflate.write(J),K)this._inflate.write(d5);this._inflate.flush(()=>{let $=this._inflate[u];if($){this._inflate.close(),this._inflate=null,X($);return}let Q=k0.concat(this._inflate[L],this._inflate[q]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[q]=0,this._inflate[L]=[],K&&this.params[`${Z}_no_context_takeover`])this._inflate.reset();X(null,Q)})}_compress(J,K,X){let Z=this._isServer?"server":"client";if(!this._deflate){let $=`${Z}_max_window_bits`,Q=typeof this.params[$]!=="number"?r.Z_DEFAULT_WINDOWBITS:this.params[$];this._deflate=r.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:Q}),this._deflate[q]=0,this._deflate[L]=[],this._deflate.on("data",c5)}this._deflate[f]=X,this._deflate.write(J),this._deflate.flush(r.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let $=k0.concat(this._deflate[L],this._deflate[q]);if(K)$=new i5($.buffer,$.byteOffset,$.length-4);if(this._deflate[f]=null,this._deflate[q]=0,this._deflate[L]=[],K&&this.params[`${Z}_no_context_takeover`])this._deflate.reset();X(null,$)})}}n0.exports=d0;function c5(J){this[L].push(J),this[q]+=J.length}function c0(J){if(this[q]+=J.length,this[$0]._maxPayload<1||this[q]<=this[$0]._maxPayload){this[L].push(J);return}this[u]=RangeError("Max payload size exceeded"),this[u].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[u][i0]=1009,this.removeListener("data",c0),this.reset()}function n5(J){if(this[$0]._inflate=null,this[u]){this[f](this[u]);return}J[i0]=1007,this[f](J)}});var l=P((N4,Q0)=>{var{isUtf8:r0}=R("buffer"),{hasBlob:r5}=C(),a5=[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 s5(J){return J>=1000&&J<=1014&&J!==1004&&J!==1005&&J!==1006||J>=3000&&J<=4999}function P0(J){let K=J.length,X=0;while(X<K)if((J[X]&128)===0)X++;else if((J[X]&224)===192){if(X+1===K||(J[X+1]&192)!==128||(J[X]&254)===192)return!1;X+=2}else if((J[X]&240)===224){if(X+2>=K||(J[X+1]&192)!==128||(J[X+2]&192)!==128||J[X]===224&&(J[X+1]&224)===128||J[X]===237&&(J[X+1]&224)===160)return!1;X+=3}else if((J[X]&248)===240){if(X+3>=K||(J[X+1]&192)!==128||(J[X+2]&192)!==128||(J[X+3]&192)!==128||J[X]===240&&(J[X+1]&240)===128||J[X]===244&&J[X+1]>143||J[X]>244)return!1;X+=4}else return!1;return!0}function o5(J){return r5&&typeof J==="object"&&typeof J.arrayBuffer==="function"&&typeof J.type==="string"&&typeof J.stream==="function"&&(J[Symbol.toStringTag]==="Blob"||J[Symbol.toStringTag]==="File")}Q0.exports={isBlob:o5,isValidStatusCode:s5,isValidUTF8:P0,tokenChars:a5};if(r0)Q0.exports.isValidUTF8=function(J){return J.length<24?P0(J):r0(J)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let J=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();Q0.exports.isValidUTF8=function(K){return K.length<32?P0(K):J(K)}}catch(J){}});var T0=P((H4,e0)=>{var{Writable:t5}=R("stream"),a0=a(),{BINARY_TYPES:e5,EMPTY_BUFFER:s0,kStatusCode:J1,kWebSocket:K1}=C(),{concat:M0,toArrayBuffer:X1,unmask:Z1}=n(),{isValidStatusCode:$1,isValidUTF8:o0}=l(),G0=Buffer[Symbol.species];class t0 extends t5{constructor(J={}){super();this._allowSynchronousEvents=J.allowSynchronousEvents!==void 0?J.allowSynchronousEvents:!0,this._binaryType=J.binaryType||e5[0],this._extensions=J.extensions||{},this._isServer=!!J.isServer,this._maxPayload=J.maxPayload|0,this._skipUTF8Validation=!!J.skipUTF8Validation,this[K1]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=0}_write(J,K,X){if(this._opcode===8&&this._state==0)return X();this._bufferedBytes+=J.length,this._buffers.push(J),this.startLoop(X)}consume(J){if(this._bufferedBytes-=J,J===this._buffers[0].length)return this._buffers.shift();if(J<this._buffers[0].length){let X=this._buffers[0];return this._buffers[0]=new G0(X.buffer,X.byteOffset+J,X.length-J),new G0(X.buffer,X.byteOffset,J)}let K=Buffer.allocUnsafe(J);do{let X=this._buffers[0],Z=K.length-J;if(J>=X.length)K.set(this._buffers.shift(),Z);else K.set(new Uint8Array(X.buffer,X.byteOffset,J),Z),this._buffers[0]=new G0(X.buffer,X.byteOffset+J,X.length-J);J-=X.length}while(J>0);return K}startLoop(J){this._loop=!0;do switch(this._state){case 0:this.getInfo(J);break;case 1:this.getPayloadLength16(J);break;case 2:this.getPayloadLength64(J);break;case 3:this.getMask();break;case 4:this.getData(J);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)J()}getInfo(J){if(this._bufferedBytes<2){this._loop=!1;return}let K=this.consume(2);if((K[0]&48)!==0){let Z=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");J(Z);return}let X=(K[0]&64)===64;if(X&&!this._extensions[a0.extensionName]){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(this._fin=(K[0]&128)===128,this._opcode=K[0]&15,this._payloadLength=K[1]&127,this._opcode===0){if(X){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(!this._fragmented){let Z=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}this._compressed=X}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let Z=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");J(Z);return}if(X){let Z=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");J(Z);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let Z=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");J(Z);return}}else{let Z=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");J(Z);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(K[1]&128)===128,this._isServer){if(!this._masked){let Z=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");J(Z);return}}else if(this._masked){let Z=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");J(Z);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(J)}getPayloadLength16(J){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(J)}getPayloadLength64(J){if(this._bufferedBytes<8){this._loop=!1;return}let K=this.consume(8),X=K.readUInt32BE(0);if(X>Math.pow(2,21)-1){let Z=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");J(Z);return}this._payloadLength=X*Math.pow(2,32)+K.readUInt32BE(4),this.haveLength(J)}haveLength(J){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let K=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");J(K);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(J){let K=s0;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(K=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)Z1(K,this._mask)}if(this._opcode>7){this.controlMessage(K,J);return}if(this._compressed){this._state=5,this.decompress(K,J);return}if(K.length)this._messageLength=this._totalPayloadLength,this._fragments.push(K);this.dataMessage(J)}decompress(J,K){this._extensions[a0.extensionName].decompress(J,this._fin,(Z,$)=>{if(Z)return K(Z);if($.length){if(this._messageLength+=$.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let Q=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");K(Q);return}this._fragments.push($)}if(this.dataMessage(K),this._state===0)this.startLoop(K)})}dataMessage(J){if(!this._fin){this._state=0;return}let K=this._messageLength,X=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let Z;if(this._binaryType==="nodebuffer")Z=M0(X,K);else if(this._binaryType==="arraybuffer")Z=X1(M0(X,K));else if(this._binaryType==="blob")Z=new Blob(X);else Z=X;if(this._allowSynchronousEvents)this.emit("message",Z,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!0),this._state=0,this.startLoop(J)})}else{let Z=M0(X,K);if(!this._skipUTF8Validation&&!o0(Z)){let $=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");J($);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",Z,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",Z,!1),this._state=0,this.startLoop(J)})}}controlMessage(J,K){if(this._opcode===8){if(J.length===0)this._loop=!1,this.emit("conclude",1005,s0),this.end();else{let X=J.readUInt16BE(0);if(!$1(X)){let $=this.createError(RangeError,`invalid status code ${X}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");K($);return}let Z=new G0(J.buffer,J.byteOffset+2,J.length-2);if(!this._skipUTF8Validation&&!o0(Z)){let $=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");K($);return}this._loop=!1,this.emit("conclude",X,Z),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",J),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",J),this._state=0,this.startLoop(K)})}createError(J,K,X,Z,$){this._loop=!1,this._errored=!0;let Q=new J(X?`Invalid WebSocket frame: ${K}`:K);return Error.captureStackTrace(Q,this.createError),Q.code=$,Q[J1]=Z,Q}}e0.exports=t0});var B0=P((A4,X5)=>{var{Duplex:R4}=R("stream"),{randomFillSync:Q1}=R("crypto"),J5=a(),{EMPTY_BUFFER:G1,kWebSocket:I1,NOOP:z1}=C(),{isBlob:p,isValidStatusCode:j1}=l(),{mask:K5,toBuffer:S}=n(),T=Symbol("kByteLength"),Y1=Buffer.alloc(4),v,b=8192,x=0,V1=1,_1=2;class W{constructor(J,K,X){if(this._extensions=K||{},X)this._generateMask=X,this._maskBuffer=Buffer.alloc(4);this._socket=J,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=x,this.onerror=z1,this[I1]=void 0}static frame(J,K){let X,Z=!1,$=2,Q=!1;if(K.mask){if(X=K.maskBuffer||Y1,K.generateMask)K.generateMask(X);else{if(b===8192){if(v===void 0)v=Buffer.alloc(8192);Q1(v,0,8192),b=0}X[0]=v[b++],X[1]=v[b++],X[2]=v[b++],X[3]=v[b++]}Q=(X[0]|X[1]|X[2]|X[3])===0,$=6}let G;if(typeof J==="string")if((!K.mask||Q)&&K[T]!==void 0)G=K[T];else J=Buffer.from(J),G=J.length;else G=J.length,Z=K.mask&&K.readOnly&&!Q;let z=G;if(G>=65536)$+=8,z=127;else if(G>125)$+=2,z=126;let I=Buffer.allocUnsafe(Z?G+$:$);if(I[0]=K.fin?K.opcode|128:K.opcode,K.rsv1)I[0]|=64;if(I[1]=z,z===126)I.writeUInt16BE(G,2);else if(z===127)I[2]=I[3]=0,I.writeUIntBE(G,4,6);if(!K.mask)return[I,J];if(I[1]|=128,I[$-4]=X[0],I[$-3]=X[1],I[$-2]=X[2],I[$-1]=X[3],Q)return[I,J];if(Z)return K5(J,X,I,$,G),[I];return K5(J,X,J,0,G),[I,J]}close(J,K,X,Z){let $;if(J===void 0)$=G1;else if(typeof J!=="number"||!j1(J))throw TypeError("First argument must be a valid error code number");else if(K===void 0||!K.length)$=Buffer.allocUnsafe(2),$.writeUInt16BE(J,0);else{let G=Buffer.byteLength(K);if(G>123)throw RangeError("The message must not be greater than 123 bytes");if($=Buffer.allocUnsafe(2+G),$.writeUInt16BE(J,0),typeof K==="string")$.write(K,2);else $.set(K,2)}let Q={[T]:$.length,fin:!0,generateMask:this._generateMask,mask:X,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==x)this.enqueue([this.dispatch,$,!1,Q,Z]);else this.sendFrame(W.frame($,Q),Z)}ping(J,K,X){let Z,$;if(typeof J==="string")Z=Buffer.byteLength(J),$=!1;else if(p(J))Z=J.size,$=!1;else J=S(J),Z=J.length,$=S.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[T]:Z,fin:!0,generateMask:this._generateMask,mask:K,maskBuffer:this._maskBuffer,opcode:9,readOnly:$,rsv1:!1};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,!1,Q,X]);else this.getBlobData(J,!1,Q,X);else if(this._state!==x)this.enqueue([this.dispatch,J,!1,Q,X]);else this.sendFrame(W.frame(J,Q),X)}pong(J,K,X){let Z,$;if(typeof J==="string")Z=Buffer.byteLength(J),$=!1;else if(p(J))Z=J.size,$=!1;else J=S(J),Z=J.length,$=S.readOnly;if(Z>125)throw RangeError("The data size must not be greater than 125 bytes");let Q={[T]:Z,fin:!0,generateMask:this._generateMask,mask:K,maskBuffer:this._maskBuffer,opcode:10,readOnly:$,rsv1:!1};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,!1,Q,X]);else this.getBlobData(J,!1,Q,X);else if(this._state!==x)this.enqueue([this.dispatch,J,!1,Q,X]);else this.sendFrame(W.frame(J,Q),X)}send(J,K,X){let Z=this._extensions[J5.extensionName],$=K.binary?2:1,Q=K.compress,G,z;if(typeof J==="string")G=Buffer.byteLength(J),z=!1;else if(p(J))G=J.size,z=!1;else J=S(J),G=J.length,z=S.readOnly;if(this._firstFragment){if(this._firstFragment=!1,Q&&Z&&Z.params[Z._isServer?"server_no_context_takeover":"client_no_context_takeover"])Q=G>=Z._threshold;this._compress=Q}else Q=!1,$=0;if(K.fin)this._firstFragment=!0;let I={[T]:G,fin:K.fin,generateMask:this._generateMask,mask:K.mask,maskBuffer:this._maskBuffer,opcode:$,readOnly:z,rsv1:Q};if(p(J))if(this._state!==x)this.enqueue([this.getBlobData,J,this._compress,I,X]);else this.getBlobData(J,this._compress,I,X);else if(this._state!==x)this.enqueue([this.dispatch,J,this._compress,I,X]);else this.dispatch(J,this._compress,I,X)}getBlobData(J,K,X,Z){this._bufferedBytes+=X[T],this._state=_1,J.arrayBuffer().then(($)=>{if(this._socket.destroyed){let G=Error("The socket was closed while the blob was being read");process.nextTick(x0,this,G,Z);return}this._bufferedBytes-=X[T];let Q=S($);if(!K)this._state=x,this.sendFrame(W.frame(Q,X),Z),this.dequeue();else this.dispatch(Q,K,X,Z)}).catch(($)=>{process.nextTick(N1,this,$,Z)})}dispatch(J,K,X,Z){if(!K){this.sendFrame(W.frame(J,X),Z);return}let $=this._extensions[J5.extensionName];this._bufferedBytes+=X[T],this._state=V1,$.compress(J,X.fin,(Q,G)=>{if(this._socket.destroyed){let z=Error("The socket was closed while data was being compressed");x0(this,z,Z);return}this._bufferedBytes-=X[T],this._state=x,X.readOnly=!1,this.sendFrame(W.frame(G,X),Z),this.dequeue()})}dequeue(){while(this._state===x&&this._queue.length){let J=this._queue.shift();this._bufferedBytes-=J[3][T],Reflect.apply(J[0],this,J.slice(1))}}enqueue(J){this._bufferedBytes+=J[3][T],this._queue.push(J)}sendFrame(J,K){if(J.length===2)this._socket.cork(),this._socket.write(J[0]),this._socket.write(J[1],K),this._socket.uncork();else this._socket.write(J[0],K)}}X5.exports=W;function x0(J,K,X){if(typeof X==="function")X(K);for(let Z=0;Z<J._queue.length;Z++){let $=J._queue[Z],Q=$[$.length-1];if(typeof Q==="function")Q(K)}}function N1(J,K,X){x0(J,K,X),J.onerror(K)}});var V5=P((F4,Y5)=>{var{kForOnEventAttribute:s,kListener:C0}=C(),Z5=Symbol("kCode"),$5=Symbol("kData"),Q5=Symbol("kError"),G5=Symbol("kMessage"),I5=Symbol("kReason"),k=Symbol("kTarget"),z5=Symbol("kType"),j5=Symbol("kWasClean");class E{constructor(J){this[k]=null,this[z5]=J}get target(){return this[k]}get type(){return this[z5]}}Object.defineProperty(E.prototype,"target",{enumerable:!0});Object.defineProperty(E.prototype,"type",{enumerable:!0});class i extends E{constructor(J,K={}){super(J);this[Z5]=K.code===void 0?0:K.code,this[I5]=K.reason===void 0?"":K.reason,this[j5]=K.wasClean===void 0?!1:K.wasClean}get code(){return this[Z5]}get reason(){return this[I5]}get wasClean(){return this[j5]}}Object.defineProperty(i.prototype,"code",{enumerable:!0});Object.defineProperty(i.prototype,"reason",{enumerable:!0});Object.defineProperty(i.prototype,"wasClean",{enumerable:!0});class o extends E{constructor(J,K={}){super(J);this[Q5]=K.error===void 0?null:K.error,this[G5]=K.message===void 0?"":K.message}get error(){return this[Q5]}get message(){return this[G5]}}Object.defineProperty(o.prototype,"error",{enumerable:!0});Object.defineProperty(o.prototype,"message",{enumerable:!0});class z0 extends E{constructor(J,K={}){super(J);this[$5]=K.data===void 0?null:K.data}get data(){return this[$5]}}Object.defineProperty(z0.prototype,"data",{enumerable:!0});var H1={addEventListener(J,K,X={}){for(let $ of this.listeners(J))if(!X[s]&&$[C0]===K&&!$[s])return;let Z;if(J==="message")Z=function(Q,G){let z=new z0("message",{data:G?Q:Q.toString()});z[k]=this,I0(K,this,z)};else if(J==="close")Z=function(Q,G){let z=new i("close",{code:Q,reason:G.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});z[k]=this,I0(K,this,z)};else if(J==="error")Z=function(Q){let G=new o("error",{error:Q,message:Q.message});G[k]=this,I0(K,this,G)};else if(J==="open")Z=function(){let Q=new E("open");Q[k]=this,I0(K,this,Q)};else return;if(Z[s]=!!X[s],Z[C0]=K,X.once)this.once(J,Z);else this.on(J,Z)},removeEventListener(J,K){for(let X of this.listeners(J))if(X[C0]===K&&!X[s]){this.removeListener(J,X);break}}};Y5.exports={CloseEvent:i,ErrorEvent:o,Event:E,EventTarget:H1,MessageEvent:z0};function I0(J,K,X){if(typeof J==="object"&&J.handleEvent)J.handleEvent.call(J,X);else J.call(K,X)}});var q0=P((D4,_5)=>{var{tokenChars:t}=l();function B(J,K,X){if(J[K]===void 0)J[K]=[X];else J[K].push(X)}function R1(J){let K=Object.create(null),X=Object.create(null),Z=!1,$=!1,Q=!1,G,z,I=-1,V=-1,_=-1,Y=0;for(;Y<J.length;Y++)if(V=J.charCodeAt(Y),G===void 0)if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(Y!==0&&(V===32||V===9)){if(_===-1&&I!==-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;let D=J.slice(I,_);if(V===44)B(K,D,X),X=Object.create(null);else G=D;I=_=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);else if(z===void 0)if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(V===32||V===9){if(_===-1&&I!==-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;if(B(X,J.slice(I,_),!0),V===44)B(K,G,X),X=Object.create(null),G=void 0;I=_=-1}else if(V===61&&I!==-1&&_===-1)z=J.slice(I,Y),I=_=-1;else throw SyntaxError(`Unexpected character at index ${Y}`);else if($){if(t[V]!==1)throw SyntaxError(`Unexpected character at index ${Y}`);if(I===-1)I=Y;else if(!Z)Z=!0;$=!1}else if(Q)if(t[V]===1){if(I===-1)I=Y}else if(V===34&&I!==-1)Q=!1,_=Y;else if(V===92)$=!0;else throw SyntaxError(`Unexpected character at index ${Y}`);else if(V===34&&J.charCodeAt(Y-1)===61)Q=!0;else if(_===-1&&t[V]===1){if(I===-1)I=Y}else if(I!==-1&&(V===32||V===9)){if(_===-1)_=Y}else if(V===59||V===44){if(I===-1)throw SyntaxError(`Unexpected character at index ${Y}`);if(_===-1)_=Y;let D=J.slice(I,_);if(Z)D=D.replace(/\\/g,""),Z=!1;if(B(X,z,D),V===44)B(K,G,X),X=Object.create(null),G=void 0;z=void 0,I=_=-1}else throw SyntaxError(`Unexpected character at index ${Y}`);if(I===-1||Q||V===32||V===9)throw SyntaxError("Unexpected end of input");if(_===-1)_=Y;let F=J.slice(I,_);if(G===void 0)B(K,F,X);else{if(z===void 0)B(X,F,!0);else if(Z)B(X,z,F.replace(/\\/g,""));else B(X,z,F);B(K,G,X)}return K}function A1(J){return Object.keys(J).map((K)=>{let X=J[K];if(!Array.isArray(X))X=[X];return X.map((Z)=>{return[K].concat(Object.keys(Z).map(($)=>{let Q=Z[$];if(!Array.isArray(Q))Q=[Q];return Q.map((G)=>G===!0?$:`${$}=${G}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}_5.exports={format:A1,parse:R1}});var _0=P((M4,B5)=>{var F1=R("events"),D1=R("https"),O1=R("http"),R5=R("net"),P1=R("tls"),{randomBytes:M1,createHash:T1}=R("crypto"),{Duplex:O4,Readable:P4}=R("stream"),{URL:U0}=R("url"),y=a(),x1=T0(),B1=B0(),{isBlob:C1}=l(),{BINARY_TYPES:N5,CLOSE_TIMEOUT:q1,EMPTY_BUFFER:j0,GUID:U1,kForOnEventAttribute:L0,kListener:L1,kStatusCode:W1,kWebSocket:A,NOOP:A5}=C(),{EventTarget:{addEventListener:E1,removeEventListener:y1}}=V5(),{format:S1,parse:v1}=q0(),{toBuffer:g1}=n(),F5=Symbol("kAborted"),W0=[8,13],U=["CONNECTING","OPEN","CLOSING","CLOSED"],w1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class j extends F1{constructor(J,K,X){super();if(this._binaryType=N5[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=j0,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=j.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,J!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,K===void 0)K=[];else if(!Array.isArray(K))if(typeof K==="object"&&K!==null)X=K,K=[];else K=[K];D5(this,J,K,X)}else this._autoPong=X.autoPong,this._closeTimeout=X.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(J){if(!N5.includes(J))return;if(this._binaryType=J,this._receiver)this._receiver._binaryType=J}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(J,K,X){let Z=new x1({allowSynchronousEvents:X.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:X.maxPayload,skipUTF8Validation:X.skipUTF8Validation}),$=new B1(J,this._extensions,X.generateMask);if(this._receiver=Z,this._sender=$,this._socket=J,Z[A]=this,$[A]=this,J[A]=this,Z.on("conclude",f1),Z.on("drain",u1),Z.on("error",l1),Z.on("message",p1),Z.on("ping",b1),Z.on("pong",k1),$.onerror=i1,J.setTimeout)J.setTimeout(0);if(J.setNoDelay)J.setNoDelay();if(K.length>0)J.unshift(K);J.on("close",M5),J.on("data",V0),J.on("end",T5),J.on("error",x5),this._readyState=j.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=j.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[y.extensionName])this._extensions[y.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=j.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(J,K){if(this.readyState===j.CLOSED)return;if(this.readyState===j.CONNECTING){M(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===j.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=j.CLOSING,this._sender.close(J,K,!this._isServer,(X)=>{if(X)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),P5(this)}pause(){if(this.readyState===j.CONNECTING||this.readyState===j.CLOSED)return;this._paused=!0,this._socket.pause()}ping(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")X=J,J=K=void 0;else if(typeof K==="function")X=K,K=void 0;if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}if(K===void 0)K=!this._isServer;this._sender.ping(J||j0,K,X)}pong(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof J==="function")X=J,J=K=void 0;else if(typeof K==="function")X=K,K=void 0;if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}if(K===void 0)K=!this._isServer;this._sender.pong(J||j0,K,X)}resume(){if(this.readyState===j.CONNECTING||this.readyState===j.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(J,K,X){if(this.readyState===j.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof K==="function")X=K,K={};if(typeof J==="number")J=J.toString();if(this.readyState!==j.OPEN){E0(this,J,X);return}let Z={binary:typeof J!=="string",mask:!this._isServer,compress:!0,fin:!0,...K};if(!this._extensions[y.extensionName])Z.compress=!1;this._sender.send(J||j0,Z,X)}terminate(){if(this.readyState===j.CLOSED)return;if(this.readyState===j.CONNECTING){M(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=j.CLOSING,this._socket.destroy()}}Object.defineProperty(j,"CONNECTING",{enumerable:!0,value:U.indexOf("CONNECTING")});Object.defineProperty(j.prototype,"CONNECTING",{enumerable:!0,value:U.indexOf("CONNECTING")});Object.defineProperty(j,"OPEN",{enumerable:!0,value:U.indexOf("OPEN")});Object.defineProperty(j.prototype,"OPEN",{enumerable:!0,value:U.indexOf("OPEN")});Object.defineProperty(j,"CLOSING",{enumerable:!0,value:U.indexOf("CLOSING")});Object.defineProperty(j.prototype,"CLOSING",{enumerable:!0,value:U.indexOf("CLOSING")});Object.defineProperty(j,"CLOSED",{enumerable:!0,value:U.indexOf("CLOSED")});Object.defineProperty(j.prototype,"CLOSED",{enumerable:!0,value:U.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((J)=>{Object.defineProperty(j.prototype,J,{enumerable:!0})});["open","error","close","message"].forEach((J)=>{Object.defineProperty(j.prototype,`on${J}`,{enumerable:!0,get(){for(let K of this.listeners(J))if(K[L0])return K[L1];return null},set(K){for(let X of this.listeners(J))if(X[L0]){this.removeListener(J,X);break}if(typeof K!=="function")return;this.addEventListener(J,K,{[L0]:!0})}})});j.prototype.addEventListener=E1;j.prototype.removeEventListener=y1;B5.exports=j;function D5(J,K,X,Z){let $={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:q1,protocolVersion:W0[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...Z,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(J._autoPong=$.autoPong,J._closeTimeout=$.closeTimeout,!W0.includes($.protocolVersion))throw RangeError(`Unsupported protocol version: ${$.protocolVersion} (supported versions: ${W0.join(", ")})`);let Q;if(K instanceof U0)Q=K;else try{Q=new U0(K)}catch(N){throw SyntaxError(`Invalid URL: ${K}`)}if(Q.protocol==="http:")Q.protocol="ws:";else if(Q.protocol==="https:")Q.protocol="wss:";J._url=Q.href;let G=Q.protocol==="wss:",z=Q.protocol==="ws+unix:",I;if(Q.protocol!=="ws:"&&!G&&!z)I=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(z&&!Q.pathname)I="The URL's pathname is empty";else if(Q.hash)I="The URL contains a fragment identifier";if(I){let N=SyntaxError(I);if(J._redirects===0)throw N;else{Y0(J,N);return}}let V=G?443:80,_=M1(16).toString("base64"),Y=G?D1.request:O1.request,F=new Set,D;if($.createConnection=$.createConnection||(G?m1:h1),$.defaultPort=$.defaultPort||V,$.port=Q.port||V,$.host=Q.hostname.startsWith("[")?Q.hostname.slice(1,-1):Q.hostname,$.headers={...$.headers,"Sec-WebSocket-Version":$.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},$.path=Q.pathname+Q.search,$.timeout=$.handshakeTimeout,$.perMessageDeflate)D=new y($.perMessageDeflate!==!0?$.perMessageDeflate:{},!1,$.maxPayload),$.headers["Sec-WebSocket-Extensions"]=S1({[y.extensionName]:D.offer()});if(X.length){for(let N of X){if(typeof N!=="string"||!w1.test(N)||F.has(N))throw SyntaxError("An invalid or duplicated subprotocol was specified");F.add(N)}$.headers["Sec-WebSocket-Protocol"]=X.join(",")}if($.origin)if($.protocolVersion<13)$.headers["Sec-WebSocket-Origin"]=$.origin;else $.headers.Origin=$.origin;if(Q.username||Q.password)$.auth=`${Q.username}:${Q.password}`;if(z){let N=$.path.split(":");$.socketPath=N[0],$.path=N[1]}let H;if($.followRedirects){if(J._redirects===0){J._originalIpc=z,J._originalSecure=G,J._originalHostOrSocketPath=z?$.socketPath:Q.host;let N=Z&&Z.headers;if(Z={...Z,headers:{}},N)for(let[O,h]of Object.entries(N))Z.headers[O.toLowerCase()]=h}else if(J.listenerCount("redirect")===0){let N=z?J._originalIpc?$.socketPath===J._originalHostOrSocketPath:!1:J._originalIpc?!1:Q.host===J._originalHostOrSocketPath;if(!N||J._originalSecure&&!G){if(delete $.headers.authorization,delete $.headers.cookie,!N)delete $.headers.host;$.auth=void 0}}if($.auth&&!Z.headers.authorization)Z.headers.authorization="Basic "+Buffer.from($.auth).toString("base64");if(H=J._req=Y($),J._redirects)J.emit("redirect",J.url,H)}else H=J._req=Y($);if($.timeout)H.on("timeout",()=>{M(J,H,"Opening handshake has timed out")});if(H.on("error",(N)=>{if(H===null||H[F5])return;H=J._req=null,Y0(J,N)}),H.on("response",(N)=>{let O=N.headers.location,h=N.statusCode;if(O&&$.followRedirects&&h>=300&&h<400){if(++J._redirects>$.maxRedirects){M(J,H,"Maximum redirects exceeded");return}H.abort();let d;try{d=new U0(O,K)}catch(y0){let m=SyntaxError(`Invalid URL: ${O}`);Y0(J,m);return}D5(J,d,X,Z)}else if(!J.emit("unexpected-response",H,N))M(J,H,`Unexpected server response: ${N.statusCode}`)}),H.on("upgrade",(N,O,h)=>{if(J.emit("upgrade",N),J.readyState!==j.CONNECTING)return;H=J._req=null;let d=N.headers.upgrade;if(d===void 0||d.toLowerCase()!=="websocket"){M(J,O,"Invalid Upgrade header");return}let y0=T1("sha1").update(_+U1).digest("base64");if(N.headers["sec-websocket-accept"]!==y0){M(J,O,"Invalid Sec-WebSocket-Accept header");return}let m=N.headers["sec-websocket-protocol"],c;if(m!==void 0){if(!F.size)c="Server sent a subprotocol but none was requested";else if(!F.has(m))c="Server sent an invalid subprotocol"}else if(F.size)c="Server sent no subprotocol";if(c){M(J,O,c);return}if(m)J._protocol=m;let S0=N.headers["sec-websocket-extensions"];if(S0!==void 0){if(!D){M(J,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let R0;try{R0=v1(S0)}catch(A0){M(J,O,"Invalid Sec-WebSocket-Extensions header");return}let v0=Object.keys(R0);if(v0.length!==1||v0[0]!==y.extensionName){M(J,O,"Server indicated an extension that was not requested");return}try{D.accept(R0[y.extensionName])}catch(A0){M(J,O,"Invalid Sec-WebSocket-Extensions header");return}J._extensions[y.extensionName]=D}J.setSocket(O,h,{allowSynchronousEvents:$.allowSynchronousEvents,generateMask:$.generateMask,maxPayload:$.maxPayload,skipUTF8Validation:$.skipUTF8Validation})}),$.finishRequest)$.finishRequest(H,J);else H.end()}function Y0(J,K){J._readyState=j.CLOSING,J._errorEmitted=!0,J.emit("error",K),J.emitClose()}function h1(J){return J.path=J.socketPath,R5.connect(J)}function m1(J){if(J.path=void 0,!J.servername&&J.servername!=="")J.servername=R5.isIP(J.host)?"":J.host;return P1.connect(J)}function M(J,K,X){J._readyState=j.CLOSING;let Z=Error(X);if(Error.captureStackTrace(Z,M),K.setHeader){if(K[F5]=!0,K.abort(),K.socket&&!K.socket.destroyed)K.socket.destroy();process.nextTick(Y0,J,Z)}else K.destroy(Z),K.once("error",J.emit.bind(J,"error")),K.once("close",J.emitClose.bind(J))}function E0(J,K,X){if(K){let Z=C1(K)?K.size:g1(K).length;if(J._socket)J._sender._bufferedBytes+=Z;else J._bufferedAmount+=Z}if(X){let Z=Error(`WebSocket is not open: readyState ${J.readyState} (${U[J.readyState]})`);process.nextTick(X,Z)}}function f1(J,K){let X=this[A];if(X._closeFrameReceived=!0,X._closeMessage=K,X._closeCode=J,X._socket[A]===void 0)return;if(X._socket.removeListener("data",V0),process.nextTick(O5,X._socket),J===1005)X.close();else X.close(J,K)}function u1(){let J=this[A];if(!J.isPaused)J._socket.resume()}function l1(J){let K=this[A];if(K._socket[A]!==void 0)K._socket.removeListener("data",V0),process.nextTick(O5,K._socket),K.close(J[W1]);if(!K._errorEmitted)K._errorEmitted=!0,K.emit("error",J)}function H5(){this[A].emitClose()}function p1(J,K){this[A].emit("message",J,K)}function b1(J){let K=this[A];if(K._autoPong)K.pong(J,!this._isServer,A5);K.emit("ping",J)}function k1(J){this[A].emit("pong",J)}function O5(J){J.resume()}function i1(J){let K=this[A];if(K.readyState===j.CLOSED)return;if(K.readyState===j.OPEN)K._readyState=j.CLOSING,P5(K);if(this._socket.end(),!K._errorEmitted)K._errorEmitted=!0,K.emit("error",J)}function P5(J){J._closeTimer=setTimeout(J._socket.destroy.bind(J._socket),J._closeTimeout)}function M5(){let J=this[A];if(this.removeListener("close",M5),this.removeListener("data",V0),this.removeListener("end",T5),J._readyState=j.CLOSING,!this._readableState.endEmitted&&!J._closeFrameReceived&&!J._receiver._writableState.errorEmitted&&this._readableState.length!==0){let K=this.read(this._readableState.length);J._receiver.write(K)}if(J._receiver.end(),this[A]=void 0,clearTimeout(J._closeTimer),J._receiver._writableState.finished||J._receiver._writableState.errorEmitted)J.emitClose();else J._receiver.on("error",H5),J._receiver.on("finish",H5)}function V0(J){if(!this[A]._receiver.write(J))this.pause()}function T5(){let J=this[A];J._readyState=j.CLOSING,J._receiver.end(),this.end()}function x5(){let J=this[A];if(this.removeListener("error",x5),this.on("error",A5),J)J._readyState=j.CLOSING,this.destroy()}});var L5=P((x4,U5)=>{var T4=_0(),{Duplex:d1}=R("stream");function C5(J){J.emit("close")}function c1(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function q5(J){if(this.removeListener("error",q5),this.destroy(),this.listenerCount("error")===0)this.emit("error",J)}function n1(J,K){let X=!0,Z=new d1({...K,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return J.on("message",function(Q,G){let z=!G&&Z._readableState.objectMode?Q.toString():Q;if(!Z.push(z))J.pause()}),J.once("error",function(Q){if(Z.destroyed)return;X=!1,Z.destroy(Q)}),J.once("close",function(){if(Z.destroyed)return;Z.push(null)}),Z._destroy=function($,Q){if(J.readyState===J.CLOSED){Q($),process.nextTick(C5,Z);return}let G=!1;if(J.once("error",function(I){G=!0,Q(I)}),J.once("close",function(){if(!G)Q($);process.nextTick(C5,Z)}),X)J.terminate()},Z._final=function($){if(J.readyState===J.CONNECTING){J.once("open",function(){Z._final($)});return}if(J._socket===null)return;if(J._socket._writableState.finished){if($(),Z._readableState.endEmitted)Z.destroy()}else J._socket.once("finish",function(){$()}),J.close()},Z._read=function(){if(J.isPaused)J.resume()},Z._write=function($,Q,G){if(J.readyState===J.CONNECTING){J.once("open",function(){Z._write($,Q,G)});return}J.send($,G)},Z.on("end",c1),Z.on("error",q5),Z}U5.exports=n1});var E5=P((B4,W5)=>{var{tokenChars:r1}=l();function a1(J){let K=new Set,X=-1,Z=-1,$=0;for($;$<J.length;$++){let G=J.charCodeAt($);if(Z===-1&&r1[G]===1){if(X===-1)X=$}else if($!==0&&(G===32||G===9)){if(Z===-1&&X!==-1)Z=$}else if(G===44){if(X===-1)throw SyntaxError(`Unexpected character at index ${$}`);if(Z===-1)Z=$;let z=J.slice(X,Z);if(K.has(z))throw SyntaxError(`The "${z}" subprotocol is duplicated`);K.add(z),X=Z=-1}else throw SyntaxError(`Unexpected character at index ${$}`)}if(X===-1||Z!==-1)throw SyntaxError("Unexpected end of input");let Q=J.slice(X,$);if(K.has(Q))throw SyntaxError(`The "${Q}" subprotocol is duplicated`);return K.add(Q),K}W5.exports={parse:a1}});var w5=P((q4,g5)=>{var s1=R("events"),N0=R("http"),{Duplex:C4}=R("stream"),{createHash:o1}=R("crypto"),y5=q0(),g=a(),t1=E5(),e1=_0(),{CLOSE_TIMEOUT:J4,GUID:K4,kWebSocket:X4}=C(),Z4=/^[+/0-9A-Za-z]{22}==$/;class v5 extends s1{constructor(J,K){super();if(J={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:J4,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:e1,...J},J.port==null&&!J.server&&!J.noServer||J.port!=null&&(J.server||J.noServer)||J.server&&J.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(J.port!=null)this._server=N0.createServer((X,Z)=>{let $=N0.STATUS_CODES[426];Z.writeHead(426,{"Content-Length":$.length,"Content-Type":"text/plain"}),Z.end($)}),this._server.listen(J.port,J.host,J.backlog,K);else if(J.server)this._server=J.server;if(this._server){let X=this.emit.bind(this,"connection");this._removeListeners=$4(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(Z,$,Q)=>{this.handleUpgrade(Z,$,Q,X)}})}if(J.perMessageDeflate===!0)J.perMessageDeflate={};if(J.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=J,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(J){if(this._state===2){if(J)this.once("close",()=>{J(Error("The server is not running"))});process.nextTick(e,this);return}if(J)this.once("close",J);if(this._state===1)return;if(this._state=1,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(e,this);else this._shouldEmitClose=!0;else process.nextTick(e,this)}else{let K=this._server;this._removeListeners(),this._removeListeners=this._server=null,K.close(()=>{e(this)})}}shouldHandle(J){if(this.options.path){let K=J.url.indexOf("?");if((K!==-1?J.url.slice(0,K):J.url)!==this.options.path)return!1}return!0}handleUpgrade(J,K,X,Z){K.on("error",S5);let $=J.headers["sec-websocket-key"],Q=J.headers.upgrade,G=+J.headers["sec-websocket-version"];if(J.method!=="GET"){w(this,J,K,405,"Invalid HTTP method");return}if(Q===void 0||Q.toLowerCase()!=="websocket"){w(this,J,K,400,"Invalid Upgrade header");return}if($===void 0||!Z4.test($)){w(this,J,K,400,"Missing or invalid Sec-WebSocket-Key header");return}if(G!==13&&G!==8){w(this,J,K,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(J)){J0(K,400);return}let z=J.headers["sec-websocket-protocol"],I=new Set;if(z!==void 0)try{I=t1.parse(z)}catch(Y){w(this,J,K,400,"Invalid Sec-WebSocket-Protocol header");return}let V=J.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&V!==void 0){let Y=new g(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let F=y5.parse(V);if(F[g.extensionName])Y.accept(F[g.extensionName]),_[g.extensionName]=Y}catch(F){w(this,J,K,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Y={origin:J.headers[`${G===8?"sec-websocket-origin":"origin"}`],secure:!!(J.socket.authorized||J.socket.encrypted),req:J};if(this.options.verifyClient.length===2){this.options.verifyClient(Y,(F,D,H,N)=>{if(!F)return J0(K,D||401,H,N);this.completeUpgrade(_,$,I,J,K,X,Z)});return}if(!this.options.verifyClient(Y))return J0(K,401)}this.completeUpgrade(_,$,I,J,K,X,Z)}completeUpgrade(J,K,X,Z,$,Q,G){if(!$.readable||!$.writable)return $.destroy();if($[X4])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return J0($,503);let I=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${o1("sha1").update(K+K4).digest("base64")}`],V=new this.options.WebSocket(null,void 0,this.options);if(X.size){let _=this.options.handleProtocols?this.options.handleProtocols(X,Z):X.values().next().value;if(_)I.push(`Sec-WebSocket-Protocol: ${_}`),V._protocol=_}if(J[g.extensionName]){let _=J[g.extensionName].params,Y=y5.format({[g.extensionName]:[_]});I.push(`Sec-WebSocket-Extensions: ${Y}`),V._extensions=J}if(this.emit("headers",I,Z),$.write(I.concat(`\r
|
|
2
2
|
`).join(`\r
|
|
3
3
|
`)),$.removeListener("error",S5),V.setSocket($,Q,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(V),V.on("close",()=>{if(this.clients.delete(V),this._shouldEmitClose&&!this.clients.size)process.nextTick(e,this)});G(V,Z)}}g5.exports=v5;function $4(J,K){for(let X of Object.keys(K))J.on(X,K[X]);return function(){for(let Z of Object.keys(K))J.removeListener(Z,K[Z])}}function e(J){J._state=2,J.emit("close")}function S5(){this.destroy()}function J0(J,K,X,Z){X=X||N0.STATUS_CODES[K],Z={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(X),...Z},J.once("finish",J.destroy),J.end(`HTTP/1.1 ${K} ${N0.STATUS_CODES[K]}\r
|
|
4
4
|
`+Object.keys(Z).map(($)=>`${$}: ${Z[$]}`).join(`\r
|