@eidos.space/just-bash 3.0.3 → 3.0.4

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 (260) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/bin/chunks/{awk2-RLMNTGI7.js → awk2-M5P56WFW.js} +1 -1
  3. package/dist/bin/{shell/chunks/base64-RZRLGMB3.js → chunks/base64-3BBQMQBD.js} +1 -1
  4. package/dist/bin/{shell/chunks/bash-CLP24TE2.js → chunks/bash-JOHLB5EM.js} +1 -1
  5. package/dist/bin/{shell/chunks/cat-LQH5FSAR.js → chunks/cat-QS3FUD2R.js} +1 -1
  6. package/dist/bin/chunks/{chunk-L24QXM5S.js → chunk-2AUW2OVD.js} +1 -1
  7. package/dist/bin/chunks/{chunk-EDTBGO7F.js → chunk-3ERCSYXB.js} +1 -1
  8. package/dist/bin/{shell/chunks/chunk-X4MX6EHF.js → chunks/chunk-46EFQINR.js} +1 -1
  9. package/dist/bin/chunks/{chunk-7NC4CPHS.js → chunk-4HZ2J7WU.js} +1 -1
  10. package/dist/bin/{shell/chunks/chunk-UO5LOD7U.js → chunks/chunk-4J4HK3AP.js} +1 -1
  11. package/dist/bin/chunks/{chunk-PAYQNSZN.js → chunk-4TKEQ5JF.js} +1 -1
  12. package/dist/bin/chunks/{chunk-V2RP73X4.js → chunk-4TZMT56V.js} +1 -1
  13. package/dist/bin/chunks/{chunk-F3GKANW3.js → chunk-5MAZXOIE.js} +1 -1
  14. package/dist/bin/{shell/chunks/chunk-6FSBHK6H.js → chunks/chunk-6CMV7VZ7.js} +1 -1
  15. package/dist/bin/chunks/{chunk-FVRXEJYQ.js → chunk-7X6QFILN.js} +2 -2
  16. package/dist/bin/{shell/chunks/chunk-2SVX7I5P.js → chunks/chunk-A66SLDOH.js} +1 -1
  17. package/dist/bin/{shell/chunks/chunk-Q4UMTSRO.js → chunks/chunk-AIE46WV2.js} +1 -1
  18. package/dist/bin/chunks/{chunk-VBDLSL7Y.js → chunk-CVDY2PJ2.js} +1 -1
  19. package/dist/bin/{shell/chunks/chunk-H7JTIXAO.js → chunks/chunk-DSS5HVJD.js} +1 -1
  20. package/dist/bin/{shell/chunks/chunk-M65CQLJE.js → chunks/chunk-E2TTMLYF.js} +1 -1
  21. package/dist/bin/{shell/chunks/chunk-HN2DCT7T.js → chunks/chunk-E35XCU6G.js} +1 -1
  22. package/dist/bin/chunks/{chunk-JZW7NFK2.js → chunk-EVVJUFZE.js} +1 -1
  23. package/dist/bin/{shell/chunks/chunk-C7ISPH7Y.js → chunks/chunk-FKCULB5D.js} +1 -1
  24. package/dist/bin/chunks/{chunk-YY5PJR7O.js → chunk-G5P37XAS.js} +1 -1
  25. package/dist/bin/{shell/chunks/chunk-CAZ75E7E.js → chunks/chunk-IAGQA4VJ.js} +1 -1
  26. package/dist/bin/chunks/{chunk-22HCD466.js → chunk-JARRTDRA.js} +1 -1
  27. package/dist/bin/chunks/{chunk-JNUX75OX.js → chunk-JW42N6DP.js} +1 -1
  28. package/dist/bin/{shell/chunks/chunk-7UU7KPEM.js → chunks/chunk-LLC5H7UY.js} +1 -1
  29. package/dist/bin/{shell/chunks/chunk-NXVG64T3.js → chunks/chunk-MMSWVFQQ.js} +1 -1
  30. package/dist/bin/chunks/{chunk-2NRAWO6E.js → chunk-MQIPLKAA.js} +1 -1
  31. package/dist/bin/chunks/{chunk-YOKQNNQO.js → chunk-NK4UMOPJ.js} +1 -1
  32. package/dist/bin/{shell/chunks/chunk-OPMLWMNH.js → chunks/chunk-OUWMQLWU.js} +1 -1
  33. package/dist/bin/chunks/{chunk-KFMPGSUT.js → chunk-PEI4ZGEQ.js} +1 -1
  34. package/dist/bin/{shell/chunks/chunk-7AYT3UKI.js → chunks/chunk-PNPB62GH.js} +1 -1
  35. package/dist/bin/chunks/chunk-PUSAQWLR.js +3 -0
  36. package/dist/bin/chunks/{chunk-LAHBP3FW.js → chunk-QMRTESE5.js} +1 -1
  37. package/dist/bin/{shell/chunks/chunk-IZGLHVBB.js → chunks/chunk-RGDGVTPT.js} +1 -1
  38. package/dist/bin/chunks/{chunk-FKVQZWJQ.js → chunk-TO6JCMLQ.js} +1 -1
  39. package/dist/bin/{shell/chunks/chunk-F3WNDKOC.js → chunks/chunk-TVCXF3IW.js} +1 -1
  40. package/dist/bin/chunks/{chunk-J7TUF2VI.js → chunk-V2CUST2J.js} +1 -1
  41. package/dist/bin/{shell/chunks/chunk-XJ37N3S5.js → chunks/chunk-VZTJXRFX.js} +1 -1
  42. package/dist/bin/chunks/{column-AQB3A3PJ.js → column-W6LUR2XZ.js} +1 -1
  43. package/dist/bin/{shell/chunks/comm-Q4VDF6ZO.js → chunks/comm-YSS52S62.js} +1 -1
  44. package/dist/bin/chunks/{cut-ZI2HIAW7.js → cut-VWMTH3YP.js} +1 -1
  45. package/dist/bin/{shell/chunks/diff-YDJ42RKS.js → chunks/diff-E5JNYAA2.js} +1 -1
  46. package/dist/bin/chunks/{env-NY32PQJM.js → env-S6XWV5SK.js} +1 -1
  47. package/dist/bin/chunks/{expand-YYSO35NS.js → expand-AIAYIGRW.js} +1 -1
  48. package/dist/bin/chunks/{flag-coverage-RFKIBJ6L.js → flag-coverage-AIBITXZA.js} +1 -1
  49. package/dist/bin/{shell/chunks/fold-5MF7QZWQ.js → chunks/fold-4X7TIQ32.js} +1 -1
  50. package/dist/bin/chunks/{grep-VAYCFO4O.js → grep-7KM7ZRPL.js} +1 -1
  51. package/dist/bin/chunks/{gzip-UGBQQKIH.js → gzip-UUURHQYK.js} +1 -1
  52. package/dist/bin/chunks/{head-QNC2ZYDO.js → head-2NYUMA2U.js} +1 -1
  53. package/dist/bin/{shell/chunks/html-to-markdown-QEFY7XQR.js → chunks/html-to-markdown-TOIJDAT5.js} +1 -1
  54. package/dist/bin/{shell/chunks/join-EJ73DYTK.js → chunks/join-W23T6UW4.js} +1 -1
  55. package/dist/bin/chunks/{jq-GGTKKMEN.js → jq-PG5TWARX.js} +1 -1
  56. package/dist/bin/chunks/{js-exec-BC6NI55L.js → js-exec-YLOWUQR4.js} +1 -1
  57. package/dist/bin/chunks/{md5sum-MCVDIB35.js → md5sum-XTC5HSJD.js} +1 -1
  58. package/dist/bin/chunks/{nl-KUPLVCTS.js → nl-7NAYBH24.js} +1 -1
  59. package/dist/bin/chunks/{od-YQ5ZUI2H.js → od-BGNLMPXW.js} +1 -1
  60. package/dist/bin/{shell/chunks/paste-A5KKPWXX.js → chunks/paste-KM6YEJO3.js} +1 -1
  61. package/dist/bin/chunks/{python3-BQWDPUBM.js → python3-ABK6N2Y5.js} +1 -1
  62. package/dist/bin/chunks/{rev-PYHOZ4D4.js → rev-YHIGUK3P.js} +1 -1
  63. package/dist/bin/chunks/{rg-BGFMSIVK.js → rg-6FON3TGH.js} +1 -1
  64. package/dist/bin/chunks/{sed-FWA634SN.js → sed-LHKUKSBN.js} +1 -1
  65. package/dist/bin/chunks/{sha1sum-4KF52U3Y.js → sha1sum-VW2AMMXS.js} +1 -1
  66. package/dist/bin/chunks/{sha256sum-6YEPULPX.js → sha256sum-7O5NHH7H.js} +1 -1
  67. package/dist/bin/chunks/{sort-4C6WOKNK.js → sort-3BIIXAER.js} +1 -1
  68. package/dist/bin/chunks/{split-TV7NL7LA.js → split-3DTOTWCO.js} +1 -1
  69. package/dist/bin/chunks/{sqlite3-W777NCI4.js → sqlite3-AUZE77IO.js} +1 -1
  70. package/dist/bin/chunks/{strings-MDD72LR6.js → strings-LQXARN54.js} +1 -1
  71. package/dist/bin/{shell/chunks/tac-C2N4NQ6S.js → chunks/tac-24IIWF3C.js} +1 -1
  72. package/dist/bin/chunks/{tail-BCB5W6JC.js → tail-5BYXLCVJ.js} +1 -1
  73. package/dist/bin/chunks/{tar-DOO744MK.js → tar-PEHGL2NT.js} +1 -1
  74. package/dist/bin/chunks/{tee-UQHPO4OW.js → tee-CPC2RSEW.js} +1 -1
  75. package/dist/bin/chunks/{time-ZPY52VT2.js → time-7GPZMM6F.js} +1 -1
  76. package/dist/bin/chunks/{timeout-5AX3ZS3X.js → timeout-B2L3MWOL.js} +1 -1
  77. package/dist/bin/chunks/{tr-G7K6M6HP.js → tr-SGANQH42.js} +1 -1
  78. package/dist/bin/chunks/{unexpand-QIR4EDPG.js → unexpand-7TJPGTBZ.js} +1 -1
  79. package/dist/bin/chunks/{uniq-I7PVFJR4.js → uniq-VH2XX4GT.js} +1 -1
  80. package/dist/bin/{shell/chunks/wc-6NGWULAP.js → chunks/wc-LGTZO4AP.js} +1 -1
  81. package/dist/bin/chunks/{xan-KX4VPXUN.js → xan-I5ZN33WB.js} +1 -1
  82. package/dist/bin/chunks/{xan-view-JXOZLJ7S.js → xan-view-UGYNQULV.js} +1 -1
  83. package/dist/bin/chunks/{xargs-UWHPYLY7.js → xargs-2NR5N6L3.js} +1 -1
  84. package/dist/bin/chunks/{yq-GCDCJBKB.js → yq-3EZZPCM2.js} +1 -1
  85. package/dist/bin/just-bash.js +72 -72
  86. package/dist/bin/shell/chunks/{awk2-RLMNTGI7.js → awk2-M5P56WFW.js} +1 -1
  87. package/dist/bin/{chunks/base64-RZRLGMB3.js → shell/chunks/base64-3BBQMQBD.js} +1 -1
  88. package/dist/bin/{chunks/bash-CLP24TE2.js → shell/chunks/bash-JOHLB5EM.js} +1 -1
  89. package/dist/bin/{chunks/cat-LQH5FSAR.js → shell/chunks/cat-QS3FUD2R.js} +1 -1
  90. package/dist/bin/shell/chunks/{chunk-L24QXM5S.js → chunk-2AUW2OVD.js} +1 -1
  91. package/dist/bin/shell/chunks/{chunk-EDTBGO7F.js → chunk-3ERCSYXB.js} +1 -1
  92. package/dist/bin/{chunks/chunk-X4MX6EHF.js → shell/chunks/chunk-46EFQINR.js} +1 -1
  93. package/dist/bin/shell/chunks/{chunk-7NC4CPHS.js → chunk-4HZ2J7WU.js} +1 -1
  94. package/dist/bin/{chunks/chunk-UO5LOD7U.js → shell/chunks/chunk-4J4HK3AP.js} +1 -1
  95. package/dist/bin/shell/chunks/{chunk-PAYQNSZN.js → chunk-4TKEQ5JF.js} +1 -1
  96. package/dist/bin/shell/chunks/{chunk-V2RP73X4.js → chunk-4TZMT56V.js} +1 -1
  97. package/dist/bin/shell/chunks/{chunk-F3GKANW3.js → chunk-5MAZXOIE.js} +1 -1
  98. package/dist/bin/{chunks/chunk-6FSBHK6H.js → shell/chunks/chunk-6CMV7VZ7.js} +1 -1
  99. package/dist/bin/shell/chunks/{chunk-FVRXEJYQ.js → chunk-7X6QFILN.js} +2 -2
  100. package/dist/bin/{chunks/chunk-2SVX7I5P.js → shell/chunks/chunk-A66SLDOH.js} +1 -1
  101. package/dist/bin/{chunks/chunk-Q4UMTSRO.js → shell/chunks/chunk-AIE46WV2.js} +1 -1
  102. package/dist/bin/shell/chunks/{chunk-VBDLSL7Y.js → chunk-CVDY2PJ2.js} +1 -1
  103. package/dist/bin/{chunks/chunk-H7JTIXAO.js → shell/chunks/chunk-DSS5HVJD.js} +1 -1
  104. package/dist/bin/{chunks/chunk-M65CQLJE.js → shell/chunks/chunk-E2TTMLYF.js} +1 -1
  105. package/dist/bin/{chunks/chunk-HN2DCT7T.js → shell/chunks/chunk-E35XCU6G.js} +1 -1
  106. package/dist/bin/shell/chunks/{chunk-JZW7NFK2.js → chunk-EVVJUFZE.js} +1 -1
  107. package/dist/bin/{chunks/chunk-C7ISPH7Y.js → shell/chunks/chunk-FKCULB5D.js} +1 -1
  108. package/dist/bin/shell/chunks/{chunk-YY5PJR7O.js → chunk-G5P37XAS.js} +1 -1
  109. package/dist/bin/{chunks/chunk-CAZ75E7E.js → shell/chunks/chunk-IAGQA4VJ.js} +1 -1
  110. package/dist/bin/shell/chunks/{chunk-22HCD466.js → chunk-JARRTDRA.js} +1 -1
  111. package/dist/bin/shell/chunks/{chunk-JNUX75OX.js → chunk-JW42N6DP.js} +1 -1
  112. package/dist/bin/{chunks/chunk-7UU7KPEM.js → shell/chunks/chunk-LLC5H7UY.js} +1 -1
  113. package/dist/bin/{chunks/chunk-NXVG64T3.js → shell/chunks/chunk-MMSWVFQQ.js} +1 -1
  114. package/dist/bin/shell/chunks/{chunk-2NRAWO6E.js → chunk-MQIPLKAA.js} +1 -1
  115. package/dist/bin/shell/chunks/{chunk-YOKQNNQO.js → chunk-NK4UMOPJ.js} +1 -1
  116. package/dist/bin/{chunks/chunk-OPMLWMNH.js → shell/chunks/chunk-OUWMQLWU.js} +1 -1
  117. package/dist/bin/shell/chunks/{chunk-KFMPGSUT.js → chunk-PEI4ZGEQ.js} +1 -1
  118. package/dist/bin/{chunks/chunk-7AYT3UKI.js → shell/chunks/chunk-PNPB62GH.js} +1 -1
  119. package/dist/bin/shell/chunks/chunk-PUSAQWLR.js +3 -0
  120. package/dist/bin/shell/chunks/{chunk-LAHBP3FW.js → chunk-QMRTESE5.js} +1 -1
  121. package/dist/bin/{chunks/chunk-IZGLHVBB.js → shell/chunks/chunk-RGDGVTPT.js} +1 -1
  122. package/dist/bin/shell/chunks/{chunk-FKVQZWJQ.js → chunk-TO6JCMLQ.js} +1 -1
  123. package/dist/bin/{chunks/chunk-F3WNDKOC.js → shell/chunks/chunk-TVCXF3IW.js} +1 -1
  124. package/dist/bin/shell/chunks/{chunk-J7TUF2VI.js → chunk-V2CUST2J.js} +1 -1
  125. package/dist/bin/{chunks/chunk-XJ37N3S5.js → shell/chunks/chunk-VZTJXRFX.js} +1 -1
  126. package/dist/bin/shell/chunks/{column-AQB3A3PJ.js → column-W6LUR2XZ.js} +1 -1
  127. package/dist/bin/{chunks/comm-Q4VDF6ZO.js → shell/chunks/comm-YSS52S62.js} +1 -1
  128. package/dist/bin/shell/chunks/{cut-ZI2HIAW7.js → cut-VWMTH3YP.js} +1 -1
  129. package/dist/bin/{chunks/diff-YDJ42RKS.js → shell/chunks/diff-E5JNYAA2.js} +1 -1
  130. package/dist/bin/shell/chunks/{env-NY32PQJM.js → env-S6XWV5SK.js} +1 -1
  131. package/dist/bin/shell/chunks/{expand-YYSO35NS.js → expand-AIAYIGRW.js} +1 -1
  132. package/dist/bin/shell/chunks/{flag-coverage-RFKIBJ6L.js → flag-coverage-AIBITXZA.js} +1 -1
  133. package/dist/bin/{chunks/fold-5MF7QZWQ.js → shell/chunks/fold-4X7TIQ32.js} +1 -1
  134. package/dist/bin/shell/chunks/{grep-VAYCFO4O.js → grep-7KM7ZRPL.js} +1 -1
  135. package/dist/bin/shell/chunks/{gzip-UGBQQKIH.js → gzip-UUURHQYK.js} +1 -1
  136. package/dist/bin/shell/chunks/{head-QNC2ZYDO.js → head-2NYUMA2U.js} +1 -1
  137. package/dist/bin/{chunks/html-to-markdown-QEFY7XQR.js → shell/chunks/html-to-markdown-TOIJDAT5.js} +1 -1
  138. package/dist/bin/{chunks/join-EJ73DYTK.js → shell/chunks/join-W23T6UW4.js} +1 -1
  139. package/dist/bin/shell/chunks/{jq-GGTKKMEN.js → jq-PG5TWARX.js} +1 -1
  140. package/dist/bin/shell/chunks/{js-exec-BC6NI55L.js → js-exec-YLOWUQR4.js} +1 -1
  141. package/dist/bin/shell/chunks/{md5sum-MCVDIB35.js → md5sum-XTC5HSJD.js} +1 -1
  142. package/dist/bin/shell/chunks/{nl-KUPLVCTS.js → nl-7NAYBH24.js} +1 -1
  143. package/dist/bin/shell/chunks/{od-YQ5ZUI2H.js → od-BGNLMPXW.js} +1 -1
  144. package/dist/bin/{chunks/paste-A5KKPWXX.js → shell/chunks/paste-KM6YEJO3.js} +1 -1
  145. package/dist/bin/shell/chunks/{python3-BQWDPUBM.js → python3-ABK6N2Y5.js} +1 -1
  146. package/dist/bin/shell/chunks/{rev-PYHOZ4D4.js → rev-YHIGUK3P.js} +1 -1
  147. package/dist/bin/shell/chunks/{rg-BGFMSIVK.js → rg-6FON3TGH.js} +1 -1
  148. package/dist/bin/shell/chunks/{sed-FWA634SN.js → sed-LHKUKSBN.js} +1 -1
  149. package/dist/bin/shell/chunks/{sha1sum-4KF52U3Y.js → sha1sum-VW2AMMXS.js} +1 -1
  150. package/dist/bin/shell/chunks/{sha256sum-6YEPULPX.js → sha256sum-7O5NHH7H.js} +1 -1
  151. package/dist/bin/shell/chunks/{sort-4C6WOKNK.js → sort-3BIIXAER.js} +1 -1
  152. package/dist/bin/shell/chunks/{split-TV7NL7LA.js → split-3DTOTWCO.js} +1 -1
  153. package/dist/bin/shell/chunks/{sqlite3-W777NCI4.js → sqlite3-AUZE77IO.js} +1 -1
  154. package/dist/bin/shell/chunks/{strings-MDD72LR6.js → strings-LQXARN54.js} +1 -1
  155. package/dist/bin/{chunks/tac-C2N4NQ6S.js → shell/chunks/tac-24IIWF3C.js} +1 -1
  156. package/dist/bin/shell/chunks/{tail-BCB5W6JC.js → tail-5BYXLCVJ.js} +1 -1
  157. package/dist/bin/shell/chunks/{tar-DOO744MK.js → tar-PEHGL2NT.js} +1 -1
  158. package/dist/bin/shell/chunks/{tee-UQHPO4OW.js → tee-CPC2RSEW.js} +1 -1
  159. package/dist/bin/shell/chunks/{time-ZPY52VT2.js → time-7GPZMM6F.js} +1 -1
  160. package/dist/bin/shell/chunks/{timeout-5AX3ZS3X.js → timeout-B2L3MWOL.js} +1 -1
  161. package/dist/bin/shell/chunks/{tr-G7K6M6HP.js → tr-SGANQH42.js} +1 -1
  162. package/dist/bin/shell/chunks/{unexpand-QIR4EDPG.js → unexpand-7TJPGTBZ.js} +1 -1
  163. package/dist/bin/shell/chunks/{uniq-I7PVFJR4.js → uniq-VH2XX4GT.js} +1 -1
  164. package/dist/bin/{chunks/wc-6NGWULAP.js → shell/chunks/wc-LGTZO4AP.js} +1 -1
  165. package/dist/bin/shell/chunks/{xan-KX4VPXUN.js → xan-I5ZN33WB.js} +1 -1
  166. package/dist/bin/shell/chunks/{xan-view-JXOZLJ7S.js → xan-view-UGYNQULV.js} +1 -1
  167. package/dist/bin/shell/chunks/{xargs-UWHPYLY7.js → xargs-2NR5N6L3.js} +1 -1
  168. package/dist/bin/shell/chunks/{yq-GCDCJBKB.js → yq-3EZZPCM2.js} +1 -1
  169. package/dist/bin/shell/shell.js +73 -73
  170. package/dist/bundle/browser.js +3 -3
  171. package/dist/bundle/chunks/{awk2-LA3USKJP.js → awk2-2OROQ6TB.js} +1 -1
  172. package/dist/bundle/chunks/{base64-C2AIWVNC.js → base64-6IJBGYEA.js} +1 -1
  173. package/dist/bundle/chunks/{bash-YZ33HQZQ.js → bash-AT4DFUJM.js} +1 -1
  174. package/dist/bundle/chunks/{cat-TSFMZVYS.js → cat-Z4ATD4R2.js} +1 -1
  175. package/dist/bundle/chunks/{chunk-YCLFEX4T.js → chunk-4HV7HIHS.js} +1 -1
  176. package/dist/bundle/chunks/{chunk-S443BAN4.js → chunk-6HPVYB3B.js} +1 -1
  177. package/dist/bundle/chunks/chunk-6JHJPYPW.js +2 -0
  178. package/dist/bundle/chunks/{chunk-GJC3WVOW.js → chunk-7QLDUSO4.js} +1 -1
  179. package/dist/bundle/chunks/{chunk-RLAAFSP3.js → chunk-AAH22H6T.js} +1 -1
  180. package/dist/bundle/chunks/{chunk-OVGANXCG.js → chunk-AEU2AH3H.js} +1 -1
  181. package/dist/bundle/chunks/{chunk-XCQWV4AU.js → chunk-AK7Q2PNY.js} +1 -1
  182. package/dist/bundle/chunks/{chunk-S3LEJEPP.js → chunk-EO3OLY7H.js} +1 -1
  183. package/dist/bundle/chunks/{chunk-XDGLKIHR.js → chunk-G372PPPL.js} +1 -1
  184. package/dist/bundle/chunks/{chunk-U73A73IE.js → chunk-HGXBBQKY.js} +1 -1
  185. package/dist/bundle/chunks/{chunk-46RN27KI.js → chunk-IJZY7GO5.js} +1 -1
  186. package/dist/bundle/chunks/{chunk-VLCHOJWK.js → chunk-K57W527P.js} +1 -1
  187. package/dist/bundle/chunks/{chunk-GSPYNYZA.js → chunk-K5VKTLDB.js} +1 -1
  188. package/dist/bundle/chunks/{chunk-VPADYNBD.js → chunk-KHCKEMD6.js} +1 -1
  189. package/dist/bundle/chunks/{chunk-ICIEVHY5.js → chunk-KTWS34JV.js} +1 -1
  190. package/dist/bundle/chunks/{chunk-Q7H5W7YE.js → chunk-KUSBC35O.js} +2 -2
  191. package/dist/bundle/chunks/{chunk-UZR7BRBM.js → chunk-LJ64BU4T.js} +1 -1
  192. package/dist/bundle/chunks/{chunk-4N6J7B5P.js → chunk-MHOVZCXO.js} +1 -1
  193. package/dist/bundle/chunks/{chunk-UP6MSJGD.js → chunk-MLX6LCEH.js} +1 -1
  194. package/dist/bundle/chunks/{chunk-2JIPICV3.js → chunk-MSHY3ROY.js} +1 -1
  195. package/dist/bundle/chunks/{chunk-6VAT5Z2D.js → chunk-NHIFOLSI.js} +1 -1
  196. package/dist/bundle/chunks/{chunk-T4TFLF3R.js → chunk-O66VCFMW.js} +1 -1
  197. package/dist/bundle/chunks/{chunk-7JHM3L42.js → chunk-PAZDJXQ2.js} +1 -1
  198. package/dist/bundle/chunks/{chunk-FW54FHZR.js → chunk-PVSBJ7RN.js} +1 -1
  199. package/dist/bundle/chunks/{chunk-XYXUMFSU.js → chunk-PXGSAN5M.js} +1 -1
  200. package/dist/bundle/chunks/{chunk-FJK43EBQ.js → chunk-RCQPTKLM.js} +1 -1
  201. package/dist/bundle/chunks/{chunk-6LASZU3O.js → chunk-RLPRNBSA.js} +1 -1
  202. package/dist/bundle/chunks/{chunk-GGC5NEPZ.js → chunk-WLZQ2YQT.js} +1 -1
  203. package/dist/bundle/chunks/{chunk-FX7KQCEA.js → chunk-WQQIVUNI.js} +1 -1
  204. package/dist/bundle/chunks/{chunk-EBAPSGAO.js → chunk-WWZU6WGV.js} +1 -1
  205. package/dist/bundle/chunks/{chunk-LNBPBRV4.js → chunk-XY467F65.js} +1 -1
  206. package/dist/bundle/chunks/{chunk-KD3KENL6.js → chunk-YAIN5HNN.js} +1 -1
  207. package/dist/bundle/chunks/{chunk-HJBTD7PY.js → chunk-YOVBUIVE.js} +1 -1
  208. package/dist/bundle/chunks/{chunk-XHLMAZX2.js → chunk-ZALQAZQS.js} +1 -1
  209. package/dist/bundle/chunks/{chunk-N6DXJ2JN.js → chunk-ZSV2XR53.js} +1 -1
  210. package/dist/bundle/chunks/{chunk-ACSZB4FE.js → chunk-ZUKEFBW2.js} +1 -1
  211. package/dist/bundle/chunks/{column-XT6UFXNQ.js → column-WWAENDUI.js} +1 -1
  212. package/dist/bundle/chunks/{comm-VV2LDX2J.js → comm-RQ5XNTJM.js} +1 -1
  213. package/dist/bundle/chunks/{cut-OKARJCCV.js → cut-QWB7NUKQ.js} +1 -1
  214. package/dist/bundle/chunks/{diff-5MIVVRRQ.js → diff-X5UWGQ3A.js} +1 -1
  215. package/dist/bundle/chunks/{env-36M5BO7M.js → env-ZRQ43ZZD.js} +1 -1
  216. package/dist/bundle/chunks/{expand-JSPG6VOP.js → expand-EAKN4OXQ.js} +1 -1
  217. package/dist/bundle/chunks/{flag-coverage-YKB23BRI.js → flag-coverage-G33S37PG.js} +1 -1
  218. package/dist/bundle/chunks/{fold-4TQNYMSW.js → fold-D373LLSA.js} +1 -1
  219. package/dist/bundle/chunks/{grep-V3LQVMRQ.js → grep-SFR3IZ6K.js} +1 -1
  220. package/dist/bundle/chunks/{gzip-O5ASJAFY.js → gzip-CVIVKFF2.js} +1 -1
  221. package/dist/bundle/chunks/{head-442HYESI.js → head-FXWZSGHI.js} +1 -1
  222. package/dist/bundle/chunks/{html-to-markdown-WGBAMDHY.js → html-to-markdown-2JNCRZB7.js} +1 -1
  223. package/dist/bundle/chunks/{join-TBRGI3LQ.js → join-CTDW75RI.js} +1 -1
  224. package/dist/bundle/chunks/{jq-4XLYLOS5.js → jq-67Y32ADP.js} +1 -1
  225. package/dist/bundle/chunks/{js-exec-N5KEZBH7.js → js-exec-2N7YE6ER.js} +1 -1
  226. package/dist/bundle/chunks/{md5sum-SPU24VSG.js → md5sum-P4DXUWPM.js} +1 -1
  227. package/dist/bundle/chunks/{nl-WSDW7I4O.js → nl-SLUVZ3TI.js} +1 -1
  228. package/dist/bundle/chunks/{od-WOKFDJTP.js → od-LKZJLHVE.js} +1 -1
  229. package/dist/bundle/chunks/{paste-7JC6S4DX.js → paste-LIMPDS6X.js} +1 -1
  230. package/dist/bundle/chunks/{python3-POMOR4OA.js → python3-2AQWCGWL.js} +1 -1
  231. package/dist/bundle/chunks/{rev-5EHFX4EJ.js → rev-W4N6QLP5.js} +1 -1
  232. package/dist/bundle/chunks/{rg-S4FXYXWB.js → rg-QVQNBE57.js} +1 -1
  233. package/dist/bundle/chunks/{sed-S5UIK574.js → sed-6Q2OKXY5.js} +1 -1
  234. package/dist/bundle/chunks/{sha1sum-2PTOAFR6.js → sha1sum-UMR2BPZO.js} +1 -1
  235. package/dist/bundle/chunks/{sha256sum-NS7D3IXX.js → sha256sum-RPSA24NY.js} +1 -1
  236. package/dist/bundle/chunks/{sort-SW2YEO5B.js → sort-JRCEWR75.js} +1 -1
  237. package/dist/bundle/chunks/{split-4KKZZXXE.js → split-KAF43FGD.js} +1 -1
  238. package/dist/bundle/chunks/{sqlite3-CGOEFJAO.js → sqlite3-QVOVCFW4.js} +1 -1
  239. package/dist/bundle/chunks/{strings-6WDHLGMX.js → strings-5J5KERRU.js} +1 -1
  240. package/dist/bundle/chunks/{tac-2STMMJYW.js → tac-VQW3WZHD.js} +1 -1
  241. package/dist/bundle/chunks/{tail-R4PCA2C4.js → tail-CDOI2GPL.js} +1 -1
  242. package/dist/bundle/chunks/{tar-STHHZTZ6.js → tar-AIQ24PFK.js} +1 -1
  243. package/dist/bundle/chunks/{tee-YUZ2FKCJ.js → tee-SYEPHRRB.js} +1 -1
  244. package/dist/bundle/chunks/{time-D4LNBSWX.js → time-DAPKFIOQ.js} +1 -1
  245. package/dist/bundle/chunks/{timeout-YDCRSLPQ.js → timeout-4OGTKQLR.js} +1 -1
  246. package/dist/bundle/chunks/{tr-36LHWFRQ.js → tr-P4RRZUZU.js} +1 -1
  247. package/dist/bundle/chunks/{unexpand-CADSA4VO.js → unexpand-V5HMWT4F.js} +1 -1
  248. package/dist/bundle/chunks/{uniq-XSIZR6PB.js → uniq-ON4F3TGM.js} +1 -1
  249. package/dist/bundle/chunks/{wc-LF7NU4LA.js → wc-ASC6XKZW.js} +1 -1
  250. package/dist/bundle/chunks/{xan-Y6WF3IRG.js → xan-UGHT4U42.js} +1 -1
  251. package/dist/bundle/chunks/xan-view-HLIT2HYA.js +2 -0
  252. package/dist/bundle/chunks/{xargs-MGZPH7AX.js → xargs-7BH6BYXE.js} +1 -1
  253. package/dist/bundle/chunks/{yq-4QJW3EQG.js → yq-5UQZWCTQ.js} +1 -1
  254. package/dist/bundle/index.cjs +76 -76
  255. package/dist/bundle/index.js +52 -52
  256. package/package.json +1 -1
  257. package/dist/bin/chunks/chunk-VZK4FHWJ.js +0 -3
  258. package/dist/bin/shell/chunks/chunk-VZK4FHWJ.js +0 -3
  259. package/dist/bundle/chunks/chunk-NRSASXYY.js +0 -2
  260. package/dist/bundle/chunks/xan-view-HDVKHFC2.js +0 -2
@@ -3,7 +3,7 @@
3
3
  This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,Fe=class extends Error{violation;constructor(e,r){super(e+nU),this.violation=r,this.name="SecurityViolationError"}},Ft=!xo&&S1?new S1:null,sU=1e3;E1={enabled:!0,auditMode:!1};Et=class t{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(e){let r=oU(e);if(!t.instance)t.instance=new t(r);else{let n=t.instance.config;if(r.enabled!==n.enabled||r.auditMode!==n.auditMode)throw new Error(`DefenseInDepthBox config conflict: requested {enabled: ${r.enabled}, auditMode: ${r.auditMode}} but singleton already has {enabled: ${n.enabled}, auditMode: ${n.auditMode}}. All Bash instances must use the same defense-in-depth security settings, or call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return t.instance}static resetInstance(){t.instance&&(t.instance.forceDeactivate(),t.instance=null),t.trustedExecutionDepth.clear()}static isInSandboxedContext(){return Ft?Ft?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(Ft)return Ft?.getStore()?.executionId}static enterTrustedScope(e){let r=t.trustedExecutionDepth.get(e)??0;t.trustedExecutionDepth.set(e,r+1)}static leaveTrustedScope(e){let r=t.trustedExecutionDepth.get(e);if(r){if(r===1){t.trustedExecutionDepth.delete(e);return}t.trustedExecutionDepth.set(e,r-1)}}static isTrustedScopeActive(e){return e?(t.trustedExecutionDepth.get(e)??0)>0:!1}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let r=this.contextCache.get(e);return r||(r={sandboxActive:!0,executionId:e},this.contextCache.set(e,r)),r}getPreferredActiveExecutionId(){if(this.activeExecutionIds.size!==0)for(let e of this.activeExecutionIds)return e}static bindCurrentContext(e){if(!Ft)return e;let r=t.instance,n=Ft.getStore(),s=n?.sandboxActive===!0?n.executionId:r?.getPreferredActiveExecutionId();if(!s)return e;let i=r?.getCachedContext(s)??{sandboxActive:!0,executionId:s};return((...o)=>{let a=t.instance;if(!(a&&!a.isExecutionIdActive(s)&&(a.recordViolation("bound_callback_after_deactivate","bound callback","Bound callback blocked after originating execution was deactivated"),!a.config.auditMode)))return iU(i,e,...o)})}isEnabled(){return this.config.enabled===!0&&Ft!==null&&!xo}updateConfig(e){this.config={...this.config,...e}}activate(){if(xo||!this.config.enabled||!Ft){let n=wS(),s=!1;return{run:i=>s?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):i(),deactivate:()=>{s=!0},executionId:n}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let e=wS(),r=!1;return{run:n=>r?Promise.reject(new Error("DefenseInDepthBox handle is deactivated and cannot run new work")):(this.activeExecutionIds.add(e),Ft.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{r||(r=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,r){return e===globalThis?`globalThis.${r}`:e===process?`process.${r}`:e===Error?`Error.${r}`:e===Function.prototype?`Function.prototype.${r}`:e===Object.prototype?`Object.prototype.${r}`:`<object>.${r}`}static runTrusted(e){if(!Ft)return e();let r=Ft.getStore();if(!r)return e();let{executionId:n}=r;return Ft.run({...r,trusted:!0},()=>{t.enterTrustedScope(n);try{let s=e();return typeof s=="object"&&s!==null&&"finally"in s&&typeof s.finally=="function"?s.finally(()=>{t.leaveTrustedScope(n)}):(t.leaveTrustedScope(n),s)}catch(s){throw t.leaveTrustedScope(n),s}})}static async runTrustedAsync(e){if(!Ft)return e();let r=Ft.getStore();if(!r)return e();let{executionId:n}=r;return Ft.run({...r,trusted:!0},async()=>{t.enterTrustedScope(n);try{return await e()}finally{t.leaveTrustedScope(n)}})}shouldBlock(){if(xo||this.config.auditMode||!Ft)return!1;let e=Ft?.getStore();return!(e?.sandboxActive!==!0||e.trusted||t.isTrustedScopeActive(e.executionId))}recordViolation(e,r,n){let s={timestamp:Date.now(),type:e,message:n,path:r,stack:new Error().stack,executionId:Ft?.getStore()?.executionId};if(this.violations.length<sU&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(i){console.debug("[DefenseInDepthBox] onViolation callback threw:",i instanceof Error?i.message:i)}return s}createBlockingProxy(e,r,n){let s=this;return new Proxy(e,{apply(i,o,a){if(s.shouldBlock()){let l=`${r} is blocked during script execution`,c=s.recordViolation(n,r,l);throw new Fe(l,c)}return s.config.auditMode&&Ft?.getStore()?.sandboxActive===!0&&s.recordViolation(n,r,`${r} called (audit mode)`),Reflect.apply(i,o,a)},construct(i,o,a){if(s.shouldBlock()){let l=`${r} constructor is blocked during script execution`,c=s.recordViolation(n,r,l);throw new Fe(l,c)}return s.config.auditMode&&Ft?.getStore()?.sandboxActive===!0&&s.recordViolation(n,r,`${r} constructor called (audit mode)`),Reflect.construct(i,o,a)}})}createBlockingObjectProxy(e,r,n,s){let i=this;return new Proxy(e,{get(o,a,l){if(i.shouldBlock()){if(s&&typeof a=="string"&&s.has(a))return Reflect.get(o,a,l);let c=`${r}.${String(a)}`,u=`${c} is blocked during script execution`,f=i.recordViolation(n,c,u);throw new Fe(u,f)}if(i.config.auditMode&&Ft?.getStore()?.sandboxActive===!0){let c=`${r}.${String(a)}`;i.recordViolation(n,c,`${c} accessed (audit mode)`)}return Reflect.get(o,a,l)},set(o,a,l,c){if(i.shouldBlock()){let u=`${r}.${String(a)}`,f=`${u} modification is blocked during script execution`,h=i.recordViolation(n,u,f);throw new Fe(f,h)}return Reflect.set(o,a,l,c)},ownKeys(o){if(i.shouldBlock()){let a=`${r} enumeration is blocked during script execution`,l=i.recordViolation(n,r,a);throw new Fe(a,l)}return Reflect.ownKeys(o)},getOwnPropertyDescriptor(o,a){if(i.shouldBlock()){let l=`${r}.${String(a)}`,c=`${l} descriptor access is blocked during script execution`,u=i.recordViolation(n,l,c);throw new Fe(c,u)}return Reflect.getOwnPropertyDescriptor(o,a)},has(o,a){if(i.shouldBlock()){let l=`${r}.${String(a)}`,c=`${l} existence check is blocked during script execution`,u=i.recordViolation(n,l,c);throw new Fe(c,u)}return Reflect.has(o,a)},deleteProperty(o,a){if(i.shouldBlock()){let l=`${r}.${String(a)}`,c=`${l} deletion is blocked during script execution`,u=i.recordViolation(n,l,c);throw new Fe(c,u)}return Reflect.deleteProperty(o,a)},setPrototypeOf(o,a){if(i.shouldBlock()){let l=`${r} setPrototypeOf is blocked during script execution`,c=i.recordViolation(n,r,l);throw new Fe(l,c)}return Reflect.setPrototypeOf(o,a)},defineProperty(o,a,l){if(i.shouldBlock()){let c=`${r}.${String(a)}`,u=`${c} defineProperty is blocked during script execution`,f=i.recordViolation(n,c,u);throw new Fe(u,f)}return Reflect.defineProperty(o,a,l)}})}applyPatches(){this.patchFailures=[];let e=b1(),r=new Set(["process_send","process_channel","process_stdout","process_stderr"]);for(let i of e)r.has(i.violationType)||this.applyPatch(i);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.lockWellKnownSymbols(),this.protectProxyRevocable();let n=["Function.prototype.constructor","Module._load"],s=this.patchFailures.filter(i=>n.includes(i));if(s.length>0)throw this.restorePatches(),new Error(`DefenseInDepthBox: critical patches failed: ${s.join(", ")}`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(e){this.patchFailures.push("AsyncFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(e){this.patchFailures.push("GeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,r=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==r&&this.patchPrototypeConstructor(e.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(e){this.patchFailures.push("AsyncGeneratorFunction.prototype.constructor"),console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let r=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:r});let n=r?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(s){if(e.shouldBlock()){let i="Error.prepareStackTrace modification is blocked during script execution",o=e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",i);throw new Fe(i,o)}e.config.auditMode&&Ft?.getStore()?.sandboxActive===!0&&e.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),n=s},configurable:!0})}catch(r){this.patchFailures.push("Error.prepareStackTrace"),console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",r instanceof Error?r.message:r)}}protectPromiseThen(){let e=this;try{let i=function(...o){return Ft.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation("promise_then_after_deactivate","Promise.then","Promise.then callback is blocked after defense deactivation"),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,o);if(this.kind==="fulfilled")return o[0];throw o[0]}return Reflect.apply(this.cb,void 0,o)})};var r=i;let n=Object.getOwnPropertyDescriptor(Promise.prototype,"then");this.originalDescriptors.push({target:Promise.prototype,prop:"then",descriptor:n});let s=n?.value;if(typeof s!="function")return;Object.defineProperty(Promise.prototype,"then",{value:function(a,l){if(!Ft)return Reflect.apply(s,this,[a,l]);let c=Ft.getStore(),u=c?.sandboxActive===!0&&c.trusted!==!0?c.executionId:void 0;if(!u)return Reflect.apply(s,this,[a,l]);let f=e.getCachedContext(u),h=(d,p)=>typeof d!="function"?d:i.bind({box:e,executionId:u,captured:f,cb:d,kind:p});return Reflect.apply(s,this,[h(a,"fulfilled"),h(l,"rejected")])},writable:!0,configurable:!0})}catch(n){this.patchFailures.push("Promise.prototype.then"),console.debug("[DefenseInDepthBox] Could not protect Promise.prototype.then:",n instanceof Error?n.message:n)}}patchPrototypeConstructor(e,r,n){let s=this;try{let i=Object.getOwnPropertyDescriptor(e,"constructor");this.originalDescriptors.push({target:e,prop:"constructor",descriptor:i});let o=i?.value;Object.defineProperty(e,"constructor",{get(){if(s.shouldBlock()){let a=`${r} access is blocked during script execution`,l=s.recordViolation(n,r,a);throw new Fe(a,l)}return s.config.auditMode&&Ft?.getStore()?.sandboxActive===!0&&s.recordViolation(n,r,`${r} accessed (audit mode)`),o},set(a){if(s.shouldBlock()){let l=`${r} modification is blocked during script execution`,c=s.recordViolation(n,r,l);throw new Fe(l,c)}Object.defineProperty(this,"constructor",{value:a,writable:!0,configurable:!0})},configurable:!0})}catch(i){this.patchFailures.push(r),console.debug(`[DefenseInDepthBox] Could not patch ${r}:`,i instanceof Error?i.message:i)}}protectProcessMainModule(){if(typeof process>"u")return;let e=this;try{let r=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:r});let n=r?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let s="process.mainModule access is blocked during script execution",i=e.recordViolation("process_main_module","process.mainModule",s);throw new Fe(s,i)}return e.config.auditMode&&Ft?.getStore()?.sandboxActive===!0&&e.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let i="process.mainModule modification is blocked during script execution",o=e.recordViolation("process_main_module","process.mainModule",i);throw new Fe(i,o)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(r){this.patchFailures.push("process.mainModule"),console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",r instanceof Error?r.message:r)}}protectProcessExecPath(){if(typeof process>"u")return;let e=this;try{let r=Object.getOwnPropertyDescriptor(process,"execPath");this.originalDescriptors.push({target:process,prop:"execPath",descriptor:r});let n=r?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let s="process.execPath access is blocked during script execution",i=e.recordViolation("process_exec_path","process.execPath",s);throw new Fe(s,i)}return e.config.auditMode&&Ft?.getStore()?.sandboxActive===!0&&e.recordViolation("process_exec_path","process.execPath","process.execPath accessed (audit mode)"),n},set(s){if(e.shouldBlock()){let i="process.execPath modification is blocked during script execution",o=e.recordViolation("process_exec_path","process.execPath",i);throw new Fe(i,o)}Object.defineProperty(process,"execPath",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(r){this.patchFailures.push("process.execPath"),console.debug("[DefenseInDepthBox] Could not protect process.execPath:",r instanceof Error?r.message:r)}}lockWellKnownSymbols(){let e=(r,n)=>{try{let s=Object.getOwnPropertyDescriptor(r,n);if(s?.configurable){if("value"in s){Object.defineProperty(r,n,{...s,configurable:!1,writable:!1});return}Object.defineProperty(r,n,{...s,configurable:!1})}}catch{}};for(let r of[Array,Map,Set,RegExp,Promise])e(r,Symbol.species);for(let r of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(r,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let r of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,r);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let r of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(r,Symbol.toStringTag);try{let r=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");this.originalDescriptors.push({target:Error,prop:"stackTraceLimit",descriptor:r}),Object.defineProperty(Error,"stackTraceLimit",{value:Error.stackTraceLimit,writable:!1,configurable:!0})}catch{}}protectProxyRevocable(){let e=this;try{let r=Proxy.revocable;if(typeof r!="function")return;let n=Object.getOwnPropertyDescriptor(Proxy,"revocable");this.originalDescriptors.push({target:Proxy,prop:"revocable",descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(i,o){if(e.shouldBlock()){let a="Proxy.revocable is blocked during script execution",l=e.recordViolation("proxy","Proxy.revocable",a);throw new Fe(a,l)}return e.config.auditMode&&Ft?.getStore()?.sandboxActive===!0&&e.recordViolation("proxy","Proxy.revocable","Proxy.revocable called (audit mode)"),r(i,o)},writable:!1,configurable:!0})}catch(r){this.patchFailures.push("Proxy.revocable"),console.debug("[DefenseInDepthBox] Could not protect Proxy.revocable:",r instanceof Error?r.message:r)}}protectDynamicImport(){if(!(xo||t.importHooksRegistered))try{let e=this,r=require("node:module"),n=new Set;for(let o of r.builtinModules??[]){let a=o.startsWith("node:")?o.slice(5):o;n.add(a);let l=a.indexOf("/");l>0&&n.add(a.slice(0,l))}let s=o=>{if(o.startsWith("./")||o.startsWith("../")||o.startsWith("/")||o.startsWith("file:")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("http:")||o.startsWith("https:"))return!1;let a=o.startsWith("node:")?o.slice(5):o;if(!a)return!1;if(typeof r.isBuiltin=="function"&&r.isBuiltin(a)||n.has(a))return!0;let l=a.indexOf("/");return l>0&&n.has(a.slice(0,l))},i=()=>{let o=Ft?.getStore();return e.config.auditMode===!0&&o?.sandboxActive===!0&&o.trusted!==!0&&!t.isTrustedScopeActive(o.executionId)};if(typeof r.registerHooks=="function"){r.registerHooks({resolve(o,a,l){if(o.startsWith("data:")||o.startsWith("blob:"))throw new Error(`dynamic import of ${o.startsWith("data:")?"data:":"blob:"} URLs is blocked by defense-in-depth`);if(s(o)){let c=`import(${o})`,u=`dynamic import of Node.js builtin '${o}' is blocked during script execution`;if(e.shouldBlock()){let f=e.recordViolation("dynamic_import_builtin",c,u);throw new Fe(u,f)}i()&&e.recordViolation("dynamic_import_builtin",c,`dynamic import of Node.js builtin '${o}' called (audit mode)`)}return l(o,a)}}),t.importHooksRegistered=!0;return}if(typeof r.register=="function"){let o=["export async function resolve(specifier, context, nextResolve) {",' if (specifier.startsWith("data:") || specifier.startsWith("blob:")) {',' throw new Error("dynamic import of " + (specifier.startsWith("data:") ? "data:" : "blob:") + " URLs is blocked by defense-in-depth");'," }"," return nextResolve(specifier, context);","}"].join(`
4
4
  `);r.register(`data:text/javascript,${encodeURIComponent(o)}`),t.importHooksRegistered=!0}}catch(e){console.debug("[DefenseInDepthBox] Could not register import() hooks:",e instanceof Error?e.message:e)}}protectModuleLoad(){if(!xo)try{let e=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(e=o.constructor)}if(!e&&typeof require<"u"&&typeof require.main<"u"&&(e=require.main.constructor),!e||typeof e._load!="function")return;let r=e._load,n=Object.getOwnPropertyDescriptor(e,"_load");this.originalDescriptors.push({target:e,prop:"_load",descriptor:n});let i=this.createBlockingProxy(r,"Module._load","module_load");Object.defineProperty(e,"_load",{value:i,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._load"),console.debug("[DefenseInDepthBox] Could not protect Module._load:",e instanceof Error?e.message:e)}}protectModuleResolveFilename(){if(!xo)try{let e=null;if(typeof process<"u"){let o=process.mainModule;o&&typeof o=="object"&&(e=o.constructor)}if(!e&&typeof require<"u"&&typeof require.main<"u"&&(e=require.main.constructor),!e||typeof e._resolveFilename!="function")return;let r=e._resolveFilename,n=Object.getOwnPropertyDescriptor(e,"_resolveFilename");this.originalDescriptors.push({target:e,prop:"_resolveFilename",descriptor:n});let i=this.createBlockingProxy(r,"Module._resolveFilename","module_resolve_filename");Object.defineProperty(e,"_resolveFilename",{value:i,writable:!0,configurable:!0})}catch(e){this.patchFailures.push("Module._resolveFilename"),console.debug("[DefenseInDepthBox] Could not protect Module._resolveFilename:",e instanceof Error?e.message:e)}}applyPatch(e){let{target:r,prop:n,violationType:s,strategy:i}=e;try{let o=r[n];if(o===void 0)return;let a=Object.getOwnPropertyDescriptor(r,n);if(this.originalDescriptors.push({target:r,prop:n,descriptor:a}),i==="freeze")typeof o=="object"&&o!==null&&Object.freeze(o);else{let l=this.getPathForTarget(r,n),c=typeof o=="function"?this.createBlockingProxy(o,l,s):this.createBlockingObjectProxy(o,l,s,e.allowedKeys);Object.defineProperty(r,n,{value:c,writable:!0,configurable:!0})}}catch(o){let a=this.getPathForTarget(r,n);this.patchFailures.push(a),console.debug(`[DefenseInDepthBox] Could not patch ${a}:`,o instanceof Error?o.message:o)}}restorePatches(){for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:r,prop:n,descriptor:s}=this.originalDescriptors[e];try{s?Object.defineProperty(r,n,s):delete r[n]}catch(i){let o=this.getPathForTarget(r,n);console.debug(`[DefenseInDepthBox] Could not restore ${o}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}}});function cU(t){return typeof t!="function"?t:Et.bindCurrentContext(t)}var aU,lU,Jce,eue,Wr,fr,bi=I(()=>{"use strict";$r();aU=globalThis.setTimeout.bind(globalThis),lU=globalThis.clearTimeout.bind(globalThis),Jce=globalThis.setInterval.bind(globalThis),eue=globalThis.clearInterval.bind(globalThis);Wr=((t,e,...r)=>aU(cU(t),e,...r)),fr=lU});var ES={};ue(ES,{echoCommand:()=>fU,flagsForFuzzing:()=>v1});function uU(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"){if(r+1>=t.length){e+="\\";break}let n=t[r+1];switch(n){case"\\":e+="\\",r+=2;break;case"n":e+=`
5
5
  `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"e":case"E":e+="\x1B",r+=2;break;case"c":return{output:e,stop:!0};case"0":{let s="",i=r+2;for(;i<t.length&&i<r+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\0";else{let o=parseInt(s,8)%256;e+=String.fromCharCode(o)}r=i;break}case"x":{let s="",i=r+2;for(;i<t.length&&i<r+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\x",r+=2;else{let o=parseInt(s,16);e+=String.fromCharCode(o),r=i}break}case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\u",r+=2;else{let o=parseInt(s,16);e+=String.fromCodePoint(o),r=i}break}case"U":{let s="",i=r+2;for(;i<t.length&&i<r+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\U",r+=2;else{let o=parseInt(s,16);try{e+=String.fromCodePoint(o)}catch{e+=`\\U${s}`}r=i}break}default:e+=`\\${n}`,r+=2}}else e+=t[r],r++;return{output:e,stop:!1}}var fU,v1,A1=I(()=>{"use strict";fU={name:"echo",async execute(t,e){let r=!1,n=e.xpgEcho??!1,s=0;for(;s<t.length;){let o=t[s];if(o==="-n")r=!0,s++;else if(o==="-e")n=!0,s++;else if(o==="-E")n=!1,s++;else if(o==="-ne"||o==="-en")r=!0,n=!0,s++;else break}let i=t.slice(s).join(" ");if(n){let o=uU(i);if(i=o.output,o.stop)return{stdout:i,stderr:"",exitCode:0}}return r||(i+=`
6
- `),{stdout:i,stderr:"",exitCode:0}}},v1={name:"echo",flags:[{flag:"-n",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-E",type:"boolean"}],stdinType:"none",needsArgs:!0}});function bo(t){return t}function ir(t){return t}function he(t){let e=t;if(!e)return e;let r=!1;for(let s=0;s<e.length;s++){let i=e.charCodeAt(s);if(i>255)return e;i>127&&(r=!0)}if(!r)return e;let n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);try{return hU.decode(n)}catch{return e}}function Ts(t){if(!t)return t;let e=dU.encode(t),r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return r}function pU(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}async function wi(t,e){return typeof t.readFileBytes=="function"?t.readFileBytes(e):pU(await t.readFileBuffer(e))}function C1(t){return t.stdoutKind?t.stdoutKind:t.stdoutEncoding==="binary"?"bytes":"text"}function Zc(t){return C1(t)==="bytes"?t.stdout:Ts(t.stdout)}function SS(t){return{stdout:t,stdoutKind:"text"}}function vS(t){return{stdout:t,stdoutKind:"bytes",stdoutEncoding:"binary"}}var hU,dU,Sh,Re=I(()=>{"use strict";hU=new TextDecoder("utf-8",{fatal:!0}),dU=new TextEncoder;Sh=""});function Z(t){let e=`${t.name} - ${t.summary}
6
+ `),{stdout:i,stderr:"",exitCode:0}}},v1={name:"echo",flags:[{flag:"-n",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-E",type:"boolean"}],stdinType:"none",needsArgs:!0}});function bo(t){return t}function ir(t){return t}function fe(t){let e=t;if(!e)return e;let r=!1,n=!1;for(let a=0;a<e.length;a++){let l=e.charCodeAt(a);l>255?n=!0:l>127&&(r=!0)}if(!r)return e;let s=[],i=new TextEncoder;for(let a=0;a<e.length;a++){let l=e.charCodeAt(a);if(l>255){let c=i.encode(e[a]);for(let u=0;u<c.length;u++)s.push(c[u])}else s.push(l)}let o=new Uint8Array(s);try{return hU.decode(o)}catch{return e}}function Ts(t){if(!t)return t;let e=dU.encode(t),r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return r}function pU(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}async function wi(t,e){return typeof t.readFileBytes=="function"?t.readFileBytes(e):pU(await t.readFileBuffer(e))}function C1(t){return t.stdoutKind?t.stdoutKind:t.stdoutEncoding==="binary"?"bytes":"text"}function Zc(t){return C1(t)==="bytes"?t.stdout:Ts(t.stdout)}function SS(t){return{stdout:t,stdoutKind:"text"}}function vS(t){return{stdout:t,stdoutKind:"bytes",stdoutEncoding:"binary"}}var hU,dU,Sh,Re=I(()=>{"use strict";hU=new TextDecoder("utf-8",{fatal:!0}),dU=new TextEncoder;Sh=""});function Z(t){let e=`${t.name} - ${t.summary}
7
7
 
8
8
  `;if(e+=`Usage: ${t.usage}
9
9
  `,t.description){if(e+=`
@@ -31,12 +31,12 @@ Notes:
31
31
  `),n=t.endsWith(`
32
32
  `),s=n?r.slice(0,-1):r;return{content:s.map((o,a)=>`${String(e+a).padStart(6," ")} ${o}`).join(`
33
33
  `)+(n?`
34
- `:""),nextLineNumber:e+s.length}}var mU,gU,yU,N1,k1=I(()=>{"use strict";Re();Ar();wo();xe();mU={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},gU={number:{short:"n",long:"number",type:"boolean"}},yU={name:"cat",async execute(t,e){if(Y(t))return Z(mU);let r=ct("cat",t,gU);if(!r.ok)return r.error;let n=r.result.flags.number,s=r.result.positional,i=await Ki(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files){let c=l;if(n){let u=xU(c,a);o+=u.content,a=u.nextLineNumber}else o+=c}return{stdout:o,stderr:i.stderr,exitCode:i.exitCode,stdoutEncoding:"binary"}}};N1={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0}});var CS=j(vh=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function e(o){return n(i(o),arguments)}function r(o,a){return e.apply(null,[o].concat(a||[]))}function n(o,a){var l=1,c=o.length,u,f="",h,d,p,m,g,y,x,b;for(h=0;h<c;h++)if(typeof o[h]=="string")f+=o[h];else if(typeof o[h]=="object"){if(p=o[h],p.keys)for(u=a[l],d=0;d<p.keys.length;d++){if(u==null)throw new Error(e('[sprintf] Cannot access property "%s" of undefined value "%s"',p.keys[d],p.keys[d-1]));u=u[p.keys[d]]}else p.param_no?u=a[p.param_no]:u=a[l++];if(t.not_type.test(p.type)&&t.not_primitive.test(p.type)&&u instanceof Function&&(u=u()),t.numeric_arg.test(p.type)&&typeof u!="number"&&isNaN(u))throw new TypeError(e("[sprintf] expecting number but found %T",u));switch(t.number.test(p.type)&&(x=u>=0),p.type){case"b":u=parseInt(u,10).toString(2);break;case"c":u=String.fromCharCode(parseInt(u,10));break;case"d":case"i":u=parseInt(u,10);break;case"j":u=JSON.stringify(u,null,p.width?parseInt(p.width):0);break;case"e":u=p.precision?parseFloat(u).toExponential(p.precision):parseFloat(u).toExponential();break;case"f":u=p.precision?parseFloat(u).toFixed(p.precision):parseFloat(u);break;case"g":u=p.precision?String(Number(u.toPrecision(p.precision))):parseFloat(u);break;case"o":u=(parseInt(u,10)>>>0).toString(8);break;case"s":u=String(u),u=p.precision?u.substring(0,p.precision):u;break;case"t":u=String(!!u),u=p.precision?u.substring(0,p.precision):u;break;case"T":u=Object.prototype.toString.call(u).slice(8,-1).toLowerCase(),u=p.precision?u.substring(0,p.precision):u;break;case"u":u=parseInt(u,10)>>>0;break;case"v":u=u.valueOf(),u=p.precision?u.substring(0,p.precision):u;break;case"x":u=(parseInt(u,10)>>>0).toString(16);break;case"X":u=(parseInt(u,10)>>>0).toString(16).toUpperCase();break}t.json.test(p.type)?f+=u:(t.number.test(p.type)&&(!x||p.sign)?(b=x?"+":"-",u=u.toString().replace(t.sign,"")):b="",g=p.pad_char?p.pad_char==="0"?"0":p.pad_char.charAt(1):" ",y=p.width-(b+u).length,m=p.width&&y>0?g.repeat(y):"",f+=p.align?b+u+m:g==="0"?b+m+u:m+b+u)}return f}var s=Object.create(null);function i(o){if(s[o])return s[o];for(var a=o,l,c=[],u=0;a;){if((l=t.text.exec(a))!==null)c.push(l[0]);else if((l=t.modulo.exec(a))!==null)c.push("%");else if((l=t.placeholder.exec(a))!==null){if(l[2]){u|=1;var f=[],h=l[2],d=[];if((d=t.key.exec(h))!==null)for(f.push(d[1]);(h=h.substring(d[0].length))!=="";)if((d=t.key_access.exec(h))!==null)f.push(d[1]);else if((d=t.index_access.exec(h))!==null)f.push(d[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=f}else u|=2;if(u===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");c.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");a=a.substring(l[0].length)}return s[o]=c}typeof vh<"u"&&(vh.sprintf=e,vh.vsprintf=r),typeof window<"u"&&(window.sprintf=e,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:e,vsprintf:r}}))})()});function Ah(t){return t instanceof gn||t instanceof yn||t instanceof tn}var mn,gn,yn,tn,zn,Nn,Xe,It,kn,Ei,dl,fe,pl,Si,fs,rt=I(()=>{"use strict";mn=class extends Error{stdout;stderr;constructor(e,r="",n=""){super(e),this.stdout=r,this.stderr=n}prependOutput(e,r){this.stdout=e+this.stdout,this.stderr=r+this.stderr}},gn=class extends mn{levels;name="BreakError";constructor(e=1,r="",n=""){super("break",r,n),this.levels=e}},yn=class extends mn{levels;name="ContinueError";constructor(e=1,r="",n=""){super("continue",r,n),this.levels=e}},tn=class extends mn{exitCode;name="ReturnError";constructor(e=0,r="",n=""){super("return",r,n),this.exitCode=e}},zn=class extends mn{exitCode;name="ErrexitError";constructor(e,r="",n=""){super(`errexit: command exited with status ${e}`,r,n),this.exitCode=e}},Nn=class extends mn{varName;name="NounsetError";constructor(e,r=""){super(`${e}: unbound variable`,r,`bash: ${e}: unbound variable
34
+ `:""),nextLineNumber:e+s.length}}var mU,gU,yU,N1,k1=I(()=>{"use strict";Re();Ar();wo();xe();mU={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},gU={number:{short:"n",long:"number",type:"boolean"}},yU={name:"cat",async execute(t,e){if(Y(t))return Z(mU);let r=ct("cat",t,gU);if(!r.ok)return r.error;let n=r.result.flags.number,s=r.result.positional,i=await Ki(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files){let c=l;if(n){let u=xU(c,a);o+=u.content,a=u.nextLineNumber}else o+=c}return{stdout:o,stderr:i.stderr,exitCode:i.exitCode,stdoutEncoding:"binary"}}};N1={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0}});var CS=j(vh=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function e(o){return n(i(o),arguments)}function r(o,a){return e.apply(null,[o].concat(a||[]))}function n(o,a){var l=1,c=o.length,u,f="",h,d,p,m,g,y,x,b;for(h=0;h<c;h++)if(typeof o[h]=="string")f+=o[h];else if(typeof o[h]=="object"){if(p=o[h],p.keys)for(u=a[l],d=0;d<p.keys.length;d++){if(u==null)throw new Error(e('[sprintf] Cannot access property "%s" of undefined value "%s"',p.keys[d],p.keys[d-1]));u=u[p.keys[d]]}else p.param_no?u=a[p.param_no]:u=a[l++];if(t.not_type.test(p.type)&&t.not_primitive.test(p.type)&&u instanceof Function&&(u=u()),t.numeric_arg.test(p.type)&&typeof u!="number"&&isNaN(u))throw new TypeError(e("[sprintf] expecting number but found %T",u));switch(t.number.test(p.type)&&(x=u>=0),p.type){case"b":u=parseInt(u,10).toString(2);break;case"c":u=String.fromCharCode(parseInt(u,10));break;case"d":case"i":u=parseInt(u,10);break;case"j":u=JSON.stringify(u,null,p.width?parseInt(p.width):0);break;case"e":u=p.precision?parseFloat(u).toExponential(p.precision):parseFloat(u).toExponential();break;case"f":u=p.precision?parseFloat(u).toFixed(p.precision):parseFloat(u);break;case"g":u=p.precision?String(Number(u.toPrecision(p.precision))):parseFloat(u);break;case"o":u=(parseInt(u,10)>>>0).toString(8);break;case"s":u=String(u),u=p.precision?u.substring(0,p.precision):u;break;case"t":u=String(!!u),u=p.precision?u.substring(0,p.precision):u;break;case"T":u=Object.prototype.toString.call(u).slice(8,-1).toLowerCase(),u=p.precision?u.substring(0,p.precision):u;break;case"u":u=parseInt(u,10)>>>0;break;case"v":u=u.valueOf(),u=p.precision?u.substring(0,p.precision):u;break;case"x":u=(parseInt(u,10)>>>0).toString(16);break;case"X":u=(parseInt(u,10)>>>0).toString(16).toUpperCase();break}t.json.test(p.type)?f+=u:(t.number.test(p.type)&&(!x||p.sign)?(b=x?"+":"-",u=u.toString().replace(t.sign,"")):b="",g=p.pad_char?p.pad_char==="0"?"0":p.pad_char.charAt(1):" ",y=p.width-(b+u).length,m=p.width&&y>0?g.repeat(y):"",f+=p.align?b+u+m:g==="0"?b+m+u:m+b+u)}return f}var s=Object.create(null);function i(o){if(s[o])return s[o];for(var a=o,l,c=[],u=0;a;){if((l=t.text.exec(a))!==null)c.push(l[0]);else if((l=t.modulo.exec(a))!==null)c.push("%");else if((l=t.placeholder.exec(a))!==null){if(l[2]){u|=1;var f=[],h=l[2],d=[];if((d=t.key.exec(h))!==null)for(f.push(d[1]);(h=h.substring(d[0].length))!=="";)if((d=t.key_access.exec(h))!==null)f.push(d[1]);else if((d=t.index_access.exec(h))!==null)f.push(d[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=f}else u|=2;if(u===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");c.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");a=a.substring(l[0].length)}return s[o]=c}typeof vh<"u"&&(vh.sprintf=e,vh.vsprintf=r),typeof window<"u"&&(window.sprintf=e,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:e,vsprintf:r}}))})()});function Ah(t){return t instanceof gn||t instanceof yn||t instanceof tn}var mn,gn,yn,tn,zn,Nn,Xe,It,kn,Ei,dl,he,pl,Si,fs,rt=I(()=>{"use strict";mn=class extends Error{stdout;stderr;constructor(e,r="",n=""){super(e),this.stdout=r,this.stderr=n}prependOutput(e,r){this.stdout=e+this.stdout,this.stderr=r+this.stderr}},gn=class extends mn{levels;name="BreakError";constructor(e=1,r="",n=""){super("break",r,n),this.levels=e}},yn=class extends mn{levels;name="ContinueError";constructor(e=1,r="",n=""){super("continue",r,n),this.levels=e}},tn=class extends mn{exitCode;name="ReturnError";constructor(e=0,r="",n=""){super("return",r,n),this.exitCode=e}},zn=class extends mn{exitCode;name="ErrexitError";constructor(e,r="",n=""){super(`errexit: command exited with status ${e}`,r,n),this.exitCode=e}},Nn=class extends mn{varName;name="NounsetError";constructor(e,r=""){super(`${e}: unbound variable`,r,`bash: ${e}: unbound variable
35
35
  `),this.varName=e}},Xe=class extends mn{exitCode;name="ExitError";constructor(e,r="",n=""){super("exit",r,n),this.exitCode=e}},It=class extends mn{name="ArithmeticError";fatal;constructor(e,r="",n="",s=!1){super(e,r,n),this.stderr=n||`bash: ${e}
36
36
  `,this.fatal=s}},kn=class extends mn{name="BadSubstitutionError";constructor(e,r="",n=""){super(e,r,n),this.stderr=n||`bash: ${e}: bad substitution
37
37
  `}},Ei=class extends mn{name="GlobError";constructor(e,r="",n=""){super(`no match: ${e}`,r,n),this.stderr=n||`bash: no match: ${e}
38
38
  `}},dl=class extends mn{name="BraceExpansionError";constructor(e,r="",n=""){super(e,r,n),this.stderr=n||`bash: ${e}
39
- `}},fe=class extends mn{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,r,n="",s=""){super(e,n,s),this.limitType=r,this.stderr=s||`bash: ${e}
39
+ `}},he=class extends mn{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,r,n="",s=""){super(e,n,s),this.limitType=r,this.stderr=s||`bash: ${e}
40
40
  `}},pl=class extends mn{name="ExecutionAbortedError";constructor(e="",r=""){super("execution aborted",e,r)}},Si=class extends mn{name="SubshellExitError";constructor(e="",r=""){super("subshell exit",e,r)}};fs=class extends mn{exitCode;name="PosixFatalError";constructor(e,r="",n=""){super("posix fatal error",r,n),this.exitCode=e}}});function Rt(t){return t instanceof Error?t.message:String(t)}var Tn=I(()=>{"use strict"});function Ch(t,e,r){let n=t;r>=0&&n.length>r&&(n=n.slice(0,r));let s=Math.abs(e);return s>n.length&&(e<0?n=n.padEnd(s," "):n=n.padStart(s," ")),n}function NS(t,e){let r=e,n=0,s=-1,i=!1;for(r<t.length&&t[r]==="-"&&(i=!0,r++);r<t.length&&/\d/.test(t[r]);)n=n*10+parseInt(t[r],10),r++;if(r<t.length&&t[r]===".")for(r++,s=0;r<t.length&&/\d/.test(t[r]);)s=s*10+parseInt(t[r],10),r++;return i&&n>0&&(n=-n),[n,s,r-e]}function Nh(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length)switch(t[r+1]){case"n":e+=`
41
41
  `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"\\":e+="\\",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"e":case"E":e+="\x1B",r+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=r+1;for(;i<t.length&&i<r+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),r=i;break}case"x":{let s=[],i=r;for(;i+3<t.length&&t[i]==="\\"&&t[i+1]==="x"&&/[0-9a-fA-F]{2}/.test(t.slice(i+2,i+4));)s.push(parseInt(t.slice(i+2,i+4),16)),i+=4;if(s.length>0){try{let o=new TextDecoder("utf-8",{fatal:!0});e+=o.decode(new Uint8Array(s))}catch{for(let o of s)e+=String.fromCharCode(o)}r=i}else e+=t[r],r++;break}case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\u",r+=2);break}case"U":{let s="",i=r+2;for(;i<t.length&&i<r+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\U",r+=2);break}default:e+=t[r],r++}else e+=t[r],r++;return e}var T1=I(()=>{"use strict"});function _S(t,e,r){let n=new Date(e*1e3),s="",i=0;for(;i<t.length;)if(t[i]==="%"&&i+1<t.length){let o=t[i+1],a=wU(n,o,r);a!==null?(s+=a,i+=2):(s+=t[i],i++)}else s+=t[i],i++;return s}function bU(t,e){let r={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",weekday:"short",hour12:!1,timeZone:e};try{let s=new Intl.DateTimeFormat("en-US",r).formatToParts(t),i=l=>s.find(c=>c.type===l)?.value??"",o=new Map([["Sun",0],["Mon",1],["Tue",2],["Wed",3],["Thu",4],["Fri",5],["Sat",6]]),a=i("weekday");return{year:Number.parseInt(i("year"),10)||t.getFullYear(),month:Number.parseInt(i("month"),10)||t.getMonth()+1,day:Number.parseInt(i("day"),10)||t.getDate(),hour:Number.parseInt(i("hour"),10)||t.getHours(),minute:Number.parseInt(i("minute"),10)||t.getMinutes(),second:Number.parseInt(i("second"),10)||t.getSeconds(),weekday:o.get(a)??t.getDay()}}catch{return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),weekday:t.getDay()}}}function wU(t,e,r){let n=bU(t,r),s=(l,c=2)=>String(l).padStart(c,"0"),i=OS(n.year,n.month,n.day),o=kS(n.year,n.month,n.day,n.weekday,0),a=kS(n.year,n.month,n.day,n.weekday,1);switch(e){case"a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][n.weekday];case"A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][n.weekday];case"b":case"h":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.month-1];case"B":return["January","February","March","April","May","June","July","August","September","October","November","December"][n.month-1];case"c":return`${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][n.weekday]} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.month-1]} ${String(n.day).padStart(2," ")} ${s(n.hour)}:${s(n.minute)}:${s(n.second)} ${n.year}`;case"C":return s(Math.floor(n.year/100));case"d":return s(n.day);case"D":return`${s(n.month)}/${s(n.day)}/${s(n.year%100)}`;case"e":return String(n.day).padStart(2," ");case"F":return`${n.year}-${s(n.month)}-${s(n.day)}`;case"g":return s(TS(n.year,n.month,n.day)%100);case"G":return String(TS(n.year,n.month,n.day));case"H":return s(n.hour);case"I":return s(n.hour%12||12);case"j":return String(i).padStart(3,"0");case"k":return String(n.hour).padStart(2," ");case"l":return String(n.hour%12||12).padStart(2," ");case"m":return s(n.month);case"M":return s(n.minute);case"n":return`
42
42
  `;case"N":return"000000000";case"p":return n.hour<12?"AM":"PM";case"P":return n.hour<12?"am":"pm";case"r":return`${s(n.hour%12||12)}:${s(n.minute)}:${s(n.second)} ${n.hour<12?"AM":"PM"}`;case"R":return`${s(n.hour)}:${s(n.minute)}`;case"s":return String(Math.floor(t.getTime()/1e3));case"S":return s(n.second);case"t":return" ";case"T":return`${s(n.hour)}:${s(n.minute)}:${s(n.second)}`;case"u":return String(n.weekday===0?7:n.weekday);case"U":return s(o);case"V":return s(vU(n.year,n.month,n.day));case"w":return String(n.weekday);case"W":return s(a);case"x":return`${s(n.month)}/${s(n.day)}/${s(n.year%100)}`;case"X":return`${s(n.hour)}:${s(n.minute)}:${s(n.second)}`;case"y":return s(n.year%100);case"Y":return String(n.year);case"z":return EU(t,r);case"Z":return SU(t,r);case"%":return"%";default:return null}}function EU(t,e){if(!e){let o=-t.getTimezoneOffset(),a=o>=0?"+":"-",l=Math.floor(Math.abs(o)/60),c=Math.abs(o)%60;return`${a}${String(l).padStart(2,"0")}${String(c).padStart(2,"0")}`}try{let l=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(t).find(c=>c.type==="timeZoneName");if(l){let c=l.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(c)return`${c[1]}${c[2]}${c[3]}`;if(l.value==="GMT"||l.value==="UTC")return"+0000"}}catch{}let r=-t.getTimezoneOffset(),n=r>=0?"+":"-",s=Math.floor(Math.abs(r)/60),i=Math.abs(r)%60;return`${n}${String(s).padStart(2,"0")}${String(i).padStart(2,"0")}`}function SU(t,e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"short"}).formatToParts(t).find(i=>i.type==="timeZoneName")?.value??"UTC"}catch{return"UTC"}}function OS(t,e,r){let n=[31,28,31,30,31,30,31,31,30,31,30,31];(t%4===0&&t%100!==0||t%400===0)&&(n[1]=29);let i=r;for(let o=0;o<e-1;o++)i+=n[o];return i}function kS(t,e,r,n,s){let i=OS(t,e,r),l=(new Date(t,0,1).getDay()-s+7)%7,c=(n-s+7)%7,u=i-1+l;return Math.floor((u-c+7)/7)}function vU(t,e,r){let n=new Date(t,e-1,r,12,0,0);n.setDate(n.getDate()+3-(n.getDay()+6)%7);let s=new Date(n.getFullYear(),0,4);s.setDate(s.getDate()+3-(s.getDay()+6)%7);let i=n.getTime()-s.getTime();return 1+Math.round(i/(10080*60*1e3))}function TS(t,e,r){let n=new Date(t,e-1,r,12,0,0);return n.setDate(n.getDate()+3-(n.getDay()+6)%7),n.getFullYear()}var IS=I(()=>{"use strict"});var PS={};ue(PS,{flagsForFuzzing:()=>_1,printfCommand:()=>NU});function AU(t){let e="",r=0;for(;r<t.length;){let n=t[r];if(n<128){e+=String.fromCharCode(n),r++;continue}if((n&224)===192){if(r+1<t.length&&(t[r+1]&192)===128&&n>=194){let s=(n&31)<<6|t[r+1]&63;e+=String.fromCharCode(s),r+=2;continue}e+=String.fromCharCode(n),r++;continue}if((n&240)===224){if(r+2<t.length&&(t[r+1]&192)===128&&(t[r+2]&192)===128){if(n===224&&t[r+1]<160){e+=String.fromCharCode(n),r++;continue}let s=(n&15)<<12|(t[r+1]&63)<<6|t[r+2]&63;if(s>=55296&&s<=57343){e+=String.fromCharCode(n),r++;continue}e+=String.fromCharCode(s),r+=3;continue}e+=String.fromCharCode(n),r++;continue}if((n&248)===240&&n<=244){if(r+3<t.length&&(t[r+1]&192)===128&&(t[r+2]&192)===128&&(t[r+3]&192)===128){if(n===240&&t[r+1]<144){e+=String.fromCharCode(n),r++;continue}let s=(n&7)<<18|(t[r+1]&63)<<12|(t[r+2]&63)<<6|t[r+3]&63;if(s>1114111){e+=String.fromCharCode(n),r++;continue}e+=String.fromCodePoint(s),r+=4;continue}e+=String.fromCharCode(n),r++;continue}e+=String.fromCharCode(n),r++}return e}function kU(t,e,r,n){let s="",i=0,o=0,a=!1,l="";for(;i<t.length;)if(t[i]==="%"&&i+1<t.length){let c=i;if(i++,t[i]==="%"){s+="%",i++;continue}let u=t.slice(c).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(u){let S=u[1]?parseInt(u[1],10):0,_=u[2]?parseInt(u[2],10):-1,P=u[3],F=u[0],R=e[r+o]||"";o++;let $;R===""||R==="-1"||R==="-2"?$=Math.floor(Date.now()/1e3):$=parseInt(R,10)||0;let N=_S(P,$,n);if(_>=0&&N.length>_&&(N=N.slice(0,_)),S!==0){let k=Math.abs(S);N.length<k&&(S<0?N=N.padEnd(k," "):N=N.padStart(k," "))}s+=N,i=c+F.length;continue}for(;i<t.length&&"+-0 #'".includes(t[i]);)i++;let f=!1;if(t[i]==="*")f=!0,i++;else for(;i<t.length&&/\d/.test(t[i]);)i++;let h=!1;if(t[i]===".")if(i++,t[i]==="*")h=!0,i++;else for(;i<t.length&&/\d/.test(t[i]);)i++;i<t.length&&"hlL".includes(t[i])&&i++;let d=t[i]||"";i++;let m=t.slice(c,i);if(f){let S=parseInt(e[r+o]||"0",10);o++,m=m.replace("*",String(S))}if(h){let S=parseInt(e[r+o]||"0",10);o++,m=m.replace(".*",`.${S}`)}let g=e[r+o]||"";o++;let{value:y,parseError:x,parseErrMsg:b,stopped:w}=TU(m,d,g);if(s+=y,x&&(a=!0,b&&(l=b)),w)return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!0}}else s+=t[i],i++;return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!1}}function TU(t,e,r){let n=!1,s="";switch(e){case"d":case"i":{let i=kh(r);return n=Zs,n&&(s=`printf: ${r}: invalid number
@@ -50,7 +50,7 @@ Notes:
50
50
  `,exitCode:2};let r=null,n=0;for(;n<t.length;){let o=t[n];if(o==="--"){n++;break}if(o==="-v"){if(n+1>=t.length)return{stdout:"",stderr:`printf: -v: option requires an argument
51
51
  `,exitCode:1};if(r=t[n+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(\[[a-zA-Z0-9_@*"'$]+\])?$/.test(r))return{stdout:"",stderr:`printf: \`${r}': not a valid identifier
52
52
  `,exitCode:2};n+=2}else{if(o.startsWith("-")&&o!=="-")break;break}}if(n>=t.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
53
- `,exitCode:1};let s=t[n],i=t.slice(n+1);try{let o=Nh(s),a="",l=0,c=!1,u="",f=e.env.get("TZ"),h=e.limits?.maxStringLength;do{let{result:d,argsConsumed:p,error:m,errMsg:g,stopped:y}=kU(o,i,l,f);if(a+=d,h!==void 0&&h>0&&a.length>h)throw new fe(`printf: output size limit exceeded (${h} bytes)`,"string_length");if(l+=p,m&&(c=!0,g&&(u=g)),y)break}while(l<i.length&&l>0);if(l===0&&i.length>0,r){let d=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(d){let p=d[1],m=d[3];m=m.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(g,y)=>e.env.get(y)??""),e.env.set(`${p}_${m}`,a)}else e.env.set(r,a);return{stdout:"",stderr:u,exitCode:c?1:0}}return{stdout:a,stderr:u,exitCode:c?1:0}}catch(o){if(o instanceof fe)throw o;return{stdout:"",stderr:`printf: ${Rt(o)}
53
+ `,exitCode:1};let s=t[n],i=t.slice(n+1);try{let o=Nh(s),a="",l=0,c=!1,u="",f=e.env.get("TZ"),h=e.limits?.maxStringLength;do{let{result:d,argsConsumed:p,error:m,errMsg:g,stopped:y}=kU(o,i,l,f);if(a+=d,h!==void 0&&h>0&&a.length>h)throw new he(`printf: output size limit exceeded (${h} bytes)`,"string_length");if(l+=p,m&&(c=!0,g&&(u=g)),y)break}while(l<i.length&&l>0);if(l===0&&i.length>0,r){let d=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(d){let p=d[1],m=d[3];m=m.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(g,y)=>e.env.get(y)??""),e.env.set(`${p}_${m}`,a)}else e.env.set(r,a);return{stdout:"",stderr:u,exitCode:c?1:0}}return{stdout:a,stderr:u,exitCode:c?1:0}}catch(o){if(o instanceof he)throw o;return{stdout:"",stderr:`printf: ${Rt(o)}
54
54
  `,exitCode:1}}}};Zs=!1;_1={name:"printf",flags:[{flag:"-v",type:"value",valueHint:"string"}],stdinType:"none",needsArgs:!0}});var I1,DS,FU,LS=I(()=>{I1=(t,e,r)=>{let n=t instanceof RegExp?DS(t,r):t,s=e instanceof RegExp?DS(e,r):e,i=n!==null&&s!=null&&FU(n,s,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+n.length,i[1]),post:r.slice(i[1]+s.length)}},DS=(t,e)=>{let r=e.match(t);return r?r[0]:null},FU=(t,e,r)=>{let n,s,i,o,a,l=r.indexOf(t),c=r.indexOf(e,l+1),u=l;if(l>=0&&c>0){if(t===e)return[l,c];for(n=[],i=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(t,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else s=n.pop(),s!==void 0&&s<i&&(i=s,o=c),c=r.indexOf(e,u+1);u=l<c&&l>=0?l:c}n.length&&o!==void 0&&(a=[i,o])}return a}});function R1(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function KU(t){return t.replace(zU,FS).replace(HU,MS).replace(WU,P1).replace(jU,$S).replace(VU,BS)}function ZU(t){return t.replace(MU,"\\").replace($U,"{").replace(BU,"}").replace(UU,",").replace(qU,".")}function US(t){if(!t)return[""];let e=[],r=I1("{","}",t);if(!r)return t.split(",");let{pre:n,body:s,post:i}=r,o=n.split(",");o[o.length-1]+="{"+s+"}";let a=US(i);return i.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),e.push.apply(e,o),e}function qS(t,e={}){if(!t)return[];let{max:r=GU}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),Yc(KU(t),r,!0).map(ZU)}function YU(t){return"{"+t+"}"}function XU(t){return/^-?0\d/.test(t)}function QU(t,e){return t<=e}function JU(t,e){return t>=e}function Yc(t,e,r){let n=[],s=I1("{","}",t);if(!s)return[t];let i=s.pre,o=s.post.length?Yc(s.post,e,!1):[""];if(/\$$/.test(s.pre))for(let a=0;a<o.length&&a<e;a++){let l=i+"{"+s.body+"}"+o[a];n.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),c=a||l,u=s.body.indexOf(",")>=0;if(!c&&!u)return s.post.match(/,(?!,).*\}/)?(t=s.pre+"{"+s.body+P1+s.post,Yc(t,e,!0)):[t];let f;if(c)f=s.body.split(/\.\./);else if(f=US(s.body),f.length===1&&f[0]!==void 0&&(f=Yc(f[0],e,!1).map(YU),f.length===1))return o.map(d=>s.pre+f[0]+d);let h;if(c&&f[0]!==void 0&&f[1]!==void 0){let d=R1(f[0]),p=R1(f[1]),m=Math.max(f[0].length,f[1].length),g=f.length===3&&f[2]!==void 0?Math.max(Math.abs(R1(f[2])),1):1,y=QU;p<d&&(g*=-1,y=JU);let b=f.some(XU);h=[];for(let w=d;y(w,p);w+=g){let S;if(l)S=String.fromCharCode(w),S==="\\"&&(S="");else if(S=String(w),b){let _=m-S.length;if(_>0){let P=new Array(_+1).join("0");w<0?S="-"+P+S.slice(1):S=P+S}}h.push(S)}}else{h=[];for(let d=0;d<f.length;d++)h.push.apply(h,Yc(f[d],e,!1))}for(let d=0;d<h.length;d++)for(let p=0;p<o.length&&n.length<e;p++){let m=i+h[d]+o[p];(!r||c||m)&&n.push(m)}}return n}var FS,MS,P1,$S,BS,MU,$U,BU,UU,qU,zU,HU,WU,jU,VU,GU,zS=I(()=>{LS();FS="\0SLASH"+Math.random()+"\0",MS="\0OPEN"+Math.random()+"\0",P1="\0CLOSE"+Math.random()+"\0",$S="\0COMMA"+Math.random()+"\0",BS="\0PERIOD"+Math.random()+"\0",MU=new RegExp(FS,"g"),$U=new RegExp(MS,"g"),BU=new RegExp(P1,"g"),UU=new RegExp($S,"g"),qU=new RegExp(BS,"g"),zU=/\\\\/g,HU=/\\{/g,WU=/\\}/g,jU=/\\,/g,VU=/\\\./g,GU=1e5});var Xc,HS=I(()=>{Xc=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")}});var eq,Qc,tq,WS,jS,VS=I(()=>{eq={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Qc=t=>t.replace(/[[\]\\-]/g,"\\$&"),tq=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),WS=t=>t.join(""),jS=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],i=r+1,o=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;i<t.length;){let m=t.charAt(i);if((m==="!"||m==="^")&&i===r+1){c=!0,i++;continue}if(m==="]"&&o&&!l){u=i+1;break}if(o=!0,m==="\\"&&!l){l=!0,i++;continue}if(m==="["&&!l){for(let[g,[y,x,b]]of Object.entries(eq))if(t.startsWith(g,i)){if(f)return["$.",!1,t.length-r,!0];i+=g.length,b?s.push(y):n.push(y),a=a||x;continue e}}if(l=!1,f){m>f?n.push(Qc(f)+"-"+Qc(m)):m===f&&n.push(Qc(m)),f="",i++;continue}if(t.startsWith("-]",i+1)){n.push(Qc(m+"-")),i+=2;continue}if(t.startsWith("-",i+1)){f=m,i+=2;continue}n.push(Qc(m)),i++}if(u<i)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,t.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let m=n[0].length===2?n[0].slice(-1):n[0];return[tq(m),!1,u-r,!1]}let h="["+(c?"^":"")+WS(n)+"]",d="["+(c?"":"^")+WS(s)+"]";return[n.length&&s.length?"("+h+"|"+d+")":n.length?h:d,a,u-r,!0]}});var Eo,Th=I(()=>{Eo=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!0}={})=>r?e?t.replace(/\[([^/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):e?t.replace(/\[([^/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1")});var Hn,rq,D1,GS,nq,sq,iq,KS,oq,_h,aq,lq,cq,uq,L1,ZS,YS,fq,pa,F1=I(()=>{VS();Th();rq=new Set(["!","?","+","*","@"]),D1=t=>rq.has(t),GS=t=>D1(t.type),nq=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),sq=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),iq=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),KS=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),oq="(?!(?:^|/)\\.\\.?(?:$|/))",_h="(?!\\.)",aq=new Set(["[","."]),lq=new Set(["..","."]),cq=new Set("().*{}+?[]^$\\!"),uq=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),L1="[^/]",ZS=L1+"*?",YS=L1+"+?",fq=0,pa=class{type;#t;#r;#n=!1;#e=[];#s;#a;#c;#l=!1;#i;#o;#u=!1;id=++fq;get depth(){return(this.#s?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#t.id,parent:this.#s?.id,depth:this.depth,partsLength:this.#e.length,parts:this.#e}}constructor(e,r,n={}){this.type=e,e&&(this.#r=!0),this.#s=r,this.#t=this.#s?this.#s.#t:this,this.#i=this.#t===this?n:this.#t.#i,this.#c=this.#t===this?[]:this.#t.#c,e==="!"&&!this.#t.#l&&this.#c.push(this),this.#a=this.#s?this.#s.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let e of this.#e)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#o!==void 0?this.#o:this.type?this.#o=this.type+"("+this.#e.map(e=>String(e)).join("|")+")":this.#o=this.#e.map(e=>String(e)).join("")}#y(){if(this!==this.#t)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let e;for(;e=this.#c.pop();){if(e.type!=="!")continue;let r=e,n=r.#s;for(;n;){for(let s=r.#a+1;!n.type&&s<n.#e.length;s++)for(let i of e.#e){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#e[s])}r=n,n=r.#s}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof Hn&&r.#s===this))throw new Error("invalid part: "+r);this.#e.push(r)}}toJSON(){let e=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#l&&this.#s?.type==="!")&&e.push({}),e}isStart(){if(this.#t===this)return!0;if(!this.#s?.isStart())return!1;if(this.#a===0)return!0;let e=this.#s;for(let r=0;r<this.#a;r++){let n=e.#e[r];if(!(n instanceof Hn&&n.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#s?.type==="!")return!0;if(!this.#s?.isEnd())return!1;if(!this.type)return this.#s?.isEnd();let e=this.#s?this.#s.#e.length:0;return this.#a===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new Hn(this.type,e);for(let n of this.#e)r.copyIn(n);return r}static#f(e,r,n,s,i){let o=s.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let m=n,g="";for(;m<e.length;){let y=e.charAt(m++);if(a||y==="\\"){a=!a,g+=y;continue}if(l){m===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(m===c+2&&u)&&(l=!1),g+=y;continue}else if(y==="["){l=!0,c=m,u=!1,g+=y;continue}if(!s.noext&&D1(y)&&e.charAt(m)==="("&&i<=o){r.push(g),g="";let b=new Hn(y,r);m=Hn.#f(e,b,m,s,i+1),r.push(b);continue}g+=y}return r.push(g),m}let f=n+1,h=new Hn(null,r),d=[],p="";for(;f<e.length;){let m=e.charAt(f++);if(a||m==="\\"){a=!a,p+=m;continue}if(l){f===c+1?(m==="^"||m==="!")&&(u=!0):m==="]"&&!(f===c+2&&u)&&(l=!1),p+=m;continue}else if(m==="["){l=!0,c=f,u=!1,p+=m;continue}if(!s.noext&&D1(m)&&e.charAt(f)==="("&&(i<=o||r&&r.#h(m))){let y=r&&r.#h(m)?0:1;h.push(p),p="";let x=new Hn(m,h);h.push(x),f=Hn.#f(e,x,f,s,i+y);continue}if(m==="|"){h.push(p),p="",d.push(h),h=new Hn(null,r);continue}if(m===")")return p===""&&r.#e.length===0&&(r.#u=!0),h.push(p),p="",r.push(...d,h),f;p+=m}return r.type=null,r.#r=void 0,r.#e=[e.substring(n-1)],f}#x(e){return this.#p(e,sq)}#p(e,r=nq){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null)return!1;let n=e.#e[0];return!n||typeof n!="object"||n.type===null?!1:this.#h(n.type,r)}#h(e,r=iq){return!!r.get(this.type)?.includes(e)}#b(e,r){let n=e.#e[0],s=new Hn(null,n,this.options);s.#e.push(""),n.push(s),this.#m(e,r)}#m(e,r){let n=e.#e[0];this.#e.splice(r,1,...n.#e);for(let s of n.#e)typeof s=="object"&&(s.#s=this);this.#o=void 0}#w(e){return!!KS.get(this.type)?.has(e)}#E(e){if(!e||typeof e!="object"||e.type!==null||e.#e.length!==1||this.type===null||this.#e.length!==1)return!1;let r=e.#e[0];return!r||typeof r!="object"||r.type===null?!1:this.#w(r.type)}#S(e){let r=KS.get(this.type),n=e.#e[0],s=r?.get(n.type);if(!s)return!1;this.#e=n.#e;for(let i of this.#e)typeof i=="object"&&(i.#s=this);this.type=s,this.#o=void 0,this.#u=!1}static fromGlob(e,r={}){let n=new Hn(null,void 0,r);return Hn.#f(e,n,0,r,0),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let e=this.toString(),[r,n,s,i]=this.toRegExpSource();if(!(s||this.#r||this.#i.nocase&&!this.#i.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#i.nocase?"i":"")+(i?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#i}toRegExpSource(e){let r=e??!!this.#i.dot;if(this.#t===this&&(this.#d(),this.#y()),!GS(this)){let l=this.isStart()&&this.isEnd()&&!this.#e.some(d=>typeof d!="string"),c=this.#e.map(d=>{let[p,m,g,y]=typeof d=="string"?Hn.#v(d,this.#r,l):d.toRegExpSource(e);return this.#r=this.#r||g,this.#n=this.#n||y,p}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&lq.has(this.#e[0]))){let p=aq,m=r&&p.has(c.charAt(0))||c.startsWith("\\.")&&p.has(c.charAt(2))||c.startsWith("\\.\\.")&&p.has(c.charAt(4)),g=!r&&!e&&p.has(c.charAt(0));u=m?oq:g?_h:""}let f="";return this.isEnd()&&this.#t.#l&&this.#s?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,Eo(c),this.#r=!!this.#r,this.#n]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#g(r);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){let l=this.toString(),c=this;return c.#e=[l],c.type=null,c.#r=void 0,[l,Eo(this.toString()),!1,!1]}let o=!n||e||r||!_h?"":this.#g(!0);o===i&&(o=""),o&&(i=`(?:${i})(?:${o})*?`);let a="";if(this.type==="!"&&this.#u)a=(this.isStart()&&!r?_h:"")+YS;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!e?_h:"")+ZS+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=s+i+l}return[a,Eo(i),this.#r=!!this.#r,this.#n]}#d(){if(GS(this)){let e=0,r=!1;do{r=!0;for(let n=0;n<this.#e.length;n++){let s=this.#e[n];typeof s=="object"&&(s.#d(),this.#p(s)?(r=!1,this.#m(s,n)):this.#x(s)?(r=!1,this.#b(s,n)):this.#E(s)&&(r=!1,this.#S(s)))}}while(!r&&++e<10)}else for(let e of this.#e)typeof e=="object"&&e.#d();this.#o=void 0}#g(e){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,i,o]=r.toRegExpSource(e);return this.#n=this.#n||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#v(e,r,n=!1){let s=!1,i="",o=!1,a=!1;for(let l=0;l<e.length;l++){let c=e.charAt(l);if(s){s=!1,i+=(cq.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(e)?YS:ZS,r=!0;continue}else a=!1;if(c==="\\"){l===e.length-1?i+="\\\\":s=!0;continue}if(c==="["){let[u,f,h,d]=jS(e,l);if(h){i+=u,o=o||f,l+=h-1,r=r||d;continue}}if(c==="?"){i+=L1,r=!0;continue}i+=uq(c)}return[i,Eo(e),!!r,o]}};Hn=pa});var M1,$1=I(()=>{M1=(t,{windowsPathsNoEscape:e=!1,magicalBraces:r=!1}={})=>r?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&")});var jr,hq,dq,pq,mq,gq,yq,xq,bq,wq,Eq,Sq,vq,Aq,Cq,Nq,kq,Tq,_q,JS,e8,t8,XS,Oq,xn,Iq,Rq,Pq,Dq,Lq,_s,Fq,r8,Mq,$q,QS,Bq,ml,n8=I(()=>{zS();HS();F1();$1();Th();F1();$1();Th();jr=(t,e,r={})=>(Xc(e),!r.nocomment&&e.charAt(0)==="#"?!1:new ml(e,r).match(t)),hq=/^\*+([^+@!?*[(]*)$/,dq=t=>e=>!e.startsWith(".")&&e.endsWith(t),pq=t=>e=>e.endsWith(t),mq=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),gq=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),yq=/^\*+\.\*+$/,xq=t=>!t.startsWith(".")&&t.includes("."),bq=t=>t!=="."&&t!==".."&&t.includes("."),wq=/^\.\*+$/,Eq=t=>t!=="."&&t!==".."&&t.startsWith("."),Sq=/^\*+$/,vq=t=>t.length!==0&&!t.startsWith("."),Aq=t=>t.length!==0&&t!=="."&&t!=="..",Cq=/^\?+([^+@!?*[(]*)?$/,Nq=([t,e=""])=>{let r=JS([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},kq=([t,e=""])=>{let r=e8([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},Tq=([t,e=""])=>{let r=e8([t]);return e?n=>r(n)&&n.endsWith(e):r},_q=([t,e=""])=>{let r=JS([t]);return e?n=>r(n)&&n.endsWith(e):r},JS=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},e8=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},t8=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",XS={win32:{sep:"\\"},posix:{sep:"/"}},Oq=t8==="win32"?XS.win32.sep:XS.posix.sep;jr.sep=Oq;xn=Symbol("globstar **");jr.GLOBSTAR=xn;Iq="[^/]",Rq=Iq+"*?",Pq="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Dq="(?:(?!(?:\\/|^)\\.).)*?",Lq=(t,e={})=>r=>jr(r,t,e);jr.filter=Lq;_s=(t,e={})=>Object.assign({},t,e),Fq=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return jr;let e=jr;return Object.assign((n,s,i={})=>e(n,s,_s(t,i)),{Minimatch:class extends e.Minimatch{constructor(s,i={}){super(s,_s(t,i))}static defaults(s){return e.defaults(_s(t,s)).Minimatch}},AST:class extends e.AST{constructor(s,i,o={}){super(s,i,_s(t,o))}static fromGlob(s,i={}){return e.AST.fromGlob(s,_s(t,i))}},unescape:(n,s={})=>e.unescape(n,_s(t,s)),escape:(n,s={})=>e.escape(n,_s(t,s)),filter:(n,s={})=>e.filter(n,_s(t,s)),defaults:n=>e.defaults(_s(t,n)),makeRe:(n,s={})=>e.makeRe(n,_s(t,s)),braceExpand:(n,s={})=>e.braceExpand(n,_s(t,s)),match:(n,s,i={})=>e.match(n,s,_s(t,i)),sep:e.sep,GLOBSTAR:xn})};jr.defaults=Fq;r8=(t,e={})=>(Xc(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:qS(t,{max:e.braceExpandMax}));jr.braceExpand=r8;Mq=(t,e={})=>new ml(t,e).makeRe();jr.makeRe=Mq;$q=(t,e,r={})=>{let n=new ml(e,r);return t=t.filter(s=>n.match(s)),n.options.nonull&&!t.length&&t.push(e),t};jr.match=$q;QS=/[?*]|[+@!]\(.*?\)|\[|\]/,Bq=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ml=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,r={}){Xc(e),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=e,this.platform=r.platform||t8,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let s=this.globParts.map((i,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=i[0]===""&&i[1]===""&&(i[2]==="?"||!QS.test(i[2]))&&!QS.test(i[3]),c=/^[a-z]:/i.test(i[0]);if(l)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(c)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(l=>this.parse(l))});if(this.debug(this.pattern,s),this.set=s.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){let o=this.set[i];o[0]===""&&o[1]===""&&this.globParts[i][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n of e)for(let s=0;s<n.length;s++)n[s]==="**"&&(n[s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,s)=>{let i=n[n.length-1];return s==="**"&&i==="**"?n:s===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<e.length-1;s++){let i=e[s];s===1&&i===""&&e[0]===""||(i==="."||i==="")&&(r=!0,e.splice(s,1),s--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let s=e[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(s))&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let o=s;for(;n[o+1]==="**";)o++;o>s&&n.splice(s+1,o-s);let a=n[s+1],l=n[s+2],c=n[s+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(s,1);let u=n.slice(0);u[s]="**",e.push(u),s--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let i=0;for(;(i=n.indexOf("..",i+1))!==-1;){let o=n[i-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let l=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...l),n.length===0&&n.push(""),i-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let s=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(s){e[r]=[],e[n]=s;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let s=0,i=0,o=[],a="";for(;s<e.length&&i<r.length;)if(e[s]===r[i])o.push(a==="b"?r[i]:e[s]),s++,i++;else if(n&&e[s]==="**"&&r[i]===e[s+1])o.push(e[s]),s++;else if(n&&r[i]==="**"&&e[s]===r[i+1])o.push(r[i]),i++;else if(e[s]==="*"&&r[i]&&(this.options.dot||!r[i].startsWith("."))&&r[i]!=="**"){if(a==="b")return!1;a="a",o.push(e[s]),s++,i++}else if(r[i]==="*"&&e[s]&&(this.options.dot||!e[s].startsWith("."))&&e[s]!=="**"){if(a==="a")return!1;a="b",o.push(r[i]),s++,i++}else return!1;return e.length===r.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let s=0;s<e.length&&e.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let s=0,i=0;if(this.isWindows){let a=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),l=!a&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,h=u?3:c?0:void 0;if(typeof f=="number"&&typeof h=="number"){let[d,p]=[e[f],r[h]];d.toLowerCase()===p.toLowerCase()&&(r[h]=d,i=h,s=f)}}let{optimizationLevel:o=1}=this.options;return o>=2&&(e=this.levelTwoFileOptimize(e)),r.includes(xn)?this.#t(e,r,n,s,i):this.#n(e,r,n,s,i)}#t(e,r,n,s,i){let o=r.indexOf(xn,i),a=r.lastIndexOf(xn),[l,c,u]=n?[r.slice(i,o),r.slice(o+1),[]]:[r.slice(i,o),r.slice(o+1,a),r.slice(a+1)];if(l.length){let x=e.slice(s,s+l.length);if(!this.#n(x,l,n,0,0))return!1;s+=l.length,i+=l.length}let f=0;if(u.length){if(u.length+s>e.length)return!1;let x=e.length-u.length;if(this.#n(e,u,n,x,0))f=u.length;else{if(e[e.length-1]!==""||s+u.length===e.length||(x--,!this.#n(e,u,n,x,0)))return!1;f=u.length+1}}if(!c.length){let x=!!f;for(let b=s;b<e.length-f;b++){let w=String(e[b]);if(x=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||x}let h=[[[],0]],d=h[0],p=0,m=[0];for(let x of c)x===xn?(m.push(p),d=[[],0],h.push(d)):(d[0].push(x),p++);let g=h.length-1,y=e.length-f;for(let x of h)x[1]=y-(m[g--]+x[0].length);return!!this.#r(e,h,s,0,n,0,!!f)}#r(e,r,n,s,i,o,a){let l=r[s];if(!l){for(let f=n;f<e.length;f++){a=!0;let h=e[f];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&o<this.maxGlobstarRecursion){let d=this.#r(e,r,n+c.length,s+1,i,o+1,a);if(d!==!1)return d}let h=e[n];if(h==="."||h===".."||!this.options.dot&&h.startsWith("."))return!1;n++}return i||null}#n(e,r,n,s,i){let o,a,l,c;for(o=s,a=i,c=e.length,l=r.length;o<c&&a<l;o++,a++){this.debug("matchOne loop");let u=r[a],f=e[o];if(this.debug(r,u,f),u===!1||u===xn)return!1;let h;if(typeof u=="string"?(h=f===u,this.debug("string match",u,f,h)):(h=u.test(f),this.debug("pattern match",u,f,h)),!h)return!1}if(o===c&&a===l)return!0;if(o===c)return n;if(a===l)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return r8(this.pattern,this.options)}parse(e){Xc(e);let r=this.options;if(e==="**")return xn;if(e==="")return"";let n,s=null;(n=e.match(Sq))?s=r.dot?Aq:vq:(n=e.match(hq))?s=(r.nocase?r.dot?gq:mq:r.dot?pq:dq)(n[1]):(n=e.match(Cq))?s=(r.nocase?r.dot?kq:Nq:r.dot?Tq:_q)(n):(n=e.match(yq))?s=r.dot?bq:xq:(n=e.match(wq))&&(s=Eq);let i=pa.fromGlob(e,this.options).toMMPattern();return s&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:s}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Rq:r.dot?Pq:Dq,s=new Set(r.nocase?["i"]:[]),i=e.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let h of f.flags.split(""))s.add(h);return typeof f=="string"?Bq(f):f===xn?xn:f._src});c.forEach((f,h)=>{let d=c[h+1],p=c[h-1];f!==xn||p===xn||(p===void 0?d!==void 0&&d!==xn?c[h+1]="(?:\\/|"+n+"\\/)?"+d:c[h]=n:d===void 0?c[h-1]=p+"(?:\\/|\\/"+n+")?":d!==xn&&(c[h-1]=p+"(?:\\/|\\/"+n+"\\/)"+d,c[h+1]=xn))});let u=c.filter(f=>f!==xn);if(this.partial&&u.length>=1){let f=[];for(let h=1;h<=u.length;h++)f.push(u.slice(0,h).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];i="^"+o+i+a+"$",this.partial&&(i="^(?:\\/|"+o+i.slice(1,-1)+a+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...s].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let s=this.slashSplit(e);this.debug(this.pattern,"split",s);let i=this.set;this.debug(this.pattern,"set",i);let o=s[s.length-1];if(!o)for(let a=s.length-2;!o&&a>=0;a--)o=s[a];for(let a of i){let l=s;if(n.matchBase&&a.length===1&&(l=[o]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return jr.defaults(e).Minimatch}};jr.AST=pa;jr.Minimatch=ml;jr.escape=M1;jr.unescape=Eo});var i8={};ue(i8,{flagsForFuzzing:()=>B1,lsCommand:()=>zq});function Oh(t){if(t<1024)return String(t);if(t<1024*1024){let r=t/1024;return r<10?`${r.toFixed(1)}K`:`${Math.round(r)}K`}if(t<1024*1024*1024){let r=t/1048576;return r<10?`${r.toFixed(1)}M`:`${Math.round(r)}M`}let e=t/(1024*1024*1024);return e<10?`${e.toFixed(1)}G`:`${Math.round(e)}G`}function Ih(t){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=String(t.getDate()).padStart(2," "),s=new Date,i=new Date(s.getTime()-4320*60*60*1e3);if(t>i){let a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${r} ${n} ${a}:${l}`}let o=t.getFullYear();return`${r} ${n} ${o}`}function ma(t){return t.isDirectory?"/":t.isSymbolicLink?"@":(t.mode&73)!==0?"*":""}async function Hq(t,e,r,n,s,i=!1,o=!1,a=!1,l=!1){let c=r||n,u=e.fs.getAllPaths(),f=e.fs.resolvePath(e.cwd,"."),h=[];for(let d of u){let p=d.startsWith(f)&&d.slice(f.length+1)||d;if(jr(p,t)||jr(d,t)){let m=p.split("/").pop()||p;if(!c&&m.startsWith("."))continue;h.push(p||d)}}if(h.length===0)return{stdout:"",stderr:`ls: ${t}: No such file or directory
55
55
  `,exitCode:2};if(a){let d=[];for(let p of h){let m=e.fs.resolvePath(e.cwd,p);try{let g=await e.fs.stat(m);d.push({path:p,size:g.size??0})}catch{d.push({path:p,size:0})}}d.sort((p,m)=>m.size-p.size),h.length=0,h.push(...d.map(p=>p.path))}else h.sort();if(i&&h.reverse(),s){let d=[];for(let p of h){let m=e.fs.resolvePath(e.cwd,p);try{let g=await e.fs.stat(m),y=g.isDirectory?"drwxr-xr-x":"-rw-r--r--",x=l?ma(await e.fs.lstat(m)):g.isDirectory?"/":"",b=g.size??0,w=o?Oh(b).padStart(5):String(b).padStart(5),S=g.mtime??new Date(0),_=Ih(S);d.push(`${y} 1 user user ${w} ${_} ${p}${x}`)}catch{d.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${p}`)}}return{stdout:`${d.join(`
56
56
  `)}
@@ -148,7 +148,7 @@ Options:
148
148
  `&&i--;let o=0;for(;i>=0&&o<e;){if(t[i]===`
149
149
  `&&(o++,o===e)){i++;break}i--}i<0&&(i=0);let a=t.slice(i);return t[s-1]===`
150
150
  `?a:`${a}
151
- `}var lg=I(()=>{"use strict";Re();xe()});var S8={};ue(S8,{flagsForFuzzing:()=>cg,headCommand:()=>pz});var dz,pz,cg,ug=I(()=>{"use strict";xe();lg();dz={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},pz={name:"head",async execute(t,e){if(Y(t))return Z(dz);let r=Rh(t,"head");if(!r.ok)return r.error;let{lines:n,bytes:s}=r.options;return Ph(e,r.options,"head",i=>w8(i,n,s))}},cg={name:"head",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}});var v8={};ue(v8,{flagsForFuzzing:()=>fg,tailCommand:()=>gz});var mz,gz,fg,hg=I(()=>{"use strict";lg();xe();mz={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},gz={name:"tail",async execute(t,e){if(Y(t))return Z(mz);let r=Rh(t,"tail");if(!r.ok)return r.error;let{lines:n,bytes:s,fromLine:i}=r.options;return Ph(e,r.options,"tail",o=>E8(o,n,s,i??!1))}},fg={name:"tail",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}});var C8={};ue(C8,{flagsForFuzzing:()=>pg,wcCommand:()=>bz});function A8(t,e){let r=t,n=r.length,s=e?Array.from(he(t)).length:n,i=0,o=0,a=!1;for(let l=0;l<n;l++){let c=r[l];c===`
151
+ `}var lg=I(()=>{"use strict";Re();xe()});var S8={};ue(S8,{flagsForFuzzing:()=>cg,headCommand:()=>pz});var dz,pz,cg,ug=I(()=>{"use strict";xe();lg();dz={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},pz={name:"head",async execute(t,e){if(Y(t))return Z(dz);let r=Rh(t,"head");if(!r.ok)return r.error;let{lines:n,bytes:s}=r.options;return Ph(e,r.options,"head",i=>w8(i,n,s))}},cg={name:"head",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}});var v8={};ue(v8,{flagsForFuzzing:()=>fg,tailCommand:()=>gz});var mz,gz,fg,hg=I(()=>{"use strict";lg();xe();mz={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},gz={name:"tail",async execute(t,e){if(Y(t))return Z(mz);let r=Rh(t,"tail");if(!r.ok)return r.error;let{lines:n,bytes:s,fromLine:i}=r.options;return Ph(e,r.options,"tail",o=>E8(o,n,s,i??!1))}},fg={name:"tail",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}});var C8={};ue(C8,{flagsForFuzzing:()=>pg,wcCommand:()=>bz});function A8(t,e){let r=t,n=r.length,s=e?Array.from(fe(t)).length:n,i=0,o=0,a=!1;for(let l=0;l<n;l++){let c=r[l];c===`
152
152
  `?(i++,a&&(o++,a=!1)):c===" "||c===" "||c==="\r"?a&&(o++,a=!1):a=!0}return a&&o++,{lines:i,words:o,third:s}}function dg(t,e,r,n,s,i){let o=[];e&&o.push(String(t.lines).padStart(i)),r&&o.push(String(t.words).padStart(i)),n&&o.push(String(t.third).padStart(i));let a=o.join(" ");return s&&(a+=` ${s}`),a}var yz,xz,bz,pg,mg=I(()=>{"use strict";Re();Ar();wo();xe();yz={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},xz={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},bz={name:"wc",async execute(t,e){if(Y(t))return Z(yz);let r=ct("wc",t,xz);if(!r.ok)return r.error;let{lines:n,words:s}=r.result.flags,i=r.result.flags.bytes,o=r.result.flags.chars,a=r.result.positional;!n&&!s&&!i&&!o&&(n=s=i=!0);let l=i||o,c=await Ki(e,a,{cmdName:"wc",stopOnError:!1});if(a.length===0){let b=A8(c.files[0].content,o);return{stdout:`${dg(b,n,s,l,"",0)}
153
153
  `,stderr:"",exitCode:0}}let u=[],f=0,h=0,d=0;for(let{filename:b,content:w}of c.files){let S=A8(w,o);f+=S.lines,h+=S.words,d+=S.third,u.push({filename:b,stats:S})}let p=a.length>1?f:Math.max(...u.map(b=>b.stats.lines)),m=a.length>1?h:Math.max(...u.map(b=>b.stats.words)),g=a.length>1?d:Math.max(...u.map(b=>b.stats.third)),y=a.length>1?3:0;n&&(y=Math.max(y,String(p).length)),s&&(y=Math.max(y,String(m).length)),l&&(y=Math.max(y,String(g).length));let x="";for(let{filename:b,stats:w}of u)x+=`${dg(w,n,s,l,b,y)}
154
154
  `;return a.length>1&&(x+=`${dg({lines:f,words:h,third:d},n,s,l,"total",y)}
@@ -194,7 +194,7 @@ Options:
194
194
  `:"",matched:!0,matchCount:P.length}}var Y8=I(()=>{"use strict"});function X8(t){let e="",r=0;for(;r<t.length;){if(t.slice(r,r+7)==="[[:<:]]"){e+="\\b",r+=7;continue}if(t.slice(r,r+7)==="[[:>:]]"){e+="\\b",r+=7;continue}if(t[r]==="["){let n="[";for(r++,r<t.length&&(t[r]==="^"||t[r]==="!")&&(n+="^",r++),r<t.length&&t[r]==="]"&&(n+="\\]",r++);r<t.length&&t[r]!=="]";){if(t[r]==="["&&r+1<t.length&&t[r+1]===":"){let s=t.indexOf(":]",r+2);if(s!==-1){let i=t.slice(r+2,s),o=Oz.get(i);if(o){n+=o,r=s+2;continue}}}if(t[r]==="\\"&&r+1<t.length){n+=t[r]+t[r+1],r+=2;continue}n+=t[r],r++}r<t.length&&t[r]==="]"&&(n+="]",r++),e+=n;continue}if(t[r]==="\\"&&r+1<t.length){e+=t[r]+t[r+1],r+=2;continue}e+=t[r],r++}return e}function ru(t,e){let r,n;switch(e.mode){case"fixed":r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":{if(r=X8(t),r=r.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),e.mode==="perl"){r=Dz(r),r=Lz(r),r=Fz(r);let a=Uz(r);r=a.pattern,n=a.kResetGroup}break}default:r=X8(t),r=Hz(r);break}e.wholeWord&&(r=`\\b(?:${r})\\b`),e.lineRegexp&&(r=`^${r}$`);let s=/\\u\{[0-9A-Fa-f]+\}/.test(r),i="g"+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.multilineDotall?"s":"")+(s?"u":""),o=Iz(r,e.ignoreCase??!1);return{regex:ae(r,i),kResetGroup:n,preFilter:o??void 0}}function Iz(t,e){let r=t;if(r.startsWith("\\b(?:")&&r.endsWith(")\\b")?r=r.slice(5,r.length-3):r.startsWith("\\b")&&r.endsWith("\\b")&&r.length>=4&&(r=r.slice(2,r.length-2)),r.length===0)return null;let n=Rz(r);if(n===null)return null;let s=[];for(let i of n){let o=Pz(i);if(o===null||o.length===0)return null;s.push(o)}return s.length===0?null:{needles:e?s.map(i=>i.toLowerCase()):s,ignoreCase:e}}function Rz(t){let e=[],r=0,n=!1,s=0;for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"){i++;continue}if(n){o==="]"&&(n=!1);continue}if(o==="[")n=!0;else if(o==="(")r++;else if(o===")"){if(r--,r<0)return null}else o==="|"&&r===0&&(e.push(t.slice(s,i)),s=i+1)}return r!==0||n?null:(e.push(t.slice(s)),e)}function Pz(t){let e="";for(let r=0;r<t.length;r++){let n=t[r];if(n==="\\"){let s=t[r+1];if(s===void 0||/[dDwWsSbBAZzGQE0-9ckpPNXRxuU]/.test(s))return null;s==="n"?e+=`
195
195
  `:s==="t"?e+=" ":s==="r"?e+="\r":s==="f"?e+="\f":s==="v"?e+="\v":e+=s,r++;continue}if(/[.*+?^${}()|[\]]/.test(n))return null;e+=n}return e}function Dz(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length&&t[r+1]==="Q"){r+=2;let n="";for(;r<t.length;){if(t[r]==="\\"&&r+1<t.length&&t[r+1]==="E"){r+=2;break}n+=t[r],r++}e+=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}else e+=t[r],r++;return e}function Lz(t){return t.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function Fz(t){let e="",r=0;for(;r<t.length;){if(t[r]==="("&&r+1<t.length&&t[r+1]==="?"){let n=t.slice(r).match(/^\(\?([imsx]*)(-[imsx]*)?(:|$|\))/);if(n){let s=n[1]||"",i=n[2]||"",o=n[3];if(o===":"){let a=r+n[0].length-1,l=Mz(t,r);if(l!==-1){let c=t.slice(a+1,l),u=$z(c,s,i);e+=`(?:${u})`,r=l+1;continue}}else if(o===")"||o===""){r+=n[0].length;continue}}}e+=t[r],r++}return e}function Mz(t,e){let r=0,n=e;for(;n<t.length;){if(t[n]==="\\"){n+=2;continue}if(t[n]==="["){for(n++;n<t.length&&t[n]!=="]";)t[n]==="\\"&&n++,n++;n++;continue}if(t[n]==="(")r++;else if(t[n]===")"&&(r--,r===0))return n;n++}return-1}function $z(t,e,r){let n=t;return e.includes("i")&&(n=Bz(n)),n}function Bz(t){let e="",r=0;for(;r<t.length;){let n=t[r];if(n==="\\"){r+1<t.length?(e+=n+t[r+1],r+=2):(e+=n,r++);continue}if(n==="["){e+=n,r++,r<t.length&&t[r]==="^"&&(e+=t[r],r++);let s=[];for(;r<t.length&&t[r]!=="]";)if(t[r]==="\\")s.push(t[r]),r++,r<t.length&&(s.push(t[r]),r++);else if(t[r]==="-"&&s.length>0&&r+1<t.length&&t[r+1]!=="]"){let i=s[s.length-1],o=t[r+1];s.push("-"),s.push(o),/[a-z]/.test(i)&&/[a-z]/.test(o)?(s.push(i.toUpperCase()),s.push("-"),s.push(o.toUpperCase())):/[A-Z]/.test(i)&&/[A-Z]/.test(o)&&(s.push(i.toLowerCase()),s.push("-"),s.push(o.toLowerCase())),r+=2}else{let i=t[r];if(s.push(i),/[a-zA-Z]/.test(i)){let o=i===i.toLowerCase()?i.toUpperCase():i.toLowerCase();s.includes(o)||s.push(o)}r++}e+=s.join(""),r<t.length&&(e+=t[r],r++);continue}if(/[a-zA-Z]/.test(n)){let s=n.toLowerCase(),i=n.toUpperCase();e+=`[${i}${s}]`}else e+=n;r++}return e}function Uz(t){let e=qz(t);if(e===-1)return{pattern:t};let r=t.slice(0,e),n=t.slice(e+2),s=zz(r);return{pattern:`(?:${r})(${n})`,kResetGroup:s+1}}function qz(t){let e=0;for(;e<t.length-1;)if(t[e]==="\\"){if(t[e+1]==="K"){let r=0,n=e-1;for(;n>=0&&t[n]==="\\";)r++,n--;if(r%2===0)return e}e+=2}else e++;return-1}function zz(t){let e=0,r=0;for(;r<t.length;){if(t[r]==="\\"){r+=2;continue}if(t[r]==="["){for(r++;r<t.length&&t[r]!=="]";)t[r]==="\\"&&r++,r++;r++;continue}if(t[r]==="(")if(r+1<t.length&&t[r+1]==="?"){if(r+2<t.length){let n=t[r+2];if(n===":"||n==="="||n==="!"){r++;continue}if(n==="<"&&r+3<t.length){let s=t[r+3];if(s==="="||s==="!"){r++;continue}e++,r++;continue}}}else e++;r++}return e}function Lg(t){let e=t.replace(/\$\{0\}|\$0(?![0-9])/g,"$$&");return e=e.replace(/\$\{([^0-9}][^}]*)\}/g,"$$<$1>"),e=e.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,"$$<$1>"),e}function Hz(t){let e="",r=0,n=!0,s=0;for(;r<t.length;){let i=t[r];if(i==="["){for(e+=i,r++,r<t.length&&(t[r]==="^"||t[r]==="!")&&(e+=t[r],r++),r<t.length&&t[r]==="]"&&(e+=t[r],r++);r<t.length&&t[r]!=="]";)t[r]==="\\"&&r+1<t.length?(e+=t[r]+t[r+1],r+=2):(e+=t[r],r++);r<t.length&&t[r]==="]"&&(e+=t[r],r++),n=!1;continue}if(i==="\\"&&r+1<t.length){let o=t[r+1];if(o==="|"){e+="|",r+=2,n=!0;continue}if(o==="("){e+="(",r+=2,s++,n=!0;continue}if(o===")"){e+=")",r+=2,s=Math.max(0,s-1),n=!1;continue}if(o==="{"){let l=t.slice(r).match(/^\\{(\d+)(,(\d*)?)?\\}/);if(l){let c=l[1],u=l[2]!==void 0,f=l[3]||"";u?e+=`{${c},${f}}`:e+=`{${c}}`,r+=l[0].length,n=!1;continue}e+="\\{",r+=2,n=!1;continue}if(o==="}"){e+="\\}",r+=2,n=!1;continue}e+=i+o,r+=2,n=!1;continue}if(i==="*"&&n){e+="\\*",r++;continue}if(i==="^"){if(n){e+="^",r++;continue}e+="\\^",r++;continue}if(i==="$"){let o=r===t.length-1,a=r+2<t.length&&t[r+1]==="\\"&&t[r+2]===")";o||a?e+="$":e+="\\$",r++,n=!1;continue}i==="+"||i==="?"||i==="|"||i==="("||i===")"||i==="{"||i==="}"?e+=`\\${i}`:e+=i,r++,n=!1}return e}var Oz,Q8=I(()=>{"use strict";Gt();Oz=new Map([["alpha","a-zA-Z"],["digit","0-9"],["alnum","a-zA-Z0-9"],["lower","a-z"],["upper","A-Z"],["xdigit","0-9A-Fa-f"],["space"," \\t\\n\\r\\f\\v"],["blank"," \\t"],["punct","!-/:-@\\[-`{-~"],["graph","!-~"],["print"," -~"],["cntrl","\\x00-\\x1F\\x7F"],["ascii","\\x00-\\x7F"],["word","a-zA-Z0-9_"]])});var Fg=I(()=>{"use strict";Y8();Q8()});var qh={};ue(qh,{egrepCommand:()=>Gz,egrepFlagsForFuzzing:()=>Ug,fgrepCommand:()=>Vz,fgrepFlagsForFuzzing:()=>Bg,flagsForFuzzing:()=>$g,grepCommand:()=>Mg});async function e9(t,e,r,n,s=0){if(s>=J8)return;let i=r.fs.resolvePath(r.cwd,t);try{if(!(await r.fs.stat(i)).isDirectory){let l=t.split("/").pop()||"";if(e){let c=e.replace(/^\//,"");_n(l,c,{stripQuotes:!0})&&n.push(t)}return}let a=await r.fs.readdir(i);for(let l of a){let c=t==="."?l:`${t}/${l}`,u=r.fs.resolvePath(r.cwd,c);if((await r.fs.stat(u)).isDirectory)await e9(c,e,r,n,s+1);else if(e){let h=e.replace(/^\//,"");_n(l,h,{stripQuotes:!0})&&n.push(c)}}}catch{}}async function jz(t,e){let r=[],n=t.lastIndexOf("/"),s,i;if(n===-1?(s=e.cwd,i=t):(s=t.slice(0,n)||"/",i=t.slice(n+1)),t.includes("**")){let a=[],l=t.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await e9(c,u,e,a),a.map(f=>({path:f}))}let o=e.fs.resolvePath(e.cwd,s);try{if(e.fs.readdirWithFileTypes){let a=await e.fs.readdirWithFileTypes(o);for(let l of a)if(_n(l.name,i,{stripQuotes:!0})){let c=n===-1?l.name:`${s}/${l.name}`;r.push({path:c,isFile:l.isFile})}}else{let a=await e.fs.readdir(o);for(let l of a)if(_n(l,i,{stripQuotes:!0})){let c=n===-1?l:`${s}/${l}`;r.push({path:c})}}}catch{}return r.sort((a,l)=>a.path.localeCompare(l.path))}async function Uh(t,e,r=[],n=[],s=[],i,o=0){if(o>=J8)return[];let a=e.fs.resolvePath(e.cwd,t),l=[];try{let c,u;if(i!==void 0)c=i,u=!i;else{let h=await e.fs.stat(a);c=h.isFile,u=h.isDirectory}if(c){let h=t.split("/").pop()||t;return n.length>0&&n.some(d=>_n(h,d,{stripQuotes:!0}))?[]:r.length>0&&!r.some(d=>_n(h,d,{stripQuotes:!0}))?[]:[{path:t,isFile:!0}]}if(!u)return[];let f=t.split("/").pop()||t;if(s.length>0&&s.some(h=>_n(f,h,{stripQuotes:!0})))return[];if(e.fs.readdirWithFileTypes){let h=await e.fs.readdirWithFileTypes(a);for(let d of h){if(d.name.startsWith("."))continue;let p=t==="."?d.name:`${t}/${d.name}`,m=await Uh(p,e,r,n,s,d.isFile,o+1);l.push(...m)}}else{let h=await e.fs.readdir(a);for(let d of h){if(d.startsWith("."))continue;let p=t==="."?d:`${t}/${d}`,m=await Uh(p,e,r,n,s,void 0,o+1);l.push(...m)}}}catch{}return l}var Wz,Mg,J8,Vz,Gz,$g,Bg,Ug,nu=I(()=>{"use strict";Re();Dg();xe();Fg();Wz={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},Mg={name:"grep",async execute(t,e){if(Y(t))return Z(Wz);let r=!1,n=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,h=!1,d=!1,p=!1,m=!1,g=!1,y=0,x=0,b=0,w=[],S=[],_=[],P=null,F=[];for(let Q=0;Q<t.length;Q++){let te=t[Q];if(te.startsWith("-")&&te!=="-"){if(te==="-e"&&Q+1<t.length){P=t[++Q];continue}if(te.startsWith("--include=")){w.push(te.slice(10));continue}if(te.startsWith("--exclude=")){S.push(te.slice(10));continue}if(te.startsWith("--exclude-dir=")){_.push(te.slice(14));continue}if(te.startsWith("--max-count=")){y=parseInt(te.slice(12),10);continue}let le=te.match(/^-m(\d+)$/);if(le){y=parseInt(le[1],10);continue}if(te==="-m"&&Q+1<t.length){y=parseInt(t[++Q],10);continue}let U=te.match(/^-([ABC])(\d+)$/);if(U){let V=parseInt(U[2],10);U[1]==="A"?b=V:U[1]==="B"?x=V:U[1]==="C"&&(x=V,b=V);continue}if((te==="-A"||te==="-B"||te==="-C")&&Q+1<t.length){let V=parseInt(t[++Q],10);te==="-A"?b=V:te==="-B"?x=V:(x=V,b=V);continue}let se=te.startsWith("--")?[te]:te.slice(1).split("");for(let V of se)if(V==="i"||V==="--ignore-case")r=!0;else if(V==="n"||V==="--line-number")n=!0;else if(V==="v"||V==="--invert-match")s=!0;else if(V==="c"||V==="--count")i=!0;else if(V==="l"||V==="--files-with-matches")o=!0;else if(V==="L"||V==="--files-without-match")a=!0;else if(V==="r"||V==="R"||V==="--recursive")l=!0;else if(V==="w"||V==="--word-regexp")c=!0;else if(V==="x"||V==="--line-regexp")u=!0;else if(V==="E"||V==="--extended-regexp")f=!0;else if(V==="P"||V==="--perl-regexp")h=!0;else if(V==="F"||V==="--fixed-strings")d=!0;else if(V==="o"||V==="--only-matching")p=!0;else if(V==="h"||V==="--no-filename")m=!0;else if(V==="q"||V==="--quiet"||V==="--silent")g=!0;else{if(V.startsWith("--"))return oe("grep",V);if(V.length===1)return oe("grep",`-${V}`)}}else P===null?P=te:F.push(te)}if(P===null)return{stdout:"",stderr:`grep: missing pattern
196
196
  `,exitCode:2};let R=d?"fixed":f?"extended":h?"perl":"basic",$,N,k;try{let Q=ru(P,{mode:R,ignoreCase:r,wholeWord:c,lineRegexp:u});$=Q.regex,N=Q.kResetGroup,k=Q.preFilter}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${P}
197
- `,exitCode:2}}if(F.length===0&&e.stdin!==void 0){let Q=bl(he(e.stdin),$,{invertMatch:s,showLineNumbers:n,countOnly:i,filename:"",onlyMatching:p,beforeContext:x,afterContext:b,maxCount:y,kResetGroup:N,preFilter:k});return g?{stdout:"",stderr:"",exitCode:Q.matched?0:1}:{stdout:Q.output,stderr:"",exitCode:Q.matched?0:1}}if(F.length===0)return{stdout:"",stderr:`grep: no input files
197
+ `,exitCode:2}}if(F.length===0&&e.stdin!==void 0){let Q=bl(fe(e.stdin),$,{invertMatch:s,showLineNumbers:n,countOnly:i,filename:"",onlyMatching:p,beforeContext:x,afterContext:b,maxCount:y,kResetGroup:N,preFilter:k});return g?{stdout:"",stderr:"",exitCode:Q.matched?0:1}:{stdout:Q.output,stderr:"",exitCode:Q.matched?0:1}}if(F.length===0)return{stdout:"",stderr:`grep: no input files
198
198
  `,exitCode:2};let T="",E="",L=!1,B=!1,K=[];for(let Q of F)if(Q.includes("*")||Q.includes("?")||Q.includes("[")){let te=await jz(Q,e);if(l)for(let le of te){let U=await Uh(le.path,e,w,S,_,le.isFile);K.push(...U)}else K.push(...te)}else if(l){let te=await Uh(Q,e,w,S,_);K.push(...te)}else K.push({path:Q});let X=(K.length>1||l)&&!m,J=50;for(let Q=0;Q<K.length;Q+=J){let te=K.slice(Q,Q+J),le=await Promise.all(te.map(async U=>{let se=U.path,V=se.split("/").pop()||se;if(S.length>0&&!l&&S.some(Ge=>_n(V,Ge,{stripQuotes:!0}))||w.length>0&&!l&&!w.some(Ge=>_n(V,Ge,{stripQuotes:!0})))return null;try{let Ge=e.fs.resolvePath(e.cwd,se),ie=!1;if(U.isFile===void 0?ie=(await e.fs.stat(Ge)).isDirectory:ie=!U.isFile,ie)return l?null:{error:`grep: ${se}: Is a directory
199
199
  `};let Le=await e.fs.readFile(Ge),Ue=bl(Le,$,{invertMatch:s,showLineNumbers:n,countOnly:i,filename:X?se:"",onlyMatching:p,beforeContext:x,afterContext:b,maxCount:y,kResetGroup:N,preFilter:k});return{file:se,result:Ue}}catch{return{error:`grep: ${se}: No such file or directory
200
200
  `}}}));for(let U of le){if(U===null)continue;if("error"in U&&U.error){E+=U.error,U.error.includes("Is a directory")||(B=!0);continue}if(!("file"in U)||!U.result)continue;let{file:se,result:V}=U;if(V.matched){if(L=!0,g)return{stdout:"",stderr:"",exitCode:0};o?T+=`${se}
@@ -205,12 +205,12 @@ Options:
205
205
  `,exitCode:1}}function a9(t){return null}function Qz(t){t.hidden?t.searchBinary=!0:t.noIgnore?t.hidden=!0:t.noIgnore=!0}function Jz(t,e,r){let n=t[e];for(let s of l9){if(n.startsWith(`--${s.long}=`)){let i=n.slice(`--${s.long}=`.length),o=Hh(r,s,i);return o?{newIndex:e,error:o}:{newIndex:e}}if(s.short&&n.startsWith(`-${s.short}`)&&n.length>2){let i=n.slice(2),o=Hh(r,s,i);return o?{newIndex:e,error:o}:{newIndex:e}}if(s.short&&n===`-${s.short}`||n===`--${s.long}`){if(e+1>=t.length)return null;let i=t[e+1],o=Hh(r,s,i);return o?{newIndex:e+1,error:o}:{newIndex:e+1}}}return null}function eH(t){return l9.find(e=>e.short===t)}function Hh(t,e,r){if(e.validate){let s=e.validate(r);if(s)return s}if(e.ignored||!e.target)return;let n=e.parse?e.parse(r):r;e.multi?t[e.target].push(n):t[e.target]=n}function tH(t,e){let r=t[e];if(r==="--sort"&&e+1<t.length){let n=t[e+1];if(n==="path"||n==="none")return{value:n,newIndex:e+1}}if(r.startsWith("--sort=")){let n=r.slice(7);if(n==="path"||n==="none")return{value:n,newIndex:e}}return null}function rH(t,e){let r=t[e],n=r.match(/^-([ABC])(\d+)$/);return n?{flag:n[1],value:parseInt(n[2],10),newIndex:e}:(r==="-A"||r==="-B"||r==="-C")&&e+1<t.length?{flag:r[1],value:parseInt(t[e+1],10),newIndex:e+1}:null}function nH(t){let e=t.match(/^-m(\d+)$/);return e?parseInt(e[1],10):null}function c9(t){let e=i9(),r=null,n=[],s=-1,i=-1,o=-1,a=!1;for(let l=0;l<t.length;l++){let c=t[l];if(c.startsWith("-")&&c!=="-"){let u=rH(t,l);if(u){let{flag:g,value:y,newIndex:x}=u;g==="A"?s=Math.max(s,y):g==="B"?i=Math.max(i,y):o=y,l=x;continue}let f=nH(c);if(f!==null){e.maxCount=f;continue}let h=Jz(t,l,e);if(h){if(h.error)return{success:!1,error:h.error};l=h.newIndex;continue}let d=tH(t,l);if(d){e.sort=d.value,l=d.newIndex;continue}let p=c.startsWith("--")?[c]:c.slice(1).split(""),m=!1;for(let g of p){if(Xz.has(g)){e.lineNumber=!0,a=!0;continue}if(g==="u"||g==="--unrestricted"){Qz(e);continue}if(g==="P"||g==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
206
206
  `,exitCode:1}};if(g.length===1){let x=eH(g);if(x){if(l+1>=t.length)return{success:!1,error:oe("rg",`-${g}`)};let b=Hh(e,x,t[l+1]);if(b)return{success:!1,error:b};l++,m=!0;continue}}let y=Yz.get(g);if(y){y(e);continue}if(g.startsWith("--"))return{success:!1,error:oe("rg",g)};if(g.length===1)return{success:!1,error:oe("rg",`-${g}`)}}}else r===null&&e.patterns.length===0&&e.patternFiles.length===0?r=c:n.push(c)}return(s>=0||o>=0)&&(e.afterContext=Math.max(s>=0?s:0,o>=0?o:0)),(i>=0||o>=0)&&(e.beforeContext=Math.max(i>=0?i:0,o>=0?o:0)),r!==null&&e.patterns.push(r),(e.column||e.vimgrep)&&(a=!0),{success:!0,options:e,paths:n,explicitLineNumbers:a}}var l9,Yz,Xz,u9=I(()=>{"use strict";xe();o9();l9=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:a9},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:a9},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:parseInt},{long:"max-filesize",target:"maxFilesize",parse:Kz,validate:Zz},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",ignored:!0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],Yz=new Map([["i",t=>{t.ignoreCase=!0,t.caseSensitive=!1,t.smartCase=!1}],["--ignore-case",t=>{t.ignoreCase=!0,t.caseSensitive=!1,t.smartCase=!1}],["s",t=>{t.caseSensitive=!0,t.ignoreCase=!1,t.smartCase=!1}],["--case-sensitive",t=>{t.caseSensitive=!0,t.ignoreCase=!1,t.smartCase=!1}],["S",t=>{t.smartCase=!0,t.ignoreCase=!1,t.caseSensitive=!1}],["--smart-case",t=>{t.smartCase=!0,t.ignoreCase=!1,t.caseSensitive=!1}],["F",t=>{t.fixedStrings=!0}],["--fixed-strings",t=>{t.fixedStrings=!0}],["w",t=>{t.wordRegexp=!0}],["--word-regexp",t=>{t.wordRegexp=!0}],["x",t=>{t.lineRegexp=!0}],["--line-regexp",t=>{t.lineRegexp=!0}],["v",t=>{t.invertMatch=!0}],["--invert-match",t=>{t.invertMatch=!0}],["U",t=>{t.multiline=!0}],["--multiline",t=>{t.multiline=!0}],["--multiline-dotall",t=>{t.multilineDotall=!0,t.multiline=!0}],["c",t=>{t.count=!0}],["--count",t=>{t.count=!0}],["--count-matches",t=>{t.countMatches=!0}],["l",t=>{t.filesWithMatches=!0}],["--files",t=>{t.files=!0}],["--files-with-matches",t=>{t.filesWithMatches=!0}],["--files-without-match",t=>{t.filesWithoutMatch=!0}],["--stats",t=>{t.stats=!0}],["o",t=>{t.onlyMatching=!0}],["--only-matching",t=>{t.onlyMatching=!0}],["q",t=>{t.quiet=!0}],["--quiet",t=>{t.quiet=!0}],["N",t=>{t.lineNumber=!1}],["--no-line-number",t=>{t.lineNumber=!1}],["H",t=>{t.withFilename=!0}],["--with-filename",t=>{t.withFilename=!0}],["I",t=>{t.noFilename=!0}],["--no-filename",t=>{t.noFilename=!0}],["0",t=>{t.nullSeparator=!0}],["--null",t=>{t.nullSeparator=!0}],["b",t=>{t.byteOffset=!0}],["--byte-offset",t=>{t.byteOffset=!0}],["--column",t=>{t.column=!0,t.lineNumber=!0}],["--no-column",t=>{t.column=!1}],["--vimgrep",t=>{t.vimgrep=!0,t.column=!0,t.lineNumber=!0}],["--json",t=>{t.json=!0}],["--hidden",t=>{t.hidden=!0}],["--no-ignore",t=>{t.noIgnore=!0}],["--no-ignore-dot",t=>{t.noIgnoreDot=!0}],["--no-ignore-vcs",t=>{t.noIgnoreVcs=!0}],["L",t=>{t.followSymlinks=!0}],["--follow",t=>{t.followSymlinks=!0}],["z",t=>{t.searchZip=!0}],["--search-zip",t=>{t.searchZip=!0}],["a",t=>{t.searchBinary=!0}],["--text",t=>{t.searchBinary=!0}],["--heading",t=>{t.heading=!0}],["--passthru",t=>{t.passthru=!0}],["--include-zero",t=>{t.includeZero=!0}],["--glob-case-insensitive",t=>{t.globCaseInsensitive=!0}]]),Xz=new Set(["n","--line-number"])});function sH(t){return`'${t.replace(/'/g,"'\\''")}'`}function Vr(t){return t.map(sH).join(" ")}var Yi=I(()=>{"use strict"});async function Hg(t,e,r=!1,n=!1,s=[]){let i=new ou(t,e,r,n);await i.load(e);for(let o of s)try{let a=t.resolvePath(e,o),l=await t.readFile(a);i.addPatternsFromContent(l,e)}catch{}return i}var iu,ou,f9=I(()=>{"use strict";Gt();iu=class{patterns=[];basePath;constructor(e="/"){this.basePath=e}parse(e){let r=e.split(`
207
207
  `);for(let n of r){let s=n.replace(/\s+$/,"");if(!s||s.startsWith("#"))continue;let i=!1;s.startsWith("!")&&(i=!0,s=s.slice(1));let o=!1;s.endsWith("/")&&(o=!0,s=s.slice(0,-1));let a=!1;s.startsWith("/")?(a=!0,s=s.slice(1)):s.includes("/")&&!s.startsWith("**/")&&(a=!0);let l=this.patternToRegex(s,a);this.patterns.push({pattern:n,regex:l,negated:i,directoryOnly:o,rooted:a})}}patternToRegex(e,r){let n="";r?n="^":n="(?:^|/)";let s=0;for(;s<e.length;){let i=e[s];if(i==="*")e[s+1]==="*"?e[s+2]==="/"?(n+="(?:.*/)?",s+=3):(s+2>=e.length,n+=".*",s+=2):(n+="[^/]*",s++);else if(i==="?")n+="[^/]",s++;else if(i==="["){let o=s+1;for(o<e.length&&e[o]==="!"&&o++,o<e.length&&e[o]==="]"&&o++;o<e.length&&e[o]!=="]";)o++;if(o<e.length){let a=e.slice(s,o+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),n+=a,s=o+1}else n+="\\[",s++}else i==="/"?(n+="/",s++):(n+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s++)}return n+="(?:/.*)?$",ae(n)}matches(e,r){let n=e.replace(/^\.\//,"");n=n.replace(/^\//,"");let s=!1;for(let i of this.patterns)i.directoryOnly&&!r||i.regex.test(n)&&(s=!i.negated);return s}isWhitelisted(e,r){let n=e.replace(/^\.\//,"");n=n.replace(/^\//,"");for(let s of this.patterns)if(!(s.directoryOnly&&!r)&&s.negated&&s.regex.test(n))return!0;return!1}getBasePath(){return this.basePath}},ou=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(e,r,n=!1,s=!1){this.fs=e,this.skipDotIgnore=n,this.skipVcsIgnore=s}async load(e){let r=[],n=e;for(;;){r.unshift(n);let i=this.fs.resolvePath(n,"..");if(i===n)break;n=i}let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let i of r){this.loadedDirs.add(i);for(let o of s){let a=this.fs.resolvePath(i,o);try{let l=await this.fs.readFile(a),c=new iu(i);c.parse(l),this.parsers.push(c)}catch{}}}}async loadForDirectory(e){if(this.loadedDirs.has(e))return;this.loadedDirs.add(e);let r=[];this.skipVcsIgnore||r.push(".gitignore"),this.skipDotIgnore||r.push(".rgignore",".ignore");for(let n of r){let s=this.fs.resolvePath(e,n);try{let i=await this.fs.readFile(s),o=new iu(e);o.parse(i),this.parsers.push(o)}catch{}}}addPatternsFromContent(e,r){let n=new iu(r);n.parse(e),this.parsers.push(n)}matches(e,r){for(let n of this.parsers){let s=n.getBasePath();if(!e.startsWith(s))continue;let i=e.slice(s.length).replace(/^\//,"");if(n.matches(i,r))return!0}return!1}isWhitelisted(e,r){for(let n of this.parsers){let s=n.getBasePath();if(!e.startsWith(s))continue;let i=e.slice(s.length).replace(/^\//,"");if(n.isWhitelisted(i,r))return!0}return!1}static isCommonIgnored(e){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(e)}}});function iH(t){return t.length>=2&&t[0]===31&&t[1]===139}function oH(t){let e=!1;for(let r=0;r<t.length;r++){let n=t[r];n==="["&&!e?e=!0:n==="]"&&e&&(e=!1)}return e?`rg: glob '${t}' has an unclosed character class`:null}async function d9(t){let{ctx:e,options:r,paths:n,explicitLineNumbers:s}=t;for(let g of r.globs){let y=g.startsWith("!")?g.slice(1):g,x=oH(y);if(x)return{stdout:"",stderr:`${x}
208
- `,exitCode:1}}if(r.files){let g=[...r.patterns,...n];return cH(e,g,r)}let i=[...r.patterns];for(let g of r.patternFiles)try{let y;if(g==="-")y=he(e.stdin);else{let b=e.fs.resolvePath(e.cwd,g);y=await e.fs.readFile(b)}let x=y.split(`
208
+ `,exitCode:1}}if(r.files){let g=[...r.patterns,...n];return cH(e,g,r)}let i=[...r.patterns];for(let g of r.patternFiles)try{let y;if(g==="-")y=fe(e.stdin);else{let b=e.fs.resolvePath(e.cwd,g);y=await e.fs.readFile(b)}let x=y.split(`
209
209
  `).filter(b=>b.length>0);i.push(...x)}catch{return{stdout:"",stderr:`rg: ${g}: No such file or directory
210
210
  `,exitCode:2}}if(i.length===0)return r.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
211
211
  `,exitCode:2};let o=n.length===0?["."]:n,a=aH(r,i),l,c;try{let g=lH(i,r,a);l=g.regex,c=g.kResetGroup}catch{return{stdout:"",stderr:`rg: invalid regex: ${i.join(", ")}
212
212
  `,exitCode:2}}let u=null;r.noIgnore||(u=await Hg(e.fs,e.cwd,r.noIgnoreDot,r.noIgnoreVcs,r.ignoreFiles));let f=new su;for(let g of r.typeClear)f.clearType(g);for(let g of r.typeAdd)f.addType(g);let{files:h,singleExplicitFile:d}=await p9(e,o,r,u,f);if(h.length===0)return{stdout:"",stderr:"",exitCode:1};let p=!r.noFilename&&(r.withFilename||!d||h.length>1),m=r.lineNumber;return s||(d&&h.length===1&&(m=!1),r.onlyMatching&&(m=!1)),hH(e,h,l,r,p,m,c)}function aH(t,e){return t.caseSensitive?!1:t.ignoreCase?!0:t.smartCase?!e.some(r=>/[A-Z]/.test(r)):!1}function lH(t,e,r){let n;return t.length===1?n=t[0]:n=t.map(s=>e.fixedStrings?s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${s})`).join("|"),ru(n,{mode:e.fixedStrings&&t.length===1?"fixed":"perl",ignoreCase:r,wholeWord:e.wordRegexp,lineRegexp:e.lineRegexp,multiline:e.multiline,multilineDotall:e.multilineDotall})}async function p9(t,e,r,n,s){let i=[],o=0,a=0;for(let c of e){let u=t.fs.resolvePath(t.cwd,c);try{let f=await t.fs.stat(u);if(f.isFile){if(o++,r.maxFilesize>0&&f.size>r.maxFilesize)continue;g9(c,r,n,u,s)&&i.push(c)}else f.isDirectory&&(a++,await m9(t,c,u,0,r,n,s,i))}catch{}}return{files:r.sort==="path"?i.sort():i,singleExplicitFile:o===1&&a===0}}async function m9(t,e,r,n,s,i,o,a){if(!(n>=s.maxDepth)){i&&await i.loadForDirectory(r);try{let l=t.fs.readdirWithFileTypes?await t.fs.readdirWithFileTypes(r):(await t.fs.readdir(r)).map(c=>({name:c,isFile:void 0}));for(let c of l){let u=c.name;if(!s.noIgnore&&ou.isCommonIgnored(u))continue;let f=u.startsWith("."),h=e==="."?u:e==="./"?`./${u}`:e.endsWith("/")?`${e}${u}`:`${e}/${u}`,d=t.fs.resolvePath(r,u),p,m,g=!1;if(c.isFile!==void 0&&"isDirectory"in c){let b=c;if(g=b.isSymbolicLink===!0,g&&!s.followSymlinks)continue;if(g&&s.followSymlinks)try{let w=await t.fs.stat(d);p=w.isFile,m=w.isDirectory}catch{continue}else p=b.isFile,m=b.isDirectory}else try{let b=t.fs.lstat?await t.fs.lstat(d):await t.fs.stat(d);if(g=b.isSymbolicLink===!0,g&&!s.followSymlinks)continue;let w=g&&s.followSymlinks?await t.fs.stat(d):b;p=w.isFile,m=w.isDirectory}catch{continue}if(!i?.matches(d,m)&&!(f&&!s.hidden&&!i?.isWhitelisted(d,m))){if(m)await m9(t,h,d,n+1,s,i,o,a);else if(p){if(s.maxFilesize>0)try{if((await t.fs.stat(d)).size>s.maxFilesize)continue}catch{continue}g9(h,s,i,d,o)&&a.push(h)}}}}catch{}}}function g9(t,e,r,n,s){let i=t.split("/").pop()||t;if(r?.matches(n,!1)||e.types.length>0&&!s.matchesType(i,e.types)||e.typesNot.length>0&&s.matchesType(i,e.typesNot))return!1;if(e.globs.length>0){let o=e.globCaseInsensitive,a=e.globs.filter(c=>!c.startsWith("!")),l=e.globs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(a.length>0){let c=!1;for(let u of a)if(Xs(i,u,o)||Xs(t,u,o)){c=!0;break}if(!c)return!1}for(let c of l)if(c.startsWith("/")){let u=c.slice(1);if(Xs(t,u,o))return!1}else if(Xs(i,c,o)||Xs(t,c,o))return!1}if(e.iglobs.length>0){let o=e.iglobs.filter(l=>!l.startsWith("!")),a=e.iglobs.filter(l=>l.startsWith("!")).map(l=>l.slice(1));if(o.length>0){let l=!1;for(let c of o)if(Xs(i,c,!0)||Xs(t,c,!0)){l=!0;break}if(!l)return!1}for(let l of a)if(l.startsWith("/")){let c=l.slice(1);if(Xs(t,c,!0))return!1}else if(Xs(i,l,!0)||Xs(t,l,!0))return!1}return!0}function Xs(t,e,r=!1){let n="^";for(let s=0;s<e.length;s++){let i=e[s];if(i==="*")e[s+1]==="*"?(n+=".*",s++):n+="[^/]*";else if(i==="?")n+="[^/]";else if(i==="["){let o=s+1;for(o<e.length&&e[o]==="!"&&o++,o<e.length&&e[o]==="]"&&o++;o<e.length&&e[o]!=="]";)o++;if(o<e.length){let a=e.slice(s,o+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),n+=a,s=o}else n+="\\["}else n+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return n+="$",ae(n,r?"i":"").test(t)}async function cH(t,e,r){let n=null;r.noIgnore||(n=await Hg(t.fs,t.cwd,r.noIgnoreDot,r.noIgnoreVcs,r.ignoreFiles));let s=new su;for(let c of r.typeClear)s.clearType(c);for(let c of r.typeAdd)s.addType(c);let i=e.length===0?["."]:e,{files:o}=await p9(t,i,r,n,s);if(o.length===0)return{stdout:"",stderr:"",exitCode:1};if(r.quiet)return{stdout:"",stderr:"",exitCode:0};let a=r.nullSeparator?"\0":`
213
- `;return{stdout:o.map(c=>c+a).join(""),stderr:"",exitCode:0}}function uH(t,e){if(e.length===0)return!0;for(let r of e)if(Xs(t,r,!1))return!0;return!1}async function fH(t,e,r,n){try{if(n.preprocessor&&t.exec){let o=r.split("/").pop()||r;if(uH(o,n.preprocessorGlobs)){let a=await t.exec(Vr([n.preprocessor]),{cwd:t.cwd,signal:t.signal,args:[e]});if(a.exitCode===0&&a.stdout){let l=he(a.stdout),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}}}if(n.searchZip&&r.endsWith(".gz")){let o=await t.fs.readFileBuffer(e);if(iH(o))try{let a=(0,h9.gunzipSync)(o),l=new TextDecoder().decode(a),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await t.fs.readFile(e),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function hH(t,e,r,n,s,i,o){let a="",l=!1,c=[],u=0,f=0,h=0,d=50;e:for(let g=0;g<e.length;g+=d){let y=e.slice(g,g+d),x=await Promise.all(y.map(async b=>{let w=t.fs.resolvePath(t.cwd,b),S=await fH(t,w,b,n);if(!S)return null;let{content:_,isBinary:P}=S;if(h+=_.length,P&&!n.searchBinary)return null;let F=s&&!n.heading?b:"",R=bl(_,r,{invertMatch:n.invertMatch,showLineNumbers:i,countOnly:n.count,countMatches:n.countMatches,filename:F,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace!==null?Lg(n.replace):null,passthru:n.passthru,multiline:n.multiline,kResetGroup:o});return n.json&&R.matched?{file:b,result:R,content:_,isBinary:!1}:{file:b,result:R}}));for(let b of x){if(!b)continue;let{file:w,result:S}=b;if(S.matched){if(l=!0,f++,u+=S.matchCount,n.quiet&&!n.json)break e;if(n.json&&!n.quiet){let _=b.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:w}}}));let P=_.split(`
213
+ `;return{stdout:o.map(c=>c+a).join(""),stderr:"",exitCode:0}}function uH(t,e){if(e.length===0)return!0;for(let r of e)if(Xs(t,r,!1))return!0;return!1}async function fH(t,e,r,n){try{if(n.preprocessor&&t.exec){let o=r.split("/").pop()||r;if(uH(o,n.preprocessorGlobs)){let a=await t.exec(Vr([n.preprocessor]),{cwd:t.cwd,signal:t.signal,args:[e]});if(a.exitCode===0&&a.stdout){let l=fe(a.stdout),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}}}if(n.searchZip&&r.endsWith(".gz")){let o=await t.fs.readFileBuffer(e);if(iH(o))try{let a=(0,h9.gunzipSync)(o),l=new TextDecoder().decode(a),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await t.fs.readFile(e),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function hH(t,e,r,n,s,i,o){let a="",l=!1,c=[],u=0,f=0,h=0,d=50;e:for(let g=0;g<e.length;g+=d){let y=e.slice(g,g+d),x=await Promise.all(y.map(async b=>{let w=t.fs.resolvePath(t.cwd,b),S=await fH(t,w,b,n);if(!S)return null;let{content:_,isBinary:P}=S;if(h+=_.length,P&&!n.searchBinary)return null;let F=s&&!n.heading?b:"",R=bl(_,r,{invertMatch:n.invertMatch,showLineNumbers:i,countOnly:n.count,countMatches:n.countMatches,filename:F,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace!==null?Lg(n.replace):null,passthru:n.passthru,multiline:n.multiline,kResetGroup:o});return n.json&&R.matched?{file:b,result:R,content:_,isBinary:!1}:{file:b,result:R}}));for(let b of x){if(!b)continue;let{file:w,result:S}=b;if(S.matched){if(l=!0,f++,u+=S.matchCount,n.quiet&&!n.json)break e;if(n.json&&!n.quiet){let _=b.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:w}}}));let P=_.split(`
214
214
  `);r.lastIndex=0;let F=0;for(let R=0;R<P.length;R++){let $=P[R];r.lastIndex=0;let N=[];for(let k=r.exec($);k!==null;k=r.exec($)){let T={match:{text:k[0]},start:k.index,end:k.index+k[0].length};n.replace!==null&&(T.replacement={text:n.replace}),N.push(T),k[0].length===0&&r.lastIndex++}if(N.length>0){let k={type:"match",data:{path:{text:w},lines:{text:`${$}
215
215
  `},line_number:R+1,absolute_offset:F,submatches:N}};c.push(JSON.stringify(k))}F+=$.length+1}c.push(JSON.stringify({type:"end",data:{path:{text:w},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:_.length,bytes_printed:0,matched_lines:S.matchCount,matches:S.matchCount}}}))}else if(n.filesWithMatches){let _=n.nullSeparator?"\0":`
216
216
  `;a+=`${w}${_}`}else n.filesWithoutMatch||(n.heading&&!n.noFilename&&(a+=`${w}
@@ -234,14 +234,14 @@ EXAMPLES:
234
234
  `,r+=2;continue}if(s==="r"){e+="\r",r+=2;continue}e+=t[r]+s,r+=2;continue}if(t[r]==="+"||t[r]==="?"||t[r]==="|"||t[r]==="("||t[r]===")"){e+=`\\${t[r]}`,r++;continue}if(t[r]==="^"&&!(e===""||e.endsWith("("))){e+="\\^",r++;continue}if(t[r]==="$"){let s=r===t.length-1,i=r+2<t.length&&t[r+1]==="\\"&&t[r+2]===")";if(!s&&!i){e+="\\$",r++;continue}}e+=t[r],r++}return e}function Kg(t){let e="",r=!1;for(let n=0;n<t.length;n++)t[n]==="["&&!r?(r=!0,e+="[",n++,n<t.length&&t[n]==="^"&&(e+="^",n++),n<t.length&&t[n]==="]"&&(e+="]",n++),n--):t[n]==="]"&&r?(r=!1,e+="]"):!r&&t[n]==="{"&&t[n+1]===","?(e+="{0,",n++):e+=t[n];return e}function b9(t){let e="";for(let r=0;r<t.length;r++){let n=t[r],s=n.charCodeAt(0);n==="\\"?e+="\\\\":n===" "?e+="\\t":n===`
235
235
  `?e+=`$
236
236
  `:n==="\r"?e+="\\r":n==="\x07"?e+="\\a":n==="\b"?e+="\\b":n==="\f"?e+="\\f":n==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=n}return`${e}$`}var Vg,w9=I(()=>{"use strict";Vg=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]])});function S9(t,e,r){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:t,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],rangeStates:r||new Map,linesConsumedInCycle:0}}function gH(t){return typeof t=="object"&&"first"in t&&"step"in t}function yH(t){return typeof t=="object"&&"offset"in t}function wl(t,e,r,n,s){if(t==="$")return e===r;if(typeof t=="number")return e===t;if(gH(t)){let{first:i,step:o}=t;return o===0?e===i:(e-i)%o===0&&e>=i}if(typeof t=="object"&&"pattern"in t)try{let i=t.pattern;i===""&&s?.lastPattern?i=s.lastPattern:i!==""&&s&&(s.lastPattern=i);let o=Kg(Gg(i));return ae(o).test(n)}catch{return!1}return!1}function Zg(t){let e=r=>r===void 0?"undefined":r==="$"?"$":typeof r=="number"?String(r):"pattern"in r?`/${r.pattern}/`:"first"in r?`${r.first}~${r.step}`:"unknown";return`${e(t.start)},${e(t.end)}`}function xH(t,e,r,n,s,i){if(!t||!t.start&&!t.end)return!0;let o=t.start,a=t.end;if(o!==void 0&&a===void 0)return wl(o,e,r,n,i);if(o!==void 0&&a!==void 0){let l=typeof o=="object"&&"pattern"in o,c=typeof a=="object"&&"pattern"in a,u=yH(a);if(u&&s){let h=Zg(t),d=s.get(h);if(d||(d={active:!1},s.set(h,d)),d.active){let p=d.startLine||e;return e>=p+a.offset&&(d.active=!1,s.set(h,d)),!0}else return wl(o,e,r,n,i)?(d.active=!0,d.startLine=e,s.set(h,d),a.offset===0&&(d.active=!1,s.set(h,d)),!0):!1}if(!l&&!c&&!u){let h=typeof o=="number"?o:o==="$"?r:1,d=typeof a=="number"?a:r;if(h<=d)return e>=h&&e<=d;if(s){let p=Zg(t),m=s.get(p);return m||(m={active:!1},s.set(p,m)),!m.completed&&e>=h?(m.completed=!0,s.set(p,m),!0):!1}return!1}if(s){let h=Zg(t),d=s.get(h);if(d||(d={active:!1},s.set(h,d)),d.active)return wl(a,e,r,n,i)&&(d.active=!1,typeof o=="number"&&(d.completed=!0),s.set(h,d)),!0;{if(d.completed)return!1;let p=!1;return typeof o=="number"?p=e>=o:p=wl(o,e,r,n,i),p?(d.active=!0,d.startLine=e,s.set(h,d),wl(a,e,r,n,i)&&(d.active=!1,typeof o=="number"&&(d.completed=!0),s.set(h,d)),!0):!1}}return wl(o,e,r,n,i)}return!0}function ya(t,e,r,n,s,i){let o=xH(t,e,r,n,s,i);return t?.negated?!o:o}function bH(t,e,r,n){let s="",i=0,o=!1;for(;i<=t.length;){e.lastIndex=i;let a=e.exec(t);if(!a){s+=t.slice(i);break}if(a.index!==i){s+=t.slice(i,a.index),i=a.index,o=!1;continue}let l=a[0],c=a.slice(1);if(o&&l.length===0){if(i<t.length)s+=t[i],i++;else break;o=!1;continue}if(s+=n(l,c),o=!1,l.length===0)if(i<t.length)s+=t[i],i++;else break;else i+=l.length,o=!0}return s}function Yg(t,e,r){let n="",s=0;for(;s<t.length;){if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&"){n+="&",s+=2;continue}if(i==="n"){n+=`
237
- `,s+=2;continue}if(i==="t"){n+=" ",s+=2;continue}if(i==="r"){n+="\r",s+=2;continue}let o=parseInt(i,10);if(o===0){n+=e,s+=2;continue}if(o>=1&&o<=9){n+=r[o-1]||"",s+=2;continue}n+=i,s+=2;continue}if(t[s]==="&"){n+=e,s++;continue}n+=t[s],s++}return n}function E9(t,e,r){if(e>0&&t.length>e)throw new fe(`sed: ${r} size limit exceeded (${e} bytes)`,"string_length")}function wH(t,e,r){let{lineNumber:n,totalLines:s,patternSpace:i}=e;if(t.type==="label"){e.coverage?.hit(`sed:cmd:${t.type}`);return}if(ya(t.address,n,s,i,e.rangeStates,e))switch(e.coverage?.hit(`sed:cmd:${t.type}`),t.type){case"substitute":{let o=t,a="";o.global&&(a+="g"),o.ignoreCase&&(a+="i");let l=o.pattern;l===""&&e.lastPattern?l=e.lastPattern:l!==""&&(e.lastPattern=l);let c=Kg(o.extendedRegex?l:Gg(l));try{let u=ae(c,a),f=u.test(e.patternSpace);if(u.lastIndex=0,f){if(e.substitutionMade=!0,o.nthOccurrence&&o.nthOccurrence>0&&!o.global){let h=0,d=o.nthOccurrence,p=ae(c,`g${o.ignoreCase?"i":""}`);e.patternSpace=p.replace(e.patternSpace,(m,...g)=>{if(h++,h===d){let y=g.slice(0,-2);return Yg(o.replacement,m,y)}return m})}else if(o.global){let h=ae(c,`g${o.ignoreCase?"i":""}`);e.patternSpace=bH(e.patternSpace,h,o.replacement,(d,p)=>Yg(o.replacement,d,p))}else e.patternSpace=u.replace(e.patternSpace,(h,...d)=>{let p=d.slice(0,-2);return Yg(o.replacement,h,p)});o.printOnMatch&&e.lineNumberOutput.push(e.patternSpace)}}catch{}break}case"print":e.lineNumberOutput.push(e.patternSpace);break;case"printFirstLine":{let o=e.patternSpace.indexOf(`
237
+ `,s+=2;continue}if(i==="t"){n+=" ",s+=2;continue}if(i==="r"){n+="\r",s+=2;continue}let o=parseInt(i,10);if(o===0){n+=e,s+=2;continue}if(o>=1&&o<=9){n+=r[o-1]||"",s+=2;continue}n+=i,s+=2;continue}if(t[s]==="&"){n+=e,s++;continue}n+=t[s],s++}return n}function E9(t,e,r){if(e>0&&t.length>e)throw new he(`sed: ${r} size limit exceeded (${e} bytes)`,"string_length")}function wH(t,e,r){let{lineNumber:n,totalLines:s,patternSpace:i}=e;if(t.type==="label"){e.coverage?.hit(`sed:cmd:${t.type}`);return}if(ya(t.address,n,s,i,e.rangeStates,e))switch(e.coverage?.hit(`sed:cmd:${t.type}`),t.type){case"substitute":{let o=t,a="";o.global&&(a+="g"),o.ignoreCase&&(a+="i");let l=o.pattern;l===""&&e.lastPattern?l=e.lastPattern:l!==""&&(e.lastPattern=l);let c=Kg(o.extendedRegex?l:Gg(l));try{let u=ae(c,a),f=u.test(e.patternSpace);if(u.lastIndex=0,f){if(e.substitutionMade=!0,o.nthOccurrence&&o.nthOccurrence>0&&!o.global){let h=0,d=o.nthOccurrence,p=ae(c,`g${o.ignoreCase?"i":""}`);e.patternSpace=p.replace(e.patternSpace,(m,...g)=>{if(h++,h===d){let y=g.slice(0,-2);return Yg(o.replacement,m,y)}return m})}else if(o.global){let h=ae(c,`g${o.ignoreCase?"i":""}`);e.patternSpace=bH(e.patternSpace,h,o.replacement,(d,p)=>Yg(o.replacement,d,p))}else e.patternSpace=u.replace(e.patternSpace,(h,...d)=>{let p=d.slice(0,-2);return Yg(o.replacement,h,p)});o.printOnMatch&&e.lineNumberOutput.push(e.patternSpace)}}catch{}break}case"print":e.lineNumberOutput.push(e.patternSpace);break;case"printFirstLine":{let o=e.patternSpace.indexOf(`
238
238
  `);o!==-1?e.lineNumberOutput.push(e.patternSpace.slice(0,o)):e.lineNumberOutput.push(e.patternSpace);break}case"delete":e.deleted=!0;break;case"deleteFirstLine":{let o=e.patternSpace.indexOf(`
239
239
  `);o!==-1?(e.patternSpace=e.patternSpace.slice(o+1),e.restartCycle=!0,e.inDRestartedCycle=!0):e.deleted=!0;break}case"zap":e.patternSpace="";break;case"append":e.appendBuffer.push(t.text);break;case"insert":e.appendBuffer.unshift(`__INSERT__${t.text}`);break;case"change":e.deleted=!0,e.changedText=t.text;break;case"hold":e.holdSpace=e.patternSpace;break;case"holdAppend":e.holdSpace?e.holdSpace+=`
240
240
  ${e.patternSpace}`:e.holdSpace=e.patternSpace,E9(e.holdSpace,r?.maxStringLength??0,"hold space");break;case"get":e.patternSpace=e.holdSpace;break;case"getAppend":e.patternSpace+=`
241
241
  ${e.holdSpace}`,E9(e.patternSpace,r?.maxStringLength??0,"pattern space");break;case"exchange":{let o=e.patternSpace;e.patternSpace=e.holdSpace,e.holdSpace=o;break}case"next":e.printed=!0;break;case"quit":e.quit=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"quitSilent":e.quit=!0,e.quitSilent=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"list":{let o=b9(e.patternSpace);e.lineNumberOutput.push(o);break}case"printFilename":e.currentFilename&&e.lineNumberOutput.push(e.currentFilename);break;case"version":{let o=[4,8,0];if(t.minVersion){let a=t.minVersion.split("."),l=[],c=!1;for(let u of a){let f=parseInt(u,10);if(Number.isNaN(f)||f<0){e.quit=!0,e.exitCode=1,e.errorMessage=`sed: invalid version string: ${t.minVersion}`,c=!0;break}l.push(f)}if(!c){for(;l.length<3;)l.push(0);for(let u=0;u<3;u++){if(l[u]>o[u]){e.quit=!0,e.exitCode=1,e.errorMessage=`sed: this is not GNU sed version ${t.minVersion}`;break}if(l[u]<o[u])break}}}break}case"readFile":e.pendingFileReads.push({filename:t.filename,wholeFile:!0});break;case"readFileLine":e.pendingFileReads.push({filename:t.filename,wholeFile:!1});break;case"writeFile":e.pendingFileWrites.push({filename:t.filename,content:`${e.patternSpace}
242
242
  `});break;case"writeFirstLine":{let o=e.patternSpace.indexOf(`
243
243
  `),a=o!==-1?e.patternSpace.slice(0,o):e.patternSpace;e.pendingFileWrites.push({filename:t.filename,content:`${a}
244
- `});break}case"execute":e.errorMessage="sed: e command (shell execution) is not supported in sandboxed environment",e.quit=!0;break;case"transliterate":e.patternSpace=EH(e.patternSpace,t);break;case"lineNumber":e.lineNumberOutput.push(String(e.lineNumber));break;case"branch":break;case"branchOnSubst":break;case"branchOnNoSubst":break;case"group":break}}function EH(t,e){let r="";for(let n of t){let s=e.source.indexOf(n);s!==-1?r+=e.dest[s]:r+=n}return r}function Xg(t,e,r,n){let s=new Map;for(let l=0;l<t.length;l++){let c=t[l];c.type==="label"&&s.set(c.name,l)}let i=n?.maxIterations??mH,o=0,a=0;for(;a<t.length;){if(o++,o>i)throw new fe(`sed: command execution exceeded maximum iterations (${i})`,"iterations");if(e.deleted||e.quit||e.quitSilent||e.restartCycle)break;let l=t[a];if(l.type==="next"){if(ya(l.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e))if(e.coverage?.hit("sed:cmd:next"),e.nCommandOutput.push(e.patternSpace),r&&r.currentLineIndex+e.linesConsumedInCycle+1<r.lines.length){e.linesConsumedInCycle++;let c=r.lines[r.currentLineIndex+e.linesConsumedInCycle];e.patternSpace=c,e.lineNumber=r.currentLineIndex+e.linesConsumedInCycle+1,e.substitutionMade=!1}else{e.quit=!0,e.deleted=!0;break}a++;continue}if(l.type==="nextAppend"){if(ya(l.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e))if(e.coverage?.hit("sed:cmd:nextAppend"),r&&r.currentLineIndex+e.linesConsumedInCycle+1<r.lines.length){e.linesConsumedInCycle++;let c=r.lines[r.currentLineIndex+e.linesConsumedInCycle];e.patternSpace+=`
244
+ `});break}case"execute":e.errorMessage="sed: e command (shell execution) is not supported in sandboxed environment",e.quit=!0;break;case"transliterate":e.patternSpace=EH(e.patternSpace,t);break;case"lineNumber":e.lineNumberOutput.push(String(e.lineNumber));break;case"branch":break;case"branchOnSubst":break;case"branchOnNoSubst":break;case"group":break}}function EH(t,e){let r="";for(let n of t){let s=e.source.indexOf(n);s!==-1?r+=e.dest[s]:r+=n}return r}function Xg(t,e,r,n){let s=new Map;for(let l=0;l<t.length;l++){let c=t[l];c.type==="label"&&s.set(c.name,l)}let i=n?.maxIterations??mH,o=0,a=0;for(;a<t.length;){if(o++,o>i)throw new he(`sed: command execution exceeded maximum iterations (${i})`,"iterations");if(e.deleted||e.quit||e.quitSilent||e.restartCycle)break;let l=t[a];if(l.type==="next"){if(ya(l.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e))if(e.coverage?.hit("sed:cmd:next"),e.nCommandOutput.push(e.patternSpace),r&&r.currentLineIndex+e.linesConsumedInCycle+1<r.lines.length){e.linesConsumedInCycle++;let c=r.lines[r.currentLineIndex+e.linesConsumedInCycle];e.patternSpace=c,e.lineNumber=r.currentLineIndex+e.linesConsumedInCycle+1,e.substitutionMade=!1}else{e.quit=!0,e.deleted=!0;break}a++;continue}if(l.type==="nextAppend"){if(ya(l.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e))if(e.coverage?.hit("sed:cmd:nextAppend"),r&&r.currentLineIndex+e.linesConsumedInCycle+1<r.lines.length){e.linesConsumedInCycle++;let c=r.lines[r.currentLineIndex+e.linesConsumedInCycle];e.patternSpace+=`
245
245
  ${c}`,e.lineNumber=r.currentLineIndex+e.linesConsumedInCycle+1}else{e.quit=!0;break}a++;continue}if(l.type==="branch"){let c=l;if(ya(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)){if(e.coverage?.hit("sed:cmd:branch"),c.label){let u=s.get(c.label);if(u!==void 0){a=u;continue}e.branchRequest=c.label;break}break}a++;continue}if(l.type==="branchOnSubst"){let c=l;if(ya(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)&&(e.coverage?.hit("sed:cmd:branchOnSubst"),e.substitutionMade)){if(e.substitutionMade=!1,c.label){let u=s.get(c.label);if(u!==void 0){a=u;continue}e.branchRequest=c.label;break}break}a++;continue}if(l.type==="branchOnNoSubst"){let c=l;if(ya(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)&&(e.coverage?.hit("sed:cmd:branchOnNoSubst"),!e.substitutionMade)){if(c.label){let u=s.get(c.label);if(u!==void 0){a=u;continue}e.branchRequest=c.label;break}break}a++;continue}if(l.type==="group"){let c=l;if(ya(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates,e)&&(e.coverage?.hit("sed:cmd:group"),Xg(c.commands,e,r,n),e.branchRequest)){let u=s.get(e.branchRequest);if(u!==void 0){e.branchRequest=void 0,a=u;continue}break}a++;continue}wH(l,e,n),a++}return e.linesConsumedInCycle}var mH,v9=I(()=>{"use strict";rt();Gt();w9();mH=1e4});var ye,Wh,A9=I(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.DOLLAR="DOLLAR",t.PATTERN="PATTERN",t.STEP="STEP",t.RELATIVE_OFFSET="RELATIVE_OFFSET",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.COMMA="COMMA",t.NEGATION="NEGATION",t.COMMAND="COMMAND",t.SUBSTITUTE="SUBSTITUTE",t.TRANSLITERATE="TRANSLITERATE",t.LABEL_DEF="LABEL_DEF",t.BRANCH="BRANCH",t.BRANCH_ON_SUBST="BRANCH_ON_SUBST",t.BRANCH_ON_NO_SUBST="BRANCH_ON_NO_SUBST",t.TEXT_CMD="TEXT_CMD",t.FILE_READ="FILE_READ",t.FILE_READ_LINE="FILE_READ_LINE",t.FILE_WRITE="FILE_WRITE",t.FILE_WRITE_LINE="FILE_WRITE_LINE",t.EXECUTE="EXECUTE",t.VERSION="VERSION",t.EOF="EOF",t.ERROR="ERROR"})(ye||(ye={}));Wh=class{input;pos=0;line=1;column=1;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&e.push(r)}return e.push(this.makeToken(ye.EOF,"")),e}makeToken(e,r,n){return{type:e,value:r,line:this.line,column:this.column,...n}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
246
246
  `?(this.line++,this.column=1):this.column++,e}readEscapedString(e){let r="";for(;this.pos<this.input.length&&this.peek()!==e;)if(this.peek()==="\\"){this.advance();let n=this.advance();n==="n"?r+=`
247
247
  `:n==="t"?r+=" ":r+=n}else{if(this.peek()===`
@@ -274,7 +274,7 @@ ${c}`,e.lineNumber=r.currentLineIndex+e.linesConsumedInCycle+1}else{e.quit=!0;br
274
274
  ${c}`}else s.push(c)}let i=s.join(`
275
275
  `),a=new Qg([i],e||n).parse();if(!a.error&&a.commands.length>0){let l=SH(a.commands);if(l)return{commands:[],error:l,silentMode:r,extendedRegexMode:n}}return{...a,silentMode:r,extendedRegexMode:n}}function SH(t){let e=new Set;N9(t,e);let r=k9(t,e);if(r)return`undefined label '${r}'`}function N9(t,e){for(let r of t)r.type==="label"?e.add(r.name):r.type==="group"&&N9(r.commands,e)}function k9(t,e){for(let r of t){if((r.type==="branch"||r.type==="branchOnSubst"||r.type==="branchOnNoSubst")&&r.label&&!e.has(r.label))return r.label;if(r.type==="group"){let n=k9(r.commands,e);if(n)return n}}}var Qg,T9=I(()=>{"use strict";A9();Qg=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(e,r=!1){this.scripts=e,this.extendedRegex=r}parse(){let e=[];for(let r of this.scripts){let n=new Wh(r);for(this.tokens=n.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(ye.NEWLINE)||this.check(ye.SEMICOLON)){this.advance();continue}let s=this.pos,i=this.parseCommand();if(i.error)return{commands:[],error:i.error};if(i.command&&e.push(i.command),this.pos===s&&!this.isAtEnd())return{commands:[],error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();if(e?.error)return{command:null,error:e.error};let r=e?.address;for(this.check(ye.NEGATION)&&(this.advance(),r&&(r.negated=!0));this.check(ye.NEWLINE)||this.check(ye.SEMICOLON);)this.advance();if(this.isAtEnd())return r&&(r.start!==void 0||r.end!==void 0)?{command:null,error:"command expected"}:{command:null};let n=this.peek();switch(n.type){case ye.COMMAND:return this.parseSimpleCommand(n,r);case ye.SUBSTITUTE:return this.parseSubstituteFromToken(n,r);case ye.TRANSLITERATE:return this.parseTransliterateFromToken(n,r);case ye.LABEL_DEF:return this.advance(),{command:{type:"label",name:n.label||""}};case ye.BRANCH:return this.advance(),{command:{type:"branch",address:r,label:n.label}};case ye.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:r,label:n.label}};case ye.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:r,label:n.label}};case ye.TEXT_CMD:return this.advance(),this.parseTextCommand(n,r);case ye.FILE_READ:return this.advance(),{command:{type:"readFile",address:r,filename:n.filename||""}};case ye.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:r,filename:n.filename||""}};case ye.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:r,filename:n.filename||""}};case ye.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:r,filename:n.filename||""}};case ye.EXECUTE:return this.advance(),{command:{type:"execute",address:r,command:n.command}};case ye.VERSION:return this.advance(),{command:{type:"version",address:r,minVersion:n.label}};case ye.LBRACE:return this.parseGroup(r);case ye.RBRACE:return{command:null};case ye.ERROR:return{command:null,error:`invalid command: ${n.value}`};default:return r&&(r.start!==void 0||r.end!==void 0)?{command:null,error:"command expected"}:{command:null}}}parseSimpleCommand(e,r){this.advance();let n=e.value;switch(n){case"p":return{command:{type:"print",address:r}};case"P":return{command:{type:"printFirstLine",address:r}};case"d":return{command:{type:"delete",address:r}};case"D":return{command:{type:"deleteFirstLine",address:r}};case"h":return{command:{type:"hold",address:r}};case"H":return{command:{type:"holdAppend",address:r}};case"g":return{command:{type:"get",address:r}};case"G":return{command:{type:"getAppend",address:r}};case"x":return{command:{type:"exchange",address:r}};case"n":return{command:{type:"next",address:r}};case"N":return{command:{type:"nextAppend",address:r}};case"q":return{command:{type:"quit",address:r}};case"Q":return{command:{type:"quitSilent",address:r}};case"z":return{command:{type:"zap",address:r}};case"=":return{command:{type:"lineNumber",address:r}};case"l":return{command:{type:"list",address:r}};case"F":return{command:{type:"printFilename",address:r}};default:return{command:null,error:`unknown command: ${n}`}}}parseSubstituteFromToken(e,r){this.advance();let n=e.flags||"",s,i=n.match(/(\d+)/);return i&&(s=parseInt(i[1],10)),{command:{type:"substitute",address:r,pattern:e.pattern||"",replacement:e.replacement||"",global:n.includes("g"),ignoreCase:n.includes("i")||n.includes("I"),printOnMatch:n.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,r){this.advance();let n=e.source||"",s=e.dest||"";return n.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:r,source:n,dest:s}}}parseTextCommand(e,r){let n=e.value,s=e.text||"";switch(n){case"a":return{command:{type:"append",address:r,text:s}};case"i":return{command:{type:"insert",address:r,text:s}};case"c":return{command:{type:"change",address:r,text:s}};default:return{command:null,error:`unknown text command: ${n}`}}}parseGroup(e){this.advance();let r=[];for(;!this.isAtEnd()&&!this.check(ye.RBRACE);){if(this.check(ye.NEWLINE)||this.check(ye.SEMICOLON)){this.advance();continue}let n=this.pos,s=this.parseCommand();if(s.error)return{command:null,error:s.error};if(s.command&&r.push(s.command),this.pos===n&&!this.isAtEnd())return{command:null,error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}return this.check(ye.RBRACE)?(this.advance(),{command:{type:"group",address:e,commands:r}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){if(this.check(ye.COMMA))return{error:"expected context address"};let e=this.parseAddress();if(e===void 0)return;let r;if(this.check(ye.RELATIVE_OFFSET))r={offset:this.advance().offset||0};else if(this.check(ye.COMMA)&&(this.advance(),r=this.parseAddress(),r===void 0))return{error:"expected context address"};return{address:{start:e,end:r}}}parseAddress(){let e=this.peek();switch(e.type){case ye.NUMBER:return this.advance(),e.value;case ye.DOLLAR:return this.advance(),"$";case ye.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case ye.STEP:return this.advance(),{first:e.first||0,step:e.step||0};case ye.RELATIVE_OFFSET:return this.advance(),{offset:e.offset||0};default:return}}peek(){return this.tokens[this.pos]||{type:ye.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===ye.EOF}}});var _9={};ue(_9,{flagsForFuzzing:()=>e2,sedCommand:()=>AH});async function Jg(t,e,r,n={}){let{limits:s,filename:i,fs:o,cwd:a,coverage:l,requireDefenseContext:c}=n;rr(c,"sed","processing entry");let u=($,N)=>sn(c,"sed",$,N),f=t.endsWith(`
276
276
  `),h=t.split(`
277
- `);h.length>0&&h[h.length-1]===""&&h.pop();let d=h.length,p="",m,g=!1,y=s?.maxStringLength??0,x=$=>{if(p+=$,y>0&&p.length>y)throw new fe(`sed: output size limit exceeded (${y} bytes)`,"string_length")},b="",w,S=new Map,_=new Map,P=new Map,F=new Map,R=s?{maxIterations:s.maxSedIterations,maxStringLength:y}:void 0;for(let $=0;$<h.length;$++){let N={...S9(d,i,S),patternSpace:h[$],holdSpace:b,lastPattern:w,lineNumber:$+1,totalLines:d,substitutionMade:!1,coverage:l},k={lines:h,currentLineIndex:$},T=0,E=1e4;N.linesConsumedInCycle=0;do{if(T++,T>E)break;if(N.restartCycle=!1,N.pendingFileReads=[],N.pendingFileWrites=[],Xg(e,N,k,R),o&&a){for(let H of N.pendingFileReads){let Q=o.resolvePath(a,H.filename);try{if(H.wholeFile){let te=await u("read command file",()=>o.readFile(Q));N.appendBuffer.push(te.replace(/\n$/,""))}else{if(!_.has(Q)){let U=await u("read command file line cache",()=>o.readFile(Q));_.set(Q,U.split(`
277
+ `);h.length>0&&h[h.length-1]===""&&h.pop();let d=h.length,p="",m,g=!1,y=s?.maxStringLength??0,x=$=>{if(p+=$,y>0&&p.length>y)throw new he(`sed: output size limit exceeded (${y} bytes)`,"string_length")},b="",w,S=new Map,_=new Map,P=new Map,F=new Map,R=s?{maxIterations:s.maxSedIterations,maxStringLength:y}:void 0;for(let $=0;$<h.length;$++){let N={...S9(d,i,S),patternSpace:h[$],holdSpace:b,lastPattern:w,lineNumber:$+1,totalLines:d,substitutionMade:!1,coverage:l},k={lines:h,currentLineIndex:$},T=0,E=1e4;N.linesConsumedInCycle=0;do{if(T++,T>E)break;if(N.restartCycle=!1,N.pendingFileReads=[],N.pendingFileWrites=[],Xg(e,N,k,R),o&&a){for(let H of N.pendingFileReads){let Q=o.resolvePath(a,H.filename);try{if(H.wholeFile){let te=await u("read command file",()=>o.readFile(Q));N.appendBuffer.push(te.replace(/\n$/,""))}else{if(!_.has(Q)){let U=await u("read command file line cache",()=>o.readFile(Q));_.set(Q,U.split(`
278
278
  `)),P.set(Q,0)}let te=_.get(Q),le=P.get(Q);te&&le!==void 0&&le<te.length&&(N.appendBuffer.push(te[le]),P.set(Q,le+1))}}catch(te){if(te instanceof Fe)throw te}}for(let H of N.pendingFileWrites){let Q=o.resolvePath(a,H.filename),te=F.get(Q)||"";F.set(Q,te+H.content)}}}while(N.restartCycle&&!N.deleted&&!N.quit&&!N.quitSilent);if($+=N.linesConsumedInCycle,b=N.holdSpace,w=N.lastPattern,!r)for(let H of N.nCommandOutput)x(`${H}
279
279
  `);let L=N.lineNumberOutput.length>0;for(let H of N.lineNumberOutput)x(`${H}
280
280
  `);let B=[],K=[];for(let H of N.appendBuffer)H.startsWith("__INSERT__")?B.push(H.slice(10)):K.push(H);for(let H of B)x(`${H}
@@ -318,22 +318,22 @@ Addresses:
318
318
  `,exitCode:1};let{commands:c,error:u,silentMode:f}=C9(n,a);if(u)return{stdout:"",stderr:`sed: ${u}
319
319
  `,exitCode:1};let h=!!(i||f);if(o){if(l.length===0)return{stdout:"",stderr:`sed: -i requires at least one file argument
320
320
  `,exitCode:1};for(let m of l){if(m==="-")continue;let g=e.fs.resolvePath(e.cwd,m);try{let y=await r("in-place input read",()=>e.fs.readFile(g)),x=await r("in-place processing",()=>Jg(y,c,h,{limits:e.limits,filename:m,fs:e.fs,cwd:e.cwd,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext}));if(x.errorMessage)return{stdout:"",stderr:`${x.errorMessage}
321
- `,exitCode:x.exitCode??1};await r("in-place output write",()=>e.fs.writeFile(g,x.output))}catch(y){if(y instanceof Fe)throw y;return y instanceof fe?{stdout:"",stderr:`sed: ${Je(y.message)}
322
- `,exitCode:fe.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory
323
- `,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}let d="";if(l.length===0){d=he(e.stdin);try{let m=await r("stdin processing",()=>Jg(d,c,h,{limits:e.limits,fs:e.fs,cwd:e.cwd,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext}));return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage}
324
- `:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof Fe)throw m;if(m instanceof fe)return{stdout:"",stderr:`sed: ${Je(m.message)}
325
- `,exitCode:fe.EXIT_CODE};throw m}}let p=!1;for(let m of l){let g;if(m==="-")p?g="":(g=he(e.stdin),p=!0);else{let y=e.fs.resolvePath(e.cwd,m);try{g=await r("input file read",()=>e.fs.readFile(y))}catch(x){if(x instanceof Fe)throw x;return x instanceof fe?{stdout:"",stderr:`sed: ${Je(x.message)}
326
- `,exitCode:fe.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory
321
+ `,exitCode:x.exitCode??1};await r("in-place output write",()=>e.fs.writeFile(g,x.output))}catch(y){if(y instanceof Fe)throw y;return y instanceof he?{stdout:"",stderr:`sed: ${Je(y.message)}
322
+ `,exitCode:he.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory
323
+ `,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}let d="";if(l.length===0){d=fe(e.stdin);try{let m=await r("stdin processing",()=>Jg(d,c,h,{limits:e.limits,fs:e.fs,cwd:e.cwd,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext}));return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage}
324
+ `:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof Fe)throw m;if(m instanceof he)return{stdout:"",stderr:`sed: ${Je(m.message)}
325
+ `,exitCode:he.EXIT_CODE};throw m}}let p=!1;for(let m of l){let g;if(m==="-")p?g="":(g=fe(e.stdin),p=!0);else{let y=e.fs.resolvePath(e.cwd,m);try{g=await r("input file read",()=>e.fs.readFile(y))}catch(x){if(x instanceof Fe)throw x;return x instanceof he?{stdout:"",stderr:`sed: ${Je(x.message)}
326
+ `,exitCode:he.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory
327
327
  `,exitCode:1}}}d.length>0&&g.length>0&&!d.endsWith(`
328
328
  `)&&(d+=`
329
329
  `),d+=g}try{let m=await r("final processing",()=>Jg(d,c,h,{limits:e.limits,filename:l.length===1?l[0]:void 0,fs:e.fs,cwd:e.cwd,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext}));return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage}
330
- `:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof Fe)throw m;if(m instanceof fe)return{stdout:"",stderr:`sed: ${Je(m.message)}
331
- `,exitCode:fe.EXIT_CODE};throw m}}},e2={name:"sed",flags:[{flag:"-n",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-E",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-e",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function Cr(t){return Object.assign(Object.create(null),Object.fromEntries(t))}function Is(t,e){return Object.assign(Object.create(null),Object.fromEntries(t),e)}function Xi(...t){return Object.assign(Object.create(null),...t)}var Rs=I(()=>{"use strict"});function r2(t={}){let{fieldSep:e=kH,maxIterations:r=CH,maxRecursionDepth:n=NH,maxOutputSize:s=0,fs:i,cwd:o,exec:a,coverage:l,requireDefenseContext:c}=t;return{FS:" ",OFS:" ",ORS:`
330
+ `:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof Fe)throw m;if(m instanceof he)return{stdout:"",stderr:`sed: ${Je(m.message)}
331
+ `,exitCode:he.EXIT_CODE};throw m}}},e2={name:"sed",flags:[{flag:"-n",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-E",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-e",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function Cr(t){return Object.assign(Object.create(null),Object.fromEntries(t))}function Is(t,e){return Object.assign(Object.create(null),Object.fromEntries(t),e)}function Xi(...t){return Object.assign(Object.create(null),...t)}var Rs=I(()=>{"use strict"});function r2(t={}){let{fieldSep:e=kH,maxIterations:r=CH,maxRecursionDepth:n=NH,maxOutputSize:s=0,fs:i,cwd:o,exec:a,coverage:l,requireDefenseContext:c}=t;return{FS:" ",OFS:" ",ORS:`
332
332
  `,OFMT:"%.6g",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,fieldSep:e,maxIterations:r,maxRecursionDepth:n,maxOutputSize:s,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:i,cwd:o,exec:a,coverage:l,requireDefenseContext:c}}var CH,NH,kH,O9=I(()=>{"use strict";Gt();CH=1e4,NH=100,kH=new Zi(/\s+/)});function I9(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?t/e:0;case"%":return e!==0?t%e:0;case"^":case"**":return t**e;default:return 0}}var R9=I(()=>{"use strict"});function Ps(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function on(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}async function jh(t,e){if(t.type==="regex")return t.pattern;let r=on(await e.evalExpr(t));return r.startsWith("/")&&r.endsWith("/")&&(r=r.slice(1,-1)),r}async function D9(t,e){return t?t.type==="variable"?t.name:t.type==="field"?`$${Math.floor(Ps(await e.evalExpr(t.index)))}`:"$0":"$0"}function L9(t,e){if(t==="$0")return e.line;if(t.startsWith("$")){let r=parseInt(t.slice(1),10)-1;return e.fields[r]||""}return on(e.vars[t]??"")}function F9(t,e,r){if(t==="$0")r.line=e,r.fields=r.FS===" "?e.trim().split(/\s+/).filter(Boolean):r.fieldSep.split(e),r.NF=r.fields.length;else if(t.startsWith("$")){let n=parseInt(t.slice(1),10)-1;for(;r.fields.length<=n;)r.fields.push("");r.fields[n]=e,r.NF=r.fields.length,r.line=r.fields.join(r.OFS)}else r.vars[t]=e}async function TH(t,e,r){return t.length===0?e.line.length:on(await r.evalExpr(t[0])).length}async function _H(t,e,r){if(t.length<2)return"";let n=on(await r.evalExpr(t[0])),s=Math.floor(Ps(await r.evalExpr(t[1])))-1;if(t.length>=3){let i=Math.floor(Ps(await r.evalExpr(t[2])));return n.substr(Math.max(0,s),i)}return n.substr(Math.max(0,s))}async function OH(t,e,r){if(t.length<2)return 0;let n=on(await r.evalExpr(t[0])),s=on(await r.evalExpr(t[1])),i=n.indexOf(s);return i===-1?0:i+1}async function IH(t,e,r){if(t.length<2)return 0;let n=on(await r.evalExpr(t[0])),s=t[1];if(s.type!=="variable")return 0;let i=s.name,o=e.FS;if(t.length>=3){let l=t[2];if(l.type==="regex")o=ae(l.pattern);else{let c=on(await r.evalExpr(l));o=c===" "?ae("\\s+"):c}}else e.FS===" "&&(o=ae("\\s+"));let a=typeof o=="string"?n.split(o):o.split(n);e.arrays[i]=Object.create(null);for(let l=0;l<a.length;l++)e.arrays[i][String(l+1)]=a[l];return a.length}async function RH(t,e,r){if(t.length<2)return 0;let n=await jh(t[0],r),s=on(await r.evalExpr(t[1])),i=await D9(t[2],r),o=L9(i,e);try{let l=ae(n).replace(o,M9(s)),c=l!==o?1:0;return F9(i,l,e),c}catch{return 0}}async function PH(t,e,r){if(t.length<2)return 0;let n=await jh(t[0],r),s=on(await r.evalExpr(t[1])),i=await D9(t[2],r),o=L9(i,e);try{let a=ae(n,"g"),l=a.match(o),c=l?l.length:0,u=a.replace(o,M9(s));return F9(i,u,e),c}catch{return 0}}function M9(t){return e=>{let r="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length){let s=t[n+1];s==="&"?(r+="&",n+=2):s==="\\"?(r+="\\",n+=2):(r+=t[n+1],n+=2)}else t[n]==="&"?(r+=e,n++):(r+=t[n],n++);return r}}async function DH(t,e,r){if(t.length<2)return e.RSTART=0,e.RLENGTH=-1,0;let n=on(await r.evalExpr(t[0])),s=await jh(t[1],r);try{let o=ae(s).exec(n);if(o)return e.RSTART=o.index+1,e.RLENGTH=o[0].length,e.RSTART}catch{}return e.RSTART=0,e.RLENGTH=-1,0}async function LH(t,e,r){if(t.length<3)return"";let n=await jh(t[0],r),s=on(await r.evalExpr(t[1])),i=on(await r.evalExpr(t[2])),o=t.length>=4?on(await r.evalExpr(t[3])):e.line;try{let a=i.toLowerCase()==="g",l=a?0:parseInt(i,10)||1;if(a)return ae(n,"g").replace(o,(u,...f)=>P9(s,u,f.slice(0,-2)));{let c=0;return ae(n,"g").replace(o,(f,...h)=>(c++,c===l?P9(s,f,h.slice(0,-2)):f))}}catch{return o}}function P9(t,e,r){let n="",s=0;for(;s<t.length;)if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&")n+="&",s+=2;else if(i==="0")n+=e,s+=2;else if(i>="1"&&i<="9"){let o=parseInt(i,10)-1;n+=r[o]||"",s+=2}else i==="n"?(n+=`
333
333
  `,s+=2):i==="t"?(n+=" ",s+=2):(n+=i,s+=2)}else t[s]==="&"?(n+=e,s++):(n+=t[s],s++);return n}async function FH(t,e,r){return t.length===0?"":on(await r.evalExpr(t[0])).toLowerCase()}async function MH(t,e,r){return t.length===0?"":on(await r.evalExpr(t[0])).toUpperCase()}async function $H(t,e,r){if(t.length===0)return"";let n=on(await r.evalExpr(t[0])),s=[];for(let i=1;i<t.length;i++)s.push(await r.evalExpr(t[i]));return Vh(n,s)}async function BH(t,e,r){return t.length===0?0:Math.floor(Ps(await r.evalExpr(t[0])))}async function UH(t,e,r){return t.length===0?0:Math.sqrt(Ps(await r.evalExpr(t[0])))}async function qH(t,e,r){return t.length===0?0:Math.sin(Ps(await r.evalExpr(t[0])))}async function zH(t,e,r){return t.length===0?0:Math.cos(Ps(await r.evalExpr(t[0])))}async function HH(t,e,r){let n=t.length>0?Ps(await r.evalExpr(t[0])):0,s=t.length>1?Ps(await r.evalExpr(t[1])):0;return Math.atan2(n,s)}async function WH(t,e,r){return t.length===0?0:Math.log(Ps(await r.evalExpr(t[0])))}async function jH(t,e,r){return t.length===0?1:Math.exp(Ps(await r.evalExpr(t[0])))}function VH(t,e,r){return e.random?e.random():Math.random()}async function GH(t,e,r){let n=t.length>0?Ps(await r.evalExpr(t[0])):Date.now();return e.vars._srand_seed=n,n}function KH(t,e){return()=>{throw new Error(`${t}() is not supported - ${e}`)}}function n2(t){return()=>{throw new Error(`function '${t}()' is not implemented`)}}function Vh(t,e){let r=0,n="",s=0;for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let i=s+1,o="",a="",l="",c,u=i;for(;i<t.length&&/\d/.test(t[i]);)i++;i>u&&t[i]==="$"?(c=parseInt(t.substring(u,i),10)-1,i++):i=u;let f=()=>{if(i<t.length){if(i+1<t.length&&(t[i]==="h"&&t[i+1]==="h"||t[i]==="l"&&t[i+1]==="l")){i+=2;return}/[lzjh]/.test(t[i])&&i++}};for(;i<t.length&&/[-+ #0]/.test(t[i]);)o+=t[i++];if(t[i]==="*"){let m=e[r++],g=m!==void 0?Math.floor(Number(m)):0;g<0?(o+="-",a=String(Math.min(-g,xa))):a=String(Math.min(g,xa)),i++}else for(;i<t.length&&/\d/.test(t[i]);)a+=t[i++];if(a&&parseInt(a,10)>xa&&(a=String(xa)),t[i]==="."){if(i++,t[i]==="*"){let m=e[r++];l=String(Math.min(m!==void 0?Math.floor(Number(m)):0,xa)),i++}else for(;i<t.length&&/\d/.test(t[i]);)l+=t[i++];l&&parseInt(l,10)>xa&&(l=String(xa))}f();let h=t[i],p=e[c!==void 0?c:r];switch(h){case"s":{let m=p!==void 0?String(p):"";if(l&&(m=m.substring(0,parseInt(l,10))),a){let g=parseInt(a,10);o.includes("-")?m=m.padEnd(g):m=m.padStart(g)}n+=m,c===void 0&&r++;break}case"d":case"i":{let m=p!==void 0?Math.floor(Number(p)):0;Number.isNaN(m)&&(m=0);let g=m<0,y=Math.abs(m).toString();if(l){let w=parseInt(l,10);y=y.padStart(w,"0")}let x="";g?x="-":o.includes("+")?x="+":o.includes(" ")&&(x=" ");let b=x+y;if(a){let w=parseInt(a,10);o.includes("-")?b=b.padEnd(w):o.includes("0")&&!l?b=x+y.padStart(w-x.length,"0"):b=b.padStart(w)}n+=b,c===void 0&&r++;break}case"f":{let m=p!==void 0?Number(p):0;Number.isNaN(m)&&(m=0);let g=l?parseInt(l,10):6,y=m.toFixed(g);if(a){let x=parseInt(a,10);o.includes("-")?y=y.padEnd(x):y=y.padStart(x)}n+=y,c===void 0&&r++;break}case"e":case"E":{let m=p!==void 0?Number(p):0;Number.isNaN(m)&&(m=0);let g=l?parseInt(l,10):6,y=m.toExponential(g);if(h==="E"&&(y=y.toUpperCase()),a){let x=parseInt(a,10);o.includes("-")?y=y.padEnd(x):y=y.padStart(x)}n+=y,c===void 0&&r++;break}case"g":case"G":{let m=p!==void 0?Number(p):0;Number.isNaN(m)&&(m=0);let g=l?parseInt(l,10):6,y=m!==0?Math.floor(Math.log10(Math.abs(m))):0,x;if(m===0?x="0":y<-4||y>=g?(x=m.toExponential(g-1),h==="G"&&(x=x.toUpperCase())):x=m.toPrecision(g),x.includes(".")&&(x=x.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),x.includes("e")&&(x=x.replace(/\.?0+e/,"e")),a){let b=parseInt(a,10);o.includes("-")?x=x.padEnd(b):x=x.padStart(b)}n+=x,c===void 0&&r++;break}case"x":case"X":{let m=p!==void 0?Math.floor(Number(p)):0;Number.isNaN(m)&&(m=0);let g=Math.abs(m).toString(16);if(h==="X"&&(g=g.toUpperCase()),l){let b=parseInt(l,10);g=g.padStart(b,"0")}let y=m<0?"-":"",x=y+g;if(a){let b=parseInt(a,10);o.includes("-")?x=x.padEnd(b):o.includes("0")&&!l?x=y+g.padStart(b-y.length,"0"):x=x.padStart(b)}n+=x,c===void 0&&r++;break}case"o":{let m=p!==void 0?Math.floor(Number(p)):0;Number.isNaN(m)&&(m=0);let g=Math.abs(m).toString(8);if(l){let b=parseInt(l,10);g=g.padStart(b,"0")}let y=m<0?"-":"",x=y+g;if(a){let b=parseInt(a,10);o.includes("-")?x=x.padEnd(b):o.includes("0")&&!l?x=y+g.padStart(b-y.length,"0"):x=x.padStart(b)}n+=x,c===void 0&&r++;break}case"c":{typeof p=="number"?n+=String.fromCharCode(p):n+=String(p??"").charAt(0)||"",c===void 0&&r++;break}case"%":n+="%";break;default:n+=t.substring(s,i+1)}s=i+1}else if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];switch(i){case"n":n+=`
334
- `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;default:n+=i}s+=2}else n+=t[s++];return n}var xa,$9,s2=I(()=>{"use strict";Gt();xa=1e4;$9=new Map([["length",TH],["substr",_H],["index",OH],["split",IH],["sub",RH],["gsub",PH],["match",DH],["gensub",LH],["tolower",FH],["toupper",MH],["sprintf",$H],["int",BH],["sqrt",UH],["sin",qH],["cos",zH],["atan2",HH],["log",WH],["exp",jH],["rand",VH],["srand",GH],["system",KH("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",n2("systime")],["mktime",n2("mktime")],["strftime",n2("strftime")]])});function On(t){return typeof t=="number"?t!==0:!(t===""||t==="0")}function ar(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function Pt(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}function i2(t){if(typeof t=="number")return!0;let e=String(t).trim();return e===""?!1:!Number.isNaN(Number(e))}function au(t,e){try{return ae(t).test(e)}catch{return!1}}var El=I(()=>{"use strict";Gt()});function B9(t,e){return e===""?[]:t.FS===" "?e.trim().split(/\s+/).filter(Boolean):t.fieldSep.split(e)}function Gh(t,e){return e===0?t.line:e<0||e>t.fields.length?"":t.fields[e-1]??""}function o2(t,e,r){if(e===0)t.line=Pt(r),t.fields=B9(t,t.line),t.NF=t.fields.length;else if(e>0){for(;t.fields.length<e;)t.fields.push("");t.fields[e-1]=Pt(r),t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}}function Sl(t,e){t.line=e,t.fields=B9(t,e),t.NF=t.fields.length}function U9(t,e){if(t.FS=e,e===" ")t.fieldSep=new Zi(/\s+/);else try{t.fieldSep=ae(e)}catch{t.fieldSep=ae(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var Kh=I(()=>{"use strict";Gt();El()});function Zh(t,e){switch(e){case"FS":return t.FS;case"OFS":return t.OFS;case"ORS":return t.ORS;case"OFMT":return t.OFMT;case"NR":return t.NR;case"NF":return t.NF;case"FNR":return t.FNR;case"FILENAME":return t.FILENAME;case"RSTART":return t.RSTART;case"RLENGTH":return t.RLENGTH;case"SUBSEP":return t.SUBSEP;case"ARGC":return t.ARGC}return t.vars[e]??""}function vl(t,e,r){switch(e){case"FS":U9(t,Pt(r));return;case"OFS":t.OFS=Pt(r);return;case"ORS":t.ORS=Pt(r);return;case"OFMT":t.OFMT=Pt(r);return;case"NR":t.NR=Math.floor(ar(r));return;case"NF":{let n=Math.floor(ar(r));if(n<t.NF)t.fields=t.fields.slice(0,n),t.line=t.fields.join(t.OFS);else if(n>t.NF){for(;t.fields.length<n;)t.fields.push("");t.line=t.fields.join(t.OFS)}t.NF=n;return}case"FNR":t.FNR=Math.floor(ar(r));return;case"FILENAME":t.FILENAME=Pt(r);return;case"RSTART":t.RSTART=Math.floor(ar(r));return;case"RLENGTH":t.RLENGTH=Math.floor(ar(r));return;case"SUBSEP":t.SUBSEP=Pt(r);return}t.vars[e]=r}function lu(t,e){let r=e,n=new Set,s=t.arrayAliases.get(r);for(;s!==void 0&&!n.has(r);)n.add(r),r=s,s=t.arrayAliases.get(r);return r}function Yh(t,e,r){if(e==="ARGV")return t.ARGV[r]??"";if(e==="ENVIRON")return t.ENVIRON[r]??"";let n=lu(t,e);return t.arrays[n]?.[r]??""}function a2(t,e,r,n){let s=lu(t,e);t.arrays[s]||(t.arrays[s]=Object.create(null)),t.arrays[s][r]=n}function q9(t,e,r){if(e==="ARGV")return t.ARGV[r]!==void 0;if(e==="ENVIRON")return t.ENVIRON[r]!==void 0;let n=lu(t,e);return t.arrays[n]?.[r]!==void 0}function z9(t,e,r){let n=lu(t,e);t.arrays[n]&&delete t.arrays[n][r]}function H9(t,e){let r=lu(t,e);delete t.arrays[r]}var l2=I(()=>{"use strict";Kh();El()});function j9(t){W9=t}function jn(t,e){rr(t.requireDefenseContext,"awk",e)}function Tt(t,e,r){return sn(t.requireDefenseContext,"awk",e,r)}async function He(t,e){switch(jn(t,"expression evaluation"),t.coverage?.hit(`awk:expr:${e.type}`),e.type){case"number":return e.value;case"string":return e.value;case"regex":return au(e.pattern,t.line)?1:0;case"field":return ZH(t,e);case"variable":return Zh(t,e.name);case"array_access":return YH(t,e);case"binary":return XH(t,e);case"unary":return eW(t,e);case"ternary":return On(await Tt(t,"ternary condition evaluation",()=>He(t,e.condition)))?await Tt(t,"ternary consequent evaluation",()=>He(t,e.consequent)):await Tt(t,"ternary alternate evaluation",()=>He(t,e.alternate));case"call":return tW(t,e.name,e.args);case"assignment":return nW(t,e);case"pre_increment":return sW(t,e.operand);case"pre_decrement":return iW(t,e.operand);case"post_increment":return oW(t,e.operand);case"post_decrement":return aW(t,e.operand);case"in":return lW(t,e.key,e.array);case"getline":return cW(t,e.variable,e.file,e.command);case"tuple":return hW(t,e.elements);default:return""}}async function ZH(t,e){jn(t,"field reference evaluation");let r=Math.floor(ar(await Tt(t,"field index evaluation",()=>He(t,e.index))));return Gh(t,r)}async function YH(t,e){jn(t,"array access evaluation");let r=Pt(await Tt(t,"array key evaluation",()=>He(t,e.key)));return Yh(t,e.array,r)}async function XH(t,e){jn(t,"binary expression evaluation");let r=e.operator;if(r==="||")return On(await Tt(t,"logical-or left evaluation",()=>He(t,e.left)))||On(await Tt(t,"logical-or right evaluation",()=>He(t,e.right)))?1:0;if(r==="&&")return On(await Tt(t,"logical-and left evaluation",()=>He(t,e.left)))&&On(await Tt(t,"logical-and right evaluation",()=>He(t,e.right)))?1:0;if(r==="~"){let a=await Tt(t,"regex left evaluation",()=>He(t,e.left));e.right.type==="regex"&&t.coverage?.hit("awk:expr:regex");let l=e.right.type==="regex"?e.right.pattern:Pt(await Tt(t,"regex right evaluation",()=>He(t,e.right)));try{return ae(l).test(Pt(a))?1:0}catch{return 0}}if(r==="!~"){let a=await Tt(t,"negated-regex left evaluation",()=>He(t,e.left));e.right.type==="regex"&&t.coverage?.hit("awk:expr:regex");let l=e.right.type==="regex"?e.right.pattern:Pt(await Tt(t,"negated-regex right evaluation",()=>He(t,e.right)));try{return ae(l).test(Pt(a))?0:1}catch{return 1}}let n=await Tt(t,"binary left evaluation",()=>He(t,e.left)),s=await Tt(t,"binary right evaluation",()=>He(t,e.right));if(r===" "){let a=Pt(n)+Pt(s);if(t.maxOutputSize>0&&a.length>t.maxOutputSize)throw new fe(`awk: string concatenation size limit exceeded (${t.maxOutputSize} bytes)`,"string_length",t.output);return a}if(QH(r))return JH(n,s,r);let i=ar(n),o=ar(s);return I9(i,o,r)}function QH(t){return["<","<=",">",">=","==","!="].includes(t)}function JH(t,e,r){let n=i2(t),s=i2(e);if(n&&s){let a=ar(t),l=ar(e);switch(r){case"<":return a<l?1:0;case"<=":return a<=l?1:0;case">":return a>l?1:0;case">=":return a>=l?1:0;case"==":return a===l?1:0;case"!=":return a!==l?1:0}}let i=Pt(t),o=Pt(e);switch(r){case"<":return i<o?1:0;case"<=":return i<=o?1:0;case">":return i>o?1:0;case">=":return i>=o?1:0;case"==":return i===o?1:0;case"!=":return i!==o?1:0}return 0}async function eW(t,e){jn(t,"unary expression evaluation");let r=await Tt(t,"unary operand evaluation",()=>He(t,e.operand));switch(e.operator){case"!":return On(r)?0:1;case"-":return-ar(r);case"+":return+ar(r);default:return r}}async function tW(t,e,r){jn(t,"function call evaluation");let n=$9.get(e);if(n)return n(r,t,{evalExpr:i=>He(t,i)});let s=t.functions.get(e);return s?rW(t,s,r):""}async function rW(t,e,r){if(jn(t,"user function call"),t.currentRecursionDepth++,t.currentRecursionDepth>t.maxRecursionDepth)throw t.currentRecursionDepth--,new fe(`awk: recursion depth exceeded maximum (${t.maxRecursionDepth})`,"recursion",t.output);let n=Object.create(null);for(let a of e.params)n[a]=t.vars[a];let s=[];for(let a=0;a<e.params.length;a++){let l=e.params[a];if(a<r.length){let c=r[a];c.type==="variable"&&(t.arrayAliases.set(l,c.name),s.push(l));let u=await Tt(t,"user function argument evaluation",()=>He(t,c));t.vars[l]=u}else t.vars[l]=""}t.hasReturn=!1,t.returnValue=void 0;let i=W9;i&&await Tt(t,"user function body execution",()=>i(t,e.body.statements));let o=t.returnValue??"";for(let a of e.params)n[a]!==void 0?t.vars[a]=n[a]:delete t.vars[a];for(let a of s)t.arrayAliases.delete(a);return t.hasReturn=!1,t.returnValue=void 0,t.currentRecursionDepth--,o}async function nW(t,e){jn(t,"assignment evaluation");let r=await Tt(t,"assignment value evaluation",()=>He(t,e.value)),n=e.target,s=e.operator,i;if(s==="=")i=r;else{let o;if(n.type==="field"){let c=Math.floor(ar(await Tt(t,"assignment field index",()=>He(t,n.index))));o=Gh(t,c)}else if(n.type==="variable")o=Zh(t,n.name);else{let c=Pt(await Tt(t,"assignment array key",()=>He(t,n.key)));o=Yh(t,n.array,c)}let a=ar(o),l=ar(r);switch(s){case"+=":i=a+l;break;case"-=":i=a-l;break;case"*=":i=a*l;break;case"/=":i=l!==0?a/l:0;break;case"%=":i=l!==0?a%l:0;break;case"^=":i=a**l;break;default:i=r}}if(n.type==="field"){let o=Math.floor(ar(await Tt(t,"assignment target field index",()=>He(t,n.index))));o2(t,o,i)}else if(n.type==="variable")vl(t,n.name,i);else{let o=Pt(await Tt(t,"assignment target array key",()=>He(t,n.key)));a2(t,n.array,o,i)}return i}async function Xh(t,e,r,n){jn(t,"inc/dec evaluation");let s;if(e.type==="field"){let i=Math.floor(ar(await Tt(t,"inc/dec field index",()=>He(t,e.index))));s=ar(Gh(t,i)),o2(t,i,s+r)}else if(e.type==="variable")s=ar(Zh(t,e.name)),vl(t,e.name,s+r);else{let i=Pt(await Tt(t,"inc/dec array key",()=>He(t,e.key)));s=ar(Yh(t,e.array,i)),a2(t,e.array,i,s+r)}return n?s+r:s}async function sW(t,e){return Xh(t,e,1,!0)}async function iW(t,e){return Xh(t,e,-1,!0)}async function oW(t,e){return Xh(t,e,1,!1)}async function aW(t,e){return Xh(t,e,-1,!1)}async function lW(t,e,r){jn(t,"in-expression evaluation");let n;if(e.type==="tuple"){t.coverage?.hit("awk:expr:tuple");let s=[];for(let i of e.elements)s.push(Pt(await Tt(t,"tuple key element evaluation",()=>He(t,i))));n=s.join(t.SUBSEP)}else n=Pt(await Tt(t,"in-expression key evaluation",()=>He(t,e)));return q9(t,r,n)?1:0}async function cW(t,e,r,n){if(jn(t,"getline evaluation"),n)return uW(t,e,n);if(r)return fW(t,e,r);if(!t.lines||t.lineIndex===void 0)return-1;let s=t.lineIndex+1;if(s>=t.lines.length)return 0;let i=t.lines[s];return e?vl(t,e,i):Sl(t,i),t.NR++,t.lineIndex=s,1}async function uW(t,e,r){let n=t.exec;if(!n)return-1;jn(t,"getline command source");let s=Pt(await Tt(t,"getline command expression",()=>He(t,r))),i=`__cmd_${s}`,o=`__cmdi_${s}`,a,l;if(t.vars[i]===void 0)try{let f=await Tt(t,"getline command exec",()=>n(s));a=he(f.stdout).split(`
334
+ `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;default:n+=i}s+=2}else n+=t[s++];return n}var xa,$9,s2=I(()=>{"use strict";Gt();xa=1e4;$9=new Map([["length",TH],["substr",_H],["index",OH],["split",IH],["sub",RH],["gsub",PH],["match",DH],["gensub",LH],["tolower",FH],["toupper",MH],["sprintf",$H],["int",BH],["sqrt",UH],["sin",qH],["cos",zH],["atan2",HH],["log",WH],["exp",jH],["rand",VH],["srand",GH],["system",KH("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",n2("systime")],["mktime",n2("mktime")],["strftime",n2("strftime")]])});function On(t){return typeof t=="number"?t!==0:!(t===""||t==="0")}function ar(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function Pt(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}function i2(t){if(typeof t=="number")return!0;let e=String(t).trim();return e===""?!1:!Number.isNaN(Number(e))}function au(t,e){try{return ae(t).test(e)}catch{return!1}}var El=I(()=>{"use strict";Gt()});function B9(t,e){return e===""?[]:t.FS===" "?e.trim().split(/\s+/).filter(Boolean):t.fieldSep.split(e)}function Gh(t,e){return e===0?t.line:e<0||e>t.fields.length?"":t.fields[e-1]??""}function o2(t,e,r){if(e===0)t.line=Pt(r),t.fields=B9(t,t.line),t.NF=t.fields.length;else if(e>0){for(;t.fields.length<e;)t.fields.push("");t.fields[e-1]=Pt(r),t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}}function Sl(t,e){t.line=e,t.fields=B9(t,e),t.NF=t.fields.length}function U9(t,e){if(t.FS=e,e===" ")t.fieldSep=new Zi(/\s+/);else try{t.fieldSep=ae(e)}catch{t.fieldSep=ae(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var Kh=I(()=>{"use strict";Gt();El()});function Zh(t,e){switch(e){case"FS":return t.FS;case"OFS":return t.OFS;case"ORS":return t.ORS;case"OFMT":return t.OFMT;case"NR":return t.NR;case"NF":return t.NF;case"FNR":return t.FNR;case"FILENAME":return t.FILENAME;case"RSTART":return t.RSTART;case"RLENGTH":return t.RLENGTH;case"SUBSEP":return t.SUBSEP;case"ARGC":return t.ARGC}return t.vars[e]??""}function vl(t,e,r){switch(e){case"FS":U9(t,Pt(r));return;case"OFS":t.OFS=Pt(r);return;case"ORS":t.ORS=Pt(r);return;case"OFMT":t.OFMT=Pt(r);return;case"NR":t.NR=Math.floor(ar(r));return;case"NF":{let n=Math.floor(ar(r));if(n<t.NF)t.fields=t.fields.slice(0,n),t.line=t.fields.join(t.OFS);else if(n>t.NF){for(;t.fields.length<n;)t.fields.push("");t.line=t.fields.join(t.OFS)}t.NF=n;return}case"FNR":t.FNR=Math.floor(ar(r));return;case"FILENAME":t.FILENAME=Pt(r);return;case"RSTART":t.RSTART=Math.floor(ar(r));return;case"RLENGTH":t.RLENGTH=Math.floor(ar(r));return;case"SUBSEP":t.SUBSEP=Pt(r);return}t.vars[e]=r}function lu(t,e){let r=e,n=new Set,s=t.arrayAliases.get(r);for(;s!==void 0&&!n.has(r);)n.add(r),r=s,s=t.arrayAliases.get(r);return r}function Yh(t,e,r){if(e==="ARGV")return t.ARGV[r]??"";if(e==="ENVIRON")return t.ENVIRON[r]??"";let n=lu(t,e);return t.arrays[n]?.[r]??""}function a2(t,e,r,n){let s=lu(t,e);t.arrays[s]||(t.arrays[s]=Object.create(null)),t.arrays[s][r]=n}function q9(t,e,r){if(e==="ARGV")return t.ARGV[r]!==void 0;if(e==="ENVIRON")return t.ENVIRON[r]!==void 0;let n=lu(t,e);return t.arrays[n]?.[r]!==void 0}function z9(t,e,r){let n=lu(t,e);t.arrays[n]&&delete t.arrays[n][r]}function H9(t,e){let r=lu(t,e);delete t.arrays[r]}var l2=I(()=>{"use strict";Kh();El()});function j9(t){W9=t}function jn(t,e){rr(t.requireDefenseContext,"awk",e)}function Tt(t,e,r){return sn(t.requireDefenseContext,"awk",e,r)}async function He(t,e){switch(jn(t,"expression evaluation"),t.coverage?.hit(`awk:expr:${e.type}`),e.type){case"number":return e.value;case"string":return e.value;case"regex":return au(e.pattern,t.line)?1:0;case"field":return ZH(t,e);case"variable":return Zh(t,e.name);case"array_access":return YH(t,e);case"binary":return XH(t,e);case"unary":return eW(t,e);case"ternary":return On(await Tt(t,"ternary condition evaluation",()=>He(t,e.condition)))?await Tt(t,"ternary consequent evaluation",()=>He(t,e.consequent)):await Tt(t,"ternary alternate evaluation",()=>He(t,e.alternate));case"call":return tW(t,e.name,e.args);case"assignment":return nW(t,e);case"pre_increment":return sW(t,e.operand);case"pre_decrement":return iW(t,e.operand);case"post_increment":return oW(t,e.operand);case"post_decrement":return aW(t,e.operand);case"in":return lW(t,e.key,e.array);case"getline":return cW(t,e.variable,e.file,e.command);case"tuple":return hW(t,e.elements);default:return""}}async function ZH(t,e){jn(t,"field reference evaluation");let r=Math.floor(ar(await Tt(t,"field index evaluation",()=>He(t,e.index))));return Gh(t,r)}async function YH(t,e){jn(t,"array access evaluation");let r=Pt(await Tt(t,"array key evaluation",()=>He(t,e.key)));return Yh(t,e.array,r)}async function XH(t,e){jn(t,"binary expression evaluation");let r=e.operator;if(r==="||")return On(await Tt(t,"logical-or left evaluation",()=>He(t,e.left)))||On(await Tt(t,"logical-or right evaluation",()=>He(t,e.right)))?1:0;if(r==="&&")return On(await Tt(t,"logical-and left evaluation",()=>He(t,e.left)))&&On(await Tt(t,"logical-and right evaluation",()=>He(t,e.right)))?1:0;if(r==="~"){let a=await Tt(t,"regex left evaluation",()=>He(t,e.left));e.right.type==="regex"&&t.coverage?.hit("awk:expr:regex");let l=e.right.type==="regex"?e.right.pattern:Pt(await Tt(t,"regex right evaluation",()=>He(t,e.right)));try{return ae(l).test(Pt(a))?1:0}catch{return 0}}if(r==="!~"){let a=await Tt(t,"negated-regex left evaluation",()=>He(t,e.left));e.right.type==="regex"&&t.coverage?.hit("awk:expr:regex");let l=e.right.type==="regex"?e.right.pattern:Pt(await Tt(t,"negated-regex right evaluation",()=>He(t,e.right)));try{return ae(l).test(Pt(a))?0:1}catch{return 1}}let n=await Tt(t,"binary left evaluation",()=>He(t,e.left)),s=await Tt(t,"binary right evaluation",()=>He(t,e.right));if(r===" "){let a=Pt(n)+Pt(s);if(t.maxOutputSize>0&&a.length>t.maxOutputSize)throw new he(`awk: string concatenation size limit exceeded (${t.maxOutputSize} bytes)`,"string_length",t.output);return a}if(QH(r))return JH(n,s,r);let i=ar(n),o=ar(s);return I9(i,o,r)}function QH(t){return["<","<=",">",">=","==","!="].includes(t)}function JH(t,e,r){let n=i2(t),s=i2(e);if(n&&s){let a=ar(t),l=ar(e);switch(r){case"<":return a<l?1:0;case"<=":return a<=l?1:0;case">":return a>l?1:0;case">=":return a>=l?1:0;case"==":return a===l?1:0;case"!=":return a!==l?1:0}}let i=Pt(t),o=Pt(e);switch(r){case"<":return i<o?1:0;case"<=":return i<=o?1:0;case">":return i>o?1:0;case">=":return i>=o?1:0;case"==":return i===o?1:0;case"!=":return i!==o?1:0}return 0}async function eW(t,e){jn(t,"unary expression evaluation");let r=await Tt(t,"unary operand evaluation",()=>He(t,e.operand));switch(e.operator){case"!":return On(r)?0:1;case"-":return-ar(r);case"+":return+ar(r);default:return r}}async function tW(t,e,r){jn(t,"function call evaluation");let n=$9.get(e);if(n)return n(r,t,{evalExpr:i=>He(t,i)});let s=t.functions.get(e);return s?rW(t,s,r):""}async function rW(t,e,r){if(jn(t,"user function call"),t.currentRecursionDepth++,t.currentRecursionDepth>t.maxRecursionDepth)throw t.currentRecursionDepth--,new he(`awk: recursion depth exceeded maximum (${t.maxRecursionDepth})`,"recursion",t.output);let n=Object.create(null);for(let a of e.params)n[a]=t.vars[a];let s=[];for(let a=0;a<e.params.length;a++){let l=e.params[a];if(a<r.length){let c=r[a];c.type==="variable"&&(t.arrayAliases.set(l,c.name),s.push(l));let u=await Tt(t,"user function argument evaluation",()=>He(t,c));t.vars[l]=u}else t.vars[l]=""}t.hasReturn=!1,t.returnValue=void 0;let i=W9;i&&await Tt(t,"user function body execution",()=>i(t,e.body.statements));let o=t.returnValue??"";for(let a of e.params)n[a]!==void 0?t.vars[a]=n[a]:delete t.vars[a];for(let a of s)t.arrayAliases.delete(a);return t.hasReturn=!1,t.returnValue=void 0,t.currentRecursionDepth--,o}async function nW(t,e){jn(t,"assignment evaluation");let r=await Tt(t,"assignment value evaluation",()=>He(t,e.value)),n=e.target,s=e.operator,i;if(s==="=")i=r;else{let o;if(n.type==="field"){let c=Math.floor(ar(await Tt(t,"assignment field index",()=>He(t,n.index))));o=Gh(t,c)}else if(n.type==="variable")o=Zh(t,n.name);else{let c=Pt(await Tt(t,"assignment array key",()=>He(t,n.key)));o=Yh(t,n.array,c)}let a=ar(o),l=ar(r);switch(s){case"+=":i=a+l;break;case"-=":i=a-l;break;case"*=":i=a*l;break;case"/=":i=l!==0?a/l:0;break;case"%=":i=l!==0?a%l:0;break;case"^=":i=a**l;break;default:i=r}}if(n.type==="field"){let o=Math.floor(ar(await Tt(t,"assignment target field index",()=>He(t,n.index))));o2(t,o,i)}else if(n.type==="variable")vl(t,n.name,i);else{let o=Pt(await Tt(t,"assignment target array key",()=>He(t,n.key)));a2(t,n.array,o,i)}return i}async function Xh(t,e,r,n){jn(t,"inc/dec evaluation");let s;if(e.type==="field"){let i=Math.floor(ar(await Tt(t,"inc/dec field index",()=>He(t,e.index))));s=ar(Gh(t,i)),o2(t,i,s+r)}else if(e.type==="variable")s=ar(Zh(t,e.name)),vl(t,e.name,s+r);else{let i=Pt(await Tt(t,"inc/dec array key",()=>He(t,e.key)));s=ar(Yh(t,e.array,i)),a2(t,e.array,i,s+r)}return n?s+r:s}async function sW(t,e){return Xh(t,e,1,!0)}async function iW(t,e){return Xh(t,e,-1,!0)}async function oW(t,e){return Xh(t,e,1,!1)}async function aW(t,e){return Xh(t,e,-1,!1)}async function lW(t,e,r){jn(t,"in-expression evaluation");let n;if(e.type==="tuple"){t.coverage?.hit("awk:expr:tuple");let s=[];for(let i of e.elements)s.push(Pt(await Tt(t,"tuple key element evaluation",()=>He(t,i))));n=s.join(t.SUBSEP)}else n=Pt(await Tt(t,"in-expression key evaluation",()=>He(t,e)));return q9(t,r,n)?1:0}async function cW(t,e,r,n){if(jn(t,"getline evaluation"),n)return uW(t,e,n);if(r)return fW(t,e,r);if(!t.lines||t.lineIndex===void 0)return-1;let s=t.lineIndex+1;if(s>=t.lines.length)return 0;let i=t.lines[s];return e?vl(t,e,i):Sl(t,i),t.NR++,t.lineIndex=s,1}async function uW(t,e,r){let n=t.exec;if(!n)return-1;jn(t,"getline command source");let s=Pt(await Tt(t,"getline command expression",()=>He(t,r))),i=`__cmd_${s}`,o=`__cmdi_${s}`,a,l;if(t.vars[i]===void 0)try{let f=await Tt(t,"getline command exec",()=>n(s));a=fe(f.stdout).split(`
335
335
  `),a.length>0&&a[a.length-1]===""&&a.pop(),t.vars[i]=JSON.stringify(a),t.vars[o]=-1,l=-1}catch(f){if(f instanceof Fe)throw f;return-1}else a=JSON.parse(t.vars[i]),l=t.vars[o];let c=l+1;if(c>=a.length)return 0;let u=a[c];return t.vars[o]=c,e?vl(t,e,u):Sl(t,u),1}async function fW(t,e,r){let n=t.fs;if(!n||!t.cwd)return-1;jn(t,"getline file source");let s=Pt(await Tt(t,"getline filename evaluation",()=>He(t,r)));if(s==="/dev/null")return 0;let i=n.resolvePath(t.cwd,s),o=`__fc_${i}`,a=`__fi_${i}`,l,c;if(t.vars[o]===void 0)try{l=(await Tt(t,"getline file read",()=>n.readFile(i))).split(`
336
- `),l.length>0&&l[l.length-1]===""&&l.pop(),t.vars[o]=JSON.stringify(l),t.vars[a]=-1,c=-1}catch(h){if(h instanceof Fe)throw h;return-1}else l=JSON.parse(t.vars[o]),c=t.vars[a];let u=c+1;if(u>=l.length)return 0;let f=l[u];return t.vars[a]=u,e?vl(t,e,f):Sl(t,f),1}async function hW(t,e){if(jn(t,"tuple evaluation"),e.length===0)return"";for(let r=0;r<e.length-1;r++)await Tt(t,"tuple intermediate element",()=>He(t,e[r]));return Tt(t,"tuple final element",()=>He(t,e[e.length-1]))}var W9,c2=I(()=>{"use strict";Re();rt();Gt();hs();$r();R9();s2();Kh();El();l2();W9=null});function u2(t){if(t.maxOutputSize>0&&t.output.length>t.maxOutputSize)throw new fe(`awk: output size limit exceeded (${t.maxOutputSize} bytes)`,"string_length",t.output)}function Qs(t,e){rr(t.requireDefenseContext,"awk",e)}function bt(t,e,r){return sn(t.requireDefenseContext,"awk",e,r)}async function Al(t,e){Qs(t,"block execution");for(let r of e)if(await bt(t,"statement execution",()=>ba(t,r)),dW(t))break}function dW(t){return t.shouldExit||t.shouldNext||t.shouldNextFile||t.loopBreak||t.loopContinue||t.hasReturn}async function ba(t,e){switch(Qs(t,"single statement execution"),t.coverage?.hit(`awk:stmt:${e.type}`),e.type){case"block":await bt(t,"nested block statement",()=>Al(t,e.statements));break;case"expr_stmt":await bt(t,"expression statement",()=>He(t,e.expression));break;case"print":await bt(t,"print statement",()=>pW(t,e.args,e.output));break;case"printf":await bt(t,"printf statement",()=>mW(t,e.format,e.args,e.output));break;case"if":await bt(t,"if statement",()=>gW(t,e));break;case"while":await bt(t,"while statement",()=>yW(t,e));break;case"do_while":await bt(t,"do-while statement",()=>xW(t,e));break;case"for":await bt(t,"for statement",()=>bW(t,e));break;case"for_in":await bt(t,"for-in statement",()=>wW(t,e));break;case"break":t.loopBreak=!0;break;case"continue":t.loopContinue=!0;break;case"next":t.shouldNext=!0;break;case"nextfile":t.shouldNextFile=!0;break;case"exit":t.shouldExit=!0;{let r=e.code;t.exitCode=r?Math.floor(ar(await bt(t,"exit code expression",()=>He(t,r)))):0}break;case"return":t.hasReturn=!0;{let r=e.value;t.returnValue=r?await bt(t,"return expression",()=>He(t,r)):""}break;case"delete":await bt(t,"delete statement",()=>EW(t,e.target));break}}async function pW(t,e,r){Qs(t,"print execution");let n=[];for(let i of e){let o=await bt(t,"print argument evaluation",()=>He(t,i));typeof o=="number"?Number.isInteger(o)&&Math.abs(o)<Number.MAX_SAFE_INTEGER?n.push(String(o)):n.push(Vh(t.OFMT,[o])):n.push(Pt(o))}let s=n.join(t.OFS)+t.ORS;r?await bt(t,"print redirection write",()=>V9(t,r.redirect,r.file,s)):(t.output+=s,u2(t))}async function mW(t,e,r,n){Qs(t,"printf execution");let s=Pt(await bt(t,"printf format evaluation",()=>He(t,e))),i=[];for(let a of r)i.push(await bt(t,"printf argument evaluation",()=>He(t,a)));let o=Vh(s,i);n?await bt(t,"printf redirection write",()=>V9(t,n.redirect,n.file,o)):(t.output+=o,u2(t))}async function V9(t,e,r,n){Qs(t,"file write execution");let s=t.fs;if(!s||!t.cwd){t.output+=n,u2(t);return}let i=Pt(await bt(t,"redirection filename evaluation",()=>He(t,r))),o=s.resolvePath(t.cwd,i);e===">"?t.openedFiles.has(o)?await bt(t,"redirection append write",()=>s.appendFile(o,n)):(await bt(t,"redirection overwrite write",()=>s.writeFile(o,n)),t.openedFiles.add(o)):(t.openedFiles.has(o)||t.openedFiles.add(o),await bt(t,"redirection append mode write",()=>s.appendFile(o,n)))}async function gW(t,e){if(Qs(t,"if execution"),On(await bt(t,"if condition evaluation",()=>He(t,e.condition))))await bt(t,"if consequent execution",()=>ba(t,e.consequent));else if(e.alternate){let r=e.alternate;await bt(t,"if alternate execution",()=>ba(t,r))}}async function yW(t,e){Qs(t,"while execution");let r=0;for(;On(await bt(t,"while condition evaluation",()=>He(t,e.condition)));){if(r++,r>t.maxIterations)throw new fe(`awk: while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,"while body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function xW(t,e){Qs(t,"do-while execution");let r=0;do{if(r++,r>t.maxIterations)throw new fe(`awk: do-while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,"do-while body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}while(On(await bt(t,"do-while condition evaluation",()=>He(t,e.condition))))}async function bW(t,e){Qs(t,"for execution");let r=e.init,n=e.condition,s=e.update;r&&await bt(t,"for init evaluation",()=>He(t,r));let i=0;for(;!n||On(await bt(t,"for condition evaluation",()=>He(t,n)));){if(i++,i>t.maxIterations)throw new fe(`awk: for loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,"for body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break;s&&await bt(t,"for update evaluation",()=>He(t,s))}}async function wW(t,e){Qs(t,"for-in execution");let r=t.arrays[e.array];if(r)for(let n of Object.keys(r)){if(t.vars[e.variable]=n,t.loopContinue=!1,await bt(t,"for-in body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function EW(t,e){if(Qs(t,"delete execution"),e.type==="array_access"){let r=Pt(await bt(t,"delete key evaluation",()=>He(t,e.key)));z9(t,e.array,r)}else e.type==="variable"&&H9(t,e.name)}var G9=I(()=>{"use strict";rt();hs();s2();c2();El();l2();j9(Al)});var cu,K9=I(()=>{"use strict";hs();c2();Kh();G9();El();cu=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}assertDefenseContext(e){rr(this.ctx.requireDefenseContext,"awk",e)}withDefenseContext(e,r){return sn(this.ctx.requireDefenseContext,"awk",e,r)}execute(e){this.assertDefenseContext("program initialization"),this.program=e,this.ctx.output="";for(let r of e.functions)this.ctx.functions.set(r.name,r);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.assertDefenseContext("BEGIN execution entry"),!!this.program){for(let e of this.program.rules)if(e.pattern?.type==="begin"&&(await this.withDefenseContext("BEGIN block execution",()=>Al(this.ctx,e.action.statements)),this.ctx.shouldExit))break}}async executeLine(e){if(this.assertDefenseContext("line execution entry"),!(!this.program||this.ctx.shouldExit)){Sl(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let r=0;r<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);r++){let n=this.program.rules[r];n.pattern?.type==="begin"||n.pattern?.type==="end"||await this.withDefenseContext("rule match",()=>this.matchesRule(n,r))&&await this.withDefenseContext("rule block execution",()=>Al(this.ctx,n.action.statements))}}}async executeEnd(){if(this.assertDefenseContext("END execution entry"),!!this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let e of this.program.rules)if(e.pattern?.type==="end"&&(await this.withDefenseContext("END block execution",()=>Al(this.ctx,e.action.statements)),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,r){this.assertDefenseContext("rule matching");let n=e.pattern;if(!n)return!0;switch(n.type){case"begin":case"end":return!1;case"regex_pattern":return au(n.pattern,this.ctx.line);case"expr_pattern":return On(await this.withDefenseContext("expression pattern evaluation",()=>He(this.ctx,n.expression)));case"range":{let s=await this.withDefenseContext("range start pattern",()=>this.matchPattern(n.start)),i=await this.withDefenseContext("range end pattern",()=>this.matchPattern(n.end));return this.rangeStates[r]?(i&&(this.rangeStates[r]=!1),!0):s?(this.rangeStates[r]=!0,i&&(this.rangeStates[r]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(this.assertDefenseContext("pattern matching"),e.type){case"regex_pattern":return au(e.pattern,this.ctx.line);case"expr_pattern":return On(await this.withDefenseContext("nested expression pattern",()=>He(this.ctx,e.expression)));default:return!1}}}});var Z9=I(()=>{"use strict";O9();K9()});function vW(t){return t.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var O,SW,AW,Qh,Y9=I(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.STRING="STRING",t.REGEX="REGEX",t.IDENT="IDENT",t.BEGIN="BEGIN",t.END="END",t.IF="IF",t.ELSE="ELSE",t.WHILE="WHILE",t.DO="DO",t.FOR="FOR",t.IN="IN",t.BREAK="BREAK",t.CONTINUE="CONTINUE",t.NEXT="NEXT",t.NEXTFILE="NEXTFILE",t.EXIT="EXIT",t.RETURN="RETURN",t.DELETE="DELETE",t.FUNCTION="FUNCTION",t.PRINT="PRINT",t.PRINTF="PRINTF",t.GETLINE="GETLINE",t.PLUS="PLUS",t.MINUS="MINUS",t.STAR="STAR",t.SLASH="SLASH",t.PERCENT="PERCENT",t.CARET="CARET",t.EQ="EQ",t.NE="NE",t.LT="LT",t.GT="GT",t.LE="LE",t.GE="GE",t.MATCH="MATCH",t.NOT_MATCH="NOT_MATCH",t.AND="AND",t.OR="OR",t.NOT="NOT",t.ASSIGN="ASSIGN",t.PLUS_ASSIGN="PLUS_ASSIGN",t.MINUS_ASSIGN="MINUS_ASSIGN",t.STAR_ASSIGN="STAR_ASSIGN",t.SLASH_ASSIGN="SLASH_ASSIGN",t.PERCENT_ASSIGN="PERCENT_ASSIGN",t.CARET_ASSIGN="CARET_ASSIGN",t.INCREMENT="INCREMENT",t.DECREMENT="DECREMENT",t.QUESTION="QUESTION",t.COLON="COLON",t.COMMA="COMMA",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.LBRACKET="LBRACKET",t.RBRACKET="RBRACKET",t.DOLLAR="DOLLAR",t.APPEND="APPEND",t.PIPE="PIPE",t.EOF="EOF"})(O||(O={}));SW=new Map([["BEGIN",O.BEGIN],["END",O.END],["if",O.IF],["else",O.ELSE],["while",O.WHILE],["do",O.DO],["for",O.FOR],["in",O.IN],["break",O.BREAK],["continue",O.CONTINUE],["next",O.NEXT],["nextfile",O.NEXTFILE],["exit",O.EXIT],["return",O.RETURN],["delete",O.DELETE],["function",O.FUNCTION],["print",O.PRINT],["printf",O.PRINTF],["getline",O.GETLINE]]);AW=new Set([O.COMMA,O.LBRACE,O.AND,O.OR,O.QUESTION,O.COLON,O.DO,O.ELSE,O.IF,O.WHILE]),Qh=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&(e.push(r),this.lastTokenType=r.type)}return e.push(this.makeToken(O.EOF,"")),e}makeToken(e,r){return{type:e,value:r,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
336
+ `),l.length>0&&l[l.length-1]===""&&l.pop(),t.vars[o]=JSON.stringify(l),t.vars[a]=-1,c=-1}catch(h){if(h instanceof Fe)throw h;return-1}else l=JSON.parse(t.vars[o]),c=t.vars[a];let u=c+1;if(u>=l.length)return 0;let f=l[u];return t.vars[a]=u,e?vl(t,e,f):Sl(t,f),1}async function hW(t,e){if(jn(t,"tuple evaluation"),e.length===0)return"";for(let r=0;r<e.length-1;r++)await Tt(t,"tuple intermediate element",()=>He(t,e[r]));return Tt(t,"tuple final element",()=>He(t,e[e.length-1]))}var W9,c2=I(()=>{"use strict";Re();rt();Gt();hs();$r();R9();s2();Kh();El();l2();W9=null});function u2(t){if(t.maxOutputSize>0&&t.output.length>t.maxOutputSize)throw new he(`awk: output size limit exceeded (${t.maxOutputSize} bytes)`,"string_length",t.output)}function Qs(t,e){rr(t.requireDefenseContext,"awk",e)}function bt(t,e,r){return sn(t.requireDefenseContext,"awk",e,r)}async function Al(t,e){Qs(t,"block execution");for(let r of e)if(await bt(t,"statement execution",()=>ba(t,r)),dW(t))break}function dW(t){return t.shouldExit||t.shouldNext||t.shouldNextFile||t.loopBreak||t.loopContinue||t.hasReturn}async function ba(t,e){switch(Qs(t,"single statement execution"),t.coverage?.hit(`awk:stmt:${e.type}`),e.type){case"block":await bt(t,"nested block statement",()=>Al(t,e.statements));break;case"expr_stmt":await bt(t,"expression statement",()=>He(t,e.expression));break;case"print":await bt(t,"print statement",()=>pW(t,e.args,e.output));break;case"printf":await bt(t,"printf statement",()=>mW(t,e.format,e.args,e.output));break;case"if":await bt(t,"if statement",()=>gW(t,e));break;case"while":await bt(t,"while statement",()=>yW(t,e));break;case"do_while":await bt(t,"do-while statement",()=>xW(t,e));break;case"for":await bt(t,"for statement",()=>bW(t,e));break;case"for_in":await bt(t,"for-in statement",()=>wW(t,e));break;case"break":t.loopBreak=!0;break;case"continue":t.loopContinue=!0;break;case"next":t.shouldNext=!0;break;case"nextfile":t.shouldNextFile=!0;break;case"exit":t.shouldExit=!0;{let r=e.code;t.exitCode=r?Math.floor(ar(await bt(t,"exit code expression",()=>He(t,r)))):0}break;case"return":t.hasReturn=!0;{let r=e.value;t.returnValue=r?await bt(t,"return expression",()=>He(t,r)):""}break;case"delete":await bt(t,"delete statement",()=>EW(t,e.target));break}}async function pW(t,e,r){Qs(t,"print execution");let n=[];for(let i of e){let o=await bt(t,"print argument evaluation",()=>He(t,i));typeof o=="number"?Number.isInteger(o)&&Math.abs(o)<Number.MAX_SAFE_INTEGER?n.push(String(o)):n.push(Vh(t.OFMT,[o])):n.push(Pt(o))}let s=n.join(t.OFS)+t.ORS;r?await bt(t,"print redirection write",()=>V9(t,r.redirect,r.file,s)):(t.output+=s,u2(t))}async function mW(t,e,r,n){Qs(t,"printf execution");let s=Pt(await bt(t,"printf format evaluation",()=>He(t,e))),i=[];for(let a of r)i.push(await bt(t,"printf argument evaluation",()=>He(t,a)));let o=Vh(s,i);n?await bt(t,"printf redirection write",()=>V9(t,n.redirect,n.file,o)):(t.output+=o,u2(t))}async function V9(t,e,r,n){Qs(t,"file write execution");let s=t.fs;if(!s||!t.cwd){t.output+=n,u2(t);return}let i=Pt(await bt(t,"redirection filename evaluation",()=>He(t,r))),o=s.resolvePath(t.cwd,i);e===">"?t.openedFiles.has(o)?await bt(t,"redirection append write",()=>s.appendFile(o,n)):(await bt(t,"redirection overwrite write",()=>s.writeFile(o,n)),t.openedFiles.add(o)):(t.openedFiles.has(o)||t.openedFiles.add(o),await bt(t,"redirection append mode write",()=>s.appendFile(o,n)))}async function gW(t,e){if(Qs(t,"if execution"),On(await bt(t,"if condition evaluation",()=>He(t,e.condition))))await bt(t,"if consequent execution",()=>ba(t,e.consequent));else if(e.alternate){let r=e.alternate;await bt(t,"if alternate execution",()=>ba(t,r))}}async function yW(t,e){Qs(t,"while execution");let r=0;for(;On(await bt(t,"while condition evaluation",()=>He(t,e.condition)));){if(r++,r>t.maxIterations)throw new he(`awk: while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,"while body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function xW(t,e){Qs(t,"do-while execution");let r=0;do{if(r++,r>t.maxIterations)throw new he(`awk: do-while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,"do-while body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}while(On(await bt(t,"do-while condition evaluation",()=>He(t,e.condition))))}async function bW(t,e){Qs(t,"for execution");let r=e.init,n=e.condition,s=e.update;r&&await bt(t,"for init evaluation",()=>He(t,r));let i=0;for(;!n||On(await bt(t,"for condition evaluation",()=>He(t,n)));){if(i++,i>t.maxIterations)throw new he(`awk: for loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,"for body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break;s&&await bt(t,"for update evaluation",()=>He(t,s))}}async function wW(t,e){Qs(t,"for-in execution");let r=t.arrays[e.array];if(r)for(let n of Object.keys(r)){if(t.vars[e.variable]=n,t.loopContinue=!1,await bt(t,"for-in body execution",()=>ba(t,e.body)),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function EW(t,e){if(Qs(t,"delete execution"),e.type==="array_access"){let r=Pt(await bt(t,"delete key evaluation",()=>He(t,e.key)));z9(t,e.array,r)}else e.type==="variable"&&H9(t,e.name)}var G9=I(()=>{"use strict";rt();hs();s2();c2();El();l2();j9(Al)});var cu,K9=I(()=>{"use strict";hs();c2();Kh();G9();El();cu=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}assertDefenseContext(e){rr(this.ctx.requireDefenseContext,"awk",e)}withDefenseContext(e,r){return sn(this.ctx.requireDefenseContext,"awk",e,r)}execute(e){this.assertDefenseContext("program initialization"),this.program=e,this.ctx.output="";for(let r of e.functions)this.ctx.functions.set(r.name,r);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.assertDefenseContext("BEGIN execution entry"),!!this.program){for(let e of this.program.rules)if(e.pattern?.type==="begin"&&(await this.withDefenseContext("BEGIN block execution",()=>Al(this.ctx,e.action.statements)),this.ctx.shouldExit))break}}async executeLine(e){if(this.assertDefenseContext("line execution entry"),!(!this.program||this.ctx.shouldExit)){Sl(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let r=0;r<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);r++){let n=this.program.rules[r];n.pattern?.type==="begin"||n.pattern?.type==="end"||await this.withDefenseContext("rule match",()=>this.matchesRule(n,r))&&await this.withDefenseContext("rule block execution",()=>Al(this.ctx,n.action.statements))}}}async executeEnd(){if(this.assertDefenseContext("END execution entry"),!!this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let e of this.program.rules)if(e.pattern?.type==="end"&&(await this.withDefenseContext("END block execution",()=>Al(this.ctx,e.action.statements)),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,r){this.assertDefenseContext("rule matching");let n=e.pattern;if(!n)return!0;switch(n.type){case"begin":case"end":return!1;case"regex_pattern":return au(n.pattern,this.ctx.line);case"expr_pattern":return On(await this.withDefenseContext("expression pattern evaluation",()=>He(this.ctx,n.expression)));case"range":{let s=await this.withDefenseContext("range start pattern",()=>this.matchPattern(n.start)),i=await this.withDefenseContext("range end pattern",()=>this.matchPattern(n.end));return this.rangeStates[r]?(i&&(this.rangeStates[r]=!1),!0):s?(this.rangeStates[r]=!0,i&&(this.rangeStates[r]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(this.assertDefenseContext("pattern matching"),e.type){case"regex_pattern":return au(e.pattern,this.ctx.line);case"expr_pattern":return On(await this.withDefenseContext("nested expression pattern",()=>He(this.ctx,e.expression)));default:return!1}}}});var Z9=I(()=>{"use strict";O9();K9()});function vW(t){return t.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var O,SW,AW,Qh,Y9=I(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.STRING="STRING",t.REGEX="REGEX",t.IDENT="IDENT",t.BEGIN="BEGIN",t.END="END",t.IF="IF",t.ELSE="ELSE",t.WHILE="WHILE",t.DO="DO",t.FOR="FOR",t.IN="IN",t.BREAK="BREAK",t.CONTINUE="CONTINUE",t.NEXT="NEXT",t.NEXTFILE="NEXTFILE",t.EXIT="EXIT",t.RETURN="RETURN",t.DELETE="DELETE",t.FUNCTION="FUNCTION",t.PRINT="PRINT",t.PRINTF="PRINTF",t.GETLINE="GETLINE",t.PLUS="PLUS",t.MINUS="MINUS",t.STAR="STAR",t.SLASH="SLASH",t.PERCENT="PERCENT",t.CARET="CARET",t.EQ="EQ",t.NE="NE",t.LT="LT",t.GT="GT",t.LE="LE",t.GE="GE",t.MATCH="MATCH",t.NOT_MATCH="NOT_MATCH",t.AND="AND",t.OR="OR",t.NOT="NOT",t.ASSIGN="ASSIGN",t.PLUS_ASSIGN="PLUS_ASSIGN",t.MINUS_ASSIGN="MINUS_ASSIGN",t.STAR_ASSIGN="STAR_ASSIGN",t.SLASH_ASSIGN="SLASH_ASSIGN",t.PERCENT_ASSIGN="PERCENT_ASSIGN",t.CARET_ASSIGN="CARET_ASSIGN",t.INCREMENT="INCREMENT",t.DECREMENT="DECREMENT",t.QUESTION="QUESTION",t.COLON="COLON",t.COMMA="COMMA",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.LBRACKET="LBRACKET",t.RBRACKET="RBRACKET",t.DOLLAR="DOLLAR",t.APPEND="APPEND",t.PIPE="PIPE",t.EOF="EOF"})(O||(O={}));SW=new Map([["BEGIN",O.BEGIN],["END",O.END],["if",O.IF],["else",O.ELSE],["while",O.WHILE],["do",O.DO],["for",O.FOR],["in",O.IN],["break",O.BREAK],["continue",O.CONTINUE],["next",O.NEXT],["nextfile",O.NEXTFILE],["exit",O.EXIT],["return",O.RETURN],["delete",O.DELETE],["function",O.FUNCTION],["print",O.PRINT],["printf",O.PRINTF],["getline",O.GETLINE]]);AW=new Set([O.COMMA,O.LBRACE,O.AND,O.OR,O.QUESTION,O.COLON,O.DO,O.ELSE,O.IF,O.WHILE]),Qh=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&(e.push(r),this.lastTokenType=r.type)}return e.push(this.makeToken(O.EOF,"")),e}makeToken(e,r){return{type:e,value:r,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
337
337
  `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===" "||e===" "||e==="\r")this.advance();else if(e==="\\")if(this.peek(1)===`
338
338
  `)this.advance(),this.advance();else break;else if(e==="#")for(;this.pos<this.input.length&&this.peek()!==`
339
339
  `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,r=this.column,n=this.peek();return n===`
@@ -345,8 +345,8 @@ Addresses:
345
345
  `,exitCode:1};let a=t[o],l=t.slice(o+1),c=new ed,u;try{u=c.parse(a)}catch(y){return{stdout:"",stderr:`awk: ${y instanceof Error?y.message:String(y)}
346
346
  `,exitCode:1}}let f={readFile:e.fs.readFile.bind(e.fs),writeFile:e.fs.writeFile.bind(e.fs),appendFile:async(y,x)=>{try{let b=await r("appendFile read",()=>e.fs.readFile(y));await r("appendFile write",()=>e.fs.writeFile(y,b+x))}catch(b){if(b instanceof Fe)throw b;await r("appendFile create",()=>e.fs.writeFile(y,x))}},resolvePath:e.fs.resolvePath.bind(e.fs)},h=e.exec,d=r2({fieldSep:n,maxIterations:e.limits?.maxAwkIterations,maxOutputSize:e.limits?.maxStringLength,fs:f,cwd:e.cwd,exec:h?y=>r("command pipe exec",()=>h(y,{cwd:e.cwd,signal:e.signal})):void 0,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext});d.FS=s,d.vars=Object.assign(Object.create(null),i),d.ARGC=l.length+1,d.ARGV=Object.create(null),d.ARGV[0]="awk";for(let y=0;y<l.length;y++)d.ARGV[String(y+1)]=l[y];d.ENVIRON=Cr(e.env);let p=new cu(d);p.execute(u);let m=u.rules.some(y=>y.pattern?.type!=="begin"&&y.pattern?.type!=="end"),g=u.rules.some(y=>y.pattern?.type==="end");try{if(await r("BEGIN execution",()=>p.executeBegin()),d.shouldExit)return await r("END execution after BEGIN exit",()=>p.executeEnd()),{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()};if(!m&&!g)return{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()};let y=[];if(l.length>0)for(let x of l)try{let b=e.fs.resolvePath(e.cwd,x),S=(await r("input file read",()=>e.fs.readFile(b))).split(`
347
347
  `);S.length>0&&S[S.length-1]===""&&S.pop(),y.push({filename:x,lines:S})}catch(b){if(b instanceof Fe)throw b;return{stdout:"",stderr:`awk: ${x}: No such file or directory
348
- `,exitCode:1}}else{let x=he(e.stdin).split(`
349
- `);x.length>0&&x[x.length-1]===""&&x.pop(),y.push({filename:"",lines:x})}for(let x of y){for(d.FILENAME=x.filename,d.FNR=0,d.lines=x.lines,d.lineIndex=-1,d.shouldNextFile=!1;d.lineIndex<x.lines.length-1;){d.lineIndex++;let b=d.lineIndex;if(await r("line execution",()=>p.executeLine(x.lines[b])),d.shouldExit||d.shouldNextFile)break}if(d.shouldExit)break}return await r("END execution",()=>p.executeEnd()),{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()}}catch(y){if(y instanceof Fe)throw y;let x=y instanceof Error?y.message:String(y),b=y instanceof fe?fe.EXIT_CODE:2;return{stdout:p.getOutput(),stderr:`awk: ${x}
348
+ `,exitCode:1}}else{let x=fe(e.stdin).split(`
349
+ `);x.length>0&&x[x.length-1]===""&&x.pop(),y.push({filename:"",lines:x})}for(let x of y){for(d.FILENAME=x.filename,d.FNR=0,d.lines=x.lines,d.lineIndex=-1,d.shouldNextFile=!1;d.lineIndex<x.lines.length-1;){d.lineIndex++;let b=d.lineIndex;if(await r("line execution",()=>p.executeLine(x.lines[b])),d.shouldExit||d.shouldNextFile)break}if(d.shouldExit)break}return await r("END execution",()=>p.executeEnd()),{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()}}catch(y){if(y instanceof Fe)throw y;let x=y instanceof Error?y.message:String(y),b=y instanceof he?he.EXIT_CODE:2;return{stdout:p.getOutput(),stderr:`awk: ${x}
350
350
  `,exitCode:b}}}};d2={name:"awk",flags:[{flag:"-F",type:"value",valueHint:"delimiter"},{flag:"-v",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function lv(t){let e=t.trim(),r=e.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!r){let o=parseFloat(e);return Number.isNaN(o)?0:o}let n=parseFloat(r[1]),s=(r[2]||"").toLowerCase(),i=RW.get(s)??1;return n*i}function cv(t){let e=t.trim().toLowerCase().slice(0,3);return PW.get(e)??0}function DW(t,e){let r=t.split(/(\d+)/),n=e.split(/(\d+)/),s=Math.max(r.length,n.length);for(let i=0;i<s;i++){let o=r[i]||"",a=n[i]||"",l=/^\d+$/.test(o)?parseInt(o,10):null,c=/^\d+$/.test(a)?parseInt(a,10):null;if(l!==null&&c!==null){if(l!==c)return l-c}else if(o!==a)return o.localeCompare(a)}return 0}function uv(t){return t.replace(/[^a-zA-Z0-9\s]/g,"")}function m2(t,e,r){let n=r!==null?r:/\s+/,s=t.split(n),i=e.startField-1;if(i>=s.length)return"";if(e.endField===void 0){let l=s[i]||"";return e.startChar!==void 0&&(l=l.slice(e.startChar-1)),e.ignoreLeading&&(l=l.trimStart()),l}let o=Math.min(e.endField-1,s.length-1),a="";for(let l=i;l<=o&&l<s.length;l++){let c=s[l]||"";if(l===i&&e.startChar!==void 0&&(c=c.slice(e.startChar-1)),l===o&&e.endChar!==void 0){let u=l===i&&e.startChar!==void 0?e.endChar-e.startChar+1:e.endChar;c=c.slice(0,u)}l>i&&(a+=r||" "),a+=c}return e.ignoreLeading&&(a=a.trimStart()),a}function fv(t,e,r){let n=t,s=e;if(r.dictionaryOrder&&(n=uv(n),s=uv(s)),r.ignoreCase&&(n=n.toLowerCase(),s=s.toLowerCase()),r.monthSort){let i=cv(n),o=cv(s);return i-o}if(r.humanNumeric){let i=lv(n),o=lv(s);return i-o}if(r.versionSort)return DW(n,s);if(r.numeric){let i=parseFloat(n)||0,o=parseFloat(s)||0;return i-o}return n.localeCompare(s)}function hv(t){let{keys:e,fieldDelimiter:r,numeric:n,ignoreCase:s,reverse:i,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c,ignoreLeadingBlanks:u,stable:f}=t;return(h,d)=>{let p=h,m=d;if(u&&(p=p.trimStart(),m=m.trimStart()),e.length===0){let y=fv(p,m,{numeric:n,ignoreCase:s,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c});if(y!==0)return i?-y:y;if(!f){let x=h.localeCompare(d);return i?-x:x}return 0}for(let g of e){let y=m2(p,g,r),x=m2(m,g,r);g.ignoreLeading&&(y=y.trimStart(),x=x.trimStart());let b={numeric:g.numeric??n,ignoreCase:g.ignoreCase??s,humanNumeric:g.humanNumeric??o,versionSort:g.versionSort??a,dictionaryOrder:g.dictionaryOrder??l,monthSort:g.monthSort??c},w=g.reverse??i,S=fv(y,x,b);if(S!==0)return w?-S:S}if(!f){let g=h.localeCompare(d);return i?-g:g}return 0}}function dv(t,e){if(e.keys.length===0){if(e.ignoreCase){let s=new Set;return t.filter(i=>{let o=i.toLowerCase();return s.has(o)?!1:(s.add(o),!0)})}return[...new Set(t)]}let r=e.keys[0],n=new Set;return t.filter(s=>{let i=m2(s,r,e.fieldDelimiter);return(r.ignoreCase??e.ignoreCase)&&(i=i.toLowerCase()),n.has(i)?!1:(n.add(i),!0)})}var RW,PW,pv=I(()=>{"use strict";RW=new Map([["",1],["k",1024],["m",1048576],["g",1073741824],["t",1099511627776],["p",0x4000000000000],["e",1152921504606847e3]]),PW=new Map([["jan",1],["feb",2],["mar",3],["apr",4],["may",5],["jun",6],["jul",7],["aug",8],["sep",9],["oct",10],["nov",11],["dec",12]])});function td(t){let e={startField:1},r="",n=t,s=n.match(/([bdfhMnrV]+)$/);s&&(r=s[1],n=n.slice(0,-r.length)),r.includes("n")&&(e.numeric=!0),r.includes("r")&&(e.reverse=!0),r.includes("f")&&(e.ignoreCase=!0),r.includes("b")&&(e.ignoreLeading=!0),r.includes("h")&&(e.humanNumeric=!0),r.includes("V")&&(e.versionSort=!0),r.includes("d")&&(e.dictionaryOrder=!0),r.includes("M")&&(e.monthSort=!0);let i=n.split(",");if(i.length===0||i[0]==="")return null;let o=i[0].split("."),a=parseInt(o[0],10);if(Number.isNaN(a)||a<1)return null;if(e.startField=a,o.length>1&&o[1]){let l=parseInt(o[1],10);!Number.isNaN(l)&&l>=1&&(e.startChar=l)}if(i.length>1&&i[1]){let l=i[1],c=l.match(/([bdfhMnrV]+)$/);if(c){let f=c[1];f.includes("n")&&(e.numeric=!0),f.includes("r")&&(e.reverse=!0),f.includes("f")&&(e.ignoreCase=!0),f.includes("b")&&(e.ignoreLeading=!0),f.includes("h")&&(e.humanNumeric=!0),f.includes("V")&&(e.versionSort=!0),f.includes("d")&&(e.dictionaryOrder=!0),f.includes("M")&&(e.monthSort=!0),l=l.slice(0,-f.length)}let u=l.split(".");if(u[0]){let f=parseInt(u[0],10);if(!Number.isNaN(f)&&f>=1&&(e.endField=f),u.length>1&&u[1]){let h=parseInt(u[1],10);!Number.isNaN(h)&&h>=1&&(e.endChar=h)}}}return e}var mv=I(()=>{"use strict"});var gv={};ue(gv,{flagsForFuzzing:()=>g2,sortCommand:()=>FW});var LW,FW,g2,y2=I(()=>{"use strict";Re();wo();xe();pv();mv();LW={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
351
351
  F is a field number (1-indexed)
352
352
  C is a character position within the field (1-indexed)
@@ -357,16 +357,16 @@ Examples:
357
357
  -k2,2 sort by second field only
358
358
  -k1.3 sort by first field starting at 3rd character
359
359
  -k1,2n sort by fields 1-2 numerically
360
- -k2 -k1 sort by field 2, then by field 1`},FW={name:"sort",async execute(t,e){if(Y(t))return Z(LW);let r={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},n=[];for(let c=0;c<t.length;c++){let u=t[c];if(u==="-r"||u==="--reverse")r.reverse=!0;else if(u==="-n"||u==="--numeric-sort")r.numeric=!0;else if(u==="-u"||u==="--unique")r.unique=!0;else if(u==="-f"||u==="--ignore-case")r.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")r.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")r.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")r.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")r.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")r.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")r.stable=!0;else if(u==="-c"||u==="--check")r.checkOnly=!0;else if(u==="-o"||u==="--output")r.outputFile=t[++c]||null;else if(u.startsWith("-o"))r.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))r.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")r.fieldDelimiter=t[++c]||null;else if(u.startsWith("-t"))r.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))r.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=t[++c];if(f){let h=td(f);h&&r.keys.push(h)}}else if(u.startsWith("-k")){let f=td(u.slice(2));f&&r.keys.push(f)}else if(u.startsWith("--key=")){let f=td(u.slice(6));f&&r.keys.push(f)}else{if(u.startsWith("--"))return oe("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let h of u.slice(1))if(h==="r")r.reverse=!0;else if(h==="n")r.numeric=!0;else if(h==="u")r.unique=!0;else if(h==="f")r.ignoreCase=!0;else if(h==="h")r.humanNumeric=!0;else if(h==="V")r.versionSort=!0;else if(h==="d")r.dictionaryOrder=!0;else if(h==="M")r.monthSort=!0;else if(h==="b")r.ignoreLeadingBlanks=!0;else if(h==="s")r.stable=!0;else if(h==="c")r.checkOnly=!0;else{f=!0;break}if(f)return oe("sort",u)}else n.push(u)}}let s=await hl(e,n,{cmdName:"sort"});if(!s.ok)return s.error;let o=he(s.content).split(`
360
+ -k2 -k1 sort by field 2, then by field 1`},FW={name:"sort",async execute(t,e){if(Y(t))return Z(LW);let r={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},n=[];for(let c=0;c<t.length;c++){let u=t[c];if(u==="-r"||u==="--reverse")r.reverse=!0;else if(u==="-n"||u==="--numeric-sort")r.numeric=!0;else if(u==="-u"||u==="--unique")r.unique=!0;else if(u==="-f"||u==="--ignore-case")r.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")r.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")r.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")r.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")r.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")r.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")r.stable=!0;else if(u==="-c"||u==="--check")r.checkOnly=!0;else if(u==="-o"||u==="--output")r.outputFile=t[++c]||null;else if(u.startsWith("-o"))r.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))r.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")r.fieldDelimiter=t[++c]||null;else if(u.startsWith("-t"))r.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))r.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=t[++c];if(f){let h=td(f);h&&r.keys.push(h)}}else if(u.startsWith("-k")){let f=td(u.slice(2));f&&r.keys.push(f)}else if(u.startsWith("--key=")){let f=td(u.slice(6));f&&r.keys.push(f)}else{if(u.startsWith("--"))return oe("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let h of u.slice(1))if(h==="r")r.reverse=!0;else if(h==="n")r.numeric=!0;else if(h==="u")r.unique=!0;else if(h==="f")r.ignoreCase=!0;else if(h==="h")r.humanNumeric=!0;else if(h==="V")r.versionSort=!0;else if(h==="d")r.dictionaryOrder=!0;else if(h==="M")r.monthSort=!0;else if(h==="b")r.ignoreLeadingBlanks=!0;else if(h==="s")r.stable=!0;else if(h==="c")r.checkOnly=!0;else{f=!0;break}if(f)return oe("sort",u)}else n.push(u)}}let s=await hl(e,n,{cmdName:"sort"});if(!s.ok)return s.error;let o=fe(s.content).split(`
361
361
  `);o.length>0&&o[o.length-1]===""&&o.pop();let a=hv(r);if(r.checkOnly){let c=n.length>0?n[0]:"-";for(let u=1;u<o.length;u++)if(a(o[u-1],o[u])>0)return{stdout:"",stderr:`sort: ${c}:${u+1}: disorder: ${o[u]}
362
362
  `,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}o.sort(a),r.unique&&(o=dv(o,r));let l=o.length>0?`${o.join(`
363
363
  `)}
364
- `:"";if(r.outputFile){let c=e.fs.resolvePath(e.cwd,r.outputFile);return await e.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}},g2={name:"sort",flags:[{flag:"-r",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-V",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-M",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-k",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"delimiter"},{flag:"-o",type:"value",valueHint:"path"}],stdinType:"text",needsFiles:!0}});var yv={};ue(yv,{flagsForFuzzing:()=>x2,uniqCommand:()=>BW});var MW,$W,BW,x2,b2=I(()=>{"use strict";Re();Ar();wo();xe();MW={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},$W={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},BW={name:"uniq",async execute(t,e){if(Y(t))return Z(MW);let r=ct("uniq",t,$W);if(!r.ok)return r.error;let{count:n,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=r.result.flags,a=r.result.positional,l=await hl(e,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=(o?he(l.content):l.content).split(`
364
+ `:"";if(r.outputFile){let c=e.fs.resolvePath(e.cwd,r.outputFile);return await e.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}},g2={name:"sort",flags:[{flag:"-r",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-V",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-M",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-k",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"delimiter"},{flag:"-o",type:"value",valueHint:"path"}],stdinType:"text",needsFiles:!0}});var yv={};ue(yv,{flagsForFuzzing:()=>x2,uniqCommand:()=>BW});var MW,$W,BW,x2,b2=I(()=>{"use strict";Re();Ar();wo();xe();MW={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},$W={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},BW={name:"uniq",async execute(t,e){if(Y(t))return Z(MW);let r=ct("uniq",t,$W);if(!r.ok)return r.error;let{count:n,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=r.result.flags,a=r.result.positional,l=await hl(e,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=(o?fe(l.content):l.content).split(`
365
365
  `);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],h=u[0],d=1,p=(y,x)=>o?y.toLowerCase()===x.toLowerCase():y===x;for(let y=1;y<u.length;y++)p(u[y],h)?d++:(f.push({line:h,count:d}),h=u[y],d=1);f.push({line:h,count:d});let m=f;s?m=f.filter(y=>y.count>1):i&&(m=f.filter(y=>y.count===1));let g="";for(let{line:y,count:x}of m)n?g+=`${String(x).padStart(4)} ${y}
366
366
  `:g+=`${y}
367
367
  `;return o?{stdout:g,stderr:"",exitCode:0}:{stdout:g,stderr:"",exitCode:0,stdoutKind:"bytes",stdoutEncoding:"binary"}}},x2={name:"uniq",flags:[{flag:"-c",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-i",type:"boolean"}],stdinType:"text",needsFiles:!0}});var xv={};ue(xv,{commCommand:()=>qW,flagsForFuzzing:()=>w2});var UW,qW,w2,E2=I(()=>{"use strict";Re();xe();UW={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},qW={name:"comm",async execute(t,e){if(Y(t))return Z(UW);let r=!1,n=!1,s=!1,i=[];for(let g of t)if(g==="-1")r=!0;else if(g==="-2")n=!0;else if(g==="-3")s=!0;else if(g==="-12"||g==="-21")r=!0,n=!0;else if(g==="-13"||g==="-31")r=!0,s=!0;else if(g==="-23"||g==="-32")n=!0,s=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")r=!0,n=!0,s=!0;else{if(g.startsWith("-")&&g!=="-")return oe("comm",g);i.push(g)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
368
368
  Try 'comm --help' for more information.
369
- `,exitCode:1};let o=async g=>{if(g==="-")return he(e.stdin);try{let y=e.fs.resolvePath(e.cwd,g);return await e.fs.readFile(y)}catch{return null}},a=await o(i[0]);if(a===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
369
+ `,exitCode:1};let o=async g=>{if(g==="-")return fe(e.stdin);try{let y=e.fs.resolvePath(e.cwd,g);return await e.fs.readFile(y)}catch{return null}},a=await o(i[0]);if(a===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
370
370
  `,exitCode:1};let l=await o(i[1]);if(l===null)return{stdout:"",stderr:`comm: ${i[1]}: No such file or directory
371
371
  `,exitCode:1};let c=a.split(`
372
372
  `),u=l.split(`
@@ -376,11 +376,11 @@ Try 'comm --help' for more information.
376
376
  `),f++):c[f]>u[h]?(n||(d+=`${p}${u[h]}
377
377
  `),h++):(s||(d+=`${m}${c[f]}
378
378
  `),f++,h++);return{stdout:d,stderr:"",exitCode:0}}},w2={name:"comm",flags:[{flag:"-1",type:"boolean"},{flag:"-2",type:"boolean"},{flag:"-3",type:"boolean"}],needsArgs:!0,minArgs:2}});var bv={};ue(bv,{cutCommand:()=>jW,flagsForFuzzing:()=>S2});function HW(t){let e=[],r=t.split(",");for(let n of r)if(n.includes("-")){let[s,i]=n.split("-");e.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(n,10);e.push({start:s,end:s})}return e}function WW(t,e){let r=[];for(let n of e){let s=n.start-1,i=n.end===null?t.length:n.end;for(let o=s;o<i&&o<t.length;o++)o>=0&&!r.includes(t[o])&&r.push(t[o])}return r}var zW,jW,S2,v2=I(()=>{"use strict";Re();wo();xe();zW={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};jW={name:"cut",async execute(t,e){if(Y(t))return Z(zW);let r=" ",n=null,s=null,i=!1,o=[];for(let h=0;h<t.length;h++){let d=t[h];if(d==="-d")r=t[++h]||" ";else if(d.startsWith("-d"))r=d.slice(2);else if(d==="-f")n=t[++h];else if(d.startsWith("-f"))n=d.slice(2);else if(d==="-c")s=t[++h];else if(d.startsWith("-c"))s=d.slice(2);else if(d==="-s"||d==="--only-delimited")i=!0;else{if(d.startsWith("--"))return oe("cut",d);if(d.startsWith("-")){let p=!1;for(let m of d.slice(1))if(m==="s")i=!0;else if(!"dfc".includes(m)){p=!0;break}if(p)return oe("cut",d)}else o.push(d)}}if(!n&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
379
- `,exitCode:1};let a=await hl(e,o,{cmdName:"cut"});if(!a.ok)return a.error;let c=(s?he(a.content):a.content).split(`
379
+ `,exitCode:1};let a=await hl(e,o,{cmdName:"cut"});if(!a.ok)return a.error;let c=(s?fe(a.content):a.content).split(`
380
380
  `);c.length>0&&c[c.length-1]===""&&c.pop();let u=HW(n||s||"1"),f="";for(let h of c)if(s){let d=Array.from(h),p=[];for(let m of u){let g=m.start-1,y=m.end===null?d.length:m.end;for(let x=g;x<y&&x<d.length;x++)x>=0&&p.push(d[x])}f+=`${p.join("")}
381
381
  `}else{if(i&&!h.includes(r))continue;let d=h.split(r),p=WW(d,u);f+=`${p.join(r)}
382
382
  `}return s?{stdout:f,stderr:"",exitCode:0}:{stdout:f,stderr:"",exitCode:0,stdoutKind:"bytes",stdoutEncoding:"binary"}}},S2={name:"cut",flags:[{flag:"-d",type:"value",valueHint:"delimiter"},{flag:"-f",type:"value",valueHint:"string"},{flag:"-c",type:"value",valueHint:"string"},{flag:"-s",type:"boolean"}],stdinType:"text",needsFiles:!0}});var Ev={};ue(Ev,{flagsForFuzzing:()=>A2,pasteCommand:()=>KW});function wv(t,e){if(t.length===0)return"";if(t.length===1)return t[0];let r=t[0];for(let n=1;n<t.length;n++){let s=(n-1)%e.length;r+=e[s]+t[n]}return r}var VW,GW,KW,A2,C2=I(()=>{"use strict";Re();Ar();xe();VW={name:"paste",summary:"merge lines of files",usage:"paste [OPTION]... [FILE]...",description:["Write lines consisting of the sequentially corresponding lines from","each FILE, separated by TABs, to standard output.","","With no FILE, or when FILE is -, read standard input."],options:["-d, --delimiters=LIST reuse characters from LIST instead of TABs","-s, --serial paste one file at a time instead of in parallel"," --help display this help and exit"],examples:["paste file1 file2 Merge file1 and file2 side by side","paste -d, file1 file2 Use comma as delimiter","paste -s file1 Paste all lines of file1 on one line","paste - - < file Paste pairs of lines from file"]},GW={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},KW={name:"paste",async execute(t,e){if(Y(t))return Z(VW);let r=ct("paste",t,GW);if(!r.ok)return r.error;let n=r.result.flags.delimiter,s=r.result.flags.serial,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
383
- `,exitCode:1};let o=he(e.stdin),a=o?o.split(`
383
+ `,exitCode:1};let o=fe(e.stdin),a=o?o.split(`
384
384
  `):[""];a.length>0&&a[a.length-1]===""&&a.pop();let l=i.filter(h=>h==="-").length,c=[],u=0;for(let h of i)if(h==="-"){let d=[];for(let p=u;p<a.length;p+=l)d.push(a[p]);c.push(d),u++}else{let d=e.fs.resolvePath(e.cwd,h);try{let m=(await e.fs.readFile(d)).split(`
385
385
  `);m.length>0&&m[m.length-1]===""&&m.pop(),c.push(m)}catch{return{stdout:"",stderr:`paste: ${h}: No such file or directory
386
386
  `,exitCode:1}}}let f="";if(s)for(let h of c)h&&(f+=`${wv(h,n)}
@@ -404,11 +404,11 @@ Try 'comm --help' for more information.
404
404
  \r\f\v`],["[:upper:]","ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["[:xdigit:]","0123456789ABCDEFabcdef"]]);XW={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},QW={name:"tr",async execute(t,e){if(Y(t))return Z(ZW);let r=ct("tr",t,XW);if(!r.ok)return r.error;let n=r.result.flags.complement||r.result.flags.complementUpper,s=r.result.flags.delete,i=r.result.flags.squeeze,o=r.result.positional;if(o.length<1)return{stdout:"",stderr:`tr: missing operand
405
405
  `,exitCode:1};if(!s&&!i&&o.length<2)return{stdout:"",stderr:`tr: missing operand after SET1
406
406
  `,exitCode:1};let a,l;try{a=Sv(o[0]),l=o.length>1?Sv(o[1]):""}catch(h){return{stdout:"",stderr:`${Je(h.message)}
407
- `,exitCode:1}}let c=he(e.stdin),u=h=>{let d=a.includes(h);return n?!d:d},f="";if(s)for(let h of c)u(h)||(f+=h);else if(i&&o.length===1){let h="";for(let d of c)u(d)&&d===h||(f+=d,h=d)}else{if(n){let h=l.length>0?l[l.length-1]:"";for(let d of c)a.includes(d)?f+=d:f+=h}else{let h=new Map;for(let d=0;d<a.length;d++){let p=d<l.length?l[d]:l[l.length-1];h.set(a[d],p)}for(let d of c)f+=h.get(d)??d}if(i){let h="",d="";for(let p of f)l.includes(p)&&p===d||(h+=p,d=p);f=h}}return{stdout:f,stderr:"",exitCode:0}}},N2={name:"tr",flags:[{flag:"-c",type:"boolean"},{flag:"-C",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-s",type:"boolean"}],stdinType:"text",needsArgs:!0}});var Av={};ue(Av,{flagsForFuzzing:()=>T2,rev:()=>tj});function ej(t){return Array.from(t).reverse().join("")}var JW,tj,T2,_2=I(()=>{"use strict";Re();xe();JW={name:"rev",summary:"reverse lines characterwise",usage:"rev [file ...]",description:"Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.",examples:["echo 'hello' | rev # Output: olleh","rev file.txt # Reverse each line in file"]};tj={name:"rev",execute:async(t,e)=>{if(Y(t))return Z(JW);let r=[];for(let i of t)if(i==="--"){let o=t.indexOf(i);r.push(...t.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return oe("rev",i);r.push(i)}let n="",s=i=>{let o=i.split(`
407
+ `,exitCode:1}}let c=fe(e.stdin),u=h=>{let d=a.includes(h);return n?!d:d},f="";if(s)for(let h of c)u(h)||(f+=h);else if(i&&o.length===1){let h="";for(let d of c)u(d)&&d===h||(f+=d,h=d)}else{if(n){let h=l.length>0?l[l.length-1]:"";for(let d of c)a.includes(d)?f+=d:f+=h}else{let h=new Map;for(let d=0;d<a.length;d++){let p=d<l.length?l[d]:l[l.length-1];h.set(a[d],p)}for(let d of c)f+=h.get(d)??d}if(i){let h="",d="";for(let p of f)l.includes(p)&&p===d||(h+=p,d=p);f=h}}return{stdout:f,stderr:"",exitCode:0}}},N2={name:"tr",flags:[{flag:"-c",type:"boolean"},{flag:"-C",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-s",type:"boolean"}],stdinType:"text",needsArgs:!0}});var Av={};ue(Av,{flagsForFuzzing:()=>T2,rev:()=>tj});function ej(t){return Array.from(t).reverse().join("")}var JW,tj,T2,_2=I(()=>{"use strict";Re();xe();JW={name:"rev",summary:"reverse lines characterwise",usage:"rev [file ...]",description:"Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.",examples:["echo 'hello' | rev # Output: olleh","rev file.txt # Reverse each line in file"]};tj={name:"rev",execute:async(t,e)=>{if(Y(t))return Z(JW);let r=[];for(let i of t)if(i==="--"){let o=t.indexOf(i);r.push(...t.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return oe("rev",i);r.push(i)}let n="",s=i=>{let o=i.split(`
408
408
  `),a=i.endsWith(`
409
409
  `)&&o[o.length-1]==="";return a&&o.pop(),o.map(ej).join(`
410
410
  `)+(a?`
411
- `:"")};if(r.length===0){let i=he(e.stdin)??"";n=s(i)}else for(let i of r)if(i==="-"){let o=he(e.stdin)??"";n+=s(o)}else{let o=e.fs.resolvePath(e.cwd,i),a=await e.fs.readFile(o);if(a===null)return{exitCode:1,stdout:n,stderr:`rev: ${i}: No such file or directory
411
+ `:"")};if(r.length===0){let i=fe(e.stdin)??"";n=s(i)}else for(let i of r)if(i==="-"){let o=fe(e.stdin)??"";n+=s(o)}else{let o=e.fs.resolvePath(e.cwd,i),a=await e.fs.readFile(o);if(a===null)return{exitCode:1,stdout:n,stderr:`rev: ${i}: No such file or directory
412
412
  `};n+=s(a)}return{exitCode:0,stdout:n,stderr:""}}},T2={name:"rev",flags:[],stdinType:"text",needsFiles:!0}});var Nv={};ue(Nv,{flagsForFuzzing:()=>O2,nl:()=>ij});function nj(t,e,r){let n=String(t);switch(e){case"ln":return n.padEnd(r);case"rn":return n.padStart(r);case"rz":return n.padStart(r,"0");default:return e}}function sj(t,e){switch(e){case"a":return!0;case"t":return t.trim().length>0;case"n":return!1;default:return e}}function Cv(t,e,r){if(t==="")return{output:"",nextNumber:r};let n=t.split(`
413
413
  `),s=[],i=r,o=t.endsWith(`
414
414
  `)&&n[n.length-1]==="";o&&n.pop();for(let a of n)if(sj(a,e.bodyStyle)){let l=nj(i,e.numberFormat,e.width);s.push(`${l}${e.separator}${a}`),i+=e.increment}else{let l=" ".repeat(e.width);s.push(`${l}${e.separator}${a}`)}return{output:s.join(`
@@ -423,7 +423,7 @@ Try 'comm --help' for more information.
423
423
  `};r.startNumber=l,s+=2}else if(a.startsWith("-v")){let l=parseInt(a.slice(2),10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid starting line number: '${a.slice(2)}'
424
424
  `};r.startNumber=l,s++}else if(a==="-i"&&s+1<t.length){let l=parseInt(t[s+1],10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid line number increment: '${t[s+1]}'
425
425
  `};r.increment=l,s+=2}else if(a.startsWith("-i")){let l=parseInt(a.slice(2),10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid line number increment: '${a.slice(2)}'
426
- `};r.increment=l,s++}else if(a==="--"){n.push(...t.slice(s+1));break}else{if(a.startsWith("-")&&a!=="-")return oe("nl",a);n.push(a),s++}}let i="",o=r.startNumber;if(n.length===0){let a=he(e.stdin)??"";i=Cv(a,r,o).output}else for(let a of n){let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFile(l);if(c===null)return{exitCode:1,stdout:i,stderr:`nl: ${a}: No such file or directory
426
+ `};r.increment=l,s++}else if(a==="--"){n.push(...t.slice(s+1));break}else{if(a.startsWith("-")&&a!=="-")return oe("nl",a);n.push(a),s++}}let i="",o=r.startNumber;if(n.length===0){let a=fe(e.stdin)??"";i=Cv(a,r,o).output}else for(let a of n){let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFile(l);if(c===null)return{exitCode:1,stdout:i,stderr:`nl: ${a}: No such file or directory
427
427
  `};let u=Cv(c,r,o);i+=u.output,o=u.nextNumber}return{exitCode:0,stdout:i,stderr:""}}},O2={name:"nl",flags:[{flag:"-b",type:"value",valueHint:"string"},{flag:"-n",type:"value",valueHint:"string"},{flag:"-w",type:"value",valueHint:"number"},{flag:"-s",type:"value",valueHint:"string"},{flag:"-v",type:"value",valueHint:"number"},{flag:"-i",type:"value",valueHint:"number"}],stdinType:"text",needsFiles:!0}});var Tv={};ue(Tv,{flagsForFuzzing:()=>R2,fold:()=>cj});function aj(t,e,r){return r?new TextEncoder().encode(t).length:t===" "?8-e%8:t==="\b"?-1:1}function lj(t,e){if(t.length===0)return t;let{width:r,breakAtSpaces:n,countBytes:s}=e,i=[],o="",a=0,l=-1,c=0;for(let u=0;u<t.length;u++){let f=t[u],h=aj(f,a,s);a+h>r&&o.length>0?n&&l>=0?(i.push(o.slice(0,l+1)),o=o.slice(l+1)+f,a=a-c-1+h,l=-1,c=0):(i.push(o),o=f,a=h,l=-1,c=0):(o+=f,a+=h,(f===" "||f===" ")&&(l=o.length-1,c=a-h))}return o.length>0&&i.push(o),i.join(`
428
428
  `)}function kv(t,e){if(t==="")return"";let r=t.split(`
429
429
  `),n=t.endsWith(`
@@ -433,7 +433,7 @@ Try 'comm --help' for more information.
433
433
  `};r.width=a,s+=2}else if(o.startsWith("-w")&&o.length>2){let a=parseInt(o.slice(2),10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${o.slice(2)}'
434
434
  `};r.width=a,s++}else if(o==="-s")r.breakAtSpaces=!0,s++;else if(o==="-b")r.countBytes=!0,s++;else if(o==="-bs"||o==="-sb")r.breakAtSpaces=!0,r.countBytes=!0,s++;else if(o.match(/^-[sb]+w\d+$/)){o.includes("s")&&(r.breakAtSpaces=!0),o.includes("b")&&(r.countBytes=!0);let a=o.replace(/^-[sb]+w/,""),l=parseInt(a,10);if(Number.isNaN(l)||l<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${a}'
435
435
  `};r.width=l,s++}else if(o.match(/^-[sb]+w$/)&&s+1<t.length){o.includes("s")&&(r.breakAtSpaces=!0),o.includes("b")&&(r.countBytes=!0);let a=parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${t[s+1]}'
436
- `};r.width=a,s+=2}else if(o==="--"){n.push(...t.slice(s+1));break}else if(o.startsWith("-")&&o!=="-"){let a=o.slice(1),l=!1;for(let c of a)if(c==="s")r.breakAtSpaces=!0;else if(c==="b")r.countBytes=!0;else{l=!0;break}if(l)return oe("fold",o);s++}else n.push(o),s++}let i="";if(n.length===0){let o=he(e.stdin)??"";i=kv(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`fold: ${o}: No such file or directory
436
+ `};r.width=a,s+=2}else if(o==="--"){n.push(...t.slice(s+1));break}else if(o.startsWith("-")&&o!=="-"){let a=o.slice(1),l=!1;for(let c of a)if(c==="s")r.breakAtSpaces=!0;else if(c==="b")r.countBytes=!0;else{l=!0;break}if(l)return oe("fold",o);s++}else n.push(o),s++}let i="";if(n.length===0){let o=fe(e.stdin)??"";i=kv(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`fold: ${o}: No such file or directory
437
437
  `};i+=kv(l,r)}return{exitCode:0,stdout:i,stderr:""}}},R2={name:"fold",flags:[{flag:"-w",type:"value",valueHint:"number"},{flag:"-s",type:"boolean"},{flag:"-b",type:"boolean"}],stdinType:"text",needsFiles:!0}});var Ov={};ue(Ov,{expand:()=>dj,flagsForFuzzing:()=>D2});function rd(t){let e=t.split(",").map(n=>n.trim()),r=[];for(let n of e){let s=parseInt(n,10);if(Number.isNaN(s)||s<1)return null;r.push(s)}for(let n=1;n<r.length;n++)if(r[n]<=r[n-1])return null;return r}function fj(t,e){if(e.length===1){let r=e[0];return r-t%r}for(let r of e)if(r>t)return r-t;if(e.length>=2){let r=e[e.length-1]-e[e.length-2],n=e[e.length-1],s=Math.floor((t-n)/r)+1;return n+s*r-t}return 1}function hj(t,e){let{tabStops:r,leadingOnly:n}=e,s="",i=0,o=!0;for(let a of t)if(a===" ")if(n&&!o)s+=a,i++;else{let l=fj(i,r);s+=" ".repeat(l),i+=l}else a!==" "&&a!==" "&&(o=!1),s+=a,i++;return s}function _v(t,e){if(t==="")return"";let r=t.split(`
438
438
  `),n=t.endsWith(`
439
439
  `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>hj(i,e)).join(`
@@ -442,7 +442,7 @@ Try 'comm --help' for more information.
442
442
  `};r.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=rd(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(2)}'
443
443
  `};r.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=rd(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
444
444
  `};r.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=rd(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(7)}'
445
- `};r.tabStops=a,s++}else if(o==="-i"||o==="--initial")r.leadingOnly=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return oe("expand",o);n.push(o),s++}}let i="";if(n.length===0){let o=he(e.stdin)??"";i=_v(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`expand: ${o}: No such file or directory
445
+ `};r.tabStops=a,s++}else if(o==="-i"||o==="--initial")r.leadingOnly=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return oe("expand",o);n.push(o),s++}}let i="";if(n.length===0){let o=fe(e.stdin)??"";i=_v(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`expand: ${o}: No such file or directory
446
446
  `};i+=_v(l,r)}return{exitCode:0,stdout:i,stderr:""}}},D2={name:"expand",flags:[{flag:"-t",type:"value",valueHint:"number"},{flag:"-i",type:"boolean"}],stdinType:"text",needsFiles:!0}});var Pv={};ue(Pv,{flagsForFuzzing:()=>F2,unexpand:()=>gj});function nd(t){let e=t.split(",").map(n=>n.trim()),r=[];for(let n of e){let s=parseInt(n,10);if(Number.isNaN(s)||s<1)return null;r.push(s)}for(let n=1;n<r.length;n++)if(r[n]<=r[n-1])return null;return r}function Iv(t,e){if(e.length===1){let r=e[0];return t+(r-t%r)}for(let r of e)if(r>t)return r;if(e.length>=2){let r=e[e.length-1]-e[e.length-2],n=e[e.length-1],s=Math.floor((t-n)/r)+1;return n+s*r}return-1}function mj(t,e){let{tabStops:r,allBlanks:n}=e,s="",i=0,o="",a=0,l=!0,c=()=>{if(o.length===0)return;let u=a+o.length;if(!n&&!l){s+=o,o="";return}let f=a,h="";for(;f<u;){let p=Iv(f,r);if(p<=u&&p>f)h+=" ",f=p;else break}let d=u-f;d>0&&(h+=" ".repeat(d)),s+=h,o=""};for(let u of t)u===" "?(o.length===0&&(a=i),o+=u,i++):u===" "?(c(),s+=u,i=Iv(i,r)):(c(),s+=u,i++,l=!1);return c(),s}function Rv(t,e){if(t==="")return"";let r=t.split(`
447
447
  `),n=t.endsWith(`
448
448
  `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>mj(i,e)).join(`
@@ -451,7 +451,7 @@ Try 'comm --help' for more information.
451
451
  `};r.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=nd(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(2)}'
452
452
  `};r.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=nd(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
453
453
  `};r.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=nd(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(7)}'
454
- `};r.tabStops=a,s++}else if(o==="-a"||o==="--all")r.allBlanks=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return oe("unexpand",o);n.push(o),s++}}let i="";if(n.length===0){let o=he(e.stdin)??"";i=Rv(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`unexpand: ${o}: No such file or directory
454
+ `};r.tabStops=a,s++}else if(o==="-a"||o==="--all")r.allBlanks=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return oe("unexpand",o);n.push(o),s++}}let i="";if(n.length===0){let o=fe(e.stdin)??"";i=Rv(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`unexpand: ${o}: No such file or directory
455
455
  `};i+=Rv(l,r)}return{exitCode:0,stdout:i,stderr:""}}},F2={name:"unexpand",flags:[{flag:"-t",type:"value",valueHint:"number"},{flag:"-a",type:"boolean"}],stdinType:"text",needsFiles:!0}});var Fv={};ue(Fv,{flagsForFuzzing:()=>$2,strings:()=>bj});function xj(t){return t>=32&&t<=126||t===9}function Dv(t,e){if(e===null)return"";switch(e){case"o":return`${t.toString(8).padStart(7," ")} `;case"x":return`${t.toString(16).padStart(7," ")} `;case"d":return`${t.toString(10).padStart(7," ")} `;default:return e}}function Lv(t,e){let r=[],n="",s=0,i=typeof t=="string"?new TextEncoder().encode(t):t;for(let o=0;o<i.length;o++){let a=i[o];if(xj(a))n.length===0&&(s=o),n+=String.fromCharCode(a);else{if(n.length>=e.minLength){let l=Dv(s,e.offsetFormat);r.push(`${l}${n}`)}n=""}}if(n.length>=e.minLength){let o=Dv(s,e.offsetFormat);r.push(`${o}${n}`)}return r}var yj,bj,$2,B2=I(()=>{"use strict";Re();xe();yj={name:"strings",summary:"print the sequences of printable characters in files",usage:"strings [OPTION]... [FILE]...",description:"For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.",options:["-n MIN Print sequences of at least MIN characters (default: 4)","-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)","-a Scan the entire file (default behavior)","-e ENCODING Select character encoding (s=7-bit, S=8-bit)"],examples:["strings file.bin # Extract strings (min 4 chars)","strings -n 8 file.bin # Extract strings (min 8 chars)","strings -t x file.bin # Show hex offset","echo 'hello' | strings # Read from stdin"]};bj={name:"strings",execute:async(t,e)=>{if(Y(t))return Z(yj);let r={minLength:4,offsetFormat:null},n=[],s=0;for(;s<t.length;){let a=t[s];if(a==="-n"&&s+1<t.length){let l=Number.parseInt(t[s+1],10);if(Number.isNaN(l)||l<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${t[s+1]}'
456
456
  `};r.minLength=l,s+=2}else if(a.match(/^-n\d+$/)){let l=Number.parseInt(a.slice(2),10);if(Number.isNaN(l)||l<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${a.slice(2)}'
457
457
  `};r.minLength=l,s++}else if(a.match(/^-\d+$/)){let l=Number.parseInt(a.slice(1),10);if(Number.isNaN(l)||l<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${a.slice(1)}'
@@ -481,7 +481,7 @@ Try 'comm --help' for more information.
481
481
  `}}}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(r.mode){case"lines":l=Sj(a,r.lines);break;case"bytes":l=vj(a,r.bytes);break;case"chunks":l=Aj(a,r.chunks);break;default:return r.mode}if(l.length>Mv)return{exitCode:1,stdout:"",stderr:`split: too many output files (${l.length}), limit is ${Mv}
482
482
  `};for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=Ej(c,r.useNumericSuffix,r.suffixLength),h=`${o}${f}${r.additionalSuffix}`,d=e.fs.resolvePath(e.cwd,h);await e.fs.writeFile(d,u.content,"binary")}return{exitCode:0,stdout:"",stderr:""}}},U2={name:"split",flags:[{flag:"-l",type:"value",valueHint:"number"},{flag:"-b",type:"value",valueHint:"string"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-d",type:"boolean"},{flag:"-a",type:"value",valueHint:"number"}],needsFiles:!0}});var qv={};ue(qv,{column:()=>Ij,flagsForFuzzing:()=>z2});function Uv(t,e,r){return e?r?t.split(e):t.split(e).filter(n=>n.length>0):r?t.split(/[ \t]/):t.split(/[ \t]+/).filter(n=>n.length>0)}function Tj(t){let e=[];for(let r of t)for(let n=0;n<r.length;n++){let s=r[n].length;(e[n]===void 0||s>e[n])&&(e[n]=s)}return e}function _j(t,e){if(t.length===0)return"";let r=Tj(t),n=[];for(let s of t){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(r[o]));n.push(i.join(e))}return n.join(`
483
483
  `)}function Oj(t,e,r){if(t.length===0)return"";let n=Math.max(...t.map(c=>c.length)),s=r.length,i=n+s,o=Math.max(1,Math.floor((e+s)/i)),a=Math.ceil(t.length/o),l=[];for(let c=0;c<a;c++){let u=[];for(let f=0;f<o;f++){let h=f*a+c;h<t.length&&(f===o-1||(f+1)*a+c>=t.length?u.push(t[h]):u.push(t[h].padEnd(n)))}l.push(u.join(r))}return l.join(`
484
- `)}var Nj,kj,Ij,z2,H2=I(()=>{"use strict";Re();Ar();xe();Nj={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},kj={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};Ij={name:"column",execute:async(t,e)=>{if(Y(t))return Z(Nj);let r=ct("column",t,kj);if(!r.ok)return r.error;let{table:n,separator:s,outputSep:i,width:o,noMerge:a}=r.result.flags,l=r.result.positional,c=i??" ",u;if(l.length===0)u=he(e.stdin)??"";else{let m=[];for(let g of l)if(g==="-")m.push(he(e.stdin)??"");else{let y=e.fs.resolvePath(e.cwd,g),x=await e.fs.readFile(y);if(x===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
484
+ `)}var Nj,kj,Ij,z2,H2=I(()=>{"use strict";Re();Ar();xe();Nj={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},kj={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};Ij={name:"column",execute:async(t,e)=>{if(Y(t))return Z(Nj);let r=ct("column",t,kj);if(!r.ok)return r.error;let{table:n,separator:s,outputSep:i,width:o,noMerge:a}=r.result.flags,l=r.result.positional,c=i??" ",u;if(l.length===0)u=fe(e.stdin)??"";else{let m=[];for(let g of l)if(g==="-")m.push(fe(e.stdin)??"");else{let y=e.fs.resolvePath(e.cwd,g),x=await e.fs.readFile(y);if(x===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
485
485
  `};m.push(x)}u=m.join("")}if(u===""||u.trim()==="")return{exitCode:0,stdout:"",stderr:""};let f=u.split(`
486
486
  `);u.endsWith(`
487
487
  `)&&f[f.length-1]===""&&f.pop();let d=f.filter(m=>m.trim().length>0),p;if(n){let m=d.map(g=>Uv(g,s,a));p=_j(m,c)}else{let m=[];for(let g of d){let y=Uv(g,s,a);m.push(...y)}p=Oj(m,o,c)}return p.length>0&&(p+=`
@@ -492,7 +492,7 @@ Try 'comm --help' for more information.
492
492
  `};r.onlyUnpairable.add(d),s+=2}else if(h.match(/^-v[12]$/))r.onlyUnpairable.add(Number.parseInt(h[2],10)),s++;else if(h==="-e"&&s+1<t.length)r.emptyString=t[s+1],s+=2;else if(h==="-o"&&s+1<t.length){let d=Lj(t[s+1]);if(!d)return{exitCode:1,stdout:"",stderr:`join: invalid field spec: '${t[s+1]}'
493
493
  `};r.outputFormat=d,s+=2}else if(h==="-i"||h==="--ignore-case")r.ignoreCase=!0,s++;else if(h==="--"){n.push(...t.slice(s+1));break}else{if(h.startsWith("-")&&h!=="-")return oe("join",h);n.push(h),s++}}if(n.length!==2)return{exitCode:1,stdout:"",stderr:n.length<2?`join: missing file operand
494
494
  `:`join: extra operand
495
- `};let i=[];for(let h of n)if(h==="-")i.push(he(e.stdin)??"");else{let d=e.fs.resolvePath(e.cwd,h),p=await e.fs.readFile(d);if(p===null)return{exitCode:1,stdout:"",stderr:`join: ${h}: No such file or directory
495
+ `};let i=[];for(let h of n)if(h==="-")i.push(fe(e.stdin)??"");else{let d=e.fs.resolvePath(e.cwd,h),p=await e.fs.readFile(d);if(p===null)return{exitCode:1,stdout:"",stderr:`join: ${h}: No such file or directory
496
496
  `};i.push(p)}let o=(h,d)=>{let p=h.split(`
497
497
  `);return h.endsWith(`
498
498
  `)&&p[p.length-1]===""&&p.pop(),p.filter(m=>m.length>0).map(m=>Dj(m,r.separator,d,r.ignoreCase))},a=o(i[0],r.field1),l=o(i[1],r.field2),c=new Map;for(let h of l){let d=c.get(h.joinKey);d?d.push(h):c.set(h.joinKey,[h])}let u=[],f=new Set;for(let h of a){let d=c.get(h.joinKey);if(d&&d.length>0){if(f.add(h.joinKey),r.onlyUnpairable.size===0)for(let p of d)u.push(W2(h,p,r))}else(r.printUnpairable.has(1)||r.onlyUnpairable.has(1))&&u.push(W2(h,null,r))}if(r.printUnpairable.has(2)||r.onlyUnpairable.has(2))for(let h of l)f.has(h.joinKey)||u.push(W2(null,h,r));return{exitCode:0,stdout:Ts(u.length>0?`${u.join(`
@@ -544,14 +544,14 @@ ${a} director${a===1?"y":"ies"}`,n.directoriesOnly||(i+=`, ${l} file${l===1?"":"
544
544
  `,exitCode:1};if(t[0]==="-a"){for(let i of e.env.keys())i.startsWith(Cl)&&e.env.delete(i);return{stdout:"",stderr:"",exitCode:0}}let r=t[0]==="--"?t.slice(1):t,n=!1,s="";for(let i of r){let o=Cl+i;e.env.get(o)?e.env.delete(o):(s+=`unalias: ${i}: not found
545
545
  `,n=!0)}return{stdout:"",stderr:s,exitCode:n?1:0}}},cy={name:"alias",flags:[]},uy={name:"unalias",flags:[{flag:"-a",type:"boolean"}]}});var iA={};ue(iA,{flagsForFuzzing:()=>hy,historyCommand:()=>yV});var gV,sA,yV,hy,dy=I(()=>{"use strict";xe();gV={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},sA="BASH_HISTORY",yV={name:"history",async execute(t,e){if(Y(t))return Z(gV);let r=e.env.get(sA)||"[]",n;try{n=JSON.parse(r)}catch{n=[]}if(t[0]==="-c")return e.env.set(sA,"[]"),{stdout:"",stderr:"",exitCode:0};let s=n.length;t[0]&&/^\d+$/.test(t[0])&&(s=Math.min(parseInt(t[0],10),n.length));let i=n.length-s,o="";for(let a=i;a<n.length;a++){let l=(a+1).toString().padStart(5," ");o+=`${l} ${n[a]}
546
546
  `}return{stdout:o,stderr:"",exitCode:0}}},hy={name:"history",flags:[{flag:"-c",type:"boolean"}]}});var oA={};ue(oA,{flagsForFuzzing:()=>py,xargsCommand:()=>bV});var xV,bV,py,my=I(()=>{"use strict";Re();Yi();xe();xV={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},bV={name:"xargs",async execute(t,e){if(Y(t))return Z(xV);let r=null,n=null,s=null,i=null,o=!1,a=!1,l=!1,c=0;for(let b=0;b<t.length;b++){let w=t[b];if(w==="-I"&&b+1<t.length)r=t[++b],c=b+1;else if(w==="-d"&&b+1<t.length)n=t[++b].replace(/\\n/g,`
547
- `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=b+1;else if(w==="-n"&&b+1<t.length)s=parseInt(t[++b],10),c=b+1;else if(w==="-P"&&b+1<t.length)i=parseInt(t[++b],10),c=b+1;else if(w==="-0"||w==="--null")o=!0,c=b+1;else if(w==="-t"||w==="--verbose")a=!0,c=b+1;else if(w==="-r"||w==="--no-run-if-empty")l=!0,c=b+1;else{if(w.startsWith("--"))return oe("xargs",w);if(w.startsWith("-")&&w.length>1){for(let S of w.slice(1))if(!"0tr".includes(S))return oe("xargs",`-${S}`);w.includes("0")&&(o=!0),w.includes("t")&&(a=!0),w.includes("r")&&(l=!0),c=b+1}else if(!w.startsWith("-")){c=b;break}}}let u=t.slice(c);u.length===0&&u.push("echo");let f=he(e.stdin),h;if(o?h=f.split("\0").filter(b=>b.length>0):n!==null?h=f.replace(/\n$/,"").split(n).filter(w=>w.length>0):h=f.split(/\s+/).map(b=>b.trim()).filter(b=>b.length>0),h.length===0)return l?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",p="",m=0,g=b=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(b)?`"${b.replace(/([\\"`$])/g,"\\$1")}"`:b,y=async b=>{if(a){let S=b.map(g).join(" ");p+=`${S}
547
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=b+1;else if(w==="-n"&&b+1<t.length)s=parseInt(t[++b],10),c=b+1;else if(w==="-P"&&b+1<t.length)i=parseInt(t[++b],10),c=b+1;else if(w==="-0"||w==="--null")o=!0,c=b+1;else if(w==="-t"||w==="--verbose")a=!0,c=b+1;else if(w==="-r"||w==="--no-run-if-empty")l=!0,c=b+1;else{if(w.startsWith("--"))return oe("xargs",w);if(w.startsWith("-")&&w.length>1){for(let S of w.slice(1))if(!"0tr".includes(S))return oe("xargs",`-${S}`);w.includes("0")&&(o=!0),w.includes("t")&&(a=!0),w.includes("r")&&(l=!0),c=b+1}else if(!w.startsWith("-")){c=b;break}}}let u=t.slice(c);u.length===0&&u.push("echo");let f=fe(e.stdin),h;if(o?h=f.split("\0").filter(b=>b.length>0):n!==null?h=f.replace(/\n$/,"").split(n).filter(w=>w.length>0):h=f.split(/\s+/).map(b=>b.trim()).filter(b=>b.length>0),h.length===0)return l?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",p="",m=0,g=b=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(b)?`"${b.replace(/([\\"`$])/g,"\\$1")}"`:b,y=async b=>{if(a){let S=b.map(g).join(" ");p+=`${S}
548
548
  `}return e.exec?e.exec(Vr([b[0]]),{cwd:e.cwd,signal:e.signal,args:b.slice(1)}):{stdout:`${b.map(g).join(" ")}
549
549
  `,stderr:"",exitCode:0}},x=async b=>{if(i!==null&&i>1)for(let w=0;w<b.length;w+=i){let S=b.slice(w,w+i),_=await Promise.all(S.map(y));for(let P of _)d+=P.stdout,p+=P.stderr,P.exitCode!==0&&(m=P.exitCode)}else for(let w of b){let S=await y(w);d+=S.stdout,p+=S.stderr,S.exitCode!==0&&(m=S.exitCode)}};if(r!==null){let b=h.map(w=>u.map(S=>S.replaceAll(r,w)));await x(b)}else if(s!==null){let b=[];for(let w=0;w<h.length;w+=s){let S=h.slice(w,w+s);b.push([...u,...S])}await x(b)}else{let b=[...u,...h],w=await y(b);d+=w.stdout,p+=w.stderr,m=w.exitCode}return{stdout:d,stderr:p,exitCode:m}}},py={name:"xargs",flags:[{flag:"-I",type:"value",valueHint:"string"},{flag:"-d",type:"value",valueHint:"delimiter"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-0",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-r",type:"boolean"}],stdinType:"text"}});var xy={};ue(xy,{falseCommand:()=>EV,falseFlagsForFuzzing:()=>yy,flagsForFuzzing:()=>gy,trueCommand:()=>wV});var wV,EV,gy,yy,ad=I(()=>{"use strict";wV={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},EV={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}},gy={name:"true",flags:[]},yy={name:"false",flags:[]}});var aA={};ue(aA,{clearCommand:()=>vV,flagsForFuzzing:()=>by});var SV,vV,by,wy=I(()=>{"use strict";xe();SV={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},vV={name:"clear",async execute(t,e){return Y(t)?Z(SV):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}},by={name:"clear",flags:[]}});var vy={};ue(vy,{bashCommand:()=>AV,flagsForFuzzing:()=>Ey,shCommand:()=>CV,shFlagsForFuzzing:()=>Sy});async function Nl(t,e,r,n){if(!n.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
550
550
  `,exitCode:1};let s=Xi(n.exportedEnv||{},{0:e,"#":String(r.length),"@":r.join(" "),"*":r.join(" ")});r.forEach((a,l)=>{s[String(l+1)]=a});let i=t;if(i.startsWith("#!")){let a=i.indexOf(`
551
- `);a!==-1&&(i=i.slice(a+1))}return await n.exec(i,{env:s,cwd:n.cwd,stdin:n.stdin,stdinKind:"bytes",signal:n.signal})}var lA,AV,CV,Ey,Sy,ld=I(()=>{"use strict";Re();Rs();xe();lA={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},AV={name:"bash",async execute(t,e){if(Y(t))return Z(lA);if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"bash",o=t.slice(3);return Nl(s,i,o,e)}if(t.length===0){let s=he(e.stdin);return s.trim()?Nl(s,"bash",[],e):{stdout:"",stderr:"",exitCode:0}}let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Nl(i,r,n,e)}catch{return{stdout:"",stderr:`bash: ${r}: No such file or directory
552
- `,exitCode:127}}}},CV={name:"sh",async execute(t,e){if(Y(t))return Z({...lA,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"sh",o=t.slice(3);return Nl(s,i,o,e)}if(t.length===0){let s=he(e.stdin);return s.trim()?Nl(s,"sh",[],e):{stdout:"",stderr:"",exitCode:0}}let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Nl(i,r,n,e)}catch{return{stdout:"",stderr:`sh: ${r}: No such file or directory
551
+ `);a!==-1&&(i=i.slice(a+1))}return await n.exec(i,{env:s,cwd:n.cwd,stdin:n.stdin,stdinKind:"bytes",signal:n.signal})}var lA,AV,CV,Ey,Sy,ld=I(()=>{"use strict";Re();Rs();xe();lA={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},AV={name:"bash",async execute(t,e){if(Y(t))return Z(lA);if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"bash",o=t.slice(3);return Nl(s,i,o,e)}if(t.length===0){let s=fe(e.stdin);return s.trim()?Nl(s,"bash",[],e):{stdout:"",stderr:"",exitCode:0}}let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Nl(i,r,n,e)}catch{return{stdout:"",stderr:`bash: ${r}: No such file or directory
552
+ `,exitCode:127}}}},CV={name:"sh",async execute(t,e){if(Y(t))return Z({...lA,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"sh",o=t.slice(3);return Nl(s,i,o,e)}if(t.length===0){let s=fe(e.stdin);return s.trim()?Nl(s,"sh",[],e):{stdout:"",stderr:"",exitCode:0}}let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Nl(i,r,n,e)}catch{return{stdout:"",stderr:`sh: ${r}: No such file or directory
553
553
  `,exitCode:127}}}};Ey={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},Sy={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function Ay(t,e,r,n,s,i,o,a,l,c){switch(e){case"sort":return Array.isArray(t)?[[...t].sort(o)]:[null];case"sort_by":return!Array.isArray(t)||r.length===0?[null]:[[...t].sort((f,h)=>{let d=s(f,r[0],n)[0],p=s(h,r[0],n)[0];return o(d,p)})];case"bsearch":{if(!Array.isArray(t)){let f=t===null?"null":typeof t=="object"?"object":typeof t;throw new Error(`${f} (${JSON.stringify(t)}) cannot be searched from`)}return r.length===0?[null]:s(t,r[0],n).map(f=>{let h=0,d=t.length;for(;h<d;){let p=h+d>>>1;o(t[p],f)<0?h=p+1:d=p}return h<t.length&&o(t[h],f)===0?h:-h-1})}case"unique_by":{if(!Array.isArray(t)||r.length===0)return[null];let u=new Map;for(let h of t){let d=s(h,r[0],n)[0],p=JSON.stringify(d);u.has(p)||u.set(p,{item:h,key:d})}let f=[...u.values()];return f.sort((h,d)=>o(h.key,d.key)),[f.map(h=>h.item)]}case"group_by":{if(!Array.isArray(t)||r.length===0)return[null];let u=new Map;for(let f of t){let h=JSON.stringify(s(f,r[0],n)[0]);u.has(h)||u.set(h,[]),u.get(h)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((u,f)=>o(u,f)>0?u:f)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||r.length===0?[null]:[t.reduce((u,f)=>{let h=s(u,r[0],n)[0],d=s(f,r[0],n)[0];return o(h,d)>0?u:f})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((u,f)=>o(u,f)<0?u:f)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||r.length===0?[null]:[t.reduce((u,f)=>{let h=s(u,r[0],n)[0],d=s(f,r[0],n)[0];return o(h,d)<0?u:f})];case"add":{let u=f=>{let h=f.filter(d=>d!==null);return h.length===0?null:h.every(d=>typeof d=="number")?h.reduce((d,p)=>d+p,0):h.every(d=>typeof d=="string")?h.join(""):h.every(d=>Array.isArray(d))?h.flat():h.every(d=>d&&typeof d=="object"&&!Array.isArray(d))?Xi(...h):null};if(r.length>=1){let f=s(t,r[0],n);return[u(f)]}return Array.isArray(t)?[u(t)]:[null]}case"any":{if(r.length>=2){try{let u=i(t,r[0],n);for(let f of u)if(s(f,r[1],n).some(a))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return r.length===1?Array.isArray(t)?[t.some(u=>a(s(u,r[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(a)]:[!1]}case"all":{if(r.length>=2){try{let u=i(t,r[0],n);for(let f of u)if(!s(f,r[1],n).some(a))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return r.length===1?Array.isArray(t)?[t.every(u=>a(s(u,r[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(a)]:[!0]}case"select":return r.length===0?[t]:s(t,r[0],n).some(a)?[t]:[];case"map":return r.length===0||!Array.isArray(t)?[null]:[t.flatMap(f=>s(f,r[0],n))];case"map_values":{if(r.length===0)return[null];if(Array.isArray(t))return[t.flatMap(u=>s(u,r[0],n))];if(t&&typeof t=="object"){let u=Object.create(null);for(let[f,h]of Object.entries(t)){if(!kt(f))continue;let d=s(h,r[0],n);d.length>0&&qt(u,f,d[0])}return[u]}return[null]}case"has":{if(r.length===0)return[!1];let f=s(t,r[0],n)[0];return Array.isArray(t)&&typeof f=="number"?[f>=0&&f<t.length]:t&&typeof t=="object"&&typeof f=="string"?[Ci(t,f)]:[!1]}case"in":{if(r.length===0)return[!1];let f=s(t,r[0],n)[0];return Array.isArray(f)&&typeof t=="number"?[t>=0&&t<f.length]:f&&typeof f=="object"&&typeof t=="string"?[Ci(f,t)]:[!1]}case"contains":{if(r.length===0)return[!1];let u=s(t,r[0],n);return[l(t,u[0])]}case"inside":{if(r.length===0)return[!1];let u=s(t,r[0],n);return[l(u[0],t)]}default:return null}}var cA=I(()=>{"use strict";Rs();Wn()});function Cy(t,e,r,n,s,i,o,a){switch(e){case"first":if(r.length>0)try{let l=i(t,r[0],n);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof a)throw l;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(r.length>0){let l=s(t,r[0],n);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(r.length<1)return[null];let l=s(t,r[0],n);if(r.length>1){for(let u of l)if(u<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(t,r[1],n)}catch(u){if(u instanceof a)throw u;c=[]}return l.flatMap(u=>{let f=u;return f<c.length?[c[f]]:[]})}return Array.isArray(t)?l.flatMap(c=>{let u=c;if(u<0)throw new Error("nth doesn't support negative indices");return u<t.length?[t[u]]:[null]}):[null]}case"range":{if(r.length===0)return[];let l=Math.max(n.limits.maxIterations*100,1e6),c=p=>p.length>=l,u=s(t,r[0],n);if(r.length===1){let p=[];for(let m of u){let g=m;for(let y=0;y<g;y++)if(p.push(y),c(p))return p}return p}let f=s(t,r[1],n);if(r.length===2){let p=[];for(let m of u)for(let g of f){let y=m,x=g;for(let b=y;b<x;b++)if(p.push(b),c(p))return p}return p}let h=s(t,r[2],n),d=[];for(let p of u)for(let m of f)for(let g of h){let y=p,x=m,b=g;if(b!==0){if(b>0){for(let w=y;w<x;w+=b)if(d.push(w),c(d))return d}else for(let w=y;w>x;w+=b)if(d.push(w),c(d))return d}}return d}case"limit":return r.length<2?[]:s(t,r[0],n).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(t,r[1],n)}catch(h){if(h instanceof a)throw h;f=[]}return f.slice(0,u)});case"isempty":{if(r.length<1)return[!0];try{return[i(t,r[0],n).length===0]}catch(l){if(l instanceof a)throw l;return[!0]}}case"isvalid":{if(r.length<1)return[!0];try{return[s(t,r[0],n).length>0]}catch(l){if(l instanceof a)throw l;return[!1]}}case"skip":return r.length<2?[]:s(t,r[0],n).flatMap(c=>{let u=c;if(u<0)throw new Error("skip doesn't support negative count");return s(t,r[1],n).slice(u)});case"until":{if(r.length<2)return[t];let l=t,c=n.limits.maxIterations;for(let u=0;u<c;u++){if(s(l,r[0],n).some(o))return[l];let h=s(l,r[1],n);if(h.length===0)return[l];l=h[0]}throw new a(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(r.length<2)return[t];let l=[],c=t,u=n.limits.maxIterations;for(let f=0;f<u&&s(c,r[0],n).some(o);f++){l.push(c);let d=s(c,r[1],n);if(d.length===0)break;c=d[0]}if(l.length>=u)throw new a(`jq while: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(r.length===0)return[t];let l=[],c=t,u=n.limits.maxIterations;for(let f=0;f<u;f++){l.push(c);let h=s(c,r[0],n);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new a(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var uA=I(()=>{"use strict"});function Ny(t,e,r,n,s){switch(e){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let i=new Date(t*1e3),o=i.getUTCFullYear(),a=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),h=i.getUTCDay(),d=Date.UTC(o,0,1),p=Math.floor((i.getTime()-d)/(1440*60*1e3));return[[o,a,l,c,u,f,h,p]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[i,o,a,l=0,c=0,u=0]=t;if(typeof i!="number"||typeof o!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,o,a??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(r.length===0)return[null];let o=s(t,r[0],n)[0];if(typeof o!="string")throw new Error("strftime/1 requires a string format");let a;if(typeof t=="number")a=new Date(t*1e3);else if(Array.isArray(t)){let[h,d,p,m=0,g=0,y=0]=t;if(typeof h!="number"||typeof d!="number")throw new Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(h,d,p??1,m??0,g??0,y??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(h,d=2)=>String(h).padStart(d,"0");return[o.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,u(a.getUTCMonth()+1)).replace(/%d/g,u(a.getUTCDate())).replace(/%H/g,u(a.getUTCHours())).replace(/%M/g,u(a.getUTCMinutes())).replace(/%S/g,u(a.getUTCSeconds())).replace(/%A/g,l[a.getUTCDay()]).replace(/%B/g,c[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(r.length===0)return[null];if(typeof t!="string")throw new Error("strptime/1 requires a string input");let o=s(t,r[0],n)[0];if(typeof o!="string")throw new Error("strptime/1 requires a string format");if(o==="%Y-%m-%dT%H:%M:%SZ"){let l=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(l){let[,c,u,f,h,d,p]=l.map(Number),m=new Date(Date.UTC(c,u-1,f,h,d,p)),g=m.getUTCDay(),y=Date.UTC(c,0,1),x=Math.floor((m.getTime()-y)/(1440*60*1e3));return[[c,u-1,f,h,d,p,g,x]]}}let a=new Date(t);if(!Number.isNaN(a.getTime())){let l=a.getUTCFullYear(),c=a.getUTCMonth(),u=a.getUTCDate(),f=a.getUTCHours(),h=a.getUTCMinutes(),d=a.getUTCSeconds(),p=a.getUTCDay(),m=Date.UTC(l,0,1),g=Math.floor((a.getTime()-m)/(1440*60*1e3));return[[l,c,u,f,h,d,p,g]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let i=new Date(t);if(Number.isNaN(i.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof t!="number")throw new Error("todate requires a number input");return[new Date(t*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}var fA=I(()=>{"use strict"});function Ls(t){return t!==!1&&t!==null}function kl(t,e){return JSON.stringify(t)===JSON.stringify(e)}function pu(t,e){return typeof t=="number"&&typeof e=="number"?t-e:typeof t=="string"&&typeof e=="string"?t.localeCompare(e):0}function ky(t,e){let r=br(t);for(let n of Object.keys(e)){if(!kt(n))continue;let s=Ci(r,n)?Kt(r[n]):null,i=Kt(e[n]);s&&i?qt(r,n,ky(s,i)):qt(r,n,e[n])}return r}function Tl(t,e=3e3){let r=0,n=t;for(;r<e;)if(Array.isArray(n)){if(n.length===0)return r+1;n=n[0],r++}else if(n!==null&&typeof n=="object"){let s=Object.keys(n);if(s.length===0)return r+1;n=n[s[0]],r++}else return r;return r}function cd(t,e){let r=a=>a===null?0:typeof a=="boolean"?1:typeof a=="number"?2:typeof a=="string"?3:Array.isArray(a)?4:typeof a=="object"?5:6,n=r(t),s=r(e);if(n!==s)return n-s;if(typeof t=="number"&&typeof e=="number")return t-e;if(typeof t=="string"&&typeof e=="string")return t.localeCompare(e);if(typeof t=="boolean"&&typeof e=="boolean")return(t?1:0)-(e?1:0);if(Array.isArray(t)&&Array.isArray(e)){for(let a=0;a<Math.min(t.length,e.length);a++){let l=cd(t[a],e[a]);if(l!==0)return l}return t.length-e.length}let i=Kt(t),o=Kt(e);if(i&&o){let a=Object.keys(i).sort(),l=Object.keys(o).sort();for(let c=0;c<Math.min(a.length,l.length);c++){let u=a[c].localeCompare(l[c]);if(u!==0)return u}if(a.length!==l.length)return a.length-l.length;for(let c of a){let u=cd(i[c],o[c]);if(u!==0)return u}}return 0}function ud(t,e){if(kl(t,e))return!0;if(typeof t=="string"&&typeof e=="string")return t.includes(e);if(Array.isArray(t)&&Array.isArray(e))return e.every(s=>t.some(i=>ud(i,s)));let r=Kt(t),n=Kt(e);return r&&n?Object.keys(n).every(s=>Ci(r,s)&&ud(r[s],n[s])):!1}var fd=I(()=>{"use strict";Wn()});function Ty(t,e,r){switch(e){case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof t=="string"?[decodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(s=>{if(s===null)return"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="number")return String(s);let i=String(s);return i.includes(",")||i.includes('"')||i.includes(`
554
- `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(n=>String(n??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let n=r??NV;return Tl(t,n+1)>n?[null]:[JSON.stringify(t)]}case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];default:return null}}var NV,hA=I(()=>{"use strict";fd();NV=2e3});function _y(t,e,r,n,s,i){switch(e){case"index":return r.length===0?[null]:s(t,r[0],n).map(a=>{if(typeof t=="string"&&typeof a=="string"){if(a===""&&t==="")return null;let l=t.indexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let c=0;c<=t.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(t[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=t.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return r.length===0?[null]:s(t,r[0],n).map(a=>{if(typeof t=="string"&&typeof a=="string"){let l=t.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let l=t.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(t[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=t.length-1;l>=0;l--)if(i(t[l],a))return l;return null}return null});case"indices":return r.length===0?[[]]:s(t,r[0],n).map(a=>{let l=[];if(typeof t=="string"&&typeof a=="string"){let c=t.indexOf(a);for(;c!==-1;)l.push(c),c=t.indexOf(a,c+1)}else if(Array.isArray(t))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=t.length;u++)l.push(u);else for(let u=0;u<=t.length-c;u++){let f=!0;for(let h=0;h<c;h++)if(!i(t[u+h],a[h])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<t.length;c++)i(t[c],a)&&l.push(c);return l});default:return null}}var dA=I(()=>{"use strict"});function Oy(t,e,r,n,s){switch(e){case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:typeof t=="string"?[t]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.hypot(t,i)]}case"fma":{if(typeof t!="number"||r.length<2)return[null];let i=s(t,r[0],n)[0],o=s(t,r[1],n)[0];return[t*i+o]}case"copysign":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.sign(i)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[t-Math.round(t/i)*i]}case"fdim":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.max(0,t-i)]}case"fmax":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.max(t,i)]}case"fmin":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.min(t,i)]}case"ldexp":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[t*2**i]}case"scalbn":case"scalbln":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[t*2**i]}case"nearbyint":return typeof t=="number"?[Math.round(t)]:[null];case"logb":return typeof t=="number"?[Math.floor(Math.log2(Math.abs(t)))]:[null];case"significand":if(typeof t=="number"){let i=Math.floor(Math.log2(Math.abs(t)));return[t/2**i]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**i,i]]}return[null];case"modf":if(typeof t=="number"){let i=Math.trunc(t);return[[t-i,i]]}return[null];default:return null}}var pA=I(()=>{"use strict"});function Iy(t,e,r,n,s,i,o,a){switch(e){case"recurse":{if(r.length===0){let d=[],p=m=>{if(d.push(m),Array.isArray(m))for(let g of m)p(g);else if(m&&typeof m=="object")for(let g of Object.keys(m))p(m[g])};return p(t),d}let l=[],c=r.length>=2?r[1]:null,u=1e4,f=0,h=d=>{if(f++>u||c&&!s(d,c,n).some(i))return;l.push(d);let p=s(d,r[0],n);for(let m of p)m!=null&&h(m)};return h(t),l}case"recurse_down":return a(t,"recurse",r,n);case"walk":{if(r.length===0)return[t];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(u))kt(p)&&qt(d,p,c(m));f=d}else f=u;return s(f,r[0],n)[0]};return[c(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let l=Math.max(...t.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(t.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(r.length>0){let f=s(t,r[0],n)[0];if(!Array.isArray(t)||f<0)return[];if(f===0)return[[]];let h=[],d=(p,m)=>{if(m===f){h.push([...p]);return}for(let g of t)p.push(g),d(p,m+1),p.pop()};return d([],0),h}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let u of t)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===t.length){l.push([...f]);return}let h=t[u];for(let d of h)f.push(d),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let l=n.currentPath;if(l.length===0)return[];let c=r.length>0?s(t,r[0],n)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(n.root,u)]}else{let u=-c-1;if(u>=l.length)return[t];let f=l.slice(0,u);return[o(n.root,f)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let l=n.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(n.root,l.slice(0,u)));return[c]}case"root":return n.root!==void 0?[n.root]:[];default:return null}}var mA=I(()=>{"use strict";Wn()});function Ry(t,e,r,n,s){switch(e){case"keys":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:typeof t=="number"?[Math.abs(t)]:[null];case"utf8bytelength":{if(typeof t=="string")return[new TextEncoder().encode(t).length];let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":{let i=Kt(t);return i?[Object.entries(i).map(([o,a])=>({key:o,value:a}))]:[null]}case"from_entries":if(Array.isArray(t)){let i=Object.create(null);for(let o of t){let a=Kt(o);if(a){let l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;if(l!==void 0){let u=String(l);kt(u)&&qt(i,u,c)}}}return[i]}return[null];case"with_entries":{if(r.length===0)return[t];let i=Kt(t);if(i){let a=Object.entries(i).map(([c,u])=>({key:c,value:u})).flatMap(c=>s(c,r[0],n)),l=Object.create(null);for(let c of a){let u=Kt(c);if(u){let f=u.key??u.name??u.k,h=u.value??u.v;if(f!==void 0){let d=String(f);kt(d)&&qt(l,d,h)}}}return[l]}return[null]}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(t)?(r.length>0?s(t,r[0],n):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return t.flat(a)}):[null];case"unique":if(Array.isArray(t)){let i=new Set,o=[];for(let a of t){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=n.limits.maxDepth??kV;return Tl(t,i+1)>i?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let i=t.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[nn(JSON.parse(t))]}catch{throw new Error(`Invalid JSON: ${t}`)}}return[t]}case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let i=Number(t);if(Number.isNaN(i))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof t} cannot be parsed as a number`);case"toboolean":{if(typeof t=="boolean")return[t];if(typeof t=="string"){if(t==="true")return[!0];if(t==="false")return[!1];throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`)}let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,Object.create(null)]);else for(let u of c)o(a[u],[...l,u])}};return o(t,[]),i.push([[]]),i}case"fromstream":{if(r.length===0)return[t];let i=s(t,r[0],n),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:Object.create(null));let u=o;for(let h=0;h<l.length-1;h++){let d=l[h],p=l[h+1];if(Array.isArray(u)&&typeof d=="number"){for(;u.length<=d;)u.push(null);u[d]===null&&(u[d]=typeof p=="number"?[]:Object.create(null)),u=u[d]}else{let m=Kt(u);if(m){let g=String(d);if(!kt(g))continue;(m[g]===null||m[g]===void 0)&&qt(m,g,typeof p=="number"?[]:Object.create(null)),u=m[g]}}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else{let h=Kt(u);if(h){let d=String(f);kt(d)&&qt(h,d,c)}}}return[o]}case"truncate_stream":{let i=typeof t=="number"?Math.floor(t):0;if(r.length===0)return[];let o=[],a=s(t,r[0],n);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var kV,gA=I(()=>{"use strict";Wn();fd();kV=2e3});function Py(t,e,r,n,s,i,o,a,l,c){switch(e){case"getpath":{if(r.length===0)return[null];let u=s(t,r[0],n),f=[];for(let h of u){let d=h,p=t;for(let m of d){if(p==null){p=null;break}if(Array.isArray(p)&&typeof m=="number")p=p[m];else if(typeof m=="string"){let g=Kt(p);if(!g||!Object.hasOwn(g,m)){p=null;break}p=g[m]}else{p=null;break}}f.push(p)}return f}case"setpath":{if(r.length<2)return[null];let f=s(t,r[0],n)[0],d=s(t,r[1],n)[0];return[o(t,f,d)]}case"delpaths":{if(r.length===0)return[t];let f=s(t,r[0],n)[0],h=t;for(let d of f.sort((p,m)=>m.length-p.length))h=a(h,d);return[h]}case"path":{if(r.length===0)return[[]];let u=[];return c(t,r[0],n,[],u),u}case"del":return r.length===0?[t]:[l(t,r[0],n)];case"pick":{if(r.length===0)return[null];let u=[];for(let h of r)c(t,h,n,[],u);let f=null;for(let h of u){for(let p of h)if(typeof p=="number"&&p<0)throw new Error("Out of bounds negative array index");let d=t;for(let p of h){if(d==null)break;if(Array.isArray(d)&&typeof p=="number")d=d[p];else if(typeof p=="string"){let m=Kt(d);if(!m||!Object.hasOwn(m,p)){d=null;break}d=m[p]}else{d=null;break}}f=o(f,h,d)}return[f]}case"paths":{let u=[],f=(h,d)=>{if(h&&typeof h=="object")if(Array.isArray(h))for(let p=0;p<h.length;p++)u.push([...d,p]),f(h[p],[...d,p]);else for(let p of Object.keys(h))u.push([...d,p]),f(h[p],[...d,p])};return f(t,[]),r.length>0?u.filter(h=>{let d=t;for(let m of h)if(Array.isArray(d)&&typeof m=="number")d=d[m];else if(typeof m=="string"){let g=Kt(d);if(!g||!Object.hasOwn(g,m))return!1;d=g[m]}else return!1;return s(d,r[0],n).some(i)}):u}case"leaf_paths":{let u=[],f=(h,d)=>{if(h===null||typeof h!="object")u.push(d);else if(Array.isArray(h))for(let p=0;p<h.length;p++)f(h[p],[...d,p]);else for(let p of Object.keys(h))f(h[p],[...d,p])};return f(t,[]),u}default:return null}}var yA=I(()=>{"use strict";Wn()});function Dy(t,e,r,n,s,i){switch(e){case"IN":{if(r.length===0)return[!1];if(r.length===1){let c=s(t,r[0],n);for(let u of c)if(i(t,u))return[!0];return[!1]}let o=s(t,r[0],n),a=s(t,r[1],n),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(r.length===0)return[Object.create(null)];if(r.length===1){let l=s(t,r[0],n),c=Object.create(null);for(let u of l){let f=String(u);kt(f)&&qt(c,f,u)}return[c]}if(r.length===2){let l=s(t,r[0],n),c=Object.create(null);for(let u of l){let f=s(u,r[1],n);if(f.length>0){let h=String(f[0]);kt(h)&&qt(c,h,u)}}return[c]}let o=s(t,r[0],n),a=Object.create(null);for(let l of o){let c=s(l,r[1],n),u=s(l,r[2],n);if(c.length>0&&u.length>0){let f=String(c[0]);kt(f)&&qt(a,f,u[0])}}return[a]}case"JOIN":{if(r.length<2)return[null];let o=Kt(s(t,r[0],n)[0]);if(!o)return[null];if(!Array.isArray(t))return[null];let a=[];for(let l of t){let c=s(l,r[1],n),u=c.length>0?String(c[0]):"",f=Ci(o,u)?o[u]:null;a.push([l,f])}return[a]}default:return null}}var xA=I(()=>{"use strict";Wn()});function Ly(t,e,r,n,s){switch(e){case"join":{if(!Array.isArray(t))return[null];let i=r.length>0?s(t,r[0],n):[""];for(let o of t)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>t.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof t!="string"||r.length===0)return[null];let i=s(t,r[0],n),o=String(i[0]);return[t.split(o)]}case"splits":{if(typeof t!="string"||r.length===0)return[];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"g";return ae(o,a.includes("g")?a:`${a}g`).split(t)}catch{return[]}}case"scan":{if(typeof t!="string"||r.length===0)return[];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"";return[...ae(o,a.includes("g")?a:`${a}g`).matchAll(t)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof t!="string"||r.length===0)return[!1];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"";return[ae(o,a).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||r.length===0)return[null];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"",c=ae(o,`${a}d`).exec(t);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,h)=>({offset:u?.[h+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||r.length===0)return[null];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"",c=ae(o,a).match(t);return!c||!c.groups?[Object.create(null)]:[c.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=String(i[0]),l=String(o[0]);try{let c=r.length>2?String(s(t,r[2],n)[0]):"";return[ae(a,c).replace(t,l)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=String(i[0]),l=String(o[0]);try{let c=r.length>2?String(s(t,r[2],n)[0]):"g",u=c.includes("g")?c:`${c}g`;return[ae(a,u).replace(t,l)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||r.length===0)return[t];let i=s(t,r[0],n),o=String(i[0]);return[t.startsWith(o)?t.slice(o.length):t]}case"rtrimstr":{if(typeof t!="string"||r.length===0)return[t];let i=s(t,r[0],n),o=String(i[0]);return o===""?[t]:[t.endsWith(o)?t.slice(0,-o.length):t]}case"trimstr":{if(typeof t!="string"||r.length===0)return[t];let i=s(t,r[0],n),o=String(i[0]);if(o==="")return[t];let a=t;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof t=="string")return[t.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof t=="string")return[t.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof t=="string")return[t.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof t!="string"||r.length===0)return[!1];let i=s(t,r[0],n);return[t.startsWith(String(i[0]))]}case"endswith":{if(typeof t!="string"||r.length===0)return[!1];let i=s(t,r[0],n);return[t.endsWith(String(i[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var bA=I(()=>{"use strict";Gt()});function Fy(t,e){switch(e){case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"values":return t===null?[]:[t];case"not":return t===!1||t===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var wA=I(()=>{"use strict"});var EA=I(()=>{"use strict";cA();uA();fA();hA();dA();pA();mA();gA();yA();xA();bA();wA()});function hd(t,e,r){if(e.length===0)return r;let[n,...s]=e;if(typeof n=="number"){if(t&&typeof t=="object"&&!Array.isArray(t))throw new Error("Cannot index object with number");if(n>536870911)throw new Error("Array index too large");if(n<0)throw new Error("Out of bounds negative array index");let c=Array.isArray(t)?[...t]:[];for(;c.length<=n;)c.push(null);return c[n]=hd(c[n],s,r),c}if(Array.isArray(t))throw new Error("Cannot index array with string");if(!kt(n))return t??Object.create(null);let i=Kt(t),o=i?br(i):Object.create(null),a=Object.hasOwn(o,n)?o[n]:void 0;return qt(o,n,hd(a,s,r)),o}function dd(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i=String(s);if(!kt(i))return t;let o=br(t);return delete o[i],o}return t}let[r,...n]=e;if(Array.isArray(t)&&typeof r=="number"){let s=[...t];return s[r]=dd(s[r],n),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s=String(r);if(!kt(s))return t;let i=br(t);return Object.hasOwn(i,s)&&qt(i,s,dd(i[s],n)),i}return t}var SA=I(()=>{"use strict";Wn()});function OV(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??TV,maxDepth:t?.limits?.maxDepth??CA},env:t?.env,coverage:t?.coverage,requireDefenseContext:t?.requireDefenseContext,defenseContextChecked:!1}}function gd(t,e,r){let n=new Map(t.vars);return n.set(e,r),{vars:n,limits:t.limits,env:t.env,requireDefenseContext:t.requireDefenseContext,defenseContextChecked:t.defenseContextChecked,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels,coverage:t.coverage}}function mu(t,e,r){switch(e.type){case"var":return gd(t,e.name,r);case"array":{if(!Array.isArray(r))return null;let n=t;for(let s=0;s<e.elements.length;s++){let i=e.elements[s],o=s<r.length?r[s]:null,a=mu(n,i,o);if(a===null)return null;n=a}return n}case"object":{let n=Kt(r);if(!n)return null;let s=t;for(let i of e.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=ne(r,i.key,t);if(c.length===0)return null;o=String(c[0])}let a=Ci(n,o)?n[o]:null;i.keyVar&&(s=gd(s,i.keyVar,a));let l=mu(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function IV(t,e){let r=t;for(let n of e)if(r&&typeof r=="object")if(Array.isArray(r))if(typeof n=="number")r=r[n];else return;else{let s=Kt(r);if(s&&typeof n=="string"&&Object.hasOwn(s,n))r=s[n];else return}else return;return r}function Co(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?Co(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?Co(t.base):[];if(e===null)return null;let r=t.index.value;return typeof r=="number"||typeof r=="string"?[...e,r]:null}if(t.type==="Pipe"){let e=Co(t.left);return e===null?null:My(e,t.right)}if(t.type==="Call"){if(t.name==="parent"||t.name==="root")return null;if(t.name==="first"&&t.args.length===0)return[0];if(t.name==="last"&&t.args.length===0)return[-1]}return null}function My(t,e){if(e.type==="Call"){if(e.name==="parent"){let r=1;if(e.args.length>0&&e.args[0].type==="Literal"){let n=e.args[0].value;typeof n=="number"&&(r=n)}if(r>=0)return t.slice(0,Math.max(0,t.length-r));{let n=-r-1;return t.slice(0,Math.min(n,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let r=Co(e);if(r!==null)return[...t,...r]}if(e.type==="Index"&&e.index.type==="Literal"){let r=Co(e);if(r!==null)return[...t,...r]}if(e.type==="Pipe"){let r=My(t,e.left);return r===null?null:My(r,e.right)}return e.type==="Identity"?t:null}function vA(t,e,r){if(e.type==="Comma"){let n=[];try{n.push(...ne(t,e.left,r))}catch(s){if(s instanceof fe)throw s;if(n.length>0)return n;throw new Error("evaluation failed")}try{n.push(...ne(t,e.right,r))}catch(s){if(s instanceof fe)throw s;return n}return n}return ne(t,e,r)}function ne(t,e,r){let n=r&&"vars"in r?r:OV(r);switch(n.defenseContextChecked||(rr(n.requireDefenseContext,"query-engine","evaluation"),n={...n,defenseContextChecked:!0}),n.root===void 0&&(n={...n,root:t,currentPath:[]}),n.coverage?.hit(`jq:node:${e.type}`),e.type){case"Identity":return[t];case"Field":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>{let o=Kt(i);if(o){if(!Object.hasOwn(o,e.name))return[null];let l=o[e.name];return[l===void 0?null:l]}if(i===null)return[null];let a=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${a} with string "${e.name}"`)});case"Index":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>ne(i,e.index,n).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof a=="string"){let l=Kt(i);return!l||!Object.hasOwn(l,a)?[null]:[l[a]]}return[null]}));case"Slice":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=e.start?ne(t,e.start,n):[0],l=e.end?ne(t,e.end,n):[o];return a.flatMap(c=>l.map(u=>{let f=c,h=u,d=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),p=Number.isNaN(h)?o:Number.isInteger(h)?h:Math.ceil(h),m=AA(d,o),g=AA(p,o);return Array.isArray(i),i.slice(m,g)}))});case"Iterate":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=ne(t,e.left,n),i=Co(e.left),o=[];for(let a of s)try{if(i!==null){let l={...n,currentPath:[...n.currentPath??[],...i]};o.push(...ne(a,e.right,l))}else o.push(...ne(a,e.right,n))}catch(l){throw l instanceof _l?l.withPrependedResults(o):l}return o}case"Comma":{let s=ne(t,e.left,n),i=ne(t,e.right,n);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[ne(t,e.elements,n)]:[[]];case"Object":{let s=[Object.create(null)];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:ne(t,i.key,n),a=ne(t,i.value,n),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}if(!kt(u)){for(let f of a)l.push(br(c));continue}for(let f of a){let h=br(c);qt(h,u,f),l.push(h)}}s.length=0,s.push(...l)}return s}case"Paren":return ne(t,e.expr,n);case"BinaryOp":return DV(t,e.op,e.left,e.right,n);case"UnaryOp":return ne(t,e.operand,n).map(i=>{if(e.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return e.op==="not"?!Ls(i):null});case"Cond":return ne(t,e.cond,n).flatMap(i=>{if(Ls(i))return ne(t,e.then,n);for(let o of e.elifs)if(ne(t,o.cond,n).some(Ls))return ne(t,o.then,n);return e.else?ne(t,e.else,n):[t]});case"Try":try{return ne(t,e.body,n)}catch(s){if(e.catch){let i=s instanceof md?s.value:s instanceof Error?s.message:String(s);return ne(i,e.catch,n)}return[]}case"Call":return NA(t,e.name,e.args,n);case"VarBind":return ne(t,e.value,n).flatMap(i=>{let o=null,a=[];e.pattern?a.push(e.pattern):e.name&&a.push({type:"var",name:e.name}),e.alternatives&&a.push(...e.alternatives);for(let l of a)if(o=mu(n,l,i),o!==null)break;return o===null?[]:ne(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[n.env?Cr(n.env):Object.create(null)];let s=n.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return ne(t,e.expr,n)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:ne(t,i,n).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[RV(t,e.path,e.op,e.value,n)];case"Reduce":{let s=ne(t,e.expr,n),i=ne(t,e.init,n)[0],o=n.limits.maxDepth??CA;for(let a of s){let l;if(e.pattern){if(l=mu(n,e.pattern,a),l===null)continue}else l=gd(n,e.varName,a);if(i=ne(i,e.update,l)[0],Tl(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=ne(t,e.expr,n),i=ne(t,e.init,n)[0],o=[];for(let a of s)try{let l;if(e.pattern){if(l=mu(n,e.pattern,a),l===null)continue}else l=gd(n,e.varName,a);if(i=ne(i,e.update,l)[0],e.extract){let c=ne(i,e.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof _l?l.withPrependedResults(o):l}return o}case"Label":try{return ne(t,e.body,{...n,labels:new Set([...n.labels??[],e.name])})}catch(s){if(s instanceof _l&&s.label===e.name)return s.partialResults;throw s}case"Break":throw new _l(e.name);case"Def":{let s=new Map(n.funcs??[]),i=`${e.name}/${e.params.length}`;s.set(i,{params:e.params,body:e.funcBody,closure:new Map(n.funcs??[])});let o={...n,funcs:s};return ne(t,e.body,o)}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function AA(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function RV(t,e,r,n,s){function i(l,c){switch(r){case"=":return c;case"|=":return ne(l,n,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?qg(l,c):c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(!kt(c.name))return l;if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let h=br(f),d=Object.hasOwn(h,c.name)?h[c.name]:void 0;return qt(h,c.name,u(d)),h}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f=br(l),h=Object.hasOwn(f,c.name)?f[c.name]:void 0;return qt(f,c.name,u(h)),f}return l}case"Index":{let h=ne(t,c.index,s)[0];if(typeof h=="number"&&Number.isNaN(h))throw new Error("Cannot set array element at NaN index");if(typeof h=="number"&&!Number.isInteger(h)&&(h=Math.trunc(h)),c.base)return o(l,c.base,d=>{if(typeof h=="number"&&Array.isArray(d)){let p=[...d],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(typeof h=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!kt(h))return d;let p=br(d),m=Object.hasOwn(p,h)?p[h]:void 0;return qt(p,h,u(m)),p}return d});if(typeof h=="number"){if(h>536870911)throw new Error("Array index too large");if(h<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let p=[...l],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(l==null){let p=[];for(;p.length<=h;)p.push(null);return p[h]=u(null),p}return l}if(typeof h=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!kt(h))return l;let d=br(l),p=Object.hasOwn(d,h)?d[h]:void 0;return qt(d,h,u(p)),d}return l}case"Iterate":{let f=h=>{if(Array.isArray(h))return h.map(d=>u(d));if(h&&typeof h=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(h))kt(p)&&qt(d,p,u(m));return d}return h};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,h=>h);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(r==="|=")return i(l,l);let c=ne(t,n,s);return i(l,c[0]??null)})}function PV(t,e,r){function n(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(!kt(o.name))return i;if(o.base){let l=ne(i,o.base,r)[0],c=n(l,{type:"Field",name:o.name},a);return n(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l=br(i);return qt(l,o.name,a),l}return i}case"Index":{if(o.base){let u=ne(i,o.base,r)[0],f=n(u,{type:"Index",index:o.index},a);return n(i,o.base,f)}let c=ne(t,o.index,r)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!kt(c))return i;let u=br(i);return qt(u,c,a),u}return i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(!kt(o.name))return i;if(o.base){let l=ne(i,o.base,r)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return n(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!kt(o.name))return i;let l=br(i);return delete l[o.name],l}return i}case"Index":{if(o.base){let u=ne(i,o.base,r)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return n(i,o.base,f)}let c=ne(t,o.index,r)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!kt(c))return i;let u=br(i);return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let u=function(d,p,m){switch(p.type){case"Identity":return m;case"Field":{if(!kt(p.name))return d;if(d&&typeof d=="object"&&!Array.isArray(d)){let g=br(d);return qt(g,p.name,m),g}return d}case"Index":{let y=ne(t,p.index,r)[0];if(typeof y=="number"&&Array.isArray(d)){let x=[...d],b=y<0?x.length+y:y;return b>=0&&b<x.length&&(x[b]=m),x}if(typeof y=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!kt(y))return d;let x=br(d);return qt(x,y,m),x}return d}case"Pipe":{let g=ne(d,p.left,r)[0],y=u(g,p.right,m);return u(d,p.left,y)}default:return d}};var a=u;let l=o.left,c=o.right,f=ne(i,l,r)[0];if(f==null)return i;let h=s(f,c);return u(i,l,h)}default:return i}}return s(t,e)}function DV(t,e,r,n,s){if(e==="and")return ne(t,r,s).flatMap(l=>Ls(l)?ne(t,n,s).map(u=>Ls(u)):[!1]);if(e==="or")return ne(t,r,s).flatMap(l=>Ls(l)?[!0]:ne(t,n,s).map(u=>Ls(u)));if(e==="//"){let l=ne(t,r,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:ne(t,n,s)}let i=ne(t,r,s),o=ne(t,n,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return a===null?l:l===null?a:typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?qg(a,l):null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":if(typeof a=="number"&&typeof l=="number")return a*l;if(typeof a=="string"&&typeof l=="number")return a.repeat(l);{let c=Kt(a),u=Kt(l);if(c&&u)return ky(c,u)}return null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return kl(a,l);case"!=":return!kl(a,l);case"<":return pu(a,l)<0;case"<=":return pu(a,l)<=0;case">":return pu(a,l)>0;case">=":return pu(a,l)>=0;default:return null}}))}function NA(t,e,r,n){let s=_V.get(e);if(s)return typeof t=="number"?[s(t)]:[null];let i=Oy(t,e,r,n,ne);if(i!==null)return i;let o=Ly(t,e,r,n,ne);if(o!==null)return o;let a=Ny(t,e,r,n,ne);if(a!==null)return a;let l=Ty(t,e,n.limits.maxDepth);if(l!==null)return l;let c=Fy(t,e);if(c!==null)return c;let u=Ry(t,e,r,n,ne);if(u!==null)return u;let f=Ay(t,e,r,n,ne,vA,cd,Ls,ud,fe);if(f!==null)return f;let h=Py(t,e,r,n,ne,Ls,hd,dd,PV,pd);if(h!==null)return h;let d=_y(t,e,r,n,ne,kl);if(d!==null)return d;let p=Cy(t,e,r,n,ne,vA,Ls,fe);if(p!==null)return p;let m=Iy(t,e,r,n,ne,Ls,IV,NA);if(m!==null)return m;let g=Dy(t,e,r,n,ne,kl);if(g!==null)return g;switch(e){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let y=r.length>0?ne(t,r[0],n)[0]:t;throw new md(y)}case"env":return[n.env?Cr(n.env):Object.create(null)];case"debug":return[t];case"input_line_number":return[1];default:{let y=`${e}/${r.length}`,x=n.funcs?.get(y);if(x){let b=x.closure??n.funcs??new Map,w=new Map(b);w.set(y,x);for(let _=0;_<x.params.length;_++){let P=x.params[_],F=r[_];if(F){let R=ne(t,F,n),$;if(R.length===0)$={type:"Call",name:"empty",args:[]};else if(R.length===1)$={type:"Literal",value:R[0]};else{$={type:"Literal",value:R[R.length-1]};for(let N=R.length-2;N>=0;N--)$={type:"Comma",left:{type:"Literal",value:R[N]},right:$}}w.set(`${P}/0`,{params:[],body:$})}}let S={...n,funcs:w};return ne(t,x.body,S)}throw new Error(`Unknown function: ${e}`)}}}function pd(t,e,r,n,s){if(e.type==="Comma"){let a=e;pd(t,a.left,r,n,s),pd(t,a.right,r,n,s);return}let i=Co(e);if(i!==null){s.push([...n,...i]);return}if(e.type==="Iterate"){if(Array.isArray(t))for(let a=0;a<t.length;a++)s.push([...n,a]);else if(t&&typeof t=="object")for(let a of Object.keys(t))s.push([...n,a]);return}if(e.type==="Recurse"){let a=(l,c)=>{if(s.push([...n,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(t,[]);return}if(e.type==="Pipe"){let a=Co(e.left);if(a!==null){let l=ne(t,e.left,r);for(let c of l)pd(c,e.right,r,[...n,...a],s);return}}ne(t,e,r).length>0&&s.push(n)}var _l,md,TV,CA,_V,kA=I(()=>{"use strict";Rs();rt();hs();EA();SA();Wn();fd();_l=class t extends Error{label;partialResults;constructor(e,r=[]){super(`break ${e}`),this.label=e,this.partialResults=r,this.name="BreakError"}withPrependedResults(e){return new t(this.label,[...e,...this.partialResults])}},md=class extends Error{value;constructor(e){super(typeof e=="string"?e:JSON.stringify(e)),this.value=e,this.name="JqError"}},TV=1e4,CA=2e3,_V=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function _A(t){let e=[],r=0,n=(c=0)=>t[r+c],s=()=>t[r++],i=()=>r>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=r,u=s();if(!(u===" "||u===" "||u===`
554
+ `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(n=>String(n??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let n=r??NV;return Tl(t,n+1)>n?[null]:[JSON.stringify(t)]}case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];default:return null}}var NV,hA=I(()=>{"use strict";fd();NV=2e3});function _y(t,e,r,n,s,i){switch(e){case"index":return r.length===0?[null]:s(t,r[0],n).map(a=>{if(typeof t=="string"&&typeof a=="string"){if(a===""&&t==="")return null;let l=t.indexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let c=0;c<=t.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(t[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=t.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return r.length===0?[null]:s(t,r[0],n).map(a=>{if(typeof t=="string"&&typeof a=="string"){let l=t.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(t)){if(Array.isArray(a)){for(let l=t.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(t[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=t.length-1;l>=0;l--)if(i(t[l],a))return l;return null}return null});case"indices":return r.length===0?[[]]:s(t,r[0],n).map(a=>{let l=[];if(typeof t=="string"&&typeof a=="string"){let c=t.indexOf(a);for(;c!==-1;)l.push(c),c=t.indexOf(a,c+1)}else if(Array.isArray(t))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=t.length;u++)l.push(u);else for(let u=0;u<=t.length-c;u++){let f=!0;for(let h=0;h<c;h++)if(!i(t[u+h],a[h])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<t.length;c++)i(t[c],a)&&l.push(c);return l});default:return null}}var dA=I(()=>{"use strict"});function Oy(t,e,r,n,s){switch(e){case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:typeof t=="string"?[t]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.hypot(t,i)]}case"fma":{if(typeof t!="number"||r.length<2)return[null];let i=s(t,r[0],n)[0],o=s(t,r[1],n)[0];return[t*i+o]}case"copysign":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.sign(i)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[t-Math.round(t/i)*i]}case"fdim":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.max(0,t-i)]}case"fmax":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.max(t,i)]}case"fmin":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[Math.min(t,i)]}case"ldexp":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[t*2**i]}case"scalbn":case"scalbln":{if(typeof t!="number"||r.length===0)return[null];let i=s(t,r[0],n)[0];return[t*2**i]}case"nearbyint":return typeof t=="number"?[Math.round(t)]:[null];case"logb":return typeof t=="number"?[Math.floor(Math.log2(Math.abs(t)))]:[null];case"significand":if(typeof t=="number"){let i=Math.floor(Math.log2(Math.abs(t)));return[t/2**i]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**i,i]]}return[null];case"modf":if(typeof t=="number"){let i=Math.trunc(t);return[[t-i,i]]}return[null];default:return null}}var pA=I(()=>{"use strict"});function Iy(t,e,r,n,s,i,o,a){switch(e){case"recurse":{if(r.length===0){let d=[],p=m=>{if(d.push(m),Array.isArray(m))for(let g of m)p(g);else if(m&&typeof m=="object")for(let g of Object.keys(m))p(m[g])};return p(t),d}let l=[],c=r.length>=2?r[1]:null,u=1e4,f=0,h=d=>{if(f++>u||c&&!s(d,c,n).some(i))return;l.push(d);let p=s(d,r[0],n);for(let m of p)m!=null&&h(m)};return h(t),l}case"recurse_down":return a(t,"recurse",r,n);case"walk":{if(r.length===0)return[t];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(u))kt(p)&&qt(d,p,c(m));f=d}else f=u;return s(f,r[0],n)[0]};return[c(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let l=Math.max(...t.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(t.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(r.length>0){let f=s(t,r[0],n)[0];if(!Array.isArray(t)||f<0)return[];if(f===0)return[[]];let h=[],d=(p,m)=>{if(m===f){h.push([...p]);return}for(let g of t)p.push(g),d(p,m+1),p.pop()};return d([],0),h}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let u of t)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===t.length){l.push([...f]);return}let h=t[u];for(let d of h)f.push(d),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let l=n.currentPath;if(l.length===0)return[];let c=r.length>0?s(t,r[0],n)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(n.root,u)]}else{let u=-c-1;if(u>=l.length)return[t];let f=l.slice(0,u);return[o(n.root,f)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let l=n.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(n.root,l.slice(0,u)));return[c]}case"root":return n.root!==void 0?[n.root]:[];default:return null}}var mA=I(()=>{"use strict";Wn()});function Ry(t,e,r,n,s){switch(e){case"keys":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((i,o)=>o)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:typeof t=="number"?[Math.abs(t)]:[null];case"utf8bytelength":{if(typeof t=="string")return[new TextEncoder().encode(t).length];let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":{let i=Kt(t);return i?[Object.entries(i).map(([o,a])=>({key:o,value:a}))]:[null]}case"from_entries":if(Array.isArray(t)){let i=Object.create(null);for(let o of t){let a=Kt(o);if(a){let l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;if(l!==void 0){let u=String(l);kt(u)&&qt(i,u,c)}}}return[i]}return[null];case"with_entries":{if(r.length===0)return[t];let i=Kt(t);if(i){let a=Object.entries(i).map(([c,u])=>({key:c,value:u})).flatMap(c=>s(c,r[0],n)),l=Object.create(null);for(let c of a){let u=Kt(c);if(u){let f=u.key??u.name??u.k,h=u.value??u.v;if(f!==void 0){let d=String(f);kt(d)&&qt(l,d,h)}}}return[l]}return[null]}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(t)?(r.length>0?s(t,r[0],n):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return t.flat(a)}):[null];case"unique":if(Array.isArray(t)){let i=new Set,o=[];for(let a of t){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=n.limits.maxDepth??kV;return Tl(t,i+1)>i?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let i=t.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[nn(JSON.parse(t))]}catch{throw new Error(`Invalid JSON: ${t}`)}}return[t]}case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let i=Number(t);if(Number.isNaN(i))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof t} cannot be parsed as a number`);case"toboolean":{if(typeof t=="boolean")return[t];if(typeof t=="string"){if(t==="true")return[!0];if(t==="false")return[!1];throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`)}let i=t===null?"null":Array.isArray(t)?"array":typeof t,o=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,Object.create(null)]);else for(let u of c)o(a[u],[...l,u])}};return o(t,[]),i.push([[]]),i}case"fromstream":{if(r.length===0)return[t];let i=s(t,r[0],n),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:Object.create(null));let u=o;for(let h=0;h<l.length-1;h++){let d=l[h],p=l[h+1];if(Array.isArray(u)&&typeof d=="number"){for(;u.length<=d;)u.push(null);u[d]===null&&(u[d]=typeof p=="number"?[]:Object.create(null)),u=u[d]}else{let m=Kt(u);if(m){let g=String(d);if(!kt(g))continue;(m[g]===null||m[g]===void 0)&&qt(m,g,typeof p=="number"?[]:Object.create(null)),u=m[g]}}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else{let h=Kt(u);if(h){let d=String(f);kt(d)&&qt(h,d,c)}}}return[o]}case"truncate_stream":{let i=typeof t=="number"?Math.floor(t):0;if(r.length===0)return[];let o=[],a=s(t,r[0],n);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var kV,gA=I(()=>{"use strict";Wn();fd();kV=2e3});function Py(t,e,r,n,s,i,o,a,l,c){switch(e){case"getpath":{if(r.length===0)return[null];let u=s(t,r[0],n),f=[];for(let h of u){let d=h,p=t;for(let m of d){if(p==null){p=null;break}if(Array.isArray(p)&&typeof m=="number")p=p[m];else if(typeof m=="string"){let g=Kt(p);if(!g||!Object.hasOwn(g,m)){p=null;break}p=g[m]}else{p=null;break}}f.push(p)}return f}case"setpath":{if(r.length<2)return[null];let f=s(t,r[0],n)[0],d=s(t,r[1],n)[0];return[o(t,f,d)]}case"delpaths":{if(r.length===0)return[t];let f=s(t,r[0],n)[0],h=t;for(let d of f.sort((p,m)=>m.length-p.length))h=a(h,d);return[h]}case"path":{if(r.length===0)return[[]];let u=[];return c(t,r[0],n,[],u),u}case"del":return r.length===0?[t]:[l(t,r[0],n)];case"pick":{if(r.length===0)return[null];let u=[];for(let h of r)c(t,h,n,[],u);let f=null;for(let h of u){for(let p of h)if(typeof p=="number"&&p<0)throw new Error("Out of bounds negative array index");let d=t;for(let p of h){if(d==null)break;if(Array.isArray(d)&&typeof p=="number")d=d[p];else if(typeof p=="string"){let m=Kt(d);if(!m||!Object.hasOwn(m,p)){d=null;break}d=m[p]}else{d=null;break}}f=o(f,h,d)}return[f]}case"paths":{let u=[],f=(h,d)=>{if(h&&typeof h=="object")if(Array.isArray(h))for(let p=0;p<h.length;p++)u.push([...d,p]),f(h[p],[...d,p]);else for(let p of Object.keys(h))u.push([...d,p]),f(h[p],[...d,p])};return f(t,[]),r.length>0?u.filter(h=>{let d=t;for(let m of h)if(Array.isArray(d)&&typeof m=="number")d=d[m];else if(typeof m=="string"){let g=Kt(d);if(!g||!Object.hasOwn(g,m))return!1;d=g[m]}else return!1;return s(d,r[0],n).some(i)}):u}case"leaf_paths":{let u=[],f=(h,d)=>{if(h===null||typeof h!="object")u.push(d);else if(Array.isArray(h))for(let p=0;p<h.length;p++)f(h[p],[...d,p]);else for(let p of Object.keys(h))f(h[p],[...d,p])};return f(t,[]),u}default:return null}}var yA=I(()=>{"use strict";Wn()});function Dy(t,e,r,n,s,i){switch(e){case"IN":{if(r.length===0)return[!1];if(r.length===1){let c=s(t,r[0],n);for(let u of c)if(i(t,u))return[!0];return[!1]}let o=s(t,r[0],n),a=s(t,r[1],n),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(r.length===0)return[Object.create(null)];if(r.length===1){let l=s(t,r[0],n),c=Object.create(null);for(let u of l){let f=String(u);kt(f)&&qt(c,f,u)}return[c]}if(r.length===2){let l=s(t,r[0],n),c=Object.create(null);for(let u of l){let f=s(u,r[1],n);if(f.length>0){let h=String(f[0]);kt(h)&&qt(c,h,u)}}return[c]}let o=s(t,r[0],n),a=Object.create(null);for(let l of o){let c=s(l,r[1],n),u=s(l,r[2],n);if(c.length>0&&u.length>0){let f=String(c[0]);kt(f)&&qt(a,f,u[0])}}return[a]}case"JOIN":{if(r.length<2)return[null];let o=Kt(s(t,r[0],n)[0]);if(!o)return[null];if(!Array.isArray(t))return[null];let a=[];for(let l of t){let c=s(l,r[1],n),u=c.length>0?String(c[0]):"",f=Ci(o,u)?o[u]:null;a.push([l,f])}return[a]}default:return null}}var xA=I(()=>{"use strict";Wn()});function Ly(t,e,r,n,s){switch(e){case"join":{if(!Array.isArray(t))return[null];let i=r.length>0?s(t,r[0],n):[""];for(let o of t)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>t.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof t!="string"||r.length===0)return[null];let i=s(t,r[0],n),o=String(i[0]);return[t.split(o)]}case"splits":{if(typeof t!="string"||r.length===0)return[];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"g";return ae(o,a.includes("g")?a:`${a}g`).split(t)}catch{return[]}}case"scan":{if(typeof t!="string"||r.length===0)return[];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"";return[...ae(o,a.includes("g")?a:`${a}g`).matchAll(t)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof t!="string"||r.length===0)return[!1];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"";return[ae(o,a).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||r.length===0)return[null];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"",c=ae(o,`${a}d`).exec(t);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,h)=>({offset:u?.[h+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||r.length===0)return[null];let i=s(t,r[0],n),o=String(i[0]);try{let a=r.length>1?String(s(t,r[1],n)[0]):"",c=ae(o,a).match(t);return!c||!c.groups?[Object.create(null)]:[c.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=String(i[0]),l=String(o[0]);try{let c=r.length>2?String(s(t,r[2],n)[0]):"";return[ae(a,c).replace(t,l)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||r.length<2)return[null];let i=s(t,r[0],n),o=s(t,r[1],n),a=String(i[0]),l=String(o[0]);try{let c=r.length>2?String(s(t,r[2],n)[0]):"g",u=c.includes("g")?c:`${c}g`;return[ae(a,u).replace(t,l)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||r.length===0)return[t];let i=s(t,r[0],n),o=String(i[0]);return[t.startsWith(o)?t.slice(o.length):t]}case"rtrimstr":{if(typeof t!="string"||r.length===0)return[t];let i=s(t,r[0],n),o=String(i[0]);return o===""?[t]:[t.endsWith(o)?t.slice(0,-o.length):t]}case"trimstr":{if(typeof t!="string"||r.length===0)return[t];let i=s(t,r[0],n),o=String(i[0]);if(o==="")return[t];let a=t;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof t=="string")return[t.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof t=="string")return[t.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof t=="string")return[t.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof t!="string"||r.length===0)return[!1];let i=s(t,r[0],n);return[t.startsWith(String(i[0]))]}case"endswith":{if(typeof t!="string"||r.length===0)return[!1];let i=s(t,r[0],n);return[t.endsWith(String(i[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var bA=I(()=>{"use strict";Gt()});function Fy(t,e){switch(e){case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"values":return t===null?[]:[t];case"not":return t===!1||t===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var wA=I(()=>{"use strict"});var EA=I(()=>{"use strict";cA();uA();fA();hA();dA();pA();mA();gA();yA();xA();bA();wA()});function hd(t,e,r){if(e.length===0)return r;let[n,...s]=e;if(typeof n=="number"){if(t&&typeof t=="object"&&!Array.isArray(t))throw new Error("Cannot index object with number");if(n>536870911)throw new Error("Array index too large");if(n<0)throw new Error("Out of bounds negative array index");let c=Array.isArray(t)?[...t]:[];for(;c.length<=n;)c.push(null);return c[n]=hd(c[n],s,r),c}if(Array.isArray(t))throw new Error("Cannot index array with string");if(!kt(n))return t??Object.create(null);let i=Kt(t),o=i?br(i):Object.create(null),a=Object.hasOwn(o,n)?o[n]:void 0;return qt(o,n,hd(a,s,r)),o}function dd(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i=String(s);if(!kt(i))return t;let o=br(t);return delete o[i],o}return t}let[r,...n]=e;if(Array.isArray(t)&&typeof r=="number"){let s=[...t];return s[r]=dd(s[r],n),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s=String(r);if(!kt(s))return t;let i=br(t);return Object.hasOwn(i,s)&&qt(i,s,dd(i[s],n)),i}return t}var SA=I(()=>{"use strict";Wn()});function OV(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??TV,maxDepth:t?.limits?.maxDepth??CA},env:t?.env,coverage:t?.coverage,requireDefenseContext:t?.requireDefenseContext,defenseContextChecked:!1}}function gd(t,e,r){let n=new Map(t.vars);return n.set(e,r),{vars:n,limits:t.limits,env:t.env,requireDefenseContext:t.requireDefenseContext,defenseContextChecked:t.defenseContextChecked,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels,coverage:t.coverage}}function mu(t,e,r){switch(e.type){case"var":return gd(t,e.name,r);case"array":{if(!Array.isArray(r))return null;let n=t;for(let s=0;s<e.elements.length;s++){let i=e.elements[s],o=s<r.length?r[s]:null,a=mu(n,i,o);if(a===null)return null;n=a}return n}case"object":{let n=Kt(r);if(!n)return null;let s=t;for(let i of e.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=ne(r,i.key,t);if(c.length===0)return null;o=String(c[0])}let a=Ci(n,o)?n[o]:null;i.keyVar&&(s=gd(s,i.keyVar,a));let l=mu(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function IV(t,e){let r=t;for(let n of e)if(r&&typeof r=="object")if(Array.isArray(r))if(typeof n=="number")r=r[n];else return;else{let s=Kt(r);if(s&&typeof n=="string"&&Object.hasOwn(s,n))r=s[n];else return}else return;return r}function Co(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?Co(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?Co(t.base):[];if(e===null)return null;let r=t.index.value;return typeof r=="number"||typeof r=="string"?[...e,r]:null}if(t.type==="Pipe"){let e=Co(t.left);return e===null?null:My(e,t.right)}if(t.type==="Call"){if(t.name==="parent"||t.name==="root")return null;if(t.name==="first"&&t.args.length===0)return[0];if(t.name==="last"&&t.args.length===0)return[-1]}return null}function My(t,e){if(e.type==="Call"){if(e.name==="parent"){let r=1;if(e.args.length>0&&e.args[0].type==="Literal"){let n=e.args[0].value;typeof n=="number"&&(r=n)}if(r>=0)return t.slice(0,Math.max(0,t.length-r));{let n=-r-1;return t.slice(0,Math.min(n,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let r=Co(e);if(r!==null)return[...t,...r]}if(e.type==="Index"&&e.index.type==="Literal"){let r=Co(e);if(r!==null)return[...t,...r]}if(e.type==="Pipe"){let r=My(t,e.left);return r===null?null:My(r,e.right)}return e.type==="Identity"?t:null}function vA(t,e,r){if(e.type==="Comma"){let n=[];try{n.push(...ne(t,e.left,r))}catch(s){if(s instanceof he)throw s;if(n.length>0)return n;throw new Error("evaluation failed")}try{n.push(...ne(t,e.right,r))}catch(s){if(s instanceof he)throw s;return n}return n}return ne(t,e,r)}function ne(t,e,r){let n=r&&"vars"in r?r:OV(r);switch(n.defenseContextChecked||(rr(n.requireDefenseContext,"query-engine","evaluation"),n={...n,defenseContextChecked:!0}),n.root===void 0&&(n={...n,root:t,currentPath:[]}),n.coverage?.hit(`jq:node:${e.type}`),e.type){case"Identity":return[t];case"Field":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>{let o=Kt(i);if(o){if(!Object.hasOwn(o,e.name))return[null];let l=o[e.name];return[l===void 0?null:l]}if(i===null)return[null];let a=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${a} with string "${e.name}"`)});case"Index":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>ne(i,e.index,n).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof a=="string"){let l=Kt(i);return!l||!Object.hasOwn(l,a)?[null]:[l[a]]}return[null]}));case"Slice":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=e.start?ne(t,e.start,n):[0],l=e.end?ne(t,e.end,n):[o];return a.flatMap(c=>l.map(u=>{let f=c,h=u,d=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),p=Number.isNaN(h)?o:Number.isInteger(h)?h:Math.ceil(h),m=AA(d,o),g=AA(p,o);return Array.isArray(i),i.slice(m,g)}))});case"Iterate":return(e.base?ne(t,e.base,n):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=ne(t,e.left,n),i=Co(e.left),o=[];for(let a of s)try{if(i!==null){let l={...n,currentPath:[...n.currentPath??[],...i]};o.push(...ne(a,e.right,l))}else o.push(...ne(a,e.right,n))}catch(l){throw l instanceof _l?l.withPrependedResults(o):l}return o}case"Comma":{let s=ne(t,e.left,n),i=ne(t,e.right,n);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[ne(t,e.elements,n)]:[[]];case"Object":{let s=[Object.create(null)];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:ne(t,i.key,n),a=ne(t,i.value,n),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}if(!kt(u)){for(let f of a)l.push(br(c));continue}for(let f of a){let h=br(c);qt(h,u,f),l.push(h)}}s.length=0,s.push(...l)}return s}case"Paren":return ne(t,e.expr,n);case"BinaryOp":return DV(t,e.op,e.left,e.right,n);case"UnaryOp":return ne(t,e.operand,n).map(i=>{if(e.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return e.op==="not"?!Ls(i):null});case"Cond":return ne(t,e.cond,n).flatMap(i=>{if(Ls(i))return ne(t,e.then,n);for(let o of e.elifs)if(ne(t,o.cond,n).some(Ls))return ne(t,o.then,n);return e.else?ne(t,e.else,n):[t]});case"Try":try{return ne(t,e.body,n)}catch(s){if(e.catch){let i=s instanceof md?s.value:s instanceof Error?s.message:String(s);return ne(i,e.catch,n)}return[]}case"Call":return NA(t,e.name,e.args,n);case"VarBind":return ne(t,e.value,n).flatMap(i=>{let o=null,a=[];e.pattern?a.push(e.pattern):e.name&&a.push({type:"var",name:e.name}),e.alternatives&&a.push(...e.alternatives);for(let l of a)if(o=mu(n,l,i),o!==null)break;return o===null?[]:ne(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[n.env?Cr(n.env):Object.create(null)];let s=n.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return ne(t,e.expr,n)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:ne(t,i,n).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[RV(t,e.path,e.op,e.value,n)];case"Reduce":{let s=ne(t,e.expr,n),i=ne(t,e.init,n)[0],o=n.limits.maxDepth??CA;for(let a of s){let l;if(e.pattern){if(l=mu(n,e.pattern,a),l===null)continue}else l=gd(n,e.varName,a);if(i=ne(i,e.update,l)[0],Tl(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=ne(t,e.expr,n),i=ne(t,e.init,n)[0],o=[];for(let a of s)try{let l;if(e.pattern){if(l=mu(n,e.pattern,a),l===null)continue}else l=gd(n,e.varName,a);if(i=ne(i,e.update,l)[0],e.extract){let c=ne(i,e.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof _l?l.withPrependedResults(o):l}return o}case"Label":try{return ne(t,e.body,{...n,labels:new Set([...n.labels??[],e.name])})}catch(s){if(s instanceof _l&&s.label===e.name)return s.partialResults;throw s}case"Break":throw new _l(e.name);case"Def":{let s=new Map(n.funcs??[]),i=`${e.name}/${e.params.length}`;s.set(i,{params:e.params,body:e.funcBody,closure:new Map(n.funcs??[])});let o={...n,funcs:s};return ne(t,e.body,o)}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function AA(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function RV(t,e,r,n,s){function i(l,c){switch(r){case"=":return c;case"|=":return ne(l,n,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?qg(l,c):c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(!kt(c.name))return l;if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let h=br(f),d=Object.hasOwn(h,c.name)?h[c.name]:void 0;return qt(h,c.name,u(d)),h}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f=br(l),h=Object.hasOwn(f,c.name)?f[c.name]:void 0;return qt(f,c.name,u(h)),f}return l}case"Index":{let h=ne(t,c.index,s)[0];if(typeof h=="number"&&Number.isNaN(h))throw new Error("Cannot set array element at NaN index");if(typeof h=="number"&&!Number.isInteger(h)&&(h=Math.trunc(h)),c.base)return o(l,c.base,d=>{if(typeof h=="number"&&Array.isArray(d)){let p=[...d],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(typeof h=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!kt(h))return d;let p=br(d),m=Object.hasOwn(p,h)?p[h]:void 0;return qt(p,h,u(m)),p}return d});if(typeof h=="number"){if(h>536870911)throw new Error("Array index too large");if(h<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let p=[...l],m=h<0?p.length+h:h;if(m>=0){for(;p.length<=m;)p.push(null);p[m]=u(p[m])}return p}if(l==null){let p=[];for(;p.length<=h;)p.push(null);return p[h]=u(null),p}return l}if(typeof h=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!kt(h))return l;let d=br(l),p=Object.hasOwn(d,h)?d[h]:void 0;return qt(d,h,u(p)),d}return l}case"Iterate":{let f=h=>{if(Array.isArray(h))return h.map(d=>u(d));if(h&&typeof h=="object"){let d=Object.create(null);for(let[p,m]of Object.entries(h))kt(p)&&qt(d,p,u(m));return d}return h};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,h=>h);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(r==="|=")return i(l,l);let c=ne(t,n,s);return i(l,c[0]??null)})}function PV(t,e,r){function n(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(!kt(o.name))return i;if(o.base){let l=ne(i,o.base,r)[0],c=n(l,{type:"Field",name:o.name},a);return n(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l=br(i);return qt(l,o.name,a),l}return i}case"Index":{if(o.base){let u=ne(i,o.base,r)[0],f=n(u,{type:"Index",index:o.index},a);return n(i,o.base,f)}let c=ne(t,o.index,r)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!kt(c))return i;let u=br(i);return qt(u,c,a),u}return i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(!kt(o.name))return i;if(o.base){let l=ne(i,o.base,r)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return n(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!kt(o.name))return i;let l=br(i);return delete l[o.name],l}return i}case"Index":{if(o.base){let u=ne(i,o.base,r)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return n(i,o.base,f)}let c=ne(t,o.index,r)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!kt(c))return i;let u=br(i);return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let u=function(d,p,m){switch(p.type){case"Identity":return m;case"Field":{if(!kt(p.name))return d;if(d&&typeof d=="object"&&!Array.isArray(d)){let g=br(d);return qt(g,p.name,m),g}return d}case"Index":{let y=ne(t,p.index,r)[0];if(typeof y=="number"&&Array.isArray(d)){let x=[...d],b=y<0?x.length+y:y;return b>=0&&b<x.length&&(x[b]=m),x}if(typeof y=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){if(!kt(y))return d;let x=br(d);return qt(x,y,m),x}return d}case"Pipe":{let g=ne(d,p.left,r)[0],y=u(g,p.right,m);return u(d,p.left,y)}default:return d}};var a=u;let l=o.left,c=o.right,f=ne(i,l,r)[0];if(f==null)return i;let h=s(f,c);return u(i,l,h)}default:return i}}return s(t,e)}function DV(t,e,r,n,s){if(e==="and")return ne(t,r,s).flatMap(l=>Ls(l)?ne(t,n,s).map(u=>Ls(u)):[!1]);if(e==="or")return ne(t,r,s).flatMap(l=>Ls(l)?[!0]:ne(t,n,s).map(u=>Ls(u)));if(e==="//"){let l=ne(t,r,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:ne(t,n,s)}let i=ne(t,r,s),o=ne(t,n,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return a===null?l:l===null?a:typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?qg(a,l):null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":if(typeof a=="number"&&typeof l=="number")return a*l;if(typeof a=="string"&&typeof l=="number")return a.repeat(l);{let c=Kt(a),u=Kt(l);if(c&&u)return ky(c,u)}return null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return kl(a,l);case"!=":return!kl(a,l);case"<":return pu(a,l)<0;case"<=":return pu(a,l)<=0;case">":return pu(a,l)>0;case">=":return pu(a,l)>=0;default:return null}}))}function NA(t,e,r,n){let s=_V.get(e);if(s)return typeof t=="number"?[s(t)]:[null];let i=Oy(t,e,r,n,ne);if(i!==null)return i;let o=Ly(t,e,r,n,ne);if(o!==null)return o;let a=Ny(t,e,r,n,ne);if(a!==null)return a;let l=Ty(t,e,n.limits.maxDepth);if(l!==null)return l;let c=Fy(t,e);if(c!==null)return c;let u=Ry(t,e,r,n,ne);if(u!==null)return u;let f=Ay(t,e,r,n,ne,vA,cd,Ls,ud,he);if(f!==null)return f;let h=Py(t,e,r,n,ne,Ls,hd,dd,PV,pd);if(h!==null)return h;let d=_y(t,e,r,n,ne,kl);if(d!==null)return d;let p=Cy(t,e,r,n,ne,vA,Ls,he);if(p!==null)return p;let m=Iy(t,e,r,n,ne,Ls,IV,NA);if(m!==null)return m;let g=Dy(t,e,r,n,ne,kl);if(g!==null)return g;switch(e){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let y=r.length>0?ne(t,r[0],n)[0]:t;throw new md(y)}case"env":return[n.env?Cr(n.env):Object.create(null)];case"debug":return[t];case"input_line_number":return[1];default:{let y=`${e}/${r.length}`,x=n.funcs?.get(y);if(x){let b=x.closure??n.funcs??new Map,w=new Map(b);w.set(y,x);for(let _=0;_<x.params.length;_++){let P=x.params[_],F=r[_];if(F){let R=ne(t,F,n),$;if(R.length===0)$={type:"Call",name:"empty",args:[]};else if(R.length===1)$={type:"Literal",value:R[0]};else{$={type:"Literal",value:R[R.length-1]};for(let N=R.length-2;N>=0;N--)$={type:"Comma",left:{type:"Literal",value:R[N]},right:$}}w.set(`${P}/0`,{params:[],body:$})}}let S={...n,funcs:w};return ne(t,x.body,S)}throw new Error(`Unknown function: ${e}`)}}}function pd(t,e,r,n,s){if(e.type==="Comma"){let a=e;pd(t,a.left,r,n,s),pd(t,a.right,r,n,s);return}let i=Co(e);if(i!==null){s.push([...n,...i]);return}if(e.type==="Iterate"){if(Array.isArray(t))for(let a=0;a<t.length;a++)s.push([...n,a]);else if(t&&typeof t=="object")for(let a of Object.keys(t))s.push([...n,a]);return}if(e.type==="Recurse"){let a=(l,c)=>{if(s.push([...n,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(t,[]);return}if(e.type==="Pipe"){let a=Co(e.left);if(a!==null){let l=ne(t,e.left,r);for(let c of l)pd(c,e.right,r,[...n,...a],s);return}}ne(t,e,r).length>0&&s.push(n)}var _l,md,TV,CA,_V,kA=I(()=>{"use strict";Rs();rt();hs();EA();SA();Wn();fd();_l=class t extends Error{label;partialResults;constructor(e,r=[]){super(`break ${e}`),this.label=e,this.partialResults=r,this.name="BreakError"}withPrependedResults(e){return new t(this.label,[...e,...this.partialResults])}},md=class extends Error{value;constructor(e){super(typeof e=="string"?e:JSON.stringify(e)),this.value=e,this.name="JqError"}},TV=1e4,CA=2e3,_V=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function _A(t){let e=[],r=0,n=(c=0)=>t[r+c],s=()=>t[r++],i=()=>r>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=r,u=s();if(!(u===" "||u===" "||u===`
555
555
  `||u==="\r")){if(u==="#"){for(;!i()&&n()!==`
556
556
  `;)s();continue}if(u==="."&&n()==="."){s(),e.push({type:"DOTDOT",pos:c});continue}if(u==="="&&n()==="="){s(),e.push({type:"EQ",pos:c});continue}if(u==="!"&&n()==="="){s(),e.push({type:"NE",pos:c});continue}if(u==="<"&&n()==="="){s(),e.push({type:"LE",pos:c});continue}if(u===">"&&n()==="="){s(),e.push({type:"GE",pos:c});continue}if(u==="/"&&n()==="/"){s(),n()==="="?(s(),e.push({type:"UPDATE_ALT",pos:c})):e.push({type:"ALT",pos:c});continue}if(u==="+"&&n()==="="){s(),e.push({type:"UPDATE_ADD",pos:c});continue}if(u==="-"&&n()==="="){s(),e.push({type:"UPDATE_SUB",pos:c});continue}if(u==="*"&&n()==="="){s(),e.push({type:"UPDATE_MUL",pos:c});continue}if(u==="/"&&n()==="="){s(),e.push({type:"UPDATE_DIV",pos:c});continue}if(u==="%"&&n()==="="){s(),e.push({type:"UPDATE_MOD",pos:c});continue}if(u==="="&&n()!=="="){e.push({type:"ASSIGN",pos:c});continue}if(u==="."){e.push({type:"DOT",pos:c});continue}if(u==="|"){n()==="="?(s(),e.push({type:"UPDATE_PIPE",pos:c})):e.push({type:"PIPE",pos:c});continue}if(u===","){e.push({type:"COMMA",pos:c});continue}if(u===":"){e.push({type:"COLON",pos:c});continue}if(u===";"){e.push({type:"SEMICOLON",pos:c});continue}if(u==="("){e.push({type:"LPAREN",pos:c});continue}if(u===")"){e.push({type:"RPAREN",pos:c});continue}if(u==="["){e.push({type:"LBRACKET",pos:c});continue}if(u==="]"){e.push({type:"RBRACKET",pos:c});continue}if(u==="{"){e.push({type:"LBRACE",pos:c});continue}if(u==="}"){e.push({type:"RBRACE",pos:c});continue}if(u==="?"){e.push({type:"QUESTION",pos:c});continue}if(u==="+"){e.push({type:"PLUS",pos:c});continue}if(u==="-"){e.push({type:"MINUS",pos:c});continue}if(u==="*"){e.push({type:"STAR",pos:c});continue}if(u==="/"){e.push({type:"SLASH",pos:c});continue}if(u==="%"){e.push({type:"PERCENT",pos:c});continue}if(u==="<"){e.push({type:"LT",pos:c});continue}if(u===">"){e.push({type:"GT",pos:c});continue}if(o(u)){let f=u;for(;!i()&&(o(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(t[r+1]==="+"||t[r+1]==="-")&&(f+=s()),f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}if(u==='"'){let f="";for(;!i()&&n()!=='"';)if(n()==="\\"){if(s(),i())break;let h=s();switch(h){case"n":f+=`
557
557
  `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=h}}else f+=s();i()||s(),e.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(n());)f+=s();let h=TA.get(f);h?e.push({type:h,value:f,pos:c}):e.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return e.push({type:"EOF",pos:r}),e}function xd(t){let e=_A(t);return new $y(e).parse()}var TA,yd,$y,OA=I(()=>{"use strict";TA=new Map([["and","AND"],["or","OR"],["not","NOT"],["if","IF"],["then","THEN"],["elif","ELIF"],["else","ELSE"],["end","END"],["as","AS"],["try","TRY"],["catch","CATCH"],["true","TRUE"],["false","FALSE"],["null","NULL"],["reduce","REDUCE"],["foreach","FOREACH"],["label","LABEL"],["break","BREAK"],["def","DEF"]]),yd=new Set(TA.values());$y=class t{tokens;pos=0;constructor(e){this.tokens=e}peek(e=0){return this.tokens[this.pos+e]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let r of e)if(this.check(r))return this.advance();return null}expect(e,r){if(!this.check(e))throw new Error(`${r} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}isFieldNameAfterDot(e=0){let r=this.peek(e),n=this.peek(e+1);return n.type==="STRING"?!0:n.type==="IDENT"||yd.has(n.type)?n.pos===r.pos+1:!1}isIdentLike(){let e=this.peek().type;return e==="IDENT"||yd.has(e)}consumeFieldNameAfterDot(e){let r=this.peek();return r.type==="STRING"?this.advance().value:(r.type==="IDENT"||yd.has(r.type))&&r.pos===e.pos+1?this.advance().value:null}parse(){let e=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){return this.parsePipe()}parsePattern(){if(this.match("LBRACKET")){let n=[];if(!this.check("RBRACKET"))for(n.push(this.parsePattern());this.match("COMMA")&&!this.check("RBRACKET");)n.push(this.parsePattern());return this.expect("RBRACKET","Expected ']' after array pattern"),{type:"array",elements:n}}if(this.match("LBRACE")){let n=[];if(!this.check("RBRACE"))for(n.push(this.parsePatternField());this.match("COMMA")&&!this.check("RBRACE");)n.push(this.parsePatternField());return this.expect("RBRACE","Expected '}' after object pattern"),{type:"object",fields:n}}let e=this.expect("IDENT","Expected variable name in pattern"),r=e.value;if(!r.startsWith("$"))throw new Error(`Variable name must start with $ at position ${e.pos}`);return{type:"var",name:r}}parsePatternField(){if(this.match("LPAREN")){let r=this.parseExpr();this.expect("RPAREN","Expected ')' after computed key"),this.expect("COLON","Expected ':' after computed key");let n=this.parsePattern();return{key:r,pattern:n}}let e=this.peek();if(e.type==="IDENT"||yd.has(e.type)){let r=e.value;if(r.startsWith("$")){if(this.advance(),this.match("COLON")){let n=this.parsePattern();return{key:r.slice(1),pattern:n,keyVar:r}}return{key:r.slice(1),pattern:{type:"var",name:r}}}if(this.advance(),this.match("COLON")){let n=this.parsePattern();return{key:r,pattern:n}}return{key:r,pattern:{type:"var",name:`$${r}`}}}throw new Error(`Expected field name in object pattern at position ${e.pos}`)}parsePipe(){let e=this.parseComma();for(;this.match("PIPE");){let r=this.parseComma();e={type:"Pipe",left:e,right:r}}return e}parseComma(){let e=this.parseVarBind();for(;this.match("COMMA");){let r=this.parseVarBind();e={type:"Comma",left:e,right:r}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match("AS")){let r=this.parsePattern(),n=[];for(;this.check("QUESTION")&&this.peekAhead(1)?.type==="ALT";)this.advance(),this.advance(),n.push(this.parsePattern());this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return r.type==="var"&&n.length===0?{type:"VarBind",name:r.name,value:e,body:s}:{type:"VarBind",name:r.type==="var"?r.name:"",value:e,body:s,pattern:r.type!=="var"?r:void 0,alternatives:n.length>0?n:void 0}}return e}peekAhead(e){let r=this.pos+e;return r<this.tokens.length?this.tokens[r]:void 0}parseUpdate(){let e=this.parseAlt(),r=new Map([["ASSIGN","="],["UPDATE_ADD","+="],["UPDATE_SUB","-="],["UPDATE_MUL","*="],["UPDATE_DIV","/="],["UPDATE_MOD","%="],["UPDATE_ALT","//="],["UPDATE_PIPE","|="]]),n=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(n){let s=this.parseVarBind(),i=r.get(n.type);if(i)return{type:"UpdateOp",op:i,path:e,value:s}}return e}parseAlt(){let e=this.parseOr();for(;this.match("ALT");){let r=this.parseOr();e={type:"BinaryOp",op:"//",left:e,right:r}}return e}parseOr(){let e=this.parseAnd();for(;this.match("OR");){let r=this.parseAnd();e={type:"BinaryOp",op:"or",left:e,right:r}}return e}parseAnd(){let e=this.parseNot();for(;this.match("AND");){let r=this.parseNot();e={type:"BinaryOp",op:"and",left:e,right:r}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),r=new Map([["EQ","=="],["NE","!="],["LT","<"],["LE","<="],["GT",">"],["GE",">="]]),n=this.match("EQ","NE","LT","LE","GT","GE");if(n){let s=r.get(n.type);if(s){let i=this.parseAddSub();e={type:"BinaryOp",op:s,left:e,right:i}}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match("PLUS")){let r=this.parseMulDiv();e={type:"BinaryOp",op:"+",left:e,right:r}}else if(this.match("MINUS")){let r=this.parseMulDiv();e={type:"BinaryOp",op:"-",left:e,right:r}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match("STAR")){let r=this.parseUnary();e={type:"BinaryOp",op:"*",left:e,right:r}}else if(this.match("SLASH")){let r=this.parseUnary();e={type:"BinaryOp",op:"/",left:e,right:r}}else if(this.match("PERCENT")){let r=this.parseUnary();e={type:"BinaryOp",op:"%",left:e,right:r}}else break;return e}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("QUESTION"))e={type:"Optional",expr:e};else if(this.check("DOT")&&this.isFieldNameAfterDot())this.advance(),e={type:"Field",name:this.advance().value,base:e};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))e={type:"Iterate",base:e};else if(this.check("COLON")){this.advance();let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",end:r,base:e}}else{let r=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",start:r,end:n,base:e}}else this.expect("RBRACKET","Expected ']'"),e={type:"Index",index:r,base:e}}else break;return e}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.check("DOT")){let e=this.advance();if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:s}}let n=this.parseExpr();if(this.match("COLON")){let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:n,end:s}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:n}}let r=this.consumeFieldNameAfterDot(e);return r!==null?{type:"Field",name:r}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let r=this.advance().value;return r.includes("\\(")?this.parseStringInterpolation(r):{type:"Literal",value:r}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let e=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:e}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let e=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:e}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let e=this.parsePostfix(),r;return this.match("CATCH")&&(r=this.parsePostfix()),{type:"Try",body:e,catch:r}}if(this.match("REDUCE")){let e=this.parseAddSub();this.expect("AS","Expected 'as' after reduce expression");let r=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr();this.expect("RPAREN","Expected ')' after update expression");let i=r.type==="var"?r.name:"";return{type:"Reduce",expr:e,varName:i,init:n,update:s,pattern:r.type!=="var"?r:void 0}}if(this.match("FOREACH")){let e=this.parseAddSub();this.expect("AS","Expected 'as' after foreach expression");let r=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr(),i;this.match("SEMICOLON")&&(i=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions");let o=r.type==="var"?r.name:"";return{type:"Foreach",expr:e,varName:o,init:n,update:s,extract:i,pattern:r.type!=="var"?r:void 0}}if(this.match("LABEL")){let e=this.expect("IDENT","Expected label name (e.g., $out)"),r=e.value;if(!r.startsWith("$"))throw new Error(`Label name must start with $ at position ${e.pos}`);this.expect("PIPE","Expected '|' after label name");let n=this.parseExpr();return{type:"Label",name:r,body:n}}if(this.match("BREAK")){let e=this.expect("IDENT","Expected label name to break to"),r=e.value;if(!r.startsWith("$"))throw new Error(`Break label must start with $ at position ${e.pos}`);return{type:"Break",name:r}}if(this.match("DEF")){let r=this.expect("IDENT","Expected function name after def").value,n=[];if(this.match("LPAREN")){if(!this.check("RPAREN")){let o=this.expect("IDENT","Expected parameter name");for(n.push(o.value);this.match("SEMICOLON");){let a=this.expect("IDENT","Expected parameter name");n.push(a.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after function body");let i=this.parseExpr();return{type:"Def",name:r,params:n,funcBody:s,body:i}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let r=this.advance().value;if(r.startsWith("$"))return{type:"VarRef",name:r};if(this.match("LPAREN")){let n=[];if(!this.check("RPAREN"))for(n.push(this.parseExpr());this.match("SEMICOLON");)n.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:r,args:n}}return{type:"Call",name:r,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let e=[];if(!this.check("RBRACE"))do{let r,n;if(this.match("LPAREN"))r=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else if(this.isIdentLike()){let s=this.advance().value;this.match("COLON")?(r=s,n=this.parseObjectValue()):(r=s,n={type:"Field",name:s})}else if(this.check("STRING"))r=this.advance().value,this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);e.push({key:r,value:n})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match("PIPE");){let r=this.parseVarBind();e={type:"Pipe",left:e,right:r}}return e}parseIf(){let e=this.parseExpr();this.expect("THEN","Expected 'then'");let r=this.parseExpr(),n=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();n.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:e,then:r,elifs:n,else:s}}parseStringInterpolation(e){let r=[],n="",s=0;for(;s<e.length;)if(e[s]==="\\"&&e[s+1]==="("){n&&(r.push(n),n=""),s+=2;let i=1,o="";for(;s<e.length&&i>0;)e[s]==="("?i++:e[s]===")"&&i--,i>0&&(o+=e[s]),s++;let a=_A(o),l=new t(a);r.push(l.parse())}else n+=e[s],s++;return n&&r.push(n),{type:"StringInterp",parts:r}}}});var Ea=I(()=>{"use strict";kA();OA()});var RA={};ue(RA,{flagsForFuzzing:()=>Uy,jqCommand:()=>$V});function LV(t){switch(t){case"\b":return"\\b";case"\f":return"\\f";case`
@@ -561,10 +561,10 @@ ${t.map(l=>o.repeat(i+1)+gu(l,!1,!1,n,s,i+1)).join(`,
561
561
  ${o.repeat(i)}]`;if(typeof t=="object"){let a=Object.keys(t);return n&&(a=a.sort()),a.length===0?"{}":e?`{${a.map(c=>`${JSON.stringify(c)}:${gu(t[c],!0,!1,n,s)}`).join(",")}}`:`{
562
562
  ${a.map(c=>{let u=gu(t[c],!1,!1,n,s,i+1);return`${o.repeat(i+1)}${JSON.stringify(c)}: ${u}`}).join(`,
563
563
  `)}
564
- ${o.repeat(i)}}`}return String(t)}var MV,$V,Uy,qy=I(()=>{"use strict";Re();rn();rt();hs();$r();wo();xe();Ea();Wn();MV={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};$V={name:"jq",async execute(t,e){rr(e.requireDefenseContext,"jq","execution entry");let r=(m,g)=>sn(e.requireDefenseContext,"jq",m,g);if(Y(t))return Z(MV);let n=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=".",h=!1,d=[];for(let m=0;m<t.length;m++){let g=t[m];if(g==="-r"||g==="--raw-output")n=!0;else if(g==="-c"||g==="--compact-output")s=!0;else if(g==="-e"||g==="--exit-status")i=!0;else if(g==="-s"||g==="--slurp")o=!0;else if(g==="-n"||g==="--null-input")a=!0;else if(g==="-j"||g==="--join-output")l=!0;else if(!(g==="-a"||g==="--ascii")){if(g==="-S"||g==="--sort-keys")c=!0;else if(!(g==="-C"||g==="--color")){if(!(g==="-M"||g==="--monochrome"))if(g==="--tab")u=!0;else if(g==="-")d.push("-");else{if(g.startsWith("--"))return oe("jq",g);if(g.startsWith("-")){for(let y of g.slice(1))if(y==="r")n=!0;else if(y==="c")s=!0;else if(y==="e")i=!0;else if(y==="s")o=!0;else if(y==="n")a=!0;else if(y==="j")l=!0;else if(y!=="a"){if(y==="S")c=!0;else if(y!=="C"){if(y!=="M")return oe("jq",`-${y}`)}}}else h?d.push(g):(f=g,h=!0)}}}}let p=[];if(!a)if(d.length===0||d.length===1&&d[0]==="-")p.push({source:"stdin",content:he(e.stdin)});else{let m=await r("file read",()=>Ki(e,d,{cmdName:"jq",stopOnError:!0}));if(m.exitCode!==0)return{stdout:"",stderr:m.stderr,exitCode:2};p=m.files.map(g=>({source:g.filename||"stdin",content:he(g.content)}))}try{let m=xd(f),g=[],y={limits:e.limits?{maxIterations:e.limits.maxJqIterations}:void 0,env:e.env,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext};if(a)g=ne(null,m,y);else if(o){let F=[];for(let{content:R}of p){let $=R.trim();$&&F.push(...IA($))}g=ne(F,m,y)}else for(let{content:F}of p){let R=F.trim();if(!R)continue;let $=IA(R);for(let N of $)g.push(...ne(N,m,y))}let x=g.map(F=>gu(F,s,n,c,u)),b=l?"":`
565
- `,w=x.join(b),S=e.limits?.maxStringLength;if(S!==void 0&&S>0&&w.length>S)throw new fe(`jq: output size limit exceeded (${S} bytes)`,"string_length");let _=i&&(g.length===0||g.every(F=>F==null||F===!1))?1:0;return{stdout:w?l?w:`${w}
566
- `:"",stderr:"",exitCode:_}}catch(m){if(m instanceof Fe)throw m;if(m instanceof fe)return{stdout:"",stderr:`jq: ${Je(m.message)}
567
- `,exitCode:fe.EXIT_CODE};let g=Je(m.message);return g.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${g}
564
+ ${o.repeat(i)}}`}return String(t)}var MV,$V,Uy,qy=I(()=>{"use strict";Re();rn();rt();hs();$r();wo();xe();Ea();Wn();MV={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};$V={name:"jq",async execute(t,e){rr(e.requireDefenseContext,"jq","execution entry");let r=(m,g)=>sn(e.requireDefenseContext,"jq",m,g);if(Y(t))return Z(MV);let n=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=".",h=!1,d=[];for(let m=0;m<t.length;m++){let g=t[m];if(g==="-r"||g==="--raw-output")n=!0;else if(g==="-c"||g==="--compact-output")s=!0;else if(g==="-e"||g==="--exit-status")i=!0;else if(g==="-s"||g==="--slurp")o=!0;else if(g==="-n"||g==="--null-input")a=!0;else if(g==="-j"||g==="--join-output")l=!0;else if(!(g==="-a"||g==="--ascii")){if(g==="-S"||g==="--sort-keys")c=!0;else if(!(g==="-C"||g==="--color")){if(!(g==="-M"||g==="--monochrome"))if(g==="--tab")u=!0;else if(g==="-")d.push("-");else{if(g.startsWith("--"))return oe("jq",g);if(g.startsWith("-")){for(let y of g.slice(1))if(y==="r")n=!0;else if(y==="c")s=!0;else if(y==="e")i=!0;else if(y==="s")o=!0;else if(y==="n")a=!0;else if(y==="j")l=!0;else if(y!=="a"){if(y==="S")c=!0;else if(y!=="C"){if(y!=="M")return oe("jq",`-${y}`)}}}else h?d.push(g):(f=g,h=!0)}}}}let p=[];if(!a)if(d.length===0||d.length===1&&d[0]==="-")p.push({source:"stdin",content:fe(e.stdin)});else{let m=await r("file read",()=>Ki(e,d,{cmdName:"jq",stopOnError:!0}));if(m.exitCode!==0)return{stdout:"",stderr:m.stderr,exitCode:2};p=m.files.map(g=>({source:g.filename||"stdin",content:fe(g.content)}))}try{let m=xd(f),g=[],y={limits:e.limits?{maxIterations:e.limits.maxJqIterations}:void 0,env:e.env,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext};if(a)g=ne(null,m,y);else if(o){let F=[];for(let{content:R}of p){let $=R.trim();$&&F.push(...IA($))}g=ne(F,m,y)}else for(let{content:F}of p){let R=F.trim();if(!R)continue;let $=IA(R);for(let N of $)g.push(...ne(N,m,y))}let x=g.map(F=>gu(F,s,n,c,u)),b=l?"":`
565
+ `,w=x.join(b),S=e.limits?.maxStringLength;if(S!==void 0&&S>0&&w.length>S)throw new he(`jq: output size limit exceeded (${S} bytes)`,"string_length");let _=i&&(g.length===0||g.every(F=>F==null||F===!1))?1:0;return{stdout:w?l?w:`${w}
566
+ `:"",stderr:"",exitCode:_}}catch(m){if(m instanceof Fe)throw m;if(m instanceof he)return{stdout:"",stderr:`jq: ${Je(m.message)}
567
+ `,exitCode:he.EXIT_CODE};let g=Je(m.message);return g.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${g}
568
568
  `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${g}
569
569
  `,exitCode:5}}}},Uy={name:"jq",flags:[{flag:"-r",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-j",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"--tab",type:"boolean"}],stdinType:"json",needsArgs:!0}});var DA={};ue(DA,{base64Command:()=>qV,flagsForFuzzing:()=>zy});async function PA(t,e,r){if(e.length===0||e.length===1&&e[0]==="-")return{ok:!0,data:Uint8Array.from(t.stdin,a=>a.charCodeAt(0))};let n=[];for(let a of e){if(a==="-"){n.push(Uint8Array.from(t.stdin,l=>l.charCodeAt(0)));continue}try{let l=t.fs.resolvePath(t.cwd,a),c=await t.fs.readFileBuffer(l);n.push(c)}catch{return{ok:!1,error:{stdout:"",stderr:`${r}: ${a}: No such file or directory
570
570
  `,exitCode:1}}}}let s=n.reduce((a,l)=>a+l.length,0),i=new Uint8Array(s),o=0;for(let a of n)i.set(a,o),o+=a.length;return{ok:!0,data:i}}var BV,UV,qV,zy,Hy=I(()=>{"use strict";Re();Ar();xe();BV={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},UV={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};qV={name:"base64",async execute(t,e){if(Y(t))return Z(BV);let r=ct("base64",t,UV);if(!r.ok)return r.error;let n=r.result.flags.decode,s=r.result.flags.wrap,i=r.result.positional;try{if(n){let l=await PA(e,i,"base64");if(!l.ok)return l.error;if(typeof Buffer<"u"){let d=Buffer.from(l.data).toString("utf8").replace(/\s/g,"");return{stdout:Buffer.from(d,"base64").toString("latin1"),stderr:"",exitCode:0,stdoutEncoding:"binary"}}let u=String.fromCharCode(...l.data).replace(/\s/g,"");return{stdout:atob(u),stderr:"",exitCode:0,stdoutEncoding:"binary"}}let o=await PA(e,i,"base64");if(!o.ok)return o.error;let a;if(typeof Buffer<"u"?a=Buffer.from(o.data).toString("base64"):a=btoa(String.fromCharCode(...o.data)),s>0){let l=[];for(let c=0;c<a.length;c+=s)l.push(a.slice(c,c+s));a=l.join(`
@@ -583,8 +583,8 @@ ${o.repeat(i)}}`}return String(t)}var MV,$V,Uy,qy=I(()=>{"use strict";Re();rn();
583
583
  `),r=t.split(`
584
584
  `).map(n=>n+`
585
585
  `);return e?r.pop():r.push(r.pop().slice(0,-1)),r}var MA,$A=I(()=>{FA();MA={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0}});var BA=I(()=>{$A()});var UA={};ue(UA,{diffCommand:()=>KV,flagsForFuzzing:()=>Ky});var VV,GV,KV,Ky,Zy=I(()=>{"use strict";BA();Re();Ar();xe();VV={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},GV={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},KV={name:"diff",async execute(t,e){if(Y(t))return Z(VV);let r=ct("diff",t,GV);if(!r.ok)return r.error;let n=r.result.flags.brief,s=r.result.flags.reportSame,i=r.result.flags.ignoreCase,o=r.result.positional;if(r.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
586
- `,exitCode:2};let a,l,[c,u]=o;try{a=c==="-"?he(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory
587
- `,exitCode:2}}try{l=u==="-"?he(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
586
+ `,exitCode:2};let a,l,[c,u]=o;try{a=c==="-"?fe(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory
587
+ `,exitCode:2}}try{l=u==="-"?fe(e.stdin):await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
588
588
  `,exitCode:2}}let f=a,h=l;return i&&(f=f.toLowerCase(),h=h.toLowerCase()),f===h?s?{stdout:`Files ${c} and ${u} are identical
589
589
  `,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:n?{stdout:`Files ${c} and ${u} differ
590
590
  `,stderr:"",exitCode:1}:{stdout:Gy(c,u,a,l,"","",{context:3}),stderr:"",exitCode:1}}},Ky={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2}});var qA={};ue(qA,{dateCommand:()=>JV,flagsForFuzzing:()=>Yy});function Vn(t,e=2){return String(t).padStart(e,"0")}function wd(t,e,r){let n={Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()},s="",i=0;for(;i<e.length;){if(e[i]==="%"&&i+1<e.length){let o=e[++i];switch(o){case"%":s+="%";break;case"a":s+=YV[n.w];break;case"b":case"h":s+=XV[n.m];break;case"d":s+=Vn(n.D);break;case"e":s+=String(n.D).padStart(2," ");break;case"F":s+=`${n.Y}-${Vn(n.m+1)}-${Vn(n.D)}`;break;case"H":s+=Vn(n.H);break;case"I":s+=Vn(n.H%12||12);break;case"m":s+=Vn(n.m+1);break;case"M":s+=Vn(n.M);break;case"n":s+=`
@@ -628,7 +628,7 @@ sys 0.00
628
628
  `:"",stderr:"",exitCode:0}}},ix={name:"seq",flags:[{flag:"-s",type:"value",valueHint:"string"},{flag:"-w",type:"boolean"}],needsArgs:!0}});var KA={};ue(KA,{exprCommand:()=>aG,flagsForFuzzing:()=>ax});function lG(t){if(t.length===1)return t[0];let e=0;function r(){let c=n();for(;e<t.length&&t[e]==="|";){e++;let u=n();if(c!=="0"&&c!=="")return c;c=u}return c}function n(){let c=s();for(;e<t.length&&t[e]==="&";){e++;let u=s();(c==="0"||c===""||u==="0"||u==="")&&(c="0")}return c}function s(){let c=i();for(;e<t.length;){let u=t[e];if(["=","!=","<",">","<=",">="].includes(u)){e++;let f=i(),h=parseInt(c,10),d=parseInt(f,10),p=!Number.isNaN(h)&&!Number.isNaN(d),m;u==="="?m=p?h===d:c===f:u==="!="?m=p?h!==d:c!==f:u==="<"?m=p?h<d:c<f:u===">"?m=p?h>d:c>f:u==="<="?m=p?h<=d:c<=f:m=p?h>=d:c>=f,c=m?"1":"0"}else break}return c}function i(){let c=o();for(;e<t.length;){let u=t[e];if(u==="+"||u==="-"){e++;let f=o(),h=parseInt(c,10),d=parseInt(f,10);if(Number.isNaN(h)||Number.isNaN(d))throw new Error("non-integer argument");c=String(u==="+"?h+d:h-d)}else break}return c}function o(){let c=a();for(;e<t.length;){let u=t[e];if(u==="*"||u==="/"||u==="%"){e++;let f=a(),h=parseInt(c,10),d=parseInt(f,10);if(Number.isNaN(h)||Number.isNaN(d))throw new Error("non-integer argument");if((u==="/"||u==="%")&&d===0)throw new Error("division by zero");u==="*"?c=String(h*d):u==="/"?c=String(Math.trunc(h/d)):c=String(h%d)}else break}return c}function a(){let c=l();for(;e<t.length&&t[e]===":";){e++;let u=l(),h=ae(`^${u}`).match(c);h?c=h[1]!==void 0?h[1]:String(h[0].length):c="0"}return c}function l(){if(e>=t.length)throw new Error("syntax error");let c=t[e];if(c==="match"){e++;let u=l(),f=l(),d=ae(f).match(u);return d?d[1]!==void 0?d[1]:String(d[0].length):"0"}if(c==="substr"){e++;let u=l(),f=parseInt(l(),10),h=parseInt(l(),10);if(Number.isNaN(f)||Number.isNaN(h))throw new Error("non-integer argument");return u.substring(f-1,f-1+h)}if(c==="index"){e++;let u=l(),f=l();for(let h=0;h<u.length;h++)if(f.includes(u[h]))return String(h+1);return"0"}if(c==="length"){e++;let u=l();return String(u.length)}if(c==="("){e++;let u=r();if(e>=t.length||t[e]!==")")throw new Error("syntax error");return e++,u}return e++,c}return r()}var aG,ax,lx=I(()=>{"use strict";rn();Gt();aG={name:"expr",async execute(t,e){if(t.length===0)return{stdout:"",stderr:`expr: missing operand
629
629
  `,exitCode:2};try{let r=lG(t),n=r==="0"||r===""?1:0;return{stdout:`${r}
630
630
  `,stderr:"",exitCode:n}}catch(r){return{stdout:"",stderr:`expr: ${Je(r.message)}
631
- `,exitCode:2}}}};ax={name:"expr",flags:[],needsArgs:!0}});function uG(t){function e(d,p){return d<<p|d>>>32-p}let r=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=t.length*8,i=(t.length%64<56?56:120)-t.length%64,o=new Uint8Array(t.length+i+8);o.set(t),o[t.length]=128;let a=new DataView(o.buffer);a.setUint32(o.length-8,s>>>0,!0),a.setUint32(o.length-4,Math.floor(s/4294967296),!0);let l=1732584193,c=4023233417,u=2562383102,f=271733878;for(let d=0;d<o.length;d+=64){let p=new Uint32Array(16);for(let b=0;b<16;b++)p[b]=a.getUint32(d+b*4,!0);let m=l,g=c,y=u,x=f;for(let b=0;b<64;b++){let w,S;b<16?(w=g&y|~g&x,S=b):b<32?(w=x&g|~x&y,S=(5*b+1)%16):b<48?(w=g^y^x,S=(3*b+5)%16):(w=y^(g|~x),S=7*b%16),w=w+m+r[b]+p[S]>>>0,m=x,x=y,y=g,g=g+e(w,n[b])>>>0}l=l+m>>>0,c=c+g>>>0,u=u+y>>>0,f=f+x>>>0}let h=new Uint8Array(16);return new DataView(h.buffer).setUint32(0,l,!0),new DataView(h.buffer).setUint32(4,c,!0),new DataView(h.buffer).setUint32(8,u,!0),new DataView(h.buffer).setUint32(12,f,!0),Array.from(h).map(d=>d.toString(16).padStart(2,"0")).join("")}async function ZA(t,e){if(t==="md5")return uG(e);let r=cG.get(t);if(!r)throw new Error(`Unknown algorithm: ${t}`);let n=await globalThis.crypto.subtle.digest(r,new Uint8Array(e).buffer);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}function Rl(t,e,r){let n={name:t,summary:r,usage:`${t} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:t,async execute(s,i){if(Y(s))return Z(n);let o=!1,a=[];for(let f of s)if(f==="-c"||f==="--check")o=!0;else if(!(f==="-b"||f==="-t"||f==="--binary"||f==="--text")){if(f.startsWith("-")&&f!=="-")return oe(t,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return Uint8Array.from(i.stdin,h=>h.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,h="";for(let d of a){let p=d==="-"?he(i.stdin):await i.fs.readFile(i.fs.resolvePath(i.cwd,d)).catch(()=>null);if(p===null)return{stdout:"",stderr:`${t}: ${d}: No such file or directory
631
+ `,exitCode:2}}}};ax={name:"expr",flags:[],needsArgs:!0}});function uG(t){function e(d,p){return d<<p|d>>>32-p}let r=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=t.length*8,i=(t.length%64<56?56:120)-t.length%64,o=new Uint8Array(t.length+i+8);o.set(t),o[t.length]=128;let a=new DataView(o.buffer);a.setUint32(o.length-8,s>>>0,!0),a.setUint32(o.length-4,Math.floor(s/4294967296),!0);let l=1732584193,c=4023233417,u=2562383102,f=271733878;for(let d=0;d<o.length;d+=64){let p=new Uint32Array(16);for(let b=0;b<16;b++)p[b]=a.getUint32(d+b*4,!0);let m=l,g=c,y=u,x=f;for(let b=0;b<64;b++){let w,S;b<16?(w=g&y|~g&x,S=b):b<32?(w=x&g|~x&y,S=(5*b+1)%16):b<48?(w=g^y^x,S=(3*b+5)%16):(w=y^(g|~x),S=7*b%16),w=w+m+r[b]+p[S]>>>0,m=x,x=y,y=g,g=g+e(w,n[b])>>>0}l=l+m>>>0,c=c+g>>>0,u=u+y>>>0,f=f+x>>>0}let h=new Uint8Array(16);return new DataView(h.buffer).setUint32(0,l,!0),new DataView(h.buffer).setUint32(4,c,!0),new DataView(h.buffer).setUint32(8,u,!0),new DataView(h.buffer).setUint32(12,f,!0),Array.from(h).map(d=>d.toString(16).padStart(2,"0")).join("")}async function ZA(t,e){if(t==="md5")return uG(e);let r=cG.get(t);if(!r)throw new Error(`Unknown algorithm: ${t}`);let n=await globalThis.crypto.subtle.digest(r,new Uint8Array(e).buffer);return Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}function Rl(t,e,r){let n={name:t,summary:r,usage:`${t} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:t,async execute(s,i){if(Y(s))return Z(n);let o=!1,a=[];for(let f of s)if(f==="-c"||f==="--check")o=!0;else if(!(f==="-b"||f==="-t"||f==="--binary"||f==="--text")){if(f.startsWith("-")&&f!=="-")return oe(t,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return Uint8Array.from(i.stdin,h=>h.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,h="";for(let d of a){let p=d==="-"?fe(i.stdin):await i.fs.readFile(i.fs.resolvePath(i.cwd,d)).catch(()=>null);if(p===null)return{stdout:"",stderr:`${t}: ${d}: No such file or directory
632
632
  `,exitCode:1};for(let m of p.split(`
633
633
  `)){let g=m.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!g)continue;let[,y,x]=g,b=await l(x);if(b===null){h+=`${x}: FAILED open or read
634
634
  `,f++;continue}let w=await ZA(e,b)===y.toLowerCase();h+=`${x}: ${w?"OK":"FAILED"}
@@ -719,7 +719,7 @@ sys 0.00
719
719
 
720
720
  `:r}};this.options=AX({},e,t),this.rules=new CT(this.options)}Ep.prototype={turndown:function(t){if(!jX(t))throw new TypeError(t+" is not a string, or an element/document/fragment node.");if(t==="")return"";var e=kT.call(this,new LX(t,this.options));return HX.call(this,e)},use:function(t){if(Array.isArray(t))for(var e=0;e<t.length;e++)this.use(t[e]);else if(typeof t=="function")t(this);else throw new TypeError("plugin must be a Function or an Array of Functions");return this},addRule:function(t,e){return this.rules.add(t,e),this},keep:function(t){return this.rules.keep(t),this},remove:function(t){return this.rules.remove(t),this},escape:function(t){return AT(t)}};function kT(t){var e=this;return zX.call(t.childNodes,function(r,n){n=new $X(n,e.options);var s="";return n.nodeType===3?s=n.isCode?n.nodeValue:e.escape(n.nodeValue):n.nodeType===1&&(s=WX.call(e,n)),TT(r,s)},"")}function HX(t){var e=this;return this.rules.forEach(function(r){typeof r.append=="function"&&(t=TT(t,r.append(e.options)))}),t.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function WX(t){var e=this.rules.forNode(t),r=kT.call(this,t),n=t.flankingWhitespace;return(n.leading||n.trailing)&&(r=r.trim()),n.leading+e.replacement(r,t,this.options)+n.trailing}function TT(t,e){var r=xT(t),n=yT(e),s=Math.max(t.length-r.length,e.length-n.length),i=`
721
721
 
722
- `.substring(0,s);return r+i+n}function jX(t){return t!=null&&(typeof t=="string"||t.nodeType&&(t.nodeType===1||t.nodeType===9||t.nodeType===11))}_T.exports=Ep});var RT={};ue(RT,{flagsForFuzzing:()=>lw,htmlToMarkdownCommand:()=>GX});var IT,VX,GX,lw,cw=I(()=>{"use strict";IT=Mr(OT(),1);Re();xe();VX={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 ![alt](src)"," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '<h1>Hello</h1><p>World</p>' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},GX={name:"html-to-markdown",async execute(t,e){if(Y(t))return Z(VX);let r="-",n="```",s="---",i="atx",o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-b"||c==="--bullet")r=t[++l]??"-";else if(c.startsWith("--bullet="))r=c.slice(9);else if(c==="-c"||c==="--code")n=t[++l]??"```";else if(c.startsWith("--code="))n=c.slice(7);else if(c==="-r"||c==="--hr")s=t[++l]??"---";else if(c.startsWith("--hr="))s=c.slice(5);else if(c.startsWith("--heading-style=")){let u=c.slice(16);(u==="setext"||u==="atx")&&(i=u)}else if(c==="-")o.push("-");else{if(c.startsWith("--"))return oe("html-to-markdown",c);if(c.startsWith("-"))return oe("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=he(e.stdin);else try{let l=e.fs.resolvePath(e.cwd,o[0]);a=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
722
+ `.substring(0,s);return r+i+n}function jX(t){return t!=null&&(typeof t=="string"||t.nodeType&&(t.nodeType===1||t.nodeType===9||t.nodeType===11))}_T.exports=Ep});var RT={};ue(RT,{flagsForFuzzing:()=>lw,htmlToMarkdownCommand:()=>GX});var IT,VX,GX,lw,cw=I(()=>{"use strict";IT=Mr(OT(),1);Re();xe();VX={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 ![alt](src)"," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '<h1>Hello</h1><p>World</p>' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},GX={name:"html-to-markdown",async execute(t,e){if(Y(t))return Z(VX);let r="-",n="```",s="---",i="atx",o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-b"||c==="--bullet")r=t[++l]??"-";else if(c.startsWith("--bullet="))r=c.slice(9);else if(c==="-c"||c==="--code")n=t[++l]??"```";else if(c.startsWith("--code="))n=c.slice(7);else if(c==="-r"||c==="--hr")s=t[++l]??"---";else if(c.startsWith("--hr="))s=c.slice(5);else if(c.startsWith("--heading-style=")){let u=c.slice(16);(u==="setext"||u==="atx")&&(i=u)}else if(c==="-")o.push("-");else{if(c.startsWith("--"))return oe("html-to-markdown",c);if(c.startsWith("-"))return oe("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=fe(e.stdin);else try{let l=e.fs.resolvePath(e.cwd,o[0]);a=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
723
723
  `,exitCode:1}}if(!a.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new IT.default({bulletListMarker:r,codeBlockStyle:"fenced",fence:n,hr:s,headingStyle:i});return l.remove(["script","style","footer"]),{stdout:`${l.turndown(a).trim()}
724
724
  `,stderr:"",exitCode:0}}catch(l){return{stdout:"",stderr:`html-to-markdown: conversion error: ${l.message}
725
725
  `,exitCode:1}}}},lw={name:"html-to-markdown",flags:[],stdinType:"text"}});var PT={};ue(PT,{flagsForFuzzing:()=>uw,helpCommand:()=>YX});function ZX(t){let e=[],r=new Set(t);e.push(`Available commands:
@@ -1088,17 +1088,17 @@ EXAMPLES:
1088
1088
  yq '.nums | max' data.yaml # maximum
1089
1089
  yq '.items | unique' data.yaml # unique values
1090
1090
  yq '.items | group_by(.type)' data.yaml`,options:["-p, --input-format=FMT input format: yaml (default), xml, json, ini, csv, toml","-o, --output-format=FMT output format: yaml (default), json, xml, ini, csv, toml","-i, --inplace modify file in-place","-r, --raw-output output strings without quotes (json only)","-c, --compact compact output (json only)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-f, --front-matter extract and process front-matter only","-P, --prettyPrint pretty print output","-I, --indent=N set indent level (default: 2)"," --xml-attribute-prefix=STR XML attribute prefix (default: +@)"," --xml-content-name=STR XML text content name (default: +content)"," --csv-delimiter=CHAR CSV delimiter (default: auto-detect)"," --csv-header CSV has header row (default: true)"," --help display this help and exit"]};rie={name:"yq",async execute(t,e){rr(e.requireDefenseContext,"yq","execution entry");let r=(u,f)=>sn(e.requireDefenseContext,"yq",u,f);if(Y(t))return Z(eie);let n=tie(t);if("exitCode"in n)return n;let{options:s,filter:i,files:o,inputFormatExplicit:a}=n;if(!a&&o.length>0&&o[0]!=="-"){let u=NP(o[0]);u&&(s.inputFormat=u)}if(s.inplace&&(o.length===0||o[0]==="-"))return{stdout:"",stderr:`yq: -i/--inplace requires a file argument
1091
- `,exitCode:1};let l,c;if(s.nullInput)l="";else if(o.length===0||o.length===1&&o[0]==="-")l=he(e.stdin);else try{let u=e.fs.resolvePath(e.cwd,o[0]);c=u,l=await r("file read",()=>e.fs.readFile(u))}catch(u){if(u instanceof Fe)throw u;return{stdout:"",stderr:`yq: ${o[0]}: No such file or directory
1091
+ `,exitCode:1};let l,c;if(s.nullInput)l="";else if(o.length===0||o.length===1&&o[0]==="-")l=fe(e.stdin);else try{let u=e.fs.resolvePath(e.cwd,o[0]);c=u,l=await r("file read",()=>e.fs.readFile(u))}catch(u){if(u instanceof Fe)throw u;return{stdout:"",stderr:`yq: ${o[0]}: No such file or directory
1092
1092
  `,exitCode:2}}try{let u=xd(i),f,h={limits:e.limits?{maxIterations:e.limits.maxJqIterations}:void 0,env:e.env,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext};if(s.nullInput)f=ne(null,u,h);else if(s.frontMatter){let x=TP(l);if(!x)return{stdout:"",stderr:`yq: no front-matter found
1093
1093
  `,exitCode:1};f=ne(x.frontMatter,u,h)}else if(s.slurp){let x;s.inputFormat==="yaml"?x=kP(l):x=[t3(l,s)],f=ne(x,u,h)}else{let x=t3(l,s);f=ne(x,u,h)}let d=f.map(x=>_P(x,s)),p=s.joinOutput?"":`
1094
1094
  `,m=d.filter(x=>x!=="").join(p),g=m?s.joinOutput?m:`${m}
1095
- `:"";if(s.inplace&&c)return await r("in-place write",()=>e.fs.writeFile(c,g)),{stdout:"",stderr:"",exitCode:0};let y=s.exitStatus&&(f.length===0||f.every(x=>x==null||x===!1))?1:0;return{stdout:g,stderr:"",exitCode:y}}catch(u){if(u instanceof Fe)throw u;if(u instanceof fe)return{stdout:"",stderr:`yq: ${Je(u.message)}
1096
- `,exitCode:fe.EXIT_CODE};let f=Je(u.message);return f.includes("Unknown function")?{stdout:"",stderr:`yq: error: ${f}
1095
+ `:"";if(s.inplace&&c)return await r("in-place write",()=>e.fs.writeFile(c,g)),{stdout:"",stderr:"",exitCode:0};let y=s.exitStatus&&(f.length===0||f.every(x=>x==null||x===!1))?1:0;return{stdout:g,stderr:"",exitCode:y}}catch(u){if(u instanceof Fe)throw u;if(u instanceof he)return{stdout:"",stderr:`yq: ${Je(u.message)}
1096
+ `,exitCode:he.EXIT_CODE};let f=Je(u.message);return f.includes("Unknown function")?{stdout:"",stderr:`yq: error: ${f}
1097
1097
  `,exitCode:3}:{stdout:"",stderr:`yq: parse error: ${f}
1098
1098
  `,exitCode:5}}}},r3={name:"yq",flags:[{flag:"-r",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"value",valueHint:"string"},{flag:"-o",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function Pr(){return Object.create(null)}function vt(t,e,r){t[e]=r}function oi(t){let e=Pr();for(let r of Object.keys(t)){let n=t[r];(typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null)&&(e[r]=n)}return e}function i3(t){let e=s3.default.parse(t.trim(),{header:!0,dynamicTyping:!0,skipEmptyLines:!0}),r=e.data.map(n=>oi(n));return{headers:e.meta.fields||[],data:r}}function et(t,e){return e.length===0?`${t.join(",")}
1099
1099
  `:`${s3.default.unparse(e,{columns:t}).replace(/\r\n/g,`
1100
1100
  `)}
1101
- `}async function Ze(t,e){let r=t.find(o=>!o.startsWith("-")),n;if(!r||r==="-")n=he(e.stdin);else try{let o=e.fs.resolvePath(e.cwd,r);n=await e.fs.readFile(o)}catch{return{headers:[],data:[],error:{stdout:"",stderr:`xan: ${r}: No such file or directory
1101
+ `}async function Ze(t,e){let r=t.find(o=>!o.startsWith("-")),n;if(!r||r==="-")n=fe(e.stdin);else try{let o=e.fs.resolvePath(e.cwd,r);n=await e.fs.readFile(o)}catch{return{headers:[],data:[],error:{stdout:"",stderr:`xan: ${r}: No such file or directory
1102
1102
  `,exitCode:1}}}let{headers:s,data:i}=i3(n);return{headers:s,data:i}}var s3,ai=I(()=>{"use strict";s3=Mr(Wp(),1);Re()});var Mf,RP=I(()=>{"use strict";Mf=class{input;pos=0;tokens=[];constructor(e){this.input=e}tokenize(){for(;this.pos<this.input.length&&(this.skipWhitespace(),!(this.pos>=this.input.length));){let e=this.nextToken();e&&this.tokens.push(e)}return this.tokens.push({type:"eof",value:"",pos:this.pos}),this.tokens}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.input[this.pos];if(e===" "||e===" "||e===`
1103
1103
  `||e==="\r")this.pos++;else if(e==="#")for(;this.pos<this.input.length&&this.input[this.pos]!==`
1104
1104
  `;)this.pos++;else break}}nextToken(){let e=this.pos,r=this.input[this.pos];if(r>="0"&&r<="9")return this.readNumber();if(r==='"'||r==="'"||r==="`")return this.readString(r);if(r==="b"&&this.pos+1<this.input.length){let i=this.input[this.pos+1];if(i==='"'||i==="'"||i==="`")return this.pos++,this.readString(i)}if(r==="/"){let i=this.tokens[this.tokens.length-1];return i&&(i.type==="int"||i.type==="float"||i.type==="string"||i.type==="ident"||i.type===")"||i.type==="]")?this.input[this.pos+1]==="/"?(this.pos+=2,{type:"//",value:"//",pos:e}):(this.pos++,{type:"/",value:"/",pos:e}):this.readRegex()}if(this.match("not in"))return{type:"not in",value:"not in",pos:e};if(this.match("=>"))return{type:"=>",value:"=>",pos:e};if(this.match("**"))return{type:"**",value:"**",pos:e};if(this.match("++"))return{type:"++",value:"++",pos:e};if(this.match("//"))return{type:"//",value:"//",pos:e};if(this.match("=="))return{type:"==",value:"==",pos:e};if(this.match("!="))return{type:"!=",value:"!=",pos:e};if(this.match("<="))return{type:"<=",value:"<=",pos:e};if(this.match(">="))return{type:">=",value:">=",pos:e};if(this.match("&&"))return{type:"&&",value:"&&",pos:e};if(this.match("||"))return{type:"||",value:"||",pos:e};let s=new Map([["(","("],[")",")"],["[","["],["]","]"],["{","{"],["}","}"],[",",","],[":",":"],[";",";"],["+","+"],["-","-"],["*","*"],["%","%"],["<","<"],[">",">"],["!","!"],[".","."],["|","|"],["=","="]]).get(r);if(s!==void 0)return this.pos++,{type:s,value:r,pos:e};if(this.isIdentStart(r))return this.readIdentifier();throw new Error(`Unexpected character '${r}' at position ${this.pos}`)}match(e){if(this.input.slice(this.pos,this.pos+e.length)===e){if(/^[a-zA-Z]/.test(e)){let r=this.input[this.pos+e.length];if(r&&this.isIdentChar(r))return!1}return this.pos+=e.length,!0}return!1}isIdentStart(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"}isIdentChar(e){return this.isIdentStart(e)||e>="0"&&e<="9"}readNumber(){let e=this.pos,r=!1,n=!1;for(;this.pos<this.input.length;){let i=this.input[this.pos];if(i>="0"&&i<="9")this.pos++;else if(i==="_")this.pos++;else if(i==="."&&!r&&!n)r=!0,this.pos++;else if((i==="e"||i==="E")&&!n)n=!0,r=!0,this.pos++,this.pos<this.input.length&&(this.input[this.pos]==="+"||this.input[this.pos]==="-")&&this.pos++;else break}let s=this.input.slice(e,this.pos).replace(/_/g,"");return{type:r?"float":"int",value:s,pos:e}}readString(e){let r=this.pos;this.pos++;let n="";for(;this.pos<this.input.length;){let s=this.input[this.pos];if(s===e)return this.pos++,{type:"string",value:n,pos:r};if(s==="\\"){if(this.pos++,this.pos<this.input.length){let i=this.input[this.pos];switch(i){case"n":n+=`
@@ -1112,7 +1112,7 @@ EXAMPLES:
1112
1112
  `:`${n.map((o,a)=>`${a} ${o}`).join(`
1113
1113
  `)}
1114
1114
  `,stderr:"",exitCode:0}}async function b3(t,e){let{data:r,error:n}=await Ze(t,e);return n||{stdout:`${r.length}
1115
- `,stderr:"",exitCode:0}}async function w3(t,e){let r=10,n=[];for(let l=0;l<t.length;l++)(t[l]==="-l"||t[l]==="-n")&&l+1<t.length?r=Number.parseInt(t[++l],10):n.push(t[l]);let{headers:s,data:i,error:o}=await Ze(n,e);if(o)return o;let a=i.slice(0,r);return{stdout:et(s,a),stderr:"",exitCode:0}}async function E3(t,e){let r=10,n=[];for(let l=0;l<t.length;l++)(t[l]==="-l"||t[l]==="-n")&&l+1<t.length?r=Number.parseInt(t[++l],10):n.push(t[l]);let{headers:s,data:i,error:o}=await Ze(n,e);if(o)return o;let a=i.slice(-r);return{stdout:et(s,a),stderr:"",exitCode:0}}async function S3(t,e){let r,n,s,i=[];for(let h=0;h<t.length;h++){let d=t[h];(d==="-s"||d==="--start")&&h+1<t.length?r=Number.parseInt(t[++h],10):(d==="-e"||d==="--end")&&h+1<t.length?n=Number.parseInt(t[++h],10):(d==="-l"||d==="--len")&&h+1<t.length?s=Number.parseInt(t[++h],10):d.startsWith("-")||i.push(d)}let{headers:o,data:a,error:l}=await Ze(i,e);if(l)return l;let c=r??0,u;s!==void 0?u=c+s:n!==void 0?u=n:u=a.length;let f=a.slice(c,u);return{stdout:et(o,f),stderr:"",exitCode:0}}async function v3(t,e){let{headers:r,data:n,error:s}=await Ze(t,e);if(s)return s;let i=[...n].reverse();return{stdout:et(r,i),stderr:"",exitCode:0}}var qP=I(()=>{"use strict";ai()});async function C3(t,e){let r=t.filter(c=>!c.startsWith("-")),{headers:n,data:s,error:i}=await Ze(r,e);if(i)return i;if(s.length===0){let c=["column"],u=n.map(f=>({column:f}));return{stdout:et(c,u),stderr:"",exitCode:0}}let o=n[0],a=[o,...s.map((c,u)=>String(c[o]??`row_${u}`))],l=[];for(let c=1;c<n.length;c++){let u=n[c],f=Pr();vt(f,o,u);for(let h=0;h<s.length;h++)vt(f,a[h+1],s[h][u]);l.push(f)}return{stdout:et(a,l),stderr:"",exitCode:0}}async function N3(t,e){let r=null,n=[];for(let u=0;u<t.length;u++){let f=t[u];f==="--seed"&&u+1<t.length?r=Number.parseInt(t[++u],10):f.startsWith("-")||n.push(f)}let{headers:s,data:i,error:o}=await Ze(n,e);if(o)return o;let a=r!==null?r:Date.now(),l=()=>(a=a*1103515245+12345&2147483647,a/2147483647),c=[...i];for(let u=c.length-1;u>0;u--){let f=Math.floor(l()*(u+1));[c[u],c[f]]=[c[f],c[u]]}return{stdout:et(s,c),stderr:"",exitCode:0}}async function k3(t,e){let r=null,n="",s=[];for(let d=0;d<t.length;d++){let p=t[d];(p==="-l"||p==="--length")&&d+1<t.length?r=Number.parseInt(t[++d],10):(p==="-d"||p==="--default")&&d+1<t.length?n=t[++d]:p.startsWith("-")||s.push(p)}let i=s[0],o;if(!i||i==="-")o=he(e.stdin);else try{let d=e.fs.resolvePath(e.cwd,i);o=await e.fs.readFile(d)}catch{return{stdout:"",stderr:`xan fixlengths: ${i}: No such file or directory
1115
+ `,stderr:"",exitCode:0}}async function w3(t,e){let r=10,n=[];for(let l=0;l<t.length;l++)(t[l]==="-l"||t[l]==="-n")&&l+1<t.length?r=Number.parseInt(t[++l],10):n.push(t[l]);let{headers:s,data:i,error:o}=await Ze(n,e);if(o)return o;let a=i.slice(0,r);return{stdout:et(s,a),stderr:"",exitCode:0}}async function E3(t,e){let r=10,n=[];for(let l=0;l<t.length;l++)(t[l]==="-l"||t[l]==="-n")&&l+1<t.length?r=Number.parseInt(t[++l],10):n.push(t[l]);let{headers:s,data:i,error:o}=await Ze(n,e);if(o)return o;let a=i.slice(-r);return{stdout:et(s,a),stderr:"",exitCode:0}}async function S3(t,e){let r,n,s,i=[];for(let h=0;h<t.length;h++){let d=t[h];(d==="-s"||d==="--start")&&h+1<t.length?r=Number.parseInt(t[++h],10):(d==="-e"||d==="--end")&&h+1<t.length?n=Number.parseInt(t[++h],10):(d==="-l"||d==="--len")&&h+1<t.length?s=Number.parseInt(t[++h],10):d.startsWith("-")||i.push(d)}let{headers:o,data:a,error:l}=await Ze(i,e);if(l)return l;let c=r??0,u;s!==void 0?u=c+s:n!==void 0?u=n:u=a.length;let f=a.slice(c,u);return{stdout:et(o,f),stderr:"",exitCode:0}}async function v3(t,e){let{headers:r,data:n,error:s}=await Ze(t,e);if(s)return s;let i=[...n].reverse();return{stdout:et(r,i),stderr:"",exitCode:0}}var qP=I(()=>{"use strict";ai()});async function C3(t,e){let r=t.filter(c=>!c.startsWith("-")),{headers:n,data:s,error:i}=await Ze(r,e);if(i)return i;if(s.length===0){let c=["column"],u=n.map(f=>({column:f}));return{stdout:et(c,u),stderr:"",exitCode:0}}let o=n[0],a=[o,...s.map((c,u)=>String(c[o]??`row_${u}`))],l=[];for(let c=1;c<n.length;c++){let u=n[c],f=Pr();vt(f,o,u);for(let h=0;h<s.length;h++)vt(f,a[h+1],s[h][u]);l.push(f)}return{stdout:et(a,l),stderr:"",exitCode:0}}async function N3(t,e){let r=null,n=[];for(let u=0;u<t.length;u++){let f=t[u];f==="--seed"&&u+1<t.length?r=Number.parseInt(t[++u],10):f.startsWith("-")||n.push(f)}let{headers:s,data:i,error:o}=await Ze(n,e);if(o)return o;let a=r!==null?r:Date.now(),l=()=>(a=a*1103515245+12345&2147483647,a/2147483647),c=[...i];for(let u=c.length-1;u>0;u--){let f=Math.floor(l()*(u+1));[c[u],c[f]]=[c[f],c[u]]}return{stdout:et(s,c),stderr:"",exitCode:0}}async function k3(t,e){let r=null,n="",s=[];for(let d=0;d<t.length;d++){let p=t[d];(p==="-l"||p==="--length")&&d+1<t.length?r=Number.parseInt(t[++d],10):(p==="-d"||p==="--default")&&d+1<t.length?n=t[++d]:p.startsWith("-")||s.push(p)}let i=s[0],o;if(!i||i==="-")o=fe(e.stdin);else try{let d=e.fs.resolvePath(e.cwd,i);o=await e.fs.readFile(d)}catch{return{stdout:"",stderr:`xan fixlengths: ${i}: No such file or directory
1116
1116
  `,exitCode:1}}let l=A3.default.parse(o.trim(),{header:!1,skipEmptyLines:!0}).data;if(l.length===0)return{stdout:"",stderr:"",exitCode:0};let c=Math.max(...l.map(d=>d.length)),u=r??c,f=l.map(d=>d.length===u?d:d.length<u?[...d,...Array(u-d.length).fill(n)]:d.slice(0,u));return{stdout:`${A3.default.unparse(f).replace(/\r\n/g,`
1117
1117
  `)}
1118
1118
  `,stderr:"",exitCode:0}}async function T3(t,e){let r=null,n=null,s=".",i=[];for(let h=0;h<t.length;h++){let d=t[h];(d==="-c"||d==="--chunks")&&h+1<t.length?r=Number.parseInt(t[++h],10):(d==="-S"||d==="--size")&&h+1<t.length?n=Number.parseInt(t[++h],10):(d==="-o"||d==="--output")&&h+1<t.length?s=t[++h]:d.startsWith("-")||i.push(d)}if(!r&&!n)return{stdout:"",stderr:`xan split: must specify -c or -S
@@ -1129,7 +1129,7 @@ EXAMPLES:
1129
1129
  `,exitCode:1}}async function oie(t,e){let r=t.filter(o=>!o.startsWith("-")),{data:n,error:s}=await Ze(r,e);return s||{stdout:`${JSON.stringify(n,null,2)}
1130
1130
  `,stderr:"",exitCode:0}}async function I3(t,e){let r="",n=[];for(let s=0;s<t.length;s++){let i=t[s];(i==="-f"||i==="--format")&&s+1<t.length?r=t[++s]:i.startsWith("-")||n.push(i)}return r?r==="json"?aie(n,e):{stdout:"",stderr:`xan from: unsupported format '${r}'
1131
1131
  `,exitCode:1}:{stdout:"",stderr:`xan from: usage: xan from -f <format> [FILE]
1132
- `,exitCode:1}}async function aie(t,e){let r=t[0],n;if(!r||r==="-")n=he(e.stdin);else try{let s=e.fs.resolvePath(e.cwd,r);n=await e.fs.readFile(s)}catch{return{stdout:"",stderr:`xan from: ${r}: No such file or directory
1132
+ `,exitCode:1}}async function aie(t,e){let r=t[0],n;if(!r||r==="-")n=fe(e.stdin);else try{let s=e.fs.resolvePath(e.cwd,r);n=await e.fs.readFile(s)}catch{return{stdout:"",stderr:`xan from: ${r}: No such file or directory
1133
1133
  `,exitCode:1}}try{let s=JSON.parse(n.trim());if(!Array.isArray(s))return{stdout:"",stderr:`xan from: JSON input must be an array
1134
1134
  `,exitCode:1};if(s.length===0)return{stdout:`
1135
1135
  `,stderr:"",exitCode:0};if(Array.isArray(s[0])){let[o,...a]=s,l=a.map(c=>{let u=Pr();for(let f=0;f<o.length;f++)vt(u,o[f],c[f]);return u});return{stdout:et(o,l),stderr:"",exitCode:0}}let i=Object.keys(s[0]).sort();return{stdout:et(i,s),stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`xan from: invalid JSON input
@@ -1159,7 +1159,7 @@ EXAMPLES:
1159
1159
  `,stderr:"",exitCode:0})}function cie(t){if(t==null)return"";let e=String(t);return e.includes(",")||e.includes('"')||e.includes(`
1160
1160
  `)?`"${e.replace(/"/g,'""')}"`:e}async function j3(t,e){let r=null,n=null,s=[];for(let h=0;h<t.length;h++){let d=t[h];if(d==="--seed"&&h+1<t.length)n=Number.parseInt(t[++h],10);else if(!d.startsWith("-")){let p=Number.parseInt(d,10);r===null&&!Number.isNaN(p)&&p>0?r=p:s.push(d)}}if(r===null)return{stdout:"",stderr:`xan sample: usage: xan sample <sample-size> [FILE]
1161
1161
  `,exitCode:1};let{headers:i,data:o,error:a}=await Ze(s,e);if(a)return a;if(o.length<=r)return{stdout:et(i,o),stderr:"",exitCode:0};let l=n!==null?n:Date.now(),c=()=>(l=l*1103515245+12345&2147483647,l/2147483647),u=o.map((h,d)=>d);for(let h=u.length-1;h>0;h--){let d=Math.floor(c()*(h+1));[u[h],u[d]]=[u[d],u[h]]}let f=u.slice(0,r).sort((h,d)=>h-d).map(h=>o[h]);return{stdout:et(i,f),stderr:"",exitCode:0}}async function V3(t,e){let r=!1,n=[];for(let l=0;l<t.length;l++){let c=t[l];c==="-p"||c==="--pad"?r=!0:c.startsWith("-")||n.push(c)}if(n.length===0)return{stdout:"",stderr:`xan cat: no files specified
1162
- `,exitCode:1};let s=await Ki(e,n,{cmdName:"xan cat",stopOnError:!0});if(s.exitCode!==0)return{stdout:"",stderr:s.stderr,exitCode:s.exitCode};let i=[],o=[];for(let{content:l}of s.files){let{headers:c,data:u}=i3(he(l));i.push({headers:c,data:u});for(let f of c)o.includes(f)||o.push(f)}if(!r){let l=JSON.stringify(i[0].headers);for(let c=1;c<i.length;c++)if(JSON.stringify(i[c].headers)!==l)return{stdout:"",stderr:`xan cat: headers do not match (use -p to pad)
1162
+ `,exitCode:1};let s=await Ki(e,n,{cmdName:"xan cat",stopOnError:!0});if(s.exitCode!==0)return{stdout:"",stderr:s.stderr,exitCode:s.exitCode};let i=[],o=[];for(let{content:l}of s.files){let{headers:c,data:u}=i3(fe(l));i.push({headers:c,data:u});for(let f of c)o.includes(f)||o.push(f)}if(!r){let l=JSON.stringify(i[0].headers);for(let c=1;c<i.length;c++)if(JSON.stringify(i[c].headers)!==l)return{stdout:"",stderr:`xan cat: headers do not match (use -p to pad)
1163
1163
  `,exitCode:1};o=i[0].headers}let a=[];for(let{headers:l,data:c}of i)for(let u of c){let f=Pr();for(let h of o)vt(f,h,l.includes(h)?u[h]:"");a.push(f)}return{stdout:et(o,a),stderr:"",exitCode:0}}async function G3(t,e){let r="",n=[],s=!1,i=!1,o=[];for(let d=0;d<t.length;d++){let p=t[d];(p==="-s"||p==="--select")&&d+1<t.length?n=t[++d].split(","):p==="-v"||p==="--invert"?s=!0:p==="-i"||p==="--ignore-case"?i=!0:p==="-r"||p==="--regex"||p.startsWith("-")||(r?o.push(p):r=p)}if(!r)return{stdout:"",stderr:`xan search: no pattern specified
1164
1164
  `,exitCode:1};let{headers:a,data:l,error:c}=await Ze(o,e);if(c)return c;let u=n.length>0?n:a,f;try{f=ae(r,i?"i":"")}catch{return{stdout:"",stderr:`xan search: invalid regex pattern '${r}'
1165
1165
  `,exitCode:1}}let h=l.filter(d=>{let p=u.some(m=>{let g=d[m];return g!=null&&f.test(String(g))});return s?!p:p});return{stdout:et(a,h),stderr:"",exitCode:0}}async function K3(t,e){let r="",n=[];for(let h of t)h.startsWith("-")||(r?n.push(h):r=h);if(!r)return{stdout:"",stderr:`xan flatmap: no expression specified
@@ -1267,7 +1267,7 @@ Run 'xan --help' for usage.
1267
1267
  Use -help for a list of options.
1268
1268
  `,exitCode:1};r===null?r=a:n===null&&(n=a)}}return{options:e,database:r,sql:n,showVersion:s}}async function _ie(){let t=await Et.runTrustedAsync(()=>(0,lD.default)()),e=new t.Database;try{let r=e.exec("SELECT sqlite_version()");return r.length>0&&r[0].values.length>0?String(r[0].values[0][0]):"unknown"}finally{e.close()}}function cD(t=(0,Mi.dirname)((0,oD.fileURLToPath)(Die.url))){let e=[(0,Mi.join)(t,"sqlite3-worker.js"),(0,Mi.join)(t,"../../commands/sqlite3/worker.js")];(t.endsWith(`${Mi.sep}commands${Mi.sep}sqlite3`)||t.endsWith("/commands/sqlite3"))&&e.push((0,Mi.join)(t,"worker.js")),e.push((0,Mi.join)(t,"../../../dist/commands/sqlite3/worker.js"));for(let r of e)if((0,iD.existsSync)(r))return r;throw new Error("sqlite3 worker not found. Run 'pnpm build' to compile the worker.")}function Oie(){return(0,sD.randomBytes)(16).toString("hex")}function Iie(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let r=t;return typeof r.protocolToken!="string"||r.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:r.type==="security-violation"?{success:!1,error:`Security violation: ${typeof r.violation?.type=="string"?r.violation.type:"unknown"}`}:typeof r.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:r.success?Array.isArray(r.results)?typeof r.hasModifications!="boolean"?{success:!1,error:"Malformed worker response: missing hasModifications flag"}:r.dbBuffer!==null&&r.dbBuffer!==void 0&&!(r.dbBuffer instanceof Uint8Array)?{success:!1,error:"Malformed worker response: invalid dbBuffer"}:{success:!0,results:r.results,hasModifications:r.hasModifications,dbBuffer:r.dbBuffer===void 0?null:r.dbBuffer,defenseStats:r.defenseStats}:{success:!1,error:"Malformed worker response: missing results array"}:{success:!1,error:typeof r.error=="string"&&r.error.length>0?r.error:"Worker execution failed"}}async function Rie(t,e,r){try{let n=cD();return await new Promise((s,i)=>{let o=Et.runTrusted(()=>uD.createWorker(n,t)),a=Ni(r,"sqlite3","worker timeout callback",()=>{o.terminate(),s({success:!1,error:`Query timeout: execution exceeded ${e}ms limit`})}),c=Wr(()=>{try{a()}catch(g){let y=g instanceof Error?g.message:String(g);s({success:!1,error:or(y)})}},e),u=Ni(r,"sqlite3","worker message callback",g=>{fr(c),s(Iie(g,t.protocolToken))}),f=Ni(r,"sqlite3","worker error callback",g=>{fr(c),i(g)}),h=Ni(r,"sqlite3","worker exit callback",g=>{fr(c),g!==0&&s({success:!1,error:`Worker exited with code ${g}`})}),d=g=>{try{u(g)}catch(y){fr(c);let x=y instanceof Error?y.message:String(y);s({success:!1,error:or(x)})}},p=g=>{try{f(g)}catch(y){fr(c);let x=y instanceof Error?y.message:String(y);i(new Error(or(x)))}},m=g=>{try{h(g)}catch(y){fr(c);let x=y instanceof Error?y.message:String(y);s({success:!1,error:or(x)})}};o.on("message",d),o.on("error",p),o.on("exit",m)})}catch(n){let s=or(n.message);throw new Error(`sqlite3 worker failed to load: ${s}`)}}var sD,iD,Mi,oD,aD,lD,Die,Nie,kie,uD,Pie,Q3,J3=I(()=>{"use strict";sD=require("node:crypto"),iD=require("node:fs"),Mi=require("node:path"),oD=require("node:url"),aD=require("node:worker_threads"),lD=Mr(require("sql.js"),1);Re();rn();hs();$r();bi();xe();nD();Die={},Nie=5e3,kie={name:"sqlite3",summary:"SQLite database CLI",usage:"sqlite3 [OPTIONS] DATABASE [SQL]",options:["-list output in list mode (default)","-csv output in CSV mode","-json output in JSON mode","-line output in line mode","-column output in column mode","-table output as ASCII table","-markdown output as markdown table","-tabs output in tab-separated mode","-box output in Unicode box mode","-quote output in SQL quote mode","-html output as HTML table","-ascii output in ASCII mode (control chars)","-header show column headers","-noheader hide column headers","-separator SEP field separator for list mode (default: |)","-newline SEP row separator (default: \\n)","-nullvalue TEXT text for NULL values (default: empty)","-readonly open database read-only (no writeback)","-bail stop on first error","-echo print SQL before execution","-cmd COMMAND run SQL command before main SQL","-version show SQLite version","-- end of options","--help show this help"],examples:['sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"','sqlite3 -json data.db "SELECT * FROM users"','sqlite3 -csv -header data.db "SELECT id, name FROM products"','sqlite3 -box data.db "SELECT * FROM users"']};uD={createWorker(t,e){return new aD.Worker(t,{workerData:e})},findWorkerPath:cD};Pie={name:"sqlite3",async execute(t,e){if(Y(t)||t.includes("-help"))return Z(kie);let r=Tie(t);if("exitCode"in r)return r;let{options:n,database:s,sql:i,showVersion:o}=r;if(o)return{stdout:`${await _ie()}
1269
1269
  `,stderr:"",exitCode:0};if(!s)return{stdout:"",stderr:`sqlite3: missing database argument
1270
- `,exitCode:1};let a=i||he(e.stdin).trim();if(n.cmd&&(a=n.cmd+(a?`; ${a}`:"")),!a)return{stdout:"",stderr:`sqlite3: no SQL provided
1270
+ `,exitCode:1};let a=i||fe(e.stdin).trim();if(n.cmd&&(a=n.cmd+(a?`; ${a}`:"")),!a)return{stdout:"",stderr:`sqlite3: no SQL provided
1271
1271
  `,exitCode:1};let l=s===":memory:",c="",u=null;try{l||(c=e.fs.resolvePath(e.cwd,s),await e.fs.exists(c)&&(u=await e.fs.readFileBuffer(c)))}catch(y){let x=Je(y.message);return{stdout:"",stderr:`sqlite3: unable to open database "${s}": ${x}
1272
1272
  `,exitCode:1}}let f=e.limits?.maxSqliteTimeoutMs??Nie,h={protocolToken:Oie(),dbBuffer:u,sql:a,options:{bail:n.bail,echo:n.echo}},d;try{d=await Rie(h,f,e.requireDefenseContext)}catch(y){return{stdout:"",stderr:`sqlite3: worker error: ${or(y.message)}
1273
1273
  `,exitCode:1}}if(!d.success)return{stdout:"",stderr:`sqlite3: ${or(d.error)}
@@ -1291,9 +1291,9 @@ ${this.commandName}: execution timeout exceeded
1291
1291
  `,exitCode:1})),f.catch(p=>({success:!1,error:or(Rt(p))}))]);if(!d.success&&d.error){let p=or(d.error);return{stdout:h.stdout,stderr:`${h.stderr}python3: ${p}
1292
1292
  `,exitCode:h.exitCode||1}}return{...h}}var hD,dD,pD,Kie,Mie,$ie,Bie,t7,Hie,mD,Gie,n7=I(()=>{"use strict";hD=require("node:crypto"),dD=require("node:url"),pD=require("node:worker_threads");Re();rn();Rs();Tn();hs();$r();bi();xe();e7();em();Kie={},Mie=1e4,$ie=6e4,Bie={name:"python3",summary:"Execute Python code via CPython Emscripten",usage:"python3 [OPTIONS] [-c CODE | -m MODULE | FILE] [ARGS...]",description:["Execute Python code using CPython compiled to WebAssembly via Emscripten.","","This command runs Python in an isolated environment with access to","the virtual filesystem. Standard library modules are available."],options:["-c CODE Execute CODE as Python script","-m MODULE Run library module as a script","--version Show Python version","--help Show this help"],examples:['python3 -c "print(1 + 2)"','python3 -c "import sys; print(sys.version)"',"python3 script.py","python3 script.py arg1 arg2",`echo 'print("hello")' | python3`],notes:["CPython runs in WebAssembly, so execution may be slower than native Python.","Standard library modules are available (no pip install).","Maximum execution time is 30 seconds by default."]};t7=new WeakMap;Hie=(0,dD.fileURLToPath)(new URL("./worker.js",Kie.url));mD={name:"python3",async execute(t,e){if(Y(t))return Z(Bie);let r=Uie(t);if("exitCode"in r)return r;if(r.showVersion)return{stdout:`Python 3.13.2 (Emscripten)
1293
1293
  `,stderr:"",exitCode:0};let n,s;if(r.code!==null)n=r.code,s="-c";else if(r.module!==null){if(!/^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(r.module))return{stdout:"",stderr:`python3: No module named '${r.module.slice(0,200)}'
1294
- `,exitCode:1};n=`import runpy; runpy.run_module('${r.module}', run_name='__main__')`,s=r.module}else if(r.scriptFile==="-")n=he(e.stdin),s="-";else if(r.scriptFile!==null){let i=e.fs.resolvePath(e.cwd,r.scriptFile);if(!await e.fs.exists(i))return{stdout:"",stderr:`python3: can't open file '${r.scriptFile}': [Errno 2] No such file or directory
1294
+ `,exitCode:1};n=`import runpy; runpy.run_module('${r.module}', run_name='__main__')`,s=r.module}else if(r.scriptFile==="-")n=fe(e.stdin),s="-";else if(r.scriptFile!==null){let i=e.fs.resolvePath(e.cwd,r.scriptFile);if(!await e.fs.exists(i))return{stdout:"",stderr:`python3: can't open file '${r.scriptFile}': [Errno 2] No such file or directory
1295
1295
  `,exitCode:2};try{n=await e.fs.readFile(i),s=r.scriptFile}catch(o){let a=Je(o.message);return{stdout:"",stderr:`python3: can't open file '${r.scriptFile}': ${a}
1296
- `,exitCode:2}}}else if(he(e.stdin).trim())n=he(e.stdin),s="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
1296
+ `,exitCode:2}}}else if(fe(e.stdin).trim())n=fe(e.stdin),s="<stdin>";else return{stdout:"",stderr:`python3: no input provided (use -c CODE, -m MODULE, or provide a script file)
1297
1297
  `,exitCode:2};return Vie(n,e,s,r.scriptArgs)}},Gie={name:"python",async execute(t,e){return mD.execute(t,e)}}});var s7={};ue(s7,{jsExecCommand:()=>ooe,nodeStubCommand:()=>aoe});function Xie(t){let e={code:null,scriptFile:null,showVersion:!1,scriptArgs:[],isModule:!1,stripTypes:!1};if(t.length===0)return e;for(let r=0;r<t.length;r++){let n=t[r];if(n==="-m"||n==="--module"){e.isModule=!0;continue}if(n==="--strip-types"){e.stripTypes=!0;continue}if(n==="-c")return r+1>=t.length?{stdout:"",stderr:`js-exec: option requires an argument -- 'c'
1298
1298
  `,exitCode:2}:(e.code=t[r+1],e.scriptArgs=t.slice(r+2),e);if(n==="--version"||n==="-V")return e.showVersion=!0,e;if(n.startsWith("-")&&n!=="-"&&n!=="--")return{stdout:"",stderr:`js-exec: unrecognized option '${n}'
1299
1299
  `,exitCode:2};if(n==="--")return r+1<t.length&&(e.scriptFile=t[r+1],e.scriptArgs=t.slice(r+2)),e;if(!n.startsWith("-"))return e.scriptFile=n,e.scriptArgs=t.slice(r+1),e}return e}function qf(){for(;ci.length>0&&ci[0].canceled;)ci.shift();if(hn||ci.length===0)return;let t=ci.shift();if(!t)return;hn=t,eoe().postMessage(hn.input)}function Jie(t,e){if(!t||typeof t!="object")return{success:!1,error:"Malformed worker response"};let r=t;return typeof r.protocolToken!="string"||r.protocolToken!==e?{success:!1,error:"Malformed worker response: invalid protocol token"}:typeof r.success!="boolean"?{success:!1,error:"Malformed worker response: missing success flag"}:r.success?{success:!0}:{success:!1,error:typeof r.error=="string"&&r.error.length>0?r.error:"Worker execution failed"}}function eoe(){if(tm&&(fr(tm),tm=null),ws)return ws;let t=Et.runTrusted(()=>new bD.Worker(Qie));return ws=t,t.on("message",e=>{if(ws===t){if(hn){let r=Jie(e,hn.input.protocolToken);hn.resolve(r),hn=null}ci.length>0?qf():toe()}}),t.on("error",e=>{if(ws===t){if(hn){let r=or(Rt(e));hn.resolve({success:!1,error:r}),hn=null}for(let r of ci)r.resolve({success:!1,error:"Worker crashed"});ci.length=0,ws=null}}),t.on("exit",()=>{ws===t&&(ws=null,hn&&(hn.resolve({success:!1,error:"Worker exited unexpectedly"}),hn=null),ci.length>0&&qf())}),t}function toe(){tm=Wr(()=>{ws&&!hn&&ci.length===0&&(ws.terminate(),ws=null)},5e3)}async function roe(t,e,r,n=[],s,i,o){return wD.getStore()?{stdout:"",stderr:`js-exec: recursive invocation is not supported
@@ -1386,7 +1386,7 @@ Limits:
1386
1386
  `;ws=null,tm=null,ci=[],hn=null,Qie=(0,xD.fileURLToPath)(new URL("./js-exec-worker.js",loe.url));ooe={name:"js-exec",async execute(t,e){if(Y(t))return{stdout:ED,stderr:"",exitCode:0};let r=Xie(t);if("exitCode"in r)return r;if(r.showVersion)return{stdout:`QuickJS (quickjs-emscripten)
1387
1387
  `,stderr:"",exitCode:0};let n,s;if(r.code!==null)n=r.code,s="-c";else if(r.scriptFile!==null){let l=e.fs.resolvePath(e.cwd,r.scriptFile);if(!await e.fs.exists(l))return{stdout:"",stderr:`js-exec: can't open file '${r.scriptFile}': No such file or directory
1388
1388
  `,exitCode:2};try{n=await e.fs.readFile(l),s=l}catch(c){return{stdout:"",stderr:`js-exec: can't open file '${r.scriptFile}': ${Je(c.message)}
1389
- `,exitCode:2}}}else if(he(e.stdin).trim())n=he(e.stdin),s="<stdin>";else return{stdout:"",stderr:`js-exec: no input provided (use -c CODE or provide a script file)
1389
+ `,exitCode:2}}}else if(fe(e.stdin).trim())n=fe(e.stdin),s="<stdin>";else return{stdout:"",stderr:`js-exec: no input provided (use -c CODE or provide a script file)
1390
1390
  `,exitCode:2};let i=r.isModule,o=r.stripTypes;s&&s!=="-c"&&s!=="<stdin>"&&((s.endsWith(".mjs")||s.endsWith(".mts")||s.endsWith(".ts"))&&(i=!0),(s.endsWith(".ts")||s.endsWith(".mts"))&&(o=!0)),!i&&/\bawait\s+[\w([`]/.test(n)&&(i=!0);let a=e.jsBootstrapCode;return roe(n,e,s,r.scriptArgs,a,i,o)}},aoe={name:"node",async execute(){return{stdout:"",stderr:`node: this sandbox uses js-exec instead of node
1391
1391
 
1392
1392
  ${ED}`,exitCode:1}}}});function SD(t){let e=t.indexOf("=");if(e>=0){let r=t.slice(0,e),n=t.slice(e+1);return r?`${encodeURIComponent(r)}=${encodeURIComponent(n)}`:encodeURIComponent(n)}return encodeURIComponent(t)}function o7(t){let e=t.indexOf("=");if(e<0)return null;let r=t.slice(0,e),n=t.slice(e+1),s,i,o=n.match(/;type=([^;]+)$/);o&&(i=o[1],n=n.slice(0,-o[0].length));let a=n.match(/;filename=([^;]+)/);return a&&(s=a[1],n=n.replace(a[0],"")),(n.startsWith("@")||n.startsWith("<"))&&(s=s??n.slice(1).split("/").pop()),{name:r,value:n,filename:s,contentType:i}}function vD(t,e){let r=`----CurlFormBoundary${Date.now().toString(36)}`,n=[];for(let s of t){let i=s.value;if(i.startsWith("@")||i.startsWith("<")){let a=i.slice(1);i=e.get(a)??""}let o=`--${r}\r
@@ -1465,7 +1465,7 @@ Gid: ${s} ${s} ${s} ${s}
1465
1465
  `:m==="$"||m==="`"||m==='"'||m==="'"||m===`
1466
1466
  `||c&&m==="}",y=o?"*?[]\\".includes(m):"*?[]\\(){}.^+".includes(m);g?h+=m:y?(d(),u.push(me.escaped(m))):h+=`\\${m}`,f+=2;continue}if(p==="'"&&!o&&!i){d();let m=e.indexOf("'",f+1);if(m===-1){h+=e.slice(f);break}u.push(me.singleQuoted(e.slice(f+1,m))),f=m+1;continue}if(p==='"'&&!i){d();let{part:m,endIndex:g}=eae(t,e,f+1);u.push(m),f=g+1;continue}if(p==="$"&&e[f+1]==="'"){d();let{part:m,endIndex:g}=NL(t,e,f+2);u.push(m),f=g;continue}if(p==="$"){d();let{part:m,endIndex:g}=F7(t,e,f);m&&u.push(m),f=g;continue}if(p==="`"){d();let{part:m,endIndex:g}=t.parseBacktickSubstitution(e,f);u.push(m),f=g;continue}if(p==="~"){let m=f>0?e[f-1]:"";if(f===0||m==="="||s&&m===":"){let y=vL(t,e,f),x=e[y];if(x===void 0||x==="/"||x===":"){d();let b=e.slice(f+1,y)||null;u.push({type:"TildeExpansion",user:b}),f=y;continue}}}if("@*+?!".includes(p)&&f+1<e.length&&e[f+1]==="("){let m=Xoe(e,f+1);if(m!==-1){d();let g=e.slice(f,m+1);u.push({type:"Glob",pattern:g}),f=m+1;continue}}if(p==="*"||p==="?"||p==="["){d();let{pattern:m,endIndex:g}=CL(t,e,f);u.push({type:"Glob",pattern:m}),f=g;continue}if(p==="{"&&!s&&!a&&!i){let m=kL(t,e,f,Xo);if(m){d(),u.push(m.part),f=m.endIndex;continue}}h+=p,f++}return d(),u}var $L=I(()=>{"use strict";Xa();vn();Ya();A7()});function BL(t,e){let r=t.length,n=e+3,s=2,i=!1,o=!1;for(;n<r&&s>0;){let a=t[n];if(i){a==="'"&&(i=!1),n++;continue}if(o){if(a==="\\"){n+=2;continue}a==='"'&&(o=!1),n++;continue}if(a==="'"){i=!0,n++;continue}if(a==='"'){o=!0,n++;continue}if(a==="\\"){n+=2;continue}if(a==="("){s++,n++;continue}if(a===")"){if(s--,s===1){let l=n+1;return!(l<r&&t[l]===")")}if(s===0)return!1;n++;continue}if(s===1&&(a==="|"&&n+1<r&&t[n+1]==="|"||a==="&"&&n+1<r&&t[n+1]==="&"||a==="|"&&n+1<r&&t[n+1]!=="|"))return!0;n++}return!1}function UL(t,e,r,n){let s=e+2,i=1,o=s,a=!1,l=!1,c=0,u=!1,f="";for(;o<t.length&&i>0;){let m=t[o];a?m==="'"&&(a=!1):l?m==="\\"&&o+1<t.length?o++:m==='"'&&(l=!1):m==="'"?(a=!0,f=""):m==='"'?(l=!0,f=""):m==="\\"&&o+1<t.length?(o++,f=""):/[a-zA-Z_]/.test(m)?f+=m:(f==="case"?(c++,u=!1):f==="in"&&c>0?u=!0:f==="esac"&&c>0&&(c--,u=!1),f="",m==="("?o>0&&t[o-1]==="$"?i++:u||i++:m===")"?u?u=!1:i--:m===";"&&c>0&&o+1<t.length&&t[o+1]===";"&&(u=!0)),i>0&&o++}i>0&&n("unexpected EOF while looking for matching `)'");let h=t.slice(s,o),p=r().parse(h);return{part:me.commandSubstitution(p,!1),endIndex:o+1}}function qL(t,e,r,n,s){let o=e+1,a="";for(;o<t.length&&t[o]!=="`";)if(t[o]==="\\"){let u=t[o+1];u==="$"||u==="`"||u==="\\"||u===`
1467
1467
  `||r&&u==='"'?(u!==`
1468
- `&&(a+=u),o+=2):(a+=t[o],o++)}else a+=t[o],o++;o>=t.length&&s("unexpected EOF while looking for matching ``'");let c=n().parse(a);return{part:me.commandSubstitution(c,!0),endIndex:o+1}}var zL=I(()=>{"use strict";Xa()});function Dn(t,e){return new je().parse(t,e)}var je,mr=I(()=>{"use strict";Xa();vn();IL();RL();FL();$L();Yo();zL();Ya();Ya();je=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>sL)throw new Qr("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>x7)throw new Qr(`Maximum parser nesting depth exceeded (${x7})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(e,r){if(e.length>g7)throw new Qr(`Input too large: ${e.length} bytes exceeds limit of ${g7}`,1,1);this._input=e;let n=new om(e,r);if(this.tokens=n.tokenize(),this.tokens.length>y7)throw new Qr(`Too many tokens: ${this.tokens.length} exceeds limit of ${y7}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,r,n,s,...i){let o=this.tokens[this.pos]?.type;return o===e||r!==void 0&&o===r||n!==void 0&&o===n||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,r){if(this.check(e))return this.advance();let n=this.current();throw new Qr(r||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let r=this.current();throw new Qr(e,r.line,r.column,r)}skipNewlines(){for(;this.check(C.NEWLINE,C.COMMENT);)this.check(C.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(C.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(C.SEMICOLON,C.COMMENT)){this.advance();continue}if(e&&this.check(C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,r,n,s){this.pendingHeredocs.push({redirect:e,delimiter:r,stripTabs:n,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(C.HEREDOC_CONTENT)){let r=this.advance(),n;e.quoted?n=me.word([me.literal(r.value)]):n=this.parseWordFromString(r.value,!1,!1,!1,!0),e.redirect.target=me.hereDoc(e.delimiter,n,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(C.EOF,C.NEWLINE,C.SEMICOLON,C.AMP,C.AND_AND,C.OR_OR,C.RPAREN,C.RBRACE,C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===C.WORD||e===C.NAME||e===C.NUMBER||e===C.ASSIGNMENT_WORD||e===C.IF||e===C.FOR||e===C.WHILE||e===C.UNTIL||e===C.CASE||e===C.LPAREN||e===C.LBRACE||e===C.DPAREN_START||e===C.DBRACK_START||e===C.FUNCTION||e===C.BANG||e===C.TIME||e===C.IN||e===C.LESS||e===C.GREAT||e===C.DLESS||e===C.DGREAT||e===C.LESSAND||e===C.GREATAND||e===C.LESSGREAT||e===C.DLESSDASH||e===C.CLOBBER||e===C.TLESS||e===C.AND_GREAT||e===C.AND_DGREAT}parseScript(){let e=[],n=0;for(this.skipNewlines();!this.check(C.EOF);){n++,n>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){e.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&e.push(o),this.skipSeparators(!1),this.check(C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(C.EOF)&&this.advance()}return me.script(e)}checkUnexpectedToken(){let e=this.current().type,r=this.current().value;if((e===C.DO||e===C.DONE||e===C.THEN||e===C.ELSE||e===C.ELIF||e===C.FI||e===C.ESAC)&&this.error(`syntax error near unexpected token \`${r}'`),e===C.RBRACE||e===C.RPAREN){let n=`syntax error near unexpected token \`${r}'`;return this.advance(),me.statement([me.pipeline([me.simpleCommand(null,[],[],[])])],[],!1,{message:n,token:r})}return(e===C.DSEMI||e===C.SEMI_AND||e===C.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${r}'`),e===C.SEMICOLON&&this.error(`syntax error near unexpected token \`${r}'`),(e===C.PIPE||e===C.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${r}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,r=[],n=[],s=!1,i=this.parsePipeline();for(r.push(i);this.check(C.AND_AND,C.OR_OR);){let l=this.advance();n.push(l.type===C.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();r.push(c)}this.check(C.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:e,a=this._input.slice(e,o);return me.statement(r,n,s,void 0,a)}parsePipeline(){let e=!1,r=!1;this.check(C.TIME)&&(this.advance(),e=!0,this.check(C.WORD,C.NAME)&&this.current().value==="-p"&&(this.advance(),r=!0));let n=0;for(;this.check(C.BANG);)this.advance(),n++;let s=n%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(C.PIPE,C.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===C.PIPE_AMP);let c=this.parseCommand();i.push(c)}return me.pipeline(i,s,e,r,o.length>0?o:void 0)}parseCommand(){return this.check(C.IF)?N7(this):this.check(C.FOR)?k7(this):this.check(C.WHILE)?T7(this):this.check(C.UNTIL)?_7(this):this.check(C.CASE)?O7(this):this.check(C.LPAREN)?I7(this):this.check(C.LBRACE)?R7(this):this.check(C.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(C.DBRACK_START)?this.parseConditionalCommand():this.check(C.FUNCTION)?this.parseFunctionDef():this.check(C.NAME,C.WORD)&&this.peek(1).type===C.LPAREN&&this.peek(2).type===C.RPAREN?this.parseFunctionDef():OL(this)}dparenClosesWithSpacedParens(){let e=1,r=1;for(;r<this.tokens.length-this.pos;){let n=this.peek(r);if(n.type===C.EOF)return!1;if(n.type===C.DPAREN_START||n.type===C.LPAREN)e++;else if(n.type===C.DPAREN_END){if(e-=2,e<=0)return!1}else if(n.type===C.RPAREN&&(e--,e===0&&this.peek(r+1).type===C.RPAREN))return!0;r++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(C.RPAREN),this.expect(C.RPAREN);let r=this.parseOptionalRedirections(),n=me.subshell(e,[]);return me.subshell([me.statement([me.pipeline([n],!1,!1,!1)])],r)}isWord(){let e=this.current().type;return e===C.WORD||e===C.NAME||e===C.NUMBER||e===C.IF||e===C.FOR||e===C.WHILE||e===C.UNTIL||e===C.CASE||e===C.FUNCTION||e===C.ELSE||e===C.ELIF||e===C.FI||e===C.THEN||e===C.DO||e===C.DONE||e===C.ESAC||e===C.IN||e===C.SELECT||e===C.TIME||e===C.COPROC||e===C.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordNoBraceExpansion(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0)}parseWordForRegex(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0,!0)}parseWordFromString(e,r=!1,n=!1,s=!1,i=!1,o=!1,a=!1){let l=Xo(this,e,r,n,s,i,!1,o,a);return me.word(l)}parseCommandSubstitution(e,r){return UL(e,r,()=>new t,n=>this.error(n))}parseBacktickSubstitution(e,r,n=!1){return qL(e,r,n,()=>new t,s=>this.error(s))}isDollarDparenSubshell(e,r){return BL(e,r)}parseArithmeticExpansion(e,r){let n=r+3,s=1,i=0,o=n;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(n,o),l=this.parseArithmeticExpression(a);return{part:me.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let e=this.expect(C.DPAREN_START),r="",n=1,s=0,i=!1,o=!1;for(;n>0&&!this.check(C.EOF);){if(i){if(i=!1,s>0){s--,r+=")";continue}if(this.check(C.RPAREN)){n--,o=!0,this.advance();continue}if(this.check(C.DPAREN_END)){n--,o=!0;continue}r+=")";continue}if(this.check(C.DPAREN_START))n++,r+="((",this.advance();else if(this.check(C.DPAREN_END))s>=2?(s-=2,r+="))",this.advance()):s===1?(s--,r+=")",i=!0,this.advance()):(n--,o=!0,n>0&&(r+="))"),this.advance());else if(this.check(C.LPAREN))s++,r+="(",this.advance();else if(this.check(C.RPAREN))s>0&&s--,r+=")",this.advance();else{let c=this.current().value,u=r.length>0?r[r.length-1]:"";r.length>0&&!r.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(r))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(r+=" "),r+=c,this.advance()}}o||this.expect(C.DPAREN_END);let a=this.parseArithmeticExpression(r.trim()),l=this.parseOptionalRedirections();return me.arithmeticCommand(a,l,e.line)}parseConditionalCommand(){let e=this.expect(C.DBRACK_START),r=D7(this);this.expect(C.DBRACK_END);let n=this.parseOptionalRedirections();return me.conditionalCommand(r,n,e.line)}parseFunctionDef(){let e;if(this.check(C.FUNCTION)){if(this.advance(),this.check(C.NAME)||this.check(C.WORD))e=this.advance().value;else{let s=this.current();throw new Qr("Expected function name",s.line,s.column,s)}this.check(C.LPAREN)&&(this.advance(),this.expect(C.RPAREN))}else e=this.advance().value,e.includes("$")&&this.error(`\`${e}': not a valid identifier`),this.expect(C.LPAREN),this.expect(C.RPAREN);this.skipNewlines();let r=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return me.functionDef(e,r,n)}parseCompoundCommandBody(e){let r=e?.forFunctionBody;if(this.check(C.LBRACE))return R7(this,{skipRedirections:r});if(this.check(C.LPAREN))return I7(this,{skipRedirections:r});if(this.check(C.IF))return N7(this,{skipRedirections:r});if(this.check(C.FOR))return k7(this,{skipRedirections:r});if(this.check(C.WHILE))return T7(this,{skipRedirections:r});if(this.check(C.UNTIL))return _7(this,{skipRedirections:r});if(this.check(C.CASE))return O7(this,{skipRedirections:r});this.error("Expected compound command for function body")}parseCompoundList(){let e=this.enterDepth(),r=[];for(this.skipNewlines();!this.check(C.EOF,C.FI,C.ELSE,C.ELIF,C.THEN,C.DO,C.DONE,C.ESAC,C.RPAREN,C.RBRACE,C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,s=this.parseStatement();if(s&&r.push(s),this.skipSeparators(),this.pos===n&&!s)break}return e(),r}parseOptionalRedirections(){let e=[];for(;cm(this);){this.checkIterationLimit();let r=this.pos;if(e.push(um(this)),this.pos===r)break}return e}parseArithmeticExpression(e){return mt(this,e)}}});function $7(t){return nae.get(t)??""}function KL(t){let e=[],r="",n=0;for(;n<t.length;){let s=t[n];if(s==="["){for(r+=s,n++,n<t.length&&(t[n]==="!"||t[n]==="^")&&(r+=t[n],n++),n<t.length&&t[n]==="]"&&(r+=t[n],n++);n<t.length&&t[n]!=="]";){if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let i=t.indexOf(":]",n+2);if(i!==-1){r+=t.slice(n,i+2),n=i+2;continue}}if(t[n]==="\\"&&n+1<t.length){r+=t[n]+t[n+1],n+=2;continue}r+=t[n],n++}n<t.length&&t[n]==="]"&&(r+=t[n],n++)}else s===":"?(r!==""&&e.push(r),r="",n++):s==="\\"&&n+1<t.length?(r+=s+t[n+1],n+=2):(r+=s,n++)}return r!==""&&e.push(r),e}function ZL(t){let e="^";for(let r=0;r<t.length;r++){let n=t[r];if(n==="*")e+="[^/]*";else if(n==="?")e+="[^/]";else if(n==="["){let s=r+1,i="[";s<t.length&&(t[s]==="^"||t[s]==="!")&&(i+="^",s++),s<t.length&&t[s]==="]"&&(i+="\\]",s++);let o=s;for(;o<t.length;){if(t[o]==="\\"&&o+1<t.length){o+=2;continue}if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let l=t.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(t[o]==="]")break;o++}let a=s;for(;s<t.length&&t[s]!=="]";){if(t[s]==="["&&s+1<t.length&&t[s+1]===":"){let l=t.indexOf(":]",s+2);if(l!==-1){let c=t.slice(s+2,l),u=$7(c);i+=u,s=l+2;continue}}if(t[s]==="\\"&&s+1<t.length){i+=`\\${t[s+1]}`,s+=2;continue}if(t[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=t[s];s++}i+="]",e+=i,r=s}else if(n==="\\"&&r+1<t.length){let s=t[r+1];/[.+^${}()|\\*?[\]]/.test(s)?e+=`\\${s}`:e+=s,r++}else/[.+^${}()|]/.test(n)?e+=`\\${n}`:e+=n}return e+="$",ae(e)}function B7(t,e){let r=1,n=e+1;for(;n<t.length&&r>0;){let s=t[n];if(s==="\\"){n+=2;continue}if(s==="(")r++;else if(s===")"&&(r--,r===0))return n;n++}return-1}function U7(t){let e=[],r="",n=0,s=!1,i=0;for(;i<t.length;){let o=t[i];if(o==="'"&&!s){s=!0,r+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,r+="\0QUOTE_END\0",i++;continue}if(s){r+=o,i++;continue}if(o==="\\"){r+=o,i+1<t.length?(r+=t[i+1],i+=2):i++;continue}o==="("?(n++,r+=o):o===")"?(n--,r+=o):o==="|"&&n===0?(e.push(r),r=""):r+=o,i++}return e.push(r),e}var nae,YL=I(()=>{"use strict";Gt();nae=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9a-fA-F"]])});var XL,Qo,fm=I(()=>{"use strict";rt();Gt();fl();YL();XL=5,Qo=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(e,r,n,s){this.fs=e,this.cwd=r,typeof s=="boolean"?(this.globstar=s,this.maxOps=1e5):s?(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0,this.maxOps=s.maxGlobOperations??1e5):this.maxOps=1e5;let i=n?.get("GLOBIGNORE");i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=KL(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new fe(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(r=>{let n=r.split("/").pop()||r;if((this.hasGlobignore||this.globskipdots)&&(n==="."||n===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(r,s))return!1}return!0})}matchGlobignorePattern(e,r){return ZL(r).test(e)}isGlobPattern(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,r){let n=e.map((o,a)=>(r?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(n.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<e.length;o++){let a=s[o];a===null?i.push(e[o]):a.length>0?i.push(...a):i.push(e[o])}return i}async expand(e){if(this.globstar){let n=e.split("/"),s=0;for(let i of n)if(i==="**"&&(s++,s>XL))throw new fe(`Glob pattern has too many ** segments (max ${XL})`,"glob_operations")}let r;if(e.includes("**")&&this.globstar&&this.isGlobstarValid(e))r=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,"*");r=await this.expandSimple(n)}return this.filterGlobignore(r)}isGlobstarValid(e){let r=e.split("/");for(let n of r)if(n.includes("**")&&n!=="**")return!1;return!0}hasGlobChars(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let r=e.startsWith("/"),n=e.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<n.length;c++)if(this.hasGlobChars(n[c])){s=c;break}if(s===-1)return[e];let i,o;if(s===0)r?(i="/",o="/"):(i=this.cwd,o="");else{let c=n.slice(0,s);r?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=n.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(e,r,n){if(this.checkOpsLimit(),n.length===0)return[r];let[s,...i]=n,o=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let h=a.some(p=>p.name==="."),d=a.some(p=>p.name==="..");h||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h.name,s)){let d=e==="/"?`/${h.name}`:`${e}/${h.name}`,p;r===""?p=h.name:r==="/"?p=`/${h.name}`:p=`${r}/${h.name}`,i.length===0?l.push(Promise.resolve([p])):h.isDirectory&&l.push(this.expandSegments(d,p,i))}let f=await Promise.all(l);for(let h of f)o.push(...h)}else{this.checkOpsLimit();let a=await this.fs.readdir(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h,s)){let d=e==="/"?`/${h}`:`${e}/${h}`,p;r===""?p=h:r==="/"?p=`/${h}`:p=`${r}/${h}`,i.length===0?l.push(Promise.resolve([p])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,p,i)}catch(m){if(m instanceof fe)throw m}return[]})())}let f=await Promise.all(l);for(let h of f)o.push(...h)}}catch(a){if(a instanceof fe)throw a}return o}async expandRecursive(e){let r=[],n=e.indexOf("**"),s=e.slice(0,n).replace(/\/$/,"")||".",o=e.slice(n+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,r),[...new Set(r)].sort()):(await this.walkDirectory(s,o,r),r.sort())}async walkDirectoryMultiGlobstar(e,r,n){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=e==="."?c.name:`${e}/${c.name}`;c.isDirectory&&o.push(u)}let a=e==="."?r:`${e}/${r}`,l=await this.expandRecursive(a);n.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,r,n)))}}else{this.checkOpsLimit();let o=await this.fs.readdir(s),a=[];for(let u of o){let f=e==="."?u:`${e}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&a.push(f)}catch(d){if(d instanceof fe)throw d}}let l=e==="."?r:`${e}/${r}`,c=await this.expandRecursive(l);n.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,r,n)))}}}catch(i){if(i instanceof fe)throw i}}async walkDirectory(e,r,n){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=e==="."?l.name:`${e}/${l.name}`;l.isDirectory?a.push(c):r&&this.matchPattern(l.name,r)&&o.push(c)}n.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,r,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let h=e==="."?f:`${e}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let p=await this.fs.stat(d);return{name:f,path:h,isDirectory:p.isDirectory}}catch(p){if(p instanceof fe)throw p;return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&r&&this.matchPattern(l.name,r)&&n.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,r,n)))}}}catch(i){if(i instanceof fe)throw i}}matchPattern(e,r){return this.patternToRegex(r).test(e)}patternToRegex(e){let r=this.patternToRegexStr(e);return ae(`^${r}$`)}patternToRegexStr(e){let r="",n=!1;for(let s=0;s<e.length;s++){if(e.slice(s,s+13)==="\0QUOTE_START\0"){n=!0,s+=12;continue}if(e.slice(s,s+11)==="\0QUOTE_END\0"){n=!1,s+=10;continue}let i=e[s];if(n){/[.+^${}()|\\*?[\]]/.test(i)?r+=`\\${i}`:r+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<e.length&&e[s+1]==="("){let o=B7(e,s+1);if(o!==-1){let a=e.slice(s+2,o),l=U7(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")r+=`(?:${u})`;else if(i==="*")r+=`(?:${u})*`;else if(i==="+")r+=`(?:${u})+`;else if(i==="?")r+=`(?:${u})?`;else if(i==="!")if(o<e.length-1){let h=l.map(p=>this.computePatternLength(p));if(h.every(p=>p!==null)&&h.every(p=>p===h[0])&&h[0]!==null){let p=h[0];if(p===0)r+="(?:.+)";else{let m=[];p>0&&m.push(`.{0,${p-1}}`),m.push(`.{${p+1},}`),m.push(`(?!(?:${u})).{${p}}`),r+=`(?:${m.join("|")})`}}else r+=`(?:(?!(?:${u})).)*?`}else r+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")r+=".*";else if(i==="?")r+=".";else if(i==="["){let o=s+1,a="[";o<e.length&&(e[o]==="^"||e[o]==="!")&&(a+="^",o++),o<e.length&&e[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<e.length;){if(e[l]==="\\"&&l+1<e.length){l+=2;continue}if(e[l]==="["&&l+1<e.length&&e[l+1]===":"){let u=e.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(e[l]==="]")break;l++}let c=o;for(;o<e.length&&e[o]!=="]";){if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let u=e.indexOf(":]",o+2);if(u!==-1){let f=e.slice(o+2,u),h=$7(f);a+=h,o=u+2;continue}}if(e[o]==="\\"&&o+1<e.length){a+=`\\${e[o+1]}`,o+=2;continue}if(e[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=e[o];o++}a+="]",r+=a,s=o}else if(i==="\\"&&s+1<e.length){let o=e[s+1];/[.+^${}()|\\*?[\]]/.test(o)?r+=`\\${o}`:r+=o,s++}else/[.+^${}()|]/.test(i)?r+=`\\${i}`:r+=i}return r}computePatternLength(e){let r=0,n=0,s=!1;for(;n<e.length;){if(e.slice(n,n+13)==="\0QUOTE_START\0"){s=!0,n+=13;continue}if(e.slice(n,n+11)==="\0QUOTE_END\0"){s=!1,n+=11;continue}let i=e[n];if(s){r+=1,n++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&n+1<e.length&&e[n+1]==="("){let o=B7(e,n+1);if(o!==-1){if(i==="@"){let a=e.slice(n+2,o),c=U7(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){r+=c[0],n=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){r+=1,n++;continue}if(i==="["){let o=e.indexOf("]",n+1);if(o!==-1){r+=1,n=o+1;continue}r+=1,n++;continue}if(i==="\\"){r+=1,n+=2;continue}r+=1,n++}return r}}});function q7(t){for(let e=0;e<t.length;e++){if(t[e]==="\\"){e++;continue}if(t[e]==="$"){let r=t[e+1];if(r==="{"||r&&/[a-zA-Z_]/.test(r))return!0}}return!1}function sae(t){if(!t.operation)return!1;let e=t.operation,r;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(r=e.word?.parts),!r)return!1;for(let n of r)if(n.type==="DoubleQuoted"||n.type==="SingleQuoted")return!0;return!1}function QL(t){if(!t.operation)return!1;let e=t.operation,r;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(r=e.word?.parts),!r||r.length===0)return!1;for(let n of r)if(n.type!=="DoubleQuoted"&&n.type!=="SingleQuoted")return!1;return!0}function jf(t){let e=!1,r=!1,n=!1,s=!1,i=!1,o=!1,a=!1;for(let l of t){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(e=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(r=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(n=!0),sae(l)&&(e=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&q7(l.pattern)&&(i=!0)}return{hasQuoted:e,hasCommandSub:r,hasArrayVar:n,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var hm=I(()=>{"use strict"});function Tr(t,e){let r=`${e}_`,n=[];for(let s of t.state.env.keys())if(s.startsWith(r)){let i=s.slice(r.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&n.push(o)}return n.sort((s,i)=>s-i)}function Bi(t,e){let r=`${e}_`;for(let n of t.state.env.keys())n.startsWith(r)&&t.state.env.delete(n)}function ui(t,e){let r=`${e}_`,n=`${e}__length`,s=[];for(let i of t.state.env.keys())if(i!==n&&i.startsWith(r)){let o=i.slice(r.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function dm(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function z7(t){if(t.parts.length<2)return null;let e=t.parts[0],r=t.parts[1];if(e.type!=="Glob"||!e.pattern.startsWith("["))return null;let n,s=r,i=1;if(r.type==="Literal"&&r.value.startsWith("]")){let f=r.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))n=e.pattern.slice(1);else if(f===""){if(t.parts.length<3)return null;let h=t.parts[2];if(h.type!=="Literal"||!h.value.startsWith("=")&&!h.value.startsWith("+="))return null;n=e.pattern.slice(1),s=h,i=2}else return null}else if(e.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(t.parts.length<3)return null;let f=t.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(r.type==="SingleQuoted")n=r.value;else{n="";for(let h of r.parts)(h.type==="Literal"||h.type==="Escaped")&&(n+=h.value)}s=f,i=2}else if(e.pattern.endsWith("]")){if(r.type!=="Literal"||!r.value.startsWith("=")&&!r.value.startsWith("+="))return null;n=e.pattern.slice(1,-1)}else return null;n=dm(n);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<t.parts.length;f++){let h=t.parts[f];h.type==="BraceExpansion"?l.push({type:"Literal",value:iae(h)}):l.push(h)}return{key:n,valueParts:l,append:a}}function iae(t){return`{${t.items.map(r=>{if(r.type==="Range"){let n=r.startStr??String(r.start),s=r.endStr??String(r.end),i=`${n}..${s}`;return r.step&&(i+=`..${r.step}`),i}return Tc(r.word)}).join(",")}}`}function Tc(t){let e="";for(let r of t.parts)switch(r.type){case"Literal":e+=r.value;break;case"Glob":e+=r.pattern;break;case"SingleQuoted":e+=r.value;break;case"DoubleQuoted":for(let n of r.parts)(n.type==="Literal"||n.type==="Escaped")&&(e+=n.value);break;case"Escaped":e+=r.value;break;case"BraceExpansion":e+="{",e+=r.items.map(n=>n.type==="Range"?`${n.startStr}..${n.endStr}${n.step?`..${n.step}`:""}`:Tc(n.word)).join(","),e+="}";break;case"TildeExpansion":e+="~",r.user&&(e+=r.user);break}return e}var Hs=I(()=>{"use strict"});function Dr(t){return t.get("IFS")??`
1468
+ `&&(a+=u),o+=2):(a+=t[o],o++)}else a+=t[o],o++;o>=t.length&&s("unexpected EOF while looking for matching ``'");let c=n().parse(a);return{part:me.commandSubstitution(c,!0),endIndex:o+1}}var zL=I(()=>{"use strict";Xa()});function Dn(t,e){return new je().parse(t,e)}var je,mr=I(()=>{"use strict";Xa();vn();IL();RL();FL();$L();Yo();zL();Ya();Ya();je=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>sL)throw new Qr("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>x7)throw new Qr(`Maximum parser nesting depth exceeded (${x7})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(e,r){if(e.length>g7)throw new Qr(`Input too large: ${e.length} bytes exceeds limit of ${g7}`,1,1);this._input=e;let n=new om(e,r);if(this.tokens=n.tokenize(),this.tokens.length>y7)throw new Qr(`Too many tokens: ${this.tokens.length} exceeds limit of ${y7}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,r,n,s,...i){let o=this.tokens[this.pos]?.type;return o===e||r!==void 0&&o===r||n!==void 0&&o===n||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,r){if(this.check(e))return this.advance();let n=this.current();throw new Qr(r||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let r=this.current();throw new Qr(e,r.line,r.column,r)}skipNewlines(){for(;this.check(C.NEWLINE,C.COMMENT);)this.check(C.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(C.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(C.SEMICOLON,C.COMMENT)){this.advance();continue}if(e&&this.check(C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,r,n,s){this.pendingHeredocs.push({redirect:e,delimiter:r,stripTabs:n,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(C.HEREDOC_CONTENT)){let r=this.advance(),n;e.quoted?n=me.word([me.literal(r.value)]):n=this.parseWordFromString(r.value,!1,!1,!1,!0),e.redirect.target=me.hereDoc(e.delimiter,n,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(C.EOF,C.NEWLINE,C.SEMICOLON,C.AMP,C.AND_AND,C.OR_OR,C.RPAREN,C.RBRACE,C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===C.WORD||e===C.NAME||e===C.NUMBER||e===C.ASSIGNMENT_WORD||e===C.IF||e===C.FOR||e===C.WHILE||e===C.UNTIL||e===C.CASE||e===C.LPAREN||e===C.LBRACE||e===C.DPAREN_START||e===C.DBRACK_START||e===C.FUNCTION||e===C.BANG||e===C.TIME||e===C.IN||e===C.LESS||e===C.GREAT||e===C.DLESS||e===C.DGREAT||e===C.LESSAND||e===C.GREATAND||e===C.LESSGREAT||e===C.DLESSDASH||e===C.CLOBBER||e===C.TLESS||e===C.AND_GREAT||e===C.AND_DGREAT}parseScript(){let e=[],n=0;for(this.skipNewlines();!this.check(C.EOF);){n++,n>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){e.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&e.push(o),this.skipSeparators(!1),this.check(C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(C.EOF)&&this.advance()}return me.script(e)}checkUnexpectedToken(){let e=this.current().type,r=this.current().value;if((e===C.DO||e===C.DONE||e===C.THEN||e===C.ELSE||e===C.ELIF||e===C.FI||e===C.ESAC)&&this.error(`syntax error near unexpected token \`${r}'`),e===C.RBRACE||e===C.RPAREN){let n=`syntax error near unexpected token \`${r}'`;return this.advance(),me.statement([me.pipeline([me.simpleCommand(null,[],[],[])])],[],!1,{message:n,token:r})}return(e===C.DSEMI||e===C.SEMI_AND||e===C.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${r}'`),e===C.SEMICOLON&&this.error(`syntax error near unexpected token \`${r}'`),(e===C.PIPE||e===C.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${r}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,r=[],n=[],s=!1,i=this.parsePipeline();for(r.push(i);this.check(C.AND_AND,C.OR_OR);){let l=this.advance();n.push(l.type===C.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();r.push(c)}this.check(C.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:e,a=this._input.slice(e,o);return me.statement(r,n,s,void 0,a)}parsePipeline(){let e=!1,r=!1;this.check(C.TIME)&&(this.advance(),e=!0,this.check(C.WORD,C.NAME)&&this.current().value==="-p"&&(this.advance(),r=!0));let n=0;for(;this.check(C.BANG);)this.advance(),n++;let s=n%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(C.PIPE,C.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===C.PIPE_AMP);let c=this.parseCommand();i.push(c)}return me.pipeline(i,s,e,r,o.length>0?o:void 0)}parseCommand(){return this.check(C.IF)?N7(this):this.check(C.FOR)?k7(this):this.check(C.WHILE)?T7(this):this.check(C.UNTIL)?_7(this):this.check(C.CASE)?O7(this):this.check(C.LPAREN)?I7(this):this.check(C.LBRACE)?R7(this):this.check(C.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(C.DBRACK_START)?this.parseConditionalCommand():this.check(C.FUNCTION)?this.parseFunctionDef():this.check(C.NAME,C.WORD)&&this.peek(1).type===C.LPAREN&&this.peek(2).type===C.RPAREN?this.parseFunctionDef():OL(this)}dparenClosesWithSpacedParens(){let e=1,r=1;for(;r<this.tokens.length-this.pos;){let n=this.peek(r);if(n.type===C.EOF)return!1;if(n.type===C.DPAREN_START||n.type===C.LPAREN)e++;else if(n.type===C.DPAREN_END){if(e-=2,e<=0)return!1}else if(n.type===C.RPAREN&&(e--,e===0&&this.peek(r+1).type===C.RPAREN))return!0;r++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(C.RPAREN),this.expect(C.RPAREN);let r=this.parseOptionalRedirections(),n=me.subshell(e,[]);return me.subshell([me.statement([me.pipeline([n],!1,!1,!1)])],r)}isWord(){let e=this.current().type;return e===C.WORD||e===C.NAME||e===C.NUMBER||e===C.IF||e===C.FOR||e===C.WHILE||e===C.UNTIL||e===C.CASE||e===C.FUNCTION||e===C.ELSE||e===C.ELIF||e===C.FI||e===C.THEN||e===C.DO||e===C.DONE||e===C.ESAC||e===C.IN||e===C.SELECT||e===C.TIME||e===C.COPROC||e===C.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordNoBraceExpansion(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0)}parseWordForRegex(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0,!0)}parseWordFromString(e,r=!1,n=!1,s=!1,i=!1,o=!1,a=!1){let l=Xo(this,e,r,n,s,i,!1,o,a);return me.word(l)}parseCommandSubstitution(e,r){return UL(e,r,()=>new t,n=>this.error(n))}parseBacktickSubstitution(e,r,n=!1){return qL(e,r,n,()=>new t,s=>this.error(s))}isDollarDparenSubshell(e,r){return BL(e,r)}parseArithmeticExpansion(e,r){let n=r+3,s=1,i=0,o=n;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(n,o),l=this.parseArithmeticExpression(a);return{part:me.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let e=this.expect(C.DPAREN_START),r="",n=1,s=0,i=!1,o=!1;for(;n>0&&!this.check(C.EOF);){if(i){if(i=!1,s>0){s--,r+=")";continue}if(this.check(C.RPAREN)){n--,o=!0,this.advance();continue}if(this.check(C.DPAREN_END)){n--,o=!0;continue}r+=")";continue}if(this.check(C.DPAREN_START))n++,r+="((",this.advance();else if(this.check(C.DPAREN_END))s>=2?(s-=2,r+="))",this.advance()):s===1?(s--,r+=")",i=!0,this.advance()):(n--,o=!0,n>0&&(r+="))"),this.advance());else if(this.check(C.LPAREN))s++,r+="(",this.advance();else if(this.check(C.RPAREN))s>0&&s--,r+=")",this.advance();else{let c=this.current().value,u=r.length>0?r[r.length-1]:"";r.length>0&&!r.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(r))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(r+=" "),r+=c,this.advance()}}o||this.expect(C.DPAREN_END);let a=this.parseArithmeticExpression(r.trim()),l=this.parseOptionalRedirections();return me.arithmeticCommand(a,l,e.line)}parseConditionalCommand(){let e=this.expect(C.DBRACK_START),r=D7(this);this.expect(C.DBRACK_END);let n=this.parseOptionalRedirections();return me.conditionalCommand(r,n,e.line)}parseFunctionDef(){let e;if(this.check(C.FUNCTION)){if(this.advance(),this.check(C.NAME)||this.check(C.WORD))e=this.advance().value;else{let s=this.current();throw new Qr("Expected function name",s.line,s.column,s)}this.check(C.LPAREN)&&(this.advance(),this.expect(C.RPAREN))}else e=this.advance().value,e.includes("$")&&this.error(`\`${e}': not a valid identifier`),this.expect(C.LPAREN),this.expect(C.RPAREN);this.skipNewlines();let r=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return me.functionDef(e,r,n)}parseCompoundCommandBody(e){let r=e?.forFunctionBody;if(this.check(C.LBRACE))return R7(this,{skipRedirections:r});if(this.check(C.LPAREN))return I7(this,{skipRedirections:r});if(this.check(C.IF))return N7(this,{skipRedirections:r});if(this.check(C.FOR))return k7(this,{skipRedirections:r});if(this.check(C.WHILE))return T7(this,{skipRedirections:r});if(this.check(C.UNTIL))return _7(this,{skipRedirections:r});if(this.check(C.CASE))return O7(this,{skipRedirections:r});this.error("Expected compound command for function body")}parseCompoundList(){let e=this.enterDepth(),r=[];for(this.skipNewlines();!this.check(C.EOF,C.FI,C.ELSE,C.ELIF,C.THEN,C.DO,C.DONE,C.ESAC,C.RPAREN,C.RBRACE,C.DSEMI,C.SEMI_AND,C.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,s=this.parseStatement();if(s&&r.push(s),this.skipSeparators(),this.pos===n&&!s)break}return e(),r}parseOptionalRedirections(){let e=[];for(;cm(this);){this.checkIterationLimit();let r=this.pos;if(e.push(um(this)),this.pos===r)break}return e}parseArithmeticExpression(e){return mt(this,e)}}});function $7(t){return nae.get(t)??""}function KL(t){let e=[],r="",n=0;for(;n<t.length;){let s=t[n];if(s==="["){for(r+=s,n++,n<t.length&&(t[n]==="!"||t[n]==="^")&&(r+=t[n],n++),n<t.length&&t[n]==="]"&&(r+=t[n],n++);n<t.length&&t[n]!=="]";){if(t[n]==="["&&n+1<t.length&&t[n+1]===":"){let i=t.indexOf(":]",n+2);if(i!==-1){r+=t.slice(n,i+2),n=i+2;continue}}if(t[n]==="\\"&&n+1<t.length){r+=t[n]+t[n+1],n+=2;continue}r+=t[n],n++}n<t.length&&t[n]==="]"&&(r+=t[n],n++)}else s===":"?(r!==""&&e.push(r),r="",n++):s==="\\"&&n+1<t.length?(r+=s+t[n+1],n+=2):(r+=s,n++)}return r!==""&&e.push(r),e}function ZL(t){let e="^";for(let r=0;r<t.length;r++){let n=t[r];if(n==="*")e+="[^/]*";else if(n==="?")e+="[^/]";else if(n==="["){let s=r+1,i="[";s<t.length&&(t[s]==="^"||t[s]==="!")&&(i+="^",s++),s<t.length&&t[s]==="]"&&(i+="\\]",s++);let o=s;for(;o<t.length;){if(t[o]==="\\"&&o+1<t.length){o+=2;continue}if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let l=t.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(t[o]==="]")break;o++}let a=s;for(;s<t.length&&t[s]!=="]";){if(t[s]==="["&&s+1<t.length&&t[s+1]===":"){let l=t.indexOf(":]",s+2);if(l!==-1){let c=t.slice(s+2,l),u=$7(c);i+=u,s=l+2;continue}}if(t[s]==="\\"&&s+1<t.length){i+=`\\${t[s+1]}`,s+=2;continue}if(t[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=t[s];s++}i+="]",e+=i,r=s}else if(n==="\\"&&r+1<t.length){let s=t[r+1];/[.+^${}()|\\*?[\]]/.test(s)?e+=`\\${s}`:e+=s,r++}else/[.+^${}()|]/.test(n)?e+=`\\${n}`:e+=n}return e+="$",ae(e)}function B7(t,e){let r=1,n=e+1;for(;n<t.length&&r>0;){let s=t[n];if(s==="\\"){n+=2;continue}if(s==="(")r++;else if(s===")"&&(r--,r===0))return n;n++}return-1}function U7(t){let e=[],r="",n=0,s=!1,i=0;for(;i<t.length;){let o=t[i];if(o==="'"&&!s){s=!0,r+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,r+="\0QUOTE_END\0",i++;continue}if(s){r+=o,i++;continue}if(o==="\\"){r+=o,i+1<t.length?(r+=t[i+1],i+=2):i++;continue}o==="("?(n++,r+=o):o===")"?(n--,r+=o):o==="|"&&n===0?(e.push(r),r=""):r+=o,i++}return e.push(r),e}var nae,YL=I(()=>{"use strict";Gt();nae=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9a-fA-F"]])});var XL,Qo,fm=I(()=>{"use strict";rt();Gt();fl();YL();XL=5,Qo=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(e,r,n,s){this.fs=e,this.cwd=r,typeof s=="boolean"?(this.globstar=s,this.maxOps=1e5):s?(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0,this.maxOps=s.maxGlobOperations??1e5):this.maxOps=1e5;let i=n?.get("GLOBIGNORE");i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=KL(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new he(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(r=>{let n=r.split("/").pop()||r;if((this.hasGlobignore||this.globskipdots)&&(n==="."||n===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(r,s))return!1}return!0})}matchGlobignorePattern(e,r){return ZL(r).test(e)}isGlobPattern(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,r){let n=e.map((o,a)=>(r?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(n.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<e.length;o++){let a=s[o];a===null?i.push(e[o]):a.length>0?i.push(...a):i.push(e[o])}return i}async expand(e){if(this.globstar){let n=e.split("/"),s=0;for(let i of n)if(i==="**"&&(s++,s>XL))throw new he(`Glob pattern has too many ** segments (max ${XL})`,"glob_operations")}let r;if(e.includes("**")&&this.globstar&&this.isGlobstarValid(e))r=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,"*");r=await this.expandSimple(n)}return this.filterGlobignore(r)}isGlobstarValid(e){let r=e.split("/");for(let n of r)if(n.includes("**")&&n!=="**")return!1;return!0}hasGlobChars(e){return!!(e.includes("*")||e.includes("?")||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let r=e.startsWith("/"),n=e.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<n.length;c++)if(this.hasGlobChars(n[c])){s=c;break}if(s===-1)return[e];let i,o;if(s===0)r?(i="/",o="/"):(i=this.cwd,o="");else{let c=n.slice(0,s);r?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=n.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(e,r,n){if(this.checkOpsLimit(),n.length===0)return[r];let[s,...i]=n,o=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let h=a.some(p=>p.name==="."),d=a.some(p=>p.name==="..");h||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),d||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h.name,s)){let d=e==="/"?`/${h.name}`:`${e}/${h.name}`,p;r===""?p=h.name:r==="/"?p=`/${h.name}`:p=`${r}/${h.name}`,i.length===0?l.push(Promise.resolve([p])):h.isDirectory&&l.push(this.expandSegments(d,p,i))}let f=await Promise.all(l);for(let h of f)o.push(...h)}else{this.checkOpsLimit();let a=await this.fs.readdir(e),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h,s)){let d=e==="/"?`/${h}`:`${e}/${h}`,p;r===""?p=h:r==="/"?p=`/${h}`:p=`${r}/${h}`,i.length===0?l.push(Promise.resolve([p])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(d)).isDirectory)return this.expandSegments(d,p,i)}catch(m){if(m instanceof he)throw m}return[]})())}let f=await Promise.all(l);for(let h of f)o.push(...h)}}catch(a){if(a instanceof he)throw a}return o}async expandRecursive(e){let r=[],n=e.indexOf("**"),s=e.slice(0,n).replace(/\/$/,"")||".",o=e.slice(n+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,r),[...new Set(r)].sort()):(await this.walkDirectory(s,o,r),r.sort())}async walkDirectoryMultiGlobstar(e,r,n){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=e==="."?c.name:`${e}/${c.name}`;c.isDirectory&&o.push(u)}let a=e==="."?r:`${e}/${r}`,l=await this.expandRecursive(a);n.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,r,n)))}}else{this.checkOpsLimit();let o=await this.fs.readdir(s),a=[];for(let u of o){let f=e==="."?u:`${e}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&a.push(f)}catch(d){if(d instanceof he)throw d}}let l=e==="."?r:`${e}/${r}`,c=await this.expandRecursive(l);n.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,r,n)))}}}catch(i){if(i instanceof he)throw i}}async walkDirectory(e,r,n){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=e==="."?l.name:`${e}/${l.name}`;l.isDirectory?a.push(c):r&&this.matchPattern(l.name,r)&&o.push(c)}n.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,r,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let h=e==="."?f:`${e}/${f}`,d=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let p=await this.fs.stat(d);return{name:f,path:h,isDirectory:p.isDirectory}}catch(p){if(p instanceof he)throw p;return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&r&&this.matchPattern(l.name,r)&&n.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,r,n)))}}}catch(i){if(i instanceof he)throw i}}matchPattern(e,r){return this.patternToRegex(r).test(e)}patternToRegex(e){let r=this.patternToRegexStr(e);return ae(`^${r}$`)}patternToRegexStr(e){let r="",n=!1;for(let s=0;s<e.length;s++){if(e.slice(s,s+13)==="\0QUOTE_START\0"){n=!0,s+=12;continue}if(e.slice(s,s+11)==="\0QUOTE_END\0"){n=!1,s+=10;continue}let i=e[s];if(n){/[.+^${}()|\\*?[\]]/.test(i)?r+=`\\${i}`:r+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<e.length&&e[s+1]==="("){let o=B7(e,s+1);if(o!==-1){let a=e.slice(s+2,o),l=U7(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")r+=`(?:${u})`;else if(i==="*")r+=`(?:${u})*`;else if(i==="+")r+=`(?:${u})+`;else if(i==="?")r+=`(?:${u})?`;else if(i==="!")if(o<e.length-1){let h=l.map(p=>this.computePatternLength(p));if(h.every(p=>p!==null)&&h.every(p=>p===h[0])&&h[0]!==null){let p=h[0];if(p===0)r+="(?:.+)";else{let m=[];p>0&&m.push(`.{0,${p-1}}`),m.push(`.{${p+1},}`),m.push(`(?!(?:${u})).{${p}}`),r+=`(?:${m.join("|")})`}}else r+=`(?:(?!(?:${u})).)*?`}else r+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")r+=".*";else if(i==="?")r+=".";else if(i==="["){let o=s+1,a="[";o<e.length&&(e[o]==="^"||e[o]==="!")&&(a+="^",o++),o<e.length&&e[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<e.length;){if(e[l]==="\\"&&l+1<e.length){l+=2;continue}if(e[l]==="["&&l+1<e.length&&e[l+1]===":"){let u=e.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(e[l]==="]")break;l++}let c=o;for(;o<e.length&&e[o]!=="]";){if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let u=e.indexOf(":]",o+2);if(u!==-1){let f=e.slice(o+2,u),h=$7(f);a+=h,o=u+2;continue}}if(e[o]==="\\"&&o+1<e.length){a+=`\\${e[o+1]}`,o+=2;continue}if(e[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=e[o];o++}a+="]",r+=a,s=o}else if(i==="\\"&&s+1<e.length){let o=e[s+1];/[.+^${}()|\\*?[\]]/.test(o)?r+=`\\${o}`:r+=o,s++}else/[.+^${}()|]/.test(i)?r+=`\\${i}`:r+=i}return r}computePatternLength(e){let r=0,n=0,s=!1;for(;n<e.length;){if(e.slice(n,n+13)==="\0QUOTE_START\0"){s=!0,n+=13;continue}if(e.slice(n,n+11)==="\0QUOTE_END\0"){s=!1,n+=11;continue}let i=e[n];if(s){r+=1,n++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&n+1<e.length&&e[n+1]==="("){let o=B7(e,n+1);if(o!==-1){if(i==="@"){let a=e.slice(n+2,o),c=U7(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){r+=c[0],n=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){r+=1,n++;continue}if(i==="["){let o=e.indexOf("]",n+1);if(o!==-1){r+=1,n=o+1;continue}r+=1,n++;continue}if(i==="\\"){r+=1,n+=2;continue}r+=1,n++}return r}}});function q7(t){for(let e=0;e<t.length;e++){if(t[e]==="\\"){e++;continue}if(t[e]==="$"){let r=t[e+1];if(r==="{"||r&&/[a-zA-Z_]/.test(r))return!0}}return!1}function sae(t){if(!t.operation)return!1;let e=t.operation,r;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(r=e.word?.parts),!r)return!1;for(let n of r)if(n.type==="DoubleQuoted"||n.type==="SingleQuoted")return!0;return!1}function QL(t){if(!t.operation)return!1;let e=t.operation,r;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(r=e.word?.parts),!r||r.length===0)return!1;for(let n of r)if(n.type!=="DoubleQuoted"&&n.type!=="SingleQuoted")return!1;return!0}function jf(t){let e=!1,r=!1,n=!1,s=!1,i=!1,o=!1,a=!1;for(let l of t){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(e=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(r=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(n=!0),sae(l)&&(e=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&q7(l.pattern)&&(i=!0)}return{hasQuoted:e,hasCommandSub:r,hasArrayVar:n,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var hm=I(()=>{"use strict"});function Tr(t,e){let r=`${e}_`,n=[];for(let s of t.state.env.keys())if(s.startsWith(r)){let i=s.slice(r.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&n.push(o)}return n.sort((s,i)=>s-i)}function Bi(t,e){let r=`${e}_`;for(let n of t.state.env.keys())n.startsWith(r)&&t.state.env.delete(n)}function ui(t,e){let r=`${e}_`,n=`${e}__length`,s=[];for(let i of t.state.env.keys())if(i!==n&&i.startsWith(r)){let o=i.slice(r.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function dm(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function z7(t){if(t.parts.length<2)return null;let e=t.parts[0],r=t.parts[1];if(e.type!=="Glob"||!e.pattern.startsWith("["))return null;let n,s=r,i=1;if(r.type==="Literal"&&r.value.startsWith("]")){let f=r.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))n=e.pattern.slice(1);else if(f===""){if(t.parts.length<3)return null;let h=t.parts[2];if(h.type!=="Literal"||!h.value.startsWith("=")&&!h.value.startsWith("+="))return null;n=e.pattern.slice(1),s=h,i=2}else return null}else if(e.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(t.parts.length<3)return null;let f=t.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(r.type==="SingleQuoted")n=r.value;else{n="";for(let h of r.parts)(h.type==="Literal"||h.type==="Escaped")&&(n+=h.value)}s=f,i=2}else if(e.pattern.endsWith("]")){if(r.type!=="Literal"||!r.value.startsWith("=")&&!r.value.startsWith("+="))return null;n=e.pattern.slice(1,-1)}else return null;n=dm(n);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<t.parts.length;f++){let h=t.parts[f];h.type==="BraceExpansion"?l.push({type:"Literal",value:iae(h)}):l.push(h)}return{key:n,valueParts:l,append:a}}function iae(t){return`{${t.items.map(r=>{if(r.type==="Range"){let n=r.startStr??String(r.start),s=r.endStr??String(r.end),i=`${n}..${s}`;return r.step&&(i+=`..${r.step}`),i}return Tc(r.word)}).join(",")}}`}function Tc(t){let e="";for(let r of t.parts)switch(r.type){case"Literal":e+=r.value;break;case"Glob":e+=r.pattern;break;case"SingleQuoted":e+=r.value;break;case"DoubleQuoted":for(let n of r.parts)(n.type==="Literal"||n.type==="Escaped")&&(e+=n.value);break;case"Escaped":e+=r.value;break;case"BraceExpansion":e+="{",e+=r.items.map(n=>n.type==="Range"?`${n.startStr}..${n.endStr}${n.step?`..${n.step}`:""}`:Tc(n.word)).join(","),e+="}";break;case"TildeExpansion":e+="~",r.user&&(e+=r.user);break}return e}var Hs=I(()=>{"use strict"});function Dr(t){return t.get("IFS")??`
1469
1469
  `}function dn(t){return t.get("IFS")===""}function pm(t){let e=Dr(t);if(e==="")return!0;for(let r of e)if(r!==" "&&r!==" "&&r!==`
1470
1470
  `)return!1;return!0}function JL(t){let e=!1,r=[];for(let n of t.split(""))n==="-"?e=!0:/[\\^$.*+?()[\]{}|]/.test(n)?r.push(`\\${n}`):n===" "?r.push("\\t"):n===`
1471
1471
  `?r.push("\\n"):r.push(n);return e&&r.push("\\-"),r.join("")}function Ye(t){let e=t.get("IFS");return e===void 0?" ":e[0]||""}function aae(t){return oae.includes(t)}function H7(t){let e=new Set,r=new Set;for(let n of t)aae(n)?e.add(n):r.add(n);return{whitespace:e,nonWhitespace:r}}function W7(t,e,r,n){if(e==="")return t===""?{words:[],wordStarts:[]}:{words:[t],wordStarts:[0]};let{whitespace:s,nonWhitespace:i}=H7(e),o=[],a=[],l=0;for(;l<t.length&&s.has(t[l]);)l++;if(l>=t.length)return{words:[],wordStarts:[]};if(i.has(t[l]))for(o.push(""),a.push(l),l++;l<t.length&&s.has(t[l]);)l++;for(;l<t.length&&!(r!==void 0&&o.length>=r);){let c=l;for(a.push(c);l<t.length;){let u=t[l];if(!n&&u==="\\"){l++,l<t.length&&l++;continue}if(s.has(u)||i.has(u))break;l++}if(o.push(t.substring(c,l)),l>=t.length)break;for(;l<t.length&&s.has(t[l]);)l++;if(l<t.length&&i.has(t[l])){for(l++;l<t.length&&s.has(t[l]);)l++;for(;l<t.length&&i.has(t[l])&&!(r!==void 0&&o.length>=r);)for(o.push(""),a.push(l),l++;l<t.length&&s.has(t[l]);)l++}}return{words:o,wordStarts:a}}function mm(t,e){if(e==="")return{words:t?[t]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(t==="")return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:r,nonWhitespace:n}=H7(e),s=[],i=0,o=!1,a=!1,l=i;for(;i<t.length&&r.has(t[i]);)i++;if(i>l&&(o=!0),i>=t.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(n.has(t[i]))for(s.push(""),i++;i<t.length&&r.has(t[i]);)i++;for(;i<t.length;){let c=i;for(;i<t.length;){let f=t[i];if(r.has(f)||n.has(f))break;i++}if(s.push(t.substring(c,i)),i>=t.length){a=!1;break}let u=i;for(;i<t.length&&r.has(t[i]);)i++;if(i<t.length&&n.has(t[i])){for(i++;i<t.length&&r.has(t[i]);)i++;for(;i<t.length&&n.has(t[i]);)for(s.push(""),i++;i<t.length&&r.has(t[i]);)i++}i>=t.length&&i>u&&(a=!0)}return{words:s,hadLeadingDelimiter:o,hadTrailingDelimiter:a}}function Yt(t,e){return mm(t,e).words}function lae(t,e){for(let r of t)if(e.has(r))return!0;return!1}function eF(t,e,r){if(e==="")return t;let{whitespace:n,nonWhitespace:s}=H7(e),i=t.length;for(;i>0&&n.has(t[i-1]);){if(!r&&i>=2){let a=0,l=i-2;for(;l>=0&&t[l]==="\\";)a++,l--;if(a%2===1)break}i--}let o=t.substring(0,i);if(o.length>=1&&s.has(o[o.length-1])){if(!r&&o.length>=2){let l=0,c=o.length-2;for(;c>=0&&o[c]==="\\";)l++,c--;if(l%2===1)return o}let a=o.substring(0,o.length-1);if(!lae(a,s))return a}return o}var oae,Ss=I(()=>{"use strict";oae=`
@@ -1475,19 +1475,19 @@ Gid: ${s} ${s} ${s} ${s}
1475
1475
  `,n+=2;break;case"r":r+="\r",n+=2;break;case"$":r+="$",n+=2;break;case"[":case"]":n+=2;break;case"u":r+=s,n+=2;break;case"h":r+=o,n+=2;break;case"H":r+=i,n+=2;break;case"w":r+=c,n+=2;break;case"W":r+=u,n+=2;break;case"d":{let y=String(f.getDate()).padStart(2," ");r+=`${h[f.getDay()]} ${d[f.getMonth()]} ${y}`,n+=2;break}case"t":{let y=String(f.getHours()).padStart(2,"0"),x=String(f.getMinutes()).padStart(2,"0"),b=String(f.getSeconds()).padStart(2,"0");r+=`${y}:${x}:${b}`,n+=2;break}case"T":{let y=f.getHours()%12;y===0&&(y=12);let x=String(y).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),w=String(f.getSeconds()).padStart(2,"0");r+=`${x}:${b}:${w}`,n+=2;break}case"@":{let y=f.getHours()%12;y===0&&(y=12);let x=String(y).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),w=f.getHours()<12?"AM":"PM";r+=`${x}:${b} ${w}`,n+=2;break}case"A":{let y=String(f.getHours()).padStart(2,"0"),x=String(f.getMinutes()).padStart(2,"0");r+=`${y}:${x}`,n+=2;break}case"D":if(n+2<e.length&&e[n+2]==="{"){let y=e.indexOf("}",n+3);if(y!==-1){let x=e.slice(n+3,y);r+=xae(x,f),n=y+1}else r+="\\D",n+=2}else r+="\\D",n+=2;break;case"s":r+="bash",n+=2;break;case"v":r+="5.0",n+=2;break;case"V":r+="5.0.0",n+=2;break;case"j":r+="0",n+=2;break;case"l":r+="tty",n+=2;break;case"#":r+=p,n+=2;break;case"!":r+=p,n+=2;break;case"x":r+="\\x",n+=2;break;default:r+=`\\${g}`,n+=2}}else r+=m,n++}return r}var Z7=I(()=>{"use strict"});function Jo(t){if(t==="")return"''";if(/[\n\r\t\x00-\x1f\x7f']/.test(t)){let r="$'";for(let n of t)switch(n){case"'":r+="\\'";break;case"\\":r+="\\\\";break;case`
1476
1476
  `:r+="\\n";break;case"\r":r+="\\r";break;case" ":r+="\\t";break;default:{let s=n.charCodeAt(0);s<32||s===127?r+=`\\${s.toString(8).padStart(3,"0")}`:r+=n}}return`${r}'`}return`'${t}'`}var Y7=I(()=>{"use strict"});function cs(t,e){t.state.readonlyVars=t.state.readonlyVars||new Set,t.state.readonlyVars.add(e)}function zi(t,e){return t.state.readonlyVars?.has(e)??!1}function Ur(t,e,r="bash"){if(zi(t,e)){let n=`${r}: ${e}: readonly variable
1477
1477
  `;throw new Xe(1,"",n)}return null}function hi(t,e){let r=t.state.exportedVars?.has(e)??!1;if(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(e),t.state.localScopes.length>0&&t.state.localScopes[t.state.localScopes.length-1].has(e)&&!r){for(t.state.localExportedVars||(t.state.localExportedVars=[]);t.state.localExportedVars.length<t.state.localScopes.length;)t.state.localExportedVars.push(new Set);t.state.localExportedVars[t.state.localExportedVars.length-1].add(e)}}function xm(t,e){t.state.exportedVars?.delete(e)}var ea=I(()=>{"use strict";rt()});function ta(t,e){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))return"";let r="",n=t.state.env.has(`${e}__length`)||Array.from(t.state.env.keys()).some(i=>i.startsWith(`${e}_`)&&/^[0-9]+$/.test(i.slice(e.length+1))),s=t.state.associativeArrays?.has(e)??!1;return n&&!s&&(r+="a"),s&&(r+="A"),t.state.integerVars?.has(e)&&(r+="i"),Bt(t,e)&&(r+="n"),zi(t,e)&&(r+="r"),t.state.exportedVars?.has(e)&&(r+="x"),r}var bm=I(()=>{"use strict";fi();ea()});async function uF(t,e,r,n){return t.coverage?.hit("bash:expansion:default_value"),(r.isUnset||e.checkEmpty&&r.isEmpty)&&e.word?n(t,e.word.parts,r.inDoubleQuotes):r.effectiveValue}async function fF(t,e,r,n,s){if(t.coverage?.hit("bash:expansion:assign_default"),(n.isUnset||r.checkEmpty&&n.isEmpty)&&r.word){let o=await s(t,r.word.parts,n.inDoubleQuotes),a=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,l,c]=a,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let h=new je,d=mt(h,c);u=await be(t,d.expression)}catch{let h=t.state.env.get(c);u=h?Number.parseInt(h,10):0}Number.isNaN(u)&&(u=0)}t.state.env.set(`${l}_${u}`,o);let f=Number.parseInt(t.state.env.get(`${l}__length`)||"0",10);u>=f&&t.state.env.set(`${l}__length`,String(u+1))}else t.state.env.set(e,o);return o}return n.effectiveValue}async function hF(t,e,r,n,s){if(t.coverage?.hit("bash:expansion:error_if_unset"),n.isUnset||r.checkEmpty&&n.isEmpty){let o=r.word?await s(t,r.word.parts,n.inDoubleQuotes):`${e}: parameter null or not set`;throw new Xe(1,"",`bash: ${o}
1478
- `)}return n.effectiveValue}async function dF(t,e,r,n){return t.coverage?.hit("bash:expansion:use_alternative"),!(r.isUnset||e.checkEmpty&&r.isEmpty)&&e.word?n(t,e.word.parts,r.inDoubleQuotes):""}async function pF(t,e,r,n,s){t.coverage?.hit("bash:expansion:pattern_removal");let i="",o=t.state.shoptOptions.extglob;if(r.pattern)for(let l of r.pattern.parts)if(l.type==="Glob")i+=st(l.pattern,r.greedy,o);else if(l.type==="Literal")i+=st(l.value,r.greedy,o);else if(l.type==="SingleQuoted"||l.type==="Escaped")i+=ut(l.value);else if(l.type==="DoubleQuoted"){let c=await n(t,l.parts);i+=ut(c)}else if(l.type==="ParameterExpansion"){let c=await s(t,l);i+=st(c,r.greedy,o)}else{let c=await s(t,l);i+=ut(c)}if(r.side==="prefix")return ae(`^${i}`,"s").replace(e,"");let a=ae(`${i}$`,"s");if(r.greedy)return a.replace(e,"");for(let l=e.length;l>=0;l--){let c=e.slice(l);if(a.test(c))return e.slice(0,l)}return e}async function mF(t,e,r,n,s){t.coverage?.hit("bash:expansion:pattern_replacement");let i="",o=t.state.shoptOptions.extglob;if(r.pattern)for(let c of r.pattern.parts)if(c.type==="Glob")i+=st(c.pattern,!0,o);else if(c.type==="Literal")i+=st(c.value,!0,o);else if(c.type==="SingleQuoted"||c.type==="Escaped")i+=ut(c.value);else if(c.type==="DoubleQuoted"){let u=await n(t,c.parts);i+=ut(u)}else if(c.type==="ParameterExpansion"){let u=await s(t,c);i+=st(u,!0,o)}else{let u=await s(t,c);i+=ut(u)}let a=r.replacement?await n(t,r.replacement.parts):"";if(r.anchor==="start"?i=`^${i}`:r.anchor==="end"&&(i=`${i}$`),i==="")return e;let l=r.all?"gs":"s";try{let c=ae(i,l);if(r.all){let u="",f=0,h=0,d=t.limits.maxStringLength,p=c.exec(e);for(;p!==null&&!(p[0].length===0&&p.index===e.length);){if(u+=e.slice(f,p.index)+a,f=p.index+p[0].length,p[0].length===0&&f++,h++,h%100===0&&u.length>d)throw new fe(`pattern replacement: string length limit exceeded (${d} bytes)`,"string_length");p=c.exec(e)}return u+=e.slice(f),u}return c.replace(e,a)}catch(c){if(c instanceof fe)throw c;return e}}function gF(t,e,r){t.coverage?.hit("bash:expansion:length");let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(n){let s=n[1],i=De(t,s);return i.length>0?String(i.length):t.state.env.get(s)!==void 0?"1":"0"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)&&co(t,e)){if(e==="FUNCNAME"){let i=t.state.funcNameStack?.[0]||"";return String([...i].length)}if(e==="BASH_LINENO"){let i=t.state.callLineStack?.[0];return String(i!==void 0?[...String(i)].length:0)}let s=t.state.env.get(`${e}_0`)||"";return String([...s].length)}return String([...r].length)}async function yF(t,e,r,n){t.coverage?.hit("bash:expansion:substring");let s=await be(t,n.offset.expression),i=n.length?await be(t,n.length.expression):void 0;if(e==="@"||e==="*"){let c=Number.parseInt(t.state.env.get("#")||"0",10),u=[];for(let p=1;p<=c;p++)u.push(t.state.env.get(String(p))||"");let f=t.state.env.get("0")||"bash",h,d;if(s<=0)if(h=[f,...u],s<0){if(d=h.length+s,d<0)return""}else d=0;else h=u,d=s-1;if(d<0||d>=h.length)return"";if(i!==void 0){let p=i<0?h.length+i:d+i;return h.slice(d,Math.max(d,p)).join(" ")}return h.slice(d).join(" ")}let o=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let c=o[1];if(t.state.associativeArrays?.has(c))throw new Xe(1,"",`bash: \${${c}[@]: 0: 3}: bad substitution
1478
+ `)}return n.effectiveValue}async function dF(t,e,r,n){return t.coverage?.hit("bash:expansion:use_alternative"),!(r.isUnset||e.checkEmpty&&r.isEmpty)&&e.word?n(t,e.word.parts,r.inDoubleQuotes):""}async function pF(t,e,r,n,s){t.coverage?.hit("bash:expansion:pattern_removal");let i="",o=t.state.shoptOptions.extglob;if(r.pattern)for(let l of r.pattern.parts)if(l.type==="Glob")i+=st(l.pattern,r.greedy,o);else if(l.type==="Literal")i+=st(l.value,r.greedy,o);else if(l.type==="SingleQuoted"||l.type==="Escaped")i+=ut(l.value);else if(l.type==="DoubleQuoted"){let c=await n(t,l.parts);i+=ut(c)}else if(l.type==="ParameterExpansion"){let c=await s(t,l);i+=st(c,r.greedy,o)}else{let c=await s(t,l);i+=ut(c)}if(r.side==="prefix")return ae(`^${i}`,"s").replace(e,"");let a=ae(`${i}$`,"s");if(r.greedy)return a.replace(e,"");for(let l=e.length;l>=0;l--){let c=e.slice(l);if(a.test(c))return e.slice(0,l)}return e}async function mF(t,e,r,n,s){t.coverage?.hit("bash:expansion:pattern_replacement");let i="",o=t.state.shoptOptions.extglob;if(r.pattern)for(let c of r.pattern.parts)if(c.type==="Glob")i+=st(c.pattern,!0,o);else if(c.type==="Literal")i+=st(c.value,!0,o);else if(c.type==="SingleQuoted"||c.type==="Escaped")i+=ut(c.value);else if(c.type==="DoubleQuoted"){let u=await n(t,c.parts);i+=ut(u)}else if(c.type==="ParameterExpansion"){let u=await s(t,c);i+=st(u,!0,o)}else{let u=await s(t,c);i+=ut(u)}let a=r.replacement?await n(t,r.replacement.parts):"";if(r.anchor==="start"?i=`^${i}`:r.anchor==="end"&&(i=`${i}$`),i==="")return e;let l=r.all?"gs":"s";try{let c=ae(i,l);if(r.all){let u="",f=0,h=0,d=t.limits.maxStringLength,p=c.exec(e);for(;p!==null&&!(p[0].length===0&&p.index===e.length);){if(u+=e.slice(f,p.index)+a,f=p.index+p[0].length,p[0].length===0&&f++,h++,h%100===0&&u.length>d)throw new he(`pattern replacement: string length limit exceeded (${d} bytes)`,"string_length");p=c.exec(e)}return u+=e.slice(f),u}return c.replace(e,a)}catch(c){if(c instanceof he)throw c;return e}}function gF(t,e,r){t.coverage?.hit("bash:expansion:length");let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(n){let s=n[1],i=De(t,s);return i.length>0?String(i.length):t.state.env.get(s)!==void 0?"1":"0"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)&&co(t,e)){if(e==="FUNCNAME"){let i=t.state.funcNameStack?.[0]||"";return String([...i].length)}if(e==="BASH_LINENO"){let i=t.state.callLineStack?.[0];return String(i!==void 0?[...String(i)].length:0)}let s=t.state.env.get(`${e}_0`)||"";return String([...s].length)}return String([...r].length)}async function yF(t,e,r,n){t.coverage?.hit("bash:expansion:substring");let s=await be(t,n.offset.expression),i=n.length?await be(t,n.length.expression):void 0;if(e==="@"||e==="*"){let c=Number.parseInt(t.state.env.get("#")||"0",10),u=[];for(let p=1;p<=c;p++)u.push(t.state.env.get(String(p))||"");let f=t.state.env.get("0")||"bash",h,d;if(s<=0)if(h=[f,...u],s<0){if(d=h.length+s,d<0)return""}else d=0;else h=u,d=s-1;if(d<0||d>=h.length)return"";if(i!==void 0){let p=i<0?h.length+i:d+i;return h.slice(d,Math.max(d,p)).join(" ")}return h.slice(d).join(" ")}let o=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let c=o[1];if(t.state.associativeArrays?.has(c))throw new Xe(1,"",`bash: \${${c}[@]: 0: 3}: bad substitution
1479
1479
  `);let u=De(t,c),f=0;if(s<0){if(u.length>0){let h=u[u.length-1][0],p=(typeof h=="number"?h:0)+1+s;if(p<0||(f=u.findIndex(([m])=>typeof m=="number"&&m>=p),f<0))return""}}else if(f=u.findIndex(([h])=>typeof h=="number"&&h>=s),f<0)return"";if(i!==void 0){if(i<0)throw new It(`${o[1]}[@]: substring expression < 0`);return u.slice(f,f+i).map(([,h])=>h).join(" ")}return u.slice(f).map(([,h])=>h).join(" ")}let a=[...r],l=s;if(l<0&&(l=Math.max(0,a.length+l)),i!==void 0){if(i<0){let c=a.length+i;return a.slice(l,Math.max(l,c)).join("")}return a.slice(l,l+i).join("")}return a.slice(l).join("")}async function xF(t,e,r,n,s){if(t.coverage?.hit("bash:expansion:case_modification"),r.pattern){let i=t.state.shoptOptions.extglob,o="";for(let f of r.pattern.parts)if(f.type==="Glob")o+=st(f.pattern,!0,i);else if(f.type==="Literal")o+=st(f.value,!0,i);else if(f.type==="SingleQuoted"||f.type==="Escaped")o+=ut(f.value);else if(f.type==="DoubleQuoted"){let h=await n(t,f.parts);o+=ut(h)}else if(f.type==="ParameterExpansion"){let h=await s(t,f);o+=st(h,!0,i)}let a=ae(`^(?:${o})$`),l=r.direction==="upper"?f=>f.toUpperCase():f=>f.toLowerCase(),c="",u=!1;for(let f of e)!r.all&&u?c+=f:a.test(f)?(c+=l(f),u=!0):c+=f;return c}return r.direction==="upper"?r.all?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1):r.all?e.toLowerCase():e.charAt(0).toLowerCase()+e.slice(1)}function bF(t,e,r,n,s){t.coverage?.hit("bash:expansion:transform");let i=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(i&&s.operator==="Q")return De(t,i[1]).map(([,c])=>Jo(c)).join(" ");if(i&&s.operator==="a")return ta(t,i[1]);let o=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&s.operator==="a")return ta(t,o[1]);switch(s.operator){case"Q":return n?"":Jo(r);case"P":return Vf(t,r);case"a":return ta(t,e);case"A":return n?"":`${e}=${Jo(r)}`;case"E":return r.replace(/\\([\\abefnrtv'"?])/g,(a,l)=>{switch(l){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
1480
- `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return l}});case"K":case"k":return n?"":Jo(r);case"u":return r.charAt(0).toUpperCase()+r.slice(1);case"U":return r.toUpperCase();case"L":return r.toLowerCase();default:return r}}async function wF(t,e,r,n,s,i,o=!1){if(t.coverage?.hit("bash:expansion:indirection"),Bt(t,e))return Ja(t,e)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(e);if(n){if(s.innerOp?.type==="UseAlternative")return"";throw new kn(`\${!${e}}`)}let l=r;if(a&&(l===""||l.includes(" ")))throw new kn(`\${!${e}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new kn(`\${!${e}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(t,u,o)}return await gt(t,l)}function EF(t,e){t.coverage?.hit("bash:expansion:array_keys");let n=De(t,e.array).map(([s])=>String(s));return e.star?n.join(Ye(t.state.env)):n.join(" ")}function SF(t,e){t.coverage?.hit("bash:expansion:var_name_prefix");let r=Pc(t,e.prefix);return e.star?r.join(Ye(t.state.env)):r.join(" ")}function vF(t,e,r,n){let s=Number.parseInt(t.state.env.get("#")||"0",10),i=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(e==="*")return{isEmpty:s===0,effectiveValue:r};if(e==="@")return{isEmpty:s===0||s===1&&t.state.env.get("1")==="",effectiveValue:r};if(i){let[,o,a]=i,l=De(t,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=Ye(t.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:n?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:r==="",effectiveValue:r}}var AF=I(()=>{"use strict";vn();mr();Gt();Fn();rt();Ss();fi();Ic();Rc();el();Z7();Y7();as();bm()});function CF(t){let e=0;for(;e<t.length;){let r=t[e];if(r==="\\"&&e+1<t.length){e+=2;continue}if(r==="'"){let n=t.indexOf("'",e+1);if(n!==-1){e=n+1;continue}}if(r==="$"&&e+1<t.length&&t[e+1]==="("||r==="`")return!0;e++}return!1}function NF(t,e){let r=1,n=e,s=!1,i=!1;for(;n<t.length&&r>0;){let o=t[n];if(o==="\\"&&!s&&n+1<t.length){n+=2;continue}if(o==="'"&&!i){s=!s,n++;continue}if(o==='"'&&!s){i=!i,n++;continue}if(!s&&!i){if(o==="(")r++;else if(o===")"&&(r--,r===0))return n}n++}return-1}async function wm(t,e){let r=new je,n;try{n=r.parse(e)}catch{return""}let s=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let i=new Map(t.state.env),o=t.state.cwd,a=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let l=await t.executeScript(n),c=l.exitCode;return t.state.env=i,t.state.cwd=o,t.state.suppressVerbose=a,t.state.lastExitCode=c,t.state.env.set("?",String(c)),l.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+l.stderr),t.state.bashPid=s,l.stdout.replace(/\n+$/,"")}catch(l){if(t.state.env=i,t.state.cwd=o,t.state.bashPid=s,t.state.suppressVerbose=a,l instanceof fe)throw l;return l instanceof Xe?(t.state.lastExitCode=l.exitCode,t.state.env.set("?",String(l.exitCode)),l.stdout?.replace(/\n+$/,"")??""):""}}function X7(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="'"){let i=e.indexOf("'",n+1);if(i!==-1){let o=e.slice(n+1,i);r+=ls(o),n=i+1;continue}}if(s==='"'){let i=-1,o=n+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(n+1,i),l=bae(t,a);r+=ls(l),n=i+1;continue}}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}if(s==="\\"&&n+1<e.length){r+=s+e[n+1],n+=2;continue}r+=s,n++}return r}function bae(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="\\"&&n+1<e.length){let i=e[n+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){r+=i,n+=2;continue}r+=s,n++;continue}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}r+=s,n++}return r}async function kF(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="'"){let i=e.indexOf("'",n+1);if(i!==-1){let o=e.slice(n+1,i);r+=ls(o),n=i+1;continue}}if(s==='"'){let i=-1,o=n+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(n+1,i),l=await wae(t,a);r+=ls(l),n=i+1;continue}}if(s==="$"&&n+1<e.length&&e[n+1]==="("){let i=NF(e,n+2);if(i!==-1){let o=e.slice(n+2,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="`"){let i=e.indexOf("`",n+1);if(i!==-1){let o=e.slice(n+1,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}if(s==="\\"&&n+1<e.length){r+=s+e[n+1],n+=2;continue}r+=s,n++}return r}async function wae(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="\\"&&n+1<e.length){let i=e[n+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){r+=i,n+=2;continue}r+=s,n++;continue}if(s==="$"&&n+1<e.length&&e[n+1]==="("){let i=NF(e,n+2);if(i!==-1){let o=e.slice(n+2,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="`"){let i=e.indexOf("`",n+1);if(i!==-1){let o=e.slice(n+1,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}r+=s,n++}return r}var TF=I(()=>{"use strict";mr();rt();Oc()});function _F(t,e){if(!e.startsWith("~"))return e;t.coverage?.hit("bash:expansion:tilde");let r=t.state.env.get("HOME")!==void 0?t.state.env.get("HOME"):"/home/user";if(e==="~"||e.startsWith("~/"))return r+e.slice(1);let n=1;for(;n<e.length&&/[a-zA-Z0-9_-]/.test(e[n]);)n++;let s=e.slice(1,n),i=e.slice(n);return i!==""&&!i.startsWith("/")?e:s==="root"?`/root${i}`:e}var OF=I(()=>{"use strict"});async function Eae(t,e,r,n){let s="";for(let i of e.parts)if(i.type==="Glob")s+=st(i.pattern,!0,t.state.shoptOptions.extglob);else if(i.type==="Literal")s+=st(i.value,!0,t.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=ut(i.value);else if(i.type==="DoubleQuoted"){let o=await r(t,i.parts);s+=ut(o)}else if(i.type==="ParameterExpansion"){let o=await n(t,i);s+=st(o,!0,t.state.shoptOptions.extglob)}else{let o=await n(t,i);s+=ut(o)}return s}async function IF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=De(t,a),f=u.map(([,g])=>g);if(u.length===0){let g=t.state.env.get(a);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h="";c.pattern&&(h=await Eae(t,c.pattern,r,n));let d=c.replacement?await r(t,c.replacement.parts):"",p=h;c.anchor==="start"?p=`^${h}`:c.anchor==="end"&&(p=`${h}$`);let m=[];try{let g=ae(p,c.all?"g":"");for(let y of f)m.push(g.replace(y,d))}catch{m.push(...f)}if(l){let g=Ye(t.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}async function RF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=De(t,a),f=u.map(([,m])=>m);if(u.length===0){let m=t.state.env.get(a);m!==void 0&&f.push(m)}if(f.length===0)return{values:[],quoted:!0};let h="",d=t.state.shoptOptions.extglob;if(c.pattern)for(let m of c.pattern.parts)if(m.type==="Glob")h+=st(m.pattern,c.greedy,d);else if(m.type==="Literal")h+=st(m.value,c.greedy,d);else if(m.type==="SingleQuoted"||m.type==="Escaped")h+=ut(m.value);else if(m.type==="DoubleQuoted"){let g=await r(t,m.parts);h+=ut(g)}else if(m.type==="ParameterExpansion"){let g=await n(t,m);h+=st(g,c.greedy,d)}else{let g=await n(t,m);h+=ut(g)}let p=[];for(let m of f)p.push(uo(m,h,c.side,c.greedy));if(l){let m=Ye(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}var PF=I(()=>{"use strict";Gt();Ss();Ic();Rc();el();as()});async function DF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="DefaultValue"&&r.parts[0].operation?.type!=="UseAlternative"&&r.parts[0].operation?.type!=="AssignDefault")return null;let n=r.parts[0],s=n.operation,i=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=De(t,l),u=c.length>0||t.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,d])=>d===""),h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(h&&f):o=!u||h&&f,!o){if(c.length>0){let p=c.map(([,m])=>m);if(a){let m=Ye(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}let d=t.state.env.get(l);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let l=n.parameter,c=await Ui(t,l),u=await gt(t,l),f=u==="",h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(h&&f):o=!c||h&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){c=h[1],u=h[2]==="*";break}}if(c){let f=De(t,c);if(f.length>0){let d=f.map(([,p])=>p);if(u||a){let p=Ye(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}let h=t.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function LF(t,e,r,n,s){if(!r||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0],o=-1,a="",l=!1,c=null;for(let m=0;m<i.parts.length;m++){let g=i.parts[m];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let y=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(y){o=m,a=y[1],l=y[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let m=0;m<o;m++)u+=await n(t,i.parts[m]);let f="";for(let m=o+1;m<i.parts.length;m++)f+=await n(t,i.parts[m]);let h=De(t,a),d=h.map(([,m])=>m);if(h.length===0){let m=t.state.env.get(a);if(m!==void 0)d=[m];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let m=c,g="",y=t.state.shoptOptions.extglob;if(m.pattern)for(let x of m.pattern.parts)if(x.type==="Glob")g+=st(x.pattern,m.greedy,y);else if(x.type==="Literal")g+=st(x.value,m.greedy,y);else if(x.type==="SingleQuoted"||x.type==="Escaped")g+=ut(x.value);else if(x.type==="DoubleQuoted"){let b=await s(t,x.parts);g+=ut(b)}else if(x.type==="ParameterExpansion"){let b=await n(t,x);g+=st(b,m.greedy,y)}else{let b=await n(t,x);g+=ut(b)}d=d.map(x=>uo(x,g,m.side,m.greedy))}else if(c?.type==="PatternReplacement"){let m=c,g="";if(m.pattern)for(let b of m.pattern.parts)if(b.type==="Glob")g+=st(b.pattern,!0,t.state.shoptOptions.extglob);else if(b.type==="Literal")g+=st(b.value,!0,t.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")g+=ut(b.value);else if(b.type==="DoubleQuoted"){let w=await s(t,b.parts);g+=ut(w)}else if(b.type==="ParameterExpansion"){let w=await n(t,b);g+=st(w,!0,t.state.shoptOptions.extglob)}else{let w=await n(t,b);g+=ut(w)}let y=m.replacement?await s(t,m.replacement.parts):"",x=g;m.anchor==="start"?x=`^${g}`:m.anchor==="end"&&(x=`${g}$`);try{let b=ae(x,m.all?"g":"");d=d.map(w=>b.replace(w,y))}catch{}}if(l){let m=Ye(t.state.env);return{values:[u+d.join(m)+f],quoted:!0}}return d.length===1?{values:[u+d[0]+f],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+f],quoted:!0}}async function FF(t,e,r,n){if(!r||e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o="",a=!1;for(let d=0;d<s.parts.length;d++){let p=s.parts[d];if(p.type==="ParameterExpansion"&&!p.operation){let m=p.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(m){i=d,o=m[1],a=m[2]==="*";break}}}if(i===-1)return null;let l="";for(let d=0;d<i;d++)l+=await n(t,s.parts[d]);let c="";for(let d=i+1;d<s.parts.length;d++)c+=await n(t,s.parts[d]);let u=De(t,o),f=u.map(([,d])=>d);if(u.length===0){let d=t.state.env.get(o);if(d!==void 0)return{values:[l+d+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}if(a){let d=Ye(t.state.env);return{values:[l+f.join(d)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var MF=I(()=>{"use strict";Gt();Ss();Ic();Rc();el();as()});async function $F(t,e,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="Substring")return null;let s=n.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(t.state.associativeArrays?.has(o))throw new Xe(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
1481
- `);let c=l.offset?await r(t,l.offset.expression):0,u=l.length?await r(t,l.length.expression):void 0,f=De(t,o),h=0;if(c<0){if(f.length>0){let p=f[f.length-1][0],g=(typeof p=="number"?p:0)+1+c;if(g<0)return{values:[],quoted:!0};h=f.findIndex(([y])=>typeof y=="number"&&y>=g),h<0&&(h=f.length)}}else h=f.findIndex(([p])=>typeof p=="number"&&p>=c),h<0&&(h=f.length);let d;if(u!==void 0){if(u<0)throw new It(`${o}[@]: substring expression < 0`);d=f.slice(h,h+u).map(([,p])=>p)}else d=f.slice(h).map(([,p])=>p);if(d.length===0)return{values:[],quoted:!0};if(a){let p=Ye(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}function BF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="Transform")return null;let n=r.parts[0],s=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=n.operation,l=De(t,i);if(l.length===0){let f=t.state.env.get(i);if(f!==void 0){let h;switch(a.operator){case"a":h="";break;case"P":h=Vf(t,f);break;case"Q":h=Jo(f);break;default:h=f}return{values:[h],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=ta(t,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>Vf(t,f));break;case"Q":u=l.map(([,f])=>Jo(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=Ye(t.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var UF=I(()=>{"use strict";rt();Ss();Z7();Y7();as();bm()});function qF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion")return null;let n=r.parts[0];if(n.operation)return null;let s=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(Bt(t,i)){let l=Ja(t,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=De(t,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=t.state.env.get(i);return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function zF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation)return null;let s=r.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!Bt(t,s))return null;let i=Ja(t,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=De(t,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=t.state.env.get(a);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var HF=I(()=>{"use strict";fi();as()});async function WF(t,e,r,n,s){if(!r||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await gt(t,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let p=Number.parseInt(t.state.env.get("#")||"0",10),m=[];for(let g=1;g<=p;g++)m.push(t.state.env.get(String(g))||"");return l==="*"?{values:[m.join(Ye(t.state.env))],quoted:!0}:{values:m,quoted:!0}}return null}let u=c[1],f=c[2]==="*",h=De(t,u);if(a.innerOp){if(a.innerOp.type==="Substring")return Sae(t,h,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return vae(t,h,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let m=ta(t,u),g=h.map(()=>m);return f?{values:[g.join(Ye(t.state.env))],quoted:!0}:{values:g,quoted:!0}}let p=[];for(let[,m]of h){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},y=t.state.env.get("_indirect_elem_");t.state.env.set("_indirect_elem_",m);try{let x=await n(t,g,!0);p.push(x)}finally{y!==void 0?t.state.env.set("_indirect_elem_",y):t.state.env.delete("_indirect_elem_")}}return f?{values:[p.join(Ye(t.state.env))],quoted:!0}:{values:p,quoted:!0}}if(h.length>0){let p=h.map(([,m])=>m);return f?{values:[p.join(Ye(t.state.env))],quoted:!0}:{values:p,quoted:!0}}let d=t.state.env.get(u);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function Sae(t,e,r,n,s){let i=s.offset?await be(t,s.offset.expression):0,o=s.length?await be(t,s.length.expression):void 0,a=0;if(i<0){if(e.length>0){let u=e[e.length-1][0],h=(typeof u=="number"?u:0)+1+i;if(h<0)return{values:[],quoted:!0};if(a=e.findIndex(([d])=>typeof d=="number"&&d>=h),a<0)return{values:[],quoted:!0}}}else if(a=e.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new It(`${r}[@]: substring expression < 0`);l=e.slice(a,a+o)}else l=e.slice(a);let c=l.map(([,u])=>u);return n?{values:[c.join(Ye(t.state.env))],quoted:!0}:{values:c,quoted:!0}}async function vae(t,e,r,n,s,i){let o=s.checkEmpty??!1,a=e.map(([,u])=>u),l=e.length===0,c=e.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:n?{values:[a.join(Ye(t.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(t,s.word.parts,!0);return t.state.env.set(`${r}_0`,f),t.state.env.set(`${r}__length`,"1"),{values:[f],quoted:!0}}return n?{values:[a.join(Ye(t.state.env))],quoted:!0}:{values:a,quoted:!0}}return n?{values:[a.join(Ye(t.state.env))],quoted:!0}:{values:a,quoted:!0}}async function jF(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="UseAlternative"&&e[0].operation?.type!=="DefaultValue")return null;let r=e[0],n=r.operation,s=n?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await gt(t,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await Ui(t,r.parameter),u=await gt(t,r.parameter)==="",f=n.checkEmpty??!1,h;if(n.type==="UseAlternative"?h=c&&!(f&&u):h=!c||f&&u,h){let d=l[1],p=l[2]==="*",m=De(t,d);if(m.length>0){let y=m.map(([,x])=>x);return p?{values:[y.join(Ye(t.state.env))],quoted:!0}:{values:y,quoted:!0}}let g=t.state.env.get(d);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function VF(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="Indirection")return null;let r=e[0],s=r.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await gt(t,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await gt(t,r.parameter),f=await Ui(t,r.parameter),h=u==="",d=s.checkEmpty??!1,p;if(s.type==="UseAlternative"?p=f&&!(d&&h):p=!f||d&&h,p){let m=c[1],g=c[2]==="*",y=De(t,m);if(y.length>0){let b=y.map(([,w])=>w);return g?{values:[b.join(Ye(t.state.env))],quoted:!0}:{values:b,quoted:!0}}let x=t.state.env.get(m);return x!==void 0?{values:[x],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var GF=I(()=>{"use strict";Fn();rt();Ss();as();bm()});function KF(t){let e=Number.parseInt(t.state.env.get("#")||"0",10),r=[];for(let n=1;n<=e;n++)r.push(t.state.env.get(String(n))||"");return r}async function ZF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let x=0;x<s.parts.length;x++){let b=s.parts[x];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=x,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await r(t,l.offset.expression):0,u=l.length?await r(t,l.length.expression):void 0,f=Number.parseInt(t.state.env.get("#")||"0",10),h=[];for(let x=1;x<=f;x++)h.push(t.state.env.get(String(x))||"");let d=t.state.env.get("0")||"bash",p;if(c<=0){let x=[d,...h],b=x.length+c;if(b<0)p=[];else{let w=c<0?b:0;if(u!==void 0){let S=u<0?x.length+u:w+u;p=x.slice(w,Math.max(w,S))}else p=x.slice(w)}}else{let x=c-1;if(x>=h.length)p=[];else if(u!==void 0){let b=u<0?h.length+u:x+u;p=h.slice(x,Math.max(x,b))}else p=h.slice(x)}let m="";for(let x=0;x<i;x++)m+=await n(t,s.parts[x]);let g="";for(let x=i+1;x<s.parts.length;x++)g+=await n(t,s.parts[x]);if(p.length===0){let x=m+g;return{values:x?[x]:[],quoted:!0}}if(o){let x=Ye(t.state.env);return{values:[m+p.join(x)+g],quoted:!0}}return p.length===1?{values:[m+p[0]+g],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+g],quoted:!0}}async function YF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let x=s.parts[y];if(x.type==="ParameterExpansion"&&(x.parameter==="@"||x.parameter==="*")&&x.operation?.type==="PatternReplacement"){i=y,o=x.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=KF(t),u="";for(let y=0;y<i;y++)u+=await r(t,s.parts[y]);let f="";for(let y=i+1;y<s.parts.length;y++)f+=await r(t,s.parts[y]);if(c.length===0){let y=u+f;return{values:y?[y]:[],quoted:!0}}let h="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")h+=st(y.pattern,!0,t.state.shoptOptions.extglob);else if(y.type==="Literal")h+=st(y.value,!0,t.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")h+=ut(y.value);else if(y.type==="DoubleQuoted"){let x=await n(t,y.parts);h+=ut(x)}else if(y.type==="ParameterExpansion"){let x=await r(t,y);h+=st(x,!0,t.state.shoptOptions.extglob)}else{let x=await r(t,y);h+=ut(x)}let d=l.replacement?await n(t,l.replacement.parts):"",p=h;l.anchor==="start"?p=`^${h}`:l.anchor==="end"&&(p=`${h}$`);let m=[];try{let y=ae(p,l.all?"g":"");for(let x of c)m.push(y.replace(x,d))}catch{m.push(...c)}if(o){let y=Ye(t.state.env);return{values:[u+m.join(y)+f],quoted:!0}}return m.length===1?{values:[u+m[0]+f],quoted:!0}:{values:[u+m[0],...m.slice(1,-1),m[m.length-1]+f],quoted:!0}}async function XF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let y=s.parts[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){i=g,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=KF(t),u="";for(let g=0;g<i;g++)u+=await r(t,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await r(t,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let h="",d=t.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")h+=st(g.pattern,l.greedy,d);else if(g.type==="Literal")h+=st(g.value,l.greedy,d);else if(g.type==="SingleQuoted"||g.type==="Escaped")h+=ut(g.value);else if(g.type==="DoubleQuoted"){let y=await n(t,g.parts);h+=ut(y)}else if(g.type==="ParameterExpansion"){let y=await r(t,g);h+=st(y,l.greedy,d)}else{let y=await r(t,g);h+=ut(y)}let p=[];for(let g of c)p.push(uo(g,h,l.side,l.greedy));if(o){let g=Ye(t.state.env);return{values:[u+p.join(g)+f],quoted:!0}}return p.length===1?{values:[u+p[0]+f],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+f],quoted:!0}}async function QF(t,e,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0],s=-1,i=!1;for(let h=0;h<n.parts.length;h++){let d=n.parts[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")){s=h,i=d.parameter==="*";break}}if(s===-1)return null;let o=n.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(t.state.env.get("#")||"0",10),l="";for(let h=0;h<s;h++)l+=await r(t,n.parts[h]);let c="";for(let h=s+1;h<n.parts.length;h++)c+=await r(t,n.parts[h]);if(a===0){if(i)return{values:[l+c],quoted:!0};let h=l+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=a;h++)u.push(t.state.env.get(String(h))||"");if(i){let h=Ye(t.state.env);return{values:[l+u.join(h)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var JF=I(()=>{"use strict";Gt();Ss();Ic();Rc();el()});function Aae(t){return new Qo(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations})}async function Em(t,e){if(t.state.options.noglob)return e;let r=Aae(t),n=[];for(let s of e)if(qi(s,t.state.shoptOptions.extglob)){let i=await r.expand(s);if(i.length>0)n.push(...i);else{if(r.hasFailglob())throw new Ei(s);r.hasNullglob()||n.push(s)}}else n.push(s);return n}async function eM(t,e,r,n){let s=-1,i="",o=!1;for(let x=0;x<e.length;x++){let b=e[x];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let w=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(w){s=x,i=w[1],o=w[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=De(t,i),u=c.map(([,x])=>x);if(c.length===0){let x=t.state.env.get(i);x!==void 0&&(u=[x])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let x of l.pattern.parts)if(x.type==="Glob")f+=st(x.pattern,!0,t.state.shoptOptions.extglob);else if(x.type==="Literal")f+=st(x.value,!0,t.state.shoptOptions.extglob);else if(x.type==="SingleQuoted"||x.type==="Escaped")f+=ut(x.value);else if(x.type==="DoubleQuoted"){let b=await r(t,x.parts);f+=ut(b)}else if(x.type==="ParameterExpansion"){let b=await n(t,x);f+=st(b,!0,t.state.shoptOptions.extglob)}else{let b=await n(t,x);f+=ut(b)}let h=l.replacement?await r(t,l.replacement.parts):"",d=f;l.anchor==="start"?d=`^${f}`:l.anchor==="end"&&(d=`${f}$`);let p=[];try{let x=ae(d,l.all?"g":"");for(let b of u)p.push(x.replace(b,h))}catch{p.push(...u)}let m=Dr(t.state.env),g=dn(t.state.env);if(o){let x=Ye(t.state.env),b=p.join(x);return g?{values:b?[b]:[],quoted:!1}:{values:Yt(b,m),quoted:!1}}if(g)return{values:p,quoted:!1};let y=[];for(let x of p)x===""?y.push(""):y.push(...Yt(x,m));return{values:y,quoted:!1}}async function tM(t,e,r,n){let s=-1,i="",o=!1;for(let y=0;y<e.length;y++){let x=e[y];if(x.type==="ParameterExpansion"&&x.operation?.type==="PatternRemoval"){let b=x.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=y,i=b[1],o=b[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=De(t,i),u=c.map(([,y])=>y);if(c.length===0){let y=t.state.env.get(i);y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="",h=t.state.shoptOptions.extglob;if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=st(y.pattern,l.greedy,h);else if(y.type==="Literal")f+=st(y.value,l.greedy,h);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=ut(y.value);else if(y.type==="DoubleQuoted"){let x=await r(t,y.parts);f+=ut(x)}else if(y.type==="ParameterExpansion"){let x=await n(t,y);f+=st(x,l.greedy,h)}else{let x=await n(t,y);f+=ut(x)}let d=[];for(let y of u)d.push(uo(y,f,l.side,l.greedy));let p=Dr(t.state.env),m=dn(t.state.env);if(o){let y=Ye(t.state.env),x=d.join(y);return m?{values:x?[x]:[],quoted:!1}:{values:Yt(x,p),quoted:!1}}if(m)return{values:d,quoted:!1};let g=[];for(let y of d)y===""?g.push(""):g.push(...Yt(y,p));return{values:g,quoted:!1}}async function rM(t,e,r,n){let s=-1,i=!1;for(let g=0;g<e.length;g++){let y=e[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){s=g,i=y.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=Number.parseInt(t.state.env.get("#")||"0",10),c=[];for(let g=1;g<=l;g++)c.push(t.state.env.get(String(g))||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=t.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=st(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=st(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=ut(g.value);else if(g.type==="DoubleQuoted"){let y=await r(t,g.parts);u+=ut(y)}else if(g.type==="ParameterExpansion"){let y=await n(t,g);u+=st(y,a.greedy,f)}else{let y=await n(t,g);u+=ut(y)}let h=[];for(let g of c)h.push(uo(g,u,a.side,a.greedy));let d=Dr(t.state.env),p=dn(t.state.env);if(i){let g=Ye(t.state.env),y=h.join(g);return p?{values:y?[y]:[],quoted:!1}:{values:Yt(y,d),quoted:!1}}if(p)return{values:h,quoted:!1};let m=[];for(let g of h)g===""?m.push(""):m.push(...Yt(g,d));return{values:m,quoted:!1}}async function nM(t,e,r,n){let s=-1,i=!1;for(let b=0;b<e.length;b++){let w=e[b];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="Substring"){s=b,i=w.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=a.offset?await r(t,a.offset.expression):0,c=a.length?await r(t,a.length.expression):void 0,u=Number.parseInt(t.state.env.get("#")||"0",10),f=[];for(let b=1;b<=u;b++)f.push(t.state.env.get(String(b))||"");let h=t.state.env.get("0")||"bash",d;if(l<=0){let b=[h,...f],w=b.length+l;if(w<0)d=[];else{let S=l<0?w:0;if(c!==void 0){let _=c<0?b.length+c:S+c;d=b.slice(S,Math.max(S,_))}else d=b.slice(S)}}else{let b=l-1;if(b>=f.length)d=[];else if(c!==void 0){let w=c<0?f.length+c:b+c;d=f.slice(b,Math.max(b,w))}else d=f.slice(b)}let p="";for(let b=0;b<s;b++)p+=await n(t,e[b]);let m="";for(let b=s+1;b<e.length;b++)m+=await n(t,e[b]);let g=Dr(t.state.env),y=dn(t.state.env);if(d.length===0){let b=p+m;return b?y?{values:[b],quoted:!1}:{values:Yt(b,g),quoted:!1}:{values:[],quoted:!1}}let x;if(i){let b=Ye(t.state.env),w=p+d.join(b)+m;y?x=w?[w]:[]:x=Yt(w,g)}else if(y)d.length===1?x=[p+d[0]+m]:x=[p+d[0],...d.slice(1,-1),d[d.length-1]+m];else{x=[];for(let b=0;b<d.length;b++){let w=d[b];if(b===0&&(w=p+w),b===d.length-1&&(w=w+m),w==="")x.push("");else{let S=Yt(w,g);x.push(...S)}}}return{values:await Em(t,x),quoted:!1}}async function sM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].parameter!=="@"&&e[0].parameter!=="*"||e[0].operation)return null;let r=e[0].parameter==="*",n=Number.parseInt(t.state.env.get("#")||"0",10);if(n===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=n;c++)s.push(t.state.env.get(String(c))||"");let i=Dr(t.state.env),o=dn(t.state.env),a=pm(t.state.env),l;if(r)if(o)l=s.filter(c=>c!=="");else{let c=Ye(t.state.env),u=s.join(c);l=Yt(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=Yt(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=Yt(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await Em(t,l),quoted:!1}}async function iM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation)return null;let r=e[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!r)return null;let n=r[1],s=r[2]==="*",i=De(t,n),o;if(i.length===0){let f=t.state.env.get(n);if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=Dr(t.state.env),l=dn(t.state.env),c=pm(t.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=Ye(t.state.env),h=o.join(f);u=Yt(h,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let h=Yt(f,a);u.push(...h)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let h=Yt(f,a);u.push(...h)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await Em(t,u),quoted:!1}}function oM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="VarNamePrefix")return null;let r=e[0].operation,n=Pc(t,r.prefix);if(n.length===0)return{values:[],quoted:!1};let s=Dr(t.state.env),i=dn(t.state.env),o;if(r.star)if(i)o=n;else{let a=Ye(t.state.env),l=n.join(a);o=Yt(l,s)}else if(i)o=n;else{o=[];for(let a of n){let l=Yt(a,s);o.push(...l)}}return{values:o,quoted:!1}}function aM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="ArrayKeys")return null;let r=e[0].operation,s=De(t,r.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=Dr(t.state.env),o=dn(t.state.env),a;if(r.star)if(o)a=s;else{let l=Ye(t.state.env),c=s.join(l);a=Yt(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=Yt(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function lM(t,e,r){let n=-1;for(let h=0;h<e.length;h++){let d=e[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")&&!d.operation){n=h;break}}if(n===-1||e.length<=1)return null;let s=Number.parseInt(t.state.env.get("#")||"0",10),i=[];for(let h=1;h<=s;h++)i.push(t.state.env.get(String(h))||"");let o="";for(let h=0;h<n;h++)o+=await r(t,e[h]);let a="";for(let h=n+1;h<e.length;h++)a+=await r(t,e[h]);let l=Dr(t.state.env),c=dn(t.state.env),u=pm(t.state.env);if(s===0){let h=o+a;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let d=0;d<i.length;d++){let p=i[d];d===0&&(p=o+p),d===i.length-1&&(p=p+a),h.push(p)}if(c)f=h.filter(d=>d!=="");else if(u){f=[];for(let d of h){if(d==="")continue;let p=Yt(d,l);f.push(...p)}}else{f=[];for(let d of h)if(d==="")f.push("");else{let p=Yt(d,l);f.push(...p)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await Em(t,f),quoted:!1}}var cM=I(()=>{"use strict";Gt();fm();rt();Ss();Ic();Oc();Rc();el();as()});async function hM(t,e,r){t.coverage?.hit("bash:expansion:word_glob");let n=e.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=jf(n),h=r.hasBraceExpansion(n)?await r.expandWordWithBracesAsync(t,e):null;if(h&&h.length>1)return Cae(t,h,s);let d=await Nae(t,n,a,c,u,r);if(d!==null)return d;let p=await Tae(t,n,r);if(p!==null)return p;let m=await _ae(t,n,r);if(m!==null)return m;let g=await Iae(t,n,r.expandPart);if(g!==null)return fM(t,g);if((i||o||l)&&!dn(t.state.env)){let x=Dr(t.state.env),b=r.buildIfsCharClassPattern(x),w=await r.smartWordSplit(t,n,x,b,r.expandPart);return fM(t,w)}let y=await r.expandWordAsync(t,e);return Rae(t,e,n,y,s,r.expandWordForGlobbing)}async function Cae(t,e,r){let n=[];for(let s of e)if(!(!r&&s===""))if(!r&&!t.state.options.noglob&&qi(s,t.state.shoptOptions.extglob)){let i=await Sm(t,s);n.push(...i)}else n.push(s);return{values:n,quoted:!1}}async function Nae(t,e,r,n,s,i){if(r){let o=qF(t,e);if(o!==null)return o}{let o=zF(t,e);if(o!==null)return o}{let o=await DF(t,e);if(o!==null)return o}{let o=await LF(t,e,r,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await FF(t,e,r,i.expandPart);if(o!==null)return o}{let o=await $F(t,e,i.evaluateArithmetic);if(o!==null)return o}{let o=BF(t,e);if(o!==null)return o}{let o=await IF(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await RF(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(n&&e.length===1&&e[0].type==="DoubleQuoted"){let o=kae(t,e);if(o!==null)return o}{let o=await WF(t,e,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await jF(t,e);if(o!==null)return o}{let o=await VF(t,e);if(o!==null)return o}return null}function kae(t,e){let r=e[0];if(r.type!=="DoubleQuoted")return null;if(r.parts.length===1&&r.parts[0].type==="ParameterExpansion"&&r.parts[0].operation?.type==="VarNamePrefix"){let n=r.parts[0].operation,s=Pc(t,n.prefix);return n.star?{values:[s.join(Ye(t.state.env))],quoted:!0}:{values:s,quoted:!0}}if(r.parts.length===1&&r.parts[0].type==="ParameterExpansion"&&r.parts[0].operation?.type==="ArrayKeys"){let n=r.parts[0].operation,i=De(t,n.array).map(([o])=>String(o));return n.star?{values:[i.join(Ye(t.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function Tae(t,e,r){{let n=await ZF(t,e,r.evaluateArithmetic,r.expandPart);if(n!==null)return n}{let n=await YF(t,e,r.expandPart,r.expandWordPartsAsync);if(n!==null)return n}{let n=await XF(t,e,r.expandPart,r.expandWordPartsAsync);if(n!==null)return n}{let n=await QF(t,e,r.expandPart);if(n!==null)return n}return null}async function _ae(t,e,r){{let n=await eM(t,e,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await tM(t,e,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await rM(t,e,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await nM(t,e,r.evaluateArithmetic,r.expandPart);if(n!==null)return n}{let n=await sM(t,e);if(n!==null)return n}{let n=await iM(t,e);if(n!==null)return n}{let n=oM(t,e);if(n!==null)return n}{let n=aM(t,e);if(n!==null)return n}{let n=await lM(t,e,r.expandPart);if(n!==null)return n}return null}function uM(t){if(t.type!=="DoubleQuoted")return null;for(let e=0;e<t.parts.length;e++){let r=t.parts[e];if(r.type!=="ParameterExpansion"||r.operation)continue;let n=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n)return{type:"array",name:n[1],atIndex:e,isStar:n[2]==="*"};if(r.parameter==="@"||r.parameter==="*")return{type:"positional",atIndex:e,isStar:r.parameter==="*"}}return null}async function Oae(t,e,r,n){let s="";for(let a=0;a<r.atIndex;a++)s+=await n(t,e.parts[a]);let i="";for(let a=r.atIndex+1;a<e.parts.length;a++)i+=await n(t,e.parts[a]);let o;if(r.type==="array"){if(o=De(t,r.name).map(([,l])=>l),o.length===0){let l=t.state.env.get(r.name);l!==void 0&&(o=[l])}}else{let a=Number.parseInt(t.state.env.get("#")||"0",10);o=[];for(let l=1;l<=a;l++)o.push(t.state.env.get(String(l))||"")}if(r.isStar){let a=Ye(t.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function Iae(t,e,r){if(e.length<2)return null;let n=!1;for(let l of e)if(uM(l)){n=!0;break}if(!n)return null;let s=Dr(t.state.env),i=dn(t.state.env),o=[];for(let l of e){let c=uM(l);if(c&&l.type==="DoubleQuoted"){let u=await Oae(t,l,c,r);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await r(t,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await r(t,l);if(i)o.push(u?[u]:[]);else{let f=Yt(u,s);o.push(f)}}else{let u=await r(t,l);if(i)o.push(u?[u]:[]);else{let f=Yt(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function fM(t,e){if(t.state.options.noglob)return{values:e,quoted:!1};let r=[];for(let n of e)if(qi(n,t.state.shoptOptions.extglob)){let s=await Sm(t,n);r.push(...s)}else r.push(n);return{values:r,quoted:!1}}async function Sm(t,e){let r=new Qo(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations}),n=await r.expand(e);if(n.length>0)return n;if(r.hasFailglob())throw new Ei(e);return r.hasNullglob()?[]:[e]}async function Rae(t,e,r,n,s,i){let o=r.some(a=>a.type==="Glob");if(!t.state.options.noglob&&o){let a=await i(t,e);if(qi(a,t.state.shoptOptions.extglob)){let c=await Sm(t,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=K7(n);if(!dn(t.state.env)){let c=Dr(t.state.env);return{values:Yt(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!t.state.options.noglob&&qi(n,t.state.shoptOptions.extglob)){let a=await i(t,e);if(qi(a,t.state.shoptOptions.extglob)){let l=await Sm(t,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(n===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=K7(n);if(!dn(t.state.env)){let l=Dr(t.state.env);return{values:Yt(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[n],quoted:s}}var dM=I(()=>{"use strict";fm();rt();Ss();hm();PF();MF();UF();HF();Oc();GF();el();JF();cM();as()});async function mM(t,e){let r=e.operation;if(!r||r.type!=="DefaultValue"&&r.type!=="AssignDefault"&&r.type!=="UseAlternative")return null;let n=r.word;if(!n||n.parts.length===0)return null;let s=await Ui(t,e.parameter),o=await gt(t,e.parameter,!1)==="",a=r.checkEmpty??!1,l;return r.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?n.parts:null}function Pae(t){return t.type==="SingleQuoted"?!0:t.type==="DoubleQuoted"?t.parts.every(r=>r.type==="Literal"):!1}async function Dae(t,e){if(e.type!=="ParameterExpansion")return null;let r=await mM(t,e);if(!r||r.length<=1)return null;let n=r.some(i=>Pae(i)),s=r.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return n&&s?r:null}function Lae(t){return t.type==="DoubleQuoted"||t.type==="SingleQuoted"||t.type==="Literal"?!1:t.type==="Glob"?q7(t.pattern):!(!(t.type==="ParameterExpansion"||t.type==="CommandSubstitution"||t.type==="ArithmeticExpansion")||t.type==="ParameterExpansion"&&QL(t))}async function gM(t,e,r,n,s){if(t.coverage?.hit("bash:expansion:word_split"),e.length===1&&e[0].type==="ParameterExpansion"){let h=e[0],d=await mM(t,h);if(d&&d.length>0&&d.length>1&&d.some(m=>m.type==="DoubleQuoted"||m.type==="SingleQuoted")&&d.some(m=>m.type==="Literal"||m.type==="ParameterExpansion"||m.type==="CommandSubstitution"||m.type==="ArithmeticExpansion"))return pM(t,d,r,n,s)}let i=[],o=!1;for(let h of e){let d=Lae(h),p=h.type==="DoubleQuoted"||h.type==="SingleQuoted",m=d?await Dae(t,h):null,g=await s(t,h);i.push({value:g,isSplittable:d,isQuoted:p,mixedDefaultParts:m??void 0}),d&&(o=!0)}if(!o){let h=i.map(d=>d.value).join("");return h?[h]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let h of i)if(!h.isSplittable)u?h.isQuoted&&h.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):h.value!==""?(l!==""&&a.push(l),l=h.value,u=!1,f=!1):(l+=h.value,f=!1):(l+=h.value,f=h.isQuoted&&h.value==="");else if(h.mixedDefaultParts){let d=await pM(t,h.mixedDefaultParts,r,n,s);if(d.length!==0)if(d.length===1)l+=d[0],c=!0;else{l+=d[0],a.push(l),c=!0;for(let p=1;p<d.length-1;p++)a.push(d[p]);l=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:p,hadTrailingDelimiter:m}=mm(h.value,r);if(f&&p&&l===""&&(a.push(""),c=!0),d.length===0)m&&(u=!0);else if(d.length===1)l+=d[0],c=!0,u=m;else{l+=d[0],a.push(l),c=!0;for(let g=1;g<d.length-1;g++)a.push(d[g]);l=d[d.length-1],u=m}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function Fae(t,e){return t.length>0&&e.includes(t[0])}async function pM(t,e,r,n,s){let i=[];for(let u of e){let h=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),d=await s(t,u);i.push({value:d,isSplittable:h})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{Fae(u.value,r)&&a!==""&&(o.push(a),a="",l=!0);let{words:h,hadTrailingDelimiter:d}=mm(u.value,r);if(h.length===0)d&&(c=!0);else if(h.length===1)a+=h[0],l=!0,c=d;else{a+=h[0],o.push(a),l=!0;for(let p=1;p<h.length-1;p++)o.push(h[p]);a=h[h.length-1],c=d}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var yM=I(()=>{"use strict";as();Ss();hm()});function xM(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function bM(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}var wM=I(()=>{"use strict"});var n4={};ue(n4,{escapeGlobChars:()=>ls,escapeRegexChars:()=>_c,expandRedirectTarget:()=>Kf,expandWord:()=>Ae,expandWordForPattern:()=>t4,expandWordForRegex:()=>e4,expandWordWithGlob:()=>pi,getArrayElements:()=>De,getVariable:()=>gt,hasQuotedMultiValueAt:()=>Gf,isArray:()=>co,isWordFullyQuoted:()=>J7});function ra(t,e,r){if(t.length>e)throw new fe(`${r}: string length limit exceeded (${e} bytes)`,"string_length")}async function di(t,e,r=!1){let n=[];for(let s of e)n.push(await vs(t,s,r));return n.join("")}function Mae(t){return bM(t)}function J7(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!Mae(e))return!1;return!0}function $ae(t,e,r=!1){let n=xM(e);if(n!==null)return n;switch(e.type){case"TildeExpansion":return r?e.user===null?"~":`~${e.user}`:(t.coverage?.hit("bash:expansion:tilde"),e.user===null?t.state.env.get("HOME")??"/home/user":e.user==="root"?"/root":`~${e.user}`);case"Glob":return X7(t,e.pattern);default:return null}}async function Ae(t,e){return r4(t,e)}async function e4(t,e){let r=[];for(let n of e.parts)if(n.type==="Escaped")r.push(`\\${n.value}`);else if(n.type==="SingleQuoted")r.push(n.value);else if(n.type==="DoubleQuoted"){let s=await di(t,n.parts);r.push(s)}else if(n.type==="TildeExpansion"){let s=await vs(t,n);r.push(_c(s))}else r.push(await vs(t,n));return r.join("")}async function t4(t,e){let r=[];for(let n of e.parts)if(n.type==="Escaped"){let s=n.value;"()|*?[]".includes(s)?r.push(`\\${s}`):r.push(s)}else if(n.type==="SingleQuoted")r.push(ls(n.value));else if(n.type==="DoubleQuoted"){let s=await di(t,n.parts);r.push(ls(s))}else r.push(await vs(t,n));return r.join("")}async function EM(t,e){let r=[];for(let n of e.parts)if(n.type==="SingleQuoted")r.push(ls(n.value));else if(n.type==="Escaped"){let s=n.value;"*?[]\\()|".includes(s)?r.push(`\\${s}`):r.push(s)}else if(n.type==="DoubleQuoted"){let s=await di(t,n.parts);r.push(ls(s))}else n.type==="Glob"?CF(n.pattern)?r.push(await kF(t,n.pattern)):r.push(X7(t,n.pattern)):n.type==="Literal"?r.push(n.value):r.push(await vs(t,n));return r.join("")}function Am(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&Am(e.parts))return!0;return!1}async function SM(t,e,r={count:0}){if(r.count>Q7)return[[]];let n=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=G7(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)r.count++,i.push(h);else{o=!0,a=f.literal;break}}else{let f=await SM(t,u.word.parts,r);for(let h of f){r.count++;let d=[];for(let p of h)typeof p=="string"?d.push(p):d.push(await vs(t,p));i.push(d.join(""))}}if(o){for(let u of n)r.count++,u.push(a);continue}if(n.length*i.length>t.limits.maxBraceExpansionResults||r.count>Q7)return n;let c=[];for(let u of n)for(let f of i){if(r.count++,r.count>Q7)return c.length>0?c:n;c.push([...u,f])}n=c}else for(let i of n)r.count++,i.push(s);return n}async function vM(t,e){let r=e.parts;if(!Am(r))return[await Ae(t,e)];let n=await SM(t,r),s=[];for(let i of n){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await vs(t,a));s.push(_F(t,o.join("")))}return s}function Bae(){return{expandWordAsync:r4,expandWordForGlobbing:EM,expandWordWithBracesAsync:vM,expandWordPartsAsync:di,expandPart:vs,expandParameterAsync:vm,hasBraceExpansion:Am,evaluateArithmetic:be,buildIfsCharClassPattern:JL,smartWordSplit:gM}}async function pi(t,e){return hM(t,e,Bae())}function Uae(t){for(let e of t){if(e.type==="ParameterExpansion")return e.parameter;if(e.type==="Literal")return e.value}return""}function Gf(t,e){if(Number.parseInt(t.state.env.get("#")||"0",10)<2)return!1;function n(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return n(e.parts)}async function Kf(t,e){if(Gf(t,e))return{error:`bash: $@: ambiguous redirect
1480
+ `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return l}});case"K":case"k":return n?"":Jo(r);case"u":return r.charAt(0).toUpperCase()+r.slice(1);case"U":return r.toUpperCase();case"L":return r.toLowerCase();default:return r}}async function wF(t,e,r,n,s,i,o=!1){if(t.coverage?.hit("bash:expansion:indirection"),Bt(t,e))return Ja(t,e)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(e);if(n){if(s.innerOp?.type==="UseAlternative")return"";throw new kn(`\${!${e}}`)}let l=r;if(a&&(l===""||l.includes(" ")))throw new kn(`\${!${e}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new kn(`\${!${e}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(t,u,o)}return await gt(t,l)}function EF(t,e){t.coverage?.hit("bash:expansion:array_keys");let n=De(t,e.array).map(([s])=>String(s));return e.star?n.join(Ye(t.state.env)):n.join(" ")}function SF(t,e){t.coverage?.hit("bash:expansion:var_name_prefix");let r=Pc(t,e.prefix);return e.star?r.join(Ye(t.state.env)):r.join(" ")}function vF(t,e,r,n){let s=Number.parseInt(t.state.env.get("#")||"0",10),i=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(e==="*")return{isEmpty:s===0,effectiveValue:r};if(e==="@")return{isEmpty:s===0||s===1&&t.state.env.get("1")==="",effectiveValue:r};if(i){let[,o,a]=i,l=De(t,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=Ye(t.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:n?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:r==="",effectiveValue:r}}var AF=I(()=>{"use strict";vn();mr();Gt();Fn();rt();Ss();fi();Ic();Rc();el();Z7();Y7();as();bm()});function CF(t){let e=0;for(;e<t.length;){let r=t[e];if(r==="\\"&&e+1<t.length){e+=2;continue}if(r==="'"){let n=t.indexOf("'",e+1);if(n!==-1){e=n+1;continue}}if(r==="$"&&e+1<t.length&&t[e+1]==="("||r==="`")return!0;e++}return!1}function NF(t,e){let r=1,n=e,s=!1,i=!1;for(;n<t.length&&r>0;){let o=t[n];if(o==="\\"&&!s&&n+1<t.length){n+=2;continue}if(o==="'"&&!i){s=!s,n++;continue}if(o==='"'&&!s){i=!i,n++;continue}if(!s&&!i){if(o==="(")r++;else if(o===")"&&(r--,r===0))return n}n++}return-1}async function wm(t,e){let r=new je,n;try{n=r.parse(e)}catch{return""}let s=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let i=new Map(t.state.env),o=t.state.cwd,a=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let l=await t.executeScript(n),c=l.exitCode;return t.state.env=i,t.state.cwd=o,t.state.suppressVerbose=a,t.state.lastExitCode=c,t.state.env.set("?",String(c)),l.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+l.stderr),t.state.bashPid=s,l.stdout.replace(/\n+$/,"")}catch(l){if(t.state.env=i,t.state.cwd=o,t.state.bashPid=s,t.state.suppressVerbose=a,l instanceof he)throw l;return l instanceof Xe?(t.state.lastExitCode=l.exitCode,t.state.env.set("?",String(l.exitCode)),l.stdout?.replace(/\n+$/,"")??""):""}}function X7(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="'"){let i=e.indexOf("'",n+1);if(i!==-1){let o=e.slice(n+1,i);r+=ls(o),n=i+1;continue}}if(s==='"'){let i=-1,o=n+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(n+1,i),l=bae(t,a);r+=ls(l),n=i+1;continue}}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}if(s==="\\"&&n+1<e.length){r+=s+e[n+1],n+=2;continue}r+=s,n++}return r}function bae(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="\\"&&n+1<e.length){let i=e[n+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){r+=i,n+=2;continue}r+=s,n++;continue}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}r+=s,n++}return r}async function kF(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="'"){let i=e.indexOf("'",n+1);if(i!==-1){let o=e.slice(n+1,i);r+=ls(o),n=i+1;continue}}if(s==='"'){let i=-1,o=n+1;for(;o<e.length;){if(e[o]==="\\"){o+=2;continue}if(e[o]==='"'){i=o;break}o++}if(i!==-1){let a=e.slice(n+1,i),l=await wae(t,a);r+=ls(l),n=i+1;continue}}if(s==="$"&&n+1<e.length&&e[n+1]==="("){let i=NF(e,n+2);if(i!==-1){let o=e.slice(n+2,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="`"){let i=e.indexOf("`",n+1);if(i!==-1){let o=e.slice(n+1,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}if(s==="\\"&&n+1<e.length){r+=s+e[n+1],n+=2;continue}r+=s,n++}return r}async function wae(t,e){let r="",n=0;for(;n<e.length;){let s=e[n];if(s==="\\"&&n+1<e.length){let i=e[n+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){r+=i,n+=2;continue}r+=s,n++;continue}if(s==="$"&&n+1<e.length&&e[n+1]==="("){let i=NF(e,n+2);if(i!==-1){let o=e.slice(n+2,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="`"){let i=e.indexOf("`",n+1);if(i!==-1){let o=e.slice(n+1,i),a=await wm(t,o);r+=a,n=i+1;continue}}if(s==="$"&&n+1<e.length){let i=e[n+1];if(i==="{"){let o=e.indexOf("}",n+2);if(o!==-1){let a=e.slice(n+2,o);r+=t.state.env.get(a)??"",n=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=n+1;for(;o<e.length&&/[a-zA-Z0-9_]/.test(e[o]);)o++;let a=e.slice(n+1,o);r+=t.state.env.get(a)??"",n=o;continue}}r+=s,n++}return r}var TF=I(()=>{"use strict";mr();rt();Oc()});function _F(t,e){if(!e.startsWith("~"))return e;t.coverage?.hit("bash:expansion:tilde");let r=t.state.env.get("HOME")!==void 0?t.state.env.get("HOME"):"/home/user";if(e==="~"||e.startsWith("~/"))return r+e.slice(1);let n=1;for(;n<e.length&&/[a-zA-Z0-9_-]/.test(e[n]);)n++;let s=e.slice(1,n),i=e.slice(n);return i!==""&&!i.startsWith("/")?e:s==="root"?`/root${i}`:e}var OF=I(()=>{"use strict"});async function Eae(t,e,r,n){let s="";for(let i of e.parts)if(i.type==="Glob")s+=st(i.pattern,!0,t.state.shoptOptions.extglob);else if(i.type==="Literal")s+=st(i.value,!0,t.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=ut(i.value);else if(i.type==="DoubleQuoted"){let o=await r(t,i.parts);s+=ut(o)}else if(i.type==="ParameterExpansion"){let o=await n(t,i);s+=st(o,!0,t.state.shoptOptions.extglob)}else{let o=await n(t,i);s+=ut(o)}return s}async function IF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=De(t,a),f=u.map(([,g])=>g);if(u.length===0){let g=t.state.env.get(a);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h="";c.pattern&&(h=await Eae(t,c.pattern,r,n));let d=c.replacement?await r(t,c.replacement.parts):"",p=h;c.anchor==="start"?p=`^${h}`:c.anchor==="end"&&(p=`${h}$`);let m=[];try{let g=ae(p,c.all?"g":"");for(let y of f)m.push(g.replace(y,d))}catch{m.push(...f)}if(l){let g=Ye(t.state.env);return{values:[m.join(g)],quoted:!0}}return{values:m,quoted:!0}}async function RF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=De(t,a),f=u.map(([,m])=>m);if(u.length===0){let m=t.state.env.get(a);m!==void 0&&f.push(m)}if(f.length===0)return{values:[],quoted:!0};let h="",d=t.state.shoptOptions.extglob;if(c.pattern)for(let m of c.pattern.parts)if(m.type==="Glob")h+=st(m.pattern,c.greedy,d);else if(m.type==="Literal")h+=st(m.value,c.greedy,d);else if(m.type==="SingleQuoted"||m.type==="Escaped")h+=ut(m.value);else if(m.type==="DoubleQuoted"){let g=await r(t,m.parts);h+=ut(g)}else if(m.type==="ParameterExpansion"){let g=await n(t,m);h+=st(g,c.greedy,d)}else{let g=await n(t,m);h+=ut(g)}let p=[];for(let m of f)p.push(uo(m,h,c.side,c.greedy));if(l){let m=Ye(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}var PF=I(()=>{"use strict";Gt();Ss();Ic();Rc();el();as()});async function DF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="DefaultValue"&&r.parts[0].operation?.type!=="UseAlternative"&&r.parts[0].operation?.type!=="AssignDefault")return null;let n=r.parts[0],s=n.operation,i=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=De(t,l),u=c.length>0||t.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,d])=>d===""),h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(h&&f):o=!u||h&&f,!o){if(c.length>0){let p=c.map(([,m])=>m);if(a){let m=Ye(t.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}let d=t.state.env.get(l);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}}else{let l=n.parameter,c=await Ui(t,l),u=await gt(t,l),f=u==="",h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(h&&f):o=!c||h&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){c=h[1],u=h[2]==="*";break}}if(c){let f=De(t,c);if(f.length>0){let d=f.map(([,p])=>p);if(u||a){let p=Ye(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}let h=t.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function LF(t,e,r,n,s){if(!r||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0],o=-1,a="",l=!1,c=null;for(let m=0;m<i.parts.length;m++){let g=i.parts[m];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let y=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(y){o=m,a=y[1],l=y[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let m=0;m<o;m++)u+=await n(t,i.parts[m]);let f="";for(let m=o+1;m<i.parts.length;m++)f+=await n(t,i.parts[m]);let h=De(t,a),d=h.map(([,m])=>m);if(h.length===0){let m=t.state.env.get(a);if(m!==void 0)d=[m];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let m=c,g="",y=t.state.shoptOptions.extglob;if(m.pattern)for(let x of m.pattern.parts)if(x.type==="Glob")g+=st(x.pattern,m.greedy,y);else if(x.type==="Literal")g+=st(x.value,m.greedy,y);else if(x.type==="SingleQuoted"||x.type==="Escaped")g+=ut(x.value);else if(x.type==="DoubleQuoted"){let b=await s(t,x.parts);g+=ut(b)}else if(x.type==="ParameterExpansion"){let b=await n(t,x);g+=st(b,m.greedy,y)}else{let b=await n(t,x);g+=ut(b)}d=d.map(x=>uo(x,g,m.side,m.greedy))}else if(c?.type==="PatternReplacement"){let m=c,g="";if(m.pattern)for(let b of m.pattern.parts)if(b.type==="Glob")g+=st(b.pattern,!0,t.state.shoptOptions.extglob);else if(b.type==="Literal")g+=st(b.value,!0,t.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")g+=ut(b.value);else if(b.type==="DoubleQuoted"){let w=await s(t,b.parts);g+=ut(w)}else if(b.type==="ParameterExpansion"){let w=await n(t,b);g+=st(w,!0,t.state.shoptOptions.extglob)}else{let w=await n(t,b);g+=ut(w)}let y=m.replacement?await s(t,m.replacement.parts):"",x=g;m.anchor==="start"?x=`^${g}`:m.anchor==="end"&&(x=`${g}$`);try{let b=ae(x,m.all?"g":"");d=d.map(w=>b.replace(w,y))}catch{}}if(l){let m=Ye(t.state.env);return{values:[u+d.join(m)+f],quoted:!0}}return d.length===1?{values:[u+d[0]+f],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+f],quoted:!0}}async function FF(t,e,r,n){if(!r||e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o="",a=!1;for(let d=0;d<s.parts.length;d++){let p=s.parts[d];if(p.type==="ParameterExpansion"&&!p.operation){let m=p.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(m){i=d,o=m[1],a=m[2]==="*";break}}}if(i===-1)return null;let l="";for(let d=0;d<i;d++)l+=await n(t,s.parts[d]);let c="";for(let d=i+1;d<s.parts.length;d++)c+=await n(t,s.parts[d]);let u=De(t,o),f=u.map(([,d])=>d);if(u.length===0){let d=t.state.env.get(o);if(d!==void 0)return{values:[l+d+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}if(a){let d=Ye(t.state.env);return{values:[l+f.join(d)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var MF=I(()=>{"use strict";Gt();Ss();Ic();Rc();el();as()});async function $F(t,e,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="Substring")return null;let s=n.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(t.state.associativeArrays?.has(o))throw new Xe(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
1481
+ `);let c=l.offset?await r(t,l.offset.expression):0,u=l.length?await r(t,l.length.expression):void 0,f=De(t,o),h=0;if(c<0){if(f.length>0){let p=f[f.length-1][0],g=(typeof p=="number"?p:0)+1+c;if(g<0)return{values:[],quoted:!0};h=f.findIndex(([y])=>typeof y=="number"&&y>=g),h<0&&(h=f.length)}}else h=f.findIndex(([p])=>typeof p=="number"&&p>=c),h<0&&(h=f.length);let d;if(u!==void 0){if(u<0)throw new It(`${o}[@]: substring expression < 0`);d=f.slice(h,h+u).map(([,p])=>p)}else d=f.slice(h).map(([,p])=>p);if(d.length===0)return{values:[],quoted:!0};if(a){let p=Ye(t.state.env);return{values:[d.join(p)],quoted:!0}}return{values:d,quoted:!0}}function BF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="Transform")return null;let n=r.parts[0],s=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=n.operation,l=De(t,i);if(l.length===0){let f=t.state.env.get(i);if(f!==void 0){let h;switch(a.operator){case"a":h="";break;case"P":h=Vf(t,f);break;case"Q":h=Jo(f);break;default:h=f}return{values:[h],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=ta(t,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>Vf(t,f));break;case"Q":u=l.map(([,f])=>Jo(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=Ye(t.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var UF=I(()=>{"use strict";rt();Ss();Z7();Y7();as();bm()});function qF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion")return null;let n=r.parts[0];if(n.operation)return null;let s=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(Bt(t,i)){let l=Ja(t,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=De(t,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=t.state.env.get(i);return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function zF(t,e){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let r=e[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation)return null;let s=r.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!Bt(t,s))return null;let i=Ja(t,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=De(t,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=t.state.env.get(a);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var HF=I(()=>{"use strict";fi();as()});async function WF(t,e,r,n,s){if(!r||e.length!==1||e[0].type!=="DoubleQuoted")return null;let i=e[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await gt(t,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let p=Number.parseInt(t.state.env.get("#")||"0",10),m=[];for(let g=1;g<=p;g++)m.push(t.state.env.get(String(g))||"");return l==="*"?{values:[m.join(Ye(t.state.env))],quoted:!0}:{values:m,quoted:!0}}return null}let u=c[1],f=c[2]==="*",h=De(t,u);if(a.innerOp){if(a.innerOp.type==="Substring")return Sae(t,h,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return vae(t,h,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let m=ta(t,u),g=h.map(()=>m);return f?{values:[g.join(Ye(t.state.env))],quoted:!0}:{values:g,quoted:!0}}let p=[];for(let[,m]of h){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},y=t.state.env.get("_indirect_elem_");t.state.env.set("_indirect_elem_",m);try{let x=await n(t,g,!0);p.push(x)}finally{y!==void 0?t.state.env.set("_indirect_elem_",y):t.state.env.delete("_indirect_elem_")}}return f?{values:[p.join(Ye(t.state.env))],quoted:!0}:{values:p,quoted:!0}}if(h.length>0){let p=h.map(([,m])=>m);return f?{values:[p.join(Ye(t.state.env))],quoted:!0}:{values:p,quoted:!0}}let d=t.state.env.get(u);return d!==void 0?{values:[d],quoted:!0}:{values:[],quoted:!0}}async function Sae(t,e,r,n,s){let i=s.offset?await be(t,s.offset.expression):0,o=s.length?await be(t,s.length.expression):void 0,a=0;if(i<0){if(e.length>0){let u=e[e.length-1][0],h=(typeof u=="number"?u:0)+1+i;if(h<0)return{values:[],quoted:!0};if(a=e.findIndex(([d])=>typeof d=="number"&&d>=h),a<0)return{values:[],quoted:!0}}}else if(a=e.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new It(`${r}[@]: substring expression < 0`);l=e.slice(a,a+o)}else l=e.slice(a);let c=l.map(([,u])=>u);return n?{values:[c.join(Ye(t.state.env))],quoted:!0}:{values:c,quoted:!0}}async function vae(t,e,r,n,s,i){let o=s.checkEmpty??!1,a=e.map(([,u])=>u),l=e.length===0,c=e.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(t,s.word.parts,!0)],quoted:!0}:n?{values:[a.join(Ye(t.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(t,s.word.parts,!0);return t.state.env.set(`${r}_0`,f),t.state.env.set(`${r}__length`,"1"),{values:[f],quoted:!0}}return n?{values:[a.join(Ye(t.state.env))],quoted:!0}:{values:a,quoted:!0}}return n?{values:[a.join(Ye(t.state.env))],quoted:!0}:{values:a,quoted:!0}}async function jF(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="UseAlternative"&&e[0].operation?.type!=="DefaultValue")return null;let r=e[0],n=r.operation,s=n?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await gt(t,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await Ui(t,r.parameter),u=await gt(t,r.parameter)==="",f=n.checkEmpty??!1,h;if(n.type==="UseAlternative"?h=c&&!(f&&u):h=!c||f&&u,h){let d=l[1],p=l[2]==="*",m=De(t,d);if(m.length>0){let y=m.map(([,x])=>x);return p?{values:[y.join(Ye(t.state.env))],quoted:!0}:{values:y,quoted:!0}}let g=t.state.env.get(d);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function VF(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="Indirection")return null;let r=e[0],s=r.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await gt(t,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await gt(t,r.parameter),f=await Ui(t,r.parameter),h=u==="",d=s.checkEmpty??!1,p;if(s.type==="UseAlternative"?p=f&&!(d&&h):p=!f||d&&h,p){let m=c[1],g=c[2]==="*",y=De(t,m);if(y.length>0){let b=y.map(([,w])=>w);return g?{values:[b.join(Ye(t.state.env))],quoted:!0}:{values:b,quoted:!0}}let x=t.state.env.get(m);return x!==void 0?{values:[x],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var GF=I(()=>{"use strict";Fn();rt();Ss();as();bm()});function KF(t){let e=Number.parseInt(t.state.env.get("#")||"0",10),r=[];for(let n=1;n<=e;n++)r.push(t.state.env.get(String(n))||"");return r}async function ZF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let x=0;x<s.parts.length;x++){let b=s.parts[x];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=x,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await r(t,l.offset.expression):0,u=l.length?await r(t,l.length.expression):void 0,f=Number.parseInt(t.state.env.get("#")||"0",10),h=[];for(let x=1;x<=f;x++)h.push(t.state.env.get(String(x))||"");let d=t.state.env.get("0")||"bash",p;if(c<=0){let x=[d,...h],b=x.length+c;if(b<0)p=[];else{let w=c<0?b:0;if(u!==void 0){let S=u<0?x.length+u:w+u;p=x.slice(w,Math.max(w,S))}else p=x.slice(w)}}else{let x=c-1;if(x>=h.length)p=[];else if(u!==void 0){let b=u<0?h.length+u:x+u;p=h.slice(x,Math.max(x,b))}else p=h.slice(x)}let m="";for(let x=0;x<i;x++)m+=await n(t,s.parts[x]);let g="";for(let x=i+1;x<s.parts.length;x++)g+=await n(t,s.parts[x]);if(p.length===0){let x=m+g;return{values:x?[x]:[],quoted:!0}}if(o){let x=Ye(t.state.env);return{values:[m+p.join(x)+g],quoted:!0}}return p.length===1?{values:[m+p[0]+g],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+g],quoted:!0}}async function YF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let x=s.parts[y];if(x.type==="ParameterExpansion"&&(x.parameter==="@"||x.parameter==="*")&&x.operation?.type==="PatternReplacement"){i=y,o=x.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=KF(t),u="";for(let y=0;y<i;y++)u+=await r(t,s.parts[y]);let f="";for(let y=i+1;y<s.parts.length;y++)f+=await r(t,s.parts[y]);if(c.length===0){let y=u+f;return{values:y?[y]:[],quoted:!0}}let h="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")h+=st(y.pattern,!0,t.state.shoptOptions.extglob);else if(y.type==="Literal")h+=st(y.value,!0,t.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")h+=ut(y.value);else if(y.type==="DoubleQuoted"){let x=await n(t,y.parts);h+=ut(x)}else if(y.type==="ParameterExpansion"){let x=await r(t,y);h+=st(x,!0,t.state.shoptOptions.extglob)}else{let x=await r(t,y);h+=ut(x)}let d=l.replacement?await n(t,l.replacement.parts):"",p=h;l.anchor==="start"?p=`^${h}`:l.anchor==="end"&&(p=`${h}$`);let m=[];try{let y=ae(p,l.all?"g":"");for(let x of c)m.push(y.replace(x,d))}catch{m.push(...c)}if(o){let y=Ye(t.state.env);return{values:[u+m.join(y)+f],quoted:!0}}return m.length===1?{values:[u+m[0]+f],quoted:!0}:{values:[u+m[0],...m.slice(1,-1),m[m.length-1]+f],quoted:!0}}async function XF(t,e,r,n){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let s=e[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let y=s.parts[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){i=g,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=KF(t),u="";for(let g=0;g<i;g++)u+=await r(t,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await r(t,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let h="",d=t.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")h+=st(g.pattern,l.greedy,d);else if(g.type==="Literal")h+=st(g.value,l.greedy,d);else if(g.type==="SingleQuoted"||g.type==="Escaped")h+=ut(g.value);else if(g.type==="DoubleQuoted"){let y=await n(t,g.parts);h+=ut(y)}else if(g.type==="ParameterExpansion"){let y=await r(t,g);h+=st(y,l.greedy,d)}else{let y=await r(t,g);h+=ut(y)}let p=[];for(let g of c)p.push(uo(g,h,l.side,l.greedy));if(o){let g=Ye(t.state.env);return{values:[u+p.join(g)+f],quoted:!0}}return p.length===1?{values:[u+p[0]+f],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+f],quoted:!0}}async function QF(t,e,r){if(e.length!==1||e[0].type!=="DoubleQuoted")return null;let n=e[0],s=-1,i=!1;for(let h=0;h<n.parts.length;h++){let d=n.parts[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")){s=h,i=d.parameter==="*";break}}if(s===-1)return null;let o=n.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(t.state.env.get("#")||"0",10),l="";for(let h=0;h<s;h++)l+=await r(t,n.parts[h]);let c="";for(let h=s+1;h<n.parts.length;h++)c+=await r(t,n.parts[h]);if(a===0){if(i)return{values:[l+c],quoted:!0};let h=l+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=a;h++)u.push(t.state.env.get(String(h))||"");if(i){let h=Ye(t.state.env);return{values:[l+u.join(h)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var JF=I(()=>{"use strict";Gt();Ss();Ic();Rc();el()});function Aae(t){return new Qo(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations})}async function Em(t,e){if(t.state.options.noglob)return e;let r=Aae(t),n=[];for(let s of e)if(qi(s,t.state.shoptOptions.extglob)){let i=await r.expand(s);if(i.length>0)n.push(...i);else{if(r.hasFailglob())throw new Ei(s);r.hasNullglob()||n.push(s)}}else n.push(s);return n}async function eM(t,e,r,n){let s=-1,i="",o=!1;for(let x=0;x<e.length;x++){let b=e[x];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let w=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(w){s=x,i=w[1],o=w[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=De(t,i),u=c.map(([,x])=>x);if(c.length===0){let x=t.state.env.get(i);x!==void 0&&(u=[x])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let x of l.pattern.parts)if(x.type==="Glob")f+=st(x.pattern,!0,t.state.shoptOptions.extglob);else if(x.type==="Literal")f+=st(x.value,!0,t.state.shoptOptions.extglob);else if(x.type==="SingleQuoted"||x.type==="Escaped")f+=ut(x.value);else if(x.type==="DoubleQuoted"){let b=await r(t,x.parts);f+=ut(b)}else if(x.type==="ParameterExpansion"){let b=await n(t,x);f+=st(b,!0,t.state.shoptOptions.extglob)}else{let b=await n(t,x);f+=ut(b)}let h=l.replacement?await r(t,l.replacement.parts):"",d=f;l.anchor==="start"?d=`^${f}`:l.anchor==="end"&&(d=`${f}$`);let p=[];try{let x=ae(d,l.all?"g":"");for(let b of u)p.push(x.replace(b,h))}catch{p.push(...u)}let m=Dr(t.state.env),g=dn(t.state.env);if(o){let x=Ye(t.state.env),b=p.join(x);return g?{values:b?[b]:[],quoted:!1}:{values:Yt(b,m),quoted:!1}}if(g)return{values:p,quoted:!1};let y=[];for(let x of p)x===""?y.push(""):y.push(...Yt(x,m));return{values:y,quoted:!1}}async function tM(t,e,r,n){let s=-1,i="",o=!1;for(let y=0;y<e.length;y++){let x=e[y];if(x.type==="ParameterExpansion"&&x.operation?.type==="PatternRemoval"){let b=x.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=y,i=b[1],o=b[2]==="*";break}}}if(s===-1)return null;let l=e[s].operation,c=De(t,i),u=c.map(([,y])=>y);if(c.length===0){let y=t.state.env.get(i);y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="",h=t.state.shoptOptions.extglob;if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=st(y.pattern,l.greedy,h);else if(y.type==="Literal")f+=st(y.value,l.greedy,h);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=ut(y.value);else if(y.type==="DoubleQuoted"){let x=await r(t,y.parts);f+=ut(x)}else if(y.type==="ParameterExpansion"){let x=await n(t,y);f+=st(x,l.greedy,h)}else{let x=await n(t,y);f+=ut(x)}let d=[];for(let y of u)d.push(uo(y,f,l.side,l.greedy));let p=Dr(t.state.env),m=dn(t.state.env);if(o){let y=Ye(t.state.env),x=d.join(y);return m?{values:x?[x]:[],quoted:!1}:{values:Yt(x,p),quoted:!1}}if(m)return{values:d,quoted:!1};let g=[];for(let y of d)y===""?g.push(""):g.push(...Yt(y,p));return{values:g,quoted:!1}}async function rM(t,e,r,n){let s=-1,i=!1;for(let g=0;g<e.length;g++){let y=e[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){s=g,i=y.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=Number.parseInt(t.state.env.get("#")||"0",10),c=[];for(let g=1;g<=l;g++)c.push(t.state.env.get(String(g))||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=t.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=st(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=st(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=ut(g.value);else if(g.type==="DoubleQuoted"){let y=await r(t,g.parts);u+=ut(y)}else if(g.type==="ParameterExpansion"){let y=await n(t,g);u+=st(y,a.greedy,f)}else{let y=await n(t,g);u+=ut(y)}let h=[];for(let g of c)h.push(uo(g,u,a.side,a.greedy));let d=Dr(t.state.env),p=dn(t.state.env);if(i){let g=Ye(t.state.env),y=h.join(g);return p?{values:y?[y]:[],quoted:!1}:{values:Yt(y,d),quoted:!1}}if(p)return{values:h,quoted:!1};let m=[];for(let g of h)g===""?m.push(""):m.push(...Yt(g,d));return{values:m,quoted:!1}}async function nM(t,e,r,n){let s=-1,i=!1;for(let b=0;b<e.length;b++){let w=e[b];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="Substring"){s=b,i=w.parameter==="*";break}}if(s===-1)return null;let a=e[s].operation,l=a.offset?await r(t,a.offset.expression):0,c=a.length?await r(t,a.length.expression):void 0,u=Number.parseInt(t.state.env.get("#")||"0",10),f=[];for(let b=1;b<=u;b++)f.push(t.state.env.get(String(b))||"");let h=t.state.env.get("0")||"bash",d;if(l<=0){let b=[h,...f],w=b.length+l;if(w<0)d=[];else{let S=l<0?w:0;if(c!==void 0){let _=c<0?b.length+c:S+c;d=b.slice(S,Math.max(S,_))}else d=b.slice(S)}}else{let b=l-1;if(b>=f.length)d=[];else if(c!==void 0){let w=c<0?f.length+c:b+c;d=f.slice(b,Math.max(b,w))}else d=f.slice(b)}let p="";for(let b=0;b<s;b++)p+=await n(t,e[b]);let m="";for(let b=s+1;b<e.length;b++)m+=await n(t,e[b]);let g=Dr(t.state.env),y=dn(t.state.env);if(d.length===0){let b=p+m;return b?y?{values:[b],quoted:!1}:{values:Yt(b,g),quoted:!1}:{values:[],quoted:!1}}let x;if(i){let b=Ye(t.state.env),w=p+d.join(b)+m;y?x=w?[w]:[]:x=Yt(w,g)}else if(y)d.length===1?x=[p+d[0]+m]:x=[p+d[0],...d.slice(1,-1),d[d.length-1]+m];else{x=[];for(let b=0;b<d.length;b++){let w=d[b];if(b===0&&(w=p+w),b===d.length-1&&(w=w+m),w==="")x.push("");else{let S=Yt(w,g);x.push(...S)}}}return{values:await Em(t,x),quoted:!1}}async function sM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].parameter!=="@"&&e[0].parameter!=="*"||e[0].operation)return null;let r=e[0].parameter==="*",n=Number.parseInt(t.state.env.get("#")||"0",10);if(n===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=n;c++)s.push(t.state.env.get(String(c))||"");let i=Dr(t.state.env),o=dn(t.state.env),a=pm(t.state.env),l;if(r)if(o)l=s.filter(c=>c!=="");else{let c=Ye(t.state.env),u=s.join(c);l=Yt(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=Yt(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=Yt(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await Em(t,l),quoted:!1}}async function iM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation)return null;let r=e[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!r)return null;let n=r[1],s=r[2]==="*",i=De(t,n),o;if(i.length===0){let f=t.state.env.get(n);if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=Dr(t.state.env),l=dn(t.state.env),c=pm(t.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=Ye(t.state.env),h=o.join(f);u=Yt(h,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let h=Yt(f,a);u.push(...h)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let h=Yt(f,a);u.push(...h)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await Em(t,u),quoted:!1}}function oM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="VarNamePrefix")return null;let r=e[0].operation,n=Pc(t,r.prefix);if(n.length===0)return{values:[],quoted:!1};let s=Dr(t.state.env),i=dn(t.state.env),o;if(r.star)if(i)o=n;else{let a=Ye(t.state.env),l=n.join(a);o=Yt(l,s)}else if(i)o=n;else{o=[];for(let a of n){let l=Yt(a,s);o.push(...l)}}return{values:o,quoted:!1}}function aM(t,e){if(e.length!==1||e[0].type!=="ParameterExpansion"||e[0].operation?.type!=="ArrayKeys")return null;let r=e[0].operation,s=De(t,r.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=Dr(t.state.env),o=dn(t.state.env),a;if(r.star)if(o)a=s;else{let l=Ye(t.state.env),c=s.join(l);a=Yt(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=Yt(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function lM(t,e,r){let n=-1;for(let h=0;h<e.length;h++){let d=e[h];if(d.type==="ParameterExpansion"&&(d.parameter==="@"||d.parameter==="*")&&!d.operation){n=h;break}}if(n===-1||e.length<=1)return null;let s=Number.parseInt(t.state.env.get("#")||"0",10),i=[];for(let h=1;h<=s;h++)i.push(t.state.env.get(String(h))||"");let o="";for(let h=0;h<n;h++)o+=await r(t,e[h]);let a="";for(let h=n+1;h<e.length;h++)a+=await r(t,e[h]);let l=Dr(t.state.env),c=dn(t.state.env),u=pm(t.state.env);if(s===0){let h=o+a;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let d=0;d<i.length;d++){let p=i[d];d===0&&(p=o+p),d===i.length-1&&(p=p+a),h.push(p)}if(c)f=h.filter(d=>d!=="");else if(u){f=[];for(let d of h){if(d==="")continue;let p=Yt(d,l);f.push(...p)}}else{f=[];for(let d of h)if(d==="")f.push("");else{let p=Yt(d,l);f.push(...p)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await Em(t,f),quoted:!1}}var cM=I(()=>{"use strict";Gt();fm();rt();Ss();Ic();Oc();Rc();el();as()});async function hM(t,e,r){t.coverage?.hit("bash:expansion:word_glob");let n=e.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=jf(n),h=r.hasBraceExpansion(n)?await r.expandWordWithBracesAsync(t,e):null;if(h&&h.length>1)return Cae(t,h,s);let d=await Nae(t,n,a,c,u,r);if(d!==null)return d;let p=await Tae(t,n,r);if(p!==null)return p;let m=await _ae(t,n,r);if(m!==null)return m;let g=await Iae(t,n,r.expandPart);if(g!==null)return fM(t,g);if((i||o||l)&&!dn(t.state.env)){let x=Dr(t.state.env),b=r.buildIfsCharClassPattern(x),w=await r.smartWordSplit(t,n,x,b,r.expandPart);return fM(t,w)}let y=await r.expandWordAsync(t,e);return Rae(t,e,n,y,s,r.expandWordForGlobbing)}async function Cae(t,e,r){let n=[];for(let s of e)if(!(!r&&s===""))if(!r&&!t.state.options.noglob&&qi(s,t.state.shoptOptions.extglob)){let i=await Sm(t,s);n.push(...i)}else n.push(s);return{values:n,quoted:!1}}async function Nae(t,e,r,n,s,i){if(r){let o=qF(t,e);if(o!==null)return o}{let o=zF(t,e);if(o!==null)return o}{let o=await DF(t,e);if(o!==null)return o}{let o=await LF(t,e,r,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await FF(t,e,r,i.expandPart);if(o!==null)return o}{let o=await $F(t,e,i.evaluateArithmetic);if(o!==null)return o}{let o=BF(t,e);if(o!==null)return o}{let o=await IF(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await RF(t,e,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(n&&e.length===1&&e[0].type==="DoubleQuoted"){let o=kae(t,e);if(o!==null)return o}{let o=await WF(t,e,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await jF(t,e);if(o!==null)return o}{let o=await VF(t,e);if(o!==null)return o}return null}function kae(t,e){let r=e[0];if(r.type!=="DoubleQuoted")return null;if(r.parts.length===1&&r.parts[0].type==="ParameterExpansion"&&r.parts[0].operation?.type==="VarNamePrefix"){let n=r.parts[0].operation,s=Pc(t,n.prefix);return n.star?{values:[s.join(Ye(t.state.env))],quoted:!0}:{values:s,quoted:!0}}if(r.parts.length===1&&r.parts[0].type==="ParameterExpansion"&&r.parts[0].operation?.type==="ArrayKeys"){let n=r.parts[0].operation,i=De(t,n.array).map(([o])=>String(o));return n.star?{values:[i.join(Ye(t.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function Tae(t,e,r){{let n=await ZF(t,e,r.evaluateArithmetic,r.expandPart);if(n!==null)return n}{let n=await YF(t,e,r.expandPart,r.expandWordPartsAsync);if(n!==null)return n}{let n=await XF(t,e,r.expandPart,r.expandWordPartsAsync);if(n!==null)return n}{let n=await QF(t,e,r.expandPart);if(n!==null)return n}return null}async function _ae(t,e,r){{let n=await eM(t,e,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await tM(t,e,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await rM(t,e,r.expandWordPartsAsync,r.expandPart);if(n!==null)return n}{let n=await nM(t,e,r.evaluateArithmetic,r.expandPart);if(n!==null)return n}{let n=await sM(t,e);if(n!==null)return n}{let n=await iM(t,e);if(n!==null)return n}{let n=oM(t,e);if(n!==null)return n}{let n=aM(t,e);if(n!==null)return n}{let n=await lM(t,e,r.expandPart);if(n!==null)return n}return null}function uM(t){if(t.type!=="DoubleQuoted")return null;for(let e=0;e<t.parts.length;e++){let r=t.parts[e];if(r.type!=="ParameterExpansion"||r.operation)continue;let n=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n)return{type:"array",name:n[1],atIndex:e,isStar:n[2]==="*"};if(r.parameter==="@"||r.parameter==="*")return{type:"positional",atIndex:e,isStar:r.parameter==="*"}}return null}async function Oae(t,e,r,n){let s="";for(let a=0;a<r.atIndex;a++)s+=await n(t,e.parts[a]);let i="";for(let a=r.atIndex+1;a<e.parts.length;a++)i+=await n(t,e.parts[a]);let o;if(r.type==="array"){if(o=De(t,r.name).map(([,l])=>l),o.length===0){let l=t.state.env.get(r.name);l!==void 0&&(o=[l])}}else{let a=Number.parseInt(t.state.env.get("#")||"0",10);o=[];for(let l=1;l<=a;l++)o.push(t.state.env.get(String(l))||"")}if(r.isStar){let a=Ye(t.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function Iae(t,e,r){if(e.length<2)return null;let n=!1;for(let l of e)if(uM(l)){n=!0;break}if(!n)return null;let s=Dr(t.state.env),i=dn(t.state.env),o=[];for(let l of e){let c=uM(l);if(c&&l.type==="DoubleQuoted"){let u=await Oae(t,l,c,r);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await r(t,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await r(t,l);if(i)o.push(u?[u]:[]);else{let f=Yt(u,s);o.push(f)}}else{let u=await r(t,l);if(i)o.push(u?[u]:[]);else{let f=Yt(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function fM(t,e){if(t.state.options.noglob)return{values:e,quoted:!1};let r=[];for(let n of e)if(qi(n,t.state.shoptOptions.extglob)){let s=await Sm(t,n);r.push(...s)}else r.push(n);return{values:r,quoted:!1}}async function Sm(t,e){let r=new Qo(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations}),n=await r.expand(e);if(n.length>0)return n;if(r.hasFailglob())throw new Ei(e);return r.hasNullglob()?[]:[e]}async function Rae(t,e,r,n,s,i){let o=r.some(a=>a.type==="Glob");if(!t.state.options.noglob&&o){let a=await i(t,e);if(qi(a,t.state.shoptOptions.extglob)){let c=await Sm(t,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=K7(n);if(!dn(t.state.env)){let c=Dr(t.state.env);return{values:Yt(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!t.state.options.noglob&&qi(n,t.state.shoptOptions.extglob)){let a=await i(t,e);if(qi(a,t.state.shoptOptions.extglob)){let l=await Sm(t,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(n===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=K7(n);if(!dn(t.state.env)){let l=Dr(t.state.env);return{values:Yt(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[n],quoted:s}}var dM=I(()=>{"use strict";fm();rt();Ss();hm();PF();MF();UF();HF();Oc();GF();el();JF();cM();as()});async function mM(t,e){let r=e.operation;if(!r||r.type!=="DefaultValue"&&r.type!=="AssignDefault"&&r.type!=="UseAlternative")return null;let n=r.word;if(!n||n.parts.length===0)return null;let s=await Ui(t,e.parameter),o=await gt(t,e.parameter,!1)==="",a=r.checkEmpty??!1,l;return r.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?n.parts:null}function Pae(t){return t.type==="SingleQuoted"?!0:t.type==="DoubleQuoted"?t.parts.every(r=>r.type==="Literal"):!1}async function Dae(t,e){if(e.type!=="ParameterExpansion")return null;let r=await mM(t,e);if(!r||r.length<=1)return null;let n=r.some(i=>Pae(i)),s=r.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return n&&s?r:null}function Lae(t){return t.type==="DoubleQuoted"||t.type==="SingleQuoted"||t.type==="Literal"?!1:t.type==="Glob"?q7(t.pattern):!(!(t.type==="ParameterExpansion"||t.type==="CommandSubstitution"||t.type==="ArithmeticExpansion")||t.type==="ParameterExpansion"&&QL(t))}async function gM(t,e,r,n,s){if(t.coverage?.hit("bash:expansion:word_split"),e.length===1&&e[0].type==="ParameterExpansion"){let h=e[0],d=await mM(t,h);if(d&&d.length>0&&d.length>1&&d.some(m=>m.type==="DoubleQuoted"||m.type==="SingleQuoted")&&d.some(m=>m.type==="Literal"||m.type==="ParameterExpansion"||m.type==="CommandSubstitution"||m.type==="ArithmeticExpansion"))return pM(t,d,r,n,s)}let i=[],o=!1;for(let h of e){let d=Lae(h),p=h.type==="DoubleQuoted"||h.type==="SingleQuoted",m=d?await Dae(t,h):null,g=await s(t,h);i.push({value:g,isSplittable:d,isQuoted:p,mixedDefaultParts:m??void 0}),d&&(o=!0)}if(!o){let h=i.map(d=>d.value).join("");return h?[h]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let h of i)if(!h.isSplittable)u?h.isQuoted&&h.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):h.value!==""?(l!==""&&a.push(l),l=h.value,u=!1,f=!1):(l+=h.value,f=!1):(l+=h.value,f=h.isQuoted&&h.value==="");else if(h.mixedDefaultParts){let d=await pM(t,h.mixedDefaultParts,r,n,s);if(d.length!==0)if(d.length===1)l+=d[0],c=!0;else{l+=d[0],a.push(l),c=!0;for(let p=1;p<d.length-1;p++)a.push(d[p]);l=d[d.length-1]}u=!1,f=!1}else{let{words:d,hadLeadingDelimiter:p,hadTrailingDelimiter:m}=mm(h.value,r);if(f&&p&&l===""&&(a.push(""),c=!0),d.length===0)m&&(u=!0);else if(d.length===1)l+=d[0],c=!0,u=m;else{l+=d[0],a.push(l),c=!0;for(let g=1;g<d.length-1;g++)a.push(d[g]);l=d[d.length-1],u=m}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function Fae(t,e){return t.length>0&&e.includes(t[0])}async function pM(t,e,r,n,s){let i=[];for(let u of e){let h=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),d=await s(t,u);i.push({value:d,isSplittable:h})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{Fae(u.value,r)&&a!==""&&(o.push(a),a="",l=!0);let{words:h,hadTrailingDelimiter:d}=mm(u.value,r);if(h.length===0)d&&(c=!0);else if(h.length===1)a+=h[0],l=!0,c=d;else{a+=h[0],o.push(a),l=!0;for(let p=1;p<h.length-1;p++)o.push(h[p]);a=h[h.length-1],c=d}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var yM=I(()=>{"use strict";as();Ss();hm()});function xM(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function bM(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}var wM=I(()=>{"use strict"});var n4={};ue(n4,{escapeGlobChars:()=>ls,escapeRegexChars:()=>_c,expandRedirectTarget:()=>Kf,expandWord:()=>Ae,expandWordForPattern:()=>t4,expandWordForRegex:()=>e4,expandWordWithGlob:()=>pi,getArrayElements:()=>De,getVariable:()=>gt,hasQuotedMultiValueAt:()=>Gf,isArray:()=>co,isWordFullyQuoted:()=>J7});function ra(t,e,r){if(t.length>e)throw new he(`${r}: string length limit exceeded (${e} bytes)`,"string_length")}async function di(t,e,r=!1){let n=[];for(let s of e)n.push(await vs(t,s,r));return n.join("")}function Mae(t){return bM(t)}function J7(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!Mae(e))return!1;return!0}function $ae(t,e,r=!1){let n=xM(e);if(n!==null)return n;switch(e.type){case"TildeExpansion":return r?e.user===null?"~":`~${e.user}`:(t.coverage?.hit("bash:expansion:tilde"),e.user===null?t.state.env.get("HOME")??"/home/user":e.user==="root"?"/root":`~${e.user}`);case"Glob":return X7(t,e.pattern);default:return null}}async function Ae(t,e){return r4(t,e)}async function e4(t,e){let r=[];for(let n of e.parts)if(n.type==="Escaped")r.push(`\\${n.value}`);else if(n.type==="SingleQuoted")r.push(n.value);else if(n.type==="DoubleQuoted"){let s=await di(t,n.parts);r.push(s)}else if(n.type==="TildeExpansion"){let s=await vs(t,n);r.push(_c(s))}else r.push(await vs(t,n));return r.join("")}async function t4(t,e){let r=[];for(let n of e.parts)if(n.type==="Escaped"){let s=n.value;"()|*?[]".includes(s)?r.push(`\\${s}`):r.push(s)}else if(n.type==="SingleQuoted")r.push(ls(n.value));else if(n.type==="DoubleQuoted"){let s=await di(t,n.parts);r.push(ls(s))}else r.push(await vs(t,n));return r.join("")}async function EM(t,e){let r=[];for(let n of e.parts)if(n.type==="SingleQuoted")r.push(ls(n.value));else if(n.type==="Escaped"){let s=n.value;"*?[]\\()|".includes(s)?r.push(`\\${s}`):r.push(s)}else if(n.type==="DoubleQuoted"){let s=await di(t,n.parts);r.push(ls(s))}else n.type==="Glob"?CF(n.pattern)?r.push(await kF(t,n.pattern)):r.push(X7(t,n.pattern)):n.type==="Literal"?r.push(n.value):r.push(await vs(t,n));return r.join("")}function Am(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&Am(e.parts))return!0;return!1}async function SM(t,e,r={count:0}){if(r.count>Q7)return[[]];let n=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=G7(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)r.count++,i.push(h);else{o=!0,a=f.literal;break}}else{let f=await SM(t,u.word.parts,r);for(let h of f){r.count++;let d=[];for(let p of h)typeof p=="string"?d.push(p):d.push(await vs(t,p));i.push(d.join(""))}}if(o){for(let u of n)r.count++,u.push(a);continue}if(n.length*i.length>t.limits.maxBraceExpansionResults||r.count>Q7)return n;let c=[];for(let u of n)for(let f of i){if(r.count++,r.count>Q7)return c.length>0?c:n;c.push([...u,f])}n=c}else for(let i of n)r.count++,i.push(s);return n}async function vM(t,e){let r=e.parts;if(!Am(r))return[await Ae(t,e)];let n=await SM(t,r),s=[];for(let i of n){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await vs(t,a));s.push(_F(t,o.join("")))}return s}function Bae(){return{expandWordAsync:r4,expandWordForGlobbing:EM,expandWordWithBracesAsync:vM,expandWordPartsAsync:di,expandPart:vs,expandParameterAsync:vm,hasBraceExpansion:Am,evaluateArithmetic:be,buildIfsCharClassPattern:JL,smartWordSplit:gM}}async function pi(t,e){return hM(t,e,Bae())}function Uae(t){for(let e of t){if(e.type==="ParameterExpansion")return e.parameter;if(e.type==="Literal")return e.value}return""}function Gf(t,e){if(Number.parseInt(t.state.env.get("#")||"0",10)<2)return!1;function n(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return n(e.parts)}async function Kf(t,e){if(Gf(t,e))return{error:`bash: $@: ambiguous redirect
1482
1482
  `};let r=e.parts,{hasQuoted:n}=jf(r);if(Am(r)&&(await vM(t,e)).length>1)return{error:`bash: ${r.map(d=>d.type==="Literal"?d.value:d.type==="BraceExpansion"?`{${d.items.map(m=>{if(m.type==="Range"){let g=m.step?`..${m.step}`:"";return`${m.startStr??m.start}..${m.endStr??m.end}${g}`}return m.word.parts.map(g=>g.type==="Literal"?g.value:"").join("")}).join(",")}}`:"").join("")}: ambiguous redirect
1483
1483
  `};let s=await r4(t,e),{hasParamExpansion:i,hasCommandSub:o}=jf(r);if((i||o)&&!n&&!dn(t.state.env)){let f=Dr(t.state.env);if(Yt(s,f).length>1)return{error:`bash: $${Uae(r)}: ambiguous redirect
1484
1484
  `}}if(n||t.state.options.noglob)return{target:s};let l=await EM(t,e);if(!qi(l,t.state.shoptOptions.extglob))return{target:s};let c=new Qo(t.fs,t.state.cwd,t.state.env,{globstar:t.state.shoptOptions.globstar,nullglob:t.state.shoptOptions.nullglob,failglob:t.state.shoptOptions.failglob,dotglob:t.state.shoptOptions.dotglob,extglob:t.state.shoptOptions.extglob,globskipdots:t.state.shoptOptions.globskipdots,maxGlobOperations:t.limits.maxGlobOperations}),u=await c.expand(l);return u.length===0?c.hasFailglob()?{error:`bash: no match: ${s}
1485
1485
  `}:{target:s}:u.length===1?{target:u[0]}:{error:`bash: ${s}: ambiguous redirect
1486
- `}}async function r4(t,e){let r=e.parts,n=r.length;if(n===1){let o=await vs(t,r[0]);return ra(o,t.limits.maxStringLength,"word expansion"),o}let s=[];for(let o=0;o<n;o++)s.push(await vs(t,r[o]));let i=s.join("");return ra(i,t.limits.maxStringLength,"word expansion"),i}async function vs(t,e,r=!1){if(e.type==="ParameterExpansion")return vm(t,e,r);let n=$ae(t,e,r);if(n!==null)return n;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(await vs(t,i,!0));return s.join("")}case"CommandSubstitution":{let s=lF(e.body);if(s)try{let h=await Ae(t,s.target),d=h.startsWith("/")?h:`${t.state.cwd}/${h}`,p=await t.fs.readFile(d);t.state.lastExitCode=0,t.state.env.set("?","0");let m=p.replace(/\n+$/,"");return ra(m,t.limits.maxStringLength,"command substitution"),m}catch(h){if(h instanceof fe)throw h;return t.state.lastExitCode=1,t.state.env.set("?","1"),""}let i=t.substitutionDepth??0,o=t.limits.maxSubstitutionDepth;if(i>=o)throw new fe(`Command substitution nesting limit exceeded (${o})`,"substitution_depth");let a=t.substitutionDepth;t.substitutionDepth=i+1;let l=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let c=new Map(t.state.env),u=t.state.cwd,f=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let h=await t.executeScript(e.body),d=h.exitCode;t.state.env=c,t.state.cwd=u,t.state.suppressVerbose=f,t.state.lastExitCode=d,t.state.env.set("?",String(d)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr),t.state.bashPid=l,t.substitutionDepth=a;let p=h.stdout.replace(/\n+$/,"");return ra(p,t.limits.maxStringLength,"command substitution"),p}catch(h){if(t.state.env=c,t.state.cwd=u,t.state.bashPid=l,t.substitutionDepth=a,t.state.suppressVerbose=f,h instanceof fe)throw h;if(h instanceof Xe){t.state.lastExitCode=h.exitCode,t.state.env.set("?",String(h.exitCode)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr);let d=h.stdout.replace(/\n+$/,"");return ra(d,t.limits.maxStringLength,"command substitution"),d}throw h}}case"ArithmeticExpansion":{let s=e.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let o=await iF(t,s),a=new je,l=mt(a,o);return String(await be(t,l.expression,!0))}return String(await be(t,e.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=G7(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(await Ae(t,i.word));return s.join(" ")}default:return""}}async function vm(t,e,r=!1){let{parameter:n}=e,{operation:s}=e,i=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,h,d]=i;if(t.state.associativeArrays?.has(h)||d.includes("$(")||d.includes("`")||d.includes("${")){let m=await V7(t,d);n=`${h}[${m}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&Bt(t,n)){let h=Ln(t,n);if(h&&h!==n){let d=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let[,p,m]=d;if(t.state.associativeArrays?.has(p)||m.includes("$(")||m.includes("`")||m.includes("${")){let y=await V7(t,m);n=`${p}[${y}]`}}}}let o=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),a=await gt(t,n,!o);if(!s)return a;let l=!await Ui(t,n),{isEmpty:c,effectiveValue:u}=vF(t,n,a,r),f={value:a,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:r};switch(s.type){case"DefaultValue":return uF(t,s,f,di);case"AssignDefault":return fF(t,n,s,f,di);case"ErrorIfUnset":return hF(t,n,s,f,di);case"UseAlternative":return dF(t,s,f,di);case"PatternRemoval":{let h=await pF(t,a,s,di,vs);return ra(h,t.limits.maxStringLength,"pattern removal"),h}case"PatternReplacement":{let h=await mF(t,a,s,di,vs);return ra(h,t.limits.maxStringLength,"pattern replacement"),h}case"Length":return gF(t,n,a);case"LengthSliceError":throw new kn(n);case"BadSubstitution":throw new kn(s.text);case"Substring":return yF(t,n,a,s);case"CaseModification":{let h=await xF(t,a,s,di,vm);return ra(h,t.limits.maxStringLength,"case modification"),h}case"Transform":return bF(t,n,a,l,s);case"Indirection":return wF(t,n,a,l,s,vm,r);case"ArrayKeys":return EF(t,s);case"VarNamePrefix":return SF(t,s);default:return a}}var Q7,Mn=I(()=>{"use strict";vn();mr();fm();Fn();rt();hm();oF();aF();cF();Oc();AF();TF();OF();as();dM();yM();Ss();fi();wM();Oc();as();Q7=1e5});function qae(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":if(e===0)throw new It("division by 0");return Math.trunc(t/e);case"%":if(e===0)throw new It("division by 0");return t%e;case"**":if(e<0)throw new It("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function AM(t,e,r){switch(r){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function zae(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}async function Hae(t,e){let r=t.state.env.get(e);if(r!==void 0)return r;let n=t.state.env.get(`${e}_0`);return n!==void 0?n:await gt(t,e)}function Wae(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let r=t.trim();if(!r)return 0;try{let n=new je,{expr:s,pos:i}=Es(n,r,0);if(i<r.length){let o=r.slice(i).trim().split(/\s+/)[0];throw new It(`${r}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(n){if(n instanceof It)throw n;let s=r.split(/\s+/).slice(1)[0]||r;throw new It(`${r}: syntax error in expression (error token is "${s}")`)}}async function s4(t,e){if(!e)return 0;let r=Number.parseInt(e,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(e.trim()))return r;let n=e.trim();if(!n)return 0;let s=new je,{expr:i,pos:o}=Es(s,n,0);if(o<n.length){let a=n.slice(o).trim(),l=a.split(/\s+/)[0]||a;throw new It(`syntax error in expression (error token is "${l}")`,"","")}return await be(t,i)}async function i4(t,e,r=new Set,n=0){if(n>100)throw new It("maximum variable indirection depth exceeded");if(r.has(e))return 0;r.add(e);let s=await Hae(t,e);if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s.trim()))return i;let o=s.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o))return await i4(t,o,r,n+1);let a=new je,{expr:l,pos:c}=Es(a,o,0);if(c<o.length){let u=o.slice(c).trim(),f=u.split(/\s+/)[0]||u;throw new It(`${o}: syntax error in expression (error token is "${f}")`)}return await be(t,l)}async function Cm(t,e){if(e.startsWith("#")){let f=e.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let p=h[1],m=De(t,p);return String(m.length)}let d=t.state.env.get(f)||"";return String(d.length)}if(e.startsWith("!")){let f=e.slice(1),h=t.state.env.get(f)||"";return t.state.env.get(h)||""}let r=[":-",":=",":?",":+","-","=","?","+"],n=-1,s="";for(let f of r){let h=e.indexOf(f);h>0&&(n===-1||h<n)&&(n=h,s=f)}if(n===-1)return await gt(t,e);let i=e.slice(0,n),o=e.slice(n+s.length),a=t.state.env.get(i),l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env.set(i,o),o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}async function be(t,e,r=!1){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new It("value too great for base");return e.value;case"ArithVariable":return await i4(t,e.name);case"ArithSpecialVar":{let s=(await gt(t,e.name)).trim();if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s))return i;let o=new je,{expr:a}=Es(o,s,0);return await be(t,a)}case"ArithNested":return await be(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let n=await t.execFn(e.command,{signal:t.state.signal});n.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+n.stderr);let s=n.stdout.trim();return Number.parseInt(s,10)||0}return 0}case"ArithBracedExpansion":{let n=await Cm(t,e.content);return Number.parseInt(n,10)||0}case"ArithDynamicBase":{let n=await Cm(t,e.baseExpr),s=Number.parseInt(n,10);if(s<2||s>64)return 0;let i=`${s}#${e.value}`;return zf(i)}case"ArithDynamicNumber":{let s=await Cm(t,e.prefix)+e.suffix;return zf(s)}case"ArithArrayElement":{let n=t.state.associativeArrays?.has(e.array),s=async i=>{let o=t.state.env.get(i);return o!==void 0?await s4(t,o):0};if(e.stringKey!==void 0)return await s(`${e.array}_${e.stringKey}`);if(n&&e.index?.type==="ArithVariable"&&!e.index.hasDollarPrefix)return await s(`${e.array}_${e.index.name}`);if(n&&e.index?.type==="ArithVariable"&&e.index.hasDollarPrefix){let i=await gt(t,e.index.name);return await s(`${e.array}_${i}`)}if(e.index){let i=await be(t,e.index,r);if(i<0){let l=De(t,e.array),c=t.state.currentLine;if(l.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${c}: ${e.array}: bad array subscript
1486
+ `}}async function r4(t,e){let r=e.parts,n=r.length;if(n===1){let o=await vs(t,r[0]);return ra(o,t.limits.maxStringLength,"word expansion"),o}let s=[];for(let o=0;o<n;o++)s.push(await vs(t,r[o]));let i=s.join("");return ra(i,t.limits.maxStringLength,"word expansion"),i}async function vs(t,e,r=!1){if(e.type==="ParameterExpansion")return vm(t,e,r);let n=$ae(t,e,r);if(n!==null)return n;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(await vs(t,i,!0));return s.join("")}case"CommandSubstitution":{let s=lF(e.body);if(s)try{let h=await Ae(t,s.target),d=h.startsWith("/")?h:`${t.state.cwd}/${h}`,p=await t.fs.readFile(d);t.state.lastExitCode=0,t.state.env.set("?","0");let m=p.replace(/\n+$/,"");return ra(m,t.limits.maxStringLength,"command substitution"),m}catch(h){if(h instanceof he)throw h;return t.state.lastExitCode=1,t.state.env.set("?","1"),""}let i=t.substitutionDepth??0,o=t.limits.maxSubstitutionDepth;if(i>=o)throw new he(`Command substitution nesting limit exceeded (${o})`,"substitution_depth");let a=t.substitutionDepth;t.substitutionDepth=i+1;let l=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let c=new Map(t.state.env),u=t.state.cwd,f=t.state.suppressVerbose;t.state.suppressVerbose=!0;try{let h=await t.executeScript(e.body),d=h.exitCode;t.state.env=c,t.state.cwd=u,t.state.suppressVerbose=f,t.state.lastExitCode=d,t.state.env.set("?",String(d)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr),t.state.bashPid=l,t.substitutionDepth=a;let p=h.stdout.replace(/\n+$/,"");return ra(p,t.limits.maxStringLength,"command substitution"),p}catch(h){if(t.state.env=c,t.state.cwd=u,t.state.bashPid=l,t.substitutionDepth=a,t.state.suppressVerbose=f,h instanceof he)throw h;if(h instanceof Xe){t.state.lastExitCode=h.exitCode,t.state.env.set("?",String(h.exitCode)),h.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+h.stderr);let d=h.stdout.replace(/\n+$/,"");return ra(d,t.limits.maxStringLength,"command substitution"),d}throw h}}case"ArithmeticExpansion":{let s=e.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let o=await iF(t,s),a=new je,l=mt(a,o);return String(await be(t,l.expression,!0))}return String(await be(t,e.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=G7(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(await Ae(t,i.word));return s.join(" ")}default:return""}}async function vm(t,e,r=!1){let{parameter:n}=e,{operation:s}=e,i=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,h,d]=i;if(t.state.associativeArrays?.has(h)||d.includes("$(")||d.includes("`")||d.includes("${")){let m=await V7(t,d);n=`${h}[${m}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&Bt(t,n)){let h=Ln(t,n);if(h&&h!==n){let d=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let[,p,m]=d;if(t.state.associativeArrays?.has(p)||m.includes("$(")||m.includes("`")||m.includes("${")){let y=await V7(t,m);n=`${p}[${y}]`}}}}let o=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),a=await gt(t,n,!o);if(!s)return a;let l=!await Ui(t,n),{isEmpty:c,effectiveValue:u}=vF(t,n,a,r),f={value:a,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:r};switch(s.type){case"DefaultValue":return uF(t,s,f,di);case"AssignDefault":return fF(t,n,s,f,di);case"ErrorIfUnset":return hF(t,n,s,f,di);case"UseAlternative":return dF(t,s,f,di);case"PatternRemoval":{let h=await pF(t,a,s,di,vs);return ra(h,t.limits.maxStringLength,"pattern removal"),h}case"PatternReplacement":{let h=await mF(t,a,s,di,vs);return ra(h,t.limits.maxStringLength,"pattern replacement"),h}case"Length":return gF(t,n,a);case"LengthSliceError":throw new kn(n);case"BadSubstitution":throw new kn(s.text);case"Substring":return yF(t,n,a,s);case"CaseModification":{let h=await xF(t,a,s,di,vm);return ra(h,t.limits.maxStringLength,"case modification"),h}case"Transform":return bF(t,n,a,l,s);case"Indirection":return wF(t,n,a,l,s,vm,r);case"ArrayKeys":return EF(t,s);case"VarNamePrefix":return SF(t,s);default:return a}}var Q7,Mn=I(()=>{"use strict";vn();mr();fm();Fn();rt();hm();oF();aF();cF();Oc();AF();TF();OF();as();dM();yM();Ss();fi();wM();Oc();as();Q7=1e5});function qae(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":if(e===0)throw new It("division by 0");return Math.trunc(t/e);case"%":if(e===0)throw new It("division by 0");return t%e;case"**":if(e<0)throw new It("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function AM(t,e,r){switch(r){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function zae(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}async function Hae(t,e){let r=t.state.env.get(e);if(r!==void 0)return r;let n=t.state.env.get(`${e}_0`);return n!==void 0?n:await gt(t,e)}function Wae(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let r=t.trim();if(!r)return 0;try{let n=new je,{expr:s,pos:i}=Es(n,r,0);if(i<r.length){let o=r.slice(i).trim().split(/\s+/)[0];throw new It(`${r}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(n){if(n instanceof It)throw n;let s=r.split(/\s+/).slice(1)[0]||r;throw new It(`${r}: syntax error in expression (error token is "${s}")`)}}async function s4(t,e){if(!e)return 0;let r=Number.parseInt(e,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(e.trim()))return r;let n=e.trim();if(!n)return 0;let s=new je,{expr:i,pos:o}=Es(s,n,0);if(o<n.length){let a=n.slice(o).trim(),l=a.split(/\s+/)[0]||a;throw new It(`syntax error in expression (error token is "${l}")`,"","")}return await be(t,i)}async function i4(t,e,r=new Set,n=0){if(n>100)throw new It("maximum variable indirection depth exceeded");if(r.has(e))return 0;r.add(e);let s=await Hae(t,e);if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s.trim()))return i;let o=s.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o))return await i4(t,o,r,n+1);let a=new je,{expr:l,pos:c}=Es(a,o,0);if(c<o.length){let u=o.slice(c).trim(),f=u.split(/\s+/)[0]||u;throw new It(`${o}: syntax error in expression (error token is "${f}")`)}return await be(t,l)}async function Cm(t,e){if(e.startsWith("#")){let f=e.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let p=h[1],m=De(t,p);return String(m.length)}let d=t.state.env.get(f)||"";return String(d.length)}if(e.startsWith("!")){let f=e.slice(1),h=t.state.env.get(f)||"";return t.state.env.get(h)||""}let r=[":-",":=",":?",":+","-","=","?","+"],n=-1,s="";for(let f of r){let h=e.indexOf(f);h>0&&(n===-1||h<n)&&(n=h,s=f)}if(n===-1)return await gt(t,e);let i=e.slice(0,n),o=e.slice(n+s.length),a=t.state.env.get(i),l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env.set(i,o),o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}async function be(t,e,r=!1){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new It("value too great for base");return e.value;case"ArithVariable":return await i4(t,e.name);case"ArithSpecialVar":{let s=(await gt(t,e.name)).trim();if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s))return i;let o=new je,{expr:a}=Es(o,s,0);return await be(t,a)}case"ArithNested":return await be(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let n=await t.execFn(e.command,{signal:t.state.signal});n.stderr&&(t.state.expansionStderr=(t.state.expansionStderr||"")+n.stderr);let s=n.stdout.trim();return Number.parseInt(s,10)||0}return 0}case"ArithBracedExpansion":{let n=await Cm(t,e.content);return Number.parseInt(n,10)||0}case"ArithDynamicBase":{let n=await Cm(t,e.baseExpr),s=Number.parseInt(n,10);if(s<2||s>64)return 0;let i=`${s}#${e.value}`;return zf(i)}case"ArithDynamicNumber":{let s=await Cm(t,e.prefix)+e.suffix;return zf(s)}case"ArithArrayElement":{let n=t.state.associativeArrays?.has(e.array),s=async i=>{let o=t.state.env.get(i);return o!==void 0?await s4(t,o):0};if(e.stringKey!==void 0)return await s(`${e.array}_${e.stringKey}`);if(n&&e.index?.type==="ArithVariable"&&!e.index.hasDollarPrefix)return await s(`${e.array}_${e.index.name}`);if(n&&e.index?.type==="ArithVariable"&&e.index.hasDollarPrefix){let i=await gt(t,e.index.name);return await s(`${e.array}_${i}`)}if(e.index){let i=await be(t,e.index,r);if(i<0){let l=De(t,e.array),c=t.state.currentLine;if(l.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${c}: ${e.array}: bad array subscript
1487
1487
  `,0;let f=Math.max(...l.map(([h])=>typeof h=="number"?h:0))+1+i;if(f<0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: line ${c}: ${e.array}: bad array subscript
1488
- `,0;i=f}let o=`${e.array}_${i}`,a=t.state.env.get(o);if(a!==void 0)return s4(t,a);if(i===0){let l=t.state.env.get(e.array);if(l!==void 0)return s4(t,l)}if(t.state.options.nounset&&!Array.from(t.state.env.keys()).some(c=>c===e.array||c.startsWith(`${e.array}_`)))throw new Nn(`${e.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new It("double subscript","","");case"ArithNumberSubscript":throw new It(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithSyntaxError":throw new It(e.message,"","",!0);case"ArithSingleQuote":{if(r)throw new It(`syntax error: operand expected (error token is "'${e.content}'")`);return e.value}case"ArithBinary":{if(e.operator==="||")return await be(t,e.left,r)||await be(t,e.right,r)?1:0;if(e.operator==="&&")return await be(t,e.left,r)&&await be(t,e.right,r)?1:0;let n=await be(t,e.left,r),s=await be(t,e.right,r);return qae(n,s,e.operator)}case"ArithUnary":{let n=await be(t,e.operand,r);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let s=e.operand.name,i=Number.parseInt(await gt(t,s),10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}if(e.operand.type==="ArithArrayElement"){let s=e.operand.array,i=t.state.associativeArrays?.has(s),o;if(e.operand.stringKey!==void 0)o=`${s}_${e.operand.stringKey}`;else if(i&&e.operand.index?.type==="ArithVariable"&&!e.operand.index.hasDollarPrefix)o=`${s}_${e.operand.index.name}`;else if(i&&e.operand.index?.type==="ArithVariable"&&e.operand.index.hasDollarPrefix){let c=await gt(t,e.operand.index.name);o=`${s}_${c}`}else if(e.operand.index){let c=await be(t,e.operand.index,r);o=`${s}_${c}`}else return n;let a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}if(e.operand.type==="ArithConcat"){let s="";for(let i of e.operand.parts)s+=await Dc(t,i,r);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}}if(e.operand.type==="ArithDynamicElement"){let s="";if(e.operand.nameExpr.type==="ArithConcat")for(let i of e.operand.nameExpr.parts)s+=await Dc(t,i,r);else e.operand.nameExpr.type==="ArithVariable"&&(s=e.operand.nameExpr.hasDollarPrefix?await gt(t,e.operand.nameExpr.name):e.operand.nameExpr.name);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=await be(t,e.operand.subscript,r),o=`${s}_${i}`,a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}}return n}return zae(n,e.operator)}case"ArithTernary":return await be(t,e.condition,r)?await be(t,e.consequent,r):await be(t,e.alternate,r);case"ArithAssignment":{let n=e.variable,s=n;if(e.stringKey!==void 0)s=`${n}_${e.stringKey}`;else if(e.subscript){let l=t.state.associativeArrays?.has(n);if(l&&e.subscript.type==="ArithVariable"&&!e.subscript.hasDollarPrefix)s=`${n}_${e.subscript.name}`;else if(l&&e.subscript.type==="ArithVariable"&&e.subscript.hasDollarPrefix){let c=await gt(t,e.subscript.name);s=`${n}_${c||"\\"}`}else if(l){let c=await be(t,e.subscript,r);s=`${n}_${c}`}else{let c=await be(t,e.subscript,r);if(c<0){let u=De(t,n);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}s=`${n}_${c}`}}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await be(t,e.value,r),a=AM(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithGroup":return await be(t,e.expression,r);case"ArithConcat":{let n="";for(let s of e.parts)n+=await Dc(t,s,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?await i4(t,n):Number.parseInt(n,10)||0}case"ArithDynamicAssignment":{let n="";if(e.target.type==="ArithConcat")for(let l of e.target.parts)n+=await Dc(t,l,r);else e.target.type==="ArithVariable"&&(n=e.target.hasDollarPrefix?await gt(t,e.target.name):e.target.name);if(!n||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return 0;let s=n;if(e.subscript){let l=await be(t,e.subscript,r);s=`${n}_${l}`}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await be(t,e.value,r),a=AM(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithDynamicElement":{let n="";if(e.nameExpr.type==="ArithConcat")for(let a of e.nameExpr.parts)n+=await Dc(t,a,r);else e.nameExpr.type==="ArithVariable"&&(n=e.nameExpr.hasDollarPrefix?await gt(t,e.nameExpr.name):e.nameExpr.name);if(!n||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return 0;let s=await be(t,e.subscript,r),i=`${n}_${s}`,o=t.state.env.get(i);return o!==void 0?Wae(o):0}default:return 0}}async function Dc(t,e,r=!1){switch(e.type){case"ArithNumber":return String(e.value);case"ArithSingleQuote":return String(await be(t,e,r));case"ArithVariable":return e.hasDollarPrefix?await gt(t,e.name):e.name;case"ArithSpecialVar":return await gt(t,e.name);case"ArithBracedExpansion":return await Cm(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command,{signal:t.state.signal})).stdout.trim():"0";case"ArithConcat":{let n="";for(let s of e.parts)n+=await Dc(t,s,r);return n}default:return String(await be(t,e,r))}}var Fn=I(()=>{"use strict";vn();mr();rt();Mn()});var Gce={};ue(Gce,{Bash:()=>Hc,BashTransformPipeline:()=>r1,CommandCollectorPlugin:()=>n1,DefenseInDepthBox:()=>Et,EMPTY_BYTES:()=>Sh,InMemoryFs:()=>$i,MountableFs:()=>rh,NetworkAccessDeniedError:()=>Ws,OverlayFs:()=>ll,ReadWriteFs:()=>nh,RedirectNotAllowedError:()=>sl,Sandbox:()=>sh,SandboxCommand:()=>cl,SecurityViolationError:()=>Fe,SecurityViolationLogger:()=>ih,TeePlugin:()=>s1,TooManyRedirectsError:()=>nl,bytesOutput:()=>vS,createConsoleViolationCallback:()=>tS,decodeBytesToUtf8:()=>he,defineCommand:()=>ZD,encodeUtf8ToBytes:()=>Ts,getCommandNames:()=>UD,getJavaScriptCommandNames:()=>VD,getNetworkCommandNames:()=>qD,getPythonCommandNames:()=>WD,latin1FromBytes:()=>ir,parse:()=>Dn,serialize:()=>zc,stdoutAsBytes:()=>Zc,stdoutKind:()=>C1,textOutput:()=>SS,unsafeBytesFromLatin1:()=>bo});module.exports=bS(Gce);bi();$r();var Ka=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(A1(),ES))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(k1(),AS))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(O1(),PS))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(U1(),i8))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(z1(),a8))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(W1(),u8))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(V1(),f8))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(K1(),h8))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Y1(),d8))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(Q1(),p8))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(eg(),m8))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(ng(),y8))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(ig(),x8))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(ag(),b8))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(ug(),S8))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(hg(),v8))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(mg(),C8))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(yg(),N8))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(nu(),qh))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(nu(),qh))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(nu(),qh))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(jg(),x9))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(t2(),_9))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(p2(),av))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(y2(),gv))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(b2(),yv))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(E2(),xv))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(v2(),bv))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(C2(),Ev))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(k2(),vv))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(_2(),Av))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(I2(),Nv))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(P2(),Tv))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(L2(),Ov))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(M2(),Pv))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(B2(),Fv))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(q2(),Bv))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(H2(),qv))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(V2(),zv))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(K2(),Hv))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(X2(),Xv))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(J2(),Qv))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(ty(),Jv))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(ny(),tA))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(iy(),nA))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(id(),ly))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(id(),ly))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(od(),fy))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(od(),fy))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(dy(),iA))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(my(),oA))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(ad(),xy))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(ad(),xy))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(wy(),aA))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(ld(),vy))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(ld(),vy))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(qy(),RA))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Hy(),DA))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Zy(),UA))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Xy(),qA))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(ex(),HA))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(rx(),WA))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(sx(),VA))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(ox(),GA))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(lx(),KA))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(ux(),YA))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(hx(),XA))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(px(),QA))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(Lx(),cC))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(cw(),RT))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(fw(),PT))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(dw(),DT))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(mw(),LT))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(yw(),FT))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(bw(),MT))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(Ew(),$T))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Hu(),Ap))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Hu(),Ap))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Hu(),Ap))).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ka.push({name:"tar",load:async()=>(await Promise.resolve().then(()=>(qw(),__))).tarCommand}),Ka.push({name:"yq",load:async()=>(await Promise.resolve().then(()=>(n3(),IP))).yqCommand}),Ka.push({name:"xan",load:async()=>(await Promise.resolve().then(()=>(X3(),QP))).xanCommand}),Ka.push({name:"sqlite3",load:async()=>(await Promise.resolve().then(()=>(J3(),fD))).sqlite3Command}));var rm=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(rm.push({name:"python3",load:async()=>(await Promise.resolve().then(()=>(n7(),r7))).python3Command}),rm.push({name:"python",load:async()=>(await Promise.resolve().then(()=>(n7(),r7))).pythonCommand}));var nm=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(nm.push({name:"js-exec",load:async()=>(await Promise.resolve().then(()=>(i7(),s7))).jsExecCommand}),nm.push({name:"node",load:async()=>(await Promise.resolve().then(()=>(i7(),s7))).nodeStubCommand}));var BD=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(RD(),ID))).curlCommand}],$D=new Map;function sm(t){return{name:t.name,async execute(e,r){let n=$D.get(t.name);if(n||(n=await Et.runTrustedAsync(()=>t.load()),$D.set(t.name,n)),r.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await Promise.resolve().then(()=>(MD(),FD));s(r.coverage,t.name,e)}return n.execute(e,r)}}}function UD(){return Ka.map(t=>t.name)}function qD(){return BD.map(t=>t.name)}function zD(t){return(t?Ka.filter(r=>t.includes(r.name)):Ka).map(sm)}function HD(){return BD.map(sm)}function WD(){return rm.map(t=>t.name)}function jD(){return rm.map(sm)}function VD(){return nm.map(t=>t.name)}function GD(){return nm.map(sm)}function KD(t){return"load"in t&&typeof t.load=="function"}function ZD(t,e){return{name:t,trusted:!0,execute:e}}function YD(t){let e=null;return{name:t.name,trusted:!0,async execute(r,n){return e||(e=await t.load()),e.execute(r,n)}}}Re();Re();Sc();function we(t){if(!t||t==="/")return"/";let e=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;e.startsWith("/")||(e=`/${e}`);let r=e.split("/").filter(s=>s&&s!=="."),n=[];for(let s of r)s===".."?n.pop():n.push(s);return`/${n.join("/")}`||"/"}function Se(t,e){if(t.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${e} '${t}'`)}function Za(t){let e=we(t);if(e==="/")return"/";let r=e.lastIndexOf("/");return r===0?"/":e.slice(0,r)}function Go(t,e){if(e.startsWith("/"))return we(e);let r=t==="/"?`/${e}`:`${t}/${e}`;return we(r)}function Ko(t,e){return t==="/"?`/${e}`:`${t}/${e}`}function Ac(t,e){if(e.startsWith("/"))return we(e);let r=Za(t);return we(Ko(r,e))}var Cc=new TextEncoder;function boe(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var $i=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[r,n]of Object.entries(e))typeof n=="function"?this.writeFileLazy(r,n):boe(n)?this.writeFileSync(r,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(r,n)}ensureParentDirs(e){let r=Za(e);r!=="/"&&(this.data.has(r)||(this.ensureParentDirs(r),this.data.set(r,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,r,n,s){Se(e,"write");let i=we(e);this.ensureParentDirs(i);let o=zs(n),a=ao(r,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}writeFileLazy(e,r,n){Se(e,"write");let s=we(e);this.ensureParentDirs(s),this.data.set(s,{type:"file",lazy:r,mode:n?.mode??420,mtime:n?.mtime??new Date})}async materializeLazy(e,r){let n=await r.lazy(),i={type:"file",content:typeof n=="string"?Cc.encode(n):n,mode:r.mode,mtime:r.mtime};return this.data.set(e,i),i}async readFile(e,r){let n=await this.readFileBuffer(e),s=zs(r);return xs(n,s)}async readFileBytes(e){let r=await this.readFileBuffer(e);return xs(r,"binary")}async readFileBuffer(e){Se(e,"open");let r=this.resolvePathWithSymlinks(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if("lazy"in n){let s=await this.materializeLazy(r,n);return s.content instanceof Uint8Array?s.content:Cc.encode(s.content)}return n.content instanceof Uint8Array?n.content:Cc.encode(n.content)}async writeFile(e,r,n){this.writeFileSync(e,r,n)}async appendFile(e,r,n){Se(e,"append");let s=we(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=zs(n),a=ao(r,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(s,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:Cc.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(s,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(e,r,n)}async exists(e){if(e.includes("\0"))return!1;try{let r=this.resolvePathWithSymlinks(e);return this.data.has(r)}catch{return!1}}async stat(e){Se(e,"stat");let r=this.resolvePathWithSymlinks(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);n.type==="file"&&"lazy"in n&&(n=await this.materializeLazy(r,n));let s=0;return n.type==="file"&&"content"in n&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=Cc.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}async lstat(e){Se(e,"lstat");let r=this.resolveIntermediateSymlinks(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};n.type==="file"&&"lazy"in n&&(n=await this.materializeLazy(r,n));let s=0;return n.type==="file"&&"content"in n&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=Cc.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}resolveIntermediateSymlinks(e){let r=we(e);if(r==="/")return"/";let n=r.slice(1).split("/");if(n.length<=1)return r;let s="",i=new Set;for(let o=0;o<n.length-1;o++){let a=n[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=Ac(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${n[n.length-1]}`}resolvePathWithSymlinks(e){let r=we(e);if(r==="/")return"/";let n=r.slice(1).split("/"),s="",i=new Set;for(let o of n){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=Ac(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,r){this.mkdirSync(e,r)}mkdirSync(e,r){Se(e,"mkdir");let n=we(e);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!r?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=Za(n);if(s!=="/"&&!this.data.has(s))if(r?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(n=>n.name)}async readdirWithFileTypes(e){Se(e,"scandir");let r=we(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;n&&n.type==="symlink";){if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(r),r=Ac(r,n.target),n=this.data.get(r)}if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=r==="/"?"/":`${r}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==r&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(e,r){Se(e,"rm");let n=we(e),s=this.data.get(n);if(!s){if(r?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!r?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=Ko(n,o);await this.rm(a,r)}}}this.data.delete(n)}async cp(e,r,n){Se(e,"cp"),Se(r,"cp");let s=we(e),i=we(r),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")if(this.ensureParentDirs(i),"content"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=Ko(s,l),u=Ko(i,l);await this.cp(c,u,n)}}}async mv(e,r){await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,r){return Go(e,r)}async chmod(e,r){Se(e,"chmod");let n=we(e),s=this.data.get(n);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=r}async symlink(e,r){Se(r,"symlink");let n=we(r);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,r){Se(e,"link"),Se(r,"link");let n=we(e),s=we(r),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${r}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(n,o)),this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){Se(e,"readlink");let r=we(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}async realpath(e){Se(e,"realpath");let r=this.resolvePathWithSymlinks(e);if(!this.data.has(r))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return r}async utimes(e,r,n){Se(e,"utimes");let s=we(e),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);o.mtime=n}};h7();function woe(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function Eoe(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function Soe(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function voe(t,e){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${QD}
1488
+ `,0;i=f}let o=`${e.array}_${i}`,a=t.state.env.get(o);if(a!==void 0)return s4(t,a);if(i===0){let l=t.state.env.get(e.array);if(l!==void 0)return s4(t,l)}if(t.state.options.nounset&&!Array.from(t.state.env.keys()).some(c=>c===e.array||c.startsWith(`${e.array}_`)))throw new Nn(`${e.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new It("double subscript","","");case"ArithNumberSubscript":throw new It(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithSyntaxError":throw new It(e.message,"","",!0);case"ArithSingleQuote":{if(r)throw new It(`syntax error: operand expected (error token is "'${e.content}'")`);return e.value}case"ArithBinary":{if(e.operator==="||")return await be(t,e.left,r)||await be(t,e.right,r)?1:0;if(e.operator==="&&")return await be(t,e.left,r)&&await be(t,e.right,r)?1:0;let n=await be(t,e.left,r),s=await be(t,e.right,r);return qae(n,s,e.operator)}case"ArithUnary":{let n=await be(t,e.operand,r);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let s=e.operand.name,i=Number.parseInt(await gt(t,s),10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}if(e.operand.type==="ArithArrayElement"){let s=e.operand.array,i=t.state.associativeArrays?.has(s),o;if(e.operand.stringKey!==void 0)o=`${s}_${e.operand.stringKey}`;else if(i&&e.operand.index?.type==="ArithVariable"&&!e.operand.index.hasDollarPrefix)o=`${s}_${e.operand.index.name}`;else if(i&&e.operand.index?.type==="ArithVariable"&&e.operand.index.hasDollarPrefix){let c=await gt(t,e.operand.index.name);o=`${s}_${c}`}else if(e.operand.index){let c=await be(t,e.operand.index,r);o=`${s}_${c}`}else return n;let a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}if(e.operand.type==="ArithConcat"){let s="";for(let i of e.operand.parts)s+=await Dc(t,i,r);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=e.operator==="++"?i+1:i-1;return t.state.env.set(s,String(o)),e.prefix?o:i}}if(e.operand.type==="ArithDynamicElement"){let s="";if(e.operand.nameExpr.type==="ArithConcat")for(let i of e.operand.nameExpr.parts)s+=await Dc(t,i,r);else e.operand.nameExpr.type==="ArithVariable"&&(s=e.operand.nameExpr.hasDollarPrefix?await gt(t,e.operand.nameExpr.name):e.operand.nameExpr.name);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=await be(t,e.operand.subscript,r),o=`${s}_${i}`,a=Number.parseInt(t.state.env.get(o)||"0",10)||0,l=e.operator==="++"?a+1:a-1;return t.state.env.set(o,String(l)),e.prefix?l:a}}return n}return zae(n,e.operator)}case"ArithTernary":return await be(t,e.condition,r)?await be(t,e.consequent,r):await be(t,e.alternate,r);case"ArithAssignment":{let n=e.variable,s=n;if(e.stringKey!==void 0)s=`${n}_${e.stringKey}`;else if(e.subscript){let l=t.state.associativeArrays?.has(n);if(l&&e.subscript.type==="ArithVariable"&&!e.subscript.hasDollarPrefix)s=`${n}_${e.subscript.name}`;else if(l&&e.subscript.type==="ArithVariable"&&e.subscript.hasDollarPrefix){let c=await gt(t,e.subscript.name);s=`${n}_${c||"\\"}`}else if(l){let c=await be(t,e.subscript,r);s=`${n}_${c}`}else{let c=await be(t,e.subscript,r);if(c<0){let u=De(t,n);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}s=`${n}_${c}`}}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await be(t,e.value,r),a=AM(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithGroup":return await be(t,e.expression,r);case"ArithConcat":{let n="";for(let s of e.parts)n+=await Dc(t,s,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?await i4(t,n):Number.parseInt(n,10)||0}case"ArithDynamicAssignment":{let n="";if(e.target.type==="ArithConcat")for(let l of e.target.parts)n+=await Dc(t,l,r);else e.target.type==="ArithVariable"&&(n=e.target.hasDollarPrefix?await gt(t,e.target.name):e.target.name);if(!n||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return 0;let s=n;if(e.subscript){let l=await be(t,e.subscript,r);s=`${n}_${l}`}let i=Number.parseInt(t.state.env.get(s)||"0",10)||0,o=await be(t,e.value,r),a=AM(i,o,e.operator);return t.state.env.set(s,String(a)),a}case"ArithDynamicElement":{let n="";if(e.nameExpr.type==="ArithConcat")for(let a of e.nameExpr.parts)n+=await Dc(t,a,r);else e.nameExpr.type==="ArithVariable"&&(n=e.nameExpr.hasDollarPrefix?await gt(t,e.nameExpr.name):e.nameExpr.name);if(!n||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return 0;let s=await be(t,e.subscript,r),i=`${n}_${s}`,o=t.state.env.get(i);return o!==void 0?Wae(o):0}default:return 0}}async function Dc(t,e,r=!1){switch(e.type){case"ArithNumber":return String(e.value);case"ArithSingleQuote":return String(await be(t,e,r));case"ArithVariable":return e.hasDollarPrefix?await gt(t,e.name):e.name;case"ArithSpecialVar":return await gt(t,e.name);case"ArithBracedExpansion":return await Cm(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command,{signal:t.state.signal})).stdout.trim():"0";case"ArithConcat":{let n="";for(let s of e.parts)n+=await Dc(t,s,r);return n}default:return String(await be(t,e,r))}}var Fn=I(()=>{"use strict";vn();mr();rt();Mn()});var Gce={};ue(Gce,{Bash:()=>Hc,BashTransformPipeline:()=>r1,CommandCollectorPlugin:()=>n1,DefenseInDepthBox:()=>Et,EMPTY_BYTES:()=>Sh,InMemoryFs:()=>$i,MountableFs:()=>rh,NetworkAccessDeniedError:()=>Ws,OverlayFs:()=>ll,ReadWriteFs:()=>nh,RedirectNotAllowedError:()=>sl,Sandbox:()=>sh,SandboxCommand:()=>cl,SecurityViolationError:()=>Fe,SecurityViolationLogger:()=>ih,TeePlugin:()=>s1,TooManyRedirectsError:()=>nl,bytesOutput:()=>vS,createConsoleViolationCallback:()=>tS,decodeBytesToUtf8:()=>fe,defineCommand:()=>ZD,encodeUtf8ToBytes:()=>Ts,getCommandNames:()=>UD,getJavaScriptCommandNames:()=>VD,getNetworkCommandNames:()=>qD,getPythonCommandNames:()=>WD,latin1FromBytes:()=>ir,parse:()=>Dn,serialize:()=>zc,stdoutAsBytes:()=>Zc,stdoutKind:()=>C1,textOutput:()=>SS,unsafeBytesFromLatin1:()=>bo});module.exports=bS(Gce);bi();$r();var Ka=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(A1(),ES))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(k1(),AS))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(O1(),PS))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(U1(),i8))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(z1(),a8))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(W1(),u8))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(V1(),f8))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(K1(),h8))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Y1(),d8))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(Q1(),p8))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(eg(),m8))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(ng(),y8))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(ig(),x8))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(ag(),b8))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(ug(),S8))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(hg(),v8))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(mg(),C8))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(yg(),N8))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(nu(),qh))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(nu(),qh))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(nu(),qh))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(jg(),x9))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(t2(),_9))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(p2(),av))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(y2(),gv))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(b2(),yv))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(E2(),xv))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(v2(),bv))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(C2(),Ev))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(k2(),vv))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(_2(),Av))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(I2(),Nv))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(P2(),Tv))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(L2(),Ov))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(M2(),Pv))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(B2(),Fv))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(q2(),Bv))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(H2(),qv))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(V2(),zv))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(K2(),Hv))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(X2(),Xv))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(J2(),Qv))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(ty(),Jv))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(ny(),tA))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(iy(),nA))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(id(),ly))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(id(),ly))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(od(),fy))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(od(),fy))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(dy(),iA))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(my(),oA))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(ad(),xy))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(ad(),xy))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(wy(),aA))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(ld(),vy))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(ld(),vy))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(qy(),RA))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Hy(),DA))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Zy(),UA))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Xy(),qA))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(ex(),HA))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(rx(),WA))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(sx(),VA))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(ox(),GA))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(lx(),KA))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(ux(),YA))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(hx(),XA))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(px(),QA))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(Lx(),cC))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(cw(),RT))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(fw(),PT))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(dw(),DT))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(mw(),LT))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(yw(),FT))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(bw(),MT))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(Ew(),$T))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Hu(),Ap))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Hu(),Ap))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Hu(),Ap))).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(Ka.push({name:"tar",load:async()=>(await Promise.resolve().then(()=>(qw(),__))).tarCommand}),Ka.push({name:"yq",load:async()=>(await Promise.resolve().then(()=>(n3(),IP))).yqCommand}),Ka.push({name:"xan",load:async()=>(await Promise.resolve().then(()=>(X3(),QP))).xanCommand}),Ka.push({name:"sqlite3",load:async()=>(await Promise.resolve().then(()=>(J3(),fD))).sqlite3Command}));var rm=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(rm.push({name:"python3",load:async()=>(await Promise.resolve().then(()=>(n7(),r7))).python3Command}),rm.push({name:"python",load:async()=>(await Promise.resolve().then(()=>(n7(),r7))).pythonCommand}));var nm=[];(typeof __BROWSER__>"u"||!__BROWSER__)&&(nm.push({name:"js-exec",load:async()=>(await Promise.resolve().then(()=>(i7(),s7))).jsExecCommand}),nm.push({name:"node",load:async()=>(await Promise.resolve().then(()=>(i7(),s7))).nodeStubCommand}));var BD=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(RD(),ID))).curlCommand}],$D=new Map;function sm(t){return{name:t.name,async execute(e,r){let n=$D.get(t.name);if(n||(n=await Et.runTrustedAsync(()=>t.load()),$D.set(t.name,n)),r.coverage&&(typeof __BROWSER__>"u"||!__BROWSER__)){let{emitFlagCoverage:s}=await Promise.resolve().then(()=>(MD(),FD));s(r.coverage,t.name,e)}return n.execute(e,r)}}}function UD(){return Ka.map(t=>t.name)}function qD(){return BD.map(t=>t.name)}function zD(t){return(t?Ka.filter(r=>t.includes(r.name)):Ka).map(sm)}function HD(){return BD.map(sm)}function WD(){return rm.map(t=>t.name)}function jD(){return rm.map(sm)}function VD(){return nm.map(t=>t.name)}function GD(){return nm.map(sm)}function KD(t){return"load"in t&&typeof t.load=="function"}function ZD(t,e){return{name:t,trusted:!0,execute:e}}function YD(t){let e=null;return{name:t.name,trusted:!0,async execute(r,n){return e||(e=await t.load()),e.execute(r,n)}}}Re();Re();Sc();function we(t){if(!t||t==="/")return"/";let e=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;e.startsWith("/")||(e=`/${e}`);let r=e.split("/").filter(s=>s&&s!=="."),n=[];for(let s of r)s===".."?n.pop():n.push(s);return`/${n.join("/")}`||"/"}function Se(t,e){if(t.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${e} '${t}'`)}function Za(t){let e=we(t);if(e==="/")return"/";let r=e.lastIndexOf("/");return r===0?"/":e.slice(0,r)}function Go(t,e){if(e.startsWith("/"))return we(e);let r=t==="/"?`/${e}`:`${t}/${e}`;return we(r)}function Ko(t,e){return t==="/"?`/${e}`:`${t}/${e}`}function Ac(t,e){if(e.startsWith("/"))return we(e);let r=Za(t);return we(Ko(r,e))}var Cc=new TextEncoder;function boe(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var $i=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[r,n]of Object.entries(e))typeof n=="function"?this.writeFileLazy(r,n):boe(n)?this.writeFileSync(r,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(r,n)}ensureParentDirs(e){let r=Za(e);r!=="/"&&(this.data.has(r)||(this.ensureParentDirs(r),this.data.set(r,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,r,n,s){Se(e,"write");let i=we(e);this.ensureParentDirs(i);let o=zs(n),a=ao(r,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}writeFileLazy(e,r,n){Se(e,"write");let s=we(e);this.ensureParentDirs(s),this.data.set(s,{type:"file",lazy:r,mode:n?.mode??420,mtime:n?.mtime??new Date})}async materializeLazy(e,r){let n=await r.lazy(),i={type:"file",content:typeof n=="string"?Cc.encode(n):n,mode:r.mode,mtime:r.mtime};return this.data.set(e,i),i}async readFile(e,r){let n=await this.readFileBuffer(e),s=zs(r);return xs(n,s)}async readFileBytes(e){let r=await this.readFileBuffer(e);return xs(r,"binary")}async readFileBuffer(e){Se(e,"open");let r=this.resolvePathWithSymlinks(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if("lazy"in n){let s=await this.materializeLazy(r,n);return s.content instanceof Uint8Array?s.content:Cc.encode(s.content)}return n.content instanceof Uint8Array?n.content:Cc.encode(n.content)}async writeFile(e,r,n){this.writeFileSync(e,r,n)}async appendFile(e,r,n){Se(e,"append");let s=we(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=zs(n),a=ao(r,o);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(s,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:Cc.encode("content"in l?l.content:""),u=new Uint8Array(c.length+a.length);u.set(c),u.set(a,c.length),this.data.set(s,{type:"file",content:u,mode:l.mode,mtime:new Date})}else this.writeFileSync(e,r,n)}async exists(e){if(e.includes("\0"))return!1;try{let r=this.resolvePathWithSymlinks(e);return this.data.has(r)}catch{return!1}}async stat(e){Se(e,"stat");let r=this.resolvePathWithSymlinks(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);n.type==="file"&&"lazy"in n&&(n=await this.materializeLazy(r,n));let s=0;return n.type==="file"&&"content"in n&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=Cc.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}async lstat(e){Se(e,"lstat");let r=this.resolveIntermediateSymlinks(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};n.type==="file"&&"lazy"in n&&(n=await this.materializeLazy(r,n));let s=0;return n.type==="file"&&"content"in n&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=Cc.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}resolveIntermediateSymlinks(e){let r=we(e);if(r==="/")return"/";let n=r.slice(1).split("/");if(n.length<=1)return r;let s="",i=new Set;for(let o=0;o<n.length-1;o++){let a=n[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=Ac(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${n[n.length-1]}`}resolvePathWithSymlinks(e){let r=we(e);if(r==="/")return"/";let n=r.slice(1).split("/"),s="",i=new Set;for(let o of n){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=Ac(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,r){this.mkdirSync(e,r)}mkdirSync(e,r){Se(e,"mkdir");let n=we(e);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!r?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=Za(n);if(s!=="/"&&!this.data.has(s))if(r?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(n=>n.name)}async readdirWithFileTypes(e){Se(e,"scandir");let r=we(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;n&&n.type==="symlink";){if(s.has(r))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(r),r=Ac(r,n.target),n=this.data.get(r)}if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=r==="/"?"/":`${r}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==r&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(e,r){Se(e,"rm");let n=we(e),s=this.data.get(n);if(!s){if(r?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!r?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=Ko(n,o);await this.rm(a,r)}}}this.data.delete(n)}async cp(e,r,n){Se(e,"cp"),Se(r,"cp");let s=we(e),i=we(r),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")if(this.ensureParentDirs(i),"content"in o){let a=o.content instanceof Uint8Array?new Uint8Array(o.content):o.content;this.data.set(i,{...o,content:a})}else this.data.set(i,{...o});else if(o.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=Ko(s,l),u=Ko(i,l);await this.cp(c,u,n)}}}async mv(e,r){await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,r){return Go(e,r)}async chmod(e,r){Se(e,"chmod");let n=we(e),s=this.data.get(n);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=r}async symlink(e,r){Se(r,"symlink");let n=we(r);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,r){Se(e,"link"),Se(r,"link");let n=we(e),s=we(r),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${r}'`);let o=i;"lazy"in o&&(o=await this.materializeLazy(n,o)),this.ensureParentDirs(s),this.data.set(s,{type:"file",content:o.content,mode:o.mode,mtime:o.mtime})}async readlink(e){Se(e,"readlink");let r=we(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}async realpath(e){Se(e,"realpath");let r=this.resolvePathWithSymlinks(e);if(!this.data.has(r))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return r}async utimes(e,r,n){Se(e,"utimes");let s=we(e),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);o.mtime=n}};h7();function woe(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function Eoe(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function Soe(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function voe(t,e){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${QD}
1489
1489
  `),t.writeFileSync("/proc/self/exe","/bin/bash"),t.writeFileSync("/proc/self/cmdline","bash\0"),t.writeFileSync("/proc/self/comm",`bash
1490
- `),t.writeFileLazy?t.writeFileLazy("/proc/self/status",()=>f7(e)):t.writeFileSync("/proc/self/status",f7(e)),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function JD(t,e,r={pid:1,ppid:0,uid:1e3,gid:1e3}){woe(t)&&(Eoe(t,e),Soe(t),voe(t,r))}rn();Rs();rt();var Aoe=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Coe=["braceexpand","hashall","interactive-comments"];function d7(t){let e=[],r=[...Coe.map(n=>({name:n,enabled:!0})),...Aoe.map(n=>({name:n,enabled:t[n]}))].sort((n,s)=>n.name.localeCompare(s.name));for(let n of r)n.enabled&&e.push(n.name);return e.join(":")}function kc(t){t.state.env.set("SHELLOPTS",d7(t.state.options))}var Noe=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function p7(t){let e=[];for(let r of Noe)t[r]&&e.push(r);return e.join(":")}function m7(t){t.state.env.set("BASHOPTS",p7(t.state.shoptOptions))}Re();Rs();Ya();$r();mr();Ya();var rae="BASH_ALIAS_";function HL(t){return t.parts.length!==1?!1:t.parts[0].type==="Literal"}function WL(t){if(t.parts.length!==1)return null;let e=t.parts[0];return e.type==="Literal"?e.value:null}function jL(t,e){return t.env.get(`${rae}${e}`)}function M7(t,e,r){if(!e.name||!HL(e.name))return e;let n=WL(e.name);if(!n)return e;let s=jL(t,n);if(!s||r.has(n))return e;try{r.add(n);let i=new je,o=s,a=s.endsWith(" ");if(!a)for(let f of e.args){let h=GL(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof Qr)throw f;return e}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return VL(e,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return VL(e,s);let u={...c,assignments:[...e.assignments,...c.assignments],redirections:[...c.redirections,...e.redirections],line:e.line};if(a&&e.args.length>0&&(u={...u,args:[...u.args,...e.args]},u.args.length>0)){let f=u.args[0];if(HL(f)){let h=WL(f);if(h&&jL(t,h)){let d={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},p=M7(t,d,r);p!==d&&(u={...u,name:p.name,args:[...p.args]})}}}return u}catch(i){throw r.delete(n),i}}function VL(t,e){let r=e;for(let o of t.args){let a=GL(o);r+=` ${a}`}let n=new je,s=n.parseWordFromString("eval",!1,!1),i=n.parseWordFromString(`'${r.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:t.assignments,redirections:t.redirections,line:t.line}}function GL(t){let e="";for(let r of t.parts)switch(r.type){case"Literal":e+=r.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":e+=`'${r.value}'`;break;case"DoubleQuoted":e+=`"${r.parts.map(n=>n.type==="Literal"?n.value:`$${n.type}`).join("")}"`;break;case"ParameterExpansion":e+=`\${${r.parameter}}`;break;case"CommandSubstitution":e+="$(...)";break;case"ArithmeticExpansion":e+=`$((${r.expression}))`;break;case"Glob":e+=r.pattern;break;default:break}return e}Fn();Mn();Hs();async function CM(t,e){let r=e.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),n=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!n||!r.endsWith(")"))return null;let s=n[1],i=[],o=!1,a="",l=!1;for(let u of e.parts)if(u.type==="Literal"){let f=u.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let d of h)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Tc({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await pi(t,{type:"Word",parts:[u]});i.push(...h.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await Ae(t,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function NM(t,e){let r=-1,n=-1,s=!1;for(let m=0;m<e.parts.length;m++){let g=e.parts[m];if(g.type==="Literal"){let y=g.value.indexOf("+=");if(y!==-1){let b=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){r=m,n=y,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){r=m,n=y,s=!0;break}}let x=g.value.indexOf("=");if(x!==-1&&(x===0||g.value[x-1]!=="+")){let b=g.value.slice(0,x);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){r=m,n=x;break}}}}if(r===-1)return null;let i=e.parts.slice(0,r),o=e.parts[r];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,n),c=o.value.slice(n+a),u=e.parts.slice(r+1),f="";for(let m of i)f+=await Ae(t,{type:"Word",parts:[m]});f+=l;let h={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},d=h.parts.length>0?await Ae(t,h):"";return`${f}${s?"+=":"="}${d}`}var jae=["tar","yq","xan","sqlite3","python3","python"];function kM(t){return jae.includes(t)}Re();rn();hs();$r();rt();rt();var tt=Object.freeze({stdout:"",stderr:"",exitCode:0});function it(t=""){return{stdout:t,stderr:"",exitCode:0}}function ee(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function re(t,e,r){return{stdout:t,stderr:e,exitCode:r}}function _r(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function Hi(t,e,r="",n=""){throw new fe(t,e,r,n)}function An(t){let e=t.state.fileDescriptors;if(e&&e.size>=t.limits.maxFileDescriptors)throw new fe(`too many open file descriptors (max ${t.limits.maxFileDescriptors})`,"file_descriptors")}function o4(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new Si;return tt}if(e.length>1)throw new Xe(1,"",`bash: break: too many arguments
1490
+ `),t.writeFileLazy?t.writeFileLazy("/proc/self/status",()=>f7(e)):t.writeFileSync("/proc/self/status",f7(e)),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function JD(t,e,r={pid:1,ppid:0,uid:1e3,gid:1e3}){woe(t)&&(Eoe(t,e),Soe(t),voe(t,r))}rn();Rs();rt();var Aoe=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Coe=["braceexpand","hashall","interactive-comments"];function d7(t){let e=[],r=[...Coe.map(n=>({name:n,enabled:!0})),...Aoe.map(n=>({name:n,enabled:t[n]}))].sort((n,s)=>n.name.localeCompare(s.name));for(let n of r)n.enabled&&e.push(n.name);return e.join(":")}function kc(t){t.state.env.set("SHELLOPTS",d7(t.state.options))}var Noe=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function p7(t){let e=[];for(let r of Noe)t[r]&&e.push(r);return e.join(":")}function m7(t){t.state.env.set("BASHOPTS",p7(t.state.shoptOptions))}Re();Rs();Ya();$r();mr();Ya();var rae="BASH_ALIAS_";function HL(t){return t.parts.length!==1?!1:t.parts[0].type==="Literal"}function WL(t){if(t.parts.length!==1)return null;let e=t.parts[0];return e.type==="Literal"?e.value:null}function jL(t,e){return t.env.get(`${rae}${e}`)}function M7(t,e,r){if(!e.name||!HL(e.name))return e;let n=WL(e.name);if(!n)return e;let s=jL(t,n);if(!s||r.has(n))return e;try{r.add(n);let i=new je,o=s,a=s.endsWith(" ");if(!a)for(let f of e.args){let h=GL(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof Qr)throw f;return e}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return VL(e,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return VL(e,s);let u={...c,assignments:[...e.assignments,...c.assignments],redirections:[...c.redirections,...e.redirections],line:e.line};if(a&&e.args.length>0&&(u={...u,args:[...u.args,...e.args]},u.args.length>0)){let f=u.args[0];if(HL(f)){let h=WL(f);if(h&&jL(t,h)){let d={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},p=M7(t,d,r);p!==d&&(u={...u,name:p.name,args:[...p.args]})}}}return u}catch(i){throw r.delete(n),i}}function VL(t,e){let r=e;for(let o of t.args){let a=GL(o);r+=` ${a}`}let n=new je,s=n.parseWordFromString("eval",!1,!1),i=n.parseWordFromString(`'${r.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:t.assignments,redirections:t.redirections,line:t.line}}function GL(t){let e="";for(let r of t.parts)switch(r.type){case"Literal":e+=r.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":e+=`'${r.value}'`;break;case"DoubleQuoted":e+=`"${r.parts.map(n=>n.type==="Literal"?n.value:`$${n.type}`).join("")}"`;break;case"ParameterExpansion":e+=`\${${r.parameter}}`;break;case"CommandSubstitution":e+="$(...)";break;case"ArithmeticExpansion":e+=`$((${r.expression}))`;break;case"Glob":e+=r.pattern;break;default:break}return e}Fn();Mn();Hs();async function CM(t,e){let r=e.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),n=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!n||!r.endsWith(")"))return null;let s=n[1],i=[],o=!1,a="",l=!1;for(let u of e.parts)if(u.type==="Literal"){let f=u.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let d of h)/^\s+$/.test(d)?(a||l)&&(i.push(a),a="",l=!1):d&&(a+=d)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=Tc({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await pi(t,{type:"Word",parts:[u]});i.push(...h.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await Ae(t,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function NM(t,e){let r=-1,n=-1,s=!1;for(let m=0;m<e.parts.length;m++){let g=e.parts[m];if(g.type==="Literal"){let y=g.value.indexOf("+=");if(y!==-1){let b=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){r=m,n=y,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){r=m,n=y,s=!0;break}}let x=g.value.indexOf("=");if(x!==-1&&(x===0||g.value[x-1]!=="+")){let b=g.value.slice(0,x);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){r=m,n=x;break}}}}if(r===-1)return null;let i=e.parts.slice(0,r),o=e.parts[r];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,n),c=o.value.slice(n+a),u=e.parts.slice(r+1),f="";for(let m of i)f+=await Ae(t,{type:"Word",parts:[m]});f+=l;let h={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},d=h.parts.length>0?await Ae(t,h):"";return`${f}${s?"+=":"="}${d}`}var jae=["tar","yq","xan","sqlite3","python3","python"];function kM(t){return jae.includes(t)}Re();rn();hs();$r();rt();rt();var tt=Object.freeze({stdout:"",stderr:"",exitCode:0});function it(t=""){return{stdout:t,stderr:"",exitCode:0}}function ee(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function re(t,e,r){return{stdout:t,stderr:e,exitCode:r}}function _r(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function Hi(t,e,r="",n=""){throw new he(t,e,r,n)}function An(t){let e=t.state.fileDescriptors;if(e&&e.size>=t.limits.maxFileDescriptors)throw new he(`too many open file descriptors (max ${t.limits.maxFileDescriptors})`,"file_descriptors")}function o4(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new Si;return tt}if(e.length>1)throw new Xe(1,"",`bash: break: too many arguments
1491
1491
  `);let r=1;if(e.length>0){let n=Number.parseInt(e[0],10);if(Number.isNaN(n)||n<1)throw new Xe(128,"",`bash: break: ${e[0]}: numeric argument required
1492
1492
  `);r=n}throw new gn(r)}async function a4(t,e){let r,n=!1,s=!1,i=0;for(;i<e.length;)if(e[i]==="--"){i++;break}else if(e[i]==="-L")s=!1,i++;else if(e[i]==="-P")s=!0,i++;else if(e[i].startsWith("-")&&e[i]!=="-")i++;else break;let o=e.slice(i);if(o.length===0||o[0]==="~"?r=t.state.env.get("HOME")||"/":o[0]==="-"?(r=t.state.previousDir,n=!0):r=o[0],!r.startsWith("/")&&!r.startsWith("./")&&!r.startsWith("../")&&r!=="."&&r!==".."){let f=t.state.env.get("CDPATH");if(f){let h=f.split(":").filter(d=>d);for(let d of h){let p=d.startsWith("/")?`${d}/${r}`:`${t.state.cwd}/${d}/${r}`;try{if((await t.fs.stat(p)).isDirectory){r=p,n=!0;break}}catch{}}}}let l=(r.startsWith("/")?r:`${t.state.cwd}/${r}`).split("/").filter(f=>f&&f!=="."),c="";for(let f of l)if(f==="..")c=c.split("/").slice(0,-1).join("/")||"/";else{c=c?`${c}/${f}`:`/${f}`;try{if(!(await t.fs.stat(c)).isDirectory)return ee(`bash: cd: ${r}: Not a directory
1493
1493
  `)}catch{return ee(`bash: cd: ${r}: No such file or directory
@@ -2037,7 +2037,7 @@ ${jm}`;if(t.state.options.posix)throw new fs(1,"",s);return ee(s)}return z4(t,e.
2037
2037
  `;if(t.state.options.posix)throw new fs(1,"",a);return ee(a)}r=o}let n=Number.parseInt(t.state.env.get("#")||"0",10);if(r>n){let o=`bash: shift: shift count out of range
2038
2038
  `;if(t.state.options.posix)throw new fs(1,"",o);return ee(o)}if(r===0)return tt;let s=[];for(let o=1;o<=n;o++)s.push(t.state.env.get(String(o))||"");let i=s.slice(r);for(let o=1;o<=n;o++)t.state.env.delete(String(o));for(let o=0;o<i.length;o++)t.state.env.set(String(o+1),i[o]);return t.state.env.set("#",String(i.length)),t.state.env.set("@",i.join(" ")),tt}mr();rt();async function j4(t,e){let r=e;if(r.length>0&&r[0]==="--"&&(r=r.slice(1)),r.length===0)return re("",`bash: source: filename argument required
2039
2039
  `,2);let n=r[0],s=null,i=null;if(n.includes("/")){let c=t.fs.resolvePath(t.state.cwd,n);try{i=await t.fs.readFile(c),s=c}catch{}}else{let u=(t.state.env.get("PATH")||"").split(":").filter(f=>f);for(let f of u){let h=t.fs.resolvePath(t.state.cwd,`${f}/${n}`);try{if((await t.fs.stat(h)).isDirectory)continue;i=await t.fs.readFile(h),s=h;break}catch{}}if(i===null){let f=t.fs.resolvePath(t.state.cwd,n);try{i=await t.fs.readFile(f),s=f}catch{}}}if(i===null)return ee(`bash: ${n}: No such file or directory
2040
- `);let o=new Map;if(r.length>1){for(let u=1;u<=9;u++)o.set(String(u),t.state.env.get(String(u)));o.set("#",t.state.env.get("#")),o.set("@",t.state.env.get("@"));let c=r.slice(1);t.state.env.set("#",String(c.length)),t.state.env.set("@",c.join(" "));for(let u=0;u<c.length&&u<9;u++)t.state.env.set(String(u+1),c[u]);for(let u=c.length+1;u<=9;u++)t.state.env.delete(String(u))}let a=t.state.currentSource,l=()=>{if(t.state.sourceDepth--,t.state.currentSource=a,r.length>1)for(let[c,u]of o)u===void 0?t.state.env.delete(c):t.state.env.set(c,u)};if(t.state.sourceDepth++,t.state.sourceDepth>t.limits.maxSourceDepth)throw t.state.sourceDepth--,new fe(`source: maximum nesting depth (${t.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,"recursion");t.state.currentSource=n;try{let c=Dn(i),u=await t.executeScript(c);return l(),u}catch(c){if(l(),c instanceof Xe)throw c;if(c instanceof tn)return re(c.stdout,c.stderr,c.exitCode);if(c.name==="ParseException")return ee(`bash: ${n}: ${c.message}
2040
+ `);let o=new Map;if(r.length>1){for(let u=1;u<=9;u++)o.set(String(u),t.state.env.get(String(u)));o.set("#",t.state.env.get("#")),o.set("@",t.state.env.get("@"));let c=r.slice(1);t.state.env.set("#",String(c.length)),t.state.env.set("@",c.join(" "));for(let u=0;u<c.length&&u<9;u++)t.state.env.set(String(u+1),c[u]);for(let u=c.length+1;u<=9;u++)t.state.env.delete(String(u))}let a=t.state.currentSource,l=()=>{if(t.state.sourceDepth--,t.state.currentSource=a,r.length>1)for(let[c,u]of o)u===void 0?t.state.env.delete(c):t.state.env.set(c,u)};if(t.state.sourceDepth++,t.state.sourceDepth>t.limits.maxSourceDepth)throw t.state.sourceDepth--,new he(`source: maximum nesting depth (${t.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,"recursion");t.state.currentSource=n;try{let c=Dn(i),u=await t.executeScript(c);return l(),u}catch(c){if(l(),c instanceof Xe)throw c;if(c instanceof tn)return re(c.stdout,c.stderr,c.exitCode);if(c.name==="ParseException")return ee(`bash: ${n}: ${c.message}
2041
2041
  `);throw c}}vn();mr();Fn();as();Mn();fi();ea();function o$(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}function Mle(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')}async function a$(t,e){if(Mle(e))return null;try{let r=new je,n=mt(r,e);return await be(t,n.expression)}catch{let r=parseInt(e,10);return Number.isNaN(r)?0:r}}function l$(t,e){if(t.state.localVarStack?.has(e)){let n=Bm(t,e);if(n){n.value===void 0?t.state.env.delete(e):t.state.env.set(e,n.value);let s=t.state.localVarStack?.get(e);if(!s||s.length===0)$m(t,e),t.state.localVarStack?.delete(e),t.state.fullyUnsetLocals=t.state.fullyUnsetLocals||new Map,t.state.fullyUnsetLocals.set(e,n.scopeIndex),V4(t,e);else{let i=s[s.length-1];t.state.localVarDepth=t.state.localVarDepth||new Map,t.state.localVarDepth.set(e,i.scopeIndex+1)}return!0}return t.state.env.delete(e),$m(t,e),t.state.localVarStack?.delete(e),t.state.fullyUnsetLocals=t.state.fullyUnsetLocals||new Map,t.state.fullyUnsetLocals.set(e,0),!0}for(let n=t.state.localScopes.length-1;n>=0;n--){let s=t.state.localScopes[n];if(s.has(e)){let i=s.get(e);i===void 0?t.state.env.delete(e):t.state.env.set(e,i),s.delete(e);let o=!1;for(let a=n-1;a>=0;a--)if(t.state.localScopes[a].has(e)){t.state.localVarDepth&&t.state.localVarDepth.set(e,a+1),o=!0;break}return o||$m(t,e),!0}}return!1}function V4(t,e){if(!t.state.tempEnvBindings||t.state.tempEnvBindings.length===0)return!1;for(let r=t.state.tempEnvBindings.length-1;r>=0;r--){let n=t.state.tempEnvBindings[r];if(n.has(e)){let s=n.get(e);return s===void 0?t.state.env.delete(e):t.state.env.set(e,s),n.delete(e),!0}}return!1}async function c$(t,e){if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e.startsWith('"')&&e.endsWith('"')){let r=e.slice(1,-1),s=new je().parseWordFromString(r,!0,!1);return Ae(t,s)}if(e.includes("$")){let n=new je().parseWordFromString(e,!1,!1);return Ae(t,n)}return e}async function G4(t,e){let r="both",n="",s=0;for(let i of e){if(i==="-v"){r="variable";continue}if(i==="-f"){r="function";continue}if(r==="function"){t.state.functions.delete(i);continue}if(r==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let h=c[1],d=c[2];if(d==="@"||d==="*"){let b=De(t,h);for(let[w]of b)t.state.env.delete(`${h}_${w}`);t.state.env.delete(h);continue}let p=t.state.associativeArrays?.has(h);if(p){let b=await c$(t,d);t.state.env.delete(`${h}_${b}`);continue}let m=co(t,h),g=t.state.declaredVars?.has(h);if((t.state.env.has(h)||g)&&!m&&!p){n+=`bash: unset: ${h}: not an array variable
2042
2042
  `,s=1;continue}let x=await a$(t,d);if(x===null&&m){n+=`bash: unset: ${d}: not a valid identifier
2043
2043
  `,s=1;continue}if(x===null)continue;if(x<0){let b=De(t,h),w=b.length,S=t.state.currentLine;if(w===0){n+=`bash: line ${S}: unset: [${x}]: bad array subscript
@@ -2107,9 +2107,9 @@ ${t} ()
2107
2107
  `,127):ee(`bash: ${e}: command not found
2108
2108
  `,127);if("error"in c)return c.error==="permission_denied"?ee(`bash: ${e}: Permission denied
2109
2109
  `,126):ee(`bash: ${e}: No such file or directory
2110
- `,127);if("script"in c)return e.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(e,c.path)),await a(c.path,r,n);let{cmd:u,path:f}=c;e.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(e,f));let h=n||i.state.groupStdin||"",d=u.custom?he(h):h,p=o(),m={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:p,stdin:d,limits:i.limits,exec:i.execFn,fetch:i.fetch,getRegisteredCommands:()=>Array.from(i.commands.keys()),sleep:i.sleep,trace:i.trace,fileDescriptors:i.state.fileDescriptors,xpgEcho:i.state.shoptOptions.xpg_echo,coverage:i.coverage,signal:i.state.signal,requireDefenseContext:i.requireDefenseContext,jsBootstrapCode:i.jsBootstrapCode,invokeTool:i.invokeTool},g=h$(m,e);try{let y=()=>sn(i.requireDefenseContext,"command",`${e} execution`,()=>u.execute(r,g));return u.trusted?await Et.runTrustedAsync(()=>y()):await y()}catch(y){if(y instanceof fe||y instanceof Fe)throw y;return ee(`${e}: ${Je(Rt(y))}
2111
- `)}}Fn();rt();Mn();async function Z4(t,e){let r=t.state.inCondition;t.state.inCondition=!0;let n="",s="",i=0;try{for(let o of e){let a=await t.executeStatement(o);n+=a.stdout,s+=a.stderr,i=a.exitCode}}finally{t.state.inCondition=r}return{stdout:n,stderr:s,exitCode:i}}rt();Tn();function eh(t,e,r,n){if(t instanceof gn)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"break",stdout:e,stderr:r};if(t instanceof yn)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"continue",stdout:e,stderr:r};if(t instanceof tn||t instanceof zn||t instanceof Xe||t instanceof fe)return t.prependOutput(e,r),{action:"rethrow",stdout:e,stderr:r,error:t};let s=Rt(t);return{action:"error",stdout:e,stderr:`${r}${s}
2112
- `,exitCode:1}}rt();Tn();async function Km(t,e,r="",n=""){let s=r,i=n,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(Ah(a)||a instanceof zn||a instanceof Xe||a instanceof fe||a instanceof Si)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${Rt(a)}
2110
+ `,127);if("script"in c)return e.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(e,c.path)),await a(c.path,r,n);let{cmd:u,path:f}=c;e.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(e,f));let h=n||i.state.groupStdin||"",d=u.custom?fe(h):h,p=o(),m={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:p,stdin:d,limits:i.limits,exec:i.execFn,fetch:i.fetch,getRegisteredCommands:()=>Array.from(i.commands.keys()),sleep:i.sleep,trace:i.trace,fileDescriptors:i.state.fileDescriptors,xpgEcho:i.state.shoptOptions.xpg_echo,coverage:i.coverage,signal:i.state.signal,requireDefenseContext:i.requireDefenseContext,jsBootstrapCode:i.jsBootstrapCode,invokeTool:i.invokeTool},g=u.custom?r.map(x=>fe(x)):r,y=h$(m,e);try{let x=()=>sn(i.requireDefenseContext,"command",`${e} execution`,()=>u.execute(g,y));return u.trusted?await Et.runTrustedAsync(()=>x()):await x()}catch(x){if(x instanceof he||x instanceof Fe)throw x;return ee(`${e}: ${Je(Rt(x))}
2111
+ `)}}Fn();rt();Mn();async function Z4(t,e){let r=t.state.inCondition;t.state.inCondition=!0;let n="",s="",i=0;try{for(let o of e){let a=await t.executeStatement(o);n+=a.stdout,s+=a.stderr,i=a.exitCode}}finally{t.state.inCondition=r}return{stdout:n,stderr:s,exitCode:i}}rt();Tn();function eh(t,e,r,n){if(t instanceof gn)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"break",stdout:e,stderr:r};if(t instanceof yn)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"continue",stdout:e,stderr:r};if(t instanceof tn||t instanceof zn||t instanceof Xe||t instanceof he)return t.prependOutput(e,r),{action:"rethrow",stdout:e,stderr:r,error:t};let s=Rt(t);return{action:"error",stdout:e,stderr:`${r}${s}
2112
+ `,exitCode:1}}rt();Tn();async function Km(t,e,r="",n=""){let s=r,i=n,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(Ah(a)||a instanceof zn||a instanceof Xe||a instanceof he||a instanceof Si)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${Rt(a)}
2113
2113
  `,exitCode:1}}return{stdout:s,stderr:i,exitCode:o}}async function E$(t,e){let r="",n="";for(let s of e.clauses){let i=await Z4(t,s.condition);if(r+=i.stdout,n+=i.stderr,i.exitCode===0)return Km(t,s.body,r,n)}return e.elseBody?Km(t,e.elseBody,r,n):re(r,n,0)}async function S$(t,e){let r=await ji(t,e.redirections);if(r)return r;let n="",s="",i=0,o=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.variable))return ee(`bash: \`${e.variable}': not a valid identifier
2114
2114
  `);let a=[];if(e.words===null)a=(t.state.env.get("@")||"").split(" ").filter(Boolean);else if(e.words.length===0)a=[];else try{for(let c of e.words){let u=await pi(t,c);a.push(...u.values)}}catch(c){if(c instanceof Ei)return{stdout:"",stderr:c.stderr,exitCode:1};throw c}t.state.loopDepth++;try{for(let c of a){o++,o>t.limits.maxLoopIterations&&Hi(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,s),t.state.env.set(e.variable,c);try{for(let u of e.body){let f=await t.executeStatement(u);n+=f.stdout,s+=f.stderr,i=f.exitCode}}catch(u){let f=eh(u,n,s,t.state.loopDepth);if(n=f.stdout,s=f.stderr,f.action==="break")break;if(f.action==="continue")continue;if(f.action==="error"){let h=re(n,s,f.exitCode??1);return sr(t,h,e.redirections)}throw f.error}}}finally{t.state.loopDepth--}let l=re(n,s,i);return sr(t,l,e.redirections)}async function v$(t,e){let r=await ji(t,e.redirections);if(r)return r;let n=e.line;n!==void 0&&(t.state.currentLine=n);let s="",i="",o=0,a=0;e.init&&await be(t,e.init.expression),t.state.loopDepth++;try{for(;a++,a>t.limits.maxLoopIterations&&Hi(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",s,i),!(e.condition&&(n!==void 0&&(t.state.currentLine=n),await be(t,e.condition.expression)===0));){try{for(let c of e.body){let u=await t.executeStatement(c);s+=u.stdout,i+=u.stderr,o=u.exitCode}}catch(c){let u=eh(c,s,i,t.state.loopDepth);if(s=u.stdout,i=u.stderr,u.action==="break")break;if(u.action==="continue"){e.update&&await be(t,e.update.expression);continue}if(u.action==="error"){let f=re(s,i,u.exitCode??1);return sr(t,f,e.redirections)}throw u.error}e.update&&await be(t,e.update.expression)}}finally{t.state.loopDepth--}let l=re(s,i,o);return sr(t,l,e.redirections)}async function A$(t,e,r=""){let n="",s="",i=0,o=0,a=r;for(let c of e.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await Ae(t,u.content);u.stripTabs&&(f=f.split(`
2115
2115
  `).map(h=>h.replace(/^\t+/,"")).join(`
@@ -2138,16 +2138,16 @@ sys 0m0.000s
2138
2138
  `,1)}}if(s=Math.max(...i.map(([a])=>typeof a=="number"?a:0))+1+s,s<0){let a=t.state.currentLine;return{index:0,error:re("",`bash: line ${a}: ${e}[${r}]: bad array subscript
2139
2139
  `,1)}}}return{index:s}}async function tce(t,e,r,n,s,i){let o="",a=r,l=null;if(Bt(t,r)){let f=sF(t,r,n);if(f===void 0)return{continueToNext:!1,xtraceOutput:"",error:re("",`bash: ${r}: circular name reference
2140
2140
  `,1)};if(f===null)return{continueToNext:!0,xtraceOutput:""};a=f;let h=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);h&&(l={arrayName:h[1],subscriptExpr:h[2]},a=h[1])}if(zi(t,a)){if(e.name)return o+=`bash: ${a}: readonly variable
2141
- `,{continueToNext:!0,xtraceOutput:o};let f=Ur(t,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(Xf(t,a))try{let f=new je;if(s){let d=`(${t.state.env.get(a)||"0"}) + (${n})`,p=mt(f,d);c=String(await be(t,p.expression))}else{let h=mt(f,n);c=String(await be(t,h.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(Mn(),n4)),h=f(t,a)?`${a}_0`:a;c=s?(t.state.env.get(h)||"")+n:n}c=Bc(t,a,c),o+=await I$(t,a,c);let u=a;if(l)u=await rce(t,l);else{let{isArray:f}=await Promise.resolve().then(()=>(Mn(),n4));f(t,a)&&(u=`${a}_0`)}return e.name?(i.set(u,t.state.env.get(u)),t.state.env.set(u,c)):(t.state.env.set(u,c),t.state.options.allexport&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(a)),t.state.tempEnvBindings?.some(f=>f.has(a))&&(t.state.mutatedTempEnvVars=t.state.mutatedTempEnvVars||new Set,t.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function rce(t,e){let{arrayName:r,subscriptExpr:n}=e;if(t.state.associativeArrays?.has(r))return D$(t,r,n);let i;if(/^-?\d+$/.test(n))i=Number.parseInt(n,10);else{try{let o=new je,a=mt(o,n);i=await be(t,a.expression,!1)}catch{let o=t.state.env.get(n);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=De(t,r);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${r}_${i}`}mr();rt();Mn();Tn();async function L$(t,e,r,n){let s=await ji(t,e.redirections);if(s)return s;let i=new Map(t.state.env),o=t.state.cwd,a={...t.state.options},l=new Map(t.state.functions),c=t.state.localScopes,u=t.state.localVarStack,f=t.state.localVarDepth,h=t.state.fullyUnsetLocals;if(t.state.localScopes=c.map(P=>new Map(P)),u){t.state.localVarStack=new Map;for(let[P,F]of u.entries())t.state.localVarStack.set(P,F.map(R=>({...R})))}f&&(t.state.localVarDepth=new Map(f)),h&&(t.state.fullyUnsetLocals=new Map(h));let d=t.state.loopDepth,p=t.state.parentHasLoopContext;t.state.parentHasLoopContext=d>0,t.state.loopDepth=0;let m=t.state.lastArg,g=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let y=t.state.groupStdin;r&&(t.state.groupStdin=r);let x="",b="",w=0,S=()=>{t.state.env=i,t.state.cwd=o,t.state.options=a,t.state.functions=l,t.state.localScopes=c,t.state.localVarStack=u,t.state.localVarDepth=f,t.state.fullyUnsetLocals=h,t.state.loopDepth=d,t.state.parentHasLoopContext=p,t.state.groupStdin=y,t.state.bashPid=g,t.state.lastArg=m};try{for(let P of e.body){let F=await n(P);x+=F.stdout,b+=F.stderr,w=F.exitCode}}catch(P){if(S(),P instanceof fe)throw P;if(P instanceof Si){x+=P.stdout,b+=P.stderr;let R=re(x,b,0);return sr(t,R,e.redirections)}if(P instanceof gn||P instanceof yn){x+=P.stdout,b+=P.stderr;let R=re(x,b,0);return sr(t,R,e.redirections)}if(P instanceof Xe){x+=P.stdout,b+=P.stderr;let R=re(x,b,P.exitCode);return sr(t,R,e.redirections)}if(P instanceof tn){x+=P.stdout,b+=P.stderr;let R=re(x,b,P.exitCode);return sr(t,R,e.redirections)}if(P instanceof zn){let R=re(x+P.stdout,b+P.stderr,P.exitCode);return sr(t,R,e.redirections)}let F=re(x,`${b}${Rt(P)}
2141
+ `,{continueToNext:!0,xtraceOutput:o};let f=Ur(t,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(Xf(t,a))try{let f=new je;if(s){let d=`(${t.state.env.get(a)||"0"}) + (${n})`,p=mt(f,d);c=String(await be(t,p.expression))}else{let h=mt(f,n);c=String(await be(t,h.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(Mn(),n4)),h=f(t,a)?`${a}_0`:a;c=s?(t.state.env.get(h)||"")+n:n}c=Bc(t,a,c),o+=await I$(t,a,c);let u=a;if(l)u=await rce(t,l);else{let{isArray:f}=await Promise.resolve().then(()=>(Mn(),n4));f(t,a)&&(u=`${a}_0`)}return e.name?(i.set(u,t.state.env.get(u)),t.state.env.set(u,c)):(t.state.env.set(u,c),t.state.options.allexport&&(t.state.exportedVars=t.state.exportedVars||new Set,t.state.exportedVars.add(a)),t.state.tempEnvBindings?.some(f=>f.has(a))&&(t.state.mutatedTempEnvVars=t.state.mutatedTempEnvVars||new Set,t.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function rce(t,e){let{arrayName:r,subscriptExpr:n}=e;if(t.state.associativeArrays?.has(r))return D$(t,r,n);let i;if(/^-?\d+$/.test(n))i=Number.parseInt(n,10);else{try{let o=new je,a=mt(o,n);i=await be(t,a.expression,!1)}catch{let o=t.state.env.get(n);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=De(t,r);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${r}_${i}`}mr();rt();Mn();Tn();async function L$(t,e,r,n){let s=await ji(t,e.redirections);if(s)return s;let i=new Map(t.state.env),o=t.state.cwd,a={...t.state.options},l=new Map(t.state.functions),c=t.state.localScopes,u=t.state.localVarStack,f=t.state.localVarDepth,h=t.state.fullyUnsetLocals;if(t.state.localScopes=c.map(P=>new Map(P)),u){t.state.localVarStack=new Map;for(let[P,F]of u.entries())t.state.localVarStack.set(P,F.map(R=>({...R})))}f&&(t.state.localVarDepth=new Map(f)),h&&(t.state.fullyUnsetLocals=new Map(h));let d=t.state.loopDepth,p=t.state.parentHasLoopContext;t.state.parentHasLoopContext=d>0,t.state.loopDepth=0;let m=t.state.lastArg,g=t.state.bashPid;t.state.bashPid=t.state.nextVirtualPid++;let y=t.state.groupStdin;r&&(t.state.groupStdin=r);let x="",b="",w=0,S=()=>{t.state.env=i,t.state.cwd=o,t.state.options=a,t.state.functions=l,t.state.localScopes=c,t.state.localVarStack=u,t.state.localVarDepth=f,t.state.fullyUnsetLocals=h,t.state.loopDepth=d,t.state.parentHasLoopContext=p,t.state.groupStdin=y,t.state.bashPid=g,t.state.lastArg=m};try{for(let P of e.body){let F=await n(P);x+=F.stdout,b+=F.stderr,w=F.exitCode}}catch(P){if(S(),P instanceof he)throw P;if(P instanceof Si){x+=P.stdout,b+=P.stderr;let R=re(x,b,0);return sr(t,R,e.redirections)}if(P instanceof gn||P instanceof yn){x+=P.stdout,b+=P.stderr;let R=re(x,b,0);return sr(t,R,e.redirections)}if(P instanceof Xe){x+=P.stdout,b+=P.stderr;let R=re(x,b,P.exitCode);return sr(t,R,e.redirections)}if(P instanceof tn){x+=P.stdout,b+=P.stderr;let R=re(x,b,P.exitCode);return sr(t,R,e.redirections)}if(P instanceof zn){let R=re(x+P.stdout,b+P.stderr,P.exitCode);return sr(t,R,e.redirections)}let F=re(x,`${b}${Rt(P)}
2142
2142
  `,1);return sr(t,F,e.redirections)}S();let _=re(x,b,w);return sr(t,_,e.redirections)}async function F$(t,e,r,n){let s="",i="",o=0,a=await Um(t,e.redirections);if(a)return a;let l=r;for(let f of e.redirections)if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let h=f.target,d=await Ae(t,h.content);h.stripTabs&&(d=d.split(`
2143
2143
  `).map(m=>m.replace(/^\t+/,"")).join(`
2144
2144
  `));let p=f.fd??0;p!==0?(t.state.fileDescriptors||(t.state.fileDescriptors=new Map),An(t),t.state.fileDescriptors.set(p,d)):l=d}else if(f.operator==="<<<"&&f.target.type==="Word")l=`${await Ae(t,f.target)}
2145
2145
  `;else if(f.operator==="<"&&f.target.type==="Word")try{let h=await Ae(t,f.target),d=t.fs.resolvePath(t.state.cwd,h);l=await t.fs.readFile(d)}catch{let h=await Ae(t,f.target);return re("",`bash: ${h}: No such file or directory
2146
- `,1)}let c=t.state.groupStdin;l&&(t.state.groupStdin=l);try{for(let f of e.body){let h=await n(f);s+=h.stdout,i+=h.stderr,o=h.exitCode}}catch(f){if(t.state.groupStdin=c,f instanceof fe)throw f;if(Ah(f)||f instanceof zn||f instanceof Xe)throw f.prependOutput(s,i),f;return re(s,`${i}${Rt(f)}
2146
+ `,1)}let c=t.state.groupStdin;l&&(t.state.groupStdin=l);try{for(let f of e.body){let h=await n(f);s+=h.stdout,i+=h.stderr,o=h.exitCode}}catch(f){if(t.state.groupStdin=c,f instanceof he)throw f;if(Ah(f)||f instanceof zn||f instanceof Xe)throw f.prependOutput(s,i),f;return re(s,`${i}${Rt(f)}
2147
2147
  `,1)}t.state.groupStdin=c;let u=re(s,i,o);return sr(t,u,e.redirections)}async function M$(t,e,r,n,s){let i;try{i=await t.fs.readFile(e)}catch{return ee(`bash: ${e}: No such file or directory
2148
2148
  `,127)}if(i.startsWith("#!")){let g=i.indexOf(`
2149
- `);g!==-1&&(i=i.slice(g+1))}let o=new Map(t.state.env),a=t.state.cwd,l={...t.state.options},c=t.state.loopDepth,u=t.state.parentHasLoopContext,f=t.state.lastArg,h=t.state.bashPid,d=t.state.groupStdin,p=t.state.currentSource;t.state.parentHasLoopContext=c>0,t.state.loopDepth=0,t.state.bashPid=t.state.nextVirtualPid++,n&&(t.state.groupStdin=n),t.state.currentSource=e,t.state.env.set("0",e),t.state.env.set("#",String(r.length)),t.state.env.set("@",r.join(" ")),t.state.env.set("*",r.join(" "));for(let g=0;g<r.length&&g<9;g++)t.state.env.set(String(g+1),r[g]);for(let g=r.length+1;g<=9;g++)t.state.env.delete(String(g));let m=()=>{t.state.env=o,t.state.cwd=a,t.state.options=l,t.state.loopDepth=c,t.state.parentHasLoopContext=u,t.state.lastArg=f,t.state.bashPid=h,t.state.groupStdin=d,t.state.currentSource=p};try{let y=new je().parse(i),x=await s(y);return m(),x}catch(g){if(m(),g instanceof Xe||g instanceof fe)throw g;if(g.name==="ParseException")return ee(`bash: ${e}: ${g.message}
2150
- `);throw g}}var th=class{ctx;constructor(e,r){this.ctx={state:r,fs:e.fs,commands:e.commands,limits:e.limits,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep,trace:e.trace,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext??!1,jsBootstrapCode:e.jsBootstrapCode,invokeTool:e.invokeTool}}assertDefenseContext(e){if(!this.ctx.requireDefenseContext||Et.isInSandboxedContext())return;let r=`interpreter ${e} attempted outside defense context`;throw new Fe(r,{timestamp:Date.now(),type:"missing_defense_context",message:r,path:"DefenseInDepthBox.context",stack:new Error().stack,executionId:Et.getCurrentExecutionId()})}buildExportedEnv(){let e=this.ctx.state.exportedVars,r=this.ctx.state.tempExportedVars,n=new Set;if(e)for(let i of e)n.add(i);if(r)for(let i of r)n.add(i);if(n.size===0)return Object.create(null);let s=Object.create(null);for(let i of n){let o=this.ctx.state.env.get(i);o!==void 0&&(s[i]=o)}return s}async executeScript(e){this.assertDefenseContext("execution");let r="",n="",s=0,i=this.ctx.limits.maxOutputSize,o=(a,l)=>{r.length+n.length+a.length+l.length>i&&Hi(`total output size exceeded (>${i} bytes), increase executionLimits.maxOutputSize`,"output_size"),r+=a,n+=l};for(let a of e.statements)try{let l=await this.executeStatement(a);o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}catch(l){if(l instanceof Xe)throw l.prependOutput(r,n),l;if(l instanceof fs)return o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof fe)throw l;if(l instanceof zn)return o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof Nn)return o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof kn)return o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof It){o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(l instanceof dl){o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(l instanceof gn||l instanceof yn){if(this.ctx.state.loopDepth>0)throw l.prependOutput(r,n),l;o(l.stdout,l.stderr);continue}throw l instanceof tn&&l.prependOutput(r,n),l}return{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)}}async executeUserScript(e,r,n=""){return M$(this.ctx,e,r,n,s=>this.executeScript(s))}async executeStatement(e){if(this.assertDefenseContext("statement"),this.ctx.state.signal?.aborted)throw new pl;if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Hi(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),e.deferredError)throw new Qr(e.deferredError.message,e.line??1,1);if(this.ctx.state.options.noexec)return tt;this.ctx.state.errexitSafe=!1;let r="",n="";this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&e.sourceText&&(n+=`${e.sourceText}
2149
+ `);g!==-1&&(i=i.slice(g+1))}let o=new Map(t.state.env),a=t.state.cwd,l={...t.state.options},c=t.state.loopDepth,u=t.state.parentHasLoopContext,f=t.state.lastArg,h=t.state.bashPid,d=t.state.groupStdin,p=t.state.currentSource;t.state.parentHasLoopContext=c>0,t.state.loopDepth=0,t.state.bashPid=t.state.nextVirtualPid++,n&&(t.state.groupStdin=n),t.state.currentSource=e,t.state.env.set("0",e),t.state.env.set("#",String(r.length)),t.state.env.set("@",r.join(" ")),t.state.env.set("*",r.join(" "));for(let g=0;g<r.length&&g<9;g++)t.state.env.set(String(g+1),r[g]);for(let g=r.length+1;g<=9;g++)t.state.env.delete(String(g));let m=()=>{t.state.env=o,t.state.cwd=a,t.state.options=l,t.state.loopDepth=c,t.state.parentHasLoopContext=u,t.state.lastArg=f,t.state.bashPid=h,t.state.groupStdin=d,t.state.currentSource=p};try{let y=new je().parse(i),x=await s(y);return m(),x}catch(g){if(m(),g instanceof Xe||g instanceof he)throw g;if(g.name==="ParseException")return ee(`bash: ${e}: ${g.message}
2150
+ `);throw g}}var th=class{ctx;constructor(e,r){this.ctx={state:r,fs:e.fs,commands:e.commands,limits:e.limits,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep,trace:e.trace,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext??!1,jsBootstrapCode:e.jsBootstrapCode,invokeTool:e.invokeTool}}assertDefenseContext(e){if(!this.ctx.requireDefenseContext||Et.isInSandboxedContext())return;let r=`interpreter ${e} attempted outside defense context`;throw new Fe(r,{timestamp:Date.now(),type:"missing_defense_context",message:r,path:"DefenseInDepthBox.context",stack:new Error().stack,executionId:Et.getCurrentExecutionId()})}buildExportedEnv(){let e=this.ctx.state.exportedVars,r=this.ctx.state.tempExportedVars,n=new Set;if(e)for(let i of e)n.add(i);if(r)for(let i of r)n.add(i);if(n.size===0)return Object.create(null);let s=Object.create(null);for(let i of n){let o=this.ctx.state.env.get(i);o!==void 0&&(s[i]=o)}return s}async executeScript(e){this.assertDefenseContext("execution");let r="",n="",s=0,i=this.ctx.limits.maxOutputSize,o=(a,l)=>{r.length+n.length+a.length+l.length>i&&Hi(`total output size exceeded (>${i} bytes), increase executionLimits.maxOutputSize`,"output_size"),r+=a,n+=l};for(let a of e.statements)try{let l=await this.executeStatement(a);o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}catch(l){if(l instanceof Xe)throw l.prependOutput(r,n),l;if(l instanceof fs)return o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof he)throw l;if(l instanceof zn)return o(l.stdout,l.stderr),s=l.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof Nn)return o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof kn)return o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)};if(l instanceof It){o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(l instanceof dl){o(l.stdout,l.stderr),s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(l instanceof gn||l instanceof yn){if(this.ctx.state.loopDepth>0)throw l.prependOutput(r,n),l;o(l.stdout,l.stderr);continue}throw l instanceof tn&&l.prependOutput(r,n),l}return{stdout:r,stderr:n,exitCode:s,env:Cr(this.ctx.state.env)}}async executeUserScript(e,r,n=""){return M$(this.ctx,e,r,n,s=>this.executeScript(s))}async executeStatement(e){if(this.assertDefenseContext("statement"),this.ctx.state.signal?.aborted)throw new pl;if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Hi(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),e.deferredError)throw new Qr(e.deferredError.message,e.line??1,1);if(this.ctx.state.options.noexec)return tt;this.ctx.state.errexitSafe=!1;let r="",n="";this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&e.sourceText&&(n+=`${e.sourceText}
2151
2151
  `);let s=0,i=-1,o=!1;for(let c=0;c<e.pipelines.length;c++){let u=e.pipelines[c],f=c>0?e.operators[c-1]:null;if(f==="&&"&&s!==0||f==="||"&&s===0)continue;let h=await this.executePipeline(u);r+=h.stdout,n+=h.stderr,s=h.exitCode,i=c,o=u.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}let a=i<e.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||l,this.ctx.state.options.errexit&&s!==0&&i===e.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!l)throw new zn(s,r,n);return re(r,n,s)}async executePipeline(e){return R$(this.ctx,e,(r,n)=>this.executeCommand(r,n))}async executeCommand(e,r){switch(this.assertDefenseContext("command"),this.ctx.coverage?.hit(`bash:cmd:${e.type}`),e.type){case"SimpleCommand":return this.executeSimpleCommand(e,r);case"If":return E$(this.ctx,e);case"For":return S$(this.ctx,e);case"CStyleFor":return v$(this.ctx,e);case"While":return A$(this.ctx,e,r);case"Until":return C$(this.ctx,e);case"Case":return N$(this.ctx,e);case"Subshell":return this.executeSubshell(e,r);case"Group":return this.executeGroup(e,r);case"FunctionDef":return zM(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return tt}}async executeSimpleCommand(e,r){try{return await this.executeSimpleCommandInner(e,r)}catch(n){if(n instanceof Ei)return ee(n.stderr);throw n}}async executeSimpleCommandInner(e,r){if(e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.shoptOptions.expand_aliases&&e.name){let w=e,S=100;for(;S>0;){let _=this.expandAlias(w);if(_===w)break;w=_,S--}this.aliasExpansionStack.clear(),w!==e&&(e=w)}this.ctx.state.expansionStderr="";let n=await P$(this.ctx,e);if(n.error)return n.error;let s=n.tempAssignments,i=n.xtraceOutput;if(!e.name){if(e.redirections.length>0){let S=await ji(this.ctx,e.redirections);if(S)return S;let _=re("",i,0);return sr(this.ctx,_,e.redirections)}this.ctx.state.lastArg="";let w=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",re("",w,this.ctx.state.lastExitCode)}let o=e.name&&Y4(e.name,["local","declare","typeset","export","readonly"]),a=Array.from(s.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let w of a)this.ctx.state.tempExportedVars.add(w)}let l=await Um(this.ctx,e.redirections);if(l){for(let[w,S]of s)S===void 0?this.ctx.state.env.delete(w):this.ctx.state.env.set(w,S);return l}let c=-1;for(let w of e.redirections){if((w.operator==="<<"||w.operator==="<<-")&&w.target.type==="HereDoc"){let S=w.target,_=await Ae(this.ctx,S.content);S.stripTabs&&(_=_.split(`
2152
2152
  `).map(F=>F.replace(/^\t+/,"")).join(`
2153
2153
  `)),_=Ts(_);let P=w.fd??0;P!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),An(this.ctx),this.ctx.state.fileDescriptors.set(P,_)):r=_;continue}if(w.operator==="<<<"&&w.target.type==="Word"){r=Ts(`${await Ae(this.ctx,w.target)}
@@ -2183,13 +2183,13 @@ ${t.terminator}`}function Mce(t){return`(${js(t.body)})${mi(t.redirections)}`}fu
2183
2183
  `],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",n],["OLDPWD",n],["OPTIND","1"],...Object.entries(e.env??{})]);if(this.limits=$$({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=eS(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:s,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(e.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",d7(this.state.options)),this.state.env.set("BASHOPTS",p7(this.state.shoptOptions)),JD(r,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),n!=="/"&&r instanceof $i)try{r.mkdirSync(n,{recursive:!0})}catch{}for(let o of zD(e.commands))this.registerCommand(o);if(e.fetch||e.network)for(let o of HD())this.registerCommand(o);if(e.python)for(let o of jD())this.registerCommand(o);let i=typeof e.javascript=="object"?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let o of GD())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let o of e.customCommands)if(KD(o)){let a=YD(o);a.custom=!0,this.registerCommand(a)}else this.registerCommand({...o,trusted:o.trusted??!0,custom:!0});this.isConstructing=!1}registerCommand(e){this.isConstructing||(e.custom=!0),this.commands.set(e.name,e);let r=this.fs;if(typeof r.writeFileSync=="function"){let n=`#!/bin/bash
2184
2184
  # Built-in command: ${e.name}
2185
2185
  `;try{r.writeFileSync(`/bin/${e.name}`,n)}catch{}try{r.writeFileSync(`/usr/bin/${e.name}`,n)}catch{}}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug("stdout",{output:e.stdout}),e.stderr&&this.logger.info("stderr",{output:e.stderr}),this.logger.info("exit",{exitCode:e.exitCode})),e.stdout=eB(e.stdout),e.stderr=eB(e.stderr),e}async exec(e,r){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
2186
- `,exitCode:1,env:Is(this.state.env,r?.env)};if(!e.trim())return{stdout:"",stderr:"",exitCode:0,env:Is(this.state.env,r?.env)};this.logger?.info("exec",{command:e});let n=r?.cwd??this.state.cwd,s,i=n;if(r?.cwd)if(r.env&&"PWD"in r.env)s=r.env.PWD;else if(r?.env&&!("PWD"in r.env))try{s=await this.fs.realpath(n),i=s}catch{s=n}else s=n;let o=r?.replaceEnv?new Map:new Map(this.state.env);if(r?.env)for(let[f,h]of Object.entries(r.env))o.set(f,h);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:Hce(r?.stdin,r?.stdinKind),signal:r?.signal,extraArgs:r?.args},l=e;r?.rawScript||(l=J$(e));let c=this.defenseInDepthConfig?Et.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let h=Dn(l,{maxHeredocSize:this.limits.maxHeredocSize}),d;if(this.transformPlugins.length>0){let x=Object.create(null);for(let b of this.transformPlugins){let w=b.transform({ast:h,metadata:x});h=w.ast,w.metadata&&(x=Xi(x,w.metadata))}d=x}let p={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},y=await new th(p,a).executeScript(h);return d&&(y.metadata=d),this.logResult(y)};return u?await u.run(f):await f()}catch(f){if(f instanceof Xe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Is(this.state.env,r?.env)});if(f instanceof fs)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Is(this.state.env,r?.env)});if(f instanceof It)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Is(this.state.env,r?.env)});if(f instanceof pl)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:Is(this.state.env,r?.env)});if(f instanceof fe)return this.logResult({stdout:f.stdout,stderr:Je(f.stderr),exitCode:fe.EXIT_CODE,env:Is(this.state.env,r?.env)});if(f instanceof Fe)return this.logResult({stdout:"",stderr:`bash: security violation: ${Je(f.message)}
2186
+ `,exitCode:1,env:Is(this.state.env,r?.env)};if(!e.trim())return{stdout:"",stderr:"",exitCode:0,env:Is(this.state.env,r?.env)};this.logger?.info("exec",{command:e});let n=r?.cwd??this.state.cwd,s,i=n;if(r?.cwd)if(r.env&&"PWD"in r.env)s=r.env.PWD;else if(r?.env&&!("PWD"in r.env))try{s=await this.fs.realpath(n),i=s}catch{s=n}else s=n;let o=r?.replaceEnv?new Map:new Map(this.state.env);if(r?.env)for(let[f,h]of Object.entries(r.env))o.set(f,h);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:Hce(r?.stdin,r?.stdinKind),signal:r?.signal,extraArgs:r?.args},l=e;r?.rawScript||(l=J$(e));let c=this.defenseInDepthConfig?Et.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let h=Dn(l,{maxHeredocSize:this.limits.maxHeredocSize}),d;if(this.transformPlugins.length>0){let x=Object.create(null);for(let b of this.transformPlugins){let w=b.transform({ast:h,metadata:x});h=w.ast,w.metadata&&(x=Xi(x,w.metadata))}d=x}let p={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},y=await new th(p,a).executeScript(h);return d&&(y.metadata=d),this.logResult(y)};return u?await u.run(f):await f()}catch(f){if(f instanceof Xe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Is(this.state.env,r?.env)});if(f instanceof fs)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Is(this.state.env,r?.env)});if(f instanceof It)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Is(this.state.env,r?.env)});if(f instanceof pl)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:Is(this.state.env,r?.env)});if(f instanceof he)return this.logResult({stdout:f.stdout,stderr:Je(f.stderr),exitCode:he.EXIT_CODE,env:Is(this.state.env,r?.env)});if(f instanceof Fe)return this.logResult({stdout:"",stderr:`bash: security violation: ${Je(f.message)}
2187
2187
  `,exitCode:1,env:Is(this.state.env,r?.env)});if(f.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${Je(f.message)}
2188
2188
  `,exitCode:2,env:Is(this.state.env,r?.env)});if(f instanceof Zo)return this.logResult({stdout:"",stderr:`bash: ${Je(f.message)}
2189
2189
  `,exitCode:2,env:Is(this.state.env,r?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${Je(f.message)}
2190
2190
  `,exitCode:1,env:Is(this.state.env,r?.env)});throw f}finally{u?.deactivate()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,r){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),r)}getCwd(){return this.state.cwd}getEnv(){return Cr(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){let r=J$(e),n=Dn(r,{maxHeredocSize:this.limits.maxHeredocSize}),s=Object.create(null);for(let i of this.transformPlugins){let o=i.transform({ast:n,metadata:s});n=o.ast,o.metadata&&(s=Xi(s,o.metadata))}return{script:zc(n),ast:n,metadata:s}}};function J$(t){let e=t.split(`
2191
2191
  `),r=[],n=[];for(let s=0;s<e.length;s++){let i=e[s];if(n.length>0){let l=n[n.length-1];if((l.stripTabs?i.replace(/^\t+/,""):i)===l.delimiter){r.push(i.trimStart()),n.pop();continue}r.push(i);continue}let o=i.trimStart();r.push(o);let a=/<<(-?)\s*(['"]?)([\w-]+)\2/g;for(let l of o.matchAll(a)){let c=l[1]==="-",u=l[3];n.push({delimiter:u,stripTabs:c})}}return r.join(`
2192
- `)}var zce=new TextDecoder("utf-8",{fatal:!0});function eB(t){if(!t)return t;let e=!1;for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);if(s>255)return t;s>127&&(e=!0)}if(!e)return t;let r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);try{return zce.decode(r)}catch{return t}}function Hce(t,e){if(t!==void 0)return e==="bytes"?t:Ts(t)}Re();Re();var rh=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new $i,e?.mounts)for(let{mountPoint:r,filesystem:n}of e.mounts)this.mount(r,n)}mount(e,r){this.validateMountPath(e);let n=we(e);this.validateMount(n),this.mounts.set(n,{mountPoint:n,filesystem:r})}unmount(e){let r=we(e);if(!this.mounts.has(r))throw new Error(`No filesystem mounted at '${e}'`);this.mounts.delete(r)}getMounts(){return Array.from(this.mounts.values()).map(e=>({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let r=we(e);return this.mounts.has(r)}validateMountPath(e){let r=e.split("/");for(let n of r)if(n==="."||n==="..")throw new Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e==="/")throw new Error("Cannot mount at root '/'");for(let r of this.mounts.keys())if(r!==e){if(e.startsWith(`${r}/`))throw new Error(`Cannot mount at '${e}': inside existing mount '${r}'`);if(r.startsWith(`${e}/`))throw new Error(`Cannot mount at '${e}': would contain existing mount '${r}'`)}}routePath(e){Se(e,"access");let r=we(e),n=null,s=0;for(let i of this.mounts.values()){let o=i.mountPoint;if(r===o)return{fs:i.filesystem,relativePath:"/"};r.startsWith(`${o}/`)&&o.length>s&&(n=i,s=o.length)}if(n){let i=r.slice(s);return{fs:n.filesystem,relativePath:i||"/"}}return{fs:this.baseFs,relativePath:r}}getChildMountPoints(e){let r=we(e),n=r==="/"?"/":`${r}/`,s=[];for(let i of this.mounts.keys())if(i.startsWith(n)){let a=i.slice(n.length).split("/")[0];a&&!s.includes(a)&&s.push(a)}return s}async readFile(e,r){let{fs:n,relativePath:s}=this.routePath(e);return n.readFile(s,r)}async readFileBytes(e){let{fs:r,relativePath:n}=this.routePath(e);return wi(r,n)}async readFileBuffer(e){let{fs:r,relativePath:n}=this.routePath(e);return r.readFileBuffer(n)}async writeFile(e,r,n){let{fs:s,relativePath:i}=this.routePath(e);return s.writeFile(i,r,n)}async appendFile(e,r,n){let{fs:s,relativePath:i}=this.routePath(e);return s.appendFile(i,r,n)}async exists(e){let r=we(e);if(this.mounts.has(r)||this.getChildMountPoints(r).length>0)return!0;let{fs:s,relativePath:i}=this.routePath(e);return s.exists(i)}async stat(e){let r=we(e),n=this.mounts.get(r);if(n)try{return await n.filesystem.stat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(r).length>0)try{return await this.baseFs.stat(r)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.stat(o)}async lstat(e){let r=we(e),n=this.mounts.get(r);if(n)try{return await n.filesystem.lstat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(r).length>0)try{return await this.baseFs.lstat(r)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.lstat(o)}async mkdir(e,r){let n=we(e);if(this.mounts.has(n)){if(r?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(n).length>0&&r?.recursive)return;let{fs:i,relativePath:o}=this.routePath(e);return i.mkdir(o,r)}async readdir(e){let r=we(e),n=new Set,s=null,{fs:i,relativePath:o}=this.routePath(e);try{let l=await i.readdir(o);for(let c of l)n.add(c)}catch(l){let c=l.code,u=l.message||"";if(c!=="ENOENT"&&!u.includes("ENOENT"))throw l;s=l}let a=this.getChildMountPoints(r);for(let l of a)n.add(l);if(n.size===0&&s&&!this.mounts.has(r))throw s;return Array.from(n).sort()}async rm(e,r){let n=we(e);if(this.mounts.has(n))throw new Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(n).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:i,relativePath:o}=this.routePath(e);return i.rm(o,r)}async cp(e,r,n){let s=this.routePath(e),i=this.routePath(r);return s.fs===i.fs?s.fs.cp(s.relativePath,i.relativePath,n):this.crossMountCopy(e,r,n)}async mv(e,r){let n=we(e);if(this.mounts.has(n))throw new Error(`EBUSY: mount point, cannot move '${e}'`);let s=this.routePath(e),i=this.routePath(r);if(s.fs===i.fs)return s.fs.mv(s.relativePath,i.relativePath);await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,r){return Go(e,r)}getAllPaths(){let e=new Set;for(let r of this.baseFs.getAllPaths())e.add(r);for(let r of this.mounts.keys()){let n=r.split("/").filter(Boolean),s="";for(let o of n)s=`${s}/${o}`,e.add(s);let i=this.mounts.get(r);if(i)for(let o of i.filesystem.getAllPaths())o==="/"?e.add(r):e.add(`${r}${o}`)}return Array.from(e).sort()}async chmod(e,r){let n=we(e),s=this.mounts.get(n);if(s)return s.filesystem.chmod("/",r);let{fs:i,relativePath:o}=this.routePath(e);return i.chmod(o,r)}async symlink(e,r){let{fs:n,relativePath:s}=this.routePath(r);return n.symlink(e,s)}async link(e,r){let n=this.routePath(e),s=this.routePath(r);if(n.fs!==s.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${r}'`);return n.fs.link(n.relativePath,s.relativePath)}async readlink(e){let{fs:r,relativePath:n}=this.routePath(e);return r.readlink(n)}async realpath(e){let r=we(e);if(this.mounts.get(r))return r;let{fs:s,relativePath:i}=this.routePath(e),o=await s.realpath(i);for(let[a,l]of this.mounts)if(r===a||r.startsWith(`${a}/`))return o==="/"?a:`${a}${o}`;return o}async crossMountCopy(e,r,n){let s=await this.lstat(e);if(s.isFile){let i=await this.readFileBuffer(e);await this.writeFile(r,i),await this.chmod(r,s.mode)}else if(s.isDirectory){if(!n?.recursive)throw new Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(r,{recursive:!0});let i=await this.readdir(e);for(let o of i){let a=Ko(e,o),l=Ko(r,o);await this.crossMountCopy(a,l,n)}}else if(s.isSymbolicLink){let i=await this.readlink(e);await this.symlink(i,r)}}async utimes(e,r,n){let{fs:s,relativePath:i}=this.routePath(e);return s.utimes(i,r,n)}};var Jt=Mr(require("node:fs"),1),pn=Mr(require("node:path"),1);Re();Sc();var Vs=Mr(require("node:fs"),1),$n=Mr(require("node:path"),1);rn();function gi(t,e){if(t===e)return!0;let r=t[e.length];return(r==="/"||r==="\\")&&t.startsWith(e)}function al(t,e){try{let r=Vs.realpathSync(t);return gi(r,e)?r:null}catch(r){if(r.code==="ENOENT"){let n=$n.dirname(t);if(n===t)return null;let s=al(n,e);if(s===null)return null;try{if(Vs.lstatSync(t).isSymbolicLink()){let o=Vs.readlinkSync(t),a=$n.isAbsolute(o)?o:$n.resolve($n.dirname(t),o);if(al(a,e)===null)return null}}catch{}return $n.join(s,$n.basename(t))}return null}}function Jm(t,e,r){let n=al(t,r);if(n===null)return null;let s=$n.resolve(t),i=s.slice(e.length),o=n.slice(r.length);if(i!==o)return null;try{if(Vs.lstatSync(s).isSymbolicLink())return null}catch{}return n}function e1(t,e){if(!Vs.existsSync(t))throw new Error(`${e} root does not exist`);if(!Vs.statSync(t).isDirectory())throw new Error(`${e} root is not a directory`)}function tB(t,e){if(!$n.isAbsolute(t))return{withinRoot:!0,relativePath:t};let r;try{r=Vs.realpathSync(t)}catch{r=$n.resolve(t)}return gi(r,e)?{withinRoot:!0,relativePath:r.slice(e.length).replace(/\\/g,"/")||"/"}:{withinRoot:!1,safeName:$n.basename(t)}}function t1(t,e,r,n){let s=t;if(s.path===void 0){for(let o of n)if(s.message?.includes(o))throw t}let i=s.code||"EIO";throw new Error(`${i}: ${r} '${e}'`)}var Wce=["ELOOP","EFBIG","EPERM"],jce="/home/user/project",ll=class{root;canonicalRoot;mountPoint;readOnly;maxFileReadSize;allowSymlinks;memory=new Map;deleted=new Set;constructor(e){this.root=pn.resolve(e.root);let r=e.mountPoint??jce;if(this.mountPoint=r==="/"?"/":r.replace(/\/+$/,""),!this.mountPoint.startsWith("/"))throw new Error(`Mount point must be an absolute path: ${r}`);this.readOnly=e.readOnly??!1,this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,e1(this.root,"OverlayFs"),this.canonicalRoot=Jt.realpathSync(this.root),this.createMountPointDirs()}assertWritable(e){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${e}`)}createMountPointDirs(){let e=this.mountPoint.split("/").filter(Boolean),r="";for(let n of e)r+=`/${n}`,this.memory.has(r)||this.memory.set(r,{type:"directory",mode:493,mtime:new Date});this.memory.has("/")||this.memory.set("/",{type:"directory",mode:493,mtime:new Date})}getMountPoint(){return this.mountPoint}mkdirSync(e,r){let s=we(e).split("/").filter(Boolean),i="";for(let o of s)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(e,r){let n=we(e),s=this.getDirname(n);s!=="/"&&this.mkdirSync(s);let i=r instanceof Uint8Array?r:new TextEncoder().encode(r);this.memory.set(n,{type:"file",content:i,mode:420,mtime:new Date})}getDirname(e){let r=e.lastIndexOf("/");return r===0?"/":e.slice(0,r)}getRelativeToMount(e){return this.mountPoint==="/"?e:e===this.mountPoint?"/":e.startsWith(`${this.mountPoint}/`)?e.slice(this.mountPoint.length):null}toRealPath(e){let r=we(e),n=this.getRelativeToMount(r);if(n===null)return null;let s=pn.join(this.root,n),i=pn.resolve(s);return gi(i,this.root)?i:null}resolveRealPath_(e){return e?this.allowSymlinks?al(e,this.canonicalRoot):Jm(e,this.root,this.canonicalRoot):null}resolveRealPathParent_(e){if(!e)return null;let r=pn.dirname(e),n=this.resolveRealPath_(r);return n===null?null:pn.join(n,pn.basename(e))}sanitizeError(e,r,n){t1(e,r,n,Wce)}ensureParentDirs(e){let r=Za(e);r!=="/"&&(this.memory.has(r)||(this.ensureParentDirs(r),this.memory.set(r,{type:"directory",mode:493,mtime:new Date})),this.deleted.delete(r))}async existsInOverlay(e){let r=we(e);if(this.deleted.has(r))return!1;if(this.memory.has(r))return!0;let n=this.resolveRealPathParent_(this.toRealPath(r));if(!n)return!1;try{return await Jt.promises.lstat(n),!0}catch{return!1}}async readFile(e,r){let n=await this.readFileBuffer(e),s=zs(r);return xs(n,s)}async readFileBytes(e){let r=await this.readFileBuffer(e);return xs(r,"binary")}async readFileBuffer(e,r=new Set){Se(e,"open");let n=we(e);if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);if(r.add(n),this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, open '${e}'`);let s=this.memory.get(n);if(s){if(s.type==="symlink"){let o=this.resolveSymlink(n,s.target);return this.readFileBuffer(o,r)}if(s.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return s.content}let i=this.resolveRealPath_(this.toRealPath(n));if(!i)throw new Error(`ENOENT: no such file or directory, open '${e}'`);try{let o=await Jt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let c=await Jt.promises.readlink(i),u=this.realTargetToVirtual(n,c),f=this.resolveSymlink(n,u);return this.readFileBuffer(f,r)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${o.size} bytes, max ${this.maxFileReadSize})`);let a=this.allowSymlinks?Jt.constants.O_RDONLY:Jt.constants.O_RDONLY|Jt.constants.O_NOFOLLOW,l=await Jt.promises.open(i,a);try{let c=await l.readFile();return new Uint8Array(c)}finally{await l.close()}}catch(o){let a=o.code;if(a==="ENOENT")throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(a==="ELOOP")throw new Error(`ENOENT: no such file or directory, open '${e}'`);this.sanitizeError(o,e,"open")}}async writeFile(e,r,n){Se(e,"write"),this.assertWritable(`write '${e}'`);let s=we(e);this.ensureParentDirs(s);let i=zs(n),o=ao(r,i);this.memory.set(s,{type:"file",content:o,mode:420,mtime:new Date}),this.deleted.delete(s)}async appendFile(e,r,n){Se(e,"append"),this.assertWritable(`append '${e}'`);let s=we(e),i=zs(n),o=ao(r,i),a;try{a=await this.readFileBuffer(s)}catch{a=new Uint8Array(0)}let l=new Uint8Array(a.length+o.length);l.set(a),l.set(o,a.length),this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:420,mtime:new Date}),this.deleted.delete(s)}async exists(e){return e.includes("\0")?!1:this.existsInOverlay(e)}async stat(e,r=new Set){Se(e,"stat");let n=we(e);if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, stat '${e}'`);if(r.add(n),this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=this.memory.get(n);if(s){if(s.type==="symlink"){let a=this.resolveSymlink(n,s.target);return this.stat(a,r)}let o=0;return s.type==="file"&&(o=s.content.length),{isFile:s.type==="file",isDirectory:s.type==="directory",isSymbolicLink:!1,mode:s.mode,size:o,mtime:s.mtime}}let i=this.resolveRealPath_(this.toRealPath(n));if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);try{let o=await Jt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let a=await Jt.promises.readlink(i),l=this.realTargetToVirtual(n,a),c=this.resolveSymlink(n,l);return this.stat(c,r)}return{isFile:o.isFile(),isDirectory:o.isDirectory(),isSymbolicLink:!1,mode:o.mode,size:o.size,mtime:o.mtime}}catch(o){if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, stat '${e}'`);this.sanitizeError(o,e,"stat")}}async lstat(e){Se(e,"lstat");let r=we(e);if(this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime};let i=0;return n.type==="file"&&(i=n.content.length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:i,mtime:n.mtime}}let s=this.resolveRealPathParent_(this.toRealPath(r));if(!s)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);try{let i=await Jt.promises.lstat(s);return{isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink(),mode:i.mode,size:i.size,mtime:i.mtime}}catch(i){if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);this.sanitizeError(i,e,"lstat")}}resolveSymlink(e,r){return Ac(e,r)}realTargetToVirtual(e,r){let n=tB(r,this.canonicalRoot);if(n.withinRoot){if(!pn.isAbsolute(r))return r;let s=n.relativePath;return this.mountPoint==="/"?s:`${this.mountPoint}${s}`}return n.safeName}async mkdir(e,r){Se(e,"mkdir"),this.assertWritable(`mkdir '${e}'`);let n=we(e);if(await this.existsInOverlay(n)){if(!r?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${e}'`);return}let i=Za(n);if(i!=="/"&&!await this.existsInOverlay(i))if(r?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.memory.set(n,{type:"directory",mode:493,mtime:new Date}),this.deleted.delete(n)}async readdirCore(e,r){if(this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let n=new Map,s=new Set,i=r==="/"?"/":`${r}/`;for(let a of this.deleted)if(a.startsWith(i)){let l=a.slice(i.length),c=l.split("/")[0];c&&!l.includes("/",c.length)&&s.add(c)}for(let[a,l]of this.memory)if(a!==r&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!s.has(u)&&!c.includes("/",1)&&n.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}let o=this.resolveRealPath_(this.toRealPath(r));if(o)try{if(!this.allowSymlinks&&(await Jt.promises.lstat(o)).isSymbolicLink()){if(!this.memory.has(r))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);return n}let a=await Jt.promises.readdir(o,{withFileTypes:!0});for(let l of a)!s.has(l.name)&&!n.has(l.name)&&n.set(l.name,{name:l.name,isFile:l.isFile(),isDirectory:l.isDirectory(),isSymbolicLink:l.isSymbolicLink()})}catch(a){if(a.code==="ENOENT"){if(!this.memory.has(r))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`)}else a.code!=="ENOTDIR"&&this.sanitizeError(a,e,"scandir")}return n}async resolveForReaddir(e,r=!1){let n=we(e),s=new Set,i=r,o=this.memory.get(n);for(;o&&o.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),i=!0,n=this.resolveSymlink(n,o.target),o=this.memory.get(n)}if(o)return{normalized:n,outsideOverlay:!1};if(this.getRelativeToMount(n)===null)return{normalized:n,outsideOverlay:!0};let l=this.resolveRealPath_(this.toRealPath(n));if(!l)return{normalized:n,outsideOverlay:!0};try{if((await Jt.promises.lstat(l)).isSymbolicLink()){if(!this.allowSymlinks)return{normalized:n,outsideOverlay:!0};let u=await Jt.promises.readlink(l),f=this.realTargetToVirtual(n,u),h=this.resolveSymlink(n,f);return this.resolveForReaddir(h,!0)}return{normalized:n,outsideOverlay:!1}}catch{return i?{normalized:n,outsideOverlay:!0}:{normalized:n,outsideOverlay:!1}}}async readdir(e){Se(e,"scandir");let{normalized:r,outsideOverlay:n}=await this.resolveForReaddir(e);if(n)return[];let s=await this.readdirCore(e,r);return Array.from(s.keys()).sort((i,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(e){Se(e,"scandir");let{normalized:r,outsideOverlay:n}=await this.resolveForReaddir(e);if(n)return[];let s=await this.readdirCore(e,r);return Array.from(s.values()).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(e,r){Se(e,"rm"),this.assertWritable(`rm '${e}'`);let n=we(e);if(!await this.existsInOverlay(n)){if(r?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}try{if((await this.stat(n)).isDirectory){let o=await this.readdir(n);if(o.length>0){if(!r?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let a of o){let l=n==="/"?`/${a}`:`${n}/${a}`;await this.rm(l,r)}}}}catch(i){if(i instanceof Error&&(i.message.includes("ENOTEMPTY")||i.message.includes("EISDIR")))throw i}this.memory.delete(n),this.existsOnRealFs(n)&&this.deleted.add(n)}existsOnRealFs(e){let r=this.toRealPath(e),n=this.resolveRealPathParent_(r);if(!n)return!1;try{return Jt.lstatSync(n),!0}catch{return!1}}async cp(e,r,n){Se(e,"cp"),Se(r,"cp"),this.assertWritable(`cp '${r}'`);let s=we(e),i=we(r);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, cp '${e}'`);let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);await this.writeFile(i,l)}else if(a.isDirectory){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(s);for(let c of l){let u=s==="/"?`/${c}`:`${s}/${c}`,f=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(u,f,n)}}}async mv(e,r){this.assertWritable(`mv '${r}'`),await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,r){return Go(e,r)}getAllPaths(){let e=new Set(this.memory.keys());for(let r of this.deleted)e.delete(r);return this.scanRealFs("/",e),Array.from(e)}scanRealFs(e,r){if(this.deleted.has(e))return;let n=this.resolveRealPath_(this.toRealPath(e));if(n)try{let s=Jt.readdirSync(n);for(let i of s){let o=e==="/"?`/${i}`:`${e}/${i}`;if(this.deleted.has(o))continue;r.add(o);let a=pn.join(n,i);Jt.lstatSync(a).isDirectory()&&this.scanRealFs(o,r)}}catch{}}async chmod(e,r){Se(e,"chmod"),this.assertWritable(`chmod '${e}'`);let n=we(e);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);let i=this.memory.get(n);if(i){i.mode=r;return}let o=await this.stat(n);if(o.isFile){let a=await this.readFileBuffer(n);this.memory.set(n,{type:"file",content:a,mode:r,mtime:new Date})}else o.isDirectory&&this.memory.set(n,{type:"directory",mode:r,mtime:new Date})}async symlink(e,r){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${r}'`);Se(r,"symlink"),this.assertWritable(`symlink '${r}'`);let n=we(r);if(await this.existsInOverlay(n))throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.ensureParentDirs(n),this.memory.set(n,{type:"symlink",target:e,mode:511,mtime:new Date}),this.deleted.delete(n)}async link(e,r){Se(e,"link"),Se(r,"link"),this.assertWritable(`link '${r}'`);let n=we(e),s=we(r);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, link '${e}'`);let o=await this.stat(n);if(!o.isFile)throw new Error(`EPERM: operation not permitted, link '${e}'`);if(await this.existsInOverlay(s))throw new Error(`EEXIST: file already exists, link '${r}'`);let l=await this.readFileBuffer(n);this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:o.mode,mtime:new Date}),this.deleted.delete(s)}async readlink(e){Se(e,"readlink");let r=we(e);if(this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);let n=this.memory.get(r);if(n){if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}let s=this.resolveRealPathParent_(this.toRealPath(r));if(!s)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);try{let i=await Jt.promises.readlink(s);if(!pn.isAbsolute(i)){let o=pn.resolve(pn.dirname(s),i),a;try{a=Jt.realpathSync(o)}catch{a=o}if(!gi(a,this.canonicalRoot))return pn.basename(i)}return this.realTargetToVirtual(r,i)}catch(i){if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(i,e,"readlink")}}async realpath(e){Se(e,"realpath");let r=we(e),n=new Set,s=async a=>{let l=a==="/"?[]:a.slice(1).split("/"),c="";for(let u of l){if(c=`${c}/${u}`,n.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let f=this.memory.get(c),h=0,d=40;for(;f&&f.type==="symlink"&&h<d;){if(n.add(c),c=this.resolveSymlink(c,f.target),h++,n.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);f=this.memory.get(c)}if(h>=d)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(!f){let p=this.toRealPath(c),m=this.resolveRealPath_(p);if(m)try{if((await Jt.promises.lstat(m)).isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let y=await Jt.promises.readlink(m),x=this.realTargetToVirtual(c,y);return n.add(c),c=this.resolveSymlink(c,x),s(c)}}catch(g){if(g.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(g,e,"realpath")}else if(!this.allowSymlinks){let g=this.resolveRealPathParent_(p);if(g)try{if((await Jt.promises.lstat(g)).isSymbolicLink())throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}catch(y){if(y.message?.includes("ENOENT")||y.message?.includes("ELOOP"))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(y,e,"realpath")}}}}return c||"/"},i=await s(r);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return i}async utimes(e,r,n){Se(e,"utimes"),this.assertWritable(`utimes '${e}'`);let s=we(e);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);let o=this.memory.get(s);if(o){o.mtime=n;return}let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);this.memory.set(s,{type:"file",content:l,mode:a.mode,mtime:n})}else a.isDirectory&&this.memory.set(s,{type:"directory",mode:a.mode,mtime:n})}};var Ce=Mr(require("node:fs"),1),jt=Mr(require("node:path"),1);Re();Sc();var Vce=["EACCES","escaping sandbox","EFBIG"],nh=class{root;canonicalRoot;maxFileReadSize;allowSymlinks;constructor(e){this.root=jt.resolve(e.root),this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,e1(this.root,"ReadWriteFs"),this.canonicalRoot=Ce.realpathSync(this.root)}resolveAndValidate(e,r){let n=this.allowSymlinks?al(e,this.canonicalRoot):Jm(e,this.root,this.canonicalRoot);if(n===null)throw new Error(`EACCES: permission denied, '${r}' resolves outside sandbox`);return n}validateParent(e,r){let n=jt.dirname(e),s=this.resolveAndValidate(n,r);return jt.join(s,jt.basename(e))}toRealPath(e){let r=we(e),n=jt.join(this.root,r);return jt.resolve(n)}async readFile(e,r){let n=await this.readFileBuffer(e),s=zs(r);return xs(n,s)}async readFileBytes(e){let r=await this.readFileBuffer(e);return xs(r,"binary")}async readFileBuffer(e){Se(e,"open");let r=this.toRealPath(e),n=this.resolveAndValidate(r,e);try{let s=this.allowSymlinks?Ce.constants.O_RDONLY:Ce.constants.O_RDONLY|Ce.constants.O_NOFOLLOW,i=await Ce.promises.open(n,s);try{if(this.maxFileReadSize>0){let a=await i.stat();if(a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${a.size} bytes, max ${this.maxFileReadSize})`)}let o=await i.readFile();return new Uint8Array(o)}finally{await i.close()}}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(i.code==="EISDIR")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(i.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(s,e,"open")}}async writeFile(e,r,n){Se(e,"write");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=zs(n),a=ao(r,o),l=jt.dirname(i);try{await Ce.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:Ce.constants.O_NOFOLLOW,u=Ce.constants.O_WRONLY|Ce.constants.O_CREAT|Ce.constants.O_TRUNC|c,f=await Ce.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(c,e,"write")}}async appendFile(e,r,n){Se(e,"append");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=zs(n),a=ao(r,o),l=jt.dirname(i);try{await Ce.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:Ce.constants.O_NOFOLLOW,u=Ce.constants.O_WRONLY|Ce.constants.O_CREAT|Ce.constants.O_APPEND|c,f=await Ce.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(c,e,"append")}}async exists(e){if(e.includes("\0"))return!1;let r=this.toRealPath(e);try{let n=this.resolveAndValidate(r,e);return await Ce.promises.access(n),!0}catch{return!1}}async stat(e){Se(e,"stat");let r=this.toRealPath(e),n=this.resolveAndValidate(r,e);try{let s=await Ce.promises.lstat(n);if(!this.allowSymlinks&&s.isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, stat '${e}'`);this.sanitizeError(s,e,"stat")}}async lstat(e){Se(e,"lstat");let r=this.toRealPath(e),n=this.validateParent(r,e);try{let s=await Ce.promises.lstat(n);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);this.sanitizeError(s,e,"lstat")}}async mkdir(e,r){Se(e,"mkdir");let n=this.toRealPath(e),s=this.resolveAndValidate(n,e);try{await Ce.promises.mkdir(s,{recursive:r?.recursive})}catch(i){let o=i;if(o.code==="EEXIST")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.sanitizeError(i,e,"mkdir")}}async readdir(e){return(await this.readdirWithFileTypes(e)).map(n=>n.name)}async readdirWithFileTypes(e){Se(e,"scandir");let r=this.toRealPath(e),n=this.resolveAndValidate(r,e);try{if(!this.allowSymlinks&&(await Ce.promises.lstat(n)).isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return(await Ce.promises.readdir(n,{withFileTypes:!0})).map(i=>({name:i.name,isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink()})).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(i.code==="ENOTDIR")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);this.sanitizeError(s,e,"scandir")}}async rm(e,r){Se(e,"rm");let n=this.toRealPath(e),s=this.resolveAndValidate(n,e);try{await Ce.promises.rm(s,{recursive:r?.recursive??!1,force:r?.force??!1})}catch(i){let o=i;if(o.code==="ENOENT"&&!r?.force)throw new Error(`ENOENT: no such file or directory, rm '${e}'`);if(o.code==="ENOTEMPTY")throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);this.sanitizeError(i,e,"rm")}}async cp(e,r,n){Se(e,"cp"),Se(r,"cp");let s=this.toRealPath(e),i=this.toRealPath(r),o=this.resolveAndValidate(s,e),a=this.resolveAndValidate(i,r);try{await Ce.promises.cp(o,a,{recursive:n?.recursive??!1,filter:async l=>{try{if(Ce.lstatSync(l).isSymbolicLink()){let u=await Ce.promises.realpath(l).catch(()=>null);return u===null?!1:gi(u,this.canonicalRoot)}return!0}catch(c){return c.code==="ENOENT"}}})}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(c.code==="EISDIR")throw new Error(`EISDIR: is a directory, cp '${e}'`);this.sanitizeError(l,e,"cp")}}async mv(e,r){Se(e,"mv"),Se(r,"mv");let n=this.toRealPath(e),s=this.toRealPath(r),i=this.validateParent(n,e),o=this.validateParent(s,r);try{if((await Ce.promises.lstat(i)).isSymbolicLink()){let c=await Ce.promises.readlink(i),u=jt.resolve(jt.dirname(o),c),f=await Ce.promises.realpath(u).catch(()=>u);if(!gi(f,this.canonicalRoot))throw new Error(`EACCES: permission denied, mv '${e}' -> '${r}' would create symlink escaping sandbox`)}}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.message?.includes("EACCES")||c.message?.includes("escaping sandbox"))throw l}let a=jt.dirname(o);try{await Ce.promises.mkdir(a,{recursive:!0})}catch(l){this.sanitizeError(l,r,"mv")}try{await Ce.promises.rename(i,o)}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.code==="EXDEV"){await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0});return}this.sanitizeError(l,e,"mv")}try{if(Ce.lstatSync(o).isDirectory()&&this.findEscapingSymlinks(o).length>0)throw await Ce.promises.rename(o,i),new Error(`EACCES: permission denied, mv '${e}' -> '${r}' would create symlinks escaping sandbox`)}catch(l){if(l.message?.includes("EACCES")||l.message?.includes("escaping sandbox"))throw l}}resolvePath(e,r){return Go(e,r)}getAllPaths(){let e=[];return this.scanDir("/",e),e}sanitizeError(e,r,n){t1(e,r,n,Vce)}findEscapingSymlinks(e){let r=[];try{let n=Ce.readdirSync(e);for(let s of n){let i=jt.join(e,s);try{let o=Ce.lstatSync(i);if(o.isSymbolicLink()){let a=Ce.readlinkSync(i),l=jt.resolve(e,a),c;try{c=Ce.realpathSync(l)}catch{c=l}gi(c,this.canonicalRoot)||r.push(i)}else o.isDirectory()&&r.push(...this.findEscapingSymlinks(i))}catch{}}}catch{}return r}scanDir(e,r){let n=this.toRealPath(e),s;try{s=this.resolveAndValidate(n,e)}catch{return}try{let i=Ce.readdirSync(s);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;r.push(a);let l=jt.join(s,o);Ce.lstatSync(l).isDirectory()&&this.scanDir(a,r)}}catch{}}async chmod(e,r){Se(e,"chmod");let n=this.toRealPath(e),s=this.resolveAndValidate(n,e);try{let i=this.allowSymlinks?Ce.constants.O_RDONLY:Ce.constants.O_RDONLY|Ce.constants.O_NOFOLLOW,o=await Ce.promises.open(s,i);try{await o.chmod(r)}finally{await o.close()}}catch(i){let o=i;if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);if(o.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(i,e,"chmod")}}async symlink(e,r){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${r}'`);Se(r,"symlink");let n=this.toRealPath(r),s=this.validateParent(n,r),i=we(r),o=we(jt.dirname(i)),a=e.startsWith("/")?we(e):we(o==="/"?`/${e}`:`${o}/${e}`),l=jt.join(this.canonicalRoot,a),c=jt.dirname(s),u=e.startsWith("/")?l:jt.relative(c,l)||".";try{await Ce.promises.symlink(u,s)}catch(f){if(f.code==="EEXIST")throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.sanitizeError(f,r,"symlink")}}async link(e,r){Se(e,"link"),Se(r,"link");let n=this.toRealPath(e),s=this.toRealPath(r),i=this.resolveAndValidate(n,e),o=this.resolveAndValidate(s,r);try{await Ce.promises.link(i,o)}catch(a){let l=a;if(l.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(l.code==="EEXIST")throw new Error(`EEXIST: file already exists, link '${r}'`);if(l.code==="EPERM")throw new Error(`EPERM: operation not permitted, link '${e}'`);this.sanitizeError(a,e,"link")}}async readlink(e){Se(e,"readlink");let r=this.toRealPath(e),n=this.validateParent(r,e);try{let s=await Ce.promises.readlink(n),i=we(e),o=jt.dirname(i),a=jt.isAbsolute(s)?s:jt.resolve(jt.dirname(n),s),l=await Ce.promises.realpath(a).catch(()=>a);if(gi(l,this.canonicalRoot)){let c=l.slice(this.canonicalRoot.length)||"/";return o==="/"?c.startsWith("/")?c.slice(1)||".":c:jt.relative(o,c)}return jt.basename(s)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(s,e,"readlink")}}async realpath(e){Se(e,"realpath");let r=this.toRealPath(e);try{this.resolveAndValidate(r,e)}catch{throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}let n;try{n=await Ce.promises.realpath(r)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);if(i.code==="ELOOP")throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);this.sanitizeError(s,e,"realpath")}if(gi(n,this.canonicalRoot))return n.slice(this.canonicalRoot.length)||"/";throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}async utimes(e,r,n){Se(e,"utimes");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e);try{let o=this.allowSymlinks?Ce.constants.O_RDONLY:Ce.constants.O_RDONLY|Ce.constants.O_NOFOLLOW,a=await Ce.promises.open(i,o);try{await a.utimes(r,n)}finally{await a.close()}}catch(o){let a=o;if(a.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);if(a.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(o,e,"utimes")}}};mr();Yi();bi();var cl=class{cmdId;cwd;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;signal;timeoutMs;abortController=new AbortController;timeoutId;externalAbortListener;resultPromise;constructor(e,r,n,s,i=!1,o,a){this.cmdId=crypto.randomUUID(),this.cwd=n,this.startedAt=new Date,this.bashEnv=e,this.cmdLine=r,this.env=s,this.explicitCwd=i,this.signal=o,this.timeoutMs=a,this.setupCancellation(),this.resultPromise=this.execute()}setupCancellation(){if(this.signal&&(this.signal.aborted?this.abortController.abort(this.signal.reason):(this.externalAbortListener=()=>{this.abortController.abort(this.signal?.reason)},this.signal.addEventListener("abort",this.externalAbortListener,{once:!0}))),this.timeoutMs!==void 0){let e=Math.max(0,this.timeoutMs);this.timeoutId=Wr(()=>{this.abortController.abort(new Error(`sandbox command timeout after ${e}ms`))},e)}}cleanupCancellation(){this.timeoutId!==void 0&&(fr(this.timeoutId),this.timeoutId=void 0),this.signal&&this.externalAbortListener&&(this.signal.removeEventListener("abort",this.externalAbortListener),this.externalAbortListener=void 0)}async execute(){let e={cwd:this.explicitCwd?this.cwd:void 0,env:this.env,signal:this.abortController.signal};try{let r=await this.bashEnv.exec(this.cmdLine,e);return this.exitCode=r.exitCode,r}finally{this.cleanupCancellation()}}async*logs(){let e=await this.resultPromise;e.stdout&&(yield{type:"stdout",data:e.stdout,timestamp:new Date}),e.stderr&&(yield{type:"stderr",data:e.stderr,timestamp:new Date})}async wait(){return await this.resultPromise,this}async output(){let e=await this.resultPromise;return e.stdout+e.stderr}async stdout(){return(await this.resultPromise).stdout}async stderr(){return(await this.resultPromise).stderr}async kill(){this.abortController.abort(new Error("command killed"))}};var sh=class t{bashEnv;timeoutMs;constructor(e,r){this.bashEnv=e,this.timeoutMs=r}static async create(e){let r=e?.fs;if(e?.overlayRoot){if(e?.fs)throw new Error("Cannot specify both 'fs' and 'overlayRoot' options");r=new ll({root:e.overlayRoot})}let n=new Hc({env:e?.env,cwd:e?.cwd,fs:r,maxCallDepth:e?.maxCallDepth,maxCommandCount:e?.maxCommandCount,maxLoopIterations:e?.maxLoopIterations,network:e?.network,defenseInDepth:e?.defenseInDepth});return new t(n,e?.timeoutMs)}async runCommand(e,r,n){let s,i,o,a,l=!1,c,u;if(typeof e=="object"){let m=e,g=[m.cmd,...m.args??[]];s=Vr(g),i=m.cwd,o=m.env,a=m.signal,l=m.detached??!1,c=m.stdout,u=m.stderr}else if(Array.isArray(r)){let m=n;s=Vr([e,...r]),a=m?.signal}else{s=e;let m=r;i=m?.cwd,o=m?.env}let f=i??this.bashEnv.getCwd(),h=i!==void 0,d=new cl(this.bashEnv,s,f,o,h,a,this.timeoutMs);if(l)return d;let p=await d.wait();if(c){let m=await d.stdout();m&&c.write(m)}if(u){let m=await d.stderr();m&&u.write(m)}return p}async writeFiles(e){let r=this.bashEnv.getCwd();for(let[n,s]of Object.entries(e)){let i;typeof s=="string"?i=s:s.encoding==="base64"?i=Buffer.from(s.content,"base64").toString("utf-8"):i=s.content;let o=this.bashEnv.fs.resolvePath(r,n),a=o.substring(0,o.lastIndexOf("/"))||"/";a!=="/"&&await this.bashEnv.fs.mkdir(a,{recursive:!0}),await this.bashEnv.writeFile(o,i)}}async readFile(e,r){let n=await this.bashEnv.readFile(e);return r==="base64"?Buffer.from(n).toString("base64"):n}async mkDir(e,r){let n=this.bashEnv.fs.resolvePath(this.bashEnv.getCwd(),e);await this.bashEnv.fs.mkdir(n,{recursive:r?.recursive??!1})}async stop(){}async extendTimeout(e){}get domain(){}get bashEnvInstance(){return this.bashEnv}};$r();var ih=class{violations=[];violationsByType=new Map;options;constructor(e={}){this.options={maxViolationsPerType:e.maxViolationsPerType??100,maxViolationsTotal:e.maxViolationsTotal??1e3,includeStackTraces:e.includeStackTraces??!0,onViolation:e.onViolation??(()=>{}),logToConsole:e.logToConsole??!1}}record(e){let r=this.options.includeStackTraces?e:{...e,stack:void 0};this.violations.unshift(r),this.violations.length>this.options.maxViolationsTotal&&(this.violations.length=this.options.maxViolationsTotal);let n=this.violationsByType.get(e.type);n||(n=[],this.violationsByType.set(e.type,n)),n.length<this.options.maxViolationsPerType&&n.push(r),this.options.logToConsole&&console.warn(`[SecurityViolation] ${e.type}: ${e.message}`,e.path),this.options.onViolation(r)}getViolations(){return[...this.violations]}getViolationsByType(e){return[...this.violationsByType.get(e)??[]]}getSummary(){let e=[];for(let[r,n]of this.violationsByType){if(n.length===0)continue;let s=new Set,i=Number.POSITIVE_INFINITY,o=0;for(let a of n)s.add(a.path),i=Math.min(i,a.timestamp),o=Math.max(o,a.timestamp);e.push({type:r,count:n.length,firstSeen:i,lastSeen:o,paths:Array.from(s)})}return e.sort((r,n)=>n.count-r.count),e}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return e=>this.record(e)}};function tS(){return t=>{console.warn("[DefenseInDepth] Security violation detected:",`
2192
+ `)}var zce=new TextDecoder("utf-8",{fatal:!0});function eB(t){if(!t)return t;let e=!1,r=!1;for(let o=0;o<t.length;o++){let a=t.charCodeAt(o);a>255?r=!0:a>127&&(e=!0)}if(!e)return t;let n=[],s=new TextEncoder;for(let o=0;o<t.length;o++){let a=t.charCodeAt(o);if(a>255){let l=s.encode(t[o]);for(let c=0;c<l.length;c++)n.push(l[c])}else n.push(a)}let i=new Uint8Array(n);try{return zce.decode(i)}catch{return t}}function Hce(t,e){if(t!==void 0)return e==="bytes"?t:Ts(t)}Re();Re();var rh=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new $i,e?.mounts)for(let{mountPoint:r,filesystem:n}of e.mounts)this.mount(r,n)}mount(e,r){this.validateMountPath(e);let n=we(e);this.validateMount(n),this.mounts.set(n,{mountPoint:n,filesystem:r})}unmount(e){let r=we(e);if(!this.mounts.has(r))throw new Error(`No filesystem mounted at '${e}'`);this.mounts.delete(r)}getMounts(){return Array.from(this.mounts.values()).map(e=>({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let r=we(e);return this.mounts.has(r)}validateMountPath(e){let r=e.split("/");for(let n of r)if(n==="."||n==="..")throw new Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e==="/")throw new Error("Cannot mount at root '/'");for(let r of this.mounts.keys())if(r!==e){if(e.startsWith(`${r}/`))throw new Error(`Cannot mount at '${e}': inside existing mount '${r}'`);if(r.startsWith(`${e}/`))throw new Error(`Cannot mount at '${e}': would contain existing mount '${r}'`)}}routePath(e){Se(e,"access");let r=we(e),n=null,s=0;for(let i of this.mounts.values()){let o=i.mountPoint;if(r===o)return{fs:i.filesystem,relativePath:"/"};r.startsWith(`${o}/`)&&o.length>s&&(n=i,s=o.length)}if(n){let i=r.slice(s);return{fs:n.filesystem,relativePath:i||"/"}}return{fs:this.baseFs,relativePath:r}}getChildMountPoints(e){let r=we(e),n=r==="/"?"/":`${r}/`,s=[];for(let i of this.mounts.keys())if(i.startsWith(n)){let a=i.slice(n.length).split("/")[0];a&&!s.includes(a)&&s.push(a)}return s}async readFile(e,r){let{fs:n,relativePath:s}=this.routePath(e);return n.readFile(s,r)}async readFileBytes(e){let{fs:r,relativePath:n}=this.routePath(e);return wi(r,n)}async readFileBuffer(e){let{fs:r,relativePath:n}=this.routePath(e);return r.readFileBuffer(n)}async writeFile(e,r,n){let{fs:s,relativePath:i}=this.routePath(e);return s.writeFile(i,r,n)}async appendFile(e,r,n){let{fs:s,relativePath:i}=this.routePath(e);return s.appendFile(i,r,n)}async exists(e){let r=we(e);if(this.mounts.has(r)||this.getChildMountPoints(r).length>0)return!0;let{fs:s,relativePath:i}=this.routePath(e);return s.exists(i)}async stat(e){let r=we(e),n=this.mounts.get(r);if(n)try{return await n.filesystem.stat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(r).length>0)try{return await this.baseFs.stat(r)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.stat(o)}async lstat(e){let r=we(e),n=this.mounts.get(r);if(n)try{return await n.filesystem.lstat("/")}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(r).length>0)try{return await this.baseFs.lstat(r)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:i,relativePath:o}=this.routePath(e);return i.lstat(o)}async mkdir(e,r){let n=we(e);if(this.mounts.has(n)){if(r?.recursive)return;throw new Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(n).length>0&&r?.recursive)return;let{fs:i,relativePath:o}=this.routePath(e);return i.mkdir(o,r)}async readdir(e){let r=we(e),n=new Set,s=null,{fs:i,relativePath:o}=this.routePath(e);try{let l=await i.readdir(o);for(let c of l)n.add(c)}catch(l){let c=l.code,u=l.message||"";if(c!=="ENOENT"&&!u.includes("ENOENT"))throw l;s=l}let a=this.getChildMountPoints(r);for(let l of a)n.add(l);if(n.size===0&&s&&!this.mounts.has(r))throw s;return Array.from(n).sort()}async rm(e,r){let n=we(e);if(this.mounts.has(n))throw new Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(n).length>0)throw new Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:i,relativePath:o}=this.routePath(e);return i.rm(o,r)}async cp(e,r,n){let s=this.routePath(e),i=this.routePath(r);return s.fs===i.fs?s.fs.cp(s.relativePath,i.relativePath,n):this.crossMountCopy(e,r,n)}async mv(e,r){let n=we(e);if(this.mounts.has(n))throw new Error(`EBUSY: mount point, cannot move '${e}'`);let s=this.routePath(e),i=this.routePath(r);if(s.fs===i.fs)return s.fs.mv(s.relativePath,i.relativePath);await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,r){return Go(e,r)}getAllPaths(){let e=new Set;for(let r of this.baseFs.getAllPaths())e.add(r);for(let r of this.mounts.keys()){let n=r.split("/").filter(Boolean),s="";for(let o of n)s=`${s}/${o}`,e.add(s);let i=this.mounts.get(r);if(i)for(let o of i.filesystem.getAllPaths())o==="/"?e.add(r):e.add(`${r}${o}`)}return Array.from(e).sort()}async chmod(e,r){let n=we(e),s=this.mounts.get(n);if(s)return s.filesystem.chmod("/",r);let{fs:i,relativePath:o}=this.routePath(e);return i.chmod(o,r)}async symlink(e,r){let{fs:n,relativePath:s}=this.routePath(r);return n.symlink(e,s)}async link(e,r){let n=this.routePath(e),s=this.routePath(r);if(n.fs!==s.fs)throw new Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${r}'`);return n.fs.link(n.relativePath,s.relativePath)}async readlink(e){let{fs:r,relativePath:n}=this.routePath(e);return r.readlink(n)}async realpath(e){let r=we(e);if(this.mounts.get(r))return r;let{fs:s,relativePath:i}=this.routePath(e),o=await s.realpath(i);for(let[a,l]of this.mounts)if(r===a||r.startsWith(`${a}/`))return o==="/"?a:`${a}${o}`;return o}async crossMountCopy(e,r,n){let s=await this.lstat(e);if(s.isFile){let i=await this.readFileBuffer(e);await this.writeFile(r,i),await this.chmod(r,s.mode)}else if(s.isDirectory){if(!n?.recursive)throw new Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(r,{recursive:!0});let i=await this.readdir(e);for(let o of i){let a=Ko(e,o),l=Ko(r,o);await this.crossMountCopy(a,l,n)}}else if(s.isSymbolicLink){let i=await this.readlink(e);await this.symlink(i,r)}}async utimes(e,r,n){let{fs:s,relativePath:i}=this.routePath(e);return s.utimes(i,r,n)}};var Jt=Mr(require("node:fs"),1),pn=Mr(require("node:path"),1);Re();Sc();var Vs=Mr(require("node:fs"),1),$n=Mr(require("node:path"),1);rn();function gi(t,e){if(t===e)return!0;let r=t[e.length];return(r==="/"||r==="\\")&&t.startsWith(e)}function al(t,e){try{let r=Vs.realpathSync(t);return gi(r,e)?r:null}catch(r){if(r.code==="ENOENT"){let n=$n.dirname(t);if(n===t)return null;let s=al(n,e);if(s===null)return null;try{if(Vs.lstatSync(t).isSymbolicLink()){let o=Vs.readlinkSync(t),a=$n.isAbsolute(o)?o:$n.resolve($n.dirname(t),o);if(al(a,e)===null)return null}}catch{}return $n.join(s,$n.basename(t))}return null}}function Jm(t,e,r){let n=al(t,r);if(n===null)return null;let s=$n.resolve(t),i=s.slice(e.length),o=n.slice(r.length);if(i!==o)return null;try{if(Vs.lstatSync(s).isSymbolicLink())return null}catch{}return n}function e1(t,e){if(!Vs.existsSync(t))throw new Error(`${e} root does not exist`);if(!Vs.statSync(t).isDirectory())throw new Error(`${e} root is not a directory`)}function tB(t,e){if(!$n.isAbsolute(t))return{withinRoot:!0,relativePath:t};let r;try{r=Vs.realpathSync(t)}catch{r=$n.resolve(t)}return gi(r,e)?{withinRoot:!0,relativePath:r.slice(e.length).replace(/\\/g,"/")||"/"}:{withinRoot:!1,safeName:$n.basename(t)}}function t1(t,e,r,n){let s=t;if(s.path===void 0){for(let o of n)if(s.message?.includes(o))throw t}let i=s.code||"EIO";throw new Error(`${i}: ${r} '${e}'`)}var Wce=["ELOOP","EFBIG","EPERM"],jce="/home/user/project",ll=class{root;canonicalRoot;mountPoint;readOnly;maxFileReadSize;allowSymlinks;memory=new Map;deleted=new Set;constructor(e){this.root=pn.resolve(e.root);let r=e.mountPoint??jce;if(this.mountPoint=r==="/"?"/":r.replace(/\/+$/,""),!this.mountPoint.startsWith("/"))throw new Error(`Mount point must be an absolute path: ${r}`);this.readOnly=e.readOnly??!1,this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,e1(this.root,"OverlayFs"),this.canonicalRoot=Jt.realpathSync(this.root),this.createMountPointDirs()}assertWritable(e){if(this.readOnly)throw new Error(`EROFS: read-only file system, ${e}`)}createMountPointDirs(){let e=this.mountPoint.split("/").filter(Boolean),r="";for(let n of e)r+=`/${n}`,this.memory.has(r)||this.memory.set(r,{type:"directory",mode:493,mtime:new Date});this.memory.has("/")||this.memory.set("/",{type:"directory",mode:493,mtime:new Date})}getMountPoint(){return this.mountPoint}mkdirSync(e,r){let s=we(e).split("/").filter(Boolean),i="";for(let o of s)i+=`/${o}`,this.memory.has(i)||this.memory.set(i,{type:"directory",mode:493,mtime:new Date})}writeFileSync(e,r){let n=we(e),s=this.getDirname(n);s!=="/"&&this.mkdirSync(s);let i=r instanceof Uint8Array?r:new TextEncoder().encode(r);this.memory.set(n,{type:"file",content:i,mode:420,mtime:new Date})}getDirname(e){let r=e.lastIndexOf("/");return r===0?"/":e.slice(0,r)}getRelativeToMount(e){return this.mountPoint==="/"?e:e===this.mountPoint?"/":e.startsWith(`${this.mountPoint}/`)?e.slice(this.mountPoint.length):null}toRealPath(e){let r=we(e),n=this.getRelativeToMount(r);if(n===null)return null;let s=pn.join(this.root,n),i=pn.resolve(s);return gi(i,this.root)?i:null}resolveRealPath_(e){return e?this.allowSymlinks?al(e,this.canonicalRoot):Jm(e,this.root,this.canonicalRoot):null}resolveRealPathParent_(e){if(!e)return null;let r=pn.dirname(e),n=this.resolveRealPath_(r);return n===null?null:pn.join(n,pn.basename(e))}sanitizeError(e,r,n){t1(e,r,n,Wce)}ensureParentDirs(e){let r=Za(e);r!=="/"&&(this.memory.has(r)||(this.ensureParentDirs(r),this.memory.set(r,{type:"directory",mode:493,mtime:new Date})),this.deleted.delete(r))}async existsInOverlay(e){let r=we(e);if(this.deleted.has(r))return!1;if(this.memory.has(r))return!0;let n=this.resolveRealPathParent_(this.toRealPath(r));if(!n)return!1;try{return await Jt.promises.lstat(n),!0}catch{return!1}}async readFile(e,r){let n=await this.readFileBuffer(e),s=zs(r);return xs(n,s)}async readFileBytes(e){let r=await this.readFileBuffer(e);return xs(r,"binary")}async readFileBuffer(e,r=new Set){Se(e,"open");let n=we(e);if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);if(r.add(n),this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, open '${e}'`);let s=this.memory.get(n);if(s){if(s.type==="symlink"){let o=this.resolveSymlink(n,s.target);return this.readFileBuffer(o,r)}if(s.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return s.content}let i=this.resolveRealPath_(this.toRealPath(n));if(!i)throw new Error(`ENOENT: no such file or directory, open '${e}'`);try{let o=await Jt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let c=await Jt.promises.readlink(i),u=this.realTargetToVirtual(n,c),f=this.resolveSymlink(n,u);return this.readFileBuffer(f,r)}if(o.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(this.maxFileReadSize>0&&o.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${o.size} bytes, max ${this.maxFileReadSize})`);let a=this.allowSymlinks?Jt.constants.O_RDONLY:Jt.constants.O_RDONLY|Jt.constants.O_NOFOLLOW,l=await Jt.promises.open(i,a);try{let c=await l.readFile();return new Uint8Array(c)}finally{await l.close()}}catch(o){let a=o.code;if(a==="ENOENT")throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(a==="ELOOP")throw new Error(`ENOENT: no such file or directory, open '${e}'`);this.sanitizeError(o,e,"open")}}async writeFile(e,r,n){Se(e,"write"),this.assertWritable(`write '${e}'`);let s=we(e);this.ensureParentDirs(s);let i=zs(n),o=ao(r,i);this.memory.set(s,{type:"file",content:o,mode:420,mtime:new Date}),this.deleted.delete(s)}async appendFile(e,r,n){Se(e,"append"),this.assertWritable(`append '${e}'`);let s=we(e),i=zs(n),o=ao(r,i),a;try{a=await this.readFileBuffer(s)}catch{a=new Uint8Array(0)}let l=new Uint8Array(a.length+o.length);l.set(a),l.set(o,a.length),this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:420,mtime:new Date}),this.deleted.delete(s)}async exists(e){return e.includes("\0")?!1:this.existsInOverlay(e)}async stat(e,r=new Set){Se(e,"stat");let n=we(e);if(r.has(n))throw new Error(`ELOOP: too many levels of symbolic links, stat '${e}'`);if(r.add(n),this.deleted.has(n))throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=this.memory.get(n);if(s){if(s.type==="symlink"){let a=this.resolveSymlink(n,s.target);return this.stat(a,r)}let o=0;return s.type==="file"&&(o=s.content.length),{isFile:s.type==="file",isDirectory:s.type==="directory",isSymbolicLink:!1,mode:s.mode,size:o,mtime:s.mtime}}let i=this.resolveRealPath_(this.toRealPath(n));if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);try{let o=await Jt.promises.lstat(i);if(o.isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let a=await Jt.promises.readlink(i),l=this.realTargetToVirtual(n,a),c=this.resolveSymlink(n,l);return this.stat(c,r)}return{isFile:o.isFile(),isDirectory:o.isDirectory(),isSymbolicLink:!1,mode:o.mode,size:o.size,mtime:o.mtime}}catch(o){if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, stat '${e}'`);this.sanitizeError(o,e,"stat")}}async lstat(e){Se(e,"lstat");let r=we(e);if(this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let n=this.memory.get(r);if(n){if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime};let i=0;return n.type==="file"&&(i=n.content.length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:i,mtime:n.mtime}}let s=this.resolveRealPathParent_(this.toRealPath(r));if(!s)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);try{let i=await Jt.promises.lstat(s);return{isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink(),mode:i.mode,size:i.size,mtime:i.mtime}}catch(i){if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);this.sanitizeError(i,e,"lstat")}}resolveSymlink(e,r){return Ac(e,r)}realTargetToVirtual(e,r){let n=tB(r,this.canonicalRoot);if(n.withinRoot){if(!pn.isAbsolute(r))return r;let s=n.relativePath;return this.mountPoint==="/"?s:`${this.mountPoint}${s}`}return n.safeName}async mkdir(e,r){Se(e,"mkdir"),this.assertWritable(`mkdir '${e}'`);let n=we(e);if(await this.existsInOverlay(n)){if(!r?.recursive)throw new Error(`EEXIST: file already exists, mkdir '${e}'`);return}let i=Za(n);if(i!=="/"&&!await this.existsInOverlay(i))if(r?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.memory.set(n,{type:"directory",mode:493,mtime:new Date}),this.deleted.delete(n)}async readdirCore(e,r){if(this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let n=new Map,s=new Set,i=r==="/"?"/":`${r}/`;for(let a of this.deleted)if(a.startsWith(i)){let l=a.slice(i.length),c=l.split("/")[0];c&&!l.includes("/",c.length)&&s.add(c)}for(let[a,l]of this.memory)if(a!==r&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!s.has(u)&&!c.includes("/",1)&&n.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}let o=this.resolveRealPath_(this.toRealPath(r));if(o)try{if(!this.allowSymlinks&&(await Jt.promises.lstat(o)).isSymbolicLink()){if(!this.memory.has(r))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);return n}let a=await Jt.promises.readdir(o,{withFileTypes:!0});for(let l of a)!s.has(l.name)&&!n.has(l.name)&&n.set(l.name,{name:l.name,isFile:l.isFile(),isDirectory:l.isDirectory(),isSymbolicLink:l.isSymbolicLink()})}catch(a){if(a.code==="ENOENT"){if(!this.memory.has(r))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`)}else a.code!=="ENOTDIR"&&this.sanitizeError(a,e,"scandir")}return n}async resolveForReaddir(e,r=!1){let n=we(e),s=new Set,i=r,o=this.memory.get(n);for(;o&&o.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),i=!0,n=this.resolveSymlink(n,o.target),o=this.memory.get(n)}if(o)return{normalized:n,outsideOverlay:!1};if(this.getRelativeToMount(n)===null)return{normalized:n,outsideOverlay:!0};let l=this.resolveRealPath_(this.toRealPath(n));if(!l)return{normalized:n,outsideOverlay:!0};try{if((await Jt.promises.lstat(l)).isSymbolicLink()){if(!this.allowSymlinks)return{normalized:n,outsideOverlay:!0};let u=await Jt.promises.readlink(l),f=this.realTargetToVirtual(n,u),h=this.resolveSymlink(n,f);return this.resolveForReaddir(h,!0)}return{normalized:n,outsideOverlay:!1}}catch{return i?{normalized:n,outsideOverlay:!0}:{normalized:n,outsideOverlay:!1}}}async readdir(e){Se(e,"scandir");let{normalized:r,outsideOverlay:n}=await this.resolveForReaddir(e);if(n)return[];let s=await this.readdirCore(e,r);return Array.from(s.keys()).sort((i,o)=>i<o?-1:i>o?1:0)}async readdirWithFileTypes(e){Se(e,"scandir");let{normalized:r,outsideOverlay:n}=await this.resolveForReaddir(e);if(n)return[];let s=await this.readdirCore(e,r);return Array.from(s.values()).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}async rm(e,r){Se(e,"rm"),this.assertWritable(`rm '${e}'`);let n=we(e);if(!await this.existsInOverlay(n)){if(r?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}try{if((await this.stat(n)).isDirectory){let o=await this.readdir(n);if(o.length>0){if(!r?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let a of o){let l=n==="/"?`/${a}`:`${n}/${a}`;await this.rm(l,r)}}}}catch(i){if(i instanceof Error&&(i.message.includes("ENOTEMPTY")||i.message.includes("EISDIR")))throw i}this.memory.delete(n),this.existsOnRealFs(n)&&this.deleted.add(n)}existsOnRealFs(e){let r=this.toRealPath(e),n=this.resolveRealPathParent_(r);if(!n)return!1;try{return Jt.lstatSync(n),!0}catch{return!1}}async cp(e,r,n){Se(e,"cp"),Se(r,"cp"),this.assertWritable(`cp '${r}'`);let s=we(e),i=we(r);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, cp '${e}'`);let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);await this.writeFile(i,l)}else if(a.isDirectory){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let l=await this.readdir(s);for(let c of l){let u=s==="/"?`/${c}`:`${s}/${c}`,f=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(u,f,n)}}}async mv(e,r){this.assertWritable(`mv '${r}'`),await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,r){return Go(e,r)}getAllPaths(){let e=new Set(this.memory.keys());for(let r of this.deleted)e.delete(r);return this.scanRealFs("/",e),Array.from(e)}scanRealFs(e,r){if(this.deleted.has(e))return;let n=this.resolveRealPath_(this.toRealPath(e));if(n)try{let s=Jt.readdirSync(n);for(let i of s){let o=e==="/"?`/${i}`:`${e}/${i}`;if(this.deleted.has(o))continue;r.add(o);let a=pn.join(n,i);Jt.lstatSync(a).isDirectory()&&this.scanRealFs(o,r)}}catch{}}async chmod(e,r){Se(e,"chmod"),this.assertWritable(`chmod '${e}'`);let n=we(e);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);let i=this.memory.get(n);if(i){i.mode=r;return}let o=await this.stat(n);if(o.isFile){let a=await this.readFileBuffer(n);this.memory.set(n,{type:"file",content:a,mode:r,mtime:new Date})}else o.isDirectory&&this.memory.set(n,{type:"directory",mode:r,mtime:new Date})}async symlink(e,r){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${r}'`);Se(r,"symlink"),this.assertWritable(`symlink '${r}'`);let n=we(r);if(await this.existsInOverlay(n))throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.ensureParentDirs(n),this.memory.set(n,{type:"symlink",target:e,mode:511,mtime:new Date}),this.deleted.delete(n)}async link(e,r){Se(e,"link"),Se(r,"link"),this.assertWritable(`link '${r}'`);let n=we(e),s=we(r);if(!await this.existsInOverlay(n))throw new Error(`ENOENT: no such file or directory, link '${e}'`);let o=await this.stat(n);if(!o.isFile)throw new Error(`EPERM: operation not permitted, link '${e}'`);if(await this.existsInOverlay(s))throw new Error(`EEXIST: file already exists, link '${r}'`);let l=await this.readFileBuffer(n);this.ensureParentDirs(s),this.memory.set(s,{type:"file",content:l,mode:o.mode,mtime:new Date}),this.deleted.delete(s)}async readlink(e){Se(e,"readlink");let r=we(e);if(this.deleted.has(r))throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);let n=this.memory.get(r);if(n){if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}let s=this.resolveRealPathParent_(this.toRealPath(r));if(!s)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);try{let i=await Jt.promises.readlink(s);if(!pn.isAbsolute(i)){let o=pn.resolve(pn.dirname(s),i),a;try{a=Jt.realpathSync(o)}catch{a=o}if(!gi(a,this.canonicalRoot))return pn.basename(i)}return this.realTargetToVirtual(r,i)}catch(i){if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(i,e,"readlink")}}async realpath(e){Se(e,"realpath");let r=we(e),n=new Set,s=async a=>{let l=a==="/"?[]:a.slice(1).split("/"),c="";for(let u of l){if(c=`${c}/${u}`,n.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let f=this.memory.get(c),h=0,d=40;for(;f&&f.type==="symlink"&&h<d;){if(n.add(c),c=this.resolveSymlink(c,f.target),h++,n.has(c))throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(this.deleted.has(c))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);f=this.memory.get(c)}if(h>=d)throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);if(!f){let p=this.toRealPath(c),m=this.resolveRealPath_(p);if(m)try{if((await Jt.promises.lstat(m)).isSymbolicLink()){if(!this.allowSymlinks)throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);let y=await Jt.promises.readlink(m),x=this.realTargetToVirtual(c,y);return n.add(c),c=this.resolveSymlink(c,x),s(c)}}catch(g){if(g.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(g,e,"realpath")}else if(!this.allowSymlinks){let g=this.resolveRealPathParent_(p);if(g)try{if((await Jt.promises.lstat(g)).isSymbolicLink())throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}catch(y){if(y.message?.includes("ENOENT")||y.message?.includes("ELOOP"))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);this.sanitizeError(y,e,"realpath")}}}}return c||"/"},i=await s(r);if(!await this.existsInOverlay(i))throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);return i}async utimes(e,r,n){Se(e,"utimes"),this.assertWritable(`utimes '${e}'`);let s=we(e);if(!await this.existsInOverlay(s))throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);let o=this.memory.get(s);if(o){o.mtime=n;return}let a=await this.stat(s);if(a.isFile){let l=await this.readFileBuffer(s);this.memory.set(s,{type:"file",content:l,mode:a.mode,mtime:n})}else a.isDirectory&&this.memory.set(s,{type:"directory",mode:a.mode,mtime:n})}};var Ce=Mr(require("node:fs"),1),jt=Mr(require("node:path"),1);Re();Sc();var Vce=["EACCES","escaping sandbox","EFBIG"],nh=class{root;canonicalRoot;maxFileReadSize;allowSymlinks;constructor(e){this.root=jt.resolve(e.root),this.maxFileReadSize=e.maxFileReadSize??10485760,this.allowSymlinks=e.allowSymlinks??!1,e1(this.root,"ReadWriteFs"),this.canonicalRoot=Ce.realpathSync(this.root)}resolveAndValidate(e,r){let n=this.allowSymlinks?al(e,this.canonicalRoot):Jm(e,this.root,this.canonicalRoot);if(n===null)throw new Error(`EACCES: permission denied, '${r}' resolves outside sandbox`);return n}validateParent(e,r){let n=jt.dirname(e),s=this.resolveAndValidate(n,r);return jt.join(s,jt.basename(e))}toRealPath(e){let r=we(e),n=jt.join(this.root,r);return jt.resolve(n)}async readFile(e,r){let n=await this.readFileBuffer(e),s=zs(r);return xs(n,s)}async readFileBytes(e){let r=await this.readFileBuffer(e);return xs(r,"binary")}async readFileBuffer(e){Se(e,"open");let r=this.toRealPath(e),n=this.resolveAndValidate(r,e);try{let s=this.allowSymlinks?Ce.constants.O_RDONLY:Ce.constants.O_RDONLY|Ce.constants.O_NOFOLLOW,i=await Ce.promises.open(n,s);try{if(this.maxFileReadSize>0){let a=await i.stat();if(a.size>this.maxFileReadSize)throw new Error(`EFBIG: file too large, read '${e}' (${a.size} bytes, max ${this.maxFileReadSize})`)}let o=await i.readFile();return new Uint8Array(o)}finally{await i.close()}}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(i.code==="EISDIR")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(i.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(s,e,"open")}}async writeFile(e,r,n){Se(e,"write");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=zs(n),a=ao(r,o),l=jt.dirname(i);try{await Ce.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:Ce.constants.O_NOFOLLOW,u=Ce.constants.O_WRONLY|Ce.constants.O_CREAT|Ce.constants.O_TRUNC|c,f=await Ce.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(c,e,"write")}}async appendFile(e,r,n){Se(e,"append");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e),o=zs(n),a=ao(r,o),l=jt.dirname(i);try{await Ce.promises.mkdir(l,{recursive:!0}),i=this.resolveAndValidate(s,e);let c=this.allowSymlinks?0:Ce.constants.O_NOFOLLOW,u=Ce.constants.O_WRONLY|Ce.constants.O_CREAT|Ce.constants.O_APPEND|c,f=await Ce.promises.open(i,u,438);try{await f.writeFile(a)}finally{await f.close()}}catch(c){if(c.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(c,e,"append")}}async exists(e){if(e.includes("\0"))return!1;let r=this.toRealPath(e);try{let n=this.resolveAndValidate(r,e);return await Ce.promises.access(n),!0}catch{return!1}}async stat(e){Se(e,"stat");let r=this.toRealPath(e),n=this.resolveAndValidate(r,e);try{let s=await Ce.promises.lstat(n);if(!this.allowSymlinks&&s.isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, stat '${e}'`);this.sanitizeError(s,e,"stat")}}async lstat(e){Se(e,"lstat");let r=this.toRealPath(e),n=this.validateParent(r,e);try{let s=await Ce.promises.lstat(n);return{isFile:s.isFile(),isDirectory:s.isDirectory(),isSymbolicLink:s.isSymbolicLink(),mode:s.mode,size:s.size,mtime:s.mtime}}catch(s){if(s.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);this.sanitizeError(s,e,"lstat")}}async mkdir(e,r){Se(e,"mkdir");let n=this.toRealPath(e),s=this.resolveAndValidate(n,e);try{await Ce.promises.mkdir(s,{recursive:r?.recursive})}catch(i){let o=i;if(o.code==="EEXIST")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.sanitizeError(i,e,"mkdir")}}async readdir(e){return(await this.readdirWithFileTypes(e)).map(n=>n.name)}async readdirWithFileTypes(e){Se(e,"scandir");let r=this.toRealPath(e),n=this.resolveAndValidate(r,e);try{if(!this.allowSymlinks&&(await Ce.promises.lstat(n)).isSymbolicLink())throw new Error(`EACCES: permission denied, '${e}' is a symlink`);return(await Ce.promises.readdir(n,{withFileTypes:!0})).map(i=>({name:i.name,isFile:i.isFile(),isDirectory:i.isDirectory(),isSymbolicLink:i.isSymbolicLink()})).sort((i,o)=>i.name<o.name?-1:i.name>o.name?1:0)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(i.code==="ENOTDIR")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);this.sanitizeError(s,e,"scandir")}}async rm(e,r){Se(e,"rm");let n=this.toRealPath(e),s=this.resolveAndValidate(n,e);try{await Ce.promises.rm(s,{recursive:r?.recursive??!1,force:r?.force??!1})}catch(i){let o=i;if(o.code==="ENOENT"&&!r?.force)throw new Error(`ENOENT: no such file or directory, rm '${e}'`);if(o.code==="ENOTEMPTY")throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);this.sanitizeError(i,e,"rm")}}async cp(e,r,n){Se(e,"cp"),Se(r,"cp");let s=this.toRealPath(e),i=this.toRealPath(r),o=this.resolveAndValidate(s,e),a=this.resolveAndValidate(i,r);try{await Ce.promises.cp(o,a,{recursive:n?.recursive??!1,filter:async l=>{try{if(Ce.lstatSync(l).isSymbolicLink()){let u=await Ce.promises.realpath(l).catch(()=>null);return u===null?!1:gi(u,this.canonicalRoot)}return!0}catch(c){return c.code==="ENOENT"}}})}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(c.code==="EISDIR")throw new Error(`EISDIR: is a directory, cp '${e}'`);this.sanitizeError(l,e,"cp")}}async mv(e,r){Se(e,"mv"),Se(r,"mv");let n=this.toRealPath(e),s=this.toRealPath(r),i=this.validateParent(n,e),o=this.validateParent(s,r);try{if((await Ce.promises.lstat(i)).isSymbolicLink()){let c=await Ce.promises.readlink(i),u=jt.resolve(jt.dirname(o),c),f=await Ce.promises.realpath(u).catch(()=>u);if(!gi(f,this.canonicalRoot))throw new Error(`EACCES: permission denied, mv '${e}' -> '${r}' would create symlink escaping sandbox`)}}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.message?.includes("EACCES")||c.message?.includes("escaping sandbox"))throw l}let a=jt.dirname(o);try{await Ce.promises.mkdir(a,{recursive:!0})}catch(l){this.sanitizeError(l,r,"mv")}try{await Ce.promises.rename(i,o)}catch(l){let c=l;if(c.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, mv '${e}'`);if(c.code==="EXDEV"){await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0});return}this.sanitizeError(l,e,"mv")}try{if(Ce.lstatSync(o).isDirectory()&&this.findEscapingSymlinks(o).length>0)throw await Ce.promises.rename(o,i),new Error(`EACCES: permission denied, mv '${e}' -> '${r}' would create symlinks escaping sandbox`)}catch(l){if(l.message?.includes("EACCES")||l.message?.includes("escaping sandbox"))throw l}}resolvePath(e,r){return Go(e,r)}getAllPaths(){let e=[];return this.scanDir("/",e),e}sanitizeError(e,r,n){t1(e,r,n,Vce)}findEscapingSymlinks(e){let r=[];try{let n=Ce.readdirSync(e);for(let s of n){let i=jt.join(e,s);try{let o=Ce.lstatSync(i);if(o.isSymbolicLink()){let a=Ce.readlinkSync(i),l=jt.resolve(e,a),c;try{c=Ce.realpathSync(l)}catch{c=l}gi(c,this.canonicalRoot)||r.push(i)}else o.isDirectory()&&r.push(...this.findEscapingSymlinks(i))}catch{}}}catch{}return r}scanDir(e,r){let n=this.toRealPath(e),s;try{s=this.resolveAndValidate(n,e)}catch{return}try{let i=Ce.readdirSync(s);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;r.push(a);let l=jt.join(s,o);Ce.lstatSync(l).isDirectory()&&this.scanDir(a,r)}}catch{}}async chmod(e,r){Se(e,"chmod");let n=this.toRealPath(e),s=this.resolveAndValidate(n,e);try{let i=this.allowSymlinks?Ce.constants.O_RDONLY:Ce.constants.O_RDONLY|Ce.constants.O_NOFOLLOW,o=await Ce.promises.open(s,i);try{await o.chmod(r)}finally{await o.close()}}catch(i){let o=i;if(o.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);if(o.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(i,e,"chmod")}}async symlink(e,r){if(!this.allowSymlinks)throw new Error(`EPERM: operation not permitted, symlink '${r}'`);Se(r,"symlink");let n=this.toRealPath(r),s=this.validateParent(n,r),i=we(r),o=we(jt.dirname(i)),a=e.startsWith("/")?we(e):we(o==="/"?`/${e}`:`${o}/${e}`),l=jt.join(this.canonicalRoot,a),c=jt.dirname(s),u=e.startsWith("/")?l:jt.relative(c,l)||".";try{await Ce.promises.symlink(u,s)}catch(f){if(f.code==="EEXIST")throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.sanitizeError(f,r,"symlink")}}async link(e,r){Se(e,"link"),Se(r,"link");let n=this.toRealPath(e),s=this.toRealPath(r),i=this.resolveAndValidate(n,e),o=this.resolveAndValidate(s,r);try{await Ce.promises.link(i,o)}catch(a){let l=a;if(l.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(l.code==="EEXIST")throw new Error(`EEXIST: file already exists, link '${r}'`);if(l.code==="EPERM")throw new Error(`EPERM: operation not permitted, link '${e}'`);this.sanitizeError(a,e,"link")}}async readlink(e){Se(e,"readlink");let r=this.toRealPath(e),n=this.validateParent(r,e);try{let s=await Ce.promises.readlink(n),i=we(e),o=jt.dirname(i),a=jt.isAbsolute(s)?s:jt.resolve(jt.dirname(n),s),l=await Ce.promises.realpath(a).catch(()=>a);if(gi(l,this.canonicalRoot)){let c=l.slice(this.canonicalRoot.length)||"/";return o==="/"?c.startsWith("/")?c.slice(1)||".":c:jt.relative(o,c)}return jt.basename(s)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(i.code==="EINVAL")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);this.sanitizeError(s,e,"readlink")}}async realpath(e){Se(e,"realpath");let r=this.toRealPath(e);try{this.resolveAndValidate(r,e)}catch{throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}let n;try{n=await Ce.promises.realpath(r)}catch(s){let i=s;if(i.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, realpath '${e}'`);if(i.code==="ELOOP")throw new Error(`ELOOP: too many levels of symbolic links, realpath '${e}'`);this.sanitizeError(s,e,"realpath")}if(gi(n,this.canonicalRoot))return n.slice(this.canonicalRoot.length)||"/";throw new Error(`ENOENT: no such file or directory, realpath '${e}'`)}async utimes(e,r,n){Se(e,"utimes");let s=this.toRealPath(e),i=this.resolveAndValidate(s,e);try{let o=this.allowSymlinks?Ce.constants.O_RDONLY:Ce.constants.O_RDONLY|Ce.constants.O_NOFOLLOW,a=await Ce.promises.open(i,o);try{await a.utimes(r,n)}finally{await a.close()}}catch(o){let a=o;if(a.code==="ENOENT")throw new Error(`ENOENT: no such file or directory, utimes '${e}'`);if(a.code==="ELOOP")throw new Error(`EACCES: permission denied, '${e}' is a symlink`);this.sanitizeError(o,e,"utimes")}}};mr();Yi();bi();var cl=class{cmdId;cwd;startedAt;exitCode;bashEnv;cmdLine;env;explicitCwd;signal;timeoutMs;abortController=new AbortController;timeoutId;externalAbortListener;resultPromise;constructor(e,r,n,s,i=!1,o,a){this.cmdId=crypto.randomUUID(),this.cwd=n,this.startedAt=new Date,this.bashEnv=e,this.cmdLine=r,this.env=s,this.explicitCwd=i,this.signal=o,this.timeoutMs=a,this.setupCancellation(),this.resultPromise=this.execute()}setupCancellation(){if(this.signal&&(this.signal.aborted?this.abortController.abort(this.signal.reason):(this.externalAbortListener=()=>{this.abortController.abort(this.signal?.reason)},this.signal.addEventListener("abort",this.externalAbortListener,{once:!0}))),this.timeoutMs!==void 0){let e=Math.max(0,this.timeoutMs);this.timeoutId=Wr(()=>{this.abortController.abort(new Error(`sandbox command timeout after ${e}ms`))},e)}}cleanupCancellation(){this.timeoutId!==void 0&&(fr(this.timeoutId),this.timeoutId=void 0),this.signal&&this.externalAbortListener&&(this.signal.removeEventListener("abort",this.externalAbortListener),this.externalAbortListener=void 0)}async execute(){let e={cwd:this.explicitCwd?this.cwd:void 0,env:this.env,signal:this.abortController.signal};try{let r=await this.bashEnv.exec(this.cmdLine,e);return this.exitCode=r.exitCode,r}finally{this.cleanupCancellation()}}async*logs(){let e=await this.resultPromise;e.stdout&&(yield{type:"stdout",data:e.stdout,timestamp:new Date}),e.stderr&&(yield{type:"stderr",data:e.stderr,timestamp:new Date})}async wait(){return await this.resultPromise,this}async output(){let e=await this.resultPromise;return e.stdout+e.stderr}async stdout(){return(await this.resultPromise).stdout}async stderr(){return(await this.resultPromise).stderr}async kill(){this.abortController.abort(new Error("command killed"))}};var sh=class t{bashEnv;timeoutMs;constructor(e,r){this.bashEnv=e,this.timeoutMs=r}static async create(e){let r=e?.fs;if(e?.overlayRoot){if(e?.fs)throw new Error("Cannot specify both 'fs' and 'overlayRoot' options");r=new ll({root:e.overlayRoot})}let n=new Hc({env:e?.env,cwd:e?.cwd,fs:r,maxCallDepth:e?.maxCallDepth,maxCommandCount:e?.maxCommandCount,maxLoopIterations:e?.maxLoopIterations,network:e?.network,defenseInDepth:e?.defenseInDepth});return new t(n,e?.timeoutMs)}async runCommand(e,r,n){let s,i,o,a,l=!1,c,u;if(typeof e=="object"){let m=e,g=[m.cmd,...m.args??[]];s=Vr(g),i=m.cwd,o=m.env,a=m.signal,l=m.detached??!1,c=m.stdout,u=m.stderr}else if(Array.isArray(r)){let m=n;s=Vr([e,...r]),a=m?.signal}else{s=e;let m=r;i=m?.cwd,o=m?.env}let f=i??this.bashEnv.getCwd(),h=i!==void 0,d=new cl(this.bashEnv,s,f,o,h,a,this.timeoutMs);if(l)return d;let p=await d.wait();if(c){let m=await d.stdout();m&&c.write(m)}if(u){let m=await d.stderr();m&&u.write(m)}return p}async writeFiles(e){let r=this.bashEnv.getCwd();for(let[n,s]of Object.entries(e)){let i;typeof s=="string"?i=s:s.encoding==="base64"?i=Buffer.from(s.content,"base64").toString("utf-8"):i=s.content;let o=this.bashEnv.fs.resolvePath(r,n),a=o.substring(0,o.lastIndexOf("/"))||"/";a!=="/"&&await this.bashEnv.fs.mkdir(a,{recursive:!0}),await this.bashEnv.writeFile(o,i)}}async readFile(e,r){let n=await this.bashEnv.readFile(e);return r==="base64"?Buffer.from(n).toString("base64"):n}async mkDir(e,r){let n=this.bashEnv.fs.resolvePath(this.bashEnv.getCwd(),e);await this.bashEnv.fs.mkdir(n,{recursive:r?.recursive??!1})}async stop(){}async extendTimeout(e){}get domain(){}get bashEnvInstance(){return this.bashEnv}};$r();var ih=class{violations=[];violationsByType=new Map;options;constructor(e={}){this.options={maxViolationsPerType:e.maxViolationsPerType??100,maxViolationsTotal:e.maxViolationsTotal??1e3,includeStackTraces:e.includeStackTraces??!0,onViolation:e.onViolation??(()=>{}),logToConsole:e.logToConsole??!1}}record(e){let r=this.options.includeStackTraces?e:{...e,stack:void 0};this.violations.unshift(r),this.violations.length>this.options.maxViolationsTotal&&(this.violations.length=this.options.maxViolationsTotal);let n=this.violationsByType.get(e.type);n||(n=[],this.violationsByType.set(e.type,n)),n.length<this.options.maxViolationsPerType&&n.push(r),this.options.logToConsole&&console.warn(`[SecurityViolation] ${e.type}: ${e.message}`,e.path),this.options.onViolation(r)}getViolations(){return[...this.violations]}getViolationsByType(e){return[...this.violationsByType.get(e)??[]]}getSummary(){let e=[];for(let[r,n]of this.violationsByType){if(n.length===0)continue;let s=new Set,i=Number.POSITIVE_INFINITY,o=0;for(let a of n)s.add(a.path),i=Math.min(i,a.timestamp),o=Math.max(o,a.timestamp);e.push({type:r,count:n.length,firstSeen:i,lastSeen:o,paths:Array.from(s)})}return e.sort((r,n)=>n.count-r.count),e}getTotalCount(){return this.violations.length}hasViolations(){return this.violations.length>0}clear(){this.violations=[],this.violationsByType.clear()}createCallback(){return e=>this.record(e)}};function tS(){return t=>{console.warn("[DefenseInDepth] Security violation detected:",`
2193
2193
  Type: ${t.type}`,`
2194
2194
  Path: ${t.path}`,`
2195
2195
  Message: ${t.message}`,t.executionId?`