@qitqode/qitqode-android-arm64 0.2.9 → 0.2.10

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.
Files changed (425) hide show
  1. package/bundle/chunk-062chtrq.js +2 -0
  2. package/bundle/chunk-062vs7bp.js +2 -0
  3. package/bundle/chunk-08g14hmz.js +2 -0
  4. package/bundle/{chunk-wgkcyqn1.js → chunk-0bhzhh7s.js} +2 -2
  5. package/bundle/{chunk-cfwz1hgr.js → chunk-0mwzxqt5.js} +3 -3
  6. package/bundle/{chunk-mr17tppa.js → chunk-0sfc21qe.js} +2 -2
  7. package/bundle/{chunk-7adsab4h.js → chunk-0tkznq75.js} +1 -1
  8. package/bundle/chunk-0w2v8dfy.js +2 -0
  9. package/bundle/chunk-10fr7a2y.js +2 -0
  10. package/bundle/chunk-141p12c4.js +4 -0
  11. package/bundle/chunk-15bjhfav.js +3 -0
  12. package/bundle/{chunk-92r1gw2j.js → chunk-1h96bk6p.js} +2 -2
  13. package/bundle/chunk-1hv61m11.js +2 -0
  14. package/bundle/{chunk-0z1keh2w.js → chunk-1m78yy4k.js} +1 -1
  15. package/bundle/chunk-1q10jyka.js +29 -0
  16. package/bundle/{chunk-g4tyaj0m.js → chunk-1r81q7m3.js} +1 -1
  17. package/bundle/{chunk-29q89bge.js → chunk-2cvwrabw.js} +2 -2
  18. package/bundle/{chunk-8p0t8qah.js → chunk-2dmcpqak.js} +1 -1
  19. package/bundle/{chunk-35fj1sfm.js → chunk-2fbkw84y.js} +2 -2
  20. package/bundle/chunk-2mkvx8b2.js +2 -0
  21. package/bundle/chunk-2rykfc3a.js +2 -0
  22. package/bundle/chunk-2w5hx4fs.js +2 -0
  23. package/bundle/{chunk-t3w43rft.js → chunk-2y5bthrp.js} +1 -1
  24. package/bundle/chunk-2yy63sxz.js +2 -0
  25. package/bundle/chunk-2z3fe4qw.js +2 -0
  26. package/bundle/{chunk-g7v6sp3c.js → chunk-2zjet9tx.js} +2 -2
  27. package/bundle/{chunk-qgkb6n8k.js → chunk-32xd626h.js} +2 -2
  28. package/bundle/chunk-361cmmrp.js +2 -0
  29. package/bundle/{chunk-eg1m81ax.js → chunk-3mtjxmw1.js} +1 -1
  30. package/bundle/chunk-3r6dq1h3.js +2 -0
  31. package/bundle/{chunk-wtt5wms9.js → chunk-3sj0jv91.js} +1 -1
  32. package/bundle/{chunk-hz02vrqs.js → chunk-3vae1s42.js} +1 -1
  33. package/bundle/{chunk-t18ka1e7.js → chunk-3yfjgks3.js} +1 -1
  34. package/bundle/{chunk-phf37x1c.js → chunk-3zzrdpsx.js} +1 -1
  35. package/bundle/chunk-4a12wv2m.js +2 -0
  36. package/bundle/{chunk-1rgt2vmt.js → chunk-4a9jqe5s.js} +1 -1
  37. package/bundle/{chunk-wqk1v8t0.js → chunk-4sa9t0vx.js} +2 -2
  38. package/bundle/{chunk-qbnt4ynd.js → chunk-532fnfmw.js} +2 -2
  39. package/bundle/chunk-547a55ba.js +2 -0
  40. package/bundle/{chunk-vr8nwzp0.js → chunk-56yp5v0w.js} +1 -1
  41. package/bundle/{chunk-ag8wxwwz.js → chunk-5fcyb122.js} +1 -1
  42. package/bundle/{chunk-4pmvxnkj.js → chunk-5nm5egq0.js} +2 -2
  43. package/bundle/{chunk-1v0khv7p.js → chunk-5p2r8bxx.js} +1 -1
  44. package/bundle/{chunk-5bv63rqj.js → chunk-5rqjze1g.js} +1 -1
  45. package/bundle/{chunk-sy9w1t2y.js → chunk-5w7ebtcd.js} +1 -1
  46. package/bundle/chunk-5ztmc770.js +2 -0
  47. package/bundle/{chunk-a1z8rnq7.js → chunk-61t4g8bh.js} +4 -4
  48. package/bundle/chunk-62x3r2q8.js +2 -0
  49. package/bundle/chunk-62y6zk9x.js +2 -0
  50. package/bundle/{chunk-c76cjhn0.js → chunk-6axm2qtj.js} +1 -1
  51. package/bundle/{chunk-zfrftgcy.js → chunk-6gbdvz6p.js} +1 -1
  52. package/bundle/{chunk-fa8pwdwv.js → chunk-6mnk5sg3.js} +1 -1
  53. package/bundle/chunk-6th7vpwm.js +2 -0
  54. package/bundle/{chunk-8yzghzjq.js → chunk-6wjdhvdf.js} +1 -1
  55. package/bundle/{chunk-a8bjcvda.js → chunk-6y58jzak.js} +1 -1
  56. package/bundle/chunk-6ybh5smv.js +2 -0
  57. package/bundle/chunk-73kprndw.js +2 -0
  58. package/bundle/chunk-79fr19xf.js +2 -0
  59. package/bundle/{chunk-3va85mbe.js → chunk-7a3txs9f.js} +2 -2
  60. package/bundle/chunk-7ezr478e.js +2 -0
  61. package/bundle/chunk-7gj1vqyj.js +2 -0
  62. package/bundle/{chunk-eacpc64g.js → chunk-7hdb1fhq.js} +2 -2
  63. package/bundle/{chunk-t8fjgkp8.js → chunk-7rbg6mg9.js} +2 -2
  64. package/bundle/{chunk-59csnjc3.js → chunk-7s0nq2aa.js} +2 -2
  65. package/bundle/chunk-7ywfkwb4.js +2 -0
  66. package/bundle/chunk-819qr675.js +2 -0
  67. package/bundle/{chunk-g6y2c5az.js → chunk-81dvy370.js} +1 -1
  68. package/bundle/chunk-85fnnwm2.js +2 -0
  69. package/bundle/chunk-89fwh84w.js +2 -0
  70. package/bundle/chunk-8e724g3k.js +2 -0
  71. package/bundle/{chunk-k6981ysw.js → chunk-8gpjmj42.js} +3 -3
  72. package/bundle/{chunk-wtxh5m6j.js → chunk-8nnajdwf.js} +3 -3
  73. package/bundle/chunk-8peby2d1.js +2 -0
  74. package/bundle/{chunk-702bt91p.js → chunk-8rkszwxq.js} +6 -6
  75. package/bundle/{chunk-w0nc0gcx.js → chunk-8v60bqm0.js} +1 -1
  76. package/bundle/chunk-9894a2yn.js +2 -0
  77. package/bundle/chunk-98ye2nwt.js +2 -0
  78. package/bundle/{chunk-48gap82w.js → chunk-9bbwxp5d.js} +1 -1
  79. package/bundle/{chunk-z0kbyr00.js → chunk-9d0exvey.js} +2 -2
  80. package/bundle/{chunk-8ysp6vf8.js → chunk-9fjcgdea.js} +1 -1
  81. package/bundle/{chunk-jpn9zfj5.js → chunk-9nf5650d.js} +1 -1
  82. package/bundle/{chunk-n6tqtk6h.js → chunk-9pj10pgd.js} +2 -2
  83. package/bundle/chunk-9s4excg8.js +2 -0
  84. package/bundle/{chunk-t6zz47zk.js → chunk-9s5h0f1y.js} +2 -2
  85. package/bundle/{chunk-p8ak162p.js → chunk-9tz18e54.js} +1 -1
  86. package/bundle/{chunk-fs1vb39f.js → chunk-9zy5tsry.js} +3 -3
  87. package/bundle/{chunk-bc2krtaf.js → chunk-a70m6kyn.js} +1 -1
  88. package/bundle/{chunk-cr5tknvb.js → chunk-acsqvgdw.js} +1 -1
  89. package/bundle/chunk-aetgcegz.js +2 -0
  90. package/bundle/chunk-agas0nay.js +2 -0
  91. package/bundle/{chunk-vs3s49jw.js → chunk-ajnzv5jt.js} +2 -2
  92. package/bundle/{chunk-9cf2ktyh.js → chunk-asxmkyz2.js} +1 -1
  93. package/bundle/{chunk-0ffmwhw7.js → chunk-at4dge22.js} +1 -1
  94. package/bundle/{chunk-sa0rrreh.js → chunk-atacnspd.js} +2 -2
  95. package/bundle/chunk-ayknzc4m.js +2 -0
  96. package/bundle/chunk-azss4acq.js +3 -0
  97. package/bundle/chunk-b2ybst88.js +2 -0
  98. package/bundle/{chunk-cghz0855.js → chunk-b8rzn48q.js} +1 -1
  99. package/bundle/{chunk-dhvx9p54.js → chunk-b9f78x5g.js} +1 -1
  100. package/bundle/chunk-bd5vtjd7.js +2 -0
  101. package/bundle/chunk-bjqqk6jt.js +2 -0
  102. package/bundle/{chunk-mv7q6ach.js → chunk-brk1jca3.js} +1 -1
  103. package/bundle/{chunk-5r7c6vvx.js → chunk-by1kwg4r.js} +2 -2
  104. package/bundle/{chunk-1acn5me8.js → chunk-c1c8ch3g.js} +327 -313
  105. package/bundle/{chunk-2nheahmq.js → chunk-c2ns2csn.js} +1 -1
  106. package/bundle/{chunk-qk5vy2pr.js → chunk-c3ey896z.js} +1 -1
  107. package/bundle/{chunk-b7sr9rn3.js → chunk-c8080519.js} +1 -1
  108. package/bundle/{chunk-vd8cmdpv.js → chunk-c8yc8qcd.js} +1 -1
  109. package/bundle/{chunk-nas631g2.js → chunk-c9cngded.js} +1 -1
  110. package/bundle/{chunk-ejhhrece.js → chunk-ccdjzn2m.js} +3 -3
  111. package/bundle/{chunk-rk0fnvp5.js → chunk-cdenq7jb.js} +1 -1
  112. package/bundle/chunk-cpkcdykz.js +2 -0
  113. package/bundle/{chunk-56wq8cqj.js → chunk-cs825mxr.js} +1 -1
  114. package/bundle/{chunk-1bxfzd6r.js → chunk-cxtwavyf.js} +4 -4
  115. package/bundle/chunk-cyafm8d6.js +2 -0
  116. package/bundle/{chunk-eewe7tx1.js → chunk-d0dsgxk4.js} +2 -2
  117. package/bundle/{chunk-g3n465ee.js → chunk-d1fv2c7s.js} +2 -2
  118. package/bundle/{chunk-1p9s5jj1.js → chunk-d1xfv4d3.js} +1 -1
  119. package/bundle/chunk-d4316r53.js +2 -0
  120. package/bundle/chunk-d8ym7mcg.js +2 -0
  121. package/bundle/{chunk-53jstmdp.js → chunk-d9w2bn2e.js} +1 -1
  122. package/bundle/{chunk-g26redah.js → chunk-dd461rg3.js} +1 -1
  123. package/bundle/{chunk-e0vrxetq.js → chunk-djfrkbd5.js} +1 -1
  124. package/bundle/{chunk-mrq35ftw.js → chunk-dm447tgc.js} +2 -2
  125. package/bundle/{chunk-7pckez5z.js → chunk-dnjyepb2.js} +2 -2
  126. package/bundle/chunk-dnpjxjkp.js +2 -0
  127. package/bundle/{chunk-0a4pmkc9.js → chunk-dp6ms01y.js} +2 -2
  128. package/bundle/{chunk-rdreeyv0.js → chunk-dx7rexx3.js} +3 -3
  129. package/bundle/{chunk-kre93a89.js → chunk-dz3kcsb6.js} +2 -2
  130. package/bundle/{chunk-dcv6wj9x.js → chunk-dzma8zvf.js} +2 -2
  131. package/bundle/{chunk-e2wfj86b.js → chunk-e10c0crf.js} +1 -1
  132. package/bundle/{chunk-wn63q3xp.js → chunk-e1x1mp9m.js} +1 -1
  133. package/bundle/{chunk-tk4z6r09.js → chunk-e3mrw0k7.js} +1 -1
  134. package/bundle/chunk-e5gjqtby.js +2 -0
  135. package/bundle/{chunk-3z2zn8rj.js → chunk-e72jwbfc.js} +1 -1
  136. package/bundle/{chunk-85wh85pk.js → chunk-eabbrt1p.js} +1 -1
  137. package/bundle/{chunk-jr80q31w.js → chunk-ecz4h0a2.js} +1 -1
  138. package/bundle/chunk-ee3mqzms.js +2 -0
  139. package/bundle/chunk-eme9xmh3.js +2 -0
  140. package/bundle/{chunk-cf9m9m9q.js → chunk-eqpep2m2.js} +1 -1
  141. package/bundle/chunk-er5f61s5.js +2 -0
  142. package/bundle/chunk-er716522.js +2 -0
  143. package/bundle/{chunk-qgek59e6.js → chunk-ev6jwt7q.js} +1 -1
  144. package/bundle/chunk-ez3gacqe.js +2 -0
  145. package/bundle/{chunk-ax64ngf2.js → chunk-f0ab2f28.js} +1 -1
  146. package/bundle/{chunk-ggncq8w8.js → chunk-f17se3hh.js} +1 -1
  147. package/bundle/chunk-f3y5kr76.js +14 -0
  148. package/bundle/{chunk-vsqvnxbz.js → chunk-f6btedtt.js} +1 -1
  149. package/bundle/{chunk-nsp1za8t.js → chunk-f6vy70p6.js} +2 -2
  150. package/bundle/{chunk-0s4cp6q2.js → chunk-ff8q10gk.js} +2 -2
  151. package/bundle/chunk-fkc7wf1p.js +2 -0
  152. package/bundle/chunk-fm6z8nqb.js +2 -0
  153. package/bundle/{chunk-fw1f47de.js → chunk-fsndgr9a.js} +1 -1
  154. package/bundle/{chunk-pqg1wjb5.js → chunk-fvv1cret.js} +1 -1
  155. package/bundle/{chunk-j10a984e.js → chunk-g08qj9z3.js} +2 -2
  156. package/bundle/chunk-g0qwm23d.js +2 -0
  157. package/bundle/chunk-g4yn8cj8.js +2 -0
  158. package/bundle/{chunk-rwwvy89t.js → chunk-g52wmt1v.js} +1 -1
  159. package/bundle/{chunk-trstb8ee.js → chunk-gb51fn3r.js} +1 -1
  160. package/bundle/{chunk-kgv68cpb.js → chunk-gbnf7zf9.js} +1 -1
  161. package/bundle/{chunk-0w19vmd7.js → chunk-ge7csm6m.js} +2 -2
  162. package/bundle/{chunk-bkfafcbw.js → chunk-gksbv613.js} +2 -2
  163. package/bundle/{chunk-afr8m0q1.js → chunk-gmq1kwn0.js} +1 -1
  164. package/bundle/{chunk-b5ym419d.js → chunk-gq3zb4wv.js} +2 -2
  165. package/bundle/{chunk-tbx741en.js → chunk-gqgjybjc.js} +1 -1
  166. package/bundle/{chunk-bhg69t69.js → chunk-gx4v8z64.js} +2 -2
  167. package/bundle/{chunk-sm1g81cv.js → chunk-h0pvxre5.js} +1 -1
  168. package/bundle/chunk-h1spsy3y.js +2 -0
  169. package/bundle/{chunk-sbjymf20.js → chunk-h2p984qb.js} +2 -2
  170. package/bundle/{chunk-gznt3dv8.js → chunk-h6z86aay.js} +1 -1
  171. package/bundle/chunk-h8gkv40j.js +2 -0
  172. package/bundle/{chunk-zsg29gba.js → chunk-h91zmzs5.js} +1 -1
  173. package/bundle/{chunk-zrhw1szj.js → chunk-hgm8yfcb.js} +1 -1
  174. package/bundle/chunk-j59kmb49.js +2 -0
  175. package/bundle/chunk-j5z95b6f.js +3 -0
  176. package/bundle/{chunk-52xvhxek.js → chunk-j7637cwg.js} +2 -2
  177. package/bundle/{chunk-rwnwjm82.js → chunk-jbcqhw3x.js} +2 -2
  178. package/bundle/{chunk-maa21rh9.js → chunk-je8fcsa9.js} +1 -1
  179. package/bundle/{chunk-y0h3jfkj.js → chunk-jt6bvxtr.js} +1 -1
  180. package/bundle/chunk-jv37ghev.js +2 -0
  181. package/bundle/chunk-k10rtgsk.js +5 -0
  182. package/bundle/chunk-k3hcb6qf.js +2 -0
  183. package/bundle/chunk-k5d822n2.js +3 -0
  184. package/bundle/{chunk-2vaphpz0.js → chunk-kc8n5cgb.js} +1 -1
  185. package/bundle/chunk-kcqeh1e5.js +2 -0
  186. package/bundle/{chunk-5xkp27b1.js → chunk-kds2g7r2.js} +1 -1
  187. package/bundle/{chunk-scnbt714.js → chunk-kec1xw1n.js} +1 -1
  188. package/bundle/{chunk-13jq2ygc.js → chunk-kk850sdw.js} +2 -2
  189. package/bundle/{chunk-3bb4aqh9.js → chunk-m01h6kk1.js} +1 -1
  190. package/bundle/{chunk-e0hha3be.js → chunk-m4j6t713.js} +1 -1
  191. package/bundle/chunk-m8ytbq04.js +2 -0
  192. package/bundle/chunk-mf9nc4xz.js +2 -0
  193. package/bundle/{chunk-7thhd7ds.js → chunk-mmqyter3.js} +1 -1
  194. package/bundle/{chunk-y31f8k5f.js → chunk-mn0pshpv.js} +1 -1
  195. package/bundle/{chunk-s2tc3qs0.js → chunk-mn5cacf6.js} +2 -2
  196. package/bundle/{chunk-0egrckx0.js → chunk-mp1x10t5.js} +2 -2
  197. package/bundle/chunk-mxby91bj.js +2 -0
  198. package/bundle/chunk-mzv1gh6f.js +2 -0
  199. package/bundle/chunk-n0hsvvw8.js +2 -0
  200. package/bundle/{chunk-az3nss5m.js → chunk-ngyv4fhn.js} +2 -2
  201. package/bundle/{chunk-g9nwqwqp.js → chunk-nh4zk07t.js} +1 -1
  202. package/bundle/{chunk-8jmb5bd4.js → chunk-nk5vrenn.js} +2 -2
  203. package/bundle/chunk-nm1v9z14.js +2 -0
  204. package/bundle/chunk-nnkfdhh9.js +2 -0
  205. package/bundle/{chunk-jqj1ay7x.js → chunk-npdgfqaw.js} +1 -1
  206. package/bundle/{chunk-p2fte9vz.js → chunk-nq4x6792.js} +2 -2
  207. package/bundle/{chunk-wr6rnxr5.js → chunk-nqk8d62j.js} +1 -1
  208. package/bundle/{chunk-7jy53zqy.js → chunk-p506eydh.js} +1 -1
  209. package/bundle/{chunk-phpxxd48.js → chunk-p6jf1fyt.js} +1 -1
  210. package/bundle/chunk-p7nstcxa.js +2 -0
  211. package/bundle/{chunk-6ps30qax.js → chunk-pbanj1gk.js} +2 -2
  212. package/bundle/{chunk-vph4w4yy.js → chunk-pchv413c.js} +2 -2
  213. package/bundle/{chunk-qsme16gk.js → chunk-pf2vq6t1.js} +2 -2
  214. package/bundle/chunk-pfwkvv7g.js +2 -0
  215. package/bundle/{chunk-ntr0ezf2.js → chunk-pky8h8rh.js} +1 -1
  216. package/bundle/chunk-pn1jz8qj.js +2 -0
  217. package/bundle/chunk-pqvmtfk7.js +2 -0
  218. package/bundle/chunk-prgw26g3.js +2 -0
  219. package/bundle/{chunk-kckr30tf.js → chunk-psqtptrs.js} +1 -1
  220. package/bundle/chunk-pv9ty6v7.js +2 -0
  221. package/bundle/{chunk-060wbpz4.js → chunk-pwsajn96.js} +1 -1
  222. package/bundle/{chunk-vgt3artc.js → chunk-pxm0x3e0.js} +1 -1
  223. package/bundle/chunk-pyf649pz.js +2 -0
  224. package/bundle/{chunk-wd8f9r4k.js → chunk-q0xgxygw.js} +1 -1
  225. package/bundle/{chunk-rye1yjnr.js → chunk-q26s0wb5.js} +1 -1
  226. package/bundle/{chunk-a48mx917.js → chunk-q4mtwv1w.js} +2 -2
  227. package/bundle/chunk-q4rstre7.js +2 -0
  228. package/bundle/chunk-q6jk2v6g.js +2 -0
  229. package/bundle/{chunk-5wx962mw.js → chunk-q7s6z0nz.js} +1 -1
  230. package/bundle/{chunk-jmmtcr2r.js → chunk-q8fjktv4.js} +1 -1
  231. package/bundle/{chunk-m7tmgvh6.js → chunk-qbewhcsz.js} +1 -1
  232. package/bundle/chunk-qd43npx3.js +2 -0
  233. package/bundle/{chunk-ydgst3h8.js → chunk-qdafm7qg.js} +2 -2
  234. package/bundle/chunk-qdb21y83.js +2 -0
  235. package/bundle/{chunk-72crs18f.js → chunk-qdbx1qkr.js} +1 -1
  236. package/bundle/{chunk-6vnqbejg.js → chunk-qdh2dm62.js} +1 -1
  237. package/bundle/chunk-qeksaefy.js +2 -0
  238. package/bundle/{chunk-qk1jkc0n.js → chunk-qjw2zcq5.js} +1 -1
  239. package/bundle/{chunk-dt3bsmfe.js → chunk-qm9fm5ja.js} +2 -2
  240. package/bundle/{chunk-h8mfbbjh.js → chunk-qq9yc2tp.js} +2 -2
  241. package/bundle/{chunk-0tcggtwv.js → chunk-qtyapmy7.js} +1 -1
  242. package/bundle/{chunk-c987bemn.js → chunk-qyan69nb.js} +1 -1
  243. package/bundle/chunk-r7t9yb9d.js +2 -0
  244. package/bundle/{chunk-6tqbnxar.js → chunk-r81w6skn.js} +1 -1
  245. package/bundle/{chunk-f4mnp6xd.js → chunk-rk21wv4k.js} +1 -1
  246. package/bundle/{chunk-ccf4pgkr.js → chunk-rpdgn9z3.js} +2 -2
  247. package/bundle/chunk-rxnd79h7.js +7 -0
  248. package/bundle/chunk-s05hqtx1.js +3 -0
  249. package/bundle/chunk-s27cz24e.js +808 -0
  250. package/bundle/chunk-sdv3a4w3.js +2 -0
  251. package/bundle/{chunk-zwhmg9dj.js → chunk-se8d5xg9.js} +1 -1
  252. package/bundle/chunk-sk89becn.js +2 -0
  253. package/bundle/{chunk-sz0favtz.js → chunk-snf6ahg7.js} +1 -1
  254. package/bundle/{chunk-dgcannw0.js → chunk-t2r51r6v.js} +1 -1
  255. package/bundle/{chunk-rva2ekrt.js → chunk-t5wdstzv.js} +1 -1
  256. package/bundle/{chunk-vkkz40je.js → chunk-t9pq363q.js} +2 -2
  257. package/bundle/chunk-tc0996xz.js +2 -0
  258. package/bundle/chunk-td9hm9be.js +2 -0
  259. package/bundle/{chunk-xy8arehp.js → chunk-tdevq564.js} +1 -1
  260. package/bundle/chunk-te91d271.js +2 -0
  261. package/bundle/chunk-tfs50mgj.js +2 -0
  262. package/bundle/{chunk-5cw8235e.js → chunk-tg1f56s3.js} +1 -1
  263. package/bundle/chunk-thecq33z.js +3 -0
  264. package/bundle/{chunk-f2v4g7t1.js → chunk-tjfer79w.js} +1 -1
  265. package/bundle/chunk-tjvtp9d9.js +2 -0
  266. package/bundle/chunk-tkm9m3n0.js +2 -0
  267. package/bundle/{chunk-ynf17943.js → chunk-tm79yrf3.js} +2 -2
  268. package/bundle/{chunk-fv5mrdyc.js → chunk-v03xq38e.js} +2 -2
  269. package/bundle/chunk-v0hnn7nb.js +2 -0
  270. package/bundle/{chunk-ftvvm4r5.js → chunk-v16n1fep.js} +2 -2
  271. package/bundle/chunk-v1s1rcqx.js +2 -0
  272. package/bundle/chunk-v4dt4062.js +2 -0
  273. package/bundle/{chunk-makegrxs.js → chunk-v8bxj01h.js} +1 -1
  274. package/bundle/{chunk-ryrxgn6d.js → chunk-v8rqgt7h.js} +1 -1
  275. package/bundle/{chunk-m4r8sepw.js → chunk-vbb1jg02.js} +1 -1
  276. package/bundle/{chunk-2kh0tg92.js → chunk-vbfc0wgv.js} +2 -2
  277. package/bundle/{chunk-d839fr0w.js → chunk-vjt6mh10.js} +2 -2
  278. package/bundle/{chunk-gsg6zn7e.js → chunk-vk35g121.js} +2 -2
  279. package/bundle/{chunk-dwkrqtbc.js → chunk-vsfj16v9.js} +2 -2
  280. package/bundle/{chunk-zqdjk4rf.js → chunk-vy93mn7d.js} +2 -2
  281. package/bundle/{chunk-1har4t9a.js → chunk-waa781eh.js} +1 -1
  282. package/bundle/{chunk-wb47k8ah.js → chunk-wbt31xap.js} +2 -2
  283. package/bundle/{chunk-0tm6589k.js → chunk-wd2xmkdp.js} +2 -2
  284. package/bundle/{chunk-fej5x648.js → chunk-wecs14rz.js} +1 -1
  285. package/bundle/chunk-wgrq86kd.js +2 -0
  286. package/bundle/{chunk-4y9wbfd2.js → chunk-wh2qqhep.js} +2 -2
  287. package/bundle/{chunk-g878zd6e.js → chunk-x0hhw46n.js} +1 -1
  288. package/bundle/{chunk-w7a33cwa.js → chunk-x308f9j4.js} +2 -2
  289. package/bundle/{chunk-y3gy62q5.js → chunk-x50adh71.js} +1 -1
  290. package/bundle/chunk-x8ks2bn7.js +2 -0
  291. package/bundle/{chunk-s5aefff0.js → chunk-xcmbxny8.js} +1 -1
  292. package/bundle/{chunk-rmsqb6r4.js → chunk-xgf4k9q7.js} +1 -1
  293. package/bundle/{chunk-2caaqmec.js → chunk-xj0zc9za.js} +1 -1
  294. package/bundle/{chunk-27saej0r.js → chunk-xnxw5zz9.js} +2 -2
  295. package/bundle/{chunk-fjftb2sz.js → chunk-xqwk2zsx.js} +2 -2
  296. package/bundle/{chunk-d30k7dpf.js → chunk-xstxdw7v.js} +1 -1
  297. package/bundle/{chunk-dwqvcdmf.js → chunk-xv03hbgj.js} +1 -1
  298. package/bundle/{chunk-bwadggys.js → chunk-xvvt886p.js} +2 -2
  299. package/bundle/{chunk-bnw744ej.js → chunk-xy2ty5h5.js} +2 -2
  300. package/bundle/{chunk-wm9nh9nb.js → chunk-yce8ph5b.js} +2 -2
  301. package/bundle/{chunk-fh3d0wce.js → chunk-yexzxx6f.js} +1 -1
  302. package/bundle/{chunk-eyr5ymt8.js → chunk-yh1t6jrj.js} +1 -1
  303. package/bundle/chunk-yspstxkq.js +2 -0
  304. package/bundle/{chunk-ykpj10nz.js → chunk-yydqavgh.js} +2 -2
  305. package/bundle/{chunk-k3m7jfdh.js → chunk-yzd6cyep.js} +1 -1
  306. package/bundle/chunk-z023h7t8.js +2 -0
  307. package/bundle/chunk-z0383stv.js +2 -0
  308. package/bundle/{chunk-vbfej8ds.js → chunk-z0m1qm7j.js} +2 -2
  309. package/bundle/{chunk-bpfq8fz4.js → chunk-z69tt390.js} +1 -1
  310. package/bundle/chunk-zewrmk8x.js +2 -0
  311. package/bundle/{chunk-29gwtcey.js → chunk-zfqgh9h7.js} +1 -1
  312. package/bundle/{chunk-h1bvqstw.js → chunk-zskdxbbh.js} +1 -1
  313. package/bundle/{chunk-kveztc6k.js → chunk-ztvkzex1.js} +1 -1
  314. package/bundle/index.js +3 -3
  315. package/bundle/parser.worker.js +2 -2
  316. package/bundle/worker.js +1 -1
  317. package/package.json +1 -1
  318. package/bundle/chunk-03zpnwk2.js +0 -2
  319. package/bundle/chunk-0aqdzyar.js +0 -2
  320. package/bundle/chunk-0eh3yc6e.js +0 -2
  321. package/bundle/chunk-0mh600tv.js +0 -2
  322. package/bundle/chunk-1a6q1f5n.js +0 -7
  323. package/bundle/chunk-2a5gjgvp.js +0 -2
  324. package/bundle/chunk-2phyc1c0.js +0 -2
  325. package/bundle/chunk-2pkfphgb.js +0 -2
  326. package/bundle/chunk-30wp95w1.js +0 -2
  327. package/bundle/chunk-32fpqd0n.js +0 -2
  328. package/bundle/chunk-3f2cjzb4.js +0 -2
  329. package/bundle/chunk-3qvap1kv.js +0 -2
  330. package/bundle/chunk-42hvspe7.js +0 -2
  331. package/bundle/chunk-452tk6v3.js +0 -2
  332. package/bundle/chunk-4gqb1hps.js +0 -2
  333. package/bundle/chunk-50qgz5ka.js +0 -2
  334. package/bundle/chunk-539cw9r0.js +0 -2
  335. package/bundle/chunk-5b0xyq5z.js +0 -2
  336. package/bundle/chunk-5j4nxpdy.js +0 -2
  337. package/bundle/chunk-5nxgk6hw.js +0 -2
  338. package/bundle/chunk-5qkvhr6y.js +0 -2
  339. package/bundle/chunk-6dpdkzrk.js +0 -2
  340. package/bundle/chunk-6p6m5956.js +0 -3
  341. package/bundle/chunk-705qkpra.js +0 -28
  342. package/bundle/chunk-76c400ze.js +0 -2
  343. package/bundle/chunk-7bxxc4a3.js +0 -2
  344. package/bundle/chunk-7g59hc61.js +0 -2
  345. package/bundle/chunk-7p88j56s.js +0 -2
  346. package/bundle/chunk-7r92d7v9.js +0 -14
  347. package/bundle/chunk-7trngc9g.js +0 -2
  348. package/bundle/chunk-8cebbmtf.js +0 -2
  349. package/bundle/chunk-8j1xcdmd.js +0 -2
  350. package/bundle/chunk-90r2z49k.js +0 -2
  351. package/bundle/chunk-94mjwy22.js +0 -2
  352. package/bundle/chunk-9bw6bx5c.js +0 -2
  353. package/bundle/chunk-aenrd7dk.js +0 -2
  354. package/bundle/chunk-ahmy80vb.js +0 -2
  355. package/bundle/chunk-avn12jkt.js +0 -2
  356. package/bundle/chunk-brk6bge4.js +0 -3
  357. package/bundle/chunk-ce5e7j62.js +0 -2
  358. package/bundle/chunk-cw1gwjx9.js +0 -2
  359. package/bundle/chunk-czw30fjs.js +0 -2
  360. package/bundle/chunk-dtcvqrmn.js +0 -2
  361. package/bundle/chunk-dwhsvpag.js +0 -2
  362. package/bundle/chunk-e0hfpdje.js +0 -2
  363. package/bundle/chunk-e5jk67xh.js +0 -2
  364. package/bundle/chunk-eg4pq4hv.js +0 -2
  365. package/bundle/chunk-ew3yz97p.js +0 -2
  366. package/bundle/chunk-f2yfyhh8.js +0 -2
  367. package/bundle/chunk-fd8x2nb4.js +0 -2
  368. package/bundle/chunk-fveaq0pb.js +0 -2
  369. package/bundle/chunk-gbvm6dpv.js +0 -2
  370. package/bundle/chunk-gkbx6edf.js +0 -2
  371. package/bundle/chunk-gq9hb2e8.js +0 -2
  372. package/bundle/chunk-gswhjd1h.js +0 -3
  373. package/bundle/chunk-h5w91zr4.js +0 -2
  374. package/bundle/chunk-hmpb3c21.js +0 -2
  375. package/bundle/chunk-hq7s4f75.js +0 -2
  376. package/bundle/chunk-j1h64m65.js +0 -2
  377. package/bundle/chunk-j32rr7rt.js +0 -2
  378. package/bundle/chunk-j871xzr7.js +0 -2
  379. package/bundle/chunk-k1qd8ecm.js +0 -808
  380. package/bundle/chunk-kx88qekb.js +0 -2
  381. package/bundle/chunk-m4g4djss.js +0 -2
  382. package/bundle/chunk-mt2by7rx.js +0 -3
  383. package/bundle/chunk-mwkms65j.js +0 -3
  384. package/bundle/chunk-n61e0znt.js +0 -2
  385. package/bundle/chunk-ndd4cn3z.js +0 -2
  386. package/bundle/chunk-nr2j8ytn.js +0 -3
  387. package/bundle/chunk-nsw5x43k.js +0 -2
  388. package/bundle/chunk-p5b5ekhh.js +0 -2
  389. package/bundle/chunk-pf23nw4z.js +0 -2
  390. package/bundle/chunk-pw3cv89g.js +0 -2
  391. package/bundle/chunk-qwmae3vk.js +0 -5
  392. package/bundle/chunk-rdk62809.js +0 -2
  393. package/bundle/chunk-rew6r516.js +0 -2
  394. package/bundle/chunk-rjcz4kbm.js +0 -2
  395. package/bundle/chunk-skgr9ypq.js +0 -2
  396. package/bundle/chunk-sv40pwe2.js +0 -2
  397. package/bundle/chunk-tax3ecy5.js +0 -2
  398. package/bundle/chunk-tfhpjmny.js +0 -2
  399. package/bundle/chunk-tnete6ye.js +0 -2
  400. package/bundle/chunk-tpyq7ycb.js +0 -2
  401. package/bundle/chunk-tr0rm1ka.js +0 -2
  402. package/bundle/chunk-ty14zznd.js +0 -2
  403. package/bundle/chunk-v5h5wxw5.js +0 -2
  404. package/bundle/chunk-v6141yq1.js +0 -2
  405. package/bundle/chunk-vjs69r6x.js +0 -2
  406. package/bundle/chunk-vmhar83s.js +0 -2
  407. package/bundle/chunk-vpjyk76v.js +0 -2
  408. package/bundle/chunk-vqvnw12p.js +0 -2
  409. package/bundle/chunk-w0sztk4y.js +0 -2
  410. package/bundle/chunk-w6bb320d.js +0 -2
  411. package/bundle/chunk-wqw6yjrg.js +0 -2
  412. package/bundle/chunk-ws08rxge.js +0 -2
  413. package/bundle/chunk-wwvek9zf.js +0 -3
  414. package/bundle/chunk-wz3dvc3g.js +0 -2
  415. package/bundle/chunk-x2pmqvdc.js +0 -2
  416. package/bundle/chunk-x4wfq39v.js +0 -2
  417. package/bundle/chunk-x7a3kqe5.js +0 -2
  418. package/bundle/chunk-xb22grz6.js +0 -2
  419. package/bundle/chunk-y3eeva80.js +0 -2
  420. package/bundle/chunk-yb6m08zj.js +0 -2
  421. package/bundle/chunk-ybcqkgs7.js +0 -2
  422. package/bundle/chunk-zj1jc1xt.js +0 -2
  423. package/bundle/chunk-zm0m0504.js +0 -2
  424. package/bundle/chunk-zq32jhj1.js +0 -2
  425. package/bundle/chunk-zxwjxszn.js +0 -2
@@ -0,0 +1,14 @@
1
+ // @bun
2
+ import{hg as Ai,ig as t1,jg as b1,kg as k1,lg as p1,mg as e1,ng as s1,og as f1,pg as rA,qg as nA,rg as a1,ug as cA}from"./chunk-ff8q10gk.js";import{vg as Er,wg as L1}from"./chunk-dm447tgc.js";import{Ag as W1}from"./chunk-f6vy70p6.js";import{Fg as Sc}from"./chunk-thecq33z.js";import{Hg as Ey}from"./chunk-32xd626h.js";import{Ig as r2}from"./chunk-dzma8zvf.js";import{Jg as Ml,Kg as zl,Lg as dn,Mg as _i,Tg as Xr,Ug as Tl,Vg as Km,Xg as Hm,Yg as pn,Zg as tn,_g as nm,ah as mm,ch as _r,dh as bc,gh as j1,hh as ql,jh as tc,kh as _l,lh as ol,mh as ji,nh as Ll,oh as Fl,ph as b0,qh as Rm,sh as w1,th as Dr,uh as Ii,vh as Wr,xh as e}from"./chunk-c1c8ch3g.js";import{$k as cr,Dj as fj,Dk as qr,Ej as tr,Ek as Fn,Fj as Rr,Fk as AA,Gj as D2,Hj as yr,Ij as br,Jj as vn,Kj as un,Kk as l1,Nj as Ym,Pk as ir,Qk as Cr,Rk as Ar,Tk as $2,Uk as I0,Vj as v1,Wj as s,Xj as er,_k as Z,sj as wr,sk as Pi,tj as rm,tk as Qr,uj as J1,vj as O1,xj as f0,yj as qi,zj as R1}from"./chunk-s27cz24e.js";import{bl as al,ll as uI}from"./chunk-gx4v8z64.js";import{Bl as Wn,Dl as y0,Hl as Gr,Jl as o,ml as Lr,ql as bj,rl as mr,sl as Kn,tl as Hn,yl as mA,zl as b}from"./chunk-v03xq38e.js";import{Vl as jn}from"./chunk-dx7rexx3.js";import{Am as M1,Em as T1,Fm as fi,Um as l0,rm as _n,tm as tj,wm as d,ym as im,zm as o1}from"./chunk-xgf4k9q7.js";import{Ln as g}from"./chunk-r81w6skn.js";import{_o as P1,tp as C1}from"./chunk-wh2qqhep.js";import{tr as bI,ur as eI,vr as Di}from"./chunk-gq3zb4wv.js";import{Er as fI,Fr as r1}from"./chunk-2cvwrabw.js";import{$r as Pr,Lr as CI,Or as Wi,_r as B0,as as WI,bs as x0,cs as XI,ds as KI,es as HI,fs as RI,gs as zr,hs as Ql,is as k0,js as VI,ks as YI,ls as ZI,ms as JI,ns as p0,os as OI,ps as sI,qs as LI,rs as qI,ss as _I,ts as _2,us as Im}from"./chunk-4sa9t0vx.js";import{_s as r0}from"./chunk-wd2xmkdp.js";import{bt as lA,nt as aI}from"./chunk-azss4acq.js";import{Et as Tj,Gt as c0}from"./chunk-0bhzhh7s.js";import{Lt as p,Ut as _}from"./chunk-7s0nq2aa.js";import{$t as IA,_t as kl,du as Xn,iu as Zn}from"./chunk-cxtwavyf.js";import{ju as I}from"./chunk-15bjhfav.js";import{Dz as In,cA as cI,dA as lI}from"./chunk-x308f9j4.js";import{$C as L2,$F as J0,$G as $m,$L as T0,AI as Al,BA as Xl,BF as M,BI as Sl,BM as ml,CA as zn,CI as e2,DC as AI,DG as O0,DI as s2,EI as X2,FI as ec,FM as K2,GA as x2,GI as wl,HI as f2,IA as C2,JG as Bn,KO as Fr,LK as PI,MO as cl,NO as R0,OG as wI,OM as Dm,QE as S1,QH as Pl,RC as MI,RO as F,TC as Tn,TM as sc,WG as Gl,WM as jm,ZA as on,_B as Dl,aC as k2,aD as q2,aH as $I,aM as Nl,bF as Sm,bH as Ul,bN as Ri,cD as H0,cI as P,eH as o2,eM as rI,fG as t,fN as Ci,gC as p2,gI as GI,hC as a2,hN as gr,iD as d2,iI as NI,iJ as UI,jC as Qm,jI as Li,kC as $r,kI as Cl,lC as Y0,mG as vm,mM as nI,nC as Br,nG as wm,nI as EI,oC as Sn,oI as QI,oM as iI,pC as L0,pG as SI,pM as mI,rC as Um,rF as z2,sC as Il,tC as vl,tG as hn,tM as X0,uC as or,uI as DI,vC as Am,vF as Z0,vI as v0,vM as K0,wC as u2,xC as Vn,xG as vI,xI as t2,xM as Pm,yI as S0,zA as An,zG as h0,zI as b2,zM as El}from"./chunk-2zjet9tx.js";import{qP as Av,rP as nr,sP as Nr,uP as sn}from"./chunk-djfrkbd5.js";var pm=nr((hy)=>{Object.defineProperty(hy,"__esModule",{value:!0});hy.default=tA;var My=/[A-Z]/g;function Ty(r){return r.toLowerCase()}function tA(r,n){let i=r.replace(My,Ty),m=n.replace(My,Ty);return i===m}});var Rc=nr((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 Vc=nr((py)=>{Object.defineProperty(py,"__esModule",{value:!0});py.toType=py.toString=void 0;var ky=(r)=>{return"_"+r},sA=(r)=>{return["name","protocol","subtype"].includes(r)},fA=(r)=>{let n={name:r.name,protocol:r.protocol,subtype:r.subtype};return Object.entries(n).filter(([m,c])=>sA(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(".")};py.toString=fA;var rS=(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}};py.toType=rS});var Zc=nr((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(sn("os")),iS=dy(Rc()),mS=sn("events"),cS=Vc(),am=".local";class Yc extends mS.EventEmitter{constructor(r){super();if(this.probe=!0,this.published=!1,this.activated=!1,this.destroyed=!1,this.txtService=new iS.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,cS.toString)({name:r.type,protocol:this.protocol}),this.port=r.port,this.host=r.host||uy.default.hostname(),this.fqdn=`${this.name}.${this.type}${am}`,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}${am}`,type:"PTR",ttl:28800,data:r.fqdn}}RecordSubtypePTR(r,n){return{name:`_${n}._sub.${r.type}${am}`,type:"PTR",ttl:28800,data:`${r.name}.${r.type}${am}`}}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 by=nr((fn)=>{var ty=fn&&fn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(fn,"__esModule",{value:!0});fn.Registry=void 0;var lS=ty(pm()),Jc=ty(Zc()),yS=3600000,jS=3,IS=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=IS;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,lS.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*jS,i<yS&&!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)})}}fn.Registry=Oc;fn.default=Oc});var ey=nr((AS)=>{AS.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};AS.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=nr((wS)=>{wS.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};wS.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=nr((NS)=>{NS.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};NS.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=nr((DS)=>{DS.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};DS.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=nr((CS)=>{CS.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}`};CS.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=nr((mj,Lc)=>{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:(N)=>n.test(N),encode(N,E,Q){Q=~~Q,E=E||new Uint8Array(Q+i);let W=N.length,H=0;for(let X=0;X<W;){let K=N.charCodeAt(X++);if(K===46)E[Q++]=H,H=0;else H=H*10+(K-48)}return E[Q]=H,E},decode(N,E){return E=~~E,`${N[E++]}.${N[E++]}.${N[E++]}.${N[E]}`}};r.v4=l;let y={name:"v6",size:c,isFormat:(N)=>N.length>0&&m.test(N),encode(N,E,Q){Q=~~Q;let W=Q+c,H=-1,X=0,K=0,J=!0,q=!1;E=E||new Uint8Array(Q+c);for(let z=0;z<N.length;z++){let L=N.charCodeAt(z);if(L===58){if(J){if(H!==-1){if(Q<W)E[Q]=0;if(Q<W-1)E[Q+1]=0;Q+=2}else if(Q<W)H=Q}else{if(q===!0){if(Q<W)E[Q]=K;Q++}else{if(Q<W)E[Q]=X>>8;if(Q<W-1)E[Q+1]=X&255;Q+=2}X=0,K=0}J=!0,q=!1}else if(L===46){if(Q<W)E[Q]=K;Q++,K=0,X=0,J=!1,q=!0}else{if(J=!1,L>=97)L-=87;else if(L>=65)L-=55;else L-=48,K=K*10+L;X=(X<<4)+L}}if(J===!1)if(q===!0){if(Q<W)E[Q]=K;Q++}else{if(Q<W)E[Q]=X>>8;if(Q<W-1)E[Q+1]=X&255;Q+=2}else if(H===0){if(Q<W)E[Q]=0;if(Q<W-1)E[Q+1]=0;Q+=2}else if(H!==-1){Q+=2;for(let z=Math.min(Q-1,W-1);z>=H+2;z--)E[z]=E[z-2];E[H]=0,E[H+1]=0,H=Q}if(H!==Q&&H!==-1){if(Q>W-2)Q=W-2;while(W>H)E[--W]=Q<W&&Q>H?E[--Q]:0}else while(Q<W)E[Q++]=0;return E},decode(N,E){E=~~E;let Q="";for(let W=0;W<c;W+=2){if(W!==0)Q+=":";Q+=(N[E+W]<<8|N[E+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(N){if(l.isFormat(N))return l.size;if(y.isFormat(N))return y.size;throw Error(`Invalid ip address: ${N}`)}function S(N){return A(N)===l.size?1:2}function v(N,E,Q){Q=~~Q;let W=A(N);if(typeof E==="function")E=E(Q+W);if(W===l.size)return l.encode(N,E,Q);return y.encode(N,E,Q)}function w(N,E,Q){if(E=~~E,Q=Q||N.length-E,Q===l.size)return l.decode(N,E,Q);if(Q===y.size)return y.decode(N,E,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 Lc==="object"&&typeof mj==="object")Lc.exports=ij});var lj=nr((YS)=>{var Y=sn("buffer").Buffer,Cn=ey(),KS=sy(),HS=fy(),dm=rj(),gc=nj(),ri=cj(),R=YS.name={};R.encode=function(r,n,i,{mail:m=!1}={}){if(!n)n=Y.alloc(R.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,R.encode.bytes=i-c,n};R.encode.bytes=0;R.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 R.decode.bytes=y,m.length===0?".":m.join(".")};R.decode.bytes=0;R.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:HS.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:KS.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=YS.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=YS.ns={};$n.encode=function(r,n,i){if(!n)n=Y.alloc($n.encodingLength(r));if(!i)i=0;return R.encode(r,n,i+2),n.writeUInt16BE(R.encode.bytes,i),$n.encode.bytes=R.encode.bytes+2,n};$n.encode.bytes=0;$n.decode=function(r,n){if(!n)n=0;let i=r.readUInt16BE(n),m=R.decode(r,n+2);return $n.decode.bytes=i+2,m};$n.decode.bytes=0;$n.encodingLength=function(r){return R.encodingLength(r)+2};var Gn=YS.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,R.encode(r.mname,n,i),i+=R.encode.bytes,R.encode(r.rname,n,i,{mail:!0}),i+=R.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=R.decode(r,n),n+=R.decode.bytes,m.rname=R.decode(r,n,{mail:!0}),n+=R.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+R.encodingLength(r.mname)+R.encodingLength(r.rname)};var Nn=YS.txt={};Nn.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(Nn.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),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=[];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 Nn.decode.bytes=n-i,c};Nn.decode.bytes=0;Nn.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 En=YS.null={};En.encode=function(r,n,i){if(!n)n=Y.alloc(En.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),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=r.slice(n,n+m);return n+=m,En.decode.bytes=n-i,c};En.decode.bytes=0;En.encodingLength=function(r){if(!r)return 2;return(Y.isBuffer(r)?r.length:Y.byteLength(r))+2};var Qn=YS.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 pr=YS.ptr={},RS=YS.cname=pr,VS=YS.dname=pr;pr.encode=function(r,n,i){if(!n)n=Y.alloc(pr.encodingLength(r));if(!i)i=0;return R.encode(r,n,i+2),n.writeUInt16BE(R.encode.bytes,i),pr.encode.bytes=R.encode.bytes+2,n};pr.encode.bytes=0;pr.decode=function(r,n){if(!n)n=0;let i=R.decode(r,n+2);return pr.decode.bytes=R.decode.bytes+2,i};pr.decode.bytes=0;pr.encodingLength=function(r){return R.encodingLength(r)+2};var Dn=YS.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),R.encode(r.target,n,i+8);let m=R.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=R.decode(r,n+8),Dn.decode.bytes=i+2,m};Dn.decode.bytes=0;Dn.encodingLength=function(r){return 8+R.encodingLength(r.target)};var Zr=YS.caa={};Zr.ISSUER_CRITICAL=128;Zr.encode=function(r,n,i){let m=Zr.encodingLength(r);if(!n)n=Y.alloc(Zr.encodingLength(r));if(!i)i=0;if(r.issuerCritical)r.flags=Zr.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),Zr.encode.bytes=m,n};Zr.encode.bytes=0;Zr.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&Zr.ISSUER_CRITICAL),Zr.decode.bytes=i+2,c};Zr.decode.bytes=0;Zr.encodingLength=function(r){return O.encodingLength(r.tag)+O.encodingLength(r.value)+2};var Ln=YS.mx={};Ln.encode=function(r,n,i){if(!n)n=Y.alloc(Ln.encodingLength(r));if(!i)i=0;let m=i;return i+=2,n.writeUInt16BE(r.preference||0,i),i+=2,R.encode(r.exchange,n,i),i+=R.encode.bytes,n.writeUInt16BE(i-m-2,m),Ln.encode.bytes=i-m,n};Ln.encode.bytes=0;Ln.decode=function(r,n){if(!n)n=0;let i=n,m={};return n+=2,m.preference=r.readUInt16BE(n),n+=2,m.exchange=R.decode(r,n),n+=R.decode.bytes,Ln.decode.bytes=n-i,m};Ln.encodingLength=function(r){return 4+R.encodingLength(r.exchange)};var Un=YS.a={};Un.encode=function(r,n,i){if(!n)n=Y.alloc(Un.encodingLength(r));if(!i)i=0;return n.writeUInt16BE(4,i),i+=2,ri.v4.encode(r,n,i),Un.encode.bytes=6,n};Un.encode.bytes=0;Un.decode=function(r,n){if(!n)n=0;n+=2;let i=ri.v4.decode(r,n);return Un.decode.bytes=6,i};Un.decode.bytes=0;Un.encodingLength=function(){return 6};var Pn=YS.aaaa={};Pn.encode=function(r,n,i){if(!n)n=Y.alloc(Pn.encodingLength(r));if(!i)i=0;return n.writeUInt16BE(16,i),i+=2,ri.v6.encode(r,n,i),Pn.encode.bytes=18,n};Pn.encode.bytes=0;Pn.decode=function(r,n){if(!n)n=0;n+=2;let i=ri.v6.decode(r,n);return Pn.decode.bytes=18,i};Pn.decode.bytes=0;Pn.encodingLength=function(){return 18};var Kr=YS.option={};Kr.encode=function(r,n,i){if(!n)n=Y.alloc(Kr.encodingLength(r));if(!i)i=0;let m=i,c=gc.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||ri.familyOf(r.ip),j=ri.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=gc.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=ri.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(gc.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=YS.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 Ur=YS.dnskey={};Ur.PROTOCOL_DNSSEC=3;Ur.ZONE_KEY=128;Ur.SECURE_ENTRYPOINT=32768;Ur.encode=function(r,n,i){if(!n)n=Y.alloc(Ur.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(Ur.PROTOCOL_DNSSEC,i),i+=1,n.writeUInt8(r.algorithm,i),i+=1,c.copy(n,i,0,c.length),i+=c.length,Ur.encode.bytes=i-m,n.writeUInt16BE(Ur.encode.bytes-2,m),n};Ur.encode.bytes=0;Ur.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)!==Ur.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,Ur.decode.bytes=n-i,m};Ur.decode.bytes=0;Ur.encodingLength=function(r){return 6+Y.byteLength(r.key)};var sr=YS.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,R.encode(r.signersName,n,i),i+=R.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=R.decode(r,n),n+=R.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+R.encodingLength(r.signersName)+Y.byteLength(r.signature)};var fr=YS.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,R.encode(r.mbox||".",n,i,{mail:!0}),i+=R.encode.bytes,R.encode(r.txt||".",n,i),i+=R.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=R.decode(r,n,{mail:!0})||".",n+=R.decode.bytes,m.txt=R.decode(r,n)||".",n+=R.decode.bytes,fr.decode.bytes=n-i,m};fr.decode.bytes=0;fr.encodingLength=function(r){return 2+R.encodingLength(r.mbox||".")+R.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=YS.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,R.encode(r.nextDomain,n,i),i+=R.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=R.decode(r,n),n+=R.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+R.encodingLength(r.nextDomain)+jr.encodingLength(r.rrtypes)};var nn=YS.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=YS.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=YS.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=YS.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,R.encode(r.replacement,n,i),i+=R.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=R.decode(r,n),n+=R.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)+R.encodingLength(r.replacement)+6};var ln=YS.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 Fc=YS.record=function(r){switch(r.toUpperCase()){case"A":return Un;case"PTR":return pr;case"CNAME":return RS;case"DNAME":return VS;case"TXT":return Nn;case"NULL":return En;case"AAAA":return Pn;case"SRV":return Dn;case"HINFO":return Qn;case"CAA":return Zr;case"NS":return $n;case"SOA":return Gn;case"MX":return Ln;case"OPT":return Or;case"DNSKEY":return Ur;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},vr=YS.answer={};vr.encode=function(r,n,i){if(!n)n=Y.alloc(vr.encodingLength(r));if(!i)i=0;let m=i;if(R.encode(r.name,n,i),i+=R.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=Fc(r.type);l.encode(r.data,n,i),i+=l.encode.bytes}return vr.encode.bytes=i-m,n};vr.encode.bytes=0;vr.decode=function(r,n){if(!n)n=0;let i={},m=n;if(i.name=R.decode(r,n),n+=R.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=Fc(i.type);i.data=l.decode(r,n+8),n+=8+l.decode.bytes}return vr.decode.bytes=n-m,i};vr.decode.bytes=0;vr.encodingLength=function(r){let n=r.data!==null&&r.data!==void 0?r.data:r.options;return R.encodingLength(r.name)+8+Fc(r.type).encodingLength(n)};var ar=YS.question={};ar.encode=function(r,n,i){if(!n)n=Y.alloc(ar.encodingLength(r));if(!i)i=0;let m=i;return R.encode(r.name,n,i),i+=R.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,ar.encode.bytes=i-m,r};ar.encode.bytes=0;ar.decode=function(r,n){if(!n)n=0;let i=n,m={};if(m.name=R.decode(r,n),n+=R.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 ar.decode.bytes=n-i,m};ar.decode.bytes=0;ar.encodingLength=function(r){return R.encodingLength(r.name)+4};YS.AUTHORITATIVE_ANSWER=1024;YS.TRUNCATED_RESPONSE=512;YS.RECURSION_DESIRED=256;YS.RECURSION_AVAILABLE=128;YS.AUTHENTIC_DATA=32;YS.CHECKING_DISABLED=16;YS.DNSSEC_OK=32768;YS.encode=function(r,n,i){let m=!n;if(m)n=Y.alloc(YS.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,ar,n,i),i=pi(r.answers,vr,n,i),i=pi(r.authorities,vr,n,i),i=pi(r.additionals,vr,n,i),YS.encode.bytes=i-c,m&&YS.encode.bytes!==n.length)return n.slice(0,YS.encode.bytes);return n};YS.encode.bytes=0;YS.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,ar,r,n),n=um(m.answers,vr,r,n),n=um(m.authorities,vr,r,n),n=um(m.additionals,vr,r,n),YS.decode.bytes=n-i,m};YS.decode.bytes=0;YS.encodingLength=function(r){return ur.encodingLength(r)+Gi(r.questions||[],ar)+Gi(r.answers||[],vr)+Gi(r.authorities||[],vr)+Gi(r.additionals||[],vr)};YS.streamEncode=function(r){let n=YS.encode(r),i=Y.alloc(2);i.writeUInt16BE(n.byteLength);let m=Y.concat([i,n]);return YS.streamEncode.bytes=m.byteLength,m};YS.streamEncode.bytes=0;YS.streamDecode=function(r){let n=r.readUInt16BE(0);if(r.byteLength<n+2)return null;let i=YS.decode(r.slice(2));return YS.streamDecode.bytes=YS.decode.bytes,i};YS.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=nr((nD,jj)=>{var yj=BS;process.nextTick(hS,42);jj.exports=zS;function zS(r){var n=m;return i;function i(c){n(c||MS)}function m(c){var l=[c];n=y,r(j);function y(A){l.push(A)}function j(A){var S=arguments;n=oS(A)?m:v;while(l.length)v(l.shift());function v(w){yj(TS,w,S)}}}}function oS(r){return Object.prototype.toString.call(r)==="[object Error]"}function MS(){}function TS(r,n){r.apply(null,n)}function hS(r){if(r===42)yj=process.nextTick}function BS(r,n,i){process.nextTick(function(){r(n,i)})}});var vj=nr((iD,Sj)=>{var zc=lj(),xS=sn("dgram"),kS=Ij(),pS=sn("events"),Mc=sn("os"),oc=function(){};Sj.exports=function(r){if(!r)r={};var n=new pS.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||xS.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,N){try{w=zc.decode(w)}catch(E){n.emit("warning",E);return}if(n.emit("packet",w,N),w.type==="query")n.emit("query",w,N);if(w.type==="response")n.emit("response",w,N)}),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=kS(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,N,E){if(typeof N==="function")return n.send(w,null,N);if(!E)E=oc;if(!N)N=l;else if(!N.host&&!N.address)N.address=l.address;v(Q);function Q(W){if(j)return E();if(W)return E(W);var H=zc.encode(w);S.send(H,0,H.length,N.port,N.address||N.host,E)}},n.response=n.respond=function(w,N,E){if(Array.isArray(w))w={answers:w};w.type="response",w.flags=(w.flags||0)|zc.AUTHORITATIVE_ANSWER,n.send(w,N,E)},n.query=function(w,N,E,Q){if(typeof N==="function")return n.query(w,null,null,N);if(typeof N==="object"&&N&&N.port)return n.query(w,null,N,E);if(typeof E==="function")return n.query(w,N,null,E);if(!Q)Q=oc;if(typeof w==="string")w=[{name:w,type:N||"ANY"}];if(Array.isArray(w))w={type:"query",questions:w};w.type="query",n.send(w,E,Q)},n.destroy=function(w){if(!w)w=oc;if(j)return process.nextTick(w);j=!0,clearInterval(A);for(var N in y)try{S.dropMembership(c,N)}catch(E){}y={},S.close(w)},n.update=function(){var w=r.interface?[].concat(r.interface):uS(),N=!1;for(var E=0;E<w.length;E++){var Q=w[E];if(y[Q])continue;try{S.addMembership(c,Q),y[Q]=!0,N=!0}catch(W){n.emit("warning",W)}}if(N){if(S.setMulticastInterface)try{S.setMulticastInterface(r.interface||aS())}catch(W){n.emit("warning",W)}n.emit("networkInterface")}},n};function aS(){var r=Mc.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(Mc.platform()==="darwin"&&n[i]==="en0")return l.address;return"0.0.0.0"}}}return"127.0.0.1"}function uS(){var r=Mc.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=nr((mD,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=nr((ni)=>{var Tc=ni&&ni.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ni,"__esModule",{value:!0});ni.Server=void 0;var dS=Tc(vj()),tS=Tc($j()),bS=Tc(pm());class hc{constructor(r,n){this.registry={},this.mdns=(0,dS.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,bS.default)(m,r)})}isDuplicateRecord(r){return(n)=>{return r.type===n.type&&r.name===n.name&&(0,tS.default)(r.data,n.data)}}unique(){var r=[];return(n)=>{if(~r.indexOf(n))return!1;return r.push(n),!0}}}ni.Server=hc;ni.default=hc});var Ej=nr((Nj)=>{Object.defineProperty(Nj,"__esModule",{value:!0});Nj.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=nr((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 Pj=nr((Uj)=>{Object.defineProperty(Uj,"__esModule",{value:!0});Uj.default=fS;function fS(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=nr((ii)=>{var ui=ii&&ii.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ii,"__esModule",{value:!0});ii.Browser=void 0;var nv=ui(Rc()),qn=ui(pm()),iv=sn("events"),Bc=Vc(),Cj=ui(Ej()),mv=ui(Dj()),cv=ui(Pj()),Wj=".local",lv="_services._dns-sd._udp"+Wj;class tm extends iv.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 nv.default(n!==null&&n.txt!=null?n.txt:void 0),n===null||n.type===void 0)this.name=lv,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,mv.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,cv.default)(r.txt,((n=this._services.find((i)=>(0,qn.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,qn.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,qn.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,qn.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,qn.default)(l.name,r)).map((l)=>{let y={addresses:[],subtypes:[]};if(c.filter((j)=>{return j.type==="PTR"&&(0,qn.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,qn.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,qn.default)(j.name,y.host)).forEach((j)=>y.addresses.push(j.data)),y}).filter((l)=>!!l)}}ii.Browser=tm;ii.default=tm});var Kj=nr((dr)=>{var bm=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 yv=bm(by()),jv=bm(Gj()),xc=bm(Xj());dr.Browser=xc.default;var Iv=bm(Zc());dr.Service=Iv.default;class kc{constructor(r={},n){this.server=new jv.default(r,n),this.registry=new yv.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 bl={};Nr(bl,{url:()=>vA,openapi:()=>p$,listen:()=>a$,Server:()=>bl,Default:()=>x$});var cc=(r)=>{let n=r.split("/");if(n[0]==="")n.shift();return n},el=(r)=>{let{groups:n,path:i}=wA(r),m=cc(i);return $A(m,n)},wA=(r)=>{let n=[];return r=r.replace(/\{[^}]+\}/g,(i,m)=>{let c=`@${m}`;return n.push([c,i]),c}),{groups:n,path:r}},$A=(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},gm={},sl=(r,n)=>{if(r==="*")return"*";let i=r.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(i){let m=`${r}#${n}`;if(!gm[m])if(i[2])gm[m]=n&&n[0]!==":"&&n[0]!=="*"?[m,i[1],new RegExp(`^${i[2]}(?=/${n})`)]:[r,i[1],new RegExp(`^${i[2]}$`)];else gm[m]=[r,i[1],!0];return gm[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},On=(r,n,...i)=>{if(i.length)n=On(n,...i);return`${r?.[0]==="/"?"":"/"}${r}${n==="/"?"":`${r?.at(-1)==="/"?"":"/"}${n?.[0]==="/"?n.slice(1):n}`}`},Fm=(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,oi):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)},oi=decodeURIComponent;var GA=/^[\w!#$%&'*.^`|~+-]+$/,NA=/^[ !#-:<-[\]-~]*$/,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||!GA.test(y)||y in m)continue;let j=cy(c.substring(l+1));if(j.startsWith('"')&&j.endsWith('"'))j=j.slice(1,-1);if(NA.test(j)){if(m[y]=j.indexOf("%")!==-1?vi(j,oi):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 EA(r,{name:"SHA-256",alias:"sha256"})};var EA=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 QA=/^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i,DA=/^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i,UA=/^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||!QA.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||!(DA.test(l)||UA.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 PA(r,n,i){if(!(i in Iy))return r;let m=Iy[i]||[];if(n==="arktype")return CA(r,m);if(n==="valibot")return WA(r,m);return r}function CA(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 WA(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=PA(l.issues,n["~standard"].vendor,r);return c.json({data:m,error:y,success:!1},400)}return l.value});var vc=Symbol("openapi"),KA=["GET","PUT","POST","DELETE","OPTIONS","HEAD","PATCH","TRACE"],HA=(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),RA=(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},VA=(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(VA(m),m),i},new Map);return Array.from(n.values())}var wi=new Map;function YA(r){let n=[];for(let[i,m]of wi)if(m&&r.match(i))n.push(m);return n}function ZA(){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:RA(r)})}function $y({route:r,specs:n,paths:i}){let m=HA(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=YA(m);if(!(m in i))i[m]={};if(i[m])i[m][c]=wy(r,...l,i[m]?.[c],n)}}function JA(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("{"),N=(y.split("/").pop()||"").includes(".");if(!v&&N)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 N=y.split("/").filter((E)=>E.startsWith("{")&&!w.parameters.find((Q)=>Q.in==="path"&&Q.name===E.slice(1,E.length-1)));for(let E of N){let Q=E.slice(1,E.length-1);if(w.parameters.findIndex((H)=>{if("$ref"in H){let X=H.$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 H.in==="path"&&H.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??{};ZA();let l=await OA(r,m);for(let j in l)for(let A in l[j])if(LA({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:{...JA(l,m),...c.paths},components:y}}async function OA(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(!KA.includes(l))continue}let y=n.options.defaultOptions?.[l],{schema:j,components:A={}}=await qA(c,y);n.components=$c(n.components,A),$y({route:m,specs:j,paths:i})}return i}function LA(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 qA(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=Ny(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=Ny(r.target,i.schema);m.parameters=c}return{schema:m,components:i.components}}function Ny(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)=>Ey(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 Nc=(r)=>("headers"in r),Uy=async(r,n=Object.create(null))=>{let{all:i=!1,dot:m=!1}=n,y=(Nc(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 _A(r,{all:i,dot:m});return{}};async function _A(r,n){let i=Nc(r)?r.headers:r.raw.headers,m=await r.arrayBuffer(),c=zm(m,i.get("Content-Type")||"");if(!Nc(r))r.bodyCache.formData=c;let l=await c;if(l)return gA(l,n);return{}}function gA(r,n){let i=Object.create(null);if(r.forEach((m,c)=>{if(!(n.all||c.endsWith("[]")))i[c]=m;else FA(i,c,m)}),n.dot)Object.entries(i).forEach(([m,c])=>{if(m.includes("."))zA(i,m,c),delete i[m]});return i}var FA=(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]},zA=(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 Py=(r)=>vi(r,oi),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)?Py(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)?Py(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 Uy(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 om={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",Ec=(r,n)=>{return{"Content-Type":r,...n}},Ti=(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||=Ti(null,{headers:this.#j??=new Headers})}set res(r){if(this.#m&&r){r=Ti(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=Ti(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 Ti(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,Ec(Xy,i))};json=(r,n,i)=>{return this.#y(JSON.stringify(r),n,Ec("application/json",i))};html=(r,n,i)=>{let m=(c)=>this.#y(c,n,Ec("text/html; charset=UTF-8",i));return typeof r==="object"?Mi(r,om.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??=()=>Ti(),this.#A(this)}};var B="ALL",Ky="all",Hy=["get","post","put","delete","options","patch"],Mm="Can not add a route since the matcher is already built.",Tm=class extends Error{};var Dc="__COMPOSED_HANDLER";var oA=(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)},Vy=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=oA;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=On(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=On(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,On(n,"*"),j),this}#l(n,i,m,c){n=n.toUpperCase(),i=On(this._basePath,i);let l={basePath:c!==void 0?On(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${On("/",n)}`,i),m,c)};fire=()=>{addEventListener("fetch",(n)=>{n.respondWith(this.#m(n.request,n,void 0,n.request.method))})}};var hi=[];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[[],hi];let S=A.indexOf("",1);return[y[1][S],A]};return this.match=m,m(r,n)}var Bm="[^/]+",Bi=".*",xi="(?:|/.*)",bn=Symbol(),MA=new Set(".\\+*[^]$()");function TA(r,n){if(r.length===1)return n.length===1?r<n?-1:1:-1;if(n.length===1)return 1;if(r===Bi||r===xi)return 1;else if(n===Bi||n===xi)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 bn;if(l)return;this.#r=i;return}let[y,...j]=n,A=y==="*"?j.length===0?["","",Bi]:["","",Bm]:y==="/*"?["","",xi]:y.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),S;if(A){let v=A[1],w=A[2]||Bm;if(v&&A[2]){if(w===".*")throw bn;if(w=w.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(w))throw bn}if(S=this.#i[w],!S){if(Object.keys(this.#i).some((N)=>N!==Bi&&N!==xi))throw bn;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!==Bi&&v!==xi))throw bn;if(l)return;S=this.#i[y]=new r}S.insert(j,i,m,c,l)}buildRegExpStr(){let i=Object.keys(this.#i).sort(TA).map((m)=>{let c=this.#i[m];return(typeof c.#n==="number"?`(${m})@${c.#n}`:MA.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 Zy=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 hA=[/^$/,[],Object.create(null)],Jy=Object.create(null);function Oy(r){return Jy[r]??=new RegExp(r==="*"?"":`^${r.replace(/\/\*$|([.\\+*[^\]$()])/g,(n,i)=>i?`\\${i}`:"(?:|/.*)")}$`)}function BA(){Jy=Object.create(null)}function xA(r){let n=new Zy,i=[];if(r.length===0)return hA;let m=r.map((S)=>[!/\*|\/:/.test(S[0]),...S]).sort(([S,v],[w,N])=>S?1:w?-1:v.length-N.length),c=Object.create(null);for(let S=0,v=-1,w=m.length;S<w;S++){let[N,E,Q]=m[S];if(N)c[E]=[Q.map(([H])=>[H,Object.create(null)]),hi];else v++;let W;try{W=n.insert(E,v,N)}catch(H){throw H===bn?new Tm(E):H}if(N)continue;i[v]=Q.map(([H,X])=>{let K=Object.create(null);X-=1;for(;X>=0;X--){let[J,q]=W[X];K[J]=q}return[H,K]})}let[l,y,j]=n.buildRegExp();for(let S=0,v=i.length;S<v;S++)for(let w=0,N=i[S].length;w<N;w++){let E=i[S][w]?.[1];if(!E)continue;let Q=Object.keys(E);for(let W=0,H=Q.length;W<H;W++)E[Q[W]]=j[E[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(Mm);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=Fm(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,BA(),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 xA(n)}};var kA=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(),hi];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 Uc=class{name="SmartRouter";#r=[];#n=[];constructor(r){this.#r=r.routers}add(r,n,i){if(!this.#n)throw Error(Mm);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 Tm)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 ki=Object.create(null),pA=(r)=>{for(let n in r)return!0;return!1},Ly=class r{#r;#n;#i;#l=0;#c=ki;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=el(i),y=[];for(let j=0,A=l.length;j<A;j++){let S=l[j],v=l[j+1],w=sl(S,v),N=Array.isArray(w)?w[0]:S;if(N in c.#n){if(c=c.#n[N],w)y.push(w[1]);continue}if(c.#n[N]=new r,w)c.#i.push(w),y.push(w[1]);c=c.#n[N]}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!==ki||l&&l!==ki)for(let w=0,N=S.possibleKeys.length;w<N;w++){let E=S.possibleKeys[w],Q=v[S.score];S.params[E]=l?.[E]&&!Q?l[E]:c[E]??l?.[E],v[S.score]=!0}}}}search(n,i){let m=[];this.#c=ki;let l=[this],y=cc(i),j=[],A=y.length,S=null;for(let v=0;v<A;v++){let w=y[v],N=v===A-1,E=[];for(let W=0,H=l.length;W<H;W++){let X=l[W],K=X.#n[w];if(K)if(K.#c=X.#c,N){if(K.#n["*"])this.#m(m,K.#n["*"],n,X.#c);this.#m(m,K,n,X.#c)}else E.push(K);for(let J=0,q=X.#i.length;J<q;J++){let z=X.#i[J],L=X.#c===ki?{}:{...X.#c};if(z==="*"){let hr=X.#n["*"];if(hr)this.#m(m,hr,n,X.#c),hr.#c=L,E.push(hr);continue}let[rr,Tr,Yr]=z;if(!w&&!(Yr instanceof RegExp))continue;let k=X.#n[rr];if(Yr instanceof RegExp){if(S===null){S=Array(A);let Si=i[0]==="/"?1:0;for(let zi=0;zi<A;zi++)S[zi]=Si,Si+=y[zi].length+1}let hr=i.substring(S[v]),Jn=Yr.exec(hr);if(Jn){if(L[Tr]=Jn[0],this.#m(m,k,n,X.#c,L),Jn[0].length===hr.length&&k.#n["*"])this.#m(m,k.#n["*"],n,X.#c,L);if(pA(k.#n)){k.#c=L;let Si=Jn[0].match(/\//)?.length??0;(j[Si]||=[]).push(k)}continue}}if(Yr===!0||Yr.test(w))if(L[Tr]=w,N){if(this.#m(m,k,n,L,X.#c),k.#n["*"])this.#m(m,k.#n["*"],n,L,X.#c)}else k.#c=L,E.push(k)}}let Q=j.shift();l=Q?E.concat(Q):E}if(m.length>1)m.sort((v,w)=>{return v.score-w.score});return[m.map(({handler:v,params:w})=>[v,w])]}};var Pc=class{name="TrieRouter";#r;constructor(){this.#r=new Ly}add(r,n,i){let m=Fm(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 V=class extends Vy{constructor(r={}){super(r);this.router=r.router??new Uc({routers:[new xm,new Pc]})}};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 aA={br:".br",zstd:".zst",gzip:".gz"},aN=Object.keys(aA);var Wc="x-hono-disable-ssg",vE=(()=>{try{return new Response("SSG is disabled",{status:404,headers:{[Wc]:"true"}})}catch{return null}})();var{write:uE}=Bun;var qy=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)}},_y=(r)=>{return new MessageEvent("message",{data:r})},gy=(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 qy({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)}})},Fy=gy((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(_y(m),Xc(r))}}},Kc=()=>({upgradeWebSocket:Fy,websocket:zy});var oy={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 Ei={};Nr(Ei,{unpublish:()=>Rj,publish:()=>Sv,MDNS:()=>Ei});var Hj=Av(Kj(),1),di=_.create({service:"mdns"}),yn,em;function Sv(r,n){if(em===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",()=>{di.info("mDNS service published",{name:m,port:r})}),c.on("error",(l)=>{di.error("mDNS service error",{error:l})}),em=r}catch(i){if(di.error("mDNS publish failed",{error:i}),yn)try{yn.destroy()}catch{}yn=void 0,em=void 0}}function Rj(){if(yn){try{yn.unpublishAll(),yn.destroy()}catch(r){di.error("mDNS unpublish failed",{error:r})}yn=void 0,em=void 0,di.info("mDNS service unpublished")}}var Vj=(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 vv=/^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/,wv=/^([^:]*):(.*)$/,$v=new TextDecoder,Yj=(r)=>{let n=vv.exec(r.headers.get("Authorization")||"");if(!n)return;let i=void 0;try{i=wv.exec($v.decode(Vj(n[1])))}catch{}if(!i)return;return{username:i[1],password:i[2]}};var Zj=(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 N of n){let[E,Q]=await Promise.all([Ic(N.username,j.username,r.hashFunction),Ic(N.password,j.password,r.hashFunction)]);if(E&&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 Lj=(r)=>r===32||r===9||r===10||r===13,sm=(r,n)=>{while(n<r.length){if(!Lj(r.charCodeAt(n)))break;n++}return n},ti=(r,n)=>{while(n>0){if(!Lj(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]},Gv=(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},Nv=(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,ti(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,ti(r,i)),A===59)l=!0;i++;break}i++}return[i,m,c??r.slice(j,ti(r,i)),l]},Ev=(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,ti(r,m)),m++,j===44)return[m,i.type?i:void 0];if(!i.type)return[Gv(r,m),void 0];break}m++}if(!i.type)return i.type=r.slice(n,ti(r,r.length)),[r.length,i.type?i:void 0];let c,l,y;while(m<r.length){if([m,c,l,y]=Nv(r,m),c&&l)i.params[c]=l;if(!y)break}return[m,i]},qj=(r)=>{if(!r)return[];let n=[],i=0,m,c=!1,l;while(i<r.length)if([i,m]=Ev(r,i),m){if(m.q=Qv(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},Qv=(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 Dv=["gzip","deflate"],Uv=/(?:^|,)\s*?no-transform\s*?(?:,|$)/i,Pv=(r,n)=>{if(r===void 0)return;let i=qj(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},_j=(r)=>{let n=r?.threshold??1024,i=r?.encoding?[r.encoding]:Dv,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)||!Cv(y.res))return;let S=y.req.header("Accept-Encoding"),v=Pv(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 N=y.res.headers.get("ETag");if(N&&!N.startsWith("W/"))y.res.headers.set("ETag",`W/${N}`)}},Cv=(r)=>{let n=r.headers.get("Cache-Control");return!n||!Uv.test(n)};import{randomUUID as Wv}from"crypto";var fm="ticket",gj="x-qitqode-ticket",Fj="1",Xv=/^\/pty\/[^/]+\/connect$/,Kv=60000,bi=new Map;function Hv(){let r=Date.now();for(let[n,i]of bi)if(i.expiresAt<=r)bi.delete(n)}function zj(r){return Xv.test(r)}function oj(r,n=Kv){Hv();let i=Wv();return bi.set(i,{ptyID:r,expiresAt:Date.now()+n}),{ticket:i,expires_in:Math.round(n/1000)}}function Mj(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 n0=_.create({service:"server"}),hj=(r,n)=>{let i=Tj(r),m=i.errorID;n0.error("failed",{error_id:m,error:r});let c=()=>n.json(new r0.Unknown({message:"Internal server error",diagnostic:i}).toObject(),{status:500,headers:{"x-qitqode-error-id":m}});if(r instanceof r0){let l;if(r instanceof Wn)l=404;else if(r instanceof ir.ModelNotFoundError)l=400;else if(r.name==="ProviderAuthValidationFailed")l=400;else if(r.name.startsWith("Worktree"))l=400;else l=500;if(l===500)return c();return n.json(r.toObject(),{status:l,headers:{"x-qitqode-error-id":m}})}if(r instanceof Z.BusyError)return n.json(new r0.Unknown({message:r.message,diagnostic:i}).toObject(),{status:409,headers:{"x-qitqode-error-id":m}});if(r instanceof kr)return r.getResponse();return c()},Bj=(r,n)=>{if(r.req.method==="OPTIONS")return n();let i=p.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=p.QITQODE_SERVER_USERNAME??"qitqode";return Zj({username:c,password:i})(r,n)},xj=async(r,n)=>{let i=r.req.path==="/log";if(!i)n0.info("request",{method:r.req.method,path:r.req.path});let m=n0.time("request",{method:r.req.method,path:r.req.path});if(await n(),!i)m.stop()};function kj(r){return Jj({maxAge:86400,origin(n){if(!n)return;if(r?.cors?.includes(n))return n}})}function Rv(r){return r==="localhost"||r==="::1"||/^127(\.\d{1,3}){3}$/.test(r)||r==="127.0.0.1"}function Vv(r){if(r.startsWith("[")){let n=r.indexOf("]");return n===-1?r:r.slice(1,n)}return r.split(":")[0]}function pj(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=Vv(l);if(Rv(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 n0.warn("rejected request with unexpected Host header",{host:y}),new kr(403,{message:`Forbidden: unexpected Host header "${y}"`})}}var Yv=_j(),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 Yv(r,n)};var a={};Nr(a,{waitForSync:()=>hv,status:()=>Mv,startWorkspaceSyncing:()=>ac,sessionRestore:()=>gv,remove:()=>zv,list:()=>Fv,isSyncing:()=>Tv,get:()=>i2,create:()=>qv,Workspace:()=>a,Info:()=>i0,Event:()=>si,ConnectionStatus:()=>n2});var uj=["forgewise"];var Zv=new TextEncoder;function Jv(r){return Zv.encode(r).byteLength}function dj(r,n=16384){let i=[...uj.filter((l)=>(l in r)),...Object.keys(r).filter((l)=>!uj.includes(l))],m={},c=0;for(let l of i){let y={...m,[l]:r[l]},j=JSON.stringify(y);if(Jv(j)>n)continue;m[l]=r[l],c+=1}if(c===0)return;return JSON.stringify(m)}var Hr=tj("workspace",{id:_n().$type().primaryKey(),type:_n().notNull(),name:_n().notNull().default(""),branch:_n(),directory:_n(),extra:_n({mode:"json"}),project_id:_n().$type().notNull().references(()=>bj.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 N=[],E=(W)=>{let H=W.slice(W.indexOf(":")+1);return H.startsWith(" ")?H.slice(1):H};if(w.split(`
7
+ `).forEach((W)=>{if(W.startsWith("data:")){N.push(E(W));return}if(W.startsWith("id:")){y=E(W);return}if(W.startsWith("retry:")){let H=Number.parseInt(E(W),10);if(!Number.isNaN(H))j=H}}),!N.length)return;let Q=N.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 pc(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),Lr.off("event",c),r.signal?.removeEventListener("abort",m)},y=setTimeout(()=>{l(),i(Error("Timed out waiting for global event"))},r.timeout);if(Lr.on("event",c),r.signal?.addEventListener("abort",m,{once:!0}),r.signal?.aborted)m()})}var i0=r2.meta({ref:"Workspace"}),n2=I.object({workspaceID:qr.zod,status:I.enum(["connected","connecting","disconnected","error"])}),Ov=I.object({workspaceID:qr.zod,sessionID:br.zod,total:I.number().int().min(0),step:I.number().int().min(0)}),si={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",Ov),Status:jn.define("workspace.status",n2)};function j0(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 Lv=I.object({id:qr.zod.optional(),type:i0.shape.type,branch:i0.shape.branch,projectID:y0.zod,extra:i0.shape.extra}),qv=nm(Lv,async(r)=>{let n=qr.ascending(r.id),i=await Fn(r.projectID,r.type),m=await i.configure({...r,id:n,name:fj.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};b.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=dj(await e.runPromise(rm.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=pc({timeout:m2,fn(A){if(A.workspace===c.id&&A.payload.type===si.Status.type){let{status:S}=A.payload.properties;return S==="error"||S==="connected"}return!1}});return await c2(c),await j,c}),_v=I.object({workspaceID:qr.zod,sessionID:br.zod}),gv=nm(_v,async(r)=>{Ir.info("session restore requested",{workspaceID:r.workspaceID,sessionID:r.sessionID});try{let n=await i2(r.workspaceID);if(!n)throw Error(`Workspace not found: ${r.workspaceID}`);let m=await(await Fn(n.projectID,n.type)).target(n);yr.run(Z.Event.Updated,{sessionID:r.sessionID,info:{workspaceID:r.workspaceID}});let c=b.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(l0(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(ei(m.url,"/sync/replay")):m.directory,events:l.length,batches:A,first:l[0]?.seq,last:l.at(-1)?.seq}),Lr.emit("event",{directory:"global",workspace:r.workspaceID,payload:{type:si.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(ei(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=ei(m.url,"/sync/replay"),N=new Headers(m.headers);N.set("content-type","application/json");let E=await fetch(w,{method:"POST",headers:N,body:JSON.stringify({directory:n.directory??"",events:v})});if(!E.ok){let Q=await E.text();throw Ir.error("session restore batch failed",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,status:E.status,body:Q}),Error(`Failed to replay session ${r.sessionID} into workspace ${r.workspaceID}: HTTP ${E.status} ${Q}`)}Ir.info("session restore batch posted",{workspaceID:r.workspaceID,sessionID:r.sessionID,step:S+1,total:A,status:E.status})}Lr.emit("event",{directory:"global",workspace:r.workspaceID,payload:{type:si.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:c0(n)}),n}});function Fv(r){return b.use((m)=>m.select().from(Hr).where(d(Hr.project_id,r.id)).all()).map(j0).sort((m,c)=>m.id.localeCompare(c.id))}var i2=nm(qr.zod,async(r)=>{let n=b.use((i)=>i.select().from(Hr).where(d(Hr.id,r)).get());if(!n)return;return j0(n)}),zv=nm(qr.zod,async(r)=>{let n=b.use((m)=>m.select({id:mr.id}).from(mr).where(d(mr.workspace_id,r)).all());for(let m of n)await e.runPromise(Z.Service.use((c)=>c.remove(m.id)));let i=b.use((m)=>m.select().from(Hr).where(d(Hr.id,r)).get());if(i){pv(r);let m=j0(i);try{await(await Fn(m.projectID,i.type)).remove(m)}catch{Ir.error("adaptor not available when removing workspace",{type:i.type})}return b.use((c)=>c.delete(Hr).where(d(Hr.id,r)).run()),m}}),m0=new Map,Qi=new Map,m2=5000;function ov(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 gn(r,n){if(m0.get(r)?.status===n)return;let m={workspaceID:r,status:n};m0.set(r,m),Lr.emit("event",{directory:"global",workspace:r,payload:{type:si.Status.type,properties:m}})}function Mv(){return[...m0.values()]}function sj(r){let n=Object.keys(r);if(n.length===0)return!0;let i=Object.fromEntries(b.use((m)=>m.select({id:tr.aggregate_id,seq:tr.seq}).from(tr).where(fi(tr.aggregate_id,n)).all()).map((m)=>[m.id,m.seq]));return n.every((m)=>{return(i[m]??-1)>=r[m]})}async function Tv(r){return Qi.has(r)}async function hv(r,n,i){if(sj(n))return;try{await pc({timeout:m2,signal:i,fn(m){if(m.workspace!==r||m.payload.type!=="sync")return!1;return sj(n)}})}catch{if(i?.aborted)throw i.reason??Error("Request aborted");throw Error(`Timed out waiting for sync fence: ${JSON.stringify(n)}`)}}var Ir=_.create({service:"workspace-sync"});function ei(r,n){let i=new URL(r);return i.pathname=`${i.pathname.replace(/\/$/,"")}${n}`,i.search="",i.hash="",i}async function Bv(r,n,i){let m=await fetch(ei(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 xv(r,n,i,m){let c=b.use((S)=>S.select({id:mr.id}).from(mr).where(d(mr.workspace_id,r.id)).all().map((v)=>v.id)),l=c.length?Object.fromEntries(b.use((S)=>S.select().from(tr).where(fi(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(ei(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}),Di.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 kv(r,n){let m=await(await Fn(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}),gn(r.id,"connecting");let l;try{l=await Bv(m.url,m.headers,n),await xv(r,m.url,m.headers,n)}catch(y){await l?.cancel().catch(()=>{return}),l=null,gn(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}),gn(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);Lr.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),gn(r.id,"disconnected");await ov(Math.min(120000,1000*2**c),n),c+=1}}async function c2(r){if(!p.QITQODE_EXPERIMENTAL_WORKSPACES)return;let i=await(await Fn(r.projectID,r.type)).target(r);if(i.type==="local"){Xn.exists(i.directory).then((c)=>{gn(r.id,c?"connected":"error")});return}if(Qi.has(r.id))return!0;gn(r.id,"disconnected");let m=new AbortController;Qi.set(r.id,m),kv(r,m.signal).catch((c)=>{Qi.delete(r.id),gn(r.id,"error"),Ir.warn("workspace listener failed",{workspaceID:r.id,error:c})})}function pv(r){Qi.get(r)?.abort(),Qi.delete(r),m0.delete(r)}function ac(r){let n=b.use((i)=>i.select({workspace:Hr}).from(Hr).innerJoin(mr,d(mr.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=j0(i);c2(m).catch((c)=>{gn(m.id,"error"),Ir.warn("failed to start workspace sync",{workspaceID:m.id,error:c})})}}var y2="x-qitqode-sync",uc=_.create({service:"fence"});function l2(r){let n=b.use((i)=>{if(!r?.length)return i.select().from(tr).all();return i.select().from(tr).where(fi(tr.aggregate_id,r)).all()});return Object.fromEntries(n.map((i)=>[i.aggregate_id,i.seq]))}function av(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 j2(r){let n=r.get(y2);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 I2(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 A2=async(r,n)=>{if(r.req.method==="GET"||r.req.method==="HEAD"||r.req.method==="OPTIONS")return n();let i=l2();await n();let m=av(i,l2());if(Object.keys(m).length>0)uc.info("header",{diff:m}),r.res.headers.set(y2,JSON.stringify(m))};var S2=_.create({service:"session.projector"});function v2(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 dv(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 w2=[yr.project(I0.Created,(r,n)=>{r.insert(mr).values($2(n.info)).run()}),yr.project(I0.Updated,(r,n)=>{let i=n.info;if(!r.update(mr).set(dv(i)).where(d(mr.id,n.sessionID)).returning().get())throw new Wn({message:`Session not found: ${n.sessionID}`})}),yr.project(I0.Deleted,(r,n)=>{r.delete(mr).where(d(mr.id,n.sessionID)).run()}),yr.project(Ar.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(!v2(j))throw j;S2.warn("ignored late message update",{messageID:m,sessionID:c})}}),yr.project(Ar.Event.Removed,(r,n)=>{r.delete(Kn).where(im(d(Kn.id,n.messageID),d(Kn.session_id,n.sessionID))).run()}),yr.project(Ar.Event.PartRemoved,(r,n)=>{r.delete(Hn).where(im(d(Hn.id,n.partID),d(Hn.session_id,n.sessionID))).run()}),yr.project(Ar.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(!v2(y))throw y;S2.warn("ignored late part update",{partID:i,messageID:m,sessionID:c})}})];function dc(){yr.init({projectors:w2,convertEvent:(r,n)=>{if(r==="session.updated"){let i=n.sessionID,m=b.use((c)=>c.select().from(mr).where(d(mr.id,i)).get());if(!m)return n;return{sessionID:i,info:Z.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 tv={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 C(...r){return Object.fromEntries(r.map((n)=>[n,tv[n]]))}function bv(r){let n=r.match(/^(.+)ID$/);if(n)return`${n[1].toLowerCase()}.id`;return`qitqode.${r}`}function ev(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[bv(i)]=m;return n}function x(r,n,i){return e.runPromise(i.pipe(P.withSpan(r,{attributes:ev(n)})))}async function U(r,n,i){return n.json(await x(r,n,P.gen(()=>i(n))))}var sv=I.object({path:I.string(),body:I.any()}),fv=new Ui,rw=new Ui;var nw=new V().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:$(sv)}}}}}),async(r)=>{let n=await fv.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 rw.push(n),r.json(!0)}),G2=g(()=>new V().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())}}},...C(400)}}),D("json",Er.PromptAppend.properties),async(r)=>{return await wr.publish(Er.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(Er.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(Er.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(Er.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(Er.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(Er.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(Er.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())}}},...C(400)}}),D("json",I.object({command:I.string()})),async(r)=>{let n=r.req.valid("json").command;return await wr.publish(Er.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",Er.ToastShow.properties),async(r)=>{return await wr.publish(Er.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())}}},...C(400)}}),D("json",I.union(Object.values(Er).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(Er).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())}}},...C(400,404)}}),D("json",Er.SessionSelect.properties),async(r)=>{let{sessionID:n}=r.req.valid("json");return await x("TuiRoutes.sessionSelect",r,Z.Service.use((i)=>i.get(n))),await wr.publish(Er.SessionSelect,{sessionID:n}),r.json(!0)}).route("/control",nw));var iw=I.object({answers:_r.Answer.zod.array().describe("User answers in order of questions (each answer is an array of selected labels)")}),N2=()=>D("param",I.object({requestID:mm.zod})),E2=g(()=>new V().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:$(_r.Request.zod.array())}}}}}),async(r)=>U("QuestionRoutes.list",r,function*(){return yield*(yield*_r.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)=>U("QuestionRoutes.neverAsk",r,function*(){return yield*(yield*_r.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())}}},...C(400)}}),D("json",I.object({enabled:I.boolean().describe("Whether never-ask is enabled")})),async(r)=>U("QuestionRoutes.setNeverAsk",r,function*(){let n=yield*_r.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())}}},...C(400,404)}}),N2(),D("json",iw),async(r)=>U("QuestionRoutes.reply",r,function*(){let n=r.req.valid("param"),i=r.req.valid("json");return yield*(yield*_r.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())}}},...C(400,404)}}),N2(),async(r)=>U("QuestionRoutes.reject",r,function*(){let n=r.req.valid("param");return yield*(yield*_r.Service).reject(n.requestID),!0})));function A0(r){return P.gen(function*(){return yield*(yield*Qr.Service).reply(r),!0})}var Q2=g(()=>new V().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())}}},...C(400,404)}}),D("param",I.object({requestID:Pi.zod})),D("json",I.object({reply:Qr.Reply.zod,message:I.string().optional()})),async(r)=>U("PermissionRoutes.reply",r,function*(){let n=r.req.valid("param"),i=r.req.valid("json");return yield*A0({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)=>U("PermissionRoutes.list",r,function*(){return yield*(yield*Qr.Service).list()})));var U2=g(()=>new V().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:D2.schema("session")})),async(r)=>U("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)=>U("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 mw=I.object({output:I.string().describe("Captured output from the interactive command"),exitCode:I.number().describe("Exit code of the interactive command")}),P2=g(()=>new V().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)=>U("BashInteractiveRoutes.list",r,function*(){return yield*(yield*bc).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())}}},...C(400,404)}}),D("param",I.object({id:I.string()})),D("json",mw),async(r)=>U("BashInteractiveRoutes.reply",r,function*(){let n=r.req.valid("param"),i=r.req.valid("json");return yield*(yield*bc).reply({id:n.id,output:i.output,exitCode:i.exitCode}),!0})));var Xm={};Nr(Xm,{webHandler:()=>t4,routes:()=>i1,ExperimentalHttpApiServer:()=>Xm});var Mr={};Nr(Mr,{reflect:()=>yl,make:()=>fw,isHttpApi:()=>ew,AdditionalSchemas:()=>V0});var u={};Nr(u,{put:()=>pw,post:()=>kw,patch:()=>aw,options:()=>tw,make:()=>Mn,isHttpApiEndpoint:()=>zw,head:()=>dw,getSuccessSchemas:()=>mi,getPayloadSchemas:()=>ow,getErrorSchemas:()=>ci,get:()=>xw,delete:()=>uw});var Vi={};Nr(Vi,{UnauthorizedNoContent:()=>Hw,Unauthorized:()=>w0,ServiceUnavailableNoContent:()=>gw,ServiceUnavailable:()=>W0,RequestTimeoutNoContent:()=>Jw,RequestTimeout:()=>Q0,NotImplementedNoContent:()=>_w,NotImplemented:()=>C0,NotFoundNoContent:()=>Vw,NotFound:()=>G0,NotAcceptableNoContent:()=>Zw,NotAcceptable:()=>E0,MethodNotAllowedNoContent:()=>Yw,MethodNotAllowed:()=>N0,InternalServerErrorNoContent:()=>qw,InternalServerError:()=>P0,GoneNoContent:()=>Lw,Gone:()=>U0,ForbiddenNoContent:()=>Rw,Forbidden:()=>$0,ConflictNoContent:()=>Ow,Conflict:()=>D0,BadRequestNoContent:()=>Kw,BadRequestFromSchemaError:()=>rl,BadRequest:()=>Rn});function lw(r){return(n)=>{return n.annotate({httpApiStatus:r})}}var yw=(r)=>sc.pipe(lw(r)),H2=yw(204);function Vr(r){return(n)=>{return sc.pipe(Ci(K2(n),v0({decode:r.decode,encode:C2})))}}function jw(r,n){return r.annotate({"~httpApiEncoding":{_tag:n._tag,contentType:n.contentType??Iw(n._tag)}})}function Iw(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 R2(r){return(n)=>jw(n,{_tag:"FormUrlEncoded",...r})}var cm=(r)=>{if(S0(r))return!0;let n=X2(r);if(S0(n))return!0;let i=r.encoding?.[0].to;if(i===void 0)return!1;return S0(i)},V2=ec("~httpApiEncoding"),Y2=ec("httpApiStatus"),Z2={_tag:"Json",contentType:"application/json"},Aw={_tag:"FormUrlEncoded",contentType:"application/x-www-form-urlencoded"};function Sw(r){return V2(r)??Z2}function fc(r,n){let i=V2(r);if(i)return i;return Wi(n)?Z2:Aw}function Xi(r){let n=Sw(r);if(n._tag==="Multipart")throw Error("Multipart is not supported in response");return n}function Ki(r){return Y2(r)??200}function Hi(r){return Y2(r)??500}var ww=Pr({status:400}),$w=Pr({status:401}),Gw=Pr({status:403}),Nw=Pr({status:404}),Ew=Pr({status:405}),Qw=Pr({status:406}),Dw=Pr({status:408}),Uw=Pr({status:409}),Pw=Pr({status:410}),Cw=Pr({status:500}),Ww=Pr({status:501}),Xw=Pr({status:503});class Rn extends Fr("effect/HttpApiError/BadRequest")({_tag:gr("BadRequest")},{description:"BadRequest",httpApiStatus:400}){[In]=!0;[zr](){return t(ww)}static singleton=new Rn}var Kw=Rn.pipe(Vr({decode:()=>new Rn({})})),rl=Rn.pipe(Ci(Ri([X0(K0),Rn]),v0({encode:(r)=>Rn.singleton,decode:zn})),Vr({decode:()=>new Rn({})})).annotate({httpApiStatus:400,description:"BadRequest"});class w0 extends Fr("effect/HttpApiError/Unauthorized")({_tag:gr("Unauthorized")},{description:"Unauthorized",httpApiStatus:401}){[In]=!0;[zr](){return t($w)}}var Hw=w0.pipe(Vr({decode:()=>new w0({})}));class $0 extends Fr("effect/HttpApiError/Forbidden")({_tag:gr("Forbidden")},{description:"Forbidden",httpApiStatus:403}){[In]=!0;[zr](){return t(Gw)}}var Rw=$0.pipe(Vr({decode:()=>new $0({})}));class G0 extends Fr("effect/HttpApiError/NotFound")({_tag:gr("NotFound")},{description:"NotFound",httpApiStatus:404}){[In]=!0;[zr](){return t(Nw)}}var Vw=G0.pipe(Vr({decode:()=>new G0({})}));class N0 extends Fr("effect/HttpApiError/MethodNotAllowed")({_tag:gr("MethodNotAllowed")},{description:"MethodNotAllowed",httpApiStatus:405}){[In]=!0;[zr](){return t(Ew)}}var Yw=N0.pipe(Vr({decode:()=>new N0({})}));class E0 extends Fr("effect/HttpApiError/NotAcceptable")({_tag:gr("NotAcceptable")},{description:"NotAcceptable",httpApiStatus:406}){[In]=!0;[zr](){return t(Qw)}}var Zw=E0.pipe(Vr({decode:()=>new E0({})}));class Q0 extends Fr("effect/HttpApiError/RequestTimeout")({_tag:gr("RequestTimeout")},{description:"RequestTimeout",httpApiStatus:408}){[In]=!0;[zr](){return t(Dw)}}var Jw=Q0.pipe(Vr({decode:()=>new Q0({})}));class D0 extends Fr("effect/HttpApiError/Conflict")({_tag:gr("Conflict")},{description:"Conflict",httpApiStatus:409}){[In]=!0;[zr](){return t(Uw)}}var Ow=D0.pipe(Vr({decode:()=>new D0({})}));class U0 extends Fr("effect/HttpApiError/Gone")({_tag:gr("Gone")},{description:"Gone",httpApiStatus:410}){[In]=!0;[zr](){return t(Pw)}}var Lw=U0.pipe(Vr({decode:()=>new U0({})}));class P0 extends Fr("effect/HttpApiError/InternalServerError")({_tag:gr("InternalServerError")},{description:"InternalServerError",httpApiStatus:500}){[zr](){return t(Cw)}}var qw=P0.pipe(Vr({decode:()=>new P0({})}));class C0 extends Fr("effect/HttpApiError/NotImplemented")({_tag:gr("NotImplemented")},{description:"NotImplemented",httpApiStatus:501}){[zr](){return t(Ww)}}var _w=C0.pipe(Vr({decode:()=>new C0({})}));class W0 extends Fr("effect/HttpApiError/ServiceUnavailable")({_tag:gr("ServiceUnavailable")},{description:"ServiceUnavailable",httpApiStatus:503}){[zr](){return t(Xw)}}var gw=W0.pipe(Vr({decode:()=>new W0({})}));var il="~effect/httpapi/HttpApiEndpoint",zw=(r)=>on(r,il);function ow(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 H0(n)?n:[H2]}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 q2(Array.from(n),rl)}var Mw={[il]:il,pipe(){return An(this,arguments)},prefix(r){return ym({...this,path:_2(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:or(this.annotations,r)})}};function ym(r){return Object.assign(Object.create(Mw),r)}var Mn=(r)=>(n,i,m)=>{let c=m?.disableCodecs??!1,l=c?zn:R0;return ym({name:n,path:i,method:r,params:nl(m?.params,l),query:nl(m?.query,l),headers:nl(m?.headers,l),payload:Tw(m?.payload,r,c),success:J2(m?.success,c),error:J2(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 Tw(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(R2())],l=i?zn:Bw;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 J2(r,n){if(r===void 0)return new Set;let i=L2(r);return new Set(n?i:i.map(hw))}function hw(r){switch(Xi(r.ast)._tag){case"Json":return cl(r);case"FormUrlEncoded":return R0(r);case"Text":case"Uint8Array":return r}}function Bw(r,n){switch(fc(r.ast,n)._tag){case"Json":return cl(r);case"FormUrlEncoded":return R0(r);case"Text":case"Uint8Array":case"Multipart":return r}}var xw=Mn("GET"),kw=Mn("POST"),pw=Mn("PUT"),aw=Mn("PATCH"),uw=Mn("DELETE");var dw=Mn("HEAD"),tw=Mn("OPTIONS");var ll="~effect/httpapi/HttpApi",ew=(r)=>on(r,ll),sw={[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=or(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:or(this.annotations,r)})}},li=(r)=>{function n(){}return Object.setPrototypeOf(n,sw),n.groups=r.groups,n.annotations=r.annotations,n},fw=(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=or(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:or(c,y.annotations),successes:g2(mi(y),Ki),errors:g2(ci(y),Hi)})}}},g2=(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 V0 extends $r()("effect/httpapi/HttpApi/AdditionalSchemas"){}var Sr={};Nr(Sr,{securitySetCookie:()=>v4,securityDecode:()=>FI,layer:()=>I4,group:()=>A4,endpoint:()=>S4,HandlersTypeId:()=>gI});var Yi={};Nr(Yi,{layerSchemaErrorTransform:()=>i4,layerClient:()=>m4,isSecurity:()=>Gm,Service:()=>r4});var F2="~effect/httpapi/HttpApiMiddleware",jl="~effect/httpapi/HttpApiMiddleware/Security",Gm=(r)=>on(r,jl),r4=()=>(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[F2]=F2,y.error=n4(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 n4(r){if(r===void 0)return new Set;return new Set(Array.isArray(r)?r:[r])}var i4=(r,n)=>z2(r,(i,m)=>O0(i,(c)=>K0(c)?n(c,m):wm(c))),m4=(r,n)=>Z0(vm(function*(){let i=(yield*$m()).pipe(Am(Sm)),m=J0(n)?yield*n:n;return Y0(new Map([[`${r.key}/Client`,(c)=>o2(m(c),(l)=>or(i,l))]]))}));var T={};Nr(T,{fromApi:()=>$l,annotations:()=>y4,Version:()=>g0,Transform:()=>Oi,Title:()=>Zi,Summary:()=>Em,Servers:()=>z0,Override:()=>Ji,License:()=>F0,Identifier:()=>_0,Format:()=>o0,ExternalDocs:()=>Nm,Exclude:()=>q0,Description:()=>yi,Deprecated:()=>M0});class _0 extends $r()("effect/httpapi/OpenApi/Identifier"){}class Zi extends $r()("effect/httpapi/OpenApi/Title"){}class g0 extends $r()("effect/httpapi/OpenApi/Version"){}class yi extends $r()("effect/httpapi/OpenApi/Description"){}class F0 extends $r()("effect/httpapi/OpenApi/License"){}class Nm extends $r()("effect/httpapi/OpenApi/ExternalDocs"){}class z0 extends $r()("effect/httpapi/OpenApi/Servers"){}class o0 extends $r()("effect/httpapi/OpenApi/Format"){}class Em extends $r()("effect/httpapi/OpenApi/Summary"){}class M0 extends $r()("effect/httpapi/OpenApi/Deprecated"){}class Ji extends $r()("effect/httpapi/OpenApi/Override"){}var q0=u2("effect/httpapi/OpenApi/Exclude",{defaultValue:x2});class Oi extends $r()("effect/httpapi/OpenApi/Transform"){}var l4=(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}},y4=l4({identifier:_0,title:Zi,version:g0,description:yi,license:F0,summary:Em,deprecated:M0,externalDocs:Nm,servers:z0,format:o0,override:Ji,exclude:q0,transform:Oi}),M2=new WeakMap;function lr(r,n,i){let m=vl(r,n);if(k2(m))i(m.value)}function $l(r,n){let i=M2.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=[];lr(r.annotations,Zi,(y)=>{m.info.title=y}),lr(r.annotations,g0,(y)=>{m.info.version=y}),lr(r.annotations,yi,(y)=>{m.info.description=y}),lr(r.annotations,F0,(y)=>{m.info.license=y}),lr(r.annotations,Em,(y)=>{m.info.summary=y}),lr(r.annotations,z0,(y)=>{m.servers=[...y]}),yl(r,{onGroup({group:y}){if(Il(y.annotations,q0))return;let j={name:L0(y.annotations,Zi,()=>y.identifier)};lr(y.annotations,yi,(A)=>{j.description=A}),lr(y.annotations,Nm,(A)=>{j.externalDocs=A}),lr(y.annotations,Ji,(A)=>{Object.assign(j,A)}),lr(y.annotations,Oi,(A)=>{j=A(j)}),m.tags.push(j)},onEndpoint({endpoint:y,group:j,mergedAnnotations:A,middleware:S}){if(Il(A,q0))return;let v={tags:[L0(j.annotations,Zi,()=>j.identifier)],operationId:L0(y.annotations,_0,()=>j.topLevel?y.name:`${j.identifier}.${y.name}`),parameters:[],security:[],responses:{}},w=y.path.replace(/:(\w+)\??/g,"{$1}"),N=y.method.toLowerCase();function E(K){if(K.size>0){let J={},q=!1;if(K.forEach(({encoding:z,schemas:L},rr)=>{let Tr=L.filter((hr)=>!cm(hr.ast));if(Tr.length===0)return;q=!0;let Yr=Tr.map(Al),k=Yr.length===1?Yr[0]:new Sl(Yr,"anyOf");c.push({_tag:"schema",ast:B2(k,z._tag),path:["paths",w,N,"requestBody","content",rr,"schema"]}),J[rr]={schema:{}}}),q)v.requestBody={content:J,required:!0}}}function Q(K,J){for(let[q,{content:z,descriptions:L}]of K){let rr=L.size>0?Array.from(L).join(" | "):J();if(v.responses[q]={description:rr},z!==void 0)z.forEach((Tr,Yr)=>{Tr.forEach((k,hr)=>{let Jn=Array.from(k,Al),Si=Jn.length===1?Jn[0]:new Sl(Jn,"anyOf");c.push({_tag:"schema",ast:B2(Si,Yr),path:["paths",w,N,"responses",String(q),"content",hr,"schema"]}),v.responses[q].content??={},v.responses[q].content[hr]={schema:{}}})})}}function W(K,J){if(K){let q=e2(K.ast);if(b2(q))for(let z of q.propertySignatures)v.parameters.push({name:String(z.name),in:J,schema:{},required:J==="path"||!s2(z.type)}),c.push({_tag:"parameter",ast:z.type,path:["paths",w,N,"parameters",String(v.parameters.length-1),"schema"]})}}lr(y.annotations,yi,(K)=>{v.description=K}),lr(y.annotations,Em,(K)=>{v.summary=K}),lr(y.annotations,M0,(K)=>{v.deprecated=K}),lr(y.annotations,Nm,(K)=>{v.externalDocs=K}),S.forEach((K)=>{if(!Gm(K))return;for(let[J,q]of Object.entries(K.security))H(J,q),v.security.push({[J]:[]})});function H(K,J){if(m.components.securitySchemes[K]!==void 0)return;m.components.securitySchemes[K]=j4(J)}let X=Wi(y.method);if(X)E(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(T2(mi(y),Ki,h2),()=>"Success"),Q(T2(ci(y),Hi,h2),()=>"Error"),!m.paths[w])m.paths[w]={};lr(y.annotations,Ji,(K)=>{Object.assign(v,K)}),lr(y.annotations,Oi,(K)=>{v=K(v)}),m.paths[w][N]=v}}),lr(r.annotations,V0,(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(rI).join("/")}if(H0(c)){let y=cI(d2(c,(S)=>S.ast)),j=iI(lI(y,{additionalProperties:n?.additionalProperties})),A=c.map((S,v)=>{let w=l(S.path),N=j.schemas[v];return{op:"replace",path:w,value:N}});Object.entries(j.definitions).forEach(([S,v])=>{A.push({op:"add",path:l(["components","schemas",S]),value:v})}),m=nI(A,m)}return Object.keys(m.components.schemas).forEach((y)=>{if(!mI.test(y))throw new globalThis.Error(`Invalid component schema key: ${y}`)}),lr(r.annotations,Ji,(y)=>{Object.assign(m,y)}),lr(r.annotations,Oi,(y)=>{m=y(m)}),M2.set(r,m),m}function T2(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,Xi(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:N,contentType:E}=S;if(w===void 0)m.set(A,{descriptions:new Set(v!==void 0?[v]:[]),content:new Map([[N,new Map([[E,new Set([j])]])]])});else if(w.content!==void 0){if(v!==void 0)w.descriptions.add(v);let Q=w.content.get(N);if(Q===void 0)w.content.set(N,new Map([[E,new Set([j])]]));else{let W=Q.get(E);if(W===void 0)Q.set(E,new Set([j]));else W.add(j)}}}}function h2(r){return f2(r)??wl(r)}var yI=Dm.annotate({format:"binary"});function B2(r,n){switch(n){case"Uint8Array":return yI.ast;case"Text":return Dm.ast;case"FormUrlEncoded":case"Json":return r;case"Multipart":return jI(r)}}function jI(r){if(t2(r)&&r.annotations?.typeConstructor?._tag==="effect/http/PersistedFile")return yI.ast;if(typeof r?.recur==="function")return r.recur(jI);return r}var j4=(r)=>{let n={};switch(lr(r.annotations,yi,(i)=>{n.description=i}),r._tag){case"Basic":return{...n,type:"http",scheme:"basic"};case"Bearer":{let i=vl(r.annotations,o0).pipe(a2((m)=>({bearerFormat:m})),p2);return{...n,type:"http",scheme:"bearer",...i}}case"ApiKey":return{...n,type:"apiKey",name:r.key,in:r.in}}};var I4=(r,n)=>qI(Pl(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*SI(`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(XI(y)))}})),A4=(r,n,i)=>Z0(vm(function*(){let m=(yield*$m()).pipe(Am(Sm)),c=r.groups[n],l=i(N4(c)),y=J0(l)?yield*l:l,j=[];for(let A of y.handlers)j.push(D4(c,A,m));return Y0(new Map([[c.key,j]]))})),gI=Symbol.for("@effect/platform/HttpApiBuilder/Handlers"),S4=(r,n,i,m)=>$I((c)=>{let l=r.groups[n],y=l.endpoints[i];return t(zI(l,y,Am(Sm)(c),m,!1))}),FI=(r)=>{switch(r._tag){case"Bearer":return h0(k0.asEffect(),(n)=>Li((n.headers.authorization??"").slice(w4)));case"ApiKey":{let n=r.in==="header"?r.key.toLowerCase():r.key,i=jm({[n]:Dm}),m=r.in==="query"?JI(i):r.in==="cookie"?YI(i):ZI(i);return Gl(m,{onFailure:()=>Li(""),onSuccess:(c)=>Li(c[n])})}case"Basic":{let n={username:"",password:Li("")};return k0.asEffect().pipe(hn((i)=>GI((i.headers.authorization??"").slice($4)).asEffect()),Gl({onFailure:()=>n,onSuccess:(i)=>{let m=i.split(":");if(m.length!==2)return n;return{username:m[0],password:Li(m[1])}}}))}}},v4=(r,n,i)=>OI((m,c)=>Bn(RI(c,r.key,NI(n),{secure:!0,httpOnly:!0,...i}))),w4=7,$4=6,G4={[gI]:{_Endpoints:zn},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}},N4=(r)=>{let n=Object.create(G4);return n.group=r,n.handlers=new Set,n};function E4(r){let n=new Map;return r.forEach(({encoding:i,schemas:m},c)=>{let l=Pm(Ri(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 Q4(r,n,i){let m=Wi(n.method),c=m?P4(n):"application/x-www-form-urlencoded",l=r.get(c);if(!l)return x0(`Unsupported content-type: ${c}`,{status:415});let{_tag:y,decode:j}=l;switch(y){case"Multipart":{if(l.mode==="buffered")return hn(Bn(Nl(l.limits,{onUndefined:()=>n.multipart,onDefined:(A)=>Ul(n.multipart,Ql(A))})),j);return t(Nl(l.limits,{onUndefined:()=>n.multipartStream,onDefined:(A)=>PI(n.multipartStream,Ql(A))}))}case"Json":return hn(Bn(n.json),j);case"Text":return hn(Bn(n.text),j);case"FormUrlEncoded":{let A=m?h0(Bn(n.urlParamsBody),CI):t(i);return hn(A,j)}case"Uint8Array":return hn(h0(Bn(n.arrayBuffer),(A)=>new Uint8Array(A)),j)}}function zI(r,n,i,m,c){let l=El(R4(n)),y=El(V4(n)),j=T0(n.params,Pm),A=T0(n.headers,Pm),S=T0(n.query,Pm),w=n.payload.size>0&&!c?E4(n.payload):void 0;return C4(r,n,i,vm(function*(){let E=UI().context,Q=Um(E,k0),W=Um(E,LI),H=Um(E,VI),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(H);if(w){let J=Q4(w,Q,H);if(B0(J))return J;if(J!==void 0)X.payload=yield*J}let K=yield*m(X);return B0(K)?K:yield*l(K)})).pipe(wI,O0((N)=>Bn(y(N))),Ul(i))}function D4(r,n,i){let m=n.endpoint;return _I(m.method,m.path,zI(r,m,i,n.handler,n.isRaw),{uninterruptible:n.uninterruptible})}var U4=(r)=>r.headers["content-type"]?r.headers["content-type"].toLowerCase().trim():"application/json",P4=(r)=>{let n=U4(r),i=n.indexOf(";");return i===-1?n:n.slice(0,i).trim()},C4=(r,n,i,m)=>{let c={group:r,endpoint:n};for(let l of n.middlewares){let y=l,j=Um(i,y);m=(Gm(y)?W4(y,j):j)(m,c)}return m},II=new WeakMap,W4=(r,n)=>{let i=II.get(n);if(i!==void 0)return i;let m=Object.entries(r.security).map(([l,y])=>({decode:FI(y),middleware:n[l]}));if(m.length===0)return zn;let c=Pl(function*(l,y){let j;for(let A=0;A<m.length;A++){let{decode:S,middleware:v}=m[A],w=yield*vI(hn(S,(N)=>v(l,{credential:N,endpoint:y.endpoint,group:y.group})));if(AI(w)){j=w;continue}return w.success}return yield*j.asEffect()});return II.set(n,c),c},X4=X0(B0),K4=oI(Ki),H4=oI(Hi);function R4(r){let n=mi(r).map(K4);return n.length===1?n[0]:Ri(n)}function V4(r){let n=ci(r).map(H4);return n.length===1?n[0]:Ri(n)}function oI(r){let n=new WeakMap;return(i)=>{let m=n.get(i.ast);if(m!==void 0)return m;let c=X4.pipe(Ci(i,Y4(r,i)));return n.set(c.ast,c),c}}function Y4(r,n){let i=n.ast,m=Z4(r(i),Xi(i),cm(i));return DI({decode:(c)=>wm(new QI(Dl(c),{message:"Encode only schema"})),encode:m})}function Z4(r,n,i){switch(n._tag){case"Json":return(m)=>{if(m===void 0||i)return t(Pr({status:r}));try{let c=JSON.stringify(m);return t(x0(c,{status:r,contentType:n.contentType}))}catch(c){return wm(new EI(Dl(m),{message:globalThis.String(c)}))}};case"Text":return(m)=>t(x0(m,{status:r,contentType:n.contentType}));case"Uint8Array":return(m)=>t(WI(m,{status:r,contentType:n.contentType}));case"FormUrlEncoded":return(m)=>t(KI(m,{status:r}).pipe(HI("content-type",n.contentType)))}}var xr={};Nr(xr,{make:()=>L4,isHttpApiGroup:()=>J4});var Wl="~effect/httpapi/HttpApiGroup",J4=(r)=>on(r,Wl),O4={[Wl]:Wl,add(...r){let n={...this.endpoints};for(let i of r)n[i.name]=i;return xn({identifier:this.identifier,topLevel:this.topLevel,endpoints:n,annotations:this.annotations})},prefix(r){return xn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(n)=>n.prefix(r)),annotations:this.annotations})},middleware(r){return xn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(n)=>n.middleware(r)),annotations:this.annotations})},annotateMerge(r){return xn({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,annotations:or(this.annotations,r)})},annotate(r,n){return xn({identifier:this.identifier,topLevel:this.topLevel,endpoints:this.endpoints,annotations:Sn(this.annotations,r,n)})},annotateEndpointsMerge(r){return xn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(n)=>n.annotateMerge(r)),annotations:this.annotations})},annotateEndpoints(r,n){return xn({identifier:this.identifier,topLevel:this.topLevel,endpoints:Tn(this.endpoints,(i)=>i.annotate(r,n)),annotations:this.annotations})},pipe(){return An(this,arguments)}},xn=(r)=>{function n(){}return Object.setPrototypeOf(n,O4),n.key=`effect/httpapi/HttpApiGroup/${r.identifier}`,Object.assign(n,r)},L4=(r,n)=>xn({identifier:r,topLevel:n?.topLevel??!1,endpoints:MI(),annotations:Br()});var a0={};Nr(a0,{bearer:()=>q4,basic:()=>g4,apiKey:()=>_4,annotateMerge:()=>F4,annotate:()=>z4});var TI="~effect/httpapi/HttpApiSecurity",Cm={[TI]:TI,pipe(){return An(this,arguments)}},q4=Object.assign(Object.create(Cm),{_tag:"Bearer",annotations:Br()}),_4=(r)=>Object.assign(Object.create(Cm),{_tag:"ApiKey",key:r.key,in:r.in??"header",annotations:Br()}),g4=Object.assign(Object.create(Cm),{_tag:"Basic",annotations:Br()}),F4=Xl(2,(r,n)=>Object.assign(Object.create(Cm),{...r,annotations:or(r.annotations,n)})),z4=Xl(3,(r,n,i)=>Object.assign(Object.create(Cm),{...r,annotations:Sn(r.annotations,n,i)}));var o4="/config",Kl=Mr.make("config").add(xr.make("config").add(u.get("providers",`${o4}/providers`,{success:ir.ConfigProvidersResult}).annotateMerge(T.annotations({identifier:"config.providers",summary:"List config providers",description:"Get a list of all configured AI providers and their default models."}))).annotateMerge(T.annotations({title:"config",description:"Experimental HttpApi config routes."}))).annotateMerge(T.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),hI=M.unwrap(P.gen(function*(){let r=yield*ir.Service,n=P.fn("ConfigHttpApi.providers")(function*(){let i=yield*r.list();return{providers:Object.values(i),default:ir.defaultModelIDs(i)}});return Sr.group(Kl,"config",(i)=>i.handle("providers",n))})).pipe(M.provide(ir.defaultLayer),M.provide(cr.defaultLayer));var BI="/permission",Hl=Mr.make("permission").add(xr.make("permission").add(u.get("list",BI,{success:F.Array(Qr.Request)}).annotateMerge(T.annotations({identifier:"permission.list",summary:"List pending permissions",description:"Get all pending permission requests across all sessions."})),u.post("reply",`${BI}/:requestID/reply`,{params:{requestID:Pi},payload:Qr.ReplyBody,success:F.Boolean}).annotateMerge(T.annotations({identifier:"permission.reply",summary:"Respond to permission request",description:"Approve or deny a permission request from the AI assistant."}))).annotateMerge(T.annotations({title:"permission",description:"Experimental HttpApi permission routes."}))).annotateMerge(T.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),xI=M.unwrap(P.gen(function*(){let r=yield*Qr.Service,n=P.fn("PermissionHttpApi.list")(function*(){return yield*r.list()}),i=P.fn("PermissionHttpApi.reply")(function*(m){return yield*r.reply({requestID:m.params.requestID,reply:m.payload.reply,message:m.payload.message}),!0});return Sr.group(Hl,"permission",(m)=>m.handle("list",n).handle("reply",i))})).pipe(M.provide(Qr.defaultLayer));var kI="/project",Rl=Mr.make("project").add(xr.make("project").add(u.get("list",kI,{success:F.Array(Gr.Info)}).annotateMerge(T.annotations({identifier:"project.list",summary:"List all projects",description:"Get a list of projects that have been opened with QitQode."})),u.get("current",`${kI}/current`,{success:Gr.Info}).annotateMerge(T.annotations({identifier:"project.current",summary:"Get current project",description:"Retrieve the currently active project that QitQode is working with."}))).annotateMerge(T.annotations({title:"project",description:"Experimental HttpApi project routes."}))).annotateMerge(T.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),pI=M.unwrap(P.gen(function*(){let r=yield*Gr.Service,n=P.fn("ProjectHttpApi.list")(function*(){return yield*r.list()}),i=P.fn("ProjectHttpApi.current")(function*(){return o.project});return Sr.group(Rl,"project",(m)=>m.handle("list",n).handle("current",i))})).pipe(M.provide(Gr.defaultLayer));var u0=P.fnUntraced(function*(r,n){let i=yield*P.promise(()=>uI.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(aI(l,(j)=>ir.fromModelsDevProvider(j)),n);return{all:Object.values(y),default:ir.defaultModelIDs(y),connected:Object.keys(n)}});var d0="/provider",Vl=Mr.make("provider").add(xr.make("provider").add(u.get("list",d0,{success:ir.ListResult}).annotateMerge(T.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",`${d0}/auth`,{success:Cr.Methods}).annotateMerge(T.annotations({identifier:"provider.auth",summary:"Get provider auth methods",description:"Retrieve available authentication methods for all AI providers."})),u.post("authorize",`${d0}/:providerID/oauth/authorize`,{params:{providerID:s},payload:Cr.AuthorizeInput,success:Cr.Authorization}).annotateMerge(T.annotations({identifier:"provider.oauth.authorize",summary:"Start OAuth authorization",description:"Start the OAuth authorization flow for a provider."})),u.post("callback",`${d0}/:providerID/oauth/callback`,{params:{providerID:s},payload:Cr.CallbackInput,success:F.Boolean}).annotateMerge(T.annotations({identifier:"provider.oauth.callback",summary:"Handle OAuth callback",description:"Handle the OAuth callback from a provider after user authorization."}))).annotateMerge(T.annotations({title:"provider",description:"Experimental HttpApi provider routes."}))).annotateMerge(T.annotations({title:"qitqode experimental HttpApi",version:"0.0.1",description:"Experimental HttpApi surface for selected instance routes."})),dI=M.unwrap(P.gen(function*(){let r=yield*cr.Service,n=yield*ir.Service,i=yield*Cr.Service,m=P.fn("ProviderHttpApi.list")(function*(){let j=yield*r.get(),A=yield*n.list();return yield*u0(j,A)}),c=P.fn("ProviderHttpApi.auth")(function*(){return yield*i.methods()}),l=P.fn("ProviderHttpApi.authorize")(function*(j){let A=yield*i.authorize({providerID:j.params.providerID,method:j.payload.method,inputs:j.payload.inputs}).pipe(P.catch(()=>P.fail(new Vi.BadRequest({}))));if(!A)return yield*new Vi.BadRequest({});return A}),y=P.fn("ProviderHttpApi.callback")(function*(j){return yield*i.callback({providerID:j.params.providerID,method:j.payload.method,code:j.payload.code}).pipe(P.catch(()=>P.fail(new Vi.BadRequest({})))),!0});return Sr.group(Vl,"provider",(j)=>j.handle("list",m).handle("auth",c).handle("authorize",l).handle("callback",y))})).pipe(M.provide(Cr.defaultLayer),M.provide(ir.defaultLayer),M.provide(cr.defaultLayer));var Wm="/question",Yl=Mr.make("question").add(xr.make("question").add(u.get("list",Wm,{success:F.Array(_r.Request)}).annotateMerge(T.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:_r.Reply,success:F.Boolean}).annotateMerge(T.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:F.Boolean}).annotateMerge(T.annotations({identifier:"question.reject",summary:"Reject question request",description:"Reject a question request from the AI assistant."})),u.get("neverAsk",`${Wm}/never-ask`,{success:F.Boolean}).annotateMerge(T.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:F.Struct({enabled:F.Boolean}),success:F.Boolean}).annotateMerge(T.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(T.annotations({title:"question",description:"Question routes."}))).annotateMerge(T.annotations({title:"qitqode HttpApi",version:"0.0.1",description:"Effect HttpApi surface for instance routes."})),tI=M.unwrap(P.gen(function*(){let r=yield*_r.Service,n=P.fn("QuestionHttpApi.list")(function*(){return yield*r.list()}),i=P.fn("QuestionHttpApi.reply")(function*(y){return yield*r.reply({requestID:y.params.requestID,answers:y.payload.answers}),!0}),m=P.fn("QuestionHttpApi.reject")(function*(y){return yield*r.reject(y.params.requestID),!0}),c=P.fn("QuestionHttpApi.neverAsk")(function*(){return yield*r.neverAsk()}),l=P.fn("QuestionHttpApi.setNeverAsk")(function*(y){return yield*r.setNeverAsk(y.payload.enabled),yield*r.neverAsk()});return Sr.group(Yl,"question",(y)=>y.handle("list",n).handle("reply",i).handle("reject",m).handle("neverAsk",c).handle("setNeverAsk",l))})).pipe(M.provide(_r.defaultLayer));var M4=F.Struct({directory:F.optional(F.String),workspace:F.optional(F.String)}),T4=F.Struct({authorization:F.optional(F.String),"x-qitqode-directory":F.optional(F.String)});function h4(r){try{return decodeURIComponent(r)}catch{return r}}class t0 extends F.TaggedErrorClass()("Unauthorized",{message:F.String},{httpApiStatus:401}){}class kn extends Yi.Service()("@qitqode/ExperimentalHttpApiAuthorization",{error:t0,security:{basic:a0.basic}}){}var B4=M.succeed(kn,kn.of({basic:(r,{credential:n})=>P.gen(function*(){if(!p.QITQODE_SERVER_PASSWORD)return yield*r;let i=p.QITQODE_SERVER_USERNAME??"qitqode";if(n.username!==i)return yield*new t0({message:"Unauthorized"});if(Cl.value(n.password)!==p.QITQODE_SERVER_PASSWORD)return yield*new t0({message:"Unauthorized"});return yield*r})}));class n1 extends F.TaggedErrorClass()("DirectoryAccessDenied",{message:F.String},{httpApiStatus:403}){}var x4=Im.middleware()(P.gen(function*(){return(r)=>P.gen(function*(){let n=yield*p0.schemaSearchParams(M4),i=yield*p0.schemaHeaders(T4),m=n.directory||i["x-qitqode-directory"]||process.cwd(),c=n.workspace||void 0,l=Xn.resolve(h4(m));if(!p.QITQODE_SERVER_PASSWORD){let A=Xn.resolve(process.cwd());if(!Xn.contains(A,l))return yield*new n1({message:"Access denied: directory must be within the server's working directory"})}let y=yield*P.promise(()=>o.provide({directory:l,init:()=>e.runPromise(pn),fn:()=>o.current}));return yield*(c?r.pipe(P.provideService(eI,c)):r).pipe(P.provideService(bI,y))})})).layer,k4=Yl.middleware(kn),p4=Hl.middleware(kn),a4=Rl.middleware(kn),u4=Vl.middleware(kn),d4=Kl.middleware(kn),i1=M.mergeAll(Sr.layer(d4).pipe(M.provide(hI)),Sr.layer(a4).pipe(M.provide(pI)),Sr.layer(k4).pipe(M.provide(tI)),Sr.layer(p4).pipe(M.provide(xI)),Sr.layer(u4).pipe(M.provide(dI))).pipe(M.provide(B4),M.provide(x4),M.provide(sI.layerServices),M.provideMerge(fI.layer)),t4=g(()=>Im.toWebHandler(i1,{memoMap:r1}));var m1=g(()=>new V().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(o.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=o.directory,i=o.project,m=await x("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 o.reload({directory:n,worktree:n,project:m,init:()=>e.runPromise(pn)}),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)}}},...C(400,404)}}),D("param",I.object({projectID:y0.zod})),D("json",Gr.UpdateInput.omit({projectID:!0})),async(r)=>U("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 Yn=_.create({service:"server"}),f=()=>D("param",I.object({sessionID:br.zod})),Zl=()=>D("param",I.object({sessionID:br.zod,messageID:vn.zod})),Jl=()=>D("param",I.object({sessionID:br.zod,messageID:vn.zod,partID:un.zod}));function c1(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)=>P.gen(function*(){let m=yield*(yield*Z.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 y1(){return new V().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:$(Z.Info.array())}}}}}),D("query",I.object(an)),async(r)=>{let n=r.req.valid("query"),i=[];for await(let m of Z.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(),Ll.Info))}}},...C(400)}}),async(r)=>U("SessionRoutes.status",r,function*(){let n=yield*Ll.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:$(Z.Info)}}},...C(400,404)}}),D("param",I.object({sessionID:Z.GetInput})),async(r)=>{let n=r.req.valid("param").sessionID;return U("SessionRoutes.get",r,function*(){return yield*(yield*Z.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:$(Z.Info.array())}}},...C(400,404)}}),D("param",I.object({sessionID:Z.ChildrenInput})),async(r)=>{let n=r.req.valid("param").sessionID;return U("SessionRoutes.children",r,function*(){return yield*(yield*Z.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:{...C(400),200:{description:"Successfully created session",content:{"application/json":{schema:$(Z.Info)}}}}}),D("json",Z.CreateInput),async(r)=>U("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())}}},...C(400,404)}}),D("param",I.object({sessionID:Z.RemoveInput})),async(r)=>U("SessionRoutes.delete",r,function*(){let n=r.req.valid("param").sessionID;return yield*(yield*Z.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:$(Z.Info)}}},...C(400,404)}}),f(),D("json",I.object({title:I.string().optional(),permission:Qr.Ruleset.zod.optional(),time:I.object({archived:I.number().optional()}).optional()})),async(r)=>U("SessionRoutes.update",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json"),m=yield*Z.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())}}},...C(400,404)}}),f(),D("json",I.object({modelID:er.zod,providerID:s.zod,messageID:vn.zod})),async(r)=>U("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:$(Z.Info)}}}}}),D("param",I.object({sessionID:Z.ForkInput.shape.sessionID})),D("json",Z.ForkInput.omit({sessionID:!0})),async(r)=>U("SessionRoutes.fork",r,function*(){let n=r.req.valid("param").sessionID,i=r.req.valid("json");return yield*(yield*Z.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())}}},...C(400,404)}}),f(),async(r)=>U("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"},...C(400,404)}}),f(),async(r)=>{let n=r.req.valid("param").sessionID,i=await x("SessionRoutes.actors",r,P.gen(function*(){let m=yield*l1.Service;return yield*(yield*Z.Service).get(n),yield*m.listBySession(n)}));return r.json(i)})}function I1(){return new V().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:$(_l.Info.array())}}},...C(400,404)}}),f(),async(r)=>{let n=r.req.valid("param").sessionID;return U("SessionRoutes.todo",r,function*(){let m=yield*(yield*ql.Service).list({session_id:n,include_terminal:!0});if(m.length>0)return m.map(c1);return yield*(yield*_l.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:$(j1.array())}}},...C(400,404)}}),f(),async(r)=>{let n=r.req.valid("param").sessionID,i=await x("SessionRoutes.task",r,P.gen(function*(){let m=yield*ql.Service;return yield*(yield*Z.Service).get(n),yield*m.list({session_id:n,include_terminal:!0})}));return r.json(i)})}function A1(){return new V().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:$(Z.Info)}}},...C(400,404)}}),f(),async(r)=>U("SessionRoutes.share",r,function*(){let n=r.req.valid("param").sessionID,i=yield*Hm.Service,m=yield*Z.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:$(Z.Info)}}},...C(400,404)}}),f(),async(r)=>U("SessionRoutes.unshare",r,function*(){let n=r.req.valid("param").sessionID,i=yield*Hm.Service,m=yield*Z.Service;return yield*i.unshare(n),yield*m.get(n)}))}var b4={code:"SUMMARY_FAILED",message:"The session summary could not be completed."};function e4(r){return r.some((n)=>n.type==="text"&&n.text.trim().length>0)}function $1(r=x){return new V().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:$(v1.FileDiff.array())}}}}}),D("param",I.object({sessionID:b0.DiffInput.shape.sessionID})),D("query",I.object({messageID:b0.DiffInput.shape.messageID})),async(n)=>U("SessionRoutes.diff",n,function*(){let i=n.req.valid("query"),m=n.req.valid("param");return yield*(yield*b0.Service).diff({sessionID:m.sessionID,messageID:i.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())}}},422:{description:"Summary could not be completed",content:{"application/json":{schema:$(I.object({error:I.object({code:I.literal("SUMMARY_FAILED"),message:I.string()})}))}}},...C(400,404)}}),f(),D("json",I.object({providerID:s.zod,modelID:er.zod,auto:I.boolean().optional().default(!1)})),async(n)=>{return await r("SessionRoutes.summarize",n,P.gen(function*(){let m=n.req.valid("param").sessionID,c=n.req.valid("json"),l=yield*Z.Service,y=yield*Rm.Service,j=yield*w1.Service,A=yield*Dr.Service,S=yield*ji.Service;yield*y.cleanup(yield*l.get(m));let v=yield*Ol(m,yield*S.defaultAgent()),w=yield*j.create({sessionID:m,agent:v,model:{providerID:c.providerID,modelID:c.modelID},auto:c.auto,agentID:"main"}),N=yield*P.exit(A.loop({sessionID:m})),E=yield*l.messages({sessionID:m,agentID:"main"});if(S1.isFailure(N))return Yn.warn("summarize: prompt loop did not complete",{sessionID:m,boundaryID:w}),!1;let Q=E.filter((H)=>H.info.role==="assistant"&&H.info.parentID===w&&H.info.mode==="compaction"&&H.info.summary===!0).at(-1);if(!Q)return Yn.warn("summarize: no compaction summary message found",{sessionID:m,boundaryID:w}),!1;let W=Q.info;if(W.finish!=="done")return Yn.warn("summarize: compaction summary not finished",{sessionID:m,boundaryID:w,finish:W.finish}),!1;if(W.error)return Yn.warn("summarize: compaction summary has error",{sessionID:m,boundaryID:w}),!1;if(!e4(Q.parts))return Yn.warn("summarize: compaction summary has no visible text",{sessionID:m,boundaryID:w}),!1;return!0}))?n.json(!0):n.json({error:b4},422)}).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:$(Z.Info)}}},...C(400,404)}}),f(),D("json",Rm.RevertInput.omit({sessionID:!0})),async(n)=>{let i=n.req.valid("param").sessionID;return Yn.info("revert",n.req.valid("json")),U("SessionRoutes.revert",n,function*(){return yield*(yield*Rm.Service).revert({sessionID:i,...n.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:$(Z.Info)}}},...C(400,404)}}),f(),async(n)=>U("SessionRoutes.unrevert",n,function*(){let i=n.req.valid("param").sessionID;return yield*(yield*Rm.Service).unrevert({sessionID:i})}))}var e0=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 Vm=()=>{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 Vm=()=>n,n};var s4=new WeakMap,s0=(r,n,i)=>{let{readable:m,writable:c}=new TransformStream,l=new e0(c,m);if(Vm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return s4.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 G1=class extends e0{constructor(r,n){super(r,n)}async writeSSE(r){let i=(await Mi(r.data,om.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)}},f4=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()}},r$=new WeakMap,gl=(r,n,i)=>{let{readable:m,writable:c}=new TransformStream,l=new G1(c,m);if(Vm())r.req.raw.signal.addEventListener("abort",()=>{if(!l.closed)l.abort()});return r$.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"),f4(l,n,i),r.newResponse(l.responseReadable)};var N1=I.object({info:Ar.Assistant,parts:Ar.Part.array()});function E1(){return new V().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:$(Ar.WithParts.array())}}},...C(400,404)}}),f(),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 Ar.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 x("SessionRoutes.messages",r,P.gen(function*(){let y=yield*Z.Service;return yield*y.get(i),yield*y.messages({sessionID:i,agentID:m})}));return r.json(l)}let c=await Ar.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:Ar.Info,parts:Ar.Part.array()}))}}},...C(400,404)}}),Zl(),async(r)=>{let n=r.req.valid("param"),i=await Ar.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())}}},...C(400,404)}}),Zl(),async(r)=>U("SessionRoutes.deleteMessage",r,function*(){let n=r.req.valid("param"),i=yield*Fl.Service,m=yield*Z.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())}}},...C(400,404)}}),Jl(),async(r)=>U("SessionRoutes.deletePart",r,function*(){let n=r.req.valid("param");return yield*(yield*Z.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:$(Ar.Part)}}},...C(400,404)}}),Jl(),D("json",Ar.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 U("SessionRoutes.updatePart",r,function*(){return yield*(yield*Z.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:$(N1)}}},...C(400,404,409)}}),f(),D("json",Dr.PromptInput.omit({sessionID:!0})),async(r)=>{let n=r.req.valid("param").sessionID;return await x("SessionRoutes.prompt.assertNotBusy",r,Fl.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=()=>{x("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 x("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"},...C(400,404)}}),f(),D("json",Dr.PromptInput.omit({sessionID:!0})),async(r)=>{let n=r.req.valid("param").sessionID,i=r.req.valid("json");return x("SessionRoutes.prompt_async",r,Dr.Service.use((m)=>m.prompt({...i,sessionID:n}))).catch((m)=>{Yn.error("prompt_async failed",{sessionID:n,error:m}),wr.publish(Z.Event.Error,{sessionID:n,error:Ar.fromError(m,{providerID:s.make(i.model?.providerID??"qlex")})})}),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:$(N1)}}},...C(400,404)}}),f(),D("json",Dr.CommandInput.omit({sessionID:!0})),async(r)=>U("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()}))}}},...C(400,404)}}),f(),async(r)=>U("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:$(Ar.WithParts)}}},...C(400,404)}}),f(),D("json",Dr.ShellInput.omit({sessionID:!0})),async(r)=>U("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 Q1(){return new V().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())}}},...C(400,404)}}),D("param",I.object({sessionID:br.zod,permissionID:Pi.zod})),D("json",I.object({response:Qr.Reply.zod})),async(r)=>U("SessionRoutes.permissionRespond",r,function*(){let n=r.req.valid("param");return yield*A0({requestID:n.permissionID,reply:r.req.valid("json").response})}))}var D1=g(()=>{let r=new V;return r.route("/",y1()),r.route("/",I1()),r.route("/",A1()),r.route("/",$1()),r.route("/",E1()),r.route("/",Q1()),r});var U1=_.create({service:"server.qredits"}),n$=I.object({balance:I.number().nullable(),status:I.enum(["signed_out","available","unavailable","not_linked"])}),X1=g(()=>new V().get("/balance",G({summary:"Get Qredits balance",description:"Retrieve the current Qredits balance for the account behind the active credential. The response status distinguishes signed-out users, credentials with no linked account, and temporary billing-service outages.",operationId:"qredits.balance",responses:{200:{description:"Qredits balance",content:{"application/json":{schema:$(n$)}}}}}),async(r)=>U("QreditsRoutes.balance",r,function*(){let n=yield*P.promise(()=>P1());if(!n)return{balance:null,status:"signed_out"};let i=yield*P.tryPromise({try:()=>W1(n),catch:(m)=>m}).pipe(P.map((m)=>m?{kind:"ok",balance:m.balance}:{kind:"failed"}),P.catch((m)=>P.sync(()=>{if(m instanceof C1)return U1.warn("credential has no linked account; no wallet to read",{method:n.method}),{kind:"not_linked"};return U1.warn("qredits balance read failed; reporting unavailable",{method:n.method,error:m instanceof Error?m.message:String(m)}),{kind:"failed"}})));if(i.kind==="not_linked")return{balance:null,status:"not_linked"};if(i.kind==="failed")return{balance:null,status:"unavailable"};return{balance:i.balance,status:"available"}})));function K1(r){return new V().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)=>U("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)}}},...C(400)}}),D("json",Wr.CreateInput),async(n)=>U("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)}}},...C(404)}}),D("param",I.object({ptyID:Ii.zod})),async(n)=>{let i=await x("PtyRoutes.get",n,P.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)}}},...C(400)}}),D("param",I.object({ptyID:Ii.zod})),D("json",Wr.UpdateInput),async(n)=>U("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())}}},...C(404)}}),D("param",I.object({ptyID:Ii.zod})),async(n)=>U("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"},...C(404)}}),D("param",I.object({ptyID:Ii.zod})),async(n)=>{if(n.req.header(gj)!==Fj)return n.json({error:"Forbidden"},403);let i=n.req.valid("param").ptyID;if(!await x("PtyRoutes.connectToken",n,P.gen(function*(){return yield*(yield*Wr.Service).get(i)})))throw new Wn({message:"Session not found"});return n.json(oj(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())}}},...C(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||!Mj(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 x("PtyRoutes.connect",n,P.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 e.runPromise(P.gen(function*(){return yield*(yield*Wr.Service).connect(i,w,c)}).pipe(P.withSpan("PtyRoutes.connect.open"))),A=!0;for(let N of j)l?.onMessage(N);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 H1=(r,n)=>P.gen(function*(){let i=yield*Xr.Service;if(n==="connect")yield*i.connect(r);else yield*i.disconnect(r);return!0}),V1=g(()=>new V().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)=>U("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))}}},...C(400)}}),D("json",I.object({name:I.string(),config:R1.Info.zod})),async(r)=>{if(!p.QITQODE_SERVER_PASSWORD)return r.json({error:"Forbidden: QITQODE_SERVER_PASSWORD must be set to add MCP servers via API"},403);return U("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")}))}}},...C(400,404)}}),async(r)=>{let n=r.req.param("name"),i=await x("McpRoutes.auth.start",r,P.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)}}},...C(400,404)}}),D("json",I.object({code:I.string().describe("Authorization code from OAuth callback")})),async(r)=>U("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)}}},...C(400,404)}}),async(r)=>{let n=r.req.param("name"),i=await x("McpRoutes.auth.authenticate",r,P.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)}))}}},...C(404)}}),async(r)=>U("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)=>U("McpRoutes.connect",r,function*(){return yield*H1(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)=>U("McpRoutes.disconnect",r,function*(){return yield*H1(r.req.valid("param").name,"disconnect")})));var Y1=g(()=>new V().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)=>U("FileRoutes.findText",r,function*(){let n=r.req.valid("query").pattern;return(yield*(yield*zl.Service).search({cwd:o.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)=>U("FileRoutes.findFile",r,function*(){let n=r.req.valid("query");return yield*(yield*dn.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:$(dn.Node.array())}}}}}),D("query",I.object({path:I.string()})),async(r)=>U("FileRoutes.list",r,function*(){return yield*(yield*dn.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:$(dn.Content)}}}}}),D("query",I.object({path:I.string()})),async(r)=>U("FileRoutes.read",r,function*(){return yield*(yield*dn.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:$(dn.Info.array())}}}}}),async(r)=>U("FileRoutes.status",r,function*(){return yield*(yield*dn.Service).status()})));var Z1=g(()=>new V().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:$(cr.Info)}}}}}),async(r)=>U("ConfigRoutes.get",r,function*(){return yield*(yield*cr.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:$(cr.Info)}}},...C(400)}}),D("json",cr.Info),async(r)=>U("ConfigRoutes.update",r,function*(){let n=r.req.valid("json");return yield*(yield*cr.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:$(ir.ConfigProvidersResult.zod)}}}}}),async(r)=>U("ConfigRoutes.providers",r,function*(){let i=yield*(yield*ir.Service).list();return{providers:Object.values(i),default:ir.defaultModelIDs(i)}})));var i$=I.object({accountID:I.string(),accountEmail:I.string(),accountUrl:I.string(),orgID:I.string(),orgName:I.string(),active:I.boolean()}),m$=I.object({orgs:I.array(i$)}),c$=I.object({accountID:I.string(),orgID:I.string()}),q1=g(()=>new V().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:$(L1.zod)}}}}}),async(r)=>U("ExperimentalRoutes.console.get",r,function*(){let n=yield*cr.Service,i=yield*f0.Service,[m,c]=yield*P.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:$(m$)}}}}}),async(r)=>U("ExperimentalRoutes.console.listOrgs",r,function*(){let n=yield*f0.Service,[i,m]=yield*P.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",c$),async(r)=>U("ExperimentalRoutes.console.switchOrg",r,function*(){let n=r.req.valid("json");return yield*(yield*f0.Service).use(J1.make(n.accountID),Qm.some(O1.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"}))}}},...C(400)}}),async(r)=>U("ExperimentalRoutes.tool.ids",r,function*(){return yield*(yield*ol.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"}))}}},...C(400)}}),D("query",I.object({provider:I.string(),model:I.string()})),async(r)=>{let{provider:n,model:i}=r.req.valid("query"),m=await x("ExperimentalRoutes.tool.list",r,P.gen(function*(){let c=yield*ji.Service;return yield*(yield*ol.Service).tools({providerID:s.make(n),modelID:er.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:$(tn.Info)}}},...C(400)}}),D("json",tn.CreateInput.optional()),async(r)=>U("ExperimentalRoutes.worktree.create",r,function*(){let n=r.req.valid("json"),i=n?{...n,startCommand:p.QITQODE_SERVER_PASSWORD?n.startCommand:void 0}:n;return yield*(yield*tn.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)=>U("ExperimentalRoutes.worktree.list",r,function*(){return yield*(yield*Gr.Service).sandboxes(o.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())}}},...C(400)}}),D("json",tn.RemoveInput),async(r)=>U("ExperimentalRoutes.worktree.remove",r,function*(){let n=r.req.valid("json"),i=yield*tn.Service,m=yield*Gr.Service;return yield*i.remove(n),yield*m.removeSandbox(o.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())}}},...C(400)}}),D("json",tn.ResetInput),async(r)=>U("ExperimentalRoutes.worktree.reset",r,function*(){let n=r.req.valid("json");return yield*(yield*tn.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:$(Z.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 Z.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)=>U("ExperimentalRoutes.resource.list",r,function*(){return yield*(yield*Xr.Service).resources()})));var _1=g(()=>new V().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:$(ir.ListResult.zod)}}}}}),async(r)=>U("ProviderRoutes.list",r,function*(){let n=yield*ir.Service,m=yield*(yield*cr.Service).get(),c=yield*n.list();return yield*u0(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)=>U("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())}}},...C(400)}}),D("param",I.object({providerID:s.zod.meta({description:"Provider ID"})})),D("json",Cr.AuthorizeInput.zod),async(r)=>U("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())}}},...C(400)}}),D("param",I.object({providerID:s.zod.meta({description:"Provider ID"})})),D("json",Cr.CallbackInput.zod),async(r)=>U("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 l$=1e4,y$=1e5,j$=8388608,I$=67108864,A$=2097152,S$=8388608;function v$(r=process.env.QITQODE_EVENT_QUEUE_CAPACITY){let n=Number(r);if(!Number.isSafeInteger(n)||n<1||n>y$)return l$;return n}var w$=v$();function $$(r=process.env.QITQODE_EVENT_QUEUE_BYTES){let n=Number(r);if(!Number.isSafeInteger(n)||n<1||n>I$)return j$;return n}function G$(r=process.env.QITQODE_EVENT_MAX_BYTES){let n=Number(r);if(!Number.isSafeInteger(n)||n<1||n>S$)return A$;return n}var g1=$$(),N$=Math.min(G$(),g1);function E$(r,n=N$){let i=JSON.stringify(r);if(i===void 0||Buffer.byteLength(i)>n)return;return i}function rc(r,n){return gl(r,async(i)=>{let m=new Ui({capacity:w$,maxWeight:g1,weight:(v)=>v===null?0:Buffer.byteLength(v)}),c=!1,l=0,y=()=>{},j=(v)=>{let w=E$(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 Zm{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=_.create({service:"server"}),F1=()=>{let r=Number(process.env.QITQODE_EVENT_CONNECT_LIMIT)||60,n=Number(process.env.QITQODE_EVENT_CONNECT_WINDOW_MS)||60000,i=new Zm(r,n);return new V().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 Q$=I.object({id:I.string(),aggregateID:I.string(),seq:I.number().int().min(0),type:I.string(),data:I.record(I.string(),I.unknown())}),z1=_.create({service:"server.sync"}),h1=g(()=>new V().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 ac(o.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()}))}}},...C(400)}}),D("json",I.object({directory:I.string(),events:I.array(Q$).min(1)})),async(r)=>{let n=r.req.valid("json"),i=n.events,m=i[0].aggregateID;return z1.info("sync replay requested",{sessionID:m,events:i.length,first:i[0]?.seq,last:i.at(-1)?.seq,directory:n.directory}),yr.replayAll(i),z1.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())})))}}},...C(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?M1(o1(...i.map(([l,y])=>im(d(Rr.aggregate_id,l),T1(Rr.seq,y))))):void 0,c=b.use((l)=>l.select().from(Rr).where(m).orderBy(l0(Rr.seq)).all());return r.json(c)}));var hl=(r)=>{let n=new V;if(p.QITQODE_EXPERIMENTAL_HTTPAPI){let i=Xm.webHandler().handler,m=Vn.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",m1()).route("/pty",K1(r)).route("/config",Z1()).route("/experimental",q1()).route("/session",D1()).route("/qredits",X1()).route("/permission",Q2()).route("/workflows",U2()).route("/question",E2()).route("/bash-interactive",P2()).route("/provider",_1()).route("/sync",h1()).route("/",Y1()).route("/",F1()).route("/mcp",V1()).route("/tui",G2()).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 o.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:Zn.Path.home,state:Zn.Path.state,config:Zn.Path.config,worktree:o.worktree,directory:o.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)=>U("InstanceRoutes.vcs.get",i,function*(){let m=yield*_i.Service,[c,l]=yield*P.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)=>U("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)=>U("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)=>U("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:$(Tl.Info.array())}}}}}),async(i)=>U("InstanceRoutes.skill.list",i,function*(){return yield*(yield*Tl.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)=>U("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:$(Ml.Status.array())}}}}}),async(i)=>U("InstanceRoutes.formatter.status",i,function*(){return yield*(yield*Ml.Service).status()}))};function B1(){let r=new V,n=(i,m)=>e.runPromise(P.gen(function*(){let c=yield*rm.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())}}},...C(400)}}),D("param",I.object({providerID:s.zod})),D("json",rm.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())}}},...C(400)}}),D("param",I.object({providerID:s.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())}}},...C(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=_.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={};Nr(gi,{scan:()=>R$,runAll:()=>V$,ExternalImport:()=>gi,ALL_SOURCES:()=>pl});import iA from"path";import{access as Bl}from"fs/promises";import{Database as D$}from"bun:sqlite";function Jm(r){let n=new D$(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={};Nr(Om,{run:()=>W$,parse:()=>u1,CodexImport:()=>Om});import U$ from"path";var P$=_.create({service:"codex-import"});function x1(r){if(!r)return Date.now();let n=Date.parse(r);return Number.isNaN(n)?Date.now():n}function C$(r){if(typeof r==="string")try{return JSON.parse(r)}catch{return{raw:r}}if(r&&typeof r==="object")return r;return{}}function u1(r,n){let i=k1(r);if(i.length===0)return;let m,c,l,y,j=0,A,S=[],v=new Map,w=null,N=null,E=()=>{if(w)S.push(w);w=null},Q=(W)=>{if(!N){let H=vn.ascending();S.push({info:{id:H,sessionID:n,role:"user",agent:"main",time:{created:W},model:{providerID:s.make("openai"),modelID:er.make("unknown")}},parts:[]}),N=H}if(!w||w.info.role!=="assistant")E(),w={info:{id:vn.ascending(),sessionID:n,role:"assistant",time:{created:W,completed:W},parentID:N,modelID:er.make("unknown"),providerID:s.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:H,payload:X}=W,K=x1(W.timestamp);if(y===void 0)y=K;if(j=Math.max(j,K),H==="session_meta"&&X){m=X.cwd,c=`codex-${X.cli_version??"unknown"}`,l=X.id;let q=x1(X.timestamp);if(y===void 0||q<y)y=q;continue}if(H!=="response_item"||!X)continue;let J=X.type;if(J==="message"){let q=X.role,z=X.content??[];if(q==="user"||q==="developer"){let L=z.filter((k)=>(k.type==="input_text"||k.type==="text")&&typeof k.text==="string"&&k.text.trim()).map((k)=>k.text);if(L.length===0)continue;E();let rr=vn.ascending(),Tr=L.map((k)=>({part:{id:un.ascending(),sessionID:n,messageID:rr,type:"text",text:k},time:K})),Yr={id:rr,sessionID:n,role:"user",agent:"main",time:{created:K},model:{providerID:s.make("openai"),modelID:er.make("unknown")}};if(S.push({info:Yr,parts:Tr}),N=rr,!A)A=p1(L);continue}if(q==="assistant"){let L=Q(K);for(let rr of z)if((rr.type==="output_text"||rr.type==="text")&&typeof rr.text==="string"&&rr.text.trim())L.parts.push({part:{id:un.ascending(),sessionID:n,messageID:L.info.id,type:"text",text:rr.text},time:K});continue}continue}if(J==="reasoning"){let q=Q(K),L=X.summary?.map((rr)=>rr.text??"").join("")??"";if(L.trim())q.parts.push({part:{id:un.ascending(),sessionID:n,messageID:q.info.id,type:"reasoning",text:L,time:{start:K,end:K}},time:K});continue}if(J==="function_call"||J==="custom_tool_call"){let q=Q(K),z=X.call_id??un.ascending(),L=X.name??"unknown",rr=J==="function_call"?C$(X.arguments):{raw:X.input??""},Tr={id:un.ascending(),sessionID:n,messageID:q.info.id,type:"tool",callID:z,tool:L,state:{status:"pending",input:rr,raw:JSON.stringify(rr)}};q.parts.push({part:Tr,time:K}),v.set(z,{part:Tr,start:K});continue}if(J==="function_call_output"||J==="custom_tool_call_output"){let q=X.call_id,z=q?v.get(q):void 0;if(!z)continue;let L=typeof X.output==="string"?X.output:JSON.stringify(X.output??"");z.part.state={status:"completed",input:z.part.state.input??{},output:L,title:z.part.tool,metadata:{},time:{start:z.start,end:K}};continue}}if(E(),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 W$=a1({source:"codex",root:U$.join(Zn.Path.home,".codex","sessions"),pattern:"**/*.jsonl",log:P$,logMessage:"codex import",parse:u1});var qm={};Nr(qm,{run:()=>H$,OpencodeImport:()=>qm,DEFAULT_DB_PATH:()=>Lm});import{access as X$}from"fs/promises";var K$=_.create({service:"opencode-import"}),Lm=(()=>{return`${process.env.XDG_DATA_HOME||`${process.env.HOME||process.env.USERPROFILE}/.local/share`}/opencode/opencode.db`})(),d1=200;async function H$(r){let n=r?.dbPath??Lm,i=t1();if(!await X$(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=e1("opencode",j);if(A&&A.source_mtime===y.time_updated&&!r?.force){i.skipped++;continue}let S=s1("opencode",A);A=S.existing;let v=S.existingUpdated,w=await b1(y.directory),N=Date.now(),E=m.all("SELECT * FROM message WHERE session_id = ? ORDER BY id",y.id);if(E.length===0){i.skipped++;continue}let Q=E.map((H)=>H.id),W=[];for(let H=0;H<Q.length;H+=d1){let X=Q.slice(H,H+d1),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(b.transaction((H)=>{if(f1(H,w,y.time_created,y.time_updated),A)rA(H,A,y.id),nA(H,y.id,{projectId:w.id,directory:y.directory,version:y.version,existingUpdated:v,timeUpdated:y.time_updated});else H.insert(mr).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:mr.id,set:{project_id:w.id,directory:y.directory,time_updated:y.time_updated}}).run();for(let X of E){let K=typeof X.data==="string"?JSON.parse(X.data):X.data;H.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;H.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()}H.insert(Ai).values({source:"opencode",source_key:j,session_id:y.id,source_path:n,source_mtime:y.time_updated,time_imported:N,message_ids:Q}).onConflictDoUpdate({target:[Ai.source,Ai.source_key],set:{source_mtime:y.time_updated,time_imported:N,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)K$.info("opencode import",{...i,errors:i.errors.length});return i}var _m=_.create({service:"external-import"}),pl=["cc","codex","opencode"];async function R$(){let r=(c)=>b.use((l)=>l.select({n:mA()}).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=iA.join(Zn.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){_m.warn("cc scan failed",{error:String(c)})}let m=iA.join(Zn.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){_m.warn("codex scan failed",{error:String(c)})}if(await Bl(Lm).then(()=>!0).catch(()=>!1))try{let c=Jm(Lm);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){_m.warn("opencode scan failed",{error:String(c)})}return n}function xl(){return{scanned:0,imported:0,resynced:0,skipped:0,errors:[]}}async function V$(r){let n=new Set(r?.sources??pl),i={cc:xl(),codex:xl(),opencode:xl()};for(let c of pl){if(!n.has(c))continue;try{if(c==="cc")i.cc=await cA.run({force:r?.force});else if(c==="codex")i.codex=await Om.run({force:r?.force});else i.opencode=await qm.run({force:r?.force})}catch(l){_m.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)_m.info("external import",m);return i}var ic=_.create({service:"server"}),Y$=jn.define("global.disposed",I.object({})),yA=g(()=>{let r=Number(process.env.QITQODE_GLOBAL_EVENT_CONNECT_LIMIT)||60,n=Number(process.env.QITQODE_GLOBAL_EVENT_CONNECT_WINDOW_MS)||60000,i=new Zm(r,n);return new V().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:lA})}).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 Lr.on("event",j),()=>Lr.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:$(cr.Info)}}}}}),async(m)=>{return m.json(await e.runPromise(cr.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:$(cr.Info)}}},...C(400)}}),D("json",cr.Info),async(m)=>{let c=m.req.valid("json"),l=await e.runPromise(cr.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 o.disposeAll(),Lr.emit("event",{directory:"global",payload:{type:Y$.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()})]))}}},...C(400)}}),D("json",I.object({target:I.string().optional()})),async(m)=>{let c=await e.runPromise(al.Service.use((y)=>P.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*P.catch(y.upgrade(j,A).pipe(P.as({success:!0,version:A})),(v)=>P.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 Lr.emit("event",{directory:"global",payload:{type:al.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())})))}}},...C(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 Fi={};Nr(Fi,{websocket:()=>z$,http:()=>F$,ServerProxy:()=>Fi});var Z$=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade","host","authorization"]);function J$(r,n){let i=new Headers(r.headers);for(let m of Z$)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 O$(r){let n=r.headers.get("sec-websocket-protocol");if(!n)return[];return n.split(",").map((i)=>i.trim()).filter(Boolean)}function L$(r){let n=new URL(r);if(n.protocol==="http:")n.protocol="ws:";if(n.protocol==="https:")n.protocol="wss:";return n.toString()}function q$(r,n){if(n instanceof Blob)return n.arrayBuffer().then((i)=>r.send(i));return r.send(n)}var _$=(r)=>new V().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,O$(n.req.raw)),c.binaryType="arraybuffer",c.onopen=()=>{for(let j of m)c?.send(j);m.length=0},c.onmessage=(j)=>{q$(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)}}})),g$=_.Default.clone().tag("service","server-proxy");async function F$(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:J$(i,n),body:i.method==="GET"||i.method==="HEAD"?void 0:i.body,redirect:"manual",signal:i.signal})).then((c)=>{let l=j2(c.headers),y=new Headers(c.headers);return y.delete("content-encoding"),y.delete("content-length"),(l?I2(m,l,i.signal):Promise.resolve()).then(async()=>{return new Response(c.body,{status:c.status,statusText:c.statusText,headers:y})})})}function z$(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",L$(n));for(let[j,A]of new Headers(i).entries())y.set(j,A);return g$.info("proxy websocket",{request:m.url,target:String(n)}),_$(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 M$(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 T$(r){if(r.pathname==="/session/status")return null;let n=r.pathname.match(/^\/session\/([^/]+)(?:\/|$)/)?.[1];if(!n)return null;return br.make(n)}async function h$(r){let n=T$(r);if(!n)return null;return(await e.runPromise(Z.Service.use((m)=>m.get(n)).pipe(P.withSpan("WorkspaceRouter.lookup"))).catch(()=>{return}))?.workspaceID}function jA(r){let n=_.create({service:"workspace-router"});return async(i,m)=>{let c=new URL(i.req.url),y=await h$(c)||c.searchParams.get("workspace");if(!y||c.pathname.startsWith("/console")||p.QITQODE_WORKSPACE_ID)return m();let j=await a.get(qr.make(y));if(!j)return new Response(`Workspace not found: ${y}`,{status:500,headers:{"content-type":"text/plain; charset=utf-8"}});if(M$(i.req.method,c.pathname))return m();let S=await(await Fn(j.projectID,j.type)).target(j);if(S.type==="local")return Di.provide({workspaceID:qr.make(y),fn:()=>o.provide({directory:S.directory,init:()=>e.runPromise(pn),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 Fi.websocket(r,v,S.headers,i.req.raw,i.env);let w=new Headers(i.req.raw.headers);w.delete("x-qitqode-workspace");let N=new Request(i.req.raw,{headers:w});return Fi.http(v,S.headers,N,j.id)}}function ul(r){return async(n,i)=>{let m=n.req.query("directory")||n.req.header("x-qitqode-directory")||process.cwd(),c=IA.resolve((()=>{try{return decodeURIComponent(m)}catch{return m}})());if(!p.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 Di.provide({workspaceID:r,async fn(){return o.provide({directory:c,init:()=>e.runPromise(pn),async fn(){return i()}})}})}}var dl=_.create({service:"server.workspace"}),SA=g(()=>new V().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 AA(o.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)}}},...C(400)}}),D("json",a.create.schema.omit({projectID:!0})),async(r)=>{let n=r.req.valid("json"),i=await a.create({projectID:o.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(o.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(o.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())}}},...C(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)}))}}},...C(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:o.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:c0(m)}),m}}));globalThis.AI_SDK_LOG_WARNINGS=!1;dc();var B$=_.create({service:"server"}),x$=g(()=>tl({}));function k$(r){try{return new URL(r).hostname}catch{return}}function tl(r){let n=new V().onError(hj).use(pj({hostname:r.hostname,mdnsDomain:r.mdnsDomain,allowedHosts:r.cors?.map(k$).filter((m)=>!!m)})).use(kj(r)).use(xj).use(Bj).use(aj).route("/global",yA()),i=oy.create(n);if(p.QITQODE_WORKSPACE_ID)return{app:n.use(ul(p.QITQODE_WORKSPACE_ID?qr.make(p.QITQODE_WORKSPACE_ID):void 0)).use(A2).route("/",hl(i.upgradeWebSocket)),runtime:i};return{app:n.route("/",B1()).route("/",new V().use(ul()).route("/experimental/workspace",SA()).use(jA(i.upgradeWebSocket)).route("/",hl(i.upgradeWebSocket))),runtime:i}}async function p$(){let{app:r}=tl({});return await wc(r,{documentation:{info:{title:"qitqode",version:"1.0.0",description:"qitqode api"},openapi:"3.1.1"}})}var vA;async function a$(r){let i=await tl(r).runtime.listen(r),m=new URL("http://localhost");m.hostname=r.hostname,m.port=String(i.port),vA=m;let c=r.mdns&&i.port&&r.hostname!=="127.0.0.1"&&r.hostname!=="localhost"&&r.hostname!=="::1";if(c)Ei.publish(i.port,r.mdnsDomain);else if(r.mdns)B$.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)Ei.unpublish();await i.stop(y)})(),l}}}
14
+ export{x$ as cg,p$ as dg,vA as eg,a$ as fg,bl as gg};