@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
@@ -1,808 +0,0 @@
1
- // @bun
2
- import{fl as KN,ml as Cl}from"./chunk-bhg69t69.js";import{Al as MA,El as W1,Gl as KX,Hl as aA,Il as $9,Ol as S8,Pl as B0,Rl as T7,rl as L7,tl as l$,ul as xY,vl as AY,wl as I1,xl as w$,yl as I8}from"./chunk-fv5mrdyc.js";import{Ul as xU,Vl as hU,Wl as gw,Yl as uw,_l as L1}from"./chunk-rdreeyv0.js";import{Bm as m0,Dm as O$,Em as wL,Hm as oA,Im as WX,Jm as Yd,Km as k5,Mm as iK,Sm as sA,_m as o6,om as Jd,vm as j8,wm as w1,xm as K9,ym as g6,zm as k9}from"./chunk-rmsqb6r4.js";import{fn as r8,gn as $U,hn as s8,in as Kw}from"./chunk-7pckez5z.js";import{An as Lm,Cn as CA,Dn as bm,En as _m,Jn as JX,jn as Mw,mn as AN,nn as ON,pn as aD,rn as q6,sn as Nm,tn as Em,un as Mm,xn as Dm,yn as wm}from"./chunk-k6981ysw.js";import{Ln as u0,Mn as Jm,Nn as F$,On as tD,Pn as w0}from"./chunk-ydgst3h8.js";import{Qn as Tm}from"./chunk-6tqbnxar.js";import{Rn as d0}from"./chunk-0w19vmd7.js";import{Tn as pL,_n as cL}from"./chunk-eewe7tx1.js";import{$n as k7,Do as vl,Eo as yl,ao as u2,fo as SA,ho as Ol,io as ql}from"./chunk-4y9wbfd2.js";import{$o as uL,Ap as QH,Ip as dL,Ko as xL,Lo as Q8,No as FJ,Oo as HX,So as z4,To as hL,Uo as gL,Vo as aU,Xo as a6,Zo as AX,_o as N4,bp as OX,dp as mL,ep as lL,jp as M4,lp as v8,mp as qX,np as A4,op as y8,qp as G8}from"./chunk-wm9nh9nb.js";import{Jp as p0,Kp as FX,Mp as r6,Op as yZ,Qp as JH,Rp as YH,Tp as XH,Vp as C8,Wp as g5,Xp as rU,Yp as UX}from"./chunk-scnbt714.js";import{fq as mu}from"./chunk-p2fte9vz.js";import{iq as BA,jq as _u}from"./chunk-t3w43rft.js";import{Cq as VO,wq as Ww,yq as AO}from"./chunk-b5ym419d.js";import{Eq as G2}from"./chunk-29q89bge.js";import{$q as h9,Nq as GN,Uq as V$,Vq as PZ,ar as WN}from"./chunk-wqk1v8t0.js";import{Jr as qA,yr as D8}from"./chunk-rwwvy89t.js";import{Kr as n8,Or as f1}from"./chunk-z0kbyr00.js";import{Pr as V00}from"./chunk-sbjymf20.js";import{Wr as Q30}from"./chunk-dt3bsmfe.js";import{bs as j1}from"./chunk-0tm6589k.js";import{ds as F8}from"./chunk-fveaq0pb.js";import{es as E$,is as DN,js as vm,ms as Gl,ns as bK,os as N1,ps as _K,qs as v6,zs as eQ}from"./chunk-gswhjd1h.js";import{Fs as J8,Hs as UY,Is as V6}from"./chunk-wgkcyqn1.js";import{Os as b0,Xs as E0}from"./chunk-59csnjc3.js";import{bt as $4,ct as D$,gt as o0,ht as V4,it as mV,lt as F0}from"./chunk-1bxfzd6r.js";import{mt as P}from"./chunk-6p6m5956.js";import{Kt as D}from"./chunk-a48mx917.js";import{Cy as oV}from"./chunk-w7a33cwa.js";import{$B as y7,AB as S1,BC as Z8,EE as T0,JI as hw,KB as v7,LE as n7,MD as xw,TD as B9,UN as O,YJ as I$,ZE as W4,_D as f6,fH as T,mB as O1,nI as Nw,oE as PY,pC as ul,vH as nV,wI as h6}from"./chunk-g7v6sp3c.js";import{sO as yL}from"./chunk-n6tqtk6h.js";import{tO as m6,uO as S,vO as F1,xO as Y0,yO as CK,zO as EK}from"./chunk-e0vrxetq.js";var R7=S((MO)=>{Object.defineProperty(MO,"__esModule",{value:!0});MO.stringArray=MO.array=MO.func=MO.error=MO.number=MO.string=MO.boolean=void 0;function ed($){return $===!0||$===!1}MO.boolean=ed;function jO($){return typeof $==="string"||$ instanceof String}MO.string=jO;function $p($){return typeof $==="number"||$ instanceof Number}MO.number=$p;function Zp($){return $ instanceof Error}MO.error=Zp;function Jp($){return typeof $==="function"}MO.func=Jp;function NO($){return Array.isArray($)}MO.array=NO;function Yp($){return NO($)&&$.every((Z)=>jO(Z))}MO.stringArray=Yp});var HV=S((cO)=>{Object.defineProperty(cO,"__esModule",{value:!0});cO.Message=cO.NotificationType9=cO.NotificationType8=cO.NotificationType7=cO.NotificationType6=cO.NotificationType5=cO.NotificationType4=cO.NotificationType3=cO.NotificationType2=cO.NotificationType1=cO.NotificationType0=cO.NotificationType=cO.RequestType9=cO.RequestType8=cO.RequestType7=cO.RequestType6=cO.RequestType5=cO.RequestType4=cO.RequestType3=cO.RequestType2=cO.RequestType1=cO.RequestType=cO.RequestType0=cO.AbstractMessageSignature=cO.ParameterStructures=cO.ResponseError=cO.ErrorCodes=void 0;var z5=R7(),VV;(function($){$.ParseError=-32700,$.InvalidRequest=-32600,$.MethodNotFound=-32601,$.InvalidParams=-32602,$.InternalError=-32603,$.jsonrpcReservedErrorRangeStart=-32099,$.serverErrorStart=-32099,$.MessageWriteError=-32099,$.MessageReadError=-32098,$.PendingResponseRejected=-32097,$.ConnectionInactive=-32096,$.ServerNotInitialized=-32002,$.UnknownErrorCode=-32001,$.jsonrpcReservedErrorRangeEnd=-32000,$.serverErrorEnd=-32000})(VV||(cO.ErrorCodes=VV={}));class UV extends Error{constructor($,Z,J){super(Z);this.code=z5.number($)?$:VV.UnknownErrorCode,this.data=J,Object.setPrototypeOf(this,UV.prototype)}toJson(){let $={code:this.code,message:this.message};if(this.data!==void 0)$.data=this.data;return $}}cO.ResponseError=UV;class h${constructor($){this.kind=$}static is($){return $===h$.auto||$===h$.byName||$===h$.byPosition}toString(){return this.kind}}cO.ParameterStructures=h$;h$.auto=new h$("auto");h$.byPosition=new h$("byPosition");h$.byName=new h$("byName");class n1{constructor($,Z){this.method=$,this.numberOfParams=Z}get parameterStructures(){return h$.auto}}cO.AbstractMessageSignature=n1;class LO extends n1{constructor($){super($,0)}}cO.RequestType0=LO;class TO extends n1{constructor($,Z=h$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}cO.RequestType=TO;class RO extends n1{constructor($,Z=h$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}cO.RequestType1=RO;class PO extends n1{constructor($){super($,2)}}cO.RequestType2=PO;class IO extends n1{constructor($){super($,3)}}cO.RequestType3=IO;class CO extends n1{constructor($){super($,4)}}cO.RequestType4=CO;class EO extends n1{constructor($){super($,5)}}cO.RequestType5=EO;class bO extends n1{constructor($){super($,6)}}cO.RequestType6=bO;class _O extends n1{constructor($){super($,7)}}cO.RequestType7=_O;class SO extends n1{constructor($){super($,8)}}cO.RequestType8=SO;class fO extends n1{constructor($){super($,9)}}cO.RequestType9=fO;class kO extends n1{constructor($,Z=h$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}cO.NotificationType=kO;class vO extends n1{constructor($){super($,0)}}cO.NotificationType0=vO;class yO extends n1{constructor($,Z=h$.auto){super($,1);this._parameterStructures=Z}get parameterStructures(){return this._parameterStructures}}cO.NotificationType1=yO;class xO extends n1{constructor($){super($,2)}}cO.NotificationType2=xO;class hO extends n1{constructor($){super($,3)}}cO.NotificationType3=hO;class gO extends n1{constructor($){super($,4)}}cO.NotificationType4=gO;class uO extends n1{constructor($){super($,5)}}cO.NotificationType5=uO;class mO extends n1{constructor($){super($,6)}}cO.NotificationType6=mO;class lO extends n1{constructor($){super($,7)}}cO.NotificationType7=lO;class dO extends n1{constructor($){super($,8)}}cO.NotificationType8=dO;class pO extends n1{constructor($){super($,9)}}cO.NotificationType9=pO;var wO;(function($){function Z(X){let Q=X;return Q&&z5.string(Q.method)&&(z5.string(Q.id)||z5.number(Q.id))}$.isRequest=Z;function J(X){let Q=X;return Q&&z5.string(Q.method)&&X.id===void 0}$.isNotification=J;function Y(X){let Q=X;return Q&&(Q.result!==void 0||!!Q.error)&&(z5.string(Q.id)||z5.number(Q.id)||Q.id===null)}$.isResponse=Y})(wO||(cO.Message=wO={}))});var zV=S((sO)=>{var nO;Object.defineProperty(sO,"__esModule",{value:!0});sO.LRUCache=sO.LinkedMap=sO.Touch=void 0;var g$;(function($){$.None=0,$.First=1,$.AsOld=$.First,$.Last=2,$.AsNew=$.Last})(g$||(sO.Touch=g$={}));class BV{constructor(){this[nO]="LinkedMap",this._map=new Map,this._head=void 0,this._tail=void 0,this._size=0,this._state=0}clear(){this._map.clear(),this._head=void 0,this._tail=void 0,this._size=0,this._state++}isEmpty(){return!this._head&&!this._tail}get size(){return this._size}get first(){return this._head?.value}get last(){return this._tail?.value}has($){return this._map.has($)}get($,Z=g$.None){let J=this._map.get($);if(!J)return;if(Z!==g$.None)this.touch(J,Z);return J.value}set($,Z,J=g$.None){let Y=this._map.get($);if(Y){if(Y.value=Z,J!==g$.None)this.touch(Y,J)}else{switch(Y={key:$,value:Z,next:void 0,previous:void 0},J){case g$.None:this.addItemLast(Y);break;case g$.First:this.addItemFirst(Y);break;case g$.Last:this.addItemLast(Y);break;default:this.addItemLast(Y);break}this._map.set($,Y),this._size++}return this}delete($){return!!this.remove($)}remove($){let Z=this._map.get($);if(!Z)return;return this._map.delete($),this.removeItem(Z),this._size--,Z.value}shift(){if(!this._head&&!this._tail)return;if(!this._head||!this._tail)throw Error("Invalid list");let $=this._head;return this._map.delete($.key),this.removeItem($),this._size--,$.value}forEach($,Z){let J=this._state,Y=this._head;while(Y){if(Z)$.bind(Z)(Y.value,Y.key,this);else $(Y.value,Y.key,this);if(this._state!==J)throw Error("LinkedMap got modified during iteration.");Y=Y.next}}keys(){let $=this._state,Z=this._head,J={[Symbol.iterator]:()=>{return J},next:()=>{if(this._state!==$)throw Error("LinkedMap got modified during iteration.");if(Z){let Y={value:Z.key,done:!1};return Z=Z.next,Y}else return{value:void 0,done:!0}}};return J}values(){let $=this._state,Z=this._head,J={[Symbol.iterator]:()=>{return J},next:()=>{if(this._state!==$)throw Error("LinkedMap got modified during iteration.");if(Z){let Y={value:Z.value,done:!1};return Z=Z.next,Y}else return{value:void 0,done:!0}}};return J}entries(){let $=this._state,Z=this._head,J={[Symbol.iterator]:()=>{return J},next:()=>{if(this._state!==$)throw Error("LinkedMap got modified during iteration.");if(Z){let Y={value:[Z.key,Z.value],done:!1};return Z=Z.next,Y}else return{value:void 0,done:!0}}};return J}[(nO=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}trimOld($){if($>=this.size)return;if($===0){this.clear();return}let Z=this._head,J=this.size;while(Z&&J>$)this._map.delete(Z.key),Z=Z.next,J--;if(this._head=Z,this._size=J,Z)Z.previous=void 0;this._state++}addItemFirst($){if(!this._head&&!this._tail)this._tail=$;else if(!this._head)throw Error("Invalid list");else $.next=this._head,this._head.previous=$;this._head=$,this._state++}addItemLast($){if(!this._head&&!this._tail)this._head=$;else if(!this._tail)throw Error("Invalid list");else $.previous=this._tail,this._tail.next=$;this._tail=$,this._state++}removeItem($){if($===this._head&&$===this._tail)this._head=void 0,this._tail=void 0;else if($===this._head){if(!$.next)throw Error("Invalid list");$.next.previous=void 0,this._head=$.next}else if($===this._tail){if(!$.previous)throw Error("Invalid list");$.previous.next=void 0,this._tail=$.previous}else{let{next:Z,previous:J}=$;if(!Z||!J)throw Error("Invalid list");Z.previous=J,J.next=Z}$.next=void 0,$.previous=void 0,this._state++}touch($,Z){if(!this._head||!this._tail)throw Error("Invalid list");if(Z!==g$.First&&Z!==g$.Last)return;if(Z===g$.First){if($===this._head)return;let{next:J,previous:Y}=$;if($===this._tail)Y.next=void 0,this._tail=Y;else J.previous=Y,Y.next=J;$.previous=void 0,$.next=this._head,this._head.previous=$,this._head=$,this._state++}else if(Z===g$.Last){if($===this._tail)return;let{next:J,previous:Y}=$;if($===this._head)J.previous=void 0,this._head=J;else J.previous=Y,Y.next=J;$.next=void 0,$.previous=this._tail,this._tail.next=$,this._tail=$,this._state++}}toJSON(){let $=[];return this.forEach((Z,J)=>{$.push([J,Z])}),$}fromJSON($){this.clear();for(let[Z,J]of $)this.set(Z,J)}}sO.LinkedMap=BV;class oO extends BV{constructor($,Z=1){super();this._limit=$,this._ratio=Math.min(Math.max(0,Z),1)}get limit(){return this._limit}set limit($){this._limit=$,this.checkTrim()}get ratio(){return this._ratio}set ratio($){this._ratio=Math.min(Math.max(0,$),1),this.checkTrim()}get($,Z=g$.AsNew){return super.get($,Z)}peek($){return super.get($,g$.None)}set($,Z){return super.set($,Z,g$.Last),this.checkTrim(),this}checkTrim(){if(this.size>this._limit)this.trimOld(Math.round(this._limit*this._ratio))}}sO.LRUCache=oO});var $q=S((tO)=>{Object.defineProperty(tO,"__esModule",{value:!0});tO.Disposable=void 0;var aO;(function($){function Z(J){return{dispose:J}}$.create=Z})(aO||(tO.Disposable=aO={}))});var DZ=S((Zq)=>{Object.defineProperty(Zq,"__esModule",{value:!0});var FV;function AV(){if(FV===void 0)throw Error("No runtime abstraction layer installed");return FV}(function($){function Z(J){if(J===void 0)throw Error("No runtime abstraction layer provided");FV=J}$.install=Z})(AV||(AV={}));Zq.default=AV});var P7=S((Xq)=>{Object.defineProperty(Xq,"__esModule",{value:!0});Xq.Emitter=Xq.Event=void 0;var gp=DZ(),Jq;(function($){let Z={dispose(){}};$.None=function(){return Z}})(Jq||(Xq.Event=Jq={}));class Yq{add($,Z=null,J){if(!this._callbacks)this._callbacks=[],this._contexts=[];if(this._callbacks.push($),this._contexts.push(Z),Array.isArray(J))J.push({dispose:()=>this.remove($,Z)})}remove($,Z=null){if(!this._callbacks)return;let J=!1;for(let Y=0,X=this._callbacks.length;Y<X;Y++)if(this._callbacks[Y]===$)if(this._contexts[Y]===Z){this._callbacks.splice(Y,1),this._contexts.splice(Y,1);return}else J=!0;if(J)throw Error("When adding a listener with a context, you should remove it with the same context")}invoke(...$){if(!this._callbacks)return[];let Z=[],J=this._callbacks.slice(0),Y=this._contexts.slice(0);for(let X=0,Q=J.length;X<Q;X++)try{Z.push(J[X].apply(Y[X],$))}catch(G){(0,gp.default)().console.error(G)}return Z}isEmpty(){return!this._callbacks||this._callbacks.length===0}dispose(){this._callbacks=void 0,this._contexts=void 0}}class q9{constructor($){this._options=$}get event(){if(!this._event)this._event=($,Z,J)=>{if(!this._callbacks)this._callbacks=new Yq;if(this._options&&this._options.onFirstListenerAdd&&this._callbacks.isEmpty())this._options.onFirstListenerAdd(this);this._callbacks.add($,Z);let Y={dispose:()=>{if(!this._callbacks)return;if(this._callbacks.remove($,Z),Y.dispose=q9._noop,this._options&&this._options.onLastListenerRemove&&this._callbacks.isEmpty())this._options.onLastListenerRemove(this)}};if(Array.isArray(J))J.push(Y);return Y};return this._event}fire($){if(this._callbacks)this._callbacks.invoke.call(this._callbacks,$)}dispose(){if(this._callbacks)this._callbacks.dispose(),this._callbacks=void 0}}Xq.Emitter=q9;q9._noop=function(){}});var N9=S((Wq)=>{Object.defineProperty(Wq,"__esModule",{value:!0});Wq.CancellationTokenSource=Wq.CancellationToken=void 0;var mp=DZ(),lp=R7(),OV=P7(),j9;(function($){$.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:OV.Event.None}),$.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:OV.Event.None});function Z(J){let Y=J;return Y&&(Y===$.None||Y===$.Cancelled||lp.boolean(Y.isCancellationRequested)&&!!Y.onCancellationRequested)}$.is=Z})(j9||(Wq.CancellationToken=j9={}));var dp=Object.freeze(function($,Z){let J=(0,mp.default)().timer.setTimeout($.bind(Z),0);return{dispose(){J.dispose()}}});class qV{constructor(){this._isCancelled=!1}cancel(){if(!this._isCancelled){if(this._isCancelled=!0,this._emitter)this._emitter.fire(void 0),this.dispose()}}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){if(this._isCancelled)return dp;if(!this._emitter)this._emitter=new OV.Emitter;return this._emitter.event}dispose(){if(this._emitter)this._emitter.dispose(),this._emitter=void 0}}class Gq{get token(){if(!this._token)this._token=new qV;return this._token}cancel(){if(!this._token)this._token=j9.Cancelled;else this._token.cancel()}dispose(){if(!this._token)this._token=j9.None;else if(this._token instanceof qV)this._token.dispose()}}Wq.CancellationTokenSource=Gq});var Aq=S((zq)=>{Object.defineProperty(zq,"__esModule",{value:!0});zq.SharedArrayReceiverStrategy=zq.SharedArraySenderStrategy=void 0;var cp=N9(),bY;(function($){$.Continue=0,$.Cancelled=1})(bY||(bY={}));class Vq{constructor(){this.buffers=new Map}enableCancellation($){if($.id===null)return;let Z=new SharedArrayBuffer(4),J=new Int32Array(Z,0,1);J[0]=bY.Continue,this.buffers.set($.id,Z),$.$cancellationData=Z}async sendCancellation($,Z){let J=this.buffers.get(Z);if(J===void 0)return;let Y=new Int32Array(J,0,1);Atomics.store(Y,0,bY.Cancelled)}cleanup($){this.buffers.delete($)}dispose(){this.buffers.clear()}}zq.SharedArraySenderStrategy=Vq;class Uq{constructor($){this.data=new Int32Array($,0,1)}get isCancellationRequested(){return Atomics.load(this.data,0)===bY.Cancelled}get onCancellationRequested(){throw Error("Cancellation over SharedArrayBuffer doesn't support cancellation events")}}class Hq{constructor($){this.token=new Uq($)}cancel(){}dispose(){}}class Bq{constructor(){this.kind="request"}createCancellationTokenSource($){let Z=$.$cancellationData;if(Z===void 0)return new cp.CancellationTokenSource;return new Hq(Z)}}zq.SharedArrayReceiverStrategy=Bq});var jV=S((qq)=>{Object.defineProperty(qq,"__esModule",{value:!0});qq.Semaphore=void 0;var np=DZ();class Oq{constructor($=1){if($<=0)throw Error("Capacity must be greater than 0");this._capacity=$,this._active=0,this._waiting=[]}lock($){return new Promise((Z,J)=>{this._waiting.push({thunk:$,resolve:Z,reject:J}),this.runNext()})}get active(){return this._active}runNext(){if(this._waiting.length===0||this._active===this._capacity)return;(0,np.default)().timer.setImmediate(()=>this.doRunNext())}doRunNext(){if(this._waiting.length===0||this._active===this._capacity)return;let $=this._waiting.shift();if(this._active++,this._active>this._capacity)throw Error("To many thunks active");try{let Z=$.thunk();if(Z instanceof Promise)Z.then((J)=>{this._active--,$.resolve(J),this.runNext()},(J)=>{this._active--,$.reject(J),this.runNext()});else this._active--,$.resolve(Z),this.runNext()}catch(Z){this._active--,$.reject(Z),this.runNext()}}}qq.Semaphore=Oq});var Lq=S((Dq)=>{Object.defineProperty(Dq,"__esModule",{value:!0});Dq.ReadableStreamMessageReader=Dq.AbstractMessageReader=Dq.MessageReader=void 0;var MV=DZ(),I7=R7(),NV=P7(),op=jV(),Nq;(function($){function Z(J){let Y=J;return Y&&I7.func(Y.listen)&&I7.func(Y.dispose)&&I7.func(Y.onError)&&I7.func(Y.onClose)&&I7.func(Y.onPartialMessage)}$.is=Z})(Nq||(Dq.MessageReader=Nq={}));class wV{constructor(){this.errorEmitter=new NV.Emitter,this.closeEmitter=new NV.Emitter,this.partialMessageEmitter=new NV.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError($){this.errorEmitter.fire(this.asError($))}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}get onPartialMessage(){return this.partialMessageEmitter.event}firePartialMessage($){this.partialMessageEmitter.fire($)}asError($){if($ instanceof Error)return $;else return Error(`Reader received error. Reason: ${I7.string($.message)?$.message:"unknown"}`)}}Dq.AbstractMessageReader=wV;var DV;(function($){function Z(J){let Y,X,Q,G=new Map,W,K=new Map;if(J===void 0||typeof J==="string")Y=J??"utf-8";else{if(Y=J.charset??"utf-8",J.contentDecoder!==void 0)Q=J.contentDecoder,G.set(Q.name,Q);if(J.contentDecoders!==void 0)for(let V of J.contentDecoders)G.set(V.name,V);if(J.contentTypeDecoder!==void 0)W=J.contentTypeDecoder,K.set(W.name,W);if(J.contentTypeDecoders!==void 0)for(let V of J.contentTypeDecoders)K.set(V.name,V)}if(W===void 0)W=(0,MV.default)().applicationJson.decoder,K.set(W.name,W);return{charset:Y,contentDecoder:Q,contentDecoders:G,contentTypeDecoder:W,contentTypeDecoders:K}}$.fromOptions=Z})(DV||(DV={}));class Mq extends wV{constructor($,Z){super();this.readable=$,this.options=DV.fromOptions(Z),this.buffer=(0,MV.default)().messageBuffer.create(this.options.charset),this._partialMessageTimeout=1e4,this.nextMessageLength=-1,this.messageToken=0,this.readSemaphore=new op.Semaphore(1)}set partialMessageTimeout($){this._partialMessageTimeout=$}get partialMessageTimeout(){return this._partialMessageTimeout}listen($){this.nextMessageLength=-1,this.messageToken=0,this.partialMessageTimer=void 0,this.callback=$;let Z=this.readable.onData((J)=>{this.onData(J)});return this.readable.onError((J)=>this.fireError(J)),this.readable.onClose(()=>this.fireClose()),Z}onData($){try{this.buffer.append($);while(!0){if(this.nextMessageLength===-1){let J=this.buffer.tryReadHeaders(!0);if(!J)return;let Y=J.get("content-length");if(!Y){this.fireError(Error(`Header must provide a Content-Length property.
3
- ${JSON.stringify(Object.fromEntries(J))}`));return}let X=parseInt(Y);if(isNaN(X)){this.fireError(Error(`Content-Length value must be a number. Got ${Y}`));return}this.nextMessageLength=X}let Z=this.buffer.tryReadBody(this.nextMessageLength);if(Z===void 0){this.setPartialMessageTimer();return}this.clearPartialMessageTimer(),this.nextMessageLength=-1,this.readSemaphore.lock(async()=>{let J=this.options.contentDecoder!==void 0?await this.options.contentDecoder.decode(Z):Z,Y=await this.options.contentTypeDecoder.decode(J,this.options);this.callback(Y)}).catch((J)=>{this.fireError(J)})}}catch(Z){this.fireError(Z)}}clearPartialMessageTimer(){if(this.partialMessageTimer)this.partialMessageTimer.dispose(),this.partialMessageTimer=void 0}setPartialMessageTimer(){if(this.clearPartialMessageTimer(),this._partialMessageTimeout<=0)return;this.partialMessageTimer=(0,MV.default)().timer.setTimeout(($,Z)=>{if(this.partialMessageTimer=void 0,$===this.messageToken)this.firePartialMessage({messageToken:$,waitingTime:Z}),this.setPartialMessageTimer()},this._partialMessageTimeout,this.messageToken,this._partialMessageTimeout)}}Dq.ReadableStreamMessageReader=Mq});var _q=S((Eq)=>{Object.defineProperty(Eq,"__esModule",{value:!0});Eq.WriteableStreamMessageWriter=Eq.AbstractMessageWriter=Eq.MessageWriter=void 0;var Tq=DZ(),_Y=R7(),ap=jV(),Rq=P7(),tp="Content-Length: ",Pq=`\r
4
- `,Iq;(function($){function Z(J){let Y=J;return Y&&_Y.func(Y.dispose)&&_Y.func(Y.onClose)&&_Y.func(Y.onError)&&_Y.func(Y.write)}$.is=Z})(Iq||(Eq.MessageWriter=Iq={}));class TV{constructor(){this.errorEmitter=new Rq.Emitter,this.closeEmitter=new Rq.Emitter}dispose(){this.errorEmitter.dispose(),this.closeEmitter.dispose()}get onError(){return this.errorEmitter.event}fireError($,Z,J){this.errorEmitter.fire([this.asError($),Z,J])}get onClose(){return this.closeEmitter.event}fireClose(){this.closeEmitter.fire(void 0)}asError($){if($ instanceof Error)return $;else return Error(`Writer received error. Reason: ${_Y.string($.message)?$.message:"unknown"}`)}}Eq.AbstractMessageWriter=TV;var LV;(function($){function Z(J){if(J===void 0||typeof J==="string")return{charset:J??"utf-8",contentTypeEncoder:(0,Tq.default)().applicationJson.encoder};else return{charset:J.charset??"utf-8",contentEncoder:J.contentEncoder,contentTypeEncoder:J.contentTypeEncoder??(0,Tq.default)().applicationJson.encoder}}$.fromOptions=Z})(LV||(LV={}));class Cq extends TV{constructor($,Z){super();this.writable=$,this.options=LV.fromOptions(Z),this.errorCount=0,this.writeSemaphore=new ap.Semaphore(1),this.writable.onError((J)=>this.fireError(J)),this.writable.onClose(()=>this.fireClose())}async write($){return this.writeSemaphore.lock(async()=>{return this.options.contentTypeEncoder.encode($,this.options).then((J)=>{if(this.options.contentEncoder!==void 0)return this.options.contentEncoder.encode(J);else return J}).then((J)=>{let Y=[];return Y.push(tp,J.byteLength.toString(),Pq),Y.push(Pq),this.doWrite($,Y,J)},(J)=>{throw this.fireError(J),J})})}async doWrite($,Z,J){try{return await this.writable.write(Z.join(""),"ascii"),this.writable.write(J)}catch(Y){return this.handleError(Y,$),Promise.reject(Y)}}handleError($,Z){this.errorCount++,this.fireError($,Z,this.errorCount)}end(){this.writable.end()}}Eq.WriteableStreamMessageWriter=Cq});var vq=S((fq)=>{Object.defineProperty(fq,"__esModule",{value:!0});fq.AbstractMessageBuffer=void 0;var Zc=13,Jc=10,Yc=`\r
5
- `;class Sq{constructor($="utf-8"){this._encoding=$,this._chunks=[],this._totalLength=0}get encoding(){return this._encoding}append($){let Z=typeof $==="string"?this.fromString($,this._encoding):$;this._chunks.push(Z),this._totalLength+=Z.byteLength}tryReadHeaders($=!1){if(this._chunks.length===0)return;let Z=0,J=0,Y=0,X=0;$:while(J<this._chunks.length){let K=this._chunks[J];Y=0;Z:while(Y<K.length){switch(K[Y]){case Zc:switch(Z){case 0:Z=1;break;case 2:Z=3;break;default:Z=0}break;case Jc:switch(Z){case 1:Z=2;break;case 3:Z=4,Y++;break $;default:Z=0}break;default:Z=0}Y++}X+=K.byteLength,J++}if(Z!==4)return;let Q=this._read(X+Y),G=new Map,W=this.toString(Q,"ascii").split(Yc);if(W.length<2)return G;for(let K=0;K<W.length-2;K++){let V=W[K],U=V.indexOf(":");if(U===-1)throw Error(`Message header must separate key and value using ':'
6
- ${V}`);let H=V.substr(0,U),B=V.substr(U+1).trim();G.set($?H.toLowerCase():H,B)}return G}tryReadBody($){if(this._totalLength<$)return;return this._read($)}get numberOfBytes(){return this._totalLength}_read($){if($===0)return this.emptyBuffer();if($>this._totalLength)throw Error("Cannot read so many bytes!");if(this._chunks[0].byteLength===$){let X=this._chunks[0];return this._chunks.shift(),this._totalLength-=$,this.asNative(X)}if(this._chunks[0].byteLength>$){let X=this._chunks[0],Q=this.asNative(X,$);return this._chunks[0]=X.slice($),this._totalLength-=$,Q}let Z=this.allocNative($),J=0,Y=0;while($>0){let X=this._chunks[Y];if(X.byteLength>$){let Q=X.slice(0,$);Z.set(Q,J),J+=$,this._chunks[Y]=X.slice($),this._totalLength-=$,$-=$}else Z.set(X,J),J+=X.byteLength,this._chunks.shift(),this._totalLength-=X.byteLength,$-=X.byteLength}return Z}}fq.AbstractMessageBuffer=Sq});var iq=S((mq)=>{Object.defineProperty(mq,"__esModule",{value:!0});mq.createMessageConnection=mq.ConnectionOptions=mq.MessageStrategy=mq.CancellationStrategy=mq.CancellationSenderStrategy=mq.CancellationReceiverStrategy=mq.RequestCancellationReceiverStrategy=mq.IdCancellationReceiverStrategy=mq.ConnectionStrategy=mq.ConnectionError=mq.ConnectionErrors=mq.LogTraceNotification=mq.SetTraceNotification=mq.TraceFormat=mq.TraceValues=mq.Trace=mq.NullLogger=mq.ProgressType=mq.ProgressToken=void 0;var yq=DZ(),t1=R7(),l0=HV(),xq=zV(),SY=P7(),RV=N9(),vY;(function($){$.type=new l0.NotificationType("$/cancelRequest")})(vY||(vY={}));var PV;(function($){function Z(J){return typeof J==="string"||typeof J==="number"}$.is=Z})(PV||(mq.ProgressToken=PV={}));var fY;(function($){$.type=new l0.NotificationType("$/progress")})(fY||(fY={}));class uq{constructor(){}}mq.ProgressType=uq;var IV;(function($){function Z(J){return t1.func(J)}$.is=Z})(IV||(IV={}));mq.NullLogger=Object.freeze({error:()=>{},warn:()=>{},info:()=>{},log:()=>{}});var T1;(function($){$[$.Off=0]="Off",$[$.Messages=1]="Messages",$[$.Compact=2]="Compact",$[$.Verbose=3]="Verbose"})(T1||(mq.Trace=T1={}));var hq;(function($){$.Off="off",$.Messages="messages",$.Compact="compact",$.Verbose="verbose"})(hq||(mq.TraceValues=hq={}));(function($){function Z(Y){if(!t1.string(Y))return $.Off;switch(Y=Y.toLowerCase(),Y){case"off":return $.Off;case"messages":return $.Messages;case"compact":return $.Compact;case"verbose":return $.Verbose;default:return $.Off}}$.fromString=Z;function J(Y){switch(Y){case $.Off:return"off";case $.Messages:return"messages";case $.Compact:return"compact";case $.Verbose:return"verbose";default:return"off"}}$.toString=J})(T1||(mq.Trace=T1={}));var N8;(function($){$.Text="text",$.JSON="json"})(N8||(mq.TraceFormat=N8={}));(function($){function Z(J){if(!t1.string(J))return $.Text;if(J=J.toLowerCase(),J==="json")return $.JSON;else return $.Text}$.fromString=Z})(N8||(mq.TraceFormat=N8={}));var CV;(function($){$.type=new l0.NotificationType("$/setTrace")})(CV||(mq.SetTraceNotification=CV={}));var M9;(function($){$.type=new l0.NotificationType("$/logTrace")})(M9||(mq.LogTraceNotification=M9={}));var kY;(function($){$[$.Closed=1]="Closed",$[$.Disposed=2]="Disposed",$[$.AlreadyListening=3]="AlreadyListening"})(kY||(mq.ConnectionErrors=kY={}));class C7 extends Error{constructor($,Z){super(Z);this.code=$,Object.setPrototypeOf(this,C7.prototype)}}mq.ConnectionError=C7;var EV;(function($){function Z(J){let Y=J;return Y&&t1.func(Y.cancelUndispatched)}$.is=Z})(EV||(mq.ConnectionStrategy=EV={}));var D9;(function($){function Z(J){let Y=J;return Y&&(Y.kind===void 0||Y.kind==="id")&&t1.func(Y.createCancellationTokenSource)&&(Y.dispose===void 0||t1.func(Y.dispose))}$.is=Z})(D9||(mq.IdCancellationReceiverStrategy=D9={}));var bV;(function($){function Z(J){let Y=J;return Y&&Y.kind==="request"&&t1.func(Y.createCancellationTokenSource)&&(Y.dispose===void 0||t1.func(Y.dispose))}$.is=Z})(bV||(mq.RequestCancellationReceiverStrategy=bV={}));var w9;(function($){$.Message=Object.freeze({createCancellationTokenSource(J){return new RV.CancellationTokenSource}});function Z(J){return D9.is(J)||bV.is(J)}$.is=Z})(w9||(mq.CancellationReceiverStrategy=w9={}));var L9;(function($){$.Message=Object.freeze({sendCancellation(J,Y){return J.sendNotification(vY.type,{id:Y})},cleanup(J){}});function Z(J){let Y=J;return Y&&t1.func(Y.sendCancellation)&&t1.func(Y.cleanup)}$.is=Z})(L9||(mq.CancellationSenderStrategy=L9={}));var T9;(function($){$.Message=Object.freeze({receiver:w9.Message,sender:L9.Message});function Z(J){let Y=J;return Y&&w9.is(Y.receiver)&&L9.is(Y.sender)}$.is=Z})(T9||(mq.CancellationStrategy=T9={}));var R9;(function($){function Z(J){let Y=J;return Y&&t1.func(Y.handleMessage)}$.is=Z})(R9||(mq.MessageStrategy=R9={}));var gq;(function($){function Z(J){let Y=J;return Y&&(T9.is(Y.cancellationStrategy)||EV.is(Y.connectionStrategy)||R9.is(Y.messageStrategy))}$.is=Z})(gq||(mq.ConnectionOptions=gq={}));var i8;(function($){$[$.New=1]="New",$[$.Listening=2]="Listening",$[$.Closed=3]="Closed",$[$.Disposed=4]="Disposed"})(i8||(i8={}));function Xc($,Z,J,Y){let X=J!==void 0?J:mq.NullLogger,Q=0,G=0,W=0,K="2.0",V=void 0,U=new Map,H=void 0,B=new Map,z=new Map,F,A=new xq.LinkedMap,j=new Map,N=new Set,L=new Map,q=T1.Off,M=N8.Text,C,R=i8.New,w=new SY.Emitter,I=new SY.Emitter,_=new SY.Emitter,E=new SY.Emitter,f=new SY.Emitter,b=Y&&Y.cancellationStrategy?Y.cancellationStrategy:T9.Message;function y(x){if(x===null)throw Error("Can't send requests with id null since the response can't be correlated.");return"req-"+x.toString()}function k(x){if(x===null)return"res-unknown-"+(++W).toString();else return"res-"+x.toString()}function g(){return"not-"+(++G).toString()}function d(x,i){if(l0.Message.isRequest(i))x.set(y(i.id),i);else if(l0.Message.isResponse(i))x.set(k(i.id),i);else x.set(g(),i)}function p(x){return}function t(){return R===i8.Listening}function r(){return R===i8.Closed}function G0(){return R===i8.Disposed}function O0(){if(R===i8.New||R===i8.Listening)R=i8.Closed,I.fire(void 0)}function h0(x){w.fire([x,void 0,void 0])}function u(x){w.fire(x)}$.onClose(O0),$.onError(h0),Z.onClose(O0),Z.onError(u);function l(){if(F||A.size===0)return;F=(0,yq.default)().timer.setImmediate(()=>{F=void 0,v()})}function $0(x){if(l0.Message.isRequest(x))c(x);else if(l0.Message.isNotification(x))a(x);else if(l0.Message.isResponse(x))m(x);else e(x)}function v(){if(A.size===0)return;let x=A.shift();try{let i=Y?.messageStrategy;if(R9.is(i))i.handleMessage(x,$0);else $0(x)}finally{l()}}let h=(x)=>{try{if(l0.Message.isNotification(x)&&x.method===vY.type.method){let i=x.params.id,n=y(i),J0=A.get(n);if(l0.Message.isRequest(J0)){let M0=Y?.connectionStrategy,D1=M0&&M0.cancelUndispatched?M0.cancelUndispatched(J0,p):p(J0);if(D1&&(D1.error!==void 0||D1.result!==void 0)){A.delete(n),L.delete(i),D1.id=J0.id,s0(D1,x.method,Date.now()),Z.write(D1).catch(()=>X.error("Sending response for canceled message failed."));return}}let C0=L.get(i);if(C0!==void 0){C0.cancel(),K0(x);return}else N.add(i)}d(A,x)}finally{l()}};function c(x){if(G0())return;function i(Z0,v0,V0){let $1={jsonrpc:K,id:x.id};if(Z0 instanceof l0.ResponseError)$1.error=Z0.toJson();else $1.result=Z0===void 0?null:Z0;s0($1,v0,V0),Z.write($1).catch(()=>X.error("Sending response failed."))}function n(Z0,v0,V0){let $1={jsonrpc:K,id:x.id,error:Z0.toJson()};s0($1,v0,V0),Z.write($1).catch(()=>X.error("Sending response failed."))}function J0(Z0,v0,V0){if(Z0===void 0)Z0=null;let $1={jsonrpc:K,id:x.id,result:Z0};s0($1,v0,V0),Z.write($1).catch(()=>X.error("Sending response failed."))}o(x);let C0=U.get(x.method),M0,D1;if(C0)M0=C0.type,D1=C0.handler;let g0=Date.now();if(D1||V){let Z0=x.id??String(Date.now()),v0=D9.is(b.receiver)?b.receiver.createCancellationTokenSource(Z0):b.receiver.createCancellationTokenSource(x);if(x.id!==null&&N.has(x.id))v0.cancel();if(x.id!==null)L.set(Z0,v0);try{let V0;if(D1)if(x.params===void 0){if(M0!==void 0&&M0.numberOfParams!==0){n(new l0.ResponseError(l0.ErrorCodes.InvalidParams,`Request ${x.method} defines ${M0.numberOfParams} params but received none.`),x.method,g0);return}V0=D1(v0.token)}else if(Array.isArray(x.params)){if(M0!==void 0&&M0.parameterStructures===l0.ParameterStructures.byName){n(new l0.ResponseError(l0.ErrorCodes.InvalidParams,`Request ${x.method} defines parameters by name but received parameters by position`),x.method,g0);return}V0=D1(...x.params,v0.token)}else{if(M0!==void 0&&M0.parameterStructures===l0.ParameterStructures.byPosition){n(new l0.ResponseError(l0.ErrorCodes.InvalidParams,`Request ${x.method} defines parameters by position but received parameters by name`),x.method,g0);return}V0=D1(x.params,v0.token)}else if(V)V0=V(x.method,x.params,v0.token);let $1=V0;if(!V0)L.delete(Z0),J0(V0,x.method,g0);else if($1.then)$1.then((D0)=>{L.delete(Z0),i(D0,x.method,g0)},(D0)=>{if(L.delete(Z0),D0 instanceof l0.ResponseError)n(D0,x.method,g0);else if(D0&&t1.string(D0.message))n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${x.method} failed with message: ${D0.message}`),x.method,g0);else n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${x.method} failed unexpectedly without providing any details.`),x.method,g0)});else L.delete(Z0),i(V0,x.method,g0)}catch(V0){if(L.delete(Z0),V0 instanceof l0.ResponseError)i(V0,x.method,g0);else if(V0&&t1.string(V0.message))n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${x.method} failed with message: ${V0.message}`),x.method,g0);else n(new l0.ResponseError(l0.ErrorCodes.InternalError,`Request ${x.method} failed unexpectedly without providing any details.`),x.method,g0)}}else n(new l0.ResponseError(l0.ErrorCodes.MethodNotFound,`Unhandled method ${x.method}`),x.method,g0)}function m(x){if(G0())return;if(x.id===null)if(x.error)X.error(`Received response message without id: Error is:
7
- ${JSON.stringify(x.error,void 0,4)}`);else X.error("Received response message without id. No further error information provided.");else{let i=x.id,n=j.get(i);if(z0(x,n),n!==void 0){j.delete(i);try{if(x.error){let J0=x.error;n.reject(new l0.ResponseError(J0.code,J0.message,J0.data))}else if(x.result!==void 0)n.resolve(x.result);else throw Error("Should never happen.")}catch(J0){if(J0.message)X.error(`Response handler '${n.method}' failed with message: ${J0.message}`);else X.error(`Response handler '${n.method}' failed unexpectedly.`)}}}}function a(x){if(G0())return;let i=void 0,n;if(x.method===vY.type.method){let J0=x.params.id;N.delete(J0),K0(x);return}else{let J0=B.get(x.method);if(J0)n=J0.handler,i=J0.type}if(n||H)try{if(K0(x),n)if(x.params===void 0){if(i!==void 0){if(i.numberOfParams!==0&&i.parameterStructures!==l0.ParameterStructures.byName)X.error(`Notification ${x.method} defines ${i.numberOfParams} params but received none.`)}n()}else if(Array.isArray(x.params)){let J0=x.params;if(x.method===fY.type.method&&J0.length===2&&PV.is(J0[0]))n({token:J0[0],value:J0[1]});else{if(i!==void 0){if(i.parameterStructures===l0.ParameterStructures.byName)X.error(`Notification ${x.method} defines parameters by name but received parameters by position`);if(i.numberOfParams!==x.params.length)X.error(`Notification ${x.method} defines ${i.numberOfParams} params but received ${J0.length} arguments`)}n(...J0)}}else{if(i!==void 0&&i.parameterStructures===l0.ParameterStructures.byPosition)X.error(`Notification ${x.method} defines parameters by position but received parameters by name`);n(x.params)}else if(H)H(x.method,x.params)}catch(J0){if(J0.message)X.error(`Notification handler '${x.method}' failed with message: ${J0.message}`);else X.error(`Notification handler '${x.method}' failed unexpectedly.`)}else _.fire(x)}function e(x){if(!x){X.error("Received empty message.");return}X.error(`Received message which is neither a response nor a notification message:
8
- ${JSON.stringify(x,null,4)}`);let i=x;if(t1.string(i.id)||t1.number(i.id)){let n=i.id,J0=j.get(n);if(J0)J0.reject(Error("The received response has neither a result nor an error property."))}}function H0(x){if(x===void 0||x===null)return;switch(q){case T1.Verbose:return JSON.stringify(x,null,4);case T1.Compact:return JSON.stringify(x);default:return}}function A0(x){if(q===T1.Off||!C)return;if(M===N8.Text){let i=void 0;if((q===T1.Verbose||q===T1.Compact)&&x.params)i=`Params: ${H0(x.params)}
9
-
10
- `;C.log(`Sending request '${x.method} - (${x.id})'.`,i)}else j0("send-request",x)}function P0(x){if(q===T1.Off||!C)return;if(M===N8.Text){let i=void 0;if(q===T1.Verbose||q===T1.Compact)if(x.params)i=`Params: ${H0(x.params)}
11
-
12
- `;else i=`No parameters provided.
13
-
14
- `;C.log(`Sending notification '${x.method}'.`,i)}else j0("send-notification",x)}function s0(x,i,n){if(q===T1.Off||!C)return;if(M===N8.Text){let J0=void 0;if(q===T1.Verbose||q===T1.Compact){if(x.error&&x.error.data)J0=`Error data: ${H0(x.error.data)}
15
-
16
- `;else if(x.result)J0=`Result: ${H0(x.result)}
17
-
18
- `;else if(x.error===void 0)J0=`No result returned.
19
-
20
- `}C.log(`Sending response '${i} - (${x.id})'. Processing request took ${Date.now()-n}ms`,J0)}else j0("send-response",x)}function o(x){if(q===T1.Off||!C)return;if(M===N8.Text){let i=void 0;if((q===T1.Verbose||q===T1.Compact)&&x.params)i=`Params: ${H0(x.params)}
21
-
22
- `;C.log(`Received request '${x.method} - (${x.id})'.`,i)}else j0("receive-request",x)}function K0(x){if(q===T1.Off||!C||x.method===M9.type.method)return;if(M===N8.Text){let i=void 0;if(q===T1.Verbose||q===T1.Compact)if(x.params)i=`Params: ${H0(x.params)}
23
-
24
- `;else i=`No parameters provided.
25
-
26
- `;C.log(`Received notification '${x.method}'.`,i)}else j0("receive-notification",x)}function z0(x,i){if(q===T1.Off||!C)return;if(M===N8.Text){let n=void 0;if(q===T1.Verbose||q===T1.Compact){if(x.error&&x.error.data)n=`Error data: ${H0(x.error.data)}
27
-
28
- `;else if(x.result)n=`Result: ${H0(x.result)}
29
-
30
- `;else if(x.error===void 0)n=`No result returned.
31
-
32
- `}if(i){let J0=x.error?` Request failed: ${x.error.message} (${x.error.code}).`:"";C.log(`Received response '${i.method} - (${x.id})' in ${Date.now()-i.timerStart}ms.${J0}`,n)}else C.log(`Received response ${x.id} without active response promise.`,n)}else j0("receive-response",x)}function j0(x,i){if(!C||q===T1.Off)return;let n={isLSPMessage:!0,type:x,message:i,timestamp:Date.now()};C.log(n)}function Q1(){if(r())throw new C7(kY.Closed,"Connection is closed.");if(G0())throw new C7(kY.Disposed,"Connection is disposed.")}function _0(){if(t())throw new C7(kY.AlreadyListening,"Connection is already listening")}function e0(){if(!t())throw Error("Call listen() first.")}function S0(x){if(x===void 0)return null;else return x}function C1(x){if(x===null)return;else return x}function n0(x){return x!==void 0&&x!==null&&!Array.isArray(x)&&typeof x==="object"}function z1(x,i){switch(x){case l0.ParameterStructures.auto:if(n0(i))return C1(i);else return[S0(i)];case l0.ParameterStructures.byName:if(!n0(i))throw Error("Received parameters by name but param is not an object literal.");return C1(i);case l0.ParameterStructures.byPosition:return[S0(i)];default:throw Error(`Unknown parameter structure ${x.toString()}`)}}function a0(x,i){let n,J0=x.numberOfParams;switch(J0){case 0:n=void 0;break;case 1:n=z1(x.parameterStructures,i[0]);break;default:n=[];for(let C0=0;C0<i.length&&C0<J0;C0++)n.push(S0(i[C0]));if(i.length<J0)for(let C0=i.length;C0<J0;C0++)n.push(null);break}return n}let U1={sendNotification:(x,...i)=>{Q1();let n,J0;if(t1.string(x)){n=x;let M0=i[0],D1=0,g0=l0.ParameterStructures.auto;if(l0.ParameterStructures.is(M0))D1=1,g0=M0;let Z0=i.length,v0=Z0-D1;switch(v0){case 0:J0=void 0;break;case 1:J0=z1(g0,i[D1]);break;default:if(g0===l0.ParameterStructures.byName)throw Error(`Received ${v0} parameters for 'by Name' notification parameter structure.`);J0=i.slice(D1,Z0).map((V0)=>S0(V0));break}}else{let M0=i;n=x.method,J0=a0(x,M0)}let C0={jsonrpc:K,method:n,params:J0};return P0(C0),Z.write(C0).catch((M0)=>{throw X.error("Sending notification failed."),M0})},onNotification:(x,i)=>{Q1();let n;if(t1.func(x))H=x;else if(i)if(t1.string(x))n=x,B.set(x,{type:void 0,handler:i});else n=x.method,B.set(x.method,{type:x,handler:i});return{dispose:()=>{if(n!==void 0)B.delete(n);else H=void 0}}},onProgress:(x,i,n)=>{if(z.has(i))throw Error(`Progress handler for token ${i} already registered`);return z.set(i,n),{dispose:()=>{z.delete(i)}}},sendProgress:(x,i,n)=>{return U1.sendNotification(fY.type,{token:i,value:n})},onUnhandledProgress:E.event,sendRequest:(x,...i)=>{Q1(),e0();let n,J0,C0=void 0;if(t1.string(x)){n=x;let Z0=i[0],v0=i[i.length-1],V0=0,$1=l0.ParameterStructures.auto;if(l0.ParameterStructures.is(Z0))V0=1,$1=Z0;let D0=i.length;if(RV.CancellationToken.is(v0))D0=D0-1,C0=v0;let H1=D0-V0;switch(H1){case 0:J0=void 0;break;case 1:J0=z1($1,i[V0]);break;default:if($1===l0.ParameterStructures.byName)throw Error(`Received ${H1} parameters for 'by Name' request parameter structure.`);J0=i.slice(V0,D0).map((P1)=>S0(P1));break}}else{let Z0=i;n=x.method,J0=a0(x,Z0);let v0=x.numberOfParams;C0=RV.CancellationToken.is(Z0[v0])?Z0[v0]:void 0}let M0=Q++,D1;if(C0)D1=C0.onCancellationRequested(()=>{let Z0=b.sender.sendCancellation(U1,M0);if(Z0===void 0)return X.log(`Received no promise from cancellation strategy when cancelling id ${M0}`),Promise.resolve();else return Z0.catch(()=>{X.log(`Sending cancellation messages for id ${M0} failed`)})});let g0={jsonrpc:K,id:M0,method:n,params:J0};if(A0(g0),typeof b.sender.enableCancellation==="function")b.sender.enableCancellation(g0);return new Promise(async(Z0,v0)=>{let V0=(H1)=>{Z0(H1),b.sender.cleanup(M0),D1?.dispose()},$1=(H1)=>{v0(H1),b.sender.cleanup(M0),D1?.dispose()},D0={method:n,timerStart:Date.now(),resolve:V0,reject:$1};try{j.set(M0,D0),await Z.write(g0)}catch(H1){throw j.delete(M0),D0.reject(new l0.ResponseError(l0.ErrorCodes.MessageWriteError,H1.message?H1.message:"Unknown reason")),X.error("Sending request failed."),H1}})},onRequest:(x,i)=>{Q1();let n=null;if(IV.is(x))n=void 0,V=x;else if(t1.string(x)){if(n=null,i!==void 0)n=x,U.set(x,{handler:i,type:void 0})}else if(i!==void 0)n=x.method,U.set(x.method,{type:x,handler:i});return{dispose:()=>{if(n===null)return;if(n!==void 0)U.delete(n);else V=void 0}}},hasPendingResponse:()=>{return j.size>0},trace:async(x,i,n)=>{let J0=!1,C0=N8.Text;if(n!==void 0)if(t1.boolean(n))J0=n;else J0=n.sendNotification||!1,C0=n.traceFormat||N8.Text;if(q=x,M=C0,q===T1.Off)C=void 0;else C=i;if(J0&&!r()&&!G0())await U1.sendNotification(CV.type,{value:T1.toString(x)})},onError:w.event,onClose:I.event,onUnhandledNotification:_.event,onDispose:f.event,end:()=>{Z.end()},dispose:()=>{if(G0())return;R=i8.Disposed,f.fire(void 0);let x=new l0.ResponseError(l0.ErrorCodes.PendingResponseRejected,"Pending response rejected since connection got disposed");for(let i of j.values())i.reject(x);if(j=new Map,L=new Map,N=new Set,A=new xq.LinkedMap,t1.func(Z.dispose))Z.dispose();if(t1.func($.dispose))$.dispose()},listen:()=>{Q1(),_0(),R=i8.Listening,$.listen(h)},inspect:()=>{(0,yq.default)().console.log("inspect")}};return U1.onNotification(M9.type,(x)=>{if(q===T1.Off||!C)return;let i=q===T1.Verbose||q===T1.Compact;C.log(x.message,i?x.verbose:void 0)}),U1.onNotification(fY.type,(x)=>{let i=z.get(x.token);if(i)i(x.value);else E.fire(x)}),U1}mq.createMessageConnection=Xc});var P9=S((q0)=>{Object.defineProperty(q0,"__esModule",{value:!0});q0.ProgressType=q0.ProgressToken=q0.createMessageConnection=q0.NullLogger=q0.ConnectionOptions=q0.ConnectionStrategy=q0.AbstractMessageBuffer=q0.WriteableStreamMessageWriter=q0.AbstractMessageWriter=q0.MessageWriter=q0.ReadableStreamMessageReader=q0.AbstractMessageReader=q0.MessageReader=q0.SharedArrayReceiverStrategy=q0.SharedArraySenderStrategy=q0.CancellationToken=q0.CancellationTokenSource=q0.Emitter=q0.Event=q0.Disposable=q0.LRUCache=q0.Touch=q0.LinkedMap=q0.ParameterStructures=q0.NotificationType9=q0.NotificationType8=q0.NotificationType7=q0.NotificationType6=q0.NotificationType5=q0.NotificationType4=q0.NotificationType3=q0.NotificationType2=q0.NotificationType1=q0.NotificationType0=q0.NotificationType=q0.ErrorCodes=q0.ResponseError=q0.RequestType9=q0.RequestType8=q0.RequestType7=q0.RequestType6=q0.RequestType5=q0.RequestType4=q0.RequestType3=q0.RequestType2=q0.RequestType1=q0.RequestType0=q0.RequestType=q0.Message=q0.RAL=void 0;q0.MessageStrategy=q0.CancellationStrategy=q0.CancellationSenderStrategy=q0.CancellationReceiverStrategy=q0.ConnectionError=q0.ConnectionErrors=q0.LogTraceNotification=q0.SetTraceNotification=q0.TraceFormat=q0.TraceValues=q0.Trace=void 0;var g1=HV();Object.defineProperty(q0,"Message",{enumerable:!0,get:function(){return g1.Message}});Object.defineProperty(q0,"RequestType",{enumerable:!0,get:function(){return g1.RequestType}});Object.defineProperty(q0,"RequestType0",{enumerable:!0,get:function(){return g1.RequestType0}});Object.defineProperty(q0,"RequestType1",{enumerable:!0,get:function(){return g1.RequestType1}});Object.defineProperty(q0,"RequestType2",{enumerable:!0,get:function(){return g1.RequestType2}});Object.defineProperty(q0,"RequestType3",{enumerable:!0,get:function(){return g1.RequestType3}});Object.defineProperty(q0,"RequestType4",{enumerable:!0,get:function(){return g1.RequestType4}});Object.defineProperty(q0,"RequestType5",{enumerable:!0,get:function(){return g1.RequestType5}});Object.defineProperty(q0,"RequestType6",{enumerable:!0,get:function(){return g1.RequestType6}});Object.defineProperty(q0,"RequestType7",{enumerable:!0,get:function(){return g1.RequestType7}});Object.defineProperty(q0,"RequestType8",{enumerable:!0,get:function(){return g1.RequestType8}});Object.defineProperty(q0,"RequestType9",{enumerable:!0,get:function(){return g1.RequestType9}});Object.defineProperty(q0,"ResponseError",{enumerable:!0,get:function(){return g1.ResponseError}});Object.defineProperty(q0,"ErrorCodes",{enumerable:!0,get:function(){return g1.ErrorCodes}});Object.defineProperty(q0,"NotificationType",{enumerable:!0,get:function(){return g1.NotificationType}});Object.defineProperty(q0,"NotificationType0",{enumerable:!0,get:function(){return g1.NotificationType0}});Object.defineProperty(q0,"NotificationType1",{enumerable:!0,get:function(){return g1.NotificationType1}});Object.defineProperty(q0,"NotificationType2",{enumerable:!0,get:function(){return g1.NotificationType2}});Object.defineProperty(q0,"NotificationType3",{enumerable:!0,get:function(){return g1.NotificationType3}});Object.defineProperty(q0,"NotificationType4",{enumerable:!0,get:function(){return g1.NotificationType4}});Object.defineProperty(q0,"NotificationType5",{enumerable:!0,get:function(){return g1.NotificationType5}});Object.defineProperty(q0,"NotificationType6",{enumerable:!0,get:function(){return g1.NotificationType6}});Object.defineProperty(q0,"NotificationType7",{enumerable:!0,get:function(){return g1.NotificationType7}});Object.defineProperty(q0,"NotificationType8",{enumerable:!0,get:function(){return g1.NotificationType8}});Object.defineProperty(q0,"NotificationType9",{enumerable:!0,get:function(){return g1.NotificationType9}});Object.defineProperty(q0,"ParameterStructures",{enumerable:!0,get:function(){return g1.ParameterStructures}});var _V=zV();Object.defineProperty(q0,"LinkedMap",{enumerable:!0,get:function(){return _V.LinkedMap}});Object.defineProperty(q0,"LRUCache",{enumerable:!0,get:function(){return _V.LRUCache}});Object.defineProperty(q0,"Touch",{enumerable:!0,get:function(){return _V.Touch}});var Mc=$q();Object.defineProperty(q0,"Disposable",{enumerable:!0,get:function(){return Mc.Disposable}});var nq=P7();Object.defineProperty(q0,"Event",{enumerable:!0,get:function(){return nq.Event}});Object.defineProperty(q0,"Emitter",{enumerable:!0,get:function(){return nq.Emitter}});var oq=N9();Object.defineProperty(q0,"CancellationTokenSource",{enumerable:!0,get:function(){return oq.CancellationTokenSource}});Object.defineProperty(q0,"CancellationToken",{enumerable:!0,get:function(){return oq.CancellationToken}});var sq=Aq();Object.defineProperty(q0,"SharedArraySenderStrategy",{enumerable:!0,get:function(){return sq.SharedArraySenderStrategy}});Object.defineProperty(q0,"SharedArrayReceiverStrategy",{enumerable:!0,get:function(){return sq.SharedArrayReceiverStrategy}});var SV=Lq();Object.defineProperty(q0,"MessageReader",{enumerable:!0,get:function(){return SV.MessageReader}});Object.defineProperty(q0,"AbstractMessageReader",{enumerable:!0,get:function(){return SV.AbstractMessageReader}});Object.defineProperty(q0,"ReadableStreamMessageReader",{enumerable:!0,get:function(){return SV.ReadableStreamMessageReader}});var fV=_q();Object.defineProperty(q0,"MessageWriter",{enumerable:!0,get:function(){return fV.MessageWriter}});Object.defineProperty(q0,"AbstractMessageWriter",{enumerable:!0,get:function(){return fV.AbstractMessageWriter}});Object.defineProperty(q0,"WriteableStreamMessageWriter",{enumerable:!0,get:function(){return fV.WriteableStreamMessageWriter}});var Dc=vq();Object.defineProperty(q0,"AbstractMessageBuffer",{enumerable:!0,get:function(){return Dc.AbstractMessageBuffer}});var C$=iq();Object.defineProperty(q0,"ConnectionStrategy",{enumerable:!0,get:function(){return C$.ConnectionStrategy}});Object.defineProperty(q0,"ConnectionOptions",{enumerable:!0,get:function(){return C$.ConnectionOptions}});Object.defineProperty(q0,"NullLogger",{enumerable:!0,get:function(){return C$.NullLogger}});Object.defineProperty(q0,"createMessageConnection",{enumerable:!0,get:function(){return C$.createMessageConnection}});Object.defineProperty(q0,"ProgressToken",{enumerable:!0,get:function(){return C$.ProgressToken}});Object.defineProperty(q0,"ProgressType",{enumerable:!0,get:function(){return C$.ProgressType}});Object.defineProperty(q0,"Trace",{enumerable:!0,get:function(){return C$.Trace}});Object.defineProperty(q0,"TraceValues",{enumerable:!0,get:function(){return C$.TraceValues}});Object.defineProperty(q0,"TraceFormat",{enumerable:!0,get:function(){return C$.TraceFormat}});Object.defineProperty(q0,"SetTraceNotification",{enumerable:!0,get:function(){return C$.SetTraceNotification}});Object.defineProperty(q0,"LogTraceNotification",{enumerable:!0,get:function(){return C$.LogTraceNotification}});Object.defineProperty(q0,"ConnectionErrors",{enumerable:!0,get:function(){return C$.ConnectionErrors}});Object.defineProperty(q0,"ConnectionError",{enumerable:!0,get:function(){return C$.ConnectionError}});Object.defineProperty(q0,"CancellationReceiverStrategy",{enumerable:!0,get:function(){return C$.CancellationReceiverStrategy}});Object.defineProperty(q0,"CancellationSenderStrategy",{enumerable:!0,get:function(){return C$.CancellationSenderStrategy}});Object.defineProperty(q0,"CancellationStrategy",{enumerable:!0,get:function(){return C$.CancellationStrategy}});Object.defineProperty(q0,"MessageStrategy",{enumerable:!0,get:function(){return C$.MessageStrategy}});var wc=DZ();q0.RAL=wc.default});var Zj=S(($j)=>{Object.defineProperty($j,"__esModule",{value:!0});var rq=Y0("util"),u6=P9();class I9 extends u6.AbstractMessageBuffer{constructor($="utf-8"){super($)}emptyBuffer(){return I9.emptyBuffer}fromString($,Z){return Buffer.from($,Z)}toString($,Z){if($ instanceof Buffer)return $.toString(Z);else return new rq.TextDecoder(Z).decode($)}asNative($,Z){if(Z===void 0)return $ instanceof Buffer?$:Buffer.from($);else return $ instanceof Buffer?$.slice(0,Z):Buffer.from($,0,Z)}allocNative($){return Buffer.allocUnsafe($)}}I9.emptyBuffer=Buffer.allocUnsafe(0);class aq{constructor($){this.stream=$}onClose($){return this.stream.on("close",$),u6.Disposable.create(()=>this.stream.off("close",$))}onError($){return this.stream.on("error",$),u6.Disposable.create(()=>this.stream.off("error",$))}onEnd($){return this.stream.on("end",$),u6.Disposable.create(()=>this.stream.off("end",$))}onData($){return this.stream.on("data",$),u6.Disposable.create(()=>this.stream.off("data",$))}}class tq{constructor($){this.stream=$}onClose($){return this.stream.on("close",$),u6.Disposable.create(()=>this.stream.off("close",$))}onError($){return this.stream.on("error",$),u6.Disposable.create(()=>this.stream.off("error",$))}onEnd($){return this.stream.on("end",$),u6.Disposable.create(()=>this.stream.off("end",$))}write($,Z){return new Promise((J,Y)=>{let X=(Q)=>{if(Q===void 0||Q===null)J();else Y(Q)};if(typeof $==="string")this.stream.write($,Z,X);else this.stream.write($,X)})}end(){this.stream.end()}}var eq=Object.freeze({messageBuffer:Object.freeze({create:($)=>new I9($)}),applicationJson:Object.freeze({encoder:Object.freeze({name:"application/json",encode:($,Z)=>{try{return Promise.resolve(Buffer.from(JSON.stringify($,void 0,0),Z.charset))}catch(J){return Promise.reject(J)}}}),decoder:Object.freeze({name:"application/json",decode:($,Z)=>{try{if($ instanceof Buffer)return Promise.resolve(JSON.parse($.toString(Z.charset)));else return Promise.resolve(JSON.parse(new rq.TextDecoder(Z.charset).decode($)))}catch(J){return Promise.reject(J)}}})}),stream:Object.freeze({asReadableStream:($)=>new aq($),asWritableStream:($)=>new tq($)}),console,timer:Object.freeze({setTimeout($,Z,...J){let Y=setTimeout($,Z,...J);return{dispose:()=>clearTimeout(Y)}},setImmediate($,...Z){let J=setImmediate($,...Z);return{dispose:()=>clearImmediate(J)}},setInterval($,Z,...J){let Y=setInterval($,Z,...J);return{dispose:()=>clearInterval(Y)}}})});function kV(){return eq}(function($){function Z(){u6.RAL.install(eq)}$.install=Z})(kV||(kV={}));$j.default=kV});var Kj=S((A1)=>{var Ic=A1&&A1.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;var X=Object.getOwnPropertyDescriptor(Z,J);if(!X||("get"in X?!Z.__esModule:X.writable||X.configurable))X={enumerable:!0,get:function(){return Z[J]}};Object.defineProperty($,Y,X)}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),Cc=A1&&A1.__exportStar||function($,Z){for(var J in $)if(J!=="default"&&!Object.prototype.hasOwnProperty.call(Z,J))Ic(Z,$,J)};Object.defineProperty(A1,"__esModule",{value:!0});A1.createMessageConnection=A1.createServerSocketTransport=A1.createClientSocketTransport=A1.createServerPipeTransport=A1.createClientPipeTransport=A1.generateRandomPipeName=A1.StreamMessageWriter=A1.StreamMessageReader=A1.SocketMessageWriter=A1.SocketMessageReader=A1.PortMessageWriter=A1.PortMessageReader=A1.IPCMessageWriter=A1.IPCMessageReader=void 0;var E7=Zj();E7.default.install();var Jj=Y0("path"),Ec=Y0("os"),bc=Y0("crypto"),C9=Y0("net"),M8=P9();Cc(P9(),A1);class Xj extends M8.AbstractMessageReader{constructor($){super();this.process=$;let Z=this.process;Z.on("error",(J)=>this.fireError(J)),Z.on("close",()=>this.fireClose())}listen($){return this.process.on("message",$),M8.Disposable.create(()=>this.process.off("message",$))}}A1.IPCMessageReader=Xj;class Qj extends M8.AbstractMessageWriter{constructor($){super();this.process=$,this.errorCount=0;let Z=this.process;Z.on("error",(J)=>this.fireError(J)),Z.on("close",()=>this.fireClose)}write($){try{if(typeof this.process.send==="function")this.process.send($,void 0,void 0,(Z)=>{if(Z)this.errorCount++,this.handleError(Z,$);else this.errorCount=0});return Promise.resolve()}catch(Z){return this.handleError(Z,$),Promise.reject(Z)}}handleError($,Z){this.errorCount++,this.fireError($,Z,this.errorCount)}end(){}}A1.IPCMessageWriter=Qj;class Gj extends M8.AbstractMessageReader{constructor($){super();this.onData=new M8.Emitter,$.on("close",()=>this.fireClose),$.on("error",(Z)=>this.fireError(Z)),$.on("message",(Z)=>{this.onData.fire(Z)})}listen($){return this.onData.event($)}}A1.PortMessageReader=Gj;class Wj extends M8.AbstractMessageWriter{constructor($){super();this.port=$,this.errorCount=0,$.on("close",()=>this.fireClose()),$.on("error",(Z)=>this.fireError(Z))}write($){try{return this.port.postMessage($),Promise.resolve()}catch(Z){return this.handleError(Z,$),Promise.reject(Z)}}handleError($,Z){this.errorCount++,this.fireError($,Z,this.errorCount)}end(){}}A1.PortMessageWriter=Wj;class b7 extends M8.ReadableStreamMessageReader{constructor($,Z="utf-8"){super((0,E7.default)().stream.asReadableStream($),Z)}}A1.SocketMessageReader=b7;class _7 extends M8.WriteableStreamMessageWriter{constructor($,Z){super((0,E7.default)().stream.asWritableStream($),Z);this.socket=$}dispose(){super.dispose(),this.socket.destroy()}}A1.SocketMessageWriter=_7;class vV extends M8.ReadableStreamMessageReader{constructor($,Z){super((0,E7.default)().stream.asReadableStream($),Z)}}A1.StreamMessageReader=vV;class yV extends M8.WriteableStreamMessageWriter{constructor($,Z){super((0,E7.default)().stream.asWritableStream($),Z)}}A1.StreamMessageWriter=yV;var Yj=process.env.XDG_RUNTIME_DIR,_c=new Map([["linux",107],["darwin",103]]);function Sc(){let $=(0,bc.randomBytes)(21).toString("hex");if(process.platform==="win32")return`\\\\.\\pipe\\vscode-jsonrpc-${$}-sock`;let Z;if(Yj)Z=Jj.join(Yj,`vscode-ipc-${$}.sock`);else Z=Jj.join(Ec.tmpdir(),`vscode-${$}.sock`);let J=_c.get(process.platform);if(J!==void 0&&Z.length>J)(0,E7.default)().console.warn(`WARNING: IPC handle "${Z}" is longer than ${J} characters.`);return Z}A1.generateRandomPipeName=Sc;function fc($,Z="utf-8"){let J,Y=new Promise((X,Q)=>{J=X});return new Promise((X,Q)=>{let G=(0,C9.createServer)((W)=>{G.close(),J([new b7(W,Z),new _7(W,Z)])});G.on("error",Q),G.listen($,()=>{G.removeListener("error",Q),X({onConnected:()=>{return Y}})})})}A1.createClientPipeTransport=fc;function kc($,Z="utf-8"){let J=(0,C9.createConnection)($);return[new b7(J,Z),new _7(J,Z)]}A1.createServerPipeTransport=kc;function vc($,Z="utf-8"){let J,Y=new Promise((X,Q)=>{J=X});return new Promise((X,Q)=>{let G=(0,C9.createServer)((W)=>{G.close(),J([new b7(W,Z),new _7(W,Z)])});G.on("error",Q),G.listen($,"127.0.0.1",()=>{G.removeListener("error",Q),X({onConnected:()=>{return Y}})})})}A1.createClientSocketTransport=vc;function yc($,Z="utf-8"){let J=(0,C9.createConnection)($,"127.0.0.1");return[new b7(J,Z),new _7(J,Z)]}A1.createServerSocketTransport=yc;function xc($){let Z=$;return Z.read!==void 0&&Z.addListener!==void 0}function hc($){let Z=$;return Z.write!==void 0&&Z.addListener!==void 0}function gc($,Z,J,Y){if(!J)J=M8.NullLogger;let X=xc($)?new vV($):$,Q=hc(Z)?new yV(Z):Z;if(M8.ConnectionStrategy.is(Y))Y={connectionStrategy:Y};return(0,M8.createMessageConnection)(X,Q,J,Y)}A1.createMessageConnection=gc});var cY=S((c20,_N)=>{var qi=Object.prototype.toString;_N.exports=function(Z){if(Z===void 0)return"undefined";if(Z===null)return"null";var J=typeof Z;if(J==="boolean")return"boolean";if(J==="string")return"string";if(J==="number")return"number";if(J==="symbol")return"symbol";if(J==="function")return wi(Z)?"generatorfunction":"function";if(ji(Z))return"array";if(Ri(Z))return"buffer";if(Ti(Z))return"arguments";if(Mi(Z))return"date";if(Ni(Z))return"error";if(Di(Z))return"regexp";switch(bN(Z)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(Li(Z))return"generator";switch(J=qi.call(Z),J){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return J.slice(8,-1).toLowerCase().replace(/\s/g,"")};function bN($){return typeof $.constructor==="function"?$.constructor.name:null}function ji($){if(Array.isArray)return Array.isArray($);return $ instanceof Array}function Ni($){return $ instanceof Error||typeof $.message==="string"&&$.constructor&&typeof $.constructor.stackTraceLimit==="number"}function Mi($){if($ instanceof Date)return!0;return typeof $.toDateString==="function"&&typeof $.getDate==="function"&&typeof $.setDate==="function"}function Di($){if($ instanceof RegExp)return!0;return typeof $.flags==="string"&&typeof $.ignoreCase==="boolean"&&typeof $.multiline==="boolean"&&typeof $.global==="boolean"}function wi($,Z){return bN($)==="GeneratorFunction"}function Li($){return typeof $.throw==="function"&&typeof $.return==="function"&&typeof $.next==="function"}function Ti($){try{if(typeof $.length==="number"&&typeof $.callee==="function")return!0}catch(Z){if(Z.message.indexOf("callee")!==-1)return!0}return!1}function Ri($){if($.constructor&&typeof $.constructor.isBuffer==="function")return $.constructor.isBuffer($);return!1}});var fN=S((i20,SN)=>{/*!
33
- * is-extendable <https://github.com/jonschlinkert/is-extendable>
34
- *
35
- * Copyright (c) 2015, Jon Schlinkert.
36
- * Licensed under the MIT License.
37
- */SN.exports=function(Z){return typeof Z<"u"&&Z!==null&&(typeof Z==="object"||typeof Z==="function")}});var yN=S((n20,vN)=>{var kN=fN();vN.exports=function(Z){if(!kN(Z))Z={};var J=arguments.length;for(var Y=1;Y<J;Y++){var X=arguments[Y];if(kN(X))Pi(Z,X)}return Z};function Pi($,Z){for(var J in Z)if(Ii(Z,J))$[J]=Z[J]}function Ii($,Z){return Object.prototype.hasOwnProperty.call($,Z)}});var gN=S((o20,hN)=>{var Ci=cY(),Ei=yN();hN.exports=function($,Z){if(typeof Z==="function")Z={parse:Z};var J=_i($),Y={section_delimiter:"---",parse:fi},X=Ei({},Y,Z),Q=X.section_delimiter,G=J.content.split(/\r?\n/),W=null,K=xN(),V=[],U=[];function H(N){J.content=N,W=[],V=[]}function B(N){if(U.length)K.key=Si(U[0],Q),K.content=N,X.parse(K,W),W.push(K),K=xN(),V=[],U=[]}for(var z=0;z<G.length;z++){var F=G[z],A=U.length,j=F.trim();if(bi(j,Q)){if(j.length===3&&z!==0){if(A===0||A===2){V.push(F);continue}U.push(j),K.data=V.join(`
38
- `),V=[];continue}if(W===null)H(V.join(`
39
- `));if(A===2)B(V.join(`
40
- `));U.push(j);continue}V.push(F)}if(W===null)H(V.join(`
41
- `));else B(V.join(`
42
- `));return J.sections=W,J};function bi($,Z){if($.slice(0,Z.length)!==Z)return!1;if($.charAt(Z.length+1)===Z.slice(-1))return!1;return!0}function _i($){if(Ci($)!=="object")$={content:$};if(typeof $.content!=="string"&&!ki($.content))throw TypeError("expected a buffer or string");return $.content=$.content.toString(),$.sections=[],$}function Si($,Z){return $?$.slice(Z.length).trim():""}function xN(){return{key:"",data:"",content:""}}function fi($){return $}function ki($){if($&&$.constructor&&typeof $.constructor.isBuffer==="function")return $.constructor.isBuffer($);return!1}});var M5=S((ui,N5)=>{function uN($){return typeof $>"u"||$===null}function vi($){return typeof $==="object"&&$!==null}function yi($){if(Array.isArray($))return $;else if(uN($))return[];return[$]}function xi($,Z){var J,Y,X,Q;if(Z){Q=Object.keys(Z);for(J=0,Y=Q.length;J<Y;J+=1)X=Q[J],$[X]=Z[X]}return $}function hi($,Z){var J="",Y;for(Y=0;Y<Z;Y+=1)J+=$;return J}function gi($){return $===0&&Number.NEGATIVE_INFINITY===1/$}ui.isNothing=uN;ui.isObject=vi;ui.toArray=yi;ui.repeat=hi;ui.isNegativeZero=gi;ui.extend=xi});var r7=S((s20,mN)=>{function iY($,Z){if(Error.call(this),this.name="YAMLException",this.reason=$,this.mark=Z,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor);else this.stack=Error().stack||""}iY.prototype=Object.create(Error.prototype);iY.prototype.constructor=iY;iY.prototype.toString=function(Z){var J=this.name+": ";if(J+=this.reason||"(unknown reason)",!Z&&this.mark)J+=" "+this.mark.toString();return J};mN.exports=iY});var pN=S((r20,dN)=>{var lN=M5();function WU($,Z,J,Y,X){this.name=$,this.buffer=Z,this.position=J,this.line=Y,this.column=X}WU.prototype.getSnippet=function(Z,J){var Y,X,Q,G,W;if(!this.buffer)return null;Z=Z||4,J=J||75,Y="",X=this.position;while(X>0&&`\x00\r
43
- \x85\u2028\u2029`.indexOf(this.buffer.charAt(X-1))===-1)if(X-=1,this.position-X>J/2-1){Y=" ... ",X+=5;break}Q="",G=this.position;while(G<this.buffer.length&&`\x00\r
44
- \x85\u2028\u2029`.indexOf(this.buffer.charAt(G))===-1)if(G+=1,G-this.position>J/2-1){Q=" ... ",G-=5;break}return W=this.buffer.slice(X,G),lN.repeat(" ",Z)+Y+W+Q+`
45
- `+lN.repeat(" ",Z+this.position-X+Y.length)+"^"};WU.prototype.toString=function(Z){var J,Y="";if(this.name)Y+='in "'+this.name+'" ';if(Y+="at line "+(this.line+1)+", column "+(this.column+1),!Z){if(J=this.getSnippet(),J)Y+=`:
46
- `+J}return Y};dN.exports=WU});var A$=S((a20,iN)=>{var cN=r7(),ni=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],oi=["scalar","sequence","mapping"];function si($){var Z={};if($!==null)Object.keys($).forEach(function(J){$[J].forEach(function(Y){Z[String(Y)]=J})});return Z}function ri($,Z){if(Z=Z||{},Object.keys(Z).forEach(function(J){if(ni.indexOf(J)===-1)throw new cN('Unknown option "'+J+'" is met in definition of "'+$+'" YAML type.')}),this.tag=$,this.kind=Z.kind||null,this.resolve=Z.resolve||function(){return!0},this.construct=Z.construct||function(J){return J},this.instanceOf=Z.instanceOf||null,this.predicate=Z.predicate||null,this.represent=Z.represent||null,this.defaultStyle=Z.defaultStyle||null,this.styleAliases=si(Z.styleAliases||null),oi.indexOf(this.kind)===-1)throw new cN('Unknown kind "'+this.kind+'" is specified for "'+$+'" YAML type.')}iN.exports=ri});var D5=S((t20,oN)=>{var nN=M5(),l9=r7(),ai=A$();function KU($,Z,J){var Y=[];return $.include.forEach(function(X){J=KU(X,Z,J)}),$[Z].forEach(function(X){J.forEach(function(Q,G){if(Q.tag===X.tag&&Q.kind===X.kind)Y.push(G)}),J.push(X)}),J.filter(function(X,Q){return Y.indexOf(Q)===-1})}function ti(){var $={scalar:{},sequence:{},mapping:{},fallback:{}},Z,J;function Y(X){$[X.kind][X.tag]=$.fallback[X.tag]=X}for(Z=0,J=arguments.length;Z<J;Z+=1)arguments[Z].forEach(Y);return $}function a7($){this.include=$.include||[],this.implicit=$.implicit||[],this.explicit=$.explicit||[],this.implicit.forEach(function(Z){if(Z.loadKind&&Z.loadKind!=="scalar")throw new l9("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=KU(this,"implicit",[]),this.compiledExplicit=KU(this,"explicit",[]),this.compiledTypeMap=ti(this.compiledImplicit,this.compiledExplicit)}a7.DEFAULT=null;a7.create=function(){var Z,J;switch(arguments.length){case 1:Z=a7.DEFAULT,J=arguments[0];break;case 2:Z=arguments[0],J=arguments[1];break;default:throw new l9("Wrong number of arguments for Schema.create function")}if(Z=nN.toArray(Z),J=nN.toArray(J),!Z.every(function(Y){return Y instanceof a7}))throw new l9("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!J.every(function(Y){return Y instanceof ai}))throw new l9("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new a7({include:Z,explicit:J})};oN.exports=a7});var rN=S((e20,sN)=>{var ei=A$();sN.exports=new ei("tag:yaml.org,2002:str",{kind:"scalar",construct:function($){return $!==null?$:""}})});var tN=S(($R0,aN)=>{var $n=A$();aN.exports=new $n("tag:yaml.org,2002:seq",{kind:"sequence",construct:function($){return $!==null?$:[]}})});var $M=S((ZR0,eN)=>{var Zn=A$();eN.exports=new Zn("tag:yaml.org,2002:map",{kind:"mapping",construct:function($){return $!==null?$:{}}})});var d9=S((JR0,ZM)=>{var Jn=D5();ZM.exports=new Jn({explicit:[rN(),tN(),$M()]})});var YM=S((YR0,JM)=>{var Yn=A$();function Xn($){if($===null)return!0;var Z=$.length;return Z===1&&$==="~"||Z===4&&($==="null"||$==="Null"||$==="NULL")}function Qn(){return null}function Gn($){return $===null}JM.exports=new Yn("tag:yaml.org,2002:null",{kind:"scalar",resolve:Xn,construct:Qn,predicate:Gn,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var QM=S((XR0,XM)=>{var Wn=A$();function Kn($){if($===null)return!1;var Z=$.length;return Z===4&&($==="true"||$==="True"||$==="TRUE")||Z===5&&($==="false"||$==="False"||$==="FALSE")}function Vn($){return $==="true"||$==="True"||$==="TRUE"}function Un($){return Object.prototype.toString.call($)==="[object Boolean]"}XM.exports=new Wn("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Kn,construct:Vn,predicate:Un,represent:{lowercase:function($){return $?"true":"false"},uppercase:function($){return $?"TRUE":"FALSE"},camelcase:function($){return $?"True":"False"}},defaultStyle:"lowercase"})});var WM=S((QR0,GM)=>{var Hn=M5(),Bn=A$();function zn($){return 48<=$&&$<=57||65<=$&&$<=70||97<=$&&$<=102}function Fn($){return 48<=$&&$<=55}function An($){return 48<=$&&$<=57}function On($){if($===null)return!1;var Z=$.length,J=0,Y=!1,X;if(!Z)return!1;if(X=$[J],X==="-"||X==="+")X=$[++J];if(X==="0"){if(J+1===Z)return!0;if(X=$[++J],X==="b"){J++;for(;J<Z;J++){if(X=$[J],X==="_")continue;if(X!=="0"&&X!=="1")return!1;Y=!0}return Y&&X!=="_"}if(X==="x"){J++;for(;J<Z;J++){if(X=$[J],X==="_")continue;if(!zn($.charCodeAt(J)))return!1;Y=!0}return Y&&X!=="_"}for(;J<Z;J++){if(X=$[J],X==="_")continue;if(!Fn($.charCodeAt(J)))return!1;Y=!0}return Y&&X!=="_"}if(X==="_")return!1;for(;J<Z;J++){if(X=$[J],X==="_")continue;if(X===":")break;if(!An($.charCodeAt(J)))return!1;Y=!0}if(!Y||X==="_")return!1;if(X!==":")return!0;return/^(:[0-5]?[0-9])+$/.test($.slice(J))}function qn($){var Z=$,J=1,Y,X,Q=[];if(Z.indexOf("_")!==-1)Z=Z.replace(/_/g,"");if(Y=Z[0],Y==="-"||Y==="+"){if(Y==="-")J=-1;Z=Z.slice(1),Y=Z[0]}if(Z==="0")return 0;if(Y==="0"){if(Z[1]==="b")return J*parseInt(Z.slice(2),2);if(Z[1]==="x")return J*parseInt(Z,16);return J*parseInt(Z,8)}if(Z.indexOf(":")!==-1)return Z.split(":").forEach(function(G){Q.unshift(parseInt(G,10))}),Z=0,X=1,Q.forEach(function(G){Z+=G*X,X*=60}),J*Z;return J*parseInt(Z,10)}function jn($){return Object.prototype.toString.call($)==="[object Number]"&&($%1===0&&!Hn.isNegativeZero($))}GM.exports=new Bn("tag:yaml.org,2002:int",{kind:"scalar",resolve:On,construct:qn,predicate:jn,represent:{binary:function($){return $>=0?"0b"+$.toString(2):"-0b"+$.toString(2).slice(1)},octal:function($){return $>=0?"0"+$.toString(8):"-0"+$.toString(8).slice(1)},decimal:function($){return $.toString(10)},hexadecimal:function($){return $>=0?"0x"+$.toString(16).toUpperCase():"-0x"+$.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var UM=S((GR0,VM)=>{var KM=M5(),Nn=A$(),Mn=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Dn($){if($===null)return!1;if(!Mn.test($)||$[$.length-1]==="_")return!1;return!0}function wn($){var Z,J,Y,X;if(Z=$.replace(/_/g,"").toLowerCase(),J=Z[0]==="-"?-1:1,X=[],"+-".indexOf(Z[0])>=0)Z=Z.slice(1);if(Z===".inf")return J===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;else if(Z===".nan")return NaN;else if(Z.indexOf(":")>=0)return Z.split(":").forEach(function(Q){X.unshift(parseFloat(Q,10))}),Z=0,Y=1,X.forEach(function(Q){Z+=Q*Y,Y*=60}),J*Z;return J*parseFloat(Z,10)}var Ln=/^[-+]?[0-9]+e/;function Tn($,Z){var J;if(isNaN($))switch(Z){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===$)switch(Z){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===$)switch(Z){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(KM.isNegativeZero($))return"-0.0";return J=$.toString(10),Ln.test(J)?J.replace("e",".e"):J}function Rn($){return Object.prototype.toString.call($)==="[object Number]"&&($%1!==0||KM.isNegativeZero($))}VM.exports=new Nn("tag:yaml.org,2002:float",{kind:"scalar",resolve:Dn,construct:wn,predicate:Rn,represent:Tn,defaultStyle:"lowercase"})});var VU=S((WR0,HM)=>{var Pn=D5();HM.exports=new Pn({include:[d9()],implicit:[YM(),QM(),WM(),UM()]})});var UU=S((KR0,BM)=>{var In=D5();BM.exports=new In({include:[VU()]})});var OM=S((VR0,AM)=>{var Cn=A$(),zM=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),FM=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function En($){if($===null)return!1;if(zM.exec($)!==null)return!0;if(FM.exec($)!==null)return!0;return!1}function bn($){var Z,J,Y,X,Q,G,W,K=0,V=null,U,H,B;if(Z=zM.exec($),Z===null)Z=FM.exec($);if(Z===null)throw Error("Date resolve error");if(J=+Z[1],Y=+Z[2]-1,X=+Z[3],!Z[4])return new Date(Date.UTC(J,Y,X));if(Q=+Z[4],G=+Z[5],W=+Z[6],Z[7]){K=Z[7].slice(0,3);while(K.length<3)K+="0";K=+K}if(Z[9]){if(U=+Z[10],H=+(Z[11]||0),V=(U*60+H)*60000,Z[9]==="-")V=-V}if(B=new Date(Date.UTC(J,Y,X,Q,G,W,K)),V)B.setTime(B.getTime()-V);return B}function _n($){return $.toISOString()}AM.exports=new Cn("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:En,construct:bn,instanceOf:Date,represent:_n})});var jM=S((UR0,qM)=>{var Sn=A$();function fn($){return $==="<<"||$===null}qM.exports=new Sn("tag:yaml.org,2002:merge",{kind:"scalar",resolve:fn})});var MM=S((HR0,NM)=>{var w5;try{HU=Y0,w5=HU("buffer").Buffer}catch($){}var HU,kn=A$(),BU=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
47
- \r`;function vn($){if($===null)return!1;var Z,J,Y=0,X=$.length,Q=BU;for(J=0;J<X;J++){if(Z=Q.indexOf($.charAt(J)),Z>64)continue;if(Z<0)return!1;Y+=6}return Y%8===0}function yn($){var Z,J,Y=$.replace(/[\r\n=]/g,""),X=Y.length,Q=BU,G=0,W=[];for(Z=0;Z<X;Z++){if(Z%4===0&&Z)W.push(G>>16&255),W.push(G>>8&255),W.push(G&255);G=G<<6|Q.indexOf(Y.charAt(Z))}if(J=X%4*6,J===0)W.push(G>>16&255),W.push(G>>8&255),W.push(G&255);else if(J===18)W.push(G>>10&255),W.push(G>>2&255);else if(J===12)W.push(G>>4&255);if(w5)return w5.from?w5.from(W):new w5(W);return W}function xn($){var Z="",J=0,Y,X,Q=$.length,G=BU;for(Y=0;Y<Q;Y++){if(Y%3===0&&Y)Z+=G[J>>18&63],Z+=G[J>>12&63],Z+=G[J>>6&63],Z+=G[J&63];J=(J<<8)+$[Y]}if(X=Q%3,X===0)Z+=G[J>>18&63],Z+=G[J>>12&63],Z+=G[J>>6&63],Z+=G[J&63];else if(X===2)Z+=G[J>>10&63],Z+=G[J>>4&63],Z+=G[J<<2&63],Z+=G[64];else if(X===1)Z+=G[J>>2&63],Z+=G[J<<4&63],Z+=G[64],Z+=G[64];return Z}function hn($){return w5&&w5.isBuffer($)}NM.exports=new kn("tag:yaml.org,2002:binary",{kind:"scalar",resolve:vn,construct:yn,predicate:hn,represent:xn})});var wM=S((zR0,DM)=>{var gn=A$(),un=Object.prototype.hasOwnProperty,mn=Object.prototype.toString;function ln($){if($===null)return!0;var Z=[],J,Y,X,Q,G,W=$;for(J=0,Y=W.length;J<Y;J+=1){if(X=W[J],G=!1,mn.call(X)!=="[object Object]")return!1;for(Q in X)if(un.call(X,Q))if(!G)G=!0;else return!1;if(!G)return!1;if(Z.indexOf(Q)===-1)Z.push(Q);else return!1}return!0}function dn($){return $!==null?$:[]}DM.exports=new gn("tag:yaml.org,2002:omap",{kind:"sequence",resolve:ln,construct:dn})});var TM=S((FR0,LM)=>{var pn=A$(),cn=Object.prototype.toString;function nn($){if($===null)return!0;var Z,J,Y,X,Q,G=$;Q=Array(G.length);for(Z=0,J=G.length;Z<J;Z+=1){if(Y=G[Z],cn.call(Y)!=="[object Object]")return!1;if(X=Object.keys(Y),X.length!==1)return!1;Q[Z]=[X[0],Y[X[0]]]}return!0}function on($){if($===null)return[];var Z,J,Y,X,Q,G=$;Q=Array(G.length);for(Z=0,J=G.length;Z<J;Z+=1)Y=G[Z],X=Object.keys(Y),Q[Z]=[X[0],Y[X[0]]];return Q}LM.exports=new pn("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:nn,construct:on})});var PM=S((AR0,RM)=>{var sn=A$(),rn=Object.prototype.hasOwnProperty;function an($){if($===null)return!0;var Z,J=$;for(Z in J)if(rn.call(J,Z)){if(J[Z]!==null)return!1}return!0}function tn($){return $!==null?$:{}}RM.exports=new sn("tag:yaml.org,2002:set",{kind:"mapping",resolve:an,construct:tn})});var t7=S((OR0,IM)=>{var en=D5();IM.exports=new en({include:[UU()],implicit:[OM(),jM()],explicit:[MM(),wM(),TM(),PM()]})});var EM=S((qR0,CM)=>{var $o=A$();function Zo(){return!0}function Jo(){return}function Yo(){return""}function Xo($){return typeof $>"u"}CM.exports=new $o("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:Zo,construct:Jo,predicate:Xo,represent:Yo})});var _M=S((jR0,bM)=>{var Qo=A$();function Go($){if($===null)return!1;if($.length===0)return!1;var Z=$,J=/\/([gim]*)$/.exec($),Y="";if(Z[0]==="/"){if(J)Y=J[1];if(Y.length>3)return!1;if(Z[Z.length-Y.length-1]!=="/")return!1}return!0}function Wo($){var Z=$,J=/\/([gim]*)$/.exec($),Y="";if(Z[0]==="/"){if(J)Y=J[1];Z=Z.slice(1,Z.length-Y.length-1)}return new RegExp(Z,Y)}function Ko($){var Z="/"+$.source+"/";if($.global)Z+="g";if($.multiline)Z+="m";if($.ignoreCase)Z+="i";return Z}function Vo($){return Object.prototype.toString.call($)==="[object RegExp]"}bM.exports=new Qo("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:Go,construct:Wo,predicate:Vo,represent:Ko})});var fM=S((NR0,SM)=>{var p9;try{zU=Y0,p9=zU("esprima")}catch($){if(typeof window<"u")p9=window.esprima}var zU,Uo=A$();function Ho($){if($===null)return!1;try{var Z="("+$+")",J=p9.parse(Z,{range:!0});if(J.type!=="Program"||J.body.length!==1||J.body[0].type!=="ExpressionStatement"||J.body[0].expression.type!=="ArrowFunctionExpression"&&J.body[0].expression.type!=="FunctionExpression")return!1;return!0}catch(Y){return!1}}function Bo($){var Z="("+$+")",J=p9.parse(Z,{range:!0}),Y=[],X;if(J.type!=="Program"||J.body.length!==1||J.body[0].type!=="ExpressionStatement"||J.body[0].expression.type!=="ArrowFunctionExpression"&&J.body[0].expression.type!=="FunctionExpression")throw Error("Failed to resolve function");if(J.body[0].expression.params.forEach(function(Q){Y.push(Q.name)}),X=J.body[0].expression.body.range,J.body[0].expression.body.type==="BlockStatement")return Function(Y,Z.slice(X[0]+1,X[1]-1));return Function(Y,"return "+Z.slice(X[0],X[1]))}function zo($){return $.toString()}function Fo($){return Object.prototype.toString.call($)==="[object Function]"}SM.exports=new Uo("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:Ho,construct:Bo,predicate:Fo,represent:zo})});var nY=S((DR0,vM)=>{var kM=D5();vM.exports=kM.DEFAULT=new kM({include:[t7()],explicit:[EM(),_M(),fM()]})});var ZD=S((ho,oY)=>{var d6=M5(),lM=r7(),Ao=pN(),dM=t7(),Oo=nY(),bZ=Object.prototype.hasOwnProperty,c9=1,pM=2,cM=3,i9=4,FU=1,qo=2,yM=3,jo=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,No=/[\x85\u2028\u2029]/,Mo=/[,\[\]\{\}]/,iM=/^(?:!|!!|![a-z\-]+!)$/i,nM=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function xM($){return Object.prototype.toString.call($)}function w6($){return $===10||$===13}function L5($){return $===9||$===32}function Y8($){return $===9||$===32||$===10||$===13}function e7($){return $===44||$===91||$===93||$===123||$===125}function Do($){var Z;if(48<=$&&$<=57)return $-48;if(Z=$|32,97<=Z&&Z<=102)return Z-97+10;return-1}function wo($){if($===120)return 2;if($===117)return 4;if($===85)return 8;return 0}function Lo($){if(48<=$&&$<=57)return $-48;return-1}function hM($){return $===48?"\x00":$===97?"\x07":$===98?"\b":$===116?"\t":$===9?"\t":$===110?`
48
- `:$===118?"\v":$===102?"\f":$===114?"\r":$===101?"\x1B":$===32?" ":$===34?'"':$===47?"/":$===92?"\\":$===78?"\x85":$===95?"\xA0":$===76?"\u2028":$===80?"\u2029":""}function To($){if($<=65535)return String.fromCharCode($);return String.fromCharCode(($-65536>>10)+55296,($-65536&1023)+56320)}function oM($,Z,J){if(Z==="__proto__")Object.defineProperty($,Z,{configurable:!0,enumerable:!0,writable:!0,value:J});else $[Z]=J}var sM=Array(256),rM=Array(256);for(CZ=0;CZ<256;CZ++)sM[CZ]=hM(CZ)?1:0,rM[CZ]=hM(CZ);var CZ;function Ro($,Z){this.input=$,this.filename=Z.filename||null,this.schema=Z.schema||Oo,this.onWarning=Z.onWarning||null,this.legacy=Z.legacy||!1,this.json=Z.json||!1,this.listener=Z.listener||null,this.maxTotalMergeKeys=typeof Z.maxTotalMergeKeys==="number"?Z.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=$.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.totalMergeKeys=0,this.documents=[]}function aM($,Z){return new lM(Z,new Ao($.filename,$.input,$.position,$.line,$.position-$.lineStart))}function f0($,Z){throw aM($,Z)}function n9($,Z){if($.onWarning)$.onWarning.call(null,aM($,Z))}var gM={YAML:function(Z,J,Y){var X,Q,G;if(Z.version!==null)f0(Z,"duplication of %YAML directive");if(Y.length!==1)f0(Z,"YAML directive accepts exactly one argument");if(X=/^([0-9]+)\.([0-9]+)$/.exec(Y[0]),X===null)f0(Z,"ill-formed argument of the YAML directive");if(Q=parseInt(X[1],10),G=parseInt(X[2],10),Q!==1)f0(Z,"unacceptable YAML version of the document");if(Z.version=Y[0],Z.checkLineBreaks=G<2,G!==1&&G!==2)n9(Z,"unsupported YAML version of the document")},TAG:function(Z,J,Y){var X,Q;if(Y.length!==2)f0(Z,"TAG directive accepts exactly two arguments");if(X=Y[0],Q=Y[1],!iM.test(X))f0(Z,"ill-formed tag handle (first argument) of the TAG directive");if(bZ.call(Z.tagMap,X))f0(Z,'there is a previously declared suffix for "'+X+'" tag handle');if(!nM.test(Q))f0(Z,"ill-formed tag prefix (second argument) of the TAG directive");Z.tagMap[X]=Q}};function EZ($,Z,J,Y){var X,Q,G,W;if(Z<J){if(W=$.input.slice(Z,J),Y){for(X=0,Q=W.length;X<Q;X+=1)if(G=W.charCodeAt(X),!(G===9||32<=G&&G<=1114111))f0($,"expected valid JSON character")}else if(jo.test(W))f0($,"the stream contains non-printable characters");$.result+=W}}function uM($,Z,J,Y){var X,Q,G,W;if(!d6.isObject(J))f0($,"cannot merge mappings; the provided source object is unacceptable");X=Object.keys(J);for(G=0,W=X.length;G<W;G+=1){if(Q=X[G],$.maxTotalMergeKeys!==-1&&++$.totalMergeKeys>$.maxTotalMergeKeys)f0($,"merge keys exceeded maxTotalMergeKeys ("+$.maxTotalMergeKeys+")");if(!bZ.call(Z,Q))oM(Z,Q,J[Q]),Y[Q]=!0}}function $J($,Z,J,Y,X,Q,G,W){var K,V;if(Array.isArray(X)){X=Array.prototype.slice.call(X);for(K=0,V=X.length;K<V;K+=1){if(Array.isArray(X[K]))f0($,"nested arrays are not supported inside keys");if(typeof X==="object"&&xM(X[K])==="[object Object]")X[K]="[object Object]"}}if(typeof X==="object"&&xM(X)==="[object Object]")X="[object Object]";if(X=String(X),Z===null)Z={};if(Y==="tag:yaml.org,2002:merge")if(Array.isArray(Q))for(K=0,V=Q.length;K<V;K+=1)uM($,Z,Q[K],J);else uM($,Z,Q,J);else{if(!$.json&&!bZ.call(J,X)&&bZ.call(Z,X))$.line=G||$.line,$.position=W||$.position,f0($,"duplicated mapping key");oM(Z,X,Q),delete J[X]}return Z}function AU($){var Z=$.input.charCodeAt($.position);if(Z===10)$.position++;else if(Z===13){if($.position++,$.input.charCodeAt($.position)===10)$.position++}else f0($,"a line break is expected");$.line+=1,$.lineStart=$.position}function U$($,Z,J){var Y=0,X=$.input.charCodeAt($.position);while(X!==0){while(L5(X))X=$.input.charCodeAt(++$.position);if(Z&&X===35)do X=$.input.charCodeAt(++$.position);while(X!==10&&X!==13&&X!==0);if(w6(X)){AU($),X=$.input.charCodeAt($.position),Y++,$.lineIndent=0;while(X===32)$.lineIndent++,X=$.input.charCodeAt(++$.position)}else break}if(J!==-1&&Y!==0&&$.lineIndent<J)n9($,"deficient indentation");return Y}function o9($){var Z=$.position,J;if(J=$.input.charCodeAt(Z),(J===45||J===46)&&J===$.input.charCodeAt(Z+1)&&J===$.input.charCodeAt(Z+2)){if(Z+=3,J=$.input.charCodeAt(Z),J===0||Y8(J))return!0}return!1}function OU($,Z){if(Z===1)$.result+=" ";else if(Z>1)$.result+=d6.repeat(`
49
- `,Z-1)}function Po($,Z,J){var Y,X,Q,G,W,K,V,U,H=$.kind,B=$.result,z;if(z=$.input.charCodeAt($.position),Y8(z)||e7(z)||z===35||z===38||z===42||z===33||z===124||z===62||z===39||z===34||z===37||z===64||z===96)return!1;if(z===63||z===45){if(X=$.input.charCodeAt($.position+1),Y8(X)||J&&e7(X))return!1}$.kind="scalar",$.result="",Q=G=$.position,W=!1;while(z!==0){if(z===58){if(X=$.input.charCodeAt($.position+1),Y8(X)||J&&e7(X))break}else if(z===35){if(Y=$.input.charCodeAt($.position-1),Y8(Y))break}else if($.position===$.lineStart&&o9($)||J&&e7(z))break;else if(w6(z))if(K=$.line,V=$.lineStart,U=$.lineIndent,U$($,!1,-1),$.lineIndent>=Z){W=!0,z=$.input.charCodeAt($.position);continue}else{$.position=G,$.line=K,$.lineStart=V,$.lineIndent=U;break}if(W)EZ($,Q,G,!1),OU($,$.line-K),Q=G=$.position,W=!1;if(!L5(z))G=$.position+1;z=$.input.charCodeAt(++$.position)}if(EZ($,Q,G,!1),$.result)return!0;return $.kind=H,$.result=B,!1}function Io($,Z){var J,Y,X;if(J=$.input.charCodeAt($.position),J!==39)return!1;$.kind="scalar",$.result="",$.position++,Y=X=$.position;while((J=$.input.charCodeAt($.position))!==0)if(J===39)if(EZ($,Y,$.position,!0),J=$.input.charCodeAt(++$.position),J===39)Y=$.position,$.position++,X=$.position;else return!0;else if(w6(J))EZ($,Y,X,!0),OU($,U$($,!1,Z)),Y=X=$.position;else if($.position===$.lineStart&&o9($))f0($,"unexpected end of the document within a single quoted scalar");else $.position++,X=$.position;f0($,"unexpected end of the stream within a single quoted scalar")}function Co($,Z){var J,Y,X,Q,G,W;if(W=$.input.charCodeAt($.position),W!==34)return!1;$.kind="scalar",$.result="",$.position++,J=Y=$.position;while((W=$.input.charCodeAt($.position))!==0)if(W===34)return EZ($,J,$.position,!0),$.position++,!0;else if(W===92){if(EZ($,J,$.position,!0),W=$.input.charCodeAt(++$.position),w6(W))U$($,!1,Z);else if(W<256&&sM[W])$.result+=rM[W],$.position++;else if((G=wo(W))>0){X=G,Q=0;for(;X>0;X--)if(W=$.input.charCodeAt(++$.position),(G=Do(W))>=0)Q=(Q<<4)+G;else f0($,"expected hexadecimal character");$.result+=To(Q),$.position++}else f0($,"unknown escape sequence");J=Y=$.position}else if(w6(W))EZ($,J,Y,!0),OU($,U$($,!1,Z)),J=Y=$.position;else if($.position===$.lineStart&&o9($))f0($,"unexpected end of the document within a double quoted scalar");else $.position++,Y=$.position;f0($,"unexpected end of the stream within a double quoted scalar")}function Eo($,Z){var J=!0,Y,X=$.tag,Q,G=$.anchor,W,K,V,U,H,B={},z,F,A,j;if(j=$.input.charCodeAt($.position),j===91)K=93,H=!1,Q=[];else if(j===123)K=125,H=!0,Q={};else return!1;if($.anchor!==null)$.anchorMap[$.anchor]=Q;j=$.input.charCodeAt(++$.position);while(j!==0){if(U$($,!0,Z),j=$.input.charCodeAt($.position),j===K)return $.position++,$.tag=X,$.anchor=G,$.kind=H?"mapping":"sequence",$.result=Q,!0;else if(!J)f0($,"missed comma between flow collection entries");if(F=z=A=null,V=U=!1,j===63){if(W=$.input.charCodeAt($.position+1),Y8(W))V=U=!0,$.position++,U$($,!0,Z)}if(Y=$.line,ZJ($,Z,c9,!1,!0),F=$.tag,z=$.result,U$($,!0,Z),j=$.input.charCodeAt($.position),(U||$.line===Y)&&j===58)V=!0,j=$.input.charCodeAt(++$.position),U$($,!0,Z),ZJ($,Z,c9,!1,!0),A=$.result;if(H)$J($,Q,B,F,z,A);else if(V)Q.push($J($,null,B,F,z,A));else Q.push(z);if(U$($,!0,Z),j=$.input.charCodeAt($.position),j===44)J=!0,j=$.input.charCodeAt(++$.position);else J=!1}f0($,"unexpected end of the stream within a flow collection")}function bo($,Z){var J,Y,X=FU,Q=!1,G=!1,W=Z,K=0,V=!1,U,H;if(H=$.input.charCodeAt($.position),H===124)Y=!1;else if(H===62)Y=!0;else return!1;$.kind="scalar",$.result="";while(H!==0)if(H=$.input.charCodeAt(++$.position),H===43||H===45)if(FU===X)X=H===43?yM:qo;else f0($,"repeat of a chomping mode identifier");else if((U=Lo(H))>=0)if(U===0)f0($,"bad explicit indentation width of a block scalar; it cannot be less than one");else if(!G)W=Z+U-1,G=!0;else f0($,"repeat of an indentation width identifier");else break;if(L5(H)){do H=$.input.charCodeAt(++$.position);while(L5(H));if(H===35)do H=$.input.charCodeAt(++$.position);while(!w6(H)&&H!==0)}while(H!==0){AU($),$.lineIndent=0,H=$.input.charCodeAt($.position);while((!G||$.lineIndent<W)&&H===32)$.lineIndent++,H=$.input.charCodeAt(++$.position);if(!G&&$.lineIndent>W)W=$.lineIndent;if(w6(H)){K++;continue}if($.lineIndent<W){if(X===yM)$.result+=d6.repeat(`
50
- `,Q?1+K:K);else if(X===FU){if(Q)$.result+=`
51
- `}break}if(Y)if(L5(H))V=!0,$.result+=d6.repeat(`
52
- `,Q?1+K:K);else if(V)V=!1,$.result+=d6.repeat(`
53
- `,K+1);else if(K===0){if(Q)$.result+=" "}else $.result+=d6.repeat(`
54
- `,K);else $.result+=d6.repeat(`
55
- `,Q?1+K:K);Q=!0,G=!0,K=0,J=$.position;while(!w6(H)&&H!==0)H=$.input.charCodeAt(++$.position);EZ($,J,$.position,!1)}return!0}function mM($,Z){var J,Y=$.tag,X=$.anchor,Q=[],G,W=!1,K;if($.anchor!==null)$.anchorMap[$.anchor]=Q;K=$.input.charCodeAt($.position);while(K!==0){if(K!==45)break;if(G=$.input.charCodeAt($.position+1),!Y8(G))break;if(W=!0,$.position++,U$($,!0,-1)){if($.lineIndent<=Z){Q.push(null),K=$.input.charCodeAt($.position);continue}}if(J=$.line,ZJ($,Z,cM,!1,!0),Q.push($.result),U$($,!0,-1),K=$.input.charCodeAt($.position),($.line===J||$.lineIndent>Z)&&K!==0)f0($,"bad indentation of a sequence entry");else if($.lineIndent<Z)break}if(W)return $.tag=Y,$.anchor=X,$.kind="sequence",$.result=Q,!0;return!1}function _o($,Z,J){var Y,X,Q,G,W=$.tag,K=$.anchor,V={},U={},H=null,B=null,z=null,F=!1,A=!1,j;if($.anchor!==null)$.anchorMap[$.anchor]=V;j=$.input.charCodeAt($.position);while(j!==0){if(Y=$.input.charCodeAt($.position+1),Q=$.line,G=$.position,(j===63||j===58)&&Y8(Y)){if(j===63){if(F)$J($,V,U,H,B,null),H=B=z=null;A=!0,F=!0,X=!0}else if(F)F=!1,X=!0;else f0($,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");$.position+=1,j=Y}else if(ZJ($,J,pM,!1,!0))if($.line===Q){j=$.input.charCodeAt($.position);while(L5(j))j=$.input.charCodeAt(++$.position);if(j===58){if(j=$.input.charCodeAt(++$.position),!Y8(j))f0($,"a whitespace character is expected after the key-value separator within a block mapping");if(F)$J($,V,U,H,B,null),H=B=z=null;A=!0,F=!1,X=!1,H=$.tag,B=$.result}else if(A)f0($,"can not read an implicit mapping pair; a colon is missed");else return $.tag=W,$.anchor=K,!0}else if(A)f0($,"can not read a block mapping entry; a multiline key may not be an implicit key");else return $.tag=W,$.anchor=K,!0;else break;if($.line===Q||$.lineIndent>Z){if(ZJ($,Z,i9,!0,X))if(F)B=$.result;else z=$.result;if(!F)$J($,V,U,H,B,z,Q,G),H=B=z=null;U$($,!0,-1),j=$.input.charCodeAt($.position)}if($.lineIndent>Z&&j!==0)f0($,"bad indentation of a mapping entry");else if($.lineIndent<Z)break}if(F)$J($,V,U,H,B,null);if(A)$.tag=W,$.anchor=K,$.kind="mapping",$.result=V;return A}function So($){var Z,J=!1,Y=!1,X,Q,G;if(G=$.input.charCodeAt($.position),G!==33)return!1;if($.tag!==null)f0($,"duplication of a tag property");if(G=$.input.charCodeAt(++$.position),G===60)J=!0,G=$.input.charCodeAt(++$.position);else if(G===33)Y=!0,X="!!",G=$.input.charCodeAt(++$.position);else X="!";if(Z=$.position,J){do G=$.input.charCodeAt(++$.position);while(G!==0&&G!==62);if($.position<$.length)Q=$.input.slice(Z,$.position),G=$.input.charCodeAt(++$.position);else f0($,"unexpected end of the stream within a verbatim tag")}else{while(G!==0&&!Y8(G)){if(G===33)if(!Y){if(X=$.input.slice(Z-1,$.position+1),!iM.test(X))f0($,"named tag handle cannot contain such characters");Y=!0,Z=$.position+1}else f0($,"tag suffix cannot contain exclamation marks");G=$.input.charCodeAt(++$.position)}if(Q=$.input.slice(Z,$.position),Mo.test(Q))f0($,"tag suffix cannot contain flow indicator characters")}if(Q&&!nM.test(Q))f0($,"tag name cannot contain such characters: "+Q);if(J)$.tag=Q;else if(bZ.call($.tagMap,X))$.tag=$.tagMap[X]+Q;else if(X==="!")$.tag="!"+Q;else if(X==="!!")$.tag="tag:yaml.org,2002:"+Q;else f0($,'undeclared tag handle "'+X+'"');return!0}function fo($){var Z,J;if(J=$.input.charCodeAt($.position),J!==38)return!1;if($.anchor!==null)f0($,"duplication of an anchor property");J=$.input.charCodeAt(++$.position),Z=$.position;while(J!==0&&!Y8(J)&&!e7(J))J=$.input.charCodeAt(++$.position);if($.position===Z)f0($,"name of an anchor node must contain at least one character");return $.anchor=$.input.slice(Z,$.position),!0}function ko($){var Z,J,Y;if(Y=$.input.charCodeAt($.position),Y!==42)return!1;Y=$.input.charCodeAt(++$.position),Z=$.position;while(Y!==0&&!Y8(Y)&&!e7(Y))Y=$.input.charCodeAt(++$.position);if($.position===Z)f0($,"name of an alias node must contain at least one character");if(J=$.input.slice(Z,$.position),!bZ.call($.anchorMap,J))f0($,'unidentified alias "'+J+'"');return $.result=$.anchorMap[J],U$($,!0,-1),!0}function ZJ($,Z,J,Y,X){var Q,G,W,K=1,V=!1,U=!1,H,B,z,F,A;if($.listener!==null)$.listener("open",$);if($.tag=null,$.anchor=null,$.kind=null,$.result=null,Q=G=W=i9===J||cM===J,Y){if(U$($,!0,-1)){if(V=!0,$.lineIndent>Z)K=1;else if($.lineIndent===Z)K=0;else if($.lineIndent<Z)K=-1}}if(K===1)while(So($)||fo($))if(U$($,!0,-1)){if(V=!0,W=Q,$.lineIndent>Z)K=1;else if($.lineIndent===Z)K=0;else if($.lineIndent<Z)K=-1}else W=!1;if(W)W=V||X;if(K===1||i9===J){if(c9===J||pM===J)F=Z;else F=Z+1;if(A=$.position-$.lineStart,K===1)if(W&&(mM($,A)||_o($,A,F))||Eo($,F))U=!0;else{if(G&&bo($,F)||Io($,F)||Co($,F))U=!0;else if(ko($)){if(U=!0,$.tag!==null||$.anchor!==null)f0($,"alias node should not have any properties")}else if(Po($,F,c9===J)){if(U=!0,$.tag===null)$.tag="?"}if($.anchor!==null)$.anchorMap[$.anchor]=$.result}else if(K===0)U=W&&mM($,A)}if($.tag!==null&&$.tag!=="!")if($.tag==="?"){if($.result!==null&&$.kind!=="scalar")f0($,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+$.kind+'"');for(H=0,B=$.implicitTypes.length;H<B;H+=1)if(z=$.implicitTypes[H],z.resolve($.result)){if($.result=z.construct($.result),$.tag=z.tag,$.anchor!==null)$.anchorMap[$.anchor]=$.result;break}}else if(bZ.call($.typeMap[$.kind||"fallback"],$.tag)){if(z=$.typeMap[$.kind||"fallback"][$.tag],$.result!==null&&z.kind!==$.kind)f0($,"unacceptable node kind for !<"+$.tag+'> tag; it should be "'+z.kind+'", not "'+$.kind+'"');if(!z.resolve($.result))f0($,"cannot resolve a node with !<"+$.tag+"> explicit tag");else if($.result=z.construct($.result),$.anchor!==null)$.anchorMap[$.anchor]=$.result}else f0($,"unknown tag !<"+$.tag+">");if($.listener!==null)$.listener("close",$);return $.tag!==null||$.anchor!==null||U}function vo($){var Z=$.position,J,Y,X,Q=!1,G;$.version=null,$.checkLineBreaks=$.legacy,$.tagMap={},$.anchorMap={};while((G=$.input.charCodeAt($.position))!==0){if(U$($,!0,-1),G=$.input.charCodeAt($.position),$.lineIndent>0||G!==37)break;Q=!0,G=$.input.charCodeAt(++$.position),J=$.position;while(G!==0&&!Y8(G))G=$.input.charCodeAt(++$.position);if(Y=$.input.slice(J,$.position),X=[],Y.length<1)f0($,"directive name must not be less than one character in length");while(G!==0){while(L5(G))G=$.input.charCodeAt(++$.position);if(G===35){do G=$.input.charCodeAt(++$.position);while(G!==0&&!w6(G));break}if(w6(G))break;J=$.position;while(G!==0&&!Y8(G))G=$.input.charCodeAt(++$.position);X.push($.input.slice(J,$.position))}if(G!==0)AU($);if(bZ.call(gM,Y))gM[Y]($,Y,X);else n9($,'unknown document directive "'+Y+'"')}if(U$($,!0,-1),$.lineIndent===0&&$.input.charCodeAt($.position)===45&&$.input.charCodeAt($.position+1)===45&&$.input.charCodeAt($.position+2)===45)$.position+=3,U$($,!0,-1);else if(Q)f0($,"directives end mark is expected");if(ZJ($,$.lineIndent-1,i9,!1,!0),U$($,!0,-1),$.checkLineBreaks&&No.test($.input.slice(Z,$.position)))n9($,"non-ASCII line breaks are interpreted as content");if($.documents.push($.result),$.position===$.lineStart&&o9($)){if($.input.charCodeAt($.position)===46)$.position+=3,U$($,!0,-1);return}if($.position<$.length-1)f0($,"end of the stream or a document separator is expected");else return}function tM($,Z){if($=String($),Z=Z||{},$.length!==0){if($.charCodeAt($.length-1)!==10&&$.charCodeAt($.length-1)!==13)$+=`
56
- `;if($.charCodeAt(0)===65279)$=$.slice(1)}var J=new Ro($,Z),Y=$.indexOf("\x00");if(Y!==-1)J.position=Y,f0(J,"null byte is not allowed in input");J.input+="\x00";while(J.input.charCodeAt(J.position)===32)J.lineIndent+=1,J.position+=1;while(J.position<J.length-1)vo(J);return J.documents}function eM($,Z,J){if(Z!==null&&typeof Z==="object"&&typeof J>"u")J=Z,Z=null;var Y=tM($,J);if(typeof Z!=="function")return Y;for(var X=0,Q=Y.length;X<Q;X+=1)Z(Y[X])}function $D($,Z){var J=tM($,Z);if(J.length===0)return;else if(J.length===1)return J[0];throw new lM("expected a single document in the stream, but found more")}function yo($,Z,J){if(typeof Z==="object"&&Z!==null&&typeof J>"u")J=Z,Z=null;return eM($,Z,d6.extend({schema:dM},J))}function xo($,Z){return $D($,d6.extend({schema:dM},Z))}ho.loadAll=eM;ho.load=$D;ho.safeLoadAll=yo;ho.safeLoad=xo});var TD=S((Ts,MU)=>{var rY=M5(),aY=r7(),po=nY(),co=t7(),VD=Object.prototype.toString,UD=Object.prototype.hasOwnProperty,io=9,sY=10,no=13,oo=32,so=33,ro=34,HD=35,ao=37,to=38,eo=39,$s=42,BD=44,Zs=45,zD=58,Js=61,Ys=62,Xs=63,Qs=64,FD=91,AD=93,Gs=96,OD=123,Ws=124,qD=125,u$={};u$[0]="\\0";u$[7]="\\a";u$[8]="\\b";u$[9]="\\t";u$[10]="\\n";u$[11]="\\v";u$[12]="\\f";u$[13]="\\r";u$[27]="\\e";u$[34]="\\\"";u$[92]="\\\\";u$[133]="\\N";u$[160]="\\_";u$[8232]="\\L";u$[8233]="\\P";var Ks=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function Vs($,Z){var J,Y,X,Q,G,W,K;if(Z===null)return{};J={},Y=Object.keys(Z);for(X=0,Q=Y.length;X<Q;X+=1){if(G=Y[X],W=String(Z[G]),G.slice(0,2)==="!!")G="tag:yaml.org,2002:"+G.slice(2);if(K=$.compiledTypeMap.fallback[G],K&&UD.call(K.styleAliases,W))W=K.styleAliases[W];J[G]=W}return J}function JD($){var Z,J,Y;if(Z=$.toString(16).toUpperCase(),$<=255)J="x",Y=2;else if($<=65535)J="u",Y=4;else if($<=4294967295)J="U",Y=8;else throw new aY("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+J+rY.repeat("0",Y-Z.length)+Z}function Us($){this.schema=$.schema||po,this.indent=Math.max(1,$.indent||2),this.noArrayIndent=$.noArrayIndent||!1,this.skipInvalid=$.skipInvalid||!1,this.flowLevel=rY.isNothing($.flowLevel)?-1:$.flowLevel,this.styleMap=Vs(this.schema,$.styles||null),this.sortKeys=$.sortKeys||!1,this.lineWidth=$.lineWidth||80,this.noRefs=$.noRefs||!1,this.noCompatMode=$.noCompatMode||!1,this.condenseFlow=$.condenseFlow||!1,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function YD($,Z){var J=rY.repeat(" ",Z),Y=0,X=-1,Q="",G,W=$.length;while(Y<W){if(X=$.indexOf(`
57
- `,Y),X===-1)G=$.slice(Y),Y=W;else G=$.slice(Y,X+1),Y=X+1;if(G.length&&G!==`
58
- `)Q+=J;Q+=G}return Q}function qU($,Z){return`
59
- `+rY.repeat(" ",$.indent*Z)}function Hs($,Z){var J,Y,X;for(J=0,Y=$.implicitTypes.length;J<Y;J+=1)if(X=$.implicitTypes[J],X.resolve(Z))return!0;return!1}function NU($){return $===oo||$===io}function JJ($){return 32<=$&&$<=126||161<=$&&$<=55295&&$!==8232&&$!==8233||57344<=$&&$<=65533&&$!==65279||65536<=$&&$<=1114111}function Bs($){return JJ($)&&!NU($)&&$!==65279&&$!==no&&$!==sY}function XD($,Z){return JJ($)&&$!==65279&&$!==BD&&$!==FD&&$!==AD&&$!==OD&&$!==qD&&$!==zD&&($!==HD||Z&&Bs(Z))}function zs($){return JJ($)&&$!==65279&&!NU($)&&$!==Zs&&$!==Xs&&$!==zD&&$!==BD&&$!==FD&&$!==AD&&$!==OD&&$!==qD&&$!==HD&&$!==to&&$!==$s&&$!==so&&$!==Ws&&$!==Js&&$!==Ys&&$!==eo&&$!==ro&&$!==ao&&$!==Qs&&$!==Gs}function jD($){var Z=/^\n* /;return Z.test($)}var ND=1,MD=2,DD=3,wD=4,s9=5;function Fs($,Z,J,Y,X){var Q,G,W,K=!1,V=!1,U=Y!==-1,H=-1,B=zs($.charCodeAt(0))&&!NU($.charCodeAt($.length-1));if(Z)for(Q=0;Q<$.length;Q++){if(G=$.charCodeAt(Q),!JJ(G))return s9;W=Q>0?$.charCodeAt(Q-1):null,B=B&&XD(G,W)}else{for(Q=0;Q<$.length;Q++){if(G=$.charCodeAt(Q),G===sY){if(K=!0,U)V=V||Q-H-1>Y&&$[H+1]!==" ",H=Q}else if(!JJ(G))return s9;W=Q>0?$.charCodeAt(Q-1):null,B=B&&XD(G,W)}V=V||U&&(Q-H-1>Y&&$[H+1]!==" ")}if(!K&&!V)return B&&!X($)?ND:MD;if(J>9&&jD($))return s9;return V?wD:DD}function As($,Z,J,Y){$.dump=function(){if(Z.length===0)return"''";if(!$.noCompatMode&&Ks.indexOf(Z)!==-1)return"'"+Z+"'";var X=$.indent*Math.max(1,J),Q=$.lineWidth===-1?-1:Math.max(Math.min($.lineWidth,40),$.lineWidth-X),G=Y||$.flowLevel>-1&&J>=$.flowLevel;function W(K){return Hs($,K)}switch(Fs(Z,G,$.indent,Q,W)){case ND:return Z;case MD:return"'"+Z.replace(/'/g,"''")+"'";case DD:return"|"+QD(Z,$.indent)+GD(YD(Z,X));case wD:return">"+QD(Z,$.indent)+GD(YD(Os(Z,Q),X));case s9:return'"'+qs(Z,Q)+'"';default:throw new aY("impossible error: invalid scalar style")}}()}function QD($,Z){var J=jD($)?String(Z):"",Y=$[$.length-1]===`
60
- `,X=Y&&($[$.length-2]===`
61
- `||$===`
62
- `),Q=X?"+":Y?"":"-";return J+Q+`
63
- `}function GD($){return $[$.length-1]===`
64
- `?$.slice(0,-1):$}function Os($,Z){var J=/(\n+)([^\n]*)/g,Y=function(){var V=$.indexOf(`
65
- `);return V=V!==-1?V:$.length,J.lastIndex=V,WD($.slice(0,V),Z)}(),X=$[0]===`
66
- `||$[0]===" ",Q,G;while(G=J.exec($)){var W=G[1],K=G[2];Q=K[0]===" ",Y+=W+(!X&&!Q&&K!==""?`
67
- `:"")+WD(K,Z),X=Q}return Y}function WD($,Z){if($===""||$[0]===" ")return $;var J=/ [^ ]/g,Y,X=0,Q,G=0,W=0,K="";while(Y=J.exec($)){if(W=Y.index,W-X>Z)Q=G>X?G:W,K+=`
68
- `+$.slice(X,Q),X=Q+1;G=W}if(K+=`
69
- `,$.length-X>Z&&G>X)K+=$.slice(X,G)+`
70
- `+$.slice(G+1);else K+=$.slice(X);return K.slice(1)}function qs($){var Z="",J,Y,X;for(var Q=0;Q<$.length;Q++){if(J=$.charCodeAt(Q),J>=55296&&J<=56319){if(Y=$.charCodeAt(Q+1),Y>=56320&&Y<=57343){Z+=JD((J-55296)*1024+Y-56320+65536),Q++;continue}}X=u$[J],Z+=!X&&JJ(J)?$[Q]:X||JD(J)}return Z}function js($,Z,J){var Y="",X=$.tag,Q,G;for(Q=0,G=J.length;Q<G;Q+=1)if(T5($,Z,J[Q],!1,!1)){if(Q!==0)Y+=","+(!$.condenseFlow?" ":"");Y+=$.dump}$.tag=X,$.dump="["+Y+"]"}function Ns($,Z,J,Y){var X="",Q=$.tag,G,W;for(G=0,W=J.length;G<W;G+=1)if(T5($,Z+1,J[G],!0,!0)){if(!Y||G!==0)X+=qU($,Z);if($.dump&&sY===$.dump.charCodeAt(0))X+="-";else X+="- ";X+=$.dump}$.tag=Q,$.dump=X||"[]"}function Ms($,Z,J){var Y="",X=$.tag,Q=Object.keys(J),G,W,K,V,U;for(G=0,W=Q.length;G<W;G+=1){if(U="",G!==0)U+=", ";if($.condenseFlow)U+='"';if(K=Q[G],V=J[K],!T5($,Z,K,!1,!1))continue;if($.dump.length>1024)U+="? ";if(U+=$.dump+($.condenseFlow?'"':"")+":"+($.condenseFlow?"":" "),!T5($,Z,V,!1,!1))continue;U+=$.dump,Y+=U}$.tag=X,$.dump="{"+Y+"}"}function Ds($,Z,J,Y){var X="",Q=$.tag,G=Object.keys(J),W,K,V,U,H,B;if($.sortKeys===!0)G.sort();else if(typeof $.sortKeys==="function")G.sort($.sortKeys);else if($.sortKeys)throw new aY("sortKeys must be a boolean or a function");for(W=0,K=G.length;W<K;W+=1){if(B="",!Y||W!==0)B+=qU($,Z);if(V=G[W],U=J[V],!T5($,Z+1,V,!0,!0,!0))continue;if(H=$.tag!==null&&$.tag!=="?"||$.dump&&$.dump.length>1024,H)if($.dump&&sY===$.dump.charCodeAt(0))B+="?";else B+="? ";if(B+=$.dump,H)B+=qU($,Z);if(!T5($,Z+1,U,!0,H))continue;if($.dump&&sY===$.dump.charCodeAt(0))B+=":";else B+=": ";B+=$.dump,X+=B}$.tag=Q,$.dump=X||"{}"}function KD($,Z,J){var Y,X,Q,G,W,K;X=J?$.explicitTypes:$.implicitTypes;for(Q=0,G=X.length;Q<G;Q+=1)if(W=X[Q],(W.instanceOf||W.predicate)&&(!W.instanceOf||typeof Z==="object"&&Z instanceof W.instanceOf)&&(!W.predicate||W.predicate(Z))){if($.tag=J?W.tag:"?",W.represent){if(K=$.styleMap[W.tag]||W.defaultStyle,VD.call(W.represent)==="[object Function]")Y=W.represent(Z,K);else if(UD.call(W.represent,K))Y=W.represent[K](Z,K);else throw new aY("!<"+W.tag+'> tag resolver accepts not "'+K+'" style');$.dump=Y}return!0}return!1}function T5($,Z,J,Y,X,Q){if($.tag=null,$.dump=J,!KD($,J,!1))KD($,J,!0);var G=VD.call($.dump);if(Y)Y=$.flowLevel<0||$.flowLevel>Z;var W=G==="[object Object]"||G==="[object Array]",K,V;if(W)K=$.duplicates.indexOf(J),V=K!==-1;if($.tag!==null&&$.tag!=="?"||V||$.indent!==2&&Z>0)X=!1;if(V&&$.usedDuplicates[K])$.dump="*ref_"+K;else{if(W&&V&&!$.usedDuplicates[K])$.usedDuplicates[K]=!0;if(G==="[object Object]"){if(Y&&Object.keys($.dump).length!==0){if(Ds($,Z,$.dump,X),V)$.dump="&ref_"+K+$.dump}else if(Ms($,Z,$.dump),V)$.dump="&ref_"+K+" "+$.dump}else if(G==="[object Array]"){var U=$.noArrayIndent&&Z>0?Z-1:Z;if(Y&&$.dump.length!==0){if(Ns($,U,$.dump,X),V)$.dump="&ref_"+K+$.dump}else if(js($,U,$.dump),V)$.dump="&ref_"+K+" "+$.dump}else if(G==="[object String]"){if($.tag!=="?")As($,$.dump,Z,Q)}else{if($.skipInvalid)return!1;throw new aY("unacceptable kind of an object to dump "+G)}if($.tag!==null&&$.tag!=="?")$.dump="!<"+$.tag+"> "+$.dump}return!0}function ws($,Z){var J=[],Y=[],X,Q;jU($,J,Y);for(X=0,Q=Y.length;X<Q;X+=1)Z.duplicates.push(J[Y[X]]);Z.usedDuplicates=Array(Q)}function jU($,Z,J){var Y,X,Q;if($!==null&&typeof $==="object")if(X=Z.indexOf($),X!==-1){if(J.indexOf(X)===-1)J.push(X)}else if(Z.push($),Array.isArray($))for(X=0,Q=$.length;X<Q;X+=1)jU($[X],Z,J);else{Y=Object.keys($);for(X=0,Q=Y.length;X<Q;X+=1)jU($[Y[X]],Z,J)}}function LD($,Z){Z=Z||{};var J=new Us(Z);if(!J.noRefs)ws($,J);if(T5(J,0,$,!0,!0))return J.dump+`
71
- `;return""}function Ls($,Z){return LD($,rY.extend({schema:co},Z))}Ts.dump=LD;Ts.safeDump=Ls});var PD=S((Is,Z$)=>{var r9=ZD(),RD=TD();function a9($){return function(){throw Error("Function "+$+" is deprecated and cannot be used.")}}Is.Type=A$();Is.Schema=D5();Is.FAILSAFE_SCHEMA=d9();Is.JSON_SCHEMA=VU();Is.CORE_SCHEMA=UU();Is.DEFAULT_SAFE_SCHEMA=t7();Is.DEFAULT_FULL_SCHEMA=nY();Is.load=r9.load;Is.loadAll=r9.loadAll;Is.safeLoad=r9.safeLoad;Is.safeLoadAll=r9.safeLoadAll;Is.dump=RD.dump;Is.safeDump=RD.safeDump;Is.YAMLException=r7();Is.MINIMAL_SCHEMA=d9();Is.SAFE_SCHEMA=t7();Is.DEFAULT_SCHEMA=nY();Is.scan=a9("scan");Is.parse=a9("parse");Is.compose=a9("compose");Is.addConstructor=a9("addConstructor")});var CD=S((wR0,ID)=>{var ss=PD();ID.exports=ss});var TU=S((wU,LU)=>{var t9=CD(),DU=wU=LU.exports;DU.yaml={parse:t9.safeLoad.bind(t9),stringify:t9.safeDump.bind(t9)};DU.json={parse:JSON.parse.bind(JSON),stringify:function($,Z){let J=Object.assign({replacer:null,space:2},Z);return JSON.stringify($,J.replacer,J.space)}};DU.javascript={parse:function parse(str,options,wrap){try{if(wrap!==!1)str=`(function() {
72
- return `+str.trim()+`;
73
- }());`;return eval(str)||{}}catch($){if(wrap!==!1&&/(unexpected|identifier)/i.test($.message))return parse(str,options,!1);throw SyntaxError($)}},stringify:function(){throw Error("stringifying JavaScript is not supported")}}});var bD=S((LR0,ED)=>{/*!
74
- * strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
75
- *
76
- * Copyright (c) 2015, 2017, Jon Schlinkert.
77
- * Released under the MIT License.
78
- */ED.exports=function($){if(typeof $==="string"&&$.charAt(0)==="\uFEFF")return $.slice(1);return $}});var e9=S((rs)=>{var _D=bD(),SD=cY();rs.define=function($,Z,J){Reflect.defineProperty($,Z,{enumerable:!1,configurable:!0,writable:!0,value:J})};rs.isBuffer=function($){return SD($)==="buffer"};rs.isObject=function($){return SD($)==="object"};rs.toBuffer=function($){return typeof $==="string"?Buffer.from($):$};rs.toString=function($){if(rs.isBuffer($))return _D(String($));if(typeof $!=="string")throw TypeError("expected input to be a string or buffer");return _D($)};rs.arrayify=function($){return $?Array.isArray($)?$:[$]:[]};rs.startsWith=function($,Z,J){if(typeof J!=="number")J=Z.length;return $.slice(0,J)===Z}});var tY=S((RR0,kD)=>{var Yr=TU(),Xr=e9();kD.exports=function($){let Z=Object.assign({},$);if(Z.delimiters=Xr.arrayify(Z.delims||Z.delimiters||"---"),Z.delimiters.length===1)Z.delimiters.push(Z.delimiters[0]);return Z.language=(Z.language||Z.lang||"yaml").toLowerCase(),Z.engines=Object.assign({},Yr,Z.parsers,Z.engines),Z}});var RU=S((PR0,vD)=>{vD.exports=function($,Z){let J=Z.engines[$]||Z.engines[Qr($)];if(typeof J>"u")throw Error('gray-matter engine "'+$+'" is not registered');if(typeof J==="function")J={parse:J};return J};function Qr($){switch($.toLowerCase()){case"js":case"javascript":return"javascript";case"coffee":case"coffeescript":case"cson":return"coffee";case"yaml":case"yml":return"yaml";default:return $}}});var PU=S((IR0,yD)=>{var Gr=cY(),Wr=RU(),Kr=tY();yD.exports=function($,Z,J){if(Z==null&&J==null)switch(Gr($)){case"object":Z=$.data,J={};break;case"string":return $;default:throw TypeError("expected file to be a string or object")}let Y=$.content,X=Kr(J);if(Z==null){if(!X.data)return $;Z=X.data}let Q=$.language||X.language,G=Wr(Q,X);if(typeof G.stringify!=="function")throw TypeError('expected "'+Q+'.stringify" to be a function');Z=Object.assign({},$.data,Z);let W=X.delimiters[0],K=X.delimiters[1],V=G.stringify(Z,J).trim(),U="";if(V!=="{}")U=YJ(W)+YJ(V)+YJ(K);if(typeof $.excerpt==="string"&&$.excerpt!==""){if(Y.indexOf($.excerpt.trim())===-1)U+=YJ($.excerpt)+YJ(K)}return U+YJ(Y)};function YJ($){return $.slice(-1)!==`
79
- `?$+`
80
- `:$}});var hD=S((CR0,xD)=>{var Vr=tY();xD.exports=function($,Z){let J=Vr(Z);if($.data==null)$.data={};if(typeof J.excerpt==="function")return J.excerpt($,J);let Y=$.data.excerpt_separator||J.excerpt_separator;if(Y==null&&(J.excerpt===!1||J.excerpt==null))return $;let X=typeof J.excerpt==="string"?J.excerpt:Y||J.delimiters[0],Q=$.content.indexOf(X);if(Q!==-1)$.excerpt=$.content.slice(0,Q);return $}});var mD=S((ER0,uD)=>{var gD=cY(),Ur=PU(),XJ=e9();uD.exports=function($){if(gD($)!=="object")$={content:$};if(gD($.data)!=="object")$.data={};if($.contents&&$.content==null)$.content=$.contents;return XJ.define($,"orig",XJ.toBuffer($.content)),XJ.define($,"language",$.language||""),XJ.define($,"matter",$.matter||""),XJ.define($,"stringify",function(Z,J){if(J&&J.language)$.language=J.language;return Ur($,Z,J)}),$.content=XJ.toString($.content),$.isEmpty=!1,$.excerpt="",$}});var dD=S((bR0,lD)=>{var Hr=RU(),Br=tY();lD.exports=function($,Z,J){let Y=Br(J),X=Hr($,Y);if(typeof X.parse!=="function")throw TypeError('expected "'+$+'.parse" to be a function');return X.parse(Z,Y)}});var nD=S((_R0,iD)=>{var zr=Y0("fs"),Fr=gN(),IU=tY(),Ar=PU(),pD=hD(),Or=TU(),qr=mD(),jr=dD(),cD=e9();function o$($,Z){if($==="")return{data:{},content:$,excerpt:"",orig:$};let J=qr($),Y=o$.cache[J.content];if(!Z){if(Y)return J=Object.assign({},Y),J.orig=Y.orig,J;o$.cache[J.content]=J}return Nr(J,Z)}function Nr($,Z){let J=IU(Z),Y=J.delimiters[0],X=`
81
- `+J.delimiters[1],Q=$.content;if(J.language)$.language=J.language;let G=Y.length;if(!cD.startsWith(Q,Y,G))return pD($,J),$;if(Q.charAt(G)===Y.slice(-1))return $;Q=Q.slice(G);let W=Q.length,K=o$.language(Q,J);if(K.name)$.language=K.name,Q=Q.slice(K.raw.length);let V=Q.indexOf(X);if(V===-1)V=W;if($.matter=Q.slice(0,V),$.matter.replace(/^\s*#[^\n]+/gm,"").trim()==="")$.isEmpty=!0,$.empty=$.content,$.data={};else $.data=jr($.language,$.matter,J);if(V===W)$.content="";else{if($.content=Q.slice(V+X.length),$.content[0]==="\r")$.content=$.content.slice(1);if($.content[0]===`
82
- `)$.content=$.content.slice(1)}if(pD($,J),J.sections===!0||typeof J.section==="function")Fr($,J.section);return $}o$.engines=Or;o$.stringify=function($,Z,J){if(typeof $==="string")$=o$($,J);return Ar($,Z,J)};o$.read=function($,Z){let J=zr.readFileSync($,"utf8"),Y=o$(J,Z);return Y.path=$,Y};o$.test=function($,Z){return cD.startsWith($,IU(Z).delimiters[0])};o$.language=function($,Z){let Y=IU(Z).delimiters[0];if(o$.test($))$=$.slice(Y.length);let X=$.slice(0,$.search(/\r?\n/));return{raw:X,name:X?X.trim():""}};o$.cache={};o$.clearCache=function(){o$.cache={}};iD.exports=o$});var $R=S((Hf0,e2)=>{function C00($){var Z=new $,J=Z;function Y(){var Q=Z;if(Q.next)Z=Q.next;else Z=new $,J=Z;return Q.next=null,Q}function X(Q){J.next=Q,J=Q}return{get:Y,release:X}}e2.exports=C00});var JR=S((Bf0,SH)=>{var E00=$R();function ZR($,Z,J){if(typeof $==="function")J=Z,Z=$,$=null;if(!(J>=1))throw Error("fastqueue concurrency must be equal to or greater than 1");var Y=E00(b00),X=null,Q=null,G=0,W=null,K={push:A,drain:W8,saturated:W8,pause:U,paused:!1,get concurrency(){return J},set concurrency(R){if(!(R>=1))throw Error("fastqueue concurrency must be equal to or greater than 1");if(J=R,K.paused)return;for(;X&&G<J;)G++,N()},running:V,resume:z,idle:F,length:H,getQueue:B,unshift:j,empty:W8,kill:L,killAndDrain:q,error:C,abort:M};return K;function V(){return G}function U(){K.paused=!0}function H(){var R=X,w=0;while(R)R=R.next,w++;return w}function B(){var R=X,w=[];while(R)w.push(R.value),R=R.next;return w}function z(){if(!K.paused)return;if(K.paused=!1,X===null){G++,N();return}for(;X&&G<J;)G++,N()}function F(){return G===0&&K.length()===0}function A(R,w){var I=Y.get();if(I.context=$,I.release=N,I.value=R,I.callback=w||W8,I.errorHandler=W,G>=J||K.paused)if(Q)Q.next=I,Q=I;else X=I,Q=I,K.saturated();else G++,Z.call($,I.value,I.worked)}function j(R,w){var I=Y.get();if(I.context=$,I.release=N,I.value=R,I.callback=w||W8,I.errorHandler=W,G>=J||K.paused)if(X)I.next=X,X=I;else X=I,Q=I,K.saturated();else G++,Z.call($,I.value,I.worked)}function N(R){if(R)Y.release(R);var w=X;if(w&&G<=J)if(!K.paused){if(Q===X)Q=null;if(X=w.next,w.next=null,Z.call($,w.value,w.worked),Q===null)K.empty()}else G--;else if(--G===0)K.drain()}function L(){X=null,Q=null,K.drain=W8}function q(){X=null,Q=null,K.drain(),K.drain=W8}function M(){var R=X;X=null,Q=null;while(R){var{next:w,callback:I,errorHandler:_,value:E,context:f}=R;if(R.value=null,R.callback=W8,R.errorHandler=null,_)_(Error("abort"),E);I.call(f,Error("abort")),R.release(R),R=w}K.drain=W8}function C(R){W=R}}function W8(){}function b00(){this.value=null,this.callback=W8,this.next=null,this.release=W8,this.context=null,this.errorHandler=null;var $=this;this.worked=function(J,Y){var{callback:X,errorHandler:Q,value:G}=$;if($.value=null,$.callback=W8,$.errorHandler)Q(J,G);X.call($.context,J,Y),$.release($)}}function _00($,Z,J){if(typeof $==="function")J=Z,Z=$,$=null;function Y(U,H){Z.call(this,U).then(function(B){H(null,B)},H)}var X=ZR($,Y,J),Q=X.push,G=X.unshift;return X.push=W,X.unshift=K,X.drained=V,X;function W(U){var H=new Promise(function(B,z){Q(U,function(F,A){if(F){z(F);return}B(A)})});return H.catch(W8),H}function K(U){var H=new Promise(function(B,z){G(U,function(F,A){if(F){z(F);return}B(A)})});return H.catch(W8),H}function V(){var U=new Promise(function(H){process.nextTick(function(){if(X.idle())H();else{var B=X.drain;X.drain=function(){if(typeof B==="function")B();H(),X.drain=B}}})});return U}}SH.exports=ZR;SH.exports.promise=_00});var fH=S((zf0,TX)=>{var{format:S00}=Y0("util");function f00(){return`${this.name} [${this.code}]: ${this.message}`}var C4=Symbol.for("fastify-error-generic");function qJ($,Z,J=500,Y=Error,X=qJ.captureStackTrace){let Q=$===C4;if(Q)$="FST_ERR";if(!$)throw Error("Fastify error code must not be empty");if(!Z)throw Error("Fastify error message must not be empty");$=$.toUpperCase(),!J&&(J=void 0);let G=Symbol.for(`fastify-error ${$}`);function W(...K){if(!new.target)return new W(...K);this.code=$,this.name="FastifyError",this.statusCode=J;let V=K.length-1;if(V!==-1&&K[V]&&typeof K[V]==="object"&&"cause"in K[V])this.cause=K.pop().cause;this.message=S00(Z,...K),Error.stackTraceLimit&&X&&Error.captureStackTrace(this,W)}if(W.prototype=Object.create(Y.prototype,{constructor:{value:W,enumerable:!1,writable:!0,configurable:!0},[C4]:{value:!0,enumerable:!1,writable:!1,configurable:!1},[G]:{value:!0,enumerable:!1,writable:!1,configurable:!1}}),Q)Object.defineProperty(W,Symbol.hasInstance,{value(K){return K&&K[C4]},configurable:!1,writable:!1,enumerable:!1});else Object.defineProperty(W,Symbol.hasInstance,{value(K){return K&&K[G]},configurable:!1,writable:!1,enumerable:!1});return W.prototype[Symbol.toStringTag]="Error",W.prototype.toString=f00,W}qJ.captureStackTrace=!0;var k00=qJ(C4,"Fastify Error",500,Error);TX.exports=qJ;TX.exports.FastifyError=k00;TX.exports.default=qJ;TX.exports.createError=qJ});var E4=S((Ff0,YR)=>{var{createError:gZ}=fH();YR.exports={AVV_ERR_EXPOSE_ALREADY_DEFINED:gZ("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' is already defined, specify an expose option for '%s'"),AVV_ERR_ATTRIBUTE_ALREADY_DEFINED:gZ("AVV_ERR_ATTRIBUTE_ALREADY_DEFINED","'%s' is already defined"),AVV_ERR_CALLBACK_NOT_FN:gZ("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:gZ("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:gZ("AVV_ERR_ROOT_PLG_BOOTED","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:gZ("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:gZ("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise"),AVV_ERR_PLUGIN_EXEC_TIMEOUT:gZ("AVV_ERR_PLUGIN_EXEC_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")}});var jJ=S((Af0,XR)=>{var v00=Symbol("avvio.Boot"),y00=Symbol("isOnCloseHandler"),x00=Symbol("avvio.ThenifyDoNotWrap"),h00=Symbol("avvio.TimeTree.untrackNode"),g00=Symbol("avvio.TimeTree.trackNode"),u00=Symbol("avvio.TimeTree.getParent"),m00=Symbol("avvio.TimeTree.getNode"),l00=Symbol("avvio.TimeTree.addNode"),d00=Symbol.for("plugin-meta");XR.exports={kAvvio:v00,kIsOnCloseHandler:y00,kThenifyDoNotWrap:x00,kUntrackNode:h00,kTrackNode:g00,kGetParent:u00,kGetNode:m00,kAddNode:l00,kPluginMeta:d00}});var BR=S((Of0,HR)=>{var{kUntrackNode:QR,kTrackNode:kH,kGetParent:GR,kGetNode:WR,kAddNode:KR}=jJ();class VR{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[kH]($){if(this.tableId.set($.id,$),this.tableLabel.has($.label))this.tableLabel.get($.label).push($);else this.tableLabel.set($.label,[$])}[QR]($){this.tableId.delete($.id);let Z=this.tableLabel.get($.label);if(Z.pop(),Z.length===0)this.tableLabel.delete($.label)}[GR]($){if($===null)return null;else if(this.tableLabel.has($)){let Z=this.tableLabel.get($);return Z[Z.length-1]}else return null}[WR]($){return this.tableId.get($)}[KR]($,Z,J){let Y=this[GR]($);if(Y===null)return this.root={parent:null,id:"root",label:Z,nodes:[],start:J,stop:null,diff:-1},this[kH](this.root),this.root.id;let Q=`${Z}-${Math.random()}`,G={parent:$,id:Q,label:Z,nodes:[],start:J,stop:null,diff:-1};return Y.nodes.push(G),this[kH](G),Q}start($,Z,J=Date.now()){return this[KR]($,Z,J)}stop($,Z=Date.now()){let J=this[WR]($);if(J)J.stop=Z,J.diff=J.stop-J.start||0,this[QR](J)}toJSON(){return Object.assign({},this.root)}prettyPrint(){return UR(this.toJSON())}}function UR($,Z=""){let J=Z,Y=$.nodes.length,X=Y-1;J+=`${$.label} ${$.diff} ms
83
- `;for(let Q=0;Q<Y;++Q){let G=$.nodes[Q],W=Z+(Q===X?" ":"\u2502 ");J+=Z,J+=Q===X?"\u2514\u2500":"\u251C\u2500",J+=G.nodes.length===0?"\u2500 ":"\u252C ",J+=UR(G,W).slice(Z.length+2)}return J}HR.exports={TimeTree:VR}});var b4=S((qf0,zR)=>{var{debuglog:p00}=Y0("util"),c00=p00("avvio");zR.exports={debug:c00}});var AR=S((jf0,FR)=>{function i00(){let $={resolve:null,reject:null,promise:null};return $.promise=new Promise((Z,J)=>{$.resolve=Z,$.reject=J}),$}FR.exports={createPromise:i00}});var jR=S((Nf0,qR)=>{var{kPluginMeta:OR}=jJ();function n00($,Z){if($[OR]?.name)return $[OR].name;if(Z?.name)return Z.name;if($.name)return $.name;else return $.toString().split(`
84
- `).slice(0,2).map((J)=>J.trim()).join(" -- ")}qR.exports={getPluginName:n00}});var _4=S((Mf0,NR)=>{function o00($){return $!==null&&typeof $==="object"&&typeof $.then==="function"}NR.exports={isPromiseLike:o00}});var DR=S((Df0,MR)=>{var{EventEmitter:s00}=Y0("events"),{inherits:r00}=Y0("util"),{debug:_$}=b4(),{createPromise:a00}=AR(),{AVV_ERR_PLUGIN_EXEC_TIMEOUT:t00}=E4(),{getPluginName:e00}=jR(),{isPromiseLike:$10}=_4();function NJ($,Z,J,Y,X){this.queue=$,this.func=Z,this.options=J,this.isAfter=Y,this.timeout=X,this.started=!1,this.name=e00(Z,J),this.queue.pause(),this._error=null,this.loaded=!1,this._promise=null,this.startTime=null}r00(NJ,s00);NJ.prototype.exec=function($,Z){_$("exec",this.name),this.server=$;let J=this.func,Y=this.name,X=!1;this.options=typeof this.options==="function"?this.options(this.server):this.options;let Q=null,G=(K)=>{if(X){_$("loading complete",Y);return}if(this._error=K,K)_$("exec errored",Y);else _$("exec completed",Y);if(X=!0,Q)clearTimeout(Q);Z(K)};if(this.timeout>0)_$("setting up timeout",Y,this.timeout),Q=setTimeout(function(){_$("timed out",Y),Q=null;let K=new t00(Y);K.fn=J,G(K)},this.timeout);this.started=!0,this.startTime=Date.now(),this.emit("start",this.server?this.server.name:null,this.name,Date.now());let W=J(this.server,this.options,G);if($10(W))_$("exec: resolving promise",Y),W.then(()=>process.nextTick(G),(K)=>process.nextTick(G,K));else if(J.length<3)G()};NJ.prototype.loadedSoFar=function(){if(_$("loadedSoFar",this.name),this.loaded)return Promise.resolve();let $=()=>{this.server.after((J,Y)=>{if(this._error=J,this.queue.pause(),this._promise){if(J)_$("rejecting promise",this.name,J),this._promise.reject(J);else _$("resolving promise",this.name),this._promise.resolve();this._promise=null}process.nextTick(Y,J)}),this.queue.resume()},Z;if(!this._promise)if(this._promise=a00(),Z=this._promise.promise,!this.server)this.on("start",$);else $();else Z=Promise.resolve();return Z};NJ.prototype.enqueue=function($,Z){_$("enqueue",this.name,$.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.queue.push($,Z)};NJ.prototype.finish=function($,Z){_$("finish",this.name,$);let J=()=>{if(this.loaded)return;_$("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,Z($)};if($){if(this._promise)this._promise.reject($),this._promise=null;J();return}let Y=()=>{if(_$("check",this.name,this.queue.length(),this.queue.running(),this._promise),this.queue.length()===0&&this.queue.running()===0)if(this._promise){let X=()=>{_$("wrap"),queueMicrotask(Y)};this._promise.resolve(),this._promise.promise.then(X,X),this._promise=null}else J();else _$("delayed",this.name),this.queue.drain=()=>{_$("drain",this.name),this.queue.drain=Z10,queueMicrotask(Y)}};queueMicrotask(Y),this.queue.resume()};function Z10(){}MR.exports={Plugin:NJ}});var LR=S((wf0,wR)=>{var{AVV_ERR_PLUGIN_NOT_VALID:vH}=E4();function J10($){if(!($&&(typeof $==="function"||typeof $.then==="function")))if(Array.isArray($))throw new vH("array");else if($===null)throw new vH("null");else throw new vH(typeof $)}wR.exports={validatePlugin:J10}});var RR=S((Lf0,TR)=>{function Y10($){return $!==null&&typeof $==="object"&&typeof $.default==="function"}TR.exports={isBundledOrTypescriptPlugin:Y10}});var CR=S((Tf0,IR)=>{var{debug:PR}=b4(),{kThenifyDoNotWrap:yH}=jJ();function X10(){if(this.booted){PR("thenify returning undefined because we are already booted");return}if(this[yH]){this[yH]=!1;return}return PR("thenify"),($,Z)=>{return this._loadRegistered().then(()=>{return this[yH]=!0,$(this._server)},Z)}}IR.exports={thenify:X10}});var bR=S((Rf0,ER)=>{var{isPromiseLike:Q10}=_4(),{kAvvio:G10}=jJ();function W10($,Z,J){let Y;try{Y=$.apply($,Z)}catch(X){if(J)process.nextTick(J,X);return}if(Q10(Y)&&!Y[G10])Y.then(()=>process.nextTick(J),(X)=>process.nextTick(J,X));else if(J)process.nextTick(J)}ER.exports={executeWithThenable:W10}});var gR=S((Pf0,hR)=>{var S4=JR(),K10=Y0("events").EventEmitter,V10=Y0("util").inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:RX,AVV_ERR_CALLBACK_NOT_FN:MJ,AVV_ERR_ROOT_PLG_BOOTED:U10,AVV_ERR_READY_TIMEOUT:H10,AVV_ERR_ATTRIBUTE_ALREADY_DEFINED:B10}=E4(),{kAvvio:fR,kIsOnCloseHandler:kR}=jJ(),{TimeTree:z10}=BR(),{Plugin:vR}=DR(),{debug:DJ}=b4(),{validatePlugin:F10}=LR(),{isBundledOrTypescriptPlugin:A10}=RR(),{isPromiseLike:O10}=_4(),{thenify:yR}=CR(),{executeWithThenable:_R}=bR();function Q$($,Z,J){if(typeof $==="function"&&arguments.length===1)J=$,Z={},$=null;if(typeof Z==="function")J=Z,Z={};if(Z=Z||{},Z.autostart=Z.autostart!==!1,Z.timeout=Number(Z.timeout)||0,Z.expose=Z.expose||{},!new.target)return new Q$($,Z,J);if(this._server=$||this,this._opts=Z,$)this._expose();if(this._current=[],this._error=null,this._lastUsed=null,this.setMaxListeners(0),J)this.once("start",J);this.started=!1,this.booted=!1,this.pluginTree=new z10,this._readyQ=S4(this,xR,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=SR},this._closeQ=S4(this,j10,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=SR},this._doStart=null;let Y=this;this._root=new vR(S4(this,this._loadPluginNextTick,1),function(Q,G,W){Y._doStart=W,G.autostart&&Y.start()},Z,!1,0),this._trackPluginLoading(this._root),this._loadPlugin(this._root,(X)=>{DJ("root plugin ready");try{this.emit("preReady"),this._root=null}catch(Q){X=X||this._error||Q}if(X){if(this._error=X,this._readyQ.length()===0)throw X}else this.booted=!0;this._readyQ.resume()})}V10(Q$,K10);if("asyncDispose"in Symbol)Q$.prototype[Symbol.asyncDispose]=function(){return new Promise(($,Z)=>{this.close((J)=>{if(J)return Z(J);$()})})};Q$.prototype.start=function(){return this.started=!0,process.nextTick(this._doStart),this};Q$.prototype.override=function($,Z,J){return $};Q$.prototype[fR]=!0;Q$.prototype.use=function($,Z){return this._lastUsed=this._addPlugin($,Z,!1),this};Q$.prototype._loadRegistered=function(){let $=this._current[0];if(!this.started&&!this.booted)process.nextTick(()=>this._root.queue.resume());if(!$)return Promise.resolve();return $.loadedSoFar()};Object.defineProperty(Q$.prototype,"then",{get:yR});Q$.prototype._addPlugin=function($,Z,J){if(A10($))$=$.default;if(F10($),Z=Z||{},this.booted)throw new U10;let Y=this._current[0],X=this._opts.timeout;if(!Y.loaded&&Y.timeout>0){let G=Date.now()-Y.startTime;X=Y.timeout-(G+3)}let Q=new vR(S4(this,this._loadPluginNextTick,1),$,Z,J,X);if(this._trackPluginLoading(Q),Y.loaded)throw Error(Q.name,Y.name);return Y.enqueue(Q,(G)=>{G&&(this._error=G)}),Q};Q$.prototype._expose=function(){let Z=this,J=Z._server,{use:Y="use",after:X="after",ready:Q="ready",onClose:G="onClose",close:W="close"}=this._opts.expose;if(J[Y])throw new RX(Y,"use");if(J[Y]=function(K,V){return Z.use(K,V),this},J[X])throw new RX(X,"after");if(J[X]=function(K){if(typeof K!=="function")return Z._loadRegistered();return Z.after(xH(K,this)),this},J[Q])throw new RX(Q,"ready");if(J[Q]=function(K){if(K&&typeof K!=="function")throw new MJ(Q,typeof K);return Z.ready(K?xH(K,this):void 0)},J[G])throw new RX(G,"onClose");if(J[G]=function(K){if(typeof K!=="function")throw new MJ(G,typeof K);return Z.onClose(N10(K,this)),this},J[W])throw new RX(W,"close");if(J[W]=function(K){if(K&&typeof K!=="function")throw new MJ(W,typeof K);if(K)return Z.close(xH(K,this)),this;return Z.close()},J.then)throw new B10("then");Object.defineProperty(J,"then",{get:yR.bind(Z)}),J[fR]=!0};Q$.prototype.after=function($){if(!$)return this._loadRegistered();this._addPlugin(Z.bind(this),{},!0);function Z(J,Y,X){xR.call(this,$,X)}return this};Q$.prototype.onClose=function($){if(typeof $!=="function")throw new MJ("onClose",typeof $);return $[kR]=!0,this._closeQ.unshift($,(Z)=>{Z&&(this._error=Z)}),this};Q$.prototype.close=function($){let Z;if($){if(typeof $!=="function")throw new MJ("close",typeof $)}else Z=new Promise(function(J,Y){$=function(X){if(X)return Y(X);J()}});return this.ready(()=>{this._error=null,this._closeQ.push($),process.nextTick(this._closeQ.resume.bind(this._closeQ))}),Z};Q$.prototype.ready=function($){if($){if(typeof $!=="function")throw new MJ("ready",typeof $);this._readyQ.push($),queueMicrotask(this.start.bind(this));return}return new Promise((Z,J)=>{this._readyQ.push(X),this.start();let Y=this._current[0].server;function X(Q,G,W){if(Q)J(Q);else Z(Y);process.nextTick(W)}})};Q$.prototype._trackPluginLoading=function($){let Z=this._current[0]?.name||null;$.once("start",(J,Y,X)=>{let Q=this.pluginTree.start(Z||null,Y,X);$.once("loaded",(G,W,K)=>{this.pluginTree.stop(Q,K)})})};Q$.prototype.prettyPrint=function(){return this.pluginTree.prettyPrint()};Q$.prototype.toJSON=function(){return this.pluginTree.toJSON()};Q$.prototype._loadPlugin=function($,Z){let J=this;if(O10($.func)){$.func.then((G)=>{if(typeof G.default==="function")G=G.default;$.func=G,this._loadPlugin($,Z)},Z);return}let Y=J._current[0];if(J._current.unshift($),J._error&&!$.isAfter){DJ("skipping loading of plugin as instance errored and it is not an after",$.name),process.nextTick(Q);return}let X=Y?.server||J._server;if(!$.isAfter)try{X=J.override(X,$.func,$.options)}catch(G){return DJ("override errored",$.name),Q(G)}$.exec(X,Q);function Q(G){$.finish(G,(W)=>{J._current.shift(),Z(W)})}};Q$.prototype._loadPluginNextTick=function($,Z){process.nextTick(this._loadPlugin.bind(this),$,Z)};function SR(){}function xR($,Z){let J=this._server,Y=this._error;if(this._error=null,$.length===0)this._error=Y,_R($,[],Z);else if($.length===1)_R($,[Y],Z);else if(this._opts.timeout===0){let X=(Q)=>{this._error=Q,Z(this._error)};if($.length===2)$(Y,X);else $(Y,J,X)}else q10.call(this,$,Y,J,Z)}function q10($,Z,J,Y){let X=$.unwrappedName??$.name;DJ("setting up ready timeout",X,this._opts.timeout);let Q=setTimeout(()=>{DJ("timed out",X),Q=null;let W=new H10(X);W.fn=$,this._error=W,Y(W)},this._opts.timeout);if($.length===2)$(Z,G.bind(this));else $(Z,J,G.bind(this));function G(W){if(Q)clearTimeout(Q),this._error=W,Y(this._error)}}function j10($,Z){let J=this._server,Y=$[kR];if($.length===0||$.length===1){let X;if(Y)X=$(J);else X=$(this._error);if(X&&typeof X.then==="function")DJ("resolving close/onClose promise"),X.then(()=>process.nextTick(Z),(Q)=>process.nextTick(Z,Q));else process.nextTick(Z)}else if($.length===2)if(Y)$(J,Z);else $(this._error,Z);else if(Y)$(J,Z);else $(this._error,J,Z)}function N10($,Z){return J.bind(Z);function J(Y,X){let Q;if($.length===0)if(Q=$(),Q?.then)Q.then(function(){process.nextTick(X)},X);else process.nextTick(X);else if($.length===1)if(Q=$(this),Q?.then)Q.then(function(){process.nextTick(X)},X);else process.nextTick(X);else $(this,X)}}function xH($,Z){let J=Y.bind(Z);return J.unwrappedName=$.name,J;function Y(X,Q){let G;if(!$)process.nextTick(Q);else if($.length===0)if(G=$(),G?.then)G.then(function(){process.nextTick(Q,X)},Q);else process.nextTick(Q,X);else if($.length===1)if(G=$(X),G?.then)G.then(function(){process.nextTick(Q)},Q);else process.nextTick(Q);else if($.length===2)$(X,Q);else $(X,this,Q)}}hR.exports=Q$});var H$=S((If0,uR)=>{var M10={kAvvioBoot:Symbol("fastify.avvioBoot"),kChildren:Symbol("fastify.children"),kServerBindings:Symbol("fastify.serverBindings"),kBodyLimit:Symbol("fastify.bodyLimit"),kSupportedHTTPMethods:Symbol("fastify.acceptedHTTPMethods"),kRoutePrefix:Symbol("fastify.routePrefix"),kLogLevel:Symbol("fastify.logLevel"),kLogSerializers:Symbol("fastify.logSerializers"),kHooks:Symbol("fastify.hooks"),kContentTypeParser:Symbol("fastify.contentTypeParser"),kState:Symbol("fastify.state"),kOptions:Symbol("fastify.options"),kDisableRequestLogging:Symbol("fastify.disableRequestLogging"),kPluginNameChain:Symbol("fastify.pluginNameChain"),kRouteContext:Symbol("fastify.context"),kGenReqId:Symbol("fastify.genReqId"),kHttp2ServerSessions:Symbol("fastify.http2ServerSessions"),kSchemaController:Symbol("fastify.schemaController"),kSchemaHeaders:Symbol("headers-schema"),kSchemaParams:Symbol("params-schema"),kSchemaQuerystring:Symbol("querystring-schema"),kSchemaBody:Symbol("body-schema"),kSchemaResponse:Symbol("response-schema"),kSchemaErrorFormatter:Symbol("fastify.schemaErrorFormatter"),kSchemaVisited:Symbol("fastify.schemas.visited"),kRequest:Symbol("fastify.Request"),kRequestPayloadStream:Symbol("fastify.RequestPayloadStream"),kRequestAcceptVersion:Symbol("fastify.RequestAcceptVersion"),kRequestCacheValidateFns:Symbol("fastify.request.cache.validateFns"),kRequestOriginalUrl:Symbol("fastify.request.originalUrl"),kRequestSignal:Symbol("fastify.request.signal"),kHandlerTimeout:Symbol("fastify.handlerTimeout"),kTimeoutTimer:Symbol("fastify.request.timeoutTimer"),kOnAbort:Symbol("fastify.request.onAbort"),kFourOhFour:Symbol("fastify.404"),kCanSetNotFoundHandler:Symbol("fastify.canSetNotFoundHandler"),kFourOhFourLevelInstance:Symbol("fastify.404LogLevelInstance"),kFourOhFourContext:Symbol("fastify.404ContextKey"),kDefaultJsonParse:Symbol("fastify.defaultJSONParse"),kReply:Symbol("fastify.Reply"),kReplySerializer:Symbol("fastify.reply.serializer"),kReplyIsError:Symbol("fastify.reply.isError"),kReplyHeaders:Symbol("fastify.reply.headers"),kReplyTrailers:Symbol("fastify.reply.trailers"),kReplyHasStatusCode:Symbol("fastify.reply.hasStatusCode"),kReplyHijacked:Symbol("fastify.reply.hijacked"),kReplyStartTime:Symbol("fastify.reply.startTime"),kReplyNextErrorHandler:Symbol("fastify.reply.nextErrorHandler"),kReplyEndTime:Symbol("fastify.reply.endTime"),kReplyErrorHandlerCalled:Symbol("fastify.reply.errorHandlerCalled"),kReplyIsRunningOnErrorHook:Symbol("fastify.reply.isRunningOnErrorHook"),kReplySerializerDefault:Symbol("fastify.replySerializerDefault"),kReplyCacheSerializeFns:Symbol("fastify.reply.cache.serializeFns"),kTestInternals:Symbol("fastify.testInternals"),kErrorHandler:Symbol("fastify.errorHandler"),kErrorHandlerAlreadySet:Symbol("fastify.errorHandlerAlreadySet"),kChildLoggerFactory:Symbol("fastify.childLoggerFactory"),kHasBeenDecorated:Symbol("fastify.hasBeenDecorated"),kKeepAliveConnections:Symbol("fastify.keepAliveConnections"),kRouteByFastify:Symbol("fastify.routeByFastify")};uR.exports=M10});var lR=S((Cf0,f4)=>{var{format:hH}=Y0("util");function D10($){return mR({...$,name:"DeprecationWarning"})}function mR({name:$,code:Z,message:J,unlimited:Y=!1}={}){if(!$)throw Error("Warning name must not be empty");if(!Z)throw Error("Warning code must not be empty");if(!J)throw Error("Warning message must not be empty");if(typeof Y!=="boolean")throw Error("Warning opts.unlimited must be a boolean");Z=Z.toUpperCase();let X={[$]:function(G,W,K){if(Q.emitted===!0&&Q.unlimited!==!0)return;Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};if(Y)X={[$]:function(G,W,K){Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};let Q=X[$];return Q.emitted=!1,Q.message=J,Q.unlimited=Y,Q.code=Z,Q.format=function(G,W,K){let V;if(G&&W&&K)V=hH(J,G,W,K);else if(G&&W)V=hH(J,G,W);else if(G)V=hH(J,G);else V=J;return V},Q}var gH={createWarning:mR,createDeprecation:D10};f4.exports=gH;f4.exports.default=gH;f4.exports.processWarning=gH});var wJ=S((Ef0,dR)=>{var{createWarning:PX}=lR(),w10=PX({name:"FastifyWarning",code:"FSTWRN001",message:"The %s schema for %s: %s is missing. This may indicate the schema is not well specified.",unlimited:!0}),L10=PX({name:"FastifyWarning",code:"FSTWRN003",message:"The %s mixes async and callback styles that may lead to unhandled rejections. Please use only one of them.",unlimited:!0}),T10=PX({name:"FastifyWarning",code:"FSTWRN004",message:"It seems that you are overriding an errorHandler in the same scope, which can lead to subtle bugs.",unlimited:!0}),R10=PX({name:"FastifySecurity",code:"FSTSEC001",message:'You are using /%s/ Content-Type which may be vulnerable to CORS attack. Please make sure your RegExp start with "^" or include ";?" to proper detection of the essence MIME type.',unlimited:!0}),P10=PX({name:"FastifyWarning",code:"FSTDEP022",message:'The router options for %s property access is deprecated. Please use "options.routerOptions" instead for accessing router options. The router options will be removed in `fastify@6`.',unlimited:!0});dR.exports={FSTWRN001:w10,FSTWRN003:L10,FSTWRN004:T10,FSTSEC001:R10,FSTDEP022:P10}});var L$=S((bf0,k4)=>{var W0=fH(),d5={FST_ERR_NOT_FOUND:W0("FST_ERR_NOT_FOUND","Not Found",404),FST_ERR_OPTIONS_NOT_OBJ:W0("FST_ERR_OPTIONS_NOT_OBJ","Options must be an object",500,TypeError),FST_ERR_QSP_NOT_FN:W0("FST_ERR_QSP_NOT_FN","querystringParser option should be a function, instead got '%s'",500,TypeError),FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN:W0("FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN","schemaController.bucket option should be a function, instead got '%s'",500,TypeError),FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN:W0("FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN","schemaErrorFormatter option should be a non async function. Instead got '%s'.",500,TypeError),FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ:W0("FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ","ajv.customOptions option should be an object, instead got '%s'",500,TypeError),FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR:W0("FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR","ajv.plugins option should be an array, instead got '%s'",500,TypeError),FST_ERR_VALIDATION:W0("FST_ERR_VALIDATION","%s",400),FST_ERR_LISTEN_OPTIONS_INVALID:W0("FST_ERR_LISTEN_OPTIONS_INVALID","Invalid listen options: '%s'",500,TypeError),FST_ERR_ERROR_HANDLER_NOT_FN:W0("FST_ERR_ERROR_HANDLER_NOT_FN","Error Handler must be a function",500,TypeError),FST_ERR_ERROR_HANDLER_ALREADY_SET:W0("FST_ERR_ERROR_HANDLER_ALREADY_SET","Error Handler already set in this scope. Set 'allowErrorHandlerOverride: true' to allow overriding.",500,TypeError),FST_ERR_CTP_ALREADY_PRESENT:W0("FST_ERR_CTP_ALREADY_PRESENT","Content type parser '%s' already present."),FST_ERR_CTP_INVALID_TYPE:W0("FST_ERR_CTP_INVALID_TYPE","The content type should be a string or a RegExp",500,TypeError),FST_ERR_CTP_EMPTY_TYPE:W0("FST_ERR_CTP_EMPTY_TYPE","The content type cannot be an empty string",500,TypeError),FST_ERR_CTP_INVALID_HANDLER:W0("FST_ERR_CTP_INVALID_HANDLER","The content type handler should be a function",500,TypeError),FST_ERR_CTP_INVALID_PARSE_TYPE:W0("FST_ERR_CTP_INVALID_PARSE_TYPE","The body parser can only parse your data as 'string' or 'buffer', you asked '%s' which is not supported.",500,TypeError),FST_ERR_CTP_BODY_TOO_LARGE:W0("FST_ERR_CTP_BODY_TOO_LARGE","Request body is too large",413,RangeError),FST_ERR_CTP_INVALID_MEDIA_TYPE:W0("FST_ERR_CTP_INVALID_MEDIA_TYPE","Unsupported Media Type",415),FST_ERR_CTP_INVALID_CONTENT_LENGTH:W0("FST_ERR_CTP_INVALID_CONTENT_LENGTH","Request body size did not match Content-Length",400,RangeError),FST_ERR_CTP_EMPTY_JSON_BODY:W0("FST_ERR_CTP_EMPTY_JSON_BODY","Body cannot be empty when content-type is set to 'application/json'",400),FST_ERR_CTP_INVALID_JSON_BODY:W0("FST_ERR_CTP_INVALID_JSON_BODY","Body is not valid JSON but content-type is set to 'application/json'",400),FST_ERR_CTP_INSTANCE_ALREADY_STARTED:W0("FST_ERR_CTP_INSTANCE_ALREADY_STARTED",'Cannot call "%s" when fastify instance is already started!',400),FST_ERR_DEC_ALREADY_PRESENT:W0("FST_ERR_DEC_ALREADY_PRESENT","The decorator '%s' has already been added!"),FST_ERR_DEC_DEPENDENCY_INVALID_TYPE:W0("FST_ERR_DEC_DEPENDENCY_INVALID_TYPE","The dependencies of decorator '%s' must be of type Array.",500,TypeError),FST_ERR_DEC_MISSING_DEPENDENCY:W0("FST_ERR_DEC_MISSING_DEPENDENCY","The decorator is missing dependency '%s'."),FST_ERR_DEC_AFTER_START:W0("FST_ERR_DEC_AFTER_START","The decorator '%s' has been added after start!"),FST_ERR_DEC_REFERENCE_TYPE:W0("FST_ERR_DEC_REFERENCE_TYPE","The decorator '%s' of type '%s' is a reference type. Use the { getter, setter } interface instead."),FST_ERR_DEC_UNDECLARED:W0("FST_ERR_DEC_UNDECLARED","No decorator '%s' has been declared on %s."),FST_ERR_HOOK_INVALID_TYPE:W0("FST_ERR_HOOK_INVALID_TYPE","The hook name must be a string",500,TypeError),FST_ERR_HOOK_INVALID_HANDLER:W0("FST_ERR_HOOK_INVALID_HANDLER","%s hook should be a function, instead got %s",500,TypeError),FST_ERR_HOOK_INVALID_ASYNC_HANDLER:W0("FST_ERR_HOOK_INVALID_ASYNC_HANDLER","Async function has too many arguments. Async hooks should not use the 'done' argument.",500,TypeError),FST_ERR_HOOK_NOT_SUPPORTED:W0("FST_ERR_HOOK_NOT_SUPPORTED","%s hook not supported!",500,TypeError),FST_ERR_MISSING_MIDDLEWARE:W0("FST_ERR_MISSING_MIDDLEWARE","You must register a plugin for handling middlewares, visit fastify.dev/docs/latest/Reference/Middleware/ for more info.",500),FST_ERR_HOOK_TIMEOUT:W0("FST_ERR_HOOK_TIMEOUT","A callback for '%s' hook%s timed out. You may have forgotten to call 'done' function or to resolve a Promise"),FST_ERR_LOG_INVALID_DESTINATION:W0("FST_ERR_LOG_INVALID_DESTINATION","Cannot specify both logger.stream and logger.file options"),FST_ERR_LOG_INVALID_LOGGER:W0("FST_ERR_LOG_INVALID_LOGGER","Invalid logger object provided. The logger instance should have these functions(s): '%s'.",500,TypeError),FST_ERR_LOG_INVALID_LOGGER_INSTANCE:W0("FST_ERR_LOG_INVALID_LOGGER_INSTANCE","loggerInstance only accepts a logger instance.",500,TypeError),FST_ERR_LOG_INVALID_LOGGER_CONFIG:W0("FST_ERR_LOG_INVALID_LOGGER_CONFIG","logger options only accepts a configuration object.",500,TypeError),FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED:W0("FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED","You cannot provide both logger and loggerInstance. Please provide only one.",500,TypeError),FST_ERR_REP_INVALID_PAYLOAD_TYPE:W0("FST_ERR_REP_INVALID_PAYLOAD_TYPE","Attempted to send payload of invalid type '%s'. Expected a string or Buffer.",500,TypeError),FST_ERR_REP_RESPONSE_BODY_CONSUMED:W0("FST_ERR_REP_RESPONSE_BODY_CONSUMED","Response.body is already consumed."),FST_ERR_REP_READABLE_STREAM_LOCKED:W0("FST_ERR_REP_READABLE_STREAM_LOCKED","ReadableStream was locked. You should call releaseLock() method on reader before sending."),FST_ERR_REP_ALREADY_SENT:W0("FST_ERR_REP_ALREADY_SENT",'Reply was already sent, did you forget to "return reply" in "%s" (%s)?'),FST_ERR_REP_SENT_VALUE:W0("FST_ERR_REP_SENT_VALUE","The only possible value for reply.sent is true.",500,TypeError),FST_ERR_SEND_INSIDE_ONERR:W0("FST_ERR_SEND_INSIDE_ONERR","You cannot use `send` inside the `onError` hook"),FST_ERR_SEND_UNDEFINED_ERR:W0("FST_ERR_SEND_UNDEFINED_ERR","Undefined error has occurred"),FST_ERR_BAD_STATUS_CODE:W0("FST_ERR_BAD_STATUS_CODE","Called reply with an invalid status code: %s"),FST_ERR_BAD_TRAILER_NAME:W0("FST_ERR_BAD_TRAILER_NAME","Called reply.trailer with an invalid header name: %s"),FST_ERR_BAD_TRAILER_VALUE:W0("FST_ERR_BAD_TRAILER_VALUE","Called reply.trailer('%s', fn) with an invalid type: %s. Expected a function."),FST_ERR_FAILED_ERROR_SERIALIZATION:W0("FST_ERR_FAILED_ERROR_SERIALIZATION","Failed to serialize an error. Error: %s. Original error: %s"),FST_ERR_MISSING_SERIALIZATION_FN:W0("FST_ERR_MISSING_SERIALIZATION_FN",'Missing serialization function. Key "%s"'),FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN:W0("FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN",'Missing serialization function. Key "%s:%s"'),FST_ERR_REQ_INVALID_VALIDATION_INVOCATION:W0("FST_ERR_REQ_INVALID_VALIDATION_INVOCATION",'Invalid validation invocation. Missing validation function for HTTP part "%s" nor schema provided.'),FST_ERR_SCH_MISSING_ID:W0("FST_ERR_SCH_MISSING_ID","Missing schema $id property"),FST_ERR_SCH_ALREADY_PRESENT:W0("FST_ERR_SCH_ALREADY_PRESENT","Schema with id '%s' already declared!"),FST_ERR_SCH_CONTENT_MISSING_SCHEMA:W0("FST_ERR_SCH_CONTENT_MISSING_SCHEMA","Schema is missing for the content type '%s'"),FST_ERR_SCH_DUPLICATE:W0("FST_ERR_SCH_DUPLICATE","Schema with '%s' already present!"),FST_ERR_SCH_VALIDATION_BUILD:W0("FST_ERR_SCH_VALIDATION_BUILD","Failed building the validation schema for %s: %s, due to error %s"),FST_ERR_SCH_SERIALIZATION_BUILD:W0("FST_ERR_SCH_SERIALIZATION_BUILD","Failed building the serialization schema for %s: %s, due to error %s"),FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX:W0("FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX",'response schemas should be nested under a valid status code, e.g { 2xx: { type: "object" } }'),FST_ERR_INIT_OPTS_INVALID:W0("FST_ERR_INIT_OPTS_INVALID","Invalid initialization options: '%s'"),FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE:W0("FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE","Cannot set forceCloseConnections to 'idle' as your HTTP server does not support closeIdleConnections method"),FST_ERR_DUPLICATED_ROUTE:W0("FST_ERR_DUPLICATED_ROUTE","Method '%s' already declared for route '%s'"),FST_ERR_BAD_URL:W0("FST_ERR_BAD_URL","'%s' is not a valid url component",400,URIError),FST_ERR_ASYNC_CONSTRAINT:W0("FST_ERR_ASYNC_CONSTRAINT","Unexpected error from async constraint",500),FST_ERR_INVALID_URL:W0("FST_ERR_INVALID_URL","URL must be a string. Received '%s'",400,TypeError),FST_ERR_ROUTE_OPTIONS_NOT_OBJ:W0("FST_ERR_ROUTE_OPTIONS_NOT_OBJ",'Options for "%s:%s" route must be an object',500,TypeError),FST_ERR_ROUTE_DUPLICATED_HANDLER:W0("FST_ERR_ROUTE_DUPLICATED_HANDLER",'Duplicate handler for "%s:%s" route is not allowed!',500),FST_ERR_ROUTE_HANDLER_NOT_FN:W0("FST_ERR_ROUTE_HANDLER_NOT_FN","Error Handler for %s:%s route, if defined, must be a function",500,TypeError),FST_ERR_ROUTE_MISSING_HANDLER:W0("FST_ERR_ROUTE_MISSING_HANDLER",'Missing handler function for "%s:%s" route.',500),FST_ERR_ROUTE_METHOD_INVALID:W0("FST_ERR_ROUTE_METHOD_INVALID","Provided method is invalid!",500,TypeError),FST_ERR_ROUTE_METHOD_NOT_SUPPORTED:W0("FST_ERR_ROUTE_METHOD_NOT_SUPPORTED","%s method is not supported.",500),FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED:W0("FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED","Body validation schema for %s:%s route is not supported!",500),FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT:W0("FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT","'bodyLimit' option must be an integer > 0. Got '%s'",500,TypeError),FST_ERR_HANDLER_TIMEOUT:W0("FST_ERR_HANDLER_TIMEOUT","Request timed out after %s ms on route '%s'",503),FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT:W0("FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT","'handlerTimeout' option must be an integer > 0. Got '%s'",500,TypeError),FST_ERR_ROUTE_REWRITE_NOT_STR:W0("FST_ERR_ROUTE_REWRITE_NOT_STR",'Rewrite url for "%s" needs to be of type "string" but received "%s"',500,TypeError),FST_ERR_REOPENED_CLOSE_SERVER:W0("FST_ERR_REOPENED_CLOSE_SERVER","Fastify has already been closed and cannot be reopened"),FST_ERR_REOPENED_SERVER:W0("FST_ERR_REOPENED_SERVER","Fastify is already listening"),FST_ERR_INSTANCE_ALREADY_LISTENING:W0("FST_ERR_INSTANCE_ALREADY_LISTENING","Fastify instance is already listening. %s"),FST_ERR_PLUGIN_VERSION_MISMATCH:W0("FST_ERR_PLUGIN_VERSION_MISMATCH","fastify-plugin: %s - expected '%s' fastify version, '%s' is installed"),FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE:W0("FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE","The decorator '%s'%s is not present in %s"),FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER:W0("FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER","The %s plugin being registered mixes async and callback styles. Async plugin should not mix async and callback style.",500,TypeError),FST_ERR_PLUGIN_CALLBACK_NOT_FN:W0("FST_ERR_PLUGIN_CALLBACK_NOT_FN","fastify-plugin: %s",500,TypeError),FST_ERR_PLUGIN_NOT_VALID:W0("FST_ERR_PLUGIN_NOT_VALID","fastify-plugin: %s"),FST_ERR_ROOT_PLG_BOOTED:W0("FST_ERR_ROOT_PLG_BOOTED","fastify-plugin: %s"),FST_ERR_PARENT_PLUGIN_BOOTED:W0("FST_ERR_PARENT_PLUGIN_BOOTED","fastify-plugin: %s"),FST_ERR_PLUGIN_TIMEOUT:W0("FST_ERR_PLUGIN_TIMEOUT","fastify-plugin: %s")};function I10($,Z){return Z.cause=$,Z}k4.exports=d5;k4.exports.appendStackTrace=I10;k4.exports.AVVIO_ERRORS_MAP={AVV_ERR_CALLBACK_NOT_FN:d5.FST_ERR_PLUGIN_CALLBACK_NOT_FN,AVV_ERR_PLUGIN_NOT_VALID:d5.FST_ERR_PLUGIN_NOT_VALID,AVV_ERR_ROOT_PLG_BOOTED:d5.FST_ERR_ROOT_PLG_BOOTED,AVV_ERR_PARENT_PLG_LOADED:d5.FST_ERR_PARENT_PLUGIN_BOOTED,AVV_ERR_READY_TIMEOUT:d5.FST_ERR_PLUGIN_TIMEOUT,AVV_ERR_PLUGIN_EXEC_TIMEOUT:d5.FST_ERR_PLUGIN_TIMEOUT}});var uZ=S((_f0,tR)=>{var C10=["onRoute","onRegister","onReady","onListen","preClose","onClose"],nR=["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError","onRequestAbort"],E10=nR.concat(C10),{FST_ERR_HOOK_INVALID_TYPE:b10,FST_ERR_HOOK_INVALID_HANDLER:_10,FST_ERR_SEND_UNDEFINED_ERR:v4,FST_ERR_HOOK_TIMEOUT:S10,FST_ERR_HOOK_NOT_SUPPORTED:f10,AVVIO_ERRORS_MAP:pR,appendStackTrace:cR}=L$(),{kChildren:IX,kHooks:oR,kRequestPayloadStream:iR}=H$();function CX(){this.onRequest=[],this.preParsing=[],this.preValidation=[],this.preSerialization=[],this.preHandler=[],this.onResponse=[],this.onSend=[],this.onError=[],this.onRoute=[],this.onRegister=[],this.onReady=[],this.onListen=[],this.onTimeout=[],this.onRequestAbort=[],this.preClose=[]}CX.prototype=Object.create(null);CX.prototype.validate=function($,Z){if(typeof $!=="string")throw new b10;if(Array.isArray(this[$])===!1)throw new f10($);if(typeof Z!=="function")throw new _10($,Object.prototype.toString.call(Z))};CX.prototype.add=function($,Z){this.validate($,Z),this[$].push(Z)};function k10($){let Z=new CX;return Z.onRequest=$.onRequest.slice(),Z.preParsing=$.preParsing.slice(),Z.preValidation=$.preValidation.slice(),Z.preSerialization=$.preSerialization.slice(),Z.preHandler=$.preHandler.slice(),Z.onSend=$.onSend.slice(),Z.onResponse=$.onResponse.slice(),Z.onError=$.onError.slice(),Z.onRoute=$.onRoute.slice(),Z.onRegister=$.onRegister.slice(),Z.onTimeout=$.onTimeout.slice(),Z.onRequestAbort=$.onRequestAbort.slice(),Z.onReady=[],Z.onListen=[],Z.preClose=[],Z}function sR($,Z,J,Y){let X=J[oR][$],Q=0,G=0;K();function W(U){let H=X[Q-1]?.name,B=H?` "${H}"`:"";if(U){if(U.code==="AVV_ERR_READY_TIMEOUT")U=cR(U,new S10($,B));else U=pR[U.code]!=null?cR(U,new pR[U.code](U.message)):U;Y(U);return}Y()}function K(U){if(U){W(U);return}if(Q===X.length&&G===J[IX].length){if(Q===0&&G===0)W();else Z(function(B,z){W(B),z(B)});return}if(Q===X.length&&G<J[IX].length){let H=J[IX][G++];sR($,Z,H,K);return}Z(V(X[Q++],J)),K()}function V(U,H){return function(B,z){if(B){z(B);return}if(U.length===1){try{U.call(H,z)}catch(F){z(F)}return}try{let F=U.call(H);if(F&&typeof F.then==="function"){F.then(z,z);return}}catch(F){B=F}z(B)}}}function rR($){let Z=$[oR].onListen,J=Z.length,Y=0,X=0;Q();function Q(W){if(W&&$.log.error(W),Y===J){while(X<$[IX].length){let K=$[IX][X++];rR(K)}return}G(Z[Y++],$,Q)}async function G(W,K,V){if(W.length===1){try{W.call(K,V)}catch(U){V(U)}return}try{let U=W.call(K);if(U&&typeof U.then==="function"){U.then(V,V);return}V()}catch(U){V(U)}}}function LJ($){return function(J,Y,X,Q){let G=0;function W(U){if(U||G===J.length){Q(U,Y,X);return}let H;try{H=$(J[G++],Y,X,W)}catch(B){Q(B,Y,X);return}if(H&&typeof H.then==="function")H.then(K,V)}function K(){W()}function V(U){if(!U)U=new v4;Q(U,Y,X)}W()}}function v10($,Z,J,Y){return $(Z,J,Y)}var y10=LJ(v10),x10=LJ(EX),h10=LJ(EX),g10=LJ(EX),u10=LJ(EX);function aR($,Z,J,Y,X){let Q=0;function G(V,U){if(V){X(V,Z,J,Y);return}if(U!==void 0)Y=U;if(Q===$.length){X(null,Z,J,Y);return}let H;try{H=$[Q++](Z,J,Y,G)}catch(B){X(B,Z,J);return}if(H&&typeof H.then==="function")H.then(W,K)}function W(V){G(null,V)}function K(V){if(!V)V=new v4;X(V,Z,J,Y)}G()}var m10=aR;function l10($,Z,J,Y){let X=0;function Q(K,V){if(J.sent)return;if(V!==void 0)Z[iR]=V;if(K||X===$.length){Y(K,Z,J);return}let U;try{U=$[X++](Z,J,Z[iR],Q)}catch(H){Y(H,Z,J);return}if(U&&typeof U.then==="function")U.then(G,W)}function G(K){Q(null,K)}function W(K){if(!K)K=new v4;Y(K,Z,J)}Q()}function d10($,Z,J){let Y=0;function X(W){if(W||Y===$.length){J(W,Z);return}let K;try{K=$[Y++](Z,X)}catch(V){J(V,Z);return}if(K&&typeof K.then==="function")K.then(Q,G)}function Q(){X()}function G(W){if(!W)W=new v4;J(W,Z)}X()}function EX($,Z,J,Y){if(J.sent===!0)return;return $(Z,J,Y)}tR.exports={Hooks:CX,buildHooks:k10,hookRunnerGenerator:LJ,preParsingHookRunner:l10,onResponseHookRunner:y10,onSendHookRunner:aR,preSerializationHookRunner:m10,onRequestAbortHookRunner:d10,hookIterator:EX,hookRunnerApplication:sR,onListenHookRunner:rR,preHandlerHookRunner:h10,preValidationHookRunner:x10,onRequestHookRunner:u10,onTimeoutHookRunner:g10,lifecycleHooks:nR,supportedHooks:E10}});var $P=S((Sf0,eR)=>{eR.exports=function(){return{[Symbol.iterator]:function*(){},add(){},delete(){},has(){return!0}}}});var uH=S((ff0,JP)=>{var{kTestInternals:p10}=H$();function ZP(){let $,Z;return{promise:new Promise((Y,X)=>{$=Y,Z=X}),resolve:$,reject:Z}}JP.exports={withResolvers:typeof Promise.withResolvers==="function"?Promise.withResolvers.bind(Promise):ZP,[p10]:{withResolvers:ZP}}});var zP=S((Q$0,BP)=>{var c10=Y0("http"),i10=Y0("https"),YP=Y0("http2"),n10=Y0("dns"),o10=Y0("os"),{kState:G$,kOptions:s10,kServerBindings:r10,kHttp2ServerSessions:p5}=H$(),{FSTWRN003:a10}=wJ(),{onListenHookRunner:y4}=uZ(),{FST_ERR_REOPENED_CLOSE_SERVER:QP,FST_ERR_REOPENED_SERVER:GP,FST_ERR_LISTEN_OPTIONS_INVALID:t10,FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE:e10}=L$(),$$0=$P(),WP=uH();Q$0.createServer=Z$0;function KP($){return`Server listening at ${$}`}function Z$0($,Z){let J=UP($,Z);function Y(V={port:0,host:"localhost"},U=void 0){if(typeof U==="function"){if(U.constructor.name==="AsyncFunction")a10("listen method");V.cb=U}if(V.signal){if(typeof V.signal.on!=="function"&&typeof V.signal.addEventListener!=="function")throw new t10("Invalid options.signal");if(this[G$].aborted=V.signal.aborted,this[G$].aborted)return this.close();else{let B=()=>{this[G$].aborted=!0,this.close()};V.signal.addEventListener("abort",B,{once:!0})}}let H;if(V.path==null)H=V.host??"localhost";else H=V.host;if(!Object.hasOwn(V,"host")||V.host==null)V.host=H;if(H==="localhost")V.cb=(B,z)=>{if(B){U(B,z);return}XP.call(this,J,Z,$,V,()=>{this[G$].listening=!0,U(null,z),y4(this)})};else V.cb=(B,z)=>{if(B){U(B,z);return}this[G$].listening=!0,U(null,z),y4(this)};if(U===void 0)return J$0.call(this,J,V).then((z)=>{let{promise:F,resolve:A}=WP.withResolvers();if(H==="localhost")XP.call(this,J,Z,$,V,()=>{this[G$].listening=!0,A(z),y4(this)});else A(z),y4(this);return F});this.ready(VP.call(this,J,V))}let X=typeof J.closeAllConnections==="function",Q=typeof J.closeIdleConnections==="function",G=typeof J.closeHttp2Sessions==="function",W=$.forceCloseConnections;if(W==="idle"&&!Q)throw new e10;else if(typeof W!=="boolean")W=Q?"idle":!1;let K=!X&&W===!0?new Set:$$0();return{server:J,listen:Y,forceCloseConnections:W,serverHasCloseAllConnections:X,serverHasCloseHttp2Sessions:G,keepAliveConnections:K}}function XP($,Z,J,Y,X){this[G$].listening=!1,n10.lookup(Y.host,{all:!0},(Q,G)=>{if(Q||this[G$].aborted){X();return}let W=$.listening&&J.serverFactory,K=0,V=0;if(!W){let H=$.address();for(let B of G)if(B.address!==H.address){K++;let z=Object.assign({},Y,{host:B.address,port:H.port,cb:(j)=>{if(V++,!j)this[r10].push(F);if(V===K)X()}}),F=UP(J,Z),A=()=>{if(F.close(()=>{}),typeof F.closeAllConnections==="function"&&J.forceCloseConnections===!0)F.closeAllConnections();if(typeof F.closeHttp2Sessions==="function")F.closeHttp2Sessions()};F.on("upgrade",$.emit.bind($,"upgrade")),$.on("unref",A),$.on("close",A),$.on("error",A),this[G$].listening=!1,VP.call(this,F,z)()}}if(K===0){X();return}let U=$.unref;$.unref=function(){U.call($),$.emit("unref")}})}function VP($,Z){let J=(Y)=>{if($.removeListener("error",J),$.removeListener("listening",J),!Y){let X=HP.call(this,$,Z.listenTextResolver||KP);Z.cb(null,X)}else this[G$].listening=!1,Z.cb(Y,null)};return(Y)=>{if(Y!=null)return Z.cb(Y);if(this[G$].listening&&this[G$].closing)return Z.cb(new QP,null);if(this[G$].listening)return Z.cb(new GP,null);if($.once("error",J),!this[G$].closing)$.once("listening",J),$.listen(Z),this[G$].listening=!0}}function J$0($,Z){if(this[G$].listening&&this[G$].closing)return Promise.reject(new QP);if(this[G$].listening)return Promise.reject(new GP);return this.ready().then(()=>{if(this[G$].aborted)return;let{promise:J,resolve:Y,reject:X}=WP.withResolvers(),Q=(K)=>{W(),this[G$].listening=!1,X(K)},G=()=>{W(),this[G$].listening=!0,Y(HP.call(this,$,Z.listenTextResolver||KP))};function W(){$.removeListener("error",Q),$.removeListener("listening",G)}return $.once("error",Q),$.once("listening",G),$.listen(Z),J})}function UP($,Z){if($.serverFactory)return $.serverFactory(Z,$);let J=$.https===!0?{}:$.https;if($.http2){let X=typeof J==="object"?YP.createSecureServer(J,Z):YP.createServer($.http,Z);if(X.on("session",(Q)=>Q.setTimeout($.http2SessionTimeout,()=>{Q.close()})),$.forceCloseConnections===!0)X.closeHttp2Sessions=X$0(X);return X.setTimeout($.connectionTimeout),X}let Y=J?i10.createServer(J,Z):c10.createServer($.http,Z);if(Y.keepAliveTimeout=$.keepAliveTimeout,Y.requestTimeout=$.requestTimeout,Y.setTimeout($.connectionTimeout),$.maxRequestsPerSocket>0)Y.maxRequestsPerSocket=$.maxRequestsPerSocket;return Y}function Y$0($){if($.address==="0.0.0.0")return Object.values(o10.networkInterfaces()).flatMap((Z)=>{return Z.filter((J)=>J.family==="IPv4")}).sort((Z)=>{return Z.internal?-1:1}).map((Z)=>{return Z.address});return[$.address]}function HP($,Z){let J;if(typeof $.address()!=="string"){if($.address().address.indexOf(":")===-1)J=Y$0($.address()).map((X)=>X+":"+$.address().port);else J=["["+$.address().address+"]:"+$.address().port];J=J.map((X)=>"http"+(this[s10].https?"s":"")+"://"+X)}else J=[$.address()];for(let X of J)this.log.info(Z(X));return J[0]}function X$0($){return $[p5]=new Set,$.on("session",function(Z){Z.once("connect",function(){$[p5].add(Z)}),Z.once("close",function(){$[p5].delete(Z)}),Z.once("frameError",function(J,Y,X){if(X===0)$[p5].delete(Z)}),Z.once("goaway",function(){$[p5].delete(Z)})}),function(){if($[p5].size===0)return;for(let J of $[p5])J.close()}}});var lH=S((kf0,qP)=>{var mH=/(?:^|;)\s*([\w!#$%&'*+.^`|~-]+)=([^;]*)/gm,FP=/^[\w!#$%&'*+.^`|~-]+$/,AP=/^[\w!#$%&'*+.^`|~-]+\s*$/;class OP{#$=!1;#Z=!0;#J="";#Y="";#X=new Map;#Q;constructor($){if($==null||$===""||$==="undefined")return;let Z=$.indexOf(";");if(Z===-1){if(Z=$.indexOf("/"),Z===-1)return;let W=$.slice(0,Z).trimStart().toLowerCase(),K=$.slice(Z+1).trimEnd().toLowerCase();if(FP.test(W)===!0&&AP.test(K)===!0)this.#$=!0,this.#Z=!1,this.#J=W,this.#Y=K;return}let J=$.slice(0,Z).toLowerCase(),Y=$.slice(Z+1).trim();if(Z=J.indexOf("/"),Z===-1)return;let X=J.slice(0,Z).trimStart(),Q=J.slice(Z+1).trimEnd();if(FP.test(X)===!1||AP.test(Q)===!1)return;this.#J=X,this.#Y=Q,this.#$=!0,this.#Z=!1;let G=mH.exec(Y);while(G){let W=G[1],K=G[2];if(K[0]==='"'){if(K.at(-1)!=='"'){this.#X.set(W,"invalid quoted string"),G=mH.exec(Y);continue}this.#X.set(W,K.slice(1,K.length-1))}else this.#X.set(W,K);G=mH.exec(Y)}}get[Symbol.toStringTag](){return"ContentType"}get isEmpty(){return this.#Z}get isValid(){return this.#$}get mediaType(){return`${this.#J}/${this.#Y}`}get type(){return this.#J}get subtype(){return this.#Y}get parameters(){return this.#X}toString(){if(this.#Q)return this.#Q;let $=[];for(let[J,Y]of this.#X.entries())$.push(`${J}="${Y}"`);let Z=[this.#J,"/",this.#Y];if($.length>0)Z.push("; "),Z.push($.join("; "));return this.#Q=Z.join(""),this.#Q}}qP.exports=OP});var x4=S((vf0,jP)=>{var{kReplyHasStatusCode:W$0}=H$();function K$0($,Z){if(!$[W$0]||$.statusCode===200){let J=Z&&(Z.statusCode||Z.status);$.code(J>=400?J:500)}}jP.exports={setErrorStatusCode:K$0}});var dH=S((yf0,MP)=>{var{kReplyIsError:NP,kReplyHijacked:V$0}=H$(),{setErrorStatusCode:U$0}=x4(),H$0=Y0("diagnostics_channel"),bX=H$0.tracingChannel("fastify.request.handler");function B$0($,Z,J){if(J)J.async=!0;$.then(function(Y){if(Z[V$0]===!0)return;if(J)bX.asyncStart.publish(J);try{if(Y!==void 0||Z.sent===!1&&Z.raw.headersSent===!1&&Z.request.raw.aborted===!1&&Z.request.socket&&!Z.request.socket.destroyed)try{Z.send(Y)}catch(X){Z[NP]=!0,Z.send(X)}}finally{if(J)bX.asyncEnd.publish(J)}},function(Y){if(J)J.error=Y,U$0(Z,Y),bX.error.publish(J),bX.asyncStart.publish(J);try{if(Z.sent===!0){Z.log.error({err:Y},"Promise errored, but reply.sent = true was set");return}Z[NP]=!0,Z.send(Y)}catch(X){Z.send(X)}finally{if(J)bX.asyncEnd.publish(J)}})}MP.exports=B$0});var iH=S((xf0,wP)=>{var{kSchemaHeaders:u4,kSchemaParams:pH,kSchemaQuerystring:cH,kSchemaBody:c5,kSchemaResponse:DP}=H$(),z$0=/^[1-5](?:\d{2}|xx)$|^default$/,{FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX:F$0}=L$(),{FSTWRN001:h4}=wJ();function A$0($,Z){if(!$.schema||!$.schema.response)return;let{method:J,url:Y}=$.config||{};$[DP]=Object.keys($.schema.response).reduce(function(X,Q){let G=$.schema.response[Q];if(Q=Q.toLowerCase(),!z$0.test(Q))throw new F$0;if(G.content){let W={};for(let K of Object.keys(G.content)){let V=G.content[K].schema;W[K]=Z({schema:V,url:Y,method:J,httpStatus:Q,contentType:K})}X[Q]=W}else X[Q]=Z({schema:G,url:Y,method:J,httpStatus:Q});return X},{})}function O$0($,Z,J){let{schema:Y}=$;if(!Y)return;let{method:X,url:Q}=$.config||{},G=Y.headers;if(G&&(J||Object.getPrototypeOf(G)!==Object.prototype))$[u4]=Z({schema:G,method:X,url:Q,httpPart:"headers"});else if(G){let W={};if(Object.keys(G).forEach((K)=>{W[K]=G[K]}),W.required instanceof Array)W.required=W.required.map((K)=>K.toLowerCase());if(G.properties)W.properties={},Object.keys(G.properties).forEach((K)=>{W.properties[K.toLowerCase()]=G.properties[K]});$[u4]=Z({schema:W,method:X,url:Q,httpPart:"headers"})}else if(Object.hasOwn(Y,"headers"))h4("headers",X,Q);if(Y.body){let W=Y.body.content;if(W){let K={};for(let V of Object.keys(W)){let U=W[V].schema;K[V]=Z({schema:U,method:X,url:Q,httpPart:"body",contentType:V})}$[c5]=K}else $[c5]=Z({schema:Y.body,method:X,url:Q,httpPart:"body"})}else if(Object.hasOwn(Y,"body"))h4("body",X,Q);if(Y.querystring)$[cH]=Z({schema:Y.querystring,method:X,url:Q,httpPart:"querystring"});else if(Object.hasOwn(Y,"querystring"))h4("querystring",X,Q);if(Y.params)$[pH]=Z({schema:Y.params,method:X,url:Q,httpPart:"params"});else if(Object.hasOwn(Y,"params"))h4("params",X,Q)}function g4($,Z,J){let Y=Z[J]===void 0,X;try{X=$?.(Y?null:Z[J])}catch(G){return G.statusCode=500,G}if(X&&typeof X.then==="function")return X.then((G)=>{return Q(G)}).catch((G)=>{return G});return Q(X);function Q(G){if(G===!1)return $.errors;if(G&&G.error)return G.error;if(G&&G.value)Z[J]=G.value;return!1}}function m4($,Z,J){let Y=J===void 0;if(Y||!J.skipParams){let Q=g4($[pH],Z,"params");if(Q)if(typeof Q.then!=="function")return mZ(Q,"params",$.schemaErrorFormatter);else return q$0(Q,$,Z)}if(Y||!J.skipBody){let Q=null;if(typeof $[c5]==="function")Q=$[c5];else if($[c5]){let W=D$0(Z.headers["content-type"]),K=$[c5][W];if(K)Q=K}let G=g4(Q,Z,"body");if(G)if(typeof G.then!=="function")return mZ(G,"body",$.schemaErrorFormatter);else return j$0(G,$,Z)}if(Y||!J.skipQuery){let Q=g4($[cH],Z,"query");if(Q)if(typeof Q.then!=="function")return mZ(Q,"querystring",$.schemaErrorFormatter);else return N$0(Q,$,Z)}let X=g4($[u4],Z,"headers");if(X)if(typeof X.then!=="function")return mZ(X,"headers",$.schemaErrorFormatter);else return M$0(X,$,Z);return!1}function q$0($,Z,J){return $.then((Y)=>{if(Y)return mZ(Y,"params",Z.schemaErrorFormatter);return m4(Z,J,{skipParams:!0})})}function j$0($,Z,J){return $.then((Y)=>{if(Y)return mZ(Y,"body",Z.schemaErrorFormatter);return m4(Z,J,{skipParams:!0,skipBody:!0})})}function N$0($,Z,J){return $.then((Y)=>{if(Y)return mZ(Y,"querystring",Z.schemaErrorFormatter);return m4(Z,J,{skipParams:!0,skipBody:!0,skipQuery:!0})})}function M$0($,Z,J){return $.then((Y)=>{if(Y)return mZ(Y,"headers",Z.schemaErrorFormatter);return!1})}function mZ($,Z,J){if($ instanceof Error)return $.statusCode=$.statusCode||400,$.code=$.code||"FST_ERR_VALIDATION",$.validationContext=$.validationContext||Z,$;let Y=J($,Z);return Y.statusCode=Y.statusCode||400,Y.code=Y.code||"FST_ERR_VALIDATION",Y.validation=$,Y.validationContext=Z,Y}function D$0($){if(!$)return"";return $.trimStart().split(/[ ;]/,1)[0].trim().toLowerCase()}wP.exports={symbols:{bodySchema:c5,querystringSchema:cH,responseSchema:DP,paramsSchema:pH,headersSchema:u4},compileSchemasForValidation:O$0,compileSchemasForSerialization:A$0,validate:m4}});var rH=S((hf0,sH)=>{var w$0=Y0("diagnostics_channel"),L$0=lH(),T$0=dH(),{validate:R$0}=iH(),{preValidationHookRunner:P$0,preHandlerHookRunner:I$0}=uZ(),{FST_ERR_CTP_INVALID_MEDIA_TYPE:C$0}=L$(),{setErrorStatusCode:LP}=x4(),{kReplyIsError:SX,kRouteContext:R6,kFourOhFourContext:E$0,kSupportedHTTPMethods:TP}=H$(),_X=w$0.tracingChannel("fastify.request.handler");function b$0($,Z,J){if(J.sent===!0)return;if($!=null){J[SX]=!0,J.send($);return}let Y=Z.method;if(this[TP].bodyless.has(Y)){TJ(Z,J);return}if(this[TP].bodywith.has(Y)){let X=Z.headers,Q=X["content-type"];if(Q===void 0){let W=X["content-length"];if(X["transfer-encoding"]===void 0&&(W===void 0||W==="0")){TJ(Z,J);return}Z[R6].contentTypeParser.run("",TJ,Z,J);return}let G=new L$0(Q);if(G.isValid===!1){J[SX]=!0,J.status(415).send(new C$0);return}Z[R6].contentTypeParser.run(G.toString(),TJ,Z,J);return}TJ(Z,J)}function TJ($,Z){try{if($[R6].preValidation!==null)P$0($[R6].preValidation,$,Z,nH);else nH(null,$,Z)}catch(J){nH(J,$,Z)}}function nH($,Z,J){if(J.sent===!0)return;if($!=null){J[SX]=!0,J.send($);return}let Y=R$0(J[R6],Z);if(Y&&typeof Y.then==="function"||!1){let Q=RP.bind(null,Z,J);Y.then(Q,Q)}else RP(Z,J,Y)}function RP($,Z,J){if(J){if(Z[R6].attachValidation===!1){Z.send(J);return}Z.request.validationError=J}if($[R6].preHandler!==null)I$0($[R6].preHandler,$,Z,oH);else oH(null,$,Z)}function oH($,Z,J){if(J.sent)return;let Y=Z[R6];if(!_X.hasSubscribers||Y[E$0]===null)PP($,Z,J);else{let X={request:Z,reply:J,async:!1,route:{url:Y.config.url,method:Y.config.method}};_X.start.runStores(X,PP,void 0,$,Z,J,X)}}function PP($,Z,J,Y){let X=Z[R6];try{if($!=null){if(J[SX]=!0,Y)Y.error=$,LP(J,$),_X.error.publish(Y);J.send($);return}let Q;try{Q=X.handler(Z,J)}catch(G){if(Y)Y.error=G,LP(J,G),_X.error.publish(Y);J[SX]=!0,J.send(G);return}if(Q!==void 0)if(Q!==null&&typeof Q.then==="function")T$0(Q,J,Y);else J.send(Q)}finally{if(Y)_X.end.publish(Y)}}sH.exports=b$0;sH.exports[Symbol.for("internals")]={handler:TJ,preHandlerCallback:oH}});var CP=S((gf0,IP)=>{function RJ(){}var _$0={fatal:RJ,error:RJ,warn:RJ,info:RJ,debug:RJ,trace:RJ};Object.defineProperty(IP,"exports",{get(){return Object.create(_$0)}})});var tH=S((uf0,_P)=>{var fX=($)=>{return $&&typeof $.message==="string"},aH=($)=>{if(!$)return;let Z=$.cause;if(typeof Z==="function"){let J=$.cause();return fX(J)?J:void 0}else return fX(Z)?Z:void 0},EP=($,Z)=>{if(!fX($))return"";let J=$.stack||"";if(Z.has($))return J+`
85
- causes have become circular...`;let Y=aH($);if(Y)return Z.add($),J+`
86
- caused by: `+EP(Y,Z);else return J},S$0=($)=>EP($,new Set),bP=($,Z,J)=>{if(!fX($))return"";let Y=J?"":$.message||"";if(Z.has($))return Y+": ...";let X=aH($);if(X){Z.add($);let Q=typeof $.cause==="function";return Y+(Q?"":": ")+bP(X,Z,Q)}else return Y},f$0=($)=>bP($,new Set);_P.exports={isErrorLike:fX,getErrorCause:aH,stackWithCauses:S$0,messageWithCauses:f$0}});var eH=S((mf0,fP)=>{var k$0=Symbol("circular-ref-tag"),l4=Symbol("pino-raw-err-ref"),SP=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},aggregateErrors:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[l4]},set:function($){this[l4]=$}}});Object.defineProperty(SP,l4,{writable:!0,value:{}});fP.exports={pinoErrProto:SP,pinoErrorSymbols:{seen:k$0,rawSymbol:l4}}});var yP=S((lf0,vP)=>{vP.exports=ZB;var{messageWithCauses:v$0,stackWithCauses:y$0,isErrorLike:kP}=tH(),{pinoErrProto:x$0,pinoErrorSymbols:h$0}=eH(),{seen:$B}=h$0,{toString:g$0}=Object.prototype;function ZB($){if(!kP($))return $;$[$B]=void 0;let Z=Object.create(x$0);if(Z.type=g$0.call($.constructor)==="[object Function]"?$.constructor.name:$.name,Z.message=v$0($),Z.stack=y$0($),Array.isArray($.errors))Z.aggregateErrors=$.errors.map((J)=>ZB(J));for(let J in $)if(Z[J]===void 0){let Y=$[J];if(kP(Y)){if(J!=="cause"&&!Object.prototype.hasOwnProperty.call(Y,$B))Z[J]=ZB(Y)}else Z[J]=Y}return delete $[$B],Z.raw=$,Z}});var hP=S((df0,xP)=>{xP.exports=p4;var{isErrorLike:JB}=tH(),{pinoErrProto:u$0,pinoErrorSymbols:m$0}=eH(),{seen:d4}=m$0,{toString:l$0}=Object.prototype;function p4($){if(!JB($))return $;$[d4]=void 0;let Z=Object.create(u$0);if(Z.type=l$0.call($.constructor)==="[object Function]"?$.constructor.name:$.name,Z.message=$.message,Z.stack=$.stack,Array.isArray($.errors))Z.aggregateErrors=$.errors.map((J)=>p4(J));if(JB($.cause)&&!Object.prototype.hasOwnProperty.call($.cause,d4))Z.cause=p4($.cause);for(let J in $)if(Z[J]===void 0){let Y=$[J];if(JB(Y)){if(!Object.prototype.hasOwnProperty.call(Y,d4))Z[J]=p4(Y)}else Z[J]=Y}return delete $[d4],Z.raw=$,Z}});var lP=S((pf0,mP)=>{mP.exports={mapHttpRequest:d$0,reqSerializer:uP};var YB=Symbol("pino-raw-req-ref"),gP=Object.create({},{id:{enumerable:!0,writable:!0,value:""},method:{enumerable:!0,writable:!0,value:""},url:{enumerable:!0,writable:!0,value:""},query:{enumerable:!0,writable:!0,value:""},params:{enumerable:!0,writable:!0,value:""},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:""},remotePort:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[YB]},set:function($){this[YB]=$}}});Object.defineProperty(gP,YB,{writable:!0,value:{}});function uP($){let Z=$.info||$.socket,J=Object.create(gP);if(J.id=typeof $.id==="function"?$.id():$.id||($.info?$.info.id:void 0),J.method=$.method,$.originalUrl)J.url=$.originalUrl;else{let Y=$.path;J.url=typeof Y==="string"?Y:$.url?$.url.path||$.url:void 0}if($.query)J.query=$.query;if($.params)J.params=$.params;return J.headers=$.headers,J.remoteAddress=Z&&Z.remoteAddress,J.remotePort=Z&&Z.remotePort,J.raw=$.raw||$,J}function d$0($){return{req:uP($)}}});var iP=S((cf0,cP)=>{cP.exports={mapHttpResponse:p$0,resSerializer:pP};var XB=Symbol("pino-raw-res-ref"),dP=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[XB]},set:function($){this[XB]=$}}});Object.defineProperty(dP,XB,{writable:!0,value:{}});function pP($){let Z=Object.create(dP);return Z.statusCode=$.headersSent?$.statusCode:null,Z.headers=$.getHeaders?$.getHeaders():$._headers,Z.raw=$,Z}function p$0($){return{res:pP($)}}});var GB=S((if0,nP)=>{var QB=yP(),c$0=hP(),c4=lP(),i4=iP();nP.exports={err:QB,errWithCause:c$0,mapHttpRequest:c4.mapHttpRequest,mapHttpResponse:i4.mapHttpResponse,req:c4.reqSerializer,res:i4.resSerializer,wrapErrorSerializer:function(Z){if(Z===QB)return Z;return function(Y){return Z(QB(Y))}},wrapRequestSerializer:function(Z){if(Z===c4.reqSerializer)return Z;return function(Y){return Z(c4.reqSerializer(Y))}},wrapResponseSerializer:function(Z){if(Z===i4.resSerializer)return Z;return function(Y){return Z(i4.resSerializer(Y))}}}});var WB=S((nf0,oP)=>{function i$0($,Z){return Z}oP.exports=function(){let Z=Error.prepareStackTrace;Error.prepareStackTrace=i$0;let J=Error().stack;if(Error.prepareStackTrace=Z,!Array.isArray(J))return;let Y=J.slice(2),X=[];for(let Q of Y){if(!Q)continue;X.push(Q.getFileName())}return X}});var $I=S((of0,eP)=>{function KB($){if($===null||typeof $!=="object")return $;if($ instanceof Date)return new Date($.getTime());if($ instanceof Array){let Z=[];for(let J=0;J<$.length;J++)Z[J]=KB($[J]);return Z}if(typeof $==="object"){let Z=Object.create(Object.getPrototypeOf($));for(let J in $)if(Object.prototype.hasOwnProperty.call($,J))Z[J]=KB($[J]);return Z}return $}function sP($){let Z=[],J="",Y=!1,X=!1,Q="";for(let G=0;G<$.length;G++){let W=$[G];if(!Y&&W==="."){if(J)Z.push(J),J=""}else if(W==="["){if(J)Z.push(J),J="";Y=!0}else if(W==="]"&&Y)Z.push(J),J="",Y=!1,X=!1;else if((W==='"'||W==="'")&&Y)if(!X)X=!0,Q=W;else if(W===Q)X=!1,Q="";else J+=W;else J+=W}if(J)Z.push(J);return Z}function rP($,Z,J){let Y=$;for(let Q=0;Q<Z.length-1;Q++){let G=Z[Q];if(typeof Y!=="object"||Y===null||!(G in Y))return!1;if(typeof Y[G]!=="object"||Y[G]===null)return!1;Y=Y[G]}let X=Z[Z.length-1];if(X==="*"){if(Array.isArray(Y))for(let Q=0;Q<Y.length;Q++)Y[Q]=J;else if(typeof Y==="object"&&Y!==null){for(let Q in Y)if(Object.prototype.hasOwnProperty.call(Y,Q))Y[Q]=J}}else if(typeof Y==="object"&&Y!==null&&X in Y&&Object.prototype.hasOwnProperty.call(Y,X))Y[X]=J;return!0}function aP($,Z){let J=$;for(let X=0;X<Z.length-1;X++){let Q=Z[X];if(typeof J!=="object"||J===null||!(Q in J))return!1;if(typeof J[Q]!=="object"||J[Q]===null)return!1;J=J[Q]}let Y=Z[Z.length-1];if(Y==="*"){if(Array.isArray(J))for(let X=0;X<J.length;X++)J[X]=void 0;else if(typeof J==="object"&&J!==null){for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X))delete J[X]}}else if(typeof J==="object"&&J!==null&&Y in J&&Object.prototype.hasOwnProperty.call(J,Y))delete J[Y];return!0}var n4=Symbol("PATH_NOT_FOUND");function n$0($,Z){let J=$;for(let Y of Z){if(J===null||J===void 0)return n4;if(typeof J!=="object"||J===null)return n4;if(!(Y in J))return n4;J=J[Y]}return J}function o$0($,Z){let J=$;for(let Y of Z){if(J===null||J===void 0)return;if(typeof J!=="object"||J===null)return;J=J[Y]}return J}function s$0($,Z,J,Y=!1){for(let X of Z){let Q=sP(X);if(Q.includes("*"))tP($,Q,J,X,Y);else if(Y)aP($,Q);else{let G=n$0($,Q);if(G===n4)continue;let W=typeof J==="function"?J(G,Q):J;rP($,Q,W)}}}function tP($,Z,J,Y,X=!1){let Q=Z.indexOf("*");if(Q===Z.length-1){let G=Z.slice(0,-1),W=$;for(let K of G){if(W===null||W===void 0)return;if(typeof W!=="object"||W===null)return;W=W[K]}if(Array.isArray(W))if(X)for(let K=0;K<W.length;K++)W[K]=void 0;else for(let K=0;K<W.length;K++){let V=[...G,K.toString()],U=typeof J==="function"?J(W[K],V):J;W[K]=U}else if(typeof W==="object"&&W!==null)if(X){let K=[];for(let V in W)if(Object.prototype.hasOwnProperty.call(W,V))K.push(V);for(let V of K)delete W[V]}else for(let K in W){let V=[...G,K],U=typeof J==="function"?J(W[K],V):J;W[K]=U}}else r$0($,Z,J,Q,Y,X)}function r$0($,Z,J,Y,X,Q=!1){let G=Z.slice(0,Y),W=Z.slice(Y+1),K=[];function V(U,H){if(H===G.length){if(Array.isArray(U))for(let B=0;B<U.length;B++)K[H]=B.toString(),V(U[B],H+1);else if(typeof U==="object"&&U!==null)for(let B in U)K[H]=B,V(U[B],H+1)}else if(H<G.length){let B=G[H];if(U&&typeof U==="object"&&U!==null&&B in U)K[H]=B,V(U[B],H+1)}else if(W.includes("*"))tP(U,W,typeof J==="function"?(z,F)=>{let A=[...K.slice(0,H),...F];return J(z,A)}:J,X,Q);else if(Q)aP(U,W);else{let B=typeof J==="function"?J(o$0(U,W),[...K.slice(0,H),...W]):J;rP(U,W,B)}}if(G.length===0)V($,0);else{let U=$;for(let H=0;H<G.length;H++){let B=G[H];if(U===null||U===void 0)return;if(typeof U!=="object"||U===null)return;U=U[B],K[H]=B}if(U!==null&&U!==void 0)V(U,G.length)}}function a$0($){if($.length===0)return null;let Z=new Map;for(let J of $){let Y=sP(J),X=Z;for(let Q=0;Q<Y.length;Q++){let G=Y[Q];if(!X.has(G))X.set(G,new Map);X=X.get(G)}}return Z}function t$0($,Z){if(!Z)return $;function J(Y,X,Q=0){if(!X||X.size===0)return Y;if(Y===null||typeof Y!=="object")return Y;if(Y instanceof Date)return new Date(Y.getTime());if(Array.isArray(Y)){let W=[];for(let K=0;K<Y.length;K++){let V=K.toString();if(X.has(V)||X.has("*"))W[K]=J(Y[K],X.get(V)||X.get("*"));else W[K]=Y[K]}return W}let G=Object.create(Object.getPrototypeOf(Y));for(let W in Y)if(Object.prototype.hasOwnProperty.call(Y,W))if(X.has(W)||X.has("*"))G[W]=J(Y[W],X.get(W)||X.get("*"));else G[W]=Y[W];return G}return J($,Z)}function e$0($){if(typeof $!=="string")throw Error("Paths must be (non-empty) strings");if($==="")throw Error("Invalid redaction path ()");if($.includes(".."))throw Error(`Invalid redaction path (${$})`);if($.includes(","))throw Error(`Invalid redaction path (${$})`);let Z=0,J=!1,Y="";for(let X=0;X<$.length;X++){let Q=$[X];if((Q==='"'||Q==="'")&&Z>0){if(!J)J=!0,Y=Q;else if(Q===Y)J=!1,Y=""}else if(Q==="["&&!J)Z++;else if(Q==="]"&&!J){if(Z--,Z<0)throw Error(`Invalid redaction path (${$})`)}}if(Z!==0)throw Error(`Invalid redaction path (${$})`)}function $80($){if(!Array.isArray($))throw TypeError("paths must be an array");for(let Z of $)e$0(Z)}function Z80($={}){let{paths:Z=[],censor:J="[REDACTED]",serialize:Y=JSON.stringify,strict:X=!0,remove:Q=!1}=$;$80(Z);let G=a$0(Z);return function(K){if(X&&(K===null||typeof K!=="object")){if(K===null||K===void 0)return Y?Y(K):K;if(typeof K!=="object")return Y?Y(K):K}let V=t$0(K,G),U=K,H=J;if(typeof J==="function")H=J;if(s$0(V,Z,H,Q),Y===!1)return V.restore=function(){return KB(U)},V;if(typeof Y==="function")return Y(V);return JSON.stringify(V)}}eP.exports=Z80});var PJ=S((sf0,ZI)=>{var J80=Symbol("pino.setLevel"),Y80=Symbol("pino.getLevel"),X80=Symbol("pino.levelVal"),Q80=Symbol("pino.levelComp"),G80=Symbol("pino.useLevelLabels"),W80=Symbol("pino.useOnlyCustomLevels"),K80=Symbol("pino.mixin"),V80=Symbol("pino.lsCache"),U80=Symbol("pino.chindings"),H80=Symbol("pino.asJson"),B80=Symbol("pino.write"),z80=Symbol("pino.redactFmt"),F80=Symbol("pino.time"),A80=Symbol("pino.timeSliceIndex"),O80=Symbol("pino.stream"),q80=Symbol("pino.stringify"),j80=Symbol("pino.stringifySafe"),N80=Symbol("pino.stringifiers"),M80=Symbol("pino.end"),D80=Symbol("pino.formatOpts"),w80=Symbol("pino.messageKey"),L80=Symbol("pino.errorKey"),T80=Symbol("pino.nestedKey"),R80=Symbol("pino.nestedKeyStr"),P80=Symbol("pino.mixinMergeStrategy"),I80=Symbol("pino.msgPrefix"),C80=Symbol("pino.wildcardFirst"),E80=Symbol.for("pino.serializers"),b80=Symbol.for("pino.formatters"),_80=Symbol.for("pino.hooks"),S80=Symbol.for("pino.metadata");ZI.exports={setLevelSym:J80,getLevelSym:Y80,levelValSym:X80,levelCompSym:Q80,useLevelLabelsSym:G80,mixinSym:K80,lsCacheSym:V80,chindingsSym:U80,asJsonSym:H80,writeSym:B80,serializersSym:E80,redactFmtSym:z80,timeSym:F80,timeSliceIndexSym:A80,streamSym:O80,stringifySym:q80,stringifySafeSym:j80,stringifiersSym:N80,endSym:M80,formatOptsSym:D80,messageKeySym:w80,errorKeySym:L80,nestedKeySym:T80,wildcardFirstSym:C80,needsMetadataGsym:S80,useOnlyCustomLevelsSym:W80,formattersSym:b80,hooksSym:_80,nestedKeyStrSym:R80,mixinMergeStrategySym:P80,msgPrefixSym:I80}});var UB=S((rf0,YI)=>{var JI=$I(),{redactFmtSym:f80,wildcardFirstSym:o4}=PJ(),VB=/[^.[\]]+|\[([^[\]]*?)\]/g;function k80($,Z){let{paths:J,censor:Y,remove:X}=v80($),Q=J.reduce((K,V)=>{VB.lastIndex=0;let U=VB.exec(V),H=VB.exec(V),B=U[1]!==void 0?U[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):U[0];if(B==="*")B=o4;if(H===null)return K[B]=null,K;if(K[B]===null)return K;let{index:z}=H,F=`${V.substr(z,V.length-1)}`;if(K[B]=K[B]||[],B!==o4&&K[B].length===0)K[B].push(...K[o4]||[]);if(B===o4)Object.keys(K).forEach(function(A){if(K[A])K[A].push(F)});return K[B].push(F),K},{}),G={[f80]:JI({paths:J,censor:Y,serialize:Z,strict:!1,remove:X})},W=(...K)=>{return typeof Y==="function"?Z(Y(...K)):Z(Y)};return[...Object.keys(Q),...Object.getOwnPropertySymbols(Q)].reduce((K,V)=>{if(Q[V]===null)K[V]=(U)=>W(U,[V]);else{let U=typeof Y==="function"?(H,B)=>{return Y(H,[V,...B])}:Y;K[V]=JI({paths:Q[V],censor:U,serialize:Z,strict:!1,remove:X})}return K},G)}function v80($){if(Array.isArray($))return $={paths:$,censor:"[Redacted]"},$;let{paths:Z,censor:J="[Redacted]",remove:Y}=$;if(Array.isArray(Z)===!1)throw Error("pino \u2013 redact must contain an array of strings");if(Y===!0)J=void 0;return{paths:Z,censor:J,remove:Y}}YI.exports=k80});var GI=S((af0,QI)=>{var y80=()=>"",x80=()=>`,"time":${Date.now()}`,h80=()=>`,"time":${Math.round(Date.now()/1000)}`,g80=()=>`,"time":"${new Date(Date.now()).toISOString()}"`,u80=1000000n,XI=1000000000n,m80=BigInt(Date.now())*u80,l80=process.hrtime.bigint(),d80=()=>{let $=process.hrtime.bigint()-l80,Z=m80+$,J=Z/XI,Y=Z%XI,X=Number(J*1000n+Y/1000000n),Q=new Date(X),G=Q.getUTCFullYear(),W=(Q.getUTCMonth()+1).toString().padStart(2,"0"),K=Q.getUTCDate().toString().padStart(2,"0"),V=Q.getUTCHours().toString().padStart(2,"0"),U=Q.getUTCMinutes().toString().padStart(2,"0"),H=Q.getUTCSeconds().toString().padStart(2,"0");return`,"time":"${G}-${W}-${K}T${V}:${U}:${H}.${Y.toString().padStart(9,"0")}Z"`};QI.exports={nullTime:y80,epochTime:x80,unixTime:h80,isoTime:g80,isoTimeNano:d80}});var KI=S((tf0,WI)=>{function p80($){try{return JSON.stringify($)}catch(Z){return'"[Circular]"'}}WI.exports=c80;function c80($,Z,J){var Y=J&&J.stringify||p80,X=1;if(typeof $==="object"&&$!==null){var Q=Z.length+X;if(Q===1)return $;var G=Array(Q);G[0]=Y($);for(var W=1;W<Q;W++)G[W]=Y(Z[W]);return G.join(" ")}if(typeof $!=="string")return $;var K=Z.length;if(K===0)return $;var V="",U=1-X,H=-1,B=$&&$.length||0;for(var z=0;z<B;){if($.charCodeAt(z)===37&&z+1<B){switch(H=H>-1?H:0,$.charCodeAt(z+1)){case 100:case 102:if(U>=K)break;if(Z[U]==null)break;if(H<z)V+=$.slice(H,z);V+=Number(Z[U]),H=z+2,z++;break;case 105:if(U>=K)break;if(Z[U]==null)break;if(H<z)V+=$.slice(H,z);V+=Math.floor(Number(Z[U])),H=z+2,z++;break;case 79:case 111:case 106:if(U>=K)break;if(Z[U]===void 0)break;if(H<z)V+=$.slice(H,z);var F=typeof Z[U];if(F==="string"){V+="'"+Z[U]+"'",H=z+2,z++;break}if(F==="function"){V+=Z[U].name||"<anonymous>",H=z+2,z++;break}V+=Y(Z[U]),H=z+2,z++;break;case 115:if(U>=K)break;if(H<z)V+=$.slice(H,z);V+=String(Z[U]),H=z+2,z++;break;case 37:if(H<z)V+=$.slice(H,z);V+="%",H=z+2,z++,U--;break}++U}++z}if(H===-1)return $;else if(H<B)V+=$.slice(H);return V}});var BB=S((ef0,HB)=>{if(typeof SharedArrayBuffer<"u"&&typeof Atomics<"u"){let Z=function(J){if((J>0&&J<1/0)===!1){if(typeof J!=="number"&&typeof J!=="bigint")throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}Atomics.wait($,0,0,Number(J))},$=new Int32Array(new SharedArrayBuffer(4));HB.exports=Z}else{let $=function(Z){if((Z>0&&Z<1/0)===!1){if(typeof Z!=="number"&&typeof Z!=="bigint")throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}let Y=Date.now()+Number(Z);while(Y>Date.now());};HB.exports=$}});var FI=S(($k0,zI)=>{var p1=Y0("fs"),i80=Y0("events"),n80=Y0("util").inherits,VI=Y0("path"),FB=BB(),o80=Y0("assert"),s4=Buffer.allocUnsafe(0),[s80,r80]=(process.versions.node||"0.0").split(".").map(Number),a80=s80>=22&&r80>=7;function UI($,Z){Z._opening=!0,Z._writing=!0,Z._asyncDrainScheduled=!1;function J(Q,G){if(Q){if(Z._reopening=!1,Z._writing=!1,Z._opening=!1,Z.sync)process.nextTick(()=>{if(Z.listenerCount("error")>0)Z.emit("error",Q)});else Z.emit("error",Q);return}let W=Z._reopening;if(Z.fd=G,Z.file=$,Z._reopening=!1,Z._opening=!1,Z._writing=!1,Z.sync)process.nextTick(()=>Z.emit("ready"));else Z.emit("ready");if(Z.destroyed)return;if(!Z._writing&&Z._len>Z.minLength||Z._flushPending)Z._actualWrite();else if(W)process.nextTick(()=>Z.emit("drain"))}let Y=Z.append?"a":"w",X=Z.mode;if(Z.sync)try{if(Z.mkdir)p1.mkdirSync(VI.dirname($),{recursive:!0});let Q=p1.openSync($,Y,X);J(null,Q)}catch(Q){throw J(Q),Q}else if(Z.mkdir)p1.mkdir(VI.dirname($),{recursive:!0},(Q)=>{if(Q)return J(Q);p1.open($,Y,X,J)});else p1.open($,Y,X,J)}function e8($){if(!(this instanceof e8))return new e8($);let{fd:Z,dest:J,minLength:Y,maxLength:X,maxWrite:Q,periodicFlush:G,sync:W,append:K=!0,mkdir:V,retryEAGAIN:U,fsync:H,contentMode:B,mode:z}=$||{};Z=Z||J,this._len=0,this.fd=-1,this._bufs=[],this._lens=[],this._writing=!1,this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._flushPending=!1,this._hwm=Math.max(Y||0,16387),this.file=null,this.destroyed=!1,this.minLength=Y||0,this.maxLength=X||0,this.maxWrite=Q||16384,this._periodicFlush=G||0,this._periodicFlushTimer=void 0,this.sync=W||!1,this.writable=!0,this._fsync=H||!1,this.append=K||!1,this.mode=z,this.retryEAGAIN=U||(()=>!0),this.mkdir=V||!1;let F,A;if(B==="buffer")this._writingBuf=s4,this.write=$60,this.flush=J60,this.flushSync=X60,this._actualWrite=G60,F=()=>p1.writeSync(this.fd,this._writingBuf),A=()=>p1.write(this.fd,this._writingBuf,this.release);else if(B===void 0||B==="utf8")this._writingBuf="",this.write=e80,this.flush=Z60,this.flushSync=Y60,this._actualWrite=Q60,F=()=>{if(Buffer.isBuffer(this._writingBuf))return p1.writeSync(this.fd,this._writingBuf);return p1.writeSync(this.fd,this._writingBuf,"utf8")},A=()=>{if(Buffer.isBuffer(this._writingBuf))return p1.write(this.fd,this._writingBuf,this.release);return p1.write(this.fd,this._writingBuf,"utf8",this.release)};else throw Error(`SonicBoom supports "utf8" and "buffer", but passed ${B}`);if(typeof Z==="number")this.fd=Z,process.nextTick(()=>this.emit("ready"));else if(typeof Z==="string")UI(Z,this);else throw Error("SonicBoom supports only file descriptors and files");if(this.minLength>=this.maxWrite)throw Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);if(this.release=(j,N)=>{if(j){if((j.code==="EAGAIN"||j.code==="EBUSY")&&this.retryEAGAIN(j,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{FB(100),this.release(void 0,0)}catch(M){this.release(M)}else setTimeout(A,100);else this._writing=!1,this.emit("error",j);return}this.emit("write",N);let L=zB(this._writingBuf,this._len,N);if(this._len=L.len,this._writingBuf=L.writingBuf,this._writingBuf.length){if(!this.sync){A();return}try{do{let M=F(),C=zB(this._writingBuf,this._len,M);this._len=C.len,this._writingBuf=C.writingBuf}while(this._writingBuf.length)}catch(M){this.release(M);return}}if(this._fsync)p1.fsyncSync(this.fd);let q=this._len;if(this._reopening)this._writing=!1,this._reopening=!1,this.reopen();else if(q>this.minLength)this._actualWrite();else if(this._ending)if(q>0)this._actualWrite();else this._writing=!1,r4(this);else if(this._writing=!1,this.sync){if(!this._asyncDrainScheduled)this._asyncDrainScheduled=!0,process.nextTick(t80,this)}else this.emit("drain")},this.on("newListener",function(j){if(j==="drain")this._asyncDrainScheduled=!1}),this._periodicFlush!==0)this._periodicFlushTimer=setInterval(()=>this.flush(null),this._periodicFlush),this._periodicFlushTimer.unref()}function zB($,Z,J){if(typeof $==="string")$=Buffer.from($);return Z=Math.max(Z-J,0),$=$.subarray(J),{writingBuf:$,len:Z}}function t80($){if(!($.listenerCount("drain")>0))return;$._asyncDrainScheduled=!1,$.emit("drain")}n80(e8,i80);function HI($,Z){if($.length===0)return s4;if($.length===1)return $[0];return Buffer.concat($,Z)}function e80($){if(this.destroyed)throw Error("SonicBoom destroyed");$=""+$;let Z=Buffer.byteLength($),J=this._len+Z,Y=this._bufs;if(this.maxLength&&J>this.maxLength)return this.emit("drop",$),this._len<this._hwm;if(Y.length===0||Buffer.byteLength(Y[Y.length-1])+Z>this.maxWrite)Y.push($);else Y[Y.length-1]+=$;if(this._len=J,!this._writing&&this._len>=this.minLength)this._actualWrite();return this._len<this._hwm}function $60($){if(this.destroyed)throw Error("SonicBoom destroyed");let Z=this._len+$.length,J=this._bufs,Y=this._lens;if(this.maxLength&&Z>this.maxLength)return this.emit("drop",$),this._len<this._hwm;if(J.length===0||Y[Y.length-1]+$.length>this.maxWrite)J.push([$]),Y.push($.length);else J[J.length-1].push($),Y[Y.length-1]+=$.length;if(this._len=Z,!this._writing&&this._len>=this.minLength)this._actualWrite();return this._len<this._hwm}function BI($){this._flushPending=!0;let Z=()=>{if(!this._fsync)try{p1.fsync(this.fd,(Y)=>{this._flushPending=!1,$(Y)})}catch(Y){$(Y)}else this._flushPending=!1,$();this.off("error",J)},J=(Y)=>{this._flushPending=!1,$(Y),this.off("drain",Z)};this.once("drain",Z),this.once("error",J)}function Z60($){if($!=null&&typeof $!=="function")throw Error("flush cb must be a function");if(this.destroyed){let Z=Error("SonicBoom destroyed");if($){$(Z);return}throw Z}if(this.minLength<=0){$?.();return}if($)BI.call(this,$);if(this._writing)return;if(this._bufs.length===0)this._bufs.push("");this._actualWrite()}function J60($){if($!=null&&typeof $!=="function")throw Error("flush cb must be a function");if(this.destroyed){let Z=Error("SonicBoom destroyed");if($){$(Z);return}throw Z}if(this.minLength<=0){$?.();return}if($)BI.call(this,$);if(this._writing)return;if(this._bufs.length===0)this._bufs.push([]),this._lens.push(0);this._actualWrite()}e8.prototype.reopen=function($){if(this.destroyed)throw Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.reopen($)});return}if(this._ending)return;if(!this.file)throw Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if($)this.file=$;if(this._reopening=!0,this._writing)return;let Z=this.fd;this.once("ready",()=>{if(Z!==this.fd)p1.close(Z,(J)=>{if(J)return this.emit("error",J)})}),UI(this.file,this)};e8.prototype.end=function(){if(this.destroyed)throw Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.end()});return}if(this._ending)return;if(this._ending=!0,this._writing)return;if(this._len>0&&this.fd>=0)this._actualWrite();else r4(this)};function Y60(){if(this.destroyed)throw Error("SonicBoom destroyed");if(this.fd<0)throw Error("sonic boom is not ready yet");if(!this._writing&&this._writingBuf.length>0)this._bufs.unshift(this._writingBuf),this._writingBuf="";let $="";while(this._bufs.length||$.length){if($.length<=0)$=this._bufs[0];try{let Z=Buffer.isBuffer($)?p1.writeSync(this.fd,$):p1.writeSync(this.fd,$,"utf8"),J=zB($,this._len,Z);if($=J.writingBuf,this._len=J.len,$.length<=0)this._bufs.shift()}catch(Z){if((Z.code==="EAGAIN"||Z.code==="EBUSY")&&!this.retryEAGAIN(Z,$.length,this._len-$.length))throw Z;FB(100)}}try{p1.fsyncSync(this.fd)}catch{}}function X60(){if(this.destroyed)throw Error("SonicBoom destroyed");if(this.fd<0)throw Error("sonic boom is not ready yet");if(!this._writing&&this._writingBuf.length>0)this._bufs.unshift([this._writingBuf]),this._writingBuf=s4;let $=s4;while(this._bufs.length||$.length){if($.length<=0)$=HI(this._bufs[0],this._lens[0]);try{let Z=p1.writeSync(this.fd,$);if($=$.subarray(Z),this._len=Math.max(this._len-Z,0),$.length<=0)this._bufs.shift(),this._lens.shift()}catch(Z){if((Z.code==="EAGAIN"||Z.code==="EBUSY")&&!this.retryEAGAIN(Z,$.length,this._len-$.length))throw Z;FB(100)}}}e8.prototype.destroy=function(){if(this.destroyed)return;r4(this)};function Q60(){let $=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:this._bufs.shift()||"",this.sync)try{let Z=Buffer.isBuffer(this._writingBuf)?p1.writeSync(this.fd,this._writingBuf):p1.writeSync(this.fd,this._writingBuf,"utf8");$(null,Z)}catch(Z){$(Z)}else p1.write(this.fd,this._writingBuf,$)}function G60(){let $=this.release;if(this._writing=!0,this._writingBuf=this._writingBuf.length?this._writingBuf:HI(this._bufs.shift(),this._lens.shift()),this.sync)try{let Z=p1.writeSync(this.fd,this._writingBuf);$(null,Z)}catch(Z){$(Z)}else{if(a80)this._writingBuf=Buffer.from(this._writingBuf);p1.write(this.fd,this._writingBuf,$)}}function r4($){if($.fd===-1){$.once("ready",r4.bind(null,$));return}if($._periodicFlushTimer!==void 0)clearInterval($._periodicFlushTimer);$.destroyed=!0,$._bufs=[],$._lens=[],o80(typeof $.fd==="number",`sonic.fd must be a number, got ${typeof $.fd}`);try{p1.fsync($.fd,Z)}catch{}function Z(){if($.fd!==1&&$.fd!==2)p1.close($.fd,J);else J()}function J(Y){if(Y){$.emit("error",Y);return}if($._ending&&!$._writing)$.emit("finish");$.emit("close")}}e8.SonicBoom=e8;e8.default=e8;zI.exports=e8});var AB=S((Zk0,NI)=>{var $6={exit:[],beforeExit:[]},AI={exit:V60,beforeExit:U60},IJ;function W60(){if(IJ===void 0)IJ=new FinalizationRegistry(H60)}function K60($){if($6[$].length>0)return;process.on($,AI[$])}function OI($){if($6[$].length>0)return;if(process.removeListener($,AI[$]),$6.exit.length===0&&$6.beforeExit.length===0)IJ=void 0}function V60(){qI("exit")}function U60(){qI("beforeExit")}function qI($){for(let Z of $6[$]){let J=Z.deref(),Y=Z.fn;if(J!==void 0)Y(J,$)}$6[$]=[]}function H60($){for(let Z of["exit","beforeExit"]){let J=$6[Z].indexOf($);$6[Z].splice(J,J+1),OI(Z)}}function jI($,Z,J){if(Z===void 0)throw Error("the object can't be undefined");K60($);let Y=new WeakRef(Z);Y.fn=J,W60(),IJ.register(Z,Y),$6[$].push(Y)}function B60($,Z){jI("exit",$,Z)}function z60($,Z){jI("beforeExit",$,Z)}function F60($){if(IJ===void 0)return;IJ.unregister($);for(let Z of["exit","beforeExit"])$6[Z]=$6[Z].filter((J)=>{let Y=J.deref();return Y&&Y!==$}),OI(Z)}NI.exports={register:B60,registerBeforeExit:z60,unregister:F60}});var MI=S((Jk0,A60)=>{A60.exports={name:"thread-stream",version:"4.2.0",description:"A streaming way to send data to a Node.js Worker Thread",main:"index.js",types:"index.d.ts",engines:{node:">=20"},dependencies:{"real-require":"^1.0.0"},devDependencies:{"@types/node":"^25.0.2","@yao-pkg/pkg":"^6.0.0",borp:"^1.0.0",desm:"^1.3.0",eslint:"^9.39.1",fastbench:"^1.0.1",neostandard:"^0.13.0","pino-elasticsearch":"^9.0.0","sonic-boom":"^5.0.0","ts-node":"^10.8.0",typescript:"~5.7.3"},scripts:{build:"tsc --noEmit",lint:"eslint",test:'npm run lint && npm run build && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',"test:ci":'npm run lint && npm run transpile && borp --pattern "test/*.test.{js,mjs}"',"test:yarn":'npm run transpile && borp --pattern "test/*.test.js"',transpile:"sh ./test/ts/transpile.sh"},repository:{type:"git",url:"git+https://github.com/mcollina/thread-stream.git"},keywords:["worker","thread","threads","stream"],author:"Matteo Collina <hello@matteocollina.com>",license:"MIT",bugs:{url:"https://github.com/mcollina/thread-stream/issues"},homepage:"https://github.com/mcollina/thread-stream#readme"}});var wI=S((Yk0,DI)=>{function O60($,Z,J,Y,X){let Q=Y===1/0?1/0:Date.now()+Y,G=()=>{let W=Atomics.load($,Z);if(W===J){X(null,"ok");return}if(Q!==1/0&&Date.now()>Q){X(null,"timed-out");return}let K=Q===1/0?1e4:Math.min(1e4,Math.max(1,Q-Date.now())),V=Atomics.waitAsync($,Z,W,K);if(V.async)V.value.then(G);else setImmediate(G)};G()}function q60($,Z,J,Y,X){let Q=Y===1/0?1/0:Date.now()+Y,G=()=>{if(Atomics.load($,Z)!==J){X(null,"ok");return}if(Q!==1/0&&Date.now()>Q){X(null,"timed-out");return}let K=Q===1/0?1e4:Math.min(1e4,Math.max(1,Q-Date.now())),V=Atomics.waitAsync($,Z,J,K);if(V.async)V.value.then((U)=>{if(U==="ok"){X(null,"ok");return}G()});else setImmediate(G)};G()}DI.exports={wait:O60,waitDiff:q60}});var TI=S((Xk0,LI)=>{LI.exports={WRITE_INDEX:4,READ_INDEX:8,SEQ_INDEX:2}});var xI=S((Qk0,yI)=>{var __dirname="/home/runner/workspace/products/qitqode/qode/node_modules/.bun/thread-stream@4.2.0/node_modules/thread-stream",{version:j60}=MI(),{EventEmitter:N60}=Y0("events"),{Worker:M60}=Y0("worker_threads"),{join:D60}=Y0("path"),{pathToFileURL:w60}=Y0("url"),{wait:L60}=wI(),{WRITE_INDEX:t6,READ_INDEX:i5,SEQ_INDEX:OB}=TI(),T60=Y0("buffer"),R60=Y0("assert"),s=Symbol("kImpl"),P60=T60.constants.MAX_STRING_LENGTH;function RI(){}function MB($,Z){Atomics.add($[s].state,OB,1),Z(),Atomics.add($[s].state,OB,1),Atomics.notify($[s].state,OB)}function PI($){MB($,()=>{Atomics.store($[s].state,i5,0),Atomics.store($[s].state,t6,0)})}class a4{constructor($){this._value=$}deref(){return this._value}}class jB{register(){}unregister(){}}var I60=process.env.NODE_V8_COVERAGE?jB:global.FinalizationRegistry||jB,C60=process.env.NODE_V8_COVERAGE?a4:global.WeakRef||a4,II=new I60(($)=>{if($.exited)return;$.terminate()});function E60($,Z){let{filename:J,workerData:Y}=Z,Q=("__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{})["thread-stream-worker"]||D60(__dirname,"lib","worker.js"),G=new M60(Q,{...Z.workerOpts,name:Z.workerOpts?.name||"thread-stream",trackUnmanagedFds:!1,workerData:{filename:J.indexOf("file://")===0?J:w60(J).href,dataBuf:$[s].dataBuf,stateBuf:$[s].stateBuf,workerData:{$context:{threadStreamVersion:j60},...Y}}});return G.stream=new a4($),G.on("message",b60),G.on("exit",bI),II.register($,G),G}function CI($){if(R60(!$[s].sync),$[s].needDrain)$[s].needDrain=!1,$.emit("drain")}function EI($){while(!0){let Z=Atomics.load($[s].state,t6),J=$[s].data.length-Z;if(J>0){if($[s].bufLen===0){if($[s].flushing=!1,$[s].ending)DB($);else if($[s].needDrain)process.nextTick(CI,$);return}kI($,J,RI);continue}if(J===0){if(Z===0&&$[s].bufLen===0)return;t4($,()=>{if($.destroyed)return;PI($),EI($)});return}x8($,Error("overwritten"));return}}function b60($){let Z=this.stream.deref();if(Z===void 0){this.exited=!0,this.terminate();return}if($?.code==null)return;switch($.code){case"READY":this.stream=new C60(Z),t4(Z,()=>{Z[s].ready=!0,Z.emit("ready")});break;case"ERROR":x8(Z,$.err);break;case"EVENT":if(Array.isArray($.args))Z.emit($.name,...$.args);else Z.emit($.name,$.args);break;case"FLUSHED":{if($.context!=="thread-stream"){x8(Z,Error("this should not happen: "+$.code));break}let J=Z[s].flushCallbacks.get($.id);if(J)Z[s].flushCallbacks.delete($.id),process.nextTick(J);break}case"WARNING":process.emitWarning($.err);break;default:x8(Z,Error("this should not happen: "+$.code))}}function bI($){let Z=this.stream.deref();if(Z===void 0)return;II.unregister(Z),Z.worker.exited=!0,Z.worker.off("exit",bI),x8(Z,$!==0?Error("the worker thread exited"):null)}class _I extends N60{constructor($={}){super();if($.bufferSize<4)throw Error("bufferSize must at least fit a 4-byte utf-8 char");this[s]={},this[s].stateBuf=new SharedArrayBuffer(128),this[s].state=new Int32Array(this[s].stateBuf),this[s].dataBuf=new SharedArrayBuffer($.bufferSize||4194304),this[s].data=Buffer.from(this[s].dataBuf),this[s].sync=$.sync||!1,this[s].ending=!1,this[s].ended=!1,this[s].needDrain=!1,this[s].destroyed=!1,this[s].flushing=!1,this[s].ready=!1,this[s].finished=!1,this[s].errored=null,this[s].closed=!1,this[s].buf=[],this[s].bufHead=0,this[s].bufLen=0,this[s].flushCallbacks=new Map,this[s].nextFlushId=0,this.worker=E60(this,$),this.on("message",(Z,J)=>{this.worker.postMessage(Z,J)})}write($){let Z=Buffer.isBuffer($)?$:Buffer.from($);if(this[s].destroyed)return NB(this,Error("the worker has exited")),!1;if(this[s].ending)return NB(this,Error("the worker is ending")),!1;if(this[s].flushing&&this[s].bufLen+Z.length>=P60)try{qB(this),this[s].flushing=!0}catch(J){return x8(this,J),!1}if(this[s].buf.push(Z),this[s].bufLen+=Z.length,this[s].sync)try{return qB(this),!0}catch(J){return x8(this,J),!1}if(!this[s].flushing)this[s].flushing=!0,setImmediate(EI,this);return this[s].needDrain=this[s].data.length-this[s].bufLen-Atomics.load(this[s].state,t6)<=0,!this[s].needDrain}end(){if(this[s].destroyed)return;this[s].ending=!0,DB(this)}flush($){$=typeof $==="function"?$:RI,SI(this,(Z)=>{if(Z){process.nextTick($,Z);return}fI(this,$)})}flushSync(){if(this[s].destroyed)return;qB(this),vI(this)}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[s].ready}get destroyed(){return this[s].destroyed}get closed(){return this[s].closed}get writable(){return!this[s].destroyed&&!this[s].ending}get writableEnded(){return this[s].ending}get writableFinished(){return this[s].finished}get writableNeedDrain(){return this[s].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[s].errored}}function SI($,Z){if($[s].destroyed){process.nextTick(Z,Error("the worker has exited"));return}if(!$[s].sync&&($[s].flushing||$[s].bufLen>0)){setImmediate(SI,$,Z);return}t4($,Z)}function t4($,Z){let J=Atomics.load($[s].state,t6);L60($[s].state,i5,J,1/0,(Y,X)=>{if(Y){x8($,Y),Z(Y);return}if(X!=="ok"){t4($,Z);return}Z()})}function fI($,Z){if($[s].destroyed){process.nextTick(Z,Error("the worker has exited"));return}if(!$[s].ready){let Y=()=>{Q(),fI($,Z)},X=()=>{Q(),process.nextTick(Z,Error("the worker has exited"))},Q=()=>{$.off("ready",Y),$.off("close",X)};$.once("ready",Y),$.once("close",X);return}let J=++$[s].nextFlushId;$[s].flushCallbacks.set(J,Z);try{$.worker.postMessage({code:"FLUSH",context:"thread-stream",id:J})}catch(Y){$[s].flushCallbacks.delete(J),x8($,Y),process.nextTick(Z,Y)}}function _60($,Z){let J=$[s].flushCallbacks;if(J.size===0)return;let Y=Z||Error("the worker has exited");for(let X of J.values())process.nextTick(X,Y);J.clear()}function NB($,Z){setImmediate(()=>{$.emit("error",Z)})}function x8($,Z){if($[s].destroyed)return;if($[s].destroyed=!0,_60($,Z),Z)$[s].errored=Z,NB($,Z);if(!$.worker.exited)$.worker.terminate().catch(()=>{}).then(()=>{$[s].closed=!0,$.emit("close")});else setImmediate(()=>{$[s].closed=!0,$.emit("close")})}function kI($,Z,J){let X=Atomics.load($[s].state,t6),Q=Z;while(Q>0&&$[s].bufLen!==0){let G=$[s].bufHead,W=$[s].buf[G];if(W.length<=Q){if(W.copy($[s].data,X),X+=W.length,Q-=W.length,$[s].bufLen-=W.length,$[s].bufHead=G+1,$[s].bufHead===$[s].buf.length)$[s].buf.length=0,$[s].bufHead=0;else if($[s].bufHead>=1024&&$[s].bufHead*2>=$[s].buf.length)$[s].buf.splice(0,$[s].bufHead),$[s].bufHead=0;continue}W.copy($[s].data,X,0,Q),$[s].buf[G]=W.subarray(Q),$[s].bufLen-=Q,X+=Q,Q=0}return MB($,()=>{Atomics.store($[s].state,t6,X)}),J(),!0}function DB($){if($[s].ended||!$[s].ending||$[s].flushing)return;$[s].ended=!0;try{$.flushSync();let Z=Atomics.load($[s].state,i5);MB($,()=>{Atomics.store($[s].state,t6,-1)});let J=0;while(Z!==-1){if(Atomics.wait($[s].state,i5,Z,1000),Z=Atomics.load($[s].state,i5),Z===-2){x8($,Error("end() failed"));return}if(++J===10){x8($,Error("end() took too long (10s)"));return}}process.nextTick(()=>{$[s].finished=!0,$.emit("finish")})}catch(Z){x8($,Z)}}function qB($){let Z=()=>{if($[s].ending)DB($);else if($[s].needDrain)process.nextTick(CI,$)};$[s].flushing=!1;while($[s].bufLen!==0){let J=Atomics.load($[s].state,t6),Y=$[s].data.length-J;if(Y===0){vI($),PI($);continue}else if(Y<0)throw Error("overwritten");kI($,Y,Z)}}function vI($){if($[s].flushing)throw Error("unable to flush while flushing");let Z=Atomics.load($[s].state,t6),J=0;while(!0){let Y=Atomics.load($[s].state,i5);if(Y===-2)throw Error("_flushSync failed");if(Y!==Z)Atomics.wait($[s].state,i5,Y,1000);else break;if(++J===10)throw Error("_flushSync took too long (10s)")}}yI.exports=_I});var TB=S((Gk0,uI)=>{var __dirname="/home/runner/workspace/products/qitqode/qode/node_modules/.bun/pino@10.3.1/node_modules/pino/lib",{createRequire:S60}=Y0("module"),{existsSync:f60}=Y0("fs"),k60=WB(),{join:wB,isAbsolute:gI,sep:v60}=Y0("path"),{fileURLToPath:y60}=Y0("url"),x60=BB(),LB=AB(),h60=xI();function g60($){LB.register($,p60),LB.registerBeforeExit($,c60),$.on("close",function(){LB.unregister($)})}function u60(){let $=process.execArgv;for(let Z=0;Z<$.length;Z++){let J=$[Z];if(J==="--import"||J==="--require"||J==="-r")return!0;if(J.startsWith("--import=")||J.startsWith("--require=")||J.startsWith("-r="))return!0}return!1}function m60($){let Z=$.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g);if(!Z)return $;let J=[],Y=!1;for(let X=0;X<Z.length;X++){let Q=Z[X];if(Q==="--require"||Q==="-r"||Q==="--import"){let G=Z[X+1];if(G&&hI(G)){Y=!0,X++;continue}if(J.push(Q),G)J.push(G),X++;continue}if(Q.startsWith("--require=")||Q.startsWith("-r=")||Q.startsWith("--import=")){let G=Q.slice(Q.indexOf("=")+1);if(hI(G)){Y=!0;continue}}J.push(Q)}return Y?J.join(" "):$}function hI($){let Z=l60($);if(!Z)return!1;let J=Z;if(J.startsWith("file://"))try{J=y60(J)}catch{return!1}return gI(J)&&!f60(J)}function l60($){let Z=$[0],J=$[$.length-1];if(Z==='"'&&J==='"'||Z==="'"&&J==="'")return $.slice(1,-1);return $}function d60($,Z,J,Y,X){if(!J.execArgv&&u60()&&Y0.main===void 0)J={...J,execArgv:[]};if(!J.env&&process.env.NODE_OPTIONS){let K=m60(process.env.NODE_OPTIONS);if(K!==process.env.NODE_OPTIONS)J={...J,env:{...process.env,NODE_OPTIONS:K}}}J={...J,name:X};let Q=new h60({filename:$,workerData:Z,workerOpts:J,sync:Y});Q.on("ready",G),Q.on("close",function(){process.removeListener("exit",W)}),process.on("exit",W);function G(){if(process.removeListener("exit",W),Q.unref(),J.autoEnd!==!1)g60(Q)}function W(){if(Q.closed)return;Q.flushSync(),x60(100),Q.end()}return Q}function p60($){$.ref(),$.flushSync(),$.end(),$.once("close",function(){$.unref()})}function c60($){$.flushSync()}function i60($){let{pipeline:Z,targets:J,levels:Y,dedupe:X,worker:Q={},caller:G=k60(),sync:W=!1}=$,K={...$.options},V=typeof G==="string"?[G]:G,U=typeof globalThis==="object"&&Object.prototype.hasOwnProperty.call(globalThis,"__bundlerPathsOverrides")&&globalThis.__bundlerPathsOverrides&&typeof globalThis.__bundlerPathsOverrides==="object"?globalThis.__bundlerPathsOverrides:Object.create(null),H=$.target;if(H&&J)throw Error("only one of target or targets can be specified");if(J)H=U["pino-worker"]||wB(__dirname,"worker.js"),K.targets=J.filter((F)=>F.target).map((F)=>{return{...F,target:z(F.target)}}),K.pipelines=J.filter((F)=>F.pipeline).map((F)=>{return F.pipeline.map((A)=>{return{...A,level:F.level,target:z(A.target)}})});else if(Z)H=U["pino-worker"]||wB(__dirname,"worker.js"),K.pipelines=[Z.map((F)=>{return{...F,target:z(F.target)}})];if(Y)K.levels=Y;if(X)K.dedupe=X;K.pinoWillSendConfig=!0;let B=J||Z?"pino.transport":H;return d60(z(H),K,Q,W,B);function z(F){if(F=U[F]||F,gI(F)||F.indexOf("file://")===0)return F;if(F==="pino/file")return wB(__dirname,"..","file.js");let A;for(let j of V)try{let N=j==="node:repl"?process.cwd()+v60:j;A=S60(N).resolve(F);break}catch(N){continue}if(!A)throw Error(`unable to determine transport target for "${F}"`);return A}}uI.exports=i60});var ZG=S((Kk0,eI)=>{var n60=Y0("diagnostics_channel"),mI=KI(),{mapHttpRequest:o60,mapHttpResponse:s60}=GB(),PB=FI(),lI=AB(),{lsCacheSym:r60,chindingsSym:nI,writeSym:dI,serializersSym:oI,formatOptsSym:pI,endSym:a60,stringifiersSym:sI,stringifySym:rI,stringifySafeSym:IB,wildcardFirstSym:aI,nestedKeySym:t60,formattersSym:tI,messageKeySym:e60,errorKeySym:$Z0,nestedKeyStrSym:ZZ0,msgPrefixSym:e4}=PJ(),{isMainThread:JZ0}=Y0("worker_threads"),YZ0=TB(),[XZ0]=process.versions.node.split(".").map(($)=>Number($)),cI=n60.tracingChannel("pino_asJson"),RB=XZ0>=25?($)=>JSON.stringify($):GZ0;function CJ(){}function QZ0($,Z){if(!Z)return J;return function(...X){Z.call(this,X,J,$)};function J(Y,...X){if(typeof Y==="object"){let Q=Y;if(Y!==null){if(Y.method&&Y.headers&&Y.socket)Y=o60(Y);else if(typeof Y.setHeader==="function")Y=s60(Y)}let G;if(Q===null&&X.length===0)G=[null];else Q=X.shift(),G=X;if(typeof this[e4]==="string"&&Q!==void 0&&Q!==null)Q=this[e4]+Q;this[dI](Y,mI(Q,G,this[pI]),$)}else{let Q=Y===void 0?X.shift():Y;if(typeof this[e4]==="string"&&Q!==void 0&&Q!==null)Q=this[e4]+Q;this[dI](null,mI(Q,X,this[pI]),$)}}}function GZ0($){let Z="",J=0,Y=!1,X=255,Q=$.length;if(Q>100)return JSON.stringify($);for(var G=0;G<Q&&X>=32;G++)if(X=$.charCodeAt(G),X===34||X===92)Z+=$.slice(J,G)+"\\",J=G,Y=!0;if(!Y)Z=$;else Z+=$.slice(J);return X<32?JSON.stringify($):'"'+Z+'"'}function WZ0($,Z,J,Y){if(cI.hasSubscribers===!1)return iI.call(this,$,Z,J,Y);let X={instance:this,arguments};return cI.traceSync(iI,X,this,$,Z,J,Y)}function iI($,Z,J,Y){let X=this[rI],Q=this[IB],G=this[sI],W=this[a60],K=this[nI],V=this[oI],U=this[tI],H=this[e60],B=this[$Z0],z=this[r60][J]+Y;z=z+K;let F;if(U.log)$=U.log($);let A=G[aI],j="";for(let L in $)if(F=$[L],Object.prototype.hasOwnProperty.call($,L)&&F!==void 0){if(V[L])F=V[L](F);else if(L===B&&V.err)F=V.err(F);let q=G[L]||A;switch(typeof F){case"undefined":case"function":continue;case"number":if(Number.isFinite(F)===!1)F=null;case"boolean":if(q)F=q(F);break;case"string":F=(q||RB)(F);break;default:F=(q||X)(F,Q)}if(F===void 0)continue;let M=RB(L);j+=","+M+":"+F}let N="";if(Z!==void 0){F=V[H]?V[H](Z):Z;let L=G[H]||A;switch(typeof F){case"function":break;case"number":if(Number.isFinite(F)===!1)F=null;case"boolean":if(L)F=L(F);N=',"'+H+'":'+F;break;case"string":F=(L||RB)(F),N=',"'+H+'":'+F;break;default:F=(L||X)(F,Q),N=',"'+H+'":'+F}}if(this[t60]&&j)return z+this[ZZ0]+j.slice(1)+"}"+N+W;else return z+j+N+W}function KZ0($,Z){let J,Y=$[nI],X=$[rI],Q=$[IB],G=$[sI],W=G[aI],K=$[oI],V=$[tI].bindings;Z=V(Z);for(let U in Z)if(J=Z[U],((U.length<5||U!=="level"&&U!=="serializers"&&U!=="formatters"&&U!=="customLevels")&&Z.hasOwnProperty(U)&&J!==void 0)===!0){if(J=K[U]?K[U](J):J,J=(G[U]||W||X)(J,Q),J===void 0)continue;Y+=',"'+U+'":'+J}return Y}function VZ0($){return $.write!==$.constructor.prototype.write}function $G($){let Z=new PB($);if(Z.on("error",J),!$.sync&&JZ0)lI.register(Z,UZ0),Z.on("close",function(){lI.unregister(Z)});return Z;function J(Y){if(Y.code==="EPIPE"){Z.write=CJ,Z.end=CJ,Z.flushSync=CJ,Z.destroy=CJ;return}Z.removeListener("error",J),Z.emit("error",Y)}}function UZ0($,Z){if($.destroyed)return;if(Z==="beforeExit")$.flush(),$.on("drain",function(){$.end()});else $.flushSync()}function HZ0($){return function(J,Y,X={},Q){if(typeof X==="string")Q=$G({dest:X}),X={};else if(typeof Q==="string"){if(X&&X.transport)throw Error("only one of option.transport or stream can be specified");Q=$G({dest:Q})}else if(X instanceof PB||X.writable||X._writableState)Q=X,X={};else if(X.transport){if(X.transport instanceof PB||X.transport.writable||X.transport._writableState)throw Error("option.transport do not allow stream, please pass to option directly. e.g. pino(transport)");if(X.transport.targets&&X.transport.targets.length&&X.formatters&&typeof X.formatters.level==="function")throw Error("option.transport.targets do not allow custom level formatters");let K;if(X.customLevels)K=X.useOnlyCustomLevels?X.customLevels:Object.assign({},X.levels,X.customLevels);Q=YZ0({caller:Y,...X.transport,levels:K})}if(X=Object.assign({},$,X),X.serializers=Object.assign({},$.serializers,X.serializers),X.formatters=Object.assign({},$.formatters,X.formatters),X.prettyPrint)throw Error("prettyPrint option is no longer supported, see the pino-pretty package (https://github.com/pinojs/pino-pretty)");let{enabled:G,onChild:W}=X;if(G===!1)X.level="silent";if(!W)X.onChild=CJ;if(!Q)if(!VZ0(process.stdout))Q=$G({fd:process.stdout.fd||1});else Q=process.stdout;return{opts:X,stream:Q}}}function BZ0($,Z){try{return JSON.stringify($)}catch(J){try{return(Z||this[IB])($)}catch(Y){return'"[unable to serialize, circular reference is too complex to analyze]"'}}}function zZ0($,Z,J){return{level:$,bindings:Z,log:J}}function FZ0($){let Z=Number($);if(typeof $==="string"&&Number.isFinite(Z))return Z;if($===void 0)return 1;return $}eI.exports={noop:CJ,buildSafeSonicBoom:$G,asChindings:KZ0,asJson:WZ0,genLog:QZ0,createArgsNormalizer:HZ0,stringify:BZ0,buildFormatters:zZ0,normalizeDestFileDescriptor:FZ0}});var JG=S((Vk0,$C)=>{var AZ0={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},OZ0={ASC:"ASC",DESC:"DESC"};$C.exports={DEFAULT_LEVELS:AZ0,SORTING_ORDER:OZ0}});var bB=S((Uk0,XC)=>{var{lsCacheSym:qZ0,levelValSym:CB,useOnlyCustomLevelsSym:jZ0,streamSym:NZ0,formattersSym:MZ0,hooksSym:DZ0,levelCompSym:ZC}=PJ(),{noop:wZ0,genLog:n5}=ZG(),{DEFAULT_LEVELS:P6,SORTING_ORDER:JC}=JG(),YC={fatal:($)=>{let Z=n5(P6.fatal,$);return function(...J){let Y=this[NZ0];if(Z.call(this,...J),typeof Y.flushSync==="function")try{Y.flushSync()}catch(X){}}},error:($)=>n5(P6.error,$),warn:($)=>n5(P6.warn,$),info:($)=>n5(P6.info,$),debug:($)=>n5(P6.debug,$),trace:($)=>n5(P6.trace,$)},EB=Object.keys(P6).reduce(($,Z)=>{return $[P6[Z]]=Z,$},{}),LZ0=Object.keys(EB).reduce(($,Z)=>{return $[Z]='{"level":'+Number(Z),$},{});function TZ0($){let Z=$[MZ0].level,{labels:J}=$.levels,Y={};for(let X in J){let Q=Z(J[X],Number(X));Y[X]=JSON.stringify(Q).slice(0,-1)}return $[qZ0]=Y,$}function RZ0($,Z){if(Z)return!1;switch($){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return!0;default:return!1}}function PZ0($){let{labels:Z,values:J}=this.levels;if(typeof $==="number"){if(Z[$]===void 0)throw Error("unknown level value"+$);$=Z[$]}if(J[$]===void 0)throw Error("unknown level "+$);let Y=this[CB],X=this[CB]=J[$],Q=this[jZ0],G=this[ZC],W=this[DZ0].logMethod;for(let K in J){if(G(J[K],X)===!1){this[K]=wZ0;continue}this[K]=RZ0(K,Q)?YC[K](W):n5(J[K],W)}this.emit("level-change",$,X,Z[Y],Y,this)}function IZ0($){let{levels:Z,levelVal:J}=this;return Z&&Z.labels?Z.labels[J]:""}function CZ0($){let{values:Z}=this.levels,J=Z[$];return J!==void 0&&this[ZC](J,this[CB])}function EZ0($,Z,J){if($===JC.DESC)return Z<=J;return Z>=J}function bZ0($){if(typeof $==="string")return EZ0.bind(null,$);return $}function _Z0($=null,Z=!1){let J=$?Object.keys($).reduce((Q,G)=>{return Q[$[G]]=G,Q},{}):null,Y=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),Z?null:EB,J),X=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),Z?null:P6,$);return{labels:Y,values:X}}function SZ0($,Z,J){if(typeof $==="number"){if(![].concat(Object.keys(Z||{}).map((Q)=>Z[Q]),J?[]:Object.keys(EB).map((Q)=>+Q),1/0).includes($))throw Error(`default level:${$} must be included in custom levels`);return}let Y=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),J?null:P6,Z);if(!($ in Y))throw Error(`default level:${$} must be included in custom levels`)}function fZ0($,Z){let{labels:J,values:Y}=$;for(let X in Z){if(X in Y)throw Error("levels cannot be overridden");if(Z[X]in J)throw Error("pre-existing level values cannot be used for new levels")}}function kZ0($){if(typeof $==="function")return;if(typeof $==="string"&&Object.values(JC).includes($))return;throw Error('Levels comparison should be one of "ASC", "DESC" or "function" type')}XC.exports={initialLsCache:LZ0,genLsCache:TZ0,levelMethods:YC,getLevel:IZ0,setLevel:PZ0,isLevelEnabled:CZ0,mappings:_Z0,assertNoLevelCollisions:fZ0,assertDefaultLevelFound:SZ0,genLevelComparison:bZ0,assertLevelComparison:kZ0}});var _B=S((Hk0,QC)=>{QC.exports={version:"10.3.1"}});var zC=S((Bk0,BC)=>{var{EventEmitter:vZ0}=Y0("events"),{lsCacheSym:yZ0,levelValSym:xZ0,setLevelSym:fB,getLevelSym:GC,chindingsSym:XG,mixinSym:hZ0,asJsonSym:KC,writeSym:gZ0,mixinMergeStrategySym:uZ0,timeSym:mZ0,timeSliceIndexSym:lZ0,streamSym:VC,serializersSym:o5,formattersSym:kX,errorKeySym:dZ0,messageKeySym:pZ0,useOnlyCustomLevelsSym:cZ0,needsMetadataGsym:iZ0,redactFmtSym:nZ0,stringifySym:oZ0,formatOptsSym:sZ0,stringifiersSym:rZ0,msgPrefixSym:kB,hooksSym:aZ0}=PJ(),{getLevel:tZ0,setLevel:eZ0,isLevelEnabled:$50,mappings:Z50,initialLsCache:J50,genLsCache:Y50,assertNoLevelCollisions:X50}=bB(),{asChindings:vB,asJson:Q50,buildFormatters:SB,stringify:WC,noop:UC}=ZG(),{version:G50}=_B(),W50=UB(),K50=class{},HC={constructor:K50,child:V50,bindings:U50,setBindings:H50,flush:F50,isLevelEnabled:$50,version:G50,get level(){return this[GC]()},set level($){this[fB]($)},get levelVal(){return this[xZ0]},set levelVal($){throw Error("levelVal is read-only")},get msgPrefix(){return this[kB]},get[Symbol.toStringTag](){return"Pino"},[yZ0]:J50,[gZ0]:z50,[KC]:Q50,[GC]:tZ0,[fB]:eZ0};Object.setPrototypeOf(HC,vZ0.prototype);BC.exports=function(){return Object.create(HC)};var YG=($)=>$;function V50($,Z){if(!$)throw Error("missing bindings for child Pino");let J=this[o5],Y=this[kX],X=Object.create(this);if(Z==null){if(X[kX].bindings!==YG)X[kX]=SB(Y.level,YG,Y.log);if(X[XG]=vB(X,$),this.onChild!==UC)this.onChild(X);return X}if(Z.hasOwnProperty("serializers")===!0){X[o5]=Object.create(null);for(let V in J)X[o5][V]=J[V];let W=Object.getOwnPropertySymbols(J);for(var Q=0;Q<W.length;Q++){let V=W[Q];X[o5][V]=J[V]}for(let V in Z.serializers)X[o5][V]=Z.serializers[V];let K=Object.getOwnPropertySymbols(Z.serializers);for(var G=0;G<K.length;G++){let V=K[G];X[o5][V]=Z.serializers[V]}}else X[o5]=J;if(Z.hasOwnProperty("formatters")){let{level:W,bindings:K,log:V}=Z.formatters;X[kX]=SB(W||Y.level,K||YG,V||Y.log)}else X[kX]=SB(Y.level,YG,Y.log);if(Z.hasOwnProperty("customLevels")===!0)X50(this.levels,Z.customLevels),X.levels=Z50(Z.customLevels,X[cZ0]),Y50(X);if(typeof Z.redact==="object"&&Z.redact!==null||Array.isArray(Z.redact)){X.redact=Z.redact;let W=W50(X.redact,WC),K={stringify:W[nZ0]};X[oZ0]=WC,X[rZ0]=W,X[sZ0]=K}if(typeof Z.msgPrefix==="string")X[kB]=(this[kB]||"")+Z.msgPrefix;if(X[XG]=vB(X,$),Z.level!==void 0&&Z.level!==this.level||Z.hasOwnProperty("customLevels")){let W=Z.level||this.level;X[fB](W)}return this.onChild(X),X}function U50(){let Z=`{${this[XG].substr(1)}}`,J=JSON.parse(Z);return delete J.pid,delete J.hostname,J}function H50($){let Z=vB(this,$);this[XG]=Z}function B50($,Z){return Object.assign(Z,$)}function z50($,Z,J){let Y=this[mZ0](),X=this[hZ0],Q=this[dZ0],G=this[pZ0],W=this[uZ0]||B50,K,V=this[aZ0].streamWrite;if($===void 0||$===null)K={};else if($ instanceof Error){if(K={[Q]:$},Z===void 0)Z=$.message}else if(K=$,Z===void 0&&$[G]===void 0&&$[Q])Z=$[Q].message;if(X)K=W(K,X(K,J,this));let U=this[KC](K,Z,J,Y),H=this[VC];if(H[iZ0]===!0)H.lastLevel=J,H.lastObj=K,H.lastMsg=Z,H.lastTime=Y.slice(this[lZ0]),H.lastLogger=this;H.write(V?V(U):U)}function F50($){if($!=null&&typeof $!=="function")throw Error("callback must be a function");let Z=this[VC];if(typeof Z.flush==="function")Z.flush($||UC);else if($)$()}});var qC=S((zk0,OC)=>{var{hasOwnProperty:vX}=Object.prototype,r5=hB();r5.configure=hB;r5.stringify=r5;r5.default=r5;zk0.stringify=r5;zk0.configure=hB;OC.exports=r5;var A50=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function lZ($){if($.length<5000&&!A50.test($))return`"${$}"`;return JSON.stringify($)}function yB($,Z){if($.length>200||Z)return $.sort(Z);for(let J=1;J<$.length;J++){let Y=$[J],X=J;while(X!==0&&$[X-1]>Y)$[X]=$[X-1],X--;$[X]=Y}return $}var O50=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function xB($){return O50.call($)!==void 0&&$.length!==0}function FC($,Z,J){if($.length<J)J=$.length;let Y=Z===","?"":" ",X=`"0":${Y}${$[0]}`;for(let Q=1;Q<J;Q++)X+=`${Z}"${Q}":${Y}${$[Q]}`;return X}function q50($){if(vX.call($,"circularValue")){let Z=$.circularValue;if(typeof Z==="string")return`"${Z}"`;if(Z==null)return Z;if(Z===Error||Z===TypeError)return{toString(){throw TypeError("Converting circular structure to JSON")}};throw TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function j50($){let Z;if(vX.call($,"deterministic")){if(Z=$.deterministic,typeof Z!=="boolean"&&typeof Z!=="function")throw TypeError('The "deterministic" argument must be of type boolean or comparator function')}return Z===void 0?!0:Z}function N50($,Z){let J;if(vX.call($,Z)){if(J=$[Z],typeof J!=="boolean")throw TypeError(`The "${Z}" argument must be of type boolean`)}return J===void 0?!0:J}function AC($,Z){let J;if(vX.call($,Z)){if(J=$[Z],typeof J!=="number")throw TypeError(`The "${Z}" argument must be of type number`);if(!Number.isInteger(J))throw TypeError(`The "${Z}" argument must be an integer`);if(J<1)throw RangeError(`The "${Z}" argument must be >= 1`)}return J===void 0?1/0:J}function s5($){if($===1)return"1 item";return`${$} items`}function M50($){let Z=new Set;for(let J of $)if(typeof J==="string"||typeof J==="number")Z.add(String(J));return Z}function D50($){if(vX.call($,"strict")){let Z=$.strict;if(typeof Z!=="boolean")throw TypeError('The "strict" argument must be of type boolean');if(Z)return(J)=>{let Y=`Object can not safely be stringified. Received type ${typeof J}`;if(typeof J!=="function")Y+=` (${J.toString()})`;throw Error(Y)}}}function hB($){$={...$};let Z=D50($);if(Z){if($.bigint===void 0)$.bigint=!1;if(!("circularValue"in $))$.circularValue=Error}let J=q50($),Y=N50($,"bigint"),X=j50($),Q=typeof X==="function"?X:void 0,G=AC($,"maximumDepth"),W=AC($,"maximumBreadth");function K(z,F,A,j,N,L){let q=F[z];if(typeof q==="object"&&q!==null&&typeof q.toJSON==="function")q=q.toJSON(z);switch(q=j.call(F,z,q),typeof q){case"string":return lZ(q);case"object":{if(q===null)return"null";if(A.indexOf(q)!==-1)return J;let M="",C=",",R=L;if(Array.isArray(q)){if(q.length===0)return"[]";if(G<A.length+1)return'"[Array]"';if(A.push(q),N!=="")L+=N,M+=`
87
- ${L}`,C=`,
88
- ${L}`;let b=Math.min(q.length,W),y=0;for(;y<b-1;y++){let g=K(String(y),q,A,j,N,L);M+=g!==void 0?g:"null",M+=C}let k=K(String(y),q,A,j,N,L);if(M+=k!==void 0?k:"null",q.length-1>W){let g=q.length-W-1;M+=`${C}"... ${s5(g)} not stringified"`}if(N!=="")M+=`
89
- ${R}`;return A.pop(),`[${M}]`}let w=Object.keys(q),I=w.length;if(I===0)return"{}";if(G<A.length+1)return'"[Object]"';let _="",E="";if(N!=="")L+=N,C=`,
90
- ${L}`,_=" ";let f=Math.min(I,W);if(X&&!xB(q))w=yB(w,Q);A.push(q);for(let b=0;b<f;b++){let y=w[b],k=K(y,q,A,j,N,L);if(k!==void 0)M+=`${E}${lZ(y)}:${_}${k}`,E=C}if(I>W){let b=I-W;M+=`${E}"...":${_}"${s5(b)} not stringified"`,E=C}if(N!==""&&E.length>1)M=`
91
- ${L}${M}
92
- ${R}`;return A.pop(),`{${M}}`}case"number":return isFinite(q)?String(q):Z?Z(q):"null";case"boolean":return q===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(q);default:return Z?Z(q):void 0}}function V(z,F,A,j,N,L){if(typeof F==="object"&&F!==null&&typeof F.toJSON==="function")F=F.toJSON(z);switch(typeof F){case"string":return lZ(F);case"object":{if(F===null)return"null";if(A.indexOf(F)!==-1)return J;let q=L,M="",C=",";if(Array.isArray(F)){if(F.length===0)return"[]";if(G<A.length+1)return'"[Array]"';if(A.push(F),N!=="")L+=N,M+=`
93
- ${L}`,C=`,
94
- ${L}`;let I=Math.min(F.length,W),_=0;for(;_<I-1;_++){let f=V(String(_),F[_],A,j,N,L);M+=f!==void 0?f:"null",M+=C}let E=V(String(_),F[_],A,j,N,L);if(M+=E!==void 0?E:"null",F.length-1>W){let f=F.length-W-1;M+=`${C}"... ${s5(f)} not stringified"`}if(N!=="")M+=`
95
- ${q}`;return A.pop(),`[${M}]`}A.push(F);let R="";if(N!=="")L+=N,C=`,
96
- ${L}`,R=" ";let w="";for(let I of j){let _=V(I,F[I],A,j,N,L);if(_!==void 0)M+=`${w}${lZ(I)}:${R}${_}`,w=C}if(N!==""&&w.length>1)M=`
97
- ${L}${M}
98
- ${q}`;return A.pop(),`{${M}}`}case"number":return isFinite(F)?String(F):Z?Z(F):"null";case"boolean":return F===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(F);default:return Z?Z(F):void 0}}function U(z,F,A,j,N){switch(typeof F){case"string":return lZ(F);case"object":{if(F===null)return"null";if(typeof F.toJSON==="function"){if(F=F.toJSON(z),typeof F!=="object")return U(z,F,A,j,N);if(F===null)return"null"}if(A.indexOf(F)!==-1)return J;let L=N;if(Array.isArray(F)){if(F.length===0)return"[]";if(G<A.length+1)return'"[Array]"';A.push(F),N+=j;let _=`
99
- ${N}`,E=`,
100
- ${N}`,f=Math.min(F.length,W),b=0;for(;b<f-1;b++){let k=U(String(b),F[b],A,j,N);_+=k!==void 0?k:"null",_+=E}let y=U(String(b),F[b],A,j,N);if(_+=y!==void 0?y:"null",F.length-1>W){let k=F.length-W-1;_+=`${E}"... ${s5(k)} not stringified"`}return _+=`
101
- ${L}`,A.pop(),`[${_}]`}let q=Object.keys(F),M=q.length;if(M===0)return"{}";if(G<A.length+1)return'"[Object]"';N+=j;let C=`,
102
- ${N}`,R="",w="",I=Math.min(M,W);if(xB(F))R+=FC(F,C,W),q=q.slice(F.length),I-=F.length,w=C;if(X)q=yB(q,Q);A.push(F);for(let _=0;_<I;_++){let E=q[_],f=U(E,F[E],A,j,N);if(f!==void 0)R+=`${w}${lZ(E)}: ${f}`,w=C}if(M>W){let _=M-W;R+=`${w}"...": "${s5(_)} not stringified"`,w=C}if(w!=="")R=`
103
- ${N}${R}
104
- ${L}`;return A.pop(),`{${R}}`}case"number":return isFinite(F)?String(F):Z?Z(F):"null";case"boolean":return F===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(F);default:return Z?Z(F):void 0}}function H(z,F,A){switch(typeof F){case"string":return lZ(F);case"object":{if(F===null)return"null";if(typeof F.toJSON==="function"){if(F=F.toJSON(z),typeof F!=="object")return H(z,F,A);if(F===null)return"null"}if(A.indexOf(F)!==-1)return J;let j="",N=F.length!==void 0;if(N&&Array.isArray(F)){if(F.length===0)return"[]";if(G<A.length+1)return'"[Array]"';A.push(F);let R=Math.min(F.length,W),w=0;for(;w<R-1;w++){let _=H(String(w),F[w],A);j+=_!==void 0?_:"null",j+=","}let I=H(String(w),F[w],A);if(j+=I!==void 0?I:"null",F.length-1>W){let _=F.length-W-1;j+=`,"... ${s5(_)} not stringified"`}return A.pop(),`[${j}]`}let L=Object.keys(F),q=L.length;if(q===0)return"{}";if(G<A.length+1)return'"[Object]"';let M="",C=Math.min(q,W);if(N&&xB(F))j+=FC(F,",",W),L=L.slice(F.length),C-=F.length,M=",";if(X)L=yB(L,Q);A.push(F);for(let R=0;R<C;R++){let w=L[R],I=H(w,F[w],A);if(I!==void 0)j+=`${M}${lZ(w)}:${I}`,M=","}if(q>W){let R=q-W;j+=`${M}"...":"${s5(R)} not stringified"`}return A.pop(),`{${j}}`}case"number":return isFinite(F)?String(F):Z?Z(F):"null";case"boolean":return F===!0?"true":"false";case"undefined":return;case"bigint":if(Y)return String(F);default:return Z?Z(F):void 0}}function B(z,F,A){if(arguments.length>1){let j="";if(typeof A==="number")j=" ".repeat(Math.min(A,10));else if(typeof A==="string")j=A.slice(0,10);if(F!=null){if(typeof F==="function")return K("",{"":z},[],F,j,"");if(Array.isArray(F))return V("",z,[],M50(F),j,"")}if(j.length!==0)return U("",z,[],j,"")}return H("",z,[])}return B}});var DC=S((Fk0,MC)=>{var gB=Symbol.for("pino.metadata"),{DEFAULT_LEVELS:NC}=JG(),T50=NC.info;function R50($,Z){$=$||[],Z=Z||{dedupe:!1};let J=Object.create(NC);if(J.silent=1/0,Z.levels&&typeof Z.levels==="object")Object.keys(Z.levels).forEach((H)=>{J[H]=Z.levels[H]});let Y={write:X,add:W,remove:K,emit:Q,flushSync:G,end:V,minLevel:0,lastId:0,streams:[],clone:U,[gB]:!0,streamLevels:J};if(Array.isArray($))$.forEach(W,Y);else W.call(Y,$);return $=null,Y;function X(H){let B,z=this.lastLevel,{streams:F}=this,A=0,j;for(let N=P50(F.length,Z.dedupe);C50(N,F.length,Z.dedupe);N=I50(N,Z.dedupe))if(B=F[N],B.level<=z){if(A!==0&&A!==B.level)break;if(j=B.stream,j[gB]){let{lastTime:L,lastMsg:q,lastObj:M,lastLogger:C}=this;j.lastLevel=z,j.lastTime=L,j.lastMsg=q,j.lastObj=M,j.lastLogger=C}if(j.write(H),Z.dedupe)A=B.level}else if(!Z.dedupe)break}function Q(...H){for(let{stream:B}of this.streams)if(typeof B.emit==="function")B.emit(...H)}function G(){for(let{stream:H}of this.streams)if(typeof H.flushSync==="function")H.flushSync()}function W(H){if(!H)return Y;let B=typeof H.write==="function"||H.stream,z=H.write?H:H.stream;if(!B)throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");let{streams:F,streamLevels:A}=this,j;if(typeof H.levelVal==="number")j=H.levelVal;else if(typeof H.level==="string")j=A[H.level];else if(typeof H.level==="number")j=H.level;else j=T50;let N={stream:z,level:j,levelVal:void 0,id:++Y.lastId};return F.unshift(N),F.sort(jC),this.minLevel=F[0].level,Y}function K(H){let{streams:B}=this,z=B.findIndex((F)=>F.id===H);if(z>=0)B.splice(z,1),B.sort(jC),this.minLevel=B.length>0?B[0].level:-1;return Y}function V(){for(let{stream:H}of this.streams){if(typeof H.flushSync==="function")H.flushSync();H.end()}}function U(H){let B=Array(this.streams.length);for(let z=0;z<B.length;z++)B[z]={level:H,stream:this.streams[z].stream};return{write:X,add:W,remove:K,minLevel:H,streams:B,clone:U,emit:Q,flushSync:G,[gB]:!0}}}function jC($,Z){return $.level-Z.level}function P50($,Z){return Z?$-1:0}function I50($,Z){return Z?$-1:$+1}function C50($,Z,J){return J?$>=0:$<Z}MC.exports=R50});var vC=S((Ak0,h8)=>{var E50=Y0("os"),EC=GB(),b50=WB(),_50=UB(),bC=GI(),S50=zC(),_C=PJ(),{configure:f50}=qC(),{assertDefaultLevelFound:k50,mappings:SC,genLsCache:v50,genLevelComparison:y50,assertLevelComparison:x50}=bB(),{DEFAULT_LEVELS:fC,SORTING_ORDER:h50}=JG(),{createArgsNormalizer:g50,asChindings:u50,buildSafeSonicBoom:wC,buildFormatters:m50,stringify:uB,normalizeDestFileDescriptor:LC,noop:l50}=ZG(),{version:d50}=_B(),{chindingsSym:TC,redactFmtSym:p50,serializersSym:RC,timeSym:c50,timeSliceIndexSym:i50,streamSym:n50,stringifySym:PC,stringifySafeSym:mB,stringifiersSym:IC,setLevelSym:o50,endSym:s50,formatOptsSym:r50,messageKeySym:a50,errorKeySym:t50,nestedKeySym:e50,mixinSym:$70,levelCompSym:Z70,useOnlyCustomLevelsSym:J70,formattersSym:CC,hooksSym:Y70,nestedKeyStrSym:X70,mixinMergeStrategySym:Q70,msgPrefixSym:G70}=_C,{epochTime:kC,nullTime:W70}=bC,{pid:K70}=process,V70=E50.hostname(),U70=EC.err,H70={level:"info",levelComparison:h50.ASC,levels:fC,messageKey:"msg",errorKey:"err",nestedKey:null,enabled:!0,base:{pid:K70,hostname:V70},serializers:Object.assign(Object.create(null),{err:U70}),formatters:Object.assign(Object.create(null),{bindings($){return $},level($,Z){return{level:Z}}}),hooks:{logMethod:void 0,streamWrite:void 0},timestamp:kC,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100},B70=g50(H70),z70=Object.assign(Object.create(null),EC);function lB(...$){let Z={},{opts:J,stream:Y}=B70(Z,b50(),...$);if(J.level&&typeof J.level==="string"&&fC[J.level.toLowerCase()]!==void 0)J.level=J.level.toLowerCase();let{redact:X,crlf:Q,serializers:G,timestamp:W,messageKey:K,errorKey:V,nestedKey:U,base:H,name:B,level:z,customLevels:F,levelComparison:A,mixin:j,mixinMergeStrategy:N,useOnlyCustomLevels:L,formatters:q,hooks:M,depthLimit:C,edgeLimit:R,onChild:w,msgPrefix:I}=J,_=f50({maximumDepth:C,maximumBreadth:R}),E=m50(q.level,q.bindings,q.log),f=uB.bind({[mB]:_}),b=X?_50(X,f):{},y=X?{stringify:b[p50]}:{stringify:f},k="}"+(Q?`\r
105
- `:`
106
- `),g=u50.bind(null,{[TC]:"",[RC]:G,[IC]:b,[PC]:uB,[mB]:_,[CC]:E}),d="";if(H!==null)if(B===void 0)d=g(H);else d=g(Object.assign({},H,{name:B}));let p=W instanceof Function?W:W?kC:W70,t=p().indexOf(":")+1;if(L&&!F)throw Error("customLevels is required if useOnlyCustomLevels is set true");if(j&&typeof j!=="function")throw Error(`Unknown mixin type "${typeof j}" - expected "function"`);if(I&&typeof I!=="string")throw Error(`Unknown msgPrefix type "${typeof I}" - expected "string"`);k50(z,F,L);let r=SC(F,L);if(typeof Y.emit==="function")Y.emit("message",{code:"PINO_CONFIG",config:{levels:r,messageKey:K,errorKey:V}});x50(A);let G0=y50(A);return Object.assign(Z,{levels:r,[Z70]:G0,[J70]:L,[n50]:Y,[c50]:p,[i50]:t,[PC]:uB,[mB]:_,[IC]:b,[s50]:k,[r50]:y,[a50]:K,[t50]:V,[e50]:U,[X70]:U?`,${JSON.stringify(U)}:{`:"",[RC]:G,[$70]:j,[Q70]:N,[TC]:d,[CC]:E,[Y70]:M,silent:l50,onChild:w,[G70]:I}),Object.setPrototypeOf(Z,S50()),v50(Z),Z[o50](z),Z}h8.exports=lB;h8.exports.destination=($=process.stdout.fd)=>{if(typeof $==="object")return $.dest=LC($.dest||process.stdout.fd),wC($);else return wC({dest:LC($),minLength:0})};h8.exports.transport=TB();h8.exports.multistream=DC();h8.exports.levels=SC();h8.exports.stdSerializers=z70;h8.exports.stdTimeFunctions=Object.assign({},bC);h8.exports.symbols=_C;h8.exports.version=d50;h8.exports.default=lB;h8.exports.pino=lB});var hC=S((Ok0,xC)=>{var QG=vC(),{serializersSym:yC}=QG.symbols,{FST_ERR_LOG_INVALID_DESTINATION:F70}=L$();function A70($){if($.stream&&$.file)throw new F70;else if($.file)$.stream=QG.destination($.file),delete $.file;let{logger:Z,genReqId:J}=$,Y=null;if(Z){if($.logger=void 0,$.genReqId=void 0,Z[yC])$.serializers=Object.assign({},$.serializers,Z[yC]);Y=Z.child({},$),$.logger=Z,$.genReqId=J}else Y=QG($,$.stream);return Y}var O70={req:function(Z){return{method:Z.method,url:Z.url,version:Z.headers&&Z.headers["accept-version"],host:Z.host,remoteAddress:Z.ip,remotePort:Z.socket?Z.socket.remotePort:void 0}},err:QG.stdSerializers.err,res:function(Z){return{statusCode:Z.statusCode}}};xC.exports={serializers:O70,createPinoLogger:A70}});var yX=S((qk0,uC)=>{var{FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED:q70,FST_ERR_LOG_INVALID_LOGGER_CONFIG:j70,FST_ERR_LOG_INVALID_LOGGER_INSTANCE:N70,FST_ERR_LOG_INVALID_LOGGER:M70}=L$();function D70($,Z,J,Y,X){let Q={[$.requestIdLogLabel]:Y},G=$.childLoggerFactory.call($.server,Z,Q,X||{},J);if($.childLoggerFactory!==gC)GG(G,!0);return G}function gC($,Z,J){return $.child(Z,J)}function GG($,Z){let J=["info","error","debug","fatal","warn","trace","child"],Y=$?J.filter((X)=>!$[X]||typeof $[X]!=="function"):J;if(!Y.length)return!0;else if(Y.length===J.length&&!Z)return!1;else throw M70(Y.join(","))}function w70($){if($.logger&&$.loggerInstance)throw new q70;if(!$.loggerInstance&&!$.logger){let G=CP();return G.child=()=>G,{logger:G,hasLogger:!1}}let{createPinoLogger:Z,serializers:J}=hC();if(GG($.loggerInstance))return{logger:Z({logger:$.loggerInstance,serializers:Object.assign({},J,$.loggerInstance.serializers)}),hasLogger:!0};if(GG($.logger))throw j70();if($.loggerInstance)throw N70();let Y={};if(Object.prototype.toString.call($.logger)==="[object Object]")Reflect.ownKeys($.logger).forEach((Q)=>{Object.defineProperty(Y,Q,{value:$.logger[Q],writable:!0,enumerable:!0,configurable:!0})});return Y.level=Y.level||"info",Y.serializers=Object.assign({},J,Y.serializers),$.logger=Y,{logger:Z($.logger),hasLogger:!0}}function L70(){let $=process.hrtime();return $[0]*1000+$[1]/1e6}uC.exports={createChildLogger:D70,defaultChildLoggerFactory:gC,createLogger:w70,validateLogger:GG,now:L70}});var WG=S((jk0,mC)=>{mC.exports=T70;function EJ($){if($ instanceof Buffer)return Buffer.from($);return new $.constructor($.buffer.slice(),$.byteOffset,$.length)}function T70($){if($=$||{},$.circles)return R70($);let Z=new Map;if(Z.set(Date,(G)=>new Date(G)),Z.set(Map,(G,W)=>new Map(Y(Array.from(G),W))),Z.set(Set,(G,W)=>new Set(Y(Array.from(G),W))),$.constructorHandlers)for(let G of $.constructorHandlers)Z.set(G[0],G[1]);let J=null;return $.proto?Q:X;function Y(G,W){let K=Object.keys(G),V=Array(K.length);for(let U=0;U<K.length;U++){let H=K[U],B=G[H];if(typeof B!=="object"||B===null)V[H]=B;else if(B.constructor!==Object&&(J=Z.get(B.constructor)))V[H]=J(B,W);else if(ArrayBuffer.isView(B))V[H]=EJ(B);else V[H]=W(B)}return V}function X(G){if(typeof G!=="object"||G===null)return G;if(Array.isArray(G))return Y(G,X);if(G.constructor!==Object&&(J=Z.get(G.constructor)))return J(G,X);let W={};for(let K in G){if(Object.hasOwnProperty.call(G,K)===!1)continue;let V=G[K];if(typeof V!=="object"||V===null)W[K]=V;else if(V.constructor!==Object&&(J=Z.get(V.constructor)))W[K]=J(V,X);else if(ArrayBuffer.isView(V))W[K]=EJ(V);else W[K]=X(V)}return W}function Q(G){if(typeof G!=="object"||G===null)return G;if(Array.isArray(G))return Y(G,Q);if(G.constructor!==Object&&(J=Z.get(G.constructor)))return J(G,Q);let W={};for(let K in G){let V=G[K];if(typeof V!=="object"||V===null)W[K]=V;else if(V.constructor!==Object&&(J=Z.get(V.constructor)))W[K]=J(V,Q);else if(ArrayBuffer.isView(V))W[K]=EJ(V);else W[K]=Q(V)}return W}}function R70($){let Z=[],J=[],Y=new Map;if(Y.set(Date,(K)=>new Date(K)),Y.set(Map,(K,V)=>new Map(Q(Array.from(K),V))),Y.set(Set,(K,V)=>new Set(Q(Array.from(K),V))),$.constructorHandlers)for(let K of $.constructorHandlers)Y.set(K[0],K[1]);let X=null;return $.proto?W:G;function Q(K,V){let U=Object.keys(K),H=Array(U.length);for(let B=0;B<U.length;B++){let z=U[B],F=K[z];if(typeof F!=="object"||F===null)H[z]=F;else if(F.constructor!==Object&&(X=Y.get(F.constructor)))H[z]=X(F,V);else if(ArrayBuffer.isView(F))H[z]=EJ(F);else{let A=Z.indexOf(F);if(A!==-1)H[z]=J[A];else H[z]=V(F)}}return H}function G(K){if(typeof K!=="object"||K===null)return K;if(Array.isArray(K))return Q(K,G);if(K.constructor!==Object&&(X=Y.get(K.constructor)))return X(K,G);let V={};Z.push(K),J.push(V);for(let U in K){if(Object.hasOwnProperty.call(K,U)===!1)continue;let H=K[U];if(typeof H!=="object"||H===null)V[U]=H;else if(H.constructor!==Object&&(X=Y.get(H.constructor)))V[U]=X(H,G);else if(ArrayBuffer.isView(H))V[U]=EJ(H);else{let B=Z.indexOf(H);if(B!==-1)V[U]=J[B];else V[U]=G(H)}}return Z.pop(),J.pop(),V}function W(K){if(typeof K!=="object"||K===null)return K;if(Array.isArray(K))return Q(K,W);if(K.constructor!==Object&&(X=Y.get(K.constructor)))return X(K,W);let V={};Z.push(K),J.push(V);for(let U in K){let H=K[U];if(typeof H!=="object"||H===null)V[U]=H;else if(H.constructor!==Object&&(X=Y.get(H.constructor)))V[U]=X(H,W);else if(ArrayBuffer.isView(H))V[U]=EJ(H);else{let B=Z.indexOf(H);if(B!==-1)V[U]=J[B];else V[U]=W(H)}}return Z.pop(),J.pop(),V}}});var xX=S((Nk0,iC)=>{var P70=WG()({circles:!1,proto:!0}),{kSchemaVisited:lC,kSchemaResponse:I70}=H$(),dB=Symbol.for("fluent-schema-object"),{FST_ERR_SCH_MISSING_ID:C70,FST_ERR_SCH_ALREADY_PRESENT:E70,FST_ERR_SCH_DUPLICATE:b70,FST_ERR_SCH_CONTENT_MISSING_SCHEMA:dC}=L$(),cC=["params","body","querystring","query","headers"];function KG($){this.store=$||{}}KG.prototype.add=function($){let Z=P70($.isFluentSchema||$.isFluentJSONSchema||$[dB]?$.valueOf():$),J=Z.$id;if(!J)throw new C70;if(this.store[J])throw new E70(J);this.store[J]=Z};KG.prototype.getSchemas=function(){return Object.assign({},this.store)};KG.prototype.getSchema=function($){return this.store[$]};function pC($){return typeof $==="object"&&Object.getPrototypeOf($)!==Object.prototype}function _70($,Z){if($[lC])return $;if($.query){if($.querystring)throw new b70("querystring");$.querystring=$.query}S70($);for(let J of cC){let Y=$[J];if(Y&&!pC(Y)){if(J==="body"&&Y.content){let X=Y.content,Q=Object.keys(X);for(let G=0;G<Q.length;G++){let W=Q[G];if(!X[W].schema)throw new dC(W)}continue}}}if($.response){let J=Object.keys($.response);for(let Y of J){if(pC($.response[Y]))continue;let X=$.response[Y].content;if(X){let Q=Object.keys(X);for(let G=0;G<Q.length;G++){let W=Q[G];if(!X[W].schema)throw new dC(W)}}}}return $[lC]=!0,$}function S70($){for(let Z of cC)if($[Z]&&($[Z].isFluentSchema||$[Z][dB]))$[Z]=$[Z].valueOf();if($.response){let Z=Object.keys($.response);for(let J of Z)if($.response[J].isFluentSchema||$.response[J][dB])$.response[J]=$.response[J].valueOf()}}function f70($,Z,J){let Y=$[I70];if(!Y)return!1;if(Y[Z]){if(Y[Z].constructor===Object&&J){let Q=J.split(";",1)[0];if(Y[Z][Q])return Y[Z][Q];if(Y[Z]["*/*"])return Y[Z]["*/*"];return!1}return Y[Z]}let X=(Z+"")[0]+"xx";if(Y[X]){if(Y[X].constructor===Object&&J){let Q=J.split(";",1)[0];if(Y[X][Q])return Y[X][Q];if(Y[X]["*/*"])return Y[X]["*/*"];return!1}return Y[X]}if(Y.default){if(Y.default.constructor===Object&&J){let Q=J.split(";",1)[0];if(Y.default[Q])return Y.default[Q];if(Y.default["*/*"])return Y.default["*/*"];return!1}return Y.default}return!1}iC.exports={buildSchemas($){return new KG($)},getSchemaSerializer:f70,normalizeSchema:_70}});var VG=S((Mk0,nC)=>{var k70=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;nC.exports=class ${constructor(Z){switch(Z&&Z.rounding){case"floor":this.parseInteger=Math.floor;break;case"ceil":this.parseInteger=Math.ceil;break;case"round":this.parseInteger=Math.round;break;case"trunc":default:this.parseInteger=Math.trunc;break}this._options=Z}asInteger(Z){if(Number.isInteger(Z))return""+Z;else if(typeof Z==="bigint")return Z.toString();let J=this.parseInteger(Z);if(J===1/0||J===-1/0||J!==J)throw Error(`The value "${Z}" cannot be converted to an integer.`);return""+J}asNumber(Z){let J=Number(Z);if(J!==J)throw Error(`The value "${Z}" cannot be converted to a number.`);else if(J===1/0||J===-1/0)return"null";else return""+J}asBoolean(Z){return Z&&"true"||"false"}asDateTime(Z){if(Z===null)return'""';if(Z instanceof Date)return'"'+Z.toISOString()+'"';if(typeof Z==="string")return'"'+Z+'"';throw Error(`The value "${Z}" cannot be converted to a date-time.`)}asDate(Z){if(Z===null)return'""';if(Z instanceof Date)return'"'+new Date(Z.getTime()-Z.getTimezoneOffset()*60000).toISOString().slice(0,10)+'"';if(typeof Z==="string")return'"'+Z+'"';throw Error(`The value "${Z}" cannot be converted to a date.`)}asTime(Z){if(Z===null)return'""';if(Z instanceof Date)return'"'+new Date(Z.getTime()-Z.getTimezoneOffset()*60000).toISOString().slice(11,19)+'"';if(typeof Z==="string")return'"'+Z+'"';throw Error(`The value "${Z}" cannot be converted to a time.`)}asString(Z){let J=Z.length;if(J===0)return'""';else if(J<42){let Y="",X=-1,Q=255;for(let G=0;G<J;G++)if(Q=Z.charCodeAt(G),Q===34||Q===92)X===-1&&(X=0),Y+=Z.slice(X,G)+"\\",X=G;else if(Q<32||Q>=55296&&Q<=57343)return JSON.stringify(Z);return X===-1&&'"'+Z+'"'||'"'+Y+Z.slice(X)+'"'}else if(J<5000&&k70.test(Z)===!1)return'"'+Z+'"';else return JSON.stringify(Z)}asUnsafeString(Z){return'"'+Z+'"'}getState(){return this._options}static restoreFromState(Z){return new $(Z)}}});var sC=S((Dk0,oC)=>{var v70=VG(),y70={mode:"standalone"},x70=v70.restoreFromState(y70);oC.exports=function(Z,J){let{asString:Y,asNumber:X,asBoolean:Q,asDateTime:G,asDate:W,asTime:K,asUnsafeString:V}=J,U=J.asInteger.bind(J),H="{",B="}",z="[",F="]",A=",",j=":",N='"',L="{}",q="[]",M='""',C="null";function R(I){let _=I&&typeof I.toJSON==="function"?I.toJSON():I;if(_===null)return L;let E,f="{",b=!1;if(E=_.statusCode,E!==void 0)!b&&(b=!0)||(f+=","),f+='"statusCode":',f+=X(E);if(E=_.code,E!==void 0)if(!b&&(b=!0)||(f+=","),f+='"code":',typeof E!=="string")if(E===null)f+=M;else if(E instanceof Date)f+='"'+E.toISOString()+'"';else if(E instanceof RegExp)f+=Y(E.source);else f+=Y(E.toString());else f+=Y(E);if(E=_.error,E!==void 0)if(!b&&(b=!0)||(f+=","),f+='"error":',typeof E!=="string")if(E===null)f+=M;else if(E instanceof Date)f+='"'+E.toISOString()+'"';else if(E instanceof RegExp)f+=Y(E.source);else f+=Y(E.toString());else f+=Y(E);if(E=_.message,E!==void 0)if(!b&&(b=!0)||(f+=","),f+='"message":',typeof E!=="string")if(E===null)f+=M;else if(E instanceof Date)f+='"'+E.toISOString()+'"';else if(E instanceof RegExp)f+=Y(E.source);else f+=Y(E.toString());else f+=Y(E);return f+"}"}return R}(null,x70)});var hX=S((wk0,eC)=>{var rC=Y0("http").STATUS_CODES,h70=dH(),{setErrorStatusCode:g70}=x4(),{kReplyHeaders:a5,kReplyNextErrorHandler:UG,kReplyIsRunningOnErrorHook:u70,kRouteContext:tC,kDisableRequestLogging:HG}=H$(),{FST_ERR_REP_INVALID_PAYLOAD_TYPE:m70,FST_ERR_FAILED_ERROR_SERIALIZATION:l70}=L$(),{getSchemaSerializer:d70}=xX(),pB=sC(),p70={func:i70,toJSON(){return this.func.name.toString()+"()"}};function c70($,Z,J){$[u70]=!1;let Y=$[tC];if($[UG]===!1){aC(Z,$,function(G,W){try{G.raw.writeHead(G.raw.statusCode,G[a5])}catch(K){if(!G.log[HG])G.log.warn({req:G.request,res:G,err:K},K?.message);G.raw.writeHead(G.raw.statusCode)}G.raw.end(W)});return}let X=$[UG]||Y.errorHandler;$[UG]=Object.getPrototypeOf(X),delete $[a5]["content-type"],delete $[a5]["content-length"];let Q=X.func;if(!Q){$[UG]=!1,aC(Z,$,J);return}try{let G=Q(Z,$.request,$);if(G!==void 0)if(G!==null&&typeof G.then==="function")h70(G,$);else $.send(G)}catch(G){$.send(G)}}function i70($,Z,J){if(o70($,J),g70(J,$),J.statusCode<500){if(!J.log[HG])J.log.info({res:J,err:$},$?.message)}else if(!J.log[HG])J.log.error({req:Z,res:J,err:$},$?.message);J.send($)}function aC($,Z,J){let{raw:Y,statusCode:X}=Z;Z[a5]["content-type"]=Z[a5]["content-type"]??"application/json; charset=utf-8";let Q;try{let G=d70(Z[tC],X,Z[a5]["content-type"]);if(G===!1)Q=pB({error:rC[X+""],code:$.code,message:$.message,statusCode:X});else Q=G(Object.create($,{error:{value:rC[X+""]},message:{value:$.message},statusCode:{value:X}}))}catch(G){if(!Z.log[HG])Z.log.error({err:G,statusCode:Y.statusCode},"The serializer for the given status code failed");Z.code(500),Q=pB(new l70(G.message,$.message))}if(typeof Q!=="string"&&!Buffer.isBuffer(Q))Q=pB(new m70(typeof Q));Z[a5]["content-length"]=""+Buffer.byteLength(Q),J(Z,Q)}function n70($=p70,Z){if(!Z)return $;let J=Object.create($);return J.func=Z,J}function o70($,Z){let J=Z.raw,Y=J.statusCode;if(Y=Y>=400?Y:500,$!=null){if($.headers!==void 0)Z.headers($.headers);if($.status>=400)Y=$.status;else if($.statusCode>=400)Y=$.statusCode}J.statusCode=Y}eC.exports={buildErrorHandler:n70,handleError:c70}});var mX=S((Lk0,YE)=>{var{kReply:cB,kRequest:iB,kState:s70,kHasBeenDecorated:r70}=H$(),{FST_ERR_DEC_ALREADY_PRESENT:$E,FST_ERR_DEC_MISSING_DEPENDENCY:a70,FST_ERR_DEC_AFTER_START:t70,FST_ERR_DEC_REFERENCE_TYPE:e70,FST_ERR_DEC_DEPENDENCY_INVALID_TYPE:$J0,FST_ERR_DEC_UNDECLARED:ZJ0}=L$();function JJ0($,Z,J,Y){if(Object.hasOwn($,Z))throw new $E(Z);if(nB($,Z,Y),J&&(typeof J.getter==="function"||typeof J.setter==="function"))Object.defineProperty($,Z,{get:J.getter,set:J.setter});else $[Z]=J}function YJ0($){if(!gX(this,$))throw new ZJ0($,"instance");if(typeof this[$]==="function")return this[$].bind(this);return this[$]}function ZE($,Z,J,Y){let X=$.prototype;if(Object.hasOwn(X,Z)||uX($,Z))throw new $E(Z);if($[r70]=!0,nB($,Z,Y),J&&(typeof J.getter==="function"||typeof J.setter==="function"))Object.defineProperty(X,Z,{get:J.getter,set:J.setter});else if(typeof J==="function")X[Z]=J;else $.props.push({key:Z,value:J})}function JE($,Z){if(typeof Z==="object"&&Z&&!(typeof Z.getter==="function"||typeof Z.setter==="function"))throw new e70($,typeof Z)}function XJ0($,Z,J){return oB(this,$),JJ0(this,$,Z,J),this}function gX($,Z){if(Z)return Z in $||$.prototype&&Z in $.prototype||uX($,Z);return $ in this}function uX($,Z){if($.props)return $.props.find(({key:J})=>J===Z);return!1}function QJ0($){if($&&uX(this[iB],$))return!0;return gX(this[iB].prototype,$)}function GJ0($){if($&&uX(this[cB],$))return!0;return gX(this[cB].prototype,$)}function nB($,Z,J){if(J===void 0||J===null)return;if(!Array.isArray(J))throw new $J0(Z);for(let Y=0;Y!==J.length;++Y)if(!gX($,J[Y]))throw new a70(J[Y])}function WJ0($,Z,J){return oB(this,$),JE($,Z),ZE(this[cB],$,Z,J),this}function KJ0($,Z,J){return oB(this,$),JE($,Z),ZE(this[iB],$,Z,J),this}function oB($,Z){if($[s70].started)throw new t70(Z)}YE.exports={add:XJ0,exist:gX,existRequest:QJ0,existReply:GJ0,dependencies:nB,decorateReply:WJ0,decorateRequest:KJ0,getInstanceDecorator:YJ0,hasKey:uX}});var MG=S((Tk0,NG)=>{var BG=Y0("stream").finished,{kFourOhFourContext:XE,kReplyErrorHandlerCalled:HE,kReplyHijacked:eB,kReplyStartTime:dX,kReplyEndTime:$z,kReplySerializer:e6,kReplySerializerDefault:zG,kReplyIsError:FG,kReplyHeaders:k1,kReplyTrailers:T$,kReplyHasStatusCode:Zz,kReplyIsRunningOnErrorHook:Jz,kReplyNextErrorHandler:VJ0,kDisableRequestLogging:BE,kSchemaResponse:AG,kReplyCacheSerializeFns:dZ,kSchemaController:sB,kOptions:UJ0,kRouteContext:K1,kTimeoutTimer:OG,kOnAbort:bJ,kRequestSignal:zE}=H$(),{onSendHookRunner:FE,onResponseHookRunner:HJ0,preHandlerHookRunner:BJ0,preSerializationHookRunner:zJ0}=uZ(),QE=rH()[Symbol.for("internals")],FJ0=yX(),tB=FJ0.now,{handleError:GE}=hX(),{getSchemaSerializer:AJ0}=xX(),rB={JSON:"application/json; charset=utf-8",PLAIN:"text/plain; charset=utf-8",OCTET:"application/octet-stream"},{FST_ERR_REP_INVALID_PAYLOAD_TYPE:OJ0,FST_ERR_REP_RESPONSE_BODY_CONSUMED:qJ0,FST_ERR_REP_READABLE_STREAM_LOCKED:jJ0,FST_ERR_REP_ALREADY_SENT:NJ0,FST_ERR_SEND_INSIDE_ONERR:MJ0,FST_ERR_BAD_STATUS_CODE:DJ0,FST_ERR_BAD_TRAILER_NAME:wJ0,FST_ERR_BAD_TRAILER_VALUE:LJ0,FST_ERR_MISSING_SERIALIZATION_FN:TJ0,FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN:RJ0,FST_ERR_DEC_UNDECLARED:PJ0}=L$(),WE=mX(),AE=Object.prototype.toString;function v1($,Z,J){this.raw=$,this[e6]=null,this[HE]=!1,this[FG]=!1,this[Jz]=!1,this.request=Z,this[k1]={},this[T$]=null,this[Zz]=!1,this[dX]=void 0,this.log=J}v1.props=[];Object.defineProperties(v1.prototype,{[K1]:{get(){return this.request[K1]}},elapsedTime:{get(){if(this[dX]===void 0)return 0;return(this[$z]||tB())-this[dX]}},server:{get(){return this.request[K1].server}},sent:{enumerable:!0,get(){return(this[eB]||this.raw.writableEnded)===!0}},statusCode:{get(){return this.raw.statusCode},set($){this.code($)}},routeOptions:{get(){return this.request.routeOptions}}});v1.prototype.writeEarlyHints=function($,Z){return this.raw.writeEarlyHints($,Z),this};v1.prototype.hijack=function(){if(this[eB]=!0,this.request[zE]){if(clearTimeout(this.request[OG]),this.request[OG]=null,this.request[bJ])this.request.raw.removeListener("close",this.request[bJ]),this.request[bJ]=null}return this};v1.prototype.send=function($){if(this[Jz])throw new MJ0;if(this.sent===!0)return this.log.warn({err:new NJ0(this.request.url,this.request.method)}),this;if(this[FG]||$ instanceof Error)return this[FG]=!1,_J(this,$,t5),this;if($===void 0)return t5(this,$),this;let Z=this.getHeader("content-type"),J=Z!==void 0;if($!==null){if(typeof $.pipe==="function"||typeof $.getReader==="function"||AE.call($)==="[object Response]")return t5(this,$),this;if($.buffer instanceof ArrayBuffer){if(!J)this[k1]["content-type"]=rB.OCTET;let Y=Buffer.isBuffer($)?$:Buffer.from($.buffer,$.byteOffset,$.byteLength);return t5(this,Y),this}if(!J&&typeof $==="string")return this[k1]["content-type"]=rB.PLAIN,t5(this,$),this}if(this[e6]!==null){if(typeof $!=="string")return KE(this,$),this;$=this[e6]($)}else if(!J||Z.indexOf("json")!==-1){if(!J)this[k1]["content-type"]=rB.JSON;else if(Z.indexOf("charset")===-1){let Y=Z.trim();if(Y.endsWith(";"))this[k1]["content-type"]=`${Y} charset=utf-8`;else this[k1]["content-type"]=`${Y}; charset=utf-8`}if(typeof $!=="string")return KE(this,$),this}return t5(this,$),this};v1.prototype.getHeader=function($){$=$.toLowerCase();let Z=this[k1][$];return Z!==void 0?Z:this.raw.getHeader($)};v1.prototype.getHeaders=function(){return{...this.raw.getHeaders(),...this[k1]}};v1.prototype.hasHeader=function($){return $=$.toLowerCase(),this[k1][$]!==void 0||this.raw.hasHeader($)};v1.prototype.removeHeader=function($){return delete this[k1][$.toLowerCase()],this};v1.prototype.header=function($,Z=""){if($=$.toLowerCase(),this[k1][$]&&$==="set-cookie"){if(typeof this[k1][$]==="string")this[k1][$]=[this[k1][$]];if(Array.isArray(Z))Array.prototype.push.apply(this[k1][$],Z);else this[k1][$].push(Z)}else this[k1][$]=Z;return this};v1.prototype.headers=function($){let Z=Object.keys($);for(let J=0;J!==Z.length;++J){let Y=Z[J];this.header(Y,$[Y])}return this};var IJ0=new Set(["transfer-encoding","content-length","host","cache-control","max-forwards","te","authorization","set-cookie","content-encoding","content-type","content-range","trailer"]);v1.prototype.trailer=function($,Z){if($=$.toLowerCase(),IJ0.has($))throw new wJ0($);if(typeof Z!=="function")throw new LJ0($,typeof Z);if(this[T$]===null)this[T$]={};return this[T$][$]=Z,this};v1.prototype.hasTrailer=function($){return this[T$]?.[$.toLowerCase()]!==void 0};v1.prototype.removeTrailer=function($){if(this[T$]===null)return this;return this[T$][$.toLowerCase()]=void 0,this};v1.prototype.code=function($){let Z=+$;if(!(Z>=100&&Z<=599))throw new DJ0($||String($));return this.raw.statusCode=Z,this[Zz]=!0,this};v1.prototype.status=v1.prototype.code;v1.prototype.getSerializationFunction=function($,Z){let J;if(typeof $==="string"||typeof $==="number")if(typeof Z==="string")J=this[K1][AG]?.[$]?.[Z];else J=this[K1][AG]?.[$];else if(typeof $==="object")J=this[K1][dZ]?.get($);return J};v1.prototype.compileSerializationSchema=function($,Z=null,J=null){let{request:Y}=this,{method:X,url:Q}=Y;if(this[K1][dZ]?.has($))return this[K1][dZ].get($);let W=(this[K1].serializerCompiler||this.server[sB].serializerCompiler||(this.server[sB].setupSerializer(this.server[UJ0])||this.server[sB].serializerCompiler))({schema:$,method:X,url:Q,httpStatus:Z,contentType:J});if(this[K1][dZ]==null)this[K1][dZ]=new WeakMap;return this[K1][dZ].set($,W),W};v1.prototype.serializeInput=function($,Z,J,Y){let X=J,Q;if(J=typeof Z==="string"||typeof Z==="number"?Z:J,Y=J&&X!==J?X:Y,J!=null){if(Y!=null)Q=this[K1][AG]?.[J]?.[Y];else Q=this[K1][AG]?.[J];if(Q==null){if(Y)throw new RJ0(J,Y);throw new TJ0(J)}}else if(this[K1][dZ]?.has(Z))Q=this[K1][dZ].get(Z);else Q=this.compileSerializationSchema(Z,J,Y);return Q($)};v1.prototype.serialize=function($){if(this[e6]!==null)return this[e6]($);else if(this[K1]&&this[K1][zG])return this[K1][zG]($,this.raw.statusCode);else return qE(this[K1],$,this.raw.statusCode)};v1.prototype.serializer=function($){return this[e6]=$,this};v1.prototype.type=function($){return this[k1]["content-type"]=$,this};v1.prototype.redirect=function($,Z){if(!Z)Z=this[Zz]?this.raw.statusCode:302;return this.header("location",$).code(Z).send()};v1.prototype.callNotFound=function(){return vJ0(this),this};v1.prototype.then=function($,Z){if(this.sent){$();return}BG(this.raw,(J)=>{if(J&&J.code!=="ERR_STREAM_PREMATURE_CLOSE")if(Z)Z(J);else this.log&&this.log.warn("unhandled rejection on reply.then");else $()})};v1.prototype.getDecorator=function($){if(!WE.hasKey(this,$)&&!WE.exist(this,$))throw new PJ0($,"reply");let Z=this[$];if(typeof Z==="function")return Z.bind(this);return Z};function KE($,Z){if($[K1].preSerialization!==null)zJ0($[K1].preSerialization,$.request,$,Z,VE);else VE(null,void 0,$,Z)}function VE($,Z,J,Y){if($!=null){_J(J,$);return}try{if(J[e6]!==null)Y=J[e6](Y);else if(J[K1]&&J[K1][zG])Y=J[K1][zG](Y,J.raw.statusCode);else Y=qE(J[K1],Y,J.raw.statusCode,J[k1]["content-type"])}catch(X){CJ0(X,J),_J(J,X);return}t5(J,Y)}function CJ0($,Z){$.serialization=Z[K1].config}function t5($,Z){if($[K1].onSend!==null)FE($[K1].onSend,$.request,$,Z,EJ0);else OE($,Z)}function EJ0($,Z,J,Y){if($!=null)_J(J,$);else OE(J,Y)}function aB($,Z){let J=$.raw;try{J.writeHead(Z,$[k1])}catch(Y){if(Y.code==="ERR_HTTP_HEADERS_SENT")$.log.warn(`Reply was already sent, did you forget to "return reply" in the "${$.request.raw.url}" (${$.request.raw.method}) route?`);throw Y}}function OE($,Z){let{raw:J,request:Y}=$;if($[T$]!==null){let Q=Object.keys($[T$]),G="";for(let W of Q){if(typeof $[T$][W]!=="function")continue;G+=" ",G+=W}$.header("Transfer-Encoding","chunked"),$.header("Trailer",G.trim())}if(AE.call(Z)==="[object Response]"){if(typeof Z.status==="number")$.code(Z.status);if(typeof Z.headers==="object"&&typeof Z.headers.forEach==="function")for(let[Q,G]of Z.headers)$.header(Q,G);if(Z.body!==null){if(Z.bodyUsed)throw new qJ0}Z=Z.body}let X=J.statusCode;if(Z===void 0||Z===null){if(X>=200&&X!==204&&X!==304&&Y.method!=="HEAD"&&$[T$]===null)$[k1]["content-length"]="0";aB($,X),lX(Z,J,$);return}if(X>=100&&X<200||X===204){if($.removeHeader("content-type"),$.removeHeader("content-length"),aB($,X),lX(void 0,J,$),typeof Z.resume==="function")Z.on("error",jG),Z.resume();return}if(typeof Z.pipe==="function"){_J0(Z,J,$);return}if(typeof Z.getReader==="function"){bJ0(Z,J,$);return}if(typeof Z!=="string"&&!Buffer.isBuffer(Z))throw new OJ0(typeof Z);if($[T$]===null){let Q=$[k1]["content-length"];if(!Q||Y.raw.method!=="HEAD"&&Number(Q)!==Buffer.byteLength(Z))$[k1]["content-length"]=""+Buffer.byteLength(Z)}aB($,X),J.write(Z),lX(Z,J,$)}function qG($,Z,J){if(Z.code==="ERR_STREAM_PREMATURE_CLOSE"){if(!$[BE])$.info({res:J},"stream closed prematurely")}else $.warn({err:Z},"response terminated with an error with headers already sent")}function bJ0($,Z,J){if($.locked)throw new jJ0;let Y=!0,X=!1,Q=!1,G=$.getReader();if(BG(Z,function(U){if(Y){if(U!=null&&Z.headersSent&&!X)X=!0,qG(J.log,U,Z);G.cancel().catch(jG)}}),!Z.headersSent)for(let U in J[k1])Z.setHeader(U,J[k1][U]);else J.log.warn("response will send, but you shouldn't use res.writeHead in stream mode");function W(U){if(U.done){Y=!1,lX(null,Z,J);return}if(Z.destroyed){Y=!1,G.cancel().catch(jG);return}if(Z.write(U.value)===!1){Q=!0,Z.once("drain",K);return}G.read().then(W,V)}function K(){if(!Q||!Y||Z.destroyed)return;Q=!1,G.read().then(W,V)}function V(U){if(Y=!1,Z.headersSent||J.request.raw.aborted===!0){if(!X)X=!0,qG(J.log,U,J);Z.destroy()}else _J(J,U)}G.read().then(W,V)}function _J0($,Z,J){let Y=!0,X=!1;if(SJ0($,Z,J),BG($,{readable:!0,writable:!1},function(Q){if(Y=!1,Q!=null)if(Z.headersSent||J.request.raw.aborted===!0){if(!X)X=!0,qG(J.log,Q,J);Z.destroy()}else _J(J,Q)}),BG(Z,function(Q){if(Y){if(Q!=null&&Z.headersSent&&!X)X=!0,qG(J.log,Q,Z);if(typeof $.destroy==="function")$.destroy();else if(typeof $.close==="function")$.close(jG);else if(typeof $.abort==="function")$.abort();else J.log.warn("stream payload does not end properly")}}),!Z.headersSent)for(let Q in J[k1])Z.setHeader(Q,J[k1][Q]);else J.log.warn("response will send, but you shouldn't use res.writeHead in stream mode");$.pipe(Z)}function lX($,Z,J){if(J[T$]===null){Z.end(null,null,null);return}let Y=Object.keys(J[T$]),X={},Q=0,G=!0;function W(){if(Q===0)Z.addTrailers(X),Z.end(null,null,null)}for(let K of Y){let V=function(H,B){if(Q++,H)J.log.debug(H);else X[K]=B;process.nextTick(W)};if(typeof J[T$][K]!=="function")continue;G=!1,Q--;let U=J[T$][K](J,$,V);if(typeof U==="object"&&typeof U.then==="function")U.then((H)=>V(null,H),V)}if(G)Z.end(null,null,null)}function SJ0($,Z,J){if(J[T$]===null)return;$.on("end",()=>lX(null,Z,J))}function _J($,Z,J){if($[K1].onError!==null&&!$[VJ0])$[Jz]=!0,FE($[K1].onError,$.request,$,Z,()=>GE($,Z,J));else GE($,Z,J)}function fJ0($){$[dX]=tB();let Z=(J)=>{$[$z]=tB(),$.raw.removeListener("finish",Z),$.raw.removeListener("error",Z);let Y=$[K1];if($.request[zE]){if(clearTimeout($.request[OG]),$.request[OG]=null,$.request[bJ])$.request.raw.removeListener("close",$.request[bJ]),$.request[bJ]=null}if(Y&&Y.onResponse!==null)HJ0(Y.onResponse,$.request,$,UE);else UE(J,$.request,$)};$.raw.on("finish",Z),$.raw.on("error",Z)}function UE($,Z,J){if(J.log[BE])return;let Y=J.elapsedTime;if($!=null){J.log.error({res:J,err:$,responseTime:Y},"request errored");return}J.log.info({res:J,responseTime:Y},"request completed")}function kJ0($){let Z=$.props.slice();function J(Y,X,Q){this.raw=Y,this[FG]=!1,this[HE]=!1,this[eB]=!1,this[e6]=null,this.request=X,this[k1]={},this[T$]=null,this[dX]=void 0,this[$z]=void 0,this.log=Q;let G;for(let W=0;W<Z.length;W++)G=Z[W],this[G.key]=G.value}return Object.setPrototypeOf(J.prototype,$.prototype),Object.setPrototypeOf(J,$),J.parent=$,J.props=Z,J}function vJ0($){if($[K1][XE]===null){$.log.warn("Trying to send a NotFound error inside a 404 handler. Sending basic 404 response."),$.code(404).send("404 Not Found");return}if($.request[K1]=$[K1][XE],$[K1].preHandler!==null)BJ0($[K1].preHandler,$.request,$,QE.preHandlerCallback);else QE.preHandlerCallback(null,$.request,$)}function qE($,Z,J,Y){let X=AJ0($,J,Y);if(X)return X(Z);return JSON.stringify(Z)}function jG(){}NG.exports=v1;NG.exports.buildReply=kJ0;NG.exports.setupResponseListeners=fJ0});var jE=S((Rk0,DG)=>{function Yz($){if(!$)throw TypeError("argument req is required");let Z=$.headers["x-forwarded-for"],J=$.socket.remoteAddress;if(!Z||typeof Z!=="string")return[J];else if(Z.indexOf(",")===-1){let Y=Z.trim();return Y.length?[J,Y]:[J]}else return yJ0(Z,J)}function yJ0($,Z){let J=[Z],Y=$.length,X=Y,Q,G;for(G=Y-1;G>=0;--G)if(Q=$[G],Q===" ")X===Y&&(X=Y=G);else if(Q===",")X!==Y&&J.push($.slice(X,Y)),X=Y=G;else X=G;return X!==Y&&J.push($.substring(X,Y)),J}DG.exports=Yz;DG.exports.default=Yz;DG.exports.forwarded=Yz});var ME=S((NE,wG)=>{(function($){let J={fourOctet:new RegExp("^(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)$","i"),threeOctet:new RegExp("^(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)$","i"),twoOctet:new RegExp("^(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)$","i"),longValue:new RegExp("^(0?\\d+|0x[a-f0-9]+)$","i")},Y=new RegExp("^0[0-7]+$","i"),X=new RegExp("^0x[a-f0-9]+$","i"),Q="%[0-9a-z]{1,}",G="(?:[0-9a-f]+::?)+",W={zoneIndex:new RegExp("%[0-9a-z]{1,}","i"),native:new RegExp("^(::)?((?:[0-9a-f]+::?)+)?([0-9a-f]+)?(::)?(%[0-9a-z]{1,})?$","i"),deprecatedTransitional:new RegExp("^(?:::)((0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)(%[0-9a-z]{1,})?)$","i"),transitional:new RegExp("^((?:(?:[0-9a-f]+::?)+)|(?:::)(?:(?:[0-9a-f]+::?)+)?)(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)\\.(0?\\d+|0x[a-f0-9]+)(%[0-9a-z]{1,})?$","i")};function K(z,F){if(z.indexOf("::")!==z.lastIndexOf("::"))return null;let A=0,j=-1,N=(z.match(W.zoneIndex)||[])[0],L,q;if(N)N=N.substring(1),z=z.replace(/%.+$/,"");while((j=z.indexOf(":",j+1))>=0)A++;if(z.substr(0,2)==="::")A--;if(z.substr(-2,2)==="::")A--;if(A>F)return null;q=F-A,L=":";while(q--)L+="0:";if(z=z.replace("::",L),z[0]===":")z=z.slice(1);if(z[z.length-1]===":")z=z.slice(0,-1);return F=function(){let M=z.split(":"),C=[];for(let R=0;R<M.length;R++)C.push(parseInt(M[R],16));return C}(),{parts:F,zoneId:N}}function V(z,F,A,j){if(z.length!==F.length)throw Error("ipaddr: cannot match CIDR for objects with different lengths");let N=0,L;while(j>0){if(L=A-j,L<0)L=0;if(z[N]>>L!==F[N]>>L)return!1;j-=A,N+=1}return!0}function U(z){if(X.test(z))return parseInt(z,16);if(z[0]==="0"&&!isNaN(parseInt(z[1],10))){if(Y.test(z))return parseInt(z,8);throw Error(`ipaddr: cannot parse ${z} as octal`)}return parseInt(z,10)}function H(z,F){while(z.length<F)z=`0${z}`;return z}let B={};if(B.IPv4=function(){function z(F){if(F.length!==4)throw Error("ipaddr: ipv4 octet count should be 4");let A,j;for(A=0;A<F.length;A++)if(j=F[A],!(0<=j&&j<=255))throw Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=F}return z.prototype.SpecialRanges={unspecified:[[new z([0,0,0,0]),8]],broadcast:[[new z([255,255,255,255]),32]],multicast:[[new z([224,0,0,0]),4]],linkLocal:[[new z([169,254,0,0]),16]],loopback:[[new z([127,0,0,0]),8]],carrierGradeNat:[[new z([100,64,0,0]),10]],private:[[new z([10,0,0,0]),8],[new z([172,16,0,0]),12],[new z([192,168,0,0]),16]],reserved:[[new z([192,0,0,0]),24],[new z([192,0,2,0]),24],[new z([192,88,99,0]),24],[new z([198,18,0,0]),15],[new z([198,51,100,0]),24],[new z([203,0,113,0]),24],[new z([240,0,0,0]),4]],as112:[[new z([192,175,48,0]),24],[new z([192,31,196,0]),24]],amt:[[new z([192,52,193,0]),24]]},z.prototype.kind=function(){return"ipv4"},z.prototype.match=function(F,A){let j;if(A===void 0)j=F,F=j[0],A=j[1];if(F.kind()!=="ipv4")throw Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return V(this.octets,F.octets,8,A)},z.prototype.prefixLengthFromSubnetMask=function(){let F=0,A=!1,j={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},N,L,q;for(N=3;N>=0;N-=1)if(L=this.octets[N],L in j){if(q=j[L],A&&q!==0)return null;if(q!==8)A=!0;F+=q}else return null;return 32-F},z.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){return this.octets.slice(0)},z.prototype.toIPv4MappedAddress=function(){return B.IPv6.parse(`::ffff:${this.toString()}`)},z.prototype.toNormalizedString=function(){return this.toString()},z.prototype.toString=function(){return this.octets.join(".")},z}(),B.IPv4.broadcastAddressFromCIDR=function(z){try{let F=this.parseCIDR(z),A=F[0].toByteArray(),j=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),N=[],L=0;while(L<4)N.push(parseInt(A[L],10)|parseInt(j[L],10)^255),L++;return new this(N)}catch(F){throw Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.isIPv4=function(z){return this.parser(z)!==null},B.IPv4.isValid=function(z){try{return new this(this.parser(z)),!0}catch(F){return!1}},B.IPv4.isValidCIDR=function(z){try{return this.parseCIDR(z),!0}catch(F){return!1}},B.IPv4.isValidFourPartDecimal=function(z){if(B.IPv4.isValid(z)&&z.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))return!0;else return!1},B.IPv4.isValidCIDRFourPartDecimal=function(z){let F=z.match(/^(.+)\/(\d+)$/);if(!B.IPv4.isValidCIDR(z)||!F)return!1;return B.IPv4.isValidFourPartDecimal(F[1])},B.IPv4.networkAddressFromCIDR=function(z){let F,A,j,N,L;try{F=this.parseCIDR(z),j=F[0].toByteArray(),L=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),N=[],A=0;while(A<4)N.push(parseInt(j[A],10)&parseInt(L[A],10)),A++;return new this(N)}catch(q){throw Error("ipaddr: the address does not have IPv4 CIDR format")}},B.IPv4.parse=function(z){let F=this.parser(z);if(F===null)throw Error("ipaddr: string is not formatted like an IPv4 Address");return new this(F)},B.IPv4.parseCIDR=function(z){let F;if(F=z.match(/^(.+)\/(\d+)$/)){let A=parseInt(F[2]);if(A>=0&&A<=32){let j=[this.parse(F[1]),A];return Object.defineProperty(j,"toString",{value:function(){return this.join("/")}}),j}}throw Error("ipaddr: string is not formatted like an IPv4 CIDR range")},B.IPv4.parser=function(z){let F,A,j;if(F=z.match(J.fourOctet))return function(){let N=F.slice(1,6),L=[];for(let q=0;q<N.length;q++)A=N[q],L.push(U(A));return L}();else if(F=z.match(J.longValue)){if(j=U(F[1]),j>4294967295||j<0)throw Error("ipaddr: address outside defined range");return function(){let N=[],L;for(L=0;L<=24;L+=8)N.push(j>>L&255);return N}().reverse()}else if(F=z.match(J.twoOctet))return function(){let N=F.slice(1,4),L=[];if(j=U(N[1]),j>16777215||j<0)throw Error("ipaddr: address outside defined range");return L.push(U(N[0])),L.push(j>>16&255),L.push(j>>8&255),L.push(j&255),L}();else if(F=z.match(J.threeOctet))return function(){let N=F.slice(1,5),L=[];if(j=U(N[2]),j>65535||j<0)throw Error("ipaddr: address outside defined range");return L.push(U(N[0])),L.push(U(N[1])),L.push(j>>8&255),L.push(j&255),L}();else return null},B.IPv4.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>32)throw Error("ipaddr: invalid IPv4 prefix length");let F=[0,0,0,0],A=0,j=Math.floor(z/8);while(A<j)F[A]=255,A++;if(j<4)F[j]=Math.pow(2,z%8)-1<<8-z%8;return new this(F)},B.IPv6=function(){function z(F,A){let j,N;if(F.length===16){this.parts=[];for(j=0;j<=14;j+=2)this.parts.push(F[j]<<8|F[j+1])}else if(F.length===8)this.parts=F;else throw Error("ipaddr: ipv6 part count should be 8 or 16");for(j=0;j<this.parts.length;j++)if(N=this.parts[j],!(0<=N&&N<=65535))throw Error("ipaddr: ipv6 part should fit in 16 bits");if(A)this.zoneId=A}return z.prototype.SpecialRanges={unspecified:[new z([0,0,0,0,0,0,0,0]),128],linkLocal:[new z([65152,0,0,0,0,0,0,0]),10],multicast:[new z([65280,0,0,0,0,0,0,0]),8],loopback:[new z([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new z([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new z([0,0,0,0,0,65535,0,0]),96],deprecatedSiteLocal:[new z([65216,0,0,0,0,0,0,0]),10],discard:[new z([256,0,0,0,0,0,0,0]),64],rfc6145:[new z([0,0,0,0,65535,0,0,0]),96],rfc6052:[[new z([100,65435,0,0,0,0,0,0]),96],[new z([100,65435,1,0,0,0,0,0]),48]],"6to4":[new z([8194,0,0,0,0,0,0,0]),16],teredo:[new z([8193,0,0,0,0,0,0,0]),32],benchmarking:[new z([8193,2,0,0,0,0,0,0]),48],amt:[new z([8193,3,0,0,0,0,0,0]),32],as112v6:[[new z([8193,4,274,0,0,0,0,0]),48],[new z([9760,79,32768,0,0,0,0,0]),48]],deprecatedOrchid:[new z([8193,16,0,0,0,0,0,0]),28],orchid2:[new z([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new z([8193,48,0,0,0,0,0,0]),28],segmentRouting:[new z([24320,0,0,0,0,0,0,0]),16],reserved:[[new z([8193,0,0,0,0,0,0,0]),23],[new z([8193,3512,0,0,0,0,0,0]),32],[new z([16383,0,0,0,0,0,0,0]),20]]},z.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},z.prototype.kind=function(){return"ipv6"},z.prototype.match=function(F,A){let j;if(A===void 0)j=F,F=j[0],A=j[1];if(F.kind()!=="ipv6")throw Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return V(this.parts,F.parts,16,A)},z.prototype.prefixLengthFromSubnetMask=function(){let F=0,A=!1,j={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},N,L;for(let q=7;q>=0;q-=1)if(N=this.parts[q],N in j){if(L=j[N],A&&L!==0)return null;if(L!==16)A=!0;F+=L}else return null;return 128-F},z.prototype.range=function(){return B.subnetMatch(this,this.SpecialRanges)},z.prototype.toByteArray=function(){let F,A=[],j=this.parts;for(let N=0;N<j.length;N++)F=j[N],A.push(F>>8),A.push(F&255);return A},z.prototype.toFixedLengthString=function(){let F=function(){let j=[];for(let N=0;N<this.parts.length;N++)j.push(H(this.parts[N].toString(16),4));return j}.call(this).join(":"),A="";if(this.zoneId)A=`%${this.zoneId}`;return F+A},z.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let F=this.parts.slice(-2),A=F[0],j=F[1];return new B.IPv4([A>>8,A&255,j>>8,j&255])},z.prototype.toNormalizedString=function(){let F=function(){let j=[];for(let N=0;N<this.parts.length;N++)j.push(this.parts[N].toString(16));return j}.call(this).join(":"),A="";if(this.zoneId)A=`%${this.zoneId}`;return F+A},z.prototype.toRFC5952String=function(){let F=/((^|:)(0(:|$)){2,})/g,A=this.toNormalizedString(),j=0,N=-1,L;while(L=F.exec(A))if(L[0].length>N)j=L.index,N=L[0].length;if(N<0)return A;return`${A.substring(0,j)}::${A.substring(j+N)}`},z.prototype.toString=function(){return this.toRFC5952String()},z}(),B.IPv6.broadcastAddressFromCIDR=function(z){try{let F=this.parseCIDR(z),A=F[0].toByteArray(),j=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),N=[],L=0;while(L<16)N.push(parseInt(A[L],10)|parseInt(j[L],10)^255),L++;return new this(N)}catch(F){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${F})`)}},B.IPv6.isIPv6=function(z){return this.parser(z)!==null},B.IPv6.isValid=function(z){if(typeof z==="string"&&z.indexOf(":")===-1)return!1;try{let F=this.parser(z);return new this(F.parts,F.zoneId),!0}catch(F){return!1}},B.IPv6.isValidCIDR=function(z){if(typeof z==="string"&&z.indexOf(":")===-1)return!1;try{return this.parseCIDR(z),!0}catch(F){return!1}},B.IPv6.networkAddressFromCIDR=function(z){let F,A,j,N,L;try{F=this.parseCIDR(z),j=F[0].toByteArray(),L=this.subnetMaskFromPrefixLength(F[1]).toByteArray(),N=[],A=0;while(A<16)N.push(parseInt(j[A],10)&parseInt(L[A],10)),A++;return new this(N)}catch(q){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${q})`)}},B.IPv6.parse=function(z){let F=this.parser(z);if(F.parts===null)throw Error("ipaddr: string is not formatted like an IPv6 Address");return new this(F.parts,F.zoneId)},B.IPv6.parseCIDR=function(z){let F,A,j;if(A=z.match(/^(.+)\/(\d+)$/)){if(F=parseInt(A[2]),F>=0&&F<=128)return j=[this.parse(A[1]),F],Object.defineProperty(j,"toString",{value:function(){return this.join("/")}}),j}throw Error("ipaddr: string is not formatted like an IPv6 CIDR range")},B.IPv6.parser=function(z){let F,A,j,N,L,q;if(j=z.match(W.deprecatedTransitional))return this.parser(`::ffff:${j[1]}`);if(W.native.test(z))return K(z,8);if(j=z.match(W.transitional)){if(q=j[6]||"",F=j[1],!j[1].endsWith("::"))F=F.slice(0,-1);if(F=K(F+q,6),F.parts){L=[parseInt(j[2]),parseInt(j[3]),parseInt(j[4]),parseInt(j[5])];for(A=0;A<L.length;A++)if(N=L[A],!(0<=N&&N<=255))return null;return F.parts.push(L[0]<<8|L[1]),F.parts.push(L[2]<<8|L[3]),{parts:F.parts,zoneId:F.zoneId}}}return null},B.IPv6.subnetMaskFromPrefixLength=function(z){if(z=parseInt(z),z<0||z>128)throw Error("ipaddr: invalid IPv6 prefix length");let F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],A=0,j=Math.floor(z/8);while(A<j)F[A]=255,A++;if(j<16)F[j]=Math.pow(2,z%8)-1<<8-z%8;return new this(F)},B.fromByteArray=function(z){let F=z.length;if(F===4)return new B.IPv4(z);else if(F===16)return new B.IPv6(z);else throw Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},B.isValid=function(z){return B.IPv6.isValid(z)||B.IPv4.isValid(z)},B.isValidCIDR=function(z){return B.IPv6.isValidCIDR(z)||B.IPv4.isValidCIDR(z)},B.parse=function(z){if(B.IPv6.isValid(z))return B.IPv6.parse(z);else if(B.IPv4.isValid(z))return B.IPv4.parse(z);else throw Error("ipaddr: the address has neither IPv6 nor IPv4 format")},B.parseCIDR=function(z){try{return B.IPv6.parseCIDR(z)}catch(F){try{return B.IPv4.parseCIDR(z)}catch(A){throw Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},B.process=function(z){let F=this.parse(z);if(F.kind()==="ipv6"&&F.isIPv4MappedAddress())return F.toIPv4Address();else return F},B.subnetMatch=function(z,F,A){let j,N,L,q;if(A===void 0||A===null)A="unicast";for(N in F)if(Object.prototype.hasOwnProperty.call(F,N)){if(L=F[N],L[0]&&!(L[0]instanceof Array))L=[L];for(j=0;j<L.length;j++)if(q=L[j],z.kind()===q[0].kind()&&z.match.apply(z,q))return N}return A},typeof wG<"u"&&wG.exports)wG.exports=B;else $.ipaddr=B})(NE)});var RE=S((Pk0,SJ)=>{/*!
107
- * proxy-addr
108
- * Copyright(c) 2021 Fastify collaborators
109
- * Copyright(c) 2014-2016 Douglas Christopher Wilson
110
- * MIT Licensed
111
- */SJ.exports=Xz;SJ.exports.default=Xz;SJ.exports.proxyaddr=Xz;SJ.exports.all=LE;SJ.exports.compile=TE;var xJ0=jE(),wE=ME(),hJ0=/^\d+$/u,LG=wE.isValid,TG=wE.parse,DE={linklocal:["169.254.0.0/16","fe80::/10"],loopback:["127.0.0.1/8","::1/128"],uniquelocal:["10.0.0.0/8","172.16.0.0/12","192.168.0.0/16","fc00::/7"]};function LE($,Z){let J=xJ0($);if(!Z)return J;if(typeof Z!=="function")Z=TE(Z);for(let Y=0;Y<J.length-1;Y++){if(Z(J[Y],Y))continue;J.length=Y+1}return J}function TE($){if(!$)throw TypeError("argument is required");let Z;if(typeof $==="string")Z=[$];else if(Array.isArray($))Z=$.slice();else throw TypeError("unsupported trust argument");for(let J=0;J<Z.length;J++){if($=Z[J],!Object.hasOwn(DE,$))continue;$=DE[$],Z.splice.apply(Z,[J,1].concat($)),J+=$.length-1}return uJ0(gJ0(Z))}function gJ0($){let Z=Array($.length);for(let J=0;J<$.length;J++)Z[J]=mJ0($[J]);return Z}function uJ0($){let Z=$.length;return Z===0?dJ0:Z===1?cJ0($[0]):pJ0($)}function mJ0($){let Z=$.lastIndexOf("/"),J=Z!==-1?$.substring(0,Z):$;if(!LG(J))throw TypeError("invalid IP address: "+J);let Y=TG(J);if(Z===-1&&Y.kind()==="ipv6"&&Y.isIPv4MappedAddress())Y=Y.toIPv4Address();let X=Y.kind()==="ipv6"?128:32,Q=Z!==-1?$.substring(Z+1,$.length):null;if(Q===null)Q=X;else if(hJ0.test(Q))Q=parseInt(Q,10);else if(Y.kind()==="ipv4"&&LG(Q))Q=lJ0(Q);else Q=null;if(Q<=0||Q>X)throw TypeError("invalid range on address: "+$);return[Y,Q]}function lJ0($){let Z=TG($);return Z.kind()==="ipv4"?Z.prefixLengthFromSubnetMask():null}function Xz($,Z){if(!$)throw TypeError("req argument is required");if(!Z)throw TypeError("trust argument is required");let J=LE($,Z);return J[J.length-1]}function dJ0(){return!1}function pJ0($){return function(J){if(!LG(J))return!1;let Y=TG(J),X,Q=Y.kind();for(let G=0;G<$.length;G++){let W=$[G],K=W[0],V=K.kind(),U=W[1],H=Y;if(Q!==V){let B=V==="ipv4";if(B&&!Y.isIPv4MappedAddress())continue;if(!X)X=B?Y.toIPv4Address():Y.toIPv4MappedAddress();H=X}if(H.match(K,U))return!0}return!1}}function cJ0($){let Z=$[0],J=Z.kind(),Y=J==="ipv4",X=$[1];return function(G){if(!LG(G))return!1;let W=TG(G);if(W.kind()!==J){if(Y&&!W.isIPv4MappedAddress())return!1;W=Y?W.toIPv4Address():W.toIPv4MappedAddress()}return W.match(Z,X)}}});var PG=S((Ik0,Kz)=>{var RG=RE(),{kHasBeenDecorated:iJ0,kSchemaBody:nJ0,kSchemaHeaders:oJ0,kSchemaParams:sJ0,kSchemaQuerystring:PE,kSchemaController:Qz,kOptions:rJ0,kRequestCacheValidateFns:pZ,kRouteContext:d$,kRequestOriginalUrl:Gz,kRequestSignal:IE,kOnAbort:aJ0}=H$(),{FST_ERR_REQ_INVALID_VALIDATION_INVOCATION:tJ0,FST_ERR_DEC_UNDECLARED:eJ0}=L$(),CE=mX(),EE={body:nJ0,headers:oJ0,params:sJ0,querystring:PE,query:PE};function Wz($,Z,J,Y,X,Q){this.id=$,this[d$]=Q,this.params=Z,this.raw=J,this.query=Y,this.log=X,this.body=void 0}Wz.props=[];function $Y0($){if(typeof $==="function")return $;if($===!0)return function(){return!0};if(typeof $==="number")return function(Z,J){return J<$};if(typeof $==="string"){let Z=$.split(",").map((J)=>J.trim());return RG.compile(Z)}return RG.compile($)}function ZY0($,Z){if(Z)return JY0($,Z);return SE($)}function SE($){let Z=$.props.slice();function J(Y,X,Q,G,W,K){this.id=Y,this[d$]=K,this.params=X,this.raw=Q,this.query=G,this.log=W,this.body=void 0;let V;for(let U=0;U<Z.length;U++)V=Z[U],this[V.key]=V.value}return Object.setPrototypeOf(J.prototype,$.prototype),Object.setPrototypeOf(J,$),J.props=Z,J.parent=$,J}function bE($){let Z=$.lastIndexOf(",");return Z===-1?$.trim():$.slice(Z+1).trim()}function JY0($,Z){let J=SE($),Y=$Y0(Z);return J[iJ0]=!0,Object.defineProperties(J.prototype,{ip:{get(){let X=RG.all(this.raw,Y);return X[X.length-1]}},ips:{get(){return RG.all(this.raw,Y)}},host:{get(){let X=this.raw.socket?.remoteAddress;if(this.headers["x-forwarded-host"]&&X!==null&&Y(X,0))return bE(this.headers["x-forwarded-host"]);return this.headers.host??this.headers[":authority"]??""}},protocol:{get(){let X=this.raw.socket?.remoteAddress;if(this.headers["x-forwarded-proto"]&&X!==null&&Y(X,0))return bE(this.headers["x-forwarded-proto"]);if(this.socket)return this.socket.encrypted?"https":"http"}}}),J}function _E($,Z){if(!CE.hasKey($,Z)&&!CE.exist($,Z))throw new eJ0(Z,"request")}Object.defineProperties(Wz.prototype,{server:{get(){return this[d$].server}},url:{get(){return this.raw.url}},originalUrl:{get(){if(!this[Gz])this[Gz]=this.raw.originalUrl||this.raw.url;return this[Gz]}},method:{get(){return this.raw.method}},routeOptions:{get(){let $=this[d$],Z=$._parserOptions.limit,J=$.server.initialConfig.bodyLimit,Y=$.server.hasConstraintStrategy("version")?this.raw.headers["accept-version"]:void 0;return{method:$.config?.method,url:$.config?.url,bodyLimit:Z||J,handlerTimeout:$.handlerTimeout,attachValidation:$.attachValidation,logLevel:$.logLevel,exposeHeadRoute:$.exposeHeadRoute,prefixTrailingSlash:$.prefixTrailingSlash,handler:$.handler,config:$.config,schema:$.schema,version:Y}}},is404:{get(){return this[d$].config?.url===void 0}},socket:{get(){return this.raw.socket}},signal:{get(){let $=this[IE];if($)return $.signal;$=new AbortController,this[IE]=$;let Z=()=>{if(!$.signal.aborted)$.abort()};return this.raw.on("close",Z),this[aJ0]=Z,$.signal}},ip:{get(){if(this.socket)return this.socket.remoteAddress}},host:{get(){return this.raw.headers.host??this.raw.headers[":authority"]??""}},hostname:{get(){if(this.host[0]==="[")return this.host.slice(0,this.host.indexOf("]")+1);return this.host.split(":",1)[0]}},port:{get(){let $=/(?<port>:\d+)$/,Z=this.headers.host??this.headers[":authority"]??"",J=$.exec(Z);if(J===null||J[1]===void 0)return null;return parseInt(J.groups.port.slice(1),10)}},protocol:{get(){if(this.socket)return this.socket.encrypted?"https":"http"}},headers:{get(){if(this.additionalHeaders)return Object.assign({},this.raw.headers,this.additionalHeaders);return this.raw.headers},set($){this.additionalHeaders=$}},getValidationFunction:{value:function($){if(typeof $==="string"){let Z=EE[$];return this[d$][Z]}else if(typeof $==="object")return this[d$][pZ]?.get($)}},compileValidationSchema:{value:function($,Z=null){let{method:J,url:Y}=this;if(this[d$][pZ]?.has($))return this[d$][pZ].get($);let Q=(this[d$].validatorCompiler||this.server[Qz].validatorCompiler||(this.server[Qz].setupValidator(this.server[rJ0])||this.server[Qz].validatorCompiler))({schema:$,method:J,url:Y,httpPart:Z});if(this[d$][pZ]==null)this[d$][pZ]=new WeakMap;return this[d$][pZ].set($,Q),Q}},validateInput:{value:function($,Z,J){J=typeof Z==="string"?Z:J;let Y=J!=null&&typeof J==="string"&&EE[J],X;if(Y)X=this[d$][Y];if(X==null&&(Z==null||typeof Z!=="object"||Array.isArray(Z)))throw new tJ0(J);if(X==null)if(this[d$][pZ]?.has(Z))X=this[d$][pZ].get(Z);else X=this.compileValidationSchema(Z,J);return X($)}},getDecorator:{value:function($){_E(this,$);let Z=this[$];if(typeof Z==="function")return Z.bind(this);return Z}},setDecorator:{value:function($,Z){_E(this,$),this[$]=Z}}});Kz.exports=Wz;Kz.exports.buildRequest=ZY0});var IG=S((Ck0,fE)=>{var{kFourOhFourContext:YY0,kReplySerializerDefault:XY0,kSchemaErrorFormatter:QY0,kErrorHandler:GY0,kChildLoggerFactory:WY0,kOptions:KY0,kReply:VY0,kRequest:UY0,kBodyLimit:HY0,kLogLevel:BY0,kContentTypeParser:zY0,kRouteByFastify:FY0,kRequestCacheValidateFns:AY0,kReplyCacheSerializeFns:OY0,kHandlerTimeout:qY0}=H$();function jY0({schema:$,handler:Z,config:J,requestIdLogLabel:Y,childLoggerFactory:X,errorHandler:Q,bodyLimit:G,logLevel:W,logSerializers:K,attachValidation:V,validatorCompiler:U,serializerCompiler:H,replySerializer:B,schemaErrorFormatter:z,exposeHeadRoute:F,prefixTrailingSlash:A,server:j,isFastify:N,handlerTimeout:L}){this.schema=$,this.handler=Z,this.Reply=j[VY0],this.Request=j[UY0],this.contentTypeParser=j[zY0],this.onRequest=null,this.onSend=null,this.onError=null,this.onTimeout=null,this.preHandler=null,this.onResponse=null,this.preSerialization=null,this.onRequestAbort=null,this.config=J,this.errorHandler=Q||j[GY0],this.requestIdLogLabel=Y||j[KY0].requestIdLogLabel,this.childLoggerFactory=X||j[WY0],this._middie=null,this._parserOptions={limit:G||j[HY0]},this.exposeHeadRoute=F,this.prefixTrailingSlash=A,this.logLevel=W||j[BY0],this.logSerializers=K,this[YY0]=null,this.attachValidation=V,this[XY0]=B,this.schemaErrorFormatter=z||j[QY0]||NY0,this[FY0]=N,this[AY0]=null,this[OY0]=null,this.validatorCompiler=U||null,this.serializerCompiler=H||null,this.handlerTimeout=L||j[qY0]||0,this.server=j}function NY0($,Z){let J="",Y=", ";for(let X=0;X!==$.length;++X){let Q=$[X];J+=Z+(Q.instancePath||"")+" "+Q.message+Y}return Error(J.slice(0,-Y.length))}fE.exports=jY0});var Bz=S((MY0)=>{class vE{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=new Map,this.last=null,this.max=$,this.ttl=Z}get size(){return this.items.size}clear(){this.items=new Map,this.first=null,this.last=null}delete($){if(this.items.has($)){let Z=this.items.get($);if(this.items.delete($),Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(this.items.delete($.key),this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(this.items.has($))return this.items.get($).expiry}get($){if(this.items.has($)){let Z=this.items.get($);if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return this.items.keys()}set($,Z){if(this.items.has($)){let Y=this.items.get($);Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl;return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items.set($,J),this.size===1)this.first=J;else this.last.next=J;this.last=J}}class Vz{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this.max=$,this.ttl=Z}clear(){this.items=Object.create(null),this.first=null,this.last=null,this.size=0}delete($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(delete this.items[$],this.size--,Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(delete this.items[$.key],--this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(Object.prototype.hasOwnProperty.call(this.items,$))return this.items[$].expiry}get($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return Object.keys(this.items)}set($,Z){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Y=this.items[$];Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl;return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items[$]=J,++this.size===1)this.first=J;else this.last.next=J;this.last=J}}class Uz{constructor(){this.records={}}initForCache($,Z){this.records[$]={[Z]:{cacheSize:0,hits:0,falsyHits:0,emptyHits:0,misses:0,expirations:0,evictions:0,invalidateOne:0,invalidateAll:0,sets:0}}}resetForCache($){for(let Z of Object.keys(this.records[$]))this.records[$][Z]={cacheSize:0,hits:0,falsyHits:0,emptyHits:0,misses:0,expirations:0,evictions:0,invalidateOne:0,invalidateAll:0,sets:0}}getStatistics(){return this.records}}class yE{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=new Map,this.last=null,this.max=$,this.ttl=Z}get size(){return this.items.size}bumpLru($){if(this.last===$)return;let Z=this.last,J=$.next,Y=$.prev;if(this.first===$)this.first=J;if($.next=null,$.prev=Z,Z.next=$,Y!==null)Y.next=J;if(J!==null)J.prev=Y;this.last=$}clear(){this.items=new Map,this.first=null,this.last=null}delete($){if(this.items.has($)){let Z=this.items.get($);if(this.items.delete($),Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(this.items.delete($.key),this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(this.items.has($))return this.items.get($).expiry}get($){if(this.items.has($)){let Z=this.items.get($);if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return this.bumpLru(Z),Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return this.items.keys()}set($,Z){if(this.items.has($)){let Y=this.items.get($);if(Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl,this.last!==Y)this.bumpLru(Y);return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items.set($,J),this.size===1)this.first=J;else this.last.next=J;this.last=J}}class CG{constructor($=1000,Z=0){if(isNaN($)||$<0)throw Error("Invalid max value");if(isNaN(Z)||Z<0)throw Error("Invalid ttl value");this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this.max=$,this.ttl=Z}bumpLru($){if(this.last===$)return;let Z=this.last,J=$.next,Y=$.prev;if(this.first===$)this.first=J;if($.next=null,$.prev=Z,Z.next=$,Y!==null)Y.next=J;if(J!==null)J.prev=Y;this.last=$}clear(){this.items=Object.create(null),this.first=null,this.last=null,this.size=0}delete($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(delete this.items[$],this.size--,Z.prev!==null)Z.prev.next=Z.next;if(Z.next!==null)Z.next.prev=Z.prev;if(this.first===Z)this.first=Z.next;if(this.last===Z)this.last=Z.prev}}deleteMany($){for(var Z=0;Z<$.length;Z++)this.delete($[Z])}evict(){if(this.size>0){let $=this.first;if(delete this.items[$.key],--this.size===0)this.first=null,this.last=null;else this.first=$.next,this.first.prev=null}}expiresAt($){if(Object.prototype.hasOwnProperty.call(this.items,$))return this.items[$].expiry}get($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($);return}return this.bumpLru(Z),Z.value}}getMany($){let Z=[];for(var J=0;J<$.length;J++)Z.push(this.get($[J]));return Z}keys(){return Object.keys(this.items)}set($,Z){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Y=this.items[$];if(Y.value=Z,Y.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl,this.last!==Y)this.bumpLru(Y);return}if(this.max>0&&this.size===this.max)this.evict();let J={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:$,prev:this.last,next:null,value:Z};if(this.items[$]=J,++this.size===1)this.first=J;else this.last.next=J;this.last=J}}function kE($){return`${$.getFullYear()}-${($.getMonth()+1).toString().padStart(2,"0")}-${$.getDate().toString().padStart(2,"0")}`}class xE{constructor($,Z,J){this.cacheId=$,this.statisticTtlInHours=Z,this.collectionStart=new Date,this.currentTimeStamp=kE(this.collectionStart),this.records=J||new Uz,this.records.initForCache(this.cacheId,this.currentTimeStamp)}get currentRecord(){if(!this.records.records[this.cacheId][this.currentTimeStamp])this.records.records[this.cacheId][this.currentTimeStamp]={cacheSize:0,hits:0,falsyHits:0,emptyHits:0,misses:0,expirations:0,evictions:0,sets:0,invalidateOne:0,invalidateAll:0};return this.records.records[this.cacheId][this.currentTimeStamp]}hoursPassed(){return(Date.now()-this.collectionStart)/1000/60/60}addHit(){this.archiveIfNeeded(),this.currentRecord.hits++}addFalsyHit(){this.archiveIfNeeded(),this.currentRecord.falsyHits++}addEmptyHit(){this.archiveIfNeeded(),this.currentRecord.emptyHits++}addMiss(){this.archiveIfNeeded(),this.currentRecord.misses++}addEviction(){this.archiveIfNeeded(),this.currentRecord.evictions++}setCacheSize($){this.archiveIfNeeded(),this.currentRecord.cacheSize=$}addExpiration(){this.archiveIfNeeded(),this.currentRecord.expirations++}addSet(){this.archiveIfNeeded(),this.currentRecord.sets++}addInvalidateOne(){this.archiveIfNeeded(),this.currentRecord.invalidateOne++}addInvalidateAll(){this.archiveIfNeeded(),this.currentRecord.invalidateAll++}getStatistics(){return this.records.getStatistics()}archiveIfNeeded(){if(this.hoursPassed()>=this.statisticTtlInHours)this.collectionStart=new Date,this.currentTimeStamp=kE(this.collectionStart),this.records.initForCache(this.cacheId,this.currentTimeStamp)}}class Hz extends CG{constructor($,Z,J,Y,X){super($||1000,Z||0);if(!J)throw Error("Cache id is mandatory");this.hitStatistics=new xE(J,X!==void 0?X:24,Y)}getStatistics(){return this.hitStatistics.getStatistics()}set($,Z){super.set($,Z),this.hitStatistics.addSet(),this.hitStatistics.setCacheSize(this.size)}evict(){super.evict(),this.hitStatistics.addEviction(),this.hitStatistics.setCacheSize(this.size)}delete($,Z=!1){if(super.delete($),!Z)this.hitStatistics.addInvalidateOne();this.hitStatistics.setCacheSize(this.size)}clear(){super.clear(),this.hitStatistics.addInvalidateAll(),this.hitStatistics.setCacheSize(this.size)}get($){if(Object.prototype.hasOwnProperty.call(this.items,$)){let Z=this.items[$];if(this.ttl>0&&Z.expiry<=Date.now()){this.delete($,!0),this.hitStatistics.addExpiration();return}if(this.bumpLru(Z),!Z.value)this.hitStatistics.addFalsyHit();if(Z.value===void 0||Z.value===null||Z.value==="")this.hitStatistics.addEmptyHit();return this.hitStatistics.addHit(),Z.value}this.hitStatistics.addMiss()}}MY0.Fifo=Vz;MY0.FifoMap=vE;MY0.FifoObject=Vz;MY0.HitStatisticsRecord=Uz;MY0.Lru=CG;MY0.LruHitStatistics=Hz;MY0.LruMap=yE;MY0.LruObject=CG;MY0.LruObjectHitStatistics=Hz});var lE=S((bk0,fJ)=>{var bY0=typeof Buffer<"u",hE=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,gE=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function uE($,Z,J){if(J==null){if(Z!==null&&typeof Z==="object")J=Z,Z=void 0}if(bY0&&Buffer.isBuffer($))$=$.toString();if($&&$.charCodeAt(0)===65279)$=$.slice(1);let Y=JSON.parse($,Z);if(Y===null||typeof Y!=="object")return Y;let X=J&&J.protoAction||"error",Q=J&&J.constructorAction||"error";if(X==="ignore"&&Q==="ignore")return Y;if(X!=="ignore"&&Q!=="ignore"){if(hE.test($)===!1&&gE.test($)===!1)return Y}else if(X!=="ignore"&&Q==="ignore"){if(hE.test($)===!1)return Y}else if(gE.test($)===!1)return Y;return mE(Y,{protoAction:X,constructorAction:Q,safe:J&&J.safe})}function mE($,{protoAction:Z="error",constructorAction:J="error",safe:Y}={}){let X=[$];while(X.length){let Q=X;X=[];for(let G of Q){if(Z!=="ignore"&&Object.prototype.hasOwnProperty.call(G,"__proto__")){if(Y===!0)return null;else if(Z==="error")throw SyntaxError("Object contains forbidden prototype property");delete G.__proto__}if(J!=="ignore"&&Object.prototype.hasOwnProperty.call(G,"constructor")&&G.constructor!==null&&typeof G.constructor==="object"&&Object.prototype.hasOwnProperty.call(G.constructor,"prototype")){if(Y===!0)return null;else if(J==="error")throw SyntaxError("Object contains forbidden prototype property");delete G.constructor}for(let W in G){let K=G[W];if(K&&typeof K==="object")X.push(K)}}}return $}function zz($,Z,J){let{stackTraceLimit:Y}=Error;Error.stackTraceLimit=0;try{return uE($,Z,J)}finally{Error.stackTraceLimit=Y}}function _Y0($,Z){let{stackTraceLimit:J}=Error;Error.stackTraceLimit=0;try{return uE($,Z,{safe:!0})}catch{return}finally{Error.stackTraceLimit=J}}fJ.exports=zz;fJ.exports.default=zz;fJ.exports.parse=zz;fJ.exports.safeParse=_Y0;fJ.exports.scan=mE});var jz=S((_k0,iX)=>{var{AsyncResource:SY0}=Y0("async_hooks"),{FifoMap:cE}=Bz(),{parse:fY0}=lE(),cX=lH(),{kDefaultJsonParse:pX,kContentTypeParser:kJ,kBodyLimit:kY0,kRequestPayloadStream:iE,kState:Az,kTestInternals:vY0,kReplyIsError:dE,kRouteContext:yY0}=H$(),{FST_ERR_CTP_INVALID_TYPE:EG,FST_ERR_CTP_EMPTY_TYPE:xY0,FST_ERR_CTP_ALREADY_PRESENT:hY0,FST_ERR_CTP_INVALID_HANDLER:gY0,FST_ERR_CTP_INVALID_PARSE_TYPE:uY0,FST_ERR_CTP_BODY_TOO_LARGE:pE,FST_ERR_CTP_INVALID_MEDIA_TYPE:mY0,FST_ERR_CTP_INVALID_CONTENT_LENGTH:lY0,FST_ERR_CTP_EMPTY_JSON_BODY:dY0,FST_ERR_CTP_INSTANCE_ALREADY_STARTED:Oz,FST_ERR_CTP_INVALID_JSON_BODY:pY0}=L$(),{FSTSEC001:cY0}=wJ();function $Z($,Z,J){this[pX]=oE(Z,J),this.customParsers=new Map,this.customParsers.set("application/json",new Fz(!0,!1,$,this[pX])),this.customParsers.set("text/plain",new Fz(!0,!1,$,qz)),this.parserList=["application/json","text/plain"],this.parserRegExpList=[],this.cache=new cE(100)}$Z.prototype.add=function($,Z,J){let Y=typeof $==="string";if(Y){if($=$.trim().toLowerCase(),$.length===0)throw new xY0}else if(!($ instanceof RegExp))throw new EG;if(typeof J!=="function")throw new gY0;if(this.existingParser($))throw new hY0($);if(Z.parseAs!==void 0){if(Z.parseAs!=="string"&&Z.parseAs!=="buffer")throw new uY0(Z.parseAs)}let X=new Fz(Z.parseAs==="string",Z.parseAs==="buffer",Z.bodyLimit,J);if($==="*")this.customParsers.set("",X);else if(Y){let Q=new cX($);if(Q.isValid===!1)throw new EG;let G=Q.toString();this.parserList.unshift(G),this.customParsers.set(G,X)}else aY0($),this.parserRegExpList.unshift($),this.customParsers.set($.toString(),X)};$Z.prototype.hasParser=function($){if(typeof $==="string")$=new cX($).toString();else{if(!($ instanceof RegExp))throw new EG;$=$.toString()}return this.customParsers.has($)};$Z.prototype.existingParser=function($){if(typeof $==="string"){let Z=new cX($).toString();if($==="application/json"&&this.customParsers.has($))return this.customParsers.get(Z).fn!==this[pX];if($==="text/plain"&&this.customParsers.has($))return this.customParsers.get(Z).fn!==qz}return this.hasParser($)};$Z.prototype.getParser=function($){if(typeof $==="string")$=new cX($);let Z=$.toString(),J=this.cache.get(Z);if(J!==void 0)return J;if(J=this.customParsers.get(Z),J!==void 0)return this.cache.set(Z,J),J;if(J=this.customParsers.get($.mediaType),J!==void 0)return J;for(let Y=0;Y!==this.parserRegExpList.length;++Y){let X=this.parserRegExpList[Y];if(X.test(Z))return J=this.customParsers.get(X.toString()),this.cache.set(Z,J),J}return this.customParsers.get("")};$Z.prototype.removeAll=function(){this.customParsers=new Map,this.parserRegExpList=[],this.parserList=[],this.cache=new cE(100)};$Z.prototype.remove=function($){let Z;if(typeof $==="string")$=new cX($).toString(),Z=this.parserList;else{if(!($ instanceof RegExp))throw new EG;$=$.toString(),Z=this.parserRegExpList}let J=this.customParsers.delete($),Y=Z.findIndex((X)=>X.toString()===$);if(Y>-1)Z.splice(Y,1);return J||Y>-1};$Z.prototype.run=function($,Z,J,Y){let X=this.getParser($);if(X===void 0){if(J.is404===!0){Z(J,Y);return}Y[dE]=!0,Y.send(new mY0);return}let Q=new SY0("content-type-parser:run",J),G=Q.bind(K);if(X.asString===!0||X.asBuffer===!0){nE(J,Y,Y[yY0]._parserOptions,X,G);return}let W=X.fn(J,J[iE],G);if(W&&typeof W.then==="function")W.then((V)=>{G(null,V)},G);function K(V,U){if(Q.emitDestroy(),V!=null){Y.header("connection","close"),Y[dE]=!0,Y.send(V);return}J.body=U,Z(J,Y)}};function nE($,Z,J,Y,X){let Q=Y.asString===!0,G=J.limit===null?Y.bodyLimit:J.limit,W=Number($.headers["content-length"]);if(W>G){X(new pE,void 0);return}let K=0,V=Q?"":[],U=$[iE]||$.raw;if(Q)U.setEncoding("utf8");U.on("data",H),U.on("end",B),U.on("error",B),U.resume();function H(z){K+=Q?Buffer.byteLength(z):z.length;let{receivedEncodedLength:F=0}=U;if(K>G||F>G){U.removeListener("data",H),U.removeListener("end",B),U.removeListener("error",B),X(new pE,void 0);return}if(Q)V+=z;else V.push(z)}function B(z){if(U.removeListener("data",H),U.removeListener("end",B),U.removeListener("error",B),z!=null){if(!(typeof z.statusCode==="number"&&z.statusCode>=400))z.statusCode=400;X(z,void 0);return}if(!Number.isNaN(W)&&(U.receivedEncodedLength||K)!==W){X(new lY0,void 0);return}if(!Q)V=Buffer.concat(V);let F=Y.fn($,V,X);if(F&&typeof F.then==="function")F.then((A)=>{X(null,A)},X)}}function oE($,Z){let J={protoAction:$,constructorAction:Z};return Y;function Y(X,Q,G){if(Q.length===0){G(new dY0,void 0);return}try{G(null,fY0(Q,J))}catch{G(new pY0,void 0)}}}function qz($,Z,J){J(null,Z)}function Fz($,Z,J,Y){this.asString=$,this.asBuffer=Z,this.bodyLimit=J,this.fn=Y}function iY0($){let Z=new $Z;return Z[pX]=$[pX],Z.customParsers=new Map($.customParsers.entries()),Z.parserList=$.parserList.slice(),Z.parserRegExpList=$.parserRegExpList.slice(),Z}function nY0($,Z,J){if(this[Az].started)throw new Oz("addContentTypeParser");if(typeof Z==="function")J=Z,Z={};if(!Z)Z={};if(!Z.bodyLimit)Z.bodyLimit=this[kY0];if(Array.isArray($))$.forEach((Y)=>this[kJ].add(Y,Z,J));else this[kJ].add($,Z,J);return this}function oY0($){return this[kJ].hasParser($)}function sY0($){if(this[Az].started)throw new Oz("removeContentTypeParser");if(Array.isArray($))for(let Z of $)this[kJ].remove(Z);else this[kJ].remove($)}function rY0(){if(this[Az].started)throw new Oz("removeAllContentTypeParsers");this[kJ].removeAll()}function aY0($){if($.source[0]!=="^"&&$.source.includes(";?")===!1)cY0($.source)}iX.exports=$Z;iX.exports.helpers={buildContentTypeParser:iY0,addContentTypeParser:nY0,hasContentTypeParser:oY0,removeContentTypeParser:sY0,removeAllContentTypeParsers:rY0};iX.exports.defaultParsers={getDefaultJsonParser:oE,defaultTextParser:qz};iX.exports[vY0]={rawBody:nE}});var yJ=S((aE)=>{Object.defineProperty(aE,"__esModule",{value:!0});aE.regexpCode=aE.getEsmExportName=aE.getProperty=aE.safeStringify=aE.stringify=aE.strConcat=aE.addCodeArg=aE.str=aE._=aE.nil=aE._Code=aE.Name=aE.IDENTIFIER=aE._CodeOrName=void 0;class bG{}aE._CodeOrName=bG;aE.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class vJ extends bG{constructor($){super();if(!aE.IDENTIFIER.test($))throw Error("CodeGen: name must be a valid identifier");this.str=$}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}aE.Name=vJ;class Z6 extends bG{constructor($){super();this._items=typeof $==="string"?[$]:$}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let $=this._items[0];return $===""||$==='""'}get str(){var $;return($=this._str)!==null&&$!==void 0?$:this._str=this._items.reduce((Z,J)=>`${Z}${J}`,"")}get names(){var $;return($=this._names)!==null&&$!==void 0?$:this._names=this._items.reduce((Z,J)=>{if(J instanceof vJ)Z[J.str]=(Z[J.str]||0)+1;return Z},{})}}aE._Code=Z6;aE.nil=new Z6("");function sE($,...Z){let J=[$[0]],Y=0;while(Y<Z.length)Mz(J,Z[Y]),J.push($[++Y]);return new Z6(J)}aE._=sE;var Nz=new Z6("+");function rE($,...Z){let J=[nX($[0])],Y=0;while(Y<Z.length)J.push(Nz),Mz(J,Z[Y]),J.push(Nz,nX($[++Y]));return tY0(J),new Z6(J)}aE.str=rE;function Mz($,Z){if(Z instanceof Z6)$.push(...Z._items);else if(Z instanceof vJ)$.push(Z);else $.push(ZX0(Z))}aE.addCodeArg=Mz;function tY0($){let Z=1;while(Z<$.length-1){if($[Z]===Nz){let J=eY0($[Z-1],$[Z+1]);if(J!==void 0){$.splice(Z-1,3,J);continue}$[Z++]="+"}Z++}}function eY0($,Z){if(Z==='""')return $;if($==='""')return Z;if(typeof $=="string"){if(Z instanceof vJ||$[$.length-1]!=='"')return;if(typeof Z!="string")return`${$.slice(0,-1)}${Z}"`;if(Z[0]==='"')return $.slice(0,-1)+Z.slice(1);return}if(typeof Z=="string"&&Z[0]==='"'&&!($ instanceof vJ))return`"${$}${Z.slice(1)}`;return}function $X0($,Z){return Z.emptyStr()?$:$.emptyStr()?Z:rE`${$}${Z}`}aE.strConcat=$X0;function ZX0($){return typeof $=="number"||typeof $=="boolean"||$===null?$:nX(Array.isArray($)?$.join(","):$)}function JX0($){return new Z6(nX($))}aE.stringify=JX0;function nX($){return JSON.stringify($).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}aE.safeStringify=nX;function YX0($){return typeof $=="string"&&aE.IDENTIFIER.test($)?new Z6(`.${$}`):sE`[${$}]`}aE.getProperty=YX0;function XX0($){if(typeof $=="string"&&aE.IDENTIFIER.test($))return new Z6(`${$}`);throw Error(`CodeGen: invalid export name: ${$}, use explicit $id name mapping`)}aE.getEsmExportName=XX0;function QX0($){return new Z6($.toString())}aE.regexpCode=QX0});var fG=S((Zb)=>{Object.defineProperty(Zb,"__esModule",{value:!0});Zb.ValueScope=Zb.ValueScopeName=Zb.Scope=Zb.varKinds=Zb.UsedValueState=void 0;var K8=yJ();class eE extends Error{constructor($){super(`CodeGen: "code" for ${$} not defined`);this.value=$.value}}var SG;(function($){$[$.Started=0]="Started",$[$.Completed=1]="Completed"})(SG||(Zb.UsedValueState=SG={}));Zb.varKinds={const:new K8.Name("const"),let:new K8.Name("let"),var:new K8.Name("var")};class wz{constructor({prefixes:$,parent:Z}={}){this._names={},this._prefixes=$,this._parent=Z}toName($){return $ instanceof K8.Name?$:this.name($)}name($){return new K8.Name(this._newName($))}_newName($){let Z=this._names[$]||this._nameGroup($);return`${$}${Z.index++}`}_nameGroup($){var Z,J;if(((J=(Z=this._parent)===null||Z===void 0?void 0:Z._prefixes)===null||J===void 0?void 0:J.has($))||this._prefixes&&!this._prefixes.has($))throw Error(`CodeGen: prefix "${$}" is not allowed in this scope`);return this._names[$]={prefix:$,index:0}}}Zb.Scope=wz;class Lz extends K8.Name{constructor($,Z){super(Z);this.prefix=$}setValue($,{property:Z,itemIndex:J}){this.value=$,this.scopePath=K8._`.${new K8.Name(Z)}[${J}]`}}Zb.ValueScopeName=Lz;var jX0=K8._`\n`;class $b extends wz{constructor($){super($);this._values={},this._scope=$.scope,this.opts={...$,_n:$.lines?jX0:K8.nil}}get(){return this._scope}name($){return new Lz($,this._newName($))}value($,Z){var J;if(Z.ref===void 0)throw Error("CodeGen: ref must be passed in value");let Y=this.toName($),{prefix:X}=Y,Q=(J=Z.key)!==null&&J!==void 0?J:Z.ref,G=this._values[X];if(G){let V=G.get(Q);if(V)return V}else G=this._values[X]=new Map;G.set(Q,Y);let W=this._scope[X]||(this._scope[X]=[]),K=W.length;return W[K]=Z.ref,Y.setValue(Z,{property:X,itemIndex:K}),Y}getValue($,Z){let J=this._values[$];if(!J)return;return J.get(Z)}scopeRefs($,Z=this._values){return this._reduceValues(Z,(J)=>{if(J.scopePath===void 0)throw Error(`CodeGen: name "${J}" has no value`);return K8._`${$}${J.scopePath}`})}scopeCode($=this._values,Z,J){return this._reduceValues($,(Y)=>{if(Y.value===void 0)throw Error(`CodeGen: name "${Y}" has no value`);return Y.value.code},Z,J)}_reduceValues($,Z,J={},Y){let X=K8.nil;for(let Q in $){let G=$[Q];if(!G)continue;let W=J[Q]=J[Q]||new Map;G.forEach((K)=>{if(W.has(K))return;W.set(K,SG.Started);let V=Z(K);if(V){let U=this.opts.es5?Zb.varKinds.var:Zb.varKinds.const;X=K8._`${X}${U} ${K} = ${V};${this.opts._n}`}else if(V=Y===null||Y===void 0?void 0:Y(K))X=K8._`${X}${V}${this.opts._n}`;else throw new eE(K);W.set(K,SG.Completed)})}return X}}Zb.ValueScope=$b});var k0=S((V8)=>{Object.defineProperty(V8,"__esModule",{value:!0});V8.or=V8.and=V8.not=V8.CodeGen=V8.operators=V8.varKinds=V8.ValueScopeName=V8.ValueScope=V8.Scope=V8.Name=V8.regexpCode=V8.stringify=V8.getProperty=V8.nil=V8.strConcat=V8.str=V8._=void 0;var q1=yJ(),J6=fG(),cZ=yJ();Object.defineProperty(V8,"_",{enumerable:!0,get:function(){return cZ._}});Object.defineProperty(V8,"str",{enumerable:!0,get:function(){return cZ.str}});Object.defineProperty(V8,"strConcat",{enumerable:!0,get:function(){return cZ.strConcat}});Object.defineProperty(V8,"nil",{enumerable:!0,get:function(){return cZ.nil}});Object.defineProperty(V8,"getProperty",{enumerable:!0,get:function(){return cZ.getProperty}});Object.defineProperty(V8,"stringify",{enumerable:!0,get:function(){return cZ.stringify}});Object.defineProperty(V8,"regexpCode",{enumerable:!0,get:function(){return cZ.regexpCode}});Object.defineProperty(V8,"Name",{enumerable:!0,get:function(){return cZ.Name}});var gG=fG();Object.defineProperty(V8,"Scope",{enumerable:!0,get:function(){return gG.Scope}});Object.defineProperty(V8,"ValueScope",{enumerable:!0,get:function(){return gG.ValueScope}});Object.defineProperty(V8,"ValueScopeName",{enumerable:!0,get:function(){return gG.ValueScopeName}});Object.defineProperty(V8,"varKinds",{enumerable:!0,get:function(){return gG.varKinds}});V8.operators={GT:new q1._Code(">"),GTE:new q1._Code(">="),LT:new q1._Code("<"),LTE:new q1._Code("<="),EQ:new q1._Code("==="),NEQ:new q1._Code("!=="),NOT:new q1._Code("!"),OR:new q1._Code("||"),AND:new q1._Code("&&"),ADD:new q1._Code("+")};class iZ{optimizeNodes(){return this}optimizeNames($,Z){return this}}class Yb extends iZ{constructor($,Z,J){super();this.varKind=$,this.name=Z,this.rhs=J}render({es5:$,_n:Z}){let J=$?J6.varKinds.var:this.varKind,Y=this.rhs===void 0?"":` = ${this.rhs}`;return`${J} ${this.name}${Y};`+Z}optimizeNames($,Z){if(!$[this.name.str])return;if(this.rhs)this.rhs=hJ(this.rhs,$,Z);return this}get names(){return this.rhs instanceof q1._CodeOrName?this.rhs.names:{}}}class Pz extends iZ{constructor($,Z,J){super();this.lhs=$,this.rhs=Z,this.sideEffects=J}render({_n:$}){return`${this.lhs} = ${this.rhs};`+$}optimizeNames($,Z){if(this.lhs instanceof q1.Name&&!$[this.lhs.str]&&!this.sideEffects)return;return this.rhs=hJ(this.rhs,$,Z),this}get names(){let $=this.lhs instanceof q1.Name?{}:{...this.lhs.names};return hG($,this.rhs)}}class Xb extends Pz{constructor($,Z,J,Y){super($,J,Y);this.op=Z}render({_n:$}){return`${this.lhs} ${this.op}= ${this.rhs};`+$}}class Qb extends iZ{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`${this.label}:`+$}}class Gb extends iZ{constructor($){super();this.label=$,this.names={}}render({_n:$}){return`break${this.label?` ${this.label}`:""};`+$}}class Wb extends iZ{constructor($){super();this.error=$}render({_n:$}){return`throw ${this.error};`+$}get names(){return this.error.names}}class Kb extends iZ{constructor($){super();this.code=$}render({_n:$}){return`${this.code};`+$}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames($,Z){return this.code=hJ(this.code,$,Z),this}get names(){return this.code instanceof q1._CodeOrName?this.code.names:{}}}class uG extends iZ{constructor($=[]){super();this.nodes=$}render($){return this.nodes.reduce((Z,J)=>Z+J.render($),"")}optimizeNodes(){let{nodes:$}=this,Z=$.length;while(Z--){let J=$[Z].optimizeNodes();if(Array.isArray(J))$.splice(Z,1,...J);else if(J)$[Z]=J;else $.splice(Z,1)}return $.length>0?this:void 0}optimizeNames($,Z){let{nodes:J}=this,Y=J.length;while(Y--){let X=J[Y];if(X.optimizeNames($,Z))continue;wX0($,X.names),J.splice(Y,1)}return J.length>0?this:void 0}get names(){return this.nodes.reduce(($,Z)=>e5($,Z.names),{})}}class nZ extends uG{render($){return"{"+$._n+super.render($)+"}"+$._n}}class Vb extends uG{}class oX extends nZ{}oX.kind="else";class ZZ extends nZ{constructor($,Z){super(Z);this.condition=$}render($){let Z=`if(${this.condition})`+super.render($);if(this.else)Z+="else "+this.else.render($);return Z}optimizeNodes(){super.optimizeNodes();let $=this.condition;if($===!0)return this.nodes;let Z=this.else;if(Z){let J=Z.optimizeNodes();Z=this.else=Array.isArray(J)?new oX(J):J}if(Z){if($===!1)return Z instanceof ZZ?Z:Z.nodes;if(this.nodes.length)return this;return new ZZ(Fb($),Z instanceof ZZ?[Z]:Z.nodes)}if($===!1||!this.nodes.length)return;return this}optimizeNames($,Z){var J;if(this.else=(J=this.else)===null||J===void 0?void 0:J.optimizeNames($,Z),!(super.optimizeNames($,Z)||this.else))return;return this.condition=hJ(this.condition,$,Z),this}get names(){let $=super.names;if(hG($,this.condition),this.else)e5($,this.else.names);return $}}ZZ.kind="if";class xJ extends nZ{}xJ.kind="for";class Ub extends xJ{constructor($){super();this.iteration=$}render($){return`for(${this.iteration})`+super.render($)}optimizeNames($,Z){if(!super.optimizeNames($,Z))return;return this.iteration=hJ(this.iteration,$,Z),this}get names(){return e5(super.names,this.iteration.names)}}class Hb extends xJ{constructor($,Z,J,Y){super();this.varKind=$,this.name=Z,this.from=J,this.to=Y}render($){let Z=$.es5?J6.varKinds.var:this.varKind,{name:J,from:Y,to:X}=this;return`for(${Z} ${J}=${Y}; ${J}<${X}; ${J}++)`+super.render($)}get names(){let $=hG(super.names,this.from);return hG($,this.to)}}class Tz extends xJ{constructor($,Z,J,Y){super();this.loop=$,this.varKind=Z,this.name=J,this.iterable=Y}render($){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render($)}optimizeNames($,Z){if(!super.optimizeNames($,Z))return;return this.iterable=hJ(this.iterable,$,Z),this}get names(){return e5(super.names,this.iterable.names)}}class kG extends nZ{constructor($,Z,J){super();this.name=$,this.args=Z,this.async=J}render($){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render($)}}kG.kind="func";class vG extends uG{render($){return"return "+super.render($)}}vG.kind="return";class Bb extends nZ{render($){let Z="try"+super.render($);if(this.catch)Z+=this.catch.render($);if(this.finally)Z+=this.finally.render($);return Z}optimizeNodes(){var $,Z;return super.optimizeNodes(),($=this.catch)===null||$===void 0||$.optimizeNodes(),(Z=this.finally)===null||Z===void 0||Z.optimizeNodes(),this}optimizeNames($,Z){var J,Y;return super.optimizeNames($,Z),(J=this.catch)===null||J===void 0||J.optimizeNames($,Z),(Y=this.finally)===null||Y===void 0||Y.optimizeNames($,Z),this}get names(){let $=super.names;if(this.catch)e5($,this.catch.names);if(this.finally)e5($,this.finally.names);return $}}class yG extends nZ{constructor($){super();this.error=$}render($){return`catch(${this.error})`+super.render($)}}yG.kind="catch";class xG extends nZ{render($){return"finally"+super.render($)}}xG.kind="finally";class zb{constructor($,Z={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...Z,_n:Z.lines?`
112
- `:""},this._extScope=$,this._scope=new J6.Scope({parent:$}),this._nodes=[new Vb]}toString(){return this._root.render(this.opts)}name($){return this._scope.name($)}scopeName($){return this._extScope.name($)}scopeValue($,Z){let J=this._extScope.value($,Z);return(this._values[J.prefix]||(this._values[J.prefix]=new Set)).add(J),J}getScopeValue($,Z){return this._extScope.getValue($,Z)}scopeRefs($){return this._extScope.scopeRefs($,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def($,Z,J,Y){let X=this._scope.toName(Z);if(J!==void 0&&Y)this._constants[X.str]=J;return this._leafNode(new Yb($,X,J)),X}const($,Z,J){return this._def(J6.varKinds.const,$,Z,J)}let($,Z,J){return this._def(J6.varKinds.let,$,Z,J)}var($,Z,J){return this._def(J6.varKinds.var,$,Z,J)}assign($,Z,J){return this._leafNode(new Pz($,Z,J))}add($,Z){return this._leafNode(new Xb($,V8.operators.ADD,Z))}code($){if(typeof $=="function")$();else if($!==q1.nil)this._leafNode(new Kb($));return this}object(...$){let Z=["{"];for(let[J,Y]of $){if(Z.length>1)Z.push(",");if(Z.push(J),J!==Y||this.opts.es5)Z.push(":"),(0,q1.addCodeArg)(Z,Y)}return Z.push("}"),new q1._Code(Z)}if($,Z,J){if(this._blockNode(new ZZ($)),Z&&J)this.code(Z).else().code(J).endIf();else if(Z)this.code(Z).endIf();else if(J)throw Error('CodeGen: "else" body without "then" body');return this}elseIf($){return this._elseNode(new ZZ($))}else(){return this._elseNode(new oX)}endIf(){return this._endBlockNode(ZZ,oX)}_for($,Z){if(this._blockNode($),Z)this.code(Z).endFor();return this}for($,Z){return this._for(new Ub($),Z)}forRange($,Z,J,Y,X=this.opts.es5?J6.varKinds.var:J6.varKinds.let){let Q=this._scope.toName($);return this._for(new Hb(X,Q,Z,J),()=>Y(Q))}forOf($,Z,J,Y=J6.varKinds.const){let X=this._scope.toName($);if(this.opts.es5){let Q=Z instanceof q1.Name?Z:this.var("_arr",Z);return this.forRange("_i",0,q1._`${Q}.length`,(G)=>{this.var(X,q1._`${Q}[${G}]`),J(X)})}return this._for(new Tz("of",Y,X,Z),()=>J(X))}forIn($,Z,J,Y=this.opts.es5?J6.varKinds.var:J6.varKinds.const){if(this.opts.ownProperties)return this.forOf($,q1._`Object.keys(${Z})`,J);let X=this._scope.toName($);return this._for(new Tz("in",Y,X,Z),()=>J(X))}endFor(){return this._endBlockNode(xJ)}label($){return this._leafNode(new Qb($))}break($){return this._leafNode(new Gb($))}return($){let Z=new vG;if(this._blockNode(Z),this.code($),Z.nodes.length!==1)throw Error('CodeGen: "return" should have one node');return this._endBlockNode(vG)}try($,Z,J){if(!Z&&!J)throw Error('CodeGen: "try" without "catch" and "finally"');let Y=new Bb;if(this._blockNode(Y),this.code($),Z){let X=this.name("e");this._currNode=Y.catch=new yG(X),Z(X)}if(J)this._currNode=Y.finally=new xG,this.code(J);return this._endBlockNode(yG,xG)}throw($){return this._leafNode(new Wb($))}block($,Z){if(this._blockStarts.push(this._nodes.length),$)this.code($).endBlock(Z);return this}endBlock($){let Z=this._blockStarts.pop();if(Z===void 0)throw Error("CodeGen: not in self-balancing block");let J=this._nodes.length-Z;if(J<0||$!==void 0&&J!==$)throw Error(`CodeGen: wrong number of nodes: ${J} vs ${$} expected`);return this._nodes.length=Z,this}func($,Z=q1.nil,J,Y){if(this._blockNode(new kG($,Z,J)),Y)this.code(Y).endFunc();return this}endFunc(){return this._endBlockNode(kG)}optimize($=1){while($-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode($){return this._currNode.nodes.push($),this}_blockNode($){this._currNode.nodes.push($),this._nodes.push($)}_endBlockNode($,Z){let J=this._currNode;if(J instanceof $||Z&&J instanceof Z)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${Z?`${$.kind}/${Z.kind}`:$.kind}"`)}_elseNode($){let Z=this._currNode;if(!(Z instanceof ZZ))throw Error('CodeGen: "else" without "if"');return this._currNode=Z.else=$,this}get _root(){return this._nodes[0]}get _currNode(){let $=this._nodes;return $[$.length-1]}set _currNode($){let Z=this._nodes;Z[Z.length-1]=$}}V8.CodeGen=zb;function e5($,Z){for(let J in Z)$[J]=($[J]||0)+(Z[J]||0);return $}function hG($,Z){return Z instanceof q1._CodeOrName?e5($,Z.names):$}function hJ($,Z,J){if($ instanceof q1.Name)return Y($);if(!X($))return $;return new q1._Code($._items.reduce((Q,G)=>{if(G instanceof q1.Name)G=Y(G);if(G instanceof q1._Code)Q.push(...G._items);else Q.push(G);return Q},[]));function Y(Q){let G=J[Q.str];if(G===void 0||Z[Q.str]!==1)return Q;return delete Z[Q.str],G}function X(Q){return Q instanceof q1._Code&&Q._items.some((G)=>G instanceof q1.Name&&Z[G.str]===1&&J[G.str]!==void 0)}}function wX0($,Z){for(let J in Z)$[J]=($[J]||0)-(Z[J]||0)}function Fb($){return typeof $=="boolean"||typeof $=="number"||$===null?!$:q1._`!${Rz($)}`}V8.not=Fb;var LX0=Ab(V8.operators.AND);function TX0(...$){return $.reduce(LX0)}V8.and=TX0;var RX0=Ab(V8.operators.OR);function PX0(...$){return $.reduce(RX0)}V8.or=PX0;function Ab($){return(Z,J)=>Z===q1.nil?J:J===q1.nil?Z:q1._`${Rz(Z)} ${$} ${Rz(J)}`}function Rz($){return $ instanceof q1.Name?$:q1._`(${$})`}});var J1=S((Tb)=>{Object.defineProperty(Tb,"__esModule",{value:!0});Tb.checkStrictMode=Tb.getErrorPath=Tb.Type=Tb.useFunc=Tb.setEvaluated=Tb.evaluatedPropsToName=Tb.mergeEvaluated=Tb.eachItem=Tb.unescapeJsonPointer=Tb.escapeJsonPointer=Tb.escapeFragment=Tb.unescapeFragment=Tb.schemaRefOrVal=Tb.schemaHasRulesButRef=Tb.schemaHasRules=Tb.checkUnknownRules=Tb.alwaysValidSchema=Tb.toHash=void 0;var x1=k0(),bX0=yJ();function _X0($){let Z={};for(let J of $)Z[J]=!0;return Z}Tb.toHash=_X0;function SX0($,Z){if(typeof Z=="boolean")return Z;if(Object.keys(Z).length===0)return!0;return Nb($,Z),!Mb(Z,$.self.RULES.all)}Tb.alwaysValidSchema=SX0;function Nb($,Z=$.schema){let{opts:J,self:Y}=$;if(!J.strictSchema)return;if(typeof Z==="boolean")return;let X=Y.RULES.keywords;for(let Q in Z)if(!X[Q])Lb($,`unknown keyword: "${Q}"`)}Tb.checkUnknownRules=Nb;function Mb($,Z){if(typeof $=="boolean")return!$;for(let J in $)if(Z[J])return!0;return!1}Tb.schemaHasRules=Mb;function fX0($,Z){if(typeof $=="boolean")return!$;for(let J in $)if(J!=="$ref"&&Z.all[J])return!0;return!1}Tb.schemaHasRulesButRef=fX0;function kX0({topSchemaRef:$,schemaPath:Z},J,Y,X){if(!X){if(typeof J=="number"||typeof J=="boolean")return J;if(typeof J=="string")return x1._`${J}`}return x1._`${$}${Z}${(0,x1.getProperty)(Y)}`}Tb.schemaRefOrVal=kX0;function vX0($){return Db(decodeURIComponent($))}Tb.unescapeFragment=vX0;function yX0($){return encodeURIComponent(Cz($))}Tb.escapeFragment=yX0;function Cz($){if(typeof $=="number")return`${$}`;return $.replace(/~/g,"~0").replace(/\//g,"~1")}Tb.escapeJsonPointer=Cz;function Db($){return $.replace(/~1/g,"/").replace(/~0/g,"~")}Tb.unescapeJsonPointer=Db;function xX0($,Z){if(Array.isArray($))for(let J of $)Z(J);else Z($)}Tb.eachItem=xX0;function qb({mergeNames:$,mergeToName:Z,mergeValues:J,resultToName:Y}){return(X,Q,G,W)=>{let K=G===void 0?Q:G instanceof x1.Name?(Q instanceof x1.Name?$(X,Q,G):Z(X,Q,G),G):Q instanceof x1.Name?(Z(X,G,Q),Q):J(Q,G);return W===x1.Name&&!(K instanceof x1.Name)?Y(X,K):K}}Tb.mergeEvaluated={props:qb({mergeNames:($,Z,J)=>$.if(x1._`${J} !== true && ${Z} !== undefined`,()=>{$.if(x1._`${Z} === true`,()=>$.assign(J,!0),()=>$.assign(J,x1._`${J} || {}`).code(x1._`Object.assign(${J}, ${Z})`))}),mergeToName:($,Z,J)=>$.if(x1._`${J} !== true`,()=>{if(Z===!0)$.assign(J,!0);else $.assign(J,x1._`${J} || {}`),Ez($,J,Z)}),mergeValues:($,Z)=>$===!0?!0:{...$,...Z},resultToName:wb}),items:qb({mergeNames:($,Z,J)=>$.if(x1._`${J} !== true && ${Z} !== undefined`,()=>$.assign(J,x1._`${Z} === true ? true : ${J} > ${Z} ? ${J} : ${Z}`)),mergeToName:($,Z,J)=>$.if(x1._`${J} !== true`,()=>$.assign(J,Z===!0?!0:x1._`${J} > ${Z} ? ${J} : ${Z}`)),mergeValues:($,Z)=>$===!0?!0:Math.max($,Z),resultToName:($,Z)=>$.var("items",Z)})};function wb($,Z){if(Z===!0)return $.var("props",!0);let J=$.var("props",x1._`{}`);if(Z!==void 0)Ez($,J,Z);return J}Tb.evaluatedPropsToName=wb;function Ez($,Z,J){Object.keys(J).forEach((Y)=>$.assign(x1._`${Z}${(0,x1.getProperty)(Y)}`,!0))}Tb.setEvaluated=Ez;var jb={};function hX0($,Z){return $.scopeValue("func",{ref:Z,code:jb[Z.code]||(jb[Z.code]=new bX0._Code(Z.code))})}Tb.useFunc=hX0;var Iz;(function($){$[$.Num=0]="Num",$[$.Str=1]="Str"})(Iz||(Tb.Type=Iz={}));function gX0($,Z,J){if($ instanceof x1.Name){let Y=Z===Iz.Num;return J?Y?x1._`"[" + ${$} + "]"`:x1._`"['" + ${$} + "']"`:Y?x1._`"/" + ${$}`:x1._`"/" + ${$}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return J?(0,x1.getProperty)($).toString():"/"+Cz($)}Tb.getErrorPath=gX0;function Lb($,Z,J=$.opts.strictSchema){if(!J)return;if(Z=`strict mode: ${Z}`,J===!0)throw Error(Z);$.self.logger.warn(Z)}Tb.checkStrictMode=Lb});var g8=S((Pb)=>{Object.defineProperty(Pb,"__esModule",{value:!0});var p$=k0(),YQ0={data:new p$.Name("data"),valCxt:new p$.Name("valCxt"),instancePath:new p$.Name("instancePath"),parentData:new p$.Name("parentData"),parentDataProperty:new p$.Name("parentDataProperty"),rootData:new p$.Name("rootData"),dynamicAnchors:new p$.Name("dynamicAnchors"),vErrors:new p$.Name("vErrors"),errors:new p$.Name("errors"),this:new p$.Name("this"),self:new p$.Name("self"),scope:new p$.Name("scope"),json:new p$.Name("json"),jsonPos:new p$.Name("jsonPos"),jsonLen:new p$.Name("jsonLen"),jsonPart:new p$.Name("jsonPart")};Pb.default=YQ0});var sX=S((bb)=>{Object.defineProperty(bb,"__esModule",{value:!0});bb.extendErrors=bb.resetErrorsCount=bb.reportExtraError=bb.reportError=bb.keyword$DataError=bb.keywordError=void 0;var M1=k0(),lG=J1(),a$=g8();bb.keywordError={message:({keyword:$})=>M1.str`must pass "${$}" keyword validation`};bb.keyword$DataError={message:({keyword:$,schemaType:Z})=>Z?M1.str`"${$}" keyword must be ${Z} ($data)`:M1.str`"${$}" keyword is invalid ($data)`};function QQ0($,Z=bb.keywordError,J,Y){let{it:X}=$,{gen:Q,compositeRule:G,allErrors:W}=X,K=Eb($,Z,J);if(Y!==null&&Y!==void 0?Y:G||W)Ib(Q,K);else Cb(X,M1._`[${K}]`)}bb.reportError=QQ0;function GQ0($,Z=bb.keywordError,J){let{it:Y}=$,{gen:X,compositeRule:Q,allErrors:G}=Y,W=Eb($,Z,J);if(Ib(X,W),!(Q||G))Cb(Y,a$.default.vErrors)}bb.reportExtraError=GQ0;function WQ0($,Z){$.assign(a$.default.errors,Z),$.if(M1._`${a$.default.vErrors} !== null`,()=>$.if(Z,()=>$.assign(M1._`${a$.default.vErrors}.length`,Z),()=>$.assign(a$.default.vErrors,null)))}bb.resetErrorsCount=WQ0;function KQ0({gen:$,keyword:Z,schemaValue:J,data:Y,errsCount:X,it:Q}){if(X===void 0)throw Error("ajv implementation error");let G=$.name("err");$.forRange("i",X,a$.default.errors,(W)=>{if($.const(G,M1._`${a$.default.vErrors}[${W}]`),$.if(M1._`${G}.instancePath === undefined`,()=>$.assign(M1._`${G}.instancePath`,(0,M1.strConcat)(a$.default.instancePath,Q.errorPath))),$.assign(M1._`${G}.schemaPath`,M1.str`${Q.errSchemaPath}/${Z}`),Q.opts.verbose)$.assign(M1._`${G}.schema`,J),$.assign(M1._`${G}.data`,Y)})}bb.extendErrors=KQ0;function Ib($,Z){let J=$.const("err",Z);$.if(M1._`${a$.default.vErrors} === null`,()=>$.assign(a$.default.vErrors,M1._`[${J}]`),M1._`${a$.default.vErrors}.push(${J})`),$.code(M1._`${a$.default.errors}++`)}function Cb($,Z){let{gen:J,validateName:Y,schemaEnv:X}=$;if(X.$async)J.throw(M1._`new ${$.ValidationError}(${Z})`);else J.assign(M1._`${Y}.errors`,Z),J.return(!1)}var $7={keyword:new M1.Name("keyword"),schemaPath:new M1.Name("schemaPath"),params:new M1.Name("params"),propertyName:new M1.Name("propertyName"),message:new M1.Name("message"),schema:new M1.Name("schema"),parentSchema:new M1.Name("parentSchema")};function Eb($,Z,J){let{createErrors:Y}=$.it;if(Y===!1)return M1._`{}`;return VQ0($,Z,J)}function VQ0($,Z,J={}){let{gen:Y,it:X}=$,Q=[UQ0(X,J),HQ0($,J)];return BQ0($,Z,Q),Y.object(...Q)}function UQ0({errorPath:$},{instancePath:Z}){let J=Z?M1.str`${$}${(0,lG.getErrorPath)(Z,lG.Type.Str)}`:$;return[a$.default.instancePath,(0,M1.strConcat)(a$.default.instancePath,J)]}function HQ0({keyword:$,it:{errSchemaPath:Z}},{schemaPath:J,parentSchema:Y}){let X=Y?Z:M1.str`${Z}/${$}`;if(J)X=M1.str`${X}${(0,lG.getErrorPath)(J,lG.Type.Str)}`;return[$7.schemaPath,X]}function BQ0($,{params:Z,message:J},Y){let{keyword:X,data:Q,schemaValue:G,it:W}=$,{opts:K,propertyName:V,topSchemaRef:U,schemaPath:H}=W;if(Y.push([$7.keyword,X],[$7.params,typeof Z=="function"?Z($):Z||M1._`{}`]),K.messages)Y.push([$7.message,typeof J=="function"?J($):J]);if(K.verbose)Y.push([$7.schema,G],[$7.parentSchema,M1._`${U}${H}`],[a$.default.data,Q]);if(V)Y.push([$7.propertyName,V])}});var vb=S((fb)=>{Object.defineProperty(fb,"__esModule",{value:!0});fb.boolOrEmptySchema=fb.topBoolOrEmptySchema=void 0;var qQ0=sX(),jQ0=k0(),NQ0=g8(),MQ0={message:"boolean schema is false"};function DQ0($){let{gen:Z,schema:J,validateName:Y}=$;if(J===!1)Sb($,!1);else if(typeof J=="object"&&J.$async===!0)Z.return(NQ0.default.data);else Z.assign(jQ0._`${Y}.errors`,null),Z.return(!0)}fb.topBoolOrEmptySchema=DQ0;function wQ0($,Z){let{gen:J,schema:Y}=$;if(Y===!1)J.var(Z,!1),Sb($);else J.var(Z,!0)}fb.boolOrEmptySchema=wQ0;function Sb($,Z){let{gen:J,data:Y}=$,X={gen:J,keyword:"false schema",data:Y,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:$};(0,qQ0.reportError)(X,MQ0,void 0,Z)}});var _z=S((yb)=>{Object.defineProperty(yb,"__esModule",{value:!0});yb.getRules=yb.isJSONType=void 0;var TQ0=["string","number","integer","boolean","null","object","array"],RQ0=new Set(TQ0);function PQ0($){return typeof $=="string"&&RQ0.has($)}yb.isJSONType=PQ0;function IQ0(){let $={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...$,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},$.number,$.string,$.array,$.object],post:{rules:[]},all:{},keywords:{}}}yb.getRules=IQ0});var Sz=S((ub)=>{Object.defineProperty(ub,"__esModule",{value:!0});ub.shouldUseRule=ub.shouldUseGroup=ub.schemaHasRulesForType=void 0;function EQ0({schema:$,self:Z},J){let Y=Z.RULES.types[J];return Y&&Y!==!0&&hb($,Y)}ub.schemaHasRulesForType=EQ0;function hb($,Z){return Z.rules.some((J)=>gb($,J))}ub.shouldUseGroup=hb;function gb($,Z){var J;return $[Z.keyword]!==void 0||((J=Z.definition.implements)===null||J===void 0?void 0:J.some((Y)=>$[Y]!==void 0))}ub.shouldUseRule=gb});var rX=S((cb)=>{Object.defineProperty(cb,"__esModule",{value:!0});cb.reportTypeError=cb.checkDataTypes=cb.checkDataType=cb.coerceAndCheckDataType=cb.getJSONTypes=cb.getSchemaTypes=cb.DataType=void 0;var SQ0=_z(),fQ0=Sz(),kQ0=sX(),Y1=k0(),lb=J1(),gJ;(function($){$[$.Correct=0]="Correct",$[$.Wrong=1]="Wrong"})(gJ||(cb.DataType=gJ={}));function vQ0($){let Z=db($.type);if(Z.includes("null")){if($.nullable===!1)throw Error("type: null contradicts nullable: false")}else{if(!Z.length&&$.nullable!==void 0)throw Error('"nullable" cannot be used without "type"');if($.nullable===!0)Z.push("null")}return Z}cb.getSchemaTypes=vQ0;function db($){let Z=Array.isArray($)?$:$?[$]:[];if(Z.every(SQ0.isJSONType))return Z;throw Error("type must be JSONType or JSONType[]: "+Z.join(","))}cb.getJSONTypes=db;function yQ0($,Z){let{gen:J,data:Y,opts:X}=$,Q=xQ0(Z,X.coerceTypes),G=Z.length>0&&!(Q.length===0&&Z.length===1&&(0,fQ0.schemaHasRulesForType)($,Z[0]));if(G){let W=kz(Z,Y,X.strictNumbers,gJ.Wrong);J.if(W,()=>{if(Q.length)hQ0($,Z,Q);else vz($)})}return G}cb.coerceAndCheckDataType=yQ0;var pb=new Set(["string","number","integer","boolean","null"]);function xQ0($,Z){return Z?$.filter((J)=>pb.has(J)||Z==="array"&&J==="array"):[]}function hQ0($,Z,J){let{gen:Y,data:X,opts:Q}=$,G=Y.let("dataType",Y1._`typeof ${X}`),W=Y.let("coerced",Y1._`undefined`);if(Q.coerceTypes==="array")Y.if(Y1._`${G} == 'object' && Array.isArray(${X}) && ${X}.length == 1`,()=>Y.assign(X,Y1._`${X}[0]`).assign(G,Y1._`typeof ${X}`).if(kz(Z,X,Q.strictNumbers),()=>Y.assign(W,X)));Y.if(Y1._`${W} !== undefined`);for(let V of J)if(pb.has(V)||V==="array"&&Q.coerceTypes==="array")K(V);Y.else(),vz($),Y.endIf(),Y.if(Y1._`${W} !== undefined`,()=>{Y.assign(X,W),gQ0($,W)});function K(V){switch(V){case"string":Y.elseIf(Y1._`${G} == "number" || ${G} == "boolean"`).assign(W,Y1._`"" + ${X}`).elseIf(Y1._`${X} === null`).assign(W,Y1._`""`);return;case"number":Y.elseIf(Y1._`${G} == "boolean" || ${X} === null
113
- || (${G} == "string" && ${X} && ${X} == +${X})`).assign(W,Y1._`+${X}`);return;case"integer":Y.elseIf(Y1._`${G} === "boolean" || ${X} === null
114
- || (${G} === "string" && ${X} && ${X} == +${X} && !(${X} % 1))`).assign(W,Y1._`+${X}`);return;case"boolean":Y.elseIf(Y1._`${X} === "false" || ${X} === 0 || ${X} === null`).assign(W,!1).elseIf(Y1._`${X} === "true" || ${X} === 1`).assign(W,!0);return;case"null":Y.elseIf(Y1._`${X} === "" || ${X} === 0 || ${X} === false`),Y.assign(W,null);return;case"array":Y.elseIf(Y1._`${G} === "string" || ${G} === "number"
115
- || ${G} === "boolean" || ${X} === null`).assign(W,Y1._`[${X}]`)}}}function gQ0({gen:$,parentData:Z,parentDataProperty:J},Y){$.if(Y1._`${Z} !== undefined`,()=>$.assign(Y1._`${Z}[${J}]`,Y))}function fz($,Z,J,Y=gJ.Correct){let X=Y===gJ.Correct?Y1.operators.EQ:Y1.operators.NEQ,Q;switch($){case"null":return Y1._`${Z} ${X} null`;case"array":Q=Y1._`Array.isArray(${Z})`;break;case"object":Q=Y1._`${Z} && typeof ${Z} == "object" && !Array.isArray(${Z})`;break;case"integer":Q=G(Y1._`!(${Z} % 1) && !isNaN(${Z})`);break;case"number":Q=G();break;default:return Y1._`typeof ${Z} ${X} ${$}`}return Y===gJ.Correct?Q:(0,Y1.not)(Q);function G(W=Y1.nil){return(0,Y1.and)(Y1._`typeof ${Z} == "number"`,W,J?Y1._`isFinite(${Z})`:Y1.nil)}}cb.checkDataType=fz;function kz($,Z,J,Y){if($.length===1)return fz($[0],Z,J,Y);let X,Q=(0,lb.toHash)($);if(Q.array&&Q.object){let G=Y1._`typeof ${Z} != "object"`;X=Q.null?G:Y1._`!${Z} || ${G}`,delete Q.null,delete Q.array,delete Q.object}else X=Y1.nil;if(Q.number)delete Q.integer;for(let G in Q)X=(0,Y1.and)(X,fz(G,Z,J,Y));return X}cb.checkDataTypes=kz;var uQ0={message:({schema:$})=>`must be ${$}`,params:({schema:$,schemaValue:Z})=>typeof $=="string"?Y1._`{type: ${$}}`:Y1._`{type: ${Z}}`};function vz($){let Z=mQ0($);(0,kQ0.reportError)(Z,uQ0)}cb.reportTypeError=vz;function mQ0($){let{gen:Z,data:J,schema:Y}=$,X=(0,lb.schemaRefOrVal)($,Y,"type");return{gen:Z,keyword:"type",data:J,schema:Y.type,schemaCode:X,schemaValue:X,parentSchema:Y,params:{},it:$}}});var rb=S((ob)=>{Object.defineProperty(ob,"__esModule",{value:!0});ob.assignDefaults=void 0;var uJ=k0(),oQ0=J1();function sQ0($,Z){let{properties:J,items:Y}=$.schema;if(Z==="object"&&J)for(let X in J)nb($,X,J[X].default);else if(Z==="array"&&Array.isArray(Y))Y.forEach((X,Q)=>nb($,Q,X.default))}ob.assignDefaults=sQ0;function nb($,Z,J){let{gen:Y,compositeRule:X,data:Q,opts:G}=$;if(J===void 0)return;let W=uJ._`${Q}${(0,uJ.getProperty)(Z)}`;if(X){(0,oQ0.checkStrictMode)($,`default is ignored for: ${W}`);return}let K=uJ._`${W} === undefined`;if(G.useDefaults==="empty")K=uJ._`${K} || ${W} === null || ${W} === ""`;Y.if(K,uJ._`${W} = ${(0,uJ.stringify)(J)}`)}});var S$=S((eb)=>{Object.defineProperty(eb,"__esModule",{value:!0});eb.validateUnion=eb.validateArray=eb.usePattern=eb.callValidateCode=eb.schemaProperties=eb.allSchemaProperties=eb.noPropertyInData=eb.propertyInData=eb.isOwnProperty=eb.hasPropFunc=eb.reportMissingProp=eb.checkMissingProp=eb.checkReportMissingProp=void 0;var c1=k0(),yz=J1(),oZ=g8(),rQ0=J1();function aQ0($,Z){let{gen:J,data:Y,it:X}=$;J.if(hz(J,Y,Z,X.opts.ownProperties),()=>{$.setParams({missingProperty:c1._`${Z}`},!0),$.error()})}eb.checkReportMissingProp=aQ0;function tQ0({gen:$,data:Z,it:{opts:J}},Y,X){return(0,c1.or)(...Y.map((Q)=>(0,c1.and)(hz($,Z,Q,J.ownProperties),c1._`${X} = ${Q}`)))}eb.checkMissingProp=tQ0;function eQ0($,Z){$.setParams({missingProperty:Z},!0),$.error()}eb.reportMissingProp=eQ0;function ab($){return $.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:c1._`Object.prototype.hasOwnProperty`})}eb.hasPropFunc=ab;function xz($,Z,J){return c1._`${ab($)}.call(${Z}, ${J})`}eb.isOwnProperty=xz;function $90($,Z,J,Y){let X=c1._`${Z}${(0,c1.getProperty)(J)} !== undefined`;return Y?c1._`${X} && ${xz($,Z,J)}`:X}eb.propertyInData=$90;function hz($,Z,J,Y){let X=c1._`${Z}${(0,c1.getProperty)(J)} === undefined`;return Y?(0,c1.or)(X,(0,c1.not)(xz($,Z,J))):X}eb.noPropertyInData=hz;function tb($){return $?Object.keys($).filter((Z)=>Z!=="__proto__"):[]}eb.allSchemaProperties=tb;function Z90($,Z){return tb(Z).filter((J)=>!(0,yz.alwaysValidSchema)($,Z[J]))}eb.schemaProperties=Z90;function J90({schemaCode:$,data:Z,it:{gen:J,topSchemaRef:Y,schemaPath:X,errorPath:Q},it:G},W,K,V){let U=V?c1._`${$}, ${Z}, ${Y}${X}`:Z,H=[[oZ.default.instancePath,(0,c1.strConcat)(oZ.default.instancePath,Q)],[oZ.default.parentData,G.parentData],[oZ.default.parentDataProperty,G.parentDataProperty],[oZ.default.rootData,oZ.default.rootData]];if(G.opts.dynamicRef)H.push([oZ.default.dynamicAnchors,oZ.default.dynamicAnchors]);let B=c1._`${U}, ${J.object(...H)}`;return K!==c1.nil?c1._`${W}.call(${K}, ${B})`:c1._`${W}(${B})`}eb.callValidateCode=J90;var Y90=c1._`new RegExp`;function X90({gen:$,it:{opts:Z}},J){let Y=Z.unicodeRegExp?"u":"",{regExp:X}=Z.code,Q=X(J,Y);return $.scopeValue("pattern",{key:Q.toString(),ref:Q,code:c1._`${X.code==="new RegExp"?Y90:(0,rQ0.useFunc)($,X)}(${J}, ${Y})`})}eb.usePattern=X90;function Q90($){let{gen:Z,data:J,keyword:Y,it:X}=$,Q=Z.name("valid");if(X.allErrors){let W=Z.let("valid",!0);return G(()=>Z.assign(W,!1)),W}return Z.var(Q,!0),G(()=>Z.break()),Q;function G(W){let K=Z.const("len",c1._`${J}.length`);Z.forRange("i",0,K,(V)=>{$.subschema({keyword:Y,dataProp:V,dataPropType:yz.Type.Num},Q),Z.if((0,c1.not)(Q),W)})}}eb.validateArray=Q90;function G90($){let{gen:Z,schema:J,keyword:Y,it:X}=$;if(!Array.isArray(J))throw Error("ajv implementation error");if(J.some((K)=>(0,yz.alwaysValidSchema)(X,K))&&!X.opts.unevaluated)return;let G=Z.let("valid",!1),W=Z.name("_valid");Z.block(()=>J.forEach((K,V)=>{let U=$.subschema({keyword:Y,schemaProp:V,compositeRule:!0},W);if(Z.assign(G,c1._`${G} || ${W}`),!$.mergeValidEvaluated(U,W))Z.if((0,c1.not)(G))})),$.result(G,()=>$.reset(),()=>$.error(!0))}eb.validateUnion=G90});var Q_=S((Y_)=>{Object.defineProperty(Y_,"__esModule",{value:!0});Y_.validateKeywordUsage=Y_.validSchemaType=Y_.funcKeywordCode=Y_.macroKeywordCode=void 0;var t$=k0(),Z7=g8(),N90=S$(),M90=sX();function D90($,Z){let{gen:J,keyword:Y,schema:X,parentSchema:Q,it:G}=$,W=Z.macro.call(G.self,X,Q,G),K=J_(J,Y,W);if(G.opts.validateSchema!==!1)G.self.validateSchema(W,!0);let V=J.name("valid");$.subschema({schema:W,schemaPath:t$.nil,errSchemaPath:`${G.errSchemaPath}/${Y}`,topSchemaRef:K,compositeRule:!0},V),$.pass(V,()=>$.error(!0))}Y_.macroKeywordCode=D90;function w90($,Z){var J;let{gen:Y,keyword:X,schema:Q,parentSchema:G,$data:W,it:K}=$;T90(K,Z);let V=!W&&Z.compile?Z.compile.call(K.self,Q,G,K):Z.validate,U=J_(Y,X,V),H=Y.let("valid");$.block$data(H,B),$.ok((J=Z.valid)!==null&&J!==void 0?J:H);function B(){if(Z.errors===!1){if(A(),Z.modifying)Z_($);j(()=>$.error())}else{let N=Z.async?z():F();if(Z.modifying)Z_($);j(()=>L90($,N))}}function z(){let N=Y.let("ruleErrs",null);return Y.try(()=>A(t$._`await `),(L)=>Y.assign(H,!1).if(t$._`${L} instanceof ${K.ValidationError}`,()=>Y.assign(N,t$._`${L}.errors`),()=>Y.throw(L))),N}function F(){let N=t$._`${U}.errors`;return Y.assign(N,null),A(t$.nil),N}function A(N=Z.async?t$._`await `:t$.nil){let L=K.opts.passContext?Z7.default.this:Z7.default.self,q=!(("compile"in Z)&&!W||Z.schema===!1);Y.assign(H,t$._`${N}${(0,N90.callValidateCode)($,U,L,q)}`,Z.modifying)}function j(N){var L;Y.if((0,t$.not)((L=Z.valid)!==null&&L!==void 0?L:H),N)}}Y_.funcKeywordCode=w90;function Z_($){let{gen:Z,data:J,it:Y}=$;Z.if(Y.parentData,()=>Z.assign(J,t$._`${Y.parentData}[${Y.parentDataProperty}]`))}function L90($,Z){let{gen:J}=$;J.if(t$._`Array.isArray(${Z})`,()=>{J.assign(Z7.default.vErrors,t$._`${Z7.default.vErrors} === null ? ${Z} : ${Z7.default.vErrors}.concat(${Z})`).assign(Z7.default.errors,t$._`${Z7.default.vErrors}.length`),(0,M90.extendErrors)($)},()=>$.error())}function T90({schemaEnv:$},Z){if(Z.async&&!$.$async)throw Error("async keyword in sync schema")}function J_($,Z,J){if(J===void 0)throw Error(`keyword "${Z}" failed to compile`);return $.scopeValue("keyword",typeof J=="function"?{ref:J}:{ref:J,code:(0,t$.stringify)(J)})}function R90($,Z,J=!1){return!Z.length||Z.some((Y)=>Y==="array"?Array.isArray($):Y==="object"?$&&typeof $=="object"&&!Array.isArray($):typeof $==Y||J&&typeof $>"u")}Y_.validSchemaType=R90;function P90({schema:$,opts:Z,self:J,errSchemaPath:Y},X,Q){if(Array.isArray(X.keyword)?!X.keyword.includes(Q):X.keyword!==Q)throw Error("ajv implementation error");let G=X.dependencies;if(G===null||G===void 0?void 0:G.some((W)=>!Object.prototype.hasOwnProperty.call($,W)))throw Error(`parent schema must have dependencies of ${Q}: ${G.join(",")}`);if(X.validateSchema){if(!X.validateSchema($[Q])){let K=`keyword "${Q}" value is invalid at path "${Y}": `+J.errorsText(X.validateSchema.errors);if(Z.validateSchema==="log")J.logger.error(K);else throw Error(K)}}}Y_.validateKeywordUsage=P90});var V_=S((W_)=>{Object.defineProperty(W_,"__esModule",{value:!0});W_.extendSubschemaMode=W_.extendSubschemaData=W_.getSubschema=void 0;var I6=k0(),G_=J1();function b90($,{keyword:Z,schemaProp:J,schema:Y,schemaPath:X,errSchemaPath:Q,topSchemaRef:G}){if(Z!==void 0&&Y!==void 0)throw Error('both "keyword" and "schema" passed, only one allowed');if(Z!==void 0){let W=$.schema[Z];return J===void 0?{schema:W,schemaPath:I6._`${$.schemaPath}${(0,I6.getProperty)(Z)}`,errSchemaPath:`${$.errSchemaPath}/${Z}`}:{schema:W[J],schemaPath:I6._`${$.schemaPath}${(0,I6.getProperty)(Z)}${(0,I6.getProperty)(J)}`,errSchemaPath:`${$.errSchemaPath}/${Z}/${(0,G_.escapeFragment)(J)}`}}if(Y!==void 0){if(X===void 0||Q===void 0||G===void 0)throw Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:Y,schemaPath:X,topSchemaRef:G,errSchemaPath:Q}}throw Error('either "keyword" or "schema" must be passed')}W_.getSubschema=b90;function _90($,Z,{dataProp:J,dataPropType:Y,data:X,dataTypes:Q,propertyName:G}){if(X!==void 0&&J!==void 0)throw Error('both "data" and "dataProp" passed, only one allowed');let{gen:W}=Z;if(J!==void 0){let{errorPath:V,dataPathArr:U,opts:H}=Z,B=W.let("data",I6._`${Z.data}${(0,I6.getProperty)(J)}`,!0);K(B),$.errorPath=I6.str`${V}${(0,G_.getErrorPath)(J,Y,H.jsPropertySyntax)}`,$.parentDataProperty=I6._`${J}`,$.dataPathArr=[...U,$.parentDataProperty]}if(X!==void 0){let V=X instanceof I6.Name?X:W.let("data",X,!0);if(K(V),G!==void 0)$.propertyName=G}if(Q)$.dataTypes=Q;function K(V){$.data=V,$.dataLevel=Z.dataLevel+1,$.dataTypes=[],Z.definedProperties=new Set,$.parentData=Z.data,$.dataNames=[...Z.dataNames,V]}}W_.extendSubschemaData=_90;function S90($,{jtdDiscriminator:Z,jtdMetadata:J,compositeRule:Y,createErrors:X,allErrors:Q}){if(Y!==void 0)$.compositeRule=Y;if(X!==void 0)$.createErrors=X;if(Q!==void 0)$.allErrors=Q;$.jtdDiscriminator=Z,$.jtdMetadata=J}W_.extendSubschemaMode=S90});var aX=S((Xv0,U_)=>{U_.exports=function $(Z,J){if(Z===J)return!0;if(Z&&J&&typeof Z=="object"&&typeof J=="object"){if(Z.constructor!==J.constructor)return!1;var Y,X,Q;if(Array.isArray(Z)){if(Y=Z.length,Y!=J.length)return!1;for(X=Y;X--!==0;)if(!$(Z[X],J[X]))return!1;return!0}if(Z.constructor===RegExp)return Z.source===J.source&&Z.flags===J.flags;if(Z.valueOf!==Object.prototype.valueOf)return Z.valueOf()===J.valueOf();if(Z.toString!==Object.prototype.toString)return Z.toString()===J.toString();if(Q=Object.keys(Z),Y=Q.length,Y!==Object.keys(J).length)return!1;for(X=Y;X--!==0;)if(!Object.prototype.hasOwnProperty.call(J,Q[X]))return!1;for(X=Y;X--!==0;){var G=Q[X];if(!$(Z[G],J[G]))return!1}return!0}return Z!==Z&&J!==J}});var B_=S((Qv0,H_)=>{var sZ=H_.exports=function($,Z,J){if(typeof Z=="function")J=Z,Z={};J=Z.cb||J;var Y=typeof J=="function"?J:J.pre||function(){},X=J.post||function(){};dG(Z,Y,X,$,"",$)};sZ.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};sZ.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};sZ.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};sZ.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function dG($,Z,J,Y,X,Q,G,W,K,V){if(Y&&typeof Y=="object"&&!Array.isArray(Y)){Z(Y,X,Q,G,W,K,V);for(var U in Y){var H=Y[U];if(Array.isArray(H)){if(U in sZ.arrayKeywords)for(var B=0;B<H.length;B++)dG($,Z,J,H[B],X+"/"+U+"/"+B,Q,X,U,Y,B)}else if(U in sZ.propsKeywords){if(H&&typeof H=="object")for(var z in H)dG($,Z,J,H[z],X+"/"+U+"/"+v90(z),Q,X,U,Y,z)}else if(U in sZ.keywords||$.allKeys&&!(U in sZ.skipKeywords))dG($,Z,J,H,X+"/"+U,Q,X,U,Y)}J(Y,X,Q,G,W,K,V)}}function v90($){return $.replace(/~/g,"~0").replace(/\//g,"~1")}});var tX=S((O_)=>{Object.defineProperty(O_,"__esModule",{value:!0});O_.getSchemaRefs=O_.resolveUrl=O_.normalizeId=O_._getFullPath=O_.getFullPath=O_.inlineRef=void 0;var y90=J1(),x90=aX(),h90=B_(),g90=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function u90($,Z=!0){if(typeof $=="boolean")return!0;if(Z===!0)return!gz($);if(!Z)return!1;return z_($)<=Z}O_.inlineRef=u90;var m90=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function gz($){for(let Z in $){if(m90.has(Z))return!0;let J=$[Z];if(Array.isArray(J)&&J.some(gz))return!0;if(typeof J=="object"&&gz(J))return!0}return!1}function z_($){let Z=0;for(let J in $){if(J==="$ref")return 1/0;if(Z++,g90.has(J))continue;if(typeof $[J]=="object")(0,y90.eachItem)($[J],(Y)=>Z+=z_(Y));if(Z===1/0)return 1/0}return Z}function F_($,Z="",J){if(J!==!1)Z=mJ(Z);let Y=$.parse(Z);return A_($,Y)}O_.getFullPath=F_;function A_($,Z){return $.serialize(Z).split("#")[0]+"#"}O_._getFullPath=A_;var l90=/#\/?$/;function mJ($){return $?$.replace(l90,""):""}O_.normalizeId=mJ;function d90($,Z,J){return J=mJ(J),$.resolve(Z,J)}O_.resolveUrl=d90;var p90=/^[a-z_][-a-z0-9._]*$/i;function c90($,Z){if(typeof $=="boolean")return{};let{schemaId:J,uriResolver:Y}=this.opts,X=mJ($[J]||Z),Q={"":X},G=F_(Y,X,!1),W={},K=new Set;return h90($,{allKeys:!0},(H,B,z,F)=>{if(F===void 0)return;let A=G+B,j=Q[F];if(typeof H[J]=="string")j=N.call(this,H[J]);L.call(this,H.$anchor),L.call(this,H.$dynamicAnchor),Q[B]=j;function N(q){let M=this.opts.uriResolver.resolve;if(q=mJ(j?M(j,q):q),K.has(q))throw U(q);K.add(q);let C=this.refs[q];if(typeof C=="string")C=this.refs[C];if(typeof C=="object")V(H,C.schema,q);else if(q!==mJ(A))if(q[0]==="#")V(H,W[q],q),W[q]=H;else this.refs[q]=A;return q}function L(q){if(typeof q=="string"){if(!p90.test(q))throw Error(`invalid anchor "${q}"`);N.call(this,`#${q}`)}}}),W;function V(H,B,z){if(B!==void 0&&!x90(H,B))throw U(z)}function U(H){return Error(`reference "${H}" resolves to more than one schema`)}}O_.getSchemaRefs=c90});var lJ=S((S_)=>{Object.defineProperty(S_,"__esModule",{value:!0});S_.getData=S_.KeywordCxt=S_.validateFunctionCode=void 0;var w_=vb(),j_=rX(),mz=Sz(),pG=rX(),a90=rb(),$Q=Q_(),uz=V_(),L0=k0(),c0=g8(),t90=tX(),JZ=J1(),eX=sX();function e90($){if(R_($)){if(P_($),T_($)){J40($);return}}L_($,()=>(0,w_.topBoolOrEmptySchema)($))}S_.validateFunctionCode=e90;function L_({gen:$,validateName:Z,schema:J,schemaEnv:Y,opts:X},Q){if(X.code.es5)$.func(Z,L0._`${c0.default.data}, ${c0.default.valCxt}`,Y.$async,()=>{$.code(L0._`"use strict"; ${N_(J,X)}`),Z40($,X),$.code(Q)});else $.func(Z,L0._`${c0.default.data}, ${$40(X)}`,Y.$async,()=>$.code(N_(J,X)).code(Q))}function $40($){return L0._`{${c0.default.instancePath}="", ${c0.default.parentData}, ${c0.default.parentDataProperty}, ${c0.default.rootData}=${c0.default.data}${$.dynamicRef?L0._`, ${c0.default.dynamicAnchors}={}`:L0.nil}}={}`}function Z40($,Z){$.if(c0.default.valCxt,()=>{if($.var(c0.default.instancePath,L0._`${c0.default.valCxt}.${c0.default.instancePath}`),$.var(c0.default.parentData,L0._`${c0.default.valCxt}.${c0.default.parentData}`),$.var(c0.default.parentDataProperty,L0._`${c0.default.valCxt}.${c0.default.parentDataProperty}`),$.var(c0.default.rootData,L0._`${c0.default.valCxt}.${c0.default.rootData}`),Z.dynamicRef)$.var(c0.default.dynamicAnchors,L0._`${c0.default.valCxt}.${c0.default.dynamicAnchors}`)},()=>{if($.var(c0.default.instancePath,L0._`""`),$.var(c0.default.parentData,L0._`undefined`),$.var(c0.default.parentDataProperty,L0._`undefined`),$.var(c0.default.rootData,c0.default.data),Z.dynamicRef)$.var(c0.default.dynamicAnchors,L0._`{}`)})}function J40($){let{schema:Z,opts:J,gen:Y}=$;L_($,()=>{if(J.$comment&&Z.$comment)C_($);if(W40($),Y.let(c0.default.vErrors,null),Y.let(c0.default.errors,0),J.unevaluated)Y40($);I_($),U40($)});return}function Y40($){let{gen:Z,validateName:J}=$;$.evaluated=Z.const("evaluated",L0._`${J}.evaluated`),Z.if(L0._`${$.evaluated}.dynamicProps`,()=>Z.assign(L0._`${$.evaluated}.props`,L0._`undefined`)),Z.if(L0._`${$.evaluated}.dynamicItems`,()=>Z.assign(L0._`${$.evaluated}.items`,L0._`undefined`))}function N_($,Z){let J=typeof $=="object"&&$[Z.schemaId];return J&&(Z.code.source||Z.code.process)?L0._`/*# sourceURL=${J} */`:L0.nil}function X40($,Z){if(R_($)){if(P_($),T_($)){Q40($,Z);return}}(0,w_.boolOrEmptySchema)($,Z)}function T_({schema:$,self:Z}){if(typeof $=="boolean")return!$;for(let J in $)if(Z.RULES.all[J])return!0;return!1}function R_($){return typeof $.schema!="boolean"}function Q40($,Z){let{schema:J,gen:Y,opts:X}=$;if(X.$comment&&J.$comment)C_($);K40($),V40($);let Q=Y.const("_errs",c0.default.errors);I_($,Q),Y.var(Z,L0._`${Q} === ${c0.default.errors}`)}function P_($){(0,JZ.checkUnknownRules)($),G40($)}function I_($,Z){if($.opts.jtd)return M_($,[],!1,Z);let J=(0,j_.getSchemaTypes)($.schema),Y=(0,j_.coerceAndCheckDataType)($,J);M_($,J,!Y,Z)}function G40($){let{schema:Z,errSchemaPath:J,opts:Y,self:X}=$;if(Z.$ref&&Y.ignoreKeywordsWithRef&&(0,JZ.schemaHasRulesButRef)(Z,X.RULES))X.logger.warn(`$ref: keywords ignored in schema at path "${J}"`)}function W40($){let{schema:Z,opts:J}=$;if(Z.default!==void 0&&J.useDefaults&&J.strictSchema)(0,JZ.checkStrictMode)($,"default is ignored in the schema root")}function K40($){let Z=$.schema[$.opts.schemaId];if(Z)$.baseId=(0,t90.resolveUrl)($.opts.uriResolver,$.baseId,Z)}function V40($){if($.schema.$async&&!$.schemaEnv.$async)throw Error("async schema in sync schema")}function C_({gen:$,schemaEnv:Z,schema:J,errSchemaPath:Y,opts:X}){let Q=J.$comment;if(X.$comment===!0)$.code(L0._`${c0.default.self}.logger.log(${Q})`);else if(typeof X.$comment=="function"){let G=L0.str`${Y}/$comment`,W=$.scopeValue("root",{ref:Z.root});$.code(L0._`${c0.default.self}.opts.$comment(${Q}, ${G}, ${W}.schema)`)}}function U40($){let{gen:Z,schemaEnv:J,validateName:Y,ValidationError:X,opts:Q}=$;if(J.$async)Z.if(L0._`${c0.default.errors} === 0`,()=>Z.return(c0.default.data),()=>Z.throw(L0._`new ${X}(${c0.default.vErrors})`));else{if(Z.assign(L0._`${Y}.errors`,c0.default.vErrors),Q.unevaluated)H40($);Z.return(L0._`${c0.default.errors} === 0`)}}function H40({gen:$,evaluated:Z,props:J,items:Y}){if(J instanceof L0.Name)$.assign(L0._`${Z}.props`,J);if(Y instanceof L0.Name)$.assign(L0._`${Z}.items`,Y)}function M_($,Z,J,Y){let{gen:X,schema:Q,data:G,allErrors:W,opts:K,self:V}=$,{RULES:U}=V;if(Q.$ref&&(K.ignoreKeywordsWithRef||!(0,JZ.schemaHasRulesButRef)(Q,U))){X.block(()=>b_($,"$ref",U.all.$ref.definition));return}if(!K.jtd)B40($,Z);X.block(()=>{for(let B of U.rules)H(B);H(U.post)});function H(B){if(!(0,mz.shouldUseGroup)(Q,B))return;if(B.type){if(X.if((0,pG.checkDataType)(B.type,G,K.strictNumbers)),D_($,B),Z.length===1&&Z[0]===B.type&&J)X.else(),(0,pG.reportTypeError)($);X.endIf()}else D_($,B);if(!W)X.if(L0._`${c0.default.errors} === ${Y||0}`)}}function D_($,Z){let{gen:J,schema:Y,opts:{useDefaults:X}}=$;if(X)(0,a90.assignDefaults)($,Z.type);J.block(()=>{for(let Q of Z.rules)if((0,mz.shouldUseRule)(Y,Q))b_($,Q.keyword,Q.definition,Z.type)})}function B40($,Z){if($.schemaEnv.meta||!$.opts.strictTypes)return;if(z40($,Z),!$.opts.allowUnionTypes)F40($,Z);A40($,$.dataTypes)}function z40($,Z){if(!Z.length)return;if(!$.dataTypes.length){$.dataTypes=Z;return}Z.forEach((J)=>{if(!E_($.dataTypes,J))lz($,`type "${J}" not allowed by context "${$.dataTypes.join(",")}"`)}),q40($,Z)}function F40($,Z){if(Z.length>1&&!(Z.length===2&&Z.includes("null")))lz($,"use allowUnionTypes to allow union type keyword")}function A40($,Z){let J=$.self.RULES.all;for(let Y in J){let X=J[Y];if(typeof X=="object"&&(0,mz.shouldUseRule)($.schema,X)){let{type:Q}=X.definition;if(Q.length&&!Q.some((G)=>O40(Z,G)))lz($,`missing type "${Q.join(",")}" for keyword "${Y}"`)}}}function O40($,Z){return $.includes(Z)||Z==="number"&&$.includes("integer")}function E_($,Z){return $.includes(Z)||Z==="integer"&&$.includes("number")}function q40($,Z){let J=[];for(let Y of $.dataTypes)if(E_(Z,Y))J.push(Y);else if(Z.includes("integer")&&Y==="number")J.push("integer");$.dataTypes=J}function lz($,Z){let J=$.schemaEnv.baseId+$.errSchemaPath;Z+=` at "${J}" (strictTypes)`,(0,JZ.checkStrictMode)($,Z,$.opts.strictTypes)}class dz{constructor($,Z,J){if((0,$Q.validateKeywordUsage)($,Z,J),this.gen=$.gen,this.allErrors=$.allErrors,this.keyword=J,this.data=$.data,this.schema=$.schema[J],this.$data=Z.$data&&$.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,JZ.schemaRefOrVal)($,this.schema,J,this.$data),this.schemaType=Z.schemaType,this.parentSchema=$.schema,this.params={},this.it=$,this.def=Z,this.$data)this.schemaCode=$.gen.const("vSchema",__(this.$data,$));else if(this.schemaCode=this.schemaValue,!(0,$Q.validSchemaType)(this.schema,Z.schemaType,Z.allowUndefined))throw Error(`${J} value must be ${JSON.stringify(Z.schemaType)}`);if("code"in Z?Z.trackErrors:Z.errors!==!1)this.errsCount=$.gen.const("_errs",c0.default.errors)}result($,Z,J){this.failResult((0,L0.not)($),Z,J)}failResult($,Z,J){if(this.gen.if($),J)J();else this.error();if(Z){if(this.gen.else(),Z(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass($,Z){this.failResult((0,L0.not)($),void 0,Z)}fail($){if($===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if($),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data($){if(!this.$data)return this.fail($);let{schemaCode:Z}=this;this.fail(L0._`${Z} !== undefined && (${(0,L0.or)(this.invalid$data(),$)})`)}error($,Z,J){if(Z){this.setParams(Z),this._error($,J),this.setParams({});return}this._error($,J)}_error($,Z){($?eX.reportExtraError:eX.reportError)(this,this.def.error,Z)}$dataError(){(0,eX.reportError)(this,this.def.$dataError||eX.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add "trackErrors" to keyword definition');(0,eX.resetErrorsCount)(this.gen,this.errsCount)}ok($){if(!this.allErrors)this.gen.if($)}setParams($,Z){if(Z)Object.assign(this.params,$);else this.params=$}block$data($,Z,J=L0.nil){this.gen.block(()=>{this.check$data($,J),Z()})}check$data($=L0.nil,Z=L0.nil){if(!this.$data)return;let{gen:J,schemaCode:Y,schemaType:X,def:Q}=this;if(J.if((0,L0.or)(L0._`${Y} === undefined`,Z)),$!==L0.nil)J.assign($,!0);if(X.length||Q.validateSchema){if(J.elseIf(this.invalid$data()),this.$dataError(),$!==L0.nil)J.assign($,!1)}J.else()}invalid$data(){let{gen:$,schemaCode:Z,schemaType:J,def:Y,it:X}=this;return(0,L0.or)(Q(),G());function Q(){if(J.length){if(!(Z instanceof L0.Name))throw Error("ajv implementation error");let W=Array.isArray(J)?J:[J];return L0._`${(0,pG.checkDataTypes)(W,Z,X.opts.strictNumbers,pG.DataType.Wrong)}`}return L0.nil}function G(){if(Y.validateSchema){let W=$.scopeValue("validate$data",{ref:Y.validateSchema});return L0._`!${W}(${Z})`}return L0.nil}}subschema($,Z){let J=(0,uz.getSubschema)(this.it,$);(0,uz.extendSubschemaData)(J,this.it,$),(0,uz.extendSubschemaMode)(J,$);let Y={...this.it,...J,items:void 0,props:void 0};return X40(Y,Z),Y}mergeEvaluated($,Z){let{it:J,gen:Y}=this;if(!J.opts.unevaluated)return;if(J.props!==!0&&$.props!==void 0)J.props=JZ.mergeEvaluated.props(Y,$.props,J.props,Z);if(J.items!==!0&&$.items!==void 0)J.items=JZ.mergeEvaluated.items(Y,$.items,J.items,Z)}mergeValidEvaluated($,Z){let{it:J,gen:Y}=this;if(J.opts.unevaluated&&(J.props!==!0||J.items!==!0))return Y.if(Z,()=>this.mergeEvaluated($,L0.Name)),!0}}S_.KeywordCxt=dz;function b_($,Z,J,Y){let X=new dz($,J,Z);if("code"in J)J.code(X,Y);else if(X.$data&&J.validate)(0,$Q.funcKeywordCode)(X,J);else if("macro"in J)(0,$Q.macroKeywordCode)(X,J);else if(J.compile||J.validate)(0,$Q.funcKeywordCode)(X,J)}var j40=/^\/(?:[^~]|~0|~1)*$/,N40=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function __($,{dataLevel:Z,dataNames:J,dataPathArr:Y}){let X,Q;if($==="")return c0.default.rootData;if($[0]==="/"){if(!j40.test($))throw Error(`Invalid JSON-pointer: ${$}`);X=$,Q=c0.default.rootData}else{let V=N40.exec($);if(!V)throw Error(`Invalid JSON-pointer: ${$}`);let U=+V[1];if(X=V[2],X==="#"){if(U>=Z)throw Error(K("property/index",U));return Y[Z-U]}if(U>Z)throw Error(K("data",U));if(Q=J[Z-U],!X)return Q}let G=Q,W=X.split("/");for(let V of W)if(V)Q=L0._`${Q}${(0,L0.getProperty)((0,JZ.unescapeJsonPointer)(V))}`,G=L0._`${G} && ${Q}`;return G;function K(V,U){return`Cannot access ${V} ${U} levels up, current level is ${Z}`}}S_.getData=__});var ZQ=S((v_)=>{Object.defineProperty(v_,"__esModule",{value:!0});class k_ extends Error{constructor($){super("validation failed");this.errors=$,this.ajv=this.validation=!0}}v_.default=k_});var YZ=S((x_)=>{Object.defineProperty(x_,"__esModule",{value:!0});var pz=tX();class y_ extends Error{constructor($,Z,J,Y){super(Y||`can't resolve reference ${J} from id ${Z}`);this.missingRef=(0,pz.resolveUrl)($,Z,J),this.missingSchema=(0,pz.normalizeId)((0,pz.getFullPath)($,this.missingRef))}}x_.default=y_});var Y7=S((u_)=>{Object.defineProperty(u_,"__esModule",{value:!0});u_.resolveSchema=u_.getCompilingSchema=u_.resolveRef=u_.compileSchema=u_.SchemaEnv=void 0;var Y6=k0(),T40=ZQ(),J7=g8(),X6=tX(),h_=J1(),R40=lJ();class JQ{constructor($){var Z;this.refs={},this.dynamicAnchors={};let J;if(typeof $.schema=="object")J=$.schema;this.schema=$.schema,this.schemaId=$.schemaId,this.root=$.root||this,this.baseId=(Z=$.baseId)!==null&&Z!==void 0?Z:(0,X6.normalizeId)(J===null||J===void 0?void 0:J[$.schemaId||"$id"]),this.schemaPath=$.schemaPath,this.localRefs=$.localRefs,this.meta=$.meta,this.$async=J===null||J===void 0?void 0:J.$async,this.refs={}}}u_.SchemaEnv=JQ;function iz($){let Z=g_.call(this,$);if(Z)return Z;let J=(0,X6.getFullPath)(this.opts.uriResolver,$.root.baseId),{es5:Y,lines:X}=this.opts.code,{ownProperties:Q}=this.opts,G=new Y6.CodeGen(this.scope,{es5:Y,lines:X,ownProperties:Q}),W;if($.$async)W=G.scopeValue("Error",{ref:T40.default,code:Y6._`require("ajv/dist/runtime/validation_error").default`});let K=G.scopeName("validate");$.validateName=K;let V={gen:G,allErrors:this.opts.allErrors,data:J7.default.data,parentData:J7.default.parentData,parentDataProperty:J7.default.parentDataProperty,dataNames:[J7.default.data],dataPathArr:[Y6.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:G.scopeValue("schema",this.opts.code.source===!0?{ref:$.schema,code:(0,Y6.stringify)($.schema)}:{ref:$.schema}),validateName:K,ValidationError:W,schema:$.schema,schemaEnv:$,rootId:J,baseId:$.baseId||J,schemaPath:Y6.nil,errSchemaPath:$.schemaPath||(this.opts.jtd?"":"#"),errorPath:Y6._`""`,opts:this.opts,self:this},U;try{this._compilations.add($),(0,R40.validateFunctionCode)(V),G.optimize(this.opts.code.optimize);let H=G.toString();if(U=`${G.scopeRefs(J7.default.scope)}return ${H}`,this.opts.code.process)U=this.opts.code.process(U,$);let z=Function(`${J7.default.self}`,`${J7.default.scope}`,U)(this,this.scope.get());if(this.scope.value(K,{ref:z}),z.errors=null,z.schema=$.schema,z.schemaEnv=$,$.$async)z.$async=!0;if(this.opts.code.source===!0)z.source={validateName:K,validateCode:H,scopeValues:G._values};if(this.opts.unevaluated){let{props:F,items:A}=V;if(z.evaluated={props:F instanceof Y6.Name?void 0:F,items:A instanceof Y6.Name?void 0:A,dynamicProps:F instanceof Y6.Name,dynamicItems:A instanceof Y6.Name},z.source)z.source.evaluated=(0,Y6.stringify)(z.evaluated)}return $.validate=z,$}catch(H){if(delete $.validate,delete $.validateName,U)this.logger.error("Error compiling schema, function code:",U);throw H}finally{this._compilations.delete($)}}u_.compileSchema=iz;function P40($,Z,J){var Y;J=(0,X6.resolveUrl)(this.opts.uriResolver,Z,J);let X=$.refs[J];if(X)return X;let Q=E40.call(this,$,J);if(Q===void 0){let G=(Y=$.localRefs)===null||Y===void 0?void 0:Y[J],{schemaId:W}=this.opts;if(G)Q=new JQ({schema:G,schemaId:W,root:$,baseId:Z})}if(Q===void 0)return;return $.refs[J]=I40.call(this,Q)}u_.resolveRef=P40;function I40($){if((0,X6.inlineRef)($.schema,this.opts.inlineRefs))return $.schema;return $.validate?$:iz.call(this,$)}function g_($){for(let Z of this._compilations)if(C40(Z,$))return Z}u_.getCompilingSchema=g_;function C40($,Z){return $.schema===Z.schema&&$.root===Z.root&&$.baseId===Z.baseId}function E40($,Z){let J;while(typeof(J=this.refs[Z])=="string")Z=J;return J||this.schemas[Z]||cG.call(this,$,Z)}function cG($,Z){let J=this.opts.uriResolver.parse(Z),Y=(0,X6._getFullPath)(this.opts.uriResolver,J),X=(0,X6.getFullPath)(this.opts.uriResolver,$.baseId,void 0);if(Object.keys($.schema).length>0&&Y===X)return cz.call(this,J,$);let Q=(0,X6.normalizeId)(Y),G=this.refs[Q]||this.schemas[Q];if(typeof G=="string"){let W=cG.call(this,$,G);if(typeof(W===null||W===void 0?void 0:W.schema)!=="object")return;return cz.call(this,J,W)}if(typeof(G===null||G===void 0?void 0:G.schema)!=="object")return;if(!G.validate)iz.call(this,G);if(Q===(0,X6.normalizeId)(Z)){let{schema:W}=G,{schemaId:K}=this.opts,V=W[K];if(V)X=(0,X6.resolveUrl)(this.opts.uriResolver,X,V);return new JQ({schema:W,schemaId:K,root:$,baseId:X})}return cz.call(this,J,G)}u_.resolveSchema=cG;var b40=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function cz($,{baseId:Z,schema:J,root:Y}){var X;if(((X=$.fragment)===null||X===void 0?void 0:X[0])!=="/")return;for(let W of $.fragment.slice(1).split("/")){if(typeof J==="boolean")return;let K=J[(0,h_.unescapeFragment)(W)];if(K===void 0)return;J=K;let V=typeof J==="object"&&J[this.opts.schemaId];if(!b40.has(W)&&V)Z=(0,X6.resolveUrl)(this.opts.uriResolver,Z,V)}let Q;if(typeof J!="boolean"&&J.$ref&&!(0,h_.schemaHasRulesButRef)(J,this.RULES)){let W=(0,X6.resolveUrl)(this.opts.uriResolver,Z,J.$ref);Q=cG.call(this,Y,W)}let{schemaId:G}=this.opts;if(Q=Q||new JQ({schema:J,schemaId:G,root:Y,baseId:Z}),Q.schema!==Q.root.schema)return Q;return}});var l_=S((Hv0,v40)=>{v40.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var sz=S((Bv0,o_)=>{var y40=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),p_=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),nz=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),c_=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),x40=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function oz($){let Z="",J=0,Y=0;for(Y=0;Y<$.length;Y++){if(J=$[Y].charCodeAt(0),J===48)continue;if(!(J>=48&&J<=57||J>=65&&J<=70||J>=97&&J<=102))return"";Z+=$[Y];break}for(Y+=1;Y<$.length;Y++){if(J=$[Y].charCodeAt(0),!(J>=48&&J<=57||J>=65&&J<=70||J>=97&&J<=102))return"";Z+=$[Y]}return Z}var h40=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function d_($){return $.length=0,!0}function g40($,Z,J){if($.length){let Y=oz($);if(Y!=="")Z.push(Y);else return J.error=!0,!1;$.length=0}return!0}function u40($){let Z=0,J={error:!1,address:"",zone:""},Y=[],X=[],Q=!1,G=!1,W=g40;for(let K=0;K<$.length;K++){let V=$[K];if(V==="["||V==="]")continue;if(V===":"){if(Q===!0)G=!0;if(!W(X,Y,J))break;if(++Z>7){J.error=!0;break}if(K>0&&$[K-1]===":")Q=!0;Y.push(":");continue}else if(V==="%"){if(!W(X,Y,J))break;W=d_}else{X.push(V);continue}}if(X.length)if(W===d_)J.zone=X.join("");else if(G)Y.push(X.join(""));else Y.push(oz(X));return J.address=Y.join(""),J}function i_($){if(m40($,":")<2)return{host:$,isIPV6:!1};let Z=u40($);if(!Z.error){let{address:J,address:Y}=Z;if(Z.zone)J+="%"+Z.zone,Y+="%25"+Z.zone;return{host:J,isIPV6:!0,escapedHost:Y}}else return{host:$,isIPV6:!1}}function m40($,Z){let J=0;for(let Y=0;Y<$.length;Y++)if($[Y]===Z)J++;return J}function l40($){let Z=$,J=[],Y=-1,X=0;while(X=Z.length){if(X===1)if(Z===".")break;else if(Z==="/"){J.push("/");break}else{J.push(Z);break}else if(X===2){if(Z[0]==="."){if(Z[1]===".")break;else if(Z[1]==="/"){Z=Z.slice(2);continue}}else if(Z[0]==="/"){if(Z[1]==="."||Z[1]==="/"){J.push("/");break}}}else if(X===3){if(Z==="/.."){if(J.length!==0)J.pop();J.push("/");break}}if(Z[0]==="."){if(Z[1]==="."){if(Z[2]==="/"){Z=Z.slice(3);continue}}else if(Z[1]==="/"){Z=Z.slice(2);continue}}else if(Z[0]==="/"){if(Z[1]==="."){if(Z[2]==="/"){Z=Z.slice(2);continue}else if(Z[2]==="."){if(Z[3]==="/"){if(Z=Z.slice(3),J.length!==0)J.pop();continue}}}}if((Y=Z.indexOf("/",1))===-1){J.push(Z);break}else J.push(Z.slice(0,Y)),Z=Z.slice(Y)}return J.join("")}var d40={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},p40=/[@/?#:]/g,c40=/[@/?#]/g;function n_($,Z){let J=Z?c40:p40;return J.lastIndex=0,$.replace(J,(Y)=>d40[Y])}function i40($,Z=!1){if($.indexOf("%")===-1)return $;let J="";for(let Y=0;Y<$.length;Y++){if($[Y]==="%"&&Y+2<$.length){let X=$.slice(Y+1,Y+3);if(nz(X)){let Q=X.toUpperCase(),G=String.fromCharCode(parseInt(Q,16));if(Z&&c_(G))J+=G;else J+="%"+Q;Y+=2;continue}}J+=$[Y]}return J}function n40($){let Z="";for(let J=0;J<$.length;J++){if($[J]==="%"&&J+2<$.length){let Y=$.slice(J+1,J+3);if(nz(Y)){let X=Y.toUpperCase(),Q=String.fromCharCode(parseInt(X,16));if(Q!=="."&&c_(Q))Z+=Q;else Z+="%"+X;J+=2;continue}}if(x40($[J]))Z+=$[J];else Z+=escape($[J])}return Z}function o40($){let Z="";for(let J=0;J<$.length;J++){if($[J]==="%"&&J+2<$.length){let Y=$.slice(J+1,J+3);if(nz(Y)){Z+="%"+Y.toUpperCase(),J+=2;continue}}Z+=escape($[J])}return Z}function s40($){let Z=[];if($.userinfo!==void 0)Z.push($.userinfo),Z.push("@");if($.host!==void 0){let J=unescape($.host);if(!p_(J)){let Y=i_(J);if(Y.isIPV6===!0)J=`[${Y.escapedHost}]`;else J=n_(J,!1)}Z.push(J)}if(typeof $.port==="number"||typeof $.port==="string")Z.push(":"),Z.push(String($.port));return Z.length?Z.join(""):void 0}o_.exports={nonSimpleDomain:h40,recomposeAuthority:s40,reescapeHostDelimiters:n_,normalizePercentEncoding:i40,normalizePathEncoding:n40,escapePreservingEscapes:o40,removeDotSegments:l40,isIPv4:p_,isUUID:y40,normalizeIPv6:i_,stringArrayToHexStripped:oz}});var e_=S((zv0,t_)=>{var{isUUID:r40}=sz(),a40=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,t40=["http","https","ws","wss","urn","urn:uuid"];function e40($){return t40.indexOf($)!==-1}function rz($){if($.secure===!0)return!0;else if($.secure===!1)return!1;else if($.scheme)return $.scheme.length===3&&($.scheme[0]==="w"||$.scheme[0]==="W")&&($.scheme[1]==="s"||$.scheme[1]==="S")&&($.scheme[2]==="s"||$.scheme[2]==="S");else return!1}function s_($){if(!$.host)$.error=$.error||"HTTP URIs must have a host.";return $}function r_($){let Z=String($.scheme).toLowerCase()==="https";if($.port===(Z?443:80)||$.port==="")$.port=void 0;if(!$.path)$.path="/";return $}function $G0($){return $.secure=rz($),$.resourceName=($.path||"/")+($.query?"?"+$.query:""),$.path=void 0,$.query=void 0,$}function ZG0($){if($.port===(rz($)?443:80)||$.port==="")$.port=void 0;if(typeof $.secure==="boolean")$.scheme=$.secure?"wss":"ws",$.secure=void 0;if($.resourceName){let[Z,J]=$.resourceName.split("?");$.path=Z&&Z!=="/"?Z:void 0,$.query=J,$.resourceName=void 0}return $.fragment=void 0,$}function JG0($,Z){if(!$.path)return $.error="URN can not be parsed",$;let J=$.path.match(a40);if(J){let Y=Z.scheme||$.scheme||"urn";$.nid=J[1].toLowerCase(),$.nss=J[2];let X=`${Y}:${Z.nid||$.nid}`,Q=az(X);if($.path=void 0,Q)$=Q.parse($,Z)}else $.error=$.error||"URN can not be parsed.";return $}function YG0($,Z){if($.nid===void 0)throw Error("URN without nid cannot be serialized");let J=Z.scheme||$.scheme||"urn",Y=$.nid.toLowerCase(),X=`${J}:${Z.nid||Y}`,Q=az(X);if(Q)$=Q.serialize($,Z);let G=$,W=$.nss;return G.path=`${Y||Z.nid}:${W}`,Z.skipEscape=!0,G}function XG0($,Z){let J=$;if(J.uuid=J.nss,J.nss=void 0,!Z.tolerant&&(!J.uuid||!r40(J.uuid)))J.error=J.error||"UUID is not valid.";return J}function QG0($){let Z=$;return Z.nss=($.uuid||"").toLowerCase(),Z}var a_={scheme:"http",domainHost:!0,parse:s_,serialize:r_},GG0={scheme:"https",domainHost:a_.domainHost,parse:s_,serialize:r_},iG={scheme:"ws",domainHost:!0,parse:$G0,serialize:ZG0},WG0={scheme:"wss",domainHost:iG.domainHost,parse:iG.parse,serialize:iG.serialize},KG0={scheme:"urn",parse:JG0,serialize:YG0,skipNormalize:!0},VG0={scheme:"urn:uuid",parse:XG0,serialize:QG0,skipNormalize:!0},nG={http:a_,https:GG0,ws:iG,wss:WG0,urn:KG0,"urn:uuid":VG0};Object.setPrototypeOf(nG,null);function az($){return $&&(nG[$]||nG[$.toLowerCase()])||void 0}t_.exports={wsIsSecure:rz,SCHEMES:nG,isValidSchemeName:e40,getSchemeHandler:az}});var sG=S((Fv0,oG)=>{var{normalizeIPv6:UG0,removeDotSegments:YQ,recomposeAuthority:HG0,normalizePercentEncoding:BG0,normalizePathEncoding:zG0,escapePreservingEscapes:FG0,reescapeHostDelimiters:AG0,isIPv4:OG0,nonSimpleDomain:qG0}=sz(),{SCHEMES:jG0,getSchemeHandler:ZS}=e_();function NG0($,Z){if(typeof $==="string")$=TG0($,Z);else if(typeof $==="object")$=dJ(X7($,Z),Z);return $}function MG0($,Z,J){let Y=J?Object.assign({scheme:"null"},J):{scheme:"null"},X=JS(dJ($,Y),dJ(Z,Y),Y,!0);return Y.skipEscape=!0,X7(X,Y)}function JS($,Z,J,Y){let X={};if(!Y)$=dJ(X7($,J),J),Z=dJ(X7(Z,J),J);if(J=J||{},!J.tolerant&&Z.scheme)X.scheme=Z.scheme,X.userinfo=Z.userinfo,X.host=Z.host,X.port=Z.port,X.path=YQ(Z.path||""),X.query=Z.query;else{if(Z.userinfo!==void 0||Z.host!==void 0||Z.port!==void 0)X.userinfo=Z.userinfo,X.host=Z.host,X.port=Z.port,X.path=YQ(Z.path||""),X.query=Z.query;else{if(!Z.path)if(X.path=$.path,Z.query!==void 0)X.query=Z.query;else X.query=$.query;else{if(Z.path[0]==="/")X.path=YQ(Z.path);else{if(($.userinfo!==void 0||$.host!==void 0||$.port!==void 0)&&!$.path)X.path="/"+Z.path;else if(!$.path)X.path=Z.path;else X.path=$.path.slice(0,$.path.lastIndexOf("/")+1)+Z.path;X.path=YQ(X.path)}X.query=Z.query}X.userinfo=$.userinfo,X.host=$.host,X.port=$.port}X.scheme=$.scheme}return X.fragment=Z.fragment,X}function DG0($,Z,J){let Y=$S($,J),X=$S(Z,J);return Y!==void 0&&X!==void 0&&Y.toLowerCase()===X.toLowerCase()}function X7($,Z){let J={host:$.host,scheme:$.scheme,userinfo:$.userinfo,port:$.port,path:$.path,query:$.query,nid:$.nid,nss:$.nss,uuid:$.uuid,fragment:$.fragment,reference:$.reference,resourceName:$.resourceName,secure:$.secure,error:""},Y=Object.assign({},Z),X=[],Q=ZS(Y.scheme||J.scheme);if(Q&&Q.serialize)Q.serialize(J,Y);if(J.path!==void 0)if(!Y.skipEscape){if(J.path=FG0(J.path),J.scheme!==void 0)J.path=J.path.split("%3A").join(":")}else J.path=BG0(J.path);if(Y.reference!=="suffix"&&J.scheme)X.push(J.scheme,":");let G=HG0(J);if(G!==void 0){if(Y.reference!=="suffix")X.push("//");if(X.push(G),J.path&&J.path[0]!=="/")X.push("/")}if(J.path!==void 0){let W=J.path;if(!Y.absolutePath&&(!Q||!Q.absolutePath))W=YQ(W);if(G===void 0&&W[0]==="/"&&W[1]==="/")W="/%2F"+W.slice(2);X.push(W)}if(J.query!==void 0)X.push("?",J.query);if(J.fragment!==void 0)X.push("#",J.fragment);return X.join("")}var wG0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function LG0($,Z){if(Z[2]!==void 0&&$.path&&$.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof $.port==="number"&&($.port<0||$.port>65535))return"URI port is malformed.";return}function YS($,Z){let J=Object.assign({},Z),Y={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},X=!1,Q=!1;if(J.reference==="suffix")if(J.scheme)$=J.scheme+":"+$;else $="//"+$;let G=$.match(wG0);if(G){if(Y.scheme=G[1],Y.userinfo=G[3],Y.host=G[4],Y.port=parseInt(G[5],10),Y.path=G[6]||"",Y.query=G[7],Y.fragment=G[8],isNaN(Y.port))Y.port=G[5];let W=LG0(Y,G);if(W!==void 0)Y.error=Y.error||W,X=!0;if(Y.host)if(OG0(Y.host)===!1){let U=UG0(Y.host);Y.host=U.host.toLowerCase(),Q=U.isIPV6}else Q=!0;if(Y.scheme===void 0&&Y.userinfo===void 0&&Y.host===void 0&&Y.port===void 0&&Y.query===void 0&&!Y.path)Y.reference="same-document";else if(Y.scheme===void 0)Y.reference="relative";else if(Y.fragment===void 0)Y.reference="absolute";else Y.reference="uri";if(J.reference&&J.reference!=="suffix"&&J.reference!==Y.reference)Y.error=Y.error||"URI is not a "+J.reference+" reference.";let K=ZS(J.scheme||Y.scheme);if(!J.unicodeSupport&&(!K||!K.unicodeSupport)){if(Y.host&&(J.domainHost||K&&K.domainHost)&&Q===!1&&qG0(Y.host))try{Y.host=URL.domainToASCII(Y.host.toLowerCase())}catch(V){Y.error=Y.error||"Host's domain name can not be converted to ASCII: "+V}}if(!K||K&&!K.skipNormalize){if($.indexOf("%")!==-1){if(Y.scheme!==void 0)Y.scheme=unescape(Y.scheme);if(Y.host!==void 0)Y.host=AG0(unescape(Y.host),Q)}if(Y.path)Y.path=zG0(Y.path);if(Y.fragment)try{Y.fragment=encodeURI(decodeURIComponent(Y.fragment))}catch{Y.error=Y.error||"URI malformed"}}if(K&&K.parse)K.parse(Y,J)}else Y.error=Y.error||"URI can not be parsed.";return{parsed:Y,malformedAuthorityOrPort:X}}function dJ($,Z){return YS($,Z).parsed}function TG0($,Z){return XS($,Z).normalized}function XS($,Z){let{parsed:J,malformedAuthorityOrPort:Y}=YS($,Z);return{normalized:Y?$:X7(J,Z),malformedAuthorityOrPort:Y}}function $S($,Z){if(typeof $==="string"){let{normalized:J,malformedAuthorityOrPort:Y}=XS($,Z);return Y?void 0:J}if(typeof $==="object")return X7($,Z)}var tz={SCHEMES:jG0,normalize:NG0,resolve:MG0,resolveComponent:JS,equal:DG0,serialize:X7,parse:dJ};oG.exports=tz;oG.exports.default=tz;oG.exports.fastUri=tz});var WS=S((GS)=>{Object.defineProperty(GS,"__esModule",{value:!0});var QS=sG();QS.code='require("ajv/dist/runtime/uri").default';GS.default=QS});var Z3=S((XZ)=>{Object.defineProperty(XZ,"__esModule",{value:!0});XZ.CodeGen=XZ.Name=XZ.nil=XZ.stringify=XZ.str=XZ._=XZ.KeywordCxt=void 0;var PG0=lJ();Object.defineProperty(XZ,"KeywordCxt",{enumerable:!0,get:function(){return PG0.KeywordCxt}});var pJ=k0();Object.defineProperty(XZ,"_",{enumerable:!0,get:function(){return pJ._}});Object.defineProperty(XZ,"str",{enumerable:!0,get:function(){return pJ.str}});Object.defineProperty(XZ,"stringify",{enumerable:!0,get:function(){return pJ.stringify}});Object.defineProperty(XZ,"nil",{enumerable:!0,get:function(){return pJ.nil}});Object.defineProperty(XZ,"Name",{enumerable:!0,get:function(){return pJ.Name}});Object.defineProperty(XZ,"CodeGen",{enumerable:!0,get:function(){return pJ.CodeGen}});var IG0=ZQ(),BS=YZ(),CG0=_z(),XQ=Y7(),EG0=k0(),QQ=tX(),rG=rX(),$3=J1(),KS=l_(),bG0=WS(),zS=($,Z)=>new RegExp($,Z);zS.code="new RegExp";var _G0=["removeAdditional","useDefaults","coerceTypes"],SG0=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),fG0={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},kG0={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},VS=200;function vG0($){var Z,J,Y,X,Q,G,W,K,V,U,H,B,z,F,A,j,N,L,q,M,C,R,w,I,_;let E=$.strict,f=(Z=$.code)===null||Z===void 0?void 0:Z.optimize,b=f===!0||f===void 0?1:f||0,y=(Y=(J=$.code)===null||J===void 0?void 0:J.regExp)!==null&&Y!==void 0?Y:zS,k=(X=$.uriResolver)!==null&&X!==void 0?X:bG0.default;return{strictSchema:(G=(Q=$.strictSchema)!==null&&Q!==void 0?Q:E)!==null&&G!==void 0?G:!0,strictNumbers:(K=(W=$.strictNumbers)!==null&&W!==void 0?W:E)!==null&&K!==void 0?K:!0,strictTypes:(U=(V=$.strictTypes)!==null&&V!==void 0?V:E)!==null&&U!==void 0?U:"log",strictTuples:(B=(H=$.strictTuples)!==null&&H!==void 0?H:E)!==null&&B!==void 0?B:"log",strictRequired:(F=(z=$.strictRequired)!==null&&z!==void 0?z:E)!==null&&F!==void 0?F:!1,code:$.code?{...$.code,optimize:b,regExp:y}:{optimize:b,regExp:y},loopRequired:(A=$.loopRequired)!==null&&A!==void 0?A:VS,loopEnum:(j=$.loopEnum)!==null&&j!==void 0?j:VS,meta:(N=$.meta)!==null&&N!==void 0?N:!0,messages:(L=$.messages)!==null&&L!==void 0?L:!0,inlineRefs:(q=$.inlineRefs)!==null&&q!==void 0?q:!0,schemaId:(M=$.schemaId)!==null&&M!==void 0?M:"$id",addUsedSchema:(C=$.addUsedSchema)!==null&&C!==void 0?C:!0,validateSchema:(R=$.validateSchema)!==null&&R!==void 0?R:!0,validateFormats:(w=$.validateFormats)!==null&&w!==void 0?w:!0,unicodeRegExp:(I=$.unicodeRegExp)!==null&&I!==void 0?I:!0,int32range:(_=$.int32range)!==null&&_!==void 0?_:!0,uriResolver:k}}class aG{constructor($={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,$=this.opts={...$,...vG0($)};let{es5:Z,lines:J}=this.opts.code;this.scope=new EG0.ValueScope({scope:{},prefixes:SG0,es5:Z,lines:J}),this.logger=mG0($.logger);let Y=$.validateFormats;if($.validateFormats=!1,this.RULES=(0,CG0.getRules)(),US.call(this,fG0,$,"NOT SUPPORTED"),US.call(this,kG0,$,"DEPRECATED","warn"),this._metaOpts=gG0.call(this),$.formats)xG0.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),$.keywords)hG0.call(this,$.keywords);if(typeof $.meta=="object")this.addMetaSchema($.meta);yG0.call(this),$.validateFormats=Y}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:$,meta:Z,schemaId:J}=this.opts,Y=KS;if(J==="id")Y={...KS},Y.id=Y.$id,delete Y.$id;if(Z&&$)this.addMetaSchema(Y,Y[J],!1)}defaultMeta(){let{meta:$,schemaId:Z}=this.opts;return this.opts.defaultMeta=typeof $=="object"?$[Z]||$:void 0}validate($,Z){let J;if(typeof $=="string"){if(J=this.getSchema($),!J)throw Error(`no schema with key or ref "${$}"`)}else J=this.compile($);let Y=J(Z);if(!("$async"in J))this.errors=J.errors;return Y}compile($,Z){let J=this._addSchema($,Z);return J.validate||this._compileSchemaEnv(J)}compileAsync($,Z){if(typeof this.opts.loadSchema!="function")throw Error("options.loadSchema should be a function");let{loadSchema:J}=this.opts;return Y.call(this,$,Z);async function Y(V,U){await X.call(this,V.$schema);let H=this._addSchema(V,U);return H.validate||Q.call(this,H)}async function X(V){if(V&&!this.getSchema(V))await Y.call(this,{$ref:V},!0)}async function Q(V){try{return this._compileSchemaEnv(V)}catch(U){if(!(U instanceof BS.default))throw U;return G.call(this,U),await W.call(this,U.missingSchema),Q.call(this,V)}}function G({missingSchema:V,missingRef:U}){if(this.refs[V])throw Error(`AnySchema ${V} is loaded but ${U} cannot be resolved`)}async function W(V){let U=await K.call(this,V);if(!this.refs[V])await X.call(this,U.$schema);if(!this.refs[V])this.addSchema(U,V,Z)}async function K(V){let U=this._loading[V];if(U)return U;try{return await(this._loading[V]=J(V))}finally{delete this._loading[V]}}}addSchema($,Z,J,Y=this.opts.validateSchema){if(Array.isArray($)){for(let Q of $)this.addSchema(Q,void 0,J,Y);return this}let X;if(typeof $==="object"){let{schemaId:Q}=this.opts;if(X=$[Q],X!==void 0&&typeof X!="string")throw Error(`schema ${Q} must be string`)}return Z=(0,QQ.normalizeId)(Z||X),this._checkUnique(Z),this.schemas[Z]=this._addSchema($,J,Z,Y,!0),this}addMetaSchema($,Z,J=this.opts.validateSchema){return this.addSchema($,Z,!0,J),this}validateSchema($,Z){if(typeof $=="boolean")return!0;let J;if(J=$.$schema,J!==void 0&&typeof J!="string")throw Error("$schema must be a string");if(J=J||this.opts.defaultMeta||this.defaultMeta(),!J)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let Y=this.validate(J,$);if(!Y&&Z){let X="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(X);else throw Error(X)}return Y}getSchema($){let Z;while(typeof(Z=HS.call(this,$))=="string")$=Z;if(Z===void 0){let{schemaId:J}=this.opts,Y=new XQ.SchemaEnv({schema:{},schemaId:J});if(Z=XQ.resolveSchema.call(this,Y,$),!Z)return;this.refs[$]=Z}return Z.validate||this._compileSchemaEnv(Z)}removeSchema($){if($ instanceof RegExp)return this._removeAllSchemas(this.schemas,$),this._removeAllSchemas(this.refs,$),this;switch(typeof $){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let Z=HS.call(this,$);if(typeof Z=="object")this._cache.delete(Z.schema);return delete this.schemas[$],delete this.refs[$],this}case"object":{let Z=$;this._cache.delete(Z);let J=$[this.opts.schemaId];if(J)J=(0,QQ.normalizeId)(J),delete this.schemas[J],delete this.refs[J];return this}default:throw Error("ajv.removeSchema: invalid parameter")}}addVocabulary($){for(let Z of $)this.addKeyword(Z);return this}addKeyword($,Z){let J;if(typeof $=="string"){if(J=$,typeof Z=="object")this.logger.warn("these parameters are deprecated, see docs for addKeyword"),Z.keyword=J}else if(typeof $=="object"&&Z===void 0){if(Z=$,J=Z.keyword,Array.isArray(J)&&!J.length)throw Error("addKeywords: keyword must be string or non-empty array")}else throw Error("invalid addKeywords parameters");if(dG0.call(this,J,Z),!Z)return(0,$3.eachItem)(J,(X)=>ez.call(this,X)),this;cG0.call(this,Z);let Y={...Z,type:(0,rG.getJSONTypes)(Z.type),schemaType:(0,rG.getJSONTypes)(Z.schemaType)};return(0,$3.eachItem)(J,Y.type.length===0?(X)=>ez.call(this,X,Y):(X)=>Y.type.forEach((Q)=>ez.call(this,X,Y,Q))),this}getKeyword($){let Z=this.RULES.all[$];return typeof Z=="object"?Z.definition:!!Z}removeKeyword($){let{RULES:Z}=this;delete Z.keywords[$],delete Z.all[$];for(let J of Z.rules){let Y=J.rules.findIndex((X)=>X.keyword===$);if(Y>=0)J.rules.splice(Y,1)}return this}addFormat($,Z){if(typeof Z=="string")Z=new RegExp(Z);return this.formats[$]=Z,this}errorsText($=this.errors,{separator:Z=", ",dataVar:J="data"}={}){if(!$||$.length===0)return"No errors";return $.map((Y)=>`${J}${Y.instancePath} ${Y.message}`).reduce((Y,X)=>Y+Z+X)}$dataMetaSchema($,Z){let J=this.RULES.all;$=JSON.parse(JSON.stringify($));for(let Y of Z){let X=Y.split("/").slice(1),Q=$;for(let G of X)Q=Q[G];for(let G in J){let W=J[G];if(typeof W!="object")continue;let{$data:K}=W.definition,V=Q[G];if(K&&V)Q[G]=FS(V)}}return $}_removeAllSchemas($,Z){for(let J in $){let Y=$[J];if(!Z||Z.test(J)){if(typeof Y=="string")delete $[J];else if(Y&&!Y.meta)this._cache.delete(Y.schema),delete $[J]}}}_addSchema($,Z,J,Y=this.opts.validateSchema,X=this.opts.addUsedSchema){let Q,{schemaId:G}=this.opts;if(typeof $=="object")Q=$[G];else if(this.opts.jtd)throw Error("schema must be object");else if(typeof $!="boolean")throw Error("schema must be object or boolean");let W=this._cache.get($);if(W!==void 0)return W;J=(0,QQ.normalizeId)(Q||J);let K=QQ.getSchemaRefs.call(this,$,J);if(W=new XQ.SchemaEnv({schema:$,schemaId:G,meta:Z,baseId:J,localRefs:K}),this._cache.set(W.schema,W),X&&!J.startsWith("#")){if(J)this._checkUnique(J);this.refs[J]=W}if(Y)this.validateSchema($,!0);return W}_checkUnique($){if(this.schemas[$]||this.refs[$])throw Error(`schema with key or id "${$}" already exists`)}_compileSchemaEnv($){if($.meta)this._compileMetaSchema($);else XQ.compileSchema.call(this,$);if(!$.validate)throw Error("ajv implementation error");return $.validate}_compileMetaSchema($){let Z=this.opts;this.opts=this._metaOpts;try{XQ.compileSchema.call(this,$)}finally{this.opts=Z}}}aG.ValidationError=IG0.default;aG.MissingRefError=BS.default;XZ.default=aG;function US($,Z,J,Y="error"){for(let X in $){let Q=X;if(Q in Z)this.logger[Y](`${J}: option ${X}. ${$[Q]}`)}}function HS($){return $=(0,QQ.normalizeId)($),this.schemas[$]||this.refs[$]}function yG0(){let $=this.opts.schemas;if(!$)return;if(Array.isArray($))this.addSchema($);else for(let Z in $)this.addSchema($[Z],Z)}function xG0(){for(let $ in this.opts.formats){let Z=this.opts.formats[$];if(Z)this.addFormat($,Z)}}function hG0($){if(Array.isArray($)){this.addVocabulary($);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let Z in $){let J=$[Z];if(!J.keyword)J.keyword=Z;this.addKeyword(J)}}function gG0(){let $={...this.opts};for(let Z of _G0)delete $[Z];return $}var uG0={log(){},warn(){},error(){}};function mG0($){if($===!1)return uG0;if($===void 0)return console;if($.log&&$.warn&&$.error)return $;throw Error("logger must implement log, warn and error methods")}var lG0=/^[a-z_$][a-z0-9_$:-]*$/i;function dG0($,Z){let{RULES:J}=this;if((0,$3.eachItem)($,(Y)=>{if(J.keywords[Y])throw Error(`Keyword ${Y} is already defined`);if(!lG0.test(Y))throw Error(`Keyword ${Y} has invalid name`)}),!Z)return;if(Z.$data&&!(("code"in Z)||("validate"in Z)))throw Error('$data keyword must have "code" or "validate" function')}function ez($,Z,J){var Y;let X=Z===null||Z===void 0?void 0:Z.post;if(J&&X)throw Error('keyword with "post" flag cannot have "type"');let{RULES:Q}=this,G=X?Q.post:Q.rules.find(({type:K})=>K===J);if(!G)G={type:J,rules:[]},Q.rules.push(G);if(Q.keywords[$]=!0,!Z)return;let W={keyword:$,definition:{...Z,type:(0,rG.getJSONTypes)(Z.type),schemaType:(0,rG.getJSONTypes)(Z.schemaType)}};if(Z.before)pG0.call(this,G,W,Z.before);else G.rules.push(W);Q.all[$]=W,(Y=Z.implements)===null||Y===void 0||Y.forEach((K)=>this.addKeyword(K))}function pG0($,Z,J){let Y=$.rules.findIndex((X)=>X.keyword===J);if(Y>=0)$.rules.splice(Y,0,Z);else $.rules.push(Z),this.logger.warn(`rule ${J} is not defined`)}function cG0($){let{metaSchema:Z}=$;if(Z===void 0)return;if($.$data&&this.opts.$data)Z=FS(Z);$.validateSchema=this.compile(Z,!0)}var iG0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function FS($){return{anyOf:[$,iG0]}}});var OS=S((AS)=>{Object.defineProperty(AS,"__esModule",{value:!0});var sG0={keyword:"id",code(){throw Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};AS.default=sG0});var J3=S((MS)=>{Object.defineProperty(MS,"__esModule",{value:!0});MS.callRef=MS.getValidate=void 0;var aG0=YZ(),qS=S$(),U8=k0(),cJ=g8(),jS=Y7(),tG=J1(),tG0={keyword:"$ref",schemaType:"string",code($){let{gen:Z,schema:J,it:Y}=$,{baseId:X,schemaEnv:Q,validateName:G,opts:W,self:K}=Y,{root:V}=Q;if((J==="#"||J==="#/")&&X===V.baseId)return H();let U=jS.resolveRef.call(K,V,X,J);if(U===void 0)throw new aG0.default(Y.opts.uriResolver,X,J);if(U instanceof jS.SchemaEnv)return B(U);return z(U);function H(){if(Q===V)return eG($,G,Q,Q.$async);let F=Z.scopeValue("root",{ref:V});return eG($,U8._`${F}.validate`,V,V.$async)}function B(F){let A=NS($,F);eG($,A,F,F.$async)}function z(F){let A=Z.scopeValue("schema",W.code.source===!0?{ref:F,code:(0,U8.stringify)(F)}:{ref:F}),j=Z.name("valid"),N=$.subschema({schema:F,dataTypes:[],schemaPath:U8.nil,topSchemaRef:A,errSchemaPath:J},j);$.mergeEvaluated(N),$.ok(j)}}};function NS($,Z){let{gen:J}=$;return Z.validate?J.scopeValue("validate",{ref:Z.validate}):U8._`${J.scopeValue("wrapper",{ref:Z})}.validate`}MS.getValidate=NS;function eG($,Z,J,Y){let{gen:X,it:Q}=$,{allErrors:G,schemaEnv:W,opts:K}=Q,V=K.passContext?cJ.default.this:U8.nil;if(Y)U();else H();function U(){if(!W.$async)throw Error("async schema referenced by sync schema");let F=X.let("valid");X.try(()=>{if(X.code(U8._`await ${(0,qS.callValidateCode)($,Z,V)}`),z(Z),!G)X.assign(F,!0)},(A)=>{if(X.if(U8._`!(${A} instanceof ${Q.ValidationError})`,()=>X.throw(A)),B(A),!G)X.assign(F,!1)}),$.ok(F)}function H(){$.result((0,qS.callValidateCode)($,Z,V),()=>z(Z),()=>B(Z))}function B(F){let A=U8._`${F}.errors`;X.assign(cJ.default.vErrors,U8._`${cJ.default.vErrors} === null ? ${A} : ${cJ.default.vErrors}.concat(${A})`),X.assign(cJ.default.errors,U8._`${cJ.default.vErrors}.length`)}function z(F){var A;if(!Q.opts.unevaluated)return;let j=(A=J===null||J===void 0?void 0:J.validate)===null||A===void 0?void 0:A.evaluated;if(Q.props!==!0)if(j&&!j.dynamicProps){if(j.props!==void 0)Q.props=tG.mergeEvaluated.props(X,j.props,Q.props)}else{let N=X.var("props",U8._`${F}.evaluated.props`);Q.props=tG.mergeEvaluated.props(X,N,Q.props,U8.Name)}if(Q.items!==!0)if(j&&!j.dynamicItems){if(j.items!==void 0)Q.items=tG.mergeEvaluated.items(X,j.items,Q.items)}else{let N=X.var("items",U8._`${F}.evaluated.items`);Q.items=tG.mergeEvaluated.items(X,N,Q.items,U8.Name)}}}MS.callRef=eG;MS.default=tG0});var LS=S((wS)=>{Object.defineProperty(wS,"__esModule",{value:!0});var ZW0=OS(),JW0=J3(),YW0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",ZW0.default,JW0.default];wS.default=YW0});var RS=S((TS)=>{Object.defineProperty(TS,"__esModule",{value:!0});var $W=k0(),rZ=$W.operators,ZW={maximum:{okStr:"<=",ok:rZ.LTE,fail:rZ.GT},minimum:{okStr:">=",ok:rZ.GTE,fail:rZ.LT},exclusiveMaximum:{okStr:"<",ok:rZ.LT,fail:rZ.GTE},exclusiveMinimum:{okStr:">",ok:rZ.GT,fail:rZ.LTE}},QW0={message:({keyword:$,schemaCode:Z})=>$W.str`must be ${ZW[$].okStr} ${Z}`,params:({keyword:$,schemaCode:Z})=>$W._`{comparison: ${ZW[$].okStr}, limit: ${Z}}`},GW0={keyword:Object.keys(ZW),type:"number",schemaType:"number",$data:!0,error:QW0,code($){let{keyword:Z,data:J,schemaCode:Y}=$;$.fail$data($W._`${J} ${ZW[Z].fail} ${Y} || isNaN(${J})`)}};TS.default=GW0});var IS=S((PS)=>{Object.defineProperty(PS,"__esModule",{value:!0});var GQ=k0(),KW0={message:({schemaCode:$})=>GQ.str`must be multiple of ${$}`,params:({schemaCode:$})=>GQ._`{multipleOf: ${$}}`},VW0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:KW0,code($){let{gen:Z,data:J,schemaCode:Y,it:X}=$,Q=X.opts.multipleOfPrecision,G=Z.let("res"),W=Q?GQ._`Math.abs(Math.round(${G}) - ${G}) > 1e-${Q}`:GQ._`${G} !== parseInt(${G})`;$.fail$data(GQ._`(${Y} === 0 || (${G} = ${J}/${Y}, ${W}))`)}};PS.default=VW0});var bS=S((ES)=>{Object.defineProperty(ES,"__esModule",{value:!0});function CS($){let Z=$.length,J=0,Y=0,X;while(Y<Z)if(J++,X=$.charCodeAt(Y++),X>=55296&&X<=56319&&Y<Z){if(X=$.charCodeAt(Y),(X&64512)===56320)Y++}return J}ES.default=CS;CS.code='require("ajv/dist/runtime/ucs2length").default'});var SS=S((_S)=>{Object.defineProperty(_S,"__esModule",{value:!0});var Q7=k0(),BW0=J1(),zW0=bS(),FW0={message({keyword:$,schemaCode:Z}){let J=$==="maxLength"?"more":"fewer";return Q7.str`must NOT have ${J} than ${Z} characters`},params:({schemaCode:$})=>Q7._`{limit: ${$}}`},AW0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:FW0,code($){let{keyword:Z,data:J,schemaCode:Y,it:X}=$,Q=Z==="maxLength"?Q7.operators.GT:Q7.operators.LT,G=X.opts.unicode===!1?Q7._`${J}.length`:Q7._`${(0,BW0.useFunc)($.gen,zW0.default)}(${J})`;$.fail$data(Q7._`${G} ${Q} ${Y}`)}};_S.default=AW0});var kS=S((fS)=>{Object.defineProperty(fS,"__esModule",{value:!0});var qW0=S$(),jW0=J1(),iJ=k0(),NW0={message:({schemaCode:$})=>iJ.str`must match pattern "${$}"`,params:({schemaCode:$})=>iJ._`{pattern: ${$}}`},MW0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:NW0,code($){let{gen:Z,data:J,$data:Y,schema:X,schemaCode:Q,it:G}=$,W=G.opts.unicodeRegExp?"u":"";if(Y){let{regExp:K}=G.opts.code,V=K.code==="new RegExp"?iJ._`new RegExp`:(0,jW0.useFunc)(Z,K),U=Z.let("valid");Z.try(()=>Z.assign(U,iJ._`${V}(${Q}, ${W}).test(${J})`),()=>Z.assign(U,!1)),$.fail$data(iJ._`!${U}`)}else{let K=(0,qW0.usePattern)($,X);$.fail$data(iJ._`!${K}.test(${J})`)}}};fS.default=MW0});var yS=S((vS)=>{Object.defineProperty(vS,"__esModule",{value:!0});var WQ=k0(),wW0={message({keyword:$,schemaCode:Z}){let J=$==="maxProperties"?"more":"fewer";return WQ.str`must NOT have ${J} than ${Z} properties`},params:({schemaCode:$})=>WQ._`{limit: ${$}}`},LW0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:wW0,code($){let{keyword:Z,data:J,schemaCode:Y}=$,X=Z==="maxProperties"?WQ.operators.GT:WQ.operators.LT;$.fail$data(WQ._`Object.keys(${J}).length ${X} ${Y}`)}};vS.default=LW0});var hS=S((xS)=>{Object.defineProperty(xS,"__esModule",{value:!0});var KQ=S$(),VQ=k0(),RW0=J1(),PW0={message:({params:{missingProperty:$}})=>VQ.str`must have required property '${$}'`,params:({params:{missingProperty:$}})=>VQ._`{missingProperty: ${$}}`},IW0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:PW0,code($){let{gen:Z,schema:J,schemaCode:Y,data:X,$data:Q,it:G}=$,{opts:W}=G;if(!Q&&J.length===0)return;let K=J.length>=W.loopRequired;if(G.allErrors)V();else U();if(W.strictRequired){let z=$.parentSchema.properties,{definedProperties:F}=$.it;for(let A of J)if((z===null||z===void 0?void 0:z[A])===void 0&&!F.has(A)){let j=G.schemaEnv.baseId+G.errSchemaPath,N=`required property "${A}" is not defined at "${j}" (strictRequired)`;(0,RW0.checkStrictMode)(G,N,G.opts.strictRequired)}}function V(){if(K||Q)$.block$data(VQ.nil,H);else for(let z of J)(0,KQ.checkReportMissingProp)($,z)}function U(){let z=Z.let("missing");if(K||Q){let F=Z.let("valid",!0);$.block$data(F,()=>B(z,F)),$.ok(F)}else Z.if((0,KQ.checkMissingProp)($,J,z)),(0,KQ.reportMissingProp)($,z),Z.else()}function H(){Z.forOf("prop",Y,(z)=>{$.setParams({missingProperty:z}),Z.if((0,KQ.noPropertyInData)(Z,X,z,W.ownProperties),()=>$.error())})}function B(z,F){$.setParams({missingProperty:z}),Z.forOf(z,Y,()=>{Z.assign(F,(0,KQ.propertyInData)(Z,X,z,W.ownProperties)),Z.if((0,VQ.not)(F),()=>{$.error(),Z.break()})},VQ.nil)}}};xS.default=IW0});var uS=S((gS)=>{Object.defineProperty(gS,"__esModule",{value:!0});var UQ=k0(),EW0={message({keyword:$,schemaCode:Z}){let J=$==="maxItems"?"more":"fewer";return UQ.str`must NOT have ${J} than ${Z} items`},params:({schemaCode:$})=>UQ._`{limit: ${$}}`},bW0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:EW0,code($){let{keyword:Z,data:J,schemaCode:Y}=$,X=Z==="maxItems"?UQ.operators.GT:UQ.operators.LT;$.fail$data(UQ._`${J}.length ${X} ${Y}`)}};gS.default=bW0});var HQ=S((lS)=>{Object.defineProperty(lS,"__esModule",{value:!0});var mS=aX();mS.code='require("ajv/dist/runtime/equal").default';lS.default=mS});var pS=S((dS)=>{Object.defineProperty(dS,"__esModule",{value:!0});var Y3=rX(),f$=k0(),fW0=J1(),kW0=HQ(),vW0={message:({params:{i:$,j:Z}})=>f$.str`must NOT have duplicate items (items ## ${Z} and ${$} are identical)`,params:({params:{i:$,j:Z}})=>f$._`{i: ${$}, j: ${Z}}`},yW0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:vW0,code($){let{gen:Z,data:J,$data:Y,schema:X,parentSchema:Q,schemaCode:G,it:W}=$;if(!Y&&!X)return;let K=Z.let("valid"),V=Q.items?(0,Y3.getSchemaTypes)(Q.items):[];$.block$data(K,U,f$._`${G} === false`),$.ok(K);function U(){let F=Z.let("i",f$._`${J}.length`),A=Z.let("j");$.setParams({i:F,j:A}),Z.assign(K,!0),Z.if(f$._`${F} > 1`,()=>(H()?B:z)(F,A))}function H(){return V.length>0&&!V.some((F)=>F==="object"||F==="array")}function B(F,A){let j=Z.name("item"),N=(0,Y3.checkDataTypes)(V,j,W.opts.strictNumbers,Y3.DataType.Wrong),L=Z.const("indices",f$._`{}`);Z.for(f$._`;${F}--;`,()=>{if(Z.let(j,f$._`${J}[${F}]`),Z.if(N,f$._`continue`),V.length>1)Z.if(f$._`typeof ${j} == "string"`,f$._`${j} += "_"`);Z.if(f$._`typeof ${L}[${j}] == "number"`,()=>{Z.assign(A,f$._`${L}[${j}]`),$.error(),Z.assign(K,!1).break()}).code(f$._`${L}[${j}] = ${F}`)})}function z(F,A){let j=(0,fW0.useFunc)(Z,kW0.default),N=Z.name("outer");Z.label(N).for(f$._`;${F}--;`,()=>Z.for(f$._`${A} = ${F}; ${A}--;`,()=>Z.if(f$._`${j}(${J}[${F}], ${J}[${A}])`,()=>{$.error(),Z.assign(K,!1).break(N)})))}}};dS.default=yW0});var iS=S((cS)=>{Object.defineProperty(cS,"__esModule",{value:!0});var X3=k0(),hW0=J1(),gW0=HQ(),uW0={message:"must be equal to constant",params:({schemaCode:$})=>X3._`{allowedValue: ${$}}`},mW0={keyword:"const",$data:!0,error:uW0,code($){let{gen:Z,data:J,$data:Y,schemaCode:X,schema:Q}=$;if(Y||Q&&typeof Q=="object")$.fail$data(X3._`!${(0,hW0.useFunc)(Z,gW0.default)}(${J}, ${X})`);else $.fail(X3._`${Q} !== ${J}`)}};cS.default=mW0});var oS=S((nS)=>{Object.defineProperty(nS,"__esModule",{value:!0});var BQ=k0(),dW0=J1(),pW0=HQ(),cW0={message:"must be equal to one of the allowed values",params:({schemaCode:$})=>BQ._`{allowedValues: ${$}}`},iW0={keyword:"enum",schemaType:"array",$data:!0,error:cW0,code($){let{gen:Z,data:J,$data:Y,schema:X,schemaCode:Q,it:G}=$;if(!Y&&X.length===0)throw Error("enum must have non-empty array");let W=X.length>=G.opts.loopEnum,K,V=()=>K!==null&&K!==void 0?K:K=(0,dW0.useFunc)(Z,pW0.default),U;if(W||Y)U=Z.let("valid"),$.block$data(U,H);else{if(!Array.isArray(X))throw Error("ajv implementation error");let z=Z.const("vSchema",Q);U=(0,BQ.or)(...X.map((F,A)=>B(z,A)))}$.pass(U);function H(){Z.assign(U,!1),Z.forOf("v",Q,(z)=>Z.if(BQ._`${V()}(${J}, ${z})`,()=>Z.assign(U,!0).break()))}function B(z,F){let A=X[F];return typeof A==="object"&&A!==null?BQ._`${V()}(${J}, ${z}[${F}])`:BQ._`${J} === ${A}`}}};nS.default=iW0});var rS=S((sS)=>{Object.defineProperty(sS,"__esModule",{value:!0});var oW0=RS(),sW0=IS(),rW0=SS(),aW0=kS(),tW0=yS(),eW0=hS(),$K0=uS(),ZK0=pS(),JK0=iS(),YK0=oS(),XK0=[oW0.default,sW0.default,rW0.default,aW0.default,tW0.default,eW0.default,$K0.default,ZK0.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},JK0.default,YK0.default];sS.default=XK0});var G3=S((tS)=>{Object.defineProperty(tS,"__esModule",{value:!0});tS.validateAdditionalItems=void 0;var G7=k0(),Q3=J1(),GK0={message:({params:{len:$}})=>G7.str`must NOT have more than ${$} items`,params:({params:{len:$}})=>G7._`{limit: ${$}}`},WK0={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:GK0,code($){let{parentSchema:Z,it:J}=$,{items:Y}=Z;if(!Array.isArray(Y)){(0,Q3.checkStrictMode)(J,'"additionalItems" is ignored when "items" is not an array of schemas');return}aS($,Y)}};function aS($,Z){let{gen:J,schema:Y,data:X,keyword:Q,it:G}=$;G.items=!0;let W=J.const("len",G7._`${X}.length`);if(Y===!1)$.setParams({len:Z.length}),$.pass(G7._`${W} <= ${Z.length}`);else if(typeof Y=="object"&&!(0,Q3.alwaysValidSchema)(G,Y)){let V=J.var("valid",G7._`${W} <= ${Z.length}`);J.if((0,G7.not)(V),()=>K(V)),$.ok(V)}function K(V){J.forRange("i",Z.length,W,(U)=>{if($.subschema({keyword:Q,dataProp:U,dataPropType:Q3.Type.Num},V),!G.allErrors)J.if((0,G7.not)(V),()=>J.break())})}}tS.validateAdditionalItems=aS;tS.default=WK0});var W3=S((Jf)=>{Object.defineProperty(Jf,"__esModule",{value:!0});Jf.validateTuple=void 0;var $f=k0(),JW=J1(),VK0=S$(),UK0={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code($){let{schema:Z,it:J}=$;if(Array.isArray(Z))return Zf($,"additionalItems",Z);if(J.items=!0,(0,JW.alwaysValidSchema)(J,Z))return;$.ok((0,VK0.validateArray)($))}};function Zf($,Z,J=$.schema){let{gen:Y,parentSchema:X,data:Q,keyword:G,it:W}=$;if(U(X),W.opts.unevaluated&&J.length&&W.items!==!0)W.items=JW.mergeEvaluated.items(Y,J.length,W.items);let K=Y.name("valid"),V=Y.const("len",$f._`${Q}.length`);J.forEach((H,B)=>{if((0,JW.alwaysValidSchema)(W,H))return;Y.if($f._`${V} > ${B}`,()=>$.subschema({keyword:G,schemaProp:B,dataProp:B},K)),$.ok(K)});function U(H){let{opts:B,errSchemaPath:z}=W,F=J.length,A=F===H.minItems&&(F===H.maxItems||H[Z]===!1);if(B.strictTuples&&!A){let j=`"${G}" is ${F}-tuple, but minItems or maxItems/${Z} are not specified or different at path "${z}"`;(0,JW.checkStrictMode)(W,j,B.strictTuples)}}}Jf.validateTuple=Zf;Jf.default=UK0});var Qf=S((Xf)=>{Object.defineProperty(Xf,"__esModule",{value:!0});var BK0=W3(),zK0={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:($)=>(0,BK0.validateTuple)($,"items")};Xf.default=zK0});var Kf=S((Wf)=>{Object.defineProperty(Wf,"__esModule",{value:!0});var Gf=k0(),AK0=J1(),OK0=S$(),qK0=G3(),jK0={message:({params:{len:$}})=>Gf.str`must NOT have more than ${$} items`,params:({params:{len:$}})=>Gf._`{limit: ${$}}`},NK0={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:jK0,code($){let{schema:Z,parentSchema:J,it:Y}=$,{prefixItems:X}=J;if(Y.items=!0,(0,AK0.alwaysValidSchema)(Y,Z))return;if(X)(0,qK0.validateAdditionalItems)($,X);else $.ok((0,OK0.validateArray)($))}};Wf.default=NK0});var Uf=S((Vf)=>{Object.defineProperty(Vf,"__esModule",{value:!0});var u8=k0(),YW=J1(),DK0={message:({params:{min:$,max:Z}})=>Z===void 0?u8.str`must contain at least ${$} valid item(s)`:u8.str`must contain at least ${$} and no more than ${Z} valid item(s)`,params:({params:{min:$,max:Z}})=>Z===void 0?u8._`{minContains: ${$}}`:u8._`{minContains: ${$}, maxContains: ${Z}}`},wK0={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:DK0,code($){let{gen:Z,schema:J,parentSchema:Y,data:X,it:Q}=$,G,W,{minContains:K,maxContains:V}=Y;if(Q.opts.next)G=K===void 0?1:K,W=V;else G=1;let U=Z.const("len",u8._`${X}.length`);if($.setParams({min:G,max:W}),W===void 0&&G===0){(0,YW.checkStrictMode)(Q,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(W!==void 0&&G>W){(0,YW.checkStrictMode)(Q,'"minContains" > "maxContains" is always invalid'),$.fail();return}if((0,YW.alwaysValidSchema)(Q,J)){let A=u8._`${U} >= ${G}`;if(W!==void 0)A=u8._`${A} && ${U} <= ${W}`;$.pass(A);return}Q.items=!0;let H=Z.name("valid");if(W===void 0&&G===1)z(H,()=>Z.if(H,()=>Z.break()));else if(G===0){if(Z.let(H,!0),W!==void 0)Z.if(u8._`${X}.length > 0`,B)}else Z.let(H,!1),B();$.result(H,()=>$.reset());function B(){let A=Z.name("_valid"),j=Z.let("count",0);z(A,()=>Z.if(A,()=>F(j)))}function z(A,j){Z.forRange("i",0,U,(N)=>{$.subschema({keyword:"contains",dataProp:N,dataPropType:YW.Type.Num,compositeRule:!0},A),j()})}function F(A){if(Z.code(u8._`${A}++`),W===void 0)Z.if(u8._`${A} >= ${G}`,()=>Z.assign(H,!0).break());else if(Z.if(u8._`${A} > ${W}`,()=>Z.assign(H,!1).break()),G===1)Z.assign(H,!0);else Z.if(u8._`${A} >= ${G}`,()=>Z.assign(H,!0))}}};Vf.default=wK0});var Of=S((zf)=>{Object.defineProperty(zf,"__esModule",{value:!0});zf.validateSchemaDeps=zf.validatePropertyDeps=zf.error=void 0;var K3=k0(),TK0=J1(),zQ=S$();zf.error={message:({params:{property:$,depsCount:Z,deps:J}})=>{let Y=Z===1?"property":"properties";return K3.str`must have ${Y} ${J} when property ${$} is present`},params:({params:{property:$,depsCount:Z,deps:J,missingProperty:Y}})=>K3._`{property: ${$},
116
- missingProperty: ${Y},
117
- depsCount: ${Z},
118
- deps: ${J}}`};var RK0={keyword:"dependencies",type:"object",schemaType:"object",error:zf.error,code($){let[Z,J]=PK0($);Hf($,Z),Bf($,J)}};function PK0({schema:$}){let Z={},J={};for(let Y in $){if(Y==="__proto__")continue;let X=Array.isArray($[Y])?Z:J;X[Y]=$[Y]}return[Z,J]}function Hf($,Z=$.schema){let{gen:J,data:Y,it:X}=$;if(Object.keys(Z).length===0)return;let Q=J.let("missing");for(let G in Z){let W=Z[G];if(W.length===0)continue;let K=(0,zQ.propertyInData)(J,Y,G,X.opts.ownProperties);if($.setParams({property:G,depsCount:W.length,deps:W.join(", ")}),X.allErrors)J.if(K,()=>{for(let V of W)(0,zQ.checkReportMissingProp)($,V)});else J.if(K3._`${K} && (${(0,zQ.checkMissingProp)($,W,Q)})`),(0,zQ.reportMissingProp)($,Q),J.else()}}zf.validatePropertyDeps=Hf;function Bf($,Z=$.schema){let{gen:J,data:Y,keyword:X,it:Q}=$,G=J.name("valid");for(let W in Z){if((0,TK0.alwaysValidSchema)(Q,Z[W]))continue;J.if((0,zQ.propertyInData)(J,Y,W,Q.opts.ownProperties),()=>{let K=$.subschema({keyword:X,schemaProp:W},G);$.mergeValidEvaluated(K,G)},()=>J.var(G,!0)),$.ok(G)}}zf.validateSchemaDeps=Bf;zf.default=RK0});var Nf=S((jf)=>{Object.defineProperty(jf,"__esModule",{value:!0});var qf=k0(),EK0=J1(),bK0={message:"property name must be valid",params:({params:$})=>qf._`{propertyName: ${$.propertyName}}`},_K0={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:bK0,code($){let{gen:Z,schema:J,data:Y,it:X}=$;if((0,EK0.alwaysValidSchema)(X,J))return;let Q=Z.name("valid");Z.forIn("key",Y,(G)=>{$.setParams({propertyName:G}),$.subschema({keyword:"propertyNames",data:G,dataTypes:["string"],propertyName:G,compositeRule:!0},Q),Z.if((0,qf.not)(Q),()=>{if($.error(!0),!X.allErrors)Z.break()})}),$.ok(Q)}};jf.default=_K0});var V3=S((Mf)=>{Object.defineProperty(Mf,"__esModule",{value:!0});var XW=S$(),Q6=k0(),fK0=g8(),QW=J1(),kK0={message:"must NOT have additional properties",params:({params:$})=>Q6._`{additionalProperty: ${$.additionalProperty}}`},vK0={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:kK0,code($){let{gen:Z,schema:J,parentSchema:Y,data:X,errsCount:Q,it:G}=$;if(!Q)throw Error("ajv implementation error");let{allErrors:W,opts:K}=G;if(G.props=!0,K.removeAdditional!=="all"&&(0,QW.alwaysValidSchema)(G,J))return;let V=(0,XW.allSchemaProperties)(Y.properties),U=(0,XW.allSchemaProperties)(Y.patternProperties);H(),$.ok(Q6._`${Q} === ${fK0.default.errors}`);function H(){Z.forIn("key",X,(j)=>{if(!V.length&&!U.length)F(j);else Z.if(B(j),()=>F(j))})}function B(j){let N;if(V.length>8){let L=(0,QW.schemaRefOrVal)(G,Y.properties,"properties");N=(0,XW.isOwnProperty)(Z,L,j)}else if(V.length)N=(0,Q6.or)(...V.map((L)=>Q6._`${j} === ${L}`));else N=Q6.nil;if(U.length)N=(0,Q6.or)(N,...U.map((L)=>Q6._`${(0,XW.usePattern)($,L)}.test(${j})`));return(0,Q6.not)(N)}function z(j){Z.code(Q6._`delete ${X}[${j}]`)}function F(j){if(K.removeAdditional==="all"||K.removeAdditional&&J===!1){z(j);return}if(J===!1){if($.setParams({additionalProperty:j}),$.error(),!W)Z.break();return}if(typeof J=="object"&&!(0,QW.alwaysValidSchema)(G,J)){let N=Z.name("valid");if(K.removeAdditional==="failing")A(j,N,!1),Z.if((0,Q6.not)(N),()=>{$.reset(),z(j)});else if(A(j,N),!W)Z.if((0,Q6.not)(N),()=>Z.break())}}function A(j,N,L){let q={keyword:"additionalProperties",dataProp:j,dataPropType:QW.Type.Str};if(L===!1)Object.assign(q,{compositeRule:!0,createErrors:!1,allErrors:!1});$.subschema(q,N)}}};Mf.default=vK0});var Tf=S((Lf)=>{Object.defineProperty(Lf,"__esModule",{value:!0});var xK0=lJ(),Df=S$(),U3=J1(),wf=V3(),hK0={keyword:"properties",type:"object",schemaType:"object",code($){let{gen:Z,schema:J,parentSchema:Y,data:X,it:Q}=$;if(Q.opts.removeAdditional==="all"&&Y.additionalProperties===void 0)wf.default.code(new xK0.KeywordCxt(Q,wf.default,"additionalProperties"));let G=(0,Df.allSchemaProperties)(J);for(let H of G)Q.definedProperties.add(H);if(Q.opts.unevaluated&&G.length&&Q.props!==!0)Q.props=U3.mergeEvaluated.props(Z,(0,U3.toHash)(G),Q.props);let W=G.filter((H)=>!(0,U3.alwaysValidSchema)(Q,J[H]));if(W.length===0)return;let K=Z.name("valid");for(let H of W){if(V(H))U(H);else{if(Z.if((0,Df.propertyInData)(Z,X,H,Q.opts.ownProperties)),U(H),!Q.allErrors)Z.else().var(K,!0);Z.endIf()}$.it.definedProperties.add(H),$.ok(K)}function V(H){return Q.opts.useDefaults&&!Q.compositeRule&&J[H].default!==void 0}function U(H){$.subschema({keyword:"properties",schemaProp:H,dataProp:H},K)}}};Lf.default=hK0});var Ef=S((Cf)=>{Object.defineProperty(Cf,"__esModule",{value:!0});var Rf=S$(),GW=k0(),Pf=J1(),If=J1(),uK0={keyword:"patternProperties",type:"object",schemaType:"object",code($){let{gen:Z,schema:J,data:Y,parentSchema:X,it:Q}=$,{opts:G}=Q,W=(0,Rf.allSchemaProperties)(J),K=W.filter((A)=>(0,Pf.alwaysValidSchema)(Q,J[A]));if(W.length===0||K.length===W.length&&(!Q.opts.unevaluated||Q.props===!0))return;let V=G.strictSchema&&!G.allowMatchingProperties&&X.properties,U=Z.name("valid");if(Q.props!==!0&&!(Q.props instanceof GW.Name))Q.props=(0,If.evaluatedPropsToName)(Z,Q.props);let{props:H}=Q;B();function B(){for(let A of W){if(V)z(A);if(Q.allErrors)F(A);else Z.var(U,!0),F(A),Z.if(U)}}function z(A){for(let j in V)if(new RegExp(A).test(j))(0,Pf.checkStrictMode)(Q,`property ${j} matches pattern ${A} (use allowMatchingProperties)`)}function F(A){Z.forIn("key",Y,(j)=>{Z.if(GW._`${(0,Rf.usePattern)($,A)}.test(${j})`,()=>{let N=K.includes(A);if(!N)$.subschema({keyword:"patternProperties",schemaProp:A,dataProp:j,dataPropType:If.Type.Str},U);if(Q.opts.unevaluated&&H!==!0)Z.assign(GW._`${H}[${j}]`,!0);else if(!N&&!Q.allErrors)Z.if((0,GW.not)(U),()=>Z.break())})})}}};Cf.default=uK0});var _f=S((bf)=>{Object.defineProperty(bf,"__esModule",{value:!0});var lK0=J1(),dK0={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code($){let{gen:Z,schema:J,it:Y}=$;if((0,lK0.alwaysValidSchema)(Y,J)){$.fail();return}let X=Z.name("valid");$.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},X),$.failResult(X,()=>$.reset(),()=>$.error())},error:{message:"must NOT be valid"}};bf.default=dK0});var ff=S((Sf)=>{Object.defineProperty(Sf,"__esModule",{value:!0});var cK0=S$(),iK0={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:cK0.validateUnion,error:{message:"must match a schema in anyOf"}};Sf.default=iK0});var vf=S((kf)=>{Object.defineProperty(kf,"__esModule",{value:!0});var WW=k0(),oK0=J1(),sK0={message:"must match exactly one schema in oneOf",params:({params:$})=>WW._`{passingSchemas: ${$.passing}}`},rK0={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:sK0,code($){let{gen:Z,schema:J,parentSchema:Y,it:X}=$;if(!Array.isArray(J))throw Error("ajv implementation error");if(X.opts.discriminator&&Y.discriminator)return;let Q=J,G=Z.let("valid",!1),W=Z.let("passing",null),K=Z.name("_valid");$.setParams({passing:W}),Z.block(V),$.result(G,()=>$.reset(),()=>$.error(!0));function V(){Q.forEach((U,H)=>{let B;if((0,oK0.alwaysValidSchema)(X,U))Z.var(K,!0);else B=$.subschema({keyword:"oneOf",schemaProp:H,compositeRule:!0},K);if(H>0)Z.if(WW._`${K} && ${G}`).assign(G,!1).assign(W,WW._`[${W}, ${H}]`).else();Z.if(K,()=>{if(Z.assign(G,!0),Z.assign(W,H),B)$.mergeEvaluated(B,WW.Name)})})}}};kf.default=rK0});var xf=S((yf)=>{Object.defineProperty(yf,"__esModule",{value:!0});var tK0=J1(),eK0={keyword:"allOf",schemaType:"array",code($){let{gen:Z,schema:J,it:Y}=$;if(!Array.isArray(J))throw Error("ajv implementation error");let X=Z.name("valid");J.forEach((Q,G)=>{if((0,tK0.alwaysValidSchema)(Y,Q))return;let W=$.subschema({keyword:"allOf",schemaProp:G},X);$.ok(X),$.mergeEvaluated(W)})}};yf.default=eK0});var mf=S((uf)=>{Object.defineProperty(uf,"__esModule",{value:!0});var KW=k0(),gf=J1(),ZV0={message:({params:$})=>KW.str`must match "${$.ifClause}" schema`,params:({params:$})=>KW._`{failingKeyword: ${$.ifClause}}`},JV0={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:ZV0,code($){let{gen:Z,parentSchema:J,it:Y}=$;if(J.then===void 0&&J.else===void 0)(0,gf.checkStrictMode)(Y,'"if" without "then" and "else" is ignored');let X=hf(Y,"then"),Q=hf(Y,"else");if(!X&&!Q)return;let G=Z.let("valid",!0),W=Z.name("_valid");if(K(),$.reset(),X&&Q){let U=Z.let("ifClause");$.setParams({ifClause:U}),Z.if(W,V("then",U),V("else",U))}else if(X)Z.if(W,V("then"));else Z.if((0,KW.not)(W),V("else"));$.pass(G,()=>$.error(!0));function K(){let U=$.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},W);$.mergeEvaluated(U)}function V(U,H){return()=>{let B=$.subschema({keyword:U},W);if(Z.assign(G,W),$.mergeValidEvaluated(B,G),H)Z.assign(H,KW._`${U}`);else $.setParams({ifClause:U})}}}};function hf($,Z){let J=$.schema[Z];return J!==void 0&&!(0,gf.alwaysValidSchema)($,J)}uf.default=JV0});var df=S((lf)=>{Object.defineProperty(lf,"__esModule",{value:!0});var XV0=J1(),QV0={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:$,parentSchema:Z,it:J}){if(Z.if===void 0)(0,XV0.checkStrictMode)(J,`"${$}" without "if" is ignored`)}};lf.default=QV0});var cf=S((pf)=>{Object.defineProperty(pf,"__esModule",{value:!0});var WV0=G3(),KV0=Qf(),VV0=W3(),UV0=Kf(),HV0=Uf(),BV0=Of(),zV0=Nf(),FV0=V3(),AV0=Tf(),OV0=Ef(),qV0=_f(),jV0=ff(),NV0=vf(),MV0=xf(),DV0=mf(),wV0=df();function LV0($=!1){let Z=[qV0.default,jV0.default,NV0.default,MV0.default,DV0.default,wV0.default,zV0.default,FV0.default,BV0.default,AV0.default,OV0.default];if($)Z.push(KV0.default,UV0.default);else Z.push(WV0.default,VV0.default);return Z.push(HV0.default),Z}pf.default=LV0});var of=S((nf)=>{Object.defineProperty(nf,"__esModule",{value:!0});var W$=k0(),RV0={message:({schemaCode:$})=>W$.str`must match format "${$}"`,params:({schemaCode:$})=>W$._`{format: ${$}}`},PV0={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:RV0,code($,Z){let{gen:J,data:Y,$data:X,schema:Q,schemaCode:G,it:W}=$,{opts:K,errSchemaPath:V,schemaEnv:U,self:H}=W;if(!K.validateFormats)return;if(X)B();else z();function B(){let F=J.scopeValue("formats",{ref:H.formats,code:K.code.formats}),A=J.const("fDef",W$._`${F}[${G}]`),j=J.let("fType"),N=J.let("format");J.if(W$._`typeof ${A} == "object" && !(${A} instanceof RegExp)`,()=>J.assign(j,W$._`${A}.type || "string"`).assign(N,W$._`${A}.validate`),()=>J.assign(j,W$._`"string"`).assign(N,A)),$.fail$data((0,W$.or)(L(),q()));function L(){if(K.strictSchema===!1)return W$.nil;return W$._`${G} && !${N}`}function q(){let M=U.$async?W$._`(${A}.async ? await ${N}(${Y}) : ${N}(${Y}))`:W$._`${N}(${Y})`,C=W$._`(typeof ${N} == "function" ? ${M} : ${N}.test(${Y}))`;return W$._`${N} && ${N} !== true && ${j} === ${Z} && !${C}`}}function z(){let F=H.formats[Q];if(!F){L();return}if(F===!0)return;let[A,j,N]=q(F);if(A===Z)$.pass(M());function L(){if(K.strictSchema===!1){H.logger.warn(C());return}throw Error(C());function C(){return`unknown format "${Q}" ignored in schema at path "${V}"`}}function q(C){let R=C instanceof RegExp?(0,W$.regexpCode)(C):K.code.formats?W$._`${K.code.formats}${(0,W$.getProperty)(Q)}`:void 0,w=J.scopeValue("formats",{key:Q,ref:C,code:R});if(typeof C=="object"&&!(C instanceof RegExp))return[C.type||"string",C.validate,W$._`${w}.validate`];return["string",C,w]}function M(){if(typeof F=="object"&&!(F instanceof RegExp)&&F.async){if(!U.$async)throw Error("async format in sync schema");return W$._`await ${N}(${Y})`}return typeof j=="function"?W$._`${N}(${Y})`:W$._`${N}.test(${Y})`}}}};nf.default=PV0});var rf=S((sf)=>{Object.defineProperty(sf,"__esModule",{value:!0});var CV0=of(),EV0=[CV0.default];sf.default=EV0});var ef=S((af)=>{Object.defineProperty(af,"__esModule",{value:!0});af.contentVocabulary=af.metadataVocabulary=void 0;af.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];af.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Jk=S((Zk)=>{Object.defineProperty(Zk,"__esModule",{value:!0});var SV0=LS(),fV0=rS(),kV0=cf(),vV0=rf(),$k=ef(),yV0=[SV0.default,fV0.default,(0,kV0.default)(),vV0.default,$k.metadataVocabulary,$k.contentVocabulary];Zk.default=yV0});var H3=S((Xk)=>{Object.defineProperty(Xk,"__esModule",{value:!0});Xk.DiscrError=void 0;var Yk;(function($){$.Tag="tag",$.Mapping="mapping"})(Yk||(Xk.DiscrError=Yk={}))});var Kk=S((Wk)=>{Object.defineProperty(Wk,"__esModule",{value:!0});var nJ=k0(),B3=H3(),Gk=Y7(),hV0=YZ(),gV0=J1(),uV0={message:({params:{discrError:$,tagName:Z}})=>$===B3.DiscrError.Tag?`tag "${Z}" must be string`:`value of tag "${Z}" must be in oneOf`,params:({params:{discrError:$,tag:Z,tagName:J}})=>nJ._`{error: ${$}, tag: ${J}, tagValue: ${Z}}`},mV0={keyword:"discriminator",type:"object",schemaType:"object",error:uV0,code($){let{gen:Z,data:J,schema:Y,parentSchema:X,it:Q}=$,{oneOf:G}=X;if(!Q.opts.discriminator)throw Error("discriminator: requires discriminator option");let W=Y.propertyName;if(typeof W!="string")throw Error("discriminator: requires propertyName");if(Y.mapping)throw Error("discriminator: mapping is not supported");if(!G)throw Error("discriminator: requires oneOf keyword");let K=Z.let("valid",!1),V=Z.const("tag",nJ._`${J}${(0,nJ.getProperty)(W)}`);Z.if(nJ._`typeof ${V} == "string"`,()=>U(),()=>$.error(!1,{discrError:B3.DiscrError.Tag,tag:V,tagName:W})),$.ok(K);function U(){let z=B();Z.if(!1);for(let F in z)Z.elseIf(nJ._`${V} === ${F}`),Z.assign(K,H(z[F]));Z.else(),$.error(!1,{discrError:B3.DiscrError.Mapping,tag:V,tagName:W}),Z.endIf()}function H(z){let F=Z.name("valid"),A=$.subschema({keyword:"oneOf",schemaProp:z},F);return $.mergeEvaluated(A,nJ.Name),F}function B(){var z;let F={},A=N(X),j=!0;for(let M=0;M<G.length;M++){let C=G[M];if((C===null||C===void 0?void 0:C.$ref)&&!(0,gV0.schemaHasRulesButRef)(C,Q.self.RULES)){let w=C.$ref;if(C=Gk.resolveRef.call(Q.self,Q.schemaEnv.root,Q.baseId,w),C instanceof Gk.SchemaEnv)C=C.schema;if(C===void 0)throw new hV0.default(Q.opts.uriResolver,Q.baseId,w)}let R=(z=C===null||C===void 0?void 0:C.properties)===null||z===void 0?void 0:z[W];if(typeof R!="object")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${W}"`);j=j&&(A||N(C)),L(R,M)}if(!j)throw Error(`discriminator: "${W}" must be required`);return F;function N({required:M}){return Array.isArray(M)&&M.includes(W)}function L(M,C){if(M.const)q(M.const,C);else if(M.enum)for(let R of M.enum)q(R,C);else throw Error(`discriminator: "properties/${W}" must have "const" or "enum"`)}function q(M,C){if(typeof M!="string"||M in F)throw Error(`discriminator: "${W}" values must be unique strings`);F[M]=C}}}};Wk.default=mV0});var Vk=S((Ky0,dV0)=>{dV0.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var UW=S((H8,z3)=>{Object.defineProperty(H8,"__esModule",{value:!0});H8.MissingRefError=H8.ValidationError=H8.CodeGen=H8.Name=H8.nil=H8.stringify=H8.str=H8._=H8.KeywordCxt=H8.Ajv=void 0;var pV0=Z3(),cV0=Jk(),iV0=Kk(),Uk=Vk(),nV0=["/properties"],VW="http://json-schema.org/draft-07/schema";class FQ extends pV0.default{_addVocabularies(){if(super._addVocabularies(),cV0.default.forEach(($)=>this.addVocabulary($)),this.opts.discriminator)this.addKeyword(iV0.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let $=this.opts.$data?this.$dataMetaSchema(Uk,nV0):Uk;this.addMetaSchema($,VW,!1),this.refs["http://json-schema.org/schema"]=VW}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(VW)?VW:void 0)}}H8.Ajv=FQ;z3.exports=H8=FQ;z3.exports.Ajv=FQ;Object.defineProperty(H8,"__esModule",{value:!0});H8.default=FQ;var oV0=lJ();Object.defineProperty(H8,"KeywordCxt",{enumerable:!0,get:function(){return oV0.KeywordCxt}});var oJ=k0();Object.defineProperty(H8,"_",{enumerable:!0,get:function(){return oJ._}});Object.defineProperty(H8,"str",{enumerable:!0,get:function(){return oJ.str}});Object.defineProperty(H8,"stringify",{enumerable:!0,get:function(){return oJ.stringify}});Object.defineProperty(H8,"nil",{enumerable:!0,get:function(){return oJ.nil}});Object.defineProperty(H8,"Name",{enumerable:!0,get:function(){return oJ.Name}});Object.defineProperty(H8,"CodeGen",{enumerable:!0,get:function(){return oJ.CodeGen}});var sV0=ZQ();Object.defineProperty(H8,"ValidationError",{enumerable:!0,get:function(){return sV0.default}});var rV0=YZ();Object.defineProperty(H8,"MissingRefError",{enumerable:!0,get:function(){return rV0.default}})});var QZ=S((Bk)=>{Object.defineProperty(Bk,"__esModule",{value:!0});Bk.checkMetadata=void 0;var eV0=J1(),$U0={keyword:"metadata",schemaType:"object",code($){Hk($);let{gen:Z,schema:J,it:Y}=$;if((0,eV0.alwaysValidSchema)(Y,J))return;let X=Z.name("valid");$.subschema({keyword:"metadata",jtdMetadata:!0},X),$.ok(X)}};function Hk({it:$,keyword:Z},J){if($.jtdMetadata!==J)throw Error(`JTD: "${Z}" cannot be used in this schema location`)}Bk.checkMetadata=Hk;Bk.default=$U0});var HW=S((qk)=>{Object.defineProperty(qk,"__esModule",{value:!0});qk.hasRef=void 0;var Fk=Y7(),AQ=k0(),JU0=YZ(),Ak=g8(),Ok=J3(),YU0=QZ(),XU0={keyword:"ref",schemaType:"string",code($){(0,YU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,parentSchema:X,it:Q}=$,{schemaEnv:{root:G}}=Q,W=Z.name("valid");if(X.nullable)Z.var(W,AQ._`${J} === null`),Z.if((0,AQ.not)(W),K);else Z.var(W,!1),K();$.ok(W);function K(){var H;let B=(H=G.schema.definitions)===null||H===void 0?void 0:H[Y];if(!B)throw new JU0.default(Q.opts.uriResolver,"",Y,`No definition ${Y}`);if(F3(B)||!Q.opts.inlineRefs)V(B);else U(B)}function V(H){let B=Fk.compileSchema.call(Q.self,new Fk.SchemaEnv({schema:H,root:G,schemaPath:`/definitions/${Y}`})),z=(0,Ok.getValidate)($,B),F=Z.const("_errs",Ak.default.errors);(0,Ok.callRef)($,z,B,B.$async),Z.assign(W,AQ._`${F} === ${Ak.default.errors}`)}function U(H){let B=Z.scopeValue("schema",Q.opts.code.source===!0?{ref:H,code:(0,AQ.stringify)(H)}:{ref:H});$.subschema({schema:H,dataTypes:[],schemaPath:AQ.nil,topSchemaRef:B,errSchemaPath:`/definitions/${Y}`},W)}}};function F3($){for(let Z in $){let J;if(Z==="ref"||typeof(J=$[Z])=="object"&&F3(J))return!0}return!1}qk.hasRef=F3;qk.default=XU0});var A3=S((Dk)=>{Object.defineProperty(Dk,"__esModule",{value:!0});var GU0=/t|\s/i,WU0=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,KU0=/^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:z|([+-]\d\d)(?::?(\d\d))?)$/i,VU0=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Mk($,Z){let J=$.split(GU0);return J.length===2&&Nk(J[0])&&UU0(J[1])||Z&&J.length===1&&Nk(J[0])}Dk.default=Mk;function Nk($){let Z=WU0.exec($);if(!Z)return!1;let J=+Z[1],Y=+Z[2],X=+Z[3];return Y>=1&&Y<=12&&X>=1&&(X<=VU0[Y]||Y===2&&X===29&&(J%100===0?J%400===0:J%4===0))}function UU0($){let Z=KU0.exec($);if(!Z)return!1;let J=+Z[1],Y=+Z[2],X=+Z[3],Q=+(Z[4]||0),G=+(Z[5]||0);return J<=23&&Y<=59&&X<=59||J-Q===23&&Y-G===59&&X===60}Mk.code='require("ajv/dist/runtime/timestamp").default'});var sJ=S((Tk)=>{Object.defineProperty(Tk,"__esModule",{value:!0});Tk.typeErrorParams=Tk.typeErrorMessage=Tk.typeError=void 0;var BU0=k0();function zU0($){return{message:(Z)=>wk(Z,$),params:(Z)=>Lk(Z,$)}}Tk.typeError=zU0;function wk({parentSchema:$},Z){return($===null||$===void 0?void 0:$.nullable)?`must be ${Z} or null`:`must be ${Z}`}Tk.typeErrorMessage=wk;function Lk({parentSchema:$},Z){return BU0._`{type: ${Z}, nullable: ${!!($===null||$===void 0?void 0:$.nullable)}}`}Tk.typeErrorParams=Lk});var q3=S((Ik)=>{Object.defineProperty(Ik,"__esModule",{value:!0});Ik.intRange=void 0;var b8=k0(),OU0=A3(),qU0=J1(),jU0=QZ(),Pk=sJ();Ik.intRange={int8:[-128,127,3],uint8:[0,255,3],int16:[-32768,32767,5],uint16:[0,65535,5],int32:[-2147483648,2147483647,10],uint32:[0,4294967295,10]};var NU0={message:($)=>(0,Pk.typeErrorMessage)($,$.schema),params:($)=>(0,Pk.typeErrorParams)($,$.schema)};function MU0($){let{gen:Z,data:J,it:Y}=$,{timestamp:X,allowDate:Q}=Y.opts;if(X==="date")return b8._`${J} instanceof Date `;let G=(0,qU0.useFunc)(Z,OU0.default),W=Q?b8._`, true`:b8.nil,K=b8._`typeof ${J} == "string" && ${G}(${J}${W})`;return X==="string"?K:(0,b8.or)(b8._`${J} instanceof Date`,K)}var DU0={keyword:"type",schemaType:"string",error:NU0,code($){(0,jU0.checkMetadata)($);let{data:Z,schema:J,parentSchema:Y,it:X}=$,Q;switch(J){case"boolean":case"string":Q=b8._`typeof ${Z} == ${J}`;break;case"timestamp":{Q=MU0($);break}case"float32":case"float64":Q=b8._`typeof ${Z} == "number"`;break;default:{let G=J;if(Q=b8._`typeof ${Z} == "number" && isFinite(${Z}) && !(${Z} % 1)`,!X.opts.int32range&&(G==="int32"||G==="uint32")){if(G==="uint32")Q=b8._`${Q} && ${Z} >= 0`}else{let[W,K]=Ik.intRange[G];Q=b8._`${Q} && ${Z} >= ${W} && ${Z} <= ${K}`}}}$.pass(Y.nullable?(0,b8.or)(b8._`${Z} === null`,Q):Q)}};Ik.default=DU0});var rJ=S((Ek)=>{Object.defineProperty(Ek,"__esModule",{value:!0});Ek.checkNullableObject=Ek.checkNullable=void 0;var BW=k0();function Ck({gen:$,data:Z,parentSchema:J},Y=BW.nil){let X=$.name("valid");if(J.nullable)$.let(X,BW._`${Z} === null`),Y=(0,BW.not)(X);else $.let(X,!1);return[X,Y]}Ek.checkNullable=Ck;function LU0($,Z){let[J,Y]=Ck($,Z);return[J,BW._`${Y} && typeof ${$.data} == "object" && !Array.isArray(${$.data})`]}Ek.checkNullableObject=LU0});var Sk=S((_k)=>{Object.defineProperty(_k,"__esModule",{value:!0});var aZ=k0(),RU0=QZ(),PU0=rJ(),IU0={message:"must be equal to one of the allowed values",params:({schemaCode:$})=>aZ._`{allowedValues: ${$}}`},CU0={keyword:"enum",schemaType:"array",error:IU0,code($){(0,RU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,schemaValue:X,parentSchema:Q,it:G}=$;if(Y.length===0)throw Error("enum must have non-empty array");if(Y.length!==new Set(Y).size)throw Error("enum items must be unique");let W,K=aZ._`typeof ${J} == "string"`;if(Y.length>=G.opts.loopEnum){let U;[W,U]=(0,PU0.checkNullable)($,K),Z.if(U,V)}else{if(!Array.isArray(Y))throw Error("ajv implementation error");if(W=(0,aZ.and)(K,(0,aZ.or)(...Y.map((U)=>aZ._`${J} === ${U}`))),Q.nullable)W=(0,aZ.or)(aZ._`${J} === null`,W)}$.pass(W);function V(){Z.forOf("v",X,(U)=>Z.if(aZ._`${W} = ${J} === ${U}`,()=>Z.break()))}}};_k.default=CU0});var vk=S((kk)=>{Object.defineProperty(kk,"__esModule",{value:!0});var bU0=J1(),_U0=S$(),fk=k0(),SU0=QZ(),fU0=rJ(),kU0=sJ(),vU0={keyword:"elements",schemaType:"object",error:(0,kU0.typeError)("array"),code($){(0,SU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,it:X}=$;if((0,bU0.alwaysValidSchema)(X,Y))return;let[Q]=(0,fU0.checkNullable)($);Z.if((0,fk.not)(Q),()=>Z.if(fk._`Array.isArray(${J})`,()=>Z.assign(Q,(0,_U0.validateArray)($)),()=>$.error())),$.ok(Q)}};kk.default=vU0});var N3=S((gk)=>{Object.defineProperty(gk,"__esModule",{value:!0});gk.validateProperties=gk.error=void 0;var j3=S$(),yk=J1(),GZ=k0(),xU0=QZ(),hU0=rJ(),xk=sJ(),aJ;(function($){$.Additional="additional",$.Missing="missing"})(aJ||(aJ={}));gk.error={message:($)=>{let{params:Z}=$;return Z.propError?Z.propError===aJ.Additional?"must NOT have additional properties":`must have property '${Z.missingProperty}'`:(0,xk.typeErrorMessage)($,"object")},params:($)=>{let{params:Z}=$;return Z.propError?Z.propError===aJ.Additional?GZ._`{error: ${Z.propError}, additionalProperty: ${Z.additionalProperty}}`:GZ._`{error: ${Z.propError}, missingProperty: ${Z.missingProperty}}`:(0,xk.typeErrorParams)($,"object")}};var gU0={keyword:"properties",schemaType:"object",error:gk.error,code:hk};function hk($){(0,xU0.checkMetadata)($);let{gen:Z,data:J,parentSchema:Y,it:X}=$,{additionalProperties:Q,nullable:G}=Y;if(X.jtdDiscriminator&&G)throw Error("JTD: nullable inside discriminator mapping");if(z())throw Error("JTD: properties and optionalProperties have common members");let[W,K]=F("properties"),[V,U]=F("optionalProperties");if(K.length===0&&U.length===0&&Q)return;let[H,B]=X.jtdDiscriminator===void 0?(0,hU0.checkNullableObject)($,J):[Z.let("valid",!1),!0];Z.if(B,()=>Z.assign(H,!0).block(()=>{if(A(K,"properties",!0),A(U,"optionalProperties"),!Q)N()})),$.pass(H);function z(){let{properties:q,optionalProperties:M}=Y;if(!(q&&M))return!1;for(let C in q)if(Object.prototype.hasOwnProperty.call(M,C))return!0;return!1}function F(q){let M=Y[q],C=M?(0,j3.allSchemaProperties)(M):[];if(X.jtdDiscriminator&&C.some((w)=>w===X.jtdDiscriminator))throw Error(`JTD: discriminator tag used in ${q}`);let R=C.filter((w)=>!(0,yk.alwaysValidSchema)(X,M[w]));return[C,R]}function A(q,M,C){let R=Z.var("valid");for(let I of q)Z.if((0,j3.propertyInData)(Z,J,I,X.opts.ownProperties),()=>j(I,M,R),()=>w(I)),$.ok(R);function w(I){if(C)Z.assign(R,!1),$.error(!1,{propError:aJ.Missing,missingProperty:I},{schemaPath:I});else Z.assign(R,!0)}}function j(q,M,C){$.subschema({keyword:M,schemaProp:q,dataProp:q},C)}function N(){Z.forIn("key",J,(q)=>{let M=L(q,W,"properties",X.jtdDiscriminator),C=L(q,V,"optionalProperties"),R=M===!0?C:C===!0?M:(0,GZ.and)(M,C);Z.if(R,()=>{if(X.opts.removeAdditional)Z.code(GZ._`delete ${J}[${q}]`);else if($.error(!1,{propError:aJ.Additional,additionalProperty:q},{instancePath:q,parentSchema:!0}),!X.opts.allErrors)Z.break()})})}function L(q,M,C,R){let w;if(M.length>8){let I=(0,yk.schemaRefOrVal)(X,Y[C],C);if(w=(0,GZ.not)((0,j3.isOwnProperty)(Z,I,q)),R!==void 0)w=(0,GZ.and)(w,GZ._`${q} !== ${R}`)}else if(M.length||R!==void 0){let I=R===void 0?M:[R].concat(M);w=(0,GZ.and)(...I.map((_)=>GZ._`${q} !== ${_}`))}else w=!0;return w}}gk.validateProperties=hk;gk.default=gU0});var pk=S((dk)=>{Object.defineProperty(dk,"__esModule",{value:!0});var lk=N3(),mU0={keyword:"optionalProperties",schemaType:"object",error:lk.error,code($){if($.parentSchema.properties)return;(0,lk.validateProperties)($)}};dk.default=mU0});var nk=S((ik)=>{Object.defineProperty(ik,"__esModule",{value:!0});var W7=k0(),dU0=QZ(),pU0=rJ(),ck=sJ(),zW=H3(),cU0={message:($)=>{let{schema:Z,params:J}=$;return J.discrError?J.discrError===zW.DiscrError.Tag?`tag "${Z}" must be string`:`value of tag "${Z}" must be in mapping`:(0,ck.typeErrorMessage)($,"object")},params:($)=>{let{schema:Z,params:J}=$;return J.discrError?W7._`{error: ${J.discrError}, tag: ${Z}, tagValue: ${J.tag}}`:(0,ck.typeErrorParams)($,"object")}},iU0={keyword:"discriminator",schemaType:"string",implements:["mapping"],error:cU0,code($){(0,dU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,parentSchema:X}=$,[Q,G]=(0,pU0.checkNullableObject)($,J);Z.if(G),W(),Z.elseIf((0,W7.not)(Q)),$.error(),Z.endIf(),$.ok(Q);function W(){let U=Z.const("tag",W7._`${J}${(0,W7.getProperty)(Y)}`);Z.if(W7._`${U} === undefined`),$.error(!1,{discrError:zW.DiscrError.Tag,tag:U}),Z.elseIf(W7._`typeof ${U} == "string"`),K(U),Z.else(),$.error(!1,{discrError:zW.DiscrError.Tag,tag:U},{instancePath:Y}),Z.endIf()}function K(U){Z.if(!1);for(let H in X.mapping)Z.elseIf(W7._`${U} === ${H}`),Z.assign(Q,V(H));Z.else(),$.error(!1,{discrError:zW.DiscrError.Mapping,tag:U},{instancePath:Y,schemaPath:"mapping",parentSchema:!0}),Z.endIf()}function V(U){let H=Z.name("valid");return $.subschema({keyword:"mapping",schemaProp:U,jtdDiscriminator:Y},H),H}}};ik.default=iU0});var rk=S((sk)=>{Object.defineProperty(sk,"__esModule",{value:!0});var ok=J1(),FW=k0(),oU0=QZ(),sU0=rJ(),rU0=sJ(),aU0={keyword:"values",schemaType:"object",error:(0,rU0.typeError)("object"),code($){(0,oU0.checkMetadata)($);let{gen:Z,data:J,schema:Y,it:X}=$,[Q,G]=(0,sU0.checkNullableObject)($,J);if((0,ok.alwaysValidSchema)(X,Y))Z.if((0,FW.not)((0,FW.or)(G,Q)),()=>$.error());else Z.if(G),Z.assign(Q,W()),Z.elseIf((0,FW.not)(Q)),$.error(),Z.endIf();$.ok(Q);function W(){let K=Z.name("valid");if(X.allErrors){let U=Z.let("valid",!0);return V(()=>Z.assign(U,!1)),U}return Z.var(K,!0),V(()=>Z.break()),K;function V(U){Z.forIn("key",J,(H)=>{$.subschema({keyword:"values",dataProp:H,dataPropType:ok.Type.Str},K),Z.if((0,FW.not)(K),U)})}}}};sk.default=aU0});var tk=S((ak)=>{Object.defineProperty(ak,"__esModule",{value:!0});var eU0=S$(),$H0={keyword:"union",schemaType:"array",trackErrors:!0,code:eU0.validateUnion,error:{message:"must match a schema in union"}};ak.default=$H0});var $v=S((ek)=>{Object.defineProperty(ek,"__esModule",{value:!0});var JH0=HW(),YH0=q3(),XH0=Sk(),QH0=vk(),GH0=N3(),WH0=pk(),KH0=nk(),VH0=rk(),UH0=tk(),HH0=QZ(),BH0=["definitions",JH0.default,YH0.default,XH0.default,QH0.default,GH0.default,WH0.default,KH0.default,VH0.default,UH0.default,HH0.default,{keyword:"additionalProperties",schemaType:"boolean"},{keyword:"nullable",schemaType:"boolean"}];ek.default=BH0});var Qv=S((Xv)=>{Object.defineProperty(Xv,"__esModule",{value:!0});var WZ=($)=>{let Z={nullable:{type:"boolean"},metadata:{optionalProperties:{union:{elements:{ref:"schema"}}},additionalProperties:!0}};if($)Z.definitions={values:{ref:"schema"}};return Z},FH0=($)=>({optionalProperties:WZ($)}),AH0=($)=>({properties:{ref:{type:"string"}},optionalProperties:WZ($)}),OH0=($)=>({properties:{type:{enum:["boolean","timestamp","string","float32","float64","int8","uint8","int16","uint16","int32","uint32"]}},optionalProperties:WZ($)}),qH0=($)=>({properties:{enum:{elements:{type:"string"}}},optionalProperties:WZ($)}),jH0=($)=>({properties:{elements:{ref:"schema"}},optionalProperties:WZ($)}),Jv=($)=>({properties:{properties:{values:{ref:"schema"}}},optionalProperties:{optionalProperties:{values:{ref:"schema"}},additionalProperties:{type:"boolean"},...WZ($)}}),Yv=($)=>({properties:{optionalProperties:{values:{ref:"schema"}}},optionalProperties:{additionalProperties:{type:"boolean"},...WZ($)}}),NH0=($)=>({properties:{discriminator:{type:"string"},mapping:{values:{metadata:{union:[Jv(!1),Yv(!1)]}}}},optionalProperties:WZ($)}),MH0=($)=>({properties:{values:{ref:"schema"}},optionalProperties:WZ($)}),Zv=($)=>({metadata:{union:[FH0,AH0,OH0,qH0,jH0,Jv,Yv,NH0,MH0].map((Z)=>Z($))}}),DH0={definitions:{schema:Zv(!1)},...Zv(!0)};Xv.default=DH0});var M3=S((Gv)=>{Object.defineProperty(Gv,"__esModule",{value:!0});Gv.jtdForms=void 0;Gv.jtdForms=["elements","values","discriminator","properties","optionalProperties","enum","type","ref"]});var Uv=S((Vv)=>{Object.defineProperty(Vv,"__esModule",{value:!0});var D3=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,LH0={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"};function Kv($){return D3.lastIndex=0,'"'+(D3.test($)?$.replace(D3,(Z)=>{let J=LH0[Z];return typeof J==="string"?J:"\\u"+("0000"+Z.charCodeAt(0).toString(16)).slice(-4)}):$)+'"'}Vv.default=Kv;Kv.code='require("ajv/dist/runtime/quote").default'});var qv=S((Ov)=>{Object.defineProperty(Ov,"__esModule",{value:!0});var RH0=M3(),Bv=Y7(),G1=k0(),PH0=YZ(),y1=g8(),IH0=S$(),CH0=HW(),EH0=J1(),bH0=Uv(),_H0={elements:fH0,values:kH0,discriminator:vH0,properties:Hv,optionalProperties:Hv,enum:OQ,type:yH0,ref:hH0};function zv($,Z){let J=Bv.getCompilingSchema.call(this,$);if(J)return J;let{es5:Y,lines:X}=this.opts.code,{ownProperties:Q}=this.opts,G=new G1.CodeGen(this.scope,{es5:Y,lines:X,ownProperties:Q}),W=G.scopeName("serialize"),K={self:this,gen:G,schema:$.schema,schemaEnv:$,definitions:Z,data:y1.default.data},V;try{this._compilations.add($),$.serializeName=W,G.func(W,y1.default.data,!1,()=>{G.let(y1.default.json,G1.str``),qQ(K),G.return(y1.default.json)}),G.optimize(this.opts.code.optimize);let U=G.toString();V=`${G.scopeRefs(y1.default.scope)}return ${U}`;let B=Function(`${y1.default.scope}`,V)(this.scope.get());this.scope.value(W,{ref:B}),$.serialize=B}catch(U){if(V)this.logger.error("Error compiling serializer, function code:",V);throw delete $.serialize,delete $.serializeName,U}finally{this._compilations.delete($)}return $}Ov.default=zv;function qQ($){let Z;for(let J of RH0.jtdForms)if(J in $.schema){Z=J;break}SH0($,Z?_H0[Z]:uH0)}function SH0($,Z){let{gen:J,schema:Y,data:X}=$;if(!Y.nullable)return Z($);J.if(G1._`${X} === undefined || ${X} === null`,()=>J.add(y1.default.json,G1._`"null"`),()=>Z($))}function fH0($){let{gen:Z,schema:J,data:Y}=$;Z.add(y1.default.json,G1.str`[`);let X=Z.let("first",!0);Z.forOf("el",Y,(Q)=>{w3($,X),qQ({...$,schema:J.elements,data:Q})}),Z.add(y1.default.json,G1.str`]`)}function kH0($){let{gen:Z,schema:J,data:Y}=$;Z.add(y1.default.json,G1.str`{`);let X=Z.let("first",!0);Z.forIn("key",Y,(Q)=>Fv($,Q,J.values,X)),Z.add(y1.default.json,G1.str`}`)}function Fv($,Z,J,Y){let{gen:X,data:Q}=$;w3($,Y),OQ({...$,data:Z}),X.add(y1.default.json,G1.str`:`);let G=X.const("value",G1._`${Q}${(0,G1.getProperty)(Z)}`);qQ({...$,schema:J,data:G})}function vH0($){let{gen:Z,schema:J,data:Y}=$,{discriminator:X}=J;Z.add(y1.default.json,G1.str`{${JSON.stringify(X)}:`);let Q=Z.const("tag",G1._`${Y}${(0,G1.getProperty)(X)}`);OQ({...$,data:Q}),Z.if(!1);for(let G in J.mapping){Z.elseIf(G1._`${Q} === ${G}`);let W=J.mapping[G];Av({...$,schema:W},X)}Z.endIf(),Z.add(y1.default.json,G1.str`}`)}function Hv($){let{gen:Z}=$;Z.add(y1.default.json,G1.str`{`),Av($),Z.add(y1.default.json,G1.str`}`)}function Av($,Z){let{gen:J,schema:Y,data:X}=$,{properties:Q,optionalProperties:G}=Y,W=B(Q),K=B(G),V=z(W.concat(K)),U=!Z,H;for(let N of W){if(U)U=!1;else J.add(y1.default.json,G1.str`,`);A(N,Q[N],F(N))}if(U)H=J.let("first",!0);for(let N of K){let L=F(N);J.if((0,G1.and)(G1._`${L} !== undefined`,(0,IH0.isOwnProperty)(J,X,N)),()=>{w3($,H),A(N,G[N],L)})}if(Y.additionalProperties)J.forIn("key",X,(N)=>J.if(j(N,V),()=>Fv($,N,{},H)));function B(N){return N?Object.keys(N):[]}function z(N){if(Z)N.push(Z);if(new Set(N).size!==N.length)throw Error("JTD: properties/optionalProperties/disciminator overlap");return N}function F(N){return J.const("value",G1._`${X}${(0,G1.getProperty)(N)}`)}function A(N,L,q){J.add(y1.default.json,G1.str`${JSON.stringify(N)}:`),qQ({...$,schema:L,data:q})}function j(N,L){return L.length?(0,G1.and)(...L.map((q)=>G1._`${N} !== ${q}`)):!0}}function yH0($){let{gen:Z,schema:J,data:Y}=$;switch(J.type){case"boolean":Z.add(y1.default.json,G1._`${Y} ? "true" : "false"`);break;case"string":OQ($);break;case"timestamp":Z.if(G1._`${Y} instanceof Date`,()=>Z.add(y1.default.json,G1._`'"' + ${Y}.toISOString() + '"'`),()=>OQ($));break;default:xH0($)}}function OQ({gen:$,data:Z}){$.add(y1.default.json,G1._`${(0,EH0.useFunc)($,bH0.default)}(${Z})`)}function xH0({gen:$,data:Z,self:J}){let Y=G1._`${Z} === Infinity || ${Z} === -Infinity || ${Z} !== ${Z}`;if(J.opts.specialNumbers===void 0||J.opts.specialNumbers==="fast")$.add(y1.default.json,G1._`"" + ${Z}`);else $.if(Y,()=>$.add(y1.default.json,G1._`null`),()=>$.add(y1.default.json,G1._`"" + ${Z}`))}function hH0($){let{gen:Z,self:J,data:Y,definitions:X,schema:Q,schemaEnv:G}=$,{ref:W}=Q,K=X[W];if(!K)throw new PH0.default(J.opts.uriResolver,"",W,`No definition ${W}`);if(!(0,CH0.hasRef)(K))return qQ({...$,schema:K});let{root:V}=G,U=zv.call(J,new Bv.SchemaEnv({schema:K,root:V}),X);Z.add(y1.default.json,G1._`${gH0(Z,U)}(${Y})`)}function gH0($,Z){return Z.serialize?$.scopeValue("serialize",{ref:Z.serialize}):G1._`${$.scopeValue("wrapper",{ref:Z})}.serialize`}function uH0({gen:$,data:Z}){$.add(y1.default.json,G1._`JSON.stringify(${Z})`)}function w3({gen:$},Z){if(Z)$.if(Z,()=>$.assign(Z,!1),()=>$.add(y1.default.json,G1.str`,`));else $.add(y1.default.json,G1.str`,`)}});var Dv=S((Nv)=>{Object.defineProperty(Nv,"__esModule",{value:!0});Nv.parseJsonString=Nv.parseJsonNumber=Nv.parseJson=void 0;var lH0=/position\s(\d+)(?: \(line \d+ column \d+\))?$/;function KZ($,Z){let J;KZ.message=void 0;let Y;if(Z)$=$.slice(Z);try{return KZ.position=Z+$.length,JSON.parse($)}catch(X){if(Y=lH0.exec(X.message),!Y){KZ.message="unexpected end";return}J=+Y[1];let Q=$[J];$=$.slice(0,J),KZ.position=Z+J;try{return JSON.parse($)}catch(G){KZ.message=`unexpected token ${Q}`;return}}}Nv.parseJson=KZ;KZ.message=void 0;KZ.position=0;KZ.code='require("ajv/dist/runtime/parseJson").parseJson';function VZ($,Z,J){let Y="",X;if(VZ.message=void 0,$[Z]==="-")Y+="-",Z++;if($[Z]==="0")Y+="0",Z++;else if(!Q(J)){G();return}if(J)return VZ.position=Z,+Y;if($[Z]==="."){if(Y+=".",Z++,!Q()){G();return}}if(X=$[Z],X==="e"||X==="E"){if(Y+="e",Z++,X=$[Z],X==="+"||X==="-")Y+=X,Z++;if(!Q()){G();return}}return VZ.position=Z,+Y;function Q(W){let K=!1;while(X=$[Z],X>="0"&&X<="9"&&(W===void 0||W-- >0))K=!0,Y+=X,Z++;return K}function G(){VZ.position=Z,VZ.message=Z<$.length?`unexpected token ${$[Z]}`:"unexpected end"}}Nv.parseJsonNumber=VZ;VZ.message=void 0;VZ.position=0;VZ.code='require("ajv/dist/runtime/parseJson").parseJsonNumber';var jv={b:"\b",f:"\f",n:`
119
- `,r:"\r",t:"\t",'"':'"',"/":"/","\\":"\\"},dH0=97,pH0=48;function tZ($,Z){let J="",Y;tZ.message=void 0;while(!0){if(Y=$[Z++],Y==='"')break;if(Y==="\\")if(Y=$[Z],Y in jv)J+=jv[Y],Z++;else if(Y==="u"){Z++;let Q=4,G=0;while(Q--){if(G<<=4,Y=$[Z],Y===void 0){X("unexpected end");return}if(Y=Y.toLowerCase(),Y>="a"&&Y<="f")G+=Y.charCodeAt(0)-dH0+10;else if(Y>="0"&&Y<="9")G+=Y.charCodeAt(0)-pH0;else{X(`unexpected token ${Y}`);return}Z++}J+=String.fromCharCode(G)}else{X(`unexpected token ${Y}`);return}else if(Y===void 0){X("unexpected end");return}else if(Y.charCodeAt(0)>=32)J+=Y;else{X(`unexpected token ${Y}`);return}}return tZ.position=Z,J;function X(Q){tZ.position=Z,tZ.message=Q}}Nv.parseJsonString=tZ;tZ.message=void 0;tZ.position=0;tZ.code='require("ajv/dist/runtime/parseJson").parseJsonString'});var fv=S((Sv)=>{Object.defineProperty(Sv,"__esModule",{value:!0});var nH0=M3(),Rv=Y7(),R0=k0(),oH0=YZ(),V1=g8(),sH0=S$(),rH0=HW(),aH0=q3(),R3=Dv(),Pv=J1(),tH0=A3(),eH0={elements:YB0,values:XB0,discriminator:GB0,properties:wv,optionalProperties:wv,enum:KB0,type:WB0,ref:VB0};function Iv($,Z){let J=Rv.getCompilingSchema.call(this,$);if(J)return J;let{es5:Y,lines:X}=this.opts.code,{ownProperties:Q}=this.opts,G=new R0.CodeGen(this.scope,{es5:Y,lines:X,ownProperties:Q}),W=G.scopeName("parse"),K={self:this,gen:G,schema:$.schema,schemaEnv:$,definitions:Z,data:V1.default.data,parseName:W,char:G.name("c")},V;try{this._compilations.add($),$.parseName=W,$B0(K),G.optimize(this.opts.code.optimize);let U=G.toString();V=`${G.scopeRefs(V1.default.scope)}return ${U}`;let B=Function(`${V1.default.scope}`,V)(this.scope.get());this.scope.value(W,{ref:B}),$.parse=B}catch(U){if(V)this.logger.error("Error compiling parser, function code:",V);throw delete $.parse,delete $.parseName,U}finally{this._compilations.delete($)}return $}Sv.default=Iv;var T3=R0._`undefined`;function $B0($){let{gen:Z,parseName:J,char:Y}=$;Z.func(J,R0._`${V1.default.json}, ${V1.default.jsonPos}, ${V1.default.jsonPart}`,!1,()=>{Z.let(V1.default.data),Z.let(Y),Z.assign(R0._`${J}.message`,T3),Z.assign(R0._`${J}.position`,T3),Z.assign(V1.default.jsonPos,R0._`${V1.default.jsonPos} || 0`),Z.const(V1.default.jsonLen,R0._`${V1.default.json}.length`),AW($),E3($),Z.if(V1.default.jsonPart,()=>{Z.assign(R0._`${J}.position`,V1.default.jsonPos),Z.return(V1.default.data)}),Z.if(R0._`${V1.default.jsonPos} === ${V1.default.jsonLen}`,()=>Z.return(V1.default.data)),tJ($)})}function AW($){let Z;for(let J of nH0.jtdForms)if(J in $.schema){Z=J;break}if(Z)JB0($,eH0[Z]);else I3($)}var ZB0=Tv(!0,Tv(!1,tJ));function JB0($,Z){let{gen:J,schema:Y,data:X}=$;if(!Y.nullable)return Z($);jQ($,"null",Z,()=>J.assign(X,null))}function YB0($){let{gen:Z,schema:J,data:Y}=$;C6($,"[");let X=Z.let("i",0);Z.assign(Y,R0._`[]`),P3($,"]",()=>{let Q=Z.let("el");AW({...$,schema:J.elements,data:Q}),Z.assign(R0._`${Y}[${X}++]`,Q)})}function XB0($){let{gen:Z,schema:J,data:Y}=$;C6($,"{"),Z.assign(Y,R0._`{}`),P3($,"}",()=>QB0($,J.values))}function P3($,Z,J){Cv($,Z,J),C6($,Z)}function Cv($,Z,J){let{gen:Y}=$;Y.for(R0._`;${V1.default.jsonPos}<${V1.default.jsonLen} && ${OW(1)}!==${Z};`,()=>{J(),jQ($,",",()=>Y.break(),X)});function X(){jQ($,Z,()=>{},tJ)}}function QB0($,Z){let{gen:J}=$,Y=J.let("key");K7({...$,data:Y}),C6($,":"),bv($,Y,Z)}function GB0($){let{gen:Z,data:J,schema:Y}=$,{discriminator:X,mapping:Q}=Y;C6($,"{"),Z.assign(J,R0._`{}`);let G=Z.const("pos",V1.default.jsonPos),W=Z.let("value"),K=Z.let("tag");Cv($,"}",()=>{let V=Z.let("key");K7({...$,data:V}),C6($,":"),Z.if(R0._`${V} === ${X}`,()=>{K7({...$,data:K}),Z.assign(R0._`${J}[${V}]`,K),Z.break()},()=>I3({...$,data:W}))}),Z.assign(V1.default.jsonPos,G),Z.if(R0._`${K} === undefined`),UZ($,R0.str`discriminator tag not found`);for(let V in Q)Z.elseIf(R0._`${K} === ${V}`),Ev({...$,schema:Q[V]},X);Z.else(),UZ($,R0.str`discriminator value not in schema`),Z.endIf()}function wv($){let{gen:Z,data:J}=$;C6($,"{"),Z.assign(J,R0._`{}`),Ev($)}function Ev($,Z){let{gen:J,schema:Y,data:X}=$,{properties:Q,optionalProperties:G,additionalProperties:W}=Y;if(P3($,"}",()=>{let K=J.let("key");if(K7({...$,data:K}),C6($,":"),J.if(!1),Lv($,K,Q),Lv($,K,G),Z){J.elseIf(R0._`${K} === ${Z}`);let V=J.let("tag");K7({...$,data:V})}if(J.else(),W)I3({...$,data:R0._`${X}[${K}]`});else UZ($,R0.str`property ${K} not allowed`);J.endIf()}),Q){let K=(0,sH0.hasPropFunc)(J),V=(0,R0.and)(...Object.keys(Q).map((U)=>R0._`${K}.call(${X}, ${U})`));J.if((0,R0.not)(V),()=>UZ($,R0.str`missing required properties`))}}function Lv($,Z,J={}){let{gen:Y}=$;for(let X in J)Y.elseIf(R0._`${Z} === ${X}`),bv($,Z,J[X])}function bv($,Z,J){AW({...$,schema:J,data:R0._`${$.data}[${Z}]`})}function WB0($){let{gen:Z,schema:J,data:Y,self:X}=$;switch(J.type){case"boolean":ZB0($);break;case"string":K7($);break;case"timestamp":{K7($);let Q=(0,Pv.useFunc)(Z,tH0.default),{allowDate:G,parseDate:W}=X.opts,K=G?R0._`!${Q}(${Y}, true)`:R0._`!${Q}(${Y})`,V=W?(0,R0.or)(K,R0._`(${Y} = new Date(${Y}), false)`,R0._`isNaN(${Y}.valueOf())`):K;Z.if(V,()=>UZ($,R0.str`invalid timestamp`));break}case"float32":case"float64":L3($);break;default:{let Q=J.type;if(!X.opts.int32range&&(Q==="int32"||Q==="uint32")){if(L3($,16),Q==="uint32")Z.if(R0._`${Y} < 0`,()=>UZ($,R0.str`integer out of range`))}else{let[G,W,K]=aH0.intRange[Q];L3($,K),Z.if(R0._`${Y} < ${G} || ${Y} > ${W}`,()=>UZ($,R0.str`integer out of range`))}}}}function K7($){C6($,'"'),C3($,R3.parseJsonString)}function KB0($){let{gen:Z,data:J,schema:Y}=$,X=Y.enum;C6($,'"'),Z.if(!1);for(let Q of X){let G=JSON.stringify(Q).slice(1);Z.elseIf(R0._`${OW(G.length)} === ${G}`),Z.assign(J,R0.str`${Q}`),Z.add(V1.default.jsonPos,G.length)}Z.else(),tJ($),Z.endIf()}function L3($,Z){let{gen:J}=$;E3($),J.if(R0._`"-0123456789".indexOf(${OW(1)}) < 0`,()=>tJ($),()=>C3($,R3.parseJsonNumber,Z))}function Tv($,Z){return(J)=>{let{gen:Y,data:X}=J;jQ(J,`${$}`,()=>Z(J),()=>Y.assign(X,$))}}function VB0($){let{gen:Z,self:J,definitions:Y,schema:X,schemaEnv:Q}=$,{ref:G}=X,W=Y[G];if(!W)throw new oH0.default(J.opts.uriResolver,"",G,`No definition ${G}`);if(!(0,rH0.hasRef)(W))return AW({...$,schema:W});let{root:K}=Q,V=Iv.call(J,new Rv.SchemaEnv({schema:W,root:K}),Y);_v($,UB0(Z,V),!0)}function UB0($,Z){return Z.parse?$.scopeValue("parse",{ref:Z.parse}):R0._`${$.scopeValue("wrapper",{ref:Z})}.parse`}function I3($){C3($,R3.parseJson)}function C3($,Z,J){_v($,(0,Pv.useFunc)($.gen,Z),J)}function _v($,Z,J){let{gen:Y,data:X}=$;Y.assign(X,R0._`${Z}(${V1.default.json}, ${V1.default.jsonPos}${J?R0._`, ${J}`:R0.nil})`),Y.assign(V1.default.jsonPos,R0._`${Z}.position`),Y.if(R0._`${X} === undefined`,()=>UZ($,R0._`${Z}.message`))}function C6($,Z){jQ($,Z,tJ)}function jQ($,Z,J,Y){let{gen:X}=$,Q=Z.length;E3($),X.if(R0._`${OW(Q)} === ${Z}`,()=>{X.add(V1.default.jsonPos,Q),Y===null||Y===void 0||Y($)},()=>J($))}function E3({gen:$,char:Z}){$.code(R0._`while((${Z}=${V1.default.json}[${V1.default.jsonPos}],${Z}===" "||${Z}==="\\n"||${Z}==="\\r"||${Z}==="\\t"))${V1.default.jsonPos}++;`)}function OW($){return $===1?R0._`${V1.default.json}[${V1.default.jsonPos}]`:R0._`${V1.default.json}.slice(${V1.default.jsonPos}, ${V1.default.jsonPos}+${$})`}function tJ($){UZ($,R0._`"unexpected token " + ${V1.default.json}[${V1.default.jsonPos}]`)}function UZ({gen:$,parseName:Z},J){$.assign(R0._`${Z}.message`,J),$.assign(R0._`${Z}.position`,V1.default.jsonPos),$.return(T3)}});var S3=S((B8,_3)=>{Object.defineProperty(B8,"__esModule",{value:!0});B8.MissingRefError=B8.ValidationError=B8.CodeGen=B8.Name=B8.nil=B8.stringify=B8.str=B8._=B8.KeywordCxt=B8.Ajv=void 0;var BB0=Z3(),zB0=$v(),FB0=Qv(),AB0=qv(),OB0=fv(),b3="JTD-meta-schema";class NQ extends BB0.default{constructor($={}){super({...$,jtd:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(zB0.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;this.addMetaSchema(FB0.default,b3,!1)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(b3)?b3:void 0)}compileSerializer($){let Z=this._addSchema($);return Z.serialize||this._compileSerializer(Z)}compileParser($){let Z=this._addSchema($);return Z.parse||this._compileParser(Z)}_compileSerializer($){if(AB0.default.call(this,$,$.schema.definitions||{}),!$.serialize)throw Error("ajv implementation error");return $.serialize}_compileParser($){if(OB0.default.call(this,$,$.schema.definitions||{}),!$.parse)throw Error("ajv implementation error");return $.parse}}B8.Ajv=NQ;_3.exports=B8=NQ;_3.exports.Ajv=NQ;Object.defineProperty(B8,"__esModule",{value:!0});B8.default=NQ;var qB0=lJ();Object.defineProperty(B8,"KeywordCxt",{enumerable:!0,get:function(){return qB0.KeywordCxt}});var eJ=k0();Object.defineProperty(B8,"_",{enumerable:!0,get:function(){return eJ._}});Object.defineProperty(B8,"str",{enumerable:!0,get:function(){return eJ.str}});Object.defineProperty(B8,"stringify",{enumerable:!0,get:function(){return eJ.stringify}});Object.defineProperty(B8,"nil",{enumerable:!0,get:function(){return eJ.nil}});Object.defineProperty(B8,"Name",{enumerable:!0,get:function(){return eJ.Name}});Object.defineProperty(B8,"CodeGen",{enumerable:!0,get:function(){return eJ.CodeGen}});var jB0=ZQ();Object.defineProperty(B8,"ValidationError",{enumerable:!0,get:function(){return jB0.default}});var NB0=YZ();Object.defineProperty(B8,"MissingRefError",{enumerable:!0,get:function(){return NB0.default}})});var f3=S((cy0,kv)=>{var wB0=sG();kv.exports=Object.freeze({coerceTypes:"array",useDefaults:!0,removeAdditional:!0,uriResolver:wB0,addUsedSchema:!1,allErrors:!1})});var qW=S((lv)=>{Object.defineProperty(lv,"__esModule",{value:!0});lv.formatNames=lv.fastFormats=lv.fullFormats=void 0;function E6($,Z){return{validate:$,compare:Z}}lv.fullFormats={date:E6(hv,x3),time:E6(v3(!0),h3),"date-time":E6(vv(!0),uv),"iso-time":E6(v3(),gv),"iso-date-time":E6(vv(),mv),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:CB0,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:vB0,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:EB0,int32:{type:"number",validate:SB0},int64:{type:"number",validate:fB0},float:{type:"number",validate:xv},double:{type:"number",validate:xv},password:!0,binary:!0};lv.fastFormats={...lv.fullFormats,date:E6(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,x3),time:E6(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,h3),"date-time":E6(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uv),"iso-time":E6(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,gv),"iso-date-time":E6(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,mv),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};lv.formatNames=Object.keys(lv.fullFormats);function LB0($){return $%4===0&&($%100!==0||$%400===0)}var TB0=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,RB0=[0,31,28,31,30,31,30,31,31,30,31,30,31];function hv($){let Z=TB0.exec($);if(!Z)return!1;let J=+Z[1],Y=+Z[2],X=+Z[3];return Y>=1&&Y<=12&&X>=1&&X<=(Y===2&&LB0(J)?29:RB0[Y])}function x3($,Z){if(!($&&Z))return;if($>Z)return 1;if($<Z)return-1;return 0}var k3=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function v3($){return function(J){let Y=k3.exec(J);if(!Y)return!1;let X=+Y[1],Q=+Y[2],G=+Y[3],W=Y[4],K=Y[5]==="-"?-1:1,V=+(Y[6]||0),U=+(Y[7]||0);if(V>23||U>59||$&&!W)return!1;if(X<=23&&Q<=59&&G<60)return!0;let H=Q-U*K,B=X-V*K-(H<0?1:0);return(B===23||B===-1)&&(H===59||H===-1)&&G<61}}function h3($,Z){if(!($&&Z))return;let J=new Date("2020-01-01T"+$).valueOf(),Y=new Date("2020-01-01T"+Z).valueOf();if(!(J&&Y))return;return J-Y}function gv($,Z){if(!($&&Z))return;let J=k3.exec($),Y=k3.exec(Z);if(!(J&&Y))return;if($=J[1]+J[2]+J[3],Z=Y[1]+Y[2]+Y[3],$>Z)return 1;if($<Z)return-1;return 0}var y3=/t|\s/i;function vv($){let Z=v3($);return function(Y){let X=Y.split(y3);return X.length===2&&hv(X[0])&&Z(X[1])}}function uv($,Z){if(!($&&Z))return;let J=new Date($).valueOf(),Y=new Date(Z).valueOf();if(!(J&&Y))return;return J-Y}function mv($,Z){if(!($&&Z))return;let[J,Y]=$.split(y3),[X,Q]=Z.split(y3),G=x3(J,X);if(G===void 0)return;return G||h3(Y,Q)}var PB0=/\/|:/,IB0=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function CB0($){return PB0.test($)&&IB0.test($)}var yv=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function EB0($){return yv.lastIndex=0,yv.test($)}var bB0=-2147483648,_B0=2147483647;function SB0($){return Number.isInteger($)&&$<=_B0&&$>=bB0}function fB0($){return Number.isInteger($)}function xv(){return!0}var kB0=/[^\\]\\Z/;function vB0($){if(kB0.test($))return!1;try{return new RegExp($),!0}catch(Z){return!1}}});var cv=S((pv)=>{Object.defineProperty(pv,"__esModule",{value:!0});pv.formatLimitDefinition=void 0;var xB0=UW(),G6=k0(),eZ=G6.operators,jW={formatMaximum:{okStr:"<=",ok:eZ.LTE,fail:eZ.GT},formatMinimum:{okStr:">=",ok:eZ.GTE,fail:eZ.LT},formatExclusiveMaximum:{okStr:"<",ok:eZ.LT,fail:eZ.GTE},formatExclusiveMinimum:{okStr:">",ok:eZ.GT,fail:eZ.LTE}},hB0={message:({keyword:$,schemaCode:Z})=>G6.str`should be ${jW[$].okStr} ${Z}`,params:({keyword:$,schemaCode:Z})=>G6._`{comparison: ${jW[$].okStr}, limit: ${Z}}`};pv.formatLimitDefinition={keyword:Object.keys(jW),type:"string",schemaType:"string",$data:!0,error:hB0,code($){let{gen:Z,data:J,schemaCode:Y,keyword:X,it:Q}=$,{opts:G,self:W}=Q;if(!G.validateFormats)return;let K=new xB0.KeywordCxt(Q,W.RULES.all.format.definition,"format");if(K.$data)V();else U();function V(){let B=Z.scopeValue("formats",{ref:W.formats,code:G.code.formats}),z=Z.const("fmt",G6._`${B}[${K.schemaCode}]`);$.fail$data((0,G6.or)(G6._`typeof ${z} != "object"`,G6._`${z} instanceof RegExp`,G6._`typeof ${z}.compare != "function"`,H(z)))}function U(){let B=K.schema,z=W.formats[B];if(!z||z===!0)return;if(typeof z!="object"||z instanceof RegExp||typeof z.compare!="function")throw Error(`"${X}": format "${B}" does not define "compare" function`);let F=Z.scopeValue("formats",{key:B,ref:z,code:G.code.formats?G6._`${G.code.formats}${(0,G6.getProperty)(B)}`:void 0});$.fail$data(H(F))}function H(B){return G6._`${B}.compare(${J}, ${Y}) ${jW[X].fail} 0`}},dependencies:["format"]};var gB0=($)=>{return $.addKeyword(pv.formatLimitDefinition),$};pv.default=gB0});var d3=S((MQ,ov)=>{Object.defineProperty(MQ,"__esModule",{value:!0});var $Y=qW(),mB0=cv(),m3=k0(),iv=new m3.Name("fullFormats"),lB0=new m3.Name("fastFormats"),l3=($,Z={keywords:!0})=>{if(Array.isArray(Z))return nv($,Z,$Y.fullFormats,iv),$;let[J,Y]=Z.mode==="fast"?[$Y.fastFormats,lB0]:[$Y.fullFormats,iv],X=Z.formats||$Y.formatNames;if(nv($,X,J,Y),Z.keywords)(0,mB0.default)($);return $};l3.get=($,Z="full")=>{let Y=(Z==="fast"?$Y.fastFormats:$Y.fullFormats)[$];if(!Y)throw Error(`Unknown format "${$}"`);return Y};function nv($,Z,J,Y){var X,Q;(X=(Q=$.opts.code).formats)!==null&&X!==void 0||(Q.formats=m3._`require("ajv-formats/dist/formats").${Y}`);for(let G of Z)$.addFormat(G,J[G])}ov.exports=MQ=l3;Object.defineProperty(MQ,"__esModule",{value:!0});MQ.default=l3});var tv=S((oy0,av)=>{var dB0=UW().default,pB0=S3(),sv=f3();class rv{constructor($,Z){if(Z.mode==="JTD")this.ajv=new pB0(Object.assign({},sv,Z.customOptions));else this.ajv=new dB0(Object.assign({},sv,Z.customOptions));let J=!0;if(Z.plugins&&Z.plugins.length>0)for(let X of Z.plugins)if(Array.isArray(X))J=J&&X[0].name!=="formatsPlugin",X[0](this.ajv,X[1]);else J=J&&X.name!=="formatsPlugin",X(this.ajv);if(J)d3()(this.ajv);Z.onCreate?.(this.ajv);let Y=Object.values($);for(let X of Y)this.ajv.addSchema(X)}buildValidatorFunction({schema:$}){if($.$id){let Z=this.ajv.getSchema($.$id);if(Z)return Z}return this.ajv.compile($)}}av.exports=rv});var Zy=S((sy0,$y)=>{var cB0=S3(),iB0=f3();class ev{constructor($,Z){this.ajv=new cB0(Object.assign({},iB0,Z))}buildSerializerFunction({schema:$}){return this.ajv.compileSerializer($)}}$y.exports=ev});var Xy=S((wQ,Yy)=>{Object.defineProperty(wQ,"__esModule",{value:!0});var DQ=fG(),W6=yJ();function Jy($,Z){if(!$.opts.code.source)throw Error("moduleCode: ajv instance must have code.source option");let{_n:J}=$.scope.opts;return typeof Z=="function"?X(Z.source):Z!==void 0?Q(Z,Y):Q($.schemas,(W)=>W.meta?void 0:$.compile(W.schema));function Y(W){let K=$.getSchema(W);if(!K)throw Error(`moduleCode: no schema with id ${W}`);return K}function X(W){let K={},V=W===null||W===void 0?void 0:W.validateName,U=G(K,W);if($.opts.code.esm)return`"use strict";${J}export const validate = ${V};${J}export default ${V};${J}${U}`;return`"use strict";${J}module.exports = ${V};${J}module.exports.default = ${V};${J}${U}`}function Q(W,K){var V;let U={},H=W6._`"use strict";`;for(let B in W){let z=K(W[B]);if(z){let F=G(U,z.source),A=$.opts.code.esm?W6._`export const ${(0,W6.getEsmExportName)(B)}`:W6._`exports${(0,W6.getProperty)(B)}`;H=W6._`${H}${J}${A} = ${(V=z.source)===null||V===void 0?void 0:V.validateName};${J}${F}`}}return`${H}`}function G(W,K){if(!K)throw Error('moduleCode: function does not have "source" property');if(B(K.validateName)===DQ.UsedValueState.Completed)return W6.nil;z(K.validateName,DQ.UsedValueState.Started);let V=$.scope.scopeCode(K.scopeValues,W,H),U=new W6._Code(`${V}${J}${K.validateCode}`);return K.evaluated?W6._`${U}${K.validateName}.evaluated = ${K.evaluated};${J}`:U;function H(F){var A;let j=(A=F.value)===null||A===void 0?void 0:A.ref;if(F.prefix==="validate"&&typeof j=="function")return G(W,j.source);else if((F.prefix==="root"||F.prefix==="wrapper")&&typeof j=="object"){let{validate:N,validateName:L}=j;if(!L)throw Error("ajv internal error");let q=$.opts.code.es5?DQ.varKinds.var:DQ.varKinds.const,M=W6._`${q} ${F} = {validate: ${L}};`;if(B(L)===DQ.UsedValueState.Started)return M;let C=G(W,N===null||N===void 0?void 0:N.source);return W6._`${M}${J}${C}`}return}function B(F){var A;return(A=W[F.prefix])===null||A===void 0?void 0:A.get(F)}function z(F,A){let{prefix:j}=F;(W[j]=W[j]||new Map).set(F,A)}}}Yy.exports=wQ=Jy;Object.defineProperty(wQ,"__esModule",{value:!0});wQ.default=Jy});var Wy=S((ry0,Gy)=>{var Qy=p3(),nB0=Xy().default;function oB0($={readMode:!0}){if($.readMode===!0&&!$.restoreFunction)throw Error("You must provide a restoreFunction options when readMode ON");if($.readMode!==!0&&!$.storeFunction)throw Error("You must provide a storeFunction options when readMode OFF");if($.readMode===!0)return function(){return function(Y){return $.restoreFunction(Y)}};let Z=Qy();return function(Y,X={}){if(!X.customOptions||!X.customOptions.code)X.customOptions=Object.assign({},X.customOptions,{code:{source:!0}});let Q=Z(Y,X);return function(G){let W=Q(G),K=nB0(Q[Qy.AjvReference].ajv,W);return $.storeFunction(G,K),W}}}Gy.exports=oB0});var p3=S((ay0,ZY)=>{var Vy=Symbol.for("fastify.ajv-compiler.reference"),sB0=tv(),rB0=Zy();function c3($){let Z=new Map,J=new Map;if($&&$.jtdSerializer===!0)return function(X,Q){let G=Ky({},Q);if(J.has(G))return J.get(G);let W=new rB0(X,Q),K=W.buildSerializerFunction.bind(W);return J.set(G,K),K};return function(X,Q){let G=Ky(X,Q.customOptions);if(Z.has(G))return Z.get(G);let W=new sB0(X,Q),K=W.buildValidatorFunction.bind(W);if(Z.set(G,K),Q.customOptions.code!==void 0)K[Vy]=W;return K}}function Ky($,Z){let J=JSON.stringify($),Y=JSON.stringify(Z);return`${J}${Y}`}ZY.exports=c3;ZY.exports.default=c3;ZY.exports.AjvCompiler=c3;ZY.exports.AjvReference=Vy;ZY.exports.StandaloneValidator=Wy()});var NW=S((aB0)=>{var Uy=Object.prototype.hasOwnProperty;function Hy($,Z,J){for(J of $.keys())if(LQ(J,Z))return J}function LQ($,Z){var J,Y,X;if($===Z)return!0;if($&&Z&&(J=$.constructor)===Z.constructor){if(J===Date)return $.getTime()===Z.getTime();if(J===RegExp)return $.toString()===Z.toString();if(J===Array){if((Y=$.length)===Z.length)while(Y--&&LQ($[Y],Z[Y]));return Y===-1}if(J===Set){if($.size!==Z.size)return!1;for(Y of $){if(X=Y,X&&typeof X==="object"){if(X=Hy(Z,X),!X)return!1}if(!Z.has(X))return!1}return!0}if(J===Map){if($.size!==Z.size)return!1;for(Y of $){if(X=Y[0],X&&typeof X==="object"){if(X=Hy(Z,X),!X)return!1}if(!LQ(Y[1],Z.get(X)))return!1}return!0}if(J===ArrayBuffer)$=new Uint8Array($),Z=new Uint8Array(Z);else if(J===DataView){if((Y=$.byteLength)===Z.byteLength)while(Y--&&$.getInt8(Y)===Z.getInt8(Y));return Y===-1}if(ArrayBuffer.isView($)){if((Y=$.byteLength)===Z.byteLength)while(Y--&&$[Y]===Z[Y]);return Y===-1}if(!J||typeof $==="object"){Y=0;for(J in $){if(Uy.call($,J)&&++Y&&!Uy.call(Z,J))return!1;if(!(J in Z)||!LQ($[J],Z[J]))return!1}return Object.keys(Z).length===Y}}return $!==$&&Z!==Z}aB0.dequal=LQ});var Oy=S((ey0,Ay)=>{var{dequal:By}=NW(),eB0=Symbol.for("json-schema-ref");class Fy{#$;#Z;#J;#Y;#X;constructor($={}){this.#$={},this.#Z={},this.#J=$.insertRefSymbol??!1,this.#Y=$.allowEqualDuplicates??!0,this.#X=$.cloneSchemaWithoutRefs??!1}addSchema($,Z,J=!0){if(J)if($.$id!==void 0&&$.$id.charAt(0)!=="#")Z=$.$id;else this.#K($,Z);let Y=$.$id;if(Y!==void 0&&typeof Y==="string")if(Y.charAt(0)==="#")this.#U($,Z,Y);else this.#K($,Y),Z=Y;let X=$.$ref;if(X!==void 0&&typeof X==="string"){let{refSchemaId:Q,refJsonPointer:G}=this.#Q(X,Z);this.#$[Z].refs.push({schemaId:Q,jsonPointer:G})}for(let Q in $)if(typeof $[Q]==="object"&&$[Q]!==null)this.addSchema($[Q],Z,!1)}getSchema($,Z="#"){let J=this.#$[$];if(J===void 0)throw Error(`Cannot resolve ref "${$}${Z}". Schema with id "${$}" is not found.`);if(J.anchors[Z]!==void 0)return J.anchors[Z];return zy(J.schema,Z)}hasSchema($){return this.#$[$]!==void 0}getSchemaRefs($){let Z=this.#$[$];if(Z===void 0)throw Error(`Schema with id "${$}" is not found.`);return Z.refs}getSchemaDependencies($,Z={}){let J=this.#$[$];for(let Y of J.refs){let X=Y.schemaId;if(X===$||Z[X]!==void 0)continue;Z[X]=this.getSchema(X),this.getSchemaDependencies(X,Z)}return Z}derefSchema($){if(this.#Z[$]!==void 0)return;let Z=this.#$[$];if(Z===void 0)throw Error(`Schema with id "${$}" is not found.`);if(!this.#X&&Z.refs.length===0)this.#Z[$]={schema:Z.schema,anchors:Z.anchors};let J=[];this.#G(Z.schema,$,!0,J);let Y=this.getSchemaDependencies($);for(let X in Y){let Q=Y[X];this.#G(Q,X,!0,J)}for(let X of J){let{refSchemaId:Q,refJsonPointer:G}=this.#Q(X.ref,X.sourceSchemaId),W=this.getDerefSchema(Q,G);if(W===null)throw Error(`Cannot resolve ref "${X.ref}". Ref "${G}" is not found in schema "${Q}".`);X.targetSchema=W,X.targetSchemaId=Q}for(let X of J)this.#W(X,J)}getDerefSchema($,Z="#"){let J=this.#Z[$];if(J===void 0)this.derefSchema($),J=this.#Z[$];if(J.anchors[Z]!==void 0)return J.anchors[Z];return zy(J.schema,Z)}#Q($,Z){let J=$.indexOf("#");if(J===-1)return{refSchemaId:$,refJsonPointer:"#"};if(J===0)return{refSchemaId:Z,refJsonPointer:$};return{refSchemaId:$.slice(0,J),refJsonPointer:$.slice(J)}}#G($,Z,J,Y=[]){let X=Array.isArray($)?[...$]:{...$};if(J)if($.$id!==void 0&&$.$id.charAt(0)!=="#")Z=$.$id;else this.#V(X,Z);let Q=X.$id;if(Q!==void 0&&typeof Q==="string")if(Q.charAt(0)==="#")this.#H(X,Z,Q);else this.#V(X,Q),Z=Q;if(X.$ref!==void 0)Y.push({ref:X.$ref,sourceSchemaId:Z,sourceSchema:X});for(let G in X){let W=X[G];if(typeof W==="object"&&W!==null)X[G]=this.#G(W,Z,!1,Y)}return X}#W($,Z){let{sourceSchema:J,targetSchema:Y}=$;if(!J.$ref)return;if(this.#J)J[eB0]=J.$ref;if(delete J.$ref,Y.$ref){let X=Z.find((Q)=>Q.sourceSchema===Y);this.#W(X,Z)}for(let X in Y){if(X==="$id")continue;if(J[X]!==void 0){if(By(J[X],Y[X]))continue;throw Error(`Cannot resolve ref "${$.ref}". Property "${X}" already exists in schema "${$.sourceSchemaId}".`)}J[X]=Y[X]}$.isResolved=!0}#K($,Z){let J=this.#$[Z];if(J!==void 0){if(this.#Y&&By($,J.schema))return;throw Error(`There is already another schema with id "${Z}".`)}this.#$[Z]={schema:$,anchors:{},refs:[]}}#U($,Z,J){let{anchors:Y}=this.#$[Z];if(Y[J]!==void 0)throw Error(`There is already another anchor "${J}" in schema "${Z}".`);Y[J]=$}#V($,Z){if(this.#Z[Z]!==void 0)return;this.#Z[Z]={schema:$,anchors:{}}}#H($,Z,J){let{anchors:Y}=this.#Z[Z];Y[J]=$}}function zy($,Z){let J=Z.split("/"),Y=$;for(let X of J){if(X===""||X==="#")continue;if(typeof Y!=="object"||Y===null)return null;Y=Y[X]}return Y??null}Ay.exports={RefResolver:Fy}});var n3=S(($x0,qy)=>{var $z0=UW(),Zz0=sG(),Jz0=d3(),Yz0=WG()({proto:!0});class i3{constructor($){this.ajv=new $z0({...$,strictSchema:!1,validateSchema:!1,allowUnionTypes:!0,uriResolver:Zz0}),Jz0(this.ajv),this.ajv.addKeyword({keyword:"fjs_type",type:"object",errors:!1,validate:(Z,J)=>{return J&&typeof J.toJSON==="function"}}),this._ajvSchemas={},this._ajvOptions=$||{}}addSchema($,Z){let J=$.$id||Z;if($.$id!==void 0&&$.$id[0]==="#")J=Z+$.$id;if(this.ajv.refs[J]===void 0&&this.ajv.schemas[J]===void 0){let Y=Yz0($);this.convertSchemaToAjvFormat(Y),this.ajv.addSchema(Y,J),this._ajvSchemas[J]=$}}validate($,Z){return this.ajv.validate($,Z)}convertSchemaToAjvFormat($){if($===null)return;if($.type==="string")$.fjs_type="string",$.type=["string","object"];else if(Array.isArray($.type)&&$.type.includes("string")&&!$.type.includes("object"))$.fjs_type="string",$.type.push("object");for(let Z in $)if(typeof $[Z]==="object")this.convertSchemaToAjvFormat($[Z])}getState(){return{ajvOptions:this._ajvOptions,ajvSchemas:this._ajvSchemas}}static restoreFromState($){let Z=new i3($.ajvOptions);for(let[J,Y]of Object.entries($.ajvSchemas))Z.ajv.addSchema(Y,J);return Z}}qy.exports=i3});var Ny=S((Zx0,jy)=>{class o3{constructor($,Z,J="#"){this.schema=$,this.schemaId=Z,this.jsonPointer=J}getPropertyLocation($){return new o3(this.schema[$],this.schemaId,this.jsonPointer+"/"+$)}getSchemaRef(){return this.schemaId+this.jsonPointer}}jy.exports=o3});var Ty=S((Jx0,r3)=>{r3.exports=U0;r3.exports.default=U0;var Xz0={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0},My={enum:["array","boolean","integer","null","number","object","string"]},Dy=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Qz0=qW().fullFormats.uri,wy=qW().fullFormats.regex;function m8($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0,W=G;if(!(typeof $=="number"&&(!($%1)&&!isNaN($))&&isFinite($)))return m8.errors=[{instancePath:Z,schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===W){if(typeof $=="number"&&isFinite($)){if($<0||isNaN($))return m8.errors=[{instancePath:Z,schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}return m8.errors=Q,G===0}var s3={validate:U0};function e$($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0;if(G===0)if(Array.isArray($))if($.length<1)return e$.errors=[{instancePath:Z,schemaPath:"#/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;else{var W=!0;let K=$.length;for(let V=0;V<K;V++){let U=G;if(!s3.validate($[V],{instancePath:Z+"/"+V,parentData:$,parentDataProperty:V,rootData:X}))Q=Q===null?s3.validate.errors:Q.concat(s3.validate.errors),G=Q.length;var W=U===G;if(!W)break}}else return e$.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;return e$.errors=Q,G===0}var Ly=HQ().default;function U0($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0;if(!($&&typeof $=="object"&&!Array.isArray($))&&typeof $!=="boolean")return U0.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:Xz0.type},message:"must be object,boolean"}],!1;if(G===0){if($&&typeof $=="object"&&!Array.isArray($)){if($.$id!==void 0){let q=$.$id,M=G;if(G===M){if(G===M)if(typeof q==="string"){if(!Dy.test(q))return U0.errors=[{instancePath:Z+"/$id",schemaPath:"#/properties/%24id/format",keyword:"format",params:{format:"uri-reference"},message:'must match format "uri-reference"'}],!1}else return U0.errors=[{instancePath:Z+"/$id",schemaPath:"#/properties/%24id/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.$schema!==void 0){let q=$.$schema,M=G;if(G===M){if(G===M)if(typeof q==="string"){if(!Qz0(q))return U0.errors=[{instancePath:Z+"/$schema",schemaPath:"#/properties/%24schema/format",keyword:"format",params:{format:"uri"},message:'must match format "uri"'}],!1}else return U0.errors=[{instancePath:Z+"/$schema",schemaPath:"#/properties/%24schema/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.$ref!==void 0){let q=$.$ref,M=G;if(G===M){if(G===M)if(typeof q==="string"){if(!Dy.test(q))return U0.errors=[{instancePath:Z+"/$ref",schemaPath:"#/properties/%24ref/format",keyword:"format",params:{format:"uri-reference"},message:'must match format "uri-reference"'}],!1}else return U0.errors=[{instancePath:Z+"/$ref",schemaPath:"#/properties/%24ref/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.$comment!==void 0){let q=G;if(typeof $.$comment!=="string")return U0.errors=[{instancePath:Z+"/$comment",schemaPath:"#/properties/%24comment/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=q===G}else var W=!0;if(W){if($.title!==void 0){let q=G;if(typeof $.title!=="string")return U0.errors=[{instancePath:Z+"/title",schemaPath:"#/properties/title/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=q===G}else var W=!0;if(W){if($.description!==void 0){let q=G;if(typeof $.description!=="string")return U0.errors=[{instancePath:Z+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=q===G}else var W=!0;if(W){if($.readOnly!==void 0){let q=G;if(typeof $.readOnly!=="boolean")return U0.errors=[{instancePath:Z+"/readOnly",schemaPath:"#/properties/readOnly/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var W=q===G}else var W=!0;if(W){if($.examples!==void 0){let q=G;if(G===q){if(!Array.isArray($.examples))return U0.errors=[{instancePath:Z+"/examples",schemaPath:"#/properties/examples/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1}var W=q===G}else var W=!0;if(W){if($.multipleOf!==void 0){let q=$.multipleOf,M=G;if(G===M)if(typeof q=="number"&&isFinite(q)){if(q<=0||isNaN(q))return U0.errors=[{instancePath:Z+"/multipleOf",schemaPath:"#/properties/multipleOf/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"}],!1}else return U0.errors=[{instancePath:Z+"/multipleOf",schemaPath:"#/properties/multipleOf/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.maximum!==void 0){let q=$.maximum,M=G;if(!(typeof q=="number"&&isFinite(q)))return U0.errors=[{instancePath:Z+"/maximum",schemaPath:"#/properties/maximum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.exclusiveMaximum!==void 0){let q=$.exclusiveMaximum,M=G;if(!(typeof q=="number"&&isFinite(q)))return U0.errors=[{instancePath:Z+"/exclusiveMaximum",schemaPath:"#/properties/exclusiveMaximum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.minimum!==void 0){let q=$.minimum,M=G;if(!(typeof q=="number"&&isFinite(q)))return U0.errors=[{instancePath:Z+"/minimum",schemaPath:"#/properties/minimum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.exclusiveMinimum!==void 0){let q=$.exclusiveMinimum,M=G;if(!(typeof q=="number"&&isFinite(q)))return U0.errors=[{instancePath:Z+"/exclusiveMinimum",schemaPath:"#/properties/exclusiveMinimum/type",keyword:"type",params:{type:"number"},message:"must be number"}],!1;var W=M===G}else var W=!0;if(W){if($.maxLength!==void 0){let q=$.maxLength,M=G,C=G;if(!(typeof q=="number"&&(!(q%1)&&!isNaN(q))&&isFinite(q)))return U0.errors=[{instancePath:Z+"/maxLength",schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===C){if(typeof q=="number"&&isFinite(q)){if(q<0||isNaN(q))return U0.errors=[{instancePath:Z+"/maxLength",schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}var W=M===G}else var W=!0;if(W){if($.minLength!==void 0){let q=G;if(!m8($.minLength,{instancePath:Z+"/minLength",parentData:$,parentDataProperty:"minLength",rootData:X}))Q=Q===null?m8.errors:Q.concat(m8.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.pattern!==void 0){let q=$.pattern,M=G;if(G===M){if(G===M)if(typeof q==="string"){if(!wy(q))return U0.errors=[{instancePath:Z+"/pattern",schemaPath:"#/properties/pattern/format",keyword:"format",params:{format:"regex"},message:'must match format "regex"'}],!1}else return U0.errors=[{instancePath:Z+"/pattern",schemaPath:"#/properties/pattern/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1}var W=M===G}else var W=!0;if(W){if($.additionalItems!==void 0){let q=G;if(!U0($.additionalItems,{instancePath:Z+"/additionalItems",parentData:$,parentDataProperty:"additionalItems",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.items!==void 0){let q=$.items,M=G,C=G,R=!1,w=G;if(!U0(q,{instancePath:Z+"/items",parentData:$,parentDataProperty:"items",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var K=w===G;if(R=R||K,!R){let _=G;if(!e$(q,{instancePath:Z+"/items",parentData:$,parentDataProperty:"items",rootData:X}))Q=Q===null?e$.errors:Q.concat(e$.errors),G=Q.length;var K=_===G;R=R||K}if(!R){let _={instancePath:Z+"/items",schemaPath:"#/properties/items/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[_];else Q.push(_);return G++,U0.errors=Q,!1}else if(G=C,Q!==null)if(C)Q.length=C;else Q=null;var W=M===G}else var W=!0;if(W){if($.maxItems!==void 0){let q=$.maxItems,M=G,C=G;if(!(typeof q=="number"&&(!(q%1)&&!isNaN(q))&&isFinite(q)))return U0.errors=[{instancePath:Z+"/maxItems",schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===C){if(typeof q=="number"&&isFinite(q)){if(q<0||isNaN(q))return U0.errors=[{instancePath:Z+"/maxItems",schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}var W=M===G}else var W=!0;if(W){if($.minItems!==void 0){let q=G;if(!m8($.minItems,{instancePath:Z+"/minItems",parentData:$,parentDataProperty:"minItems",rootData:X}))Q=Q===null?m8.errors:Q.concat(m8.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.uniqueItems!==void 0){let q=G;if(typeof $.uniqueItems!=="boolean")return U0.errors=[{instancePath:Z+"/uniqueItems",schemaPath:"#/properties/uniqueItems/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;var W=q===G}else var W=!0;if(W){if($.contains!==void 0){let q=G;if(!U0($.contains,{instancePath:Z+"/contains",parentData:$,parentDataProperty:"contains",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.maxProperties!==void 0){let q=$.maxProperties,M=G,C=G;if(!(typeof q=="number"&&(!(q%1)&&!isNaN(q))&&isFinite(q)))return U0.errors=[{instancePath:Z+"/maxProperties",schemaPath:"#/definitions/nonNegativeInteger/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(G===C){if(typeof q=="number"&&isFinite(q)){if(q<0||isNaN(q))return U0.errors=[{instancePath:Z+"/maxProperties",schemaPath:"#/definitions/nonNegativeInteger/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"}],!1}}var W=M===G}else var W=!0;if(W){if($.minProperties!==void 0){let q=G;if(!m8($.minProperties,{instancePath:Z+"/minProperties",parentData:$,parentDataProperty:"minProperties",rootData:X}))Q=Q===null?m8.errors:Q.concat(m8.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.required!==void 0){let q=$.required,M=G;if(G===G)if(Array.isArray(q)){var V=!0;let w=q.length;for(let I=0;I<w;I++){let _=G;if(typeof q[I]!=="string")return U0.errors=[{instancePath:Z+"/required/"+I,schemaPath:"#/definitions/stringArray/items/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var V=_===G;if(!V)break}if(V){let I=q.length,_;if(I>1){let E={};for(;I--;){let f=q[I];if(typeof f!=="string")continue;if(typeof E[f]=="number"){return _=E[f],U0.errors=[{instancePath:Z+"/required",schemaPath:"#/definitions/stringArray/uniqueItems",keyword:"uniqueItems",params:{i:I,j:_},message:"must NOT have duplicate items (items ## "+_+" and "+I+" are identical)"}],!1;break}E[f]=I}}}}else return U0.errors=[{instancePath:Z+"/required",schemaPath:"#/definitions/stringArray/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var W=M===G}else var W=!0;if(W){if($.additionalProperties!==void 0){let q=G;if(!U0($.additionalProperties,{instancePath:Z+"/additionalProperties",parentData:$,parentDataProperty:"additionalProperties",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.definitions!==void 0){let q=$.definitions,M=G;if(G===M)if(q&&typeof q=="object"&&!Array.isArray(q))for(let R in q){let w=G;if(!U0(q[R],{instancePath:Z+"/definitions/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:q,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var U=w===G;if(!U)break}else return U0.errors=[{instancePath:Z+"/definitions",schemaPath:"#/properties/definitions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.properties!==void 0){let q=$.properties,M=G;if(G===M)if(q&&typeof q=="object"&&!Array.isArray(q))for(let R in q){let w=G;if(!U0(q[R],{instancePath:Z+"/properties/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:q,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var H=w===G;if(!H)break}else return U0.errors=[{instancePath:Z+"/properties",schemaPath:"#/properties/properties/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.patternProperties!==void 0){let q=$.patternProperties,M=G;if(G===M)if(q&&typeof q=="object"&&!Array.isArray(q)){for(let R in q){let w=G;if(G===w){if(typeof R==="string"){if(!wy(R)){let I={instancePath:Z+"/patternProperties",schemaPath:"#/properties/patternProperties/propertyNames/format",keyword:"format",params:{format:"regex"},message:'must match format "regex"',propertyName:R};if(Q===null)Q=[I];else Q.push(I);G++}}}var B=w===G;if(!B){let I={instancePath:Z+"/patternProperties",schemaPath:"#/properties/patternProperties/propertyNames",keyword:"propertyNames",params:{propertyName:R},message:"property name must be valid"};if(Q===null)Q=[I];else Q.push(I);return G++,U0.errors=Q,!1;break}}if(B)for(let R in q){let w=G;if(!U0(q[R],{instancePath:Z+"/patternProperties/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:q,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var z=w===G;if(!z)break}}else return U0.errors=[{instancePath:Z+"/patternProperties",schemaPath:"#/properties/patternProperties/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.dependencies!==void 0){let q=$.dependencies,M=G;if(G===M)if(q&&typeof q=="object"&&!Array.isArray(q))for(let R in q){let w=q[R],I=G,_=G,E=!1,f=G;if(!U0(w,{instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:q,parentDataProperty:R,rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var F=f===G;if(E=E||F,!E){let b=G;if(G===G)if(Array.isArray(w)){var A=!0;let g=w.length;for(let d=0;d<g;d++){let p=G;if(typeof w[d]!=="string"){let r={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+d,schemaPath:"#/definitions/stringArray/items/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[r];else Q.push(r);G++}var A=p===G;if(!A)break}if(A){let d=w.length,p;if(d>1){let t={};for(;d--;){let r=w[d];if(typeof r!=="string")continue;if(typeof t[r]=="number"){p=t[r];let G0={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/stringArray/uniqueItems",keyword:"uniqueItems",params:{i:d,j:p},message:"must NOT have duplicate items (items ## "+p+" and "+d+" are identical)"};if(Q===null)Q=[G0];else Q.push(G0);G++;break}t[r]=d}}}}else{let g={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/definitions/stringArray/type",keyword:"type",params:{type:"array"},message:"must be array"};if(Q===null)Q=[g];else Q.push(g);G++}var F=b===G;E=E||F}if(!E){let b={instancePath:Z+"/dependencies/"+R.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/dependencies/additionalProperties/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[b];else Q.push(b);return G++,U0.errors=Q,!1}else if(G=_,Q!==null)if(_)Q.length=_;else Q=null;var j=I===G;if(!j)break}else return U0.errors=[{instancePath:Z+"/dependencies",schemaPath:"#/properties/dependencies/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=M===G}else var W=!0;if(W){if($.propertyNames!==void 0){let q=G;if(!U0($.propertyNames,{instancePath:Z+"/propertyNames",parentData:$,parentDataProperty:"propertyNames",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.enum!==void 0){let q=$.enum,M=G;if(G===M)if(Array.isArray(q))if(q.length<1)return U0.errors=[{instancePath:Z+"/enum",schemaPath:"#/properties/enum/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"}],!1;else{let R=q.length,w;if(R>1)$:for(;R--;)for(w=R;w--;)if(Ly(q[R],q[w])){return U0.errors=[{instancePath:Z+"/enum",schemaPath:"#/properties/enum/uniqueItems",keyword:"uniqueItems",params:{i:R,j:w},message:"must NOT have duplicate items (items ## "+w+" and "+R+" are identical)"}],!1;break $}}else return U0.errors=[{instancePath:Z+"/enum",schemaPath:"#/properties/enum/type",keyword:"type",params:{type:"array"},message:"must be array"}],!1;var W=M===G}else var W=!0;if(W){if($.type!==void 0){let q=$.type,M=G,C=G,R=!1,w=G;if(!(q==="array"||q==="boolean"||q==="integer"||q==="null"||q==="number"||q==="object"||q==="string")){let _={instancePath:Z+"/type",schemaPath:"#/definitions/simpleTypes/enum",keyword:"enum",params:{allowedValues:My.enum},message:"must be equal to one of the allowed values"};if(Q===null)Q=[_];else Q.push(_);G++}var N=w===G;if(R=R||N,!R){let _=G;if(G===_)if(Array.isArray(q))if(q.length<1){let f={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};if(Q===null)Q=[f];else Q.push(f);G++}else{var L=!0;let f=q.length;for(let b=0;b<f;b++){let y=q[b],k=G;if(!(y==="array"||y==="boolean"||y==="integer"||y==="null"||y==="number"||y==="object"||y==="string")){let d={instancePath:Z+"/type/"+b,schemaPath:"#/definitions/simpleTypes/enum",keyword:"enum",params:{allowedValues:My.enum},message:"must be equal to one of the allowed values"};if(Q===null)Q=[d];else Q.push(d);G++}var L=k===G;if(!L)break}if(L){let b=q.length,y;if(b>1)$:for(;b--;)for(y=b;y--;)if(Ly(q[b],q[y])){let k={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf/1/uniqueItems",keyword:"uniqueItems",params:{i:b,j:y},message:"must NOT have duplicate items (items ## "+y+" and "+b+" are identical)"};if(Q===null)Q=[k];else Q.push(k);G++;break $}}}else{let f={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};if(Q===null)Q=[f];else Q.push(f);G++}var N=_===G;R=R||N}if(!R){let _={instancePath:Z+"/type",schemaPath:"#/properties/type/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[_];else Q.push(_);return G++,U0.errors=Q,!1}else if(G=C,Q!==null)if(C)Q.length=C;else Q=null;var W=M===G}else var W=!0;if(W){if($.format!==void 0){let q=G;if(typeof $.format!=="string")return U0.errors=[{instancePath:Z+"/format",schemaPath:"#/properties/format/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=q===G}else var W=!0;if(W){if($.contentMediaType!==void 0){let q=G;if(typeof $.contentMediaType!=="string")return U0.errors=[{instancePath:Z+"/contentMediaType",schemaPath:"#/properties/contentMediaType/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=q===G}else var W=!0;if(W){if($.contentEncoding!==void 0){let q=G;if(typeof $.contentEncoding!=="string")return U0.errors=[{instancePath:Z+"/contentEncoding",schemaPath:"#/properties/contentEncoding/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var W=q===G}else var W=!0;if(W){if($.if!==void 0){let q=G;if(!U0($.if,{instancePath:Z+"/if",parentData:$,parentDataProperty:"if",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.then!==void 0){let q=G;if(!U0($.then,{instancePath:Z+"/then",parentData:$,parentDataProperty:"then",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.else!==void 0){let q=G;if(!U0($.else,{instancePath:Z+"/else",parentData:$,parentDataProperty:"else",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.allOf!==void 0){let q=G;if(!e$($.allOf,{instancePath:Z+"/allOf",parentData:$,parentDataProperty:"allOf",rootData:X}))Q=Q===null?e$.errors:Q.concat(e$.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.anyOf!==void 0){let q=G;if(!e$($.anyOf,{instancePath:Z+"/anyOf",parentData:$,parentDataProperty:"anyOf",rootData:X}))Q=Q===null?e$.errors:Q.concat(e$.errors),G=Q.length;var W=q===G}else var W=!0;if(W){if($.oneOf!==void 0){let q=G;if(!e$($.oneOf,{instancePath:Z+"/oneOf",parentData:$,parentDataProperty:"oneOf",rootData:X}))Q=Q===null?e$.errors:Q.concat(e$.errors),G=Q.length;var W=q===G}else var W=!0;if(W)if($.not!==void 0){let q=G;if(!U0($.not,{instancePath:Z+"/not",parentData:$,parentDataProperty:"not",rootData:X}))Q=Q===null?U0.errors:Q.concat(U0.errors),G=Q.length;var W=q===G}else var W=!0}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}return U0.errors=Q,G===0}});var a3=S((Yx0,Cy)=>{class Ry extends Error{constructor($,Z){super();this.name="JsonSchemaMergeError",this.code="JSON_SCHEMA_MERGE_ERROR",this.message=`Failed to merge "${$}" keyword schemas.`,this.schemas=Z}}class Py extends Error{constructor($,Z){super();this.name="JsonSchemaMergeError",this.code="JSON_SCHEMA_MERGE_ERROR",this.message=`Resolver for "${$}" keyword not found.`,this.schemas=Z}}class Iy extends Error{constructor($){super();this.name="JsonSchemaMergeError",this.code="JSON_SCHEMA_MERGE_ERROR",this.message=`Invalid "onConflict" option: "${$}".`}}Cy.exports={MergeError:Ry,ResolverNotFoundError:Py,InvalidOnConflictOptionError:Iy}});var _y=S((Xx0,by)=>{var{dequal:Gz0}=NW(),{MergeError:t3}=a3();function Ey($){let Z=$[0];for(let J=1;J<$.length;J++)Z=Z.filter((Y)=>$[J].includes(Y));return Z}function Wz0($,Z,J){let Y=Ey(Z);if(Y.length===0)throw new t3($,Z);J[$]=Y}function Kz0($,Z,J){for(let X=0;X<Z.length;X++)if(!Array.isArray(Z[X]))Z[X]=[Z[X]];let Y=Ey(Z);if(Y.length===0)throw new t3($,Z);if(Y.length===1)J[$]=Y[0];else J[$]=Y}function Vz0($,Z,J){let Y=[];for(let X of Z)for(let Q of X)if(!Y.includes(Q))Y.push(Q);J[$]=Y}function Uz0($,Z,J){J[$]=Math.min(...Z)}function Hz0($,Z,J){J[$]=Math.max(...Z)}function Bz0($,Z,J){let Y=(W,K)=>!K?W:Y(K,W%K),X=(W,K)=>W*K/Y(W,K),Q=1;for(let W of Z)while(W*Q%1!==0)Q*=10;let G=Z[0]*Q;for(let W of Z)G=X(G,W*Q);J[$]=G/Q}function zz0($,Z,J){let Y=Z[0];for(let X=1;X<Z.length;X++)if(!Gz0(Z[X],Y))throw new t3($,Z);J[$]=Y}function Fz0(){}function Az0($,Z,J){for(let Y of Z)if(Y===!1){J[$]=!1;return}J[$]=!0}function Oz0($,Z,J){for(let Y of Z)if(Y===!0){J[$]=!0;return}J[$]=!1}by.exports={arraysIntersection:Wz0,hybridArraysIntersection:Kz0,arraysUnion:Vz0,minNumber:Uz0,maxNumber:Hz0,commonMultiple:Bz0,allEqual:zz0,booleanAnd:Az0,booleanOr:Oz0,skip:Fz0}});var xy=S((Qx0,yy)=>{var{dequal:qz0}=NW(),e1=_y(),wW=a3(),ky={$id:e1.skip,type:e1.hybridArraysIntersection,enum:e1.arraysIntersection,minLength:e1.maxNumber,maxLength:e1.minNumber,minimum:e1.maxNumber,maximum:e1.minNumber,multipleOf:e1.commonMultiple,exclusiveMinimum:e1.maxNumber,exclusiveMaximum:e1.minNumber,minItems:e1.maxNumber,maxItems:e1.minNumber,maxProperties:e1.minNumber,minProperties:e1.maxNumber,const:e1.allEqual,default:e1.allEqual,format:e1.allEqual,required:e1.arraysUnion,properties:Lz0,patternProperties:DW,additionalProperties:MW,items:Mz0,additionalItems:Dz0,definitions:DW,$defs:DW,nullable:e1.booleanAnd,oneOf:Sy,anyOf:Sy,allOf:e1.arraysUnion,not:MW,if:Tz0,then:e1.skip,else:e1.skip,dependencies:fy,dependentRequired:fy,dependentSchemas:DW,propertyNames:MW,uniqueItems:e1.booleanOr,contains:MW};function MW($,Z,J,Y,X){J[$]=K6(Z,X)}function jz0($){let Z=[[]];for(let J of $){let Y=[];for(let X of Z)for(let Q of J)Y.push([...X,Q]);Z=Y}return Z}function Sy($,Z,J,Y,X){if(Z.length===1){J[$]=Z[0];return}let Q=jz0(Z),G=[];for(let W of Q)try{let K=K6(W,X);if(K!==void 0)G.push(K)}catch(K){if(K instanceof wW.MergeError)continue;throw K}J[$]=G}function Nz0($,Z){let{items:J,additionalItems:Y}=$;if(Array.isArray(J)){if(Z<J.length)return J[Z];return Y}if(J!==void 0)return J;return Y}function Mz0($,Z,J,Y,X){let Q=0;for(let W of Z)if(Array.isArray(W))Q=Math.max(Q,W.length);if(Q===0){J[$]=K6(Z,X);return}let G=[];for(let W=0;W<Q;W++){let K=[];for(let V of Y){let U=Nz0(V,W);if(U!==void 0)K.push(U)}G[W]=K6(K,X)}J[$]=G}function Dz0($,Z,J,Y,X){let Q=!1;for(let W of Y)if(Array.isArray(W.items)){Q=!0;break}if(!Q){J[$]=K6(Z,X);return}let G=[];for(let W of Y){let K=W.additionalItems;if(K===void 0&&!Array.isArray(W.items))K=W.items;if(K!==void 0)G.push(K)}J[$]=K6(G,X)}function wz0($,Z){let{properties:J,patternProperties:Y,additionalProperties:X}=$;if(J?.[Z]!==void 0)return J[Z];for(let Q of Object.keys(Y??{}))if(new RegExp(Q).test(Z))return Y[Q];return X}function Lz0($,Z,J,Y,X){let Q={};for(let W of Y){let K=W.properties??{};for(let V of Object.keys(K)){if(Q[V]!==void 0)continue;let U=K[V];Q[V]=[U];for(let H of Y){if(W===H)continue;let B=wz0(H,V);if(B!==void 0)Q[V].push(B)}}}let G={};for(let W of Object.keys(Q)){let K=Q[W];G[W]=K6(K,X)}J[$]=G}function DW($,Z,J,Y,X){let Q={};for(let W of Z)for(let K of Object.keys(W)){if(Q[K]===void 0)Q[K]=[];Q[K].push(W[K])}let G={};for(let W of Object.keys(Q)){let K=Q[W],V=K6(K,X);G[W]=V}J[$]=G}function Tz0($,Z,J,Y,X){for(let Q=0;Q<Y.length;Q++){let G={if:Y[Q].if,then:Y[Q].then,else:Y[Q].else};if(G.if===void 0)continue;if(J.if===void 0){if(J.if=G.if,G.then!==void 0)J.then=G.then;if(G.else!==void 0)J.else=G.else;continue}if(J.then!==void 0)J.then=K6([J.then,G],X);if(J.else!==void 0)J.else=K6([J.else,G],X)}}function fy($,Z,J){let Y={};for(let X of Z)for(let Q of Object.keys(X)){if(Y[Q]===void 0)Y[Q]=[];let G=Y[Q];for(let W of X[Q])if(!G.includes(W))G.push(W)}J[$]=Y}function K6($,Z){if($.length===0)return{};if($.length===1)return $[0];let J={},Y={},X=!0;for(let Q of $){if(Q===!1)return!1;if(Q===!0)continue;X=!1;for(let G of Object.keys(Q)){if(Y[G]===void 0)Y[G]=[];Y[G].push(Q[G])}}if(X)return!0;for(let Q of Object.keys(Y)){let G=Y[Q];(Z.resolvers[Q]??Z.defaultResolver)(Q,G,J,$,Z)}return J}function vy($,Z,J,Y,X){let Q=X.onConflict??"throw";if(Z.length===1||Q==="first"){J[$]=Z[0];return}let G=!0;for(let W=1;W<Z.length;W++)if(!qz0(Z[W],Z[0])){G=!1;break}if(G){J[$]=Z[0];return}if(Q==="throw")throw new wW.ResolverNotFoundError($,Z);if(Q==="skip")return;throw new wW.InvalidOnConflictOptionError(Q)}function Rz0($,Z={}){if(Z.defaultResolver===void 0)Z.defaultResolver=vy;return Z.resolvers={...ky,...Z.resolvers},K6($,Z)}yy.exports={mergeSchemas:Rz0,keywordsResolvers:ky,defaultResolver:vy,...wW}});var gy=S((Gx0,hy)=>{var{mergeSchemas:Pz0}=xy();function Iz0($){return Pz0($,{onConflict:"skip"})}hy.exports=Iz0});var uy=S((Wx0,e3)=>{function Cz0($,Z,J,Y){let X="";if(Z.validatorSchemasIds.size>0)X+=`const Validator = require('fast-json-stringify/lib/validator')
120
- `,X+=`const validatorState = ${JSON.stringify(Y.getState())}
121
- `,X+=`const validator = Validator.restoreFromState(validatorState)
122
- `;else X+=`const validator = null
123
- `;let{schema:Q,...G}=J.getState();return`
124
- 'use strict'
125
-
126
- const Serializer = require('fast-json-stringify/lib/serializer')
127
- const serializerState = ${JSON.stringify(G)}
128
- const serializer = Serializer.restoreFromState(serializerState)
129
-
130
- ${X}
131
-
132
- module.exports = ${$.toString()}(validator, serializer)`}e3.exports=Cz0;e3.exports.dependencies={Serializer:VG(),Validator:n3()}});var sy=S((Kx0,JY)=>{var{RefResolver:Ez0}=Oy(),bz0=VG(),_z0=n3(),V7=Ny(),my=Ty(),Sz0=gy(),fz0=/'/g,TQ=20000,LW="default",kz0=`
133
- const {
134
- asString,
135
- asNumber,
136
- asBoolean,
137
- asDateTime,
138
- asDate,
139
- asTime,
140
- asUnsafeString
141
- } = serializer
142
-
143
- const asInteger = serializer.asInteger.bind(serializer)
144
-
145
- `,vz0=new Set(["floor","ceil","round","trunc"]),cy=new Set(["default","json-stringify"]),RQ=0;function $F($,Z){if(!my($)){if(Z)Z=`"${Z}" `;else Z="";let J=my.errors[0],Y=Error(`${Z}schema is invalid: data${J.instancePath} ${J.message}`);throw Y.errors=$F.errors,Y}}function HZ($,Z){let J=Z.schema.$ref,Y=J.indexOf("#");if(Y===-1)Y=J.length;let X=J.slice(0,Y)||Z.schemaId,Q=J.slice(Y)||"#",G=$.refResolver.getSchema(X,Q);if(G===null)throw Error(`Cannot find reference "${J}"`);let W=new V7(G,X,Q);if(G.$ref!==void 0)return HZ($,W);return W}function TW($,Z){let J=$.refResolver.getSchema(Z,"#");return new V7(J,Z,"#")}function ly($,Z){if($.$id&&$.$id.charAt(0)!=="#")return $.$id;return Z}function PQ($,Z){let J=Z.getSchemaRef()||"";if(J.startsWith($.rootSchemaId))J=J.replace($.rootSchemaId,"")||"#";return J}function JF($,Z){$F($),Z=Z||{};let J={functions:[],functionsCounter:0,functionsNamesBySchema:new Map,options:Z,refResolver:new Ez0,rootSchemaId:$.$id||`__fjs_root_${RQ++}`,validatorSchemasIds:new Set,mergedSchemasIds:new Map,recursiveSchemas:new Set,recursivePaths:new Set,buildingSet:new Set,uid:0},Y=ly($,J.rootSchemaId);if(!J.refResolver.hasSchema(Y))J.refResolver.addSchema($,J.rootSchemaId);if(Z.schema)for(let U in Z.schema){let H=Z.schema[U],B=ly(H,U);if(!J.refResolver.hasSchema(B))$F(H,U),J.refResolver.addSchema(H,U)}if(Z.rounding){if(!vz0.has(Z.rounding))throw Error(`Unsupported integer rounding method ${Z.rounding}`)}if(Z.largeArrayMechanism)if(cy.has(Z.largeArrayMechanism))LW=Z.largeArrayMechanism;else throw Error(`Unsupported large array mechanism ${Z.largeArrayMechanism}`);if(Z.largeArraySize){let U=typeof Z.largeArraySize,H;if(U==="string"&&Number.isFinite(H=Number.parseInt(Z.largeArraySize,10)))TQ=H;else if(U==="number"&&Number.isInteger(Z.largeArraySize))TQ=Z.largeArraySize;else if(U==="bigint")TQ=Number(Z.largeArraySize);else throw Error(`Unsupported large array size. Expected integer-like, got ${typeof Z.largeArraySize} with value ${Z.largeArraySize}`)}let X=new V7($,J.rootSchemaId);cz0(J,X);let Q=c$(J,X,"input"),G=`
146
- ${kz0}
147
- const JSON_STR_BEGIN_OBJECT = '{'
148
- const JSON_STR_END_OBJECT = '}'
149
- const JSON_STR_BEGIN_ARRAY = '['
150
- const JSON_STR_END_ARRAY = ']'
151
- const JSON_STR_COMMA = ','
152
- const JSON_STR_COLONS = ':'
153
- const JSON_STR_QUOTE = '"'
154
- const JSON_STR_EMPTY_OBJECT = JSON_STR_BEGIN_OBJECT + JSON_STR_END_OBJECT
155
- const JSON_STR_EMPTY_ARRAY = JSON_STR_BEGIN_ARRAY + JSON_STR_END_ARRAY
156
- const JSON_STR_EMPTY_STRING = JSON_STR_QUOTE + JSON_STR_QUOTE
157
- const JSON_STR_NULL = 'null'
158
- `;if(Q==="json += anonymous0(input)")G+=`
159
- ${J.functions.join(`
160
- `)}
161
- const main = anonymous0
162
- return main
163
- `;else G+=`
164
- function main (input) {
165
- let json = ''
166
- ${Q}
167
- return json
168
- }
169
- ${J.functions.join(`
170
- `)}
171
- return main
172
- `;let W=new bz0(Z),K=new _z0(Z.ajv);for(let U of J.validatorSchemasIds){let H=J.refResolver.getSchema(U);K.addSchema(H,U);let B=J.refResolver.getSchemaDependencies(U);for(let[z,F]of Object.entries(B))K.addSchema(F,z)}if(Z.debugMode)Z.mode="debug";if(Z.mode==="debug")return{validator:K,serializer:W,code:`validator
173
- serializer
174
- ${G}`,ajv:K.ajv};let V=Function("validator","serializer",G);if(Z.mode==="standalone")return uy()(V,J,W,K);return V(K,W)}var yz0=["properties","required","additionalProperties","patternProperties","maxProperties","minProperties","dependencies"],xz0=["items","additionalItems","maxItems","minItems","uniqueItems","contains"],hz0=["maxLength","minLength","pattern"],gz0=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum"];function uz0($){for(let Z of yz0)if(Z in $)return"object";for(let Z of xz0)if(Z in $)return"array";for(let Z of hz0)if(Z in $)return"string";for(let Z of gz0)if(Z in $)return"number";return $.type}function mz0($,Z,J,Y){let X=Z.schema,Q=Object.keys(X.properties||{}),G=`
175
- for (const key of Object.keys(${Y})) {
176
- if (
177
- ${Q.length>0?Q.map((H)=>`key === ${JSON.stringify(H)}`).join(" || ")+" ||":""}
178
- ${Y}[key] === undefined ||
179
- typeof ${Y}[key] === 'function' ||
180
- typeof ${Y}[key] === 'symbol'
181
- ) continue
182
- const value = ${Y}[key]
183
- `,W=Z.getPropertyLocation("patternProperties"),K=W.schema;if(K!==void 0)for(let H in K){let B=W.getPropertyLocation(H);G+=`
184
- if (/${H.replace(/\\*\//g,"\\/")}/.test(key)) {
185
- ${J}
186
- json += asString(key) + JSON_STR_COLONS
187
- ${c$($,B,"value")}
188
- continue
189
- }
190
- `}let U=Z.getPropertyLocation("additionalProperties").schema;if(U!==void 0)if(U===!0)G+=`
191
- ${J}
192
- json += asString(key) + JSON_STR_COLONS + JSON.stringify(value)
193
- `;else{let H=Z.getPropertyLocation("additionalProperties");G+=`
194
- ${J}
195
- json += asString(key) + JSON_STR_COLONS
196
- ${c$($,H,"value")}
197
- `}return G+=`
198
- }
199
- `,G}function dy($,Z,J){let Y=Z.schema,X=Z.getPropertyLocation("properties"),Q=Y.required||[],G=Object.keys(Y.properties||{}).sort((U,H)=>{let B=Q.includes(U),z=Q.includes(H);return B===z?0:B?-1:1}),W="";for(let U of Q)if(!G.includes(U)){let H=JSON.stringify(U);W+=`if (${J}[${H}] === undefined) throw new Error('${H.replace(/'/g,"\\'")} is required!')
200
- `}W+=`json += JSON_STR_BEGIN_OBJECT
201
- `;let K=$.uid++,V="";if(Q.length>0){for(let U=0;U<G.length;U++){let H=G[U],B=X.getPropertyLocation(H),z=B;if(B.schema.$ref)z=HZ($,B);let F=JSON.stringify(H),A=`value_${H.replace(/[^a-zA-Z0-9]/g,"_")}_${$.uid++}`,j=z.schema.default,N=Q.includes(H),L=U===0?"":"json += JSON_STR_COMMA";if(W+=`
202
- const ${A} = ${J}[${F}]
203
- if (${A} !== undefined) {
204
- ${L}
205
- json += ${JSON.stringify(F+":")}
206
- ${c$($,z,`${A}`)}
207
- }`,j!==void 0)W+=` else {
208
- ${L}
209
- json += ${JSON.stringify(F+":"+JSON.stringify(j))}
210
- }
211
- `;else if(N)W+=` else {
212
- throw new Error('${F.replace(/'/g,"\\'")} is required!')
213
- }
214
- `;else W+=`
215
- `}V="json += JSON_STR_COMMA"}else{if(G.length>1||Y.patternProperties||Y.additionalProperties!==void 0&&Y.additionalProperties!==!1)W+=`let addComma_${K} = false
216
- `,V=`!addComma_${K} && (addComma_${K} = true) || (json += JSON_STR_COMMA)`;for(let H of G){let B=X.getPropertyLocation(H);if(B.schema.$ref)B=HZ($,B);let z=JSON.stringify(H),F=`value_${H.replace(/[^a-zA-Z0-9]/g,"_")}_${$.uid++}`,A=B.schema.default,j=Q.includes(H);if(W+=`
217
- const ${F} = ${J}[${z}]
218
- if (${F} !== undefined) {
219
- ${V}
220
- json += ${JSON.stringify(z+":")}
221
- ${c$($,B,`${F}`)}
222
- }`,A!==void 0)W+=` else {
223
- ${V}
224
- json += ${JSON.stringify(z+":"+JSON.stringify(A))}
225
- }
226
- `;else if(j)W+=` else {
227
- throw new Error('${z.replace(/'/g,"\\'")} is required!')
228
- }
229
- `;else W+=`
230
- `}}if(Y.patternProperties||Y.additionalProperties)W+=mz0($,Z,V,J);return W+=`
231
- json += JSON_STR_END_OBJECT
232
- `,W}function RW($,Z,J){for(let G=0,W=J.length;G<W;G++){let K=J[G];if(K.schema.$ref)J[G]=HZ($,K)}let Y=[];for(let G of J){let W=iy($,G.schema,G.schemaId);delete W.$id,Y.push(W)}let X=Sz0(Y),Q=new V7(X,Z);return $.refResolver.addSchema(X,Z),Q}function iy($,Z,J){let Y=Array.isArray(Z)?[]:{};if(Z.$id!==void 0&&Z.$id.charAt(0)!=="#")J=Z.$id;let X=$.mergedSchemasIds.get(Z);if(X)$.mergedSchemasIds.set(Y,X);for(let Q in Z){let G=Z[Q];if(Q==="$ref"&&typeof G==="string"&&G.charAt(0)==="#")G=J+G;if(typeof G==="object"&&G!==null)G=iy($,G,J);Y[Q]=G}return Y}function py($){return`(${$} && typeof ${$}.toJSON === 'function')
233
- ? ${$}.toJSON()
234
- : ${$}
235
- `}function lz0($,Z,J){let Y=Z.schema;if($.functionsNamesBySchema.has(Y))return`json += ${$.functionsNamesBySchema.get(Y)}(${J})`;let X=Y.nullable===!0,Q=Z.schemaId||"",G=Z.jsonPointer||"",W=`${Q}#${G}`;if($.recursivePaths.has(W)||$.buildingSet.has(Y)||Q!==""){let U=ny($);$.functionsNamesBySchema.set(Y,U);let B=`
236
- // ${PQ($,Z)}
237
- function ${U} (input) {
238
- const obj = ${py("input")}
239
- if (obj === null) return ${X?"JSON_STR_NULL":"JSON_STR_EMPTY_OBJECT"}
240
- let json = ''
241
-
242
- ${dy($,Z,"obj")}
243
- return json
244
- }
245
- `;return $.functions.push(B),`json += ${U}(${J})`}$.buildingSet.add(Y);let K=`obj_${$.uid++}`,V=`
246
- const ${K} = ${py(J)}
247
- if (${K} === null) {
248
- json += ${X?"JSON_STR_NULL":"JSON_STR_EMPTY_OBJECT"}
249
- } else {
250
- ${dy($,Z,K)}
251
- }
252
- `;return $.buildingSet.delete(Y),V}function dz0($,Z,J){let Y=Z.schema,X=Z.getPropertyLocation("items");if(X.schema=X.schema||{},X.schema.$ref)X=HZ($,X);let Q=X.schema;if($.functionsNamesBySchema.has(Y))return`json += ${$.functionsNamesBySchema.get(Y)}(${J})`;let G=Y.nullable===!0,W=Z.schemaId||"",K=Z.jsonPointer||"",V=`${W}#${K}`;if($.recursivePaths.has(V)||$.buildingSet.has(Y)||W!==""){let z=ny($);$.functionsNamesBySchema.set(Y,z);let F=PQ($,Z),A=`
253
- function ${z} (obj) {
254
- // ${F}
255
- let json = ''
256
- `;if(A+=`
257
- if (obj === null) return ${G?"JSON_STR_NULL":"JSON_STR_EMPTY_ARRAY"}
258
- if (!Array.isArray(obj)) {
259
- throw new TypeError(\`The value of '${F}' does not match schema definition.\`)
260
- }
261
- const arrayLength = obj.length
262
- `,!Y.additionalItems&&Array.isArray(Q))A+=`
263
- if (arrayLength > ${Q.length}) {
264
- throw new Error(\`Item at ${Q.length} does not match schema definition.\`)
265
- }
266
- `;if(LW==="json-stringify")A+=`if (arrayLength >= ${TQ}) return JSON.stringify(obj)
267
- `;if(A+=`
268
- json += JSON_STR_BEGIN_ARRAY
269
- `,Array.isArray(Q)){for(let j=0,N=Q.length;j<N;j++){let L=Q[j],q=X.getPropertyLocation(j);if(q.schema.$ref)q=HZ($,q),L=q.schema;let M=`value_${j}`;A+=`const ${M} = obj[${j}]`;let C=c$($,q,M);A+=`
270
- if (${j} < arrayLength) {
271
- if (${ZF(L.type,M)}) {
272
- if (${j}) {
273
- json += JSON_STR_COMMA
274
- }
275
- ${C}
276
- } else {
277
- throw new Error(\`Item at ${j} does not match schema definition.\`)
278
- }
279
- }
280
- `}if(Y.additionalItems)A+=`
281
- for (let i = ${Q.length}; i < arrayLength; i++) {
282
- if (i) {
283
- json += JSON_STR_COMMA
284
- }
285
- json += JSON.stringify(obj[i])
286
- }`}else{let j=c$($,X,"value");A+=`
287
- if (arrayLength > 0) {
288
- const value = obj[0]
289
- ${j}
290
- for (let i = 1; i < arrayLength; i++) {
291
- json += JSON_STR_COMMA
292
- const value = obj[i]
293
- ${j}
294
- }
295
- }`}return A+=`
296
- return json + JSON_STR_END_ARRAY
297
- }`,$.functions.push(A),`json += ${z}(${J})`}$.buildingSet.add(Y);let U=PQ($,Z),H=`obj_${$.uid++}`,B=`
298
- const ${H} = ${J}
299
- if (${H} === null) {
300
- json += ${G?"JSON_STR_NULL":"JSON_STR_EMPTY_ARRAY"}
301
- } else if (!Array.isArray(${H})) {
302
- throw new TypeError(\`The value of '${U}' does not match schema definition.\`)
303
- } else {
304
- const arrayLength_${H} = ${H}.length
305
- `;if(!Y.additionalItems&&Array.isArray(Q))B+=`
306
- if (arrayLength_${H} > ${Q.length}) {
307
- throw new Error(\`Item at ${Q.length} does not match schema definition.\`)
308
- }
309
- `;if(LW==="json-stringify")B+=`if (arrayLength_${H} >= ${TQ}) json += JSON.stringify(${H})
310
- else {`;if(B+=`
311
- json += JSON_STR_BEGIN_ARRAY
312
- `,Array.isArray(Q)){let z=$.uid++;B+=`let addComma_${z} = false
313
- `;for(let F=0,A=Q.length;F<A;F++){let j=Q[F],N=X.getPropertyLocation(F);if(N.schema.$ref)N=HZ($,N),j=N.schema;let L=`value_${F}_${$.uid++}`;B+=`const ${L} = ${H}[${F}]`;let q=c$($,N,L);B+=`
314
- if (${F} < arrayLength_${H}) {
315
- if (${ZF(j.type,L)}) {
316
- !addComma_${z} && (addComma_${z} = true) || (json += JSON_STR_COMMA)
317
- ${q}
318
- } else {
319
- throw new Error(\`Item at ${F} does not match schema definition.\`)
320
- }
321
- }
322
- `}if(Y.additionalItems)B+=`
323
- for (let i = ${Q.length}; i < arrayLength_${H}; i++) {
324
- !addComma_${z} && (addComma_${z} = true) || (json += JSON_STR_COMMA)
325
- json += JSON.stringify(${H}[i])
326
- }`}else{let z=c$($,X,"value");B+=`
327
- if (arrayLength_${H} > 0) {
328
- const value = ${H}[0]
329
- ${z}
330
- for (let i = 1; i < arrayLength_${H}; i++) {
331
- json += JSON_STR_COMMA
332
- const value = ${H}[i]
333
- ${z}
334
- }
335
- }`}if(B+=`
336
- json += JSON_STR_END_ARRAY
337
- `,LW==="json-stringify")B+="}";return B+="}",$.buildingSet.delete(Y),B}function ZF($,Z){let J;switch($){case"null":J=`${Z} === null`;break;case"string":J=`typeof ${Z} === 'string' ||
338
- ${Z} === null ||
339
- ${Z} instanceof Date ||
340
- ${Z} instanceof RegExp ||
341
- (
342
- typeof ${Z} === "object" &&
343
- typeof ${Z}.toString === "function" &&
344
- ${Z}.toString !== Object.prototype.toString
345
- )`;break;case"integer":J=`Number.isInteger(${Z})`;break;case"number":J=`Number.isFinite(${Z})`;break;case"boolean":J=`typeof ${Z} === 'boolean'`;break;case"object":J=`${Z} && typeof ${Z} === 'object' && ${Z}.constructor === Object`;break;case"array":J=`Array.isArray(${Z})`;break;default:if(Array.isArray($))J=`(${$.map((X)=>{return ZF(X,Z)}).join(" || ")})`}return J}function ny($){return"anonymous"+$.functionsCounter++}function pz0($,Z,J){let X=Z.schema.type.sort((G)=>G==="null"?-1:1),Q="";return X.forEach((G,W)=>{Z.schema={...Z.schema,type:G};let K=oy($,Z,J),V=W===0?"if":"else if";switch(G){case"null":Q+=`
346
- ${V} (${J} === null) {
347
- ${K}
348
- }
349
- `;break;case"string":{Q+=`
350
- ${V}(
351
- typeof ${J} === "string" ||
352
- ${J} === null ||
353
- ${J} instanceof Date ||
354
- ${J} instanceof RegExp ||
355
- (
356
- typeof ${J} === "object" &&
357
- typeof ${J}.toString === "function" &&
358
- ${J}.toString !== Object.prototype.toString
359
- )
360
- ) {
361
- ${K}
362
- }
363
- `;break}case"array":{Q+=`
364
- ${V}(Array.isArray(${J})) {
365
- ${K}
366
- }
367
- `;break}case"integer":{Q+=`
368
- ${V}(Number.isInteger(${J}) || ${J} === null) {
369
- ${K}
370
- }
371
- `;break}default:{Q+=`
372
- ${V}(typeof ${J} === "${G}" || ${J} === null) {
373
- ${K}
374
- }
375
- `;break}}}),Q+=`
376
- else throw new TypeError(\`The value of '${PQ($,Z)}' does not match schema definition.\`)
377
- `,Q}function oy($,Z,J){let Y=Z.schema;switch(Y.type){case"null":return"json += JSON_STR_NULL";case"string":if(Y.format==="date-time")return`json += asDateTime(${J})`;else if(Y.format==="date")return`json += asDate(${J})`;else if(Y.format==="time")return`json += asTime(${J})`;else if(Y.format==="unsafe")return`json += asUnsafeString(${J})`;else return`
378
- if (typeof ${J} !== 'string') {
379
- if (${J} === null) {
380
- json += JSON_STR_EMPTY_STRING
381
- } else if (${J} instanceof Date) {
382
- json += JSON_STR_QUOTE + ${J}.toISOString() + JSON_STR_QUOTE
383
- } else if (${J} instanceof RegExp) {
384
- json += asString(${J}.source)
385
- } else {
386
- json += asString(${J}.toString())
387
- }
388
- } else {
389
- json += asString(${J})
390
- }
391
- `;case"integer":return`json += asInteger(${J})`;case"number":return`json += asNumber(${J})`;case"boolean":return`json += asBoolean(${J})`;case"object":return lz0($,Z,J);case"array":return dz0($,Z,J);case void 0:return`json += JSON.stringify(${J})`;default:throw Error(`${Y.type} unsupported`)}}function cz0($,Z){let J=new Set;function Y(X){let Q=X.schema;if(typeof Q!=="object"||Q===null)return;let G=X.schemaId||"",W=X.jsonPointer||"",K=`${G}#${W}`;if(J.has(K)){let V=!1;for(let U of J){if(U===K)V=!0;if(V)$.recursivePaths.add(U)}$.recursivePaths.add(K);return}if(J.add(K),Q.$ref)try{let V=HZ($,X);Y(V)}catch(V){}if(Q.properties){let V=X.getPropertyLocation("properties");for(let U in Q.properties)Y(V.getPropertyLocation(U))}if(Q.additionalProperties&&typeof Q.additionalProperties==="object")Y(X.getPropertyLocation("additionalProperties"));if(Q.patternProperties){let V=X.getPropertyLocation("patternProperties");for(let U in Q.patternProperties)Y(V.getPropertyLocation(U))}if(Q.items){let V=X.getPropertyLocation("items");if(Array.isArray(Q.items))for(let U=0;U<Q.items.length;U++)Y(V.getPropertyLocation(U));else Y(V)}if(Q.additionalItems&&typeof Q.additionalItems==="object")Y(X.getPropertyLocation("additionalItems"));if(Q.oneOf){let V=X.getPropertyLocation("oneOf");for(let U=0;U<Q.oneOf.length;U++)Y(V.getPropertyLocation(U))}if(Q.anyOf){let V=X.getPropertyLocation("anyOf");for(let U=0;U<Q.anyOf.length;U++)Y(V.getPropertyLocation(U))}if(Q.allOf){let V=X.getPropertyLocation("allOf");for(let U=0;U<Q.allOf.length;U++)Y(V.getPropertyLocation(U))}if(Q.then)Y(X.getPropertyLocation("then"));if(Q.else)Y(X.getPropertyLocation("else"));J.delete(K)}Y(Z)}function iz0($,Z){let J=$.schema,Y=J.type,X=Array.isArray(Y)&&Y.includes("null"),Q="";if(X)Q+=`
392
- if (${Z} === null) {
393
- json += JSON_STR_NULL
394
- } else {
395
- `;if(Q+=`json += '${JSON.stringify(J.const).replace(fz0,"\\'")}'`,X)Q+=`
396
- }
397
- `;return Q}function nz0($,Z,J){let Y=Z.schema,X=$.mergedSchemasIds.get(Y);if(X){let U=TW($,X);return c$($,U,J)}X=`__fjs_merged_${RQ++}`,$.mergedSchemasIds.set(Y,X);let{allOf:Q,...G}=Z.schema,W=[new V7(G,Z.schemaId,Z.jsonPointer)],K=Z.getPropertyLocation("allOf");for(let U=0,H=Q.length;U<H;U++)W.push(K.getPropertyLocation(U));let V=RW($,X,W);return c$($,V,J)}function oz0($,Z,J){$.validatorSchemasIds.add(Z.schemaId);let X=Z.schema.anyOf?"anyOf":"oneOf",{[X]:Q,...G}=Z.schema,W=new V7(G,Z.schemaId,Z.jsonPointer),K=Z.getPropertyLocation(X),V="";for(let U=0,H=Q.length;U<H;U++){let B=K.getPropertyLocation(U),z=B.schema,F=$.mergedSchemasIds.get(z),A=null;if(F)A=TW($,F);else F=`__fjs_merged_${RQ++}`,$.mergedSchemasIds.set(z,F),A=RW($,F,[W,B]);let j=c$($,A,J),N=B.getSchemaRef();V+=`
398
- ${U===0?"if":"else if"}(validator.validate("${N}", ${J})) {
399
- ${j}
400
- }
401
- `}return V+=`
402
- else throw new TypeError(\`The value of '${PQ($,Z)}' does not match schema definition.\`)
403
- `,V}function sz0($,Z,J){$.validatorSchemasIds.add(Z.schemaId);let{if:Y,then:X,else:Q,...G}=Z.schema,W=new V7(G,Z.schemaId,Z.jsonPointer),V=Z.getPropertyLocation("if").getSchemaRef(),U=Z.getPropertyLocation("then"),H=$.mergedSchemasIds.get(X),B=null;if(H)B=TW($,H);else H=`__fjs_merged_${RQ++}`,$.mergedSchemasIds.set(X,H),B=RW($,H,[W,U]);if(!Q)return`
404
- if (validator.validate("${V}", ${J})) {
405
- ${c$($,B,J)}
406
- } else {
407
- ${c$($,W,J)}
408
- }
409
- `;let z=Z.getPropertyLocation("else"),F=$.mergedSchemasIds.get(Q),A=null;if(F)A=TW($,F);else F=`__fjs_merged_${RQ++}`,$.mergedSchemasIds.set(Q,F),A=RW($,F,[W,z]);return`
410
- if (validator.validate("${V}", ${J})) {
411
- ${c$($,B,J)}
412
- } else {
413
- ${c$($,A,J)}
414
- }
415
- `}function c$($,Z,J){let Y=Z.schema;if(typeof Y==="boolean")return`json += JSON.stringify(${J})`;if(Y.$ref)Z=HZ($,Z),Y=Z.schema;if(Y.allOf)return nz0($,Z,J);if(Y.anyOf||Y.oneOf)return oz0($,Z,J);if(Y.if&&Y.then)return sz0($,Z,J);if(Y.type===void 0){let W=uz0(Y);if(W)Y.type=W}let X="",Q=Y.type,G=Y.nullable===!0;if(G)X+=`
416
- if (${J} === null) {
417
- json += JSON_STR_NULL
418
- } else {
419
- `;if(Y.const!==void 0)X+=iz0(Z,J);else if(Array.isArray(Q))X+=pz0($,Z,J);else X+=oy($,Z,J);if(G)X+=`
420
- }
421
- `;return X}JY.exports=JF;JY.exports.default=JF;JY.exports.build=JF;JY.exports.validLargeArrayMechanisms=cy;JY.exports.restore=function({code:$,validator:Z,serializer:J}){return Function.apply(null,["validator","serializer",$]).apply(null,[Z,J])}});var ty=S((tz0,PW)=>{var rz0=sy();function ry(){return function(Z,J){let Y=Object.assign({},J,{schema:Z});return az0.bind(null,Y)}}function az0($,{schema:Z}){if($.schema&&Z.$id&&$.schema[Z.$id])$.schema={...$.schema},delete $.schema[Z.$id];return rz0(Z,$)}function ay($={readMode:!0}){if($.readMode===!0&&typeof $.restoreFunction!=="function")throw Error("You must provide a function for the restoreFunction-option when readMode ON");if($.readMode!==!0&&typeof $.storeFunction!=="function")throw Error("You must provide a function for the storeFunction-option when readMode OFF");if($.readMode===!0)return function(){return function(Y){return $.restoreFunction(Y)}};let Z=ry();return function(Y,X={}){X.mode="standalone";let Q=Z(Y,X);return function(G){let W=Q(G);return $.storeFunction(G,W),Function(W)}}}tz0.SerializerSelector=ry;tz0.StandaloneSerializer=ay;tz0.default=ay});var ey=S((Vx0,IQ)=>{var{SerializerSelector:YF,StandaloneSerializer:J30}=ty();IQ.exports=YF;IQ.exports.default=YF;IQ.exports.SerializerSelector=YF;IQ.exports.StandaloneSerializer=J30});var XF=S((Ux0,$x)=>{var{buildSchemas:Y30}=xX();function X30($,Z){if($)return new CQ($,Z);let J=Object.assign({buildValidator:null,buildSerializer:null},Z?.compilersFactory);if(!J.buildValidator){let X=p3();J.buildValidator=X()}if(!J.buildSerializer){let X=ey();J.buildSerializer=X()}let Y={bucket:Z&&Z.bucket||Y30,compilersFactory:J,isCustomValidatorCompiler:typeof Z?.compilersFactory?.buildValidator==="function",isCustomSerializerCompiler:typeof Z?.compilersFactory?.buildValidator==="function"};return new CQ(void 0,Y)}class CQ{constructor($,Z){if(this.opts=Z||$?.opts,this.addedSchemas=!1,this.compilersFactory=this.opts.compilersFactory,$)this.schemaBucket=this.opts.bucket($.getSchemas()),this.validatorCompiler=$.getValidatorCompiler(),this.serializerCompiler=$.getSerializerCompiler(),this.isCustomValidatorCompiler=$.isCustomValidatorCompiler,this.isCustomSerializerCompiler=$.isCustomSerializerCompiler,this.parent=$;else this.schemaBucket=this.opts.bucket(),this.isCustomValidatorCompiler=this.opts.isCustomValidatorCompiler||!1,this.isCustomSerializerCompiler=this.opts.isCustomSerializerCompiler||!1}add($){return this.addedSchemas=!0,this.schemaBucket.add($)}getSchema($){return this.schemaBucket.getSchema($)}getSchemas(){return this.schemaBucket.getSchemas()}setValidatorCompiler($){this.compilersFactory=Object.assign({},this.compilersFactory,{buildValidator:()=>$}),this.validatorCompiler=$,this.isCustomValidatorCompiler=!0}setSerializerCompiler($){this.compilersFactory=Object.assign({},this.compilersFactory,{buildSerializer:()=>$}),this.serializerCompiler=$,this.isCustomSerializerCompiler=!0}getValidatorCompiler(){return this.validatorCompiler||this.parent&&this.parent.getValidatorCompiler()}getSerializerCompiler(){return this.serializerCompiler||this.parent&&this.parent.getSerializerCompiler()}getSerializerBuilder(){return this.compilersFactory.buildSerializer||this.parent&&this.parent.getSerializerBuilder()}getValidatorBuilder(){return this.compilersFactory.buildValidator||this.parent&&this.parent.getValidatorBuilder()}setupValidator($){if(this.validatorCompiler!==void 0&&!this.addedSchemas)return;this.validatorCompiler=this.getValidatorBuilder()(this.schemaBucket.getSchemas(),$.ajv)}setupSerializer($){if(this.serializerCompiler!==void 0&&!this.addedSchemas)return;this.serializerCompiler=this.getSerializerBuilder()(this.schemaBucket.getSchemas(),$.serializerOpts)}}CQ.buildSchemaController=X30;$x.exports=CQ});var UF=S((Hx0,VF)=>{var QF=Q30(),WF=Y0("assert"),KF=Symbol.for("registered-plugin"),{kTestInternals:G30}=H$(),{exist:W30,existReply:K30,existRequest:V30}=mX(),{FST_ERR_PLUGIN_VERSION_MISMATCH:U30,FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE:H30,FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER:B30}=L$(),z30=/-(?:rc|pre|alpha).+$/u;function EQ($){return $[Symbol.for("plugin-meta")]}function Zx($){let Z=Jx($);if(Z)return Z;let J=Y0.cache;if(J){let Y=Object.keys(J);for(let X=0;X<Y.length;X++){let Q=Y[X];if(J[Q].exports===$)return Q}}if($.name)return $.name;return null}function F30($){return $.toString().split(`
422
- `,2).map((Z)=>Z.trim()).join(" -- ")}function Jx($){return $[Symbol.for("fastify.display-name")]}function Yx($){return!!$[Symbol.for("skip-override")]}function Xx($){let Z=EQ($);if(!Z)return;let J=Z.dependencies;if(!J)return;WF(Array.isArray(J),"The dependencies should be an array of strings"),J.forEach((Y)=>{WF(this[KF].indexOf(Y)>-1,`The dependency '${Y}' of plugin '${Z.name}' is not registered`)})}function Qx($){let Z=EQ($);if(!Z)return;let{decorators:J,name:Y}=Z;if(!J)return;if(J.fastify)GF(this,"Fastify",J.fastify,Y);if(J.reply)GF(this,"Reply",J.reply,Y);if(J.request)GF(this,"Request",J.request,Y)}var A30={Fastify:W30,Request:V30,Reply:K30};function GF($,Z,J,Y){WF(Array.isArray(J),"The decorators should be an array of strings"),J.forEach((X)=>{let Q=typeof Y==="string"?` required by '${Y}'`:"";if(!A30[Z].call($,X))throw new H30(X,Q,Z)})}function O30($){let Z=EQ($);if(Z?.fastify==null)return;let J=Z.fastify,Y=z30.test(this.version);if(Y===!0&&QF.gt(this.version,QF.coerce(J))===!0)return;if(J&&QF.satisfies(this.version,J,{includePrerelease:Y})===!1)throw new U30(Z.name,J,this.version)}function q30($){let Z=EQ($);if(!Z)return;let J=Z.name;if(!J)return;return this[KF].push(J),J}function j30($,Z){if($.constructor.name==="AsyncFunction"&&$.length===3)throw new B30(Z)}function N30($){let Z=q30.call(this,$)||Zx($);return j30.call(this,$,Z),O30.call(this,$),Qx.call(this,$),Xx.call(this,$),Yx($)}VF.exports={getPluginName:Zx,getFuncPreview:F30,kRegisteredPlugins:KF,getDisplayName:Jx,registerPlugin:N30};VF.exports[G30]={shouldSkipOverride:Yx,getMeta:EQ,checkDecorators:Qx,checkDependencies:Xx}});var IW=S((zx0,Gx)=>{function M30($,Z){let J=Z||w30();if($)return L30($,J);return J}function D30($,Z){return $.genReqId(Z)}function w30(){let Z=0;return function(){return Z=Z+1&2147483647,`req-${Z.toString(36)}`}}function L30($,Z){return function(J){return J.headers[$]||Z(J)}}Gx.exports={getGenReqId:D30,reqIdGenFactory:M30}});var Ux=S((Fx0,Vx)=>{var Wx=12,T30=0,HF=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,7,7,7,7,7,7,7,7,7,7,7,7,8,7,7,10,9,9,9,11,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,24,36,48,60,72,84,96,0,12,12,12,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,24,24,24,0,0,0,0,0,0,0,0,0,24,24,0,0,0,0,0,0,0,0,0,0,48,48,48,0,0,0,0,0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,127,63,63,63,0,31,15,15,15,7,7,7];function R30($){var Z=$.indexOf("%");if(Z===-1)return $;var J=$.length,Y="",X=0,Q=0,G=Z,W=Wx;while(Z>-1&&Z<J){var K=Kx($[Z+1],4),V=Kx($[Z+2],0),U=K|V,H=HF[U];if(W=HF[256+W+H],Q=Q<<6|U&HF[364+H],W===Wx)Y+=$.slice(X,G),Y+=Q<=65535?String.fromCharCode(Q):String.fromCharCode(55232+(Q>>10),56320+(Q&1023)),Q=0,X=Z+3,Z=G=$.indexOf("%",X);else if(W===T30)return null;else{if(Z+=3,Z<J&&$.charCodeAt(Z)===37)continue;return null}}return Y+$.slice(X)}var P30={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function Kx($,Z){var J=P30[$];return J===void 0?255:J<<Z}Vx.exports=R30});var Ax=S((Ax0,Fx)=>{var Hx=Ux(),Bx=/\+/g,zx=function(){};zx.prototype=Object.create(null);function I30($){let Z=new zx;if(typeof $!=="string")return Z;let J=$.length,Y="",X="",Q=-1,G=-1,W=!1,K=!1,V=!1,U=!1,H=!1,B=0;for(let z=0;z<J+1;z++)if(B=z!==J?$.charCodeAt(z):38,B===38){if(H=G>Q,!H)G=z;if(Y=$.slice(Q+1,G),H||Y.length>0){if(V)Y=Y.replace(Bx," ");if(W)Y=Hx(Y)||Y;if(H){if(X=$.slice(G+1,z),U)X=X.replace(Bx," ");if(K)X=Hx(X)||X}let F=Z[Y];if(F===void 0)Z[Y]=X;else if(F.pop)F.push(X);else Z[Y]=[F,X]}X="",Q=z,G=z,W=!1,K=!1,V=!1,U=!1}else if(B===61)if(G<=Q)G=z;else K=!0;else if(B===43)if(G>Q)U=!0;else V=!0;else if(B===37)if(G>Q)K=!0;else W=!0;return Z}Fx.exports=I30});var qx=S((Ox0,Ox)=>{var b6=Array.from({length:256},($,Z)=>"%"+((Z<16?"0":"")+Z.toString(16)).toUpperCase()),C30=new Int8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0]);function E30($){let Z=$.length;if(Z===0)return"";let J="",Y=0,X=0;$:for(;X<Z;X++){let Q=$.charCodeAt(X);while(Q<128){if(C30[Q]!==1){if(Y<X)J+=$.slice(Y,X);Y=X+1,J+=b6[Q]}if(++X===Z)break $;Q=$.charCodeAt(X)}if(Y<X)J+=$.slice(Y,X);if(Q<2048){Y=X+1,J+=b6[192|Q>>6]+b6[128|Q&63];continue}if(Q<55296||Q>=57344){Y=X+1,J+=b6[224|Q>>12]+b6[128|Q>>6&63]+b6[128|Q&63];continue}if(++X,X>=Z)throw Error("URI malformed");let G=$.charCodeAt(X)&1023;Y=X+1,Q=65536+((Q&1023)<<10|G),J+=b6[240|Q>>18]+b6[128|Q>>12&63]+b6[128|Q>>6&63]+b6[128|Q&63]}if(Y===0)return $;if(Y<Z)return J+$.slice(Y);return J}Ox.exports={encodeString:E30}});var Mx=S((qx0,Nx)=>{var{encodeString:BF}=qx();function jx($){let Z=typeof $;if(Z==="string")return BF($);else if(Z==="bigint")return $.toString();else if(Z==="boolean")return $?"true":"false";else if(Z==="number"&&Number.isFinite($))return $<1000000000000000000000?""+$:BF(""+$);return""}function b30($){let Z="";if($===null||typeof $!=="object")return Z;let J="&",Y=Object.keys($),X=Y.length,Q=0;for(let G=0;G<X;G++){let W=Y[G],K=$[W],V=BF(W)+"=";if(G)Z+=J;if(Array.isArray(K)){Q=K.length;for(let U=0;U<Q;U++){if(U)Z+=J;Z+=V,Z+=jx(K[U])}}else Z+=V,Z+=jx(K)}return Z}Nx.exports=b30});var Tx=S((jx0,bQ)=>{var Dx=Ax(),wx=Mx(),Lx={parse:Dx,stringify:wx};bQ.exports=Lx;bQ.exports.default=Lx;bQ.exports.parse=Dx;bQ.exports.stringify=wx});var Px=S((Rx)=>{Object.defineProperty(Rx,"__esModule",{value:!0})});var Cx=S((Ix)=>{Object.defineProperty(Ix,"__esModule",{value:!0});Ix.types=void 0;var _30;(function($){$[$.ROOT=0]="ROOT",$[$.GROUP=1]="GROUP",$[$.POSITION=2]="POSITION",$[$.SET=3]="SET",$[$.RANGE=4]="RANGE",$[$.REPETITION=5]="REPETITION",$[$.REFERENCE=6]="REFERENCE",$[$.CHAR=7]="CHAR"})(_30=Ix.types||(Ix.types={}))});var bx=S((Ex)=>{Object.defineProperty(Ex,"__esModule",{value:!0})});var zZ=S((BZ)=>{var S30=BZ&&BZ.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),FF=BZ&&BZ.__exportStar||function($,Z){for(var J in $)if(J!=="default"&&!Object.prototype.hasOwnProperty.call(Z,J))S30(Z,$,J)};Object.defineProperty(BZ,"__esModule",{value:!0});FF(Px(),BZ);FF(Cx(),BZ);FF(bx(),BZ)});var CW=S((kx)=>{Object.defineProperty(kx,"__esModule",{value:!0});kx.anyChar=kx.notWhitespace=kx.whitespace=kx.notInts=kx.ints=kx.notWords=kx.words=void 0;var R1=zZ(),_x=()=>[{type:R1.types.RANGE,from:48,to:57}],Sx=()=>[{type:R1.types.CHAR,value:95},{type:R1.types.RANGE,from:97,to:122},{type:R1.types.RANGE,from:65,to:90},{type:R1.types.RANGE,from:48,to:57}],fx=()=>[{type:R1.types.CHAR,value:9},{type:R1.types.CHAR,value:10},{type:R1.types.CHAR,value:11},{type:R1.types.CHAR,value:12},{type:R1.types.CHAR,value:13},{type:R1.types.CHAR,value:32},{type:R1.types.CHAR,value:160},{type:R1.types.CHAR,value:5760},{type:R1.types.RANGE,from:8192,to:8202},{type:R1.types.CHAR,value:8232},{type:R1.types.CHAR,value:8233},{type:R1.types.CHAR,value:8239},{type:R1.types.CHAR,value:8287},{type:R1.types.CHAR,value:12288},{type:R1.types.CHAR,value:65279}],f30=()=>[{type:R1.types.CHAR,value:10},{type:R1.types.CHAR,value:13},{type:R1.types.CHAR,value:8232},{type:R1.types.CHAR,value:8233}];kx.words=()=>({type:R1.types.SET,set:Sx(),not:!1});kx.notWords=()=>({type:R1.types.SET,set:Sx(),not:!0});kx.ints=()=>({type:R1.types.SET,set:_x(),not:!1});kx.notInts=()=>({type:R1.types.SET,set:_x(),not:!0});kx.whitespace=()=>({type:R1.types.SET,set:fx(),not:!1});kx.notWhitespace=()=>({type:R1.types.SET,set:fx(),not:!0});kx.anyChar=()=>({type:R1.types.SET,set:f30(),not:!0})});var xx=S((l8)=>{var u30=l8&&l8.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),m30=l8&&l8.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),l30=l8&&l8.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))u30(Z,$,J)}return m30(Z,$),Z};Object.defineProperty(l8,"__esModule",{value:!0});l8.tokenizeClass=l8.strToChars=void 0;var yx=zZ(),YY=l30(CW()),d30="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?";l8.strToChars=($)=>{let Z=/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g;return $.replace(Z,(J,Y,X,Q,G,W,K)=>{if(X)return J;let V=Y?8:Q?parseInt(Q,16):G?parseInt(G,16):W?d30.indexOf(W):{0:0,t:9,n:10,v:11,f:12,r:13}[K],U=String.fromCharCode(V);return/[[\]{}^$.|?*+()]/.test(U)?`\\${U}`:U})};l8.tokenizeClass=($,Z)=>{var J,Y,X,Q,G,W,K;let V=[],U,H,B=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;while((U=B.exec($))!==null){let z=(K=(W=(G=(Q=(X=(Y=(J=U[1]&&YY.words())!==null&&J!==void 0?J:U[2]&&YY.ints())!==null&&Y!==void 0?Y:U[3]&&YY.whitespace())!==null&&X!==void 0?X:U[4]&&YY.notWords())!==null&&Q!==void 0?Q:U[5]&&YY.notInts())!==null&&G!==void 0?G:U[6]&&YY.notWhitespace())!==null&&W!==void 0?W:U[7]&&{type:yx.types.RANGE,from:(U[8]||U[9]).charCodeAt(0),to:(H=U[10]).charCodeAt(H.length-1)})!==null&&K!==void 0?K:(H=U[16])&&{type:yx.types.CHAR,value:H.charCodeAt(0)};if(z)V.push(z);else return[V,B.lastIndex]}throw SyntaxError(`Invalid regular expression: /${Z}/: Unterminated character class`)}});var AF=S((_6)=>{var p30=_6&&_6.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),c30=_6&&_6.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),ux=_6&&_6.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))p30(Z,$,J)}return c30(Z,$),Z};Object.defineProperty(_6,"__esModule",{value:!0});_6.tokenizer=void 0;var hx=ux(xx()),k$=zZ(),U7=ux(CW()),i30=/^[a-zA-Z_$]$/i,n30=/^[a-zA-Z0-9_$]$/i,gx=/\d/;_6.tokenizer=($)=>{let Z=0,J,Y={type:k$.types.ROOT,stack:[]},X=Y,Q=Y.stack,G=[],W=[],K=0,V=(H)=>{throw SyntaxError(`Invalid regular expression: /${$}/: Nothing to repeat at column ${H-1}`)},U=hx.strToChars($);while(Z<U.length)switch(J=U[Z++]){case"\\":if(Z===U.length)throw SyntaxError(`Invalid regular expression: /${$}/: \\ at end of pattern`);switch(J=U[Z++]){case"b":Q.push({type:k$.types.POSITION,value:"b"});break;case"B":Q.push({type:k$.types.POSITION,value:"B"});break;case"w":Q.push(U7.words());break;case"W":Q.push(U7.notWords());break;case"d":Q.push(U7.ints());break;case"D":Q.push(U7.notInts());break;case"s":Q.push(U7.whitespace());break;case"S":Q.push(U7.notWhitespace());break;default:if(gx.test(J)){let H=J;while(Z<U.length&&gx.test(U[Z]))H+=U[Z++];let B=parseInt(H,10),z={type:k$.types.REFERENCE,value:B};Q.push(z),W.push({reference:z,stack:Q,index:Q.length-1})}else Q.push({type:k$.types.CHAR,value:J.charCodeAt(0)})}break;case"^":Q.push({type:k$.types.POSITION,value:"^"});break;case"$":Q.push({type:k$.types.POSITION,value:"$"});break;case"[":{let H;if(U[Z]==="^")H=!0,Z++;else H=!1;let B=hx.tokenizeClass(U.slice(Z),$);Z+=B[1],Q.push({type:k$.types.SET,set:B[0],not:H});break}case".":Q.push(U7.anyChar());break;case"(":{let H={type:k$.types.GROUP,stack:[],remember:!0};if(U[Z]==="?")if(J=U[Z+1],Z+=2,J==="=")H.followedBy=!0,H.remember=!1;else if(J==="!")H.notFollowedBy=!0,H.remember=!1;else if(J==="<"){let B="";if(i30.test(U[Z]))B+=U[Z],Z++;else throw SyntaxError(`Invalid regular expression: /${$}/: Invalid capture group name, character '${U[Z]}' after '<' at column ${Z+1}`);while(Z<U.length&&n30.test(U[Z]))B+=U[Z],Z++;if(!B)throw SyntaxError(`Invalid regular expression: /${$}/: Invalid capture group name, character '${U[Z]}' after '<' at column ${Z+1}`);if(U[Z]!==">")throw SyntaxError(`Invalid regular expression: /${$}/: Unclosed capture group name, expected '>', found '${U[Z]}' at column ${Z+1}`);H.name=B,Z++}else if(J===":")H.remember=!1;else throw SyntaxError(`Invalid regular expression: /${$}/: Invalid group, character '${J}' after '?' at column ${Z-1}`);else K+=1;Q.push(H),G.push(X),X=H,Q=H.stack;break}case")":if(G.length===0)throw SyntaxError(`Invalid regular expression: /${$}/: Unmatched ) at column ${Z-1}`);X=G.pop(),Q=X.options?X.options[X.options.length-1]:X.stack;break;case"|":{if(!X.options)X.options=[X.stack],delete X.stack;let H=[];X.options.push(H),Q=H;break}case"{":{let H=/^(\d+)(,(\d+)?)?\}/.exec(U.slice(Z)),B,z;if(H!==null){if(Q.length===0)V(Z);B=parseInt(H[1],10),z=H[2]?H[3]?parseInt(H[3],10):1/0:B,Z+=H[0].length,Q.push({type:k$.types.REPETITION,min:B,max:z,value:Q.pop()})}else Q.push({type:k$.types.CHAR,value:123});break}case"?":if(Q.length===0)V(Z);Q.push({type:k$.types.REPETITION,min:0,max:1,value:Q.pop()});break;case"+":if(Q.length===0)V(Z);Q.push({type:k$.types.REPETITION,min:1,max:1/0,value:Q.pop()});break;case"*":if(Q.length===0)V(Z);Q.push({type:k$.types.REPETITION,min:0,max:1/0,value:Q.pop()});break;default:Q.push({type:k$.types.CHAR,value:J.charCodeAt(0)})}if(G.length!==0)throw SyntaxError(`Invalid regular expression: /${$}/: Unterminated group`);return o30(W,K),Y};function o30($,Z){for(let J of $.reverse())if(Z<J.reference.value){J.reference.type=k$.types.CHAR;let Y=J.reference.value.toString();if(J.reference.value=parseInt(Y,8),!/^[0-7]+$/.test(Y)){let X=0;while(Y[X]!=="8"&&Y[X]!=="9")X+=1;if(X===0)J.reference.value=Y.charCodeAt(0),X+=1;else J.reference.value=parseInt(Y.slice(0,X),8);if(Y.length>X){let Q=J.stack.splice(J.index+1);for(let G of Y.slice(X))J.stack.push({type:k$.types.CHAR,value:G.charCodeAt(0)});J.stack.push(...Q)}}}}});var lx=S((i$)=>{var s30=i$&&i$.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),r30=i$&&i$.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),a30=i$&&i$.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))s30(Z,$,J)}return r30(Z,$),Z};Object.defineProperty(i$,"__esModule",{value:!0});i$.NOTANYCHAR=i$.WHITESPACE=i$.WORDS=i$.INTS=void 0;var EW=a30(CW()),mx=zZ();function bW($){let Z={},J=0;for(let Y of $){if(Y.type===mx.types.CHAR)Z[Y.value]=!0;if(Y.type===mx.types.RANGE)Z[`${Y.from}-${Y.to}`]=!0;J+=1}return{lookup:()=>Object.assign({},Z),len:J}}i$.INTS=bW(EW.ints().set);i$.WORDS=bW(EW.words().set);i$.WHITESPACE=bW(EW.whitespace().set);i$.NOTANYCHAR=bW(EW.anyChar().set)});var px=S((d8)=>{var t30=d8&&d8.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),e30=d8&&d8.__setModuleDefault||(Object.create?function($,Z){Object.defineProperty($,"default",{enumerable:!0,value:Z})}:function($,Z){$.default=Z}),$F0=d8&&d8.__importStar||function($){if($&&$.__esModule)return $;var Z={};if($!=null){for(var J in $)if(J!=="default"&&Object.prototype.hasOwnProperty.call($,J))t30(Z,$,J)}return e30(Z,$),Z};Object.defineProperty(d8,"__esModule",{value:!0});d8.writeSetTokens=d8.setChar=void 0;var kW=zZ(),_W=$F0(lx());function fW($){return $===94?"\\^":$===92?"\\\\":$===93?"\\]":$===45?"\\-":String.fromCharCode($)}d8.setChar=fW;function SW($,{lookup:Z,len:J}){if(J!==$.length)return!1;let Y=Z();for(let X of $){if(X.type===kW.types.SET)return!1;let Q=X.type===kW.types.CHAR?X.value:`${X.from}-${X.to}`;if(Y[Q])Y[Q]=!1;else return!1}return!0}function dx($,Z=!1){if(SW($.set,_W.INTS))return $.not?"\\D":"\\d";if(SW($.set,_W.WORDS))return $.not?"\\W":"\\w";if($.not&&SW($.set,_W.NOTANYCHAR))return".";if(SW($.set,_W.WHITESPACE))return $.not?"\\S":"\\s";let J="";for(let X=0;X<$.set.length;X++){let Q=$.set[X];J+=ZF0(Q)}let Y=`${$.not?"^":""}${J}`;return Z?Y:`[${Y}]`}d8.writeSetTokens=dx;function ZF0($){if($.type===kW.types.CHAR)return fW($.value);else if($.type===kW.types.RANGE)return`${fW($.from)}-${fW($.to)}`;return dx($,!0)}});var qF=S((nx)=>{Object.defineProperty(nx,"__esModule",{value:!0});nx.reconstruct=void 0;var $5=zZ(),OF=px(),cx=($)=>$.map(nx.reconstruct).join(""),ix=($)=>{if("options"in $)return $.options.map(cx).join("|");else if("stack"in $)return cx($.stack);else throw Error("options or stack must be Root or Group token")};nx.reconstruct=($)=>{switch($.type){case $5.types.ROOT:return ix($);case $5.types.CHAR:{let Z=String.fromCharCode($.value);return(/[[\\{}$^.|?*+()]/.test(Z)?"\\":"")+Z}case $5.types.POSITION:if($.value==="^"||$.value==="$")return $.value;else return`\\${$.value}`;case $5.types.REFERENCE:return`\\${$.value}`;case $5.types.SET:return OF.writeSetTokens($);case $5.types.GROUP:return`(${$.name?`?<${$.name}>`:$.remember?"":$.followedBy?"?=":$.notFollowedBy?"?!":"?:"}${ix($)})`;case $5.types.REPETITION:{let{min:Z,max:J}=$,Y;if(Z===0&&J===1)Y="?";else if(Z===1&&J===1/0)Y="+";else if(Z===0&&J===1/0)Y="*";else if(J===1/0)Y=`{${Z},}`;else if(Z===J)Y=`{${Z}}`;else Y=`{${Z},${J}}`;return`${nx.reconstruct($.value)}${Y}`}case $5.types.RANGE:return`${OF.setChar($.from)}-${OF.setChar($.to)}`;default:throw Error(`Invalid token type ${$}`)}}});var NF=S((p8,yW)=>{var JF0=p8&&p8.__createBinding||(Object.create?function($,Z,J,Y){if(Y===void 0)Y=J;Object.defineProperty($,Y,{enumerable:!0,get:function(){return Z[J]}})}:function($,Z,J,Y){if(Y===void 0)Y=J;$[Y]=Z[J]}),jF=p8&&p8.__exportStar||function($,Z){for(var J in $)if(J!=="default"&&!Object.prototype.hasOwnProperty.call(Z,J))JF0(Z,$,J)};Object.defineProperty(p8,"__esModule",{value:!0});p8.types=void 0;var ox=zZ();Object.defineProperty(p8,"types",{enumerable:!0,get:function(){return ox.types}});jF(AF(),p8);jF(qF(),p8);var sx=AF(),YF0=qF();jF(zZ(),p8);p8.default=sx.tokenizer;yW.exports=sx.tokenizer;yW.exports.types=ox.types;yW.exports.reconstruct=YF0.reconstruct});var rx=S((Ex0,xW)=>{var XF0=NF(),{types:QF0}=NF();function MF($,Z,J){let Y,X,Q;if($.type===QF0.REPETITION){if(J++,Z.reps++,J>1)return!1;if(Z.reps>Z.limit)return!1}let G=$.options||$.value?.options;if(G){for(Y=0,Q=G.length;Y<Q;Y++)if(X=MF({stack:G[Y]},Z,J),!X)return!1}let W=$.stack||$.value?.stack;if(!W)return!0;for(Y=0,Q=W.length;Y<Q;Y++)if(X=MF(W[Y],Z,J),!X)return!1;return!0}function DF($,Z){let J={reps:0,limit:Z?.limit??25};if(GF0($))$=$.source;else if(typeof $!=="string")$=String($);try{return MF(XF0($),J,0)}catch{return!1}}function GF0($){return Object.prototype.toString.call($)==="[object RegExp]"}xW.exports=DF;xW.exports.default=DF;xW.exports.safeRegex=DF});var hW=S((bx0,ax)=>{ax.exports={name:"__fmw_internal_strategy_merged_tree_http_method__",storage:function(){let $=new Map;return{get:(Z)=>{return $.get(Z)||null},set:(Z,J)=>{$.set(Z,J)}}},deriveConstraint:($)=>$.method,mustMatchWhenDerived:!0}});var Xh=S((_x0,Yh)=>{var tx=aX(),ex=hW(),$h=Symbol("treeData");function Zh($,Z=""){let J="",Y=Object.keys($);for(let X=0;X<Y.length;X++){let Q=Y[X],G=$[Q],W=X===Y.length-1,K=W?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",V=W?" ":"\u2502 ",H=(G[$h]||"").replaceAll(`
423
- `,`
424
- `+Z+V);J+=Z+K+Q+H+`
425
- `,J+=Zh(G,Z+V)}return J}function WF0($){let Z=$.name||"";return Z=Z.replace("bound","").trim(),Z=(Z||"anonymous")+"()",Z}function Jh($){if(Array.isArray($))return $.map((Z)=>Jh(Z));if(typeof $==="symbol")return $.toString();if(typeof $==="function")return WF0($);return $}function KF0($,Z){if(!Z.includeMeta)return{};let J=Z.buildPrettyMeta($),Y={},X=Z.includeMeta;if(!Array.isArray(X))X=Reflect.ownKeys(J);for(let Q of X){if(!Object.prototype.hasOwnProperty.call(J,Q))continue;let G=Q.toString(),W=J[Q];if(W!==void 0&&W!==null){let K=JSON.stringify(Jh(W));Y[G]=K}}return Y}function VF0($){let Z="";for(let[J,Y]of Object.entries($))Z+=`
426
- \u2022 (${J}) ${Y}`;return Z}function UF0($){let Z={...$.opts.constraints},J=Z[ex.name];return delete Z[ex.name],{...$,method:J,opts:{constraints:Z}}}function HF0($){let Z=` (${$.method})`,J=$.opts.constraints||{};if(Object.keys(J).length!==0)Z+=" "+JSON.stringify(J);return Z+=VF0($.metaData),Z}function BF0($){return $.reduce((Z,J)=>{for(let Y of Z)if(tx(J.opts.constraints,Y.opts.constraints)&&tx(J.metaData,Y.metaData))return Y.method+=", "+J.method,Z;return Z.push(J),Z},[])}function zF0($,Z,J){let Y=$.routes;if(J.method===void 0)Y=Y.map(UF0);if(Y=Y.map((X)=>{return X.metaData=KF0(X,J),X}),J.method===void 0)Y=BF0(Y);return Y.map(HF0).join(`
427
- ${Z}`)}function gW($,Z,J,Y){if($.isLeafNode||Y.commonPrefix!==!1){if(J=J||"(empty root node)",Z=Z[J]={},$.isLeafNode)Z[$h]=zF0($,J,Y);J=""}if($.staticChildren)for(let X of Object.values($.staticChildren))gW(X,Z,J+X.prefix,Y);if($.parametricChildren)for(let X of Object.values($.parametricChildren)){let Q=Array.from(X.nodePaths).join("|");gW(X,Z,J+Q,Y)}if($.wildcardChild)gW($.wildcardChild,Z,"*",Y)}function FF0($,Z){let J={};return gW($,J,$.prefix,Z),Zh(J)}Yh.exports={prettyPrintTree:FF0}});var Wh=S((Sx0,Gh)=>{var Qh=function(){};Qh.prototype=Object.create(null);Gh.exports={NullObject:Qh}});var Uh=S((fx0,Vh)=>{var{NullObject:AF0}=Wh(),OF0=hW();class Kh{constructor(){this.unconstrainedHandler=null,this.constraints=[],this.handlers=[],this.constrainedHandlerStores=null}getMatchingHandler($){if($===void 0)return this.unconstrainedHandler;return this._getHandlerMatchingConstraints($)}addHandler($,Z){let J=Z.params,Y=Z.opts.constraints||{},X={params:J,constraints:Y,handler:Z.handler,store:Z.store||null,_createParamsObject:this._compileCreateParamsObject(J)},Q=Object.keys(Y);if(Q.length===0)this.unconstrainedHandler=X;for(let W of Q)if(!this.constraints.includes(W))if(W==="version")this.constraints.unshift(W);else this.constraints.push(W);let G=Q.includes(OF0.name);if(!G&&this.handlers.length>=31)throw Error("find-my-way supports a maximum of 31 route handlers per node when there are constraints, limit reached");if(this.handlers.push(X),this.handlers.sort((W,K)=>Object.keys(W.constraints).length-Object.keys(K.constraints).length),!G)this._compileGetHandlerMatchingConstraints($,Y)}_compileCreateParamsObject($){let Z=[];Z.push("const fn = function _createParamsObject (paramsArray) {"),Z.push("const params = new NullObject()");for(let J=0;J<$.length;J++)Z.push(`params['${$[J]}'] = paramsArray[${J}]`);return Z.push("return params"),Z.push("}"),Z.push("return fn"),Function("NullObject",Z.join(`
428
- `))(AF0)}_getHandlerMatchingConstraints(){return null}_buildConstraintStore($,Z){for(let J=0;J<this.handlers.length;J++){let X=this.handlers[J].constraints[Z];if(X!==void 0){let Q=$.get(X)||0;Q|=1<<J,$.set(X,Q)}}}_constrainedIndexBitmask($){let Z=0;for(let J=0;J<this.handlers.length;J++)if(this.handlers[J].constraints[$]!==void 0)Z|=1<<J;return~Z}_compileGetHandlerMatchingConstraints($){this.constrainedHandlerStores={};for(let J of this.constraints){let Y=$.newStoreForConstraint(J);this.constrainedHandlerStores[J]=Y,this._buildConstraintStore(Y,J)}let Z=[];Z.push(`
429
- let candidates = ${(1<<this.handlers.length)-1}
430
- let mask, matches
431
- `);for(let J of this.constraints){Z.push(`
432
- mask = ${this._constrainedIndexBitmask(J)}
433
- value = derivedConstraints.${J}
434
- `);let X=$.strategies[J].mustMatchWhenDerived?"matches":"(matches | mask)";Z.push(`
435
- if (value === undefined) {
436
- candidates &= mask
437
- } else {
438
- matches = this.constrainedHandlerStores.${J}.get(value) || 0
439
- candidates &= ${X}
440
- }
441
- if (candidates === 0) return null;
442
- `)}for(let J in $.strategies){if(!Object.hasOwn($.strategies,J))continue;if($.strategies[J].mustMatchWhenDerived&&!this.constraints.includes(J))Z.push(`if (derivedConstraints.${J} !== undefined) return null`)}Z.push("return this.handlers[31 - Math.clz32(candidates)]"),this._getHandlerMatchingConstraints=Function("derivedConstraints",Z.join(`
443
- `))}}Vh.exports=Kh});var Bh=S((kx0,Hh)=>{var qF0=Uh(),uW={STATIC:0,PARAMETRIC:1,WILDCARD:2};class wF{constructor(){this.isLeafNode=!1,this.routes=null,this.handlerStorage=null}addRoute($,Z){if(this.routes===null)this.routes=[];if(this.handlerStorage===null)this.handlerStorage=new qF0;this.isLeafNode=!0,this.routes.push($),this.handlerStorage.addHandler(Z,$)}}class LF extends wF{constructor(){super();this.staticChildren={}}findStaticMatchingChild($,Z){let J=this.staticChildren[$.charAt(Z)];if(J===void 0||!J.matchPrefix($,Z))return null;return J}getStaticChild($,Z=0){if($.length===Z)return this;let J=this.findStaticMatchingChild($,Z);if(J)return J.getStaticChild($,Z+J.prefix.length);return null}createStaticChild($){if($.length===0)return this;let Z=this.staticChildren[$.charAt(0)];if(Z){let Y=1;for(;Y<Z.prefix.length;Y++)if($.charCodeAt(Y)!==Z.prefix.charCodeAt(Y)){Z=Z.split(this,Y);break}return Z.createStaticChild($.slice(Y))}let J=$.charAt(0);return this.staticChildren[J]=new mW($),this.staticChildren[J]}}class mW extends LF{constructor($){super();this.prefix=$,this.wildcardChild=null,this.parametricChildren=[],this.kind=uW.STATIC,this._compilePrefixMatch()}getParametricChild($){let Z=$&&$.source,J=this.parametricChildren.find((Y)=>{return(Y.regex&&Y.regex.source)===Z});if(J)return J;return null}createParametricChild($,Z,J){let Y=this.getParametricChild($);if(Y)return Y.nodePaths.add(J),Y;return Y=new TF($,Z,J),this.parametricChildren.push(Y),this.parametricChildren.sort((X,Q)=>{if(!X.isRegex)return 1;if(!Q.isRegex)return-1;if(X.staticSuffix===null)return 1;if(Q.staticSuffix===null)return-1;if(Q.staticSuffix.endsWith(X.staticSuffix))return 1;if(X.staticSuffix.endsWith(Q.staticSuffix))return-1;return 0}),Y}getWildcardChild(){return this.wildcardChild}createWildcardChild(){return this.wildcardChild=this.getWildcardChild()||new RF,this.wildcardChild}split($,Z){let J=this.prefix.slice(0,Z),Y=this.prefix.slice(Z);this.prefix=Y,this._compilePrefixMatch();let X=new mW(J);return X.staticChildren[Y.charAt(0)]=this,$.staticChildren[J.charAt(0)]=X,X}getNextNode($,Z,J,Y){let X=this.findStaticMatchingChild($,Z),Q=0;if(X===null){if(this.parametricChildren.length===0)return this.wildcardChild;X=this.parametricChildren[0],Q=1}if(this.wildcardChild!==null)J.push({paramsCount:Y,brotherPathIndex:Z,brotherNode:this.wildcardChild});for(let G=this.parametricChildren.length-1;G>=Q;G--)J.push({paramsCount:Y,brotherPathIndex:Z,brotherNode:this.parametricChildren[G]});return X}_compilePrefixMatch(){if(this.prefix.length===1){this.matchPrefix=()=>!0;return}let $=[];for(let Z=1;Z<this.prefix.length;Z++){let J=this.prefix.charCodeAt(Z);$.push(`path.charCodeAt(i + ${Z}) === ${J}`)}this.matchPrefix=Function("path","i",`return ${$.join(" && ")}`)}}class TF extends LF{constructor($,Z,J){super();this.isRegex=!!$,this.regex=$||null,this.staticSuffix=Z||null,this.kind=uW.PARAMETRIC,this.nodePaths=new Set([J])}getNextNode($,Z){return this.findStaticMatchingChild($,Z)}}class RF extends wF{constructor(){super();this.kind=uW.WILDCARD}getNextNode(){return null}}Hh.exports={StaticNode:mW,ParametricNode:TF,WildcardNode:RF,NODE_TYPES:uW}});var Fh=S((vx0,zh)=>{var jF0=Y0("assert");function _Q(){if(!(this instanceof _Q))return new _Q;this.store=new Map,this.maxMajor=0,this.maxMinors={},this.maxPatches={}}_Q.prototype.set=function($,Z){if(typeof $!=="string")throw TypeError("Version should be a string");let[J,Y,X]=$.split(".",3);if(isNaN(J))throw TypeError("Major version must be a numeric value");if(J=Number(J),Y=Number(Y)||0,X=Number(X)||0,J>=this.maxMajor)this.maxMajor=J,this.store.set("x",Z),this.store.set("*",Z),this.store.set("x.x",Z),this.store.set("x.x.x",Z);if(Y>=(this.maxMinors[J]||0))this.maxMinors[J]=Y,this.store.set(`${J}.x`,Z),this.store.set(`${J}.x.x`,Z);if(X>=(this.maxPatches[`${J}.${Y}`]||0))this.maxPatches[`${J}.${Y}`]=X,this.store.set(`${J}.${Y}.x`,Z);return this.store.set(`${J}.${Y}.${X}`,Z),this};_Q.prototype.get=function($){return this.store.get($)};zh.exports={name:"version",mustMatchWhenDerived:!0,storage:_Q,validate($){jF0(typeof $==="string","Version should be a string")}}});var Oh=S((yx0,Ah)=>{var NF0=Y0("assert");function MF0(){let $=new Map,Z=[];return{get:(J)=>{let Y=$.get(J);if(Y)return Y;for(let X of Z)if(X.host.test(J))return X.value},set:(J,Y)=>{if(J instanceof RegExp)Z.push({host:J,value:Y});else $.set(J,Y)}}}Ah.exports={name:"host",mustMatchWhenDerived:!1,storage:MF0,validate($){NF0(typeof $==="string"||Object.prototype.toString.call($)==="[object RegExp]","Host should be a string or a RegExp")}}});var Nh=S((xx0,jh)=>{var DF0=Fh(),wF0=Oh(),PF=Y0("assert");class qh{constructor($){if(this.strategies={version:DF0,host:wF0},this.strategiesInUse=new Set,this.asyncStrategiesInUse=new Set,$)for(let Z of Object.values($))this.addConstraintStrategy(Z)}isStrategyUsed($){return this.strategiesInUse.has($)||this.asyncStrategiesInUse.has($)}hasConstraintStrategy($){let Z=this.strategies[$];if(Z!==void 0)return Z.isCustom||this.isStrategyUsed($);return!1}addConstraintStrategy($){if(PF(typeof $.name==="string"&&$.name!=="","strategy.name is required."),PF($.storage&&typeof $.storage==="function","strategy.storage function is required."),PF($.deriveConstraint&&typeof $.deriveConstraint==="function","strategy.deriveConstraint function is required."),this.strategies[$.name]&&this.strategies[$.name].isCustom)throw Error(`There already exists a custom constraint with the name ${$.name}.`);if(this.isStrategyUsed($.name))throw Error(`There already exists a route with ${$.name} constraint.`);if($.isCustom=!0,$.isAsync=$.deriveConstraint.length===3,this.strategies[$.name]=$,$.mustMatchWhenDerived)this.noteUsage({[$.name]:$})}deriveConstraints($,Z,J){let Y=this.deriveSyncConstraints($,Z);if(J===void 0)return Y;this.deriveAsyncConstraints(Y,$,Z,J)}deriveSyncConstraints($,Z){return}noteUsage($){if($){let Z=this.strategiesInUse.size;for(let J in $){if(!Object.hasOwn($,J))continue;if(this.strategies[J].isAsync)this.asyncStrategiesInUse.add(J);else this.strategiesInUse.add(J)}if(Z!==this.strategiesInUse.size)this._buildDeriveConstraints()}}newStoreForConstraint($){if(!this.strategies[$])throw Error(`No strategy registered for constraint key ${$}`);return this.strategies[$].storage()}validateConstraints($){for(let Z in $){if(!Object.hasOwn($,Z))continue;let J=$[Z];if(typeof J>"u")throw Error("Can't pass an undefined constraint value, must pass null or no key at all");let Y=this.strategies[Z];if(!Y)throw Error(`No strategy registered for constraint key ${Z}`);if(Y.validate)Y.validate(J)}}deriveAsyncConstraints($,Z,J,Y){let X=this.asyncStrategiesInUse.size;if(X===0){Y(null,$);return}$=$||{};for(let Q of this.asyncStrategiesInUse)this.strategies[Q].deriveConstraint(Z,J,(W,K)=>{if(W!==null){Y(W);return}if($[Q]=K,--X===0)Y(null,$)})}_buildDeriveConstraints(){if(this.strategiesInUse.size===0)return;let $=["return {"];for(let Z of this.strategiesInUse){let J=this.strategies[Z];if(!J.isCustom)if(Z==="version")$.push(" version: req.headers['accept-version'],");else $.push(" host: req.headers.host || req.headers[':authority'],");else $.push(` ${J.name}: this.strategies.${Z}.deriveConstraint(req, ctx),`)}$.push("}"),this.deriveSyncConstraints=Function("req","ctx",$.join(`
444
- `)).bind(this)}}jh.exports=qh});var Dh=S((hx0,Mh)=>{var LF0=["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","QUERY","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE"];Mh.exports=LF0});var Th=S((gx0,Lh)=>{function wh($,Z){if($===50){if(Z===53)return"%";if(Z===51)return"#";if(Z===52)return"$";if(Z===54)return"&";if(Z===66)return"+";if(Z===98)return"+";if(Z===67)return",";if(Z===99)return",";if(Z===70)return"/";if(Z===102)return"/";return null}if($===51){if(Z===65)return":";if(Z===97)return":";if(Z===66)return";";if(Z===98)return";";if(Z===68)return"=";if(Z===100)return"=";if(Z===70)return"?";if(Z===102)return"?";return null}if($===52&&Z===48)return"@";return null}function TF0($,Z){let J=!1,Y=!1,X="";for(let G=1;G<$.length;G++){let W=$.charCodeAt(G);if(W===37){let K=$.charCodeAt(G+1),V=$.charCodeAt(G+2);if(wh(K,V)===null)J=!0;else{if(Y=!0,K===50&&V===53)J=!0,$=$.slice(0,G+1)+"25"+$.slice(G+1),G+=2;G+=2}}else if(W===63||W===35||W===59&&Z){X=$.slice(G+1),$=$.slice(0,G);break}}return{path:J?decodeURI($):$,querystring:X,shouldDecodeParam:Y}}function RF0($){let Z=$.indexOf("%");if(Z===-1)return $;let J="",Y=Z;for(let X=Z;X<$.length;X++)if($.charCodeAt(X)===37){let Q=$.charCodeAt(X+1),G=$.charCodeAt(X+2),W=wh(Q,G);J+=$.slice(Y,X)+W,Y=X+3}return $.slice(0,Z)+J+$.slice(Y)}Lh.exports={safeDecodeURI:TF0,safeDecodeURIComponent:RF0}});var bF=S((ux0,kh)=>{var K$=Y0("assert"),PF0=Tx(),QY=rx(),EF=aX(),{prettyPrintTree:IF0}=Xh(),{StaticNode:Rh,NODE_TYPES:Ph}=Bh(),CF0=Nh(),XY=Dh(),IF=hW(),{safeDecodeURI:Ih,safeDecodeURIComponent:CF}=Th(),Ch=/^https?:\/\/.*?\//,H7=/(\/:[^/()]*?)\?(\/?)/,Eh=/[.*+?^${}()|[\]\\]/g,bh=/\/\/+/g;if(!QY(Ch))throw Error("the FULL_PATH_REGEXP is not safe, update this module");if(!QY(H7))throw Error("the OPTIONAL_PARAM_REGEXP is not safe, update this module");if(!QY(Eh))throw Error("the ESCAPE_REGEXP is not safe, update this module");if(!QY(bh))throw Error("the REMOVE_DUPLICATE_SLASHES_REGEXP is not safe, update this module");function u1($){if(!(this instanceof u1))return new u1($);if($=$||{},this._opts=$,$.defaultRoute)K$(typeof $.defaultRoute==="function","The default route must be a function"),this.defaultRoute=$.defaultRoute;else this.defaultRoute=null;if($.onBadUrl)K$(typeof $.onBadUrl==="function","The bad url handler must be a function"),this.onBadUrl=$.onBadUrl;else this.onBadUrl=null;if($.buildPrettyMeta)K$(typeof $.buildPrettyMeta==="function","buildPrettyMeta must be a function"),this.buildPrettyMeta=$.buildPrettyMeta;else this.buildPrettyMeta=EF0;if($.querystringParser)K$(typeof $.querystringParser==="function","querystringParser must be a function"),this.querystringParser=$.querystringParser;else this.querystringParser=(Z)=>Z.length===0?{}:PF0.parse(Z);this.caseSensitive=$.caseSensitive===void 0?!0:$.caseSensitive,this.ignoreTrailingSlash=$.ignoreTrailingSlash||!1,this.ignoreDuplicateSlashes=$.ignoreDuplicateSlashes||!1,this.maxParamLength=$.maxParamLength||100,this.onMaxParamLength=$.onMaxParamLength||null,this.allowUnsafeRegex=$.allowUnsafeRegex||!1,this.constrainer=new CF0($.constraints),this.useSemicolonDelimiter=$.useSemicolonDelimiter||!1,this.routes=[],this.trees={}}u1.prototype.on=function(Z,J,Y,X,Q){if(typeof Y==="function"){if(X!==void 0)Q=X;X=Y,Y={}}K$(typeof J==="string","Path should be a string"),K$(J.length>0,"The path could not be empty"),K$(J[0]==="/"||J[0]==="*","The first character of a path should be `/` or `*`"),K$(typeof X==="function","Handler should be a function");let G=J.match(H7);if(G){K$(J.length===G.index+G[0].length,"Optional Parameter needs to be the last parameter of the path");let V=J.replace(H7,"$1$2"),U=J.replace(H7,"$2")||"/";this.on(Z,V,Y,X,Q),this.on(Z,U,Y,X,Q);return}let W=J;if(this.ignoreDuplicateSlashes)J=lW(J);if(this.ignoreTrailingSlash)J=dW(J);let K=Array.isArray(Z)?Z:[Z];for(let V of K)K$(typeof V==="string","Method should be a string"),K$(XY.includes(V),`Method '${V}' is not an http method.`),this._on(V,J,Y,X,Q,W)};u1.prototype._on=function(Z,J,Y,X,Q){let G={};if(Y.constraints!==void 0){if(K$(typeof Y.constraints==="object"&&Y.constraints!==null,"Constraints should be an object"),Object.keys(Y.constraints).length!==0)G=Y.constraints}if(this.constrainer.validateConstraints(G),this.constrainer.noteUsage(G),this.trees[Z]===void 0)this.trees[Z]=new Rh("/");let W=J;if(W==="*"&&this.trees[Z].prefix.length!==0){let B=this.trees[Z];this.trees[Z]=new Rh(""),this.trees[Z].staticChildren["/"]=B}let K=this.trees[Z],V=K.prefix.length,U=[];for(let B=0;B<=W.length;B++){if(W.charCodeAt(B)===58&&W.charCodeAt(B+1)===58){B++;continue}let z=W.charCodeAt(B)===58&&W.charCodeAt(B+1)!==58,F=W.charCodeAt(B)===42;if(z||F||B===W.length&&B!==V){let A=W.slice(V,B);if(!this.caseSensitive)A=A.toLowerCase();A=A.replaceAll("::",":"),A=A.replaceAll("%","%25"),K=K.createStaticChild(A)}if(z){let A=!1,j=!0,N="",L=[],q=B+1;for(let M=q;;M++){let C=W.charCodeAt(M),R=C===40,w=C===45||C===46,I=C===47||M===W.length;if(R||w||I){let _=W.slice(q,M);if(U.push(_),A=A||R||w,R){let b=fh(W,M),y=W.slice(M,b+1);if(!this.allowUnsafeRegex)K$(QY(new RegExp(y)),`The regex '${y}' is not safe!`);L.push(Sh(y)),M=b+1,j=!0}else L.push(j?"(.*?)":`(${N}|(?:(?!${N}).)*)`),j=!1;let E=M;for(;M<W.length;M++){let b=W.charCodeAt(M);if(b===47)break;if(b===58)if(W.charCodeAt(M+1)===58)M++;else break}let f=W.slice(E,M);if(f)f=f.replaceAll("::",":"),f=f.replaceAll("%","%25"),L.push(N=_h(f));if(q=M+1,I||W.charCodeAt(M)===47||M===W.length){let b=A?"()"+f:f,y=W.slice(B,M);W=W.slice(0,B+1)+b+W.slice(M),B+=b.length;let k=A?new RegExp("^"+L.join("")+"$"):null;K=K.createParametricChild(k,f||null,y),V=B+1;break}}}}else if(F){if(U.push("*"),K=K.createWildcardChild(),V=B+1,B!==W.length-1)throw Error("Wildcard must be the last character in the route")}}if(!this.caseSensitive)W=W.toLowerCase();if(W==="*")W="/*";for(let B of this.routes){let z=B.opts.constraints||{};if(B.method===Z&&B.pattern===W&&EF(z,G))throw Error(`Method '${Z}' already declared for route '${W}' with constraints '${JSON.stringify(G)}'`)}let H={method:Z,path:J,pattern:W,params:U,opts:Y,handler:X,store:Q};this.routes.push(H),K.addRoute(H,this.constrainer)};u1.prototype.hasRoute=function(Z,J,Y){return this.findRoute(Z,J,Y)!==null};u1.prototype.findRoute=function(Z,J,Y={}){if(this.trees[Z]===void 0)return null;let X=J,Q=this.trees[Z],G=Q.prefix.length,W=[];for(let K=0;K<=X.length;K++){if(X.charCodeAt(K)===58&&X.charCodeAt(K+1)===58){K++;continue}let V=X.charCodeAt(K)===58&&X.charCodeAt(K+1)!==58,U=X.charCodeAt(K)===42;if(V||U||K===X.length&&K!==G){let H=X.slice(G,K);if(!this.caseSensitive)H=H.toLowerCase();if(H=H.replaceAll("::",":"),H=H.replaceAll("%","%25"),Q=Q.getStaticChild(H),Q===null)return null}if(V){let H=!1,B=!0,z="",F=[],A=K+1;for(let j=A;;j++){let N=X.charCodeAt(j),L=N===40,q=N===45||N===46,M=N===47||j===X.length;if(L||q||M){let C=X.slice(A,j);if(W.push(C),H=H||L||q,L){let I=fh(X,j),_=X.slice(j,I+1);if(!this.allowUnsafeRegex)K$(QY(new RegExp(_)),`The regex '${_}' is not safe!`);F.push(Sh(_)),j=I+1,B=!1}else F.push(B?"(.*?)":`(${z}|(?:(?!${z}).)*)`),B=!1;let R=j;for(;j<X.length;j++){let I=X.charCodeAt(j);if(I===47)break;if(I===58)if(X.charCodeAt(j+1)===58)j++;else break}let w=X.slice(R,j);if(w)w=w.replaceAll("::",":"),w=w.replaceAll("%","%25"),F.push(z=_h(w));if(A=j+1,M||X.charCodeAt(j)===47||j===X.length){let I=H?"()"+w:w,_=X.slice(K,j);X=X.slice(0,K+1)+I+X.slice(j),K+=I.length;let E=H?new RegExp("^"+F.join("")+"$"):null;if(Q=Q.getParametricChild(E,w||null,_),Q===null)return null;G=K+1;break}}}}else if(U){if(W.push("*"),Q=Q.getWildcardChild(),G=K+1,K!==X.length-1)throw Error("Wildcard must be the last character in the route")}}if(!this.caseSensitive)X=X.toLowerCase();for(let K of this.routes){let V=K.opts.constraints||{};if(K.method===Z&&K.pattern===X&&EF(V,Y))return{handler:K.handler,store:K.store,params:K.params}}return null};u1.prototype.hasConstraintStrategy=function($){return this.constrainer.hasConstraintStrategy($)};u1.prototype.addConstraintStrategy=function($){this.constrainer.addConstraintStrategy($),this._rebuild(this.routes)};u1.prototype.reset=function(){this.trees={},this.routes=[]};u1.prototype.off=function(Z,J,Y){K$(typeof J==="string","Path should be a string"),K$(J.length>0,"The path could not be empty"),K$(J[0]==="/"||J[0]==="*","The first character of a path should be `/` or `*`"),K$(typeof Y>"u"||typeof Y==="object"&&!Array.isArray(Y)&&Y!==null,"Constraints should be an object or undefined.");let X=J.match(H7);if(X){K$(J.length===X.index+X[0].length,"Optional Parameter needs to be the last parameter of the path");let G=J.replace(H7,"$1$2"),W=J.replace(H7,"$2");this.off(Z,G,Y),this.off(Z,W,Y);return}if(this.ignoreDuplicateSlashes)J=lW(J);if(this.ignoreTrailingSlash)J=dW(J);let Q=Array.isArray(Z)?Z:[Z];for(let G of Q)this._off(G,J,Y)};u1.prototype._off=function(Z,J,Y){K$(typeof Z==="string","Method should be a string"),K$(XY.includes(Z),`Method '${Z}' is not an http method.`);function X(K){return Z!==K.method||J!==K.path}function Q(K){return X(K)||!EF(Y,K.opts.constraints||{})}let G=Y?Q:X,W=this.routes.filter(G);this._rebuild(W)};u1.prototype.lookup=function(Z,J,Y,X){if(typeof Y==="function")X=Y,Y=void 0;if(X===void 0){let Q=this.constrainer.deriveConstraints(Z,Y),G=this.find(Z.method,Z.url,Q);return this.callHandler(G,Z,J,Y)}this.constrainer.deriveConstraints(Z,Y,(Q,G)=>{if(Q!==null){X(Q);return}try{let W=this.find(Z.method,Z.url,G),K=this.callHandler(W,Z,J,Y);X(null,K)}catch(W){X(W)}})};u1.prototype.callHandler=function(Z,J,Y,X){if(Z===null)return this._defaultRoute(J,Y,X);return X===void 0?Z.handler(J,Y,Z.params,Z.store,Z.searchParams):Z.handler.call(X,J,Y,Z.params,Z.store,Z.searchParams)};u1.prototype.find=function(Z,J,Y){let X=this.trees[Z];if(X===void 0)return null;if(J.charCodeAt(0)!==47)J=J.replace(Ch,"/");if(this.ignoreDuplicateSlashes)J=lW(J);let Q,G,W;try{Q=Ih(J,this.useSemicolonDelimiter),J=Q.path,G=Q.querystring,W=Q.shouldDecodeParam}catch(A){return this._onBadUrl(J)}if(this.ignoreTrailingSlash)J=dW(J);let K=J;if(this.caseSensitive===!1)J=J.toLowerCase();let V=this.maxParamLength,U=X.prefix.length,H=[],B=J.length,z=[],F=!1;while(!0){if(U===B&&X.isLeafNode){let L=X.handlerStorage.getMatchingHandler(Y);if(L!==null)return{handler:L.handler,store:L.store,params:L._createParamsObject(H),searchParams:this.querystringParser(G)}}let A=X.getNextNode(J,U,z,H.length);if(A===null){if(z.length===0){if(F&&this.onMaxParamLength)return this._onMaxParamLength(K);return null}let L=z.pop();U=L.brotherPathIndex,H.splice(L.paramsCount),A=L.brotherNode}if(X=A,X.kind===Ph.STATIC){U+=X.prefix.length;continue}if(X.kind===Ph.WILDCARD){let L=K.slice(U);if(W)L=CF(L);H.push(L),U=B;continue}let j=K.indexOf("/",U);if(j===-1)j=B;let N=K.slice(U,j);if(W)N=CF(N);if(X.isRegex){let L=X.regex.exec(N);if(L===null){A=null;continue}let q=!1;for(let M=1;M<L.length;M++)if(L[M].length>V){q=!0;break}if(q){F=!0,A=null;continue}for(let M=1;M<L.length;M++)H.push(L[M])}else{if(N.length>V){F=!0,A=null;continue}H.push(N)}U=j}};u1.prototype._rebuild=function($){this.reset();for(let Z of $){let{method:J,path:Y,opts:X,handler:Q,store:G}=Z;this._on(J,Y,X,Q,G)}};u1.prototype._defaultRoute=function($,Z,J){if(this.defaultRoute!==null)return J===void 0?this.defaultRoute($,Z):this.defaultRoute.call(J,$,Z);else Z.statusCode=404,Z.end()};u1.prototype._onBadUrl=function($){if(this.onBadUrl===null)return null;let Z=this.onBadUrl;return{handler:(J,Y,X)=>Z($,J,Y),params:{},store:null}};u1.prototype._onMaxParamLength=function($){if(this.onMaxParamLength===null)return null;let Z=this.onMaxParamLength;return{handler:(J,Y,X)=>Z($,J,Y),params:{},store:null}};u1.prototype.prettyPrint=function($={}){let Z=$.method;$.buildPrettyMeta=this.buildPrettyMeta.bind(this);let J=null;if(Z===void 0){let{version:Y,host:X,...Q}=this.constrainer.strategies;Q[IF.name]=IF;let G=new u1({...this._opts,constraints:Q}),W=this.routes.map((K)=>{let V={...K.opts.constraints,[IF.name]:K.method};return{...K,method:"MERGED",opts:{constraints:V}}});G._rebuild(W),J=G.trees.MERGED}else J=this.trees[Z];if(J==null)return"(empty tree)";return IF0(J,$)};for(let $ in XY){if(!XY.hasOwnProperty($))continue;let Z=XY[$],J=Z.toLowerCase();u1.prototype[J]=function(Y,X,Q){return this.on(Z,Y,X,Q)}}u1.prototype.all=function($,Z,J){this.on(XY,$,Z,J)};u1.sanitizeUrlPath=function(Z,J){let Y=Ih(Z,J);if(Y.shouldDecodeParam)return CF(Y.path);return Y.path};u1.removeDuplicateSlashes=lW;u1.trimLastSlash=dW;kh.exports=u1;function _h($){return $.replace(Eh,"\\$&")}function lW($){return $.indexOf("//")!==-1?$.replace(bh,"/"):$}function dW($){if($.length>1&&$.charCodeAt($.length-1)===47)return $.slice(0,-1);return $}function Sh($){if($.charCodeAt(1)===94)$=$.slice(0,1)+$.slice(2);if($.charCodeAt($.length-2)===36)$=$.slice(0,$.length-2)+$.slice($.length-1);return $}function fh($,Z){let J=1;while(Z<$.length){if(Z++,$.charCodeAt(Z)===92){Z++;continue}if($.charCodeAt(Z)===41)J--;else if($.charCodeAt(Z)===40)J++;if(!J)return Z}throw TypeError('Invalid regexp expression in "'+$+'"')}function EF0($){if(!$)return{};if(!$.store)return{};return Object.assign({},$.store)}});var yh=S((mx0,vh)=>{function _F($,Z,J,Y){if(J===void 0){Z.header("content-length","0"),Y(null,null);return}if(typeof J.resume==="function"){J.on("error",(Q)=>{Z.log.error({err:Q},"Error on Stream found for HEAD route")}),J.resume(),Y(null,null);return}if(typeof J.getReader==="function"){J.cancel("Stream cancelled by HEAD route").catch((Q)=>{Z.log.error({err:Q},"Error on Stream found for HEAD route")}),Y(null,null);return}let X=""+Buffer.byteLength(J);Z.header("content-length",X),Y(null,null)}function bF0($){if($==null)return _F;return Array.isArray($)?[...$,_F]:[$,_F]}vh.exports={parseHeadOnSendHandlers:bF0}});var Jg=S((lx0,Zg)=>{var _F0=bF(),SF0=IG(),xh=rH(),{onRequestAbortHookRunner:fF0,lifecycleHooks:hh,preParsingHookRunner:kF0,onTimeoutHookRunner:vF0,onRequestHookRunner:yF0}=uZ(),{normalizeSchema:xF0}=xX(),{parseHeadOnSendHandlers:hF0}=yh(),{compileSchemasForValidation:gF0,compileSchemasForSerialization:uF0}=iH(),{FST_ERR_SCH_VALIDATION_BUILD:mF0,FST_ERR_SCH_SERIALIZATION_BUILD:lF0,FST_ERR_DUPLICATED_ROUTE:dF0,FST_ERR_INVALID_URL:pF0,FST_ERR_HOOK_INVALID_HANDLER:gh,FST_ERR_ROUTE_OPTIONS_NOT_OBJ:cF0,FST_ERR_ROUTE_DUPLICATED_HANDLER:iF0,FST_ERR_ROUTE_HANDLER_NOT_FN:uh,FST_ERR_ROUTE_MISSING_HANDLER:nF0,FST_ERR_ROUTE_METHOD_NOT_SUPPORTED:oF0,FST_ERR_ROUTE_METHOD_INVALID:sF0,FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED:rF0,FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT:aF0,FST_ERR_ROUTE_HANDLER_TIMEOUT_OPTION_NOT_INT:tF0,FST_ERR_HANDLER_TIMEOUT:eF0,FST_ERR_HOOK_INVALID_ASYNC_HANDLER:SF}=L$(),{kRoutePrefix:$A0,kSupportedHTTPMethods:vF,kLogLevel:ZA0,kLogSerializers:mh,kHooks:lh,kSchemaController:JA0,kOptions:dh,kReplySerializerDefault:fF,kReplyIsError:eh,kRequestPayloadStream:YA0,kDisableRequestLogging:ph,kSchemaErrorFormatter:XA0,kErrorHandler:ch,kHasBeenDecorated:ih,kRequestAcceptVersion:kF,kRouteByFastify:QA0,kRouteContext:nh,kRequestSignal:GA0,kTimeoutTimer:oh,kOnAbort:WA0}=H$(),{buildErrorHandler:KA0}=hX(),{createChildLogger:VA0}=yX(),{getGenReqId:UA0}=IW(),{FSTDEP022:HA0}=wJ(),sh=["allowUnsafeRegex","buildPrettyMeta","caseSensitive","constraints","defaultRoute","ignoreDuplicateSlashes","ignoreTrailingSlash","maxParamLength","onBadUrl","querystringParser","useSemicolonDelimiter"];function BA0($){let Z=_F0($),J,Y,X,Q,G,W,K,V,U,H,B,z,F,A=!1;return{setup(I,_){if(J=_.avvio,Y=_.fourOhFour,X=I.logger,Q=_.hasLogger,G=_.setupResponseListeners,W=_.throwIfAlreadyStarted,z=I.exposeHeadRoutes,K=I.disableRequestLogging,typeof K==="function")V=I.disableRequestLogging;U=I.routerOptions.ignoreTrailingSlash,H=I.routerOptions.ignoreDuplicateSlashes,B=Object.hasOwn(I,"return503OnClosing")?I.return503OnClosing:!0,F=_.keepAliveConnections},routing:Z.lookup.bind(Z),route:R,hasRoute:M,prepareRoute:q,routeHandler:w,closeRoutes:()=>{A=!0},printRoutes:Z.prettyPrint.bind(Z),addConstraintStrategy:j,hasConstraintStrategy:N,isAsyncConstraint:L,findRoute:C};function j(I){return W("Cannot add constraint strategy!"),Z.addConstraintStrategy(I)}function N(I){return Z.hasConstraintStrategy(I)}function L(){return Z.constrainer.asyncStrategiesInUse.size>0}function q({method:I,url:_,options:E,handler:f,isFastify:b}){if(typeof _!=="string")throw new pF0(typeof _);if(!f&&typeof E==="function")f=E,E={};else if(f&&typeof f==="function"){if(Object.prototype.toString.call(E)!=="[object Object]")throw new cF0(I,_);else if(E.handler)if(typeof E.handler==="function")throw new iF0(I,_);else throw new uh(I,_)}return E=Object.assign({},E,{method:I,url:_,path:_,handler:f||E&&E.handler}),R.call(this,{options:E,isFastify:b})}function M({options:I}){let _=I.method?.toUpperCase()??"";return Z.hasRoute(_,I.url||"",I.constraints)}function C(I){let _=Z.find(I.method,I.url||"",I.constraints);if(_)return{handler:_.handler,params:_.params,searchParams:_.searchParams};else return null}function R({options:I,isFastify:_}){W("Cannot add route!");let E={...I},f=E.url||E.path||"";if(!E.handler)throw new nF0(E.method,f);if(E.errorHandler!==void 0&&typeof E.errorHandler!=="function")throw new uh(E.method,f);$g(E.bodyLimit),AA0(E.handlerTimeout);let b=E.exposeHeadRoute??z,y=!1,k=!1;if(Array.isArray(E.method))for(let t=0;t<E.method.length;++t)E.method[t]=rh.call(this,E.method[t]),ah.call(this,E.method[t],f,E.schema),y=E.method.includes("GET"),k=E.method.includes("HEAD");else E.method=rh.call(this,E.method),ah.call(this,E.method,f,E.schema),y=E.method==="GET",k=E.method==="HEAD";let g=b&&y?{...I}:null,d=this[$A0];if(f==="/"&&d.length>0&&E.method!=="HEAD")switch(E.prefixTrailingSlash){case"slash":p.call(this,{path:f,isFastify:_});break;case"no-slash":p.call(this,{path:"",isFastify:_});break;case"both":default:if(p.call(this,{path:"",isFastify:_}),U!==!0&&(H!==!0||!d.endsWith("/")))p.call(this,{path:f,prefixing:!0,isFastify:_})}else if(f[0]==="/"&&d.endsWith("/"))p.call(this,{path:f.slice(1),isFastify:_});else p.call(this,{path:f,isFastify:_});return this;function p({path:t,prefixing:r=!1,isFastify:G0=!1}){let O0=d+t;if(E.url=O0,E.path=O0,E.routePath=t,E.prefix=d,E.logLevel=E.logLevel||this[ZA0],this[mh]||E.logSerializers)E.logSerializers=Object.assign(Object.create(this[mh]),E.logSerializers);if(E.attachValidation==null)E.attachValidation=!1;if(r===!1)for(let h of this[lh].onRoute)h.call(this,E);for(let h of hh)if(E&&h in E){if(Array.isArray(E[h]))for(let c of E[h]){if(typeof c!=="function")throw new gh(h,Object.prototype.toString.call(c));if(h==="onSend"||h==="preSerialization"||h==="onError"||h==="preParsing"){if(c.constructor.name==="AsyncFunction"&&c.length===4)throw new SF}else if(h==="onRequestAbort"){if(c.constructor.name==="AsyncFunction"&&c.length!==1)throw new SF}else if(c.constructor.name==="AsyncFunction"&&c.length===3)throw new SF}else if(E[h]!==void 0&&typeof E[h]!=="function")throw new gh(h,Object.prototype.toString.call(E[h]))}let h0=E.constraints||{},u={...E.config,url:O0,method:E.method},l=new SF0({schema:E.schema,handler:E.handler.bind(this),config:u,errorHandler:E.errorHandler,childLoggerFactory:E.childLoggerFactory,bodyLimit:E.bodyLimit,logLevel:E.logLevel,logSerializers:E.logSerializers,attachValidation:E.attachValidation,schemaErrorFormatter:E.schemaErrorFormatter,replySerializer:this[fF],validatorCompiler:E.validatorCompiler,serializerCompiler:E.serializerCompiler,exposeHeadRoute:b,prefixTrailingSlash:E.prefixTrailingSlash||"both",server:this,isFastify:G0,handlerTimeout:E.handlerTimeout}),v=Z.findRoute("HEAD",E.url,h0)!==null;try{Z.on(E.method,E.url,{constraints:h0},w,l)}catch(h){if(!l[QA0]){if(h.message.includes(`Method '${E.method}' already declared for route`))throw new dF0(E.method,E.url);throw h}}if(this.after((h,c)=>{l.errorHandler=E.errorHandler?KA0(this[ch],E.errorHandler):this[ch],l._parserOptions.limit=E.bodyLimit||null,l.logLevel=E.logLevel,l.logSerializers=E.logSerializers,l.attachValidation=E.attachValidation,l[fF]=this[fF],l.schemaErrorFormatter=E.schemaErrorFormatter||this[XA0]||l.schemaErrorFormatter,J.once("preReady",()=>{for(let m of hh){let a=this[lh][m].concat(E[m]||[]).map((e)=>e.bind(this));l[m]=a.length?a:null}while(!l.Request[ih]&&l.Request.parent)l.Request=l.Request.parent;while(!l.Reply[ih]&&l.Reply.parent)l.Reply=l.Reply.parent;if(Y.setContext(this,l),E.schema){l.schema=xF0(l.schema,this.initialConfig);let m=this[JA0],a=E.schema.body||E.schema.headers||E.schema.querystring||E.schema.params;if(!E.validatorCompiler&&a)m.setupValidator(this[dh]);try{let e=typeof E?.validatorCompiler==="function"||m.isCustomValidatorCompiler;gF0(l,E.validatorCompiler||m.validatorCompiler,e)}catch(e){throw new mF0(E.method,O0,e.message)}if(E.schema.response&&!E.serializerCompiler)m.setupSerializer(this[dh]);try{uF0(l,E.serializerCompiler||m.serializerCompiler)}catch(e){throw new lF0(E.method,O0,e.message)}}}),c(h)}),b&&y&&!k&&!v){let h=hF0(g.onSend);q.call(this,{method:"HEAD",url:t,options:{...g,onSend:h},isFastify:!0})}}}function w(I,_,E,f,b){let y=UA0(f.server,I),k={level:f.logLevel};if(f.logSerializers)k.serializers=f.logSerializers;let g=VA0(f,X,I,y,k);if(g[ph]=V?!1:K,A===!0){if(I.httpVersionMajor!==2)_.setHeader("Connection","close");if(B){let O0={"Content-Type":"application/json","Content-Length":"80"};_.writeHead(503,O0),_.end('{"error":"Service Unavailable","message":"Service Unavailable","statusCode":503}'),g.info({res:{statusCode:503}},"request aborted - refusing to accept new requests as server is closing");return}}if(String.prototype.toLowerCase.call(I.headers.connection||"")==="keep-alive"){if(F.has(I.socket)===!1)F.add(I.socket),I.socket.on("close",qA0.bind({keepAliveConnections:F,socket:I.socket}))}if(I.headers[kF]!==void 0)I.headers["accept-version"]=I.headers[kF],I.headers[kF]=void 0;let p=new f.Request(y,E,I,b,g,f),t=new f.Reply(_,p,g),r=V?V(p):K;if(g[ph]=r,r===!1)g.info({req:p},"incoming request");let G0=f.handlerTimeout;if(G0>0){let O0=new AbortController;p[GA0]=O0,p[oh]=setTimeout(()=>{if(!t.sent){let u=new eF0(G0,f.config?.url);O0.abort(u),t[eh]=!0,t.send(u)}},G0);let h0=()=>{if(!O0.signal.aborted)O0.abort();clearTimeout(p[oh])};I.on("close",h0),p[WA0]=h0}if(Q===!0||f.onResponse!==null||G0>0)G(t);if(f.onRequest!==null)yF0(f.onRequest,p,t,th);else th(null,p,t);if(f.onRequestAbort!==null)I.on("close",()=>{if(I.aborted)fF0(f.onRequestAbort,p,zA0.bind(null,t))});if(f.onTimeout!==null){if(!p.raw.socket._meta)p.raw.socket.on("timeout",FA0);p.raw.socket._meta={context:f,request:p,reply:t}}}}function zA0($,Z){if(Z)$.log.error({err:Z},"onRequestAborted hook failed")}function FA0(){let{context:$,request:Z,reply:J}=this._meta;vF0($.onTimeout,Z,J,jA0)}function rh($){if(typeof $!=="string")throw new sF0;if($=$.toUpperCase(),!this[vF].bodyless.has($)&&!this[vF].bodywith.has($))throw new oF0($);return $}function ah($,Z,J){if(this[vF].bodyless.has($)&&J?.body)throw new rF0($,Z)}function $g($){if($===void 0)return;if(!Number.isInteger($)||$<=0)throw new aF0($)}function AA0($){if($===void 0)return;if(!Number.isInteger($)||$<=0)throw new tF0($)}function th($,Z,J){if(J.sent===!0)return;if($!=null){J[eh]=!0,J.send($);return}if(Z[YA0]=Z.raw,Z[nh].preParsing!==null)kF0(Z[nh].preParsing,Z,J,xh.bind(Z.server));else xh.call(Z.server,null,Z,J)}function OA0($,Z){let J=$.routerOptions==null?Object.create(null):Object.assign(Object.create(null),$.routerOptions),Y=sh.filter((X)=>Object.hasOwn($,X));if(Y.length>0)HA0(Y.join(", "));for(let X of sh)if(!Object.hasOwn(J,X))J[X]=$[X]??Z[X];return J}function qA0(){this.keepAliveConnections.delete(this.socket)}function jA0(){}Zg.exports={buildRouting:BA0,validateBodyLimitOption:$g,buildRouterOptions:OA0}});var Vg=S((dx0,Kg)=>{var NA0=bF(),Yg=MG(),Xg=PG(),MA0=IG(),{kRoutePrefix:DA0,kCanSetNotFoundHandler:SQ,kFourOhFourLevelInstance:fQ,kFourOhFourContext:S6,kHooks:wA0,kErrorHandler:Qg}=H$(),{lifecycleHooks:LA0}=uZ(),{buildErrorHandler:TA0}=hX(),{FST_ERR_NOT_FOUND:RA0}=L$(),{createChildLogger:Gg}=yX(),{getGenReqId:Wg}=IW();function PA0($){let{logger:Z,disableRequestLogging:J}=$,Y=NA0({onBadUrl:W(),defaultRoute:H}),X=null;return{router:Y,setNotFoundHandler:V,setContext:K,arrange404:Q};function Q(B){B[fQ]=B,B[SQ]=!0,Y.onBadUrl=Y.onBadUrl.bind(B),Y.defaultRoute=Y.defaultRoute.bind(B)}function G(B,z){let{url:F,method:A}=B.raw,j=`Route ${A}:${F} not found`;if(!(typeof J==="function"?J(B.raw):J))B.log.info(j);z.code(404).send({message:j,error:"Not Found",statusCode:404})}function W(){return function(z,F,A){let j=this[fQ][S6],N=Wg(j.server,F),L=Gg(j,Z,F,N),q=new Xg(N,null,F,null,L,j),M=new Yg(A,q,L);X(q,M)}}function K(B,z){let F=Object.assign({},B[S6]);F.onSend=z.onSend,z[S6]=F}function V(B,z,F,A){if(this[SQ]===void 0)this[SQ]=!0;if(this[S6]===void 0)this[S6]=null;let j=this,N=this[DA0]||"/";if(this[SQ]===!1)throw Error(`Not found handler already set for Fastify instance with prefix: '${N}'`);if(typeof B==="object"){if(B.preHandler)if(Array.isArray(B.preHandler))B.preHandler=B.preHandler.map((L)=>L.bind(j));else B.preHandler=B.preHandler.bind(j);if(B.preValidation)if(Array.isArray(B.preValidation))B.preValidation=B.preValidation.map((L)=>L.bind(j));else B.preValidation=B.preValidation.bind(j)}if(typeof B==="function")z=B,B=void 0;if(B=B||{},z)this[fQ][SQ]=!1,z=z.bind(this),X=z;else z=G,X=G;this.after((L,q)=>{U.call(this,N,B,z,F,A),q(L)})}function U(B,z,F,A,j){let N=new MA0({schema:z.schema,handler:F,config:z.config||{},server:this});if(A.once("preReady",()=>{let L=this[S6];for(let q of LA0){let M=this[wA0][q].concat(z[q]||[]).map((C)=>C.bind(this));L[q]=M.length?M:null}L.errorHandler=z.errorHandler?TA0(this[Qg],z.errorHandler):this[Qg]}),this[S6]!==null&&B==="/"){Object.assign(this[S6],N);return}this[fQ][S6]=N,Y.all(B+(B.endsWith("/")?"*":"/*"),j,N),Y.all(B,j,N)}function H(B,z){let F=this[fQ][S6],A=Wg(F.server,B),j=Gg(F,Z,B,A);j.info({req:B},"incoming request");let N=new Xg(A,null,B,null,j,F),L=new Yg(z,N,j);N.log.warn("the default handler for 404 did not catch this, this is likely a fastify bug, please report it"),N.log.warn(Y.prettyPrint()),L.code(404).send(new RA0)}}Kg.exports=PA0});var Ug=S((px0,pW)=>{pW.exports=B1;pW.exports.default=B1;var IA0={type:"object",additionalProperties:!1,properties:{connectionTimeout:{type:"integer",default:0},keepAliveTimeout:{type:"integer",default:72000},forceCloseConnections:{oneOf:[{type:"string",pattern:"idle"},{type:"boolean"}]},maxRequestsPerSocket:{type:"integer",default:0,nullable:!0},requestTimeout:{type:"integer",default:0},handlerTimeout:{type:"integer",default:0},bodyLimit:{type:"integer",default:1048576},caseSensitive:{type:"boolean",default:!0},allowUnsafeRegex:{type:"boolean",default:!1},http2:{type:"boolean"},https:{if:{not:{oneOf:[{type:"boolean"},{type:"null"},{type:"object",additionalProperties:!1,required:["allowHTTP1"],properties:{allowHTTP1:{type:"boolean"}}}]}},then:{setDefaultValue:!0}},ignoreTrailingSlash:{type:"boolean",default:!1},ignoreDuplicateSlashes:{type:"boolean",default:!1},disableRequestLogging:{default:!1},maxParamLength:{type:"integer",default:100},onProtoPoisoning:{type:"string",default:"error"},onConstructorPoisoning:{type:"string",default:"error"},pluginTimeout:{type:"integer",default:1e4},requestIdHeader:{anyOf:[{type:"boolean"},{type:"string"}],default:!1},requestIdLogLabel:{type:"string",default:"reqId"},http2SessionTimeout:{type:"integer",default:72000},exposeHeadRoutes:{type:"boolean",default:!0},useSemicolonDelimiter:{type:"boolean",default:!1},routerOptions:{type:"object",additionalProperties:!0,properties:{ignoreTrailingSlash:{type:"boolean",default:!1},ignoreDuplicateSlashes:{type:"boolean",default:!1},maxParamLength:{type:"integer",default:100},allowUnsafeRegex:{type:"boolean",default:!1},useSemicolonDelimiter:{type:"boolean",default:!1}}},constraints:{type:"object",additionalProperties:{type:"object",required:["name","storage","validate","deriveConstraint"],additionalProperties:!0,properties:{name:{type:"string"},storage:{},validate:{},deriveConstraint:{}}}}}},CA0=Object.prototype.hasOwnProperty,EA0=new RegExp("idle","u");function B1($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0;if(G===0)if($&&typeof $=="object"&&!Array.isArray($)){if($.connectionTimeout===void 0)$.connectionTimeout=0;if($.keepAliveTimeout===void 0)$.keepAliveTimeout=72000;if($.maxRequestsPerSocket===void 0)$.maxRequestsPerSocket=0;if($.requestTimeout===void 0)$.requestTimeout=0;if($.handlerTimeout===void 0)$.handlerTimeout=0;if($.bodyLimit===void 0)$.bodyLimit=1048576;if($.caseSensitive===void 0)$.caseSensitive=!0;if($.allowUnsafeRegex===void 0)$.allowUnsafeRegex=!1;if($.ignoreTrailingSlash===void 0)$.ignoreTrailingSlash=!1;if($.ignoreDuplicateSlashes===void 0)$.ignoreDuplicateSlashes=!1;if($.disableRequestLogging===void 0)$.disableRequestLogging=!1;if($.maxParamLength===void 0)$.maxParamLength=100;if($.onProtoPoisoning===void 0)$.onProtoPoisoning="error";if($.onConstructorPoisoning===void 0)$.onConstructorPoisoning="error";if($.pluginTimeout===void 0)$.pluginTimeout=1e4;if($.requestIdHeader===void 0)$.requestIdHeader=!1;if($.requestIdLogLabel===void 0)$.requestIdLogLabel="reqId";if($.http2SessionTimeout===void 0)$.http2SessionTimeout=72000;if($.exposeHeadRoutes===void 0)$.exposeHeadRoutes=!0;if($.useSemicolonDelimiter===void 0)$.useSemicolonDelimiter=!1;let A=G;for(let j in $)if(!CA0.call(IA0.properties,j))delete $[j];if(A===G){let j=$.connectionTimeout,N=G;if(!(typeof j=="number"&&(!(j%1)&&!isNaN(j))&&isFinite(j))){let L=typeof j,q=void 0;if(q===void 0)if(L==="boolean"||j===null||L==="string"&&j&&j==+j&&!(j%1))q=+j;else return B1.errors=[{instancePath:Z+"/connectionTimeout",schemaPath:"#/properties/connectionTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(q!==void 0){if(j=q,$!==void 0)$.connectionTimeout=q}}var W=N===G;if(W){let L=$.keepAliveTimeout,q=G;if(!(typeof L=="number"&&(!(L%1)&&!isNaN(L))&&isFinite(L))){let C=typeof L,R=void 0;if(R===void 0)if(C==="boolean"||L===null||C==="string"&&L&&L==+L&&!(L%1))R=+L;else return B1.errors=[{instancePath:Z+"/keepAliveTimeout",schemaPath:"#/properties/keepAliveTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(R!==void 0){if(L=R,$!==void 0)$.keepAliveTimeout=R}}var W=q===G;if(W){if($.forceCloseConnections!==void 0){let C=$.forceCloseConnections,R=G,w=G,I=!1,_=null,E=G;if(typeof C!=="string"){let y=typeof C,k=void 0;if(k===void 0)if(y=="number"||y=="boolean")k=""+C;else if(C===null)k="";else{let g={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[g];else Q.push(g);G++}if(k!==void 0){if(C=k,$!==void 0)$.forceCloseConnections=k}}if(G===E){if(typeof C==="string"){if(!EA0.test(C)){let y={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/0/pattern",keyword:"pattern",params:{pattern:"idle"},message:'must match pattern "idle"'};if(Q===null)Q=[y];else Q.push(y);G++}}}var K=E===G;if(K)I=!0,_=0;let f=G;if(typeof C!=="boolean"){let y=void 0;if(y===void 0)if(C==="false"||C===0||C===null)y=!1;else if(C==="true"||C===1)y=!0;else{let k={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf/1/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};if(Q===null)Q=[k];else Q.push(k);G++}if(y!==void 0){if(C=y,$!==void 0)$.forceCloseConnections=y}}var K=f===G;if(K&&I)I=!1,_=[_,1];else if(K)I=!0,_=1;if(!I){let y={instancePath:Z+"/forceCloseConnections",schemaPath:"#/properties/forceCloseConnections/oneOf",keyword:"oneOf",params:{passingSchemas:_},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[y];else Q.push(y);return G++,B1.errors=Q,!1}else if(G=w,Q!==null)if(w)Q.length=w;else Q=null;var W=R===G}else var W=!0;if(W){let C=$.maxRequestsPerSocket,R=G;if(!(typeof C=="number"&&(!(C%1)&&!isNaN(C))&&isFinite(C))&&C!==null){let I=typeof C,_=void 0;if(_===void 0)if(I==="boolean"||C===null||I==="string"&&C&&C==+C&&!(C%1))_=+C;else if(C===""||C===0||C===!1)_=null;else return B1.errors=[{instancePath:Z+"/maxRequestsPerSocket",schemaPath:"#/properties/maxRequestsPerSocket/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(_!==void 0){if(C=_,$!==void 0)$.maxRequestsPerSocket=_}}var W=R===G;if(W){let I=$.requestTimeout,_=G;if(!(typeof I=="number"&&(!(I%1)&&!isNaN(I))&&isFinite(I))){let f=typeof I,b=void 0;if(b===void 0)if(f==="boolean"||I===null||f==="string"&&I&&I==+I&&!(I%1))b=+I;else return B1.errors=[{instancePath:Z+"/requestTimeout",schemaPath:"#/properties/requestTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(b!==void 0){if(I=b,$!==void 0)$.requestTimeout=b}}var W=_===G;if(W){let f=$.handlerTimeout,b=G;if(!(typeof f=="number"&&(!(f%1)&&!isNaN(f))&&isFinite(f))){let k=typeof f,g=void 0;if(g===void 0)if(k==="boolean"||f===null||k==="string"&&f&&f==+f&&!(f%1))g=+f;else return B1.errors=[{instancePath:Z+"/handlerTimeout",schemaPath:"#/properties/handlerTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(g!==void 0){if(f=g,$!==void 0)$.handlerTimeout=g}}var W=b===G;if(W){let k=$.bodyLimit,g=G;if(!(typeof k=="number"&&(!(k%1)&&!isNaN(k))&&isFinite(k))){let p=typeof k,t=void 0;if(t===void 0)if(p==="boolean"||k===null||p==="string"&&k&&k==+k&&!(k%1))t=+k;else return B1.errors=[{instancePath:Z+"/bodyLimit",schemaPath:"#/properties/bodyLimit/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(t!==void 0){if(k=t,$!==void 0)$.bodyLimit=t}}var W=g===G;if(W){let p=$.caseSensitive,t=G;if(typeof p!=="boolean"){let G0=void 0;if(G0===void 0)if(p==="false"||p===0||p===null)G0=!1;else if(p==="true"||p===1)G0=!0;else return B1.errors=[{instancePath:Z+"/caseSensitive",schemaPath:"#/properties/caseSensitive/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(G0!==void 0){if(p=G0,$!==void 0)$.caseSensitive=G0}}var W=t===G;if(W){let G0=$.allowUnsafeRegex,O0=G;if(typeof G0!=="boolean"){let u=void 0;if(u===void 0)if(G0==="false"||G0===0||G0===null)u=!1;else if(G0==="true"||G0===1)u=!0;else return B1.errors=[{instancePath:Z+"/allowUnsafeRegex",schemaPath:"#/properties/allowUnsafeRegex/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(u!==void 0){if(G0=u,$!==void 0)$.allowUnsafeRegex=u}}var W=O0===G;if(W){if($.http2!==void 0){let u=$.http2,l=G;if(typeof u!=="boolean"){let v=void 0;if(v===void 0)if(u==="false"||u===0||u===null)v=!1;else if(u==="true"||u===1)v=!0;else return B1.errors=[{instancePath:Z+"/http2",schemaPath:"#/properties/http2/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(v!==void 0){if(u=v,$!==void 0)$.http2=v}}var W=l===G}else var W=!0;if(W){if($.https!==void 0){let u=$.https,l=G,$0=G,v=!0,h=G,c=G,m=G,a=G,e=!1,H0=null,A0=G;if(typeof u!=="boolean"){let o=void 0;if(o===void 0)if(u==="false"||u===0||u===null)o=!1;else if(u==="true"||u===1)o=!0;else{let K0={};if(Q===null)Q=[K0];else Q.push(K0);G++}if(o!==void 0){if(u=o,$!==void 0)$.https=o}}var V=A0===G;if(V)e=!0,H0=0;let P0=G;if(u!==null){let o=void 0;if(o===void 0)if(u===""||u===0||u===!1)o=null;else{let K0={};if(Q===null)Q=[K0];else Q.push(K0);G++}if(o!==void 0){if(u=o,$!==void 0)$.https=o}}var V=P0===G;if(V&&e)e=!1,H0=[H0,1];else{if(V)e=!0,H0=1;let o=G;if(G===o)if(u&&typeof u=="object"&&!Array.isArray(u)){let z0;if(u.allowHTTP1===void 0&&(z0="allowHTTP1")){let j0={};if(Q===null)Q=[j0];else Q.push(j0);G++}else{let j0=G;for(let Q1 in u)if(Q1!=="allowHTTP1")delete u[Q1];if(j0===G){if(u.allowHTTP1!==void 0){let Q1=u.allowHTTP1;if(typeof Q1!=="boolean"){let _0=void 0;if(_0===void 0)if(Q1==="false"||Q1===0||Q1===null)_0=!1;else if(Q1==="true"||Q1===1)_0=!0;else{let e0={};if(Q===null)Q=[e0];else Q.push(e0);G++}if(_0!==void 0){if(Q1=_0,u!==void 0)u.allowHTTP1=_0}}}}}}else{let z0={};if(Q===null)Q=[z0];else Q.push(z0);G++}var V=o===G;if(V&&e)e=!1,H0=[H0,2];else if(V)e=!0,H0=2}if(!e){let o={};if(Q===null)Q=[o];else Q.push(o);G++}else if(G=a,Q!==null)if(a)Q.length=a;else Q=null;var U=m===G;if(U){let o={};if(Q===null)Q=[o];else Q.push(o);G++}else if(G=c,Q!==null)if(c)Q.length=c;else Q=null;var H=h===G;if(G=$0,Q!==null)if($0)Q.length=$0;else Q=null;if(H){let o=G;$.https=!0;var H=o===G;v=H}if(!v){let o={instancePath:Z+"/https",schemaPath:"#/properties/https/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};if(Q===null)Q=[o];else Q.push(o);return G++,B1.errors=Q,!1}var W=l===G}else var W=!0;if(W){let u=$.ignoreTrailingSlash,l=G;if(typeof u!=="boolean"){let v=void 0;if(v===void 0)if(u==="false"||u===0||u===null)v=!1;else if(u==="true"||u===1)v=!0;else return B1.errors=[{instancePath:Z+"/ignoreTrailingSlash",schemaPath:"#/properties/ignoreTrailingSlash/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(v!==void 0){if(u=v,$!==void 0)$.ignoreTrailingSlash=v}}var W=l===G;if(W){let v=$.ignoreDuplicateSlashes,h=G;if(typeof v!=="boolean"){let m=void 0;if(m===void 0)if(v==="false"||v===0||v===null)m=!1;else if(v==="true"||v===1)m=!0;else return B1.errors=[{instancePath:Z+"/ignoreDuplicateSlashes",schemaPath:"#/properties/ignoreDuplicateSlashes/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(m!==void 0){if(v=m,$!==void 0)$.ignoreDuplicateSlashes=m}}var W=h===G;if(W){let m=$.maxParamLength,a=G;if(!(typeof m=="number"&&(!(m%1)&&!isNaN(m))&&isFinite(m))){let H0=typeof m,A0=void 0;if(A0===void 0)if(H0==="boolean"||m===null||H0==="string"&&m&&m==+m&&!(m%1))A0=+m;else return B1.errors=[{instancePath:Z+"/maxParamLength",schemaPath:"#/properties/maxParamLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(A0!==void 0){if(m=A0,$!==void 0)$.maxParamLength=A0}}var W=a===G;if(W){let H0=$.onProtoPoisoning,A0=G;if(typeof H0!=="string"){let s0=typeof H0,o=void 0;if(o===void 0)if(s0=="number"||s0=="boolean")o=""+H0;else if(H0===null)o="";else return B1.errors=[{instancePath:Z+"/onProtoPoisoning",schemaPath:"#/properties/onProtoPoisoning/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(o!==void 0){if(H0=o,$!==void 0)$.onProtoPoisoning=o}}var W=A0===G;if(W){let s0=$.onConstructorPoisoning,o=G;if(typeof s0!=="string"){let z0=typeof s0,j0=void 0;if(j0===void 0)if(z0=="number"||z0=="boolean")j0=""+s0;else if(s0===null)j0="";else return B1.errors=[{instancePath:Z+"/onConstructorPoisoning",schemaPath:"#/properties/onConstructorPoisoning/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(j0!==void 0){if(s0=j0,$!==void 0)$.onConstructorPoisoning=j0}}var W=o===G;if(W){let z0=$.pluginTimeout,j0=G;if(!(typeof z0=="number"&&(!(z0%1)&&!isNaN(z0))&&isFinite(z0))){let _0=typeof z0,e0=void 0;if(e0===void 0)if(_0==="boolean"||z0===null||_0==="string"&&z0&&z0==+z0&&!(z0%1))e0=+z0;else return B1.errors=[{instancePath:Z+"/pluginTimeout",schemaPath:"#/properties/pluginTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(e0!==void 0){if(z0=e0,$!==void 0)$.pluginTimeout=e0}}var W=j0===G;if(W){let _0=$.requestIdHeader,e0=G,S0=G,C1=!1,n0=G;if(typeof _0!=="boolean"){let a0=void 0;if(a0===void 0)if(_0==="false"||_0===0||_0===null)a0=!1;else if(_0==="true"||_0===1)a0=!0;else{let U1={instancePath:Z+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf/0/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};if(Q===null)Q=[U1];else Q.push(U1);G++}if(a0!==void 0){if(_0=a0,$!==void 0)$.requestIdHeader=a0}}var B=n0===G;if(C1=C1||B,!C1){let a0=G;if(typeof _0!=="string"){let x=typeof _0,i=void 0;if(i===void 0)if(x=="number"||x=="boolean")i=""+_0;else if(_0===null)i="";else{let n={instancePath:Z+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf/1/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[n];else Q.push(n);G++}if(i!==void 0){if(_0=i,$!==void 0)$.requestIdHeader=i}}var B=a0===G;C1=C1||B}if(!C1){let a0={instancePath:Z+"/requestIdHeader",schemaPath:"#/properties/requestIdHeader/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[a0];else Q.push(a0);return G++,B1.errors=Q,!1}else if(G=S0,Q!==null)if(S0)Q.length=S0;else Q=null;var W=e0===G;if(W){let a0=$.requestIdLogLabel,U1=G;if(typeof a0!=="string"){let i=typeof a0,n=void 0;if(n===void 0)if(i=="number"||i=="boolean")n=""+a0;else if(a0===null)n="";else return B1.errors=[{instancePath:Z+"/requestIdLogLabel",schemaPath:"#/properties/requestIdLogLabel/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(n!==void 0){if(a0=n,$!==void 0)$.requestIdLogLabel=n}}var W=U1===G;if(W){let i=$.http2SessionTimeout,n=G;if(!(typeof i=="number"&&(!(i%1)&&!isNaN(i))&&isFinite(i))){let C0=typeof i,M0=void 0;if(M0===void 0)if(C0==="boolean"||i===null||C0==="string"&&i&&i==+i&&!(i%1))M0=+i;else return B1.errors=[{instancePath:Z+"/http2SessionTimeout",schemaPath:"#/properties/http2SessionTimeout/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(M0!==void 0){if(i=M0,$!==void 0)$.http2SessionTimeout=M0}}var W=n===G;if(W){let C0=$.exposeHeadRoutes,M0=G;if(typeof C0!=="boolean"){let g0=void 0;if(g0===void 0)if(C0==="false"||C0===0||C0===null)g0=!1;else if(C0==="true"||C0===1)g0=!0;else return B1.errors=[{instancePath:Z+"/exposeHeadRoutes",schemaPath:"#/properties/exposeHeadRoutes/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(g0!==void 0){if(C0=g0,$!==void 0)$.exposeHeadRoutes=g0}}var W=M0===G;if(W){let g0=$.useSemicolonDelimiter,Z0=G;if(typeof g0!=="boolean"){let V0=void 0;if(V0===void 0)if(g0==="false"||g0===0||g0===null)V0=!1;else if(g0==="true"||g0===1)V0=!0;else return B1.errors=[{instancePath:Z+"/useSemicolonDelimiter",schemaPath:"#/properties/useSemicolonDelimiter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(V0!==void 0){if(g0=V0,$!==void 0)$.useSemicolonDelimiter=V0}}var W=Z0===G;if(W){if($.routerOptions!==void 0){let V0=$.routerOptions,$1=G;if(G===$1)if(V0&&typeof V0=="object"&&!Array.isArray(V0)){if(V0.ignoreTrailingSlash===void 0)V0.ignoreTrailingSlash=!1;if(V0.ignoreDuplicateSlashes===void 0)V0.ignoreDuplicateSlashes=!1;if(V0.maxParamLength===void 0)V0.maxParamLength=100;if(V0.allowUnsafeRegex===void 0)V0.allowUnsafeRegex=!1;if(V0.useSemicolonDelimiter===void 0)V0.useSemicolonDelimiter=!1;let H1=V0.ignoreTrailingSlash,P1=G;if(typeof H1!=="boolean"){let E1=void 0;if(E1===void 0)if(H1==="false"||H1===0||H1===null)E1=!1;else if(H1==="true"||H1===1)E1=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/ignoreTrailingSlash",schemaPath:"#/properties/routerOptions/properties/ignoreTrailingSlash/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E1!==void 0){if(H1=E1,V0!==void 0)V0.ignoreTrailingSlash=E1}}var z=P1===G;if(z){let E1=V0.ignoreDuplicateSlashes,b1=G;if(typeof E1!=="boolean"){let m1=void 0;if(m1===void 0)if(E1==="false"||E1===0||E1===null)m1=!1;else if(E1==="true"||E1===1)m1=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/ignoreDuplicateSlashes",schemaPath:"#/properties/routerOptions/properties/ignoreDuplicateSlashes/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(m1!==void 0){if(E1=m1,V0!==void 0)V0.ignoreDuplicateSlashes=m1}}var z=b1===G;if(z){let m1=V0.maxParamLength,c8=G;if(!(typeof m1=="number"&&(!(m1%1)&&!isNaN(m1))&&isFinite(m1))){let O8=typeof m1,A6=void 0;if(A6===void 0)if(O8==="boolean"||m1===null||O8==="string"&&m1&&m1==+m1&&!(m1%1))A6=+m1;else return B1.errors=[{instancePath:Z+"/routerOptions/maxParamLength",schemaPath:"#/properties/routerOptions/properties/maxParamLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(A6!==void 0){if(m1=A6,V0!==void 0)V0.maxParamLength=A6}}var z=c8===G;if(z){let O8=V0.allowUnsafeRegex,A6=G;if(typeof O8!=="boolean"){let y$=void 0;if(y$===void 0)if(O8==="false"||O8===0||O8===null)y$=!1;else if(O8==="true"||O8===1)y$=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/allowUnsafeRegex",schemaPath:"#/properties/routerOptions/properties/allowUnsafeRegex/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(y$!==void 0){if(O8=y$,V0!==void 0)V0.allowUnsafeRegex=y$}}var z=A6===G;if(z){let y$=V0.useSemicolonDelimiter,U9=G;if(typeof y$!=="boolean"){let q8=void 0;if(q8===void 0)if(y$==="false"||y$===0||y$===null)q8=!1;else if(y$==="true"||y$===1)q8=!0;else return B1.errors=[{instancePath:Z+"/routerOptions/useSemicolonDelimiter",schemaPath:"#/properties/routerOptions/properties/useSemicolonDelimiter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(q8!==void 0){if(y$=q8,V0!==void 0)V0.useSemicolonDelimiter=q8}}var z=U9===G}}}}}else return B1.errors=[{instancePath:Z+"/routerOptions",schemaPath:"#/properties/routerOptions/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=$1===G}else var W=!0;if(W)if($.constraints!==void 0){let V0=$.constraints,$1=G;if(G===$1)if(V0&&typeof V0=="object"&&!Array.isArray(V0))for(let H1 in V0){let P1=V0[H1],E1=G;if(G===E1)if(P1&&typeof P1=="object"&&!Array.isArray(P1)){let b1;if(P1.name===void 0&&(b1="name")||P1.storage===void 0&&(b1="storage")||P1.validate===void 0&&(b1="validate")||P1.deriveConstraint===void 0&&(b1="deriveConstraint"))return B1.errors=[{instancePath:Z+"/constraints/"+H1.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/constraints/additionalProperties/required",keyword:"required",params:{missingProperty:b1},message:"must have required property '"+b1+"'"}],!1;else if(P1.name!==void 0){let F6=P1.name;if(typeof F6!=="string"){let m1=typeof F6,c8=void 0;if(c8===void 0)if(m1=="number"||m1=="boolean")c8=""+F6;else if(F6===null)c8="";else return B1.errors=[{instancePath:Z+"/constraints/"+H1.replace(/~/g,"~0").replace(/\//g,"~1")+"/name",schemaPath:"#/properties/constraints/additionalProperties/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(c8!==void 0){if(F6=c8,P1!==void 0)P1.name=c8}}}}else return B1.errors=[{instancePath:Z+"/constraints/"+H1.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/constraints/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var F=E1===G;if(!F)break}else return B1.errors=[{instancePath:Z+"/constraints",schemaPath:"#/properties/constraints/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var W=$1===G}else var W=!0}}}}}}}}}}}}}}}}}}}}}}}}else return B1.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return B1.errors=Q,G===0}pW.exports.defaultInitOptions={connectionTimeout:0,keepAliveTimeout:72000,maxRequestsPerSocket:0,requestTimeout:0,handlerTimeout:0,bodyLimit:1048576,caseSensitive:!0,allowUnsafeRegex:!1,disableRequestLogging:!1,ignoreTrailingSlash:!1,ignoreDuplicateSlashes:!1,maxParamLength:100,onProtoPoisoning:"error",onConstructorPoisoning:"error",pluginTimeout:1e4,requestIdHeader:!1,requestIdLogLabel:"reqId",http2SessionTimeout:72000,exposeHeadRoutes:!0,useSemicolonDelimiter:!1,allowErrorHandlerOverride:!0,routerOptions:{ignoreTrailingSlash:!1,ignoreDuplicateSlashes:!1,maxParamLength:100,allowUnsafeRegex:!1,useSemicolonDelimiter:!1}}});var Hg=S((cx0,iW)=>{var cW=Ug(),bA0=WG()({circles:!0,proto:!1}),{FST_ERR_INIT_OPTS_INVALID:_A0}=L$();function SA0($){let Z=bA0($);if(!cW(Z)){let J=new _A0(JSON.stringify(cW.errors.map((Y)=>Y.message)));throw J.errors=cW.errors,J}return yF(Z)}function yF($){let Z=Object.getOwnPropertyNames($);for(let J of Z){let Y=$[J];if(ArrayBuffer.isView(Y)&&!(Y instanceof DataView))continue;$[J]=Y&&typeof Y==="object"?yF(Y):Y}return Object.freeze($)}iW.exports=SA0;iW.exports.defaultInitOptions=cW.defaultInitOptions;iW.exports.utils={deepFreezeObject:yF}});var Mg=S((ix0,Ng)=>{var{kAvvioBoot:fA0,kChildren:Bg,kRoutePrefix:zg,kLogLevel:Fg,kLogSerializers:xF,kHooks:hF,kSchemaController:GY,kContentTypeParser:Ag,kReply:Og,kRequest:qg,kFourOhFour:kA0,kPluginNameChain:jg,kErrorHandlerAlreadySet:vA0}=H$(),yA0=MG(),xA0=PG(),hA0=XF(),gA0=jz(),{buildHooks:uA0}=uZ(),kQ=UF();Ng.exports=function(Z,J,Y){let X=kQ.registerPlugin.call(Z,J),Q=kQ.getPluginName(J)||kQ.getFuncPreview(J);if(X)return Z[jg].push(Q),Z;let G=Object.create(Z);if(Z[Bg].push(G),G.ready=Z[fA0].bind(G),G[Bg]=[],G[Og]=yA0.buildReply(G[Og]),G[qg]=xA0.buildRequest(G[qg]),G[Ag]=gA0.helpers.buildContentTypeParser(G[Ag]),G[hF]=uA0(G[hF]),G[zg]=mA0(G[zg],Y.prefix),G[Fg]=Y.logLevel||G[Fg],G[GY]=hA0.buildSchemaController(Z[GY]),G.getSchema=G[GY].getSchema.bind(G[GY]),G.getSchemas=G[GY].getSchemas.bind(G[GY]),G[kQ.kRegisteredPlugins]=Object.create(G[kQ.kRegisteredPlugins]),G[jg]=[Q],G[vA0]=!1,G[xF]||Y.logSerializers)G[xF]=Object.assign(Object.create(G[xF]),Y.logSerializers);if(Y.prefix)G[kA0].arrange404(G);for(let W of G[hF].onRegister)W.call(Z,G,Y);return G};function mA0($,Z){if(!Z)return $;if($.endsWith("/")&&Z[0]==="/")Z=Z.slice(1);else if(Z[0]!=="/")Z="/"+Z;return $+Z}});var Cg=S((Rg)=>{Object.defineProperty(Rg,"__esModule",{value:!0});Rg.parseCookie=Lg;Rg.parse=Lg;Rg.stringifyCookie=nA0;Rg.stringifySetCookie=nW;Rg.serialize=nW;Rg.parseSetCookie=oA0;Rg.stringifySetCookie=nW;Rg.serialize=nW;var Dg=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,wg=/^[\u0021-\u003A\u003C-\u007E]*$/,lA0=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,dA0=/^[\u0020-\u003A\u003D-\u007E]*$/,pA0=/^-?\d+$/,cA0=Object.prototype.toString,iA0=(()=>{let $=function(){};return $.prototype=Object.create(null),$})();function Lg($,Z){let J=new iA0,Y=$.length;if(Y<2)return J;let X=Z?.decode||Tg,Q=0;do{let G=uF($,Q,Y);if(G===-1)break;let W=gF($,Q,Y);if(G>W){Q=$.lastIndexOf(";",G-1)+1;continue}let K=Z5($,Q,G);if(J[K]===void 0)J[K]=X(Z5($,G+1,W));Q=W+1}while(Q<Y);return J}function nA0($,Z){let J=Z?.encode||encodeURIComponent,Y=[];for(let X of Object.keys($)){let Q=$[X];if(Q===void 0)continue;if(!Dg.test(X))throw TypeError(`cookie name is invalid: ${X}`);let G=J(Q);if(!wg.test(G))throw TypeError(`cookie val is invalid: ${Q}`);Y.push(`${X}=${G}`)}return Y.join("; ")}function nW($,Z,J){let Y=typeof $==="object"?$:{...J,name:$,value:String(Z)},Q=(typeof Z==="object"?Z:J)?.encode||encodeURIComponent;if(!Dg.test(Y.name))throw TypeError(`argument name is invalid: ${Y.name}`);let G=Y.value?Q(Y.value):"";if(!wg.test(G))throw TypeError(`argument val is invalid: ${Y.value}`);let W=Y.name+"="+G;if(Y.maxAge!==void 0){if(!Number.isInteger(Y.maxAge))throw TypeError(`option maxAge is invalid: ${Y.maxAge}`);W+="; Max-Age="+Y.maxAge}if(Y.domain){if(!lA0.test(Y.domain))throw TypeError(`option domain is invalid: ${Y.domain}`);W+="; Domain="+Y.domain}if(Y.path){if(!dA0.test(Y.path))throw TypeError(`option path is invalid: ${Y.path}`);W+="; Path="+Y.path}if(Y.expires){if(!sA0(Y.expires)||!Number.isFinite(Y.expires.valueOf()))throw TypeError(`option expires is invalid: ${Y.expires}`);W+="; Expires="+Y.expires.toUTCString()}if(Y.httpOnly)W+="; HttpOnly";if(Y.secure)W+="; Secure";if(Y.partitioned)W+="; Partitioned";if(Y.priority)switch(typeof Y.priority==="string"?Y.priority.toLowerCase():void 0){case"low":W+="; Priority=Low";break;case"medium":W+="; Priority=Medium";break;case"high":W+="; Priority=High";break;default:throw TypeError(`option priority is invalid: ${Y.priority}`)}if(Y.sameSite)switch(typeof Y.sameSite==="string"?Y.sameSite.toLowerCase():Y.sameSite){case!0:case"strict":W+="; SameSite=Strict";break;case"lax":W+="; SameSite=Lax";break;case"none":W+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${Y.sameSite}`)}return W}function oA0($,Z){let J=Z?.decode||Tg,Y=$.length,X=gF($,0,Y),Q=uF($,0,X),G=Q===-1?{name:"",value:J(Z5($,0,X))}:{name:Z5($,0,Q),value:J(Z5($,Q+1,X))},W=X+1;while(W<Y){let K=gF($,W,Y),V=uF($,W,K),U=V===-1?Z5($,W,K):Z5($,W,V),H=V===-1?void 0:Z5($,V+1,K);switch(U.toLowerCase()){case"httponly":G.httpOnly=!0;break;case"secure":G.secure=!0;break;case"partitioned":G.partitioned=!0;break;case"domain":G.domain=H;break;case"path":G.path=H;break;case"max-age":if(H&&pA0.test(H))G.maxAge=Number(H);break;case"expires":if(!H)break;let B=new Date(H);if(Number.isFinite(B.valueOf()))G.expires=B;break;case"priority":if(!H)break;let z=H.toLowerCase();if(z==="low"||z==="medium"||z==="high")G.priority=z;break;case"samesite":if(!H)break;let F=H.toLowerCase();if(F==="lax"||F==="strict"||F==="none")G.sameSite=F;break}W=K+1}return G}function gF($,Z,J){let Y=$.indexOf(";",Z);return Y===-1?J:Y}function uF($,Z,J){let Y=$.indexOf("=",Z);return Y<J?Y:-1}function Z5($,Z,J){let Y=Z,X=J;do{let Q=$.charCodeAt(Y);if(Q!==32&&Q!==9)break}while(++Y<X);while(X>Y){let Q=$.charCodeAt(X-1);if(Q!==32&&Q!==9)break;X--}return $.slice(Y,X)}function Tg($){if($.indexOf("%")===-1)return $;try{return decodeURIComponent($)}catch(Z){return $}}function sA0($){return cA0.call($)==="[object Date]"}});var bg=S((ox0,oW)=>{var{format:mF}=Y0("util");function $O0($){return Eg({...$,name:"DeprecationWarning"})}function Eg({name:$,code:Z,message:J,unlimited:Y=!1}={}){if(!$)throw Error("Warning name must not be empty");if(!Z)throw Error("Warning code must not be empty");if(!J)throw Error("Warning message must not be empty");if(typeof Y!=="boolean")throw Error("Warning opts.unlimited must be a boolean");Z=Z.toUpperCase();let X={[$]:function(G,W,K){if(Q.emitted===!0&&Q.unlimited!==!0)return;Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};if(Y)X={[$]:function(G,W,K){Q.emitted=!0,process.emitWarning(Q.format(G,W,K),Q.name,Q.code)}};let Q=X[$];return Q.emitted=!1,Q.message=J,Q.unlimited=Y,Q.code=Z,Q.format=function(G,W,K){let V;if(G&&W&&K)V=mF(J,G,W,K);else if(G&&W)V=mF(J,G,W);else if(G)V=mF(J,G);else V=J;return V},Q}var lF={createWarning:Eg,createDeprecation:$O0};oW.exports=lF;oW.exports.default=lF;oW.exports.processWarning=lF});var fg=S((sx0,Sg)=>{var{URL:_g}=Y0("url");Sg.exports=function(Z,J){if((typeof Z==="string"||Object.prototype.toString.call(Z)==="[object String]")&&Z.startsWith("//"))Z="http://localhost"+Z;let Y=typeof Z==="object"?Object.assign(new _g("http://localhost"),Z):new _g(Z,"http://localhost");if(typeof J==="string"){J=new URLSearchParams(J);for(let X of J.keys()){Y.searchParams.delete(X);for(let Q of J.getAll(X))Y.searchParams.append(X,Q)}}else{let X=Object.assign({},Z.query,J);for(let Q in X){let G=X[Q];if(Array.isArray(G)){Y.searchParams.delete(Q);for(let W of G)Y.searchParams.append(Q,W)}else Y.searchParams.set(Q,G)}}return Y}});var kg=S((QO0,dF)=>{var{randomUUID:ZO0}=Y0("crypto"),{Readable:JO0}=Y0("stream"),WY;function YO0($){return $&&typeof $==="object"&&typeof $.append==="function"&&typeof $.delete==="function"&&typeof $.get==="function"&&typeof $.getAll==="function"&&typeof $.has==="function"&&typeof $.set==="function"&&$[Symbol.toStringTag]==="FormData"}function XO0($){WY=WY??new TextEncoder;let Z=`----formdata-${ZO0()}`,J=`--${Z}\r
445
- Content-Disposition: form-data`;/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */let Y=(K)=>K.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22"),X=(K)=>K.replace(/\r?\n|\r/g,`\r
446
- `),Q=new Uint8Array([13,10]);async function*G(){for(let[K,V]of $)if(typeof V==="string")yield WY.encode(`${J}; name="${Y(X(K))}"\r
447
- \r
448
- `),yield WY.encode(`${X(V)}\r
449
- `);else{let U=`${J}; name="${Y(X(K))}"`;if(V.name&&(U+=`; filename="${Y(V.name)}"`),U+=`\r
450
- Content-Type: ${V.type||"application/octet-stream"}\r
451
- \r
452
- `,yield WY.encode(U),V.stream)yield*V.stream();else yield V;yield Q}yield WY.encode(`--${Z}--`)}return{stream:JO0.from(G()),contentType:`multipart/form-data; boundary=${Z}`}}QO0.isFormDataLike=YO0;QO0.formDataToStream=XO0});var hg=S((rx0,sW)=>{var{Readable:vg,addAbortSignal:KO0}=Y0("stream"),pF=Y0("util"),VO0=Cg(),UO0=Y0("assert"),{createDeprecation:HO0}=bg(),BO0=fg(),{isFormDataLike:zO0,formDataToStream:FO0}=kg(),{EventEmitter:AO0}=Y0("events"),OO0=HO0({name:"FastifyDeprecationLightMyRequest",code:"FST_LIGHTMYREQUEST_DEP01",message:'You are accessing "request.connection", use "request.socket" instead.'});function qO0($){return $.port?$.host:$.hostname+($.protocol==="https:"?":443":":80")}class yg extends AO0{constructor($){super();this.remoteAddress=$}}function xg($){return new Z(this);function Z(J){J5.call(J,{...$,Request:void 0}),Object.assign(this,J);for(let Y of Object.keys(J5.prototype))this.constructor.prototype[Y]=J5.prototype[Y];return pF.inherits(this.constructor,$.Request),this}}function J5($){vg.call(this,{autoDestroy:!1});let Z=BO0($.url||$.path,$.query);this.url=Z.pathname+Z.search,this.aborted=!1,this.httpVersionMajor=1,this.httpVersionMinor=1,this.httpVersion="1.1",this.method=$.method?$.method.toUpperCase():"GET",this.headers={},this.rawHeaders=[];let J=$.headers||{};for(let G in J){let W=G.toLowerCase();if((W==="user-agent"||W==="content-type")&&J[G]===void 0){this.headers[W]=void 0;continue}let K=J[G];UO0(K!==void 0,'invalid value "undefined" for header '+G),this.headers[W]=""+K}if("user-agent"in this.headers===!1)this.headers["user-agent"]="lightMyRequest";if(this.headers.host=this.headers.host||$.authority||qO0(Z),$.cookies){let{cookies:G}=$,W=Object.keys(G).map((K)=>VO0.serialize(K,G[K]));if(this.headers.cookie)W.unshift(this.headers.cookie);this.headers.cookie=W.join("; ")}this.socket=new yg($.remoteAddress||"127.0.0.1"),Object.defineProperty(this,"connection",{get(){return OO0(),this.socket},configurable:!0});let Y=$.payload||$.body||null,X=Y&&typeof Y.resume==="function";if(zO0(Y)){let G=FO0(Y);Y=G.stream,X=!0,this.headers["content-type"]=G.contentType,this.headers["transfer-encoding"]="chunked"}if(Y&&typeof Y!=="string"&&!X&&!Buffer.isBuffer(Y)){if(Y=JSON.stringify(Y),"content-type"in this.headers===!1)this.headers["content-type"]="application/json"}if(Y&&!X&&!Object.hasOwn(this.headers,"content-length"))this.headers["content-length"]=(Buffer.isBuffer(Y)?Y.length:Buffer.byteLength(Y)).toString();for(let G of Object.keys(this.headers))this.rawHeaders.push(G,this.headers[G]);this._lightMyRequest={payload:Y,isDone:!1,simulate:$.simulate||{},payloadAsStream:$.payloadAsStream,signal:$.signal};let Q=$.signal;if(Q)KO0(Q,this);{let G=this._lightMyRequest.payload;if(G?._readableState)this._read=jO0,G.on("error",(W)=>{this.destroy(W)}),G.on("end",()=>{this.push(null)});else this._read=NO0}return this}function jO0(){let $=this._lightMyRequest.payload,Z=!0,J=!1,Y;while(Z&&(Y=$.read()))J=!0,Z=this.push(Y);if(Z&&!J)this._lightMyRequest.payload.once("readable",this._read.bind(this))}function NO0(){setImmediate(()=>{if(this._lightMyRequest.isDone){if(this._lightMyRequest.simulate.end!==!1)this.push(null);return}if(this._lightMyRequest.isDone=!0,this._lightMyRequest.payload)if(this._lightMyRequest.simulate.split)this.push(this._lightMyRequest.payload.slice(0,1)),this.push(this._lightMyRequest.payload.slice(1));else this.push(this._lightMyRequest.payload);if(this._lightMyRequest.simulate.error)this.emit("error",Error("Simulated"));if(this._lightMyRequest.simulate.close)this.emit("close");if(this._lightMyRequest.simulate.end!==!1)this.push(null)})}pF.inherits(J5,vg);pF.inherits(xg,J5);J5.prototype.destroy=function($){if(this.destroyed||this._lightMyRequest.isDone)return;if(this.destroyed=!0,$)this._error=!0,process.nextTick(()=>this.emit("error",$));process.nextTick(()=>this.emit("close"))};sW.exports=J5;sW.exports.Request=J5;sW.exports.CustomRequest=xg});var ug=S((ax0,vQ)=>{var rW={decodeValues:!0,map:!1,silent:!1};function cF($){return typeof $!=="string"||$ in{}}function iF(){return Object.create(null)}function nF($){return typeof $==="string"&&!!$.trim()}function oF($,Z){var J=$.split(";").filter(nF),Y=J.shift(),X=MO0(Y),Q=X.name,G=X.value;if(Z=Z?Object.assign({},rW,Z):rW,cF(Q))return null;try{G=Z.decodeValues?decodeURIComponent(G):G}catch(K){console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",K)}var W=iF();return W.name=Q,W.value=G,J.forEach(function(K){var V=K.split("="),U=V.shift().trimLeft().toLowerCase();if(cF(U))return;var H=V.join("=");if(U==="expires")W.expires=new Date(H);else if(U==="max-age"){var B=parseInt(H,10);if(!Number.isNaN(B))W.maxAge=B}else if(U==="secure")W.secure=!0;else if(U==="httponly")W.httpOnly=!0;else if(U==="samesite")W.sameSite=H;else if(U==="partitioned")W.partitioned=!0;else if(U)W[U]=H}),W}function MO0($){var Z="",J="",Y=$.split("=");if(Y.length>1)Z=Y.shift(),J=Y.join("=");else J=$;return{name:Z,value:J}}function gg($,Z){if(Z=Z?Object.assign({},rW,Z):rW,!$)if(!Z.map)return[];else return iF();if($.headers)if(typeof $.headers.getSetCookie==="function")$=$.headers.getSetCookie();else if($.headers["set-cookie"])$=$.headers["set-cookie"];else{var J=$.headers[Object.keys($.headers).find(function(X){return X.toLowerCase()==="set-cookie"})];if(!J&&$.headers.cookie&&!Z.silent)console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning.");$=J}if(!Array.isArray($))$=[$];if(!Z.map)return $.filter(nF).map(function(X){return oF(X,Z)}).filter(Boolean);else{var Y=iF();return $.filter(nF).reduce(function(X,Q){var G=oF(Q,Z);if(G&&!cF(G.name))X[G.name]=G;return X},Y)}}function DO0($){if(Array.isArray($))return $;if(typeof $!=="string")return[];var Z=[],J=0,Y,X,Q,G,W;function K(){while(J<$.length&&/\s/.test($.charAt(J)))J+=1;return J<$.length}function V(){return X=$.charAt(J),X!=="="&&X!==";"&&X!==","}while(J<$.length){Y=J,W=!1;while(K())if(X=$.charAt(J),X===","){Q=J,J+=1,K(),G=J;while(J<$.length&&V())J+=1;if(J<$.length&&$.charAt(J)==="=")W=!0,J=G,Z.push($.substring(Y,Q)),Y=J;else J=Q+1}else J+=1;if(!W||J>=$.length)Z.push($.substring(Y,$.length))}return Z}vQ.exports=gg;vQ.exports.parse=gg;vQ.exports.parseString=oF;vQ.exports.splitCookiesString=DO0});var cg=S((tx0,pg)=>{var yQ=Y0("http"),{Writable:wO0,Readable:mg,addAbortSignal:LO0}=Y0("stream"),TO0=Y0("util"),RO0=ug();function Y5($,Z,J){if(yQ.ServerResponse.call(this,$),$._lightMyRequest?.payloadAsStream){let W=this.emit.bind(this,"drain");this._lightMyRequest={headers:null,trailers:{},stream:new mg({read:W})};let K=$._lightMyRequest.signal;if(K)LO0(K,this._lightMyRequest.stream)}else this._lightMyRequest={headers:null,trailers:{},payloadChunks:[]};this.setHeader("foo","bar"),this.removeHeader("foo"),this.assignSocket(PO0()),this._promiseCallback=typeof J==="function";let Y=!1,X=(W)=>{if(Y)return;if(Y=!0,this._promiseCallback)return process.nextTick(()=>Z(W));process.nextTick(()=>Z(null,W))};this._lightMyRequest.onEndSuccess=X;let Q=!1,G=(W)=>{if(Y){if(this._lightMyRequest.stream&&!Q){if(!W)W=Error("response destroyed before completion"),W.code="LIGHT_ECONNRESET";this._lightMyRequest.stream.destroy(W),this._lightMyRequest.stream.on("error",()=>{})}return}if(Y=!0,!W)W=Error("response destroyed before completion"),W.code="LIGHT_ECONNRESET";if(this._promiseCallback)return process.nextTick(()=>J(W));process.nextTick(()=>Z(W,null))};if(this._lightMyRequest.stream)this.once("finish",()=>{Q=!0,this._lightMyRequest.stream.push(null)});else this.once("finish",()=>{let W=lg(this);W.raw.req=$,X(W)});this.connection.once("error",G),this.once("error",G),this.once("close",G)}TO0.inherits(Y5,yQ.ServerResponse);Y5.prototype.setTimeout=function($,Z){return this.timeoutHandle=setTimeout(()=>{this.emit("timeout")},$),this.on("timeout",Z),this};Y5.prototype.writeHead=function(){let $=yQ.ServerResponse.prototype.writeHead.apply(this,arguments);if(dg(this),this._lightMyRequest.stream)this._lightMyRequest.onEndSuccess(lg(this));return $};Y5.prototype.write=function($,Z,J){if(this.timeoutHandle)clearTimeout(this.timeoutHandle);if(yQ.ServerResponse.prototype.write.call(this,$,Z,J),this._lightMyRequest.stream)return this._lightMyRequest.stream.push(Buffer.from($,Z));else return this._lightMyRequest.payloadChunks.push(Buffer.from($,Z)),!0};Y5.prototype.end=function($,Z,J){if($)this.write($,Z);yQ.ServerResponse.prototype.end.call(this,J),this.emit("finish"),this.destroy()};Y5.prototype.destroy=function($){if(this.destroyed)return;if(this.destroyed=!0,$)process.nextTick(()=>this.emit("error",$));process.nextTick(()=>this.emit("close"))};Y5.prototype.addTrailers=function($){for(let Z in $)this._lightMyRequest.trailers[Z.toLowerCase().trim()]=$[Z].toString().trim()};function lg($){if($._lightMyRequest.headers===null)dg($);IO0($);let Z={raw:{res:$},headers:$._lightMyRequest.headers,statusCode:$.statusCode,statusMessage:$.statusMessage,trailers:{},get cookies(){return RO0.parse(this)}};if(Z.trailers=$._lightMyRequest.trailers,$._lightMyRequest.payloadChunks){let J=Buffer.concat($._lightMyRequest.payloadChunks);Z.rawPayload=J,Z.payload=J.toString(),Z.body=Z.payload,Z.json=function(){return JSON.parse(Z.payload)}}else Z.json=function(){throw Error("Response payload is not available with payloadAsStream: true")};return Z.stream=function(){if($._lightMyRequest.stream)return $._lightMyRequest.stream;return mg.from($._lightMyRequest.payloadChunks)},Z}function PO0(){return new wO0({write($,Z,J){setImmediate(J)}})}function IO0($){let Z=$._lightMyRequest.headers;for(let J of Object.keys(Z)){let Y=Z[J];if(Array.isArray(Y))Z[J]=Y.map((X)=>""+X);else Z[J]=""+Y}}function dg($){$._lightMyRequest.headers=Object.assign({},$.getHeaders()),["Date","Connection","Transfer-Encoding"].forEach((Z)=>{let J=new RegExp("\\r\\n"+Z+": ([^\\r]*)\\r\\n"),Y=$._header?.match(J);if(Y)$._lightMyRequest.headers[Z.toLowerCase()]=Y[1]})}pg.exports=Y5});var ig=S((ex0,sF)=>{sF.exports=B$;sF.exports.default=B$;var CO0={type:"object",properties:{url:{oneOf:[{type:"string"},{type:"object",properties:{protocol:{type:"string"},hostname:{type:"string"},pathname:{type:"string"}},additionalProperties:!0,required:["pathname"]}]},path:{oneOf:[{type:"string"},{type:"object",properties:{protocol:{type:"string"},hostname:{type:"string"},pathname:{type:"string"}},additionalProperties:!0,required:["pathname"]}]},cookies:{type:"object",additionalProperties:!0},headers:{type:"object",additionalProperties:!0},query:{anyOf:[{type:"object",additionalProperties:!0},{type:"string"}]},simulate:{type:"object",properties:{end:{type:"boolean"},split:{type:"boolean"},error:{type:"boolean"},close:{type:"boolean"}}},authority:{type:"string"},remoteAddress:{type:"string"},method:{type:"string",enum:["ACL","BIND","CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LINK","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCALENDAR","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","QUERY","REBIND","REPORT","SEARCH","SOURCE","SUBSCRIBE","TRACE","UNBIND","UNLINK","UNLOCK","UNSUBSCRIBE","acl","bind","checkout","connect","copy","delete","get","head","link","lock","m-search","merge","mkactivity","mkcalendar","mkcol","move","notify","options","patch","post","propfind","proppatch","purge","put","query","rebind","report","search","source","subscribe","trace","unbind","unlink","unlock","unsubscribe"]},validate:{type:"boolean"}},additionalProperties:!0,oneOf:[{required:["url"]},{required:["path"]}]};function B$($,{instancePath:Z="",parentData:J,parentDataProperty:Y,rootData:X=$}={}){let Q=null,G=0,W=G,K=!1,V=null,U=G;if($&&typeof $=="object"&&!Array.isArray($)){let M;if($.url===void 0&&(M="url")){let C={instancePath:Z,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"};if(Q===null)Q=[C];else Q.push(C);G++}}var B=U===G;if(B)K=!0,V=0;let H=G;if($&&typeof $=="object"&&!Array.isArray($)){let M;if($.path===void 0&&(M="path")){let C={instancePath:Z,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:M},message:"must have required property '"+M+"'"};if(Q===null)Q=[C];else Q.push(C);G++}}var B=H===G;if(B&&K)K=!1,V=[V,1];else if(B)K=!0,V=1;if(!K){let M={instancePath:Z,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:V},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[M];else Q.push(M);return G++,B$.errors=Q,!1}else if(G=W,Q!==null)if(W)Q.length=W;else Q=null;if(G===0)if($&&typeof $=="object"&&!Array.isArray($)){if($.url!==void 0){let M=$.url,C=G,R=G,w=!1,I=null,_=G;if(typeof M!=="string"){let f=typeof M,b=void 0;if(b===void 0)if(f=="number"||f=="boolean")b=""+M;else if(M===null)b="";else{let y={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[y];else Q.push(y);G++}if(b!==void 0){if(M=b,$!==void 0)$.url=b}}var F=_===G;if(F)w=!0,I=0;let E=G;if(G===E)if(M&&typeof M=="object"&&!Array.isArray(M)){let f;if(M.pathname===void 0&&(f="pathname")){let b={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf/1/required",keyword:"required",params:{missingProperty:f},message:"must have required property '"+f+"'"};if(Q===null)Q=[b];else Q.push(b);G++}else{if(M.protocol!==void 0){let b=M.protocol,y=G;if(typeof b!=="string"){let k=typeof b,g=void 0;if(g===void 0)if(k=="number"||k=="boolean")g=""+b;else if(b===null)g="";else{let d={instancePath:Z+"/url/protocol",schemaPath:"#/properties/url/oneOf/1/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[d];else Q.push(d);G++}if(g!==void 0){if(b=g,M!==void 0)M.protocol=g}}var z=y===G}else var z=!0;if(z){if(M.hostname!==void 0){let b=M.hostname,y=G;if(typeof b!=="string"){let g=typeof b,d=void 0;if(d===void 0)if(g=="number"||g=="boolean")d=""+b;else if(b===null)d="";else{let p={instancePath:Z+"/url/hostname",schemaPath:"#/properties/url/oneOf/1/properties/hostname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[p];else Q.push(p);G++}if(d!==void 0){if(b=d,M!==void 0)M.hostname=d}}var z=y===G}else var z=!0;if(z)if(M.pathname!==void 0){let b=M.pathname,y=G;if(typeof b!=="string"){let g=typeof b,d=void 0;if(d===void 0)if(g=="number"||g=="boolean")d=""+b;else if(b===null)d="";else{let p={instancePath:Z+"/url/pathname",schemaPath:"#/properties/url/oneOf/1/properties/pathname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[p];else Q.push(p);G++}if(d!==void 0){if(b=d,M!==void 0)M.pathname=d}}var z=y===G}else var z=!0}}}else{let f={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};if(Q===null)Q=[f];else Q.push(f);G++}var F=E===G;if(F&&w)w=!1,I=[I,1];else if(F)w=!0,I=1;if(!w){let f={instancePath:Z+"/url",schemaPath:"#/properties/url/oneOf",keyword:"oneOf",params:{passingSchemas:I},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[f];else Q.push(f);return G++,B$.errors=Q,!1}else if(G=R,Q!==null)if(R)Q.length=R;else Q=null;var A=C===G}else var A=!0;if(A){if($.path!==void 0){let M=$.path,C=G,R=G,w=!1,I=null,_=G;if(typeof M!=="string"){let b=typeof M,y=void 0;if(y===void 0)if(b=="number"||b=="boolean")y=""+M;else if(M===null)y="";else{let k={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[k];else Q.push(k);G++}if(y!==void 0){if(M=y,$!==void 0)$.path=y}}var N=_===G;if(N)w=!0,I=0;let E=G;if(G===E)if(M&&typeof M=="object"&&!Array.isArray(M)){let b;if(M.pathname===void 0&&(b="pathname")){let y={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf/1/required",keyword:"required",params:{missingProperty:b},message:"must have required property '"+b+"'"};if(Q===null)Q=[y];else Q.push(y);G++}else{if(M.protocol!==void 0){let y=M.protocol,k=G;if(typeof y!=="string"){let g=typeof y,d=void 0;if(d===void 0)if(g=="number"||g=="boolean")d=""+y;else if(y===null)d="";else{let p={instancePath:Z+"/path/protocol",schemaPath:"#/properties/path/oneOf/1/properties/protocol/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[p];else Q.push(p);G++}if(d!==void 0){if(y=d,M!==void 0)M.protocol=d}}var j=k===G}else var j=!0;if(j){if(M.hostname!==void 0){let y=M.hostname,k=G;if(typeof y!=="string"){let d=typeof y,p=void 0;if(p===void 0)if(d=="number"||d=="boolean")p=""+y;else if(y===null)p="";else{let t={instancePath:Z+"/path/hostname",schemaPath:"#/properties/path/oneOf/1/properties/hostname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[t];else Q.push(t);G++}if(p!==void 0){if(y=p,M!==void 0)M.hostname=p}}var j=k===G}else var j=!0;if(j)if(M.pathname!==void 0){let y=M.pathname,k=G;if(typeof y!=="string"){let d=typeof y,p=void 0;if(p===void 0)if(d=="number"||d=="boolean")p=""+y;else if(y===null)p="";else{let t={instancePath:Z+"/path/pathname",schemaPath:"#/properties/path/oneOf/1/properties/pathname/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[t];else Q.push(t);G++}if(p!==void 0){if(y=p,M!==void 0)M.pathname=p}}var j=k===G}else var j=!0}}}else{let b={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};if(Q===null)Q=[b];else Q.push(b);G++}var N=E===G;if(N&&w)w=!1,I=[I,1];else if(N)w=!0,I=1;if(!w){let b={instancePath:Z+"/path",schemaPath:"#/properties/path/oneOf",keyword:"oneOf",params:{passingSchemas:I},message:"must match exactly one schema in oneOf"};if(Q===null)Q=[b];else Q.push(b);return G++,B$.errors=Q,!1}else if(G=R,Q!==null)if(R)Q.length=R;else Q=null;var A=C===G}else var A=!0;if(A){if($.cookies!==void 0){let M=$.cookies,C=G;if(G===C){if(!(M&&typeof M=="object"&&!Array.isArray(M)))return B$.errors=[{instancePath:Z+"/cookies",schemaPath:"#/properties/cookies/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1}var A=C===G}else var A=!0;if(A){if($.headers!==void 0){let M=$.headers,C=G;if(G===C){if(!(M&&typeof M=="object"&&!Array.isArray(M)))return B$.errors=[{instancePath:Z+"/headers",schemaPath:"#/properties/headers/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1}var A=C===G}else var A=!0;if(A){if($.query!==void 0){let M=$.query,C=G,R=G,w=!1,I=G;if(G===I){if(!(M&&typeof M=="object"&&!Array.isArray(M))){let E={instancePath:Z+"/query",schemaPath:"#/properties/query/anyOf/0/type",keyword:"type",params:{type:"object"},message:"must be object"};if(Q===null)Q=[E];else Q.push(E);G++}}var L=I===G;if(w=w||L,!w){let E=G;if(typeof M!=="string"){let b=typeof M,y=void 0;if(y===void 0)if(b=="number"||b=="boolean")y=""+M;else if(M===null)y="";else{let k={instancePath:Z+"/query",schemaPath:"#/properties/query/anyOf/1/type",keyword:"type",params:{type:"string"},message:"must be string"};if(Q===null)Q=[k];else Q.push(k);G++}if(y!==void 0){if(M=y,$!==void 0)$.query=y}}var L=E===G;w=w||L}if(!w){let E={instancePath:Z+"/query",schemaPath:"#/properties/query/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(Q===null)Q=[E];else Q.push(E);return G++,B$.errors=Q,!1}else if(G=R,Q!==null)if(R)Q.length=R;else Q=null;var A=C===G}else var A=!0;if(A){if($.simulate!==void 0){let M=$.simulate,C=G;if(G===C)if(M&&typeof M=="object"&&!Array.isArray(M)){if(M.end!==void 0){let w=M.end,I=G;if(typeof w!=="boolean"){let _=void 0;if(_===void 0)if(w==="false"||w===0||w===null)_=!1;else if(w==="true"||w===1)_=!0;else return B$.errors=[{instancePath:Z+"/simulate/end",schemaPath:"#/properties/simulate/properties/end/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(_!==void 0){if(w=_,M!==void 0)M.end=_}}var q=I===G}else var q=!0;if(q){if(M.split!==void 0){let w=M.split,I=G;if(typeof w!=="boolean"){let E=void 0;if(E===void 0)if(w==="false"||w===0||w===null)E=!1;else if(w==="true"||w===1)E=!0;else return B$.errors=[{instancePath:Z+"/simulate/split",schemaPath:"#/properties/simulate/properties/split/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E!==void 0){if(w=E,M!==void 0)M.split=E}}var q=I===G}else var q=!0;if(q){if(M.error!==void 0){let w=M.error,I=G;if(typeof w!=="boolean"){let E=void 0;if(E===void 0)if(w==="false"||w===0||w===null)E=!1;else if(w==="true"||w===1)E=!0;else return B$.errors=[{instancePath:Z+"/simulate/error",schemaPath:"#/properties/simulate/properties/error/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E!==void 0){if(w=E,M!==void 0)M.error=E}}var q=I===G}else var q=!0;if(q)if(M.close!==void 0){let w=M.close,I=G;if(typeof w!=="boolean"){let E=void 0;if(E===void 0)if(w==="false"||w===0||w===null)E=!1;else if(w==="true"||w===1)E=!0;else return B$.errors=[{instancePath:Z+"/simulate/close",schemaPath:"#/properties/simulate/properties/close/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(E!==void 0){if(w=E,M!==void 0)M.close=E}}var q=I===G}else var q=!0}}}else return B$.errors=[{instancePath:Z+"/simulate",schemaPath:"#/properties/simulate/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var A=C===G}else var A=!0;if(A){if($.authority!==void 0){let M=$.authority,C=G;if(typeof M!=="string"){let w=typeof M,I=void 0;if(I===void 0)if(w=="number"||w=="boolean")I=""+M;else if(M===null)I="";else return B$.errors=[{instancePath:Z+"/authority",schemaPath:"#/properties/authority/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!==void 0){if(M=I,$!==void 0)$.authority=I}}var A=C===G}else var A=!0;if(A){if($.remoteAddress!==void 0){let M=$.remoteAddress,C=G;if(typeof M!=="string"){let w=typeof M,I=void 0;if(I===void 0)if(w=="number"||w=="boolean")I=""+M;else if(M===null)I="";else return B$.errors=[{instancePath:Z+"/remoteAddress",schemaPath:"#/properties/remoteAddress/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!==void 0){if(M=I,$!==void 0)$.remoteAddress=I}}var A=C===G}else var A=!0;if(A){if($.method!==void 0){let M=$.method,C=G;if(typeof M!=="string"){let w=typeof M,I=void 0;if(I===void 0)if(w=="number"||w=="boolean")I=""+M;else if(M===null)I="";else return B$.errors=[{instancePath:Z+"/method",schemaPath:"#/properties/method/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(I!==void 0){if(M=I,$!==void 0)$.method=I}}if(!(M==="ACL"||M==="BIND"||M==="CHECKOUT"||M==="CONNECT"||M==="COPY"||M==="DELETE"||M==="GET"||M==="HEAD"||M==="LINK"||M==="LOCK"||M==="M-SEARCH"||M==="MERGE"||M==="MKACTIVITY"||M==="MKCALENDAR"||M==="MKCOL"||M==="MOVE"||M==="NOTIFY"||M==="OPTIONS"||M==="PATCH"||M==="POST"||M==="PROPFIND"||M==="PROPPATCH"||M==="PURGE"||M==="PUT"||M==="QUERY"||M==="REBIND"||M==="REPORT"||M==="SEARCH"||M==="SOURCE"||M==="SUBSCRIBE"||M==="TRACE"||M==="UNBIND"||M==="UNLINK"||M==="UNLOCK"||M==="UNSUBSCRIBE"||M==="acl"||M==="bind"||M==="checkout"||M==="connect"||M==="copy"||M==="delete"||M==="get"||M==="head"||M==="link"||M==="lock"||M==="m-search"||M==="merge"||M==="mkactivity"||M==="mkcalendar"||M==="mkcol"||M==="move"||M==="notify"||M==="options"||M==="patch"||M==="post"||M==="propfind"||M==="proppatch"||M==="purge"||M==="put"||M==="query"||M==="rebind"||M==="report"||M==="search"||M==="source"||M==="subscribe"||M==="trace"||M==="unbind"||M==="unlink"||M==="unlock"||M==="unsubscribe"))return B$.errors=[{instancePath:Z+"/method",schemaPath:"#/properties/method/enum",keyword:"enum",params:{allowedValues:CO0.properties.method.enum},message:"must be equal to one of the allowed values"}],!1;var A=C===G}else var A=!0;if(A)if($.validate!==void 0){let M=$.validate,C=G;if(typeof M!=="boolean"){let w=void 0;if(w===void 0)if(M==="false"||M===0||M===null)w=!1;else if(M==="true"||M===1)w=!0;else return B$.errors=[{instancePath:Z+"/validate",schemaPath:"#/properties/validate/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"}],!1;if(w!==void 0){if(M=w,$!==void 0)$.validate=w}}var A=C===G}else var A=!0}}}}}}}}}else return B$.errors=[{instancePath:Z,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;return B$.errors=Q,G===0}});var sg=S(($h0,hQ)=>{var EO0=Y0("assert"),rF=hg(),aW=cg(),ng=ig();function aF($,Z,J){if(J===void 0)return new xQ($,Z);else return tW($,Z,J)}function bO0($,Z){let J=$._lightMyRequest.payload;if(!J||J._readableState||typeof J.resume!=="function")return Z();let Y=[];J.on("data",(X)=>Y.push(Buffer.from(X))),J.on("end",()=>{let X=Buffer.concat(Y);return $.headers["content-length"]=$.headers["content-length"]||""+X.length,delete $.headers["transfer-encoding"],$._lightMyRequest.payload=X,Z()}),J.resume()}function og($,Z,J,Y){return J.once("error",function(X){if(this.destroyed)Y.destroy(X)}),J.once("close",function(){if(this.destroyed&&!this._error)Y.destroy()}),bO0(J,()=>$.call(Z,J,Y))}function tW($,Z,J){if(Z=typeof Z==="string"?{url:Z}:Z,Z.validate!==!1){if(EO0(typeof $==="function","dispatchFunc should be a function"),!ng(Z))throw Error(ng.errors.map((G)=>G.message))}let Y=Z.server||{},X=Z.Request?rF.CustomRequest:rF;if($.request&&$.request.app===$)Object.setPrototypeOf(Object.getPrototypeOf($.request),X.prototype),Object.setPrototypeOf(Object.getPrototypeOf($.response),aW.prototype);if(typeof J==="function"){let Q=new X(Z),G=new aW(Q,J);return og($,Y,Q,G)}else return new Promise((Q,G)=>{let W=new X(Z),K=new aW(W,Q,G);og($,Y,W,K)})}function xQ($,Z){if(typeof Z==="string")this.option={url:Z};else this.option=Object.assign({},Z);if(this.dispatch=$,this._hasInvoked=!1,this._promise=null,this.option.autoStart!==!1)process.nextTick(()=>{if(!this._hasInvoked)this.end()})}var _O0=["delete","get","head","options","patch","post","put","trace"];_O0.forEach(($)=>{xQ.prototype[$]=function(Z){if(this._hasInvoked===!0||this._promise)throw Error("The dispatch function has already been invoked");return this.option.url=Z,this.option.method=$.toUpperCase(),this}});var SO0=["body","cookies","headers","payload","query"];SO0.forEach(($)=>{xQ.prototype[$]=function(Z){if(this._hasInvoked===!0||this._promise)throw Error("The dispatch function has already been invoked");return this.option[$]=Z,this}});xQ.prototype.end=function($){if(this._hasInvoked===!0||this._promise)throw Error("The dispatch function has already been invoked");if(this._hasInvoked=!0,typeof $==="function")tW(this.dispatch,this.option,$);else return this._promise=tW(this.dispatch,this.option),this._promise};Object.getOwnPropertyNames(Promise.prototype).forEach(($)=>{if($==="constructor")return;xQ.prototype[$]=function(...Z){if(!this._promise){if(this._hasInvoked===!0)throw Error("The dispatch function has already been invoked");this._hasInvoked=!0,this._promise=tW(this.dispatch,this.option)}return this._promise[$](...Z)}});function fO0($){return $ instanceof rF||$ instanceof aW||$?.constructor?.name==="_CustomLMRRequest"}hQ.exports=aF;hQ.exports.default=aF;hQ.exports.inject=aF;hQ.exports.isInjection=fO0});var Hu=S((Zh0,dQ)=>{var kO0=gR(),JK=Y0("http"),vO0=Y0("diagnostics_channel"),gQ,{kAvvioBoot:uQ,kChildren:tF,kServerBindings:rg,kBodyLimit:yO0,kSupportedHTTPMethods:B7,kRoutePrefix:ag,kLogLevel:xO0,kLogSerializers:hO0,kHooks:eF,kSchemaController:X5,kRequestAcceptVersion:gO0,kReplySerializerDefault:tg,kContentTypeParser:uO0,kReply:mO0,kRequest:lO0,kFourOhFour:dO0,kState:$$,kOptions:$A,kPluginNameChain:mQ,kSchemaErrorFormatter:ZA,kErrorHandler:eW,kKeepAliveConnections:JA,kChildLoggerFactory:YA,kGenReqId:XA,kErrorHandlerAlreadySet:$K,kHandlerTimeout:pO0}=H$(),{createServer:cO0}=zP(),lQ=MG(),ZK=PG(),iO0=IG(),z7=mX(),F7=jz(),eg=XF(),{Hooks:nO0,hookRunnerApplication:$u,supportedHooks:QA}=uZ(),{createChildLogger:Zu,defaultChildLoggerFactory:oO0,createLogger:sO0}=yX(),Ju=UF(),{getGenReqId:Yu,reqIdGenFactory:Vu}=IW(),{buildRouting:rO0,validateBodyLimitOption:aO0,buildRouterOptions:tO0}=Jg(),eO0=Vg(),Uu=Hg(),$q0=Mg(),{appendStackTrace:Zq0,AVVIO_ERRORS_MAP:Xu,...A7}=L$(),Jq0=uH(),{defaultInitOptions:z8}=Uu,{FST_ERR_ASYNC_CONSTRAINT:Yq0,FST_ERR_BAD_URL:Xq0,FST_ERR_OPTIONS_NOT_OBJ:Qq0,FST_ERR_QSP_NOT_FN:Gq0,FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN:Wq0,FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ:Kq0,FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR:Vq0,FST_ERR_INSTANCE_ALREADY_LISTENING:Uq0,FST_ERR_REOPENED_CLOSE_SERVER:Hq0,FST_ERR_ROUTE_REWRITE_NOT_STR:Bq0,FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN:Qu,FST_ERR_ERROR_HANDLER_NOT_FN:zq0,FST_ERR_ERROR_HANDLER_ALREADY_SET:Fq0,FST_ERR_ROUTE_METHOD_INVALID:Aq0}=A7,{buildErrorHandler:Gu}=hX(),{FSTWRN004:Oq0}=wJ(),Wu=vO0.channel("fastify.initialization");function GA($){let{options:Z,genReqId:J,disableRequestLogging:Y,hasLogger:X,initialConfig:Q}=qq0($,f,b),G=rO0(Z.routerOptions),W=eO0(Z),K=u(G,Z),{server:V,listen:U,forceCloseConnections:H,serverHasCloseAllConnections:B,serverHasCloseHttp2Sessions:z,keepAliveConnections:F}=cO0(Z,K),A=lQ.setupResponseListeners,j=eg.buildSchemaController(null,Z.schemaController),N={[$$]:{listening:!1,closing:!1,started:!1,ready:!1,booting:!1,aborted:!1,readyResolver:null},[JA]:F,[B7]:{bodyless:new Set(["GET","HEAD","TRACE"]),bodywith:new Set(["DELETE","OPTIONS","PATCH","PUT","POST"])},[$A]:Z,[tF]:[],[rg]:[],[yO0]:Z.bodyLimit,[pO0]:Z.handlerTimeout,[ag]:"",[xO0]:"",[hO0]:null,[eF]:new nO0,[X5]:j,[ZA]:null,[eW]:Gu(),[$K]:!1,[YA]:Z.childLoggerFactory||oO0,[tg]:null,[uO0]:new F7(Z.bodyLimit,Z.onProtoPoisoning||z8.onProtoPoisoning,Z.onConstructorPoisoning||z8.onConstructorPoisoning),[mO0]:lQ.buildReply(lQ),[lO0]:ZK.buildRequest(ZK,Z.trustProxy),[dO0]:W,[Ju.kRegisteredPlugins]:[],[mQ]:["fastify"],[uQ]:null,[XA]:J,routing:K,delete:function(h,c,m){return G.prepareRoute.call(this,{method:"DELETE",url:h,options:c,handler:m})},get:function(h,c,m){return G.prepareRoute.call(this,{method:"GET",url:h,options:c,handler:m})},head:function(h,c,m){return G.prepareRoute.call(this,{method:"HEAD",url:h,options:c,handler:m})},trace:function(h,c,m){return G.prepareRoute.call(this,{method:"TRACE",url:h,options:c,handler:m})},patch:function(h,c,m){return G.prepareRoute.call(this,{method:"PATCH",url:h,options:c,handler:m})},post:function(h,c,m){return G.prepareRoute.call(this,{method:"POST",url:h,options:c,handler:m})},put:function(h,c,m){return G.prepareRoute.call(this,{method:"PUT",url:h,options:c,handler:m})},options:function(h,c,m){return G.prepareRoute.call(this,{method:"OPTIONS",url:h,options:c,handler:m})},all:function(h,c,m){return G.prepareRoute.call(this,{method:this.supportedMethods,url:h,options:c,handler:m})},route:function(h){return G.route.call(this,{options:h})},hasRoute:function(h){return G.hasRoute.call(this,{options:h})},findRoute:function(h){return G.findRoute(h)},log:Z.logger,withTypeProvider:I,addHook:_,addSchema:E,getSchema:j.getSchema.bind(j),getSchemas:j.getSchemas.bind(j),setValidatorCompiler:g,setSerializerCompiler:p,setSchemaController:t,setReplySerializer:r,setSchemaErrorFormatter:d,setGenReqId:l,addContentTypeParser:F7.helpers.addContentTypeParser,hasContentTypeParser:F7.helpers.hasContentTypeParser,getDefaultJsonParser:F7.defaultParsers.getDefaultJsonParser,defaultTextParser:F7.defaultParsers.defaultTextParser,removeContentTypeParser:F7.helpers.removeContentTypeParser,removeAllContentTypeParsers:F7.helpers.removeAllContentTypeParsers,register:null,after:null,ready:null,onClose:null,close:null,printPlugins:null,hasPlugin:function(v){return this[Ju.kRegisteredPlugins].includes(v)||this[mQ].includes(v)},listen:U,server:V,addresses:function(){let v=this[rg].map((h)=>h.address());return v.push(this.server.address()),v.filter((h)=>h)},decorate:z7.add,hasDecorator:z7.exist,decorateReply:z7.decorateReply,decorateRequest:z7.decorateRequest,hasRequestDecorator:z7.existRequest,hasReplyDecorator:z7.existReply,getDecorator:z7.getInstanceDecorator,addHttpMethod:$0,inject:R,printRoutes:h0,setNotFoundHandler:k,setErrorHandler:G0,setChildLoggerFactory:O0,initialConfig:Q,addConstraintStrategy:G.addConstraintStrategy.bind(G),hasConstraintStrategy:G.hasConstraintStrategy.bind(G)};if(Object.defineProperties(N,{listeningOrigin:{get(){let v=this.addresses().slice(-1).pop();if(typeof v==="string")return v;let h=v.family==="IPv6"?`[${v.address}]`:v.address;return`${this[$A].https?"https":"http"}://${h}:${v.port}`}},pluginName:{configurable:!0,get(){if(this[mQ].length>1)return this[mQ].join(" -> ");return this[mQ][0]}},prefix:{configurable:!0,get(){return this[ag]}},validatorCompiler:{configurable:!0,get(){return this[X5].getValidatorCompiler()}},serializerCompiler:{configurable:!0,get(){return this[X5].getSerializerCompiler()}},childLoggerFactory:{configurable:!0,get(){return this[YA]}},version:{configurable:!0,get(){return"5.8.5"}},errorHandler:{configurable:!0,get(){return this[eW].func}},genReqId:{configurable:!0,get(){return this[XA]}},supportedMethods:{configurable:!1,get(){return[...this[B7].bodyless,...this[B7].bodywith]}}}),Z.schemaErrorFormatter)Ku(Z.schemaErrorFormatter),N[ZA]=Z.schemaErrorFormatter.bind(N);let L=Number(Z.pluginTimeout),q=kO0(N,{autostart:!1,timeout:isNaN(L)===!1?L:z8.pluginTimeout,expose:{use:"register"}});q.override=$q0,q.on("start",()=>N[$$].started=!0),N[uQ]=N.ready,N.ready=w,N.printPlugins=q.prettyPrint.bind(q),q.once("preReady",()=>{N.onClose((v,h)=>{N[$$].closing=!0,G.closeRoutes(),$u("preClose",N[uQ],N,function(){if(N[$$].listening){if(H==="idle")v.server.closeIdleConnections();else if(B&&H)v.server.closeAllConnections();else if(H===!0)for(let c of N[JA])c.destroy(),N[JA].delete(c)}if(z)v.server.closeHttp2Sessions();if(!Z.serverFactory||N[$$].listening)v.server.close(function(c){if(c&&c.code!=="ERR_SERVER_NOT_RUNNING")h(null);else h()});else process.nextTick(h,null)})})});let M=new iO0({server:N,config:{}});if(N.setNotFoundHandler(),W.arrange404(N),G.setup(Z,{avvio:q,fourOhFour:W,hasLogger:X,setupResponseListeners:A,throwIfAlreadyStarted:C,keepAliveConnections:F}),V.on("clientError",Z.clientErrorHandler.bind(N)),Wu.hasSubscribers)Wu.publish({fastify:N});if("asyncDispose"in Symbol)N[Symbol.asyncDispose]=function(){return N.close()};return N;function C(v){if(N[$$].started)throw new Uq0(v)}function R(v,h){if(gQ===void 0)gQ=sg();if(N[$$].started){if(N[$$].closing){let c=new Hq0;if(h){h(c);return}else return Promise.reject(c)}return gQ(K,v,h)}if(h)this.ready((c)=>{if(c)h(c,null);else gQ(K,v,h)});else return gQ((c,m)=>{this.ready(function(a){if(a){m.emit("error",a);return}K(c,m)})},v)}function w(v){if(this[$$].readyResolver!==null){if(v!=null){this[$$].readyResolver.promise.then(()=>v(null,N),v);return}return this[$$].readyResolver.promise}if(process.nextTick(h),this[$$].readyResolver=Jq0.withResolvers(),!v)return this[$$].readyResolver.promise;else this[$$].readyResolver.promise.then(()=>v(null,N),v);function h(){N[uQ]((m,a)=>{if(m||N[$$].started||N[$$].ready||N[$$].booting)c(m);else N[$$].booting=!0,$u("onReady",N[uQ],N,c);a()})}function c(m){if(m=m!=null&&Xu[m.code]!=null?Zq0(m,new Xu[m.code](m.message)):m,m)return N[$$].readyResolver.reject(m);N[$$].readyResolver.resolve(N),N[$$].booting=!1,N[$$].ready=!0,N[$$].readyResolver=null}}function I(){return this}function _(v,h){if(C('Cannot call "addHook"!'),h==null)throw new A7.FST_ERR_HOOK_INVALID_HANDLER(v,h);if(v==="onSend"||v==="preSerialization"||v==="onError"||v==="preParsing"){if(h.constructor.name==="AsyncFunction"&&h.length===4)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER}else if(v==="onReady"||v==="onListen"){if(h.constructor.name==="AsyncFunction"&&h.length!==0)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER}else if(v==="onRequestAbort"){if(h.constructor.name==="AsyncFunction"&&h.length!==1)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER}else if(h.constructor.name==="AsyncFunction"&&h.length===3)throw new A7.FST_ERR_HOOK_INVALID_ASYNC_HANDLER;if(v==="onClose")this.onClose(h.bind(this));else if(v==="onReady"||v==="onListen"||v==="onRoute")this[eF].add(v,h);else this.after((m,a)=>{try{c.call(this,v,h),a(m)}catch(e){a(e)}});return this;function c(m,a){this[eF].add(m,a),this[tF].forEach((e)=>c.call(e,m,a))}}function E(v){return C('Cannot call "addSchema"!'),this[X5].add(v),this[tF].forEach((h)=>h.addSchema(v)),this}function f(v,h){if(v.headers["accept-version"]!==void 0)v.headers[gO0]=v.headers["accept-version"],v.headers["accept-version"]=void 0;W.router.lookup(v,h)}function b(v,h,c){if(Z.frameworkErrors){let a=Yu(M.server,h),e=Zu(M,Z.logger,h,a),H0=new ZK(a,null,h,null,e,M),A0=new lQ(c,H0,e);if((typeof Y==="function"?Y(h):Y)===!1)e.info({req:H0},"incoming request");return Z.frameworkErrors(new Xq0(v),H0,A0)}let m=JSON.stringify({error:"Bad Request",code:"FST_ERR_BAD_URL",message:`'${v}' is not a valid url component`,statusCode:400});c.writeHead(400,{"Content-Type":"application/json","Content-Length":Buffer.byteLength(m)}),c.end(m)}function y(v,h,c){if(v===!1)return;return function(a){if(a){if(Z.frameworkErrors){let H0=Yu(M.server,h),A0=Zu(M,Z.logger,h,H0),P0=new ZK(H0,null,h,null,A0,M),s0=new lQ(c,P0,A0);if((typeof Y==="function"?Y(h):Y)===!1)A0.info({req:P0},"incoming request");return Z.frameworkErrors(new Yq0,P0,s0)}let e='{"error":"Internal Server Error","message":"Unexpected error from async constraint","statusCode":500}';c.writeHead(500,{"Content-Type":"application/json","Content-Length":e.length}),c.end(e)}}}function k(v,h){return C('Cannot call "setNotFoundHandler"!'),W.setNotFoundHandler.call(this,v,h,q,G.routeHandler),this}function g(v){return C('Cannot call "setValidatorCompiler"!'),this[X5].setValidatorCompiler(v),this}function d(v){return C('Cannot call "setSchemaErrorFormatter"!'),Ku(v),this[ZA]=v.bind(this),this}function p(v){return C('Cannot call "setSerializerCompiler"!'),this[X5].setSerializerCompiler(v),this}function t(v){C('Cannot call "setSchemaController"!');let h=this[X5],c=eg.buildSchemaController(h,Object.assign({},h.opts,v));return this[X5]=c,this.getSchema=c.getSchema.bind(c),this.getSchemas=c.getSchemas.bind(c),this}function r(v){return C('Cannot call "setReplySerializer"!'),this[tg]=v,this}function G0(v){if(C('Cannot call "setErrorHandler"!'),typeof v!=="function")throw new zq0;if(!Z.allowErrorHandlerOverride&&this[$K])throw new Fq0;else if(this[$K])Oq0("To disable this behavior, set 'allowErrorHandlerOverride' to false or ignore this message. For more information, visit: https://fastify.dev/docs/latest/Reference/Server/#allowerrorhandleroverride");return this[$K]=!0,this[eW]=Gu(this[eW],v.bind(this)),this}function O0(v){return C('Cannot call "setChildLoggerFactory"!'),this[YA]=v,this}function h0(v={}){return v.includeMeta=v.includeHooks?v.includeMeta?QA.concat(v.includeMeta):QA:v.includeMeta,G.printRoutes(v)}function u(v,{rewriteUrl:h,logger:c}){let m;return function(e,H0){if(m===void 0)m=v.isAsyncConstraint();if(h){e.originalUrl=e.url;let A0=h.call(N,e);if(typeof A0==="string")e.url=A0;else{let P0=new Bq0(e.url,typeof A0);e.destroy(P0)}}v.routing(e,H0,y(m,e,H0))}}function l(v){return C('Cannot call "setGenReqId"!'),this[XA]=Vu(this[$A].requestIdHeader,v),this}function $0(v,{hasBody:h=!1}={}){if(typeof v!=="string"||JK.METHODS.indexOf(v)===-1)throw new Aq0;if(h===!0)this[B7].bodywith.add(v),this[B7].bodyless.delete(v);else this[B7].bodywith.delete(v),this[B7].bodyless.add(v);let c=v.toLowerCase();if(!this.hasDecorator(c))this.decorate(c,function(m,a,e){return G.prepareRoute.call(this,{method:v,url:m,options:a,handler:e})});return this}}function qq0($,Z,J){if($&&typeof $!=="object")throw new Qq0;else $=Object.assign({},$);if($.querystringParser&&typeof $.querystringParser!=="function"||$.routerOptions?.querystringParser&&typeof $.routerOptions.querystringParser!=="function")throw new Gq0(typeof($.querystringParser??$.routerOptions.querystringParser));if($.schemaController&&$.schemaController.bucket&&typeof $.schemaController.bucket!=="function")throw new Wq0(typeof $.schemaController.bucket);aO0($.bodyLimit);let Y=typeof $.requestIdHeader==="string"&&$.requestIdHeader.length!==0?$.requestIdHeader.toLowerCase():$.requestIdHeader===!0&&"request-id",X=Vu(Y,$.genReqId),Q=$.requestIdLogLabel||"reqId";$.bodyLimit=$.bodyLimit||z8.bodyLimit;let G=$.disableRequestLogging||!1,W=Object.assign({customOptions:{},plugins:[]},$.ajv);if(!W.customOptions||Object.prototype.toString.call(W.customOptions)!=="[object Object]")throw new Kq0(typeof W.customOptions);if(!W.plugins||!Array.isArray(W.plugins))throw new Vq0(typeof W.plugins);let{logger:K,hasLogger:V}=sO0($);$.connectionTimeout=$.connectionTimeout||z8.connectionTimeout,$.keepAliveTimeout=$.keepAliveTimeout||z8.keepAliveTimeout,$.maxRequestsPerSocket=$.maxRequestsPerSocket||z8.maxRequestsPerSocket,$.requestTimeout=$.requestTimeout||z8.requestTimeout,$.logger=K,$.requestIdHeader=Y,$.requestIdLogLabel=Q,$.disableRequestLogging=G,$.ajv=W,$.clientErrorHandler=$.clientErrorHandler||Nq0,$.allowErrorHandlerOverride=$.allowErrorHandlerOverride??z8.allowErrorHandlerOverride;let U=Uu($);return $.exposeHeadRoutes=U.exposeHeadRoutes,$.http2SessionTimeout=U.http2SessionTimeout,$.routerOptions=tO0($,{defaultRoute:Z,onBadUrl:J,ignoreTrailingSlash:z8.ignoreTrailingSlash,ignoreDuplicateSlashes:z8.ignoreDuplicateSlashes,maxParamLength:z8.maxParamLength,allowUnsafeRegex:z8.allowUnsafeRegex,buildPrettyMeta:jq0,useSemicolonDelimiter:z8.useSemicolonDelimiter}),{options:$,genReqId:X,disableRequestLogging:G,hasLogger:V,initialConfig:U}}function jq0($){let Z={};return["errorHandler","logLevel","logSerializers"].concat(QA).forEach((Y)=>{Z[Y]=$.store[Y]}),Object.assign({},Z)}function Nq0($,Z){if($.code==="ECONNRESET"||Z.destroyed)return;let J,Y,X,Q;if($.code==="ERR_HTTP_REQUEST_TIMEOUT")Y="408",X=JK.STATUS_CODES[Y],J=`{"error":"${X}","message":"Client Timeout","statusCode":408}`,Q="timeout";else if($.code==="HPE_HEADER_OVERFLOW")Y="431",X=JK.STATUS_CODES[Y],J=`{"error":"${X}","message":"Exceeded maximum allowed HTTP header size","statusCode":431}`,Q="header_overflow";else Y="400",X=JK.STATUS_CODES[Y],J=`{"error":"${X}","message":"Client Error","statusCode":400}`,Q="error";if(this.log.trace({err:$},`client ${Q}`),Z.writable)Z.write(`HTTP/1.1 ${Y} ${X}\r
453
- Content-Length: ${J.length}\r
454
- Content-Type: application/json\r
455
- \r
456
- ${J}`);Z.destroy($)}function Ku($){if(typeof $!=="function")throw new Qu(typeof $);else if($.constructor.name==="AsyncFunction")throw new Qu("AsyncFunction")}dQ.exports=GA;dQ.exports.errorCodes=A7;dQ.exports.fastify=GA;dQ.exports.default=GA});var zu=S((Jh0,WA)=>{var Mq0=/at\s(?:.*\.)?plugin\s.*\n\s*(.*)/,Dq0=/(\w*(\.\w*)*)\..*/;WA.exports=function(Z){if(Z.name.length>0)return Z.name;let J=Error.stackTraceLimit;Error.stackTraceLimit=10;try{throw Error("anonymous function")}catch(Y){return Error.stackTraceLimit=J,Bu(Y.stack)}};function Bu($){let Z=$.match(Mq0);return Z?Z[1].split(/[/\\]/).slice(-1)[0].match(Dq0)[1]:"anonymous"}WA.exports.extractPluginName=Bu});var Au=S((Yh0,Fu)=>{Fu.exports=function(Z){if(Z[0]==="@")Z=Z.slice(1).replace("/","-");return Z.replace(/-(.)/g,function(J,Y){return Y.toUpperCase()})}});var Ou=S((Xh0,YK)=>{var wq0=zu(),Lq0=Au(),Tq0=0;function KA($,Z={}){let J=!1;if($.default!==void 0)$=$.default;if(typeof $!=="function")throw TypeError(`fastify-plugin expects a function, instead got a '${typeof $}'`);if(typeof Z==="string")Z={fastify:Z};if(typeof Z!=="object"||Array.isArray(Z)||Z===null)throw TypeError("The options object should be an object");if(Z.fastify!==void 0&&typeof Z.fastify!=="string")throw TypeError(`fastify-plugin expects a version string, instead got '${typeof Z.fastify}'`);if(!Z.name)J=!0,Z.name=wq0($)+"-auto-"+Tq0++;if($[Symbol.for("skip-override")]=Z.encapsulate!==!0,$[Symbol.for("fastify.display-name")]=Z.name,$[Symbol.for("plugin-meta")]=Z,!$.default)$.default=$;let Y=Lq0(Z.name);if(!J&&!$[Y])$[Y]=$;return $}YK.exports=KA;YK.exports.default=KA;YK.exports.fastifyPlugin=KA});var qu=S((Cq0)=>{var Rq0=/^(-?(?:\d+)?\.?\d+) *(m(?:illiseconds?|s(?:ecs?)?))?(s(?:ec(?:onds?|s)?)?)?(m(?:in(?:utes?|s)?)?)?(h(?:ours?|rs?)?)?(d(?:ays?)?)?(w(?:eeks?|ks?)?)?(y(?:ears?|rs?)?)?$/,XK=1000,QK=XK*60,GK=QK*60,cQ=GK*24,VA=cQ*365.25;function Pq0($){var Z,J=$.toLowerCase().match(Rq0);if(J!=null&&(Z=parseFloat(J[1]))){if(J[3]!=null)return Z*XK;if(J[4]!=null)return Z*QK;if(J[5]!=null)return Z*GK;if(J[6]!=null)return Z*cQ;if(J[7]!=null)return Z*cQ*7;if(J[8]!=null)return Z*VA;return Z}}function pQ($,Z,J,Y){var X=($|0)===$?$:~~($+0.5);return Z+X+(Y?" "+J+(X!=1?"s":""):J[0])}function Iq0($,Z){var J=$<0?"-":"",Y=$<0?-$:$;if(Y<XK)return $+(Z?" ms":"ms");if(Y<QK)return pQ(Y/XK,J,"second",Z);if(Y<GK)return pQ(Y/QK,J,"minute",Z);if(Y<cQ)return pQ(Y/GK,J,"hour",Z);if(Y<VA)return pQ(Y/cQ,J,"day",Z);return pQ(Y/VA,J,"year",Z)}Cq0.format=Iq0;Cq0.parse=Pq0});var Nu=S((Gh0,ju)=>{var{LruMap:_q0}=Bz();function WK($,Z,J=5000){this.continueExceeding=$,this.exponentialBackoff=Z,this.lru=new _q0(J)}WK.prototype.incr=function($,Z,J,Y){let X=Date.now(),Q=this.lru.get($);if(!Q)Q={current:1,ttl:J,iterationStartMs:X};else if(Q.iterationStartMs+J<=X)Q.current=1,Q.ttl=J,Q.iterationStartMs=X;else if(++Q.current,this.continueExceeding&&Q.current>Y)Q.ttl=J,Q.iterationStartMs=X;else if(this.exponentialBackoff&&Q.current>Y){let G=Q.current-Y-1,W=J*2**G;Q.ttl=Number.isSafeInteger(W)?W:Number.MAX_SAFE_INTEGER,Q.iterationStartMs=X}else Q.ttl=J-(X-Q.iterationStartMs);this.lru.set($,Q),Z(null,Q)};WK.prototype.child=function($){return new WK($.continueExceeding,$.exponentialBackoff,$.cache)};ju.exports=WK});var Du=S((Wh0,Mu)=>{function KK($,Z,J,Y="fastify-rate-limit-"){if(this.continueExceeding=$,this.exponentialBackoff=Z,this.redis=J,this.key=Y,!this.redis.rateLimit)this.redis.defineCommand("rateLimit",{numberOfKeys:1,lua:`
457
- -- Key to operate on
458
- local key = KEYS[1]
459
- -- Time window for the TTL
460
- local timeWindow = tonumber(ARGV[1])
461
- -- Max requests
462
- local max = tonumber(ARGV[2])
463
- -- Flag to determine if TTL should be reset after exceeding
464
- local continueExceeding = ARGV[3] == 'true'
465
- --Flag to determine if exponential backoff should be applied
466
- local exponentialBackoff = ARGV[4] == 'true'
467
-
468
- --Max safe integer
469
- local MAX_SAFE_INTEGER = (2^53) - 1
470
-
471
- -- Increment the key's value
472
- local current = redis.call('INCR', key)
473
-
474
- if current == 1 or (continueExceeding and current > max) then
475
- redis.call('PEXPIRE', key, timeWindow)
476
- elseif exponentialBackoff and current > max then
477
- local backoffExponent = current - max - 1
478
- timeWindow = math.min(timeWindow * (2 ^ backoffExponent), MAX_SAFE_INTEGER)
479
- redis.call('PEXPIRE', key, timeWindow)
480
- else
481
- timeWindow = redis.call('PTTL', key)
482
- end
483
-
484
- return {current, timeWindow}
485
- `})}KK.prototype.incr=function($,Z,J,Y){this.redis.rateLimit(this.key+$,J,Y,this.continueExceeding,this.exponentialBackoff,(X,Q)=>{X?Z(X,null):Z(null,{current:Q[0],ttl:Q[1]})})};KK.prototype.child=function($){return new KK($.continueExceeding,$.exponentialBackoff,this.redis,`${this.key}${$.routeInfo.method}${$.routeInfo.url}-`)};Mu.exports=KK});var Cu=S((Kh0,VK)=>{var Sq0=Ou(),{parse:Tu,format:fq0}=qu(),kq0=Nu(),vq0=Du(),yq0={rateLimit:"x-ratelimit-limit",rateRemaining:"x-ratelimit-remaining",rateReset:"x-ratelimit-reset",retryAfter:"retry-after"},xq0={rateLimit:"ratelimit-limit",rateRemaining:"ratelimit-remaining",rateReset:"ratelimit-reset",retryAfter:"retry-after"},UA=()=>{},hq0=($)=>$.ip,gq0=($,Z)=>{let J=Error(`Rate limit exceeded, retry in ${Z.after}`);return J.statusCode=Z.statusCode,J};async function HA($,Z){let J={global:typeof Z.global==="boolean"?Z.global:!0};if(typeof Z.enableDraftSpec==="boolean"&&Z.enableDraftSpec)J.enableDraftSpec=!0,J.labels=xq0;else J.enableDraftSpec=!1,J.labels=yq0;if(J.addHeaders=Object.assign({[J.labels.rateLimit]:!0,[J.labels.rateRemaining]:!0,[J.labels.rateReset]:!0,[J.labels.retryAfter]:!0},Z.addHeaders),J.addHeadersOnExceeding=Object.assign({[J.labels.rateLimit]:!0,[J.labels.rateRemaining]:!0,[J.labels.rateReset]:!0},Z.addHeadersOnExceeding),Number.isFinite(Z.max)&&Z.max>=0)J.max=Math.trunc(Z.max);else if(typeof Z.max==="function")J.max=Z.max;else J.max=1000;if(Number.isFinite(Z.timeWindow)&&Z.timeWindow>=0)J.timeWindow=Math.trunc(Z.timeWindow);else if(typeof Z.timeWindow==="string")J.timeWindow=Tu(Z.timeWindow);else if(typeof Z.timeWindow==="function")J.timeWindow=Z.timeWindow;else J.timeWindow=60000;if(J.hook=Z.hook||"onRequest",J.allowList=Z.allowList||Z.whitelist||null,J.ban=Number.isFinite(Z.ban)&&Z.ban>=0?Math.trunc(Z.ban):-1,J.onBanReach=typeof Z.onBanReach==="function"?Z.onBanReach:UA,J.onExceeding=typeof Z.onExceeding==="function"?Z.onExceeding:UA,J.onExceeded=typeof Z.onExceeded==="function"?Z.onExceeded:UA,J.continueExceeding=typeof Z.continueExceeding==="boolean"?Z.continueExceeding:!1,J.exponentialBackoff=typeof Z.exponentialBackoff==="boolean"?Z.exponentialBackoff:!1,J.keyGenerator=typeof Z.keyGenerator==="function"?Z.keyGenerator:hq0,typeof Z.errorResponseBuilder==="function")J.errorResponseBuilder=Z.errorResponseBuilder,J.isCustomErrorMessage=!0;else J.errorResponseBuilder=gq0,J.isCustomErrorMessage=!1;J.skipOnError=typeof Z.skipOnError==="boolean"?Z.skipOnError:!1;let Y={rateLimitRan:Symbol("fastify.request.rateLimitRan"),store:null};if(Z.store){let X=Z.store;Y.store=new X(J)}else if(Z.redis)Y.store=new vq0(J.continueExceeding,J.exponentialBackoff,Z.redis,Z.nameSpace);else Y.store=new kq0(J.continueExceeding,J.exponentialBackoff,Z.cache);if($.decorateRequest(Y.rateLimitRan,!1),!$.hasDecorator("createRateLimit"))$.decorate("createRateLimit",(X)=>{let Q=wu(Y,J,X);return(G)=>Pu.apply(this,Q.concat(G))});if(!$.hasDecorator("rateLimit"))$.decorate("rateLimit",(X)=>{let Q=wu(Y,J,X);return Iu(...Q)});$.addHook("onRoute",(X)=>{if(X.config?.rateLimit!=null){if(typeof X.config.rateLimit==="object"){let Q=Object.create(Y),G=Ru(J,X.config.rateLimit,{routeInfo:X});Q.store=Y.store.child(G),Lu(Q,G,X)}else if(X.config.rateLimit!==!1)throw Error("Unknown value for route rate-limit configuration")}else if(J.global)Lu(Y,J,X)})}function Ru(...$){let Z=Object.assign({},...$);if(Number.isFinite(Z.timeWindow)&&Z.timeWindow>=0)Z.timeWindow=Math.trunc(Z.timeWindow);else if(typeof Z.timeWindow==="string")Z.timeWindow=Tu(Z.timeWindow);else if(typeof Z.timeWindow!=="function")Z.timeWindow=60000;if(Number.isFinite(Z.max)&&Z.max>=0)Z.max=Math.trunc(Z.max);else if(typeof Z.max!=="function")Z.max=1000;if(Number.isFinite(Z.ban)&&Z.ban>=0)Z.ban=Math.trunc(Z.ban);else Z.ban=-1;if(Z.groupId!==void 0&&typeof Z.groupId!=="string")throw Error("groupId must be a string");return Z}function wu($,Z,J){if(typeof J==="object"){let Y=Object.create($),X=Ru(Z,J,{routeInfo:{}});return Y.store=Y.store.child(X),[Y,X]}return[$,Z]}function Lu($,Z,J){let Y=Z.hook,X=Iu($,Z);if(Array.isArray(J[Y]))J[Y].push(X);else if(typeof J[Y]==="function")J[Y]=[J[Y],X];else J[Y]=[X]}async function Pu($,Z,J){let{store:Y}=$,X=await Z.keyGenerator(J),Q=J.routeOptions.config?.rateLimit?.groupId;if(Q)X+=Q;if(Z.allowList){if(typeof Z.allowList==="function"){if(await Z.allowList(J,X))return{isAllowed:!0,key:X}}else if(Z.allowList.indexOf(X)!==-1)return{isAllowed:!0,key:X}}let G=typeof Z.max==="number"?Z.max:await Z.max(J,X),W=typeof Z.timeWindow==="number"?Z.timeWindow:await Z.timeWindow(J,X),K=0,V=0,U=0;try{let H=await new Promise((B,z)=>{Y.incr(X,(F,A)=>{F?z(F):B(A)},W,G)});K=H.current,V=H.ttl,U=Math.ceil(H.ttl/1000)}catch(H){if(!Z.skipOnError)throw H}return{isAllowed:!1,key:X,max:G,timeWindow:W,remaining:Math.max(0,G-K),ttl:V,ttlInSeconds:U,isExceeded:K>G,isBanned:Z.ban!==-1&&K-G>Z.ban}}function Iu($,Z){let{rateLimitRan:J}=$;return async(Y,X)=>{if(Y[J])return;Y[J]=!0;let Q=await Pu($,Z,Y);if(Q.isAllowed)return;let{key:G,max:W,remaining:K,ttl:V,ttlInSeconds:U,isExceeded:H,isBanned:B}=Q;if(!H){if(Z.addHeadersOnExceeding[Z.labels.rateLimit])X.header(Z.labels.rateLimit,W);if(Z.addHeadersOnExceeding[Z.labels.rateRemaining])X.header(Z.labels.rateRemaining,K);if(Z.addHeadersOnExceeding[Z.labels.rateReset])X.header(Z.labels.rateReset,U);Z.onExceeding(Y,G);return}if(Z.onExceeded(Y,G),Z.addHeaders[Z.labels.rateLimit])X.header(Z.labels.rateLimit,W);if(Z.addHeaders[Z.labels.rateRemaining])X.header(Z.labels.rateRemaining,0);if(Z.addHeaders[Z.labels.rateReset])X.header(Z.labels.rateReset,U);if(Z.addHeaders[Z.labels.retryAfter])X.header(Z.labels.retryAfter,U);let z={statusCode:429,ban:!1,max:W,ttl:V,after:fq0(U*1000,!0)};if(B)z.statusCode=403,z.ban=!0,Z.onBanReach(Y,G);throw Z.errorResponseBuilder(Y,z)}}VK.exports=Sq0(HA,{fastify:"5.x",name:"@fastify/rate-limit"});VK.exports.default=HA;VK.exports.fastifyRateLimit=HA});var km=S((fm,jK)=>{(($,Z)=>{if(typeof define==="function"&&define.amd)define([],Z);else if(typeof jK==="object"&&jK.exports)jK.exports=Z();else $.fuzzysort=Z()})(fm,($)=>{var Z=(u,l)=>{if(!u||!l)return r;var $0=z(u);if(!g(l))l=B(l);var v=$0.bitflags;if((v&l._bitflags)!==v)return r;return A($0,l)},J=(u,l,$0)=>{if(!u)return $0?.all?F(l,$0):t;var v=z(u),h=v.bitflags,c=v.containsSpace,m=U($0?.threshold||0),a=$0?.limit||d,e=0,H0=0,A0=l.length;function P0(x){if(e<a)h0.add(x),++e;else if(++H0,x._score>h0.peek()._score)h0.replaceTop(x)}if($0?.key){var s0=$0.key;for(var o=0;o<A0;++o){var K0=l[o],z0=k(K0,s0);if(!z0)continue;if(!g(z0))z0=B(z0);if((h&z0._bitflags)!==h)continue;var j0=A(v,z0);if(j0===r)continue;if(j0._score<m)continue;j0.obj=K0,P0(j0)}}else if($0?.keys){var Q1=$0.keys,_0=Q1.length;$:for(var o=0;o<A0;++o){var K0=l[o];{var e0=0;for(var S0=0;S0<_0;++S0){var s0=Q1[S0],z0=k(K0,s0);if(!z0){b[S0]=G0;continue}if(!g(z0))z0=B(z0);b[S0]=z0,e0|=z0._bitflags}if((h&e0)!==h)continue}if(c)for(let n=0;n<v.spaceSearches.length;n++)E[n]=p;for(var S0=0;S0<_0;++S0){if(z0=b[S0],z0===G0){y[S0]=G0;continue}if(y[S0]=A(v,z0,!1,c),y[S0]===r){y[S0]=G0;continue}if(c)for(let J0=0;J0<v.spaceSearches.length;J0++){if(f[J0]>-1000){if(E[J0]>p){var C1=(E[J0]+f[J0])/4;if(C1>E[J0])E[J0]=C1}}if(f[J0]>E[J0])E[J0]=f[J0]}}if(c){for(let n=0;n<v.spaceSearches.length;n++)if(E[n]===p)continue $}else{var n0=!1;for(let n=0;n<_0;n++)if(y[n]._score!==p){n0=!0;break}if(!n0)continue}var z1=new W(_0);for(let n=0;n<_0;n++)z1[n]=y[n];if(c){var a0=0;for(let n=0;n<v.spaceSearches.length;n++)a0+=E[n]}else{var a0=p;for(let J0=0;J0<_0;J0++){var j0=z1[J0];if(j0._score>-1000){if(a0>p){var C1=(a0+j0._score)/4;if(C1>a0)a0=C1}}if(j0._score>a0)a0=j0._score}}if(z1.obj=K0,z1._score=a0,$0?.scoreFn){if(a0=$0.scoreFn(z1),!a0)continue;a0=U(a0),z1._score=a0}if(a0<m)continue;P0(z1)}}else for(var o=0;o<A0;++o){var z0=l[o];if(!z0)continue;if(!g(z0))z0=B(z0);if((h&z0._bitflags)!==h)continue;var j0=A(v,z0);if(j0===r)continue;if(j0._score<m)continue;P0(j0)}if(e===0)return t;var U1=Array(e);for(var o=e-1;o>=0;--o)U1[o]=h0.poll();return U1.total=e+H0,U1},Y=(u,l="<b>",$0="</b>")=>{var v=typeof l==="function"?l:void 0,h=u.target,c=h.length,m=u.indexes,a="",e=0,H0=0,A0=!1,P0=[];for(var s0=0;s0<c;++s0){var o=h[s0];if(m[H0]===s0){if(++H0,!A0)if(A0=!0,v)P0.push(a),a="";else a+=l;if(H0===m.length){if(v)a+=o,P0.push(v(a,e++)),a="",P0.push(h.substr(s0+1));else a+=o+$0+h.substr(s0+1);break}}else if(A0)if(A0=!1,v)P0.push(v(a,e++)),a="";else a+=$0;a+=o}return v?P0:a},X=(u)=>{if(typeof u==="number")u=""+u;else if(typeof u!=="string")u="";var l=L(u);return K(u,{_targetLower:l._lower,_targetLowerCodes:l.lowerCodes,_bitflags:l.bitflags})},Q=()=>{C.clear(),R.clear()};class G{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((u,l)=>u-l)}set["indexes"](u){return this._indexes=u}["highlight"](u,l){return Y(this,u,l)}get["score"](){return V(this._score)}set["score"](u){this._score=U(u)}}class W extends Array{get["score"](){return V(this._score)}set["score"](u){this._score=U(u)}}var K=(u,l)=>{let $0=new G;return $0.target=u,$0.obj=l.obj??r,$0._score=l._score??p,$0._indexes=l._indexes??[],$0._targetLower=l._targetLower??"",$0._targetLowerCodes=l._targetLowerCodes??r,$0._nextBeginningIndexes=l._nextBeginningIndexes??r,$0._bitflags=l._bitflags??0,$0},V=(u)=>{if(u===p)return 0;if(u>1)return u;return Math.E**(((-u+1)**0.04307-1)*-2)},U=(u)=>{if(u===0)return p;if(u>1)return u;return 1-Math.pow(Math.log(u)/-2+1,23.218017181332716)},H=(u)=>{if(typeof u==="number")u=""+u;else if(typeof u!=="string")u="";u=u.trim();var l=L(u),$0=[];if(l.containsSpace){var v=u.split(/\s+/);v=[...new Set(v)];for(var h=0;h<v.length;h++){if(v[h]==="")continue;var c=L(v[h]);$0.push({lowerCodes:c.lowerCodes,_lower:v[h].toLowerCase(),containsSpace:!1})}}return{lowerCodes:l.lowerCodes,_lower:l._lower,containsSpace:l.containsSpace,bitflags:l.bitflags,spaceSearches:$0}},B=(u)=>{if(u.length>999)return X(u);var l=C.get(u);if(l!==void 0)return l;return l=X(u),C.set(u,l),l},z=(u)=>{if(u.length>999)return H(u);var l=R.get(u);if(l!==void 0)return l;return l=H(u),R.set(u,l),l},F=(u,l)=>{var $0=[];$0.total=u.length;var v=l?.limit||d;if(l?.key)for(var h=0;h<u.length;h++){var c=u[h],m=k(c,l.key);if(m==r)continue;if(!g(m))m=B(m);var a=K(m.target,{_score:m._score,obj:c});if($0.push(a),$0.length>=v)return $0}else if(l?.keys)for(var h=0;h<u.length;h++){var c=u[h],e=new W(l.keys.length);for(var H0=l.keys.length-1;H0>=0;--H0){var m=k(c,l.keys[H0]);if(!m){e[H0]=G0;continue}if(!g(m))m=B(m);m._score=p,m._indexes.len=0,e[H0]=m}if(e.obj=c,e._score=p,$0.push(e),$0.length>=v)return $0}else for(var h=0;h<u.length;h++){var m=u[h];if(m==r)continue;if(!g(m))m=B(m);if(m._score=p,m._indexes.len=0,$0.push(m),$0.length>=v)return $0}return $0},A=(u,l,$0=!1,v=!1)=>{if($0===!1&&u.containsSpace)return j(u,l,v);var{_lower:h,lowerCodes:c}=u,m=c[0],a=l._targetLowerCodes,e=c.length,H0=a.length,o=0,A0=0,P0=0;for(;;){var s0=m===a[A0];if(s0){if(w[P0++]=A0,++o,o===e)break;m=c[o]}if(++A0,A0>=H0)return r}var o=0,K0=!1,z0=0,j0=l._nextBeginningIndexes;if(j0===r)j0=l._nextBeginningIndexes=M(l.target);A0=w[0]===0?0:j0[w[0]-1];var Q1=0;if(A0!==H0)for(;;)if(A0>=H0){if(o<=0)break;if(++Q1,Q1>200)break;--o;var _0=I[--z0];A0=j0[_0]}else{var s0=c[o]===a[A0];if(s0){if(I[z0++]=A0,++o,o===e){K0=!0;break}++A0}else A0=j0[A0]}var e0=e<=1?-1:l._targetLower.indexOf(h,w[0]),S0=!!~e0,C1=!S0?!1:e0===0||l._nextBeginningIndexes[e0-1]===e0;if(S0&&!C1)for(var n0=0;n0<j0.length;n0=j0[n0]){if(n0<=e0)continue;for(var z1=0;z1<e;z1++)if(c[z1]!==l._targetLowerCodes[n0+z1])break;if(z1===e){e0=n0,C1=!0;break}}var a0=(n)=>{var J0=0,C0=0;for(var M0=1;M0<e;++M0)if(n[M0]-n[M0-1]!==1)J0-=n[M0],++C0;var D1=n[e-1]-n[0]-(e-1);if(J0-=(12+D1)*C0,n[0]!==0)J0-=n[0]*n[0]*0.2;if(!K0)J0*=1000;else{var g0=1;for(var M0=j0[0];M0<H0;M0=j0[M0])++g0;if(g0>24)J0*=(g0-24)*10}if(J0-=(H0-e)/2,S0)J0/=1+e*e*1;if(C1)J0/=1+e*e*1;return J0-=(H0-e)/2,J0};if(!K0){if(S0)for(var n0=0;n0<e;++n0)w[n0]=e0+n0;var U1=w,x=a0(U1)}else if(C1){for(var n0=0;n0<e;++n0)w[n0]=e0+n0;var U1=w,x=a0(w)}else var U1=I,x=a0(I);l._score=x;for(var n0=0;n0<e;++n0)l._indexes[n0]=U1[n0];l._indexes.len=e;let i=new G;return i.target=l.target,i._score=l._score,i._indexes=l._indexes,i},j=(u,l,$0)=>{var v=new Set,h=0,c=r,m=0,a=u.spaceSearches,e=a.length,H0=0,A0=()=>{for(let C1=H0-1;C1>=0;C1--)l._nextBeginningIndexes[_[C1*2+0]]=_[C1*2+1]},P0=!1;for(var S0=0;S0<e;++S0){f[S0]=p;var s0=a[S0];if(c=A(s0,l),$0){if(c===r)continue;P0=!0}else if(c===r)return A0(),r;var o=S0===e-1;if(!o){var K0=c._indexes,z0=!0;for(let n0=0;n0<K0.len-1;n0++)if(K0[n0+1]-K0[n0]!==1){z0=!1;break}if(z0){var j0=K0[K0.len-1]+1,Q1=l._nextBeginningIndexes[j0-1];for(let n0=j0-1;n0>=0;n0--){if(Q1!==l._nextBeginningIndexes[n0])break;l._nextBeginningIndexes[n0]=j0,_[H0*2+0]=n0,_[H0*2+1]=Q1,H0++}}}if(h+=c._score/e,f[S0]=c._score/e,c._indexes[0]<m)h-=(m-c._indexes[0])*2;m=c._indexes[0];for(var _0=0;_0<c._indexes.len;++_0)v.add(c._indexes[_0])}if($0&&!P0)return r;A0();var e0=A(u,l,!0);if(e0!==r&&e0._score>h){if($0)for(var S0=0;S0<e;++S0)f[S0]=e0._score/e;return e0}if($0)c=l;c._score=h;var S0=0;for(let C1 of v)c._indexes[S0++]=C1;return c._indexes.len=S0,c},N=(u)=>u.replace(/\p{Script=Latin}+/gu,(l)=>l.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),L=(u)=>{u=N(u);var l=u.length,$0=u.toLowerCase(),v=[],h=0,c=!1;for(var m=0;m<l;++m){var a=v[m]=$0.charCodeAt(m);if(a===32){c=!0;continue}var e=a>=97&&a<=122?a-97:a>=48&&a<=57?26:a<=127?30:31;h|=1<<e}return{lowerCodes:v,bitflags:h,containsSpace:c,_lower:$0}},q=(u)=>{var l=u.length,$0=[],v=0,h=!1,c=!1;for(var m=0;m<l;++m){var a=u.charCodeAt(m),e=a>=65&&a<=90,H0=e||a>=97&&a<=122||a>=48&&a<=57,A0=e&&!h||!c||!H0;if(h=e,c=H0,A0)$0[v++]=m}return $0},M=(u)=>{u=N(u);var l=u.length,$0=q(u),v=[],h=$0[0],c=0;for(var m=0;m<l;++m)if(h>m)v[m]=h;else h=$0[++c],v[m]=h===void 0?l:h;return v},C=new Map,R=new Map,w=[],I=[],_=[],E=[],f=[],b=[],y=[],k=(u,l)=>{var $0=u[l];if($0!==void 0)return $0;if(typeof l==="function")return l(u);var v=l;if(!Array.isArray(l))v=l.split(".");var h=v.length,c=-1;while(u&&++c<h)u=u[v[c]];return u},g=(u)=>{return typeof u==="object"&&typeof u._bitflags==="number"},d=1/0,p=-d,t=[];t.total=0;var r=null,G0=X(""),O0=(u)=>{var l=[],$0=0,v={},h=(c)=>{for(var m=0,a=l[m],e=1;e<$0;){var H0=e+1;m=e,H0<$0&&l[H0]._score<l[e]._score&&(m=H0),l[m-1>>1]=l[m],e=1+(m<<1)}for(var A0=m-1>>1;m>0&&a._score<l[A0]._score;A0=(m=A0)-1>>1)l[m]=l[A0];l[m]=a};return v.add=(c)=>{var m=$0;l[$0++]=c;for(var a=m-1>>1;m>0&&c._score<l[a]._score;a=(m=a)-1>>1)l[m]=l[a];l[m]=c},v.poll=(c)=>{if($0!==0){var m=l[0];return l[0]=l[--$0],h(),m}},v.peek=(c)=>{if($0!==0)return l[0]},v.replaceTop=(c)=>{l[0]=c,h()},v},h0=O0();return{single:Z,go:J,prepare:X,cleanup:Q}})});var Y9={};F1(Y9,{toRow:()=>bM0,plan:()=>lM0,listGlobal:()=>cM0,list:()=>pM0,layer:()=>Ld,isDefaultTitle:()=>EM0,getUsage:()=>dM0,fromRow:()=>OY,defaultLayer:()=>rM0,SetTitleInput:()=>xM0,SetRevertInput:()=>uM0,SetPermissionInput:()=>gM0,SetArchivedInput:()=>hM0,Service:()=>nK,RemoveInput:()=>yM0,ProjectInfo:()=>Md,MessagesInput:()=>mM0,Info:()=>z6,GlobalInfo:()=>_M0,GetInput:()=>kM0,ForkInput:()=>fM0,Event:()=>qY,CreateInput:()=>SM0,ChildrenInput:()=>vM0,BusyError:()=>wd});var JV;((tM0)=>{let $=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],Z=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function J(){return[$[Math.floor(Math.random()*$.length)],Z[Math.floor(Math.random()*Z.length)]].join("-")}tM0.create=J})(JV||={});var l1={};F1(l1,{subscribeAll:()=>vd,subscribe:()=>kd,publish:()=>fd,layer:()=>YV,defaultLayer:()=>_d,Service:()=>IY,InstanceDisposed:()=>UO,Bus:()=>l1});var NZ=E0.create({service:"bus"}),UO=L1.define("server.instance.disposed",P.object({directory:P.string()}));class IY extends S1.Service()("@qitqode/Bus"){}var YV=T0.effect(IY,T.gen(function*(){let $=yield*B0.make(T.fn("Bus.state")(function*(K){let V=yield*h6.unbounded(),U=new Map;return yield*T.addFinalizer(()=>T.gen(function*(){yield*h6.publish(V,{type:UO.type,properties:{directory:K.directory}}),yield*h6.shutdown(V);for(let H of U.values())yield*h6.shutdown(H)})),{wildcard:V,typed:U}}));function Z(K,V){return T.gen(function*(){let U=K.typed.get(V.type);if(!U)U=yield*h6.unbounded(),K.typed.set(V.type,U);return U})}function J(K,V){return T.gen(function*(){let U=yield*B0.get($),H={type:K.type,properties:V};NZ.debug("publishing",{type:K.type});let B=U.typed.get(K.type);if(B)yield*h6.publish(B,H);yield*h6.publish(U.wildcard,H);let z=yield*B0.directory,F=yield*B0.context,A=yield*B0.workspaceID;L7.emit("event",{directory:z,project:F.project.id,workspace:A,payload:H})})}function Y(K){return NZ.info("subscribing",{type:K.type}),I$.unwrap(T.gen(function*(){let V=yield*B0.get($),U=yield*Z(V,K);return I$.fromPubSub(U)})).pipe(I$.ensuring(T.sync(()=>NZ.info("unsubscribing",{type:K.type}))))}function X(){return NZ.info("subscribing",{type:"*"}),I$.unwrap(T.gen(function*(){let K=yield*B0.get($);return I$.fromPubSub(K.wildcard)})).pipe(I$.ensuring(T.sync(()=>NZ.info("unsubscribing",{type:"*"}))))}function Q(K,V,U){return T.gen(function*(){NZ.info("subscribing",{type:V});let H=yield*T7.make(),B=yield*PY.make(),z=yield*PY.provide(B)(h6.subscribe(K));return yield*PY.provide(B)(I$.fromSubscription(z).pipe(I$.runForEach((F)=>T.tryPromise({try:()=>Promise.resolve().then(()=>U(F)),catch:(A)=>{NZ.error("subscriber failed",{type:V,cause:A})}}).pipe(T.ignore)),T.forkScoped)),()=>{NZ.info("unsubscribing",{type:V}),H.fork(PY.close(B,B9.void))}})}let G=T.fn("Bus.subscribeCallback")(function*(K,V){let U=yield*B0.get($),H=yield*Z(U,K);return yield*Q(H,K.type,V)}),W=T.fn("Bus.subscribeAllCallback")(function*(K){let V=yield*B0.get($);return yield*Q(V.wildcard,"*",K)});return IY.of({publish:J,subscribe:Y,subscribeAll:X,subscribeCallback:G,subscribeAllCallback:W})})),_d=YV,{runPromise:Sd,runSync:HO}=VO(IY,YV);async function fd($,Z){return Sd((J)=>J.publish($,Z))}function kd($,Z){return HO((J)=>J.subscribeCallback($,Z))}function vd($){return HO((Z)=>Z.subscribeAllCallback($))}var X$={};F1(X$,{versionedType:()=>CY,run:()=>rd,reset:()=>cd,replayAll:()=>sd,replay:()=>qO,remove:()=>ad,registry:()=>EY,project:()=>od,payloads:()=>td,init:()=>id,define:()=>nd,SyncEvent:()=>X$});var _8=g6("event_sequence",{aggregate_id:w1().notNull().primaryKey(),seq:j8().notNull()}),z9=g6("event",{id:w1().primaryKey(),aggregate_id:w1().notNull().references(()=>_8.aggregate_id,{onDelete:"cascade"}),seq:j8().notNull(),type:w1().notNull(),data:w1({mode:"json"}).$type().notNull()});var d1={};F1(d1,{timestamp:()=>pd,schema:()=>gd,descending:()=>dd,create:()=>zO,ascending:()=>ld,Identifier:()=>d1});import{randomBytes as yd}from"crypto";var xd="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function XV($){let Z="",J=yd($);for(let Y=0;Y<$;Y++)Z+=xd[J[Y]%62];return Z}function QV(){let $=0,Z=0;return(J)=>{if(J!==void 0)return BigInt(J)*BigInt(4096);let Y=Date.now();if(Y>$)$=Y,Z=0;if(Z++,Z>4095)$++,Z=1;return BigInt($)*BigInt(4096)+BigInt(Z)}}function GV($){let Z=Buffer.alloc(6);for(let J=0;J<6;J++)Z[J]=Number($>>BigInt(40-8*J)&BigInt(255));return Z.toString("hex")}var hd;((HD0)=>{let Z=QV();function J(){return X(!1)}HD0.ascending=J;function Y(){return X(!0)}HD0.descending=Y;function X(Q,G){let W=Z(G);return W=Q?~W:W,GV(W)+XV(14)}HD0.create=X})(hd||={});var F9={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk",entry:"ent",workflow:"wf"};function gd($){return P.string().startsWith(F9[$])}var ud=26,md=QV();function ld($,Z){return BO($,"ascending",Z)}function dd($,Z){return BO($,"descending",Z)}function BO($,Z,J){if(!J)return zO(F9[$],Z);if(!J.startsWith(F9[$]))throw Error(`ID ${J} does not start with ${F9[$]}`);return J}function zO($,Z,J){let Y=md(J);return Y=Z==="descending"?~Y:Y,$+"_"+GV(Y)+XV(ud-12)}function pd($){let Z=$.split("_")[0],J=$.slice(Z.length+1,Z.length+13),Y=BigInt("0x"+J);return Number(Y/BigInt(4096))}var FO=O.String.annotate({[F$]:d1.schema("event")}).pipe(O.brand("EventID"),u0(($)=>({ascending:(Z)=>$.make(d1.ascending("event",Z)),zod:d1.schema("event").pipe(P.custom())})));var EY=new Map,A9,O9=new Map,WV=!1,KV;function cd(){WV=!1,A9=void 0,KV=($,Z)=>Z}function id($){A9=new Map($.projectors);for(let[Z,J]of O9.entries()){let Y=EY.get(CY(Z,J));L1.define(Y.type,Y.properties||Y.schema)}WV=!0,KV=$.convertEvent||((Z,J)=>J)}function CY($,Z){return Z?`${$}.${Z}`:$}function nd($){if(WV)throw Error("Error defining sync event: sync system has been frozen");let Z={type:$.type,version:$.version,aggregate:$.aggregate,schema:$.schema,properties:$.busSchema?$.busSchema:$.schema};return O9.set(Z.type,Math.max(Z.version,O9.get(Z.type)||0)),EY.set(CY(Z.type,Z.version),Z),Z}function od($,Z){return[$,Z]}function OO($,Z,J){if(A9==null)throw Error("No projectors available. Call `SyncEvent.init` to install projectors");let Y=A9.get($);if(!Y)throw Error(`Projector not found for event: ${$.type}`);W1.transaction((X)=>{if(Y(X,Z.data),b0.QITQODE_EXPERIMENTAL_WORKSPACES)X.insert(_8).values({aggregate_id:Z.aggregateID,seq:Z.seq}).onConflictDoUpdate({target:_8.aggregate_id,set:{seq:Z.seq}}).run(),X.insert(z9).values({id:Z.id,seq:Z.seq,aggregate_id:Z.aggregateID,type:CY($.type,$.version),data:Z.data}).run();W1.effect(()=>{if(J?.publish){let Q=KV($.type,Z.data);if(Q instanceof Promise)Q.then((G)=>{l1.publish({type:$.type,properties:$.schema},G)});else l1.publish({type:$.type,properties:$.schema},Q);L7.emit("event",{directory:S8.directory,project:S8.project.id,workspace:AO.workspaceID,payload:{type:"sync",syncEvent:{type:CY($.type,$.version),...Z}}})}})})}function qO($,Z){let J=EY.get($.type);if(!J)throw Error(`Unknown event type: ${$.type}`);let X=W1.use((G)=>G.select({seq:_8.seq}).from(_8).where(m0(_8.aggregate_id,$.aggregateID)).get())?.seq??-1;if($.seq<=X)return;let Q=X+1;if($.seq!==Q)throw Error(`Sequence mismatch for aggregate "${$.aggregateID}": expected ${Q}, got ${$.seq}`);OO(J,$,{publish:!!Z?.publish})}function sd($,Z){let J=$[0]?.aggregateID;if(!J)return;if($.some((X)=>X.aggregateID!==J))throw Error("Replay events must belong to the same session");let Y=$[0].seq;for(let[X,Q]of $.entries()){let G=Y+X;if(Q.seq!==G)throw Error(`Replay sequence mismatch at index ${X}: expected ${G}, got ${Q.seq}`)}for(let X of $)qO(X,Z);return J}function rd($,Z,J){let Y=Z[$.aggregate];if(Y==null)throw Error(`SyncEvent.run: "${$.aggregate}" required but not found: ${JSON.stringify(Z)}`);if($.version!==O9.get($.type))throw Error(`SyncEvent.run: running old versions of events is not allowed: ${$.type}`);let{publish:X=!0}=J||{};W1.transaction((Q)=>{let G=FO.ascending(),W=Q.select({seq:_8.seq}).from(_8).where(m0(_8.aggregate_id,Y)).get(),K=W?.seq!=null?W.seq+1:0;OO($,{id:G,seq:K,aggregateID:Y,data:Z},{publish:X})},{behavior:"immediate"})}function ad($){W1.transaction((Z)=>{Z.delete(_8).where(m0(_8.aggregate_id,$)).run(),Z.delete(z9).where(m0(z9.aggregate_id,$)).run()})}function td(){return EY.entries().map(([$,Z])=>{return P.object({type:P.literal("sync"),name:P.literal($),id:P.string(),seq:P.number(),aggregateID:P.literal(Z.aggregate),data:Z.schema}).meta({ref:`SyncEvent.${Z.type}`})}).toArray()}var b$={};F1(b$,{toModelMessagesEffect:()=>K2,toModelMessages:()=>re,stream:()=>pU,parts:()=>PL,page:()=>RL,isMedia:()=>NX,get:()=>Ca,fromError:()=>xA,fingerprint:()=>OH,filterCompactedEffect:()=>Ea,filterCompacted:()=>cU,cursor:()=>dU,WithParts:()=>Ta,User:()=>ML,ToolStateRunning:()=>zL,ToolStatePending:()=>BL,ToolStateError:()=>AL,ToolStateCompleted:()=>FL,ToolState:()=>OL,ToolPart:()=>qL,TextPart:()=>tw,SymbolSource:()=>ZL,SubtaskPart:()=>GL,StructuredOutputError:()=>dw,StepStartPart:()=>VL,StepFinishPart:()=>HL,SnapshotPart:()=>rw,SYNTHETIC_ATTACHMENT_PROMPT:()=>W2,RetryPart:()=>KL,ResourceSource:()=>JL,ReasoningPart:()=>ew,Provenance:()=>NL,PatchPart:()=>aw,Part:()=>mU,OutputLengthError:()=>U4,OutputFormatText:()=>nw,OutputFormatJsonSchema:()=>ow,ModelError:()=>iw,MessageV2:()=>b$,InvalidOutputError:()=>pw,Info:()=>lU,Format:()=>sw,FileSource:()=>$L,FilePartSource:()=>YL,FilePart:()=>uU,Event:()=>La,ErrorDiagnostic:()=>lw,ContextOverflowError:()=>GX,ContentFilterError:()=>cw,CompactionPart:()=>WL,CheckpointPart:()=>QL,AuthError:()=>H4,Assistant:()=>DL,AgentPart:()=>XL,AbortedError:()=>f5,APIError:()=>L6});var r0=O.String.annotate({[F$]:d1.schema("session")}).pipe(O.brand("SessionID"),u0(($)=>({descending:(Z)=>$.make(d1.descending("session",Z)),zod:d1.schema("session").pipe(P.custom())}))),i1=O.String.annotate({[F$]:d1.schema("message")}).pipe(O.brand("MessageID"),u0(($)=>({ascending:(Z)=>$.make(d1.ascending("message",Z)),zod:d1.schema("message").pipe(P.custom())}))),MZ=O.String.annotate({[F$]:d1.schema("part")}).pipe(O.brand("PartID"),u0(($)=>({ascending:(Z)=>$.make(d1.ascending("part",Z)),zod:d1.schema("part").pipe(P.custom())})));var X4={};F1(X4,{layer:()=>Iw,defaultLayer:()=>Ha,Symbol:()=>Ga,Status:()=>Ka,Service:()=>Y4,Range:()=>J4,Event:()=>Pw,DocumentSymbol:()=>Wa,Diagnostic:()=>XX});var S7=m6(Kj(),1);import yY from"path";import{pathToFileURL as F5,fileURLToPath as uc}from"url";var Vj={".abap":"abap",".bat":"bat",".bib":"bibtex",".bibtex":"bibtex",".clj":"clojure",".cljs":"clojure",".cljc":"clojure",".edn":"clojure",".coffee":"coffeescript",".c":"c",".cpp":"cpp",".cxx":"cpp",".cc":"cpp",".c++":"cpp",".cs":"csharp",".css":"css",".d":"d",".pas":"pascal",".pascal":"pascal",".diff":"diff",".patch":"diff",".dart":"dart",".dockerfile":"dockerfile",".ex":"elixir",".exs":"elixir",".erl":"erlang",".ets":"typescript",".hrl":"erlang",".fs":"fsharp",".fsi":"fsharp",".fsx":"fsharp",".fsscript":"fsharp",".gitcommit":"git-commit",".gitrebase":"git-rebase",".go":"go",".groovy":"groovy",".gleam":"gleam",".hbs":"handlebars",".handlebars":"handlebars",".hs":"haskell",".lhs":"haskell",".html":"html",".htm":"html",".ini":"ini",".java":"java",".jl":"julia",".js":"javascript",".kt":"kotlin",".kts":"kotlin",".jsx":"javascriptreact",".json":"json",".tex":"latex",".latex":"latex",".less":"less",".lua":"lua",".makefile":"makefile",makefile:"makefile",".md":"markdown",".markdown":"markdown",".m":"objective-c",".mm":"objective-cpp",".pl":"perl",".pm":"perl",".pm6":"perl6",".php":"php",".ps1":"powershell",".psm1":"powershell",".pug":"jade",".jade":"jade",".py":"python",".r":"r",".cshtml":"razor",".razor":"razor",".rb":"ruby",".rake":"ruby",".gemspec":"ruby",".ru":"ruby",".erb":"erb",".html.erb":"erb",".js.erb":"erb",".css.erb":"erb",".json.erb":"erb",".rs":"rust",".scss":"scss",".sass":"sass",".scala":"scala",".shader":"shaderlab",".sh":"shellscript",".bash":"shellscript",".zsh":"shellscript",".ksh":"shellscript",".sql":"sql",".svelte":"svelte",".swift":"swift",".ts":"typescript",".tsx":"typescriptreact",".mts":"typescript",".cts":"typescript",".mtsx":"typescriptreact",".ctsx":"typescriptreact",".xml":"xml",".xsl":"xsl",".yaml":"yaml",".yml":"yaml",".mjs":"javascript",".cjs":"javascript",".vue":"vue",".zig":"zig",".zon":"zig",".astro":"astro",".ml":"ocaml",".mli":"ocaml",".tf":"terraform",".tfvars":"terraform-vars",".hcl":"hcl",".nix":"nix",".typ":"typst",".typc":"typst"};function xV($,Z){let J;return Promise.race([$,new Promise((X,Q)=>{J=setTimeout(()=>{Q(Error(`Operation timed out after ${Z}ms`))},Z)})]).finally(()=>clearTimeout(J))}var mc=150,A5=E0.create({service:"lsp.client"}),lc=j1.create("LSPInitializeError",P.object({serverID:P.string()})),Uj={Diagnostics:L1.define("lsp.client.diagnostics",P.object({serverID:P.string(),path:P.string()}))};async function Hj($){let Z=A5.clone().tag("serverID",$.serverID);Z.info("starting client");let J=S7.createMessageConnection(new S7.StreamMessageReader($.server.process.stdout),new S7.StreamMessageWriter($.server.process.stdin)),Y=new Map;if(J.onNotification("textDocument/publishDiagnostics",(G)=>{let W=o0.normalizePath(uc(G.uri));Z.info("textDocument/publishDiagnostics",{path:W,count:G.diagnostics.length});let K=Y.has(W);if(Y.set(W,G.diagnostics),!K&&$.serverID==="typescript")return;l1.publish(Uj.Diagnostics,{path:W,serverID:$.serverID})}),J.onRequest("window/workDoneProgress/create",(G)=>{return Z.info("window/workDoneProgress/create",G),null}),J.onRequest("workspace/configuration",async()=>{return[$.server.initialization??{}]}),J.onRequest("client/registerCapability",async()=>{}),J.onRequest("client/unregisterCapability",async()=>{}),J.onRequest("workspace/workspaceFolders",async()=>[{name:"workspace",uri:F5($.root).href}]),J.listen(),Z.info("sending initialize"),await xV(J.sendRequest("initialize",{rootUri:F5($.root).href,processId:$.server.process.pid,workspaceFolders:[{name:"workspace",uri:F5($.root).href}],initializationOptions:{...$.server.initialization},capabilities:{window:{workDoneProgress:!0},workspace:{configuration:!0,didChangeWatchedFiles:{dynamicRegistration:!0}},textDocument:{synchronization:{didOpen:!0,didChange:!0},publishDiagnostics:{versionSupport:!0}}}}),45000).catch((G)=>{throw Z.error("initialize error",{error:G}),new lc({serverID:$.serverID},{cause:G})}),await J.sendNotification("initialized",{}),$.server.initialization)await J.sendNotification("workspace/didChangeConfiguration",{settings:$.server.initialization});let X={},Q={root:$.root,get serverID(){return $.serverID},get connection(){return J},notify:{async open(G){G.path=yY.isAbsolute(G.path)?G.path:yY.resolve($.directory,G.path);let W=await o0.readText(G.path),K=yY.extname(G.path),V=Vj[K]??"plaintext",U=X[G.path];if(U!==void 0){A5.info("workspace/didChangeWatchedFiles",G),await J.sendNotification("workspace/didChangeWatchedFiles",{changes:[{uri:F5(G.path).href,type:2}]});let H=U+1;X[G.path]=H,A5.info("textDocument/didChange",{path:G.path,version:H}),await J.sendNotification("textDocument/didChange",{textDocument:{uri:F5(G.path).href,version:H},contentChanges:[{text:W}]});return}A5.info("workspace/didChangeWatchedFiles",G),await J.sendNotification("workspace/didChangeWatchedFiles",{changes:[{uri:F5(G.path).href,type:1}]}),A5.info("textDocument/didOpen",G),Y.delete(G.path),await J.sendNotification("textDocument/didOpen",{textDocument:{uri:F5(G.path).href,languageId:V,version:0,text:W}}),X[G.path]=0;return}},get diagnostics(){return Y},async waitForDiagnostics(G){let W=o0.normalizePath(yY.isAbsolute(G.path)?G.path:yY.resolve($.directory,G.path));A5.info("waiting for diagnostics",{path:W});let K,V;return await xV(new Promise((U)=>{K=l1.subscribe(Uj.Diagnostics,(H)=>{if(H.properties.path===W&&H.properties.serverID===Q.serverID){if(V)clearTimeout(V);V=setTimeout(()=>{A5.info("got diagnostics",{path:W}),K?.(),U()},mc)}})}),3000).catch(()=>{}).finally(()=>{if(V)clearTimeout(V);K?.()})},async shutdown(){Z.info("shutting down"),J.end(),J.dispose(),await f1.stop($.server.process),Z.info("shutdown")}};return Z.info("initialized"),Q}import Tw from"path";import{pathToFileURL as Rw,fileURLToPath as Qa}from"url";var f7={};F1(f7,{Zls:()=>xj,YamlLS:()=>wj,Vue:()=>Oj,Typescript:()=>Aj,Ty:()=>gj,Tinymist:()=>ij,TexLab:()=>oj,TerraformLS:()=>nj,Svelte:()=>Mj,SourceKit:()=>Ej,RustAnalyzer:()=>bj,Rubocop:()=>hj,Pyright:()=>uj,Prisma:()=>Tj,PHPIntelephense:()=>lj,Oxlint:()=>jj,Ocaml:()=>vj,Nixd:()=>cj,LuaLS:()=>Lj,KotlinLS:()=>fj,JuliaLS:()=>dj,JDTLS:()=>Sj,HLS:()=>pj,Gopls:()=>Pj,Gleam:()=>yj,FSharp:()=>Cj,ElixirLS:()=>mj,ESLint:()=>qj,DockerfileLS:()=>sj,Deno:()=>Fj,Dart:()=>kj,Clojure:()=>rj,Clangd:()=>_j,CSharp:()=>Ij,Biome:()=>Nj,BashLS:()=>Rj,Astro:()=>Dj});function Z1($,Z,J){let Y=Array.isArray(Z)?[...Z]:[],X=Array.isArray(Z)?J:Z,Q=f1.spawn([$,...Y],{...X,stdin:"pipe",stdout:"pipe",stderr:"pipe"});if(!Q.stdin||!Q.stdout||!Q.stderr)throw Error("Process output not available");return Q}import dc from"fs/promises";import hV from"path";var Q0=E0.create({service:"lsp.server"}),gV=async($)=>dc.stat($).then(()=>!0).catch(()=>!1),j6=($,Z={})=>f1.run($,{...Z,nothrow:!0}),zj=($,Z={})=>f1.text($,{...Z,nothrow:!0});async function N6($,Z){if($)return $;if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;return q6.which(Z)}var M6=($,Z,J)=>Z1($,Z,{cwd:J,env:{...n8()}}),t0=($,Z)=>{return async(J,Y)=>{if(Z){let G=o0.up({targets:Z,start:hV.dirname(J),stop:Y.directory}),W=await G.next();if(await G.return(),W.value)return}let X=o0.up({targets:$,start:hV.dirname(J),stop:Y.directory}),Q=await X.next();if(await X.return(),!Q.value)return Y.directory;return hV.dirname(Q.value)}};import{createRequire as pc}from"module";import cc from"path";var wZ;((CL0)=>{function $(Z,J){try{return pc(cc.join(J,"package.json")).resolve(Z)}catch{}}CL0.resolve=$})(wZ||={});import ic from"path";async function LZ($,Z,J){let Y=await fetch($);if(!Y.ok){Q0.error(`Failed to download ${J}`);return}let X=ic.join(F0.Path.bin,Z);if(Y.body)await o0.writeStream(X,Y.body);return X}async function TZ($,Z){return D8.extractZip($,F0.Path.bin).then(()=>!0).catch((J)=>{return Q0.error(`Failed to extract ${Z} archive`,{error:J}),!1})}import D6 from"fs/promises";import{text as nc}from"stream/consumers";import w8 from"path";var Fj={id:"deno",root:async($,Z)=>{let J=o0.up({targets:["deno.json","deno.jsonc"],start:w8.dirname($),stop:Z.directory}),Y=await J.next();if(await J.return(),!Y.value)return;return w8.dirname(Y.value)},extensions:[".ts",".tsx",".js",".jsx",".mjs"],async spawn($){let Z=d0("deno");if(!Z){Q0.info("deno not found, please install deno first");return}return{process:Z1(Z,["lsp"],{cwd:$})}}},Aj={id:"typescript",root:t0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"],["deno.json","deno.jsonc"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts"],async spawn($,Z){let J=wZ.resolve("typescript/lib/tsserver.js",Z.directory);if(Q0.info("typescript server",{tsserver:J}),!J)return;let Y=await q6.which("typescript-language-server");if(!Y)return;return{process:Z1(Y,["--stdio"],{cwd:$,env:{...n8()}}),initialization:{tsserver:{path:J}}}}},Oj={id:"vue",extensions:[".vue"],root:t0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($){let Z=await N6(d0("vue-language-server"),"@vue/language-server");if(!Z)return;return{process:M6(Z,["--stdio"],$),initialization:{}}}},qj={id:"eslint",root:t0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".vue"],async spawn($,Z){if(!wZ.resolve("eslint",Z.directory))return;Q0.info("spawning eslint server");let Y=w8.join(F0.Path.bin,"vscode-eslint","server","out","eslintServer.js");if(!await o0.exists(Y)){if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading and building VS Code ESLint server");let Q=await LZ("https://github.com/microsoft/vscode-eslint/archive/refs/heads/main.zip","vscode-eslint.zip","vscode-eslint");if(!Q)return;if(!await TZ(Q,"vscode-eslint"))return;await D6.rm(Q,{force:!0});let W=w8.join(F0.Path.bin,"vscode-eslint-main"),K=w8.join(F0.Path.bin,"vscode-eslint");if(await D6.stat(K).catch(()=>{return}))Q0.info("removing old eslint installation",{path:K}),await D6.rm(K,{force:!0,recursive:!0});await D6.rename(W,K);let U=process.platform==="win32"?"npm.cmd":"npm";await f1.run([U,"install"],{cwd:K}),await f1.run([U,"run","compile"],{cwd:K}),Q0.info("installed VS Code ESLint server",{serverPath:Y})}return{process:Z1("node",[Y,"--stdio"],{cwd:$,env:{...n8()}})}}},jj={id:"oxlint",root:t0([".oxlintrc.json","package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock","package.json"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".vue",".astro",".svelte"],async spawn($,Z){let J=process.platform==="win32"?".cmd":"",Y=w8.join("node_modules",".bin","oxc_language_server"+J),X=w8.join("node_modules",".bin","oxlint"+J),Q=async(K)=>{let V=w8.join($,K);if(await o0.exists(V))return V;let U=o0.up({targets:[K],start:$,stop:Z.worktree}),H=await U.next();if(await U.return(),H.value)return H.value;return},G=await Q(X);if(!G){let K=d0("oxlint");if(K)G=K}if(G){let K=Z1(G,["--help"]);if(await K.exited,K.stdout){if((await nc(K.stdout)).includes("--lsp"))return{process:Z1(G,["--lsp"],{cwd:$})}}}let W=await Q(Y);if(!W){let K=d0("oxc_language_server");if(K)W=K}if(W)return{process:Z1(W,[],{cwd:$})};Q0.info("oxlint not found, please install oxlint");return}},Nj={id:"biome",root:t0(["biome.json","biome.jsonc","package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),extensions:[".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".json",".jsonc",".vue",".astro",".svelte",".css",".graphql",".gql",".html"],async spawn($){let Z=w8.join($,"node_modules",".bin","biome"),J;if(await o0.exists(Z))J=Z;if(!J){let Q=d0("biome");if(Q)J=Q}let Y=["lsp-proxy","--stdio"];if(!J){if(!wZ.resolve("biome",$))return;if(J=await q6.which("biome"),!J)return;Y=["lsp-proxy","--stdio"]}return{process:Z1(J,Y,{cwd:$,env:{...n8()}})}}},Mj={id:"svelte",extensions:[".svelte"],root:t0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($){let Z=await N6(d0("svelteserver"),"svelte-language-server");if(!Z)return;return{process:M6(Z,["--stdio"],$),initialization:{}}}},Dj={id:"astro",extensions:[".astro"],root:t0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($,Z){let J=wZ.resolve("typescript/lib/tsserver.js",Z.directory);if(!J){Q0.info("typescript not found, required for Astro language server");return}let Y=w8.dirname(J),X=await N6(d0("astro-ls"),"@astrojs/language-server");if(!X)return;return{process:M6(X,["--stdio"],$),initialization:{typescript:{tsdk:Y}}}}},wj={id:"yaml-ls",extensions:[".yaml",".yml"],root:t0(["package-lock.json","bun.lockb","bun.lock","pnpm-lock.yaml","yarn.lock"]),async spawn($){let Z=await N6(d0("yaml-language-server"),"yaml-language-server");if(!Z)return;return{process:M6(Z,["--stdio"],$)}}},Lj={id:"lua-ls",root:t0([".luarc.json",".luarc.jsonc",".luacheckrc",".stylua.toml","stylua.toml","selene.toml","selene.yml"]),extensions:[".lua"],async spawn($){let Z=d0("lua-language-server");if(!Z){if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading lua-language-server from GitHub releases");let J=await fetch("https://api.github.com/repos/LuaLS/lua-language-server/releases/latest");if(!J.ok){Q0.error("Failed to fetch lua-language-server release info");return}let Y=await J.json(),X=process.platform,Q=process.arch,G="",W=Q;if(Q==="arm64")W="arm64";else if(Q==="x64")W="x64";else if(Q==="ia32")W="ia32";let K=X;if(X==="darwin")K="darwin";else if(X==="linux")K="linux";else if(X==="win32")K="win32";let V=X==="win32"?"zip":"tar.gz";G=`lua-language-server-${Y.tag_name}-${K}-${W}.${V}`;let U=["darwin-arm64.tar.gz","darwin-x64.tar.gz","linux-x64.tar.gz","linux-arm64.tar.gz","win32-x64.zip","win32-ia32.zip"],H=`${K}-${W}.${V}`;if(!U.includes(H)){Q0.error(`Platform ${X} and architecture ${Q} is not supported by lua-language-server`);return}let B=Y.assets.find((L)=>L.name===G);if(!B){Q0.error(`Could not find asset ${G} in latest lua-language-server release`);return}let z=B.browser_download_url,F=await fetch(z);if(!F.ok){Q0.error("Failed to download lua-language-server");return}let A=w8.join(F0.Path.bin,G);if(F.body)await o0.writeStream(A,F.body);let j=w8.join(F0.Path.bin,`lua-language-server-${W}-${K}`);if(await D6.stat(j).catch(()=>{return}))await D6.rm(j,{force:!0,recursive:!0});if(await D6.mkdir(j,{recursive:!0}),V==="zip"){if(!await D8.extractZip(A,j).then(()=>!0).catch((q)=>{return Q0.error("Failed to extract lua-language-server archive",{error:q}),!1}))return}else if(!await j6(["tar","-xzf",A,"-C",j]).then((q)=>q.code===0).catch((q)=>{return Q0.error("Failed to extract lua-language-server archive",{error:q}),!1}))return;if(await D6.rm(A,{force:!0}),Z=w8.join(j,"bin","lua-language-server"+(X==="win32"?".exe":"")),!await o0.exists(Z)){Q0.error("Failed to extract lua-language-server binary");return}if(X!=="win32"){if(!await D6.chmod(Z,493).then(()=>!0).catch((q)=>{return Q0.error("Failed to set executable permission for lua-language-server binary",{error:q}),!1}))return}Q0.info("installed lua-language-server",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},Tj={id:"prisma",extensions:[".prisma"],root:t0(["schema.prisma","prisma/schema.prisma","prisma"],["package.json"]),async spawn($){let Z=d0("prisma");if(!Z){Q0.info("prisma not found, please install prisma");return}return{process:Z1(Z,["language-server"],{cwd:$})}}},Rj={id:"bash",extensions:[".sh",".bash",".zsh",".ksh"],root:async($,Z)=>Z.directory,async spawn($){let Z=await N6(d0("bash-language-server"),"bash-language-server");if(!Z)return;return{process:M6(Z,["start"],$)}}};import $8 from"fs/promises";import o1 from"path";import oc from"os";var Pj={id:"gopls",root:async($,Z)=>{let J=await t0(["go.work"])($,Z);if(J)return J;return t0(["go.mod","go.sum"])($,Z)},extensions:[".go"],async spawn($){let Z=d0("gopls");if(!Z){if(!d0("go"))return;if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(Q0.info("installing gopls"),await f1.spawn(["go","install","golang.org/x/tools/gopls@latest"],{env:{GOBIN:F0.Path.bin},stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){Q0.error("Failed to install gopls");return}Z=o1.join(F0.Path.bin,"gopls"+(process.platform==="win32"?".exe":"")),Q0.info("installed gopls",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},Ij={id:"csharp",root:t0([".slnx",".sln",".csproj","global.json"]),extensions:[".cs"],async spawn($){let Z=d0("csharp-ls");if(!Z){if(!d0("dotnet")){Q0.error(".NET SDK is required to install csharp-ls");return}if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(Q0.info("installing csharp-ls via dotnet tool"),await f1.spawn(["dotnet","tool","install","csharp-ls","--tool-path",F0.Path.bin],{stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){Q0.error("Failed to install csharp-ls");return}Z=o1.join(F0.Path.bin,"csharp-ls"+(process.platform==="win32"?".exe":"")),Q0.info("installed csharp-ls",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},Cj={id:"fsharp",root:t0([".slnx",".sln",".fsproj","global.json"]),extensions:[".fs",".fsi",".fsx",".fsscript"],async spawn($){let Z=d0("fsautocomplete");if(!Z){if(!d0("dotnet")){Q0.error(".NET SDK is required to install fsautocomplete");return}if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(Q0.info("installing fsautocomplete via dotnet tool"),await f1.spawn(["dotnet","tool","install","fsautocomplete","--tool-path",F0.Path.bin],{stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){Q0.error("Failed to install fsautocomplete");return}Z=o1.join(F0.Path.bin,"fsautocomplete"+(process.platform==="win32"?".exe":"")),Q0.info("installed fsautocomplete",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},Ej={id:"sourcekit-lsp",extensions:[".swift",".objc","objcpp"],root:t0(["Package.swift","*.xcodeproj","*.xcworkspace"]),async spawn($){let Z=d0("sourcekit-lsp");if(Z)return{process:Z1(Z,{cwd:$})};if(!d0("xcrun"))return;let J=await zj(["xcrun","--find","sourcekit-lsp"]);if(J.code!==0)return;let Y=J.text.trim();return{process:Z1(Y,{cwd:$})}}},bj={id:"rust",root:async($,Z)=>{let J=await t0(["Cargo.toml","Cargo.lock"])($,Z);if(J===void 0)return;let Y=J;while(Y!==o1.dirname(Y)){let X=o1.join(Y,"Cargo.toml");try{if((await o0.readText(X)).includes("[workspace]"))return Y}catch{}let Q=o1.dirname(Y);if(Q===Y||!o0.contains(Z.worktree,Q))break;Y=Q}return J},extensions:[".rs"],async spawn($){let Z=d0("rust-analyzer");if(!Z){Q0.info("rust-analyzer not found in path, please install it");return}return{process:Z1(Z,{cwd:$})}}},_j={id:"clangd",root:t0(["compile_commands.json","compile_flags.txt",".clangd"]),extensions:[".c",".cpp",".cc",".cxx",".c++",".h",".hpp",".hh",".hxx",".h++"],async spawn($){let Z=["--background-index","--clang-tidy"],J=d0("clangd");if(J)return{process:Z1(J,Z,{cwd:$})};let Y=process.platform==="win32"?".exe":"",X=o1.join(F0.Path.bin,"clangd"+Y);if(await o0.exists(X))return{process:Z1(X,Z,{cwd:$})};let Q=await $8.readdir(F0.Path.bin,{withFileTypes:!0}).catch(()=>[]);for(let R of Q){if(!R.isDirectory())continue;if(!R.name.startsWith("clangd_"))continue;let w=o1.join(F0.Path.bin,R.name,"bin","clangd"+Y);if(await o0.exists(w))return{process:Z1(w,Z,{cwd:$})}}if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading clangd from GitHub releases");let G=await fetch("https://api.github.com/repos/clangd/clangd/releases/latest");if(!G.ok){Q0.error("Failed to fetch clangd release info");return}let W=await G.json(),K=W.tag_name;if(!K){Q0.error("clangd release did not include a tag name");return}let V=process.platform,H={darwin:"mac",linux:"linux",win32:"windows"}[V];if(!H){Q0.error(`Platform ${V} is not supported by clangd auto-download`);return}let B=W.assets??[],z=(R)=>{if(!R.name)return!1;if(!R.browser_download_url)return!1;if(!R.name.includes(H))return!1;return R.name.includes(K)},F=B.find((R)=>z(R)&&R.name?.endsWith(".zip"))??B.find((R)=>z(R)&&R.name?.endsWith(".tar.xz"))??B.find((R)=>z(R));if(!F?.name||!F.browser_download_url){Q0.error("clangd could not match release asset",{tag:K,platform:V});return}let A=F.name,j=await fetch(F.browser_download_url);if(!j.ok){Q0.error("Failed to download clangd");return}let N=o1.join(F0.Path.bin,A),L=await j.arrayBuffer();if(L.byteLength===0){Q0.error("Failed to write clangd archive");return}await o0.write(N,Buffer.from(L));let q=A.endsWith(".zip"),M=A.endsWith(".tar.xz");if(!q&&!M){Q0.error("clangd encountered unsupported asset",{asset:A});return}if(q){if(!await D8.extractZip(N,F0.Path.bin).then(()=>!0).catch((w)=>{return Q0.error("Failed to extract clangd archive",{error:w}),!1}))return}if(M)await j6(["tar","-xf",N],{cwd:F0.Path.bin});await $8.rm(N,{force:!0});let C=o1.join(F0.Path.bin,"clangd_"+K,"bin","clangd"+Y);if(!await o0.exists(C)){Q0.error("Failed to extract clangd binary");return}if(V!=="win32")await $8.chmod(C,493).catch(()=>{});return await $8.unlink(o1.join(F0.Path.bin,"clangd")).catch(()=>{}),await $8.symlink(C,o1.join(F0.Path.bin,"clangd")).catch(()=>{}),Q0.info("installed clangd",{bin:C}),{process:Z1(C,Z,{cwd:$})}}},Sj={id:"jdtls",root:async($,Z)=>{let J=["settings.gradle","settings.gradle.kts"],Y=["gradlew","gradlew.bat"],X=Y.concat(J),[Q,G,W]=await Promise.all([t0(["pom.xml","build.gradle","build.gradle.kts",".project",".classpath"],X)($,Z),t0(Y,J)($,Z),t0(J)($,Z)]);if(Q)return Q;if(G)return G;if(W)return W},extensions:[".java"],async spawn($){let Z=d0("java");if(!Z){Q0.error("Java 21 or newer is required to run the JDTLS. Please install it first.");return}let J=await j6(["java","-version"]).then((U)=>{let H=/"(\d+)\.\d+\.\d+"/.exec(U.stderr.toString());return!H?void 0:parseInt(H[1])});if(J==null||J<21){Q0.error("JDTLS requires at least Java 21.");return}let Y=o1.join(F0.Path.bin,"jdtls"),X=o1.join(Y,"plugins");if(!await gV(X)){if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("Downloading JDTLS LSP server."),await $8.mkdir(Y,{recursive:!0});let U="https://www.eclipse.org/downloads/download.php?file=/jdtls/snapshots/jdt-language-server-latest.tar.gz",H="release.tar.gz";Q0.info("Downloading JDTLS archive",{url:U,dest:Y});let B=await fetch(U);if(!B.ok||!B.body){Q0.error("Failed to download JDTLS",{status:B.status,statusText:B.statusText});return}await o0.writeStream(o1.join(Y,H),B.body),Q0.info("Extracting JDTLS archive");let z=await j6(["tar","-xzf",H],{cwd:Y});if(z.code!==0){Q0.error("Failed to extract JDTLS",{exitCode:z.code,stderr:z.stderr.toString()});return}await $8.rm(o1.join(Y,H),{force:!0}),Q0.info("JDTLS download and extraction completed")}let G=(await $8.readdir(X).catch(()=>[])).find((U)=>/^org\.eclipse\.equinox\.launcher_.*\.jar$/.test(U))?.trim()??"",W=o1.join(X,G);if(!await gV(W)){Q0.error(`Failed to locate the JDTLS launcher module in the installed directory: ${Y}.`);return}let K=o1.join(Y,(()=>{switch(process.platform){case"darwin":return"config_mac";case"linux":return"config_linux";case"win32":return"config_win";default:return"config_linux"}})()),V=await $8.mkdtemp(o1.join(oc.tmpdir(),"qitqode-jdtls-data"));return{process:Z1(Z,["-jar",W,"-configuration",K,"-data",V,"-Declipse.application=org.eclipse.jdt.ls.core.id1","-Dosgi.bundles.defaultStartLevel=4","-Declipse.product=org.eclipse.jdt.ls.core.product","-Dlog.level=ALL","--add-modules=ALL-SYSTEM","--add-opens java.base/java.util=ALL-UNNAMED","--add-opens java.base/java.lang=ALL-UNNAMED"],{cwd:$})}}},fj={id:"kotlin-ls",extensions:[".kt",".kts"],root:async($,Z)=>{let J=await t0(["settings.gradle.kts","settings.gradle"])($,Z);if(J)return J;let Y=await t0(["gradlew","gradlew.bat"])($,Z);if(Y)return Y;let X=await t0(["build.gradle.kts","build.gradle"])($,Z);if(X)return X;return t0(["pom.xml"])($,Z)},async spawn($){let Z=o1.join(F0.Path.bin,"kotlin-ls"),J=process.platform==="win32"?o1.join(Z,"kotlin-lsp.cmd"):o1.join(Z,"kotlin-lsp.sh");if(!await o0.exists(J)){if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("Downloading Kotlin Language Server from GitHub.");let X=await fetch("https://api.github.com/repos/Kotlin/kotlin-lsp/releases/latest");if(!X.ok){Q0.error("Failed to fetch kotlin-lsp release info");return}let G=(await X.json()).name?.replace(/^v/,"");if(!G){Q0.error("Could not determine Kotlin LSP version from release");return}let{platform:W,arch:K}=process,V=K;if(K==="arm64")V="aarch64";else if(K==="x64")V="x64";let U=W;if(W==="darwin")U="mac";else if(W==="linux")U="linux";else if(W==="win32")U="win";let H=["mac-x64","mac-aarch64","linux-x64","linux-aarch64","win-x64","win-aarch64"],B=`${U}-${V}`;if(!H.includes(B)){Q0.error(`Platform ${W}/${K} is not supported by Kotlin LSP`);return}let z=`kotlin-lsp-${G}-${U}-${V}.zip`,F=`https://download-cdn.jetbrains.com/kotlin-lsp/${G}/${z}`;await $8.mkdir(Z,{recursive:!0});let A=o1.join(Z,"kotlin-ls.zip"),j=await fetch(F);if(!j.ok||!j.body){Q0.error("Failed to download Kotlin Language Server",{status:j.status,statusText:j.statusText});return}if(await o0.writeStream(A,j.body),!await D8.extractZip(A,Z).then(()=>!0).catch((L)=>{return Q0.error("Failed to extract Kotlin LS archive",{error:L}),!1}))return;if(await $8.rm(A,{force:!0}),process.platform!=="win32")await $8.chmod(J,493).catch(()=>{});Q0.info("Installed Kotlin Language Server",{path:J})}if(!await o0.exists(J)){Q0.error(`Failed to locate the Kotlin LS launcher script in the installed directory: ${Z}.`);return}return{process:Z1(J,["--stdio"],{cwd:$})}}},kj={id:"dart",extensions:[".dart"],root:t0(["pubspec.yaml","analysis_options.yaml"]),async spawn($){let Z=d0("dart");if(!Z){Q0.info("dart not found, please install dart first");return}return{process:Z1(Z,["language-server","--lsp"],{cwd:$})}}},vj={id:"ocaml-lsp",extensions:[".ml",".mli"],root:t0(["dune-project","dune-workspace",".merlin","opam"]),async spawn($){let Z=d0("ocamllsp");if(!Z){Q0.info("ocamllsp not found, please install ocaml-lsp-server");return}return{process:Z1(Z,{cwd:$})}}},yj={id:"gleam",extensions:[".gleam"],root:t0(["gleam.toml"]),async spawn($){let Z=d0("gleam");if(!Z){Q0.info("gleam not found, please install gleam first");return}return{process:Z1(Z,["lsp"],{cwd:$})}}},xj={id:"zls",extensions:[".zig",".zon"],root:t0(["build.zig"]),async spawn($){let Z=d0("zls");if(!Z){if(!d0("zig")){Q0.error("Zig is required to use zls. Please install Zig first.");return}if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading zls from GitHub releases");let Y=await fetch("https://api.github.com/repos/zigtools/zls/releases/latest");if(!Y.ok){Q0.error("Failed to fetch zls release info");return}let X=await Y.json(),Q=process.platform,G=process.arch,W="",K=G;if(G==="arm64")K="aarch64";else if(G==="x64")K="x86_64";else if(G==="ia32")K="x86";let V=Q;if(Q==="darwin")V="macos";else if(Q==="win32")V="windows";let U=Q==="win32"?"zip":"tar.xz";if(W=`zls-${K}-${V}.${U}`,!["zls-x86_64-linux.tar.xz","zls-x86_64-macos.tar.xz","zls-x86_64-windows.zip","zls-aarch64-linux.tar.xz","zls-aarch64-macos.tar.xz","zls-aarch64-windows.zip","zls-x86-linux.tar.xz","zls-x86-windows.zip"].includes(W)){Q0.error(`Platform ${Q} and architecture ${G} is not supported by zls`);return}let B=X.assets?.find((F)=>F.name===W);if(!B?.browser_download_url){Q0.error(`Could not find asset ${W} in latest zls release`);return}let z=await LZ(B.browser_download_url,W,"zls");if(!z)return;if(U==="zip"){if(!await TZ(z,"zls"))return}else await j6(["tar","-xf",z],{cwd:F0.Path.bin});if(await $8.rm(z,{force:!0}),Z=o1.join(F0.Path.bin,"zls"+(Q==="win32"?".exe":"")),!await o0.exists(Z)){Q0.error("Failed to extract zls binary");return}if(Q!=="win32")await $8.chmod(Z,493).catch(()=>{});Q0.info("installed zls",{bin:Z})}return{process:Z1(Z,{cwd:$})}}};import O5 from"fs/promises";import f8 from"path";function sc($){return[process.env.VIRTUAL_ENV,f8.join($,".venv"),f8.join($,"venv")].filter((Z)=>Z!==void 0)}async function uV($,Z){let J=process.platform==="win32";for(let Y of sc($)){let X=J?f8.join(Y,"Scripts",`${Z}.exe`):f8.join(Y,"bin",Z);if(await o0.exists(X))return X}return}var hj={id:"ruby-lsp",root:t0(["Gemfile"]),extensions:[".rb",".rake",".gemspec",".ru"],async spawn($){let Z=d0("rubocop");if(!Z){let J=d0("ruby"),Y=d0("gem");if(!J||!Y){Q0.info("Ruby not found, please install Ruby first");return}if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;if(Q0.info("installing rubocop"),await f1.spawn(["gem","install","rubocop","--bindir",F0.Path.bin],{stdout:"pipe",stderr:"pipe",stdin:"pipe"}).exited!==0){Q0.error("Failed to install rubocop");return}Z=f8.join(F0.Path.bin,"rubocop"+(process.platform==="win32"?".exe":"")),Q0.info("installed rubocop",{bin:Z})}return{process:Z1(Z,["--lsp"],{cwd:$})}}},gj={id:"ty",extensions:[".py",".pyi"],root:t0(["pyproject.toml","ty.toml","setup.py","setup.cfg","requirements.txt","Pipfile","pyrightconfig.json"]),async spawn($){if(!b0.QITQODE_EXPERIMENTAL_LSP_TY)return;let Z=d0("ty"),J={},Y=await uV($,"python");if(Y)J.pythonPath=Y;if(!Z)Z=await uV($,"ty")??null;if(!Z){Q0.error("ty not found, please install ty first");return}return{process:Z1(Z,["server"],{cwd:$}),initialization:J}}},uj={id:"pyright",extensions:[".py",".pyi"],root:t0(["pyproject.toml","setup.py","setup.cfg","requirements.txt","Pipfile","pyrightconfig.json"]),async spawn($){let Z=await N6(d0("pyright-langserver"),"pyright");if(!Z)return;let J=["--stdio"],Y={},X=await uV($,"python");if(X)Y.pythonPath=X;return{process:M6(Z,J,$),initialization:Y}}},mj={id:"elixir-ls",extensions:[".ex",".exs"],root:t0(["mix.exs","mix.lock"]),async spawn($){let Z=d0("elixir-ls");if(!Z){let J=f8.join(F0.Path.bin,"elixir-ls");if(Z=f8.join(F0.Path.bin,"elixir-ls-master","release",process.platform==="win32"?"language_server.bat":"language_server.sh"),!await o0.exists(Z)){if(!d0("elixir")){Q0.error("elixir is required to run elixir-ls");return}if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading elixir-ls from GitHub releases");let X=await LZ("https://github.com/elixir-lsp/elixir-ls/archive/refs/heads/master.zip","elixir-ls.zip","elixir-ls");if(!X)return;if(!await TZ(X,"elixir-ls"))return;await O5.rm(X,{force:!0,recursive:!0});let G=f8.join(F0.Path.bin,"elixir-ls-master"),W={MIX_ENV:"prod",...n8()};await f1.run(["mix","deps.get"],{cwd:G,env:W}),await f1.run(["mix","compile"],{cwd:G,env:W}),await f1.run(["mix","elixir_ls.release2","-o","release"],{cwd:G,env:W}),Q0.info("installed elixir-ls",{path:J})}}return{process:Z1(Z,{cwd:$})}}},lj={id:"php intelephense",extensions:[".php"],root:t0(["composer.json","composer.lock",".php-version"]),async spawn($){let Z=await N6(d0("intelephense"),"intelephense");if(!Z)return;return{process:M6(Z,["--stdio"],$),initialization:{telemetry:{enabled:!1}}}}},dj={id:"julials",extensions:[".jl"],root:t0(["Project.toml","Manifest.toml","*.jl"]),async spawn($){let Z=d0("julia");if(!Z){Q0.info("julia not found, please install julia first (https://julialang.org/downloads/)");return}return{process:Z1(Z,["--startup-file=no","--history-file=no","-e","using LanguageServer; runserver()"],{cwd:$})}}},pj={id:"haskell-language-server",extensions:[".hs",".lhs"],root:t0(["stack.yaml","cabal.project","hie.yaml","*.cabal"]),async spawn($){let Z=d0("haskell-language-server-wrapper");if(!Z){Q0.info("haskell-language-server-wrapper not found, please install haskell-language-server");return}return{process:Z1(Z,["--lsp"],{cwd:$})}}},cj={id:"nixd",extensions:[".nix"],root:async($,Z)=>{let J=await t0(["flake.nix"])($,Z);if(J&&J!==Z.directory)return J;if(Z.worktree&&Z.worktree!==Z.directory)return Z.worktree;return Z.directory},async spawn($){let Z=d0("nixd");if(!Z){Q0.info("nixd not found, please install nixd first");return}return{process:Z1(Z,[],{cwd:$,env:{...n8()}})}}},ij={id:"tinymist",extensions:[".typ",".typc"],root:t0(["typst.toml"]),async spawn($){let Z=d0("tinymist");if(!Z){if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading tinymist from GitHub releases");let J=await fetch("https://api.github.com/repos/Myriad-Dreamin/tinymist/releases/latest");if(!J.ok){Q0.error("Failed to fetch tinymist release info");return}let Y=await J.json(),X=process.platform,G=process.arch==="arm64"?"aarch64":"x86_64",W,K;if(X==="darwin")W="apple-darwin",K="tar.gz";else if(X==="win32")W="pc-windows-msvc",K="zip";else W="unknown-linux-gnu",K="tar.gz";let V=`tinymist-${G}-${W}.${K}`,H=(Y.assets??[]).find((z)=>z.name===V);if(!H?.browser_download_url){Q0.error(`Could not find asset ${V} in tinymist release`);return}let B=await LZ(H.browser_download_url,V,"tinymist");if(!B)return;if(K==="zip"){if(!await TZ(B,"tinymist"))return}else await j6(["tar","-xzf",B,"--strip-components=1"],{cwd:F0.Path.bin});if(await O5.rm(B,{force:!0}),Z=f8.join(F0.Path.bin,"tinymist"+(X==="win32"?".exe":"")),!await o0.exists(Z)){Q0.error("Failed to extract tinymist binary");return}if(X!=="win32")await O5.chmod(Z,493).catch(()=>{});Q0.info("installed tinymist",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},nj={id:"terraform",extensions:[".tf",".tfvars"],root:t0([".terraform.lock.hcl","terraform.tfstate","*.tf"]),async spawn($){let Z=d0("terraform-ls");if(!Z){if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading terraform-ls from HashiCorp releases");let J=await fetch("https://api.releases.hashicorp.com/v1/releases/terraform-ls/latest");if(!J.ok){Q0.error("Failed to fetch terraform-ls release info");return}let Y=await J.json(),X=process.platform,G=process.arch==="arm64"?"arm64":"amd64",W=X==="win32"?"windows":X,V=(Y.builds??[]).find((z)=>z.arch===G&&z.os===W);if(!V?.url){Q0.error(`Could not find build for ${W}/${G} terraform-ls release version ${Y.version}`);return}let U=await fetch(V.url);if(!U.ok){Q0.error("Failed to download terraform-ls");return}let H=f8.join(F0.Path.bin,"terraform-ls.zip");if(U.body)await o0.writeStream(H,U.body);if(!await D8.extractZip(H,F0.Path.bin).then(()=>!0).catch((z)=>{return Q0.error("Failed to extract terraform-ls archive",{error:z}),!1}))return;if(await O5.rm(H,{force:!0}),Z=f8.join(F0.Path.bin,"terraform-ls"+(X==="win32"?".exe":"")),!await o0.exists(Z)){Q0.error("Failed to extract terraform-ls binary");return}if(X!=="win32")await O5.chmod(Z,493).catch(()=>{});Q0.info("installed terraform-ls",{bin:Z})}return{process:Z1(Z,["serve"],{cwd:$}),initialization:{experimentalFeatures:{prefillRequiredFields:!0,validateOnSave:!0}}}}},oj={id:"texlab",extensions:[".tex",".bib"],root:t0([".latexmkrc","latexmkrc",".texlabroot","texlabroot"]),async spawn($){let Z=d0("texlab");if(!Z){if(b0.QITQODE_DISABLE_LSP_DOWNLOAD)return;Q0.info("downloading texlab from GitHub releases");let J=await fetch("https://api.github.com/repos/latex-lsp/texlab/releases/latest");if(!J.ok){Q0.error("Failed to fetch texlab release info");return}let Y=await J.json();if(!Y.tag_name?.replace("v","")){Q0.error("texlab release did not include a version tag");return}let Q=process.platform,W=process.arch==="arm64"?"aarch64":"x86_64",K=Q==="darwin"?"macos":Q==="win32"?"windows":"linux",V=Q==="win32"?"zip":"tar.gz",U=`texlab-${W}-${K}.${V}`,B=(Y.assets??[]).find((F)=>F.name===U);if(!B?.browser_download_url){Q0.error(`Could not find asset ${U} in texlab release`);return}let z=await LZ(B.browser_download_url,U,"texlab");if(!z)return;if(V==="zip"){if(!await TZ(z,"texlab"))return}if(V==="tar.gz")await j6(["tar","-xzf",z],{cwd:F0.Path.bin});if(await O5.rm(z,{force:!0}),Z=f8.join(F0.Path.bin,"texlab"+(Q==="win32"?".exe":"")),!await o0.exists(Z)){Q0.error("Failed to extract texlab binary");return}if(Q!=="win32")await O5.chmod(Z,493).catch(()=>{});Q0.info("installed texlab",{bin:Z})}return{process:Z1(Z,{cwd:$})}}},sj={id:"dockerfile",extensions:[".dockerfile","Dockerfile"],root:async($,Z)=>Z.directory,async spawn($){let Z=await N6(d0("docker-langserver"),"dockerfile-language-server-nodejs");if(!Z)return;return{process:M6(Z,["--stdio"],$)}}},rj={id:"clojure-lsp",extensions:[".clj",".cljs",".cljc",".edn"],root:t0(["deps.edn","project.clj","shadow-cljs.edn","bb.edn","build.boot"]),async spawn($){let Z=d0("clojure-lsp");if(!Z&&process.platform==="win32")Z=d0("clojure-lsp.exe");if(!Z){Q0.info("clojure-lsp not found, please install clojure-lsp first");return}return{process:Z1(Z,["listen"],{cwd:$})}}};var X8={};F1(X8,{layer:()=>Dw,defaultLayer:()=>Ya,Service:()=>Z4,Server:()=>$a,Layout:()=>Za,Info:()=>E5,ConfigDirectoryTypoError:()=>Ja});import tr from"path";var k8={};F1(k8,{sweepStaleAuthTmp:()=>tj,layer:()=>$N,defaultLayer:()=>tc,WellKnown:()=>cV,Service:()=>_9,Oauth:()=>dV,OAUTH_DUMMY_KEY:()=>lV,Info:()=>ej,AuthError:()=>S9,Auth:()=>k8,Api:()=>pV});import rc from"path";var lV="qitqode-oauth-dummy-key",b9=rc.join(F0.Path.data,"auth.json"),ac=60000;async function tj(){let $=b9+".tmp";try{let{stat:Z,unlink:J}=await import("fs/promises"),Y=await Z($);if(Date.now()-Y.mtimeMs>=ac)await J($).catch(()=>{return})}catch{}}var E9=($)=>(Z)=>new S9({message:$,cause:Z});class dV extends O.Class("OAuth")({type:O.Literal("oauth"),refresh:O.String,access:O.String,expires:O.Number,accountId:O.optional(O.String),enterpriseUrl:O.optional(O.String)}){}class pV extends O.Class("ApiAuth")({type:O.Literal("api"),key:O.String,metadata:O.optional(O.Record(O.String,O.String))}){}class cV extends O.Class("WellKnownAuth")({type:O.Literal("wellknown"),key:O.String,token:O.String}){}var aj=O.Union([dV,pV,cV]).annotate({discriminator:"type",identifier:"Auth"}),ej=Object.assign(aj,{zod:w0(aj)});class S9 extends O.TaggedErrorClass()("AuthError",{message:O.String,cause:O.optional(O.Defect)}){}class _9 extends S1.Service()("@qitqode/Auth"){}var $N=T0.effect(_9,T.gen(function*(){let $=yield*D$.Service,Z=O.decodeUnknownOption(ej);yield*T.promise(()=>tj());let J=T.fn("Auth.readFile")(function*(){let V=yield*$.readJson(b9).pipe(T.orElseSucceed(()=>({})));if(!k7.isEnvelope(V))return V;let U=yield*T.promise(()=>k7.encryptionKey());if(!U)return yield*T.fail(new S9({message:"auth.json is encrypted but the OS keyring is unavailable. Restore keyring access or delete auth.json and log in again."}));return yield*T.try({try:()=>JSON.parse(k7.decrypt(V,U)),catch:E9("Failed to decrypt auth data (keyring key mismatch?)")})}),Y=T.fn("Auth.writeFile")(function*(V){let U=yield*T.promise(()=>k7.encryptionKey()),H=U?k7.encrypt(JSON.stringify(V),U):V,B=b9+".tmp";yield*$.writeJson(B,H).pipe(T.mapError(E9("Failed to write auth data"))),yield*$.chmod(B,384).pipe(T.mapError(E9("Failed to set auth file permissions"))),yield*$.rename(B,b9).pipe(T.mapError(E9("Failed to atomically replace auth data")))}),X=T.fn("Auth.all")(function*(){let V=yield*J(),U=y7.filterMap(V,(H)=>v7.fromOption(Z(H),()=>{return}));if(process.env.QITQODE_AUTH_CONTENT)try{let H=JSON.parse(process.env.QITQODE_AUTH_CONTENT);return{...y7.filterMap(H,(z)=>v7.fromOption(Z(z),()=>{return})),...U}}catch(H){console.error("[Auth] Failed to parse QITQODE_AUTH_CONTENT env var:",H)}return U}),Q=T.fn("Auth.get")(function*(V){return(yield*X())[V]}),G="auth-file",W=T.fn("Auth.set")(function*(V,U){yield*T.scoped(T.gen(function*(){yield*mV.effect(G);let H=V.replace(/\/+$/,""),B=yield*X();if(H!==V)delete B[V];delete B[H+"/"],yield*Y({...B,[H]:U})}))}),K=T.fn("Auth.remove")(function*(V){yield*T.scoped(T.gen(function*(){yield*mV.effect(G);let U=V.replace(/\/+$/,""),H=yield*X();delete H[V],delete H[U],yield*Y(H)}))});return _9.of({get:Q,all:X,set:W,remove:K})})),tc=$N.pipe(T0.provide(D$.defaultLayer));var l6={};F1(l6,{layer:()=>ZN,defaultLayer:()=>ec,Service:()=>f9,Env:()=>l6});class f9 extends S1.Service()("@qitqode/Env"){}var ZN=T0.effect(f9,T.gen(function*(){let $=yield*B0.make(T.fn("Env.state")(()=>T.succeed({...process.env}))),Z=T.fn("Env.get")((Q)=>B0.use($,(G)=>G[Q])),J=T.fn("Env.all")(()=>B0.get($)),Y=T.fn("Env.set")(function*(Q,G){let W=yield*B0.get($);W[Q]=G}),X=T.fn("Env.remove")(function*(Q){let G=yield*B0.get($);delete G[Q]});return f9.of({get:Z,all:J,set:Y,remove:X})})),ec=ZN;var JN={Connected:L1.define("server.connected",P.object({})),Heartbeat:L1.define("server.heartbeat",P.object({})),Disposed:L1.define("global.disposed",P.object({}))};var o7={};F1(o7,{layer:()=>FN,defaultLayer:()=>Qi,UserCode:()=>uY,Service:()=>u9,RefreshToken:()=>x7,PollSuccess:()=>u7,PollSlow:()=>l7,PollResult:()=>YN,PollPending:()=>m7,PollExpired:()=>d7,PollError:()=>c7,PollDenied:()=>p7,OrgID:()=>v9,Org:()=>lY,Login:()=>dY,Info:()=>mY,DeviceCode:()=>h7,AccountTransportError:()=>j5,AccountServiceError:()=>RZ,AccountRepoError:()=>g7,AccountID:()=>hY,Account:()=>o7,AccessToken:()=>gY});var i7={};F1(i7,{layer:()=>$i,Service:()=>x9,AccountRepo:()=>i7});var L8=g6("account",{id:w1().$type().primaryKey(),email:w1().notNull(),url:w1().notNull(),access_token:w1().$type().notNull(),refresh_token:w1().$type().notNull(),token_expiry:j8(),...xY}),q5=g6("account_state",{id:j8().primaryKey(),active_account_id:w1().$type().references(()=>L8.id,{onDelete:"set null"}),active_org_id:w1().$type()}),kT0=g6("control_account",{email:w1().notNull(),url:w1().notNull(),access_token:w1().$type().notNull(),refresh_token:w1().$type().notNull(),token_expiry:j8(),active:j8({mode:"boolean"}).notNull().$default(()=>!1),...xY},($)=>[k9({columns:[$.email,$.url]})]);var hY=O.String.pipe(O.brand("AccountID")),v9=O.String.pipe(O.brand("OrgID")),gY=O.String.pipe(O.brand("AccessToken")),x7=O.String.pipe(O.brand("RefreshToken")),h7=O.String.pipe(O.brand("DeviceCode")),uY=O.String.pipe(O.brand("UserCode"));class mY extends O.Class("Account")({id:hY,email:O.String,url:O.String,active_org_id:O.NullOr(v9)}){}class lY extends O.Class("Org")({id:v9,name:O.String}){}class g7 extends O.TaggedErrorClass()("AccountRepoError",{message:O.String,cause:O.optional(O.Defect)}){}class RZ extends O.TaggedErrorClass()("AccountServiceError",{message:O.String,cause:O.optional(O.Defect)}){}class j5 extends O.TaggedErrorClass()("AccountTransportError",{method:O.String,url:O.String,description:O.optional(O.String),cause:O.optional(O.Defect)}){static fromHttpClientError($){return new j5({method:$.request.method,url:$.request.url,description:$.description,cause:$.cause})}get message(){return[`Could not reach ${this.method} ${this.url}.`,"This failed before the server returned an HTTP response.",this.description,"Check your network, proxy, or VPN configuration and try again."].filter(Boolean).join(`
486
- `)}}class dY extends O.Class("Login")({code:h7,user:uY,url:O.String,server:O.String,expiry:O.Duration,interval:O.Duration}){}class u7 extends O.TaggedClass()("PollSuccess",{email:O.String}){}class m7 extends O.TaggedClass()("PollPending",{}){}class l7 extends O.TaggedClass()("PollSlow",{}){}class d7 extends O.TaggedClass()("PollExpired",{}){}class p7 extends O.TaggedClass()("PollDenied",{}){}class c7 extends O.TaggedClass()("PollError",{cause:O.Defect}){}var YN=O.Union([u7,m7,l7,d7,p7,c7]);var y9=($)=>{let Z=new URL($);Z.search="",Z.hash="";let J=Z.pathname.replace(/\/+$/,"");return J.length===0?Z.origin:`${Z.origin}${J}`};var XN=1;class x9 extends S1.Service()("@qitqode/AccountRepo"){}var $i=T0.effect(x9,T.gen(function*(){let $=O.decodeUnknownSync(mY),Z=(B)=>T.try({try:()=>W1.use(B),catch:(z)=>new g7({message:"Database operation failed",cause:z})}),J=(B)=>T.try({try:()=>W1.transaction(B),catch:(z)=>new g7({message:"Database operation failed",cause:z})}),Y=(B)=>{let z=B.select().from(q5).where(m0(q5.id,XN)).get();if(!z?.active_account_id)return;let F=B.select().from(L8).where(m0(L8.id,z.active_account_id)).get();if(!F)return;return{...F,active_org_id:z.active_org_id??null}},X=(B,z,F)=>{let A=O1.getOrNull(F);return B.insert(q5).values({id:XN,active_account_id:z,active_org_id:A}).onConflictDoUpdate({target:q5.id,set:{active_account_id:z,active_org_id:A}}).run()},Q=T.fn("AccountRepo.active")(()=>Z((B)=>Y(B)).pipe(T.map((B)=>B?O1.some($(B)):O1.none()))),G=T.fn("AccountRepo.list")(()=>Z((B)=>B.select().from(L8).all().map((z)=>$({...z,active_org_id:null})))),W=T.fn("AccountRepo.remove")((B)=>J((z)=>{z.update(q5).set({active_account_id:null,active_org_id:null}).where(m0(q5.active_account_id,B)).run(),z.delete(L8).where(m0(L8.id,B)).run()}).pipe(T.asVoid)),K=T.fn("AccountRepo.use")((B,z)=>Z((F)=>X(F,B,z)).pipe(T.asVoid)),V=T.fn("AccountRepo.getRow")((B)=>Z((z)=>z.select().from(L8).where(m0(L8.id,B)).get()).pipe(T.map(O1.fromNullishOr))),U=T.fn("AccountRepo.persistToken")((B)=>Z((z)=>z.update(L8).set({access_token:B.accessToken,refresh_token:B.refreshToken,token_expiry:O1.getOrNull(B.expiry)}).where(m0(L8.id,B.accountID)).run()).pipe(T.asVoid)),H=T.fn("AccountRepo.persistAccount")((B)=>J((z)=>{let F=y9(B.url);z.insert(L8).values({id:B.id,email:B.email,url:F,access_token:B.accessToken,refresh_token:B.refreshToken,token_expiry:B.expiry}).onConflictDoUpdate({target:L8.id,set:{email:B.email,url:F,access_token:B.accessToken,refresh_token:B.refreshToken,token_expiry:B.expiry}}).run(),X(z,B.id,B.orgID)}).pipe(T.asVoid));return x9.of({active:Q,list:G,remove:W,use:K,getRow:V,persistToken:U,persistAccount:H})}));class VN extends O.Class("RemoteConfig")({config:O.Record(O.String,O.Json)}){}var g9=O.Number.pipe(O.decodeTo(O.Duration,{decode:nV.transform(($)=>Z8.seconds($)),encode:nV.transform(($)=>Z8.toSeconds($))}));class UN extends O.Class("TokenRefresh")({access_token:gY,refresh_token:x7,expires_in:g9}){}class HN extends O.Class("DeviceAuth")({device_code:h7,user_code:uY,verification_uri_complete:O.String,expires_in:g9,interval:g9}){}class BN extends O.Class("DeviceTokenSuccess")({access_token:gY,refresh_token:x7,token_type:O.Literal("Bearer"),expires_in:g9}){}class tV extends O.Class("DeviceTokenError")({error:O.String,error_description:O.String}){toPollResult(){if(this.error==="authorization_pending")return new m7;if(this.error==="slow_down")return new l7;if(this.error==="expired_token")return new d7;if(this.error==="access_denied")return new p7;return new c7({cause:this.error})}}var Zi=O.Union([BN,tV]);class zN extends O.Class("User")({id:hY,email:O.String}){}class sV extends O.Class("ClientId")({client_id:O.String}){}class rV extends O.Class("DeviceTokenRequest")({grant_type:O.String,device_code:h7,client_id:O.String}){}class aV extends O.Class("TokenRefreshRequest")({grant_type:O.String,refresh_token:x7,client_id:O.String}){}var iV="opencode-cli",Ji=Z8.minutes(5),Yi=Z8.toMillis(Ji),QN=($,Z)=>$!=null&&$>Z+Yi,o8=($="Account service operation failed")=>(Z)=>Z.pipe(T.mapError((J)=>Xi(J,$))),Xi=($,Z)=>{if($ instanceof RZ||$ instanceof j5)return $;if(GN.isHttpClientError($))switch($.reason._tag){case"TransportError":return j5.fromHttpClientError($.reason);default:return new RZ({message:Z,cause:$})}return new RZ({message:Z,cause:$})};class u9 extends S1.Service()("@qitqode/Account"){}var FN=T0.effect(u9,T.gen(function*(){let $=yield*i7.Service,Z=yield*h9.HttpClient,J=KN(Z),Y=h9.filterStatusOk(Z),X=h9.filterStatusOk(J),Q=(R)=>J.execute(R).pipe(o8("HTTP request failed")),G=(R)=>X.execute(R).pipe(o8("HTTP request failed")),W=(R)=>R.pipe(T.flatMap((w)=>Y.execute(w)),o8("HTTP request failed")),K=(R)=>R.pipe(T.flatMap((w)=>Z.execute(w)),o8("HTTP request failed")),V=T.fnUntraced(function*(R){let w=yield*n7.currentTimeMillis,I=yield*W(V$.post(`${R.url}/auth/device/token`).pipe(V$.acceptJson,V$.schemaBodyJson(aV)(new aV({grant_type:"refresh_token",refresh_token:R.refresh_token,client_id:iV})))),_=yield*PZ.schemaBodyJson(UN)(I).pipe(o8("Failed to decode response")),E=O1.some(w+Z8.toMillis(_.expires_in));return yield*$.persistToken({accountID:R.id,accessToken:_.access_token,refreshToken:_.refresh_token,expiry:E}),_.access_token}),U=yield*oV.make({capacity:Number.POSITIVE_INFINITY,timeToLive:Z8.zero,lookup:T.fnUntraced(function*(R){let w=yield*$.getRow(R);if(O1.isNone(w))return yield*T.fail(new RZ({message:"Account not found during token refresh"}));let I=w.value,_=yield*n7.currentTimeMillis;if(QN(I.token_expiry,_))return I.access_token;return yield*V(I)})}),H=T.fnUntraced(function*(R){let w=yield*n7.currentTimeMillis;if(QN(R.token_expiry,w))return R.access_token;return yield*oV.get(U,R.id)}),B=T.fnUntraced(function*(R){let w=yield*$.getRow(R);if(O1.isNone(w))return O1.none();let I=w.value,_=yield*H(I);return O1.some({account:I,accessToken:_})}),z=T.fnUntraced(function*(R,w){let I=yield*G(V$.get(`${R}/api/orgs`).pipe(V$.acceptJson,V$.bearerToken(w)));return yield*PZ.schemaBodyJson(O.Array(lY))(I).pipe(o8("Failed to decode response"))}),F=T.fnUntraced(function*(R,w){let I=yield*G(V$.get(`${R}/api/user`).pipe(V$.acceptJson,V$.bearerToken(w)));return yield*PZ.schemaBodyJson(zN)(I).pipe(o8("Failed to decode response"))}),A=T.fn("Account.token")((R)=>B(R).pipe(T.map(O1.map((w)=>w.accessToken)))),j=T.fn("Account.activeOrg")(function*(){let R=yield*$.active();if(O1.isNone(R))return O1.none();let w=R.value;if(!w.active_org_id)return O1.none();let _=(yield*L(w.id)).find((E)=>E.id===w.active_org_id);if(!_)return O1.none();return O1.some({account:w,org:_})}),N=T.fn("Account.orgsByAccount")(function*(){let R=yield*$.list();return yield*T.forEach(R,(w)=>L(w.id).pipe(T.catch(()=>T.succeed([])),T.map((I)=>({account:w,orgs:I}))),{concurrency:3})}),L=T.fn("Account.orgs")(function*(R){let w=yield*B(R);if(O1.isNone(w))return[];let{account:I,accessToken:_}=w.value;return yield*z(I.url,_)}),q=T.fn("Account.config")(function*(R,w){let I=yield*B(R);if(O1.isNone(I))return O1.none();let{account:_,accessToken:E}=I.value,f=yield*Q(V$.get(`${_.url}/api/config`).pipe(V$.acceptJson,V$.bearerToken(E),V$.setHeaders({"x-org-id":w})));if(f.status===404)return O1.none();let b=yield*PZ.filterStatusOk(f).pipe(o8()),y=yield*PZ.schemaBodyJson(VN)(b).pipe(o8("Failed to decode response"));return O1.some(y.config)}),M=T.fn("Account.login")(function*(R){let w=y9(R),I=yield*W(V$.post(`${w}/auth/device/code`).pipe(V$.acceptJson,V$.schemaBodyJson(sV)(new sV({client_id:iV})))),_=yield*PZ.schemaBodyJson(HN)(I).pipe(o8("Failed to decode response"));return new dY({code:_.device_code,user:_.user_code,url:`${w}${_.verification_uri_complete}`,server:w,expiry:_.expires_in,interval:_.interval})}),C=T.fn("Account.poll")(function*(R){let w=yield*K(V$.post(`${R.server}/auth/device/token`).pipe(V$.acceptJson,V$.schemaBodyJson(rV)(new rV({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:R.code,client_id:iV})))),I=yield*PZ.schemaBodyJson(Zi)(w).pipe(o8("Failed to decode response"));if(I instanceof tV)return I.toPollResult();let _=I.access_token,E=F(R.server,_),f=z(R.server,_),[b,y]=yield*T.all([E,f],{concurrency:2}),k=y.length>0?O1.some(y[0].id):O1.none(),d=(yield*n7.currentTimeMillis)+Z8.toMillis(I.expires_in),p=I.refresh_token;return yield*$.persistAccount({id:b.id,email:b.email,url:R.server,accessToken:_,refreshToken:p,expiry:d,orgID:k}),new u7({email:b.email})});return u9.of({active:$.active,activeOrg:j,list:$.list,orgsByAccount:N,remove:$.remove,use:$.use,orgs:L,config:q,token:A,login:M,poll:C})})),Qi=FN.pipe(T0.provide(i7.layer),T0.provide(WN.layer));import Gi from"path";async function qN(){let $=["qitqode.jsonc","qitqode.json","config.json"].map((Z)=>Gi.join(F0.Path.config,Z));for(let Z of $)if(await o0.exists(Z))return Z;return $[0]}function eV($,Z,J=[]){if(!J8(Z)){let Y=AN($,J,Z,{formattingOptions:{insertSpaces:!0,tabSize:2}});return ON($,Y)}return Object.entries(Z).reduce((Y,[X,Q])=>{if(Q===void 0)return Y;return eV(Y,Q,[...J,X])},$)}function s7($){let{plugin_origins:Z,mcp_origins:J,...Y}=$;return Y}var Wi=E0.create({service:"config.sources"});function jN($,Z){if(!J8($))return $;let J={...$};if(!(("theme"in J)||("keybinds"in J)||("tui"in J)))return J;return delete J.theme,delete J.keybinds,delete J.tui,Wi.warn("tui keys in qitqode config are deprecated; move them to tui.json",{path:Z}),J}async function NN($,Z){if(!$.plugin)return $;for(let J=0;J<$.plugin.length;J++)$.plugin[J]=await s8.resolvePluginSpec($.plugin[J],Z);return $}var Ki=E0.create({service:"config.loader"});function MN($){let Z=T.fnUntraced(function*(X){return yield*$.fs.readFileString(X).pipe(T.catchIf((Q)=>Q.reason._tag==="NotFound",()=>T.succeed(void 0)),T.orDie)}),J=T.fnUntraced(function*(X,Q){let G="path"in Q?Q.path:Q.source,W=yield*T.promise(()=>$U.substitute("path"in Q?{text:X,type:"path",path:Q.path}:{text:X,type:"virtual",...Q})),K=r8.jsonc(W,G),V=r8.schema($.info,jN(K,G),G);if(!("path"in Q))return V;if(yield*T.promise(()=>NN(V,Q.path)),!V.$schema){V.$schema="https://opencode.ai/config.json";let U=X.replace(/^\s*\{/,`{
487
- "$schema": "https://opencode.ai/config.json",`);yield*$.fs.writeFileString(Q.path,U).pipe(T.catch(()=>T.void))}return V}),Y=T.fnUntraced(function*(X){Ki.info("loading",{path:X});let Q=yield*Z(X);if(!Q)return{};return yield*J(Q,{path:X})});return{readConfigFile:Z,loadConfig:J,loadFile:Y}}import pY from"path";import{pathToFileURL as Vi}from"url";import ZU from"fs/promises";function wN($){return T.fnUntraced(function*(){let Z=DN({},N1(yield*$(pY.join(F0.Path.config,"config.json"))),N1(yield*$(pY.join(F0.Path.config,"qitqode.json"))),N1(yield*$(pY.join(F0.Path.config,"qitqode.jsonc")))),J=pY.join(F0.Path.config,"config");if(!(yield*T.promise(()=>ZU.access(J).then(()=>!0,()=>!1))))return Z;return yield*T.promise(()=>import(Vi(J).href,{with:{type:"toml"}}).then(async(X)=>{let{provider:Q,model:G,...W}=X.default;if(Q&&G)Z.model=`${Q}/${G}`;Z.$schema="https://opencode.ai/config.json",Z=N1(Z,W),await ZU.writeFile(pY.join(F0.Path.config,"config.json"),JSON.stringify(Z,null,2)),await ZU.unlink(J)}).catch(()=>{})),Z})}import fZ from"path";import lr from"os";function m9($,Z){let J=N1($,Z);if($.instructions&&Z.instructions)J.instructions=Array.from(new Set([...$.instructions,...Z.instructions]));return J}var IZ={};F1(IZ,{redactString:()=>RN,redactCommand:()=>Ai,fromClaude:()=>Fi,Remote:()=>QU,OAuth:()=>XU,Local:()=>YU,Info:()=>Ui,ConfigMCP:()=>IZ});class YU extends O.Class("McpLocalConfig")({type:O.Literal("local").annotate({description:"Type of MCP server connection"}),command:O.mutable(O.Array(O.String)).annotate({description:"Command and arguments to run the MCP server"}),environment:O.optional(O.Record(O.String,O.String)).annotate({description:"Environment variables to set when running the MCP server"}),enabled:O.optional(O.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),timeout:O.optional(O.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}){static zod=w0(this)}class XU extends O.Class("McpOAuthConfig")({clientId:O.optional(O.String).annotate({description:"OAuth client ID. If not provided, dynamic client registration (RFC 7591) will be attempted."}),clientSecret:O.optional(O.String).annotate({description:"OAuth client secret (if required by the authorization server)"}),scope:O.optional(O.String).annotate({description:"OAuth scopes to request during authorization"}),redirectUri:O.optional(O.String).annotate({description:"OAuth redirect URI (default: http://127.0.0.1:19876/mcp/oauth/callback)."})}){static zod=w0(this)}class QU extends O.Class("McpRemoteConfig")({type:O.Literal("remote").annotate({description:"Type of MCP server connection"}),url:O.String.annotate({description:"URL of the remote MCP server"}),enabled:O.optional(O.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),headers:O.optional(O.Record(O.String,O.String)).annotate({description:"Headers to send with the request"}),oauth:O.optional(O.Union([XU,O.Literal(!1)])).annotate({description:"OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection."}),timeout:O.optional(O.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}){static zod=w0(this)}var Ui=O.Union([YU,QU]).annotate({discriminator:"type"}).pipe(u0(($)=>({zod:w0($)}))),LN=new Set(["http","streamable-http","remote"]),TN=new Set(["stdio","local"]),Hi=["authorization","token","api_key","apikey","key","secret","password","credential"];function JU($){if(!J8($))return;return Object.fromEntries(Object.entries($).filter((Z)=>typeof Z[1]==="string"))}function Bi($){return Hi.some((Z)=>$.toLowerCase().includes(Z))}function zi($){if($===!1)return!1;if(!J8($))return;let Z={...typeof $.clientId==="string"&&{clientId:$.clientId},...typeof $.clientSecret==="string"&&{clientSecret:$.clientSecret},...typeof $.scope==="string"&&{scope:$.scope},...typeof $.redirectUri==="string"&&{redirectUri:$.redirectUri}};return Object.keys(Z).length>0?Z:void 0}function Fi($,Z){if(!J8(Z))return{warning:`skipped Claude Code MCP server "${$}"; server config is not an object.`};if(Z.type==="sse")return{warning:`skipped Claude Code MCP server "${$}"; unsupported transport "sse".`};if(Z.args!==void 0&&!Array.isArray(Z.args))return{warning:`skipped Claude Code MCP server "${$}"; args is not an array.`};let J=Array.isArray(Z.args)?Z.args:[];if(!J.every((W)=>typeof W==="string"))return{warning:`skipped Claude Code MCP server "${$}"; args must contain only strings.`};let Y=Z.disabled===!0?!1:Z.enabled===!1?!1:!0,X=JU(Z.environment)??JU(Z.env),Q=typeof Z.timeout==="number"?Z.timeout:void 0,G=typeof Z.type==="string"?Z.type:void 0;if(typeof Z.command==="string"&&(!G||TN.has(G)))return{config:{type:"local",command:[Z.command,...J],...X&&{environment:X},enabled:Y,...Q!==void 0&&{timeout:Q}}};if(Z.command!==void 0)return{warning:`skipped Claude Code MCP server "${$}"; command is not a string.`};if(typeof Z.url==="string"&&(!G||LN.has(G))){let W=JU(Z.headers),K=zi(Z.oauth);return{config:{type:"remote",url:Z.url,enabled:Y,...W&&{headers:W},...K!==void 0&&{oauth:K},...Q!==void 0&&{timeout:Q}}}}if(Z.url!==void 0)return{warning:`skipped Claude Code MCP server "${$}"; url is not a string.`};if(G&&!TN.has(G)&&!LN.has(G))return{warning:`skipped Claude Code MCP server "${$}"; unsupported transport "${G}".`};return{warning:`skipped Claude Code MCP server "${$}"; missing command or url.`}}function RN($){return $.replace(/(Bearer\s+)[^\s]+/gi,"$1****").replace(/([?&][^=\s&]*(?:authorization|token|api[_-]?key|apikey|key|secret|password|credential)[^=\s&]*=)[^&\s]+/gi,"$1****").replace(/((?:authorization|token|api[_-]?key|apikey|key|secret|password|credential)=)[^\s]+/gi,"$1****")}function Ai($){return $.map((Z,J)=>{if(J>0&&Bi($[J-1]))return"****";return RN(Z)})}var GU=E0.create({service:"config.sources"});function PN($){let Z=(G,W,K,V)=>{if(!K.mcp)return G;return{...G,mcp_origins:{...G.mcp_origins??{},...Object.fromEntries(Object.keys(K.mcp).map((U)=>[U,{type:V,source:W}]))}}},J=T.fnUntraced(function*(G,W,K,V){if(!K?.length)return G;let U=V??(yield*$.resolvePluginScope(W)),H=s8.deduplicatePluginOrigins([...G.plugin_origins??[],...K.map((B)=>({spec:B,source:W,scope:U}))]);return{...G,plugin:H.map((B)=>B.spec),plugin_origins:H}}),Y=T.fnUntraced(function*(G,W,K,V){let U=m9(G,K),H=Z(U,W,K,"qitqode");return yield*J(H,W,K.plugin,V)}),X=T.fnUntraced(function*(G){let W=yield*$.readConfigFile(G);if(!W)return;return yield*T.try({try:()=>JSON.parse(W),catch:()=>Error(`failed to parse ${G}; Claude Code MCP compatibility skipped.`)}).pipe(T.tapError((K)=>T.sync(()=>GU.warn(K.message))),T.option,T.map(O1.getOrUndefined))}),Q=T.fnUntraced(function*(G,W){let K=yield*X(W);if(!J8(K)||!J8(K.mcpServers))return G;let V=G;for(let[U,H]of Object.entries(K.mcpServers)){if(V.mcp?.[U]&&V.mcp_origins?.[U]?.type!=="claude"){GU.info(`skipped Claude Code MCP server "${U}"; native qitqode MCP with same name already exists.`);continue}let z=IZ.fromClaude(U,H);if("warning"in z){GU.warn(z.warning);continue}let F=r8.schema($.info,{mcp:{[U]:z.config}},W);V={...V,mcp:{...V.mcp??{},[U]:F.mcp[U]},mcp_origins:{...V.mcp_origins??{},[U]:{type:"claude",source:W}}}}return V});return{merge:Y,mergeMcpOrigins:Z,mergePluginOrigins:J,mergeClaudeMcp:Q}}function IN($,Z){let J=$;for(let[Y,X]of Object.entries(J.mode??{}))J.agent=N1(J.agent??{},{[Y]:{...X,mode:"primary"}});if(Z.permissionOverride)J.permission=N1(J.permission??{},JSON.parse(Z.permissionOverride));if(J.tools){let Y={};for(let[X,Q]of Object.entries(J.tools)){let G=Q?"allow":"deny";if(X==="write"||X==="edit"||X==="patch"||X==="multiedit"){Y.edit=G;continue}Y[X]=G}J.permission=N1(Y,J.permission??{})}if(!J.username)J.username=Z.username;if(J.autoshare===!0&&!J.share)J.share="auto";if(Z.disableAutoCompact)J.compaction={...J.compaction,auto:!1};if(Z.disablePrune)J.compaction={...J.compaction,prune:!1};return J}var c6={};F1(c6,{loadMode:()=>kr,load:()=>fr,Info:()=>_U,ConfigAgent:()=>c6});import CN from"path";function Oi($,Z){let J=$.replaceAll("\\","/");for(let Y of Z){let X=J.indexOf(Y);if(X===-1)continue;return J.slice(X+Y.length)}}function EN($,Z){let J=Oi($,Z)??CN.basename($),Y=CN.extname(J);return Y.length?J.slice(0,-Y.length):J}var bU={};F1(bU,{shell:()=>Dr,parse:()=>EU,files:()=>Mr,fallbackSanitization:()=>rD,SHELL_REGEX:()=>sD,FrontmatterError:()=>eY,FILE_REGEX:()=>oD});var CU=m6(nD(),1);var oD=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g,sD=/!`([^`]+)`/g;function Mr($){return Array.from($.matchAll(oD))}function Dr($){return Array.from($.matchAll(sD))}function rD($){let Z=$.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!Z)return $;let J=Z[1],Y=J.split(/\r?\n/),X=[];for(let G of Y){if(G.trim().startsWith("#")||G.trim()===""){X.push(G);continue}if(G.match(/^\s+/)){X.push(G);continue}let W=G.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*:\s*(.*)$/);if(!W){X.push(G);continue}let K=W[1],V=W[2].trim();if(V===""||V===">"||V==="|"||V.startsWith('"')||V.startsWith("'")){X.push(G);continue}if(V.includes(":")){X.push(`${K}: |-`),X.push(` ${V}`);continue}X.push(G)}let Q=X.join(`
488
- `);return $.replace(J,()=>Q)}async function EU($){let Z=await o0.readText($);try{return CU.default(Z,{})}catch(J){let Y=rD(Z);if(Y===Z)throw new eY({path:$,message:`${$}: Failed to parse YAML frontmatter: ${J instanceof Error?J.message:String(J)}`},{cause:J});try{return CU.default(Y,{})}catch(X){throw new eY({path:$,message:`${$}: Failed to parse YAML frontmatter: ${X instanceof Error?X.message:String(X)}`},{cause:X})}}}var eY=j1.create("ConfigFrontmatterError",D.object({path:D.string(),message:D.string()}));var wr=E0.create({service:"config"});function $X($,Z,J,Y){let X=$.safeParse(Z);if(X.success)return X.data;if(Y?.ignoreInvalid)return;throw new aD({path:J,issues:X.error.issues},{cause:X.error})}async function ZX($){for(let Z of await $4.scan($.glob,{cwd:$.dir,absolute:!0,dot:!0,symlink:!0})){let J=await EU(Z).catch(async(Q)=>{let G=eY.isInstance(Q)?Q.data.message:`Failed to parse ${$.entity} ${Z}`,{Session:W}=await import("./chunk-zxwjxszn.js");l1.publish(W.Event.Error,{error:new j1.Unknown({message:G}).toObject()}),wr.error(`failed to load ${$.entity}`,{[$.entity]:Z,err:Q});return});if(!J)continue;let X={name:EN(Z,$.namePatterns),...J.data,[$.contentKey]:J.content.trim()};$.store(X,Z)}}var T8=O.String.annotate({[F$]:P.string().meta({$ref:"https://models.dev/model-schema.json#/$defs/Model"})}).pipe(u0(($)=>({zod:w0($)})));var _Z={};F1(_Z,{Rule:()=>R8,Object:()=>eD,Info:()=>Ir,ConfigPermission:()=>_Z,Action:()=>p6});var p6=O.Literals(["ask","allow","deny"]).annotate({identifier:"PermissionActionConfig"}).pipe(u0(($)=>({zod:w0($)}))),eD=O.Record(O.String,p6).annotate({identifier:"PermissionObjectConfig"}).pipe(u0(($)=>({zod:w0($)}))),R8=O.Union([p6,eD]).annotate({identifier:"PermissionRuleConfig"}).pipe(u0(($)=>({zod:w0($)}))),Lr=($)=>{if(typeof $==="object"&&$!==null&&!Array.isArray($))return{__originalKeys:globalThis.Object.keys($),...$};return $},Tr=O.StructWithRest(O.Struct({__originalKeys:O.optional(O.mutable(O.Array(O.String))),read:O.optional(R8),edit:O.optional(R8),glob:O.optional(R8),grep:O.optional(R8),list:O.optional(R8),bash:O.optional(R8),task:O.optional(R8),actor:O.optional(R8),external_directory:O.optional(R8),question:O.optional(p6),webfetch:O.optional(p6),websearch:O.optional(p6),codesearch:O.optional(p6),lsp:O.optional(R8),doom_loop:O.optional(p6),skill:O.optional(R8)}),[O.Record(O.String,R8)]),Rr=O.Union([Tr,p6]).annotate({[tD]:Lr}),Pr=($)=>{if(typeof $==="string")return{"*":$};let Z=$,{__originalKeys:J,...Y}=Z;if(!J)return Y;let X={};for(let Q of J)if(Q in Y)X[Q]=Y[Q];return X},Ir=w0(Rr).transform(Pr).meta({ref:"PermissionConfig"});var $w=O.Number.check(O.isInt()).check(O.isGreaterThan(0)),Cr=O.Union([O.String.check(O.isPattern(/^#[0-9a-fA-F]{6}$/)),O.Literals(["primary","secondary","accent","success","warning","error","info"])]),Er=O.Any.annotate({[F$]:_Z.Info}),br=O.StructWithRest(O.Struct({model:O.optional(T8).annotate({description:"Model for this agent: a literal provider/model (e.g. anthropic/claude-opus-4-8) or a tier/group name (e.g. fast/economical/default/power). Names without a '/' are resolved as model groups, provider-aware, at spawn time."}),variant:O.optional(O.String).annotate({description:"Default model variant for this agent (applies only when using the agent's configured model)."}),temperature:O.optional(O.Number),top_p:O.optional(O.Number),prompt:O.optional(O.String),tools:O.optional(O.Record(O.String,O.Boolean)).annotate({description:"@deprecated Use 'permission' field instead"}),disable:O.optional(O.Boolean),description:O.optional(O.String).annotate({description:"Description of when to use the agent"}),mode:O.optional(O.Literals(["subagent","primary","all"])),hidden:O.optional(O.Boolean).annotate({description:"Hide this subagent from the @ autocomplete menu (default: false, only applies to mode: subagent)"}),options:O.optional(O.Record(O.String,O.Any)),color:O.optional(Cr).annotate({description:"Hex color code (e.g., #FF5733) or theme color (e.g., primary)"}),steps:O.optional($w).annotate({description:"Maximum number of agentic iterations before forcing text-only response"}),tool_allowlist:O.optional(O.Array(O.String)).annotate({description:"Optional list of tool IDs allowed for this agent. When set, only these tools are available."}),maxSteps:O.optional($w).annotate({description:"@deprecated Use 'steps' field instead."}),permission:O.optional(Er)}),[O.Record(O.String,O.Any)]),_r=new Set(["name","model","variant","prompt","description","temperature","top_p","mode","hidden","color","steps","maxSteps","options","permission","disable","tools","tool_allowlist"]),Sr=($)=>{let Z={...$.options};for(let[Y,X]of Object.entries($))if(!_r.has(Y))Z[Y]=X;let J={};for(let[Y,X]of Object.entries($.tools??{})){let Q=X?"allow":"deny";if(Y==="write"||Y==="edit"||Y==="patch"||Y==="multiedit"){J.edit=Q;continue}if(Y==="task"){J.actor=Q;continue}J[Y]=Q}return globalThis.Object.assign(J,$.permission),{...$,options:Z,permission:J,steps:$.steps??$.maxSteps}},_U=w0(br).transform(Sr).meta({ref:"AgentConfig"});async function fr($){let Z={};return await ZX({dir:$,glob:"{agent,agents}/**/*.md",entity:"agent",namePatterns:["/.qitqode/agent/","/.qitqode/agents/","/agent/","/agents/"],contentKey:"prompt",store:(J,Y)=>{Z[J.name]=$X(_U,J,Y)}}),Z}async function kr($){let Z={};return await ZX({dir:$,glob:"{mode,modes}/*.md",entity:"mode",namePatterns:[],contentKey:"prompt",store:(J,Y)=>{let X=$X(_U,J,Y,{ignoreInvalid:!0});if(X)Z[J.name]={...X,mode:"primary"}}}),Z}var i6={};F1(i6,{load:()=>vr,Info:()=>Zw,ConfigCommand:()=>i6});var Zw=O.Struct({template:O.String,description:O.optional(O.String),agent:O.optional(O.String),model:O.optional(T8),subtask:O.optional(O.Boolean)}).pipe(u0(($)=>({zod:w0($)})));async function vr($){let Z={};return await ZX({dir:$,glob:"{command,commands}/**/*.md",entity:"command",namePatterns:["/.qitqode/command/","/.qitqode/commands/","/.claude/command/","/.claude/commands/","/command/","/commands/"],contentKey:"template",store:(J,Y)=>{Z[J.name]=$X(Zw.zod,J,Y)}}),Z}var R5={};F1(R5,{readManagedPreferences:()=>mr,parseManagedPlist:()=>Qw,managedConfigDirs:()=>Xw,managedConfigDir:()=>ur,ConfigManaged:()=>R5});import yr from"os";import SU from"path";var Jw=E0.create({service:"config"}),xr="ai.qitqode.managed",hr="ai.opencode.managed",gr=new Set(["PayloadDisplayName","PayloadIdentifier","PayloadType","PayloadUUID","PayloadVersion","_manualProfile"]);function Yw($="qitqode"){switch(process.platform){case"darwin":return`/Library/Application Support/${$}`;case"win32":return SU.join(process.env.ProgramData||"C:\\ProgramData",$);default:return`/etc/${$}`}}function ur(){return Xw().at(-1)}function Xw(){let $=process.env.QITQODE_TEST_MANAGED_CONFIG_DIR;if($)return[$];return[Yw("opencode"),Yw()]}function Qw($){let Z=JSON.parse($);for(let J of Object.keys(Z))if(gr.has(J))delete Z[J];return JSON.stringify(Z)}async function mr(){if(process.platform!=="darwin")return;let $=yr.userInfo().username,Z=[hr,xr].flatMap((J)=>[SU.join("/Library/Managed Preferences",$,`${J}.plist`),SU.join("/Library/Managed Preferences",`${J}.plist`)]);for(let J of Z){if(!await o0.exists(J))continue;Jw.info("reading macOS managed preferences",{path:J});let Y=await f1.run(["plutil","-convert","json","-o","-",J],{nothrow:!0});if(Y.code!==0){Jw.warn("failed to convert managed preferences plist",{path:J});continue}return{source:`mobileconfig:${J}`,text:Qw(Y.stdout.toString())}}return}var SZ=E0.create({service:"config"}),Gw=["node_modules","package.json","package-lock.json","bun.lock",".gitignore","/plans/"],dr=T.fn("Config.ensureGitignore")(function*($){let Z=yield*D$.Service,J=fZ.join($,".gitignore");if(!(yield*Z.existsSafe(J))){yield*Z.writeFileString(J,Gw.join(`
489
- `)+`
490
- `).pipe(T.catchIf((V)=>V.reason?._tag==="PermissionDenied",()=>T.void));return}let X=yield*Z.readFileString(J),Q=new Set(X.split(`
491
- `).map((V)=>V.trim())),G=Gw.filter((V)=>!Q.has(V));if(G.length===0)return;let W=!X.endsWith(`
492
- `),K=X+(W?`
493
- `:"")+G.join(`
494
- `)+`
495
- `;yield*Z.writeFileString(J,K).pipe(T.catchIf((V)=>V.reason?._tag==="PermissionDenied",()=>T.void))});function Vw($){let{fs:Z,authSvc:J,accountSvc:Y,env:X,npmSvc:Q,readConfigFile:G,loadConfig:W,loadFile:K,getGlobal:V}=$;return{loadInstanceState:T.fn("Config.loadInstanceState")(function*(H){let B=yield*J.all().pipe(T.orDie),z={},F=new Set,A,j=T.fnUntraced(function*(w){if(w.startsWith("http://")||w.startsWith("https://"))return"global";if(w==="QITQODE_CONFIG_CONTENT")return"local";if(yield*Ww.use((I)=>T.succeed(S8.containsPath(w,I))))return"local";return"global"}),N=PN({info:$.info,readConfigFile:G,resolvePluginScope:j});for(let[w,I]of Object.entries(B))if(I.type==="wellknown"){let _=w.replace(/\/+$/,"");process.env[I.key]=I.token,SZ.debug("fetching remote config",{url:`${_}/.well-known/opencode`});let E=yield*T.promise(()=>fetch(`${_}/.well-known/opencode`,{signal:AbortSignal.timeout(1000)}));if(!E.ok)throw Error(`failed to fetch remote config from ${_}: ${E.status}`);let b=(yield*T.promise(()=>E.json())).config??{};if(!b.$schema)b.$schema="https://opencode.ai/config.json";let y=`${_}/.well-known/opencode`,k=yield*W(JSON.stringify(b),{dir:fZ.dirname(y),source:y});z=yield*N.merge(z,y,k,"global"),SZ.debug("loaded remote config from well-known",{url:_})}let L=yield*V();if(z=yield*N.merge(z,F0.Path.config,L,"global"),b0.QITQODE_CONFIG)z=yield*N.merge(z,b0.QITQODE_CONFIG,yield*K(b0.QITQODE_CONFIG)),SZ.debug("loaded custom config",{path:b0.QITQODE_CONFIG});if(!b0.QITQODE_DISABLE_PROJECT_CONFIG)for(let w of yield*JX.files("qitqode",H.directory,H.worktree).pipe(T.orDie))z=yield*N.merge(z,w,yield*K(w),"local");z.agent=z.agent||{},z.mode=z.mode||{},z.plugin=z.plugin||[];let q=yield*JX.directories(H.directory,H.worktree);if(b0.QITQODE_CONFIG_DIR)SZ.debug("loading config from QITQODE_CONFIG_DIR",{path:b0.QITQODE_CONFIG_DIR});let M=[];for(let w of yield*JX.claudeCommandDirectories(H.directory,H.worktree))z.command=N1(z.command??{},yield*T.promise(()=>i6.load(w)));for(let w of q){if(w.endsWith(".qitqode")||w===b0.QITQODE_CONFIG_DIR)for(let E of["qitqode.json","qitqode.jsonc"]){let f=fZ.join(w,E);SZ.debug(`loading config from ${f}`),z=yield*N.merge(z,f,yield*K(f)),z.agent??={},z.mode??={},z.plugin??=[]}yield*dr(w).pipe(T.orDie);let I=yield*Kw.install({fs:Z,npm:Q,dir:w}).pipe(T.exit,T.tap((E)=>B9.isFailure(E)?T.sync(()=>{SZ.warn("background dependency install failed",{dir:w,error:String(E.cause)})}):T.void),T.asVoid,T.forkDetach);M.push(I),z.command=N1(z.command??{},yield*T.promise(()=>i6.load(w))),z.agent=N1(z.agent??{},yield*T.promise(()=>c6.load(w))),z.agent=N1(z.agent??{},yield*T.promise(()=>c6.loadMode(w)));let _=yield*T.promise(()=>s8.load(w));z=yield*N.mergePluginOrigins(z,w,_)}if(process.env.QITQODE_CONFIG_CONTENT){let I=yield*W(process.env.QITQODE_CONFIG_CONTENT,{dir:H.directory,source:"QITQODE_CONFIG_CONTENT"});z=yield*N.merge(z,"QITQODE_CONFIG_CONTENT",I,"local"),SZ.debug("loaded custom config from QITQODE_CONFIG_CONTENT")}let C=O1.getOrUndefined(yield*Y.active().pipe(T.catch(()=>T.succeed(O1.none()))));if(C?.active_org_id){let{id:w,active_org_id:I,url:_}=C;yield*T.gen(function*(){let[E,f]=yield*T.all([Y.config(w,I),Y.token(w)],{concurrency:2});if(O1.isSome(f))process.env.QITQODE_CONSOLE_TOKEN=f.value,yield*X.set("QITQODE_CONSOLE_TOKEN",f.value);if(O1.isSome(E)){let b=`${_}/api/config`,y=yield*W(JSON.stringify(E.value),{dir:fZ.dirname(b),source:b});for(let k of Object.keys(y.provider??{}))F.add(k);z=yield*N.merge(z,b,y,"global")}}).pipe(T.withSpan("Config.loadActiveOrgConfig"),T.catch((E)=>{return SZ.debug("failed to fetch remote account config",{error:E instanceof Error?E.message:String(E)}),T.void}))}for(let w of R5.managedConfigDirs()){if(!(yield*T.promise(()=>o0.exists(w))))continue;for(let I of["qitqode.json","qitqode.jsonc"]){let _=fZ.join(w,I);z=yield*N.merge(z,_,yield*K(_),"global")}}let R=yield*T.promise(()=>R5.readManagedPreferences());if(R){let w=yield*W(R.text,{dir:fZ.dirname(R.source),source:R.source});z=N.mergeMcpOrigins(m9(z,w),R.source,w,"qitqode")}if(!b0.QITQODE_DISABLE_CLAUDE_CODE_MCP)z=yield*N.mergeClaudeMcp(z,fZ.join(F0.Path.home,".claude.json")),z=yield*N.mergeClaudeMcp(z,fZ.join(H.directory,".claude.json"));return z=IN(z,{username:lr.userInfo().username,permissionOverride:b0.QITQODE_PERMISSION,disableAutoCompact:b0.QITQODE_DISABLE_AUTOCOMPACT,disablePrune:b0.QITQODE_DISABLE_PRUNE}),{config:z,directories:q,deps:M,consoleState:{consoleManagedProviders:Array.from(F),activeOrgName:A,switchableOrgCount:0}}},T.provideService(D$.Service,Z))}}var P5={};F1(P5,{Layout:()=>pr,ConfigLayout:()=>P5});var pr=O.Literals(["auto","stretch"]).annotate({identifier:"LayoutConfig"}).pipe(u0(($)=>({zod:w0($)})));var I5={};F1(I5,{Server:()=>Uw,ConfigServer:()=>I5});class Uw extends O.Class("ServerConfig")({port:O.optional(O.Number.check(O.isInt()).check(O.isGreaterThan(0))).annotate({description:"Port to listen on"}),hostname:O.optional(O.String).annotate({description:"Hostname to listen on"}),mdns:O.optional(O.Boolean).annotate({description:"Enable mDNS service discovery"}),mdnsDomain:O.optional(O.String).annotate({description:"Custom domain name for mDNS service (default: qitqode.local)"}),cors:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Additional domains to allow for CORS"})}){static zod=w0(this)}var QJ={};F1(QJ,{Info:()=>cr,Entry:()=>Hw,ConfigFormatter:()=>QJ});var Hw=O.Struct({disabled:O.optional(O.Boolean),command:O.optional(O.mutable(O.Array(O.String))),environment:O.optional(O.Record(O.String,O.String)),extensions:O.optional(O.mutable(O.Array(O.String)))}).pipe(u0(($)=>({zod:w0($)}))),cr=O.Union([O.Boolean,O.Record(O.String,Hw)]).pipe(u0(($)=>({zod:w0($)})));var YX={};F1(YX,{Kind:()=>Bw,Info:()=>ir,ConfigHistory:()=>YX});var Bw=O.Literals(["user_text","assistant_text","tool_input","tool_error","reasoning","tool_output"]),ir=O.Struct({kinds:O.optional(O.Array(Bw)).annotate({description:"Which part kinds the history FTS index should cover. Defaults to text (user/assistant) + tool input + tool errors. Add 'reasoning' or 'tool_output' to grow recall at the cost of database size. Note: enabling 'tool_output' reclassifies completed tools from kind='tool_input' to kind='tool_output' (input remains searchable in the body, but kind:['tool_input'] filter will then only match pending/error tools)."})});var GJ={};F1(GJ,{requiresExtensionsForCustomServers:()=>Aw,Info:()=>nr,Entry:()=>Fw,Disabled:()=>zw,ConfigLSP:()=>GJ});var zw=O.Struct({disabled:O.Literal(!0)}).pipe(u0(($)=>({zod:w0($)}))),Fw=O.Union([zw,O.Struct({command:O.mutable(O.Array(O.String)),extensions:O.optional(O.mutable(O.Array(O.String))),disabled:O.optional(O.Boolean),env:O.optional(O.Record(O.String,O.String)),initialization:O.optional(O.Record(O.String,O.Unknown))})]).pipe(u0(($)=>({zod:w0($)}))),Aw=O.makeFilter(($)=>{if(typeof $==="boolean")return;let Z=new Set(Object.values(f7).map((Y)=>Y.id));return Object.entries($).every(([Y,X])=>{if("disabled"in X&&X.disabled)return!0;if(Z.has(Y))return!0;return"extensions"in X&&Boolean(X.extensions)})?void 0:"For custom LSP servers, 'extensions' array is required."}),nr=O.Union([O.Boolean,O.Record(O.String,Fw)]).check(Aw).pipe(u0(($)=>({zod:w0($)})));var WJ={};F1(WJ,{Model:()=>qw,Info:()=>jw,ConfigProvider:()=>WJ});var Ow=O.Number.check(O.isInt()).check(O.isGreaterThan(0)),qw=O.Struct({id:O.optional(O.String),name:O.optional(O.String),family:O.optional(O.String),release_date:O.optional(O.String),attachment:O.optional(O.Boolean),reasoning:O.optional(O.Boolean),temperature:O.optional(O.Boolean),tool_call:O.optional(O.Boolean),interleaved:O.optional(O.Union([O.Literal(!0),O.Struct({field:O.Literals(["reasoning_content","reasoning_details"])})])),cost:O.optional(O.Struct({input:O.Number,output:O.Number,cache_read:O.optional(O.Number),cache_write:O.optional(O.Number),context_over_200k:O.optional(O.Struct({input:O.Number,output:O.Number,cache_read:O.optional(O.Number),cache_write:O.optional(O.Number)}))})),limit:O.optional(O.Struct({context:O.Number,input:O.optional(O.Number),output:O.Number})),modalities:O.optional(O.Struct({input:O.mutable(O.Array(O.Literals(["text","audio","image","video","pdf"]))),output:O.mutable(O.Array(O.Literals(["text","audio","image","video","pdf"])))})),experimental:O.optional(O.Boolean),status:O.optional(O.Literals(["alpha","beta","deprecated"])),cachePromptTTL:O.optional(O.Literals(["5m","1h"])).annotate({description:"Prompt-cache breakpoint TTL for Anthropic/OpenRouter. '1h' keeps the cached prefix alive for one hour (2x write cost) instead of the 5m default. Ignored by providers whose SDK doesn't support a cache TTL."}),provider:O.optional(O.Struct({npm:O.optional(O.String),api:O.optional(O.String)})),options:O.optional(O.Record(O.String,O.Any)),headers:O.optional(O.Record(O.String,O.String)),variants:O.optional(O.Record(O.String,O.StructWithRest(O.Struct({disabled:O.optional(O.Boolean).annotate({description:"Disable this variant for the model"})}),[O.Record(O.String,O.Any)])).annotate({description:"Variant-specific configuration"}))}).pipe(u0(($)=>({zod:w0($)})));class jw extends O.Class("ProviderConfig")({api:O.optional(O.String),name:O.optional(O.String),env:O.optional(O.mutable(O.Array(O.String))),id:O.optional(O.String),npm:O.optional(O.String),whitelist:O.optional(O.mutable(O.Array(O.String))),blacklist:O.optional(O.mutable(O.Array(O.String))),options:O.optional(O.StructWithRest(O.Struct({apiKey:O.optional(O.String),baseURL:O.optional(O.String),enterpriseUrl:O.optional(O.String).annotate({description:"GitHub Enterprise URL for copilot authentication"}),setCacheKey:O.optional(O.Boolean).annotate({description:"Enable promptCacheKey for this provider (default false)"}),timeout:O.optional(O.Union([Ow,O.Literal(!1)]).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."})).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."}),chunkTimeout:O.optional(Ow).annotate({description:"Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted."})}),[O.Record(O.String,O.Any)])),models:O.optional(O.Record(O.String,qw))}){static zod=w0(this)}var KJ={};F1(KJ,{Info:()=>or,ConfigSkills:()=>KJ});var or=O.Struct({paths:O.optional(O.Array(O.String)).annotate({description:"Additional paths to skill folders"}),urls:O.optional(O.Array(O.String)).annotate({description:"URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)"})}).pipe(u0(($)=>({zod:w0($)})));var a8=O.Any.annotate({[F$]:c6.Info}),sr=O.Any.annotate({[F$]:_Z.Info}),rr=O.Any.annotate({[F$]:E0.Level}),m$=O.Number.check(O.isInt()).check(O.isGreaterThan(0)),C5=O.Number.check(O.isInt()).check(O.isGreaterThanOrEqualTo(0)),ar=O.Struct({$schema:O.optional(O.String).annotate({description:"JSON schema reference for configuration validation"}),logLevel:O.optional(rr).annotate({description:"Log level"}),server:O.optional(I5.Server).annotate({description:"Server configuration for qitqode serve and web commands"}),command:O.optional(O.Record(O.String,i6.Info)).annotate({description:"Command configuration, see https://opencode.ai/docs/commands"}),skills:O.optional(KJ.Info).annotate({description:"Additional skill folder paths"}),watcher:O.optional(O.Struct({ignore:O.optional(O.mutable(O.Array(O.String)))})),snapshot:O.optional(O.Boolean).annotate({description:"Enable or disable snapshot tracking. When false, filesystem snapshots are not recorded and undoing or reverting will not undo/redo file changes. Defaults to true."}),plugin:O.optional(O.mutable(O.Array(s8.Spec))),share:O.optional(O.Literals(["manual","auto","disabled"])).annotate({description:"Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing"}),autoshare:O.optional(O.Boolean).annotate({description:"@deprecated Use 'share' field instead. Share newly created sessions automatically"}),autoupdate:O.optional(O.Union([O.Boolean,O.Literal("notify")])).annotate({description:"Update behavior. Defaults to notifications only; set true to auto-install patch updates, false to disable checks, or 'notify' to show notifications"}),disabled_providers:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Disable providers that are loaded automatically"}),enabled_providers:O.optional(O.mutable(O.Array(O.String))).annotate({description:"When set, ONLY these providers will be enabled. All other providers will be ignored"}),model:O.optional(T8).annotate({description:"Model to use in the format of provider/model, eg anthropic/claude-2"}),small_model:O.optional(T8).annotate({description:"Small model to use for tasks like title generation in the format of provider/model"}),model_groups:O.optional(O.Record(O.String,O.Union([T8,O.Struct({default:T8,models:O.optional(O.mutable(O.Array(T8)))})]))).annotate({description:"Named model groups (capability tiers, e.g. fast/economical/default/power). Each group has a default model and optional member models. A group name can be used anywhere a provider/model string is accepted."}),default_agent:O.optional(O.String).annotate({description:"Default agent to use when none is specified. Must be a primary agent. Falls back to 'build' if not set or if the specified agent is invalid."}),username:O.optional(O.String).annotate({description:"Custom username to display in conversations instead of system username"}),mode:O.optional(O.StructWithRest(O.Struct({build:O.optional(a8),plan:O.optional(a8)}),[O.Record(O.String,a8)])).annotate({description:"@deprecated Use `agent` field instead."}),agent:O.optional(O.StructWithRest(O.Struct({plan:O.optional(a8),build:O.optional(a8),general:O.optional(a8),explore:O.optional(a8),title:O.optional(a8),summary:O.optional(a8),compaction:O.optional(a8)}),[O.Record(O.String,a8)])).annotate({description:"Agent configuration, see https://opencode.ai/docs/agents"}),provider:O.optional(O.Record(O.String,WJ.Info)).annotate({description:"Custom provider configurations and model overrides"}),mcp:O.optional(O.Record(O.String,O.Union([IZ.Info,O.Any.annotate({[F$]:P.object({enabled:P.boolean()}).strict()})]))).annotate({description:"MCP (Model Context Protocol) server configurations"}),formatter:O.optional(QJ.Info),lsp:O.optional(GJ.Info),instructions:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Additional instruction files or patterns to include"}),layout:O.optional(P5.Layout).annotate({description:"@deprecated Always uses stretch layout."}),permission:O.optional(sr),tools:O.optional(O.Record(O.String,O.Boolean)),tool:O.optional(O.Struct({invocation_style:O.optional(O.Literals(["json","shell"])).annotate({description:"Default invocation style for all tools. 'json' (default) exposes the original Zod schema; 'shell' exposes a single `script` parameter and uses the tool's shell.parse mapping."}),invocation_style_by_tool:O.optional(O.Record(O.String,O.Literals(["json","shell"]))).annotate({description:"Per-tool override of invocation_style. Keys are tool IDs. A tool without a `shell` field falls back to JSON regardless of this setting."})})).annotate({description:"Tool invocation style configuration (JSON vs shell-style)."}),enterprise:O.optional(O.Struct({url:O.optional(O.String).annotate({description:"Enterprise URL"})})),compaction:O.optional(O.Struct({auto:O.optional(O.Boolean).annotate({description:"Enable automatic compaction when context is full (default: true)"}),prune:O.optional(O.Boolean).annotate({description:"Enable pruning of old tool outputs (default: true)"}),tail_turns:O.optional(C5).annotate({description:"Number of recent user turns, including their following assistant/tool responses, to keep verbatim during compaction (default: 2)"}),preserve_recent_tokens:O.optional(C5).annotate({description:"Maximum number of tokens from recent turns to preserve verbatim after compaction"}),reserved:O.optional(C5).annotate({description:"Token buffer for compaction. Leaves enough window to avoid overflow during compaction."})})),checkpoint:O.optional(O.Struct({thresholds:O.optional(O.Array(O.String)).annotate({description:'Context fill thresholds that trigger checkpoint writes. Strings may be percentages ("40%"), absolute tokens ("100K", "1.5M"), or mixed ("100K", "50%"). Each threshold must be <= window - 20K reserved. Default: ["40%", "60%", "80%"].'}),reserved:O.optional(C5).annotate({description:"Token buffer reserved for checkpoint operations. Default: 20000."}),max_writer_failures:O.optional(m$).annotate({description:"Maximum consecutive writer failures per session before checkpointing stops retrying until process restart. Default: 3."}),fork:O.optional(O.Boolean).annotate({description:"Whether to fork the parent agent's message prefix into the writer session for prefix-cache reuse. Requires provider cache-breakpoint support. Default: false."}),push_caps:O.optional(O.Struct({tasks_ledger:O.optional(m$).annotate({description:"Token cap for the tasks ledger section of rebuild context. Default: 2000."}),focus_task:O.optional(m$).annotate({description:"Token cap for the focus task body in rebuild context. Default: 4000."}),actor_ledger:O.optional(m$).annotate({description:"Token cap for the actor ledger section of rebuild context. Default: 500."}),memory_titles:O.optional(m$).annotate({description:"Token cap for memory titles in rebuild context. Default: 500."}),global:O.optional(m$).annotate({description:"Token cap for the global memory section (global/MEMORY.md) of rebuild context. Default: 6000."}),checkpoint:O.optional(m$).annotate({description:"Token cap for the session checkpoint section (checkpoint.md) of rebuild context. Default: 11000."}),memory:O.optional(m$).annotate({description:"Token cap for the project memory section (MEMORY.md) of rebuild context. Default: 10000."}),notes:O.optional(m$).annotate({description:"Token cap for the session notes (notes.md) of rebuild context. Default: 6000."}),design_decisions:O.optional(m$).annotate({description:"Token cap for \xA710 Design decisions section of checkpoint.md (writer-side budget validation). Default: 3000."}),open_notes:O.optional(m$).annotate({description:"Token cap for \xA711 Open notes section of checkpoint.md (writer-side budget validation). Default: 800."}),recent_user:O.optional(C5).annotate({description:"Token cap for the recent user input section (verbatim user messages from the live DB, FIFO eviction). Default: 16000. Set 0 to disable."}),recent_user_per_msg:O.optional(m$).annotate({description:"Per-message cap inside recent user input section; oversized messages get head/tail truncation with messageID elision marker. Default: 2000."})})).annotate({description:"Per-section token caps for rebuild context (renderRebuildContext). Each section is loaded up to its cap so the rebuild stays within a predictable budget."}),task_archive_days:O.optional(m$).annotate({description:"Number of days after task done/abandoned before it's filtered out of `list({include_archived: false})`. Rows are NOT deleted \u2014 see v9 for true GC. Default: 7."}),task_cleanup_days:O.optional(m$).annotate({description:"[deprecated] Alias for task_archive_days. Will be removed in v9."}),memory_reconcile_on_search:O.optional(O.Boolean).annotate({description:"Whether to reconcile memory state on search operations. Default: true."}),memory_search_score_floor:O.optional(O.Number).annotate({description:"Relative BM25 floor for memory.search (OR-joined query): keep results scoring >= this fraction of the top hit, dropping common-word-only noise. The #1 result is always kept. Default: 0.15. Set 0 to keep all matches."})})),memory:O.optional(O.Struct({cc_index:O.optional(O.Boolean).annotate({description:"Index Claude Code memory (~/.claude/projects/<slug>/memory) and expose under scope='cc'. Default: false. Note: when enabled, every qitqode agent (build/explore/subagents) can search these memories via the builtin `memory` tool \u2014 including CC's `type: user` (your role/preferences) and `type: feedback` (your guidance) categories. CC originally writes them for future CC sessions; flipping this on widens the consumer set to qitqode agents on the same machine. Leave disabled (default) if you don't want personal context recallable from a prompt-injection-vulnerable agent."})})),history:O.optional(YX.Info).annotate({description:"Trajectory (conversation history) FTS index configuration."}),dream:O.optional(O.Struct({auto:O.optional(O.Boolean).annotate({description:"Auto-trigger dream memory consolidation on new session start. Default: true."}),interval_days:O.optional(C5).annotate({description:"Minimum days between automatic dream runs. Set to 0 to trigger on every new session. Default: 7."})})),distill:O.optional(O.Struct({auto:O.optional(O.Boolean).annotate({description:"Auto-trigger distill workflow packaging on new session start. Default: true."}),interval_days:O.optional(C5).annotate({description:"Minimum days between automatic distill runs. Default: 30."})})),voice:O.optional(O.Struct({asr_model:O.optional(T8).annotate({description:"Model to use for voice ASR transcription in provider/model format, e.g. openai/whisper-1."}),control_model:O.optional(T8).annotate({description:"Model to use for voice control (multimodal) in provider/model format, e.g. openai/gpt-4o."})})).annotate({description:"Voice input provider and model configuration."}),experimental:O.optional(O.Struct({disable_paste_summary:O.optional(O.Boolean),batch_tool:O.optional(O.Boolean).annotate({description:"Enable the batch tool"}),openTelemetry:O.optional(O.Boolean).annotate({description:"Enable OpenTelemetry spans for AI SDK calls (using the 'experimental_telemetry' flag)"}),primary_tools:O.optional(O.mutable(O.Array(O.String))).annotate({description:"Tools that should only be available to primary agents."}),continue_loop_on_deny:O.optional(O.Boolean).annotate({description:"Continue the agent loop when a tool call is denied"}),mcp_timeout:O.optional(m$).annotate({description:"Timeout in milliseconds for model context protocol (MCP) requests"}),predict_next_prompt:O.optional(O.Boolean).annotate({description:"Predict the user's likely next prompt after each turn and show it as inline ghost text (Tab to accept). Enabled by default; set to false to disable."}),maxMode:O.optional(O.Struct({candidates:O.optional(m$).annotate({description:"Number of parallel reasoning candidates per step in max mode (default 5)."})})).annotate({description:"Max mode (experimental): the 'max' agent runs N parallel reasoning candidates each step, picks the best via a judge call, and executes only the winner."})})),workflow:O.optional(O.Struct({maxConcurrentAgents:O.optional(O.Number).annotate({description:"Process-wide ceiling on subagents running concurrently across ALL workflow runs (including nested children). Default min(16, 2x CPU cores). No upper clamp: the previous 2x-cores hard cap was removed so an operator can match real provider capacity \u2014 but that also means a misconfigured value (e.g. an extra zero) can exhaust provider rate limits or host memory. This is the only concurrency ceiling, so set it deliberately."}),maxDepth:O.optional(O.Number).annotate({description:"Max nesting depth for workflow()-calls-workflow. Default 8. Exceeding it fails the run."}),maxLifecycleAgents:O.optional(O.Number).annotate({description:"Hard ceiling on total agents a single workflow run may spawn over its life. Default 1000. Over-cap agent() calls return null (graceful degradation). PER-RUN, not tree-wide: each child workflow has its own independent budget, so a deep nesting can spawn maxDepth \xD7 this over the whole tree (concurrent in-flight is still bounded by maxConcurrentAgents)."}),scriptDeadlineMs:O.optional(O.Number).annotate({description:"Wall-clock budget for a whole workflow script, in milliseconds. Default 12h. The sandbox interrupt handler enforces this as a hard kill-switch."})})).annotate({description:"Dynamic workflow runtime settings."})}),E5=w0(ar).strict().meta({ref:"Config"});var er=E0.create({service:"config"}),$a=I5.Server.zod,Za=P5.Layout.zod;class Z4 extends S1.Service()("@qitqode/Config"){}var Ja=j1.create("ConfigDirectoryTypoError",P.object({path:P.string(),dir:P.string(),suggestion:P.string()})),Dw=T0.effect(Z4,T.gen(function*(){let $=yield*D$.Service,Z=yield*k8.Service,J=yield*o7.Service,Y=yield*l6.Service,X=yield*q6.Service,{readConfigFile:Q,loadConfig:G,loadFile:W}=MN({fs:$,info:E5}),K=wN(W),[V,U]=yield*T.cachedInvalidateWithTTL(K().pipe(T.tapError((C)=>T.sync(()=>er.error("failed to load global config, using defaults",{error:String(C)}))),T.orElseSucceed(()=>({}))),Z8.infinity),H=T.fn("Config.getGlobal")(function*(){return yield*V}),{loadInstanceState:B}=Vw({fs:$,authSvc:Z,accountSvc:J,env:Y,npmSvc:X,info:E5,readConfigFile:Q,loadConfig:G,loadFile:W,getGlobal:H}),z=yield*B0.make(T.fn("Config.state")(function*(C){return yield*B(C).pipe(T.orDie)})),F=T.fn("Config.get")(function*(){return yield*B0.use(z,(C)=>C.config)}),A=T.fn("Config.directories")(function*(){return yield*B0.use(z,(C)=>C.directories)}),j=T.fn("Config.getConsoleState")(function*(){return yield*B0.use(z,(C)=>C.consoleState)}),N=T.fn("Config.waitForDependencies")(function*(){yield*B0.useEffect(z,(C)=>T.forEach(C.deps,Nw.join,{concurrency:"unbounded"}).pipe(T.asVoid))}),L=T.fn("Config.update")(function*(C){let R=yield*B0.directory,w=tr.join(R,"config.json"),I=yield*W(w);yield*$.writeFileString(w,JSON.stringify(N1(s7(I),s7(C)),null,2)).pipe(T.orDie),yield*T.promise(()=>S8.dispose())}),q=T.fn("Config.invalidate")(function*(C){yield*U;let R=S8.disposeAll().catch(()=>{return}).finally(()=>L7.emit("event",{directory:"global",payload:{type:JN.Disposed.type,properties:{}}}));if(C)yield*T.promise(()=>R)}),M=T.fn("Config.updateGlobal")(function*(C){let R=yield*T.promise(()=>qN()),w=(yield*Q(R))??"{}",I;if(!R.endsWith(".jsonc")){let _=r8.schema(E5,r8.jsonc(w,R),R),E=N1(s7(_),s7(C));yield*$.writeFileString(R,JSON.stringify(E,null,2)).pipe(T.orDie),I=E}else{let _=eV(w,s7(C));I=r8.schema(E5,r8.jsonc(_,R),R),yield*$.writeFileString(R,_).pipe(T.orDie)}return yield*q(),I});return Z4.of({get:F,getGlobal:H,getConsoleState:j,update:L,updateGlobal:M,invalidate:q,directories:A,waitForDependencies:N})})),Ya=Dw.pipe(T0.provide(Mw.defaultLayer),T0.provide(D$.defaultLayer),T0.provide(l6.defaultLayer),T0.provide(k8.defaultLayer),T0.provide(o7.defaultLayer),T0.provide(q6.defaultLayer));var XX={};F1(XX,{report:()=>Xa,pretty:()=>Lw,Diagnostic:()=>XX});var ww=20;function Lw($){let J={1:"ERROR",2:"WARN",3:"INFO",4:"HINT"}[$.severity||1],Y=$.range.start.line+1,X=$.range.start.character+1;return`${J} [${Y}:${X}] ${$.message}`}function Xa($,Z){let J=Z.filter((G)=>G.severity===1);if(J.length===0)return"";let Y=J.slice(0,ww),X=J.length-ww,Q=X>0?`
496
- ... and ${X} more`:"";return`<diagnostics file="${$}">
497
- ${Y.map(Lw).join(`
498
- `)}${Q}
499
- </diagnostics>`}var n6=E0.create({service:"lsp"}),Pw={Updated:L1.define("lsp.updated",P.object({}))},J4=P.object({start:P.object({line:P.number(),character:P.number()}),end:P.object({line:P.number(),character:P.number()})}).meta({ref:"Range"}),Ga=P.object({name:P.string(),kind:P.number(),location:P.object({uri:P.string(),range:J4})}).meta({ref:"Symbol"}),Wa=P.object({name:P.string(),detail:P.string().optional(),kind:P.number(),range:J4,selectionRange:J4}).meta({ref:"DocumentSymbol"}),Ka=P.object({id:P.string(),name:P.string(),root:P.string(),status:P.union([P.literal("connected"),P.literal("error")])}).meta({ref:"LSPStatus"});var Va=[5,12,6,11,13,14,23,10],Ua=($)=>{if(b0.QITQODE_EXPERIMENTAL_LSP_TY){if($.pyright)n6.info("LSP server pyright is disabled because QITQODE_EXPERIMENTAL_LSP_TY is enabled"),delete $.pyright}else if($.ty)delete $.ty};class Y4 extends S1.Service()("@qitqode/LSP"){}var Iw=T0.effect(Y4,T.gen(function*(){let $=yield*X8.Service,Z=yield*B0.make(T.fn("LSP.state")(function*(R){let w=yield*$.get(),I={};if(!w.lsp)n6.info("all LSPs are disabled");else{for(let E of Object.values(f7))I[E.id]=E;if(Ua(I),w.lsp!==!0)for(let[E,f]of Object.entries(w.lsp)){let b=I[E];if(f.disabled){n6.info(`LSP server ${E} is disabled`),delete I[E];continue}I[E]={...b,id:E,root:b?.root??(async(y,k)=>k.directory),extensions:f.extensions??b?.extensions??[],spawn:async(y)=>({process:Z1(f.command[0],f.command.slice(1),{cwd:y,env:{...n8(),...f.env}}),initialization:f.initialization})}}n6.info("enabled LSP servers",{serverIds:Object.values(I).map((E)=>E.id).join(", ")})}let _={clients:[],servers:I,broken:new Set,spawning:new Map};return yield*T.addFinalizer(()=>T.promise(async()=>{await Promise.all(_.clients.map((E)=>E.shutdown()))})),_}));async function J(R,w,I,_=!1){let E=Tw.parse(R).ext||R,f=[];for(let b of Object.values(I.servers)){if(b.extensions.length&&!b.extensions.includes(E))continue;let y=await b.root(R,w);if(!y)continue;if(I.broken.has(y+b.id))continue;if(f.push({server:b,root:y}),_)break}return f}let Y=T.fnUntraced(function*(R){let w=yield*B0.context;if(!D$.contains(w.directory,R)&&(w.worktree==="/"||!D$.contains(w.worktree,R)))return[];let I=yield*B0.get(Z);return yield*T.promise(async()=>{let _=[];async function E(f,b,y){let k=await f.spawn(b,w).then((p)=>{if(!p)I.broken.add(y);return p}).catch((p)=>{I.broken.add(y),n6.error(`Failed to spawn LSP server ${f.id}`,{error:p});return});if(!k)return;n6.info("spawned lsp server",{serverID:f.id,root:b});let g=await Hj({serverID:f.id,server:k,root:b,directory:w.directory}).catch(async(p)=>{I.broken.add(y),await f1.stop(k.process),n6.error(`Failed to initialize LSP client ${f.id}`,{error:p});return});if(!g)return;let d=I.clients.find((p)=>p.root===b&&p.serverID===f.id);if(d)return await f1.stop(k.process),d;return I.clients.push(g),g}for(let{server:f,root:b}of await J(R,w,I)){let y=I.clients.find((p)=>p.root===b&&p.serverID===f.id);if(y){_.push(y);continue}let k=I.spawning.get(b+f.id);if(k){let p=await k;if(!p)continue;_.push(p);continue}let g=E(f,b,b+f.id);I.spawning.set(b+f.id,g),g.finally(()=>{if(I.spawning.get(b+f.id)===g)I.spawning.delete(b+f.id)});let d=await g;if(!d)continue;_.push(d),l1.publish(Pw.Updated,{})}return _})}),X=T.fnUntraced(function*(R,w){let I=yield*Y(R);return yield*T.promise(()=>Promise.all(I.map((_)=>w(_))))}),Q=T.fnUntraced(function*(R){let w=yield*B0.get(Z);return yield*T.promise(()=>Promise.all(w.clients.map((I)=>R(I))))}),G=T.fn("LSP.init")(function*(){yield*B0.get(Z)}),W=T.fn("LSP.status")(function*(){let R=yield*B0.context,w=yield*B0.get(Z),I=[];for(let _ of w.clients)I.push({id:_.serverID,name:w.servers[_.serverID].id,root:Tw.relative(R.directory,_.root),status:"connected"});return I}),K=T.fn("LSP.hasClients")(function*(R){let w=yield*B0.context,I=yield*B0.get(Z);return yield*T.promise(async()=>{return(await J(R,w,I,!0)).length>0})}),V=T.fn("LSP.touchFile")(function*(R,w){n6.info("touching file",{file:R});let I=yield*Y(R);yield*T.promise(()=>Promise.all(I.map(async(_)=>{let E=w?_.waitForDiagnostics({path:R}):Promise.resolve();return await _.notify.open({path:R}),E})).catch((_)=>{n6.error("failed to touch file",{err:_,file:R})}))}),U=T.fn("LSP.diagnostics")(function*(){let R={},w=yield*Q(async(I)=>I.diagnostics);for(let I of w)for(let[_,E]of I.entries()){let f=R[_]||[];f.push(...E),R[_]=f}return R}),H=T.fnUntraced(function*(R,w,I,_){return yield*X(R.file,(E)=>E.connection.sendRequest(w,{textDocument:{uri:Rw(R.file).href},position:{line:R.line,character:R.character},..._}).catch(()=>I))}),B=T.fn("LSP.hover")(function*(R){return yield*H(R,"textDocument/hover",null)}),z=T.fn("LSP.definition")(function*(R){return(yield*H(R,"textDocument/definition",null)).flat().filter(Boolean)}),F=T.fn("LSP.references")(function*(R){return(yield*H(R,"textDocument/references",[],{context:{includeDeclaration:!0}})).flat().filter(Boolean)}),A=T.fn("LSP.implementation")(function*(R){return(yield*H(R,"textDocument/implementation",null)).flat().filter(Boolean)}),j=T.fn("LSP.documentSymbol")(function*(R){let w=Qa(R);return(yield*X(w,(_)=>_.connection.sendRequest("textDocument/documentSymbol",{textDocument:{uri:R}}).catch(()=>[]))).flat().filter(Boolean)}),N=T.fn("LSP.workspaceSymbol")(function*(R){return(yield*Q((I)=>I.connection.sendRequest("workspace/symbol",{query:R}).then((_)=>_.filter((E)=>Va.includes(E.kind)).slice(0,10)).catch(()=>[]))).flat()}),L=T.fn("LSP.prepareCallHierarchy")(function*(R){return(yield*H(R,"textDocument/prepareCallHierarchy",[])).flat().filter(Boolean)}),q=T.fnUntraced(function*(R,w){return(yield*X(R.file,async(_)=>{let E=await _.connection.sendRequest("textDocument/prepareCallHierarchy",{textDocument:{uri:Rw(R.file).href},position:{line:R.line,character:R.character}}).catch(()=>[]);if(!E?.length)return[];return _.connection.sendRequest(w,{item:E[0]}).catch(()=>[])})).flat().filter(Boolean)}),M=T.fn("LSP.incomingCalls")(function*(R){return yield*q(R,"callHierarchy/incomingCalls")}),C=T.fn("LSP.outgoingCalls")(function*(R){return yield*q(R,"callHierarchy/outgoingCalls")});return Y4.of({init:G,status:W,hasClients:K,touchFile:V,diagnostics:U,hover:B,definition:z,references:F,implementation:A,documentSymbol:j,workspaceSymbol:N,prepareCallHierarchy:L,incomingCalls:M,outgoingCalls:C})})),Ha=Iw.pipe(T0.provide(X8.defaultLayer));var vZ={};F1(vZ,{layer:()=>mw,defaultLayer:()=>Ma,Snapshot:()=>vZ,Service:()=>K4,Patch:()=>qa,FileDiff:()=>ja});class Q4{diff($,Z,J={}){let Y;if(typeof J==="function")Y=J,J={};else if("callback"in J)Y=J.callback;let X=this.castInput($,J),Q=this.castInput(Z,J),G=this.removeEmpty(this.tokenize(X,J)),W=this.removeEmpty(this.tokenize(Q,J));return this.diffWithOptionsObj(G,W,J,Y)}diffWithOptionsObj($,Z,J,Y){var X;let Q=(N)=>{if(N=this.postProcess(N,J),Y){setTimeout(function(){Y(N)},0);return}else return N},G=Z.length,W=$.length,K=1,V=G+W;if(J.maxEditLength!=null)V=Math.min(V,J.maxEditLength);let U=(X=J.timeout)!==null&&X!==void 0?X:1/0,H=Date.now()+U,B=[{oldPos:-1,lastComponent:void 0}],z=this.extractCommon(B[0],Z,$,0,J);if(B[0].oldPos+1>=W&&z+1>=G)return Q(this.buildValues(B[0].lastComponent,Z,$));let F=-1/0,A=1/0,j=()=>{for(let N=Math.max(F,-K);N<=Math.min(A,K);N+=2){let L,q=B[N-1],M=B[N+1];if(q)B[N-1]=void 0;let C=!1;if(M){let w=M.oldPos-N;C=M&&0<=w&&w<G}let R=q&&q.oldPos+1<W;if(!C&&!R){B[N]=void 0;continue}if(!R||C&&q.oldPos<M.oldPos)L=this.addToPath(M,!0,!1,0,J);else L=this.addToPath(q,!1,!0,1,J);if(z=this.extractCommon(L,Z,$,N,J),L.oldPos+1>=W&&z+1>=G)return Q(this.buildValues(L.lastComponent,Z,$))||!0;else{if(B[N]=L,L.oldPos+1>=W)A=Math.min(A,N-1);if(z+1>=G)F=Math.max(F,N+1)}}K++};if(Y)(function N(){setTimeout(function(){if(K>V||Date.now()>H)return Y(void 0);if(!j())N()},0)})();else while(K<=V&&Date.now()<=H){let N=j();if(N)return N}}addToPath($,Z,J,Y,X){let Q=$.lastComponent;if(Q&&!X.oneChangePerToken&&Q.added===Z&&Q.removed===J)return{oldPos:$.oldPos+Y,lastComponent:{count:Q.count+1,added:Z,removed:J,previousComponent:Q.previousComponent}};else return{oldPos:$.oldPos+Y,lastComponent:{count:1,added:Z,removed:J,previousComponent:Q}}}extractCommon($,Z,J,Y,X){let Q=Z.length,G=J.length,W=$.oldPos,K=W-Y,V=0;while(K+1<Q&&W+1<G&&this.equals(J[W+1],Z[K+1],X))if(K++,W++,V++,X.oneChangePerToken)$.lastComponent={count:1,previousComponent:$.lastComponent,added:!1,removed:!1};if(V&&!X.oneChangePerToken)$.lastComponent={count:V,previousComponent:$.lastComponent,added:!1,removed:!1};return $.oldPos=W,K}equals($,Z,J){if(J.comparator)return J.comparator($,Z);else return $===Z||!!J.ignoreCase&&$.toLowerCase()===Z.toLowerCase()}removeEmpty($){let Z=[];for(let J=0;J<$.length;J++)if($[J])Z.push($[J]);return Z}castInput($,Z){return $}tokenize($,Z){return Array.from($)}join($){return $.join("")}postProcess($,Z){return $}get useLongestToken(){return!1}buildValues($,Z,J){let Y=[],X;while($)Y.push($),X=$.previousComponent,delete $.previousComponent,$=X;Y.reverse();let Q=Y.length,G=0,W=0,K=0;for(;G<Q;G++){let V=Y[G];if(!V.removed){if(!V.added&&this.useLongestToken){let U=Z.slice(W,W+V.count);U=U.map(function(H,B){let z=J[K+B];return z.length>H.length?z:H}),V.value=this.join(U)}else V.value=this.join(Z.slice(W,W+V.count));if(W+=V.count,!V.added)K+=V.count}else V.value=this.join(J.slice(K,K+V.count)),K+=V.count}return Y}}class Cw extends Q4{constructor(){super(...arguments);this.tokenize=Ba}equals($,Z,J){if(J.ignoreWhitespace){if(!J.newlineIsToken||!$.includes(`
500
- `))$=$.trim();if(!J.newlineIsToken||!Z.includes(`
501
- `))Z=Z.trim()}else if(J.ignoreNewlineAtEof&&!J.newlineIsToken){if($.endsWith(`
502
- `))$=$.slice(0,-1);if(Z.endsWith(`
503
- `))Z=Z.slice(0,-1)}return super.equals($,Z,J)}}var Ew=new Cw;function G4($,Z,J){return Ew.diff($,Z,J)}function Ba($,Z){if(Z.stripTrailingCr)$=$.replace(/\r\n/g,`
504
- `);let J=[],Y=$.split(/(\n|\r\n)/);if(!Y[Y.length-1])Y.pop();for(let X=0;X<Y.length;X++){let Q=Y[X];if(X%2&&!Z.newlineIsToken)J[J.length-1]+=Q;else J.push(Q)}return J}function bw($){return $.includes(`\r
505
- `)&&!$.startsWith(`
506
- `)&&!$.match(/[^\r]\n/)}function _w($){return!$.includes(`\r
507
- `)&&$.includes(`
508
- `)}function fU($){if(Array.isArray($))return $.map((Z)=>fU(Z));return Object.assign(Object.assign({},$),{hunks:$.hunks.map((Z)=>Object.assign(Object.assign({},Z),{lines:Z.lines.map((J,Y)=>{var X;return J.startsWith("\\")||J.endsWith("\r")||((X=Z.lines[Y+1])===null||X===void 0?void 0:X.startsWith("\\"))?J:J+"\r"})}))})}function kU($){if(Array.isArray($))return $.map((Z)=>kU(Z));return Object.assign(Object.assign({},$),{hunks:$.hunks.map((Z)=>Object.assign(Object.assign({},Z),{lines:Z.lines.map((J)=>J.endsWith("\r")?J.substring(0,J.length-1):J)}))})}function Sw($){if(!Array.isArray($))$=[$];return!$.some((Z)=>Z.hunks.some((J)=>J.lines.some((Y)=>!Y.startsWith("\\")&&Y.endsWith("\r"))))}function fw($){if(!Array.isArray($))$=[$];return $.some((Z)=>Z.hunks.some((J)=>J.lines.some((Y)=>Y.endsWith("\r"))))&&$.every((Z)=>Z.hunks.every((J)=>J.lines.every((Y,X)=>{var Q;return Y.startsWith("\\")||Y.endsWith("\r")||((Q=J.lines[X+1])===null||Q===void 0?void 0:Q.startsWith("\\"))})))}function vU($){let Z=$.split(/\n/),J=[],Y=0;function X(){let W={};J.push(W);while(Y<Z.length){let K=Z[Y];if(/^(---|\+\+\+|@@)\s/.test(K))break;let V=/^(?:Index:|diff(?: -r \w+)+)\s+/.exec(K);if(V)W.index=K.substring(V[0].length).trim();Y++}Q(W),Q(W),W.hunks=[];while(Y<Z.length){let K=Z[Y];if(/^(Index:\s|diff\s|---\s|\+\+\+\s|===================================================================)/.test(K))break;else if(/^@@/.test(K))W.hunks.push(G());else if(K)throw Error("Unknown line "+(Y+1)+" "+JSON.stringify(K));else Y++}}function Q(W){let K=/^(---|\+\+\+)\s+/.exec(Z[Y]);if(K){let V=K[1],U=Z[Y].substring(3).trim().split("\t",2),H=(U[1]||"").trim(),B=U[0].replace(/\\\\/g,"\\");if(B.startsWith('"')&&B.endsWith('"'))B=B.substr(1,B.length-2);if(V==="---")W.oldFileName=B,W.oldHeader=H;else W.newFileName=B,W.newHeader=H;Y++}}function G(){var W;let K=Y,V=Z[Y++],U=V.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/),H={oldStart:+U[1],oldLines:typeof U[2]>"u"?1:+U[2],newStart:+U[3],newLines:typeof U[4]>"u"?1:+U[4],lines:[]};if(H.oldLines===0)H.oldStart+=1;if(H.newLines===0)H.newStart+=1;let B=0,z=0;for(;Y<Z.length&&(z<H.oldLines||B<H.newLines||((W=Z[Y])===null||W===void 0?void 0:W.startsWith("\\")));Y++){let F=Z[Y].length==0&&Y!=Z.length-1?" ":Z[Y][0];if(F==="+"||F==="-"||F===" "||F==="\\"){if(H.lines.push(Z[Y]),F==="+")B++;else if(F==="-")z++;else if(F===" ")B++,z++}else throw Error(`Hunk at line ${K+1} contained invalid line ${Z[Y]}`)}if(!B&&H.newLines===1)H.newLines=0;if(!z&&H.oldLines===1)H.oldLines=0;if(B!==H.newLines)throw Error("Added line count did not match for hunk at line "+(K+1));if(z!==H.oldLines)throw Error("Removed line count did not match for hunk at line "+(K+1));return H}while(Y<Z.length)X();return J}function yU($,Z,J){let Y=!0,X=!1,Q=!1,G=1;return function W(){if(Y&&!Q){if(X)G++;else Y=!1;if($+G<=J)return $+G;Q=!0}if(!X){if(!Q)Y=!0;if(Z<=$-G)return $-G++;return X=!0,W()}return}}function za($,Z,J={}){let Y;if(typeof Z==="string")Y=vU(Z);else if(Array.isArray(Z))Y=Z;else Y=[Z];if(Y.length>1)throw Error("applyPatch only works with a single input.");return Fa($,Y[0],J)}function Fa($,Z,J={}){if(J.autoConvertLineEndings||J.autoConvertLineEndings==null){if(bw($)&&Sw(Z))Z=fU(Z);else if(_w($)&&fw(Z))Z=kU(Z)}let Y=$.split(`
509
- `),X=Z.hunks,Q=J.compareLine||((F,A,j,N)=>A===N),G=J.fuzzFactor||0,W=0;if(G<0||!Number.isInteger(G))throw Error("fuzzFactor must be a non-negative integer");if(!X.length)return $;let K="",V=!1,U=!1;for(let F=0;F<X[X.length-1].lines.length;F++){let A=X[X.length-1].lines[F];if(A[0]=="\\"){if(K[0]=="+")V=!0;else if(K[0]=="-")U=!0}K=A}if(V){if(U){if(!G&&Y[Y.length-1]=="")return!1}else if(Y[Y.length-1]=="")Y.pop();else if(!G)return!1}else if(U){if(Y[Y.length-1]!="")Y.push("");else if(!G)return!1}function H(F,A,j,N=0,L=!0,q=[],M=0){let C=0,R=!1;for(;N<F.length;N++){let w=F[N],I=w.length>0?w[0]:" ",_=w.length>0?w.substr(1):w;if(I==="-")if(Q(A+1,Y[A],I,_))A++,C=0;else{if(!j||Y[A]==null)return null;return q[M]=Y[A],H(F,A+1,j-1,N,!1,q,M+1)}if(I==="+"){if(!L)return null;q[M]=_,M++,C=0,R=!0}if(I===" ")if(C++,q[M]=Y[A],Q(A+1,Y[A],I,_))M++,L=!0,R=!1,A++;else{if(R||!j)return null;return Y[A]&&(H(F,A+1,j-1,N+1,!1,q,M+1)||H(F,A+1,j-1,N,!1,q,M+1))||H(F,A,j-1,N+1,!1,q,M)}}return M-=C,A-=C,q.length=M,{patchedLines:q,oldLineLastI:A-1}}let B=[],z=0;for(let F=0;F<X.length;F++){let A=X[F],j,N=Y.length-A.oldLines+G,L;for(let q=0;q<=G;q++){L=A.oldStart+z-1;let M=yU(L,W,N);for(;L!==void 0;L=M())if(j=H(A.lines,L,q),j)break;if(j)break}if(!j)return!1;for(let q=W;q<L;q++)B.push(Y[q]);for(let q=0;q<j.patchedLines.length;q++){let M=j.patchedLines[q];B.push(M)}W=j.oldLineLastI+1,z=L+1-A.oldStart}for(let F=W;F<Y.length;F++)B.push(Y[F]);return B.join(`
510
- `)}var kw={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function QX($,Z,J,Y,X,Q,G){let W;if(!G)W={};else if(typeof G==="function")W={callback:G};else W=G;if(typeof W.context>"u")W.context=4;let K=W.context;if(W.newlineIsToken)throw Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(!W.callback)return V(G4(J,Y,W));else{let{callback:U}=W;G4(J,Y,Object.assign(Object.assign({},W),{callback:(H)=>{let B=V(H);U(B)}}))}function V(U){if(!U)return;U.push({value:"",lines:[]});function H(L){return L.map(function(q){return" "+q})}let B=[],z=0,F=0,A=[],j=1,N=1;for(let L=0;L<U.length;L++){let q=U[L],M=q.lines||Oa(q.value);if(q.lines=M,q.added||q.removed){if(!z){let C=U[L-1];if(z=j,F=N,C)A=K>0?H(C.lines.slice(-K)):[],z-=A.length,F-=A.length}for(let C of M)A.push((q.added?"+":"-")+C);if(q.added)N+=M.length;else j+=M.length}else{if(z)if(M.length<=K*2&&L<U.length-2)for(let C of H(M))A.push(C);else{let C=Math.min(M.length,K);for(let w of H(M.slice(0,C)))A.push(w);let R={oldStart:z,oldLines:j-z+C,newStart:F,newLines:N-F+C,lines:A};B.push(R),z=0,F=0,A=[]}j+=M.length,N+=M.length}}for(let L of B)for(let q=0;q<L.lines.length;q++)if(L.lines[q].endsWith(`
511
- `))L.lines[q]=L.lines[q].slice(0,-1);else L.lines.splice(q+1,0,"\"),q++;return{oldFileName:$,newFileName:Z,oldHeader:X,newHeader:Q,hunks:B}}}function VJ($,Z){if(!Z)Z=kw;if(Array.isArray($)){if($.length>1&&!Z.includeFileHeaders)throw Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return $.map((Y)=>VJ(Y,Z)).join(`
512
- `)}let J=[];if(Z.includeIndex&&$.oldFileName==$.newFileName)J.push("Index: "+$.oldFileName);if(Z.includeUnderline)J.push("===================================================================");if(Z.includeFileHeaders)J.push("--- "+$.oldFileName+(typeof $.oldHeader>"u"?"":"\t"+$.oldHeader)),J.push("+++ "+$.newFileName+(typeof $.newHeader>"u"?"":"\t"+$.newHeader));for(let Y=0;Y<$.hunks.length;Y++){let X=$.hunks[Y];if(X.oldLines===0)X.oldStart-=1;if(X.newLines===0)X.newStart-=1;J.push("@@ -"+X.oldStart+","+X.oldLines+" +"+X.newStart+","+X.newLines+" @@");for(let Q of X.lines)J.push(Q)}return J.join(`
513
- `)+`
514
- `}function Aa($,Z,J,Y,X,Q,G){if(typeof G==="function")G={callback:G};if(!(G===null||G===void 0?void 0:G.callback)){let W=QX($,Z,J,Y,X,Q,G);if(!W)return;return VJ(W,G===null||G===void 0?void 0:G.headerOptions)}else{let{callback:W}=G;QX($,Z,J,Y,X,Q,Object.assign(Object.assign({},G),{callback:(K)=>{if(!K)W(void 0);else W(VJ(K,G.headerOptions))}}))}}function Oa($){let Z=$.endsWith(`
515
- `),J=$.split(`
516
- `).map((Y)=>Y+`
517
- `);if(Z)J.pop();else J.push(J.pop().slice(0,-1));return J}import b5 from"path";function vw($,Z){return $.pipe(T.catchCause(Z),T.repeat(W4.spaced(Z8.hours(1))),T.delay(Z8.minutes(1)),T.forkScoped)}var qa=P.object({hash:P.string(),files:P.string().array()}),ja=P.object({file:P.string(),patch:P.string(),additions:P.number(),deletions:P.number(),status:P.enum(["added","deleted","modified"]).optional()}).meta({ref:"SnapshotFileDiff"});var J$=E0.create({service:"snapshot"}),yw="7.days",Na=2097152,S5=["-c","core.longpaths=true","-c","core.symlinks=true"],kZ=["-c","core.autocrlf=false",...S5],_5=[...kZ,"-c","core.quotepath=false"];class K4 extends S1.Service()("@qitqode/Snapshot"){}var mw=T0.effect(K4,T.gen(function*(){let $=yield*D$.Service,Z=yield*xU.ChildProcessSpawner,J=yield*X8.Service,Y=new Map,X=(G)=>{let W=Y.get(G);if(W)return W;let K=hw.makeUnsafe(1);return Y.set(G,K),K},Q=yield*B0.make(T.fn("Snapshot.state")(function*(G){let W={directory:G.directory,worktree:G.worktree,gitdir:b5.join(F0.Path.data,"snapshot",G.project.id,V4.fast(G.worktree)),vcs:G.project.vcs},K=(k)=>["--git-dir",W.gitdir,"--work-tree",W.worktree,...k],V=new TextEncoder,U=(k)=>I$.make(V.encode(k.join("\x00")+"\x00")),H=T.fnUntraced(function*(k,g){let d=hU.make("git",k,{cwd:g?.cwd,env:g?.env,extendEnv:!0,stdin:g?.stdin});return yield*uw(Z,d)},T.catch((k)=>T.succeed({code:xU.ExitCode(1),text:"",stderr:k instanceof Error?k.message:String(k)}))),B=T.fnUntraced(function*(k){if(!k.length)return new Set;let g=yield*H([..._5,"--git-dir",b5.join(W.worktree,".git"),"--work-tree",W.worktree,"check-ignore","--no-index","--stdin","-z"],{cwd:W.directory,stdin:U(k)});if(g.code!==0&&g.code!==1)return new Set;return new Set(g.text.split("\x00").filter(Boolean))}),z=T.fnUntraced(function*(k){if(!k.length)return;yield*H([...kZ,...K(["rm","--cached","-f","--ignore-unmatch","--pathspec-from-file=-","--pathspec-file-nul"])],{cwd:W.directory,stdin:U(k)})}),F=T.fnUntraced(function*(k){if(!k.length)return;let g=yield*H([...kZ,...K(["add","--all","--sparse","--pathspec-from-file=-","--pathspec-file-nul"])],{cwd:W.directory,stdin:U(k)});if(g.code===0)return;J$.warn("failed to add snapshot files",{exitCode:g.code,stderr:g.stderr})}),A=(k)=>$.exists(k).pipe(T.orDie),j=(k)=>$.readFileString(k).pipe(T.catch(()=>T.succeed(""))),N=(k)=>$.remove(k).pipe(T.catch(()=>T.void)),L=(k)=>X(W.gitdir).withPermits(1)(k),q=T.fnUntraced(function*(){if(W.vcs!=="git")return!1;return(yield*J.get()).snapshot!==!1}),M=T.fnUntraced(function*(){let g=(yield*H(["rev-parse","--path-format=absolute","--git-path","info/exclude"],{cwd:W.worktree})).text.trim();if(!g)return;if(!(yield*A(g)))return;return g}),C=T.fnUntraced(function*(k=[]){let g=yield*M(),d=b5.join(W.gitdir,"info","exclude"),p=[g?(yield*j(g)).trimEnd():"",...k.map((t)=>`/${t.replaceAll("\\","/")}`)].filter(Boolean).join(`
518
- `);yield*$.ensureDir(b5.join(W.gitdir,"info")).pipe(T.orDie),yield*$.writeFileString(d,p?`${p}
519
- `:"").pipe(T.orDie)}),R=T.fnUntraced(function*(){yield*C();let[k,g]=yield*T.all([H([..._5,...K(["diff-files","--name-only","-z","--","."])],{cwd:W.directory}),H([..._5,...K(["ls-files","--others","--exclude-standard","-z","--","."])],{cwd:W.directory})],{concurrency:2});if(k.code!==0||g.code!==0){J$.warn("failed to list snapshot files",{diffCode:k.code,diffStderr:k.stderr,otherCode:g.code,otherStderr:g.stderr});return}let d=k.text.split("\x00").filter(Boolean),p=g.text.split("\x00").filter(Boolean),t=Array.from(new Set([...d,...p]));if(!t.length)return;let r=yield*B(t);if(r.size>0){let u=Array.from(r);J$.info("removing gitignored files from snapshot",{count:u.length}),yield*z(u)}let G0=t.filter((u)=>!r.has(u));if(!G0.length)return;let O0=new Set((yield*T.all(G0.map((u)=>$.stat(b5.join(W.directory,u)).pipe(T.catch(()=>T.void)).pipe(T.map((l)=>{if(!l||l.type!=="File")return;return(typeof l.size==="bigint"?Number(l.size):l.size)>Na?u:void 0}))),{concurrency:8})).filter((u)=>Boolean(u))),h0=new Set(p.filter((u)=>O0.has(u)));yield*C(Array.from(h0)),yield*F(G0.filter((u)=>!h0.has(u)))}),w=T.fnUntraced(function*(){return yield*L(T.gen(function*(){if(!(yield*q()))return;if(!(yield*A(W.gitdir)))return;let k=yield*H(K(["gc",`--prune=${yw}`]),{cwd:W.directory});if(k.code!==0){J$.warn("cleanup failed",{exitCode:k.code,stderr:k.stderr});return}J$.info("cleanup",{prune:yw})}))}),I=T.fnUntraced(function*(){return yield*L(T.gen(function*(){if(!(yield*q()))return;let k=yield*A(W.gitdir);if(yield*$.ensureDir(W.gitdir).pipe(T.orDie),!k)yield*H(["init"],{env:{GIT_DIR:W.gitdir,GIT_WORK_TREE:W.worktree}}),yield*H(["--git-dir",W.gitdir,"config","core.autocrlf","false"]),yield*H(["--git-dir",W.gitdir,"config","core.longpaths","true"]),yield*H(["--git-dir",W.gitdir,"config","core.symlinks","true"]),yield*H(["--git-dir",W.gitdir,"config","core.fsmonitor","false"]),J$.info("initialized");yield*R();let d=(yield*H(K(["write-tree"]),{cwd:W.directory})).text.trim();return J$.info("tracking",{hash:d,cwd:W.directory,git:W.gitdir}),d}))}),_=T.fnUntraced(function*(k){return yield*L(T.gen(function*(){yield*R();let g=yield*H([..._5,...K(["diff","--cached","--no-ext-diff","--name-only",k,"--","."])],{cwd:W.directory});if(g.code!==0)return J$.warn("failed to get diff",{hash:k,exitCode:g.code}),{hash:k,files:[]};let d=g.text.trim().split(`
520
- `).map((t)=>t.trim()).filter(Boolean),p=yield*B(d);return{hash:k,files:d.filter((t)=>!p.has(t)).map((t)=>b5.join(W.worktree,t).replaceAll("\\","/"))}}))}),E=T.fnUntraced(function*(k){return yield*L(T.gen(function*(){J$.info("restore",{commit:k});let g=yield*H([...S5,...K(["read-tree",k])],{cwd:W.worktree});if(g.code===0){let d=yield*H([...S5,...K(["checkout-index","-a","-f"])],{cwd:W.worktree});if(d.code===0)return;J$.error("failed to restore snapshot",{snapshot:k,exitCode:d.code,stderr:d.stderr});return}J$.error("failed to restore snapshot",{snapshot:k,exitCode:g.code,stderr:g.stderr})}))}),f=T.fnUntraced(function*(k){return yield*L(T.gen(function*(){let g=[],d=new Set;for(let r of k)for(let G0 of r.files){if(d.has(G0))continue;d.add(G0),g.push({hash:r.hash,file:G0,rel:b5.relative(W.worktree,G0).replaceAll("\\","/")})}let p=T.fnUntraced(function*(r){if(J$.info("reverting",{file:r.file,hash:r.hash}),(yield*H([...S5,...K(["checkout",r.hash,"--",r.file])],{cwd:W.worktree})).code===0)return;let O0=yield*H([...S5,...K(["ls-tree",r.hash,"--",r.rel])],{cwd:W.worktree});if(O0.code===0&&O0.text.trim()){J$.info("file existed in snapshot but checkout failed, keeping",{file:r.file,hash:r.hash});return}J$.info("file did not exist in snapshot, deleting",{file:r.file,hash:r.hash}),yield*N(r.file)}),t=(r,G0)=>r===G0||r.startsWith(`${G0}/`)||G0.startsWith(`${r}/`);for(let r=0;r<g.length;){let G0=g[r],O0=[G0],h0=r+1;while(h0<g.length&&O0.length<100){let v=g[h0];if(v.hash!==G0.hash)break;if(O0.some((h)=>t(h.rel,v.rel)))break;O0.push(v),h0+=1}if(O0.length===1){yield*p(G0),r=h0;continue}let u=yield*H([...S5,...K(["ls-tree","--name-only",G0.hash,"--",...O0.map((v)=>v.rel)])],{cwd:W.worktree});if(u.code!==0){J$.info("batched ls-tree failed, falling back to single-file revert",{hash:G0.hash,files:O0.length});for(let v of O0)yield*p(v);r=h0;continue}let l=new Set(u.text.trim().split(`
521
- `).map((v)=>v.trim()).filter(Boolean)),$0=O0.filter((v)=>l.has(v.rel));if($0.length){if(J$.info("reverting",{hash:G0.hash,files:$0.length}),(yield*H([...S5,...K(["checkout",G0.hash,"--",...$0.map((h)=>h.file)])],{cwd:W.worktree})).code!==0){J$.info("batched checkout failed, falling back to single-file revert",{hash:G0.hash,files:$0.length});for(let h of O0)yield*p(h);r=h0;continue}}for(let v of O0){if(l.has(v.rel))continue;J$.info("file did not exist in snapshot, deleting",{file:v.file,hash:v.hash}),yield*N(v.file)}r=h0}}))}),b=T.fnUntraced(function*(k){return yield*L(T.gen(function*(){yield*R();let g=yield*H([..._5,...K(["diff","--cached","--no-ext-diff",k,"--","."])],{cwd:W.worktree});if(g.code!==0)return J$.warn("failed to get diff",{hash:k,exitCode:g.code,stderr:g.stderr}),"";return g.text.trim()}))}),y=T.fnUntraced(function*(k,g){return yield*L(T.gen(function*(){let d=T.fnUntraced(function*(v){if(v.binary)return["",""];if(v.status==="added")return["",yield*H([...kZ,...K(["show",`${g}:${v.file}`])]).pipe(T.map((h)=>h.text))];if(v.status==="deleted")return[yield*H([...kZ,...K(["show",`${k}:${v.file}`])]).pipe(T.map((h)=>h.text)),""];return yield*T.all([H([...kZ,...K(["show",`${k}:${v.file}`])]).pipe(T.map((h)=>h.text)),H([...kZ,...K(["show",`${g}:${v.file}`])]).pipe(T.map((h)=>h.text))],{concurrency:2})}),p=T.fnUntraced(function*(v){let h=v.flatMap((K0)=>{if(K0.binary)return[];if(K0.status==="added")return[{file:K0.file,side:"after",ref:`${g}:${K0.file}`}];if(K0.status==="deleted")return[{file:K0.file,side:"before",ref:`${k}:${K0.file}`}];return[{file:K0.file,side:"before",ref:`${k}:${K0.file}`},{file:K0.file,side:"after",ref:`${g}:${K0.file}`}]});if(!h.length)return new Map;let c=hU.make("git",[...kZ,...K(["cat-file","--batch"])],{cwd:W.directory,extendEnv:!0,stdin:I$.make(new TextEncoder().encode(h.map((K0)=>K0.ref).join(`
522
- `)+`
523
- `))}),m=yield*Z.spawn(c),[a,e]=yield*T.all([I$.mkUint8Array(m.stdout),I$.mkString(I$.decodeText(m.stderr))],{concurrency:2});if((yield*m.exitCode)!==0){J$.info("git cat-file --batch failed during snapshot diff, falling back to per-file git show",{stderr:e,refs:h.length});return}let A0=(K0,z0)=>{J$.info(K0,{...z0,refs:h.length});return},P0=new Map,s0=new TextDecoder,o=0;for(let K0 of h){let z0=o;while(z0<a.length&&a[z0]!==10)z0+=1;if(z0>=a.length)return A0("git cat-file --batch returned a truncated header during snapshot diff, falling back to per-file git show");let j0=s0.decode(a.slice(o,z0));o=z0+1;let Q1=P0.get(K0.file)??{before:"",after:""};if(j0.endsWith(" missing")){P0.set(K0.file,Q1);continue}let _0=j0.match(/^[0-9a-f]+ blob (\d+)$/);if(!_0)return A0("git cat-file --batch returned an unexpected header during snapshot diff, falling back to per-file git show",{head:j0});let e0=Number(_0[1]);if(!Number.isInteger(e0)||e0<0||o+e0>=a.length||a[o+e0]!==10)return A0("git cat-file --batch returned truncated content during snapshot diff, falling back to per-file git show",{head:j0});let S0=s0.decode(a.slice(o,o+e0));if(K0.side==="before")Q1.before=S0;if(K0.side==="after")Q1.after=S0;P0.set(K0.file,Q1),o+=e0+1}if(o!==a.length)return A0("git cat-file --batch returned trailing data during snapshot diff, falling back to per-file git show");return P0},T.scoped,T.catch(()=>T.succeed(void 0))),t=[],r=new Map,G0=yield*H([..._5,...K(["diff","--no-ext-diff","--name-status","--no-renames",k,g,"--","."])],{cwd:W.directory});for(let v of G0.text.trim().split(`
524
- `)){if(!v)continue;let[h,c]=v.split("\t");if(!h||!c)continue;r.set(c,h.startsWith("A")?"added":h.startsWith("D")?"deleted":"modified")}let h0=(yield*H([..._5,...K(["diff","--no-ext-diff","--no-renames","--numstat",k,g,"--","."])],{cwd:W.directory})).text.trim().split(`
525
- `).filter(Boolean).flatMap((v)=>{let[h,c,m]=v.split("\t");if(!m)return[];let a=h==="-"&&c==="-",e=a?0:parseInt(h),H0=a?0:parseInt(c);return[{file:m,status:r.get(m)??"modified",binary:a,additions:Number.isFinite(e)?e:0,deletions:Number.isFinite(H0)?H0:0}]}),u=yield*B(h0.map((v)=>v.file));if(u.size>0){let v=h0.filter((h)=>!u.has(h.file));h0.length=0,h0.push(...v)}let l=100,$0=(v,h,c)=>VJ(QX(v,v,h,c,"","",{context:Number.MAX_SAFE_INTEGER}));for(let v=0;v<h0.length;v+=l){let h=h0.slice(v,v+l),c=yield*p(h);for(let m of h){let a=c?.get(m.file)??{before:"",after:""},[e,H0]=m.binary?["",""]:c?[a.before,a.after]:yield*d(m);t.push({file:m.file,patch:m.binary?"":$0(m.file,e,H0),additions:m.additions,deletions:m.deletions,status:m.status})}}return t}))});return yield*vw(w(),(k)=>{return J$.error("cleanup loop failed",{cause:xw.pretty(k)}),T.void}),{cleanup:w,track:I,patch:_,restore:E,revert:f,diff:b,diffFull:y}}));return K4.of({init:T.fn("Snapshot.init")(function*(){yield*B0.get(Q)}),cleanup:T.fn("Snapshot.cleanup")(function*(){return yield*B0.useEffect(Q,(G)=>G.cleanup())}),track:T.fn("Snapshot.track")(function*(){return yield*B0.useEffect(Q,(G)=>G.track())}),patch:T.fn("Snapshot.patch")(function*(G){return yield*B0.useEffect(Q,(W)=>W.patch(G))}),restore:T.fn("Snapshot.restore")(function*(G){return yield*B0.useEffect(Q,(W)=>W.restore(G))}),revert:T.fn("Snapshot.revert")(function*(G){return yield*B0.useEffect(Q,(W)=>W.revert(G))}),diff:T.fn("Snapshot.diff")(function*(G){return yield*B0.useEffect(Q,(W)=>W.diff(G))}),diffFull:T.fn("Snapshot.diffFull")(function*(G,W){return yield*B0.useEffect(Q,(K)=>K.diffFull(G,W))})})})),Ma=mw.pipe(T0.provide(gw),T0.provide(D$.defaultLayer),T0.provide(X8.defaultLayer));var Da=O.String.pipe(O.brand("ProviderID")),X1=Da.pipe(u0(($)=>({zod:P.string().pipe(P.custom()),opencode:$.make("opencode"),anthropic:$.make("anthropic"),openai:$.make("openai"),google:$.make("google"),googleVertex:$.make("google-vertex"),githubCopilot:$.make("github-copilot"),amazonBedrock:$.make("amazon-bedrock"),azure:$.make("azure"),openrouter:$.make("openrouter"),mistral:$.make("mistral"),gitlab:$.make("gitlab")}))),wa=O.String.pipe(O.brand("ModelID")),s1=wa.pipe(u0(($)=>({zod:P.string().pipe(P.custom())})));var lw=P.object({errorID:P.string(),errorName:P.string(),logFile:P.string()}).meta({ref:"ErrorDiagnostic"}),U4=j1.create("MessageOutputLengthError",P.object({})),f5=j1.create("MessageAbortedError",P.object({message:P.string()})),dw=j1.create("StructuredOutputError",P.object({message:P.string(),retries:P.number()})),H4=j1.create("ProviderAuthError",P.object({providerID:P.string(),message:P.string()})),L6=j1.create("APIError",P.object({message:P.string(),statusCode:P.number().optional(),isRetryable:P.boolean(),category:P.string().optional(),upstreamCode:P.string().optional(),requestId:P.string().optional(),outputBudgetRecoveryAvailable:P.boolean().optional(),outputBudgetRecoveryTokens:P.number().int().positive().optional(),diagnostic:lw.optional(),responseHeaders:P.record(P.string(),P.string()).optional(),responseBody:P.string().optional(),metadata:P.record(P.string(),P.string()).optional()})),GX=j1.create("ContextOverflowError",P.object({message:P.string(),responseBody:P.string().optional()})),pw=j1.create("InvalidOutputError",P.object({message:P.string()})),cw=j1.create("ContentFilterError",P.object({message:P.string()})),iw=j1.create("ModelError",P.object({message:P.string()})),nw=P.object({type:P.literal("text")}).meta({ref:"OutputFormatText"}),ow=P.object({type:P.literal("json_schema"),schema:P.record(P.string(),P.any()).meta({ref:"JSONSchema"}),retryCount:P.number().int().min(0).default(2)}).meta({ref:"OutputFormatJsonSchema"}),sw=P.discriminatedUnion("type",[nw,ow]).meta({ref:"OutputFormat"}),P8=P.object({id:MZ.zod,sessionID:r0.zod,messageID:i1.zod}),rw=P8.extend({type:P.literal("snapshot"),snapshot:P.string()}).meta({ref:"SnapshotPart"}),aw=P8.extend({type:P.literal("patch"),hash:P.string(),files:P.string().array()}).meta({ref:"PatchPart"}),tw=P8.extend({type:P.literal("text"),text:P.string(),synthetic:P.boolean().optional(),ignored:P.boolean().optional(),time:P.object({start:P.number(),end:P.number().optional()}).optional(),metadata:P.record(P.string(),P.any()).optional()}).meta({ref:"TextPart"}),ew=P8.extend({type:P.literal("reasoning"),text:P.string(),metadata:P.record(P.string(),P.any()).optional(),time:P.object({start:P.number(),end:P.number().optional()})}).meta({ref:"ReasoningPart"}),gU=P.object({text:P.object({value:P.string(),start:P.number().int(),end:P.number().int()}).meta({ref:"FilePartSourceText"})}),$L=gU.extend({type:P.literal("file"),path:P.string()}).meta({ref:"FileSource"}),ZL=gU.extend({type:P.literal("symbol"),path:P.string(),range:X4.Range,name:P.string(),kind:P.number().int()}).meta({ref:"SymbolSource"}),JL=gU.extend({type:P.literal("resource"),clientName:P.string(),uri:P.string()}).meta({ref:"ResourceSource"}),YL=P.discriminatedUnion("type",[$L,ZL,JL]).meta({ref:"FilePartSource"}),uU=P8.extend({type:P.literal("file"),mime:P.string(),filename:P.string().optional(),url:P.string(),source:YL.optional()}).meta({ref:"FilePart"}),XL=P8.extend({type:P.literal("agent"),name:P.string(),source:P.object({value:P.string(),start:P.number().int(),end:P.number().int()}).optional()}).meta({ref:"AgentPart"}),QL=P8.extend({type:P.literal("checkpoint"),checkpointDir:P.string(),checkpointNumber:P.number(),coveredUpTo:i1.zod}).meta({ref:"CheckpointPart"}),GL=P8.extend({type:P.literal("subtask"),prompt:P.string(),description:P.string(),agent:P.string(),model:P.object({providerID:X1.zod,modelID:s1.zod}).optional(),command:P.string().optional()}).meta({ref:"SubtaskPart"}),WL=P8.extend({type:P.literal("compaction"),auto:P.boolean(),overflow:P.boolean().optional(),tail_start_id:i1.zod.optional()}).meta({ref:"CompactionPart"}),KL=P8.extend({type:P.literal("retry"),attempt:P.number(),error:L6.Schema,time:P.object({created:P.number()})}).meta({ref:"RetryPart"}),VL=P8.extend({type:P.literal("step-start"),snapshot:P.string().optional()}).meta({ref:"StepStartPart"}),UL=P.object({total:P.number().optional(),input:P.number(),output:P.number(),reasoning:P.number(),cache:P.object({read:P.number(),write:P.number()})}),HL=P8.extend({type:P.literal("step-finish"),reason:P.string(),snapshot:P.string().optional(),cost:P.number(),costCredits:P.number().optional(),tokens:UL,contextWindow:P.number().optional()}).meta({ref:"StepFinishPart"}),BL=P.object({status:P.literal("pending"),input:P.record(P.string(),P.any()),raw:P.string()}).meta({ref:"ToolStatePending"}),zL=P.object({status:P.literal("running"),input:P.record(P.string(),P.any()),title:P.string().optional(),metadata:P.record(P.string(),P.any()).optional(),time:P.object({start:P.number()})}).meta({ref:"ToolStateRunning"}),FL=P.object({status:P.literal("completed"),input:P.record(P.string(),P.any()),output:P.string(),title:P.string(),metadata:P.record(P.string(),P.any()),time:P.object({start:P.number(),end:P.number(),compacted:P.number().optional()}),attachments:uU.array().optional()}).meta({ref:"ToolStateCompleted"}),AL=P.object({status:P.literal("error"),input:P.record(P.string(),P.any()),error:P.string(),metadata:P.record(P.string(),P.any()).optional(),time:P.object({start:P.number(),end:P.number()})}).meta({ref:"ToolStateError"}),OL=P.discriminatedUnion("status",[BL,zL,FL,AL]).meta({ref:"ToolState"}),qL=P8.extend({type:P.literal("tool"),callID:P.string(),tool:P.string(),state:OL,metadata:P.record(P.string(),P.any()).optional()}).meta({ref:"ToolPart"}),jL=P.object({id:i1.zod,sessionID:r0.zod,agentID:P.string().optional()}),NL=P.object({hookPhase:P.enum(["pre","post"]),hookIteration:P.number().int().nonnegative(),pluginNames:P.array(P.string()),hookIDs:P.array(P.string())}).meta({ref:"Provenance"}),ML=jL.extend({role:P.literal("user"),time:P.object({created:P.number()}),format:sw.optional(),summary:P.object({title:P.string().optional(),body:P.string().optional(),diffs:vZ.FileDiff.array()}).optional(),agent:P.string(),model:P.object({providerID:X1.zod,modelID:s1.zod,variant:P.string().optional()}),system:P.string().optional(),tools:P.record(P.string(),P.boolean()).optional(),provenance:NL.optional(),outputBudgetRecoveryTokens:P.number().int().positive().optional()}).meta({ref:"UserMessage"}),mU=P.discriminatedUnion("type",[tw,GL,ew,uU,qL,VL,HL,rw,aw,XL,KL,QL,WL]).meta({ref:"Part"}),DL=jL.extend({role:P.literal("assistant"),time:P.object({created:P.number(),completed:P.number().optional()}),error:P.discriminatedUnion("name",[H4.Schema,j1.Unknown.Schema,U4.Schema,f5.Schema,dw.Schema,GX.Schema,pw.Schema,cw.Schema,iw.Schema,L6.Schema]).optional(),parentID:i1.zod,modelID:s1.zod,providerID:X1.zod,mode:P.string(),agent:P.string(),path:P.object({cwd:P.string(),root:P.string()}),summary:P.boolean().optional(),cost:P.number(),costCredits:P.number().optional(),tokens:UL,contextWindow:P.number().optional(),structured:P.any().optional(),variant:P.string().optional(),finish:P.string().optional()}).meta({ref:"AssistantMessage"}),lU=P.discriminatedUnion("role",[ML,DL]).meta({ref:"Message"}),La={Updated:X$.define({type:"message.updated",version:1,aggregate:"sessionID",schema:P.object({sessionID:r0.zod,info:lU})}),Removed:X$.define({type:"message.removed",version:1,aggregate:"sessionID",schema:P.object({sessionID:r0.zod,messageID:i1.zod})}),PartUpdated:X$.define({type:"message.part.updated",version:1,aggregate:"sessionID",schema:P.object({sessionID:r0.zod,part:mU,time:P.number()})}),PartDelta:L1.define("message.part.delta",P.object({sessionID:r0.zod,messageID:i1.zod,partID:MZ.zod,field:P.string(),delta:P.string()})),PartRemoved:X$.define({type:"message.part.removed",version:1,aggregate:"sessionID",schema:P.object({sessionID:r0.zod,messageID:i1.zod,partID:MZ.zod})})},Ta=P.object({info:lU,parts:P.array(mU)});var Ra=P.object({id:i1.zod,time:P.number()}),dU={encode($){return Buffer.from(JSON.stringify($)).toString("base64url")},decode($){return Ra.parse(JSON.parse(Buffer.from($,"base64url").toString("utf8")))}},LL=($)=>({...$.data,id:$.id,sessionID:$.session_id,agentID:$.agent_id}),TL=($)=>({...$.data,id:$.id,sessionID:$.session_id,messageID:$.message_id}),Pa=($)=>wL(WX(w$.time_created,$.time),O$(m0(w$.time_created,$.time),WX(w$.id,$.id)));function Ia($){let Z=$.map((Y)=>Y.id),J=new Map;if(Z.length>0){let Y=W1.use((X)=>X.select().from(I8).where(k5(I8.message_id,Z)).orderBy(I8.message_id,I8.id).all());for(let X of Y){let Q=TL(X),G=J.get(X.message_id);if(G)G.push(Q);else J.set(X.message_id,[Q])}}return $.map((Y)=>({info:LL(Y),parts:J.get(Y.id)??[]}))}function RL($){let Z=$.before?dU.decode($.before):void 0,J=$.agentID==="*"?void 0:m0(w$.agent_id,$.agentID??"main"),Y=O$(m0(w$.session_id,$.sessionID),...Z?[Pa(Z)]:[],...J?[J]:[]),X=W1.use((V)=>V.select().from(w$).where(Y).orderBy(o6(w$.time_created),o6(w$.id)).limit($.limit+1).all());if(X.length===0){if(!W1.use((U)=>U.select({id:I1.id}).from(I1).where(m0(I1.id,$.sessionID)).get()))throw new KX({message:`Session not found: ${$.sessionID}`});return{items:[],more:!1}}let Q=X.length>$.limit,G=Q?X.slice(0,$.limit):X,W=Ia(G);W.reverse();let K=G.at(-1);return{items:W,more:Q,cursor:Q&&K?dU.encode({id:K.id,time:K.time_created}):void 0}}function*pU($,Z){let Y;while(!0){let X=RL({sessionID:$,limit:50,before:Y,agentID:Z?.agentID});if(X.items.length===0)break;for(let Q=X.items.length-1;Q>=0;Q--)yield X.items[Q];if(!X.more||!X.cursor)break;Y=X.cursor}}function PL($){return W1.use((J)=>J.select().from(I8).where(m0(I8.message_id,$)).orderBy(I8.id).all()).map(TL)}function Ca($){let Z=W1.use((J)=>J.select().from(w$).where(O$(m0(w$.id,$.messageID),m0(w$.session_id,$.sessionID))).get());if(!Z)throw new KX({message:`Message not found: ${$.messageID}`});return{info:LL(Z),parts:PL($.messageID)}}function cU($){let Z=[];for(let J of $)if(Z.push(J),J.info.role==="user"&&J.parts.some((Y)=>Y.type==="checkpoint"||Y.type==="compaction"))break;return Z.reverse(),Z}var Ea=T.fnUntraced(function*($,Z){let J=cU(pU($,{agentID:Z?.agentID}));if(!Z?.contextFrom)return J;let Y=pU(Z.contextFrom,{agentID:"main"}),X=cU(Y);if(Z.contextWatermark){let Q=X.findIndex((G)=>G.info.id===Z.contextWatermark);if(Q>=0)return[...X.slice(0,Q+1),...J]}return[...X,...J]});var lT=m6(yL(),1),zJ=m6(yL(),1);var ba=Object.defineProperty,_a=($,Z)=>{for(var J in Z)ba($,J,{get:Z[J],enumerable:!0})},iL="AI_InvalidArgumentError",nL=`vercel.ai.error.${iL}`,Sa=Symbol.for(nL),oL,r1=class extends p0{constructor({parameter:$,value:Z,message:J}){super({name:iL,message:`Invalid argument for parameter ${$}: ${J}`});this[oL]=!0,this.parameter=$,this.value=Z}static isInstance($){return p0.hasMarker($,nL)}};oL=Sa;var fa="AI_InvalidStreamPartError",ka=`vercel.ai.error.${fa}`,va=Symbol.for(ka),ya;ya=va;var sL="AI_InvalidToolApprovalError",rL=`vercel.ai.error.${sL}`,xa=Symbol.for(rL),aL,ha=class extends p0{constructor({approvalId:$}){super({name:sL,message:`Tool approval response references unknown approvalId: "${$}". No matching tool-approval-request found in message history.`});this[aL]=!0,this.approvalId=$}static isInstance($){return p0.hasMarker($,rL)}};aL=xa;var tL="AI_InvalidToolInputError",eL=`vercel.ai.error.${tL}`,ga=Symbol.for(eL),$T,GH=class extends p0{constructor({toolInput:$,toolName:Z,cause:J,message:Y=`Invalid input for tool ${Z}: ${r6(J)}`}){super({name:tL,message:Y,cause:J});this[$T]=!0,this.toolInput=$,this.toolName=Z}static isInstance($){return p0.hasMarker($,eL)}};$T=ga;var ZT="AI_ToolCallNotFoundForApprovalError",JT=`vercel.ai.error.${ZT}`,ua=Symbol.for(JT),YT,XT=class extends p0{constructor({toolCallId:$,approvalId:Z}){super({name:ZT,message:`Tool call "${$}" not found for approval request "${Z}".`});this[YT]=!0,this.toolCallId=$,this.approvalId=Z}static isInstance($){return p0.hasMarker($,JT)}};YT=ua;var QT="AI_MissingToolResultsError",GT=`vercel.ai.error.${QT}`,ma=Symbol.for(GT),WT,IL=class extends p0{constructor({toolCallIds:$}){super({name:QT,message:`Tool result${$.length>1?"s are":" is"} missing for tool call${$.length>1?"s":""} ${$.join(", ")}.`});this[WT]=!0,this.toolCallIds=$}static isInstance($){return p0.hasMarker($,GT)}};WT=ma;var la="AI_NoImageGeneratedError",da=`vercel.ai.error.${la}`,pa=Symbol.for(da),ca;ca=pa;var KT="AI_NoObjectGeneratedError",VT=`vercel.ai.error.${KT}`,ia=Symbol.for(VT),UT,E8=class extends p0{constructor({message:$="No object generated.",cause:Z,text:J,response:Y,usage:X,finishReason:Q}){super({name:KT,message:$,cause:Z});this[UT]=!0,this.text=J,this.response=Y,this.usage=X,this.finishReason=Q}static isInstance($){return p0.hasMarker($,VT)}};UT=ia;var HT="AI_NoOutputGeneratedError",BT=`vercel.ai.error.${HT}`,na=Symbol.for(BT),zT,oa=class extends p0{constructor({message:$="No output generated.",cause:Z}={}){super({name:HT,message:$,cause:Z});this[zT]=!0}static isInstance($){return p0.hasMarker($,BT)}};zT=na;var sa="AI_NoSpeechGeneratedError",ra=`vercel.ai.error.${sa}`,aa=Symbol.for(ra),ta;ta=aa;var ea="AI_NoTranscriptGeneratedError",$t=`vercel.ai.error.${ea}`,Zt=Symbol.for($t),Jt;Jt=Zt;var Yt="AI_NoVideoGeneratedError",Xt=`vercel.ai.error.${Yt}`,Qt=Symbol.for(Xt),Gt;Gt=Qt;var FT="AI_NoSuchToolError",AT=`vercel.ai.error.${FT}`,Wt=Symbol.for(AT),OT,tU=class extends p0{constructor({toolName:$,availableTools:Z=void 0,message:J=`Model tried to call unavailable tool '${$}'. ${Z===void 0?"No tools are available.":`Available tools: ${Z.join(", ")}.`}`}){super({name:FT,message:J});this[OT]=!0,this.toolName=$,this.availableTools=Z}static isInstance($){return p0.hasMarker($,AT)}};OT=Wt;var qT="AI_ToolCallRepairError",jT=`vercel.ai.error.${qT}`,Kt=Symbol.for(jT),NT,Vt=class extends p0{constructor({cause:$,originalError:Z,message:J=`Error repairing tool call: ${r6($)}`}){super({name:qT,message:J,cause:$});this[NT]=!0,this.originalError=Z}static isInstance($){return p0.hasMarker($,jT)}};NT=Kt;var Ut=class extends p0{constructor($){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${$.version} for provider "${$.provider}" and model "${$.modelId}". AI SDK 5 only supports models that implement specification version "v2".`});this.version=$.version,this.provider=$.provider,this.modelId=$.modelId}},MT="AI_UIMessageStreamError",DT=`vercel.ai.error.${MT}`,Ht=Symbol.for(DT),wT,UJ=class extends p0{constructor({chunkType:$,chunkId:Z,message:J}){super({name:MT,message:J});this[wT]=!0,this.chunkType=$,this.chunkId=Z}static isInstance($){return p0.hasMarker($,DT)}};wT=Ht;var Bt="AI_InvalidDataContentError",zt=`vercel.ai.error.${Bt}`,Ft=Symbol.for(zt),At;At=Ft;var LT="AI_InvalidMessageRoleError",TT=`vercel.ai.error.${LT}`,Ot=Symbol.for(TT),RT,qt=class extends p0{constructor({role:$,message:Z=`Invalid message role: '${$}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:LT,message:Z});this[RT]=!0,this.role=$}static isInstance($){return p0.hasMarker($,TT)}};RT=Ot;var PT="AI_MessageConversionError",IT=`vercel.ai.error.${PT}`,jt=Symbol.for(IT),CT,Nt=class extends p0{constructor({originalMessage:$,message:Z}){super({name:PT,message:Z});this[CT]=!0,this.originalMessage=$}static isInstance($){return p0.hasMarker($,IT)}};CT=jt;var ET="AI_RetryError",bT=`vercel.ai.error.${ET}`,Mt=Symbol.for(bT),_T,O4=class extends p0{constructor({message:$,reason:Z,errors:J}){super({name:ET,message:$});this[_T]=!0,this.reason=Z,this.errors=J,this.lastError=J[J.length-1]}static isInstance($){return p0.hasMarker($,bT)}};_T=Mt;function y5($){return $===void 0?[]:Array.isArray($)?$:[$]}async function v5($){for(let Z of y5($.callbacks)){if(Z==null)continue;try{await Z($.event)}catch(J){}}}function Dt({warning:$,provider:Z,model:J}){let Y=`AI SDK Warning (${Z} / ${J}):`;switch($.type){case"unsupported":{let X=`${Y} The feature "${$.feature}" is not supported.`;if($.details)X+=` ${$.details}`;return X}case"compatibility":{let X=`${Y} The feature "${$.feature}" is used in a compatibility mode.`;if($.details)X+=` ${$.details}`;return X}case"other":return`${Y} ${$.message}`;default:return`${Y} ${JSON.stringify($,null,2)}`}}var wt="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",CL=!1,D4=($)=>{if($.warnings.length===0)return;let Z=globalThis.AI_SDK_LOG_WARNINGS;if(Z===!1)return;if(typeof Z==="function"){Z($);return}if(!CL)CL=!0,console.info(wt);for(let J of $.warnings)console.warn(Dt({warning:J,provider:$.provider,model:$.model}))};function Lt({provider:$,modelId:Z}){D4({warnings:[{type:"compatibility",feature:"specificationVersion",details:"Using v2 specification compatibility mode. Some features may not be available."}],provider:$,model:Z})}function Tt($){if($.specificationVersion==="v3")return $;return Lt({provider:$.provider,modelId:$.modelId}),new Proxy($,{get(Z,J){switch(J){case"specificationVersion":return"v3";case"doGenerate":return async(...Y)=>{let X=await Z.doGenerate(...Y);return{...X,finishReason:ST(X.finishReason),usage:fT(X.usage)}};case"doStream":return async(...Y)=>{let X=await Z.doStream(...Y);return{...X,stream:Rt(X.stream)}};default:return Z[J]}}})}function Rt($){return $.pipeThrough(new TransformStream({transform(Z,J){switch(Z.type){case"finish":J.enqueue({...Z,finishReason:ST(Z.finishReason),usage:fT(Z.usage)});break;default:J.enqueue(Z);break}}}))}function ST($){return{unified:$==="unknown"?"other":$,raw:void 0}}function fT($){return{inputTokens:{total:$.inputTokens,noCache:void 0,cacheRead:$.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:$.outputTokens,text:void 0,reasoning:$.reasoningTokens}}}function w4($){if(typeof $!=="string"){if($.specificationVersion!=="v3"&&$.specificationVersion!=="v2"){let Z=$;throw new Ut({version:Z.specificationVersion,provider:Z.provider,modelId:Z.modelId})}return Tt($)}return Pt().languageModel($)}function Pt(){var $;return($=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?$:cL}function kT($){if($==null)return;if(typeof $==="number")return $;return $.totalMs}function It($){if($==null||typeof $==="number")return;return $.stepMs}function Ct($){if($==null||typeof $==="number")return;return $.chunkMs}var Et=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}];var bt=($)=>{let Z=typeof $==="string"?FJ($):$,J=(Z[6]&127)<<21|(Z[7]&127)<<14|(Z[8]&127)<<7|Z[9]&127;return Z.slice(J+10)};function _t($){return typeof $==="string"&&$.startsWith("SUQz")||typeof $!=="string"&&$.length>10&&$[0]===73&&$[1]===68&&$[2]===51?bt($):$}function St({data:$,signatures:Z}){let J=_t($),Y=typeof J==="string"?FJ(J.substring(0,Math.min(J.length,24))):J;for(let X of Z)if(Y.length>=X.bytesPrefix.length&&X.bytesPrefix.every((Q,G)=>Q===null||Y[G]===Q))return X.mediaType;return}var vT="6.0.168",yT=async({url:$,maxBytes:Z,abortSignal:J})=>{var Y;let X=$.toString();aU(X);try{let Q=await fetch(X,{headers:OX({},`ai-sdk/${vT}`,uL()),signal:J});if(Q.redirected)aU(Q.url);if(!Q.ok)throw new z4({url:X,statusCode:Q.status,statusText:Q.statusText});return{data:await gL({response:Q,url:X,maxBytes:Z!=null?Z:hL}),mediaType:(Y=Q.headers.get("content-type"))!=null?Y:void 0}}catch(Q){if(z4.isInstance(Q))throw Q;throw new z4({url:X,cause:Q})}},ft=($=yT)=>(Z)=>Promise.all(Z.map(async(J)=>J.isUrlSupportedByModel?null:$(J)));function kt($){try{let[Z,J]=$.split(",");return{mediaType:Z.split(";")[0].split(":")[1],base64Content:J}}catch(Z){return{mediaType:void 0,base64Content:void 0}}}var xT=D.union([D.string(),D.instanceof(Uint8Array),D.instanceof(ArrayBuffer),D.custom(($)=>{var Z,J;return(J=(Z=globalThis.Buffer)==null?void 0:Z.isBuffer($))!=null?J:!1},{message:"Must be a Buffer"})]);function hT($){if($ instanceof Uint8Array)return{data:$,mediaType:void 0};if($ instanceof ArrayBuffer)return{data:new Uint8Array($),mediaType:void 0};if(typeof $==="string")try{$=new URL($)}catch(Z){}if($ instanceof URL&&$.protocol==="data:"){let{mediaType:Z,base64Content:J}=kt($.toString());if(Z==null||J==null)throw new p0({name:"InvalidDataContentError",message:`Invalid data URL format in content ${$.toString()}`});return{data:J,mediaType:Z}}return{data:$,mediaType:void 0}}function vt($){if(typeof $==="string")return $;if($ instanceof ArrayBuffer)return HX(new Uint8Array($));return HX($)}async function WH({prompt:$,supportedUrls:Z,download:J=ft()}){let Y=await xt($.messages,J,Z),X=new Map;for(let V of $.messages)if(V.role==="assistant"&&Array.isArray(V.content)){for(let U of V.content)if(U.type==="tool-approval-request"&&"approvalId"in U&&"toolCallId"in U)X.set(U.approvalId,U.toolCallId)}let Q=new Set;for(let V of $.messages)if(V.role==="tool"){for(let U of V.content)if(U.type==="tool-approval-response"){let H=X.get(U.approvalId);if(H)Q.add(H)}}let G=[...$.system!=null?typeof $.system==="string"?[{role:"system",content:$.system}]:y5($.system).map((V)=>({role:"system",content:V.content,providerOptions:V.providerOptions})):[],...$.messages.map((V)=>yt({message:V,downloadedAssets:Y}))],W=[];for(let V of G){if(V.role!=="tool"){W.push(V);continue}let U=W.at(-1);if((U==null?void 0:U.role)==="tool")U.content.push(...V.content);else W.push(V)}let K=new Set;for(let V of W)switch(V.role){case"assistant":{for(let U of V.content)if(U.type==="tool-call"&&!U.providerExecuted)K.add(U.toolCallId);break}case"tool":{for(let U of V.content)if(U.type==="tool-result")K.delete(U.toolCallId);break}case"user":case"system":for(let U of Q)K.delete(U);if(K.size>0)throw new IL({toolCallIds:Array.from(K)});break}for(let V of Q)K.delete(V);if(K.size>0)throw new IL({toolCallIds:Array.from(K)});return W.filter((V)=>V.role!=="tool"||V.content.length>0)}function yt({message:$,downloadedAssets:Z}){let J=$.role;switch(J){case"system":return{role:"system",content:$.content,providerOptions:$.providerOptions};case"user":{if(typeof $.content==="string")return{role:"user",content:[{type:"text",text:$.content}],providerOptions:$.providerOptions};return{role:"user",content:$.content.map((Y)=>ht(Y,Z)).filter((Y)=>Y.type!=="text"||Y.text!==""),providerOptions:$.providerOptions}}case"assistant":{if(typeof $.content==="string")return{role:"assistant",content:[{type:"text",text:$.content}],providerOptions:$.providerOptions};return{role:"assistant",content:$.content.filter((Y)=>Y.type!=="text"||Y.text!==""||Y.providerOptions!=null).filter((Y)=>Y.type!=="tool-approval-request").map((Y)=>{let X=Y.providerOptions;switch(Y.type){case"file":{let{data:Q,mediaType:G}=hT(Y.data);return{type:"file",data:Q,filename:Y.filename,mediaType:G!=null?G:Y.mediaType,providerOptions:X}}case"reasoning":return{type:"reasoning",text:Y.text,providerOptions:X};case"text":return{type:"text",text:Y.text,providerOptions:X};case"tool-call":return{type:"tool-call",toolCallId:Y.toolCallId,toolName:Y.toolName,input:Y.input,providerExecuted:Y.providerExecuted,providerOptions:X};case"tool-result":return{type:"tool-result",toolCallId:Y.toolCallId,toolName:Y.toolName,output:EL(Y.output),providerOptions:X}}}),providerOptions:$.providerOptions}}case"tool":return{role:"tool",content:$.content.filter((Y)=>Y.type!=="tool-approval-response"||Y.providerExecuted).map((Y)=>{switch(Y.type){case"tool-result":return{type:"tool-result",toolCallId:Y.toolCallId,toolName:Y.toolName,output:EL(Y.output),providerOptions:Y.providerOptions};case"tool-approval-response":return{type:"tool-approval-response",approvalId:Y.approvalId,approved:Y.approved,reason:Y.reason}}}),providerOptions:$.providerOptions};default:throw new qt({role:J})}}async function xt($,Z,J){let Y=$.filter((Q)=>Q.role==="user").map((Q)=>Q.content).filter((Q)=>Array.isArray(Q)).flat().filter((Q)=>Q.type==="image"||Q.type==="file").map((Q)=>{var G;let W=(G=Q.mediaType)!=null?G:Q.type==="image"?"image/*":void 0,K=Q.type==="image"?Q.image:Q.data;if(typeof K==="string")try{K=new URL(K)}catch(V){}return{mediaType:W,data:K}}).filter((Q)=>Q.data instanceof URL).map((Q)=>({url:Q.data,isUrlSupportedByModel:Q.mediaType!=null&&lL({url:Q.data.toString(),mediaType:Q.mediaType,supportedUrls:J})})),X=await Z(Y);return Object.fromEntries(X.map((Q,G)=>Q==null?null:[Y[G].url.toString(),{data:Q.data,mediaType:Q.mediaType}]).filter((Q)=>Q!=null))}function ht($,Z){var J;if($.type==="text")return{type:"text",text:$.text,providerOptions:$.providerOptions};let Y,X=$.type;switch(X){case"image":Y=$.image;break;case"file":Y=$.data;break;default:throw Error(`Unsupported part type: ${X}`)}let{data:Q,mediaType:G}=hT(Y),W=G!=null?G:$.mediaType,K=Q;if(K instanceof URL){let V=Z[K.toString()];if(V)K=V.data,W!=null||(W=V.mediaType)}switch(X){case"image":{if(K instanceof Uint8Array||typeof K==="string")W=(J=St({data:K,signatures:Et}))!=null?J:W;return{type:"file",mediaType:W!=null?W:"image/*",filename:void 0,data:K,providerOptions:$.providerOptions}}case"file":{if(W==null)throw Error("Media type is missing for file part");return{type:"file",mediaType:W,filename:$.filename,data:K,providerOptions:$.providerOptions}}}}function EL($){if($.type!=="content")return $;return{type:"content",value:$.value.map((Z)=>{if(Z.type!=="media")return Z;if(Z.mediaType.startsWith("image/"))return{type:"image-data",data:Z.data,mediaType:Z.mediaType};return{type:"file-data",data:Z.data,mediaType:Z.mediaType}})}}async function BJ({toolCallId:$,input:Z,output:J,tool:Y,errorMode:X}){if(X==="text")return{type:"error-text",value:r6(J)};else if(X==="json")return{type:"error-json",value:bL(J)};if(Y==null?void 0:Y.toModelOutput)return await Y.toModelOutput({toolCallId:$,input:Z,output:J});return typeof J==="string"?{type:"text",value:J}:{type:"json",value:bL(J)}}function bL($){return $===void 0?null:$}function BX({maxOutputTokens:$,temperature:Z,topP:J,topK:Y,presencePenalty:X,frequencyPenalty:Q,seed:G,stopSequences:W}){if($!=null){if(!Number.isInteger($))throw new r1({parameter:"maxOutputTokens",value:$,message:"maxOutputTokens must be an integer"});if($<1)throw new r1({parameter:"maxOutputTokens",value:$,message:"maxOutputTokens must be >= 1"})}if(Z!=null){if(typeof Z!=="number")throw new r1({parameter:"temperature",value:Z,message:"temperature must be a number"})}if(J!=null){if(typeof J!=="number")throw new r1({parameter:"topP",value:J,message:"topP must be a number"})}if(Y!=null){if(typeof Y!=="number")throw new r1({parameter:"topK",value:Y,message:"topK must be a number"})}if(X!=null){if(typeof X!=="number")throw new r1({parameter:"presencePenalty",value:X,message:"presencePenalty must be a number"})}if(Q!=null){if(typeof Q!=="number")throw new r1({parameter:"frequencyPenalty",value:Q,message:"frequencyPenalty must be a number"})}if(G!=null){if(!Number.isInteger(G))throw new r1({parameter:"seed",value:G,message:"seed must be an integer"})}return{maxOutputTokens:$,temperature:Z,topP:J,topK:Y,presencePenalty:X,frequencyPenalty:Q,stopSequences:W,seed:G}}function gt($){return $!=null&&Object.keys($).length>0}async function ut({tools:$,toolChoice:Z,activeTools:J}){if(!gt($))return{tools:void 0,toolChoice:void 0};let Y=J!=null?Object.entries($).filter(([Q])=>J.includes(Q)):Object.entries($),X=[];for(let[Q,G]of Y){let W=G.type;switch(W){case void 0:case"dynamic":case"function":X.push({type:"function",name:Q,description:G.description,inputSchema:await v8(G.inputSchema).jsonSchema,...G.inputExamples!=null?{inputExamples:G.inputExamples}:{},providerOptions:G.providerOptions,...G.strict!=null?{strict:G.strict}:{}});break;case"provider":X.push({type:"provider",name:Q,id:G.id,args:G.args});break;default:throw Error(`Unsupported tool type: ${W}`)}}return{tools:X,toolChoice:Z==null?{type:"auto"}:typeof Z==="string"?{type:Z}:{type:"tool",toolName:Z.toolName}}}var zX=D.lazy(()=>D.union([D.null(),D.string(),D.number(),D.boolean(),D.record(D.string(),zX.optional()),D.array(zX)])),N0=D.record(D.string(),D.record(D.string(),zX.optional())),gT=D.object({type:D.literal("text"),text:D.string(),providerOptions:N0.optional()}),mt=D.object({type:D.literal("image"),image:D.union([xT,D.instanceof(URL)]),mediaType:D.string().optional(),providerOptions:N0.optional()}),uT=D.object({type:D.literal("file"),data:D.union([xT,D.instanceof(URL)]),filename:D.string().optional(),mediaType:D.string(),providerOptions:N0.optional()}),lt=D.object({type:D.literal("reasoning"),text:D.string(),providerOptions:N0.optional()}),dt=D.object({type:D.literal("tool-call"),toolCallId:D.string(),toolName:D.string(),input:D.unknown(),providerOptions:N0.optional(),providerExecuted:D.boolean().optional()}),pt=D.discriminatedUnion("type",[D.object({type:D.literal("text"),value:D.string(),providerOptions:N0.optional()}),D.object({type:D.literal("json"),value:zX,providerOptions:N0.optional()}),D.object({type:D.literal("execution-denied"),reason:D.string().optional(),providerOptions:N0.optional()}),D.object({type:D.literal("error-text"),value:D.string(),providerOptions:N0.optional()}),D.object({type:D.literal("error-json"),value:zX,providerOptions:N0.optional()}),D.object({type:D.literal("content"),value:D.array(D.union([D.object({type:D.literal("text"),text:D.string(),providerOptions:N0.optional()}),D.object({type:D.literal("media"),data:D.string(),mediaType:D.string()}),D.object({type:D.literal("file-data"),data:D.string(),mediaType:D.string(),filename:D.string().optional(),providerOptions:N0.optional()}),D.object({type:D.literal("file-url"),url:D.string(),providerOptions:N0.optional()}),D.object({type:D.literal("file-id"),fileId:D.union([D.string(),D.record(D.string(),D.string())]),providerOptions:N0.optional()}),D.object({type:D.literal("image-data"),data:D.string(),mediaType:D.string(),providerOptions:N0.optional()}),D.object({type:D.literal("image-url"),url:D.string(),providerOptions:N0.optional()}),D.object({type:D.literal("image-file-id"),fileId:D.union([D.string(),D.record(D.string(),D.string())]),providerOptions:N0.optional()}),D.object({type:D.literal("custom"),providerOptions:N0.optional()})]))})]),mT=D.object({type:D.literal("tool-result"),toolCallId:D.string(),toolName:D.string(),output:pt,providerOptions:N0.optional()}),ct=D.object({type:D.literal("tool-approval-request"),approvalId:D.string(),toolCallId:D.string()}),it=D.object({type:D.literal("tool-approval-response"),approvalId:D.string(),approved:D.boolean(),reason:D.string().optional()}),nt=D.object({role:D.literal("system"),content:D.string(),providerOptions:N0.optional()}),ot=D.object({role:D.literal("user"),content:D.union([D.string(),D.array(D.union([gT,mt,uT]))]),providerOptions:N0.optional()}),st=D.object({role:D.literal("assistant"),content:D.union([D.string(),D.array(D.union([gT,uT,lt,dt,mT,ct]))]),providerOptions:N0.optional()}),rt=D.object({role:D.literal("tool"),content:D.array(D.union([mT,it])),providerOptions:N0.optional()}),at=D.union([nt,ot,st,rt]);async function KH($){if($.prompt==null&&$.messages==null)throw new yZ({prompt:$,message:"prompt or messages must be defined"});if($.prompt!=null&&$.messages!=null)throw new yZ({prompt:$,message:"prompt and messages cannot be defined at the same time"});if($.system!=null&&typeof $.system!=="string"&&!y5($.system).every((Y)=>typeof Y==="object"&&Y!==null&&("role"in Y)&&Y.role==="system"))throw new yZ({prompt:$,message:"system must be a string, SystemModelMessage, or array of SystemModelMessage"});let Z;if($.prompt!=null&&typeof $.prompt==="string")Z=[{role:"user",content:$.prompt}];else if($.prompt!=null&&Array.isArray($.prompt))Z=$.prompt;else if($.messages!=null)Z=$.messages;else throw new yZ({prompt:$,message:"prompt or messages must be defined"});if(Z.length===0)throw new yZ({prompt:$,message:"messages must not be empty"});let J=await y8({value:Z,schema:D.array(at)});if(!J.success)throw new yZ({prompt:$,message:"The messages do not match the ModelMessage[] schema.",cause:J.error});return{messages:Z,system:$.system}}function VH($){if(!pL.isInstance($))return $;let Z=(process==null?void 0:"test")==="production",J="https://ai-sdk.dev/unauthenticated-ai-gateway";if(Z)return new p0({name:"GatewayError",message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${J}`});return Object.assign(Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
526
-
527
- To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
528
-
529
- Alternatively, you can use a provider module instead of the AI Gateway.
530
-
531
- Learn more: \x1B[34m${J}\x1B[0m
532
-
533
- `),{name:"GatewayAuthenticationError"})}function x5({operationId:$,telemetry:Z}){return{"operation.name":`${$}${(Z==null?void 0:Z.functionId)!=null?` ${Z.functionId}`:""}`,"resource.name":Z==null?void 0:Z.functionId,"ai.operationId":$,"ai.telemetry.functionId":Z==null?void 0:Z.functionId}}function UH({model:$,settings:Z,telemetry:J,headers:Y}){var X;return{"ai.model.provider":$.provider,"ai.model.id":$.modelId,...Object.entries(Z).reduce((Q,[G,W])=>{if(G==="timeout"){let K=kT(W);if(K!=null)Q[`ai.settings.${G}`]=K}else Q[`ai.settings.${G}`]=W;return Q},{}),...Object.entries((X=J==null?void 0:J.metadata)!=null?X:{}).reduce((Q,[G,W])=>{return Q[`ai.telemetry.metadata.${G}`]=W,Q},{}),...Object.entries(Y!=null?Y:{}).reduce((Q,[G,W])=>{if(W!==void 0)Q[`ai.request.headers.${G}`]=W;return Q},{})}}var tt={startSpan(){return B4},startActiveSpan($,Z,J,Y){if(typeof Z==="function")return Z(B4);if(typeof J==="function")return J(B4);if(typeof Y==="function")return Y(B4)}},B4={spanContext(){return et},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},et={traceId:"",spanId:"",traceFlags:0};function HH({isEnabled:$=!1,tracer:Z}={}){if(!$)return tt;if(Z)return Z;return lT.trace.getTracer("ai")}async function h5({name:$,tracer:Z,attributes:J,fn:Y,endWhenDone:X=!0}){return Z.startActiveSpan($,{attributes:await J},async(Q)=>{let G=zJ.context.active();try{let W=await zJ.context.with(G,()=>Y(Q));if(X)Q.end();return W}catch(W){try{dT(Q,W)}finally{Q.end()}throw W}})}function dT($,Z){if(Z instanceof Error)$.recordException({name:Z.name,message:Z.message,stack:Z.stack}),$.setStatus({code:zJ.SpanStatusCode.ERROR,message:Z.message});else $.setStatus({code:zJ.SpanStatusCode.ERROR})}async function s$({telemetry:$,attributes:Z}){if(($==null?void 0:$.isEnabled)!==!0)return{};let J={};for(let[Y,X]of Object.entries(Z)){if(X==null)continue;if(typeof X==="object"&&"input"in X&&typeof X.input==="function"){if(($==null?void 0:$.recordInputs)===!1)continue;let Q=await X.input();if(Q!=null)J[Y]=Q;continue}if(typeof X==="object"&&"output"in X&&typeof X.output==="function"){if(($==null?void 0:$.recordOutputs)===!1)continue;let Q=await X.output();if(Q!=null)J[Y]=Q;continue}J[Y]=X}return J}function BH($){return JSON.stringify($.map((Z)=>({...Z,content:typeof Z.content==="string"?Z.content:Z.content.map((J)=>J.type==="file"?{...J,data:J.data instanceof Uint8Array?vt(J.data):J.data}:J)})))}function $e(){var $;return($=globalThis.AI_SDK_TELEMETRY_INTEGRATIONS)!=null?$:[]}function Ze(){let $=$e();return(Z)=>{let J=y5(Z),Y=[...$,...J];function X(Q){let G=Y.map(Q).filter(Boolean);return async(W)=>{for(let K of G)try{await K(W)}catch(V){}}}return{onStart:X((Q)=>Q.onStart),onStepStart:X((Q)=>Q.onStepStart),onToolCallStart:X((Q)=>Q.onToolCallStart),onToolCallFinish:X((Q)=>Q.onToolCallFinish),onStepFinish:X((Q)=>Q.onStepFinish),onFinish:X((Q)=>Q.onFinish)}}}function q4($){return{inputTokens:$.inputTokens.total,inputTokenDetails:{noCacheTokens:$.inputTokens.noCache,cacheReadTokens:$.inputTokens.cacheRead,cacheWriteTokens:$.inputTokens.cacheWrite},outputTokens:$.outputTokens.total,outputTokenDetails:{textTokens:$.outputTokens.text,reasoningTokens:$.outputTokens.reasoning},totalTokens:t8($.inputTokens.total,$.outputTokens.total),raw:$.raw,reasoningTokens:$.outputTokens.reasoning,cachedInputTokens:$.inputTokens.cacheRead}}function F4(){return{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}}function Je($,Z){var J,Y,X,Q,G,W,K,V,U,H;return{inputTokens:t8($.inputTokens,Z.inputTokens),inputTokenDetails:{noCacheTokens:t8((J=$.inputTokenDetails)==null?void 0:J.noCacheTokens,(Y=Z.inputTokenDetails)==null?void 0:Y.noCacheTokens),cacheReadTokens:t8((X=$.inputTokenDetails)==null?void 0:X.cacheReadTokens,(Q=Z.inputTokenDetails)==null?void 0:Q.cacheReadTokens),cacheWriteTokens:t8((G=$.inputTokenDetails)==null?void 0:G.cacheWriteTokens,(W=Z.inputTokenDetails)==null?void 0:W.cacheWriteTokens)},outputTokens:t8($.outputTokens,Z.outputTokens),outputTokenDetails:{textTokens:t8((K=$.outputTokenDetails)==null?void 0:K.textTokens,(V=Z.outputTokenDetails)==null?void 0:V.textTokens),reasoningTokens:t8((U=$.outputTokenDetails)==null?void 0:U.reasoningTokens,(H=Z.outputTokenDetails)==null?void 0:H.reasoningTokens)},totalTokens:t8($.totalTokens,Z.totalTokens),reasoningTokens:t8($.reasoningTokens,Z.reasoningTokens),cachedInputTokens:t8($.cachedInputTokens,Z.cachedInputTokens)}}function t8($,Z){return $==null&&Z==null?void 0:($!=null?$:0)+(Z!=null?Z:0)}function zH($,Z){if($===void 0&&Z===void 0)return;if($===void 0)return Z;if(Z===void 0)return $;let J={...$};for(let Y in Z)if(Object.prototype.hasOwnProperty.call(Z,Y)){let X=Z[Y];if(X===void 0)continue;let Q=Y in $?$[Y]:void 0,G=X!==null&&typeof X==="object"&&!Array.isArray(X)&&!(X instanceof Date)&&!(X instanceof RegExp),W=Q!==null&&Q!==void 0&&typeof Q==="object"&&!Array.isArray(Q)&&!(Q instanceof Date)&&!(Q instanceof RegExp);if(G&&W)J[Y]=zH(Q,X);else J[Y]=X}return J}function Ye({error:$,exponentialBackoffDelay:Z}){let J=$.responseHeaders;if(!J)return Z;let Y,X=J["retry-after-ms"];if(X){let G=parseFloat(X);if(!Number.isNaN(G))Y=G}let Q=J["retry-after"];if(Q&&Y===void 0){let G=parseFloat(Q);if(!Number.isNaN(G))Y=G*1000;else Y=Date.parse(Q)-Date.now()}if(Y!=null&&!Number.isNaN(Y)&&0<=Y&&(Y<60000||Y<Z))return Y;return Z}var Xe=({maxRetries:$=2,initialDelayInMs:Z=2000,backoffFactor:J=2,abortSignal:Y}={})=>async(X)=>pT(X,{maxRetries:$,delayInMs:Z,backoffFactor:J,abortSignal:Y});async function pT($,{maxRetries:Z,delayInMs:J,backoffFactor:Y,abortSignal:X},Q=[]){try{return await $()}catch(G){if(N4(G))throw G;if(Z===0)throw G;let W=AX(G),K=[...Q,G],V=K.length;if(V>Z)throw new O4({message:`Failed after ${V} attempts. Last error: ${W}`,reason:"maxRetriesExceeded",errors:K});if(G instanceof Error&&FX.isInstance(G)&&G.isRetryable===!0&&V<=Z)return await xL(Ye({error:G,exponentialBackoffDelay:J}),{abortSignal:X}),pT($,{maxRetries:Z,delayInMs:Y*J,backoffFactor:Y,abortSignal:X},K);if(V===1)throw G;throw new O4({message:`Failed after ${V} attempts with non-retryable error: '${W}'`,reason:"errorNotRetryable",errors:K})}}function FH({maxRetries:$,abortSignal:Z}){if($!=null){if(!Number.isInteger($))throw new r1({parameter:"maxRetries",value:$,message:"maxRetries must be an integer"});if($<0)throw new r1({parameter:"maxRetries",value:$,message:"maxRetries must be >= 0"})}let J=$!=null?$:2;return{maxRetries:J,retry:Xe({maxRetries:J,abortSignal:Z})}}function Qe({messages:$}){let Z=$.at(-1);if((Z==null?void 0:Z.role)!="tool")return{approvedToolApprovals:[],deniedToolApprovals:[]};let J={};for(let K of $)if(K.role==="assistant"&&typeof K.content!=="string"){let V=K.content;for(let U of V)if(U.type==="tool-call")J[U.toolCallId]=U}let Y={};for(let K of $)if(K.role==="assistant"&&typeof K.content!=="string"){let V=K.content;for(let U of V)if(U.type==="tool-approval-request")Y[U.approvalId]=U}let X={};for(let K of Z.content)if(K.type==="tool-result")X[K.toolCallId]=K;let Q=[],G=[],W=Z.content.filter((K)=>K.type==="tool-approval-response");for(let K of W){let V=Y[K.approvalId];if(V==null)throw new ha({approvalId:K.approvalId});if(X[V.toolCallId]!=null)continue;let U=J[V.toolCallId];if(U==null)throw new XT({toolCallId:V.toolCallId,approvalId:V.approvalId});let H={approvalRequest:V,approvalResponse:K,toolCall:U};if(K.approved)Q.push(H);else G.push(H)}return{approvedToolApprovals:Q,deniedToolApprovals:G}}function VX(){var $,Z;return(Z=($=globalThis==null?void 0:globalThis.performance)==null?void 0:$.now())!=null?Z:Date.now()}async function cT({toolCall:$,tools:Z,tracer:J,telemetry:Y,messages:X,abortSignal:Q,experimental_context:G,stepNumber:W,model:K,onPreliminaryToolResult:V,onToolCallStart:U,onToolCallFinish:H}){let{toolName:B,toolCallId:z,input:F}=$,A=Z==null?void 0:Z[B];if((A==null?void 0:A.execute)==null)return;let j={stepNumber:W,model:K,toolCall:$,messages:X,abortSignal:Q,functionId:Y==null?void 0:Y.functionId,metadata:Y==null?void 0:Y.metadata,experimental_context:G};return h5({name:"ai.toolCall",attributes:s$({telemetry:Y,attributes:{...x5({operationId:"ai.toolCall",telemetry:Y}),"ai.toolCall.name":B,"ai.toolCall.id":z,"ai.toolCall.args":{output:()=>JSON.stringify(F)}}}),tracer:J,fn:async(N)=>{let L;await v5({event:j,callbacks:U});let q=VX();try{let C=dL({execute:A.execute.bind(A),input:F,options:{toolCallId:z,messages:X,abortSignal:Q,experimental_context:G}});for await(let R of C)if(R.type==="preliminary")V==null||V({...$,type:"tool-result",output:R.output,preliminary:!0});else L=R.output}catch(C){let R=VX()-q;return await v5({event:{...j,success:!1,error:C,durationMs:R},callbacks:H}),dT(N,C),{type:"tool-error",toolCallId:z,toolName:B,input:F,error:C,dynamic:A.type==="dynamic",...$.providerMetadata!=null?{providerMetadata:$.providerMetadata}:{}}}let M=VX()-q;await v5({event:{...j,success:!0,output:L,durationMs:M},callbacks:H});try{N.setAttributes(await s$({telemetry:Y,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(L)}}}))}catch(C){}return{type:"tool-result",toolCallId:z,toolName:B,input:F,output:L,dynamic:A.type==="dynamic",...$.providerMetadata!=null?{providerMetadata:$.providerMetadata}:{}}}})}function Ge($){let Z=$.filter((J)=>J.type==="reasoning");return Z.length===0?void 0:Z.map((J)=>J.text).join(`
534
- `)}function We($){let Z=$.filter((J)=>J.type==="text");if(Z.length===0)return;return Z.map((J)=>J.text).join("")}var Ke=class{constructor({data:$,mediaType:Z}){let J=$ instanceof Uint8Array;this.base64Data=J?void 0:$,this.uint8ArrayData=J?$:void 0,this.mediaType=Z}get base64(){if(this.base64Data==null)this.base64Data=HX(this.uint8ArrayData);return this.base64Data}get uint8Array(){if(this.uint8ArrayData==null)this.uint8ArrayData=FJ(this.base64Data);return this.uint8ArrayData}},Ve=class extends Ke{constructor($){super($);this.type="file"}};async function Ue({tool:$,toolCall:Z,messages:J,experimental_context:Y}){if($.needsApproval==null)return!1;if(typeof $.needsApproval==="boolean")return $.needsApproval;return await $.needsApproval(Z.input,{toolCallId:Z.toolCallId,messages:J,experimental_context:Y})}var He={};_a(He,{array:()=>Fe,choice:()=>Ae,json:()=>Oe,object:()=>ze,text:()=>eU});function Be($){let Z=["ROOT"],J=-1,Y=null;function X(K,V,U){switch(K){case'"':{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_STRING");break}case"f":case"t":case"n":{J=V,Y=V,Z.pop(),Z.push(U),Z.push("INSIDE_LITERAL");break}case"-":{Z.pop(),Z.push(U),Z.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_NUMBER");break}case"{":{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_OBJECT_START");break}case"[":{J=V,Z.pop(),Z.push(U),Z.push("INSIDE_ARRAY_START");break}}}function Q(K,V){switch(K){case",":{Z.pop(),Z.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{J=V,Z.pop();break}}}function G(K,V){switch(K){case",":{Z.pop(),Z.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{J=V,Z.pop();break}}}for(let K=0;K<$.length;K++){let V=$[K];switch(Z[Z.length-1]){case"ROOT":X(V,K,"FINISH");break;case"INSIDE_OBJECT_START":{switch(V){case'"':{Z.pop(),Z.push("INSIDE_OBJECT_KEY");break}case"}":{J=K,Z.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(V){case'"':{Z.pop(),Z.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(V){case'"':{Z.pop(),Z.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(V){case":":{Z.pop(),Z.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{X(V,K,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{Q(V,K);break}case"INSIDE_STRING":{switch(V){case'"':{Z.pop(),J=K;break}case"\\":{Z.push("INSIDE_STRING_ESCAPE");break}default:J=K}break}case"INSIDE_ARRAY_START":{switch(V){case"]":{J=K,Z.pop();break}default:{J=K,X(V,K,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(V){case",":{Z.pop(),Z.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{J=K,Z.pop();break}default:{J=K;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{X(V,K,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{Z.pop(),J=K;break}case"INSIDE_NUMBER":{switch(V){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{J=K;break}case"e":case"E":case"-":case".":break;case",":{if(Z.pop(),Z[Z.length-1]==="INSIDE_ARRAY_AFTER_VALUE")G(V,K);if(Z[Z.length-1]==="INSIDE_OBJECT_AFTER_VALUE")Q(V,K);break}case"}":{if(Z.pop(),Z[Z.length-1]==="INSIDE_OBJECT_AFTER_VALUE")Q(V,K);break}case"]":{if(Z.pop(),Z[Z.length-1]==="INSIDE_ARRAY_AFTER_VALUE")G(V,K);break}default:{Z.pop();break}}break}case"INSIDE_LITERAL":{let H=$.substring(Y,K+1);if(!"false".startsWith(H)&&!"true".startsWith(H)&&!"null".startsWith(H)){if(Z.pop(),Z[Z.length-1]==="INSIDE_OBJECT_AFTER_VALUE")Q(V,K);else if(Z[Z.length-1]==="INSIDE_ARRAY_AFTER_VALUE")G(V,K)}else J=K;break}}}let W=$.slice(0,J+1);for(let K=Z.length-1;K>=0;K--)switch(Z[K]){case"INSIDE_STRING":{W+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{W+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{W+="]";break}case"INSIDE_LITERAL":{let U=$.substring(Y,$.length);if("true".startsWith(U))W+="true".slice(U.length);else if("false".startsWith(U))W+="false".slice(U.length);else if("null".startsWith(U))W+="null".slice(U.length)}}return W}async function AJ($){if($===void 0)return{value:void 0,state:"undefined-input"};let Z=await G8({text:$});if(Z.success)return{value:Z.value,state:"successful-parse"};if(Z=await G8({text:Be($)}),Z.success)return{value:Z.value,state:"repaired-parse"};return{value:void 0,state:"failed-parse"}}var eU=()=>({name:"text",responseFormat:Promise.resolve({type:"text"}),async parseCompleteOutput({text:$}){return $},async parsePartialOutput({text:$}){return{partial:$}},createElementStreamTransform(){return}}),ze=({schema:$,name:Z,description:J})=>{let Y=v8($);return{name:"object",responseFormat:QH(Y.jsonSchema).then((X)=>({type:"json",schema:X,...Z!=null&&{name:Z},...J!=null&&{description:J}})),async parseCompleteOutput({text:X},Q){let G=await G8({text:X});if(!G.success)throw new E8({message:"No object generated: could not parse the response.",cause:G.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});let W=await y8({value:G.value,schema:Y});if(!W.success)throw new E8({message:"No object generated: response did not match schema.",cause:W.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});return W.value},async parsePartialOutput({text:X}){let Q=await AJ(X);switch(Q.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:Q.value}}},createElementStreamTransform(){return}}},Fe=({element:$,name:Z,description:J})=>{let Y=v8($);return{name:"array",responseFormat:QH(Y.jsonSchema).then((X)=>{let{$schema:Q,...G}=X;return{type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:G}},required:["elements"],additionalProperties:!1},...Z!=null&&{name:Z},...J!=null&&{description:J}}}),async parseCompleteOutput({text:X},Q){let G=await G8({text:X});if(!G.success)throw new E8({message:"No object generated: could not parse the response.",cause:G.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});let W=G.value;if(W==null||typeof W!=="object"||!("elements"in W)||!Array.isArray(W.elements))throw new E8({message:"No object generated: response did not match schema.",cause:new C8({value:W,cause:"response must be an object with an elements array"}),text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason});for(let K of W.elements){let V=await y8({value:K,schema:Y});if(!V.success)throw new E8({message:"No object generated: response did not match schema.",cause:V.error,text:X,response:Q.response,usage:Q.usage,finishReason:Q.finishReason})}return W.elements},async parsePartialOutput({text:X}){let Q=await AJ(X);switch(Q.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{let G=Q.value;if(G==null||typeof G!=="object"||!("elements"in G)||!Array.isArray(G.elements))return;let W=Q.state==="repaired-parse"&&G.elements.length>0?G.elements.slice(0,-1):G.elements,K=[];for(let V of W){let U=await y8({value:V,schema:Y});if(U.success)K.push(U.value)}return{partial:K}}}},createElementStreamTransform(){let X=0;return new TransformStream({transform({partialOutput:Q},G){if(Q!=null)for(;X<Q.length;X++)G.enqueue(Q[X])}})}}},Ae=({options:$,name:Z,description:J})=>{return{name:"choice",responseFormat:Promise.resolve({type:"json",schema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:$}},required:["result"],additionalProperties:!1},...Z!=null&&{name:Z},...J!=null&&{description:J}}),async parseCompleteOutput({text:Y},X){let Q=await G8({text:Y});if(!Q.success)throw new E8({message:"No object generated: could not parse the response.",cause:Q.error,text:Y,response:X.response,usage:X.usage,finishReason:X.finishReason});let G=Q.value;if(G==null||typeof G!=="object"||!("result"in G)||typeof G.result!=="string"||!$.includes(G.result))throw new E8({message:"No object generated: response did not match schema.",cause:new C8({value:G,cause:"response must be an object that contains a choice value."}),text:Y,response:X.response,usage:X.usage,finishReason:X.finishReason});return G.result},async parsePartialOutput({text:Y}){let X=await AJ(Y);switch(X.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":{let Q=X.value;if(Q==null||typeof Q!=="object"||!("result"in Q)||typeof Q.result!=="string")return;let G=$.filter((W)=>W.startsWith(Q.result));if(X.state==="successful-parse")return G.includes(Q.result)?{partial:Q.result}:void 0;else return G.length===1?{partial:G[0]}:void 0}}},createElementStreamTransform(){return}}},Oe=({name:$,description:Z}={})=>{return{name:"json",responseFormat:Promise.resolve({type:"json",...$!=null&&{name:$},...Z!=null&&{description:Z}}),async parseCompleteOutput({text:J},Y){let X=await G8({text:J});if(!X.success)throw new E8({message:"No object generated: could not parse the response.",cause:X.error,text:J,response:Y.response,usage:Y.usage,finishReason:Y.finishReason});return X.value},async parsePartialOutput({text:J}){let Y=await AJ(J);switch(Y.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return Y.value===void 0?void 0:{partial:Y.value}}},createElementStreamTransform(){return}}};async function qe({toolCall:$,tools:Z,repairToolCall:J,system:Y,messages:X}){var Q;try{if(Z==null){if($.providerExecuted&&$.dynamic)return await iT($);throw new tU({toolName:$.toolName})}try{return await _L({toolCall:$,tools:Z})}catch(G){if(J==null||!(tU.isInstance(G)||GH.isInstance(G)))throw G;let W=null;try{W=await J({toolCall:$,tools:Z,inputSchema:async({toolName:K})=>{let{inputSchema:V}=Z[K];return await v8(V).jsonSchema},system:Y,messages:X,error:G})}catch(K){throw new Vt({cause:K,originalError:G})}if(W==null)throw G;return await _L({toolCall:W,tools:Z})}}catch(G){let W=await G8({text:$.input}),K=W.success?W.value:$.input;return{type:"tool-call",toolCallId:$.toolCallId,toolName:$.toolName,input:K,dynamic:!0,invalid:!0,error:G,title:(Q=Z==null?void 0:Z[$.toolName])==null?void 0:Q.title,providerExecuted:$.providerExecuted,providerMetadata:$.providerMetadata}}}async function iT($){let Z=$.input.trim()===""?{success:!0,value:{}}:await G8({text:$.input});if(Z.success===!1)throw new GH({toolName:$.toolName,toolInput:$.input,cause:Z.error});return{type:"tool-call",toolCallId:$.toolCallId,toolName:$.toolName,input:Z.value,providerExecuted:!0,dynamic:!0,providerMetadata:$.providerMetadata}}async function _L({toolCall:$,tools:Z}){let J=$.toolName,Y=Z[J];if(Y==null){if($.providerExecuted&&$.dynamic)return await iT($);throw new tU({toolName:$.toolName,availableTools:Object.keys(Z)})}let X=v8(Y.inputSchema),Q=$.input.trim()===""?await y8({value:{},schema:X}):await G8({text:$.input,schema:X});if(Q.success===!1)throw new GH({toolName:J,toolInput:$.input,cause:Q.error});return Y.type==="dynamic"?{type:"tool-call",toolCallId:$.toolCallId,toolName:$.toolName,input:Q.value,providerExecuted:$.providerExecuted,providerMetadata:$.providerMetadata,dynamic:!0,title:Y.title}:{type:"tool-call",toolCallId:$.toolCallId,toolName:J,input:Q.value,providerExecuted:$.providerExecuted,providerMetadata:$.providerMetadata,title:Y.title}}var je=class{constructor({stepNumber:$,model:Z,functionId:J,metadata:Y,experimental_context:X,content:Q,finishReason:G,rawFinishReason:W,usage:K,warnings:V,request:U,response:H,providerMetadata:B}){this.stepNumber=$,this.model=Z,this.functionId=J,this.metadata=Y,this.experimental_context=X,this.content=Q,this.finishReason=G,this.rawFinishReason=W,this.usage=K,this.warnings=V,this.request=U,this.response=H,this.providerMetadata=B}get text(){return this.content.filter(($)=>$.type==="text").map(($)=>$.text).join("")}get reasoning(){return this.content.filter(($)=>$.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(($)=>$.text).join("")}get files(){return this.content.filter(($)=>$.type==="file").map(($)=>$.file)}get sources(){return this.content.filter(($)=>$.type==="source")}get toolCalls(){return this.content.filter(($)=>$.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(($)=>$.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(($)=>$.dynamic===!0)}get toolResults(){return this.content.filter(($)=>$.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(($)=>$.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(($)=>$.dynamic===!0)}};function Ne($){return({steps:Z})=>Z.length===$}async function Me({stopConditions:$,steps:Z}){return(await Promise.all($.map((J)=>J({steps:Z})))).some((J)=>J)}async function SL({content:$,tools:Z}){let J=[],Y=[];for(let Q of $){if(Q.type==="source")continue;if((Q.type==="tool-result"||Q.type==="tool-error")&&!Q.providerExecuted)continue;if(Q.type==="text"&&Q.text.length===0)continue;switch(Q.type){case"text":Y.push({type:"text",text:Q.text,providerOptions:Q.providerMetadata});break;case"reasoning":Y.push({type:"reasoning",text:Q.text,providerOptions:Q.providerMetadata});break;case"file":Y.push({type:"file",data:Q.file.base64,mediaType:Q.file.mediaType,providerOptions:Q.providerMetadata});break;case"tool-call":Y.push({type:"tool-call",toolCallId:Q.toolCallId,toolName:Q.toolName,input:Q.invalid&&typeof Q.input!=="object"?{}:Q.input,providerExecuted:Q.providerExecuted,providerOptions:Q.providerMetadata});break;case"tool-result":{let G=await BJ({toolCallId:Q.toolCallId,input:Q.input,tool:Z==null?void 0:Z[Q.toolName],output:Q.output,errorMode:"none"});Y.push({type:"tool-result",toolCallId:Q.toolCallId,toolName:Q.toolName,output:G,providerOptions:Q.providerMetadata});break}case"tool-error":{let G=await BJ({toolCallId:Q.toolCallId,input:Q.input,tool:Z==null?void 0:Z[Q.toolName],output:Q.error,errorMode:"json"});Y.push({type:"tool-result",toolCallId:Q.toolCallId,toolName:Q.toolName,output:G,providerOptions:Q.providerMetadata});break}case"tool-approval-request":Y.push({type:"tool-approval-request",approvalId:Q.approvalId,toolCallId:Q.toolCall.toolCallId});break}}if(Y.length>0)J.push({role:"assistant",content:Y});let X=[];for(let Q of $){if(!(Q.type==="tool-result"||Q.type==="tool-error")||Q.providerExecuted)continue;let G=await BJ({toolCallId:Q.toolCallId,input:Q.input,tool:Z==null?void 0:Z[Q.toolName],output:Q.type==="tool-result"?Q.output:Q.error,errorMode:Q.type==="tool-error"?"text":"none"});X.push({type:"tool-result",toolCallId:Q.toolCallId,toolName:Q.toolName,output:G,...Q.providerMetadata!=null?{providerOptions:Q.providerMetadata}:{}})}if(X.length>0)J.push({role:"tool",content:X});return J}function De(...$){let Z=$.filter((Y)=>Y!=null);if(Z.length===0)return;if(Z.length===1)return Z[0];let J=new AbortController;for(let Y of Z){if(Y.aborted)return J.abort(Y.reason),J.signal;Y.addEventListener("abort",()=>{J.abort(Y.reason)},{once:!0})}return J.signal}var pb0=a6({prefix:"aitxt",size:24});function jX($,Z){let J=new Headers($!=null?$:{});for(let[Y,X]of Object.entries(Z))if(!J.has(Y))J.set(Y,X);return J}function nT({status:$,statusText:Z,headers:J,textStream:Y}){return new Response(Y.pipeThrough(new TextEncoderStream),{status:$!=null?$:200,statusText:Z,headers:jX(J,{"content-type":"text/plain; charset=utf-8"})})}function oT({response:$,status:Z,statusText:J,headers:Y,stream:X}){let Q=Z!=null?Z:200;if(J!==void 0)$.writeHead(Q,J,Y);else $.writeHead(Q,Y);let G=X.getReader();(async()=>{try{while(!0){let{done:K,value:V}=await G.read();if(K)break;if(!$.write(V))await new Promise((H)=>{$.once("drain",H)})}}catch(K){throw K}finally{$.end()}})()}function sT({response:$,status:Z,statusText:J,headers:Y,textStream:X}){oT({response:$,status:Z,statusText:J,headers:Object.fromEntries(jX(Y,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:X.pipeThrough(new TextEncoderStream)})}var rT=class extends TransformStream{constructor(){super({transform($,Z){Z.enqueue(`data: ${JSON.stringify($)}
535
-
536
- `)},flush($){$.enqueue(`data: [DONE]
537
-
538
- `)}})}},aT={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function we({status:$,statusText:Z,headers:J,stream:Y,consumeSseStream:X}){let Q=Y.pipeThrough(new rT);if(X){let[G,W]=Q.tee();Q=G,X({stream:W})}return new Response(Q.pipeThrough(new TextEncoderStream),{status:$,statusText:Z,headers:jX(J,aT)})}function Le({originalMessages:$,responseMessageId:Z}){if($==null)return;let J=$[$.length-1];return(J==null?void 0:J.role)==="assistant"?J.id:typeof Z==="function"?Z():Z}var rb0=M4(()=>qX(D.union([D.strictObject({type:D.literal("text-start"),id:D.string(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("text-delta"),id:D.string(),delta:D.string(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("text-end"),id:D.string(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("error"),errorText:D.string()}),D.strictObject({type:D.literal("tool-input-start"),toolCallId:D.string(),toolName:D.string(),providerExecuted:D.boolean().optional(),providerMetadata:N0.optional(),dynamic:D.boolean().optional(),title:D.string().optional()}),D.strictObject({type:D.literal("tool-input-delta"),toolCallId:D.string(),inputTextDelta:D.string()}),D.strictObject({type:D.literal("tool-input-available"),toolCallId:D.string(),toolName:D.string(),input:D.unknown(),providerExecuted:D.boolean().optional(),providerMetadata:N0.optional(),dynamic:D.boolean().optional(),title:D.string().optional()}),D.strictObject({type:D.literal("tool-input-error"),toolCallId:D.string(),toolName:D.string(),input:D.unknown(),providerExecuted:D.boolean().optional(),providerMetadata:N0.optional(),dynamic:D.boolean().optional(),errorText:D.string(),title:D.string().optional()}),D.strictObject({type:D.literal("tool-approval-request"),approvalId:D.string(),toolCallId:D.string()}),D.strictObject({type:D.literal("tool-output-available"),toolCallId:D.string(),output:D.unknown(),providerExecuted:D.boolean().optional(),providerMetadata:N0.optional(),dynamic:D.boolean().optional(),preliminary:D.boolean().optional()}),D.strictObject({type:D.literal("tool-output-error"),toolCallId:D.string(),errorText:D.string(),providerExecuted:D.boolean().optional(),providerMetadata:N0.optional(),dynamic:D.boolean().optional()}),D.strictObject({type:D.literal("tool-output-denied"),toolCallId:D.string()}),D.strictObject({type:D.literal("reasoning-start"),id:D.string(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("reasoning-delta"),id:D.string(),delta:D.string(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("reasoning-end"),id:D.string(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("source-url"),sourceId:D.string(),url:D.string(),title:D.string().optional(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("source-document"),sourceId:D.string(),mediaType:D.string(),title:D.string(),filename:D.string().optional(),providerMetadata:N0.optional()}),D.strictObject({type:D.literal("file"),url:D.string(),mediaType:D.string(),providerMetadata:N0.optional()}),D.strictObject({type:D.custom(($)=>typeof $==="string"&&$.startsWith("data-"),{message:'Type must start with "data-"'}),id:D.string().optional(),data:D.unknown(),transient:D.boolean().optional()}),D.strictObject({type:D.literal("start-step")}),D.strictObject({type:D.literal("finish-step")}),D.strictObject({type:D.literal("start"),messageId:D.string().optional(),messageMetadata:D.unknown().optional()}),D.strictObject({type:D.literal("finish"),finishReason:D.enum(["stop","length","content-filter","tool-calls","error","other"]).optional(),messageMetadata:D.unknown().optional()}),D.strictObject({type:D.literal("abort"),reason:D.string().optional()}),D.strictObject({type:D.literal("message-metadata"),messageMetadata:D.unknown()})])));function Te($){return $.type.startsWith("data-")}function iU($){return $.type.startsWith("data-")}function nU($){return $.type==="text"}function oU($){return $.type==="file"}function fL($){return $.type==="reasoning"}function $H($){return $.type.startsWith("tool-")}function tT($){return $.type==="dynamic-tool"}function HJ($){return $H($)||tT($)}function ZH($){return $.type.split("-").slice(1).join("-")}function sU($){return tT($)?$.toolName:ZH($)}function Re({lastMessage:$,messageId:Z}){return{message:($==null?void 0:$.role)==="assistant"?$:{id:Z,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Pe({stream:$,messageMetadataSchema:Z,dataPartSchemas:J,runUpdateMessageJob:Y,onError:X,onToolCall:Q,onData:G}){return $.pipeThrough(new TransformStream({async transform(W,K){await Y(async({state:V,write:U})=>{var H,B,z,F;function A(q){let C=V.message.parts.filter(HJ).find((R)=>R.toolCallId===q);if(C==null)throw new UJ({chunkType:"tool-invocation",chunkId:q,message:`No tool invocation found for tool call ID "${q}".`});return C}function j(q){var M;let C=V.message.parts.find((I)=>$H(I)&&I.toolCallId===q.toolCallId),R=q,w=C;if(C!=null){if(C.state=q.state,w.input=R.input,w.output=R.output,w.errorText=R.errorText,w.rawInput=R.rawInput,w.preliminary=R.preliminary,q.title!==void 0)w.title=q.title;w.providerExecuted=(M=R.providerExecuted)!=null?M:C.providerExecuted;let I=R.providerMetadata;if(I!=null)if(q.state==="output-available"||q.state==="output-error"){let _=C;_.resultProviderMetadata=I}else C.callProviderMetadata=I}else V.message.parts.push({type:`tool-${q.toolName}`,toolCallId:q.toolCallId,state:q.state,title:q.title,input:R.input,output:R.output,rawInput:R.rawInput,errorText:R.errorText,providerExecuted:R.providerExecuted,preliminary:R.preliminary,...R.providerMetadata!=null&&(q.state==="output-available"||q.state==="output-error")?{resultProviderMetadata:R.providerMetadata}:{},...R.providerMetadata!=null&&!(q.state==="output-available"||q.state==="output-error")?{callProviderMetadata:R.providerMetadata}:{}})}function N(q){var M,C;let R=V.message.parts.find((_)=>_.type==="dynamic-tool"&&_.toolCallId===q.toolCallId),w=q,I=R;if(R!=null){if(R.state=q.state,I.toolName=q.toolName,I.input=w.input,I.output=w.output,I.errorText=w.errorText,I.rawInput=(M=w.rawInput)!=null?M:I.rawInput,I.preliminary=w.preliminary,q.title!==void 0)I.title=q.title;I.providerExecuted=(C=w.providerExecuted)!=null?C:R.providerExecuted;let _=w.providerMetadata;if(_!=null)if(q.state==="output-available"||q.state==="output-error"){let E=R;E.resultProviderMetadata=_}else R.callProviderMetadata=_}else V.message.parts.push({type:"dynamic-tool",toolName:q.toolName,toolCallId:q.toolCallId,state:q.state,input:w.input,output:w.output,errorText:w.errorText,preliminary:w.preliminary,providerExecuted:w.providerExecuted,title:q.title,...w.providerMetadata!=null&&(q.state==="output-available"||q.state==="output-error")?{resultProviderMetadata:w.providerMetadata}:{},...w.providerMetadata!=null&&!(q.state==="output-available"||q.state==="output-error")?{callProviderMetadata:w.providerMetadata}:{}})}async function L(q){if(q!=null){let M=V.message.metadata!=null?zH(V.message.metadata,q):q;if(Z!=null)await A4({value:M,schema:Z,context:{field:"message.metadata",entityId:V.message.id}});V.message.metadata=M}}switch(W.type){case"text-start":{let q={type:"text",text:"",providerMetadata:W.providerMetadata,state:"streaming"};V.activeTextParts[W.id]=q,V.message.parts.push(q),U();break}case"text-delta":{let q=V.activeTextParts[W.id];if(q==null)throw new UJ({chunkType:"text-delta",chunkId:W.id,message:`Received text-delta for missing text part with ID "${W.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});q.text+=W.delta,q.providerMetadata=(H=W.providerMetadata)!=null?H:q.providerMetadata,U();break}case"text-end":{let q=V.activeTextParts[W.id];if(q==null)throw new UJ({chunkType:"text-end",chunkId:W.id,message:`Received text-end for missing text part with ID "${W.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});q.state="done",q.providerMetadata=(B=W.providerMetadata)!=null?B:q.providerMetadata,delete V.activeTextParts[W.id],U();break}case"reasoning-start":{let q={type:"reasoning",text:"",providerMetadata:W.providerMetadata,state:"streaming"};V.activeReasoningParts[W.id]=q,V.message.parts.push(q),U();break}case"reasoning-delta":{let q=V.activeReasoningParts[W.id];if(q==null)throw new UJ({chunkType:"reasoning-delta",chunkId:W.id,message:`Received reasoning-delta for missing reasoning part with ID "${W.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});q.text+=W.delta,q.providerMetadata=(z=W.providerMetadata)!=null?z:q.providerMetadata,U();break}case"reasoning-end":{let q=V.activeReasoningParts[W.id];if(q==null)throw new UJ({chunkType:"reasoning-end",chunkId:W.id,message:`Received reasoning-end for missing reasoning part with ID "${W.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});q.providerMetadata=(F=W.providerMetadata)!=null?F:q.providerMetadata,q.state="done",delete V.activeReasoningParts[W.id],U();break}case"file":{V.message.parts.push({type:"file",mediaType:W.mediaType,url:W.url,...W.providerMetadata!=null?{providerMetadata:W.providerMetadata}:{}}),U();break}case"source-url":{V.message.parts.push({type:"source-url",sourceId:W.sourceId,url:W.url,title:W.title,providerMetadata:W.providerMetadata}),U();break}case"source-document":{V.message.parts.push({type:"source-document",sourceId:W.sourceId,mediaType:W.mediaType,title:W.title,filename:W.filename,providerMetadata:W.providerMetadata}),U();break}case"tool-input-start":{let q=V.message.parts.filter($H);if(V.partialToolCalls[W.toolCallId]={text:"",toolName:W.toolName,index:q.length,dynamic:W.dynamic,title:W.title},W.dynamic)N({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-streaming",input:void 0,providerExecuted:W.providerExecuted,title:W.title,providerMetadata:W.providerMetadata});else j({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-streaming",input:void 0,providerExecuted:W.providerExecuted,title:W.title,providerMetadata:W.providerMetadata});U();break}case"tool-input-delta":{let q=V.partialToolCalls[W.toolCallId];if(q==null)throw new UJ({chunkType:"tool-input-delta",chunkId:W.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${W.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});q.text+=W.inputTextDelta;let{value:M}=await AJ(q.text);if(q.dynamic)N({toolCallId:W.toolCallId,toolName:q.toolName,state:"input-streaming",input:M,title:q.title});else j({toolCallId:W.toolCallId,toolName:q.toolName,state:"input-streaming",input:M,title:q.title});U();break}case"tool-input-available":{if(W.dynamic)N({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-available",input:W.input,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:W.title});else j({toolCallId:W.toolCallId,toolName:W.toolName,state:"input-available",input:W.input,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:W.title});if(U(),Q&&!W.providerExecuted)await Q({toolCall:W});break}case"tool-input-error":{let q=V.message.parts.filter(HJ).find((C)=>C.toolCallId===W.toolCallId);if(q!=null?q.type==="dynamic-tool":!!W.dynamic)N({toolCallId:W.toolCallId,toolName:W.toolName,state:"output-error",input:W.input,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata});else j({toolCallId:W.toolCallId,toolName:W.toolName,state:"output-error",input:void 0,rawInput:W.input,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata});U();break}case"tool-approval-request":{let q=A(W.toolCallId);q.state="approval-requested",q.approval={id:W.approvalId},U();break}case"tool-output-denied":{let q=A(W.toolCallId);q.state="output-denied",U();break}case"tool-output-available":{let q=A(W.toolCallId);if(q.type==="dynamic-tool")N({toolCallId:W.toolCallId,toolName:q.toolName,state:"output-available",input:q.input,output:W.output,preliminary:W.preliminary,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:q.title});else j({toolCallId:W.toolCallId,toolName:ZH(q),state:"output-available",input:q.input,output:W.output,providerExecuted:W.providerExecuted,preliminary:W.preliminary,providerMetadata:W.providerMetadata,title:q.title});U();break}case"tool-output-error":{let q=A(W.toolCallId);if(q.type==="dynamic-tool")N({toolCallId:W.toolCallId,toolName:q.toolName,state:"output-error",input:q.input,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:q.title});else j({toolCallId:W.toolCallId,toolName:ZH(q),state:"output-error",input:q.input,rawInput:q.rawInput,errorText:W.errorText,providerExecuted:W.providerExecuted,providerMetadata:W.providerMetadata,title:q.title});U();break}case"start-step":{V.message.parts.push({type:"step-start"});break}case"finish-step":{V.activeTextParts={},V.activeReasoningParts={};break}case"start":{if(W.messageId!=null)V.message.id=W.messageId;if(await L(W.messageMetadata),W.messageId!=null||W.messageMetadata!=null)U();break}case"finish":{if(W.finishReason!=null)V.finishReason=W.finishReason;if(await L(W.messageMetadata),W.messageMetadata!=null)U();break}case"message-metadata":{if(await L(W.messageMetadata),W.messageMetadata!=null)U();break}case"error":{X==null||X(Error(W.errorText));break}default:if(Te(W)){if((J==null?void 0:J[W.type])!=null){let C=V.message.parts.findIndex((w)=>("id"in w)&&("data"in w)&&w.id===W.id&&w.type===W.type),R=C>=0?C:V.message.parts.length;await A4({value:W.data,schema:J[W.type],context:{field:`message.parts[${R}].data`,entityName:W.type,entityId:W.id}})}let q=W;if(q.transient){G==null||G(q);break}let M=q.id!=null?V.message.parts.find((C)=>q.type===C.type&&q.id===C.id):void 0;if(M!=null)M.data=q.data;else V.message.parts.push(q);G==null||G(q),U()}}K.enqueue(W)})}}))}function Ie({messageId:$,originalMessages:Z=[],onStepFinish:J,onFinish:Y,onError:X,stream:Q}){let G=Z==null?void 0:Z[Z.length-1];if((G==null?void 0:G.role)!=="assistant")G=void 0;else $=G.id;let W=!1,K=Q.pipeThrough(new TransformStream({transform(F,A){if(F.type==="start"){let j=F;if(j.messageId==null&&$!=null)j.messageId=$}if(F.type==="abort")W=!0;A.enqueue(F)}}));if(Y==null&&J==null)return K;let V=Re({lastMessage:G?structuredClone(G):void 0,messageId:$!=null?$:""}),U=async(F)=>{await F({state:V,write:()=>{}})},H=!1,B=async()=>{if(H||!Y)return;H=!0;let F=V.message.id===(G==null?void 0:G.id);await Y({isAborted:W,isContinuation:F,responseMessage:V.message,messages:[...F?Z.slice(0,-1):Z,V.message],finishReason:V.finishReason})},z=async()=>{if(!J)return;let F=V.message.id===(G==null?void 0:G.id);try{await J({isContinuation:F,responseMessage:structuredClone(V.message),messages:[...F?Z.slice(0,-1):Z,structuredClone(V.message)]})}catch(A){X(A)}};return Pe({stream:K,runUpdateMessageJob:U,onError:X}).pipeThrough(new TransformStream({async transform(F,A){if(F.type==="finish-step")await z();A.enqueue(F)},async cancel(){await B()},async flush(){await B()}}))}function Ce({response:$,status:Z,statusText:J,headers:Y,stream:X,consumeSseStream:Q}){let G=X.pipeThrough(new rT);if(Q){let[W,K]=G.tee();G=W,Q({stream:K})}oT({response:$,status:Z,statusText:J,headers:Object.fromEntries(jX(Y,aT).entries()),stream:G.pipeThrough(new TextEncoderStream)})}function s6($){let Z=$.pipeThrough(new TransformStream);return Z[Symbol.asyncIterator]=function(){let J=this.getReader(),Y=!1;async function X(Q){var G;if(Y)return;Y=!0;try{if(Q)await((G=J.cancel)==null?void 0:G.call(J))}finally{try{J.releaseLock()}catch(W){}}}return{async next(){if(Y)return{done:!0,value:void 0};let{done:Q,value:G}=await J.read();if(Q)return await X(!0),{done:!0,value:void 0};return{done:!1,value:G}},async return(){return await X(!0),{done:!0,value:void 0}},async throw(Q){throw await X(!0),Q}}},Z}async function Ee({stream:$,onError:Z}){let J=$.getReader();try{while(!0){let{done:Y}=await J.read();if(Y)break}}catch(Y){Z==null||Z(Y)}finally{J.releaseLock()}}function kL(){let $,Z;return{promise:new Promise((Y,X)=>{$=Y,Z=X}),resolve:$,reject:Z}}function eT(){let $=[],Z=null,J=!1,Y=kL(),X=()=>{J=!0,Y.resolve(),$.forEach((G)=>G.cancel()),$=[],Z==null||Z.close()},Q=async()=>{if(J&&$.length===0){Z==null||Z.close();return}if($.length===0)return Y=kL(),await Y.promise,Q();try{let{value:G,done:W}=await $[0].read();if(W)if($.shift(),$.length===0&&J)Z==null||Z.close();else await Q();else Z==null||Z.enqueue(G)}catch(G){Z==null||Z.error(G),$.shift(),X()}};return{stream:new ReadableStream({start(G){Z=G},pull:Q,async cancel(){for(let G of $)await G.cancel();$=[],J=!0}}),addStream:(G)=>{if(J)throw Error("Cannot add inner stream: outer stream is closed");$.push(G.getReader()),Y.resolve()},close:()=>{if(J=!0,Y.resolve(),$.length===0)Z==null||Z.close()},terminate:X}}function be({tools:$,generatorStream:Z,tracer:J,telemetry:Y,system:X,messages:Q,abortSignal:G,repairToolCall:W,experimental_context:K,generateId:V,stepNumber:U,model:H,onToolCallStart:B,onToolCallFinish:z}){let F=null,A=new ReadableStream({start(w){F=w}}),j=new Set,N=new Map,L=new Map,q=!1,M=void 0;function C(){if(q&&j.size===0){if(M!=null)F.enqueue(M);F.close()}}let R=new TransformStream({async transform(w,I){let _=w.type;switch(_){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{I.enqueue(w);break}case"file":{I.enqueue({type:"file",file:new Ve({data:w.data,mediaType:w.mediaType}),...w.providerMetadata!=null?{providerMetadata:w.providerMetadata}:{}});break}case"finish":{M={type:"finish",finishReason:w.finishReason.unified,rawFinishReason:w.finishReason.raw,usage:q4(w.usage),providerMetadata:w.providerMetadata};break}case"tool-approval-request":{let E=L.get(w.toolCallId);if(E==null){F.enqueue({type:"error",error:new XT({toolCallId:w.toolCallId,approvalId:w.approvalId})});break}I.enqueue({type:"tool-approval-request",approvalId:w.approvalId,toolCall:E});break}case"tool-call":{try{let E=await qe({toolCall:w,tools:$,repairToolCall:W,system:X,messages:Q});if(L.set(E.toolCallId,E),I.enqueue(E),E.invalid){F.enqueue({type:"tool-error",toolCallId:E.toolCallId,toolName:E.toolName,input:E.input,error:AX(E.error),dynamic:!0,title:E.title});break}let f=$==null?void 0:$[E.toolName];if(f==null)break;if(f.onInputAvailable!=null)await f.onInputAvailable({input:E.input,toolCallId:E.toolCallId,messages:Q,abortSignal:G,experimental_context:K});if(await Ue({tool:f,toolCall:E,messages:Q,experimental_context:K})){F.enqueue({type:"tool-approval-request",approvalId:V(),toolCall:E});break}if(N.set(E.toolCallId,E.input),f.execute!=null&&E.providerExecuted!==!0){let b=V();j.add(b),cT({toolCall:E,tools:$,tracer:J,telemetry:Y,messages:Q,abortSignal:G,experimental_context:K,stepNumber:U,model:H,onToolCallStart:B,onToolCallFinish:z,onPreliminaryToolResult:(y)=>{F.enqueue(y)}}).then((y)=>{F.enqueue(y)}).catch((y)=>{F.enqueue({type:"error",error:y})}).finally(()=>{j.delete(b),C()})}}catch(E){F.enqueue({type:"error",error:E})}break}case"tool-result":{let E=w.toolName;if(w.isError)F.enqueue({type:"tool-error",toolCallId:w.toolCallId,toolName:E,input:N.get(w.toolCallId),providerExecuted:!0,error:w.result,dynamic:w.dynamic,...w.providerMetadata!=null?{providerMetadata:w.providerMetadata}:{}});else I.enqueue({type:"tool-result",toolCallId:w.toolCallId,toolName:E,input:N.get(w.toolCallId),output:w.result,providerExecuted:!0,dynamic:w.dynamic,...w.providerMetadata!=null?{providerMetadata:w.providerMetadata}:{}});break}default:throw Error(`Unhandled chunk type: ${_}`)}},flush(){q=!0,C()}});return new ReadableStream({async start(w){return Promise.all([Z.pipeThrough(R).pipeTo(new WritableStream({write(I){w.enqueue(I)},close(){}})),A.pipeTo(new WritableStream({write(I){w.enqueue(I)},close(){w.close()}}))])}})}var _e=a6({prefix:"aitxt",size:24});function tb0({model:$,tools:Z,toolChoice:J,system:Y,prompt:X,messages:Q,maxRetries:G,abortSignal:W,timeout:K,headers:V,stopWhen:U=Ne(1),experimental_output:H,output:B=H,experimental_telemetry:z,prepareStep:F,providerOptions:A,experimental_activeTools:j,activeTools:N=j,experimental_repairToolCall:L,experimental_transform:q,experimental_download:M,includeRawChunks:C=!1,onChunk:R,onError:w=({error:G0})=>{console.error(G0)},onFinish:I,onAbort:_,onStepFinish:E,experimental_onStart:f,experimental_onStepStart:b,experimental_onToolCallStart:y,experimental_onToolCallFinish:k,experimental_context:g,experimental_include:d,_internal:{now:p=VX,generateId:t=_e}={},...r}){let G0=kT(K),O0=It(K),h0=Ct(K),u=O0!=null?new AbortController:void 0,l=h0!=null?new AbortController:void 0;return new fe({model:w4($),telemetry:z,headers:V,settings:r,maxRetries:G,abortSignal:De(W,G0!=null?AbortSignal.timeout(G0):void 0,u==null?void 0:u.signal,l==null?void 0:l.signal),stepTimeoutMs:O0,stepAbortController:u,chunkTimeoutMs:h0,chunkAbortController:l,system:Y,prompt:X,messages:Q,tools:Z,toolChoice:J,transforms:y5(q),activeTools:N,repairToolCall:L,stopConditions:y5(U),output:B,providerOptions:A,prepareStep:F,includeRawChunks:C,timeout:K,stopWhen:U,originalAbortSignal:W,onChunk:R,onError:w,onFinish:I,onAbort:_,onStepFinish:E,onStart:f,onStepStart:b,onToolCallStart:y,onToolCallFinish:k,now:p,generateId:t,experimental_context:g,download:M,include:d})}function Se($){let Z=void 0,J="",Y="",X=void 0,Q="";function G({controller:W,partialOutput:K=void 0}){W.enqueue({part:{type:"text-delta",id:Z,text:Y,providerMetadata:X},partialOutput:K}),Y=""}return new TransformStream({async transform(W,K){var V;if(W.type==="finish-step"&&Y.length>0)G({controller:K});if(W.type!=="text-delta"&&W.type!=="text-start"&&W.type!=="text-end"){K.enqueue({part:W,partialOutput:void 0});return}if(Z==null)Z=W.id;else if(W.id!==Z){K.enqueue({part:W,partialOutput:void 0});return}if(W.type==="text-start"){K.enqueue({part:W,partialOutput:void 0});return}if(W.type==="text-end"){if(Y.length>0)G({controller:K});K.enqueue({part:W,partialOutput:void 0});return}J+=W.text,Y+=W.text,X=(V=W.providerMetadata)!=null?V:X;let U=await $.parsePartialOutput({text:J});if(U!==void 0){let H=typeof U.partial==="string"?U.partial:JSON.stringify(U.partial);if(H!==Q)G({controller:K,partialOutput:U.partial}),Q=H}}})}var fe=class{constructor({model:$,telemetry:Z,headers:J,settings:Y,maxRetries:X,abortSignal:Q,stepTimeoutMs:G,stepAbortController:W,chunkTimeoutMs:K,chunkAbortController:V,system:U,prompt:H,messages:B,tools:z,toolChoice:F,transforms:A,activeTools:j,repairToolCall:N,stopConditions:L,output:q,providerOptions:M,prepareStep:C,includeRawChunks:R,now:w,generateId:I,timeout:_,stopWhen:E,originalAbortSignal:f,onChunk:b,onError:y,onFinish:k,onAbort:g,onStepFinish:d,onStart:p,onStepStart:t,onToolCallStart:r,onToolCallFinish:G0,experimental_context:O0,download:h0,include:u}){this._totalUsage=new Q8,this._finishReason=new Q8,this._rawFinishReason=new Q8,this._steps=new Q8,this.outputSpecification=q,this.includeRawChunks=R,this.tools=z;let $0=Ze()(Z==null?void 0:Z.integrations),v,h=[],c=[],m=void 0,a=void 0,e=void 0,H0={},A0=[],P0=[],s0=new Map,o,K0={},z0={},j0=new TransformStream({async transform(n,J0){var C0,M0,D1,g0;J0.enqueue(n);let{part:Z0}=n;if(Z0.type==="text-delta"||Z0.type==="reasoning-delta"||Z0.type==="source"||Z0.type==="tool-call"||Z0.type==="tool-result"||Z0.type==="tool-input-start"||Z0.type==="tool-input-delta"||Z0.type==="raw")await(b==null?void 0:b({chunk:Z0}));if(Z0.type==="error")await y({error:VH(Z0.error)});if(Z0.type==="text-start")K0[Z0.id]={type:"text",text:"",providerMetadata:Z0.providerMetadata},h.push(K0[Z0.id]);if(Z0.type==="text-delta"){let v0=K0[Z0.id];if(v0==null){J0.enqueue({part:{type:"error",error:`text part ${Z0.id} not found`},partialOutput:void 0});return}v0.text+=Z0.text,v0.providerMetadata=(C0=Z0.providerMetadata)!=null?C0:v0.providerMetadata}if(Z0.type==="text-end"){let v0=K0[Z0.id];if(v0==null){J0.enqueue({part:{type:"error",error:`text part ${Z0.id} not found`},partialOutput:void 0});return}v0.providerMetadata=(M0=Z0.providerMetadata)!=null?M0:v0.providerMetadata,delete K0[Z0.id]}if(Z0.type==="reasoning-start")z0[Z0.id]={type:"reasoning",text:"",providerMetadata:Z0.providerMetadata},h.push(z0[Z0.id]);if(Z0.type==="reasoning-delta"){let v0=z0[Z0.id];if(v0==null){J0.enqueue({part:{type:"error",error:`reasoning part ${Z0.id} not found`},partialOutput:void 0});return}v0.text+=Z0.text,v0.providerMetadata=(D1=Z0.providerMetadata)!=null?D1:v0.providerMetadata}if(Z0.type==="reasoning-end"){let v0=z0[Z0.id];if(v0==null){J0.enqueue({part:{type:"error",error:`reasoning part ${Z0.id} not found`},partialOutput:void 0});return}v0.providerMetadata=(g0=Z0.providerMetadata)!=null?g0:v0.providerMetadata,delete z0[Z0.id]}if(Z0.type==="file")h.push({type:"file",file:Z0.file,...Z0.providerMetadata!=null?{providerMetadata:Z0.providerMetadata}:{}});if(Z0.type==="source")h.push(Z0);if(Z0.type==="tool-call")h.push(Z0);if(Z0.type==="tool-result"&&!Z0.preliminary)h.push(Z0);if(Z0.type==="tool-approval-request")h.push(Z0);if(Z0.type==="tool-error")h.push(Z0);if(Z0.type==="start-step")h=[],z0={},K0={},H0=Z0.request,A0=Z0.warnings;if(Z0.type==="finish-step"){let v0=await SL({content:h,tools:z}),V0=new je({stepNumber:P0.length,model:x,...i,experimental_context:O0,content:h,finishReason:Z0.finishReason,rawFinishReason:Z0.rawFinishReason,usage:Z0.usage,warnings:A0,request:H0,response:{...Z0.response,messages:[...c,...v0]},providerMetadata:Z0.providerMetadata});await v5({event:V0,callbacks:[d,$0.onStepFinish]}),D4({warnings:A0,provider:x.provider,model:x.modelId}),P0.push(V0),c.push(...v0),v.resolve()}if(Z0.type==="finish")e=Z0.totalUsage,m=Z0.finishReason,a=Z0.rawFinishReason},async flush(n){var J0,C0,M0,D1,g0,Z0,v0;try{if(P0.length===0){let H1=(Q==null?void 0:Q.aborted)?Q.reason:new oa({message:"No output generated. Check the stream for errors."});U1._finishReason.reject(H1),U1._rawFinishReason.reject(H1),U1._totalUsage.reject(H1),U1._steps.reject(H1);return}let V0=m!=null?m:"other",$1=e!=null?e:F4();U1._finishReason.resolve(V0),U1._rawFinishReason.resolve(a),U1._totalUsage.resolve($1),U1._steps.resolve(P0);let D0=P0[P0.length-1];await v5({event:{stepNumber:D0.stepNumber,model:D0.model,functionId:D0.functionId,metadata:D0.metadata,experimental_context:D0.experimental_context,finishReason:D0.finishReason,rawFinishReason:D0.rawFinishReason,totalUsage:$1,usage:D0.usage,content:D0.content,text:D0.text,reasoningText:D0.reasoningText,reasoning:D0.reasoning,files:D0.files,sources:D0.sources,toolCalls:D0.toolCalls,staticToolCalls:D0.staticToolCalls,dynamicToolCalls:D0.dynamicToolCalls,toolResults:D0.toolResults,staticToolResults:D0.staticToolResults,dynamicToolResults:D0.dynamicToolResults,request:D0.request,response:D0.response,warnings:D0.warnings,providerMetadata:D0.providerMetadata,steps:P0},callbacks:[k,$0.onFinish]}),o.setAttributes(await s$({telemetry:Z,attributes:{"ai.response.finishReason":V0,"ai.response.text":{output:()=>D0.text},"ai.response.reasoning":{output:()=>D0.reasoningText},"ai.response.toolCalls":{output:()=>{var H1;return((H1=D0.toolCalls)==null?void 0:H1.length)?JSON.stringify(D0.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(D0.providerMetadata),"ai.usage.inputTokens":$1.inputTokens,"ai.usage.inputTokenDetails.noCacheTokens":(J0=$1.inputTokenDetails)==null?void 0:J0.noCacheTokens,"ai.usage.inputTokenDetails.cacheReadTokens":(C0=$1.inputTokenDetails)==null?void 0:C0.cacheReadTokens,"ai.usage.inputTokenDetails.cacheWriteTokens":(M0=$1.inputTokenDetails)==null?void 0:M0.cacheWriteTokens,"ai.usage.outputTokens":$1.outputTokens,"ai.usage.outputTokenDetails.textTokens":(D1=$1.outputTokenDetails)==null?void 0:D1.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(g0=$1.outputTokenDetails)==null?void 0:g0.reasoningTokens,"ai.usage.totalTokens":$1.totalTokens,"ai.usage.reasoningTokens":(Z0=$1.outputTokenDetails)==null?void 0:Z0.reasoningTokens,"ai.usage.cachedInputTokens":(v0=$1.inputTokenDetails)==null?void 0:v0.cacheReadTokens}}))}catch(V0){n.error(V0)}finally{o.end()}}}),Q1=eT();this.addStream=Q1.addStream,this.closeStream=Q1.close;let _0=Q1.stream.getReader(),e0=new ReadableStream({async start(n){n.enqueue({type:"start"})},async pull(n){function J0(){g==null||g({steps:P0}),n.enqueue({type:"abort",...(Q==null?void 0:Q.reason)!==void 0?{reason:r6(Q.reason)}:{}}),n.close()}try{let{done:C0,value:M0}=await _0.read();if(C0){n.close();return}if(Q==null?void 0:Q.aborted){J0();return}n.enqueue(M0)}catch(C0){if(N4(C0)&&(Q==null?void 0:Q.aborted))J0();else n.error(C0)}},cancel(n){return Q1.stream.cancel(n)}});for(let n of A)e0=e0.pipeThrough(n({tools:z,stopStream(){Q1.terminate()}}));this.baseStream=e0.pipeThrough(Se(q!=null?q:eU())).pipeThrough(j0);let{maxRetries:S0,retry:C1}=FH({maxRetries:X,abortSignal:Q}),n0=HH(Z),z1=BX(Y),a0=UH({model:$,telemetry:Z,headers:J,settings:{...z1,maxRetries:S0}}),U1=this,x={provider:$.provider,modelId:$.modelId},i={functionId:Z==null?void 0:Z.functionId,metadata:Z==null?void 0:Z.metadata};h5({name:"ai.streamText",attributes:s$({telemetry:Z,attributes:{...x5({operationId:"ai.streamText",telemetry:Z}),...a0,"ai.prompt":{input:()=>JSON.stringify({system:U,prompt:H,messages:B})}}}),tracer:n0,endWhenDone:!1,fn:async(n)=>{o=n;let J0=await KH({system:U,prompt:H,messages:B});await v5({event:{model:x,system:U,prompt:H,messages:B,tools:z,toolChoice:F,activeTools:j,maxOutputTokens:z1.maxOutputTokens,temperature:z1.temperature,topP:z1.topP,topK:z1.topK,presencePenalty:z1.presencePenalty,frequencyPenalty:z1.frequencyPenalty,stopSequences:z1.stopSequences,seed:z1.seed,maxRetries:S0,timeout:_,headers:J,providerOptions:M,stopWhen:E,output:q,abortSignal:f,include:u,...i,experimental_context:O0},callbacks:[p,$0.onStart]});let C0=J0.messages,M0=[],{approvedToolApprovals:D1,deniedToolApprovals:g0}=Qe({messages:C0});if(g0.length>0||D1.length>0){let v0=D1.filter((P1)=>!P1.toolCall.providerExecuted),V0=g0.filter((P1)=>!P1.toolCall.providerExecuted),$1=g0.filter((P1)=>P1.toolCall.providerExecuted),D0,H1=new ReadableStream({start(P1){D0=P1}});U1.addStream(H1);try{for(let E1 of[...V0,...$1])D0==null||D0.enqueue({type:"tool-output-denied",toolCallId:E1.toolCall.toolCallId,toolName:E1.toolCall.toolName});let P1=[];if(await Promise.all(v0.map(async(E1)=>{let b1=await cT({toolCall:E1.toolCall,tools:z,tracer:n0,telemetry:Z,messages:C0,abortSignal:Q,experimental_context:O0,stepNumber:P0.length,model:x,onToolCallStart:[r,$0.onToolCallStart],onToolCallFinish:[G0,$0.onToolCallFinish],onPreliminaryToolResult:(F6)=>{D0==null||D0.enqueue(F6)}});if(b1!=null)D0==null||D0.enqueue(b1),P1.push(b1)})),P1.length>0||V0.length>0){let E1=[];for(let b1 of P1)E1.push({type:"tool-result",toolCallId:b1.toolCallId,toolName:b1.toolName,output:await BJ({toolCallId:b1.toolCallId,input:b1.input,tool:z==null?void 0:z[b1.toolName],output:b1.type==="tool-result"?b1.output:b1.error,errorMode:b1.type==="tool-error"?"text":"none"})});for(let b1 of V0)E1.push({type:"tool-result",toolCallId:b1.toolCall.toolCallId,toolName:b1.toolCall.toolName,output:{type:"execution-denied",reason:b1.approvalResponse.reason}});M0.push({role:"tool",content:E1})}}finally{D0==null||D0.close()}}c.push(...M0);async function Z0({currentStep:v0,responseMessages:V0,usage:$1}){var D0,H1,P1,E1,b1,F6,m1,c8,tA;let O8=U1.includeRawChunks,A6=G!=null?setTimeout(()=>W.abort(),G):void 0,M7=void 0;function y$(){if(K!=null){if(M7!=null)clearTimeout(M7);M7=setTimeout(()=>V.abort(),K)}}function U9(){if(M7!=null)clearTimeout(M7),M7=void 0}function eA(){if(A6!=null)clearTimeout(A6)}try{v=new Q8;let q8=[...C0,...V0],j$=await(C==null?void 0:C({model:$,steps:P0,stepNumber:P0.length,messages:q8,experimental_context:O0})),jZ=w4((D0=j$==null?void 0:j$.model)!=null?D0:$),$O={provider:jZ.provider,modelId:jZ.modelId},ZO=await WH({prompt:{system:(H1=j$==null?void 0:j$.system)!=null?H1:J0.system,messages:(P1=j$==null?void 0:j$.messages)!=null?P1:q8},supportedUrls:await jZ.supportedUrls,download:h0}),JO=(E1=j$==null?void 0:j$.activeTools)!=null?E1:j,{toolChoice:H9,tools:oK}=await ut({tools:z,toolChoice:(b1=j$==null?void 0:j$.toolChoice)!=null?b1:F,activeTools:JO});O0=(F6=j$==null?void 0:j$.experimental_context)!=null?F6:O0;let Td=(m1=j$==null?void 0:j$.messages)!=null?m1:q8,Rd=(c8=j$==null?void 0:j$.system)!=null?c8:J0.system,YO=zH(M,j$==null?void 0:j$.providerOptions);await v5({event:{stepNumber:P0.length,model:$O,system:Rd,messages:Td,tools:z,toolChoice:H9,activeTools:JO,steps:[...P0],providerOptions:YO,timeout:_,headers:J,stopWhen:E,output:q,abortSignal:f,include:u,...i,experimental_context:O0},callbacks:[t,$0.onStepStart]});let{result:{stream:Pd,response:XO,request:sK},doStreamSpan:B5,startTimestampMs:QO}=await C1(()=>h5({name:"ai.streamText.doStream",attributes:s$({telemetry:Z,attributes:{...x5({operationId:"ai.streamText.doStream",telemetry:Z}),...a0,"ai.model.provider":jZ.provider,"ai.model.id":jZ.modelId,"ai.prompt.messages":{input:()=>BH(ZO)},"ai.prompt.tools":{input:()=>oK==null?void 0:oK.map((y0)=>JSON.stringify(y0))},"ai.prompt.toolChoice":{input:()=>H9!=null?JSON.stringify(H9):void 0},"gen_ai.system":jZ.provider,"gen_ai.request.model":jZ.modelId,"gen_ai.request.frequency_penalty":z1.frequencyPenalty,"gen_ai.request.max_tokens":z1.maxOutputTokens,"gen_ai.request.presence_penalty":z1.presencePenalty,"gen_ai.request.stop_sequences":z1.stopSequences,"gen_ai.request.temperature":z1.temperature,"gen_ai.request.top_k":z1.topK,"gen_ai.request.top_p":z1.topP}}),tracer:n0,endWhenDone:!1,fn:async(y0)=>({startTimestampMs:w(),doStreamSpan:y0,result:await jZ.doStream({...z1,tools:oK,toolChoice:H9,responseFormat:await(q==null?void 0:q.responseFormat),prompt:ZO,providerOptions:YO,abortSignal:Q,headers:J,includeRawChunks:O8})})})),Id=be({tools:z,generatorStream:Pd,tracer:n0,telemetry:Z,system:U,messages:q8,repairToolCall:N,abortSignal:Q,experimental_context:O0,generateId:I,stepNumber:P0.length,model:$O,onToolCallStart:[r,$0.onToolCallStart],onToolCallFinish:[G0,$0.onToolCallFinish]}),Cd=((tA=u==null?void 0:u.requestBody)!=null?tA:!0)?sK!=null?sK:{}:{...sK,body:void 0},jY=[],NY=[],rK,aK={},D7="other",tK=void 0,x$=F4(),GO,WO=!0,O6={id:I(),timestamp:new Date,modelId:x.modelId},Ed="";U1.addStream(Id.pipeThrough(new TransformStream({async transform(y0,N$){var MY,DY,wY,LY,TY;if(y$(),y0.type==="stream-start"){rK=y0.warnings;return}if(WO){let M$=w()-QO;WO=!1,B5.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":M$}),B5.setAttributes({"ai.response.msToFirstChunk":M$}),N$.enqueue({type:"start-step",request:Cd,warnings:rK!=null?rK:[]})}let RY=y0.type;switch(RY){case"tool-approval-request":case"text-start":case"text-end":{N$.enqueue(y0);break}case"text-delta":{if(y0.delta.length>0)N$.enqueue({type:"text-delta",id:y0.id,text:y0.delta,providerMetadata:y0.providerMetadata}),Ed+=y0.delta;break}case"reasoning-start":case"reasoning-end":{N$.enqueue(y0);break}case"reasoning-delta":{N$.enqueue({type:"reasoning-delta",id:y0.id,text:y0.delta,providerMetadata:y0.providerMetadata});break}case"tool-call":{N$.enqueue(y0),jY.push(y0);break}case"tool-result":{if(N$.enqueue(y0),!y0.preliminary)NY.push(y0);break}case"tool-error":{N$.enqueue(y0),NY.push(y0);break}case"response-metadata":{O6={id:(MY=y0.id)!=null?MY:O6.id,timestamp:(DY=y0.timestamp)!=null?DY:O6.timestamp,modelId:(wY=y0.modelId)!=null?wY:O6.modelId};break}case"finish":{x$=y0.usage,D7=y0.finishReason,tK=y0.rawFinishReason,GO=y0.providerMetadata;let M$=w()-QO;B5.addEvent("ai.stream.finish"),B5.setAttributes({"ai.response.msToFinish":M$,"ai.response.avgOutputTokensPerSecond":1000*((LY=x$.outputTokens)!=null?LY:0)/M$});break}case"file":{N$.enqueue(y0);break}case"source":{N$.enqueue(y0);break}case"tool-input-start":{aK[y0.id]=y0.toolName;let M$=z==null?void 0:z[y0.toolName];if((M$==null?void 0:M$.onInputStart)!=null)await M$.onInputStart({toolCallId:y0.id,messages:q8,abortSignal:Q,experimental_context:O0});N$.enqueue({...y0,dynamic:(TY=y0.dynamic)!=null?TY:(M$==null?void 0:M$.type)==="dynamic",title:M$==null?void 0:M$.title});break}case"tool-input-end":{delete aK[y0.id],N$.enqueue(y0);break}case"tool-input-delta":{let M$=aK[y0.id],w7=z==null?void 0:z[M$];if((w7==null?void 0:w7.onInputDelta)!=null)await w7.onInputDelta({inputTextDelta:y0.delta,toolCallId:y0.id,messages:q8,abortSignal:Q,experimental_context:O0});N$.enqueue(y0);break}case"error":{N$.enqueue(y0),D7="error";break}case"raw":{if(O8)N$.enqueue(y0);break}default:throw Error(`Unknown chunk type: ${RY}`)}},async flush(y0){var N$,MY,DY,wY,LY,TY,RY;let M$=jY.length>0?JSON.stringify(jY):void 0;try{B5.setAttributes(await s$({telemetry:Z,attributes:{"ai.response.finishReason":D7,"ai.response.toolCalls":{output:()=>M$},"ai.response.id":O6.id,"ai.response.model":O6.modelId,"ai.response.timestamp":O6.timestamp.toISOString(),"ai.usage.inputTokens":x$.inputTokens,"ai.usage.inputTokenDetails.noCacheTokens":(N$=x$.inputTokenDetails)==null?void 0:N$.noCacheTokens,"ai.usage.inputTokenDetails.cacheReadTokens":(MY=x$.inputTokenDetails)==null?void 0:MY.cacheReadTokens,"ai.usage.inputTokenDetails.cacheWriteTokens":(DY=x$.inputTokenDetails)==null?void 0:DY.cacheWriteTokens,"ai.usage.outputTokens":x$.outputTokens,"ai.usage.outputTokenDetails.textTokens":(wY=x$.outputTokenDetails)==null?void 0:wY.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(LY=x$.outputTokenDetails)==null?void 0:LY.reasoningTokens,"ai.usage.totalTokens":x$.totalTokens,"ai.usage.reasoningTokens":(TY=x$.outputTokenDetails)==null?void 0:TY.reasoningTokens,"ai.usage.cachedInputTokens":(RY=x$.inputTokenDetails)==null?void 0:RY.cacheReadTokens,"gen_ai.response.finish_reasons":[D7],"gen_ai.response.id":O6.id,"gen_ai.response.model":O6.modelId,"gen_ai.usage.input_tokens":x$.inputTokens,"gen_ai.usage.output_tokens":x$.outputTokens}}))}catch(P$){}y0.enqueue({type:"finish-step",finishReason:D7,rawFinishReason:tK,usage:x$,providerMetadata:GO,response:{...O6,headers:XO==null?void 0:XO.headers}});let w7=Je($1,x$);await v.promise;let eK=P0[P0.length-1];try{B5.setAttributes(await s$({telemetry:Z,attributes:{"ai.response.text":{output:()=>eK.text},"ai.response.reasoning":{output:()=>eK.reasoningText},"ai.response.providerMetadata":JSON.stringify(eK.providerMetadata)}}))}catch(P$){}finally{B5.end()}let KO=jY.filter((P$)=>P$.providerExecuted!==!0),bd=NY.filter((P$)=>P$.providerExecuted!==!0);for(let P$ of jY){if(P$.providerExecuted!==!0)continue;let $V=z==null?void 0:z[P$.toolName];if(($V==null?void 0:$V.type)==="provider"&&$V.supportsDeferredResults){if(!NY.some((ZV)=>(ZV.type==="tool-result"||ZV.type==="tool-error")&&ZV.toolCallId===P$.toolCallId))s0.set(P$.toolCallId,{toolName:P$.toolName})}}for(let P$ of NY)if(P$.type==="tool-result"||P$.type==="tool-error")s0.delete(P$.toolCallId);if(eA(),U9(),(KO.length>0&&bd.length===KO.length||s0.size>0)&&!await Me({stopConditions:L,steps:P0})){V0.push(...await SL({content:P0[P0.length-1].content,tools:z}));try{await Z0({currentStep:v0+1,responseMessages:V0,usage:w7})}catch(P$){y0.enqueue({type:"error",error:P$}),U1.closeStream()}}else y0.enqueue({type:"finish",finishReason:D7,rawFinishReason:tK,totalUsage:w7}),U1.closeStream()}})))}finally{eA(),U9()}}await Z0({currentStep:0,responseMessages:M0,usage:F4()})}}).catch((n)=>{U1.addStream(new ReadableStream({start(J0){J0.enqueue({type:"error",error:n}),J0.close()}})),U1.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(($)=>$[$.length-1])}get content(){return this.finalStep.then(($)=>$.content)}get warnings(){return this.finalStep.then(($)=>$.warnings)}get providerMetadata(){return this.finalStep.then(($)=>$.providerMetadata)}get text(){return this.finalStep.then(($)=>$.text)}get reasoningText(){return this.finalStep.then(($)=>$.reasoningText)}get reasoning(){return this.finalStep.then(($)=>$.reasoning)}get sources(){return this.finalStep.then(($)=>$.sources)}get files(){return this.finalStep.then(($)=>$.files)}get toolCalls(){return this.finalStep.then(($)=>$.toolCalls)}get staticToolCalls(){return this.finalStep.then(($)=>$.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(($)=>$.dynamicToolCalls)}get toolResults(){return this.finalStep.then(($)=>$.toolResults)}get staticToolResults(){return this.finalStep.then(($)=>$.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(($)=>$.dynamicToolResults)}get usage(){return this.finalStep.then(($)=>$.usage)}get request(){return this.finalStep.then(($)=>$.request)}get response(){return this.finalStep.then(($)=>$.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}get rawFinishReason(){return this.consumeStream(),this._rawFinishReason.promise}teeStream(){let[$,Z]=this.baseStream.tee();return this.baseStream=Z,$}get textStream(){return s6(this.teeStream().pipeThrough(new TransformStream({transform({part:$},Z){if($.type==="text-delta")Z.enqueue($.text)}})))}get fullStream(){return s6(this.teeStream().pipeThrough(new TransformStream({transform({part:$},Z){Z.enqueue($)}})))}async consumeStream($){var Z;try{await Ee({stream:this.fullStream,onError:$==null?void 0:$.onError})}catch(J){(Z=$==null?void 0:$.onError)==null||Z.call($,J)}}get experimental_partialOutputStream(){return this.partialOutputStream}get partialOutputStream(){return s6(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:$},Z){if($!=null)Z.enqueue($)}})))}get elementStream(){var $,Z,J;let Y=($=this.outputSpecification)==null?void 0:$.createElementStreamTransform();if(Y==null)throw new g5({functionality:`element streams in ${(J=(Z=this.outputSpecification)==null?void 0:Z.name)!=null?J:"text"} mode`});return s6(this.teeStream().pipeThrough(Y))}get output(){return this.finalStep.then(($)=>{var Z;return((Z=this.outputSpecification)!=null?Z:eU()).parseCompleteOutput({text:$.text},{response:$.response,usage:$.usage,finishReason:$.finishReason})})}toUIMessageStream({originalMessages:$,generateMessageId:Z,onFinish:J,messageMetadata:Y,sendReasoning:X=!0,sendSources:Q=!1,sendStart:G=!0,sendFinish:W=!0,onError:K=r6}={}){let V=Z!=null?Le({originalMessages:$,responseMessageId:Z}):void 0,U=(B)=>{var z;let F=(z=this.tools)==null?void 0:z[B.toolName];if(F==null)return B.dynamic;return(F==null?void 0:F.type)==="dynamic"?!0:void 0},H=this.fullStream.pipeThrough(new TransformStream({transform:async(B,z)=>{let F=Y==null?void 0:Y({part:B}),A=B.type;switch(A){case"text-start":{z.enqueue({type:"text-start",id:B.id,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"text-delta":{z.enqueue({type:"text-delta",id:B.id,delta:B.text,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"text-end":{z.enqueue({type:"text-end",id:B.id,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"reasoning-start":case"reasoning-end":{if(X)z.enqueue({type:A,id:B.id,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"reasoning-delta":{if(X)z.enqueue({type:"reasoning-delta",id:B.id,delta:B.text,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"file":{z.enqueue({type:"file",mediaType:B.file.mediaType,url:`data:${B.file.mediaType};base64,${B.file.base64}`,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"source":{if(Q&&B.sourceType==="url")z.enqueue({type:"source-url",sourceId:B.id,url:B.url,title:B.title,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});if(Q&&B.sourceType==="document")z.enqueue({type:"source-document",sourceId:B.id,mediaType:B.mediaType,title:B.title,filename:B.filename,...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{}});break}case"tool-input-start":{let j=U(B);z.enqueue({type:"tool-input-start",toolCallId:B.id,toolName:B.toolName,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...j!=null?{dynamic:j}:{},...B.title!=null?{title:B.title}:{}});break}case"tool-input-delta":{z.enqueue({type:"tool-input-delta",toolCallId:B.id,inputTextDelta:B.delta});break}case"tool-call":{let j=U(B);if(B.invalid)z.enqueue({type:"tool-input-error",toolCallId:B.toolCallId,toolName:B.toolName,input:B.input,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...j!=null?{dynamic:j}:{},errorText:K(B.error),...B.title!=null?{title:B.title}:{}});else z.enqueue({type:"tool-input-available",toolCallId:B.toolCallId,toolName:B.toolName,input:B.input,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...j!=null?{dynamic:j}:{},...B.title!=null?{title:B.title}:{}});break}case"tool-approval-request":{z.enqueue({type:"tool-approval-request",approvalId:B.approvalId,toolCallId:B.toolCall.toolCallId});break}case"tool-result":{let j=U(B);z.enqueue({type:"tool-output-available",toolCallId:B.toolCallId,output:B.output,...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...B.preliminary!=null?{preliminary:B.preliminary}:{},...j!=null?{dynamic:j}:{}});break}case"tool-error":{let j=U(B);z.enqueue({type:"tool-output-error",toolCallId:B.toolCallId,errorText:B.providerExecuted?typeof B.error==="string"?B.error:JSON.stringify(B.error):K(B.error),...B.providerExecuted!=null?{providerExecuted:B.providerExecuted}:{},...B.providerMetadata!=null?{providerMetadata:B.providerMetadata}:{},...j!=null?{dynamic:j}:{}});break}case"tool-output-denied":{z.enqueue({type:"tool-output-denied",toolCallId:B.toolCallId});break}case"error":{z.enqueue({type:"error",errorText:K(B.error)});break}case"start-step":{z.enqueue({type:"start-step"});break}case"finish-step":{z.enqueue({type:"finish-step"});break}case"start":{if(G)z.enqueue({type:"start",...F!=null?{messageMetadata:F}:{},...V!=null?{messageId:V}:{}});break}case"finish":{if(W)z.enqueue({type:"finish",finishReason:B.finishReason,...F!=null?{messageMetadata:F}:{}});break}case"abort":{z.enqueue(B);break}case"tool-input-end":break;case"raw":break;default:throw Error(`Unknown chunk type: ${A}`)}if(F!=null&&A!=="start"&&A!=="finish")z.enqueue({type:"message-metadata",messageMetadata:F})}}));return s6(Ie({stream:H,messageId:V!=null?V:Z==null?void 0:Z(),originalMessages:$,onFinish:J,onError:K}))}pipeUIMessageStreamToResponse($,{originalMessages:Z,generateMessageId:J,onFinish:Y,messageMetadata:X,sendReasoning:Q,sendSources:G,sendFinish:W,sendStart:K,onError:V,...U}={}){Ce({response:$,stream:this.toUIMessageStream({originalMessages:Z,generateMessageId:J,onFinish:Y,messageMetadata:X,sendReasoning:Q,sendSources:G,sendFinish:W,sendStart:K,onError:V}),...U})}pipeTextStreamToResponse($,Z){sT({response:$,textStream:this.textStream,...Z})}toUIMessageStreamResponse({originalMessages:$,generateMessageId:Z,onFinish:J,messageMetadata:Y,sendReasoning:X,sendSources:Q,sendFinish:G,sendStart:W,onError:K,...V}={}){return we({stream:this.toUIMessageStream({originalMessages:$,generateMessageId:Z,onFinish:J,messageMetadata:Y,sendReasoning:X,sendSources:Q,sendFinish:G,sendStart:W,onError:K}),...V})}toTextStreamResponse($){return nT({textStream:this.textStream,...$})}};async function $2($,Z){let J=[];if(Z==null?void 0:Z.ignoreIncompleteToolCalls)$=$.map((Y)=>({...Y,parts:Y.parts.filter((X)=>!HJ(X)||X.state!=="input-streaming"&&X.state!=="input-available")}));for(let Y of $)switch(Y.role){case"system":{let X=Y.parts.filter((G)=>G.type==="text"),Q=X.reduce((G,W)=>{if(W.providerMetadata!=null)return{...G,...W.providerMetadata};return G},{});J.push({role:"system",content:X.map((G)=>G.text).join(""),...Object.keys(Q).length>0?{providerOptions:Q}:{}});break}case"user":{J.push({role:"user",content:Y.parts.map((X)=>{var Q;if(nU(X))return{type:"text",text:X.text,...X.providerMetadata!=null?{providerOptions:X.providerMetadata}:{}};if(oU(X))return{type:"file",mediaType:X.mediaType,filename:X.filename,data:X.url,...X.providerMetadata!=null?{providerOptions:X.providerMetadata}:{}};if(iU(X))return(Q=Z==null?void 0:Z.convertDataPart)==null?void 0:Q.call(Z,X)}).filter(mL)});break}case"assistant":{if(Y.parts!=null){let X=[];async function Q(){var G,W,K,V,U,H,B;if(X.length===0)return;let z=[];for(let A of X)if(nU(A))z.push({type:"text",text:A.text,...A.providerMetadata!=null?{providerOptions:A.providerMetadata}:{}});else if(oU(A))z.push({type:"file",mediaType:A.mediaType,filename:A.filename,data:A.url,...A.providerMetadata!=null?{providerOptions:A.providerMetadata}:{}});else if(fL(A))z.push({type:"reasoning",text:A.text,providerOptions:A.providerMetadata});else if(HJ(A)){let j=sU(A);if(A.state!=="input-streaming"){if(z.push({type:"tool-call",toolCallId:A.toolCallId,toolName:j,input:A.state==="output-error"?(G=A.input)!=null?G:("rawInput"in A)?A.rawInput:void 0:A.input,providerExecuted:A.providerExecuted,...A.callProviderMetadata!=null?{providerOptions:A.callProviderMetadata}:{}}),A.approval!=null)z.push({type:"tool-approval-request",approvalId:A.approval.id,toolCallId:A.toolCallId});if(A.providerExecuted===!0&&A.state!=="approval-responded"&&(A.state==="output-available"||A.state==="output-error")){let N=(W=A.resultProviderMetadata)!=null?W:A.callProviderMetadata;z.push({type:"tool-result",toolCallId:A.toolCallId,toolName:j,output:await BJ({toolCallId:A.toolCallId,input:A.input,output:A.state==="output-error"?A.errorText:A.output,tool:(K=Z==null?void 0:Z.tools)==null?void 0:K[j],errorMode:A.state==="output-error"?"json":"none"}),...N!=null?{providerOptions:N}:{}})}}}else if(iU(A)){let j=(V=Z==null?void 0:Z.convertDataPart)==null?void 0:V.call(Z,A);if(j!=null)z.push(j)}else throw Error(`Unsupported part: ${A}`);J.push({role:"assistant",content:z});let F=X.filter((A)=>{var j;return HJ(A)&&(A.providerExecuted!==!0||((j=A.approval)==null?void 0:j.approved)!=null)});if(F.length>0){let A=[];for(let j of F){if(((U=j.approval)==null?void 0:U.approved)!=null)A.push({type:"tool-approval-response",approvalId:j.approval.id,approved:j.approval.approved,reason:j.approval.reason,providerExecuted:j.providerExecuted});if(j.providerExecuted===!0)continue;switch(j.state){case"output-denied":{A.push({type:"tool-result",toolCallId:j.toolCallId,toolName:sU(j),output:{type:"error-text",value:(H=j.approval.reason)!=null?H:"Tool execution denied."},...j.callProviderMetadata!=null?{providerOptions:j.callProviderMetadata}:{}});break}case"output-error":case"output-available":{let N=sU(j);A.push({type:"tool-result",toolCallId:j.toolCallId,toolName:N,output:await BJ({toolCallId:j.toolCallId,input:j.input,output:j.state==="output-error"?j.errorText:j.output,tool:(B=Z==null?void 0:Z.tools)==null?void 0:B[N],errorMode:j.state==="output-error"?"text":"none"}),...j.callProviderMetadata!=null?{providerOptions:j.callProviderMetadata}:{}});break}}}if(A.length>0)J.push({role:"tool",content:A})}X=[]}for(let G of Y.parts)if(nU(G)||fL(G)||oU(G)||HJ(G)||iU(G))X.push(G);else if(G.type==="step-start")await Q();await Q();break}break}default:{let X=Y.role;throw new Nt({originalMessage:Y,message:`Unsupported role: ${X}`})}}return J}var J_0=M4(()=>qX(D.array(D.object({id:D.string(),role:D.enum(["system","user","assistant"]),metadata:D.unknown().optional(),parts:D.array(D.union([D.object({type:D.literal("text"),text:D.string(),state:D.enum(["streaming","done"]).optional(),providerMetadata:N0.optional()}),D.object({type:D.literal("reasoning"),text:D.string(),state:D.enum(["streaming","done"]).optional(),providerMetadata:N0.optional()}),D.object({type:D.literal("source-url"),sourceId:D.string(),url:D.string(),title:D.string().optional(),providerMetadata:N0.optional()}),D.object({type:D.literal("source-document"),sourceId:D.string(),mediaType:D.string(),title:D.string(),filename:D.string().optional(),providerMetadata:N0.optional()}),D.object({type:D.literal("file"),mediaType:D.string(),filename:D.string().optional(),url:D.string(),providerMetadata:N0.optional()}),D.object({type:D.literal("step-start")}),D.object({type:D.string().startsWith("data-"),id:D.string().optional(),data:D.unknown()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("input-streaming"),input:D.unknown().optional(),providerExecuted:D.boolean().optional(),callProviderMetadata:N0.optional(),output:D.never().optional(),errorText:D.never().optional(),approval:D.never().optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("input-available"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.never().optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("approval-requested"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.never().optional(),reason:D.never().optional()})}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("approval-responded"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.boolean(),reason:D.string().optional()})}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("output-available"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.unknown(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),resultProviderMetadata:N0.optional(),preliminary:D.boolean().optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("output-error"),input:D.unknown(),rawInput:D.unknown().optional(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.string(),callProviderMetadata:N0.optional(),resultProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.literal("dynamic-tool"),toolName:D.string(),toolCallId:D.string(),state:D.literal("output-denied"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.literal(!1),reason:D.string().optional()})}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("input-streaming"),providerExecuted:D.boolean().optional(),callProviderMetadata:N0.optional(),input:D.unknown().optional(),output:D.never().optional(),errorText:D.never().optional(),approval:D.never().optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("input-available"),providerExecuted:D.boolean().optional(),input:D.unknown(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.never().optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("approval-requested"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.never().optional(),reason:D.never().optional()})}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("approval-responded"),input:D.unknown(),providerExecuted:D.boolean().optional(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.boolean(),reason:D.string().optional()})}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("output-available"),providerExecuted:D.boolean().optional(),input:D.unknown(),output:D.unknown(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),resultProviderMetadata:N0.optional(),preliminary:D.boolean().optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("output-error"),providerExecuted:D.boolean().optional(),input:D.unknown(),rawInput:D.unknown().optional(),output:D.never().optional(),errorText:D.string(),callProviderMetadata:N0.optional(),resultProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.literal(!0),reason:D.string().optional()}).optional()}),D.object({type:D.string().startsWith("tool-"),toolCallId:D.string(),state:D.literal("output-denied"),providerExecuted:D.boolean().optional(),input:D.unknown(),output:D.never().optional(),errorText:D.never().optional(),callProviderMetadata:N0.optional(),approval:D.object({id:D.string(),approved:D.literal(!1),reason:D.string().optional()})})])).nonempty("Message must contain at least one part")})).nonempty("Messages array must not be empty")));var ke={type:"no-schema",jsonSchema:async()=>{return},async validatePartialResult({value:$,textDelta:Z}){return{success:!0,value:{partial:$,textDelta:Z}}},async validateFinalResult($,Z){return $===void 0?{success:!1,error:new E8({message:"No object generated: response did not match schema.",text:Z.text,response:Z.response,usage:Z.usage,finishReason:Z.finishReason})}:{success:!0,value:$}},createElementStream(){throw new g5({functionality:"element streams in no-schema mode"})}},ve=($)=>({type:"object",jsonSchema:async()=>await $.jsonSchema,async validatePartialResult({value:Z,textDelta:J}){return{success:!0,value:{partial:Z,textDelta:J}}},async validateFinalResult(Z){return y8({value:Z,schema:$})},createElementStream(){throw new g5({functionality:"element streams in object mode"})}}),ye=($)=>{return{type:"array",jsonSchema:async()=>{let{$schema:Z,...J}=await $.jsonSchema;return{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:J}},required:["elements"],additionalProperties:!1}},async validatePartialResult({value:Z,latestObject:J,isFirstDelta:Y,isFinalDelta:X}){var Q;if(!UX(Z)||!rU(Z.elements))return{success:!1,error:new C8({value:Z,cause:"value must be an object that contains an array of elements"})};let G=Z.elements,W=[];for(let U=0;U<G.length;U++){let H=G[U],B=await y8({value:H,schema:$});if(U===G.length-1&&!X)continue;if(!B.success)return B;W.push(B.value)}let K=(Q=J==null?void 0:J.length)!=null?Q:0,V="";if(Y)V+="[";if(K>0)V+=",";if(V+=W.slice(K).map((U)=>JSON.stringify(U)).join(","),X)V+="]";return{success:!0,value:{partial:W,textDelta:V}}},async validateFinalResult(Z){if(!UX(Z)||!rU(Z.elements))return{success:!1,error:new C8({value:Z,cause:"value must be an object that contains an array of elements"})};let J=Z.elements;for(let Y of J){let X=await y8({value:Y,schema:$});if(!X.success)return X}return{success:!0,value:J}},createElementStream(Z){let J=0;return s6(Z.pipeThrough(new TransformStream({transform(Y,X){switch(Y.type){case"object":{let Q=Y.object;for(;J<Q.length;J++)X.enqueue(Q[J]);break}case"text-delta":case"finish":case"error":break;default:throw Error(`Unsupported chunk type: ${Y}`)}}})))}}},xe=($)=>{return{type:"enum",jsonSchema:async()=>({$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:$}},required:["result"],additionalProperties:!1}),async validateFinalResult(Z){if(!UX(Z)||typeof Z.result!=="string")return{success:!1,error:new C8({value:Z,cause:'value must be an object that contains a string in the "result" property.'})};let J=Z.result;return $.includes(J)?{success:!0,value:J}:{success:!1,error:new C8({value:Z,cause:"value must be a string in the enum"})}},async validatePartialResult({value:Z,textDelta:J}){if(!UX(Z)||typeof Z.result!=="string")return{success:!1,error:new C8({value:Z,cause:'value must be an object that contains a string in the "result" property.'})};let Y=Z.result,X=$.filter((Q)=>Q.startsWith(Y));if(Z.result.length===0||X.length===0)return{success:!1,error:new C8({value:Z,cause:"value must be a string in the enum"})};return{success:!0,value:{partial:X.length>1?Y:X[0],textDelta:J}}},createElementStream(){throw new g5({functionality:"element streams in enum mode"})}}};function Z2({output:$,schema:Z,enumValues:J}){switch($){case"object":return ve(v8(Z));case"array":return ye(v8(Z));case"enum":return xe(J);case"no-schema":return ke;default:throw Error(`Unsupported output: ${$}`)}}async function vL($,Z,J){let Y=await G8({text:$});if(!Y.success)throw new E8({message:"No object generated: could not parse the response.",cause:Y.error,text:$,response:J.response,usage:J.usage,finishReason:J.finishReason});let X=await Z.validateFinalResult(Y.value,{text:$,response:J.response,usage:J.usage});if(!X.success)throw new E8({message:"No object generated: response did not match schema.",cause:X.error,text:$,response:J.response,usage:J.usage,finishReason:J.finishReason});return X.value}async function J2($,Z,J,Y){try{return await vL($,Z,Y)}catch(X){if(J!=null&&E8.isInstance(X)&&(JH.isInstance(X.cause)||C8.isInstance(X.cause))){let Q=await J({text:$,error:X.cause});if(Q===null)throw X;return await vL(Q,Z,Y)}throw X}}function Y2({output:$,schema:Z,schemaName:J,schemaDescription:Y,enumValues:X}){if($!=null&&$!=="object"&&$!=="array"&&$!=="enum"&&$!=="no-schema")throw new r1({parameter:"output",value:$,message:"Invalid output type."});if($==="no-schema"){if(Z!=null)throw new r1({parameter:"schema",value:Z,message:"Schema is not supported for no-schema output."});if(Y!=null)throw new r1({parameter:"schemaDescription",value:Y,message:"Schema description is not supported for no-schema output."});if(J!=null)throw new r1({parameter:"schemaName",value:J,message:"Schema name is not supported for no-schema output."});if(X!=null)throw new r1({parameter:"enumValues",value:X,message:"Enum values are not supported for no-schema output."})}if($==="object"){if(Z==null)throw new r1({parameter:"schema",value:Z,message:"Schema is required for object output."});if(X!=null)throw new r1({parameter:"enumValues",value:X,message:"Enum values are not supported for object output."})}if($==="array"){if(Z==null)throw new r1({parameter:"schema",value:Z,message:"Element schema is required for array output."});if(X!=null)throw new r1({parameter:"enumValues",value:X,message:"Enum values are not supported for array output."})}if($==="enum"){if(Z!=null)throw new r1({parameter:"schema",value:Z,message:"Schema is not supported for enum output."});if(Y!=null)throw new r1({parameter:"schemaDescription",value:Y,message:"Schema description is not supported for enum output."});if(J!=null)throw new r1({parameter:"schemaName",value:J,message:"Schema name is not supported for enum output."});if(X==null)throw new r1({parameter:"enumValues",value:X,message:"Enum values are required for enum output."});for(let Q of X)if(typeof Q!=="string")throw new r1({parameter:"enumValues",value:Q,message:"Enum values must be strings."})}}var he=a6({prefix:"aiobj",size:24});async function K_0($){let{model:Z,output:J="object",system:Y,prompt:X,messages:Q,maxRetries:G,abortSignal:W,headers:K,experimental_repairText:V,experimental_telemetry:U,experimental_download:H,providerOptions:B,_internal:{generateId:z=he,currentDate:F=()=>new Date}={},...A}=$,j=w4(Z),N="enum"in $?$.enum:void 0,{schema:L,schemaDescription:q,schemaName:M}="schema"in $?$:{};Y2({output:J,schema:L,schemaName:M,schemaDescription:q,enumValues:N});let{maxRetries:C,retry:R}=FH({maxRetries:G,abortSignal:W}),w=Z2({output:J,schema:L,enumValues:N}),I=BX(A),_=OX(K!=null?K:{},`ai/${vT}`),E=UH({model:j,telemetry:U,headers:_,settings:{...I,maxRetries:C}}),f=HH(U),b=await w.jsonSchema();try{return await h5({name:"ai.generateObject",attributes:s$({telemetry:U,attributes:{...x5({operationId:"ai.generateObject",telemetry:U}),...E,"ai.prompt":{input:()=>JSON.stringify({system:Y,prompt:X,messages:Q})},"ai.schema":b!=null?{input:()=>JSON.stringify(b)}:void 0,"ai.schema.name":M,"ai.schema.description":q,"ai.settings.output":w.type}}),tracer:f,fn:async(y)=>{var k;let g,d,p,t,r,G0,O0,h0,u=await KH({system:Y,prompt:X,messages:Q}),l=await WH({prompt:u,supportedUrls:await j.supportedUrls,download:H}),$0=await R(()=>h5({name:"ai.generateObject.doGenerate",attributes:s$({telemetry:U,attributes:{...x5({operationId:"ai.generateObject.doGenerate",telemetry:U}),...E,"ai.prompt.messages":{input:()=>BH(l)},"gen_ai.system":j.provider,"gen_ai.request.model":j.modelId,"gen_ai.request.frequency_penalty":I.frequencyPenalty,"gen_ai.request.max_tokens":I.maxOutputTokens,"gen_ai.request.presence_penalty":I.presencePenalty,"gen_ai.request.temperature":I.temperature,"gen_ai.request.top_k":I.topK,"gen_ai.request.top_p":I.topP}}),tracer:f,fn:async(h)=>{var c,m,a,e,H0,A0,P0,s0;let o=await j.doGenerate({responseFormat:{type:"json",schema:b,name:M,description:q},...BX(A),prompt:l,providerOptions:B,abortSignal:W,headers:_}),K0={id:(m=(c=o.response)==null?void 0:c.id)!=null?m:z(),timestamp:(e=(a=o.response)==null?void 0:a.timestamp)!=null?e:F(),modelId:(A0=(H0=o.response)==null?void 0:H0.modelId)!=null?A0:j.modelId,headers:(P0=o.response)==null?void 0:P0.headers,body:(s0=o.response)==null?void 0:s0.body},z0=We(o.content),j0=Ge(o.content);if(z0===void 0)throw new E8({message:"No object generated: the model did not return a response.",response:K0,usage:q4(o.usage),finishReason:o.finishReason.unified});return h.setAttributes(await s$({telemetry:U,attributes:{"ai.response.finishReason":o.finishReason.unified,"ai.response.object":{output:()=>z0},"ai.response.id":K0.id,"ai.response.model":K0.modelId,"ai.response.timestamp":K0.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(o.providerMetadata),"ai.usage.promptTokens":o.usage.inputTokens.total,"ai.usage.completionTokens":o.usage.outputTokens.total,"gen_ai.response.finish_reasons":[o.finishReason.unified],"gen_ai.response.id":K0.id,"gen_ai.response.model":K0.modelId,"gen_ai.usage.input_tokens":o.usage.inputTokens.total,"gen_ai.usage.output_tokens":o.usage.outputTokens.total}})),{...o,objectText:z0,reasoning:j0,responseData:K0}}}));g=$0.objectText,d=$0.finishReason.unified,p=q4($0.usage),t=$0.warnings,O0=$0.providerMetadata,G0=(k=$0.request)!=null?k:{},r=$0.responseData,h0=$0.reasoning,D4({warnings:t,provider:j.provider,model:j.modelId});let v=await J2(g,w,V,{response:r,usage:p,finishReason:d});return y.setAttributes(await s$({telemetry:U,attributes:{"ai.response.finishReason":d,"ai.response.object":{output:()=>JSON.stringify(v)},"ai.response.providerMetadata":JSON.stringify(O0),"ai.usage.promptTokens":p.inputTokens,"ai.usage.completionTokens":p.outputTokens}})),new ge({object:v,reasoning:h0,finishReason:d,usage:p,warnings:t,request:G0,response:r,providerMetadata:O0})}})}catch(y){throw VH(y)}}var ge=class{constructor($){this.object=$.object,this.finishReason=$.finishReason,this.usage=$.usage,this.warnings=$.warnings,this.providerMetadata=$.providerMetadata,this.response=$.response,this.request=$.request,this.reasoning=$.reasoning}toJsonResponse($){var Z;return new Response(JSON.stringify(this.object),{status:(Z=$==null?void 0:$.status)!=null?Z:200,headers:jX($==null?void 0:$.headers,{"content-type":"application/json; charset=utf-8"})})}};function X2($){return({url:Z,abortSignal:J})=>yT({url:Z,maxBytes:$==null?void 0:$.maxBytes,abortSignal:J})}function j4($,Z){if($===Z)return!0;if($==null||Z==null)return!1;if(typeof $!=="object"&&typeof Z!=="object")return $===Z;if($.constructor!==Z.constructor)return!1;if($ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if(Array.isArray($)){if($.length!==Z.length)return!1;for(let X=0;X<$.length;X++)if(!j4($[X],Z[X]))return!1;return!0}let J=Object.keys($),Y=Object.keys(Z);if(J.length!==Y.length)return!1;for(let X of J){if(!Y.includes(X))return!1;if(!j4($[X],Z[X]))return!1}return!0}var ue=a6({prefix:"aiobj",size:24});function U_0($){let{model:Z,output:J="object",system:Y,prompt:X,messages:Q,maxRetries:G,abortSignal:W,headers:K,experimental_repairText:V,experimental_telemetry:U,experimental_download:H,providerOptions:B,onError:z=({error:I})=>{console.error(I)},onFinish:F,_internal:{generateId:A=ue,currentDate:j=()=>new Date,now:N=VX}={},...L}=$,q="enum"in $&&$.enum?$.enum:void 0,{schema:M,schemaDescription:C,schemaName:R}="schema"in $?$:{};Y2({output:J,schema:M,schemaName:R,schemaDescription:C,enumValues:q});let w=Z2({output:J,schema:M,enumValues:q});return new me({model:Z,telemetry:U,headers:K,settings:L,maxRetries:G,abortSignal:W,outputStrategy:w,system:Y,prompt:X,messages:Q,schemaName:R,schemaDescription:C,providerOptions:B,repairText:V,onError:z,onFinish:F,download:H,generateId:A,currentDate:j,now:N})}var me=class{constructor({model:$,headers:Z,telemetry:J,settings:Y,maxRetries:X,abortSignal:Q,outputStrategy:G,system:W,prompt:K,messages:V,schemaName:U,schemaDescription:H,providerOptions:B,repairText:z,onError:F,onFinish:A,download:j,generateId:N,currentDate:L,now:q}){this._object=new Q8,this._usage=new Q8,this._providerMetadata=new Q8,this._warnings=new Q8,this._request=new Q8,this._response=new Q8,this._finishReason=new Q8;let M=w4($),{maxRetries:C,retry:R}=FH({maxRetries:X,abortSignal:Q}),w=BX(Y),I=UH({model:M,telemetry:J,headers:Z,settings:{...w,maxRetries:C}}),_=HH(J),E=this,f=eT(),b=new TransformStream({transform(y,k){if(k.enqueue(y),y.type==="error")F({error:VH(y.error)})}});this.baseStream=f.stream.pipeThrough(b),h5({name:"ai.streamObject",attributes:s$({telemetry:J,attributes:{...x5({operationId:"ai.streamObject",telemetry:J}),...I,"ai.prompt":{input:()=>JSON.stringify({system:W,prompt:K,messages:V})},"ai.schema":{input:async()=>JSON.stringify(await G.jsonSchema())},"ai.schema.name":U,"ai.schema.description":H,"ai.settings.output":G.type}}),tracer:_,endWhenDone:!1,fn:async(y)=>{let k=await KH({system:W,prompt:K,messages:V}),g={responseFormat:{type:"json",schema:await G.jsonSchema(),name:U,description:H},...BX(Y),prompt:await WH({prompt:k,supportedUrls:await M.supportedUrls,download:j}),providerOptions:B,abortSignal:Q,headers:Z,includeRawChunks:!1},d={transform:(o,K0)=>{switch(o.type){case"text-delta":K0.enqueue(o.delta);break;case"response-metadata":case"finish":case"error":case"stream-start":K0.enqueue(o);break}}},{result:{stream:p,response:t,request:r},doStreamSpan:G0,startTimestampMs:O0}=await R(()=>h5({name:"ai.streamObject.doStream",attributes:s$({telemetry:J,attributes:{...x5({operationId:"ai.streamObject.doStream",telemetry:J}),...I,"ai.prompt.messages":{input:()=>BH(g.prompt)},"gen_ai.system":M.provider,"gen_ai.request.model":M.modelId,"gen_ai.request.frequency_penalty":w.frequencyPenalty,"gen_ai.request.max_tokens":w.maxOutputTokens,"gen_ai.request.presence_penalty":w.presencePenalty,"gen_ai.request.temperature":w.temperature,"gen_ai.request.top_k":w.topK,"gen_ai.request.top_p":w.topP}}),tracer:_,endWhenDone:!1,fn:async(o)=>({startTimestampMs:q(),doStreamSpan:o,result:await M.doStream(g)})}));E._request.resolve(r!=null?r:{});let h0,u=F4(),l,$0,v,h,c="",m="",a={id:N(),timestamp:L(),modelId:M.modelId},e=void 0,H0=void 0,A0=!0,P0=!0,s0=p.pipeThrough(new TransformStream(d)).pipeThrough(new TransformStream({async transform(o,K0){var z0,j0,Q1;if(typeof o==="object"&&o.type==="stream-start"){h0=o.warnings;return}if(A0){let _0=q()-O0;A0=!1,G0.addEvent("ai.stream.firstChunk",{"ai.stream.msToFirstChunk":_0}),G0.setAttributes({"ai.stream.msToFirstChunk":_0})}if(typeof o==="string"){c+=o,m+=o;let{value:_0,state:e0}=await AJ(c);if(_0!==void 0&&!j4(e,_0)){let S0=await G.validatePartialResult({value:_0,textDelta:m,latestObject:H0,isFirstDelta:P0,isFinalDelta:e0==="successful-parse"});if(S0.success&&!j4(H0,S0.value.partial))e=_0,H0=S0.value.partial,K0.enqueue({type:"object",object:H0}),K0.enqueue({type:"text-delta",textDelta:S0.value.textDelta}),m="",P0=!1}return}switch(o.type){case"response-metadata":{a={id:(z0=o.id)!=null?z0:a.id,timestamp:(j0=o.timestamp)!=null?j0:a.timestamp,modelId:(Q1=o.modelId)!=null?Q1:a.modelId};break}case"finish":{if(m!=="")K0.enqueue({type:"text-delta",textDelta:m});l=o.finishReason.unified,u=q4(o.usage),$0=o.providerMetadata,K0.enqueue({...o,finishReason:o.finishReason.unified,usage:u,response:a}),D4({warnings:h0!=null?h0:[],provider:M.provider,model:M.modelId}),E._usage.resolve(u),E._providerMetadata.resolve($0),E._warnings.resolve(h0),E._response.resolve({...a,headers:t==null?void 0:t.headers}),E._finishReason.resolve(l!=null?l:"other");try{v=await J2(c,G,z,{response:a,usage:u,finishReason:l}),E._object.resolve(v)}catch(_0){h=_0,E._object.reject(_0)}break}default:{K0.enqueue(o);break}}},async flush(o){try{let K0=u!=null?u:{promptTokens:NaN,completionTokens:NaN,totalTokens:NaN};G0.setAttributes(await s$({telemetry:J,attributes:{"ai.response.finishReason":l,"ai.response.object":{output:()=>JSON.stringify(v)},"ai.response.id":a.id,"ai.response.model":a.modelId,"ai.response.timestamp":a.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify($0),"ai.usage.inputTokens":K0.inputTokens,"ai.usage.outputTokens":K0.outputTokens,"ai.usage.totalTokens":K0.totalTokens,"ai.usage.reasoningTokens":K0.reasoningTokens,"ai.usage.cachedInputTokens":K0.cachedInputTokens,"gen_ai.response.finish_reasons":[l],"gen_ai.response.id":a.id,"gen_ai.response.model":a.modelId,"gen_ai.usage.input_tokens":K0.inputTokens,"gen_ai.usage.output_tokens":K0.outputTokens}})),G0.end(),y.setAttributes(await s$({telemetry:J,attributes:{"ai.usage.inputTokens":K0.inputTokens,"ai.usage.outputTokens":K0.outputTokens,"ai.usage.totalTokens":K0.totalTokens,"ai.usage.reasoningTokens":K0.reasoningTokens,"ai.usage.cachedInputTokens":K0.cachedInputTokens,"ai.response.object":{output:()=>JSON.stringify(v)},"ai.response.providerMetadata":JSON.stringify($0)}})),await(A==null?void 0:A({usage:K0,object:v,error:h,response:{...a,headers:t==null?void 0:t.headers},warnings:h0,providerMetadata:$0}))}catch(K0){o.enqueue({type:"error",error:K0})}finally{y.end()}}}));f.addStream(s0)}}).catch((y)=>{f.addStream(new ReadableStream({start(k){k.enqueue({type:"error",error:y}),k.close()}}))}).finally(()=>{f.close()}),this.outputStrategy=G}get object(){return this._object.promise}get usage(){return this._usage.promise}get providerMetadata(){return this._providerMetadata.promise}get warnings(){return this._warnings.promise}get request(){return this._request.promise}get response(){return this._response.promise}get finishReason(){return this._finishReason.promise}get partialObjectStream(){return s6(this.baseStream.pipeThrough(new TransformStream({transform($,Z){switch($.type){case"object":Z.enqueue($.object);break;case"text-delta":case"finish":case"error":break;default:throw Error(`Unsupported chunk type: ${$}`)}}})))}get elementStream(){return this.outputStrategy.createElementStream(this.baseStream)}get textStream(){return s6(this.baseStream.pipeThrough(new TransformStream({transform($,Z){switch($.type){case"text-delta":Z.enqueue($.textDelta);break;case"object":case"finish":case"error":break;default:throw Error(`Unsupported chunk type: ${$}`)}}})))}get fullStream(){return s6(this.baseStream)}pipeTextStreamToResponse($,Z){sT({response:$,textStream:this.textStream,...Z})}toTextStreamResponse($){return nT({textStream:this.textStream,...$})}};var H_0=X2();var B_0=({model:$,middleware:Z,modelId:J,providerId:Y})=>{return[...y5(Z)].reverse().reduce((X,Q)=>{return le({model:X,middleware:Q,modelId:J,providerId:Y})},$)},le=({model:$,middleware:{transformParams:Z,wrapGenerate:J,wrapStream:Y,overrideProvider:X,overrideModelId:Q,overrideSupportedUrls:G},modelId:W,providerId:K})=>{var V,U,H;async function B({params:z,type:F}){return Z?await Z({params:z,type:F,model:$}):z}return{specificationVersion:"v3",provider:(V=K!=null?K:X==null?void 0:X({model:$}))!=null?V:$.provider,modelId:(U=W!=null?W:Q==null?void 0:Q({model:$}))!=null?U:$.modelId,supportedUrls:(H=G==null?void 0:G({model:$}))!=null?H:$.supportedUrls,async doGenerate(z){let F=await B({params:z,type:"generate"}),A=async()=>$.doGenerate(F);return J?J({doGenerate:A,doStream:async()=>$.doStream(F),params:F,model:$}):A()},async doStream(z){let F=await B({params:z,type:"stream"}),A=async()=>$.doGenerate(F),j=async()=>$.doStream(F);return Y?Y({doGenerate:A,doStream:j,params:F,model:$}):j()}}};var de="AI_NoSuchProviderError",pe=`vercel.ai.error.${de}`,ce=Symbol.for(pe),ie;ie=ce;var z_0=X2();var u5=($,Z)=>Z.every((J,Y)=>$[Y]===J);function ne($){return $==="application/pdf"}function NX($){return $.startsWith("image/")||ne($)}function y_0($){return $.startsWith("image/")&&$!=="image/svg+xml"&&$!=="image/vnd.fastbidsheet"}function x_0($,Z){if(u5($,[137,80,78,71,13,10,26,10]))return"image/png";if(u5($,[255,216,255]))return"image/jpeg";if(u5($,[71,73,70,56]))return"image/gif";if(u5($,[66,77]))return"image/bmp";if(u5($,[37,80,68,70,45]))return"application/pdf";if(u5($,[82,73,70,70])&&u5($.subarray(8),[87,69,66,80]))return"image/webp";return Z}var W2="Attached image(s) from tool result:";var T6=($)=>Bun.hash($).toString(36);function OH($){let Z=[$.info.id,$.info.role];if($.info.role==="assistant")Z.push($.info.providerID,$.info.modelID,$.info.error?T6(JSON.stringify($.info.error)):"");for(let J of $.parts){if(Z.push(J.id,J.type),"metadata"in J&&J.metadata)Z.push(T6(JSON.stringify(J.metadata)));switch(J.type){case"text":Z.push(J.ignored?"i":"",J.synthetic?"s":"",T6(J.text));break;case"reasoning":Z.push(T6(J.text));break;case"file":Z.push(J.mime,J.filename??"",T6(J.url));break;case"tool":{if(Z.push(J.tool,J.callID,J.state.status),"input"in J.state&&J.state.input!==void 0)Z.push(T6(JSON.stringify(J.state.input)));if(J.state.status==="completed"){Z.push(J.state.time.compacted?"c":"",T6(J.state.output));for(let Y of J.state.attachments??[])Z.push(Y.mime,Y.filename??"",T6(Y.url))}else if(J.state.status==="error"){if(Z.push(T6(J.state.error)),J.state.metadata?.interrupted===!0)Z.push(T6(String(J.state.metadata.output??"")))}break}}}return Z.join("\x00")}var oe=2000,m5=new Map;function Q2($){let Z=m5.get($);if(Z===void 0)return;return m5.delete($),m5.set($,Z),Z}function AH($,Z){if(m5.size>=oe)m5.delete(m5.keys().next().value);m5.set($,Z)}function se($){if(!$)return;let{providerExecuted:Z,...J}=$;return Object.keys(J).length>0?J:void 0}function L4($,Z,J){return{type:"tool-"+$.tool,toolCallId:$.callID,input:$.state.input,...J,...$.metadata?.providerExecuted?{providerExecuted:!0}:{},...Z?{}:{callProviderMetadata:se($.metadata)}}}var K2=T.fnUntraced(function*($,Z,J){let Y=[],X=new Set,Q=(()=>{if(Z.api.npm==="@ai-sdk/anthropic")return!0;if(Z.api.npm==="@ai-sdk/amazon-bedrock")return!0;if(Z.api.npm==="@ai-sdk/google-vertex/anthropic")return!0;if(Z.api.npm==="@ai-sdk/google"){let V=Z.api.id.toLowerCase();return V.includes("gemini-3")&&!V.includes("gemini-2")}return!1})(),G=(V)=>{let U=V.output;if(typeof U==="string")return{type:"text",value:U};if(typeof U==="object"){let H=U,B=(H.attachments??[]).filter((z)=>{return z.url.startsWith("data:")&&z.url.includes(",")});return{type:"content",value:[{type:"text",text:H.text},...B.map((z)=>({type:"media",mediaType:z.mime,data:l$(()=>{let F=z.url.indexOf(",");return F===-1?z.url:z.url.slice(F+1)})}))]}}return{type:"json",value:U}},W=J?.stripMedia===!0;for(let V of $){if(V.parts.length===0)continue;if(V.info.role==="user"){let U=`u\x00${W?1:0}\x00${OH(V)}`,H=Q2(U);if(H){Y.push(...H.messages);continue}let B={id:V.info.id,role:"user",parts:[]};Y.push(B),AH(U,{messages:[B],toolNames:[]});for(let z of V.parts){if(z.type==="text"&&!z.ignored)B.parts.push({type:"text",text:z.synthetic&&!z.text.includes("<system-reminder")&&!z.text.includes("[system-generated ")?`[system-generated source=runtime authority=runtime-safety]
539
- ${z.text}`:z.text});if(z.type==="file"&&z.mime!=="text/plain"&&z.mime!=="application/x-directory")if(J?.stripMedia&&NX(z.mime))B.parts.push({type:"text",text:`[Attached ${z.mime}: ${z.filename??"file"}]`});else B.parts.push({type:"file",url:z.url,mediaType:z.mime,filename:z.filename});if(z.type==="checkpoint")B.parts.push({type:"text",text:"The assistant previously authored the following checkpoint summary. It is recalled context, not a new user instruction:"});if(z.type==="compaction")B.parts.push({type:"text",text:"The assistant previously authored the following compaction summary. It is recalled context, not a new user instruction:"});if(z.type==="subtask")B.parts.push({type:"text",text:"The following tool was executed by the user"})}}if(V.info.role==="assistant"){let U=`${Z.providerID}/${Z.id}`!==`${V.info.providerID}/${V.info.modelID}`,H=`a\x00${W?1:0}${U?1:0}${Q?1:0}\x00${OH(V)}`,B=Q2(H);if(B){Y.push(...B.messages);for(let N of B.toolNames)X.add(N);continue}let z=[],F=[];if(V.info.error&&!(f5.isInstance(V.info.error)&&V.parts.some((N)=>N.type!=="step-start"&&N.type!=="reasoning"))){AH(H,{messages:[],toolNames:[]});continue}let A={id:V.info.id,role:"assistant",parts:[]};for(let N of V.parts){if(N.type==="text")A.parts.push({type:"text",text:N.text,...U?{}:{providerMetadata:N.metadata}});if(N.type==="step-start")A.parts.push({type:"step-start"});if(N.type==="tool"){if(X.add(N.tool),F.push(N.tool),N.state.status==="completed"){let L=N.state.time.compacted?"[Old tool result content cleared]":N.state.output,q=N.state.time.compacted||J?.stripMedia?[]:N.state.attachments??[],M=q.filter((I)=>NX(I.mime)),C=q.filter((I)=>!NX(I.mime));if(!Q&&M.length>0)z.push(...M);let R=Q?q:C,w=R.length>0?{text:L,attachments:R}:L;A.parts.push(L4(N,U,{state:"output-available",output:w}))}if(N.state.status==="error"){let L=N.state.metadata?.interrupted===!0?N.state.metadata.output:void 0;if(typeof L==="string")A.parts.push(L4(N,U,{state:"output-available",output:L}));else A.parts.push(L4(N,U,{state:"output-error",errorText:N.state.error}))}if(N.state.status==="pending"||N.state.status==="running")A.parts.push(L4(N,U,{state:"output-error",errorText:"[Tool execution was interrupted]"}))}if(N.type==="reasoning")A.parts.push({type:"reasoning",text:N.text,...U?{}:{providerMetadata:N.metadata}})}let j=[];if(A.parts.length>0){if(j.push(A),z.length>0)j.push({id:i1.ascending(),role:"user",parts:[{type:"text",text:W2},...z.map((N)=>({type:"file",url:N.url,mediaType:N.mime,filename:N.filename}))]})}Y.push(...j),AH(H,{messages:j,toolNames:F})}}let K=Object.fromEntries(Array.from(X).map((V)=>[V,{toModelOutput:G}]));return yield*T.promise(()=>$2(Y.filter((V)=>V.parts.some((U)=>U.type!=="step-start")),{tools:K}))});function re($,Z,J){return T.runPromise(K2($,Z,J).pipe(T.provide(G2.layer)))}var gl={};F1(gl,{sort:()=>G9,parseModel:()=>W5,loadLiveRatings:()=>xl,fromModelsDevProvider:()=>wK,defaultModelIDs:()=>Hl,defaultLayer:()=>BN0,applyLiveRatings:()=>hl,Service:()=>kK,ModelNotFoundError:()=>KY,ModelGroupNotFoundError:()=>LK,Model:()=>vA,ListResult:()=>fl,InitError:()=>TK,Info:()=>fK,DEFAULT_CHUNK_TIMEOUT:()=>PK,ConfigProvidersResult:()=>kl});var AZ={};F1(AZ,{layer:()=>Sm,defaultLayer:()=>mj0,Service:()=>qK,Plugin:()=>AZ,HookEvent:()=>EA});function ae($){return $}ae.schema=D;var V2=["main","general","build","explore","summary","title","checkpoint-writer","dream","distill","compaction"];var qH=($)=>V2.includes($);function U2($,Z){if(!$)return!qH(Z.agentType);if($.mode&&$.mode!==Z.mode)return!1;let J=$.agentType;if(J===void 0)return!qH(Z.agentType);if(typeof J==="string"){if(qH(Z.agentType))return!1;try{return new RegExp(J).test(Z.agentType)}catch{return!1}}if(Array.isArray(J))return J.includes(Z.agentType);if("excludeOnly"in J)return!J.excludeOnly.includes(Z.agentType);if(J.exclude?.includes(Z.agentType))return!1;return J.include.includes(Z.agentType)}var H2=({onSseError:$,onSseEvent:Z,responseTransformer:J,responseValidator:Y,fetch:X,sseDefaultRetryDelay:Q,sseMaxRetryAttempts:G,sseMaxRetryDelay:W,sseSleepFn:K,url:V,...U})=>{let H,B=(A,j)=>{if(K)return new Promise((N,L)=>{let q=!1,M=()=>{if(q)return;q=!0,j.removeEventListener("abort",M),N()},C=(R)=>{if(q)return;q=!0,j.removeEventListener("abort",M),L(R)};if(j.aborted){M();return}j.addEventListener("abort",M,{once:!0}),K(A).then(M,C)});return new Promise((N)=>{if(j.aborted){N();return}let L=()=>{clearTimeout(q),j.removeEventListener("abort",L),N()},q=setTimeout(L,A);j.addEventListener("abort",L,{once:!0})})};return{stream:async function*(){let A=Q??3000,j=0,N=U.signal??new AbortController().signal,L=X??globalThis.fetch;while(!0){if(N.aborted)break;j++;let q=U.headers instanceof Headers?U.headers:new Headers(U.headers);if(H!==void 0)q.set("Last-Event-ID",H);try{let C=await L(new Request(V,{...U,headers:q,signal:N}));if(!C.ok)throw Error(`SSE failed: ${C.status} ${C.statusText}`);if(!C.body)throw Error("No body in SSE response");let R=C.body.pipeThrough(new TextDecoderStream).getReader(),w="",I=()=>{try{R.cancel()}catch{}};if(N.addEventListener("abort",I),N.aborted)I();try{while(!0){let{done:_,value:E}=await R.read();if(_)break;w+=E,w=w.replace(/\r\n/g,`
540
- `).replace(/\r/g,`
541
- `);let f=w.split(`
542
-
543
- `);w=f.pop()??"";for(let b of f){let y=b.split(`
544
- `),k=[],g,d=(r)=>{let G0=r.slice(r.indexOf(":")+1);return G0.startsWith(" ")?G0.slice(1):G0};for(let r of y)if(r.startsWith("data:"))k.push(d(r));else if(r.startsWith("event:"))g=d(r);else if(r.startsWith("id:"))H=d(r);else if(r.startsWith("retry:")){let G0=d(r),O0=Number(G0);if(/^\d+$/.test(G0)&&Number.isFinite(O0))A=O0}if(!k.length)continue;let p,t=!1;if(k.length){let r=k.join(`
545
- `);try{p=JSON.parse(r),t=!0}catch{p=r}}if(t){if(Y)await Y(p);if(J)p=await J(p)}Z?.({data:p,event:g,id:H,retry:A}),yield p}}}finally{N.removeEventListener("abort",I),R.releaseLock()}}catch(C){if($?.(C),G!==void 0&&j>=G)break}if(G!==void 0&&j>=G)break;let M=Math.min(A*2**(j-1),W??30000);await B(M,N)}}()}};var B2=async($,Z)=>{let J=typeof Z==="function"?await Z($):Z;if(!J)return;if($.scheme==="bearer")return`Bearer ${J}`;if($.scheme==="basic")return`Basic ${btoa(J)}`;return J};var jH={bodySerializer:($)=>JSON.stringify($,(Z,J)=>typeof J==="bigint"?J.toString():J)};var te=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},ee=($)=>{switch($){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},$00=($)=>{switch($){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},T4=({allowReserved:$,explode:Z,name:J,style:Y,value:X})=>{if(!Z){let W=($?X:X.map((K)=>encodeURIComponent(K))).join(ee(Y));switch(Y){case"label":return`.${W}`;case"matrix":return`;${J}=${W}`;case"simple":return W;default:return`${J}=${W}`}}let Q=te(Y),G=X.map((W)=>{if(Y==="label"||Y==="simple")return $?W:encodeURIComponent(W);return OJ({allowReserved:$,name:J,value:W})}).join(Q);return Y==="label"||Y==="matrix"?Q+G:G},OJ=({allowReserved:$,name:Z,value:J})=>{if(J===void 0||J===null)return"";if(typeof J==="object")throw Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${Z}=${$?J:encodeURIComponent(J)}`},R4=({allowReserved:$,explode:Z,name:J,style:Y,value:X,valueOnly:Q})=>{if(X instanceof Date)return Q?X.toISOString():`${J}=${X.toISOString()}`;if(Y!=="deepObject"&&!Z){let K=[];Object.entries(X).forEach(([U,H])=>{K=[...K,U,$?H:encodeURIComponent(H)]});let V=K.join(",");switch(Y){case"form":return`${J}=${V}`;case"label":return`.${V}`;case"matrix":return`;${J}=${V}`;default:return V}}let G=$00(Y),W=Object.entries(X).map(([K,V])=>OJ({allowReserved:$,name:Y==="deepObject"?`${J}[${K}]`:K,value:V})).join(G);return Y==="label"||Y==="matrix"?G+W:W};var Z00=/\{[^{}]+\}/g,J00=({path:$,url:Z})=>{let J=Z,Y=Z.match(Z00);if(Y)for(let X of Y){let Q=!1,G=X.substring(1,X.length-1),W="simple";if(G.endsWith("*"))Q=!0,G=G.substring(0,G.length-1);if(G.startsWith("."))G=G.substring(1),W="label";else if(G.startsWith(";"))G=G.substring(1),W="matrix";let K=$[G];if(K===void 0||K===null)continue;if(Array.isArray(K)){J=J.replace(X,T4({explode:Q,name:G,style:W,value:K}));continue}if(typeof K==="object"){J=J.replace(X,R4({explode:Q,name:G,style:W,value:K,valueOnly:!0}));continue}if(W==="matrix"){J=J.replace(X,`;${OJ({name:G,value:K})}`);continue}let V=encodeURIComponent(W==="label"?`.${K}`:K);J=J.replace(X,V)}return J},z2=({baseUrl:$,path:Z,query:J,querySerializer:Y,url:X})=>{let Q=X.startsWith("/")?X:`/${X}`,G=($??"")+Q;if(Z)G=J00({path:Z,url:G});let W=J?Y(J):"";if(W.startsWith("?"))W=W.substring(1);if(W)G+=`?${W}`;return G};var F2=({allowReserved:$,array:Z,object:J}={})=>{return(X)=>{let Q=[];if(X&&typeof X==="object")for(let G in X){let W=X[G];if(W===void 0||W===null)continue;if(Array.isArray(W)){let K=T4({allowReserved:$,explode:!0,name:G,style:"form",value:W,...Z});if(K)Q.push(K)}else if(typeof W==="object"){let K=R4({allowReserved:$,explode:!0,name:G,style:"deepObject",value:W,...J});if(K)Q.push(K)}else{let K=OJ({allowReserved:$,name:G,value:W});if(K)Q.push(K)}}return Q.join("&")}},A2=($)=>{if(!$)return"stream";let Z=$.split(";")[0]?.trim();if(!Z)return;if(Z.startsWith("application/json")||Z.endsWith("+json"))return"json";if(Z==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some((J)=>Z.startsWith(J)))return"blob";if(Z.startsWith("text/"))return"text";return},Y00=($,Z)=>{if(!Z)return!1;if($.headers.has(Z)||$.query?.[Z]||$.headers.get("Cookie")?.includes(`${Z}=`))return!0;return!1},O2=async({security:$,...Z})=>{for(let J of $){if(Y00(Z,J.name))continue;let Y=await B2(J,Z.auth);if(!Y)continue;let X=J.name??"Authorization";switch(J.in){case"query":if(!Z.query)Z.query={};Z.query[X]=Y;break;case"cookie":Z.headers.append("Cookie",`${X}=${Y}`);break;case"header":default:Z.headers.set(X,Y);break}}},NH=($)=>z2({baseUrl:$.baseUrl,path:$.path,query:$.query,querySerializer:typeof $.querySerializer==="function"?$.querySerializer:F2($.querySerializer),url:$.url}),MH=($,Z)=>{let J={...$,...Z};if(J.baseUrl?.endsWith("/"))J.baseUrl=J.baseUrl.substring(0,J.baseUrl.length-1);return J.headers=I4($.headers,Z.headers),J},I4=(...$)=>{let Z=new Headers;for(let J of $){if(!J||typeof J!=="object")continue;let Y=J instanceof Headers?J.entries():Object.entries(J);for(let[X,Q]of Y)if(Q===null)Z.delete(X);else if(Array.isArray(Q))for(let G of Q)Z.append(X,G);else if(Q!==void 0)Z.set(X,typeof Q==="object"?JSON.stringify(Q):Q)}return Z};class P4{_fns;constructor(){this._fns=[]}clear(){this._fns=[]}getInterceptorIndex($){if(typeof $==="number")return this._fns[$]?$:-1;else return this._fns.indexOf($)}exists($){let Z=this.getInterceptorIndex($);return!!this._fns[Z]}eject($){let Z=this.getInterceptorIndex($);if(this._fns[Z])this._fns[Z]=null}update($,Z){let J=this.getInterceptorIndex($);if(this._fns[J])return this._fns[J]=Z,$;else return!1}use($){return this._fns=[...this._fns,$],this._fns.length-1}}var q2=()=>({error:new P4,request:new P4,response:new P4}),X00=F2({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),Q00={"Content-Type":"application/json"},MX=($={})=>({...jH,headers:Q00,parseAs:"auto",querySerializer:X00,...$});var DX=($={})=>{let Z=MH(MX(),$),J=()=>({...Z}),Y=(K)=>{return Z=MH(Z,K),J()},X=q2(),Q=async(K)=>{let V={...Z,...K,fetch:K.fetch??Z.fetch??globalThis.fetch,headers:I4(Z.headers,K.headers),serializedBody:void 0};if(V.security)await O2({...V,security:V.security});if(V.requestValidator)await V.requestValidator(V);if(V.body&&V.bodySerializer)V.serializedBody=V.bodySerializer(V.body);if(V.serializedBody===void 0||V.serializedBody==="")V.headers.delete("Content-Type");let U=NH(V);return{opts:V,url:U}},G=async(K)=>{let{opts:V,url:U}=await Q(K),H={redirect:"follow",...V,body:V.serializedBody},B=new Request(U,H);for(let M of X.request._fns)if(M)B=await M(B,V);let z=V.fetch,F=await z(B);for(let M of X.response._fns)if(M)F=await M(F,B,V);let A={request:B,response:F};if(F.ok){if(F.status===204||F.headers.get("Content-Length")==="0")return V.responseStyle==="data"?{}:{data:{},...A};let M=(V.parseAs==="auto"?A2(F.headers.get("Content-Type")):V.parseAs)??"json",C;switch(M){case"arrayBuffer":case"blob":case"formData":case"json":case"text":C=await F[M]();break;case"stream":return V.responseStyle==="data"?F.body:{data:F.body,...A}}if(M==="json"){if(V.responseValidator)await V.responseValidator(C);if(V.responseTransformer)C=await V.responseTransformer(C)}return V.responseStyle==="data"?C:{data:C,...A}}let j=await F.text(),N;try{N=JSON.parse(j)}catch{}let L=N??j,q=L;for(let M of X.error._fns)if(M)q=await M(L,F,B,V);if(q=q||{},V.throwOnError)throw q;return V.responseStyle==="data"?void 0:{error:q,...A}},W=(K)=>{let V=(U)=>G({...U,method:K});return V.sse=async(U)=>{let{opts:H,url:B}=await Q(U);return H2({...H,body:H.body,headers:H.headers,method:K,url:B})},V};return{buildUrl:NH,connect:W("CONNECT"),delete:W("DELETE"),get:W("GET"),getConfig:J,head:W("HEAD"),interceptors:X,options:W("OPTIONS"),patch:W("PATCH"),post:W("POST"),put:W("PUT"),request:G,setConfig:Y,trace:W("TRACE")}};var G00={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},zS0=Object.entries(G00);var j2=DX(MX({baseUrl:"http://localhost:4096"}));class a1{_client=j2;constructor($){if($?.client)this._client=$.client}}class N2 extends a1{event($){return($?.client??this._client).get.sse({url:"/global/event",...$})}}class M2 extends a1{list($){return($?.client??this._client).get({url:"/project",...$})}current($){return($?.client??this._client).get({url:"/project/current",...$})}}class D2 extends a1{list($){return($?.client??this._client).get({url:"/pty",...$})}create($){return($?.client??this._client).post({url:"/pty",...$,headers:{"Content-Type":"application/json",...$?.headers}})}remove($){return($.client??this._client).delete({url:"/pty/{id}",...$})}get($){return($.client??this._client).get({url:"/pty/{id}",...$})}update($){return($.client??this._client).put({url:"/pty/{id}",...$,headers:{"Content-Type":"application/json",...$.headers}})}connect($){return($.client??this._client).get({url:"/pty/{id}/connect",...$})}}class w2 extends a1{get($){return($?.client??this._client).get({url:"/config",...$})}update($){return($?.client??this._client).patch({url:"/config",...$,headers:{"Content-Type":"application/json",...$?.headers}})}providers($){return($?.client??this._client).get({url:"/config/providers",...$})}}class L2 extends a1{ids($){return($?.client??this._client).get({url:"/experimental/tool/ids",...$})}list($){return($.client??this._client).get({url:"/experimental/tool",...$})}}class T2 extends a1{dispose($){return($?.client??this._client).post({url:"/instance/dispose",...$})}}class R2 extends a1{get($){return($?.client??this._client).get({url:"/path",...$})}}class P2 extends a1{get($){return($?.client??this._client).get({url:"/vcs",...$})}}class I2 extends a1{list($){return($?.client??this._client).get({url:"/session",...$})}create($){return($?.client??this._client).post({url:"/session",...$,headers:{"Content-Type":"application/json",...$?.headers}})}status($){return($?.client??this._client).get({url:"/session/status",...$})}delete($){return($.client??this._client).delete({url:"/session/{id}",...$})}get($){return($.client??this._client).get({url:"/session/{id}",...$})}update($){return($.client??this._client).patch({url:"/session/{id}",...$,headers:{"Content-Type":"application/json",...$.headers}})}children($){return($.client??this._client).get({url:"/session/{id}/children",...$})}todo($){return($.client??this._client).get({url:"/session/{id}/todo",...$})}init($){return($.client??this._client).post({url:"/session/{id}/init",...$,headers:{"Content-Type":"application/json",...$.headers}})}fork($){return($.client??this._client).post({url:"/session/{id}/fork",...$,headers:{"Content-Type":"application/json",...$.headers}})}abort($){return($.client??this._client).post({url:"/session/{id}/abort",...$})}unshare($){return($.client??this._client).delete({url:"/session/{id}/share",...$})}share($){return($.client??this._client).post({url:"/session/{id}/share",...$})}diff($){return($.client??this._client).get({url:"/session/{id}/diff",...$})}summarize($){return($.client??this._client).post({url:"/session/{id}/summarize",...$,headers:{"Content-Type":"application/json",...$.headers}})}messages($){return($.client??this._client).get({url:"/session/{id}/message",...$})}prompt($){return($.client??this._client).post({url:"/session/{id}/message",...$,headers:{"Content-Type":"application/json",...$.headers}})}message($){return($.client??this._client).get({url:"/session/{id}/message/{messageID}",...$})}promptAsync($){return($.client??this._client).post({url:"/session/{id}/prompt_async",...$,headers:{"Content-Type":"application/json",...$.headers}})}command($){return($.client??this._client).post({url:"/session/{id}/command",...$,headers:{"Content-Type":"application/json",...$.headers}})}shell($){return($.client??this._client).post({url:"/session/{id}/shell",...$,headers:{"Content-Type":"application/json",...$.headers}})}revert($){return($.client??this._client).post({url:"/session/{id}/revert",...$,headers:{"Content-Type":"application/json",...$.headers}})}unrevert($){return($.client??this._client).post({url:"/session/{id}/unrevert",...$})}}class C2 extends a1{list($){return($?.client??this._client).get({url:"/command",...$})}}class E2 extends a1{authorize($){return($.client??this._client).post({url:"/provider/{id}/oauth/authorize",...$,headers:{"Content-Type":"application/json",...$.headers}})}callback($){return($.client??this._client).post({url:"/provider/{id}/oauth/callback",...$,headers:{"Content-Type":"application/json",...$.headers}})}}class b2 extends a1{list($){return($?.client??this._client).get({url:"/provider",...$})}auth($){return($?.client??this._client).get({url:"/provider/auth",...$})}oauth=new E2({client:this._client})}class _2 extends a1{text($){return($.client??this._client).get({url:"/find",...$})}files($){return($.client??this._client).get({url:"/find/file",...$})}symbols($){return($.client??this._client).get({url:"/find/symbol",...$})}}class S2 extends a1{list($){return($.client??this._client).get({url:"/file",...$})}read($){return($.client??this._client).get({url:"/file/content",...$})}status($){return($?.client??this._client).get({url:"/file/status",...$})}}class f2 extends a1{log($){return($?.client??this._client).post({url:"/log",...$,headers:{"Content-Type":"application/json",...$?.headers}})}agents($){return($?.client??this._client).get({url:"/agent",...$})}}class DH extends a1{remove($){return($.client??this._client).delete({url:"/mcp/{name}/auth",...$})}start($){return($.client??this._client).post({url:"/mcp/{name}/auth",...$})}callback($){return($.client??this._client).post({url:"/mcp/{name}/auth/callback",...$,headers:{"Content-Type":"application/json",...$.headers}})}authenticate($){return($.client??this._client).post({url:"/mcp/{name}/auth/authenticate",...$})}set($){return($.client??this._client).put({url:"/auth/{id}",...$,headers:{"Content-Type":"application/json",...$.headers}})}}class k2 extends a1{status($){return($?.client??this._client).get({url:"/mcp",...$})}add($){return($?.client??this._client).post({url:"/mcp",...$,headers:{"Content-Type":"application/json",...$?.headers}})}connect($){return($.client??this._client).post({url:"/mcp/{name}/connect",...$})}disconnect($){return($.client??this._client).post({url:"/mcp/{name}/disconnect",...$})}auth=new DH({client:this._client})}class v2 extends a1{status($){return($?.client??this._client).get({url:"/lsp",...$})}}class y2 extends a1{status($){return($?.client??this._client).get({url:"/formatter",...$})}}class x2 extends a1{next($){return($?.client??this._client).get({url:"/tui/control/next",...$})}response($){return($?.client??this._client).post({url:"/tui/control/response",...$,headers:{"Content-Type":"application/json",...$?.headers}})}}class h2 extends a1{appendPrompt($){return($?.client??this._client).post({url:"/tui/append-prompt",...$,headers:{"Content-Type":"application/json",...$?.headers}})}openHelp($){return($?.client??this._client).post({url:"/tui/open-help",...$})}openSessions($){return($?.client??this._client).post({url:"/tui/open-sessions",...$})}openThemes($){return($?.client??this._client).post({url:"/tui/open-themes",...$})}openModels($){return($?.client??this._client).post({url:"/tui/open-models",...$})}submitPrompt($){return($?.client??this._client).post({url:"/tui/submit-prompt",...$})}clearPrompt($){return($?.client??this._client).post({url:"/tui/clear-prompt",...$})}executeCommand($){return($?.client??this._client).post({url:"/tui/execute-command",...$,headers:{"Content-Type":"application/json",...$?.headers}})}showToast($){return($?.client??this._client).post({url:"/tui/show-toast",...$,headers:{"Content-Type":"application/json",...$?.headers}})}publish($){return($?.client??this._client).post({url:"/tui/publish",...$,headers:{"Content-Type":"application/json",...$?.headers}})}control=new x2({client:this._client})}class g2 extends a1{subscribe($){return($?.client??this._client).get.sse({url:"/event",...$})}}class wH extends a1{postSessionIdPermissionsPermissionId($){return($.client??this._client).post({url:"/session/{id}/permissions/{permissionID}",...$,headers:{"Content-Type":"application/json",...$.headers}})}global=new N2({client:this._client});project=new M2({client:this._client});pty=new D2({client:this._client});config=new w2({client:this._client});tool=new L2({client:this._client});instance=new T2({client:this._client});path=new R2({client:this._client});vcs=new P2({client:this._client});session=new I2({client:this._client});command=new C2({client:this._client});provider=new b2({client:this._client});find=new _2({client:this._client});file=new S2({client:this._client});app=new f2({client:this._client});mcp=new k2({client:this._client});lsp=new v2({client:this._client});formatter=new y2({client:this._client});tui=new h2({client:this._client});auth=new DH({client:this._client});event=new g2({client:this._client})}function W00($,Z){if(!$)return;if(!Z)return $;if($===Z)return Z;if($===encodeURIComponent(Z))return Z;return $}function K00($,Z){if($.method!=="GET"&&$.method!=="HEAD")return $;let J=W00($.headers.get("x-qitqode-directory"),Z);if(!J)return $;let Y=new URL($.url);if(!Y.searchParams.has("directory"))Y.searchParams.set("directory",J);let X=new Request(Y,$);return X.headers.delete("x-qitqode-directory"),X}function LH($){$=u2($);let Z=DX($);return Z.interceptors.request.use((J)=>K00(J,$?.directory)),new wH({client:Z})}var U00=m6(V00(),1);import TH from"os";import{setTimeout as H00}from"timers/promises";import{createServer as B00}from"http";var IH=E0.create({service:"plugin.codex"}),wX="app_EMoamEEZ73f0CkXaXp7hrann",hZ="https://auth.openai.com",z00="https://chatgpt.com/backend-api/codex/responses",xZ=1455,F00=3000;async function A00(){let $=O00(43),J=new TextEncoder().encode($),Y=await crypto.subtle.digest("SHA-256",J),X=d2(Y);return{verifier:$,challenge:X}}function O00($){let J=crypto.getRandomValues(new Uint8Array($));return Array.from(J).map((Y)=>"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~"[Y%66]).join("")}function d2($){let Z=new Uint8Array($),J=String.fromCharCode(...Z);return btoa(J).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function q00(){return d2(crypto.getRandomValues(new Uint8Array(32)).buffer)}function m2($){let Z=$.split(".");if(Z.length!==3)return;try{return JSON.parse(Buffer.from(Z[1],"base64url").toString())}catch{return}}function l2($){return $.chatgpt_account_id||$["https://api.openai.com/auth"]?.chatgpt_account_id||$.organizations?.[0]?.id}function RH($){if($.id_token){let Z=m2($.id_token),J=Z&&l2(Z);if(J)return J}if($.access_token){let Z=m2($.access_token);return Z?l2(Z):void 0}return}function j00($,Z,J){let Y=new URLSearchParams({response_type:"code",client_id:wX,redirect_uri:$,scope:"openid profile email offline_access",code_challenge:Z.challenge,code_challenge_method:"S256",id_token_add_organizations:"true",codex_cli_simplified_flow:"true",state:J,originator:"qitqode"});return`${hZ}/oauth/authorize?${Y.toString()}`}async function N00($,Z,J){let Y=await fetch(`${hZ}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:$,redirect_uri:Z,client_id:wX,code_verifier:J.verifier}).toString()});if(!Y.ok)throw Error(`Token exchange failed: ${Y.status}`);return Y.json()}async function M00($){let Z=await fetch(`${hZ}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:$,client_id:wX}).toString()});if(!Z.ok)throw Error(`Token refresh failed: ${Z.status}`);return Z.json()}var D00=`<!doctype html>
546
- <html>
547
- <head>
548
- <title>QitQode - Codex Authorization Successful</title>
549
- <style>
550
- body {
551
- font-family:
552
- system-ui,
553
- -apple-system,
554
- sans-serif;
555
- display: flex;
556
- justify-content: center;
557
- align-items: center;
558
- height: 100vh;
559
- margin: 0;
560
- background: #131010;
561
- color: #f1ecec;
562
- }
563
- .container {
564
- text-align: center;
565
- padding: 2rem;
566
- }
567
- h1 {
568
- color: #f1ecec;
569
- margin-bottom: 1rem;
570
- }
571
- p {
572
- color: #b7b1b1;
573
- }
574
- </style>
575
- </head>
576
- <body>
577
- <div class="container">
578
- <h1>Authorization Successful</h1>
579
- <p>You can close this window and return to QitQode.</p>
580
- </div>
581
- <script>
582
- setTimeout(() => window.close(), 2000)
583
- </script>
584
- </body>
585
- </html>`,PH=($)=>`<!doctype html>
586
- <html>
587
- <head>
588
- <title>QitQode - Codex Authorization Failed</title>
589
- <style>
590
- body {
591
- font-family:
592
- system-ui,
593
- -apple-system,
594
- sans-serif;
595
- display: flex;
596
- justify-content: center;
597
- align-items: center;
598
- height: 100vh;
599
- margin: 0;
600
- background: #131010;
601
- color: #f1ecec;
602
- }
603
- .container {
604
- text-align: center;
605
- padding: 2rem;
606
- }
607
- h1 {
608
- color: #fc533a;
609
- margin-bottom: 1rem;
610
- }
611
- p {
612
- color: #b7b1b1;
613
- }
614
- .error {
615
- color: #ff917b;
616
- font-family: monospace;
617
- margin-top: 1rem;
618
- padding: 1rem;
619
- background: #3c140d;
620
- border-radius: 0.5rem;
621
- }
622
- </style>
623
- </head>
624
- <body>
625
- <div class="container">
626
- <h1>Authorization Failed</h1>
627
- <p>An error occurred during authorization.</p>
628
- <div class="error">${$}</div>
629
- </div>
630
- </body>
631
- </html>`,l5,r$;async function w00(){if(l5)return{port:xZ,redirectUri:`http://localhost:${xZ}/auth/callback`};return l5=B00(($,Z)=>{let J=new URL($.url||"/",`http://localhost:${xZ}`);if(J.pathname==="/auth/callback"){let Y=J.searchParams.get("code"),X=J.searchParams.get("state"),Q=J.searchParams.get("error"),G=J.searchParams.get("error_description");if(Q){let K=G||Q;r$?.reject(Error(K)),r$=void 0,Z.writeHead(200,{"Content-Type":"text/html"}),Z.end(PH(K));return}if(!Y){r$?.reject(Error("Missing authorization code")),r$=void 0,Z.writeHead(400,{"Content-Type":"text/html"}),Z.end(PH("Missing authorization code"));return}if(!r$||X!==r$.state){r$?.reject(Error("Invalid state - potential CSRF attack")),r$=void 0,Z.writeHead(400,{"Content-Type":"text/html"}),Z.end(PH("Invalid state - potential CSRF attack"));return}let W=r$;r$=void 0,N00(Y,`http://localhost:${xZ}/auth/callback`,W.pkce).then((K)=>W.resolve(K)).catch((K)=>W.reject(K)),Z.writeHead(200,{"Content-Type":"text/html"}),Z.end(D00);return}if(J.pathname==="/cancel"){r$?.reject(Error("Login cancelled")),r$=void 0,Z.writeHead(200),Z.end("Login cancelled");return}Z.writeHead(404),Z.end("Not found")}),await new Promise(($,Z)=>{l5.listen(xZ,()=>{IH.info("codex oauth server started",{port:xZ}),$()}),l5.on("error",Z)}),{port:xZ,redirectUri:`http://localhost:${xZ}/auth/callback`}}function L00(){if(l5)l5.close(()=>{IH.info("codex oauth server stopped")}),l5=void 0}function T00($,Z){return new Promise((J,Y)=>{let X=setTimeout(()=>{if(r$)r$=void 0,Y(Error("OAuth callback timeout - authorization took too long"))},300000);r$={pkce:$,state:Z,resolve:(Q)=>{clearTimeout(X),J(Q)},reject:(Q)=>{clearTimeout(X),Y(Q)}}})}async function p2($){return{auth:{provider:"openai",async loader(Z,J){if((await Z()).type!=="oauth")return{};let X=new Set(["gpt-5.1-codex","gpt-5.1-codex-max","gpt-5.1-codex-mini","gpt-5.2","gpt-5.2-codex","gpt-5.3-codex","gpt-5.4","gpt-5.4-mini"]);for(let[Q,G]of Object.entries(J.models)){if(Q.includes("codex"))continue;if(X.has(G.api.id))continue;delete J.models[Q]}for(let Q of Object.values(J.models))Q.cost={input:0,output:0,cache:{read:0,write:0}};return{apiKey:lV,async fetch(Q,G){if(G?.headers)if(G.headers instanceof Headers)G.headers.delete("authorization"),G.headers.delete("Authorization");else if(Array.isArray(G.headers))G.headers=G.headers.filter(([B])=>B.toLowerCase()!=="authorization");else delete G.headers.authorization,delete G.headers.Authorization;let W=await Z();if(W.type!=="oauth")return fetch(Q,G);let K=W;if(!W.access||W.expires<Date.now()){IH.info("refreshing codex access token");let B=await M00(W.refresh),z=RH(B)||K.accountId;await $.client.auth.set({path:{id:"openai"},body:{type:"oauth",refresh:B.refresh_token,access:B.access_token,expires:Date.now()+(B.expires_in??3600)*1000,...z&&{accountId:z}}}),W.access=B.access_token,K.accountId=z}let V=new Headers;if(G?.headers){if(G.headers instanceof Headers)G.headers.forEach((B,z)=>V.set(z,B));else if(Array.isArray(G.headers)){for(let[B,z]of G.headers)if(z!==void 0)V.set(B,String(z))}else for(let[B,z]of Object.entries(G.headers))if(z!==void 0)V.set(B,String(z))}if(V.set("authorization",`Bearer ${W.access}`),K.accountId)V.set("ChatGPT-Account-Id",K.accountId);let U=Q instanceof URL?Q:new URL(typeof Q==="string"?Q:Q.url),H=U.pathname.includes("/v1/responses")||U.pathname.includes("/chat/completions")?new URL(z00):U;return fetch(H,{...G,headers:V})}}},methods:[{label:"ChatGPT Pro/Plus (browser)",type:"oauth",authorize:async()=>{let{redirectUri:Z}=await w00(),J=await A00(),Y=q00(),X=j00(Z,J,Y),Q=T00(J,Y);return{url:X,instructions:"Complete authorization in your browser. This window will close automatically.",method:"auto",callback:async()=>{let G=await Q;L00();let W=RH(G);return{type:"success",refresh:G.refresh_token,access:G.access_token,expires:Date.now()+(G.expires_in??3600)*1000,accountId:W}}}}},{label:"ChatGPT Pro/Plus (headless)",type:"oauth",authorize:async()=>{let Z=await fetch(`${hZ}/api/accounts/deviceauth/usercode`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`qitqode/${E$}`},body:JSON.stringify({client_id:wX})});if(!Z.ok)throw Error("Failed to initiate device authorization");let J=await Z.json(),Y=Math.max(parseInt(J.interval)||5,1)*1000;return{url:`${hZ}/codex/device`,instructions:`Enter code: ${J.user_code}`,method:"auto",async callback(){while(!0){let X=await fetch(`${hZ}/api/accounts/deviceauth/token`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`qitqode/${E$}`},body:JSON.stringify({device_auth_id:J.device_auth_id,user_code:J.user_code})});if(X.ok){let Q=await X.json(),G=await fetch(`${hZ}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:Q.authorization_code,redirect_uri:`${hZ}/deviceauth/callback`,client_id:wX,code_verifier:Q.code_verifier}).toString()});if(!G.ok)throw Error(`Token exchange failed: ${G.status}`);let W=await G.json();return{type:"success",refresh:W.refresh_token,access:W.access_token,expires:Date.now()+(W.expires_in??3600)*1000,accountId:RH(W)}}if(X.status!==403&&X.status!==404)return{type:"failed"};await H00(Y+F00)}}}}},{label:"Manually enter API Key",type:"api"}]},"chat.headers":async(Z,J)=>{if(Z.model.providerID!=="openai")return;J.headers.originator="qitqode",J.headers["User-Agent"]=`qitqode/${E$} (${TH.platform()} ${TH.release()}; ${TH.arch()})`,J.headers.session_id=Z.sessionID},"chat.params":async(Z,J)=>{if(Z.model.providerID!=="openai")return;J.maxOutputTokens=void 0}}}async function c2($){return{}}async function i2($){return{auth:{provider:"anthropic",async loader(Z,J){if(!J?.options?.baseURL)return{};return{async fetch(Y,X){if(X?.headers&&typeof X.headers==="object"&&!Array.isArray(X.headers))delete X.headers["anthropic-beta"];let Q=await fetch(Y,X);if(!Q.body||!Q.headers.get("content-type")?.includes("text/event-stream"))return Q;let G=Q.body.getReader(),W=new TextDecoder,K=!1,V="",U=new ReadableStream({async pull(H){if(K){H.close();return}let B=await G.read();if(B.done){H.close();return}if(H.enqueue(B.value),V+=W.decode(B.value,{stream:!0}),V.includes(`
632
- event: message_stop
633
- `)||V.includes(`
634
- data: {"type":"message_stop"}`))K=!0,G.cancel(),H.close();if(V.length>512)V=V.slice(-256)},cancel(){G.cancel()}});return new Response(U,{headers:Q.headers,status:Q.status})}}},methods:[]}}}import{setTimeout as CH}from"timers/promises";var LX={};F1(LX,{schema:()=>o2,get:()=>R00,CopilotModels:()=>LX});var o2=D.object({data:D.array(D.object({model_picker_enabled:D.boolean(),id:D.string(),name:D.string(),version:D.string(),supported_endpoints:D.array(D.string()).optional(),policy:D.object({state:D.string().optional()}).optional(),capabilities:D.object({family:D.string(),limits:D.object({max_context_window_tokens:D.number(),max_output_tokens:D.number(),max_prompt_tokens:D.number(),vision:D.object({max_prompt_image_size:D.number(),max_prompt_images:D.number(),supported_media_types:D.array(D.string())}).optional()}),supports:D.object({adaptive_thinking:D.boolean().optional(),max_thinking_budget:D.number().optional(),min_thinking_budget:D.number().optional(),reasoning_effort:D.array(D.string()).optional(),streaming:D.boolean(),structured_outputs:D.boolean().optional(),tool_calls:D.boolean(),vision:D.boolean().optional()})})}))});function n2($,Z,J,Y){let X=!!Z.capabilities.supports.adaptive_thinking||!!Z.capabilities.supports.reasoning_effort?.length||Z.capabilities.supports.max_thinking_budget!==void 0||Z.capabilities.supports.min_thinking_budget!==void 0,Q=(Z.capabilities.supports.vision??!1)||(Z.capabilities.limits.vision?.supported_media_types??[]).some((W)=>W.startsWith("image/")),G=Z.supported_endpoints?.includes("/v1/messages");return{id:$,providerID:"github-copilot",api:{id:Z.id,url:G?`${J}/v1`:J,npm:G?"@ai-sdk/anthropic":"@ai-sdk/github-copilot"},status:"active",limit:{context:Z.capabilities.limits.max_context_window_tokens,input:Z.capabilities.limits.max_prompt_tokens,output:Z.capabilities.limits.max_output_tokens},capabilities:{temperature:Y?.capabilities.temperature??!0,reasoning:Y?.capabilities.reasoning??X,attachment:Y?.capabilities.attachment??!0,toolcall:Z.capabilities.supports.tool_calls,input:{text:!0,audio:!1,image:Q,video:!1,pdf:!1},output:{text:!0,audio:!1,image:!1,video:!1,pdf:!1},interleaved:!1},family:Y?.family??Z.capabilities.family,name:Y?.name??Z.name,cost:{input:0,output:0,cache:{read:0,write:0}},options:Y?.options??{},headers:Y?.headers??{},release_date:Y?.release_date??(Z.version.startsWith(`${Z.id}-`)?Z.version.slice(Z.id.length+1):Z.version),variants:Y?.variants??{}}}async function R00($,Z={},J={}){let Y=await fetch(`${$}/models`,{headers:Z,signal:AbortSignal.timeout(5000)}).then(async(G)=>{if(!G.ok)throw Error(`Failed to fetch models: ${G.status}`);return o2.parse(await G.json())}),X={...J},Q=new Map(Y.data.filter((G)=>G.model_picker_enabled&&G.policy?.state!=="disabled").map((G)=>[G.id,G]));for(let[G,W]of Object.entries(X)){let K=Q.get(W.api.id);if(!K){delete X[G];continue}X[G]=n2(G,K,$,W)}for(let[G,W]of Q){if(G in X)continue;X[G]=n2(G,W,$)}return X}var P00=E0.create({service:"plugin.copilot"}),s2="Ov23li8tweQw6odWQebz",EH=3000;function a2($){return $.replace(/^https?:\/\//,"").replace(/\/$/,"")}function I00($){return{DEVICE_CODE_URL:`https://${$}/login/device/code`,ACCESS_TOKEN_URL:`https://${$}/login/oauth/access_token`}}function bH($){return $?`https://copilot-api.${a2($)}`:"https://api.githubcopilot.com"}function _H($){if($?.role!=="user")return!1;let Z=$.content;if(typeof Z==="string")return Z===b$.SYNTHETIC_ATTACHMENT_PROMPT;if(!Array.isArray(Z))return!1;return Z.some((J)=>(J?.type==="text"||J?.type==="input_text")&&J.text===b$.SYNTHETIC_ATTACHMENT_PROMPT)}function r2($,Z){return{...$,api:{...$.api,url:Z,npm:"@ai-sdk/github-copilot"}}}async function t2($){let Z=$.client;return{provider:{id:"github-copilot",async models(J,Y){if(Y.auth?.type!=="oauth")return Object.fromEntries(Object.entries(J.models).map(([Q,G])=>[Q,r2(G,bH())]));let X=Y.auth;return LX.get(bH(X.enterpriseUrl),{Authorization:`Bearer ${X.refresh}`,"User-Agent":`qitqode/${E$}`},J.models).catch((Q)=>{return P00.error("failed to fetch copilot models",{error:Q}),Object.fromEntries(Object.entries(J.models).map(([G,W])=>[G,r2(W,bH(X.enterpriseUrl))]))})}},auth:{provider:"github-copilot",async loader(J){let Y=await J();if(!Y||Y.type!=="oauth")return{};return{apiKey:"",async fetch(X,Q){let G=await J();if(G.type!=="oauth")return fetch(X,Q);let W=X instanceof URL?X.href:typeof X==="string"?X:X.url,{isVision:K,isAgent:V}=l$(()=>{try{let H=typeof Q?.body==="string"?JSON.parse(Q.body):Q?.body;if(H?.messages&&W.includes("completions")){let B=H.messages[H.messages.length-1];return{isVision:H.messages.some((z)=>Array.isArray(z.content)&&z.content.some((F)=>F.type==="image_url")),isAgent:B?.role!=="user"||_H(B)}}if(H?.input){let B=H.input[H.input.length-1];return{isVision:H.input.some((z)=>Array.isArray(z?.content)&&z.content.some((F)=>F.type==="input_image")),isAgent:B?.role!=="user"||_H(B)}}if(H?.messages){let B=H.messages[H.messages.length-1],z=Array.isArray(B?.content)&&B.content.some((F)=>F?.type!=="tool_result");return{isVision:H.messages.some((F)=>Array.isArray(F?.content)&&F.content.some((A)=>A?.type==="image"||A?.type==="tool_result"&&Array.isArray(A?.content)&&A.content.some((j)=>j?.type==="image"))),isAgent:!(B?.role==="user"&&z)||_H(B)}}}catch{}return{isVision:!1,isAgent:!1}}),U={"x-initiator":V?"agent":"user",...Q?.headers,"User-Agent":`qitqode/${E$}`,Authorization:`Bearer ${G.refresh}`,"Openai-Intent":"conversation-edits"};if(K)U["Copilot-Vision-Request"]="true";return delete U["x-api-key"],delete U.authorization,fetch(X,{...Q,headers:U})}}},methods:[{type:"oauth",label:"Login with GitHub Copilot",prompts:[{type:"select",key:"deploymentType",message:"Select GitHub deployment type",options:[{label:"GitHub.com",value:"github.com",hint:"Public"},{label:"GitHub Enterprise",value:"enterprise",hint:"Data residency or self-hosted"}]},{type:"text",key:"enterpriseUrl",message:"Enter your GitHub Enterprise URL or domain",placeholder:"company.ghe.com or https://company.ghe.com",when:{key:"deploymentType",op:"eq",value:"enterprise"},validate:(J)=>{if(!J)return"URL or domain is required";try{if(!(J.includes("://")?new URL(J):new URL(`https://${J}`)).hostname)return"Please enter a valid URL or domain";return}catch{return"Please enter a valid URL (e.g., company.ghe.com or https://company.ghe.com)"}}}],async authorize(J={}){let Y=J.deploymentType||"github.com",X="github.com";if(Y==="enterprise"){let K=J.enterpriseUrl;X=a2(K)}let Q=I00(X),G=await fetch(Q.DEVICE_CODE_URL,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":`qitqode/${E$}`},body:JSON.stringify({client_id:s2,scope:"read:user"})});if(!G.ok)throw Error("Failed to initiate device authorization");let W=await G.json();return{url:W.verification_uri,instructions:`Enter code: ${W.user_code}`,method:"auto",async callback(){while(!0){let K=await fetch(Q.ACCESS_TOKEN_URL,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Agent":`qitqode/${E$}`},body:JSON.stringify({client_id:s2,device_code:W.device_code,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})});if(!K.ok)return{type:"failed"};let V=await K.json();if(V.access_token){let U={type:"success",refresh:V.access_token,access:V.access_token,expires:0};if(Y==="enterprise")U.enterpriseUrl=X;return U}if(V.error==="authorization_pending"){await CH(W.interval*1000+EH);continue}if(V.error==="slow_down"){let U=(W.interval+5)*1000,H=V.interval;if(H&&typeof H==="number"&&H>0)U=H*1000;await CH(U+EH);continue}if(V.error)return{type:"failed"};await CH(W.interval*1000+EH);continue}}}}}]},"chat.params":async(J,Y)=>{if(!J.model.providerID.includes("github-copilot"))return;if(J.model.api.id.includes("gpt"))Y.maxOutputTokens=void 0;if(J.model.api.npm==="@ai-sdk/anthropic")Y.options.toolStreaming=!1},"chat.headers":async(J,Y)=>{if(!J.model.providerID.includes("github-copilot"))return;if(J.model.api.npm==="@ai-sdk/anthropic")Y.headers["anthropic-beta"]="interleaved-thinking-2025-05-14";let X=await Z.session.get({path:{id:J.sessionID},query:{directory:$.directory},throwOnError:!0}).catch(()=>{return});if(!X||!X.data.parentID)return;Y.headers["x-initiator"]="agent"}}}var Eu=m6(Hu(),1),bu=m6(Cu(),1);class iQ{options;server;resolveCallback;rejectCallback;timeoutHandle;constructor($={}){this.options=$,this.server=Eu.default({logger:!1}),this.server.register(bu.default,{max:30,timeWindow:60000}),this.server.get("/callback",async(Z,J)=>{let{code:Y,state:X,error:Q,error_description:G}=Z.query;if(Q){let W=G||Q;this.rejectCallback?.(Error(`OAuth error: ${W}`)),await J.type("text/html").send(`
635
- <!DOCTYPE html>
636
- <html>
637
- <head><title>Authentication Failed</title></head>
638
- <body>
639
- <h1>Authentication Failed</h1>
640
- <p>${W}</p>
641
- <p>You can close this window.</p>
642
- </body>
643
- </html>
644
- `),this.cleanup();return}if(!Y||!X){this.rejectCallback?.(Error("Missing code or state parameter")),await J.type("text/html").send(`
645
- <!DOCTYPE html>
646
- <html>
647
- <head><title>Authentication Failed</title></head>
648
- <body>
649
- <h1>Authentication Failed</h1>
650
- <p>Missing required parameters.</p>
651
- <p>You can close this window.</p>
652
- </body>
653
- </html>
654
- `),this.cleanup();return}this.resolveCallback?.({code:Y,state:X}),await J.type("text/html").send(`
655
- <!DOCTYPE html>
656
- <html>
657
- <head><title>Authentication Successful</title></head>
658
- <body>
659
- <h1>Authentication Successful</h1>
660
- <p>You can close this window and return to your terminal.</p>
661
- </body>
662
- </html>
663
- `),this.cleanup()})}async start(){let $=this.options.host||"127.0.0.1",Z=this.options.port||0;await this.server.listen({host:$,port:Z})}async waitForCallback(){let $=this.options.timeout||60000;return this.timeoutHandle=setTimeout(()=>{this.rejectCallback?.(Error("OAuth callback timeout")),this.cleanup()},$),new Promise((Z,J)=>{this.resolveCallback=Z,this.rejectCallback=J})}getPort(){let $=this.server.server.address();if(!$||typeof $==="string")throw Error("Server not started or using Unix socket");return $.port}getCallbackUrl(){let $=this.options.host||"127.0.0.1",Z=this.getPort();return`http://${$}:${Z}/callback`}cleanup(){if(this.timeoutHandle)clearTimeout(this.timeoutHandle),this.timeoutHandle=void 0;setTimeout(()=>{this.server.close()},100)}async close(){if(this.timeoutHandle)clearTimeout(this.timeoutHandle),this.timeoutHandle=void 0;await this.server.close()}}class UK{options;constructor($){this.options=$}async authorize(){let $=BA(43),Z=_u($),J=BA(32);if(this.options.method==="auto")return this.authorizeWithCallback(Z,J,$);else return this.authorizeWithManualCode(Z,J,$)}async authorizeWithCallback($,Z,J){let Y=new iQ({port:0,host:"127.0.0.1",timeout:this.options.timeout||60000});try{let X=Y.waitForCallback(),Q=Y.getCallbackUrl(),G=this.buildAuthorizationUrl(Q,$,Z);await(await import("./chunk-tnete6ye.js")).default(G);let K=await X;if(K.state!==Z)throw Error("State mismatch - possible CSRF attack");return{code:K.code,state:K.state,codeVerifier:J}}finally{await Y.close()}}authorizeWithManualCode($,Z,J){throw this.buildAuthorizationUrl("http://127.0.0.1/callback",$,Z),Error("Manual code entry not yet implemented - use auto method")}buildAuthorizationUrl($,Z,J){let Y=new URLSearchParams({client_id:this.options.clientId,redirect_uri:$,response_type:"code",state:J,scope:this.options.scopes.join(" "),code_challenge:Z,code_challenge_method:"S256"});return`${this.options.instanceUrl.replace(/\/$/,"")}/oauth/authorize?${Y.toString()}`}async exchangeAuthorizationCode($,Z,J){let X=`${this.options.instanceUrl.replace(/\/$/,"")}/oauth/token`,Q=new URLSearchParams({client_id:this.options.clientId,code:$,grant_type:"authorization_code",redirect_uri:J,code_verifier:Z}),G=await fetch(X,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Q.toString()});if(!G.ok){let K=await G.text();throw Error(`Token exchange failed: ${G.status} ${G.statusText} - ${K}`)}return await G.json()}async exchangeRefreshToken($){let J=`${this.options.instanceUrl.replace(/\/$/,"")}/oauth/token`,Y=new URLSearchParams({client_id:this.options.clientId,refresh_token:$,grant_type:"refresh_token"}),X=await fetch(J,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:Y.toString()});if(!X.ok){let G=await X.text();throw Error(`Token refresh failed: ${X.status} ${X.statusText} - ${G}`)}return await X.json()}}import R$ from"fs";import O7 from"path";import Su from"os";var sQ=process.env.GITLAB_OAUTH_CLIENT_ID||"1d89f9fdb23ee96d4e603201f6861dab6e143c5c3c00469a018a2d94bdc03d4e",uq0="https://gitlab.com",zA=["api"];function nQ(){return process.env.GITLAB_INSTANCE_URL||uq0}function Y$($,Z){try{let J=Su.homedir(),Y=O7.join(J,".local","share","opencode","log");if(!R$.existsSync(Y))R$.mkdirSync(Y,{recursive:!0});let X=O7.join(Y,"gitlab-auth.log"),Q=new Date().toISOString(),G=Z?`[${Q}] ${$}: ${JSON.stringify(Z)}
664
- `:`[${Q}] ${$}
665
- `;R$.appendFileSync(X,G)}catch{}}function FA(){let $=Su.homedir(),Z=process.env.XDG_DATA_HOME;if(Z)return O7.join(Z,"opencode","auth.json");if(process.platform!=="win32")return O7.join($,".local","share","opencode","auth.json");return O7.join($,".opencode","auth.json")}async function fu($,Z,J,Y){let X=FA(),Q=O7.dirname(X);if(!R$.existsSync(Q))R$.mkdirSync(Q,{recursive:!0});let G={};if(R$.existsSync(X)){let W=R$.readFileSync(X,"utf-8");G=JSON.parse(W)}G.gitlab={type:"oauth",access:$,refresh:Z,expires:J,enterpriseUrl:Y},R$.writeFileSync(X,JSON.stringify(G,null,2)),R$.chmodSync(X,384)}async function mq0($,Z){let J=FA(),Y=O7.dirname(J);if(!R$.existsSync(Y))R$.mkdirSync(Y,{recursive:!0});let X={};if(R$.existsSync(J)){let Q=R$.readFileSync(J,"utf-8");X=JSON.parse(Q)}X.gitlab={type:"api",key:$,enterpriseUrl:Z},R$.writeFileSync(J,JSON.stringify(X,null,2)),R$.chmodSync(J,384)}var oQ=null;async function lq0($,Z,J){let Y=Date.now(),X=300000;if(!($.expires<=Y+300000))return Y$("Token is still valid",{expiresAt:new Date($.expires).toISOString(),expiresIn:Math.round(($.expires-Y)/1000/60)+" minutes"}),{apiKey:$.access,instanceUrl:$.enterpriseUrl||J};if(oQ){Y$("Token refresh already in progress, waiting..."),await oQ;let W=await Z();if(W&&W.type==="oauth")return{apiKey:W.access,instanceUrl:W.enterpriseUrl||J};throw Error("Failed to get refreshed auth data")}Y$("Token expired or expiring soon, refreshing...",{expiresAt:new Date($.expires).toISOString(),expired:$.expires<=Y}),oQ=(async()=>{try{let W=$.enterpriseUrl||J,K=new UK({instanceUrl:W,clientId:sQ,scopes:zA,method:"auto"});Y$("Calling exchangeRefreshToken...");let V=await K.exchangeRefreshToken($.refresh),U=Date.now()+V.expires_in*1000;Y$("Token refresh successful",{newExpiresAt:new Date(U).toISOString(),expiresIn:Math.round(V.expires_in/60)+" minutes"}),await fu(V.access_token,V.refresh_token,U,W),Y$("New tokens saved successfully")}catch(W){if(Y$("Token refresh failed",{error:W instanceof Error?W.message:String(W),stack:W instanceof Error?W.stack:void 0}),W instanceof Error&&W.message.includes("401")){Y$("Refresh token appears to be revoked (401), clearing auth data");let K=FA();if(R$.existsSync(K)){let V=R$.readFileSync(K,"utf-8"),U=JSON.parse(V);delete U.gitlab,R$.writeFileSync(K,JSON.stringify(U,null,2))}}throw W}})();try{await oQ}finally{oQ=null}let G=await Z();if(G&&G.type==="oauth")return{apiKey:G.access,instanceUrl:G.enterpriseUrl||J};throw Error("Failed to get refreshed auth data after token refresh")}var ku=async($)=>{return{auth:{provider:"gitlab",async loader(J){let Y=await J();if(!Y)return{};if(Y.type==="oauth")try{return{...await lq0(Y,J,nQ()),clientId:sQ}}catch(X){return Y$("Failed to refresh token in loader",{error:X instanceof Error?X.message:String(X)}),{apiKey:Y.access,instanceUrl:Y.enterpriseUrl||nQ(),clientId:sQ}}if(Y.type==="api"){let X=Y.enterpriseUrl||nQ();return{apiKey:Y.key,instanceUrl:X}}return{}},methods:[{type:"oauth",label:"GitLab OAuth",prompts:[],async authorize(){let J=nQ(),Y;try{let N=new URL(J);Y=`${N.protocol}//${N.host}`}catch{throw Error(`Invalid GitLab instance URL: ${J}`)}let{generateSecret:X,generateCodeChallengeFromVerifier:Q}=await import("./chunk-3qvap1kv.js"),G=X(43),W=Q(G),K=X(32),V=new iQ({port:8080,host:"127.0.0.1",timeout:120000});await V.start();let U=V.getCallbackUrl(),H=V.waitForCallback(),B=new URLSearchParams({client_id:sQ,redirect_uri:U,response_type:"code",state:K,scope:zA.join(" "),code_challenge:W,code_challenge_method:"S256"}),z=`${Y}/oauth/authorize?${B.toString()}`,{exec:F}=await import("child_process"),A=process.platform;return F(`${A==="darwin"?"open":A==="win32"?"start":"xdg-open"} "${z}"`),{method:"auto",url:z,instructions:"Your browser will open for authentication. The callback will be handled automatically.",async callback(){Y$("callback() called");try{Y$("Waiting for callback...");let N=await H;if(Y$("Received callback",{hasCode:!!N.code,hasState:!!N.state}),N.state!==K)return Y$("State mismatch",{expected:K,received:N.state}),await V.close(),{type:"failed"};Y$("State verified"),Y$("Exchanging code for tokens...");let q=await new UK({instanceUrl:Y,clientId:sQ,scopes:zA,method:"auto"}).exchangeAuthorizationCode(N.code,G,U);Y$("Token exchange successful"),await V.close();let M=Date.now()+q.expires_in*1000;return Y$("Tokens received",{expiresAt:new Date(M).toISOString()}),Y$("Saving auth data..."),await fu(q.access_token,q.refresh_token,M,Y),Y$("Auth data saved successfully"),{type:"success",provider:Y,access:q.access_token,refresh:q.refresh_token,expires:M}}catch(N){Y$("Error in callback",{error:N instanceof Error?N.message:String(N),stack:N instanceof Error?N.stack:void 0});try{await V.close()}catch(L){}return{type:"failed"}}}}}},{type:"api",label:"GitLab Personal Access Token",prompts:[{type:"text",key:"token",message:"Personal Access Token",placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",validate:(J)=>{if(!J)return"Token is required";if(!J.startsWith("glpat-"))return"Token should start with glpat-";return}}],async authorize(J){let Y=nQ(),X=J?.token;if(!X)return{type:"failed"};let Q;try{let G=new URL(Y);Q=`${G.protocol}//${G.host}`}catch{return{type:"failed"}}try{if(!(await fetch(`${Q}/api/v4/user`,{headers:{Authorization:`Bearer ${X}`}})).ok)return{type:"failed"};return Y$("Saving PAT auth data..."),await mq0(X,Q),Y$("PAT auth data saved successfully"),{type:"success",key:X,provider:Q}}catch{return{type:"failed"}}}}]}}};import dq0 from"http";function vu($){if($===null||$.length===0)return null;try{let Z=Buffer.from($,"base64url").toString("utf8"),J=JSON.parse(Z);if(J.v!==1||typeof J.n!=="string"||J.n.length===0||typeof J.i!=="string"||J.i.length===0||typeof J.r!=="boolean")return null;return{issuer:J.i,requireIssuer:J.r}}catch{return null}}async function xu($={}){let Z=$.callbackPath??"/callback",J=$.createServer?$.createServer():dq0.createServer();return{redirectUri:`http://127.0.0.1:${await pq0(J)}${Z}`,async waitForCode(Q){return cq0(J,Q,$,Z)},close(){J.closeAllConnections?.(),J.close()}}}async function pq0($){return new Promise((Z)=>{$.listen(0,"127.0.0.1",()=>{let J=$.address();Z(J.port)})})}function cq0($,Z,J,Y){let X=nq0(Z);return new Promise((Q,G)=>{let W=!1,K=(V)=>{if(!W)W=!0,V()};if($.on("request",(V,U)=>{let H=new URL(V.url??"/","http://127.0.0.1");if(H.pathname!==Y){U.writeHead(404),U.end("Not found");return}let B=H.searchParams.get("error");if(B!==null){let z=H.searchParams.get("error_description")??B;U.writeHead(400),U.end(`Authorization failed: ${z}`),K(()=>G(Error(`OAuth authorization failed: ${B} \u2014 ${z}`)));return}try{let z=yu({code:H.searchParams.get("code"),state:H.searchParams.get("state"),iss:H.searchParams.get("iss")},X);U.writeHead(200,{"Content-Type":"text/html"}),U.end(oq0(J.landingPage)),K(()=>Q(z))}catch(z){U.writeHead(400),U.end(z instanceof Error?z.message:"Invalid OAuth callback"),K(()=>G(z instanceof Error?z:Error(String(z))))}}),J.readLine!==void 0)J.readLine().then((V)=>{let U=iq0(V);if(U===null){K(()=>G(Error("OAuth callback missing authorization code")));return}try{let H=yu(U,X);K(()=>Q(H))}catch(H){K(()=>G(H instanceof Error?H:Error(String(H))))}}).catch(()=>{return});if(J.openBrowser!==void 0)J.openBrowser(Z).catch((V)=>{K(()=>G(V))})})}function iq0($){let Z=$.replaceAll("\r","").replaceAll(`
666
- `,"").trim();if(Z.length===0)return null;try{let J=new URL(Z);return{code:J.searchParams.get("code"),state:J.searchParams.get("state"),iss:J.searchParams.get("iss")}}catch{return{code:Z,state:null,iss:null}}}function nq0($){let J=new URL($).searchParams.get("state"),Y=vu(J);return{state:J,issuer:Y?.issuer??null,requireIssuer:Y?.requireIssuer??!1}}function yu($,Z){if($.code===null||$.code.length===0)throw Error("OAuth callback missing authorization code");if(Z.state!==null){if($.state===null||$.state.length===0)throw Error("OAuth callback missing state");if($.state!==Z.state)throw Error("OAuth callback state mismatch")}if(Z.requireIssuer){if($.iss===null||$.iss.length===0)throw Error("OAuth callback missing issuer")}if($.iss!==null&&$.iss.length>0&&Z.issuer!==null&&$.iss!==Z.issuer)throw Error("OAuth callback issuer mismatch");return $.code}function AA($){return $.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}function oq0($){let Z=$?.title??"Connected",J=$?.body??"You can close this tab and return to your terminal.";return["<!DOCTYPE html>",`<html><head><meta charset=utf-8><title>${AA(Z)}</title></head>`,'<body style="font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0">','<div style="text-align:center">',`<h1>${AA(Z)}</h1>`,`<p style="color:#666">${AA(J)}</p>`,"</div></body></html>"].join("")}import hu from"crypto";function gu(){return hu.randomBytes(32).toString("base64url")}function uu($){return hu.createHash("sha256").update($).digest("base64url")}var sq0="https://poe.com/oauth/authorize",rq0="https://api.poe.com/token";function OA($){let Z=$.fetch??globalThis.fetch;return{authorize:()=>tq0($,Z)}}function aq0(){return gu()}async function tq0($,Z){let J=$.authorizationEndpoint??sq0,Y=$.tokenEndpoint??rq0,X=aq0(),Q=uu(X),G=await xu({openBrowser:$.openBrowser,readLine:$.readLine,createServer:$.createServer,landingPage:$.landingPage??{title:"Connected to Poe",body:"You can close this tab and return to your terminal."}}),W=G.redirectUri,K=eq0({endpoint:J,clientId:$.clientId,redirectUri:W,codeChallenge:Q});return{authorizationUrl:K,waitForResult:async()=>{try{let U=await G.waitForCode(K);return await $j0({tokenEndpoint:Y,code:U,codeVerifier:X,clientId:$.clientId,redirectUri:W,fetchFn:Z})}finally{G.close()}}}}function eq0($){let Z=new URL($.endpoint);return Z.searchParams.set("response_type","code"),Z.searchParams.set("client_id",$.clientId),Z.searchParams.set("scope","apikey:create"),Z.searchParams.set("code_challenge",$.codeChallenge),Z.searchParams.set("code_challenge_method","S256"),Z.searchParams.set("redirect_uri",$.redirectUri),Z.toString()}async function $j0($){let Z=new URLSearchParams({grant_type:"authorization_code",code:$.code,code_verifier:$.codeVerifier,client_id:$.clientId,redirect_uri:$.redirectUri}),J=await $.fetchFn($.tokenEndpoint,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:Z.toString()});if(!J.ok){let X=await J.text(),Q=Zj0(X);throw Error(Q??`Token exchange failed (${J.status}): ${X}`)}let Y=await J.json();if(typeof Y.api_key!=="string"||Y.api_key.length===0)throw Error("Token response missing api_key field");return{apiKey:Y.api_key,expiresIn:typeof Y.api_key_expires_in==="number"?Y.api_key_expires_in:null}}function Zj0($){try{let Z=JSON.parse($);if(typeof Z.error_description==="string")return Z.error_description;if(typeof Z.error==="string")return Z.error}catch{}return null}var Jj0="client_728290227fc048cc9262091a1ea197ea";function Yj0($){if($==null)return Number.MAX_SAFE_INTEGER;return Date.now()+$*1000}async function Xj0(){let Z=await OA({clientId:Jj0,landingPage:{title:"Connected to Poe",body:"You can close this tab and return to OpenCode."},openBrowser:async(J)=>{await mu(J)}}).authorize();return{url:Z.authorizationUrl,instructions:"Complete authorization in your browser. This window will close automatically.",method:"auto",callback:async()=>{let J=await Z.waitForResult();return{type:"success",access:J.apiKey,refresh:J.apiKey,expires:Yj0(J.expiresIn)}}}}async function HK($){return{auth:{provider:"poe",async loader(Z){let J=await Z();if(J.type==="api")return{apiKey:J.key};if(J.type!=="oauth")return{};if(J.expires<Date.now())throw Error("Poe API key expired. Run `opencode providers login` again.");return{apiKey:J.access}},methods:[{label:"Login with Poe (browser)",type:"oauth",authorize:Xj0},{label:"Manually enter API Key",type:"api"}]}}}async function lu($){return{auth:{provider:"cloudflare-workers-ai",methods:[{type:"api",label:"API key",prompts:!process.env.CLOUDFLARE_ACCOUNT_ID?[{type:"text",key:"accountId",message:"Enter your Cloudflare Account ID",placeholder:"e.g. 1234567890abcdef1234567890abcdef"}]:[]}]}}}async function du($){return{auth:{provider:"cloudflare-ai-gateway",methods:[{type:"api",label:"Gateway API token",prompts:[...!process.env.CLOUDFLARE_ACCOUNT_ID?[{type:"text",key:"accountId",message:"Enter your Cloudflare Account ID",placeholder:"e.g. 1234567890abcdef1234567890abcdef"}]:[],...!process.env.CLOUDFLARE_GATEWAY_ID?[{type:"text",key:"gatewayId",message:"Enter your Cloudflare AI Gateway ID",placeholder:"e.g. my-gateway"}]:[]]}]},"chat.params":async(J,Y)=>{if(J.model.providerID!=="cloudflare-ai-gateway")return;if(!J.model.api.id.toLowerCase().startsWith("openai/"))return;if(!J.model.capabilities.reasoning)return;Y.maxOutputTokens=void 0}}}import FZ from"path";import Qj0 from"fs/promises";function BK($){return FZ.join(F0.Path.data,"memory","sessions",$)}function rQ($){return FZ.join(BK($),"checkpoint.md")}function aQ($){return FZ.join(F0.Path.data,"memory","projects",$,"MEMORY.md")}function dh0(){return FZ.join(F0.Path.data,"memory","global","MEMORY.md")}async function ph0($){let Z=aQ($),J=FZ.join(FZ.dirname(Z),"memory.md");if(await Bun.file(Z).exists())return;if(await Bun.file(J).exists())await Qj0.rename(J,Z).catch((Y)=>{if(Y.code!=="ENOENT")throw Y})}function ch0($){return FZ.join(BK($),"notes.md")}function Gj0($){return FZ.join(BK($),"tasks")}function pu($,Z){return FZ.join(Gj0($),Z,"progress.md")}var cu=80,Wj0=["### Execution context","### Live resources","### Session metadata"],Kj0=["### Discovered","### Dead ends"];function iu($,Z,J){let Y=[],X=$.split(`
667
- `).find((K)=>K.trim().length>0)??"";if(/^# Checkpoint #\d+/.test(X))Y.push({file:Z,rule:"topic-anti-pattern-checkpoint-header",severity:"error",detail:`First line is "${X}". Replace with "Topic: <\u226480-char one-line summary>" with NO leading "#".`});let Q=$.match(/^Topic:\s*(.+?)$/m);if(!Q)Y.push({file:Z,rule:"topic-missing",severity:"error",detail:'Missing required first-line "Topic: <summary>". Add it as the first non-blank line.'});else{let K=Q[1].trim();if(K.length>cu)Y.push({file:Z,rule:"topic-too-long",severity:"warn",detail:`Topic line is ${K.length} chars (limit ${cu}). Rewrite shorter.`})}let G=J.map((K)=>({section:K,idx:$.indexOf(K)}));for(let K of G)if(K.idx===-1)Y.push({file:Z,rule:"subsection-missing",severity:"error",detail:`Missing "${K.section}" sub-section. Add the header (use "(none)" placeholder if no entries).`});let W=G.filter((K)=>K.idx!==-1);for(let K=1;K<W.length;K++)if(W[K].idx<W[K-1].idx){Y.push({file:Z,rule:"subsection-out-of-order",severity:"error",detail:`Sub-sections must appear in order: ${J.join(", ")}.`});break}return Y}function nu($,Z){return iu($,Z,Wj0)}function ou($){let Z=$.match(/^(?:Topic:.*\n+)?### discovered\s*\n([\s\S]*?)(?=\n### |$)/i);if(!Z)return[];let J=Z[1],Y=[],X=J.split(`
668
- `),Q;for(let G of X){let W=G.match(/^- (.+)$/);if(W){if(Q)Y.push({title:Q.title,block:Q.lines.join(`
669
- `)});Q={title:W[1].trim(),lines:[G]}}else if(Q)Q.lines.push(G)}if(Q)Y.push({title:Q.title,block:Q.lines.join(`
670
- `)});return Y}function su($){return ou($).map((Z)=>Z.title)}function ru($,Z,J){let Y=iu($,Z,Kj0),X=ou($);for(let Q of X){if(J.has(Q.title))Y.push({file:Z,rule:"discovered-duplicate-title",severity:"error",detail:`Discovered title "${Q.title}" duplicates a prior checkpoint's title verbatim. Remove this entry or rephrase.`});if(!/^\s*Why:/m.test(Q.block))Y.push({file:Z,rule:"discovered-missing-why",severity:"warn",detail:`Discovered entry "${Q.title}" is missing a "Why:" line.`});if(!/^\s*How to apply:/m.test(Q.block))Y.push({file:Z,rule:"discovered-missing-how-to-apply",severity:"warn",detail:`Discovered entry "${Q.title}" is missing a "How to apply:" line.`})}return Y}function au($,Z){let J=[];for(let Y of Z)if(!$.includes(Y.expectedText))J.push({file:"MEMORY.md",rule:"directive-not-revised",severity:"error",detail:`Directive ${Y.id} should mention "${Y.expectedText}" per a recent user instruction, but MEMORY.md does not contain that text.`});return J}function jA($,Z,J){let Y=qA.estimate($);if(Y<=Z)return[];return[{file:J,rule:"budget-exceeded",severity:"extract-required",detail:`${Y} tokens > ${Z} budget`}]}function NA($,Z,J){let Y=[],X=/^## (.+)$/gm,Q=[],G;while((G=X.exec($))!==null)Q.push({title:G[1].trim(),index:G.index});for(let W=0;W<Q.length;W++){let K=Q[W].index,V=W+1<Q.length?Q[W+1].index:$.length,U=$.slice(K,V),H=Q[W].title,B=Z[H];if(B==null)continue;let z=qA.estimate(U);if(z>B)Y.push({file:J,rule:"section-budget-exceeded",severity:"extract-required",detail:`section "${H}" is ${z} tokens (budget ${B})`})}return Y}var sh0=`# Session checkpoint
671
- _Generated by checkpoint writer; structure preserved across updates. Edit only content under italic instructions._
672
-
673
- ## \xA71 Active intent
674
- _User's most recent explicit request, verbatim block-quoted from the conversation. The verbatim quote is the ground truth for what to do \u2014 do not paraphrase._
675
-
676
- (none yet)
677
-
678
- ## \xA72 Next concrete action
679
- _The single next concrete step, derived from \xA71 and current state. Include verbatim quote when the user gave one._
680
-
681
- (none yet)
682
-
683
- ## \xA73 Directives (this session)
684
- _This session's specific working style. Project-level rules are in projects/<pid>/MEMORY.md \u2014 do not duplicate them here. Only put items that are session-specific._
685
-
686
- (none)
687
-
688
- ## \xA74 Task tree
689
- _Hierarchical view of tasks with current focus marked. Pulled from task tool's DB; one bullet per top-level task with status + summary. Append \` (progress: tasks/<id>/progress.md)\` so the next agent can Read the per-task journal directly. Indent sub-tasks two spaces under their parent._
690
-
691
- (none yet)
692
-
693
- ## \xA75 Current work
694
- _Description of what was being done immediately before this checkpoint. Mention specific file paths and code locations._
695
-
696
- (none yet)
697
-
698
- ## \xA76 Files and code sections
699
- _Files actively being read or modified. List with one-line purpose._
700
-
701
- (none yet)
702
-
703
- ## \xA77 Discovered knowledge (cross-task)
704
- _Facts learned during this session that may apply to future tasks. Items here are candidates for promotion to projects/<pid>/MEMORY.md if they prove durable._
705
-
706
- (none yet)
707
-
708
- ## \xA78 Errors and fixes
709
- _Errors encountered this session and how they were resolved. Newest first._
710
-
711
- (none)
712
-
713
- ## \xA79 Live resources
714
- _Runtime state: branch, uncommitted files, running processes, temp artifacts. Most volatile \u2014 don't dwell on details that change every minute._
715
-
716
- (none yet)
717
-
718
- ## \xA710 Design decisions and discussion outcomes
719
- _Decisions reached through discussion that produced no immediate code/file artifact. Captures user intent or trade-off rationale future agents need to understand "why we did it this way". Promote to MEMORY.md ## Architecture decisions when proven cross-session-durable._
720
-
721
- (none yet)
722
-
723
- ## \xA711 Open notes
724
- _Writer-curated catch-all for items that don't fit \xA71-\xA710. Quotes from conversation, unresolved questions, micro-observations, miscellaneous. Cleaner than letting orphan content pollute \xA73 or \xA77. May be empty for many checkpoints._
725
-
726
- (none yet)
727
- `,rh0=`# Project memory
728
- _Durable project-level knowledge. Persists across all sessions in this project. Edit only content under italic instructions._
729
-
730
- ## Project context
731
- _What is this project? What's its goal? High-level identity._
732
-
733
- (none yet)
734
-
735
- ## Rules
736
- _Hard constraints from user that every session must respect._
737
-
738
- (none yet)
739
-
740
- ## Architecture decisions
741
- _Major design choices with rationale. The "why" matters more than the "what" for future sessions._
742
-
743
- (none yet)
744
-
745
- ## Discovered durable knowledge
746
- _Cross-task facts that survive across sessions. Promoted from session checkpoints' \xA77 when proven durable._
747
-
748
- (none yet)
749
- `,tu={"\xA71 Active intent":500,"\xA72 Next concrete action":1000,"\xA73 Directives (this session)":800,"\xA74 Task tree":1000,"\xA75 Current work":2000,"\xA76 Files and code sections":1500,"\xA77 Discovered knowledge (cross-task)":2000,"\xA78 Errors and fixes":1500,"\xA79 Live resources":1000,"\xA710 Design decisions and discussion outcomes":3000,"\xA711 Open notes":800},eu={"Project context":1000,Rules:2000,"Architecture decisions":3000,"Discovered durable knowledge":4000},ah0="# Session notes\n_Free-form scratchpad for the main agent. Append entries as you go; the checkpoint writer reconciles them at checkpoint events. Format each entry as `## [turn N \xB7 YYYY-MM-DDTHH:MM:SSZ]` (minute precision UTC, seconds optional) followed by free-form body. Before appending: scan existing entries \u2014 if you've already noted substantially similar content, add a short `(see entry above)` reference instead of duplicating._\n";var Q5={};F1(Q5,{merge:()=>Fj0,layer:()=>Km,fromConfig:()=>zj0,evaluate:()=>DA,disabled:()=>Oj0,defaultLayer:()=>qj0,Service:()=>AK,Ruleset:()=>Qm,Rule:()=>wA,Request:()=>Z9,ReplyInput:()=>Hj0,ReplyBody:()=>Vj0,Reply:()=>LA,RejectedError:()=>j7,Permission:()=>Q5,Event:()=>tQ,DeniedError:()=>FK,CorrectedError:()=>TA,AskInput:()=>Uj0,Approval:()=>Wm,Action:()=>Xm});var $m=($,Z)=>T.addFinalizer(()=>T.gen(function*(){for(let J of $.values())yield*f6.fail(J.deferred,Z());$.clear()}));import zK from"os";function Zm($,Z,...J){return F8.evaluatePermission($,Z,...J)}class q7 extends Jm()("PermissionID",O.String.annotate({[F$]:d1.schema("permission")})){static ascending($){return this.make(d1.ascending("permission",$))}static zod=d1.schema("permission")}var Ym=E0.create({service:"permission"}),Xm=O.Literals(["allow","deny","ask"]).annotate({identifier:"PermissionAction"}).pipe(u0(($)=>({zod:w0($)})));class wA extends O.Class("PermissionRule")({permission:O.String,pattern:O.String,action:Xm}){static zod=w0(this)}var Qm=O.mutable(O.Array(wA)).annotate({identifier:"PermissionRuleset"}).pipe(u0(($)=>({zod:w0($)})));class Z9 extends O.Class("PermissionRequest")({id:q7,sessionID:r0,permission:O.String,patterns:O.Array(O.String),metadata:O.Record(O.String,O.Unknown),always:O.Array(O.String),tool:O.optional(O.Struct({messageID:i1,callID:O.String}))}){static zod=w0(this)}var LA=O.Literals(["once","always","reject"]).pipe(u0(($)=>({zod:w0($)}))),Gm={reply:LA,message:O.optional(O.String)},Vj0=O.Struct(Gm).annotate({identifier:"PermissionReplyBody"}).pipe(u0(($)=>({zod:w0($)})));class Wm extends O.Class("PermissionApproval")({projectID:$9,patterns:O.Array(O.String)}){static zod=w0(this)}var tQ={Asked:L1.define("permission.asked",Z9.zod),Replied:L1.define("permission.replied",w0(O.Struct({sessionID:r0,requestID:q7,reply:LA})))};class j7 extends O.TaggedErrorClass()("PermissionRejectedError",{}){get message(){return"The user rejected permission to use this specific tool call."}}class TA extends O.TaggedErrorClass()("PermissionCorrectedError",{feedback:O.String}){get message(){return`The user rejected permission to use this specific tool call with the following feedback: ${this.feedback}`}}class FK extends O.TaggedErrorClass()("PermissionDeniedError",{ruleset:O.Any}){get message(){return`The user has specified a rule which prevents you from using this specific tool call. Here are some of the relevant rules ${JSON.stringify(this.ruleset)}`}}var Uj0=O.Struct({...Z9.fields,id:O.optional(q7),ruleset:Qm,interactive:O.optional(O.Boolean)}).annotate({identifier:"PermissionAskInput"}).pipe(u0(($)=>({zod:w0($)}))),Hj0=O.Struct({requestID:q7,...Gm}).annotate({identifier:"PermissionReplyInput"}).pipe(u0(($)=>({zod:w0($)})));function DA($,Z,...J){return Zm($,Z,...J)}class AK extends S1.Service()("@qitqode/Permission"){}var Km=T0.effect(AK,T.gen(function*(){let $=yield*l1.Service,Z=yield*B0.make(T.fn("Permission.state")(function*(Q){let G=W1.use((K)=>K.select().from(MA).where(m0(MA.project_id,Q.project.id)).get()),W={pending:new Map,approved:G?.data??[]};return yield*$m(W.pending,()=>new j7),W})),J=T.fn("Permission.ask")(function*(Q,G){let{approved:W,pending:K}=yield*B0.get(Z),{ruleset:V,...U}=Q,H=!1;for(let N of U.patterns){let L=DA(U.permission,N,V,W);if(Ym.info("evaluated",{permission:U.permission,pattern:N,action:L}),L.action==="deny")return yield*new FK({ruleset:V.filter((q)=>eQ.match(U.permission,q.permission))});if(L.action==="allow")continue;H=!0}if(H&&Q.interactive===!1)return yield*new FK({ruleset:V.filter((N)=>eQ.match(U.permission,N.permission))});if(!H)return;let B=U.id??q7.ascending(),z=O.decodeUnknownSync(Z9)({id:B,...U});Ym.info("asking",{id:B,permission:z.permission,patterns:z.patterns});let F=yield*f6.make();K.set(B,{info:z,deferred:F}),yield*$.publish(tQ.Asked,z);let A=f6.await(F),j=G?T.race(A,T.callback((N)=>{let L=()=>{T.runPromise(f6.fail(F,new j7)).catch((q)=>{console.error("permission: failed to fail deferred after abort",q)}),N(T.fail(new j7))};if(G.aborted){L();return}return G.addEventListener("abort",L,{once:!0}),T.sync(()=>{G.removeEventListener("abort",L)})})):A;return yield*T.ensuring(j,T.sync(()=>{K.delete(B)}))}),Y=T.fn("Permission.reply")(function*(Q){let{approved:G,pending:W}=yield*B0.get(Z),K=W.get(Q.requestID);if(!K)return;if(W.delete(Q.requestID),yield*$.publish(tQ.Replied,{sessionID:K.info.sessionID,requestID:K.info.id,reply:Q.reply}),Q.reply==="reject"){yield*f6.fail(K.deferred,Q.message?new TA({feedback:Q.message}):new j7);for(let[V,U]of W.entries()){if(U.info.sessionID!==K.info.sessionID)continue;W.delete(V),yield*$.publish(tQ.Replied,{sessionID:U.info.sessionID,requestID:U.info.id,reply:"reject"}),yield*f6.fail(U.deferred,new j7)}return}if(yield*f6.succeed(K.deferred,void 0),Q.reply==="once")return;for(let V of K.info.always)G.push({permission:K.info.permission,pattern:V,action:"allow"});for(let[V,U]of W.entries()){if(U.info.sessionID!==K.info.sessionID)continue;if(!U.info.patterns.every((B)=>DA(U.info.permission,B,G).action==="allow"))continue;W.delete(V),yield*$.publish(tQ.Replied,{sessionID:U.info.sessionID,requestID:U.info.id,reply:"always"}),yield*f6.succeed(U.deferred,void 0)}}),X=T.fn("Permission.list")(function*(){let Q=(yield*B0.get(Z)).pending;return Array.from(Q.values(),(G)=>G.info)});return AK.of({ask:J,reply:Y,list:X})}));function Bj0($){if($.startsWith("~/"))return zK.homedir()+$.slice(1);if($==="~")return zK.homedir();if($.startsWith("$HOME/"))return zK.homedir()+$.slice(5);if($.startsWith("$HOME"))return zK.homedir()+$.slice(5);return $}function zj0($){let Z=[];for(let[J,Y]of Object.entries($)){if(typeof Y==="string"){Z.push({permission:J,action:Y,pattern:"*"});continue}Z.push(...Object.entries(Y).map(([X,Q])=>({permission:J,pattern:Bj0(X),action:Q})))}return Z}function Fj0(...$){return $.flat()}var Aj0=["edit","write","apply_patch","multiedit"];function Oj0($,Z){let J=new Set;for(let Y of $){let X=Z.findLast((Q)=>eQ.match(Y,Q.permission)||Aj0.includes(Y)&&eQ.match("edit",Q.permission));if(!X)continue;if(X.pattern==="*"&&X.action==="deny")J.add(Y)}return J}var qj0=Km.pipe(T0.provide(l1.layer));var Vm=P.enum(["interactive-build","read-only-plan","workflow-compose","parallel-max","read-only-explore","subagent","system","custom-primary","custom"]),Ig0=P.enum(["coding","agent","research","review","chat"]),Cg0=P.string().min(1).refine(($)=>$.includes("/"),{message:"Qortex directives must be prompt-registry keys in <scope>/<name> form"});function jj0($){let Z=$.mode==="primary",J=$.mode==="subagent",Y=$.permission===void 0||Q5.evaluate("edit","*",$.permission).action==="deny";switch($.name){case"build":return Z?"interactive-build":J?"subagent":"custom";case"plan":return Z&&Y?"read-only-plan":Z?"custom-primary":"subagent";case"compose":return Z?"workflow-compose":J?"subagent":"custom";case"max":return Z?"parallel-max":J?"subagent":"custom";case"explore":return J&&Y?"read-only-explore":J?"subagent":"custom-primary";case"general":return J?"subagent":Z?"custom-primary":"custom";case"title":case"summary":case"compaction":case"checkpoint-writer":case"dream":case"distill":return $.hidden===!0&&J?"system":J?"subagent":"custom-primary";default:return J?"subagent":Z?"custom-primary":"custom"}}function Nj0($){switch(jj0($)){case"interactive-build":return"coding";case"read-only-plan":return"review";case"workflow-compose":case"parallel-max":case"subagent":return"agent";case"read-only-explore":return"research";case"system":case"custom-primary":case"custom":return}}var Mj0=new Set(["bash","shell","edit","write","apply_patch","multiedit","change_directory","actor","task"]);function Eg0($,Z){let J=Nj0($);if(!J)return;let Y=(J==="coding"||J==="agent"||J==="research")&&Z.some((X)=>Mj0.has(X));return{posture:J,...Y?{directive:"discipline/operational-directives"}:{}}}var Dj0=P.enum(["mode","checkpoint","goal","task-gate","recovery","never-ask","memory","tool-result","runtime"]),wj0=P.enum(["local-policy","session-state","runtime-safety","model-guidance"]),Lj0=P.enum(["system-reminder","plain"]),Tj0={mode:100,checkpoint:90,goal:80,"task-gate":80,recovery:70,"never-ask":60,memory:40,"tool-result":40,runtime:50},Rj0=P.object({source:Dj0,trust:wj0,priority:P.number().int(),posture:Vm.optional(),envelope:Lj0.default("system-reminder"),body:P.string().min(1)});function Pj0($){return Rj0.parse({...$,priority:$.priority??Tj0[$.source]})}function Um($){let Z=Pj0($),J=`source=${Z.source} authority=${Z.trust}`;if(Z.envelope==="plain")return`[system-generated ${J}]
750
- ${Z.body}`;return["<system-reminder>",`[system-generated ${J}]`,Z.body,"</system-reminder>"].join(`
751
- `)}async function gg0($){let Z=await Bun.file(rQ($)).text().catch(()=>"");if(!Z)return new Set;return new Set(su(Z))}async function Hm($,Z){let J=await Bun.file(rQ($)).text().catch(()=>""),Y=await Bun.file(aQ(Z.projectID)).text().catch(()=>""),X=[];if(J)X.push(...nu(J,"checkpoint.md")),X.push(...ru(J,"checkpoint.md",Z.priorTitles));else X.push({file:"checkpoint.md",rule:"topic-missing",severity:"error",detail:"checkpoint file did not exist after writer finished"});if(Y&&Z.expectedRevisions.length>0)X.push(...au(Y,Z.expectedRevisions));let Q=Z.budgets??{checkpoint:11000,memory:1e4,progress_per_task:6000};if(J)X.push(...jA(J,Q.checkpoint,"checkpoint.md"));if(Y)X.push(...jA(Y,Q.memory,"MEMORY.md"));if(J)X.push(...NA(J,tu,"checkpoint.md"));if(Y)X.push(...NA(Y,eu,"MEMORY.md"));return X}function Bm($,Z){let J=new Map;for(let X of $){let Q=J.get(X.file)??[];Q.push(`- ${X.detail}`),J.set(X.file,Q)}let Y=[...J.entries()].map(([X,Q])=>`${X}:
752
- ${Q.join(`
753
- `)}`);return Um({source:"checkpoint",trust:"runtime-safety",posture:"system",body:["The previous attempt at this checkpoint had validation errors. Read your output at the absolute paths below, fix ONLY the issues listed, and write again. Other content may stay the same.","",Y.join(`
754
-
755
- `),"",`CHECKPOINT_PATH = ${Z.checkpoint}`,`MEMORY_PATH = ${Z.memory}`].join(`
756
- `)})}function zm($){return`EXTRACTION REQUIRED: The following files exceed their token budget: ${$.filter((Y)=>Y.severity==="extract-required").map((Y)=>`${Y.file} (${Y.detail})`).join(", ")}.
757
-
758
- Extract the LESS-IMPORTANT topic cluster from the over-budget file into a new spillover file:
759
- - Checkpoint spillover: checkpoint-<topic>.md (sibling of checkpoint.md)
760
- - Memory spillover: MEMORY-<topic>.md (sibling of MEMORY.md)
761
-
762
- Selection criteria for "less important" (extract THESE first):
763
- - Already-stable decisions unlikely to be revisited
764
- - Dead ends before Discovered entries
765
- - Historical / completed steps before recent / in-progress
766
- - Topics not directly relevant to the current focus task
767
-
768
- After extraction, edit the main file to:
769
- - REMOVE the extracted lines
770
- - INSERT an index line near the bottom:
771
- "- See <spillover-filename>.md (N entries) \u2014 short summary"
772
-
773
- Re-validation will run after this single extraction.`}var RA=new Map;function PA($,Z){return`${$}:${Z}`}function mg0($,Z,J){RA.set(PA($,Z),J)}function Fm($,Z){let J=RA.get(PA($,Z));if(!J)return;return structuredClone(J)}function lg0($,Z){RA.delete(PA($,Z))}var Cj0=E0.create({service:"plugin.checkpoint-splitover"}),Ej0={priorTitles:new Set,expectedRevisions:[]};async function Am($){let Z=$.project.id;return{"actor.preStop":{matcher:{agentType:{include:["checkpoint-writer"]}},run:async(J,Y)=>{let X=J.parentSessionID??J.sessionID,Q=Fm(X,J.actorID)??Ej0;try{let G=await Hm(X,{priorTitles:Q.priorTitles,expectedRevisions:Q.expectedRevisions,projectID:Z});if(G.length===0)return;let W=G.filter((V)=>V.severity==="extract-required");if(W.length>0){Y.continue=!0,Y.reason=zm(W);return}let K=G.filter((V)=>V.severity==="error");if(K.length>0){Y.continue=!0,Y.reason=Bm(K,{checkpoint:rQ(X),memory:aQ(Z)});return}}catch(G){Cj0.error("checkpoint-splitover hook failed",{err:G,sessionID:X,actorID:J.actorID})}}}}}import bj0 from"fs/promises";import _j0 from"path";var Sj0=E0.create({service:"plugin.subagent-progress-checker"}),fj0=["## \xA71 Task identity","## \xA72 Subagent intent","## \xA73 Files and code sections","## \xA74 Verbatim commands","## \xA75 Outcome and discoveries"],Om=`## \xA71 Task identity
774
- - task_id: <TID>
775
- - short summary: <one line>
776
-
777
- ## \xA72 Subagent intent
778
- What this subagent was asked to do (one paragraph).
779
-
780
- ## \xA73 Files and code sections
781
- - path/to/file.ext: <what you did with it>
782
-
783
- ## \xA74 Verbatim commands
784
- Exact commands you ran or commands the user/task asked to be runnable later. Keep BACKTICK-FENCED for grep-ability.
785
- \`\`\`
786
- <command>
787
- \`\`\`
788
-
789
- ## \xA75 Outcome and discoveries
790
- - Outcome (success/partial/failed): <reason>
791
- - Discoveries that may matter for other tasks: <bullets>
792
- `;function qm($){if($.kind==="missing")return["Before terminating, write the task progress journal to:",` ${$.filePath}`,"","Required structure (5 sections, headings exact):","",Om.replace("<TID>",$.taskId),"","Write the file now using the Write tool, then terminate normally."].join(`
793
- `);return[`tasks/${$.taskId}/progress.md exists but is missing required sections:`,...($.missing??[]).map((Z)=>` - ${Z}`),"","Add the missing sections. For reference, the full required template is:","",Om.replace("<TID>",$.taskId),"","Re-write the file using Write tool, then terminate normally."].join(`
794
- `)}async function kj0($,Z){let Y=`---
795
- written-at: ${Date.now()}
796
- ---
797
- `,X=Z.match(/^---\n[\s\S]*?\n---\n/),Q=X?Y+Z.slice(X[0].length):Y+Z;await Bun.write($,Q)}async function jm($){return{"actor.postStop":{matcher:{agentType:{excludeOnly:["checkpoint-writer","title","summary","dream","distill","compaction","main"]}},run:async(Z,J)=>{let Y=Z.task_id;if(!Y)return;if(Z.canWrite===!1)return;let X=Z.sessionID,Q=pu(X,Y),G;try{G=await Bun.file(Q).text()}catch{G=void 0}if(G===void 0){J.continue=!0,J.reason=qm({kind:"missing",taskId:Y,filePath:Q});return}let W=fj0.filter((K)=>!G.includes(K));if(W.length>0){J.continue=!0,J.reason=qm({kind:"incomplete",taskId:Y,filePath:Q,missing:W});return}try{await bj0.mkdir(_j0.dirname(Q),{recursive:!0}),await kj0(Q,G)}catch(K){Sj0.error("frontmatter injection failed",{err:K,filePath:Q})}}}}}var IA;((Zu0)=>{function $(Q){let G=s8.pluginSpecifier(Q);return{spec:G,options:s8.pluginOptions(Q),deprecated:Nm(G)}}async function Z(Q,G){let W="";try{W=await wm(Q.spec)}catch(V){return{ok:!1,stage:"install",error:V}}if(!W)return{ok:!1,stage:"install",error:Error(`Plugin ${Q.spec} target is empty`)};let K;try{K=await Lm(Q.spec,W,G)}catch(V){return{ok:!1,stage:"entry",error:V}}if(!K.entry)return{ok:!1,stage:"missing",value:{...Q,source:K.source,target:K.target,pkg:K.pkg,message:`Plugin ${Q.spec} does not expose a ${G} entrypoint`}};if(K.source==="npm")try{await Dm(K.target,E$,K.pkg)}catch(V){return{ok:!1,stage:"compatibility",error:V}}return{ok:!0,value:{...Q,source:K.source,target:K.target,entry:K.entry,pkg:K.pkg}}}Zu0.resolve=Z;async function J(Q){let G;try{G=await import(Q.entry)}catch(W){return{ok:!1,error:W}}if(!G)return{ok:!1,error:Error(`Plugin ${Q.spec} module is empty`)};return{ok:!0,value:{...Q,mod:G}}}Zu0.load=J;async function Y(Q,G,W,K,V,U){let H=Q.plan;if(H.deprecated)return;U?.start?.(Q,W);let B=await Z(H,G);if(!B.ok){if(B.stage==="missing"){if(V){let F=await V(B.value,Q.origin,W);if(F!==void 0)return F}U?.missing?.(Q,W,B.value.message,B.value);return}U?.error?.(Q,W,B.stage,B.error);return}let z=await J(B.value);if(!z.ok){U?.error?.(Q,W,"load",z.error,B.value);return}if(!K)return z.value;return K(z.value,Q.origin,W)}async function X(Q){let G=Q.items.map((U)=>({origin:U,plan:$(U.spec)})),W=[];for(let U of G)W.push(Y(U,Q.kind,!1,Q.finish,Q.missing,Q.report));let K=await Promise.all(W);if(Q.wait){let U;for(let H=0;H<G.length;H++){if(K[H]!==void 0)continue;let B=G[H];if(!B||Mm(B.plan.spec)!=="file")continue;U??=Q.wait(),await U,K[H]=await Y(B,Q.kind,!0,Q.finish,Q.missing,Q.report)}}let V=[];for(let U of K)if(U!==void 0)V.push(U);return V}Zu0.loadExternal=X})(IA||={});var Rm={worktree:Tm(async()=>(await import("./chunk-x7a3kqe5.js")).WorktreeAdaptor)},OK=new Map;async function Xu0($,Z){let J=OK.get($)?.get(Z);if(J)return J;let Y=Rm[Z];if(Y)return Y();throw Error(`Unknown workspace adaptor: ${Z}`)}async function Qu0($){let Z=await Promise.all(Object.entries(Rm).map(async([Y,X])=>{let Q=await X();return{type:Y,name:Q.name,description:Q.description}})),J=[...OK.get($)?.entries()??[]].map(([Y,X])=>({type:Y,name:X.name,description:X.description}));return[...Z,...J]}function Pm($,Z,J){let Y=OK.get($)??new Map;Y.set(Z,J),OK.set($,Y)}import vj0 from"fs/promises";import J9 from"path";import{pathToFileURL as Im,fileURLToPath as yj0}from"url";var z$=E0.create({service:"plugin"}),EA={Executed:L1.define("hook.executed",D.object({event:D.enum(["actor.preStop","actor.postStop"]),hookID:D.string(),pluginName:D.string(),actorID:D.string(),agentType:D.string(),durationMs:D.number(),outcome:D.enum(["success","error","skipped"]),continueRequested:D.boolean(),reasonLength:D.number()})),ReActReentered:L1.define("hook.react.reentered",D.object({phase:D.enum(["pre","post"]),actorID:D.string(),agentType:D.string(),iteration:D.number(),triggeredByPlugins:D.array(D.string()),reasonPreview:D.string()})),ReActMaxReached:L1.define("hook.react.max_reached",D.object({phase:D.enum(["pre","post"]),actorID:D.string(),agentType:D.string()}))};class qK extends S1.Service()("@qitqode/Plugin"){}var xj0=[c2,i2,p2,t2,ku,HK,lu,du,Am,jm];function Cm($){return typeof $==="function"}function hj0($){if(Cm($))return $;if(!$||typeof $!=="object"||!("server"in $))return;if(!Cm($.server))return;return $.server}function gj0($){let Z=new Set,J=[];for(let Y of Object.values($)){if(Z.has(Y))continue;Z.add(Y);let X=hj0(Y);if(!X)throw TypeError("Plugin export is not a function");J.push(X)}return J}async function uj0($,Z,J,Y){let X=bm($.mod,$.spec,"server","detect");if(X){await _m($.source,$.spec,$.target,CA(X.id,$.spec),$.pkg);let Q=CA(X.id,$.spec)??$.pkg?.pkg??$.spec,G=await X.server(Z,$.options);J.push(G),Y.push({hook:G,pluginName:Q,hookIDFor:(W)=>`${Q}#${W}`});return}for(let Q of gj0($.mod)){let G=Q.name,W=G&&G!=="default"&&G!==""?G:$.pkg?.pkg??$.spec,K=await Q(Z,$.options);J.push(K),Y.push({hook:K,pluginName:W,hookIDFor:(V)=>`${W}#${V}`})}}var Sm=T0.effect(qK,T.gen(function*(){let $=yield*l1.Service,Z=yield*X8.Service,J=yield*B0.make(T.fn("Plugin.state")(function*(F){let A=[],j=[],N=yield*T7.make();function L(f){N.fork($.publish(Y9.Event.Error,{error:new j1.Unknown({message:f}).toObject()}))}let{Server:q}=yield*T.promise(()=>import("./chunk-76c400ze.js")),M=LH({baseUrl:"http://localhost:4096",directory:F.directory,headers:b0.QITQODE_SERVER_PASSWORD?{Authorization:`Basic ${Buffer.from(`${b0.QITQODE_SERVER_USERNAME??"qitqode"}:${b0.QITQODE_SERVER_PASSWORD}`).toString("base64")}`}:void 0,fetch:async(...f)=>(await q.Default()).app.fetch(...f)}),C=yield*Z.get(),R={client:M,project:F.project,worktree:F.worktree,directory:F.directory,experimental_workspace:{register(f,b){Pm(F.project.id,f,b)}},get serverUrl(){return q.url??new URL("http://localhost:4096")},$:typeof Bun>"u"?void 0:Bun.$};for(let f of xj0){z$.info("loading internal plugin",{name:f.name});let b=yield*T.tryPromise({try:()=>f(R),catch:(y)=>{z$.error("failed to load internal plugin",{name:f.name,error:y})}}).pipe(T.option);if(b._tag==="Some")A.push(b.value),j.push({hook:b.value,pluginName:f.name,hookIDFor:(y)=>`${f.name}#${y}`})}let w={},I=yield*T.tryPromise(()=>import("./chunk-aenrd7dk.js")).pipe(T.option);if(I._tag==="Some")Object.assign(w,I.value.modules??{});else{let f=J9.join(J9.dirname(yj0(import.meta.url)),"..","ext"),y=(yield*T.promise(()=>vj0.readdir(f).catch(()=>[]))).filter((k)=>k.endsWith(".ts")&&!k.endsWith(".d.ts")&&k!=="_manifest.ts");for(let k of y){let g=yield*T.tryPromise({try:()=>import(Im(J9.join(f,k)).href),catch:(d)=>z$.error("failed to import extension",{name:k,error:d})}).pipe(T.option);if(g._tag==="Some")w[k.replace(/\.ts$/,"")]=g.value}}for(let[f,b]of Object.entries(w)){let y=Object.entries(b).find(([g,d])=>typeof d==="function"&&g.endsWith("Plugin"))?.[1];if(!y)continue;z$.info("loading extension",{name:f});let k=yield*T.tryPromise({try:()=>y(R),catch:(g)=>z$.error("failed to load extension",{name:f,error:g})}).pipe(T.option);if(k._tag==="Some")A.push(k.value),j.push({hook:k.value,pluginName:f,hookIDFor:(g)=>`${f}#${g}`})}let _=b0.QITQODE_PURE?[]:C.plugin_origins??[];if(b0.QITQODE_PURE&&C.plugin_origins?.length)z$.info("skipping external plugins in pure mode",{count:C.plugin_origins.length});if(_.length)yield*Z.waitForDependencies();let E=yield*T.promise(()=>IA.loadExternal({items:_,kind:"server",report:{start(f){z$.info("loading plugin",{path:f.plan.spec})},missing(f,b,y){z$.warn("plugin has no server entrypoint",{path:f.plan.spec,message:y})},error(f,b,y,k,g){let d=f.plan.spec,p=k instanceof Error?k.cause??k:k,t=y==="load"?V6(k):V6(p);if(y==="install"){let r=Em(d);z$.error("failed to install plugin",{pkg:r.pkg,version:r.version,error:t}),L(`Failed to install plugin ${r.pkg}@${r.version}: ${t}`);return}if(y==="compatibility"){z$.warn("plugin incompatible",{path:d,error:t}),L(`Plugin ${d} skipped: ${t}`);return}if(y==="entry"){z$.error("failed to resolve plugin server entry",{path:d,error:t}),L(`Failed to load plugin ${d}: ${t}`);return}z$.error("failed to load plugin",{path:d,target:g?.entry,error:t}),L(`Failed to load plugin ${d}: ${t}`)}}}));for(let f of E){if(!f)continue;yield*T.tryPromise({try:()=>uj0(f,R,A,j),catch:(b)=>{let y=V6(b);return z$.error("failed to load plugin",{path:f.spec,error:y}),y}}).pipe(T.catch(()=>{return T.void}))}for(let f of A)yield*T.tryPromise({try:()=>Promise.resolve(f.config?.(C)),catch:(b)=>{z$.error("plugin config hook failed",{error:b})}}).pipe(T.ignore);return yield*$.subscribeAll().pipe(I$.runForEach((f)=>T.sync(()=>{for(let b of A)b.event?.({event:f})})),T.forkScoped),{hooks:A,hooksWithMeta:j}})),Y=yield*B0.make(T.fn("Plugin.fileHooks")(function*(){let F=[],A=[],j=yield*Z.get(),N=yield*Z.directories();for(let L of N){let q=$4.scanSync("{hook,hooks}/*.{js,ts}",{cwd:L,absolute:!0,dot:!0,symlink:!0});for(let M of q){let C=yield*T.tryPromise({try:()=>import(`${Im(M).href}?v=${Date.now()}`),catch:(w)=>w}).pipe(T.catch((w)=>{return z$.error("failed to load file hook",{path:M,error:V6(w)}),T.succeed(void 0)}));if(!C)continue;let R=C.default??C;if(R&&typeof R==="object"){let w=J9.basename(M,J9.extname(M));F.push(R),A.push({hook:R,pluginName:`file:${w}`,hookIDFor:(I)=>`file:${w}#${I}`}),z$.info("loaded file hook",{path:M,name:w})}}}return{hooks:F,meta:A}})),X=(F,A)=>T.gen(function*(){let j=yield*B0.get(J),N=yield*B0.get(Y),L=[],q=[],M=[],C=!1;for(let w of[...j.hooksWithMeta,...N.meta]){let I=w.hook[A];if(!I)continue;let _=typeof I==="function"?I:I.run,E=typeof I==="function"?void 0:I.matcher;if(!U2(E,F)){yield*$.publish(EA.Executed,{event:A,hookID:w.hookIDFor(A),pluginName:w.pluginName,actorID:F.actorID,agentType:F.agentType,durationMs:0,outcome:"skipped",continueRequested:!1,reasonLength:0});continue}let f=Date.now(),b={continue:!1},y="success";yield*T.tryPromise({try:()=>_(F,b),catch:(g)=>g}).pipe(T.tapError((g)=>T.gen(function*(){y="error",z$.error(`${A} hook failed`,{pluginName:w.pluginName,hookID:w.hookIDFor(A),error:g}),yield*$.publish(Y9.Event.Error,{sessionID:F.sessionID,error:new j1.Unknown({message:`${A} hook (${w.pluginName}) failed: ${V6(g)}`}).toObject()})})),T.ignore);let k=Date.now()-f;if(yield*$.publish(EA.Executed,{event:A,hookID:w.hookIDFor(A),pluginName:w.pluginName,actorID:F.actorID,agentType:F.agentType,durationMs:k,outcome:y,continueRequested:b.continue===!0,reasonLength:b.reason?.length??0}),b.continue===!0&&b.reason&&b.reason.length>0)C=!0,L.push(b.reason),q.push(w.pluginName),M.push(w.hookIDFor(A));else if(b.continue===!0)z$.warn(`${A} hook returned continue=true without reason; ignored`,{pluginName:w.pluginName})}return{continue:C,reason:L.length>0?L.join(`
798
-
799
- `):void 0,contributingPluginNames:q,contributingHookIDs:M}}),Q=T.fn("Plugin.triggerActorPreStop")(function*(F){return yield*X(F,"actor.preStop")}),G=T.fn("Plugin.triggerActorPostStop")(function*(F){return yield*X(F,"actor.postStop")}),W=5000,K=3,V=new Map,U=T.fn("Plugin.trigger")(function*(F,A,j){if(!F)return j;let N=yield*B0.get(J),L=yield*B0.get(Y);for(let q of N.hooksWithMeta){let M=q.hook[F];if(!M)continue;yield*T.promise(async()=>M(A,j))}for(let q of L.meta){let M=q.hook[F];if(!M)continue;let C=q.hookIDFor(F);if((V.get(C)??0)>=3){z$.warn("hook circuit-breaker open, skipping",{hook:C});continue}let R=structuredClone(j);if(!(yield*T.tryPromise({try:async()=>{await Promise.race([Promise.resolve(M(A,j)),new Promise((I,_)=>setTimeout(()=>_(Error("hook timed out after 5000ms")),5000))])},catch:(I)=>I}).pipe(T.map(()=>!1),T.catch((I)=>{Object.assign(j,R);let _=(V.get(C)??0)+1;return V.set(C,_),z$.error("file hook failed, output rolled back",{hook:C,event:F,error:V6(I),consecutiveFailures:_,circuitOpen:_>=3}),T.succeed(!0)}))))V.delete(C)}return j}),H=T.fn("Plugin.list")(function*(){return(yield*B0.get(J)).hooks}),B=T.fn("Plugin.init")(function*(){yield*B0.get(J),yield*B0.get(Y)}),z=T.fn("Plugin.reloadFileHooks")(function*(){yield*B0.invalidate(Y)});return qK.of({trigger:U,list:H,init:B,reloadFileHooks:z,triggerActorPreStop:Q,triggerActorPostStop:G})})),mj0=Sm.pipe(T0.provide(l1.layer),T0.provide(X8.defaultLayer));import UN0 from"path";var RK=m6(km(),1);var X9={};F1(X9,{variants:()=>G5,topP:()=>am,topK:()=>tm,temperature:()=>rm,smallOptions:()=>$l,schema:()=>Xl,providerOptions:()=>Zl,options:()=>em,message:()=>hm,maxOutputTokens:()=>Jl,OUTPUT_TOKEN_MAX:()=>MK});var ym=32000;function lj0($){if($.startsWith("image/"))return"image";if($.startsWith("audio/"))return"audio";if($.startsWith("video/"))return"video";if($==="application/pdf")return"pdf";return}function dj0($){let Z=$.id.toLowerCase(),J=$.api.id.toLowerCase();if(Z.includes("claude")||J.includes("claude")||$.providerID==="anthropic")return!0;if(Z.includes("gpt")||J.includes("gpt"))return!0;return $.capabilities.input.image}function NK($){switch($){case"@ai-sdk/github-copilot":return"copilot";case"@ai-sdk/azure":return"azure";case"@ai-sdk/openai":return"openai";case"@ai-sdk/amazon-bedrock":return"bedrock";case"@ai-sdk/anthropic":case"@ai-sdk/google-vertex/anthropic":return"anthropic";case"@ai-sdk/google-vertex":return"vertex";case"@ai-sdk/google":return"google";case"@ai-sdk/gateway":return"gateway";case"@openrouter/ai-sdk-provider":return"openrouter"}return}function pj0($,Z,J){if(Z.api.npm==="@ai-sdk/anthropic"||Z.api.npm==="@ai-sdk/amazon-bedrock")$=$.map((Y)=>{if(typeof Y.content==="string"){if(Y.content==="")return;return Y}if(!Array.isArray(Y.content))return Y;let X=Y.content.filter((Q)=>{if(Q.type==="text"||Q.type==="reasoning")return Q.text!=="";return!0});if(X.length===0)return;return{...Y,content:X}}).filter((Y)=>Y!==void 0&&Y.content!=="");if(Z.api.id.includes("claude")){let Y=(X)=>X.replace(/[^a-zA-Z0-9_-]/g,"_");$=$.map((X)=>{if(X.role==="assistant"&&Array.isArray(X.content))return{...X,content:X.content.map((Q)=>{if(Q.type==="tool-call"||Q.type==="tool-result")return{...Q,toolCallId:Y(Q.toolCallId)};return Q})};if(X.role==="tool"&&Array.isArray(X.content))return{...X,content:X.content.map((Q)=>{if(Q.type==="tool-result")return{...Q,toolCallId:Y(Q.toolCallId)};return Q})};return X})}if(["@ai-sdk/anthropic","@ai-sdk/google-vertex/anthropic"].includes(Z.api.npm))$=$.flatMap((Y)=>{if(Y.role!=="assistant"||!Array.isArray(Y.content))return[Y];let X=Y.content,Q=X.findIndex((G)=>G.type==="tool-call");if(Q===-1)return[Y];if(!X.slice(Q).some((G)=>G.type!=="tool-call"))return[Y];return[{...Y,content:X.filter((G)=>G.type!=="tool-call")},{...Y,content:X.filter((G)=>G.type==="tool-call")}]});if(Z.providerID==="mistral"||Z.api.id.toLowerCase().includes("mistral")||Z.api.id.toLowerCase().includes("devstral")){let Y=(Q)=>{return Q.replace(/[^a-zA-Z0-9]/g,"").substring(0,9).padEnd(9,"0")},X=[];for(let Q=0;Q<$.length;Q++){let G=$[Q],W=$[Q+1];if(G.role==="assistant"&&Array.isArray(G.content))X.push({...G,content:G.content.map((K)=>{if(K.type==="tool-call"||K.type==="tool-result")return{...K,toolCallId:Y(K.toolCallId)};return K})});else if(G.role==="tool"&&Array.isArray(G.content))X.push({...G,content:G.content.map((K)=>{if(K.type==="tool-result")return{...K,toolCallId:Y(K.toolCallId)};return K})});else X.push(G);if(G.role==="tool"&&W?.role==="user")X.push({role:"assistant",content:[{type:"text",text:"Done."}]})}return X}if(typeof Z.capabilities.interleaved==="object"&&Z.capabilities.interleaved.field){let Y=Z.capabilities.interleaved.field;return $.map((X)=>{if(X.role==="assistant"&&Array.isArray(X.content)){let G=X.content.filter((K)=>K.type==="reasoning").map((K)=>K.text).join(""),W=X.content.filter((K)=>K.type!=="reasoning");if(G)return{...X,content:W,providerOptions:{...X.providerOptions,openaiCompatible:{...X.providerOptions?.openaiCompatible,[Y]:G}}};return{...X,content:W}}return X})}return $}function cj0($){if($.api.npm==="@ai-sdk/anthropic"||$.api.npm==="@ai-sdk/google-vertex/anthropic")return!0;if($.providerID==="anthropic"||$.providerID==="google-vertex-anthropic")return!0;if($.api.npm==="@ai-sdk/amazon-bedrock")return!0;if($.api.npm==="@openrouter/ai-sdk-provider"||$.api.npm==="@ai-sdk/github-copilot"||$.api.npm==="@ai-sdk/alibaba")return $.api.id.includes("claude")||$.api.id.includes("anthropic")||$.id.includes("claude")||$.id.includes("anthropic");return!1}function ij0($,Z){let J=Z.cachePromptTTL==="1h"?{ttl:"1h"}:{},Y={anthropic:{cacheControl:{type:"ephemeral",...J}},openrouter:{cacheControl:{type:"ephemeral",...J}},bedrock:{cachePoint:{type:"default"}},openaiCompatible:{cache_control:{type:"ephemeral"}},copilot:{copilot_cache_control:{type:"ephemeral"}},alibaba:{cacheControl:{type:"ephemeral"}}},X=[],Q=$.filter((K)=>K.role==="system");if(Q.length>0)X.push(Q[Q.length-1]);let G=$.filter((K)=>K.role!=="system"),W=G.findLastIndex((K)=>K.role==="user");if(W>=1){X.push(G[W-1]);let K=Math.floor(W/2);if(K>0&&K<W-1)X.push(G[K])}else if(W===0)X.push(G[0]);for(let K of vm(X)){if(!(Z.providerID==="anthropic"||Z.providerID.includes("bedrock")||Z.api.npm==="@ai-sdk/amazon-bedrock")&&Array.isArray(K.content)&&K.content.length>0){let H=K.content[K.content.length-1];if(H&&typeof H==="object"&&H.type!=="tool-approval-request"&&H.type!=="tool-approval-response"){H.providerOptions=N1(H.providerOptions??{},Y);continue}}K.providerOptions=N1(K.providerOptions??{},Y)}return $}function nj0($,Z){return $.map((J)=>{if(J.role!=="user"||!Array.isArray(J.content))return J;let Y=J.content.map((X)=>{if(X.type!=="file"&&X.type!=="image")return X;if(X.type==="image"){let U=String(X.image);if(U.startsWith("data:")){let H=U.match(/^data:([^;]+);base64,(.*)$/);if(H&&(!H[2]||H[2].length===0))return{type:"text",text:"ERROR: Image file is empty or corrupted. Please provide a valid image."}}}let Q=X.type==="image"?String(X.image).split(";")[0].replace("data:",""):X.mediaType,G=X.type==="file"?X.filename:void 0,W=lj0(Q);if(!W)return X;if(W==="image"?dj0(Z):Z.capabilities.input[W])return X;return{type:"text",text:`ERROR: Cannot read ${G?`"${G}"`:W} (this model does not support ${W} input). Inform the user.`}});return{...J,content:Y}})}function oj0($){if(!$.startsWith("data:"))return;let Z=$.slice($.indexOf(",")+1);if(!Z)return 0;let J=Z.endsWith("==")?2:Z.endsWith("=")?1:0;return Math.floor(Z.length*3/4)-J}function sj0($,Z,J){if(Z===void 0&&J===void 0)return $;let Y=$.reduce((Q,G)=>G.role==="user"&&Array.isArray(G.content)?Q+G.content.filter((W)=>W.type==="image").length:Q,0),X=Z===void 0?0:Math.max(0,Y-Z);return $.map((Q)=>{if(Q.role!=="user"||!Array.isArray(Q.content))return Q;let G=Q.content.map((W)=>{if(W.type!=="image")return W;if(X>0)return X--,{type:"text",text:`[Image omitted: exceeds the configured limit of ${Z} prompt image(s).]`};if(J!==void 0){let K=oj0(String(W.image));if(K!==void 0&&K>J)return{type:"text",text:`[Image omitted: exceeds the configured ${J}-byte prompt image size limit.]`}}return W});return{...Q,content:G}})}function xm($,Z,J,Y={}){if($=nj0($,Z),$=sj0($,Y.maxImages,Y.maxSize),$=pj0($,Z,J),cj0(Z))$=ij0($,Z);let X=NK(Z.api.npm);if(X&&X!==Z.providerID){let Q=(G)=>{if(!G)return G;if(!(Z.providerID in G))return G;let W={...G};return W[X]=W[Z.providerID],delete W[Z.providerID],W};$=$.map((G)=>{if(!Array.isArray(G.content))return{...G,providerOptions:Q(G.providerOptions)};return{...G,providerOptions:Q(G.providerOptions),content:G.content.map((W)=>{if(W.type==="tool-approval-request"||W.type==="tool-approval-response")return{...W};return{...W,providerOptions:Q(W.providerOptions)}})}})}return $}var MK=b0.QITQODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX||ym;function hm($,Z,J){return xm($,Z,J,{maxImages:b0.QITQODE_MAX_PROMPT_IMAGES,maxSize:b0.QITQODE_MAX_PROMPT_IMAGE_SIZE})}function gm($){return $()}var U6=["low","medium","high"],um=["none","minimal",...U6,"xhigh"];function mm($){if($)return Object.fromEntries($.map((Z)=>[Z,{thinking:{type:"adaptive"},effort:Z}]));return{high:{thinking:{type:"enabled",budgetTokens:16000}},max:{thinking:{type:"enabled",budgetTokens:31999}}}}function rj0($){if(["opus-4-7","opus-4.7","opus-4-8","opus-4.8"].some((Z)=>$.includes(Z)))return["low","medium","high","xhigh","max"];if(["opus-4-6","opus-4.6","sonnet-4-6","sonnet-4.6"].some((Z)=>$.includes(Z)))return["low","medium","high","max"];return null}function lm($){if(!$.capabilities.reasoning)return{};let Z=$.id.toLowerCase(),J=rj0($.api.id);if(Z.includes("deepseek")||Z.includes("minimax")||Z.includes("glm")||Z.includes("mistral")||Z.includes("kimi")||Z.includes("k2p5")||Z.includes("qwen")||Z.includes("big-pickle"))return{};if(Z.includes("grok")&&Z.includes("grok-3-mini")){if($.api.npm==="@openrouter/ai-sdk-provider")return{low:{reasoning:{effort:"low"}},high:{reasoning:{effort:"high"}}};return{low:{reasoningEffort:"low"},high:{reasoningEffort:"high"}}}if(Z.includes("grok"))return{};switch($.api.npm){case"@openrouter/ai-sdk-provider":if(!$.id.includes("gpt")&&!$.id.includes("gemini-3")&&!$.id.includes("claude"))return{};return Object.fromEntries(um.map((K)=>[K,{reasoning:{effort:K}}]));case"@ai-sdk/gateway":if($.id.includes("anthropic"))return mm(J);if($.id.includes("google")){if(Z.includes("2.5"))return{high:{thinkingConfig:{includeThoughts:!0,thinkingBudget:16000}},max:{thinkingConfig:{includeThoughts:!0,thinkingBudget:24576}}};return Object.fromEntries(["low","high"].map((K)=>[K,{includeThoughts:!0,thinkingLevel:K}]))}return Object.fromEntries(um.map((K)=>[K,{reasoningEffort:K}]));case"@ai-sdk/github-copilot":if($.id.includes("gemini"))return{};if($.id.includes("claude"))return Object.fromEntries(U6.map((K)=>[K,{reasoningEffort:K}]));let Y=gm(()=>{if(Z.includes("5.1-codex-max")||Z.includes("5.2")||Z.includes("5.3"))return[...U6,"xhigh"];let K=[...U6];if(Z.includes("gpt-5")&&$.release_date>="2025-12-04")K.push("xhigh");return K});return Object.fromEntries(Y.map((K)=>[K,{reasoningEffort:K,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}]));case"@ai-sdk/cerebras":case"@ai-sdk/togetherai":case"@ai-sdk/xai":case"@ai-sdk/deepinfra":case"venice-ai-sdk-provider":case"@ai-sdk/openai-compatible":return Object.fromEntries(U6.map((K)=>[K,{reasoningEffort:K}]));case"@ai-sdk/azure":if(Z==="o1-mini")return{};let X=["low","medium","high"];if(Z.includes("gpt-5-")||Z==="gpt-5")X.unshift("minimal");return Object.fromEntries(X.map((K)=>[K,{reasoningEffort:K,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}]));case"@ai-sdk/openai":if(Z==="gpt-5-pro")return{};let Q=gm(()=>{if(Z.includes("codex")){if(Z.includes("5.2")||Z.includes("5.3"))return[...U6,"xhigh"];return U6}let K=[...U6];if(Z.includes("gpt-5-")||Z==="gpt-5")K.unshift("minimal");if($.release_date>="2025-11-13")K.unshift("none");if($.release_date>="2025-12-04")K.push("xhigh");return K});return Object.fromEntries(Q.map((K)=>[K,{reasoningEffort:K,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}]));case"@ai-sdk/anthropic":case"@ai-sdk/google-vertex/anthropic":if($.providerID==="github-copilot"){if($.api.id.includes("opus-4.7"))return Object.fromEntries(["medium"].map((K)=>[K,{reasoningEffort:K}]))}if(J)return Object.fromEntries(J.map((K)=>[K,{thinking:{type:"adaptive",...["opus-4-7","opus-4.7","opus-4-8","opus-4.8"].some((V)=>$.api.id.includes(V))?{display:"summarized"}:{}},effort:K}]));return{high:{thinking:{type:"enabled",budgetTokens:Math.max(1,Math.min(16000,Math.floor($.limit.output/2-1)))}},max:{thinking:{type:"enabled",budgetTokens:Math.max(1,Math.min(31999,$.limit.output-1))}}};case"@ai-sdk/amazon-bedrock":if(J)return Object.fromEntries(J.map((K)=>[K,{reasoningConfig:{type:"adaptive",maxReasoningEffort:K,...["opus-4-7","opus-4.7","opus-4-8","opus-4.8"].some((V)=>$.api.id.includes(V))?{display:"summarized"}:{}}}]));if($.api.id.includes("anthropic"))return{high:{reasoningConfig:{type:"enabled",budgetTokens:16000}},max:{reasoningConfig:{type:"enabled",budgetTokens:31999}}};return Object.fromEntries(U6.map((K)=>[K,{reasoningConfig:{type:"enabled",maxReasoningEffort:K}}]));case"@ai-sdk/google-vertex":case"@ai-sdk/google":if(Z.includes("2.5"))return{high:{thinkingConfig:{includeThoughts:!0,thinkingBudget:16000}},max:{thinkingConfig:{includeThoughts:!0,thinkingBudget:24576}}};let G=["low","high"];if(Z.includes("3.1"))G=["low","medium","high"];return Object.fromEntries(G.map((K)=>[K,{thinkingConfig:{includeThoughts:!0,thinkingLevel:K}}]));case"@ai-sdk/mistral":return{};case"@ai-sdk/cohere":return{};case"@ai-sdk/groq":let W=["none",...U6];return Object.fromEntries(W.map((K)=>[K,{reasoningEffort:K}]));case"@ai-sdk/perplexity":return{};case"@jerome-benoit/sap-ai-provider-v2":if($.api.id.includes("anthropic"))return mm(J);if($.api.id.includes("gemini")&&Z.includes("2.5"))return{high:{thinkingConfig:{includeThoughts:!0,thinkingBudget:16000}},max:{thinkingConfig:{includeThoughts:!0,thinkingBudget:24576}}};if($.api.id.includes("gpt")||/\bo[1-9]/.test($.api.id))return Object.fromEntries(U6.map((K)=>[K,{reasoningEffort:K}]));return{}}return{}}function G5($){return lm($)}function dm($){let Z=$.id.toLowerCase();if(Z.includes("qwen"))return 0.55;if(Z.includes("claude"))return;if(Z.includes("gemini"))return 1;if(Z.includes("glm-4.6"))return 1;if(Z.includes("glm-4.7"))return 1;if(Z.includes("minimax-m2"))return 1;if(Z.includes("kimi-k2")){if(["thinking","k2.","k2p","k2-5"].some((J)=>Z.includes(J)))return 1;return 0.6}return}function pm($){let Z=$.id.toLowerCase();if(Z.includes("qwen"))return 1;if(["minimax-m2","gemini","kimi-k2.5","kimi-k2p5","kimi-k2-5"].some((J)=>Z.includes(J)))return 0.95;return}function cm($){let Z=$.id.toLowerCase();if(Z.includes("minimax-m2")){if(["m2.","m25","m21"].some((J)=>Z.includes(J)))return 40;return 20}if(Z.includes("gemini"))return 64;return}function im($){let Z={};if($.model.providerID==="openai"||$.model.api.npm==="@ai-sdk/openai"||$.model.api.npm==="@ai-sdk/github-copilot")Z.store=!1;if($.model.api.npm==="@ai-sdk/azure")Z.store=!0,Z.promptCacheKey=$.sessionID;if($.model.api.npm==="@openrouter/ai-sdk-provider"||$.model.api.npm==="@llmgateway/ai-sdk-provider"){if(Z.usage={include:!0},$.model.api.id.includes("gemini-3"))Z.reasoning={effort:"high"}}if($.model.providerID==="baseten"||$.model.providerID==="opencode"&&["kimi-k2-thinking","glm-4.6"].includes($.model.api.id))Z.chat_template_args={enable_thinking:!0};if(["zai","zhipuai"].some((Y)=>$.model.providerID.includes(Y))&&$.model.api.npm==="@ai-sdk/openai-compatible")Z.thinking={type:"enabled",clear_thinking:!1};if($.model.providerID==="openai"||$.providerOptions?.setCacheKey)Z.promptCacheKey=$.sessionID;if($.model.api.npm==="@ai-sdk/google"||$.model.api.npm==="@ai-sdk/google-vertex"){if($.model.capabilities.reasoning){if(Z.thinkingConfig={includeThoughts:!0},$.model.api.id.includes("gemini-3"))Z.thinkingConfig.thinkingLevel="high"}}let J=$.model.api.id.toLowerCase();if(($.model.api.npm==="@ai-sdk/anthropic"||$.model.api.npm==="@ai-sdk/google-vertex/anthropic")&&(J.includes("k2p5")||J.includes("kimi-k2.5")||J.includes("kimi-k2p5")))Z.thinking={type:"enabled",budgetTokens:Math.max(1,Math.min(16000,Math.floor($.model.limit.output/2-1)))};if($.model.providerID==="alibaba-cn"&&$.model.capabilities.reasoning&&$.model.api.npm==="@ai-sdk/openai-compatible"&&!J.includes("kimi-k2-thinking"))Z.enable_thinking=!0;if($.model.api.id.includes("gpt-5")&&!$.model.api.id.includes("gpt-5-chat")){if(!$.model.api.id.includes("gpt-5-pro")){if(Z.reasoningEffort="medium",$.model.api.npm==="@ai-sdk/openai"||$.model.api.npm==="@ai-sdk/azure"||$.model.api.npm==="@ai-sdk/github-copilot")Z.reasoningSummary="auto"}if($.model.api.id.includes("gpt-5.")&&!$.model.api.id.includes("codex")&&!$.model.api.id.includes("-chat")&&$.model.providerID!=="azure")Z.textVerbosity="low";if($.model.providerID.startsWith("opencode"))Z.promptCacheKey=$.sessionID,Z.include=["reasoning.encrypted_content"],Z.reasoningSummary="auto"}if($.model.providerID==="venice")Z.promptCacheKey=$.sessionID;if($.model.providerID==="openrouter")Z.prompt_cache_key=$.sessionID;if($.model.api.npm==="@ai-sdk/gateway")Z.gateway={caching:"auto"};return Z}function nm($){if($.providerID==="openai"||$.api.npm==="@ai-sdk/openai"||$.api.npm==="@ai-sdk/github-copilot"){if($.api.id.includes("gpt-5")){if($.api.id.includes("5.")||$.api.id.includes("5-mini"))return{store:!1,reasoningEffort:"low"};return{store:!1,reasoningEffort:"minimal"}}return{store:!1}}if($.providerID==="google"){if($.api.id.includes("gemini-3"))return{thinkingConfig:{thinkingLevel:"minimal"}};return{thinkingConfig:{thinkingBudget:0}}}if($.providerID==="openrouter"||$.providerID==="llmgateway"){if($.api.id.includes("google"))return{reasoning:{enabled:!1}};return{reasoningEffort:"minimal"}}if($.providerID==="venice")return{veniceParameters:{disableThinking:!0}};return{}}var aj0={amazon:"bedrock"};function om($,Z){if($.api.npm==="@ai-sdk/gateway"){let Y=$.api.id.indexOf("/"),X=Y>0?$.api.id.slice(0,Y):void 0,Q=X?aj0[X]??X:void 0,G=Z.gateway,W=Object.fromEntries(Object.entries(Z).filter(([U])=>U!=="gateway")),K=Object.keys(W).length>0,V={};if(G!==void 0)V.gateway=G;if(K)if(Q)V[Q]=W;else if(G&&typeof G==="object"&&!Array.isArray(G))V.gateway={...G,...W};else V.gateway=W;return V}let J=NK($.api.npm)??$.providerID;if($.api.npm==="@ai-sdk/azure")return{openai:Z,azure:Z};return{[J]:Z}}function sm($,Z){return Math.min($.limit.output,Z)||Z}function rm($){return dm($)}function am($){return pm($)}function tm($){return cm($)}function em($){return im($)}function $l($){return nm($)}function Zl($,Z){return om($,Z)}function Jl($){return sm($,MK)}function tj0($){let Z=$,J=Z.anyOf??Z.oneOf;if(!J?.length)return $;let Y=new Map;for(let W of J){if(!W.properties)continue;for(let[K,V]of Object.entries(W.properties))if(V&&typeof V==="object"&&"const"in V){if(!Y.has(K))Y.set(K,new Set);Y.get(K).add(V.const)}}let X;for(let[W,K]of Y)if(K.size===J.length){X=W;break}let Q={},G={};for(let W of J){if(!W.properties)continue;let K=X?W.properties[X]?.const:void 0;for(let[V,U]of Object.entries(W.properties)){if(V===X)continue;if(!(V in Q))Q[V]=U;if(K!==void 0){if(!G[V])G[V]=[];G[V].push(K)}}}if(X)for(let[W,K]of Object.entries(G)){if(K.length===J.length)continue;let V=`(only when ${X}=${K.map((H)=>JSON.stringify(H)).join("|")})`,U=Q[W].description;Q[W]={...Q[W],description:U?`${V} ${U}`:V}}if(X){let W=J[0].properties[X],K=J.map((H)=>H.properties[X]?.const),V=W?.description??"",U=J.map((H)=>{let B=H.properties[X]?.const,z=(H.required??[]).filter((F)=>F!==X);return z.length>0?`${B}: requires ${z.join(", ")}`:`${B}: no extra required fields`}).join("; ");Q[X]={type:"string",enum:K,description:V?`${V}
800
-
801
- Per-${X}: ${U}.`:`Per-${X}: ${U}.`}}return{type:"object",properties:Q,required:X?[X]:[],additionalProperties:!1}}function Yl($,Z){if(Z=tj0(Z),$.providerID==="google"||$.api.id.includes("gemini")){let J=(G)=>typeof G==="object"&&G!==null&&!Array.isArray(G),Y=(G)=>J(G)&&(Array.isArray(G.anyOf)||Array.isArray(G.oneOf)||Array.isArray(G.allOf)),X=(G)=>{if(!J(G))return!1;if(Y(G))return!0;return["type","properties","items","prefixItems","enum","const","$ref","additionalProperties","patternProperties","required","not","if","then","else"].some((W)=>(W in G))},Q=(G)=>{if(G===null||typeof G!=="object")return G;if(Array.isArray(G))return G.map(Q);let W={};for(let[K,V]of Object.entries(G))if(K==="enum"&&Array.isArray(V)){if(W[K]=V.map((U)=>String(U)),W.type==="integer"||W.type==="number")W.type="string"}else if(typeof V==="object"&&V!==null)W[K]=Q(V);else W[K]=V;if(W.type==="object"&&W.properties&&Array.isArray(W.required))W.required=W.required.filter((K)=>(K in W.properties));if(W.type==="array"&&!Y(W)){if(W.items==null)W.items={};if(J(W.items)&&!X(W.items))W.items.type="string"}if(W.type&&W.type!=="object"&&!Y(W))delete W.properties,delete W.required;return W};Z=Q(Z)}return Z}function Xl($,Z){return Yl($,Z)}var bA=1e6,DK=new Set(F8.tiers().map(($)=>$.id)),Wl=F8.tiers(),N7=Object.fromEntries(Wl.map(($)=>[$.id,{providerID:$.providerID,modelID:$.modelID}])),k6=F8.qlexProviderMeta();function Kl($,Z){let J=F8.tierBudgetFacts($)??F8.tierBudgetFacts("adaptive");return{id:s1.make($),providerID:X1.make("qlex"),name:Z,family:k6.family,api:{id:$,url:"",npm:k6.npm},status:"active",headers:{},options:{},cost:{input:0,output:0,cache:{read:0,write:0}},limit:{context:J.context,output:J.output},capabilities:{temperature:k6.capabilities.temperature,reasoning:J.reasoning,attachment:k6.capabilities.attachment,toolcall:k6.capabilities.toolcall,input:{...k6.capabilities.input},output:{...k6.capabilities.output},interleaved:k6.capabilities.interleaved},release_date:k6.release_date,variants:{}}}var Q9={id:X1.make("qlex"),name:k6.name,source:"custom",env:[],options:{},models:Object.fromEntries(Wl.map(($)=>[$.id,Kl($.id,$.label)]))};function Vl(){let $=F8.tiers();DK.clear();for(let J of $)DK.add(J.id);for(let J of Object.keys(N7))delete N7[J];Object.assign(N7,Object.fromEntries($.map((J)=>[J.id,{providerID:J.providerID,modelID:J.modelID}])));let Z=Q9.models;for(let J of Object.keys(Z))delete Z[J];Object.assign(Q9.models,Object.fromEntries($.map((J)=>[J.id,Kl(J.id,J.label)])))}var _A=new Set;function Ul($){let Z={input:$?.input??0,output:$?.output??0,cache:{read:$?.cache_read??0,write:$?.cache_write??0}};if($?.context_over_200k)Z.experimentalOver200K={cache:{read:$.context_over_200k.cache_read??0,write:$.context_over_200k.cache_write??0},input:$.context_over_200k.input,output:$.context_over_200k.output};return Z}function Ql($,Z){let J={id:s1.make(Z.id),providerID:X1.make($.id),name:Z.name,family:Z.family,api:{id:Z.id,url:Z.provider?.api??$.api??"",npm:Z.provider?.npm??$.npm??"@ai-sdk/openai-compatible"},status:Z.status??"active",headers:{},options:{},cost:Ul(Z.cost),limit:{context:Z.limit.context,input:Z.limit.input,output:Z.limit.output},capabilities:{temperature:Z.temperature??!1,reasoning:Z.reasoning??!1,attachment:Z.attachment??!1,toolcall:Z.tool_call??!0,input:{text:Z.modalities?.input?.includes("text")??!1,audio:Z.modalities?.input?.includes("audio")??!1,image:Z.modalities?.input?.includes("image")??!1,video:Z.modalities?.input?.includes("video")??!1,pdf:Z.modalities?.input?.includes("pdf")??!1},output:{text:Z.modalities?.output?.includes("text")??!1,audio:Z.modalities?.output?.includes("audio")??!1,image:Z.modalities?.output?.includes("image")??!1,video:Z.modalities?.output?.includes("video")??!1,pdf:Z.modalities?.output?.includes("pdf")??!1},interleaved:Z.interleaved??!1},release_date:Z.release_date??"",variants:{}};return{...J,variants:v6(G5(J),(Y)=>Y)}}function wK($){let Z={};for(let[J,Y]of Object.entries($.models)){Z[J]=Ql($,Y);for(let[X,Q]of Object.entries(Y.experimental?.modes??{})){let G=`${Y.id}-${X}`,W=Ql($,Y);Z[G]={...W,id:s1.make(G),name:`${Y.name} ${X[0].toUpperCase()}${X.slice(1)}`,cost:Q.cost?N1(W.cost,Ul(Q.cost)):W.cost,options:Q.provider?.body?Object.fromEntries(Object.entries(Q.provider.body).map(([K,V])=>[K.replace(/_([a-z])/g,(U,H)=>H.toUpperCase()),V])):W.options,headers:Q.provider?.headers??W.headers}}}return{id:X1.make($.id),source:"custom",name:$.name,env:$.env??[],options:{},models:Z}}function Hl($){return v6($,(Z)=>G9(Object.values(Z.models))[0].id)}var ej0=["gpt-5.5","gpt-5","claude-sonnet-4","gemini-3-pro"];function G9($){return Gl($,[(Z)=>ej0.findIndex((J)=>Z.id.includes(J)),"desc"],[(Z)=>Z.id.includes("latest")?0:1,"asc"],[(Z)=>Z.id,"desc"])}function W5($){let[Z,...J]=$.split("/");return{providerID:X1.make(Z),modelID:s1.make(J.join("/"))}}var KY=j1.create("ProviderModelNotFoundError",P.object({providerID:X1.zod,modelID:s1.zod,suggestions:P.array(P.string()).optional()})),LK=j1.create("ProviderModelGroupNotFoundError",P.object({group:P.string(),suggestions:P.array(P.string()).optional()})),TK=j1.create("ProviderInitError",P.object({providerID:X1.zod}));function Bl($){let{getState:Z,config:J,readRecent:Y}=$,X=T.fn("Provider.getProvider")((U)=>Z().pipe(T.map((H)=>H.providers[U]))),Q=T.fn("Provider.getModel")(function*(U,H){let B=yield*Z(),z=B.providers[U];if(!z){let A=Object.keys(B.providers),j=RK.default.go(U,A,{limit:3,threshold:-1e4});throw new KY({providerID:U,modelID:H,suggestions:j.map((N)=>N.target)})}let F=z.models[H];if(!F){let A=Object.keys(z.models),j=RK.default.go(H,A,{limit:3,threshold:-1e4});throw new KY({providerID:U,modelID:H,suggestions:j.map((N)=>N.target)})}return F}),G=T.fn("Provider.closest")(function*(U,H){let z=(yield*Z()).providers[U];if(!z)return;for(let F of H)for(let A of Object.keys(z.models))if(A.includes(F))return{providerID:U,modelID:A};return}),W=T.fn("Provider.resolveModelRef")(function*(U,H){if(U.includes("/")){let N=W5(U);return yield*Q(N.providerID,N.modelID)}let B=yield*J.get(),z=B.model_groups?.[U];if(!z){if(DK.has(U)){let q=N7[U];if(q){let C=yield*Q(X1.make(q.providerID),s1.make(q.modelID)).pipe(T.exit);if(C._tag==="Success")return C.value}let M=yield*V();return yield*Q(M.providerID,M.modelID)}let N=Object.keys(B.model_groups??{}),L=RK.default.go(U,N,{limit:3,threshold:-1e4});throw new LK({group:U,suggestions:L.map((q)=>q.target)})}let F=typeof z==="string"?z:z.default,A=typeof z==="string"?[z]:z.models??[z.default];if(H)for(let N of A){let L=W5(N);if(L.providerID!==H)continue;let q=yield*Q(L.providerID,L.modelID).pipe(T.exit);if(q._tag==="Success")return q.value}let j=W5(F);return yield*Q(j.providerID,j.modelID)}),K=T.fn("Provider.getSmallModel")(function*(U){let H=yield*J.get();if(H.small_model){let B=W5(H.small_model);return yield*Q(B.providerID,B.modelID)}for(let B of["lite","free","economical"]){if(H.model_groups?.[B])return yield*W(B,U);let F=N7[B];if(F){let A=yield*Q(X1.make(F.providerID),s1.make(F.modelID)).pipe(T.exit);if(A._tag==="Success")return A.value}}return yield*W("economical",U)}),V=T.fn("Provider.defaultModel")(function*(){let U=yield*J.get();if(U.model)return W5(U.model);let H=yield*Z(),B=yield*Y().pipe(T.map((A)=>{if(!J8(A)||!Array.isArray(A.recent))return[];return A.recent.flatMap((j)=>{if(!J8(j))return[];if(typeof j.providerID!=="string")return[];if(typeof j.modelID!=="string")return[];return[{providerID:X1.make(j.providerID),modelID:s1.make(j.modelID)}]})}),T.catch(()=>T.succeed([])));for(let A of B){let j=H.providers[A.providerID];if(!j)continue;if(!j.models[A.modelID])continue;return{providerID:A.providerID,modelID:A.modelID}}for(let A of["adaptive","fast","economical","max-int"]){let j=N7[A];if(!j)continue;let N=H.providers[X1.make(j.providerID)];if(N?.models[s1.make(j.modelID)])return{providerID:N.id,modelID:s1.make(j.modelID)}}let z=Object.values(H.providers).find((A)=>!U.provider||Object.keys(U.provider).includes(A.id));if(!z)throw Error("no providers found");let[F]=G9(Object.values(z.models));if(!F)throw Error("no models found");return{providerID:z.id,modelID:F.id}});return{getProvider:X,getModel:Q,closest:G,resolveModelRef:W,getSmallModel:K,defaultModel:V}}var PK=480000;function zl($,Z,J){if(typeof Z!=="number"||Z<=0)return $;if(!$.body)return $;if(!$.headers.get("content-type")?.includes("text/event-stream"))return $;let Y=$.body.getReader(),X=new ReadableStream({async pull(Q){let G=await new Promise((W,K)=>{let V=setTimeout(()=>{let U=Error("SSE read timed out");J.abort(U),Y.cancel(U),K(U)},Z);Y.read().then((U)=>{clearTimeout(V),W(U)},(U)=>{clearTimeout(V),K(U)})});if(G.done){Q.close();return}Q.enqueue(G.value)},async cancel(Q){J.abort(Q),await Y.cancel(Q)}});return new Response(X,{headers:new Headers($.headers),status:$.status,statusText:$.statusText})}import OZ from"os";var VY=E0.create({service:"provider/loaders"}),IK=new Map,jl={"@qitqode/qlex-provider":()=>import("./chunk-705qkpra.js").then(($)=>$.createQlexProvider),"@ai-sdk/amazon-bedrock":()=>import("./chunk-h1bvqstw.js").then(($)=>$.createAmazonBedrock),"@ai-sdk/anthropic":()=>import("./chunk-5bv63rqj.js").then(($)=>$.createAnthropic),"@ai-sdk/azure":()=>import("./chunk-fh3d0wce.js").then(($)=>$.createAzure),"@ai-sdk/google":()=>import("./chunk-rva2ekrt.js").then(($)=>$.createGoogleGenerativeAI),"@ai-sdk/google-vertex":()=>import("./chunk-d30k7dpf.js").then(($)=>$.createVertex),"@ai-sdk/google-vertex/anthropic":()=>import("./chunk-b7sr9rn3.js").then(($)=>$.createVertexAnthropic),"@ai-sdk/openai":()=>import("./chunk-8ysp6vf8.js").then(($)=>$.createOpenAI),"@ai-sdk/openai-compatible":()=>import("./chunk-zj1jc1xt.js").then(($)=>$.createOpenAICompatible),"@openrouter/ai-sdk-provider":()=>import("./chunk-m7tmgvh6.js").then(($)=>$.createOpenRouter),"@ai-sdk/xai":()=>import("./chunk-phf37x1c.js").then(($)=>$.createXai),"@ai-sdk/mistral":()=>import("./chunk-8yzghzjq.js").then(($)=>$.createMistral),"@ai-sdk/groq":()=>import("./chunk-qk5vy2pr.js").then(($)=>$.createGroq),"@ai-sdk/deepinfra":()=>import("./chunk-ag8wxwwz.js").then(($)=>$.createDeepInfra),"@ai-sdk/cerebras":()=>import("./chunk-fej5x648.js").then(($)=>$.createCerebras),"@ai-sdk/cohere":()=>import("./chunk-sy9w1t2y.js").then(($)=>$.createCohere),"@ai-sdk/gateway":()=>import("./chunk-5qkvhr6y.js").then(($)=>$.createGateway),"@ai-sdk/togetherai":()=>import("./chunk-qk1jkc0n.js").then(($)=>$.createTogetherAI),"@ai-sdk/perplexity":()=>import("./chunk-56wq8cqj.js").then(($)=>$.createPerplexity),"@ai-sdk/vercel":()=>import("./chunk-zsg29gba.js").then(($)=>$.createVercel),"@ai-sdk/alibaba":()=>import("./chunk-2caaqmec.js").then(($)=>$.createAlibaba),"gitlab-ai-provider":()=>import("./chunk-qgek59e6.js").then(($)=>$.createGitLab),"@ai-sdk/github-copilot":()=>import("./chunk-e2wfj86b.js").then(($)=>$.createOpenaiCompatible),"venice-ai-sdk-provider":()=>import("./chunk-3z2zn8rj.js").then(($)=>$.createVenice)};function Nl($){return $.responses===void 0&&$.chat===void 0}function $N0($){let Z=/^gpt-(\d+)/.exec($);if(!Z)return!1;return Number(Z[1])>=5&&!$.startsWith("gpt-5-mini")}async function Fl($,Z,J){if(Nl($))return $.languageModel(Z);if(J?.useCompletionUrls)return $.chat(Z);else return $.responses(Z)}function Al($,Z){return $.CLOUDFLARE_ACCOUNT_ID||(Z?.type==="api"?Z.metadata?.accountId:void 0)}function Ml($){return{qlex:T.fnUntraced(function*(){return{autoload:!0,options:{getToken:Ol,onInvalidCredentials:async()=>{if(process.env.QITQODE_KEY)VY.error(SA),console.error(SA);try{await ql()}catch{}}},async getModel(Y,X){return Y.languageModel(X)}}}),anthropic:()=>T.succeed({autoload:!1,options:{headers:{"anthropic-beta":"interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14"}}}),opencode:T.fnUntraced(function*(Z){let J=yield*$.env(),X=l$(()=>{if(Z.env.some((Q)=>J[Q]))return!0;return!1})||Boolean(yield*$.auth(Z.id))||Boolean((yield*$.config()).provider?.opencode?.options?.apiKey);for(let[Q,G]of Object.entries(Z.models))if(!X||G.cost.input===0)delete Z.models[Q];return{autoload:Object.keys(Z.models).length>0,options:{}}}),openai:()=>T.succeed({autoload:!1,async getModel(Z,J,Y){return Z.responses(J)},options:{}}),xai:()=>T.succeed({autoload:!1,async getModel(Z,J,Y){return Z.responses(J)},options:{}}),"github-copilot":()=>T.succeed({autoload:!1,async getModel(Z,J,Y){if(Nl(Z))return Z.languageModel(J);return $N0(J)?Z.responses(J):Z.chat(J)},options:{}}),azure:T.fnUntraced(function*(Z){let J=yield*$.env(),Y=l$(()=>{let X=Z.options?.resourceName;if(typeof X==="string"&&X.trim()!=="")return X;return J.AZURE_RESOURCE_NAME});return{autoload:!1,getModel:Fl,options:{},vars(X){return{...Y&&{AZURE_RESOURCE_NAME:Y}}}}}),"azure-cognitive-services":T.fnUntraced(function*(){let Z=yield*$.get("AZURE_COGNITIVE_SERVICES_RESOURCE_NAME");return{autoload:!1,getModel:Fl,options:{baseURL:Z?`https://${Z}.cognitiveservices.azure.com/openai`:void 0}}}),"amazon-bedrock":T.fnUntraced(function*(){let Z=(yield*$.config()).provider?.["amazon-bedrock"],J=yield*$.auth("amazon-bedrock"),Y=yield*$.env(),X=Z?.options?.region,Q=Y.AWS_REGION,G=X??Q??"us-east-1",W=Z?.options?.profile,K=Y.AWS_PROFILE,V=W??K,U=Y.AWS_ACCESS_KEY_ID,H=l$(()=>{let N=IK.get("AWS_BEARER_TOKEN_BEDROCK");if(N)return N;if(J?.type==="api")return IK.set("AWS_BEARER_TOKEN_BEDROCK",J.key),process.env.AWS_BEARER_TOKEN_BEDROCK=J.key,J.key;return}),B=Y.AWS_WEB_IDENTITY_TOKEN_FILE,z=Boolean(process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI||process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI);if(!V&&!U&&!H&&!B&&!z)return{autoload:!1};let{fromNodeProviderChain:F}=yield*T.promise(()=>import("./chunk-ftvvm4r5.js")),A={region:G};if(!H){let N=V?{profile:V}:{};A.credentialProvider=F(N)}let j=Z?.options?.endpoint??Z?.options?.baseURL;if(j)A.baseURL=j;return{autoload:!0,options:A,async getModel(N,L,q){if(["global.","us.","eu.","jp.","apac.","au."].some((w)=>L.startsWith(w)))return N.languageModel(L);let C=q?.region??G,R=C.split("-")[0];switch(R){case"us":{let w=["nova-micro","nova-lite","nova-pro","nova-premier","nova-2","claude","deepseek"].some((_)=>L.includes(_)),I=C.startsWith("us-gov");if(w&&!I)L=`${R}.${L}`;break}case"eu":{let w=["eu-west-1","eu-west-2","eu-west-3","eu-north-1","eu-central-1","eu-south-1","eu-south-2"].some((_)=>C.includes(_)),I=["claude","nova-lite","nova-micro","llama3","pixtral"].some((_)=>L.includes(_));if(w&&I)L=`${R}.${L}`;break}case"ap":{let w=["ap-southeast-2","ap-southeast-4"].includes(C),I=C==="ap-northeast-1";if(w&&["anthropic.claude-sonnet-4-5","anthropic.claude-haiku"].some((_)=>L.includes(_)))R="au",L=`${R}.${L}`;else if(I){if(["claude","nova-lite","nova-micro","nova-pro"].some((E)=>L.includes(E)))R="jp",L=`${R}.${L}`}else if(["claude","nova-lite","nova-micro","nova-pro"].some((E)=>L.includes(E)))R="apac",L=`${R}.${L}`;break}}return N.languageModel(L)}}}),llmgateway:()=>T.succeed({autoload:!1,options:{headers:{"X-Source":"qitqode"}}}),openrouter:()=>T.succeed({autoload:!1,options:{headers:{"X-OpenRouter-Categories":"programming,programming-app,cli-agent"}}}),nvidia:()=>T.succeed({autoload:!1,options:{}}),vercel:()=>T.succeed({autoload:!1,options:{}}),"google-vertex":T.fnUntraced(function*(Z){let J=yield*$.env(),Y=Z.options?.project??J.GOOGLE_CLOUD_PROJECT??J.GCP_PROJECT??J.GCLOUD_PROJECT,X=String(Z.options?.location??J.GOOGLE_VERTEX_LOCATION??J.GOOGLE_CLOUD_LOCATION??J.VERTEX_LOCATION??"us-central1");if(!Boolean(Y))return{autoload:!1};return{autoload:!0,vars(G){let W=X==="global"?"aiplatform.googleapis.com":`${X}-aiplatform.googleapis.com`;return{...Y&&{GOOGLE_VERTEX_PROJECT:Y},GOOGLE_VERTEX_LOCATION:X,GOOGLE_VERTEX_ENDPOINT:W}},options:{project:Y,location:X,fetch:async(G,W)=>{let{GoogleAuth:K}=await import("./chunk-452tk6v3.js").then((m)=>m6(m.default,1)),H=await(await new K().getApplicationDefault()).credential.getAccessToken(),B=new Headers(W?.headers);return B.set("Authorization",`Bearer ${H.token}`),fetch(G,{...W,headers:B})}},async getModel(G,W){let K=String(W).trim();return G.languageModel(K)}}}),"google-vertex-anthropic":T.fnUntraced(function*(){let Z=yield*$.env(),J=Z.GOOGLE_CLOUD_PROJECT??Z.GCP_PROJECT??Z.GCLOUD_PROJECT,Y=Z.GOOGLE_CLOUD_LOCATION??Z.VERTEX_LOCATION??"global";if(!Boolean(J))return{autoload:!1};return{autoload:!0,options:{project:J,location:Y},async getModel(Q,G){let W=String(G).trim();return Q.languageModel(W)}}}),"sap-ai-core":T.fnUntraced(function*(){let Z=yield*$.auth("sap-ai-core"),J=l$(()=>{let Q=IK.get("AICORE_SERVICE_KEY");if(Q)return Q;if(Z?.type==="api")return IK.set("AICORE_SERVICE_KEY",Z.key),process.env.AICORE_SERVICE_KEY=Z.key,Z.key;return}),Y=process.env.AICORE_DEPLOYMENT_ID,X=process.env.AICORE_RESOURCE_GROUP;return{autoload:!!J,options:J?{deploymentId:Y,resourceGroup:X}:{},async getModel(Q,G){return Q(G)}}}),zenmux:()=>T.succeed({autoload:!1,options:{}}),gitlab:T.fnUntraced(function*(Z){let{VERSION:J,isWorkflowModel:Y,discoverWorkflowModels:X}=yield*T.promise(()=>import("./chunk-qgek59e6.js")),Q=(yield*$.get("GITLAB_INSTANCE_URL"))||"https://gitlab.com",G=yield*$.auth(Z.id),W=yield*T.sync(()=>{if(G?.type==="oauth")return G.access;if(G?.type==="api")return G.key;return}),K=W??(yield*$.get("GITLAB_TOKEN")),V=(yield*$.config()).provider?.gitlab,U=yield*B0.directory,H={"User-Agent":`qitqode/${E$} gitlab-ai-provider/${J} (${OZ.platform()} ${OZ.release()}; ${OZ.arch()})`,"anthropic-beta":"context-1m-2025-08-07",...V?.options?.aiGatewayHeaders},B={duo_agent_platform_agentic_chat:!0,duo_agent_platform:!0,...V?.options?.featureFlags};return{autoload:!!K,options:{instanceUrl:Q,apiKey:K,aiGatewayHeaders:H,featureFlags:B},async getModel(z,F,A){if(F.startsWith("duo-workflow-")){let j=typeof A?.workflowRef==="string"?A.workflowRef:void 0,N=Y(F)?F:"duo-workflow",L=typeof A?.workflowDefinition==="string"?A.workflowDefinition:void 0,q=z.workflowChat(N,{featureFlags:B,workflowDefinition:L});if(j)q.selectedModelRef=j;return q}return z.agenticChat(F,{aiGatewayHeaders:H,featureFlags:B})},async discoverModels(){if(!W)return VY.info("gitlab model discovery skipped: no apiKey"),{};try{let z=W,F=()=>G?.type==="api"?{"PRIVATE-TOKEN":z}:{Authorization:`Bearer ${z}`};VY.info("gitlab model discovery starting",{instanceUrl:Q});let A=await X({instanceUrl:Q,getHeaders:F},{workingDirectory:U});if(!A.models.length)return VY.info("gitlab model discovery skipped: no models found",{project:A.project?{id:A.project.id,path:A.project.pathWithNamespace}:null}),{};let j={};for(let N of A.models)if(!Z.models[N.id])j[N.id]={id:s1.make(N.id),providerID:X1.make("gitlab"),name:`Agent Platform (${N.name})`,family:"",api:{id:N.id,url:Q,npm:"gitlab-ai-provider"},status:"active",headers:{},options:{workflowRef:N.ref},cost:{input:0,output:0,cache:{read:0,write:0}},limit:{context:N.context,output:N.output},capabilities:{temperature:!1,reasoning:!0,attachment:!0,toolcall:!0,input:{text:!0,audio:!1,image:!0,video:!1,pdf:!0},output:{text:!0,audio:!1,image:!1,video:!1,pdf:!1},interleaved:!1},release_date:"",variants:{}};return VY.info("gitlab model discovery complete",{count:Object.keys(j).length,models:Object.keys(j)}),j}catch(z){return VY.warn("gitlab model discovery failed",{error:z}),{}}}}}),"cloudflare-workers-ai":T.fnUntraced(function*(Z){if(Z.options?.baseURL)return{autoload:!1};let J=yield*$.auth(Z.id),Y=yield*$.env(),X=Al(Y,J);if(!X)return{autoload:!1,async getModel(){throw Error("CLOUDFLARE_ACCOUNT_ID is missing. Set it with: export CLOUDFLARE_ACCOUNT_ID=<your-account-id>")}};let Q=yield*T.gen(function*(){let G=Y.CLOUDFLARE_API_KEY;if(G)return G;if(J?.type==="api")return J.key;return});return{autoload:!!Q,options:{apiKey:Q,headers:{"User-Agent":`qitqode/${E$} cloudflare-workers-ai (${OZ.platform()} ${OZ.release()}; ${OZ.arch()})`}},async getModel(G,W){return G.languageModel(W)},vars(G){return{CLOUDFLARE_ACCOUNT_ID:X}}}}),"cloudflare-ai-gateway":T.fnUntraced(function*(Z){if(Z.options?.baseURL)return{autoload:!1};let J=yield*$.auth(Z.id),Y=yield*$.env(),X=Al(Y,J),Q=Y.CLOUDFLARE_GATEWAY_ID||(J?.type==="api"?J.metadata?.gatewayId:void 0);if(!X||!Q){let z=[!X?"CLOUDFLARE_ACCOUNT_ID":void 0,!Q?"CLOUDFLARE_GATEWAY_ID":void 0].filter((F)=>Boolean(F));return{autoload:!1,async getModel(){throw Error(`${z.join(" and ")} missing. Set with: ${z.map((F)=>`export ${F}=<value>`).join(" && ")}`)}}}let G=yield*T.gen(function*(){let z=Y.CLOUDFLARE_API_TOKEN||Y.CF_AIG_TOKEN;if(z)return z;if(J?.type==="api")return J.key;return});if(!G)throw Error("CLOUDFLARE_API_TOKEN (or CF_AIG_TOKEN) is required for Cloudflare AI Gateway. Set it via environment variable or run `qitqode auth cloudflare-ai-gateway`.");let{createAiGateway:W}=yield*T.promise(()=>import("./chunk-wr6rnxr5.js")),{createUnified:K}=yield*T.promise(()=>import("./chunk-2pkfphgb.js")),U={metadata:l$(()=>{if(Z.options?.metadata)return Z.options.metadata;try{return JSON.parse(Z.options?.headers?.["cf-aig-metadata"])}catch{return}}),cacheTtl:Z.options?.cacheTtl,cacheKey:Z.options?.cacheKey,skipCache:Z.options?.skipCache,collectLog:Z.options?.collectLog,headers:{"User-Agent":`qitqode/${E$} cloudflare-ai-gateway (${OZ.platform()} ${OZ.release()}; ${OZ.arch()})`}},H=W({accountId:X,gateway:Q,apiKey:G,...Object.values(U).some((z)=>z!==void 0)?{options:U}:{}}),B=K();return{autoload:!0,async getModel(z,F,A){return H(B(F))},options:{}}}),cerebras:()=>T.succeed({autoload:!1,options:{headers:{"X-Cerebras-3rd-Party-Integration":"qitqode"}}}),kilo:()=>T.succeed({autoload:!1,options:{}})}}import{pathToFileURL as ZN0}from"url";var fA=E0.create({service:"provider.sdk-runtime"});async function Dl($,Z,J){try{let Y=[];try{const W=CK(Y,fA.time("getSDK",{providerID:$.providerID}),0);let K=Z.providers[$.providerID];let V={...K.options};if($.providerID==="google-vertex"&&!$.api.npm.includes("@ai-sdk/openai-compatible"))delete V.fetch;if($.api.npm.includes("@ai-sdk/openai-compatible")&&V.includeUsage!==!1)V.includeUsage=!0;let U=l$(()=>{let R=typeof V.baseURL==="string"&&V.baseURL!==""?V.baseURL:$.api.url;if(!R)return;let w=Z.varsLoaders[$.providerID];if(w){let I=w(V);for(let[_,E]of Object.entries(I)){let f="${"+_+"}";R=R.replaceAll(f,E)}}return R});if(U!==void 0)V.baseURL=U;if(V.apiKey===void 0&&typeof K.key==="string")V.apiKey=K.key;if($.headers)V.headers={...V.headers,...$.headers};let H=V.fetch;delete V.fetch;let B=V4.fast(JSON.stringify({providerID:$.providerID,npm:$.api.npm,options:V}));let z=Z.sdk.get(B);if(z)return z;let F=V.chunkTimeout;let A=typeof F==="number"?F:PK;delete V.chunkTimeout;V.fetch=async(R,w)=>{let I=H??fetch,_=w??{},E=typeof A==="number"&&A>0?new AbortController:void 0,f=[];if(_.signal)f.push(_.signal);if(E)f.push(E.signal);if(V.timeout!==void 0&&V.timeout!==null&&V.timeout!==!1)f.push(AbortSignal.timeout(V.timeout));let b=f.length===0?null:f.length===1?f[0]:AbortSignal.any(f);if(b)_.signal=b;if($.api.npm==="@ai-sdk/openai"&&_.body&&_.method==="POST"){let k=JSON.parse(_.body);if(!($.providerID.includes("azure")&&k.store===!0)&&Array.isArray(k.input)){for(let p of k.input)if("id"in p)delete p.id;_.body=JSON.stringify(k)}}let y=await I(R,{..._,timeout:!1});if(!E)return y;return zl(y,A,E)};let j=jl[$.api.npm];if(j){fA.info("using bundled provider",{providerID:$.providerID,pkg:$.api.npm});let w=(await j())({name:$.providerID,...V});return Z.sdk.set(B,w),w}let N;if(!$.api.npm.startsWith("file://")){let R=await q6.add($.api.npm);if(!R.entrypoint)throw Error(`Package ${$.api.npm} has no import entrypoint`);N=R.entrypoint}else fA.info("loading local provider",{pkg:$.api.npm}),N=$.api.npm;let L=N.startsWith("file://")?N:ZN0(N).href;let q=await import(L);let M=q[Object.keys(q).find((R)=>R.startsWith("create"))];let C=M({name:$.providerID,...V});Z.sdk.set(B,C);return C}catch(X){var Q=X,G=1}finally{EK(Y,Q,G)}}catch(W){throw new TK({providerID:$.providerID},{cause:W})}}function wl($){let Z={};function J(Y,X){let Q=Z[Y];if(Q){Z[Y]=N1(Q,X);return}let G=$[Y];if(!G)return;Z[Y]=N1(G,X)}return{database:$,providers:Z,mergeProvider:J}}function Ll($){if($.enabled&&!$.enabled.has($.providerID))return!1;if($.disabled.has($.providerID))return!1;return!0}function Tl($,Z){let J=$.env.map((Y)=>Z[Y]).find(Boolean);if(!J)return;return{source:"env",key:$.env.length===1?J:void 0}}function Rl($){if($.type!=="api")return;return{source:"api",key:$.key}}function kA($){return $.hasProvider?{options:$.options??{}}:{source:"custom",options:$.options??{}}}var JN0=E0.create({service:"provider.discovery.filter"});function Pl($){for(let[Z,J]of Object.entries($.providers)){let Y=X1.make(Z);if(!$.isAllowed(Y)){delete $.providers[Y];continue}let X=$.overrides[Y];for(let[Q,G]of Object.entries(J.models)){if(G.api.id=G.api.id??G.id??Q,Q==="gpt-5-chat-latest"||Y===X1.openrouter&&Q==="openai/gpt-5-chat")delete J.models[Q];if(G.status==="alpha"&&!$.experimentalModels)delete J.models[Q];if(G.status==="deprecated")delete J.models[Q];if(X?.blacklist&&X.blacklist.includes(Q)||X?.whitelist&&!X.whitelist.includes(Q))delete J.models[Q];G.variants=v6(G5(G),(K)=>K);let W=X?.models?.[Q]?.variants;if(W&&G.variants){let K=N1(G.variants,W);G.variants=v6(bK(K,(V)=>!V.disabled),(V)=>_K(V,["disabled"]))}}if(Object.keys(J.models).length===0){delete $.providers[Y];continue}JN0.info("found",{providerID:Y})}return $.providers}var YN0=E0.create({service:"provider.discovery.config"});function Il($){for(let[Z,J]of $.configProviders){let Y=$.database[Z],X={id:X1.make(Z),name:J.name??Y?.name??Z,env:J.env??Y?.env??[],options:N1(Y?.options??{},J.options??{}),source:"config",models:Y?.models??{}};for(let[Q,G]of Object.entries(J.models??{})){let W=X.models[G.id??Q],K=G.id??W?.api.id??Q,V=G.provider?.npm??J.npm??W?.api.npm??$.modelsDev[Z]?.npm??"@ai-sdk/openai-compatible",U=l$(()=>{if(G.name)return G.name;if(G.id&&G.id!==Q)return Q;return W?.name??Q}),H={id:s1.make(Q),api:{id:K,npm:V,url:G.provider?.api??J?.api??W?.api.url??$.modelsDev[Z]?.api??""},status:G.status??W?.status??"active",name:U,providerID:X1.make(Z),capabilities:{temperature:G.temperature??W?.capabilities.temperature??!1,reasoning:G.reasoning??W?.capabilities.reasoning??!1,attachment:G.attachment??W?.capabilities.attachment??!1,toolcall:G.tool_call??W?.capabilities.toolcall??!0,input:{text:G.modalities?.input?.includes("text")??W?.capabilities.input.text??!0,audio:G.modalities?.input?.includes("audio")??W?.capabilities.input.audio??!1,image:G.modalities?.input?.includes("image")??W?.capabilities.input.image??!1,video:G.modalities?.input?.includes("video")??W?.capabilities.input.video??!1,pdf:G.modalities?.input?.includes("pdf")??W?.capabilities.input.pdf??!1},output:{text:G.modalities?.output?.includes("text")??W?.capabilities.output.text??!0,audio:G.modalities?.output?.includes("audio")??W?.capabilities.output.audio??!1,image:G.modalities?.output?.includes("image")??W?.capabilities.output.image??!1,video:G.modalities?.output?.includes("video")??W?.capabilities.output.video??!1,pdf:G.modalities?.output?.includes("pdf")??W?.capabilities.output.pdf??!1},interleaved:G.interleaved??W?.capabilities.interleaved??(!W&&V==="@ai-sdk/openai-compatible"&&K.includes("deepseek")?{field:"reasoning_content"}:!1)},cost:{input:G?.cost?.input??W?.cost?.input??0,output:G?.cost?.output??W?.cost?.output??0,cache:{read:G?.cost?.cache_read??W?.cost?.cache.read??0,write:G?.cost?.cache_write??W?.cost?.cache.write??0}},options:N1(W?.options??{},G.options??{}),limit:{context:(()=>{let z=G.limit?.context??W?.limit?.context;if(z!==void 0)return z;let F=`${Z}/${Q}`;if(!_A.has(F))_A.add(F),YN0.warn("limit.context not configured and not found in models.dev",{providerID:Z,modelID:Q,defaulting_to:bA,fix:`Set limit.context explicitly in qitqode.json under provider.${Z}.models.${Q}`});return bA})(),input:G.limit?.input??W?.limit?.input,output:G.limit?.output??W?.limit?.output??0},headers:N1(W?.headers??{},G.headers??{}),family:G.family??W?.family??"",release_date:G.release_date??W?.release_date??"",cachePromptTTL:G.cachePromptTTL??W?.cachePromptTTL,variants:{}},B=N1(G5(H),G.variants??{});H.variants=v6(bK(B,(z)=>!z.disabled),(z)=>_K(z,["disabled"])),X.models[Q]=H}$.database[Z]=X}}var SK=E0.create({service:"provider.discovery"});function El($){let{config:Z,auth:J,env:Y,plugin:X}=$;return T.gen(function*(){let E=[];try{const Q=CK(E,SK.time("state"),0);let G=yield*T7.make();let W=yield*Z.get();let K=yield*T.promise(()=>Cl());let V=v6(K,wK);V[Q9.id]=Q9;let U=wl(V);let{providers:H,mergeProvider:B}=U;let z=new Map;let F={};let A={};let j=new Map;let N={};let L={auth:(k)=>J.get(k).pipe(T.orDie),config:()=>Z.get(),env:()=>Y.all(),get:(k)=>Y.get(k)};SK.info("init");let q=yield*X.list();let M=Object.entries(W.provider??{});let C=new Set(W.disabled_providers??[]);let R=W.enabled_providers?new Set(W.enabled_providers):null;let w=(k)=>Ll({providerID:k,enabled:R,disabled:C});Il({database:V,modelsDev:K,configProviders:M});if(!b0.QITQODE_DISABLE_PROVIDER_ENV){let k=yield*Y.all();for(let[g,d]of Object.entries(V)){let p=X1.make(g);if(C.has(p))continue;let t=Tl(d,k);if(t)B(p,t)}}let I=yield*J.all().pipe(T.orDie);for(let[k,g]of Object.entries(I)){let d=X1.make(k);if(C.has(d))continue;let p=Rl(g);if(p)B(d,p)}for(let k of q){if(!k.auth)continue;let g=X1.make(k.auth.provider);if(C.has(g))continue;if(!(yield*J.get(g).pipe(T.orDie)))continue;if(!k.auth.loader)continue;let t=(yield*T.promise(()=>k.auth.loader(()=>G.promise(J.get(g).pipe(T.orDie)),V[k.auth.provider])))??{};B(g,kA({options:t,hasProvider:Boolean(H[g])}))}for(let[k,g]of Object.entries(Ml(L))){let d=X1.make(k);if(C.has(d))continue;let p=V[d];if(!p){SK.error("Provider does not exist in model list "+d);continue}let t=yield*g(p);if(t&&(t.autoload||H[d])){if(t.getModel)F[d]=t.getModel;if(t.vars)A[d]=t.vars;if(t.discoverModels)N[d]=t.discoverModels;let r=t.options??{};B(d,kA({options:r,hasProvider:Boolean(H[d])}))}}for(let[k,g]of M){let d=X1.make(k),p={source:"config"};if(g.env)p.env=g.env;if(g.name)p.name=g.name;if(g.options)p.options=g.options;B(d,p)}let _=X1.make("gitlab");if(N[_]&&H[_]&&w(_))yield*T.promise(async()=>{try{let k=await N[_]();for(let[g,d]of Object.entries(k))if(!H[_].models[g])H[_].models[g]=d}catch(k){SK.warn("state discovery error",{id:"gitlab",error:k})}});for(let k of q){let g=k.provider,d=g?.models;if(!g||!d)continue;let p=X1.make(g.id);if(C.has(p))continue;let t=H[p];if(!t)continue;let r=yield*J.get(p).pipe(T.orDie);t.models=yield*T.promise(async()=>{let G0=await d(t,{auth:r});return Object.fromEntries(Object.entries(G0).map(([O0,h0])=>[O0,{...h0,id:s1.make(O0),providerID:p}]))})}Pl({providers:H,overrides:W.provider??{},isAllowed:w,experimentalModels:b0.QITQODE_ENABLE_EXPERIMENTAL_MODELS});return{models:z,providers:H,sdk:j,modelLoaders:F,varsLoaders:A}}catch(f){var b=f,y=1}finally{EK(E,b,y)}})}var QN0=O.Struct({id:O.String,url:O.String,npm:O.String}),bl=O.Struct({text:O.Boolean,audio:O.Boolean,image:O.Boolean,video:O.Boolean,pdf:O.Boolean}),GN0=O.Union([O.Boolean,O.Struct({field:O.Literals(["reasoning_content","reasoning_details"])})]),WN0=O.Struct({temperature:O.Boolean,reasoning:O.Boolean,attachment:O.Boolean,toolcall:O.Boolean,input:bl,output:bl,interleaved:GN0}),_l=O.Struct({read:O.Number,write:O.Number}),KN0=O.Struct({input:O.Number,output:O.Number,cache:_l,experimentalOver200K:O.optional(O.Struct({input:O.Number,output:O.Number,cache:_l}))}),VN0=O.Struct({context:O.Number,input:O.optional(O.Number),output:O.Number}),vA=O.Struct({id:s1,providerID:X1,api:QN0,name:O.String,family:O.optional(O.String),capabilities:WN0,cost:KN0,limit:VN0,status:O.Literals(["alpha","beta","deprecated","active"]),options:O.Record(O.String,O.Any),headers:O.Record(O.String,O.String),release_date:O.String,variants:O.optional(O.Record(O.String,O.Record(O.String,O.Any))),cacheTTL:O.optional(O.Number),cachePromptTTL:O.optional(O.Literals(["5m","1h"]))}).annotate({identifier:"Model"}).pipe(u0(($)=>({zod:w0($)}))),fK=O.Struct({id:X1,name:O.String,source:O.Literals(["env","config","custom","api"]),env:O.Array(O.String),key:O.optional(O.String),options:O.Record(O.String,O.Any),models:O.Record(O.String,vA)}).annotate({identifier:"Provider"}).pipe(u0(($)=>({zod:w0($)}))),Sl=O.Record(O.String,O.String),fl=O.Struct({all:O.Array(fK),default:Sl,connected:O.Array(O.String)}).pipe(u0(($)=>({zod:w0($)}))),kl=O.Struct({providers:O.Array(fK),default:Sl}).pipe(u0(($)=>({zod:w0($)})));async function xl($=yl){return F8.loadLiveRatings($)}function hl($){F8.mergeLiveTierRatings($)}class kK extends S1.Service()("@qitqode/Provider"){}var HN0=T0.effect(kK,T.gen(function*(){let $=yield*D$.Service,Z=yield*X8.Service,J=yield*k8.Service,Y=yield*l6.Service,X=yield*AZ.Service;F8.beginTierRatingsLoad();let[Q,G]=yield*T.promise(()=>Promise.all([vl(),xl()]));F8.mergeLiveTiers(Q),hl(G),Vl();let W=yield*B0.make(()=>El({config:Z,auth:J,env:Y,plugin:X})),K=T.fn("Provider.list")(()=>B0.use(W,(N)=>N.providers)),V=Bl({getState:()=>B0.get(W),config:Z,readRecent:()=>$.readJson(UN0.join(F0.Path.state,"model.json"))}),{getProvider:U,getModel:H,closest:B,getSmallModel:z,defaultModel:F,resolveModelRef:A}=V,j=T.fn("Provider.getLanguage")(function*(N){let L=yield*B0.get(W),q=yield*Y.all(),M=`${N.providerID}/${N.id}`;if(L.models.has(M))return L.models.get(M);return yield*T.promise(async()=>{let C=L.providers[N.providerID],R=await Dl(N,L,q);try{let w=L.modelLoaders[N.providerID]?await L.modelLoaders[N.providerID](R,N.api.id,{...C.options,...N.options}):R.languageModel(N.api.id);return L.models.set(M,w),w}catch(w){if(w instanceof XH)throw new KY({modelID:N.id,providerID:N.providerID},{cause:w});throw w}})});return kK.of({list:K,getProvider:U,getModel:H,getLanguage:j,closest:B,getSmallModel:z,defaultModel:F,resolveModelRef:A})})),BN0=T0.suspend(()=>HN0.pipe(T0.provide(D$.defaultLayer),T0.provide(l6.defaultLayer),T0.provide(X8.defaultLayer),T0.provide(k8.defaultLayer),T0.provide(AZ.defaultLayer)));var sl={};F1(sl,{layer:()=>ol,defaultLayer:()=>NN0,ValidationFailed:()=>nl,Service:()=>vK,OauthMissing:()=>pl,OauthCodeMissing:()=>cl,OauthCallbackFailed:()=>il,Methods:()=>ll,Method:()=>yA,CallbackInput:()=>jN0,AuthorizeInput:()=>qN0,Authorization:()=>dl});var ml=O.Struct({key:O.String,op:O.Literals(["eq","neq"]),value:O.String}),zN0=O.Struct({type:O.Literal("text"),key:O.String,message:O.String,placeholder:O.optional(O.String),when:O.optional(ml)}),FN0=O.Struct({label:O.String,value:O.String,hint:O.optional(O.String)}),AN0=O.Struct({type:O.Literal("select"),key:O.String,message:O.String,options:O.Array(FN0),when:O.optional(ml)}),ON0=O.Union([zN0,AN0]);class yA extends O.Class("ProviderAuthMethod")({type:O.Literals(["oauth","api"]),label:O.String,prompts:O.optional(O.Array(ON0))}){static zod=w0(this)}var ll=O.Record(O.String,O.Array(yA)).pipe(u0(($)=>({zod:w0($)})));class dl extends O.Class("ProviderAuthAuthorization")({url:O.String,method:O.Literals(["auto","code"]),instructions:O.String}){static zod=w0(this)}var qN0=O.Struct({method:O.Number.annotate({description:"Auth method index"}),inputs:O.optional(O.Record(O.String,O.String)).annotate({description:"Prompt inputs"})}).pipe(u0(($)=>({zod:w0($)}))),jN0=O.Struct({method:O.Number.annotate({description:"Auth method index"}),code:O.optional(O.String).annotate({description:"OAuth authorization code"})}).pipe(u0(($)=>({zod:w0($)}))),pl=j1.create("ProviderAuthOauthMissing",P.object({providerID:X1.zod})),cl=j1.create("ProviderAuthOauthCodeMissing",P.object({providerID:X1.zod})),il=j1.create("ProviderAuthOauthCallbackFailed",P.object({})),nl=j1.create("ProviderAuthValidationFailed",P.object({field:P.string(),message:P.string()}));class vK extends S1.Service()("@qitqode/ProviderAuth"){}var ol=T0.effect(vK,T.gen(function*(){let $=yield*k8.Service,Z=yield*AZ.Service,J=yield*B0.make(T.fn("ProviderAuth.state")(function*(){let W=yield*Z.list();return{hooks:y7.fromEntries(ul.filterMap(W,(K)=>K.auth?.provider!==void 0?v7.succeed([X1.make(K.auth.provider),K.auth]):v7.failVoid)),pending:new Map}})),Y=O.decodeUnknownSync(ll),X=T.fn("ProviderAuth.methods")(function*(){let W=(yield*B0.get(J)).hooks;return Y(y7.map(W,(K)=>K.methods.map((V)=>({type:V.type,label:V.label,prompts:V.prompts?.map((U)=>{if(U.type==="select")return{type:"select",key:U.key,message:U.message,options:U.options,when:U.when};return{type:"text",key:U.key,message:U.message,placeholder:U.placeholder,when:U.when}})}))))}),Q=T.fn("ProviderAuth.authorize")(function*(W){let{hooks:K,pending:V}=yield*B0.get(J),U=K[W.providerID].methods[W.method];if(U.type!=="oauth")return;if(U.prompts&&W.inputs){for(let B of U.prompts)if(B.type==="text"&&B.validate&&W.inputs[B.key]!==void 0){let z=B.validate(W.inputs[B.key]);if(z)return yield*T.fail(new nl({field:B.key,message:z}))}}let H=yield*T.promise(()=>U.authorize(W.inputs));return V.set(W.providerID,H),{url:H.url,method:H.method,instructions:H.instructions}}),G=T.fn("ProviderAuth.callback")(function*(W){let V=(yield*B0.get(J)).pending.get(W.providerID);if(!V)return yield*T.fail(new pl({providerID:W.providerID}));if(V.method==="code"&&!W.code)return yield*T.fail(new cl({providerID:W.providerID}));let U=yield*T.promise(()=>V.method==="code"?V.callback(W.code):V.callback(W.code));if(!U||U.type!=="success")return yield*T.fail(new il({}));if("key"in U)yield*$.set(W.providerID,{type:"api",key:U.key,..."metadata"in U&&U.metadata?{metadata:U.metadata}:{}});if("refresh"in U){let{type:H,provider:B,refresh:z,access:F,expires:A,...j}=U;yield*$.set(W.providerID,{type:"oauth",access:F,refresh:z,expires:A,...j})}});return vK.of({methods:X,authorize:Q,callback:G})})),NN0=T0.suspend(()=>ol.pipe(T0.provide(k8.defaultLayer),T0.provide(AZ.defaultLayer)));var W9={};F1(W9,{parseStreamError:()=>RN0,parseAPICallError:()=>PN0});import{STATUS_CODES as rl}from"http";var MN0=[/prompt is too long/i,/input is too long for requested model/i,/exceeds the context window/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/context[_ ]length[_ ]exceeded/i,/request entity too large/i,/context length is only \d+ tokens/i,/input length.*exceeds.*context length/i,/prompt too long; exceeded (?:max )?context length/i,/too large for model with \d+ maximum context length/i,/model_context_window_exceeded/i];function DN0($){let Z=$.statusCode;if(!Z)return $.isRetryable;return Z===404||$.isRetryable}function wN0($){if(MN0.some((Z)=>Z.test($)))return!0;return/^4(00|13)\s*(status code)?\s*\(no body\)/i.test($)}function LN0($){if(!$||!/^\s*[\[{]/.test($))return!1;try{return JSON.parse($),!1}catch(Z){let J=0,Y=!1,X=!1;for(let Q of $){if(Y){if(X)X=!1;else if(Q==="\\")X=!0;else if(Q==='"')Y=!1;continue}if(Q==='"')Y=!0;else if(Q==="{"||Q==="[")J++;else if(Q==="}"||Q==="]")J--;if(J<0)return!1}return Y||J>0||/unexpected end|end of json|unterminated string/i.test(String(Z))}}function TN0($,Z){return l$(()=>{let J=Z.message;if(J===""){if(Z.responseBody)return Z.responseBody;if(Z.statusCode){let X=rl[Z.statusCode];if(X)return X}return"Unknown error"}if(!Z.responseBody||Z.statusCode&&J!==rl[Z.statusCode])return J;try{let X=JSON.parse(Z.responseBody),Q=X.message||X.detail||X.error?.message||X.error;if(Q&&typeof Q==="string")return`${J}: ${Q.slice(0,300)}`;if(Array.isArray(Q)&&Q.length>0){let G=Q[0],W=typeof G?.msg==="string"?G.msg:typeof G?.message==="string"?G.message:typeof G==="string"?G:void 0;if(W)return`${J}: ${W.slice(0,300)}`}}catch{}if(/^\s*<!doctype|^\s*<html/i.test(Z.responseBody)){if(Z.statusCode===401)return"Unauthorized: request was blocked by a gateway or proxy. Your authentication token may be missing or expired \u2014 try running `qitqode auth login <your provider URL>` to re-authenticate.";if(Z.statusCode===403)return"Forbidden: request was blocked by a gateway or proxy. You may not have permission to access this resource \u2014 check your account and provider settings.";return J}let Y=Z.responseBody.length>300?Z.responseBody.slice(0,300)+"\u2026":Z.responseBody;return`${J}: ${Y}`}).trim()}function al($){if(typeof $==="string")try{let Z=JSON.parse($);if(Z&&typeof Z==="object")return Z;return}catch{return}if(typeof $==="object"&&$!==null)return $;return}function RN0($){let Z=al($);if(!Z)return;let J=JSON.stringify(Z);if(Z.type!=="error")return;switch(Z?.error?.code){case"context_length_exceeded":return{type:"context_overflow",message:"Input exceeds context window of this model",responseBody:J};case"insufficient_quota":return{type:"api_error",message:"Quota exceeded. Check your plan and billing details.",isRetryable:!1,responseBody:J};case"usage_not_included":return{type:"api_error",message:"To use Codex with your ChatGPT plan, upgrade to Plus: https://chatgpt.com/explore/plus.",isRetryable:!1,responseBody:J};case"invalid_prompt":return{type:"api_error",message:typeof Z?.error?.message==="string"?Z?.error?.message:"Invalid prompt.",isRetryable:!1,responseBody:J}}}function PN0($){let Z=TN0($.providerID,$.error),J=al($.error.responseBody),Y=LN0($.error.responseBody);if(wN0(Z)||$.error.statusCode===413||J?.error?.code==="context_length_exceeded")return{type:"context_overflow",message:Z,responseBody:$.error.responseBody};let X=$.error.url?{url:$.error.url}:void 0;return{type:"api_error",message:Y?"The model connection ended before the response completed.":Z,statusCode:$.error.statusCode,isRetryable:Y||($.providerID.startsWith("openai")?DN0($.error):$.error.isRetryable),category:Y?"stream_truncated":void 0,responseHeaders:$.error.responseHeaders,responseBody:$.error.responseBody,metadata:X}}function xA($,Z){switch(!0){case($ instanceof DOMException&&$.name==="AbortError"):return new f5({message:$.message},{cause:$}).toObject();case O4.isInstance($):{let J=$.lastError??$.errors[$.errors.length-1];if(J!==void 0&&J!==$)return xA(J,Z);return new L6({message:$.message,isRetryable:!0},{cause:$}).toObject()}case U4.isInstance($):return $;case YH.isInstance($):return new H4({providerID:Z.providerID,message:$.message},{cause:$}).toObject();case $?.code==="ECONNRESET":return new L6({message:"Connection reset by server",isRetryable:!0,metadata:{code:$.code??"",syscall:$.syscall??"",message:$.message??""}},{cause:$}).toObject();case($ instanceof Error&&$.code==="ZlibError"):if(Z.aborted)return new f5({message:$.message},{cause:$}).toObject();return new L6({message:"Response decompression failed",isRetryable:!0,metadata:{code:$.code,message:$.message}},{cause:$}).toObject();case FX.isInstance($):{let J=W9.parseAPICallError({providerID:Z.providerID,error:$});if(J.type==="context_overflow")return new GX({message:J.message,responseBody:J.responseBody},{cause:$}).toObject();return new L6({message:J.message,statusCode:J.statusCode,isRetryable:J.isRetryable,category:J.category,outputBudgetRecoveryAvailable:void 0,outputBudgetRecoveryTokens:void 0,diagnostic:UY($),responseHeaders:J.responseHeaders,responseBody:J.responseBody,metadata:J.metadata},{cause:$}).toObject()}case($ instanceof Error&&(typeof $.status==="number"||typeof $.category==="string"&&typeof $.retryable==="boolean")):{let J=$.status,Y=$.retryable===!0;return new L6({message:V6($),statusCode:J,isRetryable:Y,category:$.category,upstreamCode:$.upstreamCode,requestId:$.requestId,outputBudgetRecoveryAvailable:$.outputBudgetRecoveryAvailable,outputBudgetRecoveryTokens:$.outputBudgetRecoveryTokens,diagnostic:UY($)},{cause:$}).toObject()}case $ instanceof Error:return new j1.Unknown({message:V6($),diagnostic:UY($)},{cause:$}).toObject();default:try{let J=W9.parseStreamError($);if(J){if(J.type==="context_overflow")return new GX({message:J.message,responseBody:J.responseBody},{cause:$}).toObject();return new L6({message:J.message,isRetryable:J.isRetryable,diagnostic:UY($),responseBody:J.responseBody},{cause:$}).toObject()}}catch{}return new j1.Unknown({message:V6($),diagnostic:UY($)},{cause:$}).toObject()}}var BY={};F1(BY,{layer:()=>Xd,defaultLayer:()=>kN0,Service:()=>yK,ActorRegistry:()=>BY});var _1=g6("actor_registry",{session_id:w1().$type().notNull().references(()=>I1.id,{onDelete:"cascade"}),actor_id:w1().notNull(),mode:w1().$type().notNull(),parent_actor_id:w1(),status:w1().$type().notNull(),last_outcome:w1().$type(),lifecycle:w1().$type().notNull(),agent:w1().notNull(),description:w1().notNull(),context_mode:w1().$type().notNull(),context_watermark:w1().$type(),background:j8({mode:"boolean"}).notNull(),tools:w1({mode:"json"}).$type(),last_turn_time:j8().notNull(),turn_count:j8().notNull().default(0),last_error:w1(),time_completed:j8(),...xY},($)=>[k9({columns:[$.session_id,$.actor_id]}),K9("actor_registry_session_agent_idx").on($.session_id,$.agent),K9("actor_registry_session_parent_idx").on($.session_id,$.parent_actor_id),K9("actor_registry_status_idx").on($.status),K9("actor_registry_status_last_turn_idx").on($.status,$.last_turn_time)]);var hA=P.enum(["pending","running","idle"]),gA=P.enum(["success","failure","cancelled"]),IN0=P.enum(["ephemeral","persistent"]),CN0=P.enum(["none","state","full"]),uA=P.enum(["peer","subagent","main"]),EN0=P.union([P.array(P.string()).readonly(),P.literal("INHERIT")]),Qd0=P.object({sessionID:r0.zod,actorID:P.string(),mode:uA,parentActorID:P.string().optional(),status:hA,lastOutcome:gA.optional(),lifecycle:IN0,agent:P.string(),description:P.string(),contextMode:CN0,contextWatermark:i1.zod.optional(),background:P.boolean(),tools:EN0.optional(),lastTurnTime:P.number(),turnCount:P.number(),lastError:P.string().optional(),time:P.object({created:P.number(),updated:P.number(),completed:P.number().optional()})}).meta({ref:"Actor"});var tl=L1.define("actor.registered",P.object({sessionID:r0.zod,actorID:P.string(),mode:uA,parentActorID:P.string().optional(),description:P.string(),agent:P.string(),background:P.boolean()})),el=L1.define("actor.status",P.object({sessionID:r0.zod,actorID:P.string(),status:hA,lastOutcome:gA.optional(),turnCount:P.number(),lastTurnTime:P.number(),error:P.string().optional()})),$d=L1.define("actor.stuck",P.object({sessionID:r0.zod,actorID:P.string(),description:P.string(),lastTurnTime:P.number(),stuckDuration:P.number()})),Hd0=L1.define("writer.cache_perf",P.object({sessionID:r0.zod,writerActorID:P.string(),status:P.enum(["completed","failed"]),total_input_tokens:P.number(),cache_read_tokens:P.number(),cache_write_tokens:P.number(),cache_hit_rate:P.number(),num_llm_calls:P.number()})),Bd0=L1.define("inbox.arrived",P.object({receiverSessionID:r0.zod,receiverActorID:P.string(),senderSessionID:r0.zod.optional(),senderActorID:P.string().optional(),inboxID:P.string(),type:P.string()}));var Zd=new Set(["checkpoint-writer","dream","distill"]);var _N0=E0.create({service:"actor.registry"}),SN0=300000,fN0=60000;function HY($){return{sessionID:$.session_id,actorID:$.actor_id,mode:$.mode,parentActorID:$.parent_actor_id??void 0,status:$.status,lastOutcome:$.last_outcome??void 0,lifecycle:$.lifecycle,agent:$.agent,description:$.description,contextMode:$.context_mode,contextWatermark:$.context_watermark??void 0,background:Boolean($.background),tools:$.tools??void 0,lastTurnTime:$.last_turn_time,turnCount:$.turn_count,lastError:$.last_error??void 0,time:{created:$.time_created,updated:$.time_updated,completed:$.time_completed??void 0}}}class yK extends S1.Service()("@qitqode/ActorRegistry"){}var Xd=T0.effect(yK,T.gen(function*(){let $=yield*l1.Service,Z=new Map,J=T.fn("ActorRegistry.register")(function*(A){let j=Date.now(),N={session_id:A.sessionID,actor_id:A.actorID,mode:A.mode,parent_actor_id:A.parentActorID??null,status:"pending",last_outcome:null,lifecycle:A.lifecycle,agent:A.agent,description:A.description,context_mode:A.contextMode,context_watermark:A.contextWatermark??null,background:A.background,tools:A.tools??null,last_turn_time:j,turn_count:0,last_error:null,time_completed:null,time_created:j,time_updated:j};return yield*T.sync(()=>W1.use((L)=>{try{L.insert(_1).values(N).run()}catch(q){if(typeof q==="object"&&q!==null&&"code"in q&&typeof q.code==="string"&&(q.code==="SQLITE_CONSTRAINT_PRIMARYKEY"||q.code==="SQLITE_CONSTRAINT_UNIQUE")||q instanceof Error&&q.message.toLowerCase().includes("unique constraint"))throw Error(`Actor ID collision: '${A.actorID}' already exists in session '${A.sessionID}'.`);throw q}})),yield*$.publish(tl,{sessionID:A.sessionID,actorID:A.actorID,mode:A.mode,parentActorID:A.parentActorID,description:A.description,agent:A.agent,background:A.background}),HY(N)}),Y=T.fnUntraced(function*(A,j){return yield*T.sync(()=>W1.use((N)=>N.select().from(_1).where(O$(m0(_1.session_id,A),m0(_1.actor_id,j))).get()))}),X=T.fn("ActorRegistry.updateStatus")(function*(A,j,N){let L=Date.now(),q=N.status==="idle"&&N.lastOutcome!==void 0,M={status:N.status,time_updated:L,...q?{time_completed:L}:{}};if(N.lastOutcome!==void 0)M.last_outcome=N.lastOutcome;if(N.lastError!==void 0)M.last_error=N.lastError;else if(N.lastOutcome!==void 0&&N.lastOutcome!=="failure")M.last_error=null;yield*T.sync(()=>W1.use((R)=>R.update(_1).set(M).where(O$(m0(_1.session_id,A),m0(_1.actor_id,j))).run()));let C=yield*Y(A,j);if(!C)return;yield*$.publish(el,{sessionID:A,actorID:j,status:C.status,...C.last_outcome?{lastOutcome:C.last_outcome}:{},turnCount:C.turn_count,lastTurnTime:C.last_turn_time,...C.last_error?{error:C.last_error}:{}})}),Q=T.fn("ActorRegistry.updateTurn")(function*(A,j){let N=Date.now();yield*T.sync(()=>W1.use((L)=>L.update(_1).set({last_turn_time:N,turn_count:Jd`${_1.turn_count} + 1`,time_updated:N}).where(O$(m0(_1.session_id,A),m0(_1.actor_id,j))).run()))}),G=T.fn("ActorRegistry.get")(function*(A,j){let N=yield*Y(A,j);return N?HY(N):void 0}),W=T.fn("ActorRegistry.listBySession")(function*(A){return(yield*T.sync(()=>W1.use((N)=>N.select().from(_1).where(m0(_1.session_id,A)).all()))).map(HY)}),K=T.fn("ActorRegistry.listActive")(function*(){return(yield*T.sync(()=>W1.use((j)=>j.select().from(_1).where(O$(k5(_1.status,["pending","running"]),m0(_1.background,!0))).all()))).map(HY)}),V=T.fn("ActorRegistry.listByParent")(function*(A,j){return(yield*T.sync(()=>W1.use((L)=>L.select().from(_1).where(O$(m0(_1.session_id,A),m0(_1.parent_actor_id,j))).all()))).map(HY)}),U=T.fn("ActorRegistry.renderForAgent")(function*(A){let N=(yield*W(A)).filter((M)=>M.background&&(M.status==="pending"||M.status==="running"));if(N.length===0)return"";let L=[];L.push("## Active Actors"),L.push(""),L.push(`You have ${N.length} background actor(s) registered. Interact via the \`actor\` tool.`),L.push("");let q=Date.now();for(let M of N){let C=q-M.lastTurnTime,R=C<60000?`${Math.floor(C/1000)}s`:`${Math.floor(C/60000)}m`;L.push(`- actor_id: ${M.actorID} (${M.status}, last activity ${R} ago)`),L.push(` description: ${M.description}`),L.push(` agent: ${M.agent}`)}return L.join(`
802
- `)}),H=T.fn("ActorRegistry.agentTypeFor")(function*(A,j){if(j==="main")return"main";return(yield*G(A,j))?.agent??"main"}),B=T.fn("ActorRegistry.isSystemSpawned")(function*(A,j){if(j==="main")return!1;let N=yield*G(A,j);if(!N)return!1;return Zd.has(N.agent)}),z=T.fn("ActorRegistry.allocateActorID")(function*(A,j){let N=`${A}:${j}`,L=`${j}-`;if(!Z.has(N)){let M=yield*T.sync(()=>W1.use((C)=>C.select({actor_id:_1.actor_id}).from(_1).where(O$(m0(_1.session_id,A),m0(_1.agent,j))).all()));if(!Z.has(N)){let C=0;for(let R of M)if(R.actor_id.startsWith(L)){let w=parseInt(R.actor_id.slice(L.length),10);if(Number.isFinite(w)&&w>C)C=w}Z.set(N,C)}}let q=(Z.get(N)??0)+1;return Z.set(N,q),`${j}-${q}`});return yield*T.sync(()=>W1.use((A)=>{let j=Date.now();A.update(_1).set({status:"idle",last_outcome:"failure",last_error:"orphaned: process restarted",time_updated:j,time_completed:j}).where(k5(_1.status,["pending","running"])).run()})),_N0.info("orphan recovery complete"),yield*T.gen(function*(){let A=Date.now()-SN0,j=yield*T.sync(()=>W1.use((N)=>N.select().from(_1).where(O$(m0(_1.status,"running"),Yd(_1.last_turn_time,A))).all()));for(let N of j){let L=HY(N);yield*$.publish($d,{sessionID:L.sessionID,actorID:L.actorID,description:L.description,lastTurnTime:L.lastTurnTime,stuckDuration:Date.now()-L.lastTurnTime})}}).pipe(T.repeat(W4.fixed(fN0)),T.ignore,T.forkScoped),yK.of({register:J,updateStatus:X,updateTurn:Q,get:G,listBySession:W,listActive:K,listByParent:V,renderForAgent:U,agentTypeFor:H,isSystemSpawned:B,allocateActorID:z})})),kN0=Xd.pipe(T0.provide(l1.layer));import nA from"path";/*!
803
- * decimal.js v10.5.0
804
- * An arbitrary-precision Decimal type for JavaScript.
805
- * https://github.com/MikeMcl/decimal.js
806
- * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
807
- * MIT Licence
808
- */var zY=9000000000000000,H5=1e9,mA="0123456789abcdef",gK="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",uK="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",lA={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-zY,maxE:zY,crypto:!1},Kd,qZ,i0=!0,lK="[DecimalError] ",U5=lK+"Invalid argument: ",Vd=lK+"Precision limit exceeded",Ud=lK+"crypto unavailable",Hd="[object Decimal]",n$=Math.floor,q$=Math.pow,vN0=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,yN0=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,xN0=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Bd=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,H6=1e7,x0=7,hN0=9007199254740991,gN0=gK.length-1,dA=uK.length-1,X0={toStringTag:Hd};X0.absoluteValue=X0.abs=function(){var $=new this.constructor(this);if($.s<0)$.s=1;return I0($)};X0.ceil=function(){return I0(new this.constructor(this),this.e+1,2)};X0.clampedTo=X0.clamp=function($,Z){var J,Y=this,X=Y.constructor;if($=new X($),Z=new X(Z),!$.s||!Z.s)return new X(NaN);if($.gt(Z))throw Error(U5+Z);return J=Y.cmp($),J<0?$:Y.cmp(Z)>0?Z:new X(Y)};X0.comparedTo=X0.cmp=function($){var Z,J,Y,X,Q=this,G=Q.d,W=($=new Q.constructor($)).d,K=Q.s,V=$.s;if(!G||!W)return!K||!V?NaN:K!==V?K:G===W?0:!G^K<0?1:-1;if(!G[0]||!W[0])return G[0]?K:W[0]?-V:0;if(K!==V)return K;if(Q.e!==$.e)return Q.e>$.e^K<0?1:-1;Y=G.length,X=W.length;for(Z=0,J=Y<X?Y:X;Z<J;++Z)if(G[Z]!==W[Z])return G[Z]>W[Z]^K<0?1:-1;return Y===X?0:Y>X^K<0?1:-1};X0.cosine=X0.cos=function(){var $,Z,J=this,Y=J.constructor;if(!J.d)return new Y(NaN);if(!J.d[0])return new Y(1);return $=Y.precision,Z=Y.rounding,Y.precision=$+Math.max(J.e,J.sd())+x0,Y.rounding=1,J=uN0(Y,qd(Y,J)),Y.precision=$,Y.rounding=Z,I0(qZ==2||qZ==3?J.neg():J,$,Z,!0)};X0.cubeRoot=X0.cbrt=function(){var $,Z,J,Y,X,Q,G,W,K,V,U=this,H=U.constructor;if(!U.isFinite()||U.isZero())return new H(U);if(i0=!1,Q=U.s*q$(U.s*U,0.3333333333333333),!Q||Math.abs(Q)==1/0){if(J=v$(U.d),$=U.e,Q=($-J.length+1)%3)J+=Q==1||Q==-2?"0":"00";if(Q=q$(J,0.3333333333333333),$=n$(($+1)/3)-($%3==($<0?-1:2)),Q==1/0)J="5e"+$;else J=Q.toExponential(),J=J.slice(0,J.indexOf("e")+1)+$;Y=new H(J),Y.s=U.s}else Y=new H(Q.toString());G=($=H.precision)+3;for(;;)if(W=Y,K=W.times(W).times(W),V=K.plus(U),Y=h1(V.plus(U).times(W),V.plus(K),G+2,1),v$(W.d).slice(0,G)===(J=v$(Y.d)).slice(0,G))if(J=J.slice(G-3,G+1),J=="9999"||!X&&J=="4999"){if(!X){if(I0(W,$+1,0),W.times(W).times(W).eq(U)){Y=W;break}}G+=4,X=1}else{if(!+J||!+J.slice(1)&&J.charAt(0)=="5")I0(Y,$+1,1),Z=!Y.times(Y).times(Y).eq(U);break}return i0=!0,I0(Y,$,H.rounding,Z)};X0.decimalPlaces=X0.dp=function(){var $,Z=this.d,J=NaN;if(Z){if($=Z.length-1,J=($-n$(this.e/x0))*x0,$=Z[$],$)for(;$%10==0;$/=10)J--;if(J<0)J=0}return J};X0.dividedBy=X0.div=function($){return h1(this,new this.constructor($))};X0.dividedToIntegerBy=X0.divToInt=function($){var Z=this,J=Z.constructor;return I0(h1(Z,new J($),0,1,1),J.precision,J.rounding)};X0.equals=X0.eq=function($){return this.cmp($)===0};X0.floor=function(){return I0(new this.constructor(this),this.e+1,3)};X0.greaterThan=X0.gt=function($){return this.cmp($)>0};X0.greaterThanOrEqualTo=X0.gte=function($){var Z=this.cmp($);return Z==1||Z===0};X0.hyperbolicCosine=X0.cosh=function(){var $,Z,J,Y,X,Q=this,G=Q.constructor,W=new G(1);if(!Q.isFinite())return new G(Q.s?1/0:NaN);if(Q.isZero())return W;if(J=G.precision,Y=G.rounding,G.precision=J+Math.max(Q.e,Q.sd())+4,G.rounding=1,X=Q.d.length,X<32)$=Math.ceil(X/3),Z=(1/pK(4,$)).toString();else $=16,Z="2.3283064365386962890625e-10";Q=FY(G,1,Q.times(Z),new G(1),!0);var K,V=$,U=new G(8);for(;V--;)K=Q.times(Q),Q=W.minus(K.times(U.minus(K.times(U))));return I0(Q,G.precision=J,G.rounding=Y,!0)};X0.hyperbolicSine=X0.sinh=function(){var $,Z,J,Y,X=this,Q=X.constructor;if(!X.isFinite()||X.isZero())return new Q(X);if(Z=Q.precision,J=Q.rounding,Q.precision=Z+Math.max(X.e,X.sd())+4,Q.rounding=1,Y=X.d.length,Y<3)X=FY(Q,2,X,X,!0);else{$=1.4*Math.sqrt(Y),$=$>16?16:$|0,X=X.times(1/pK(5,$)),X=FY(Q,2,X,X,!0);var G,W=new Q(5),K=new Q(16),V=new Q(20);for(;$--;)G=X.times(X),X=X.times(W.plus(G.times(K.times(G).plus(V))))}return Q.precision=Z,Q.rounding=J,I0(X,Z,J,!0)};X0.hyperbolicTangent=X0.tanh=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite())return new Y(J.s);if(J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+7,Y.rounding=1,h1(J.sinh(),J.cosh(),Y.precision=$,Y.rounding=Z)};X0.inverseCosine=X0.acos=function(){var $=this,Z=$.constructor,J=$.abs().cmp(1),Y=Z.precision,X=Z.rounding;if(J!==-1)return J===0?$.isNeg()?y6(Z,Y,X):new Z(0):new Z(NaN);if($.isZero())return y6(Z,Y+4,X).times(0.5);return Z.precision=Y+6,Z.rounding=1,$=new Z(1).minus($).div($.plus(1)).sqrt().atan(),Z.precision=Y,Z.rounding=X,$.times(2)};X0.inverseHyperbolicCosine=X0.acosh=function(){var $,Z,J=this,Y=J.constructor;if(J.lte(1))return new Y(J.eq(1)?0:NaN);if(!J.isFinite())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+Math.max(Math.abs(J.e),J.sd())+4,Y.rounding=1,i0=!1,J=J.times(J).minus(1).sqrt().plus(J),i0=!0,Y.precision=$,Y.rounding=Z,J.ln()};X0.inverseHyperbolicSine=X0.asinh=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite()||J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+2*Math.max(Math.abs(J.e),J.sd())+6,Y.rounding=1,i0=!1,J=J.times(J).plus(1).sqrt().plus(J),i0=!0,Y.precision=$,Y.rounding=Z,J.ln()};X0.inverseHyperbolicTangent=X0.atanh=function(){var $,Z,J,Y,X=this,Q=X.constructor;if(!X.isFinite())return new Q(NaN);if(X.e>=0)return new Q(X.abs().eq(1)?X.s/0:X.isZero()?X:NaN);if($=Q.precision,Z=Q.rounding,Y=X.sd(),Math.max(Y,$)<2*-X.e-1)return I0(new Q(X),$,Z,!0);return Q.precision=J=Y-X.e,X=h1(X.plus(1),new Q(1).minus(X),J+$,1),Q.precision=$+4,Q.rounding=1,X=X.ln(),Q.precision=$,Q.rounding=Z,X.times(0.5)};X0.inverseSine=X0.asin=function(){var $,Z,J,Y,X=this,Q=X.constructor;if(X.isZero())return new Q(X);if(Z=X.abs().cmp(1),J=Q.precision,Y=Q.rounding,Z!==-1){if(Z===0)return $=y6(Q,J+4,Y).times(0.5),$.s=X.s,$;return new Q(NaN)}return Q.precision=J+6,Q.rounding=1,X=X.div(new Q(1).minus(X.times(X)).sqrt().plus(1)).atan(),Q.precision=J,Q.rounding=Y,X.times(2)};X0.inverseTangent=X0.atan=function(){var $,Z,J,Y,X,Q,G,W,K,V=this,U=V.constructor,H=U.precision,B=U.rounding;if(!V.isFinite()){if(!V.s)return new U(NaN);if(H+4<=dA)return G=y6(U,H+4,B).times(0.5),G.s=V.s,G}else if(V.isZero())return new U(V);else if(V.abs().eq(1)&&H+4<=dA)return G=y6(U,H+4,B).times(0.25),G.s=V.s,G;U.precision=W=H+10,U.rounding=1,J=Math.min(28,W/x0+2|0);for($=J;$;--$)V=V.div(V.times(V).plus(1).sqrt().plus(1));i0=!1,Z=Math.ceil(W/x0),Y=1,K=V.times(V),G=new U(V),X=V;for(;$!==-1;)if(X=X.times(K),Q=G.minus(X.div(Y+=2)),X=X.times(K),G=Q.plus(X.div(Y+=2)),G.d[Z]!==void 0)for($=Z;G.d[$]===Q.d[$]&&$--;);if(J)G=G.times(2<<J-1);return i0=!0,I0(G,U.precision=H,U.rounding=B,!0)};X0.isFinite=function(){return!!this.d};X0.isInteger=X0.isInt=function(){return!!this.d&&n$(this.e/x0)>this.d.length-2};X0.isNaN=function(){return!this.s};X0.isNegative=X0.isNeg=function(){return this.s<0};X0.isPositive=X0.isPos=function(){return this.s>0};X0.isZero=function(){return!!this.d&&this.d[0]===0};X0.lessThan=X0.lt=function($){return this.cmp($)<0};X0.lessThanOrEqualTo=X0.lte=function($){return this.cmp($)<1};X0.logarithm=X0.log=function($){var Z,J,Y,X,Q,G,W,K,V=this,U=V.constructor,H=U.precision,B=U.rounding,z=5;if($==null)$=new U(10),Z=!0;else{if($=new U($),J=$.d,$.s<0||!J||!J[0]||$.eq(1))return new U(NaN);Z=$.eq(10)}if(J=V.d,V.s<0||!J||!J[0]||V.eq(1))return new U(J&&!J[0]?-1/0:V.s!=1?NaN:J?0:1/0);if(Z)if(J.length>1)Q=!0;else{for(X=J[0];X%10===0;)X/=10;Q=X!==1}if(i0=!1,W=H+z,G=V5(V,W),Y=Z?mK(U,W+10):V5($,W),K=h1(G,Y,W,1),V9(K.d,X=H,B))do if(W+=10,G=V5(V,W),Y=Z?mK(U,W+10):V5($,W),K=h1(G,Y,W,1),!Q){if(+v$(K.d).slice(X+1,X+15)+1==100000000000000)K=I0(K,H+1,0);break}while(V9(K.d,X+=10,B));return i0=!0,I0(K,H,B)};X0.minus=X0.sub=function($){var Z,J,Y,X,Q,G,W,K,V,U,H,B,z=this,F=z.constructor;if($=new F($),!z.d||!$.d){if(!z.s||!$.s)$=new F(NaN);else if(z.d)$.s=-$.s;else $=new F($.d||z.s!==$.s?z:NaN);return $}if(z.s!=$.s)return $.s=-$.s,z.plus($);if(V=z.d,B=$.d,W=F.precision,K=F.rounding,!V[0]||!B[0]){if(B[0])$.s=-$.s;else if(V[0])$=new F(z);else return new F(K===3?-0:0);return i0?I0($,W,K):$}if(J=n$($.e/x0),U=n$(z.e/x0),V=V.slice(),Q=U-J,Q){if(H=Q<0,H)Z=V,Q=-Q,G=B.length;else Z=B,J=U,G=V.length;if(Y=Math.max(Math.ceil(W/x0),G)+2,Q>Y)Q=Y,Z.length=1;Z.reverse();for(Y=Q;Y--;)Z.push(0);Z.reverse()}else{if(Y=V.length,G=B.length,H=Y<G,H)G=Y;for(Y=0;Y<G;Y++)if(V[Y]!=B[Y]){H=V[Y]<B[Y];break}Q=0}if(H)Z=V,V=B,B=Z,$.s=-$.s;G=V.length;for(Y=B.length-G;Y>0;--Y)V[G++]=0;for(Y=B.length;Y>Q;){if(V[--Y]<B[Y]){for(X=Y;X&&V[--X]===0;)V[X]=H6-1;--V[X],V[Y]+=H6}V[Y]-=B[Y]}for(;V[--G]===0;)V.pop();for(;V[0]===0;V.shift())--J;if(!V[0])return new F(K===3?-0:0);return $.d=V,$.e=dK(V,J),i0?I0($,W,K):$};X0.modulo=X0.mod=function($){var Z,J=this,Y=J.constructor;if($=new Y($),!J.d||!$.s||$.d&&!$.d[0])return new Y(NaN);if(!$.d||J.d&&!J.d[0])return I0(new Y(J),Y.precision,Y.rounding);if(i0=!1,Y.modulo==9)Z=h1(J,$.abs(),0,3,1),Z.s*=$.s;else Z=h1(J,$,0,Y.modulo,1);return Z=Z.times($),i0=!0,J.minus(Z)};X0.naturalExponential=X0.exp=function(){return pA(this)};X0.naturalLogarithm=X0.ln=function(){return V5(this)};X0.negated=X0.neg=function(){var $=new this.constructor(this);return $.s=-$.s,I0($)};X0.plus=X0.add=function($){var Z,J,Y,X,Q,G,W,K,V,U,H=this,B=H.constructor;if($=new B($),!H.d||!$.d){if(!H.s||!$.s)$=new B(NaN);else if(!H.d)$=new B($.d||H.s===$.s?H:NaN);return $}if(H.s!=$.s)return $.s=-$.s,H.minus($);if(V=H.d,U=$.d,W=B.precision,K=B.rounding,!V[0]||!U[0]){if(!U[0])$=new B(H);return i0?I0($,W,K):$}if(Q=n$(H.e/x0),Y=n$($.e/x0),V=V.slice(),X=Q-Y,X){if(X<0)J=V,X=-X,G=U.length;else J=U,Y=Q,G=V.length;if(Q=Math.ceil(W/x0),G=Q>G?Q+1:G+1,X>G)X=G,J.length=1;J.reverse();for(;X--;)J.push(0);J.reverse()}if(G=V.length,X=U.length,G-X<0)X=G,J=U,U=V,V=J;for(Z=0;X;)Z=(V[--X]=V[X]+U[X]+Z)/H6|0,V[X]%=H6;if(Z)V.unshift(Z),++Y;for(G=V.length;V[--G]==0;)V.pop();return $.d=V,$.e=dK(V,Y),i0?I0($,W,K):$};X0.precision=X0.sd=function($){var Z,J=this;if($!==void 0&&$!==!!$&&$!==1&&$!==0)throw Error(U5+$);if(J.d){if(Z=zd(J.d),$&&J.e+1>Z)Z=J.e+1}else Z=NaN;return Z};X0.round=function(){var $=this,Z=$.constructor;return I0(new Z($),$.e+1,Z.rounding)};X0.sine=X0.sin=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite())return new Y(NaN);if(J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+Math.max(J.e,J.sd())+x0,Y.rounding=1,J=lN0(Y,qd(Y,J)),Y.precision=$,Y.rounding=Z,I0(qZ>2?J.neg():J,$,Z,!0)};X0.squareRoot=X0.sqrt=function(){var $,Z,J,Y,X,Q,G=this,W=G.d,K=G.e,V=G.s,U=G.constructor;if(V!==1||!W||!W[0])return new U(!V||V<0&&(!W||W[0])?NaN:W?G:1/0);if(i0=!1,V=Math.sqrt(+G),V==0||V==1/0){if(Z=v$(W),(Z.length+K)%2==0)Z+="0";if(V=Math.sqrt(Z),K=n$((K+1)/2)-(K<0||K%2),V==1/0)Z="5e"+K;else Z=V.toExponential(),Z=Z.slice(0,Z.indexOf("e")+1)+K;Y=new U(Z)}else Y=new U(V.toString());J=(K=U.precision)+3;for(;;)if(Q=Y,Y=Q.plus(h1(G,Q,J+2,1)).times(0.5),v$(Q.d).slice(0,J)===(Z=v$(Y.d)).slice(0,J))if(Z=Z.slice(J-3,J+1),Z=="9999"||!X&&Z=="4999"){if(!X){if(I0(Q,K+1,0),Q.times(Q).eq(G)){Y=Q;break}}J+=4,X=1}else{if(!+Z||!+Z.slice(1)&&Z.charAt(0)=="5")I0(Y,K+1,1),$=!Y.times(Y).eq(G);break}return i0=!0,I0(Y,K,U.rounding,$)};X0.tangent=X0.tan=function(){var $,Z,J=this,Y=J.constructor;if(!J.isFinite())return new Y(NaN);if(J.isZero())return new Y(J);return $=Y.precision,Z=Y.rounding,Y.precision=$+10,Y.rounding=1,J=J.sin(),J.s=1,J=h1(J,new Y(1).minus(J.times(J)).sqrt(),$+10,0),Y.precision=$,Y.rounding=Z,I0(qZ==2||qZ==4?J.neg():J,$,Z,!0)};X0.times=X0.mul=function($){var Z,J,Y,X,Q,G,W,K,V,U=this,H=U.constructor,B=U.d,z=($=new H($)).d;if($.s*=U.s,!B||!B[0]||!z||!z[0])return new H(!$.s||B&&!B[0]&&!z||z&&!z[0]&&!B?NaN:!B||!z?$.s/0:$.s*0);if(J=n$(U.e/x0)+n$($.e/x0),K=B.length,V=z.length,K<V)Q=B,B=z,z=Q,G=K,K=V,V=G;Q=[],G=K+V;for(Y=G;Y--;)Q.push(0);for(Y=V;--Y>=0;){Z=0;for(X=K+Y;X>Y;)W=Q[X]+z[Y]*B[X-Y-1]+Z,Q[X--]=W%H6|0,Z=W/H6|0;Q[X]=(Q[X]+Z)%H6|0}for(;!Q[--G];)Q.pop();if(Z)++J;else Q.shift();return $.d=Q,$.e=dK(Q,J),i0?I0($,H.precision,H.rounding):$};X0.toBinary=function($,Z){return cA(this,2,$,Z)};X0.toDecimalPlaces=X0.toDP=function($,Z){var J=this,Y=J.constructor;if(J=new Y(J),$===void 0)return J;if(A8($,0,H5),Z===void 0)Z=Y.rounding;else A8(Z,0,8);return I0(J,$+J.e+1,Z)};X0.toExponential=function($,Z){var J,Y=this,X=Y.constructor;if($===void 0)J=x6(Y,!0);else{if(A8($,0,H5),Z===void 0)Z=X.rounding;else A8(Z,0,8);Y=I0(new X(Y),$+1,Z),J=x6(Y,!0,$+1)}return Y.isNeg()&&!Y.isZero()?"-"+J:J};X0.toFixed=function($,Z){var J,Y,X=this,Q=X.constructor;if($===void 0)J=x6(X);else{if(A8($,0,H5),Z===void 0)Z=Q.rounding;else A8(Z,0,8);Y=I0(new Q(X),$+X.e+1,Z),J=x6(Y,!1,$+Y.e+1)}return X.isNeg()&&!X.isZero()?"-"+J:J};X0.toFraction=function($){var Z,J,Y,X,Q,G,W,K,V,U,H,B,z=this,F=z.d,A=z.constructor;if(!F)return new A(z);if(V=J=new A(1),Y=K=new A(0),Z=new A(Y),Q=Z.e=zd(F)-z.e-1,G=Q%x0,Z.d[0]=q$(10,G<0?x0+G:G),$==null)$=Q>0?Z:V;else{if(W=new A($),!W.isInt()||W.lt(V))throw Error(U5+W);$=W.gt(Z)?Q>0?Z:V:W}i0=!1,W=new A(v$(F)),U=A.precision,A.precision=Q=F.length*x0*2;for(;;){if(H=h1(W,Z,0,1,1),X=J.plus(H.times(Y)),X.cmp($)==1)break;J=Y,Y=X,X=V,V=K.plus(H.times(X)),K=X,X=Z,Z=W.minus(H.times(X)),W=X}return X=h1($.minus(J),Y,0,1,1),K=K.plus(X.times(V)),J=J.plus(X.times(Y)),K.s=V.s=z.s,B=h1(V,Y,Q,1).minus(z).abs().cmp(h1(K,J,Q,1).minus(z).abs())<1?[V,Y]:[K,J],A.precision=U,i0=!0,B};X0.toHexadecimal=X0.toHex=function($,Z){return cA(this,16,$,Z)};X0.toNearest=function($,Z){var J=this,Y=J.constructor;if(J=new Y(J),$==null){if(!J.d)return J;$=new Y(1),Z=Y.rounding}else{if($=new Y($),Z===void 0)Z=Y.rounding;else A8(Z,0,8);if(!J.d)return $.s?J:$;if(!$.d){if($.s)$.s=J.s;return $}}if($.d[0])i0=!1,J=h1(J,$,0,Z,1).times($),i0=!0,I0(J);else $.s=J.s,J=$;return J};X0.toNumber=function(){return+this};X0.toOctal=function($,Z){return cA(this,8,$,Z)};X0.toPower=X0.pow=function($){var Z,J,Y,X,Q,G,W=this,K=W.constructor,V=+($=new K($));if(!W.d||!$.d||!W.d[0]||!$.d[0])return new K(q$(+W,V));if(W=new K(W),W.eq(1))return W;if(Y=K.precision,Q=K.rounding,$.eq(1))return I0(W,Y,Q);if(Z=n$($.e/x0),Z>=$.d.length-1&&(J=V<0?-V:V)<=hN0)return X=Fd(K,W,J,Y),$.s<0?new K(1).div(X):I0(X,Y,Q);if(G=W.s,G<0){if(Z<$.d.length-1)return new K(NaN);if(($.d[Z]&1)==0)G=1;if(W.e==0&&W.d[0]==1&&W.d.length==1)return W.s=G,W}if(J=q$(+W,V),Z=J==0||!isFinite(J)?n$(V*(Math.log("0."+v$(W.d))/Math.LN10+W.e+1)):new K(J+"").e,Z>K.maxE+1||Z<K.minE-1)return new K(Z>0?G/0:0);if(i0=!1,K.rounding=W.s=1,J=Math.min(12,(Z+"").length),X=pA($.times(V5(W,Y+J)),Y),X.d){if(X=I0(X,Y+5,1),V9(X.d,Y,Q)){if(Z=Y+10,X=I0(pA($.times(V5(W,Z+J)),Z),Z+5,1),+v$(X.d).slice(Y+1,Y+15)+1==100000000000000)X=I0(X,Y+1,0)}}return X.s=G,i0=!0,K.rounding=Q,I0(X,Y,Q)};X0.toPrecision=function($,Z){var J,Y=this,X=Y.constructor;if($===void 0)J=x6(Y,Y.e<=X.toExpNeg||Y.e>=X.toExpPos);else{if(A8($,1,H5),Z===void 0)Z=X.rounding;else A8(Z,0,8);Y=I0(new X(Y),$,Z),J=x6(Y,$<=Y.e||Y.e<=X.toExpNeg,$)}return Y.isNeg()&&!Y.isZero()?"-"+J:J};X0.toSignificantDigits=X0.toSD=function($,Z){var J=this,Y=J.constructor;if($===void 0)$=Y.precision,Z=Y.rounding;else if(A8($,1,H5),Z===void 0)Z=Y.rounding;else A8(Z,0,8);return I0(new Y(J),$,Z)};X0.toString=function(){var $=this,Z=$.constructor,J=x6($,$.e<=Z.toExpNeg||$.e>=Z.toExpPos);return $.isNeg()&&!$.isZero()?"-"+J:J};X0.truncated=X0.trunc=function(){return I0(new this.constructor(this),this.e+1,1)};X0.valueOf=X0.toJSON=function(){var $=this,Z=$.constructor,J=x6($,$.e<=Z.toExpNeg||$.e>=Z.toExpPos);return $.isNeg()?"-"+J:J};function v$($){var Z,J,Y,X=$.length-1,Q="",G=$[0];if(X>0){Q+=G;for(Z=1;Z<X;Z++){if(Y=$[Z]+"",J=x0-Y.length,J)Q+=K5(J);Q+=Y}if(G=$[Z],Y=G+"",J=x0-Y.length,J)Q+=K5(J)}else if(G===0)return"0";for(;G%10===0;)G/=10;return Q+G}function A8($,Z,J){if($!==~~$||$<Z||$>J)throw Error(U5+$)}function V9($,Z,J,Y){var X,Q,G,W;for(Q=$[0];Q>=10;Q/=10)--Z;if(--Z<0)Z+=x0,X=0;else X=Math.ceil((Z+1)/x0),Z%=x0;if(Q=q$(10,x0-Z),W=$[X]%Q|0,Y==null)if(Z<3){if(Z==0)W=W/100|0;else if(Z==1)W=W/10|0;G=J<4&&W==99999||J>3&&W==49999||W==50000||W==0}else G=(J<4&&W+1==Q||J>3&&W+1==Q/2)&&($[X+1]/Q/100|0)==q$(10,Z-2)-1||(W==Q/2||W==0)&&($[X+1]/Q/100|0)==0;else if(Z<4){if(Z==0)W=W/1000|0;else if(Z==1)W=W/100|0;else if(Z==2)W=W/10|0;G=(Y||J<4)&&W==9999||!Y&&J>3&&W==4999}else G=((Y||J<4)&&W+1==Q||!Y&&J>3&&W+1==Q/2)&&($[X+1]/Q/1000|0)==q$(10,Z-3)-1;return G}function xK($,Z,J){var Y,X=[0],Q,G=0,W=$.length;for(;G<W;){for(Q=X.length;Q--;)X[Q]*=Z;X[0]+=mA.indexOf($.charAt(G++));for(Y=0;Y<X.length;Y++)if(X[Y]>J-1){if(X[Y+1]===void 0)X[Y+1]=0;X[Y+1]+=X[Y]/J|0,X[Y]%=J}}return X.reverse()}function uN0($,Z){var J,Y,X;if(Z.isZero())return Z;if(Y=Z.d.length,Y<32)J=Math.ceil(Y/3),X=(1/pK(4,J)).toString();else J=16,X="2.3283064365386962890625e-10";$.precision+=J,Z=FY($,1,Z.times(X),new $(1));for(var Q=J;Q--;){var G=Z.times(Z);Z=G.times(G).minus(G).times(8).plus(1)}return $.precision-=J,Z}var h1=function(){function $(Y,X,Q){var G,W=0,K=Y.length;for(Y=Y.slice();K--;)G=Y[K]*X+W,Y[K]=G%Q|0,W=G/Q|0;if(W)Y.unshift(W);return Y}function Z(Y,X,Q,G){var W,K;if(Q!=G)K=Q>G?1:-1;else for(W=K=0;W<Q;W++)if(Y[W]!=X[W]){K=Y[W]>X[W]?1:-1;break}return K}function J(Y,X,Q,G){var W=0;for(;Q--;)Y[Q]-=W,W=Y[Q]<X[Q]?1:0,Y[Q]=W*G+Y[Q]-X[Q];for(;!Y[0]&&Y.length>1;)Y.shift()}return function(Y,X,Q,G,W,K){var V,U,H,B,z,F,A,j,N,L,q,M,C,R,w,I,_,E,f,b,y=Y.constructor,k=Y.s==X.s?1:-1,g=Y.d,d=X.d;if(!g||!g[0]||!d||!d[0])return new y(!Y.s||!X.s||(g?d&&g[0]==d[0]:!d)?NaN:g&&g[0]==0||!d?k*0:k/0);if(K)z=1,U=Y.e-X.e;else K=H6,z=x0,U=n$(Y.e/z)-n$(X.e/z);f=d.length,_=g.length,N=new y(k),L=N.d=[];for(H=0;d[H]==(g[H]||0);H++);if(d[H]>(g[H]||0))U--;if(Q==null)R=Q=y.precision,G=y.rounding;else if(W)R=Q+(Y.e-X.e)+1;else R=Q;if(R<0)L.push(1),F=!0;else{if(R=R/z+2|0,H=0,f==1){B=0,d=d[0],R++;for(;(H<_||B)&&R--;H++)w=B*K+(g[H]||0),L[H]=w/d|0,B=w%d|0;F=B||H<_}else{if(B=K/(d[0]+1)|0,B>1)d=$(d,B,K),g=$(g,B,K),f=d.length,_=g.length;I=f,q=g.slice(0,f),M=q.length;for(;M<f;)q[M++]=0;if(b=d.slice(),b.unshift(0),E=d[0],d[1]>=K/2)++E;do{if(B=0,V=Z(d,q,f,M),V<0){if(C=q[0],f!=M)C=C*K+(q[1]||0);if(B=C/E|0,B>1){if(B>=K)B=K-1;if(A=$(d,B,K),j=A.length,M=q.length,V=Z(A,q,j,M),V==1)B--,J(A,f<j?b:d,j,K)}else{if(B==0)V=B=1;A=d.slice()}if(j=A.length,j<M)A.unshift(0);if(J(q,A,M,K),V==-1){if(M=q.length,V=Z(d,q,f,M),V<1)B++,J(q,f<M?b:d,M,K)}M=q.length}else if(V===0)B++,q=[0];if(L[H++]=B,V&&q[0])q[M++]=g[I]||0;else q=[g[I]],M=1}while((I++<_||q[0]!==void 0)&&R--);F=q[0]!==void 0}if(!L[0])L.shift()}if(z==1)N.e=U,Kd=F;else{for(H=1,B=L[0];B>=10;B/=10)H++;N.e=H+U*z-1,I0(N,W?Q+N.e+1:Q,G,F)}return N}}();function I0($,Z,J,Y){var X,Q,G,W,K,V,U,H,B,z=$.constructor;$:if(Z!=null){if(H=$.d,!H)return $;for(X=1,W=H[0];W>=10;W/=10)X++;if(Q=Z-X,Q<0)Q+=x0,G=Z,U=H[B=0],K=U/q$(10,X-G-1)%10|0;else if(B=Math.ceil((Q+1)/x0),W=H.length,B>=W)if(Y){for(;W++<=B;)H.push(0);U=K=0,X=1,Q%=x0,G=Q-x0+1}else break $;else{U=W=H[B];for(X=1;W>=10;W/=10)X++;Q%=x0,G=Q-x0+X,K=G<0?0:U/q$(10,X-G-1)%10|0}if(Y=Y||Z<0||H[B+1]!==void 0||(G<0?U:U%q$(10,X-G-1)),V=J<4?(K||Y)&&(J==0||J==($.s<0?3:2)):K>5||K==5&&(J==4||Y||J==6&&(Q>0?G>0?U/q$(10,X-G):0:H[B-1])%10&1||J==($.s<0?8:7)),Z<1||!H[0]){if(H.length=0,V)Z-=$.e+1,H[0]=q$(10,(x0-Z%x0)%x0),$.e=-Z||0;else H[0]=$.e=0;return $}if(Q==0)H.length=B,W=1,B--;else H.length=B+1,W=q$(10,x0-Q),H[B]=G>0?(U/q$(10,X-G)%q$(10,G)|0)*W:0;if(V)for(;;)if(B==0){for(Q=1,G=H[0];G>=10;G/=10)Q++;G=H[0]+=W;for(W=1;G>=10;G/=10)W++;if(Q!=W){if($.e++,H[0]==H6)H[0]=1}break}else{if(H[B]+=W,H[B]!=H6)break;H[B--]=0,W=1}for(Q=H.length;H[--Q]===0;)H.pop()}if(i0){if($.e>z.maxE)$.d=null,$.e=NaN;else if($.e<z.minE)$.e=0,$.d=[0]}return $}function x6($,Z,J){if(!$.isFinite())return Od($);var Y,X=$.e,Q=v$($.d),G=Q.length;if(Z){if(J&&(Y=J-G)>0)Q=Q.charAt(0)+"."+Q.slice(1)+K5(Y);else if(G>1)Q=Q.charAt(0)+"."+Q.slice(1);Q=Q+($.e<0?"e":"e+")+$.e}else if(X<0){if(Q="0."+K5(-X-1)+Q,J&&(Y=J-G)>0)Q+=K5(Y)}else if(X>=G){if(Q+=K5(X+1-G),J&&(Y=J-X-1)>0)Q=Q+"."+K5(Y)}else{if((Y=X+1)<G)Q=Q.slice(0,Y)+"."+Q.slice(Y);if(J&&(Y=J-G)>0){if(X+1===G)Q+=".";Q+=K5(Y)}}return Q}function dK($,Z){var J=$[0];for(Z*=x0;J>=10;J/=10)Z++;return Z}function mK($,Z,J){if(Z>gN0){if(i0=!0,J)$.precision=J;throw Error(Vd)}return I0(new $(gK),Z,1,!0)}function y6($,Z,J){if(Z>dA)throw Error(Vd);return I0(new $(uK),Z,J,!0)}function zd($){var Z=$.length-1,J=Z*x0+1;if(Z=$[Z],Z){for(;Z%10==0;Z/=10)J--;for(Z=$[0];Z>=10;Z/=10)J++}return J}function K5($){var Z="";for(;$--;)Z+="0";return Z}function Fd($,Z,J,Y){var X,Q=new $(1),G=Math.ceil(Y/x0+4);i0=!1;for(;;){if(J%2){if(Q=Q.times(Z),Gd(Q.d,G))X=!0}if(J=n$(J/2),J===0){if(J=Q.d.length-1,X&&Q.d[J]===0)++Q.d[J];break}Z=Z.times(Z),Gd(Z.d,G)}return i0=!0,Q}function Qd($){return $.d[$.d.length-1]&1}function Ad($,Z,J){var Y,X,Q=new $(Z[0]),G=0;for(;++G<Z.length;){if(X=new $(Z[G]),!X.s){Q=X;break}if(Y=Q.cmp(X),Y===J||Y===0&&Q.s===J)Q=X}return Q}function pA($,Z){var J,Y,X,Q,G,W,K,V=0,U=0,H=0,B=$.constructor,z=B.rounding,F=B.precision;if(!$.d||!$.d[0]||$.e>17)return new B($.d?!$.d[0]?1:$.s<0?0:1/0:$.s?$.s<0?0:$:NaN);if(Z==null)i0=!1,K=F;else K=Z;W=new B(0.03125);while($.e>-2)$=$.times(W),H+=5;Y=Math.log(q$(2,H))/Math.LN10*2+5|0,K+=Y,J=Q=G=new B(1),B.precision=K;for(;;){if(Q=I0(Q.times($),K,1),J=J.times(++U),W=G.plus(h1(Q,J,K,1)),v$(W.d).slice(0,K)===v$(G.d).slice(0,K)){X=H;while(X--)G=I0(G.times(G),K,1);if(Z==null)if(V<3&&V9(G.d,K-Y,z,V))B.precision=K+=10,J=Q=W=new B(1),U=0,V++;else return I0(G,B.precision=F,z,i0=!0);else return B.precision=F,G}G=W}}function V5($,Z){var J,Y,X,Q,G,W,K,V,U,H,B,z=1,F=10,A=$,j=A.d,N=A.constructor,L=N.rounding,q=N.precision;if(A.s<0||!j||!j[0]||!A.e&&j[0]==1&&j.length==1)return new N(j&&!j[0]?-1/0:A.s!=1?NaN:j?0:A);if(Z==null)i0=!1,U=q;else U=Z;if(N.precision=U+=F,J=v$(j),Y=J.charAt(0),Math.abs(Q=A.e)<1500000000000000){while(Y<7&&Y!=1||Y==1&&J.charAt(1)>3)A=A.times($),J=v$(A.d),Y=J.charAt(0),z++;if(Q=A.e,Y>1)A=new N("0."+J),Q++;else A=new N(Y+"."+J.slice(1))}else return V=mK(N,U+2,q).times(Q+""),A=V5(new N(Y+"."+J.slice(1)),U-F).plus(V),N.precision=q,Z==null?I0(A,q,L,i0=!0):A;H=A,K=G=A=h1(A.minus(1),A.plus(1),U,1),B=I0(A.times(A),U,1),X=3;for(;;){if(G=I0(G.times(B),U,1),V=K.plus(h1(G,new N(X),U,1)),v$(V.d).slice(0,U)===v$(K.d).slice(0,U)){if(K=K.times(2),Q!==0)K=K.plus(mK(N,U+2,q).times(Q+""));if(K=h1(K,new N(z),U,1),Z==null)if(V9(K.d,U-F,L,W))N.precision=U+=F,V=G=A=h1(H.minus(1),H.plus(1),U,1),B=I0(A.times(A),U,1),X=W=1;else return I0(K,N.precision=q,L,i0=!0);else return N.precision=q,K}K=V,X+=2}}function Od($){return String($.s*$.s/0)}function hK($,Z){var J,Y,X;if((J=Z.indexOf("."))>-1)Z=Z.replace(".","");if((Y=Z.search(/e/i))>0){if(J<0)J=Y;J+=+Z.slice(Y+1),Z=Z.substring(0,Y)}else if(J<0)J=Z.length;for(Y=0;Z.charCodeAt(Y)===48;Y++);for(X=Z.length;Z.charCodeAt(X-1)===48;--X);if(Z=Z.slice(Y,X),Z){if(X-=Y,$.e=J=J-Y-1,$.d=[],Y=(J+1)%x0,J<0)Y+=x0;if(Y<X){if(Y)$.d.push(+Z.slice(0,Y));for(X-=x0;Y<X;)$.d.push(+Z.slice(Y,Y+=x0));Z=Z.slice(Y),Y=x0-Z.length}else Y-=X;for(;Y--;)Z+="0";if($.d.push(+Z),i0){if($.e>$.constructor.maxE)$.d=null,$.e=NaN;else if($.e<$.constructor.minE)$.e=0,$.d=[0]}}else $.e=0,$.d=[0];return $}function mN0($,Z){var J,Y,X,Q,G,W,K,V,U;if(Z.indexOf("_")>-1){if(Z=Z.replace(/(\d)_(?=\d)/g,"$1"),Bd.test(Z))return hK($,Z)}else if(Z==="Infinity"||Z==="NaN"){if(!+Z)$.s=NaN;return $.e=NaN,$.d=null,$}if(yN0.test(Z))J=16,Z=Z.toLowerCase();else if(vN0.test(Z))J=2;else if(xN0.test(Z))J=8;else throw Error(U5+Z);if(Q=Z.search(/p/i),Q>0)K=+Z.slice(Q+1),Z=Z.substring(2,Q);else Z=Z.slice(2);if(Q=Z.indexOf("."),G=Q>=0,Y=$.constructor,G)Z=Z.replace(".",""),W=Z.length,Q=W-Q,X=Fd(Y,new Y(J),Q,Q*2);V=xK(Z,J,H6),U=V.length-1;for(Q=U;V[Q]===0;--Q)V.pop();if(Q<0)return new Y($.s*0);if($.e=dK(V,U),$.d=V,i0=!1,G)$=h1($,X,W*4);if(K)$=$.times(Math.abs(K)<54?q$(2,K):B6.pow(2,K));return i0=!0,$}function lN0($,Z){var J,Y=Z.d.length;if(Y<3)return Z.isZero()?Z:FY($,2,Z,Z);J=1.4*Math.sqrt(Y),J=J>16?16:J|0,Z=Z.times(1/pK(5,J)),Z=FY($,2,Z,Z);var X,Q=new $(5),G=new $(16),W=new $(20);for(;J--;)X=Z.times(Z),Z=Z.times(Q.plus(X.times(G.times(X).minus(W))));return Z}function FY($,Z,J,Y,X){var Q,G,W,K,V=1,U=$.precision,H=Math.ceil(U/x0);i0=!1,K=J.times(J),W=new $(Y);for(;;){if(G=h1(W.times(K),new $(Z++*Z++),U,1),W=X?Y.plus(G):Y.minus(G),Y=h1(G.times(K),new $(Z++*Z++),U,1),G=W.plus(Y),G.d[H]!==void 0){for(Q=H;G.d[Q]===W.d[Q]&&Q--;);if(Q==-1)break}Q=W,W=Y,Y=G,G=Q,V++}return i0=!0,G.d.length=H+1,G}function pK($,Z){var J=$;while(--Z)J*=$;return J}function qd($,Z){var J,Y=Z.s<0,X=y6($,$.precision,1),Q=X.times(0.5);if(Z=Z.abs(),Z.lte(Q))return qZ=Y?4:1,Z;if(J=Z.divToInt(X),J.isZero())qZ=Y?3:2;else{if(Z=Z.minus(J.times(X)),Z.lte(Q))return qZ=Qd(J)?Y?2:3:Y?4:1,Z;qZ=Qd(J)?Y?1:4:Y?3:2}return Z.minus(X).abs()}function cA($,Z,J,Y){var X,Q,G,W,K,V,U,H,B,z=$.constructor,F=J!==void 0;if(F)if(A8(J,1,H5),Y===void 0)Y=z.rounding;else A8(Y,0,8);else J=z.precision,Y=z.rounding;if(!$.isFinite())U=Od($);else{if(U=x6($),G=U.indexOf("."),F){if(X=2,Z==16)J=J*4-3;else if(Z==8)J=J*3-2}else X=Z;if(G>=0)U=U.replace(".",""),B=new z(1),B.e=U.length-G,B.d=xK(x6(B),10,X),B.e=B.d.length;H=xK(U,10,X),Q=K=H.length;for(;H[--K]==0;)H.pop();if(!H[0])U=F?"0p+0":"0";else{if(G<0)Q--;else $=new z($),$.d=H,$.e=Q,$=h1($,B,J,Y,0,X),H=$.d,Q=$.e,V=Kd;if(G=H[J],W=X/2,V=V||H[J+1]!==void 0,V=Y<4?(G!==void 0||V)&&(Y===0||Y===($.s<0?3:2)):G>W||G===W&&(Y===4||V||Y===6&&H[J-1]&1||Y===($.s<0?8:7)),H.length=J,V){for(;++H[--J]>X-1;)if(H[J]=0,!J)++Q,H.unshift(1)}for(K=H.length;!H[K-1];--K);for(G=0,U="";G<K;G++)U+=mA.charAt(H[G]);if(F){if(K>1)if(Z==16||Z==8){G=Z==16?4:3;for(--K;K%G;K++)U+="0";H=xK(U,X,Z);for(K=H.length;!H[K-1];--K);for(G=1,U="1.";G<K;G++)U+=mA.charAt(H[G])}else U=U.charAt(0)+"."+U.slice(1);U=U+(Q<0?"p":"p+")+Q}else if(Q<0){for(;++Q;)U="0"+U;U="0."+U}else if(++Q>K)for(Q-=K;Q--;)U+="0";else if(Q<K)U=U.slice(0,Q)+"."+U.slice(Q)}U=(Z==16?"0x":Z==2?"0b":Z==8?"0o":"")+U}return $.s<0?"-"+U:U}function Gd($,Z){if($.length>Z)return $.length=Z,!0}function dN0($){return new this($).abs()}function pN0($){return new this($).acos()}function cN0($){return new this($).acosh()}function iN0($,Z){return new this($).plus(Z)}function nN0($){return new this($).asin()}function oN0($){return new this($).asinh()}function sN0($){return new this($).atan()}function rN0($){return new this($).atanh()}function aN0($,Z){$=new this($),Z=new this(Z);var J,Y=this.precision,X=this.rounding,Q=Y+4;if(!$.s||!Z.s)J=new this(NaN);else if(!$.d&&!Z.d)J=y6(this,Q,1).times(Z.s>0?0.25:0.75),J.s=$.s;else if(!Z.d||$.isZero())J=Z.s<0?y6(this,Y,X):new this(0),J.s=$.s;else if(!$.d||Z.isZero())J=y6(this,Q,1).times(0.5),J.s=$.s;else if(Z.s<0)this.precision=Q,this.rounding=1,J=this.atan(h1($,Z,Q,1)),Z=y6(this,Q,1),this.precision=Y,this.rounding=X,J=$.s<0?J.minus(Z):J.plus(Z);else J=this.atan(h1($,Z,Q,1));return J}function tN0($){return new this($).cbrt()}function eN0($){return I0($=new this($),$.e+1,2)}function $M0($,Z,J){return new this($).clamp(Z,J)}function ZM0($){if(!$||typeof $!=="object")throw Error(lK+"Object expected");var Z,J,Y,X=$.defaults===!0,Q=["precision",1,H5,"rounding",0,8,"toExpNeg",-zY,0,"toExpPos",0,zY,"maxE",0,zY,"minE",-zY,0,"modulo",0,9];for(Z=0;Z<Q.length;Z+=3){if(J=Q[Z],X)this[J]=lA[J];if((Y=$[J])!==void 0)if(n$(Y)===Y&&Y>=Q[Z+1]&&Y<=Q[Z+2])this[J]=Y;else throw Error(U5+J+": "+Y)}if(J="crypto",X)this[J]=lA[J];if((Y=$[J])!==void 0)if(Y===!0||Y===!1||Y===0||Y===1)if(Y)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[J]=!0;else throw Error(Ud);else this[J]=!1;else throw Error(U5+J+": "+Y);return this}function JM0($){return new this($).cos()}function YM0($){return new this($).cosh()}function jd($){var Z,J,Y;function X(Q){var G,W,K,V=this;if(!(V instanceof X))return new X(Q);if(V.constructor=X,Wd(Q)){if(V.s=Q.s,i0)if(!Q.d||Q.e>X.maxE)V.e=NaN,V.d=null;else if(Q.e<X.minE)V.e=0,V.d=[0];else V.e=Q.e,V.d=Q.d.slice();else V.e=Q.e,V.d=Q.d?Q.d.slice():Q.d;return}if(K=typeof Q,K==="number"){if(Q===0){V.s=1/Q<0?-1:1,V.e=0,V.d=[0];return}if(Q<0)Q=-Q,V.s=-1;else V.s=1;if(Q===~~Q&&Q<1e7){for(G=0,W=Q;W>=10;W/=10)G++;if(i0)if(G>X.maxE)V.e=NaN,V.d=null;else if(G<X.minE)V.e=0,V.d=[0];else V.e=G,V.d=[Q];else V.e=G,V.d=[Q];return}if(Q*0!==0){if(!Q)V.s=NaN;V.e=NaN,V.d=null;return}return hK(V,Q.toString())}if(K==="string"){if((W=Q.charCodeAt(0))===45)Q=Q.slice(1),V.s=-1;else{if(W===43)Q=Q.slice(1);V.s=1}return Bd.test(Q)?hK(V,Q):mN0(V,Q)}if(K==="bigint"){if(Q<0)Q=-Q,V.s=-1;else V.s=1;return hK(V,Q.toString())}throw Error(U5+Q)}if(X.prototype=X0,X.ROUND_UP=0,X.ROUND_DOWN=1,X.ROUND_CEIL=2,X.ROUND_FLOOR=3,X.ROUND_HALF_UP=4,X.ROUND_HALF_DOWN=5,X.ROUND_HALF_EVEN=6,X.ROUND_HALF_CEIL=7,X.ROUND_HALF_FLOOR=8,X.EUCLID=9,X.config=X.set=ZM0,X.clone=jd,X.isDecimal=Wd,X.abs=dN0,X.acos=pN0,X.acosh=cN0,X.add=iN0,X.asin=nN0,X.asinh=oN0,X.atan=sN0,X.atanh=rN0,X.atan2=aN0,X.cbrt=tN0,X.ceil=eN0,X.clamp=$M0,X.cos=JM0,X.cosh=YM0,X.div=XM0,X.exp=QM0,X.floor=GM0,X.hypot=WM0,X.ln=KM0,X.log=VM0,X.log10=HM0,X.log2=UM0,X.max=BM0,X.min=zM0,X.mod=FM0,X.mul=AM0,X.pow=OM0,X.random=qM0,X.round=jM0,X.sign=NM0,X.sin=MM0,X.sinh=DM0,X.sqrt=wM0,X.sub=LM0,X.sum=TM0,X.tan=RM0,X.tanh=PM0,X.trunc=IM0,$===void 0)$={};if($){if($.defaults!==!0){Y=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(Z=0;Z<Y.length;)if(!$.hasOwnProperty(J=Y[Z++]))$[J]=this[J]}}return X.config($),X}function XM0($,Z){return new this($).div(Z)}function QM0($){return new this($).exp()}function GM0($){return I0($=new this($),$.e+1,3)}function WM0(){var $,Z,J=new this(0);i0=!1;for($=0;$<arguments.length;)if(Z=new this(arguments[$++]),!Z.d){if(Z.s)return i0=!0,new this(1/0);J=Z}else if(J.d)J=J.plus(Z.times(Z));return i0=!0,J.sqrt()}function Wd($){return $ instanceof B6||$&&$.toStringTag===Hd||!1}function KM0($){return new this($).ln()}function VM0($,Z){return new this($).log(Z)}function UM0($){return new this($).log(2)}function HM0($){return new this($).log(10)}function BM0(){return Ad(this,arguments,-1)}function zM0(){return Ad(this,arguments,1)}function FM0($,Z){return new this($).mod(Z)}function AM0($,Z){return new this($).mul(Z)}function OM0($,Z){return new this($).pow(Z)}function qM0($){var Z,J,Y,X,Q=0,G=new this(1),W=[];if($===void 0)$=this.precision;else A8($,1,H5);if(Y=Math.ceil($/x0),!this.crypto)for(;Q<Y;)W[Q++]=Math.random()*1e7|0;else if(crypto.getRandomValues){Z=crypto.getRandomValues(new Uint32Array(Y));for(;Q<Y;)if(X=Z[Q],X>=4290000000)Z[Q]=crypto.getRandomValues(new Uint32Array(1))[0];else W[Q++]=X%1e7}else if(crypto.randomBytes){Z=crypto.randomBytes(Y*=4);for(;Q<Y;)if(X=Z[Q]+(Z[Q+1]<<8)+(Z[Q+2]<<16)+((Z[Q+3]&127)<<24),X>=2140000000)crypto.randomBytes(4).copy(Z,Q);else W.push(X%1e7),Q+=4;Q=Y/4}else throw Error(Ud);if(Y=W[--Q],$%=x0,Y&&$)X=q$(10,x0-$),W[Q]=(Y/X|0)*X;for(;W[Q]===0;Q--)W.pop();if(Q<0)J=0,W=[0];else{J=-1;for(;W[0]===0;J-=x0)W.shift();for(Y=1,X=W[0];X>=10;X/=10)Y++;if(Y<x0)J-=x0-Y}return G.e=J,G.d=W,G}function jM0($){return I0($=new this($),$.e+1,this.rounding)}function NM0($){return $=new this($),$.d?$.d[0]?$.s:0*$.s:$.s||NaN}function MM0($){return new this($).sin()}function DM0($){return new this($).sinh()}function wM0($){return new this($).sqrt()}function LM0($,Z){return new this($).sub(Z)}function TM0(){var $=0,Z=arguments,J=new this(Z[$]);i0=!1;for(;J.s&&++$<Z.length;)J=J.plus(Z[$]);return i0=!0,I0(J,this.precision,this.rounding)}function RM0($){return new this($).tan()}function PM0($){return new this($).tanh()}function IM0($){return I0($=new this($),$.e+1,1)}X0[Symbol.for("nodejs.util.inspect.custom")]=X0.toString;X0[Symbol.toStringTag]="Decimal";var B6=X0.constructor=jd(lA);gK=new B6(gK);uK=new B6(uK);var CM0=O.String.annotate({[F$]:d1.schema("workspace")}).pipe(O.brand("WorkspaceID")),iA=CM0.pipe(u0(($)=>({ascending:(Z)=>$.make(d1.ascending("workspace",Z)),zod:d1.schema("workspace").pipe(P.custom())})));function cK($){let Z={};for(let[J,Y]of Object.entries($.required().shape))Z[J]=Y.nullable();return P.object(Z)}var Nd=E0.create({service:"session.usage"});function EM0($){return/^(New session - |Child session - )\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test($)}function OY($){let Z=$.summary_additions!==null||$.summary_deletions!==null||$.summary_files!==null?{additions:$.summary_additions??0,deletions:$.summary_deletions??0,files:$.summary_files??0,diffs:$.summary_diffs??void 0}:void 0,J=$.share_url?{url:$.share_url}:void 0,Y=$.revert??void 0;return{id:$.id,slug:$.slug,projectID:$.project_id,workspaceID:$.workspace_id??void 0,directory:$.directory,parentID:$.parent_id??void 0,contextFrom:$.context_from??void 0,contextWatermark:$.context_watermark??void 0,title:$.title,version:$.version,summary:Z,share:J,revert:Y,permission:$.permission??void 0,time:{created:$.time_created,updated:$.time_updated,compacting:$.time_compacting??void 0,archived:$.time_archived??void 0}}}function bM0($){return{id:$.id,project_id:$.projectID,workspace_id:$.workspaceID,parent_id:$.parentID,context_from:$.contextFrom,context_watermark:$.contextWatermark,slug:$.slug,directory:$.directory,title:$.title,version:$.version,share_url:$.share?.url,summary_additions:$.summary?.additions,summary_deletions:$.summary?.deletions,summary_files:$.summary?.files,summary_diffs:$.summary?.diffs,revert:$.revert??null,permission:$.permission,time_created:$.time.created,time_updated:$.time.updated,time_compacting:$.time.compacting,time_archived:$.time.archived}}var z6=P.object({id:r0.zod,slug:P.string(),projectID:$9.zod,workspaceID:iA.zod.optional(),directory:P.string(),parentID:r0.zod.optional(),contextFrom:r0.zod.optional(),contextWatermark:i1.zod.optional(),summary:P.object({additions:P.number(),deletions:P.number(),files:P.number(),diffs:vZ.FileDiff.array().optional()}).optional(),share:P.object({url:P.string()}).optional(),title:P.string(),version:P.string(),time:P.object({created:P.number(),updated:P.number(),compacting:P.number().optional(),archived:P.number().optional()}),permission:Q5.Ruleset.zod.optional(),revert:P.object({messageID:i1.zod,partID:MZ.zod.optional(),snapshot:P.string().optional(),diff:P.string().optional()}).optional()}).meta({ref:"Session"}),Md=P.object({id:$9.zod,name:P.string().optional(),worktree:P.string()}).meta({ref:"ProjectSummary"}),_M0=z6.extend({project:Md.nullable()}).meta({ref:"GlobalSession"}),SM0=P.object({parentID:r0.zod.optional(),contextFrom:r0.zod.optional(),contextWatermark:i1.zod.optional(),title:P.string().optional(),permission:z6.shape.permission,workspaceID:iA.zod.optional()}).optional(),fM0=P.object({sessionID:r0.zod,messageID:i1.zod.optional()}),kM0=r0.zod,vM0=r0.zod,yM0=r0.zod,xM0=P.object({sessionID:r0.zod,title:P.string()}),hM0=P.object({sessionID:r0.zod,time:P.number().optional()}),gM0=P.object({sessionID:r0.zod,permission:Q5.Ruleset.zod}),uM0=P.object({sessionID:r0.zod,revert:z6.shape.revert,summary:z6.shape.summary}),mM0=P.object({sessionID:r0.zod,limit:P.number().optional()}),qY={Created:X$.define({type:"session.created",version:1,aggregate:"sessionID",schema:P.object({sessionID:r0.zod,info:z6})}),Updated:X$.define({type:"session.updated",version:1,aggregate:"sessionID",schema:P.object({sessionID:r0.zod,info:cK(z6).extend({share:cK(z6.shape.share.unwrap()).optional(),time:cK(z6.shape.time).optional()})}),busSchema:P.object({sessionID:r0.zod,info:z6})}),Deleted:X$.define({type:"session.deleted",version:1,aggregate:"sessionID",schema:P.object({sessionID:r0.zod,info:z6})}),Diff:L1.define("session.diff",P.object({sessionID:r0.zod,diff:vZ.FileDiff.array()})),Error:L1.define("session.error",P.object({sessionID:r0.zod.optional(),error:P.lazy(()=>b$.Assistant.shape.error)})),RetryAttempt:L1.define("session.retry.attempt",P.object({sessionID:r0.zod,messageID:P.string(),attempt:P.number().int().min(1),maxAttempts:P.number().int().min(1),reason:P.string(),nextDelayMs:P.number().int().nonnegative()}))};function lM0($){let Z=S8.project.vcs?nA.join(S8.worktree,".qitqode","plans"):nA.join(F0.Path.data,"plans");return nA.join(Z,[$.time.created,$.slug].join("-")+".md")}var dM0=($)=>{let Z=(j)=>{if(!Number.isFinite(j))return 0;return j},J=Z($.usage.inputTokens??0),Y=Z($.usage.outputTokens??0),X=Z($.usage.outputTokenDetails?.reasoningTokens??$.usage.reasoningTokens??0),Q=Z($.usage.inputTokenDetails?.cacheReadTokens??$.usage.cachedInputTokens??0),G=Z(Number($.usage.inputTokenDetails?.cacheWriteTokens??$.metadata?.anthropic?.cacheCreationInputTokens??$.metadata?.vertex?.cacheCreationInputTokens??$.metadata?.bedrock?.usage?.cacheWriteInputTokens??$.metadata?.venice?.usage?.cacheCreationInputTokens??0)),W=Z(J-Q-G),V={total:$.usage.totalTokens,input:W,output:Z(Y-X),reasoning:X,cache:{write:G,read:Q}},U=$.usage.raw,H=typeof U?.cost_usd==="number"?U.cost_usd:void 0,B=typeof U?.cost_credits==="number"?U.cost_credits:void 0,z=typeof U?.context_window==="number"?U.context_window:void 0;if(H!==void 0){let j={cost:Z(H),costCredits:Z(B??H),tokens:V,contextWindow:z};return Nd.info("usage",{provider:$.model.providerID,model:$.model.id,source:"qlex",tokens:V,cost:j.cost,costCredits:j.costCredits}),j}let F=$.model.cost?.experimentalOver200K&&V.input+V.cache.read>200000?$.model.cost.experimentalOver200K:$.model.cost,A=Z(new B6(0).add(new B6(V.input).mul(F?.input??0).div(1e6)).add(new B6(V.output).mul(F?.output??0).div(1e6)).add(new B6(V.cache.read).mul(F?.cache?.read??0).div(1e6)).add(new B6(V.cache.write).mul(F?.cache?.write??0).div(1e6)).add(new B6(V.reasoning).mul(F?.output??0).div(1e6)).toNumber());return Nd.info("usage",{provider:$.model.providerID,model:$.model.id,source:"estimated",tokens:V,cost:A}),{cost:A,costCredits:void 0,tokens:V,contextWindow:z}};function*pM0($){let Z=S8.project,J=[m0(I1.project_id,Z.id)];if($?.workspaceID)J.push(m0(I1.workspace_id,$.workspaceID));if(!b0.QITQODE_EXPERIMENTAL_WORKSPACES){if($?.directory)J.push(m0(I1.directory,$.directory))}if($?.roots)J.push(iK(I1.parent_id));if($?.start)J.push(oA(I1.time_updated,$.start));if($?.search)J.push(sA(I1.title,`%${$.search}%`));let Y=$?.limit??100,X=W1.use((Q)=>Q.select().from(I1).where(O$(...J)).orderBy(o6(I1.time_updated)).limit(Y).all());for(let Q of X)yield OY(Q)}function*cM0($){let Z=[];if($?.directory)Z.push(m0(I1.directory,$.directory));if($?.roots)Z.push(iK(I1.parent_id));if($?.start)Z.push(oA(I1.time_updated,$.start));if($?.cursor)Z.push(WX(I1.time_updated,$.cursor));if($?.search)Z.push(sA(I1.title,`%${$.search}%`));if(!$?.archived)Z.push(iK(I1.time_archived));let J=$?.limit??100,Y=W1.use((G)=>{return(Z.length>0?G.select().from(I1).where(O$(...Z)):G.select().from(I1)).orderBy(o6(I1.time_updated),o6(I1.id)).limit(J).all()}),X=[...new Set(Y.map((G)=>G.project_id))],Q=new Map;if(X.length>0){let G=W1.use((W)=>W.select({id:AY.id,name:AY.name,worktree:AY.worktree}).from(AY).where(k5(AY.id,X)).all());for(let W of G)Q.set(W.id,{id:W.id,name:W.name??void 0,worktree:W.worktree})}for(let G of Y){let W=Q.get(G.project_id)??null;yield{...OY(G),project:W}}}var Dd=E0.create({service:"session"}),iM0="New session - ",nM0="Child session - ";function oM0($=!1){return($?nM0:iM0)+new Date().toISOString()}function sM0($){let Z=$.match(/^(.+) \(fork #(\d+)\)$/);if(Z){let J=Z[1],Y=parseInt(Z[2],10);return`${J} (fork #${Y+1})`}return`${$} (fork #1)`}class wd extends Error{sessionID;constructor($){super(`Session ${$} is busy`);this.sessionID=$}}class nK extends S1.Service()("@qitqode/Session"){}var rA=($)=>T.sync(()=>W1.use($)),Ld=T0.effect(nK,T.gen(function*(){let $=yield*l1.Service,Z=yield*aA.Service,J=yield*BY.Service,Y=T.fn("Session.createNext")(function*(b){let y=yield*B0.context,k={id:r0.descending(b.id),slug:JV.create(),version:E$,projectID:y.project.id,directory:b.directory,workspaceID:b.workspaceID,parentID:b.parentID,contextFrom:b.contextFrom,contextWatermark:b.contextWatermark,title:b.title??oM0(!!b.parentID),permission:b.permission,time:{created:Date.now(),updated:Date.now()}};if(Dd.info("created",k),yield*T.sync(()=>X$.run(qY.Created,{sessionID:k.id,info:k})),yield*J.register({sessionID:k.id,actorID:"main",mode:"main",parentActorID:void 0,agent:"main",description:"main agent",contextMode:"full",contextWatermark:void 0,background:!1,lifecycle:"persistent",tools:"INHERIT"}).pipe(T.ignore),!b0.QITQODE_EXPERIMENTAL_WORKSPACES)yield*$.publish(qY.Updated,{sessionID:k.id,info:k});return k}),X=T.fn("Session.get")(function*(b){let y=yield*rA((k)=>k.select().from(I1).where(m0(I1.id,b)).get());if(!y)throw new KX({message:`Session not found: ${b}`});return OY(y)}),Q=T.fn("Session.children")(function*(b){return(yield*rA((k)=>k.select().from(I1).where(O$(m0(I1.parent_id,b))).all())).map(OY)}),G=T.fnUntraced(function*(b){try{let y=yield*X(b),k=yield*Q(b);for(let d of k)yield*G(d.id);let g=yield*B0.directory.pipe(T.as(!0),T.catchCause(()=>T.succeed(!1)));yield*T.sync(()=>{X$.run(qY.Deleted,{sessionID:b,info:y},{publish:g}),X$.remove(b)})}catch(y){Dd.error(y)}}),W=(b)=>T.gen(function*(){return yield*T.sync(()=>X$.run(b$.Event.Updated,{sessionID:b.sessionID,info:b})),b}).pipe(T.withSpan("Session.updateMessage")),K=(b)=>{let y={...b};if(y.state){if(y.state={...y.state},y.state.time)y.state.time={...y.state.time}}return y},V=(b)=>T.gen(function*(){return yield*T.sync(()=>X$.run(b$.Event.PartUpdated,{sessionID:b.sessionID,part:K(b),time:Date.now()})),b}).pipe(T.withSpan("Session.updatePart")),U=T.fn("Session.getPart")(function*(b){let y=W1.use((k)=>k.select().from(I8).where(O$(m0(I8.session_id,b.sessionID),m0(I8.message_id,b.messageID),m0(I8.id,b.partID))).get());if(!y)return;return{...y.data,id:y.id,sessionID:y.session_id,messageID:y.message_id}}),H=T.fn("Session.create")(function*(b){let y=yield*B0.directory,k=yield*B0.workspaceID;return yield*Y({parentID:b?.parentID,contextFrom:b?.contextFrom,contextWatermark:b?.contextWatermark,directory:y,title:b?.title,permission:b?.permission,workspaceID:k})}),B=T.fn("Session.fork")(function*(b){let y=yield*B0.directory,k=yield*X(b.sessionID),g=sM0(k.title),d=yield*Y({directory:y,workspaceID:k.workspaceID,title:g}),p=yield*R({sessionID:b.sessionID,agentID:"*"}),t=new Map;for(let r of p){if(b.messageID&&r.info.id>=b.messageID)break;let G0=i1.ascending();t.set(r.info.id,G0);let O0=r.info.role==="assistant"&&r.info.parentID?t.get(r.info.parentID):void 0,h0=yield*W({...r.info,sessionID:d.id,id:G0,...O0&&{parentID:O0}});for(let u of r.parts)yield*V({...u,id:MZ.ascending(),messageID:h0.id,sessionID:d.id})}return d}),z=(b,y)=>T.sync(()=>X$.run(qY.Updated,{sessionID:b,info:y})),F=T.fn("Session.touch")(function*(b){yield*z(b,{time:{updated:Date.now()}})}),A=T.fn("Session.setTitle")(function*(b){yield*z(b.sessionID,{title:b.title})}),j=T.fn("Session.setArchived")(function*(b){yield*z(b.sessionID,{time:{archived:b.time}})}),N=T.fn("Session.setPermission")(function*(b){yield*z(b.sessionID,{permission:b.permission,time:{updated:Date.now()}})}),L=T.fn("Session.setRevert")(function*(b){yield*z(b.sessionID,{summary:b.summary,time:{updated:Date.now()},revert:b.revert})}),q=T.fn("Session.clearRevert")(function*(b){yield*z(b,{time:{updated:Date.now()},revert:null})}),M=T.fn("Session.setSummary")(function*(b){yield*z(b.sessionID,{time:{updated:Date.now()},summary:b.summary})}),C=T.fn("Session.diff")(function*(b){return yield*Z.read(["session_diff",b]).pipe(T.orElseSucceed(()=>[]))}),R=T.fn("Session.messages")(function*(b){if(b.limit)return b$.page({sessionID:b.sessionID,limit:b.limit,agentID:b.agentID}).items;return Array.from(b$.stream(b.sessionID,{agentID:b.agentID})).reverse()}),w=T.fn("Session.removeMessage")(function*(b){return yield*T.sync(()=>X$.run(b$.Event.Removed,{sessionID:b.sessionID,messageID:b.messageID})),b.messageID}),I=T.fn("Session.removePart")(function*(b){return yield*T.sync(()=>X$.run(b$.Event.PartRemoved,{sessionID:b.sessionID,messageID:b.messageID,partID:b.partID})),b.partID}),_=T.fnUntraced(function*(b){yield*$.publish(b$.Event.PartDelta,b)}),E=T.fn("Session.findMessage")(function*(b,y,k){for(let g of b$.stream(b,{agentID:k?.agentID}))if(y(g))return O1.some(g);return O1.none()}),f=T.fn("Session.lastMainMessageID")(function*(b){return(yield*rA((k)=>k.select({id:w$.id}).from(w$).where(O$(m0(w$.session_id,b),m0(w$.agent_id,"main"))).orderBy(o6(w$.id)).limit(1).get()))?.id});return nK.of({create:H,fork:B,touch:F,get:X,setTitle:A,setArchived:j,setPermission:N,setRevert:L,clearRevert:q,setSummary:M,diff:C,messages:R,children:Q,remove:G,updateMessage:W,removeMessage:w,removePart:I,updatePart:V,getPart:U,updatePartDelta:_,findMessage:E,lastMainMessageID:f})})),rM0=Ld.pipe(T0.provide(BY.defaultLayer),T0.provide(l1.layer),T0.provide(aA.defaultLayer));export{l1 as xj,k8 as yj,hY as zj,v9 as Aj,d7 as Bj,o7 as Cj,JN as Dj,IZ as Ej,nD as Fj,rD as Gj,bU as Hj,JV as Ij,_8 as Jj,z9 as Kj,d1 as Lj,X$ as Mj,r0 as Nj,i1 as Oj,MZ as Pj,Vj as Qj,xV as Rj,X4 as Sj,G4 as Tj,vU as Uj,za as Vj,QX as Wj,VJ as Xj,Aa as Yj,vw as Zj,vZ as _j,X1 as $j,s1 as ak,tb0 as bk,K_0 as ck,U_0 as dk,B_0 as ek,ne as fk,y_0 as gk,x_0 as hk,UW as ik,d3 as jk,BK as kk,rQ as lk,aQ as mk,dh0 as nk,ph0 as ok,ch0 as pk,Gj0 as qk,sh0 as rk,rh0 as sk,tu as tk,ah0 as uk,$m as vk,Zm as wk,q7 as xk,Q5 as yk,Vm as zk,jj0 as Ak,Eg0 as Bk,Um as Ck,gg0 as Dk,mg0 as Ek,lg0 as Fk,IA as Gk,km as Hk,iA as Ik,Xu0 as Jk,Qu0 as Kk,el as Lk,Hd0 as Mk,Bd0 as Nk,Zd as Ok,BY as Pk,EA as Qk,AZ as Rk,X9 as Sk,N7 as Tk,gl as Uk,sl as Vk,b$ as Wk,EM0 as Xk,bM0 as Yk,qY as Zk,lM0 as _k,dM0 as $k,wd as al,nK as bl,rM0 as cl,Y9 as dl,X8 as el};