@qitqode/qitqode-android-arm64 0.1.24 → 0.1.26
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-gn9p1d50.js → chunk-01gwb793.js} +1 -1
- package/bundle/{chunk-4kse3awh.js → chunk-0304b7xg.js} +1 -1
- package/bundle/{chunk-k9d927xe.js → chunk-05amr7y9.js} +1 -1
- package/bundle/{chunk-am73j1bt.js → chunk-06x1p3t4.js} +1 -1
- package/bundle/{chunk-9798jffg.js → chunk-07net7s8.js} +1 -1
- package/bundle/chunk-08y06vgt.js +3 -0
- package/bundle/chunk-09ecxdmd.js +2 -0
- package/bundle/{chunk-6mscvf6y.js → chunk-0cehm5fn.js} +1 -1
- package/bundle/chunk-0jaj2g7x.js +2 -0
- package/bundle/{chunk-7gczzccz.js → chunk-0m2tj2h9.js} +1 -1
- package/bundle/{chunk-srf73nm4.js → chunk-0mekr486.js} +1 -1
- package/bundle/{chunk-gen6f3dn.js → chunk-0ndvy0nh.js} +2 -2
- package/bundle/chunk-0nr2925m.js +2 -0
- package/bundle/chunk-0vqrakhw.js +3 -0
- package/bundle/{chunk-vf1r5ckp.js → chunk-0w5npkgr.js} +1 -1
- package/bundle/chunk-0wbq1y92.js +2 -0
- package/bundle/chunk-12pxszgn.js +2 -0
- package/bundle/chunk-1337582e.js +2 -0
- package/bundle/{chunk-hxgb0y1w.js → chunk-14ag9ea0.js} +1 -1
- package/bundle/chunk-182jf8fz.js +2 -0
- package/bundle/chunk-1ht3zcsh.js +2 -0
- package/bundle/{chunk-fhng5her.js → chunk-1n4w8dya.js} +2 -2
- package/bundle/{chunk-g7vkkmsk.js → chunk-1qbm1k9y.js} +3 -3
- package/bundle/{chunk-apq38bt4.js → chunk-1xkwm21b.js} +3 -3
- package/bundle/{chunk-3tkp27x7.js → chunk-1xpx1t40.js} +2 -2
- package/bundle/{chunk-w1atxyz0.js → chunk-1yx4jesj.js} +1 -1
- package/bundle/chunk-25zkavr0.js +2 -0
- package/bundle/{chunk-4k149ews.js → chunk-28vnspd4.js} +1 -1
- package/bundle/chunk-2cm91ktc.js +3 -0
- package/bundle/chunk-2jfd82jk.js +2 -0
- package/bundle/{chunk-ve5gb789.js → chunk-2jn2hd12.js} +2 -2
- package/bundle/chunk-2k7bbzj2.js +2 -0
- package/bundle/{chunk-7yf15a3a.js → chunk-2kdn66xt.js} +1 -1
- package/bundle/{chunk-99n6czag.js → chunk-2q76qax6.js} +2 -2
- package/bundle/{chunk-8pe047p0.js → chunk-2sy1wx99.js} +1 -1
- package/bundle/{chunk-8651hq0k.js → chunk-2yb59jwr.js} +1 -1
- package/bundle/chunk-30081kwd.js +2 -0
- package/bundle/{chunk-g0v9g37f.js → chunk-32zrch7h.js} +1 -1
- package/bundle/{chunk-7y3y3j51.js → chunk-3bb7y9pq.js} +2 -2
- package/bundle/{chunk-jz3aav8a.js → chunk-3kdhvq0p.js} +2 -2
- package/bundle/{chunk-m8djypsy.js → chunk-3rgct4bd.js} +1 -1
- package/bundle/{chunk-frdc3ysq.js → chunk-3s0d17xe.js} +1 -1
- package/bundle/chunk-3vag59se.js +2 -0
- package/bundle/{chunk-j1a64ade.js → chunk-3w64fpwn.js} +2 -2
- package/bundle/chunk-3x5v6sjw.js +2 -0
- package/bundle/{chunk-hqg5qbxk.js → chunk-3zn71txs.js} +1 -1
- package/bundle/{chunk-3vbtra1j.js → chunk-41ftye7w.js} +1 -1
- package/bundle/chunk-43ep9d7a.js +2 -0
- package/bundle/chunk-48j09m6e.js +3 -0
- package/bundle/{chunk-6szvs3k9.js → chunk-4920vf6a.js} +1 -1
- package/bundle/{chunk-wa2ce2sg.js → chunk-49tqzsy0.js} +2 -2
- package/bundle/{chunk-cvchztkc.js → chunk-49ypxzfx.js} +1 -1
- package/bundle/{chunk-6nhje520.js → chunk-4k70wrhf.js} +1 -1
- package/bundle/{chunk-tk3bve0x.js → chunk-4nck07pc.js} +2 -2
- package/bundle/chunk-4qqja22v.js +2 -0
- package/bundle/{chunk-23geekk5.js → chunk-54pk7nna.js} +1 -1
- package/bundle/{chunk-ewyk4py6.js → chunk-56pwz1kk.js} +1 -1
- package/bundle/{chunk-2y8qz8te.js → chunk-56qm8xpt.js} +1 -1
- package/bundle/{chunk-y3n31nnx.js → chunk-58gp7wbg.js} +2 -2
- package/bundle/{chunk-9easaxy7.js → chunk-5dm3p5r6.js} +1 -1
- package/bundle/chunk-5gazgxt5.js +2 -0
- package/bundle/{chunk-0ae5q6ck.js → chunk-5jtd006j.js} +2 -2
- package/bundle/{chunk-t488d66k.js → chunk-5mec6cde.js} +1 -1
- package/bundle/{chunk-gvzfffr4.js → chunk-5yaahmjb.js} +1 -1
- package/bundle/{chunk-jbd9k041.js → chunk-5ymj2q6j.js} +2 -2
- package/bundle/{chunk-ebjhggdw.js → chunk-613kegcn.js} +1 -1
- package/bundle/chunk-63znhwx0.js +2 -0
- package/bundle/{chunk-zavtsfxz.js → chunk-6fpfr8tk.js} +1 -1
- package/bundle/{chunk-0pvbk8ks.js → chunk-6h2faxs9.js} +2 -2
- package/bundle/chunk-6hmyy7n6.js +2 -0
- package/bundle/{chunk-78bajmqm.js → chunk-6nk3wx6f.js} +1 -1
- package/bundle/{chunk-1jsywey3.js → chunk-6nkcfncg.js} +1 -1
- package/bundle/{chunk-ps543k72.js → chunk-6s2f5sv4.js} +1 -1
- package/bundle/{chunk-dcx8hjbs.js → chunk-6vb26adv.js} +1 -1
- package/bundle/{chunk-r48g0kaq.js → chunk-6wdwwpsc.js} +2 -2
- package/bundle/{chunk-8r79zf3y.js → chunk-77e1wh0j.js} +2 -2
- package/bundle/chunk-7dyddrpk.js +2 -0
- package/bundle/{chunk-4d1a547n.js → chunk-7e1aw8rw.js} +1 -1
- package/bundle/{chunk-ac202abt.js → chunk-7ez3ye6e.js} +1 -1
- package/bundle/{chunk-wfnk2vsd.js → chunk-7fmy4cvn.js} +1 -1
- package/bundle/{chunk-82gs5cmn.js → chunk-7n2kpqh5.js} +1 -1
- package/bundle/chunk-7penjsgq.js +2 -0
- package/bundle/chunk-7qxn24qa.js +3 -0
- package/bundle/{chunk-4q9w2yve.js → chunk-7rxsj310.js} +2 -2
- package/bundle/{chunk-dkv2mg97.js → chunk-7ryv0f5h.js} +1 -1
- package/bundle/chunk-7t5gzkj6.js +2 -0
- package/bundle/{chunk-84gnbzky.js → chunk-7tbvr236.js} +1 -1
- package/bundle/{chunk-8cr7ks31.js → chunk-81engf0t.js} +1 -1
- package/bundle/{chunk-cy2586rv.js → chunk-880msfsd.js} +1 -1
- package/bundle/chunk-89vgt8vq.js +2 -0
- package/bundle/{chunk-vftqwdpg.js → chunk-8ahpk8td.js} +1 -1
- package/bundle/{chunk-9f7y0dj0.js → chunk-8bzwgcjb.js} +1 -1
- package/bundle/chunk-8e8n82f9.js +2 -0
- package/bundle/{chunk-xj73j10a.js → chunk-91khd3fq.js} +1 -1
- package/bundle/chunk-97exhw9j.js +2 -0
- package/bundle/chunk-9cvkaht5.js +2 -0
- package/bundle/{chunk-1jh5p5qw.js → chunk-9p83me3p.js} +2 -2
- package/bundle/{chunk-ygj1cy0n.js → chunk-9qtf8khv.js} +1 -1
- package/bundle/{chunk-kaeyhw2n.js → chunk-9wm41z2f.js} +2 -2
- package/bundle/chunk-9zrwbxx0.js +3 -0
- package/bundle/{chunk-q6fbyvpq.js → chunk-admgf65a.js} +1 -1
- package/bundle/{chunk-spm1yy6w.js → chunk-afhg3w2j.js} +1 -1
- package/bundle/chunk-akdvstd9.js +2 -0
- package/bundle/{chunk-w7p2x973.js → chunk-atbm0pnt.js} +2 -2
- package/bundle/chunk-ave2e4sa.js +2 -0
- package/bundle/chunk-axnwehc7.js +2 -0
- package/bundle/{chunk-ns0pswww.js → chunk-b79k456s.js} +1 -1
- package/bundle/chunk-bmzyxspj.js +2 -0
- package/bundle/{chunk-9sy9ws1w.js → chunk-bse8p94q.js} +1 -1
- package/bundle/chunk-bvaqpfv8.js +2 -0
- package/bundle/{chunk-gf4ek7rv.js → chunk-c0k8j498.js} +1 -1
- package/bundle/{chunk-pyq01301.js → chunk-cbmw8fy2.js} +1 -1
- package/bundle/{chunk-cesrhm09.js → chunk-cn10hn58.js} +1 -1
- package/bundle/{chunk-gc9q0x8z.js → chunk-cqhpbfcn.js} +3 -3
- package/bundle/{chunk-jegn6jc3.js → chunk-cr06m77n.js} +2 -2
- package/bundle/{chunk-3wzqs241.js → chunk-crap29f6.js} +1 -1
- package/bundle/chunk-cxb05cdg.js +2 -0
- package/bundle/chunk-cxe92z5c.js +2 -0
- package/bundle/{chunk-b643cra9.js → chunk-cyjzqa5p.js} +195 -195
- package/bundle/{chunk-0w4v0fbs.js → chunk-d2n09yvh.js} +2 -2
- package/bundle/{chunk-fm4xa6yx.js → chunk-d31yrcrn.js} +2 -2
- package/bundle/chunk-d5wp85kw.js +2 -0
- package/bundle/{chunk-6j0365q3.js → chunk-dazye86e.js} +2 -2
- package/bundle/chunk-dm5xnb4t.js +2 -0
- package/bundle/chunk-dpeqsvan.js +2 -0
- package/bundle/chunk-drxtmg5c.js +2 -0
- package/bundle/{chunk-k16hzy2q.js → chunk-dv5zf5gz.js} +1 -1
- package/bundle/{chunk-2qcndbxv.js → chunk-e57d1he9.js} +1 -1
- package/bundle/{chunk-1d64dywx.js → chunk-e58pdw5k.js} +2 -2
- package/bundle/chunk-e9pfdjcy.js +2 -0
- package/bundle/chunk-ejn5hfzd.js +2 -0
- package/bundle/{chunk-hg563h5r.js → chunk-ek1fawsj.js} +2 -2
- package/bundle/{chunk-rvvfs9ps.js → chunk-eq33vmze.js} +1 -1
- package/bundle/{chunk-6sdh1q7g.js → chunk-eqaym8gm.js} +1 -1
- package/bundle/chunk-ernd18jb.js +2 -0
- package/bundle/{chunk-evqxvhdb.js → chunk-ewvgbg68.js} +1 -1
- package/bundle/{chunk-wf09j72q.js → chunk-f3c9667r.js} +2 -2
- package/bundle/{chunk-9nx8hm57.js → chunk-f3rrd2p6.js} +1 -1
- package/bundle/chunk-f416n3mp.js +14 -0
- package/bundle/{chunk-hh3w51wp.js → chunk-f6y7a5w3.js} +2 -2
- package/bundle/{chunk-zeh481tm.js → chunk-fd9zrmhr.js} +2 -2
- package/bundle/chunk-ff9b4cg8.js +2 -0
- package/bundle/{chunk-bas6x25m.js → chunk-fffj9447.js} +2 -2
- package/bundle/{chunk-5y8efy5b.js → chunk-fk3praj7.js} +1 -1
- package/bundle/{chunk-ecwz9nhs.js → chunk-fk8cctjy.js} +2 -2
- package/bundle/{chunk-1y9t7nxn.js → chunk-fkat2pw6.js} +1 -1
- package/bundle/chunk-fpff6a4q.js +2 -0
- package/bundle/chunk-fvy5w4dh.js +7 -0
- package/bundle/{chunk-2gxjjqfx.js → chunk-fx7w497c.js} +1 -1
- package/bundle/{chunk-5rkmhzq0.js → chunk-fxb6vjcb.js} +2 -2
- package/bundle/{chunk-9xvctnjr.js → chunk-g4qwkcdv.js} +1 -1
- package/bundle/{chunk-2eardzxs.js → chunk-g6dgc5af.js} +1 -1
- package/bundle/{chunk-2mmspnr3.js → chunk-g7vahvkz.js} +1 -1
- package/bundle/chunk-g8wvr7a1.js +3 -0
- package/bundle/{chunk-21ejqv4v.js → chunk-gaxbbxk6.js} +1 -1
- package/bundle/chunk-gq361kdt.js +2 -0
- package/bundle/{chunk-n1chdwrs.js → chunk-gxa2r4zc.js} +1 -1
- package/bundle/{chunk-p54bzjtv.js → chunk-h56jxxvj.js} +1 -1
- package/bundle/{chunk-2z6fzwyc.js → chunk-hb4d06q0.js} +2 -2
- package/bundle/chunk-hbagpppv.js +2 -0
- package/bundle/chunk-hf473xav.js +2 -0
- package/bundle/{chunk-gff87y4n.js → chunk-hjratj6g.js} +1 -1
- package/bundle/{chunk-y2jmtfdh.js → chunk-hk8j5ht8.js} +2 -2
- package/bundle/{chunk-jr8qcf99.js → chunk-hkmb3zer.js} +2 -2
- package/bundle/chunk-hr88054m.js +2 -0
- package/bundle/{chunk-ep8zn49w.js → chunk-hybq019j.js} +2 -2
- package/bundle/{chunk-1xyn0sp2.js → chunk-hyckncza.js} +2 -2
- package/bundle/{chunk-wj6aq50n.js → chunk-hz1hd1bd.js} +1 -1
- package/bundle/{chunk-zp2ffbc2.js → chunk-j0ftbmex.js} +2 -2
- package/bundle/chunk-j3czd7v2.js +28 -0
- package/bundle/{chunk-0w0jfzb4.js → chunk-j7zs1yg2.js} +1 -1
- package/bundle/{chunk-xv8gnkh5.js → chunk-j87bvp1b.js} +1 -1
- package/bundle/chunk-j9m2d6t5.js +2 -0
- package/bundle/chunk-jd9edy2s.js +2 -0
- package/bundle/{chunk-4tn69nqs.js → chunk-jdkxeqw5.js} +1 -1
- package/bundle/chunk-jwtdbx31.js +2 -0
- package/bundle/chunk-jzcz92pq.js +8 -0
- package/bundle/{chunk-5h2hcp46.js → chunk-k7h6tfzj.js} +1 -1
- package/bundle/{chunk-dann9gfq.js → chunk-kbg3k1az.js} +1 -1
- package/bundle/{chunk-va4davgy.js → chunk-kbjwdv1x.js} +259 -253
- package/bundle/{chunk-j1veq3zr.js → chunk-kbyk7hyn.js} +2 -2
- package/bundle/{chunk-jr9xnvjq.js → chunk-kfk1zqc1.js} +1 -1
- package/bundle/{chunk-9jf67xb0.js → chunk-kkdgzeva.js} +2 -2
- package/bundle/{chunk-9rqrm9y8.js → chunk-kn318ev4.js} +1 -1
- package/bundle/{chunk-pv8jcpnf.js → chunk-kp84yba1.js} +1 -1
- package/bundle/{chunk-b8ag61vj.js → chunk-kpnfndkg.js} +1 -1
- package/bundle/chunk-krkxrej2.js +2 -0
- package/bundle/{chunk-ms1fd6h4.js → chunk-kvz0vzsn.js} +1 -1
- package/bundle/chunk-m26mcy8p.js +2 -0
- package/bundle/chunk-m62wgqp1.js +2 -0
- package/bundle/chunk-m7txgh5w.js +2 -0
- package/bundle/chunk-m84cn9c6.js +2 -0
- package/bundle/{chunk-kr0fsqas.js → chunk-md7vpe1e.js} +1 -1
- package/bundle/{chunk-yz7rqzby.js → chunk-mg239rc3.js} +3 -3
- package/bundle/chunk-mvc7pvtq.js +2 -0
- package/bundle/{chunk-tsn1jkr7.js → chunk-n07rsssz.js} +1 -1
- package/bundle/{chunk-8717htya.js → chunk-n10atvac.js} +1 -1
- package/bundle/chunk-nfp9xtca.js +3 -0
- package/bundle/{chunk-fdezde1z.js → chunk-ngz5xw45.js} +1 -1
- package/bundle/{chunk-7mhffm9f.js → chunk-njzpswgt.js} +183 -183
- package/bundle/{chunk-najzfhb2.js → chunk-nszqy06d.js} +1 -1
- package/bundle/{chunk-q3x4x2tq.js → chunk-nxjbbq5h.js} +1 -1
- package/bundle/{chunk-jmjg8d8a.js → chunk-p0k4sv89.js} +4 -4
- package/bundle/{chunk-bf146hz2.js → chunk-p31yg62z.js} +2 -2
- package/bundle/chunk-p5t9mq8r.js +2 -0
- package/bundle/chunk-pfbykat1.js +2 -0
- package/bundle/{chunk-bd21p9zz.js → chunk-pfn1db1m.js} +2 -2
- package/bundle/{chunk-1fnmkm0z.js → chunk-pjbbdm96.js} +2 -2
- package/bundle/{chunk-k9g77a02.js → chunk-pnj8s20t.js} +1 -1
- package/bundle/{chunk-a5zjrwqy.js → chunk-ppvmy940.js} +2 -2
- package/bundle/{chunk-r3yqe7x0.js → chunk-ptf09vmp.js} +1 -1
- package/bundle/{chunk-sjrmhd3e.js → chunk-q2exgz82.js} +1 -1
- package/bundle/{chunk-te1zfpzv.js → chunk-qan3kwbv.js} +1 -1
- package/bundle/{chunk-7tgm8wp5.js → chunk-qb5qemtp.js} +1 -1
- package/bundle/chunk-qd0nvn4z.js +2 -0
- package/bundle/chunk-qh99kv2j.js +2 -0
- package/bundle/{chunk-kc3hpmr2.js → chunk-qkwhgfjt.js} +2 -2
- package/bundle/{chunk-5kmfnkzv.js → chunk-qm9ezq93.js} +1 -1
- package/bundle/chunk-qmhcbdkg.js +8 -0
- package/bundle/{chunk-7a6p7dfx.js → chunk-qngs31yf.js} +1 -1
- package/bundle/{chunk-hbnr0j7h.js → chunk-qpv4438m.js} +2 -2
- package/bundle/{chunk-hv4nhx6q.js → chunk-qq71akpw.js} +2 -2
- package/bundle/chunk-qyrafh4m.js +2 -0
- package/bundle/{chunk-17ggas8k.js → chunk-r1yqmd4y.js} +1 -1
- package/bundle/chunk-rc37cw86.js +2 -0
- package/bundle/{chunk-xccs5c50.js → chunk-rf625fxx.js} +1 -1
- package/bundle/chunk-rmpty636.js +2 -0
- package/bundle/{chunk-9pe4agdz.js → chunk-rs0nx844.js} +2 -2
- package/bundle/{chunk-9vcw33dv.js → chunk-rvrjw0fy.js} +1 -1
- package/bundle/{chunk-jpygkh1c.js → chunk-rz54qjew.js} +1 -1
- package/bundle/{chunk-a9y27zd2.js → chunk-rze20q68.js} +1 -1
- package/bundle/{chunk-hg9nk090.js → chunk-s1h0k1yj.js} +1 -1
- package/bundle/{chunk-hh4c02fh.js → chunk-s2za1y84.js} +1 -1
- package/bundle/chunk-s3wjwxme.js +2 -0
- package/bundle/chunk-s4ncnbgd.js +2 -0
- package/bundle/{chunk-p4hpr8d7.js → chunk-s54c8fpf.js} +1 -1
- package/bundle/{chunk-0pbt75ev.js → chunk-s5krbdvd.js} +1 -1
- package/bundle/{chunk-wmw2gne9.js → chunk-s86fj82v.js} +2 -2
- package/bundle/{chunk-qywwj58s.js → chunk-sdsggxm4.js} +2 -2
- package/bundle/{chunk-r7xp0xcn.js → chunk-se195e52.js} +2 -2
- package/bundle/chunk-snz3w30x.js +2 -0
- package/bundle/chunk-srw748gr.js +2 -0
- package/bundle/{chunk-mj24ntn9.js → chunk-st74db4c.js} +1 -1
- package/bundle/{chunk-0rtshz2r.js → chunk-t1vtdgd6.js} +1 -1
- package/bundle/{chunk-6dxaty1v.js → chunk-t6xm49ea.js} +1 -1
- package/bundle/{chunk-f819a7ec.js → chunk-t7tstr83.js} +1 -1
- package/bundle/{chunk-v2kyarwz.js → chunk-tedrfa7d.js} +2 -2
- package/bundle/{chunk-zfnbk5gy.js → chunk-tfggzzqw.js} +1 -1
- package/bundle/chunk-tn167yyz.js +2 -0
- package/bundle/{chunk-d56zc21w.js → chunk-txty44v2.js} +1 -1
- package/bundle/{chunk-b6m4yyww.js → chunk-tyy4gx61.js} +1 -1
- package/bundle/chunk-v1xwe58d.js +2 -0
- package/bundle/{chunk-vvypb02q.js → chunk-vh05n2x3.js} +1 -1
- package/bundle/{chunk-agdfqncf.js → chunk-vpqd0t8a.js} +2 -2
- package/bundle/chunk-vrfegg5f.js +2 -0
- package/bundle/{chunk-tzc4jkzg.js → chunk-vthm5q05.js} +1 -1
- package/bundle/{chunk-6g3m7yxf.js → chunk-vw673y0t.js} +2 -2
- package/bundle/{chunk-3tdqsm5c.js → chunk-vx837ete.js} +1 -1
- package/bundle/{chunk-hjbks7r9.js → chunk-vy9xre57.js} +1 -1
- package/bundle/{chunk-x6z2b63w.js → chunk-vyjsng14.js} +1 -1
- package/bundle/{chunk-ftk58wxe.js → chunk-vztxv9dj.js} +1 -1
- package/bundle/{chunk-1p34bx7c.js → chunk-w01gjnty.js} +2 -2
- package/bundle/chunk-w12tky28.js +2 -0
- package/bundle/{chunk-t6w96xq2.js → chunk-w2gpgapp.js} +1 -1
- package/bundle/{chunk-gn7xgd4c.js → chunk-w3pzv615.js} +1 -1
- package/bundle/chunk-w4hbw37v.js +3 -0
- package/bundle/chunk-w9ct698t.js +2 -0
- package/bundle/{chunk-8ace31r2.js → chunk-wefjbwv6.js} +1 -1
- package/bundle/{chunk-sgtgvzv6.js → chunk-wg42cxrw.js} +1 -1
- package/bundle/{chunk-02txthqv.js → chunk-wg5dv21f.js} +2 -2
- package/bundle/chunk-wms4skr9.js +11 -0
- package/bundle/chunk-wr5hdsst.js +9 -0
- package/bundle/chunk-wxnqgh8t.js +2 -0
- package/bundle/chunk-wzmte7sy.js +3 -0
- package/bundle/chunk-x0h1jdxt.js +2 -0
- package/bundle/{chunk-ha1w0xzh.js → chunk-x36jhtex.js} +1 -1
- package/bundle/{chunk-yzdty5t9.js → chunk-x3931we7.js} +2 -2
- package/bundle/{chunk-v7r9np94.js → chunk-x3z8q0ep.js} +1 -1
- package/bundle/chunk-x6hsmnhz.js +2 -0
- package/bundle/{chunk-fkvccmgk.js → chunk-xak2r993.js} +2 -2
- package/bundle/{chunk-c31k8yh0.js → chunk-xc3fadkh.js} +1 -1
- package/bundle/{chunk-hh9a709t.js → chunk-xcs2jbz9.js} +1 -1
- package/bundle/{chunk-qw2hgs5b.js → chunk-xdv9xt0y.js} +2 -2
- package/bundle/{chunk-dgzyn27r.js → chunk-xdwej3ae.js} +1 -1
- package/bundle/chunk-xg9e0enb.js +2 -0
- package/bundle/{chunk-pfhp78cr.js → chunk-xqxpjbqk.js} +1 -1
- package/bundle/chunk-xtxxb25n.js +2 -0
- package/bundle/{chunk-8h9r6c8g.js → chunk-y2ch07yv.js} +2 -2
- package/bundle/chunk-y3s7sh1e.js +2 -0
- package/bundle/chunk-ydvheqw9.js +2 -0
- package/bundle/{chunk-0z3z0gk1.js → chunk-ygwe0vf1.js} +2 -2
- package/bundle/{chunk-58enbars.js → chunk-ykxde207.js} +2 -2
- package/bundle/{chunk-dkm7x8rj.js → chunk-ynfbz3sz.js} +2 -2
- package/bundle/{chunk-2wp1w8cy.js → chunk-yqtfvgrp.js} +1 -1
- package/bundle/{chunk-edvcz2gd.js → chunk-yt1yk4j1.js} +1 -1
- package/bundle/{chunk-yh174jhg.js → chunk-yvj021eg.js} +2 -2
- package/bundle/chunk-yxnq0d7k.js +2 -0
- package/bundle/{chunk-e346x00p.js → chunk-z2m09m4w.js} +1 -1
- package/bundle/{chunk-f3kjp838.js → chunk-z2q3mg73.js} +2 -2
- package/bundle/chunk-z2raegj9.js +2 -0
- package/bundle/{chunk-y1srca0c.js → chunk-z3hj5bfd.js} +2 -2
- package/bundle/chunk-z3pyhmg6.js +2 -0
- package/bundle/{chunk-3nhqd8wg.js → chunk-z4ae6jmb.js} +3 -3
- package/bundle/{chunk-7dckfame.js → chunk-z559gc3n.js} +1 -1
- package/bundle/chunk-z7pg6sw1.js +2 -0
- package/bundle/chunk-z84376c6.js +2 -0
- package/bundle/{chunk-ktmazmas.js → chunk-ze00x1xb.js} +2 -2
- package/bundle/{chunk-pb7rnkke.js → chunk-zjvzc0my.js} +1 -1
- package/bundle/chunk-zn8th65r.js +2 -0
- package/bundle/{chunk-sswbfqcq.js → chunk-zna6neq5.js} +1 -1
- package/bundle/chunk-ztv1brgn.js +2 -0
- package/bundle/{chunk-s9amvacw.js → chunk-zvsafnkp.js} +2 -2
- package/bundle/chunk-zyxvd9fj.js +2 -0
- package/bundle/index.js +16 -16
- package/bundle/parser.worker.js +2 -2
- package/bundle/worker.js +1 -1
- package/package.json +1 -1
- package/bundle/chunk-0bvde0cx.js +0 -2
- package/bundle/chunk-0kbxnazj.js +0 -2
- package/bundle/chunk-19z5q33z.js +0 -2
- package/bundle/chunk-1a0wnwna.js +0 -2
- package/bundle/chunk-1ddm2wxv.js +0 -2
- package/bundle/chunk-1fk4vsmc.js +0 -2
- package/bundle/chunk-1j2f9nd5.js +0 -2
- package/bundle/chunk-27s736an.js +0 -2
- package/bundle/chunk-2j17xrzj.js +0 -2
- package/bundle/chunk-2zca3nak.js +0 -2
- package/bundle/chunk-2zcvcfq4.js +0 -2
- package/bundle/chunk-38hwkfj5.js +0 -2
- package/bundle/chunk-3afqxvsn.js +0 -2
- package/bundle/chunk-3avc1ppg.js +0 -7
- package/bundle/chunk-3v4vtah1.js +0 -2
- package/bundle/chunk-3ypk0j2f.js +0 -2
- package/bundle/chunk-3z1y040p.js +0 -3
- package/bundle/chunk-4aykrj51.js +0 -9
- package/bundle/chunk-4dtbmqmq.js +0 -2
- package/bundle/chunk-4zjb6rps.js +0 -2
- package/bundle/chunk-5hkcjgwh.js +0 -2
- package/bundle/chunk-5snrz263.js +0 -2
- package/bundle/chunk-653c0mxr.js +0 -11
- package/bundle/chunk-6av7hrrk.js +0 -7
- package/bundle/chunk-6bswn7w5.js +0 -2
- package/bundle/chunk-6epghftw.js +0 -2
- package/bundle/chunk-6jjhxh8p.js +0 -2
- package/bundle/chunk-6ws7xyc5.js +0 -2
- package/bundle/chunk-7g28zhar.js +0 -2
- package/bundle/chunk-7v02b2ms.js +0 -2
- package/bundle/chunk-7vmp2034.js +0 -2
- package/bundle/chunk-7wxrypkr.js +0 -2
- package/bundle/chunk-8kk9gvdy.js +0 -2
- package/bundle/chunk-8ygpp4y3.js +0 -2
- package/bundle/chunk-95q60g1p.js +0 -2
- package/bundle/chunk-9mjbenja.js +0 -2
- package/bundle/chunk-9vn1gy8h.js +0 -2
- package/bundle/chunk-ajp3f08k.js +0 -2
- package/bundle/chunk-aptkpdkc.js +0 -2
- package/bundle/chunk-bky5a42k.js +0 -3
- package/bundle/chunk-bry94ar5.js +0 -2
- package/bundle/chunk-btzyvqkf.js +0 -2
- package/bundle/chunk-c94pjdfh.js +0 -2
- package/bundle/chunk-cct9ds5c.js +0 -2
- package/bundle/chunk-czn535v0.js +0 -2
- package/bundle/chunk-d7wd5hz1.js +0 -2
- package/bundle/chunk-d86cmjrp.js +0 -2
- package/bundle/chunk-dnq65xvn.js +0 -2
- package/bundle/chunk-dpqv8rtn.js +0 -2
- package/bundle/chunk-e9mh7s3z.js +0 -2
- package/bundle/chunk-ek2y5f6g.js +0 -2
- package/bundle/chunk-epdsay73.js +0 -2
- package/bundle/chunk-f89gntcy.js +0 -3
- package/bundle/chunk-ffnsn7tv.js +0 -2
- package/bundle/chunk-fkezc7ew.js +0 -2
- package/bundle/chunk-fsxddgj0.js +0 -2
- package/bundle/chunk-gbcsfg6v.js +0 -2
- package/bundle/chunk-gfmz85hp.js +0 -2
- package/bundle/chunk-gk63k4t6.js +0 -2
- package/bundle/chunk-j0vf8s12.js +0 -2
- package/bundle/chunk-j1bxt69x.js +0 -2
- package/bundle/chunk-jcem8s30.js +0 -2
- package/bundle/chunk-jjwjb9w0.js +0 -3
- package/bundle/chunk-jpham2a3.js +0 -2
- package/bundle/chunk-jzkymnr5.js +0 -2
- package/bundle/chunk-k0qtwnhb.js +0 -2
- package/bundle/chunk-k2rsky7z.js +0 -2
- package/bundle/chunk-kcetcysa.js +0 -2
- package/bundle/chunk-kjfc5v3s.js +0 -2
- package/bundle/chunk-kkvb2c2z.js +0 -8
- package/bundle/chunk-km2ayfyf.js +0 -2
- package/bundle/chunk-knrh89eb.js +0 -2
- package/bundle/chunk-ksqfjawv.js +0 -2
- package/bundle/chunk-mjhb1q0n.js +0 -3
- package/bundle/chunk-mxcger73.js +0 -2
- package/bundle/chunk-nazkrkeb.js +0 -2
- package/bundle/chunk-nk01s49e.js +0 -2
- package/bundle/chunk-ns8b7rx1.js +0 -2
- package/bundle/chunk-ny6vpkx2.js +0 -2
- package/bundle/chunk-q0dd3ak6.js +0 -3
- package/bundle/chunk-q2s057bm.js +0 -2
- package/bundle/chunk-q5cqg2c0.js +0 -28
- package/bundle/chunk-qk2wnp2x.js +0 -2
- package/bundle/chunk-r012q335.js +0 -3
- package/bundle/chunk-rbdjbgkb.js +0 -2
- package/bundle/chunk-rxjprhgh.js +0 -2
- package/bundle/chunk-s3w9bmze.js +0 -2
- package/bundle/chunk-s3zste1a.js +0 -2
- package/bundle/chunk-sbt7qmwm.js +0 -3
- package/bundle/chunk-sf6h44pb.js +0 -2
- package/bundle/chunk-sgvzxs7m.js +0 -2
- package/bundle/chunk-sp9bndyh.js +0 -2
- package/bundle/chunk-vavrczqm.js +0 -3
- package/bundle/chunk-vg4styg5.js +0 -2
- package/bundle/chunk-vh09hhcs.js +0 -2
- package/bundle/chunk-vhktpm0n.js +0 -2
- package/bundle/chunk-vzjcmwry.js +0 -14
- package/bundle/chunk-wtp0yvqw.js +0 -2
- package/bundle/chunk-xmzs7q66.js +0 -2
- package/bundle/chunk-xv80476w.js +0 -2
- package/bundle/chunk-yjvr0et1.js +0 -2
- package/bundle/chunk-zk8n8hnh.js +0 -3
- package/bundle/chunk-zx3kcfkj.js +0 -2
package/bundle/chunk-vzjcmwry.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$f as Ai,ag as k2,bg as a2,cg as T2,dg as M2,eg as p2,fg as u2,gg as d2,hg as t2,ig as e2,jg as h2,mg as f2}from"./chunk-6j0365q3.js";import{ng as Nr,og as Z2}from"./chunk-7y3y3j51.js";import{xg as Q2}from"./chunk-4aykrj51.js";import{Fg as Sc}from"./chunk-sbt7qmwm.js";import{Hg as Ny}from"./chunk-ktmazmas.js";import{Ig as fj}from"./chunk-qywwj58s.js";import{$g as mm,Jg as Tl,Kg as zl,Lg as un,Mg as _i,Tg as Xr,Ug as Ml,Vg as Km,Xg as Hm,Yg as kn,Zg as dn,_g as nm,ah as qr,bh as ec,ch as y2,dh as Ll,fh as tc,gh as ql,hh as Fl,ih as ji,jh as Ol,kh as gl,lh as e0,mh as Rm,nh as S2,oh as Dr,ph as Ii,qh as Wr,sh as b}from"./chunk-va4davgy.js";import{$j as br,Bj as f0,Cj as qi,Dj as C2,Hj as sj,Hk as Lr,Ij as tr,Ik as _n,Jj as Rr,Jk as cA,Kj as QI,Lj as yr,Mj as er,Nj as vn,Oj as pn,Ok as c2,Rj as Ym,Tk as nr,Uk as Cr,Vk as vr,Xk as wI,Yk as j0,Zj as A2,_j as lr,cl as V,dl as mr,wj as wr,wk as Ci,xj as ii,xk as Qr,yj as H2,zj as R2}from"./chunk-7mhffm9f.js";import{fl as pl,pl as p1}from"./chunk-r012q335.js";import{Cl as s2,Dl as e,Fl as Wn,Hl as l0,Ll as Gr,Nl as F,ql as Or,ul as tj,vl as ir,wl as Kn,xl as Hn}from"./chunk-0z3z0gk1.js";import{Zl as jn}from"./chunk-g7vkkmsk.js";import{En as c0,bn as Ln,dn as dj,gn as d,in as im,jn as L2,kn as q2,on as _2,pn as rm}from"./chunk-m8djypsy.js";import{Ap as q}from"./chunk-3tdqsm5c.js";import{Dr as t1,Er as e1,Fr as Pi}from"./chunk-tk3bve0x.js";import{Or as s1,Pr as f1}from"./chunk-0w4v0fbs.js";import{As as o1,Bs as O1,Cs as L1,Ds as LI,Es as Im,Vr as U1,Yr as Xi,is as h0,js as Ur,ks as C1,ls as B0,ms as W1,ns as X1,os as K1,ps as H1,qs as zr,rs as Ql,ss as x0,ts as R1,us as Z1,vs as Y1,ws as V1,xs as k0,ys as J1,zs as b1}from"./chunk-wf09j72q.js";import{Qs as Qi}from"./chunk-f3kjp838.js";import{Ts as rA,pt as Yn,qt as k,zt as g}from"./chunk-zk8n8hnh.js";import{Dt as m0,Ot as kl,Pt as mA,Tt as Xn}from"./chunk-1jh5p5qw.js";import{Vt as I}from"./chunk-f89gntcy.js";import{cu as a1}from"./chunk-bky5a42k.js";import{Lz as In,kA as m1,lA as c1}from"./chunk-v2kyarwz.js";import{BF as gI,CL as XI,DG as Mn,DI as Q1,DO as P1,EI as S0,FF as Y0,GI as dI,HA as An,HG as S1,HI as A0,HN as gr,II as tI,JA as Xl,JG as M0,JI as Al,JN as cl,KA as gn,KI as Sl,KN as H0,LC as F1,LF as T,LI as eI,LL as Dm,MI as bI,NC as Tn,NG as J0,NI as WI,OA as BI,OI as bc,ON as _,PI as wl,QA as UI,QI as sI,QL as sc,TG as hn,TL as jm,VC as oI,WC as OI,YC as K0,YG as v1,YK as T0,ZK as El,_H as Ul,_L as Zi,bL as fI,cD as pI,cM as Wi,eH as Gl,eM as _r,fB as zn,gC as Dl,iC as xI,jD as $r,jG as V0,jH as $m,jL as r1,kD as Z0,kH as w1,lF as Sm,lH as Pl,lL as n1,mD as Br,mI as C,mL as i1,nD as Sn,oC as kI,oD as o0,oH as zI,pC as aI,pG as t,qD as Pm,qI as $1,qL as W0,rC as Qm,rD as Il,sD as vl,sI as G1,sL as X0,tD as Fr,tI as Li,uD as Am,uI as Cl,uL as Um,vD as uI,wD as Zn,wG as vm,wL as Nl,xC as I1,xG as wm,xI as E1,yI as N1,yL as ml,zG as A1,zJ as D1}from"./chunk-dkm7x8rj.js";import{AP as Er,CP as bn,yP as cv,zP as rr}from"./chunk-hh4c02fh.js";var am=rr((hy)=>{Object.defineProperty(hy,"__esModule",{value:!0});hy.default=kA;var Ty=/[A-Z]/g;function My(r){return r.toLowerCase()}function kA(r,n){let i=r.replace(Ty,My),m=n.replace(Ty,My);return i===m}});var Rc=rr((By)=>{Object.defineProperty(By,"__esModule",{value:!0});By.DnsTxt=void 0;class Hc{constructor(r={}){this.binary=r?r.binary:!1}encode(r={}){return Object.entries(r).map(([n,i])=>{let m=`${n}=${i}`;return Buffer.from(m)})}decode(r){var n={};try{let m=r.toString().split(/=(.+)/),c=m[0],l=m[1];n[c]=l}catch(i){}return n}decodeAll(r){return r.filter((n)=>n.length>1).map((n)=>this.decode(n)).reduce((n,i)=>{var m=n;let[c]=Object.keys(i),[l]=Object.values(i);return m[c]=l,m},{})}}By.DnsTxt=Hc;By.default=Hc});var Zc=rr((ay)=>{Object.defineProperty(ay,"__esModule",{value:!0});ay.toType=ay.toString=void 0;var ky=(r)=>{return"_"+r},uA=(r)=>{return["name","protocol","subtype"].includes(r)},dA=(r)=>{let n={name:r.name,protocol:r.protocol,subtype:r.subtype};return Object.entries(n).filter(([m,c])=>uA(m)&&c!==void 0).reduce((m,[c,l])=>{switch(typeof l){case"object":l.map((y)=>m.push(ky(y)));break;default:m.push(ky(l));break}return m},[]).join(".")};ay.toString=dA;var tA=(r)=>{let n=r.split("."),i;for(let m in n){if(n[m][0]!=="_")continue;n[m]=n[m].slice(1)}if(n.includes("sub"))i=n.shift(),n.shift();return{name:n.shift(),protocol:n.shift()||null,subtype:i}};ay.toType=tA});var Vc=rr((en)=>{var dy=en&&en.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(en,"__esModule",{value:!0});en.Service=void 0;var uy=dy(bn("os")),bA=dy(Rc()),sA=bn("events"),fA=Zc(),pm=".local";class Yc extends sA.EventEmitter{constructor(r){super();if(this.probe=!0,this.published=!1,this.activated=!1,this.destroyed=!1,this.txtService=new bA.default,!r.name)throw Error("ServiceConfig requires `name` property to be set");if(!r.type)throw Error("ServiceConfig requires `type` property to be set");if(!r.port)throw Error("ServiceConfig requires `port` property to be set");this.name=r.name.split(".").join("-"),this.protocol=r.protocol||"tcp",this.type=(0,fA.toString)({name:r.type,protocol:this.protocol}),this.port=r.port,this.host=r.host||uy.default.hostname(),this.fqdn=`${this.name}.${this.type}${pm}`,this.txt=r.txt,this.subtypes=r.subtypes,this.disableIPv6=!!r.disableIPv6}records(){var r=[this.RecordPTR(this),this.RecordSRV(this),this.RecordTXT(this)];for(let i of this.subtypes||[])r.push(this.RecordSubtypePTR(this,i));let n=Object.values(uy.default.networkInterfaces());for(let i of n){let m=i;for(let c of m){if(c.internal||c.mac==="00:00:00:00:00:00")continue;switch(c.family){case"IPv4":r.push(this.RecordA(this,c.address));break;case"IPv6":if(this.disableIPv6)break;r.push(this.RecordAAAA(this,c.address));break}}}return r}RecordPTR(r){return{name:`${r.type}${pm}`,type:"PTR",ttl:28800,data:r.fqdn}}RecordSubtypePTR(r,n){return{name:`_${n}._sub.${r.type}${pm}`,type:"PTR",ttl:28800,data:`${r.name}.${r.type}${pm}`}}RecordSRV(r){return{name:r.fqdn,type:"SRV",ttl:120,data:{port:r.port,target:r.host}}}RecordTXT(r){return{name:r.fqdn,type:"TXT",ttl:4500,data:this.txtService.encode(r.txt)}}RecordA(r,n){return{name:r.host,type:"A",ttl:120,data:n}}RecordAAAA(r,n){return{name:r.host,type:"AAAA",ttl:120,data:n}}}en.Service=Yc;en.default=Yc});var ey=rr((sn)=>{var ty=sn&&sn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(sn,"__esModule",{value:!0});sn.Registry=void 0;var rS=ty(am()),Jc=ty(Vc()),nS=3600000,iS=3,mS=function(){};class oc{constructor(r){this.services=[],this.server=r}publish(r){function n(c,l,y){if(c.activated)return;if(c.activated=!0,l.services.push(c),!(c instanceof Jc.default))return;if(y===null||y===void 0?void 0:y.probe)l.probe(l.server.mdns,c,(j)=>{if(j){if(c.stop!==void 0)c.stop();console.log(Error("Service name is already in use on the network"));return}l.announce(l.server,c)});else l.announce(l.server,c)}function i(c,l,y){if(!y)y=mS;if(!c.activated)return process.nextTick(y);if(!(c instanceof Jc.default))return process.nextTick(y);l.teardown(l.server,c,y);let j=l.services.indexOf(c);if(j!==-1)l.services.splice(j,1)}let m=new Jc.default(r);return m.start=n.bind(null,m,this),m.stop=i.bind(null,m,this),m.start({probe:r.probe!==!1}),m}unpublishAll(r){this.teardown(this.server,this.services,r),this.services=[]}destroy(){this.services.map((r)=>r.destroyed=!0)}probe(r,n,i){var m=!1,c=0,l;let y=()=>{if(!n.activated||n.destroyed)return;r.query(n.fqdn,"ANY",function(){m=!0,l=setTimeout(++c<3?y:S,250),l.unref()})},j=(v)=>{if(!m)return;if(v.answers.some(A)||v.additionals.some(A))S(!0)},A=(v)=>{return(0,rS.default)(v.name,n.fqdn)},S=(v)=>{r.removeListener("response",j),clearTimeout(l),i(!!v)};r.on("response",j),setTimeout(y,Math.random()*250)}announce(r,n){var i=1000,m=n.records();r.register(m);let c=()=>{if(!n.activated||n.destroyed)return;r.mdns.respond(m,function(){if(!n.published)n.activated=!0,n.published=!0,n.emit("up");if(i=i*iS,i<nS&&!n.destroyed)setTimeout(c,i).unref()})};c()}teardown(r,n,i){if(!Array.isArray(n))n=[n];n=n.filter((c)=>c.activated);var m=n.flatMap(function(c){c.activated=!1;var l=c.records();return l.forEach((y)=>{y.ttl=0}),l});if(m.length===0)return i&&process.nextTick(i);r.unregister(m),r.mdns.respond(m,function(){if(n.forEach(function(c){c.published=!1}),typeof i==="function")i.apply(null,arguments)})}}sn.Registry=oc;sn.default=oc});var by=rr((cS)=>{cS.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};cS.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}if(r.toUpperCase().startsWith("UNKNOWN_"))return parseInt(r.slice(8));return 0}});var sy=rr((jS)=>{jS.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};jS.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var fy=rr((SS)=>{SS.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};SS.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var rj=rr(($S)=>{$S.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};$S.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var nj=rr((NS)=>{NS.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}if(r<0)return null;return`OPTION_${r}`};NS.toCode=function(r){if(typeof r==="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let n=r.match(/_(\d+)$/);if(n)return parseInt(n[1],10);return-1}});var cj=rr((mj,Oc)=>{var ij=function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.decode=w,r.encode=v,r.familyOf=S,r.name=void 0,r.sizeOf=A,r.v6=r.v4=void 0;let n=/^(\d{1,3}\.){3,3}\d{1,3}$/,i=4,m=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,c=16,l={name:"v4",size:i,isFormat:(E)=>n.test(E),encode(E,N,Q){Q=~~Q,N=N||new Uint8Array(Q+i);let W=E.length,R=0;for(let X=0;X<W;){let K=E.charCodeAt(X++);if(K===46)N[Q++]=R,R=0;else R=R*10+(K-48)}return N[Q]=R,N},decode(E,N){return N=~~N,`${E[N++]}.${E[N++]}.${E[N++]}.${E[N]}`}};r.v4=l;let y={name:"v6",size:c,isFormat:(E)=>E.length>0&&m.test(E),encode(E,N,Q){Q=~~Q;let W=Q+c,R=-1,X=0,K=0,J=!0,L=!1;N=N||new Uint8Array(Q+c);for(let z=0;z<E.length;z++){let O=E.charCodeAt(z);if(O===58){if(J){if(R!==-1){if(Q<W)N[Q]=0;if(Q<W-1)N[Q+1]=0;Q+=2}else if(Q<W)R=Q}else{if(L===!0){if(Q<W)N[Q]=K;Q++}else{if(Q<W)N[Q]=X>>8;if(Q<W-1)N[Q+1]=X&255;Q+=2}X=0,K=0}J=!0,L=!1}else if(O===46){if(Q<W)N[Q]=K;Q++,K=0,X=0,J=!1,L=!0}else{if(J=!1,O>=97)O-=87;else if(O>=65)O-=55;else O-=48,K=K*10+O;X=(X<<4)+O}}if(J===!1)if(L===!0){if(Q<W)N[Q]=K;Q++}else{if(Q<W)N[Q]=X>>8;if(Q<W-1)N[Q+1]=X&255;Q+=2}else if(R===0){if(Q<W)N[Q]=0;if(Q<W-1)N[Q+1]=0;Q+=2}else if(R!==-1){Q+=2;for(let z=Math.min(Q-1,W-1);z>=R+2;z--)N[z]=N[z-2];N[R]=0,N[R+1]=0,R=Q}if(R!==Q&&R!==-1){if(Q>W-2)Q=W-2;while(W>R)N[--W]=Q<W&&Q>R?N[--Q]:0}else while(Q<W)N[Q++]=0;return N},decode(E,N){N=~~N;let Q="";for(let W=0;W<c;W+=2){if(W!==0)Q+=":";Q+=(E[N+W]<<8|E[N+W+1]).toString(16)}return Q.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=y;let j="ip";r.name=j;function A(E){if(l.isFormat(E))return l.size;if(y.isFormat(E))return y.size;throw Error(`Invalid ip address: ${E}`)}function S(E){return A(E)===l.size?1:2}function v(E,N,Q){Q=~~Q;let W=A(E);if(typeof N==="function")N=N(Q+W);if(W===l.size)return l.encode(E,N,Q);return y.encode(E,N,Q)}function w(E,N,Q){if(N=~~N,Q=Q||E.length-N,Q===l.size)return l.decode(E,N,Q);if(Q===y.size)return y.decode(E,N,Q);throw Error(`Invalid buffer size needs to be ${l.size} for v4 or ${y.size} for v6.`)}return"default"in r?r.default:r}({});if(typeof define==="function"&&define.amd)define([],function(){return ij});else if(typeof Oc==="object"&&typeof mj==="object")Oc.exports=ij});var lj=rr((XS)=>{var Y=bn("buffer").Buffer,Cn=by(),PS=sy(),US=fy(),dm=rj(),_c=nj(),fn=cj(),H=XS.name={};H.encode=function(r,n,i,{mail:m=!1}={}){if(!n)n=Y.alloc(H.encodingLength(r));if(!i)i=0;let c=i,l=r.replace(/^\.|\.$/gm,"");if(l.length){let y=[];if(m){let j="";l.split(".").forEach((A)=>{if(A.endsWith("\\"))j+=(j.length?".":"")+A.slice(0,-1);else if(y.length===0&&j.length)y.push(j+"."+A);else y.push(A)})}else y=l.split(".");for(let j=0;j<y.length;j++){let A=n.write(y[j],i+1);n[i]=A,i+=A+1}}return n[i++]=0,H.encode.bytes=i-c,n};H.encode.bytes=0;H.decode=function(r,n,{mail:i=!1}={}){if(!n)n=0;let m=[],c=n,l=0,y=0,j=!1;while(!0){if(n>=r.length)throw Error("Cannot decode name (buffer overflow)");let A=r[n++];if(y+=j?0:1,A===0)break;else if((A&192)===0){if(n+A>r.length)throw Error("Cannot decode name (buffer overflow)");if(l+=A+1,l>254)throw Error("Cannot decode name (name too long)");let S=r.toString("utf-8",n,n+A);if(i)S=S.replace(/\./g,"\\.");m.push(S),n+=A,y+=j?0:A}else if((A&192)===192){if(n+1>r.length)throw Error("Cannot decode name (buffer overflow)");let S=r.readUInt16BE(n-1)-49152;if(S>=c)throw Error("Cannot decode name (bad pointer)");n=S,c=S,y+=j?0:1,j=!0}else throw Error("Cannot decode name (bad label)")}return H.decode.bytes=y,m.length===0?".":m.join(".")};H.decode.bytes=0;H.encodingLength=function(r){if(r==="."||r==="..")return 1;return Y.byteLength(r.replace(/^\.|\.$/gm,""))+2};var o={};o.encode=function(r,n,i){if(!n)n=Y.alloc(o.encodingLength(r));if(!i)i=0;let m=n.write(r,i+1);return n[i]=m,o.encode.bytes=m+1,n};o.encode.bytes=0;o.decode=function(r,n){if(!n)n=0;let i=r[n],m=r.toString("utf-8",n+1,n+1+i);return o.decode.bytes=i+1,m};o.decode.bytes=0;o.encodingLength=function(r){return Y.byteLength(r)+1};var ur={};ur.encode=function(r,n,i){if(!n)n=ur.encodingLength(r);if(!i)i=0;let m=(r.flags||0)&32767,c=r.type==="response"?32768:0;return n.writeUInt16BE(r.id||0,i),n.writeUInt16BE(m|c,i+2),n.writeUInt16BE(r.questions.length,i+4),n.writeUInt16BE(r.answers.length,i+6),n.writeUInt16BE(r.authorities.length,i+8),n.writeUInt16BE(r.additionals.length,i+10),n};ur.encode.bytes=12;ur.decode=function(r,n){if(!n)n=0;if(r.length<12)throw Error("Header must be 12 bytes");let i=r.readUInt16BE(n+2);return{id:r.readUInt16BE(n),type:i&32768?"response":"query",flags:i&32767,flag_qr:(i>>15&1)===1,opcode:US.toString(i>>11&15),flag_aa:(i>>10&1)===1,flag_tc:(i>>9&1)===1,flag_rd:(i>>8&1)===1,flag_ra:(i>>7&1)===1,flag_z:(i>>6&1)===1,flag_ad:(i>>5&1)===1,flag_cd:(i>>4&1)===1,rcode:PS.toString(i&15),questions:Array(r.readUInt16BE(n+4)),answers:Array(r.readUInt16BE(n+6)),authorities:Array(r.readUInt16BE(n+8)),additionals:Array(r.readUInt16BE(n+10))}};ur.decode.bytes=12;ur.encodingLength=function(){return 12};var wn=XS.unknown={};wn.encode=function(r,n,i){if(!n)n=Y.alloc(wn.encodingLength(r));if(!i)i=0;return n.writeUInt16BE(r.length,i),r.copy(n,i+2),wn.encode.bytes=r.length+2,n};wn.encode.bytes=0;wn.decode=function(r,n){if(!n)n=0;let i=r.readUInt16BE(n),m=r.slice(n+2,n+2+i);return wn.decode.bytes=i+2,m};wn.decode.bytes=0;wn.encodingLength=function(r){return r.length+2};var $n=XS.ns={};$n.encode=function(r,n,i){if(!n)n=Y.alloc($n.encodingLength(r));if(!i)i=0;return H.encode(r,n,i+2),n.writeUInt16BE(H.encode.bytes,i),$n.encode.bytes=H.encode.bytes+2,n};$n.encode.bytes=0;$n.decode=function(r,n){if(!n)n=0;let i=r.readUInt16BE(n),m=H.decode(r,n+2);return $n.decode.bytes=i+2,m};$n.decode.bytes=0;$n.encodingLength=function(r){return H.encodingLength(r)+2};var Gn=XS.soa={};Gn.encode=function(r,n,i){if(!n)n=Y.alloc(Gn.encodingLength(r));if(!i)i=0;let m=i;return i+=2,H.encode(r.mname,n,i),i+=H.encode.bytes,H.encode(r.rname,n,i,{mail:!0}),i+=H.encode.bytes,n.writeUInt32BE(r.serial||0,i),i+=4,n.writeUInt32BE(r.refresh||0,i),i+=4,n.writeUInt32BE(r.retry||0,i),i+=4,n.writeUInt32BE(r.expire||0,i),i+=4,n.writeUInt32BE(r.minimum||0,i),i+=4,n.writeUInt16BE(i-m-2,m),Gn.encode.bytes=i-m,n};Gn.encode.bytes=0;Gn.decode=function(r,n){if(!n)n=0;let i=n,m={};return n+=2,m.mname=H.decode(r,n),n+=H.decode.bytes,m.rname=H.decode(r,n,{mail:!0}),n+=H.decode.bytes,m.serial=r.readUInt32BE(n),n+=4,m.refresh=r.readUInt32BE(n),n+=4,m.retry=r.readUInt32BE(n),n+=4,m.expire=r.readUInt32BE(n),n+=4,m.minimum=r.readUInt32BE(n),n+=4,Gn.decode.bytes=n-i,m};Gn.decode.bytes=0;Gn.encodingLength=function(r){return 22+H.encodingLength(r.mname)+H.encodingLength(r.rname)};var En=XS.txt={};En.encode=function(r,n,i){if(!Array.isArray(r))r=[r];for(let c=0;c<r.length;c++){if(typeof r[c]==="string")r[c]=Y.from(r[c]);if(!Y.isBuffer(r[c]))throw Error("Must be a Buffer")}if(!n)n=Y.alloc(En.encodingLength(r));if(!i)i=0;let m=i;return i+=2,r.forEach(function(c){n[i++]=c.length,c.copy(n,i,0,c.length),i+=c.length}),n.writeUInt16BE(i-m-2,m),En.encode.bytes=i-m,n};En.encode.bytes=0;En.decode=function(r,n){if(!n)n=0;let i=n,m=r.readUInt16BE(n);n+=2;let c=[];while(m>0){let l=r[n++];if(--m,m<l)throw Error("Buffer overflow");c.push(r.slice(n,n+l)),n+=l,m-=l}return En.decode.bytes=n-i,c};En.decode.bytes=0;En.encodingLength=function(r){if(!Array.isArray(r))r=[r];let n=2;return r.forEach(function(i){if(typeof i==="string")n+=Y.byteLength(i)+1;else n+=i.length+1}),n};var Nn=XS.null={};Nn.encode=function(r,n,i){if(!n)n=Y.alloc(Nn.encodingLength(r));if(!i)i=0;if(typeof r==="string")r=Y.from(r);if(!r)r=Y.alloc(0);let m=i;i+=2;let c=r.length;return r.copy(n,i,0,c),i+=c,n.writeUInt16BE(i-m-2,m),Nn.encode.bytes=i-m,n};Nn.encode.bytes=0;Nn.decode=function(r,n){if(!n)n=0;let i=n,m=r.readUInt16BE(n);n+=2;let c=r.slice(n,n+m);return n+=m,Nn.decode.bytes=n-i,c};Nn.decode.bytes=0;Nn.encodingLength=function(r){if(!r)return 2;return(Y.isBuffer(r)?r.length:Y.byteLength(r))+2};var Qn=XS.hinfo={};Qn.encode=function(r,n,i){if(!n)n=Y.alloc(Qn.encodingLength(r));if(!i)i=0;let m=i;return i+=2,o.encode(r.cpu,n,i),i+=o.encode.bytes,o.encode(r.os,n,i),i+=o.encode.bytes,n.writeUInt16BE(i-m-2,m),Qn.encode.bytes=i-m,n};Qn.encode.bytes=0;Qn.decode=function(r,n){if(!n)n=0;let i=n,m={};return n+=2,m.cpu=o.decode(r,n),n+=o.decode.bytes,m.os=o.decode(r,n),n+=o.decode.bytes,Qn.decode.bytes=n-i,m};Qn.decode.bytes=0;Qn.encodingLength=function(r){return o.encodingLength(r.cpu)+o.encodingLength(r.os)+2};var ar=XS.ptr={},CS=XS.cname=ar,WS=XS.dname=ar;ar.encode=function(r,n,i){if(!n)n=Y.alloc(ar.encodingLength(r));if(!i)i=0;return H.encode(r,n,i+2),n.writeUInt16BE(H.encode.bytes,i),ar.encode.bytes=H.encode.bytes+2,n};ar.encode.bytes=0;ar.decode=function(r,n){if(!n)n=0;let i=H.decode(r,n+2);return ar.decode.bytes=H.decode.bytes+2,i};ar.decode.bytes=0;ar.encodingLength=function(r){return H.encodingLength(r)+2};var Dn=XS.srv={};Dn.encode=function(r,n,i){if(!n)n=Y.alloc(Dn.encodingLength(r));if(!i)i=0;n.writeUInt16BE(r.priority||0,i+2),n.writeUInt16BE(r.weight||0,i+4),n.writeUInt16BE(r.port||0,i+6),H.encode(r.target,n,i+8);let m=H.encode.bytes+6;return n.writeUInt16BE(m,i),Dn.encode.bytes=m+2,n};Dn.encode.bytes=0;Dn.decode=function(r,n){if(!n)n=0;let i=r.readUInt16BE(n),m={};return m.priority=r.readUInt16BE(n+2),m.weight=r.readUInt16BE(n+4),m.port=r.readUInt16BE(n+6),m.target=H.decode(r,n+8),Dn.decode.bytes=i+2,m};Dn.decode.bytes=0;Dn.encodingLength=function(r){return 8+H.encodingLength(r.target)};var Vr=XS.caa={};Vr.ISSUER_CRITICAL=128;Vr.encode=function(r,n,i){let m=Vr.encodingLength(r);if(!n)n=Y.alloc(Vr.encodingLength(r));if(!i)i=0;if(r.issuerCritical)r.flags=Vr.ISSUER_CRITICAL;return n.writeUInt16BE(m-2,i),i+=2,n.writeUInt8(r.flags||0,i),i+=1,o.encode(r.tag,n,i),i+=o.encode.bytes,n.write(r.value,i),i+=Y.byteLength(r.value),Vr.encode.bytes=m,n};Vr.encode.bytes=0;Vr.decode=function(r,n){if(!n)n=0;let i=r.readUInt16BE(n);n+=2;let m=n,c={};return c.flags=r.readUInt8(n),n+=1,c.tag=o.decode(r,n),n+=o.decode.bytes,c.value=r.toString("utf-8",n,m+i),c.issuerCritical=!!(c.flags&Vr.ISSUER_CRITICAL),Vr.decode.bytes=i+2,c};Vr.decode.bytes=0;Vr.encodingLength=function(r){return o.encodingLength(r.tag)+o.encodingLength(r.value)+2};var on=XS.mx={};on.encode=function(r,n,i){if(!n)n=Y.alloc(on.encodingLength(r));if(!i)i=0;let m=i;return i+=2,n.writeUInt16BE(r.preference||0,i),i+=2,H.encode(r.exchange,n,i),i+=H.encode.bytes,n.writeUInt16BE(i-m-2,m),on.encode.bytes=i-m,n};on.encode.bytes=0;on.decode=function(r,n){if(!n)n=0;let i=n,m={};return n+=2,m.preference=r.readUInt16BE(n),n+=2,m.exchange=H.decode(r,n),n+=H.decode.bytes,on.decode.bytes=n-i,m};on.encodingLength=function(r){return 4+H.encodingLength(r.exchange)};var Pn=XS.a={};Pn.encode=function(r,n,i){if(!n)n=Y.alloc(Pn.encodingLength(r));if(!i)i=0;return n.writeUInt16BE(4,i),i+=2,fn.v4.encode(r,n,i),Pn.encode.bytes=6,n};Pn.encode.bytes=0;Pn.decode=function(r,n){if(!n)n=0;n+=2;let i=fn.v4.decode(r,n);return Pn.decode.bytes=6,i};Pn.decode.bytes=0;Pn.encodingLength=function(){return 6};var Un=XS.aaaa={};Un.encode=function(r,n,i){if(!n)n=Y.alloc(Un.encodingLength(r));if(!i)i=0;return n.writeUInt16BE(16,i),i+=2,fn.v6.encode(r,n,i),Un.encode.bytes=18,n};Un.encode.bytes=0;Un.decode=function(r,n){if(!n)n=0;n+=2;let i=fn.v6.decode(r,n);return Un.decode.bytes=18,i};Un.decode.bytes=0;Un.encodingLength=function(){return 18};var Kr=XS.option={};Kr.encode=function(r,n,i){if(!n)n=Y.alloc(Kr.encodingLength(r));if(!i)i=0;let m=i,c=_c.toCode(r.code);if(n.writeUInt16BE(c,i),i+=2,r.data)n.writeUInt16BE(r.data.length,i),i+=2,r.data.copy(n,i),i+=r.data.length;else switch(c){case 8:let l=r.sourcePrefixLength||0,y=r.family||fn.familyOf(r.ip),j=fn.encode(r.ip,Y.alloc),A=Math.ceil(l/8);n.writeUInt16BE(A+4,i),i+=2,n.writeUInt16BE(y,i),i+=2,n.writeUInt8(l,i++),n.writeUInt8(r.scopePrefixLength||0,i++),j.copy(n,i,0,A),i+=A;break;case 11:if(r.timeout)n.writeUInt16BE(2,i),i+=2,n.writeUInt16BE(r.timeout,i),i+=2;else n.writeUInt16BE(0,i),i+=2;break;case 12:let S=r.length||0;n.writeUInt16BE(S,i),i+=2,n.fill(0,i,i+S),i+=S;break;case 14:let v=r.tags.length*2;n.writeUInt16BE(v,i),i+=2;for(let w of r.tags)n.writeUInt16BE(w,i),i+=2;break;default:throw Error(`Unknown roption code: ${r.code}`)}return Kr.encode.bytes=i-m,n};Kr.encode.bytes=0;Kr.decode=function(r,n){if(!n)n=0;let i={};i.code=r.readUInt16BE(n),i.type=_c.toString(i.code),n+=2;let m=r.readUInt16BE(n);switch(n+=2,i.data=r.slice(n,n+m),i.code){case 8:i.family=r.readUInt16BE(n),n+=2,i.sourcePrefixLength=r.readUInt8(n++),i.scopePrefixLength=r.readUInt8(n++);let c=Y.alloc(i.family===1?4:16);r.copy(c,0,n,n+m-4),i.ip=fn.decode(c);break;case 11:if(m>0)i.timeout=r.readUInt16BE(n),n+=2;break;case 14:i.tags=[];for(let l=0;l<m;l+=2)i.tags.push(r.readUInt16BE(n)),n+=2}return Kr.decode.bytes=m+4,i};Kr.decode.bytes=0;Kr.encodingLength=function(r){if(r.data)return r.data.length+4;switch(_c.toCode(r.code)){case 8:let i=r.sourcePrefixLength||0;return Math.ceil(i/8)+8;case 11:return typeof r.timeout==="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw Error(`Unknown roption code: ${r.code}`)};var or=XS.opt={};or.encode=function(r,n,i){if(!n)n=Y.alloc(or.encodingLength(r));if(!i)i=0;let m=i,c=Gi(r,Kr);return n.writeUInt16BE(c,i),i=pi(r,Kr,n,i+2),or.encode.bytes=i-m,n};or.encode.bytes=0;or.decode=function(r,n){if(!n)n=0;let i=n,m=[],c=r.readUInt16BE(n);n+=2;let l=0;while(c>0)m[l++]=Kr.decode(r,n),n+=Kr.decode.bytes,c-=Kr.decode.bytes;return or.decode.bytes=n-i,m};or.decode.bytes=0;or.encodingLength=function(r){return 2+Gi(r||[],Kr)};var Pr=XS.dnskey={};Pr.PROTOCOL_DNSSEC=3;Pr.ZONE_KEY=128;Pr.SECURE_ENTRYPOINT=32768;Pr.encode=function(r,n,i){if(!n)n=Y.alloc(Pr.encodingLength(r));if(!i)i=0;let m=i,c=r.key;if(!Y.isBuffer(c))throw Error("Key must be a Buffer");return i+=2,n.writeUInt16BE(r.flags,i),i+=2,n.writeUInt8(Pr.PROTOCOL_DNSSEC,i),i+=1,n.writeUInt8(r.algorithm,i),i+=1,c.copy(n,i,0,c.length),i+=c.length,Pr.encode.bytes=i-m,n.writeUInt16BE(Pr.encode.bytes-2,m),n};Pr.encode.bytes=0;Pr.decode=function(r,n){if(!n)n=0;let i=n;var m={},c=r.readUInt16BE(n);if(n+=2,m.flags=r.readUInt16BE(n),n+=2,r.readUInt8(n)!==Pr.PROTOCOL_DNSSEC)throw Error("Protocol must be 3");return n+=1,m.algorithm=r.readUInt8(n),n+=1,m.key=r.slice(n,i+c+2),n+=m.key.length,Pr.decode.bytes=n-i,m};Pr.decode.bytes=0;Pr.encodingLength=function(r){return 6+Y.byteLength(r.key)};var sr=XS.rrsig={};sr.encode=function(r,n,i){if(!n)n=Y.alloc(sr.encodingLength(r));if(!i)i=0;let m=i,c=r.signature;if(!Y.isBuffer(c))throw Error("Signature must be a Buffer");return i+=2,n.writeUInt16BE(Cn.toType(r.typeCovered),i),i+=2,n.writeUInt8(r.algorithm,i),i+=1,n.writeUInt8(r.labels,i),i+=1,n.writeUInt32BE(r.originalTTL,i),i+=4,n.writeUInt32BE(r.expiration,i),i+=4,n.writeUInt32BE(r.inception,i),i+=4,n.writeUInt16BE(r.keyTag,i),i+=2,H.encode(r.signersName,n,i),i+=H.encode.bytes,c.copy(n,i,0,c.length),i+=c.length,sr.encode.bytes=i-m,n.writeUInt16BE(sr.encode.bytes-2,m),n};sr.encode.bytes=0;sr.decode=function(r,n){if(!n)n=0;let i=n;var m={},c=r.readUInt16BE(n);return n+=2,m.typeCovered=Cn.toString(r.readUInt16BE(n)),n+=2,m.algorithm=r.readUInt8(n),n+=1,m.labels=r.readUInt8(n),n+=1,m.originalTTL=r.readUInt32BE(n),n+=4,m.expiration=r.readUInt32BE(n),n+=4,m.inception=r.readUInt32BE(n),n+=4,m.keyTag=r.readUInt16BE(n),n+=2,m.signersName=H.decode(r,n),n+=H.decode.bytes,m.signature=r.slice(n,i+c+2),n+=m.signature.length,sr.decode.bytes=n-i,m};sr.decode.bytes=0;sr.encodingLength=function(r){return 20+H.encodingLength(r.signersName)+Y.byteLength(r.signature)};var fr=XS.rp={};fr.encode=function(r,n,i){if(!n)n=Y.alloc(fr.encodingLength(r));if(!i)i=0;let m=i;return i+=2,H.encode(r.mbox||".",n,i,{mail:!0}),i+=H.encode.bytes,H.encode(r.txt||".",n,i),i+=H.encode.bytes,fr.encode.bytes=i-m,n.writeUInt16BE(fr.encode.bytes-2,m),n};fr.encode.bytes=0;fr.decode=function(r,n){if(!n)n=0;let i=n,m={};return n+=2,m.mbox=H.decode(r,n,{mail:!0})||".",n+=H.decode.bytes,m.txt=H.decode(r,n)||".",n+=H.decode.bytes,fr.decode.bytes=n-i,m};fr.decode.bytes=0;fr.encodingLength=function(r){return 2+H.encodingLength(r.mbox||".")+H.encodingLength(r.txt||".")};var jr={};jr.encode=function(r,n,i){if(!n)n=Y.alloc(jr.encodingLength(r));if(!i)i=0;let m=i;var c=[];for(var l=0;l<r.length;l++){var y=Cn.toType(r[l]);if(c[y>>8]===void 0)c[y>>8]=[];c[y>>8][y>>3&31]|=1<<7-(y&7)}for(l=0;l<c.length;l++)if(c[l]!==void 0){var j=Y.from(c[l]);n.writeUInt8(l,i),i+=1,n.writeUInt8(j.length,i),i+=1,j.copy(n,i),i+=j.length}return jr.encode.bytes=i-m,n};jr.encode.bytes=0;jr.decode=function(r,n,i){if(!n)n=0;let m=n;var c=[];while(n-m<i){var l=r.readUInt8(n);n+=1;var y=r.readUInt8(n);n+=1;for(var j=0;j<y;j++){var A=r.readUInt8(n+j);for(var S=0;S<8;S++)if(A&1<<7-S){var v=Cn.toString(l<<8|j<<3|S);c.push(v)}}n+=y}return jr.decode.bytes=n-m,c};jr.decode.bytes=0;jr.encodingLength=function(r){var n=[];for(var i=0;i<r.length;i++){var m=Cn.toType(r[i]);n[m>>8]=Math.max(n[m>>8]||0,m&255)}var c=0;for(i=0;i<n.length;i++)if(n[i]!==void 0)c+=2+Math.ceil((n[i]+1)/8);return c};var rn=XS.nsec={};rn.encode=function(r,n,i){if(!n)n=Y.alloc(rn.encodingLength(r));if(!i)i=0;let m=i;return i+=2,H.encode(r.nextDomain,n,i),i+=H.encode.bytes,jr.encode(r.rrtypes,n,i),i+=jr.encode.bytes,rn.encode.bytes=i-m,n.writeUInt16BE(rn.encode.bytes-2,m),n};rn.encode.bytes=0;rn.decode=function(r,n){if(!n)n=0;let i=n;var m={},c=r.readUInt16BE(n);return n+=2,m.nextDomain=H.decode(r,n),n+=H.decode.bytes,m.rrtypes=jr.decode(r,n,c-(n-i)),n+=jr.decode.bytes,rn.decode.bytes=n-i,m};rn.decode.bytes=0;rn.encodingLength=function(r){return 2+H.encodingLength(r.nextDomain)+jr.encodingLength(r.rrtypes)};var nn=XS.nsec3={};nn.encode=function(r,n,i){if(!n)n=Y.alloc(nn.encodingLength(r));if(!i)i=0;let m=i,c=r.salt;if(!Y.isBuffer(c))throw Error("salt must be a Buffer");let l=r.nextDomain;if(!Y.isBuffer(l))throw Error("nextDomain must be a Buffer");return i+=2,n.writeUInt8(r.algorithm,i),i+=1,n.writeUInt8(r.flags,i),i+=1,n.writeUInt16BE(r.iterations,i),i+=2,n.writeUInt8(c.length,i),i+=1,c.copy(n,i,0,c.length),i+=c.length,n.writeUInt8(l.length,i),i+=1,l.copy(n,i,0,l.length),i+=l.length,jr.encode(r.rrtypes,n,i),i+=jr.encode.bytes,nn.encode.bytes=i-m,n.writeUInt16BE(nn.encode.bytes-2,m),n};nn.encode.bytes=0;nn.decode=function(r,n){if(!n)n=0;let i=n;var m={},c=r.readUInt16BE(n);n+=2,m.algorithm=r.readUInt8(n),n+=1,m.flags=r.readUInt8(n),n+=1,m.iterations=r.readUInt16BE(n),n+=2;let l=r.readUInt8(n);n+=1,m.salt=r.slice(n,n+l),n+=l;let y=r.readUInt8(n);return n+=1,m.nextDomain=r.slice(n,n+y),n+=y,m.rrtypes=jr.decode(r,n,c-(n-i)),n+=jr.decode.bytes,nn.decode.bytes=n-i,m};nn.decode.bytes=0;nn.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+jr.encodingLength(r.rrtypes)};var mn=XS.ds={};mn.encode=function(r,n,i){if(!n)n=Y.alloc(mn.encodingLength(r));if(!i)i=0;let m=i,c=r.digest;if(!Y.isBuffer(c))throw Error("Digest must be a Buffer");return i+=2,n.writeUInt16BE(r.keyTag,i),i+=2,n.writeUInt8(r.algorithm,i),i+=1,n.writeUInt8(r.digestType,i),i+=1,c.copy(n,i,0,c.length),i+=c.length,mn.encode.bytes=i-m,n.writeUInt16BE(mn.encode.bytes-2,m),n};mn.encode.bytes=0;mn.decode=function(r,n){if(!n)n=0;let i=n;var m={},c=r.readUInt16BE(n);return n+=2,m.keyTag=r.readUInt16BE(n),n+=2,m.algorithm=r.readUInt8(n),n+=1,m.digestType=r.readUInt8(n),n+=1,m.digest=r.slice(n,i+c+2),n+=m.digest.length,mn.decode.bytes=n-i,m};mn.decode.bytes=0;mn.encodingLength=function(r){return 6+Y.byteLength(r.digest)};var Jr=XS.sshfp={};Jr.getFingerprintLengthForHashType=function(n){switch(n){case 1:return 20;case 2:return 32}};Jr.encode=function(n,i,m){if(!i)i=Y.alloc(Jr.encodingLength(n));if(!m)m=0;let c=m;m+=2,i[m]=n.algorithm,m+=1,i[m]=n.hash,m+=1;let l=Y.from(n.fingerprint.toUpperCase(),"hex");if(l.length!==Jr.getFingerprintLengthForHashType(n.hash))throw Error("Invalid fingerprint length");return l.copy(i,m),m+=l.byteLength,Jr.encode.bytes=m-c,i.writeUInt16BE(Jr.encode.bytes-2,c),i};Jr.encode.bytes=0;Jr.decode=function(n,i){if(!i)i=0;let m=i,c={};i+=2,c.algorithm=n[i],i+=1,c.hash=n[i],i+=1;let l=Jr.getFingerprintLengthForHashType(c.hash);return c.fingerprint=n.slice(i,i+l).toString("hex").toUpperCase(),i+=l,Jr.decode.bytes=i-m,c};Jr.decode.bytes=0;Jr.encodingLength=function(r){return 4+Y.from(r.fingerprint,"hex").byteLength};var cn=XS.naptr={};cn.encode=function(r,n,i){if(!n)n=Y.alloc(cn.encodingLength(r));if(!i)i=0;let m=i;return i+=2,n.writeUInt16BE(r.order||0,i),i+=2,n.writeUInt16BE(r.preference||0,i),i+=2,o.encode(r.flags,n,i),i+=o.encode.bytes,o.encode(r.services,n,i),i+=o.encode.bytes,o.encode(r.regexp,n,i),i+=o.encode.bytes,H.encode(r.replacement,n,i),i+=H.encode.bytes,cn.encode.bytes=i-m,n.writeUInt16BE(cn.encode.bytes-2,m),n};cn.encode.bytes=0;cn.decode=function(r,n){if(!n)n=0;let i=n,m={};return n+=2,m.order=r.readUInt16BE(n),n+=2,m.preference=r.readUInt16BE(n),n+=2,m.flags=o.decode(r,n),n+=o.decode.bytes,m.services=o.decode(r,n),n+=o.decode.bytes,m.regexp=o.decode(r,n),n+=o.decode.bytes,m.replacement=H.decode(r,n),n+=H.decode.bytes,cn.decode.bytes=n-i,m};cn.decode.bytes=0;cn.encodingLength=function(r){return o.encodingLength(r.flags)+o.encodingLength(r.services)+o.encodingLength(r.regexp)+H.encodingLength(r.replacement)+6};var ln=XS.tlsa={};ln.encode=function(r,n,i){if(!n)n=Y.alloc(ln.encodingLength(r));if(!i)i=0;let m=i,c=r.certificate;if(!Y.isBuffer(c))throw Error("Certificate must be a Buffer");return i+=2,n.writeUInt8(r.usage,i),i+=1,n.writeUInt8(r.selector,i),i+=1,n.writeUInt8(r.matchingType,i),i+=1,c.copy(n,i,0,c.length),i+=c.length,ln.encode.bytes=i-m,n.writeUInt16BE(ln.encode.bytes-2,m),n};ln.encode.bytes=0;ln.decode=function(r,n){if(!n)n=0;let i=n,m={},c=r.readUInt16BE(n);return n+=2,m.usage=r.readUInt8(n),n+=1,m.selector=r.readUInt8(n),n+=1,m.matchingType=r.readUInt8(n),n+=1,m.certificate=r.slice(n,i+c+2),n+=m.certificate.length,ln.decode.bytes=n-i,m};ln.decode.bytes=0;ln.encodingLength=function(r){return 5+Y.byteLength(r.certificate)};var gc=XS.record=function(r){switch(r.toUpperCase()){case"A":return Pn;case"PTR":return ar;case"CNAME":return CS;case"DNAME":return WS;case"TXT":return En;case"NULL":return Nn;case"AAAA":return Un;case"SRV":return Dn;case"HINFO":return Qn;case"CAA":return Vr;case"NS":return $n;case"SOA":return Gn;case"MX":return on;case"OPT":return or;case"DNSKEY":return Pr;case"RRSIG":return sr;case"RP":return fr;case"NSEC":return rn;case"NSEC3":return nn;case"SSHFP":return Jr;case"DS":return mn;case"NAPTR":return cn;case"TLSA":return ln}return wn},Sr=XS.answer={};Sr.encode=function(r,n,i){if(!n)n=Y.alloc(Sr.encodingLength(r));if(!i)i=0;let m=i;if(H.encode(r.name,n,i),i+=H.encode.bytes,n.writeUInt16BE(Cn.toType(r.type),i),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw Error("OPT name must be root.");n.writeUInt16BE(r.udpPayloadSize||4096,i+2),n.writeUInt8(r.extendedRcode||0,i+4),n.writeUInt8(r.ednsVersion||0,i+5),n.writeUInt16BE(r.flags||0,i+6),i+=8,or.encode(r.options||[],n,i),i+=or.encode.bytes}else{let c=dm.toClass(r.class===void 0?"IN":r.class);if(r.flush)c|=32768;n.writeUInt16BE(c,i+2),n.writeUInt32BE(r.ttl||0,i+4),i+=8;let l=gc(r.type);l.encode(r.data,n,i),i+=l.encode.bytes}return Sr.encode.bytes=i-m,n};Sr.encode.bytes=0;Sr.decode=function(r,n){if(!n)n=0;let i={},m=n;if(i.name=H.decode(r,n),n+=H.decode.bytes,i.type=Cn.toString(r.readUInt16BE(n)),i.type==="OPT")i.udpPayloadSize=r.readUInt16BE(n+2),i.extendedRcode=r.readUInt8(n+4),i.ednsVersion=r.readUInt8(n+5),i.flags=r.readUInt16BE(n+6),i.flag_do=(i.flags>>15&1)===1,i.options=or.decode(r,n+8),n+=8+or.decode.bytes;else{let c=r.readUInt16BE(n+2);i.ttl=r.readUInt32BE(n+4),i.class=dm.toString(c&-32769),i.flush=!!(c&32768);let l=gc(i.type);i.data=l.decode(r,n+8),n+=8+l.decode.bytes}return Sr.decode.bytes=n-m,i};Sr.decode.bytes=0;Sr.encodingLength=function(r){let n=r.data!==null&&r.data!==void 0?r.data:r.options;return H.encodingLength(r.name)+8+gc(r.type).encodingLength(n)};var pr=XS.question={};pr.encode=function(r,n,i){if(!n)n=Y.alloc(pr.encodingLength(r));if(!i)i=0;let m=i;return H.encode(r.name,n,i),i+=H.encode.bytes,n.writeUInt16BE(Cn.toType(r.type),i),i+=2,n.writeUInt16BE(dm.toClass(r.class===void 0?"IN":r.class),i),i+=2,pr.encode.bytes=i-m,r};pr.encode.bytes=0;pr.decode=function(r,n){if(!n)n=0;let i=n,m={};if(m.name=H.decode(r,n),n+=H.decode.bytes,m.type=Cn.toString(r.readUInt16BE(n)),n+=2,m.class=dm.toString(r.readUInt16BE(n)),n+=2,!!(m.class&32768))m.class&=-32769;return pr.decode.bytes=n-i,m};pr.decode.bytes=0;pr.encodingLength=function(r){return H.encodingLength(r.name)+4};XS.AUTHORITATIVE_ANSWER=1024;XS.TRUNCATED_RESPONSE=512;XS.RECURSION_DESIRED=256;XS.RECURSION_AVAILABLE=128;XS.AUTHENTIC_DATA=32;XS.CHECKING_DISABLED=16;XS.DNSSEC_OK=32768;XS.encode=function(r,n,i){let m=!n;if(m)n=Y.alloc(XS.encodingLength(r));if(!i)i=0;let c=i;if(!r.questions)r.questions=[];if(!r.answers)r.answers=[];if(!r.authorities)r.authorities=[];if(!r.additionals)r.additionals=[];if(ur.encode(r,n,i),i+=ur.encode.bytes,i=pi(r.questions,pr,n,i),i=pi(r.answers,Sr,n,i),i=pi(r.authorities,Sr,n,i),i=pi(r.additionals,Sr,n,i),XS.encode.bytes=i-c,m&&XS.encode.bytes!==n.length)return n.slice(0,XS.encode.bytes);return n};XS.encode.bytes=0;XS.decode=function(r,n){if(!n)n=0;let i=n,m=ur.decode(r,n);return n+=ur.decode.bytes,n=um(m.questions,pr,r,n),n=um(m.answers,Sr,r,n),n=um(m.authorities,Sr,r,n),n=um(m.additionals,Sr,r,n),XS.decode.bytes=n-i,m};XS.decode.bytes=0;XS.encodingLength=function(r){return ur.encodingLength(r)+Gi(r.questions||[],pr)+Gi(r.answers||[],Sr)+Gi(r.authorities||[],Sr)+Gi(r.additionals||[],Sr)};XS.streamEncode=function(r){let n=XS.encode(r),i=Y.alloc(2);i.writeUInt16BE(n.byteLength);let m=Y.concat([i,n]);return XS.streamEncode.bytes=m.byteLength,m};XS.streamEncode.bytes=0;XS.streamDecode=function(r){let n=r.readUInt16BE(0);if(r.byteLength<n+2)return null;let i=XS.decode(r.slice(2));return XS.streamDecode.bytes=XS.decode.bytes,i};XS.streamDecode.bytes=0;function Gi(r,n){let i=0;for(let m=0;m<r.length;m++)i+=n.encodingLength(r[m]);return i}function pi(r,n,i,m){for(let c=0;c<r.length;c++)n.encode(r[c],i,m),m+=n.encode.bytes;return m}function um(r,n,i,m){for(let c=0;c<r.length;c++)r[c]=n.decode(i,m),m+=n.decode.bytes;return m}});var Ij=rr((tQ,jj)=>{var yj=zS;process.nextTick(gS,42);jj.exports=OS;function OS(r){var n=m;return i;function i(c){n(c||qS)}function m(c){var l=[c];n=y,r(j);function y(A){l.push(A)}function j(A){var S=arguments;n=LS(A)?m:v;while(l.length)v(l.shift());function v(w){yj(_S,w,S)}}}}function LS(r){return Object.prototype.toString.call(r)==="[object Error]"}function qS(){}function _S(r,n){r.apply(null,n)}function gS(r){if(r===42)yj=process.nextTick}function zS(r,n,i){process.nextTick(function(){r(n,i)})}});var vj=rr((eQ,Sj)=>{var zc=lj(),FS=bn("dgram"),TS=Ij(),MS=bn("events"),Tc=bn("os"),Fc=function(){};Sj.exports=function(r){if(!r)r={};var n=new MS.EventEmitter,i=typeof r.port==="number"?r.port:5353,m=r.type||"udp4",c=r.ip||r.host||(m==="udp4"?"224.0.0.251":null),l={address:c,port:i},y={},j=!1,A=null;if(m==="udp6"&&(!c||!r.interface))throw Error("For IPv6 multicast you must specify `ip` and `interface`");var S=r.socket||FS.createSocket({type:m,reuseAddr:r.reuseAddr!==!1,toString:function(){return m}});S.on("error",function(w){if(w.code==="EACCES"||w.code==="EADDRINUSE")n.emit("error",w);else n.emit("warning",w)}),S.on("message",function(w,E){try{w=zc.decode(w)}catch(N){n.emit("warning",N);return}if(n.emit("packet",w,E),w.type==="query")n.emit("query",w,E);if(w.type==="response")n.emit("response",w,E)}),S.on("listening",function(){if(!i)i=l.port=S.address().port;if(r.multicast!==!1)n.update(),A=setInterval(n.update,5000),S.setMulticastTTL(r.ttl||255),S.setMulticastLoopback(r.loopback!==!1)});var v=TS(function(w){if(!i||r.bind===!1)return w(null);S.once("error",w),S.bind(i,r.bind||r.interface,function(){S.removeListener("error",w),w(null)})});return v(function(w){if(w)return n.emit("error",w);n.emit("ready")}),n.send=function(w,E,N){if(typeof E==="function")return n.send(w,null,E);if(!N)N=Fc;if(!E)E=l;else if(!E.host&&!E.address)E.address=l.address;v(Q);function Q(W){if(j)return N();if(W)return N(W);var R=zc.encode(w);S.send(R,0,R.length,E.port,E.address||E.host,N)}},n.response=n.respond=function(w,E,N){if(Array.isArray(w))w={answers:w};w.type="response",w.flags=(w.flags||0)|zc.AUTHORITATIVE_ANSWER,n.send(w,E,N)},n.query=function(w,E,N,Q){if(typeof E==="function")return n.query(w,null,null,E);if(typeof E==="object"&&E&&E.port)return n.query(w,null,E,N);if(typeof N==="function")return n.query(w,E,null,N);if(!Q)Q=Fc;if(typeof w==="string")w=[{name:w,type:E||"ANY"}];if(Array.isArray(w))w={type:"query",questions:w};w.type="query",n.send(w,N,Q)},n.destroy=function(w){if(!w)w=Fc;if(j)return process.nextTick(w);j=!0,clearInterval(A);for(var E in y)try{S.dropMembership(c,E)}catch(N){}y={},S.close(w)},n.update=function(){var w=r.interface?[].concat(r.interface):BS(),E=!1;for(var N=0;N<w.length;N++){var Q=w[N];if(y[Q])continue;try{S.addMembership(c,Q),y[Q]=!0,E=!0}catch(W){n.emit("warning",W)}}if(E){if(S.setMulticastInterface)try{S.setMulticastInterface(r.interface||hS())}catch(W){n.emit("warning",W)}n.emit("networkInterface")}},n};function hS(){var r=Tc.networkInterfaces(),n=Object.keys(r);for(var i=0;i<n.length;i++){var m=r[n[i]];for(var c=0;c<m.length;c++){var l=m[c];if(Aj(l.family)&&!l.internal){if(Tc.platform()==="darwin"&&n[i]==="en0")return l.address;return"0.0.0.0"}}}return"127.0.0.1"}function BS(){var r=Tc.networkInterfaces(),n=Object.keys(r),i=[];for(var m=0;m<n.length;m++){var c=r[n[m]];for(var l=0;l<c.length;l++){var y=c[l];if(Aj(y.family)){i.push(y.address);break}}}return i}function Aj(r){return r===4||r==="IPv4"}});var $j=rr((bQ,wj)=>{wj.exports=function r(n,i){if(n===i)return!0;if(n&&i&&typeof n=="object"&&typeof i=="object"){if(n.constructor!==i.constructor)return!1;var m,c,l;if(Array.isArray(n)){if(m=n.length,m!=i.length)return!1;for(c=m;c--!==0;)if(!r(n[c],i[c]))return!1;return!0}if(n instanceof Map&&i instanceof Map){if(n.size!==i.size)return!1;for(c of n.entries())if(!i.has(c[0]))return!1;for(c of n.entries())if(!r(c[1],i.get(c[0])))return!1;return!0}if(n instanceof Set&&i instanceof Set){if(n.size!==i.size)return!1;for(c of n.entries())if(!i.has(c[0]))return!1;return!0}if(ArrayBuffer.isView(n)&&ArrayBuffer.isView(i)){if(m=n.length,m!=i.length)return!1;for(c=m;c--!==0;)if(n[c]!==i[c])return!1;return!0}if(n.constructor===RegExp)return n.source===i.source&&n.flags===i.flags;if(n.valueOf!==Object.prototype.valueOf)return n.valueOf()===i.valueOf();if(n.toString!==Object.prototype.toString)return n.toString()===i.toString();if(l=Object.keys(n),m=l.length,m!==Object.keys(i).length)return!1;for(c=m;c--!==0;)if(!Object.prototype.hasOwnProperty.call(i,l[c]))return!1;for(c=m;c--!==0;){var y=l[c];if(!r(n[y],i[y]))return!1}return!0}return n!==n&&i!==i}});var Gj=rr((ri)=>{var Mc=ri&&ri.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ri,"__esModule",{value:!0});ri.Server=void 0;var xS=Mc(vj()),kS=Mc($j()),aS=Mc(am());class hc{constructor(r,n){this.registry={},this.mdns=(0,xS.default)(r),this.mdns.setMaxListeners(0),this.mdns.on("query",this.respondToQuery.bind(this)),this.errorCallback=n!==null&&n!==void 0?n:function(i){throw i}}register(r){let n=(i)=>{var m=this.registry[i.type];if(!m)m=this.registry[i.type]=[];else if(m.some(this.isDuplicateRecord(i)))return;m.push(i)};if(Array.isArray(r))r.forEach(n);else n(r)}unregister(r){let n=(i)=>{let m=i.type;if(!(m in this.registry))return;this.registry[m]=this.registry[m].filter((c)=>c.name!==i.name)};if(Array.isArray(r))r.forEach(n);else n(r)}respondToQuery(r){let n=this;r.questions.forEach((i)=>{var{type:m,name:c}=i,l=m==="ANY"?Object.keys(n.registry).map(n.recordsFor.bind(n,c)).flat(1):n.recordsFor(c,m);if(l.length===0)return;var y=[];if(m!=="ANY")l.forEach((j)=>{if(j.type!=="PTR")return;y=y.concat(n.recordsFor(j.data,"SRV")).concat(n.recordsFor(j.data,"TXT"))}),y.filter(function(j){return j.type==="SRV"}).map(function(j){return j.data.target}).filter(this.unique()).forEach(function(j){y=y.concat(n.recordsFor(j,"A")).concat(n.recordsFor(j,"AAAA"))});n.mdns.respond({answers:l,additionals:y},(j)=>{if(j)this.errorCallback(j)})})}recordsFor(r,n){if(!(n in this.registry))return[];return this.registry[n].filter((i)=>{var m=~r.indexOf(".")?i.name:i.name.split(".")[0];return(0,aS.default)(m,r)})}isDuplicateRecord(r){return(n)=>{return r.type===n.type&&r.name===n.name&&(0,kS.default)(r.data,n.data)}}unique(){var r=[];return(n)=>{if(~r.indexOf(n))return!1;return r.push(n),!0}}}ri.Server=hc;ri.default=hc});var Nj=rr((Ej)=>{Object.defineProperty(Ej,"__esModule",{value:!0});Ej.default=(r,n)=>{if(n===void 0)return!0;let i=r.txt,m=Object.entries(n).map(([c,l])=>{let y=i[c];if(y===void 0)return!1;if(l!=y)return!1;return!0});if(m.length==0)return!0;if(m.includes(!1))return!1;return!0}});var Dj=rr((Qj)=>{Object.defineProperty(Qj,"__esModule",{value:!0});Qj.default=(r)=>Object.keys(r).filter((n)=>!n.includes("binary")).reduce((n,i)=>{return Object.assign(n,{[i]:r[i]})},{})});var Uj=rr((Pj)=>{Object.defineProperty(Pj,"__esModule",{value:!0});Pj.default=dS;function dS(r,n){if(r===void 0||n===void 0)return!1;let i=Object.keys(r),m=Object.keys(n);if(i.length!=m.length)return!1;for(let c of i)if(r[c]!=n[c])return!1;return!0}});var Xj=rr((ni)=>{var di=ni&&ni.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ni,"__esModule",{value:!0});ni.Browser=void 0;var eS=di(Rc()),On=di(am()),bS=bn("events"),Bc=Zc(),Cj=di(Nj()),sS=di(Dj()),fS=di(Uj()),Wj=".local",rv="_services._dns-sd._udp"+Wj;class tm extends bS.EventEmitter{constructor(r,n,i){super();if(this.onresponse=void 0,this.serviceMap={},this.wildcard=!1,this._services=[],typeof n==="function")return new tm(r,null,n);if(this.mdns=r,this.txt=new eS.default(n!==null&&n.txt!=null?n.txt:void 0),n===null||n.type===void 0)this.name=rv,this.wildcard=!0;else{if(this.name=(0,Bc.toString)({name:n.type,protocol:n.protocol||"tcp"})+Wj,n.name)this.name=n.name+"."+this.name;this.wildcard=!1}if(n!=null&&n.txt!==void 0)this.txtQuery=(0,sS.default)(n.txt);if(i)this.on("up",i);this.start()}start(){if(this.onresponse||this.name===void 0)return;var r=this,n={};if(!this.wildcard)n[this.name]=!0;this.onresponse=(i,m)=>{if(r.wildcard)i.answers.forEach((c)=>{if(c.type!=="PTR"||c.name!==r.name||c.name in n)return;n[c.data]=!0,r.mdns.query(c.data,"PTR")});Object.keys(n).forEach(function(c){r.goodbyes(c,i).forEach(r.removeService.bind(r));var l=r.buildServicesFor(c,i,r.txt,m);if(l.length===0)return;l.forEach((y)=>{if(r.serviceMap[y.fqdn]){r.updateService(y);return}r.addService(y)})})},this.mdns.on("response",this.onresponse),this.update()}stop(){if(!this.onresponse)return;this.mdns.removeListener("response",this.onresponse),this.onresponse=void 0}update(){this.mdns.query(this.name,"PTR")}get services(){return this._services}addService(r){if((0,Cj.default)(r,this.txtQuery)===!1)return;this._services.push(r),this.serviceMap[r.fqdn]=!0,this.emit("up",r)}updateService(r){var n;if((0,fS.default)(r.txt,((n=this._services.find((i)=>(0,On.default)(i.fqdn,r.fqdn)))===null||n===void 0?void 0:n.txt)||{}))return;if(!(0,Cj.default)(r,this.txtQuery)){this.removeService(r.fqdn);return}this._services=this._services.map(function(i){if(!(0,On.default)(i.fqdn,r.fqdn))return i;return r}),this.emit("txt-update",r)}removeService(r){var n,i;if(this._services.some(function(m,c){if((0,On.default)(m.fqdn,r))return n=m,i=c,!0}),!n||i===void 0)return;this._services.splice(i,1),delete this.serviceMap[r],this.emit("down",n)}goodbyes(r,n){return n.answers.concat(n.additionals).filter((i)=>i.type==="PTR"&&i.ttl===0&&(0,On.default)(i.name,r)).map((i)=>i.data)}buildServicesFor(r,n,i,m){var c=n.answers.concat(n.additionals).filter((l)=>l.ttl>0);return c.filter((l)=>l.type==="PTR"&&(0,On.default)(l.name,r)).map((l)=>{let y={addresses:[],subtypes:[]};if(c.filter((j)=>{return j.type==="PTR"&&(0,On.default)(j.data,l.data)&&j.name.includes("._sub")}).forEach((j)=>{let A=(0,Bc.toType)(j.name);y.subtypes.push(A.subtype)}),c.filter((j)=>{return(j.type==="SRV"||j.type==="TXT")&&(0,On.default)(j.name,l.data)}).forEach((j)=>{if(j.type==="SRV"){var A=j.name.split("."),S=A[0],v=(0,Bc.toType)(A.slice(1,-1).join("."));y.name=S,y.fqdn=j.name,y.host=j.data.target,y.referer=m,y.port=j.data.port,y.type=v.name,y.protocol=v.protocol}else if(j.type==="TXT")y.rawTxt=j.data,y.txt=this.txt.decodeAll(j.data)}),!y.name)return;return c.filter((j)=>(j.type==="A"||j.type==="AAAA")&&(0,On.default)(j.name,y.host)).forEach((j)=>y.addresses.push(j.data)),y}).filter((l)=>!!l)}}ni.Browser=tm;ni.default=tm});var Kj=rr((dr)=>{var em=dr&&dr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(dr,"__esModule",{value:!0});dr.Browser=dr.Service=dr.Bonjour=void 0;var nv=em(ey()),iv=em(Gj()),xc=em(Xj());dr.Browser=xc.default;var mv=em(Vc());dr.Service=mv.default;class kc{constructor(r={},n){this.server=new iv.default(r,n),this.registry=new nv.default(this.server)}publish(r){return this.registry.publish(r)}unpublishAll(r){return this.registry.unpublishAll(r)}find(r=null,n){return new xc.default(this.server.mdns,r,n)}findOne(r=null,n=1e4,i){let m=new xc.default(this.server.mdns,r);var c;return m.once("up",(l)=>{if(c!==void 0)clearTimeout(c);if(m.stop(),i)i(l)}),c=setTimeout(()=>{if(m.stop(),i)i(null)},n),m}destroy(r){this.registry.destroy(),this.server.mdns.destroy(r)}}dr.Bonjour=kc;dr.default=kc});var el={};Er(el,{url:()=>yA,openapi:()=>T$,listen:()=>M$,Server:()=>el,Default:()=>z$});var cc=(r)=>{let n=r.split("/");if(n[0]==="")n.shift();return n},bl=(r)=>{let{groups:n,path:i}=jA(r),m=cc(i);return IA(m,n)},jA=(r)=>{let n=[];return r=r.replace(/\{[^}]+\}/g,(i,m)=>{let c=`@${m}`;return n.push([c,i]),c}),{groups:n,path:r}},IA=(r,n)=>{for(let i=n.length-1;i>=0;i--){let[m]=n[i];for(let c=r.length-1;c>=0;c--)if(r[c].includes(m)){r[c]=r[c].replace(m,n[i][1]);break}}return r},_m={},sl=(r,n)=>{if(r==="*")return"*";let i=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(i){let m=`${r}#${n}`;if(!_m[m])if(i[2])_m[m]=n&&n[0]!==":"&&n[0]!=="*"?[m,i[1],new RegExp(`^${i[2]}(?=/${n})`)]:[r,i[1],new RegExp(`^${i[2]}$`)];else _m[m]=[r,i[1],!0];return _m[m]}return null},vi=(r,n)=>{try{return n(r)}catch{return r.replace(/(?:%[0-9A-Fa-f]{2})+/g,(i)=>{try{return n(i)}catch{return i}})}},fl=(r)=>vi(r,decodeURI),lc=(r)=>{let n=r.url,i=n.indexOf("/",n.indexOf(":")+4),m=i;for(;m<n.length;m++){let c=n.charCodeAt(m);if(c===37){let l=n.indexOf("?",m),y=n.indexOf("#",m),j=l===-1?y===-1?void 0:y:y===-1?l:Math.min(l,y),A=n.slice(i,j);return fl(A.includes("%25")?A.replace(/%25/g,"%2525"):A)}else if(c===63||c===35)break}return n.slice(i,m)};var ry=(r)=>{let n=lc(r);return n.length>1&&n.at(-1)==="/"?n.slice(0,-1):n},Jn=(r,n,...i)=>{if(i.length)n=Jn(n,...i);return`${r?.[0]==="/"?"":"/"}${r}${n==="/"?"":`${r?.at(-1)==="/"?"":"/"}${n?.[0]==="/"?n.slice(1):n}`}`},gm=(r)=>{if(r.charCodeAt(r.length-1)!==63||!r.includes(":"))return null;let n=r.split("/"),i=[],m="";return n.forEach((c)=>{if(c!==""&&!/\:/.test(c))m+="/"+c;else if(/\:/.test(c))if(/\?/.test(c)){if(i.length===0&&m==="")i.push("/");else i.push(m);let l=c.replace("?","");m+="/"+l,i.push(m)}else m+="/"+c}),i.filter((c,l,y)=>y.indexOf(c)===l)},mc=(r)=>{if(!/[%+]/.test(r))return r;if(r.indexOf("+")!==-1)r=r.replace(/\+/g," ");return r.indexOf("%")!==-1?vi(r,Ti):r},ny=(r,n,i)=>{let m;if(!i&&n&&!/[%+]/.test(n)){let y=r.indexOf("?",8);if(y===-1)return;if(!r.startsWith(n,y+1))y=r.indexOf(`&${n}`,y+1);while(y!==-1){let j=r.charCodeAt(y+n.length+1);if(j===61){let A=y+n.length+2,S=r.indexOf("&",A);return mc(r.slice(A,S===-1?void 0:S))}else if(j==38||isNaN(j))return"";y=r.indexOf(`&${n}`,y+1)}if(m=/[%+]/.test(r),!m)return}let c={};m??=/[%+]/.test(r);let l=r.indexOf("?",8);while(l!==-1){let y=r.indexOf("&",l+1),j=r.indexOf("=",l);if(j>y&&y!==-1)j=-1;let A=r.slice(l+1,j===-1?y===-1?void 0:y:j);if(m)A=mc(A);if(l=y,A==="")continue;let S;if(j===-1)S="";else if(S=r.slice(j+1,y===-1?void 0:y),m)S=mc(S);if(i){if(!(c[A]&&Array.isArray(c[A])))c[A]=[];c[A].push(S)}else c[A]??=S}return n?c[n]:c},iy=ny,my=(r,n)=>{return ny(r,n,!0)},Ti=decodeURIComponent;var AA=/^[\w!#$%&'*.^`|~+-]+$/,SA=/^[ !#-:<-[\]-~]*$/,cy=(r)=>{let n=0,i=r.length;while(n<i){let m=r.charCodeAt(n);if(m!==32&&m!==9)break;n++}while(i>n){let m=r.charCodeAt(i-1);if(m!==32&&m!==9)break;i--}return n===0&&i===r.length?r:r.slice(n,i)},yc=(r,n)=>{if(n&&r.indexOf(n)===-1)return{};let i=r.split(";"),m=Object.create(null);for(let c of i){let l=c.indexOf("=");if(l===-1)continue;let y=cy(c.substring(0,l));if(n&&n!==y||!AA.test(y)||y in m)continue;let j=cy(c.substring(l+1));if(j.startsWith('"')&&j.endsWith('"'))j=j.slice(1,-1);if(SA.test(j)){if(m[y]=j.indexOf("%")!==-1?vi(j,Ti):j,n)break}}return m};var ly=(r,n,i)=>{let m=r.req.raw.headers.get("Cookie");if(typeof n==="string"){if(!m)return;let l=n;if(i==="secure")l="__Secure-"+n;else if(i==="host")l="__Host-"+n;return yc(m,l)[l]}if(!m)return{};return yc(m)};var kr=class extends Error{res;status;constructor(r=500,n){super(n?.message,{cause:n?.cause});this.res=n?.res,this.status=r}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}};var jc=async(r)=>{return await vA(r,{name:"SHA-256",alias:"sha256"})};var vA=async(r,n)=>{let i;if(ArrayBuffer.isView(r)||r instanceof ArrayBuffer)i=r;else{if(typeof r==="object")r=JSON.stringify(r);i=new TextEncoder().encode(String(r))}if(crypto&&crypto.subtle){let m=await crypto.subtle.digest({name:n.name},i);return Array.prototype.map.call(new Uint8Array(m),(l)=>("00"+l.toString(16)).slice(-2)).join("")}return null};var yy=(r,n)=>{let i=r.length,m=n.length,c=Math.max(i,m),l=i^m;for(let y=0;y<c;y++){let j=y<i?r.charCodeAt(y):0,A=y<m?n.charCodeAt(y):0;l|=j^A}return l===0},jy=async(r,n,i)=>{if(!i)i=jc;let[m,c]=await Promise.all([i(r),i(n)]);if(m==null||c==null||typeof m!=="string"||typeof c!=="string")return!1;let l=yy(m,c),y=yy(r,n);return l&&y},Ic=async(r,n,i)=>{if(typeof r==="string"&&typeof n==="string")return jy(r,n,i);if(!i)i=jc;let[m,c]=await Promise.all([i(r),i(n)]);if(!m||!c||typeof m!=="string"||typeof c!=="string")return!1;return jy(m,c)};var zm=(r,n)=>{return new Response(r,{headers:{"Content-Type":n.replace(/^[^;]+/,(m)=>m.toLowerCase())}}).formData()};var wA=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i,$A=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i,GA=/^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i,Ac=(r,n)=>{return async(i,m)=>{let c={},l=i.req.header("Content-Type");switch(r){case"json":if(!l||!wA.test(l))break;try{c=await i.req.json()}catch{throw new kr(400,{message:"Malformed JSON in request body"})}break;case"form":{if(!l||!($A.test(l)||GA.test(l)))break;let j;if(i.req.bodyCache.formData)j=await i.req.bodyCache.formData;else try{let S=await i.req.arrayBuffer();j=await zm(S,l),i.req.bodyCache.formData=j}catch(S){let v="Malformed FormData request.";throw v+=S instanceof Error?` ${S.message}`:` ${String(S)}`,new kr(400,{message:v})}let A=Object.create(null);j.forEach((S,v)=>{if(v.endsWith("[]"))(A[v]??=[]).push(S);else if(Array.isArray(A[v]))A[v].push(S);else if(Object.hasOwn(A,v))A[v]=[A[v],S];else A[v]=S}),c=A;break}case"query":c=Object.fromEntries(Object.entries(i.req.queries()).map(([j,A])=>{return A.length===1?[j,A[0]]:[j,A]}));break;case"param":c=i.req.param();break;case"header":c=i.req.header();break;case"cookie":c=ly(i);break}let y=await n(c,i);if(y instanceof Response)return y;return i.req.addValidatedData(r,y),await m()}};var Iy={header:["cookie"]};function EA(r,n,i){if(!(i in Iy))return r;let m=Iy[i]||[];if(n==="arktype")return NA(r,m);if(n==="valibot")return QA(r,m);return r}function NA(r,n){return r.map((i)=>{if(i&&typeof i==="object"&&"data"in i&&typeof i.data==="object"&&i.data!==null&&!Array.isArray(i.data)){let m={...i.data};for(let l of n)delete m[l];let c=Object.create(Object.getPrototypeOf(i));return Object.assign(c,i,{data:m}),c}return i})}function QA(r,n){return r.map((i)=>{if(i&&typeof i==="object"&&"path"in i&&Array.isArray(i.path)){for(let m of i.path)if(typeof m==="object"&&"input"in m&&typeof m.input==="object"&&m.input!==null&&!Array.isArray(m.input))for(let c of n)delete m.input[c]}return i})}var Ay=(r,n,i)=>Ac(r,async(m,c)=>{let l=await n["~standard"].validate(m);if(i){let y=await i(l.issues?{data:m,error:l.issues,success:!1,target:r}:{data:m,success:!0,target:r},c);if(y){if(y instanceof Response)return y;if("response"in y)return y.response}}if(l.issues){let y=EA(l.issues,n["~standard"].vendor,r);return c.json({data:m,error:y,success:!1},400)}return l.value});var vc=Symbol("openapi"),PA=["GET","PUT","POST","DELETE","OPTIONS","HEAD","PATCH","TRACE"],UA=(r)=>r.split("/").map((n)=>{let i=n;if(i.startsWith(":")){let m=i.match(/^:([^{?]+)(?:{(.+)})?(\?)?$/);if(m)i=`{${m[1]}}`;else{if(i=i.slice(1,i.length),i.endsWith("?"))i=i.slice(0,-1);i=`{${i}}`}}return i}).join("/"),Sy=(r)=>r.charAt(0).toUpperCase()+r.slice(1),CA=(r)=>{let n=r.method.toLowerCase();if(r.path==="/")return`${n}Index`;for(let i of r.path.split("/"))if(i.charCodeAt(0)===123)n+=`By${Sy(i.slice(1,-1))}`;else n+=Sy(i);return n},WA=(r)=>("$ref"in r)?r.$ref:`${r.in} ${r.name}`;function vy(...r){let n=r.flatMap((i)=>i??[]).reduce((i,m)=>{return i.set(WA(m),m),i},new Map);return Array.from(n.values())}var wi=new Map;function XA(r){let n=[];for(let[i,m]of wi)if(m&&r.match(i))n.push(m);return n}function KA(){wi.clear()}function wy(r,...n){return n.reduce((i,m)=>{if(!m||!i)return i;for(let[c,l]of Object.entries(m)){if(l==null)continue;if(c in i&&(typeof l==="object"||typeof l==="function"&&c==="operationId"))if(Array.isArray(l)){let y=[...i[c]??[],...l];if(c==="tags")i[c]=Array.from(new Set(y));else if(c==="parameters")i[c]=vy(y);else i[c]=y}else if(typeof l==="function")i[c]=l(r);else if(c==="parameters")i[c]=vy(i[c],l);else i[c]={...i[c],...l};else i[c]=l}return i},{operationId:CA(r)})}function $y({route:r,specs:n,paths:i}){let m=UA(r.path),c=r.method.toLowerCase();if(c==="all"){if(!n)return;if(wi.has(m)){let l=wi.get(m)??{};wi.set(m,wy(r,l,n))}else wi.set(m,n)}else{let l=XA(m);if(!(m in i))i[m]={};if(i[m])i[m][c]=wy(r,...l,i[m]?.[c],n)}}function HA(r,n){let{exclude:i,excludeStaticFile:m}=n.options,c={},l=Array.isArray(i)?i:[i];for(let[y,j]of Object.entries(r)){if(j==null)continue;if(l.some((v)=>{if(typeof v==="string")return y===v;return v.test(y)}))continue;if(y.includes("*")&&!y.includes("{"))continue;if(m){let v=y.includes("{"),E=(y.split("/").pop()||"").includes(".");if(!v&&E)continue}for(let v of Object.keys(j)){let w=j[v];if(w==null)continue;if(y.includes("{")){w.parameters=w.parameters?[...w.parameters]:[];let E=y.split("/").filter((N)=>N.startsWith("{")&&!w.parameters.find((Q)=>Q.in==="path"&&Q.name===N.slice(1,N.length-1)));for(let N of E){let Q=N.slice(1,N.length-1);if(w.parameters.findIndex((R)=>{if("$ref"in R){let X=R.$ref.split("/").pop();if(X){let K=n.components.parameters?.[X];if(K&&!("$ref"in K))return K.in==="path"&&K.name===Q}return!1}return R.in==="path"&&R.name===Q})===-1)w.parameters.push({schema:{type:"string"},in:"path",name:Q,required:!0})}}if(!w.responses)w.responses={200:{}}}c[y]=j}return c}var Gy={documentation:{},excludeStaticFile:!0,exclude:[],excludeMethods:["OPTIONS"],excludeTags:[]};function Qy(r,n){let i;return async(m)=>{if(i)return m.json(i);return i=await wc(r,n,m),m.json(i)}}async function wc(r,n=Gy,i){let m={components:{},options:{...Gy,...n}},c=m.options.documentation??{};KA();let l=await RA(r,m);for(let j in l)for(let A in l[j])if(ZA({valueOrFunc:l[j][A]?.hide,method:A,path:j,c:i}))l[j][A]=void 0;let y=$c(c.components,m.components);return{openapi:"3.1.0",...c,tags:c.tags?.filter((j)=>!m.options.excludeTags?.includes(j?.name)),info:{title:"Hono Documentation",description:"Development documentation",version:"0.0.0",...c.info},paths:{...HA(l,m),...c.paths},components:y}}async function RA(r,n){let i={};for(let m of r.routes){let c=m.handler[vc];if(!c){if(n.options.includeEmptyPaths)$y({route:m,paths:i});continue}let l=m.method;if(l!=="ALL"){if(n.options.excludeMethods?.includes(l))continue;if(!PA.includes(l))continue}let y=n.options.defaultOptions?.[l],{schema:j,components:A={}}=await YA(c,y);n.components=$c(n.components,A),$y({route:m,specs:j,paths:i})}return i}function ZA(r){let{valueOrFunc:n,c:i,method:m,path:c}=r;if(n!=null){if(typeof n==="boolean")return n;if(typeof n==="function")return n({c:i,method:m,path:c})}return!1}async function YA(r,n){if("spec"in r){let c={},l={...n,...r.spec,responses:{...n?.responses,...r.spec.responses}};if(l.responses)for(let y of Object.keys(l.responses)){let j=l.responses[y];if(!j||!("content"in j))continue;for(let A of Object.keys(j.content??{})){let S=j.content?.[A];if(!S)continue;if(S.schema&&"toOpenAPISchema"in S.schema){let v=await S.schema.toOpenAPISchema();if(S.schema=v.schema,v.components)c=$c(c,v.components)}}}return{schema:l,components:c}}let i=await r.toOpenAPISchema(),m=n??{};if(r.target==="form"||r.target==="json"){let c=r.options?.media??r.target==="json"?"application/json":"multipart/form-data";if(!m.requestBody||!("content"in m.requestBody)||!m.requestBody.content)m.requestBody={content:{[c]:{schema:i.schema}}};else m.requestBody.content[c]={schema:i.schema}}else{let c=[];if("$ref"in i.schema){let y=i.schema.$ref.split("/").pop();if(y&&i.components?.schemas?.[y]){let j=i.components.schemas[y],A=Ey(r.target,j)[0];if(!i.components.parameters)i.components.parameters={};i.components.parameters[y]=A,delete i.components.schemas[y],c.push({$ref:`#/components/parameters/${y}`})}}else c=Ey(r.target,i.schema);m.parameters=c}return{schema:m,components:i.components}}function Ey(r,n){let i=[];for(let[m,c]of Object.entries(n.properties??{})){let l={in:r==="param"?"path":r,name:m,schema:c};if(n.required?.includes(m))l.required=!0;if(l.schema&&"description"in l.schema&&l.schema.description)l.description=l.schema.description,l.schema.description=void 0;i.push(l)}return i}function $c(...r){return r.reduce((n,i,m)=>{if(i==null||m===0)return n;if(n.schemas&&Object.keys(n.schemas).length>0||i.schemas&&Object.keys(i.schemas).length>0)n.schemas={...n.schemas,...i.schemas};if(n.parameters&&Object.keys(n.parameters).length>0||i.parameters&&Object.keys(i.parameters).length>0)n.parameters={...n.parameters,...i.parameters};return n},r[0]??{})}function $(r,n){return{vendor:r["~standard"].vendor,validate:r["~standard"].validate,toJSONSchema:(i)=>Ny(r,{...n,...i}),toOpenAPISchema:(i)=>Sc(r,{...n,...i})}}function D(r,n,i,m){let c=Ay(r,n,i);return Object.assign(c,{[vc]:{target:r,...$(n,m),options:m}})}function G(r){return Object.assign(async(i,m)=>{await m()},{[vc]:{spec:r}})}var Gc=(r,n,i)=>{return(m,c)=>{let l=-1;return y(0);async function y(j){if(j<=l)throw Error("next() called multiple times");l=j;let A,S=!1,v;if(r[j])v=r[j][0][0],m.req.routeIndex=j;else v=j===r.length&&c||void 0;if(v)try{A=await v(m,()=>y(j+1))}catch(w){if(w instanceof Error&&n)m.error=w,A=await n(w,m),S=!0;else throw w}else if(m.finalized===!1&&i)A=await i(m);if(A&&(m.finalized===!1||S))m.res=A;return m}}};var Dy=Symbol();var Ec=(r)=>("headers"in r),Py=async(r,n=Object.create(null))=>{let{all:i=!1,dot:m=!1}=n,y=(Ec(r)?r.headers:r.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();if(y==="multipart/form-data"||y==="application/x-www-form-urlencoded")return VA(r,{all:i,dot:m});return{}};async function VA(r,n){let i=Ec(r)?r.headers:r.raw.headers,m=await r.arrayBuffer(),c=zm(m,i.get("Content-Type")||"");if(!Ec(r))r.bodyCache.formData=c;let l=await c;if(l)return JA(l,n);return{}}function JA(r,n){let i=Object.create(null);if(r.forEach((m,c)=>{if(!(n.all||c.endsWith("[]")))i[c]=m;else oA(i,c,m)}),n.dot)Object.entries(i).forEach(([m,c])=>{if(m.includes("."))OA(i,m,c),delete i[m]});return i}var oA=(r,n,i)=>{if(r[n]!==void 0)if(Array.isArray(r[n]))r[n].push(i);else r[n]=[r[n],i];else if(!n.endsWith("[]"))r[n]=i;else r[n]=[i]},OA=(r,n,i)=>{if(/(?:^|\.)__proto__\./.test(n))return;let m=r,c=n.split(".");c.forEach((l,y)=>{if(y===c.length-1)m[l]=i;else{if(!m[l]||typeof m[l]!=="object"||Array.isArray(m[l])||m[l]instanceof File)m[l]=Object.create(null);m=m[l]}})};var Uy=(r)=>vi(r,Ti),Cy=class{raw;#r;#n;routeIndex=0;path;bodyCache={};constructor(r,n="/",i=[[]]){this.raw=r,this.path=n,this.#n=i,this.#r={}}param(r){return r?this.#i(r):this.#l()}#i(r){let n=this.#n[0][this.routeIndex][1][r],i=this.#c(n);return i&&/\%/.test(i)?Uy(i):i}#l(){let r={},n=Object.keys(this.#n[0][this.routeIndex][1]);for(let i of n){let m=this.#c(this.#n[0][this.routeIndex][1][i]);if(m!==void 0)r[i]=/\%/.test(m)?Uy(m):m}return r}#c(r){return this.#n[1]?this.#n[1][r]:r}query(r){return iy(this.url,r)}queries(r){return my(this.url,r)}header(r){if(r)return this.raw.headers.get(r)??void 0;let n={};return this.raw.headers.forEach((i,m)=>{n[m]=i}),n}async parseBody(r){return Py(this,r)}#m=(r)=>{let{bodyCache:n,raw:i}=this,m=n[r];if(m)return m;let c=Object.keys(n)[0];if(c)return n[c].then((l)=>{if(c==="json")l=JSON.stringify(l);return new Response(l)[r]()});return n[r]=i[r]()};json(){return this.#m("text").then((r)=>JSON.parse(r))}text(){return this.#m("text")}arrayBuffer(){return this.#m("arrayBuffer")}bytes(){return this.#m("arrayBuffer").then((r)=>new Uint8Array(r))}blob(){return this.#m("blob")}formData(){return this.#m("formData")}addValidatedData(r,n){this.#r[r]=n}valid(r){return this.#r[r]}get url(){return this.raw.url}get method(){return this.raw.method}get[Dy](){return this.#n}get matchedRoutes(){return this.#n[0].map(([[,r]])=>r)}get routePath(){return this.#n[0].map(([[,r]])=>r)[this.routeIndex].path}};var Fm={Stringify:1,BeforeStream:2,Stream:3},Wy=(r,n)=>{let i=new String(r);return i.isEscaped=!0,i.callbacks=n,i};var Mi=async(r,n,i,m,c)=>{if(typeof r==="object"&&!(r instanceof String)){if(!(r instanceof Promise))r=r.toString();if(r instanceof Promise)r=await r}let l=r.callbacks;if(!l?.length)return Promise.resolve(r);if(c)c[0]+=r;else c=[r];let y=Promise.all(l.map((j)=>j({phase:n,buffer:c,context:m}))).then((j)=>Promise.all(j.filter(Boolean).map((A)=>Mi(A,n,!1,m,c))).then(()=>c[0]));if(i)return Wy(await y,l);else return y};var Xy="text/plain; charset=UTF-8",Nc=(r,n)=>{return{"Content-Type":r,...n}},hi=(r,n)=>new Response(r,n),Qc=class{#r;#n;env={};#i;finalized=!1;error;#l;#c;#m;#S;#I;#A;#j;#v;#w;constructor(r,n){if(this.#r=r,n)this.#c=n.executionCtx,this.env=n.env,this.#A=n.notFoundHandler,this.#w=n.path,this.#v=n.matchResult}get req(){return this.#n??=new Cy(this.#r,this.#w,this.#v),this.#n}get event(){if(this.#c&&"respondWith"in this.#c)return this.#c;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#c)return this.#c;else throw Error("This context has no ExecutionContext")}get res(){return this.#m||=hi(null,{headers:this.#j??=new Headers})}set res(r){if(this.#m&&r){r=hi(r.body,r);for(let[n,i]of this.#m.headers.entries()){if(n==="content-type")continue;if(n==="set-cookie"){let m=this.#m.headers.getSetCookie();r.headers.delete("set-cookie");for(let c of m)r.headers.append("set-cookie",c)}else r.headers.set(n,i)}}this.#m=r,this.finalized=!0}render=(...r)=>{return this.#I??=(n)=>this.html(n),this.#I(...r)};setLayout=(r)=>this.#S=r;getLayout=()=>this.#S;setRenderer=(r)=>{this.#I=r};header=(r,n,i)=>{if(this.finalized)this.#m=hi(this.#m.body,this.#m);let m=this.#m?this.#m.headers:this.#j??=new Headers;if(n===void 0)m.delete(r);else if(i?.append)m.append(r,n);else m.set(r,n)};status=(r)=>{this.#l=r};set=(r,n)=>{this.#i??=new Map,this.#i.set(r,n)};get=(r)=>{return this.#i?this.#i.get(r):void 0};get var(){if(!this.#i)return{};return Object.fromEntries(this.#i)}#y(r,n,i){let m=this.#m?new Headers(this.#m.headers):this.#j??new Headers;if(typeof n==="object"&&"headers"in n){let l=n.headers instanceof Headers?n.headers:new Headers(n.headers);for(let[y,j]of l)if(y.toLowerCase()==="set-cookie")m.append(y,j);else m.set(y,j)}if(i)for(let[l,y]of Object.entries(i))if(typeof y==="string")m.set(l,y);else{m.delete(l);for(let j of y)m.append(l,j)}let c=typeof n==="number"?n:n?.status??this.#l;return hi(r,{status:c,headers:m})}newResponse=(...r)=>this.#y(...r);body=(r,n,i)=>this.#y(r,n,i);text=(r,n,i)=>{return!this.#j&&!this.#l&&!n&&!i&&!this.finalized?new Response(r):this.#y(r,n,Nc(Xy,i))};json=(r,n,i)=>{return this.#y(JSON.stringify(r),n,Nc("application/json",i))};html=(r,n,i)=>{let m=(c)=>this.#y(c,n,Nc("text/html; charset=UTF-8",i));return typeof r==="object"?Mi(r,Fm.Stringify,!1,{}).then(m):m(r)};redirect=(r,n)=>{let i=String(r);return this.header("Location",!/[^\x00-\xFF]/.test(i)?i:encodeURI(i)),this.newResponse(null,n??302)};notFound=()=>{return this.#A??=()=>hi(),this.#A(this)}};var B="ALL",Ky="all",Hy=["get","post","put","delete","options","patch"],Tm="Can not add a route since the matcher is already built.",Mm=class extends Error{};var Dc="__COMPOSED_HANDLER";var LA=(r)=>{return r.text("404 Not Found",404)},Ry=(r,n)=>{if("getResponse"in r){let i=r.getResponse();return n.newResponse(i.body,i)}return console.error(r),n.text("Internal Server Error",500)},Zy=class r{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#r="/";routes=[];constructor(n={}){[...Hy,Ky].forEach((l)=>{this[l]=(y,...j)=>{if(typeof y==="string")this.#r=y;else this.#l(l,this.#r,y);return j.forEach((A)=>{this.#l(l,this.#r,A)}),this}}),this.on=(l,y,...j)=>{for(let A of[y].flat()){this.#r=A;for(let S of[l].flat())j.map((v)=>{this.#l(S.toUpperCase(),this.#r,v)})}return this},this.use=(l,...y)=>{if(typeof l==="string")this.#r=l;else this.#r="*",y.unshift(l);return y.forEach((j)=>{this.#l(B,this.#r,j)}),this};let{strict:m,...c}=n;Object.assign(this,c),this.getPath=m??!0?n.getPath??lc:ry}#n(){let n=new r({router:this.router,getPath:this.getPath});return n.errorHandler=this.errorHandler,n.#i=this.#i,n.routes=this.routes,n}#i=LA;errorHandler=Ry;route(n,i){let m=this.basePath(n);return i.routes.map((c)=>{let l;if(i.errorHandler===Ry)l=c.handler;else l=async(y,j)=>(await Gc([],i.errorHandler)(y,()=>c.handler(y,j))).res,l[Dc]=c.handler;m.#l(c.method,c.path,l,c.basePath)}),this}basePath(n){let i=this.#n();return i._basePath=Jn(this._basePath,n),i}onError=(n)=>{return this.errorHandler=n,this};notFound=(n)=>{return this.#i=n,this};mount(n,i,m){let c,l;if(m)if(typeof m==="function")l=m;else if(l=m.optionHandler,m.replaceRequest===!1)c=(A)=>A;else c=m.replaceRequest;let y=l?(A)=>{let S=l(A);return Array.isArray(S)?S:[S]}:(A)=>{let S=void 0;try{S=A.executionCtx}catch{}return[A.env,S]};c||=(()=>{let A=Jn(this._basePath,n),S=A==="/"?0:A.length;return(v)=>{let w=new URL(v.url);return w.pathname=this.getPath(v).slice(S)||"/",new Request(w,v)}})();let j=async(A,S)=>{let v=await i(c(A.req.raw),...y(A));if(v)return v;await S()};return this.#l(B,Jn(n,"*"),j),this}#l(n,i,m,c){n=n.toUpperCase(),i=Jn(this._basePath,i);let l={basePath:c!==void 0?Jn(this._basePath,c):this._basePath,path:i,method:n,handler:m};this.router.add(n,i,[m,l]),this.routes.push(l)}#c(n,i){if(n instanceof Error)return this.errorHandler(n,i);throw n}#m(n,i,m,c){if(c==="HEAD")return(async()=>new Response(null,await this.#m(n,i,m,"GET")))();let l=this.getPath(n,{env:m}),y=this.router.match(c,l),j=new Qc(n,{path:l,matchResult:y,env:m,executionCtx:i,notFoundHandler:this.#i});if(y[0].length===1){let S;try{S=y[0][0][0][0](j,async()=>{j.res=await this.#i(j)})}catch(v){return this.#c(v,j)}return S instanceof Promise?S.then((v)=>v||(j.finalized?j.res:this.#i(j))).catch((v)=>this.#c(v,j)):S??this.#i(j)}let A=Gc(y[0],this.errorHandler,this.#i);return(async()=>{try{let S=await A(j);if(!S.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return S.res}catch(S){return this.#c(S,j)}})()}fetch=(n,...i)=>{return this.#m(n,i[1],i[0],n.method)};request=(n,i,m,c)=>{if(n instanceof Request)return this.fetch(i?new Request(n,i):n,m,c);return n=n.toString(),this.fetch(new Request(/^https?:\/\//.test(n)?n:`http://localhost${Jn("/",n)}`,i),m,c)};fire=()=>{addEventListener("fetch",(n)=>{n.respondWith(this.#m(n.request,n,void 0,n.request.method))})}};var Bi=[];function hm(r,n){let i=this.buildAllMatchers(),m=(c,l)=>{let y=i[c]||i[B],j=y[2][l];if(j)return j;let A=l.match(y[0]);if(!A)return[[],Bi];let S=A.indexOf("",1);return[y[1][S],A]};return this.match=m,m(r,n)}var Bm="[^/]+",xi=".*",ki="(?:|/.*)",tn=Symbol(),qA=new Set(".\\+*[^]$()");function _A(r,n){if(r.length===1)return n.length===1?r<n?-1:1:-1;if(n.length===1)return 1;if(r===xi||r===ki)return 1;else if(n===xi||n===ki)return-1;if(r===Bm)return 1;else if(n===Bm)return-1;return r.length===n.length?r<n?-1:1:n.length-r.length}var Yy=class r{#r;#n;#i=Object.create(null);insert(n,i,m,c,l){if(n.length===0){if(this.#r!==void 0)throw tn;if(l)return;this.#r=i;return}let[y,...j]=n,A=y==="*"?j.length===0?["","",xi]:["","",Bm]:y==="/*"?["","",ki]:y.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),S;if(A){let v=A[1],w=A[2]||Bm;if(v&&A[2]){if(w===".*")throw tn;if(w=w.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(w))throw tn}if(S=this.#i[w],!S){if(Object.keys(this.#i).some((E)=>E!==xi&&E!==ki))throw tn;if(l)return;if(S=this.#i[w]=new r,v!=="")S.#n=c.varIndex++}if(!l&&v!=="")m.push([v,S.#n])}else if(S=this.#i[y],!S){if(Object.keys(this.#i).some((v)=>v.length>1&&v!==xi&&v!==ki))throw tn;if(l)return;S=this.#i[y]=new r}S.insert(j,i,m,c,l)}buildRegExpStr(){let i=Object.keys(this.#i).sort(_A).map((m)=>{let c=this.#i[m];return(typeof c.#n==="number"?`(${m})@${c.#n}`:qA.has(m)?`\\${m}`:m)+c.buildRegExpStr()});if(typeof this.#r==="number")i.unshift(`#${this.#r}`);if(i.length===0)return"";if(i.length===1)return i[0];return"(?:"+i.join("|")+")"}};var Vy=class{#r={varIndex:0};#n=new Yy;insert(r,n,i){let m=[],c=[];for(let y=0;;){let j=!1;if(r=r.replace(/\{[^}]+\}/g,(A)=>{let S=`@\\${y}`;return c[y]=[S,A],y++,j=!0,S}),!j)break}let l=r.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let y=c.length-1;y>=0;y--){let[j]=c[y];for(let A=l.length-1;A>=0;A--)if(l[A].indexOf(j)!==-1){l[A]=l[A].replace(j,c[y][1]);break}}return this.#n.insert(l,n,m,this.#r,i),m}buildRegExp(){let r=this.#n.buildRegExpStr();if(r==="")return[/^$/,[],[]];let n=0,i=[],m=[];return r=r.replace(/#(\d+)|@(\d+)|\.\*\$/g,(c,l,y)=>{if(l!==void 0)return i[++n]=Number(l),"$()";if(y!==void 0)return m[Number(y)]=++n,"";return""}),[new RegExp(`^${r}`),i,m]}};var gA=[/^$/,[],Object.create(null)],Jy=Object.create(null);function oy(r){return Jy[r]??=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(n,i)=>i?`\\${i}`:"(?:|/.*)")}$`)}function zA(){Jy=Object.create(null)}function FA(r){let n=new Vy,i=[];if(r.length===0)return gA;let m=r.map((S)=>[!/\*|\/:/.test(S[0]),...S]).sort(([S,v],[w,E])=>S?1:w?-1:v.length-E.length),c=Object.create(null);for(let S=0,v=-1,w=m.length;S<w;S++){let[E,N,Q]=m[S];if(E)c[N]=[Q.map(([R])=>[R,Object.create(null)]),Bi];else v++;let W;try{W=n.insert(N,v,E)}catch(R){throw R===tn?new Mm(N):R}if(E)continue;i[v]=Q.map(([R,X])=>{let K=Object.create(null);X-=1;for(;X>=0;X--){let[J,L]=W[X];K[J]=L}return[R,K]})}let[l,y,j]=n.buildRegExp();for(let S=0,v=i.length;S<v;S++)for(let w=0,E=i[S].length;w<E;w++){let N=i[S][w]?.[1];if(!N)continue;let Q=Object.keys(N);for(let W=0,R=Q.length;W<R;W++)N[Q[W]]=j[N[Q[W]]]}let A=[];for(let S in y)A[S]=i[y[S]];return[l,A,c]}function $i(r,n){if(!r)return;for(let i of Object.keys(r).sort((m,c)=>c.length-m.length))if(oy(i).test(n))return[...r[i]];return}var xm=class{name="RegExpRouter";#r;#n;constructor(){this.#r={[B]:Object.create(null)},this.#n={[B]:Object.create(null)}}add(r,n,i){let m=this.#r,c=this.#n;if(!m||!c)throw Error(Tm);if(!m[r])[m,c].forEach((j)=>{j[r]=Object.create(null),Object.keys(j[B]).forEach((A)=>{j[r][A]=[...j[B][A]]})});if(n==="/*")n="*";let l=(n.match(/\/:/g)||[]).length;if(/\*$/.test(n)){let j=oy(n);if(r===B)Object.keys(m).forEach((A)=>{m[A][n]||=$i(m[A],n)||$i(m[B],n)||[]});else m[r][n]||=$i(m[r],n)||$i(m[B],n)||[];Object.keys(m).forEach((A)=>{if(r===B||r===A)Object.keys(m[A]).forEach((S)=>{j.test(S)&&m[A][S].push([i,l])})}),Object.keys(c).forEach((A)=>{if(r===B||r===A)Object.keys(c[A]).forEach((S)=>j.test(S)&&c[A][S].push([i,l]))});return}let y=gm(n)||[n];for(let j=0,A=y.length;j<A;j++){let S=y[j];Object.keys(c).forEach((v)=>{if(r===B||r===v)c[v][S]||=[...$i(m[v],S)||$i(m[B],S)||[]],c[v][S].push([i,l-A+j+1])})}}match=hm;buildAllMatchers(){let r=Object.create(null);return Object.keys(this.#n).concat(Object.keys(this.#r)).forEach((n)=>{r[n]||=this.#i(n)}),this.#r=this.#n=void 0,zA(),r}#i(r){let n=[],i=r===B;if([this.#r,this.#n].forEach((m)=>{let c=m[r]?Object.keys(m[r]).map((l)=>[l,m[r][l]]):[];if(c.length!==0)i||=!0,n.push(...c);else if(r!==B)n.push(...Object.keys(m[B]).map((l)=>[l,m[B][l]]))}),!i)return null;else return FA(n)}};var TA=class{name="PreparedRegExpRouter";#r;#n;constructor(r,n){this.#r=r,this.#n=n}#i(r,n){let i=this.#r[r];i[1].forEach((m)=>m&&m.push(n)),Object.values(i[2]).forEach((m)=>m[0].push(n))}#l(r,n,i,m,c){let l=this.#r[r];if(!c)l[2][n][0].push([i,{}]);else m.forEach((y)=>{if(typeof y==="number")l[1][y].push([i,c]);else l[2][y||n][0].push([i,c])})}add(r,n,i){if(!this.#r[r]){let c=this.#r[B],l={};for(let y in c[2])l[y]=[c[2][y][0].slice(),Bi];this.#r[r]=[c[0],c[1].map((y)=>Array.isArray(y)?y.slice():0),l]}if(n==="/*"||n==="*"){let c=[i,{}];if(r===B)for(let l in this.#r)this.#i(l,c);else this.#i(r,c);return}let m=this.#n[n];if(!m)throw Error(`Path ${n} is not registered`);for(let[c,l]of m)if(r===B)for(let y in this.#r)this.#l(y,n,i,c,l);else this.#l(r,n,i,c,l)}buildAllMatchers(){return this.#r}match=hm};var Pc=class{name="SmartRouter";#r=[];#n=[];constructor(r){this.#r=r.routers}add(r,n,i){if(!this.#n)throw Error(Tm);this.#n.push([r,n,i])}match(r,n){if(!this.#n)throw Error("Fatal error");let i=this.#r,m=this.#n,c=i.length,l=0,y;for(;l<c;l++){let j=i[l];try{for(let A=0,S=m.length;A<S;A++)j.add(...m[A]);y=j.match(r,n)}catch(A){if(A instanceof Mm)continue;throw A}this.match=j.match.bind(j),this.#r=[j],this.#n=void 0;break}if(l===c)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,y}get activeRouter(){if(this.#n||this.#r.length!==1)throw Error("No active router has been determined yet.");return this.#r[0]}};var ai=Object.create(null),MA=(r)=>{for(let n in r)return!0;return!1},Oy=class r{#r;#n;#i;#l=0;#c=ai;constructor(n,i,m){if(this.#n=m||Object.create(null),this.#r=[],n&&i){let c=Object.create(null);c[n]={handler:i,possibleKeys:[],score:0},this.#r=[c]}this.#i=[]}insert(n,i,m){this.#l=++this.#l;let c=this,l=bl(i),y=[];for(let j=0,A=l.length;j<A;j++){let S=l[j],v=l[j+1],w=sl(S,v),E=Array.isArray(w)?w[0]:S;if(E in c.#n){if(c=c.#n[E],w)y.push(w[1]);continue}if(c.#n[E]=new r,w)c.#i.push(w),y.push(w[1]);c=c.#n[E]}return c.#r.push({[n]:{handler:m,possibleKeys:y.filter((j,A,S)=>S.indexOf(j)===A),score:this.#l}}),c}#m(n,i,m,c,l){for(let y=0,j=i.#r.length;y<j;y++){let A=i.#r[y],S=A[m]||A[B],v={};if(S!==void 0){if(S.params=Object.create(null),n.push(S),c!==ai||l&&l!==ai)for(let w=0,E=S.possibleKeys.length;w<E;w++){let N=S.possibleKeys[w],Q=v[S.score];S.params[N]=l?.[N]&&!Q?l[N]:c[N]??l?.[N],v[S.score]=!0}}}}search(n,i){let m=[];this.#c=ai;let l=[this],y=cc(i),j=[],A=y.length,S=null;for(let v=0;v<A;v++){let w=y[v],E=v===A-1,N=[];for(let W=0,R=l.length;W<R;W++){let X=l[W],K=X.#n[w];if(K)if(K.#c=X.#c,E){if(K.#n["*"])this.#m(m,K.#n["*"],n,X.#c);this.#m(m,K,n,X.#c)}else N.push(K);for(let J=0,L=X.#i.length;J<L;J++){let z=X.#i[J],O=X.#c===ai?{}:{...X.#c};if(z==="*"){let hr=X.#n["*"];if(hr)this.#m(m,hr,n,X.#c),hr.#c=O,N.push(hr);continue}let[f,Mr,Yr]=z;if(!w&&!(Yr instanceof RegExp))continue;let x=X.#n[f];if(Yr instanceof RegExp){if(S===null){S=Array(A);let Si=i[0]==="/"?1:0;for(let Fi=0;Fi<A;Fi++)S[Fi]=Si,Si+=y[Fi].length+1}let hr=i.substring(S[v]),Vn=Yr.exec(hr);if(Vn){if(O[Mr]=Vn[0],this.#m(m,x,n,X.#c,O),Vn[0].length===hr.length&&x.#n["*"])this.#m(m,x.#n["*"],n,X.#c,O);if(MA(x.#n)){x.#c=O;let Si=Vn[0].match(/\//)?.length??0;(j[Si]||=[]).push(x)}continue}}if(Yr===!0||Yr.test(w))if(O[Mr]=w,E){if(this.#m(m,x,n,O,X.#c),x.#n["*"])this.#m(m,x.#n["*"],n,O,X.#c)}else x.#c=O,N.push(x)}}let Q=j.shift();l=Q?N.concat(Q):N}if(m.length>1)m.sort((v,w)=>{return v.score-w.score});return[m.map(({handler:v,params:w})=>[v,w])]}};var Uc=class{name="TrieRouter";#r;constructor(){this.#r=new Oy}add(r,n,i){let m=gm(n);if(m){for(let c=0,l=m.length;c<l;c++)this.#r.insert(r,m[c],i);return}this.#r.insert(r,n,i)}match(r,n){return this.#r.search(r,n)}};var Z=class extends Zy{constructor(r={}){super(r);this.router=r.router??new Pc({routers:[new xm,new Uc]})}};var Cc=/^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|msgpack|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|vnd\.msgpack|wasm|x-httpd-php|x-javascript|x-msgpack|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml|msgpack))(?:[;\s]|$)/i;var hA={br:".br",zstd:".zst",gzip:".gz"},ME=Object.keys(hA);var Wc="x-hono-disable-ssg",lN=(()=>{try{return new Response("SSG is disabled",{status:404,headers:{[Wc]:"true"}})}catch{return null}})();var{write:hN}=Bun;var Ly=class{#r;constructor(r){this.#r=r,this.raw=r.raw,this.url=r.url?new URL(r.url):null,this.protocol=r.protocol??null}send(r,n){this.#r.send(r,n??{})}raw;binaryType="arraybuffer";get readyState(){return this.#r.readyState}url;protocol;close(r,n){this.#r.close(r,n)}},qy=(r)=>{return new MessageEvent("message",{data:r})},_y=(r)=>{return(...n)=>{if(typeof n[0]==="function"){let[i,m]=n;return async function(l,y){let j=await i(l),A=await r(l,j,m);if(A)return A;await y()}}else{let[i,m,c]=n;return(async()=>{let l=await r(i,m,c);if(!l)throw Error("Failed to upgrade WebSocket");return l})()}}};var km=(r)=>("server"in r.env)?r.env.server:r.env;var Xc=(r)=>{return new Ly({send:(n,i)=>{r.send(n,i?.compress)},raw:r,readyState:r.readyState,url:r.data.url,protocol:r.data.protocol,close(n,i){r.close(n,i)}})},gy=_y((r,n)=>{let i=km(r);if(!i)throw TypeError("env has to include the 2nd argument of fetch.");if(i.upgrade(r.req.raw,{data:{events:n,url:new URL(r.req.url),protocol:r.req.header("sec-websocket-protocol")?.split(",")[0]?.trim()??""}}))return new Response(null);return}),zy={open(r){let n=r.data.events;if(n.onOpen)n.onOpen(new Event("open"),Xc(r))},close(r,n,i){let m=r.data.events;if(m.onClose)m.onClose(new CloseEvent("close",{code:n,reason:i}),Xc(r))},message(r,n){let i=r.data.events;if(i.onMessage){let m=typeof n==="string"?n:n.buffer;i.onMessage(qy(m),Xc(r))}}},Kc=()=>({upgradeWebSocket:gy,websocket:zy});var Fy={create(r){let n=Kc();return{upgradeWebSocket:n.upgradeWebSocket,async listen(i){let m={fetch:r.fetch,hostname:i.hostname,idleTimeout:0,websocket:n.websocket},c=(y)=>{try{return Bun.serve({...m,port:y})}catch{return}},l=i.port===0?c(4096)??c(0):c(i.port);if(!l)throw Error(`Failed to start server on port ${i.port}`);if(!l.port)throw Error(`Failed to resolve server address for port ${i.port}`);return{port:l.port,stop(y){return Promise.resolve(l.stop(y))}}}}}};var Ni={};Er(Ni,{unpublish:()=>Rj,publish:()=>lv,MDNS:()=>Ni});var Hj=cv(Kj(),1),ti=g.create({service:"mdns"}),yn,bm;function lv(r,n){if(bm===r)return;if(yn)Rj();try{let i=n??"qitqode.local",m=`qitqode-${r}`;yn=new Hj.Bonjour;let c=yn.publish({name:m,type:"http",host:i,port:r,txt:{path:"/"}});c.on("up",()=>{ti.info("mDNS service published",{name:m,port:r})}),c.on("error",(l)=>{ti.error("mDNS service error",{error:l})}),bm=r}catch(i){if(ti.error("mDNS publish failed",{error:i}),yn)try{yn.destroy()}catch{}yn=void 0,bm=void 0}}function Rj(){if(yn){try{yn.unpublishAll(),yn.destroy()}catch(r){ti.error("mDNS unpublish failed",{error:r})}yn=void 0,bm=void 0,ti.info("mDNS service unpublished")}}var Zj=(r)=>{let n=atob(r),i=new Uint8Array(new ArrayBuffer(n.length)),m=n.length/2;for(let c=0,l=n.length-1;c<=m;c++,l--)i[c]=n.charCodeAt(c),i[l]=n.charCodeAt(l);return i};var yv=/^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/,jv=/^([^:]*):(.*)$/,Iv=new TextDecoder,Yj=(r)=>{let n=yv.exec(r.headers.get("Authorization")||"");if(!n)return;let i=void 0;try{i=jv.exec(Iv.decode(Zj(n[1])))}catch{}if(!i)return;return{username:i[1],password:i[2]}};var Vj=(r,...n)=>{let i="username"in r&&"password"in r,m="verifyUser"in r;if(!(i||m))throw Error('basic auth middleware requires options for "username and password" or "verifyUser"');if(!r.realm)r.realm="Secure Area";if(!r.invalidUserMessage)r.invalidUserMessage="Unauthorized";if(i)n.unshift({username:r.username,password:r.password});return async function(l,y){let j=Yj(l.req.raw);if(j)if(m){if(await r.verifyUser(j.username,j.password,l)){if(r.onAuthSuccess)await r.onAuthSuccess(l,j.username);await y();return}}else for(let E of n){let[N,Q]=await Promise.all([Ic(E.username,j.username,r.hashFunction),Ic(E.password,j.password,r.hashFunction)]);if(N&&Q){if(r.onAuthSuccess)await r.onAuthSuccess(l,j.username);await y();return}}let A=401,S={"WWW-Authenticate":'Basic realm="'+r.realm?.replace(/"/g,"\\\"")+'"'},v=typeof r.invalidUserMessage==="function"?await r.invalidUserMessage(l):r.invalidUserMessage,w=typeof v==="string"?new Response(v,{status:A,headers:S}):new Response(JSON.stringify(v),{status:A,headers:{...S,"content-type":"application/json"}});throw new kr(A,{res:w})}};var Jj=(r)=>{let n={origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[],...r},i=((c)=>{if(typeof c==="string")if(c==="*")return()=>c;else return(l)=>c===l?l:null;else if(typeof c==="function")return c;else return(l)=>c.includes(l)?l:null})(n.origin),m=((c)=>{if(typeof c==="function")return c;else if(Array.isArray(c))return()=>c;else return()=>[]})(n.allowMethods);return async function(l,y){function j(S,v){l.res.headers.set(S,v)}let A=await i(l.req.header("origin")||"",l);if(A)j("Access-Control-Allow-Origin",A);if(n.credentials)j("Access-Control-Allow-Credentials","true");if(n.exposeHeaders?.length)j("Access-Control-Expose-Headers",n.exposeHeaders.join(","));if(l.req.method==="OPTIONS"){if(n.origin!=="*")j("Vary","Origin");if(n.maxAge!=null)j("Access-Control-Max-Age",n.maxAge.toString());let S=await m(l.req.header("origin")||"",l);if(S.length)j("Access-Control-Allow-Methods",S.join(","));let v=n.allowHeaders;if(!v?.length){let w=l.req.header("Access-Control-Request-Headers");if(w)v=w.split(/\s*,\s*/)}if(v?.length)j("Access-Control-Allow-Headers",v.join(",")),l.res.headers.append("Vary","Access-Control-Request-Headers");return l.res.headers.delete("Content-Length"),l.res.headers.delete("Content-Type"),new Response(null,{headers:l.res.headers,status:204,statusText:"No Content"})}if(await y(),n.origin!=="*")l.header("Vary","Origin",{append:!0})}};var Oj=(r)=>r===32||r===9||r===10||r===13,sm=(r,n)=>{while(n<r.length){if(!Oj(r.charCodeAt(n)))break;n++}return n},ei=(r,n)=>{while(n>0){if(!Oj(r.charCodeAt(n-1)))break;n--}return n},oj=(r,n)=>{while(n<r.length){let i=r.charCodeAt(n);if(i===59)return[n+1,!0];if(i===44)return[n+1,!1];n++}return[n,!1]},Av=(r,n)=>{let i=n,m=!1;while(i<r.length){let c=r.charCodeAt(i);if(m&&c===92)i++;else if(c===34)m=!m;else if(!m&&c===44)return i+1;i++}return i},Sv=(r,n)=>{n=sm(r,n);let i=n,m,c,l=!1;while(i<r.length){let A=r.charCodeAt(i);if(A===61){m=r.slice(n,ei(r,i)),i++;break}if(A===59)return[i+1,void 0,void 0,!0];if(A===44)return[i+1,void 0,void 0,!1];i++}if(m===void 0)return[i,void 0,void 0,!1];if(i=sm(r,i),r.charCodeAt(i)===61){let A=oj(r,i+1);return[A[0],m,void 0,A[1]]}let y=!1,j=i;while(i<r.length){let A=r.charCodeAt(i);if(y&&A===92)i++;else if(A===34){if(y){let S=sm(r,i+1),v=r.charCodeAt(S);if(S<r.length&&!(v===59||v===44)){let w=oj(r,S);return[w[0],m,void 0,w[1]]}if(c=r.slice(j+1,i),c.includes("\\"))c=c.replace(/\\(.)/g,"$1");if(v===44)return[S+1,m,c,!1];if(v===59)l=!0,S++;i=S;break}y=!0}else if(!y&&(A===59||A===44)){if(c=r.slice(j,ei(r,i)),A===59)l=!0;i++;break}i++}return[i,m,c??r.slice(j,ei(r,i)),l]},vv=(r,n)=>{let i={type:"",params:{},q:1};n=sm(r,n);let m=n;while(m<r.length){let j=r.charCodeAt(m);if(j===59||j===44){if(i.type=r.slice(n,ei(r,m)),m++,j===44)return[m,i.type?i:void 0];if(!i.type)return[Av(r,m),void 0];break}m++}if(!i.type)return i.type=r.slice(n,ei(r,r.length)),[r.length,i.type?i:void 0];let c,l,y;while(m<r.length){if([m,c,l,y]=Sv(r,m),c&&l)i.params[c]=l;if(!y)break}return[m,i]},Lj=(r)=>{if(!r)return[];let n=[],i=0,m,c=!1,l;while(i<r.length)if([i,m]=vv(r,i),m){if(m.q=wv(m.params.q),n.push(m),l&&l.q<m.q)c=!0;l=m}if(c)n.sort((y,j)=>j.q-y.q);return n},wv=(r)=>{if(r===void 0)return 1;if(r==="")return 1;if(r==="NaN")return 0;let n=Number(r);if(n===1/0)return 1;if(n===-1/0)return 0;if(Number.isNaN(n))return 1;if(n<0||n>1)return 1;return n};var $v=["gzip","deflate"],Gv=/(?:^|,)\s*?no-transform\s*?(?:,|$)/i,Ev=(r,n)=>{if(r===void 0)return;let i=Lj(r),m=i.find((l)=>l.type==="*")?.q,c;for(let l of n){let y=i.find((A)=>A.type.toLowerCase()===l),j=y?y.q:m??0;if(j===1)return l;else if(j>0&&(!c||j>c.q))c={encoding:l,q:j}}return c?.encoding},qj=(r)=>{let n=r?.threshold??1024,i=r?.encoding?[r.encoding]:$v,m=r?.contentTypeFilter??Cc,c=typeof m==="function"?(l)=>{let y=l.headers.get("Content-Type");return y&&m(y)}:(l)=>{let y=l.headers.get("Content-Type");return y&&m.test(y)};return async function(y,j){await j();let A=y.res.headers.get("Content-Length");if(y.res.status===206||y.res.headers.has("Content-Encoding")||y.res.headers.has("Transfer-Encoding")||y.req.method==="HEAD"||A&&Number(A)<n||!c(y.res)||!Nv(y.res))return;let S=y.req.header("Accept-Encoding"),v=Ev(S,i);if(!v||!y.res.body)return;let w=new CompressionStream(v);y.res=new Response(y.res.body.pipeThrough(w),y.res),y.res.headers.delete("Content-Length"),y.res.headers.set("Content-Encoding",v);let E=y.res.headers.get("ETag");if(E&&!E.startsWith("W/"))y.res.headers.set("ETag",`W/${E}`)}},Nv=(r)=>{let n=r.headers.get("Cache-Control");return!n||!Gv.test(n)};import{randomUUID as Qv}from"crypto";var fm="ticket",_j="x-qitqode-ticket",gj="1",Dv=/^\/pty\/[^/]+\/connect$/,Pv=60000,bi=new Map;function Uv(){let r=Date.now();for(let[n,i]of bi)if(i.expiresAt<=r)bi.delete(n)}function zj(r){return Dv.test(r)}function Fj(r,n=Pv){Uv();let i=Qv();return bi.set(i,{ptyID:r,expiresAt:Date.now()+n}),{ticket:i,expires_in:Math.round(n/1000)}}function Tj(r,n){let i=bi.get(r);if(!i)return!1;if(bi.delete(r),i.expiresAt<=Date.now())return!1;return i.ptyID===n}var r0=g.create({service:"server"}),Mj=(r,n)=>{let i=crypto.randomUUID();r0.error("failed",{error_id:i,error:r});let m=()=>n.json(new Qi.Unknown({message:"Internal server error"}).toObject(),{status:500,headers:{"x-qitqode-error-id":i}});if(r instanceof Qi){let c;if(r instanceof Wn)c=404;else if(r instanceof nr.ModelNotFoundError)c=400;else if(r.name==="ProviderAuthValidationFailed")c=400;else if(r.name.startsWith("Worktree"))c=400;else c=500;if(c===500)return m();return n.json(r.toObject(),{status:c})}if(r instanceof V.BusyError)return n.json(new Qi.Unknown({message:r.message}).toObject(),{status:409});if(r instanceof kr)return r.getResponse();return m()},hj=(r,n)=>{if(r.req.method==="OPTIONS")return n();let i=k.QITQODE_SERVER_PASSWORD;if(!i)return n();let m=new URL(r.req.url).pathname;if(zj(m)&&r.req.query(fm))return n();let c=k.QITQODE_SERVER_USERNAME??"qitqode";return Vj({username:c,password:i})(r,n)},Bj=async(r,n)=>{let i=r.req.path==="/log";if(!i)r0.info("request",{method:r.req.method,path:r.req.path});let m=r0.time("request",{method:r.req.method,path:r.req.path});if(await n(),!i)m.stop()};function xj(r){return Jj({maxAge:86400,origin(n){if(!n)return;if(r?.cors?.includes(n))return n}})}function Cv(r){return r==="localhost"||r==="::1"||/^127(\.\d{1,3}){3}$/.test(r)||r==="127.0.0.1"}function Wv(r){if(r.startsWith("[")){let n=r.indexOf("]");return n===-1?r:r.slice(1,n)}return r.split(":")[0]}function kj(r){let n=r.hostname===void 0,i=r.hostname==="0.0.0.0"||r.hostname==="::";return(m,c)=>{if(n||i)return c();let l=m.req.header("host");if(!l)return c();let y=Wv(l);if(Cv(y))return c();if(r.hostname&&y===r.hostname)return c();if(r.mdnsDomain&&y===r.mdnsDomain)return c();if(r.allowedHosts?.includes(y))return c();throw r0.warn("rejected request with unexpected Host header",{host:y}),new kr(403,{message:`Forbidden: unexpected Host header "${y}"`})}}var Xv=qj(),aj=(r,n)=>{let i=r.req.path,m=r.req.method;if(i==="/event"||i==="/global/event")return n();if(m==="POST"&&/\/session\/[^/]+\/(message|prompt_async)$/.test(i))return n();return Xv(r,n)};var a={};Er(a,{waitForSync:()=>gv,status:()=>qv,startWorkspaceSyncing:()=>pc,sessionRestore:()=>Jv,remove:()=>Ov,list:()=>ov,isSyncing:()=>_v,get:()=>nI,create:()=>Yv,Workspace:()=>a,Info:()=>n0,Event:()=>fi,ConnectionStatus:()=>rI});var pj=["forgewise"];var Kv=new TextEncoder;function Hv(r){return Kv.encode(r).byteLength}function uj(r,n=16384){let i=[...pj.filter((l)=>(l in r)),...Object.keys(r).filter((l)=>!pj.includes(l))],m={},c=0;for(let l of i){let y={...m,[l]:r[l]},j=JSON.stringify(y);if(Hv(j)>n)continue;m[l]=r[l],c+=1}if(c===0)return;return JSON.stringify(m)}var Hr=dj("workspace",{id:Ln().$type().primaryKey(),type:Ln().notNull(),name:Ln().notNull().default(""),branch:Ln(),directory:Ln(),extra:Ln({mode:"json"}),project_id:Ln().$type().notNull().references(()=>tj.id,{onDelete:"cascade"})});async function ej(r,n,i){let m=r.getReader(),c=new TextDecoder,l="",y="",j=1000,A=()=>{m.cancel().catch(()=>{return})};if(n.addEventListener("abort",A),n.aborted)A();try{while(!n.aborted){let S=await m.read().catch(()=>({done:!0,value:void 0}));if(S.done)break;l+=c.decode(S.value,{stream:!0}),l=l.replace(/\r\n/g,`
|
|
3
|
-
`).replace(/\r/g,`
|
|
4
|
-
`);let v=l.split(`
|
|
5
|
-
|
|
6
|
-
`);l=v.pop()??"",v.forEach((w)=>{let E=[],N=(W)=>{let R=W.slice(W.indexOf(":")+1);return R.startsWith(" ")?R.slice(1):R};if(w.split(`
|
|
7
|
-
`).forEach((W)=>{if(W.startsWith("data:")){E.push(N(W));return}if(W.startsWith("id:")){y=N(W);return}if(W.startsWith("retry:")){let R=Number.parseInt(N(W),10);if(!Number.isNaN(R))j=R}}),!E.length)return;let Q=E.join(`
|
|
8
|
-
`);try{i(JSON.parse(Q))}catch{i({type:"sse.message",properties:{data:Q,id:y||void 0,retry:j}})}})}}finally{n.removeEventListener("abort",A),m.releaseLock()}}function ac(r){if(r.signal?.aborted)return Promise.reject(r.signal.reason??Error("Request aborted"));return new Promise((n,i)=>{let m=()=>{l(),i(r.signal?.reason??Error("Request aborted"))},c=(j)=>{try{if(!r.fn(j))return;l(),n()}catch(A){l(),i(A)}},l=()=>{clearTimeout(y),Or.off("event",c),r.signal?.removeEventListener("abort",m)},y=setTimeout(()=>{l(),i(Error("Timed out waiting for global event"))},r.timeout);if(Or.on("event",c),r.signal?.addEventListener("abort",m,{once:!0}),r.signal?.aborted)m()})}var n0=fj.meta({ref:"Workspace"}),rI=I.object({workspaceID:Lr.zod,status:I.enum(["connected","connecting","disconnected","error"])}),Rv=I.object({workspaceID:Lr.zod,sessionID:er.zod,total:I.number().int().min(0),step:I.number().int().min(0)}),fi={Ready:jn.define("workspace.ready",I.object({name:I.string()})),Failed:jn.define("workspace.failed",I.object({message:I.string()})),Restore:jn.define("workspace.restore",Rv),Status:jn.define("workspace.status",rI)};function y0(r){return{id:r.id,type:r.type,branch:r.branch,name:r.name,directory:r.directory,extra:r.extra,projectID:r.project_id}}var Zv=I.object({id:Lr.zod.optional(),type:n0.shape.type,branch:n0.shape.branch,projectID:l0.zod,extra:n0.shape.extra}),Yv=nm(Zv,async(r)=>{let n=Lr.ascending(r.id),i=await _n(r.projectID,r.type),m=await i.configure({...r,id:n,name:sj.create(),directory:null}),c={id:n,type:m.type,branch:m.branch??null,name:m.name??null,directory:m.directory??null,extra:m.extra??null,projectID:r.projectID};e.use((A)=>{A.insert(Hr).values({id:c.id,type:c.type,branch:c.branch,name:c.name,directory:c.directory,extra:c.extra,project_id:c.projectID}).run()});let l=uj(await b.runPromise(ii.Service.use((A)=>A.all()))),y={...l!==void 0?{QITQODE_AUTH_CONTENT:l}:{},QITQODE_WORKSPACE_ID:m.id,QITQODE_EXPERIMENTAL_WORKSPACES:"true",OTEL_EXPORTER_OTLP_HEADERS:process.env.OTEL_EXPORTER_OTLP_HEADERS,OTEL_EXPORTER_OTLP_ENDPOINT:process.env.OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_RESOURCE_ATTRIBUTES:process.env.OTEL_RESOURCE_ATTRIBUTES};await i.create(m,y);let j=ac({timeout:iI,fn(A){if(A.workspace===c.id&&A.payload.type===fi.Status.type){let{status:S}=A.payload.properties;return S==="error"||S==="connected"}return!1}});return await mI(c),await j,c}),Vv=I.object({workspaceID:Lr.zod,sessionID:er.zod}),Jv=nm(Vv,async(r)=>{Ir.info("session restore requested",{workspaceID:r.workspaceID,sessionID:r.sessionID});try{let n=await nI(r.workspaceID);if(!n)throw Error(`Workspace not found: ${r.workspaceID}`);let m=await(await _n(n.projectID,n.type)).target(n);yr.run(V.Event.Updated,{sessionID:r.sessionID,info:{workspaceID:r.workspaceID}});let c=e.use((S)=>S.select({id:Rr.id,aggregateID:Rr.aggregate_id,seq:Rr.seq,type:Rr.type,data:Rr.data}).from(Rr).where(d(Rr.aggregate_id,r.sessionID)).orderBy(c0(Rr.seq)).all());if(c.length===0)throw Error(`No events found for session: ${r.sessionID}`);let l=c,y=100,j=Array.from({length:Math.ceil(l.length/y)},(S,v)=>l.slice(v*y,(v+1)*y)),A=j.length;Ir.info("session restore prepared",{workspaceID:r.workspaceID,sessionID:r.sessionID,workspaceType:n.type,directory:n.directory,target:m.type==="remote"?String(si(m.url,"/sync/replay")):m.directory,events:l.length,batches:A,first:l[0]?.seq,last:l.at(-1)?.seq}),Or.emit("event",{directory:"global",workspace:r.workspaceID,payload:{type:fi.Restore.type,properties:{workspaceID:r.workspaceID,sessionID:r.sessionID,total:A,step:0}}});for(let[S,v]of j.entries()){if(Ir.info("session restore batch starting",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,events:v.length,first:v[0]?.seq,last:v.at(-1)?.seq,target:m.type==="remote"?String(si(m.url,"/sync/replay")):m.directory}),m.type==="local")yr.replayAll(v),Ir.info("session restore batch replayed locally",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,events:v.length});else{let w=si(m.url,"/sync/replay"),E=new Headers(m.headers);E.set("content-type","application/json");let N=await fetch(w,{method:"POST",headers:E,body:JSON.stringify({directory:n.directory??"",events:v})});if(!N.ok){let Q=await N.text();throw Ir.error("session restore batch failed",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,status:N.status,body:Q}),Error(`Failed to replay session ${r.sessionID} into workspace ${r.workspaceID}: HTTP ${N.status} ${Q}`)}Ir.info("session restore batch posted",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,status:N.status})}Or.emit("event",{directory:"global",workspace:r.workspaceID,payload:{type:fi.Restore.type,properties:{workspaceID:r.workspaceID,sessionID:r.sessionID,total:A,step:S+1}}})}return Ir.info("session restore complete",{workspaceID:r.workspaceID,sessionID:r.sessionID,batches:A}),{total:A}}catch(n){throw Ir.error("session restore failed",{workspaceID:r.workspaceID,sessionID:r.sessionID,error:m0(n)}),n}});function ov(r){return e.use((m)=>m.select().from(Hr).where(d(Hr.project_id,r.id)).all()).map(y0).sort((m,c)=>m.id.localeCompare(c.id))}var nI=nm(Lr.zod,async(r)=>{let n=e.use((i)=>i.select().from(Hr).where(d(Hr.id,r)).get());if(!n)return;return y0(n)}),Ov=nm(Lr.zod,async(r)=>{let n=e.use((m)=>m.select({id:ir.id}).from(ir).where(d(ir.workspace_id,r)).all());for(let m of n)await b.runPromise(V.Service.use((c)=>c.remove(m.id)));let i=e.use((m)=>m.select().from(Hr).where(d(Hr.id,r)).get());if(i){Mv(r);let m=y0(i);try{await(await _n(m.projectID,i.type)).remove(m)}catch{Ir.error("adaptor not available when removing workspace",{type:i.type})}return e.use((c)=>c.delete(Hr).where(d(Hr.id,r)).run()),m}}),i0=new Map,Di=new Map,iI=5000;function Lv(r,n){return new Promise((i)=>{if(n.aborted){i();return}let m=()=>{clearTimeout(c),n.removeEventListener("abort",m),i()},c=setTimeout(m,r);if(n.addEventListener("abort",m,{once:!0}),n.aborted)m()})}function qn(r,n){if(i0.get(r)?.status===n)return;let m={workspaceID:r,status:n};i0.set(r,m),Or.emit("event",{directory:"global",workspace:r,payload:{type:fi.Status.type,properties:m}})}function qv(){return[...i0.values()]}function bj(r){let n=Object.keys(r);if(n.length===0)return!0;let i=Object.fromEntries(e.use((m)=>m.select({id:tr.aggregate_id,seq:tr.seq}).from(tr).where(rm(tr.aggregate_id,n)).all()).map((m)=>[m.id,m.seq]));return n.every((m)=>{return(i[m]??-1)>=r[m]})}async function _v(r){return Di.has(r)}async function gv(r,n,i){if(bj(n))return;try{await ac({timeout:iI,signal:i,fn(m){if(m.workspace!==r||m.payload.type!=="sync")return!1;return bj(n)}})}catch{if(i?.aborted)throw i.reason??Error("Request aborted");throw Error(`Timed out waiting for sync fence: ${JSON.stringify(n)}`)}}var Ir=g.create({service:"workspace-sync"});function si(r,n){let i=new URL(r);return i.pathname=`${i.pathname.replace(/\/$/,"")}${n}`,i.search="",i.hash="",i}async function zv(r,n,i){let m=await fetch(si(r,"/global/event"),{method:"GET",headers:n,signal:i});if(!m.ok)throw Error(`Workspace sync HTTP failure: ${m.status}`);if(!m.body)throw Error("No response body from global sync");return m.body}async function Fv(r,n,i,m){let c=e.use((S)=>S.select({id:ir.id}).from(ir).where(d(ir.workspace_id,r.id)).all().map((v)=>v.id)),l=c.length?Object.fromEntries(e.use((S)=>S.select().from(tr).where(rm(tr.aggregate_id,c)).all()).map((S)=>[S.aggregate_id,S.seq])):{};Ir.info("syncing workspace history",{workspaceID:r.id,sessions:c.length,known:Object.keys(l).length});let y=new Headers(i);y.set("content-type","application/json");let j=await fetch(si(n,"/sync/history"),{method:"POST",headers:y,body:JSON.stringify(l),signal:m});if(!j.ok){let S=await j.text();throw Error(`Workspace history HTTP failure: ${j.status} ${S}`)}let A=await j.json();return Ir.info("workspace history synced",{workspaceID:r.id,events:A.length}),Pi.provide({workspaceID:r.id,fn:()=>{for(let S of A)yr.replay({id:S.id,aggregateID:S.aggregate_id,seq:S.seq,type:S.type,data:S.data},{publish:!0})}})}async function Tv(r,n){let m=await(await _n(r.projectID,r.type)).target(r);if(m.type==="local")return null;let c=0;while(!n.aborted){Ir.info("connecting to global sync",{workspace:r.name}),qn(r.id,"connecting");let l;try{l=await zv(m.url,m.headers,n),await Fv(r,m.url,m.headers,n)}catch(y){await l?.cancel().catch(()=>{return}),l=null,qn(r.id,"error"),Ir.info("failed to connect to global sync",{workspace:r.name,err:y})}if(l)c=0,Ir.info("global sync connected",{workspace:r.name}),qn(r.id,"connected"),await ej(l,n,(y)=>{try{if(!("payload"in y))return;if(y.payload.type==="server.heartbeat")return;if(y.payload.type==="sync")yr.replay(y.payload.syncEvent);Or.emit("event",{directory:y.directory,project:y.project,workspace:r.id,payload:y.payload})}catch(j){Ir.info("failed to replay global event",{workspaceID:r.id,error:j})}}),Ir.info("disconnected from global sync: "+r.id),qn(r.id,"disconnected");await Lv(Math.min(120000,1000*2**c),n),c+=1}}async function mI(r){if(!k.QITQODE_EXPERIMENTAL_WORKSPACES)return;let i=await(await _n(r.projectID,r.type)).target(r);if(i.type==="local"){Xn.exists(i.directory).then((c)=>{qn(r.id,c?"connected":"error")});return}if(Di.has(r.id))return!0;qn(r.id,"disconnected");let m=new AbortController;Di.set(r.id,m),Tv(r,m.signal).catch((c)=>{Di.delete(r.id),qn(r.id,"error"),Ir.warn("workspace listener failed",{workspaceID:r.id,error:c})})}function Mv(r){Di.get(r)?.abort(),Di.delete(r),i0.delete(r)}function pc(r){let n=e.use((i)=>i.select({workspace:Hr}).from(Hr).innerJoin(ir,d(ir.workspace_id,Hr.id)).where(d(Hr.project_id,r)).all());for(let i of new Map(n.map((m)=>[m.workspace.id,m.workspace])).values()){let m=y0(i);mI(m).catch((c)=>{qn(m.id,"error"),Ir.warn("failed to start workspace sync",{workspaceID:m.id,error:c})})}}var lI="x-qitqode-sync",uc=g.create({service:"fence"});function cI(r){let n=e.use((i)=>{if(!r?.length)return i.select().from(tr).all();return i.select().from(tr).where(rm(tr.aggregate_id,r)).all()});return Object.fromEntries(n.map((i)=>[i.aggregate_id,i.seq]))}function hv(r,n){let i=new Set([...Object.keys(r),...Object.keys(n)]);return Object.fromEntries([...i].map((m)=>[m,n[m]??-1]).filter(([m,c])=>{return(r[m]??-1)!==c}))}function yI(r){let n=r.get(lI);if(!n)return;let i;try{i=JSON.parse(n)}catch{return}if(!i||typeof i!=="object")return;return Object.fromEntries(Object.entries(i).filter(([m,c])=>{return typeof m==="string"&&Number.isInteger(c)}))}async function jI(r,n,i){uc.info("waiting for state",{workspaceID:r,state:n}),await a.waitForSync(r,n,i),uc.info("state fully synced",{workspaceID:r,state:n})}var II=async(r,n)=>{if(r.req.method==="GET"||r.req.method==="HEAD"||r.req.method==="OPTIONS")return n();let i=cI();await n();let m=hv(i,cI());if(Object.keys(m).length>0)uc.info("header",{diff:m}),r.res.headers.set(lI,JSON.stringify(m))};var AI=g.create({service:"session.projector"});function SI(r){if(typeof r!=="object"||r===null)return!1;if("code"in r&&r.code==="SQLITE_CONSTRAINT_FOREIGNKEY")return!0;return"message"in r&&typeof r.message==="string"&&r.message.includes("FOREIGN KEY constraint failed")}function h(r,n,i){if(r==null||!(n in r))return;let m=r[n];if(m&&typeof m==="object"&&i)return i(m);if(m===void 0)throw Error("Session update failure: pass `null` to clear a field instead of `undefined`: "+JSON.stringify(r));return m}function xv(r){let n={id:h(r,"id"),project_id:h(r,"projectID"),workspace_id:h(r,"workspaceID"),parent_id:h(r,"parentID"),context_from:h(r,"contextFrom"),context_watermark:h(r,"contextWatermark"),slug:h(r,"slug"),directory:h(r,"directory"),title:h(r,"title"),version:h(r,"version"),share_url:h(r,"share",(i)=>h(i,"url")),summary_additions:h(r,"summary",(i)=>h(i,"additions")),summary_deletions:h(r,"summary",(i)=>h(i,"deletions")),summary_files:h(r,"summary",(i)=>h(i,"files")),summary_diffs:h(r,"summary",(i)=>h(i,"diffs")),revert:h(r,"revert"),permission:h(r,"permission"),time_created:h(r,"time",(i)=>h(i,"created")),time_updated:h(r,"time",(i)=>h(i,"updated")),time_compacting:h(r,"time",(i)=>h(i,"compacting")),time_archived:h(r,"time",(i)=>h(i,"archived"))};return Object.fromEntries(Object.entries(n).filter(([i,m])=>m!==void 0))}var vI=[yr.project(j0.Created,(r,n)=>{r.insert(ir).values(wI(n.info)).run()}),yr.project(j0.Updated,(r,n)=>{let i=n.info;if(!r.update(ir).set(xv(i)).where(d(ir.id,n.sessionID)).returning().get())throw new Wn({message:`Session not found: ${n.sessionID}`})}),yr.project(j0.Deleted,(r,n)=>{r.delete(ir).where(d(ir.id,n.sessionID)).run()}),yr.project(vr.Event.Updated,(r,n)=>{let i=n.info.time.created,{id:m,sessionID:c,agentID:l,...y}=n.info;try{r.insert(Kn).values({id:m,session_id:c,agent_id:l??"main",time_created:i,data:y}).onConflictDoUpdate({target:Kn.id,set:{agent_id:l??"main",data:y}}).run()}catch(j){if(!SI(j))throw j;AI.warn("ignored late message update",{messageID:m,sessionID:c})}}),yr.project(vr.Event.Removed,(r,n)=>{r.delete(Kn).where(im(d(Kn.id,n.messageID),d(Kn.session_id,n.sessionID))).run()}),yr.project(vr.Event.PartRemoved,(r,n)=>{r.delete(Hn).where(im(d(Hn.id,n.partID),d(Hn.session_id,n.sessionID))).run()}),yr.project(vr.Event.PartUpdated,(r,n)=>{let{id:i,messageID:m,sessionID:c,...l}=n.part;try{r.insert(Hn).values({id:i,message_id:m,session_id:c,time_created:n.time,data:l}).onConflictDoUpdate({target:Hn.id,set:{data:l}}).run()}catch(y){if(!SI(y))throw y;AI.warn("ignored late part update",{partID:i,messageID:m,sessionID:c})}})];function dc(){yr.init({projectors:vI,convertEvent:(r,n)=>{if(r==="session.updated"){let i=n.sessionID,m=e.use((c)=>c.select().from(ir).where(d(ir.id,i)).get());if(!m)return n;return{sessionID:i,info:V.fromRow(m)}}return n}})}dc();class Ui{queue=[];resolvers=[];capacity;maxWeight;itemWeight;totalWeight=0;dropped=0;droppedWeight=0;constructor(r){this.capacity=r?.capacity??1/0,this.maxWeight=r?.maxWeight??1/0,this.itemWeight=r?.weight??(()=>1)}push(r){let n=this.resolvers.shift();if(n)return n(r),!0;let i=this.itemWeight(r);if(!Number.isFinite(i)||i<0)throw Error("Queue item weight must be a finite non-negative number");if(this.capacity<=0)return this.dropped++,this.droppedWeight+=i,!1;if(i>this.maxWeight)return this.dropped++,this.droppedWeight+=i,!1;while(this.queue.length>=this.capacity||this.totalWeight+i>this.maxWeight){let m=this.queue.shift();if(!m)break;this.totalWeight-=m.weight,this.dropped++,this.droppedWeight+=m.weight}return this.queue.push({item:r,weight:i}),this.totalWeight+=i,!0}get size(){return this.queue.length}get bufferedWeight(){return this.totalWeight}async next(){if(this.queue.length>0){let r=this.queue.shift();return this.totalWeight-=r.weight,r.item}return new Promise((r)=>this.resolvers.push(r))}async*[Symbol.asyncIterator](){while(!0)yield await this.next()}}var kv={400:{description:"Bad request",content:{"application/json":{schema:$(I.object({data:I.any(),errors:I.array(I.record(I.string(),I.any())),success:I.literal(!1)}).meta({ref:"BadRequestError"}))}}},404:{description:"Not found",content:{"application/json":{schema:$(Wn.Schema)}}},409:{description:"Conflict \u2014 session resource is busy",content:{"application/json":{schema:$(I.object({name:I.literal("UnknownError"),data:I.object({message:I.string()})}).meta({ref:"ConflictError"}))}}}};function U(...r){return Object.fromEntries(r.map((n)=>[n,kv[n]]))}function av(r){let n=r.match(/^(.+)ID$/);if(n)return`${n[1].toLowerCase()}.id`;return`qitqode.${r}`}function pv(r){let n={"http.method":r.req.method,"http.path":new URL(r.req.url).pathname};for(let[i,m]of Object.entries(r.req.param()))n[av(i)]=m;return n}function p(r,n,i){return b.runPromise(i.pipe(C.withSpan(r,{attributes:pv(n)})))}async function P(r,n,i){return n.json(await p(r,n,C.gen(()=>i(n))))}var uv=I.object({path:I.string(),body:I.any()}),dv=new Ui,tv=new Ui;var ev=new Z().get("/next",G({summary:"Get next TUI request",description:"Retrieve the next TUI (Terminal User Interface) request from the queue for processing.",operationId:"tui.control.next",responses:{200:{description:"Next TUI request",content:{"application/json":{schema:$(uv)}}}}}),async(r)=>{let n=await dv.next();return r.json(n)}).post("/response",G({summary:"Submit TUI response",description:"Submit a response to the TUI request queue to complete a pending request.",operationId:"tui.control.response",responses:{200:{description:"Response submitted successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("json",I.any()),async(r)=>{let n=r.req.valid("json");return tv.push(n),r.json(!0)}),$I=q(()=>new Z().post("/append-prompt",G({summary:"Append TUI prompt",description:"Append prompt to the TUI",operationId:"tui.appendPrompt",responses:{200:{description:"Prompt processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("json",Nr.PromptAppend.properties),async(r)=>{return await wr.publish(Nr.PromptAppend,r.req.valid("json")),r.json(!0)}).post("/open-help",G({summary:"Open help dialog",description:"Open the help dialog in the TUI to display user assistance information.",operationId:"tui.openHelp",responses:{200:{description:"Help dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Nr.CommandExecute,{command:"help.show"}),r.json(!0)}).post("/open-sessions",G({summary:"Open sessions dialog",description:"Open the session dialog",operationId:"tui.openSessions",responses:{200:{description:"Session dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Nr.CommandExecute,{command:"session.list"}),r.json(!0)}).post("/open-themes",G({summary:"Open themes dialog",description:"Open the theme dialog",operationId:"tui.openThemes",responses:{200:{description:"Theme dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Nr.CommandExecute,{command:"session.list"}),r.json(!0)}).post("/open-models",G({summary:"Open models dialog",description:"Open the model dialog",operationId:"tui.openModels",responses:{200:{description:"Model dialog opened successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Nr.CommandExecute,{command:"model.list"}),r.json(!0)}).post("/submit-prompt",G({summary:"Submit TUI prompt",description:"Submit the prompt",operationId:"tui.submitPrompt",responses:{200:{description:"Prompt submitted successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Nr.CommandExecute,{command:"prompt.submit"}),r.json(!0)}).post("/clear-prompt",G({summary:"Clear TUI prompt",description:"Clear the prompt",operationId:"tui.clearPrompt",responses:{200:{description:"Prompt cleared successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return await wr.publish(Nr.CommandExecute,{command:"prompt.clear"}),r.json(!0)}).post("/execute-command",G({summary:"Execute TUI command",description:"Execute a TUI command (e.g. agent_cycle)",operationId:"tui.executeCommand",responses:{200:{description:"Command executed successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("json",I.object({command:I.string()})),async(r)=>{let n=r.req.valid("json").command;return await wr.publish(Nr.CommandExecute,{command:{session_new:"session.new",session_share:"session.share",session_interrupt:"session.interrupt",session_compact:"session.compact",messages_page_up:"session.page.up",messages_page_down:"session.page.down",messages_line_up:"session.line.up",messages_line_down:"session.line.down",messages_half_page_up:"session.half.page.up",messages_half_page_down:"session.half.page.down",messages_first:"session.first",messages_last:"session.last",agent_cycle:"agent.cycle"}[n]}),r.json(!0)}).post("/show-toast",G({summary:"Show TUI toast",description:"Show a toast notification in the TUI",operationId:"tui.showToast",responses:{200:{description:"Toast notification shown successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("json",Nr.ToastShow.properties),async(r)=>{return await wr.publish(Nr.ToastShow,r.req.valid("json")),r.json(!0)}).post("/publish",G({summary:"Publish TUI event",description:"Publish a TUI event",operationId:"tui.publish",responses:{200:{description:"Event published successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("json",I.union(Object.values(Nr).map((r)=>{return I.object({type:I.literal(r.type),properties:r.properties}).meta({ref:`Event.${r.type}`})}))),async(r)=>{let n=r.req.valid("json");return await wr.publish(Object.values(Nr).find((i)=>i.type===n.type),n.properties),r.json(!0)}).post("/select-session",G({summary:"Select session",description:"Navigate the TUI to display the specified session.",operationId:"tui.selectSession",responses:{200:{description:"Session selected successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),D("json",Nr.SessionSelect.properties),async(r)=>{let{sessionID:n}=r.req.valid("json");return await p("TuiRoutes.sessionSelect",r,V.Service.use((i)=>i.get(n))),await wr.publish(Nr.SessionSelect,{sessionID:n}),r.json(!0)}).route("/control",ev));var bv=I.object({answers:qr.Answer.zod.array().describe("User answers in order of questions (each answer is an array of selected labels)")}),GI=()=>D("param",I.object({requestID:mm.zod})),EI=q(()=>new Z().get("/",G({summary:"List pending questions",description:"Get all pending question requests across all sessions.",operationId:"question.list",responses:{200:{description:"List of pending questions",content:{"application/json":{schema:$(qr.Request.zod.array())}}}}}),async(r)=>P("QuestionRoutes.list",r,function*(){return yield*(yield*qr.Service).list()})).get("/never-ask",G({summary:"Get never-ask state",description:"Whether the question tool auto-resolves to a [Never-Ask] directive instead of blocking for a user.",operationId:"question.neverAsk",responses:{200:{description:"Current never-ask state",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>P("QuestionRoutes.neverAsk",r,function*(){return yield*(yield*qr.Service).neverAsk()})).post("/never-ask",G({summary:"Set never-ask state",description:"Enable or disable never-ask: the question tool stays visible but returns a [Never-Ask] directive so the model resolves decisions itself.",operationId:"question.setNeverAsk",responses:{200:{description:"Updated never-ask state",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("json",I.object({enabled:I.boolean().describe("Whether never-ask is enabled")})),async(r)=>P("QuestionRoutes.setNeverAsk",r,function*(){let n=yield*qr.Service;return yield*n.setNeverAsk(r.req.valid("json").enabled),yield*n.neverAsk()})).post("/:requestID/reply",G({summary:"Reply to question request",description:"Provide answers to a question request from the AI assistant.",operationId:"question.reply",responses:{200:{description:"Question answered successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),GI(),D("json",bv),async(r)=>P("QuestionRoutes.reply",r,function*(){let n=r.req.valid("param"),i=r.req.valid("json");return yield*(yield*qr.Service).reply({requestID:n.requestID,answers:i.answers}),!0})).post("/:requestID/reject",G({summary:"Reject question request",description:"Reject a question request from the AI assistant.",operationId:"question.reject",responses:{200:{description:"Question rejected successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),GI(),async(r)=>P("QuestionRoutes.reject",r,function*(){let n=r.req.valid("param");return yield*(yield*qr.Service).reject(n.requestID),!0})));function I0(r){return C.gen(function*(){return yield*(yield*Qr.Service).reply(r),!0})}var NI=q(()=>new Z().post("/:requestID/reply",G({summary:"Respond to permission request",description:"Approve or deny a permission request from the AI assistant.",operationId:"permission.reply",responses:{200:{description:"Permission processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),D("param",I.object({requestID:Ci.zod})),D("json",I.object({reply:Qr.Reply.zod,message:I.string().optional()})),async(r)=>P("PermissionRoutes.reply",r,function*(){let n=r.req.valid("param"),i=r.req.valid("json");return yield*I0({requestID:n.requestID,reply:i.reply,message:i.message})})).get("/",G({summary:"List pending permissions",description:"Get all pending permission requests across all sessions.",operationId:"permission.list",responses:{200:{description:"List of pending permissions",content:{"application/json":{schema:$(Qr.Request.zod.array())}}}}}),async(r)=>P("PermissionRoutes.list",r,function*(){return yield*(yield*Qr.Service).list()})));var DI=q(()=>new Z().get("/",G({summary:"List workflow runs",description:"List dynamic-workflow runs for a session. sessionID is REQUIRED \u2014 there is no per-user identity, so the session is the access boundary and an omitted/invalid sessionID is a 400 (never an unfiltered all-session listing). Empty when the workflow runtime is not running.",operationId:"workflow.list",responses:{200:{description:"Workflow runs",content:{"application/json":{schema:$(I.array(I.any()))}}}}}),D("query",I.object({sessionID:QI.schema("session")})),async(r)=>P("WorkflowRoutes.list",r,function*(){let n=tc.current;if(!n)return[];let i=r.req.valid("query");return yield*n.list({sessionID:i.sessionID})})).post("/:runID/resume",G({summary:"Resume a workflow run",description:"Re-launch a persisted workflow run by id. Returns { runID, resumed }; resumed is false if the run is unknown, still running, or has no persisted script.",operationId:"workflow.resume",responses:{200:{description:"Resume result",content:{"application/json":{schema:$(I.object({runID:I.string(),resumed:I.boolean()}))}}}}}),D("param",I.object({runID:I.string().regex(/^wf_[0-9A-Za-z]{26}$/,"invalid workflow runID")})),async(r)=>P("WorkflowRoutes.resume",r,function*(){let n=tc.current,i=r.req.valid("param");if(!n)return{runID:i.runID,resumed:!1};return yield*n.resume({runID:i.runID})})));var sv=I.object({output:I.string().describe("Captured output from the interactive command"),exitCode:I.number().describe("Exit code of the interactive command")}),PI=q(()=>new Z().get("/",G({summary:"List pending interactive bash requests",description:"Get all pending interactive bash requests waiting for user interaction.",operationId:"bash.interactive.list",responses:{200:{description:"List of pending interactive requests",content:{"application/json":{schema:$(I.array(I.object({id:I.string(),command:I.string(),cwd:I.string(),description:I.string()})))}}}}}),async(r)=>P("BashInteractiveRoutes.list",r,function*(){return yield*(yield*ec).list()})).post("/:id/reply",G({summary:"Reply to interactive bash request",description:"Provide the result of an interactive bash command execution.",operationId:"bash.interactive.reply",responses:{200:{description:"Reply accepted",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),D("param",I.object({id:I.string()})),D("json",sv),async(r)=>P("BashInteractiveRoutes.reply",r,function*(){let n=r.req.valid("param"),i=r.req.valid("json");return yield*(yield*ec).reply({id:n.id,output:i.output,exitCode:i.exitCode}),!0})));var Xm={};Er(Xm,{webHandler:()=>k4,routes:()=>n2,ExperimentalHttpApiServer:()=>Xm});var Tr={};Er(Tr,{reflect:()=>yl,make:()=>dw,isHttpApi:()=>pw,AdditionalSchemas:()=>R0});var u={};Er(u,{put:()=>Mw,post:()=>Tw,patch:()=>hw,options:()=>kw,make:()=>Fn,isHttpApiEndpoint:()=>Ow,head:()=>xw,getSuccessSchemas:()=>mi,getPayloadSchemas:()=>Lw,getErrorSchemas:()=>ci,get:()=>Fw,delete:()=>Bw});var Yi={};Er(Yi,{UnauthorizedNoContent:()=>Uw,Unauthorized:()=>v0,ServiceUnavailableNoContent:()=>Jw,ServiceUnavailable:()=>C0,RequestTimeoutNoContent:()=>Hw,RequestTimeout:()=>N0,NotImplementedNoContent:()=>Vw,NotImplemented:()=>U0,NotFoundNoContent:()=>Ww,NotFound:()=>$0,NotAcceptableNoContent:()=>Kw,NotAcceptable:()=>E0,MethodNotAllowedNoContent:()=>Xw,MethodNotAllowed:()=>G0,InternalServerErrorNoContent:()=>Yw,InternalServerError:()=>P0,GoneNoContent:()=>Zw,Gone:()=>D0,ForbiddenNoContent:()=>Cw,Forbidden:()=>w0,ConflictNoContent:()=>Rw,Conflict:()=>Q0,BadRequestNoContent:()=>Pw,BadRequestFromSchemaError:()=>rl,BadRequest:()=>Rn});function rw(r){return(n)=>{return n.annotate({httpApiStatus:r})}}var nw=(r)=>sc.pipe(rw(r)),KI=nw(204);function Zr(r){return(n)=>{return sc.pipe(Wi(XI(n),S0({decode:r.decode,encode:UI})))}}function iw(r,n){return r.annotate({"~httpApiEncoding":{_tag:n._tag,contentType:n.contentType??mw(n._tag)}})}function mw(r){switch(r){case"Multipart":return"multipart/form-data";case"Json":return"application/json";case"FormUrlEncoded":return"application/x-www-form-urlencoded";case"Uint8Array":return"application/octet-stream";case"Text":return"text/plain"}}function HI(r){return(n)=>iw(n,{_tag:"FormUrlEncoded",...r})}var cm=(r)=>{if(A0(r))return!0;let n=WI(r);if(A0(n))return!0;let i=r.encoding?.[0].to;if(i===void 0)return!1;return A0(i)},RI=bc("~httpApiEncoding"),ZI=bc("httpApiStatus"),YI={_tag:"Json",contentType:"application/json"},cw={_tag:"FormUrlEncoded",contentType:"application/x-www-form-urlencoded"};function lw(r){return RI(r)??YI}function fc(r,n){let i=RI(r);if(i)return i;return Xi(n)?YI:cw}function Ki(r){let n=lw(r);if(n._tag==="Multipart")throw Error("Multipart is not supported in response");return n}function Hi(r){return ZI(r)??200}function Ri(r){return ZI(r)??500}var jw=Ur({status:400}),Iw=Ur({status:401}),Aw=Ur({status:403}),Sw=Ur({status:404}),vw=Ur({status:405}),ww=Ur({status:406}),$w=Ur({status:408}),Gw=Ur({status:409}),Ew=Ur({status:410}),Nw=Ur({status:500}),Qw=Ur({status:501}),Dw=Ur({status:503});class Rn extends gr("effect/HttpApiError/BadRequest")({_tag:_r("BadRequest")},{description:"BadRequest",httpApiStatus:400}){[In]=!0;[zr](){return t(jw)}static singleton=new Rn}var Pw=Rn.pipe(Zr({decode:()=>new Rn({})})),rl=Rn.pipe(Wi(Zi([W0(X0),Rn]),S0({encode:(r)=>Rn.singleton,decode:gn})),Zr({decode:()=>new Rn({})})).annotate({httpApiStatus:400,description:"BadRequest"});class v0 extends gr("effect/HttpApiError/Unauthorized")({_tag:_r("Unauthorized")},{description:"Unauthorized",httpApiStatus:401}){[In]=!0;[zr](){return t(Iw)}}var Uw=v0.pipe(Zr({decode:()=>new v0({})}));class w0 extends gr("effect/HttpApiError/Forbidden")({_tag:_r("Forbidden")},{description:"Forbidden",httpApiStatus:403}){[In]=!0;[zr](){return t(Aw)}}var Cw=w0.pipe(Zr({decode:()=>new w0({})}));class $0 extends gr("effect/HttpApiError/NotFound")({_tag:_r("NotFound")},{description:"NotFound",httpApiStatus:404}){[In]=!0;[zr](){return t(Sw)}}var Ww=$0.pipe(Zr({decode:()=>new $0({})}));class G0 extends gr("effect/HttpApiError/MethodNotAllowed")({_tag:_r("MethodNotAllowed")},{description:"MethodNotAllowed",httpApiStatus:405}){[In]=!0;[zr](){return t(vw)}}var Xw=G0.pipe(Zr({decode:()=>new G0({})}));class E0 extends gr("effect/HttpApiError/NotAcceptable")({_tag:_r("NotAcceptable")},{description:"NotAcceptable",httpApiStatus:406}){[In]=!0;[zr](){return t(ww)}}var Kw=E0.pipe(Zr({decode:()=>new E0({})}));class N0 extends gr("effect/HttpApiError/RequestTimeout")({_tag:_r("RequestTimeout")},{description:"RequestTimeout",httpApiStatus:408}){[In]=!0;[zr](){return t($w)}}var Hw=N0.pipe(Zr({decode:()=>new N0({})}));class Q0 extends gr("effect/HttpApiError/Conflict")({_tag:_r("Conflict")},{description:"Conflict",httpApiStatus:409}){[In]=!0;[zr](){return t(Gw)}}var Rw=Q0.pipe(Zr({decode:()=>new Q0({})}));class D0 extends gr("effect/HttpApiError/Gone")({_tag:_r("Gone")},{description:"Gone",httpApiStatus:410}){[In]=!0;[zr](){return t(Ew)}}var Zw=D0.pipe(Zr({decode:()=>new D0({})}));class P0 extends gr("effect/HttpApiError/InternalServerError")({_tag:_r("InternalServerError")},{description:"InternalServerError",httpApiStatus:500}){[zr](){return t(Nw)}}var Yw=P0.pipe(Zr({decode:()=>new P0({})}));class U0 extends gr("effect/HttpApiError/NotImplemented")({_tag:_r("NotImplemented")},{description:"NotImplemented",httpApiStatus:501}){[zr](){return t(Qw)}}var Vw=U0.pipe(Zr({decode:()=>new U0({})}));class C0 extends gr("effect/HttpApiError/ServiceUnavailable")({_tag:_r("ServiceUnavailable")},{description:"ServiceUnavailable",httpApiStatus:503}){[zr](){return t(Dw)}}var Jw=C0.pipe(Zr({decode:()=>new C0({})}));var il="~effect/httpapi/HttpApiEndpoint",Ow=(r)=>zn(r,il);function Lw(r){let n=[];for(let{schemas:i}of r.payload.values())n.push(...i);return n}function mi(r){let n=Array.from(r.success);return K0(n)?n:[KI]}function ci(r){let n=new Set(r.error);for(let i of r.middlewares){let m=i;for(let c of m.error)n.add(c)}return OI(Array.from(n),rl)}var qw={[il]:il,pipe(){return An(this,arguments)},prefix(r){return ym({...this,path:LI(this.path,r)})},middleware(r){return ym({...this,middlewares:new Set([...this.middlewares,r])})},annotate(r,n){return ym({...this,annotations:Sn(this.annotations,r,n)})},annotateMerge(r){return ym({...this,annotations:Fr(this.annotations,r)})}};function ym(r){return Object.assign(Object.create(qw),r)}var Fn=(r)=>(n,i,m)=>{let c=m?.disableCodecs??!1,l=c?gn:H0;return ym({name:n,path:i,method:r,params:nl(m?.params,l),query:nl(m?.query,l),headers:nl(m?.headers,l),payload:_w(m?.payload,r,c),success:VI(m?.success,c),error:VI(m?.error,c),annotations:Br(),middlewares:new Set})};function nl(r,n){if(r===void 0)return;if(ml(r))return n(r);return n(jm(r))}function _w(r,n,i){let m=new Map;if(r===void 0)return m;let c=Array.isArray(r)?r:ml(r)?[r]:[jm(r).pipe(HI())],l=i?gn:zw;for(let y of c){let j=fc(y.ast,n),A=m.get(j.contentType);if(A){if(A.encoding._tag!==j._tag)throw Error(`Multiple payload encodings for content-type: ${j.contentType}`);if(A.encoding._tag==="Multipart")throw Error(`Multiple multipart payloads for content-type: ${j.contentType}`);A.schemas.push(l(y,n))}else m.set(j.contentType,{encoding:j,schemas:[l(y,n)]})}return m}function VI(r,n){if(r===void 0)return new Set;let i=oI(r);return new Set(n?i:i.map(gw))}function gw(r){switch(Ki(r.ast)._tag){case"Json":return cl(r);case"FormUrlEncoded":return H0(r);case"Text":case"Uint8Array":return r}}function zw(r,n){switch(fc(r.ast,n)._tag){case"Json":return cl(r);case"FormUrlEncoded":return H0(r);case"Text":case"Uint8Array":case"Multipart":return r}}var Fw=Fn("GET"),Tw=Fn("POST"),Mw=Fn("PUT"),hw=Fn("PATCH"),Bw=Fn("DELETE");var xw=Fn("HEAD"),kw=Fn("OPTIONS");var ll="~effect/httpapi/HttpApi",pw=(r)=>zn(r,ll),uw={[ll]:ll,pipe(){return An(this,arguments)},add(...r){let n={...this.groups};for(let i of r)n[i.identifier]=i;return li({identifier:this.identifier,groups:n,annotations:this.annotations})},addHttpApi(r){let n={...this.groups};for(let i in r.groups){let m=r.groups[i];m.annotations=Fr(r.annotations,m.annotations),n[i]=m}return li({identifier:this.identifier,groups:n,annotations:this.annotations})},prefix(r){return li({identifier:this.identifier,groups:Tn(this.groups,(n)=>n.prefix(r)),annotations:this.annotations})},middleware(r){return li({identifier:this.identifier,groups:Tn(this.groups,(n)=>n.middleware(r)),annotations:this.annotations})},annotate(r,n){return li({identifier:this.identifier,groups:this.groups,annotations:Sn(this.annotations,r,n)})},annotateMerge(r){return li({identifier:this.identifier,groups:this.groups,annotations:Fr(this.annotations,r)})}},li=(r)=>{function n(){}return Object.setPrototypeOf(n,uw),n.groups=r.groups,n.annotations=r.annotations,n},dw=(r)=>li({identifier:r,groups:new Map,annotations:Br()}),yl=(r,n)=>{let i=Object.values(r.groups);for(let m of i){let c=Fr(r.annotations,m.annotations);n.onGroup({group:m,mergedAnnotations:c});let l=Object.values(m.endpoints);for(let y of l){if(n.predicate&&!n.predicate({endpoint:y,group:m}))continue;n.onEndpoint({group:m,endpoint:y,middleware:y.middlewares,mergedAnnotations:Fr(c,y.annotations),successes:qI(mi(y),Hi),errors:qI(ci(y),Ri)})}}},qI=(r,n)=>{let i=new Map;return r.forEach(m),i;function m(c){let l=c.ast,y=n(l),j=i.get(y);if(j===void 0)i.set(y,[c]);else j.push(c)}};class R0 extends $r()("effect/httpapi/HttpApi/AdditionalSchemas"){}var Ar={};Er(Ar,{securitySetCookie:()=>y4,securityDecode:()=>_1,layer:()=>m4,group:()=>c4,endpoint:()=>l4,HandlersTypeId:()=>q1});var Vi={};Er(Vi,{layerSchemaErrorTransform:()=>bw,layerClient:()=>sw,isSecurity:()=>Gm,Service:()=>tw});var _I="~effect/httpapi/HttpApiMiddleware",jl="~effect/httpapi/HttpApiMiddleware/Security",Gm=(r)=>zn(r,jl),tw=()=>(r,n)=>{let i=globalThis.Error,m=i.stackTraceLimit;i.stackTraceLimit=2;let c=new i;i.stackTraceLimit=m;class l extends $r()(r){}let y=l;if(Object.defineProperty(l,"stack",{get(){return c.stack}}),y[_I]=_I,y.error=ew(n?.error),y.requiredForClient=n?.requiredForClient??!1,n?.security!==void 0){if(Object.keys(n.security).length===0)throw Error("HttpApiMiddleware.Service: security object must not be empty");y[jl]=jl,y.security=n.security}return y};function ew(r){if(r===void 0)return new Set;return new Set(Array.isArray(r)?r:[r])}var bw=(r,n)=>gI(r,(i,m)=>J0(i,(c)=>X0(c)?n(c,m):wm(c))),sw=(r,n)=>Y0(vm(function*(){let i=(yield*$m()).pipe(Am(Sm)),m=V0(n)?yield*n:n;return Z0(new Map([[`${r.key}/Client`,(c)=>zI(m(c),(l)=>Fr(i,l))]]))}));var M={};Er(M,{fromApi:()=>$l,annotations:()=>n4,Version:()=>q0,Transform:()=>Oi,Title:()=>Ji,Summary:()=>Nm,Servers:()=>g0,Override:()=>oi,License:()=>_0,Identifier:()=>L0,Format:()=>z0,ExternalDocs:()=>Em,Exclude:()=>O0,Description:()=>yi,Deprecated:()=>F0});class L0 extends $r()("effect/httpapi/OpenApi/Identifier"){}class Ji extends $r()("effect/httpapi/OpenApi/Title"){}class q0 extends $r()("effect/httpapi/OpenApi/Version"){}class yi extends $r()("effect/httpapi/OpenApi/Description"){}class _0 extends $r()("effect/httpapi/OpenApi/License"){}class Em extends $r()("effect/httpapi/OpenApi/ExternalDocs"){}class g0 extends $r()("effect/httpapi/OpenApi/Servers"){}class z0 extends $r()("effect/httpapi/OpenApi/Format"){}class Nm extends $r()("effect/httpapi/OpenApi/Summary"){}class F0 extends $r()("effect/httpapi/OpenApi/Deprecated"){}class oi extends $r()("effect/httpapi/OpenApi/Override"){}var O0=uI("effect/httpapi/OpenApi/Exclude",{defaultValue:BI});class Oi extends $r()("effect/httpapi/OpenApi/Transform"){}var r4=(r)=>{let n=Object.entries(r);return(i)=>{let m=Br();for(let[c,l]of n)if(i[c]!==void 0)m=Sn(m,l,i[c]);return m}},n4=r4({identifier:L0,title:Ji,version:q0,description:yi,license:_0,summary:Nm,deprecated:F0,externalDocs:Em,servers:g0,format:z0,override:oi,exclude:O0,transform:Oi}),FI=new WeakMap;function cr(r,n,i){let m=vl(r,n);if(xI(m))i(m.value)}function $l(r,n){let i=FI.get(r);if(i!==void 0)return i;let m={openapi:"3.1.0",info:{title:"Api",version:"0.0.1"},paths:{},components:{schemas:{},securitySchemes:{}},security:[],tags:[]},c=[];cr(r.annotations,Ji,(y)=>{m.info.title=y}),cr(r.annotations,q0,(y)=>{m.info.version=y}),cr(r.annotations,yi,(y)=>{m.info.description=y}),cr(r.annotations,_0,(y)=>{m.info.license=y}),cr(r.annotations,Nm,(y)=>{m.info.summary=y}),cr(r.annotations,g0,(y)=>{m.servers=[...y]}),yl(r,{onGroup({group:y}){if(Il(y.annotations,O0))return;let j={name:o0(y.annotations,Ji,()=>y.identifier)};cr(y.annotations,yi,(A)=>{j.description=A}),cr(y.annotations,Em,(A)=>{j.externalDocs=A}),cr(y.annotations,oi,(A)=>{Object.assign(j,A)}),cr(y.annotations,Oi,(A)=>{j=A(j)}),m.tags.push(j)},onEndpoint({endpoint:y,group:j,mergedAnnotations:A,middleware:S}){if(Il(A,O0))return;let v={tags:[o0(j.annotations,Ji,()=>j.identifier)],operationId:o0(y.annotations,L0,()=>j.topLevel?y.name:`${j.identifier}.${y.name}`),parameters:[],security:[],responses:{}},w=y.path.replace(/:(\w+)\??/g,"{$1}"),E=y.method.toLowerCase();function N(K){if(K.size>0){let J={},L=!1;if(K.forEach(({encoding:z,schemas:O},f)=>{let Mr=O.filter((hr)=>!cm(hr.ast));if(Mr.length===0)return;L=!0;let Yr=Mr.map(Al),x=Yr.length===1?Yr[0]:new Sl(Yr,"anyOf");c.push({_tag:"schema",ast:hI(x,z._tag),path:["paths",w,E,"requestBody","content",f,"schema"]}),J[f]={schema:{}}}),L)v.requestBody={content:J,required:!0}}}function Q(K,J){for(let[L,{content:z,descriptions:O}]of K){let f=O.size>0?Array.from(O).join(" | "):J();if(v.responses[L]={description:f},z!==void 0)z.forEach((Mr,Yr)=>{Mr.forEach((x,hr)=>{let Vn=Array.from(x,Al),Si=Vn.length===1?Vn[0]:new Sl(Vn,"anyOf");c.push({_tag:"schema",ast:hI(Si,Yr),path:["paths",w,E,"responses",String(L),"content",hr,"schema"]}),v.responses[L].content??={},v.responses[L].content[hr]={schema:{}}})})}}function W(K,J){if(K){let L=eI(K.ast);if(tI(L))for(let z of L.propertySignatures)v.parameters.push({name:String(z.name),in:J,schema:{},required:J==="path"||!bI(z.type)}),c.push({_tag:"parameter",ast:z.type,path:["paths",w,E,"parameters",String(v.parameters.length-1),"schema"]})}}cr(y.annotations,yi,(K)=>{v.description=K}),cr(y.annotations,Nm,(K)=>{v.summary=K}),cr(y.annotations,F0,(K)=>{v.deprecated=K}),cr(y.annotations,Em,(K)=>{v.externalDocs=K}),S.forEach((K)=>{if(!Gm(K))return;for(let[J,L]of Object.entries(K.security))R(J,L),v.security.push({[J]:[]})});function R(K,J){if(m.components.securitySchemes[K]!==void 0)return;m.components.securitySchemes[K]=i4(J)}let X=Xi(y.method);if(X)N(y.payload);if(W(y.params,"path"),!X&&y.payload.size===1){let K=y.payload.values().next().value;W(K.schemas[0],"query")}if(W(y.headers,"header"),W(y.query,"query"),Q(TI(mi(y),Hi,MI),()=>"Success"),Q(TI(ci(y),Ri,MI),()=>"Error"),!m.paths[w])m.paths[w]={};cr(y.annotations,oi,(K)=>{Object.assign(v,K)}),cr(y.annotations,Oi,(K)=>{v=K(v)}),m.paths[w][E]=v}}),cr(r.annotations,R0,(y)=>{y.forEach((j)=>{let A=wl(j.ast);if(A!==void 0){if(A in m.components.schemas)throw new globalThis.Error(`Duplicate component schema identifier: ${A}`);m.components.schemas[A]={},c.push({_tag:"schema",ast:j.ast,path:["components","schemas",A]})}})});function l(y){return"/"+y.map(fI).join("/")}if(K0(c)){let y=m1(pI(c,(S)=>S.ast)),j=n1(c1(y,{additionalProperties:n?.additionalProperties})),A=c.map((S,v)=>{let w=l(S.path),E=j.schemas[v];return{op:"replace",path:w,value:E}});Object.entries(j.definitions).forEach(([S,v])=>{A.push({op:"add",path:l(["components","schemas",S]),value:v})}),m=r1(A,m)}return Object.keys(m.components.schemas).forEach((y)=>{if(!i1.test(y))throw new globalThis.Error(`Invalid component schema key: ${y}`)}),cr(r.annotations,oi,(y)=>{Object.assign(m,y)}),cr(r.annotations,Oi,(y)=>{m=y(m)}),FI.set(r,m),m}function TI(r,n,i){let m=new Map;return r.forEach(c),m;function c(j){let A=j.ast,S=n(A);if(cm(A))l(S,i(j.ast)??"<No Content>");else y(j,S,Ki(A))}function l(j,A){let S=m.get(j);if(S===void 0)m.set(j,{descriptions:new Set([A]),content:void 0});else if(A!==void 0)S.descriptions.add(A)}function y(j,A,S){let v=i(j.ast),w=m.get(A),{_tag:E,contentType:N}=S;if(w===void 0)m.set(A,{descriptions:new Set(v!==void 0?[v]:[]),content:new Map([[E,new Map([[N,new Set([j])]])]])});else if(w.content!==void 0){if(v!==void 0)w.descriptions.add(v);let Q=w.content.get(E);if(Q===void 0)w.content.set(E,new Map([[N,new Set([j])]]));else{let W=Q.get(N);if(W===void 0)Q.set(N,new Set([j]));else W.add(j)}}}}function MI(r){return sI(r)??wl(r)}var l1=Dm.annotate({format:"binary"});function hI(r,n){switch(n){case"Uint8Array":return l1.ast;case"Text":return Dm.ast;case"FormUrlEncoded":case"Json":return r;case"Multipart":return y1(r)}}function y1(r){if(dI(r)&&r.annotations?.typeConstructor?._tag==="effect/http/PersistedFile")return l1.ast;if(typeof r?.recur==="function")return r.recur(y1);return r}var i4=(r)=>{let n={};switch(cr(r.annotations,yi,(i)=>{n.description=i}),r._tag){case"Basic":return{...n,type:"http",scheme:"basic"};case"Bearer":{let i=vl(r.annotations,z0).pipe(aI((m)=>({bearerFormat:m})),kI);return{...n,type:"http",scheme:"bearer",...i}}case"ApiKey":return{...n,type:"apiKey",name:r.key,in:r.in}}};var m4=(r,n)=>O1(Ul(function*(i){let m=yield*$m(),c=[],l=Array.from(m.mapUnsafe.keys()).filter((y)=>y.startsWith("effect/httpapi/HttpApiGroup/"));for(let y of Object.values(r.groups)){let j=m.mapUnsafe.get(y.key);if(j===void 0){let A=l.length===0?"none":l.join(", ");return yield*A1(`HttpApiGroup "${y.identifier}" not found (key: "${y.key}"). Did you forget to provide HttpApiBuilder.group(api, "${y.identifier}", ...)? Available groups: ${A}`)}c.push(...j)}if(yield*i.addAll(c),n?.openapiPath){let y=$l(r);yield*i.add("GET",n.openapiPath,t(W1(y)))}})),c4=(r,n,i)=>Y0(vm(function*(){let m=(yield*$m()).pipe(Am(Sm)),c=r.groups[n],l=i(S4(c)),y=V0(l)?yield*l:l,j=[];for(let A of y.handlers)j.push($4(c,A,m));return Z0(new Map([[c.key,j]]))})),q1=Symbol.for("@effect/platform/HttpApiBuilder/Handlers"),l4=(r,n,i,m)=>w1((c)=>{let l=r.groups[n],y=l.endpoints[i];return t(g1(l,y,Am(Sm)(c),m,!1))}),_1=(r)=>{switch(r._tag){case"Bearer":return M0(x0.asEffect(),(n)=>Li((n.headers.authorization??"").slice(j4)));case"ApiKey":{let n=r.in==="header"?r.key.toLowerCase():r.key,i=jm({[n]:Dm}),m=r.in==="query"?V1(i):r.in==="cookie"?Z1(i):Y1(i);return Gl(m,{onFailure:()=>Li(""),onSuccess:(c)=>Li(c[n])})}case"Basic":{let n={username:"",password:Li("")};return x0.asEffect().pipe(Mn((i)=>$1((i.headers.authorization??"").slice(I4)).asEffect()),Gl({onFailure:()=>n,onSuccess:(i)=>{let m=i.split(":");if(m.length!==2)return n;return{username:m[0],password:Li(m[1])}}}))}}},y4=(r,n,i)=>J1((m,c)=>hn(H1(c,r.key,G1(n),{secure:!0,httpOnly:!0,...i}))),j4=7,I4=6,A4={[q1]:{_Endpoints:gn},pipe(){return An(this,arguments)},handle(r,n,i){let m=this.group.endpoints[r];return this.handlers.add({endpoint:m,handler:n,isRaw:!1,uninterruptible:i?.uninterruptible??!1}),this},handleRaw(r,n,i){let m=this.group.endpoints[r];return this.handlers.add({endpoint:m,handler:n,isRaw:!0,uninterruptible:i?.uninterruptible??!1}),this}},S4=(r)=>{let n=Object.create(A4);return n.group=r,n.handlers=new Set,n};function v4(r){let n=new Map;return r.forEach(({encoding:i,schemas:m},c)=>{let l=Um(Zi(m));if(i._tag==="Multipart")n.set(c,{_tag:"Multipart",mode:i.mode,limits:i.limits,decode:l});else n.set(c,{_tag:i._tag,decode:l})}),n}function w4(r,n,i){let m=Xi(n.method),c=m?E4(n):"application/x-www-form-urlencoded",l=r.get(c);if(!l)return B0(`Unsupported content-type: ${c}`,{status:415});let{_tag:y,decode:j}=l;switch(y){case"Multipart":{if(l.mode==="buffered")return Mn(hn(El(l.limits,{onUndefined:()=>n.multipart,onDefined:(A)=>Pl(n.multipart,Ql(A))})),j);return t(El(l.limits,{onUndefined:()=>n.multipartStream,onDefined:(A)=>P1(n.multipartStream,Ql(A))}))}case"Json":return Mn(hn(n.json),j);case"Text":return Mn(hn(n.text),j);case"FormUrlEncoded":{let A=m?M0(hn(n.urlParamsBody),U1):t(i);return Mn(A,j)}case"Uint8Array":return Mn(M0(hn(n.arrayBuffer),(A)=>new Uint8Array(A)),j)}}function g1(r,n,i,m,c){let l=Nl(C4(n)),y=Nl(W4(n)),j=T0(n.params,Um),A=T0(n.headers,Um),S=T0(n.query,Um),w=n.payload.size>0&&!c?v4(n.payload):void 0;return N4(r,n,i,vm(function*(){let N=D1().context,Q=Pm(N,x0),W=Pm(N,o1),R=Pm(N,R1),X={request:Q,endpoint:n,group:r};if(j)X.params=yield*j(W.params);if(A)X.headers=yield*A(Q.headers);if(S)X.query=yield*S(R);if(w){let J=w4(w,Q,R);if(h0(J))return J;if(J!==void 0)X.payload=yield*J}let K=yield*m(X);return h0(K)?K:yield*l(K)})).pipe(v1,J0((E)=>hn(y(E))),Pl(i))}function $4(r,n,i){let m=n.endpoint;return L1(m.method,m.path,g1(r,m,i,n.handler,n.isRaw),{uninterruptible:n.uninterruptible})}var G4=(r)=>r.headers["content-type"]?r.headers["content-type"].toLowerCase().trim():"application/json",E4=(r)=>{let n=G4(r),i=n.indexOf(";");return i===-1?n:n.slice(0,i).trim()},N4=(r,n,i,m)=>{let c={group:r,endpoint:n};for(let l of n.middlewares){let y=l,j=Pm(i,y);m=(Gm(y)?Q4(y,j):j)(m,c)}return m},j1=new WeakMap,Q4=(r,n)=>{let i=j1.get(n);if(i!==void 0)return i;let m=Object.entries(r.security).map(([l,y])=>({decode:_1(y),middleware:n[l]}));if(m.length===0)return gn;let c=Ul(function*(l,y){let j;for(let A=0;A<m.length;A++){let{decode:S,middleware:v}=m[A],w=yield*S1(Mn(S,(E)=>v(l,{credential:E,endpoint:y.endpoint,group:y.group})));if(I1(w)){j=w;continue}return w.success}return yield*j.asEffect()});return j1.set(n,c),c},D4=W0(h0),P4=z1(Hi),U4=z1(Ri);function C4(r){let n=mi(r).map(P4);return n.length===1?n[0]:Zi(n)}function W4(r){let n=ci(r).map(U4);return n.length===1?n[0]:Zi(n)}function z1(r){let n=new WeakMap;return(i)=>{let m=n.get(i.ast);if(m!==void 0)return m;let c=D4.pipe(Wi(i,X4(r,i)));return n.set(c.ast,c),c}}function X4(r,n){let i=n.ast,m=K4(r(i),Ki(i),cm(i));return Q1({decode:(c)=>wm(new N1(Dl(c),{message:"Encode only schema"})),encode:m})}function K4(r,n,i){switch(n._tag){case"Json":return(m)=>{if(m===void 0||i)return t(Ur({status:r}));try{let c=JSON.stringify(m);return t(B0(c,{status:r,contentType:n.contentType}))}catch(c){return wm(new E1(Dl(m),{message:globalThis.String(c)}))}};case"Text":return(m)=>t(B0(m,{status:r,contentType:n.contentType}));case"Uint8Array":return(m)=>t(C1(m,{status:r,contentType:n.contentType}));case"FormUrlEncoded":return(m)=>t(X1(m,{status:r}).pipe(K1("content-type",n.contentType)))}}var xr={};Er(xr,{make:()=>Z4,isHttpApiGroup:()=>H4});var Wl="~effect/httpapi/HttpApiGroup",H4=(r)=>zn(r,Wl),R4={[Wl]:Wl,add(...r){let n={...this.endpoints};for(let i of r)n[i.name]=i;return Bn({identifier:this.identifier,topLevel:this.topLevel,endpoints:n,annotations:this.annotations})},prefix(r){return Bn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(n)=>n.prefix(r)),annotations:this.annotations})},middleware(r){return Bn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(n)=>n.middleware(r)),annotations:this.annotations})},annotateMerge(r){return Bn({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,annotations:Fr(this.annotations,r)})},annotate(r,n){return Bn({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,annotations:Sn(this.annotations,r,n)})},annotateEndpointsMerge(r){return Bn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(n)=>n.annotateMerge(r)),annotations:this.annotations})},annotateEndpoints(r,n){return Bn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(i)=>i.annotate(r,n)),annotations:this.annotations})},pipe(){return An(this,arguments)}},Bn=(r)=>{function n(){}return Object.setPrototypeOf(n,R4),n.key=`effect/httpapi/HttpApiGroup/${r.identifier}`,Object.assign(n,r)},Z4=(r,n)=>Bn({identifier:r,topLevel:n?.topLevel??!1,endpoints:F1(),annotations:Br()});var a0={};Er(a0,{bearer:()=>Y4,basic:()=>J4,apiKey:()=>V4,annotateMerge:()=>o4,annotate:()=>O4});var T1="~effect/httpapi/HttpApiSecurity",Cm={[T1]:T1,pipe(){return An(this,arguments)}},Y4=Object.assign(Object.create(Cm),{_tag:"Bearer",annotations:Br()}),V4=(r)=>Object.assign(Object.create(Cm),{_tag:"ApiKey",key:r.key,in:r.in??"header",annotations:Br()}),J4=Object.assign(Object.create(Cm),{_tag:"Basic",annotations:Br()}),o4=Xl(2,(r,n)=>Object.assign(Object.create(Cm),{...r,annotations:Fr(r.annotations,n)})),O4=Xl(3,(r,n,i)=>Object.assign(Object.create(Cm),{...r,annotations:Sn(r.annotations,n,i)}));var L4="/config",Kl=Tr.make("config").add(xr.make("config").add(u.get("providers",`${L4}/providers`,{success:nr.ConfigProvidersResult}).annotateMerge(M.annotations({identifier:"config.providers",summary:"List config providers",description:"Get a list of all configured AI providers and their default models."}))).annotateMerge(M.annotations({title:"config",description:"Experimental HttpApi config routes."}))).annotateMerge(M.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),M1=T.unwrap(C.gen(function*(){let r=yield*nr.Service,n=C.fn("ConfigHttpApi.providers")(function*(){let i=yield*r.list();return{providers:Object.values(i),default:nr.defaultModelIDs(i)}});return Ar.group(Kl,"config",(i)=>i.handle("providers",n))})).pipe(T.provide(nr.defaultLayer),T.provide(mr.defaultLayer));var h1="/permission",Hl=Tr.make("permission").add(xr.make("permission").add(u.get("list",h1,{success:_.Array(Qr.Request)}).annotateMerge(M.annotations({identifier:"permission.list",summary:"List pending permissions",description:"Get all pending permission requests across all sessions."})),u.post("reply",`${h1}/:requestID/reply`,{params:{requestID:Ci},payload:Qr.ReplyBody,success:_.Boolean}).annotateMerge(M.annotations({identifier:"permission.reply",summary:"Respond to permission request",description:"Approve or deny a permission request from the AI assistant."}))).annotateMerge(M.annotations({title:"permission",description:"Experimental HttpApi permission routes."}))).annotateMerge(M.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),B1=T.unwrap(C.gen(function*(){let r=yield*Qr.Service,n=C.fn("PermissionHttpApi.list")(function*(){return yield*r.list()}),i=C.fn("PermissionHttpApi.reply")(function*(m){return yield*r.reply({requestID:m.params.requestID,reply:m.payload.reply,message:m.payload.message}),!0});return Ar.group(Hl,"permission",(m)=>m.handle("list",n).handle("reply",i))})).pipe(T.provide(Qr.defaultLayer));var x1="/project",Rl=Tr.make("project").add(xr.make("project").add(u.get("list",x1,{success:_.Array(Gr.Info)}).annotateMerge(M.annotations({identifier:"project.list",summary:"List all projects",description:"Get a list of projects that have been opened with QitQode."})),u.get("current",`${x1}/current`,{success:Gr.Info}).annotateMerge(M.annotations({identifier:"project.current",summary:"Get current project",description:"Retrieve the currently active project that QitQode is working with."}))).annotateMerge(M.annotations({title:"project",description:"Experimental HttpApi project routes."}))).annotateMerge(M.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),k1=T.unwrap(C.gen(function*(){let r=yield*Gr.Service,n=C.fn("ProjectHttpApi.list")(function*(){return yield*r.list()}),i=C.fn("ProjectHttpApi.current")(function*(){return F.project});return Ar.group(Rl,"project",(m)=>m.handle("list",n).handle("current",i))})).pipe(T.provide(Gr.defaultLayer));var p0=C.fnUntraced(function*(r,n){let i=yield*C.promise(()=>p1.get()),m=new Set(r.disabled_providers??[]),c=r.enabled_providers?new Set(r.enabled_providers):void 0,l={};for(let[j,A]of Object.entries(i))if((c?c.has(j):!0)&&!m.has(j))l[j]=A;let y=Object.assign(a1(l,(j)=>nr.fromModelsDevProvider(j)),n);return{all:Object.values(y),default:nr.defaultModelIDs(y),connected:Object.keys(n)}});var u0="/provider",Zl=Tr.make("provider").add(xr.make("provider").add(u.get("list",u0,{success:nr.ListResult}).annotateMerge(M.annotations({identifier:"provider.list",summary:"List providers",description:"Get a list of all available AI providers, including both available and connected ones."})),u.get("auth",`${u0}/auth`,{success:Cr.Methods}).annotateMerge(M.annotations({identifier:"provider.auth",summary:"Get provider auth methods",description:"Retrieve available authentication methods for all AI providers."})),u.post("authorize",`${u0}/:providerID/oauth/authorize`,{params:{providerID:lr},payload:Cr.AuthorizeInput,success:Cr.Authorization}).annotateMerge(M.annotations({identifier:"provider.oauth.authorize",summary:"Start OAuth authorization",description:"Start the OAuth authorization flow for a provider."})),u.post("callback",`${u0}/:providerID/oauth/callback`,{params:{providerID:lr},payload:Cr.CallbackInput,success:_.Boolean}).annotateMerge(M.annotations({identifier:"provider.oauth.callback",summary:"Handle OAuth callback",description:"Handle the OAuth callback from a provider after user authorization."}))).annotateMerge(M.annotations({title:"provider",description:"Experimental HttpApi provider routes."}))).annotateMerge(M.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),u1=T.unwrap(C.gen(function*(){let r=yield*mr.Service,n=yield*nr.Service,i=yield*Cr.Service,m=C.fn("ProviderHttpApi.list")(function*(){let j=yield*r.get(),A=yield*n.list();return yield*p0(j,A)}),c=C.fn("ProviderHttpApi.auth")(function*(){return yield*i.methods()}),l=C.fn("ProviderHttpApi.authorize")(function*(j){let A=yield*i.authorize({providerID:j.params.providerID,method:j.payload.method,inputs:j.payload.inputs}).pipe(C.catch(()=>C.fail(new Yi.BadRequest({}))));if(!A)return yield*new Yi.BadRequest({});return A}),y=C.fn("ProviderHttpApi.callback")(function*(j){return yield*i.callback({providerID:j.params.providerID,method:j.payload.method,code:j.payload.code}).pipe(C.catch(()=>C.fail(new Yi.BadRequest({})))),!0});return Ar.group(Zl,"provider",(j)=>j.handle("list",m).handle("auth",c).handle("authorize",l).handle("callback",y))})).pipe(T.provide(Cr.defaultLayer),T.provide(nr.defaultLayer),T.provide(mr.defaultLayer));var Wm="/question",Yl=Tr.make("question").add(xr.make("question").add(u.get("list",Wm,{success:_.Array(qr.Request)}).annotateMerge(M.annotations({identifier:"question.list",summary:"List pending questions",description:"Get all pending question requests across all sessions."})),u.post("reply",`${Wm}/:requestID/reply`,{params:{requestID:mm},payload:qr.Reply,success:_.Boolean}).annotateMerge(M.annotations({identifier:"question.reply",summary:"Reply to question request",description:"Provide answers to a question request from the AI assistant."})),u.post("reject",`${Wm}/:requestID/reject`,{params:{requestID:mm},success:_.Boolean}).annotateMerge(M.annotations({identifier:"question.reject",summary:"Reject question request",description:"Reject a question request from the AI assistant."})),u.get("neverAsk",`${Wm}/never-ask`,{success:_.Boolean}).annotateMerge(M.annotations({identifier:"question.neverAsk",summary:"Get never-ask state",description:"Whether the question tool auto-resolves to a [Never-Ask] directive instead of blocking for a user."})),u.post("setNeverAsk",`${Wm}/never-ask`,{payload:_.Struct({enabled:_.Boolean}),success:_.Boolean}).annotateMerge(M.annotations({identifier:"question.setNeverAsk",summary:"Set never-ask state",description:"Enable or disable never-ask: the question tool stays visible but returns a [Never-Ask] directive so the model resolves decisions itself."}))).annotateMerge(M.annotations({title:"question",description:"Question routes."}))).annotateMerge(M.annotations({title:"qitqode HttpApi",version:"0.0.1",description:"Effect HttpApi surface for instance routes."})),d1=T.unwrap(C.gen(function*(){let r=yield*qr.Service,n=C.fn("QuestionHttpApi.list")(function*(){return yield*r.list()}),i=C.fn("QuestionHttpApi.reply")(function*(y){return yield*r.reply({requestID:y.params.requestID,answers:y.payload.answers}),!0}),m=C.fn("QuestionHttpApi.reject")(function*(y){return yield*r.reject(y.params.requestID),!0}),c=C.fn("QuestionHttpApi.neverAsk")(function*(){return yield*r.neverAsk()}),l=C.fn("QuestionHttpApi.setNeverAsk")(function*(y){return yield*r.setNeverAsk(y.payload.enabled),yield*r.neverAsk()});return Ar.group(Yl,"question",(y)=>y.handle("list",n).handle("reply",i).handle("reject",m).handle("neverAsk",c).handle("setNeverAsk",l))})).pipe(T.provide(qr.defaultLayer));var q4=_.Struct({directory:_.optional(_.String),workspace:_.optional(_.String)}),_4=_.Struct({authorization:_.optional(_.String),"x-qitqode-directory":_.optional(_.String)});function g4(r){try{return decodeURIComponent(r)}catch{return r}}class d0 extends _.TaggedErrorClass()("Unauthorized",{message:_.String},{httpApiStatus:401}){}class xn extends Vi.Service()("@qitqode/ExperimentalHttpApiAuthorization",{error:d0,security:{basic:a0.basic}}){}var z4=T.succeed(xn,xn.of({basic:(r,{credential:n})=>C.gen(function*(){if(!k.QITQODE_SERVER_PASSWORD)return yield*r;let i=k.QITQODE_SERVER_USERNAME??"qitqode";if(n.username!==i)return yield*new d0({message:"Unauthorized"});if(Cl.value(n.password)!==k.QITQODE_SERVER_PASSWORD)return yield*new d0({message:"Unauthorized"});return yield*r})}));class r2 extends _.TaggedErrorClass()("DirectoryAccessDenied",{message:_.String},{httpApiStatus:403}){}var F4=Im.middleware()(C.gen(function*(){return(r)=>C.gen(function*(){let n=yield*k0.schemaSearchParams(q4),i=yield*k0.schemaHeaders(_4),m=n.directory||i["x-qitqode-directory"]||process.cwd(),c=n.workspace||void 0,l=Xn.resolve(g4(m));if(!k.QITQODE_SERVER_PASSWORD){let A=Xn.resolve(process.cwd());if(!Xn.contains(A,l))return yield*new r2({message:"Access denied: directory must be within the server's working directory"})}let y=yield*C.promise(()=>F.provide({directory:l,init:()=>b.runPromise(kn),fn:()=>F.current}));return yield*(c?r.pipe(C.provideService(e1,c)):r).pipe(C.provideService(t1,y))})})).layer,T4=Yl.middleware(xn),M4=Hl.middleware(xn),h4=Rl.middleware(xn),B4=Zl.middleware(xn),x4=Kl.middleware(xn),n2=T.mergeAll(Ar.layer(x4).pipe(T.provide(M1)),Ar.layer(h4).pipe(T.provide(k1)),Ar.layer(T4).pipe(T.provide(d1)),Ar.layer(M4).pipe(T.provide(B1)),Ar.layer(B4).pipe(T.provide(u1))).pipe(T.provide(z4),T.provide(F4),T.provide(b1.layerServices),T.provideMerge(s1.layer)),k4=q(()=>Im.toWebHandler(n2,{memoMap:f1}));var i2=q(()=>new Z().get("/",G({summary:"List all projects",description:"Get a list of projects that have been opened with QitQode.",operationId:"project.list",responses:{200:{description:"List of projects",content:{"application/json":{schema:$(Gr.Info.zod.array())}}}}}),async(r)=>{let n=Gr.list();return r.json(n)}).get("/current",G({summary:"Get current project",description:"Retrieve the currently active project that QitQode is working with.",operationId:"project.current",responses:{200:{description:"Current project information",content:{"application/json":{schema:$(Gr.Info.zod)}}}}}),async(r)=>{return r.json(F.project)}).post("/git/init",G({summary:"Initialize git repository",description:"Create a git repository for the current project and return the refreshed project info.",operationId:"project.initGit",responses:{200:{description:"Project information after git initialization",content:{"application/json":{schema:$(Gr.Info.zod)}}}}}),async(r)=>{let n=F.directory,i=F.project,m=await p("ProjectRoutes.initGit",r,Gr.Service.use((c)=>c.initGit({directory:n,project:i})));if(m.id===i.id&&m.vcs===i.vcs&&m.worktree===i.worktree)return r.json(m);return await F.reload({directory:n,worktree:n,project:m,init:()=>b.runPromise(kn)}),r.json(m)}).patch("/:projectID",G({summary:"Update project",description:"Update project properties such as name, icon, and commands.",operationId:"project.update",responses:{200:{description:"Updated project information",content:{"application/json":{schema:$(Gr.Info.zod)}}},...U(400,404)}}),D("param",I.object({projectID:l0.zod})),D("json",Gr.UpdateInput.omit({projectID:!0})),async(r)=>P("ProjectRoutes.update",r,function*(){let n=r.req.valid("param").projectID,i=r.req.valid("json");return yield*(yield*Gr.Service).update({...i,projectID:n})})));var an={directory:I.string().optional().meta({description:"Filter sessions by project directory"}),roots:I.coerce.boolean().optional().meta({description:"Only return root sessions (no parentID)"}),start:I.coerce.number().optional().meta({description:"Filter sessions updated on or after this timestamp (milliseconds since epoch)"}),search:I.string().optional().meta({description:"Filter sessions by title (case-insensitive)"}),limit:I.coerce.number().optional().meta({description:"Maximum number of sessions to return"})};var t0=g.create({service:"server"}),s=()=>D("param",I.object({sessionID:er.zod})),Vl=()=>D("param",I.object({sessionID:er.zod,messageID:vn.zod})),Jl=()=>D("param",I.object({sessionID:er.zod,messageID:vn.zod,partID:pn.zod}));function m2(r){let n=r.status==="in_progress"?"in_progress":r.status==="done"?"completed":r.status==="abandoned"?"cancelled":"pending";return{content:r.summary,status:n}}var ol=(r,n)=>C.gen(function*(){let m=yield*(yield*V.Service).messages({sessionID:r,agentID:"main"});for(let c=m.length-1;c>=0;c--){let l=m[c].info;if(l.role==="user")return l.agent||n}return n});function l2(){return new Z().get("/",G({summary:"List sessions",description:"Get a list of all QitQode sessions, sorted by most recently updated.",operationId:"session.list",responses:{200:{description:"List of sessions",content:{"application/json":{schema:$(V.Info.array())}}}}}),D("query",I.object(an)),async(r)=>{let n=r.req.valid("query"),i=[];for await(let m of V.list({directory:n.directory,roots:n.roots,start:n.start,search:n.search,limit:n.limit}))i.push(m);return r.json(i)}).get("/status",G({summary:"Get session status",description:"Retrieve the current status of all sessions, including active, idle, and completed states.",operationId:"session.status",responses:{200:{description:"Get session status",content:{"application/json":{schema:$(I.record(I.string(),Ol.Info))}}},...U(400)}}),async(r)=>P("SessionRoutes.status",r,function*(){let n=yield*Ol.Service;return Object.fromEntries(yield*n.list())})).get("/:sessionID",G({summary:"Get session",description:"Retrieve detailed information about a specific QitQode session.",tags:["Session"],operationId:"session.get",responses:{200:{description:"Get session",content:{"application/json":{schema:$(V.Info)}}},...U(400,404)}}),D("param",I.object({sessionID:V.GetInput})),async(r)=>{let n=r.req.valid("param").sessionID;return P("SessionRoutes.get",r,function*(){return yield*(yield*V.Service).get(n)})}).get("/:sessionID/children",G({summary:"Get session children",tags:["Session"],description:"Retrieve all child sessions that were forked from the specified parent session.",operationId:"session.children",responses:{200:{description:"List of children",content:{"application/json":{schema:$(V.Info.array())}}},...U(400,404)}}),D("param",I.object({sessionID:V.ChildrenInput})),async(r)=>{let n=r.req.valid("param").sessionID;return P("SessionRoutes.children",r,function*(){return yield*(yield*V.Service).children(n)})}).post("/",G({summary:"Create session",description:"Create a new QitQode session for interacting with AI assistants and managing conversations.",operationId:"session.create",responses:{...U(400),200:{description:"Successfully created session",content:{"application/json":{schema:$(V.Info)}}}}}),D("json",V.CreateInput),async(r)=>P("SessionRoutes.create",r,function*(){let n=r.req.valid("json")??{};return yield*(yield*Hm.Service).create(n)})).delete("/:sessionID",G({summary:"Delete session",description:"Delete a session and permanently remove all associated data, including messages and history.",operationId:"session.delete",responses:{200:{description:"Successfully deleted session",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),D("param",I.object({sessionID:V.RemoveInput})),async(r)=>P("SessionRoutes.delete",r,function*(){let n=r.req.valid("param").sessionID;return yield*(yield*V.Service).remove(n),!0})).patch("/:sessionID",G({summary:"Update session",description:"Update properties of an existing session, such as title or other metadata.",operationId:"session.update",responses:{200:{description:"Successfully updated session",content:{"application/json":{schema:$(V.Info)}}},...U(400,404)}}),s(),D("json",I.object({title:I.string().optional(),permission:Qr.Ruleset.zod.optional(),time:I.object({archived:I.number().optional()}).optional()})),async(r)=>P("SessionRoutes.update",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json"),m=yield*V.Service,c=yield*m.get(n);if(i.title!==void 0)yield*m.setTitle({sessionID:n,title:i.title});if(i.permission!==void 0)yield*m.setPermission({sessionID:n,permission:Qr.merge(c.permission??[],i.permission)});if(i.time?.archived!==void 0)yield*m.setArchived({sessionID:n,time:i.time.archived});return yield*m.get(n)})).post("/:sessionID/init",G({summary:"Initialize session",description:"Analyze the current application and create an AGENTS.md file with project-specific agent configurations.",operationId:"session.init",responses:{200:{description:"200",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),s(),D("json",I.object({modelID:br.zod,providerID:lr.zod,messageID:vn.zod})),async(r)=>P("SessionRoutes.init",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json");return yield*(yield*Dr.Service).command({sessionID:n,messageID:i.messageID,model:i.providerID+"/"+i.modelID,command:Km.Default.INIT,arguments:""}),!0})).post("/:sessionID/fork",G({summary:"Fork session",description:"Create a new session by forking an existing session at a specific message point.",operationId:"session.fork",responses:{200:{description:"200",content:{"application/json":{schema:$(V.Info)}}}}}),D("param",I.object({sessionID:V.ForkInput.shape.sessionID})),D("json",V.ForkInput.omit({sessionID:!0})),async(r)=>P("SessionRoutes.fork",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json");return yield*(yield*V.Service).fork({...i,sessionID:n})})).post("/:sessionID/abort",G({summary:"Abort session",description:"Abort an active session and stop any ongoing AI processing or command execution.",operationId:"session.abort",responses:{200:{description:"Aborted session",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),s(),async(r)=>P("SessionRoutes.abort",r,function*(){return yield*(yield*Dr.Service).cancel(r.req.valid("param").sessionID),!0})).get("/:sessionID/actors",G({summary:"List session actors",description:"List actors registered for a session.",operationId:"session.actors",responses:{200:{description:"Actor list"},...U(400,404)}}),s(),async(r)=>{let n=r.req.valid("param").sessionID,i=await p("SessionRoutes.actors",r,C.gen(function*(){let m=yield*c2.Service;return yield*(yield*V.Service).get(n),yield*m.listBySession(n)}));return r.json(i)})}function j2(){return new Z().get("/:sessionID/todo",G({summary:"Get session todos",description:"Retrieve the todo list associated with a specific session, showing tasks and action items.",operationId:"session.todo",responses:{200:{description:"Todo list",content:{"application/json":{schema:$(ql.Info.array())}}},...U(400,404)}}),s(),async(r)=>{let n=r.req.valid("param").sessionID;return P("SessionRoutes.todo",r,function*(){let m=yield*(yield*Ll.Service).list({session_id:n,include_terminal:!0});if(m.length>0)return m.map(m2);return yield*(yield*ql.Service).get(n)})}).get("/:sessionID/task",G({summary:"List session tasks",description:"List tasks registered for a session (the work-item registry).",operationId:"session.task",responses:{200:{description:"Task list",content:{"application/json":{schema:$(y2.array())}}},...U(400,404)}}),s(),async(r)=>{let n=r.req.valid("param").sessionID,i=await p("SessionRoutes.task",r,C.gen(function*(){let m=yield*Ll.Service;return yield*(yield*V.Service).get(n),yield*m.list({session_id:n,include_terminal:!0})}));return r.json(i)})}function I2(){return new Z().post("/:sessionID/share",G({summary:"Share session",description:"Create a shareable link for a session, allowing others to view the conversation.",operationId:"session.share",responses:{200:{description:"Successfully shared session",content:{"application/json":{schema:$(V.Info)}}},...U(400,404)}}),s(),async(r)=>P("SessionRoutes.share",r,function*(){let n=r.req.valid("param").sessionID,i=yield*Hm.Service,m=yield*V.Service;return yield*i.share(n),yield*m.get(n)})).delete("/:sessionID/share",G({summary:"Unshare session",description:"Remove the shareable link for a session, making it private again.",operationId:"session.unshare",responses:{200:{description:"Successfully unshared session",content:{"application/json":{schema:$(V.Info)}}},...U(400,404)}}),s(),async(r)=>P("SessionRoutes.unshare",r,function*(){let n=r.req.valid("param").sessionID,i=yield*Hm.Service,m=yield*V.Service;return yield*i.unshare(n),yield*m.get(n)}))}function v2(){return new Z().get("/:sessionID/diff",G({summary:"Get message diff",description:"Get the file changes (diff) that resulted from a specific user message in the session.",operationId:"session.diff",responses:{200:{description:"Successfully retrieved diff",content:{"application/json":{schema:$(A2.FileDiff.array())}}}}}),D("param",I.object({sessionID:e0.DiffInput.shape.sessionID})),D("query",I.object({messageID:e0.DiffInput.shape.messageID})),async(r)=>P("SessionRoutes.diff",r,function*(){let n=r.req.valid("query"),i=r.req.valid("param");return yield*(yield*e0.Service).diff({sessionID:i.sessionID,messageID:n.messageID})})).post("/:sessionID/summarize",G({summary:"Summarize session",description:"Generate a concise summary of the session using AI compaction to preserve key information.",operationId:"session.summarize",responses:{200:{description:"Summarized session",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),s(),D("json",I.object({providerID:lr.zod,modelID:br.zod,auto:I.boolean().optional().default(!1)})),async(r)=>P("SessionRoutes.summarize",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json"),m=yield*V.Service,c=yield*Rm.Service,l=yield*S2.Service,y=yield*Dr.Service,j=yield*ji.Service;yield*c.cleanup(yield*m.get(n));let A=yield*ol(n,yield*j.defaultAgent());return yield*l.create({sessionID:n,agent:A,model:{providerID:i.providerID,modelID:i.modelID},auto:i.auto,agentID:"main"}),yield*y.loop({sessionID:n}),!0})).post("/:sessionID/revert",G({summary:"Revert message",description:"Revert a specific message in a session, undoing its effects and restoring the previous state.",operationId:"session.revert",responses:{200:{description:"Updated session",content:{"application/json":{schema:$(V.Info)}}},...U(400,404)}}),s(),D("json",Rm.RevertInput.omit({sessionID:!0})),async(r)=>{let n=r.req.valid("param").sessionID;return t0.info("revert",r.req.valid("json")),P("SessionRoutes.revert",r,function*(){return yield*(yield*Rm.Service).revert({sessionID:n,...r.req.valid("json")})})}).post("/:sessionID/unrevert",G({summary:"Restore reverted messages",description:"Restore all previously reverted messages in a session.",operationId:"session.unrevert",responses:{200:{description:"Updated session",content:{"application/json":{schema:$(V.Info)}}},...U(400,404)}}),s(),async(r)=>P("SessionRoutes.unrevert",r,function*(){let n=r.req.valid("param").sessionID;return yield*(yield*Rm.Service).unrevert({sessionID:n})}))}var b0=class{writer;encoder;writable;abortSubscribers=[];responseReadable;aborted=!1;closed=!1;constructor(r,n){this.writable=r,this.writer=r.getWriter(),this.encoder=new TextEncoder;let i=n.getReader();this.abortSubscribers.push(async()=>{await i.cancel()}),this.responseReadable=new ReadableStream({async pull(m){let{done:c,value:l}=await i.read();c?m.close():m.enqueue(l)},cancel:()=>{if(!this.closed)this.abort()}})}async write(r){try{if(typeof r==="string")r=this.encoder.encode(r);await this.writer.write(r)}catch{}return this}async writeln(r){return await this.write(r+`
|
|
9
|
-
`),this}sleep(r){return new Promise((n)=>setTimeout(n,r))}async close(){this.closed=!0;try{await this.writer.close()}catch{}}async pipe(r){this.writer.releaseLock(),await r.pipeTo(this.writable,{preventClose:!0}),this.writer=this.writable.getWriter()}onAbort(r){this.abortSubscribers.push(r)}abort(){if(!this.aborted)this.aborted=!0,this.abortSubscribers.forEach((r)=>r())}};var Zm=()=>{let r=typeof Bun<"u"?Bun.version:void 0;if(r===void 0)return!1;let n=r.startsWith("1.1")||r.startsWith("1.0")||r.startsWith("0.");return Zm=()=>n,n};var a4=new WeakMap,s0=(r,n,i)=>{let{readable:m,writable:c}=new TransformStream,l=new b0(c,m);if(Zm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return a4.set(l.responseReadable,r),(async()=>{try{await n(l)}catch(y){if(y===void 0);else if(y instanceof Error&&i)await i(y,l);else console.error(y)}finally{l.close()}})(),r.newResponse(l.responseReadable)};var w2=class extends b0{constructor(r,n){super(r,n)}async writeSSE(r){let i=(await Mi(r.data,Fm.Stringify,!1,{})).split(/\r\n|\r|\n/).map((c)=>{return`data: ${c}`}).join(`
|
|
10
|
-
`);for(let c of["event","id","retry"])if(r[c]&&/[\r\n]/.test(r[c]))throw Error(`${c} must not contain "\\r" or "\\n"`);let m=[r.event&&`event: ${r.event}`,i,r.id&&`id: ${r.id}`,r.retry&&`retry: ${r.retry}`].filter(Boolean).join(`
|
|
11
|
-
`)+`
|
|
12
|
-
|
|
13
|
-
`;await this.write(m)}},p4=async(r,n,i)=>{try{await n(r)}catch(m){if(m instanceof Error&&i)await i(m,r),await r.writeSSE({event:"error",data:m.message});else console.error(m)}finally{r.close()}},u4=new WeakMap,_l=(r,n,i)=>{let{readable:m,writable:c}=new TransformStream,l=new w2(c,m);if(Zm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return u4.set(l.responseReadable,r),r.header("Transfer-Encoding","chunked"),r.header("Content-Type","text/event-stream"),r.header("Cache-Control","no-cache"),r.header("Connection","keep-alive"),p4(l,n,i),r.newResponse(l.responseReadable)};var $2=I.object({info:vr.Assistant,parts:vr.Part.array()});function G2(){return new Z().get("/:sessionID/message",G({summary:"Get session messages",description:"Retrieve all messages in a session, including user prompts and AI responses.",operationId:"session.messages",responses:{200:{description:"List of messages",content:{"application/json":{schema:$(vr.WithParts.array())}}},...U(400,404)}}),s(),D("query",I.object({limit:I.coerce.number().int().min(0).optional().meta({description:"Maximum number of messages to return"}),before:I.string().optional().meta({description:"Opaque cursor for loading older messages"}).refine((r)=>{if(!r)return!0;try{return vr.cursor.decode(r),!0}catch{return!1}},{message:"Invalid cursor"}),agent_id:I.string().optional().meta({description:"Filter by message slice. Omitted = main-agent slice only (default). Pass a subagent's actor id to fetch its slice. Pass `*` to return every message regardless of slice."})}).refine((r)=>!r.before||r.limit!==void 0,{message:"before requires limit",path:["before"]})),async(r)=>{let n=r.req.valid("query"),i=r.req.valid("param").sessionID,m=n.agent_id??"main";if(n.limit===void 0||n.limit===0){let l=await p("SessionRoutes.messages",r,C.gen(function*(){let y=yield*V.Service;return yield*y.get(i),yield*y.messages({sessionID:i,agentID:m})}));return r.json(l)}let c=await vr.page({sessionID:i,limit:n.limit,before:n.before,agentID:m});if(c.cursor){let l=new URL(r.req.url);l.searchParams.set("limit",n.limit.toString()),l.searchParams.set("before",c.cursor),r.header("Access-Control-Expose-Headers","Link, X-Next-Cursor"),r.header("Link",`<${l.toString()}>; rel="next"`),r.header("X-Next-Cursor",c.cursor)}return r.json(c.items)}).get("/:sessionID/message/:messageID",G({summary:"Get message",description:"Retrieve a specific message from a session by its message ID.",operationId:"session.message",responses:{200:{description:"Message",content:{"application/json":{schema:$(I.object({info:vr.Info,parts:vr.Part.array()}))}}},...U(400,404)}}),Vl(),async(r)=>{let n=r.req.valid("param"),i=await vr.get({sessionID:n.sessionID,messageID:n.messageID});return r.json(i)}).delete("/:sessionID/message/:messageID",G({summary:"Delete message",description:"Permanently delete a specific message (and all of its parts) from a session. This does not revert any file changes that may have been made while processing the message.",operationId:"session.deleteMessage",responses:{200:{description:"Successfully deleted message",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),Vl(),async(r)=>P("SessionRoutes.deleteMessage",r,function*(){let n=r.req.valid("param"),i=yield*gl.Service,m=yield*V.Service;return yield*i.assertNotBusy(n.sessionID),yield*m.removeMessage({sessionID:n.sessionID,messageID:n.messageID}),!0})).delete("/:sessionID/message/:messageID/part/:partID",G({description:"Delete a part from a message",operationId:"part.delete",responses:{200:{description:"Successfully deleted part",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),Jl(),async(r)=>P("SessionRoutes.deletePart",r,function*(){let n=r.req.valid("param");return yield*(yield*V.Service).removePart({sessionID:n.sessionID,messageID:n.messageID,partID:n.partID}),!0})).patch("/:sessionID/message/:messageID/part/:partID",G({description:"Update a part in a message",operationId:"part.update",responses:{200:{description:"Successfully updated part",content:{"application/json":{schema:$(vr.Part)}}},...U(400,404)}}),Jl(),D("json",vr.Part),async(r)=>{let n=r.req.valid("param"),i=r.req.valid("json");if(i.id!==n.partID||i.messageID!==n.messageID||i.sessionID!==n.sessionID)throw Error(`Part mismatch: body.id='${i.id}' vs partID='${n.partID}', body.messageID='${i.messageID}' vs messageID='${n.messageID}', body.sessionID='${i.sessionID}' vs sessionID='${n.sessionID}'`);return P("SessionRoutes.updatePart",r,function*(){return yield*(yield*V.Service).updatePart(i)})}).post("/:sessionID/message",G({summary:"Send message",description:"Create and send a new message to a session, streaming the AI response.",operationId:"session.prompt",responses:{200:{description:"Created message",content:{"application/json":{schema:$($2)}}},...U(400,404,409)}}),s(),D("json",Dr.PromptInput.omit({sessionID:!0})),async(r)=>{let n=r.req.valid("param").sessionID;return await p("SessionRoutes.prompt.assertNotBusy",r,gl.Service.use((i)=>i.assertNotBusy(n))),r.status(200),r.header("Content-Type","application/json"),s0(r,async(i)=>{let m=r.req.valid("json"),c=r.req.raw.signal,l=()=>{p("SessionRoutes.prompt.disconnect",r,Dr.Service.use((y)=>y.cancel(n))).catch(()=>{})};if(c.aborted){l();return}c.addEventListener("abort",l,{once:!0});try{let y=await p("SessionRoutes.prompt",r,Dr.Service.use((j)=>j.prompt({...m,sessionID:n})));i.write(JSON.stringify(y))}finally{c.removeEventListener("abort",l)}})}).post("/:sessionID/prompt_async",G({summary:"Send async message",description:"Create and send a new message to a session asynchronously, starting the session if needed and returning immediately.",operationId:"session.prompt_async",responses:{204:{description:"Prompt accepted"},...U(400,404)}}),s(),D("json",Dr.PromptInput.omit({sessionID:!0})),async(r)=>{let n=r.req.valid("param").sessionID,i=r.req.valid("json");return p("SessionRoutes.prompt_async",r,Dr.Service.use((m)=>m.prompt({...i,sessionID:n}))).catch((m)=>{t0.error("prompt_async failed",{sessionID:n,error:m}),wr.publish(V.Event.Error,{sessionID:n,error:new Qi.Unknown({message:m instanceof Error?m.message:String(m)}).toObject()})}),r.body(null,204)}).post("/:sessionID/command",G({summary:"Send command",description:"Send a new command to a session for execution by the AI assistant.",operationId:"session.command",responses:{200:{description:"Created message",content:{"application/json":{schema:$($2)}}},...U(400,404)}}),s(),D("json",Dr.CommandInput.omit({sessionID:!0})),async(r)=>P("SessionRoutes.command",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json");return yield*(yield*Dr.Service).command({...i,sessionID:n})})).post("/:sessionID/predict",G({summary:"Predict next prompt",description:"Predict the user's most likely next prompt based on the latest user message and the assistant's result. Returns an empty string when disabled or unavailable.",operationId:"session.predict",responses:{200:{description:"Predicted next prompt",content:{"application/json":{schema:$(I.object({prediction:I.string()}))}}},...U(400,404)}}),s(),async(r)=>P("SessionRoutes.predict",r,function*(){let n=r.req.valid("param").sessionID;return{prediction:yield*(yield*Dr.Service).predict({sessionID:n})}})).post("/:sessionID/shell",G({summary:"Run shell command",description:"Execute a shell command within the session context and return the AI's response.",operationId:"session.shell",responses:{200:{description:"Created message",content:{"application/json":{schema:$(vr.WithParts)}}},...U(400,404)}}),s(),D("json",Dr.ShellInput.omit({sessionID:!0})),async(r)=>P("SessionRoutes.shell",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json");return yield*(yield*Dr.Service).shell({...i,sessionID:n})}))}function E2(){return new Z().post("/:sessionID/permissions/:permissionID",G({summary:"Respond to permission",deprecated:!0,description:"Approve or deny a permission request from the AI assistant.",operationId:"permission.respond",responses:{200:{description:"Permission processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400,404)}}),D("param",I.object({sessionID:er.zod,permissionID:Ci.zod})),D("json",I.object({response:Qr.Reply.zod})),async(r)=>P("SessionRoutes.permissionRespond",r,function*(){let n=r.req.valid("param");return yield*I0({requestID:n.permissionID,reply:r.req.valid("json").response})}))}var N2=q(()=>{let r=new Z;return r.route("/",l2()),r.route("/",j2()),r.route("/",I2()),r.route("/",v2()),r.route("/",G2()),r.route("/",E2()),r});var d4="forgewise",t4=I.object({balance:I.number().nullable(),status:I.enum(["signed_out","available","unavailable"])}),D2=q(()=>new Z().get("/balance",G({summary:"Get Qredits balance",description:"Retrieve the current Qredits balance for the signed-in Forgewise user. The response status distinguishes signed-out users from temporary billing-service outages.",operationId:"qredits.balance",responses:{200:{description:"Qredits balance",content:{"application/json":{schema:$(t4)}}}}}),async(r)=>P("QreditsRoutes.balance",r,function*(){let i=yield*(yield*ii.Service).get(d4);if(!i||i.type!=="api")return{balance:null,status:"signed_out"};let m=i.key;if(!m)return{balance:null,status:"signed_out"};let c=yield*C.tryPromise({try:()=>Q2(m),catch:()=>null}).pipe(C.orElseSucceed(()=>null));if(!c)return{balance:null,status:"unavailable"};return{balance:c.balance,status:"available"}})));function P2(r){return new Z().get("/",G({summary:"List PTY sessions",description:"Get a list of all active pseudo-terminal (PTY) sessions managed by QitQode.",operationId:"pty.list",responses:{200:{description:"List of sessions",content:{"application/json":{schema:$(Wr.Info.array())}}}}}),async(n)=>P("PtyRoutes.list",n,function*(){return yield*(yield*Wr.Service).list()})).post("/",G({summary:"Create PTY session",description:"Create a new pseudo-terminal (PTY) session for running shell commands and processes.",operationId:"pty.create",responses:{200:{description:"Created session",content:{"application/json":{schema:$(Wr.Info)}}},...U(400)}}),D("json",Wr.CreateInput),async(n)=>P("PtyRoutes.create",n,function*(){return yield*(yield*Wr.Service).create(n.req.valid("json"))})).get("/:ptyID",G({summary:"Get PTY session",description:"Retrieve detailed information about a specific pseudo-terminal (PTY) session.",operationId:"pty.get",responses:{200:{description:"Session info",content:{"application/json":{schema:$(Wr.Info)}}},...U(404)}}),D("param",I.object({ptyID:Ii.zod})),async(n)=>{let i=await p("PtyRoutes.get",n,C.gen(function*(){return yield*(yield*Wr.Service).get(n.req.valid("param").ptyID)}));if(!i)throw new Wn({message:"Session not found"});return n.json(i)}).put("/:ptyID",G({summary:"Update PTY session",description:"Update properties of an existing pseudo-terminal (PTY) session.",operationId:"pty.update",responses:{200:{description:"Updated session",content:{"application/json":{schema:$(Wr.Info)}}},...U(400)}}),D("param",I.object({ptyID:Ii.zod})),D("json",Wr.UpdateInput),async(n)=>P("PtyRoutes.update",n,function*(){return yield*(yield*Wr.Service).update(n.req.valid("param").ptyID,n.req.valid("json"))})).delete("/:ptyID",G({summary:"Remove PTY session",description:"Remove and terminate a specific pseudo-terminal (PTY) session.",operationId:"pty.remove",responses:{200:{description:"Session removed",content:{"application/json":{schema:$(I.boolean())}}},...U(404)}}),D("param",I.object({ptyID:Ii.zod})),async(n)=>P("PtyRoutes.remove",n,function*(){return yield*(yield*Wr.Service).remove(n.req.valid("param").ptyID),!0})).post("/:ptyID/connect-token",G({summary:"Issue PTY connect ticket",description:"Issue a one-time ticket for authenticating a WebSocket connection to a PTY session. The ticket must be passed as the 'ticket' query parameter on the /connect WebSocket URL.",operationId:"pty.connectToken",responses:{200:{description:"Issued ticket",content:{"application/json":{schema:$(I.object({ticket:I.string(),expires_in:I.number()}))}}},403:{description:"Forbidden \u2014 missing required header or invalid origin"},...U(404)}}),D("param",I.object({ptyID:Ii.zod})),async(n)=>{if(n.req.header(_j)!==gj)return n.json({error:"Forbidden"},403);let i=n.req.valid("param").ptyID;if(!await p("PtyRoutes.connectToken",n,C.gen(function*(){return yield*(yield*Wr.Service).get(i)})))throw new Wn({message:"Session not found"});return n.json(Fj(i))}).get("/:ptyID/connect",G({summary:"Connect to PTY session",description:"Establish a WebSocket connection to interact with a pseudo-terminal (PTY) session in real-time.",operationId:"pty.connect",responses:{200:{description:"Connected session",content:{"application/json":{schema:$(I.boolean())}}},...U(404)}}),D("param",I.object({ptyID:Ii.zod})),r(async(n)=>{let i=Ii.zod.parse(n.req.param("ptyID")),m=n.req.query(fm);if(!m||!Tj(m,i))throw new kr(401,{message:"Invalid or expired ticket"});let c=(()=>{let S=n.req.query("cursor");if(!S)return;let v=Number(S);if(!Number.isSafeInteger(v)||v<-1)return;return v})(),l;if(!await p("PtyRoutes.connect",n,C.gen(function*(){return yield*(yield*Wr.Service).get(i)})))throw Error("Session not found");let y=(S)=>{if(!S||typeof S!=="object")return!1;if(!("readyState"in S))return!1;if(!("send"in S)||typeof S.send!=="function")return!1;if(!("close"in S)||typeof S.close!=="function")return!1;return typeof S.readyState==="number"},j=[],A=!1;return{async onOpen(S,v){let w=v.raw;if(!y(w)){v.close();return}l=await b.runPromise(C.gen(function*(){return yield*(yield*Wr.Service).connect(i,w,c)}).pipe(C.withSpan("PtyRoutes.connect.open"))),A=!0;for(let E of j)l?.onMessage(E);j.length=0},onMessage(S){if(typeof S.data!=="string")return;if(!A){j.push(S.data);return}l?.onMessage(S.data)},onClose(){l?.onClose()},onError(){l?.onClose()}}}))}var U2=(r,n)=>C.gen(function*(){let i=yield*Xr.Service;if(n==="connect")yield*i.connect(r);else yield*i.disconnect(r);return!0}),W2=q(()=>new Z().get("/",G({summary:"Get MCP status",description:"Get the status of all Model Context Protocol (MCP) servers.",operationId:"mcp.status",responses:{200:{description:"MCP server status",content:{"application/json":{schema:$(I.record(I.string(),Xr.Status))}}}}}),async(r)=>P("McpRoutes.status",r,function*(){return yield*(yield*Xr.Service).status()})).post("/",G({summary:"Add MCP server",description:"Dynamically add a new Model Context Protocol (MCP) server to the system.",operationId:"mcp.add",responses:{200:{description:"MCP server added successfully",content:{"application/json":{schema:$(I.record(I.string(),Xr.Status))}}},...U(400)}}),D("json",I.object({name:I.string(),config:C2.Info.zod})),async(r)=>{if(!k.QITQODE_SERVER_PASSWORD)return r.json({error:"Forbidden: QITQODE_SERVER_PASSWORD must be set to add MCP servers via API"},403);return P("McpRoutes.add",r,function*(){let{name:n,config:i}=r.req.valid("json");return(yield*(yield*Xr.Service).add(n,i)).status})}).post("/:name/auth",G({summary:"Start MCP OAuth",description:"Start OAuth authentication flow for a Model Context Protocol (MCP) server.",operationId:"mcp.auth.start",responses:{200:{description:"OAuth flow started",content:{"application/json":{schema:$(I.object({authorizationUrl:I.string().describe("URL to open in browser for authorization")}))}}},...U(400,404)}}),async(r)=>{let n=r.req.param("name"),i=await p("McpRoutes.auth.start",r,C.gen(function*(){let m=yield*Xr.Service,c=yield*m.supportsOAuth(n);if(!c)return{supports:c};return{supports:c,auth:yield*m.startAuth(n)}}));if(!i.supports)return r.json({error:`MCP server ${n} does not support OAuth`},400);return r.json(i.auth)}).post("/:name/auth/callback",G({summary:"Complete MCP OAuth",description:"Complete OAuth authentication for a Model Context Protocol (MCP) server using the authorization code.",operationId:"mcp.auth.callback",responses:{200:{description:"OAuth authentication completed",content:{"application/json":{schema:$(Xr.Status)}}},...U(400,404)}}),D("json",I.object({code:I.string().describe("Authorization code from OAuth callback")})),async(r)=>P("McpRoutes.auth.callback",r,function*(){let n=r.req.param("name"),{code:i}=r.req.valid("json");return yield*(yield*Xr.Service).finishAuth(n,i)})).post("/:name/auth/authenticate",G({summary:"Authenticate MCP OAuth",description:"Start OAuth flow and wait for callback (opens browser)",operationId:"mcp.auth.authenticate",responses:{200:{description:"OAuth authentication completed",content:{"application/json":{schema:$(Xr.Status)}}},...U(400,404)}}),async(r)=>{let n=r.req.param("name"),i=await p("McpRoutes.auth.authenticate",r,C.gen(function*(){let m=yield*Xr.Service,c=yield*m.supportsOAuth(n);if(!c)return{supports:c};return{supports:c,status:yield*m.authenticate(n)}}));if(!i.supports)return r.json({error:`MCP server ${n} does not support OAuth`},400);return r.json(i.status)}).delete("/:name/auth",G({summary:"Remove MCP OAuth",description:"Remove OAuth credentials for an MCP server",operationId:"mcp.auth.remove",responses:{200:{description:"OAuth credentials removed",content:{"application/json":{schema:$(I.object({success:I.literal(!0)}))}}},...U(404)}}),async(r)=>P("McpRoutes.auth.remove",r,function*(){let n=r.req.param("name");return yield*(yield*Xr.Service).removeAuth(n),{success:!0}})).post("/:name/connect",G({description:"Connect an MCP server",operationId:"mcp.connect",responses:{200:{description:"MCP server connected successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("param",I.object({name:I.string()})),async(r)=>P("McpRoutes.connect",r,function*(){return yield*U2(r.req.valid("param").name,"connect")})).post("/:name/disconnect",G({description:"Disconnect an MCP server",operationId:"mcp.disconnect",responses:{200:{description:"MCP server disconnected successfully",content:{"application/json":{schema:$(I.boolean())}}}}}),D("param",I.object({name:I.string()})),async(r)=>P("McpRoutes.disconnect",r,function*(){return yield*U2(r.req.valid("param").name,"disconnect")})));var X2=q(()=>new Z().get("/find",G({summary:"Find text",description:"Search for text patterns across files in the project using ripgrep.",operationId:"find.text",responses:{200:{description:"Matches",content:{"application/json":{schema:$(zl.Match.shape.data.array())}}}}}),D("query",I.object({pattern:I.string()})),async(r)=>P("FileRoutes.findText",r,function*(){let n=r.req.valid("query").pattern;return(yield*(yield*zl.Service).search({cwd:F.directory,pattern:n,limit:10})).items})).get("/find/file",G({summary:"Find files",description:"Search for files or directories by name or pattern in the project directory.",operationId:"find.files",responses:{200:{description:"File paths",content:{"application/json":{schema:$(I.string().array())}}}}}),D("query",I.object({query:I.string(),dirs:I.enum(["true","false"]).optional(),type:I.enum(["file","directory"]).optional(),limit:I.coerce.number().int().min(1).max(200).optional()})),async(r)=>P("FileRoutes.findFile",r,function*(){let n=r.req.valid("query");return yield*(yield*un.Service).search({query:n.query,limit:n.limit??10,dirs:n.dirs!=="false",type:n.type})})).get("/find/symbol",G({summary:"Find symbols",description:"Search for workspace symbols like functions, classes, and variables using LSP.",operationId:"find.symbols",responses:{200:{description:"Symbols",content:{"application/json":{schema:$(Ym.Symbol.array())}}}}}),D("query",I.object({query:I.string()})),async(r)=>{return r.json([])}).get("/file",G({summary:"List files",description:"List files and directories in a specified path.",operationId:"file.list",responses:{200:{description:"Files and directories",content:{"application/json":{schema:$(un.Node.array())}}}}}),D("query",I.object({path:I.string()})),async(r)=>P("FileRoutes.list",r,function*(){return yield*(yield*un.Service).list(r.req.valid("query").path)})).get("/file/content",G({summary:"Read file",description:"Read the content of a specified file.",operationId:"file.read",responses:{200:{description:"File content",content:{"application/json":{schema:$(un.Content)}}}}}),D("query",I.object({path:I.string()})),async(r)=>P("FileRoutes.read",r,function*(){return yield*(yield*un.Service).read(r.req.valid("query").path)})).get("/file/status",G({summary:"Get file status",description:"Get the git status of all files in the project.",operationId:"file.status",responses:{200:{description:"File status",content:{"application/json":{schema:$(un.Info.array())}}}}}),async(r)=>P("FileRoutes.status",r,function*(){return yield*(yield*un.Service).status()})));var K2=q(()=>new Z().get("/",G({summary:"Get configuration",description:"Retrieve the current QitQode configuration settings and preferences.",operationId:"config.get",responses:{200:{description:"Get config info",content:{"application/json":{schema:$(mr.Info)}}}}}),async(r)=>P("ConfigRoutes.get",r,function*(){return yield*(yield*mr.Service).get()})).patch("/",G({summary:"Update configuration",description:"Update QitQode configuration settings and preferences.",operationId:"config.update",responses:{200:{description:"Successfully updated config",content:{"application/json":{schema:$(mr.Info)}}},...U(400)}}),D("json",mr.Info),async(r)=>P("ConfigRoutes.update",r,function*(){let n=r.req.valid("json");return yield*(yield*mr.Service).update(n),n})).get("/providers",G({summary:"List config providers",description:"Get a list of all configured AI providers and their default models.",operationId:"config.providers",responses:{200:{description:"List of providers",content:{"application/json":{schema:$(nr.ConfigProvidersResult.zod)}}}}}),async(r)=>P("ConfigRoutes.providers",r,function*(){let i=yield*(yield*nr.Service).list();return{providers:Object.values(i),default:nr.defaultModelIDs(i)}})));var e4=I.object({accountID:I.string(),accountEmail:I.string(),accountUrl:I.string(),orgID:I.string(),orgName:I.string(),active:I.boolean()}),b4=I.object({orgs:I.array(e4)}),s4=I.object({accountID:I.string(),orgID:I.string()}),Y2=q(()=>new Z().get("/console",G({summary:"Get active Console provider metadata",description:"Get the active Console org name and the set of provider IDs managed by that Console org.",operationId:"experimental.console.get",responses:{200:{description:"Active Console provider metadata",content:{"application/json":{schema:$(Z2.zod)}}}}}),async(r)=>P("ExperimentalRoutes.console.get",r,function*(){let n=yield*mr.Service,i=yield*f0.Service,[m,c]=yield*C.all([n.getConsoleState(),i.orgsByAccount()],{concurrency:"unbounded"});return{...m,switchableOrgCount:c.reduce((l,y)=>l+y.orgs.length,0)}})).get("/console/orgs",G({summary:"List switchable Console orgs",description:"Get the available Console orgs across logged-in accounts, including the current active org.",operationId:"experimental.console.listOrgs",responses:{200:{description:"Switchable Console orgs",content:{"application/json":{schema:$(b4)}}}}}),async(r)=>P("ExperimentalRoutes.console.listOrgs",r,function*(){let n=yield*f0.Service,[i,m]=yield*C.all([n.orgsByAccount(),n.active()],{concurrency:"unbounded"}),c=Qm.getOrUndefined(m);return{orgs:i.flatMap((y)=>y.orgs.map((j)=>({accountID:y.account.id,accountEmail:y.account.email,accountUrl:y.account.url,orgID:j.id,orgName:j.name,active:!!c&&c.id===y.account.id&&c.active_org_id===j.id})))}})).post("/console/switch",G({summary:"Switch active Console org",description:"Persist a new active Console account/org selection for the current local QitQode state.",operationId:"experimental.console.switchOrg",responses:{200:{description:"Switch success",content:{"application/json":{schema:$(I.boolean())}}}}}),D("json",s4),async(r)=>P("ExperimentalRoutes.console.switchOrg",r,function*(){let n=r.req.valid("json");return yield*(yield*f0.Service).use(H2.make(n.accountID),Qm.some(R2.make(n.orgID))),!0})).get("/tool/ids",G({summary:"List tool IDs",description:"Get a list of all available tool IDs, including both built-in tools and dynamically registered tools.",operationId:"tool.ids",responses:{200:{description:"Tool IDs",content:{"application/json":{schema:$(I.array(I.string()).meta({ref:"ToolIDs"}))}}},...U(400)}}),async(r)=>P("ExperimentalRoutes.tool.ids",r,function*(){return yield*(yield*Fl.Service).ids()})).get("/tool",G({summary:"List tools",description:"Get a list of available tools with their JSON schema parameters for a specific provider and model combination.",operationId:"tool.list",responses:{200:{description:"Tools",content:{"application/json":{schema:$(I.array(I.object({id:I.string(),description:I.string(),parameters:I.any()}).meta({ref:"ToolListItem"})).meta({ref:"ToolList"}))}}},...U(400)}}),D("query",I.object({provider:I.string(),model:I.string()})),async(r)=>{let{provider:n,model:i}=r.req.valid("query"),m=await p("ExperimentalRoutes.tool.list",r,C.gen(function*(){let c=yield*ji.Service;return yield*(yield*Fl.Service).tools({providerID:lr.make(n),modelID:br.make(i),agent:yield*c.get(yield*c.defaultAgent())})}));return r.json(m.map((c)=>({id:c.id,description:c.description,parameters:I.toJSONSchema(c.parameters)})))}).post("/worktree",G({summary:"Create worktree",description:"Create a new git worktree for the current project and run any configured startup scripts.",operationId:"worktree.create",responses:{200:{description:"Worktree created",content:{"application/json":{schema:$(dn.Info)}}},...U(400)}}),D("json",dn.CreateInput.optional()),async(r)=>P("ExperimentalRoutes.worktree.create",r,function*(){let n=r.req.valid("json"),i=n?{...n,startCommand:k.QITQODE_SERVER_PASSWORD?n.startCommand:void 0}:n;return yield*(yield*dn.Service).create(i)})).get("/worktree",G({summary:"List worktrees",description:"List all sandbox worktrees for the current project.",operationId:"worktree.list",responses:{200:{description:"List of worktree directories",content:{"application/json":{schema:$(I.array(I.string()))}}}}}),async(r)=>P("ExperimentalRoutes.worktree.list",r,function*(){return yield*(yield*Gr.Service).sandboxes(F.project.id)})).delete("/worktree",G({summary:"Remove worktree",description:"Remove a git worktree and delete its branch.",operationId:"worktree.remove",responses:{200:{description:"Worktree removed",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("json",dn.RemoveInput),async(r)=>P("ExperimentalRoutes.worktree.remove",r,function*(){let n=r.req.valid("json"),i=yield*dn.Service,m=yield*Gr.Service;return yield*i.remove(n),yield*m.removeSandbox(F.project.id,n.directory),!0})).post("/worktree/reset",G({summary:"Reset worktree",description:"Reset a worktree branch to the primary default branch.",operationId:"worktree.reset",responses:{200:{description:"Worktree reset",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("json",dn.ResetInput),async(r)=>P("ExperimentalRoutes.worktree.reset",r,function*(){let n=r.req.valid("json");return yield*(yield*dn.Service).reset(n),!0})).get("/session",G({summary:"List sessions",description:"Get a list of all QitQode sessions across projects, sorted by most recently updated. Archived sessions are excluded by default.",operationId:"experimental.session.list",responses:{200:{description:"List of sessions",content:{"application/json":{schema:$(V.GlobalInfo.array())}}}}}),D("query",I.object({directory:an.directory,roots:an.roots,start:an.start,cursor:I.coerce.number().optional().meta({description:"Return sessions updated before this timestamp (milliseconds since epoch)"}),search:an.search,limit:an.limit,archived:I.coerce.boolean().optional().meta({description:"Include archived sessions (default false)"})})),async(r)=>{let n=r.req.valid("query"),i=n.limit??100,m=[];for await(let y of V.listGlobal({directory:n.directory,roots:n.roots,start:n.start,cursor:n.cursor,search:n.search,limit:i+1,archived:n.archived}))m.push(y);let c=m.length>i,l=c?m.slice(0,i):m;if(c&&l.length>0)r.header("x-next-cursor",String(l[l.length-1].time.updated));return r.json(l)}).get("/resource",G({summary:"Get MCP resources",description:"Get all available MCP resources from connected servers. Optionally filter by name.",operationId:"experimental.resource.list",responses:{200:{description:"MCP resources",content:{"application/json":{schema:$(I.record(I.string(),Xr.Resource))}}}}}),async(r)=>P("ExperimentalRoutes.resource.list",r,function*(){return yield*(yield*Xr.Service).resources()})));var V2=q(()=>new Z().get("/",G({summary:"List providers",description:"Get a list of all available AI providers, including both available and connected ones.",operationId:"provider.list",responses:{200:{description:"List of providers",content:{"application/json":{schema:$(nr.ListResult.zod)}}}}}),async(r)=>P("ProviderRoutes.list",r,function*(){let n=yield*nr.Service,m=yield*(yield*mr.Service).get(),c=yield*n.list();return yield*p0(m,c)})).get("/auth",G({summary:"Get provider auth methods",description:"Retrieve available authentication methods for all AI providers.",operationId:"provider.auth",responses:{200:{description:"Provider auth methods",content:{"application/json":{schema:$(Cr.Methods.zod)}}}}}),async(r)=>P("ProviderRoutes.auth",r,function*(){return yield*(yield*Cr.Service).methods()})).post("/:providerID/oauth/authorize",G({summary:"OAuth authorize",description:"Initiate OAuth authorization for a specific AI provider to get an authorization URL.",operationId:"provider.oauth.authorize",responses:{200:{description:"Authorization URL and method",content:{"application/json":{schema:$(Cr.Authorization.zod.optional())}}},...U(400)}}),D("param",I.object({providerID:lr.zod.meta({description:"Provider ID"})})),D("json",Cr.AuthorizeInput.zod),async(r)=>P("ProviderRoutes.oauth.authorize",r,function*(){let n=r.req.valid("param").providerID,{method:i,inputs:m}=r.req.valid("json");return yield*(yield*Cr.Service).authorize({providerID:n,method:i,inputs:m})})).post("/:providerID/oauth/callback",G({summary:"OAuth callback",description:"Handle the OAuth callback from a provider after user authorization.",operationId:"provider.oauth.callback",responses:{200:{description:"OAuth callback processed successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("param",I.object({providerID:lr.zod.meta({description:"Provider ID"})})),D("json",Cr.CallbackInput.zod),async(r)=>P("ProviderRoutes.oauth.callback",r,function*(){let n=r.req.valid("param").providerID,{method:i,code:m}=r.req.valid("json");return yield*(yield*Cr.Service).callback({providerID:n,method:i,code:m}),!0})));var f4=1e4,r$=1e5,n$=8388608,i$=67108864,m$=2097152,c$=8388608;function l$(r=process.env.QITQODE_EVENT_QUEUE_CAPACITY){let n=Number(r);if(!Number.isSafeInteger(n)||n<1||n>r$)return f4;return n}var y$=l$();function j$(r=process.env.QITQODE_EVENT_QUEUE_BYTES){let n=Number(r);if(!Number.isSafeInteger(n)||n<1||n>i$)return n$;return n}function I$(r=process.env.QITQODE_EVENT_MAX_BYTES){let n=Number(r);if(!Number.isSafeInteger(n)||n<1||n>c$)return m$;return n}var J2=j$(),A$=Math.min(I$(),J2);function S$(r,n=A$){let i=JSON.stringify(r);if(i===void 0||Buffer.byteLength(i)>n)return;return i}function rc(r,n){return _l(r,async(i)=>{let m=new Ui({capacity:y$,maxWeight:J2,weight:(v)=>v===null?0:Buffer.byteLength(v)}),c=!1,l=0,y=()=>{},j=(v)=>{let w=S$(v);if(w===void 0){l++;return}m.push(w)};j(n.connected);let A=setInterval(()=>j(n.heartbeat),1e4),S=()=>{if(c)return;if(c=!0,clearInterval(A),y(),m.push(null),m.dropped+l>0)n.onDrop?.(m.dropped+l);n.onDisconnect?.(m.size,m.bufferedWeight)};try{let v=n.subscribe(j,S);if(c)v();else y=v;i.onAbort(S);for await(let w of m){if(w===null)return;await i.writeSSE({data:w})}}finally{S()}})}class Vm{limit;windowMs;buckets=new Map;pruneKeys=[];pruneIndex=0;sweeping=!1;nextSweepAt=0;constructor(r,n){this.limit=r;this.windowMs=n}check(r,n=Date.now()){if(this.sweeping||this.buckets.size>1024||this.buckets.size>0&&n>=this.nextSweepAt)this.pruneSome(n);let i=n-this.windowMs,m=(this.buckets.get(r)??[]).filter((c)=>c>i);if(m.length>=this.limit){this.buckets.set(r,m);let c=m[0]??n;return{allowed:!1,retryAfterSeconds:Math.max(1,Math.ceil((c+this.windowMs-n)/1000))}}return m.push(n),this.buckets.set(r,m),{allowed:!0}}pruneSome(r,n=64){if(!this.sweeping)this.pruneKeys=[...this.buckets.keys()],this.pruneIndex=0,this.sweeping=!0,this.nextSweepAt=r+this.windowMs;let i=r-this.windowMs,m=Math.min(this.pruneIndex+n,this.pruneKeys.length);for(;this.pruneIndex<m;this.pruneIndex++){let c=this.pruneKeys[this.pruneIndex],l=this.buckets.get(c);if(!l)continue;let y=l.filter((j)=>j>i);if(y.length===0)this.buckets.delete(c);else this.buckets.set(c,y)}if(this.pruneIndex>=this.pruneKeys.length)this.sweeping=!1,this.pruneKeys=[],this.pruneIndex=0}}var nc=g.create({service:"server"}),o2=()=>{let r=Number(process.env.QITQODE_EVENT_CONNECT_LIMIT)||60,n=Number(process.env.QITQODE_EVENT_CONNECT_WINDOW_MS)||60000,i=new Vm(r,n);return new Z().get("/event",G({summary:"Subscribe to events",description:"Get events",operationId:"event.subscribe",responses:{200:{description:"Event stream",content:{"text/event-stream":{schema:$(I.union(jn.payloads()).meta({ref:"Event"}))}}}}}),async(m)=>{let c=m.req.header("x-forwarded-for")?.split(",")[0]?.trim()||"local",l=i.check(c);if(!l.allowed)return nc.warn("event connection rate limited",{key:c,retryAfterSeconds:l.retryAfterSeconds}),m.header("Retry-After",String(l.retryAfterSeconds)),m.json({error:"Too many reconnect attempts, slow down"},429);return nc.info("event connected"),m.header("Cache-Control","no-cache, no-transform"),m.header("X-Accel-Buffering","no"),m.header("X-Content-Type-Options","nosniff"),rc(m,{connected:{type:qi.Connected.type,properties:{}},heartbeat:{type:qi.Heartbeat.type,properties:{}},subscribe(y,j){return wr.subscribeAll((A)=>{if(y(A),A.type===wr.InstanceDisposed.type)j()})},onDrop(y){nc.warn("event dropped under backpressure",{dropped:y})},onDisconnect(y,j){nc.info("event disconnected",{buffered:y,bufferedBytes:j})}})})};var v$=I.object({id:I.string(),aggregateID:I.string(),seq:I.number().int().min(0),type:I.string(),data:I.record(I.string(),I.unknown())}),O2=g.create({service:"server.sync"}),g2=q(()=>new Z().post("/start",G({summary:"Start workspace sync",description:"Start sync loops for workspaces in the current project that have active sessions.",operationId:"sync.start",responses:{200:{description:"Workspace sync started",content:{"application/json":{schema:$(I.boolean())}}}}}),async(r)=>{return pc(F.project.id),r.json(!0)}).post("/replay",G({summary:"Replay sync events",description:"Validate and replay a complete sync event history.",operationId:"sync.replay",responses:{200:{description:"Replayed sync events",content:{"application/json":{schema:$(I.object({sessionID:I.string()}))}}},...U(400)}}),D("json",I.object({directory:I.string(),events:I.array(v$).min(1)})),async(r)=>{let n=r.req.valid("json"),i=n.events,m=i[0].aggregateID;return O2.info("sync replay requested",{sessionID:m,events:i.length,first:i[0]?.seq,last:i.at(-1)?.seq,directory:n.directory}),yr.replayAll(i),O2.info("sync replay complete",{sessionID:m,events:i.length,first:i[0]?.seq,last:i.at(-1)?.seq}),r.json({sessionID:m})}).post("/history",G({summary:"List sync events",description:"List sync events for all aggregates. Keys are aggregate IDs the client already knows about, values are the last known sequence ID. Events with seq > value are returned for those aggregates. Aggregates not listed in the input get their full history.",operationId:"sync.history.list",responses:{200:{description:"Sync events",content:{"application/json":{schema:$(I.array(I.object({id:I.string(),aggregate_id:I.string(),seq:I.number(),type:I.string(),data:I.record(I.string(),I.unknown())})))}}},...U(400)}}),D("json",I.record(I.string(),I.number().int().min(0))),async(r)=>{let n=r.req.valid("json"),i=Object.entries(n),m=i.length>0?q2(L2(...i.map(([l,y])=>im(d(Rr.aggregate_id,l),_2(Rr.seq,y))))):void 0,c=e.use((l)=>l.select().from(Rr).where(m).orderBy(c0(Rr.seq)).all());return r.json(c)}));var hl=(r)=>{let n=new Z;if(k.QITQODE_EXPERIMENTAL_HTTPAPI){let i=Xm.webHandler().handler,m=Zn.empty();n.get("/question",(c)=>i(c.req.raw,m)),n.post("/question/:requestID/reply",(c)=>i(c.req.raw,m)),n.post("/question/:requestID/reject",(c)=>i(c.req.raw,m)),n.get("/permission",(c)=>i(c.req.raw,m)),n.post("/permission/:requestID/reply",(c)=>i(c.req.raw,m)),n.get("/config/providers",(c)=>i(c.req.raw,m)),n.get("/provider",(c)=>i(c.req.raw,m)),n.get("/provider/auth",(c)=>i(c.req.raw,m)),n.post("/provider/:providerID/oauth/authorize",(c)=>i(c.req.raw,m)),n.post("/provider/:providerID/oauth/callback",(c)=>i(c.req.raw,m)),n.get("/project",(c)=>i(c.req.raw,m)),n.get("/project/current",(c)=>i(c.req.raw,m))}return n.route("/project",i2()).route("/pty",P2(r)).route("/config",K2()).route("/experimental",Y2()).route("/session",N2()).route("/qredits",D2()).route("/permission",NI()).route("/workflows",DI()).route("/question",EI()).route("/bash-interactive",PI()).route("/provider",V2()).route("/sync",g2()).route("/",X2()).route("/",o2()).route("/mcp",W2()).route("/tui",$I()).post("/instance/dispose",G({summary:"Dispose instance",description:"Clean up and dispose the current QitQode instance, releasing all resources.",operationId:"instance.dispose",responses:{200:{description:"Instance disposed",content:{"application/json":{schema:$(I.boolean())}}}}}),async(i)=>{return await F.dispose(),i.json(!0)}).get("/path",G({summary:"Get paths",description:"Retrieve the current working directory and related path information for the QitQode instance.",operationId:"path.get",responses:{200:{description:"Path",content:{"application/json":{schema:$(I.object({home:I.string(),state:I.string(),config:I.string(),worktree:I.string(),directory:I.string()}).meta({ref:"Path"}))}}}}}),async(i)=>{return i.json({home:Yn.Path.home,state:Yn.Path.state,config:Yn.Path.config,worktree:F.worktree,directory:F.directory})}).get("/vcs",G({summary:"Get VCS info",description:"Retrieve version control system (VCS) information for the current project, such as git branch.",operationId:"vcs.get",responses:{200:{description:"VCS info",content:{"application/json":{schema:$(_i.Info)}}}}}),async(i)=>P("InstanceRoutes.vcs.get",i,function*(){let m=yield*_i.Service,[c,l]=yield*C.all([m.branch(),m.defaultBranch()],{concurrency:2});return{branch:c,default_branch:l}})).get("/vcs/diff",G({summary:"Get VCS diff",description:"Retrieve the current git diff for the working tree or against the default branch.",operationId:"vcs.diff",responses:{200:{description:"VCS diff",content:{"application/json":{schema:$(_i.FileDiff.array())}}}}}),D("query",I.object({mode:_i.Mode})),async(i)=>P("InstanceRoutes.vcs.diff",i,function*(){return yield*(yield*_i.Service).diff(i.req.valid("query").mode)})).get("/command",G({summary:"List commands",description:"Get a list of all available commands in the QitQode system.",operationId:"command.list",responses:{200:{description:"List of commands",content:{"application/json":{schema:$(Km.Info.array())}}}}}),async(i)=>P("InstanceRoutes.command.list",i,function*(){return yield*(yield*Km.Service).list()})).get("/agent",G({summary:"List agents",description:"Get a list of all available AI agents in the QitQode system.",operationId:"app.agents",responses:{200:{description:"List of agents",content:{"application/json":{schema:$(ji.Info.array())}}}}}),async(i)=>P("InstanceRoutes.agent.list",i,function*(){return yield*(yield*ji.Service).list()})).get("/skill",G({summary:"List skills",description:"Get a list of all available skills in the QitQode system.",operationId:"app.skills",responses:{200:{description:"List of skills",content:{"application/json":{schema:$(Ml.Info.array())}}}}}),async(i)=>P("InstanceRoutes.skill.list",i,function*(){return yield*(yield*Ml.Service).all()})).get("/lsp",G({summary:"Get LSP status",description:"Get LSP server status",operationId:"lsp.status",responses:{200:{description:"LSP server status",content:{"application/json":{schema:$(Ym.Status.array())}}}}}),async(i)=>P("InstanceRoutes.lsp.status",i,function*(){return yield*(yield*Ym.Service).status()})).get("/formatter",G({summary:"Get formatter status",description:"Get formatter status",operationId:"formatter.status",responses:{200:{description:"Formatter status",content:{"application/json":{schema:$(Tl.Status.array())}}}}}),async(i)=>P("InstanceRoutes.formatter.status",i,function*(){return yield*(yield*Tl.Service).status()}))};function z2(){let r=new Z,n=(i,m)=>b.runPromise(C.gen(function*(){let c=yield*ii.Service;if(m)yield*c.set(i,m);else yield*c.remove(i)}));return r.put("/auth/:providerID",G({summary:"Set auth credentials",description:"Set authentication credentials",operationId:"auth.set",responses:{200:{description:"Successfully set authentication credentials",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("param",I.object({providerID:lr.zod})),D("json",ii.Info.zod),async(i)=>{let m=i.req.valid("param").providerID,c=i.req.valid("json");return await n(m,c),i.json(!0)}).delete("/auth/:providerID",G({summary:"Remove auth credentials",description:"Remove authentication credentials",operationId:"auth.remove",responses:{200:{description:"Successfully removed authentication credentials",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("param",I.object({providerID:lr.zod})),async(i)=>{let m=i.req.valid("param").providerID;return await n(m),i.json(!0)}).get("/doc",Qy(r,{documentation:{info:{title:"qitqode",version:"0.0.3",description:"qitqode api"},openapi:"3.1.1"}})).use(D("query",I.object({directory:I.string().optional(),workspace:I.string().optional()}))).post("/log",G({summary:"Write log",description:"Write a log entry to the server logs with specified level and metadata.",operationId:"app.log",responses:{200:{description:"Log entry written successfully",content:{"application/json":{schema:$(I.boolean())}}},...U(400)}}),D("json",I.object({service:I.string().meta({description:"Service name for the log entry"}),level:I.enum(["debug","info","error","warn"]).meta({description:"Log level"}),message:I.string().meta({description:"Log message"}),extra:I.record(I.string(),I.any()).optional().meta({description:"Additional metadata for the log entry"})})),async(i)=>{let{service:m,level:c,message:l,extra:y}=i.req.valid("json"),j=g.create({service:m});switch(c){case"debug":j.debug(l,y);break;case"info":j.info(l,y);break;case"error":j.error(l,y);break;case"warn":j.warn(l,y);break}return i.json(!0)})}var gi={};Er(gi,{scan:()=>U$,runAll:()=>C$,ExternalImport:()=>gi,ALL_SOURCES:()=>al});import b2 from"path";import{access as Bl}from"fs/promises";import{Database as w$}from"bun:sqlite";function Jm(r){let n=new w$(r,{readonly:!0});return{all:(i,...m)=>n.query(i).all(...m),get:(i,...m)=>n.query(i).get(...m)??null,close:()=>n.close()}}var om={};Er(om,{run:()=>N$,parse:()=>B2,CodexImport:()=>om});import $$ from"path";var G$=g.create({service:"codex-import"});function F2(r){if(!r)return Date.now();let n=Date.parse(r);return Number.isNaN(n)?Date.now():n}function E$(r){if(typeof r==="string")try{return JSON.parse(r)}catch{return{raw:r}}if(r&&typeof r==="object")return r;return{}}function B2(r,n){let i=T2(r);if(i.length===0)return;let m,c,l,y,j=0,A,S=[],v=new Map,w=null,E=null,N=()=>{if(w)S.push(w);w=null},Q=(W)=>{if(!E){let R=vn.ascending();S.push({info:{id:R,sessionID:n,role:"user",agent:"main",time:{created:W},model:{providerID:lr.make("openai"),modelID:br.make("unknown")}},parts:[]}),E=R}if(!w||w.info.role!=="assistant")N(),w={info:{id:vn.ascending(),sessionID:n,role:"assistant",time:{created:W,completed:W},parentID:E,modelID:br.make("unknown"),providerID:lr.make("openai"),mode:"build",agent:"main",path:{cwd:m??"",root:m??""},cost:0,tokens:{input:0,output:0,reasoning:0,cache:{read:0,write:0}}},parts:[]};return w.info.time.completed=W,w};for(let W of i){let{type:R,payload:X}=W,K=F2(W.timestamp);if(y===void 0)y=K;if(j=Math.max(j,K),R==="session_meta"&&X){m=X.cwd,c=`codex-${X.cli_version??"unknown"}`,l=X.id;let L=F2(X.timestamp);if(y===void 0||L<y)y=L;continue}if(R!=="response_item"||!X)continue;let J=X.type;if(J==="message"){let L=X.role,z=X.content??[];if(L==="user"||L==="developer"){let O=z.filter((x)=>(x.type==="input_text"||x.type==="text")&&typeof x.text==="string"&&x.text.trim()).map((x)=>x.text);if(O.length===0)continue;N();let f=vn.ascending(),Mr=O.map((x)=>({part:{id:pn.ascending(),sessionID:n,messageID:f,type:"text",text:x},time:K})),Yr={id:f,sessionID:n,role:"user",agent:"main",time:{created:K},model:{providerID:lr.make("openai"),modelID:br.make("unknown")}};if(S.push({info:Yr,parts:Mr}),E=f,!A)A=M2(O);continue}if(L==="assistant"){let O=Q(K);for(let f of z)if((f.type==="output_text"||f.type==="text")&&typeof f.text==="string"&&f.text.trim())O.parts.push({part:{id:pn.ascending(),sessionID:n,messageID:O.info.id,type:"text",text:f.text},time:K});continue}continue}if(J==="reasoning"){let L=Q(K),O=X.summary?.map((f)=>f.text??"").join("")??"";if(O.trim())L.parts.push({part:{id:pn.ascending(),sessionID:n,messageID:L.info.id,type:"reasoning",text:O,time:{start:K,end:K}},time:K});continue}if(J==="function_call"||J==="custom_tool_call"){let L=Q(K),z=X.call_id??pn.ascending(),O=X.name??"unknown",f=J==="function_call"?E$(X.arguments):{raw:X.input??""},Mr={id:pn.ascending(),sessionID:n,messageID:L.info.id,type:"tool",callID:z,tool:O,state:{status:"pending",input:f,raw:JSON.stringify(f)}};L.parts.push({part:Mr,time:K}),v.set(z,{part:Mr,start:K});continue}if(J==="function_call_output"||J==="custom_tool_call_output"){let L=X.call_id,z=L?v.get(L):void 0;if(!z)continue;let O=typeof X.output==="string"?X.output:JSON.stringify(X.output??"");z.part.state={status:"completed",input:z.part.state.input??{},output:O,title:z.part.tool,metadata:{},time:{start:z.start,end:K}};continue}}if(N(),S.length===0)return;return{cwd:m??"",version:c??"codex",sessionUuid:l,title:A??"Codex session",timeCreated:y??Date.now(),timeUpdated:j||y||Date.now(),messages:S}}var N$=h2({source:"codex",root:$$.join(Yn.Path.home,".codex","sessions"),pattern:"**/*.jsonl",log:G$,logMessage:"codex import",parse:B2});var Lm={};Er(Lm,{run:()=>P$,OpencodeImport:()=>Lm,DEFAULT_DB_PATH:()=>Om});import{access as Q$}from"fs/promises";var D$=g.create({service:"opencode-import"}),Om=(()=>{return`${process.env.XDG_DATA_HOME||`${process.env.HOME||process.env.USERPROFILE}/.local/share`}/opencode/opencode.db`})(),x2=200;async function P$(r){let n=r?.dbPath??Om,i=k2();if(!await Q$(n).then(()=>!0).catch(()=>!1))return i;let m;try{m=Jm(n)}catch(c){return i.errors.push(`failed to open ${n}: ${c}`),i}try{if(!m.get("SELECT name FROM sqlite_master WHERE type='table' AND name='session'"))return i.errors.push(`${n}: missing 'session' table`),i;let l=m.all("SELECT * FROM session ORDER BY time_created DESC");for(let y of l){i.scanned++;try{let j=y.id,A=p2("opencode",j);if(A&&A.source_mtime===y.time_updated&&!r?.force){i.skipped++;continue}let S=u2("opencode",A);A=S.existing;let v=S.existingUpdated,w=await a2(y.directory),E=Date.now(),N=m.all("SELECT * FROM message WHERE session_id = ? ORDER BY id",y.id);if(N.length===0){i.skipped++;continue}let Q=N.map((R)=>R.id),W=[];for(let R=0;R<Q.length;R+=x2){let X=Q.slice(R,R+x2),K=X.map(()=>"?").join(","),J=m.all(`SELECT * FROM part WHERE session_id = ? AND message_id IN (${K}) ORDER BY id`,y.id,...X);W.push(...J)}if(e.transaction((R)=>{if(d2(R,w,y.time_created,y.time_updated),A)t2(R,A,y.id),e2(R,y.id,{projectId:w.id,directory:y.directory,version:y.version,existingUpdated:v,timeUpdated:y.time_updated});else R.insert(ir).values({id:y.id,project_id:w.id,parent_id:y.parent_id,slug:y.slug,directory:y.directory,title:y.title,version:y.version,time_created:y.time_created,time_updated:y.time_updated}).onConflictDoUpdate({target:ir.id,set:{project_id:w.id,directory:y.directory,time_updated:y.time_updated}}).run();for(let X of N){let K=typeof X.data==="string"?JSON.parse(X.data):X.data;R.insert(Kn).values({id:X.id,session_id:y.id,agent_id:"main",time_created:X.time_created,data:K}).onConflictDoUpdate({target:Kn.id,set:{data:K,time_created:X.time_created}}).run()}for(let X of W){let K=typeof X.data==="string"?JSON.parse(X.data):X.data;R.insert(Hn).values({id:X.id,message_id:X.message_id,session_id:y.id,time_created:X.time_created,data:K}).onConflictDoUpdate({target:Hn.id,set:{data:K,time_created:X.time_created}}).run()}R.insert(Ai).values({source:"opencode",source_key:j,session_id:y.id,source_path:n,source_mtime:y.time_updated,time_imported:E,message_ids:Q}).onConflictDoUpdate({target:[Ai.source,Ai.source_key],set:{source_mtime:y.time_updated,time_imported:E,message_ids:Q}}).run()}),A)i.resynced++;else i.imported++}catch(j){i.errors.push(`session ${y.id}: ${j}`)}}}finally{m.close()}if(i.imported+i.resynced>0||i.errors.length>0)D$.info("opencode import",{...i,errors:i.errors.length});return i}var qm=g.create({service:"external-import"}),al=["cc","codex","opencode"];async function U$(){let r=(c)=>e.use((l)=>l.select({n:s2()}).from(Ai).where(d(Ai.source,c)).get())?.n??0,n={cc:{available:!1,sessions:0,imported:0},codex:{available:!1,sessions:0,imported:0},opencode:{available:!1,sessions:0,imported:0}},i=b2.join(Yn.Path.home,".claude","projects");if(await Bl(i).then(()=>!0).catch(()=>!1))try{let c=await kl.scan("*/*.jsonl",{cwd:i,absolute:!1});n.cc={available:!0,sessions:c.length,imported:r("cc")}}catch(c){qm.warn("cc scan failed",{error:String(c)})}let m=b2.join(Yn.Path.home,".codex","sessions");if(await Bl(m).then(()=>!0).catch(()=>!1))try{let c=await kl.scan("**/*.jsonl",{cwd:m,absolute:!1});n.codex={available:!0,sessions:c.length,imported:r("codex")}}catch(c){qm.warn("codex scan failed",{error:String(c)})}if(await Bl(Om).then(()=>!0).catch(()=>!1))try{let c=Jm(Om);try{let l=c.get("SELECT count(*) AS n FROM session");n.opencode={available:!0,sessions:l?.n??0,imported:r("opencode")}}finally{c.close()}}catch(c){qm.warn("opencode scan failed",{error:String(c)})}return n}function xl(){return{scanned:0,imported:0,resynced:0,skipped:0,errors:[]}}async function C$(r){let n=new Set(r?.sources??al),i={cc:xl(),codex:xl(),opencode:xl()};for(let c of al){if(!n.has(c))continue;try{if(c==="cc")i.cc=await f2.run({force:r?.force});else if(c==="codex")i.codex=await om.run({force:r?.force});else i.opencode=await Lm.run({force:r?.force})}catch(l){qm.warn(`${c} import failed`,{error:String(l)}),i[c].errors.push(String(l))}}let m={scanned:i.cc.scanned+i.codex.scanned+i.opencode.scanned,imported:i.cc.imported+i.codex.imported+i.opencode.imported,resynced:i.cc.resynced+i.codex.resynced+i.opencode.resynced,errors:i.cc.errors.length+i.codex.errors.length+i.opencode.errors.length};if(m.imported+m.resynced>0||m.errors>0)qm.info("external import",m);return i}var ic=g.create({service:"server"}),W$=jn.define("global.disposed",I.object({})),nA=q(()=>{let r=Number(process.env.QITQODE_GLOBAL_EVENT_CONNECT_LIMIT)||60,n=Number(process.env.QITQODE_GLOBAL_EVENT_CONNECT_WINDOW_MS)||60000,i=new Vm(r,n);return new Z().get("/health",G({summary:"Get health",description:"Get health information about the QitQode server.",operationId:"global.health",responses:{200:{description:"Health information",content:{"application/json":{schema:$(I.object({healthy:I.literal(!0),version:I.string()}))}}}}}),async(m)=>{return m.json({healthy:!0,version:rA})}).get("/event",G({summary:"Get global events",description:"Subscribe to global events from the QitQode system using server-sent events.",operationId:"global.event",responses:{200:{description:"Event stream",content:{"text/event-stream":{schema:$(I.object({directory:I.string(),project:I.string().optional(),workspace:I.string().optional(),payload:I.union([...jn.payloads(),...yr.payloads()])}).meta({ref:"GlobalEvent"}))}}}}}),async(m)=>{let c=m.req.header("x-forwarded-for")?.split(",")[0]?.trim()||"local",l=i.check(c);if(!l.allowed)return ic.warn("global event connection rate limited",{key:c,retryAfterSeconds:l.retryAfterSeconds}),m.header("Retry-After",String(l.retryAfterSeconds)),m.json({error:"Too many reconnect attempts, slow down"},429);return ic.info("global event connected"),m.header("Cache-Control","no-cache, no-transform"),m.header("X-Accel-Buffering","no"),m.header("X-Content-Type-Options","nosniff"),rc(m,{connected:{directory:"global",payload:{type:qi.Connected.type,properties:{}}},heartbeat:{directory:"global",payload:{type:qi.Heartbeat.type,properties:{}}},subscribe(y){function j(A){y(A)}return Or.on("event",j),()=>Or.off("event",j)},onDrop(y){ic.warn("global event dropped under backpressure",{dropped:y})},onDisconnect(y,j){ic.info("global event disconnected",{buffered:y,bufferedBytes:j})}})}).get("/config",G({summary:"Get global configuration",description:"Retrieve the current global QitQode configuration settings and preferences.",operationId:"global.config.get",responses:{200:{description:"Get global config info",content:{"application/json":{schema:$(mr.Info)}}}}}),async(m)=>{return m.json(await b.runPromise(mr.Service.use((c)=>c.getGlobal())))}).patch("/config",G({summary:"Update global configuration",description:"Update global QitQode configuration settings and preferences.",operationId:"global.config.update",responses:{200:{description:"Successfully updated global config",content:{"application/json":{schema:$(mr.Info)}}},...U(400)}}),D("json",mr.Info),async(m)=>{let c=m.req.valid("json"),l=await b.runPromise(mr.Service.use((y)=>y.updateGlobal(c)));return m.json(l)}).post("/dispose",G({summary:"Dispose instance",description:"Clean up and dispose all QitQode instances, releasing all resources.",operationId:"global.dispose",responses:{200:{description:"Global disposed",content:{"application/json":{schema:$(I.boolean())}}}}}),async(m)=>{return await F.disposeAll(),Or.emit("event",{directory:"global",payload:{type:W$.type,properties:{}}}),m.json(!0)}).post("/upgrade",G({summary:"Upgrade qitqode",description:"Upgrade qitqode to the specified version or latest if not specified.",operationId:"global.upgrade",responses:{200:{description:"Upgrade result",content:{"application/json":{schema:$(I.union([I.object({success:I.literal(!0),version:I.string()}),I.object({success:I.literal(!1),error:I.string()})]))}}},...U(400)}}),D("json",I.object({target:I.string().optional()})),async(m)=>{let c=await b.runPromise(pl.Service.use((y)=>C.gen(function*(){let j=yield*y.method();if(j==="unknown")return{success:!1,status:400,error:"Unknown installation method"};let A=m.req.valid("json").target||(yield*y.latest(j)),S=yield*C.catch(y.upgrade(j,A).pipe(C.as({success:!0,version:A})),(v)=>C.succeed({success:!1,status:500,error:v instanceof Error?v.message:String(v)}));if(!S.success)return S;return{...S,status:200}})));if(!c.success)return m.json({success:!1,error:c.error},c.status);let l=c.version;return Or.emit("event",{directory:"global",payload:{type:pl.Event.Updated.type,properties:{version:l}}}),m.json({success:!0,version:l})}).get("/import/scan",G({summary:"Scan external session sources",description:"Detect availability and session counts of external AI tool session stores (Claude Code, Codex, opencode). Read-only.",operationId:"global.import.scan",responses:{200:{description:"Per-source availability and counts",content:{"application/json":{schema:$(I.record(I.enum(["cc","codex","opencode"]),I.object({available:I.boolean(),sessions:I.number(),imported:I.number()})))}}}}}),async(m)=>{return m.json(await gi.scan())}).post("/import/run",G({summary:"Import external sessions",description:"Import sessions from external AI tools (Claude Code, Codex, opencode) into qitqode. Idempotent; pass force to re-sync. Per-source failures are not thrown as HTTP errors \u2014 they are collected into the corresponding stats.errors[] while other sources continue.",operationId:"global.import.run",responses:{200:{description:"Per-source import stats",content:{"application/json":{schema:$(I.record(I.enum(["cc","codex","opencode"]),I.object({scanned:I.number(),imported:I.number(),resynced:I.number(),skipped:I.number(),errors:I.array(I.string())})))}}},...U(400)}}),D("json",I.object({sources:I.array(I.enum(["cc","codex","opencode"])).optional(),force:I.boolean().optional()})),async(m)=>{let{sources:c,force:l}=m.req.valid("json");return m.json(await gi.runAll({sources:c,force:l}))})});var zi={};Er(zi,{websocket:()=>o$,http:()=>J$,ServerProxy:()=>zi});var X$=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade","host","authorization"]);function K$(r,n){let i=new Headers(r.headers);for(let m of X$)i.delete(m);if(i.delete("accept-encoding"),i.delete("x-qitqode-directory"),i.delete("x-qitqode-workspace"),!n)return i;for(let[m,c]of new Headers(n).entries())i.set(m,c);return i}function H$(r){let n=r.headers.get("sec-websocket-protocol");if(!n)return[];return n.split(",").map((i)=>i.trim()).filter(Boolean)}function R$(r){let n=new URL(r);if(n.protocol==="http:")n.protocol="ws:";if(n.protocol==="https:")n.protocol="wss:";return n.toString()}function Z$(r,n){if(n instanceof Blob)return n.arrayBuffer().then((i)=>r.send(i));return r.send(n)}var Y$=(r)=>new Z().get("/__workspace_ws",r((n)=>{let i=n.req.header("x-qitqode-proxy-url"),m=[],c;return{onOpen(l,y){if(!i){y.close(1011,"missing proxy target");return}c=new WebSocket(i,H$(n.req.raw)),c.binaryType="arraybuffer",c.onopen=()=>{for(let j of m)c?.send(j);m.length=0},c.onmessage=(j)=>{Z$(y,j.data)},c.onerror=()=>{y.close(1011,"proxy error")},c.onclose=(j)=>{y.close(j.code,j.reason)}},onMessage(l){let y=l.data;if(typeof y!=="string"&&!(y instanceof Uint8Array)&&!(y instanceof ArrayBuffer))return;if(c?.readyState===WebSocket.OPEN){c.send(y);return}m.push(y)},onClose(l){c?.close(l.code,l.reason)}}})),V$=g.Default.clone().tag("service","server-proxy");async function J$(r,n,i,m){if(!a.isSyncing(m))return new Response(`broken sync connection for workspace: ${m}`,{status:503,headers:{"content-type":"text/plain; charset=utf-8"}});return fetch(new Request(r,{method:i.method,headers:K$(i,n),body:i.method==="GET"||i.method==="HEAD"?void 0:i.body,redirect:"manual",signal:i.signal})).then((c)=>{let l=yI(c.headers),y=new Headers(c.headers);return y.delete("content-encoding"),y.delete("content-length"),(l?jI(m,l,i.signal):Promise.resolve()).then(async()=>{return new Response(c.body,{status:c.status,statusText:c.statusText,headers:y})})})}function o$(r,n,i,m,c){let l=new URL(m.url);l.pathname="/__workspace_ws",l.search="";let y=new Headers(m.headers);y.set("x-qitqode-proxy-url",R$(n));for(let[j,A]of new Headers(i).entries())y.set(j,A);return V$.info("proxy websocket",{request:m.url,target:String(n)}),Y$(r).fetch(new Request(l,{method:m.method,headers:y,signal:m.signal}),c)}var O$=[{path:"/session/status",action:"forward"},{method:"GET",path:"/session",action:"local"}];function L$(r,n){for(let i of O$){if(i.method&&i.method!==r)continue;if(i.exact?n===i.path:n===i.path||n.startsWith(i.path+"/"))return i.action==="local"}return!1}function q$(r){if(r.pathname==="/session/status")return null;let n=r.pathname.match(/^\/session\/([^/]+)(?:\/|$)/)?.[1];if(!n)return null;return er.make(n)}async function _$(r){let n=q$(r);if(!n)return null;return(await b.runPromise(V.Service.use((m)=>m.get(n)).pipe(C.withSpan("WorkspaceRouter.lookup"))).catch(()=>{return}))?.workspaceID}function iA(r){let n=g.create({service:"workspace-router"});return async(i,m)=>{let c=new URL(i.req.url),y=await _$(c)||c.searchParams.get("workspace");if(!y||c.pathname.startsWith("/console")||k.QITQODE_WORKSPACE_ID)return m();let j=await a.get(Lr.make(y));if(!j)return new Response(`Workspace not found: ${y}`,{status:500,headers:{"content-type":"text/plain; charset=utf-8"}});if(L$(i.req.method,c.pathname))return m();let S=await(await _n(j.projectID,j.type)).target(j);if(S.type==="local")return Pi.provide({workspaceID:Lr.make(y),fn:()=>F.provide({directory:S.directory,init:()=>b.runPromise(kn),async fn(){return m()}})});let v=new URL(S.url);if(v.pathname=`${v.pathname.replace(/\/$/,"")}${c.pathname}`,v.search=c.search,v.hash=c.hash,v.searchParams.delete("workspace"),v.searchParams.delete("auth_token"),n.info("workspace proxy forwarding",{workspaceID:y,request:c.toString(),target:String(S.url),proxy:v.toString()}),i.req.header("upgrade")?.toLowerCase()==="websocket")return zi.websocket(r,v,S.headers,i.req.raw,i.env);let w=new Headers(i.req.raw.headers);w.delete("x-qitqode-workspace");let E=new Request(i.req.raw,{headers:w});return zi.http(v,S.headers,E,j.id)}}function ul(r){return async(n,i)=>{let m=n.req.query("directory")||n.req.header("x-qitqode-directory")||process.cwd(),c=mA.resolve((()=>{try{return decodeURIComponent(m)}catch{return m}})());if(!k.QITQODE_SERVER_PASSWORD){let l=Xn.resolve(process.cwd());if(!Xn.contains(l,c))return n.json({error:"Access denied: directory must be within the server's working directory"},403)}return Pi.provide({workspaceID:r,async fn(){return F.provide({directory:c,init:()=>b.runPromise(kn),async fn(){return i()}})}})}}var dl=g.create({service:"server.workspace"}),lA=q(()=>new Z().get("/adaptor",G({summary:"List workspace adaptors",description:"List all available workspace adaptors for the current project.",operationId:"experimental.workspace.adaptor.list",responses:{200:{description:"Workspace adaptors",content:{"application/json":{schema:$(I.array(I.object({type:I.string(),name:I.string(),description:I.string()})))}}}}}),async(r)=>{return r.json(await cA(F.project.id))}).post("/",G({summary:"Create workspace",description:"Create a workspace for the current project.",operationId:"experimental.workspace.create",responses:{200:{description:"Workspace created",content:{"application/json":{schema:$(a.Info)}}},...U(400)}}),D("json",a.create.schema.omit({projectID:!0})),async(r)=>{let n=r.req.valid("json"),i=await a.create({projectID:F.project.id,...n});return r.json(i)}).get("/",G({summary:"List workspaces",description:"List all workspaces.",operationId:"experimental.workspace.list",responses:{200:{description:"Workspaces",content:{"application/json":{schema:$(I.array(a.Info))}}}}}),async(r)=>{return r.json(a.list(F.project))}).get("/status",G({summary:"Workspace status",description:"Get connection status for workspaces in the current project.",operationId:"experimental.workspace.status",responses:{200:{description:"Workspace status",content:{"application/json":{schema:$(I.array(a.ConnectionStatus))}}}}}),async(r)=>{let n=new Set(a.list(F.project).map((i)=>i.id));return r.json(a.status().filter((i)=>n.has(i.workspaceID)))}).delete("/:id",G({summary:"Remove workspace",description:"Remove an existing workspace.",operationId:"experimental.workspace.remove",responses:{200:{description:"Workspace removed",content:{"application/json":{schema:$(a.Info.optional())}}},...U(400)}}),D("param",I.object({id:a.Info.shape.id})),async(r)=>{let{id:n}=r.req.valid("param");return r.json(await a.remove(n))}).post("/:id/session-restore",G({summary:"Restore session into workspace",description:"Replay a session's sync events into the target workspace in batches.",operationId:"experimental.workspace.sessionRestore",responses:{200:{description:"Session replay started",content:{"application/json":{schema:$(I.object({total:I.number().int().min(0)}))}}},...U(400)}}),D("param",I.object({id:a.Info.shape.id})),D("json",a.sessionRestore.schema.omit({workspaceID:!0})),async(r)=>{let{id:n}=r.req.valid("param"),i=r.req.valid("json");dl.info("session restore route requested",{workspaceID:n,sessionID:i.sessionID,directory:F.directory});try{let m=await a.sessionRestore({workspaceID:n,...i});return dl.info("session restore route complete",{workspaceID:n,sessionID:i.sessionID,total:m.total}),r.json(m)}catch(m){throw dl.error("session restore route failed",{workspaceID:n,sessionID:i.sessionID,error:m0(m)}),m}}));globalThis.AI_SDK_LOG_WARNINGS=!1;dc();var g$=g.create({service:"server"}),z$=q(()=>tl({}));function F$(r){try{return new URL(r).hostname}catch{return}}function tl(r){let n=new Z().onError(Mj).use(kj({hostname:r.hostname,mdnsDomain:r.mdnsDomain,allowedHosts:r.cors?.map(F$).filter((m)=>!!m)})).use(xj(r)).use(Bj).use(hj).use(aj).route("/global",nA()),i=Fy.create(n);if(k.QITQODE_WORKSPACE_ID)return{app:n.use(ul(k.QITQODE_WORKSPACE_ID?Lr.make(k.QITQODE_WORKSPACE_ID):void 0)).use(II).route("/",hl(i.upgradeWebSocket)),runtime:i};return{app:n.route("/",z2()).route("/",new Z().use(ul()).route("/experimental/workspace",lA()).use(iA(i.upgradeWebSocket)).route("/",hl(i.upgradeWebSocket))),runtime:i}}async function T$(){let{app:r}=tl({});return await wc(r,{documentation:{info:{title:"qitqode",version:"1.0.0",description:"qitqode api"},openapi:"3.1.1"}})}var yA;async function M$(r){let i=await tl(r).runtime.listen(r),m=new URL("http://localhost");m.hostname=r.hostname,m.port=String(i.port),yA=m;let c=r.mdns&&i.port&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="::1";if(c)Ni.publish(i.port,r.mdnsDomain);else if(r.mdns)g$.warn("mDNS enabled but hostname is loopback; skipping mDNS publish");let l;return{hostname:r.hostname,port:i.port,url:m,stop(y){return l??=(async()=>{if(c)Ni.unpublish();await i.stop(y)})(),l}}}
|
|
14
|
-
export{z$ as Wf,T$ as Xf,yA as Yf,M$ as Zf,el as _f};
|