@qitqode/qitqode-android-arm64 0.2.7 → 0.2.8
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/bundle/{chunk-ga6wc979.js → chunk-03zpnwk2.js} +1 -1
- package/bundle/{chunk-qdvnscxm.js → chunk-0a4pmkc9.js} +1 -1
- package/bundle/chunk-0aqdzyar.js +2 -0
- package/bundle/{chunk-drnj1a14.js → chunk-0egrckx0.js} +1 -1
- package/bundle/{chunk-368jx5dp.js → chunk-0tcggtwv.js} +1 -1
- package/bundle/{chunk-0qpqd7nz.js → chunk-0tm6589k.js} +2 -2
- package/bundle/{chunk-0gsw04hw.js → chunk-0w19vmd7.js} +2 -2
- package/bundle/{chunk-j6xmgn63.js → chunk-0z1keh2w.js} +1 -1
- package/bundle/{chunk-aa2n02qk.js → chunk-1bxfzd6r.js} +2 -2
- package/bundle/{chunk-hrtze4c5.js → chunk-1har4t9a.js} +1 -1
- package/bundle/{chunk-33jcxsbe.js → chunk-1p9s5jj1.js} +1 -1
- package/bundle/{chunk-p40z6510.js → chunk-1v0khv7p.js} +1 -1
- package/bundle/{chunk-2c26kxp4.js → chunk-26cr51wa.js} +1 -1
- package/bundle/{chunk-eeq0krp7.js → chunk-27saej0r.js} +2 -2
- package/bundle/{chunk-ppy0jy6j.js → chunk-29gwtcey.js} +1 -1
- package/bundle/chunk-2a5gjgvp.js +2 -0
- package/bundle/{chunk-bn71wqqf.js → chunk-2caaqmec.js} +1 -1
- package/bundle/{chunk-hhk2sp5n.js → chunk-2kh0tg92.js} +1 -1
- package/bundle/{chunk-bd505nsd.js → chunk-2nheahmq.js} +1 -1
- package/bundle/chunk-2pkfphgb.js +2 -0
- package/bundle/{chunk-jxkrhrp0.js → chunk-2qm46qvn.js} +1 -1
- package/bundle/{chunk-ajp53ksp.js → chunk-2t5yh25f.js} +1 -1
- package/bundle/{chunk-4fy08jcj.js → chunk-2vaphpz0.js} +1 -1
- package/bundle/{chunk-5nhwqg7c.js → chunk-33ebjca6.js} +1 -1
- package/bundle/{chunk-yxttz5z5.js → chunk-35fj1sfm.js} +1 -1
- package/bundle/{chunk-makecdh6.js → chunk-37cbrnke.js} +5 -5
- package/bundle/{chunk-1vpx7szf.js → chunk-3bb4aqh9.js} +1 -1
- package/bundle/chunk-3cx4p07h.js +2 -0
- package/bundle/chunk-3f2cjzb4.js +2 -0
- package/bundle/chunk-3qvap1kv.js +2 -0
- package/bundle/{chunk-c8prg3jx.js → chunk-3va85mbe.js} +2 -2
- package/bundle/{chunk-wvb17w0z.js → chunk-3z2zn8rj.js} +1 -1
- package/bundle/{chunk-ghap1n1m.js → chunk-3zwma68w.js} +4 -4
- package/bundle/{chunk-abv0fskc.js → chunk-4064rbtp.js} +1 -1
- package/bundle/{chunk-84pjdenq.js → chunk-42hvspe7.js} +1 -1
- package/bundle/chunk-452tk6v3.js +2 -0
- package/bundle/{chunk-w3zhy5vq.js → chunk-48gap82w.js} +1 -1
- package/bundle/{chunk-q87fw8dk.js → chunk-4aajzxm9.js} +1 -1
- package/bundle/{chunk-4ftjx7ss.js → chunk-4gqb1hps.js} +1 -1
- package/bundle/{chunk-gww0skmn.js → chunk-4pmvxnkj.js} +1 -1
- package/bundle/chunk-50qgz5ka.js +2 -0
- package/bundle/{chunk-4zhrg3rv.js → chunk-52xvhxek.js} +1 -1
- package/bundle/{chunk-8hmt3avx.js → chunk-56wq8cqj.js} +1 -1
- package/bundle/{chunk-5r05d901.js → chunk-58f4y4b7.js} +2 -2
- package/bundle/{chunk-mbbxedsq.js → chunk-59csnjc3.js} +2 -2
- package/bundle/chunk-5b0xyq5z.js +2 -0
- package/bundle/{chunk-0ggvqmnm.js → chunk-5bv63rqj.js} +1 -1
- package/bundle/{chunk-vfb72vdy.js → chunk-5cw8235e.js} +1 -1
- package/bundle/{chunk-yd94wz5v.js → chunk-5f0nhthe.js} +1 -1
- package/bundle/chunk-5j4nxpdy.js +2 -0
- package/bundle/{chunk-r4kg0z96.js → chunk-5nmm1kvx.js} +1 -1
- package/bundle/chunk-5nxgk6hw.js +2 -0
- package/bundle/chunk-5qkvhr6y.js +2 -0
- package/bundle/{chunk-5zh91zk2.js → chunk-5r7c6vvx.js} +1 -1
- package/bundle/{chunk-c6cajbyj.js → chunk-5wx962mw.js} +1 -1
- package/bundle/{chunk-7sq5dyv1.js → chunk-5xkp27b1.js} +1 -1
- package/bundle/chunk-66qmmmdp.js +2 -0
- package/bundle/{chunk-vhzx5bxd.js → chunk-66wv82vf.js} +1 -1
- package/bundle/chunk-6dpdkzrk.js +2 -0
- package/bundle/chunk-6p6m5956.js +3 -0
- package/bundle/{chunk-n4qxj391.js → chunk-6ps30qax.js} +1 -1
- package/bundle/{chunk-gbxf6e5d.js → chunk-6qwk6z87.js} +3 -3
- package/bundle/{chunk-kmzpeq8k.js → chunk-6tqbnxar.js} +1 -1
- package/bundle/{chunk-gdew7bwm.js → chunk-6yhn9syz.js} +1 -1
- package/bundle/{chunk-2pex3ak9.js → chunk-72crs18f.js} +1 -1
- package/bundle/{chunk-mghnkwp8.js → chunk-7adsab4h.js} +1 -1
- package/bundle/{chunk-aqcpk2vg.js → chunk-7b60whxm.js} +1 -1
- package/bundle/chunk-7g59hc61.js +2 -0
- package/bundle/{chunk-52rdms56.js → chunk-7jy53zqy.js} +1 -1
- package/bundle/chunk-7p88j56s.js +2 -0
- package/bundle/{chunk-t4b2fm7z.js → chunk-7thhd7ds.js} +1 -1
- package/bundle/chunk-7trngc9g.js +2 -0
- package/bundle/{chunk-yjqww6ag.js → chunk-82xrfk5x.js} +2 -2
- package/bundle/{chunk-4fvbexr8.js → chunk-85wh85pk.js} +1 -1
- package/bundle/chunk-8cebbmtf.js +2 -0
- package/bundle/chunk-8csas2jc.js +2 -0
- package/bundle/chunk-8g4jdqq1.js +2 -0
- package/bundle/chunk-8j1xcdmd.js +2 -0
- package/bundle/{chunk-ntpn0w9m.js → chunk-8jmb5bd4.js} +2 -2
- package/bundle/{chunk-pf3nqf00.js → chunk-8ysp6vf8.js} +1 -1
- package/bundle/{chunk-3k7016c2.js → chunk-8yzghzjq.js} +1 -1
- package/bundle/{chunk-73xryfgn.js → chunk-9009v4d0.js} +2 -2
- package/bundle/chunk-90r2z49k.js +2 -0
- package/bundle/{chunk-amp6mvbp.js → chunk-92r1gw2j.js} +1 -1
- package/bundle/{chunk-ktp2b4t4.js → chunk-94mjwy22.js} +1 -1
- package/bundle/{chunk-f84hw65n.js → chunk-9cf2ktyh.js} +1 -1
- package/bundle/{chunk-16srrzjr.js → chunk-9cn8cmt0.js} +1 -1
- package/bundle/{chunk-x55h5qdc.js → chunk-a1z8rnq7.js} +3 -3
- package/bundle/{chunk-c3szabpf.js → chunk-a48mx917.js} +2 -2
- package/bundle/{chunk-prbxhnza.js → chunk-a8bjcvda.js} +1 -1
- package/bundle/chunk-aenrd7dk.js +2 -0
- package/bundle/{chunk-dw70wds9.js → chunk-afr8m0q1.js} +1 -1
- package/bundle/{chunk-7p6mxch0.js → chunk-ag8wxwwz.js} +1 -1
- package/bundle/{chunk-22qetqnp.js → chunk-ahmy80vb.js} +1 -1
- package/bundle/chunk-avn12jkt.js +2 -0
- package/bundle/{chunk-tc9xbn1t.js → chunk-ax64ngf2.js} +1 -1
- package/bundle/{chunk-4ngmjk8j.js → chunk-ayb3bdb7.js} +1 -1
- package/bundle/{chunk-0crgymtr.js → chunk-az3nss5m.js} +2 -2
- package/bundle/chunk-b7ncyat6.js +2 -0
- package/bundle/{chunk-dt1wwt7m.js → chunk-b7sr9rn3.js} +1 -1
- package/bundle/{chunk-9qzwmt76.js → chunk-bc2krtaf.js} +1 -1
- package/bundle/{chunk-0bgssfvq.js → chunk-bjv1h2dq.js} +1 -1
- package/bundle/{chunk-8jvfqh3b.js → chunk-bnaj2hh3.js} +1 -1
- package/bundle/{chunk-twvmjsxf.js → chunk-bpfq8fz4.js} +1 -1
- package/bundle/chunk-brk6bge4.js +3 -0
- package/bundle/{chunk-s06t769q.js → chunk-bwadggys.js} +1 -1
- package/bundle/chunk-c2a74stf.js +2 -0
- package/bundle/{chunk-76h0f86f.js → chunk-c3yjbent.js} +1 -1
- package/bundle/{chunk-spzd8rev.js → chunk-c76cjhn0.js} +1 -1
- package/bundle/{chunk-705xnxbc.js → chunk-ccf4pgkr.js} +1 -1
- package/bundle/chunk-ce5e7j62.js +2 -0
- package/bundle/{chunk-2bjfz4fb.js → chunk-cf9m9m9q.js} +1 -1
- package/bundle/{chunk-z7kswv9r.js → chunk-cfwz1hgr.js} +3 -3
- package/bundle/{chunk-dgva3y5v.js → chunk-cghz0855.js} +1 -1
- package/bundle/{chunk-a76w2jwm.js → chunk-cr5tknvb.js} +1 -1
- package/bundle/chunk-cw1gwjx9.js +2 -0
- package/bundle/chunk-czw30fjs.js +2 -0
- package/bundle/{chunk-x80d0zh7.js → chunk-d30k7dpf.js} +1 -1
- package/bundle/{chunk-x9fyt3vx.js → chunk-d839fr0w.js} +1 -1
- package/bundle/{chunk-n0g4983e.js → chunk-ddx2pcr4.js} +1 -1
- package/bundle/{chunk-4byvnx78.js → chunk-dgcannw0.js} +1 -1
- package/bundle/{chunk-4rpgwgx9.js → chunk-dhvx9p54.js} +1 -1
- package/bundle/chunk-dmkgjf1v.js +3 -0
- package/bundle/{chunk-z744mz4w.js → chunk-dt3bsmfe.js} +2 -2
- package/bundle/chunk-dwhsvpag.js +2 -0
- package/bundle/{chunk-4j76bf4j.js → chunk-dwkrqtbc.js} +1 -1
- package/bundle/chunk-e01jgnnm.js +2 -0
- package/bundle/chunk-e0hfpdje.js +2 -0
- package/bundle/{chunk-f2pv705d.js → chunk-e0vrxetq.js} +1 -1
- package/bundle/{chunk-59kk0mce.js → chunk-e2wfj86b.js} +1 -1
- package/bundle/chunk-e5jk67xh.js +2 -0
- package/bundle/{chunk-ae7b11np.js → chunk-eacpc64g.js} +2 -2
- package/bundle/{chunk-hqjc4wgg.js → chunk-eewe7tx1.js} +2 -2
- package/bundle/{chunk-etv6c77a.js → chunk-eg1m81ax.js} +1 -1
- package/bundle/chunk-eg4pq4hv.js +2 -0
- package/bundle/{chunk-9xxnwb33.js → chunk-ejhhrece.js} +3 -3
- package/bundle/{chunk-nfzpegqx.js → chunk-epmc4aht.js} +1 -1
- package/bundle/chunk-ew3yz97p.js +2 -0
- package/bundle/chunk-ezgfhy4e.js +2 -0
- package/bundle/{chunk-19pspc1p.js → chunk-f2v4g7t1.js} +1 -1
- package/bundle/chunk-f2yfyhh8.js +2 -0
- package/bundle/chunk-f30em1wx.js +2 -0
- package/bundle/{chunk-k3g28tbw.js → chunk-f81kk8ra.js} +1 -1
- package/bundle/{chunk-p847g35y.js → chunk-f8cae1ap.js} +1 -1
- package/bundle/{chunk-vp3yf46q.js → chunk-fa8pwdwv.js} +1 -1
- package/bundle/{chunk-dz3bec8g.js → chunk-fej5x648.js} +1 -1
- package/bundle/{chunk-14d301ze.js → chunk-fge37dke.js} +1 -1
- package/bundle/{chunk-0tqmm8b8.js → chunk-fh3d0wce.js} +1 -1
- package/bundle/{chunk-twd6r7nf.js → chunk-fjftb2sz.js} +1 -1
- package/bundle/{chunk-xhh70g8j.js → chunk-fs1vb39f.js} +2 -2
- package/bundle/{chunk-9g9katgy.js → chunk-ftvvm4r5.js} +2 -2
- package/bundle/{chunk-ptwex14s.js → chunk-fw1f47de.js} +1 -1
- package/bundle/{chunk-y2t5pmqw.js → chunk-g26redah.js} +1 -1
- package/bundle/{chunk-acd72413.js → chunk-g3n465ee.js} +1 -1
- package/bundle/{chunk-hfefq104.js → chunk-g4tyaj0m.js} +1 -1
- package/bundle/{chunk-a610qd3x.js → chunk-g6y2c5az.js} +1 -1
- package/bundle/{chunk-tezrgfc6.js → chunk-g7v6sp3c.js} +2 -2
- package/bundle/{chunk-4bewbvvr.js → chunk-g878zd6e.js} +1 -1
- package/bundle/{chunk-na1wr2qf.js → chunk-g9nwqwqp.js} +1 -1
- package/bundle/chunk-gbvm6dpv.js +2 -0
- package/bundle/{chunk-ns8xnkjb.js → chunk-gc5rhnht.js} +1 -1
- package/bundle/{chunk-q6p92zyn.js → chunk-gefx3n08.js} +1 -1
- package/bundle/{chunk-xcxqt8ag.js → chunk-ggncq8w8.js} +1 -1
- package/bundle/{chunk-gwrnxcdn.js → chunk-gsg6zn7e.js} +1 -1
- package/bundle/{chunk-4jpab7ag.js → chunk-gznt3dv8.js} +1 -1
- package/bundle/{chunk-defj5zs6.js → chunk-h1bvqstw.js} +1 -1
- package/bundle/{chunk-dd4qnh8s.js → chunk-h4hs2rhf.js} +1 -1
- package/bundle/chunk-h5w91zr4.js +2 -0
- package/bundle/{chunk-qp3hxqg5.js → chunk-h8mfbbjh.js} +1 -1
- package/bundle/{chunk-w43kmnm9.js → chunk-he9kpk9r.js} +357 -357
- package/bundle/chunk-hmpb3c21.js +2 -0
- package/bundle/{chunk-6gqs1k7m.js → chunk-hz02vrqs.js} +1 -1
- package/bundle/{chunk-3xdmxm5t.js → chunk-j10a984e.js} +1 -1
- package/bundle/chunk-j32rr7rt.js +2 -0
- package/bundle/chunk-j871xzr7.js +2 -0
- package/bundle/{chunk-kfj37631.js → chunk-jmmtcr2r.js} +1 -1
- package/bundle/{chunk-h7658zxy.js → chunk-jpn9zfj5.js} +1 -1
- package/bundle/{chunk-wgt1tqw9.js → chunk-jqj1ay7x.js} +1 -1
- package/bundle/{chunk-e4g4mvak.js → chunk-jr80q31w.js} +1 -1
- package/bundle/chunk-k3hgwszx.js +2 -0
- package/bundle/{chunk-k6zwfstj.js → chunk-kckr30tf.js} +1 -1
- package/bundle/{chunk-8rfqv5he.js → chunk-kgv68cpb.js} +1 -1
- package/bundle/{chunk-tkzctbxq.js → chunk-khpfseej.js} +2 -2
- package/bundle/{chunk-55way0em.js → chunk-kveztc6k.js} +1 -1
- package/bundle/{chunk-znmbfx70.js → chunk-kwfe4em6.js} +1 -1
- package/bundle/chunk-kx88qekb.js +2 -0
- package/bundle/{chunk-nbckdba0.js → chunk-m4r8sepw.js} +1 -1
- package/bundle/{chunk-6ychs4wx.js → chunk-m7tmgvh6.js} +1 -1
- package/bundle/{chunk-egkhynj5.js → chunk-makegrxs.js} +1 -1
- package/bundle/{chunk-438faz6b.js → chunk-mr17tppa.js} +1 -1
- package/bundle/{chunk-yzpc5kj2.js → chunk-mv7q6ach.js} +1 -1
- package/bundle/chunk-n61e0znt.js +2 -0
- package/bundle/{chunk-kry4vcrf.js → chunk-n6tqtk6h.js} +2 -2
- package/bundle/chunk-n6v36np0.js +2 -0
- package/bundle/chunk-ndd4cn3z.js +2 -0
- package/bundle/{chunk-d1tb1jd0.js → chunk-nfafk3ts.js} +1 -1
- package/bundle/{chunk-b6eypnbj.js → chunk-nga216dm.js} +1 -1
- package/bundle/{chunk-qbrj9wzd.js → chunk-njsmma3a.js} +1 -1
- package/bundle/{chunk-bk7f59fn.js → chunk-ntr0ezf2.js} +1 -1
- package/bundle/chunk-nwj6mcxz.js +2 -0
- package/bundle/{chunk-cth373se.js → chunk-p2fte9vz.js} +2 -2
- package/bundle/chunk-p5b5ekhh.js +2 -0
- package/bundle/chunk-pf23nw4z.js +2 -0
- package/bundle/{chunk-whw18cn9.js → chunk-phf37x1c.js} +1 -1
- package/bundle/{chunk-r73e8gsp.js → chunk-phpxxd48.js} +1 -1
- package/bundle/{chunk-1ay97v74.js → chunk-pqg1wjb5.js} +1 -1
- package/bundle/chunk-pw3cv89g.js +2 -0
- package/bundle/{chunk-77h8tytk.js → chunk-q3c8mfbq.js} +1 -1
- package/bundle/{chunk-0am156m5.js → chunk-qbnt4ynd.js} +1 -1
- package/bundle/chunk-qc89yj61.js +2 -0
- package/bundle/{chunk-mjrqhbp2.js → chunk-qgek59e6.js} +1 -1
- package/bundle/{chunk-npzx3yd5.js → chunk-qgfbsmsx.js} +1 -1
- package/bundle/{chunk-v9w88wpy.js → chunk-qgkb6n8k.js} +1 -1
- package/bundle/{chunk-2c41dncf.js → chunk-qk1jkc0n.js} +1 -1
- package/bundle/{chunk-wb1d3mqw.js → chunk-qk5vy2pr.js} +1 -1
- package/bundle/chunk-qn8tz704.js +2 -0
- package/bundle/{chunk-9a6p1gdn.js → chunk-qq9m8fxv.js} +7 -7
- package/bundle/{chunk-5b3v1x2c.js → chunk-qxdpgdfk.js} +2 -2
- package/bundle/chunk-qxre2gqn.js +2 -0
- package/bundle/chunk-rdk62809.js +2 -0
- package/bundle/chunk-rew6r516.js +2 -0
- package/bundle/chunk-rjhvdfn5.js +2 -0
- package/bundle/chunk-rmsqb6r4.js +10 -0
- package/bundle/{chunk-qph2c2v7.js → chunk-rva2ekrt.js} +1 -1
- package/bundle/{chunk-7z96r2px.js → chunk-rwnwjm82.js} +1 -1
- package/bundle/{chunk-tz3s8dvy.js → chunk-rye1yjnr.js} +1 -1
- package/bundle/{chunk-t9qyzzsz.js → chunk-ryrxgn6d.js} +1 -1
- package/bundle/{chunk-wjz42325.js → chunk-s2tc3qs0.js} +2 -2
- package/bundle/{chunk-djqxbnwc.js → chunk-s8z7v1me.js} +1 -1
- package/bundle/{chunk-msh249db.js → chunk-sa0rrreh.js} +2 -2
- package/bundle/{chunk-dbpkq7ba.js → chunk-sbjymf20.js} +2 -2
- package/bundle/{chunk-n5p7cn4w.js → chunk-scnbt714.js} +1 -1
- package/bundle/chunk-skgr9ypq.js +2 -0
- package/bundle/{chunk-rhrcgvb8.js → chunk-sm1g81cv.js} +1 -1
- package/bundle/chunk-sv40pwe2.js +2 -0
- package/bundle/{chunk-qprbef09.js → chunk-sy9w1t2y.js} +1 -1
- package/bundle/{chunk-bd84t3fb.js → chunk-sz0favtz.js} +1 -1
- package/bundle/{chunk-xb3sxa6f.js → chunk-t18ka1e7.js} +1 -1
- package/bundle/{chunk-va2qfh0x.js → chunk-t3w43rft.js} +1 -1
- package/bundle/{chunk-n9twhc5d.js → chunk-t6zz47zk.js} +1 -1
- package/bundle/{chunk-wd8hbven.js → chunk-t8fjgkp8.js} +1 -1
- package/bundle/{chunk-6r48fje7.js → chunk-tbx741en.js} +1 -1
- package/bundle/chunk-tfhpjmny.js +2 -0
- package/bundle/chunk-tnete6ye.js +2 -0
- package/bundle/{chunk-2y87m7pe.js → chunk-tpyq7ycb.js} +1 -1
- package/bundle/{chunk-nftbj8g9.js → chunk-trstb8ee.js} +1 -1
- package/bundle/chunk-tsmj98yf.js +5 -0
- package/bundle/{chunk-skxg3s8z.js → chunk-txkdt4ep.js} +1 -1
- package/bundle/chunk-v5h5wxw5.js +2 -0
- package/bundle/chunk-v6141yq1.js +2 -0
- package/bundle/{chunk-vjn54xj5.js → chunk-vbfej8ds.js} +2 -2
- package/bundle/{chunk-9aafddkw.js → chunk-vfd3azkp.js} +1 -1
- package/bundle/chunk-vjs69r6x.js +2 -0
- package/bundle/{chunk-ts2k13g0.js → chunk-vkjqy92f.js} +1 -1
- package/bundle/chunk-vmhar83s.js +2 -0
- package/bundle/{chunk-zp5sr5nx.js → chunk-vph4w4yy.js} +1 -1
- package/bundle/chunk-vqvnw12p.js +2 -0
- package/bundle/{chunk-0g0jpw0z.js → chunk-vr8nwzp0.js} +1 -1
- package/bundle/{chunk-nrk29616.js → chunk-vs3s49jw.js} +1 -1
- package/bundle/{chunk-v0c3k797.js → chunk-vsqvnxbz.js} +1 -1
- package/bundle/{chunk-rqedtjz9.js → chunk-w0nc0gcx.js} +1 -1
- package/bundle/{chunk-y5q9v80n.js → chunk-w0sng8a9.js} +1 -1
- package/bundle/chunk-w0sztk4y.js +2 -0
- package/bundle/chunk-w6bb320d.js +2 -0
- package/bundle/{chunk-t8sy5sgx.js → chunk-w7a33cwa.js} +2 -2
- package/bundle/{chunk-2cjfezfr.js → chunk-w9qh2479.js} +1 -1
- package/bundle/{chunk-42q8vj0w.js → chunk-waa1ggtj.js} +1 -1
- package/bundle/{chunk-v3nmnm57.js → chunk-wb05bp10.js} +2 -2
- package/bundle/{chunk-agqss9ga.js → chunk-wb47k8ah.js} +2 -2
- package/bundle/{chunk-rfzra502.js → chunk-wd8f9r4k.js} +1 -1
- package/bundle/chunk-wf41m019.js +2 -0
- package/bundle/{chunk-hwsqqkrv.js → chunk-wgkcyqn1.js} +2 -2
- package/bundle/{chunk-dy2k5rdx.js → chunk-wm9nh9nb.js} +2 -2
- package/bundle/{chunk-6nxebcf8.js → chunk-wn63q3xp.js} +1 -1
- package/bundle/{chunk-z6kcnpsj.js → chunk-wqk1v8t0.js} +2 -2
- package/bundle/chunk-wqw6yjrg.js +2 -0
- package/bundle/{chunk-q3pt4p9f.js → chunk-wr6rnxr5.js} +1 -1
- package/bundle/chunk-ws08rxge.js +2 -0
- package/bundle/{chunk-dw7yrk1g.js → chunk-wtt5wms9.js} +1 -1
- package/bundle/{chunk-93pmbdz7.js → chunk-wtxh5m6j.js} +6 -6
- package/bundle/chunk-wz3dvc3g.js +2 -0
- package/bundle/{chunk-vzrc2fmt.js → chunk-x00hwy3x.js} +1 -1
- package/bundle/chunk-x2pmqvdc.js +2 -0
- package/bundle/chunk-x4wfq39v.js +2 -0
- package/bundle/{chunk-q6mcnq9p.js → chunk-xs6v0r9m.js} +1 -1
- package/bundle/{chunk-3623jvcm.js → chunk-xy8arehp.js} +1 -1
- package/bundle/{chunk-mhxyv9c8.js → chunk-y3gy62q5.js} +1 -1
- package/bundle/chunk-yb6m08zj.js +2 -0
- package/bundle/{chunk-b79z8f94.js → chunk-ybcqkgs7.js} +1 -1
- package/bundle/{chunk-95am490c.js → chunk-ydgst3h8.js} +2 -2
- package/bundle/{chunk-twfvrafb.js → chunk-ykpj10nz.js} +1 -1
- package/bundle/{chunk-e0zb6sw6.js → chunk-ynf17943.js} +1 -1
- package/bundle/{chunk-yy7r3t3w.js → chunk-ytyzrqev.js} +1 -1
- package/bundle/{chunk-01e3v1xz.js → chunk-z0kbyr00.js} +2 -2
- package/bundle/{chunk-4vzjdmts.js → chunk-zfrftgcy.js} +1 -1
- package/bundle/chunk-zj1jc1xt.js +2 -0
- package/bundle/{chunk-9sv53kb4.js → chunk-zm0m0504.js} +1 -1
- package/bundle/{chunk-gdj7mqrd.js → chunk-zqdjk4rf.js} +1 -1
- package/bundle/{chunk-7x2q1w0f.js → chunk-zsg29gba.js} +1 -1
- package/bundle/{chunk-1c0yp2gv.js → chunk-zwhmg9dj.js} +1 -1
- package/bundle/index.js +3 -3
- package/bundle/parser.worker.js +2 -2
- package/bundle/worker.js +1 -1
- package/package.json +1 -1
- package/bundle/chunk-0dzpjk7x.js +0 -2
- package/bundle/chunk-12fwmmcp.js +0 -2
- package/bundle/chunk-1a95ysv3.js +0 -2
- package/bundle/chunk-1akh8pk2.js +0 -2
- package/bundle/chunk-2d2a92kj.js +0 -2
- package/bundle/chunk-2qrvkef8.js +0 -2
- package/bundle/chunk-2tppw8j9.js +0 -2
- package/bundle/chunk-3ft1dn9j.js +0 -2
- package/bundle/chunk-3rgct4bd.js +0 -11
- package/bundle/chunk-4656qm05.js +0 -2
- package/bundle/chunk-46knch5z.js +0 -2
- package/bundle/chunk-4sgy87h5.js +0 -2
- package/bundle/chunk-54hktc8h.js +0 -2
- package/bundle/chunk-59m55866.js +0 -2
- package/bundle/chunk-5js5nw7r.js +0 -2
- package/bundle/chunk-61jn7908.js +0 -2
- package/bundle/chunk-61txdqz1.js +0 -2
- package/bundle/chunk-668g9wkg.js +0 -2
- package/bundle/chunk-6frhjpmt.js +0 -2
- package/bundle/chunk-6k14c8x1.js +0 -5
- package/bundle/chunk-6r1jpj0h.js +0 -2
- package/bundle/chunk-73fn4dqd.js +0 -2
- package/bundle/chunk-78j2c2je.js +0 -2
- package/bundle/chunk-78jt24ht.js +0 -2
- package/bundle/chunk-7j2vpavd.js +0 -2
- package/bundle/chunk-7nkxgm72.js +0 -2
- package/bundle/chunk-859pkecc.js +0 -2
- package/bundle/chunk-8p249svd.js +0 -2
- package/bundle/chunk-8rqbx4jw.js +0 -2
- package/bundle/chunk-8s3krfsm.js +0 -2
- package/bundle/chunk-9wbe0dkx.js +0 -2
- package/bundle/chunk-aj5z8qd5.js +0 -2
- package/bundle/chunk-b0c2mvc0.js +0 -2
- package/bundle/chunk-bbwcsdy9.js +0 -2
- package/bundle/chunk-bbzjdbb9.js +0 -2
- package/bundle/chunk-bh4s1yct.js +0 -2
- package/bundle/chunk-crqcppwq.js +0 -2
- package/bundle/chunk-d09zpgj1.js +0 -2
- package/bundle/chunk-dexcptaz.js +0 -3
- package/bundle/chunk-dgqkak21.js +0 -2
- package/bundle/chunk-dhgvh7c3.js +0 -2
- package/bundle/chunk-dmd101ja.js +0 -2
- package/bundle/chunk-dwb39jdf.js +0 -2
- package/bundle/chunk-dx4zxex7.js +0 -2
- package/bundle/chunk-e2pqvscp.js +0 -2
- package/bundle/chunk-efe6kj3d.js +0 -2
- package/bundle/chunk-emac0dss.js +0 -2
- package/bundle/chunk-encfnt6w.js +0 -2
- package/bundle/chunk-fg2nyz2x.js +0 -2
- package/bundle/chunk-ge19ff9d.js +0 -2
- package/bundle/chunk-gt0q07xq.js +0 -2
- package/bundle/chunk-h4dnjfr2.js +0 -2
- package/bundle/chunk-h8fx619t.js +0 -2
- package/bundle/chunk-jnvb3s7f.js +0 -2
- package/bundle/chunk-jrq2xw6e.js +0 -2
- package/bundle/chunk-jwckmhjm.js +0 -2
- package/bundle/chunk-jz27ypm5.js +0 -2
- package/bundle/chunk-jzrs878d.js +0 -2
- package/bundle/chunk-jzx700tb.js +0 -2
- package/bundle/chunk-k1x8469r.js +0 -3
- package/bundle/chunk-m483jvn8.js +0 -2
- package/bundle/chunk-menbcmkq.js +0 -2
- package/bundle/chunk-np8h66t0.js +0 -2
- package/bundle/chunk-nwwmns3w.js +0 -2
- package/bundle/chunk-pe5dpzec.js +0 -2
- package/bundle/chunk-q8f6a074.js +0 -2
- package/bundle/chunk-qqaevt32.js +0 -2
- package/bundle/chunk-qzpvz708.js +0 -2
- package/bundle/chunk-reyjr2e0.js +0 -2
- package/bundle/chunk-t178njgb.js +0 -2
- package/bundle/chunk-tjpev5t6.js +0 -2
- package/bundle/chunk-tzq7wjgv.js +0 -3
- package/bundle/chunk-v1s16wwd.js +0 -2
- package/bundle/chunk-v6b29nx4.js +0 -2
- package/bundle/chunk-v6rgd1j5.js +0 -2
- package/bundle/chunk-v9dnetq8.js +0 -2
- package/bundle/chunk-vd5mpvcc.js +0 -2
- package/bundle/chunk-wwct4z7j.js +0 -2
- package/bundle/chunk-xr9wz961.js +0 -2
- package/bundle/chunk-zfegnt1e.js +0 -2
- package/bundle/chunk-zg7kesbp.js +0 -2
- package/bundle/chunk-zy06fe4r.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jr as yZ,Kr as N0,Lr as ZQ,Mr as ZJ,Nr as p0,Or as n0,Pr as i0,Rr as s0,Sr as o0}from"./chunk-ae7b11np.js";import{Tr as AQ,Ur as E}from"./chunk-eeq0krp7.js";import{$F as XQ,BD as $Q,BG as c0,BH as S0,DP as L0,EP as P0,FG as r,JG as u,KH as JJ,MC as O0,MD as _0,OG as g,SC as D0,SH as QJ,VF as NJ,VG as y0,WF as PJ,YF as d0,ZF as l0,_F as m0,aG as u0,eB as g0,eE as E0,hG as A0,nH as t,pH as e,uP as C0,vB as h0,yF as k0,zD as WQ,zF as I0,zG as x0}from"./chunk-tezrgfc6.js";import{RP as M}from"./chunk-kry4vcrf.js";import{SP as d,TP as K,WP as TJ}from"./chunk-f2pv705d.js";var bJ=K((GQ)=>{Object.defineProperty(GQ,"__esModule",{value:!0});GQ.AbstractAsyncHooksContextManager=void 0;var t0=TJ("events"),e0=["addListener","on","once","prependListener","prependOnceListener"];class KQ{bind(J,Q){if(Q instanceof t0.EventEmitter)return this._bindEventEmitter(J,Q);if(typeof Q==="function")return this._bindFunction(J,Q);return Q}_bindFunction(J,Q){let Z=this,$=function(...q){return Z.with(J,()=>Q.apply(this,q))};return Object.defineProperty($,"length",{enumerable:!1,configurable:!0,writable:!1,value:Q.length}),$}_bindEventEmitter(J,Q){if(this._getPatchMap(Q)!==void 0)return Q;if(this._createPatchMap(Q),e0.forEach(($)=>{if(Q[$]===void 0)return;Q[$]=this._patchAddListener(Q,Q[$],J)}),typeof Q.removeListener==="function")Q.removeListener=this._patchRemoveListener(Q,Q.removeListener);if(typeof Q.off==="function")Q.off=this._patchRemoveListener(Q,Q.off);if(typeof Q.removeAllListeners==="function")Q.removeAllListeners=this._patchRemoveAllListeners(Q,Q.removeAllListeners);return Q}_patchRemoveListener(J,Q){let Z=this;return function($,q){let W=Z._getPatchMap(J)?.[$];if(W===void 0)return Q.call(this,$,q);let X=W.get(q);return Q.call(this,$,X||q)}}_patchRemoveAllListeners(J,Q){let Z=this;return function($){let q=Z._getPatchMap(J);if(q!==void 0){if(arguments.length===0)Z._createPatchMap(J);else if(q[$]!==void 0)delete q[$]}return Q.apply(this,arguments)}}_patchAddListener(J,Q,Z){let $=this;return function(q,W){if($._wrapped)return Q.call(this,q,W);let X=$._getPatchMap(J);if(X===void 0)X=$._createPatchMap(J);let H=X[q];if(H===void 0)H=new WeakMap,X[q]=H;let Y=$.bind(Z,W);H.set(W,Y),$._wrapped=!0;try{return Q.call(this,q,Y)}finally{$._wrapped=!1}}}_createPatchMap(J){let Q=Object.create(null);return J[this._kOtListeners]=Q,Q}_getPatchMap(J){return J[this._kOtListeners]}_kOtListeners=Symbol("OtListeners");_wrapped=!1}GQ.AbstractAsyncHooksContextManager=KQ});var jQ=K((UQ)=>{Object.defineProperty(UQ,"__esModule",{value:!0});UQ.AsyncHooksContextManager=void 0;var J6=M(),Q6=TJ("async_hooks"),Z6=bJ();class VQ extends Z6.AbstractAsyncHooksContextManager{_asyncHook;_contexts=new Map;_stack=[];constructor(){super();this._asyncHook=Q6.createHook({init:this._init.bind(this),before:this._before.bind(this),after:this._after.bind(this),destroy:this._destroy.bind(this),promiseResolve:this._destroy.bind(this)})}active(){return this._stack[this._stack.length-1]??J6.ROOT_CONTEXT}with(J,Q,Z,...$){this._enterContext(J);try{return Q.call(Z,...$)}finally{this._exitContext()}}enable(){return this._asyncHook.enable(),this}disable(){return this._asyncHook.disable(),this._contexts.clear(),this._stack=[],this}_init(J,Q){if(Q==="TIMERWRAP")return;let Z=this._stack[this._stack.length-1];if(Z!==void 0)this._contexts.set(J,Z)}_destroy(J){this._contexts.delete(J)}_before(J){let Q=this._contexts.get(J);if(Q!==void 0)this._enterContext(Q)}_after(){this._exitContext()}_enterContext(J){this._stack.push(J)}_exitContext(){this._stack.pop()}}UQ.AsyncHooksContextManager=VQ});var DQ=K((hQ)=>{Object.defineProperty(hQ,"__esModule",{value:!0});hQ.AsyncLocalStorageContextManager=void 0;var $6=M(),q6=TJ("async_hooks"),W6=bJ();class FQ extends W6.AbstractAsyncHooksContextManager{_asyncLocalStorage;constructor(){super();this._asyncLocalStorage=new q6.AsyncLocalStorage}active(){return this._asyncLocalStorage.getStore()??$6.ROOT_CONTEXT}with(J,Q,Z,...$){let q=Z==null?Q:Q.bind(Z);return this._asyncLocalStorage.run(J,q,...$)}enable(){return this}disable(){return this._asyncLocalStorage.disable(),this}}hQ.AsyncLocalStorageContextManager=FQ});var EQ=K((GJ)=>{Object.defineProperty(GJ,"__esModule",{value:!0});GJ.AsyncLocalStorageContextManager=GJ.AsyncHooksContextManager=void 0;var z6=jQ();Object.defineProperty(GJ,"AsyncHooksContextManager",{enumerable:!0,get:function(){return z6.AsyncHooksContextManager}});var X6=DQ();Object.defineProperty(GJ,"AsyncLocalStorageContextManager",{enumerable:!0,get:function(){return X6.AsyncLocalStorageContextManager}})});var MQ=K((kQ)=>{Object.defineProperty(kQ,"__esModule",{value:!0});kQ.ExceptionEventName=void 0;kQ.ExceptionEventName="exception"});var PQ=K((CQ)=>{Object.defineProperty(CQ,"__esModule",{value:!0});CQ.SpanImpl=void 0;var h=M(),O=E(),m=AQ(),H6=MQ();class RQ{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:h.SpanStatusCode.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(J){let Q=Date.now();if(this._spanContext=J.spanContext,this._performanceStartTime=O.otperformance.now(),this._performanceOffset=Q-(this._performanceStartTime+O.otperformance.timeOrigin),this._startTimeProvided=J.startTime!=null,this._spanLimits=J.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=J.spanProcessor,this.name=J.name,this.parentSpanContext=J.parentSpanContext,this.kind=J.kind,J.links)for(let Z of J.links)this.addLink(Z);if(this.startTime=this._getTime(J.startTime??Q),this.resource=J.resource,this.instrumentationScope=J.scope,this._recordEndMetrics=J.recordEndMetrics,J.attributes!=null)this.setAttributes(J.attributes);this._spanProcessor.onStart(this,J.context)}spanContext(){return this._spanContext}setAttribute(J,Q){if(Q==null||this._isSpanEnded())return this;if(J.length===0)return h.diag.warn(`Invalid attribute key: ${J}`),this;if(!(0,O.isAttributeValue)(Q))return h.diag.warn(`Invalid attribute value set for key: ${J}`),this;let{attributeCountLimit:Z}=this._spanLimits,$=!Object.prototype.hasOwnProperty.call(this.attributes,J);if(Z!==void 0&&this._attributesCount>=Z&&$)return this._droppedAttributesCount++,this;if(this.attributes[J]=this._truncateToSize(Q),$)this._attributesCount++;return this}setAttributes(J){for(let Q in J)if(Object.prototype.hasOwnProperty.call(J,Q))this.setAttribute(Q,J[Q]);return this}addEvent(J,Q,Z){if(this._isSpanEnded())return this;let{eventCountLimit:$}=this._spanLimits;if($===0)return h.diag.warn("No events allowed."),this._droppedEventsCount++,this;if($!==void 0&&this.events.length>=$){if(this._droppedEventsCount===0)h.diag.debug("Dropping extra events.");this.events.shift(),this._droppedEventsCount++}if((0,O.isTimeInput)(Q)){if(!(0,O.isTimeInput)(Z))Z=Q;Q=void 0}let q=(0,O.sanitizeAttributes)(Q),{attributePerEventCountLimit:W}=this._spanLimits,X={},H=0,Y=0;for(let V in q){if(!Object.prototype.hasOwnProperty.call(q,V))continue;let R=q[V];if(W!==void 0&&Y>=W){H++;continue}X[V]=this._truncateToSize(R),Y++}return this.events.push({name:J,attributes:X,time:this._getTime(Z),droppedAttributesCount:H}),this}addLink(J){if(this._isSpanEnded())return this;let{linkCountLimit:Q}=this._spanLimits;if(Q===0)return this._droppedLinksCount++,this;if(Q!==void 0&&this.links.length>=Q){if(this._droppedLinksCount===0)h.diag.debug("Dropping extra links.");this.links.shift(),this._droppedLinksCount++}let{attributePerLinkCountLimit:Z}=this._spanLimits,$=(0,O.sanitizeAttributes)(J.attributes),q={},W=0,X=0;for(let Y in $){if(!Object.prototype.hasOwnProperty.call($,Y))continue;let V=$[Y];if(Z!==void 0&&X>=Z){W++;continue}q[Y]=this._truncateToSize(V),X++}let H={context:J.context};if(X>0)H.attributes=q;if(W>0)H.droppedAttributesCount=W;return this.links.push(H),this}addLinks(J){for(let Q of J)this.addLink(Q);return this}setStatus(J){if(this._isSpanEnded())return this;if(J.code===h.SpanStatusCode.UNSET)return this;if(this.status.code===h.SpanStatusCode.OK)return this;let Q={code:J.code};if(J.code===h.SpanStatusCode.ERROR){if(typeof J.message==="string")Q.message=J.message;else if(J.message!=null)h.diag.warn(`Dropping invalid status.message of type '${typeof J.message}', expected 'string'`)}return this.status=Q,this}updateName(J){if(this._isSpanEnded())return this;return this.name=J,this}end(J){if(this._isSpanEnded()){h.diag.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}if(this.endTime=this._getTime(J),this._duration=(0,O.hrTimeDuration)(this.startTime,this.endTime),this._duration[0]<0)h.diag.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.",this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0];if(this._droppedEventsCount>0)h.diag.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`);if(this._droppedLinksCount>0)h.diag.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`);if(this._spanProcessor.onEnding)this._spanProcessor.onEnding(this);this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(J){if(typeof J==="number"&&J<=O.otperformance.now())return(0,O.hrTime)(J+this._performanceOffset);if(typeof J==="number")return(0,O.millisToHrTime)(J);if(J instanceof Date)return(0,O.millisToHrTime)(J.getTime());if((0,O.isTimeInputHrTime)(J))return J;if(this._startTimeProvided)return(0,O.millisToHrTime)(Date.now());let Q=O.otperformance.now()-this._performanceStartTime;return(0,O.addHrTimes)(this.startTime,(0,O.millisToHrTime)(Q))}isRecording(){return this._ended===!1}recordException(J,Q){let Z={};if(typeof J==="string")Z[m.ATTR_EXCEPTION_MESSAGE]=J;else if(J){if(J.code)Z[m.ATTR_EXCEPTION_TYPE]=J.code.toString();else if(J.name)Z[m.ATTR_EXCEPTION_TYPE]=J.name;if(J.message)Z[m.ATTR_EXCEPTION_MESSAGE]=J.message;if(J.stack)Z[m.ATTR_EXCEPTION_STACKTRACE]=J.stack}if(Z[m.ATTR_EXCEPTION_TYPE]||Z[m.ATTR_EXCEPTION_MESSAGE])this.addEvent(H6.ExceptionEventName,Z,Q);else h.diag.warn(`Failed to record an exception ${J}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let J=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);h.diag.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,J)}return this._ended}_truncateToLimitUtil(J,Q){if(J.length<=Q)return J;return J.substring(0,Q)}_truncateToSize(J){let Q=this._attributeValueLengthLimit;if(Q<=0)return h.diag.warn(`Attribute value limit must be positive, got ${Q}`),J;if(typeof J==="string")return this._truncateToLimitUtil(J,Q);if(Array.isArray(J))return J.map((Z)=>typeof Z==="string"?this._truncateToLimitUtil(Z,Q):Z);return J}}CQ.SpanImpl=RQ});var i=K((NQ)=>{Object.defineProperty(NQ,"__esModule",{value:!0});NQ.SamplingDecision=void 0;var K6;(function(J){J[J.NOT_RECORD=0]="NOT_RECORD",J[J.RECORD=1]="RECORD",J[J.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(K6=NQ.SamplingDecision||(NQ.SamplingDecision={}))});var wJ=K((TQ)=>{Object.defineProperty(TQ,"__esModule",{value:!0});TQ.AlwaysOffSampler=void 0;var G6=i();class fQ{shouldSample(){return{decision:G6.SamplingDecision.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}TQ.AlwaysOffSampler=fQ});var VJ=K((xQ)=>{Object.defineProperty(xQ,"__esModule",{value:!0});xQ.AlwaysOnSampler=void 0;var w6=i();class _Q{shouldSample(){return{decision:w6.SamplingDecision.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}xQ.AlwaysOnSampler=_Q});var dJ=K((vQ)=>{Object.defineProperty(vQ,"__esModule",{value:!0});vQ.ParentBasedSampler=void 0;var UJ=M(),V6=E(),yQ=wJ(),xJ=VJ();class SQ{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(J){if(this._root=J.root,!this._root)(0,V6.globalErrorHandler)(Error("ParentBasedSampler must have a root sampler configured")),this._root=new xJ.AlwaysOnSampler;this._remoteParentSampled=J.remoteParentSampled??new xJ.AlwaysOnSampler,this._remoteParentNotSampled=J.remoteParentNotSampled??new yQ.AlwaysOffSampler,this._localParentSampled=J.localParentSampled??new xJ.AlwaysOnSampler,this._localParentNotSampled=J.localParentNotSampled??new yQ.AlwaysOffSampler}shouldSample(J,Q,Z,$,q,W){let X=UJ.trace.getSpanContext(J);if(!X||!(0,UJ.isSpanContextValid)(X))return this._root.shouldSample(J,Q,Z,$,q,W);if(X.isRemote){if(X.traceFlags&UJ.TraceFlags.SAMPLED)return this._remoteParentSampled.shouldSample(J,Q,Z,$,q,W);return this._remoteParentNotSampled.shouldSample(J,Q,Z,$,q,W)}if(X.traceFlags&UJ.TraceFlags.SAMPLED)return this._localParentSampled.shouldSample(J,Q,Z,$,q,W);return this._localParentNotSampled.shouldSample(J,Q,Z,$,q,W)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}vQ.ParentBasedSampler=SQ});var yJ=K((uQ)=>{Object.defineProperty(uQ,"__esModule",{value:!0});uQ.TraceIdRatioBasedSampler=void 0;var U6=M(),lQ=i();class mQ{_ratio;_upperBound;constructor(J=0){this._ratio=this._normalize(J),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(J,Q){return{decision:(0,U6.isValidTraceId)(Q)&&this._accumulate(Q)<this._upperBound?lQ.SamplingDecision.RECORD_AND_SAMPLED:lQ.SamplingDecision.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(J){if(typeof J!=="number"||isNaN(J))return 0;return J>=1?1:J<=0?0:J}_accumulate(J){let Q=0;for(let Z=0;Z<J.length/8;Z++){let $=Z*8,q=parseInt(J.slice($,$+8),16);Q=(Q^q)>>>0}return Q}}uQ.TraceIdRatioBasedSampler=mQ});var gJ=K((oQ)=>{Object.defineProperty(oQ,"__esModule",{value:!0});oQ.buildSamplerFromEnv=oQ.loadDefaultConfig=void 0;var vJ=M(),_=E(),pQ=wJ(),SJ=VJ(),BJ=dJ(),nQ=yJ(),x;(function(J){J.AlwaysOff="always_off",J.AlwaysOn="always_on",J.ParentBasedAlwaysOff="parentbased_always_off",J.ParentBasedAlwaysOn="parentbased_always_on",J.ParentBasedTraceIdRatio="parentbased_traceidratio",J.TraceIdRatio="traceidratio"})(x||(x={}));var jJ=1;function B6(){return{sampler:sQ(),forceFlushTimeoutMillis:30000,generalLimits:{attributeValueLengthLimit:(0,_.getNumberFromEnv)("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")??1/0,attributeCountLimit:(0,_.getNumberFromEnv)("OTEL_ATTRIBUTE_COUNT_LIMIT")??128},spanLimits:{attributeValueLengthLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT")??1/0,attributeCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT")??128,linkCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_LINK_COUNT_LIMIT")??128,eventCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_EVENT_COUNT_LIMIT")??128,attributePerEventCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT")??128,attributePerLinkCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT")??128}}}oQ.loadDefaultConfig=B6;function sQ(){let J=(0,_.getStringFromEnv)("OTEL_TRACES_SAMPLER")??x.ParentBasedAlwaysOn;switch(J){case x.AlwaysOn:return new SJ.AlwaysOnSampler;case x.AlwaysOff:return new pQ.AlwaysOffSampler;case x.ParentBasedAlwaysOn:return new BJ.ParentBasedSampler({root:new SJ.AlwaysOnSampler});case x.ParentBasedAlwaysOff:return new BJ.ParentBasedSampler({root:new pQ.AlwaysOffSampler});case x.TraceIdRatio:return new nQ.TraceIdRatioBasedSampler(iQ());case x.ParentBasedTraceIdRatio:return new BJ.ParentBasedSampler({root:new nQ.TraceIdRatioBasedSampler(iQ())});default:return vJ.diag.error(`OTEL_TRACES_SAMPLER value "${J}" invalid, defaulting to "${x.ParentBasedAlwaysOn}".`),new BJ.ParentBasedSampler({root:new SJ.AlwaysOnSampler})}}oQ.buildSamplerFromEnv=sQ;function iQ(){let J=(0,_.getNumberFromEnv)("OTEL_TRACES_SAMPLER_ARG");if(J==null)return vJ.diag.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${jJ}.`),jJ;if(J<0||J>1)return vJ.diag.error(`OTEL_TRACES_SAMPLER_ARG=${J} was given, but it is out of range ([0..1]), defaulting to ${jJ}.`),jJ;return J}});var lJ=K((tQ)=>{Object.defineProperty(tQ,"__esModule",{value:!0});tQ.reconfigureLimits=tQ.mergeConfig=tQ.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT=tQ.DEFAULT_ATTRIBUTE_COUNT_LIMIT=void 0;var rQ=gJ(),FJ=E();tQ.DEFAULT_ATTRIBUTE_COUNT_LIMIT=128;tQ.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT=1/0;function F6(J){let Q={sampler:(0,rQ.buildSamplerFromEnv)()},Z=(0,rQ.loadDefaultConfig)(),$=Object.assign({},Z,Q,J);return $.generalLimits=Object.assign({},Z.generalLimits,J.generalLimits||{}),$.spanLimits=Object.assign({},Z.spanLimits,J.spanLimits||{}),$}tQ.mergeConfig=F6;function h6(J){let Q=Object.assign({},J.spanLimits);return Q.attributeCountLimit=J.spanLimits?.attributeCountLimit??J.generalLimits?.attributeCountLimit??(0,FJ.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT")??(0,FJ.getNumberFromEnv)("OTEL_ATTRIBUTE_COUNT_LIMIT")??tQ.DEFAULT_ATTRIBUTE_COUNT_LIMIT,Q.attributeValueLengthLimit=J.spanLimits?.attributeValueLengthLimit??J.generalLimits?.attributeValueLengthLimit??(0,FJ.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT")??(0,FJ.getNumberFromEnv)("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")??tQ.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,Object.assign({},J,{spanLimits:Q})}tQ.reconfigureLimits=h6});var WZ=K(($Z)=>{Object.defineProperty($Z,"__esModule",{value:!0});$Z.BatchSpanProcessorBase=void 0;var s=M(),S=E();class ZZ{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(J,Q){if(this._exporter=J,this._maxExportBatchSize=typeof Q?.maxExportBatchSize==="number"?Q.maxExportBatchSize:(0,S.getNumberFromEnv)("OTEL_BSP_MAX_EXPORT_BATCH_SIZE")??512,this._maxQueueSize=typeof Q?.maxQueueSize==="number"?Q.maxQueueSize:(0,S.getNumberFromEnv)("OTEL_BSP_MAX_QUEUE_SIZE")??2048,this._scheduledDelayMillis=typeof Q?.scheduledDelayMillis==="number"?Q.scheduledDelayMillis:(0,S.getNumberFromEnv)("OTEL_BSP_SCHEDULE_DELAY")??5000,this._exportTimeoutMillis=typeof Q?.exportTimeoutMillis==="number"?Q.exportTimeoutMillis:(0,S.getNumberFromEnv)("OTEL_BSP_EXPORT_TIMEOUT")??30000,this._shutdownOnce=new S.BindOnceFuture(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize)s.diag.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize}forceFlush(){if(this._shutdownOnce.isCalled)return this._shutdownOnce.promise;return this._flushAll()}onStart(J,Q){}onEnd(J){if(this._shutdownOnce.isCalled)return;if((J.spanContext().traceFlags&s.TraceFlags.SAMPLED)===0)return;this._addToBuffer(J)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>{return this.onShutdown()}).then(()=>{return this._flushAll()}).then(()=>{return this._exporter.shutdown()})}_addToBuffer(J){if(this._finishedSpans.length>=this._maxQueueSize){if(this._droppedSpansCount===0)s.diag.debug("maxQueueSize reached, dropping spans");this._droppedSpansCount++;return}if(this._droppedSpansCount>0)s.diag.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0;this._finishedSpans.push(J),this._maybeStartTimer()}_flushAll(){return new Promise((J,Q)=>{let Z=[],$=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let q=0,W=$;q<W;q++)Z.push(this._flushOneBatch());Promise.all(Z).then(()=>{J()}).catch(Q)})}_flushOneBatch(){if(this._clearTimer(),this._finishedSpans.length===0)return Promise.resolve();return new Promise((J,Q)=>{let Z=setTimeout(()=>{Q(Error("Timeout"))},this._exportTimeoutMillis);s.context.with((0,S.suppressTracing)(s.context.active()),()=>{let $;if(this._finishedSpans.length<=this._maxExportBatchSize)$=this._finishedSpans,this._finishedSpans=[];else $=this._finishedSpans.splice(0,this._maxExportBatchSize);let q=()=>this._exporter.export($,(X)=>{if(clearTimeout(Z),X.code===S.ExportResultCode.SUCCESS)J();else Q(X.error??Error("BatchSpanProcessor: span export failed"))}),W=null;for(let X=0,H=$.length;X<H;X++){let Y=$[X];if(Y.resource.asyncAttributesPending&&Y.resource.waitForAsyncAttributes)W??=[],W.push(Y.resource.waitForAsyncAttributes())}if(W===null)q();else Promise.all(W).then(q,(X)=>{(0,S.globalErrorHandler)(X),Q(X)})})})}_maybeStartTimer(){if(this._isExporting)return;let J=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{if(this._isExporting=!1,this._finishedSpans.length>0)this._clearTimer(),this._maybeStartTimer()}).catch((Q)=>{this._isExporting=!1,(0,S.globalErrorHandler)(Q)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return J();if(this._timer!==void 0)return;if(this._timer=setTimeout(()=>J(),this._scheduledDelayMillis),typeof this._timer!=="number")this._timer.unref()}_clearTimer(){if(this._timer!==void 0)clearTimeout(this._timer),this._timer=void 0}}$Z.BatchSpanProcessorBase=ZZ});var HZ=K((XZ)=>{Object.defineProperty(XZ,"__esModule",{value:!0});XZ.BatchSpanProcessor=void 0;var D6=WZ();class zZ extends D6.BatchSpanProcessorBase{onShutdown(){}}XZ.BatchSpanProcessor=zZ});var BZ=K((VZ)=>{Object.defineProperty(VZ,"__esModule",{value:!0});VZ.RandomIdGenerator=void 0;var E6=8,GZ=16;class wZ{generateTraceId=KZ(GZ);generateSpanId=KZ(E6)}VZ.RandomIdGenerator=wZ;var hJ=Buffer.allocUnsafe(GZ);function KZ(J){return function(){for(let Z=0;Z<J/4;Z++)hJ.writeUInt32BE(Math.random()*4294967296>>>0,Z*4);for(let Z=0;Z<J;Z++)if(hJ[Z]>0)break;else if(Z===J-1)hJ[J-1]=1;return hJ.toString("hex",0,J)}}});var jZ=K((OJ)=>{Object.defineProperty(OJ,"__esModule",{value:!0});OJ.RandomIdGenerator=OJ.BatchSpanProcessor=void 0;var k6=HZ();Object.defineProperty(OJ,"BatchSpanProcessor",{enumerable:!0,get:function(){return k6.BatchSpanProcessor}});var I6=BZ();Object.defineProperty(OJ,"RandomIdGenerator",{enumerable:!0,get:function(){return I6.RandomIdGenerator}})});var mJ=K((DJ)=>{Object.defineProperty(DJ,"__esModule",{value:!0});DJ.RandomIdGenerator=DJ.BatchSpanProcessor=void 0;var FZ=jZ();Object.defineProperty(DJ,"BatchSpanProcessor",{enumerable:!0,get:function(){return FZ.BatchSpanProcessor}});Object.defineProperty(DJ,"RandomIdGenerator",{enumerable:!0,get:function(){return FZ.RandomIdGenerator}})});var DZ=K((hZ)=>{Object.defineProperty(hZ,"__esModule",{value:!0});hZ.METRIC_OTEL_SDK_SPAN_STARTED=hZ.METRIC_OTEL_SDK_SPAN_LIVE=hZ.ATTR_OTEL_SPAN_SAMPLING_RESULT=hZ.ATTR_OTEL_SPAN_PARENT_ORIGIN=void 0;hZ.ATTR_OTEL_SPAN_PARENT_ORIGIN="otel.span.parent.origin";hZ.ATTR_OTEL_SPAN_SAMPLING_RESULT="otel.span.sampling_result";hZ.METRIC_OTEL_SDK_SPAN_LIVE="otel.sdk.span.live";hZ.METRIC_OTEL_SDK_SPAN_STARTED="otel.sdk.span.started"});var MZ=K((kZ)=>{Object.defineProperty(kZ,"__esModule",{value:!0});kZ.TracerMetrics=void 0;var EJ=i(),qJ=DZ();class EZ{startedSpans;liveSpans;constructor(J){this.startedSpans=J.createCounter(qJ.METRIC_OTEL_SDK_SPAN_STARTED,{unit:"{span}",description:"The number of created spans."}),this.liveSpans=J.createUpDownCounter(qJ.METRIC_OTEL_SDK_SPAN_LIVE,{unit:"{span}",description:"The number of currently live spans."})}startSpan(J,Q){let Z=N6(Q);if(this.startedSpans.add(1,{[qJ.ATTR_OTEL_SPAN_PARENT_ORIGIN]:P6(J),[qJ.ATTR_OTEL_SPAN_SAMPLING_RESULT]:Z}),Q===EJ.SamplingDecision.NOT_RECORD)return()=>{};let $={[qJ.ATTR_OTEL_SPAN_SAMPLING_RESULT]:Z};return this.liveSpans.add(1,$),()=>{this.liveSpans.add(-1,$)}}}kZ.TracerMetrics=EZ;function P6(J){if(!J)return"none";if(J.isRemote)return"remote";return"local"}function N6(J){switch(J){case EJ.SamplingDecision.RECORD_AND_SAMPLED:return"RECORD_AND_SAMPLE";case EJ.SamplingDecision.RECORD:return"RECORD_ONLY";case EJ.SamplingDecision.NOT_RECORD:return"DROP"}}});var CZ=K((AZ)=>{Object.defineProperty(AZ,"__esModule",{value:!0});AZ.VERSION=void 0;AZ.VERSION="2.6.1"});var fZ=K((PZ)=>{Object.defineProperty(PZ,"__esModule",{value:!0});PZ.Tracer=void 0;var F=M(),kJ=E(),f6=PQ(),T6=lJ(),b6=mJ(),_6=MZ(),x6=CZ();class LZ{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(J,Q,Z,$){let q=(0,T6.mergeConfig)(Q);this._sampler=q.sampler,this._generalLimits=q.generalLimits,this._spanLimits=q.spanLimits,this._idGenerator=Q.idGenerator||new b6.RandomIdGenerator,this._resource=Z,this._spanProcessor=$,this.instrumentationScope=J;let W=q.meterProvider?q.meterProvider.getMeter("@opentelemetry/sdk-trace",x6.VERSION):F.createNoopMeter();this._tracerMetrics=new _6.TracerMetrics(W)}startSpan(J,Q={},Z=F.context.active()){if(Q.root)Z=F.trace.deleteSpan(Z);let $=F.trace.getSpan(Z);if((0,kJ.isTracingSuppressed)(Z))return F.diag.debug("Instrumentation suppressed, returning Noop Span"),F.trace.wrapSpanContext(F.INVALID_SPAN_CONTEXT);let q=$?.spanContext(),W=this._idGenerator.generateSpanId(),X,H,Y;if(!q||!F.trace.isSpanContextValid(q))H=this._idGenerator.generateTraceId();else H=q.traceId,Y=q.traceState,X=q;let V=Q.kind??F.SpanKind.INTERNAL,R=(Q.links??[]).map((D)=>{return{context:D.context,attributes:(0,kJ.sanitizeAttributes)(D.attributes)}}),z=(0,kJ.sanitizeAttributes)(Q.attributes),U=this._sampler.shouldSample(Z,H,J,V,z,R),I=this._tracerMetrics.startSpan(q,U.decision);Y=U.traceState??Y;let G=U.decision===F.SamplingDecision.RECORD_AND_SAMPLED?F.TraceFlags.SAMPLED:F.TraceFlags.NONE,w={traceId:H,spanId:W,traceFlags:G,traceState:Y};if(U.decision===F.SamplingDecision.NOT_RECORD)return F.diag.debug("Recording is off, propagating context in a non-recording span"),F.trace.wrapSpanContext(w);let B=(0,kJ.sanitizeAttributes)(Object.assign(z,U.attributes));return new f6.SpanImpl({resource:this._resource,scope:this.instrumentationScope,context:Z,spanContext:w,name:J,kind:V,links:R,parentSpanContext:X,attributes:B,startTime:Q.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:I})}startActiveSpan(J,Q,Z,$){let q,W,X;if(arguments.length<2)return;else if(arguments.length===2)X=Q;else if(arguments.length===3)q=Q,X=Z;else q=Q,W=Z,X=$;let H=W??F.context.active(),Y=this.startSpan(J,q,H),V=F.trace.setSpan(H,Y);return F.context.with(V,X,void 0,Y)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}PZ.Tracer=LZ});var xZ=K((bZ)=>{Object.defineProperty(bZ,"__esModule",{value:!0});bZ.MultiSpanProcessor=void 0;var d6=E();class TZ{_spanProcessors;constructor(J){this._spanProcessors=J}forceFlush(){let J=[];for(let Q of this._spanProcessors)J.push(Q.forceFlush());return new Promise((Q)=>{Promise.all(J).then(()=>{Q()}).catch((Z)=>{(0,d6.globalErrorHandler)(Z||Error("MultiSpanProcessor: forceFlush failed")),Q()})})}onStart(J,Q){for(let Z of this._spanProcessors)Z.onStart(J,Q)}onEnding(J){for(let Q of this._spanProcessors)if(Q.onEnding)Q.onEnding(J)}onEnd(J){for(let Q of this._spanProcessors)Q.onEnd(J)}shutdown(){let J=[];for(let Q of this._spanProcessors)J.push(Q.shutdown());return new Promise((Q,Z)=>{Promise.all(J).then(()=>{Q()},Z)})}}bZ.MultiSpanProcessor=TZ});var lZ=K((vZ)=>{Object.defineProperty(vZ,"__esModule",{value:!0});vZ.BasicTracerProvider=vZ.ForceFlushState=void 0;var y6=E(),S6=yZ(),v6=fZ(),g6=gJ(),l6=xZ(),m6=lJ(),o;(function(J){J[J.resolved=0]="resolved",J[J.timeout=1]="timeout",J[J.error=2]="error",J[J.unresolved=3]="unresolved"})(o=vZ.ForceFlushState||(vZ.ForceFlushState={}));class SZ{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(J={}){let Q=(0,y6.merge)({},(0,g6.loadDefaultConfig)(),(0,m6.reconfigureLimits)(J));this._resource=Q.resource??(0,S6.defaultResource)(),this._config=Object.assign({},Q,{resource:this._resource});let Z=[];if(J.spanProcessors?.length)Z.push(...J.spanProcessors);this._activeSpanProcessor=new l6.MultiSpanProcessor(Z)}getTracer(J,Q,Z){let $=`${J}@${Q||""}:${Z?.schemaUrl||""}`;if(!this._tracers.has($))this._tracers.set($,new v6.Tracer({name:J,version:Q,schemaUrl:Z?.schemaUrl},this._config,this._resource,this._activeSpanProcessor));return this._tracers.get($)}forceFlush(){let J=this._config.forceFlushTimeoutMillis,Q=this._activeSpanProcessor._spanProcessors.map((Z)=>{return new Promise(($)=>{let q,W=setTimeout(()=>{$(Error(`Span processor did not completed within timeout period of ${J} ms`)),q=o.timeout},J);Z.forceFlush().then(()=>{if(clearTimeout(W),q!==o.timeout)q=o.resolved,$(q)}).catch((X)=>{clearTimeout(W),q=o.error,$(X)})})});return new Promise((Z,$)=>{Promise.all(Q).then((q)=>{let W=q.filter((X)=>X!==o.resolved);if(W.length>0)$(W);else Z()}).catch((q)=>$([q]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}vZ.BasicTracerProvider=SZ});var pZ=K((uZ)=>{Object.defineProperty(uZ,"__esModule",{value:!0});uZ.ConsoleSpanExporter=void 0;var uJ=E();class mZ{export(J,Q){return this._sendSpans(J,Q)}shutdown(){return this._sendSpans([]),this.forceFlush()}forceFlush(){return Promise.resolve()}_exportInfo(J){return{resource:{attributes:J.resource.attributes},instrumentationScope:J.instrumentationScope,traceId:J.spanContext().traceId,parentSpanContext:J.parentSpanContext,traceState:J.spanContext().traceState?.serialize(),name:J.name,id:J.spanContext().spanId,kind:J.kind,timestamp:(0,uJ.hrTimeToMicroseconds)(J.startTime),duration:(0,uJ.hrTimeToMicroseconds)(J.duration),attributes:J.attributes,status:J.status,events:J.events,links:J.links}}_sendSpans(J,Q){for(let Z of J)console.dir(this._exportInfo(Z),{depth:3});if(Q)return Q({code:uJ.ExportResultCode.SUCCESS})}}uZ.ConsoleSpanExporter=mZ});var aZ=K((sZ)=>{Object.defineProperty(sZ,"__esModule",{value:!0});sZ.InMemorySpanExporter=void 0;var nZ=E();class iZ{_finishedSpans=[];_stopped=!1;export(J,Q){if(this._stopped)return Q({code:nZ.ExportResultCode.FAILED,error:Error("Exporter has been stopped")});this._finishedSpans.push(...J),setTimeout(()=>Q({code:nZ.ExportResultCode.SUCCESS}),0)}shutdown(){return this._stopped=!0,this._finishedSpans=[],this.forceFlush()}forceFlush(){return Promise.resolve()}reset(){this._finishedSpans=[]}getFinishedSpans(){return this._finishedSpans}}sZ.InMemorySpanExporter=iZ});var J0=K((tZ)=>{Object.defineProperty(tZ,"__esModule",{value:!0});tZ.SimpleSpanProcessor=void 0;var u6=M(),IJ=E();class rZ{_exporter;_shutdownOnce;_pendingExports;constructor(J){this._exporter=J,this._shutdownOnce=new IJ.BindOnceFuture(this._shutdown,this),this._pendingExports=new Set}async forceFlush(){if(await Promise.all(Array.from(this._pendingExports)),this._exporter.forceFlush)await this._exporter.forceFlush()}onStart(J,Q){}onEnd(J){if(this._shutdownOnce.isCalled)return;if((J.spanContext().traceFlags&u6.TraceFlags.SAMPLED)===0)return;let Q=this._doExport(J).catch((Z)=>(0,IJ.globalErrorHandler)(Z));this._pendingExports.add(Q),Q.finally(()=>this._pendingExports.delete(Q))}async _doExport(J){if(J.resource.asyncAttributesPending)await J.resource.waitForAsyncAttributes?.();let Q=await IJ.internal._export(this._exporter,[J]);if(Q.code!==IJ.ExportResultCode.SUCCESS)throw Q.error??Error(`SimpleSpanProcessor: span export failed (status ${Q})`)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}}tZ.SimpleSpanProcessor=rZ});var q0=K((Z0)=>{Object.defineProperty(Z0,"__esModule",{value:!0});Z0.NoopSpanProcessor=void 0;class Q0{onStart(J,Q){}onEnd(J){}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}}Z0.NoopSpanProcessor=Q0});var cJ=K((A)=>{Object.defineProperty(A,"__esModule",{value:!0});A.SamplingDecision=A.TraceIdRatioBasedSampler=A.ParentBasedSampler=A.AlwaysOnSampler=A.AlwaysOffSampler=A.NoopSpanProcessor=A.SimpleSpanProcessor=A.InMemorySpanExporter=A.ConsoleSpanExporter=A.RandomIdGenerator=A.BatchSpanProcessor=A.BasicTracerProvider=void 0;var c6=lZ();Object.defineProperty(A,"BasicTracerProvider",{enumerable:!0,get:function(){return c6.BasicTracerProvider}});var W0=mJ();Object.defineProperty(A,"BatchSpanProcessor",{enumerable:!0,get:function(){return W0.BatchSpanProcessor}});Object.defineProperty(A,"RandomIdGenerator",{enumerable:!0,get:function(){return W0.RandomIdGenerator}});var p6=pZ();Object.defineProperty(A,"ConsoleSpanExporter",{enumerable:!0,get:function(){return p6.ConsoleSpanExporter}});var n6=aZ();Object.defineProperty(A,"InMemorySpanExporter",{enumerable:!0,get:function(){return n6.InMemorySpanExporter}});var i6=J0();Object.defineProperty(A,"SimpleSpanProcessor",{enumerable:!0,get:function(){return i6.SimpleSpanProcessor}});var s6=q0();Object.defineProperty(A,"NoopSpanProcessor",{enumerable:!0,get:function(){return s6.NoopSpanProcessor}});var o6=wJ();Object.defineProperty(A,"AlwaysOffSampler",{enumerable:!0,get:function(){return o6.AlwaysOffSampler}});var a6=VJ();Object.defineProperty(A,"AlwaysOnSampler",{enumerable:!0,get:function(){return a6.AlwaysOnSampler}});var r6=dJ();Object.defineProperty(A,"ParentBasedSampler",{enumerable:!0,get:function(){return r6.ParentBasedSampler}});var t6=yJ();Object.defineProperty(A,"TraceIdRatioBasedSampler",{enumerable:!0,get:function(){return t6.TraceIdRatioBasedSampler}});var e6=i();Object.defineProperty(A,"SamplingDecision",{enumerable:!0,get:function(){return e6.SamplingDecision}})});var H0=K((X0)=>{Object.defineProperty(X0,"__esModule",{value:!0});X0.NodeTracerProvider=void 0;var Q7=EQ(),Z7=cJ(),WJ=M(),pJ=E();function $7(J){if(J===null)return;if(J===void 0){let Q=new Q7.AsyncLocalStorageContextManager;Q.enable(),WJ.context.setGlobalContextManager(Q);return}J.enable(),WJ.context.setGlobalContextManager(J)}function q7(J){if(J===null)return;if(J===void 0){WJ.propagation.setGlobalPropagator(new pJ.CompositePropagator({propagators:[new pJ.W3CTraceContextPropagator,new pJ.W3CBaggagePropagator]}));return}WJ.propagation.setGlobalPropagator(J)}class z0 extends Z7.BasicTracerProvider{constructor(J={}){super(J)}register(J={}){WJ.trace.setGlobalTracerProvider(this),$7(J.contextManager),q7(J.propagator)}}X0.NodeTracerProvider=z0});var K0=K((k)=>{Object.defineProperty(k,"__esModule",{value:!0});k.TraceIdRatioBasedSampler=k.SimpleSpanProcessor=k.SamplingDecision=k.RandomIdGenerator=k.ParentBasedSampler=k.NoopSpanProcessor=k.InMemorySpanExporter=k.ConsoleSpanExporter=k.BatchSpanProcessor=k.BasicTracerProvider=k.AlwaysOnSampler=k.AlwaysOffSampler=k.NodeTracerProvider=void 0;var W7=H0();Object.defineProperty(k,"NodeTracerProvider",{enumerable:!0,get:function(){return W7.NodeTracerProvider}});var L=cJ();Object.defineProperty(k,"AlwaysOffSampler",{enumerable:!0,get:function(){return L.AlwaysOffSampler}});Object.defineProperty(k,"AlwaysOnSampler",{enumerable:!0,get:function(){return L.AlwaysOnSampler}});Object.defineProperty(k,"BasicTracerProvider",{enumerable:!0,get:function(){return L.BasicTracerProvider}});Object.defineProperty(k,"BatchSpanProcessor",{enumerable:!0,get:function(){return L.BatchSpanProcessor}});Object.defineProperty(k,"ConsoleSpanExporter",{enumerable:!0,get:function(){return L.ConsoleSpanExporter}});Object.defineProperty(k,"InMemorySpanExporter",{enumerable:!0,get:function(){return L.InMemorySpanExporter}});Object.defineProperty(k,"NoopSpanProcessor",{enumerable:!0,get:function(){return L.NoopSpanProcessor}});Object.defineProperty(k,"ParentBasedSampler",{enumerable:!0,get:function(){return L.ParentBasedSampler}});Object.defineProperty(k,"RandomIdGenerator",{enumerable:!0,get:function(){return L.RandomIdGenerator}});Object.defineProperty(k,"SamplingDecision",{enumerable:!0,get:function(){return L.SamplingDecision}});Object.defineProperty(k,"SimpleSpanProcessor",{enumerable:!0,get:function(){return L.SimpleSpanProcessor}});Object.defineProperty(k,"TraceIdRatioBasedSampler",{enumerable:!0,get:function(){return L.TraceIdRatioBasedSampler}})});var a0=d(K0(),1);var MJ=(J)=>J!==void 0&&!(Array.isArray(J)&&J.length===0);var HJ=d(M(),1);var v;(function(J){J[J.UNSPECIFIED=0]="UNSPECIFIED",J[J.TRACE=1]="TRACE",J[J.TRACE2=2]="TRACE2",J[J.TRACE3=3]="TRACE3",J[J.TRACE4=4]="TRACE4",J[J.DEBUG=5]="DEBUG",J[J.DEBUG2=6]="DEBUG2",J[J.DEBUG3=7]="DEBUG3",J[J.DEBUG4=8]="DEBUG4",J[J.INFO=9]="INFO",J[J.INFO2=10]="INFO2",J[J.INFO3=11]="INFO3",J[J.INFO4=12]="INFO4",J[J.WARN=13]="WARN",J[J.WARN2=14]="WARN2",J[J.WARN3=15]="WARN3",J[J.WARN4=16]="WARN4",J[J.ERROR=17]="ERROR",J[J.ERROR2=18]="ERROR2",J[J.ERROR3=19]="ERROR3",J[J.ERROR4=20]="ERROR4",J[J.FATAL=21]="FATAL",J[J.FATAL2=22]="FATAL2",J[J.FATAL3=23]="FATAL3",J[J.FATAL4=24]="FATAL4"})(v||(v={}));class zJ{emit(J){}}var XJ=new zJ;var YJ=Symbol.for("io.opentelemetry.js.api.logs"),a=globalThis;function G0(J,Q,Z){return($)=>$===J?Q:Z}var nJ=1;class w0{getLogger(J,Q,Z){return new zJ}}var AJ=new w0;class iJ{constructor(J,Q,Z,$){this._provider=J,this.name=Q,this.version=Z,this.options=$}emit(J){this._getLogger().emit(J)}_getLogger(){if(this._delegate)return this._delegate;let J=this._provider._getDelegateLogger(this.name,this.version,this.options);if(!J)return XJ;return this._delegate=J,this._delegate}}class RJ{getLogger(J,Q,Z){var $;return($=this._getDelegateLogger(J,Q,Z))!==null&&$!==void 0?$:new iJ(this,J,Q,Z)}_getDelegate(){var J;return(J=this._delegate)!==null&&J!==void 0?J:AJ}_setDelegate(J){this._delegate=J}_getDelegateLogger(J,Q,Z){var $;return($=this._delegate)===null||$===void 0?void 0:$.getLogger(J,Q,Z)}}class CJ{constructor(){this._proxyLoggerProvider=new RJ}static getInstance(){if(!this._instance)this._instance=new CJ;return this._instance}setGlobalLoggerProvider(J){if(a[YJ])return this.getLoggerProvider();return a[YJ]=G0(nJ,J,AJ),this._proxyLoggerProvider._setDelegate(J),J}getLoggerProvider(){var J,Q;return(Q=(J=a[YJ])===null||J===void 0?void 0:J.call(a,nJ))!==null&&Q!==void 0?Q:this._proxyLoggerProvider}getLogger(J,Q,Z){return this.getLoggerProvider().getLogger(J,Q,Z)}disable(){delete a[YJ],this._proxyLoggerProvider=new RJ}}var l8=CJ.getInstance();var j0=d(yZ(),1),F0=d(E(),1);var T=d(M(),1);var f=d(M(),1),oJ=d(E(),1),C=d(AQ(),1);function V0(J){return sJ(J,new WeakSet)}function sJ(J,Q){if(J==null)return!0;if(typeof J==="string"||typeof J==="number"||typeof J==="boolean")return!0;if(J instanceof Uint8Array)return!0;if(typeof J==="object"){if(Q.has(J))return!1;if(Q.add(J),Array.isArray(J))return J.every(($)=>sJ($,Q));let Z=J;if(Z.constructor!==Object&&Z.constructor!==void 0)return!1;return Object.values(Z).every(($)=>sJ($,Q))}return!1}class aJ{hrTime;hrTimeObserved;spanContext;resource;instrumentationScope;attributes={};_severityText;_severityNumber;_body;_eventName;_attributesCount=0;_droppedAttributesCount=0;_isReadonly=!1;_logRecordLimits;set severityText(J){if(this._isLogRecordReadonly())return;this._severityText=J}get severityText(){return this._severityText}set severityNumber(J){if(this._isLogRecordReadonly())return;this._severityNumber=J}get severityNumber(){return this._severityNumber}set body(J){if(this._isLogRecordReadonly())return;this._body=J}get body(){return this._body}get eventName(){return this._eventName}set eventName(J){if(this._isLogRecordReadonly())return;this._eventName=J}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(J,Q,Z){let{timestamp:$,observedTimestamp:q,eventName:W,severityNumber:X,severityText:H,body:Y,attributes:V={},exception:R,context:z}=Z,U=Date.now();if(this.hrTime=oJ.timeInputToHrTime($??U),this.hrTimeObserved=oJ.timeInputToHrTime(q??U),z){let I=f.trace.getSpanContext(z);if(I&&f.isSpanContextValid(I))this.spanContext=I}if(this.severityNumber=X,this.severityText=H,this.body=Y,this.resource=J.resource,this.instrumentationScope=Q,this._logRecordLimits=J.logRecordLimits,this._eventName=W,this.setAttributes(V),R!=null)this._setException(R)}setAttribute(J,Q){if(this._isLogRecordReadonly())return this;if(J.length===0)return f.diag.warn(`Invalid attribute key: ${J}`),this;if(!V0(Q))return f.diag.warn(`Invalid attribute value set for key: ${J}`),this;let Z=!Object.prototype.hasOwnProperty.call(this.attributes,J);if(Z&&this._attributesCount>=this._logRecordLimits.attributeCountLimit){if(this._droppedAttributesCount++,this._droppedAttributesCount===1)f.diag.warn("Dropping extra attributes.");return this}if(this.attributes[J]=this._truncateToSize(Q),Z)this._attributesCount++;return this}setAttributes(J){for(let[Q,Z]of Object.entries(J))this.setAttribute(Q,Z);return this}setBody(J){return this.body=J,this}setEventName(J){return this.eventName=J,this}setSeverityNumber(J){return this.severityNumber=J,this}setSeverityText(J){return this.severityText=J,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(J){let Q=this._logRecordLimits.attributeValueLengthLimit;if(Q<=0)return f.diag.warn(`Attribute value limit must be positive, got ${Q}`),J;if(J==null)return J;if(typeof J==="string")return this._truncateToLimitUtil(J,Q);if(J instanceof Uint8Array)return J;if(Array.isArray(J))return J.map((Z)=>this._truncateToSize(Z));if(typeof J==="object"){let Z={};for(let[$,q]of Object.entries(J))Z[$]=this._truncateToSize(q);return Z}return J}_setException(J){let Q=!1;if(typeof J==="string"||typeof J==="number"){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_MESSAGE))this.setAttribute(C.ATTR_EXCEPTION_MESSAGE,String(J));Q=!0}else if(J&&typeof J==="object"){let Z=J;if(Z.code){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_TYPE))this.setAttribute(C.ATTR_EXCEPTION_TYPE,Z.code.toString());Q=!0}else if(Z.name){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_TYPE))this.setAttribute(C.ATTR_EXCEPTION_TYPE,Z.name);Q=!0}if(Z.message){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_MESSAGE))this.setAttribute(C.ATTR_EXCEPTION_MESSAGE,Z.message);Q=!0}if(Z.stack){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_STACKTRACE))this.setAttribute(C.ATTR_EXCEPTION_STACKTRACE,Z.stack);Q=!0}}if(!Q)f.diag.warn(`Failed to record an exception ${J}`)}_truncateToLimitUtil(J,Q){if(J.length<=Q)return J;return J.substring(0,Q)}_isLogRecordReadonly(){if(this._isReadonly)f.diag.warn("Can not execute the operation on emitted log record");return this._isReadonly}}class rJ{instrumentationScope;_sharedState;_loggerConfig;constructor(J,Q){this.instrumentationScope=J,this._sharedState=Q,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(J){let Q=this._loggerConfig,Z=J.context||T.context.active(),$=J.severityNumber??v.UNSPECIFIED;if($!==v.UNSPECIFIED&&$<Q.minimumSeverity)return;if(Q.traceBased){let W=T.trace.getSpanContext(Z);if(W&&T.isSpanContextValid(W)){if((W.traceFlags&T.TraceFlags.SAMPLED)!==T.TraceFlags.SAMPLED)return}}let q=new aJ(this._sharedState,this.instrumentationScope,{context:Z,...J});this._sharedState.activeProcessor.onEmit(q,Z),q._makeReadonly()}}class tJ{forceFlush(){return Promise.resolve()}onEmit(J,Q){}shutdown(){return Promise.resolve()}}var U0=d(E(),1);class eJ{processors;forceFlushTimeoutMillis;constructor(J,Q){this.processors=J,this.forceFlushTimeoutMillis=Q}async forceFlush(){let J=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map((Q)=>U0.callWithTimeout(Q.forceFlush(),J)))}onEmit(J,Q){this.processors.forEach((Z)=>Z.onEmit(J,Q))}async shutdown(){await Promise.all(this.processors.map((J)=>J.shutdown()))}}function B0(J){return`${J.name}@${J.version||""}:${J.schemaUrl||""}`}var X7={disabled:!1,minimumSeverity:v.UNSPECIFIED,traceBased:!1},JQ=()=>({...X7});class QQ{loggers=new Map;activeProcessor;registeredLogRecordProcessors=[];resource;forceFlushTimeoutMillis;logRecordLimits;processors;_loggerConfigurator;_loggerConfigs=new Map;constructor(J,Q,Z,$,q){if(this.resource=J,this.forceFlushTimeoutMillis=Q,this.logRecordLimits=Z,this.processors=$,$.length>0)this.registeredLogRecordProcessors=$,this.activeProcessor=new eJ(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis);else this.activeProcessor=new tJ;this._loggerConfigurator=q??JQ}getLoggerConfig(J){let Q=B0(J),Z=this._loggerConfigs.get(Q);if(Z)return Z;return Z=this._loggerConfigurator(J),this._loggerConfigs.set(Q,Z),Z}}var Y7="unknown";class LJ{_shutdownOnce;_sharedState;constructor(J={}){let Q={resource:J.resource??j0.defaultResource(),forceFlushTimeoutMillis:J.forceFlushTimeoutMillis??30000,logRecordLimits:{attributeCountLimit:J.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:J.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:J.loggerConfigurator??JQ,processors:J.processors??[]};this._sharedState=new QQ(Q.resource,Q.forceFlushTimeoutMillis,Q.logRecordLimits,Q.processors,Q.loggerConfigurator),this._shutdownOnce=new F0.BindOnceFuture(this._shutdown,this)}getLogger(J,Q,Z){if(this._shutdownOnce.isCalled)return HJ.diag.warn("A shutdown LoggerProvider cannot provide a Logger"),XJ;if(!J)HJ.diag.warn("Logger requested without instrumentation scope name.");let $=J||Y7,q=`${$}@${Q||""}:${Z?.schemaUrl||""}`;if(!this._sharedState.loggers.has(q))this._sharedState.loggers.set(q,new rJ({name:$,version:Q,schemaUrl:Z?.schemaUrl},this._sharedState));return this._sharedState.loggers.get(q)}forceFlush(){if(this._shutdownOnce.isCalled)return HJ.diag.warn("invalid attempt to force flush after LoggerProvider shutdown"),this._shutdownOnce.promise;return this._sharedState.activeProcessor.forceFlush()}shutdown(){if(this._shutdownOnce.isCalled)return HJ.diag.warn("shutdown may only be called once per LoggerProvider"),this._shutdownOnce.promise;return this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}}class qQ extends O0()("@effect/opentelemetry/Logger/OtelLoggerProvider"){}var G7=g(function*(){let J=yield*qQ,Q=yield*A0,Z=J.getLogger("@effect/opentelemetry");return L0(($)=>{let q={fiberId:$.fiber.id},W=D0($.fiber.context,E0);if(h0(W))q.spanId=W.spanId,q.traceId=W.traceId;for(let[V,R]of Object.entries($.fiber.getRef(k0)))q[V]=ZQ(R);let X=$.date.getTime();for(let[V,R]of $.fiber.getRef(I0))q[`logSpan.${V}`]=`${X-R}ms`;let H=$Q($.message).map(ZQ),Y=N0(Q.currentTimeNanosUnsafe());Z.emit({body:H.length===1?H[0]:H,severityText:$.logLevel,severityNumber:C0($.logLevel),timestamp:Y,observedTimestamp:Y,attributes:q})})}),f0=(J)=>P0([G7],{mergeWithExisting:J.mergeWithExisting??!0}),T0=(J,Q)=>PJ(qQ,g(function*(){let Z=yield*ZJ;return yield*JJ(u(()=>new LJ({...Q??void 0,processors:$Q(J),resource:Z})),($)=>r(()=>$.forceFlush().then(()=>$.shutdown())).pipe(t,QJ,e(Q?.shutdownTimeout??3000)))}));var l=d(M(),1);var c;(function(J){J[J.DELTA=0]="DELTA",J[J.CUMULATIVE=1]="CUMULATIVE"})(c||(c={}));var P;(function(J){J.COUNTER="COUNTER",J.GAUGE="GAUGE",J.HISTOGRAM="HISTOGRAM",J.UP_DOWN_COUNTER="UP_DOWN_COUNTER",J.OBSERVABLE_COUNTER="OBSERVABLE_COUNTER",J.OBSERVABLE_GAUGE="OBSERVABLE_GAUGE",J.OBSERVABLE_UP_DOWN_COUNTER="OBSERVABLE_UP_DOWN_COUNTER"})(P||(P={}));var b;(function(J){J[J.HISTOGRAM=0]="HISTOGRAM",J[J.EXPONENTIAL_HISTOGRAM=1]="EXPONENTIAL_HISTOGRAM",J[J.GAUGE=2]="GAUGE",J[J.SUM=3]="SUM"})(b||(b={}));var V7="@effect/opentelemetry/Metrics";class zQ{resource;context;temporality;startTimes;startTimeNanos;previousExportTimeNanos;previousCounterState;previousHistogramState;previousFrequencyState;previousSummaryState;constructor(J,Q,Z="cumulative"){this.resource=J,this.context=Q,this.temporality=Z,this.startTimes=new Map,this.startTimeNanos=b0(),this.previousExportTimeNanos=this.startTimeNanos,this.previousCounterState=new Map,this.previousHistogramState=new Map,this.previousFrequencyState=new Map,this.previousSummaryState=new Map}startTimeFor(J,Q){if(this.startTimes.has(J))return this.startTimes.get(J);return this.startTimes.set(J,Q),Q}collect(J){let Q=x0(this.context),Z=b0(),$=[],q=new Map,W=(V)=>{$.push(V),q.set(V.descriptor.name,V)},X=this.temporality==="delta",H=X?c.DELTA:c.CUMULATIVE,Y=X?this.previousExportTimeNanos:this.startTimeNanos;for(let V=0,R=Q.length;V<R;V++){let z=Q[V],U=z.attributes?_0(Object.entries(z.attributes),{},(G,[w,B])=>{return G[w]=String(B),G}):{},I=U7(z.id,z.attributes);switch(z.type){case"Counter":{let G=z.state.count,w=G;if(X){let j=this.previousCounterState.get(I);if(j!==void 0)if(typeof G==="bigint"&&typeof j==="bigint"){if(w=G-j,w<0n)w=G}else{let y=Number(G),p=Number(j);if(w=y-p,w<0)w=y}this.previousCounterState.set(I,G)}let B=$J(z,U),D={startTime:this.startTimeFor(B.name,Y),endTime:Z,attributes:U,value:Number(w)};if(q.has(z.id))q.get(z.id).dataPoints.push(D);else W({dataPointType:b.SUM,descriptor:B,isMonotonic:z.state.incremental,aggregationTemporality:H,dataPoints:[D]});break}case"Gauge":{let G=$J(z,U),B={startTime:this.startTimeFor(G.name,this.startTimeNanos),endTime:Z,attributes:U,value:Number(z.state.value)};if(q.has(z.id))q.get(z.id).dataPoints.push(B);else W({dataPointType:b.GAUGE,descriptor:G,aggregationTemporality:c.CUMULATIVE,dataPoints:[B]});break}case"Histogram":{let G=z.state.buckets.length,w={boundaries:WQ(G-1),counts:WQ(G)},B=0,N=0;for(let[n,KJ]of z.state.buckets){if(B<G-1)w.boundaries[B]=n;w.counts[B]=KJ-N,N=KJ,B++}let D=z.state.count,j=z.state.sum,y=w.counts,p=z.state.min,fJ=z.state.max;if(X){let n=this.previousHistogramState.get(I);if(n!==void 0)D=z.state.count-n.count,j=z.state.sum-n.sum,y=w.counts.map((KJ,r0)=>Math.max(0,KJ-(n.bucketCounts[r0]??0)));this.previousHistogramState.set(I,{count:z.state.count,sum:z.state.sum,bucketCounts:w.counts.slice(),min:z.state.min,max:z.state.max})}let YQ=$J(z,U),HQ={startTime:this.startTimeFor(YQ.name,Y),endTime:Z,attributes:U,value:{buckets:{boundaries:w.boundaries,counts:y},count:D,min:p,max:fJ,sum:j}};if(q.has(z.id))q.get(z.id).dataPoints.push(HQ);else W({dataPointType:b.HISTOGRAM,descriptor:YQ,aggregationTemporality:H,dataPoints:[HQ]});break}case"Frequency":{let G=[],w=new Map;for(let[B,N]of z.state.occurrences){w.set(B,N);let D=N;if(X){let p=this.previousFrequencyState.get(I);if(p!==void 0){let fJ=p.get(B)??0;D=Math.max(0,N-fJ)}}let j=$J(z,U),y=this.startTimeFor(j.name,Y);G.push({startTime:y,endTime:Z,attributes:{...U,key:B},value:D})}if(X)this.previousFrequencyState.set(I,w);if(q.has(z.id))q.get(z.id).dataPoints.push(...G);else{let B=$J(z,U);W({dataPointType:b.SUM,descriptor:B,aggregationTemporality:H,isMonotonic:!0,dataPoints:G})}break}case"Summary":{let G=[{startTime:Y,endTime:Z,attributes:{...U,quantile:"min"},value:z.state.min}];for(let[j,y]of z.state.quantiles)G.push({startTime:Y,endTime:Z,attributes:{...U,quantile:j.toString()},value:y??0});G.push({startTime:Y,endTime:Z,attributes:{...U,quantile:"max"},value:z.state.max});let w=z.state.count,B=z.state.sum;if(X){let j=this.previousSummaryState.get(I);if(j!==void 0)w=z.state.count-j.count,B=z.state.sum-j.sum;this.previousSummaryState.set(I,{count:z.state.count,sum:z.state.sum})}let N={startTime:Y,endTime:Z,attributes:U,value:w},D={startTime:Y,endTime:Z,attributes:U,value:B};if(q.has(`${z.id}_quantiles`))q.get(`${z.id}_quantiles`).dataPoints.push(...G),q.get(`${z.id}_count`).dataPoints.push(N),q.get(`${z.id}_sum`).dataPoints.push(D);else{let j=$J(z,U);W({dataPointType:b.SUM,descriptor:{...j,name:`${j.name}_quantiles`},aggregationTemporality:H,isMonotonic:!1,dataPoints:G}),W({dataPointType:b.SUM,descriptor:{name:`${z.id}_count`,description:z.description??"",unit:"1",type:P.COUNTER,valueType:l.ValueType.INT,advice:{}},aggregationTemporality:H,isMonotonic:!0,dataPoints:[N]}),W({dataPointType:b.SUM,descriptor:{name:`${z.id}_sum`,description:z.description??"",unit:"1",type:P.COUNTER,valueType:l.ValueType.DOUBLE,advice:{}},aggregationTemporality:H,isMonotonic:!0,dataPoints:[D]})}break}}}if(X)this.previousExportTimeNanos=Z;return Promise.resolve({resourceMetrics:{resource:this.resource,scopeMetrics:[{scope:{name:V7},metrics:$}]},errors:[]})}}var U7=(J,Q)=>{if(Q===void 0||Object.keys(Q).length===0)return J;let Z=Object.entries(Q).sort(($,q)=>$[0].localeCompare(q[0]));return`${J}:${JSON.stringify(Z)}`},b0=()=>{let J=Date.now();return[Math.floor(J/1000),J%1000*1e6]},$J=(J,Q)=>{let Z=Q.unit??Q.time_unit??"1";return{name:J.id,description:J.description??"",unit:Z,type:B7(J),valueType:j7(J),advice:{}}},B7=(J)=>{switch(J.type){case"Histogram":return P.HISTOGRAM;case"Gauge":return P.OBSERVABLE_GAUGE;case"Frequency":return P.COUNTER;case"Counter":return J.state.incremental?P.COUNTER:P.UP_DOWN_COUNTER;case"Summary":return P.COUNTER}},j7=(J)=>{if(J.type==="Counter")return typeof J.state.count==="bigint"?l.ValueType.INT:l.ValueType.DOUBLE;else if(J.type==="Gauge")return typeof J.state.value==="bigint"?l.ValueType.INT:l.ValueType.DOUBLE;return l.ValueType.DOUBLE};var F7=(J)=>g(function*(){let Q=yield*ZJ,Z=yield*S0();return new zQ(Q,Z,J)}),h7=(J,Q,Z)=>JJ(u(()=>{let $=Q(),q=Array.isArray($)?$:[$];return q.forEach((W)=>W.setMetricProducer(J)),q}),($)=>r(()=>Promise.all($.map((q)=>q.shutdown()))).pipe(t,QJ,e(Z?.shutdownTimeout??3000))),v0=(J,Q)=>d0(y0(F7(Q?.temporality),(Z)=>h7(Z,J,Q)));var D7=(J,Q)=>PJ(s0,g(function*(){let Z=yield*ZJ;return yield*JJ(u(()=>{return new a0.NodeTracerProvider({...Q??void 0,resource:Z,spanProcessors:Array.isArray(J)?J:[J]})}),($)=>r(()=>$.forceFlush().then(()=>$.shutdown())).pipe(t,QJ,e(Q?.shutdownTimeout??3000)))})),a9=(J)=>l0(g(function*(){let Q=yield*c0(J)?J:u(J),Z=n0(Q.resource&&p0(Q.resource)),$=MJ(Q.spanProcessor)?XQ(o0,D7(Q.spanProcessor,{...Q.tracerConfig,shutdownTimeout:Q.shutdownTimeout})):NJ,q=MJ(Q.metricReader)?v0(g0(Q.metricReader),{shutdownTimeout:Q.shutdownTimeout,temporality:Q.metricTemporality}):NJ,W=MJ(Q.logRecordProcessor)?XQ(f0({mergeWithExisting:Q.loggerMergeWithExisting}),T0(Q.logRecordProcessor,{...Q.loggerProviderConfig,shutdownTimeout:Q.shutdownTimeout})):NJ;return m0($,q,W).pipe(u0(Z))})),r9=i0;export{D7 as layerTracerProvider,r9 as layerEmpty,a9 as layer};
|
|
2
|
+
import{kq as yZ,lq as N0,mq as ZQ,nq as ZJ,oq as p0,pq as n0,qq as i0,sq as s0,tq as o0}from"./chunk-eacpc64g.js";import{uq as AQ,vq as E}from"./chunk-27saej0r.js";import{$D as k0,AE as l0,BE as m0,CE as XQ,DE as u0,HC as E0,Hz as g0,KE as A0,QF as t,SF as e,XN as C0,Yz as h0,aC as WQ,aE as I0,aF as x0,cC as $Q,cF as c0,cG as S0,eO as L0,fO as P0,gF as r,kF as u,lG as JJ,nB as O0,nC as _0,pF as g,tB as D0,tG as QJ,wE as NJ,wF as y0,xE as PJ,zE as d0}from"./chunk-g7v6sp3c.js";import{sO as M}from"./chunk-n6tqtk6h.js";import{tO as d,uO as K,xO as TJ}from"./chunk-e0vrxetq.js";var bJ=K((GQ)=>{Object.defineProperty(GQ,"__esModule",{value:!0});GQ.AbstractAsyncHooksContextManager=void 0;var t0=TJ("events"),e0=["addListener","on","once","prependListener","prependOnceListener"];class KQ{bind(J,Q){if(Q instanceof t0.EventEmitter)return this._bindEventEmitter(J,Q);if(typeof Q==="function")return this._bindFunction(J,Q);return Q}_bindFunction(J,Q){let Z=this,$=function(...q){return Z.with(J,()=>Q.apply(this,q))};return Object.defineProperty($,"length",{enumerable:!1,configurable:!0,writable:!1,value:Q.length}),$}_bindEventEmitter(J,Q){if(this._getPatchMap(Q)!==void 0)return Q;if(this._createPatchMap(Q),e0.forEach(($)=>{if(Q[$]===void 0)return;Q[$]=this._patchAddListener(Q,Q[$],J)}),typeof Q.removeListener==="function")Q.removeListener=this._patchRemoveListener(Q,Q.removeListener);if(typeof Q.off==="function")Q.off=this._patchRemoveListener(Q,Q.off);if(typeof Q.removeAllListeners==="function")Q.removeAllListeners=this._patchRemoveAllListeners(Q,Q.removeAllListeners);return Q}_patchRemoveListener(J,Q){let Z=this;return function($,q){let W=Z._getPatchMap(J)?.[$];if(W===void 0)return Q.call(this,$,q);let X=W.get(q);return Q.call(this,$,X||q)}}_patchRemoveAllListeners(J,Q){let Z=this;return function($){let q=Z._getPatchMap(J);if(q!==void 0){if(arguments.length===0)Z._createPatchMap(J);else if(q[$]!==void 0)delete q[$]}return Q.apply(this,arguments)}}_patchAddListener(J,Q,Z){let $=this;return function(q,W){if($._wrapped)return Q.call(this,q,W);let X=$._getPatchMap(J);if(X===void 0)X=$._createPatchMap(J);let H=X[q];if(H===void 0)H=new WeakMap,X[q]=H;let Y=$.bind(Z,W);H.set(W,Y),$._wrapped=!0;try{return Q.call(this,q,Y)}finally{$._wrapped=!1}}}_createPatchMap(J){let Q=Object.create(null);return J[this._kOtListeners]=Q,Q}_getPatchMap(J){return J[this._kOtListeners]}_kOtListeners=Symbol("OtListeners");_wrapped=!1}GQ.AbstractAsyncHooksContextManager=KQ});var jQ=K((UQ)=>{Object.defineProperty(UQ,"__esModule",{value:!0});UQ.AsyncHooksContextManager=void 0;var J6=M(),Q6=TJ("async_hooks"),Z6=bJ();class VQ extends Z6.AbstractAsyncHooksContextManager{_asyncHook;_contexts=new Map;_stack=[];constructor(){super();this._asyncHook=Q6.createHook({init:this._init.bind(this),before:this._before.bind(this),after:this._after.bind(this),destroy:this._destroy.bind(this),promiseResolve:this._destroy.bind(this)})}active(){return this._stack[this._stack.length-1]??J6.ROOT_CONTEXT}with(J,Q,Z,...$){this._enterContext(J);try{return Q.call(Z,...$)}finally{this._exitContext()}}enable(){return this._asyncHook.enable(),this}disable(){return this._asyncHook.disable(),this._contexts.clear(),this._stack=[],this}_init(J,Q){if(Q==="TIMERWRAP")return;let Z=this._stack[this._stack.length-1];if(Z!==void 0)this._contexts.set(J,Z)}_destroy(J){this._contexts.delete(J)}_before(J){let Q=this._contexts.get(J);if(Q!==void 0)this._enterContext(Q)}_after(){this._exitContext()}_enterContext(J){this._stack.push(J)}_exitContext(){this._stack.pop()}}UQ.AsyncHooksContextManager=VQ});var DQ=K((hQ)=>{Object.defineProperty(hQ,"__esModule",{value:!0});hQ.AsyncLocalStorageContextManager=void 0;var $6=M(),q6=TJ("async_hooks"),W6=bJ();class FQ extends W6.AbstractAsyncHooksContextManager{_asyncLocalStorage;constructor(){super();this._asyncLocalStorage=new q6.AsyncLocalStorage}active(){return this._asyncLocalStorage.getStore()??$6.ROOT_CONTEXT}with(J,Q,Z,...$){let q=Z==null?Q:Q.bind(Z);return this._asyncLocalStorage.run(J,q,...$)}enable(){return this}disable(){return this._asyncLocalStorage.disable(),this}}hQ.AsyncLocalStorageContextManager=FQ});var EQ=K((GJ)=>{Object.defineProperty(GJ,"__esModule",{value:!0});GJ.AsyncLocalStorageContextManager=GJ.AsyncHooksContextManager=void 0;var z6=jQ();Object.defineProperty(GJ,"AsyncHooksContextManager",{enumerable:!0,get:function(){return z6.AsyncHooksContextManager}});var X6=DQ();Object.defineProperty(GJ,"AsyncLocalStorageContextManager",{enumerable:!0,get:function(){return X6.AsyncLocalStorageContextManager}})});var MQ=K((kQ)=>{Object.defineProperty(kQ,"__esModule",{value:!0});kQ.ExceptionEventName=void 0;kQ.ExceptionEventName="exception"});var PQ=K((CQ)=>{Object.defineProperty(CQ,"__esModule",{value:!0});CQ.SpanImpl=void 0;var h=M(),O=E(),m=AQ(),H6=MQ();class RQ{_spanContext;kind;parentSpanContext;attributes={};links=[];events=[];startTime;resource;instrumentationScope;_droppedAttributesCount=0;_droppedEventsCount=0;_droppedLinksCount=0;_attributesCount=0;name;status={code:h.SpanStatusCode.UNSET};endTime=[0,0];_ended=!1;_duration=[-1,-1];_spanProcessor;_spanLimits;_attributeValueLengthLimit;_recordEndMetrics;_performanceStartTime;_performanceOffset;_startTimeProvided;constructor(J){let Q=Date.now();if(this._spanContext=J.spanContext,this._performanceStartTime=O.otperformance.now(),this._performanceOffset=Q-(this._performanceStartTime+O.otperformance.timeOrigin),this._startTimeProvided=J.startTime!=null,this._spanLimits=J.spanLimits,this._attributeValueLengthLimit=this._spanLimits.attributeValueLengthLimit??0,this._spanProcessor=J.spanProcessor,this.name=J.name,this.parentSpanContext=J.parentSpanContext,this.kind=J.kind,J.links)for(let Z of J.links)this.addLink(Z);if(this.startTime=this._getTime(J.startTime??Q),this.resource=J.resource,this.instrumentationScope=J.scope,this._recordEndMetrics=J.recordEndMetrics,J.attributes!=null)this.setAttributes(J.attributes);this._spanProcessor.onStart(this,J.context)}spanContext(){return this._spanContext}setAttribute(J,Q){if(Q==null||this._isSpanEnded())return this;if(J.length===0)return h.diag.warn(`Invalid attribute key: ${J}`),this;if(!(0,O.isAttributeValue)(Q))return h.diag.warn(`Invalid attribute value set for key: ${J}`),this;let{attributeCountLimit:Z}=this._spanLimits,$=!Object.prototype.hasOwnProperty.call(this.attributes,J);if(Z!==void 0&&this._attributesCount>=Z&&$)return this._droppedAttributesCount++,this;if(this.attributes[J]=this._truncateToSize(Q),$)this._attributesCount++;return this}setAttributes(J){for(let Q in J)if(Object.prototype.hasOwnProperty.call(J,Q))this.setAttribute(Q,J[Q]);return this}addEvent(J,Q,Z){if(this._isSpanEnded())return this;let{eventCountLimit:$}=this._spanLimits;if($===0)return h.diag.warn("No events allowed."),this._droppedEventsCount++,this;if($!==void 0&&this.events.length>=$){if(this._droppedEventsCount===0)h.diag.debug("Dropping extra events.");this.events.shift(),this._droppedEventsCount++}if((0,O.isTimeInput)(Q)){if(!(0,O.isTimeInput)(Z))Z=Q;Q=void 0}let q=(0,O.sanitizeAttributes)(Q),{attributePerEventCountLimit:W}=this._spanLimits,X={},H=0,Y=0;for(let V in q){if(!Object.prototype.hasOwnProperty.call(q,V))continue;let R=q[V];if(W!==void 0&&Y>=W){H++;continue}X[V]=this._truncateToSize(R),Y++}return this.events.push({name:J,attributes:X,time:this._getTime(Z),droppedAttributesCount:H}),this}addLink(J){if(this._isSpanEnded())return this;let{linkCountLimit:Q}=this._spanLimits;if(Q===0)return this._droppedLinksCount++,this;if(Q!==void 0&&this.links.length>=Q){if(this._droppedLinksCount===0)h.diag.debug("Dropping extra links.");this.links.shift(),this._droppedLinksCount++}let{attributePerLinkCountLimit:Z}=this._spanLimits,$=(0,O.sanitizeAttributes)(J.attributes),q={},W=0,X=0;for(let Y in $){if(!Object.prototype.hasOwnProperty.call($,Y))continue;let V=$[Y];if(Z!==void 0&&X>=Z){W++;continue}q[Y]=this._truncateToSize(V),X++}let H={context:J.context};if(X>0)H.attributes=q;if(W>0)H.droppedAttributesCount=W;return this.links.push(H),this}addLinks(J){for(let Q of J)this.addLink(Q);return this}setStatus(J){if(this._isSpanEnded())return this;if(J.code===h.SpanStatusCode.UNSET)return this;if(this.status.code===h.SpanStatusCode.OK)return this;let Q={code:J.code};if(J.code===h.SpanStatusCode.ERROR){if(typeof J.message==="string")Q.message=J.message;else if(J.message!=null)h.diag.warn(`Dropping invalid status.message of type '${typeof J.message}', expected 'string'`)}return this.status=Q,this}updateName(J){if(this._isSpanEnded())return this;return this.name=J,this}end(J){if(this._isSpanEnded()){h.diag.error(`${this.name} ${this._spanContext.traceId}-${this._spanContext.spanId} - You can only call end() on a span once.`);return}if(this.endTime=this._getTime(J),this._duration=(0,O.hrTimeDuration)(this.startTime,this.endTime),this._duration[0]<0)h.diag.warn("Inconsistent start and end time, startTime > endTime. Setting span duration to 0ms.",this.startTime,this.endTime),this.endTime=this.startTime.slice(),this._duration=[0,0];if(this._droppedEventsCount>0)h.diag.warn(`Dropped ${this._droppedEventsCount} events because eventCountLimit reached`);if(this._droppedLinksCount>0)h.diag.warn(`Dropped ${this._droppedLinksCount} links because linkCountLimit reached`);if(this._spanProcessor.onEnding)this._spanProcessor.onEnding(this);this._recordEndMetrics?.(),this._ended=!0,this._spanProcessor.onEnd(this)}_getTime(J){if(typeof J==="number"&&J<=O.otperformance.now())return(0,O.hrTime)(J+this._performanceOffset);if(typeof J==="number")return(0,O.millisToHrTime)(J);if(J instanceof Date)return(0,O.millisToHrTime)(J.getTime());if((0,O.isTimeInputHrTime)(J))return J;if(this._startTimeProvided)return(0,O.millisToHrTime)(Date.now());let Q=O.otperformance.now()-this._performanceStartTime;return(0,O.addHrTimes)(this.startTime,(0,O.millisToHrTime)(Q))}isRecording(){return this._ended===!1}recordException(J,Q){let Z={};if(typeof J==="string")Z[m.ATTR_EXCEPTION_MESSAGE]=J;else if(J){if(J.code)Z[m.ATTR_EXCEPTION_TYPE]=J.code.toString();else if(J.name)Z[m.ATTR_EXCEPTION_TYPE]=J.name;if(J.message)Z[m.ATTR_EXCEPTION_MESSAGE]=J.message;if(J.stack)Z[m.ATTR_EXCEPTION_STACKTRACE]=J.stack}if(Z[m.ATTR_EXCEPTION_TYPE]||Z[m.ATTR_EXCEPTION_MESSAGE])this.addEvent(H6.ExceptionEventName,Z,Q);else h.diag.warn(`Failed to record an exception ${J}`)}get duration(){return this._duration}get ended(){return this._ended}get droppedAttributesCount(){return this._droppedAttributesCount}get droppedEventsCount(){return this._droppedEventsCount}get droppedLinksCount(){return this._droppedLinksCount}_isSpanEnded(){if(this._ended){let J=Error(`Operation attempted on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`);h.diag.warn(`Cannot execute the operation on ended Span {traceId: ${this._spanContext.traceId}, spanId: ${this._spanContext.spanId}}`,J)}return this._ended}_truncateToLimitUtil(J,Q){if(J.length<=Q)return J;return J.substring(0,Q)}_truncateToSize(J){let Q=this._attributeValueLengthLimit;if(Q<=0)return h.diag.warn(`Attribute value limit must be positive, got ${Q}`),J;if(typeof J==="string")return this._truncateToLimitUtil(J,Q);if(Array.isArray(J))return J.map((Z)=>typeof Z==="string"?this._truncateToLimitUtil(Z,Q):Z);return J}}CQ.SpanImpl=RQ});var i=K((NQ)=>{Object.defineProperty(NQ,"__esModule",{value:!0});NQ.SamplingDecision=void 0;var K6;(function(J){J[J.NOT_RECORD=0]="NOT_RECORD",J[J.RECORD=1]="RECORD",J[J.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(K6=NQ.SamplingDecision||(NQ.SamplingDecision={}))});var wJ=K((TQ)=>{Object.defineProperty(TQ,"__esModule",{value:!0});TQ.AlwaysOffSampler=void 0;var G6=i();class fQ{shouldSample(){return{decision:G6.SamplingDecision.NOT_RECORD}}toString(){return"AlwaysOffSampler"}}TQ.AlwaysOffSampler=fQ});var VJ=K((xQ)=>{Object.defineProperty(xQ,"__esModule",{value:!0});xQ.AlwaysOnSampler=void 0;var w6=i();class _Q{shouldSample(){return{decision:w6.SamplingDecision.RECORD_AND_SAMPLED}}toString(){return"AlwaysOnSampler"}}xQ.AlwaysOnSampler=_Q});var dJ=K((vQ)=>{Object.defineProperty(vQ,"__esModule",{value:!0});vQ.ParentBasedSampler=void 0;var UJ=M(),V6=E(),yQ=wJ(),xJ=VJ();class SQ{_root;_remoteParentSampled;_remoteParentNotSampled;_localParentSampled;_localParentNotSampled;constructor(J){if(this._root=J.root,!this._root)(0,V6.globalErrorHandler)(Error("ParentBasedSampler must have a root sampler configured")),this._root=new xJ.AlwaysOnSampler;this._remoteParentSampled=J.remoteParentSampled??new xJ.AlwaysOnSampler,this._remoteParentNotSampled=J.remoteParentNotSampled??new yQ.AlwaysOffSampler,this._localParentSampled=J.localParentSampled??new xJ.AlwaysOnSampler,this._localParentNotSampled=J.localParentNotSampled??new yQ.AlwaysOffSampler}shouldSample(J,Q,Z,$,q,W){let X=UJ.trace.getSpanContext(J);if(!X||!(0,UJ.isSpanContextValid)(X))return this._root.shouldSample(J,Q,Z,$,q,W);if(X.isRemote){if(X.traceFlags&UJ.TraceFlags.SAMPLED)return this._remoteParentSampled.shouldSample(J,Q,Z,$,q,W);return this._remoteParentNotSampled.shouldSample(J,Q,Z,$,q,W)}if(X.traceFlags&UJ.TraceFlags.SAMPLED)return this._localParentSampled.shouldSample(J,Q,Z,$,q,W);return this._localParentNotSampled.shouldSample(J,Q,Z,$,q,W)}toString(){return`ParentBased{root=${this._root.toString()}, remoteParentSampled=${this._remoteParentSampled.toString()}, remoteParentNotSampled=${this._remoteParentNotSampled.toString()}, localParentSampled=${this._localParentSampled.toString()}, localParentNotSampled=${this._localParentNotSampled.toString()}}`}}vQ.ParentBasedSampler=SQ});var yJ=K((uQ)=>{Object.defineProperty(uQ,"__esModule",{value:!0});uQ.TraceIdRatioBasedSampler=void 0;var U6=M(),lQ=i();class mQ{_ratio;_upperBound;constructor(J=0){this._ratio=this._normalize(J),this._upperBound=Math.floor(this._ratio*4294967295)}shouldSample(J,Q){return{decision:(0,U6.isValidTraceId)(Q)&&this._accumulate(Q)<this._upperBound?lQ.SamplingDecision.RECORD_AND_SAMPLED:lQ.SamplingDecision.NOT_RECORD}}toString(){return`TraceIdRatioBased{${this._ratio}}`}_normalize(J){if(typeof J!=="number"||isNaN(J))return 0;return J>=1?1:J<=0?0:J}_accumulate(J){let Q=0;for(let Z=0;Z<J.length/8;Z++){let $=Z*8,q=parseInt(J.slice($,$+8),16);Q=(Q^q)>>>0}return Q}}uQ.TraceIdRatioBasedSampler=mQ});var gJ=K((oQ)=>{Object.defineProperty(oQ,"__esModule",{value:!0});oQ.buildSamplerFromEnv=oQ.loadDefaultConfig=void 0;var vJ=M(),_=E(),pQ=wJ(),SJ=VJ(),BJ=dJ(),nQ=yJ(),x;(function(J){J.AlwaysOff="always_off",J.AlwaysOn="always_on",J.ParentBasedAlwaysOff="parentbased_always_off",J.ParentBasedAlwaysOn="parentbased_always_on",J.ParentBasedTraceIdRatio="parentbased_traceidratio",J.TraceIdRatio="traceidratio"})(x||(x={}));var jJ=1;function B6(){return{sampler:sQ(),forceFlushTimeoutMillis:30000,generalLimits:{attributeValueLengthLimit:(0,_.getNumberFromEnv)("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")??1/0,attributeCountLimit:(0,_.getNumberFromEnv)("OTEL_ATTRIBUTE_COUNT_LIMIT")??128},spanLimits:{attributeValueLengthLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT")??1/0,attributeCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT")??128,linkCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_LINK_COUNT_LIMIT")??128,eventCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_EVENT_COUNT_LIMIT")??128,attributePerEventCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT")??128,attributePerLinkCountLimit:(0,_.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT")??128}}}oQ.loadDefaultConfig=B6;function sQ(){let J=(0,_.getStringFromEnv)("OTEL_TRACES_SAMPLER")??x.ParentBasedAlwaysOn;switch(J){case x.AlwaysOn:return new SJ.AlwaysOnSampler;case x.AlwaysOff:return new pQ.AlwaysOffSampler;case x.ParentBasedAlwaysOn:return new BJ.ParentBasedSampler({root:new SJ.AlwaysOnSampler});case x.ParentBasedAlwaysOff:return new BJ.ParentBasedSampler({root:new pQ.AlwaysOffSampler});case x.TraceIdRatio:return new nQ.TraceIdRatioBasedSampler(iQ());case x.ParentBasedTraceIdRatio:return new BJ.ParentBasedSampler({root:new nQ.TraceIdRatioBasedSampler(iQ())});default:return vJ.diag.error(`OTEL_TRACES_SAMPLER value "${J}" invalid, defaulting to "${x.ParentBasedAlwaysOn}".`),new BJ.ParentBasedSampler({root:new SJ.AlwaysOnSampler})}}oQ.buildSamplerFromEnv=sQ;function iQ(){let J=(0,_.getNumberFromEnv)("OTEL_TRACES_SAMPLER_ARG");if(J==null)return vJ.diag.error(`OTEL_TRACES_SAMPLER_ARG is blank, defaulting to ${jJ}.`),jJ;if(J<0||J>1)return vJ.diag.error(`OTEL_TRACES_SAMPLER_ARG=${J} was given, but it is out of range ([0..1]), defaulting to ${jJ}.`),jJ;return J}});var lJ=K((tQ)=>{Object.defineProperty(tQ,"__esModule",{value:!0});tQ.reconfigureLimits=tQ.mergeConfig=tQ.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT=tQ.DEFAULT_ATTRIBUTE_COUNT_LIMIT=void 0;var rQ=gJ(),FJ=E();tQ.DEFAULT_ATTRIBUTE_COUNT_LIMIT=128;tQ.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT=1/0;function F6(J){let Q={sampler:(0,rQ.buildSamplerFromEnv)()},Z=(0,rQ.loadDefaultConfig)(),$=Object.assign({},Z,Q,J);return $.generalLimits=Object.assign({},Z.generalLimits,J.generalLimits||{}),$.spanLimits=Object.assign({},Z.spanLimits,J.spanLimits||{}),$}tQ.mergeConfig=F6;function h6(J){let Q=Object.assign({},J.spanLimits);return Q.attributeCountLimit=J.spanLimits?.attributeCountLimit??J.generalLimits?.attributeCountLimit??(0,FJ.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT")??(0,FJ.getNumberFromEnv)("OTEL_ATTRIBUTE_COUNT_LIMIT")??tQ.DEFAULT_ATTRIBUTE_COUNT_LIMIT,Q.attributeValueLengthLimit=J.spanLimits?.attributeValueLengthLimit??J.generalLimits?.attributeValueLengthLimit??(0,FJ.getNumberFromEnv)("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT")??(0,FJ.getNumberFromEnv)("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")??tQ.DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT,Object.assign({},J,{spanLimits:Q})}tQ.reconfigureLimits=h6});var WZ=K(($Z)=>{Object.defineProperty($Z,"__esModule",{value:!0});$Z.BatchSpanProcessorBase=void 0;var s=M(),S=E();class ZZ{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedSpans=[];_timer;_shutdownOnce;_droppedSpansCount=0;constructor(J,Q){if(this._exporter=J,this._maxExportBatchSize=typeof Q?.maxExportBatchSize==="number"?Q.maxExportBatchSize:(0,S.getNumberFromEnv)("OTEL_BSP_MAX_EXPORT_BATCH_SIZE")??512,this._maxQueueSize=typeof Q?.maxQueueSize==="number"?Q.maxQueueSize:(0,S.getNumberFromEnv)("OTEL_BSP_MAX_QUEUE_SIZE")??2048,this._scheduledDelayMillis=typeof Q?.scheduledDelayMillis==="number"?Q.scheduledDelayMillis:(0,S.getNumberFromEnv)("OTEL_BSP_SCHEDULE_DELAY")??5000,this._exportTimeoutMillis=typeof Q?.exportTimeoutMillis==="number"?Q.exportTimeoutMillis:(0,S.getNumberFromEnv)("OTEL_BSP_EXPORT_TIMEOUT")??30000,this._shutdownOnce=new S.BindOnceFuture(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize)s.diag.warn("BatchSpanProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize}forceFlush(){if(this._shutdownOnce.isCalled)return this._shutdownOnce.promise;return this._flushAll()}onStart(J,Q){}onEnd(J){if(this._shutdownOnce.isCalled)return;if((J.spanContext().traceFlags&s.TraceFlags.SAMPLED)===0)return;this._addToBuffer(J)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return Promise.resolve().then(()=>{return this.onShutdown()}).then(()=>{return this._flushAll()}).then(()=>{return this._exporter.shutdown()})}_addToBuffer(J){if(this._finishedSpans.length>=this._maxQueueSize){if(this._droppedSpansCount===0)s.diag.debug("maxQueueSize reached, dropping spans");this._droppedSpansCount++;return}if(this._droppedSpansCount>0)s.diag.warn(`Dropped ${this._droppedSpansCount} spans because maxQueueSize reached`),this._droppedSpansCount=0;this._finishedSpans.push(J),this._maybeStartTimer()}_flushAll(){return new Promise((J,Q)=>{let Z=[],$=Math.ceil(this._finishedSpans.length/this._maxExportBatchSize);for(let q=0,W=$;q<W;q++)Z.push(this._flushOneBatch());Promise.all(Z).then(()=>{J()}).catch(Q)})}_flushOneBatch(){if(this._clearTimer(),this._finishedSpans.length===0)return Promise.resolve();return new Promise((J,Q)=>{let Z=setTimeout(()=>{Q(Error("Timeout"))},this._exportTimeoutMillis);s.context.with((0,S.suppressTracing)(s.context.active()),()=>{let $;if(this._finishedSpans.length<=this._maxExportBatchSize)$=this._finishedSpans,this._finishedSpans=[];else $=this._finishedSpans.splice(0,this._maxExportBatchSize);let q=()=>this._exporter.export($,(X)=>{if(clearTimeout(Z),X.code===S.ExportResultCode.SUCCESS)J();else Q(X.error??Error("BatchSpanProcessor: span export failed"))}),W=null;for(let X=0,H=$.length;X<H;X++){let Y=$[X];if(Y.resource.asyncAttributesPending&&Y.resource.waitForAsyncAttributes)W??=[],W.push(Y.resource.waitForAsyncAttributes())}if(W===null)q();else Promise.all(W).then(q,(X)=>{(0,S.globalErrorHandler)(X),Q(X)})})})}_maybeStartTimer(){if(this._isExporting)return;let J=()=>{this._isExporting=!0,this._flushOneBatch().finally(()=>{if(this._isExporting=!1,this._finishedSpans.length>0)this._clearTimer(),this._maybeStartTimer()}).catch((Q)=>{this._isExporting=!1,(0,S.globalErrorHandler)(Q)})};if(this._finishedSpans.length>=this._maxExportBatchSize)return J();if(this._timer!==void 0)return;if(this._timer=setTimeout(()=>J(),this._scheduledDelayMillis),typeof this._timer!=="number")this._timer.unref()}_clearTimer(){if(this._timer!==void 0)clearTimeout(this._timer),this._timer=void 0}}$Z.BatchSpanProcessorBase=ZZ});var HZ=K((XZ)=>{Object.defineProperty(XZ,"__esModule",{value:!0});XZ.BatchSpanProcessor=void 0;var D6=WZ();class zZ extends D6.BatchSpanProcessorBase{onShutdown(){}}XZ.BatchSpanProcessor=zZ});var BZ=K((VZ)=>{Object.defineProperty(VZ,"__esModule",{value:!0});VZ.RandomIdGenerator=void 0;var E6=8,GZ=16;class wZ{generateTraceId=KZ(GZ);generateSpanId=KZ(E6)}VZ.RandomIdGenerator=wZ;var hJ=Buffer.allocUnsafe(GZ);function KZ(J){return function(){for(let Z=0;Z<J/4;Z++)hJ.writeUInt32BE(Math.random()*4294967296>>>0,Z*4);for(let Z=0;Z<J;Z++)if(hJ[Z]>0)break;else if(Z===J-1)hJ[J-1]=1;return hJ.toString("hex",0,J)}}});var jZ=K((OJ)=>{Object.defineProperty(OJ,"__esModule",{value:!0});OJ.RandomIdGenerator=OJ.BatchSpanProcessor=void 0;var k6=HZ();Object.defineProperty(OJ,"BatchSpanProcessor",{enumerable:!0,get:function(){return k6.BatchSpanProcessor}});var I6=BZ();Object.defineProperty(OJ,"RandomIdGenerator",{enumerable:!0,get:function(){return I6.RandomIdGenerator}})});var mJ=K((DJ)=>{Object.defineProperty(DJ,"__esModule",{value:!0});DJ.RandomIdGenerator=DJ.BatchSpanProcessor=void 0;var FZ=jZ();Object.defineProperty(DJ,"BatchSpanProcessor",{enumerable:!0,get:function(){return FZ.BatchSpanProcessor}});Object.defineProperty(DJ,"RandomIdGenerator",{enumerable:!0,get:function(){return FZ.RandomIdGenerator}})});var DZ=K((hZ)=>{Object.defineProperty(hZ,"__esModule",{value:!0});hZ.METRIC_OTEL_SDK_SPAN_STARTED=hZ.METRIC_OTEL_SDK_SPAN_LIVE=hZ.ATTR_OTEL_SPAN_SAMPLING_RESULT=hZ.ATTR_OTEL_SPAN_PARENT_ORIGIN=void 0;hZ.ATTR_OTEL_SPAN_PARENT_ORIGIN="otel.span.parent.origin";hZ.ATTR_OTEL_SPAN_SAMPLING_RESULT="otel.span.sampling_result";hZ.METRIC_OTEL_SDK_SPAN_LIVE="otel.sdk.span.live";hZ.METRIC_OTEL_SDK_SPAN_STARTED="otel.sdk.span.started"});var MZ=K((kZ)=>{Object.defineProperty(kZ,"__esModule",{value:!0});kZ.TracerMetrics=void 0;var EJ=i(),qJ=DZ();class EZ{startedSpans;liveSpans;constructor(J){this.startedSpans=J.createCounter(qJ.METRIC_OTEL_SDK_SPAN_STARTED,{unit:"{span}",description:"The number of created spans."}),this.liveSpans=J.createUpDownCounter(qJ.METRIC_OTEL_SDK_SPAN_LIVE,{unit:"{span}",description:"The number of currently live spans."})}startSpan(J,Q){let Z=N6(Q);if(this.startedSpans.add(1,{[qJ.ATTR_OTEL_SPAN_PARENT_ORIGIN]:P6(J),[qJ.ATTR_OTEL_SPAN_SAMPLING_RESULT]:Z}),Q===EJ.SamplingDecision.NOT_RECORD)return()=>{};let $={[qJ.ATTR_OTEL_SPAN_SAMPLING_RESULT]:Z};return this.liveSpans.add(1,$),()=>{this.liveSpans.add(-1,$)}}}kZ.TracerMetrics=EZ;function P6(J){if(!J)return"none";if(J.isRemote)return"remote";return"local"}function N6(J){switch(J){case EJ.SamplingDecision.RECORD_AND_SAMPLED:return"RECORD_AND_SAMPLE";case EJ.SamplingDecision.RECORD:return"RECORD_ONLY";case EJ.SamplingDecision.NOT_RECORD:return"DROP"}}});var CZ=K((AZ)=>{Object.defineProperty(AZ,"__esModule",{value:!0});AZ.VERSION=void 0;AZ.VERSION="2.6.1"});var fZ=K((PZ)=>{Object.defineProperty(PZ,"__esModule",{value:!0});PZ.Tracer=void 0;var F=M(),kJ=E(),f6=PQ(),T6=lJ(),b6=mJ(),_6=MZ(),x6=CZ();class LZ{_sampler;_generalLimits;_spanLimits;_idGenerator;instrumentationScope;_resource;_spanProcessor;_tracerMetrics;constructor(J,Q,Z,$){let q=(0,T6.mergeConfig)(Q);this._sampler=q.sampler,this._generalLimits=q.generalLimits,this._spanLimits=q.spanLimits,this._idGenerator=Q.idGenerator||new b6.RandomIdGenerator,this._resource=Z,this._spanProcessor=$,this.instrumentationScope=J;let W=q.meterProvider?q.meterProvider.getMeter("@opentelemetry/sdk-trace",x6.VERSION):F.createNoopMeter();this._tracerMetrics=new _6.TracerMetrics(W)}startSpan(J,Q={},Z=F.context.active()){if(Q.root)Z=F.trace.deleteSpan(Z);let $=F.trace.getSpan(Z);if((0,kJ.isTracingSuppressed)(Z))return F.diag.debug("Instrumentation suppressed, returning Noop Span"),F.trace.wrapSpanContext(F.INVALID_SPAN_CONTEXT);let q=$?.spanContext(),W=this._idGenerator.generateSpanId(),X,H,Y;if(!q||!F.trace.isSpanContextValid(q))H=this._idGenerator.generateTraceId();else H=q.traceId,Y=q.traceState,X=q;let V=Q.kind??F.SpanKind.INTERNAL,R=(Q.links??[]).map((D)=>{return{context:D.context,attributes:(0,kJ.sanitizeAttributes)(D.attributes)}}),z=(0,kJ.sanitizeAttributes)(Q.attributes),U=this._sampler.shouldSample(Z,H,J,V,z,R),I=this._tracerMetrics.startSpan(q,U.decision);Y=U.traceState??Y;let G=U.decision===F.SamplingDecision.RECORD_AND_SAMPLED?F.TraceFlags.SAMPLED:F.TraceFlags.NONE,w={traceId:H,spanId:W,traceFlags:G,traceState:Y};if(U.decision===F.SamplingDecision.NOT_RECORD)return F.diag.debug("Recording is off, propagating context in a non-recording span"),F.trace.wrapSpanContext(w);let B=(0,kJ.sanitizeAttributes)(Object.assign(z,U.attributes));return new f6.SpanImpl({resource:this._resource,scope:this.instrumentationScope,context:Z,spanContext:w,name:J,kind:V,links:R,parentSpanContext:X,attributes:B,startTime:Q.startTime,spanProcessor:this._spanProcessor,spanLimits:this._spanLimits,recordEndMetrics:I})}startActiveSpan(J,Q,Z,$){let q,W,X;if(arguments.length<2)return;else if(arguments.length===2)X=Q;else if(arguments.length===3)q=Q,X=Z;else q=Q,W=Z,X=$;let H=W??F.context.active(),Y=this.startSpan(J,q,H),V=F.trace.setSpan(H,Y);return F.context.with(V,X,void 0,Y)}getGeneralLimits(){return this._generalLimits}getSpanLimits(){return this._spanLimits}}PZ.Tracer=LZ});var xZ=K((bZ)=>{Object.defineProperty(bZ,"__esModule",{value:!0});bZ.MultiSpanProcessor=void 0;var d6=E();class TZ{_spanProcessors;constructor(J){this._spanProcessors=J}forceFlush(){let J=[];for(let Q of this._spanProcessors)J.push(Q.forceFlush());return new Promise((Q)=>{Promise.all(J).then(()=>{Q()}).catch((Z)=>{(0,d6.globalErrorHandler)(Z||Error("MultiSpanProcessor: forceFlush failed")),Q()})})}onStart(J,Q){for(let Z of this._spanProcessors)Z.onStart(J,Q)}onEnding(J){for(let Q of this._spanProcessors)if(Q.onEnding)Q.onEnding(J)}onEnd(J){for(let Q of this._spanProcessors)Q.onEnd(J)}shutdown(){let J=[];for(let Q of this._spanProcessors)J.push(Q.shutdown());return new Promise((Q,Z)=>{Promise.all(J).then(()=>{Q()},Z)})}}bZ.MultiSpanProcessor=TZ});var lZ=K((vZ)=>{Object.defineProperty(vZ,"__esModule",{value:!0});vZ.BasicTracerProvider=vZ.ForceFlushState=void 0;var y6=E(),S6=yZ(),v6=fZ(),g6=gJ(),l6=xZ(),m6=lJ(),o;(function(J){J[J.resolved=0]="resolved",J[J.timeout=1]="timeout",J[J.error=2]="error",J[J.unresolved=3]="unresolved"})(o=vZ.ForceFlushState||(vZ.ForceFlushState={}));class SZ{_config;_tracers=new Map;_resource;_activeSpanProcessor;constructor(J={}){let Q=(0,y6.merge)({},(0,g6.loadDefaultConfig)(),(0,m6.reconfigureLimits)(J));this._resource=Q.resource??(0,S6.defaultResource)(),this._config=Object.assign({},Q,{resource:this._resource});let Z=[];if(J.spanProcessors?.length)Z.push(...J.spanProcessors);this._activeSpanProcessor=new l6.MultiSpanProcessor(Z)}getTracer(J,Q,Z){let $=`${J}@${Q||""}:${Z?.schemaUrl||""}`;if(!this._tracers.has($))this._tracers.set($,new v6.Tracer({name:J,version:Q,schemaUrl:Z?.schemaUrl},this._config,this._resource,this._activeSpanProcessor));return this._tracers.get($)}forceFlush(){let J=this._config.forceFlushTimeoutMillis,Q=this._activeSpanProcessor._spanProcessors.map((Z)=>{return new Promise(($)=>{let q,W=setTimeout(()=>{$(Error(`Span processor did not completed within timeout period of ${J} ms`)),q=o.timeout},J);Z.forceFlush().then(()=>{if(clearTimeout(W),q!==o.timeout)q=o.resolved,$(q)}).catch((X)=>{clearTimeout(W),q=o.error,$(X)})})});return new Promise((Z,$)=>{Promise.all(Q).then((q)=>{let W=q.filter((X)=>X!==o.resolved);if(W.length>0)$(W);else Z()}).catch((q)=>$([q]))})}shutdown(){return this._activeSpanProcessor.shutdown()}}vZ.BasicTracerProvider=SZ});var pZ=K((uZ)=>{Object.defineProperty(uZ,"__esModule",{value:!0});uZ.ConsoleSpanExporter=void 0;var uJ=E();class mZ{export(J,Q){return this._sendSpans(J,Q)}shutdown(){return this._sendSpans([]),this.forceFlush()}forceFlush(){return Promise.resolve()}_exportInfo(J){return{resource:{attributes:J.resource.attributes},instrumentationScope:J.instrumentationScope,traceId:J.spanContext().traceId,parentSpanContext:J.parentSpanContext,traceState:J.spanContext().traceState?.serialize(),name:J.name,id:J.spanContext().spanId,kind:J.kind,timestamp:(0,uJ.hrTimeToMicroseconds)(J.startTime),duration:(0,uJ.hrTimeToMicroseconds)(J.duration),attributes:J.attributes,status:J.status,events:J.events,links:J.links}}_sendSpans(J,Q){for(let Z of J)console.dir(this._exportInfo(Z),{depth:3});if(Q)return Q({code:uJ.ExportResultCode.SUCCESS})}}uZ.ConsoleSpanExporter=mZ});var aZ=K((sZ)=>{Object.defineProperty(sZ,"__esModule",{value:!0});sZ.InMemorySpanExporter=void 0;var nZ=E();class iZ{_finishedSpans=[];_stopped=!1;export(J,Q){if(this._stopped)return Q({code:nZ.ExportResultCode.FAILED,error:Error("Exporter has been stopped")});this._finishedSpans.push(...J),setTimeout(()=>Q({code:nZ.ExportResultCode.SUCCESS}),0)}shutdown(){return this._stopped=!0,this._finishedSpans=[],this.forceFlush()}forceFlush(){return Promise.resolve()}reset(){this._finishedSpans=[]}getFinishedSpans(){return this._finishedSpans}}sZ.InMemorySpanExporter=iZ});var J0=K((tZ)=>{Object.defineProperty(tZ,"__esModule",{value:!0});tZ.SimpleSpanProcessor=void 0;var u6=M(),IJ=E();class rZ{_exporter;_shutdownOnce;_pendingExports;constructor(J){this._exporter=J,this._shutdownOnce=new IJ.BindOnceFuture(this._shutdown,this),this._pendingExports=new Set}async forceFlush(){if(await Promise.all(Array.from(this._pendingExports)),this._exporter.forceFlush)await this._exporter.forceFlush()}onStart(J,Q){}onEnd(J){if(this._shutdownOnce.isCalled)return;if((J.spanContext().traceFlags&u6.TraceFlags.SAMPLED)===0)return;let Q=this._doExport(J).catch((Z)=>(0,IJ.globalErrorHandler)(Z));this._pendingExports.add(Q),Q.finally(()=>this._pendingExports.delete(Q))}async _doExport(J){if(J.resource.asyncAttributesPending)await J.resource.waitForAsyncAttributes?.();let Q=await IJ.internal._export(this._exporter,[J]);if(Q.code!==IJ.ExportResultCode.SUCCESS)throw Q.error??Error(`SimpleSpanProcessor: span export failed (status ${Q})`)}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}}tZ.SimpleSpanProcessor=rZ});var q0=K((Z0)=>{Object.defineProperty(Z0,"__esModule",{value:!0});Z0.NoopSpanProcessor=void 0;class Q0{onStart(J,Q){}onEnd(J){}shutdown(){return Promise.resolve()}forceFlush(){return Promise.resolve()}}Z0.NoopSpanProcessor=Q0});var cJ=K((A)=>{Object.defineProperty(A,"__esModule",{value:!0});A.SamplingDecision=A.TraceIdRatioBasedSampler=A.ParentBasedSampler=A.AlwaysOnSampler=A.AlwaysOffSampler=A.NoopSpanProcessor=A.SimpleSpanProcessor=A.InMemorySpanExporter=A.ConsoleSpanExporter=A.RandomIdGenerator=A.BatchSpanProcessor=A.BasicTracerProvider=void 0;var c6=lZ();Object.defineProperty(A,"BasicTracerProvider",{enumerable:!0,get:function(){return c6.BasicTracerProvider}});var W0=mJ();Object.defineProperty(A,"BatchSpanProcessor",{enumerable:!0,get:function(){return W0.BatchSpanProcessor}});Object.defineProperty(A,"RandomIdGenerator",{enumerable:!0,get:function(){return W0.RandomIdGenerator}});var p6=pZ();Object.defineProperty(A,"ConsoleSpanExporter",{enumerable:!0,get:function(){return p6.ConsoleSpanExporter}});var n6=aZ();Object.defineProperty(A,"InMemorySpanExporter",{enumerable:!0,get:function(){return n6.InMemorySpanExporter}});var i6=J0();Object.defineProperty(A,"SimpleSpanProcessor",{enumerable:!0,get:function(){return i6.SimpleSpanProcessor}});var s6=q0();Object.defineProperty(A,"NoopSpanProcessor",{enumerable:!0,get:function(){return s6.NoopSpanProcessor}});var o6=wJ();Object.defineProperty(A,"AlwaysOffSampler",{enumerable:!0,get:function(){return o6.AlwaysOffSampler}});var a6=VJ();Object.defineProperty(A,"AlwaysOnSampler",{enumerable:!0,get:function(){return a6.AlwaysOnSampler}});var r6=dJ();Object.defineProperty(A,"ParentBasedSampler",{enumerable:!0,get:function(){return r6.ParentBasedSampler}});var t6=yJ();Object.defineProperty(A,"TraceIdRatioBasedSampler",{enumerable:!0,get:function(){return t6.TraceIdRatioBasedSampler}});var e6=i();Object.defineProperty(A,"SamplingDecision",{enumerable:!0,get:function(){return e6.SamplingDecision}})});var H0=K((X0)=>{Object.defineProperty(X0,"__esModule",{value:!0});X0.NodeTracerProvider=void 0;var Q7=EQ(),Z7=cJ(),WJ=M(),pJ=E();function $7(J){if(J===null)return;if(J===void 0){let Q=new Q7.AsyncLocalStorageContextManager;Q.enable(),WJ.context.setGlobalContextManager(Q);return}J.enable(),WJ.context.setGlobalContextManager(J)}function q7(J){if(J===null)return;if(J===void 0){WJ.propagation.setGlobalPropagator(new pJ.CompositePropagator({propagators:[new pJ.W3CTraceContextPropagator,new pJ.W3CBaggagePropagator]}));return}WJ.propagation.setGlobalPropagator(J)}class z0 extends Z7.BasicTracerProvider{constructor(J={}){super(J)}register(J={}){WJ.trace.setGlobalTracerProvider(this),$7(J.contextManager),q7(J.propagator)}}X0.NodeTracerProvider=z0});var K0=K((k)=>{Object.defineProperty(k,"__esModule",{value:!0});k.TraceIdRatioBasedSampler=k.SimpleSpanProcessor=k.SamplingDecision=k.RandomIdGenerator=k.ParentBasedSampler=k.NoopSpanProcessor=k.InMemorySpanExporter=k.ConsoleSpanExporter=k.BatchSpanProcessor=k.BasicTracerProvider=k.AlwaysOnSampler=k.AlwaysOffSampler=k.NodeTracerProvider=void 0;var W7=H0();Object.defineProperty(k,"NodeTracerProvider",{enumerable:!0,get:function(){return W7.NodeTracerProvider}});var L=cJ();Object.defineProperty(k,"AlwaysOffSampler",{enumerable:!0,get:function(){return L.AlwaysOffSampler}});Object.defineProperty(k,"AlwaysOnSampler",{enumerable:!0,get:function(){return L.AlwaysOnSampler}});Object.defineProperty(k,"BasicTracerProvider",{enumerable:!0,get:function(){return L.BasicTracerProvider}});Object.defineProperty(k,"BatchSpanProcessor",{enumerable:!0,get:function(){return L.BatchSpanProcessor}});Object.defineProperty(k,"ConsoleSpanExporter",{enumerable:!0,get:function(){return L.ConsoleSpanExporter}});Object.defineProperty(k,"InMemorySpanExporter",{enumerable:!0,get:function(){return L.InMemorySpanExporter}});Object.defineProperty(k,"NoopSpanProcessor",{enumerable:!0,get:function(){return L.NoopSpanProcessor}});Object.defineProperty(k,"ParentBasedSampler",{enumerable:!0,get:function(){return L.ParentBasedSampler}});Object.defineProperty(k,"RandomIdGenerator",{enumerable:!0,get:function(){return L.RandomIdGenerator}});Object.defineProperty(k,"SamplingDecision",{enumerable:!0,get:function(){return L.SamplingDecision}});Object.defineProperty(k,"SimpleSpanProcessor",{enumerable:!0,get:function(){return L.SimpleSpanProcessor}});Object.defineProperty(k,"TraceIdRatioBasedSampler",{enumerable:!0,get:function(){return L.TraceIdRatioBasedSampler}})});var a0=d(K0(),1);var MJ=(J)=>J!==void 0&&!(Array.isArray(J)&&J.length===0);var HJ=d(M(),1);var v;(function(J){J[J.UNSPECIFIED=0]="UNSPECIFIED",J[J.TRACE=1]="TRACE",J[J.TRACE2=2]="TRACE2",J[J.TRACE3=3]="TRACE3",J[J.TRACE4=4]="TRACE4",J[J.DEBUG=5]="DEBUG",J[J.DEBUG2=6]="DEBUG2",J[J.DEBUG3=7]="DEBUG3",J[J.DEBUG4=8]="DEBUG4",J[J.INFO=9]="INFO",J[J.INFO2=10]="INFO2",J[J.INFO3=11]="INFO3",J[J.INFO4=12]="INFO4",J[J.WARN=13]="WARN",J[J.WARN2=14]="WARN2",J[J.WARN3=15]="WARN3",J[J.WARN4=16]="WARN4",J[J.ERROR=17]="ERROR",J[J.ERROR2=18]="ERROR2",J[J.ERROR3=19]="ERROR3",J[J.ERROR4=20]="ERROR4",J[J.FATAL=21]="FATAL",J[J.FATAL2=22]="FATAL2",J[J.FATAL3=23]="FATAL3",J[J.FATAL4=24]="FATAL4"})(v||(v={}));class zJ{emit(J){}}var XJ=new zJ;var YJ=Symbol.for("io.opentelemetry.js.api.logs"),a=globalThis;function G0(J,Q,Z){return($)=>$===J?Q:Z}var nJ=1;class w0{getLogger(J,Q,Z){return new zJ}}var AJ=new w0;class iJ{constructor(J,Q,Z,$){this._provider=J,this.name=Q,this.version=Z,this.options=$}emit(J){this._getLogger().emit(J)}_getLogger(){if(this._delegate)return this._delegate;let J=this._provider._getDelegateLogger(this.name,this.version,this.options);if(!J)return XJ;return this._delegate=J,this._delegate}}class RJ{getLogger(J,Q,Z){var $;return($=this._getDelegateLogger(J,Q,Z))!==null&&$!==void 0?$:new iJ(this,J,Q,Z)}_getDelegate(){var J;return(J=this._delegate)!==null&&J!==void 0?J:AJ}_setDelegate(J){this._delegate=J}_getDelegateLogger(J,Q,Z){var $;return($=this._delegate)===null||$===void 0?void 0:$.getLogger(J,Q,Z)}}class CJ{constructor(){this._proxyLoggerProvider=new RJ}static getInstance(){if(!this._instance)this._instance=new CJ;return this._instance}setGlobalLoggerProvider(J){if(a[YJ])return this.getLoggerProvider();return a[YJ]=G0(nJ,J,AJ),this._proxyLoggerProvider._setDelegate(J),J}getLoggerProvider(){var J,Q;return(Q=(J=a[YJ])===null||J===void 0?void 0:J.call(a,nJ))!==null&&Q!==void 0?Q:this._proxyLoggerProvider}getLogger(J,Q,Z){return this.getLoggerProvider().getLogger(J,Q,Z)}disable(){delete a[YJ],this._proxyLoggerProvider=new RJ}}var l8=CJ.getInstance();var j0=d(yZ(),1),F0=d(E(),1);var T=d(M(),1);var f=d(M(),1),oJ=d(E(),1),C=d(AQ(),1);function V0(J){return sJ(J,new WeakSet)}function sJ(J,Q){if(J==null)return!0;if(typeof J==="string"||typeof J==="number"||typeof J==="boolean")return!0;if(J instanceof Uint8Array)return!0;if(typeof J==="object"){if(Q.has(J))return!1;if(Q.add(J),Array.isArray(J))return J.every(($)=>sJ($,Q));let Z=J;if(Z.constructor!==Object&&Z.constructor!==void 0)return!1;return Object.values(Z).every(($)=>sJ($,Q))}return!1}class aJ{hrTime;hrTimeObserved;spanContext;resource;instrumentationScope;attributes={};_severityText;_severityNumber;_body;_eventName;_attributesCount=0;_droppedAttributesCount=0;_isReadonly=!1;_logRecordLimits;set severityText(J){if(this._isLogRecordReadonly())return;this._severityText=J}get severityText(){return this._severityText}set severityNumber(J){if(this._isLogRecordReadonly())return;this._severityNumber=J}get severityNumber(){return this._severityNumber}set body(J){if(this._isLogRecordReadonly())return;this._body=J}get body(){return this._body}get eventName(){return this._eventName}set eventName(J){if(this._isLogRecordReadonly())return;this._eventName=J}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(J,Q,Z){let{timestamp:$,observedTimestamp:q,eventName:W,severityNumber:X,severityText:H,body:Y,attributes:V={},exception:R,context:z}=Z,U=Date.now();if(this.hrTime=oJ.timeInputToHrTime($??U),this.hrTimeObserved=oJ.timeInputToHrTime(q??U),z){let I=f.trace.getSpanContext(z);if(I&&f.isSpanContextValid(I))this.spanContext=I}if(this.severityNumber=X,this.severityText=H,this.body=Y,this.resource=J.resource,this.instrumentationScope=Q,this._logRecordLimits=J.logRecordLimits,this._eventName=W,this.setAttributes(V),R!=null)this._setException(R)}setAttribute(J,Q){if(this._isLogRecordReadonly())return this;if(J.length===0)return f.diag.warn(`Invalid attribute key: ${J}`),this;if(!V0(Q))return f.diag.warn(`Invalid attribute value set for key: ${J}`),this;let Z=!Object.prototype.hasOwnProperty.call(this.attributes,J);if(Z&&this._attributesCount>=this._logRecordLimits.attributeCountLimit){if(this._droppedAttributesCount++,this._droppedAttributesCount===1)f.diag.warn("Dropping extra attributes.");return this}if(this.attributes[J]=this._truncateToSize(Q),Z)this._attributesCount++;return this}setAttributes(J){for(let[Q,Z]of Object.entries(J))this.setAttribute(Q,Z);return this}setBody(J){return this.body=J,this}setEventName(J){return this.eventName=J,this}setSeverityNumber(J){return this.severityNumber=J,this}setSeverityText(J){return this.severityText=J,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(J){let Q=this._logRecordLimits.attributeValueLengthLimit;if(Q<=0)return f.diag.warn(`Attribute value limit must be positive, got ${Q}`),J;if(J==null)return J;if(typeof J==="string")return this._truncateToLimitUtil(J,Q);if(J instanceof Uint8Array)return J;if(Array.isArray(J))return J.map((Z)=>this._truncateToSize(Z));if(typeof J==="object"){let Z={};for(let[$,q]of Object.entries(J))Z[$]=this._truncateToSize(q);return Z}return J}_setException(J){let Q=!1;if(typeof J==="string"||typeof J==="number"){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_MESSAGE))this.setAttribute(C.ATTR_EXCEPTION_MESSAGE,String(J));Q=!0}else if(J&&typeof J==="object"){let Z=J;if(Z.code){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_TYPE))this.setAttribute(C.ATTR_EXCEPTION_TYPE,Z.code.toString());Q=!0}else if(Z.name){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_TYPE))this.setAttribute(C.ATTR_EXCEPTION_TYPE,Z.name);Q=!0}if(Z.message){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_MESSAGE))this.setAttribute(C.ATTR_EXCEPTION_MESSAGE,Z.message);Q=!0}if(Z.stack){if(!Object.hasOwn(this.attributes,C.ATTR_EXCEPTION_STACKTRACE))this.setAttribute(C.ATTR_EXCEPTION_STACKTRACE,Z.stack);Q=!0}}if(!Q)f.diag.warn(`Failed to record an exception ${J}`)}_truncateToLimitUtil(J,Q){if(J.length<=Q)return J;return J.substring(0,Q)}_isLogRecordReadonly(){if(this._isReadonly)f.diag.warn("Can not execute the operation on emitted log record");return this._isReadonly}}class rJ{instrumentationScope;_sharedState;_loggerConfig;constructor(J,Q){this.instrumentationScope=J,this._sharedState=Q,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(J){let Q=this._loggerConfig,Z=J.context||T.context.active(),$=J.severityNumber??v.UNSPECIFIED;if($!==v.UNSPECIFIED&&$<Q.minimumSeverity)return;if(Q.traceBased){let W=T.trace.getSpanContext(Z);if(W&&T.isSpanContextValid(W)){if((W.traceFlags&T.TraceFlags.SAMPLED)!==T.TraceFlags.SAMPLED)return}}let q=new aJ(this._sharedState,this.instrumentationScope,{context:Z,...J});this._sharedState.activeProcessor.onEmit(q,Z),q._makeReadonly()}}class tJ{forceFlush(){return Promise.resolve()}onEmit(J,Q){}shutdown(){return Promise.resolve()}}var U0=d(E(),1);class eJ{processors;forceFlushTimeoutMillis;constructor(J,Q){this.processors=J,this.forceFlushTimeoutMillis=Q}async forceFlush(){let J=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map((Q)=>U0.callWithTimeout(Q.forceFlush(),J)))}onEmit(J,Q){this.processors.forEach((Z)=>Z.onEmit(J,Q))}async shutdown(){await Promise.all(this.processors.map((J)=>J.shutdown()))}}function B0(J){return`${J.name}@${J.version||""}:${J.schemaUrl||""}`}var X7={disabled:!1,minimumSeverity:v.UNSPECIFIED,traceBased:!1},JQ=()=>({...X7});class QQ{loggers=new Map;activeProcessor;registeredLogRecordProcessors=[];resource;forceFlushTimeoutMillis;logRecordLimits;processors;_loggerConfigurator;_loggerConfigs=new Map;constructor(J,Q,Z,$,q){if(this.resource=J,this.forceFlushTimeoutMillis=Q,this.logRecordLimits=Z,this.processors=$,$.length>0)this.registeredLogRecordProcessors=$,this.activeProcessor=new eJ(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis);else this.activeProcessor=new tJ;this._loggerConfigurator=q??JQ}getLoggerConfig(J){let Q=B0(J),Z=this._loggerConfigs.get(Q);if(Z)return Z;return Z=this._loggerConfigurator(J),this._loggerConfigs.set(Q,Z),Z}}var Y7="unknown";class LJ{_shutdownOnce;_sharedState;constructor(J={}){let Q={resource:J.resource??j0.defaultResource(),forceFlushTimeoutMillis:J.forceFlushTimeoutMillis??30000,logRecordLimits:{attributeCountLimit:J.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:J.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:J.loggerConfigurator??JQ,processors:J.processors??[]};this._sharedState=new QQ(Q.resource,Q.forceFlushTimeoutMillis,Q.logRecordLimits,Q.processors,Q.loggerConfigurator),this._shutdownOnce=new F0.BindOnceFuture(this._shutdown,this)}getLogger(J,Q,Z){if(this._shutdownOnce.isCalled)return HJ.diag.warn("A shutdown LoggerProvider cannot provide a Logger"),XJ;if(!J)HJ.diag.warn("Logger requested without instrumentation scope name.");let $=J||Y7,q=`${$}@${Q||""}:${Z?.schemaUrl||""}`;if(!this._sharedState.loggers.has(q))this._sharedState.loggers.set(q,new rJ({name:$,version:Q,schemaUrl:Z?.schemaUrl},this._sharedState));return this._sharedState.loggers.get(q)}forceFlush(){if(this._shutdownOnce.isCalled)return HJ.diag.warn("invalid attempt to force flush after LoggerProvider shutdown"),this._shutdownOnce.promise;return this._sharedState.activeProcessor.forceFlush()}shutdown(){if(this._shutdownOnce.isCalled)return HJ.diag.warn("shutdown may only be called once per LoggerProvider"),this._shutdownOnce.promise;return this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}}class qQ extends O0()("@effect/opentelemetry/Logger/OtelLoggerProvider"){}var G7=g(function*(){let J=yield*qQ,Q=yield*A0,Z=J.getLogger("@effect/opentelemetry");return L0(($)=>{let q={fiberId:$.fiber.id},W=D0($.fiber.context,E0);if(h0(W))q.spanId=W.spanId,q.traceId=W.traceId;for(let[V,R]of Object.entries($.fiber.getRef(k0)))q[V]=ZQ(R);let X=$.date.getTime();for(let[V,R]of $.fiber.getRef(I0))q[`logSpan.${V}`]=`${X-R}ms`;let H=$Q($.message).map(ZQ),Y=N0(Q.currentTimeNanosUnsafe());Z.emit({body:H.length===1?H[0]:H,severityText:$.logLevel,severityNumber:C0($.logLevel),timestamp:Y,observedTimestamp:Y,attributes:q})})}),f0=(J)=>P0([G7],{mergeWithExisting:J.mergeWithExisting??!0}),T0=(J,Q)=>PJ(qQ,g(function*(){let Z=yield*ZJ;return yield*JJ(u(()=>new LJ({...Q??void 0,processors:$Q(J),resource:Z})),($)=>r(()=>$.forceFlush().then(()=>$.shutdown())).pipe(t,QJ,e(Q?.shutdownTimeout??3000)))}));var l=d(M(),1);var c;(function(J){J[J.DELTA=0]="DELTA",J[J.CUMULATIVE=1]="CUMULATIVE"})(c||(c={}));var P;(function(J){J.COUNTER="COUNTER",J.GAUGE="GAUGE",J.HISTOGRAM="HISTOGRAM",J.UP_DOWN_COUNTER="UP_DOWN_COUNTER",J.OBSERVABLE_COUNTER="OBSERVABLE_COUNTER",J.OBSERVABLE_GAUGE="OBSERVABLE_GAUGE",J.OBSERVABLE_UP_DOWN_COUNTER="OBSERVABLE_UP_DOWN_COUNTER"})(P||(P={}));var b;(function(J){J[J.HISTOGRAM=0]="HISTOGRAM",J[J.EXPONENTIAL_HISTOGRAM=1]="EXPONENTIAL_HISTOGRAM",J[J.GAUGE=2]="GAUGE",J[J.SUM=3]="SUM"})(b||(b={}));var V7="@effect/opentelemetry/Metrics";class zQ{resource;context;temporality;startTimes;startTimeNanos;previousExportTimeNanos;previousCounterState;previousHistogramState;previousFrequencyState;previousSummaryState;constructor(J,Q,Z="cumulative"){this.resource=J,this.context=Q,this.temporality=Z,this.startTimes=new Map,this.startTimeNanos=b0(),this.previousExportTimeNanos=this.startTimeNanos,this.previousCounterState=new Map,this.previousHistogramState=new Map,this.previousFrequencyState=new Map,this.previousSummaryState=new Map}startTimeFor(J,Q){if(this.startTimes.has(J))return this.startTimes.get(J);return this.startTimes.set(J,Q),Q}collect(J){let Q=x0(this.context),Z=b0(),$=[],q=new Map,W=(V)=>{$.push(V),q.set(V.descriptor.name,V)},X=this.temporality==="delta",H=X?c.DELTA:c.CUMULATIVE,Y=X?this.previousExportTimeNanos:this.startTimeNanos;for(let V=0,R=Q.length;V<R;V++){let z=Q[V],U=z.attributes?_0(Object.entries(z.attributes),{},(G,[w,B])=>{return G[w]=String(B),G}):{},I=U7(z.id,z.attributes);switch(z.type){case"Counter":{let G=z.state.count,w=G;if(X){let j=this.previousCounterState.get(I);if(j!==void 0)if(typeof G==="bigint"&&typeof j==="bigint"){if(w=G-j,w<0n)w=G}else{let y=Number(G),p=Number(j);if(w=y-p,w<0)w=y}this.previousCounterState.set(I,G)}let B=$J(z,U),D={startTime:this.startTimeFor(B.name,Y),endTime:Z,attributes:U,value:Number(w)};if(q.has(z.id))q.get(z.id).dataPoints.push(D);else W({dataPointType:b.SUM,descriptor:B,isMonotonic:z.state.incremental,aggregationTemporality:H,dataPoints:[D]});break}case"Gauge":{let G=$J(z,U),B={startTime:this.startTimeFor(G.name,this.startTimeNanos),endTime:Z,attributes:U,value:Number(z.state.value)};if(q.has(z.id))q.get(z.id).dataPoints.push(B);else W({dataPointType:b.GAUGE,descriptor:G,aggregationTemporality:c.CUMULATIVE,dataPoints:[B]});break}case"Histogram":{let G=z.state.buckets.length,w={boundaries:WQ(G-1),counts:WQ(G)},B=0,N=0;for(let[n,KJ]of z.state.buckets){if(B<G-1)w.boundaries[B]=n;w.counts[B]=KJ-N,N=KJ,B++}let D=z.state.count,j=z.state.sum,y=w.counts,p=z.state.min,fJ=z.state.max;if(X){let n=this.previousHistogramState.get(I);if(n!==void 0)D=z.state.count-n.count,j=z.state.sum-n.sum,y=w.counts.map((KJ,r0)=>Math.max(0,KJ-(n.bucketCounts[r0]??0)));this.previousHistogramState.set(I,{count:z.state.count,sum:z.state.sum,bucketCounts:w.counts.slice(),min:z.state.min,max:z.state.max})}let YQ=$J(z,U),HQ={startTime:this.startTimeFor(YQ.name,Y),endTime:Z,attributes:U,value:{buckets:{boundaries:w.boundaries,counts:y},count:D,min:p,max:fJ,sum:j}};if(q.has(z.id))q.get(z.id).dataPoints.push(HQ);else W({dataPointType:b.HISTOGRAM,descriptor:YQ,aggregationTemporality:H,dataPoints:[HQ]});break}case"Frequency":{let G=[],w=new Map;for(let[B,N]of z.state.occurrences){w.set(B,N);let D=N;if(X){let p=this.previousFrequencyState.get(I);if(p!==void 0){let fJ=p.get(B)??0;D=Math.max(0,N-fJ)}}let j=$J(z,U),y=this.startTimeFor(j.name,Y);G.push({startTime:y,endTime:Z,attributes:{...U,key:B},value:D})}if(X)this.previousFrequencyState.set(I,w);if(q.has(z.id))q.get(z.id).dataPoints.push(...G);else{let B=$J(z,U);W({dataPointType:b.SUM,descriptor:B,aggregationTemporality:H,isMonotonic:!0,dataPoints:G})}break}case"Summary":{let G=[{startTime:Y,endTime:Z,attributes:{...U,quantile:"min"},value:z.state.min}];for(let[j,y]of z.state.quantiles)G.push({startTime:Y,endTime:Z,attributes:{...U,quantile:j.toString()},value:y??0});G.push({startTime:Y,endTime:Z,attributes:{...U,quantile:"max"},value:z.state.max});let w=z.state.count,B=z.state.sum;if(X){let j=this.previousSummaryState.get(I);if(j!==void 0)w=z.state.count-j.count,B=z.state.sum-j.sum;this.previousSummaryState.set(I,{count:z.state.count,sum:z.state.sum})}let N={startTime:Y,endTime:Z,attributes:U,value:w},D={startTime:Y,endTime:Z,attributes:U,value:B};if(q.has(`${z.id}_quantiles`))q.get(`${z.id}_quantiles`).dataPoints.push(...G),q.get(`${z.id}_count`).dataPoints.push(N),q.get(`${z.id}_sum`).dataPoints.push(D);else{let j=$J(z,U);W({dataPointType:b.SUM,descriptor:{...j,name:`${j.name}_quantiles`},aggregationTemporality:H,isMonotonic:!1,dataPoints:G}),W({dataPointType:b.SUM,descriptor:{name:`${z.id}_count`,description:z.description??"",unit:"1",type:P.COUNTER,valueType:l.ValueType.INT,advice:{}},aggregationTemporality:H,isMonotonic:!0,dataPoints:[N]}),W({dataPointType:b.SUM,descriptor:{name:`${z.id}_sum`,description:z.description??"",unit:"1",type:P.COUNTER,valueType:l.ValueType.DOUBLE,advice:{}},aggregationTemporality:H,isMonotonic:!0,dataPoints:[D]})}break}}}if(X)this.previousExportTimeNanos=Z;return Promise.resolve({resourceMetrics:{resource:this.resource,scopeMetrics:[{scope:{name:V7},metrics:$}]},errors:[]})}}var U7=(J,Q)=>{if(Q===void 0||Object.keys(Q).length===0)return J;let Z=Object.entries(Q).sort(($,q)=>$[0].localeCompare(q[0]));return`${J}:${JSON.stringify(Z)}`},b0=()=>{let J=Date.now();return[Math.floor(J/1000),J%1000*1e6]},$J=(J,Q)=>{let Z=Q.unit??Q.time_unit??"1";return{name:J.id,description:J.description??"",unit:Z,type:B7(J),valueType:j7(J),advice:{}}},B7=(J)=>{switch(J.type){case"Histogram":return P.HISTOGRAM;case"Gauge":return P.OBSERVABLE_GAUGE;case"Frequency":return P.COUNTER;case"Counter":return J.state.incremental?P.COUNTER:P.UP_DOWN_COUNTER;case"Summary":return P.COUNTER}},j7=(J)=>{if(J.type==="Counter")return typeof J.state.count==="bigint"?l.ValueType.INT:l.ValueType.DOUBLE;else if(J.type==="Gauge")return typeof J.state.value==="bigint"?l.ValueType.INT:l.ValueType.DOUBLE;return l.ValueType.DOUBLE};var F7=(J)=>g(function*(){let Q=yield*ZJ,Z=yield*S0();return new zQ(Q,Z,J)}),h7=(J,Q,Z)=>JJ(u(()=>{let $=Q(),q=Array.isArray($)?$:[$];return q.forEach((W)=>W.setMetricProducer(J)),q}),($)=>r(()=>Promise.all($.map((q)=>q.shutdown()))).pipe(t,QJ,e(Z?.shutdownTimeout??3000))),v0=(J,Q)=>d0(y0(F7(Q?.temporality),(Z)=>h7(Z,J,Q)));var D7=(J,Q)=>PJ(s0,g(function*(){let Z=yield*ZJ;return yield*JJ(u(()=>{return new a0.NodeTracerProvider({...Q??void 0,resource:Z,spanProcessors:Array.isArray(J)?J:[J]})}),($)=>r(()=>$.forceFlush().then(()=>$.shutdown())).pipe(t,QJ,e(Q?.shutdownTimeout??3000)))})),a9=(J)=>l0(g(function*(){let Q=yield*c0(J)?J:u(J),Z=n0(Q.resource&&p0(Q.resource)),$=MJ(Q.spanProcessor)?XQ(o0,D7(Q.spanProcessor,{...Q.tracerConfig,shutdownTimeout:Q.shutdownTimeout})):NJ,q=MJ(Q.metricReader)?v0(g0(Q.metricReader),{shutdownTimeout:Q.shutdownTimeout,temporality:Q.metricTemporality}):NJ,W=MJ(Q.logRecordProcessor)?XQ(f0({mergeWithExisting:Q.loggerMergeWithExisting}),T0(Q.logRecordProcessor,{...Q.loggerProviderConfig,shutdownTimeout:Q.shutdownTimeout})):NJ;return m0($,q,W).pipe(u0(Z))})),r9=i0;export{D7 as layerTracerProvider,r9 as layerEmpty,a9 as layer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ng as a}from"./chunk-4aajzxm9.js";import{Ch as c,ch as t}from"./chunk-he9kpk9r.js";import"./chunk-vs3s49jw.js";import"./chunk-kre93a89.js";import"./chunk-060wbpz4.js";import"./chunk-zrhw1szj.js";import"./chunk-t8fjgkp8.js";import"./chunk-0egrckx0.js";import"./chunk-qq9m8fxv.js";import"./chunk-2qm46qvn.js";import"./chunk-tsmj98yf.js";import"./chunk-58f4y4b7.js";import"./chunk-rmsqb6r4.js";import"./chunk-qxdpgdfk.js";import"./chunk-6qwk6z87.js";import"./chunk-sa0rrreh.js";import"./chunk-ydgst3h8.js";import"./chunk-6tqbnxar.js";import"./chunk-0w19vmd7.js";import"./chunk-eewe7tx1.js";import"./chunk-37cbrnke.js";import"./chunk-wm9nh9nb.js";import"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import"./chunk-az3nss5m.js";import"./chunk-p2fte9vz.js";import"./chunk-ggncq8w8.js";import"./chunk-t3w43rft.js";import"./chunk-eacpc64g.js";import"./chunk-27saej0r.js";import"./chunk-9009v4d0.js";import"./chunk-82xrfk5x.js";import"./chunk-wqk1v8t0.js";import"./chunk-vkjqy92f.js";import"./chunk-z0kbyr00.js";import"./chunk-sbjymf20.js";import"./chunk-dt3bsmfe.js";import"./chunk-vbfej8ds.js";import"./chunk-0tm6589k.js";import"./chunk-6yhn9syz.js";import"./chunk-wb05bp10.js";import"./chunk-wgkcyqn1.js";import"./chunk-59csnjc3.js";import"./chunk-1bxfzd6r.js";import{mt as i}from"./chunk-6p6m5956.js";import"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-w7a33cwa.js";import"./chunk-g7v6sp3c.js";import"./chunk-s2tc3qs0.js";import"./chunk-n6tqtk6h.js";import"./chunk-e0vrxetq.js";var n=i.object({name:a.shape.name,branch:a.shape.branch.unwrap(),directory:a.shape.directory.unwrap()}),d={name:"Worktree",description:"Create a git worktree",async configure(e){let r=await c.runPromise(t.Service.use((o)=>o.makeWorktreeInfo()));return{...e,name:r.name,branch:r.branch,directory:r.directory}},async create(e){let r=n.parse(e);await c.runPromise(t.Service.use((o)=>o.createFromInfo({name:r.name,directory:r.directory,branch:r.branch})))},async remove(e){let r=n.parse(e);await c.runPromise(t.Service.use((o)=>o.remove({directory:r.directory})))},target(e){return{type:"local",directory:n.parse(e).directory}}};export{d as WorktreeAdaptor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{gq as f,hq as H}from"./chunk-ggncq8w8.js";import D from"process";import{Buffer as b}from"buffer";import A from"path";import{fileURLToPath as s}from"url";import SS from"util";import y from"child_process";import z,{constants as u}from"fs/promises";function v(S,$,q){let J=(G)=>Object.defineProperty(S,$,{value:G,enumerable:!0,writable:!0});return Object.defineProperty(S,$,{configurable:!0,enumerable:!0,get(){let G=q();return J(G),G},set(G){J(G)}}),S}import{promisify as i}from"util";import T from"process";import{execFile as n}from"child_process";import{promisify as w}from"util";import h from"process";import{execFile as g}from"child_process";var l=w(g);async function X(){if(h.platform!=="darwin")throw Error("macOS only");let{stdout:S}=await l("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),q=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(S)?.groups.id??"com.apple.Safari";if(q==="com.apple.safari")return"com.apple.Safari";return q}import c from"process";import{promisify as m}from"util";import{execFile as d,execFileSync as kS}from"child_process";var a=m(d);async function W(S,{humanReadableOutput:$=!0,signal:q}={}){if(c.platform!=="darwin")throw Error("macOS only");let J=$?[]:["-ss"],G={};if(q)G.signal=q;let{stdout:Q}=await a("osascript",["-e",S,J],G);return Q.trim()}async function E(S){return W(`tell application "Finder" to set app_path to application file id "${S}" as string
|
|
3
3
|
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as t}from"util";import{execFile as r}from"child_process";var p=t(r),N={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},MS=new Map(Object.entries(N));class _ extends Error{}async function M(S=p){let{stdout:$}=await S("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),q=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec($);if(!q)throw new _(`Cannot find Windows browser in stdout: ${JSON.stringify($)}`);let{id:J}=q.groups,G=J.lastIndexOf("."),Q=J.lastIndexOf("-"),Y=G===-1?void 0:J.slice(0,G),K=Q===-1?void 0:J.slice(0,Q);return N[J]??N[Y]??N[K]??{name:J,id:J}}var e=i(n),o=(S)=>S.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,($)=>$.toUpperCase());async function j(){if(T.platform==="darwin"){let S=await X();return{name:await E(S),id:S}}if(T.platform==="linux"){let{stdout:S}=await e("xdg-mime",["query","default","x-scheme-handler/http"]),$=S.trim();return{name:o($.replace(/.desktop$/,"").replace("-"," ")),id:$}}if(T.platform==="win32")return M();throw Error("Only macOS, Linux, and Windows are supported")}var $S=SS.promisify(y.execFile),L=A.dirname(s(import.meta.url)),F=A.join(L,"xdg-open"),{platform:R,arch:I}=D,qS=(()=>{let $;return async function(){if($)return $;let q="/etc/wsl.conf",J=!1;try{await z.access(q,u.F_OK),J=!0}catch{}if(!J)return"/mnt/";let G=await z.readFile(q,{encoding:"utf8"}),Q=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(G);if(!Q)return"/mnt/";return $=Q.groups.mountPoint.trim(),$=$.endsWith("/")?$:`${$}/`,$}})(),P=async()=>{return`${await qS()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`};async function GS(){let S=await P(),$='(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',q=b.from('(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',"utf16le").toString("base64"),{stdout:J}=await $S(S,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",q],{encoding:"utf8"}),G=J.trim(),Q={ChromeHTML:"com.google.chrome",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return Q[G]?{id:Q[G]}:{}}var x=async(S,$)=>{let q;for(let J of S)try{return await $(J)}catch(G){q=G}throw q},U=async(S)=>{if(S={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...S},Array.isArray(S.app))return x(S.app,(K)=>U({...S,app:K}));let{name:$,arguments:q=[]}=S.app??{};if(q=[...q],Array.isArray($))return x($,(K)=>U({...S,app:{name:K,arguments:q}}));if($==="browser"||$==="browserPrivate"){let K={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},V={chrome:"--incognito",firefox:"--private-window",edge:"--inPrivate"},Z=H?await GS():await j();if(Z.id in K){let C=K[Z.id];if($==="browserPrivate")q.push(V[C]);return U({...S,app:{name:k[C],arguments:q}})}throw Error(`${Z.name} is not supported as a default browser`)}let J,G=[],Q={};if(R==="darwin"){if(J="open",S.wait)G.push("--wait-apps");if(S.background)G.push("--background");if(S.newInstance)G.push("--new");if($)G.push("-a",$)}else if(R==="win32"||H&&!f()&&!$){if(J=H?await P():`${D.env.SYSTEMROOT||D.env.windir||"C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`,G.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),!H)Q.windowsVerbatimArguments=!0;let K=["Start"];if(S.wait)K.push("-Wait");if($){if(K.push(`"\`"${$}\`""`),S.target)q.push(S.target)}else if(S.target)K.push(`"${S.target}"`);if(q.length>0)q=q.map((V)=>`"\`"${V}\`""`),K.push("-ArgumentList",q.join(","));S.target=b.from(K.join(" "),"utf16le").toString("base64")}else{if($)J=$;else{let K=!L||L==="/",V=!1;try{await z.access(F,u.X_OK),V=!0}catch{}J=D.versions.electron??(R==="android"||K||!V)?"xdg-open":F}if(q.length>0)G.push(...q);if(!S.wait)Q.stdio="ignore",Q.detached=!0}if(R==="darwin"&&q.length>0)G.push("--args",...q);if(S.target)G.push(S.target);let Y=y.spawn(J,G,Q);if(S.wait)return new Promise((K,V)=>{Y.once("error",V),Y.once("close",(Z)=>{if(!S.allowNonzeroExitCode&&Z>0){V(Error(`Exited with code ${Z}`));return}K(Y)})});return Y.unref(),Y},JS=(S,$)=>{if(typeof S!=="string")throw TypeError("Expected a `target`");return U({...$,target:S})},hS=(S,$)=>{if(typeof S!=="string"&&!Array.isArray(S))throw TypeError("Expected a valid `name`");let{arguments:q=[]}=$??{};if(q!==void 0&&q!==null&&!Array.isArray(q))throw TypeError("Expected `appArguments` as Array type");return U({...$,app:{name:S,arguments:q}})};function B(S){if(typeof S==="string"||Array.isArray(S))return S;let{[I]:$}=S;if(!$)throw Error(`${I} is not supported`);return $}function O({[R]:S},{wsl:$}){if($&&H)return B($);if(!S)throw Error(`${R} is not supported`);return B(S)}var k={};v(k,"chrome",()=>O({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));v(k,"firefox",()=>O({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));v(k,"edge",()=>O({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));v(k,"browser",()=>"browser");v(k,"browserPrivate",()=>"browserPrivate");var lS=JS;
|
|
4
|
-
export{hS as
|
|
4
|
+
export{hS as dq,k as eq,lS as fq};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$q as YG,Aq as OG,Bq as XG,Eq as fG,Iq as v,Lq as k,Mq as s,Pq as CG,Sq as p,Tq as u,Yq as _,_q as yG,ar as d,br as IG,cr as RG,er as xG,fq as g,hq as FG,jq as NG,lq as wG,mq as QG,nq as SG,vq as $G}from"./chunk-dy2k5rdx.js";import{gr as l,hr as GG,qr as BG,tr as c}from"./chunk-n5p7cn4w.js";import"./chunk-cqtkxwd8.js";import"./chunk-mhxyv9c8.js";import{hv as G}from"./chunk-c3szabpf.js";import"./chunk-c8prg3jx.js";import"./chunk-f2pv705d.js";function vG(J){var D;let L=[],q=[];for(let{role:K,content:z}of J)switch(K){case"system":{L.push({role:"system",content:z});break}case"user":{if(z.length===1&&z[0].type==="text"){L.push({role:"user",content:z[0].text});break}L.push({role:"user",content:z.map((A)=>{switch(A.type){case"text":return{type:"text",text:A.text};case"file":if(A.mediaType.startsWith("image/")){let Y=A.mediaType==="image/*"?"image/jpeg":A.mediaType;return{type:"image_url",image_url:{url:A.data instanceof URL?A.data.toString():`data:${Y};base64,${QG(A.data)}`}}}else throw new c({functionality:`file part media type ${A.mediaType}`})}})});break}case"assistant":{let A="",Y=[];for(let X of z)switch(X.type){case"text":{A+=X.text;break}case"tool-call":{Y.push({id:X.toolCallId,type:"function",function:{name:X.toolName,arguments:JSON.stringify(X.input)}});break}}L.push({role:"assistant",content:A,tool_calls:Y.length>0?Y:void 0});break}case"tool":{for(let A of z){if(A.type==="tool-approval-response")continue;let Y=A.output,X;switch(Y.type){case"text":case"error-text":X=Y.value;break;case"execution-denied":X=(D=Y.reason)!=null?D:"Tool execution denied.";break;case"content":case"json":case"error-json":X=JSON.stringify(Y.value);break}L.push({role:"tool",tool_call_id:A.toolCallId,content:X})}break}default:throw Error(`Unsupported role: ${K}`)}return{messages:L,warnings:q}}function EG(J){var D,L,q,K;let z=(L=(D=J.prompt_tokens_details)==null?void 0:D.cached_tokens)!=null?L:0,A=(K=(q=J.completion_tokens_details)==null?void 0:q.reasoning_tokens)!=null?K:0,Y=z<=J.prompt_tokens;return{inputTokens:{total:Y?J.prompt_tokens:J.prompt_tokens+z,noCache:Y?J.prompt_tokens-z:J.prompt_tokens,cacheRead:z,cacheWrite:void 0},outputTokens:{total:J.completion_tokens+A,text:J.completion_tokens,reasoning:A},raw:J}}function JG({id:J,model:D,created:L,created_at:q}){let K=L!=null?L:q;return{id:J!=null?J:void 0,modelId:D!=null?D:void 0,timestamp:K!=null?new Date(K*1000):void 0}}function WG(J){switch(J){case"stop":return"stop";case"length":return"length";case"tool_calls":case"function_call":return"tool-calls";case"content_filter":return"content-filter";default:return"other"}}var kG=G.object({type:G.literal("web"),country:G.string().length(2).optional(),excludedWebsites:G.array(G.string()).max(5).optional(),allowedWebsites:G.array(G.string()).max(5).optional(),safeSearch:G.boolean().optional()}),bG=G.object({type:G.literal("x"),excludedXHandles:G.array(G.string()).optional(),includedXHandles:G.array(G.string()).optional(),postFavoriteCount:G.number().int().optional(),postViewCount:G.number().int().optional(),xHandles:G.array(G.string()).optional()}),hG=G.object({type:G.literal("news"),country:G.string().length(2).optional(),excludedWebsites:G.array(G.string()).max(5).optional(),safeSearch:G.boolean().optional()}),_G=G.object({type:G.literal("rss"),links:G.array(G.string().url()).max(1)}),mG=G.discriminatedUnion("type",[kG,bG,hG,_G]),gG=G.object({reasoningEffort:G.enum(["low","high"]).optional(),logprobs:G.boolean().optional(),topLogprobs:G.number().int().min(0).max(8).optional(),parallel_function_calling:G.boolean().optional(),searchParameters:G.object({mode:G.enum(["off","auto","on"]),returnCitations:G.boolean().optional(),fromDate:G.string().optional(),toDate:G.string().optional(),maxSearchResults:G.number().min(1).max(50).optional(),sources:G.array(mG).optional()}).optional()}),uG=G.object({error:G.object({message:G.string(),type:G.string().nullish(),param:G.any().nullish(),code:G.union([G.string(),G.number()]).nullish()})}),r=yG({errorSchema:uG,errorToMessage:(J)=>J.error.message});function dG({tools:J,toolChoice:D}){J=(J==null?void 0:J.length)?J:void 0;let L=[];if(J==null)return{tools:void 0,toolChoice:void 0,toolWarnings:L};let q=[];for(let z of J)if(z.type==="provider")L.push({type:"unsupported",feature:`provider-defined tool ${z.name}`});else q.push({type:"function",function:{name:z.name,description:z.description,parameters:z.inputSchema,...z.strict!=null?{strict:z.strict}:{}}});if(D==null)return{tools:q,toolChoice:void 0,toolWarnings:L};let K=D.type;switch(K){case"auto":case"none":return{tools:q,toolChoice:K,toolWarnings:L};case"required":return{tools:q,toolChoice:"required",toolWarnings:L};case"tool":return{tools:q,toolChoice:{type:"function",function:{name:D.toolName}},toolWarnings:L};default:throw new c({functionality:`tool choice type: ${K}`})}}var cG=class{constructor(J,D){this.specificationVersion="v3",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=J,this.config=D}get provider(){return this.config.provider}async getArgs({prompt:J,maxOutputTokens:D,temperature:L,topP:q,topK:K,frequencyPenalty:z,presencePenalty:A,stopSequences:Y,seed:X,responseFormat:Z,providerOptions:M,tools:E,toolChoice:F}){var B,R,N;let $=[],W=(B=await p({provider:"xai",providerOptions:M,schema:gG}))!=null?B:{};if(K!=null)$.push({type:"unsupported",feature:"topK"});if(z!=null)$.push({type:"unsupported",feature:"frequencyPenalty"});if(A!=null)$.push({type:"unsupported",feature:"presencePenalty"});if(Y!=null)$.push({type:"unsupported",feature:"stopSequences"});let{messages:H,warnings:O}=vG(J);$.push(...O);let{tools:C,toolChoice:w,toolWarnings:j}=dG({tools:E,toolChoice:F});return $.push(...j),{args:{model:this.modelId,logprobs:W.logprobs===!0||W.topLogprobs!=null?!0:void 0,top_logprobs:W.topLogprobs,max_completion_tokens:D,temperature:L,top_p:q,seed:X,reasoning_effort:W.reasoningEffort,parallel_function_calling:W.parallel_function_calling,response_format:(Z==null?void 0:Z.type)==="json"?Z.schema!=null?{type:"json_schema",json_schema:{name:(R=Z.name)!=null?R:"response",schema:Z.schema,strict:!0}}:{type:"json_object"}:void 0,search_parameters:W.searchParameters?{mode:W.searchParameters.mode,return_citations:W.searchParameters.returnCitations,from_date:W.searchParameters.fromDate,to_date:W.searchParameters.toDate,max_search_results:W.searchParameters.maxSearchResults,sources:(N=W.searchParameters.sources)==null?void 0:N.map((S)=>{var h;return{type:S.type,...S.type==="web"&&{country:S.country,excluded_websites:S.excludedWebsites,allowed_websites:S.allowedWebsites,safe_search:S.safeSearch},...S.type==="x"&&{excluded_x_handles:S.excludedXHandles,included_x_handles:(h=S.includedXHandles)!=null?h:S.xHandles,post_favorite_count:S.postFavoriteCount,post_view_count:S.postViewCount},...S.type==="news"&&{country:S.country,excluded_websites:S.excludedWebsites,safe_search:S.safeSearch},...S.type==="rss"&&{links:S.links}}})}:void 0,messages:H,tools:C,tool_choice:w},warnings:$}}async doGenerate(J){var D,L;let{args:q,warnings:K}=await this.getArgs(J),z=`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/chat/completions`,{responseHeaders:A,value:Y,rawValue:X}=await u({url:z,headers:g(this.config.headers(),J.headers),body:q,failedResponseHandler:r,successfulResponseHandler:d(pG),abortSignal:J.abortSignal,fetch:this.config.fetch});if(Y.error!=null)throw new GG({message:Y.error,url:z,requestBodyValues:q,statusCode:200,responseHeaders:A,responseBody:JSON.stringify(X),isRetryable:Y.code==="The service is currently unavailable"});let Z=Y.choices[0],M=[];if(Z.message.content!=null&&Z.message.content.length>0){let E=Z.message.content,F=q.messages[q.messages.length-1];if((F==null?void 0:F.role)==="assistant"&&E===F.content)E="";if(E.length>0)M.push({type:"text",text:E})}if(Z.message.reasoning_content!=null&&Z.message.reasoning_content.length>0)M.push({type:"reasoning",text:Z.message.reasoning_content});if(Z.message.tool_calls!=null)for(let E of Z.message.tool_calls)M.push({type:"tool-call",toolCallId:E.id,toolName:E.function.name,input:E.function.arguments});if(Y.citations!=null)for(let E of Y.citations)M.push({type:"source",sourceType:"url",id:this.config.generateId(),url:E});return{content:M,finishReason:{unified:WG(Z.finish_reason),raw:(L=Z.finish_reason)!=null?L:void 0},usage:Y.usage?EG(Y.usage):{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}},request:{body:q},response:{...JG(Y),headers:A,body:X},warnings:K}}async doStream(J){var D;let{args:L,warnings:q}=await this.getArgs(J),K={...L,stream:!0,stream_options:{include_usage:!0}},z=`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/chat/completions`,{responseHeaders:A,value:Y}=await u({url:z,headers:g(this.config.headers(),J.headers),body:K,failedResponseHandler:r,successfulResponseHandler:async({response:N})=>{let $=NG(N),W=N.headers.get("content-type");if(W==null?void 0:W.includes("application/json")){let H=await N.text(),O=await CG({text:H,schema:lG});if(O.success)throw new GG({message:O.value.error,url:z,requestBodyValues:K,statusCode:200,responseHeaders:$,responseBody:H,isRetryable:O.value.code==="The service is currently unavailable"});throw new GG({message:"Invalid JSON response",url:z,requestBodyValues:K,statusCode:200,responseHeaders:$,responseBody:H})}return YG(iG)({response:N,url:z,requestBodyValues:K})},abortSignal:J.abortSignal,fetch:this.config.fetch}),X={unified:"other",raw:void 0},Z=void 0,M=!0,E={},F={},B=void 0,R=this;return{stream:Y.pipeThrough(new TransformStream({start(N){N.enqueue({type:"stream-start",warnings:q})},transform(N,$){if(J.includeRawChunks)$.enqueue({type:"raw",rawValue:N.rawValue});if(!N.success){$.enqueue({type:"error",error:N.error});return}let W=N.value;if(M)$.enqueue({type:"response-metadata",...JG(W)}),M=!1;if(W.citations!=null)for(let w of W.citations)$.enqueue({type:"source",sourceType:"url",id:R.config.generateId(),url:w});if(W.usage!=null)Z=EG(W.usage);let H=W.choices[0];if((H==null?void 0:H.finish_reason)!=null)X={unified:WG(H.finish_reason),raw:H.finish_reason};if((H==null?void 0:H.delta)==null)return;let{delta:O,index:C}=H;if(O.content!=null&&O.content.length>0){let w=O.content;if(B!=null&&!E[B].ended)$.enqueue({type:"reasoning-end",id:B}),E[B].ended=!0,B=void 0;let j=K.messages[K.messages.length-1];if((j==null?void 0:j.role)==="assistant"&&w===j.content)return;let y=`text-${W.id||C}`;if(E[y]==null)E[y]={type:"text",ended:!1},$.enqueue({type:"text-start",id:y});$.enqueue({type:"text-delta",id:y,delta:w})}if(O.reasoning_content!=null&&O.reasoning_content.length>0){let w=`reasoning-${W.id||C}`;if(F[w]===O.reasoning_content)return;if(F[w]=O.reasoning_content,E[w]==null)E[w]={type:"reasoning",ended:!1},B=w,$.enqueue({type:"reasoning-start",id:w});$.enqueue({type:"reasoning-delta",id:w,delta:O.reasoning_content})}if(O.tool_calls!=null){if(B!=null&&!E[B].ended)$.enqueue({type:"reasoning-end",id:B}),E[B].ended=!0,B=void 0;for(let w of O.tool_calls){let j=w.id;$.enqueue({type:"tool-input-start",id:j,toolName:w.function.name}),$.enqueue({type:"tool-input-delta",id:j,delta:w.function.arguments}),$.enqueue({type:"tool-input-end",id:j}),$.enqueue({type:"tool-call",toolCallId:j,toolName:w.function.name,input:w.function.arguments})}}},flush(N){for(let[$,W]of Object.entries(E))if(!W.ended)N.enqueue({type:W.type==="text"?"text-end":"reasoning-end",id:$});N.enqueue({type:"finish",finishReason:X,usage:Z!=null?Z:{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}}})}})),request:{body:K},response:{headers:A}}}},TG=G.object({prompt_tokens:G.number(),completion_tokens:G.number(),total_tokens:G.number(),prompt_tokens_details:G.object({text_tokens:G.number().nullish(),audio_tokens:G.number().nullish(),image_tokens:G.number().nullish(),cached_tokens:G.number().nullish()}).nullish(),completion_tokens_details:G.object({reasoning_tokens:G.number().nullish(),audio_tokens:G.number().nullish(),accepted_prediction_tokens:G.number().nullish(),rejected_prediction_tokens:G.number().nullish()}).nullish()}),pG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({message:G.object({role:G.literal("assistant"),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({id:G.string(),type:G.literal("function"),function:G.object({name:G.string(),arguments:G.string()})})).nullish()}),index:G.number(),finish_reason:G.string().nullish()})).nullish(),object:G.literal("chat.completion").nullish(),usage:TG.nullish(),citations:G.array(G.string().url()).nullish(),code:G.string().nullish(),error:G.string().nullish()}),iG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({delta:G.object({role:G.enum(["assistant"]).optional(),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({id:G.string(),type:G.literal("function"),function:G.object({name:G.string(),arguments:G.string()})})).nullish()}),finish_reason:G.string().nullish(),index:G.number()})),usage:TG.nullish(),citations:G.array(G.string().url()).nullish()}),lG=G.object({code:G.string(),error:G.string()}),rG=G.object({aspect_ratio:G.string().optional(),output_format:G.string().optional(),sync_mode:G.boolean().optional(),resolution:G.enum(["1k","2k"]).optional(),quality:G.enum(["low","medium","high"]).optional(),user:G.string().optional()}),aG=class{constructor(J,D){this.modelId=J,this.config=D,this.specificationVersion="v3",this.maxImagesPerCall=3}get provider(){return this.config.provider}async doGenerate({prompt:J,n:D,size:L,aspectRatio:q,seed:K,providerOptions:z,headers:A,abortSignal:Y,files:X,mask:Z}){var M,E,F,B,R;let N=[];if(L!=null)N.push({type:"unsupported",feature:"size",details:"This model does not support the `size` option. Use `aspectRatio` instead."});if(K!=null)N.push({type:"unsupported",feature:"seed"});if(Z!=null)N.push({type:"unsupported",feature:"mask"});let $=await p({provider:"xai",providerOptions:z,schema:rG}),W=X!=null&&X.length>0,H=W?X.map((I)=>SG(I)):[],O=W?"/images/edits":"/images/generations",C={model:this.modelId,prompt:J,n:D,response_format:"b64_json"};if(q!=null)C.aspect_ratio=q;if(($==null?void 0:$.output_format)!=null)C.output_format=$.output_format;if(($==null?void 0:$.sync_mode)!=null)C.sync_mode=$.sync_mode;if(($==null?void 0:$.aspect_ratio)!=null&&q==null)C.aspect_ratio=$.aspect_ratio;if(($==null?void 0:$.resolution)!=null)C.resolution=$.resolution;if(($==null?void 0:$.quality)!=null)C.quality=$.quality;if(($==null?void 0:$.user)!=null)C.user=$.user;if(H.length===1)C.image={url:H[0],type:"image_url"};else if(H.length>1)C.images=H.map((I)=>({url:I,type:"image_url"}));let w=(M=this.config.baseURL)!=null?M:"https://api.x.ai/v1",j=(B=(F=(E=this.config._internal)==null?void 0:E.currentDate)==null?void 0:F.call(E))!=null?B:new Date,{value:y,responseHeaders:S}=await u({url:`${w}${O}`,headers:g(this.config.headers(),A),body:C,failedResponseHandler:r,successfulResponseHandler:d(nG),abortSignal:Y,fetch:this.config.fetch});return{images:y.data.every((I)=>I.b64_json!=null)?y.data.map((I)=>I.b64_json):await Promise.all(y.data.map((I)=>this.downloadImage(I.url,Y))),warnings:N,response:{timestamp:j,modelId:this.modelId,headers:S},providerMetadata:{xai:{images:y.data.map((I)=>({...I.revised_prompt?{revisedPrompt:I.revised_prompt}:{}})),...((R=y.usage)==null?void 0:R.cost_in_usd_ticks)!=null?{costInUsdTicks:y.usage.cost_in_usd_ticks}:{}}}}}async downloadImage(J,D){let{value:L}=await XG({url:J,abortSignal:D,failedResponseHandler:RG(),successfulResponseHandler:IG(),fetch:this.config.fetch});return L}},nG=G.object({data:G.array(G.object({url:G.string().nullish(),b64_json:G.string().nullish(),revised_prompt:G.string().nullish()})),usage:G.object({cost_in_usd_ticks:G.number().nullish()}).nullish()});async function sG({prompt:J}){var D,L,q,K,z;let A=[],Y=[];for(let X of J)switch(X.role){case"system":{A.push({role:"system",content:X.content});break}case"user":{let Z=[];for(let M of X.content)switch(M.type){case"text":{Z.push({type:"input_text",text:M.text});break}case"file":{if(M.mediaType.startsWith("image/")){let E=M.mediaType==="image/*"?"image/jpeg":M.mediaType,F=M.data instanceof URL?M.data.toString():`data:${E};base64,${QG(M.data)}`;Z.push({type:"input_image",image_url:F})}else throw new c({functionality:`file part media type ${M.mediaType}`});break}default:{let E=M;Y.push({type:"other",message:"xAI Responses API does not support this content type in user messages"})}}A.push({role:"user",content:Z});break}case"assistant":{for(let Z of X.content)switch(Z.type){case"text":{let M=typeof((L=(D=Z.providerOptions)==null?void 0:D.xai)==null?void 0:L.itemId)==="string"?Z.providerOptions.xai.itemId:void 0;A.push({role:"assistant",content:Z.text,id:M});break}case"tool-call":{if(Z.providerExecuted)break;let M=typeof((K=(q=Z.providerOptions)==null?void 0:q.xai)==null?void 0:K.itemId)==="string"?Z.providerOptions.xai.itemId:void 0;A.push({type:"function_call",id:M!=null?M:Z.toolCallId,call_id:Z.toolCallId,name:Z.toolName,arguments:JSON.stringify(Z.input),status:"completed"});break}case"tool-result":break;case"reasoning":case"file":{Y.push({type:"other",message:`xAI Responses API does not support ${Z.type} in assistant messages`});break}default:{let M=Z;Y.push({type:"other",message:"xAI Responses API does not support this content type in assistant messages"})}}break}case"tool":{for(let Z of X.content){if(Z.type==="tool-approval-response")continue;let M=Z.output,E;switch(M.type){case"text":case"error-text":E=M.value;break;case"execution-denied":E=(z=M.reason)!=null?z:"tool execution denied";break;case"json":case"error-json":E=JSON.stringify(M.value);break;case"content":E=M.value.map((F)=>{if(F.type==="text")return F.text;return""}).join("");break;default:{let F=M;E=""}}A.push({type:"function_call_output",call_id:Z.toolCallId,output:E})}break}default:{let Z=X;Y.push({type:"other",message:"unsupported message role"})}}return{input:A,inputWarnings:Y}}function ZG(J){var D,L,q,K;let z=(L=(D=J.input_tokens_details)==null?void 0:D.cached_tokens)!=null?L:0,A=(K=(q=J.output_tokens_details)==null?void 0:q.reasoning_tokens)!=null?K:0,Y=z<=J.input_tokens;return{inputTokens:{total:Y?J.input_tokens:J.input_tokens+z,noCache:Y?J.input_tokens-z:J.input_tokens,cacheRead:z,cacheWrite:void 0},outputTokens:{total:J.output_tokens,text:J.output_tokens-A,reasoning:A},raw:J}}function o(J){switch(J){case"stop":case"completed":return"stop";case"length":case"max_output_tokens":return"length";case"tool_calls":case"function_call":return"tool-calls";case"content_filter":return"content-filter";default:return"other"}}var KG=G.union([G.object({type:G.literal("url_citation"),url:G.string(),title:G.string().optional()}),G.object({type:G.string()})]),AG=G.object({type:G.string(),text:G.string().optional(),logprobs:G.array(G.any()).optional(),annotations:G.array(KG).optional()}),jG=G.object({type:G.string(),text:G.string()}),i=G.object({name:G.string().optional(),arguments:G.string().optional(),input:G.string().optional(),call_id:G.string().optional(),id:G.string(),status:G.string(),action:G.any().optional()}),tG=G.object({name:G.string().optional(),arguments:G.string().optional(),output:G.string().optional(),error:G.string().optional(),id:G.string(),status:G.string(),server_label:G.string().optional()}),DG=G.discriminatedUnion("type",[G.object({type:G.literal("web_search_call"),...i.shape}),G.object({type:G.literal("x_search_call"),...i.shape}),G.object({type:G.literal("code_interpreter_call"),...i.shape}),G.object({type:G.literal("code_execution_call"),...i.shape}),G.object({type:G.literal("view_image_call"),...i.shape}),G.object({type:G.literal("view_x_video_call"),...i.shape}),G.object({type:G.literal("file_search_call"),id:G.string(),status:G.string(),queries:G.array(G.string()).optional(),results:G.array(G.object({file_id:G.string(),filename:G.string(),score:G.number(),text:G.string()})).nullish()}),G.object({type:G.literal("custom_tool_call"),...i.shape}),G.object({type:G.literal("mcp_call"),...tG.shape}),G.object({type:G.literal("message"),role:G.string(),content:G.array(AG),id:G.string(),status:G.string()}),G.object({type:G.literal("function_call"),name:G.string(),arguments:G.string(),call_id:G.string(),id:G.string()}),G.object({type:G.literal("reasoning"),id:G.string(),summary:G.array(jG),status:G.string(),encrypted_content:G.string().nullish()})]),qG=G.object({input_tokens:G.number(),output_tokens:G.number(),total_tokens:G.number().optional(),input_tokens_details:G.object({cached_tokens:G.number().optional()}).optional(),output_tokens_details:G.object({reasoning_tokens:G.number().optional()}).optional(),num_sources_used:G.number().optional(),num_server_side_tools_used:G.number().optional()}),t=G.object({id:G.string().nullish(),created_at:G.number().nullish(),model:G.string().nullish(),object:G.literal("response"),output:G.array(DG),usage:qG.nullish(),status:G.string()}),eG=G.union([G.object({type:G.literal("response.created"),response:t.partial({usage:!0,status:!0})}),G.object({type:G.literal("response.in_progress"),response:t.partial({usage:!0,status:!0})}),G.object({type:G.literal("response.output_item.added"),item:DG,output_index:G.number()}),G.object({type:G.literal("response.output_item.done"),item:DG,output_index:G.number()}),G.object({type:G.literal("response.content_part.added"),item_id:G.string(),output_index:G.number(),content_index:G.number(),part:AG}),G.object({type:G.literal("response.content_part.done"),item_id:G.string(),output_index:G.number(),content_index:G.number(),part:AG}),G.object({type:G.literal("response.output_text.delta"),item_id:G.string(),output_index:G.number(),content_index:G.number(),delta:G.string(),logprobs:G.array(G.any()).optional()}),G.object({type:G.literal("response.output_text.done"),item_id:G.string(),output_index:G.number(),content_index:G.number(),text:G.string(),logprobs:G.array(G.any()).optional(),annotations:G.array(KG).optional()}),G.object({type:G.literal("response.output_text.annotation.added"),item_id:G.string(),output_index:G.number(),content_index:G.number(),annotation_index:G.number(),annotation:KG}),G.object({type:G.literal("response.reasoning_summary_part.added"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),part:jG}),G.object({type:G.literal("response.reasoning_summary_part.done"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),part:jG}),G.object({type:G.literal("response.reasoning_summary_text.delta"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.reasoning_summary_text.done"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),text:G.string()}),G.object({type:G.literal("response.reasoning_text.delta"),item_id:G.string(),output_index:G.number(),content_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.reasoning_text.done"),item_id:G.string(),output_index:G.number(),content_index:G.number(),text:G.string()}),G.object({type:G.literal("response.web_search_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.web_search_call.searching"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.web_search_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.x_search_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.x_search_call.searching"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.x_search_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.file_search_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.file_search_call.searching"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.file_search_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_execution_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_execution_call.executing"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_execution_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.executing"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.interpreting"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call_code.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.code_interpreter_call_code.done"),item_id:G.string(),output_index:G.number(),code:G.string()}),G.object({type:G.literal("response.custom_tool_call_input.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.custom_tool_call_input.done"),item_id:G.string(),output_index:G.number(),input:G.string()}),G.object({type:G.literal("response.function_call_arguments.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.function_call_arguments.done"),item_id:G.string(),output_index:G.number(),arguments:G.string()}),G.object({type:G.literal("response.mcp_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call.executing"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call.failed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call_arguments.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.mcp_call_arguments.done"),item_id:G.string(),output_index:G.number(),arguments:G.string().optional()}),G.object({type:G.literal("response.mcp_call_output.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.mcp_call_output.done"),item_id:G.string(),output_index:G.number(),output:G.string().optional()}),G.object({type:G.literal("response.incomplete"),response:G.object({incomplete_details:G.object({reason:G.string()}).nullish(),usage:qG.nullish()})}),G.object({type:G.literal("response.failed"),response:G.object({error:G.object({code:G.string().nullish(),message:G.string()}).nullish(),incomplete_details:G.object({reason:G.string()}).nullish(),usage:qG.nullish()})}),G.object({type:G.literal("error"),code:G.string().nullish(),message:G.string(),param:G.string().nullish()}),G.object({type:G.literal("response.done"),response:t}),G.object({type:G.literal("response.completed"),response:t})]),oG=G.object({reasoningEffort:G.enum(["low","medium","high"]).optional(),logprobs:G.boolean().optional(),topLogprobs:G.number().int().min(0).max(8).optional(),store:G.boolean().optional(),previousResponseId:G.string().optional(),include:G.array(G.enum(["file_search_call.results"])).nullish()}),GJ=v(()=>k(G.object({vectorStoreIds:G.array(G.string()),maxNumResults:G.number().optional()}))),JJ=v(()=>k(G.object({queries:G.array(G.string()),results:G.array(G.object({fileId:G.string(),filename:G.string(),score:G.number().min(0).max(1),text:G.string()})).nullable()}))),QJ=_({id:"xai.file_search",inputSchema:v(()=>k(G.object({}))),outputSchema:JJ}),XJ=(J)=>QJ(J),YJ=v(()=>k(G.object({serverUrl:G.string().describe("The URL of the MCP server"),serverLabel:G.string().optional().describe("A label for the MCP server"),serverDescription:G.string().optional().describe("Description of the MCP server"),allowedTools:G.array(G.string()).optional().describe("List of allowed tool names"),headers:G.record(G.string(),G.string()).optional().describe("Custom headers to send"),authorization:G.string().optional().describe("Authorization header value")}))),ZJ=v(()=>k(G.object({name:G.string(),arguments:G.string(),result:G.unknown()}))),$J=_({id:"xai.mcp",inputSchema:v(()=>k(G.object({}))),outputSchema:ZJ}),KJ=(J)=>$J(J),AJ=v(()=>k(G.object({allowedDomains:G.array(G.string()).max(5).optional(),excludedDomains:G.array(G.string()).max(5).optional(),enableImageUnderstanding:G.boolean().optional()}))),jJ=v(()=>k(G.object({query:G.string(),sources:G.array(G.object({title:G.string(),url:G.string(),snippet:G.string()}))}))),DJ=_({id:"xai.web_search",inputSchema:v(()=>k(G.object({}))),outputSchema:jJ}),qJ=(J={})=>DJ(J),zJ=v(()=>k(G.object({allowedXHandles:G.array(G.string()).max(10).optional(),excludedXHandles:G.array(G.string()).max(10).optional(),fromDate:G.string().optional(),toDate:G.string().optional(),enableImageUnderstanding:G.boolean().optional(),enableVideoUnderstanding:G.boolean().optional()}))),VJ=v(()=>k(G.object({query:G.string(),posts:G.array(G.object({author:G.string(),text:G.string(),url:G.string(),likes:G.number()}))}))),LJ=_({id:"xai.x_search",inputSchema:v(()=>k(G.object({}))),outputSchema:VJ}),UJ=(J={})=>LJ(J);async function HJ({tools:J,toolChoice:D}){let L=(J==null?void 0:J.length)?J:void 0,q=[];if(L==null)return{tools:void 0,toolChoice:void 0,toolWarnings:q};let K=[],z=new Map;for(let Y of L)if(z.set(Y.name,Y),Y.type==="provider")switch(Y.id){case"xai.web_search":{let X=await s({value:Y.args,schema:AJ});K.push({type:"web_search",allowed_domains:X.allowedDomains,excluded_domains:X.excludedDomains,enable_image_understanding:X.enableImageUnderstanding});break}case"xai.x_search":{let X=await s({value:Y.args,schema:zJ});K.push({type:"x_search",allowed_x_handles:X.allowedXHandles,excluded_x_handles:X.excludedXHandles,from_date:X.fromDate,to_date:X.toDate,enable_image_understanding:X.enableImageUnderstanding,enable_video_understanding:X.enableVideoUnderstanding});break}case"xai.code_execution":{K.push({type:"code_interpreter"});break}case"xai.view_image":{K.push({type:"view_image"});break}case"xai.view_x_video":{K.push({type:"view_x_video"});break}case"xai.file_search":{let X=await s({value:Y.args,schema:GJ});K.push({type:"file_search",vector_store_ids:X.vectorStoreIds,max_num_results:X.maxNumResults});break}case"xai.mcp":{let X=await s({value:Y.args,schema:YJ});K.push({type:"mcp",server_url:X.serverUrl,server_label:X.serverLabel,server_description:X.serverDescription,allowed_tools:X.allowedTools,headers:X.headers,authorization:X.authorization});break}default:{q.push({type:"unsupported",feature:`provider-defined tool ${Y.name}`});break}}else K.push({type:"function",name:Y.name,description:Y.description,parameters:Y.inputSchema,...Y.strict!=null?{strict:Y.strict}:{}});if(D==null)return{tools:K,toolChoice:void 0,toolWarnings:q};let A=D.type;switch(A){case"auto":case"none":return{tools:K,toolChoice:A,toolWarnings:q};case"required":return{tools:K,toolChoice:"required",toolWarnings:q};case"tool":{let Y=z.get(D.toolName);if(Y==null)return{tools:K,toolChoice:void 0,toolWarnings:q};if(Y.type==="provider")return q.push({type:"unsupported",feature:`toolChoice for server-side tool "${Y.name}"`}),{tools:K,toolChoice:void 0,toolWarnings:q};return{tools:K,toolChoice:{type:"function",name:Y.name},toolWarnings:q}}default:throw new c({functionality:`tool choice type: ${A}`})}}var MJ=class{constructor(J,D){this.specificationVersion="v3",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=J,this.config=D}get provider(){return this.config.provider}async getArgs({prompt:J,maxOutputTokens:D,temperature:L,topP:q,stopSequences:K,seed:z,responseFormat:A,providerOptions:Y,tools:X,toolChoice:Z}){var M,E,F,B,R,N,$;let W=[],H=(M=await p({provider:"xai",providerOptions:Y,schema:oG}))!=null?M:{};if(K!=null)W.push({type:"unsupported",feature:"stopSequences"});let O=(E=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.web_search"))==null?void 0:E.name,C=(F=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.x_search"))==null?void 0:F.name,w=(B=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.code_execution"))==null?void 0:B.name,j=(R=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.mcp"))==null?void 0:R.name,y=(N=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.file_search"))==null?void 0:N.name,{input:S,inputWarnings:h}=await sG({prompt:J,store:!0});W.push(...h);let{tools:m,toolChoice:I,toolWarnings:P}=await HJ({tools:X,toolChoice:Z});W.push(...P);let f=H.include?[...H.include]:void 0;if(H.store===!1)if(f==null)f=["reasoning.encrypted_content"];else f=[...f,"reasoning.encrypted_content"];let U={model:this.modelId,input:S,logprobs:H.logprobs===!0||H.topLogprobs!=null?!0:void 0,top_logprobs:H.topLogprobs,max_output_tokens:D,temperature:L,top_p:q,seed:z,...(A==null?void 0:A.type)==="json"&&{text:{format:A.schema!=null?{type:"json_schema",strict:!0,name:($=A.name)!=null?$:"response",description:A.description,schema:A.schema}:{type:"json_object"}}},...H.reasoningEffort!=null&&{reasoning:{effort:H.reasoningEffort}},...H.store===!1&&{store:H.store},...f!=null&&{include:f},...H.previousResponseId!=null&&{previous_response_id:H.previousResponseId}};if(m&&m.length>0)U.tools=m;if(I!=null)U.tool_choice=I;return{args:U,warnings:W,webSearchToolName:O,xSearchToolName:C,codeExecutionToolName:w,mcpToolName:j,fileSearchToolName:y}}async doGenerate(J){var D,L,q,K,z,A,Y,X,Z,M,E,F,B;let{args:R,warnings:N,webSearchToolName:$,xSearchToolName:W,codeExecutionToolName:H,mcpToolName:O,fileSearchToolName:C}=await this.getArgs(J),{responseHeaders:w,value:j,rawValue:y}=await u({url:`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/responses`,headers:g(this.config.headers(),J.headers),body:R,failedResponseHandler:r,successfulResponseHandler:d(t),abortSignal:J.abortSignal,fetch:this.config.fetch}),S=[],h=!1,m=["web_search","web_search_with_snippets","browse_page"],I=["x_user_search","x_keyword_search","x_semantic_search","x_thread_fetch"];for(let P of j.output){if(P.type==="file_search_call"){let f=C!=null?C:"file_search";S.push({type:"tool-call",toolCallId:P.id,toolName:f,input:"",providerExecuted:!0}),S.push({type:"tool-result",toolCallId:P.id,toolName:f,result:{queries:(L=P.queries)!=null?L:[],results:(K=(q=P.results)==null?void 0:q.map((U)=>({fileId:U.file_id,filename:U.filename,score:U.score,text:U.text})))!=null?K:null}});continue}if(P.type==="web_search_call"||P.type==="x_search_call"||P.type==="code_interpreter_call"||P.type==="code_execution_call"||P.type==="view_image_call"||P.type==="view_x_video_call"||P.type==="custom_tool_call"||P.type==="mcp_call"){let f=(z=P.name)!=null?z:"";if(m.includes((A=P.name)!=null?A:"")||P.type==="web_search_call")f=$!=null?$:"web_search";else if(I.includes((Y=P.name)!=null?Y:"")||P.type==="x_search_call")f=W!=null?W:"x_search";else if(P.name==="code_execution"||P.type==="code_interpreter_call"||P.type==="code_execution_call")f=H!=null?H:"code_execution";else if(P.type==="mcp_call")f=(X=O!=null?O:P.name)!=null?X:"mcp";let U=P.type==="custom_tool_call"?(Z=P.input)!=null?Z:"":P.type==="mcp_call"?(M=P.arguments)!=null?M:"":(E=P.arguments)!=null?E:"";S.push({type:"tool-call",toolCallId:P.id,toolName:f,input:U,providerExecuted:!0});continue}switch(P.type){case"message":{for(let f of P.content){if(f.text)S.push({type:"text",text:f.text});if(f.annotations){for(let U of f.annotations)if(U.type==="url_citation"&&"url"in U)S.push({type:"source",sourceType:"url",id:this.config.generateId(),url:U.url,title:(F=U.title)!=null?F:U.url})}}break}case"function_call":{h=!0,S.push({type:"tool-call",toolCallId:P.call_id,toolName:P.name,input:P.arguments});break}case"reasoning":{let f=P.summary.map((U)=>U.text).filter((U)=>U&&U.length>0);if(f.length>0){let U=f.join("");if(P.encrypted_content||P.id)S.push({type:"reasoning",text:U,providerMetadata:{xai:{...P.encrypted_content&&{reasoningEncryptedContent:P.encrypted_content},...P.id&&{itemId:P.id}}}});else S.push({type:"reasoning",text:U})}break}default:break}}return{content:S,finishReason:{unified:h?"tool-calls":o(j.status),raw:(B=j.status)!=null?B:void 0},usage:j.usage?ZG(j.usage):{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}},request:{body:R},response:{...JG(j),headers:w,body:y},warnings:N}}async doStream(J){var D;let{args:L,warnings:q,webSearchToolName:K,xSearchToolName:z,codeExecutionToolName:A,mcpToolName:Y,fileSearchToolName:X}=await this.getArgs(J),Z={...L,stream:!0},{responseHeaders:M,value:E}=await u({url:`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/responses`,headers:g(this.config.headers(),J.headers),body:Z,failedResponseHandler:r,successfulResponseHandler:YG(eG),abortSignal:J.abortSignal,fetch:this.config.fetch}),F={unified:"other",raw:void 0},B=!1,R=void 0,N=!0,$={},W=new Set,H={},O={},C=this;return{stream:E.pipeThrough(new TransformStream({start(w){w.enqueue({type:"stream-start",warnings:q})},transform(w,j){var y,S,h,m,I,P,f,U,x,zG,VG,LG,UG,HG,MG;if(J.includeRawChunks)j.enqueue({type:"raw",rawValue:w.rawValue});if(!w.success){j.enqueue({type:"error",error:w.error});return}let V=w.value;if(V.type==="response.created"||V.type==="response.in_progress"){if(N)j.enqueue({type:"response-metadata",...JG(V.response)}),N=!1;return}if(V.type==="response.reasoning_summary_part.added"){let Q=`reasoning-${V.item_id}`;O[V.item_id]={},j.enqueue({type:"reasoning-start",id:Q,providerMetadata:{xai:{itemId:V.item_id}}})}if(V.type==="response.reasoning_summary_text.delta"){let Q=`reasoning-${V.item_id}`;j.enqueue({type:"reasoning-delta",id:Q,delta:V.delta,providerMetadata:{xai:{itemId:V.item_id}}});return}if(V.type==="response.reasoning_summary_text.done")return;if(V.type==="response.reasoning_text.delta"){let Q=`reasoning-${V.item_id}`;if(O[V.item_id]==null)O[V.item_id]={},j.enqueue({type:"reasoning-start",id:Q,providerMetadata:{xai:{itemId:V.item_id}}});j.enqueue({type:"reasoning-delta",id:Q,delta:V.delta,providerMetadata:{xai:{itemId:V.item_id}}});return}if(V.type==="response.reasoning_text.done")return;if(V.type==="response.output_text.delta"){let Q=`text-${V.item_id}`;if($[Q]==null)$[Q]={type:"text"},j.enqueue({type:"text-start",id:Q});j.enqueue({type:"text-delta",id:Q,delta:V.delta});return}if(V.type==="response.output_text.done"){if(V.annotations){for(let Q of V.annotations)if(Q.type==="url_citation"&&"url"in Q)j.enqueue({type:"source",sourceType:"url",id:C.config.generateId(),url:Q.url,title:(y=Q.title)!=null?y:Q.url})}return}if(V.type==="response.output_text.annotation.added"){let Q=V.annotation;if(Q.type==="url_citation"&&"url"in Q)j.enqueue({type:"source",sourceType:"url",id:C.config.generateId(),url:Q.url,title:(S=Q.title)!=null?S:Q.url});return}if(V.type==="response.done"||V.type==="response.completed"||V.type==="response.incomplete"){let Q=V.response;if(Q.usage)R=ZG(Q.usage);if(V.type==="response.incomplete"){let T="incomplete_details"in Q?(h=Q.incomplete_details)==null?void 0:h.reason:void 0;F={unified:T?o(T):"other",raw:T!=null?T:"incomplete"}}else if("status"in Q&&Q.status)F={unified:B?"tool-calls":o(Q.status),raw:Q.status};return}if(V.type==="response.failed"){let Q=(m=V.response.incomplete_details)==null?void 0:m.reason;if(F={unified:Q?o(Q):"error",raw:Q!=null?Q:"error"},V.response.usage)R=ZG(V.response.usage);return}if(V.type==="error"){j.enqueue({type:"error",error:V});return}if(V.type==="response.custom_tool_call_input.delta"||V.type==="response.custom_tool_call_input.done")return;if(V.type==="response.function_call_arguments.delta"){let Q=H[V.output_index];if(Q!=null)j.enqueue({type:"tool-input-delta",id:Q.toolCallId,delta:V.delta});return}if(V.type==="response.function_call_arguments.done")return;if(V.type==="response.output_item.added"||V.type==="response.output_item.done"){let Q=V.item;if(Q.type==="reasoning"){if(V.type==="response.output_item.done"){let T=`reasoning-${Q.id}`;if(!(Q.id in O))O[Q.id]={},j.enqueue({type:"reasoning-start",id:T,providerMetadata:{xai:{...Q.id&&{itemId:Q.id}}}});j.enqueue({type:"reasoning-end",id:T,providerMetadata:{xai:{...Q.encrypted_content&&{reasoningEncryptedContent:Q.encrypted_content},...Q.id&&{itemId:Q.id}}}}),delete O[Q.id]}return}if(Q.type==="file_search_call"){let T=X!=null?X:"file_search";if(!W.has(Q.id))W.add(Q.id),j.enqueue({type:"tool-input-start",id:Q.id,toolName:T}),j.enqueue({type:"tool-input-delta",id:Q.id,delta:""}),j.enqueue({type:"tool-input-end",id:Q.id}),j.enqueue({type:"tool-call",toolCallId:Q.id,toolName:T,input:"",providerExecuted:!0});if(V.type==="response.output_item.done")j.enqueue({type:"tool-result",toolCallId:Q.id,toolName:T,result:{queries:(I=Q.queries)!=null?I:[],results:(f=(P=Q.results)==null?void 0:P.map((b)=>({fileId:b.file_id,filename:b.filename,score:b.score,text:b.text})))!=null?f:null}});return}if(Q.type==="web_search_call"||Q.type==="x_search_call"||Q.type==="code_interpreter_call"||Q.type==="code_execution_call"||Q.type==="view_image_call"||Q.type==="view_x_video_call"||Q.type==="custom_tool_call"||Q.type==="mcp_call"){let T=["web_search","web_search_with_snippets","browse_page"],b=["x_user_search","x_keyword_search","x_semantic_search","x_thread_fetch"],n=(U=Q.name)!=null?U:"";if(T.includes((x=Q.name)!=null?x:"")||Q.type==="web_search_call")n=K!=null?K:"web_search";else if(b.includes((zG=Q.name)!=null?zG:"")||Q.type==="x_search_call")n=z!=null?z:"x_search";else if(Q.name==="code_execution"||Q.type==="code_interpreter_call"||Q.type==="code_execution_call")n=A!=null?A:"code_execution";else if(Q.type==="mcp_call")n=(VG=Y!=null?Y:Q.name)!=null?VG:"mcp";let PG=Q.type==="custom_tool_call"?(LG=Q.input)!=null?LG:"":Q.type==="mcp_call"?(UG=Q.arguments)!=null?UG:"":(HG=Q.arguments)!=null?HG:"";if((Q.type==="custom_tool_call"?V.type==="response.output_item.done":!W.has(Q.id))&&!W.has(Q.id))W.add(Q.id),j.enqueue({type:"tool-input-start",id:Q.id,toolName:n}),j.enqueue({type:"tool-input-delta",id:Q.id,delta:PG}),j.enqueue({type:"tool-input-end",id:Q.id}),j.enqueue({type:"tool-call",toolCallId:Q.id,toolName:n,input:PG,providerExecuted:!0});return}if(Q.type==="message")for(let T of Q.content){if(T.text&&T.text.length>0){let b=`text-${Q.id}`;if($[b]==null)$[b]={type:"text"},j.enqueue({type:"text-start",id:b}),j.enqueue({type:"text-delta",id:b,delta:T.text})}if(T.annotations){for(let b of T.annotations)if(b.type==="url_citation"&&"url"in b)j.enqueue({type:"source",sourceType:"url",id:C.config.generateId(),url:b.url,title:(MG=b.title)!=null?MG:b.url})}}else if(Q.type==="function_call"){if(V.type==="response.output_item.added")H[V.output_index]={toolName:Q.name,toolCallId:Q.call_id},j.enqueue({type:"tool-input-start",id:Q.call_id,toolName:Q.name});else if(V.type==="response.output_item.done")B=!0,H[V.output_index]=void 0,j.enqueue({type:"tool-input-end",id:Q.call_id}),j.enqueue({type:"tool-call",toolCallId:Q.call_id,toolName:Q.name,input:Q.arguments})}}},flush(w){for(let[j,y]of Object.entries($))if(y.type==="text")w.enqueue({type:"text-end",id:j});w.enqueue({type:"finish",finishReason:F,usage:R!=null?R:{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}}})}})),request:{body:Z},response:{headers:M}}}},PJ=G.object({output:G.string().describe("the output of the code execution"),error:G.string().optional().describe("any error that occurred")}),EJ=_({id:"xai.code_execution",inputSchema:G.object({}).describe("no input parameters"),outputSchema:PJ}),WJ=(J={})=>EJ(J),BJ=G.object({description:G.string().describe("description of the image"),objects:G.array(G.string()).optional().describe("objects detected in the image")}),FJ=_({id:"xai.view_image",inputSchema:G.object({}).describe("no input parameters"),outputSchema:BJ}),NJ=(J={})=>FJ(J),wJ=G.object({transcript:G.string().optional().describe("transcript of the video"),description:G.string().describe("description of the video content"),duration:G.number().optional().describe("duration in seconds")}),SJ=_({id:"xai.view_x_video",inputSchema:G.object({}).describe("no input parameters"),outputSchema:wJ}),OJ=(J={})=>SJ(J),fJ={codeExecution:WJ,fileSearch:XJ,mcpServer:KJ,viewImage:NJ,viewXVideo:OJ,webSearch:qJ,xSearch:UJ},CJ="3.0.82",a=G.string().min(1),yJ=G.enum(["480p","720p"]),IJ=G.enum(["edit-video","extend-video","reference-to-video"]),e={pollIntervalMs:G.number().positive().nullish(),pollTimeoutMs:G.number().positive().nullish(),resolution:yJ.nullish()},RJ=G.object({...e,mode:G.literal("edit-video"),videoUrl:a,referenceImageUrls:G.undefined().optional()}),xJ=G.object({...e,mode:G.literal("extend-video"),videoUrl:a,referenceImageUrls:G.undefined().optional()}),TJ=G.object({...e,mode:G.literal("reference-to-video"),referenceImageUrls:G.array(a).min(1).max(7),videoUrl:G.undefined().optional()}),vJ=G.object({...e,mode:G.undefined().optional(),videoUrl:a.optional(),referenceImageUrls:G.array(a).min(1).max(7).optional()}),IQ=G.union([RJ,xJ,TJ,vJ]),kJ=G.object({mode:IJ.optional(),videoUrl:a.optional(),referenceImageUrls:G.array(a).min(1).max(7).optional(),...e}).passthrough(),bJ=v(()=>k(kJ)),hJ={"1280x720":"720p","854x480":"480p","640x480":"480p"};function _J(J){if((J==null?void 0:J.mode)!=null)return J.mode;if((J==null?void 0:J.videoUrl)!=null)return"edit-video";if((J==null?void 0:J.referenceImageUrls)!=null&&J.referenceImageUrls.length>0)return"reference-to-video";return}var mJ=class{constructor(J,D){this.modelId=J,this.config=D,this.specificationVersion="v3",this.maxVideosPerCall=1}get provider(){return this.config.provider}async doGenerate(J){var D,L,q,K,z,A,Y,X,Z,M;let E=(q=(L=(D=this.config._internal)==null?void 0:D.currentDate)==null?void 0:L.call(D))!=null?q:new Date,F=[],B=await p({provider:"xai",providerOptions:J.providerOptions,schema:bJ}),R=_J(B),N=R==="edit-video",$=R==="extend-video",W=R==="reference-to-video";if(J.fps!=null)F.push({type:"unsupported",feature:"fps",details:"xAI video models do not support custom FPS."});if(J.seed!=null)F.push({type:"unsupported",feature:"seed",details:"xAI video models do not support seed."});if(J.n!=null&&J.n>1)F.push({type:"unsupported",feature:"n",details:"xAI video models do not support generating multiple videos per call. Only 1 video will be generated."});if(N&&J.duration!=null)F.push({type:"unsupported",feature:"duration",details:"xAI video editing does not support custom duration."});if(N&&J.aspectRatio!=null)F.push({type:"unsupported",feature:"aspectRatio",details:"xAI video editing does not support custom aspect ratio."});if(N&&((B==null?void 0:B.resolution)!=null||J.resolution!=null))F.push({type:"unsupported",feature:"resolution",details:"xAI video editing does not support custom resolution."});if($&&J.aspectRatio!=null)F.push({type:"unsupported",feature:"aspectRatio",details:"xAI video extension does not support custom aspect ratio."});if($&&((B==null?void 0:B.resolution)!=null||J.resolution!=null))F.push({type:"unsupported",feature:"resolution",details:"xAI video extension does not support custom resolution."});let H={model:this.modelId,prompt:J.prompt},O=!N,C=!N&&!$,w=!N&&!$;if(O&&J.duration!=null)H.duration=J.duration;if(C&&J.aspectRatio!=null)H.aspect_ratio=J.aspectRatio;if(w&&(B==null?void 0:B.resolution)!=null)H.resolution=B.resolution;else if(w&&J.resolution!=null){let U=hJ[J.resolution];if(U!=null)H.resolution=U;else F.push({type:"unsupported",feature:"resolution",details:`Unrecognized resolution "${J.resolution}". Use providerOptions.xai.resolution with "480p" or "720p" instead.`})}if(N)H.video={url:B.videoUrl};if($)H.video={url:B.videoUrl};if(J.image!=null)if(J.image.type==="url")H.image={url:J.image.url};else{let U=typeof J.image.data==="string"?J.image.data:wG(J.image.data);H.image={url:`data:${J.image.mediaType};base64,${U}`}}if(W)H.reference_images=B.referenceImageUrls.map((U)=>({url:U}));if(B!=null){for(let[U,x]of Object.entries(B))if(!["mode","pollIntervalMs","pollTimeoutMs","resolution","videoUrl","referenceImageUrls"].includes(U))H[U]=x}let j=(K=this.config.baseURL)!=null?K:"https://api.x.ai/v1",y;if(N)y=`${j}/videos/edits`;else if($)y=`${j}/videos/extensions`;else y=`${j}/videos/generations`;let{value:S}=await u({url:y,headers:g(this.config.headers(),J.headers),body:H,failedResponseHandler:r,successfulResponseHandler:d(gJ),abortSignal:J.abortSignal,fetch:this.config.fetch}),h=S.request_id;if(!h)throw new l({name:"XAI_VIDEO_GENERATION_ERROR",message:`No request_id returned from xAI API. Response: ${JSON.stringify(S)}`});let m=(z=B==null?void 0:B.pollIntervalMs)!=null?z:5000,I=(A=B==null?void 0:B.pollTimeoutMs)!=null?A:600000,P=Date.now(),f;while(!0){if(await FG(m,{abortSignal:J.abortSignal}),Date.now()-P>I)throw new l({name:"XAI_VIDEO_GENERATION_TIMEOUT",message:`Video generation timed out after ${I}ms`});let{value:U,responseHeaders:x}=await XG({url:`${j}/videos/${h}`,headers:g(this.config.headers(),J.headers),successfulResponseHandler:d(uJ),failedResponseHandler:r,abortSignal:J.abortSignal,fetch:this.config.fetch});if(f=x,U.status==="done"||U.status==null&&((Y=U.video)==null?void 0:Y.url)){if(((X=U.video)==null?void 0:X.respect_moderation)===!1)throw new l({name:"XAI_VIDEO_MODERATION_ERROR",message:"Video generation was blocked due to a content policy violation."});if(!((Z=U.video)==null?void 0:Z.url))throw new l({name:"XAI_VIDEO_GENERATION_ERROR",message:"Video generation completed but no video URL was returned."});return{videos:[{type:"url",url:U.video.url,mediaType:"video/mp4"}],warnings:F,response:{timestamp:E,modelId:this.modelId,headers:f},providerMetadata:{xai:{requestId:h,videoUrl:U.video.url,...U.video.duration!=null?{duration:U.video.duration}:{},...((M=U.usage)==null?void 0:M.cost_in_usd_ticks)!=null?{costInUsdTicks:U.usage.cost_in_usd_ticks}:{},...U.progress!=null?{progress:U.progress}:{}}}}}if(U.status==="expired")throw new l({name:"XAI_VIDEO_GENERATION_EXPIRED",message:"Video generation request expired."});if(U.status==="failed")throw new l({name:"XAI_VIDEO_GENERATION_FAILED",message:"Video generation failed."})}}},gJ=G.object({request_id:G.string().nullish()}),uJ=G.object({status:G.string().nullish(),video:G.object({url:G.string(),duration:G.number().nullish(),respect_moderation:G.boolean().nullish()}).nullish(),model:G.string().nullish(),usage:G.object({cost_in_usd_ticks:G.number().nullish()}).nullish(),progress:G.number().nullish(),error:G.object({code:G.string().nullish(),message:G.string().nullish()}).nullish()});function dJ(J={}){var D;let L=xG((D=J.baseURL)!=null?D:"https://api.x.ai/v1"),q=()=>OG({Authorization:`Bearer ${fG({apiKey:J.apiKey,environmentVariableName:"XAI_API_KEY",description:"xAI API key"})}`,...J.headers},`ai-sdk/xai/${CJ}`),K=(Z)=>{return new cG(Z,{provider:"xai.chat",baseURL:L,headers:q,generateId:$G,fetch:J.fetch})},z=(Z)=>{return new MJ(Z,{provider:"xai.responses",baseURL:L,headers:q,generateId:$G,fetch:J.fetch})},A=(Z)=>{return new aG(Z,{provider:"xai.image",baseURL:L,headers:q,fetch:J.fetch})},Y=(Z)=>{return new mJ(Z,{provider:"xai.video",baseURL:L,headers:q,fetch:J.fetch})},X=(Z)=>K(Z);return X.specificationVersion="v3",X.languageModel=K,X.chat=K,X.responses=z,X.embeddingModel=(Z)=>{throw new BG({modelId:Z,modelType:"embeddingModel"})},X.textEmbeddingModel=X.embeddingModel,X.imageModel=A,X.image=A,X.videoModel=Y,X.video=Y,X.tools=fJ,X}var RQ=dJ();export{fJ as xaiTools,RQ as xai,UJ as xSearch,qJ as webSearch,OJ as viewXVideo,NJ as viewImage,KJ as mcpServer,dJ as createXai,WJ as codeExecution,CJ as VERSION};
|
|
2
|
+
import{Bp as yG,Cp as YG,Dp as d,Ep as IG,Fp as RG,Hp as xG,Io as g,Ko as FG,Mo as NG,Oo as wG,Po as QG,Qo as SG,Yo as $G,bp as OG,cp as XG,fp as fG,jp as v,mp as k,np as s,qp as CG,tp as p,up as u,zp as _}from"./chunk-wm9nh9nb.js";import{Jp as l,Kp as GG,Tp as BG,Wp as c}from"./chunk-scnbt714.js";import"./chunk-cqtkxwd8.js";import"./chunk-y3gy62q5.js";import{Kt as G}from"./chunk-a48mx917.js";import"./chunk-3va85mbe.js";import"./chunk-e0vrxetq.js";function vG(J){var D;let L=[],q=[];for(let{role:K,content:z}of J)switch(K){case"system":{L.push({role:"system",content:z});break}case"user":{if(z.length===1&&z[0].type==="text"){L.push({role:"user",content:z[0].text});break}L.push({role:"user",content:z.map((A)=>{switch(A.type){case"text":return{type:"text",text:A.text};case"file":if(A.mediaType.startsWith("image/")){let Y=A.mediaType==="image/*"?"image/jpeg":A.mediaType;return{type:"image_url",image_url:{url:A.data instanceof URL?A.data.toString():`data:${Y};base64,${QG(A.data)}`}}}else throw new c({functionality:`file part media type ${A.mediaType}`})}})});break}case"assistant":{let A="",Y=[];for(let X of z)switch(X.type){case"text":{A+=X.text;break}case"tool-call":{Y.push({id:X.toolCallId,type:"function",function:{name:X.toolName,arguments:JSON.stringify(X.input)}});break}}L.push({role:"assistant",content:A,tool_calls:Y.length>0?Y:void 0});break}case"tool":{for(let A of z){if(A.type==="tool-approval-response")continue;let Y=A.output,X;switch(Y.type){case"text":case"error-text":X=Y.value;break;case"execution-denied":X=(D=Y.reason)!=null?D:"Tool execution denied.";break;case"content":case"json":case"error-json":X=JSON.stringify(Y.value);break}L.push({role:"tool",tool_call_id:A.toolCallId,content:X})}break}default:throw Error(`Unsupported role: ${K}`)}return{messages:L,warnings:q}}function EG(J){var D,L,q,K;let z=(L=(D=J.prompt_tokens_details)==null?void 0:D.cached_tokens)!=null?L:0,A=(K=(q=J.completion_tokens_details)==null?void 0:q.reasoning_tokens)!=null?K:0,Y=z<=J.prompt_tokens;return{inputTokens:{total:Y?J.prompt_tokens:J.prompt_tokens+z,noCache:Y?J.prompt_tokens-z:J.prompt_tokens,cacheRead:z,cacheWrite:void 0},outputTokens:{total:J.completion_tokens+A,text:J.completion_tokens,reasoning:A},raw:J}}function JG({id:J,model:D,created:L,created_at:q}){let K=L!=null?L:q;return{id:J!=null?J:void 0,modelId:D!=null?D:void 0,timestamp:K!=null?new Date(K*1000):void 0}}function WG(J){switch(J){case"stop":return"stop";case"length":return"length";case"tool_calls":case"function_call":return"tool-calls";case"content_filter":return"content-filter";default:return"other"}}var kG=G.object({type:G.literal("web"),country:G.string().length(2).optional(),excludedWebsites:G.array(G.string()).max(5).optional(),allowedWebsites:G.array(G.string()).max(5).optional(),safeSearch:G.boolean().optional()}),bG=G.object({type:G.literal("x"),excludedXHandles:G.array(G.string()).optional(),includedXHandles:G.array(G.string()).optional(),postFavoriteCount:G.number().int().optional(),postViewCount:G.number().int().optional(),xHandles:G.array(G.string()).optional()}),hG=G.object({type:G.literal("news"),country:G.string().length(2).optional(),excludedWebsites:G.array(G.string()).max(5).optional(),safeSearch:G.boolean().optional()}),_G=G.object({type:G.literal("rss"),links:G.array(G.string().url()).max(1)}),mG=G.discriminatedUnion("type",[kG,bG,hG,_G]),gG=G.object({reasoningEffort:G.enum(["low","high"]).optional(),logprobs:G.boolean().optional(),topLogprobs:G.number().int().min(0).max(8).optional(),parallel_function_calling:G.boolean().optional(),searchParameters:G.object({mode:G.enum(["off","auto","on"]),returnCitations:G.boolean().optional(),fromDate:G.string().optional(),toDate:G.string().optional(),maxSearchResults:G.number().min(1).max(50).optional(),sources:G.array(mG).optional()}).optional()}),uG=G.object({error:G.object({message:G.string(),type:G.string().nullish(),param:G.any().nullish(),code:G.union([G.string(),G.number()]).nullish()})}),r=yG({errorSchema:uG,errorToMessage:(J)=>J.error.message});function dG({tools:J,toolChoice:D}){J=(J==null?void 0:J.length)?J:void 0;let L=[];if(J==null)return{tools:void 0,toolChoice:void 0,toolWarnings:L};let q=[];for(let z of J)if(z.type==="provider")L.push({type:"unsupported",feature:`provider-defined tool ${z.name}`});else q.push({type:"function",function:{name:z.name,description:z.description,parameters:z.inputSchema,...z.strict!=null?{strict:z.strict}:{}}});if(D==null)return{tools:q,toolChoice:void 0,toolWarnings:L};let K=D.type;switch(K){case"auto":case"none":return{tools:q,toolChoice:K,toolWarnings:L};case"required":return{tools:q,toolChoice:"required",toolWarnings:L};case"tool":return{tools:q,toolChoice:{type:"function",function:{name:D.toolName}},toolWarnings:L};default:throw new c({functionality:`tool choice type: ${K}`})}}var cG=class{constructor(J,D){this.specificationVersion="v3",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=J,this.config=D}get provider(){return this.config.provider}async getArgs({prompt:J,maxOutputTokens:D,temperature:L,topP:q,topK:K,frequencyPenalty:z,presencePenalty:A,stopSequences:Y,seed:X,responseFormat:Z,providerOptions:M,tools:E,toolChoice:F}){var B,R,N;let $=[],W=(B=await p({provider:"xai",providerOptions:M,schema:gG}))!=null?B:{};if(K!=null)$.push({type:"unsupported",feature:"topK"});if(z!=null)$.push({type:"unsupported",feature:"frequencyPenalty"});if(A!=null)$.push({type:"unsupported",feature:"presencePenalty"});if(Y!=null)$.push({type:"unsupported",feature:"stopSequences"});let{messages:H,warnings:O}=vG(J);$.push(...O);let{tools:C,toolChoice:w,toolWarnings:j}=dG({tools:E,toolChoice:F});return $.push(...j),{args:{model:this.modelId,logprobs:W.logprobs===!0||W.topLogprobs!=null?!0:void 0,top_logprobs:W.topLogprobs,max_completion_tokens:D,temperature:L,top_p:q,seed:X,reasoning_effort:W.reasoningEffort,parallel_function_calling:W.parallel_function_calling,response_format:(Z==null?void 0:Z.type)==="json"?Z.schema!=null?{type:"json_schema",json_schema:{name:(R=Z.name)!=null?R:"response",schema:Z.schema,strict:!0}}:{type:"json_object"}:void 0,search_parameters:W.searchParameters?{mode:W.searchParameters.mode,return_citations:W.searchParameters.returnCitations,from_date:W.searchParameters.fromDate,to_date:W.searchParameters.toDate,max_search_results:W.searchParameters.maxSearchResults,sources:(N=W.searchParameters.sources)==null?void 0:N.map((S)=>{var h;return{type:S.type,...S.type==="web"&&{country:S.country,excluded_websites:S.excludedWebsites,allowed_websites:S.allowedWebsites,safe_search:S.safeSearch},...S.type==="x"&&{excluded_x_handles:S.excludedXHandles,included_x_handles:(h=S.includedXHandles)!=null?h:S.xHandles,post_favorite_count:S.postFavoriteCount,post_view_count:S.postViewCount},...S.type==="news"&&{country:S.country,excluded_websites:S.excludedWebsites,safe_search:S.safeSearch},...S.type==="rss"&&{links:S.links}}})}:void 0,messages:H,tools:C,tool_choice:w},warnings:$}}async doGenerate(J){var D,L;let{args:q,warnings:K}=await this.getArgs(J),z=`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/chat/completions`,{responseHeaders:A,value:Y,rawValue:X}=await u({url:z,headers:g(this.config.headers(),J.headers),body:q,failedResponseHandler:r,successfulResponseHandler:d(pG),abortSignal:J.abortSignal,fetch:this.config.fetch});if(Y.error!=null)throw new GG({message:Y.error,url:z,requestBodyValues:q,statusCode:200,responseHeaders:A,responseBody:JSON.stringify(X),isRetryable:Y.code==="The service is currently unavailable"});let Z=Y.choices[0],M=[];if(Z.message.content!=null&&Z.message.content.length>0){let E=Z.message.content,F=q.messages[q.messages.length-1];if((F==null?void 0:F.role)==="assistant"&&E===F.content)E="";if(E.length>0)M.push({type:"text",text:E})}if(Z.message.reasoning_content!=null&&Z.message.reasoning_content.length>0)M.push({type:"reasoning",text:Z.message.reasoning_content});if(Z.message.tool_calls!=null)for(let E of Z.message.tool_calls)M.push({type:"tool-call",toolCallId:E.id,toolName:E.function.name,input:E.function.arguments});if(Y.citations!=null)for(let E of Y.citations)M.push({type:"source",sourceType:"url",id:this.config.generateId(),url:E});return{content:M,finishReason:{unified:WG(Z.finish_reason),raw:(L=Z.finish_reason)!=null?L:void 0},usage:Y.usage?EG(Y.usage):{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}},request:{body:q},response:{...JG(Y),headers:A,body:X},warnings:K}}async doStream(J){var D;let{args:L,warnings:q}=await this.getArgs(J),K={...L,stream:!0,stream_options:{include_usage:!0}},z=`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/chat/completions`,{responseHeaders:A,value:Y}=await u({url:z,headers:g(this.config.headers(),J.headers),body:K,failedResponseHandler:r,successfulResponseHandler:async({response:N})=>{let $=NG(N),W=N.headers.get("content-type");if(W==null?void 0:W.includes("application/json")){let H=await N.text(),O=await CG({text:H,schema:lG});if(O.success)throw new GG({message:O.value.error,url:z,requestBodyValues:K,statusCode:200,responseHeaders:$,responseBody:H,isRetryable:O.value.code==="The service is currently unavailable"});throw new GG({message:"Invalid JSON response",url:z,requestBodyValues:K,statusCode:200,responseHeaders:$,responseBody:H})}return YG(iG)({response:N,url:z,requestBodyValues:K})},abortSignal:J.abortSignal,fetch:this.config.fetch}),X={unified:"other",raw:void 0},Z=void 0,M=!0,E={},F={},B=void 0,R=this;return{stream:Y.pipeThrough(new TransformStream({start(N){N.enqueue({type:"stream-start",warnings:q})},transform(N,$){if(J.includeRawChunks)$.enqueue({type:"raw",rawValue:N.rawValue});if(!N.success){$.enqueue({type:"error",error:N.error});return}let W=N.value;if(M)$.enqueue({type:"response-metadata",...JG(W)}),M=!1;if(W.citations!=null)for(let w of W.citations)$.enqueue({type:"source",sourceType:"url",id:R.config.generateId(),url:w});if(W.usage!=null)Z=EG(W.usage);let H=W.choices[0];if((H==null?void 0:H.finish_reason)!=null)X={unified:WG(H.finish_reason),raw:H.finish_reason};if((H==null?void 0:H.delta)==null)return;let{delta:O,index:C}=H;if(O.content!=null&&O.content.length>0){let w=O.content;if(B!=null&&!E[B].ended)$.enqueue({type:"reasoning-end",id:B}),E[B].ended=!0,B=void 0;let j=K.messages[K.messages.length-1];if((j==null?void 0:j.role)==="assistant"&&w===j.content)return;let y=`text-${W.id||C}`;if(E[y]==null)E[y]={type:"text",ended:!1},$.enqueue({type:"text-start",id:y});$.enqueue({type:"text-delta",id:y,delta:w})}if(O.reasoning_content!=null&&O.reasoning_content.length>0){let w=`reasoning-${W.id||C}`;if(F[w]===O.reasoning_content)return;if(F[w]=O.reasoning_content,E[w]==null)E[w]={type:"reasoning",ended:!1},B=w,$.enqueue({type:"reasoning-start",id:w});$.enqueue({type:"reasoning-delta",id:w,delta:O.reasoning_content})}if(O.tool_calls!=null){if(B!=null&&!E[B].ended)$.enqueue({type:"reasoning-end",id:B}),E[B].ended=!0,B=void 0;for(let w of O.tool_calls){let j=w.id;$.enqueue({type:"tool-input-start",id:j,toolName:w.function.name}),$.enqueue({type:"tool-input-delta",id:j,delta:w.function.arguments}),$.enqueue({type:"tool-input-end",id:j}),$.enqueue({type:"tool-call",toolCallId:j,toolName:w.function.name,input:w.function.arguments})}}},flush(N){for(let[$,W]of Object.entries(E))if(!W.ended)N.enqueue({type:W.type==="text"?"text-end":"reasoning-end",id:$});N.enqueue({type:"finish",finishReason:X,usage:Z!=null?Z:{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}}})}})),request:{body:K},response:{headers:A}}}},TG=G.object({prompt_tokens:G.number(),completion_tokens:G.number(),total_tokens:G.number(),prompt_tokens_details:G.object({text_tokens:G.number().nullish(),audio_tokens:G.number().nullish(),image_tokens:G.number().nullish(),cached_tokens:G.number().nullish()}).nullish(),completion_tokens_details:G.object({reasoning_tokens:G.number().nullish(),audio_tokens:G.number().nullish(),accepted_prediction_tokens:G.number().nullish(),rejected_prediction_tokens:G.number().nullish()}).nullish()}),pG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({message:G.object({role:G.literal("assistant"),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({id:G.string(),type:G.literal("function"),function:G.object({name:G.string(),arguments:G.string()})})).nullish()}),index:G.number(),finish_reason:G.string().nullish()})).nullish(),object:G.literal("chat.completion").nullish(),usage:TG.nullish(),citations:G.array(G.string().url()).nullish(),code:G.string().nullish(),error:G.string().nullish()}),iG=G.object({id:G.string().nullish(),created:G.number().nullish(),model:G.string().nullish(),choices:G.array(G.object({delta:G.object({role:G.enum(["assistant"]).optional(),content:G.string().nullish(),reasoning_content:G.string().nullish(),tool_calls:G.array(G.object({id:G.string(),type:G.literal("function"),function:G.object({name:G.string(),arguments:G.string()})})).nullish()}),finish_reason:G.string().nullish(),index:G.number()})),usage:TG.nullish(),citations:G.array(G.string().url()).nullish()}),lG=G.object({code:G.string(),error:G.string()}),rG=G.object({aspect_ratio:G.string().optional(),output_format:G.string().optional(),sync_mode:G.boolean().optional(),resolution:G.enum(["1k","2k"]).optional(),quality:G.enum(["low","medium","high"]).optional(),user:G.string().optional()}),aG=class{constructor(J,D){this.modelId=J,this.config=D,this.specificationVersion="v3",this.maxImagesPerCall=3}get provider(){return this.config.provider}async doGenerate({prompt:J,n:D,size:L,aspectRatio:q,seed:K,providerOptions:z,headers:A,abortSignal:Y,files:X,mask:Z}){var M,E,F,B,R;let N=[];if(L!=null)N.push({type:"unsupported",feature:"size",details:"This model does not support the `size` option. Use `aspectRatio` instead."});if(K!=null)N.push({type:"unsupported",feature:"seed"});if(Z!=null)N.push({type:"unsupported",feature:"mask"});let $=await p({provider:"xai",providerOptions:z,schema:rG}),W=X!=null&&X.length>0,H=W?X.map((I)=>SG(I)):[],O=W?"/images/edits":"/images/generations",C={model:this.modelId,prompt:J,n:D,response_format:"b64_json"};if(q!=null)C.aspect_ratio=q;if(($==null?void 0:$.output_format)!=null)C.output_format=$.output_format;if(($==null?void 0:$.sync_mode)!=null)C.sync_mode=$.sync_mode;if(($==null?void 0:$.aspect_ratio)!=null&&q==null)C.aspect_ratio=$.aspect_ratio;if(($==null?void 0:$.resolution)!=null)C.resolution=$.resolution;if(($==null?void 0:$.quality)!=null)C.quality=$.quality;if(($==null?void 0:$.user)!=null)C.user=$.user;if(H.length===1)C.image={url:H[0],type:"image_url"};else if(H.length>1)C.images=H.map((I)=>({url:I,type:"image_url"}));let w=(M=this.config.baseURL)!=null?M:"https://api.x.ai/v1",j=(B=(F=(E=this.config._internal)==null?void 0:E.currentDate)==null?void 0:F.call(E))!=null?B:new Date,{value:y,responseHeaders:S}=await u({url:`${w}${O}`,headers:g(this.config.headers(),A),body:C,failedResponseHandler:r,successfulResponseHandler:d(nG),abortSignal:Y,fetch:this.config.fetch});return{images:y.data.every((I)=>I.b64_json!=null)?y.data.map((I)=>I.b64_json):await Promise.all(y.data.map((I)=>this.downloadImage(I.url,Y))),warnings:N,response:{timestamp:j,modelId:this.modelId,headers:S},providerMetadata:{xai:{images:y.data.map((I)=>({...I.revised_prompt?{revisedPrompt:I.revised_prompt}:{}})),...((R=y.usage)==null?void 0:R.cost_in_usd_ticks)!=null?{costInUsdTicks:y.usage.cost_in_usd_ticks}:{}}}}}async downloadImage(J,D){let{value:L}=await XG({url:J,abortSignal:D,failedResponseHandler:RG(),successfulResponseHandler:IG(),fetch:this.config.fetch});return L}},nG=G.object({data:G.array(G.object({url:G.string().nullish(),b64_json:G.string().nullish(),revised_prompt:G.string().nullish()})),usage:G.object({cost_in_usd_ticks:G.number().nullish()}).nullish()});async function sG({prompt:J}){var D,L,q,K,z;let A=[],Y=[];for(let X of J)switch(X.role){case"system":{A.push({role:"system",content:X.content});break}case"user":{let Z=[];for(let M of X.content)switch(M.type){case"text":{Z.push({type:"input_text",text:M.text});break}case"file":{if(M.mediaType.startsWith("image/")){let E=M.mediaType==="image/*"?"image/jpeg":M.mediaType,F=M.data instanceof URL?M.data.toString():`data:${E};base64,${QG(M.data)}`;Z.push({type:"input_image",image_url:F})}else throw new c({functionality:`file part media type ${M.mediaType}`});break}default:{let E=M;Y.push({type:"other",message:"xAI Responses API does not support this content type in user messages"})}}A.push({role:"user",content:Z});break}case"assistant":{for(let Z of X.content)switch(Z.type){case"text":{let M=typeof((L=(D=Z.providerOptions)==null?void 0:D.xai)==null?void 0:L.itemId)==="string"?Z.providerOptions.xai.itemId:void 0;A.push({role:"assistant",content:Z.text,id:M});break}case"tool-call":{if(Z.providerExecuted)break;let M=typeof((K=(q=Z.providerOptions)==null?void 0:q.xai)==null?void 0:K.itemId)==="string"?Z.providerOptions.xai.itemId:void 0;A.push({type:"function_call",id:M!=null?M:Z.toolCallId,call_id:Z.toolCallId,name:Z.toolName,arguments:JSON.stringify(Z.input),status:"completed"});break}case"tool-result":break;case"reasoning":case"file":{Y.push({type:"other",message:`xAI Responses API does not support ${Z.type} in assistant messages`});break}default:{let M=Z;Y.push({type:"other",message:"xAI Responses API does not support this content type in assistant messages"})}}break}case"tool":{for(let Z of X.content){if(Z.type==="tool-approval-response")continue;let M=Z.output,E;switch(M.type){case"text":case"error-text":E=M.value;break;case"execution-denied":E=(z=M.reason)!=null?z:"tool execution denied";break;case"json":case"error-json":E=JSON.stringify(M.value);break;case"content":E=M.value.map((F)=>{if(F.type==="text")return F.text;return""}).join("");break;default:{let F=M;E=""}}A.push({type:"function_call_output",call_id:Z.toolCallId,output:E})}break}default:{let Z=X;Y.push({type:"other",message:"unsupported message role"})}}return{input:A,inputWarnings:Y}}function ZG(J){var D,L,q,K;let z=(L=(D=J.input_tokens_details)==null?void 0:D.cached_tokens)!=null?L:0,A=(K=(q=J.output_tokens_details)==null?void 0:q.reasoning_tokens)!=null?K:0,Y=z<=J.input_tokens;return{inputTokens:{total:Y?J.input_tokens:J.input_tokens+z,noCache:Y?J.input_tokens-z:J.input_tokens,cacheRead:z,cacheWrite:void 0},outputTokens:{total:J.output_tokens,text:J.output_tokens-A,reasoning:A},raw:J}}function o(J){switch(J){case"stop":case"completed":return"stop";case"length":case"max_output_tokens":return"length";case"tool_calls":case"function_call":return"tool-calls";case"content_filter":return"content-filter";default:return"other"}}var KG=G.union([G.object({type:G.literal("url_citation"),url:G.string(),title:G.string().optional()}),G.object({type:G.string()})]),AG=G.object({type:G.string(),text:G.string().optional(),logprobs:G.array(G.any()).optional(),annotations:G.array(KG).optional()}),jG=G.object({type:G.string(),text:G.string()}),i=G.object({name:G.string().optional(),arguments:G.string().optional(),input:G.string().optional(),call_id:G.string().optional(),id:G.string(),status:G.string(),action:G.any().optional()}),tG=G.object({name:G.string().optional(),arguments:G.string().optional(),output:G.string().optional(),error:G.string().optional(),id:G.string(),status:G.string(),server_label:G.string().optional()}),DG=G.discriminatedUnion("type",[G.object({type:G.literal("web_search_call"),...i.shape}),G.object({type:G.literal("x_search_call"),...i.shape}),G.object({type:G.literal("code_interpreter_call"),...i.shape}),G.object({type:G.literal("code_execution_call"),...i.shape}),G.object({type:G.literal("view_image_call"),...i.shape}),G.object({type:G.literal("view_x_video_call"),...i.shape}),G.object({type:G.literal("file_search_call"),id:G.string(),status:G.string(),queries:G.array(G.string()).optional(),results:G.array(G.object({file_id:G.string(),filename:G.string(),score:G.number(),text:G.string()})).nullish()}),G.object({type:G.literal("custom_tool_call"),...i.shape}),G.object({type:G.literal("mcp_call"),...tG.shape}),G.object({type:G.literal("message"),role:G.string(),content:G.array(AG),id:G.string(),status:G.string()}),G.object({type:G.literal("function_call"),name:G.string(),arguments:G.string(),call_id:G.string(),id:G.string()}),G.object({type:G.literal("reasoning"),id:G.string(),summary:G.array(jG),status:G.string(),encrypted_content:G.string().nullish()})]),qG=G.object({input_tokens:G.number(),output_tokens:G.number(),total_tokens:G.number().optional(),input_tokens_details:G.object({cached_tokens:G.number().optional()}).optional(),output_tokens_details:G.object({reasoning_tokens:G.number().optional()}).optional(),num_sources_used:G.number().optional(),num_server_side_tools_used:G.number().optional()}),t=G.object({id:G.string().nullish(),created_at:G.number().nullish(),model:G.string().nullish(),object:G.literal("response"),output:G.array(DG),usage:qG.nullish(),status:G.string()}),eG=G.union([G.object({type:G.literal("response.created"),response:t.partial({usage:!0,status:!0})}),G.object({type:G.literal("response.in_progress"),response:t.partial({usage:!0,status:!0})}),G.object({type:G.literal("response.output_item.added"),item:DG,output_index:G.number()}),G.object({type:G.literal("response.output_item.done"),item:DG,output_index:G.number()}),G.object({type:G.literal("response.content_part.added"),item_id:G.string(),output_index:G.number(),content_index:G.number(),part:AG}),G.object({type:G.literal("response.content_part.done"),item_id:G.string(),output_index:G.number(),content_index:G.number(),part:AG}),G.object({type:G.literal("response.output_text.delta"),item_id:G.string(),output_index:G.number(),content_index:G.number(),delta:G.string(),logprobs:G.array(G.any()).optional()}),G.object({type:G.literal("response.output_text.done"),item_id:G.string(),output_index:G.number(),content_index:G.number(),text:G.string(),logprobs:G.array(G.any()).optional(),annotations:G.array(KG).optional()}),G.object({type:G.literal("response.output_text.annotation.added"),item_id:G.string(),output_index:G.number(),content_index:G.number(),annotation_index:G.number(),annotation:KG}),G.object({type:G.literal("response.reasoning_summary_part.added"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),part:jG}),G.object({type:G.literal("response.reasoning_summary_part.done"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),part:jG}),G.object({type:G.literal("response.reasoning_summary_text.delta"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.reasoning_summary_text.done"),item_id:G.string(),output_index:G.number(),summary_index:G.number(),text:G.string()}),G.object({type:G.literal("response.reasoning_text.delta"),item_id:G.string(),output_index:G.number(),content_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.reasoning_text.done"),item_id:G.string(),output_index:G.number(),content_index:G.number(),text:G.string()}),G.object({type:G.literal("response.web_search_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.web_search_call.searching"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.web_search_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.x_search_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.x_search_call.searching"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.x_search_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.file_search_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.file_search_call.searching"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.file_search_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_execution_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_execution_call.executing"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_execution_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.executing"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.interpreting"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.code_interpreter_call_code.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.code_interpreter_call_code.done"),item_id:G.string(),output_index:G.number(),code:G.string()}),G.object({type:G.literal("response.custom_tool_call_input.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.custom_tool_call_input.done"),item_id:G.string(),output_index:G.number(),input:G.string()}),G.object({type:G.literal("response.function_call_arguments.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.function_call_arguments.done"),item_id:G.string(),output_index:G.number(),arguments:G.string()}),G.object({type:G.literal("response.mcp_call.in_progress"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call.executing"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call.completed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call.failed"),item_id:G.string(),output_index:G.number()}),G.object({type:G.literal("response.mcp_call_arguments.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.mcp_call_arguments.done"),item_id:G.string(),output_index:G.number(),arguments:G.string().optional()}),G.object({type:G.literal("response.mcp_call_output.delta"),item_id:G.string(),output_index:G.number(),delta:G.string()}),G.object({type:G.literal("response.mcp_call_output.done"),item_id:G.string(),output_index:G.number(),output:G.string().optional()}),G.object({type:G.literal("response.incomplete"),response:G.object({incomplete_details:G.object({reason:G.string()}).nullish(),usage:qG.nullish()})}),G.object({type:G.literal("response.failed"),response:G.object({error:G.object({code:G.string().nullish(),message:G.string()}).nullish(),incomplete_details:G.object({reason:G.string()}).nullish(),usage:qG.nullish()})}),G.object({type:G.literal("error"),code:G.string().nullish(),message:G.string(),param:G.string().nullish()}),G.object({type:G.literal("response.done"),response:t}),G.object({type:G.literal("response.completed"),response:t})]),oG=G.object({reasoningEffort:G.enum(["low","medium","high"]).optional(),logprobs:G.boolean().optional(),topLogprobs:G.number().int().min(0).max(8).optional(),store:G.boolean().optional(),previousResponseId:G.string().optional(),include:G.array(G.enum(["file_search_call.results"])).nullish()}),GJ=v(()=>k(G.object({vectorStoreIds:G.array(G.string()),maxNumResults:G.number().optional()}))),JJ=v(()=>k(G.object({queries:G.array(G.string()),results:G.array(G.object({fileId:G.string(),filename:G.string(),score:G.number().min(0).max(1),text:G.string()})).nullable()}))),QJ=_({id:"xai.file_search",inputSchema:v(()=>k(G.object({}))),outputSchema:JJ}),XJ=(J)=>QJ(J),YJ=v(()=>k(G.object({serverUrl:G.string().describe("The URL of the MCP server"),serverLabel:G.string().optional().describe("A label for the MCP server"),serverDescription:G.string().optional().describe("Description of the MCP server"),allowedTools:G.array(G.string()).optional().describe("List of allowed tool names"),headers:G.record(G.string(),G.string()).optional().describe("Custom headers to send"),authorization:G.string().optional().describe("Authorization header value")}))),ZJ=v(()=>k(G.object({name:G.string(),arguments:G.string(),result:G.unknown()}))),$J=_({id:"xai.mcp",inputSchema:v(()=>k(G.object({}))),outputSchema:ZJ}),KJ=(J)=>$J(J),AJ=v(()=>k(G.object({allowedDomains:G.array(G.string()).max(5).optional(),excludedDomains:G.array(G.string()).max(5).optional(),enableImageUnderstanding:G.boolean().optional()}))),jJ=v(()=>k(G.object({query:G.string(),sources:G.array(G.object({title:G.string(),url:G.string(),snippet:G.string()}))}))),DJ=_({id:"xai.web_search",inputSchema:v(()=>k(G.object({}))),outputSchema:jJ}),qJ=(J={})=>DJ(J),zJ=v(()=>k(G.object({allowedXHandles:G.array(G.string()).max(10).optional(),excludedXHandles:G.array(G.string()).max(10).optional(),fromDate:G.string().optional(),toDate:G.string().optional(),enableImageUnderstanding:G.boolean().optional(),enableVideoUnderstanding:G.boolean().optional()}))),VJ=v(()=>k(G.object({query:G.string(),posts:G.array(G.object({author:G.string(),text:G.string(),url:G.string(),likes:G.number()}))}))),LJ=_({id:"xai.x_search",inputSchema:v(()=>k(G.object({}))),outputSchema:VJ}),UJ=(J={})=>LJ(J);async function HJ({tools:J,toolChoice:D}){let L=(J==null?void 0:J.length)?J:void 0,q=[];if(L==null)return{tools:void 0,toolChoice:void 0,toolWarnings:q};let K=[],z=new Map;for(let Y of L)if(z.set(Y.name,Y),Y.type==="provider")switch(Y.id){case"xai.web_search":{let X=await s({value:Y.args,schema:AJ});K.push({type:"web_search",allowed_domains:X.allowedDomains,excluded_domains:X.excludedDomains,enable_image_understanding:X.enableImageUnderstanding});break}case"xai.x_search":{let X=await s({value:Y.args,schema:zJ});K.push({type:"x_search",allowed_x_handles:X.allowedXHandles,excluded_x_handles:X.excludedXHandles,from_date:X.fromDate,to_date:X.toDate,enable_image_understanding:X.enableImageUnderstanding,enable_video_understanding:X.enableVideoUnderstanding});break}case"xai.code_execution":{K.push({type:"code_interpreter"});break}case"xai.view_image":{K.push({type:"view_image"});break}case"xai.view_x_video":{K.push({type:"view_x_video"});break}case"xai.file_search":{let X=await s({value:Y.args,schema:GJ});K.push({type:"file_search",vector_store_ids:X.vectorStoreIds,max_num_results:X.maxNumResults});break}case"xai.mcp":{let X=await s({value:Y.args,schema:YJ});K.push({type:"mcp",server_url:X.serverUrl,server_label:X.serverLabel,server_description:X.serverDescription,allowed_tools:X.allowedTools,headers:X.headers,authorization:X.authorization});break}default:{q.push({type:"unsupported",feature:`provider-defined tool ${Y.name}`});break}}else K.push({type:"function",name:Y.name,description:Y.description,parameters:Y.inputSchema,...Y.strict!=null?{strict:Y.strict}:{}});if(D==null)return{tools:K,toolChoice:void 0,toolWarnings:q};let A=D.type;switch(A){case"auto":case"none":return{tools:K,toolChoice:A,toolWarnings:q};case"required":return{tools:K,toolChoice:"required",toolWarnings:q};case"tool":{let Y=z.get(D.toolName);if(Y==null)return{tools:K,toolChoice:void 0,toolWarnings:q};if(Y.type==="provider")return q.push({type:"unsupported",feature:`toolChoice for server-side tool "${Y.name}"`}),{tools:K,toolChoice:void 0,toolWarnings:q};return{tools:K,toolChoice:{type:"function",name:Y.name},toolWarnings:q}}default:throw new c({functionality:`tool choice type: ${A}`})}}var MJ=class{constructor(J,D){this.specificationVersion="v3",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=J,this.config=D}get provider(){return this.config.provider}async getArgs({prompt:J,maxOutputTokens:D,temperature:L,topP:q,stopSequences:K,seed:z,responseFormat:A,providerOptions:Y,tools:X,toolChoice:Z}){var M,E,F,B,R,N,$;let W=[],H=(M=await p({provider:"xai",providerOptions:Y,schema:oG}))!=null?M:{};if(K!=null)W.push({type:"unsupported",feature:"stopSequences"});let O=(E=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.web_search"))==null?void 0:E.name,C=(F=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.x_search"))==null?void 0:F.name,w=(B=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.code_execution"))==null?void 0:B.name,j=(R=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.mcp"))==null?void 0:R.name,y=(N=X==null?void 0:X.find((x)=>x.type==="provider"&&x.id==="xai.file_search"))==null?void 0:N.name,{input:S,inputWarnings:h}=await sG({prompt:J,store:!0});W.push(...h);let{tools:m,toolChoice:I,toolWarnings:P}=await HJ({tools:X,toolChoice:Z});W.push(...P);let f=H.include?[...H.include]:void 0;if(H.store===!1)if(f==null)f=["reasoning.encrypted_content"];else f=[...f,"reasoning.encrypted_content"];let U={model:this.modelId,input:S,logprobs:H.logprobs===!0||H.topLogprobs!=null?!0:void 0,top_logprobs:H.topLogprobs,max_output_tokens:D,temperature:L,top_p:q,seed:z,...(A==null?void 0:A.type)==="json"&&{text:{format:A.schema!=null?{type:"json_schema",strict:!0,name:($=A.name)!=null?$:"response",description:A.description,schema:A.schema}:{type:"json_object"}}},...H.reasoningEffort!=null&&{reasoning:{effort:H.reasoningEffort}},...H.store===!1&&{store:H.store},...f!=null&&{include:f},...H.previousResponseId!=null&&{previous_response_id:H.previousResponseId}};if(m&&m.length>0)U.tools=m;if(I!=null)U.tool_choice=I;return{args:U,warnings:W,webSearchToolName:O,xSearchToolName:C,codeExecutionToolName:w,mcpToolName:j,fileSearchToolName:y}}async doGenerate(J){var D,L,q,K,z,A,Y,X,Z,M,E,F,B;let{args:R,warnings:N,webSearchToolName:$,xSearchToolName:W,codeExecutionToolName:H,mcpToolName:O,fileSearchToolName:C}=await this.getArgs(J),{responseHeaders:w,value:j,rawValue:y}=await u({url:`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/responses`,headers:g(this.config.headers(),J.headers),body:R,failedResponseHandler:r,successfulResponseHandler:d(t),abortSignal:J.abortSignal,fetch:this.config.fetch}),S=[],h=!1,m=["web_search","web_search_with_snippets","browse_page"],I=["x_user_search","x_keyword_search","x_semantic_search","x_thread_fetch"];for(let P of j.output){if(P.type==="file_search_call"){let f=C!=null?C:"file_search";S.push({type:"tool-call",toolCallId:P.id,toolName:f,input:"",providerExecuted:!0}),S.push({type:"tool-result",toolCallId:P.id,toolName:f,result:{queries:(L=P.queries)!=null?L:[],results:(K=(q=P.results)==null?void 0:q.map((U)=>({fileId:U.file_id,filename:U.filename,score:U.score,text:U.text})))!=null?K:null}});continue}if(P.type==="web_search_call"||P.type==="x_search_call"||P.type==="code_interpreter_call"||P.type==="code_execution_call"||P.type==="view_image_call"||P.type==="view_x_video_call"||P.type==="custom_tool_call"||P.type==="mcp_call"){let f=(z=P.name)!=null?z:"";if(m.includes((A=P.name)!=null?A:"")||P.type==="web_search_call")f=$!=null?$:"web_search";else if(I.includes((Y=P.name)!=null?Y:"")||P.type==="x_search_call")f=W!=null?W:"x_search";else if(P.name==="code_execution"||P.type==="code_interpreter_call"||P.type==="code_execution_call")f=H!=null?H:"code_execution";else if(P.type==="mcp_call")f=(X=O!=null?O:P.name)!=null?X:"mcp";let U=P.type==="custom_tool_call"?(Z=P.input)!=null?Z:"":P.type==="mcp_call"?(M=P.arguments)!=null?M:"":(E=P.arguments)!=null?E:"";S.push({type:"tool-call",toolCallId:P.id,toolName:f,input:U,providerExecuted:!0});continue}switch(P.type){case"message":{for(let f of P.content){if(f.text)S.push({type:"text",text:f.text});if(f.annotations){for(let U of f.annotations)if(U.type==="url_citation"&&"url"in U)S.push({type:"source",sourceType:"url",id:this.config.generateId(),url:U.url,title:(F=U.title)!=null?F:U.url})}}break}case"function_call":{h=!0,S.push({type:"tool-call",toolCallId:P.call_id,toolName:P.name,input:P.arguments});break}case"reasoning":{let f=P.summary.map((U)=>U.text).filter((U)=>U&&U.length>0);if(f.length>0){let U=f.join("");if(P.encrypted_content||P.id)S.push({type:"reasoning",text:U,providerMetadata:{xai:{...P.encrypted_content&&{reasoningEncryptedContent:P.encrypted_content},...P.id&&{itemId:P.id}}}});else S.push({type:"reasoning",text:U})}break}default:break}}return{content:S,finishReason:{unified:h?"tool-calls":o(j.status),raw:(B=j.status)!=null?B:void 0},usage:j.usage?ZG(j.usage):{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}},request:{body:R},response:{...JG(j),headers:w,body:y},warnings:N}}async doStream(J){var D;let{args:L,warnings:q,webSearchToolName:K,xSearchToolName:z,codeExecutionToolName:A,mcpToolName:Y,fileSearchToolName:X}=await this.getArgs(J),Z={...L,stream:!0},{responseHeaders:M,value:E}=await u({url:`${(D=this.config.baseURL)!=null?D:"https://api.x.ai/v1"}/responses`,headers:g(this.config.headers(),J.headers),body:Z,failedResponseHandler:r,successfulResponseHandler:YG(eG),abortSignal:J.abortSignal,fetch:this.config.fetch}),F={unified:"other",raw:void 0},B=!1,R=void 0,N=!0,$={},W=new Set,H={},O={},C=this;return{stream:E.pipeThrough(new TransformStream({start(w){w.enqueue({type:"stream-start",warnings:q})},transform(w,j){var y,S,h,m,I,P,f,U,x,zG,VG,LG,UG,HG,MG;if(J.includeRawChunks)j.enqueue({type:"raw",rawValue:w.rawValue});if(!w.success){j.enqueue({type:"error",error:w.error});return}let V=w.value;if(V.type==="response.created"||V.type==="response.in_progress"){if(N)j.enqueue({type:"response-metadata",...JG(V.response)}),N=!1;return}if(V.type==="response.reasoning_summary_part.added"){let Q=`reasoning-${V.item_id}`;O[V.item_id]={},j.enqueue({type:"reasoning-start",id:Q,providerMetadata:{xai:{itemId:V.item_id}}})}if(V.type==="response.reasoning_summary_text.delta"){let Q=`reasoning-${V.item_id}`;j.enqueue({type:"reasoning-delta",id:Q,delta:V.delta,providerMetadata:{xai:{itemId:V.item_id}}});return}if(V.type==="response.reasoning_summary_text.done")return;if(V.type==="response.reasoning_text.delta"){let Q=`reasoning-${V.item_id}`;if(O[V.item_id]==null)O[V.item_id]={},j.enqueue({type:"reasoning-start",id:Q,providerMetadata:{xai:{itemId:V.item_id}}});j.enqueue({type:"reasoning-delta",id:Q,delta:V.delta,providerMetadata:{xai:{itemId:V.item_id}}});return}if(V.type==="response.reasoning_text.done")return;if(V.type==="response.output_text.delta"){let Q=`text-${V.item_id}`;if($[Q]==null)$[Q]={type:"text"},j.enqueue({type:"text-start",id:Q});j.enqueue({type:"text-delta",id:Q,delta:V.delta});return}if(V.type==="response.output_text.done"){if(V.annotations){for(let Q of V.annotations)if(Q.type==="url_citation"&&"url"in Q)j.enqueue({type:"source",sourceType:"url",id:C.config.generateId(),url:Q.url,title:(y=Q.title)!=null?y:Q.url})}return}if(V.type==="response.output_text.annotation.added"){let Q=V.annotation;if(Q.type==="url_citation"&&"url"in Q)j.enqueue({type:"source",sourceType:"url",id:C.config.generateId(),url:Q.url,title:(S=Q.title)!=null?S:Q.url});return}if(V.type==="response.done"||V.type==="response.completed"||V.type==="response.incomplete"){let Q=V.response;if(Q.usage)R=ZG(Q.usage);if(V.type==="response.incomplete"){let T="incomplete_details"in Q?(h=Q.incomplete_details)==null?void 0:h.reason:void 0;F={unified:T?o(T):"other",raw:T!=null?T:"incomplete"}}else if("status"in Q&&Q.status)F={unified:B?"tool-calls":o(Q.status),raw:Q.status};return}if(V.type==="response.failed"){let Q=(m=V.response.incomplete_details)==null?void 0:m.reason;if(F={unified:Q?o(Q):"error",raw:Q!=null?Q:"error"},V.response.usage)R=ZG(V.response.usage);return}if(V.type==="error"){j.enqueue({type:"error",error:V});return}if(V.type==="response.custom_tool_call_input.delta"||V.type==="response.custom_tool_call_input.done")return;if(V.type==="response.function_call_arguments.delta"){let Q=H[V.output_index];if(Q!=null)j.enqueue({type:"tool-input-delta",id:Q.toolCallId,delta:V.delta});return}if(V.type==="response.function_call_arguments.done")return;if(V.type==="response.output_item.added"||V.type==="response.output_item.done"){let Q=V.item;if(Q.type==="reasoning"){if(V.type==="response.output_item.done"){let T=`reasoning-${Q.id}`;if(!(Q.id in O))O[Q.id]={},j.enqueue({type:"reasoning-start",id:T,providerMetadata:{xai:{...Q.id&&{itemId:Q.id}}}});j.enqueue({type:"reasoning-end",id:T,providerMetadata:{xai:{...Q.encrypted_content&&{reasoningEncryptedContent:Q.encrypted_content},...Q.id&&{itemId:Q.id}}}}),delete O[Q.id]}return}if(Q.type==="file_search_call"){let T=X!=null?X:"file_search";if(!W.has(Q.id))W.add(Q.id),j.enqueue({type:"tool-input-start",id:Q.id,toolName:T}),j.enqueue({type:"tool-input-delta",id:Q.id,delta:""}),j.enqueue({type:"tool-input-end",id:Q.id}),j.enqueue({type:"tool-call",toolCallId:Q.id,toolName:T,input:"",providerExecuted:!0});if(V.type==="response.output_item.done")j.enqueue({type:"tool-result",toolCallId:Q.id,toolName:T,result:{queries:(I=Q.queries)!=null?I:[],results:(f=(P=Q.results)==null?void 0:P.map((b)=>({fileId:b.file_id,filename:b.filename,score:b.score,text:b.text})))!=null?f:null}});return}if(Q.type==="web_search_call"||Q.type==="x_search_call"||Q.type==="code_interpreter_call"||Q.type==="code_execution_call"||Q.type==="view_image_call"||Q.type==="view_x_video_call"||Q.type==="custom_tool_call"||Q.type==="mcp_call"){let T=["web_search","web_search_with_snippets","browse_page"],b=["x_user_search","x_keyword_search","x_semantic_search","x_thread_fetch"],n=(U=Q.name)!=null?U:"";if(T.includes((x=Q.name)!=null?x:"")||Q.type==="web_search_call")n=K!=null?K:"web_search";else if(b.includes((zG=Q.name)!=null?zG:"")||Q.type==="x_search_call")n=z!=null?z:"x_search";else if(Q.name==="code_execution"||Q.type==="code_interpreter_call"||Q.type==="code_execution_call")n=A!=null?A:"code_execution";else if(Q.type==="mcp_call")n=(VG=Y!=null?Y:Q.name)!=null?VG:"mcp";let PG=Q.type==="custom_tool_call"?(LG=Q.input)!=null?LG:"":Q.type==="mcp_call"?(UG=Q.arguments)!=null?UG:"":(HG=Q.arguments)!=null?HG:"";if((Q.type==="custom_tool_call"?V.type==="response.output_item.done":!W.has(Q.id))&&!W.has(Q.id))W.add(Q.id),j.enqueue({type:"tool-input-start",id:Q.id,toolName:n}),j.enqueue({type:"tool-input-delta",id:Q.id,delta:PG}),j.enqueue({type:"tool-input-end",id:Q.id}),j.enqueue({type:"tool-call",toolCallId:Q.id,toolName:n,input:PG,providerExecuted:!0});return}if(Q.type==="message")for(let T of Q.content){if(T.text&&T.text.length>0){let b=`text-${Q.id}`;if($[b]==null)$[b]={type:"text"},j.enqueue({type:"text-start",id:b}),j.enqueue({type:"text-delta",id:b,delta:T.text})}if(T.annotations){for(let b of T.annotations)if(b.type==="url_citation"&&"url"in b)j.enqueue({type:"source",sourceType:"url",id:C.config.generateId(),url:b.url,title:(MG=b.title)!=null?MG:b.url})}}else if(Q.type==="function_call"){if(V.type==="response.output_item.added")H[V.output_index]={toolName:Q.name,toolCallId:Q.call_id},j.enqueue({type:"tool-input-start",id:Q.call_id,toolName:Q.name});else if(V.type==="response.output_item.done")B=!0,H[V.output_index]=void 0,j.enqueue({type:"tool-input-end",id:Q.call_id}),j.enqueue({type:"tool-call",toolCallId:Q.call_id,toolName:Q.name,input:Q.arguments})}}},flush(w){for(let[j,y]of Object.entries($))if(y.type==="text")w.enqueue({type:"text-end",id:j});w.enqueue({type:"finish",finishReason:F,usage:R!=null?R:{inputTokens:{total:0,noCache:0,cacheRead:0,cacheWrite:0},outputTokens:{total:0,text:0,reasoning:0}}})}})),request:{body:Z},response:{headers:M}}}},PJ=G.object({output:G.string().describe("the output of the code execution"),error:G.string().optional().describe("any error that occurred")}),EJ=_({id:"xai.code_execution",inputSchema:G.object({}).describe("no input parameters"),outputSchema:PJ}),WJ=(J={})=>EJ(J),BJ=G.object({description:G.string().describe("description of the image"),objects:G.array(G.string()).optional().describe("objects detected in the image")}),FJ=_({id:"xai.view_image",inputSchema:G.object({}).describe("no input parameters"),outputSchema:BJ}),NJ=(J={})=>FJ(J),wJ=G.object({transcript:G.string().optional().describe("transcript of the video"),description:G.string().describe("description of the video content"),duration:G.number().optional().describe("duration in seconds")}),SJ=_({id:"xai.view_x_video",inputSchema:G.object({}).describe("no input parameters"),outputSchema:wJ}),OJ=(J={})=>SJ(J),fJ={codeExecution:WJ,fileSearch:XJ,mcpServer:KJ,viewImage:NJ,viewXVideo:OJ,webSearch:qJ,xSearch:UJ},CJ="3.0.82",a=G.string().min(1),yJ=G.enum(["480p","720p"]),IJ=G.enum(["edit-video","extend-video","reference-to-video"]),e={pollIntervalMs:G.number().positive().nullish(),pollTimeoutMs:G.number().positive().nullish(),resolution:yJ.nullish()},RJ=G.object({...e,mode:G.literal("edit-video"),videoUrl:a,referenceImageUrls:G.undefined().optional()}),xJ=G.object({...e,mode:G.literal("extend-video"),videoUrl:a,referenceImageUrls:G.undefined().optional()}),TJ=G.object({...e,mode:G.literal("reference-to-video"),referenceImageUrls:G.array(a).min(1).max(7),videoUrl:G.undefined().optional()}),vJ=G.object({...e,mode:G.undefined().optional(),videoUrl:a.optional(),referenceImageUrls:G.array(a).min(1).max(7).optional()}),IQ=G.union([RJ,xJ,TJ,vJ]),kJ=G.object({mode:IJ.optional(),videoUrl:a.optional(),referenceImageUrls:G.array(a).min(1).max(7).optional(),...e}).passthrough(),bJ=v(()=>k(kJ)),hJ={"1280x720":"720p","854x480":"480p","640x480":"480p"};function _J(J){if((J==null?void 0:J.mode)!=null)return J.mode;if((J==null?void 0:J.videoUrl)!=null)return"edit-video";if((J==null?void 0:J.referenceImageUrls)!=null&&J.referenceImageUrls.length>0)return"reference-to-video";return}var mJ=class{constructor(J,D){this.modelId=J,this.config=D,this.specificationVersion="v3",this.maxVideosPerCall=1}get provider(){return this.config.provider}async doGenerate(J){var D,L,q,K,z,A,Y,X,Z,M;let E=(q=(L=(D=this.config._internal)==null?void 0:D.currentDate)==null?void 0:L.call(D))!=null?q:new Date,F=[],B=await p({provider:"xai",providerOptions:J.providerOptions,schema:bJ}),R=_J(B),N=R==="edit-video",$=R==="extend-video",W=R==="reference-to-video";if(J.fps!=null)F.push({type:"unsupported",feature:"fps",details:"xAI video models do not support custom FPS."});if(J.seed!=null)F.push({type:"unsupported",feature:"seed",details:"xAI video models do not support seed."});if(J.n!=null&&J.n>1)F.push({type:"unsupported",feature:"n",details:"xAI video models do not support generating multiple videos per call. Only 1 video will be generated."});if(N&&J.duration!=null)F.push({type:"unsupported",feature:"duration",details:"xAI video editing does not support custom duration."});if(N&&J.aspectRatio!=null)F.push({type:"unsupported",feature:"aspectRatio",details:"xAI video editing does not support custom aspect ratio."});if(N&&((B==null?void 0:B.resolution)!=null||J.resolution!=null))F.push({type:"unsupported",feature:"resolution",details:"xAI video editing does not support custom resolution."});if($&&J.aspectRatio!=null)F.push({type:"unsupported",feature:"aspectRatio",details:"xAI video extension does not support custom aspect ratio."});if($&&((B==null?void 0:B.resolution)!=null||J.resolution!=null))F.push({type:"unsupported",feature:"resolution",details:"xAI video extension does not support custom resolution."});let H={model:this.modelId,prompt:J.prompt},O=!N,C=!N&&!$,w=!N&&!$;if(O&&J.duration!=null)H.duration=J.duration;if(C&&J.aspectRatio!=null)H.aspect_ratio=J.aspectRatio;if(w&&(B==null?void 0:B.resolution)!=null)H.resolution=B.resolution;else if(w&&J.resolution!=null){let U=hJ[J.resolution];if(U!=null)H.resolution=U;else F.push({type:"unsupported",feature:"resolution",details:`Unrecognized resolution "${J.resolution}". Use providerOptions.xai.resolution with "480p" or "720p" instead.`})}if(N)H.video={url:B.videoUrl};if($)H.video={url:B.videoUrl};if(J.image!=null)if(J.image.type==="url")H.image={url:J.image.url};else{let U=typeof J.image.data==="string"?J.image.data:wG(J.image.data);H.image={url:`data:${J.image.mediaType};base64,${U}`}}if(W)H.reference_images=B.referenceImageUrls.map((U)=>({url:U}));if(B!=null){for(let[U,x]of Object.entries(B))if(!["mode","pollIntervalMs","pollTimeoutMs","resolution","videoUrl","referenceImageUrls"].includes(U))H[U]=x}let j=(K=this.config.baseURL)!=null?K:"https://api.x.ai/v1",y;if(N)y=`${j}/videos/edits`;else if($)y=`${j}/videos/extensions`;else y=`${j}/videos/generations`;let{value:S}=await u({url:y,headers:g(this.config.headers(),J.headers),body:H,failedResponseHandler:r,successfulResponseHandler:d(gJ),abortSignal:J.abortSignal,fetch:this.config.fetch}),h=S.request_id;if(!h)throw new l({name:"XAI_VIDEO_GENERATION_ERROR",message:`No request_id returned from xAI API. Response: ${JSON.stringify(S)}`});let m=(z=B==null?void 0:B.pollIntervalMs)!=null?z:5000,I=(A=B==null?void 0:B.pollTimeoutMs)!=null?A:600000,P=Date.now(),f;while(!0){if(await FG(m,{abortSignal:J.abortSignal}),Date.now()-P>I)throw new l({name:"XAI_VIDEO_GENERATION_TIMEOUT",message:`Video generation timed out after ${I}ms`});let{value:U,responseHeaders:x}=await XG({url:`${j}/videos/${h}`,headers:g(this.config.headers(),J.headers),successfulResponseHandler:d(uJ),failedResponseHandler:r,abortSignal:J.abortSignal,fetch:this.config.fetch});if(f=x,U.status==="done"||U.status==null&&((Y=U.video)==null?void 0:Y.url)){if(((X=U.video)==null?void 0:X.respect_moderation)===!1)throw new l({name:"XAI_VIDEO_MODERATION_ERROR",message:"Video generation was blocked due to a content policy violation."});if(!((Z=U.video)==null?void 0:Z.url))throw new l({name:"XAI_VIDEO_GENERATION_ERROR",message:"Video generation completed but no video URL was returned."});return{videos:[{type:"url",url:U.video.url,mediaType:"video/mp4"}],warnings:F,response:{timestamp:E,modelId:this.modelId,headers:f},providerMetadata:{xai:{requestId:h,videoUrl:U.video.url,...U.video.duration!=null?{duration:U.video.duration}:{},...((M=U.usage)==null?void 0:M.cost_in_usd_ticks)!=null?{costInUsdTicks:U.usage.cost_in_usd_ticks}:{},...U.progress!=null?{progress:U.progress}:{}}}}}if(U.status==="expired")throw new l({name:"XAI_VIDEO_GENERATION_EXPIRED",message:"Video generation request expired."});if(U.status==="failed")throw new l({name:"XAI_VIDEO_GENERATION_FAILED",message:"Video generation failed."})}}},gJ=G.object({request_id:G.string().nullish()}),uJ=G.object({status:G.string().nullish(),video:G.object({url:G.string(),duration:G.number().nullish(),respect_moderation:G.boolean().nullish()}).nullish(),model:G.string().nullish(),usage:G.object({cost_in_usd_ticks:G.number().nullish()}).nullish(),progress:G.number().nullish(),error:G.object({code:G.string().nullish(),message:G.string().nullish()}).nullish()});function dJ(J={}){var D;let L=xG((D=J.baseURL)!=null?D:"https://api.x.ai/v1"),q=()=>OG({Authorization:`Bearer ${fG({apiKey:J.apiKey,environmentVariableName:"XAI_API_KEY",description:"xAI API key"})}`,...J.headers},`ai-sdk/xai/${CJ}`),K=(Z)=>{return new cG(Z,{provider:"xai.chat",baseURL:L,headers:q,generateId:$G,fetch:J.fetch})},z=(Z)=>{return new MJ(Z,{provider:"xai.responses",baseURL:L,headers:q,generateId:$G,fetch:J.fetch})},A=(Z)=>{return new aG(Z,{provider:"xai.image",baseURL:L,headers:q,fetch:J.fetch})},Y=(Z)=>{return new mJ(Z,{provider:"xai.video",baseURL:L,headers:q,fetch:J.fetch})},X=(Z)=>K(Z);return X.specificationVersion="v3",X.languageModel=K,X.chat=K,X.responses=z,X.embeddingModel=(Z)=>{throw new BG({modelId:Z,modelType:"embeddingModel"})},X.textEmbeddingModel=X.embeddingModel,X.imageModel=A,X.image=A,X.videoModel=Y,X.video=Y,X.tools=fJ,X}var RQ=dJ();export{fJ as xaiTools,RQ as xai,UJ as xSearch,qJ as webSearch,OJ as viewXVideo,NJ as viewImage,KJ as mcpServer,dJ as createXai,WJ as codeExecution,CJ as VERSION};
|