sliccy 6.99.7 → 6.99.9

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 (278) hide show
  1. package/dist/node-server/_shared/tray-signaling.d.ts +2 -0
  2. package/dist/node-server/_shared/tray-signaling.d.ts.map +1 -1
  3. package/dist/ui/.vite/manifest.json +390 -615
  4. package/dist/ui/assets/__vite-browser-external-CyeY5rFA.js +1 -0
  5. package/dist/ui/assets/{account-store-y43KgcoW.js → account-store-CYMEkNNe.js} +3 -3
  6. package/dist/ui/assets/{account-store-llwJaGRg.js → account-store-ktNi3pcb.js} +5 -5
  7. package/dist/ui/assets/{adobe-C30ITWqR.js → adobe-B9bqpVA6.js} +1 -1
  8. package/dist/ui/assets/adobe-D2l8vW4Z.js +2 -0
  9. package/dist/ui/assets/agent-panels-BFjOOqNh.js +1 -0
  10. package/dist/ui/assets/{anthropic-messages-DbPJ2ji9.js → anthropic-messages-B7p0objs.js} +1 -1
  11. package/dist/ui/assets/{anthropic-messages-CpSojOI8.js → anthropic-messages-JQYJ-RUq.js} +1 -1
  12. package/dist/ui/assets/{apply-layout-CyFMgsCH.js → apply-layout-C9atHx_R.js} +1 -1
  13. package/dist/ui/assets/{apps-BaBqMpf9.js → apps-bxajdBmb.js} +1 -1
  14. package/dist/ui/assets/azure-openai-B7WXqTuL.js +18 -0
  15. package/dist/ui/assets/azure-openai-DbxXj8zK.js +18 -0
  16. package/dist/ui/assets/{azure-openai-responses-DUMDrZ29.js → azure-openai-responses-BNbgkULn.js} +1 -1
  17. package/dist/ui/assets/{azure-openai-responses-BcoOaRCx.js → azure-openai-responses-BULcSJeo.js} +1 -1
  18. package/dist/ui/assets/{bedrock-camp-LeceEQbU.js → bedrock-camp-9Mg_YE1C.js} +1 -1
  19. package/dist/ui/assets/{bedrock-camp-BcJEC3Pg.js → bedrock-camp-DP3Gfbz7.js} +1 -1
  20. package/dist/ui/assets/{browser-DdY1FBRp.js → browser-DGwroBSO.js} +3 -3
  21. package/dist/ui/assets/{bsh-watchdog-GrjFkpDG.js → bsh-watchdog--Df_ThJG.js} +1 -1
  22. package/dist/ui/assets/{cdp-ByIHQG_1.js → cdp-BzUC7d2h.js} +1 -1
  23. package/dist/ui/assets/{cerebras-Oyxkgl8K.js → cerebras-CUwJMnYY.js} +1 -1
  24. package/dist/ui/assets/{cerebras-DCOB1GIn.js → cerebras-CfOSdVHz.js} +1 -1
  25. package/dist/ui/assets/{claude-model-version-Csn7RPVg.js → claude-model-version-BXR93nLt.js} +1 -1
  26. package/dist/ui/assets/claude-model-version-D6lCh6G7.js +2 -0
  27. package/dist/ui/assets/{composer-speech-Bqp4MnUW.js → composer-speech-Byuwd2QJ.js} +1 -1
  28. package/dist/ui/assets/{connect-surface-N7OhnOjG.js → connect-surface-BIhkXU-D.js} +1 -1
  29. package/dist/ui/assets/{cost-command-BQWpaecs.js → cost-command-CwOkolbd.js} +57 -57
  30. package/dist/ui/assets/{dist-_7dnux20.js → dist-BmTb9jmr.js} +1 -1
  31. package/dist/ui/assets/{dist-D7yTTAcb.js → dist-BnDrtqYs.js} +1 -1
  32. package/dist/ui/assets/dist-CMD3ZuiV.js +1 -0
  33. package/dist/ui/assets/{dist-DTAqvnM4.js → dist-CV-6KpFS.js} +1 -1
  34. package/dist/ui/assets/dist-CWHNqkcj.js +1 -0
  35. package/dist/ui/assets/dist-CrVgSn_b.js +6 -0
  36. package/dist/ui/assets/dist-DkG8wgj1.js +23 -0
  37. package/dist/ui/assets/dist-N1MMHRNk.js +18 -0
  38. package/dist/ui/assets/dist-RekgwRC0.js +12 -0
  39. package/dist/ui/assets/{dist-B4LJzMVB.js → dist-kBT87Ea7.js} +11 -11
  40. package/dist/ui/assets/{ensure-speech-assets-CO3wuKjp.js → ensure-speech-assets-Hv5Jwof_.js} +1 -1
  41. package/dist/ui/assets/{es-BDNIRkLU.js → es-BLFevQz4.js} +5 -5
  42. package/dist/ui/assets/{esbuild-wasm-DUOZmSly.js → esbuild-wasm-Dl3vgXvq.js} +2 -2
  43. package/dist/ui/assets/esp8266-1y0C3qJ1.js +1 -0
  44. package/dist/ui/assets/esptool-operations-CiccBbBW.js +12 -0
  45. package/dist/ui/assets/esptool-operations-lUvXx3gs.js +13 -0
  46. package/dist/ui/assets/{follower-navigate-watcher-Dd46El3D.js → follower-navigate-watcher-DRFF6ll0.js} +1 -1
  47. package/dist/ui/assets/fs-CvM7tq2t.js +2 -0
  48. package/dist/ui/assets/{fs-BNz_JyUR.js → fs-DUneCuZW.js} +1 -1
  49. package/dist/ui/assets/git-config-Bdgu8kD2.js +7 -0
  50. package/dist/ui/assets/git-config-D2u6LGfT.js +5 -0
  51. package/dist/ui/assets/github-CHdABf-3.js +2 -0
  52. package/dist/ui/assets/github-DvD4qs-U.js +1 -0
  53. package/dist/ui/assets/github-copilot-BB3QwaLu.js +2 -0
  54. package/dist/ui/assets/{github-copilot-DiPxhMir.js → github-copilot-K0sRIoSq.js} +1 -1
  55. package/dist/ui/assets/{github-install-CZSoNGFR.js → github-install-vA3zHPFd.js} +1 -1
  56. package/dist/ui/assets/{github-zip-CrdkhxjH.js → github-zip-C7KlmYg5.js} +1 -1
  57. package/dist/ui/assets/{google-generative-ai-Rjh7hNBV.js → google-generative-ai-DEMR2Ygt.js} +1 -1
  58. package/dist/ui/assets/{google-generative-ai-Dxo91M3n.js → google-generative-ai-ZQ9beFyW.js} +1 -1
  59. package/dist/ui/assets/{google-shared-DQJPCU3d.js → google-shared-B7H0ZrH8.js} +6 -6
  60. package/dist/ui/assets/google-shared-REamLvEm.js +11 -0
  61. package/dist/ui/assets/{google-vertex-DEwkNZJm.js → google-vertex-0C6GT5h4.js} +1 -1
  62. package/dist/ui/assets/{google-vertex-61Jj0dk6.js → google-vertex-DsErHx7o.js} +1 -1
  63. package/dist/ui/assets/handoff-link-BObMRgsx.js +1 -0
  64. package/dist/ui/assets/{hear-Co4TqejW.js → hear-zfLnACrB.js} +1 -1
  65. package/dist/ui/assets/{installer-CufDPCfO.js → installer-VcJEC2uC.js} +1 -1
  66. package/dist/ui/assets/{isomorphic-git-BAj-fLD-.js → isomorphic-git-WdgG3efW.js} +6 -6
  67. package/dist/ui/assets/js-realm-worker-CJBsByLD.js +40 -0
  68. package/dist/ui/assets/{kernel-worker-DyoLnIZO.js → kernel-worker-DL4H-NBi.js} +421 -428
  69. package/dist/ui/assets/kokoro-BkJ3NLgd.js +4 -0
  70. package/dist/ui/assets/{legacy-api-aliases-oJPAvhVV.js → legacy-api-aliases-BYDhiWyY.js} +1 -1
  71. package/dist/ui/assets/{legacy-api-aliases-BnRqMAef.js → legacy-api-aliases-Dh4ciP2O.js} +1 -1
  72. package/dist/ui/assets/{libesm-BI4UHVqp.js → libesm-BypnjKEL.js} +1 -1
  73. package/dist/ui/assets/{libesm-zfj8k-QN.js → libesm-CSMdpGMF.js} +1 -1
  74. package/dist/ui/assets/lick-manager-CYlek4qq.js +2 -0
  75. package/dist/ui/assets/{lick-ws-bridge-yklVm5en.js → lick-ws-bridge-CdCpPLQn.js} +1 -1
  76. package/dist/ui/assets/{local-llm-DOnsCe6c.js → local-llm-BxbXSRY1.js} +1 -1
  77. package/dist/ui/assets/{local-llm-DNFbzXTw.js → local-llm-DFV3ffPY.js} +1 -1
  78. package/dist/ui/assets/magick-wasm-266b8ntc.js +43 -0
  79. package/dist/ui/assets/main-B6Og2ks7.js +22 -0
  80. package/dist/ui/assets/{main-cherry-3UVAQhqV.js → main-cherry-C6fqCnLL.js} +1 -1
  81. package/dist/ui/assets/mount-CqTvny3n.js +2 -0
  82. package/dist/ui/assets/{mount-DhhlMZMN.js → mount-iK3BWJwS.js} +1 -1
  83. package/dist/ui/assets/{mount-recovery-Dbd9EVjz.js → mount-recovery-BNtMtfx7.js} +1 -1
  84. package/dist/ui/assets/{navigation-watcher-OPbGCby9.js → navigation-watcher-DrWMx-B4.js} +1 -1
  85. package/dist/ui/assets/new-session-Dq10ablA.js +2 -0
  86. package/dist/ui/assets/oauth-bootstrap-BriIqrT5.js +2 -0
  87. package/dist/ui/assets/onboarding-orchestrator-Cd0lVIve.js +1 -0
  88. package/dist/ui/assets/openai-BKEGagiR.js +17 -0
  89. package/dist/ui/assets/openai-Bgt_f1Dp.js +17 -0
  90. package/dist/ui/assets/openai-codex-CrPEnCvZ.js +1 -0
  91. package/dist/ui/assets/{openai-codex-BI5-lt7L.js → openai-codex-D50qgZ4K.js} +1 -1
  92. package/dist/ui/assets/{openai-codex-responses-CPOJeFUY.js → openai-codex-responses-C-nzMgox.js} +1 -1
  93. package/dist/ui/assets/{openai-codex-responses-jQR19NyX.js → openai-codex-responses-CG4v_H6T.js} +1 -1
  94. package/dist/ui/assets/{openai-completions-DGOcowq8.js → openai-completions-CIRx7G9l.js} +2 -2
  95. package/dist/ui/assets/{openai-completions-DGZFJo5D.js → openai-completions-ojba8VM0.js} +2 -2
  96. package/dist/ui/assets/{openai-responses-CDTdSIhv.js → openai-responses-BDRcKCF5.js} +1 -1
  97. package/dist/ui/assets/{openai-responses-bnETPgx9.js → openai-responses-DzwaJ-X-.js} +1 -1
  98. package/dist/ui/assets/openai-responses-shared-BjAQ1eIE.js +10 -0
  99. package/dist/ui/assets/openai-responses-shared-Dg_yfxea.js +10 -0
  100. package/dist/ui/assets/openrouter-0FxeBdE5.js +1 -0
  101. package/dist/ui/assets/{openrouter-DZhpGJA4.js → openrouter-Dhsi_ko9.js} +1 -1
  102. package/dist/ui/assets/{openrouter-images-C93KT7V_.js → openrouter-images-BAtqv3Im.js} +1 -1
  103. package/dist/ui/assets/{openrouter-images-CiM-JPBO.js → openrouter-images-Du3tMEQa.js} +1 -1
  104. package/dist/ui/assets/{openrouter-oauth-iFmYGgcr.js → openrouter-oauth-CIzZhpZg.js} +1 -1
  105. package/dist/ui/assets/openrouter-oauth-CpKt1MA8.js +1 -0
  106. package/dist/ui/assets/panel-rpc-handlers-DRmkHDcC.js +2 -0
  107. package/dist/ui/assets/panelize-shell-B1SCUwME.js +4 -0
  108. package/dist/ui/assets/pdfjs-DAWky37A.js +100 -0
  109. package/dist/ui/assets/{provider-CauMmJra.js → provider-CHFkYrg5.js} +1 -1
  110. package/dist/ui/assets/provider-DR7pS55u.js +2 -0
  111. package/dist/ui/assets/{provider-settings-CDR9tmFe.js → provider-settings-QhXeD8p1.js} +1 -1
  112. package/dist/ui/assets/provider-store-access-BWBUxNsZ.js +1 -0
  113. package/dist/ui/assets/provider-store-access-WTMg_H8y.js +1 -0
  114. package/dist/ui/assets/{providers-DS7U7ou8.js → providers-CMHd9MFS.js} +1 -1
  115. package/dist/ui/assets/providers-D-6LGcDk.js +2 -0
  116. package/dist/ui/assets/{py-realm-worker-B2OTI7Xc.js → py-realm-worker-D1gqcTkl.js} +2 -2
  117. package/dist/ui/assets/{pyodide-CkJHMMSo.js → pyodide-D43YUXvd.js} +2 -2
  118. package/dist/ui/assets/{quick-llm-DSQHsD_0.js → quick-llm-CPywyeCK.js} +1 -1
  119. package/dist/ui/assets/{recovery-screen-dGlemlkP.js → recovery-screen-CmRYQ0rB.js} +1 -1
  120. package/dist/ui/assets/{redirect-uri-BOpxbXbd.js → redirect-uri-C8-Woku_.js} +1 -1
  121. package/dist/ui/assets/remote-cdp-transport-DeDqT7I4.js +1 -0
  122. package/dist/ui/assets/remote-sprinkle-vfs-CawR6gXx.js +1 -0
  123. package/dist/ui/assets/{remote-terminal-view-BNWZWMBC.js → remote-terminal-view-D2bRNJcS.js} +2 -2
  124. package/dist/ui/assets/{run-Cll4MnAK.js → run-CxkS2v3b.js} +1 -1
  125. package/dist/ui/assets/safe-buffer-OLJ0qaLt.js +12 -0
  126. package/dist/ui/assets/safe-buffer-iah92gQe.js +1 -0
  127. package/dist/ui/assets/{setup-feature-flags-remote-rcKrPHk7.js → setup-feature-flags-remote-bBB7gD8w.js} +1 -1
  128. package/dist/ui/assets/shared-B9N4MZd0.js +1 -0
  129. package/dist/ui/assets/shared-CPVZc-MN.js +4 -0
  130. package/dist/ui/assets/sidecar-repair-CwI_pMMe.js +1 -0
  131. package/dist/ui/assets/{skills-0Do2e7wj.js → skills-D0atjE-P.js} +1 -1
  132. package/dist/ui/assets/{slicc-diff-DhGIKKqP.js → slicc-diff-DRjxoBYz.js} +1 -1
  133. package/dist/ui/assets/slicc-editor-D-eO_pjd.js +23 -0
  134. package/dist/ui/assets/slicc-editor-Sdfe-_x_.js +1 -0
  135. package/dist/ui/assets/slicc-version-Bc9r0Wca.js +1 -0
  136. package/dist/ui/assets/speak-BsVaFA0Z.js +3 -0
  137. package/dist/ui/assets/{sprinkle-bridge-C4qw-DTw.js → sprinkle-bridge-e00Na2NA.js} +1 -1
  138. package/dist/ui/assets/{sprinkle-manager-B5T2quSt.js → sprinkle-manager-BqdBktzt.js} +1 -1
  139. package/dist/ui/assets/{sprinkle-renderer-D64E-W2o.js → sprinkle-renderer-C9L5ZRvl.js} +2 -2
  140. package/dist/ui/assets/{sql-wasm-DO685FZu.js → sql-wasm-B7K7OCuB.js} +1 -1
  141. package/dist/ui/assets/{state-BrCP8Eff.js → state-o12tamuF.js} +1 -1
  142. package/dist/ui/assets/{store-C2gM1M-9.js → store-BT0FKeS5.js} +1 -1
  143. package/dist/ui/assets/{store-bEWnkux0.js → store-BUjz66P2.js} +1 -1
  144. package/dist/ui/assets/{sudo-D0ZG1KJr.js → sudo-Cb_jI2eu.js} +1 -1
  145. package/dist/ui/assets/sync-dialog-CV7-2aVT.js +1 -0
  146. package/dist/ui/assets/{temperature-support-B4x2xaWY.js → temperature-support-BVrwHxWv.js} +1 -1
  147. package/dist/ui/assets/{temperature-support-Cpml9LfI.js → temperature-support-LrmsX3ix.js} +1 -1
  148. package/dist/ui/assets/{transformers-env-HIDS8utb.js → transformers-env-_JNZLFlo.js} +1 -1
  149. package/dist/ui/assets/transformers.web-B0gi9Hor.js +39 -0
  150. package/dist/ui/assets/tray-leader-Mq6HIneb.js +1 -0
  151. package/dist/ui/assets/{upgrade-detection-Ckesn3Ns.js → upgrade-detection-CNu3KNsM.js} +1 -1
  152. package/dist/ui/assets/voice-reply-BFImQhAG.js +1 -0
  153. package/dist/ui/assets/wc-attach-d-lHwJPz.js +13 -0
  154. package/dist/ui/assets/wc-extension-p4la3vtz.js +2 -0
  155. package/dist/ui/assets/wc-float-label-Dtx9Io98.js +1 -0
  156. package/dist/ui/assets/{wc-floatbar-online-tsTifrU7.js → wc-floatbar-online-pmlV024x.js} +1 -1
  157. package/dist/ui/assets/wc-follower-2DQ7Q3wG.js +17 -0
  158. package/dist/ui/assets/wc-follower-oauth-BXi7U3s5.js +5 -0
  159. package/dist/ui/assets/wc-live-BfpVK1Kd.js +399 -0
  160. package/dist/ui/assets/wc-nav-BNZDsOwH.js +2 -0
  161. package/dist/ui/assets/wc-onboarding-BinmjNb5.js +2 -0
  162. package/dist/ui/assets/{wc-permissions-CEmFmdBe.js → wc-permissions-WjSZrbPa.js} +2 -2
  163. package/dist/ui/assets/{wc-placeholder-C1LDJQR7.js → wc-placeholder-CPP2DyEf.js} +3 -3
  164. package/dist/ui/assets/{wc-settings-PtFpnkee.js → wc-settings-ChigIGe8.js} +3 -3
  165. package/dist/ui/assets/{src-B-encLtu.js → wc-shell-C8rORiLz.js} +304 -161
  166. package/dist/ui/assets/{wc-shortcut-config-w6fJ0bVB.js → wc-shortcut-config-CsiYOxaR.js} +2 -2
  167. package/dist/ui/assets/{wc-sprinkles-CeAUkWME.js → wc-sprinkles-DwSBE-SU.js} +2 -2
  168. package/dist/ui/assets/wc-transcript-export-CjvhPpom.js +2 -0
  169. package/dist/ui/assets/wc-tray-g89TbAbd.js +2 -0
  170. package/dist/ui/assets/welcome-detection-BHAB2hpt.js +1 -0
  171. package/dist/ui/assets/{whisper-session-DzV9Jmfi.js → whisper-session-Ba-J0yyJ.js} +2 -2
  172. package/dist/ui/assets/{xai-grok-DRbKtbML.js → xai-grok-CaAyB00w.js} +1 -1
  173. package/dist/ui/assets/xai-grok-FS5CaRb2.js +1 -0
  174. package/dist/ui/assets/xterm-B5LH8GIb.css +1 -0
  175. package/dist/ui/assets/xterm-C3BHN0de.js +16 -0
  176. package/dist/ui/index.html +8 -11
  177. package/dist/ui/packages/webapp/index.html +8 -11
  178. package/dist/ui/slicc-diff.js +1 -1
  179. package/dist/ui/slicc-editor.js +1 -1
  180. package/package.json +2 -2
  181. package/dist/ui/assets/__vite-browser-external-CwfFUl-x.js +0 -1
  182. package/dist/ui/assets/adobe-DeM_oCMe.js +0 -2
  183. package/dist/ui/assets/agent-message-to-chat-_cvF5A5g.js +0 -1
  184. package/dist/ui/assets/agent-panels-B92KQapO.js +0 -1
  185. package/dist/ui/assets/azure-openai-B2VLKBwJ.js +0 -18
  186. package/dist/ui/assets/azure-openai-tc52REpx.js +0 -18
  187. package/dist/ui/assets/backend-local-1YuE96fx.js +0 -1
  188. package/dist/ui/assets/chat-session-store-pWb1-jNp.js +0 -1
  189. package/dist/ui/assets/claude-model-version-DoVrYsKi.js +0 -2
  190. package/dist/ui/assets/db-cKsBsMMN.js +0 -1
  191. package/dist/ui/assets/dictation-priming-CNllGgNq.js +0 -1
  192. package/dist/ui/assets/dip-rCM_6Bc6.js +0 -233
  193. package/dist/ui/assets/dist-B6HZAA0r.js +0 -1
  194. package/dist/ui/assets/dist-BHvDPTv0.js +0 -1
  195. package/dist/ui/assets/dist-C56QxoYU.js +0 -18
  196. package/dist/ui/assets/dist-COLaZOxM.js +0 -23
  197. package/dist/ui/assets/dist-CPNmKU6m.js +0 -12
  198. package/dist/ui/assets/dist-Cew647MY.js +0 -12
  199. package/dist/ui/assets/dist-mxmkfALf.js +0 -6
  200. package/dist/ui/assets/esptool-operations-BmdosN6N.js +0 -13
  201. package/dist/ui/assets/esptool-operations-CbgLIJzi.js +0 -12
  202. package/dist/ui/assets/export-provider-BEHTjSYw.js +0 -1
  203. package/dist/ui/assets/follower-presentation-DqBw0YiV.js +0 -1
  204. package/dist/ui/assets/fs-C6heN6Io.js +0 -2
  205. package/dist/ui/assets/git-config-DA8M5e8O.js +0 -7
  206. package/dist/ui/assets/git-config-DLJIrKjL.js +0 -5
  207. package/dist/ui/assets/github-BES17MG4.js +0 -2
  208. package/dist/ui/assets/github-BnrwrtRn.js +0 -1
  209. package/dist/ui/assets/github-copilot-CzZSdNg_.js +0 -2
  210. package/dist/ui/assets/google-shared-CzJgTu-P.js +0 -11
  211. package/dist/ui/assets/handoff-link-BM4ctkE8.js +0 -1
  212. package/dist/ui/assets/host-command-zx0pt9Np.js +0 -1
  213. package/dist/ui/assets/js-realm-worker-D_8dhTFA.js +0 -40
  214. package/dist/ui/assets/kokoro-Bs5vU5OU.js +0 -4
  215. package/dist/ui/assets/layout-schema-m9_VAwOw.js +0 -1
  216. package/dist/ui/assets/leader-session-events-Iq9N1w56.js +0 -1
  217. package/dist/ui/assets/lick-manager-DFmMezV-.js +0 -2
  218. package/dist/ui/assets/magick-wasm-BpzBj-21.js +0 -43
  219. package/dist/ui/assets/main-CPLi98yu.js +0 -22
  220. package/dist/ui/assets/mount-CvVyowQ-.js +0 -2
  221. package/dist/ui/assets/new-session-BUxTN19q.js +0 -2
  222. package/dist/ui/assets/oauth-bootstrap-BnctKs3I.js +0 -2
  223. package/dist/ui/assets/onboarding-orchestrator-BF4m_3Ig.js +0 -1
  224. package/dist/ui/assets/openai-CjBvzZcB.js +0 -17
  225. package/dist/ui/assets/openai-ZcrxEOGB.js +0 -17
  226. package/dist/ui/assets/openai-codex-ad3likLF.js +0 -1
  227. package/dist/ui/assets/openai-responses-shared-ChgvRZ74.js +0 -10
  228. package/dist/ui/assets/openai-responses-shared-DqJbHrek.js +0 -10
  229. package/dist/ui/assets/openrouter-BfwBtJ0a.js +0 -1
  230. package/dist/ui/assets/openrouter-oauth-D1ocgCDw.js +0 -1
  231. package/dist/ui/assets/panel-registry-CJdOibpf.js +0 -1
  232. package/dist/ui/assets/panel-rpc-handlers-Dj-UnwwI.js +0 -2
  233. package/dist/ui/assets/panelize-shell-Dfx0Qk97.js +0 -4
  234. package/dist/ui/assets/pdfjs-BspLIDsM.js +0 -100
  235. package/dist/ui/assets/provider-3zYFx7pL.js +0 -2
  236. package/dist/ui/assets/provider-settings-CZ97KB3C.js +0 -2
  237. package/dist/ui/assets/provider-store-access-DvHfXiAa.js +0 -2
  238. package/dist/ui/assets/provider-store-access-escWLliN.js +0 -1
  239. package/dist/ui/assets/providers-DJA67z1N.js +0 -2
  240. package/dist/ui/assets/remote-cdp-transport-CgOXLjZ8.js +0 -1
  241. package/dist/ui/assets/remote-sprinkle-vfs-e81pZJKo.js +0 -1
  242. package/dist/ui/assets/safe-buffer-B2wnAhUx.js +0 -12
  243. package/dist/ui/assets/safe-buffer-BwTVRVVo.js +0 -1
  244. package/dist/ui/assets/session-freezer-BgO7tLUp.js +0 -162
  245. package/dist/ui/assets/setup-standalone-prelude-50scBzpK.js +0 -2
  246. package/dist/ui/assets/setup-sudo-Ce_APR8D.js +0 -2
  247. package/dist/ui/assets/shared-6HJLEwgI.js +0 -1
  248. package/dist/ui/assets/shared-BzvvjAZt.js +0 -4
  249. package/dist/ui/assets/sidecar-repair-431vRT2V.js +0 -1
  250. package/dist/ui/assets/slicc-editor-CVftccS9.js +0 -1
  251. package/dist/ui/assets/slicc-editor-DsHp_in-.js +0 -12
  252. package/dist/ui/assets/slicc-version-qJjMq-6R.js +0 -1
  253. package/dist/ui/assets/speak-KEFd3n_I.js +0 -3
  254. package/dist/ui/assets/sync-dialog-ACgl0n-p.js +0 -1
  255. package/dist/ui/assets/timestamp-preference-sKwBl5I8.js +0 -2
  256. package/dist/ui/assets/transformers.web-Cg_-cFJu.js +0 -39
  257. package/dist/ui/assets/tray-leader-iVJTGwuf.js +0 -1
  258. package/dist/ui/assets/tray-sync-protocol-BZ5yhJH9.js +0 -1
  259. package/dist/ui/assets/tray-sync-protocol-DV_QG_Ey.js +0 -1
  260. package/dist/ui/assets/trusted-layer-ghPA1ENf.js +0 -1
  261. package/dist/ui/assets/voice-reply-DaVk8H0o.js +0 -1
  262. package/dist/ui/assets/wc-attach-3I9pOCPA.js +0 -13
  263. package/dist/ui/assets/wc-extension-D1gzObu-.js +0 -2
  264. package/dist/ui/assets/wc-float-label-CCMo81Ds.js +0 -1
  265. package/dist/ui/assets/wc-follower-DrCJN-aK.js +0 -17
  266. package/dist/ui/assets/wc-follower-oauth-Dw0qOLsI.js +0 -5
  267. package/dist/ui/assets/wc-live-qc9mrCs3.js +0 -8
  268. package/dist/ui/assets/wc-nav-CysORJLz.js +0 -2
  269. package/dist/ui/assets/wc-onboarding-COhEMI0E.js +0 -2
  270. package/dist/ui/assets/wc-scoop-color-ShF3p7L9.js +0 -1
  271. package/dist/ui/assets/wc-shell-lFwQe30J.js +0 -119
  272. package/dist/ui/assets/wc-shortcuts-GiPteshM.js +0 -26
  273. package/dist/ui/assets/wc-transcript-export-DKIleW7-.js +0 -2
  274. package/dist/ui/assets/wc-tray-_dof-pAl.js +0 -2
  275. package/dist/ui/assets/welcome-detection-iVN_xL76.js +0 -1
  276. package/dist/ui/assets/xai-grok-BnSpWJjV.js +0 -1
  277. package/dist/ui/assets/xterm-BSL5rRqA.js +0 -18
  278. package/dist/ui/assets/xterm-BmfB5bmM.css +0 -1
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./libesm-zfj8k-QN.js";var r=t((e=>{(function(){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 n(e){return i(o(e),arguments)}function r(e,t){return n.apply(null,[e].concat(t||[]))}function i(e,r){var i=1,a=e.length,o,s=``,c,l,u,d,f,p,m,h;for(c=0;c<a;c++)if(typeof e[c]==`string`)s+=e[c];else if(typeof e[c]==`object`){if(u=e[c],u.keys)for(o=r[i],l=0;l<u.keys.length;l++){if(o==null)throw Error(n(`[sprintf] Cannot access property "%s" of undefined value "%s"`,u.keys[l],u.keys[l-1]));o=o[u.keys[l]]}else o=u.param_no?r[u.param_no]:r[i++];if(t.not_type.test(u.type)&&t.not_primitive.test(u.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(u.type)&&typeof o!=`number`&&isNaN(o))throw TypeError(n(`[sprintf] expecting number but found %T`,o));switch(t.number.test(u.type)&&(m=o>=0),u.type){case`b`:o=parseInt(o,10).toString(2);break;case`c`:o=String.fromCharCode(parseInt(o,10));break;case`d`:case`i`:o=parseInt(o,10);break;case`j`:o=JSON.stringify(o,null,u.width?parseInt(u.width):0);break;case`e`:o=u.precision?parseFloat(o).toExponential(u.precision):parseFloat(o).toExponential();break;case`f`:o=u.precision?parseFloat(o).toFixed(u.precision):parseFloat(o);break;case`g`:o=u.precision?String(Number(o.toPrecision(u.precision))):parseFloat(o);break;case`o`:o=(parseInt(o,10)>>>0).toString(8);break;case`s`:o=String(o),o=u.precision?o.substring(0,u.precision):o;break;case`t`:o=String(!!o),o=u.precision?o.substring(0,u.precision):o;break;case`T`:o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=u.precision?o.substring(0,u.precision):o;break;case`u`:o=parseInt(o,10)>>>0;break;case`v`:o=o.valueOf(),o=u.precision?o.substring(0,u.precision):o;break;case`x`:o=(parseInt(o,10)>>>0).toString(16);break;case`X`:o=(parseInt(o,10)>>>0).toString(16).toUpperCase()}t.json.test(u.type)?s+=o:(t.number.test(u.type)&&(!m||u.sign)?(h=m?`+`:`-`,o=o.toString().replace(t.sign,``)):h=``,f=u.pad_char?u.pad_char===`0`?`0`:u.pad_char.charAt(1):` `,p=u.width-(h+o).length,d=u.width&&p>0?f.repeat(p):``,s+=u.align?h+o+d:f===`0`?h+d+o:d+h+o)}return s}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var n=e,r,i=[],o=0;n;){if((r=t.text.exec(n))!==null)i.push(r[0]);else if((r=t.modulo.exec(n))!==null)i.push(`%`);else if((r=t.placeholder.exec(n))!==null){if(r[2]){o|=1;var s=[],c=r[2],l=[];if((l=t.key.exec(c))!==null)for(s.push(l[1]);(c=c.substring(l[0].length))!==``;)if((l=t.key_access.exec(c))!==null)s.push(l[1]);else if((l=t.index_access.exec(c))!==null)s.push(l[1]);else throw SyntaxError(`[sprintf] failed to parse named argument key`);else throw SyntaxError(`[sprintf] failed to parse named argument key`);r[2]=s}else o|=2;if(o===3)throw Error(`[sprintf] mixing positional and named placeholders is not (yet) supported`);i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}else throw SyntaxError(`[sprintf] unexpected placeholder`);n=n.substring(r[0].length)}return a[e]=i}e!==void 0&&(e.sprintf=n,e.vsprintf=r),typeof window<`u`&&(window.sprintf=n,window.vsprintf=r,typeof define==`function`&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()}))();const i=(e,t,n)=>{let r=e instanceof RegExp?a(e,n):e,i=t instanceof RegExp?a(t,n):t,s=r!==null&&i!=null&&o(r,i,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+r.length,s[1]),post:n.slice(s[1]+i.length)}},a=(e,t)=>{let n=t.match(e);return n?n[0]:null},o=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},s=`\0SLASH`+Math.random()+`\0`,c=`\0OPEN`+Math.random()+`\0`,l=`\0CLOSE`+Math.random()+`\0`,u=`\0COMMA`+Math.random()+`\0`,d=`\0PERIOD`+Math.random()+`\0`,f=new RegExp(s,`g`),p=new RegExp(c,`g`),m=new RegExp(l,`g`),h=new RegExp(u,`g`),g=new RegExp(d,`g`),_=/\\\\/g,v=/\\{/g,y=/\\}/g,b=/\\,/g,x=/\\\./g;function S(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function ee(e){return e.replace(_,s).replace(v,c).replace(y,l).replace(b,u).replace(x,d)}function C(e){return e.replace(f,`\\`).replace(p,`{`).replace(m,`}`).replace(h,`,`).replace(g,`.`)}function te(e){if(!e)return[``];let t=[],n=i(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:a,post:o}=n,s=r.split(`,`);s[s.length-1]+=`{`+a+`}`;let c=te(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function ne(e,t={}){if(!e)return[];let{max:n=1e5,maxLength:r=4e6}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),ce(ee(e),n,r,!0).map(C)}function w(e){return`{`+e+`}`}function re(e){return/^-?0\d/.test(e)}function ie(e,t){return e<=t}function ae(e,t){return e>=t}function oe(e,t,n,r,i,a){let o=[],s=0;for(let c=0;c<e.length;c++)for(let l=0;l<n.length;l++){if(o.length>=r)return o;let u=e[c]+t+n[l];if(!(a&&!u)){if(s+u.length>i)return o;o.push(u),s+=u.length}}return o}function se(e,t,n,r){let i=e.split(/\.\./),a=[];if(i[0]===void 0||i[1]===void 0)return a;let o=S(i[0]),s=S(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(S(i[2])),1):1,u=ie;s<o&&(l*=-1,u=ae);let d=i.some(re),f=0;for(let e=o;u(e,s)&&a.length<n;e+=l){let n;if(t)n=String.fromCharCode(e),n===`\\`&&(n=``);else if(n=String(e),d){let t=c-n.length;if(t>0){let r=Array(t+1).join(`0`);n=e<0?`-`+r+n.slice(1):r+n}}if(f+n.length>r)break;a.push(n),f+=n.length}return a}function ce(e,t,n,r){let a=[``],o=!1,s=!0;for(;;){let c=i(`{`,`}`,e);if(!c)return oe(a,e,[``],t,n,o);let u=c.pre;if(/\$$/.test(u)){if(a=oe(a,u+`{`+c.body+`}`,[``],t,n,o&&!c.post.length),s=!1,!c.post.length)break;e=c.post;continue}let d=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(c.body),f=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(c.body),p=d||f,m=c.body.indexOf(`,`)>=0;if(!p&&!m){if(c.post.match(/,(?!,).*\}/)){e=c.pre+`{`+c.body+l+c.post,r=!0;continue}return oe(a,u+`{`+c.body+`}`+c.post,[``],t,n,o)}s&&=(o=r&&!p,!1);let h;if(p)h=se(c.body,f,t,n);else{let r=te(c.body);if(r.length===1&&r[0]!==void 0&&(r=ce(r[0],t,n,!1).map(w),r.length===1)){if(a=oe(a,u+r[0],[``],t,n,o&&!c.post.length),!c.post.length)break;e=c.post;continue}let i=o&&!c.post.length&&!u;for(let e=0;i&&e<a.length;e++)a[e]&&(i=!1);h=[];let s=0;outer:for(let e=0;e<r.length;e++){let a=ce(r[e],t,n,!1);for(let e=0;e<a.length;e++){let r=a[e];if(!(i&&!r)){if(h.length>=t||s+r.length>n)break outer;h.push(r),s+=r.length}}}}if(a=oe(a,u,h,t,n,o&&!c.post.length),!c.post.length)break;e=c.post}return a}const le=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},ue={"[: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]},de=e=>e.replace(/[[\]\\-]/g,`\\$&`),fe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),pe=e=>e.join(``),me=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(ue))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(de(d)+`-`+de(t)):t===d&&r.push(de(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(de(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(de(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let e=r[0].length===2?r[0].slice(-1):r[0];return[fe(e),!1,u-n,!1]}let f=`[`+(l?`^`:``)+pe(r)+`]`,p=`[`+(l?``:`^`)+pe(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},he=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var ge;const _e=new Set([`!`,`?`,`+`,`*`,`@`]),ve=e=>_e.has(e),ye=e=>ve(e.type),be=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),xe=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),Se=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),Ce=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),we=`(?!\\.)`,Te=new Set([`[`,`.`]),Ee=new Set([`..`,`.`]),De=new Set(`().*{}+?[]^$\\!`),Oe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),ke=`[^/]+?`;let Ae=0;var je=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++Ae;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.#l=this.type?this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof ge&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof ge&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new ge(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&ve(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new ge(n,t);u=ge.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new ge(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&ve(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new ge(n,d);d.push(o),u=ge.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new ge(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,xe)}#m(e,t=be){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=Se){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new ge(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!Ce.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=Ce.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new ge(null,void 0,t);return ge.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!ye(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?ge.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&Ee.has(this.#r[0]))){let n=Te,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?we:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,he(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,he(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?we:``)+ke;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?we:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,he(i),this.#t=!!this.#t,this.#n]}#x(){if(ye(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(De.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?ke:`[^/]*?`,t=!0;continue}if(o=!1,c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=me(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=Oe(c)}return[i,he(e),!!t,a]}};ge=je;const Me=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),Ne=(e,t,n={})=>(le(t),!n.nocomment&&t.charAt(0)===`#`?!1:new st(t,n).match(e)),Pe=/^\*+([^+@!?*[(]*)$/,Fe=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Ie=e=>t=>t.endsWith(e),Le=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Re=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ze=/^\*+\.\*+$/,Be=e=>!e.startsWith(`.`)&&e.includes(`.`),Ve=e=>e!==`.`&&e!==`..`&&e.includes(`.`),He=/^\.\*+$/,Ue=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),We=/^\*+$/,Ge=e=>e.length!==0&&!e.startsWith(`.`),Ke=e=>e.length!==0&&e!==`.`&&e!==`..`,qe=/^\?+([^+@!?*[(]*)?$/,Je=([e,t=``])=>{let n=Qe([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Ye=([e,t=``])=>{let n=$e([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Xe=([e,t=``])=>{let n=$e([e]);return t?e=>n(e)&&e.endsWith(t):n},Ze=([e,t=``])=>{let n=Qe([e]);return t?e=>n(e)&&e.endsWith(t):n},Qe=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},$e=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},et=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,tt={win32:{sep:`\\`},posix:{sep:`/`}};Ne.sep=et===`win32`?tt.win32.sep:tt.posix.sep;const nt=Symbol(`globstar **`);Ne.GLOBSTAR=nt,Ne.filter=(e,t={})=>n=>Ne(n,e,t);const rt=(e,t={})=>Object.assign({},e,t);Ne.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return Ne;let t=Ne;return Object.assign((n,r,i={})=>t(n,r,rt(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,rt(e,n))}static defaults(n){return t.defaults(rt(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,rt(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,rt(e,r))}},unescape:(n,r={})=>t.unescape(n,rt(e,r)),escape:(n,r={})=>t.escape(n,rt(e,r)),filter:(n,r={})=>t.filter(n,rt(e,r)),defaults:n=>t.defaults(rt(e,n)),makeRe:(n,r={})=>t.makeRe(n,rt(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,rt(e,r)),match:(n,r,i={})=>t.match(n,r,rt(e,i)),sep:t.sep,GLOBSTAR:nt})};const it=(e,t={})=>(le(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:ne(e,{max:t.braceExpandMax}));Ne.braceExpand=it,Ne.makeRe=(e,t={})=>new st(e,t).makeRe(),Ne.match=(e,t,n={})=>{let r=new st(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const at=/[?*]|[+@!]\(.*?\)|\[|\]/,ot=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var st=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){le(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||et,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,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 t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!at.test(e[2]))&&!at.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t of e)for(let e=0;e<t.length;e++)t[e]===`**`&&(t[e]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];(n!==1||r!==``||e[0]!==``)&&(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];(e!==1||r!==``||n[0]!==``)&&(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(nt)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(nt,i),o=t.lastIndexOf(nt),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===nt?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===nt)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return it(this.pattern,this.options)}parse(e){le(e);let t=this.options;if(e===`**`)return nt;if(e===``)return``;let n,r=null;(n=e.match(We))?r=t.dot?Ke:Ge:(n=e.match(Pe))?r=(t.nocase?t.dot?Re:Le:t.dot?Ie:Fe)(n[1]):(n=e.match(qe))?r=(t.nocase?t.dot?Ye:Je:t.dot?Xe:Ze)(n):(n=e.match(ze))?r=t.dot?Ve:Be:(n=e.match(He))&&(r=Ue);let i=je.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),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 t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?ot(e):e===nt?nt:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e===nt&&a!==nt&&(a===void 0?i!==void 0&&i!==nt?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==nt&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=nt))});let i=t.filter(e=>e!==nt);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].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,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return Ne.defaults(e).Minimatch}};Ne.AST=je,Ne.Minimatch=st,Ne.escape=Me,Ne.unescape=he;const ct={};function lt(){throw Error(`gunzipSync is not available in the browser`)}function ut(){throw Error(`gzipSync is not available in the browser`)}function dt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}function ft(e,t){return Array(t+1).join(e)}function pt(e){return e.replace(/^\n*/,``)}function mt(e){for(var t=e.length;t>0&&e[t-1]===`
1
+ import{n as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./libesm-CSMdpGMF.js";var r=t((e=>{(function(){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 n(e){return i(o(e),arguments)}function r(e,t){return n.apply(null,[e].concat(t||[]))}function i(e,r){var i=1,a=e.length,o,s=``,c,l,u,d,f,p,m,h;for(c=0;c<a;c++)if(typeof e[c]==`string`)s+=e[c];else if(typeof e[c]==`object`){if(u=e[c],u.keys)for(o=r[i],l=0;l<u.keys.length;l++){if(o==null)throw Error(n(`[sprintf] Cannot access property "%s" of undefined value "%s"`,u.keys[l],u.keys[l-1]));o=o[u.keys[l]]}else o=u.param_no?r[u.param_no]:r[i++];if(t.not_type.test(u.type)&&t.not_primitive.test(u.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(u.type)&&typeof o!=`number`&&isNaN(o))throw TypeError(n(`[sprintf] expecting number but found %T`,o));switch(t.number.test(u.type)&&(m=o>=0),u.type){case`b`:o=parseInt(o,10).toString(2);break;case`c`:o=String.fromCharCode(parseInt(o,10));break;case`d`:case`i`:o=parseInt(o,10);break;case`j`:o=JSON.stringify(o,null,u.width?parseInt(u.width):0);break;case`e`:o=u.precision?parseFloat(o).toExponential(u.precision):parseFloat(o).toExponential();break;case`f`:o=u.precision?parseFloat(o).toFixed(u.precision):parseFloat(o);break;case`g`:o=u.precision?String(Number(o.toPrecision(u.precision))):parseFloat(o);break;case`o`:o=(parseInt(o,10)>>>0).toString(8);break;case`s`:o=String(o),o=u.precision?o.substring(0,u.precision):o;break;case`t`:o=String(!!o),o=u.precision?o.substring(0,u.precision):o;break;case`T`:o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=u.precision?o.substring(0,u.precision):o;break;case`u`:o=parseInt(o,10)>>>0;break;case`v`:o=o.valueOf(),o=u.precision?o.substring(0,u.precision):o;break;case`x`:o=(parseInt(o,10)>>>0).toString(16);break;case`X`:o=(parseInt(o,10)>>>0).toString(16).toUpperCase()}t.json.test(u.type)?s+=o:(t.number.test(u.type)&&(!m||u.sign)?(h=m?`+`:`-`,o=o.toString().replace(t.sign,``)):h=``,f=u.pad_char?u.pad_char===`0`?`0`:u.pad_char.charAt(1):` `,p=u.width-(h+o).length,d=u.width&&p>0?f.repeat(p):``,s+=u.align?h+o+d:f===`0`?h+d+o:d+h+o)}return s}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var n=e,r,i=[],o=0;n;){if((r=t.text.exec(n))!==null)i.push(r[0]);else if((r=t.modulo.exec(n))!==null)i.push(`%`);else if((r=t.placeholder.exec(n))!==null){if(r[2]){o|=1;var s=[],c=r[2],l=[];if((l=t.key.exec(c))!==null)for(s.push(l[1]);(c=c.substring(l[0].length))!==``;)if((l=t.key_access.exec(c))!==null)s.push(l[1]);else if((l=t.index_access.exec(c))!==null)s.push(l[1]);else throw SyntaxError(`[sprintf] failed to parse named argument key`);else throw SyntaxError(`[sprintf] failed to parse named argument key`);r[2]=s}else o|=2;if(o===3)throw Error(`[sprintf] mixing positional and named placeholders is not (yet) supported`);i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}else throw SyntaxError(`[sprintf] unexpected placeholder`);n=n.substring(r[0].length)}return a[e]=i}e!==void 0&&(e.sprintf=n,e.vsprintf=r),typeof window<`u`&&(window.sprintf=n,window.vsprintf=r,typeof define==`function`&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()}))();const i=(e,t,n)=>{let r=e instanceof RegExp?a(e,n):e,i=t instanceof RegExp?a(t,n):t,s=r!==null&&i!=null&&o(r,i,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+r.length,s[1]),post:n.slice(s[1]+i.length)}},a=(e,t)=>{let n=t.match(e);return n?n[0]:null},o=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},s=`\0SLASH`+Math.random()+`\0`,c=`\0OPEN`+Math.random()+`\0`,l=`\0CLOSE`+Math.random()+`\0`,u=`\0COMMA`+Math.random()+`\0`,d=`\0PERIOD`+Math.random()+`\0`,f=new RegExp(s,`g`),p=new RegExp(c,`g`),m=new RegExp(l,`g`),h=new RegExp(u,`g`),g=new RegExp(d,`g`),_=/\\\\/g,v=/\\{/g,y=/\\}/g,b=/\\,/g,x=/\\\./g;function S(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function ee(e){return e.replace(_,s).replace(v,c).replace(y,l).replace(b,u).replace(x,d)}function C(e){return e.replace(f,`\\`).replace(p,`{`).replace(m,`}`).replace(h,`,`).replace(g,`.`)}function te(e){if(!e)return[``];let t=[],n=i(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:a,post:o}=n,s=r.split(`,`);s[s.length-1]+=`{`+a+`}`;let c=te(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function ne(e,t={}){if(!e)return[];let{max:n=1e5,maxLength:r=4e6}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),ce(ee(e),n,r,!0).map(C)}function w(e){return`{`+e+`}`}function re(e){return/^-?0\d/.test(e)}function ie(e,t){return e<=t}function ae(e,t){return e>=t}function oe(e,t,n,r,i,a){let o=[],s=0;for(let c=0;c<e.length;c++)for(let l=0;l<n.length;l++){if(o.length>=r)return o;let u=e[c]+t+n[l];if(!(a&&!u)){if(s+u.length>i)return o;o.push(u),s+=u.length}}return o}function se(e,t,n,r){let i=e.split(/\.\./),a=[];if(i[0]===void 0||i[1]===void 0)return a;let o=S(i[0]),s=S(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(S(i[2])),1):1,u=ie;s<o&&(l*=-1,u=ae);let d=i.some(re),f=0;for(let e=o;u(e,s)&&a.length<n;e+=l){let n;if(t)n=String.fromCharCode(e),n===`\\`&&(n=``);else if(n=String(e),d){let t=c-n.length;if(t>0){let r=Array(t+1).join(`0`);n=e<0?`-`+r+n.slice(1):r+n}}if(f+n.length>r)break;a.push(n),f+=n.length}return a}function ce(e,t,n,r){let a=[``],o=!1,s=!0;for(;;){let c=i(`{`,`}`,e);if(!c)return oe(a,e,[``],t,n,o);let u=c.pre;if(/\$$/.test(u)){if(a=oe(a,u+`{`+c.body+`}`,[``],t,n,o&&!c.post.length),s=!1,!c.post.length)break;e=c.post;continue}let d=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(c.body),f=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(c.body),p=d||f,m=c.body.indexOf(`,`)>=0;if(!p&&!m){if(c.post.match(/,(?!,).*\}/)){e=c.pre+`{`+c.body+l+c.post,r=!0;continue}return oe(a,u+`{`+c.body+`}`+c.post,[``],t,n,o)}s&&=(o=r&&!p,!1);let h;if(p)h=se(c.body,f,t,n);else{let r=te(c.body);if(r.length===1&&r[0]!==void 0&&(r=ce(r[0],t,n,!1).map(w),r.length===1)){if(a=oe(a,u+r[0],[``],t,n,o&&!c.post.length),!c.post.length)break;e=c.post;continue}let i=o&&!c.post.length&&!u;for(let e=0;i&&e<a.length;e++)a[e]&&(i=!1);h=[];let s=0;outer:for(let e=0;e<r.length;e++){let a=ce(r[e],t,n,!1);for(let e=0;e<a.length;e++){let r=a[e];if(!(i&&!r)){if(h.length>=t||s+r.length>n)break outer;h.push(r),s+=r.length}}}}if(a=oe(a,u,h,t,n,o&&!c.post.length),!c.post.length)break;e=c.post}return a}const le=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},ue={"[: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]},de=e=>e.replace(/[[\]\\-]/g,`\\$&`),fe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),pe=e=>e.join(``),me=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(ue))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(de(d)+`-`+de(t)):t===d&&r.push(de(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(de(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(de(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let e=r[0].length===2?r[0].slice(-1):r[0];return[fe(e),!1,u-n,!1]}let f=`[`+(l?`^`:``)+pe(r)+`]`,p=`[`+(l?``:`^`)+pe(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},he=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var ge;const _e=new Set([`!`,`?`,`+`,`*`,`@`]),ve=e=>_e.has(e),ye=e=>ve(e.type),be=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),xe=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),Se=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),Ce=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),we=`(?!\\.)`,Te=new Set([`[`,`.`]),Ee=new Set([`..`,`.`]),De=new Set(`().*{}+?[]^$\\!`),Oe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),ke=`[^/]+?`;let Ae=0;var je=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++Ae;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.#l=this.type?this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof ge&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof ge&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new ge(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&ve(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new ge(n,t);u=ge.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new ge(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&ve(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new ge(n,d);d.push(o),u=ge.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new ge(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,xe)}#m(e,t=be){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=Se){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new ge(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!Ce.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=Ce.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new ge(null,void 0,t);return ge.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!ye(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?ge.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&Ee.has(this.#r[0]))){let n=Te,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?we:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,he(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,he(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?we:``)+ke;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?we:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,he(i),this.#t=!!this.#t,this.#n]}#x(){if(ye(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(De.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?ke:`[^/]*?`,t=!0;continue}if(o=!1,c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=me(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=Oe(c)}return[i,he(e),!!t,a]}};ge=je;const Me=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),Ne=(e,t,n={})=>(le(t),!n.nocomment&&t.charAt(0)===`#`?!1:new st(t,n).match(e)),Pe=/^\*+([^+@!?*[(]*)$/,Fe=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Ie=e=>t=>t.endsWith(e),Le=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Re=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ze=/^\*+\.\*+$/,Be=e=>!e.startsWith(`.`)&&e.includes(`.`),Ve=e=>e!==`.`&&e!==`..`&&e.includes(`.`),He=/^\.\*+$/,Ue=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),We=/^\*+$/,Ge=e=>e.length!==0&&!e.startsWith(`.`),Ke=e=>e.length!==0&&e!==`.`&&e!==`..`,qe=/^\?+([^+@!?*[(]*)?$/,Je=([e,t=``])=>{let n=Qe([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Ye=([e,t=``])=>{let n=$e([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Xe=([e,t=``])=>{let n=$e([e]);return t?e=>n(e)&&e.endsWith(t):n},Ze=([e,t=``])=>{let n=Qe([e]);return t?e=>n(e)&&e.endsWith(t):n},Qe=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},$e=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},et=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,tt={win32:{sep:`\\`},posix:{sep:`/`}};Ne.sep=et===`win32`?tt.win32.sep:tt.posix.sep;const nt=Symbol(`globstar **`);Ne.GLOBSTAR=nt,Ne.filter=(e,t={})=>n=>Ne(n,e,t);const rt=(e,t={})=>Object.assign({},e,t);Ne.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return Ne;let t=Ne;return Object.assign((n,r,i={})=>t(n,r,rt(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,rt(e,n))}static defaults(n){return t.defaults(rt(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,rt(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,rt(e,r))}},unescape:(n,r={})=>t.unescape(n,rt(e,r)),escape:(n,r={})=>t.escape(n,rt(e,r)),filter:(n,r={})=>t.filter(n,rt(e,r)),defaults:n=>t.defaults(rt(e,n)),makeRe:(n,r={})=>t.makeRe(n,rt(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,rt(e,r)),match:(n,r,i={})=>t.match(n,r,rt(e,i)),sep:t.sep,GLOBSTAR:nt})};const it=(e,t={})=>(le(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:ne(e,{max:t.braceExpandMax}));Ne.braceExpand=it,Ne.makeRe=(e,t={})=>new st(e,t).makeRe(),Ne.match=(e,t,n={})=>{let r=new st(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const at=/[?*]|[+@!]\(.*?\)|\[|\]/,ot=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var st=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){le(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||et,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,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 t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!at.test(e[2]))&&!at.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t of e)for(let e=0;e<t.length;e++)t[e]===`**`&&(t[e]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];(n!==1||r!==``||e[0]!==``)&&(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];(e!==1||r!==``||n[0]!==``)&&(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(nt)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(nt,i),o=t.lastIndexOf(nt),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===nt?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===nt)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return it(this.pattern,this.options)}parse(e){le(e);let t=this.options;if(e===`**`)return nt;if(e===``)return``;let n,r=null;(n=e.match(We))?r=t.dot?Ke:Ge:(n=e.match(Pe))?r=(t.nocase?t.dot?Re:Le:t.dot?Ie:Fe)(n[1]):(n=e.match(qe))?r=(t.nocase?t.dot?Ye:Je:t.dot?Xe:Ze)(n):(n=e.match(ze))?r=t.dot?Ve:Be:(n=e.match(He))&&(r=Ue);let i=je.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),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 t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?ot(e):e===nt?nt:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e===nt&&a!==nt&&(a===void 0?i!==void 0&&i!==nt?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==nt&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=nt))});let i=t.filter(e=>e!==nt);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].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,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return Ne.defaults(e).Minimatch}};Ne.AST=je,Ne.Minimatch=st,Ne.escape=Me,Ne.unescape=he;const ct={};function lt(){throw Error(`gunzipSync is not available in the browser`)}function ut(){throw Error(`gzipSync is not available in the browser`)}function dt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}function ft(e,t){return Array(t+1).join(e)}function pt(e){return e.replace(/^\n*/,``)}function mt(e){for(var t=e.length;t>0&&e[t-1]===`
2
2
  `;)t--;return e.substring(0,t)}function ht(e){return mt(pt(e))}var gt=`ADDRESS.ARTICLE.ASIDE.AUDIO.BLOCKQUOTE.BODY.CANVAS.CENTER.DD.DIR.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.FRAMESET.H1.H2.H3.H4.H5.H6.HEADER.HGROUP.HR.HTML.ISINDEX.LI.MAIN.MENU.NAV.NOFRAMES.NOSCRIPT.OL.OUTPUT.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL`.split(`.`);function _t(e){return wt(e,gt)}var vt=[`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`];function yt(e){return wt(e,vt)}function bt(e){return Tt(e,vt)}var xt=[`A`,`TABLE`,`THEAD`,`TBODY`,`TFOOT`,`TH`,`TD`,`IFRAME`,`SCRIPT`,`AUDIO`,`VIDEO`];function St(e){return wt(e,xt)}function Ct(e){return Tt(e,xt)}function wt(e,t){return t.indexOf(e.nodeName)>=0}function Tt(e,t){return e.getElementsByTagName&&t.some(function(t){return e.getElementsByTagName(t).length})}var Et=[[/\\/g,`\\\\`],[/\*/g,`\\*`],[/^-/g,`\\-`],[/^\+ /g,`\\+ `],[/^(=+)/g,`\\$1`],[/^(#{1,6}) /g,`\\$1 `],[/`/g,"\\`"],[/^~~~/g,`\\~~~`],[/\[/g,`\\[`],[/\]/g,`\\]`],[/^>/g,`\\>`],[/_/g,`\\_`],[/^(\d+)\. /g,`$1\\. `]];function Dt(e){return Et.reduce(function(e,t){return e.replace(t[0],t[1])},e)}var Ot={};Ot.paragraph={filter:`p`,replacement:function(e){return`
3
3
 
4
4
  `+e+`
@@ -100,14 +100,14 @@ Notes:
100
100
  `:`
101
101
  `)}return o}var ni,ri,ii,ai,oi=T(()=>{k(),Wr(),j(),Kr(),Zr(),F(),ni={name:`cat`,summary:`concatenate files and print on the standard output`,usage:`cat [OPTION]... [FILE]...`,options:[`-A, --show-all equivalent to -vET`,`-b, --number-nonblank number nonempty output lines, overrides -n`,`-e equivalent to -vE`,`-E, --show-ends display $ at end of each line`,`-n, --number number all output lines`,`-s, --squeeze-blank suppress repeated empty output lines`,`-t equivalent to -vT`,`-T, --show-tabs display TAB characters as ^I`,`-u (ignored)`,`-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB`,` --help display this help and exit`]},ri={number:{short:`n`,long:`number`,type:`boolean`},numberNonblank:{short:`b`,long:`number-nonblank`,type:`boolean`},showEnds:{short:`E`,long:`show-ends`,type:`boolean`},showTabs:{short:`T`,long:`show-tabs`,type:`boolean`},showNonprinting:{short:`v`,long:`show-nonprinting`,type:`boolean`},showAll:{short:`A`,long:`show-all`,type:`boolean`},squeeze:{short:`s`,long:`squeeze-blank`,type:`boolean`},vE:{short:`e`,type:`boolean`},vT:{short:`t`,type:`boolean`},ignored:{short:`u`,type:`boolean`}},ii={name:`cat`,async execute(e,t){if(N(e))return M(ni);let n=Gr(`cat`,e,ri);if(!n.ok)return n.error;let r=n.result.flags,i=r.showEnds||r.showAll||r.vE,a=r.showTabs||r.showAll||r.vT,o=r.showNonprinting||r.showAll||r.vE||r.vT,s=r.squeeze,c=r.numberNonblank,l=r.number&&!c,u={numberAll:l,numberNonblank:c,showEnds:i,showTabs:a,showNonprinting:o,squeeze:s},d=n.result.positional,f=t.limits.maxStringLength,p=Math.min(f,t.limits.maxOutputSize),m=d.length===0?[`-`]:d,h=``,g=0,_=0,v,y=i||a||o||s||l||c,b=``;for(let e of m)try{let n=e===`-`?t.stdin:await lr(t.fs,t.fs.resolvePath(t.cwd,e)),r=n.length,i=Math.min(y?f:p,t.limits.maxInputBytes);if(r>i-_)throw new A(`cat: ${y?`input`:`output`} size limit exceeded (${i} bytes)`,y?`string_length`:`output_size`);e!==`-`&&Jr(t,r,`cat`),_+=r,b+=n}catch(t){Ur(t),h+=`cat: ${e}: No such file or directory
102
102
  `,g=1}return v=y?ti(b,u,p,t.limits.maxArrayElements):b,{stdout:v,stderr:h,exitCode:g,stdoutEncoding:`binary`}}},ai={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}});function si(e){return e instanceof Error?e.message:String(e)}var ci=T(()=>{});function li(e,t,n,r={}){let i=new Date(t*1e3),a=ui(i,n),o=``,s=0,c=0,l=0,u=new Map,d=e=>{let t=O(e);if(r.maxOutputBytes!==void 0&&t>r.maxOutputBytes-s)throw new A(`strftime: output size limit exceeded (${r.maxOutputBytes} bytes)`,`output_size`);o+=e,s+=t};for(;c<e.length;){if(l++,r.maxOperations!==void 0&&l>r.maxOperations)throw new A(`strftime: iteration limit exceeded (${r.maxOperations})`,`iterations`);if(e[c]===`%`&&c+1<e.length){let t=e[c+1],r;u.has(t)?r=u.get(t)??null:(r=di(i,a,t,n),u.set(t,r)),r===null?(d(e[c]),c++):(d(r),c+=2)}else d(e[c]),c++}return o}function ui(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,weekday:`short`,hour12:!1,timeZone:t};try{let t=new Intl.DateTimeFormat(`en-US`,n).formatToParts(e),r=e=>t.find(t=>t.type===e)?.value??``,i=new Map([[`Sun`,0],[`Mon`,1],[`Tue`,2],[`Wed`,3],[`Thu`,4],[`Fri`,5],[`Sat`,6]]),a=r(`weekday`),o=(e,t)=>{let n=Number.parseInt(e,10);return Number.isNaN(n)?t:n};return{year:o(r(`year`),e.getFullYear()),month:o(r(`month`),e.getMonth()+1),day:o(r(`day`),e.getDate()),hour:o(r(`hour`),e.getHours())%24,minute:o(r(`minute`),e.getMinutes()),second:o(r(`second`),e.getSeconds()),weekday:i.get(a)??e.getDay()}}catch{return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),weekday:e.getDay()}}}function di(e,t,n,r){let i=(e,t=2)=>String(e).padStart(t,`0`),a=mi(t.year,t.month,t.day),o=hi(t.year,t.month,t.day,t.weekday,0),s=hi(t.year,t.month,t.day,t.weekday,1);switch(n){case`a`:return[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.weekday];case`A`:return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`][t.weekday];case`b`:case`h`:return[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.month-1];case`B`:return[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`][t.month-1];case`c`:return`${[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.weekday]} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.month-1]} ${String(t.day).padStart(2,` `)} ${i(t.hour)}:${i(t.minute)}:${i(t.second)} ${t.year}`;case`C`:return i(Math.floor(t.year/100));case`d`:return i(t.day);case`D`:return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case`e`:return String(t.day).padStart(2,` `);case`F`:return`${t.year}-${i(t.month)}-${i(t.day)}`;case`g`:return i(_i(t.year,t.month,t.day)%100);case`G`:return String(_i(t.year,t.month,t.day));case`H`:return i(t.hour);case`I`:return i(t.hour%12||12);case`j`:return String(a).padStart(3,`0`);case`k`:return String(t.hour).padStart(2,` `);case`l`:return String(t.hour%12||12).padStart(2,` `);case`m`:return i(t.month);case`M`:return i(t.minute);case`n`:return`
103
- `;case`N`:return`000000000`;case`p`:return t.hour<12?`AM`:`PM`;case`P`:return t.hour<12?`am`:`pm`;case`r`:return`${i(t.hour%12||12)}:${i(t.minute)}:${i(t.second)} ${t.hour<12?`AM`:`PM`}`;case`R`:return`${i(t.hour)}:${i(t.minute)}`;case`s`:return String(Math.floor(e.getTime()/1e3));case`S`:return i(t.second);case`t`:return` `;case`T`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`u`:return String(t.weekday===0?7:t.weekday);case`U`:return i(o);case`V`:return i(gi(t.year,t.month,t.day));case`w`:return String(t.weekday);case`W`:return i(s);case`x`:return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case`X`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`y`:return i(t.year%100);case`Y`:return String(t.year);case`z`:return fi(e,r);case`Z`:return pi(e,r);case`%`:return`%`;default:return null}}function fi(e,t){if(!t){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.floor(Math.abs(t)/60),i=Math.abs(t)%60;return`${n}${String(r).padStart(2,`0`)}${String(i).padStart(2,`0`)}`}try{let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`longOffset`}).formatToParts(e).find(e=>e.type===`timeZoneName`);if(n){let e=n.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(e)return`${e[1]}${e[2]}${e[3]}`;if(n.value===`GMT`||n.value===`UTC`)return`+0000`}}catch{}let n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`,i=Math.floor(Math.abs(n)/60),a=Math.abs(n)%60;return`${r}${String(i).padStart(2,`0`)}${String(a).padStart(2,`0`)}`}function pi(e,t){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??`UTC`}catch{return`UTC`}}function mi(e,t,n){let r=[31,28,31,30,31,30,31,31,30,31,30,31];(e%4==0&&e%100!=0||e%400==0)&&(r[1]=29);let i=n;for(let e=0;e<t-1;e++)i+=r[e];return i}function hi(e,t,n,r,i){let a=mi(e,t,n),o=new Date(e,0,1).getDay(),s=a-(1+(7+i-o)%7);return s<0?0:Math.floor(s/7)+1}function gi(e,t,n){let r=new Date(e,t-1,n,12,0,0);r.setDate(r.getDate()+3-(r.getDay()+6)%7);let i=new Date(r.getFullYear(),0,4);i.setDate(i.getDate()+3-(i.getDay()+6)%7);let a=r.getTime()-i.getTime();return 1+Math.round(a/6048e5)}function _i(e,t,n){let r=new Date(e,t-1,n,12,0,0);return r.setDate(r.getDate()+3-(r.getDay()+6)%7),r.getFullYear()}var vi=T(()=>{j(),Lr()}),yi={};E(yi,{flagsForFuzzing:()=>Ii,printfCommand:()=>Pi});function bi(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function xi(e,t,n,r,i=10485760){let a=``,o=0,s=0,c=!1,l=``,u=0,d=e=>{let t=O(e);if(t>i-u)throw new A(`printf: output size limit exceeded (${i} bytes)`,`string_length`);a+=e,u+=t};for(;o<e.length;)if(e[o]===`%`&&o+1<e.length){let f=o;if(o++,e[o]===`%`){d(`%`),o++;continue}let p=e.slice(f).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(p){let e=p[1]?parseInt(p[1],10):0,a=p[2]?parseInt(p[2],10):-1;Mr(e,i,`width`),a!==-1&&Mr(a,i,`precision`);let c=p[3],l=p[0],m=t[n+s]||``;s++;let h;h=m===``||m===`-1`||m===`-2`?Math.floor(Date.now()/1e3):parseInt(m,10)||0;let g=li(c,h,r,{maxOperations:i-u,maxOutputBytes:i-u});g=Nr(g,e,a,i-u),d(g),o=f+l.length;continue}for(;o<e.length&&`+-0 #'`.includes(e[o]);)o++;let m=!1;if(e[o]===`*`)m=!0,o++;else for(;o<e.length&&/\d/.test(e[o]);)o++;let h=!1;if(e[o]===`.`)if(o++,e[o]===`*`)h=!0,o++;else for(;o<e.length&&/\d/.test(e[o]);)o++;o<e.length&&`hlL`.includes(e[o])&&o++;let g=e[o]||``;o++;let _=e.slice(f,o);if(m){let e=parseInt(t[n+s]||`0`,10);Mr(e,i-u,`width`),s++,_=_.replace(`*`,String(e))}if(h){let e=parseInt(t[n+s]||`0`,10);e>=0?Mr(e,i-u,`precision`):Number.isSafeInteger(e)||Mr(e,i-u,`precision`),s++,_=_.replace(`.*`,`.${e}`)}Ci(_,i-u);let v=t[n+s]||``;s++;let{value:y,parseError:b,parseErrMsg:x,stopped:S}=Si(_,g,v,i-u);if(d(y),b&&(c=!0,x&&(l=x)),S)return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!0}}else d(e[o]),o++;return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!1}}function Si(e,t,n,i){let a=!1,o=``;switch(t){case`d`:case`i`:{let t=wi(n);return a=Fi,a&&(o=`printf: ${n}: invalid number
103
+ `;case`N`:return`000000000`;case`p`:return t.hour<12?`AM`:`PM`;case`P`:return t.hour<12?`am`:`pm`;case`r`:return`${i(t.hour%12||12)}:${i(t.minute)}:${i(t.second)} ${t.hour<12?`AM`:`PM`}`;case`R`:return`${i(t.hour)}:${i(t.minute)}`;case`s`:return String(Math.floor(e.getTime()/1e3));case`S`:return i(t.second);case`t`:return` `;case`T`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`u`:return String(t.weekday===0?7:t.weekday);case`U`:return i(o);case`V`:return i(gi(t.year,t.month,t.day));case`w`:return String(t.weekday);case`W`:return i(s);case`x`:return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case`X`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`y`:return i(t.year%100);case`Y`:return String(t.year);case`z`:return fi(e,r);case`Z`:return pi(e,r);case`%`:return`%`;default:return null}}function fi(e,t){if(!t){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.floor(Math.abs(t)/60),i=Math.abs(t)%60;return`${n}${String(r).padStart(2,`0`)}${String(i).padStart(2,`0`)}`}try{let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`longOffset`}).formatToParts(e).find(e=>e.type===`timeZoneName`);if(n){let e=n.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(e)return`${e[1]}${e[2]}${e[3]}`;if(n.value===`GMT`||n.value===`UTC`)return`+0000`}}catch{}let n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`,i=Math.floor(Math.abs(n)/60),a=Math.abs(n)%60;return`${r}${String(i).padStart(2,`0`)}${String(a).padStart(2,`0`)}`}function pi(e,t){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??`UTC`}catch{return`UTC`}}function mi(e,t,n){let r=[31,28,31,30,31,30,31,31,30,31,30,31];(e%4==0&&e%100!=0||e%400==0)&&(r[1]=29);let i=n;for(let e=0;e<t-1;e++)i+=r[e];return i}function hi(e,t,n,r,i){let a=mi(e,t,n),o=new Date(e,0,1).getDay(),s=a-(1+(7+i-o)%7);return s<0?0:Math.floor(s/7)+1}function gi(e,t,n){let r=new Date(e,t-1,n,12,0,0);r.setDate(r.getDate()+3-(r.getDay()+6)%7);let i=new Date(r.getFullYear(),0,4);i.setDate(i.getDate()+3-(i.getDay()+6)%7);let a=r.getTime()-i.getTime();return 1+Math.round(a/6048e5)}function _i(e,t,n){let r=new Date(e,t-1,n,12,0,0);return r.setDate(r.getDate()+3-(r.getDay()+6)%7),r.getFullYear()}var vi=T(()=>{j(),Lr()}),yi={};E(yi,{flagsForFuzzing:()=>Ii,printfCommand:()=>Pi});function bi(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function xi(e,t,n,r,i=10485760){let a=``,o=0,s=0,c=!1,l=``,u=0,d=e=>{let t=O(e);if(t>i-u)throw new A(`printf: output size limit exceeded (${i} bytes)`,`string_length`);a+=e,u+=t};for(;o<e.length;)if(e[o]===`%`&&o+1<e.length){let f=o;if(o++,e[o]===`%`){d(`%`),o++;continue}let p=e.slice(f).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(p){let e=p[1]?parseInt(p[1],10):0,a=p[2]?parseInt(p[2],10):-1;Mr(e,i,`width`),a!==-1&&Mr(a,i,`precision`);let c=p[3],l=p[0],m=t[n+s]||``;s++;let h;h=m===``||m===`-1`||m===`-2`?Math.floor(Date.now()/1e3):parseInt(m,10)||0;let g=li(c,h,r,{maxOperations:i-u,maxOutputBytes:i-u});g=Nr(g,e,a,i-u),d(g),o=f+l.length;continue}for(;o<e.length&&`+-0 #'`.includes(e[o]);)o++;let m=!1;if(e[o]===`*`)m=!0,o++;else for(;o<e.length&&/\d/.test(e[o]);)o++;let h=!1;if(e[o]===`.`){if(o++,e[o]===`*`)h=!0,o++;else for(;o<e.length&&/\d/.test(e[o]);)o++}o<e.length&&`hlL`.includes(e[o])&&o++;let g=e[o]||``;o++;let _=e.slice(f,o);if(m){let e=parseInt(t[n+s]||`0`,10);Mr(e,i-u,`width`),s++,_=_.replace(`*`,String(e))}if(h){let e=parseInt(t[n+s]||`0`,10);e>=0?Mr(e,i-u,`precision`):Number.isSafeInteger(e)||Mr(e,i-u,`precision`),s++,_=_.replace(`.*`,`.${e}`)}Ci(_,i-u);let v=t[n+s]||``;s++;let{value:y,parseError:b,parseErrMsg:x,stopped:S}=Si(_,g,v,i-u);if(d(y),b&&(c=!0,x&&(l=x)),S)return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!0}}else d(e[o]),o++;return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!1}}function Si(e,t,n,i){let a=!1,o=``;switch(t){case`d`:case`i`:{let t=wi(n);return a=Fi,a&&(o=`printf: ${n}: invalid number
104
104
  `),{value:Ti(e,t),parseError:a,parseErrMsg:o}}case`o`:{let t=wi(n);return a=Fi,a&&(o=`printf: ${n}: invalid number
105
105
  `),{value:Ei(e,t),parseError:a,parseErrMsg:o}}case`u`:{let t=wi(n);a=Fi,a&&(o=`printf: ${n}: invalid number
106
106
  `);let r=t<0?t>>>0:t;return{value:Ti(e.replace(`u`,`d`),r),parseError:a,parseErrMsg:o}}case`x`:case`X`:{let t=wi(n);return a=Fi,a&&(o=`printf: ${n}: invalid number
107
107
  `),{value:Di(e,t),parseError:a,parseErrMsg:o}}case`e`:case`E`:case`f`:case`F`:case`g`:case`G`:return{value:ji(e,t,parseFloat(n)||0),parseError:!1,parseErrMsg:``};case`c`:{if(n===``)return{value:``,parseError:!1,parseErrMsg:``};let e=new TextEncoder().encode(n)[0];return{value:String.fromCharCode(e),parseError:!1,parseErrMsg:``}}case`s`:return{value:ki(e,n,i),parseError:!1,parseErrMsg:``};case`q`:return{value:Ai(e,n,i),parseError:!1,parseErrMsg:``};case`b`:{let e=Mi(n,i);return{value:e.value,parseError:!1,parseErrMsg:``,stopped:e.stopped}}default:try{return{value:(0,r.sprintf)(e,n),parseError:!1,parseErrMsg:``}}catch{return{value:``,parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
108
108
  `}}}}function Ci(e,t){let n=e.match(/^%[-+0 #' ]*(\d*)(?:\.(\d*))?/);if(!n)return;let r=n[1]?Number(n[1]):0,i=n[2]===void 0?-1:Number(n[2]);Mr(r,t,`width`),i!==-1&&Mr(i,t,`precision`)}function wi(e){Fi=!1;let t=e.trimStart(),n=t!==t.trimEnd();if(e=t.trimEnd(),e.startsWith(`'`)&&e.length>=2||e.startsWith(`"`)&&e.length>=2)return e.charCodeAt(1);if(e.startsWith(`\\'`)&&e.length>=3||e.startsWith(`\\"`)&&e.length>=3)return e.charCodeAt(2);if(e.startsWith(`+`)&&(e=e.slice(1)),e.startsWith(`0x`)||e.startsWith(`0X`)){let t=parseInt(e,16);return Number.isNaN(t)?(Fi=!0,0):(n&&(Fi=!0),t)}if(e.startsWith(`0`)&&e.length>1&&/^-?0[0-7]+$/.test(e))return n&&(Fi=!0),parseInt(e,8)||0;if(/^\d+#/.test(e)){Fi=!0;let t=e.match(/^(\d+)#/);return t?parseInt(t[1],10):0}if(e!==``&&!/^-?\d+$/.test(e)){Fi=!0;let t=parseInt(e,10);return Number.isNaN(t)?0:t}return n&&(Fi=!0),parseInt(e,10)||0}function Ti(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return(0,r.sprintf)(e.replace(/\.\d*/,``),t);let i=n[1]||``,a=n[2]?parseInt(n[2],10):0,o=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0,s=t<0,c=String(Math.abs(t));o>=0&&(c=c.padStart(o,`0`));let l=``;s?l=`-`:i.includes(`+`)?l=`+`:i.includes(` `)&&(l=` `);let u=l+c;return a>u.length&&(u=i.includes(`-`)?u.padEnd(a,` `):i.includes(`0`)&&o<0?l+c.padStart(a-l.length,`0`):u.padStart(a,` `)),u}function Ei(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return(0,r.sprintf)(e,t);let i=n[1]||``,a=n[2]?parseInt(n[2],10):0,o=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0,s=Math.abs(t).toString(8);o>=0&&(s=s.padStart(o,`0`)),i.includes(`#`)&&!s.startsWith(`0`)&&(s=`0${s}`);let c=s;return a>c.length&&(c=i.includes(`-`)?c.padEnd(a,` `):i.includes(`0`)&&o<0?c.padStart(a,`0`):c.padStart(a,` `)),c}function Di(e,t){let n=e.includes(`X`),i=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!i)return(0,r.sprintf)(e,t);let a=i[1]||``,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?-1:i[4]?parseInt(i[4],10):0,c=Math.abs(t).toString(16);n&&(c=c.toUpperCase()),s>=0&&(c=c.padStart(s,`0`));let l=``;a.includes(`#`)&&t!==0&&(l=n?`0X`:`0x`);let u=l+c;return o>u.length&&(u=a.includes(`-`)?u.padEnd(o,` `):a.includes(`0`)&&s<0?l+c.padStart(o-l.length,`0`):u.padStart(o,` `)),u}function Oi(e,t){if(e===``){if(t<2)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`);return`''`}if(/^[a-zA-Z0-9_./-]+$/.test(e)){if(O(e)>t)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`);return e}let n=/[\x00-\x1f\x7f-\xff]/.test(e),r=n?3:0;for(let i of e){let e=i.charCodeAt(0);if(r+=n?i===`'`||i===`\\`||i===`
109
109
  `||i===` `||i===`\r`||i===`\x07`||i===`\b`||i===`\f`||i===`\v`||i===`\x1B`||i===`"`?2:e<32||e>=127&&e<=255?4:O(i):O(i)+ +!!` |&;<>()$\`\\"'*?[#~=%!{}`.includes(i),r>t)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`)}if(n){let t=`$'`;for(let n of e){let e=n.charCodeAt(0);t+=n===`'`?`\\'`:n===`\\`?`\\\\`:n===`
110
- `?`\\n`:n===` `?`\\t`:n===`\r`?`\\r`:n===`\x07`?`\\a`:n===`\b`?`\\b`:n===`\f`?`\\f`:n===`\v`?`\\v`:n===`\x1B`?`\\E`:e<32||e>=127&&e<=255?`\\${e.toString(8).padStart(3,`0`)}`:n===`"`?`\\"`:n}return t+=`'`,t}let i=``;for(let t of e)` |&;<>()$\`\\"'*?[#~=%!{}`.includes(t)?i+=`\\${t}`:i+=t;return i}function ki(e,t,n){let i=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!i)return(0,r.sprintf)(e.replace(/0+(?=\d)/,``),t);let a=i[1]===`-`,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?-1:i[4]?parseInt(i[4],10):0;return Nr(t,a?-o:o,s,n)}function Ai(e,t,n){let r=Oi(t,n),i=e.match(/^%(-?)(\d*)q$/);if(!i)return r;let a=i[1]===`-`,o=i[2]?parseInt(i[2],10):0;return Nr(r,a?-o:o,-1,n)}function ji(e,t,n){let i=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!i)return(0,r.sprintf)(e,n);let a=i[1]||``,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?6:i[4]?parseInt(i[4],10):0,c,l=t.toLowerCase();if(l===`e`?(c=n.toExponential(s),c=c.replace(/e([+-])(\d)$/,`e$10$2`),t===`E`&&(c=c.toUpperCase())):l===`f`?(c=n.toFixed(s),a.includes(`#`)&&s===0&&!c.includes(`.`)&&(c+=`.`)):l===`g`?(c=n.toPrecision(s||1),a.includes(`#`)||(c=c.replace(/\.?0+$/,``),c=c.replace(/\.?0+e/,`e`)),c=c.replace(/e([+-])(\d)$/,`e$10$2`),t===`G`&&(c=c.toUpperCase())):c=n.toString(),n>=0&&(a.includes(`+`)?c=`+${c}`:a.includes(` `)&&(c=` ${c}`)),o>c.length)if(a.includes(`-`))c=c.padEnd(o,` `);else if(a.includes(`0`)){let e=c.match(/^[+ -]/)?.[0]||``;c=e+(e?c.slice(1):c).padStart(o-e.length,`0`)}else c=c.padStart(o,` `);return c}function Mi(e,t){if(O(e)>t)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`);let n=``,r=0;for(;r<e.length;)if(e[r]===`\\`&&r+1<e.length)switch(e[r+1]){case`n`:n+=`
110
+ `?`\\n`:n===` `?`\\t`:n===`\r`?`\\r`:n===`\x07`?`\\a`:n===`\b`?`\\b`:n===`\f`?`\\f`:n===`\v`?`\\v`:n===`\x1B`?`\\E`:e<32||e>=127&&e<=255?`\\${e.toString(8).padStart(3,`0`)}`:n===`"`?`\\"`:n}return t+=`'`,t}let i=``;for(let t of e)` |&;<>()$\`\\"'*?[#~=%!{}`.includes(t)?i+=`\\${t}`:i+=t;return i}function ki(e,t,n){let i=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!i)return(0,r.sprintf)(e.replace(/0+(?=\d)/,``),t);let a=i[1]===`-`,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?-1:i[4]?parseInt(i[4],10):0;return Nr(t,a?-o:o,s,n)}function Ai(e,t,n){let r=Oi(t,n),i=e.match(/^%(-?)(\d*)q$/);if(!i)return r;let a=i[1]===`-`,o=i[2]?parseInt(i[2],10):0;return Nr(r,a?-o:o,-1,n)}function ji(e,t,n){let i=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!i)return(0,r.sprintf)(e,n);let a=i[1]||``,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?6:i[4]?parseInt(i[4],10):0,c,l=t.toLowerCase();if(l===`e`?(c=n.toExponential(s),c=c.replace(/e([+-])(\d)$/,`e$10$2`),t===`E`&&(c=c.toUpperCase())):l===`f`?(c=n.toFixed(s),a.includes(`#`)&&s===0&&!c.includes(`.`)&&(c+=`.`)):l===`g`?(c=n.toPrecision(s||1),a.includes(`#`)||(c=c.replace(/\.?0+$/,``),c=c.replace(/\.?0+e/,`e`)),c=c.replace(/e([+-])(\d)$/,`e$10$2`),t===`G`&&(c=c.toUpperCase())):c=n.toString(),n>=0&&(a.includes(`+`)?c=`+${c}`:a.includes(` `)&&(c=` ${c}`)),o>c.length){if(a.includes(`-`))c=c.padEnd(o,` `);else if(a.includes(`0`)){let e=c.match(/^[+ -]/)?.[0]||``;c=e+(e?c.slice(1):c).padStart(o-e.length,`0`)}else c=c.padStart(o,` `)}return c}function Mi(e,t){if(O(e)>t)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`);let n=``,r=0;for(;r<e.length;)if(e[r]===`\\`&&r+1<e.length)switch(e[r+1]){case`n`:n+=`
111
111
  `,r+=2;break;case`t`:n+=` `,r+=2;break;case`r`:n+=`\r`,r+=2;break;case`\\`:n+=`\\`,r+=2;break;case`a`:n+=`\x07`,r+=2;break;case`b`:n+=`\b`,r+=2;break;case`f`:n+=`\f`,r+=2;break;case`v`:n+=`\v`,r+=2;break;case`c`:return{value:n,stopped:!0};case`x`:{let t=[],i=r;for(;i+1<e.length&&e[i]===`\\`&&e[i+1]===`x`;){let n=``,r=i+2;for(;r<e.length&&r<i+4&&/[0-9a-fA-F]/.test(e[r]);)n+=e[r],r++;if(n)t.push(parseInt(n,16)),i=r;else break}t.length>0?(n+=bi(t),r=i):(n+=`\\x`,r+=2);break}case`u`:{let t=``,i=r+2;for(;i<e.length&&i<r+6&&/[0-9a-fA-F]/.test(e[i]);)t+=e[i],i++;t?(n+=String.fromCodePoint(parseInt(t,16)),r=i):(n+=`\\u`,r+=2);break}case`0`:{let t=``,i=r+2;for(;i<e.length&&i<r+5&&/[0-7]/.test(e[i]);)t+=e[i],i++;n+=t?String.fromCharCode(parseInt(t,8)):`\0`,r=i;break}case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let t=``,i=r+1;for(;i<e.length&&i<r+4&&/[0-7]/.test(e[i]);)t+=e[i],i++;n+=String.fromCharCode(parseInt(t,8)),r=i;break}default:n+=e[r],r++}else n+=e[r],r++;return{value:n,stopped:!1}}var Ni,Pi,Fi,Ii,Li=T(()=>{j(),ci(),F(),Lr(),vi(),Ni={name:`printf`,summary:`format and print data`,usage:`printf [-v var] FORMAT [ARGUMENT...]`,options:[` -v var assign the output to shell variable VAR rather than display it`,` --help display this help and exit`],notes:[`FORMAT controls the output like in C printf.`,`Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)`,`Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)`,`Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)`,`Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)`]},Pi={name:`printf`,async execute(e,t){if(N(e))return M(Ni);if(e.length===0)return{stdout:``,stderr:`printf: usage: printf format [arguments]
112
112
  `,exitCode:2,internalStdinConsumed:0};let n=null,r=0;for(;r<e.length;){let t=e[r];if(t===`--`){r++;break}if(t===`-v`){if(r+1>=e.length)return{stdout:``,stderr:`printf: -v: option requires an argument
113
113
  `,exitCode:1,internalStdinConsumed:0};if(n=e[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]\n]+\])?$/.test(n)||/[;\r\\]/.test(n)||n.includes(`..`))return{stdout:``,stderr:`printf: \`${n}': not a valid identifier
@@ -150,8 +150,8 @@ Options:
150
150
  -v, --verbose Output a diagnostic for every directory processed`,Na={parents:{short:`p`,long:`parents`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`},help:{long:`help`,type:`boolean`}},Pa={name:`rmdir`,async execute(e,t){let n=Gr(`rmdir`,e,Na);if(!n.ok)return n.error;if(n.result.flags.help)return{stdout:`${Ma}
151
151
  `,stderr:``,exitCode:0};let r=n.result.flags.parents,i=n.result.flags.verbose,a=n.result.positional;if(a.length===0)return{stdout:``,stderr:`rmdir: missing operand
152
152
  `,exitCode:1};let o=``,s=``,c=0,l=new ca({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`rmdir`,label:`parent traversal`});for(let e of a){let n=await ka(t,e,r,i,l);o+=n.stdout,s+=n.stderr,n.exitCode!==0&&(c=n.exitCode)}return{stdout:o,stderr:s,exitCode:c}}},Fa={name:`rmdir`,flags:[{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),La={};E(La,{flagsForFuzzing:()=>Ba,touchCommand:()=>za});function Ra(e){let t=e.replace(/\//g,`-`),n=new Date(t);if(!Number.isNaN(n.getTime()))return n;let r=t.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(r){let[,e,t,i]=r;if(n=new Date(Number.parseInt(e,10),Number.parseInt(t,10)-1,Number.parseInt(i,10)),!Number.isNaN(n.getTime()))return n}let i=t.match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})$/);if(i){let[,e,t,r,a,o,s]=i;if(n=new Date(Number.parseInt(e,10),Number.parseInt(t,10)-1,Number.parseInt(r,10),Number.parseInt(a,10),Number.parseInt(o,10),Number.parseInt(s,10)),!Number.isNaN(n.getTime()))return n}return null}var za,Ba,Va=T(()=>{ci(),F(),za={name:`touch`,async execute(e,t){let n=[],r=null,i=!1;for(let t=0;t<e.length;t++){let a=e[t];if(a===`--`){n.push(...e.slice(t+1));break}if(a===`-d`||a===`--date`){if(t+1>=e.length)return{stdout:``,stderr:`touch: option requires an argument -- 'd'
153
- `,exitCode:1};r=e[++t]}else if(a.startsWith(`--date=`))r=a.slice(7);else if(a===`-c`||a===`--no-create`)i=!0;else if(a===`-a`||a===`-m`||a===`-r`||a===`-t`)(a===`-r`||a===`-t`)&&t++;else{if(a.startsWith(`--`))return P(`touch`,a);if(a.startsWith(`-`)&&a.length>1){let n=!1;for(let o of a.slice(1))if(o===`c`)i=!0;else if(o!==`a`&&o!==`m`)if(o===`d`){if(t+1>=e.length)return{stdout:``,stderr:`touch: option requires an argument -- 'd'
154
- `,exitCode:1};r=e[++t],n=!0;break}else if(o===`r`||o===`t`){t++,n=!0;break}else return P(`touch`,`-${o}`);if(n)continue}else n.push(a)}}if(n.length===0)return{stdout:``,stderr:`touch: missing file operand
153
+ `,exitCode:1};r=e[++t]}else if(a.startsWith(`--date=`))r=a.slice(7);else if(a===`-c`||a===`--no-create`)i=!0;else if(a===`-a`||a===`-m`||a===`-r`||a===`-t`)(a===`-r`||a===`-t`)&&t++;else{if(a.startsWith(`--`))return P(`touch`,a);if(a.startsWith(`-`)&&a.length>1){let n=!1;for(let o of a.slice(1))if(o===`c`)i=!0;else if(o!==`a`&&o!==`m`){if(o===`d`){if(t+1>=e.length)return{stdout:``,stderr:`touch: option requires an argument -- 'd'
154
+ `,exitCode:1};r=e[++t],n=!0;break}if(o===`r`||o===`t`){t++,n=!0;break}return P(`touch`,`-${o}`)}if(n)continue}else n.push(a)}}if(n.length===0)return{stdout:``,stderr:`touch: missing file operand
155
155
  `,exitCode:1};let a=null;if(r!==null&&(a=Ra(r),a===null))return{stdout:``,stderr:`touch: invalid date format '${r}'
156
156
  `,exitCode:1};let o=``,s=0;for(let e of n)try{let n=t.fs.resolvePath(t.cwd,e);if(!await t.fs.exists(n)){if(i)continue;await t.fs.writeFile(n,``)}let r=a??new Date;await t.fs.utimes(n,r,r)}catch(t){o+=`touch: cannot touch '${e}': ${si(t)}
157
157
  `,s=1}return{stdout:``,stderr:o,exitCode:s}}},Ba={name:`touch`,flags:[{flag:`-c`,type:`boolean`},{flag:`-a`,type:`boolean`},{flag:`-m`,type:`boolean`},{flag:`-d`,type:`value`,valueHint:`string`}],needsArgs:!0}}),Ha={};E(Ha,{flagsForFuzzing:()=>Ga,rmCommand:()=>Wa});var Ua,Wa,Ga,Ka=T(()=>{ea(),ci(),Kr(),Ua={recursive:{short:`r`,long:`recursive`,type:`boolean`},recursiveUpper:{short:`R`,type:`boolean`},force:{short:`f`,long:`force`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},Wa={name:`rm`,async execute(e,t){let n=Gr(`rm`,e,Ua);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,i=n.result.flags.force,a=n.result.flags.verbose,o=n.result.positional;if(o.length===0)return i?{stdout:``,stderr:``,exitCode:0}:{stdout:``,stderr:`rm: missing operand
@@ -180,9 +180,9 @@ Options:
180
180
  `:u+=`mv: cannot move '${e}': ${n}
181
181
  `,d=1}return{stdout:l,stderr:u,exitCode:d}}},ro={name:`mv`,flags:[{flag:`-f`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),ao={};E(ao,{flagsForFuzzing:()=>co,lnCommand:()=>so});var oo,so,co,lo=T(()=>{ea(),F(),oo={name:`ln`,summary:`make links between files`,usage:`ln [OPTIONS] TARGET LINK_NAME`,options:[`-s create a symbolic link instead of a hard link`,`-f remove existing destination files`,`-n treat LINK_NAME as a normal file if it is a symbolic link to a directory`,`-v print name of each linked file`,` --help display this help and exit`]},so={name:`ln`,async execute(e,t){if(N(e))return M(oo);let n=!1,r=!1,i=!1,a=0;for(;a<e.length&&e[a].startsWith(`-`);){let t=e[a];if(t===`-s`||t===`--symbolic`)n=!0,a++;else if(t===`-f`||t===`--force`)r=!0,a++;else if(t===`-v`||t===`--verbose`)i=!0,a++;else if(t===`-n`||t===`--no-dereference`)a++;else if(/^-[sfvn]+$/.test(t))t.includes(`s`)&&(n=!0),t.includes(`f`)&&(r=!0),t.includes(`v`)&&(i=!0),a++;else if(t===`--`){a++;break}else return P(`ln`,t)}let o=e.slice(a);if(o.length<2)return{stdout:``,stderr:`ln: missing file operand
182
182
  `,exitCode:1};if(o.length>2)return{stdout:``,stderr:`ln: extra operand '${o[2]}'
183
- `,exitCode:1};let s=o[0],c=o[1],l=t.fs.resolvePath(t.cwd,c);if(await t.fs.exists(l))if(r)try{await t.fs.rm(l,{force:!0})}catch{return{stdout:``,stderr:`ln: cannot remove '${c}': Permission denied
183
+ `,exitCode:1};let s=o[0],c=o[1],l=t.fs.resolvePath(t.cwd,c);if(await t.fs.exists(l)){if(r)try{await t.fs.rm(l,{force:!0})}catch{return{stdout:``,stderr:`ln: cannot remove '${c}': Permission denied
184
184
  `,exitCode:1}}else return{stdout:``,stderr:`ln: failed to create ${n?`symbolic `:``}link '${c}': File exists
185
- `,exitCode:1};try{if(n)await t.fs.symlink(s,l);else{let e=t.fs.resolvePath(t.cwd,s);if(!await t.fs.exists(e))return{stdout:``,stderr:`ln: failed to access '${s}': No such file or directory
185
+ `,exitCode:1}}try{if(n)await t.fs.symlink(s,l);else{let e=t.fs.resolvePath(t.cwd,s);if(!await t.fs.exists(e))return{stdout:``,stderr:`ln: failed to access '${s}': No such file or directory
186
186
  `,exitCode:1};await t.fs.link(e,l)}}catch(e){let t=e;return t.message.includes(`EPERM`)?{stdout:``,stderr:`ln: '${s}': hard link not allowed for directory
187
187
  `,exitCode:1}:{stdout:``,stderr:`ln: ${$i(t.message)}
188
188
  `,exitCode:1}}let u=``;return i&&(u=`'${c}' -> '${s}'
@@ -222,7 +222,7 @@ Modify: ${i.mtime.toISOString()}
222
222
  `):t+=`\\n`;break;case R.CODES.get(`\r`):t+=`\\r`;break;case R.CODES.get(`\b`):t+=`\\b`;break;case R.CODES.get(`\f`):t+=`\\f`;break;default:{let n=e.toString(16);e<256?(t+=`\\x`,n.length===1&&(t+=`0`),t+=n):t+=`\\x{${n}}`;break}}return t}static stringToRunes(e){return String(e).split(``).map(e=>e.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return R.CODES.get(`a`)<=e&&e<=R.CODES.get(`z`)||R.CODES.get(`A`)<=e&&e<=R.CODES.get(`Z`)||R.CODES.get(`0`)<=e&&e<=R.CODES.get(`9`)||e===R.CODES.get(`_`)}static emptyOpContext(e,t){let n=0;return e<0&&(n|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===R.CODES.get(`
223
223
  `)&&(n|=this.EMPTY_BEGIN_LINE),t<0&&(n|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===R.CODES.get(`
224
224
  `)&&(n|=this.EMPTY_END_LINE),this.isWordRune(e)===this.isWordRune(t)?n|=this.EMPTY_NO_WORD_BOUNDARY:n|=this.EMPTY_WORD_BOUNDARY,n}static quoteMeta(e){return e.split(``).map(e=>this.METACHARACTERS.indexOf(e)>=0?`\\${e}`:e).join(``)}static charCount(e){return e>B.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder(`utf-8`).decode(new Uint8Array(e));{let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)}}},os=(e=[],t=0)=>{let n={};for(let r=0;r<e.length;r++){let i=e[r],a=t+r;n[i]=a,n[a]=i}return Object.freeze(n)},ss=class e{static Encoding=os([`UTF_16`,`UTF_8`]);getEncoding(){throw Error(`not implemented`)}isUTF8Encoding(){return this.getEncoding()===e.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===e.Encoding.UTF_16}},cs=class extends ss{constructor(e=null){super(),this.bytes=e}getEncoding(){return ss.Encoding.UTF_8}asCharSequence(){return as.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},ls=class extends ss{constructor(e=null){super(),this.charSequence=e}getEncoding(){return ss.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split(``).map(e=>e.codePointAt(0))}length(){return this.charSequence.length}},us=class{static utf16(e){return new ls(e)}static utf8(e){return Array.isArray(e)?new cs(e):new cs(as.stringToUtf8ByteArray(e))}},ds=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},fs=class extends ds{constructor(e,t=0,n=e.length){super(),this.bytes=e,this.start=t,this.end=n}step(e){if(e+=this.start,e>=this.end)return ds.EOF();let t=this.bytes[e++]&255;return t&128?(t&224)==192?(t&=31,e>=this.end?ds.EOF():(t=t<<6|this.bytes[e++]&63,t<<3|2)):(t&240)==224?(t&=15,e+1>=this.end?ds.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|3)):(t&=7,e+2>=this.end?ds.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|4)):t<<3|1}index(e,t){t+=this.start;let n=this.indexOf(this.bytes,e.prefixUTF8,t);return n<0?n:n-t}context(e){e+=this.start;let t=-1;if(e>this.start&&e<=this.end){let n=e-1;if(t=this.bytes[n--],t>=128){let r=e-4;for(r<this.start&&(r=this.start);n>=r&&(this.bytes[n]&192)==128;)n--;n<this.start&&(n=this.start),t=this.step(n)>>3}}let n=e<this.end?this.step(e)>>3:-1;return as.emptyOpContext(t,n)}indexOf(e,t,n=0){let r=t.length;if(r===0)return-1;let i=e.length;for(let a=n;a<=i-r;a++)for(let n=0;n<r&&e[a+n]===t[n];n++)if(n===r-1)return a;return-1}},ps=class extends ds{constructor(e,t=0,n=e.length){super(),this.charSequence=e,this.start=t,this.end=n}step(e){if(e+=this.start,e<this.end){let t=this.charSequence.codePointAt(e);return t<<3|as.charCount(t)}return ds.EOF()}index(e,t){t+=this.start;let n=this.charSequence.indexOf(e.prefix,t);return n<0?n:n-t}context(e){e+=this.start;let t=e>0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,n=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return as.emptyOpContext(t,n)}},ms=class{static fromUTF8(e,t=0,n=e.length){return new fs(e,t,n)}static fromUTF16(e,t=0,n=e.length){return new ps(e,t,n)}},hs=class extends Error{constructor(e){super(e),this.name=`RE2JSException`}},gs=class extends hs{constructor(e,t=null){let n=`error parsing regexp: ${e}`;t&&(n+=`: \`${t}\``),super(n),this.name=`RE2JSSyntaxException`,this.message=n,this.error=e,this.input=t}getDescription(){return this.error}getPattern(){return this.input}},_s=class extends hs{constructor(e){super(e),this.name=`RE2JSCompileException`}},vs=class extends hs{constructor(e){super(e),this.name=`RE2JSGroupException`}},ys=class extends hs{constructor(e){super(e),this.name=`RE2JSFlagsException`}},bs=class{static quoteReplacement(e){return e.indexOf(`\\`)<0&&e.indexOf(`$`)<0?e:e.split(``).map(e=>{let t=e.codePointAt(0);return t===R.CODES.get(`\\`)||t===R.CODES.get(`$`)?`\\${e}`:e}).join(``)}constructor(e,t){if(e===null)throw Error(`pattern is null`);this.patternInput=e;let n=this.patternInput.re2();this.patternGroupCount=n.numberOfCapturingGroups(),this.groups=[],this.namedGroups=n.namedGroups,this.numberOfInstructions=n.numberOfInstructions(),t instanceof ss?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(us.utf8(t)):this.resetMatcherInput(us.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw Error(`input is null`);return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}programSize(){return this.numberOfInstructions}group(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}let t=this.start(e),n=this.end(e);return t<0&&n<0?null:this.substring(t,n)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new vs(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new vs(`perhaps no match attempted`);if(e===0||this.hasGroups)return;let t=this.groups[1]+1;t>this.matcherInputLength&&(t=this.matcherInputLength);let n=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!n[0])throw new vs(`inconsistency in matching group data`);this.groups=n[1],this.hasGroups=!0}matches(){return this.genMatch(0,L.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,L.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new vs(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,L.UNANCHORED)}genMatch(e,t){let n=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return n[0]?(this.groups=n[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0):!1}substring(e,t){return this.matcherInput.isUTF8Encoding()?as.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let n=``,r=this.start(),i=this.end();return this.appendPos<r&&(n+=this.substring(this.appendPos,r)),this.appendPos=i,n+=t?this.appendReplacementInternalPerl(e):this.appendReplacementInternal(e),n}appendReplacementInternal(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++){if(e.codePointAt(i)===R.CODES.get(`\\`)){n<i&&(t+=e.substring(n,i)),i++,n=i;continue}if(e.codePointAt(i)===R.CODES.get(`$`)){let a=e.codePointAt(i+1);if(R.CODES.get(`0`)<=a&&a<=R.CODES.get(`9`)){let o=a-R.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<R.CODES.get(`0`)||a>R.CODES.get(`9`)||o*10+a-R.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-R.CODES.get(`0`);if(o>this.patternGroupCount)throw new vs(`n > number of groups: ${o}`);let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}if(a===R.CODES.get(`{`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==R.CODES.get(`}`)&&e.codePointAt(r)!==R.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==R.CODES.get(`}`))throw new vs(`named capture group is missing trailing '}'`);let a=e.substring(i+1,r);t+=this.group(a),n=r+1}}}return n<r&&(t+=e.substring(n,r)),t}appendReplacementInternalPerl(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++)if(e.codePointAt(i)===R.CODES.get(`$`)){let a=e.codePointAt(i+1);if(R.CODES.get(`$`)===a){n<i&&(t+=e.substring(n,i)),t+=`$`,i++,n=i+1;continue}if(R.CODES.get(`&`)===a){n<i&&(t+=e.substring(n,i));let r=this.group(0);t+=r===null?`$&`:r,i++,n=i+1;continue}if(R.CODES.get(`1`)<=a&&a<=R.CODES.get(`9`)){let o=a-R.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<R.CODES.get(`0`)||a>R.CODES.get(`9`)||o*10+a-R.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-R.CODES.get(`0`);if(o>this.patternGroupCount){t+=`$${o}`,n=i,i--;continue}let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}if(a===R.CODES.get(`<`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==R.CODES.get(`>`)&&e.codePointAt(r)!==R.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==R.CODES.get(`>`)){t+=e.substring(i-1,r+1),n=r+1;continue}let a=e.substring(i+1,r);Object.prototype.hasOwnProperty.call(this.namedGroups,a)?t+=this.group(a):t+=`$<${a}>`,n=r+1}}return n<r&&(t+=e.substring(n,r)),t}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,t=!1){return this.replace(e,!0,t)}replaceFirst(e,t=!1){return this.replace(e,!1,t)}replace(e,t=!0,n=!1){let r=``;for(this.reset();this.find()&&(r+=this.appendReplacement(e,n),t););return r+=this.appendTail(),r}},V=class e{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(t){return e.RUNE<=t&&t<=e.RUNE_ANY_NOT_NL}static escapeRunes(e){let t=`"`;for(let n of e)t+=as.escapeRune(n);return t+=`"`,t}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=[]}matchRune(e){if(this.runes.length===1){let t=this.runes[0];return(this.arg&L.FOLD_CASE)===0?e===t:B.equalsIgnoreCase(t,e)}for(let t=0;t<this.runes.length&&t<=8;t+=2){if(e<this.runes[t])return!1;if(e<=this.runes[t+1])return!0}let t=0,n=this.runes.length/2|0;for(;t<n;){let r=t+((n-t)/2|0);if(this.runes[2*r]<=e){if(e<=this.runes[2*r+1])return!0;t=r+1}else n=r}return!1}toString(){switch(this.op){case e.ALT:return`alt -> ${this.out}, ${this.arg}`;case e.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case e.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case e.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case e.MATCH:return`match`;case e.FAIL:return`fail`;case e.NOP:return`nop -> ${this.out}`;case e.RUNE:return this.runes===null?`rune <null>`:[`rune `,e.escapeRunes(this.runes),(this.arg&L.FOLD_CASE)===0?``:`/i`,` -> `,this.out].join(``);case e.RUNE1:return`rune1 ${e.escapeRunes(this.runes)} -> ${this.out}`;case e.RUNE_ANY:return`any -> ${this.out}`;case e.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw Error(`unhandled case in Inst.toString`)}}},xs=class{constructor(){this.inst=null,this.cap=[]}},Ss=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let t=this.sparse[e];return t<this.size&&this.densePcs[t]===e}isEmpty(){return this.size===0}add(e){let t=this.size++;return this.sparse[e]=t,this.denseThreads[t]=null,this.densePcs[t]=e,t}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e=`{`;for(let t=0;t<this.size;t++)t!==0&&(e+=`, `),e+=this.densePcs[t];return e+=`}`,e}},Cs=class e{static fromRE2(t){let n=new e;return n.prog=t.prog,n.re2=t,n.q0=new Ss(n.prog.numInst()),n.q1=new Ss(n.prog.numInst()),n.pool=[],n.poolSize=0,n.matched=!1,n.matchcap=Array(n.prog.numCap<2?2:n.prog.numCap).fill(0),n.ncap=0,n}static fromMachine(t){let n=new e;return n.re2=t.re2,n.prog=t.prog,n.q0=t.q0,n.q1=t.q1,n.pool=t.pool,n.poolSize=t.poolSize,n.matched=t.matched,n.matchcap=t.matchcap,n.ncap=t.ncap,n}init(e){this.ncap=e,e>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}}initNewCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}this.matchcap=Array(e).fill(0)}submatches(){return this.ncap===0?as.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let t;return this.poolSize>0?(this.poolSize--,t=this.pool[this.poolSize]):t=new xs,t.inst=e,t}freeQueue(e,t=0){let n=e.size-t,r=this.poolSize+n;this.pool.length<r&&(this.pool=this.pool.slice(0,Math.max(this.pool.length*2,r)));for(let n=t;n<e.size;n++){let t=e.denseThreads[n];t!==null&&(this.pool[this.poolSize]=t,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,this.pool.length*2)),this.pool[this.poolSize]=e,this.poolSize++}match(e,t,n){let r=this.re2.cond;if(r===as.EMPTY_ALL||(n===L.ANCHOR_START||n===L.ANCHOR_BOTH)&&t!==0)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,a=this.q1,o=e.step(t),s=o>>3,c=o&7,l=-1,u=0;o!==ds.EOF()&&(o=e.step(t+c),l=o>>3,u=o&7);let d;for(d=t===0?as.emptyOpContext(-1,s):e.context(t);;){if(i.isEmpty()){if((r&as.EMPTY_BEGIN_TEXT)!==0&&t!==0||this.matched)break;if(this.re2.prefix.length!==0&&l!==this.re2.prefixRune&&e.canCheckPrefix()){let n=e.index(this.re2,t);if(n<0)break;t+=n,o=e.step(t),s=o>>3,c=o&7,o=e.step(t+c),l=o>>3,u=o&7}}!this.matched&&(t===0||n===L.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=t),this.add(i,this.prog.start,t,this.matchcap,d,null));let f=t+c;if(d=e.context(f),this.step(i,a,t,f,s,d,n,t===e.endPos()),c===0||this.ncap===0&&this.matched)break;t+=c,s=l,c=u,s!==-1&&(o=e.step(t+c),l=o>>3,u=o&7);let p=i;i=a,a=p}return this.freeQueue(a),this.matched}step(e,t,n,r,i,a,o,s){let c=this.re2.longest;for(let l=0;l<e.size;l++){let u=e.denseThreads[l];if(u===null)continue;if(c&&this.matched&&this.ncap>0&&this.matchcap[0]<u.cap[0]){this.freeThread(u);continue}let d=u.inst,f=!1;switch(d.op){case V.MATCH:if(o===L.ANCHOR_BOTH&&!s)break;this.ncap>0&&(!c||!this.matched||this.matchcap[1]<n)&&(u.cap[1]=n,this.matchcap=u.cap.slice(0,this.ncap)),c||this.freeQueue(e,l+1),this.matched=!0;break;case V.RUNE:f=d.matchRune(i);break;case V.RUNE1:f=i===d.runes[0];break;case V.RUNE_ANY:f=!0;break;case V.RUNE_ANY_NOT_NL:f=i!==R.CODES.get(`
225
- `);break;default:throw Error(`bad inst`)}f&&(u=this.add(t,d.out,r,u.cap,a,u)),u!==null&&(this.freeThread(u),e.denseThreads[l]=null)}e.clear()}add(e,t,n,r,i,a){if(t===0||e.contains(t))return a;let o=e.add(t),s=this.prog.inst[t];switch(s.op){case V.FAIL:break;case V.ALT:case V.ALT_MATCH:a=this.add(e,s.out,n,r,i,a),a=this.add(e,s.arg,n,r,i,a);break;case V.EMPTY_WIDTH:(s.arg&~i)===0&&(a=this.add(e,s.out,n,r,i,a));break;case V.NOP:a=this.add(e,s.out,n,r,i,a);break;case V.CAPTURE:if(s.arg<this.ncap){let t=r[s.arg];r[s.arg]=n,this.add(e,s.out,n,r,i,null),r[s.arg]=t}else a=this.add(e,s.out,n,r,i,a);break;case V.MATCH:case V.RUNE:case V.RUNE1:case V.RUNE_ANY:case V.RUNE_ANY_NOT_NL:a===null?a=this.alloc(s):a.inst=s,this.ncap>0&&a.cap!==r&&(a.cap=r.slice(0,this.ncap)),e.denseThreads[o]=a,a=null;break;default:throw Error(`unhandled`)}return a}},ws=e=>{let t=-2128831035;for(let n=0;n<e.length;n++)t^=e[n],t=Math.imul(t,16777619);return t},Ts=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Es=class{constructor(e,t){this.nfaStates=e,this.isMatch=t,this.nextAscii=Array(B.MAX_ASCII+1).fill(null),this.nextMap=new Map}},Ds=class{constructor(e){this.prog=e,this.stateCache=new Map,this.stateCount=0,this.startState=null,this.stateLimit=1e4}computeClosure(e){let t=new Set,n=[...e],r=!1;for(;n.length>0;){let e=n.pop();if(t.has(e))continue;t.add(e);let i=this.prog.getInst(e);switch(i.op){case V.MATCH:r=!0;break;case V.ALT:case V.ALT_MATCH:n.push(i.out),n.push(i.arg);break;case V.NOP:case V.CAPTURE:n.push(i.out);break;case V.EMPTY_WIDTH:return null}}return{pcs:Int32Array.from(t).sort(),isMatch:r}}getState(e){let t=this.computeClosure(e);if(!t)return null;let n=t.pcs,r=ws(n),i=this.stateCache.get(r);if(i)for(let e=0;e<i.length;e++){let t=i[e];if(Ts(t.nfaStates,n))return t}else i=[],this.stateCache.set(r,i);if(this.stateCount>=this.stateLimit)return this.stateCache.clear(),this.stateCount=0,this.startState=null,null;let a=new Es(n,t.isMatch);return i.push(a),this.stateCount++,a}step(e,t,n){if(n===L.UNANCHORED&&t<=B.MAX_ASCII){let n=e.nextAscii[t];if(n!==null)return n}else{let r=t+(n===L.UNANCHORED?0:B.MAX_RUNE+1);if(e.nextMap.has(r))return e.nextMap.get(r)}let r=[];for(let n=0;n<e.nfaStates.length;n++){let i=e.nfaStates[n],a=this.prog.getInst(i);V.isRuneOp(a.op)&&a.matchRune(t)&&r.push(a.out)}n===L.UNANCHORED&&r.push(this.prog.start);let i=this.getState(r);if(n===L.UNANCHORED&&t<=B.MAX_ASCII)e.nextAscii[t]=i;else{let r=t+(n===L.UNANCHORED?0:B.MAX_RUNE+1);e.nextMap.set(r,i)}return i}match(e,t,n){if((n===L.ANCHOR_START||n===L.ANCHOR_BOTH)&&t!==0)return!1;if(!this.startState&&(this.startState=this.getState([this.prog.start]),!this.startState))return null;let r=e.endPos(),i=this.startState;if(i.isMatch)if(n===L.ANCHOR_BOTH){if(t===r)return!0}else return!0;let a=t;for(;a<r;){let t=e.step(a),o=t>>3,s=t&7;if(s===0)break;if(i=this.step(i,o,n),i===null)return null;if(i.isMatch)if(n===L.ANCHOR_BOTH){if(a+s===r)return!0}else return!0;if(i.nfaStates.length===0&&n!==L.UNANCHORED)return!1;a+=s}return!1}},H=class e{static Op=os([`NO_MATCH`,`EMPTY_MATCH`,`LITERAL`,`CHAR_CLASS`,`ANY_CHAR_NOT_NL`,`ANY_CHAR`,`BEGIN_LINE`,`END_LINE`,`BEGIN_TEXT`,`END_TEXT`,`WORD_BOUNDARY`,`NO_WORD_BOUNDARY`,`CAPTURE`,`STAR`,`PLUS`,`QUEST`,`REPEAT`,`CONCAT`,`ALTERNATE`,`LEFT_PAREN`,`VERTICAL_BAR`]);static isPseudoOp(t){return t>=e.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===R.CODES.get(`-`)?`\\`:``}static fromRegexp(t){let n=new e(t.op);return n.flags=t.flags,n.subs=t.subs,n.runes=t.runes,n.cap=t.cap,n.min=t.min,n.max=t.max,n.name=t.name,n.namedGroups=t.namedGroups,n}constructor(t){this.op=t,this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t=``;switch(this.op){case e.Op.NO_MATCH:t+=`[^\\x00-\\x{10FFFF}]`;break;case e.Op.EMPTY_MATCH:t+=`(?:)`;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:case e.Op.REPEAT:{let n=this.subs[0];switch(n.op>e.Op.CAPTURE||n.op===e.Op.LITERAL&&n.runes.length>1?t+=`(?:${n.appendTo()})`:t+=n.appendTo(),this.op){case e.Op.STAR:t+=`*`;break;case e.Op.PLUS:t+=`+`;break;case e.Op.QUEST:t+=`?`;break;case e.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=`,`,this.max>=0&&(t+=this.max)),t+=`}`}(this.flags&L.NON_GREEDY)!==0&&(t+=`?`);break}case e.Op.CONCAT:for(let n of this.subs)n.op===e.Op.ALTERNATE?t+=`(?:${n.appendTo()})`:t+=n.appendTo();break;case e.Op.ALTERNATE:{let e=``;for(let n of this.subs)t+=e,e=`|`,t+=n.appendTo();break}case e.Op.LITERAL:(this.flags&L.FOLD_CASE)!==0&&(t+=`(?i:`);for(let e of this.runes)t+=as.escapeRune(e);(this.flags&L.FOLD_CASE)!==0&&(t+=`)`);break;case e.Op.ANY_CHAR_NOT_NL:t+=`(?-s:.)`;break;case e.Op.ANY_CHAR:t+=`(?s:.)`;break;case e.Op.CAPTURE:this.name===null||this.name.length===0?t+=`(`:t+=`(?P<${this.name}>`,this.subs[0].op!==e.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=`)`;break;case e.Op.BEGIN_TEXT:t+=`\\A`;break;case e.Op.END_TEXT:(this.flags&L.WAS_DOLLAR)===0?t+=`\\z`:t+=`(?-m:$)`;break;case e.Op.BEGIN_LINE:t+=`^`;break;case e.Op.END_LINE:t+=`$`;break;case e.Op.WORD_BOUNDARY:t+=`\\b`;break;case e.Op.NO_WORD_BOUNDARY:t+=`\\B`;break;case e.Op.CHAR_CLASS:if(this.runes.length%2!=0){t+=`[invalid char class]`;break}if(t+=`[`,this.runes.length===0)t+=`^\\x00-\\x{10FFFF}`;else if(this.runes[0]===0&&this.runes[this.runes.length-1]===B.MAX_RUNE){t+=`^`;for(let n=1;n<this.runes.length-1;n+=2){let r=this.runes[n]+1,i=this.runes[n+1]-1;t+=e.quoteIfHyphen(r),t+=as.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=as.escapeRune(i))}}else for(let n=0;n<this.runes.length;n+=2){let r=this.runes[n],i=this.runes[n+1];t+=e.quoteIfHyphen(r),t+=as.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=as.escapeRune(i))}t+=`]`;break;default:t+=this.op}return t}maxCap(){let t=0;if(this.op===e.Op.CAPTURE&&(t=this.cap),this.subs!==null)for(let e of this.subs){let n=e.maxCap();t<n&&(t=n)}return t}equals(t){if(!(t!==null&&t instanceof e)||this.op!==t.op)return!1;switch(this.op){case e.Op.END_TEXT:if((this.flags&L.WAS_DOLLAR)!==(t.flags&L.WAS_DOLLAR))return!1;break;case e.Op.LITERAL:case e.Op.CHAR_CLASS:if(this.runes===null&&t.runes===null)break;if(this.runes===null||t.runes===null||this.runes.length!==t.runes.length)return!1;for(let e=0;e<this.runes.length;e++)if(this.runes[e]!==t.runes[e])return!1;break;case e.Op.ALTERNATE:case e.Op.CONCAT:if(this.subs.length!==t.subs.length)return!1;for(let e=0;e<this.subs.length;++e)if(!this.subs[e].equals(t.subs[e]))return!1;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:if((this.flags&L.NON_GREEDY)!==(t.flags&L.NON_GREEDY)||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.REPEAT:if((this.flags&L.NON_GREEDY)!==(t.flags&L.NON_GREEDY)||this.min!==t.min||this.max!==t.max||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.CAPTURE:if(this.cap!==t.cap||(this.name===null?t.name!==null:this.name!==t.name)||!this.subs[0].equals(t.subs[0]))return!1}return!0}},Os=class{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new V(e))}skipNop(e){let t=this.inst[e];for(;t.op===V.NOP||t.op===V.CAPTURE;)t=this.inst[e],e=t.out;return t}prefix(){let e=``,t=this.skipNop(this.start);if(!V.isRuneOp(t.op)||t.runes.length!==1)return[t.op===V.MATCH,e];for(;V.isRuneOp(t.op)&&t.runes.length===1&&(t.arg&L.FOLD_CASE)===0;)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===V.MATCH,e]}startCond(){let e=0,t=this.start;e:for(;;){let n=this.inst[t];switch(n.op){case V.EMPTY_WIDTH:e|=n.arg;break;case V.FAIL:return-1;case V.CAPTURE:case V.NOP:break;default:break e}t=n.out}return e}next(e){let t=this.inst[e>>1];return e&1?t.arg:t.out}patch(e,t){for(;e!==0;){let n=this.inst[e>>1];e&1?(e=n.arg,n.arg=t):(e=n.out,n.out=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let n=e;for(;;){let e=this.next(n);if(e===0)break;n=e}let r=this.inst[n>>1];return n&1?r.arg=t:r.out=t,e}toString(){let e=``;for(let t=0;t<this.inst.length;t++){let n=e.length;e+=t,t===this.start&&(e+=`*`),e+=` `.substring(e.length-n),e+=this.inst[t],e+=`
225
+ `);break;default:throw Error(`bad inst`)}f&&(u=this.add(t,d.out,r,u.cap,a,u)),u!==null&&(this.freeThread(u),e.denseThreads[l]=null)}e.clear()}add(e,t,n,r,i,a){if(t===0||e.contains(t))return a;let o=e.add(t),s=this.prog.inst[t];switch(s.op){case V.FAIL:break;case V.ALT:case V.ALT_MATCH:a=this.add(e,s.out,n,r,i,a),a=this.add(e,s.arg,n,r,i,a);break;case V.EMPTY_WIDTH:(s.arg&~i)===0&&(a=this.add(e,s.out,n,r,i,a));break;case V.NOP:a=this.add(e,s.out,n,r,i,a);break;case V.CAPTURE:if(s.arg<this.ncap){let t=r[s.arg];r[s.arg]=n,this.add(e,s.out,n,r,i,null),r[s.arg]=t}else a=this.add(e,s.out,n,r,i,a);break;case V.MATCH:case V.RUNE:case V.RUNE1:case V.RUNE_ANY:case V.RUNE_ANY_NOT_NL:a===null?a=this.alloc(s):a.inst=s,this.ncap>0&&a.cap!==r&&(a.cap=r.slice(0,this.ncap)),e.denseThreads[o]=a,a=null;break;default:throw Error(`unhandled`)}return a}},ws=e=>{let t=-2128831035;for(let n=0;n<e.length;n++)t^=e[n],t=Math.imul(t,16777619);return t},Ts=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Es=class{constructor(e,t){this.nfaStates=e,this.isMatch=t,this.nextAscii=Array(B.MAX_ASCII+1).fill(null),this.nextMap=new Map}},Ds=class{constructor(e){this.prog=e,this.stateCache=new Map,this.stateCount=0,this.startState=null,this.stateLimit=1e4}computeClosure(e){let t=new Set,n=[...e],r=!1;for(;n.length>0;){let e=n.pop();if(t.has(e))continue;t.add(e);let i=this.prog.getInst(e);switch(i.op){case V.MATCH:r=!0;break;case V.ALT:case V.ALT_MATCH:n.push(i.out),n.push(i.arg);break;case V.NOP:case V.CAPTURE:n.push(i.out);break;case V.EMPTY_WIDTH:return null}}return{pcs:Int32Array.from(t).sort(),isMatch:r}}getState(e){let t=this.computeClosure(e);if(!t)return null;let n=t.pcs,r=ws(n),i=this.stateCache.get(r);if(i)for(let e=0;e<i.length;e++){let t=i[e];if(Ts(t.nfaStates,n))return t}else i=[],this.stateCache.set(r,i);if(this.stateCount>=this.stateLimit)return this.stateCache.clear(),this.stateCount=0,this.startState=null,null;let a=new Es(n,t.isMatch);return i.push(a),this.stateCount++,a}step(e,t,n){if(n===L.UNANCHORED&&t<=B.MAX_ASCII){let n=e.nextAscii[t];if(n!==null)return n}else{let r=t+(n===L.UNANCHORED?0:B.MAX_RUNE+1);if(e.nextMap.has(r))return e.nextMap.get(r)}let r=[];for(let n=0;n<e.nfaStates.length;n++){let i=e.nfaStates[n],a=this.prog.getInst(i);V.isRuneOp(a.op)&&a.matchRune(t)&&r.push(a.out)}n===L.UNANCHORED&&r.push(this.prog.start);let i=this.getState(r);if(n===L.UNANCHORED&&t<=B.MAX_ASCII)e.nextAscii[t]=i;else{let r=t+(n===L.UNANCHORED?0:B.MAX_RUNE+1);e.nextMap.set(r,i)}return i}match(e,t,n){if((n===L.ANCHOR_START||n===L.ANCHOR_BOTH)&&t!==0)return!1;if(!this.startState&&(this.startState=this.getState([this.prog.start]),!this.startState))return null;let r=e.endPos(),i=this.startState;if(i.isMatch){if(n===L.ANCHOR_BOTH){if(t===r)return!0}else return!0}let a=t;for(;a<r;){let t=e.step(a),o=t>>3,s=t&7;if(s===0)break;if(i=this.step(i,o,n),i===null)return null;if(i.isMatch){if(n===L.ANCHOR_BOTH){if(a+s===r)return!0}else return!0}if(i.nfaStates.length===0&&n!==L.UNANCHORED)return!1;a+=s}return!1}},H=class e{static Op=os([`NO_MATCH`,`EMPTY_MATCH`,`LITERAL`,`CHAR_CLASS`,`ANY_CHAR_NOT_NL`,`ANY_CHAR`,`BEGIN_LINE`,`END_LINE`,`BEGIN_TEXT`,`END_TEXT`,`WORD_BOUNDARY`,`NO_WORD_BOUNDARY`,`CAPTURE`,`STAR`,`PLUS`,`QUEST`,`REPEAT`,`CONCAT`,`ALTERNATE`,`LEFT_PAREN`,`VERTICAL_BAR`]);static isPseudoOp(t){return t>=e.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===R.CODES.get(`-`)?`\\`:``}static fromRegexp(t){let n=new e(t.op);return n.flags=t.flags,n.subs=t.subs,n.runes=t.runes,n.cap=t.cap,n.min=t.min,n.max=t.max,n.name=t.name,n.namedGroups=t.namedGroups,n}constructor(t){this.op=t,this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t=``;switch(this.op){case e.Op.NO_MATCH:t+=`[^\\x00-\\x{10FFFF}]`;break;case e.Op.EMPTY_MATCH:t+=`(?:)`;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:case e.Op.REPEAT:{let n=this.subs[0];switch(n.op>e.Op.CAPTURE||n.op===e.Op.LITERAL&&n.runes.length>1?t+=`(?:${n.appendTo()})`:t+=n.appendTo(),this.op){case e.Op.STAR:t+=`*`;break;case e.Op.PLUS:t+=`+`;break;case e.Op.QUEST:t+=`?`;break;case e.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=`,`,this.max>=0&&(t+=this.max)),t+=`}`}(this.flags&L.NON_GREEDY)!==0&&(t+=`?`);break}case e.Op.CONCAT:for(let n of this.subs)n.op===e.Op.ALTERNATE?t+=`(?:${n.appendTo()})`:t+=n.appendTo();break;case e.Op.ALTERNATE:{let e=``;for(let n of this.subs)t+=e,e=`|`,t+=n.appendTo();break}case e.Op.LITERAL:(this.flags&L.FOLD_CASE)!==0&&(t+=`(?i:`);for(let e of this.runes)t+=as.escapeRune(e);(this.flags&L.FOLD_CASE)!==0&&(t+=`)`);break;case e.Op.ANY_CHAR_NOT_NL:t+=`(?-s:.)`;break;case e.Op.ANY_CHAR:t+=`(?s:.)`;break;case e.Op.CAPTURE:this.name===null||this.name.length===0?t+=`(`:t+=`(?P<${this.name}>`,this.subs[0].op!==e.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=`)`;break;case e.Op.BEGIN_TEXT:t+=`\\A`;break;case e.Op.END_TEXT:(this.flags&L.WAS_DOLLAR)===0?t+=`\\z`:t+=`(?-m:$)`;break;case e.Op.BEGIN_LINE:t+=`^`;break;case e.Op.END_LINE:t+=`$`;break;case e.Op.WORD_BOUNDARY:t+=`\\b`;break;case e.Op.NO_WORD_BOUNDARY:t+=`\\B`;break;case e.Op.CHAR_CLASS:if(this.runes.length%2!=0){t+=`[invalid char class]`;break}if(t+=`[`,this.runes.length===0)t+=`^\\x00-\\x{10FFFF}`;else if(this.runes[0]===0&&this.runes[this.runes.length-1]===B.MAX_RUNE){t+=`^`;for(let n=1;n<this.runes.length-1;n+=2){let r=this.runes[n]+1,i=this.runes[n+1]-1;t+=e.quoteIfHyphen(r),t+=as.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=as.escapeRune(i))}}else for(let n=0;n<this.runes.length;n+=2){let r=this.runes[n],i=this.runes[n+1];t+=e.quoteIfHyphen(r),t+=as.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=as.escapeRune(i))}t+=`]`;break;default:t+=this.op}return t}maxCap(){let t=0;if(this.op===e.Op.CAPTURE&&(t=this.cap),this.subs!==null)for(let e of this.subs){let n=e.maxCap();t<n&&(t=n)}return t}equals(t){if(!(t!==null&&t instanceof e)||this.op!==t.op)return!1;switch(this.op){case e.Op.END_TEXT:if((this.flags&L.WAS_DOLLAR)!==(t.flags&L.WAS_DOLLAR))return!1;break;case e.Op.LITERAL:case e.Op.CHAR_CLASS:if(this.runes===null&&t.runes===null)break;if(this.runes===null||t.runes===null||this.runes.length!==t.runes.length)return!1;for(let e=0;e<this.runes.length;e++)if(this.runes[e]!==t.runes[e])return!1;break;case e.Op.ALTERNATE:case e.Op.CONCAT:if(this.subs.length!==t.subs.length)return!1;for(let e=0;e<this.subs.length;++e)if(!this.subs[e].equals(t.subs[e]))return!1;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:if((this.flags&L.NON_GREEDY)!==(t.flags&L.NON_GREEDY)||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.REPEAT:if((this.flags&L.NON_GREEDY)!==(t.flags&L.NON_GREEDY)||this.min!==t.min||this.max!==t.max||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.CAPTURE:if(this.cap!==t.cap||(this.name===null?t.name!==null:this.name!==t.name)||!this.subs[0].equals(t.subs[0]))return!1}return!0}},Os=class{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new V(e))}skipNop(e){let t=this.inst[e];for(;t.op===V.NOP||t.op===V.CAPTURE;)t=this.inst[e],e=t.out;return t}prefix(){let e=``,t=this.skipNop(this.start);if(!V.isRuneOp(t.op)||t.runes.length!==1)return[t.op===V.MATCH,e];for(;V.isRuneOp(t.op)&&t.runes.length===1&&(t.arg&L.FOLD_CASE)===0;)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===V.MATCH,e]}startCond(){let e=0,t=this.start;e:for(;;){let n=this.inst[t];switch(n.op){case V.EMPTY_WIDTH:e|=n.arg;break;case V.FAIL:return-1;case V.CAPTURE:case V.NOP:break;default:break e}t=n.out}return e}next(e){let t=this.inst[e>>1];return e&1?t.arg:t.out}patch(e,t){for(;e!==0;){let n=this.inst[e>>1];e&1?(e=n.arg,n.arg=t):(e=n.out,n.out=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let n=e;for(;;){let e=this.next(n);if(e===0)break;n=e}let r=this.inst[n>>1];return n&1?r.arg=t:r.out=t,e}toString(){let e=``;for(let t=0;t<this.inst.length;t++){let n=e.length;e+=t,t===this.start&&(e+=`*`),e+=` `.substring(e.length-n),e+=this.inst[t],e+=`
226
226
  `}return e}},ks=class{constructor(e=0,t=0,n=!1){this.i=e,this.out=t,this.nullable=n}},As=class e{static ANY_RUNE_NOT_NL(){return[0,R.CODES.get(`
227
227
  `)-1,R.CODES.get(`
228
228
  `)+1,B.MAX_RUNE]}static ANY_RUNE(){return[0,B.MAX_RUNE]}static compileRegexp(t){let n=new e,r=n.compile(t);return n.prog.patch(r.out,n.newInst(V.MATCH).i),n.prog.start=r.i,n.prog}constructor(){this.prog=new Os,this.newInst(V.FAIL)}newInst(e){return this.prog.addInst(e),new ks(this.prog.numInst()-1,0,!0)}nop(){let e=this.newInst(V.NOP);return e.out=e.i<<1,e}fail(){return new ks}cap(e){let t=this.newInst(V.CAPTURE);return t.out=t.i<<1,this.prog.getInst(t.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),t}cat(e,t){return e.i===0||t.i===0?this.fail():(this.prog.patch(e.out,t.i),new ks(e.i,t.out,e.nullable&&t.nullable))}alt(e,t){if(e.i===0)return t;if(t.i===0)return e;let n=this.newInst(V.ALT),r=this.prog.getInst(n.i);return r.out=e.i,r.arg=t.i,n.out=this.prog.append(e.out,t.out),n.nullable=e.nullable||t.nullable,n}loop(e,t){let n=this.newInst(V.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),this.prog.patch(e.out,n.i),n}quest(e,t){let n=this.newInst(V.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),n.out=this.prog.append(n.out,e.out),n}star(e,t){return e.nullable?this.quest(this.plus(e,t),t):this.loop(e,t)}plus(e,t){return new ks(e.i,this.loop(e,t).out,e.nullable)}empty(e){let t=this.newInst(V.EMPTY_WIDTH);return this.prog.getInst(t.i).arg=e,t.out=t.i<<1,t}rune(e,t){let n=this.newInst(V.RUNE);n.nullable=!1;let r=this.prog.getInst(n.i);return r.runes=e,t&=L.FOLD_CASE,(e.length!==1||B.simpleFold(e[0])===e[0])&&(t&=-2),r.arg=t,n.out=n.i<<1,(t&L.FOLD_CASE)===0&&e.length===1||e.length===2&&e[0]===e[1]?r.op=V.RUNE1:e.length===2&&e[0]===0&&e[1]===B.MAX_RUNE?r.op=V.RUNE_ANY:e.length===4&&e[0]===0&&e[1]===R.CODES.get(`
@@ -230,13 +230,13 @@ Modify: ${i.mtime.toISOString()}
230
230
  `)+1&&e[3]===B.MAX_RUNE&&(r.op=V.RUNE_ANY_NOT_NL),n}compile(t){switch(t.op){case H.Op.NO_MATCH:return this.fail();case H.Op.EMPTY_MATCH:return this.nop();case H.Op.LITERAL:if(t.runes.length===0)return this.nop();{let e=null;for(let n of t.runes){let r=this.rune([n],t.flags);e=e===null?r:this.cat(e,r)}return e}case H.Op.CHAR_CLASS:return this.rune(t.runes,t.flags);case H.Op.ANY_CHAR_NOT_NL:return this.rune(e.ANY_RUNE_NOT_NL(),0);case H.Op.ANY_CHAR:return this.rune(e.ANY_RUNE(),0);case H.Op.BEGIN_LINE:return this.empty(as.EMPTY_BEGIN_LINE);case H.Op.END_LINE:return this.empty(as.EMPTY_END_LINE);case H.Op.BEGIN_TEXT:return this.empty(as.EMPTY_BEGIN_TEXT);case H.Op.END_TEXT:return this.empty(as.EMPTY_END_TEXT);case H.Op.WORD_BOUNDARY:return this.empty(as.EMPTY_WORD_BOUNDARY);case H.Op.NO_WORD_BOUNDARY:return this.empty(as.EMPTY_NO_WORD_BOUNDARY);case H.Op.CAPTURE:{let e=this.cap(t.cap<<1),n=this.compile(t.subs[0]),r=this.cap(t.cap<<1|1);return this.cat(this.cat(e,n),r)}case H.Op.STAR:return this.star(this.compile(t.subs[0]),(t.flags&L.NON_GREEDY)!==0);case H.Op.PLUS:return this.plus(this.compile(t.subs[0]),(t.flags&L.NON_GREEDY)!==0);case H.Op.QUEST:return this.quest(this.compile(t.subs[0]),(t.flags&L.NON_GREEDY)!==0);case H.Op.CONCAT:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.cat(e,t)}return e}case H.Op.ALTERNATE:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.alt(e,t)}return e}default:throw new _s(`regexp: unhandled case in compile`)}}},js=class e{static simplify(t){if(t===null)return null;switch(t.op){case H.Op.CAPTURE:case H.Op.CONCAT:case H.Op.ALTERNATE:{let n=t;for(let r=0;r<t.subs.length;r++){let i=t.subs[r],a=e.simplify(i);n===t&&a!==i&&(n=H.fromRegexp(t),n.runes=[],n.subs=t.subs.slice(0,t.subs.length)),n!==t&&(n.subs[r]=a)}return n}case H.Op.STAR:case H.Op.PLUS:case H.Op.QUEST:{let n=e.simplify(t.subs[0]);return e.simplify1(t.op,t.flags,n,t)}case H.Op.REPEAT:{if(t.min===0&&t.max===0)return new H(H.Op.EMPTY_MATCH);let n=e.simplify(t.subs[0]);if(t.max===-1){if(t.min===0)return e.simplify1(H.Op.STAR,t.flags,n,null);if(t.min===1)return e.simplify1(H.Op.PLUS,t.flags,n,null);let r=new H(H.Op.CONCAT),i=[];for(let e=0;e<t.min-1;e++)i.push(n);return i.push(e.simplify1(H.Op.PLUS,t.flags,n,null)),r.subs=i.slice(0),r}if(t.min===1&&t.max===1)return n;let r=null;if(t.min>0){r=[];for(let e=0;e<t.min;e++)r.push(n)}if(t.max>t.min){let i=e.simplify1(H.Op.QUEST,t.flags,n,null);for(let r=t.min+1;r<t.max;r++){let r=new H(H.Op.CONCAT);r.subs=[n,i],i=e.simplify1(H.Op.QUEST,t.flags,r,null)}if(r===null)return i;r.push(i)}if(r!==null){let e=new H(H.Op.CONCAT);return e.subs=r.slice(0),e}return new H(H.Op.NO_MATCH)}}return t}static simplify1(e,t,n,r){return n.op===H.Op.EMPTY_MATCH||e===n.op&&(t&L.NON_GREEDY)===(n.flags&L.NON_GREEDY)?n:(r!==null&&r.op===e&&(r.flags&L.NON_GREEDY)===(t&L.NON_GREEDY)&&n===r.subs[0]||(r=new H(e),r.flags=t,r.subs=[n]),r)}},Ms=class{constructor(e,t){this.sign=e,this.cls=t}},Ns=[48,57],Ps=[9,10,12,13,32,32],Fs=[48,57,65,90,95,95,97,122],Is=new Map([[`\\d`,new Ms(1,Ns)],[`\\D`,new Ms(-1,Ns)],[`\\s`,new Ms(1,Ps)],[`\\S`,new Ms(-1,Ps)],[`\\w`,new Ms(1,Fs)],[`\\W`,new Ms(-1,Fs)]]),Ls=[48,57,65,90,97,122],Rs=[65,90,97,122],zs=[0,127],Bs=[9,9,32,32],Vs=[0,31,127,127],Hs=[48,57],Us=[33,126],Ws=[97,122],Gs=[32,126],Ks=[33,47,58,64,91,96,123,126],qs=[9,13,32,32],Js=[65,90],Ys=[48,57,65,90,95,95,97,122],Xs=[48,57,65,70,97,102],Zs=new Map([[`[:alnum:]`,new Ms(1,Ls)],[`[:^alnum:]`,new Ms(-1,Ls)],[`[:alpha:]`,new Ms(1,Rs)],[`[:^alpha:]`,new Ms(-1,Rs)],[`[:ascii:]`,new Ms(1,zs)],[`[:^ascii:]`,new Ms(-1,zs)],[`[:blank:]`,new Ms(1,Bs)],[`[:^blank:]`,new Ms(-1,Bs)],[`[:cntrl:]`,new Ms(1,Vs)],[`[:^cntrl:]`,new Ms(-1,Vs)],[`[:digit:]`,new Ms(1,Hs)],[`[:^digit:]`,new Ms(-1,Hs)],[`[:graph:]`,new Ms(1,Us)],[`[:^graph:]`,new Ms(-1,Us)],[`[:lower:]`,new Ms(1,Ws)],[`[:^lower:]`,new Ms(-1,Ws)],[`[:print:]`,new Ms(1,Gs)],[`[:^print:]`,new Ms(-1,Gs)],[`[:punct:]`,new Ms(1,Ks)],[`[:^punct:]`,new Ms(-1,Ks)],[`[:space:]`,new Ms(1,qs)],[`[:^space:]`,new Ms(-1,qs)],[`[:upper:]`,new Ms(1,Js)],[`[:^upper:]`,new Ms(-1,Js)],[`[:word:]`,new Ms(1,Ys)],[`[:^word:]`,new Ms(-1,Ys)],[`[:xdigit:]`,new Ms(1,Xs)],[`[:^xdigit:]`,new Ms(-1,Xs)]]),Qs=class e{static charClassToString(e,t){let n=`[`;for(let r=0;r<t;r+=2){r>0&&(n+=` `);let t=e[r],i=e[r+1];n+=t===i?`0x${t.toString(16)}`:`0x${t.toString(16)}-0x${i.toString(16)}`}return n+=`]`,n}static cmp(e,t,n,r){let i=e[t]-n;return i===0?r-e[t+1]:i}static qsortIntPair(t,n,r){let i=((n+r)/2|0)&-2,a=t[i],o=t[i+1],s=n,c=r;for(;s<=c;){for(;s<r&&e.cmp(t,s,a,o)<0;)s+=2;for(;c>n&&e.cmp(t,c,a,o)>0;)c-=2;if(s<=c){if(s!==c){let e=t[s];t[s]=t[c],t[c]=e,e=t[s+1],t[s+1]=t[c+1],t[c+1]=e}s+=2,c-=2}}n<c&&e.qsortIntPair(t,n,c),s<r&&e.qsortIntPair(t,s,r)}constructor(e=as.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;e.qsortIntPair(this.r,0,this.len-2);let t=2;for(let e=2;e<this.len;e+=2){let n=this.r[e],r=this.r[e+1];if(n<=this.r[t-1]+1){r>this.r[t-1]&&(this.r[t-1]=r);continue}this.r[t]=n,this.r[t+1]=r,t+=2}return this.len=t,this}appendLiteral(e,t){return(t&L.FOLD_CASE)===0?this.appendRange(e,e):this.appendFoldedRange(e,e)}appendRange(e,t){if(this.len>0){for(let n=2;n<=4;n+=2)if(this.len>=n){let r=this.r[this.len-n],i=this.r[this.len-n+1];if(e<=i+1&&r<=t+1)return e<r&&(this.r[this.len-n]=e),t>i&&(this.r[this.len-n+1]=t),this}}return this.r[this.len++]=e,this.r[this.len++]=t,this}appendFoldedRange(e,t){if(e<=B.MIN_FOLD&&t>=B.MAX_FOLD||t<B.MIN_FOLD||e>B.MAX_FOLD)return this.appendRange(e,t);e<B.MIN_FOLD&&(this.appendRange(e,B.MIN_FOLD-1),e=B.MIN_FOLD),t>B.MAX_FOLD&&(this.appendRange(B.MAX_FOLD+1,t),t=B.MAX_FOLD);for(let n=e;n<=t;n++){this.appendRange(n,n);for(let e=B.simpleFold(n);e!==n;e=B.simpleFold(e))this.appendRange(e,e)}return this}appendClass(e){for(let t=0;t<e.length;t+=2)this.appendRange(e[t],e[t+1]);return this}appendFoldedClass(e){for(let t=0;t<e.length;t+=2)this.appendFoldedRange(e[t],e[t+1]);return this}appendNegatedClass(e){let t=0;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t<=r-1&&this.appendRange(t,r-1),t=i+1}return t<=B.MAX_RUNE&&this.appendRange(t,B.MAX_RUNE),this}appendTable(e){for(let t=0;t<e.length;++t){let n=e.getLo(t),r=e.getHi(t),i=e.getStride(t);if(i===1){this.appendRange(n,r);continue}for(let e=n;e<=r;e+=i)this.appendRange(e,e)}return this}appendNegatedTable(e){let t=0;for(let n=0;n<e.length;++n){let r=e.getLo(n),i=e.getHi(n),a=e.getStride(n);if(a===1){t<=r-1&&this.appendRange(t,r-1),t=i+1;continue}for(let e=r;e<=i;e+=a)t<=e-1&&this.appendRange(t,e-1),t=e+1}return t<=B.MAX_RUNE&&this.appendRange(t,B.MAX_RUNE),this}appendTableWithSign(e,t){return t<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,t=0;for(let n=0;n<this.len;n+=2){let r=this.r[n],i=this.r[n+1];e<=r-1&&(this.r[t]=e,this.r[t+1]=r-1,t+=2),e=i+1}return this.len=t,e<=B.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=B.MAX_RUNE),this}appendClassWithSign(e,t){return t<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(t,n){let r=t.cls;return n&&(r=new e().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,t.sign)}toString(){return e.charClassToString(this.r,this.len)}},$s=class e{static of(t,n){return new e(t,n)}constructor(e,t){this.first=e,this.second=t}},ec=class{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){let e=this.str.codePointAt(this.position);return this.position+=as.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}},tc=class e{static ERR_INTERNAL_ERROR=`regexp/syntax: internal error`;static ERR_INVALID_CHAR_RANGE=`invalid character class range`;static ERR_INVALID_ESCAPE=`invalid escape sequence`;static ERR_INVALID_NAMED_CAPTURE=`invalid named capture`;static ERR_INVALID_PERL_OP=`invalid or unsupported Perl syntax`;static ERR_INVALID_REPEAT_OP=`invalid nested repetition operator`;static ERR_INVALID_REPEAT_SIZE=`invalid repeat count`;static ERR_MISSING_BRACKET=`missing closing ]`;static ERR_MISSING_PAREN=`missing closing )`;static ERR_MISSING_REPEAT_ARGUMENT=`missing argument to repetition operator`;static ERR_TRAILING_BACKSLASH=`trailing backslash at end of expression`;static ERR_DUPLICATE_NAMED_CAPTURE=`duplicate capture group name`;static ERR_UNEXPECTED_PAREN=`unexpected )`;static ERR_NESTING_DEPTH=`expression nests too deeply`;static ERR_LARGE=`expression too large`;static MAX_HEIGHT=1e3;static MAX_SIZE=3355443;static MAX_RUNES=33554432;static ANY_TABLE=new z(new Uint32Array([0,B.MAX_RUNE,1]));static unicodeTable(t){return t===`Any`?$s.of(e.ANY_TABLE,e.ANY_TABLE):is.CATEGORIES.has(t)?$s.of(is.CATEGORIES.get(t),is.FOLD_CATEGORIES.get(t)):is.SCRIPTS.has(t)?$s.of(is.SCRIPTS.get(t),is.FOLD_SCRIPT.get(t)):null}static minFoldRune(e){if(e<B.MIN_FOLD||e>B.MAX_FOLD)return e;let t=e,n=e;for(e=B.simpleFold(e);e!==n;e=B.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){if(e.op===H.Op.EMPTY_MATCH)return null;if(e.op===H.Op.CONCAT&&e.subs.length>0){let t=e.subs[0];return t.op===H.Op.EMPTY_MATCH?null:t}return e}static literalRegexp(e,t){let n=new H(H.Op.LITERAL);return n.flags=t,n.runes=as.stringToRunes(e),n}static parse(t,n){return new e(t,n).parseInternal()}static parseRepeat(t){let n=t.pos();if(!t.more()||!t.lookingAt(`{`))return-1;t.skip(1);let r=e.parseInt(t);if(r===-1||!t.more())return-1;let i;if(!t.lookingAt(`,`))i=r;else{if(t.skip(1),!t.more())return-1;if(t.lookingAt(`}`))i=-1;else if((i=e.parseInt(t))===-1)return-1}if(!t.more()||!t.lookingAt(`}`))return-1;if(t.skip(1),r<0||r>1e3||i===-2||i>1e3||i>=0&&r>i)throw new gs(e.ERR_INVALID_REPEAT_SIZE,t.from(n));return r<<16|i&B.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n!==R.CODES.get(`_`)&&!as.isalnum(n))return!1}return!0}static parseInt(e){let t=e.pos();for(;e.more()&&e.peek()>=R.CODES.get(`0`)&&e.peek()<=R.CODES.get(`9`);)e.skip(1);let n=e.from(t);return n.length===0||n.length>1&&n.codePointAt(0)===R.CODES.get(`0`)?-1:n.length>8?-2:parseFloat(n,10)}static isCharClass(e){return e.op===H.Op.LITERAL&&e.runes.length===1||e.op===H.Op.CHAR_CLASS||e.op===H.Op.ANY_CHAR_NOT_NL||e.op===H.Op.ANY_CHAR}static matchRune(e,t){switch(e.op){case H.Op.LITERAL:return e.runes.length===1&&e.runes[0]===t;case H.Op.CHAR_CLASS:for(let n=0;n<e.runes.length;n+=2)if(e.runes[n]<=t&&t<=e.runes[n+1])return!0;return!1;case H.Op.ANY_CHAR_NOT_NL:return t!==R.CODES.get(`
231
231
  `);case H.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(t,n){switch(t.op){case H.Op.ANY_CHAR:break;case H.Op.ANY_CHAR_NOT_NL:e.matchRune(n,R.CODES.get(`
232
232
  `))&&(t.op=H.Op.ANY_CHAR);break;case H.Op.CHAR_CLASS:t.runes=n.op===H.Op.LITERAL?new Qs(t.runes).appendLiteral(n.runes[0],n.flags).toArray():new Qs(t.runes).appendClass(n.runes).toArray();break;case H.Op.LITERAL:if(n.runes[0]===t.runes[0]&&n.flags===t.flags)break;t.op=H.Op.CHAR_CLASS,t.runes=new Qs().appendLiteral(t.runes[0],t.flags).appendLiteral(n.runes[0],n.flags).toArray()}}static parseEscape(t){let n=t.pos();if(t.skip(1),!t.more())throw new gs(e.ERR_TRAILING_BACKSLASH);let r=t.pop();e:switch(r){case R.CODES.get(`1`):case R.CODES.get(`2`):case R.CODES.get(`3`):case R.CODES.get(`4`):case R.CODES.get(`5`):case R.CODES.get(`6`):case R.CODES.get(`7`):if(!t.more()||t.peek()<R.CODES.get(`0`)||t.peek()>R.CODES.get(`7`))break;case R.CODES.get(`0`):{let e=r-R.CODES.get(`0`);for(let n=1;n<3&&!(!t.more()||t.peek()<R.CODES.get(`0`)||t.peek()>R.CODES.get(`7`));n++)e=e*8+t.peek()-R.CODES.get(`0`),t.skip(1);return e}case R.CODES.get(`x`):{if(!t.more())break;if(r=t.pop(),r===R.CODES.get(`{`)){let e=0,n=0;for(;;){if(!t.more())break e;if(r=t.pop(),r===R.CODES.get(`}`))break;let i=as.unhex(r);if(i<0||(n=n*16+i,n>B.MAX_RUNE))break e;e++}if(e===0)break e;return n}let e=as.unhex(r);if(!t.more())break;r=t.pop();let n=as.unhex(r);if(e<0||n<0)break;return e*16+n}case R.CODES.get(`a`):return R.CODES.get(`\x07`);case R.CODES.get(`f`):return R.CODES.get(`\f`);case R.CODES.get(`n`):return R.CODES.get(`
233
- `);case R.CODES.get(`r`):return R.CODES.get(`\r`);case R.CODES.get(`t`):return R.CODES.get(` `);case R.CODES.get(`v`):return R.CODES.get(`\v`);default:if(r<=B.MAX_ASCII&&!as.isalnum(r))return r}throw new gs(e.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new gs(e.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt(`\\`)?e.parseEscape(t):t.pop()}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):(t=new H(e),this.numRegexp+=1),t}reuse(e){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,e)&&delete this.height[e],e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}checkLimits(t){if(this.numRunes>e.MAX_RUNES)throw new gs(e.ERR_LARGE);this.checkSize(t),this.checkHeight(t)}checkSize(t){if(this.size===null){if(this.repeats===0&&(this.repeats=1),t.op===H.Op.REPEAT){let n=t.max;n===-1&&(n=t.min),n<=0&&(n=1),n>e.MAX_SIZE/this.repeats?this.repeats=e.MAX_SIZE:this.repeats*=n}if(this.numRegexp<e.MAX_SIZE/this.repeats)return;this.size={};for(let e of this.stack)this.checkSize(e)}if(this.calcSize(t,!0)>e.MAX_SIZE)throw new gs(e.ERR_LARGE)}calcSize(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.size,e))return this.size[e];let n=0;switch(e.op){case H.Op.LITERAL:n=e.runes.length;break;case H.Op.CAPTURE:case H.Op.STAR:n=2+this.calcSize(e.subs[0]);break;case H.Op.PLUS:case H.Op.QUEST:n=1+this.calcSize(e.subs[0]);break;case H.Op.CONCAT:for(let t of e.subs)n+=this.calcSize(t);break;case H.Op.ALTERNATE:for(let t of e.subs)n+=this.calcSize(t);e.subs.length>1&&(n=n+e.subs.length-1);break;case H.Op.REPEAT:{let t=this.calcSize(e.subs[0]);if(e.max===-1){n=e.min===0?2+t:1+e.min*t;break}n=e.max*t+(e.max-e.min);break}}return n=Math.max(1,n),this.size[e]=n,n}checkHeight(t){if(!(this.numRegexp<e.MAX_HEIGHT)){if(this.height===null){this.height={};for(let e of this.stack)this.checkHeight(e)}if(this.calcHeight(t,!0)>e.MAX_HEIGHT)throw new gs(e.ERR_NESTING_DEPTH)}}calcHeight(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.height,e))return this.height[e];let n=1;for(let t of e.subs){let e=this.calcHeight(t);n<1+e&&(n=1+e)}return this.height[e]=n,n}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,t=e;for(;t>0&&!H.isPseudoOp(this.stack[t-1].op);)t--;let n=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),n}push(e){if(this.numRunes+=e.runes.length,e.op===H.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=H.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===H.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&B.simpleFold(e.runes[0])===e.runes[2]&&B.simpleFold(e.runes[2])===e.runes[0]||e.op===H.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&B.simpleFold(e.runes[0])===e.runes[1]&&B.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|L.FOLD_CASE))return null;e.op=H.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|L.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),this.checkLimits(e),e}maybeConcat(t,n){let r=this.stack.length;if(r<2)return!1;let i=this.stack[r-1],a=this.stack[r-2];return i.op!==H.Op.LITERAL||a.op!==H.Op.LITERAL||(i.flags&L.FOLD_CASE)!==(a.flags&L.FOLD_CASE)?!1:(a.runes=e.concatRunes(a.runes,i.runes),t>=0?(i.runes=[t],i.flags=n,!0):(this.pop(),this.reuse(i),!1))}newLiteral(t,n){let r=this.newRegexp(H.Op.LITERAL);return r.flags=n,(n&L.FOLD_CASE)!==0&&(t=e.minFoldRune(t)),r.runes=[t],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(t,n,r,i,a,o){let s=this.flags;if((s&L.PERL_X)!==0&&(a.more()&&a.lookingAt(`?`)&&(a.skip(1),s^=L.NON_GREEDY),o!==-1))throw new gs(e.ERR_INVALID_REPEAT_OP,a.from(o));let c=this.stack.length;if(c===0)throw new gs(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let l=this.stack[c-1];if(H.isPseudoOp(l.op))throw new gs(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let u=this.newRegexp(t);if(u.min=n,u.max=r,u.flags=s,u.subs=[l],this.stack[c-1]=u,this.checkLimits(u),t===H.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new gs(e.ERR_INVALID_REPEAT_SIZE,a.from(i))}repeatIsValid(e,t){if(e.op===H.Op.REPEAT){let n=e.max;if(n===0)return!0;if(n<0&&(n=e.min),n>t)return!1;n>0&&(t=Math.trunc(t/n))}for(let n of e.subs)if(!this.repeatIsValid(n,t))return!1;return!0}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(H.Op.EMPTY_MATCH)):this.push(this.collapse(e,H.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(H.Op.NO_MATCH)):this.push(this.collapse(e,H.Op.ALTERNATE))}cleanAlt(e){e.op===H.Op.CHAR_CLASS&&(e.runes=new Qs(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===B.MAX_RUNE?(e.runes=[],e.op=H.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===R.CODES.get(`
233
+ `);case R.CODES.get(`r`):return R.CODES.get(`\r`);case R.CODES.get(`t`):return R.CODES.get(` `);case R.CODES.get(`v`):return R.CODES.get(`\v`);default:if(r<=B.MAX_ASCII&&!as.isalnum(r))return r;break}throw new gs(e.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new gs(e.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt(`\\`)?e.parseEscape(t):t.pop()}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):(t=new H(e),this.numRegexp+=1),t}reuse(e){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,e)&&delete this.height[e],e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}checkLimits(t){if(this.numRunes>e.MAX_RUNES)throw new gs(e.ERR_LARGE);this.checkSize(t),this.checkHeight(t)}checkSize(t){if(this.size===null){if(this.repeats===0&&(this.repeats=1),t.op===H.Op.REPEAT){let n=t.max;n===-1&&(n=t.min),n<=0&&(n=1),n>e.MAX_SIZE/this.repeats?this.repeats=e.MAX_SIZE:this.repeats*=n}if(this.numRegexp<e.MAX_SIZE/this.repeats)return;this.size={};for(let e of this.stack)this.checkSize(e)}if(this.calcSize(t,!0)>e.MAX_SIZE)throw new gs(e.ERR_LARGE)}calcSize(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.size,e))return this.size[e];let n=0;switch(e.op){case H.Op.LITERAL:n=e.runes.length;break;case H.Op.CAPTURE:case H.Op.STAR:n=2+this.calcSize(e.subs[0]);break;case H.Op.PLUS:case H.Op.QUEST:n=1+this.calcSize(e.subs[0]);break;case H.Op.CONCAT:for(let t of e.subs)n+=this.calcSize(t);break;case H.Op.ALTERNATE:for(let t of e.subs)n+=this.calcSize(t);e.subs.length>1&&(n=n+e.subs.length-1);break;case H.Op.REPEAT:{let t=this.calcSize(e.subs[0]);if(e.max===-1){n=e.min===0?2+t:1+e.min*t;break}n=e.max*t+(e.max-e.min);break}}return n=Math.max(1,n),this.size[e]=n,n}checkHeight(t){if(!(this.numRegexp<e.MAX_HEIGHT)){if(this.height===null){this.height={};for(let e of this.stack)this.checkHeight(e)}if(this.calcHeight(t,!0)>e.MAX_HEIGHT)throw new gs(e.ERR_NESTING_DEPTH)}}calcHeight(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.height,e))return this.height[e];let n=1;for(let t of e.subs){let e=this.calcHeight(t);n<1+e&&(n=1+e)}return this.height[e]=n,n}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,t=e;for(;t>0&&!H.isPseudoOp(this.stack[t-1].op);)t--;let n=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),n}push(e){if(this.numRunes+=e.runes.length,e.op===H.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=H.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===H.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&B.simpleFold(e.runes[0])===e.runes[2]&&B.simpleFold(e.runes[2])===e.runes[0]||e.op===H.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&B.simpleFold(e.runes[0])===e.runes[1]&&B.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|L.FOLD_CASE))return null;e.op=H.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|L.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),this.checkLimits(e),e}maybeConcat(t,n){let r=this.stack.length;if(r<2)return!1;let i=this.stack[r-1],a=this.stack[r-2];return i.op!==H.Op.LITERAL||a.op!==H.Op.LITERAL||(i.flags&L.FOLD_CASE)!==(a.flags&L.FOLD_CASE)?!1:(a.runes=e.concatRunes(a.runes,i.runes),t>=0?(i.runes=[t],i.flags=n,!0):(this.pop(),this.reuse(i),!1))}newLiteral(t,n){let r=this.newRegexp(H.Op.LITERAL);return r.flags=n,(n&L.FOLD_CASE)!==0&&(t=e.minFoldRune(t)),r.runes=[t],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(t,n,r,i,a,o){let s=this.flags;if((s&L.PERL_X)!==0&&(a.more()&&a.lookingAt(`?`)&&(a.skip(1),s^=L.NON_GREEDY),o!==-1))throw new gs(e.ERR_INVALID_REPEAT_OP,a.from(o));let c=this.stack.length;if(c===0)throw new gs(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let l=this.stack[c-1];if(H.isPseudoOp(l.op))throw new gs(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let u=this.newRegexp(t);if(u.min=n,u.max=r,u.flags=s,u.subs=[l],this.stack[c-1]=u,this.checkLimits(u),t===H.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new gs(e.ERR_INVALID_REPEAT_SIZE,a.from(i))}repeatIsValid(e,t){if(e.op===H.Op.REPEAT){let n=e.max;if(n===0)return!0;if(n<0&&(n=e.min),n>t)return!1;n>0&&(t=Math.trunc(t/n))}for(let n of e.subs)if(!this.repeatIsValid(n,t))return!1;return!0}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(H.Op.EMPTY_MATCH)):this.push(this.collapse(e,H.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(H.Op.NO_MATCH)):this.push(this.collapse(e,H.Op.ALTERNATE))}cleanAlt(e){e.op===H.Op.CHAR_CLASS&&(e.runes=new Qs(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===B.MAX_RUNE?(e.runes=[],e.op=H.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===R.CODES.get(`
234
234
  `)-1&&e.runes[2]===R.CODES.get(`
235
- `)+1&&e.runes[3]===B.MAX_RUNE&&(e.runes=[],e.op=H.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let n=0;for(let r of e)n+=r.op===t?r.subs.length:1;let r=Array(n).fill(null),i=0;for(let n of e)n.op===t?(r.splice(i,n.subs.length,...n.subs),i+=n.subs.length,this.reuse(n)):r[i++]=n;let a=this.newRegexp(t);if(a.subs=r,t===H.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let e=a;a=a.subs[0],this.reuse(e)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,i=0,a=null,o=0,s=0,c=0;for(let e=0;e<=r;e++){let l=null,u=0,d=0;if(e<r){let r=t[n+e];if(r.op===H.Op.CONCAT&&r.subs.length>0&&(r=r.subs[0]),r.op===H.Op.LITERAL&&(l=r.runes,u=r.runes.length,d=r.flags&L.FOLD_CASE),d===s){let e=0;for(;e<o&&e<u&&a[e]===l[e];)e++;if(e>0){o=e;continue}}}if(e!==c)if(e===c+1)t[i++]=t[n+c];else{let r=this.newRegexp(H.Op.LITERAL);r.flags=s,r.runes=a.slice(0,o);for(let r=c;r<e;r++)t[n+r]=this.removeLeadingString(t[n+r],o),this.checkLimits(t[n+r]);let l=this.collapse(t.slice(n+c,n+e),H.Op.ALTERNATE),u=this.newRegexp(H.Op.CONCAT);u.subs=[r,l],t[i++]=u}c=e,a=l,o=u,s=d}r=i,n=0,c=0,i=0;let l=null;for(let a=0;a<=r;a++){let o=null;if(!(a<r&&(o=e.leadingRegexp(t[n+a]),l!==null&&l.equals(o)&&(e.isCharClass(l)||l.op===H.Op.REPEAT&&l.min===l.max&&e.isCharClass(l.subs[0]))))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let e=l;for(let e=c;e<a;e++){let r=e!==c;t[n+e]=this.removeLeadingRegexp(t[n+e],r),this.checkLimits(t[n+e])}let r=this.collapse(t.slice(n+c,n+a),H.Op.ALTERNATE),o=this.newRegexp(H.Op.CONCAT);o.subs=[e,r],t[i++]=o}c=a,l=o}}r=i,n=0,c=0,i=0;for(let a=0;a<=r;a++)if(!(a<r&&e.isCharClass(t[n+a]))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let r=c;for(let e=c+1;e<a;e++){let i=t[n+r],a=t[n+e];(i.op<a.op||i.op===a.op&&(i.runes===null?0:i.runes.length)<(a.runes===null?0:a.runes.length))&&(r=e)}let o=t[n+c];t[n+c]=t[n+r],t[n+r]=o;for(let r=c+1;r<a;r++)e.mergeCharClass(t[n+c],t[n+r]),this.reuse(t[n+r]);this.cleanAlt(t[n+c]),t[i++]=t[n+c]}a<r&&(t[i++]=t[n+a]),c=a+1}r=i,n=0,c=0,i=0;for(let e=0;e<r;++e)e+1<r&&t[n+e].op===H.Op.EMPTY_MATCH&&t[n+e+1].op===H.Op.EMPTY_MATCH||(t[i++]=t[n+e]);return r=i,n=0,t.slice(n,r)}removeLeadingString(e,t){if(e.op===H.Op.CONCAT&&e.subs.length>0){let n=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=n,n.op===H.Op.EMPTY_MATCH)switch(this.reuse(n),e.subs.length){case 0:case 1:e.op=H.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let t=e;e=e.subs[1],this.reuse(t);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===H.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=H.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===H.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=H.Op.EMPTY_MATCH,e.subs=H.emptySubs();break;case 1:{let t=e;e=e.subs[0],this.reuse(t);break}}return e}return t&&this.reuse(e),this.newRegexp(H.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&L.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,i=new ec(this.wholeRegexp);for(;i.more();){let a=-1;e:switch(i.peek()){case R.CODES.get(`(`):if((this.flags&L.PERL_X)!==0&&i.lookingAt(`(?`)){this.parsePerlFlags(i);break}this.op(H.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case R.CODES.get(`|`):this.parseVerticalBar(),i.skip(1);break;case R.CODES.get(`)`):this.parseRightParen(),i.skip(1);break;case R.CODES.get(`^`):(this.flags&L.ONE_LINE)===0?this.op(H.Op.BEGIN_LINE):this.op(H.Op.BEGIN_TEXT),i.skip(1);break;case R.CODES.get(`$`):(this.flags&L.ONE_LINE)===0?this.op(H.Op.END_LINE):this.op(H.Op.END_TEXT).flags|=L.WAS_DOLLAR,i.skip(1);break;case R.CODES.get(`.`):(this.flags&L.DOT_NL)===0?this.op(H.Op.ANY_CHAR_NOT_NL):this.op(H.Op.ANY_CHAR),i.skip(1);break;case R.CODES.get(`[`):this.parseClass(i);break;case R.CODES.get(`*`):case R.CODES.get(`+`):case R.CODES.get(`?`):{a=i.pos();let e=null;switch(i.pop()){case R.CODES.get(`*`):e=H.Op.STAR;break;case R.CODES.get(`+`):e=H.Op.PLUS;break;case R.CODES.get(`?`):e=H.Op.QUEST}this.repeat(e,n,r,a,i,t);break}case R.CODES.get(`{`):{a=i.pos();let o=e.parseRepeat(i);if(o<0){i.rewindTo(a),this.literal(i.pop());break}n=o>>16,r=(o&B.MAX_BMP)<<16>>16,this.repeat(H.Op.REPEAT,n,r,a,i,t);break}case R.CODES.get(`\\`):{let t=i.pos();if(i.skip(1),(this.flags&L.PERL_X)!==0&&i.more())switch(i.pop()){case R.CODES.get(`A`):this.op(H.Op.BEGIN_TEXT);break e;case R.CODES.get(`b`):this.op(H.Op.WORD_BOUNDARY);break e;case R.CODES.get(`B`):this.op(H.Op.NO_WORD_BOUNDARY);break e;case R.CODES.get(`C`):throw new gs(e.ERR_INVALID_ESCAPE,`\\C`);case R.CODES.get(`Q`):{let e=i.rest(),t=e.indexOf(`\\E`);t>=0&&(e=e.substring(0,t)),i.skipString(e),i.skipString(`\\E`);let n=0;for(;n<e.length;){let t=e.codePointAt(n);this.literal(t),n+=as.charCount(t)}break e}case R.CODES.get(`z`):this.op(H.Op.END_TEXT);break e;default:i.rewindTo(t);break}let n=this.newRegexp(H.Op.CHAR_CLASS);if(n.flags=this.flags,i.lookingAt(`\\p`)||i.lookingAt(`\\P`)){let e=new Qs;if(this.parseUnicodeClass(i,e)){n.runes=e.toArray(),this.push(n);break e}}let r=new Qs;if(this.parsePerlClassEscape(i,r)){n.runes=r.toArray(),this.push(n);break e}i.rewindTo(t),this.reuse(n),this.literal(e.parseEscape(i));break}default:this.literal(i.pop())}t=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new gs(e.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){let n=t.pos(),r=t.rest();if(r.startsWith(`(?P<`)||r.startsWith(`(?<`)){let n=r.charAt(2)===`P`?4:3,i=r.indexOf(`>`);if(i<0)throw new gs(e.ERR_INVALID_NAMED_CAPTURE,r);let a=r.substring(n,i);if(t.skipString(a),t.skip(n+1),!e.isValidCaptureName(a))throw new gs(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,i+1));let o=this.op(H.Op.LEFT_PAREN);if(o.cap=++this.numCap,this.namedGroups[a])throw new gs(e.ERR_DUPLICATE_NAMED_CAPTURE,a);this.namedGroups[a]=this.numCap,o.name=a;return}t.skip(2);let i=this.flags,a=1,o=!1;e:for(;t.more();){let e=t.pop();switch(e){case R.CODES.get(`i`):i|=L.FOLD_CASE,o=!0;break;case R.CODES.get(`m`):i&=-17,o=!0;break;case R.CODES.get(`s`):i|=L.DOT_NL,o=!0;break;case R.CODES.get(`U`):i|=L.NON_GREEDY,o=!0;break;case R.CODES.get(`-`):if(a<0)break e;a=-1,i=~i,o=!1;break;case R.CODES.get(`:`):case R.CODES.get(`)`):if(a<0){if(!o)break e;i=~i}e===R.CODES.get(`:`)&&this.op(H.Op.LEFT_PAREN),this.flags=i;return;default:break e}}throw new gs(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(H.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===H.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let e=r;r=n,n=e,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let e=this.stack[t-1],n=this.stack[t-2];if(n.op===H.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=e,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new gs(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let t=this.pop(),n=this.pop();if(n.op!==H.Op.LEFT_PAREN)throw new gs(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=n.flags,n.cap===0?this.push(t):(n.op=H.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(e,t){let n=e.pos();if((this.flags&L.PERL_X)===0||!e.more()||e.pop()!==R.CODES.get(`\\`)||!e.more())return!1;e.pop();let r=e.from(n),i=Is.has(r)?Is.get(r):null;return i!==null&&(t.appendGroup(i,(this.flags&L.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),i=r.indexOf(`:]`);if(i<0)return!1;let a=r.substring(0,i+2);t.skipString(a);let o=Zs.has(a)?Zs.get(a):null;if(o===null)throw new gs(e.ERR_INVALID_CHAR_RANGE,a);return n.appendGroup(o,(this.flags&L.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&L.UNICODE_GROUPS)===0||!t.lookingAt(`\\p`)&&!t.lookingAt(`\\P`))return!1;t.skip(1);let i=1,a=t.pop();if(a===R.CODES.get(`P`)&&(i=-1),!t.more())throw t.rewindTo(r),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest());a=t.pop();let o;if(a!==R.CODES.get(`{`))o=as.runeToString(a);else{let n=t.rest(),i=n.indexOf(`}`);if(i<0)throw t.rewindTo(r),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest());o=n.substring(0,i),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===R.CODES.get(`^`)&&(i=0-i,o=o.substring(1));let s=e.unicodeTable(o);if(s===null)throw new gs(e.ERR_INVALID_CHAR_RANGE,t.from(r));let c=s.first,l=s.second;if((this.flags&L.FOLD_CASE)===0||l===null)n.appendTableWithSign(c,i);else{let e=new Qs().appendTable(c).appendTable(l).cleanClass().toArray();n.appendClassWithSign(e,i)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(H.Op.CHAR_CLASS);r.flags=this.flags;let i=new Qs,a=1;t.more()&&t.lookingAt(`^`)&&(a=-1,t.skip(1),(this.flags&L.CLASS_NL)===0&&i.appendRange(R.CODES.get(`
235
+ `)+1&&e.runes[3]===B.MAX_RUNE&&(e.runes=[],e.op=H.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let n=0;for(let r of e)n+=r.op===t?r.subs.length:1;let r=Array(n).fill(null),i=0;for(let n of e)n.op===t?(r.splice(i,n.subs.length,...n.subs),i+=n.subs.length,this.reuse(n)):r[i++]=n;let a=this.newRegexp(t);if(a.subs=r,t===H.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let e=a;a=a.subs[0],this.reuse(e)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,i=0,a=null,o=0,s=0,c=0;for(let e=0;e<=r;e++){let l=null,u=0,d=0;if(e<r){let r=t[n+e];if(r.op===H.Op.CONCAT&&r.subs.length>0&&(r=r.subs[0]),r.op===H.Op.LITERAL&&(l=r.runes,u=r.runes.length,d=r.flags&L.FOLD_CASE),d===s){let e=0;for(;e<o&&e<u&&a[e]===l[e];)e++;if(e>0){o=e;continue}}}if(e!==c){if(e===c+1)t[i++]=t[n+c];else{let r=this.newRegexp(H.Op.LITERAL);r.flags=s,r.runes=a.slice(0,o);for(let r=c;r<e;r++)t[n+r]=this.removeLeadingString(t[n+r],o),this.checkLimits(t[n+r]);let l=this.collapse(t.slice(n+c,n+e),H.Op.ALTERNATE),u=this.newRegexp(H.Op.CONCAT);u.subs=[r,l],t[i++]=u}}c=e,a=l,o=u,s=d}r=i,n=0,c=0,i=0;let l=null;for(let a=0;a<=r;a++){let o=null;if(!(a<r&&(o=e.leadingRegexp(t[n+a]),l!==null&&l.equals(o)&&(e.isCharClass(l)||l.op===H.Op.REPEAT&&l.min===l.max&&e.isCharClass(l.subs[0]))))){if(a!==c){if(a===c+1)t[i++]=t[n+c];else{let e=l;for(let e=c;e<a;e++){let r=e!==c;t[n+e]=this.removeLeadingRegexp(t[n+e],r),this.checkLimits(t[n+e])}let r=this.collapse(t.slice(n+c,n+a),H.Op.ALTERNATE),o=this.newRegexp(H.Op.CONCAT);o.subs=[e,r],t[i++]=o}}c=a,l=o}}r=i,n=0,c=0,i=0;for(let a=0;a<=r;a++)if(!(a<r&&e.isCharClass(t[n+a]))){if(a!==c){if(a===c+1)t[i++]=t[n+c];else{let r=c;for(let e=c+1;e<a;e++){let i=t[n+r],a=t[n+e];(i.op<a.op||i.op===a.op&&(i.runes===null?0:i.runes.length)<(a.runes===null?0:a.runes.length))&&(r=e)}let o=t[n+c];t[n+c]=t[n+r],t[n+r]=o;for(let r=c+1;r<a;r++)e.mergeCharClass(t[n+c],t[n+r]),this.reuse(t[n+r]);this.cleanAlt(t[n+c]),t[i++]=t[n+c]}}a<r&&(t[i++]=t[n+a]),c=a+1}r=i,n=0,c=0,i=0;for(let e=0;e<r;++e)e+1<r&&t[n+e].op===H.Op.EMPTY_MATCH&&t[n+e+1].op===H.Op.EMPTY_MATCH||(t[i++]=t[n+e]);return r=i,n=0,t.slice(n,r)}removeLeadingString(e,t){if(e.op===H.Op.CONCAT&&e.subs.length>0){let n=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=n,n.op===H.Op.EMPTY_MATCH)switch(this.reuse(n),e.subs.length){case 0:case 1:e.op=H.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let t=e;e=e.subs[1],this.reuse(t);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===H.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=H.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===H.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=H.Op.EMPTY_MATCH,e.subs=H.emptySubs();break;case 1:{let t=e;e=e.subs[0],this.reuse(t);break}}return e}return t&&this.reuse(e),this.newRegexp(H.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&L.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,i=new ec(this.wholeRegexp);for(;i.more();){let a=-1;e:switch(i.peek()){case R.CODES.get(`(`):if((this.flags&L.PERL_X)!==0&&i.lookingAt(`(?`)){this.parsePerlFlags(i);break}this.op(H.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case R.CODES.get(`|`):this.parseVerticalBar(),i.skip(1);break;case R.CODES.get(`)`):this.parseRightParen(),i.skip(1);break;case R.CODES.get(`^`):(this.flags&L.ONE_LINE)===0?this.op(H.Op.BEGIN_LINE):this.op(H.Op.BEGIN_TEXT),i.skip(1);break;case R.CODES.get(`$`):(this.flags&L.ONE_LINE)===0?this.op(H.Op.END_LINE):this.op(H.Op.END_TEXT).flags|=L.WAS_DOLLAR,i.skip(1);break;case R.CODES.get(`.`):(this.flags&L.DOT_NL)===0?this.op(H.Op.ANY_CHAR_NOT_NL):this.op(H.Op.ANY_CHAR),i.skip(1);break;case R.CODES.get(`[`):this.parseClass(i);break;case R.CODES.get(`*`):case R.CODES.get(`+`):case R.CODES.get(`?`):{a=i.pos();let e=null;switch(i.pop()){case R.CODES.get(`*`):e=H.Op.STAR;break;case R.CODES.get(`+`):e=H.Op.PLUS;break;case R.CODES.get(`?`):e=H.Op.QUEST}this.repeat(e,n,r,a,i,t);break}case R.CODES.get(`{`):{a=i.pos();let o=e.parseRepeat(i);if(o<0){i.rewindTo(a),this.literal(i.pop());break}n=o>>16,r=(o&B.MAX_BMP)<<16>>16,this.repeat(H.Op.REPEAT,n,r,a,i,t);break}case R.CODES.get(`\\`):{let t=i.pos();if(i.skip(1),(this.flags&L.PERL_X)!==0&&i.more())switch(i.pop()){case R.CODES.get(`A`):this.op(H.Op.BEGIN_TEXT);break e;case R.CODES.get(`b`):this.op(H.Op.WORD_BOUNDARY);break e;case R.CODES.get(`B`):this.op(H.Op.NO_WORD_BOUNDARY);break e;case R.CODES.get(`C`):throw new gs(e.ERR_INVALID_ESCAPE,`\\C`);case R.CODES.get(`Q`):{let e=i.rest(),t=e.indexOf(`\\E`);t>=0&&(e=e.substring(0,t)),i.skipString(e),i.skipString(`\\E`);let n=0;for(;n<e.length;){let t=e.codePointAt(n);this.literal(t),n+=as.charCount(t)}break e}case R.CODES.get(`z`):this.op(H.Op.END_TEXT);break e;default:i.rewindTo(t);break}let n=this.newRegexp(H.Op.CHAR_CLASS);if(n.flags=this.flags,i.lookingAt(`\\p`)||i.lookingAt(`\\P`)){let e=new Qs;if(this.parseUnicodeClass(i,e)){n.runes=e.toArray(),this.push(n);break e}}let r=new Qs;if(this.parsePerlClassEscape(i,r)){n.runes=r.toArray(),this.push(n);break e}i.rewindTo(t),this.reuse(n),this.literal(e.parseEscape(i));break}default:this.literal(i.pop());break}t=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new gs(e.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){let n=t.pos(),r=t.rest();if(r.startsWith(`(?P<`)||r.startsWith(`(?<`)){let n=r.charAt(2)===`P`?4:3,i=r.indexOf(`>`);if(i<0)throw new gs(e.ERR_INVALID_NAMED_CAPTURE,r);let a=r.substring(n,i);if(t.skipString(a),t.skip(n+1),!e.isValidCaptureName(a))throw new gs(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,i+1));let o=this.op(H.Op.LEFT_PAREN);if(o.cap=++this.numCap,this.namedGroups[a])throw new gs(e.ERR_DUPLICATE_NAMED_CAPTURE,a);this.namedGroups[a]=this.numCap,o.name=a;return}t.skip(2);let i=this.flags,a=1,o=!1;e:for(;t.more();){let e=t.pop();switch(e){case R.CODES.get(`i`):i|=L.FOLD_CASE,o=!0;break;case R.CODES.get(`m`):i&=-17,o=!0;break;case R.CODES.get(`s`):i|=L.DOT_NL,o=!0;break;case R.CODES.get(`U`):i|=L.NON_GREEDY,o=!0;break;case R.CODES.get(`-`):if(a<0)break e;a=-1,i=~i,o=!1;break;case R.CODES.get(`:`):case R.CODES.get(`)`):if(a<0){if(!o)break e;i=~i}e===R.CODES.get(`:`)&&this.op(H.Op.LEFT_PAREN),this.flags=i;return;default:break e}}throw new gs(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(H.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===H.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let e=r;r=n,n=e,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let e=this.stack[t-1],n=this.stack[t-2];if(n.op===H.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=e,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new gs(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let t=this.pop(),n=this.pop();if(n.op!==H.Op.LEFT_PAREN)throw new gs(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=n.flags,n.cap===0?this.push(t):(n.op=H.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(e,t){let n=e.pos();if((this.flags&L.PERL_X)===0||!e.more()||e.pop()!==R.CODES.get(`\\`)||!e.more())return!1;e.pop();let r=e.from(n),i=Is.has(r)?Is.get(r):null;return i!==null&&(t.appendGroup(i,(this.flags&L.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),i=r.indexOf(`:]`);if(i<0)return!1;let a=r.substring(0,i+2);t.skipString(a);let o=Zs.has(a)?Zs.get(a):null;if(o===null)throw new gs(e.ERR_INVALID_CHAR_RANGE,a);return n.appendGroup(o,(this.flags&L.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&L.UNICODE_GROUPS)===0||!t.lookingAt(`\\p`)&&!t.lookingAt(`\\P`))return!1;t.skip(1);let i=1,a=t.pop();if(a===R.CODES.get(`P`)&&(i=-1),!t.more())throw t.rewindTo(r),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest());a=t.pop();let o;if(a!==R.CODES.get(`{`))o=as.runeToString(a);else{let n=t.rest(),i=n.indexOf(`}`);if(i<0)throw t.rewindTo(r),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest());o=n.substring(0,i),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===R.CODES.get(`^`)&&(i=0-i,o=o.substring(1));let s=e.unicodeTable(o);if(s===null)throw new gs(e.ERR_INVALID_CHAR_RANGE,t.from(r));let c=s.first,l=s.second;if((this.flags&L.FOLD_CASE)===0||l===null)n.appendTableWithSign(c,i);else{let e=new Qs().appendTable(c).appendTable(l).cleanClass().toArray();n.appendClassWithSign(e,i)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(H.Op.CHAR_CLASS);r.flags=this.flags;let i=new Qs,a=1;t.more()&&t.lookingAt(`^`)&&(a=-1,t.skip(1),(this.flags&L.CLASS_NL)===0&&i.appendRange(R.CODES.get(`
236
236
  `),R.CODES.get(`
237
237
  `)));let o=!0;for(;!t.more()||t.peek()!==R.CODES.get(`]`)||o;){if(t.more()&&t.lookingAt(`-`)&&(this.flags&L.PERL_X)===0&&!o){let r=t.rest();if(r===`-`||!r.startsWith(`-]`))throw t.rewindTo(n),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let r=t.pos();if(t.lookingAt(`[:`)){if(this.parseNamedClass(t,i))continue;t.rewindTo(r)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(r);let a=e.parseClassChar(t,n),s=a;if(t.more()&&t.lookingAt(`-`)){if(t.skip(1),t.more()&&t.lookingAt(`]`))t.skip(-1);else if(s=e.parseClassChar(t,n),s<a)throw new gs(e.ERR_INVALID_CHAR_RANGE,t.from(r))}(this.flags&L.FOLD_CASE)===0?i.appendRange(a,s):i.appendFoldedRange(a,s)}t.skip(1),i.cleanClass(),a<0&&i.negateClass(),r.runes=i.toArray(),this.push(r)}},nc=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e&&(this.value=t,!0)}},rc=class e{static initTest(t){let n=e.compile(t),r=new e(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(t){return e.compileImpl(t,L.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,L.POSIX,!0)}static compileImpl(t,n,r){let i=tc.parse(t,n),a=i.maxCap();i=js.simplify(i);let o=As.compileRegexp(i),s=new e(t,o,a,r),[c,l]=o.prefix();return s.prefixComplete=c,s.prefix=l,s.prefixUTF8=as.stringToUtf8ByteArray(s.prefix),s.prefix.length>0&&(s.prefixRune=s.prefix.codePointAt(0)),s.namedGroups=i.namedGroups,s}static match(t,n){return e.compile(t).match(n)}constructor(e,t,n=0,r=0){this.expr=e,this.prog=t,this.numSubexp=n,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new nc,this.dfa=new Ds(t)}executeEngine(e,t,n,r){if(r>0)return this.doExecuteNFA(e,t,n,r);let i=this.dfa.match(e,t,n);return i===null?this.doExecuteNFA(e,t,n,r):i?[]:null}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let n=this.pooled.get();do n=this.pooled.get(),!t&&n&&(e=Cs.fromMachine(e),t=!0),e.next!==n&&(e.next=n);while(!this.pooled.compareAndSet(n,e))}toString(){return this.expr}doExecuteNFA(e,t,n,r){let i=this.get(),a=!1;i?i.next!==null&&(i=Cs.fromMachine(i),a=!0):(i=Cs.fromRE2(this),a=!0),i.init(r);let o=i.match(e,t,n)?i.submatches():null;return this.put(i,a),o}match(e){return this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,0)!==null}matchWithGroup(e,t,n,r,i){return e instanceof ss||(e=us.utf16(e)),this.matchMachineInput(e,t,n,r,i)}matchMachineInput(e,t,n,r,i){if(t>n)return[!1,null];let a=e.isUTF16Encoding()?ms.fromUTF16(e.asCharSequence(),0,n):ms.fromUTF8(e.asBytes(),0,n),o=this.executeEngine(a,t,r,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(e){return this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,n){let r=0,i=0,a=``,o=ms.fromUTF16(e),s=0;for(;i<=e.length;){let c=this.executeEngine(o,i,L.UNANCHORED,2);if(c===null||c.length===0)break;a+=e.substring(r,c[0]),(c[1]>r||c[0]===0)&&(a+=t(e.substring(c[0],c[1])),s++),r=c[1];let l=o.step(i)&7;if(i+l>c[1]?i+=l:i+1>c[1]?i++:i=c[1],s>=n)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let n=Array(t).fill(-1);for(let t=0;t<e.length;t++)n[t]=e[t];e=n}return e}allMatches(e,t,n=e=>e){let r=[],i=e.endPos();t<0&&(t=i+1);let a=0,o=0,s=-1;for(;o<t&&a<=i;){let t=this.executeEngine(e,a,L.UNANCHORED,this.prog.numCap);if(t===null||t.length===0)break;let c=!0;if(t[1]===a){t[0]===s&&(c=!1);let n=e.step(a);n<0?a=i+1:a+=n&7}else a=t[1];s=t[1],c&&(r.push(n(this.pad(t))),o++)}return r}findUTF8(e){let t=this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){let t=this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){let t=this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,2);return t===null?``:e.substring(t[0],t[1])}findIndex(e){return this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,2)}findUTF8Submatch(e){let t=this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n}findUTF8SubmatchIndex(e){return this.pad(this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,this.prog.numCap))}findSubmatch(e){let t=this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n}findSubmatchIndex(e){return this.pad(this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){let n=this.allMatches(ms.fromUTF8(e),t,t=>e.slice(t[0],t[1]));return n.length===0?null:n}findAllUTF8Index(e,t){let n=this.allMatches(ms.fromUTF8(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAll(e,t){let n=this.allMatches(ms.fromUTF16(e),t,t=>e.substring(t[0],t[1]));return n.length===0?null:n}findAllIndex(e,t){let n=this.allMatches(ms.fromUTF16(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(e,t){let n=this.allMatches(ms.fromUTF8(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllUTF8SubmatchIndex(e,t){let n=this.allMatches(ms.fromUTF8(e),t);return n.length===0?null:n}findAllSubmatch(e,t){let n=this.allMatches(ms.fromUTF16(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllSubmatchIndex(e,t){let n=this.allMatches(ms.fromUTF16(e),t);return n.length===0?null:n}},ic=class e{static isUpperCaseAlpha(e){return`A`<=e&&e<=`Z`}static isHexadecimal(e){return`0`<=e&&e<=`9`||`A`<=e&&e<=`F`||`a`<=e&&e<=`f`}static getUtf8CharSize(e){let t=e.charCodeAt(0);return t<128?1:t<2048?2:t<65536?3:4}static translate(t){if(typeof t!=`string`)return t;let n=``,r=!1,i=t.length;i===0&&(n=`(?:)`,r=!0);let a=0;for(;a<i;){let o=t[a];if(o===`\\`){if(a+1<i)switch(o=t[a+1],o){case`\\`:n+=`\\\\`,a+=2;continue;case`c`:if(a+2<i){let i=t[a+2];if(e.isUpperCaseAlpha(i)){n+=`\\x`,n+=(i.charCodeAt(0)-64>>4).toString(16).toUpperCase(),n+=(i.charCodeAt(0)-64&15).toString(16).toUpperCase(),a+=3,r=!0;continue}}n+=`\\c`,a+=2;continue;case`u`:if(a+2<i){let o=t[a+2];if(e.isHexadecimal(o)){n+=`\\x{`+o,a+=3;for(let r=0;r<3&&a<i&&(o=t[a],e.isHexadecimal(o));++a,++r)n+=o;n+=`}`,r=!0;continue}if(o===`{`){n+=`\\x`,a+=2,r=!0;continue}}n+=`\\u`,a+=2;continue;default:{n+=`\\`;let r=e.getUtf8CharSize(o);n+=t.substring(a+1,a+1+r),a+=r+1;continue}}}else if(o===`/`){n+=`\\/`,a+=1,r=!0;continue}else if(o===`(`&&a+2<i&&t[a+1]===`?`&&t[a+2]===`<`&&(a+3>=i||t[a+3]!==`=`&&t[a+3]!==`!`)){n+=`(?P<`,a+=3,r=!0;continue}let s=e.getUtf8CharSize(o);n+=t.substring(a,a+s),a+=s}return r?n:t}},ac=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return as.quoteMeta(e)}static translateRegExp(e){return ic.translate(e)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new ys(`Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH`);let i=L.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(i&=-129);let a=new e(t,n);return a.re2Input=rc.compileImpl(r,i,(n&e.LONGEST_MATCH)!==0),a}static matches(t,n){return e.compile(t).testExact(n)}static initTest(t,n,r){if(t==null)throw Error(`pattern is null`);if(r==null)throw Error(`re2 is null`);let i=new e(t,n);return i.re2Input=r,i}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.testExact(e)}matcher(e){return Array.isArray(e)&&(e=us.utf8(e)),new bs(this,e)}test(e){return Array.isArray(e)?this.re2Input.matchUTF8(e):this.re2Input.match(e)}testExact(e){let t=Array.isArray(e)?ms.fromUTF8(e):ms.fromUTF16(e);return this.re2Input.executeEngine(t,0,L.ANCHOR_BOTH,0)!==null}split(e,t=0){let n=this.matcher(e),r=[],i=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(t>0&&r.length===t-1)break;if(a===n.start()){if(t===0){i+=1,a=n.end();continue}}else for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.start())),a=n.end()}if(t===0&&a!==n.inputLength()){for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.inputLength()))}return(t!==0||r.length===0)&&r.push(n.substring(a,n.inputLength())),r}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}});function sc(e){let t=0;return e.includes(`i`)&&(t|=ac.CASE_INSENSITIVE),e.includes(`m`)&&(t|=ac.MULTILINE),e.includes(`s`)&&(t|=ac.DOTALL),t}function cc(e){return ac.translateRegExp(e)}function U(e,t=``,n={}){return new dc(e,t,n)}var lc,uc,dc,fc,pc=T(()=>{oc(),Wi(),j(),lc=1e6,uc=67108864,dc=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;_matcher=null;_matcherInput=null;maxResults;maxOutputBytes;signal;assertResultCount(e){if(this.signal?.aborted)throw Error(`regular expression aborted`);if(e>this.maxResults)throw new A(`regular expression result limit exceeded (${this.maxResults})`,`array_elements`)}expandReplacement(e,t){let n=new Ui(this.maxOutputBytes,`regular expression replacement`),r=this._re2.groupCount(),i=this._re2.namedGroups();for(let a=0;a<t.length;a++){let o=t[a];if(o===`\\`&&a+1<t.length){n.append(t[++a]);continue}if(o!==`$`||a+1>=t.length){n.append(o);continue}if(t[a+1]===`{`){let r=t.indexOf(`}`,a+2);if(r!==-1){let o=t.slice(a+2,r),s=i?.[o];if(s!==void 0){n.append(e.group(s)??``),a=r;continue}}}if(/\d/.test(t[a+1])){let i=a+1,o=0;for(;i<t.length&&/\d/.test(t[i]);){let e=o*10+Number(t[i]);if(e>r)break;o=e,i++}n.append(e.group(o)??``),a=i-1;continue}n.append(o)}return n.build()}acquireMatcher(e){return this._matcher===null?(this._matcher=this._re2.matcher(e),this._matcherInput=e,this._matcher):(this._matcherInput!==e&&(this._matcher.matcherInput.charSequence=e,this._matcherInput=e),this._matcher.reset(),this._matcher)}constructor(e,t=``,n={}){if(this._pattern=e,this._flags=t,this._global=t.includes(`g`),this._ignoreCase=t.includes(`i`),this._multiline=t.includes(`m`),this.maxResults=n.maxResults??lc,this.maxOutputBytes=n.maxOutputBytes??uc,this.signal=n.signal,!Number.isSafeInteger(this.maxResults)||this.maxResults<0||!Number.isSafeInteger(this.maxOutputBytes)||this.maxOutputBytes<0)throw Error(`invalid regular expression limits`);try{let n=cc(e),r=sc(t);this._re2=ac.compile(n,r)}catch(t){if(t instanceof gs){let n=t.message||``,r=``;throw n.includes(`(?=`)||n.includes(`(?!`)||n.includes(`(?<`)||n.includes(`(?<!`)||e.includes(`(?=`)||e.includes(`(?!`)||e.includes(`(?<=`)||e.includes(`(?<!`)?r=` Lookahead (?=, ?!) and lookbehind (?<=, ?<!) assertions are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support these features.`:(n.includes(`backreference`)||/\\[1-9]/.test(e))&&(r=` Backreferences (\\1, \\2, etc.) are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support backreferences.`),SyntaxError(`Invalid regular expression: /${e}/: ${n}${r}`)}throw t}}test(e){return this._global&&(this._lastIndex=0),this.acquireMatcher(e).find()}exec(e){let t=this.acquireMatcher(e),n=this._global?this._lastIndex:0;if(!t.find(n))return this._global&&(this._lastIndex=0),null;let r=this._re2.groupCount(),i=[];i.push(t.group(0)??``);for(let e=1;e<=r;e++){let n=t.group(e);i.push(n)}let a=i;a.index=t.start(0),a.input=e;let o=this._re2.namedGroups();if(o&&Object.keys(o).length>0){let e=Object.create(null);for(let[n,r]of Object.entries(o)){let i=t.group(r);i!==null&&(e[n]=i)}a.groups=e}return this._global&&(this._lastIndex=t.end(0),t.start(0)===t.end(0)&&this._lastIndex++),a}match(e){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(e);let t=[],n=this.acquireMatcher(e),r=0;for(;n.find(r);){let i=n.group(0)??``;if(this.assertResultCount(t.length+1),t.push(i),r=n.end(0),n.start(0)===n.end(0)&&r++,r>e.length)break}return t.length>0?t:null}replace(e,t){if(this._global&&(this._lastIndex=0),typeof t==`string`){let n=this._re2.matcher(e),r=new Ui(this.maxOutputBytes,`regular expression replacement`),i=0,a=0,o=0;for(;n.find(a);){this.assertResultCount(++o);let s=n.start(0),c=n.end(0);if(r.append(e.slice(i,s)),r.append(this.expandReplacement(n,t)),i=c,a=c>s?c:c+1,!this._global||a>e.length)break}return r.append(e.slice(i)),r.build()}let n=new Ui(this.maxOutputBytes,`regular expression replacement`),r=this._re2.matcher(e),i=0,a=0,o=0,s=this._re2.groupCount(),c=this._re2.namedGroups();for(;r.find(a);){this.assertResultCount(++o),n.append(e.slice(i,r.start(0)));let l=[],u=r.group(0)??``;for(let e=1;e<=s;e++)l.push(r.group(e));if(l.push(r.start(0)),l.push(e),c&&Object.keys(c).length>0){let e=Object.create(null);for(let[t,n]of Object.entries(c))e[t]=r.group(n)??``;l.push(e)}let d=r.start(0),f=r.end(0);if(n.append(t(u,...l)),i=f,a=i,d===f&&a++,!this._global||a>e.length)break}return n.append(e.slice(i)),n.build()}split(e,t){if(t===0)return[];let n=t===void 0||t<0?this.maxResults:Math.min(t,this.maxResults),r=[],i=this._re2.matcher(e),a=0,o=0;for(;r.length<n&&i.find(o);)this.assertResultCount(r.length+1),r.push(e.slice(a,i.start(0))),a=i.end(0),o=i.end(0)>i.start(0)?i.end(0):i.end(0)+1;return r.length<n&&r.push(e.slice(a)),r}search(e){let t=this.acquireMatcher(e);return t.find()?t.start(0):-1}*matchAll(e){if(!this._global)throw Error(`matchAll requires global flag`);this._lastIndex=0;let t=this._re2.matcher(e),n=this._re2.groupCount(),r=this._re2.namedGroups(),i=0,a=0;for(;t.find(i);){this.assertResultCount(++a);let o=[];o.push(t.group(0)??``);for(let e=1;e<=n;e++)o.push(t.group(e));let s=o;if(s.index=t.start(0),s.input=e,r&&Object.keys(r).length>0){let e=Object.create(null);for(let[n,i]of Object.entries(r)){let r=t.group(i);r!==null&&(e[n]=r)}s.groups=e}if(yield s,i=t.end(0),t.start(0)===t.end(0)&&i++,i>e.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=RegExp(``,this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(e){this._lastIndex=e}},fc=class{_regex;constructor(e){this._regex=e}test(e){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(e)}exec(e){return this._regex.exec(e)}match(e){return this._regex.global&&(this._regex.lastIndex=0),e.match(this._regex)}replace(e,t){return this._regex.global&&(this._regex.lastIndex=0),e.replace(this._regex,t)}split(e,t){return e.split(this._regex,t)}search(e){return e.search(this._regex)}*matchAll(e){if(!this._regex.global)throw Error(`matchAll requires global flag`);this._regex.lastIndex=0;let t=this._regex.exec(e);for(;t!==null;)yield t,t[0].length===0&&this._regex.lastIndex++,t=this._regex.exec(e)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(e){this._regex.lastIndex=e}}}),mc=T(()=>{pc()});function hc(e,t,n){let r=typeof n==`boolean`?{ignoreCase:n}:n??{},i=t;r.stripQuotes&&(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1));let a=r.ignoreCase?`i:${i}`:i,o=vc.get(a);if(!o){if(o=gc(i,r.ignoreCase),vc.size>=_c){let e=vc.keys().next().value;e!==void 0&&vc.delete(e)}vc.set(a,o)}return o.test(e)}function gc(e,t){let n=`^`;for(let t=0;t<e.length;t++){let r=e[t];if(r===`*`)n+=`.*`;else if(r===`?`)n+=`.`;else if(r===`[`){let r=t+1;for(;r<e.length&&e[r]!==`]`;)r++;n+=e.slice(t,r+1),t=r}else n+=r===`.`||r===`+`||r===`^`||r===`$`||r===`{`||r===`}`||r===`(`||r===`)`||r===`|`||r===`\\`?`\\${r}`:r}return n+=`$`,U(n,t?`i`:``)}var _c,vc,yc=T(()=>{mc(),_c=2048,vc=new Map});function bc(e,t){let n=e.ignoreCase?t.toLowerCase():t,r=e.needles;for(let e=0;e<r.length;e++)if(n.indexOf(r[e])!==-1)return!0;return!1}function xc(e,t){return e.replace(/\$(&|\d+|<([^>]+)>)/g,(e,n,r)=>n===`&`?t[0]:r===void 0?t[parseInt(n,10)]??``:t.groups?.[r]??``)}function Sc(e,t,n={}){let{invertMatch:r=!1,showLineNumbers:i=!1,countOnly:a=!1,countMatches:o=!1,filename:s=``,onlyMatching:c=!1,beforeContext:l=0,afterContext:u=0,maxCount:d=0,contextSeparator:f=`--`,showColumn:p=!1,vimgrep:m=!1,showByteOffset:h=!1,replace:g=null,passthru:_=!1,multiline:v=!1,kResetGroup:y,preFilter:b,maxWork:x,maxMatches:S,signal:ee}=n;if(v)return Cc(e,t,{invertMatch:r,showLineNumbers:i,countOnly:a,countMatches:o,filename:s,onlyMatching:c,beforeContext:l,afterContext:u,maxCount:d,contextSeparator:f,showColumn:p,showByteOffset:h,replace:g,kResetGroup:y,preFilter:b,maxWork:x,maxMatches:S,signal:ee});let C=0,te=(e=1)=>{if(ee?.aborted)throw new kr;if(C+=e,x!==void 0&&C>x)throw new A(`search: matching work limit exceeded (${x})`,`iterations`)},ne=(e,t)=>{if(S!==void 0&&e.length>=S)throw new A(`search: result limit exceeded (${S})`,`array_elements`);e.push(t)},w=1;for(let t=0;t<e.length;t++)if(!(t&1023)&&te(),e.charCodeAt(t)===10&&(w++,S!==void 0&&w>S))throw new A(`search: line limit exceeded (${S})`,`array_elements`);let re=e.split(`
238
- `),ie=re.length,ae=ie>0&&re[ie-1]===``?ie-1:ie;if(a||o){let e=0,n=(o||c)&&!r;for(let i=0;i<ae;i++){te();let a=re[i];if(!(b&&!r&&!bc(b,a)))if(t.lastIndex=0,n)for(let n=t.exec(a);n!==null;n=t.exec(a))te(),e++,n[0].length===0&&t.lastIndex++;else t.test(a)!==r&&e++}return{output:`${s?`${s}:${e}`:String(e)}
239
- `,matched:e>0,matchCount:e}}if(l===0&&u===0&&!_){let e=[],n=!1,a=0,o=0;for(let l=0;l<ae&&(te(),!(d>0&&a>=d));l++){let u=re[l],d=null;if(b&&!bc(b,u)||(t.lastIndex=0,d=t.exec(u)),d!==null!==r)if(n=!0,a++,c)for(let n=d;n!==null;n=t.exec(u)){te();let r=y===void 0?n[0]:n[y]??``,a=g===null?r:xc(g,n),c=s?`${s}:`:``;h&&(c+=`${o+n.index}:`),i&&(c+=`${l+1}:`),p&&(c+=`${n.index+1}:`),ne(e,c+a),n[0].length===0&&t.lastIndex++}else if(m)for(let n=d;n!==null;n=t.exec(u)){te();let r=s?`${s}:`:``;h&&(r+=`${o+n.index}:`),i&&(r+=`${l+1}:`),p&&(r+=`${n.index+1}:`),ne(e,r+u),n[0].length===0&&t.lastIndex++}else{let n=d?d.index+1:1,r=u;g!==null&&(t.lastIndex=0,r=t.replace(u,(...e)=>{if(e[0].length===0)return``;let t=e,n=e[e.length-1];return typeof n==`object`&&n?(t.groups=n,t.input=e[e.length-2],t.index=e[e.length-3]):(t.input=e[e.length-1],t.index=e[e.length-2]),xc(g,t)}));let a=s?`${s}:`:``;h&&(a+=`${o+(d?d.index:0)}:`),i&&(a+=`${l+1}:`),p&&(a+=`${n}:`),ne(e,a+r)}o+=u.length+1}return{output:e.length>0?`${e.join(`
238
+ `),ie=re.length,ae=ie>0&&re[ie-1]===``?ie-1:ie;if(a||o){let e=0,n=(o||c)&&!r;for(let i=0;i<ae;i++){te();let a=re[i];if(!(b&&!r&&!bc(b,a))){if(t.lastIndex=0,n)for(let n=t.exec(a);n!==null;n=t.exec(a))te(),e++,n[0].length===0&&t.lastIndex++;else t.test(a)!==r&&e++}}return{output:`${s?`${s}:${e}`:String(e)}
239
+ `,matched:e>0,matchCount:e}}if(l===0&&u===0&&!_){let e=[],n=!1,a=0,o=0;for(let l=0;l<ae&&(te(),!(d>0&&a>=d));l++){let u=re[l],d=null;if(b&&!bc(b,u)||(t.lastIndex=0,d=t.exec(u)),d!==null!==r){if(n=!0,a++,c)for(let n=d;n!==null;n=t.exec(u)){te();let r=y===void 0?n[0]:n[y]??``,a=g===null?r:xc(g,n),c=s?`${s}:`:``;h&&(c+=`${o+n.index}:`),i&&(c+=`${l+1}:`),p&&(c+=`${n.index+1}:`),ne(e,c+a),n[0].length===0&&t.lastIndex++}else if(m)for(let n=d;n!==null;n=t.exec(u)){te();let r=s?`${s}:`:``;h&&(r+=`${o+n.index}:`),i&&(r+=`${l+1}:`),p&&(r+=`${n.index+1}:`),ne(e,r+u),n[0].length===0&&t.lastIndex++}else{let n=d?d.index+1:1,r=u;g!==null&&(t.lastIndex=0,r=t.replace(u,(...e)=>{if(e[0].length===0)return``;let t=e,n=e[e.length-1];return typeof n==`object`&&n?(t.groups=n,t.input=e[e.length-2],t.index=e[e.length-3]):(t.input=e[e.length-1],t.index=e[e.length-2]),xc(g,t)}));let a=s?`${s}:`:``;h&&(a+=`${o+(d?d.index:0)}:`),i&&(a+=`${l+1}:`),p&&(a+=`${n}:`),ne(e,a+r)}}o+=u.length+1}return{output:e.length>0?`${e.join(`
240
240
  `)}
241
241
  `:``,matched:n,matchCount:a}}if(_){let e=[],n=!1,a=0;for(let o=0;o<ae;o++){te();let c=re[o],l;b&&!bc(b,c)?l=!1:(t.lastIndex=0,l=t.test(c));let u=l!==r;u&&(n=!0,a++);let d=u?`:`:`-`,f=s?`${s}${d}`:``;i&&(f+=`${o+1}${d}`),ne(e,f+c)}return{output:e.length>0?`${e.join(`
242
242
  `)}
@@ -251,7 +251,7 @@ Modify: ${i.mtime.toISOString()}
251
251
  `:``,matched:t.length>0,matchCount:t.length}}if(ie.length===0)return{output:``,matched:!1,matchCount:0};let ae=new Set,oe=-1,se=[];for(let e of ie){S();let n=Math.max(0,e.startLine-l),r=Math.min(ne-1,e.endLine+u);oe>=0&&n>oe+1&&se.push(f);for(let t=n;t<e.startLine;t++)if(S(),!ae.has(t)){ae.add(t),oe=t;let e=C[t];i&&(e=`${t+1}-${e}`),s&&(e=`${s}-${e}`),se.push(e)}if(c){let t=h===null?e.matchText:h,n=s?`${s}:`:``;m&&(n+=`${e.byteOffset}:`),i&&(n+=`${e.startLine+1}:`),p&&(n+=`${e.column}:`),se.push(n+t);for(let t=e.startLine;t<=e.endLine;t++)S(),ae.add(t),oe=t}else for(let n=e.startLine;n<=e.endLine&&n<ne;n++)if(S(),!ae.has(n)){ae.add(n),oe=n;let r=C[n];h!==null&&n===e.startLine&&(t.lastIndex=0,r=t.replace(r,h));let a=s?`${s}:`:``;m&&n===e.startLine&&(a+=`${e.byteOffset}:`),i&&(a+=`${n+1}:`),p&&n===e.startLine&&(a+=`${e.column}:`),se.push(a+r)}for(let t=e.endLine+1;t<=r;t++)if(S(),!ae.has(t)){ae.add(t),oe=t;let e=C[t];i&&(e=`${t+1}-${e}`),s&&(e=`${s}-${e}`),se.push(e)}}return{output:se.length>0?`${se.join(`
252
252
  `)}
253
253
  `:``,matched:!0,matchCount:ie.length}}var wc=T(()=>{j()});function Tc(e){let t=``,n=0;for(;n<e.length;){if(e.slice(n,n+7)===`[[:<:]]`){t+=`\\b`,n+=7;continue}if(e.slice(n,n+7)===`[[:>:]]`){t+=`\\b`,n+=7;continue}if(e[n]===`[`){let r=`[`;for(n++,n<e.length&&(e[n]===`^`||e[n]===`!`)&&(r+=`^`,n++),n<e.length&&e[n]===`]`&&(r+=`\\]`,n++);n<e.length&&e[n]!==`]`;){if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let i=e.slice(n+2,t),a=Vc.get(i);if(a){r+=a,n=t+2;continue}}}if(e[n]===`\\`&&n+1<e.length){r+=e[n]+e[n+1],n+=2;continue}r+=e[n],n++}n<e.length&&e[n]===`]`&&(r+=`]`,n++),t+=r;continue}if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++}return t}function Ec(e,t){let n,r;switch(t.mode){case`fixed`:n=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);break;case`extended`:case`perl`:if(n=Tc(e),n=n.replace(/\(\?P<([^>]+)>/g,`(?<$1>`),t.mode===`perl`){n=Ac(n),n=jc(n),n=Mc(n);let e=Ic(n);n=e.pattern,r=e.kResetGroup}break;default:n=Tc(e),n=Bc(n)}t.wholeWord&&(n=`\\b(?:${n})\\b`),t.lineRegexp&&(n=`^(?:${n})$`);let i=/\\u\{[0-9A-Fa-f]+\}/.test(n),a=`g`+(t.ignoreCase?`i`:``)+(t.multiline?`m`:``)+(t.multilineDotall?`s`:``)+(i?`u`:``),o=Dc(n,t.ignoreCase??!1);return{regex:U(n,a),kResetGroup:r,preFilter:o??void 0}}function Dc(e,t){let n=e;if(n.startsWith(`\\b(?:`)&&n.endsWith(`)\\b`)?n=n.slice(5,n.length-3):n.startsWith(`\\b`)&&n.endsWith(`\\b`)&&n.length>=4&&(n=n.slice(2,n.length-2)),n.length===0)return null;let r=Oc(n);if(r===null)return null;let i=[];for(let e of r){let t=kc(e);if(t===null||t.length===0)return null;i.push(t)}return i.length===0?null:{needles:t?i.map(e=>e.toLowerCase()):i,ignoreCase:t}}function Oc(e){let t=[],n=0,r=!1,i=0;for(let a=0;a<e.length;a++){let o=e[a];if(o===`\\`){a++;continue}if(r){o===`]`&&(r=!1);continue}if(o===`[`)r=!0;else if(o===`(`)n++;else if(o===`)`){if(n--,n<0)return null}else o===`|`&&n===0&&(t.push(e.slice(i,a)),i=a+1)}return n!==0||r?null:(t.push(e.slice(i)),t)}function kc(e){let t=e;if(t.startsWith(`^`)&&(t=t.slice(1)),t.endsWith(`$`)){let e=0;for(let n=t.length-2;n>=0&&t[n]===`\\`;n--)e++;e%2==0&&(t=t.slice(0,-1))}if(t.length===0)return null;let n=``;for(let e=0;e<t.length;e++){let r=t[e];if(r===`\\`){let r=t[e+1];if(r===void 0||/[dDwWsSbBAZzGQE0-9ckpPNXRxuU]/.test(r))return null;n+=r===`n`?`
254
- `:r===`t`?` `:r===`r`?`\r`:r===`f`?`\f`:r===`v`?`\v`:r,e++;continue}if(/[.*+?^${}()|[\]]/.test(r))return null;n+=r}return n}function Ac(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length&&e[n+1]===`Q`){n+=2;let r=``;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length&&e[n+1]===`E`){n+=2;break}r+=e[n],n++}t+=r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}else t+=e[n],n++;return t}function jc(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,`\\u{$1}`)}function Mc(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`(`&&n+1<e.length&&e[n+1]===`?`){let r=e.slice(n).match(/^\(\?([imsx]*)(-[imsx]*)?(:|$|\))/);if(r){let i=r[1]||``,a=r[2]||``,o=r[3];if(o===`:`){let o=n+r[0].length-1,s=Nc(e,n);if(s!==-1){let r=Pc(e.slice(o+1,s),i,a);t+=`(?:${r})`,n=s+1;continue}}else if(o===`)`||o===``){n+=r[0].length;continue}}}t+=e[n],n++}return t}function Nc(e,t){let n=0,r=t;for(;r<e.length;){if(e[r]===`\\`){r+=2;continue}if(e[r]===`[`){for(r++;r<e.length&&e[r]!==`]`;)e[r]===`\\`&&r++,r++;r++;continue}if(e[r]===`(`)n++;else if(e[r]===`)`&&(n--,n===0))return r;r++}return-1}function Pc(e,t,n){let r=e;return t.includes(`i`)&&(r=Fc(r)),r}function Fc(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`\\`){n+1<e.length?(t+=r+e[n+1],n+=2):(t+=r,n++);continue}if(r===`[`){t+=r,n++,n<e.length&&e[n]===`^`&&(t+=e[n],n++);let i=[];for(;n<e.length&&e[n]!==`]`;)if(e[n]===`\\`)i.push(e[n]),n++,n<e.length&&(i.push(e[n]),n++);else if(e[n]===`-`&&i.length>0&&n+1<e.length&&e[n+1]!==`]`){let t=i[i.length-1],r=e[n+1];i.push(`-`),i.push(r),/[a-z]/.test(t)&&/[a-z]/.test(r)?(i.push(t.toUpperCase()),i.push(`-`),i.push(r.toUpperCase())):/[A-Z]/.test(t)&&/[A-Z]/.test(r)&&(i.push(t.toLowerCase()),i.push(`-`),i.push(r.toLowerCase())),n+=2}else{let t=e[n];if(i.push(t),/[a-zA-Z]/.test(t)){let e=t===t.toLowerCase()?t.toUpperCase():t.toLowerCase();i.includes(e)||i.push(e)}n++}t+=i.join(``),n<e.length&&(t+=e[n],n++);continue}if(/[a-zA-Z]/.test(r)){let e=r.toLowerCase(),n=r.toUpperCase();t+=`[${n}${e}]`}else t+=r;n++}return t}function Ic(e){let t=Lc(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),i=Rc(n);return{pattern:`(?:${n})(${r})`,kResetGroup:i+1}}function Lc(e){let t=0;for(;t<e.length-1;)if(e[t]===`\\`){if(e[t+1]===`K`){let n=0,r=t-1;for(;r>=0&&e[r]===`\\`;)n++,r--;if(n%2==0)return t}t+=2}else t++;return-1}function Rc(e){let t=0,n=0;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`[`){for(n++;n<e.length&&e[n]!==`]`;)e[n]===`\\`&&n++,n++;n++;continue}if(e[n]===`(`)if(n+1<e.length&&e[n+1]===`?`){if(n+2<e.length){let r=e[n+2];if(r===`:`||r===`=`||r===`!`){n++;continue}if(r===`<`&&n+3<e.length){let r=e[n+3];if(r===`=`||r===`!`){n++;continue}t++,n++;continue}}}else t++;n++}return t}function zc(e){let t=e.replace(/\$\{0\}|\$0(?![0-9])/g,`$$&`);return t=t.replace(/\$\{([^0-9}][^}]*)\}/g,`$$<$1>`),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,`$$<$1>`),t}function Bc(e){let t=``,n=0,r=!0,i=0;for(;n<e.length;){let a=e[n];if(a===`[`){for(t+=a,n++,n<e.length&&(e[n]===`^`||e[n]===`!`)&&(t+=e[n],n++),n<e.length&&e[n]===`]`&&(t+=e[n],n++);n<e.length&&e[n]!==`]`;)e[n]===`\\`&&n+1<e.length?(t+=e[n]+e[n+1],n+=2):(t+=e[n],n++);n<e.length&&e[n]===`]`&&(t+=e[n],n++),r=!1;continue}if(a===`\\`&&n+1<e.length){let o=e[n+1];if(o===`|`){t+=`|`,n+=2,r=!0;continue}if(o===`(`){t+=`(`,n+=2,i++,r=!0;continue}if(o===`)`){t+=`)`,n+=2,i=Math.max(0,i-1),r=!1;continue}if(o===`{`){let i=e.slice(n).match(/^\\{(\d+)(,(\d*)?)?\\}/);if(i){let e=i[1],a=i[2]!==void 0,o=i[3]||``;t+=a?`{${e},${o}}`:`{${e}}`,n+=i[0].length,r=!1;continue}t+=`\\{`,n+=2,r=!1;continue}if(o===`}`){t+=`\\}`,n+=2,r=!1;continue}t+=a+o,n+=2,r=!1;continue}if(a===`*`&&r){t+=`\\*`,n++;continue}if(a===`^`){if(r){t+=`^`,n++;continue}t+=`\\^`,n++;continue}if(a===`$`){let i=n===e.length-1,a=n+2<e.length&&e[n+1]===`\\`&&e[n+2]===`)`;t+=i||a?`$`:`\\$`,n++,r=!1;continue}t+=a===`+`||a===`?`||a===`|`||a===`(`||a===`)`||a===`{`||a===`}`?`\\${a}`:a,n++,r=!1}return t}var Vc,Hc=T(()=>{mc(),Vc=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_`]])}),Uc=T(()=>{wc(),Hc()}),Wc={};E(Wc,{egrepCommand:()=>ol,egrepFlagsForFuzzing:()=>ll,fgrepCommand:()=>al,fgrepFlagsForFuzzing:()=>cl,flagsForFuzzing:()=>sl,grepCommand:()=>rl});function Gc(e){let t=e.limits.maxLoopIterations,n=e.limits.maxArrayElements;return Math.max(t,Math.min(n,t*10))}function Kc(e){if(++e.operations>e.maxOperations)throw new A(`grep: glob operation limit exceeded (${e.maxOperations})`,`glob_operations`)}function qc(e){if(e.results>=e.maxResults)throw new A(`grep: array element limit exceeded (${e.maxResults})`,`array_elements`);e.results++}function Jc(e){return e.split(`
254
+ `:r===`t`?` `:r===`r`?`\r`:r===`f`?`\f`:r===`v`?`\v`:r,e++;continue}if(/[.*+?^${}()|[\]]/.test(r))return null;n+=r}return n}function Ac(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length&&e[n+1]===`Q`){n+=2;let r=``;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length&&e[n+1]===`E`){n+=2;break}r+=e[n],n++}t+=r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}else t+=e[n],n++;return t}function jc(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,`\\u{$1}`)}function Mc(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`(`&&n+1<e.length&&e[n+1]===`?`){let r=e.slice(n).match(/^\(\?([imsx]*)(-[imsx]*)?(:|$|\))/);if(r){let i=r[1]||``,a=r[2]||``,o=r[3];if(o===`:`){let o=n+r[0].length-1,s=Nc(e,n);if(s!==-1){let r=Pc(e.slice(o+1,s),i,a);t+=`(?:${r})`,n=s+1;continue}}else if(o===`)`||o===``){n+=r[0].length;continue}}}t+=e[n],n++}return t}function Nc(e,t){let n=0,r=t;for(;r<e.length;){if(e[r]===`\\`){r+=2;continue}if(e[r]===`[`){for(r++;r<e.length&&e[r]!==`]`;)e[r]===`\\`&&r++,r++;r++;continue}if(e[r]===`(`)n++;else if(e[r]===`)`&&(n--,n===0))return r;r++}return-1}function Pc(e,t,n){let r=e;return t.includes(`i`)&&(r=Fc(r)),r}function Fc(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`\\`){n+1<e.length?(t+=r+e[n+1],n+=2):(t+=r,n++);continue}if(r===`[`){t+=r,n++,n<e.length&&e[n]===`^`&&(t+=e[n],n++);let i=[];for(;n<e.length&&e[n]!==`]`;)if(e[n]===`\\`)i.push(e[n]),n++,n<e.length&&(i.push(e[n]),n++);else if(e[n]===`-`&&i.length>0&&n+1<e.length&&e[n+1]!==`]`){let t=i[i.length-1],r=e[n+1];i.push(`-`),i.push(r),/[a-z]/.test(t)&&/[a-z]/.test(r)?(i.push(t.toUpperCase()),i.push(`-`),i.push(r.toUpperCase())):/[A-Z]/.test(t)&&/[A-Z]/.test(r)&&(i.push(t.toLowerCase()),i.push(`-`),i.push(r.toLowerCase())),n+=2}else{let t=e[n];if(i.push(t),/[a-zA-Z]/.test(t)){let e=t===t.toLowerCase()?t.toUpperCase():t.toLowerCase();i.includes(e)||i.push(e)}n++}t+=i.join(``),n<e.length&&(t+=e[n],n++);continue}if(/[a-zA-Z]/.test(r)){let e=r.toLowerCase(),n=r.toUpperCase();t+=`[${n}${e}]`}else t+=r;n++}return t}function Ic(e){let t=Lc(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),i=Rc(n);return{pattern:`(?:${n})(${r})`,kResetGroup:i+1}}function Lc(e){let t=0;for(;t<e.length-1;)if(e[t]===`\\`){if(e[t+1]===`K`){let n=0,r=t-1;for(;r>=0&&e[r]===`\\`;)n++,r--;if(n%2==0)return t}t+=2}else t++;return-1}function Rc(e){let t=0,n=0;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`[`){for(n++;n<e.length&&e[n]!==`]`;)e[n]===`\\`&&n++,n++;n++;continue}if(e[n]===`(`){if(n+1<e.length&&e[n+1]===`?`){if(n+2<e.length){let r=e[n+2];if(r===`:`||r===`=`||r===`!`){n++;continue}if(r===`<`&&n+3<e.length){let r=e[n+3];if(r===`=`||r===`!`){n++;continue}t++,n++;continue}}}else t++}n++}return t}function zc(e){let t=e.replace(/\$\{0\}|\$0(?![0-9])/g,`$$&`);return t=t.replace(/\$\{([^0-9}][^}]*)\}/g,`$$<$1>`),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,`$$<$1>`),t}function Bc(e){let t=``,n=0,r=!0,i=0;for(;n<e.length;){let a=e[n];if(a===`[`){for(t+=a,n++,n<e.length&&(e[n]===`^`||e[n]===`!`)&&(t+=e[n],n++),n<e.length&&e[n]===`]`&&(t+=e[n],n++);n<e.length&&e[n]!==`]`;)e[n]===`\\`&&n+1<e.length?(t+=e[n]+e[n+1],n+=2):(t+=e[n],n++);n<e.length&&e[n]===`]`&&(t+=e[n],n++),r=!1;continue}if(a===`\\`&&n+1<e.length){let o=e[n+1];if(o===`|`){t+=`|`,n+=2,r=!0;continue}if(o===`(`){t+=`(`,n+=2,i++,r=!0;continue}if(o===`)`){t+=`)`,n+=2,i=Math.max(0,i-1),r=!1;continue}if(o===`{`){let i=e.slice(n).match(/^\\{(\d+)(,(\d*)?)?\\}/);if(i){let e=i[1],a=i[2]!==void 0,o=i[3]||``;t+=a?`{${e},${o}}`:`{${e}}`,n+=i[0].length,r=!1;continue}t+=`\\{`,n+=2,r=!1;continue}if(o===`}`){t+=`\\}`,n+=2,r=!1;continue}t+=a+o,n+=2,r=!1;continue}if(a===`*`&&r){t+=`\\*`,n++;continue}if(a===`^`){if(r){t+=`^`,n++;continue}t+=`\\^`,n++;continue}if(a===`$`){let i=n===e.length-1,a=n+2<e.length&&e[n+1]===`\\`&&e[n+2]===`)`;t+=i||a?`$`:`\\$`,n++,r=!1;continue}t+=a===`+`||a===`?`||a===`|`||a===`(`||a===`)`||a===`{`||a===`}`?`\\${a}`:a,n++,r=!1}return t}var Vc,Hc=T(()=>{mc(),Vc=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_`]])}),Uc=T(()=>{wc(),Hc()}),Wc={};E(Wc,{egrepCommand:()=>ol,egrepFlagsForFuzzing:()=>ll,fgrepCommand:()=>al,fgrepFlagsForFuzzing:()=>cl,flagsForFuzzing:()=>sl,grepCommand:()=>rl});function Gc(e){let t=e.limits.maxLoopIterations,n=e.limits.maxArrayElements;return Math.max(t,Math.min(n,t*10))}function Kc(e){if(++e.operations>e.maxOperations)throw new A(`grep: glob operation limit exceeded (${e.maxOperations})`,`glob_operations`)}function qc(e){if(e.results>=e.maxResults)throw new A(`grep: array element limit exceeded (${e.maxResults})`,`array_elements`);e.results++}function Jc(e){return e.split(`
255
255
  `)}function Yc(e){if(e===``)return[];let t=e.split(`
256
256
  `);return t[t.length-1]===``&&t.pop(),t}function Xc(e,t){return e.length===1?{pattern:e[0],mode:t}:t===`fixed`?{pattern:e.map(e=>`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`).join(`|`),mode:`extended`}:t===`basic`?{pattern:e.join(`\\|`),mode:t}:{pattern:e.map(e=>`(?:${e})`).join(`|`),mode:t}}async function Zc(e,t,n,r,i,a=0){if(a>=il)return;let o=n.fs.resolvePath(n.cwd,e);try{if(Kc(i),!(await n.fs.stat(o)).isDirectory){let n=e.split(`/`).pop()||``;t&&hc(n,t.replace(/^\//,``),{stripQuotes:!0})&&(qc(i),r.push(e));return}Kc(i);let s=await n.fs.readdir(o);for(let o of s){let s=e===`.`?o:`${e}/${o}`,c=n.fs.resolvePath(n.cwd,s);Kc(i),(await n.fs.stat(c)).isDirectory?await Zc(s,t,n,r,i,a+1):t&&hc(o,t.replace(/^\//,``),{stripQuotes:!0})&&(qc(i),r.push(s))}}catch(e){Ur(e)}}async function Qc(e,t,n){let r=[],i=e.lastIndexOf(`/`),a,o;if(i===-1?(a=t.cwd,o=e):(a=e.slice(0,i)||`/`,o=e.slice(i+1)),e.includes(`**`)){let r=[],i=e.split(`**`);return await Zc(i[0].replace(/\/$/,``)||`.`,i[1]||``,t,r,n),r.map(e=>({path:e}))}let s=t.fs.resolvePath(t.cwd,a);try{if(t.fs.readdirWithFileTypes){Kc(n);let e=await t.fs.readdirWithFileTypes(s);for(let t of e)if(Kc(n),hc(t.name,o,{stripQuotes:!0})){let e=i===-1?t.name:`${a}/${t.name}`;qc(n),r.push({path:e,isFile:t.isFile})}}else{Kc(n);let e=await t.fs.readdir(s);for(let t of e)if(Kc(n),hc(t,o,{stripQuotes:!0})){let e=i===-1?t:`${a}/${t}`;qc(n),r.push({path:e})}}}catch(e){Ur(e)}return r.sort((e,t)=>e.path.localeCompare(t.path))}async function $c(e,t,n=[],r=[],i=[],a,o={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},s=[],c=0){if(c>=il)return s;let l=t.fs.resolvePath(t.cwd,e);try{let u,d;if(a!==void 0)u=a,d=!a;else{Kc(o);let e=await t.fs.stat(l);u=e.isFile,d=e.isDirectory}if(u){let t=e.split(`/`).pop()||e;return r.length>0&&r.some(e=>hc(t,e,{stripQuotes:!0}))||n.length>0&&!n.some(e=>hc(t,e,{stripQuotes:!0}))||(qc(o),s.push({path:e,isFile:!0})),s}if(!d)return s;let f=e.split(`/`).pop()||e;if(i.length>0&&i.some(e=>hc(f,e,{stripQuotes:!0})))return s;if(t.fs.readdirWithFileTypes){Kc(o);let a=await t.fs.readdirWithFileTypes(l);for(let l of a)Kc(o),!l.name.startsWith(`.`)&&await $c(e===`.`?l.name:`${e}/${l.name}`,t,n,r,i,l.isFile,o,s,c+1)}else{Kc(o);let a=await t.fs.readdir(l);for(let l of a)Kc(o),!l.startsWith(`.`)&&await $c(e===`.`?l:`${e}/${l}`,t,n,r,i,void 0,o,s,c+1)}}catch(e){Ur(e)}return s}var el,tl,nl,rl,il,al,ol,sl,cl,ll,ul=T(()=>{k(),Wr(),j(),yc(),F(),Uc(),el=`(standard input)`,tl=`[^\\s\\S]`,nl={name:`grep`,summary:`print lines that match patterns`,usage:`grep [OPTION]... PATTERN [FILE]...`,description:[`Search for PATTERN in each FILE.`,`With no FILE, or when FILE is -, read standard input.`],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`,`-f FILE, --file=FILE obtain patterns from FILE, one per line`,` --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`]},rl={name:`grep`,async execute(e,t){let n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=!1,p=!1,m=!1,h=!1,g=!1,_=0,v=0,y=0,b=[],x=[],S=[],ee=null,C=[],te=[],ne=!0;for(let t=0;t<e.length;t++){let w=e[t];if(ne&&w===`--`){ne=!1;continue}if(ne&&w===`--help`)return M(nl);if(ne&&w.startsWith(`-`)&&w!==`-`){if(w===`-e`&&t+1<e.length){ee=e[++t];continue}if(w.startsWith(`--file=`)){C.push(w.slice(7));continue}if(w.startsWith(`--include=`)){b.push(w.slice(10));continue}if(w.startsWith(`--exclude=`)){x.push(w.slice(10));continue}if(w.startsWith(`--exclude-dir=`)){S.push(w.slice(14));continue}if(w.startsWith(`--max-count=`)){_=parseInt(w.slice(12),10);continue}let te=w.match(/^-m(\d+)$/);if(te){_=parseInt(te[1],10);continue}if(w===`-m`&&t+1<e.length){_=parseInt(e[++t],10);continue}let ne=w.match(/^-([ABC])(\d+)$/);if(ne){let e=parseInt(ne[2],10);ne[1]===`A`?y=e:ne[1]===`B`?v=e:ne[1]===`C`&&(v=e,y=e);continue}if((w===`-A`||w===`-B`||w===`-C`)&&t+1<e.length){let n=parseInt(e[++t],10);w===`-A`?y=n:w===`-B`?v=n:(v=n,y=n);continue}let re=w.startsWith(`--`)?[w]:w.slice(1).split(``);for(let _=0;_<re.length;_++){let v=re[_];if(v===`f`||v===`--file`){let n=v===`f`?re.slice(_+1).join(``):``;if(n.length>0)C.push(n);else if(t+1<e.length)C.push(e[++t]);else return{stdout:``,stderr:v===`f`?`grep: option requires an argument -- 'f'
257
257
  `:`grep: option '--file' requires an argument
@@ -305,7 +305,7 @@ EXAMPLES:
305
305
  rg -l foo List files with matches only`,options:[`-e, --regexp PATTERN search for PATTERN (can be used multiple times)`,`-f, --file FILE read patterns from FILE, one per line`,`-i, --ignore-case case-insensitive search`,`-s, --case-sensitive case-sensitive search (overrides smart-case)`,`-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)`,`-F, --fixed-strings treat pattern as literal string`,`-w, --word-regexp match whole words only`,`-x, --line-regexp match whole lines only`,`-v, --invert-match select non-matching lines`,`-r, --replace TEXT replace matches with TEXT`,`-c, --count print count of matching lines per file`,` --count-matches print count of individual matches per file`,`-l, --files-with-matches print only file names with matches`,` --files-without-match print file names without matches`,` --files list files that would be searched`,`-o, --only-matching print only matching parts`,`-m, --max-count NUM stop after NUM matches per file`,`-q, --quiet suppress output, exit 0 on match`,` --stats print search statistics`,`-n, --line-number print line numbers (default: on)`,`-N, --no-line-number do not print line numbers`,`-I, --no-filename suppress the prefixing of file names`,`-0, --null use NUL as filename separator`,`-b, --byte-offset show byte offset of each match`,` --column show column number of first match`,` --vimgrep show results in vimgrep format`,` --json show results in JSON Lines format`,`-A NUM print NUM lines after each match`,`-B NUM print NUM lines before each match`,`-C NUM print NUM lines before and after each match`,` --context-separator SEP separator for context groups (default: --)`,`-U, --multiline match patterns across lines`,`-z, --search-zip search in compressed files (gzip only)`,`-g, --glob GLOB include files matching GLOB`,`-t, --type TYPE only search files of TYPE (e.g., js, py, ts)`,`-T, --type-not TYPE exclude files of TYPE`,`-L, --follow follow symbolic links`,`-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)`,`-a, --text search binary files as text`,` --hidden search hidden files and directories`,` --no-ignore don't respect .gitignore/.ignore files`,`-d, --max-depth NUM maximum search depth`,` --sort TYPE sort files (path, none)`,` --heading show file path above matches`,` --passthru print all lines (non-matches use - separator)`,` --include-zero include files with 0 matches in count output`,` --type-list list all available file types`,` --help display this help and exit`]},_u={name:`rg`,async execute(e,t){if(N(e))return M(gu);if(e.includes(`--type-list`))return{stdout:Sl(),stderr:``,exitCode:0};let n=zl(e);return n.success?nu({ctx:t,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}},vu={name:`rg`,flags:[{flag:`-i`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-x`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-o`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-N`,type:`boolean`},{flag:`--hidden`,type:`boolean`},{flag:`--no-ignore`,type:`boolean`},{flag:`-m`,type:`value`,valueHint:`number`},{flag:`-A`,type:`value`,valueHint:`number`},{flag:`-B`,type:`value`,valueHint:`number`},{flag:`-C`,type:`value`,valueHint:`number`},{flag:`-g`,type:`value`,valueHint:`pattern`},{flag:`-t`,type:`value`,valueHint:`string`},{flag:`-T`,type:`value`,valueHint:`string`}],needsArgs:!0}});function bu(e,t,n){if(!e||Kn.isInSandboxedContext())return;let r=`${t} ${n} attempted outside defense context`;throw new D(r,{timestamp:Date.now(),type:`missing_defense_context`,message:r,path:`DefenseInDepthBox.context`,stack:Error().stack,executionId:Kn.getCurrentExecutionId()})}async function xu(e,t,n,r){bu(e,t,`${n} (pre-await)`);let i=await r();return bu(e,t,`${n} (post-await)`),i}var Su=T(()=>{qn()});function Cu(e){let t=``,n=0,r=!1;for(;n<e.length;){if(e[n]===`[`&&!r){if(e[n+1]===`[`&&e[n+2]===`:`){let r=e.indexOf(`:]]`,n+3);if(r!==-1){let i=e.slice(n+3,r),a=Eu.get(i);if(a){t+=`[${a}]`,n=r+3;continue}}}if(e[n+1]===`^`&&e[n+2]===`[`&&e[n+3]===`:`){let r=e.indexOf(`:]]`,n+4);if(r!==-1){let i=e.slice(n+4,r),a=Eu.get(i);if(a){t+=`[^${a}]`,n=r+3;continue}}}t+=`[`,n++,r=!0,n<e.length&&e[n]===`^`&&(t+=`^`,n++),n<e.length&&e[n]===`]`&&(t+=`\\]`,n++);continue}if(r){if(e[n]===`]`){t+=`]`,n++,r=!1;continue}if(e[n]===`[`&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r),a=Eu.get(i);if(a){t+=a,n=r+2;continue}}}if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++;continue}if(e[n]===`\\`&&n+1<e.length){let r=e[n+1];if(r===`+`||r===`?`||r===`|`){t+=r,n+=2;continue}if(r===`(`||r===`)`){t+=r,n+=2;continue}if(r===`{`||r===`}`){t+=r,n+=2;continue}if(r===`t`){t+=` `,n+=2;continue}if(r===`n`){t+=`
306
306
  `,n+=2;continue}if(r===`r`){t+=`\r`,n+=2;continue}t+=e[n]+r,n+=2;continue}if(e[n]===`+`||e[n]===`?`||e[n]===`|`||e[n]===`(`||e[n]===`)`){t+=`\\${e[n]}`,n++;continue}if(e[n]===`^`&&!(t===``||t.endsWith(`(`))){t+=`\\^`,n++;continue}if(e[n]===`$`){let r=n===e.length-1,i=n+2<e.length&&e[n+1]===`\\`&&e[n+2]===`)`;if(!r&&!i){t+=`\\$`,n++;continue}}t+=e[n],n++}return t}function wu(e){let t=``,n=!1;for(let r=0;r<e.length;r++)e[r]===`[`&&!n?(n=!0,t+=`[`,r++,r<e.length&&e[r]===`^`&&(t+=`^`,r++),r<e.length&&e[r]===`]`&&(t+=`]`,r++),r--):e[r]===`]`&&n?(n=!1,t+=`]`):!n&&e[r]===`{`&&e[r+1]===`,`?(t+=`{0,`,r++):t+=e[r];return t}function Tu(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=r.charCodeAt(0);t+=r===`\\`?`\\\\`:r===` `?`\\t`:r===`
307
307
  `?`$
308
- `:r===`\r`?`\\r`:r===`\x07`?`\\a`:r===`\b`?`\\b`:r===`\f`?`\\f`:r===`\v`?`\\v`:i<32||i>=127?`\\${i.toString(8).padStart(3,`0`)}`:r}return`${t}$`}var Eu,Du=T(()=>{Eu=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 Ou(e,t,n){return{patternSpace:``,holdSpace:``,lineNumber:0,totalLines:e,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:t,pendingFileReads:[],pendingFileWrites:[],rangeStates:n||new Map,linesConsumedInCycle:0}}function ku(e){return typeof e==`object`&&`first`in e&&`step`in e}function Au(e){return typeof e==`object`&&`offset`in e}function ju(e,t,n,r,i){if(e===`$`)return t===n;if(typeof e==`number`)return t===e;if(ku(e)){let{first:n,step:r}=e;return r===0?t===n:(t-n)%r===0&&t>=n}if(typeof e==`object`&&`pattern`in e)try{let t=e.pattern;return t===``&&i?.lastPattern?t=i.lastPattern:t!==``&&i&&(i.lastPattern=t),U(wu(Cu(t))).test(r)}catch{return!1}return!1}function Mu(e){let t=e=>e===void 0?`undefined`:e===`$`?`$`:typeof e==`number`?String(e):`pattern`in e?`/${e.pattern}/`:`first`in e?`${e.first}~${e.step}`:`unknown`;return`${t(e.start)},${t(e.end)}`}function Nu(e,t,n,r,i,a){if(!e||!e.start&&!e.end)return!0;let o=e.start,s=e.end;if(o!==void 0&&s===void 0)return ju(o,t,n,r,a);if(o!==void 0&&s!==void 0){let c=typeof o==`object`&&`pattern`in o,l=typeof s==`object`&&`pattern`in s,u=Au(s);if(u&&i){let c=Mu(e),l=i.get(c);return l||(l={active:!1},i.set(c,l)),l.active?(t>=(l.startLine||t)+s.offset&&(l.active=!1,i.set(c,l)),!0):ju(o,t,n,r,a)?(l.active=!0,l.startLine=t,i.set(c,l),s.offset===0&&(l.active=!1,i.set(c,l)),!0):!1}if(!c&&!l&&!u){let r=typeof o==`number`?o:o===`$`?n:1,a=typeof s==`number`?s:n;if(r<=a)return t>=r&&t<=a;if(i){let n=Mu(e),a=i.get(n);return a||(a={active:!1},i.set(n,a)),!a.completed&&t>=r&&(a.completed=!0,i.set(n,a),!0)}return!1}if(i){let c=Mu(e),l=i.get(c);if(l||(l={active:!1},i.set(c,l)),l.active)return ju(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0;{if(l.completed)return!1;let e=!1;return e=typeof o==`number`?t>=o:ju(o,t,n,r,a),e?(l.active=!0,l.startLine=t,i.set(c,l),ju(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0):!1}}return ju(o,t,n,r,a)}return!0}function Pu(e,t,n,r,i,a){let o=Nu(e,t,n,r,i,a);return e?.negated?!o:o}function Fu(e,t,n,r){let i=``,a=0,o=!1;for(;a<=e.length;){t.lastIndex=a;let n=t.exec(e);if(!n){i+=e.slice(a);break}if(n.index!==a){i+=e.slice(a,n.index),a=n.index,o=!1;continue}let s=n[0],c=n.slice(1);if(o&&s.length===0){if(a<e.length)i+=e[a],a++;else break;o=!1;continue}if(i+=r(s,c),o=!1,s.length===0)if(a<e.length)i+=e[a],a++;else break;else a+=s.length,o=!0}return i}function Iu(e,t,n){let r=``,i=0;for(;i<e.length;){if(e[i]===`\\`&&i+1<e.length){let a=e[i+1];if(a===`&`){r+=`&`,i+=2;continue}if(a===`n`){r+=`
308
+ `:r===`\r`?`\\r`:r===`\x07`?`\\a`:r===`\b`?`\\b`:r===`\f`?`\\f`:r===`\v`?`\\v`:i<32||i>=127?`\\${i.toString(8).padStart(3,`0`)}`:r}return`${t}$`}var Eu,Du=T(()=>{Eu=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 Ou(e,t,n){return{patternSpace:``,holdSpace:``,lineNumber:0,totalLines:e,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:t,pendingFileReads:[],pendingFileWrites:[],rangeStates:n||new Map,linesConsumedInCycle:0}}function ku(e){return typeof e==`object`&&`first`in e&&`step`in e}function Au(e){return typeof e==`object`&&`offset`in e}function ju(e,t,n,r,i){if(e===`$`)return t===n;if(typeof e==`number`)return t===e;if(ku(e)){let{first:n,step:r}=e;return r===0?t===n:(t-n)%r===0&&t>=n}if(typeof e==`object`&&`pattern`in e)try{let t=e.pattern;return t===``&&i?.lastPattern?t=i.lastPattern:t!==``&&i&&(i.lastPattern=t),U(wu(Cu(t))).test(r)}catch{return!1}return!1}function Mu(e){let t=e=>e===void 0?`undefined`:e===`$`?`$`:typeof e==`number`?String(e):`pattern`in e?`/${e.pattern}/`:`first`in e?`${e.first}~${e.step}`:`unknown`;return`${t(e.start)},${t(e.end)}`}function Nu(e,t,n,r,i,a){if(!e||!e.start&&!e.end)return!0;let o=e.start,s=e.end;if(o!==void 0&&s===void 0)return ju(o,t,n,r,a);if(o!==void 0&&s!==void 0){let c=typeof o==`object`&&`pattern`in o,l=typeof s==`object`&&`pattern`in s,u=Au(s);if(u&&i){let c=Mu(e),l=i.get(c);return l||(l={active:!1},i.set(c,l)),l.active?(t>=(l.startLine||t)+s.offset&&(l.active=!1,i.set(c,l)),!0):ju(o,t,n,r,a)?(l.active=!0,l.startLine=t,i.set(c,l),s.offset===0&&(l.active=!1,i.set(c,l)),!0):!1}if(!c&&!l&&!u){let r=typeof o==`number`?o:o===`$`?n:1,a=typeof s==`number`?s:n;if(r<=a)return t>=r&&t<=a;if(i){let n=Mu(e),a=i.get(n);return a||(a={active:!1},i.set(n,a)),!a.completed&&t>=r&&(a.completed=!0,i.set(n,a),!0)}return!1}if(i){let c=Mu(e),l=i.get(c);if(l||(l={active:!1},i.set(c,l)),l.active)return ju(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0;{if(l.completed)return!1;let e=!1;return e=typeof o==`number`?t>=o:ju(o,t,n,r,a),e?(l.active=!0,l.startLine=t,i.set(c,l),ju(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0):!1}}return ju(o,t,n,r,a)}return!0}function Pu(e,t,n,r,i,a){let o=Nu(e,t,n,r,i,a);return e?.negated?!o:o}function Fu(e,t,n,r){let i=``,a=0,o=!1;for(;a<=e.length;){t.lastIndex=a;let n=t.exec(e);if(!n){i+=e.slice(a);break}if(n.index!==a){i+=e.slice(a,n.index),a=n.index,o=!1;continue}let s=n[0],c=n.slice(1);if(o&&s.length===0){if(a<e.length)i+=e[a],a++;else break;o=!1;continue}if(i+=r(s,c),o=!1,s.length===0){if(a<e.length)i+=e[a],a++;else break}else a+=s.length,o=!0}return i}function Iu(e,t,n){let r=``,i=0;for(;i<e.length;){if(e[i]===`\\`&&i+1<e.length){let a=e[i+1];if(a===`&`){r+=`&`,i+=2;continue}if(a===`n`){r+=`
309
309
  `,i+=2;continue}if(a===`t`){r+=` `,i+=2;continue}if(a===`r`){r+=`\r`,i+=2;continue}let o=parseInt(a,10);if(o===0){r+=t,i+=2;continue}if(o>=1&&o<=9){r+=n[o-1]||``,i+=2;continue}r+=a,i+=2;continue}if(e[i]===`&`){r+=t,i++;continue}r+=e[i],i++}return r}function Lu(e,t,n){if(t>0&&e.length>t)throw new A(`sed: ${n} size limit exceeded (${t} bytes)`,`string_length`)}function Ru(e,t,n){let{lineNumber:r,totalLines:i,patternSpace:a}=t;if(e.type===`label`){t.coverage?.hit(`sed:cmd:${e.type}`);return}if(Pu(e.address,r,i,a,t.rangeStates,t))switch(t.coverage?.hit(`sed:cmd:${e.type}`),e.type){case`substitute`:{let n=e,r=``;n.global&&(r+=`g`),n.ignoreCase&&(r+=`i`);let i=n.pattern;i===``&&t.lastPattern?i=t.lastPattern:i!==``&&(t.lastPattern=i);let a=wu(n.extendedRegex?i:Cu(i));try{let e=U(a,r),i=e.test(t.patternSpace);if(e.lastIndex=0,i){if(t.substitutionMade=!0,n.nthOccurrence&&n.nthOccurrence>0&&!n.global){let e=0,r=n.nthOccurrence;t.patternSpace=U(a,`g${n.ignoreCase?`i`:``}`).replace(t.patternSpace,(t,...i)=>{if(e++,e===r){let e=i.slice(0,-2);return Iu(n.replacement,t,e)}return t})}else if(n.global){let e=U(a,`g${n.ignoreCase?`i`:``}`);t.patternSpace=Fu(t.patternSpace,e,n.replacement,(e,t)=>Iu(n.replacement,e,t))}else t.patternSpace=e.replace(t.patternSpace,(e,...t)=>{let r=t.slice(0,-2);return Iu(n.replacement,e,r)});n.printOnMatch&&t.lineNumberOutput.push(t.patternSpace)}}catch{}break}case`print`:t.lineNumberOutput.push(t.patternSpace);break;case`printFirstLine`:{let e=t.patternSpace.indexOf(`
310
310
  `);e===-1?t.lineNumberOutput.push(t.patternSpace):t.lineNumberOutput.push(t.patternSpace.slice(0,e));break}case`delete`:t.deleted=!0;break;case`deleteFirstLine`:{let e=t.patternSpace.indexOf(`
311
311
  `);e===-1?t.deleted=!0:(t.patternSpace=t.patternSpace.slice(e+1),t.restartCycle=!0,t.inDRestartedCycle=!0);break}case`zap`:t.patternSpace=``;break;case`append`:t.appendBuffer.push(e.text);break;case`insert`:t.appendBuffer.unshift(`__INSERT__${e.text}`);break;case`change`:t.deleted=!0,t.changedText=e.text;break;case`hold`:t.holdSpace=t.patternSpace;break;case`holdAppend`:t.holdSpace?t.holdSpace+=`
@@ -313,8 +313,8 @@ ${t.patternSpace}`:t.holdSpace=t.patternSpace,Lu(t.holdSpace,n?.maxStringLength?
313
313
  ${t.holdSpace}`,Lu(t.patternSpace,n?.maxStringLength??0,`pattern space`);break;case`exchange`:{let e=t.patternSpace;t.patternSpace=t.holdSpace,t.holdSpace=e;break}case`next`:t.printed=!0;break;case`quit`:t.quit=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case`quitSilent`:t.quit=!0,t.quitSilent=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case`list`:{let e=Tu(t.patternSpace);t.lineNumberOutput.push(e);break}case`printFilename`:t.currentFilename&&t.lineNumberOutput.push(t.currentFilename);break;case`version`:{let n=[4,8,0];if(e.minVersion){let r=e.minVersion.split(`.`),i=[],a=!1;for(let n of r){let r=parseInt(n,10);if(Number.isNaN(r)||r<0){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: invalid version string: ${e.minVersion}`,a=!0;break}i.push(r)}if(!a){for(;i.length<3;)i.push(0);for(let r=0;r<3;r++){if(i[r]>n[r]){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: this is not GNU sed version ${e.minVersion}`;break}if(i[r]<n[r])break}}}break}case`readFile`:t.pendingFileReads.push({filename:e.filename,wholeFile:!0});break;case`readFileLine`:t.pendingFileReads.push({filename:e.filename,wholeFile:!1});break;case`writeFile`:t.pendingFileWrites.push({filename:e.filename,content:`${t.patternSpace}
314
314
  `});break;case`writeFirstLine`:{let n=t.patternSpace.indexOf(`
315
315
  `),r=n===-1?t.patternSpace:t.patternSpace.slice(0,n);t.pendingFileWrites.push({filename:e.filename,content:`${r}
316
- `});break}case`execute`:t.errorMessage=`sed: e command (shell execution) is not supported in sandboxed environment`,t.quit=!0;break;case`transliterate`:t.patternSpace=zu(t.patternSpace,e);break;case`lineNumber`:t.lineNumberOutput.push(String(t.lineNumber));break;case`branch`:break;case`branchOnSubst`:break;case`branchOnNoSubst`:break;case`group`:break}}function zu(e,t){let n=``;for(let r of e){let e=t.source.indexOf(r);n+=e===-1?r:t.dest[e]}return n}function Bu(e,t,n,r){let i=new Map;for(let t=0;t<e.length;t++){let n=e[t];n.type===`label`&&i.set(n.name,t)}let a=r?.maxIterations??Vu,o=0,s=0;for(;s<e.length;){if(o++,o>a)throw new A(`sed: command execution exceeded maximum iterations (${a})`,`iterations`);if(t.deleted||t.quit||t.quitSilent||t.restartCycle)break;let c=e[s];if(c.type===`next`){if(Pu(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t))if(t.coverage?.hit(`sed:cmd:next`),t.nCommandOutput.push(t.patternSpace),n&&n.currentLineIndex+t.linesConsumedInCycle+1<n.lines.length)t.linesConsumedInCycle++,t.patternSpace=n.lines[n.currentLineIndex+t.linesConsumedInCycle],t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1,t.substitutionMade=!1;else{t.quit=!0,t.deleted=!0;break}s++;continue}if(c.type===`nextAppend`){if(Pu(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t))if(t.coverage?.hit(`sed:cmd:nextAppend`),n&&n.currentLineIndex+t.linesConsumedInCycle+1<n.lines.length){t.linesConsumedInCycle++;let e=n.lines[n.currentLineIndex+t.linesConsumedInCycle];t.patternSpace+=`
317
- ${e}`,t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1}else{t.quit=!0;break}s++;continue}if(c.type===`branch`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)){if(t.coverage?.hit(`sed:cmd:branch`),e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`branchOnSubst`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:branchOnSubst`),t.substitutionMade)){if(t.substitutionMade=!1,e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`branchOnNoSubst`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:branchOnNoSubst`),!t.substitutionMade)){if(e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`group`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:group`),Bu(e.commands,t,n,r),t.branchRequest)){let e=i.get(t.branchRequest);if(e!==void 0){t.branchRequest=void 0,s=e;continue}break}s++;continue}Ru(c,t,r),s++}return t.linesConsumedInCycle}var Vu,Hu=T(()=>{j(),mc(),Du(),Vu=1e4}),W,Uu,Wu=T(()=>{j(),(function(e){e.NUMBER=`NUMBER`,e.DOLLAR=`DOLLAR`,e.PATTERN=`PATTERN`,e.STEP=`STEP`,e.RELATIVE_OFFSET=`RELATIVE_OFFSET`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.COMMA=`COMMA`,e.NEGATION=`NEGATION`,e.COMMAND=`COMMAND`,e.SUBSTITUTE=`SUBSTITUTE`,e.TRANSLITERATE=`TRANSLITERATE`,e.LABEL_DEF=`LABEL_DEF`,e.BRANCH=`BRANCH`,e.BRANCH_ON_SUBST=`BRANCH_ON_SUBST`,e.BRANCH_ON_NO_SUBST=`BRANCH_ON_NO_SUBST`,e.TEXT_CMD=`TEXT_CMD`,e.FILE_READ=`FILE_READ`,e.FILE_READ_LINE=`FILE_READ_LINE`,e.FILE_WRITE=`FILE_WRITE`,e.FILE_WRITE_LINE=`FILE_WRITE_LINE`,e.EXECUTE=`EXECUTE`,e.VERSION=`VERSION`,e.EOF=`EOF`,e.ERROR=`ERROR`})(W||={}),Uu=class{maxInputLength;maxTokens;input;pos=0;line=1;column=1;constructor(e,t=1048576,n=1e5){this.maxInputLength=t,this.maxTokens=n,this.input=e}tokenize(){if(this.input.length>this.maxInputLength)throw new A(`sed: script size limit exceeded (${this.maxInputLength} bytes)`,`string_length`);let e=[];for(;this.pos<this.input.length;){let t=this.nextToken();if(t){if(e.length>=this.maxTokens-1)throw new A(`sed: token limit exceeded (${this.maxTokens})`,`array_elements`);e.push(t)}}return e.push(this.makeToken(W.EOF,``)),e}makeToken(e,t,n){return{type:e,value:t,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===`
316
+ `});break}case`execute`:t.errorMessage=`sed: e command (shell execution) is not supported in sandboxed environment`,t.quit=!0;break;case`transliterate`:t.patternSpace=zu(t.patternSpace,e);break;case`lineNumber`:t.lineNumberOutput.push(String(t.lineNumber));break;case`branch`:break;case`branchOnSubst`:break;case`branchOnNoSubst`:break;case`group`:break}}function zu(e,t){let n=``;for(let r of e){let e=t.source.indexOf(r);n+=e===-1?r:t.dest[e]}return n}function Bu(e,t,n,r){let i=new Map;for(let t=0;t<e.length;t++){let n=e[t];n.type===`label`&&i.set(n.name,t)}let a=r?.maxIterations??Vu,o=0,s=0;for(;s<e.length;){if(o++,o>a)throw new A(`sed: command execution exceeded maximum iterations (${a})`,`iterations`);if(t.deleted||t.quit||t.quitSilent||t.restartCycle)break;let c=e[s];if(c.type===`next`){if(Pu(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)){if(t.coverage?.hit(`sed:cmd:next`),t.nCommandOutput.push(t.patternSpace),n&&n.currentLineIndex+t.linesConsumedInCycle+1<n.lines.length)t.linesConsumedInCycle++,t.patternSpace=n.lines[n.currentLineIndex+t.linesConsumedInCycle],t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1,t.substitutionMade=!1;else{t.quit=!0,t.deleted=!0;break}}s++;continue}if(c.type===`nextAppend`){if(Pu(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)){if(t.coverage?.hit(`sed:cmd:nextAppend`),n&&n.currentLineIndex+t.linesConsumedInCycle+1<n.lines.length){t.linesConsumedInCycle++;let e=n.lines[n.currentLineIndex+t.linesConsumedInCycle];t.patternSpace+=`
317
+ ${e}`,t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1}else{t.quit=!0;break}}s++;continue}if(c.type===`branch`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)){if(t.coverage?.hit(`sed:cmd:branch`),e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`branchOnSubst`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:branchOnSubst`),t.substitutionMade)){if(t.substitutionMade=!1,e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`branchOnNoSubst`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:branchOnNoSubst`),!t.substitutionMade)){if(e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`group`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:group`),Bu(e.commands,t,n,r),t.branchRequest)){let e=i.get(t.branchRequest);if(e!==void 0){t.branchRequest=void 0,s=e;continue}break}s++;continue}Ru(c,t,r),s++}return t.linesConsumedInCycle}var Vu,Hu=T(()=>{j(),mc(),Du(),Vu=1e4}),W,Uu,Wu=T(()=>{j(),(function(e){e.NUMBER=`NUMBER`,e.DOLLAR=`DOLLAR`,e.PATTERN=`PATTERN`,e.STEP=`STEP`,e.RELATIVE_OFFSET=`RELATIVE_OFFSET`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.COMMA=`COMMA`,e.NEGATION=`NEGATION`,e.COMMAND=`COMMAND`,e.SUBSTITUTE=`SUBSTITUTE`,e.TRANSLITERATE=`TRANSLITERATE`,e.LABEL_DEF=`LABEL_DEF`,e.BRANCH=`BRANCH`,e.BRANCH_ON_SUBST=`BRANCH_ON_SUBST`,e.BRANCH_ON_NO_SUBST=`BRANCH_ON_NO_SUBST`,e.TEXT_CMD=`TEXT_CMD`,e.FILE_READ=`FILE_READ`,e.FILE_READ_LINE=`FILE_READ_LINE`,e.FILE_WRITE=`FILE_WRITE`,e.FILE_WRITE_LINE=`FILE_WRITE_LINE`,e.EXECUTE=`EXECUTE`,e.VERSION=`VERSION`,e.EOF=`EOF`,e.ERROR=`ERROR`})(W||={}),Uu=class{maxInputLength;maxTokens;input;pos=0;line=1;column=1;constructor(e,t=1048576,n=1e5){this.maxInputLength=t,this.maxTokens=n,this.input=e}tokenize(){if(this.input.length>this.maxInputLength)throw new A(`sed: script size limit exceeded (${this.maxInputLength} bytes)`,`string_length`);let e=[];for(;this.pos<this.input.length;){let t=this.nextToken();if(t){if(e.length>=this.maxTokens-1)throw new A(`sed: token limit exceeded (${this.maxTokens})`,`array_elements`);e.push(t)}}return e.push(this.makeToken(W.EOF,``)),e}makeToken(e,t,n){return{type:e,value:t,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===`
318
318
  `?(this.line++,this.column=1):this.column++,e}readEscapedString(e){let t=``;for(;this.pos<this.input.length&&this.peek()!==e;)if(this.peek()===`\\`){this.advance();let e=this.advance();t+=e===`n`?`
319
319
  `:e===`t`?` `:e}else{if(this.peek()===`
320
320
  `)return null;t+=this.advance()}return t}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===` `||e===` `||e===`\r`)this.advance();else if(e===`#`)for(;this.pos<this.input.length&&this.peek()!==`
@@ -326,11 +326,11 @@ ${e}`,t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1}else{t.quit=!0;br
326
326
  `||e===`;`||e===`}`||e===`{`)break;n+=this.advance()}return{type:W.LABEL_DEF,value:n,label:n,line:e,column:t}}readCommand(){let e=this.line,t=this.column,n=this.advance();switch(n){case`s`:return this.readSubstitute(e,t);case`y`:return this.readTransliterate(e,t);case`a`:case`i`:case`c`:return this.readTextCommand(n,e,t);case`b`:return this.readBranch(W.BRANCH,`b`,e,t);case`t`:return this.readBranch(W.BRANCH_ON_SUBST,`t`,e,t);case`T`:return this.readBranch(W.BRANCH_ON_NO_SUBST,`T`,e,t);case`r`:return this.readFileCommand(W.FILE_READ,`r`,e,t);case`R`:return this.readFileCommand(W.FILE_READ_LINE,`R`,e,t);case`w`:return this.readFileCommand(W.FILE_WRITE,`w`,e,t);case`W`:return this.readFileCommand(W.FILE_WRITE_LINE,`W`,e,t);case`e`:return this.readExecute(e,t);case`p`:case`P`:case`d`:case`D`:case`h`:case`H`:case`g`:case`G`:case`x`:case`n`:case`N`:case`q`:case`Q`:case`z`:case`=`:case`l`:case`F`:return{type:W.COMMAND,value:n,line:e,column:t};case`v`:return this.readVersion(e,t);default:return{type:W.ERROR,value:n,line:e,column:t}}}readSubstitute(e,t){let n=this.advance();if(!n||n===`
327
327
  `)return{type:W.ERROR,value:`s`,line:e,column:t};let r=``,i=!1;for(;this.pos<this.input.length;){let e=this.peek();if(e===n&&!i)break;if(e===`\\`)this.advance(),this.pos<this.input.length&&this.peek()!==`
328
328
  `?(this.peek()===n&&!i||(r+=`\\`),r+=this.advance()):r+=`\\`;else{if(e===`
329
- `)break;e===`[`&&!i?(i=!0,r+=this.advance(),this.peek()===`^`&&(r+=this.advance()),this.peek()===`]`&&(r+=this.advance())):(e===`]`&&i&&(i=!1),r+=this.advance())}}if(this.peek()!==n)return{type:W.ERROR,value:`unterminated substitution pattern`,line:e,column:t};this.advance();let a=``;for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()===`\\`)if(this.advance(),this.pos<this.input.length){let e=this.peek();e===`\\`?(this.advance(),this.pos<this.input.length&&this.peek()===`
329
+ `)break;e===`[`&&!i?(i=!0,r+=this.advance(),this.peek()===`^`&&(r+=this.advance()),this.peek()===`]`&&(r+=this.advance())):(e===`]`&&i&&(i=!1),r+=this.advance())}}if(this.peek()!==n)return{type:W.ERROR,value:`unterminated substitution pattern`,line:e,column:t};this.advance();let a=``;for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()===`\\`){if(this.advance(),this.pos<this.input.length){let e=this.peek();e===`\\`?(this.advance(),this.pos<this.input.length&&this.peek()===`
330
330
  `?(a+=`
331
331
  `,this.advance()):a+=`\\`):e===`
332
332
  `?(a+=`
333
- `,this.advance()):a+=`\\${this.advance()}`}else a+=`\\`;else{if(this.peek()===`
333
+ `,this.advance()):a+=`\\${this.advance()}`}else a+=`\\`}else{if(this.peek()===`
334
334
  `)break;a+=this.advance()}this.peek()===n&&this.advance();let o=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===`g`||e===`i`||e===`p`||e===`I`||this.isDigit(e))o+=this.advance();else break}return{type:W.SUBSTITUTE,value:`s${n}${r}${n}${a}${n}${o}`,pattern:r,replacement:a,flags:o,line:e,column:t}}readTransliterate(e,t){let n=this.advance();if(!n||n===`
335
335
  `)return{type:W.ERROR,value:`y`,line:e,column:t};let r=this.readEscapedString(n);if(r===null||this.peek()!==n)return{type:W.ERROR,value:`unterminated transliteration source`,line:e,column:t};this.advance();let i=this.readEscapedString(n);if(i===null||this.peek()!==n)return{type:W.ERROR,value:`unterminated transliteration dest`,line:e,column:t};this.advance();let a=this.peek();for(;a===` `||a===` `;)this.advance(),a=this.peek();return a!==``&&a!==`;`&&a!==`
336
336
  `&&a!==`}`?{type:W.ERROR,value:`extra text at the end of a transform command`,line:e,column:t}:{type:W.TRANSLITERATE,value:`y${n}${r}${n}${i}${n}`,source:r,dest:i,line:e,column:t}}readTextCommand(e,t,n){let r=!1;this.peek()===`\\`&&this.pos+1<this.input.length&&(this.input[this.pos+1]===`
@@ -406,8 +406,8 @@ Addresses:
406
406
  `);break;case`t`:c(` `);break;case`r`:c(`\r`);break;case`\\`:c(`\\`);break;default:c(t)}o+=2}else c(e[o++]);return i}var Jd,Yd,Xd,Zd=T(()=>{Wi(),k(),Wr(),j(),mc(),Jd=10485760,Yd=1e4,Xd=new Map([[`length`,Cd],[`substr`,wd],[`index`,Td],[`split`,Ed],[`sub`,Dd],[`gsub`,Od],[`match`,Ad],[`gensub`,jd],[`tolower`,Nd],[`toupper`,Pd],[`sprintf`,Fd],[`int`,Id],[`sqrt`,Ld],[`sin`,Rd],[`cos`,zd],[`atan2`,Bd],[`log`,Vd],[`exp`,Hd],[`rand`,Ud],[`srand`,Wd],[`system`,Gd(`system`,`shell execution not allowed in sandboxed environment`)],[`close`,()=>0],[`fflush`,()=>0],[`systime`,Kd(`systime`)],[`mktime`,Kd(`mktime`)],[`strftime`,Kd(`strftime`)]])});function Qd(e){return typeof e==`number`?e!==0:e!==``&&e!==`0`}function $d(e){if(typeof e==`number`)return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function ef(e){return typeof e==`string`?e:String(e)}function tf(e){if(typeof e==`number`)return!0;let t=String(e).trim();return t!==``&&!Number.isNaN(Number(t))}function nf(e,t){try{return U(e).test(t)}catch{return!1}}var rf=T(()=>{mc()});function af(e,t){return t===``?[]:e.FS===` `?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function of(e,t){return t===0?e.line:t<0||t>e.fields.length?``:e.fields[t-1]??``}function sf(e,t,n){if(t===0)e.line=ef(n),e.fields=af(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push(``);e.fields[t-1]=ef(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function cf(e,t){e.line=t,e.fields=af(e,t),e.NF=e.fields.length}function lf(e,t){if(e.FS=t,t===` `)e.fieldSep=new fc(/\s+/);else try{e.fieldSep=U(t)}catch{e.fieldSep=U(t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`))}}var uf=T(()=>{mc(),rf()});function df(e,t){switch(t){case`FS`:return e.FS;case`OFS`:return e.OFS;case`ORS`:return e.ORS;case`OFMT`:return e.OFMT;case`NR`:return e.NR;case`NF`:return e.NF;case`FNR`:return e.FNR;case`FILENAME`:return e.FILENAME;case`RSTART`:return e.RSTART;case`RLENGTH`:return e.RLENGTH;case`SUBSEP`:return e.SUBSEP;case`ARGC`:return e.ARGC}return e.vars[t]??``}function ff(e,t,n){switch(t){case`FS`:lf(e,ef(n));return;case`OFS`:e.OFS=ef(n);return;case`ORS`:e.ORS=ef(n);return;case`OFMT`:e.OFMT=ef(n);return;case`NR`:e.NR=Math.floor($d(n));return;case`NF`:{let t=Math.floor($d(n));if(t<e.NF)e.fields=e.fields.slice(0,t),e.line=e.fields.join(e.OFS);else if(t>e.NF){for(;e.fields.length<t;)e.fields.push(``);e.line=e.fields.join(e.OFS)}e.NF=t;return}case`FNR`:e.FNR=Math.floor($d(n));return;case`FILENAME`:e.FILENAME=ef(n);return;case`RSTART`:e.RSTART=Math.floor($d(n));return;case`RLENGTH`:e.RLENGTH=Math.floor($d(n));return;case`SUBSEP`:e.SUBSEP=ef(n);return}e.vars[t]=n}function pf(e,t){let n=t,r=new Set,i=e.arrayAliases.get(n);for(;i!==void 0&&!r.has(n);)r.add(n),n=i,i=e.arrayAliases.get(n);return n}function mf(e,t,n){if(t===`ARGV`)return e.ARGV[n]??``;if(t===`ENVIRON`)return e.ENVIRON[n]??``;let r=pf(e,t);return e.arrays[r]?.[n]??``}function hf(e,t,n,r){let i=pf(e,t);if(e.arrays[i]||(e.arrays[i]=Object.create(null)),!(n in e.arrays[i])){if(e.arrayElementCount>=e.maxArrayElements)throw new A(`array element limit exceeded (${e.maxArrayElements})`,`array_elements`);e.arrayElementCount++}e.arrays[i][n]=r}function gf(e,t,n){if(t===`ARGV`)return e.ARGV[n]!==void 0;if(t===`ENVIRON`)return e.ENVIRON[n]!==void 0;let r=pf(e,t);return e.arrays[r]?.[n]!==void 0}function _f(e,t,n){let r=pf(e,t);e.arrays[r]&&(n in e.arrays[r]&&e.arrayElementCount--,delete e.arrays[r][n])}function vf(e,t){let n=pf(e,t);e.arrayElementCount-=Object.keys(e.arrays[n]??{}).length,delete e.arrays[n]}var yf=T(()=>{j(),uf(),rf()});function bf(e){Hf=e}function xf(e,t){bu(e.requireDefenseContext,`awk`,t)}function Sf(e,t,n){return xu(e.requireDefenseContext,`awk`,t,n)}async function G(e,t){switch(xf(e,`expression evaluation`),e.coverage?.hit(`awk:expr:${t.type}`),t.type){case`number`:return t.value;case`string`:return t.value;case`regex`:return+!!nf(t.pattern,e.line);case`field`:return Cf(e,t);case`variable`:return df(e,t.name);case`array_access`:return wf(e,t);case`binary`:return Tf(e,t);case`unary`:return Of(e,t);case`ternary`:return Qd(await Sf(e,`ternary condition evaluation`,()=>G(e,t.condition)))?await Sf(e,`ternary consequent evaluation`,()=>G(e,t.consequent)):await Sf(e,`ternary alternate evaluation`,()=>G(e,t.alternate));case`call`:return kf(e,t.name,t.args);case`assignment`:return jf(e,t);case`pre_increment`:return Nf(e,t.operand);case`pre_decrement`:return Pf(e,t.operand);case`post_increment`:return Ff(e,t.operand);case`post_decrement`:return If(e,t.operand);case`in`:return Lf(e,t.key,t.array);case`getline`:return Rf(e,t.variable,t.file,t.command);case`tuple`:return Vf(e,t.elements);default:return``}}async function Cf(e,t){return xf(e,`field reference evaluation`),of(e,Math.floor($d(await Sf(e,`field index evaluation`,()=>G(e,t.index)))))}async function wf(e,t){xf(e,`array access evaluation`);let n=ef(await Sf(e,`array key evaluation`,()=>G(e,t.key)));return mf(e,t.array,n)}async function Tf(e,t){xf(e,`binary expression evaluation`);let n=t.operator;if(n===`||`)return Qd(await Sf(e,`logical-or left evaluation`,()=>G(e,t.left)))||Qd(await Sf(e,`logical-or right evaluation`,()=>G(e,t.right)))?1:0;if(n===`&&`)return Qd(await Sf(e,`logical-and left evaluation`,()=>G(e,t.left)))&&Qd(await Sf(e,`logical-and right evaluation`,()=>G(e,t.right)))?1:0;if(n===`~`){let n=await Sf(e,`regex left evaluation`,()=>G(e,t.left));t.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let r=t.right.type===`regex`?t.right.pattern:ef(await Sf(e,`regex right evaluation`,()=>G(e,t.right)));try{return+!!U(r).test(ef(n))}catch{return 0}}if(n===`!~`){let n=await Sf(e,`negated-regex left evaluation`,()=>G(e,t.left));t.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let r=t.right.type===`regex`?t.right.pattern:ef(await Sf(e,`negated-regex right evaluation`,()=>G(e,t.right)));try{return+!U(r).test(ef(n))}catch{return 1}}let r=await Sf(e,`binary left evaluation`,()=>G(e,t.left)),i=await Sf(e,`binary right evaluation`,()=>G(e,t.right));if(n===` `){let t=ef(r)+ef(i);if(e.maxOutputSize>0&&t.length>e.maxOutputSize)throw new A(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output);return t}return Ef(n)?Df(r,i,n):fd($d(r),$d(i),n)}function Ef(e){return[`<`,`<=`,`>`,`>=`,`==`,`!=`].includes(e)}function Df(e,t,n){let r=tf(e),i=tf(t);if(r&&i){let r=$d(e),i=$d(t);switch(n){case`<`:return+(r<i);case`<=`:return+(r<=i);case`>`:return+(r>i);case`>=`:return+(r>=i);case`==`:return+(r===i);case`!=`:return r===i?0:1}}let a=ef(e),o=ef(t);switch(n){case`<`:return+(a<o);case`<=`:return+(a<=o);case`>`:return+(a>o);case`>=`:return+(a>=o);case`==`:return+(a===o);case`!=`:return a===o?0:1}return 0}async function Of(e,t){xf(e,`unary expression evaluation`);let n=await Sf(e,`unary operand evaluation`,()=>G(e,t.operand));switch(t.operator){case`!`:return+!Qd(n);case`-`:return-$d(n);case`+`:return+$d(n);default:return n}}async function kf(e,t,n){xf(e,`function call evaluation`);let r=Xd.get(t);if(r)return r(n,e,{evalExpr:t=>G(e,t)});let i=e.functions.get(t);return i?Af(e,i,n):``}async function Af(e,t,n){if(xf(e,`user function call`),e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new A(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,`recursion`,e.output);let r=Object.create(null);for(let n of t.params)r[n]=e.vars[n];let i=[];for(let r=0;r<t.params.length;r++){let a=t.params[r];if(r<n.length){let t=n[r];t.type===`variable`&&(e.arrayAliases.set(a,t.name),i.push(a));let o=await Sf(e,`user function argument evaluation`,()=>G(e,t));e.vars[a]=o}else e.vars[a]=``}e.hasReturn=!1,e.returnValue=void 0;let a=Hf;a&&await Sf(e,`user function body execution`,()=>a(e,t.body.statements));let o=e.returnValue??``;for(let n of t.params)r[n]===void 0?delete e.vars[n]:e.vars[n]=r[n];for(let t of i)e.arrayAliases.delete(t);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,o}async function jf(e,t){xf(e,`assignment evaluation`);let n=await Sf(e,`assignment value evaluation`,()=>G(e,t.value)),r=t.target,i=t.operator,a;if(i===`=`)a=n;else{let t;if(r.type===`field`)t=of(e,Math.floor($d(await Sf(e,`assignment field index`,()=>G(e,r.index)))));else if(r.type===`variable`)t=df(e,r.name);else{let n=ef(await Sf(e,`assignment array key`,()=>G(e,r.key)));t=mf(e,r.array,n)}let o=$d(t),s=$d(n);switch(i){case`+=`:a=o+s;break;case`-=`:a=o-s;break;case`*=`:a=o*s;break;case`/=`:a=s===0?0:o/s;break;case`%=`:a=s===0?0:o%s;break;case`^=`:a=o**s;break;default:a=n}}if(r.type===`field`)sf(e,Math.floor($d(await Sf(e,`assignment target field index`,()=>G(e,r.index)))),a);else if(r.type===`variable`)ff(e,r.name,a);else{let t=ef(await Sf(e,`assignment target array key`,()=>G(e,r.key)));hf(e,r.array,t,a)}return a}async function Mf(e,t,n,r){xf(e,`inc/dec evaluation`);let i;if(t.type===`field`){let r=Math.floor($d(await Sf(e,`inc/dec field index`,()=>G(e,t.index))));i=$d(of(e,r)),sf(e,r,i+n)}else if(t.type===`variable`)i=$d(df(e,t.name)),ff(e,t.name,i+n);else{let r=ef(await Sf(e,`inc/dec array key`,()=>G(e,t.key)));i=$d(mf(e,t.array,r)),hf(e,t.array,r,i+n)}return r?i+n:i}async function Nf(e,t){return Mf(e,t,1,!0)}async function Pf(e,t){return Mf(e,t,-1,!0)}async function Ff(e,t){return Mf(e,t,1,!1)}async function If(e,t){return Mf(e,t,-1,!1)}async function Lf(e,t,n){xf(e,`in-expression evaluation`);let r;if(t.type===`tuple`){e.coverage?.hit(`awk:expr:tuple`);let n=[];for(let r of t.elements)n.push(ef(await Sf(e,`tuple key element evaluation`,()=>G(e,r))));r=n.join(e.SUBSEP)}else r=ef(await Sf(e,`in-expression key evaluation`,()=>G(e,t)));return+!!gf(e,n,r)}async function Rf(e,t,n,r){if(xf(e,`getline evaluation`),r)return zf(e,t,r);if(n)return Bf(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let i=e.lineIndex+1;if(i>=e.lines.length)return 0;let a=e.lines[i];return t?ff(e,t,a):cf(e,a),e.NR++,e.lineIndex=i,1}async function zf(e,t,n){let r=e.exec;if(!r)return-1;xf(e,`getline command source`);let i=ef(await Sf(e,`getline command expression`,()=>G(e,n))),a=e.getlineCommandStreams.get(i);if(!a)try{let t=or((await Sf(e,`getline command exec`,()=>r(i))).stdout).split(`
407
407
  `);t.length>0&&t[t.length-1]===``&&t.pop(),a={lines:t,index:-1},e.getlineCommandStreams.set(i,a)}catch(e){if(e instanceof D)throw e;return-1}let o=a.index+1;if(o>=a.lines.length)return 0;let s=a.lines[o];return a.index=o,t?ff(e,t,s):cf(e,s),1}async function Bf(e,t,n){let r=e.fs;if(!r||!e.cwd)return-1;xf(e,`getline file source`);let i=ef(await Sf(e,`getline filename evaluation`,()=>G(e,n)));if(i===`/dev/null`)return 0;let a=r.resolvePath(e.cwd,i),o=e.getlineFileStreams.get(a);if(!o)try{let t=(await Sf(e,`getline file read`,()=>r.readFile(a))).split(`
408
408
  `);t.length>0&&t[t.length-1]===``&&t.pop(),o={lines:t,index:-1},e.getlineFileStreams.set(a,o)}catch(e){if(e instanceof D)throw e;return-1}let s=o.index+1;if(s>=o.lines.length)return 0;let c=o.lines[s];return o.index=s,t?ff(e,t,c):cf(e,c),1}async function Vf(e,t){if(xf(e,`tuple evaluation`),t.length===0)return``;for(let n=0;n<t.length-1;n++)await Sf(e,`tuple intermediate element`,()=>G(e,t[n]));return Sf(e,`tuple final element`,()=>G(e,t[t.length-1]))}var Hf,Uf=T(()=>{k(),j(),mc(),Su(),qn(),pd(),Zd(),uf(),rf(),yf(),Hf=null});function Wf(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new A(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output)}function Gf(e,t){bu(e.requireDefenseContext,`awk`,t)}function Kf(e,t,n){return xu(e.requireDefenseContext,`awk`,t,n)}async function qf(e,t){Gf(e,`block execution`);for(let n of t)if(await Kf(e,`statement execution`,()=>Yf(e,n)),Jf(e))break}function Jf(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function Yf(e,t){switch(Gf(e,`single statement execution`),e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case`block`:await Kf(e,`nested block statement`,()=>qf(e,t.statements));break;case`expr_stmt`:await Kf(e,`expression statement`,()=>G(e,t.expression));break;case`print`:await Kf(e,`print statement`,()=>Xf(e,t.args,t.output));break;case`printf`:await Kf(e,`printf statement`,()=>Zf(e,t.format,t.args,t.output));break;case`if`:await Kf(e,`if statement`,()=>$f(e,t));break;case`while`:await Kf(e,`while statement`,()=>ep(e,t));break;case`do_while`:await Kf(e,`do-while statement`,()=>tp(e,t));break;case`for`:await Kf(e,`for statement`,()=>np(e,t));break;case`for_in`:await Kf(e,`for-in statement`,()=>rp(e,t));break;case`break`:e.loopBreak=!0;break;case`continue`:e.loopContinue=!0;break;case`next`:e.shouldNext=!0;break;case`nextfile`:e.shouldNextFile=!0;break;case`exit`:e.shouldExit=!0;{let n=t.code;e.exitCode=n?Math.floor($d(await Kf(e,`exit code expression`,()=>G(e,n)))):0}break;case`return`:e.hasReturn=!0;{let n=t.value;e.returnValue=n?await Kf(e,`return expression`,()=>G(e,n)):``}break;case`delete`:await Kf(e,`delete statement`,()=>ip(e,t.target))}}async function Xf(e,t,n){Gf(e,`print execution`);let r=[];for(let n of t){let t=await Kf(e,`print argument evaluation`,()=>G(e,n));typeof t==`number`?Number.isInteger(t)&&Math.abs(t)<2**53-1?r.push(String(t)):r.push(qd(e.OFMT,[t],e.maxOutputSize||void 0)):r.push(ef(t))}let i=r.join(e.OFS)+e.ORS;n?await Kf(e,`print redirection write`,()=>Qf(e,n.redirect,n.file,i)):(e.output+=i,Wf(e))}async function Zf(e,t,n,r){Gf(e,`printf execution`);let i=ef(await Kf(e,`printf format evaluation`,()=>G(e,t))),a=[];for(let t of n)a.push(await Kf(e,`printf argument evaluation`,()=>G(e,t)));let o=qd(i,a,e.maxOutputSize>0?Math.max(0,e.maxOutputSize-O(e.output)):void 0);r?await Kf(e,`printf redirection write`,()=>Qf(e,r.redirect,r.file,o)):(e.output+=o,Wf(e))}async function Qf(e,t,n,r){Gf(e,`file write execution`);let i=e.fs;if(!i||!e.cwd){e.output+=r,Wf(e);return}let a=ef(await Kf(e,`redirection filename evaluation`,()=>G(e,n))),o=i.resolvePath(e.cwd,a);t===`>`?e.openedFiles.has(o)?await Kf(e,`redirection append write`,()=>i.appendFile(o,r)):(await Kf(e,`redirection overwrite write`,()=>i.writeFile(o,r)),e.openedFiles.add(o)):(e.openedFiles.has(o)||e.openedFiles.add(o),await Kf(e,`redirection append mode write`,()=>i.appendFile(o,r)))}async function $f(e,t){if(Gf(e,`if execution`),Qd(await Kf(e,`if condition evaluation`,()=>G(e,t.condition))))await Kf(e,`if consequent execution`,()=>Yf(e,t.consequent));else if(t.alternate){let n=t.alternate;await Kf(e,`if alternate execution`,()=>Yf(e,n))}}async function ep(e,t){Gf(e,`while execution`);let n=0;for(;Qd(await Kf(e,`while condition evaluation`,()=>G(e,t.condition)));){if(n++,n>e.maxIterations)throw new A(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await Kf(e,`while body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function tp(e,t){Gf(e,`do-while execution`);let n=0;do{if(n++,n>e.maxIterations)throw new A(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await Kf(e,`do-while body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(Qd(await Kf(e,`do-while condition evaluation`,()=>G(e,t.condition))))}async function np(e,t){Gf(e,`for execution`);let n=t.init,r=t.condition,i=t.update;n&&await Kf(e,`for init evaluation`,()=>G(e,n));let a=0;for(;!r||Qd(await Kf(e,`for condition evaluation`,()=>G(e,r)));){if(a++,a>e.maxIterations)throw new A(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await Kf(e,`for body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;i&&await Kf(e,`for update evaluation`,()=>G(e,i))}}async function rp(e,t){Gf(e,`for-in execution`);let n=e.arrays[t.array];if(n)for(let r of Object.keys(n)){if(e.vars[t.variable]=r,e.loopContinue=!1,await Kf(e,`for-in body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function ip(e,t){if(Gf(e,`delete execution`),t.type===`array_access`){let n=ef(await Kf(e,`delete key evaluation`,()=>G(e,t.key)));_f(e,t.array,n)}else t.type===`variable`&&vf(e,t.name)}var ap=T(()=>{j(),Su(),Lr(),Zd(),Uf(),rf(),yf(),bf(qf)}),op,sp=T(()=>{j(),Su(),Uf(),uf(),ap(),rf(),op=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}assertDefenseContext(e){bu(this.ctx.requireDefenseContext,`awk`,e)}withDefenseContext(e,t){return xu(this.ctx.requireDefenseContext,`awk`,e,t)}execute(e){this.assertDefenseContext(`program initialization`),this.program=e,this.ctx.output=``;for(let t of e.functions)this.ctx.functions.set(t.name,t);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`,()=>qf(this.ctx,e.action.statements)),this.ctx.shouldExit))break}}async executeLine(e){if(this.assertDefenseContext(`line execution entry`),!(!this.program||this.ctx.shouldExit)){if(this.ctx.recordsProcessed++,this.ctx.recordsProcessed>this.ctx.maxIterations)throw new A(`record limit exceeded (${this.ctx.maxIterations})`,`iterations`);cf(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let e=0;e<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);e++){let t=this.program.rules[e];t.pattern?.type===`begin`||t.pattern?.type===`end`||await this.withDefenseContext(`rule match`,()=>this.matchesRule(t,e))&&await this.withDefenseContext(`rule block execution`,()=>qf(this.ctx,t.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`,()=>qf(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,t){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 nf(n.pattern,this.ctx.line);case`expr_pattern`:return Qd(await this.withDefenseContext(`expression pattern evaluation`,()=>G(this.ctx,n.expression)));case`range`:{let e=await this.withDefenseContext(`range start pattern`,()=>this.matchPattern(n.start)),r=await this.withDefenseContext(`range end pattern`,()=>this.matchPattern(n.end));return this.rangeStates[t]?(r&&(this.rangeStates[t]=!1),!0):e?(this.rangeStates[t]=!0,r&&(this.rangeStates[t]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(this.assertDefenseContext(`pattern matching`),e.type){case`regex_pattern`:return nf(e.pattern,this.ctx.line);case`expr_pattern`:return Qd(await this.withDefenseContext(`nested expression pattern`,()=>G(this.ctx,e.expression)));default:return!1}}}}),cp=T(()=>{dd(),sp()});function lp(e){return e.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 K,up,dp,fp,pp=T(()=>{j(),(function(e){e.NUMBER=`NUMBER`,e.STRING=`STRING`,e.REGEX=`REGEX`,e.IDENT=`IDENT`,e.BEGIN=`BEGIN`,e.END=`END`,e.IF=`IF`,e.ELSE=`ELSE`,e.WHILE=`WHILE`,e.DO=`DO`,e.FOR=`FOR`,e.IN=`IN`,e.BREAK=`BREAK`,e.CONTINUE=`CONTINUE`,e.NEXT=`NEXT`,e.NEXTFILE=`NEXTFILE`,e.EXIT=`EXIT`,e.RETURN=`RETURN`,e.DELETE=`DELETE`,e.FUNCTION=`FUNCTION`,e.PRINT=`PRINT`,e.PRINTF=`PRINTF`,e.GETLINE=`GETLINE`,e.PLUS=`PLUS`,e.MINUS=`MINUS`,e.STAR=`STAR`,e.SLASH=`SLASH`,e.PERCENT=`PERCENT`,e.CARET=`CARET`,e.EQ=`EQ`,e.NE=`NE`,e.LT=`LT`,e.GT=`GT`,e.LE=`LE`,e.GE=`GE`,e.MATCH=`MATCH`,e.NOT_MATCH=`NOT_MATCH`,e.AND=`AND`,e.OR=`OR`,e.NOT=`NOT`,e.ASSIGN=`ASSIGN`,e.PLUS_ASSIGN=`PLUS_ASSIGN`,e.MINUS_ASSIGN=`MINUS_ASSIGN`,e.STAR_ASSIGN=`STAR_ASSIGN`,e.SLASH_ASSIGN=`SLASH_ASSIGN`,e.PERCENT_ASSIGN=`PERCENT_ASSIGN`,e.CARET_ASSIGN=`CARET_ASSIGN`,e.INCREMENT=`INCREMENT`,e.DECREMENT=`DECREMENT`,e.QUESTION=`QUESTION`,e.COLON=`COLON`,e.COMMA=`COMMA`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.LBRACKET=`LBRACKET`,e.RBRACKET=`RBRACKET`,e.DOLLAR=`DOLLAR`,e.APPEND=`APPEND`,e.PIPE=`PIPE`,e.EOF=`EOF`})(K||={}),up=new Map([[`BEGIN`,K.BEGIN],[`END`,K.END],[`if`,K.IF],[`else`,K.ELSE],[`while`,K.WHILE],[`do`,K.DO],[`for`,K.FOR],[`in`,K.IN],[`break`,K.BREAK],[`continue`,K.CONTINUE],[`next`,K.NEXT],[`nextfile`,K.NEXTFILE],[`exit`,K.EXIT],[`return`,K.RETURN],[`delete`,K.DELETE],[`function`,K.FUNCTION],[`print`,K.PRINT],[`printf`,K.PRINTF],[`getline`,K.GETLINE]]),dp=new Set([K.COMMA,K.LBRACE,K.AND,K.OR,K.QUESTION,K.COLON,K.DO,K.ELSE,K.IF,K.WHILE]),fp=class{maxTokens;input;pos=0;line=1;column=1;lastTokenType=null;constructor(e,t=1e5){this.maxTokens=t,this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let t=this.nextToken();if(t){if(e.length>=this.maxTokens)throw new A(`awk: token limit exceeded (${this.maxTokens})`,`array_elements`);e.push(t),this.lastTokenType=t.type}}if(e.length>=this.maxTokens)throw new A(`awk: token limit exceeded (${this.maxTokens})`,`array_elements`);return e.push(this.makeToken(K.EOF,``)),e}makeToken(e,t){return{type:e,value:t,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||``}advance(){let e=this.input[this.pos++]||``;return e===`
409
- `?(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)===`
410
- `)this.advance(),this.advance();else break;else if(e===`#`)for(;this.pos<this.input.length&&this.peek()!==`
409
+ `?(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)===`
410
+ `)this.advance(),this.advance();else break}else if(e===`#`)for(;this.pos<this.input.length&&this.peek()!==`
411
411
  `;)this.advance();else break}}nextToken(){for(this.skipWhitespace();this.peek()===`
412
412
  `&&this.lastTokenType!==null&&dp.has(this.lastTokenType);)this.advance(),this.skipWhitespace();if(this.pos>=this.input.length)return null;let e=this.line,t=this.column,n=this.peek();return n===`
413
413
  `?(this.advance(),{type:K.NEWLINE,value:`
@@ -505,7 +505,7 @@ Try 'comm --help' for more information.
505
505
  `};n.width=e,i++}else if(t===`-s`)n.breakAtSpaces=!0,i++;else if(t===`-b`)n.countBytes=!0,i++;else if(t===`-bs`||t===`-sb`)n.breakAtSpaces=!0,n.countBytes=!0,i++;else if(t.match(/^-[sb]+w\d+$/)){t.includes(`s`)&&(n.breakAtSpaces=!0),t.includes(`b`)&&(n.countBytes=!0);let e=t.replace(/^-[sb]+w/,``),r=parseInt(e,10);if(Number.isNaN(r)||r<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${e}'
506
506
  `};n.width=r,i++}else if(t.match(/^-[sb]+w$/)&&i+1<e.length){t.includes(`s`)&&(n.breakAtSpaces=!0),t.includes(`b`)&&(n.countBytes=!0);let r=parseInt(e[i+1],10);if(Number.isNaN(r)||r<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${e[i+1]}'
507
507
  `};n.width=r,i+=2}else if(t===`--`){r.push(...e.slice(i+1));break}else if(t.startsWith(`-`)&&t!==`-`){let e=t.slice(1),r=!1;for(let t of e)if(t===`s`)n.breakAtSpaces=!0;else if(t===`b`)n.countBytes=!0;else{r=!0;break}if(r)return P(`fold`,t);i++}else r.push(t),i++}let a=``;if(r.length===0)a=Qm(or(t.stdin)??``,n);else for(let e of r){let r=t.fs.resolvePath(t.cwd,e),i=await t.fs.readFile(r);if(i===null)return{exitCode:1,stdout:a,stderr:`fold: ${e}: No such file or directory
508
- `};a+=Qm(i,n)}return{exitCode:0,stdout:a,stderr:``}}},th={name:`fold`,flags:[{flag:`-w`,type:`value`,valueHint:`number`},{flag:`-s`,type:`boolean`},{flag:`-b`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),rh={};E(rh,{expand:()=>lh,flagsForFuzzing:()=>uh});function ih(e,t,n){let r=e.split(`,`).map(e=>e.trim());if(r.length>n)return null;let i=[];for(let e of r){let n=/^\d+$/.test(e)?Number(e):NaN;if(!Number.isSafeInteger(n)||n<1||n>t)return null;i.push(n)}for(let e=1;e<i.length;e++)if(i[e]<=i[e-1])return null;return i}function ah(e,t){if(t.length===1){let n=t[0];return n-e%n}for(let n of t)if(n>e)return n-e;if(t.length>=2){let n=t[t.length-1]-t[t.length-2],r=t[t.length-1];return r+(Math.floor((e-r)/n)+1)*n-e}return 1}function oh(e,t,n){let{tabStops:r,leadingOnly:i}=t,a=``,o=0,s=!0,c=0;for(let t of e)if(t===` `)if(i&&!s){if(c+1>n)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c++,o++}else{let e=ah(o,r);if(e>n-c)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=` `.repeat(e),c+=e,o+=e}else{t!==` `&&t!==` `&&(s=!1);let e=O(t);if(e>n-c)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c+=e,o++}return a}function sh(e,t,n){if(e===``)return``;let r=e.split(`
508
+ `};a+=Qm(i,n)}return{exitCode:0,stdout:a,stderr:``}}},th={name:`fold`,flags:[{flag:`-w`,type:`value`,valueHint:`number`},{flag:`-s`,type:`boolean`},{flag:`-b`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),rh={};E(rh,{expand:()=>lh,flagsForFuzzing:()=>uh});function ih(e,t,n){let r=e.split(`,`).map(e=>e.trim());if(r.length>n)return null;let i=[];for(let e of r){let n=/^\d+$/.test(e)?Number(e):NaN;if(!Number.isSafeInteger(n)||n<1||n>t)return null;i.push(n)}for(let e=1;e<i.length;e++)if(i[e]<=i[e-1])return null;return i}function ah(e,t){if(t.length===1){let n=t[0];return n-e%n}for(let n of t)if(n>e)return n-e;if(t.length>=2){let n=t[t.length-1]-t[t.length-2],r=t[t.length-1];return r+(Math.floor((e-r)/n)+1)*n-e}return 1}function oh(e,t,n){let{tabStops:r,leadingOnly:i}=t,a=``,o=0,s=!0,c=0;for(let t of e)if(t===` `){if(i&&!s){if(c+1>n)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c++,o++}else{let e=ah(o,r);if(e>n-c)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=` `.repeat(e),c+=e,o+=e}}else{t!==` `&&t!==` `&&(s=!1);let e=O(t);if(e>n-c)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c+=e,o++}return a}function sh(e,t,n){if(e===``)return``;let r=e.split(`
509
509
  `),i=e.endsWith(`
510
510
  `)&&r[r.length-1]===``;i&&r.pop();let a=[],o=0;for(let e of r){let r=+(a.length>0),i=oh(e,t,n-o-r);o+=r+O(i),a.push(i)}if(i&&o+1>n)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);return a.join(`
511
511
  `)+(i?`
@@ -577,10 +577,10 @@ Try 'comm --help' for more information.
577
577
  `,s=1}return{stdout:a,stderr:o,exitCode:s,stdoutEncoding:`binary`}}},gg={name:`tee`,flags:[{flag:`-a`,type:`boolean`}],stdinType:`text`,needsArgs:!0}}),vg,yg=T(()=>{k(),j(),vg=class{scope;site;stdoutChunks=[];stderrChunks=[];stdoutBytes=0;stderrBytes=0;attachedErrors=new WeakSet;constructor(e,t){this.scope=e,this.site=t}append(e,t,n=0,r=`text`){let i;try{i=this.scope.appendOutput(e,t,this.site,n,r)}catch(e){throw this.prependTo(e),e}t&&(e===`stdout`?this.stdoutChunks:this.stderrChunks).push(t),e===`stdout`?this.stdoutBytes+=i:this.stderrBytes+=i}prependTo(e){e instanceof vr&&(this.attachedErrors.has(e)||(this.attachedErrors.add(e),e.prependOutput(this.stdout,this.stderr)))}appendResult(e,t=e.stdout){let n=e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`,r=n===`bytes`?t.length:O(t);this.append(`stdout`,t,Math.min(e.internalOutputAccounting?.stdout??0,r),n),this.append(`stderr`,e.stderr,e.internalOutputAccounting?.stderr??0)}build(e,t){return{stdout:this.stdoutChunks.join(``),stderr:this.stderrChunks.join(``),exitCode:e,...t,internalOutputAccounting:{stdout:this.stdoutBytes,stderr:this.stderrBytes}}}get stdout(){return this.stdoutChunks.join(``)}get stderr(){return this.stderrChunks.join(``)}}});function bg(e,t){switch(e.type){case`name`:{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let n=r[1],i=t.name;if(e.ignoreCase){if(!i.toLowerCase().endsWith(n.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(n))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:hc(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case`path`:{let n=e.pattern,r=t.relativePath,i=n.split(`/`);for(let t=0;t<i.length-1;t++){let n=i[t];if(n&&n!==`.`&&n!==`..`&&!n.includes(`*`)&&!n.includes(`?`)&&!n.includes(`[`)){let t=`/${n}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(t))return{matches:!1,pruned:!1,printed:!1}}}let a=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let t=a[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(t))return{matches:!1,pruned:!1,printed:!1}}return{matches:hc(r,n,e.ignoreCase),pruned:!1,printed:!1}}case`regex`:try{let n=e.ignoreCase?`i`:``;return{matches:U(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case`type`:return e.fileType===`f`?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType===`d`?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case`empty`:return{matches:t.isEmpty,pruned:!1,printed:!1};case`mtime`:{let n=(Date.now()-t.mtime)/864e5,r;return r=e.comparison===`more`?n>e.days:e.comparison===`less`?n<e.days:Math.floor(n)===e.days,{matches:r,pruned:!1,printed:!1}}case`newer`:{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case`size`:{let n=e.value;switch(e.unit){case`c`:n=e.value;break;case`k`:n=e.value*1024;break;case`M`:n=e.value*1024*1024;break;case`G`:n=e.value*1024*1024*1024;break;case`b`:n=e.value*512}let r;return r=e.comparison===`more`?t.size>n:e.comparison===`less`?t.size<n:e.unit===`b`?Math.ceil(t.size/512)===e.value:t.size===n,{matches:r,pruned:!1,printed:!1}}case`perm`:{let n=t.mode&511,r=e.mode&511,i;return i=e.matchType===`exact`?n===r:e.matchType===`all`?(n&r)===r:(n&r)!==0,{matches:i,pruned:!1,printed:!1}}case`prune`:return{matches:!0,pruned:!0,printed:!1};case`action`:return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case`not`:{let n=bg(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1,actions:n.actions}}case`and`:{let n=bg(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1,actions:n.actions};let r=bg(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed,actions:[...n.actions??[],...r.actions??[]]}}case`or`:{let n=bg(e.left,t);if(n.matches)return n;let r=bg(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed,actions:[...n.actions??[],...r.actions??[]]}}}}function xg(e){if(!e)return!1;switch(e.type){case`name`:case`path`:case`regex`:case`type`:case`prune`:return!1;case`action`:return!1;case`empty`:case`mtime`:case`newer`:case`size`:case`perm`:return!0;case`not`:return xg(e.expr);case`and`:case`or`:return xg(e.left)||xg(e.right)}}function Sg(e){if(!e)return!1;switch(e.type){case`empty`:return!0;case`not`:return Sg(e.expr);case`and`:case`or`:return Sg(e.left)||Sg(e.right);default:return!1}}function Cg(e){let t=[],n=e=>{e&&(e.type===`newer`?t.push(e.refPath):e.type===`not`?n(e.expr):(e.type===`and`||e.type===`or`)&&(n(e.left),n(e.right)))};return n(e),t}function wg(e){if(!e)return!0;switch(e.type){case`name`:case`path`:case`regex`:case`type`:case`prune`:return!0;case`action`:return!1;case`empty`:case`mtime`:case`newer`:case`size`:case`perm`:return!1;case`not`:return wg(e.expr);case`and`:case`or`:return wg(e.left)&&wg(e.right)}}function Tg(e,t,n,r,i){switch(e.type){case`name`:{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let n=r[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(n.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(n))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:hc(t,n,e.ignoreCase),pruned:!1,printed:!1}}case`path`:{let t=e.pattern,r=t.split(`/`);for(let t=0;t<r.length-1;t++){let i=r[t];if(i&&i!==`.`&&i!==`..`&&!i.includes(`*`)&&!i.includes(`?`)&&!i.includes(`[`)){let t=`/${i}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(t))return{matches:!1,pruned:!1,printed:!1}}}let i=t.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let t=i[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(t))return{matches:!1,pruned:!1,printed:!1}}return{matches:hc(n,t,e.ignoreCase),pruned:!1,printed:!1}}case`regex`:try{let t=e.ignoreCase?`i`:``;return{matches:U(e.pattern,t).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case`type`:return e.fileType===`f`?{matches:r,pruned:!1,printed:!1}:e.fileType===`d`?{matches:i,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case`prune`:return{matches:!0,pruned:!0,printed:!1};case`action`:return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case`not`:{let a=Tg(e.expr,t,n,r,i);return{matches:!a.matches,pruned:a.pruned,printed:!1,actions:a.actions}}case`and`:{let a=Tg(e.left,t,n,r,i);if(!a.matches)return{matches:!1,pruned:a.pruned,printed:!1,actions:a.actions};let o=Tg(e.right,t,n,r,i);return{matches:o.matches,pruned:a.pruned||o.pruned,printed:a.printed||o.printed,actions:[...a.actions??[],...o.actions??[]]}}case`or`:{let a=Tg(e.left,t,n,r,i);if(a.matches)return a;let o=Tg(e.right,t,n,r,i);return{matches:o.matches,pruned:a.pruned||o.pruned,printed:o.printed,actions:[...a.actions??[],...o.actions??[]]}}default:return{matches:!1,pruned:!1,printed:!1}}}function Eg(e){if(!e)return!1;switch(e.type){case`prune`:return!0;case`not`:return Eg(e.expr);case`and`:case`or`:return Eg(e.left)||Eg(e.right);default:return!1}}function Dg(e){switch(e.type){case`name`:case`path`:case`regex`:case`type`:case`prune`:return!0;case`action`:return!1;case`empty`:case`mtime`:case`newer`:case`size`:case`perm`:return!1;case`not`:return Dg(e.expr);case`and`:case`or`:return Dg(e.left)&&Dg(e.right)}}function Og(e,t){return!e||!t.isDirectory?{shouldPrune:!1}:Dg(e)?{shouldPrune:bg(e,{name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map}).pruned}:kg(e,t)}function kg(e,t){switch(e.type){case`or`:if(Dg(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(bg(e.left,n).pruned)return{shouldPrune:!0}}return kg(e.right,t);case`and`:if(Dg(e.left)&&Dg(e.right))return{shouldPrune:bg(e,{name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map}).pruned};if(Dg(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return bg(e.left,n).matches?kg(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1};case`not`:return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Ag=T(()=>{mc(),yc()});function jg(e,t){let n=[],r=t,i=e=>({expr:null,pathIndex:r,error:`find: missing argument to \`${e}'
578
578
  `}),a=(e,t)=>({expr:null,pathIndex:r,error:`find: invalid argument \`${t}' to \`${e}'
579
579
  `});for(;r<e.length;){let t=e[r];if(t===`(`||t===`\\(`){n.push({type:`lparen`}),r++;continue}if(t===`)`||t===`\\)`){n.push({type:`rparen`}),r++;continue}if(t===`-name`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`name`,pattern:e[++r]}})}else if(t===`-iname`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`name`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-path`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`path`,pattern:e[++r]}})}else if(t===`-ipath`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`path`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-regex`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`regex`,pattern:e[++r]}})}else if(t===`-iregex`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`regex`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-type`){if(r+1>=e.length)return i(t);let a=e[++r];if(a===`f`||a===`d`)n.push({type:`expr`,expr:{type:`type`,fileType:a}});else return{expr:null,pathIndex:r,error:`find: Unknown argument to -type: ${a}
580
- `}}else if(t===`-empty`)n.push({type:`expr`,expr:{type:`empty`}});else if(t===`-mtime`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1)),!/^\d+$/.test(c))return a(t,o);let l=Number(c);if(!Number.isSafeInteger(l))return a(t,o);n.push({type:`expr`,expr:{type:`mtime`,days:l,comparison:s}})}else if(t===`-newer`){if(r+1>=e.length)return i(t);let a=e[++r];n.push({type:`expr`,expr:{type:`newer`,refPath:a}})}else if(t===`-size`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1));let l=c.match(/^(\d+)([ckMGb])?$/);if(!l)return a(t,o);let u=Number(l[1]);if(!Number.isSafeInteger(u))return a(t,o);let d=l[2]||`b`,f=d===`G`?1024**3:d===`M`?1024**2:d===`k`?1024:d===`b`?512:1;if(!Number.isSafeInteger(u*f))return a(t,o);n.push({type:`expr`,expr:{type:`size`,value:u,unit:d,comparison:s}})}else if(t===`-perm`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`-`)?(s=`all`,c=o.slice(1)):o.startsWith(`/`)&&(s=`any`,c=o.slice(1)),!/^[0-7]{1,4}$/.test(c))return a(t,o);let l=Number.parseInt(c,8);n.push({type:`expr`,expr:{type:`perm`,mode:l,matchType:s}})}else if(t===`-prune`)n.push({type:`expr`,expr:{type:`prune`}});else if(t===`-not`||t===`!`)n.push({type:`not`});else if(t===`-o`||t===`-or`)n.push({type:`op`,op:`or`});else if(t===`-a`||t===`-and`)n.push({type:`op`,op:`and`});else if(t===`-maxdepth`||t===`-mindepth`){if(r+1>=e.length)return i(t);r++}else if(t!==`-depth`)if(t===`-exec`){let t=[];for(r++;r<e.length&&e[r]!==`;`&&e[r]!==`+`;)t.push(e[r]),r++;if(r>=e.length)return{expr:null,pathIndex:r,error:`find: missing argument to \`-exec'
580
+ `}}else if(t===`-empty`)n.push({type:`expr`,expr:{type:`empty`}});else if(t===`-mtime`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1)),!/^\d+$/.test(c))return a(t,o);let l=Number(c);if(!Number.isSafeInteger(l))return a(t,o);n.push({type:`expr`,expr:{type:`mtime`,days:l,comparison:s}})}else if(t===`-newer`){if(r+1>=e.length)return i(t);let a=e[++r];n.push({type:`expr`,expr:{type:`newer`,refPath:a}})}else if(t===`-size`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1));let l=c.match(/^(\d+)([ckMGb])?$/);if(!l)return a(t,o);let u=Number(l[1]);if(!Number.isSafeInteger(u))return a(t,o);let d=l[2]||`b`,f=d===`G`?1024**3:d===`M`?1024**2:d===`k`?1024:d===`b`?512:1;if(!Number.isSafeInteger(u*f))return a(t,o);n.push({type:`expr`,expr:{type:`size`,value:u,unit:d,comparison:s}})}else if(t===`-perm`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`-`)?(s=`all`,c=o.slice(1)):o.startsWith(`/`)&&(s=`any`,c=o.slice(1)),!/^[0-7]{1,4}$/.test(c))return a(t,o);let l=Number.parseInt(c,8);n.push({type:`expr`,expr:{type:`perm`,mode:l,matchType:s}})}else if(t===`-prune`)n.push({type:`expr`,expr:{type:`prune`}});else if(t===`-not`||t===`!`)n.push({type:`not`});else if(t===`-o`||t===`-or`)n.push({type:`op`,op:`or`});else if(t===`-a`||t===`-and`)n.push({type:`op`,op:`and`});else if(t===`-maxdepth`||t===`-mindepth`){if(r+1>=e.length)return i(t);r++}else if(t!==`-depth`){if(t===`-exec`){let t=[];for(r++;r<e.length&&e[r]!==`;`&&e[r]!==`+`;)t.push(e[r]),r++;if(r>=e.length)return{expr:null,pathIndex:r,error:`find: missing argument to \`-exec'
581
581
  `};if(t.length===0)return i(`-exec`);let o=e[r]===`+`;if(o&&(t.at(-1)!==`{}`||t.filter(e=>e===`{}`).length!==1))return a(`-exec`,`+`);n.push({type:`expr`,expr:{type:`action`,action:{type:`exec`,command:t,batchMode:o}}})}else if(t===`-print`)n.push({type:`expr`,expr:{type:`action`,action:{type:`print`}}});else if(t===`-print0`)n.push({type:`expr`,expr:{type:`action`,action:{type:`print0`}}});else if(t===`-printf`){if(r+1>=e.length)return i(t);let a=e[++r];n.push({type:`expr`,expr:{type:`action`,action:{type:`printf`,format:a}}})}else if(t===`-delete`)n.push({type:`expr`,expr:{type:`action`,action:{type:`delete`}}});else return t.startsWith(`-`)?{expr:null,pathIndex:r,error:`find: unknown predicate '${t}'
582
582
  `}:{expr:null,pathIndex:r,error:`find: paths must precede expression: \`${t}'
583
- `};r++}if(n.length===0)return{expr:null,pathIndex:r};let o=Mg(n);return o.error?{expr:null,pathIndex:r,error:o.error}:{expr:o.expr,pathIndex:r}}function Mg(e){let t=0,n;function r(){let r=i();if(!r)return null;for(;t<e.length;){let a=e[t];if(a.type===`op`&&a.op===`or`){t++;let e=i();if(!e)return n=`find: expected an expression after \`-o'
583
+ `}}r++}if(n.length===0)return{expr:null,pathIndex:r};let o=Mg(n);return o.error?{expr:null,pathIndex:r,error:o.error}:{expr:o.expr,pathIndex:r}}function Mg(e){let t=0,n;function r(){let r=i();if(!r)return null;for(;t<e.length;){let a=e[t];if(a.type===`op`&&a.op===`or`){t++;let e=i();if(!e)return n=`find: expected an expression after \`-o'
584
584
  `,null;r={type:`or`,left:r,right:e}}else break}return r}function i(){let r=a();if(!r)return null;for(;t<e.length;){let i=e[t];if(i.type===`op`&&i.op===`and`){t++;let e=a();if(!e)return n=`find: expected an expression after \`-a'
585
585
  `,null;r={type:`and`,left:r,right:e}}else if(i.type===`expr`||i.type===`not`||i.type===`lparen`){let e=a();if(!e)return r;r={type:`and`,left:r,right:e}}else break}return r}function a(){if(t<e.length&&e[t].type===`not`){t++;let e=a();return e?{type:`not`,expr:e}:(n=`find: expected an expression after \`!'
586
586
  `,null)}return o()}function o(){if(t>=e.length)return null;let i=e[t];if(i.type===`lparen`){t++;let i=r();return!i||t>=e.length||e[t].type!==`rparen`?(n=`find: missing closing \`)'
@@ -639,11 +639,11 @@ ${s} director${s===1?`y`:`ies`}`,r.directoriesOnly||(a+=`, ${c} file${c===1?``:`
639
639
  `,exitCode:1};let i=ad(r.exportedEnv||{},{0:t,"#":String(n.length),"@":n.join(` `),"*":n.join(` `)});n.forEach((e,t)=>{i[String(t+1)]=e});let a=e;if(a.startsWith(`#!`)){let e=a.indexOf(`
640
640
  `);e!==-1&&(a=a.slice(e+1))}let o=r.execWithInheritedStdin;return o?await o(a,{env:i,cwd:r.cwd,signal:r.signal}):await r.exec(a,{env:i,cwd:r.cwd,stdin:r.stdin,stdinKind:`bytes`,signal:r.signal})}var sv,cv,lv,uv,dv,fv=T(()=>{k(),od(),F(),sv={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).`]},cv={name:`bash`,async execute(e,t){if(N(e))return M(sv);if(e[0]===`-c`&&e.length>=2){let n=e[1];return ov(n,e[2]||`bash`,e.slice(3),t)}if(e.length===0){let e=or(t.stdin);return e.trim()?ov(e,`bash`,[],t):{stdout:``,stderr:``,exitCode:0}}let n=e[0],r=e.slice(1);try{let e=t.fs.resolvePath(t.cwd,n);return ov(await t.fs.readFile(e),n,r,t)}catch{return{stdout:``,stderr:`bash: ${n}: No such file or directory
641
641
  `,exitCode:127}}}},lv={name:`sh`,async execute(e,t){if(N(e))return M({...sv,name:`sh`,summary:`execute shell commands or scripts (POSIX shell)`});if(e[0]===`-c`&&e.length>=2){let n=e[1];return ov(n,e[2]||`sh`,e.slice(3),t)}if(e.length===0){let e=or(t.stdin);return e.trim()?ov(e,`sh`,[],t):{stdout:``,stderr:``,exitCode:0}}let n=e[0],r=e.slice(1);try{let e=t.fs.resolvePath(t.cwd,n);return ov(await t.fs.readFile(e),n,r,t)}catch{return{stdout:``,stderr:`sh: ${n}: No such file or directory
642
- `,exitCode:127}}}},uv={name:`bash`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`},dv={name:`sh`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`}});function pv(e,t,n=1){let r=e.limits.maxArrayElements;if(n<0||t>r-n)throw new A(`query result element limit exceeded (${r})`,`array_elements`)}function mv(e,t,n,r,i,a,o,s,c,l){switch(t){case`sort`:return Array.isArray(e)?[[...e].sort(o)]:[null];case`sort_by`:return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)})];case`bsearch`:if(!Array.isArray(e))throw Error(`${e===null?`null`:typeof e==`object`?`object`:typeof e} (${JSON.stringify(e)}) cannot be searched from`);return n.length===0?[null]:i(e,n[0],r).map(t=>{let n=0,r=e.length;for(;n<r;){let i=n+r>>>1;o(e[i],t)<0?n=i+1:r=i}return n<e.length&&o(e[n],t)===0?n:-n-1});case`unique_by`:{if(!Array.isArray(e)||n.length===0)return[null];let t=new Map;for(let a of e){let e=i(a,n[0],r)[0],o=JSON.stringify(e);t.has(o)||t.set(o,{item:a,key:e})}let a=[...t.values()];return a.sort((e,t)=>o(e.key,t.key)),[a.map(e=>e.item)]}case`group_by`:{if(!Array.isArray(e)||n.length===0)return[null];let t=new Map;for(let a of e){let e=JSON.stringify(i(a,n[0],r)[0]);t.has(e)||t.set(e,[]),t.get(e)?.push(a)}return[[...t.values()]]}case`max`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)>0?e:t)]:[null];case`max_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)>0?e:t})];case`min`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)<0?e:t)]:[null];case`min_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)<0?e:t})];case`add`:{let t=e=>{let t=e.filter(e=>e!==null);return t.length===0?null:t.every(e=>typeof e==`number`)?t.reduce((e,t)=>e+t,0):t.every(e=>typeof e==`string`)?t.join(``):t.every(e=>Array.isArray(e))?t.flat():t.every(e=>e&&typeof e==`object`&&!Array.isArray(e))?ad(...t):null};return n.length>=1?[t(i(e,n[0],r))]:Array.isArray(e)?[t(e)]:[null]}case`any`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(i(e,n[1],r).some(s))return[!0]}catch(e){if(e instanceof l)throw e}return[!1]}return n.length===1?Array.isArray(e)?[e.some(e=>s(i(e,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(s)]:[!1];case`all`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(!i(e,n[1],r).some(s))return[!1]}catch(e){if(e instanceof l)throw e}return[!0]}return n.length===1?Array.isArray(e)?[e.every(e=>s(i(e,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(s)]:[!0];case`select`:return n.length===0||i(e,n[0],r).some(s)?[e]:[];case`map`:{if(n.length===0||!Array.isArray(e))return[null];pv(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);pv(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}case`map_values`:if(n.length===0)return[null];if(Array.isArray(e)){pv(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);pv(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}if(e&&typeof e==`object`){let t=Object.create(null),a=Object.keys(e);pv(r,0,a.length);for(let o of a){if(!fl(o))continue;let a=e[o],s=i(a,n[0],r);s.length>0&&pl(t,o,s[0])}return[t]}return[null];case`has`:{if(n.length===0)return[!1];let t=i(e,n[0],r)[0];return Array.isArray(e)&&typeof t==`number`?[t>=0&&t<e.length]:e&&typeof e==`object`&&typeof t==`string`?[Object.hasOwn(e,t)]:[!1]}case`in`:{if(n.length===0)return[!1];let t=i(e,n[0],r)[0];return Array.isArray(t)&&typeof e==`number`?[e>=0&&e<t.length]:t&&typeof t==`object`&&typeof e==`string`?[Object.hasOwn(t,e)]:[!1]}case`contains`:return n.length===0?[!1]:[c(e,i(e,n[0],r)[0])];case`inside`:return n.length===0?[!1]:[c(i(e,n[0],r)[0],e)];default:return null}}var hv=T(()=>{od(),j(),xl()});function gv(e,t,n,r,i,a,o,s){switch(t){case`first`:if(n.length>0)try{let t=a(e,n[0],r);return t.length>0?[t[0]]:[]}catch(e){if(e instanceof s)throw e;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case`last`:if(n.length>0){let t=i(e,n[0],r);return t.length>0?[t[t.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case`nth`:{if(n.length<1)return[null];let t=i(e,n[0],r);if(n.length>1){for(let e of t)if(e<0)throw Error(`nth doesn't support negative indices`);let i;try{i=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;i=[]}return t.flatMap(e=>{let t=e;return t<i.length?[i[t]]:[]})}return Array.isArray(e)?t.flatMap(t=>{let n=t;if(n<0)throw Error(`nth doesn't support negative indices`);return n<e.length?[e[n]]:[null]}):[null]}case`range`:{if(n.length===0)return[];let t=r.limits.maxArrayElements,a=(e,n)=>{if(e.length>=t)throw new s(`query result element limit exceeded (${t})`,`array_elements`);e.push(n)},o=i(e,n[0],r);if(n.length===1){let e=[];for(let t of o){let n=t;for(let t=0;t<n;t++)a(e,t)}return e}let c=i(e,n[1],r);if(n.length===2){let e=[];for(let t of o)for(let n of c){let r=t,i=n;for(let t=r;t<i;t++)a(e,t)}return e}let l=i(e,n[2],r),u=[];for(let e of o)for(let t of c)for(let n of l){let r=e,i=t,o=n;if(o!==0)if(o>0)for(let e=r;e<i;e+=o)a(u,e);else for(let e=r;e>i;e+=o)a(u,e)}return u}case`limit`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let i=t;if(i<0)throw Error(`limit doesn't support negative count`);if(i===0)return[];let o;try{o=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;o=[]}return o.slice(0,i)});case`isempty`:if(n.length<1)return[!0];try{return[a(e,n[0],r).length===0]}catch(e){if(e instanceof s)throw e;return[!0]}case`isvalid`:if(n.length<1)return[!0];try{return[i(e,n[0],r).length>0]}catch(e){if(e instanceof s)throw e;return[!1]}case`skip`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let a=t;if(a<0)throw Error(`skip doesn't support negative count`);return i(e,n[1],r).slice(a)});case`until`:{if(n.length<2)return[e];let t=e,a=r.limits.maxIterations;for(let e=0;e<a;e++){if(i(t,n[0],r).some(o))return[t];let e=i(t,n[1],r);if(e.length===0)return[t];t=e[0]}throw new s(`jq until: too many iterations (${a}), increase executionLimits.maxJqIterations`,`iterations`)}case`while`:{if(n.length<2)return[e];let t=[],a=e,c=r.limits.maxIterations;for(let e=0;e<c&&i(a,n[0],r).some(o);e++){t.push(a);let e=i(a,n[1],r);if(e.length===0)break;a=e[0]}if(t.length>=c)throw new s(`jq while: too many iterations (${c}), increase executionLimits.maxJqIterations`,`iterations`);return t}case`repeat`:{if(n.length===0)return[e];let t=[],a=e,o=r.limits.maxIterations;for(let e=0;e<o;e++){t.push(a);let e=i(a,n[0],r);if(e.length===0)break;a=e[0]}if(t.length>=o)throw new s(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,`iterations`);return t}default:return null}}var _v=T(()=>{});function vv(e,t){if(!Number.isFinite(e)||Math.abs(e)>864e10)throw Error(`${t} timestamp is outside the supported range`);return new Date(e*1e3)}function yv(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(!t)return null;let[,n,r,i,a,o,s]=t.map(Number),c=Date.UTC(n,r-1,i,a,o,s);if(!Number.isFinite(c))return null;let l=new Date(c);return l.getUTCFullYear()!==n||l.getUTCMonth()!==r-1||l.getUTCDate()!==i||l.getUTCHours()!==a||l.getUTCMinutes()!==o||l.getUTCSeconds()!==s?null:l}function bv(e,t,n,r,i){switch(t){case`now`:return[Date.now()/1e3];case`gmtime`:{if(typeof e!=`number`)return[null];let t=vv(e,`gmtime`),n=t.getUTCFullYear(),r=t.getUTCMonth(),i=t.getUTCDate(),a=t.getUTCHours(),o=t.getUTCMinutes(),s=t.getUTCSeconds(),c=t.getUTCDay(),l=Date.UTC(n,0,1);return[[n,r,i,a,o,s,c,Math.floor((t.getTime()-l)/864e5)]]}case`mktime`:{if(!Array.isArray(e))throw Error(`mktime requires parsed datetime inputs`);let[t,n,r,i=0,a=0,o=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`mktime requires parsed datetime inputs`);return[Math.floor(Date.UTC(t,n,r??1,i??0,a??0,o??0)/1e3)]}case`strftime`:{if(n.length===0)return[null];let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strftime/1 requires a string format`);let a;if(typeof e==`number`)a=vv(e,`strftime`);else if(Array.isArray(e)){let[t,n,r,i=0,o=0,s=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`strftime/1 requires parsed datetime inputs`);a=new Date(Date.UTC(t,n,r??1,i??0,o??0,s??0))}else throw Error(`strftime/1 requires parsed datetime inputs`);let o=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],s=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],c=(e,t=2)=>String(e).padStart(t,`0`);return[t.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,c(a.getUTCMonth()+1)).replace(/%d/g,c(a.getUTCDate())).replace(/%H/g,c(a.getUTCHours())).replace(/%M/g,c(a.getUTCMinutes())).replace(/%S/g,c(a.getUTCSeconds())).replace(/%A/g,o[a.getUTCDay()]).replace(/%B/g,s[a.getUTCMonth()]).replace(/%Z/g,`UTC`).replace(/%%/g,`%`)]}case`strptime`:{if(n.length===0)return[null];if(typeof e!=`string`)throw Error(`strptime/1 requires a string input`);let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strptime/1 requires a string format`);if(t!==xv)throw Error(`strptime format is not supported: ${t}`);let a=yv(e);if(a){let e=a.getUTCFullYear(),t=a.getUTCMonth(),n=a.getUTCDate(),r=a.getUTCHours(),i=a.getUTCMinutes(),o=a.getUTCSeconds(),s=a.getUTCDay(),c=Date.UTC(e,0,1);return[[e,t,n,r,i,o,s,Math.floor((a.getTime()-c)/864e5)]]}throw Error(`Cannot parse date: ${e}`)}case`fromdate`:{if(typeof e!=`string`)throw Error(`fromdate requires a string input`);let t=yv(e);if(!t)throw Error(`date "${e}" does not match format "${xv}"`);return[Math.floor(t.getTime()/1e3)]}case`todate`:if(typeof e!=`number`)throw Error(`todate requires a number input`);return[vv(e,`todate`).toISOString().replace(/\.\d{3}Z$/,`Z`)];default:return null}}var xv,Sv=T(()=>{xv=`%Y-%m-%dT%H:%M:%SZ`});function Cv(e){return e!==!1&&e!==null}function wv(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Tv(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`string`&&typeof t==`string`?e.localeCompare(t):0}function Ev(e,t,n={}){let r=n.maxDepth??2e3,i=vl(e),a=[{target:i,source:t,depth:0}];for(;a.length>0;){let e=a.pop();if(!e)break;if(e.depth>r)throw new A(`query depth limit exceeded (${r})`,`recursion`);for(let t of Object.keys(e.source)){if(n.visit?.(),!fl(t))continue;let r=ml(e.target,t)?gl(e.target[t]):null,i=gl(e.source[t]);if(r&&i){let n=vl(r);pl(e.target,t,n),a.push({target:n,source:i,depth:e.depth+1})}else pl(e.target,t,e.source[t])}}return i}function Dv(e,t=3e3){if(typeof e!=`object`||!e)return 0;if(t<=1)return t;let n=(e,t)=>({value:e,keys:Array.isArray(e)?void 0:Object.keys(e),nextChild:0,pathDepth:t,maxChildDepth:0}),r=e=>e.keys===void 0?e.value.length:e.keys.length,i=e=>{if(e.keys){let t=e.keys[e.nextChild++];return e.value[t]}return e.value[e.nextChild++]},a=new WeakMap,o=new WeakMap,s=e,c=[n(s,1)];for(a.set(s,`visiting`);c.length>0;){let e=c[c.length-1];if(e.nextChild<r(e)){let r=i(e);if(typeof r!=`object`||!r)continue;let s=a.get(r);if(s===`visiting`)return t;if(s===`done`){let n=o.get(r)??0;if(e.pathDepth+n>=t)return t;e.maxChildDepth=Math.max(e.maxChildDepth,n);continue}let l=e.pathDepth+1;if(l>=t)return t;let u=r;a.set(r,`visiting`),c.push(n(u,l));continue}let s=e.maxChildDepth+1;o.set(e.value,s),a.set(e.value,`done`),c.pop();let l=c.at(-1);if(l)l.maxChildDepth=Math.max(l.maxChildDepth,s);else return s}return 0}function Ov(e,t){let n=e=>e===null?0:typeof e==`boolean`?1:typeof e==`number`?2:typeof e==`string`?3:Array.isArray(e)?4:typeof e==`object`?5:6,r=n(e),i=n(t);if(r!==i)return r-i;if(typeof e==`number`&&typeof t==`number`)return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);if(typeof e==`boolean`&&typeof t==`boolean`)return!!e-+!!t;if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<Math.min(e.length,t.length);n++){let r=Ov(e[n],t[n]);if(r!==0)return r}return e.length-t.length}let a=gl(e),o=gl(t);if(a&&o){let e=Object.keys(a).sort(),t=Object.keys(o).sort();for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n].localeCompare(t[n]);if(r!==0)return r}if(e.length!==t.length)return e.length-t.length;for(let t of e){let e=Ov(a[t],o[t]);if(e!==0)return e}}return 0}function kv(e,t){if(wv(e,t))return!0;if(typeof e==`string`&&typeof t==`string`)return e.includes(t);if(Array.isArray(e)&&Array.isArray(t))return t.every(t=>e.some(e=>kv(e,t)));let n=gl(e),r=gl(t);return n&&r?Object.keys(r).every(e=>ml(n,e)&&kv(n[e],r[e])):!1}var Av=T(()=>{j(),xl()});function jv(e){let t=[];for(let n=0;n<e.length;n+=32768){let r=Math.min(n+32768,e.length),i=``;for(let t=n;t<r;t++)i+=String.fromCharCode(e[t]);t.push(i)}return t.join(``)}function Mv(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function Nv(e,t,n){switch(t){case`@base64`:if(typeof e==`string`){if(typeof Buffer<`u`)return[Buffer.from(e,`utf-8`).toString(`base64`)];let t=new TextEncoder().encode(e);return[btoa(jv(t))]}return[null];case`@base64d`:if(typeof e==`string`){if(typeof Buffer<`u`)return[Buffer.from(e,`base64`).toString(`utf-8`)];let t=Mv(atob(e));return[new TextDecoder(`utf-8`,{fatal:!1}).decode(t)]}return[null];case`@uri`:return typeof e==`string`?[encodeURIComponent(e).replace(/!/g,`%21`).replace(/'/g,`%27`).replace(/\(/g,`%28`).replace(/\)/g,`%29`).replace(/\*/g,`%2A`)]:[null];case`@urid`:return typeof e==`string`?[decodeURIComponent(e)]:[null];case`@csv`:return Array.isArray(e)?[e.map(e=>{if(e===null)return``;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return String(e);let t=String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
643
- `)||t.includes(`\r`)?`"${t.replace(/"/g,`""`)}"`:t}).join(`,`)]:[null];case`@tsv`:return Array.isArray(e)?[e.map(e=>String(e??``).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`)).join(` `)]:[null];case`@json`:{let t=n??Pv;return Dv(e,t+1)>t?[null]:[JSON.stringify(e)]}case`@html`:return typeof e==`string`?[e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/'/g,`&apos;`).replace(/"/g,`&quot;`)]:[null];case`@sh`:return typeof e==`string`?[`'${e.replace(/'/g,`'\\''`)}'`]:[null];case`@text`:return typeof e==`string`?[e]:e==null?[``]:[String(e)];default:return null}}var Pv,Fv=T(()=>{Av(),Pv=2e3});function Iv(e,t,n,r,i,a){switch(t){case`index`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){if(t===``&&e===``)return null;let n=e.indexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=0;n<=e.length-t.length;n++){let r=!0;for(let i=0;i<t.length;i++)if(!a(e[n+i],t[i])){r=!1;break}if(r)return n}return null}let n=e.findIndex(e=>a(e,t));return n>=0?n:null}return null});case`rindex`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){let n=e.lastIndexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=e.length-t.length;n>=0;n--){let r=!0;for(let i=0;i<t.length;i++)if(!a(e[n+i],t[i])){r=!1;break}if(r)return n}return null}for(let n=e.length-1;n>=0;n--)if(a(e[n],t))return n;return null}return null});case`indices`:return n.length===0?[[]]:i(e,n[0],r).map(t=>{let n=[];if(typeof e==`string`&&typeof t==`string`){let r=e.indexOf(t);for(;r!==-1;)n.push(r),r=e.indexOf(t,r+1)}else if(Array.isArray(e))if(Array.isArray(t)){let r=t.length;if(r===0)for(let t=0;t<=e.length;t++)n.push(t);else for(let i=0;i<=e.length-r;i++){let o=!0;for(let n=0;n<r;n++)if(!a(e[i+n],t[n])){o=!1;break}o&&n.push(i)}}else for(let r=0;r<e.length;r++)a(e[r],t)&&n.push(r);return n});default:return null}}var Lv=T(()=>{});function Rv(e,t,n,r,i){switch(t){case`fabs`:case`abs`:return typeof e==`number`?[Math.abs(e)]:typeof e==`string`?[e]:[null];case`exp10`:return typeof e==`number`?[10**e]:[null];case`exp2`:return typeof e==`number`?[2**e]:[null];case`pow`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[o**s]}case`atan2`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[Math.atan2(o,s)]}case`hypot`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.hypot(e,t)]}case`fma`:{if(typeof e!=`number`||n.length<2)return[null];let t=i(e,n[0],r)[0],a=i(e,n[1],r)[0];return[e*t+a]}case`copysign`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.sign(t)*Math.abs(e)]}case`drem`:case`remainder`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[e-Math.round(e/t)*t]}case`fdim`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(0,e-t)]}case`fmax`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(e,t)]}case`fmin`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.min(e,t)]}case`ldexp`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`scalbn`:case`scalbln`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`nearbyint`:return typeof e==`number`?[Math.round(e)]:[null];case`logb`:return typeof e==`number`?[Math.floor(Math.log2(Math.abs(e)))]:[null];case`significand`:return typeof e==`number`?[e/2**Math.floor(Math.log2(Math.abs(e)))]:[null];case`frexp`:if(typeof e==`number`){if(e===0)return[[0,0]];let t=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**t,t]]}return[null];case`modf`:if(typeof e==`number`){let t=Math.trunc(e);return[[e-t,t]]}return[null];default:return null}}var zv=T(()=>{});function Bv(e){let t=e.limits.maxIterations;return{maxDepth:e.limits.maxDepth,maxResults:e.limits.maxArrayElements,maxIterations:t}}function Vv(e){throw new A(e,`array_elements`)}function Hv(e,t){let n=1;for(let r of e){if(!Number.isSafeInteger(r)||r<0)throw Error(`combinations requires finite array lengths`);r!==0&&n>Math.floor(t/r)&&Vv(`query combination limit exceeded (${t})`),n*=r}return n}function Uv(e,t,n,r,i,a,o,s){switch(t){case`recurse`:{let t=[],o=Bv(r),s=n.length>=2?n[1]:null,c=[{value:e,depth:0}],l=0;for(;c.length>0;){let e=c.pop();if(!e)break;if(++l>o.maxIterations)throw new A(`query iteration limit exceeded (${o.maxIterations})`,`iterations`);if(e.depth>o.maxDepth)throw new A(`query depth limit exceeded (${o.maxDepth})`,`recursion`);if(s&&!i(e.value,s,r).some(a))continue;t.length>=o.maxResults&&Vv(`query result element limit exceeded (${o.maxResults})`),t.push(e.value);let u=[];n.length===0?Array.isArray(e.value)?u=e.value:e.value&&typeof e.value==`object`&&(u=Object.keys(e.value).map(t=>e.value[t])):u=i(e.value,n[0],r).filter(e=>e!=null),c.length>o.maxResults-u.length&&Vv(`query traversal queue limit exceeded (${o.maxResults})`);for(let t=u.length-1;t>=0;t--)c.push({value:u[t],depth:e.depth+1})}return t}case`recurse_down`:return s(e,`recurse`,n,r);case`walk`:{if(n.length===0)return[e];let t=Bv(r),a=new WeakSet,o=new WeakMap,s=[{value:e,depth:0,expanded:!1}],c=e,l=0;for(;s.length>0;){let e=s.pop();if(!e)break;if(++l>t.maxIterations)throw new A(`query iteration limit exceeded (${t.maxIterations})`,`iterations`);if(e.depth>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let u=e.value!==null&&typeof e.value==`object`?e.value:null;if(!e.expanded&&u){if(a.has(u))continue;a.add(u),s.push({...e,expanded:!0});let n=gl(e.value),r=Array.isArray(e.value)?e.value:Object.keys(n??{}).map(e=>n?.[e]);s.length>t.maxResults-r.length&&Vv(`query traversal queue limit exceeded (${t.maxResults})`);for(let t=r.length-1;t>=0;t--)s.push({value:r[t],depth:e.depth+1,expanded:!1});continue}let d=e.value;if(Array.isArray(e.value))d=e.value.map(e=>typeof e==`object`&&e?o.get(e)??e:e);else if(u){let t=Object.create(null),n=gl(e.value);for(let e of Object.keys(n??{})){if(!fl(e))continue;let r=n?.[e];pl(t,e,typeof r==`object`&&r?o.get(r)??r:r)}d=t}let f=i(d,n[0],r)[0];u&&o.set(u,f),e.depth===0&&(c=f)}return[c]}case`transpose`:{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let t=Bv(r),n=0;for(let t of e)Array.isArray(t)&&(n=Math.max(n,t.length));Hv([e.length,n],t.maxResults);let i=[];for(let t=0;t<n;t++)i.push(e.map(e=>Array.isArray(e)?e[t]:null));return[i]}case`combinations`:{if(n.length>0){let t=i(e,n[0],r)[0];if(!Array.isArray(e))return[];if(!Number.isFinite(t)||!Number.isSafeInteger(t)||t<0)throw Error(`combinations length must be a finite non-negative integer`);let a=Bv(r);if(t>a.maxDepth||t>a.maxResults)throw new A(`query depth limit exceeded (${a.maxDepth})`,`recursion`);if(t===0)return a.maxResults<1&&Vv(`query combination limit exceeded (0)`),[[]];let o=Hv(Array.from({length:t},()=>e.length),a.maxResults);if(o===0)return[];let s=[],c=Array(t).fill(0);for(let n=0;n<o;n++){s.push(c.map(t=>e[t]));for(let n=t-1;n>=0&&(c[n]++,!(c[n]<e.length));n--)c[n]=0}return s}if(!Array.isArray(e))return[];if(e.length===0)return Bv(r).maxResults<1&&Vv(`query combination limit exceeded (0)`),[[]];for(let t of e)if(!Array.isArray(t))return[];let t=Bv(r),a=e;if(a.length>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let o=Hv(a.map(e=>e.length),t.maxResults);if(o===0)return[];let s=[],c=Array(a.length).fill(0);for(let e=0;e<o;e++){s.push(c.map((e,t)=>a[t][e]));for(let e=a.length-1;e>=0&&(c[e]++,!(c[e]<a[e].length));e--)c[e]=0}return s}case`parent`:{if(r.root===void 0||r.currentPath===void 0)return[];let t=r.currentPath;if(t.length===0)return[];let a=n.length>0?i(e,n[0],r)[0]:1;if(a>=0){if(a>t.length)return[];let e=t.slice(0,t.length-a);return[o(r.root,e)]}{let n=-a-1;if(n>=t.length)return[e];let i=t.slice(0,n);return[o(r.root,i)]}}case`parents`:{if(r.root===void 0||r.currentPath===void 0)return[[]];let e=r.currentPath,t=[];for(let n=e.length-1;n>=0;n--)t.push(o(r.root,e.slice(0,n)));return[t]}case`root`:return r.root===void 0?[]:[r.root];default:return null}}var Wv=T(()=>{j(),xl()});function Gv(e){return e.limits.maxArrayElements}function Kv(e,t){let n=Gv(e);if(t>=n)throw new A(`query result element limit exceeded (${n})`,`array_elements`)}function qv(e,t){let n=t.limits.maxDepth??Yv;if(e.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new A(`query array index limit exceeded (${r})`,`array_elements`)}else if(typeof t!=`string`)throw Error(`stream path components must be strings or integers`)}function Jv(e,t,n,r,i){switch(t){case`keys`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e).sort()]:[null];case`keys_unsorted`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e)]:[null];case`length`:return typeof e==`string`||Array.isArray(e)?[e.length]:e&&typeof e==`object`?[Object.keys(e).length]:e===null?[0]:typeof e==`number`?[Math.abs(e)]:[null];case`utf8bytelength`:{if(typeof e==`string`)return[O(e)];let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) only strings have UTF-8 byte length`)}case`to_entries`:{let t=gl(e);if(t){let e=Object.keys(t);if(e.length>Gv(r))throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);return[e.map(e=>{let n=Object.create(null);return pl(n,`key`,e),pl(n,`value`,t[e]),n})]}return[null]}case`from_entries`:if(Array.isArray(e)){let t=Object.create(null);for(let n of e){let e=gl(n);if(e){let n=e.key??e.Key??e.name??e.Name??e.k,r=e.value??e.Value??e.v;if(n!==void 0){let e=String(n);fl(e)&&pl(t,e,r)}}}return[t]}return[null];case`with_entries`:{if(n.length===0)return[e];let t=gl(e);if(t){let e=Object.keys(t);if(e.length>Gv(r))throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);let a=[];for(let o of e){let e=Object.create(null);pl(e,`key`,o),pl(e,`value`,t[o]);let s=i(e,n[0],r);if(a.length>Gv(r)-s.length)throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);for(let e of s)a.push(e)}let o=Object.create(null);for(let e of a){let t=gl(e);if(t){let e=t.key??t.name??t.k,n=t.value??t.v;if(e!==void 0){let t=String(e);fl(t)&&pl(o,t,n)}}}return[o]}return[null]}case`reverse`:return Array.isArray(e)?[[...e].reverse()]:typeof e==`string`?[e.split(``).reverse().join(``)]:[null];case`flatten`:return Array.isArray(e)?(n.length>0?i(e,n[0],r):[1/0]).map(t=>{let n=t;if(n<0)throw Error(`flatten depth must not be negative`);return e.flat(n)}):[null];case`unique`:if(Array.isArray(e)){let t=new Set,n=[];for(let r of e){let e=JSON.stringify(r);t.has(e)||(t.add(e),n.push(r))}return[n]}return[null];case`tojson`:case`tojsonstream`:{let t=r.limits.maxDepth??Yv;return Dv(e,t+1)>t?[null]:[JSON.stringify(e)]}case`fromjson`:if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`nan`)return[NaN];if(t===`inf`||t===`infinity`)return[1/0];if(t===`-inf`||t===`-infinity`)return[-1/0];try{return[hl(JSON.parse(e),{maxDepth:r.limits.maxDepth,maxElements:r.limits.maxArrayElements})]}catch(t){throw t instanceof A?t:Error(`Invalid JSON: ${e}`)}}return[e];case`tostring`:return typeof e==`string`?[e]:[JSON.stringify(e)];case`tonumber`:if(typeof e==`number`)return[e];if(typeof e==`string`){let t=Number(e);if(Number.isNaN(t))throw Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[t]}throw Error(`${typeof e} cannot be parsed as a number`);case`toboolean`:{if(typeof e==`boolean`)return[e];if(typeof e==`string`){if(e===`true`)return[!0];if(e===`false`)return[!1];throw Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) cannot be parsed as a boolean`)}case`tostream`:{let t=[],n=r.limits.maxDepth??Yv,i=[{value:e,path:[]}],a=new WeakSet,o=0;for(;i.length>0;){let e=i.pop();if(!e)break;if(++o>r.limits.maxIterations)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);if(e.path.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let s=e.value;if(typeof s!=`object`||!s)Kv(r,t.length),t.push([e.path,s]);else if(Array.isArray(s)){if(a.has(s))throw new A(`cyclic value cannot be converted to a stream`,`recursion`);if(a.add(s),s.length===0)Kv(r,t.length),t.push([e.path,[]]);else{if(i.length>Gv(r)-s.length)throw new A(`query traversal queue limit exceeded (${Gv(r)})`,`array_elements`);for(let t=s.length-1;t>=0;t--)i.push({value:s[t],path:[...e.path,t]})}}else{if(a.has(s))throw new A(`cyclic value cannot be converted to a stream`,`recursion`);a.add(s);let n=Object.keys(s);if(n.length===0)Kv(r,t.length),t.push([e.path,Object.create(null)]);else{if(i.length>Gv(r)-n.length)throw new A(`query traversal queue limit exceeded (${Gv(r)})`,`array_elements`);for(let t=n.length-1;t>=0;t--){let r=n[t];i.push({value:s[r],path:[...e.path,r]})}}}}return Kv(r,t.length),t.push([[]]),t}case`fromstream`:{if(n.length===0)return[e];let t=i(e,n[0],r);if(t.length>Gv(r))throw new A(`query stream item limit exceeded (${Gv(r)})`,`array_elements`);let a=null,o=0;for(let e of t){if(!Array.isArray(e)||e.length===1&&Array.isArray(e[0])&&e[0].length===0||e.length!==2)continue;let[t,n]=e;if(!Array.isArray(t))continue;if(qv(t,r),t.length===0){a=n;continue}a===null&&(a=typeof t[0]==`number`?[]:Object.create(null));let i=a;for(let e=0;e<t.length-1;e++){let n=t[e],a=t[e+1];if(Array.isArray(i)&&typeof n==`number`){let e=n+1-i.length;if(e>r.limits.maxIterations-o)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=n;)i.push(null);i[n]===null&&(i[n]=typeof a==`number`?[]:Object.create(null)),i=i[n]}else{let e=gl(i);if(e){let t=String(n);if(!fl(t))continue;(e[t]===null||e[t]===void 0)&&pl(e,t,typeof a==`number`?[]:Object.create(null)),i=e[t]}}}let s=t[t.length-1];if(Array.isArray(i)&&typeof s==`number`){let e=s+1-i.length;if(e>r.limits.maxIterations-o)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=s;)i.push(null);i[s]=n}else{let e=gl(i);if(e){let t=String(s);fl(t)&&pl(e,t,n)}}}return[a]}case`truncate_stream`:{let t=typeof e==`number`?Math.floor(e):0;if(n.length===0)return[];let a=[],o=i(e,n[0],r);for(let e of o)if(Array.isArray(e)){if(e.length===1&&Array.isArray(e[0])){let n=e[0];n.length>t&&a.push([n.slice(t)]);continue}if(e.length===2&&Array.isArray(e[0])){let n=e[0],r=e[1];n.length>t&&a.push([n.slice(t),r])}}return a}default:return null}}var Yv,Xv=T(()=>{k(),j(),xl(),Av(),Yv=2e3});function Zv(e,t){if(!Array.isArray(e))throw Error(`path must be an array`);let n=t.limits.maxDepth;if(e.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements,i=0;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new A(`query array index limit exceeded (${r})`,`array_elements`);let e=t+1;if(i>r-e)throw new A(`query cumulative array allocation limit exceeded (${r})`,`array_elements`);i+=e}else if(typeof t!=`string`)throw Error(`path components must be strings or integers`);return gy(t,i+e.length),e}function Qv(e,t,n){let r=[],i=[{value:e,path:[],isRoot:!0}];for(;i.length>0;){let e=i.pop();if(!e)break;if(gy(t),e.path.length>t.limits.maxDepth)throw new A(`query depth limit exceeded (${t.limits.maxDepth})`,`recursion`);if(e.value===null||typeof e.value!=`object`){(n||!e.isRoot)&&(_y(t,r.length),r.push(e.path));continue}!n&&!e.isRoot&&(_y(t,r.length),r.push(e.path));let a=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);_y(t,r.length,i.length+a.length);for(let t=a.length-1;t>=0;t--){let[n,r]=a[t],o=[...e.path,n];i.push({value:r,path:o,isRoot:!1})}}return r}function $v(e,t,n,r,i,a,o,s,c,l){switch(t){case`getpath`:{if(n.length===0)return[null];let t=i(e,n[0],r),a=[];for(let n of t){let t=n,r=e;for(let e of t){if(r==null){r=null;break}if(Array.isArray(r)&&typeof e==`number`)r=r[e];else if(typeof e==`string`){let t=gl(r);if(!t||!Object.hasOwn(t,e)){r=null;break}r=t[e]}else{r=null;break}}a.push(r)}return a}case`setpath`:{if(n.length<2)return[null];let t=Zv(i(e,n[0],r)[0],r),a=i(e,n[1],r)[0];return[o(e,t,a)]}case`delpaths`:{if(n.length===0)return[e];let t=i(e,n[0],r)[0],a=e;for(let e of t.sort((e,t)=>t.length-e.length))a=s(a,e);return[a]}case`path`:{if(n.length===0)return[[]];let t=[];return l(e,n[0],r,[],t),t}case`del`:return n.length===0?[e]:[c(e,n[0],r)];case`pick`:{if(n.length===0)return[null];let t=[];for(let i of n)l(e,i,r,[],t);let i=null;for(let n of t){for(let e of n)if(typeof e==`number`&&e<0)throw Error(`Out of bounds negative array index`);Zv(n,r);let t=e;for(let e of n){if(t==null)break;if(Array.isArray(t)&&typeof e==`number`)t=t[e];else if(typeof e==`string`){let n=gl(t);if(!n||!Object.hasOwn(n,e)){t=null;break}t=n[e]}else{t=null;break}}i=o(i,n,t)}return[i]}case`paths`:{let t=Qv(e,r,!1);return n.length>0?t.filter(t=>{let o=e;for(let e of t)if(Array.isArray(o)&&typeof e==`number`)o=o[e];else if(typeof e==`string`){let t=gl(o);if(!t||!Object.hasOwn(t,e))return!1;o=t[e]}else return!1;return i(o,n[0],r).some(a)}):t}case`leaf_paths`:return Qv(e,r,!0);default:return null}}var ey=T(()=>{j(),By(),xl()});function ty(e,t,n,r,i,a){switch(t){case`IN`:{if(n.length===0)return[!1];if(n.length===1){let t=i(e,n[0],r);for(let n of t)if(a(e,n))return[!0];return[!1]}let t=i(e,n[0],r),o=i(e,n[1],r),s=new Set(o.map(e=>JSON.stringify(e)));for(let e of t)if(s.has(JSON.stringify(e)))return[!0];return[!1]}case`INDEX`:{if(n.length===0)return[Object.create(null)];if(n.length===1){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=String(e);fl(t)&&pl(a,t,e)}return[a]}if(n.length===2){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r);if(t.length>0){let n=String(t[0]);fl(n)&&pl(a,n,e)}}return[a]}let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r),o=i(e,n[2],r);if(t.length>0&&o.length>0){let e=String(t[0]);fl(e)&&pl(a,e,o[0])}}return[a]}case`JOIN`:{if(n.length<2)return[null];let t=gl(i(e,n[0],r)[0]);if(!t||!Array.isArray(e))return[null];let a=[];for(let o of e){let e=i(o,n[1],r),s=e.length>0?String(e[0]):``,c=ml(t,s)?t[s]:null;a.push([o,c])}return[a]}default:return null}}var ny=T(()=>{xl()});function ry(e){return e.limits.maxArrayElements}function iy(e){return Math.min(e.limits.maxStringLength,e.limits.maxOutputSize)}function ay(e,t){let n=ry(e);if(!Number.isSafeInteger(t)||t<0||t>n)throw new A(`query result element limit exceeded (${n})`,`array_elements`)}function oy(e,t,n){if(e===``)return t===``?0:1;if(t===``)return e.length;let r=1,i=0;for(;;){let a=e.indexOf(t,i);if(a<0||(r++,r>n))return r;i=a+t.length}}function sy(e,t,n,r,i){switch(t){case`join`:{if(!Array.isArray(e))return[null];let t=n.length>0?i(e,n[0],r):[``];for(let t of e)if(Array.isArray(t)||typeof t==`object`&&t)throw Error(`cannot join: contains arrays or objects`);return ay(r,t.length),t.map(t=>{let n=String(t),i=0;for(let t=0;t<e.length;t++){let a=e[t]===null?``:typeof e[t]==`string`?e[t]:String(e[t]);if(i+=O(a),t>0&&(i+=O(n)),i>iy(r))throw new A(`query string size limit exceeded (${iy(r)} bytes)`,`string_length`)}return e.map(e=>e===null?``:typeof e==`string`?e:String(e)).join(n)})}case`split`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);return ay(r,oy(e,a,ry(r))),[e.split(a)]}case`splits`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):`g`,o=U(a,t.includes(`g`)?t:`${t}g`),s=1;for(let t of o.matchAll(e))s+=Math.max(1,t.length),ay(r,s);let c=o.split(e);return ay(r,c.length),c}catch(e){if(e instanceof A)throw e;return[]}}case`scan`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):``,o=U(a,t.includes(`g`)?t:`${t}g`),s=[];for(let t of o.matchAll(e))ay(r,s.length+1),t.length>1?(ay(r,t.length-1),s.push(t.slice(1))):s.push(t[0]);return s}catch(e){if(e instanceof A)throw e;return[]}}case`test`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r),a=String(t[0]);try{return[U(a,n.length>1?String(i(e,n[1],r)[0]):``).test(e)]}catch{return[!1]}}case`match`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=U(a,`${n.length>1?String(i(e,n[1],r)[0]):``}d`).exec(e);if(!t)return[];let o=t.indices;return[{offset:t.index,length:t[0].length,string:t[0],captures:t.slice(1).map((e,t)=>({offset:o?.[t+1]?.[0]??null,length:e?.length??0,string:e??``,name:null}))}]}catch{return[null]}}case`capture`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=U(a,n.length>1?String(i(e,n[1],r)[0]):``).match(e);return!t||!t.groups?[Object.create(null)]:[t.groups]}catch{return[null]}}case`sub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{return[U(o,n.length>2?String(i(e,n[2],r)[0]):``).replace(e,s)]}catch{return[e]}}case`gsub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{let t=n.length>2?String(i(e,n[2],r)[0]):`g`;return[U(o,t.includes(`g`)?t:`${t}g`).replace(e,s)]}catch{return[e]}}case`ascii_downcase`:return typeof e==`string`?[e.replace(/[A-Z]/g,e=>String.fromCharCode(e.charCodeAt(0)+32))]:[null];case`ascii_upcase`:return typeof e==`string`?[e.replace(/[a-z]/g,e=>String.fromCharCode(e.charCodeAt(0)-32))]:[null];case`ltrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return[e.startsWith(a)?e.slice(a.length):e]}case`rtrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return a===``?[e]:[e.endsWith(a)?e.slice(0,-a.length):e]}case`trimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);if(a===``)return[e];let o=e;return o.startsWith(a)&&(o=o.slice(a.length)),o.endsWith(a)&&(o=o.slice(0,-a.length)),[o]}case`trim`:if(typeof e==`string`)return[e.trim()];throw Error(`trim input must be a string`);case`ltrim`:if(typeof e==`string`)return[e.trimStart()];throw Error(`trim input must be a string`);case`rtrim`:if(typeof e==`string`)return[e.trimEnd()];throw Error(`trim input must be a string`);case`startswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.startsWith(String(t[0]))]}case`endswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.endsWith(String(t[0]))]}case`ascii`:return typeof e==`string`&&e.length>0?[e.charCodeAt(0)]:[null];case`explode`:if(typeof e==`string`){let t=0;for(let n of e)t++,ay(r,t);return[Array.from(e).map(e=>e.codePointAt(0))]}return[null];case`implode`:if(!Array.isArray(e))throw Error(`implode input must be an array`);return[e.map(e=>{if(typeof e==`string`)throw Error(`string (${JSON.stringify(e)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof e!=`number`||Number.isNaN(e))throw Error(`number (null) can't be imploded, unicode codepoint needs to be numeric`);let t=Math.trunc(e);return t<0||t>1114111||t>=55296&&t<=57343?String.fromCodePoint(65533):String.fromCodePoint(t)}).join(``)];default:return null}}var cy=T(()=>{j(),mc(),Lr()});function ly(e,t){switch(t){case`type`:return e===null?[`null`]:Array.isArray(e)?[`array`]:typeof e==`boolean`?[`boolean`]:typeof e==`number`?[`number`]:typeof e==`string`?[`string`]:typeof e==`object`?[`object`]:[`null`];case`infinite`:return[1/0];case`nan`:return[NaN];case`isinfinite`:return[typeof e==`number`&&!Number.isFinite(e)];case`isnan`:return[typeof e==`number`&&Number.isNaN(e)];case`isnormal`:return[typeof e==`number`&&Number.isFinite(e)&&e!==0];case`isfinite`:return[typeof e==`number`&&Number.isFinite(e)];case`numbers`:return typeof e==`number`?[e]:[];case`strings`:return typeof e==`string`?[e]:[];case`booleans`:return typeof e==`boolean`?[e]:[];case`nulls`:return e===null?[e]:[];case`arrays`:return Array.isArray(e)?[e]:[];case`objects`:return e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`iterables`:return Array.isArray(e)||e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`scalars`:return!Array.isArray(e)&&!(e&&typeof e==`object`)?[e]:[];case`values`:return e===null?[]:[e];case`not`:return e===!1||e===null?[!0]:[!1];case`null`:return[null];case`true`:return[!0];case`false`:return[!1];case`empty`:return[];default:return null}}var uy=T(()=>{}),dy=T(()=>{hv(),_v(),Sv(),Fv(),Lv(),zv(),Wv(),Xv(),ey(),ny(),cy(),uy()});function fy(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(typeof r==`number`){if(e&&typeof e==`object`&&!Array.isArray(e))throw Error(`Cannot index object with number`);if(r>536870911)throw Error(`Array index too large`);if(r<0)throw Error(`Out of bounds negative array index`);let t=Array.isArray(e)?[...e]:[];for(;t.length<=r;)t.push(null);return t[r]=fy(t[r],i,n),t}if(Array.isArray(e))throw Error(`Cannot index array with string`);if(!fl(r))return e??Object.create(null);let a=gl(e),o=a?vl(a):Object.create(null);return pl(o,r,fy(Object.hasOwn(o,r)?o[r]:void 0,i,n)),o}function py(e,t){if(t.length===0)return null;if(t.length===1){let n=t[0];if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t.splice(n,1),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!fl(t))return e;let r=vl(e);return delete r[t],r}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t[n]=py(t[n],r),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!fl(t))return e;let i=vl(e);return Object.hasOwn(i,t)&&pl(i,t,py(i[t],r)),i}return e}var my=T(()=>{xl()});function hy(e,t){return new A(e,t)}function gy(e,t=1){if(!Number.isSafeInteger(t)||t<0||e.budget.operations>e.limits.maxIterations-t)throw hy(`query evaluation: too many iterations (${e.limits.maxIterations})`,`iterations`);e.budget.operations+=t}function _y(e,t,n=1){let r=e.limits.maxArrayElements;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0||t>r-n)throw hy(`query result element limit exceeded (${r})`,`array_elements`)}function vy(e,t,n){_y(e,t.length,n.length);for(let e of n)t.push(e)}function yy(e,t,n){let r=[];for(let i of t)gy(e),vy(e,r,n(i));return r}function by(e){let t=new Map;if(e?.namedArgs)for(let[n,r]of e.namedArgs)t.set(`$${n}`,r);return{vars:t,limits:{maxIterations:e?.limits?.maxIterations??Iy,maxDepth:e?.limits?.maxDepth??Ry,maxStringLength:e?.limits?.maxStringLength??Ly,maxOutputSize:e?.limits?.maxOutputSize??Ly,maxArrayElements:e?.limits?.maxArrayElements??1e5},env:e?.env,namedArgs:e?.namedArgs,positionalArgs:e?.positionalArgs,coverage:e?.coverage,requireDefenseContext:e?.requireDefenseContext,defenseContextChecked:!1,budget:e?.budget??{operations:0,callDepth:0}}}function xy(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,namedArgs:e.namedArgs,positionalArgs:e.positionalArgs,requireDefenseContext:e.requireDefenseContext,defenseContextChecked:e.defenseContextChecked,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels,coverage:e.coverage,budget:e.budget}}function Sy(e,t,n){switch(t.type){case`var`:return xy(e,t.name,n);case`array`:{if(!Array.isArray(n))return null;let r=e;for(let e=0;e<t.elements.length;e++){let i=t.elements[e],a=e<n.length?n[e]:null,o=Sy(r,i,a);if(o===null)return null;r=o}return r}case`object`:{let r=gl(n);if(!r)return null;let i=e;for(let a of t.fields){let t;if(typeof a.key==`string`)t=a.key;else{let r=J(n,a.key,e);if(r.length===0)return null;t=String(r[0])}let o=ml(r,t)?r[t]:null;a.keyVar&&(i=xy(i,a.keyVar,o));let s=Sy(i,a.pattern,o);if(s===null)return null;i=s}return i}}}function Cy(e,t){let n=e;for(let e of t)if(n&&typeof n==`object`)if(Array.isArray(n))if(typeof e==`number`)n=n[e];else return;else{let t=gl(n);if(t&&typeof e==`string`&&Object.hasOwn(t,e))n=t[e];else return}else return;return n}function wy(e){if(e.type===`Identity`)return[];if(e.type===`Field`){let t=e.base?wy(e.base):[];return t===null?null:[...t,e.name]}if(e.type===`Index`&&e.index.type===`Literal`){let t=e.base?wy(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n==`number`||typeof n==`string`?[...t,n]:null}if(e.type===`Pipe`){let t=wy(e.left);return t===null?null:Ty(t,e.right)}if(e.type===`Call`){if(e.name===`parent`||e.name===`root`)return null;if(e.name===`first`&&e.args.length===0)return[0];if(e.name===`last`&&e.args.length===0)return[-1]}return null}function Ty(e,t){if(t.type===`Call`){if(t.name===`parent`){let n=1;if(t.args.length>0&&t.args[0].type===`Literal`){let e=t.args[0].value;typeof e==`number`&&(n=e)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let t=-n-1;return e.slice(0,Math.min(t,e.length))}}if(t.name===`root`)return[]}if(t.type===`Field`){let n=wy(t);if(n!==null)return[...e,...n]}if(t.type===`Index`&&t.index.type===`Literal`){let n=wy(t);if(n!==null)return[...e,...n]}if(t.type===`Pipe`){let n=Ty(e,t.left);return n===null?null:Ty(n,t.right)}return t.type===`Identity`?e:null}function Ey(e,t,n){if(t.type===`Comma`){let r=[];try{vy(n,r,J(e,t.left,n))}catch(e){if(e instanceof A)throw e;if(r.length>0)return r;throw Error(`evaluation failed`)}try{vy(n,r,J(e,t.right,n))}catch(e){if(e instanceof A)throw e;return r}return r}return J(e,t,n)}function J(e,t,n){let r=n&&`vars`in n?n:by(n);if(r.defenseContextChecked||(bu(r.requireDefenseContext,`query-engine`,`evaluation`),r={...r,defenseContextChecked:!0}),r.root===void 0&&(r={...r,root:e,currentPath:[]}),gy(r),r.budget.callDepth++,r.budget.callDepth>r.limits.maxDepth)throw r.budget.callDepth--,hy(`query depth limit exceeded (${r.limits.maxDepth})`,`recursion`);try{let n=Dy(e,t,r);return _y(r,0,n.length),n}finally{r.budget.callDepth--}}function Dy(e,t,n){switch(n.coverage?.hit(`jq:node:${t.type}`),t.type){case`Identity`:return[e];case`Field`:return yy(n,t.base?J(e,t.base,n):[e],e=>{let n=gl(e);if(n){if(!Object.hasOwn(n,t.name))return[null];let e=n[t.name];return[e===void 0?null:e]}if(e===null)return[null];throw Error(`Cannot index ${Array.isArray(e)?`array`:typeof e} with string "${t.name}"`)});case`Index`:return yy(n,t.base?J(e,t.base,n):[e],e=>yy(n,J(e,t.index,n),t=>{if(typeof t==`number`&&Array.isArray(e)){if(Number.isNaN(t))return[null];let n=Math.trunc(t),r=n<0?e.length+n:n;return r>=0&&r<e.length?[e[r]]:[null]}if(typeof t==`string`){let n=gl(e);return!n||!Object.hasOwn(n,t)?[null]:[n[t]]}return[null]}));case`Slice`:return yy(n,t.base?J(e,t.base,n):[e],r=>{if(r===null)return[null];if(!Array.isArray(r)&&typeof r!=`string`)throw Error(`Cannot slice ${typeof r} (${JSON.stringify(r)})`);let i=r.length,a=t.start?J(e,t.start,n):[0],o=t.end?J(e,t.end,n):[i];return _y(n,0,a.length*o.length),yy(n,a,e=>o.map(t=>{let n=e,a=t,o=Number.isNaN(n)?0:Number.isInteger(n)?n:Math.floor(n),s=Number.isNaN(a)?i:Number.isInteger(a)?a:Math.ceil(a),c=Oy(o,i),l=Oy(s,i);return r.slice(c,l)}))});case`Iterate`:return yy(n,t.base?J(e,t.base,n):[e],e=>Array.isArray(e)?e:e&&typeof e==`object`?Object.values(e):[]);case`Pipe`:{let r=J(e,t.left,n),i=wy(t.left),a=[];for(let e of r)try{if(i!==null){let r={...n,currentPath:[...n.currentPath??[],...i]};vy(n,a,J(e,t.right,r))}else vy(n,a,J(e,t.right,n))}catch(e){throw e instanceof Py?e.withPrependedResults(a):e}return a}case`Comma`:{let r=J(e,t.left,n),i=J(e,t.right,n);return _y(n,r.length,i.length),[...r,...i]}case`Literal`:return[t.value];case`Array`:return t.elements?[J(e,t.elements,n)]:[[]];case`Object`:{let r=[Object.create(null)];for(let i of t.entries){let t=typeof i.key==`string`?[i.key]:J(e,i.key,n),a=J(e,i.value,n),o=[],s=t.filter(e=>typeof e==`string`&&fl(e)).length,c=s+(t.length-s);_y(n,0,r.length*c*a.length);for(let e of r)for(let n of t){if(typeof n!=`string`)throw Error(`Cannot use ${n===null?`null`:Array.isArray(n)?`array`:typeof n} (${JSON.stringify(n)}) as object key`);if(!fl(n)){for(let t of a)o.push(vl(e));continue}for(let t of a){let r=vl(e);pl(r,n,t),o.push(r)}}r.length=0,vy(n,r,o)}return r}case`Paren`:return J(e,t.expr,n);case`BinaryOp`:return jy(e,t.op,t.left,t.right,n);case`UnaryOp`:return J(e,t.operand,n).map(e=>{if(t.op===`-`){if(typeof e==`number`)return-e;if(typeof e==`string`)throw Error(`string (${(e=>e.length>5?`"${e.slice(0,3)}...`:JSON.stringify(e))(e)}) cannot be negated`);return null}return t.op===`not`?!Cv(e):null});case`Cond`:return yy(n,J(e,t.cond,n),r=>{if(Cv(r))return J(e,t.then,n);for(let r of t.elifs)if(J(e,r.cond,n).some(Cv))return J(e,r.then,n);return t.else?J(e,t.else,n):[e]});case`Try`:try{return J(e,t.body,n)}catch(e){if(e instanceof A)throw e;return t.catch?J(e instanceof Fy?e.value:e instanceof Error?e.message:String(e),t.catch,n):[]}case`Call`:return My(e,t.name,t.args,n);case`VarBind`:return yy(n,J(e,t.value,n),r=>{let i=null,a=[];if(t.pattern?a.push(t.pattern):t.name&&a.push({type:`var`,name:t.name}),t.alternatives)for(let e of t.alternatives)a.push(e);for(let e of a)if(i=Sy(n,e,r),i!==null)break;return i===null?[]:J(e,t.body,i)});case`VarRef`:{if(t.name===`$ENV`)return[n.env?rd(n.env):Object.create(null)];if(t.name===`$ARGS`){let e=Object.create(null);if(n.namedArgs)for(let[t,r]of n.namedArgs)Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0});let t=Object.create(null);return t.positional=n.positionalArgs?[...n.positionalArgs]:[],t.named=e,[t]}let e=n.vars.get(t.name);return e===void 0?[null]:[e]}case`Recurse`:{let t=[],r=new WeakSet,i=[{val:e,depth:0}];for(;i.length>0;){let e=i.pop();if(!e)break;let{val:a,depth:o}=e;if(gy(n),o>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);if(a&&typeof a==`object`){if(r.has(a))continue;r.add(a)}if(_y(n,t.length),t.push(a),Array.isArray(a))for(let e=a.length-1;e>=0;e--)i.push({val:a[e],depth:o+1});else if(a&&typeof a==`object`){let e=Object.keys(a);for(let t=e.length-1;t>=0;t--)i.push({val:a[e[t]],depth:o+1})}}return t}case`Optional`:try{return J(e,t.expr,n)}catch(e){if(e instanceof A)throw e;return[]}case`StringInterp`:{let r=new Ui(n.limits.maxStringLength,`query string interpolation`,()=>new A(`string size limit exceeded (${n.limits.maxStringLength} bytes)`,`string_length`));for(let i of t.parts){if(typeof i==`string`){r.append(i);continue}let t=J(e,i,n);for(let e of t){if(gy(n),Dv(e,n.limits.maxDepth+1)>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);r.append(typeof e==`string`?e:JSON.stringify(e))}}return[r.build()]}case`UpdateOp`:return[ky(e,t.path,t.op,t.value,n)];case`Reduce`:{let r=J(e,t.expr,n),i=J(e,t.init,n)[0],a=n.limits.maxDepth??Ry;for(let e of r){let r;if(t.pattern){if(r=Sy(n,t.pattern,e),r===null)continue}else r=xy(n,t.varName,e);if(i=J(i,t.update,r)[0],Dv(i,a+1)>a)return[null]}return[i]}case`Foreach`:{let r=J(e,t.expr,n),i=J(e,t.init,n)[0],a=[];for(let e of r)try{let r;if(t.pattern){if(r=Sy(n,t.pattern,e),r===null)continue}else r=xy(n,t.varName,e);i=J(i,t.update,r)[0],t.extract?vy(n,a,J(i,t.extract,r)):(_y(n,a.length),a.push(i))}catch(e){throw e instanceof Py?e.withPrependedResults(a):e}return a}case`Label`:try{return J(e,t.body,{...n,labels:new Set([...n.labels??[],t.name])})}catch(e){if(e instanceof Py&&e.label===t.name)return e.partialResults;throw e}case`Break`:throw new Py(t.name);case`Def`:{let r=new Map(n.funcs??[]),i=`${t.name}/${t.params.length}`;r.set(i,{params:t.params,body:t.funcBody,closure:new Map(n.funcs??[])});let a={...n,funcs:r};return J(e,t.body,a)}default:throw Error(`Unknown AST node type: ${t.type}`)}}function Oy(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function ky(e,t,n,r,i){function a(e,t){switch(n){case`=`:return t;case`|=`:return J(e,r,i)[0]??null;case`+=`:return typeof e==`number`&&typeof t==`number`||typeof e==`string`&&typeof t==`string`?e+t:Array.isArray(e)&&Array.isArray(t)?(_y(i,e.length,t.length),[...e,...t]):e&&t&&typeof e==`object`&&typeof t==`object`?yl(e,t):t;case`-=`:return typeof e==`number`&&typeof t==`number`?e-t:e;case`*=`:return typeof e==`number`&&typeof t==`number`?e*t:e;case`/=`:return typeof e==`number`&&typeof t==`number`?e/t:e;case`%=`:return typeof e==`number`&&typeof t==`number`?e%t:e;case`//=`:return e===null||e===!1?t:e;default:return t}}function o(t,n,r){switch(n.type){case`Identity`:return r(t);case`Field`:if(!fl(n.name))return t;if(n.base)return o(t,n.base,e=>{if(e&&typeof e==`object`&&!Array.isArray(e)){let t=vl(e),i=Object.hasOwn(t,n.name)?t[n.name]:void 0;return pl(t,n.name,r(i)),t}return e});if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t),i=Object.hasOwn(e,n.name)?e[n.name]:void 0;return pl(e,n.name,r(i)),e}return t;case`Index`:{let a=J(e,n.index,i)[0];if(typeof a==`number`&&Number.isNaN(a))throw Error(`Cannot set array element at NaN index`);if(typeof a==`number`&&!Number.isFinite(a))throw Error(`array index must be finite`);if(typeof a==`number`&&!Number.isInteger(a)&&(a=Math.trunc(a)),n.base)return o(t,n.base,e=>{if(typeof a==`number`&&Array.isArray(e)){let t=[...e],n=a<0?t.length+a:a;if(n>=0){_y(i,0,n+1),t.length<=n&&(t.length=n+1);for(let r=e.length;r<n;r++)t[r]=null;t[n]=r(t[n])}return t}if(typeof a==`string`&&e&&typeof e==`object`&&!Array.isArray(e)){if(!fl(a))return e;let t=vl(e),n=Object.hasOwn(t,a)?t[a]:void 0;return pl(t,a,r(n)),t}return e});if(typeof a==`number`){if(!Number.isSafeInteger(a)||a>536870911)throw Error(`Array index too large`);if(a<0&&(!t||!Array.isArray(t)))throw Error(`Out of bounds negative array index`);if(Array.isArray(t)){let e=[...t],n=a<0?e.length+a:a;if(n>=0){_y(i,0,n+1),e.length<=n&&(e.length=n+1);for(let r=t.length;r<n;r++)e[r]=null;e[n]=r(e[n])}return e}if(t==null){_y(i,0,a+1);let e=Array(a+1).fill(null);return e[a]=r(null),e}return t}if(typeof a==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(a))return t;let e=vl(t),n=Object.hasOwn(e,a)?e[a]:void 0;return pl(e,a,r(n)),e}return t}case`Iterate`:{let e=e=>{if(Array.isArray(e)){_y(i,0,e.length);let t=[];for(let n of e)gy(i),t.push(r(n));return t}if(e&&typeof e==`object`){let t=Object.create(null);for(let[n,i]of Object.entries(e))fl(n)&&pl(t,n,r(i));return t}return e};return n.base?o(t,n.base,e):e(t)}case`Pipe`:return o(o(t,n.left,e=>e),n.right,r);default:return r(t)}}return o(e,t,t=>n===`|=`?a(t,t):a(t,J(e,r,i)[0]??null))}function Ay(e,t,n){function r(t,i,a){switch(i.type){case`Identity`:return a;case`Field`:if(!fl(i.name))return t;if(i.base){let e=J(t,i.base,n)[0],o=r(e,{type:`Field`,name:i.name},a);return r(t,i.base,o)}if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t);return pl(e,i.name,a),e}return t;case`Index`:{if(i.base){let e=J(t,i.base,n)[0],o=r(e,{type:`Index`,index:i.index},a);return r(t,i.base,o)}let o=J(e,i.index,n)[0];if(typeof o==`number`&&Array.isArray(t)){let e=[...t],n=o<0?e.length+o:o;return n>=0&&n<e.length&&(e[n]=a),e}if(typeof o==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(o))return t;let e=vl(t);return pl(e,o,a),e}return t}default:return t}}function i(t,a){switch(a.type){case`Identity`:return null;case`Field`:if(!fl(a.name))return t;if(a.base){let e=J(t,a.base,n)[0];if(e==null)return t;let o=i(e,{type:`Field`,name:a.name});return r(t,a.base,o)}if(t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(a.name))return t;let e=vl(t);return delete e[a.name],e}return t;case`Index`:{if(a.base){let e=J(t,a.base,n)[0];if(e==null)return t;let o=i(e,{type:`Index`,index:a.index});return r(t,a.base,o)}let o=J(e,a.index,n)[0];if(typeof o==`number`&&Array.isArray(t)){let e=[...t],n=o<0?e.length+o:o;return n>=0&&n<e.length&&e.splice(n,1),e}if(typeof o==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(o))return t;let e=vl(t);return delete e[o],e}return t}case`Iterate`:return Array.isArray(t)?[]:t&&typeof t==`object`?Object.create(null):t;case`Pipe`:{let r=function(t,i,a){switch(i.type){case`Identity`:return a;case`Field`:if(!fl(i.name))return t;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t);return pl(e,i.name,a),e}return t;case`Index`:{let r=J(e,i.index,n)[0];if(typeof r==`number`&&Array.isArray(t)){let e=[...t],n=r<0?e.length+r:r;return n>=0&&n<e.length&&(e[n]=a),e}if(typeof r==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(r))return t;let e=vl(t);return pl(e,r,a),e}return t}case`Pipe`:{let e=J(t,i.left,n)[0],o=r(e,i.right,a);return r(t,i.left,o)}default:return t}},o=a.left,s=a.right,c=J(t,o,n)[0];return c==null?t:r(t,o,i(c,s))}default:return t}}return i(e,t)}function jy(e,t,n,r,i){if(t===`and`)return yy(i,J(e,n,i),t=>Cv(t)?yy(i,J(e,r,i),e=>[Cv(e)]):[!1]);if(t===`or`)return yy(i,J(e,n,i),t=>Cv(t)?[!0]:yy(i,J(e,r,i),e=>[Cv(e)]));if(t===`//`){let t=J(e,n,i).filter(e=>e!=null&&e!==!1);return t.length>0?t:J(e,r,i)}let a=J(e,n,i),o=J(e,r,i),s=a.length*o.length;return _y(i,0,s),gy(i,s),a.flatMap(e=>o.map(n=>{switch(t){case`+`:if(e===null)return n;if(n===null)return e;if(typeof e==`number`&&typeof n==`number`)return e+n;if(typeof e==`string`&&typeof n==`string`){let t=i.limits.maxStringLength;if(O(e)+O(n)>t)throw new A(`string size limit exceeded (${t} bytes)`,`string_length`);return e+n}return Array.isArray(e)&&Array.isArray(n)?(_y(i,e.length,n.length),[...e,...n]):e&&n&&typeof e==`object`&&typeof n==`object`&&!Array.isArray(e)&&!Array.isArray(n)?yl(e,n):null;case`-`:if(typeof e==`number`&&typeof n==`number`)return e-n;if(Array.isArray(e)&&Array.isArray(n)){let t=new Set(n.map(e=>JSON.stringify(e)));return e.filter(e=>!t.has(JSON.stringify(e)))}if(typeof e==`string`&&typeof n==`string`){let t=e=>e.length>10?`"${e.slice(0,10)}...`:JSON.stringify(e);throw Error(`string (${t(e)}) and string (${t(n)}) cannot be subtracted`)}return null;case`*`:if(typeof e==`number`&&typeof n==`number`)return e*n;if(typeof e==`string`&&typeof n==`number`){if(!Number.isFinite(n))throw Error(`invalid string repetition count: ${n}`);let t=Math.trunc(n);if(t<0)return null;let r=O(e),a=i.limits.maxStringLength;if(r>0&&t>Math.floor(a/r))throw new A(`string size limit exceeded (${a} bytes)`,`string_length`);return e.repeat(t)}{let t=gl(e),r=gl(n);if(t&&r)return Ev(t,r,{maxDepth:i.limits.maxDepth,visit:()=>gy(i)})}return null;case`/`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided because the divisor is zero`);return e/n}return typeof e==`string`&&typeof n==`string`?e.split(n):null;case`%`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(e)&&!Number.isNaN(e)?!Number.isFinite(n)&&!Number.isNaN(n)&&e<0&&n>0?-1:0:e%n}return null;case`==`:return wv(e,n);case`!=`:return!wv(e,n);case`<`:return Tv(e,n)<0;case`<=`:return Tv(e,n)<=0;case`>`:return Tv(e,n)>0;case`>=`:return Tv(e,n)>=0;default:return null}}))}function My(e,t,n,r){let i=zy.get(t);if(i)return typeof e==`number`?[i(e)]:[null];let a=Rv(e,t,n,r,J);if(a!==null)return a;let o=sy(e,t,n,r,J);if(o!==null)return o;let s=bv(e,t,n,r,J);if(s!==null)return s;let c=Nv(e,t,r.limits.maxDepth);if(c!==null)return c;let l=ly(e,t);if(l!==null)return l;let u=Jv(e,t,n,r,J);if(u!==null)return u;let d=mv(e,t,n,r,J,Ey,Ov,Cv,kv,A);if(d!==null)return d;let f=$v(e,t,n,r,J,Cv,fy,py,Ay,Ny);if(f!==null)return f;let p=Iv(e,t,n,r,J,wv);if(p!==null)return p;let m=gv(e,t,n,r,J,Ey,Cv,A);if(m!==null)return m;let h=Uv(e,t,n,r,J,Cv,Cy,My);if(h!==null)return h;let g=ty(e,t,n,r,J,wv);if(g!==null)return g;switch(t){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`.split(`.`)];case`error`:{let t=n.length>0?J(e,n[0],r)[0]:e;throw new Fy(t)}case`env`:return[r.env?rd(r.env):Object.create(null)];case`debug`:return[e];case`input_line_number`:return[1];default:{let i=`${t}/${n.length}`,a=r.funcs?.get(i);if(a){let t=a.closure??r.funcs??new Map,o=new Map(t);o.set(i,a);for(let t=0;t<a.params.length;t++){let i=a.params[t],s=n[t];if(s){let t=J(e,s,r),n;if(t.length===0)n={type:`Call`,name:`empty`,args:[]};else if(t.length===1)n={type:`Literal`,value:t[0]};else{n={type:`Literal`,value:t[t.length-1]};for(let e=t.length-2;e>=0;e--)n={type:`Comma`,left:{type:`Literal`,value:t[e]},right:n}}o.set(`${i}/0`,{params:[],body:n})}}let s={...r,funcs:o};return J(e,a.body,s)}throw Error(`Unknown function: ${t}`)}}}function Ny(e,t,n,r,i){if(gy(n),r.length>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);let a=e=>{if(e.length>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);_y(n,i.length),i.push(e)};if(t.type===`Comma`){let a=t;Ny(e,a.left,n,r,i),Ny(e,a.right,n,r,i);return}let o=wy(t);if(o!==null){a([...r,...o]);return}if(t.type===`Iterate`){if(Array.isArray(e))for(let t=0;t<e.length;t++)gy(n),a([...r,t]);else if(e&&typeof e==`object`)for(let t of Object.keys(e))gy(n),a([...r,t]);return}if(t.type===`Recurse`){let t=[{value:e,path:[]}];for(;t.length>0;){let e=t.pop();if(!e)break;if(gy(n),a([...r,...e.path]),e.value&&typeof e.value==`object`){let r=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);_y(n,0,t.length+r.length);for(let n=r.length-1;n>=0;n--){let[i,a]=r[n];t.push({value:a,path:[...e.path,i]})}}}return}if(t.type===`Pipe`){let a=wy(t.left);if(a!==null){let o=J(e,t.left,n);for(let e of o)Ny(e,t.right,n,[...r,...a],i);return}}J(e,t,n).length>0&&a(r)}var Py,Fy,Iy,Ly,Ry,zy,By=T(()=>{Wi(),od(),j(),Su(),Lr(),dy(),my(),xl(),Av(),Py=class e extends Error{label;partialResults;constructor(e,t=[]){super(`break ${e}`),this.label=e,this.partialResults=t,this.name=`BreakError`}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},Fy=class extends Error{value;constructor(e){super(typeof e==`string`?e:JSON.stringify(e)),this.value=e,this.name=`JqError`}},Iy=1e4,Ly=10485760,Ry=2e3,zy=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 Vy(e){let t=[],n=0,r=(t=0)=>e[n+t],i=()=>e[n++],a=()=>n>=e.length,o=e=>e>=`0`&&e<=`9`,s=e=>e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`,c=e=>s(e)||o(e);for(;!a();){let l=n,u=i();if(u!==` `&&u!==` `&&u!==`
642
+ `,exitCode:127}}}},uv={name:`bash`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`},dv={name:`sh`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`}});function pv(e,t,n=1){let r=e.limits.maxArrayElements;if(n<0||t>r-n)throw new A(`query result element limit exceeded (${r})`,`array_elements`)}function mv(e,t,n,r,i,a,o,s,c,l){switch(t){case`sort`:return Array.isArray(e)?[[...e].sort(o)]:[null];case`sort_by`:return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)})];case`bsearch`:if(!Array.isArray(e))throw Error(`${e===null?`null`:typeof e==`object`?`object`:typeof e} (${JSON.stringify(e)}) cannot be searched from`);return n.length===0?[null]:i(e,n[0],r).map(t=>{let n=0,r=e.length;for(;n<r;){let i=n+r>>>1;o(e[i],t)<0?n=i+1:r=i}return n<e.length&&o(e[n],t)===0?n:-n-1});case`unique_by`:{if(!Array.isArray(e)||n.length===0)return[null];let t=new Map;for(let a of e){let e=i(a,n[0],r)[0],o=JSON.stringify(e);t.has(o)||t.set(o,{item:a,key:e})}let a=[...t.values()];return a.sort((e,t)=>o(e.key,t.key)),[a.map(e=>e.item)]}case`group_by`:{if(!Array.isArray(e)||n.length===0)return[null];let t=new Map;for(let a of e){let e=JSON.stringify(i(a,n[0],r)[0]);t.has(e)||t.set(e,[]),t.get(e)?.push(a)}return[[...t.values()]]}case`max`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)>0?e:t)]:[null];case`max_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)>0?e:t})];case`min`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)<0?e:t)]:[null];case`min_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)<0?e:t})];case`add`:{let t=e=>{let t=e.filter(e=>e!==null);return t.length===0?null:t.every(e=>typeof e==`number`)?t.reduce((e,t)=>e+t,0):t.every(e=>typeof e==`string`)?t.join(``):t.every(e=>Array.isArray(e))?t.flat():t.every(e=>e&&typeof e==`object`&&!Array.isArray(e))?ad(...t):null};return n.length>=1?[t(i(e,n[0],r))]:Array.isArray(e)?[t(e)]:[null]}case`any`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(i(e,n[1],r).some(s))return[!0]}catch(e){if(e instanceof l)throw e}return[!1]}return n.length===1?Array.isArray(e)?[e.some(e=>s(i(e,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(s)]:[!1];case`all`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(!i(e,n[1],r).some(s))return[!1]}catch(e){if(e instanceof l)throw e}return[!0]}return n.length===1?Array.isArray(e)?[e.every(e=>s(i(e,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(s)]:[!0];case`select`:return n.length===0||i(e,n[0],r).some(s)?[e]:[];case`map`:{if(n.length===0||!Array.isArray(e))return[null];pv(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);pv(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}case`map_values`:if(n.length===0)return[null];if(Array.isArray(e)){pv(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);pv(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}if(e&&typeof e==`object`){let t=Object.create(null),a=Object.keys(e);pv(r,0,a.length);for(let o of a){if(!fl(o))continue;let a=e[o],s=i(a,n[0],r);s.length>0&&pl(t,o,s[0])}return[t]}return[null];case`has`:{if(n.length===0)return[!1];let t=i(e,n[0],r)[0];return Array.isArray(e)&&typeof t==`number`?[t>=0&&t<e.length]:e&&typeof e==`object`&&typeof t==`string`?[Object.hasOwn(e,t)]:[!1]}case`in`:{if(n.length===0)return[!1];let t=i(e,n[0],r)[0];return Array.isArray(t)&&typeof e==`number`?[e>=0&&e<t.length]:t&&typeof t==`object`&&typeof e==`string`?[Object.hasOwn(t,e)]:[!1]}case`contains`:return n.length===0?[!1]:[c(e,i(e,n[0],r)[0])];case`inside`:return n.length===0?[!1]:[c(i(e,n[0],r)[0],e)];default:return null}}var hv=T(()=>{od(),j(),xl()});function gv(e,t,n,r,i,a,o,s){switch(t){case`first`:if(n.length>0)try{let t=a(e,n[0],r);return t.length>0?[t[0]]:[]}catch(e){if(e instanceof s)throw e;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case`last`:if(n.length>0){let t=i(e,n[0],r);return t.length>0?[t[t.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case`nth`:{if(n.length<1)return[null];let t=i(e,n[0],r);if(n.length>1){for(let e of t)if(e<0)throw Error(`nth doesn't support negative indices`);let i;try{i=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;i=[]}return t.flatMap(e=>{let t=e;return t<i.length?[i[t]]:[]})}return Array.isArray(e)?t.flatMap(t=>{let n=t;if(n<0)throw Error(`nth doesn't support negative indices`);return n<e.length?[e[n]]:[null]}):[null]}case`range`:{if(n.length===0)return[];let t=r.limits.maxArrayElements,a=(e,n)=>{if(e.length>=t)throw new s(`query result element limit exceeded (${t})`,`array_elements`);e.push(n)},o=i(e,n[0],r);if(n.length===1){let e=[];for(let t of o){let n=t;for(let t=0;t<n;t++)a(e,t)}return e}let c=i(e,n[1],r);if(n.length===2){let e=[];for(let t of o)for(let n of c){let r=t,i=n;for(let t=r;t<i;t++)a(e,t)}return e}let l=i(e,n[2],r),u=[];for(let e of o)for(let t of c)for(let n of l){let r=e,i=t,o=n;if(o!==0){if(o>0)for(let e=r;e<i;e+=o)a(u,e);else for(let e=r;e>i;e+=o)a(u,e)}}return u}case`limit`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let i=t;if(i<0)throw Error(`limit doesn't support negative count`);if(i===0)return[];let o;try{o=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;o=[]}return o.slice(0,i)});case`isempty`:if(n.length<1)return[!0];try{return[a(e,n[0],r).length===0]}catch(e){if(e instanceof s)throw e;return[!0]}case`isvalid`:if(n.length<1)return[!0];try{return[i(e,n[0],r).length>0]}catch(e){if(e instanceof s)throw e;return[!1]}case`skip`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let a=t;if(a<0)throw Error(`skip doesn't support negative count`);return i(e,n[1],r).slice(a)});case`until`:{if(n.length<2)return[e];let t=e,a=r.limits.maxIterations;for(let e=0;e<a;e++){if(i(t,n[0],r).some(o))return[t];let e=i(t,n[1],r);if(e.length===0)return[t];t=e[0]}throw new s(`jq until: too many iterations (${a}), increase executionLimits.maxJqIterations`,`iterations`)}case`while`:{if(n.length<2)return[e];let t=[],a=e,c=r.limits.maxIterations;for(let e=0;e<c&&i(a,n[0],r).some(o);e++){t.push(a);let e=i(a,n[1],r);if(e.length===0)break;a=e[0]}if(t.length>=c)throw new s(`jq while: too many iterations (${c}), increase executionLimits.maxJqIterations`,`iterations`);return t}case`repeat`:{if(n.length===0)return[e];let t=[],a=e,o=r.limits.maxIterations;for(let e=0;e<o;e++){t.push(a);let e=i(a,n[0],r);if(e.length===0)break;a=e[0]}if(t.length>=o)throw new s(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,`iterations`);return t}default:return null}}var _v=T(()=>{});function vv(e,t){if(!Number.isFinite(e)||Math.abs(e)>864e10)throw Error(`${t} timestamp is outside the supported range`);return new Date(e*1e3)}function yv(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(!t)return null;let[,n,r,i,a,o,s]=t.map(Number),c=Date.UTC(n,r-1,i,a,o,s);if(!Number.isFinite(c))return null;let l=new Date(c);return l.getUTCFullYear()!==n||l.getUTCMonth()!==r-1||l.getUTCDate()!==i||l.getUTCHours()!==a||l.getUTCMinutes()!==o||l.getUTCSeconds()!==s?null:l}function bv(e,t,n,r,i){switch(t){case`now`:return[Date.now()/1e3];case`gmtime`:{if(typeof e!=`number`)return[null];let t=vv(e,`gmtime`),n=t.getUTCFullYear(),r=t.getUTCMonth(),i=t.getUTCDate(),a=t.getUTCHours(),o=t.getUTCMinutes(),s=t.getUTCSeconds(),c=t.getUTCDay(),l=Date.UTC(n,0,1);return[[n,r,i,a,o,s,c,Math.floor((t.getTime()-l)/864e5)]]}case`mktime`:{if(!Array.isArray(e))throw Error(`mktime requires parsed datetime inputs`);let[t,n,r,i=0,a=0,o=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`mktime requires parsed datetime inputs`);return[Math.floor(Date.UTC(t,n,r??1,i??0,a??0,o??0)/1e3)]}case`strftime`:{if(n.length===0)return[null];let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strftime/1 requires a string format`);let a;if(typeof e==`number`)a=vv(e,`strftime`);else if(Array.isArray(e)){let[t,n,r,i=0,o=0,s=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`strftime/1 requires parsed datetime inputs`);a=new Date(Date.UTC(t,n,r??1,i??0,o??0,s??0))}else throw Error(`strftime/1 requires parsed datetime inputs`);let o=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],s=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],c=(e,t=2)=>String(e).padStart(t,`0`);return[t.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,c(a.getUTCMonth()+1)).replace(/%d/g,c(a.getUTCDate())).replace(/%H/g,c(a.getUTCHours())).replace(/%M/g,c(a.getUTCMinutes())).replace(/%S/g,c(a.getUTCSeconds())).replace(/%A/g,o[a.getUTCDay()]).replace(/%B/g,s[a.getUTCMonth()]).replace(/%Z/g,`UTC`).replace(/%%/g,`%`)]}case`strptime`:{if(n.length===0)return[null];if(typeof e!=`string`)throw Error(`strptime/1 requires a string input`);let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strptime/1 requires a string format`);if(t!==xv)throw Error(`strptime format is not supported: ${t}`);let a=yv(e);if(a){let e=a.getUTCFullYear(),t=a.getUTCMonth(),n=a.getUTCDate(),r=a.getUTCHours(),i=a.getUTCMinutes(),o=a.getUTCSeconds(),s=a.getUTCDay(),c=Date.UTC(e,0,1);return[[e,t,n,r,i,o,s,Math.floor((a.getTime()-c)/864e5)]]}throw Error(`Cannot parse date: ${e}`)}case`fromdate`:{if(typeof e!=`string`)throw Error(`fromdate requires a string input`);let t=yv(e);if(!t)throw Error(`date "${e}" does not match format "${xv}"`);return[Math.floor(t.getTime()/1e3)]}case`todate`:if(typeof e!=`number`)throw Error(`todate requires a number input`);return[vv(e,`todate`).toISOString().replace(/\.\d{3}Z$/,`Z`)];default:return null}}var xv,Sv=T(()=>{xv=`%Y-%m-%dT%H:%M:%SZ`});function Cv(e){return e!==!1&&e!==null}function wv(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Tv(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`string`&&typeof t==`string`?e.localeCompare(t):0}function Ev(e,t,n={}){let r=n.maxDepth??2e3,i=vl(e),a=[{target:i,source:t,depth:0}];for(;a.length>0;){let e=a.pop();if(!e)break;if(e.depth>r)throw new A(`query depth limit exceeded (${r})`,`recursion`);for(let t of Object.keys(e.source)){if(n.visit?.(),!fl(t))continue;let r=ml(e.target,t)?gl(e.target[t]):null,i=gl(e.source[t]);if(r&&i){let n=vl(r);pl(e.target,t,n),a.push({target:n,source:i,depth:e.depth+1})}else pl(e.target,t,e.source[t])}}return i}function Dv(e,t=3e3){if(typeof e!=`object`||!e)return 0;if(t<=1)return t;let n=(e,t)=>({value:e,keys:Array.isArray(e)?void 0:Object.keys(e),nextChild:0,pathDepth:t,maxChildDepth:0}),r=e=>e.keys===void 0?e.value.length:e.keys.length,i=e=>{if(e.keys){let t=e.keys[e.nextChild++];return e.value[t]}return e.value[e.nextChild++]},a=new WeakMap,o=new WeakMap,s=e,c=[n(s,1)];for(a.set(s,`visiting`);c.length>0;){let e=c[c.length-1];if(e.nextChild<r(e)){let r=i(e);if(typeof r!=`object`||!r)continue;let s=a.get(r);if(s===`visiting`)return t;if(s===`done`){let n=o.get(r)??0;if(e.pathDepth+n>=t)return t;e.maxChildDepth=Math.max(e.maxChildDepth,n);continue}let l=e.pathDepth+1;if(l>=t)return t;let u=r;a.set(r,`visiting`),c.push(n(u,l));continue}let s=e.maxChildDepth+1;o.set(e.value,s),a.set(e.value,`done`),c.pop();let l=c.at(-1);if(l)l.maxChildDepth=Math.max(l.maxChildDepth,s);else return s}return 0}function Ov(e,t){let n=e=>e===null?0:typeof e==`boolean`?1:typeof e==`number`?2:typeof e==`string`?3:Array.isArray(e)?4:typeof e==`object`?5:6,r=n(e),i=n(t);if(r!==i)return r-i;if(typeof e==`number`&&typeof t==`number`)return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);if(typeof e==`boolean`&&typeof t==`boolean`)return!!e-+!!t;if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<Math.min(e.length,t.length);n++){let r=Ov(e[n],t[n]);if(r!==0)return r}return e.length-t.length}let a=gl(e),o=gl(t);if(a&&o){let e=Object.keys(a).sort(),t=Object.keys(o).sort();for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n].localeCompare(t[n]);if(r!==0)return r}if(e.length!==t.length)return e.length-t.length;for(let t of e){let e=Ov(a[t],o[t]);if(e!==0)return e}}return 0}function kv(e,t){if(wv(e,t))return!0;if(typeof e==`string`&&typeof t==`string`)return e.includes(t);if(Array.isArray(e)&&Array.isArray(t))return t.every(t=>e.some(e=>kv(e,t)));let n=gl(e),r=gl(t);return n&&r?Object.keys(r).every(e=>ml(n,e)&&kv(n[e],r[e])):!1}var Av=T(()=>{j(),xl()});function jv(e){let t=[];for(let n=0;n<e.length;n+=32768){let r=Math.min(n+32768,e.length),i=``;for(let t=n;t<r;t++)i+=String.fromCharCode(e[t]);t.push(i)}return t.join(``)}function Mv(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function Nv(e,t,n){switch(t){case`@base64`:if(typeof e==`string`){if(typeof Buffer<`u`)return[Buffer.from(e,`utf-8`).toString(`base64`)];let t=new TextEncoder().encode(e);return[btoa(jv(t))]}return[null];case`@base64d`:if(typeof e==`string`){if(typeof Buffer<`u`)return[Buffer.from(e,`base64`).toString(`utf-8`)];let t=Mv(atob(e));return[new TextDecoder(`utf-8`,{fatal:!1}).decode(t)]}return[null];case`@uri`:return typeof e==`string`?[encodeURIComponent(e).replace(/!/g,`%21`).replace(/'/g,`%27`).replace(/\(/g,`%28`).replace(/\)/g,`%29`).replace(/\*/g,`%2A`)]:[null];case`@urid`:return typeof e==`string`?[decodeURIComponent(e)]:[null];case`@csv`:return Array.isArray(e)?[e.map(e=>{if(e===null)return``;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return String(e);let t=String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
643
+ `)||t.includes(`\r`)?`"${t.replace(/"/g,`""`)}"`:t}).join(`,`)]:[null];case`@tsv`:return Array.isArray(e)?[e.map(e=>String(e??``).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`)).join(` `)]:[null];case`@json`:{let t=n??Pv;return Dv(e,t+1)>t?[null]:[JSON.stringify(e)]}case`@html`:return typeof e==`string`?[e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/'/g,`&apos;`).replace(/"/g,`&quot;`)]:[null];case`@sh`:return typeof e==`string`?[`'${e.replace(/'/g,`'\\''`)}'`]:[null];case`@text`:return typeof e==`string`?[e]:e==null?[``]:[String(e)];default:return null}}var Pv,Fv=T(()=>{Av(),Pv=2e3});function Iv(e,t,n,r,i,a){switch(t){case`index`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){if(t===``&&e===``)return null;let n=e.indexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=0;n<=e.length-t.length;n++){let r=!0;for(let i=0;i<t.length;i++)if(!a(e[n+i],t[i])){r=!1;break}if(r)return n}return null}let n=e.findIndex(e=>a(e,t));return n>=0?n:null}return null});case`rindex`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){let n=e.lastIndexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=e.length-t.length;n>=0;n--){let r=!0;for(let i=0;i<t.length;i++)if(!a(e[n+i],t[i])){r=!1;break}if(r)return n}return null}for(let n=e.length-1;n>=0;n--)if(a(e[n],t))return n;return null}return null});case`indices`:return n.length===0?[[]]:i(e,n[0],r).map(t=>{let n=[];if(typeof e==`string`&&typeof t==`string`){let r=e.indexOf(t);for(;r!==-1;)n.push(r),r=e.indexOf(t,r+1)}else if(Array.isArray(e)){if(Array.isArray(t)){let r=t.length;if(r===0)for(let t=0;t<=e.length;t++)n.push(t);else for(let i=0;i<=e.length-r;i++){let o=!0;for(let n=0;n<r;n++)if(!a(e[i+n],t[n])){o=!1;break}o&&n.push(i)}}else for(let r=0;r<e.length;r++)a(e[r],t)&&n.push(r)}return n});default:return null}}var Lv=T(()=>{});function Rv(e,t,n,r,i){switch(t){case`fabs`:case`abs`:return typeof e==`number`?[Math.abs(e)]:typeof e==`string`?[e]:[null];case`exp10`:return typeof e==`number`?[10**e]:[null];case`exp2`:return typeof e==`number`?[2**e]:[null];case`pow`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[o**s]}case`atan2`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[Math.atan2(o,s)]}case`hypot`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.hypot(e,t)]}case`fma`:{if(typeof e!=`number`||n.length<2)return[null];let t=i(e,n[0],r)[0],a=i(e,n[1],r)[0];return[e*t+a]}case`copysign`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.sign(t)*Math.abs(e)]}case`drem`:case`remainder`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[e-Math.round(e/t)*t]}case`fdim`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(0,e-t)]}case`fmax`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(e,t)]}case`fmin`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.min(e,t)]}case`ldexp`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`scalbn`:case`scalbln`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`nearbyint`:return typeof e==`number`?[Math.round(e)]:[null];case`logb`:return typeof e==`number`?[Math.floor(Math.log2(Math.abs(e)))]:[null];case`significand`:return typeof e==`number`?[e/2**Math.floor(Math.log2(Math.abs(e)))]:[null];case`frexp`:if(typeof e==`number`){if(e===0)return[[0,0]];let t=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**t,t]]}return[null];case`modf`:if(typeof e==`number`){let t=Math.trunc(e);return[[e-t,t]]}return[null];default:return null}}var zv=T(()=>{});function Bv(e){let t=e.limits.maxIterations;return{maxDepth:e.limits.maxDepth,maxResults:e.limits.maxArrayElements,maxIterations:t}}function Vv(e){throw new A(e,`array_elements`)}function Hv(e,t){let n=1;for(let r of e){if(!Number.isSafeInteger(r)||r<0)throw Error(`combinations requires finite array lengths`);r!==0&&n>Math.floor(t/r)&&Vv(`query combination limit exceeded (${t})`),n*=r}return n}function Uv(e,t,n,r,i,a,o,s){switch(t){case`recurse`:{let t=[],o=Bv(r),s=n.length>=2?n[1]:null,c=[{value:e,depth:0}],l=0;for(;c.length>0;){let e=c.pop();if(!e)break;if(++l>o.maxIterations)throw new A(`query iteration limit exceeded (${o.maxIterations})`,`iterations`);if(e.depth>o.maxDepth)throw new A(`query depth limit exceeded (${o.maxDepth})`,`recursion`);if(s&&!i(e.value,s,r).some(a))continue;t.length>=o.maxResults&&Vv(`query result element limit exceeded (${o.maxResults})`),t.push(e.value);let u=[];n.length===0?Array.isArray(e.value)?u=e.value:e.value&&typeof e.value==`object`&&(u=Object.keys(e.value).map(t=>e.value[t])):u=i(e.value,n[0],r).filter(e=>e!=null),c.length>o.maxResults-u.length&&Vv(`query traversal queue limit exceeded (${o.maxResults})`);for(let t=u.length-1;t>=0;t--)c.push({value:u[t],depth:e.depth+1})}return t}case`recurse_down`:return s(e,`recurse`,n,r);case`walk`:{if(n.length===0)return[e];let t=Bv(r),a=new WeakSet,o=new WeakMap,s=[{value:e,depth:0,expanded:!1}],c=e,l=0;for(;s.length>0;){let e=s.pop();if(!e)break;if(++l>t.maxIterations)throw new A(`query iteration limit exceeded (${t.maxIterations})`,`iterations`);if(e.depth>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let u=e.value!==null&&typeof e.value==`object`?e.value:null;if(!e.expanded&&u){if(a.has(u))continue;a.add(u),s.push({...e,expanded:!0});let n=gl(e.value),r=Array.isArray(e.value)?e.value:Object.keys(n??{}).map(e=>n?.[e]);s.length>t.maxResults-r.length&&Vv(`query traversal queue limit exceeded (${t.maxResults})`);for(let t=r.length-1;t>=0;t--)s.push({value:r[t],depth:e.depth+1,expanded:!1});continue}let d=e.value;if(Array.isArray(e.value))d=e.value.map(e=>typeof e==`object`&&e?o.get(e)??e:e);else if(u){let t=Object.create(null),n=gl(e.value);for(let e of Object.keys(n??{})){if(!fl(e))continue;let r=n?.[e];pl(t,e,typeof r==`object`&&r?o.get(r)??r:r)}d=t}let f=i(d,n[0],r)[0];u&&o.set(u,f),e.depth===0&&(c=f)}return[c]}case`transpose`:{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let t=Bv(r),n=0;for(let t of e)Array.isArray(t)&&(n=Math.max(n,t.length));Hv([e.length,n],t.maxResults);let i=[];for(let t=0;t<n;t++)i.push(e.map(e=>Array.isArray(e)?e[t]:null));return[i]}case`combinations`:{if(n.length>0){let t=i(e,n[0],r)[0];if(!Array.isArray(e))return[];if(!Number.isFinite(t)||!Number.isSafeInteger(t)||t<0)throw Error(`combinations length must be a finite non-negative integer`);let a=Bv(r);if(t>a.maxDepth||t>a.maxResults)throw new A(`query depth limit exceeded (${a.maxDepth})`,`recursion`);if(t===0)return a.maxResults<1&&Vv(`query combination limit exceeded (0)`),[[]];let o=Hv(Array.from({length:t},()=>e.length),a.maxResults);if(o===0)return[];let s=[],c=Array(t).fill(0);for(let n=0;n<o;n++){s.push(c.map(t=>e[t]));for(let n=t-1;n>=0&&(c[n]++,!(c[n]<e.length));n--)c[n]=0}return s}if(!Array.isArray(e))return[];if(e.length===0)return Bv(r).maxResults<1&&Vv(`query combination limit exceeded (0)`),[[]];for(let t of e)if(!Array.isArray(t))return[];let t=Bv(r),a=e;if(a.length>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let o=Hv(a.map(e=>e.length),t.maxResults);if(o===0)return[];let s=[],c=Array(a.length).fill(0);for(let e=0;e<o;e++){s.push(c.map((e,t)=>a[t][e]));for(let e=a.length-1;e>=0&&(c[e]++,!(c[e]<a[e].length));e--)c[e]=0}return s}case`parent`:{if(r.root===void 0||r.currentPath===void 0)return[];let t=r.currentPath;if(t.length===0)return[];let a=n.length>0?i(e,n[0],r)[0]:1;if(a>=0){if(a>t.length)return[];let e=t.slice(0,t.length-a);return[o(r.root,e)]}{let n=-a-1;if(n>=t.length)return[e];let i=t.slice(0,n);return[o(r.root,i)]}}case`parents`:{if(r.root===void 0||r.currentPath===void 0)return[[]];let e=r.currentPath,t=[];for(let n=e.length-1;n>=0;n--)t.push(o(r.root,e.slice(0,n)));return[t]}case`root`:return r.root===void 0?[]:[r.root];default:return null}}var Wv=T(()=>{j(),xl()});function Gv(e){return e.limits.maxArrayElements}function Kv(e,t){let n=Gv(e);if(t>=n)throw new A(`query result element limit exceeded (${n})`,`array_elements`)}function qv(e,t){let n=t.limits.maxDepth??Yv;if(e.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new A(`query array index limit exceeded (${r})`,`array_elements`)}else if(typeof t!=`string`)throw Error(`stream path components must be strings or integers`)}function Jv(e,t,n,r,i){switch(t){case`keys`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e).sort()]:[null];case`keys_unsorted`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e)]:[null];case`length`:return typeof e==`string`||Array.isArray(e)?[e.length]:e&&typeof e==`object`?[Object.keys(e).length]:e===null?[0]:typeof e==`number`?[Math.abs(e)]:[null];case`utf8bytelength`:{if(typeof e==`string`)return[O(e)];let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) only strings have UTF-8 byte length`)}case`to_entries`:{let t=gl(e);if(t){let e=Object.keys(t);if(e.length>Gv(r))throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);return[e.map(e=>{let n=Object.create(null);return pl(n,`key`,e),pl(n,`value`,t[e]),n})]}return[null]}case`from_entries`:if(Array.isArray(e)){let t=Object.create(null);for(let n of e){let e=gl(n);if(e){let n=e.key??e.Key??e.name??e.Name??e.k,r=e.value??e.Value??e.v;if(n!==void 0){let e=String(n);fl(e)&&pl(t,e,r)}}}return[t]}return[null];case`with_entries`:{if(n.length===0)return[e];let t=gl(e);if(t){let e=Object.keys(t);if(e.length>Gv(r))throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);let a=[];for(let o of e){let e=Object.create(null);pl(e,`key`,o),pl(e,`value`,t[o]);let s=i(e,n[0],r);if(a.length>Gv(r)-s.length)throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);for(let e of s)a.push(e)}let o=Object.create(null);for(let e of a){let t=gl(e);if(t){let e=t.key??t.name??t.k,n=t.value??t.v;if(e!==void 0){let t=String(e);fl(t)&&pl(o,t,n)}}}return[o]}return[null]}case`reverse`:return Array.isArray(e)?[[...e].reverse()]:typeof e==`string`?[e.split(``).reverse().join(``)]:[null];case`flatten`:return Array.isArray(e)?(n.length>0?i(e,n[0],r):[1/0]).map(t=>{let n=t;if(n<0)throw Error(`flatten depth must not be negative`);return e.flat(n)}):[null];case`unique`:if(Array.isArray(e)){let t=new Set,n=[];for(let r of e){let e=JSON.stringify(r);t.has(e)||(t.add(e),n.push(r))}return[n]}return[null];case`tojson`:case`tojsonstream`:{let t=r.limits.maxDepth??Yv;return Dv(e,t+1)>t?[null]:[JSON.stringify(e)]}case`fromjson`:if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`nan`)return[NaN];if(t===`inf`||t===`infinity`)return[1/0];if(t===`-inf`||t===`-infinity`)return[-1/0];try{return[hl(JSON.parse(e),{maxDepth:r.limits.maxDepth,maxElements:r.limits.maxArrayElements})]}catch(t){throw t instanceof A?t:Error(`Invalid JSON: ${e}`)}}return[e];case`tostring`:return typeof e==`string`?[e]:[JSON.stringify(e)];case`tonumber`:if(typeof e==`number`)return[e];if(typeof e==`string`){let t=Number(e);if(Number.isNaN(t))throw Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[t]}throw Error(`${typeof e} cannot be parsed as a number`);case`toboolean`:{if(typeof e==`boolean`)return[e];if(typeof e==`string`){if(e===`true`)return[!0];if(e===`false`)return[!1];throw Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) cannot be parsed as a boolean`)}case`tostream`:{let t=[],n=r.limits.maxDepth??Yv,i=[{value:e,path:[]}],a=new WeakSet,o=0;for(;i.length>0;){let e=i.pop();if(!e)break;if(++o>r.limits.maxIterations)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);if(e.path.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let s=e.value;if(typeof s!=`object`||!s)Kv(r,t.length),t.push([e.path,s]);else if(Array.isArray(s)){if(a.has(s))throw new A(`cyclic value cannot be converted to a stream`,`recursion`);if(a.add(s),s.length===0)Kv(r,t.length),t.push([e.path,[]]);else{if(i.length>Gv(r)-s.length)throw new A(`query traversal queue limit exceeded (${Gv(r)})`,`array_elements`);for(let t=s.length-1;t>=0;t--)i.push({value:s[t],path:[...e.path,t]})}}else{if(a.has(s))throw new A(`cyclic value cannot be converted to a stream`,`recursion`);a.add(s);let n=Object.keys(s);if(n.length===0)Kv(r,t.length),t.push([e.path,Object.create(null)]);else{if(i.length>Gv(r)-n.length)throw new A(`query traversal queue limit exceeded (${Gv(r)})`,`array_elements`);for(let t=n.length-1;t>=0;t--){let r=n[t];i.push({value:s[r],path:[...e.path,r]})}}}}return Kv(r,t.length),t.push([[]]),t}case`fromstream`:{if(n.length===0)return[e];let t=i(e,n[0],r);if(t.length>Gv(r))throw new A(`query stream item limit exceeded (${Gv(r)})`,`array_elements`);let a=null,o=0;for(let e of t){if(!Array.isArray(e)||e.length===1&&Array.isArray(e[0])&&e[0].length===0||e.length!==2)continue;let[t,n]=e;if(!Array.isArray(t))continue;if(qv(t,r),t.length===0){a=n;continue}a===null&&(a=typeof t[0]==`number`?[]:Object.create(null));let i=a;for(let e=0;e<t.length-1;e++){let n=t[e],a=t[e+1];if(Array.isArray(i)&&typeof n==`number`){let e=n+1-i.length;if(e>r.limits.maxIterations-o)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=n;)i.push(null);i[n]===null&&(i[n]=typeof a==`number`?[]:Object.create(null)),i=i[n]}else{let e=gl(i);if(e){let t=String(n);if(!fl(t))continue;(e[t]===null||e[t]===void 0)&&pl(e,t,typeof a==`number`?[]:Object.create(null)),i=e[t]}}}let s=t[t.length-1];if(Array.isArray(i)&&typeof s==`number`){let e=s+1-i.length;if(e>r.limits.maxIterations-o)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=s;)i.push(null);i[s]=n}else{let e=gl(i);if(e){let t=String(s);fl(t)&&pl(e,t,n)}}}return[a]}case`truncate_stream`:{let t=typeof e==`number`?Math.floor(e):0;if(n.length===0)return[];let a=[],o=i(e,n[0],r);for(let e of o)if(Array.isArray(e)){if(e.length===1&&Array.isArray(e[0])){let n=e[0];n.length>t&&a.push([n.slice(t)]);continue}if(e.length===2&&Array.isArray(e[0])){let n=e[0],r=e[1];n.length>t&&a.push([n.slice(t),r])}}return a}default:return null}}var Yv,Xv=T(()=>{k(),j(),xl(),Av(),Yv=2e3});function Zv(e,t){if(!Array.isArray(e))throw Error(`path must be an array`);let n=t.limits.maxDepth;if(e.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements,i=0;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new A(`query array index limit exceeded (${r})`,`array_elements`);let e=t+1;if(i>r-e)throw new A(`query cumulative array allocation limit exceeded (${r})`,`array_elements`);i+=e}else if(typeof t!=`string`)throw Error(`path components must be strings or integers`);return gy(t,i+e.length),e}function Qv(e,t,n){let r=[],i=[{value:e,path:[],isRoot:!0}];for(;i.length>0;){let e=i.pop();if(!e)break;if(gy(t),e.path.length>t.limits.maxDepth)throw new A(`query depth limit exceeded (${t.limits.maxDepth})`,`recursion`);if(e.value===null||typeof e.value!=`object`){(n||!e.isRoot)&&(_y(t,r.length),r.push(e.path));continue}!n&&!e.isRoot&&(_y(t,r.length),r.push(e.path));let a=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);_y(t,r.length,i.length+a.length);for(let t=a.length-1;t>=0;t--){let[n,r]=a[t],o=[...e.path,n];i.push({value:r,path:o,isRoot:!1})}}return r}function $v(e,t,n,r,i,a,o,s,c,l){switch(t){case`getpath`:{if(n.length===0)return[null];let t=i(e,n[0],r),a=[];for(let n of t){let t=n,r=e;for(let e of t){if(r==null){r=null;break}if(Array.isArray(r)&&typeof e==`number`)r=r[e];else if(typeof e==`string`){let t=gl(r);if(!t||!Object.hasOwn(t,e)){r=null;break}r=t[e]}else{r=null;break}}a.push(r)}return a}case`setpath`:{if(n.length<2)return[null];let t=Zv(i(e,n[0],r)[0],r),a=i(e,n[1],r)[0];return[o(e,t,a)]}case`delpaths`:{if(n.length===0)return[e];let t=i(e,n[0],r)[0],a=e;for(let e of t.sort((e,t)=>t.length-e.length))a=s(a,e);return[a]}case`path`:{if(n.length===0)return[[]];let t=[];return l(e,n[0],r,[],t),t}case`del`:return n.length===0?[e]:[c(e,n[0],r)];case`pick`:{if(n.length===0)return[null];let t=[];for(let i of n)l(e,i,r,[],t);let i=null;for(let n of t){for(let e of n)if(typeof e==`number`&&e<0)throw Error(`Out of bounds negative array index`);Zv(n,r);let t=e;for(let e of n){if(t==null)break;if(Array.isArray(t)&&typeof e==`number`)t=t[e];else if(typeof e==`string`){let n=gl(t);if(!n||!Object.hasOwn(n,e)){t=null;break}t=n[e]}else{t=null;break}}i=o(i,n,t)}return[i]}case`paths`:{let t=Qv(e,r,!1);return n.length>0?t.filter(t=>{let o=e;for(let e of t)if(Array.isArray(o)&&typeof e==`number`)o=o[e];else if(typeof e==`string`){let t=gl(o);if(!t||!Object.hasOwn(t,e))return!1;o=t[e]}else return!1;return i(o,n[0],r).some(a)}):t}case`leaf_paths`:return Qv(e,r,!0);default:return null}}var ey=T(()=>{j(),By(),xl()});function ty(e,t,n,r,i,a){switch(t){case`IN`:{if(n.length===0)return[!1];if(n.length===1){let t=i(e,n[0],r);for(let n of t)if(a(e,n))return[!0];return[!1]}let t=i(e,n[0],r),o=i(e,n[1],r),s=new Set(o.map(e=>JSON.stringify(e)));for(let e of t)if(s.has(JSON.stringify(e)))return[!0];return[!1]}case`INDEX`:{if(n.length===0)return[Object.create(null)];if(n.length===1){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=String(e);fl(t)&&pl(a,t,e)}return[a]}if(n.length===2){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r);if(t.length>0){let n=String(t[0]);fl(n)&&pl(a,n,e)}}return[a]}let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r),o=i(e,n[2],r);if(t.length>0&&o.length>0){let e=String(t[0]);fl(e)&&pl(a,e,o[0])}}return[a]}case`JOIN`:{if(n.length<2)return[null];let t=gl(i(e,n[0],r)[0]);if(!t||!Array.isArray(e))return[null];let a=[];for(let o of e){let e=i(o,n[1],r),s=e.length>0?String(e[0]):``,c=ml(t,s)?t[s]:null;a.push([o,c])}return[a]}default:return null}}var ny=T(()=>{xl()});function ry(e){return e.limits.maxArrayElements}function iy(e){return Math.min(e.limits.maxStringLength,e.limits.maxOutputSize)}function ay(e,t){let n=ry(e);if(!Number.isSafeInteger(t)||t<0||t>n)throw new A(`query result element limit exceeded (${n})`,`array_elements`)}function oy(e,t,n){if(e===``)return t===``?0:1;if(t===``)return e.length;let r=1,i=0;for(;;){let a=e.indexOf(t,i);if(a<0||(r++,r>n))return r;i=a+t.length}}function sy(e,t,n,r,i){switch(t){case`join`:{if(!Array.isArray(e))return[null];let t=n.length>0?i(e,n[0],r):[``];for(let t of e)if(Array.isArray(t)||typeof t==`object`&&t)throw Error(`cannot join: contains arrays or objects`);return ay(r,t.length),t.map(t=>{let n=String(t),i=0;for(let t=0;t<e.length;t++){let a=e[t]===null?``:typeof e[t]==`string`?e[t]:String(e[t]);if(i+=O(a),t>0&&(i+=O(n)),i>iy(r))throw new A(`query string size limit exceeded (${iy(r)} bytes)`,`string_length`)}return e.map(e=>e===null?``:typeof e==`string`?e:String(e)).join(n)})}case`split`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);return ay(r,oy(e,a,ry(r))),[e.split(a)]}case`splits`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):`g`,o=U(a,t.includes(`g`)?t:`${t}g`),s=1;for(let t of o.matchAll(e))s+=Math.max(1,t.length),ay(r,s);let c=o.split(e);return ay(r,c.length),c}catch(e){if(e instanceof A)throw e;return[]}}case`scan`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):``,o=U(a,t.includes(`g`)?t:`${t}g`),s=[];for(let t of o.matchAll(e))ay(r,s.length+1),t.length>1?(ay(r,t.length-1),s.push(t.slice(1))):s.push(t[0]);return s}catch(e){if(e instanceof A)throw e;return[]}}case`test`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r),a=String(t[0]);try{return[U(a,n.length>1?String(i(e,n[1],r)[0]):``).test(e)]}catch{return[!1]}}case`match`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=U(a,`${n.length>1?String(i(e,n[1],r)[0]):``}d`).exec(e);if(!t)return[];let o=t.indices;return[{offset:t.index,length:t[0].length,string:t[0],captures:t.slice(1).map((e,t)=>({offset:o?.[t+1]?.[0]??null,length:e?.length??0,string:e??``,name:null}))}]}catch{return[null]}}case`capture`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=U(a,n.length>1?String(i(e,n[1],r)[0]):``).match(e);return!t||!t.groups?[Object.create(null)]:[t.groups]}catch{return[null]}}case`sub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{return[U(o,n.length>2?String(i(e,n[2],r)[0]):``).replace(e,s)]}catch{return[e]}}case`gsub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{let t=n.length>2?String(i(e,n[2],r)[0]):`g`;return[U(o,t.includes(`g`)?t:`${t}g`).replace(e,s)]}catch{return[e]}}case`ascii_downcase`:return typeof e==`string`?[e.replace(/[A-Z]/g,e=>String.fromCharCode(e.charCodeAt(0)+32))]:[null];case`ascii_upcase`:return typeof e==`string`?[e.replace(/[a-z]/g,e=>String.fromCharCode(e.charCodeAt(0)-32))]:[null];case`ltrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return[e.startsWith(a)?e.slice(a.length):e]}case`rtrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return a===``?[e]:[e.endsWith(a)?e.slice(0,-a.length):e]}case`trimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);if(a===``)return[e];let o=e;return o.startsWith(a)&&(o=o.slice(a.length)),o.endsWith(a)&&(o=o.slice(0,-a.length)),[o]}case`trim`:if(typeof e==`string`)return[e.trim()];throw Error(`trim input must be a string`);case`ltrim`:if(typeof e==`string`)return[e.trimStart()];throw Error(`trim input must be a string`);case`rtrim`:if(typeof e==`string`)return[e.trimEnd()];throw Error(`trim input must be a string`);case`startswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.startsWith(String(t[0]))]}case`endswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.endsWith(String(t[0]))]}case`ascii`:return typeof e==`string`&&e.length>0?[e.charCodeAt(0)]:[null];case`explode`:if(typeof e==`string`){let t=0;for(let n of e)t++,ay(r,t);return[Array.from(e).map(e=>e.codePointAt(0))]}return[null];case`implode`:if(!Array.isArray(e))throw Error(`implode input must be an array`);return[e.map(e=>{if(typeof e==`string`)throw Error(`string (${JSON.stringify(e)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof e!=`number`||Number.isNaN(e))throw Error(`number (null) can't be imploded, unicode codepoint needs to be numeric`);let t=Math.trunc(e);return t<0||t>1114111||t>=55296&&t<=57343?String.fromCodePoint(65533):String.fromCodePoint(t)}).join(``)];default:return null}}var cy=T(()=>{j(),mc(),Lr()});function ly(e,t){switch(t){case`type`:return e===null?[`null`]:Array.isArray(e)?[`array`]:typeof e==`boolean`?[`boolean`]:typeof e==`number`?[`number`]:typeof e==`string`?[`string`]:typeof e==`object`?[`object`]:[`null`];case`infinite`:return[1/0];case`nan`:return[NaN];case`isinfinite`:return[typeof e==`number`&&!Number.isFinite(e)];case`isnan`:return[typeof e==`number`&&Number.isNaN(e)];case`isnormal`:return[typeof e==`number`&&Number.isFinite(e)&&e!==0];case`isfinite`:return[typeof e==`number`&&Number.isFinite(e)];case`numbers`:return typeof e==`number`?[e]:[];case`strings`:return typeof e==`string`?[e]:[];case`booleans`:return typeof e==`boolean`?[e]:[];case`nulls`:return e===null?[e]:[];case`arrays`:return Array.isArray(e)?[e]:[];case`objects`:return e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`iterables`:return Array.isArray(e)||e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`scalars`:return!Array.isArray(e)&&!(e&&typeof e==`object`)?[e]:[];case`values`:return e===null?[]:[e];case`not`:return e===!1||e===null?[!0]:[!1];case`null`:return[null];case`true`:return[!0];case`false`:return[!1];case`empty`:return[];default:return null}}var uy=T(()=>{}),dy=T(()=>{hv(),_v(),Sv(),Fv(),Lv(),zv(),Wv(),Xv(),ey(),ny(),cy(),uy()});function fy(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(typeof r==`number`){if(e&&typeof e==`object`&&!Array.isArray(e))throw Error(`Cannot index object with number`);if(r>536870911)throw Error(`Array index too large`);if(r<0)throw Error(`Out of bounds negative array index`);let t=Array.isArray(e)?[...e]:[];for(;t.length<=r;)t.push(null);return t[r]=fy(t[r],i,n),t}if(Array.isArray(e))throw Error(`Cannot index array with string`);if(!fl(r))return e??Object.create(null);let a=gl(e),o=a?vl(a):Object.create(null);return pl(o,r,fy(Object.hasOwn(o,r)?o[r]:void 0,i,n)),o}function py(e,t){if(t.length===0)return null;if(t.length===1){let n=t[0];if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t.splice(n,1),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!fl(t))return e;let r=vl(e);return delete r[t],r}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t[n]=py(t[n],r),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!fl(t))return e;let i=vl(e);return Object.hasOwn(i,t)&&pl(i,t,py(i[t],r)),i}return e}var my=T(()=>{xl()});function hy(e,t){return new A(e,t)}function gy(e,t=1){if(!Number.isSafeInteger(t)||t<0||e.budget.operations>e.limits.maxIterations-t)throw hy(`query evaluation: too many iterations (${e.limits.maxIterations})`,`iterations`);e.budget.operations+=t}function _y(e,t,n=1){let r=e.limits.maxArrayElements;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0||t>r-n)throw hy(`query result element limit exceeded (${r})`,`array_elements`)}function vy(e,t,n){_y(e,t.length,n.length);for(let e of n)t.push(e)}function yy(e,t,n){let r=[];for(let i of t)gy(e),vy(e,r,n(i));return r}function by(e){let t=new Map;if(e?.namedArgs)for(let[n,r]of e.namedArgs)t.set(`$${n}`,r);return{vars:t,limits:{maxIterations:e?.limits?.maxIterations??Iy,maxDepth:e?.limits?.maxDepth??Ry,maxStringLength:e?.limits?.maxStringLength??Ly,maxOutputSize:e?.limits?.maxOutputSize??Ly,maxArrayElements:e?.limits?.maxArrayElements??1e5},env:e?.env,namedArgs:e?.namedArgs,positionalArgs:e?.positionalArgs,coverage:e?.coverage,requireDefenseContext:e?.requireDefenseContext,defenseContextChecked:!1,budget:e?.budget??{operations:0,callDepth:0}}}function xy(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,namedArgs:e.namedArgs,positionalArgs:e.positionalArgs,requireDefenseContext:e.requireDefenseContext,defenseContextChecked:e.defenseContextChecked,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels,coverage:e.coverage,budget:e.budget}}function Sy(e,t,n){switch(t.type){case`var`:return xy(e,t.name,n);case`array`:{if(!Array.isArray(n))return null;let r=e;for(let e=0;e<t.elements.length;e++){let i=t.elements[e],a=e<n.length?n[e]:null,o=Sy(r,i,a);if(o===null)return null;r=o}return r}case`object`:{let r=gl(n);if(!r)return null;let i=e;for(let a of t.fields){let t;if(typeof a.key==`string`)t=a.key;else{let r=J(n,a.key,e);if(r.length===0)return null;t=String(r[0])}let o=ml(r,t)?r[t]:null;a.keyVar&&(i=xy(i,a.keyVar,o));let s=Sy(i,a.pattern,o);if(s===null)return null;i=s}return i}}}function Cy(e,t){let n=e;for(let e of t)if(n&&typeof n==`object`){if(Array.isArray(n)){if(typeof e==`number`)n=n[e];else return}else{let t=gl(n);if(t&&typeof e==`string`&&Object.hasOwn(t,e))n=t[e];else return}}else return;return n}function wy(e){if(e.type===`Identity`)return[];if(e.type===`Field`){let t=e.base?wy(e.base):[];return t===null?null:[...t,e.name]}if(e.type===`Index`&&e.index.type===`Literal`){let t=e.base?wy(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n==`number`||typeof n==`string`?[...t,n]:null}if(e.type===`Pipe`){let t=wy(e.left);return t===null?null:Ty(t,e.right)}if(e.type===`Call`){if(e.name===`parent`||e.name===`root`)return null;if(e.name===`first`&&e.args.length===0)return[0];if(e.name===`last`&&e.args.length===0)return[-1]}return null}function Ty(e,t){if(t.type===`Call`){if(t.name===`parent`){let n=1;if(t.args.length>0&&t.args[0].type===`Literal`){let e=t.args[0].value;typeof e==`number`&&(n=e)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let t=-n-1;return e.slice(0,Math.min(t,e.length))}}if(t.name===`root`)return[]}if(t.type===`Field`){let n=wy(t);if(n!==null)return[...e,...n]}if(t.type===`Index`&&t.index.type===`Literal`){let n=wy(t);if(n!==null)return[...e,...n]}if(t.type===`Pipe`){let n=Ty(e,t.left);return n===null?null:Ty(n,t.right)}return t.type===`Identity`?e:null}function Ey(e,t,n){if(t.type===`Comma`){let r=[];try{vy(n,r,J(e,t.left,n))}catch(e){if(e instanceof A)throw e;if(r.length>0)return r;throw Error(`evaluation failed`)}try{vy(n,r,J(e,t.right,n))}catch(e){if(e instanceof A)throw e;return r}return r}return J(e,t,n)}function J(e,t,n){let r=n&&`vars`in n?n:by(n);if(r.defenseContextChecked||(bu(r.requireDefenseContext,`query-engine`,`evaluation`),r={...r,defenseContextChecked:!0}),r.root===void 0&&(r={...r,root:e,currentPath:[]}),gy(r),r.budget.callDepth++,r.budget.callDepth>r.limits.maxDepth)throw r.budget.callDepth--,hy(`query depth limit exceeded (${r.limits.maxDepth})`,`recursion`);try{let n=Dy(e,t,r);return _y(r,0,n.length),n}finally{r.budget.callDepth--}}function Dy(e,t,n){switch(n.coverage?.hit(`jq:node:${t.type}`),t.type){case`Identity`:return[e];case`Field`:return yy(n,t.base?J(e,t.base,n):[e],e=>{let n=gl(e);if(n){if(!Object.hasOwn(n,t.name))return[null];let e=n[t.name];return[e===void 0?null:e]}if(e===null)return[null];throw Error(`Cannot index ${Array.isArray(e)?`array`:typeof e} with string "${t.name}"`)});case`Index`:return yy(n,t.base?J(e,t.base,n):[e],e=>yy(n,J(e,t.index,n),t=>{if(typeof t==`number`&&Array.isArray(e)){if(Number.isNaN(t))return[null];let n=Math.trunc(t),r=n<0?e.length+n:n;return r>=0&&r<e.length?[e[r]]:[null]}if(typeof t==`string`){let n=gl(e);return!n||!Object.hasOwn(n,t)?[null]:[n[t]]}return[null]}));case`Slice`:return yy(n,t.base?J(e,t.base,n):[e],r=>{if(r===null)return[null];if(!Array.isArray(r)&&typeof r!=`string`)throw Error(`Cannot slice ${typeof r} (${JSON.stringify(r)})`);let i=r.length,a=t.start?J(e,t.start,n):[0],o=t.end?J(e,t.end,n):[i];return _y(n,0,a.length*o.length),yy(n,a,e=>o.map(t=>{let n=e,a=t,o=Number.isNaN(n)?0:Number.isInteger(n)?n:Math.floor(n),s=Number.isNaN(a)?i:Number.isInteger(a)?a:Math.ceil(a),c=Oy(o,i),l=Oy(s,i);return r.slice(c,l)}))});case`Iterate`:return yy(n,t.base?J(e,t.base,n):[e],e=>Array.isArray(e)?e:e&&typeof e==`object`?Object.values(e):[]);case`Pipe`:{let r=J(e,t.left,n),i=wy(t.left),a=[];for(let e of r)try{if(i!==null){let r={...n,currentPath:[...n.currentPath??[],...i]};vy(n,a,J(e,t.right,r))}else vy(n,a,J(e,t.right,n))}catch(e){throw e instanceof Py?e.withPrependedResults(a):e}return a}case`Comma`:{let r=J(e,t.left,n),i=J(e,t.right,n);return _y(n,r.length,i.length),[...r,...i]}case`Literal`:return[t.value];case`Array`:return t.elements?[J(e,t.elements,n)]:[[]];case`Object`:{let r=[Object.create(null)];for(let i of t.entries){let t=typeof i.key==`string`?[i.key]:J(e,i.key,n),a=J(e,i.value,n),o=[],s=t.filter(e=>typeof e==`string`&&fl(e)).length,c=s+(t.length-s);_y(n,0,r.length*c*a.length);for(let e of r)for(let n of t){if(typeof n!=`string`)throw Error(`Cannot use ${n===null?`null`:Array.isArray(n)?`array`:typeof n} (${JSON.stringify(n)}) as object key`);if(!fl(n)){for(let t of a)o.push(vl(e));continue}for(let t of a){let r=vl(e);pl(r,n,t),o.push(r)}}r.length=0,vy(n,r,o)}return r}case`Paren`:return J(e,t.expr,n);case`BinaryOp`:return jy(e,t.op,t.left,t.right,n);case`UnaryOp`:return J(e,t.operand,n).map(e=>{if(t.op===`-`){if(typeof e==`number`)return-e;if(typeof e==`string`)throw Error(`string (${(e=>e.length>5?`"${e.slice(0,3)}...`:JSON.stringify(e))(e)}) cannot be negated`);return null}return t.op===`not`?!Cv(e):null});case`Cond`:return yy(n,J(e,t.cond,n),r=>{if(Cv(r))return J(e,t.then,n);for(let r of t.elifs)if(J(e,r.cond,n).some(Cv))return J(e,r.then,n);return t.else?J(e,t.else,n):[e]});case`Try`:try{return J(e,t.body,n)}catch(e){if(e instanceof A)throw e;return t.catch?J(e instanceof Fy?e.value:e instanceof Error?e.message:String(e),t.catch,n):[]}case`Call`:return My(e,t.name,t.args,n);case`VarBind`:return yy(n,J(e,t.value,n),r=>{let i=null,a=[];if(t.pattern?a.push(t.pattern):t.name&&a.push({type:`var`,name:t.name}),t.alternatives)for(let e of t.alternatives)a.push(e);for(let e of a)if(i=Sy(n,e,r),i!==null)break;return i===null?[]:J(e,t.body,i)});case`VarRef`:{if(t.name===`$ENV`)return[n.env?rd(n.env):Object.create(null)];if(t.name===`$ARGS`){let e=Object.create(null);if(n.namedArgs)for(let[t,r]of n.namedArgs)Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0});let t=Object.create(null);return t.positional=n.positionalArgs?[...n.positionalArgs]:[],t.named=e,[t]}let e=n.vars.get(t.name);return e===void 0?[null]:[e]}case`Recurse`:{let t=[],r=new WeakSet,i=[{val:e,depth:0}];for(;i.length>0;){let e=i.pop();if(!e)break;let{val:a,depth:o}=e;if(gy(n),o>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);if(a&&typeof a==`object`){if(r.has(a))continue;r.add(a)}if(_y(n,t.length),t.push(a),Array.isArray(a))for(let e=a.length-1;e>=0;e--)i.push({val:a[e],depth:o+1});else if(a&&typeof a==`object`){let e=Object.keys(a);for(let t=e.length-1;t>=0;t--)i.push({val:a[e[t]],depth:o+1})}}return t}case`Optional`:try{return J(e,t.expr,n)}catch(e){if(e instanceof A)throw e;return[]}case`StringInterp`:{let r=new Ui(n.limits.maxStringLength,`query string interpolation`,()=>new A(`string size limit exceeded (${n.limits.maxStringLength} bytes)`,`string_length`));for(let i of t.parts){if(typeof i==`string`){r.append(i);continue}let t=J(e,i,n);for(let e of t){if(gy(n),Dv(e,n.limits.maxDepth+1)>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);r.append(typeof e==`string`?e:JSON.stringify(e))}}return[r.build()]}case`UpdateOp`:return[ky(e,t.path,t.op,t.value,n)];case`Reduce`:{let r=J(e,t.expr,n),i=J(e,t.init,n)[0],a=n.limits.maxDepth??Ry;for(let e of r){let r;if(t.pattern){if(r=Sy(n,t.pattern,e),r===null)continue}else r=xy(n,t.varName,e);if(i=J(i,t.update,r)[0],Dv(i,a+1)>a)return[null]}return[i]}case`Foreach`:{let r=J(e,t.expr,n),i=J(e,t.init,n)[0],a=[];for(let e of r)try{let r;if(t.pattern){if(r=Sy(n,t.pattern,e),r===null)continue}else r=xy(n,t.varName,e);i=J(i,t.update,r)[0],t.extract?vy(n,a,J(i,t.extract,r)):(_y(n,a.length),a.push(i))}catch(e){throw e instanceof Py?e.withPrependedResults(a):e}return a}case`Label`:try{return J(e,t.body,{...n,labels:new Set([...n.labels??[],t.name])})}catch(e){if(e instanceof Py&&e.label===t.name)return e.partialResults;throw e}case`Break`:throw new Py(t.name);case`Def`:{let r=new Map(n.funcs??[]),i=`${t.name}/${t.params.length}`;r.set(i,{params:t.params,body:t.funcBody,closure:new Map(n.funcs??[])});let a={...n,funcs:r};return J(e,t.body,a)}default:throw Error(`Unknown AST node type: ${t.type}`)}}function Oy(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function ky(e,t,n,r,i){function a(e,t){switch(n){case`=`:return t;case`|=`:return J(e,r,i)[0]??null;case`+=`:return typeof e==`number`&&typeof t==`number`||typeof e==`string`&&typeof t==`string`?e+t:Array.isArray(e)&&Array.isArray(t)?(_y(i,e.length,t.length),[...e,...t]):e&&t&&typeof e==`object`&&typeof t==`object`?yl(e,t):t;case`-=`:return typeof e==`number`&&typeof t==`number`?e-t:e;case`*=`:return typeof e==`number`&&typeof t==`number`?e*t:e;case`/=`:return typeof e==`number`&&typeof t==`number`?e/t:e;case`%=`:return typeof e==`number`&&typeof t==`number`?e%t:e;case`//=`:return e===null||e===!1?t:e;default:return t}}function o(t,n,r){switch(n.type){case`Identity`:return r(t);case`Field`:if(!fl(n.name))return t;if(n.base)return o(t,n.base,e=>{if(e&&typeof e==`object`&&!Array.isArray(e)){let t=vl(e),i=Object.hasOwn(t,n.name)?t[n.name]:void 0;return pl(t,n.name,r(i)),t}return e});if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t),i=Object.hasOwn(e,n.name)?e[n.name]:void 0;return pl(e,n.name,r(i)),e}return t;case`Index`:{let a=J(e,n.index,i)[0];if(typeof a==`number`&&Number.isNaN(a))throw Error(`Cannot set array element at NaN index`);if(typeof a==`number`&&!Number.isFinite(a))throw Error(`array index must be finite`);if(typeof a==`number`&&!Number.isInteger(a)&&(a=Math.trunc(a)),n.base)return o(t,n.base,e=>{if(typeof a==`number`&&Array.isArray(e)){let t=[...e],n=a<0?t.length+a:a;if(n>=0){_y(i,0,n+1),t.length<=n&&(t.length=n+1);for(let r=e.length;r<n;r++)t[r]=null;t[n]=r(t[n])}return t}if(typeof a==`string`&&e&&typeof e==`object`&&!Array.isArray(e)){if(!fl(a))return e;let t=vl(e),n=Object.hasOwn(t,a)?t[a]:void 0;return pl(t,a,r(n)),t}return e});if(typeof a==`number`){if(!Number.isSafeInteger(a)||a>536870911)throw Error(`Array index too large`);if(a<0&&(!t||!Array.isArray(t)))throw Error(`Out of bounds negative array index`);if(Array.isArray(t)){let e=[...t],n=a<0?e.length+a:a;if(n>=0){_y(i,0,n+1),e.length<=n&&(e.length=n+1);for(let r=t.length;r<n;r++)e[r]=null;e[n]=r(e[n])}return e}if(t==null){_y(i,0,a+1);let e=Array(a+1).fill(null);return e[a]=r(null),e}return t}if(typeof a==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(a))return t;let e=vl(t),n=Object.hasOwn(e,a)?e[a]:void 0;return pl(e,a,r(n)),e}return t}case`Iterate`:{let e=e=>{if(Array.isArray(e)){_y(i,0,e.length);let t=[];for(let n of e)gy(i),t.push(r(n));return t}if(e&&typeof e==`object`){let t=Object.create(null);for(let[n,i]of Object.entries(e))fl(n)&&pl(t,n,r(i));return t}return e};return n.base?o(t,n.base,e):e(t)}case`Pipe`:return o(o(t,n.left,e=>e),n.right,r);default:return r(t)}}return o(e,t,t=>n===`|=`?a(t,t):a(t,J(e,r,i)[0]??null))}function Ay(e,t,n){function r(t,i,a){switch(i.type){case`Identity`:return a;case`Field`:if(!fl(i.name))return t;if(i.base){let e=J(t,i.base,n)[0],o=r(e,{type:`Field`,name:i.name},a);return r(t,i.base,o)}if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t);return pl(e,i.name,a),e}return t;case`Index`:{if(i.base){let e=J(t,i.base,n)[0],o=r(e,{type:`Index`,index:i.index},a);return r(t,i.base,o)}let o=J(e,i.index,n)[0];if(typeof o==`number`&&Array.isArray(t)){let e=[...t],n=o<0?e.length+o:o;return n>=0&&n<e.length&&(e[n]=a),e}if(typeof o==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(o))return t;let e=vl(t);return pl(e,o,a),e}return t}default:return t}}function i(t,a){switch(a.type){case`Identity`:return null;case`Field`:if(!fl(a.name))return t;if(a.base){let e=J(t,a.base,n)[0];if(e==null)return t;let o=i(e,{type:`Field`,name:a.name});return r(t,a.base,o)}if(t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(a.name))return t;let e=vl(t);return delete e[a.name],e}return t;case`Index`:{if(a.base){let e=J(t,a.base,n)[0];if(e==null)return t;let o=i(e,{type:`Index`,index:a.index});return r(t,a.base,o)}let o=J(e,a.index,n)[0];if(typeof o==`number`&&Array.isArray(t)){let e=[...t],n=o<0?e.length+o:o;return n>=0&&n<e.length&&e.splice(n,1),e}if(typeof o==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(o))return t;let e=vl(t);return delete e[o],e}return t}case`Iterate`:return Array.isArray(t)?[]:t&&typeof t==`object`?Object.create(null):t;case`Pipe`:{let r=function(t,i,a){switch(i.type){case`Identity`:return a;case`Field`:if(!fl(i.name))return t;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t);return pl(e,i.name,a),e}return t;case`Index`:{let r=J(e,i.index,n)[0];if(typeof r==`number`&&Array.isArray(t)){let e=[...t],n=r<0?e.length+r:r;return n>=0&&n<e.length&&(e[n]=a),e}if(typeof r==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(r))return t;let e=vl(t);return pl(e,r,a),e}return t}case`Pipe`:{let e=J(t,i.left,n)[0],o=r(e,i.right,a);return r(t,i.left,o)}default:return t}},o=a.left,s=a.right,c=J(t,o,n)[0];return c==null?t:r(t,o,i(c,s))}default:return t}}return i(e,t)}function jy(e,t,n,r,i){if(t===`and`)return yy(i,J(e,n,i),t=>Cv(t)?yy(i,J(e,r,i),e=>[Cv(e)]):[!1]);if(t===`or`)return yy(i,J(e,n,i),t=>Cv(t)?[!0]:yy(i,J(e,r,i),e=>[Cv(e)]));if(t===`//`){let t=J(e,n,i).filter(e=>e!=null&&e!==!1);return t.length>0?t:J(e,r,i)}let a=J(e,n,i),o=J(e,r,i),s=a.length*o.length;return _y(i,0,s),gy(i,s),a.flatMap(e=>o.map(n=>{switch(t){case`+`:if(e===null)return n;if(n===null)return e;if(typeof e==`number`&&typeof n==`number`)return e+n;if(typeof e==`string`&&typeof n==`string`){let t=i.limits.maxStringLength;if(O(e)+O(n)>t)throw new A(`string size limit exceeded (${t} bytes)`,`string_length`);return e+n}return Array.isArray(e)&&Array.isArray(n)?(_y(i,e.length,n.length),[...e,...n]):e&&n&&typeof e==`object`&&typeof n==`object`&&!Array.isArray(e)&&!Array.isArray(n)?yl(e,n):null;case`-`:if(typeof e==`number`&&typeof n==`number`)return e-n;if(Array.isArray(e)&&Array.isArray(n)){let t=new Set(n.map(e=>JSON.stringify(e)));return e.filter(e=>!t.has(JSON.stringify(e)))}if(typeof e==`string`&&typeof n==`string`){let t=e=>e.length>10?`"${e.slice(0,10)}...`:JSON.stringify(e);throw Error(`string (${t(e)}) and string (${t(n)}) cannot be subtracted`)}return null;case`*`:if(typeof e==`number`&&typeof n==`number`)return e*n;if(typeof e==`string`&&typeof n==`number`){if(!Number.isFinite(n))throw Error(`invalid string repetition count: ${n}`);let t=Math.trunc(n);if(t<0)return null;let r=O(e),a=i.limits.maxStringLength;if(r>0&&t>Math.floor(a/r))throw new A(`string size limit exceeded (${a} bytes)`,`string_length`);return e.repeat(t)}{let t=gl(e),r=gl(n);if(t&&r)return Ev(t,r,{maxDepth:i.limits.maxDepth,visit:()=>gy(i)})}return null;case`/`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided because the divisor is zero`);return e/n}return typeof e==`string`&&typeof n==`string`?e.split(n):null;case`%`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(e)&&!Number.isNaN(e)?!Number.isFinite(n)&&!Number.isNaN(n)&&e<0&&n>0?-1:0:e%n}return null;case`==`:return wv(e,n);case`!=`:return!wv(e,n);case`<`:return Tv(e,n)<0;case`<=`:return Tv(e,n)<=0;case`>`:return Tv(e,n)>0;case`>=`:return Tv(e,n)>=0;default:return null}}))}function My(e,t,n,r){let i=zy.get(t);if(i)return typeof e==`number`?[i(e)]:[null];let a=Rv(e,t,n,r,J);if(a!==null)return a;let o=sy(e,t,n,r,J);if(o!==null)return o;let s=bv(e,t,n,r,J);if(s!==null)return s;let c=Nv(e,t,r.limits.maxDepth);if(c!==null)return c;let l=ly(e,t);if(l!==null)return l;let u=Jv(e,t,n,r,J);if(u!==null)return u;let d=mv(e,t,n,r,J,Ey,Ov,Cv,kv,A);if(d!==null)return d;let f=$v(e,t,n,r,J,Cv,fy,py,Ay,Ny);if(f!==null)return f;let p=Iv(e,t,n,r,J,wv);if(p!==null)return p;let m=gv(e,t,n,r,J,Ey,Cv,A);if(m!==null)return m;let h=Uv(e,t,n,r,J,Cv,Cy,My);if(h!==null)return h;let g=ty(e,t,n,r,J,wv);if(g!==null)return g;switch(t){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`.split(`.`)];case`error`:{let t=n.length>0?J(e,n[0],r)[0]:e;throw new Fy(t)}case`env`:return[r.env?rd(r.env):Object.create(null)];case`debug`:return[e];case`input_line_number`:return[1];default:{let i=`${t}/${n.length}`,a=r.funcs?.get(i);if(a){let t=a.closure??r.funcs??new Map,o=new Map(t);o.set(i,a);for(let t=0;t<a.params.length;t++){let i=a.params[t],s=n[t];if(s){let t=J(e,s,r),n;if(t.length===0)n={type:`Call`,name:`empty`,args:[]};else if(t.length===1)n={type:`Literal`,value:t[0]};else{n={type:`Literal`,value:t[t.length-1]};for(let e=t.length-2;e>=0;e--)n={type:`Comma`,left:{type:`Literal`,value:t[e]},right:n}}o.set(`${i}/0`,{params:[],body:n})}}let s={...r,funcs:o};return J(e,a.body,s)}throw Error(`Unknown function: ${t}`)}}}function Ny(e,t,n,r,i){if(gy(n),r.length>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);let a=e=>{if(e.length>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);_y(n,i.length),i.push(e)};if(t.type===`Comma`){let a=t;Ny(e,a.left,n,r,i),Ny(e,a.right,n,r,i);return}let o=wy(t);if(o!==null){a([...r,...o]);return}if(t.type===`Iterate`){if(Array.isArray(e))for(let t=0;t<e.length;t++)gy(n),a([...r,t]);else if(e&&typeof e==`object`)for(let t of Object.keys(e))gy(n),a([...r,t]);return}if(t.type===`Recurse`){let t=[{value:e,path:[]}];for(;t.length>0;){let e=t.pop();if(!e)break;if(gy(n),a([...r,...e.path]),e.value&&typeof e.value==`object`){let r=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);_y(n,0,t.length+r.length);for(let n=r.length-1;n>=0;n--){let[i,a]=r[n];t.push({value:a,path:[...e.path,i]})}}}return}if(t.type===`Pipe`){let a=wy(t.left);if(a!==null){let o=J(e,t.left,n);for(let e of o)Ny(e,t.right,n,[...r,...a],i);return}}J(e,t,n).length>0&&a(r)}var Py,Fy,Iy,Ly,Ry,zy,By=T(()=>{Wi(),od(),j(),Su(),Lr(),dy(),my(),xl(),Av(),Py=class e extends Error{label;partialResults;constructor(e,t=[]){super(`break ${e}`),this.label=e,this.partialResults=t,this.name=`BreakError`}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},Fy=class extends Error{value;constructor(e){super(typeof e==`string`?e:JSON.stringify(e)),this.value=e,this.name=`JqError`}},Iy=1e4,Ly=10485760,Ry=2e3,zy=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 Vy(e){let t=[],n=0,r=(t=0)=>e[n+t],i=()=>e[n++],a=()=>n>=e.length,o=e=>e>=`0`&&e<=`9`,s=e=>e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`,c=e=>s(e)||o(e);for(;!a();){let l=n,u=i();if(u!==` `&&u!==` `&&u!==`
644
644
  `&&u!==`\r`){if(u===`#`){for(;!a()&&r()!==`
645
645
  `;)i();continue}if(u===`.`&&r()===`.`){i(),t.push({type:`DOTDOT`,pos:l});continue}if(u===`=`&&r()===`=`){i(),t.push({type:`EQ`,pos:l});continue}if(u===`!`&&r()===`=`){i(),t.push({type:`NE`,pos:l});continue}if(u===`<`&&r()===`=`){i(),t.push({type:`LE`,pos:l});continue}if(u===`>`&&r()===`=`){i(),t.push({type:`GE`,pos:l});continue}if(u===`/`&&r()===`/`){i(),r()===`=`?(i(),t.push({type:`UPDATE_ALT`,pos:l})):t.push({type:`ALT`,pos:l});continue}if(u===`+`&&r()===`=`){i(),t.push({type:`UPDATE_ADD`,pos:l});continue}if(u===`-`&&r()===`=`){i(),t.push({type:`UPDATE_SUB`,pos:l});continue}if(u===`*`&&r()===`=`){i(),t.push({type:`UPDATE_MUL`,pos:l});continue}if(u===`/`&&r()===`=`){i(),t.push({type:`UPDATE_DIV`,pos:l});continue}if(u===`%`&&r()===`=`){i(),t.push({type:`UPDATE_MOD`,pos:l});continue}if(u===`=`&&r()!==`=`){t.push({type:`ASSIGN`,pos:l});continue}if(u===`.`){t.push({type:`DOT`,pos:l});continue}if(u===`|`){r()===`=`?(i(),t.push({type:`UPDATE_PIPE`,pos:l})):t.push({type:`PIPE`,pos:l});continue}if(u===`,`){t.push({type:`COMMA`,pos:l});continue}if(u===`:`){t.push({type:`COLON`,pos:l});continue}if(u===`;`){t.push({type:`SEMICOLON`,pos:l});continue}if(u===`(`){t.push({type:`LPAREN`,pos:l});continue}if(u===`)`){t.push({type:`RPAREN`,pos:l});continue}if(u===`[`){t.push({type:`LBRACKET`,pos:l});continue}if(u===`]`){t.push({type:`RBRACKET`,pos:l});continue}if(u===`{`){t.push({type:`LBRACE`,pos:l});continue}if(u===`}`){t.push({type:`RBRACE`,pos:l});continue}if(u===`?`){t.push({type:`QUESTION`,pos:l});continue}if(u===`+`){t.push({type:`PLUS`,pos:l});continue}if(u===`-`){t.push({type:`MINUS`,pos:l});continue}if(u===`*`){t.push({type:`STAR`,pos:l});continue}if(u===`/`){t.push({type:`SLASH`,pos:l});continue}if(u===`%`){t.push({type:`PERCENT`,pos:l});continue}if(u===`<`){t.push({type:`LT`,pos:l});continue}if(u===`>`){t.push({type:`GT`,pos:l});continue}if(o(u)){let s=u;for(;!a()&&(o(r())||r()===`.`||r()===`e`||r()===`E`);)(r()===`e`||r()===`E`)&&(e[n+1]===`+`||e[n+1]===`-`)&&(s+=i()),s+=i();t.push({type:`NUMBER`,value:Number(s),pos:l});continue}if(u===`"`){let e=``,n=0;for(;!a();){let t=r();if(n===0&&t===`"`)break;if(n===0&&t===`\\`){if(i(),a())break;let t=i();switch(t){case`n`:e+=`
646
- `;break;case`r`:e+=`\r`;break;case`t`:e+=` `;break;case`\\`:e+=`\\`;break;case`"`:e+=`"`;break;case`(`:e+=`\\(`,n=1;break;default:e+=t}continue}if(n>0){if(t===`"`){for(e+=i();!a();){let t=r();if(t===`\\`){e+=i(),a()||(e+=i());continue}if(e+=i(),t===`"`)break}continue}t===`(`?n++:t===`)`&&n--,e+=i();continue}e+=i()}a()||i(),t.push({type:`STRING`,value:e,pos:l});continue}if(s(u)||u===`$`||u===`@`){let e=u;for(;!a()&&c(r());)e+=i();let n=Uy.get(e);n?t.push({type:n,value:e,pos:l}):t.push({type:`IDENT`,value:e,pos:l});continue}throw Error(`Unexpected character '${u}' at position ${l}`)}}return t.push({type:`EOF`,pos:n}),t}function Hy(e,t={}){let n=t.maxDepth??256,r=t.maxTokens??1e5,i=t.maxSourceLength??1048576;if(e.length>i)throw Error(`query source length limit exceeded (${i} characters)`);if(e.length+1>r)throw Error(`query token limit exceeded (${r})`);let a=Vy(e);return new Gy(a,n).parse()}var Uy,Wy,Gy,Ky=T(()=>{Uy=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`]]),Wy=new Set(Uy.values()),Gy=class e{maxDepth;tokens;pos=0;depth;constructor(e,t,n=0){this.maxDepth=t,this.tokens=e,this.depth=n}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 t of e)if(this.check(t))return this.advance();return null}expect(e,t){if(!this.check(e))throw Error(`${t} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}withDepth(e){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return e()}finally{this.depth--}}isFieldNameAfterDot(e=0){let t=this.peek(e),n=this.peek(e+1);return n.type===`STRING`?!0:n.type===`IDENT`||Wy.has(n.type)?n.pos===t.pos+1:!1}isIdentLike(){let e=this.peek().type;return e===`IDENT`||Wy.has(e)}consumeFieldNameAfterDot(e){let t=this.peek();return t.type===`STRING`||(t.type===`IDENT`||Wy.has(t.type))&&t.pos===e.pos+1?this.advance().value:null}parse(){let e=this.parseExpr();if(!this.check(`EOF`))throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePipe()}finally{this.depth--}}parsePattern(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePatternInner()}finally{this.depth--}}parsePatternInner(){if(this.match(`LBRACKET`)){let e=[];if(!this.check(`RBRACKET`))for(e.push(this.parsePattern());this.match(`COMMA`)&&!this.check(`RBRACKET`);)e.push(this.parsePattern());return this.expect(`RBRACKET`,`Expected ']' after array pattern`),{type:`array`,elements:e}}if(this.match(`LBRACE`)){let e=[];if(!this.check(`RBRACE`))for(e.push(this.parsePatternField());this.match(`COMMA`)&&!this.check(`RBRACE`);)e.push(this.parsePatternField());return this.expect(`RBRACE`,`Expected '}' after object pattern`),{type:`object`,fields:e}}let e=this.expect(`IDENT`,`Expected variable name in pattern`),t=e.value;if(!t.startsWith(`$`))throw Error(`Variable name must start with $ at position ${e.pos}`);return{type:`var`,name:t}}parsePatternField(){if(this.match(`LPAREN`)){let e=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after computed key`),this.expect(`COLON`,`Expected ':' after computed key`),{key:e,pattern:this.parsePattern()}}let e=this.peek();if(e.type===`IDENT`||Wy.has(e.type)){let t=e.value;if(t.startsWith(`$`)){if(this.advance(),this.match(`COLON`)){let e=this.parsePattern();return{key:t.slice(1),pattern:e,keyVar:t}}return{key:t.slice(1),pattern:{type:`var`,name:t}}}return this.advance(),this.match(`COLON`)?{key:t,pattern:this.parsePattern()}:{key:t,pattern:{type:`var`,name:`$${t}`}}}throw Error(`Expected field name in object pattern at position ${e.pos}`)}parsePipe(){let e=this.parseComma();for(;this.match(`PIPE`);){let t=this.parseComma();e={type:`Pipe`,left:e,right:t}}return e}parseComma(){let e=this.parseVarBind();for(;this.match(`COMMA`);){let t=this.parseVarBind();e={type:`Comma`,left:e,right:t}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match(`AS`)){let t=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 r=this.parseExpr();return t.type===`var`&&n.length===0?{type:`VarBind`,name:t.name,value:e,body:r}:{type:`VarBind`,name:t.type===`var`?t.name:``,value:e,body:r,pattern:t.type===`var`?void 0:t,alternatives:n.length>0?n:void 0}}return e}peekAhead(e){let t=this.pos+e;return t<this.tokens.length?this.tokens[t]:void 0}parseUpdate(){let e=this.parseAlt(),t=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 r=this.withDepth(()=>this.parseVarBind()),i=t.get(n.type);if(i)return{type:`UpdateOp`,op:i,path:e,value:r}}return e}parseAlt(){let e=this.parseOr();for(;this.match(`ALT`);){let t=this.parseOr();e={type:`BinaryOp`,op:`//`,left:e,right:t}}return e}parseOr(){let e=this.parseAnd();for(;this.match(`OR`);){let t=this.parseAnd();e={type:`BinaryOp`,op:`or`,left:e,right:t}}return e}parseAnd(){let e=this.parseNot();for(;this.match(`AND`);){let t=this.parseNot();e={type:`BinaryOp`,op:`and`,left:e,right:t}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),t=new Map([[`EQ`,`==`],[`NE`,`!=`],[`LT`,`<`],[`LE`,`<=`],[`GT`,`>`],[`GE`,`>=`]]),n=this.match(`EQ`,`NE`,`LT`,`LE`,`GT`,`GE`);if(n){let r=t.get(n.type);if(r){let t=this.parseAddSub();e={type:`BinaryOp`,op:r,left:e,right:t}}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match(`PLUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`+`,left:e,right:t}}else if(this.match(`MINUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`-`,left:e,right:t}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match(`STAR`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`*`,left:e,right:t}}else if(this.match(`SLASH`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`/`,left:e,right:t}}else if(this.match(`PERCENT`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`%`,left:e,right:t}}else break;return e}parseUnary(){let e=0;for(;this.match(`MINUS`);)if(e++,this.depth+e>this.maxDepth)throw Error(`query parse depth limit exceeded (${this.maxDepth})`);let t=this.parsePostfix();for(;e-->0;)t={type:`UnaryOp`,op:`-`,operand:t};return t}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 t=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,end:t,base:e}}else{let t=this.parseExpr();if(this.match(`COLON`)){let n=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,start:t,end:n,base:e}}else this.expect(`RBRACKET`,`Expected ']'`),e={type:`Index`,index:t,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 e=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,end:e}}let e=this.parseExpr();if(this.match(`COLON`)){let t=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,start:e,end:t}}return this.expect(`RBRACKET`,`Expected ']'`),{type:`Index`,index:e}}let t=this.consumeFieldNameAfterDot(e);return t===null?{type:`Identity`}:{type:`Field`,name:t}}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 e=this.advance().value;return e.includes(`\\(`)?this.parseStringInterpolation(e):{type:`Literal`,value:e}}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.withDepth(()=>this.parsePostfix()),t;return this.match(`CATCH`)&&(t=this.withDepth(()=>this.parsePostfix())),{type:`Try`,body:e,catch:t}}if(this.match(`REDUCE`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after reduce expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after update expression`),{type:`Reduce`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,pattern:t.type===`var`?void 0:t}}if(this.match(`FOREACH`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after foreach expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr(),i;return this.match(`SEMICOLON`)&&(i=this.parseExpr()),this.expect(`RPAREN`,`Expected ')' after expressions`),{type:`Foreach`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,extract:i,pattern:t.type===`var`?void 0:t}}if(this.match(`LABEL`)){let e=this.expect(`IDENT`,`Expected label name (e.g., $out)`),t=e.value;if(!t.startsWith(`$`))throw Error(`Label name must start with $ at position ${e.pos}`);return this.expect(`PIPE`,`Expected '|' after label name`),{type:`Label`,name:t,body:this.parseExpr()}}if(this.match(`BREAK`)){let e=this.expect(`IDENT`,`Expected label name to break to`),t=e.value;if(!t.startsWith(`$`))throw Error(`Break label must start with $ at position ${e.pos}`);return{type:`Break`,name:t}}if(this.match(`DEF`)){let e=this.expect(`IDENT`,`Expected function name after def`).value,t=[];if(this.match(`LPAREN`)){if(!this.check(`RPAREN`)){let e=this.expect(`IDENT`,`Expected parameter name`);for(t.push(e.value);this.match(`SEMICOLON`);){let e=this.expect(`IDENT`,`Expected parameter name`);t.push(e.value)}}this.expect(`RPAREN`,`Expected ')' after parameters`)}this.expect(`COLON`,`Expected ':' after function name`);let n=this.parseExpr();return this.expect(`SEMICOLON`,`Expected ';' after function body`),{type:`Def`,name:e,params:t,funcBody:n,body:this.parseExpr()}}if(this.match(`NOT`))return{type:`Call`,name:`not`,args:[]};if(this.check(`IDENT`)){let e=this.advance().value;if(e.startsWith(`$`))return{type:`VarRef`,name:e};if(this.match(`LPAREN`)){let t=[];if(!this.check(`RPAREN`))for(t.push(this.parseExpr());this.match(`SEMICOLON`);)t.push(this.parseExpr());return this.expect(`RPAREN`,`Expected ')'`),{type:`Call`,name:e,args:t}}return{type:`Call`,name:e,args:[]}}throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parseObjectConstructionInner()}finally{this.depth--}}parseObjectConstructionInner(){let e=[];if(!this.check(`RBRACE`))do{let t,n;if(this.match(`LPAREN`))t=this.parseExpr(),this.expect(`RPAREN`,`Expected ')'`),this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else if(this.isIdentLike()){let e=this.advance().value;this.match(`COLON`)?(t=e,n=this.parseObjectValue()):(t=e,n={type:`Field`,name:e})}else if(this.check(`STRING`))t=this.advance().value,this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else throw Error(`Expected object key at position ${this.peek().pos}`);e.push({key:t,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 t=this.parseVarBind();e={type:`Pipe`,left:e,right:t}}return e}parseIf(){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then'`);let t=this.parseExpr(),n=[];for(;this.match(`ELIF`);){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then' after elif`);let t=this.parseExpr();n.push({cond:e,then:t})}let r;return this.match(`ELSE`)&&(r=this.parseExpr()),this.expect(`END`,`Expected 'end'`),{type:`Cond`,cond:e,then:t,elifs:n,else:r}}parseStringInterpolation(t){let n=[],r=``,i=0;for(;i<t.length;)if(t[i]===`\\`&&t[i+1]===`(`){r&&=(n.push(r),``),i+=2;let a=1,o=``;for(;i<t.length&&a>0;){let e=t[i];if(e===`"`){for(o+=e,i++;i<t.length;){let e=t[i];if(e===`\\`){o+=e,i++,i<t.length&&(o+=t[i],i++);continue}if(o+=e,i++,e===`"`)break}continue}e===`(`?a++:e===`)`&&a--,a>0&&(o+=e),i++}let s=Vy(o),c=new e(s,this.maxDepth,this.depth);n.push(c.parse())}else r+=t[i],i++;return r&&n.push(r),{type:`StringInterp`,parts:n}}}}),qy=T(()=>{By(),Ky()});function Jy(e,t,n={}){let r=new Ui(t,`query JSON output`,()=>new A(`output size limit exceeded (${t} bytes)`,n.limitKind??`output_size`));return Yy(r,e,n,0),r.build()}function Yy(e,t,n,r){if(t==null){e.append(`null`);return}if(typeof t==`boolean`){e.append(String(t));return}if(typeof t==`number`){e.append(Number.isFinite(t)?String(t):`null`);return}if(typeof t==`string`){n.raw&&r===0?e.append(t):Xy(e,t);return}let i=n.compact??!1,a=n.indent??2,o=n.useTab?` `:` `.repeat(a);if(Array.isArray(t)){e.append(`[`);for(let a=0;a<t.length;a++)e.append(i?a===0?``:`,`:a===0?`
646
+ `;break;case`r`:e+=`\r`;break;case`t`:e+=` `;break;case`\\`:e+=`\\`;break;case`"`:e+=`"`;break;case`(`:e+=`\\(`,n=1;break;default:e+=t}continue}if(n>0){if(t===`"`){for(e+=i();!a();){let t=r();if(t===`\\`){e+=i(),a()||(e+=i());continue}if(e+=i(),t===`"`)break}continue}t===`(`?n++:t===`)`&&n--,e+=i();continue}e+=i()}a()||i(),t.push({type:`STRING`,value:e,pos:l});continue}if(s(u)||u===`$`||u===`@`){let e=u;for(;!a()&&c(r());)e+=i();let n=Uy.get(e);n?t.push({type:n,value:e,pos:l}):t.push({type:`IDENT`,value:e,pos:l});continue}throw Error(`Unexpected character '${u}' at position ${l}`)}}return t.push({type:`EOF`,pos:n}),t}function Hy(e,t={}){let n=t.maxDepth??256,r=t.maxTokens??1e5,i=t.maxSourceLength??1048576;if(e.length>i)throw Error(`query source length limit exceeded (${i} characters)`);if(e.length+1>r)throw Error(`query token limit exceeded (${r})`);let a=Vy(e);return new Gy(a,n).parse()}var Uy,Wy,Gy,Ky=T(()=>{Uy=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`]]),Wy=new Set(Uy.values()),Gy=class e{maxDepth;tokens;pos=0;depth;constructor(e,t,n=0){this.maxDepth=t,this.tokens=e,this.depth=n}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 t of e)if(this.check(t))return this.advance();return null}expect(e,t){if(!this.check(e))throw Error(`${t} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}withDepth(e){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return e()}finally{this.depth--}}isFieldNameAfterDot(e=0){let t=this.peek(e),n=this.peek(e+1);return n.type===`STRING`?!0:n.type===`IDENT`||Wy.has(n.type)?n.pos===t.pos+1:!1}isIdentLike(){let e=this.peek().type;return e===`IDENT`||Wy.has(e)}consumeFieldNameAfterDot(e){let t=this.peek();return t.type===`STRING`||(t.type===`IDENT`||Wy.has(t.type))&&t.pos===e.pos+1?this.advance().value:null}parse(){let e=this.parseExpr();if(!this.check(`EOF`))throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePipe()}finally{this.depth--}}parsePattern(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePatternInner()}finally{this.depth--}}parsePatternInner(){if(this.match(`LBRACKET`)){let e=[];if(!this.check(`RBRACKET`))for(e.push(this.parsePattern());this.match(`COMMA`)&&!this.check(`RBRACKET`);)e.push(this.parsePattern());return this.expect(`RBRACKET`,`Expected ']' after array pattern`),{type:`array`,elements:e}}if(this.match(`LBRACE`)){let e=[];if(!this.check(`RBRACE`))for(e.push(this.parsePatternField());this.match(`COMMA`)&&!this.check(`RBRACE`);)e.push(this.parsePatternField());return this.expect(`RBRACE`,`Expected '}' after object pattern`),{type:`object`,fields:e}}let e=this.expect(`IDENT`,`Expected variable name in pattern`),t=e.value;if(!t.startsWith(`$`))throw Error(`Variable name must start with $ at position ${e.pos}`);return{type:`var`,name:t}}parsePatternField(){if(this.match(`LPAREN`)){let e=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after computed key`),this.expect(`COLON`,`Expected ':' after computed key`),{key:e,pattern:this.parsePattern()}}let e=this.peek();if(e.type===`IDENT`||Wy.has(e.type)){let t=e.value;if(t.startsWith(`$`)){if(this.advance(),this.match(`COLON`)){let e=this.parsePattern();return{key:t.slice(1),pattern:e,keyVar:t}}return{key:t.slice(1),pattern:{type:`var`,name:t}}}return this.advance(),this.match(`COLON`)?{key:t,pattern:this.parsePattern()}:{key:t,pattern:{type:`var`,name:`$${t}`}}}throw Error(`Expected field name in object pattern at position ${e.pos}`)}parsePipe(){let e=this.parseComma();for(;this.match(`PIPE`);){let t=this.parseComma();e={type:`Pipe`,left:e,right:t}}return e}parseComma(){let e=this.parseVarBind();for(;this.match(`COMMA`);){let t=this.parseVarBind();e={type:`Comma`,left:e,right:t}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match(`AS`)){let t=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 r=this.parseExpr();return t.type===`var`&&n.length===0?{type:`VarBind`,name:t.name,value:e,body:r}:{type:`VarBind`,name:t.type===`var`?t.name:``,value:e,body:r,pattern:t.type===`var`?void 0:t,alternatives:n.length>0?n:void 0}}return e}peekAhead(e){let t=this.pos+e;return t<this.tokens.length?this.tokens[t]:void 0}parseUpdate(){let e=this.parseAlt(),t=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 r=this.withDepth(()=>this.parseVarBind()),i=t.get(n.type);if(i)return{type:`UpdateOp`,op:i,path:e,value:r}}return e}parseAlt(){let e=this.parseOr();for(;this.match(`ALT`);){let t=this.parseOr();e={type:`BinaryOp`,op:`//`,left:e,right:t}}return e}parseOr(){let e=this.parseAnd();for(;this.match(`OR`);){let t=this.parseAnd();e={type:`BinaryOp`,op:`or`,left:e,right:t}}return e}parseAnd(){let e=this.parseNot();for(;this.match(`AND`);){let t=this.parseNot();e={type:`BinaryOp`,op:`and`,left:e,right:t}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),t=new Map([[`EQ`,`==`],[`NE`,`!=`],[`LT`,`<`],[`LE`,`<=`],[`GT`,`>`],[`GE`,`>=`]]),n=this.match(`EQ`,`NE`,`LT`,`LE`,`GT`,`GE`);if(n){let r=t.get(n.type);if(r){let t=this.parseAddSub();e={type:`BinaryOp`,op:r,left:e,right:t}}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match(`PLUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`+`,left:e,right:t}}else if(this.match(`MINUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`-`,left:e,right:t}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match(`STAR`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`*`,left:e,right:t}}else if(this.match(`SLASH`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`/`,left:e,right:t}}else if(this.match(`PERCENT`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`%`,left:e,right:t}}else break;return e}parseUnary(){let e=0;for(;this.match(`MINUS`);)if(e++,this.depth+e>this.maxDepth)throw Error(`query parse depth limit exceeded (${this.maxDepth})`);let t=this.parsePostfix();for(;e-->0;)t={type:`UnaryOp`,op:`-`,operand:t};return t}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 t=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,end:t,base:e}}else{let t=this.parseExpr();if(this.match(`COLON`)){let n=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,start:t,end:n,base:e}}else this.expect(`RBRACKET`,`Expected ']'`),e={type:`Index`,index:t,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 e=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,end:e}}let e=this.parseExpr();if(this.match(`COLON`)){let t=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,start:e,end:t}}return this.expect(`RBRACKET`,`Expected ']'`),{type:`Index`,index:e}}let t=this.consumeFieldNameAfterDot(e);return t===null?{type:`Identity`}:{type:`Field`,name:t}}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 e=this.advance().value;return e.includes(`\\(`)?this.parseStringInterpolation(e):{type:`Literal`,value:e}}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.withDepth(()=>this.parsePostfix()),t;return this.match(`CATCH`)&&(t=this.withDepth(()=>this.parsePostfix())),{type:`Try`,body:e,catch:t}}if(this.match(`REDUCE`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after reduce expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after update expression`),{type:`Reduce`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,pattern:t.type===`var`?void 0:t}}if(this.match(`FOREACH`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after foreach expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr(),i;return this.match(`SEMICOLON`)&&(i=this.parseExpr()),this.expect(`RPAREN`,`Expected ')' after expressions`),{type:`Foreach`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,extract:i,pattern:t.type===`var`?void 0:t}}if(this.match(`LABEL`)){let e=this.expect(`IDENT`,`Expected label name (e.g., $out)`),t=e.value;if(!t.startsWith(`$`))throw Error(`Label name must start with $ at position ${e.pos}`);return this.expect(`PIPE`,`Expected '|' after label name`),{type:`Label`,name:t,body:this.parseExpr()}}if(this.match(`BREAK`)){let e=this.expect(`IDENT`,`Expected label name to break to`),t=e.value;if(!t.startsWith(`$`))throw Error(`Break label must start with $ at position ${e.pos}`);return{type:`Break`,name:t}}if(this.match(`DEF`)){let e=this.expect(`IDENT`,`Expected function name after def`).value,t=[];if(this.match(`LPAREN`)){if(!this.check(`RPAREN`)){let e=this.expect(`IDENT`,`Expected parameter name`);for(t.push(e.value);this.match(`SEMICOLON`);){let e=this.expect(`IDENT`,`Expected parameter name`);t.push(e.value)}}this.expect(`RPAREN`,`Expected ')' after parameters`)}this.expect(`COLON`,`Expected ':' after function name`);let n=this.parseExpr();return this.expect(`SEMICOLON`,`Expected ';' after function body`),{type:`Def`,name:e,params:t,funcBody:n,body:this.parseExpr()}}if(this.match(`NOT`))return{type:`Call`,name:`not`,args:[]};if(this.check(`IDENT`)){let e=this.advance().value;if(e.startsWith(`$`))return{type:`VarRef`,name:e};if(this.match(`LPAREN`)){let t=[];if(!this.check(`RPAREN`))for(t.push(this.parseExpr());this.match(`SEMICOLON`);)t.push(this.parseExpr());return this.expect(`RPAREN`,`Expected ')'`),{type:`Call`,name:e,args:t}}return{type:`Call`,name:e,args:[]}}throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parseObjectConstructionInner()}finally{this.depth--}}parseObjectConstructionInner(){let e=[];if(!this.check(`RBRACE`))do{let t,n;if(this.match(`LPAREN`))t=this.parseExpr(),this.expect(`RPAREN`,`Expected ')'`),this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else if(this.isIdentLike()){let e=this.advance().value;this.match(`COLON`)?(t=e,n=this.parseObjectValue()):(t=e,n={type:`Field`,name:e})}else if(this.check(`STRING`))t=this.advance().value,this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else throw Error(`Expected object key at position ${this.peek().pos}`);e.push({key:t,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 t=this.parseVarBind();e={type:`Pipe`,left:e,right:t}}return e}parseIf(){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then'`);let t=this.parseExpr(),n=[];for(;this.match(`ELIF`);){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then' after elif`);let t=this.parseExpr();n.push({cond:e,then:t})}let r;return this.match(`ELSE`)&&(r=this.parseExpr()),this.expect(`END`,`Expected 'end'`),{type:`Cond`,cond:e,then:t,elifs:n,else:r}}parseStringInterpolation(t){let n=[],r=``,i=0;for(;i<t.length;)if(t[i]===`\\`&&t[i+1]===`(`){r&&=(n.push(r),``),i+=2;let a=1,o=``;for(;i<t.length&&a>0;){let e=t[i];if(e===`"`){for(o+=e,i++;i<t.length;){let e=t[i];if(e===`\\`){o+=e,i++,i<t.length&&(o+=t[i],i++);continue}if(o+=e,i++,e===`"`)break}continue}e===`(`?a++:e===`)`&&a--,a>0&&(o+=e),i++}let s=Vy(o),c=new e(s,this.maxDepth,this.depth);n.push(c.parse())}else r+=t[i],i++;return r&&n.push(r),{type:`StringInterp`,parts:n}}}}),qy=T(()=>{By(),Ky()});function Jy(e,t,n={}){let r=new Ui(t,`query JSON output`,()=>new A(`output size limit exceeded (${t} bytes)`,n.limitKind??`output_size`));return Yy(r,e,n,0),r.build()}function Yy(e,t,n,r){if(t==null){e.append(`null`);return}if(typeof t==`boolean`){e.append(String(t));return}if(typeof t==`number`){e.append(Number.isFinite(t)?String(t):`null`);return}if(typeof t==`string`){n.raw&&r===0?e.append(t):Xy(e,t);return}let i=n.compact??!1,a=n.indent??2,o=n.useTab?` `:` `.repeat(a);if(Array.isArray(t)){e.append(`[`);for(let a=0;a<t.length;a++)e.append(i?a===0?``:`,`:a===0?`
647
647
  `:`,
648
648
  `),i||e.repeat(o,r+1),Yy(e,t[a],n,r+1);!i&&t.length>0&&e.append(`
649
649
  `).repeat(o,r),e.append(`]`);return}let s=Object.keys(t);n.sortKeys&&(s=s.sort()),e.append(`{`);for(let a=0;a<s.length;a++){let c=s[a];e.append(i?a===0?``:`,`:a===0?`
@@ -651,7 +651,7 @@ ${s} director${s===1?`y`:`ies`}`,r.directoriesOnly||(a+=`, ${c} file${c===1?``:`
651
651
  `),i||e.repeat(o,r+1),Xy(e,c),e.append(i?`:`:`: `),Yy(e,t[c],n,r+1)}!i&&s.length>0&&e.append(`
652
652
  `).repeat(o,r),e.append(`}`)}function Xy(e,t){e.append(`"`);let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r),a=``;i===34?a=`\\"`:i===92?a=`\\\\`:i===8?a=`\\b`:i===9?a=`\\t`:i===10?a=`\\n`:i===12?a=`\\f`:i===13?a=`\\r`:i<32&&(a=`\\u${i.toString(16).padStart(4,`0`)}`),a&&(e.append(t.slice(n,r)).append(a),n=r+1)}e.append(t.slice(n)).append(`"`)}var Zy=T(()=>{Wi(),j()}),Qy={};E(Qy,{flagsForFuzzing:()=>ob,jqCommand:()=>ab});function $y(e){switch(e){case`\b`:return`\\b`;case`\f`:return`\\f`;case`
653
653
  `:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;default:return`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`}}function eb(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(r){t+=a,r=!1;continue}if(a===`\\`){t+=a,r=!0;continue}if(a===`"`){t+=a,n=!n;continue}if(n&&a.charCodeAt(0)<=31){t+=$y(a);continue}t+=a}return t}function tb(e,t,n){return JSON.parse(eb(e.slice(t,n)))}function nb(e,t){let n=[],r=e=>{if(n.length>=t.maxElements)throw new A(`query result element limit exceeded (${t.maxElements})`,`array_elements`);n.push(e)},i=0,a=e.length;for(;i<a;){for(;i<a&&/\s/.test(e[i]);)i++;if(i>=a)break;let n=i,o=e[i];if(o===`{`||o===`[`){let s=[o===`{`?`}`:`]`],c=!1,l=!1;for(i++;i<a&&s.length>0;){let n=e[i];if(l)l=!1;else if(n===`\\`)l=!0;else if(n===`"`)c=!c;else if(!c){if(n===`{`||n===`[`){if(s.push(n===`{`?`}`:`]`),s.length>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`)}else if((n===`}`||n===`]`)&&s.pop()!==n)throw Error(`Mismatched JSON delimiter at position ${i}`)}i++}if(s.length!==0)throw Error(`Unexpected end of JSON input at position ${i} (unclosed ${o})`);r(hl(tb(e,n,i),{maxDepth:t.maxDepth,maxElements:t.maxElements}))}else if(o===`"`){let o=!1;for(i++;i<a;){let t=e[i];if(o)o=!1;else if(t===`\\`)o=!0;else if(t===`"`){i++;break}i++}r(hl(tb(e,n,i),t))}else if(o===`-`||o>=`0`&&o<=`9`){for(;i<a&&/[\d.eE+-]/.test(e[i]);)i++;r(hl(tb(e,n,i),t))}else if(e.slice(i,i+4)===`true`)r(!0),i+=4;else if(e.slice(i,i+5)===`false`)r(!1),i+=5;else if(e.slice(i,i+4)===`null`)r(null),i+=4;else{let t=e.slice(i,i+10);throw Error(`Invalid JSON at position ${n}: unexpected '${t.split(/\s/)[0]}'`)}}return n}function rb(e){return{stdout:``,stderr:`jq: ${e}
654
- `,exitCode:2}}var ib,ab,ob,sb=T(()=>{k(),ea(),j(),Su(),qn(),Zr(),F(),Lr(),qy(),Zy(),xl(),Av(),ib={name:`jq`,summary:`command-line JSON processor`,usage:`jq [OPTIONS] FILTER [FILE...]`,options:[`-R, --raw-input read each line as string instead of JSON`,`-r, --raw-output output strings without quotes`,`-c, --compact-output compact instead of pretty-printed output`,`-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`,` --arg NAME VALUE bind $NAME to the string VALUE`,` --argjson NAME JSON bind $NAME to the JSON-decoded value JSON`,` --rawfile NAME FILE bind $NAME to the raw contents of FILE`,` --slurpfile NAME FILE bind $NAME to the array of JSON values in FILE`,` --args remaining arguments are string positional args ($ARGS.positional)`,` --jsonargs remaining arguments are JSON positional args ($ARGS.positional)`,` --help display this help and exit`]},ab={name:`jq`,async execute(e,t){bu(t.requireDefenseContext,`jq`,`execution entry`);let n=(e,n)=>xu(t.requireDefenseContext,`jq`,e,n);if(N(e))return M(ib);let r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=`.`,p=!1,m=`none`,h=[],g=new Map,_=[],v=[],y={maxDepth:t.limits.maxQueryDepth,maxElements:t.limits.maxQueryElements};for(let t=0;t<e.length;t++){let n=e[t];if(n===`-R`||n===`--raw-input`)i=!0;else if(n===`-r`||n===`--raw-output`)r=!0;else if(n===`-c`||n===`--compact-output`)a=!0;else if(n===`-e`||n===`--exit-status`)o=!0;else if(n===`-s`||n===`--slurp`)s=!0;else if(n===`-n`||n===`--null-input`)c=!0;else if(n===`-j`||n===`--join-output`)l=!0;else if(n!==`-a`&&n!==`--ascii`){if(n===`-S`||n===`--sort-keys`)u=!0;else if(n!==`-C`&&n!==`--color`&&n!==`-M`&&n!==`--monochrome`)if(n===`--tab`)d=!0;else if(n===`--arg`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--arg takes two parameters (e.g. --arg varname value)`);g.set(n,r),t+=2}else if(n===`--argjson`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--argjson takes two parameters (e.g. --argjson varname text)`);let i;try{i=nb(r.trim(),y)}catch{return rb(`invalid JSON text passed to --argjson`)}if(i.length!==1)return rb(`invalid JSON text passed to --argjson`);g.set(n,i[0]),t+=2}else if(n===`--rawfile`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--rawfile takes two parameters (e.g. --rawfile varname filename)`);v.push({name:n,file:r,mode:`raw`}),t+=2}else if(n===`--slurpfile`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--slurpfile takes two parameters (e.g. --slurpfile varname filename)`);v.push({name:n,file:r,mode:`slurp`}),t+=2}else if(n===`--args`)m=`args`;else if(n===`--jsonargs`)m=`jsonargs`;else if(n===`-`)h.push(`-`);else{if(n.startsWith(`--`))return P(`jq`,n);if(n.startsWith(`-`)){for(let e of n.slice(1))if(e===`R`)i=!0;else if(e===`r`)r=!0;else if(e===`c`)a=!0;else if(e===`e`)o=!0;else if(e===`s`)s=!0;else if(e===`n`)c=!0;else if(e===`j`)l=!0;else if(e!==`a`){if(e===`S`)u=!0;else if(e!==`C`&&e!==`M`)return P(`jq`,`-${e}`)}}else if(!p)f=n,p=!0;else if(m===`args`)_.push(n);else if(m===`jsonargs`){let e;try{e=nb(n.trim(),y)}catch{return rb(`invalid JSON text passed to --jsonargs`)}if(e.length!==1)return rb(`invalid JSON text passed to --jsonargs`);_.push(e[0])}else h.push(n)}}}if(v.length>0){let e=await n(`arg file read`,()=>Yr(t,v.map(e=>e.file),{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};for(let t=0;t<v.length;t++){let{name:n,mode:r}=v[t],i=or(e.files[t].content);if(r===`raw`)g.set(n,i);else{let e=i.trim();try{g.set(n,e?nb(e,y):[])}catch{return rb(`invalid JSON text passed to --slurpfile`)}}}}let b=[];if(!c)if(h.length===0||h.length===1&&h[0]===`-`)b.push({source:`stdin`,content:or(t.stdin)});else{let e=await n(`file read`,()=>Yr(t,h,{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};b=e.files.map(e=>({source:e.filename||`stdin`,content:or(e.content)}))}try{let e=Hy(f,{maxDepth:t.limits.maxQueryDepth,maxTokens:t.limits.maxQueryTokens,maxSourceLength:t.limits.maxStringLength}),n=[],p={limits:t.limits?{maxIterations:t.limits.maxJqIterations,maxStringLength:t.limits.maxStringLength,maxOutputSize:t.limits.maxOutputSize,maxArrayElements:t.limits.maxQueryElements,maxDepth:t.limits.maxQueryDepth}:void 0,env:t.env,namedArgs:g,positionalArgs:_,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext,budget:{operations:0,callDepth:0}},m=(e,n)=>{if(n.length>t.limits.maxQueryElements-e.length)throw new A(`query result element limit exceeded (${t.limits.maxQueryElements})`,`array_elements`);for(let t of n)e.push(t)};if(c)n=J(null,e,p);else if(i&&s)n=J(b.map(({content:e})=>e).join(``),e,p);else if(i){let t=``;for(let{content:r}of b){let i=t+r,a=0,o=i.indexOf(`
654
+ `,exitCode:2}}var ib,ab,ob,sb=T(()=>{k(),ea(),j(),Su(),qn(),Zr(),F(),Lr(),qy(),Zy(),xl(),Av(),ib={name:`jq`,summary:`command-line JSON processor`,usage:`jq [OPTIONS] FILTER [FILE...]`,options:[`-R, --raw-input read each line as string instead of JSON`,`-r, --raw-output output strings without quotes`,`-c, --compact-output compact instead of pretty-printed output`,`-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`,` --arg NAME VALUE bind $NAME to the string VALUE`,` --argjson NAME JSON bind $NAME to the JSON-decoded value JSON`,` --rawfile NAME FILE bind $NAME to the raw contents of FILE`,` --slurpfile NAME FILE bind $NAME to the array of JSON values in FILE`,` --args remaining arguments are string positional args ($ARGS.positional)`,` --jsonargs remaining arguments are JSON positional args ($ARGS.positional)`,` --help display this help and exit`]},ab={name:`jq`,async execute(e,t){bu(t.requireDefenseContext,`jq`,`execution entry`);let n=(e,n)=>xu(t.requireDefenseContext,`jq`,e,n);if(N(e))return M(ib);let r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=`.`,p=!1,m=`none`,h=[],g=new Map,_=[],v=[],y={maxDepth:t.limits.maxQueryDepth,maxElements:t.limits.maxQueryElements};for(let t=0;t<e.length;t++){let n=e[t];if(n===`-R`||n===`--raw-input`)i=!0;else if(n===`-r`||n===`--raw-output`)r=!0;else if(n===`-c`||n===`--compact-output`)a=!0;else if(n===`-e`||n===`--exit-status`)o=!0;else if(n===`-s`||n===`--slurp`)s=!0;else if(n===`-n`||n===`--null-input`)c=!0;else if(n===`-j`||n===`--join-output`)l=!0;else if(n!==`-a`&&n!==`--ascii`){if(n===`-S`||n===`--sort-keys`)u=!0;else if(n!==`-C`&&n!==`--color`&&n!==`-M`&&n!==`--monochrome`){if(n===`--tab`)d=!0;else if(n===`--arg`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--arg takes two parameters (e.g. --arg varname value)`);g.set(n,r),t+=2}else if(n===`--argjson`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--argjson takes two parameters (e.g. --argjson varname text)`);let i;try{i=nb(r.trim(),y)}catch{return rb(`invalid JSON text passed to --argjson`)}if(i.length!==1)return rb(`invalid JSON text passed to --argjson`);g.set(n,i[0]),t+=2}else if(n===`--rawfile`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--rawfile takes two parameters (e.g. --rawfile varname filename)`);v.push({name:n,file:r,mode:`raw`}),t+=2}else if(n===`--slurpfile`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--slurpfile takes two parameters (e.g. --slurpfile varname filename)`);v.push({name:n,file:r,mode:`slurp`}),t+=2}else if(n===`--args`)m=`args`;else if(n===`--jsonargs`)m=`jsonargs`;else if(n===`-`)h.push(`-`);else{if(n.startsWith(`--`))return P(`jq`,n);if(n.startsWith(`-`)){for(let e of n.slice(1))if(e===`R`)i=!0;else if(e===`r`)r=!0;else if(e===`c`)a=!0;else if(e===`e`)o=!0;else if(e===`s`)s=!0;else if(e===`n`)c=!0;else if(e===`j`)l=!0;else if(e!==`a`){if(e===`S`)u=!0;else if(e!==`C`&&e!==`M`)return P(`jq`,`-${e}`)}}else if(!p)f=n,p=!0;else if(m===`args`)_.push(n);else if(m===`jsonargs`){let e;try{e=nb(n.trim(),y)}catch{return rb(`invalid JSON text passed to --jsonargs`)}if(e.length!==1)return rb(`invalid JSON text passed to --jsonargs`);_.push(e[0])}else h.push(n)}}}}if(v.length>0){let e=await n(`arg file read`,()=>Yr(t,v.map(e=>e.file),{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};for(let t=0;t<v.length;t++){let{name:n,mode:r}=v[t],i=or(e.files[t].content);if(r===`raw`)g.set(n,i);else{let e=i.trim();try{g.set(n,e?nb(e,y):[])}catch{return rb(`invalid JSON text passed to --slurpfile`)}}}}let b=[];if(!c){if(h.length===0||h.length===1&&h[0]===`-`)b.push({source:`stdin`,content:or(t.stdin)});else{let e=await n(`file read`,()=>Yr(t,h,{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};b=e.files.map(e=>({source:e.filename||`stdin`,content:or(e.content)}))}}try{let e=Hy(f,{maxDepth:t.limits.maxQueryDepth,maxTokens:t.limits.maxQueryTokens,maxSourceLength:t.limits.maxStringLength}),n=[],p={limits:t.limits?{maxIterations:t.limits.maxJqIterations,maxStringLength:t.limits.maxStringLength,maxOutputSize:t.limits.maxOutputSize,maxArrayElements:t.limits.maxQueryElements,maxDepth:t.limits.maxQueryDepth}:void 0,env:t.env,namedArgs:g,positionalArgs:_,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext,budget:{operations:0,callDepth:0}},m=(e,n)=>{if(n.length>t.limits.maxQueryElements-e.length)throw new A(`query result element limit exceeded (${t.limits.maxQueryElements})`,`array_elements`);for(let t of n)e.push(t)};if(c)n=J(null,e,p);else if(i&&s)n=J(b.map(({content:e})=>e).join(``),e,p);else if(i){let t=``;for(let{content:r}of b){let i=t+r,a=0,o=i.indexOf(`
655
655
  `,a);for(;o!==-1;)m(n,J(i.slice(a,o),e,p)),a=o+1,o=i.indexOf(`
656
656
  `,a);t=i.slice(a)}t!==``&&m(n,J(t,e,p))}else if(s){let t=[];for(let{content:e}of b){let n=e.trim();n&&m(t,nb(n,y))}n=J(t,e,p)}else for(let{content:t}of b){let r=t.trim();if(!r)continue;let i=nb(r,y);for(let t of i)m(n,J(t,e,p))}let h=l?``:`
657
657
  `,v=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),x=[],S=0;for(let e of n){let n=x.length>0?h.length:0,i=+!l,o=v-S-n-i;if(o<0)throw new A(`output size limit exceeded (${v} bytes)`,`string_length`);if(Dv(e,t.limits.maxQueryDepth+1)>t.limits.maxQueryDepth)throw new A(`query depth limit exceeded (${t.limits.maxQueryDepth})`,`recursion`);let s=Jy(e,o,{compact:a,raw:r,sortKeys:u,useTab:d,limitKind:`string_length`}),c=O(s);if(S+n+c+i>v)throw new A(`output size limit exceeded (${v} bytes)`,`string_length`);S+=n+c,x.push(s)}let ee=x.join(h),C=o&&(n.length===0||n.every(e=>e==null||e===!1))?1:0;return{stdout:ee?l?ee:`${ee}
@@ -684,7 +684,7 @@ DURATION is a number with optional suffix:
684
684
  s - seconds (default)
685
685
  m - minutes
686
686
  h - hours
687
- d - days`,options:[`-k, --kill-after=DURATION send KILL signal after DURATION if still running`,`-s, --signal=SIGNAL specify signal to send (default: TERM)`,` --preserve-status exit with same status as COMMAND, even on timeout`,` --foreground run command in foreground`,` --help display this help and exit`]},Ub={name:`timeout`,async execute(e,t){if(N(e))return M(Hb);let n=0;for(let t=0;t<e.length;t++){let r=e[t];if(r===`--preserve-status`)n=t+1;else if(r===`--foreground`)n=t+1;else if(r===`-k`||r===`--kill-after`)t++,n=t+1;else if(r.startsWith(`--kill-after=`))n=t+1;else if(r===`-s`||r===`--signal`)t++,n=t+1;else if(r.startsWith(`--signal=`))n=t+1;else{if(r.startsWith(`--`)&&r!==`--`)return P(`timeout`,r);if(r.startsWith(`-`)&&r.length>1&&r!==`--`)if(r.startsWith(`-k`))n=t+1;else if(r.startsWith(`-s`))n=t+1;else return P(`timeout`,r);else{n=t;break}}}let r=e.slice(n);if(r.length===0)return{stdout:``,stderr:`timeout: missing operand
687
+ d - days`,options:[`-k, --kill-after=DURATION send KILL signal after DURATION if still running`,`-s, --signal=SIGNAL specify signal to send (default: TERM)`,` --preserve-status exit with same status as COMMAND, even on timeout`,` --foreground run command in foreground`,` --help display this help and exit`]},Ub={name:`timeout`,async execute(e,t){if(N(e))return M(Hb);let n=0;for(let t=0;t<e.length;t++){let r=e[t];if(r===`--preserve-status`)n=t+1;else if(r===`--foreground`)n=t+1;else if(r===`-k`||r===`--kill-after`)t++,n=t+1;else if(r.startsWith(`--kill-after=`))n=t+1;else if(r===`-s`||r===`--signal`)t++,n=t+1;else if(r.startsWith(`--signal=`))n=t+1;else{if(r.startsWith(`--`)&&r!==`--`)return P(`timeout`,r);if(r.startsWith(`-`)&&r.length>1&&r!==`--`){if(r.startsWith(`-k`))n=t+1;else if(r.startsWith(`-s`))n=t+1;else return P(`timeout`,r)}else{n=t;break}}}let r=e.slice(n);if(r.length===0)return{stdout:``,stderr:`timeout: missing operand
688
688
  `,exitCode:1};let i=r[0],a=Nb(i);if(a===null)return{stdout:``,stderr:`timeout: invalid time interval '${i}'
689
689
  `,exitCode:1};let o=r.slice(1);if(o.length===0)return{stdout:``,stderr:`timeout: missing operand
690
690
  `,exitCode:1};if(!t.exec)return{stdout:``,stderr:`timeout: exec not available
@@ -715,12 +715,12 @@ sys 0.00
715
715
  `,l||n++}}return n>0&&(r+=`${e}: WARNING: ${n} computed checksum${n>1?`s`:``} did NOT match
716
716
  `),{stdout:r,stderr:``,exitCode:+(n>0)}}let c=``,l=0;for(let n of o){let r=await s(n);if(r===null){c+=`${e}: ${n}: No such file or directory
717
717
  `,l=1;continue}c+=`${await dx(t,r)} ${n}
718
- `}return{stdout:c,stderr:``,exitCode:l}}}}var px,mx=T(()=>{k(),F(),px=new Map([[`sha1`,`SHA-1`],[`sha256`,`SHA-256`]])}),hx={};E(hx,{flagsForFuzzing:()=>_x,md5sumCommand:()=>gx});var gx,_x,vx=T(()=>{mx(),gx=fx(`md5sum`,`md5`,`compute MD5 message digest`),_x={name:`md5sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),yx={};E(yx,{flagsForFuzzing:()=>xx,sha1sumCommand:()=>bx});var bx,xx,Sx=T(()=>{mx(),bx=fx(`sha1sum`,`sha1`,`compute SHA1 message digest`),xx={name:`sha1sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),Cx={};E(Cx,{flagsForFuzzing:()=>Tx,sha256sumCommand:()=>wx});var wx,Tx,Ex=T(()=>{mx(),wx=fx(`sha256sum`,`sha256`,`compute SHA256 message digest`),Tx={name:`sha256sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),Dx=pn(e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else{if(a===c)return o?NaN:(p?-1:1)*(1/0);o+=2**r,a-=l}return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}});function Ox(){if(!(typeof globalThis.TextDecoder>`u`))return Bx??=new globalThis.TextDecoder(`utf-8`)}function kx(e,t=`utf-8`){switch(t.toLowerCase()){case`utf-8`:case`utf8`:{let t=Ox();return t?t.decode(e):Nx(e)}case`utf-16le`:return Px(e);case`us-ascii`:case`ascii`:return Fx(e);case`latin1`:case`iso-8859-1`:return Ix(e);case`windows-1252`:return Lx(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function Ax(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function jx(e,t,n){t.push(n),t.length>=Vx&&Ax(e,t)}function Mx(e,t,n){if(n<=65535){jx(e,t,n);return}n-=65536,jx(e,t,55296+(n>>10)),jx(e,t,56320+(n&1023))}function Nx(e){let t=[],n=[],r=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(r=3);r<e.length;){let i=e[r];if(i<=127){jx(t,n,i),r++;continue}if(i<194||i>244){jx(t,n,Hx),r++;continue}if(i<=223){if(r+1>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1];if((a&192)!=128){jx(t,n,Hx),r++;continue}jx(t,n,(i&31)<<6|a&63),r+=2;continue}if(i<=239){if(r+2>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1],o=e[r+2];if(!((a&192)==128&&(o&192)==128&&!(i===224&&a<160)&&!(i===237&&a>=160))){jx(t,n,Hx),r++;continue}jx(t,n,(i&15)<<12|(a&63)<<6|o&63),r+=3;continue}if(r+3>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1],o=e[r+2],s=e[r+3];if(!((a&192)==128&&(o&192)==128&&(s&192)==128&&!(i===240&&a<144)&&!(i===244&&a>143))){jx(t,n,Hx),r++;continue}Mx(t,n,(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63),r+=4}return Ax(t,n),t.join(``)}function Px(e){let t=[],n=[],r=e.length,i=0;for(;i+1<r;){let a=e[i]|e[i+1]<<8;if(i+=2,a>=55296&&a<=56319){if(i+1<r){let r=e[i]|e[i+1]<<8;r>=56320&&r<=57343?(jx(t,n,a),jx(t,n,r),i+=2):jx(t,n,Hx)}else jx(t,n,Hx);continue}if(a>=56320&&a<=57343){jx(t,n,Hx);continue}jx(t,n,a)}return i<r&&jx(t,n,Hx),Ax(t,n),t.join(``)}function Fx(e){let t=[];for(let n=0;n<e.length;n+=Vx){let r=Math.min(e.length,n+Vx),i=Array(r-n);for(let t=n,a=0;t<r;t++,a++)i[a]=e[t]&127;t.push(String.fromCharCode.apply(null,i))}return t.join(``)}function Ix(e){let t=[];for(let n=0;n<e.length;n+=Vx){let r=Math.min(e.length,n+Vx),i=Array(r-n);for(let t=n,a=0;t<r;t++,a++)i[a]=e[t];t.push(String.fromCharCode.apply(null,i))}return t.join(``)}function Lx(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r],a=i>=128&&i<=159?Rx[i]:void 0;n+=a??String.fromCharCode(i),n.length>=Vx&&(t.push(n),n=``)}return n&&t.push(n),t.join(``)}var Rx,zx,Bx,Vx,Hx,Ux=T(()=>{Rx={128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`},zx={};for(let[e,t]of Object.entries(Rx))zx[t]=Number.parseInt(e,10);Vx=32768,Hx=65533});function Wx(e){return new DataView(e.buffer,e.byteOffset)}var Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x=T(()=>{hn(Dx(),1),Ux(),Gx={len:1,get(e,t){return Wx(e).getUint8(t)},put(e,t,n){return Wx(e).setUint8(t,n),t+1}},Kx={len:2,get(e,t){return Wx(e).getUint16(t,!0)},put(e,t,n){return Wx(e).setUint16(t,n,!0),t+2}},qx={len:2,get(e,t){return Wx(e).getUint16(t)},put(e,t,n){return Wx(e).setUint16(t,n),t+2}},Jx={len:4,get(e,t){return Wx(e).getUint32(t,!0)},put(e,t,n){return Wx(e).setUint32(t,n,!0),t+4}},Yx={len:4,get(e,t){return Wx(e).getUint32(t)},put(e,t,n){return Wx(e).setUint32(t,n),t+4}},Xx={len:4,get(e,t){return Wx(e).getInt32(t)},put(e,t,n){return Wx(e).setInt32(t,n),t+4}},Zx={len:8,get(e,t){return Wx(e).getBigUint64(t,!0)},put(e,t,n){return Wx(e).setBigUint64(t,n,!0),t+8}},Qx=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){return kx(e.subarray(t,t+this.len),this.encoding)}}}),eS,tS,nS,rS=T(()=>{eS=`End-Of-Stream`,tS=class extends Error{constructor(){super(eS),this.name=`EndOfStreamError`}},nS=class extends Error{constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}}}),iS=T(()=>{}),aS,oS=T(()=>{rS(),aS=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new tS;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let r=this.peekQueue.pop();if(!r)throw Error(`peekData should be defined`);let i=Math.min(r.length,t);e.set(r.subarray(0,i),n),n+=i,t-=i,i<r.length&&this.peekQueue.push(r.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new nS;let r=await this.readFromStream(e.subarray(n),t);if(r===0)break;n+=r}if(!t&&n<e.length)throw new tS;return n}}}),sS=T(()=>{rS(),iS(),oS()}),cS,lS=T(()=>{oS(),cS=class extends aS{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}}),uS,dS=T(()=>{lS(),uS=class extends cS{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}}}),fS,pS=T(()=>{rS(),oS(),fS=class extends aS{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),this.buffer=n<t.length?t.subarray(n):null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(n+=this.writeChunk(e.subarray(n),t.value))}if(!t&&n===0&&this.endOfStream)throw new tS;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function mS(e){try{let t=e.getReader({mode:`byob`});return t instanceof ReadableStreamDefaultReader?new fS(t):new uS(t)}catch(t){if(t instanceof TypeError)return new fS(e.getReader());throw t}}var hS=T(()=>{dS(),pS()}),gS=T(()=>{rS(),sS(),dS(),pS(),hS()}),_S,vS=T(()=>{gS(),_S=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener(`abort`,()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})<e.len)throw new tS;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:t})<e.len)throw new tS;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new tS;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new tS;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw RangeError(`ignore length must be ≥ 0 bytes`);if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}}}),yS,bS,xS=T(()=>{vS(),gS(),yS=256e3,bS=class extends _S{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new tS;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=0;if(n.position){let t=n.position-this.position;if(t>0){let i=new Uint8Array(n.length+t);return r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),e.set(i.subarray(t)),r-t}if(t<0)throw Error(`Cannot peek from a negative offset in a stream`)}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof tS)return 0;throw e}if(!n.mayBeLess&&r<n.length)throw new tS}return r}async ignore(e){if(e<0)throw RangeError(`ignore length must be ≥ 0 bytes`);let t=Math.min(yS,e),n=new Uint8Array(t),r=0;for(;r<e;){let i=e-r,a=await this.readBuffer(n,{length:Math.min(t,i)});if(a<0)return a;r+=a}return r}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}}),SS,CS=T(()=>{gS(),vS(),SS=class extends _S{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new tS;return e.set(this.uint8Array.subarray(n.position,n.position+r)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}}),wS,TS=T(()=>{gS(),vS(),wS=class extends _S{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new tS;let i=await this.blob.slice(n.position,n.position+r).arrayBuffer();return e.set(new Uint8Array(i)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});function ES(e,t){let n=mS(e),r=t??{},i=r.onClose;return r.onClose=async()=>{if(await n.close(),i)return i()},new bS(n,r)}function DS(e,t){return new SS(e,t)}function OS(e,t){return new wS(e,t)}var kS=T(()=>{gS(),xS(),CS(),TS(),gS(),vS()}),AS=pn((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}),jS=pn((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=AS(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(typeof t>`u`?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n}),MS=pn((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t={}.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=jS()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}}),NS,PS,FS,IS,LS,RS=T(()=>{$x(),NS={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},PS={get(e){return{signature:Jx.get(e,0),compressedSize:Jx.get(e,8),uncompressedSize:Jx.get(e,12)}},len:16},FS={get(e){let t=Kx.get(e,6);return{signature:Jx.get(e,0),minVersion:Kx.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Kx.get(e,8),compressedSize:Jx.get(e,18),uncompressedSize:Jx.get(e,22),filenameLength:Kx.get(e,26),extraFieldLength:Kx.get(e,28),filename:null}},len:30},IS={get(e){return{signature:Jx.get(e,0),nrOfThisDisk:Kx.get(e,4),nrOfThisDiskWithTheStart:Kx.get(e,6),nrOfEntriesOnThisDisk:Kx.get(e,8),nrOfEntriesOfSize:Kx.get(e,10),sizeOfCd:Jx.get(e,12),offsetOfStartOfCd:Jx.get(e,16),zipFileCommentLength:Kx.get(e,20)}},len:22},LS={get(e){let t=Kx.get(e,8);return{signature:Jx.get(e,0),minVersion:Kx.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Kx.get(e,10),compressedSize:Jx.get(e,20),uncompressedSize:Jx.get(e,24),filenameLength:Kx.get(e,28),extraFieldLength:Kx.get(e,30),fileCommentLength:Kx.get(e,32),relativeOffsetOfLocalHeader:Jx.get(e,42),filename:null}},len:46}});function zS(e){let t=new Uint8Array(Jx.len);return Jx.put(t,0,e),t}function BS(e,t){let n=e.length,r=t.length;if(r>n)return-1;for(let i=0;i<=n-r;i++){let n=!0;for(let a=0;a<r;a++)if(e[i+a]!==t[a]){n=!1;break}if(n)return i}return-1}function VS(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var HS,US,WS,GS,KS,qS,JS=T(()=>{$x(),HS=hn(MS(),1),RS(),US=(0,HS.default)(`tokenizer:inflate`),WS=262144,GS=zS(NS.DataDescriptor),KS=zS(NS.EndOfCentralDirectory),qS=class e{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(WS)}async isZip(){return await this.peekSignature()===NS.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Jx)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16384,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let r=n.length-4;r>=0;r--)if(n[r]===KS[0]&&n[r+1]===KS[1]&&n[r+2]===KS[2]&&n[r+3]===KS[3])return e.fileInfo.size-t+r;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){US(`Cannot reading central-directory without random-read support`);return}US(`Reading central-directory...`);let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){US(`Central-directory 32-bit signature found`);let n=await this.tokenizer.readToken(IS,t),r=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let e=0;e<n.nrOfEntriesOfSize;++e){let t=await this.tokenizer.readToken(LS);if(t.signature!==NS.CentralFileHeader)throw Error(`Expected Central-File-Header signature`);t.filename=await this.tokenizer.readToken(new Qx(t.filenameLength,`utf-8`)),await this.tokenizer.ignore(t.extraFieldLength),await this.tokenizer.ignore(t.fileCommentLength),r.push(t),US(`Add central-directory file-entry: n=${e+1}/${r.length}: filename=${r[e].filename}`)}return this.tokenizer.setPosition(e),r}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let n=!1;do{let t=await this.readLocalFileHeader();if(!t)break;let r=e(t);n=!!r.stop;let i;if(await this.tokenizer.ignore(t.extraFieldLength),t.dataDescriptor&&t.compressedSize===0){let e=[],n=WS;US(`Compressed-file-size unknown, scanning for next data-descriptor-signature....`);let i=-1;for(;i<0&&n===WS;){n=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),i=BS(this.syncBuffer.subarray(0,n),GS);let t=i>=0?i:n;if(r.handler){let n=new Uint8Array(t);await this.tokenizer.readBuffer(n),e.push(n)}else await this.tokenizer.ignore(t)}US(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),r.handler&&await this.inflate(t,VS(e),r.handler)}else r.handler?(US(`Reading compressed-file-data: ${t.compressedSize} bytes`),i=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(t,i,r.handler)):(US(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(US(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor&&(await this.tokenizer.readToken(PS)).signature!==134695760)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-PS.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let e=t(n);if(e.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);let r=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(r),await this.inflate(t,r,e.handler)}}if(e.stop)break}}async inflate(t,n,r){if(t.compressedMethod===0)return r(n);if(t.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);return US(`Decompress filename=${t.filename}, compressed-size=${n.length}`),r(await e.decompressDeflateRaw(n))}static async decompressDeflateRaw(e){let t=new ReadableStream({start(t){t.enqueue(e),t.close()}}),n=new DecompressionStream(`deflate-raw`),r=t.pipeThrough(n);try{let e=await new Response(r).arrayBuffer();return new Uint8Array(e)}catch(e){let t=e instanceof Error?`Failed to deflate ZIP entry: ${e.message}`:`Unknown decompression error in ZIP entry`;throw TypeError(t)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(Jx);if(e===NS.LocalFileHeader){let e=await this.tokenizer.readToken(FS);return e.filename=await this.tokenizer.readToken(new Qx(e.filenameLength,`utf-8`)),e}if(e===NS.CentralFileHeader)return!1;throw Error(e===3759263696?`Encrypted ZIP`:`Unexpected signature`)}}}),YS,XS=T(()=>{YS=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),r=await e.readBuffer(n,{mayBeLess:!0});if(r===0){t.close();return}t.enqueue(n.subarray(0,r))}}).pipeThrough(new DecompressionStream(`gzip`))}}}),ZS=T(()=>{JS(),XS()});function QS(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}var $S=T(()=>{new globalThis.TextDecoder(`utf8`),new globalThis.TextEncoder,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`))});function eC(e,t){if(t===`utf-16le`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r&255,r>>8&255)}return t}if(t===`utf-16be`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r>>8&255,r&255)}return t}return[...e].map(e=>e.charCodeAt(0))}function tC(e,t=0){let n=Number.parseInt(new Qx(6).get(e,148).replace(/\0.*$/,``).trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let n=t;n<t+148;n++)r+=e[n];for(let n=t+156;n<t+512;n++)r+=e[n];return n===r}var nC,rC=T(()=>{$x(),nC={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}}),iC,aC,oC=T(()=>{iC=`jpg,png,apng,gif,webp,flif,xcf,cr2,cr3,orf,arw,dng,nef,rw2,raf,tif,bmp,icns,jxr,psd,indd,zip,tar,rar,gz,bz2,7z,dmg,mp4,mid,mkv,webm,mov,avi,mpg,mp2,mp3,m4a,oga,ogg,ogv,opus,flac,wav,spx,amr,pdf,epub,elf,macho,exe,swf,rtf,wasm,woff,woff2,eot,ttf,otf,ttc,ico,flv,ps,xz,sqlite,nes,crx,xpi,cab,deb,ar,rpm,Z,lz,cfb,mxf,mts,blend,bpg,docx,pptx,xlsx,3gp,3g2,j2c,jp2,jpm,jpx,mj2,aif,qcp,odt,ods,odp,xml,mobi,heic,cur,ktx,ape,wv,dcm,ics,glb,pcap,dsf,lnk,alias,voc,ac3,m4v,m4p,m4b,f4v,f4p,f4b,f4a,mie,asf,ogm,ogx,mpc,arrow,shp,aac,mp1,it,s3m,xm,skp,avif,eps,lzh,pgp,asar,stl,chm,3mf,zst,jxl,vcf,jls,pst,dwg,parquet,class,arj,cpio,ace,avro,icc,fbx,vsdx,vtt,apk,drc,lz4,potx,xltx,dotx,xltm,ott,ots,otp,odg,otg,xlsm,docm,dotm,potm,pptm,jar,jmp,rm,sav,ppsm,ppsx,tar.gz,reg,dat`.split(`,`),aC=`image/jpeg,image/png,image/gif,image/webp,image/flif,image/x-xcf,image/x-canon-cr2,image/x-canon-cr3,image/tiff,image/bmp,image/vnd.ms-photo,image/vnd.adobe.photoshop,application/x-indesign,application/epub+zip,application/x-xpinstall,application/vnd.ms-powerpoint.slideshow.macroenabled.12,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/zip,application/x-tar,application/x-rar-compressed,application/gzip,application/x-bzip2,application/x-7z-compressed,application/x-apple-diskimage,application/vnd.apache.arrow.file,video/mp4,audio/midi,video/matroska,video/webm,video/quicktime,video/vnd.avi,audio/wav,audio/qcelp,audio/x-ms-asf,video/x-ms-asf,application/vnd.ms-asf,video/mpeg,video/3gpp,audio/mpeg,audio/mp4,video/ogg,audio/ogg,audio/ogg; codecs=opus,application/ogg,audio/flac,audio/ape,audio/wavpack,audio/amr,application/pdf,application/x-elf,application/x-mach-binary,application/x-msdownload,application/x-shockwave-flash,application/rtf,application/wasm,font/woff,font/woff2,application/vnd.ms-fontobject,font/ttf,font/otf,font/collection,image/x-icon,video/x-flv,application/postscript,application/eps,application/x-xz,application/x-sqlite3,application/x-nintendo-nes-rom,application/x-google-chrome-extension,application/vnd.ms-cab-compressed,application/x-deb,application/x-unix-archive,application/x-rpm,application/x-compress,application/x-lzip,application/x-cfb,application/x-mie,application/mxf,video/mp2t,application/x-blender,image/bpg,image/j2c,image/jp2,image/jpx,image/jpm,image/mj2,audio/aiff,application/xml,application/x-mobipocket-ebook,image/heif,image/heif-sequence,image/heic,image/heic-sequence,image/icns,image/ktx,application/dicom,audio/x-musepack,text/calendar,text/vcard,text/vtt,model/gltf-binary,application/vnd.tcpdump.pcap,audio/x-dsf,application/x.ms.shortcut,application/x.apple.alias,audio/x-voc,audio/vnd.dolby.dd-raw,audio/x-m4a,image/apng,image/x-olympus-orf,image/x-sony-arw,image/x-adobe-dng,image/x-nikon-nef,image/x-panasonic-rw2,image/x-fujifilm-raf,video/x-m4v,video/3gpp2,application/x-esri-shape,audio/aac,audio/x-it,audio/x-s3m,audio/x-xm,video/MP1S,video/MP2P,application/vnd.sketchup.skp,image/avif,application/x-lzh-compressed,application/pgp-encrypted,application/x-asar,model/stl,application/vnd.ms-htmlhelp,model/3mf,image/jxl,application/zstd,image/jls,application/vnd.ms-outlook,image/vnd.dwg,application/vnd.apache.parquet,application/java-vm,application/x-arj,application/x-cpio,application/x-ace-compressed,application/avro,application/vnd.iccprofile,application/x.autodesk.fbx,application/vnd.visio,application/vnd.android.package-archive,application/vnd.google.draco,application/x-lz4,application/vnd.openxmlformats-officedocument.presentationml.template,application/vnd.openxmlformats-officedocument.spreadsheetml.template,application/vnd.openxmlformats-officedocument.wordprocessingml.template,application/vnd.ms-excel.template.macroenabled.12,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.spreadsheet-template,application/vnd.oasis.opendocument.presentation-template,application/vnd.oasis.opendocument.graphics,application/vnd.oasis.opendocument.graphics-template,application/vnd.ms-excel.sheet.macroenabled.12,application/vnd.ms-word.document.macroenabled.12,application/vnd.ms-word.template.macroenabled.12,application/vnd.ms-powerpoint.template.macroenabled.12,application/vnd.ms-powerpoint.presentation.macroenabled.12,application/java-archive,application/vnd.rn-realmedia,application/x-spss-sav,application/x-ms-regedit,application/x-ft-windows-registry-hive,application/x-jmp-data`.split(`,`)});function sC(e){let t=e?.streamReader;if(t?.constructor?.name!==`WebStreamByobReader`)return e;let{reader:n}=t,r=async()=>{await n.cancel(),n.releaseLock()};return t.close=r,t.abort=async()=>{t.interrupted=!0,await r()},e}function cC(e,t,n){if(!Number.isFinite(e)||e<0||e>t)throw new cw(`${n} has invalid size ${e} (maximum ${t} bytes)`);return e}async function lC(e,t,{maximumLength:n=BC,reason:r=`skip`}={}){let i=cC(t,n,r);await e.ignore(i)}async function uC(e,t,n,{maximumLength:r=t.length,reason:i=`read`}={}){let a=cC(n?.length??t.length,r,i);return e.readBuffer(t,{...n,length:a})}async function dC(e,{maximumLength:t=LC}={}){let n=new ReadableStream({start(t){t.enqueue(e),t.close()}}).pipeThrough(new DecompressionStream(`deflate-raw`)).getReader(),r=[],i=0;try{for(;;){let{done:e,value:a}=await n.read();if(e)break;if(i+=a.length,i>t)throw await n.cancel(),Error(`ZIP entry decompressed data exceeds ${t} bytes`);r.push(a)}}finally{n.releaseLock()}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}function fC(e,t){if(e.length<uw)return-1;let n=e.length-uw;for(let r=0;r<=n;r++)if(Jx.get(e,r)===lw&&Jx.get(e,r+8)===t+r)return r;return-1}function pC(e){return!!(e.codePointAt(0)&32)}function mC(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}async function hC(e,{shouldBuffer:t,maximumLength:n=LC}={}){let{syncBuffer:r}=e,{length:i}=r,a=[],o=0;for(;;){let s=await e.tokenizer.peekBuffer(r,{mayBeLess:!0}),c=fC(r.subarray(0,s),o),l=c>=0?0:s===i?Math.min(dw,s-1):0,u=c>=0?c:s-l;if(u===0)break;if(o+=u,o>n)throw Error(`ZIP entry compressed data exceeds ${n} bytes`);if(t){let t=new Uint8Array(u);await e.tokenizer.readBuffer(t),a.push(t)}else await e.tokenizer.ignore(u);if(c>=0)break}if(EC(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=o),t)return mC(a,o)}function gC(e,t){return EC(e.tokenizer)?Math.max(0,BC-(e.tokenizer.position-t)):Math.max(0,LC-e.knownSizeDescriptorScannedBytes)}async function _C(e,t,{shouldBuffer:n,maximumDescriptorLength:r=LC}={}){if(t.dataDescriptor&&t.compressedSize===0)return hC(e,{shouldBuffer:n,maximumLength:r});if(!n){await lC(e.tokenizer,t.compressedSize,{maximumLength:EC(e.tokenizer)?LC:e.tokenizer.fileInfo.size,reason:`ZIP entry compressed data`});return}let i=OC(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>i)throw Error(`ZIP entry compressed data exceeds ${i} bytes`);let a=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(a),a}function vC(e,t){let n=e.getReader(),r=0,i=!1,a=!1,o=async e=>{i||a||(a=!0,await n.cancel(e))};return new ReadableStream({async pull(e){if(r>=t){e.close(),await o();return}let{done:a,value:s}=await n.read();if(a||!s){i=!0,e.close();return}let c=t-r;if(s.length>c){e.enqueue(s.subarray(0,c)),r+=c,e.close(),await o();return}e.enqueue(s),r+=s.length},async cancel(e){await o(e)}})}async function yC(e,t){return new fw(t).fromBuffer(e)}function bC(e){switch(e=e.toLowerCase(),e){case`application/epub+zip`:return{ext:`epub`,mime:e};case`application/vnd.oasis.opendocument.text`:return{ext:`odt`,mime:e};case`application/vnd.oasis.opendocument.text-template`:return{ext:`ott`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet`:return{ext:`ods`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet-template`:return{ext:`ots`,mime:e};case`application/vnd.oasis.opendocument.presentation`:return{ext:`odp`,mime:e};case`application/vnd.oasis.opendocument.presentation-template`:return{ext:`otp`,mime:e};case`application/vnd.oasis.opendocument.graphics`:return{ext:`odg`,mime:e};case`application/vnd.oasis.opendocument.graphics-template`:return{ext:`otg`,mime:e};case`application/vnd.openxmlformats-officedocument.presentationml.slideshow`:return{ext:`ppsx`,mime:e};case`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`:return{ext:`xlsx`,mime:e};case`application/vnd.ms-excel.sheet.macroenabled`:return{ext:`xlsm`,mime:`application/vnd.ms-excel.sheet.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.spreadsheetml.template`:return{ext:`xltx`,mime:e};case`application/vnd.ms-excel.template.macroenabled`:return{ext:`xltm`,mime:`application/vnd.ms-excel.template.macroenabled.12`};case`application/vnd.ms-powerpoint.slideshow.macroenabled`:return{ext:`ppsm`,mime:`application/vnd.ms-powerpoint.slideshow.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.document`:return{ext:`docx`,mime:e};case`application/vnd.ms-word.document.macroenabled`:return{ext:`docm`,mime:`application/vnd.ms-word.document.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.template`:return{ext:`dotx`,mime:e};case`application/vnd.ms-word.template.macroenabledtemplate`:return{ext:`dotm`,mime:`application/vnd.ms-word.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.template`:return{ext:`potx`,mime:e};case`application/vnd.ms-powerpoint.template.macroenabled`:return{ext:`potm`,mime:`application/vnd.ms-powerpoint.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.presentation`:return{ext:`pptx`,mime:e};case`application/vnd.ms-powerpoint.presentation.macroenabled`:return{ext:`pptm`,mime:`application/vnd.ms-powerpoint.presentation.macroenabled.12`};case`application/vnd.ms-visio.drawing`:return{ext:`vsdx`,mime:`application/vnd.visio`};case`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`:return{ext:`3mf`,mime:`model/3mf`}}}function xC(e,t,n){n={offset:0,...n};for(let[r,i]of t.entries())if(n.mask){if(i!==(n.mask[r]&e[r+n.offset]))return!1}else if(i!==e[r+n.offset])return!1;return!0}function SC(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):FC}function CC(e,t,n){return n===void 0?e.read(t):(n.throwIfAborted(),new Promise((r,i)=>{let a=()=>{n.removeEventListener(`abort`,o)},o=()=>{let t=n.reason;a(),(async()=>{try{await e.cancel(t)}catch{}})(),i(t)};n.addEventListener(`abort`,o,{once:!0}),(async()=>{try{let n=await e.read(t);a(),r(n)}catch(e){a(),i(e)}})()}))}function wC(e){return Number.isFinite(e)?Math.max(0,Math.min(IC,Math.trunc(e))):0}function TC(e){return Number.isFinite(e)?Math.max(0,e):2**53-1}function EC(e){let t=e.fileInfo.size;return!Number.isFinite(t)||t===2**53-1}function DC(e,t,n){return EC(e)&&e.position-t>n}function OC(e){let t=e.fileInfo.size,n=Number.isFinite(t)?Math.max(0,t-e.position):2**53-1;return Math.min(n,zC)}function kC(e){if(e instanceof tS||e instanceof cw)return!0;if(!(e instanceof Error))return!1;if(aw.has(e.message)||sw.has(e.code))return!0;for(let t of ow)if(e.message.startsWith(t))return!0;return!1}function AC(e,t=LC){let n=[e.compressedSize,e.uncompressedSize];for(let e of n)if(!Number.isFinite(e)||e<0||e>t)return!1;return!0}function jC(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function MC(e,t){t.startsWith(`word/`)&&(e.hasWordDirectory=!0),t.startsWith(`ppt/`)&&(e.hasPresentationDirectory=!0),t.startsWith(`xl/`)&&(e.hasSpreadsheetDirectory=!0),t.startsWith(`3D/`)&&t.endsWith(`.model`)&&(e.hasThreeDimensionalModelEntry=!0)}function NC(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:`docx`,mime:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`};if(e.hasPresentationDirectory)return{ext:`pptx`,mime:`application/vnd.openxmlformats-officedocument.presentationml.presentation`};if(e.hasSpreadsheetDirectory)return{ext:`xlsx`,mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`};if(e.hasThreeDimensionalModelEntry)return{ext:`3mf`,mime:`model/3mf`}}}function PC(e){let t=e.indexOf(`.main+xml"`);if(t===-1){let t=`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`;return e.includes(`ContentType="${t}"`)?t:void 0}let n=e.slice(0,t),r=n.lastIndexOf(`"`);return n.slice(r+1)}var FC,IC,LC,RC,zC,BC,VC,HC,UC,WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C,ew,tw,nw,rw,iw,aw,ow,sw,cw,lw,uw,dw,fw,pw=T(()=>{$x(),kS(),ZS(),$S(),rC(),oC(),FC=4100,IC=FC-2,LC=1048576,RC=1024,zC=2**31-1,BC=16777216,VC=LC,HC=LC,UC=BC,WC=1,GC=100,KC=BC,qC=64,JC=VC,YC=256,XC=512,ZC=BC,QC=512,$C=512,ew=256,tw=VC,nw=VC,rw=VC,iw=BC,aw=new Set([`Unexpected signature`,`Encrypted ZIP`,`Expected Central-File-Header signature`]),ow=[`ZIP entry count exceeds `,`Unsupported ZIP compression method:`,`ZIP entry compressed data exceeds `,`ZIP entry decompressed data exceeds `,`Expected data-descriptor-signature at position `],sw=new Set([`Z_BUF_ERROR`,`Z_DATA_ERROR`,`ERR_INVALID_STATE`]),cw=class extends Error{},lw=134695760,uw=16,dw=uw-1,qS.prototype.inflate=async function(e,t,n){if(e.compressedMethod===0)return n(t);if(e.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);return n(await dC(t,{maximumLength:LC}))},qS.prototype.unzip=async function(e){let t=!1,n=0,r=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(DC(this.tokenizer,r,BC))throw new cw(`ZIP stream probing exceeds ${BC} bytes`);let i=await this.readLocalFileHeader();if(!i)break;if(n++,n>RC)throw Error(`ZIP entry count exceeds ${RC}`);let a=e(i);t=!!a.stop,await this.tokenizer.ignore(i.extraFieldLength);let o=await _C(this,i,{shouldBuffer:!!a.handler,maximumDescriptorLength:Math.min(LC,gC(this,r))});if(a.handler&&await this.inflate(i,o,a.handler),i.dataDescriptor){let e=new Uint8Array(uw);if(await this.tokenizer.readBuffer(e),Jx.get(e,0)!==lw)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-e.length}`)}if(DC(this.tokenizer,r,BC))throw new cw(`ZIP stream probing exceeds ${BC} bytes`)}while(!t)},fw=class e{constructor(e){let t=wC(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:`core`,detect:this.detectConfident},{id:`core.imprecise`,detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return sC(ES(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;let n=e.position;for(let t of this.detectors){let r;try{r=await t.detect(e)}catch(e){if(e instanceof tS||e instanceof cw)return;throw e}if(r)return r;if(n!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(DS(t,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let t=OS(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();let t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){let n=SC(t?.sampleSize??FC),r,i,a=e.getReader({mode:`byob`});try{let{value:e,done:t}=await CC(a,new Uint8Array(n),this.options.signal);if(i=e,!t&&e)try{r=await this.fromBuffer(e.subarray(0,n))}catch(e){if(!(e instanceof tS))throw e;r=void 0}i=e}finally{a.releaseLock()}let o=new TransformStream({async start(e){e.enqueue(i)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(o);return s.fileType=r,s}async detectGzip(t){if(this.gzipProbeDepth>=WC)return{ext:`gz`,mime:`application/gzip`};let n=vC(new YS(t).inflate(),UC),r=EC(t),i,a,o,s;if(r){let t=new AbortController;i=setTimeout(()=>{t.abort(new DOMException(`Operation timed out after ${GC} ms`,`TimeoutError`))},GC),a=this.options.signal===void 0?t.signal:AbortSignal.any([this.options.signal,t.signal]),o=new e({...this.options,signal:a}),o.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{s=await(o??this).fromStream(n)}catch(e){if(e?.name===`AbortError`&&a?.reason?.name!==`TimeoutError`)throw e}finally{clearTimeout(i),r||this.gzipProbeDepth--}return s?.ext===`tar`?{ext:`tar.gz`,mime:`application/gzip`}:{ext:`gz`,mime:`application/gzip`}}check(e,t){return xC(this.buffer,e,t)}checkString(e,t){return this.check(eC(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(FC),e.fileInfo.size===void 0&&(e.fileInfo.size=2**53-1),this.tokenizer=e,EC(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:`bmp`,mime:`image/bmp`};if(this.check([11,119]))return{ext:`ac3`,mime:`audio/vnd.dolby.dd-raw`};if(this.check([120,1]))return{ext:`dmg`,mime:`application/x-apple-diskimage`};if(this.check([77,90]))return{ext:`exe`,mime:`application/x-msdownload`};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString(`PS-Adobe-`,{offset:2})&&this.checkString(` EPSF-`,{offset:14})?{ext:`eps`,mime:`application/eps`}:{ext:`ps`,mime:`application/postscript`};if(this.check([31,160])||this.check([31,157]))return{ext:`Z`,mime:`application/x-compress`};if(this.check([199,113]))return{ext:`cpio`,mime:`application/x-cpio`};if(this.check([96,234]))return{ext:`arj`,mime:`application/x-arj`};if(this.check([239,187,191]))return this.detectionReentryCount>=ew?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:`gif`,mime:`image/gif`};if(this.check([73,73,188]))return{ext:`jxr`,mime:`image/vnd.ms-photo`};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:`bz2`,mime:`application/x-bzip2`};if(this.checkString(`ID3`)){await lC(e,6,{maximumLength:6,reason:`ID3 header prefix`});let t=await e.readToken(nC),n=EC(e);if(!Number.isFinite(t)||t<0||n&&(t>KC||e.position+t>KC))return;if(e.position+t>e.fileInfo.size)return n?void 0:{ext:`mp3`,mime:`audio/mpeg`};try{await lC(e,t,{maximumLength:n?KC:e.fileInfo.size,reason:`ID3 payload`})}catch(e){if(e instanceof tS)return;throw e}return this.detectionReentryCount>=ew?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString(`MP+`))return{ext:`mpc`,mime:`audio/x-musepack`};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:`swf`,mime:`application/x-shockwave-flash`};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:`jls`,mime:`image/jls`}:{ext:`jpg`,mime:`image/jpeg`};if(this.check([79,98,106,1]))return{ext:`avro`,mime:`application/avro`};if(this.checkString(`FLIF`))return{ext:`flif`,mime:`image/flif`};if(this.checkString(`8BPS`))return{ext:`psd`,mime:`image/vnd.adobe.photoshop`};if(this.checkString(`MPCK`))return{ext:`mpc`,mime:`audio/x-musepack`};if(this.checkString(`FORM`))return{ext:`aif`,mime:`audio/aiff`};if(this.checkString(`icns`,{offset:0}))return{ext:`icns`,mime:`image/icns`};if(this.check([80,75,3,4])){let t,n=jC();try{await new qS(e).unzip(e=>{MC(n,e.filename);let r=e.filename===`[Content_Types].xml`,i=NC(n);if(!r&&i)return t=i,{stop:!0};switch(e.filename){case`META-INF/mozilla.rsa`:return t={ext:`xpi`,mime:`application/x-xpinstall`},{stop:!0};case`META-INF/MANIFEST.MF`:return t={ext:`jar`,mime:`application/java-archive`},{stop:!0};case`mimetype`:return AC(e,HC)?{async handler(e){t=bC(new TextDecoder(`utf-8`).decode(e).trim())},stop:!0}:{};case`[Content_Types].xml`:return n.hasContentTypesEntry=!0,AC(e,HC)?(n.isParsingContentTypes=!0,{async handler(e){let r=PC(new TextDecoder(`utf-8`).decode(e));r&&(t=bC(r)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(e.filename)?(t={ext:`apk`,mime:`application/vnd.android.package-archive`},{stop:!0}):{}}})}catch(e){if(!kC(e))throw e;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return t??NC(n)??{ext:`zip`,mime:`application/zip`}}if(this.checkString(`OggS`)){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),xC(t,[79,112,117,115,72,101,97,100])?{ext:`opus`,mime:`audio/ogg; codecs=opus`}:xC(t,[128,116,104,101,111,114,97])?{ext:`ogv`,mime:`video/ogg`}:xC(t,[1,118,105,100,101,111,0])?{ext:`ogm`,mime:`video/ogg`}:xC(t,[127,70,76,65,67])?{ext:`oga`,mime:`audio/ogg`}:xC(t,[83,112,101,101,120,32,32])?{ext:`spx`,mime:`audio/ogg`}:xC(t,[1,118,111,114,98,105,115])?{ext:`ogg`,mime:`audio/ogg`}:{ext:`ogx`,mime:`application/ogg`}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:`zip`,mime:`application/zip`};if(this.checkString(`MThd`))return{ext:`mid`,mime:`audio/midi`};if(this.checkString(`wOFF`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff`,mime:`font/woff`};if(this.checkString(`wOF2`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff2`,mime:`font/woff2`};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:`pcap`,mime:`application/vnd.tcpdump.pcap`};if(this.checkString(`DSD `))return{ext:`dsf`,mime:`audio/x-dsf`};if(this.checkString(`LZIP`))return{ext:`lz`,mime:`application/x-lzip`};if(this.checkString(`fLaC`))return{ext:`flac`,mime:`audio/flac`};if(this.check([66,80,71,251]))return{ext:`bpg`,mime:`image/bpg`};if(this.checkString(`wvpk`))return{ext:`wv`,mime:`audio/wavpack`};if(this.checkString(`%PDF`))return{ext:`pdf`,mime:`application/pdf`};if(this.check([0,97,115,109]))return{ext:`wasm`,mime:`application/wasm`};if(this.check([73,73])){let e=await this.readTiffHeader(!1);if(e)return e}if(this.check([77,77])){let e=await this.readTiffHeader(!0);if(e)return e}if(this.checkString(`MAC `))return{ext:`ape`,mime:`audio/ape`};if(this.check([26,69,223,163])){async function t(){let t=await e.peekNumber(Gx),n=128,r=0;for(;(t&n)===0&&n!==0;)++r,n>>=1;let i=new Uint8Array(r+1);return await uC(e,i,void 0,{maximumLength:i.length,reason:`EBML field`}),i}async function n(){let e=await t(),n=await t();n[0]^=128>>n.length-1;let r=Math.min(6,n.length),i=new DataView(e.buffer),a=new DataView(n.buffer,n.length-r,r);return{id:QS(i),len:QS(a)}}async function r(t){let r=0;for(;t>0;){if(r++,r>YC||DC(e,a,BC))return;let i=e.position,o=await n();if(o.id===17026){if(o.len>qC)return;let t=cC(o.len,qC,`EBML DocType`);return(await e.readToken(new Qx(t))).replaceAll(/\00.*$/g,``)}if(EC(e)&&(!Number.isFinite(o.len)||o.len<0||o.len>JC)||(await lC(e,o.len,{maximumLength:EC(e)?JC:e.fileInfo.size,reason:`EBML payload`}),--t,e.position<=i))return}}let i=await n(),a=e.position;switch(await r(i.len)){case`webm`:return{ext:`webm`,mime:`video/webm`};case`matroska`:return{ext:`mkv`,mime:`video/matroska`};default:return}}if(this.checkString(`SQLi`))return{ext:`sqlite`,mime:`application/x-sqlite3`};if(this.check([78,69,83,26]))return{ext:`nes`,mime:`application/x-nintendo-nes-rom`};if(this.checkString(`Cr24`))return{ext:`crx`,mime:`application/x-google-chrome-extension`};if(this.checkString(`MSCF`)||this.checkString(`ISc(`))return{ext:`cab`,mime:`application/vnd.ms-cab-compressed`};if(this.check([237,171,238,219]))return{ext:`rpm`,mime:`application/x-rpm`};if(this.check([197,208,211,198]))return{ext:`eps`,mime:`application/eps`};if(this.check([40,181,47,253]))return{ext:`zst`,mime:`application/zstd`};if(this.check([127,69,76,70]))return{ext:`elf`,mime:`application/x-elf`};if(this.check([33,66,68,78]))return{ext:`pst`,mime:`application/vnd.ms-outlook`};if(this.checkString(`PAR1`)||this.checkString(`PARE`))return{ext:`parquet`,mime:`application/vnd.apache.parquet`};if(this.checkString(`ttcf`))return{ext:`ttc`,mime:`font/collection`};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:`macho`,mime:`application/x-mach-binary`};if(this.check([4,34,77,24]))return{ext:`lz4`,mime:`application/x-lz4`};if(this.checkString(`regf`))return{ext:`dat`,mime:`application/x-ft-windows-registry-hive`};if(this.checkString(`$FL2`)||this.checkString(`$FL3`))return{ext:`sav`,mime:`application/x-spss-sav`};if(this.check([79,84,84,79,0]))return{ext:`otf`,mime:`font/otf`};if(this.checkString(`#!AMR`))return{ext:`amr`,mime:`audio/amr`};if(this.checkString(`{\\rtf`))return{ext:`rtf`,mime:`application/rtf`};if(this.check([70,76,86,1]))return{ext:`flv`,mime:`video/x-flv`};if(this.checkString(`IMPM`))return{ext:`it`,mime:`audio/x-it`};if(this.checkString(`-lh0-`,{offset:2})||this.checkString(`-lh1-`,{offset:2})||this.checkString(`-lh2-`,{offset:2})||this.checkString(`-lh3-`,{offset:2})||this.checkString(`-lh4-`,{offset:2})||this.checkString(`-lh5-`,{offset:2})||this.checkString(`-lh6-`,{offset:2})||this.checkString(`-lh7-`,{offset:2})||this.checkString(`-lzs-`,{offset:2})||this.checkString(`-lz4-`,{offset:2})||this.checkString(`-lz5-`,{offset:2})||this.checkString(`-lhd-`,{offset:2}))return{ext:`lzh`,mime:`application/x-lzh-compressed`};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:`mpg`,mime:`video/MP1S`};if(this.check([68],{offset:4,mask:[196]}))return{ext:`mpg`,mime:`video/MP2P`}}if(this.checkString(`ITSF`))return{ext:`chm`,mime:`application/vnd.ms-htmlhelp`};if(this.check([202,254,186,190])){let e=Yx.get(this.buffer,4),t=qx.get(this.buffer,6);if(e>0&&e<=30)return{ext:`macho`,mime:`application/x-mach-binary`};if(t>30)return{ext:`class`,mime:`application/java-vm`}}if(this.checkString(`.RMF`))return{ext:`rm`,mime:`application/vnd.rn-realmedia`};if(this.checkString(`DRACO`))return{ext:`drc`,mime:`application/vnd.google.draco`};if(this.check([253,55,122,88,90,0]))return{ext:`xz`,mime:`application/x-xz`};if(this.checkString(`<?xml `))return{ext:`xml`,mime:`application/xml`};if(this.check([55,122,188,175,39,28]))return{ext:`7z`,mime:`application/x-7z-compressed`};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:`rar`,mime:`application/x-rar-compressed`};if(this.checkString(`solid `))return{ext:`stl`,mime:`model/stl`};if(this.checkString(`AC`)){let e=new Qx(4,`latin1`).get(this.buffer,2);if(e.match(`^d*`)&&e>=1e3&&e<=1050)return{ext:`dwg`,mime:`image/vnd.dwg`}}if(this.checkString(`070707`))return{ext:`cpio`,mime:`application/x-cpio`};if(this.checkString(`BLENDER`))return{ext:`blend`,mime:`application/x-blender`};if(this.checkString(`!<arch>`))return await e.ignore(8),await e.readToken(new Qx(13,`ascii`))===`debian-binary`?{ext:`deb`,mime:`application/x-deb`}:{ext:`ar`,mime:`application/x-unix-archive`};if(this.checkString(`WEBVTT`)&&[`
718
+ `}return{stdout:c,stderr:``,exitCode:l}}}}var px,mx=T(()=>{k(),F(),px=new Map([[`sha1`,`SHA-1`],[`sha256`,`SHA-256`]])}),hx={};E(hx,{flagsForFuzzing:()=>_x,md5sumCommand:()=>gx});var gx,_x,vx=T(()=>{mx(),gx=fx(`md5sum`,`md5`,`compute MD5 message digest`),_x={name:`md5sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),yx={};E(yx,{flagsForFuzzing:()=>xx,sha1sumCommand:()=>bx});var bx,xx,Sx=T(()=>{mx(),bx=fx(`sha1sum`,`sha1`,`compute SHA1 message digest`),xx={name:`sha1sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),Cx={};E(Cx,{flagsForFuzzing:()=>Tx,sha256sumCommand:()=>wx});var wx,Tx,Ex=T(()=>{mx(),wx=fx(`sha256sum`,`sha256`,`compute SHA256 message digest`),Tx={name:`sha256sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),Dx=pn(e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else{if(a===c)return o?NaN:1/0*(p?-1:1);o+=2**r,a-=l}return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}});function Ox(){if(!(typeof globalThis.TextDecoder>`u`))return Bx??=new globalThis.TextDecoder(`utf-8`)}function kx(e,t=`utf-8`){switch(t.toLowerCase()){case`utf-8`:case`utf8`:{let t=Ox();return t?t.decode(e):Nx(e)}case`utf-16le`:return Px(e);case`us-ascii`:case`ascii`:return Fx(e);case`latin1`:case`iso-8859-1`:return Ix(e);case`windows-1252`:return Lx(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function Ax(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function jx(e,t,n){t.push(n),t.length>=Vx&&Ax(e,t)}function Mx(e,t,n){if(n<=65535){jx(e,t,n);return}n-=65536,jx(e,t,55296+(n>>10)),jx(e,t,56320+(n&1023))}function Nx(e){let t=[],n=[],r=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(r=3);r<e.length;){let i=e[r];if(i<=127){jx(t,n,i),r++;continue}if(i<194||i>244){jx(t,n,Hx),r++;continue}if(i<=223){if(r+1>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1];if((a&192)!=128){jx(t,n,Hx),r++;continue}jx(t,n,(i&31)<<6|a&63),r+=2;continue}if(i<=239){if(r+2>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1],o=e[r+2];if(!((a&192)==128&&(o&192)==128&&!(i===224&&a<160)&&!(i===237&&a>=160))){jx(t,n,Hx),r++;continue}jx(t,n,(i&15)<<12|(a&63)<<6|o&63),r+=3;continue}if(r+3>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1],o=e[r+2],s=e[r+3];if(!((a&192)==128&&(o&192)==128&&(s&192)==128&&!(i===240&&a<144)&&!(i===244&&a>143))){jx(t,n,Hx),r++;continue}Mx(t,n,(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63),r+=4}return Ax(t,n),t.join(``)}function Px(e){let t=[],n=[],r=e.length,i=0;for(;i+1<r;){let a=e[i]|e[i+1]<<8;if(i+=2,a>=55296&&a<=56319){if(i+1<r){let r=e[i]|e[i+1]<<8;r>=56320&&r<=57343?(jx(t,n,a),jx(t,n,r),i+=2):jx(t,n,Hx)}else jx(t,n,Hx);continue}if(a>=56320&&a<=57343){jx(t,n,Hx);continue}jx(t,n,a)}return i<r&&jx(t,n,Hx),Ax(t,n),t.join(``)}function Fx(e){let t=[];for(let n=0;n<e.length;n+=Vx){let r=Math.min(e.length,n+Vx),i=Array(r-n);for(let t=n,a=0;t<r;t++,a++)i[a]=e[t]&127;t.push(String.fromCharCode.apply(null,i))}return t.join(``)}function Ix(e){let t=[];for(let n=0;n<e.length;n+=Vx){let r=Math.min(e.length,n+Vx),i=Array(r-n);for(let t=n,a=0;t<r;t++,a++)i[a]=e[t];t.push(String.fromCharCode.apply(null,i))}return t.join(``)}function Lx(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r],a=i>=128&&i<=159?Rx[i]:void 0;n+=a??String.fromCharCode(i),n.length>=Vx&&(t.push(n),n=``)}return n&&t.push(n),t.join(``)}var Rx,zx,Bx,Vx,Hx,Ux=T(()=>{Rx={128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`},zx={};for(let[e,t]of Object.entries(Rx))zx[t]=Number.parseInt(e,10);Vx=32768,Hx=65533});function Wx(e){return new DataView(e.buffer,e.byteOffset)}var Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x=T(()=>{hn(Dx(),1),Ux(),Gx={len:1,get(e,t){return Wx(e).getUint8(t)},put(e,t,n){return Wx(e).setUint8(t,n),t+1}},Kx={len:2,get(e,t){return Wx(e).getUint16(t,!0)},put(e,t,n){return Wx(e).setUint16(t,n,!0),t+2}},qx={len:2,get(e,t){return Wx(e).getUint16(t)},put(e,t,n){return Wx(e).setUint16(t,n),t+2}},Jx={len:4,get(e,t){return Wx(e).getUint32(t,!0)},put(e,t,n){return Wx(e).setUint32(t,n,!0),t+4}},Yx={len:4,get(e,t){return Wx(e).getUint32(t)},put(e,t,n){return Wx(e).setUint32(t,n),t+4}},Xx={len:4,get(e,t){return Wx(e).getInt32(t)},put(e,t,n){return Wx(e).setInt32(t,n),t+4}},Zx={len:8,get(e,t){return Wx(e).getBigUint64(t,!0)},put(e,t,n){return Wx(e).setBigUint64(t,n,!0),t+8}},Qx=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){return kx(e.subarray(t,t+this.len),this.encoding)}}}),eS,tS,nS,rS=T(()=>{eS=`End-Of-Stream`,tS=class extends Error{constructor(){super(eS),this.name=`EndOfStreamError`}},nS=class extends Error{constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}}}),iS=T(()=>{}),aS,oS=T(()=>{rS(),aS=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new tS;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let r=this.peekQueue.pop();if(!r)throw Error(`peekData should be defined`);let i=Math.min(r.length,t);e.set(r.subarray(0,i),n),n+=i,t-=i,i<r.length&&this.peekQueue.push(r.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new nS;let r=await this.readFromStream(e.subarray(n),t);if(r===0)break;n+=r}if(!t&&n<e.length)throw new tS;return n}}}),sS=T(()=>{rS(),iS(),oS()}),cS,lS=T(()=>{oS(),cS=class extends aS{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}}),uS,dS=T(()=>{lS(),uS=class extends cS{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}}}),fS,pS=T(()=>{rS(),oS(),fS=class extends aS{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),this.buffer=n<t.length?t.subarray(n):null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(n+=this.writeChunk(e.subarray(n),t.value))}if(!t&&n===0&&this.endOfStream)throw new tS;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function mS(e){try{let t=e.getReader({mode:`byob`});return t instanceof ReadableStreamDefaultReader?new fS(t):new uS(t)}catch(t){if(t instanceof TypeError)return new fS(e.getReader());throw t}}var hS=T(()=>{dS(),pS()}),gS=T(()=>{rS(),sS(),dS(),pS(),hS()}),_S,vS=T(()=>{gS(),_S=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener(`abort`,()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})<e.len)throw new tS;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:t})<e.len)throw new tS;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new tS;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new tS;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw RangeError(`ignore length must be ≥ 0 bytes`);if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}}}),yS,bS,xS=T(()=>{vS(),gS(),yS=256e3,bS=class extends _S{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new tS;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=0;if(n.position){let t=n.position-this.position;if(t>0){let i=new Uint8Array(n.length+t);return r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),e.set(i.subarray(t)),r-t}if(t<0)throw Error(`Cannot peek from a negative offset in a stream`)}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof tS)return 0;throw e}if(!n.mayBeLess&&r<n.length)throw new tS}return r}async ignore(e){if(e<0)throw RangeError(`ignore length must be ≥ 0 bytes`);let t=Math.min(yS,e),n=new Uint8Array(t),r=0;for(;r<e;){let i=e-r,a=await this.readBuffer(n,{length:Math.min(t,i)});if(a<0)return a;r+=a}return r}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}}),SS,CS=T(()=>{gS(),vS(),SS=class extends _S{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new tS;return e.set(this.uint8Array.subarray(n.position,n.position+r)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}}),wS,TS=T(()=>{gS(),vS(),wS=class extends _S{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new tS;let i=await this.blob.slice(n.position,n.position+r).arrayBuffer();return e.set(new Uint8Array(i)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});function ES(e,t){let n=mS(e),r=t??{},i=r.onClose;return r.onClose=async()=>{if(await n.close(),i)return i()},new bS(n,r)}function DS(e,t){return new SS(e,t)}function OS(e,t){return new wS(e,t)}var kS=T(()=>{gS(),xS(),CS(),TS(),gS(),vS()}),AS=pn((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}),jS=pn((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=AS(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(typeof t>`u`?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n}),MS=pn((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t={}.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=jS()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}}),NS,PS,FS,IS,LS,RS=T(()=>{$x(),NS={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},PS={get(e){return{signature:Jx.get(e,0),compressedSize:Jx.get(e,8),uncompressedSize:Jx.get(e,12)}},len:16},FS={get(e){let t=Kx.get(e,6);return{signature:Jx.get(e,0),minVersion:Kx.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Kx.get(e,8),compressedSize:Jx.get(e,18),uncompressedSize:Jx.get(e,22),filenameLength:Kx.get(e,26),extraFieldLength:Kx.get(e,28),filename:null}},len:30},IS={get(e){return{signature:Jx.get(e,0),nrOfThisDisk:Kx.get(e,4),nrOfThisDiskWithTheStart:Kx.get(e,6),nrOfEntriesOnThisDisk:Kx.get(e,8),nrOfEntriesOfSize:Kx.get(e,10),sizeOfCd:Jx.get(e,12),offsetOfStartOfCd:Jx.get(e,16),zipFileCommentLength:Kx.get(e,20)}},len:22},LS={get(e){let t=Kx.get(e,8);return{signature:Jx.get(e,0),minVersion:Kx.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Kx.get(e,10),compressedSize:Jx.get(e,20),uncompressedSize:Jx.get(e,24),filenameLength:Kx.get(e,28),extraFieldLength:Kx.get(e,30),fileCommentLength:Kx.get(e,32),relativeOffsetOfLocalHeader:Jx.get(e,42),filename:null}},len:46}});function zS(e){let t=new Uint8Array(Jx.len);return Jx.put(t,0,e),t}function BS(e,t){let n=e.length,r=t.length;if(r>n)return-1;for(let i=0;i<=n-r;i++){let n=!0;for(let a=0;a<r;a++)if(e[i+a]!==t[a]){n=!1;break}if(n)return i}return-1}function VS(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var HS,US,WS,GS,KS,qS,JS=T(()=>{$x(),HS=hn(MS(),1),RS(),US=(0,HS.default)(`tokenizer:inflate`),WS=262144,GS=zS(NS.DataDescriptor),KS=zS(NS.EndOfCentralDirectory),qS=class e{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(WS)}async isZip(){return await this.peekSignature()===NS.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Jx)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16384,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let r=n.length-4;r>=0;r--)if(n[r]===KS[0]&&n[r+1]===KS[1]&&n[r+2]===KS[2]&&n[r+3]===KS[3])return e.fileInfo.size-t+r;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){US(`Cannot reading central-directory without random-read support`);return}US(`Reading central-directory...`);let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){US(`Central-directory 32-bit signature found`);let n=await this.tokenizer.readToken(IS,t),r=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let e=0;e<n.nrOfEntriesOfSize;++e){let t=await this.tokenizer.readToken(LS);if(t.signature!==NS.CentralFileHeader)throw Error(`Expected Central-File-Header signature`);t.filename=await this.tokenizer.readToken(new Qx(t.filenameLength,`utf-8`)),await this.tokenizer.ignore(t.extraFieldLength),await this.tokenizer.ignore(t.fileCommentLength),r.push(t),US(`Add central-directory file-entry: n=${e+1}/${r.length}: filename=${r[e].filename}`)}return this.tokenizer.setPosition(e),r}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let n=!1;do{let t=await this.readLocalFileHeader();if(!t)break;let r=e(t);n=!!r.stop;let i;if(await this.tokenizer.ignore(t.extraFieldLength),t.dataDescriptor&&t.compressedSize===0){let e=[],n=WS;US(`Compressed-file-size unknown, scanning for next data-descriptor-signature....`);let i=-1;for(;i<0&&n===WS;){n=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),i=BS(this.syncBuffer.subarray(0,n),GS);let t=i>=0?i:n;if(r.handler){let n=new Uint8Array(t);await this.tokenizer.readBuffer(n),e.push(n)}else await this.tokenizer.ignore(t)}US(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),r.handler&&await this.inflate(t,VS(e),r.handler)}else r.handler?(US(`Reading compressed-file-data: ${t.compressedSize} bytes`),i=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(t,i,r.handler)):(US(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(US(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor&&(await this.tokenizer.readToken(PS)).signature!==134695760)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-PS.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let e=t(n);if(e.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);let r=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(r),await this.inflate(t,r,e.handler)}}if(e.stop)break}}async inflate(t,n,r){if(t.compressedMethod===0)return r(n);if(t.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);return US(`Decompress filename=${t.filename}, compressed-size=${n.length}`),r(await e.decompressDeflateRaw(n))}static async decompressDeflateRaw(e){let t=new ReadableStream({start(t){t.enqueue(e),t.close()}}),n=new DecompressionStream(`deflate-raw`),r=t.pipeThrough(n);try{let e=await new Response(r).arrayBuffer();return new Uint8Array(e)}catch(e){let t=e instanceof Error?`Failed to deflate ZIP entry: ${e.message}`:`Unknown decompression error in ZIP entry`;throw TypeError(t)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(Jx);if(e===NS.LocalFileHeader){let e=await this.tokenizer.readToken(FS);return e.filename=await this.tokenizer.readToken(new Qx(e.filenameLength,`utf-8`)),e}if(e===NS.CentralFileHeader)return!1;throw Error(e===3759263696?`Encrypted ZIP`:`Unexpected signature`)}}}),YS,XS=T(()=>{YS=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),r=await e.readBuffer(n,{mayBeLess:!0});if(r===0){t.close();return}t.enqueue(n.subarray(0,r))}}).pipeThrough(new DecompressionStream(`gzip`))}}}),ZS=T(()=>{JS(),XS()});function QS(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}var $S=T(()=>{new globalThis.TextDecoder(`utf8`),new globalThis.TextEncoder,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`))});function eC(e,t){if(t===`utf-16le`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r&255,r>>8&255)}return t}if(t===`utf-16be`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r>>8&255,r&255)}return t}return[...e].map(e=>e.charCodeAt(0))}function tC(e,t=0){let n=Number.parseInt(new Qx(6).get(e,148).replace(/\0.*$/,``).trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let n=t;n<t+148;n++)r+=e[n];for(let n=t+156;n<t+512;n++)r+=e[n];return n===r}var nC,rC=T(()=>{$x(),nC={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}}),iC,aC,oC=T(()=>{iC=`jpg,png,apng,gif,webp,flif,xcf,cr2,cr3,orf,arw,dng,nef,rw2,raf,tif,bmp,icns,jxr,psd,indd,zip,tar,rar,gz,bz2,7z,dmg,mp4,mid,mkv,webm,mov,avi,mpg,mp2,mp3,m4a,oga,ogg,ogv,opus,flac,wav,spx,amr,pdf,epub,elf,macho,exe,swf,rtf,wasm,woff,woff2,eot,ttf,otf,ttc,ico,flv,ps,xz,sqlite,nes,crx,xpi,cab,deb,ar,rpm,Z,lz,cfb,mxf,mts,blend,bpg,docx,pptx,xlsx,3gp,3g2,j2c,jp2,jpm,jpx,mj2,aif,qcp,odt,ods,odp,xml,mobi,heic,cur,ktx,ape,wv,dcm,ics,glb,pcap,dsf,lnk,alias,voc,ac3,m4v,m4p,m4b,f4v,f4p,f4b,f4a,mie,asf,ogm,ogx,mpc,arrow,shp,aac,mp1,it,s3m,xm,skp,avif,eps,lzh,pgp,asar,stl,chm,3mf,zst,jxl,vcf,jls,pst,dwg,parquet,class,arj,cpio,ace,avro,icc,fbx,vsdx,vtt,apk,drc,lz4,potx,xltx,dotx,xltm,ott,ots,otp,odg,otg,xlsm,docm,dotm,potm,pptm,jar,jmp,rm,sav,ppsm,ppsx,tar.gz,reg,dat`.split(`,`),aC=`image/jpeg,image/png,image/gif,image/webp,image/flif,image/x-xcf,image/x-canon-cr2,image/x-canon-cr3,image/tiff,image/bmp,image/vnd.ms-photo,image/vnd.adobe.photoshop,application/x-indesign,application/epub+zip,application/x-xpinstall,application/vnd.ms-powerpoint.slideshow.macroenabled.12,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/zip,application/x-tar,application/x-rar-compressed,application/gzip,application/x-bzip2,application/x-7z-compressed,application/x-apple-diskimage,application/vnd.apache.arrow.file,video/mp4,audio/midi,video/matroska,video/webm,video/quicktime,video/vnd.avi,audio/wav,audio/qcelp,audio/x-ms-asf,video/x-ms-asf,application/vnd.ms-asf,video/mpeg,video/3gpp,audio/mpeg,audio/mp4,video/ogg,audio/ogg,audio/ogg; codecs=opus,application/ogg,audio/flac,audio/ape,audio/wavpack,audio/amr,application/pdf,application/x-elf,application/x-mach-binary,application/x-msdownload,application/x-shockwave-flash,application/rtf,application/wasm,font/woff,font/woff2,application/vnd.ms-fontobject,font/ttf,font/otf,font/collection,image/x-icon,video/x-flv,application/postscript,application/eps,application/x-xz,application/x-sqlite3,application/x-nintendo-nes-rom,application/x-google-chrome-extension,application/vnd.ms-cab-compressed,application/x-deb,application/x-unix-archive,application/x-rpm,application/x-compress,application/x-lzip,application/x-cfb,application/x-mie,application/mxf,video/mp2t,application/x-blender,image/bpg,image/j2c,image/jp2,image/jpx,image/jpm,image/mj2,audio/aiff,application/xml,application/x-mobipocket-ebook,image/heif,image/heif-sequence,image/heic,image/heic-sequence,image/icns,image/ktx,application/dicom,audio/x-musepack,text/calendar,text/vcard,text/vtt,model/gltf-binary,application/vnd.tcpdump.pcap,audio/x-dsf,application/x.ms.shortcut,application/x.apple.alias,audio/x-voc,audio/vnd.dolby.dd-raw,audio/x-m4a,image/apng,image/x-olympus-orf,image/x-sony-arw,image/x-adobe-dng,image/x-nikon-nef,image/x-panasonic-rw2,image/x-fujifilm-raf,video/x-m4v,video/3gpp2,application/x-esri-shape,audio/aac,audio/x-it,audio/x-s3m,audio/x-xm,video/MP1S,video/MP2P,application/vnd.sketchup.skp,image/avif,application/x-lzh-compressed,application/pgp-encrypted,application/x-asar,model/stl,application/vnd.ms-htmlhelp,model/3mf,image/jxl,application/zstd,image/jls,application/vnd.ms-outlook,image/vnd.dwg,application/vnd.apache.parquet,application/java-vm,application/x-arj,application/x-cpio,application/x-ace-compressed,application/avro,application/vnd.iccprofile,application/x.autodesk.fbx,application/vnd.visio,application/vnd.android.package-archive,application/vnd.google.draco,application/x-lz4,application/vnd.openxmlformats-officedocument.presentationml.template,application/vnd.openxmlformats-officedocument.spreadsheetml.template,application/vnd.openxmlformats-officedocument.wordprocessingml.template,application/vnd.ms-excel.template.macroenabled.12,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.spreadsheet-template,application/vnd.oasis.opendocument.presentation-template,application/vnd.oasis.opendocument.graphics,application/vnd.oasis.opendocument.graphics-template,application/vnd.ms-excel.sheet.macroenabled.12,application/vnd.ms-word.document.macroenabled.12,application/vnd.ms-word.template.macroenabled.12,application/vnd.ms-powerpoint.template.macroenabled.12,application/vnd.ms-powerpoint.presentation.macroenabled.12,application/java-archive,application/vnd.rn-realmedia,application/x-spss-sav,application/x-ms-regedit,application/x-ft-windows-registry-hive,application/x-jmp-data`.split(`,`)});function sC(e){let t=e?.streamReader;if(t?.constructor?.name!==`WebStreamByobReader`)return e;let{reader:n}=t,r=async()=>{await n.cancel(),n.releaseLock()};return t.close=r,t.abort=async()=>{t.interrupted=!0,await r()},e}function cC(e,t,n){if(!Number.isFinite(e)||e<0||e>t)throw new cw(`${n} has invalid size ${e} (maximum ${t} bytes)`);return e}async function lC(e,t,{maximumLength:n=BC,reason:r=`skip`}={}){let i=cC(t,n,r);await e.ignore(i)}async function uC(e,t,n,{maximumLength:r=t.length,reason:i=`read`}={}){let a=cC(n?.length??t.length,r,i);return e.readBuffer(t,{...n,length:a})}async function dC(e,{maximumLength:t=LC}={}){let n=new ReadableStream({start(t){t.enqueue(e),t.close()}}).pipeThrough(new DecompressionStream(`deflate-raw`)).getReader(),r=[],i=0;try{for(;;){let{done:e,value:a}=await n.read();if(e)break;if(i+=a.length,i>t)throw await n.cancel(),Error(`ZIP entry decompressed data exceeds ${t} bytes`);r.push(a)}}finally{n.releaseLock()}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}function fC(e,t){if(e.length<uw)return-1;let n=e.length-uw;for(let r=0;r<=n;r++)if(Jx.get(e,r)===lw&&Jx.get(e,r+8)===t+r)return r;return-1}function pC(e){return!!(e.codePointAt(0)&32)}function mC(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}async function hC(e,{shouldBuffer:t,maximumLength:n=LC}={}){let{syncBuffer:r}=e,{length:i}=r,a=[],o=0;for(;;){let s=await e.tokenizer.peekBuffer(r,{mayBeLess:!0}),c=fC(r.subarray(0,s),o),l=c>=0?0:s===i?Math.min(dw,s-1):0,u=c>=0?c:s-l;if(u===0)break;if(o+=u,o>n)throw Error(`ZIP entry compressed data exceeds ${n} bytes`);if(t){let t=new Uint8Array(u);await e.tokenizer.readBuffer(t),a.push(t)}else await e.tokenizer.ignore(u);if(c>=0)break}if(EC(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=o),t)return mC(a,o)}function gC(e,t){return EC(e.tokenizer)?Math.max(0,BC-(e.tokenizer.position-t)):Math.max(0,LC-e.knownSizeDescriptorScannedBytes)}async function _C(e,t,{shouldBuffer:n,maximumDescriptorLength:r=LC}={}){if(t.dataDescriptor&&t.compressedSize===0)return hC(e,{shouldBuffer:n,maximumLength:r});if(!n){await lC(e.tokenizer,t.compressedSize,{maximumLength:EC(e.tokenizer)?LC:e.tokenizer.fileInfo.size,reason:`ZIP entry compressed data`});return}let i=OC(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>i)throw Error(`ZIP entry compressed data exceeds ${i} bytes`);let a=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(a),a}function vC(e,t){let n=e.getReader(),r=0,i=!1,a=!1,o=async e=>{i||a||(a=!0,await n.cancel(e))};return new ReadableStream({async pull(e){if(r>=t){e.close(),await o();return}let{done:a,value:s}=await n.read();if(a||!s){i=!0,e.close();return}let c=t-r;if(s.length>c){e.enqueue(s.subarray(0,c)),r+=c,e.close(),await o();return}e.enqueue(s),r+=s.length},async cancel(e){await o(e)}})}async function yC(e,t){return new fw(t).fromBuffer(e)}function bC(e){switch(e=e.toLowerCase(),e){case`application/epub+zip`:return{ext:`epub`,mime:e};case`application/vnd.oasis.opendocument.text`:return{ext:`odt`,mime:e};case`application/vnd.oasis.opendocument.text-template`:return{ext:`ott`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet`:return{ext:`ods`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet-template`:return{ext:`ots`,mime:e};case`application/vnd.oasis.opendocument.presentation`:return{ext:`odp`,mime:e};case`application/vnd.oasis.opendocument.presentation-template`:return{ext:`otp`,mime:e};case`application/vnd.oasis.opendocument.graphics`:return{ext:`odg`,mime:e};case`application/vnd.oasis.opendocument.graphics-template`:return{ext:`otg`,mime:e};case`application/vnd.openxmlformats-officedocument.presentationml.slideshow`:return{ext:`ppsx`,mime:e};case`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`:return{ext:`xlsx`,mime:e};case`application/vnd.ms-excel.sheet.macroenabled`:return{ext:`xlsm`,mime:`application/vnd.ms-excel.sheet.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.spreadsheetml.template`:return{ext:`xltx`,mime:e};case`application/vnd.ms-excel.template.macroenabled`:return{ext:`xltm`,mime:`application/vnd.ms-excel.template.macroenabled.12`};case`application/vnd.ms-powerpoint.slideshow.macroenabled`:return{ext:`ppsm`,mime:`application/vnd.ms-powerpoint.slideshow.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.document`:return{ext:`docx`,mime:e};case`application/vnd.ms-word.document.macroenabled`:return{ext:`docm`,mime:`application/vnd.ms-word.document.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.template`:return{ext:`dotx`,mime:e};case`application/vnd.ms-word.template.macroenabledtemplate`:return{ext:`dotm`,mime:`application/vnd.ms-word.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.template`:return{ext:`potx`,mime:e};case`application/vnd.ms-powerpoint.template.macroenabled`:return{ext:`potm`,mime:`application/vnd.ms-powerpoint.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.presentation`:return{ext:`pptx`,mime:e};case`application/vnd.ms-powerpoint.presentation.macroenabled`:return{ext:`pptm`,mime:`application/vnd.ms-powerpoint.presentation.macroenabled.12`};case`application/vnd.ms-visio.drawing`:return{ext:`vsdx`,mime:`application/vnd.visio`};case`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`:return{ext:`3mf`,mime:`model/3mf`}}}function xC(e,t,n){n={offset:0,...n};for(let[r,i]of t.entries())if(n.mask){if(i!==(n.mask[r]&e[r+n.offset]))return!1}else if(i!==e[r+n.offset])return!1;return!0}function SC(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):FC}function CC(e,t,n){return n===void 0?e.read(t):(n.throwIfAborted(),new Promise((r,i)=>{let a=()=>{n.removeEventListener(`abort`,o)},o=()=>{let t=n.reason;a(),(async()=>{try{await e.cancel(t)}catch{}})(),i(t)};n.addEventListener(`abort`,o,{once:!0}),(async()=>{try{let n=await e.read(t);a(),r(n)}catch(e){a(),i(e)}})()}))}function wC(e){return Number.isFinite(e)?Math.max(0,Math.min(IC,Math.trunc(e))):0}function TC(e){return Number.isFinite(e)?Math.max(0,e):2**53-1}function EC(e){let t=e.fileInfo.size;return!Number.isFinite(t)||t===2**53-1}function DC(e,t,n){return EC(e)&&e.position-t>n}function OC(e){let t=e.fileInfo.size,n=Number.isFinite(t)?Math.max(0,t-e.position):2**53-1;return Math.min(n,zC)}function kC(e){if(e instanceof tS||e instanceof cw)return!0;if(!(e instanceof Error))return!1;if(aw.has(e.message)||sw.has(e.code))return!0;for(let t of ow)if(e.message.startsWith(t))return!0;return!1}function AC(e,t=LC){let n=[e.compressedSize,e.uncompressedSize];for(let e of n)if(!Number.isFinite(e)||e<0||e>t)return!1;return!0}function jC(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function MC(e,t){t.startsWith(`word/`)&&(e.hasWordDirectory=!0),t.startsWith(`ppt/`)&&(e.hasPresentationDirectory=!0),t.startsWith(`xl/`)&&(e.hasSpreadsheetDirectory=!0),t.startsWith(`3D/`)&&t.endsWith(`.model`)&&(e.hasThreeDimensionalModelEntry=!0)}function NC(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:`docx`,mime:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`};if(e.hasPresentationDirectory)return{ext:`pptx`,mime:`application/vnd.openxmlformats-officedocument.presentationml.presentation`};if(e.hasSpreadsheetDirectory)return{ext:`xlsx`,mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`};if(e.hasThreeDimensionalModelEntry)return{ext:`3mf`,mime:`model/3mf`}}}function PC(e){let t=e.indexOf(`.main+xml"`);if(t===-1){let t=`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`;return e.includes(`ContentType="${t}"`)?t:void 0}let n=e.slice(0,t),r=n.lastIndexOf(`"`);return n.slice(r+1)}var FC,IC,LC,RC,zC,BC,VC,HC,UC,WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C,ew,tw,nw,rw,iw,aw,ow,sw,cw,lw,uw,dw,fw,pw=T(()=>{$x(),kS(),ZS(),$S(),rC(),oC(),FC=4100,IC=FC-2,LC=1048576,RC=1024,zC=2**31-1,BC=16777216,VC=LC,HC=LC,UC=BC,WC=1,GC=100,KC=BC,qC=64,JC=VC,YC=256,XC=512,ZC=BC,QC=512,$C=512,ew=256,tw=VC,nw=VC,rw=VC,iw=BC,aw=new Set([`Unexpected signature`,`Encrypted ZIP`,`Expected Central-File-Header signature`]),ow=[`ZIP entry count exceeds `,`Unsupported ZIP compression method:`,`ZIP entry compressed data exceeds `,`ZIP entry decompressed data exceeds `,`Expected data-descriptor-signature at position `],sw=new Set([`Z_BUF_ERROR`,`Z_DATA_ERROR`,`ERR_INVALID_STATE`]),cw=class extends Error{},lw=134695760,uw=16,dw=uw-1,qS.prototype.inflate=async function(e,t,n){if(e.compressedMethod===0)return n(t);if(e.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);return n(await dC(t,{maximumLength:LC}))},qS.prototype.unzip=async function(e){let t=!1,n=0,r=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(DC(this.tokenizer,r,BC))throw new cw(`ZIP stream probing exceeds ${BC} bytes`);let i=await this.readLocalFileHeader();if(!i)break;if(n++,n>RC)throw Error(`ZIP entry count exceeds ${RC}`);let a=e(i);t=!!a.stop,await this.tokenizer.ignore(i.extraFieldLength);let o=await _C(this,i,{shouldBuffer:!!a.handler,maximumDescriptorLength:Math.min(LC,gC(this,r))});if(a.handler&&await this.inflate(i,o,a.handler),i.dataDescriptor){let e=new Uint8Array(uw);if(await this.tokenizer.readBuffer(e),Jx.get(e,0)!==lw)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-e.length}`)}if(DC(this.tokenizer,r,BC))throw new cw(`ZIP stream probing exceeds ${BC} bytes`)}while(!t)},fw=class e{constructor(e){let t=wC(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:`core`,detect:this.detectConfident},{id:`core.imprecise`,detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return sC(ES(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;let n=e.position;for(let t of this.detectors){let r;try{r=await t.detect(e)}catch(e){if(e instanceof tS||e instanceof cw)return;throw e}if(r)return r;if(n!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(DS(t,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let t=OS(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();let t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){let n=SC(t?.sampleSize??FC),r,i,a=e.getReader({mode:`byob`});try{let{value:e,done:t}=await CC(a,new Uint8Array(n),this.options.signal);if(i=e,!t&&e)try{r=await this.fromBuffer(e.subarray(0,n))}catch(e){if(!(e instanceof tS))throw e;r=void 0}i=e}finally{a.releaseLock()}let o=new TransformStream({async start(e){e.enqueue(i)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(o);return s.fileType=r,s}async detectGzip(t){if(this.gzipProbeDepth>=WC)return{ext:`gz`,mime:`application/gzip`};let n=vC(new YS(t).inflate(),UC),r=EC(t),i,a,o,s;if(r){let t=new AbortController;i=setTimeout(()=>{t.abort(new DOMException(`Operation timed out after ${GC} ms`,`TimeoutError`))},GC),a=this.options.signal===void 0?t.signal:AbortSignal.any([this.options.signal,t.signal]),o=new e({...this.options,signal:a}),o.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{s=await(o??this).fromStream(n)}catch(e){if(e?.name===`AbortError`&&a?.reason?.name!==`TimeoutError`)throw e}finally{clearTimeout(i),r||this.gzipProbeDepth--}return s?.ext===`tar`?{ext:`tar.gz`,mime:`application/gzip`}:{ext:`gz`,mime:`application/gzip`}}check(e,t){return xC(this.buffer,e,t)}checkString(e,t){return this.check(eC(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(FC),e.fileInfo.size===void 0&&(e.fileInfo.size=2**53-1),this.tokenizer=e,EC(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:`bmp`,mime:`image/bmp`};if(this.check([11,119]))return{ext:`ac3`,mime:`audio/vnd.dolby.dd-raw`};if(this.check([120,1]))return{ext:`dmg`,mime:`application/x-apple-diskimage`};if(this.check([77,90]))return{ext:`exe`,mime:`application/x-msdownload`};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString(`PS-Adobe-`,{offset:2})&&this.checkString(` EPSF-`,{offset:14})?{ext:`eps`,mime:`application/eps`}:{ext:`ps`,mime:`application/postscript`};if(this.check([31,160])||this.check([31,157]))return{ext:`Z`,mime:`application/x-compress`};if(this.check([199,113]))return{ext:`cpio`,mime:`application/x-cpio`};if(this.check([96,234]))return{ext:`arj`,mime:`application/x-arj`};if(this.check([239,187,191]))return this.detectionReentryCount>=ew?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:`gif`,mime:`image/gif`};if(this.check([73,73,188]))return{ext:`jxr`,mime:`image/vnd.ms-photo`};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:`bz2`,mime:`application/x-bzip2`};if(this.checkString(`ID3`)){await lC(e,6,{maximumLength:6,reason:`ID3 header prefix`});let t=await e.readToken(nC),n=EC(e);if(!Number.isFinite(t)||t<0||n&&(t>KC||e.position+t>KC))return;if(e.position+t>e.fileInfo.size)return n?void 0:{ext:`mp3`,mime:`audio/mpeg`};try{await lC(e,t,{maximumLength:n?KC:e.fileInfo.size,reason:`ID3 payload`})}catch(e){if(e instanceof tS)return;throw e}return this.detectionReentryCount>=ew?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString(`MP+`))return{ext:`mpc`,mime:`audio/x-musepack`};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:`swf`,mime:`application/x-shockwave-flash`};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:`jls`,mime:`image/jls`}:{ext:`jpg`,mime:`image/jpeg`};if(this.check([79,98,106,1]))return{ext:`avro`,mime:`application/avro`};if(this.checkString(`FLIF`))return{ext:`flif`,mime:`image/flif`};if(this.checkString(`8BPS`))return{ext:`psd`,mime:`image/vnd.adobe.photoshop`};if(this.checkString(`MPCK`))return{ext:`mpc`,mime:`audio/x-musepack`};if(this.checkString(`FORM`))return{ext:`aif`,mime:`audio/aiff`};if(this.checkString(`icns`,{offset:0}))return{ext:`icns`,mime:`image/icns`};if(this.check([80,75,3,4])){let t,n=jC();try{await new qS(e).unzip(e=>{MC(n,e.filename);let r=e.filename===`[Content_Types].xml`,i=NC(n);if(!r&&i)return t=i,{stop:!0};switch(e.filename){case`META-INF/mozilla.rsa`:return t={ext:`xpi`,mime:`application/x-xpinstall`},{stop:!0};case`META-INF/MANIFEST.MF`:return t={ext:`jar`,mime:`application/java-archive`},{stop:!0};case`mimetype`:return AC(e,HC)?{async handler(e){t=bC(new TextDecoder(`utf-8`).decode(e).trim())},stop:!0}:{};case`[Content_Types].xml`:return n.hasContentTypesEntry=!0,AC(e,HC)?(n.isParsingContentTypes=!0,{async handler(e){let r=PC(new TextDecoder(`utf-8`).decode(e));r&&(t=bC(r)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(e.filename)?(t={ext:`apk`,mime:`application/vnd.android.package-archive`},{stop:!0}):{}}})}catch(e){if(!kC(e))throw e;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return t??NC(n)??{ext:`zip`,mime:`application/zip`}}if(this.checkString(`OggS`)){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),xC(t,[79,112,117,115,72,101,97,100])?{ext:`opus`,mime:`audio/ogg; codecs=opus`}:xC(t,[128,116,104,101,111,114,97])?{ext:`ogv`,mime:`video/ogg`}:xC(t,[1,118,105,100,101,111,0])?{ext:`ogm`,mime:`video/ogg`}:xC(t,[127,70,76,65,67])?{ext:`oga`,mime:`audio/ogg`}:xC(t,[83,112,101,101,120,32,32])?{ext:`spx`,mime:`audio/ogg`}:xC(t,[1,118,111,114,98,105,115])?{ext:`ogg`,mime:`audio/ogg`}:{ext:`ogx`,mime:`application/ogg`}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:`zip`,mime:`application/zip`};if(this.checkString(`MThd`))return{ext:`mid`,mime:`audio/midi`};if(this.checkString(`wOFF`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff`,mime:`font/woff`};if(this.checkString(`wOF2`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff2`,mime:`font/woff2`};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:`pcap`,mime:`application/vnd.tcpdump.pcap`};if(this.checkString(`DSD `))return{ext:`dsf`,mime:`audio/x-dsf`};if(this.checkString(`LZIP`))return{ext:`lz`,mime:`application/x-lzip`};if(this.checkString(`fLaC`))return{ext:`flac`,mime:`audio/flac`};if(this.check([66,80,71,251]))return{ext:`bpg`,mime:`image/bpg`};if(this.checkString(`wvpk`))return{ext:`wv`,mime:`audio/wavpack`};if(this.checkString(`%PDF`))return{ext:`pdf`,mime:`application/pdf`};if(this.check([0,97,115,109]))return{ext:`wasm`,mime:`application/wasm`};if(this.check([73,73])){let e=await this.readTiffHeader(!1);if(e)return e}if(this.check([77,77])){let e=await this.readTiffHeader(!0);if(e)return e}if(this.checkString(`MAC `))return{ext:`ape`,mime:`audio/ape`};if(this.check([26,69,223,163])){async function t(){let t=await e.peekNumber(Gx),n=128,r=0;for(;(t&n)===0&&n!==0;)++r,n>>=1;let i=new Uint8Array(r+1);return await uC(e,i,void 0,{maximumLength:i.length,reason:`EBML field`}),i}async function n(){let e=await t(),n=await t();n[0]^=128>>n.length-1;let r=Math.min(6,n.length),i=new DataView(e.buffer),a=new DataView(n.buffer,n.length-r,r);return{id:QS(i),len:QS(a)}}async function r(t){let r=0;for(;t>0;){if(r++,r>YC||DC(e,a,BC))return;let i=e.position,o=await n();if(o.id===17026){if(o.len>qC)return;let t=cC(o.len,qC,`EBML DocType`);return(await e.readToken(new Qx(t))).replaceAll(/\00.*$/g,``)}if(EC(e)&&(!Number.isFinite(o.len)||o.len<0||o.len>JC)||(await lC(e,o.len,{maximumLength:EC(e)?JC:e.fileInfo.size,reason:`EBML payload`}),--t,e.position<=i))return}}let i=await n(),a=e.position;switch(await r(i.len)){case`webm`:return{ext:`webm`,mime:`video/webm`};case`matroska`:return{ext:`mkv`,mime:`video/matroska`};default:return}}if(this.checkString(`SQLi`))return{ext:`sqlite`,mime:`application/x-sqlite3`};if(this.check([78,69,83,26]))return{ext:`nes`,mime:`application/x-nintendo-nes-rom`};if(this.checkString(`Cr24`))return{ext:`crx`,mime:`application/x-google-chrome-extension`};if(this.checkString(`MSCF`)||this.checkString(`ISc(`))return{ext:`cab`,mime:`application/vnd.ms-cab-compressed`};if(this.check([237,171,238,219]))return{ext:`rpm`,mime:`application/x-rpm`};if(this.check([197,208,211,198]))return{ext:`eps`,mime:`application/eps`};if(this.check([40,181,47,253]))return{ext:`zst`,mime:`application/zstd`};if(this.check([127,69,76,70]))return{ext:`elf`,mime:`application/x-elf`};if(this.check([33,66,68,78]))return{ext:`pst`,mime:`application/vnd.ms-outlook`};if(this.checkString(`PAR1`)||this.checkString(`PARE`))return{ext:`parquet`,mime:`application/vnd.apache.parquet`};if(this.checkString(`ttcf`))return{ext:`ttc`,mime:`font/collection`};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:`macho`,mime:`application/x-mach-binary`};if(this.check([4,34,77,24]))return{ext:`lz4`,mime:`application/x-lz4`};if(this.checkString(`regf`))return{ext:`dat`,mime:`application/x-ft-windows-registry-hive`};if(this.checkString(`$FL2`)||this.checkString(`$FL3`))return{ext:`sav`,mime:`application/x-spss-sav`};if(this.check([79,84,84,79,0]))return{ext:`otf`,mime:`font/otf`};if(this.checkString(`#!AMR`))return{ext:`amr`,mime:`audio/amr`};if(this.checkString(`{\\rtf`))return{ext:`rtf`,mime:`application/rtf`};if(this.check([70,76,86,1]))return{ext:`flv`,mime:`video/x-flv`};if(this.checkString(`IMPM`))return{ext:`it`,mime:`audio/x-it`};if(this.checkString(`-lh0-`,{offset:2})||this.checkString(`-lh1-`,{offset:2})||this.checkString(`-lh2-`,{offset:2})||this.checkString(`-lh3-`,{offset:2})||this.checkString(`-lh4-`,{offset:2})||this.checkString(`-lh5-`,{offset:2})||this.checkString(`-lh6-`,{offset:2})||this.checkString(`-lh7-`,{offset:2})||this.checkString(`-lzs-`,{offset:2})||this.checkString(`-lz4-`,{offset:2})||this.checkString(`-lz5-`,{offset:2})||this.checkString(`-lhd-`,{offset:2}))return{ext:`lzh`,mime:`application/x-lzh-compressed`};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:`mpg`,mime:`video/MP1S`};if(this.check([68],{offset:4,mask:[196]}))return{ext:`mpg`,mime:`video/MP2P`}}if(this.checkString(`ITSF`))return{ext:`chm`,mime:`application/vnd.ms-htmlhelp`};if(this.check([202,254,186,190])){let e=Yx.get(this.buffer,4),t=qx.get(this.buffer,6);if(e>0&&e<=30)return{ext:`macho`,mime:`application/x-mach-binary`};if(t>30)return{ext:`class`,mime:`application/java-vm`}}if(this.checkString(`.RMF`))return{ext:`rm`,mime:`application/vnd.rn-realmedia`};if(this.checkString(`DRACO`))return{ext:`drc`,mime:`application/vnd.google.draco`};if(this.check([253,55,122,88,90,0]))return{ext:`xz`,mime:`application/x-xz`};if(this.checkString(`<?xml `))return{ext:`xml`,mime:`application/xml`};if(this.check([55,122,188,175,39,28]))return{ext:`7z`,mime:`application/x-7z-compressed`};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:`rar`,mime:`application/x-rar-compressed`};if(this.checkString(`solid `))return{ext:`stl`,mime:`model/stl`};if(this.checkString(`AC`)){let e=new Qx(4,`latin1`).get(this.buffer,2);if(e.match(`^d*`)&&e>=1e3&&e<=1050)return{ext:`dwg`,mime:`image/vnd.dwg`}}if(this.checkString(`070707`))return{ext:`cpio`,mime:`application/x-cpio`};if(this.checkString(`BLENDER`))return{ext:`blend`,mime:`application/x-blender`};if(this.checkString(`!<arch>`))return await e.ignore(8),await e.readToken(new Qx(13,`ascii`))===`debian-binary`?{ext:`deb`,mime:`application/x-deb`}:{ext:`ar`,mime:`application/x-unix-archive`};if(this.checkString(`WEBVTT`)&&[`
719
719
  `,`\r`,` `,` `,`\0`].some(e=>this.checkString(e,{offset:6})))return{ext:`vtt`,mime:`text/vtt`};if(this.check([137,80,78,71,13,10,26,10])){let t={ext:`png`,mime:`image/png`},n={ext:`apng`,mime:`image/apng`};await e.ignore(8);async function r(){return{length:await e.readToken(Xx),type:await e.readToken(new Qx(4,`latin1`))}}let i=EC(e),a=e.position,o=0,s=!1;do{if(o++,o>XC||DC(e,a,ZC))break;let c=e.position,l=await r();if(l.length<0)return;if(l.type===`IHDR`){if(l.length!==13)return;s=!0}switch(l.type){case`IDAT`:return t;case`acTL`:return n;default:if(!s&&l.type!==`CgBI`)return;if(i&&l.length>tw)return s&&pC(l.type)?t:void 0;try{await lC(e,l.length+4,{maximumLength:i?tw+4:e.fileInfo.size,reason:`PNG chunk payload`})}catch(e){if(!i&&(e instanceof cw||e instanceof tS))return t;throw e}}if(e.position<=c)break}while(e.position+8<e.fileInfo.size);return t}if(this.check([65,82,82,79,87,49,0,0]))return{ext:`arrow`,mime:`application/vnd.apache.arrow.file`};if(this.check([103,108,84,70,2,0,0,0]))return{ext:`glb`,mime:`model/gltf-binary`};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:`mov`,mime:`video/quicktime`};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:`orf`,mime:`image/x-olympus-orf`};if(this.checkString(`gimp xcf `))return{ext:`xcf`,mime:`image/x-xcf`};if(this.checkString(`ftyp`,{offset:4})&&this.buffer[8]&96){let e=new Qx(4,`latin1`).get(this.buffer,8).replace(`\0`,` `).trim();switch(e){case`avif`:case`avis`:return{ext:`avif`,mime:`image/avif`};case`mif1`:return{ext:`heic`,mime:`image/heif`};case`msf1`:return{ext:`heic`,mime:`image/heif-sequence`};case`heic`:case`heix`:return{ext:`heic`,mime:`image/heic`};case`hevc`:case`hevx`:return{ext:`heic`,mime:`image/heic-sequence`};case`qt`:return{ext:`mov`,mime:`video/quicktime`};case`M4V`:case`M4VH`:case`M4VP`:return{ext:`m4v`,mime:`video/x-m4v`};case`M4P`:return{ext:`m4p`,mime:`video/mp4`};case`M4B`:return{ext:`m4b`,mime:`audio/mp4`};case`M4A`:return{ext:`m4a`,mime:`audio/x-m4a`};case`F4V`:return{ext:`f4v`,mime:`video/mp4`};case`F4P`:return{ext:`f4p`,mime:`video/mp4`};case`F4A`:return{ext:`f4a`,mime:`audio/mp4`};case`F4B`:return{ext:`f4b`,mime:`audio/mp4`};case`crx`:return{ext:`cr3`,mime:`image/x-canon-cr3`};default:return e.startsWith(`3g`)?e.startsWith(`3g2`)?{ext:`3g2`,mime:`video/3gpp2`}:{ext:`3gp`,mime:`video/3gpp`}:{ext:`mp4`,mime:`video/mp4`}}}if(this.checkString(`REGEDIT4\r
720
720
  `))return{ext:`reg`,mime:`application/x-ms-regedit`};if(this.check([82,73,70,70])){if(this.checkString(`WEBP`,{offset:8}))return{ext:`webp`,mime:`image/webp`};if(this.check([65,86,73],{offset:8}))return{ext:`avi`,mime:`video/vnd.avi`};if(this.check([87,65,86,69],{offset:8}))return{ext:`wav`,mime:`audio/wav`};if(this.check([81,76,67,77],{offset:8}))return{ext:`qcp`,mime:`audio/qcelp`}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:`rw2`,mime:`image/x-panasonic-rw2`};if(this.check([48,38,178,117,142,102,207,17,166,217])){let t=!1;try{async function n(){let t=new Uint8Array(16);return await uC(e,t,void 0,{maximumLength:t.length,reason:`ASF header GUID`}),{id:t,size:Number(await e.readToken(Zx))}}await lC(e,30,{maximumLength:30,reason:`ASF header prelude`});let r=EC(e),i=e.position,a=0;for(;e.position+24<e.fileInfo.size&&(a++,!(a>QC||DC(e,i,BC)));){let i=e.position,a=await n(),o=a.size-24;if(!Number.isFinite(o)||o<0){t=!0;break}if(xC(a.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let t=new Uint8Array(16);if(o-=await uC(e,t,void 0,{maximumLength:t.length,reason:`ASF stream type GUID`}),xC(t,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`audio/x-ms-asf`};if(xC(t,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`video/x-ms-asf`};break}if(r&&o>nw){t=!0;break}if(await lC(e,o,{maximumLength:r?nw:e.fileInfo.size,reason:`ASF header payload`}),e.position<=i){t=!0;break}}}catch(n){if(n instanceof tS||n instanceof cw)EC(e)&&(t=!0);else throw n}return t?void 0:{ext:`asf`,mime:`application/vnd.ms-asf`}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:`ktx`,mime:`image/ktx`};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:`mie`,mime:`application/x-mie`};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:`shp`,mime:`application/x-esri-shape`};if(this.check([255,79,255,81]))return{ext:`j2c`,mime:`image/j2c`};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Qx(4,`ascii`))){case`jp2 `:return{ext:`jp2`,mime:`image/jp2`};case`jpx `:return{ext:`jpx`,mime:`image/jpx`};case`jpm `:return{ext:`jpm`,mime:`image/jpm`};case`mjp2`:return{ext:`mj2`,mime:`image/mj2`};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:`jxl`,mime:`image/jxl`};if(this.check([254,255]))return this.checkString(`<?xml `,{offset:2,encoding:`utf-16be`})?{ext:`xml`,mime:`application/xml`}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:`cfb`,mime:`application/x-cfb`};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:`icc`,mime:`application/vnd.iccprofile`};if(this.checkString(`**ACE`,{offset:7})&&this.checkString(`**`,{offset:12}))return{ext:`ace`,mime:`application/x-ace-compressed`};if(this.checkString(`BEGIN:`)){if(this.checkString(`VCARD`,{offset:6}))return{ext:`vcf`,mime:`text/vcard`};if(this.checkString(`VCALENDAR`,{offset:6}))return{ext:`ics`,mime:`text/calendar`}}if(this.checkString(`FUJIFILMCCD-RAW`))return{ext:`raf`,mime:`image/x-fujifilm-raf`};if(this.checkString(`Extended Module:`))return{ext:`xm`,mime:`audio/x-xm`};if(this.checkString(`Creative Voice File`))return{ext:`voc`,mime:`audio/x-voc`};if(this.check([4,0,0,0])&&this.buffer.length>=16){let e=new DataView(this.buffer.buffer).getUint32(12,!0);if(e>12&&this.buffer.length>=e+16)try{let t=new TextDecoder().decode(this.buffer.subarray(16,e+16));if(JSON.parse(t).files)return{ext:`asar`,mime:`application/x-asar`}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:`mxf`,mime:`application/mxf`};if(this.checkString(`SCRM`,{offset:44}))return{ext:`s3m`,mime:`audio/x-s3m`};if(this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:`mts`,mime:`video/mp2t`};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:`mobi`,mime:`application/x-mobipocket-ebook`};if(this.check([68,73,67,77],{offset:128}))return{ext:`dcm`,mime:`application/dicom`};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:`lnk`,mime:`application/x.ms.shortcut`};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:`alias`,mime:`application/x.apple.alias`};if(this.checkString(`Kaydara FBX Binary \0`))return{ext:`fbx`,mime:`application/x.autodesk.fbx`};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:`eot`,mime:`application/vnd.ms-fontobject`};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:`indd`,mime:`application/x-indesign`};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:`jmp`,mime:`application/x-jmp-data`};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString(`ustar`,{offset:257})&&(this.checkString(`\0`,{offset:262})||this.checkString(` `,{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&tC(this.buffer))return{ext:`tar`,mime:`application/x-tar`};if(this.check([255,254])){let e=`utf-16le`;return this.checkString(`<?xml `,{offset:2,encoding:e})?{ext:`xml`,mime:`application/xml`}:this.check([255,14],{offset:2})&&this.checkString(`SketchUp Model`,{offset:4,encoding:e})?{ext:`skp`,mime:`application/vnd.sketchup.skp`}:this.checkString(`Windows Registry Editor Version 5.00\r
721
721
  `,{offset:2,encoding:e})?{ext:`reg`,mime:`application/x-ms-regedit`}:void 0}if(this.checkString(`-----BEGIN PGP MESSAGE-----`))return{ext:`pgp`,mime:`application/pgp-encrypted`}};detectImprecise=async e=>{this.buffer=new Uint8Array(FC);let t=TC(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:`mpg`,mime:`video/mpeg`};if(this.check([0,1,0,0,0]))return{ext:`ttf`,mime:`font/ttf`};if(this.check([0,0,1,0]))return{ext:`ico`,mime:`image/x-icon`};if(this.check([0,0,2,0]))return{ext:`cur`,mime:`image/x-icon`};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let e=0;e<=this.options.mpegOffsetTolerance;++e){let t=this.scanMpeg(e);if(t)return t}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?qx:Kx);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:`arw`,mime:`image/x-sony-arw`};case 50706:return{ext:`dng`,mime:`image/x-adobe-dng`}}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?qx:Kx);if(!(t>$C)&&!(EC(this.tokenizer)&&2+t*12>iw))for(let n=0;n<t;++n){let t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){let t={ext:`tif`,mime:`image/tiff`},n=(e?qx:Kx).get(this.buffer,2),r=(e?Yx:Jx).get(this.buffer,4);if(n===42){if(r>=6){if(this.checkString(`CR`,{offset:8}))return{ext:`cr2`,mime:`image/x-canon-cr2`};if(r>=8){let t=(e?qx:Kx).get(this.buffer,8),n=(e?qx:Kx).get(this.buffer,10);if(t===28&&n===254||t===31&&n===11)return{ext:`nef`,mime:`image/x-nikon-nef`}}}if(EC(this.tokenizer)&&r>rw)return t;let n=EC(this.tokenizer)?iw:this.tokenizer.fileInfo.size;try{await lC(this.tokenizer,r,{maximumLength:n,reason:`TIFF IFD offset`})}catch(e){if(e instanceof tS)return;throw e}let i;try{i=await this.readTiffIFD(e)}catch(e){if(e instanceof tS)return;throw e}return i??t}if(n===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]}),{ext:`aac`,mime:`audio/aac`};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:`mp3`,mime:`audio/mpeg`};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:`mp2`,mime:`audio/mpeg`};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:`mp1`,mime:`audio/mpeg`}}}},new Set(iC),new Set(aC)}),mw={};E(mw,{fileCommand:()=>Sw,flagsForFuzzing:()=>Cw});function hw(e,t){let n=xw.get(e);if(n)return n;let[r,i]=t.split(`/`),a=i?.split(`+`)[0]?.replace(/-/g,` `)||e;switch(r){case`image`:return`${a.toUpperCase()} image data`;case`audio`:return`${a.toUpperCase()} audio`;case`video`:return`${a.toUpperCase()} video`;case`font`:return`${a} font`;case`model`:return`${a} 3D model`;case`application`:return i?.includes(`zip`)||i?.includes(`compressed`)?`${a} archive data`:i?.includes(`executable`)?`${a} executable`:`${e.toUpperCase()} data`;default:return`${e.toUpperCase()} data`}}function gw(e){let t=e.split(`/`).pop()||e;if(t.startsWith(`.`)&&!t.includes(`.`,1))return t;let n=t.lastIndexOf(`.`);return n===-1||n===0?``:t.slice(n).toLowerCase()}function _w(e,t){if(e.startsWith(`#!`)){let t=e.split(`
722
722
  `)[0];return t.includes(`python`)?{description:`Python script, ASCII text executable`,mime:`text/x-python`}:t.includes(`node`)||t.includes(`bun`)||t.includes(`deno`)?{description:`JavaScript script, ASCII text executable`,mime:`text/javascript`}:t.includes(`bash`)?{description:`Bourne-Again shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`sh`)?{description:`POSIX shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`ruby`)?{description:`Ruby script, ASCII text executable`,mime:`text/x-ruby`}:t.includes(`perl`)?{description:`Perl script, ASCII text executable`,mime:`text/x-perl`}:{description:`script, ASCII text executable`,mime:`text/plain`}}let n=e.trimStart();if(n.startsWith(`<?xml`))return{description:`XML document`,mime:`application/xml`};if(n.startsWith(`<!DOCTYPE html`)||n.toLowerCase().startsWith(`<html`))return{description:`HTML document`,mime:`text/html`};let r=e.includes(`\r
723
- `),i=e.includes(`\r`)&&!r,a=``;r?a=`, with CRLF line terminators`:i&&(a=`, with CR line terminators`);let o=gw(t),s=o?bw.get(o):void 0;if(s)return s.mime.startsWith(`text/`)&&a?{description:`${s.description}${a}`,mime:s.mime}:s;let c=!1;for(let t=0;t<Math.min(e.length,8192);t++)if(e.charCodeAt(t)>127){c=!0;break}return c?{description:`UTF-8 Unicode text${a}`,mime:`text/plain; charset=utf-8`}:{description:`ASCII text${a}`,mime:`text/plain`}}async function vw(e,t){if(t.length===0)return{description:`empty`,mime:`inode/x-empty`};let n=await yC(t);return n?{description:hw(n.ext,n.mime),mime:n.mime}:_w(new TextDecoder(`utf-8`,{fatal:!1}).decode(t),e)}var yw,bw,xw,Sw,Cw,ww=T(()=>{pw(),Wi(),Wr(),F(),yw={name:`file`,summary:`determine file type`,usage:`file [OPTION]... FILE...`,options:[`-b, --brief do not prepend filenames to output`,`-i, --mime output MIME type strings`,`-L, --dereference follow symlinks`,` --help display this help and exit`]},bw=new Map([[`.js`,{description:`JavaScript source`,mime:`text/javascript`}],[`.mjs`,{description:`JavaScript module`,mime:`text/javascript`}],[`.cjs`,{description:`CommonJS module`,mime:`text/javascript`}],[`.ts`,{description:`TypeScript source`,mime:`text/typescript`}],[`.tsx`,{description:`TypeScript JSX source`,mime:`text/typescript`}],[`.jsx`,{description:`JavaScript JSX source`,mime:`text/javascript`}],[`.py`,{description:`Python script`,mime:`text/x-python`}],[`.rb`,{description:`Ruby script`,mime:`text/x-ruby`}],[`.go`,{description:`Go source`,mime:`text/x-go`}],[`.rs`,{description:`Rust source`,mime:`text/x-rust`}],[`.c`,{description:`C source`,mime:`text/x-c`}],[`.h`,{description:`C header`,mime:`text/x-c`}],[`.cpp`,{description:`C++ source`,mime:`text/x-c++`}],[`.hpp`,{description:`C++ header`,mime:`text/x-c++`}],[`.java`,{description:`Java source`,mime:`text/x-java`}],[`.sh`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.bash`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.zsh`,{description:`Zsh shell script`,mime:`text/x-shellscript`}],[`.json`,{description:`JSON data`,mime:`application/json`}],[`.yaml`,{description:`YAML data`,mime:`text/yaml`}],[`.yml`,{description:`YAML data`,mime:`text/yaml`}],[`.xml`,{description:`XML document`,mime:`application/xml`}],[`.csv`,{description:`CSV text`,mime:`text/csv`}],[`.toml`,{description:`TOML data`,mime:`text/toml`}],[`.html`,{description:`HTML document`,mime:`text/html`}],[`.htm`,{description:`HTML document`,mime:`text/html`}],[`.css`,{description:`CSS stylesheet`,mime:`text/css`}],[`.svg`,{description:`SVG image`,mime:`image/svg+xml`}],[`.md`,{description:`Markdown document`,mime:`text/markdown`}],[`.markdown`,{description:`Markdown document`,mime:`text/markdown`}],[`.txt`,{description:`ASCII text`,mime:`text/plain`}],[`.rst`,{description:`reStructuredText`,mime:`text/x-rst`}],[`.env`,{description:`ASCII text`,mime:`text/plain`}],[`.gitignore`,{description:`ASCII text`,mime:`text/plain`}],[`.dockerignore`,{description:`ASCII text`,mime:`text/plain`}]]),xw=new Map([[`jpg`,`JPEG image data`],[`jpeg`,`JPEG image data`],[`png`,`PNG image data`],[`gif`,`GIF image data`],[`webp`,`WebP image data`],[`bmp`,`PC bitmap`],[`ico`,`MS Windows icon resource`],[`tif`,`TIFF image data`],[`tiff`,`TIFF image data`],[`psd`,`Adobe Photoshop Document`],[`avif`,`AVIF image`],[`heic`,`HEIC image`],[`heif`,`HEIF image`],[`jxl`,`JPEG XL image`],[`icns`,`Mac OS X icon`],[`svg`,`SVG Scalable Vector Graphics image`],[`pdf`,`PDF document`],[`epub`,`EPUB document`],[`mobi`,`Mobipocket E-book`],[`djvu`,`DjVu document`],[`zip`,`Zip archive data`],[`gz`,`gzip compressed data`],[`gzip`,`gzip compressed data`],[`bz2`,`bzip2 compressed data`],[`xz`,`XZ compressed data`],[`tar`,`POSIX tar archive`],[`rar`,`RAR archive data`],[`7z`,`7-zip archive data`],[`lz`,`lzip compressed data`],[`lzma`,`LZMA compressed data`],[`zst`,`Zstandard compressed data`],[`cab`,`Microsoft Cabinet archive`],[`ar`,`Unix ar archive`],[`rpm`,`RPM package`],[`deb`,`Debian binary package`],[`apk`,`Android Package`],[`dmg`,`Apple disk image`],[`iso`,`ISO 9660 CD-ROM filesystem data`],[`vhd`,`Microsoft Virtual Hard Disk`],[`vhdx`,`Microsoft Virtual Hard Disk (new format)`],[`qcow2`,`QEMU QCOW Image`],[`mp3`,`Audio file with ID3`],[`m4a`,`MPEG-4 audio`],[`aac`,`AAC audio`],[`wav`,`RIFF (little-endian) data, WAVE audio`],[`flac`,`FLAC audio bitstream data`],[`ogg`,`Ogg data`],[`oga`,`Ogg audio`],[`opus`,`Ogg Opus audio`],[`aiff`,`AIFF audio`],[`wma`,`Windows Media Audio`],[`amr`,`AMR audio`],[`mid`,`MIDI audio`],[`midi`,`MIDI audio`],[`ape`,`Monkey's Audio`],[`mp4`,`ISO Media, MPEG-4`],[`m4v`,`MPEG-4 video`],[`webm`,`WebM`],[`avi`,`RIFF (little-endian) data, AVI`],[`mov`,`ISO Media, Apple QuickTime movie`],[`mkv`,`Matroska data`],[`wmv`,`Windows Media Video`],[`flv`,`Flash Video`],[`3gp`,`3GPP multimedia`],[`3g2`,`3GPP2 multimedia`],[`ogv`,`Ogg video`],[`mts`,`MPEG transport stream`],[`m2ts`,`MPEG transport stream`],[`ts`,`MPEG transport stream`],[`mpg`,`MPEG video`],[`mpeg`,`MPEG video`],[`exe`,`PE32 executable`],[`dll`,`PE32 DLL`],[`elf`,`ELF executable`],[`mach`,`Mach-O executable`],[`wasm`,`WebAssembly (wasm) binary module`],[`dex`,`Android Dalvik executable`],[`class`,`Java class file`],[`swf`,`Adobe Flash`],[`doc`,`Microsoft Word Document`],[`docx`,`Microsoft Word 2007+ Document`],[`xls`,`Microsoft Excel Spreadsheet`],[`xlsx`,`Microsoft Excel 2007+ Spreadsheet`],[`ppt`,`Microsoft PowerPoint Presentation`],[`pptx`,`Microsoft PowerPoint 2007+ Presentation`],[`odt`,`OpenDocument Text`],[`ods`,`OpenDocument Spreadsheet`],[`odp`,`OpenDocument Presentation`],[`ttf`,`TrueType Font`],[`otf`,`OpenType Font`],[`woff`,`Web Open Font Format`],[`woff2`,`Web Open Font Format 2`],[`eot`,`Embedded OpenType font`],[`stl`,`Stereolithography CAD`],[`obj`,`Wavefront 3D Object`],[`gltf`,`GL Transmission Format`],[`glb`,`GL Transmission Format (binary)`],[`sqlite`,`SQLite 3.x database`],[`mdb`,`Microsoft Access Database`],[`xml`,`XML document`],[`json`,`JSON data`],[`macho`,`Mach-O binary`],[`ics`,`iCalendar data`],[`vcf`,`vCard data`],[`msi`,`Microsoft Installer`],[`ps`,`PostScript`],[`ai`,`Adobe Illustrator`],[`indd`,`Adobe InDesign`],[`sketch`,`Sketch design file`],[`fig`,`Figma design file`],[`xd`,`Adobe XD`],[`blend`,`Blender`],[`fbx`,`Autodesk FBX`],[`lnk`,`MS Windows shortcut`],[`alias`,`Mac OS alias`],[`torrent`,`BitTorrent file`],[`pcap`,`pcap capture file`],[`arrow`,`Apache Arrow`],[`parquet`,`Apache Parquet`]]),Sw={name:`file`,async execute(e,t){if(N(e))return M(yw);let n=!1,r=!1,i=!1,a=[];for(let t of e)if(t.startsWith(`--`))if(t===`--brief`)n=!0;else if(t===`--mime`||t===`--mime-type`)r=!0;else if(t===`--dereference`)i=!0;else return P(`file`,t);else if(t.startsWith(`-`)&&t!==`-`)for(let e of t.slice(1))if(e===`b`)n=!0;else if(e===`i`)r=!0;else if(e===`L`)i=!0;else return P(`file`,`-${e}`);else a.push(t);if(a.length===0)return{stdout:``,stderr:`Usage: file [-bLi] FILE...
723
+ `),i=e.includes(`\r`)&&!r,a=``;r?a=`, with CRLF line terminators`:i&&(a=`, with CR line terminators`);let o=gw(t),s=o?bw.get(o):void 0;if(s)return s.mime.startsWith(`text/`)&&a?{description:`${s.description}${a}`,mime:s.mime}:s;let c=!1;for(let t=0;t<Math.min(e.length,8192);t++)if(e.charCodeAt(t)>127){c=!0;break}return c?{description:`UTF-8 Unicode text${a}`,mime:`text/plain; charset=utf-8`}:{description:`ASCII text${a}`,mime:`text/plain`}}async function vw(e,t){if(t.length===0)return{description:`empty`,mime:`inode/x-empty`};let n=await yC(t);return n?{description:hw(n.ext,n.mime),mime:n.mime}:_w(new TextDecoder(`utf-8`,{fatal:!1}).decode(t),e)}var yw,bw,xw,Sw,Cw,ww=T(()=>{pw(),Wi(),Wr(),F(),yw={name:`file`,summary:`determine file type`,usage:`file [OPTION]... FILE...`,options:[`-b, --brief do not prepend filenames to output`,`-i, --mime output MIME type strings`,`-L, --dereference follow symlinks`,` --help display this help and exit`]},bw=new Map([[`.js`,{description:`JavaScript source`,mime:`text/javascript`}],[`.mjs`,{description:`JavaScript module`,mime:`text/javascript`}],[`.cjs`,{description:`CommonJS module`,mime:`text/javascript`}],[`.ts`,{description:`TypeScript source`,mime:`text/typescript`}],[`.tsx`,{description:`TypeScript JSX source`,mime:`text/typescript`}],[`.jsx`,{description:`JavaScript JSX source`,mime:`text/javascript`}],[`.py`,{description:`Python script`,mime:`text/x-python`}],[`.rb`,{description:`Ruby script`,mime:`text/x-ruby`}],[`.go`,{description:`Go source`,mime:`text/x-go`}],[`.rs`,{description:`Rust source`,mime:`text/x-rust`}],[`.c`,{description:`C source`,mime:`text/x-c`}],[`.h`,{description:`C header`,mime:`text/x-c`}],[`.cpp`,{description:`C++ source`,mime:`text/x-c++`}],[`.hpp`,{description:`C++ header`,mime:`text/x-c++`}],[`.java`,{description:`Java source`,mime:`text/x-java`}],[`.sh`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.bash`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.zsh`,{description:`Zsh shell script`,mime:`text/x-shellscript`}],[`.json`,{description:`JSON data`,mime:`application/json`}],[`.yaml`,{description:`YAML data`,mime:`text/yaml`}],[`.yml`,{description:`YAML data`,mime:`text/yaml`}],[`.xml`,{description:`XML document`,mime:`application/xml`}],[`.csv`,{description:`CSV text`,mime:`text/csv`}],[`.toml`,{description:`TOML data`,mime:`text/toml`}],[`.html`,{description:`HTML document`,mime:`text/html`}],[`.htm`,{description:`HTML document`,mime:`text/html`}],[`.css`,{description:`CSS stylesheet`,mime:`text/css`}],[`.svg`,{description:`SVG image`,mime:`image/svg+xml`}],[`.md`,{description:`Markdown document`,mime:`text/markdown`}],[`.markdown`,{description:`Markdown document`,mime:`text/markdown`}],[`.txt`,{description:`ASCII text`,mime:`text/plain`}],[`.rst`,{description:`reStructuredText`,mime:`text/x-rst`}],[`.env`,{description:`ASCII text`,mime:`text/plain`}],[`.gitignore`,{description:`ASCII text`,mime:`text/plain`}],[`.dockerignore`,{description:`ASCII text`,mime:`text/plain`}]]),xw=new Map([[`jpg`,`JPEG image data`],[`jpeg`,`JPEG image data`],[`png`,`PNG image data`],[`gif`,`GIF image data`],[`webp`,`WebP image data`],[`bmp`,`PC bitmap`],[`ico`,`MS Windows icon resource`],[`tif`,`TIFF image data`],[`tiff`,`TIFF image data`],[`psd`,`Adobe Photoshop Document`],[`avif`,`AVIF image`],[`heic`,`HEIC image`],[`heif`,`HEIF image`],[`jxl`,`JPEG XL image`],[`icns`,`Mac OS X icon`],[`svg`,`SVG Scalable Vector Graphics image`],[`pdf`,`PDF document`],[`epub`,`EPUB document`],[`mobi`,`Mobipocket E-book`],[`djvu`,`DjVu document`],[`zip`,`Zip archive data`],[`gz`,`gzip compressed data`],[`gzip`,`gzip compressed data`],[`bz2`,`bzip2 compressed data`],[`xz`,`XZ compressed data`],[`tar`,`POSIX tar archive`],[`rar`,`RAR archive data`],[`7z`,`7-zip archive data`],[`lz`,`lzip compressed data`],[`lzma`,`LZMA compressed data`],[`zst`,`Zstandard compressed data`],[`cab`,`Microsoft Cabinet archive`],[`ar`,`Unix ar archive`],[`rpm`,`RPM package`],[`deb`,`Debian binary package`],[`apk`,`Android Package`],[`dmg`,`Apple disk image`],[`iso`,`ISO 9660 CD-ROM filesystem data`],[`vhd`,`Microsoft Virtual Hard Disk`],[`vhdx`,`Microsoft Virtual Hard Disk (new format)`],[`qcow2`,`QEMU QCOW Image`],[`mp3`,`Audio file with ID3`],[`m4a`,`MPEG-4 audio`],[`aac`,`AAC audio`],[`wav`,`RIFF (little-endian) data, WAVE audio`],[`flac`,`FLAC audio bitstream data`],[`ogg`,`Ogg data`],[`oga`,`Ogg audio`],[`opus`,`Ogg Opus audio`],[`aiff`,`AIFF audio`],[`wma`,`Windows Media Audio`],[`amr`,`AMR audio`],[`mid`,`MIDI audio`],[`midi`,`MIDI audio`],[`ape`,`Monkey's Audio`],[`mp4`,`ISO Media, MPEG-4`],[`m4v`,`MPEG-4 video`],[`webm`,`WebM`],[`avi`,`RIFF (little-endian) data, AVI`],[`mov`,`ISO Media, Apple QuickTime movie`],[`mkv`,`Matroska data`],[`wmv`,`Windows Media Video`],[`flv`,`Flash Video`],[`3gp`,`3GPP multimedia`],[`3g2`,`3GPP2 multimedia`],[`ogv`,`Ogg video`],[`mts`,`MPEG transport stream`],[`m2ts`,`MPEG transport stream`],[`ts`,`MPEG transport stream`],[`mpg`,`MPEG video`],[`mpeg`,`MPEG video`],[`exe`,`PE32 executable`],[`dll`,`PE32 DLL`],[`elf`,`ELF executable`],[`mach`,`Mach-O executable`],[`wasm`,`WebAssembly (wasm) binary module`],[`dex`,`Android Dalvik executable`],[`class`,`Java class file`],[`swf`,`Adobe Flash`],[`doc`,`Microsoft Word Document`],[`docx`,`Microsoft Word 2007+ Document`],[`xls`,`Microsoft Excel Spreadsheet`],[`xlsx`,`Microsoft Excel 2007+ Spreadsheet`],[`ppt`,`Microsoft PowerPoint Presentation`],[`pptx`,`Microsoft PowerPoint 2007+ Presentation`],[`odt`,`OpenDocument Text`],[`ods`,`OpenDocument Spreadsheet`],[`odp`,`OpenDocument Presentation`],[`ttf`,`TrueType Font`],[`otf`,`OpenType Font`],[`woff`,`Web Open Font Format`],[`woff2`,`Web Open Font Format 2`],[`eot`,`Embedded OpenType font`],[`stl`,`Stereolithography CAD`],[`obj`,`Wavefront 3D Object`],[`gltf`,`GL Transmission Format`],[`glb`,`GL Transmission Format (binary)`],[`sqlite`,`SQLite 3.x database`],[`mdb`,`Microsoft Access Database`],[`xml`,`XML document`],[`json`,`JSON data`],[`macho`,`Mach-O binary`],[`ics`,`iCalendar data`],[`vcf`,`vCard data`],[`msi`,`Microsoft Installer`],[`ps`,`PostScript`],[`ai`,`Adobe Illustrator`],[`indd`,`Adobe InDesign`],[`sketch`,`Sketch design file`],[`fig`,`Figma design file`],[`xd`,`Adobe XD`],[`blend`,`Blender`],[`fbx`,`Autodesk FBX`],[`lnk`,`MS Windows shortcut`],[`alias`,`Mac OS alias`],[`torrent`,`BitTorrent file`],[`pcap`,`pcap capture file`],[`arrow`,`Apache Arrow`],[`parquet`,`Apache Parquet`]]),Sw={name:`file`,async execute(e,t){if(N(e))return M(yw);let n=!1,r=!1,i=!1,a=[];for(let t of e)if(t.startsWith(`--`)){if(t===`--brief`)n=!0;else if(t===`--mime`||t===`--mime-type`)r=!0;else if(t===`--dereference`)i=!0;else return P(`file`,t)}else if(t.startsWith(`-`)&&t!==`-`)for(let e of t.slice(1))if(e===`b`)n=!0;else if(e===`i`)r=!0;else if(e===`L`)i=!0;else return P(`file`,`-${e}`);else a.push(t);if(a.length===0)return{stdout:``,stderr:`Usage: file [-bLi] FILE...
724
724
  `,exitCode:1};let o=new Ui(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`file`),s=0;for(let e of a){t.executionScope?.consumeLimited(`file-operands`,1,t.limits.maxArrayElements,`file`);try{let a=t.fs.resolvePath(t.cwd,e),s=i?await t.fs.stat(a):await t.fs.lstat(a);if(s.isSymbolicLink){let i=await t.fs.readlink(a),s=r?`inode/symlink`:`symbolic link to ${i}`;o.append(n?`${s}
725
725
  `:`${e}: ${s}
726
726
  `);continue}if(s.isDirectory){let t=r?`inode/directory`:`directory`;o.append(n?`${t}
@@ -821,7 +821,7 @@ ${e}\r
821
821
  `:``,exitCode:22};let c=(r.outputFile||r.useRemoteName)&&!r.verbose?``:fE(r,s,i);if(r.outputFile||r.useRemoteName){let e=r.outputFile||nE(i),n=t.fs.resolvePath(t.cwd,e);await t.fs.writeFile(n,r.headOnly?``:s.body),r.verbose||(c=``),r.writeOut&&(c=rE(r.writeOut,{status:s.status,headers:s.headers,url:s.url,bodyLength:s.body.byteLength}))}return{stdout:c,stderr:``,exitCode:0,stdoutKind:`bytes`}}catch(e){let t=si(e),n=1;return t.includes(`Network access denied`)?n=7:t.includes(`HTTP method`)&&t.includes(`not allowed`)?n=3:t.includes(`Redirect target not in allow-list`)||t.includes(`Too many redirects`)?n=47:t.includes(`aborted`)&&(n=28),{stdout:``,stderr:!r.silent||r.showError?`curl: (${n}) ${t}
822
822
  `:``,exitCode:n}}}}});nr(),ir(),Lr(),qn();var hE=[{name:`echo`,load:async()=>(await Promise.resolve().then(()=>(Hr(),Rr))).echoCommand},{name:`cat`,load:async()=>(await Promise.resolve().then(()=>(oi(),Qr))).catCommand},{name:`printf`,load:async()=>(await Promise.resolve().then(()=>(Li(),yi))).printfCommand},{name:`ls`,load:async()=>(await Promise.resolve().then(()=>(Sa(),ua))).lsCommand},{name:`mkdir`,load:async()=>(await Promise.resolve().then(()=>(Da(),Ca))).mkdirCommand},{name:`rmdir`,load:async()=>(await Promise.resolve().then(()=>(Ia(),Oa))).rmdirCommand},{name:`touch`,load:async()=>(await Promise.resolve().then(()=>(Va(),La))).touchCommand},{name:`rm`,load:async()=>(await Promise.resolve().then(()=>(Ka(),Ha))).rmCommand},{name:`cp`,load:async()=>(await Promise.resolve().then(()=>(Qa(),qa))).cpCommand},{name:`mv`,load:async()=>(await Promise.resolve().then(()=>(io(),$a))).mvCommand},{name:`ln`,load:async()=>(await Promise.resolve().then(()=>(lo(),ao))).lnCommand},{name:`chmod`,load:async()=>(await Promise.resolve().then(()=>(_o(),uo))).chmodCommand},{name:`pwd`,load:async()=>(await Promise.resolve().then(()=>(xo(),vo))).pwdCommand},{name:`readlink`,load:async()=>(await Promise.resolve().then(()=>(Eo(),So))).readlinkCommand},{name:`head`,load:async()=>(await Promise.resolve().then(()=>(Io(),Mo))).headCommand},{name:`tail`,load:async()=>(await Promise.resolve().then(()=>(Vo(),Lo))).tailCommand},{name:`wc`,load:async()=>(await Promise.resolve().then(()=>(Yo(),Ho))).wcCommand},{name:`stat`,load:async()=>(await Promise.resolve().then(()=>(rs(),Qo))).statCommand},{name:`grep`,load:async()=>(await Promise.resolve().then(()=>(ul(),Wc))).grepCommand},{name:`fgrep`,load:async()=>(await Promise.resolve().then(()=>(ul(),Wc))).fgrepCommand},{name:`egrep`,load:async()=>(await Promise.resolve().then(()=>(ul(),Wc))).egrepCommand},{name:`rg`,load:async()=>(await Promise.resolve().then(()=>(yu(),hu))).rgCommand},{name:`sed`,load:async()=>(await Promise.resolve().then(()=>(nd(),Zu))).sedCommand},{name:`awk`,load:async()=>(await Promise.resolve().then(()=>(Lp(),Ap))).awkCommand2},{name:`sort`,load:async()=>(await Promise.resolve().then(()=>(tm(),Zp))).sortCommand},{name:`uniq`,load:async()=>(await Promise.resolve().then(()=>(sm(),nm))).uniqCommand},{name:`comm`,load:async()=>(await Promise.resolve().then(()=>(fm(),cm))).commCommand},{name:`cut`,load:async()=>(await Promise.resolve().then(()=>(ym(),pm))).cutCommand},{name:`paste`,load:async()=>(await Promise.resolve().then(()=>(Em(),bm))).pasteCommand},{name:`tr`,load:async()=>(await Promise.resolve().then(()=>(Pm(),Dm))).trCommand},{name:`rev`,load:async()=>(await Promise.resolve().then(()=>(Bm(),Fm))).rev},{name:`nl`,load:async()=>(await Promise.resolve().then(()=>(Jm(),Vm))).nl},{name:`fold`,load:async()=>(await Promise.resolve().then(()=>(nh(),Ym))).fold},{name:`expand`,load:async()=>(await Promise.resolve().then(()=>(dh(),rh))).expand},{name:`unexpand`,load:async()=>(await Promise.resolve().then(()=>(bh(),fh))).unexpand},{name:`strings`,load:async()=>(await Promise.resolve().then(()=>(Oh(),xh))).strings},{name:`split`,load:async()=>(await Promise.resolve().then(()=>(Kh(),kh))).split},{name:`column`,load:async()=>(await Promise.resolve().then(()=>(ng(),qh))).column},{name:`join`,load:async()=>(await Promise.resolve().then(()=>(dg(),rg))).join},{name:`tee`,load:async()=>(await Promise.resolve().then(()=>(_g(),fg))).teeCommand},{name:`find`,load:async()=>(await Promise.resolve().then(()=>(Kg(),Fg))).findCommand},{name:`basename`,load:async()=>(await Promise.resolve().then(()=>(Zg(),qg))).basenameCommand},{name:`dirname`,load:async()=>(await Promise.resolve().then(()=>(n_(),Qg))).dirnameCommand},{name:`tree`,load:async()=>(await Promise.resolve().then(()=>(u_(),r_))).treeCommand},{name:`du`,load:async()=>(await Promise.resolve().then(()=>(v_(),d_))).duCommand},{name:`env`,load:async()=>(await Promise.resolve().then(()=>(E_(),y_))).envCommand},{name:`printenv`,load:async()=>(await Promise.resolve().then(()=>(E_(),y_))).printenvCommand},{name:`alias`,load:async()=>(await Promise.resolve().then(()=>(P_(),D_))).aliasCommand},{name:`unalias`,load:async()=>(await Promise.resolve().then(()=>(P_(),D_))).unaliasCommand},{name:`history`,load:async()=>(await Promise.resolve().then(()=>(B_(),F_))).historyCommand},{name:`xargs`,load:async()=>(await Promise.resolve().then(()=>(q_(),V_))).xargsCommand},{name:`true`,load:async()=>(await Promise.resolve().then(()=>($_(),J_))).trueCommand},{name:`false`,load:async()=>(await Promise.resolve().then(()=>($_(),J_))).falseCommand},{name:`clear`,load:async()=>(await Promise.resolve().then(()=>(iv(),ev))).clearCommand},{name:`bash`,load:async()=>(await Promise.resolve().then(()=>(fv(),av))).bashCommand},{name:`sh`,load:async()=>(await Promise.resolve().then(()=>(fv(),av))).shCommand},{name:`jq`,load:async()=>(await Promise.resolve().then(()=>(sb(),Qy))).jqCommand},{name:`base64`,load:async()=>(await Promise.resolve().then(()=>(_b(),cb))).base64Command},{name:`diff`,load:async()=>(await Promise.resolve().then(()=>(Cb(),vb))).diffCommand},{name:`date`,load:async()=>(await Promise.resolve().then(()=>(Mb(),wb))).dateCommand},{name:`sleep`,load:async()=>(await Promise.resolve().then(()=>(Bb(),Fb))).sleepCommand},{name:`timeout`,load:async()=>(await Promise.resolve().then(()=>(Gb(),Vb))).timeoutCommand},{name:`time`,load:async()=>(await Promise.resolve().then(()=>(ex(),Xb))).timeCommand},{name:`seq`,load:async()=>(await Promise.resolve().then(()=>(ix(),tx))).seqCommand},{name:`expr`,load:async()=>(await Promise.resolve().then(()=>(lx(),ax))).exprCommand},{name:`md5sum`,load:async()=>(await Promise.resolve().then(()=>(vx(),hx))).md5sumCommand},{name:`sha1sum`,load:async()=>(await Promise.resolve().then(()=>(Sx(),yx))).sha1sumCommand},{name:`sha256sum`,load:async()=>(await Promise.resolve().then(()=>(Ex(),Cx))).sha256sumCommand},{name:`file`,load:async()=>(await Promise.resolve().then(()=>(ww(),mw))).fileCommand},{name:`html-to-markdown`,load:async()=>(await Promise.resolve().then(()=>(kw(),Tw))).htmlToMarkdownCommand},{name:`help`,load:async()=>(await Promise.resolve().then(()=>(Fw(),Aw))).helpCommand},{name:`which`,load:async()=>(await Promise.resolve().then(()=>(Vw(),Iw))).whichCommand},{name:`tac`,load:async()=>(await Promise.resolve().then(()=>(Kw(),Hw))).tac},{name:`hostname`,load:async()=>(await Promise.resolve().then(()=>(Zw(),qw))).hostname},{name:`whoami`,load:async()=>(await Promise.resolve().then(()=>(nT(),Qw))).whoami},{name:`od`,load:async()=>(await Promise.resolve().then(()=>(sT(),rT))).od},{name:`gzip`,load:async()=>(await Promise.resolve().then(()=>(LT(),uT))).gzipCommand},{name:`gunzip`,load:async()=>(await Promise.resolve().then(()=>(LT(),uT))).gunzipCommand},{name:`zcat`,load:async()=>(await Promise.resolve().then(()=>(LT(),uT))).zcatCommand}],gE=[],_E=[],vE=[{name:`curl`,load:async()=>(await Promise.resolve().then(()=>(mE(),aE))).curlCommand}],yE=new Map;function bE(e){return{name:e.name,async execute(t,n){let r=yE.get(e.name);return r||(r=await Kn.runTrustedAsync(()=>e.load()),yE.set(e.name,r)),n.coverage,r.execute(t,n)}}}function xE(){return hE.map(e=>e.name)}function SE(){return vE.map(e=>e.name)}function CE(e){return(e?hE.filter(t=>e.includes(t.name)):hE).map(bE)}function wE(){return vE.map(bE)}function TE(){return gE.map(bE)}function EE(){return _E.map(bE)}k();var DE=new WeakMap,OE=new WeakSet;function kE(e){let t=DE.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),DE.set(e,t),OE.add(t)),t}function AE(e){return OE.has(e)}var jE={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},ME={...jE,maxSourceBytes:8388608,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxFileSystemBytes:134217728,maxDatabaseBytes:67108864,maxDatabaseResultBytes:16777216,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5,maxWorkerMessageBytes:16777216,maxExecutionTimeMs:3e4};function NE(e,t=`normal`){if(t!==`normal`&&t!==`hardened`)throw RangeError(`executionLimitProfile must be "normal" or "hardened"`);let n=t===`hardened`?ME:jE;if(!e)return{...n};let r={maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let e of Object.keys(r)){let t=r[e];if(t!==1/0&&(!Number.isSafeInteger(t)||t<0))throw RangeError(`${e} must be a non-negative safe integer or positive Infinity`)}return r}function PE(e){let{executionLimits:t,executionLimitProfile:n,fs:r,stdin:i=gr,...a}=e;return{fs:r,fsIdentity:a.fsIdentity??kE(r),cwd:`/`,env:new Map,stdin:i,limits:NE(t,n),...a}}function FE(e){return`load`in e&&typeof e.load==`function`}function IE(e,t,n={}){return{name:e,trusted:n.trusted!==!1,execute:t}}function LE(e){let t=null,n=null;return{name:e.name,trusted:e.trusted!==!1,async execute(r,i){if(!t){let r=n;r||(r=e.load().then(e=>(t=e,e)),n=r);try{t=await r}catch(e){throw n===r&&(n=null),e}}let a=t;if(!a)throw Error(`Failed to load command: ${e.name}`);return a.execute(r,i)}}}k(),k(),j(),nr();var RE=Object.freeze(Object.create(null)),zE=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(e,t=void 0){this.limits=e,this.signal=t}fail(e){throw this.poisoned??=e,this.poisoned}poisonAfterAbort(e){this.poisoned??=e}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw Error(`execution budget is already closed`);this.throwIfAborted()}chargeCommand(){return this.consume(`commands`,1,`execution`)}consumeWork(e=1,t=`execution`){return this.consume(`work`,e,t)}consumeLimited(e,t,n,r=e){this.assertUsable();let i=this.countersByKind.get(e)??0;return(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n)||n<0||t>n-i)&&this.fail(new A(`${r}: ${e} work limit exceeded (${n})`,`iterations`)),t>this.limits.maxWorkUnits-this.workUnits&&this.fail(new A(`${r}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,`iterations`)),this.countersByKind.set(e,i+t),this.workUnits+=t,i+t}consumeInput(e,t=`execution`){return this.assertUsable(),(!Number.isSafeInteger(e)||e<0||e>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new A(`${t}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,`string_length`)),this.inputBytes+=e,this.inputBytes}consume(e,t=1,n=e){this.assertUsable();let r=this.countersByKind.get(e)??0,i=e===`commands`?this.commandCount:this.workUnits,a=e===`commands`?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(t)||t<0||t>a-i)&&this.fail(new A(e===`commands`?`too many commands executed (>${a}), increase executionLimits.maxCommandCount`:`${n}: ${e} work limit exceeded (${a})`,e===`commands`?`commands`:`iterations`));let o=i+t;return e===`commands`?this.commandCount=o:this.workUnits=o,this.countersByKind.set(e,r+t),o}reserveBytes(e,t,n){this.assertUsable();let r=typeof e==`string`?e:`live`,i=typeof e==`string`?t:e,a=typeof e==`string`?n??r:t??`execution`;(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new A(`${a}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,`string_length`)),this.liveBytes+=i,this.bytesByKind.set(r,(this.bytesByKind.get(r)??0)+i);let o=!1;return{release:()=>{if(o)return;o=!0,this.liveBytes-=i;let e=(this.bytesByKind.get(r)??i)-i;e<=0?this.bytesByKind.delete(r):this.bytesByKind.set(r,e)}}}appendOutput(e,t,n=`execution`,r=0,i=`text`){this.assertUsable();let a=i===`bytes`?t.length:O(t);(!Number.isSafeInteger(r)||r<0||r>a)&&this.fail(new A(`${n}: invalid ${e} accounting`,`output_size`));let o=a-r;return o>this.limits.maxOutputSize-this.outputBytes&&this.fail(new A(`${n}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,`output_size`)),this.outputBytes+=o,a}accountResult(e,t=`execution`,n=1/0){let r=e.internalOutputAccounting,i=Math.min(r?.stdout??0,n),a=Math.min(r?.stderr??0,Math.max(0,n-i)),o=this.appendOutput(`stdout`,e.stdout,t,i,e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`),s=this.appendOutput(`stderr`,e.stderr,t,a);return Object.isExtensible(e)?(e.internalOutputAccounting={stdout:o,stderr:s},e):o===0&&s===0?e:{...e,internalOutputAccounting:{stdout:o,stderr:s}}}relinquishOutput(e,t,n){this.assertUsable(),n!==RE&&this.fail(new A(`${t}: unauthorized output accounting release`,`output_size`)),(!Number.isSafeInteger(e)||e<0||e>this.outputBytes)&&this.fail(new A(`${t}: invalid output accounting release`,`output_size`)),this.outputBytes-=e}enterDepth(e,t=this.limits.maxCallDepth,n){this.assertUsable();let r=typeof t==`number`?t:this.limits.maxCallDepth,i=typeof t==`string`?t:n??e,a=this.depthByKind.get(e)??0;a>=r&&this.fail(new A(`${i}: maximum depth (${r}) exceeded`,`recursion`)),this.depthByKind.set(e,a+1);let o=!1;return{release:()=>{if(o)return;o=!0;let t=(this.depthByKind.get(e)??1)-1;t<=0?this.depthByKind.delete(e):this.depthByKind.set(e,t)}}}throwIfAborted(e=`execution`){this.signal?.aborted&&this.fail(new kr(``,`bash: ${e} aborted
823
823
  `)),Date.now()-this.startedAt>this.limits.maxExecutionTimeMs&&this.fail(new kr(``,`bash: ${e} exceeded execution deadline (${this.limits.maxExecutionTimeMs}ms)
824
- `))}remainingTimeMs(){return Math.max(0,this.limits.maxExecutionTimeMs-(Date.now()-this.startedAt))}registerCleanup(e){this.assertUsable(),this.cleanupCallbacks.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.cleanupCallbacks.indexOf(e);n>=0&&this.cleanupCallbacks.splice(n,1)}}async close(){if(this.closed)return;this.closed=!0;let e=[],t=Date.now()+this.limits.maxExtensionCleanupTimeMs;for(let n=this.cleanupCallbacks.length-1;n>=0;n--)try{let r=t-Date.now();if(r<=0){e.push(Error(`execution cleanup grace period exceeded`));break}let i,a=await Promise.race([Promise.resolve().then(this.cleanupCallbacks[n]).then(()=>({ok:!0}),e=>({ok:!1,error:e})),new Promise(e=>{i=Yn(()=>e({ok:!1,error:Error(`execution cleanup grace period exceeded`)}),r)})]);if(Xn(i),!a.ok&&(e.push(a.error),Date.now()>=t))break}catch(t){e.push(t)}if(this.cleanupCallbacks.length=0,this.depthByKind.clear(),this.bytesByKind.clear(),this.liveBytes=0,e.length>0)throw AggregateError(e,`execution cleanup failed`)}assertExecDepth(e){this.assertUsable(),e>this.limits.maxExecDepth&&this.fail(new A(`maximum nested execution depth (${this.limits.maxExecDepth}) exceeded`,`recursion`))}};function BE(e){let t=Object.create(null);return Object.defineProperties(t,{remainingLiveBytes:{enumerable:!0,get:()=>e.remainingLiveBytes},consumeWork:{enumerable:!0,value:e.consumeWork.bind(e)},consumeLimited:{enumerable:!0,value:e.consumeLimited.bind(e)},consumeInput:{enumerable:!0,value:e.consumeInput.bind(e)},reserveBytes:{enumerable:!0,value:e.reserveBytes.bind(e)},enterDepth:{enumerable:!0,value:e.enterDepth.bind(e)},throwIfAborted:{enumerable:!0,value:e.throwIfAborted.bind(e)},remainingTimeMs:{enumerable:!0,value:e.remainingTimeMs.bind(e)},registerCleanup:{enumerable:!0,value:e.registerCleanup.bind(e)}}),Object.freeze(t)}function VE(e,t,n=`pipeline`){e.relinquishOutput(t,n,RE)}k(),UT(),Zi();var HE=new TextEncoder;function UE(e){return typeof e==`object`&&!!e&&!(e instanceof Uint8Array)&&`content`in e}var WE=class{data=new Map;entryIdentities=new WeakMap;nextEntryIdentity=1;maxTotalBytes;retainedBytes=0;contentReferences=new WeakMap;materializedContent(e){return e?.type===`file`&&`content`in e?e.content:null}storedByteLength(e){return e===null?0:e instanceof Uint8Array?e.byteLength:O(e)}wouldReleaseBytes(e){let t=this.materializedContent(e);return t===null?0:t instanceof Uint8Array?this.contentReferences.get(t)===1?t.byteLength:0:this.storedByteLength(t)}assertCanAllocate(e,t){let n=this.wouldReleaseBytes(this.data.get(e));if(!Number.isSafeInteger(t)||t<0||t>this.maxTotalBytes-this.retainedBytes+n)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`)}setEntry(e,t){let n=this.data.get(e),r=this.materializedContent(n),i=this.materializedContent(t);if(r===i){this.data.set(e,t);return}let a=this.wouldReleaseBytes(n),o=i instanceof Uint8Array?this.contentReferences.has(i)?0:i.byteLength:this.storedByteLength(i);if(o>this.maxTotalBytes-this.retainedBytes+a)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`);if(r instanceof Uint8Array){let e=this.contentReferences.get(r)??0;e<=1?this.contentReferences.delete(r):this.contentReferences.set(r,e-1)}i instanceof Uint8Array&&this.contentReferences.set(i,(this.contentReferences.get(i)??0)+1),this.retainedBytes+=o-a,this.data.set(e,t)}deleteEntry(e){let t=this.data.get(e);if(!t)return!1;let n=this.materializedContent(t),r=this.wouldReleaseBytes(t);if(n instanceof Uint8Array){let e=this.contentReferences.get(n)??0;e<=1?this.contentReferences.delete(n):this.contentReferences.set(n,e-1)}return this.retainedBytes-=r,this.data.delete(e)}contentByteLength(e,t){if(e instanceof Uint8Array)return e.byteLength;if(t===`hex`)return Math.floor(e.length/2);if(t===`base64`){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.max(0,Math.floor(e.length*3/4)-t)}return t===`binary`||t===`latin1`?e.length:O(e)}identityFor(e){let t=this.entryIdentities.get(e);return t||(t=`memfs:${this.nextEntryIdentity++}`,this.entryIdentities.set(e,t)),t}constructor(e,t={}){if(this.maxTotalBytes=t.maxTotalBytes??1073741824,!Number.isSafeInteger(this.maxTotalBytes)||this.maxTotalBytes<0)throw Error(`InMemoryFs: invalid maxTotalBytes`);if(this.data.set(`/`,{type:`directory`,mode:493,mtime:new Date}),e)for(let[t,n]of Object.entries(e))typeof n==`function`?this.writeFileLazy(t,n):UE(n)?this.writeFileSync(t,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(t,n)}ensureParentDirs(e){let t=qi(e);t!==`/`&&(this.data.has(t)||(this.ensureParentDirs(t),this.data.set(t,{type:`directory`,mode:493,mtime:new Date})))}writeFileSync(e,t,n,r){Ki(e,`write`);let i=I(e);this.ensureParentDirs(i);let a=BT(n);this.assertCanAllocate(i,this.contentByteLength(t,a));let o=RT(t,a);this.setEntry(i,{type:`file`,content:o,mode:r?.mode??420,mtime:r?.mtime??new Date})}writeFileLazy(e,t,n){Ki(e,`write`);let r=I(e);this.ensureParentDirs(r),this.setEntry(r,{type:`file`,lazy:t,mode:n?.mode??420,mtime:n?.mtime??new Date})}async materializeLazy(e,t){let n=await t.lazy(),r=typeof n==`string`?HE.encode(n):n,i={type:`file`,content:r,mode:t.mode,mtime:t.mtime};return this.assertCanAllocate(e,r.byteLength),this.setEntry(e,i),i}async readFile(e,t){return zT(await this.readFileBuffer(e),BT(t))}async readFileBytes(e){return zT(await this.readFileBuffer(e),`binary`)}async readFileBuffer(e){Ki(e,`open`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!==`file`)throw Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(`lazy`in n){let e=await this.materializeLazy(t,n);return e.content instanceof Uint8Array?e.content:HE.encode(e.content)}return n.content instanceof Uint8Array?n.content:HE.encode(n.content)}async writeFile(e,t,n){this.writeFileSync(e,t,n)}async appendFile(e,t,n){Ki(e,`append`);let r=I(e),i=this.data.get(r);if(i&&i.type===`directory`)throw Error(`EISDIR: illegal operation on a directory, write '${e}'`);let a=BT(n),o=this.contentByteLength(t,a);if(i?.type===`file`){let e=i;`lazy`in e&&(e=await this.materializeLazy(r,e));let n=`content`in e&&e.content instanceof Uint8Array?e.content:HE.encode(`content`in e?e.content:``);this.assertCanAllocate(r,n.byteLength+o);let s=RT(t,a),c=new Uint8Array(n.length+s.length);c.set(n),c.set(s,n.length),this.setEntry(r,{type:`file`,content:c,mode:e.mode,mtime:new Date})}else this.writeFileSync(e,t,n)}async exists(e){if(e.includes(`\0`))return!1;try{let t=this.resolvePathWithSymlinks(e);return this.data.has(t)}catch{return!1}}async stat(e){Ki(e,`stat`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, stat '${e}'`);n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:HE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}async lstat(e){Ki(e,`lstat`);let t=this.resolveIntermediateSymlinks(e),n=this.data.get(t);if(!n)throw 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(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:HE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}resolveIntermediateSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`);if(n.length<=1)return t;let r=``,i=new Set;for(let t=0;t<n.length-1;t++){let a=n[t];r=`${r}/${a}`;let o=this.data.get(r),s=0;for(;o&&o.type===`symlink`&&s<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(r),r=Xi(r,o.target),o=this.data.get(r),s++}if(s>=40)throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`),r=``,i=new Set;for(let t of n){r=`${r}/${t}`;let n=this.data.get(r),a=0;for(;n&&n.type===`symlink`&&a<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(r),r=Xi(r,n.target),n=this.data.get(r),a++}if(a>=40)throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return r}async mkdir(e,t){this.mkdirSync(e,t)}mkdirSync(e,t){Ki(e,`mkdir`);let n=I(e);if(this.data.has(n)){if(this.data.get(n)?.type===`file`)throw Error(`EEXIST: file already exists, mkdir '${e}'`);if(!t?.recursive)throw Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let r=qi(n);if(r!==`/`&&!this.data.has(r))if(t?.recursive)this.mkdirSync(r,{recursive:!0});else throw 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(e=>e.name)}async readdirWithFileTypes(e){Ki(e,`scandir`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Set;for(;n&&n.type===`symlink`;){if(r.has(t))throw Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);r.add(t),t=Xi(t,n.target),n=this.data.get(t)}if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!==`directory`)throw Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=t===`/`?`/`:`${t}/`,a=new Map;for(let[e,n]of this.data.entries())if(e!==t&&e.startsWith(i)){let t=e.slice(i.length),r=t.split(`/`)[0];r&&!t.includes(`/`,r.length)&&!a.has(r)&&a.set(r,{name:r,isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:n.type===`symlink`})}return Array.from(a.values()).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}async rm(e,t){Ki(e,`rm`);let n=I(e),r=this.data.get(n);if(!r){if(t?.force)return;throw Error(`ENOENT: no such file or directory, rm '${e}'`)}if(r.type===`directory`){let r=await this.readdir(n);if(r.length>0){if(!t?.recursive)throw Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let e of r){let r=Yi(n,e);await this.rm(r,t)}}}this.deleteEntry(n)}async cp(e,t,n){Ki(e,`cp`),Ki(t,`cp`);let r=I(e),i=I(t),a=this.data.get(r);if(!a)throw Error(`ENOENT: no such file or directory, cp '${e}'`);if(a.type===`file`)if(this.ensureParentDirs(i),`content`in a){let e=a.content instanceof Uint8Array?a.content.byteLength:HE.encode(a.content).byteLength;this.assertCanAllocate(i,e);let t=a.content instanceof Uint8Array?new Uint8Array(a.content):a.content;this.setEntry(i,{...a,content:t})}else this.setEntry(i,{...a});else if(a.type===`symlink`)this.ensureParentDirs(i),this.data.set(i,{...a});else if(a.type===`directory`){if(!n?.recursive)throw Error(`EISDIR: is a directory, cp '${e}'`);if(Gi(r,i))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let e of a){let t=Yi(r,e),a=Yi(i,e);await this.cp(t,a,n)}}}async mv(e,t){Ki(e,`mv`),Ki(t,`mv`);let n=I(e),r=I(t);if(n===r)return;let i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, mv '${e}'`);if(i.type===`directory`&&Gi(n,r))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(i.type===`directory`){await this.mkdir(r,{recursive:!0});let e=await this.readdir(n);for(let t of e)await this.mv(Yi(n,t),Yi(r,t));this.deleteEntry(n);return}this.ensureParentDirs(r),this.setEntry(r,i),this.deleteEntry(n)}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,t){return Ji(e,t)}async chmod(e,t){Ki(e,`chmod`);let n=I(e),r=this.data.get(n);if(!r)throw Error(`ENOENT: no such file or directory, chmod '${e}'`);r.mode=t}async symlink(e,t){Ki(t,`symlink`);let n=I(t);if(this.data.has(n))throw Error(`EEXIST: file already exists, symlink '${t}'`);this.ensureParentDirs(n),this.data.set(n,{type:`symlink`,target:e,mode:511,mtime:new Date})}async link(e,t){Ki(e,`link`),Ki(t,`link`);let n=I(e),r=I(t),i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!==`file`)throw Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(r))throw Error(`EEXIST: file already exists, link '${t}'`);let a=i;`lazy`in a&&(a=await this.materializeLazy(n,a)),this.ensureParentDirs(r);let o={type:`file`,content:a.content,mode:a.mode,mtime:a.mtime};this.entryIdentities.set(o,this.identityFor(a)),this.setEntry(r,o)}async readlink(e){Ki(e,`readlink`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!==`symlink`)throw Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}async realpath(e){Ki(e,`realpath`);let t=this.resolvePathWithSymlinks(e);if(!this.data.has(t))throw Error(`ENOENT: no such file or directory, realpath '${e}'`);return t}async utimes(e,t,n){Ki(e,`utimes`);let r=I(e),i=this.resolvePathWithSymlinks(r),a=this.data.get(i);if(!a)throw Error(`ENOENT: no such file or directory, utimes '${e}'`);a.mtime=n}},GE=`5.1.0(1)-release`,KE=`Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT`;function qE(e){let{pid:t,ppid:n,uid:r,gid:i}=e;return`Name: bash
824
+ `))}remainingTimeMs(){return Math.max(0,this.limits.maxExecutionTimeMs-(Date.now()-this.startedAt))}registerCleanup(e){this.assertUsable(),this.cleanupCallbacks.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.cleanupCallbacks.indexOf(e);n>=0&&this.cleanupCallbacks.splice(n,1)}}async close(){if(this.closed)return;this.closed=!0;let e=[],t=Date.now()+this.limits.maxExtensionCleanupTimeMs;for(let n=this.cleanupCallbacks.length-1;n>=0;n--)try{let r=t-Date.now();if(r<=0){e.push(Error(`execution cleanup grace period exceeded`));break}let i,a=await Promise.race([Promise.resolve().then(this.cleanupCallbacks[n]).then(()=>({ok:!0}),e=>({ok:!1,error:e})),new Promise(e=>{i=Yn(()=>e({ok:!1,error:Error(`execution cleanup grace period exceeded`)}),r)})]);if(Xn(i),!a.ok&&(e.push(a.error),Date.now()>=t))break}catch(t){e.push(t)}if(this.cleanupCallbacks.length=0,this.depthByKind.clear(),this.bytesByKind.clear(),this.liveBytes=0,e.length>0)throw AggregateError(e,`execution cleanup failed`)}assertExecDepth(e){this.assertUsable(),e>this.limits.maxExecDepth&&this.fail(new A(`maximum nested execution depth (${this.limits.maxExecDepth}) exceeded`,`recursion`))}};function BE(e){let t=Object.create(null);return Object.defineProperties(t,{remainingLiveBytes:{enumerable:!0,get:()=>e.remainingLiveBytes},consumeWork:{enumerable:!0,value:e.consumeWork.bind(e)},consumeLimited:{enumerable:!0,value:e.consumeLimited.bind(e)},consumeInput:{enumerable:!0,value:e.consumeInput.bind(e)},reserveBytes:{enumerable:!0,value:e.reserveBytes.bind(e)},enterDepth:{enumerable:!0,value:e.enterDepth.bind(e)},throwIfAborted:{enumerable:!0,value:e.throwIfAborted.bind(e)},remainingTimeMs:{enumerable:!0,value:e.remainingTimeMs.bind(e)},registerCleanup:{enumerable:!0,value:e.registerCleanup.bind(e)}}),Object.freeze(t)}function VE(e,t,n=`pipeline`){e.relinquishOutput(t,n,RE)}k(),UT(),Zi();var HE=new TextEncoder;function UE(e){return typeof e==`object`&&!!e&&!(e instanceof Uint8Array)&&`content`in e}var WE=class{data=new Map;entryIdentities=new WeakMap;nextEntryIdentity=1;maxTotalBytes;retainedBytes=0;contentReferences=new WeakMap;materializedContent(e){return e?.type===`file`&&`content`in e?e.content:null}storedByteLength(e){return e===null?0:e instanceof Uint8Array?e.byteLength:O(e)}wouldReleaseBytes(e){let t=this.materializedContent(e);return t===null?0:t instanceof Uint8Array?this.contentReferences.get(t)===1?t.byteLength:0:this.storedByteLength(t)}assertCanAllocate(e,t){let n=this.wouldReleaseBytes(this.data.get(e));if(!Number.isSafeInteger(t)||t<0||t>this.maxTotalBytes-this.retainedBytes+n)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`)}setEntry(e,t){let n=this.data.get(e),r=this.materializedContent(n),i=this.materializedContent(t);if(r===i){this.data.set(e,t);return}let a=this.wouldReleaseBytes(n),o=i instanceof Uint8Array?this.contentReferences.has(i)?0:i.byteLength:this.storedByteLength(i);if(o>this.maxTotalBytes-this.retainedBytes+a)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`);if(r instanceof Uint8Array){let e=this.contentReferences.get(r)??0;e<=1?this.contentReferences.delete(r):this.contentReferences.set(r,e-1)}i instanceof Uint8Array&&this.contentReferences.set(i,(this.contentReferences.get(i)??0)+1),this.retainedBytes+=o-a,this.data.set(e,t)}deleteEntry(e){let t=this.data.get(e);if(!t)return!1;let n=this.materializedContent(t),r=this.wouldReleaseBytes(t);if(n instanceof Uint8Array){let e=this.contentReferences.get(n)??0;e<=1?this.contentReferences.delete(n):this.contentReferences.set(n,e-1)}return this.retainedBytes-=r,this.data.delete(e)}contentByteLength(e,t){if(e instanceof Uint8Array)return e.byteLength;if(t===`hex`)return Math.floor(e.length/2);if(t===`base64`){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.max(0,Math.floor(e.length*3/4)-t)}return t===`binary`||t===`latin1`?e.length:O(e)}identityFor(e){let t=this.entryIdentities.get(e);return t||(t=`memfs:${this.nextEntryIdentity++}`,this.entryIdentities.set(e,t)),t}constructor(e,t={}){if(this.maxTotalBytes=t.maxTotalBytes??1073741824,!Number.isSafeInteger(this.maxTotalBytes)||this.maxTotalBytes<0)throw Error(`InMemoryFs: invalid maxTotalBytes`);if(this.data.set(`/`,{type:`directory`,mode:493,mtime:new Date}),e)for(let[t,n]of Object.entries(e))typeof n==`function`?this.writeFileLazy(t,n):UE(n)?this.writeFileSync(t,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(t,n)}ensureParentDirs(e){let t=qi(e);t!==`/`&&(this.data.has(t)||(this.ensureParentDirs(t),this.data.set(t,{type:`directory`,mode:493,mtime:new Date})))}writeFileSync(e,t,n,r){Ki(e,`write`);let i=I(e);this.ensureParentDirs(i);let a=BT(n);this.assertCanAllocate(i,this.contentByteLength(t,a));let o=RT(t,a);this.setEntry(i,{type:`file`,content:o,mode:r?.mode??420,mtime:r?.mtime??new Date})}writeFileLazy(e,t,n){Ki(e,`write`);let r=I(e);this.ensureParentDirs(r),this.setEntry(r,{type:`file`,lazy:t,mode:n?.mode??420,mtime:n?.mtime??new Date})}async materializeLazy(e,t){let n=await t.lazy(),r=typeof n==`string`?HE.encode(n):n,i={type:`file`,content:r,mode:t.mode,mtime:t.mtime};return this.assertCanAllocate(e,r.byteLength),this.setEntry(e,i),i}async readFile(e,t){return zT(await this.readFileBuffer(e),BT(t))}async readFileBytes(e){return zT(await this.readFileBuffer(e),`binary`)}async readFileBuffer(e){Ki(e,`open`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!==`file`)throw Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(`lazy`in n){let e=await this.materializeLazy(t,n);return e.content instanceof Uint8Array?e.content:HE.encode(e.content)}return n.content instanceof Uint8Array?n.content:HE.encode(n.content)}async writeFile(e,t,n){this.writeFileSync(e,t,n)}async appendFile(e,t,n){Ki(e,`append`);let r=I(e),i=this.data.get(r);if(i&&i.type===`directory`)throw Error(`EISDIR: illegal operation on a directory, write '${e}'`);let a=BT(n),o=this.contentByteLength(t,a);if(i?.type===`file`){let e=i;`lazy`in e&&(e=await this.materializeLazy(r,e));let n=`content`in e&&e.content instanceof Uint8Array?e.content:HE.encode(`content`in e?e.content:``);this.assertCanAllocate(r,n.byteLength+o);let s=RT(t,a),c=new Uint8Array(n.length+s.length);c.set(n),c.set(s,n.length),this.setEntry(r,{type:`file`,content:c,mode:e.mode,mtime:new Date})}else this.writeFileSync(e,t,n)}async exists(e){if(e.includes(`\0`))return!1;try{let t=this.resolvePathWithSymlinks(e);return this.data.has(t)}catch{return!1}}async stat(e){Ki(e,`stat`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, stat '${e}'`);n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:HE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}async lstat(e){Ki(e,`lstat`);let t=this.resolveIntermediateSymlinks(e),n=this.data.get(t);if(!n)throw 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(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:HE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}resolveIntermediateSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`);if(n.length<=1)return t;let r=``,i=new Set;for(let t=0;t<n.length-1;t++){let a=n[t];r=`${r}/${a}`;let o=this.data.get(r),s=0;for(;o&&o.type===`symlink`&&s<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(r),r=Xi(r,o.target),o=this.data.get(r),s++}if(s>=40)throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`),r=``,i=new Set;for(let t of n){r=`${r}/${t}`;let n=this.data.get(r),a=0;for(;n&&n.type===`symlink`&&a<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(r),r=Xi(r,n.target),n=this.data.get(r),a++}if(a>=40)throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return r}async mkdir(e,t){this.mkdirSync(e,t)}mkdirSync(e,t){Ki(e,`mkdir`);let n=I(e);if(this.data.has(n)){if(this.data.get(n)?.type===`file`)throw Error(`EEXIST: file already exists, mkdir '${e}'`);if(!t?.recursive)throw Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let r=qi(n);if(r!==`/`&&!this.data.has(r)){if(t?.recursive)this.mkdirSync(r,{recursive:!0});else throw 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(e=>e.name)}async readdirWithFileTypes(e){Ki(e,`scandir`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Set;for(;n&&n.type===`symlink`;){if(r.has(t))throw Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);r.add(t),t=Xi(t,n.target),n=this.data.get(t)}if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!==`directory`)throw Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=t===`/`?`/`:`${t}/`,a=new Map;for(let[e,n]of this.data.entries())if(e!==t&&e.startsWith(i)){let t=e.slice(i.length),r=t.split(`/`)[0];r&&!t.includes(`/`,r.length)&&!a.has(r)&&a.set(r,{name:r,isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:n.type===`symlink`})}return Array.from(a.values()).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}async rm(e,t){Ki(e,`rm`);let n=I(e),r=this.data.get(n);if(!r){if(t?.force)return;throw Error(`ENOENT: no such file or directory, rm '${e}'`)}if(r.type===`directory`){let r=await this.readdir(n);if(r.length>0){if(!t?.recursive)throw Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let e of r){let r=Yi(n,e);await this.rm(r,t)}}}this.deleteEntry(n)}async cp(e,t,n){Ki(e,`cp`),Ki(t,`cp`);let r=I(e),i=I(t),a=this.data.get(r);if(!a)throw Error(`ENOENT: no such file or directory, cp '${e}'`);if(a.type===`file`){if(this.ensureParentDirs(i),`content`in a){let e=a.content instanceof Uint8Array?a.content.byteLength:HE.encode(a.content).byteLength;this.assertCanAllocate(i,e);let t=a.content instanceof Uint8Array?new Uint8Array(a.content):a.content;this.setEntry(i,{...a,content:t})}else this.setEntry(i,{...a})}else if(a.type===`symlink`)this.ensureParentDirs(i),this.data.set(i,{...a});else if(a.type===`directory`){if(!n?.recursive)throw Error(`EISDIR: is a directory, cp '${e}'`);if(Gi(r,i))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let e of a){let t=Yi(r,e),a=Yi(i,e);await this.cp(t,a,n)}}}async mv(e,t){Ki(e,`mv`),Ki(t,`mv`);let n=I(e),r=I(t);if(n===r)return;let i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, mv '${e}'`);if(i.type===`directory`&&Gi(n,r))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(i.type===`directory`){await this.mkdir(r,{recursive:!0});let e=await this.readdir(n);for(let t of e)await this.mv(Yi(n,t),Yi(r,t));this.deleteEntry(n);return}this.ensureParentDirs(r),this.setEntry(r,i),this.deleteEntry(n)}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,t){return Ji(e,t)}async chmod(e,t){Ki(e,`chmod`);let n=I(e),r=this.data.get(n);if(!r)throw Error(`ENOENT: no such file or directory, chmod '${e}'`);r.mode=t}async symlink(e,t){Ki(t,`symlink`);let n=I(t);if(this.data.has(n))throw Error(`EEXIST: file already exists, symlink '${t}'`);this.ensureParentDirs(n),this.data.set(n,{type:`symlink`,target:e,mode:511,mtime:new Date})}async link(e,t){Ki(e,`link`),Ki(t,`link`);let n=I(e),r=I(t),i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!==`file`)throw Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(r))throw Error(`EEXIST: file already exists, link '${t}'`);let a=i;`lazy`in a&&(a=await this.materializeLazy(n,a)),this.ensureParentDirs(r);let o={type:`file`,content:a.content,mode:a.mode,mtime:a.mtime};this.entryIdentities.set(o,this.identityFor(a)),this.setEntry(r,o)}async readlink(e){Ki(e,`readlink`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!==`symlink`)throw Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}async realpath(e){Ki(e,`realpath`);let t=this.resolvePathWithSymlinks(e);if(!this.data.has(t))throw Error(`ENOENT: no such file or directory, realpath '${e}'`);return t}async utimes(e,t,n){Ki(e,`utimes`);let r=I(e),i=this.resolvePathWithSymlinks(r),a=this.data.get(i);if(!a)throw Error(`ENOENT: no such file or directory, utimes '${e}'`);a.mtime=n}},GE=`5.1.0(1)-release`,KE=`Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT`;function qE(e){let{pid:t,ppid:n,uid:r,gid:i}=e;return`Name: bash
825
825
  State: R (running)
826
826
  Pid: ${t}
827
827
  PPid: ${n}
@@ -851,7 +851,7 @@ Gid: ${i} ${i} ${i} ${i}
851
851
  `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`||e===`'`||e===`"`||e===`\\`||e===`$`||e==="`"||e===`{`||e===`}`||e===`~`||e===`*`||e===`?`||e===`[`)break;a++}if(a>o){let s=r[a];if(!(s===`(`&&a>o&&`@*+?!`.includes(r[a-1]))&&(a>=i||s===` `||s===` `||s===`
852
852
  `||s===`;`||s===`&`||s===`|`||s===`(`||s===`)`||s===`<`||s===`>`)){let i=r.slice(o,a);this.pos=a,this.column=n+(a-o);let s=ND.get(i);if(s!==void 0)return{type:s,value:i,start:e,end:a,line:t,column:n};let c=LD(i);return c>0&&ID(i.slice(0,c))?{type:Z.ASSIGNMENT_WORD,value:i,start:e,end:a,line:t,column:n}:/^[0-9]+$/.test(i)?{type:Z.NUMBER,value:i,start:e,end:a,line:t,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?{type:Z.NAME,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}:{type:Z.WORD,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}}a=this.pos;let s=this.column,c=this.line,l=``,u=!1,d=!1,f=!1,p=!1,m=r[a]===`"`||r[a]===`'`,h=!1,g=0;for(;a<i;){let e=r[a];if(!f&&!p){if(e===`(`&&l.length>0&&`@*+?!`.includes(l[l.length-1])){let e=this.scanExtglobPattern(a);if(e!==null){l+=e.content,a=e.end,s+=e.content.length;continue}}if(e===`[`&&g===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){let t=a+1<i?r[a+1]:``;if(t===`^`||t===`!`){l+=e,a++,s++;continue}g=1,l+=e,a++,s++;continue}}else if(e===`[`&&g>0){l.length>0&&l[l.length-1]!==`\\`&&g++,l+=e,a++,s++;continue}else if(e===`]`&&g>0){l.length>0&&l[l.length-1]!==`\\`&&g--,l+=e,a++,s++;continue}if(g>0){if(e===`
853
853
  `)break;l+=e,a++,s++;continue}if(e===` `||e===` `||e===`
854
- `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+1<i&&r[a+1]===`'`&&!f&&!p){for(l+=`$'`,a+=2,s+=2;a<i&&r[a]!==`'`;)r[a]===`\\`&&a+1<i?(l+=r[a]+r[a+1],a+=2,s+=2):(l+=r[a],a++,s++);a<i&&(l+=`'`,a++,s++);continue}if(e===`$`&&a+1<i&&r[a+1]===`"`&&!f&&!p){a++,s++,p=!0,u=!0,l===``&&(m=!0),a++,s++;continue}if(e===`'`&&!p){if(f)if(f=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!HD(t)&&t!==`'`&&(t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else f=!0,m&&!h?(d=!0,u=!0):l+=e;a++,s++;continue}if(e===`"`&&!f){if(p)if(p=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!HD(t)&&t!==`"`&&(t===`'`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else p=!0,m&&!h?u=!0:l+=e;a++,s++;continue}if(e===`\\`&&!f&&a+1<i){let t=r[a+1];if(t===`
854
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+1<i&&r[a+1]===`'`&&!f&&!p){for(l+=`$'`,a+=2,s+=2;a<i&&r[a]!==`'`;)r[a]===`\\`&&a+1<i?(l+=r[a]+r[a+1],a+=2,s+=2):(l+=r[a],a++,s++);a<i&&(l+=`'`,a++,s++);continue}if(e===`$`&&a+1<i&&r[a+1]===`"`&&!f&&!p){a++,s++,p=!0,u=!0,l===``&&(m=!0),a++,s++;continue}if(e===`'`&&!p){if(f){if(f=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!HD(t)&&t!==`'`&&(t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}}else f=!0,m&&!h?(d=!0,u=!0):l+=e;a++,s++;continue}if(e===`"`&&!f){if(p){if(p=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!HD(t)&&t!==`"`&&(t===`'`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}}else p=!0,m&&!h?u=!0:l+=e;a++,s++;continue}if(e===`\\`&&!f&&a+1<i){let t=r[a+1];if(t===`
855
855
  `){a+=2,c++,s=1;continue}if(p){if(t===`"`||t===`\\`||t===`$`||t==="`"||t===`
856
856
  `){if(t===`
857
857
  `){a+=2,s=1,c++;continue}l+=e+t,a+=2,s+=2;continue}}else{l+=e+t,a+=2,s+=2;continue}}if(e===`$`&&a+1<i&&r[a+1]===`(`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1,n=!1,o=!1,u=0,d=!1,f=``,p=[],m=r[a]===`(`&&!this.dollarDparenIsSubshell(a),h=+!!m;for(;t>0&&a<i;){let e=r[a];if(l+=e,n)e===`'`&&(n=!1);else if(o)e===`\\`&&a+1<i?(l+=r[a+1],a++,s++):e===`"`&&(o=!1);else{if(e===`(`&&r[a+1]===`(`?h++:e===`)`&&r[a+1]===`)`&&h>0&&h--,h===0&&e===`<`&&r[a+1]===`<`&&r[a+2]!==`<`){let e=a+2,t=!1;for(r[e]===`-`&&(t=!0,e++);r[e]===` `||r[e]===` `;)e++;let{delim:n,endPos:i,unclosedQuote:o,unclosedSubstitution:u}=TD(r,e);if(o)throw new MD(`unexpected EOF while looking for matching \`${o}'`,c,s);if(u)throw new MD("unexpected EOF while looking for matching `)'",c,s);if(n.length>0){l+=r.slice(a+1,i),s+=i-a,p.push({delim:n,stripTabs:t}),a=i;continue}}if(e===`
@@ -883,9 +883,9 @@ Gid: ${i} ${i} ${i} ${i}
883
883
  `);)a=!0,i++;if(a&&i<n&&t[i]===`)`||s)return!0}if(i===0)return!1;r++;continue}r++}return!1}dparenClosesWithSpacedParens(e){let t=this.input,n=t.length,r=e,i=2,a=!1,o=!1;for(;r<n&&i>0;){let e=t[r];if(a){e===`'`&&(a=!1),r++;continue}if(o){if(e===`\\`){r+=2;continue}e===`"`&&(o=!1),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e<n&&t[e]===`)`)return!1;let i=e,a=!1;for(;i<n&&(t[i]===` `||t[i]===` `||t[i]===`
884
884
  `);)a=!0,i++;if(a&&i<n&&t[i]===`)`)return!0}if(i===0)return!1;r++;continue}if(i===1&&(e===`|`&&r+1<n&&t[r+1]===`|`||e===`&`&&r+1<n&&t[r+1]===`&`||e===`|`&&r+1<n&&t[r+1]!==`|`))return!0;r++}return!1}},WD=1e6,GD=1e5,KD=1e6,qD=200,JD;(function(e){e[e.Default=0]=`Default`,e[e.Assignment=1]=`Assignment`,e[e.NoBraceExpansion=2]=`NoBraceExpansion`,e[e.Regex=4]=`Regex`})(JD||={});var YD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),XD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS]),ZD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),QD=class extends Error{line;column;token;constructor(e,t,n,r=void 0){super(`Parse error at ${t}:${n}: ${e}`),this.line=t,this.column=n,this.token=r,this.name=`ParseException`}},$D=class{iterations=0;tokens=0;depth=0;reset(){this.iterations=0,this.tokens=0,this.depth=0}chargeIteration(e,t){if(this.iterations++,this.iterations>KD)throw new QD(`Maximum parse iterations exceeded (possible infinite loop)`,e,t)}chargeTokens(e,t=1,n=1){if(this.tokens+=e,this.tokens>GD)throw new QD(`Too many tokens: cumulative count exceeds limit of ${GD}`,t,n)}enter(e,t){if(this.depth++,this.depth>qD)throw this.depth--,new QD(`Maximum parser nesting depth exceeded (${qD})`,e,t);let n=!0;return()=>{n&&(n=!1,this.depth--)}}};qn(),Lr(),j();function eO(e,t){for(;t<e.length;){if(e[t]===`\\`&&e[t+1]===`
885
885
  `){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}var tO=[`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`|=`,`^=`];function nO(e){if(e.includes(`#`)){let t=e.split(`#`);if(t.length!==2)return NaN;let[n,r]=t;if(!/^\d+$/.test(n)||r.length===0)return NaN;let i=Number.parseInt(n,10);if(i<2||i>64)return NaN;let a=0;for(let e of r){let t;if(/[0-9]/.test(e))t=e.charCodeAt(0)-48;else if(/[a-z]/.test(e))t=e.charCodeAt(0)-97+10;else if(/[A-Z]/.test(e))t=e.charCodeAt(0)-65+(i<=36?10:36);else if(e===`@`)t=62;else if(e===`_`)t=63;else return NaN;if(t>=i)return NaN;if(a=a*i+t,a>2**53-1)return 2**53-1}return a}if(e.startsWith(`0x`)||e.startsWith(`0X`)){let t=Number.parseInt(e.slice(2),16);return t>2**53-1?2**53-1:t}if(e.startsWith(`0`)&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return NaN;let t=Number.parseInt(e,8);return t>2**53-1?2**53-1:t}let t=Number.parseInt(e,10);return t>2**53-1?2**53-1:t}function rO(e,t,n,r){if(n.slice(r,r+3)!==`$((`)return null;let i=r+3,a=1,o=i;for(;i<n.length-1&&a>0;)n[i]===`(`&&n[i+1]===`(`?(a++,i+=2):n[i]===`)`&&n[i+1]===`)`?(a--,a>0&&(i+=2)):i++;let{expr:s}=e(t,n.slice(o,i),0);return i+=2,{expr:{type:`ArithNested`,expression:s},pos:i}}function iO(e,t){if(e.slice(t,t+2)!==`$'`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`'`;)if(e[n]===`\\`&&n+1<e.length){let t=e[n+1];switch(t){case`n`:r+=`
886
- `;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`\\`:r+=`\\`;break;case`'`:r+=`'`;break;default:r+=t}n+=2}else r+=e[n],n++;e[n]===`'`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function aO(e,t){if(e.slice(t,t+2)!==`$"`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]===`"`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function oO(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function sO(e,t){let n=oO(t),{expr:r,pos:i}=uO(e,n,0),a=eO(n,i);if(a<n.length){let e=t.slice(a).trim();if(e)return{type:`ArithmeticExpression`,originalText:t,expression:{type:`ArithSyntaxError`,errorToken:e,message:`${e}: syntax error: invalid arithmetic operator (error token is "${e}")`}}}return{type:`ArithmeticExpression`,expression:r,originalText:t}}function cO(e,t){return{expr:{type:`ArithSyntaxError`,errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function lO(e,t){return eO(e,t)>=e.length}function uO(e,t,n){return fO(e,t,n)}function dO(e,t,n){return e.withDepth(()=>uO(e,t,n))}function fO(e,t,n){let{expr:r,pos:i}=pO(e,t,n);for(i=eO(t,i);t[i]===`,`;){if(i++,lO(t,i))return cO(`,`,i);let{expr:n,pos:a}=pO(e,t,i);r={type:`ArithBinary`,operator:`,`,left:r,right:n},i=eO(t,a)}return{expr:r,pos:i}}function pO(e,t,n){let{expr:r,pos:i}=mO(e,t,n);if(i=eO(t,i),t[i]===`?`){i++;let{expr:n,pos:a}=dO(e,t,i);if(i=eO(t,a),t[i]===`:`){i++;let{expr:a,pos:o}=dO(e,t,i);return{expr:{type:`ArithTernary`,condition:r,consequent:n,alternate:a},pos:o}}}return{expr:r,pos:i}}function mO(e,t,n){let{expr:r,pos:i}=hO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`||`;){if(i+=2,lO(t,i))return cO(`||`,i);let{expr:n,pos:a}=hO(e,t,i);r={type:`ArithBinary`,operator:`||`,left:r,right:n},i=a}return{expr:r,pos:i}}function hO(e,t,n){let{expr:r,pos:i}=gO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`&&`;){if(i+=2,lO(t,i))return cO(`&&`,i);let{expr:n,pos:a}=gO(e,t,i);r={type:`ArithBinary`,operator:`&&`,left:r,right:n},i=a}return{expr:r,pos:i}}function gO(e,t,n){let{expr:r,pos:i}=_O(e,t,n);for(;i=eO(t,i),t[i]===`|`&&t[i+1]!==`|`;){if(i++,lO(t,i))return cO(`|`,i);let{expr:n,pos:a}=_O(e,t,i);r={type:`ArithBinary`,operator:`|`,left:r,right:n},i=a}return{expr:r,pos:i}}function _O(e,t,n){let{expr:r,pos:i}=vO(e,t,n);for(;i=eO(t,i),t[i]===`^`;){if(i++,lO(t,i))return cO(`^`,i);let{expr:n,pos:a}=vO(e,t,i);r={type:`ArithBinary`,operator:`^`,left:r,right:n},i=a}return{expr:r,pos:i}}function vO(e,t,n){let{expr:r,pos:i}=yO(e,t,n);for(;i=eO(t,i),t[i]===`&`&&t[i+1]!==`&`;){if(i++,lO(t,i))return cO(`&`,i);let{expr:n,pos:a}=yO(e,t,i);r={type:`ArithBinary`,operator:`&`,left:r,right:n},i=a}return{expr:r,pos:i}}function yO(e,t,n){let{expr:r,pos:i}=bO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`==`||t.slice(i,i+2)===`!=`;){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=bO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function bO(e,t,n){let{expr:r,pos:i}=xO(e,t,n);for(;;)if(i=eO(t,i),t.slice(i,i+2)===`<=`||t.slice(i,i+2)===`>=`){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=xO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else if(t[i]===`<`||t[i]===`>`){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=xO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function xO(e,t,n){let{expr:r,pos:i}=SO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`<<`||t.slice(i,i+2)===`>>`;){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=SO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function SO(e,t,n){let{expr:r,pos:i}=CO(e,t,n);for(;i=eO(t,i),(t[i]===`+`||t[i]===`-`)&&t[i+1]!==t[i];){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=CO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function CO(e,t,n){let{expr:r,pos:i}=wO(e,t,n);for(;;)if(i=eO(t,i),t[i]===`*`&&t[i+1]!==`*`){if(i++,lO(t,i))return cO(`*`,i);let{expr:n,pos:a}=wO(e,t,i);r={type:`ArithBinary`,operator:`*`,left:r,right:n},i=a}else if(t[i]===`/`||t[i]===`%`){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=wO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function wO(e,t,n){let{expr:r,pos:i}=TO(e,t,n),a=eO(t,i);if(t.slice(a,a+2)===`**`){if(a+=2,lO(t,a))return cO(`**`,a);let{expr:n,pos:i}=e.withDepth(()=>wO(e,t,a));return{expr:{type:`ArithBinary`,operator:`**`,left:r,right:n},pos:i}}return{expr:r,pos:i}}function TO(e,t,n){let r=eO(t,n);if(t.slice(r,r+2)===`++`||t.slice(r,r+2)===`--`){let n=t.slice(r,r+2);r+=2;let{expr:i,pos:a}=e.withDepth(()=>TO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}if(t[r]===`+`||t[r]===`-`||t[r]===`!`||t[r]===`~`){let n=t[r];r++;let{expr:i,pos:a}=e.withDepth(()=>TO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}return DO(e,t,r)}function EO(e,t){let n=e[t];return n===`$`||n==="`"}function DO(e,t,n){let{expr:r,pos:i}=OO(e,t,n,!1),a=[r];for(;EO(t,i);){let{expr:n,pos:r}=OO(e,t,i,!0);a.push(n),i=r}a.length>1&&(r={type:`ArithConcat`,parts:a});let o;if(t[i]===`[`&&r.type===`ArithConcat`){i++;let{expr:n,pos:r}=dO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(o&&r.type===`ArithConcat`&&(r={type:`ArithDynamicElement`,nameExpr:r,subscript:o},o=void 0),i=eO(t,i),r.type===`ArithConcat`||r.type===`ArithVariable`||r.type===`ArithDynamicElement`){for(let n of tO)if(t.slice(i,i+n.length)===n&&t.slice(i,i+n.length+1)!==`==`){i+=n.length;let{expr:a,pos:o}=e.withDepth(()=>pO(e,t,i));return r.type===`ArithDynamicElement`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r.nameExpr,subscript:r.subscript,value:a},pos:o}:r.type===`ArithConcat`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r,value:a},pos:o}:{expr:{type:`ArithAssignment`,operator:n,variable:r.name,value:a},pos:o}}}if(t.slice(i,i+2)===`++`||t.slice(i,i+2)===`--`){let e=t.slice(i,i+2);return i+=2,{expr:{type:`ArithUnary`,operator:e,operand:r,prefix:!1},pos:i}}return{expr:r,pos:i}}function OO(e,t,n,r=!1){let i=eO(t,n),a=rO(dO,e,t,i);if(a)return a;let o=iO(t,i);if(o)return o;let s=aO(t,i);if(s)return s;if(t.slice(i,i+2)===`$(`&&t[i+2]!==`(`){i+=2;let e=1,n=i;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,e>0&&i++;let r=t.slice(n,i);return i++,{expr:{type:`ArithCommandSubst`,command:r},pos:i}}if(t[i]==="`"){i++;let e=i;for(;i<t.length&&t[i]!=="`";)i++;let n=t.slice(e,i);return t[i]==="`"&&i++,{expr:{type:`ArithCommandSubst`,command:n},pos:i}}if(t[i]===`(`){i++;let{expr:n,pos:r}=dO(e,t,i);return i=eO(t,r),t[i]===`)`&&i++,{expr:{type:`ArithGroup`,expression:n},pos:i}}if(t[i]===`'`){i++;let e=``;for(;i<t.length&&t[i]!==`'`;)e+=t[i],i++;t[i]===`'`&&i++;let n=Number.parseInt(e,10);return{expr:{type:`ArithSingleQuote`,content:e,value:Number.isNaN(n)?0:n},pos:i}}if(t[i]===`"`){i++;let n=``;for(;i<t.length&&t[i]!==`"`;)t[i]===`\\`&&i+1<t.length?(n+=t[i+1],i+=2):(n+=t[i],i++);t[i]===`"`&&i++;let r=n.trim();if(!r)return{expr:{type:`ArithNumber`,value:0},pos:i};let{expr:a}=dO(e,r,0);return{expr:a,pos:i}}if(/[0-9]/.test(t[i])){let e=``,n=!1,r=!1;for(;i<t.length;){let a=t[i];if(n)if(/[0-9a-zA-Z@_]/.test(a))e+=a,i++;else break;else if(a===`#`)n=!0,e+=a,i++;else if(e===`0`&&(a===`x`||a===`X`)&&i+1<t.length&&/[0-9a-fA-F]/.test(t[i+1]))r=!0,e+=a,i++;else if(r&&/[0-9a-fA-F]/.test(a))e+=a,i++;else if(!r&&/[0-9]/.test(a))e+=a,i++;else break}if(i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=e;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: value too great for base (error token is "${n}")`},pos:i}}if(t[i]===`.`&&/[0-9]/.test(t[i+1]))throw new Tr(`${e}.${t[i+1]}...: syntax error: invalid arithmetic operator`);if(t[i]===`[`){let n=t.slice(i).trim();return{expr:{type:`ArithNumberSubscript`,number:e,errorToken:n},pos:t.length}}return{expr:{type:`ArithNumber`,value:nO(e)},pos:i}}if(t[i]===`$`&&t[i+1]===`{`){let e=i+2,n=1,r=e;for(;r<t.length&&n>0;)t[r]===`{`?n++:t[r]===`}`&&n--,n>0&&r++;let a=t.slice(e,r),o=r+1;if(t[o]===`#`){let e=o+1;for(;e<t.length&&/[0-9a-zA-Z@_]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicBase`,baseExpr:a,value:t.slice(o+1,e)},pos:e}}if(/[0-9]/.test(t[o])||t[o]===`x`||t[o]===`X`){let e=o;if(t[o]===`x`||t[o]===`X`)for(e++;e<t.length&&/[0-9a-fA-F]/.test(t[e]);)e++;else for(;e<t.length&&/[0-9]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicNumber`,prefix:a,suffix:t.slice(o,e)},pos:e}}return i=o,{expr:{type:`ArithBracedExpansion`,content:a},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[0-9]/.test(t[i+1])){i++;let e=``;for(;i<t.length&&/[0-9]/.test(t[i]);)e+=t[i],i++;return{expr:{type:`ArithVariable`,name:e,hasDollarPrefix:!0},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[*@#?\-!$]/.test(t[i+1])){let e=t[i+1];return i+=2,{expr:{type:`ArithSpecialVar`,name:e},pos:i}}let c=!1;if(t[i]===`$`&&i+1<t.length&&/[a-zA-Z_]/.test(t[i+1])&&(c=!0,i++),i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=``;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;if(t[i]===`[`&&!r){i++;let a;if(t[i]===`'`||t[i]===`"`){let e=t[i];for(i++,a=``;i<t.length&&t[i]!==e;)a+=t[i],i++;t[i]===e&&i++,i=eO(t,i),t[i]===`]`&&i++}let o;if(a===void 0){let{expr:n,pos:r}=dO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(i=eO(t,i),t[i]===`[`&&o)return{expr:{type:`ArithDoubleSubscript`,array:n,index:o},pos:i};if(!r){for(let r of tO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:s,pos:c}=e.withDepth(()=>pO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,subscript:o,stringKey:a,value:s},pos:c}}}return{expr:{type:`ArithArrayElement`,array:n,index:o,stringKey:a},pos:i}}if(i=eO(t,i),!r){for(let r of tO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:a,pos:o}=e.withDepth(()=>pO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,value:a},pos:o}}}return{expr:{type:`ArithVariable`,name:n,hasDollarPrefix:c},pos:i}}if(t[i]===`#`){let e=i+1;for(;e<t.length&&t[e]!==`
886
+ `;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`\\`:r+=`\\`;break;case`'`:r+=`'`;break;default:r+=t}n+=2}else r+=e[n],n++;e[n]===`'`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function aO(e,t){if(e.slice(t,t+2)!==`$"`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]===`"`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function oO(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function sO(e,t){let n=oO(t),{expr:r,pos:i}=uO(e,n,0),a=eO(n,i);if(a<n.length){let e=t.slice(a).trim();if(e)return{type:`ArithmeticExpression`,originalText:t,expression:{type:`ArithSyntaxError`,errorToken:e,message:`${e}: syntax error: invalid arithmetic operator (error token is "${e}")`}}}return{type:`ArithmeticExpression`,expression:r,originalText:t}}function cO(e,t){return{expr:{type:`ArithSyntaxError`,errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function lO(e,t){return eO(e,t)>=e.length}function uO(e,t,n){return fO(e,t,n)}function dO(e,t,n){return e.withDepth(()=>uO(e,t,n))}function fO(e,t,n){let{expr:r,pos:i}=pO(e,t,n);for(i=eO(t,i);t[i]===`,`;){if(i++,lO(t,i))return cO(`,`,i);let{expr:n,pos:a}=pO(e,t,i);r={type:`ArithBinary`,operator:`,`,left:r,right:n},i=eO(t,a)}return{expr:r,pos:i}}function pO(e,t,n){let{expr:r,pos:i}=mO(e,t,n);if(i=eO(t,i),t[i]===`?`){i++;let{expr:n,pos:a}=dO(e,t,i);if(i=eO(t,a),t[i]===`:`){i++;let{expr:a,pos:o}=dO(e,t,i);return{expr:{type:`ArithTernary`,condition:r,consequent:n,alternate:a},pos:o}}}return{expr:r,pos:i}}function mO(e,t,n){let{expr:r,pos:i}=hO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`||`;){if(i+=2,lO(t,i))return cO(`||`,i);let{expr:n,pos:a}=hO(e,t,i);r={type:`ArithBinary`,operator:`||`,left:r,right:n},i=a}return{expr:r,pos:i}}function hO(e,t,n){let{expr:r,pos:i}=gO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`&&`;){if(i+=2,lO(t,i))return cO(`&&`,i);let{expr:n,pos:a}=gO(e,t,i);r={type:`ArithBinary`,operator:`&&`,left:r,right:n},i=a}return{expr:r,pos:i}}function gO(e,t,n){let{expr:r,pos:i}=_O(e,t,n);for(;i=eO(t,i),t[i]===`|`&&t[i+1]!==`|`;){if(i++,lO(t,i))return cO(`|`,i);let{expr:n,pos:a}=_O(e,t,i);r={type:`ArithBinary`,operator:`|`,left:r,right:n},i=a}return{expr:r,pos:i}}function _O(e,t,n){let{expr:r,pos:i}=vO(e,t,n);for(;i=eO(t,i),t[i]===`^`;){if(i++,lO(t,i))return cO(`^`,i);let{expr:n,pos:a}=vO(e,t,i);r={type:`ArithBinary`,operator:`^`,left:r,right:n},i=a}return{expr:r,pos:i}}function vO(e,t,n){let{expr:r,pos:i}=yO(e,t,n);for(;i=eO(t,i),t[i]===`&`&&t[i+1]!==`&`;){if(i++,lO(t,i))return cO(`&`,i);let{expr:n,pos:a}=yO(e,t,i);r={type:`ArithBinary`,operator:`&`,left:r,right:n},i=a}return{expr:r,pos:i}}function yO(e,t,n){let{expr:r,pos:i}=bO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`==`||t.slice(i,i+2)===`!=`;){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=bO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function bO(e,t,n){let{expr:r,pos:i}=xO(e,t,n);for(;;)if(i=eO(t,i),t.slice(i,i+2)===`<=`||t.slice(i,i+2)===`>=`){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=xO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else if(t[i]===`<`||t[i]===`>`){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=xO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function xO(e,t,n){let{expr:r,pos:i}=SO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`<<`||t.slice(i,i+2)===`>>`;){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=SO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function SO(e,t,n){let{expr:r,pos:i}=CO(e,t,n);for(;i=eO(t,i),(t[i]===`+`||t[i]===`-`)&&t[i+1]!==t[i];){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=CO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function CO(e,t,n){let{expr:r,pos:i}=wO(e,t,n);for(;;)if(i=eO(t,i),t[i]===`*`&&t[i+1]!==`*`){if(i++,lO(t,i))return cO(`*`,i);let{expr:n,pos:a}=wO(e,t,i);r={type:`ArithBinary`,operator:`*`,left:r,right:n},i=a}else if(t[i]===`/`||t[i]===`%`){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=wO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function wO(e,t,n){let{expr:r,pos:i}=TO(e,t,n),a=eO(t,i);if(t.slice(a,a+2)===`**`){if(a+=2,lO(t,a))return cO(`**`,a);let{expr:n,pos:i}=e.withDepth(()=>wO(e,t,a));return{expr:{type:`ArithBinary`,operator:`**`,left:r,right:n},pos:i}}return{expr:r,pos:i}}function TO(e,t,n){let r=eO(t,n);if(t.slice(r,r+2)===`++`||t.slice(r,r+2)===`--`){let n=t.slice(r,r+2);r+=2;let{expr:i,pos:a}=e.withDepth(()=>TO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}if(t[r]===`+`||t[r]===`-`||t[r]===`!`||t[r]===`~`){let n=t[r];r++;let{expr:i,pos:a}=e.withDepth(()=>TO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}return DO(e,t,r)}function EO(e,t){let n=e[t];return n===`$`||n==="`"}function DO(e,t,n){let{expr:r,pos:i}=OO(e,t,n,!1),a=[r];for(;EO(t,i);){let{expr:n,pos:r}=OO(e,t,i,!0);a.push(n),i=r}a.length>1&&(r={type:`ArithConcat`,parts:a});let o;if(t[i]===`[`&&r.type===`ArithConcat`){i++;let{expr:n,pos:r}=dO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(o&&r.type===`ArithConcat`&&(r={type:`ArithDynamicElement`,nameExpr:r,subscript:o},o=void 0),i=eO(t,i),r.type===`ArithConcat`||r.type===`ArithVariable`||r.type===`ArithDynamicElement`){for(let n of tO)if(t.slice(i,i+n.length)===n&&t.slice(i,i+n.length+1)!==`==`){i+=n.length;let{expr:a,pos:o}=e.withDepth(()=>pO(e,t,i));return r.type===`ArithDynamicElement`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r.nameExpr,subscript:r.subscript,value:a},pos:o}:r.type===`ArithConcat`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r,value:a},pos:o}:{expr:{type:`ArithAssignment`,operator:n,variable:r.name,value:a},pos:o}}}if(t.slice(i,i+2)===`++`||t.slice(i,i+2)===`--`){let e=t.slice(i,i+2);return i+=2,{expr:{type:`ArithUnary`,operator:e,operand:r,prefix:!1},pos:i}}return{expr:r,pos:i}}function OO(e,t,n,r=!1){let i=eO(t,n),a=rO(dO,e,t,i);if(a)return a;let o=iO(t,i);if(o)return o;let s=aO(t,i);if(s)return s;if(t.slice(i,i+2)===`$(`&&t[i+2]!==`(`){i+=2;let e=1,n=i;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,e>0&&i++;let r=t.slice(n,i);return i++,{expr:{type:`ArithCommandSubst`,command:r},pos:i}}if(t[i]==="`"){i++;let e=i;for(;i<t.length&&t[i]!=="`";)i++;let n=t.slice(e,i);return t[i]==="`"&&i++,{expr:{type:`ArithCommandSubst`,command:n},pos:i}}if(t[i]===`(`){i++;let{expr:n,pos:r}=dO(e,t,i);return i=eO(t,r),t[i]===`)`&&i++,{expr:{type:`ArithGroup`,expression:n},pos:i}}if(t[i]===`'`){i++;let e=``;for(;i<t.length&&t[i]!==`'`;)e+=t[i],i++;t[i]===`'`&&i++;let n=Number.parseInt(e,10);return{expr:{type:`ArithSingleQuote`,content:e,value:Number.isNaN(n)?0:n},pos:i}}if(t[i]===`"`){i++;let n=``;for(;i<t.length&&t[i]!==`"`;)t[i]===`\\`&&i+1<t.length?(n+=t[i+1],i+=2):(n+=t[i],i++);t[i]===`"`&&i++;let r=n.trim();if(!r)return{expr:{type:`ArithNumber`,value:0},pos:i};let{expr:a}=dO(e,r,0);return{expr:a,pos:i}}if(/[0-9]/.test(t[i])){let e=``,n=!1,r=!1;for(;i<t.length;){let a=t[i];if(n){if(/[0-9a-zA-Z@_]/.test(a))e+=a,i++;else break}else if(a===`#`)n=!0,e+=a,i++;else if(e===`0`&&(a===`x`||a===`X`)&&i+1<t.length&&/[0-9a-fA-F]/.test(t[i+1]))r=!0,e+=a,i++;else if(r&&/[0-9a-fA-F]/.test(a))e+=a,i++;else if(!r&&/[0-9]/.test(a))e+=a,i++;else break}if(i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=e;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: value too great for base (error token is "${n}")`},pos:i}}if(t[i]===`.`&&/[0-9]/.test(t[i+1]))throw new Tr(`${e}.${t[i+1]}...: syntax error: invalid arithmetic operator`);if(t[i]===`[`){let n=t.slice(i).trim();return{expr:{type:`ArithNumberSubscript`,number:e,errorToken:n},pos:t.length}}return{expr:{type:`ArithNumber`,value:nO(e)},pos:i}}if(t[i]===`$`&&t[i+1]===`{`){let e=i+2,n=1,r=e;for(;r<t.length&&n>0;)t[r]===`{`?n++:t[r]===`}`&&n--,n>0&&r++;let a=t.slice(e,r),o=r+1;if(t[o]===`#`){let e=o+1;for(;e<t.length&&/[0-9a-zA-Z@_]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicBase`,baseExpr:a,value:t.slice(o+1,e)},pos:e}}if(/[0-9]/.test(t[o])||t[o]===`x`||t[o]===`X`){let e=o;if(t[o]===`x`||t[o]===`X`)for(e++;e<t.length&&/[0-9a-fA-F]/.test(t[e]);)e++;else for(;e<t.length&&/[0-9]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicNumber`,prefix:a,suffix:t.slice(o,e)},pos:e}}return i=o,{expr:{type:`ArithBracedExpansion`,content:a},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[0-9]/.test(t[i+1])){i++;let e=``;for(;i<t.length&&/[0-9]/.test(t[i]);)e+=t[i],i++;return{expr:{type:`ArithVariable`,name:e,hasDollarPrefix:!0},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[*@#?\-!$]/.test(t[i+1])){let e=t[i+1];return i+=2,{expr:{type:`ArithSpecialVar`,name:e},pos:i}}let c=!1;if(t[i]===`$`&&i+1<t.length&&/[a-zA-Z_]/.test(t[i+1])&&(c=!0,i++),i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=``;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;if(t[i]===`[`&&!r){i++;let a;if(t[i]===`'`||t[i]===`"`){let e=t[i];for(i++,a=``;i<t.length&&t[i]!==e;)a+=t[i],i++;t[i]===e&&i++,i=eO(t,i),t[i]===`]`&&i++}let o;if(a===void 0){let{expr:n,pos:r}=dO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(i=eO(t,i),t[i]===`[`&&o)return{expr:{type:`ArithDoubleSubscript`,array:n,index:o},pos:i};if(!r){for(let r of tO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:s,pos:c}=e.withDepth(()=>pO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,subscript:o,stringKey:a,value:s},pos:c}}}return{expr:{type:`ArithArrayElement`,array:n,index:o,stringKey:a},pos:i}}if(i=eO(t,i),!r){for(let r of tO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:a,pos:o}=e.withDepth(()=>pO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,value:a},pos:o}}}return{expr:{type:`ArithVariable`,name:n,hasDollarPrefix:c},pos:i}}if(t[i]===`#`){let e=i+1;for(;e<t.length&&t[e]!==`
887
887
  `;)e++;let n=t.slice(i,e).trim()||`#`;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: syntax error: invalid arithmetic operator (error token is "${n}")`},pos:t.length}}return{expr:{type:`ArithNumber`,value:0},pos:i}}var kO=e=>{let t,n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`&&t===`"`&&r+1<e.length){n+=i+e[r+1],r+=1;continue}if(i===`'`||i===`"`){t===i?t=void 0:t||=i,n+=i;continue}if(i===`\\`&&!t&&r+1<e.length){let t=e[r+1];n+=t===`$`||t==="`"?`\\${t}`:t,r+=1;continue}n+=i}return n};function AO(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function jO(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function MO(e,t,n,r,i){let a=1,o=n+1;for(;o<t.length&&a>0;)t[o]===r?a++:t[o]===i&&a--,a>0&&o++;return a===0?o:-1}function NO(e,t,n){let r=n,i=1;for(;r<t.length&&i>0;){let e=t[r];if(e===`\\`&&r+1<t.length){r+=2;continue}if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++;continue}e===`{`?i++:e===`}`&&i--,i>0&&r++}return r}function PO(e,t,n){let r=n,i=!1;for(;r<t.length;){let e=t[r];if(e===`/`&&i||e===`}`)break;if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1,i=!0;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++,i=!0;continue}e===`\\`?(r+=2,i=!0):(r++,i=!0)}return r}function FO(e,t,n){let r=n,i=``;for(;r<t.length;){let e=t[r];if(e===`*`||e===`?`)i+=e,r++;else if(e===`[`){let n=IO(t,r);n===-1?(i+=e,r++):(i+=t.slice(r,n+1),r=n+1)}else break}return{pattern:i,endIndex:r}}function IO(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){let t=e[n];if(t===`\\`&&n+1<e.length){let t=e[n+1];if(t===`"`||t===`'`)return-1;n+=2;continue}if(t===`]`)return n;if(t===`"`||t===`$`||t==="`")return-1;if(t===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}if(t===`[`&&n+1<e.length&&(e[n+1]===`.`||e[n+1]===`=`)){let t=`${e[n+1]}]`,r=e.indexOf(t,n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function LO(e,t,n){let r=``,i=n;for(;i<t.length&&t[i]!==`'`;){let e=t[i];if(e===`\\`&&i+1<t.length)switch(t[i+1]){case`n`:r+=`
888
- `,i+=2;break;case`t`:r+=` `,i+=2;break;case`r`:r+=`\r`,i+=2;break;case`\\`:r+=`\\`,i+=2;break;case`'`:r+=`'`,i+=2;break;case`"`:r+=`"`,i+=2;break;case`a`:r+=`\x07`,i+=2;break;case`b`:r+=`\b`,i+=2;break;case`e`:case`E`:r+=`\x1B`,i+=2;break;case`f`:r+=`\f`,i+=2;break;case`v`:r+=`\v`,i+=2;break;case`x`:{let e=[],n=i;for(;n+1<t.length&&t[n]===`\\`&&t[n+1]===`x`;){let r=t.slice(n+2,n+4),i=parseInt(r,16);if(!Number.isNaN(i)&&r.length>0)e.push(i),n+=2+r.length;else break}e.length>0?(r+=AO(e),i=n):(r+=`\\x`,i+=2);break}case`u`:{let e=t.slice(i+2,i+6),n=parseInt(e,16);Number.isNaN(n)?(r+=`\\u`,i+=2):(r+=String.fromCharCode(n),i+=6);break}case`c`:if(i+2<t.length){let e=t[i+2].charCodeAt(0)&31;r+=String.fromCharCode(e),i+=3}else r+=`\\c`,i+=2;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let e=``,n=i+1;for(;n<t.length&&n<i+4&&/[0-7]/.test(t[n]);)e+=t[n],n++;let a=parseInt(e,8);r+=String.fromCharCode(a),i=n;break}default:r+=e,i++}else r+=e,i++}return i<t.length&&t[i]===`'`&&i++,{part:X.literal(r),endIndex:i}}function RO(e,t){let n=t.trim();return n===``?{type:`ArithmeticExpression`,expression:{type:`ArithNumber`,value:0}}:sO(e,n)}function zO(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`{`?(r++,n+=a):a===`}`?(r--,n+=a):a===`,`&&r===0?(t.push(n),n=``):n+=a}return t.push(n),t}function BO(e,t,n,r){let i=MO(e,t,n,`{`,`}`);if(i===-1)return null;let a=t.slice(n+1,i),o=a.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:`BraceExpansion`,items:[{type:`Range`,start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:i+1};let s=a.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return s?{part:{type:`BraceExpansion`,items:[{type:`Range`,start:s[1],end:s[2],step:s[3]?Number.parseInt(s[3],10):void 0}]},endIndex:i+1}:a.includes(`,`)&&r?{part:{type:`BraceExpansion`,items:zO(a).map(t=>e.withDepth(()=>({type:`Word`,word:X.word(r(e,t,!1,!1,!1))})))},endIndex:i+1}:a.includes(`,`)?{part:{type:`BraceExpansion`,items:zO(a).map(e=>({type:`Word`,word:X.word([X.literal(e)])}))},endIndex:i+1}:null}function VO(e,t){let n=``;for(let r of t.parts)switch(r.type){case`Literal`:n+=r.value;break;case`SingleQuoted`:n+=`'${r.value}'`;break;case`Escaped`:n+=r.value;break;case`DoubleQuoted`:n+=`"`;for(let e of r.parts)e.type===`Literal`||e.type===`Escaped`?n+=e.value:e.type===`ParameterExpansion`&&(n+=`\${${e.parameter}}`);n+=`"`;break;case`ParameterExpansion`:n+=`\${${r.parameter}}`;break;case`Glob`:n+=r.pattern;break;case`TildeExpansion`:n+=`~`,r.user&&(n+=r.user);break;case`BraceExpansion`:{n+=`{`;let t=[];for(let n of r.items)if(n.type===`Range`){let e=n.startStr??String(n.start),r=n.endStr??String(n.end);n.step===void 0?t.push(`${e}..${r}`):t.push(`${e}..${r}..${n.step}`)}else t.push(VO(e,n.word));t.length===1&&r.items[0].type===`Range`?n+=t[0]:n+=t.join(`,`),n+=`}`;break}default:n+=r.type}return n}function HO(e,t){return{[Z.LESS]:`<`,[Z.GREAT]:`>`,[Z.DGREAT]:`>>`,[Z.LESSAND]:`<&`,[Z.GREATAND]:`>&`,[Z.LESSGREAT]:`<>`,[Z.CLOBBER]:`>|`,[Z.TLESS]:`<<<`,[Z.AND_GREAT]:`&>`,[Z.AND_DGREAT]:`&>>`,[Z.DLESS]:`<`,[Z.DLESSDASH]:`<`}[t]||`>`}function UO(e){let t=e.current(),n=t.type;if(n===Z.NUMBER){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:XD.has(n.type)}if(n===Z.FD_VARIABLE){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:ZD.has(n.type)}return!e.isProcessSubstitutionStart()&&YD.has(n)}function WO(e){let t=null,n;e.check(Z.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(Z.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),i=HO(e,r.type);if(r.type===Z.DLESS||r.type===Z.DLESSDASH)return GO(e,t,n,r.type===Z.DLESSDASH);e.isWord()||e.error(`Expected redirection target`);let a=e.parseWord();return X.redirection(i,a,t,n)}function GO(e,t,n,r){e.isWord()||e.error(`Expected here-document delimiter`);let i=e.advance(),a=i.heredocDelimiter??i.value,o=i.quoted||!1,s=X.redirection(r?`<<-`:`<<`,X.hereDoc(a,X.word([]),r,o),t,n);return e.addPendingHeredoc(s,a,r,o),s}function KO(e){let t=e.getSourceLine(),n=[],r=null,i=[],a=[];for(;e.check(Z.ASSIGNMENT_WORD)||UO(e);)e.checkIterationLimit(),e.check(Z.ASSIGNMENT_WORD)?n.push(qO(e)):a.push(WO(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(Z.DBRACK_START)||e.check(Z.DPAREN_START))){let t=e.advance();r=X.word([X.literal(t.value)])}for(;(!e.isStatementEnd()||e.check(Z.RBRACE))&&!e.check(Z.PIPE,Z.PIPE_AMP);)if(e.checkIterationLimit(),UO(e))a.push(WO(e));else if(e.check(Z.ASSIGNMENT_WORD)){let t=e.advance(),n=t.value,r=n.endsWith(`=`),a=n.endsWith(`=(`);if((r||a)&&(a||e.check(Z.LPAREN))){let t=a?n.slice(0,-2):n.slice(0,-1);a||e.expect(Z.LPAREN);let r=YO(e);e.expect(Z.RPAREN);let o=`${t}=(${r.map(t=>VO(e,t)).join(` `)})`;i.push(e.parseWordFromString(o,!1,!1,!0))}else{let r=e.parseWordFromString(n,t.quoted,t.singleQuoted,!0);i.push(e.parseAdjacentWordParts(r.parts,t.end,JD.Assignment))}}else if(e.isWord())i.push(e.parseWord());else if(e.check(Z.RBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.DBRACK_END)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=X.simpleCommand(r,i,n,a);return o.line=t,o}function qO(e){let t=e.expect(Z.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let i=r[0],a,o=i.length;if(n[o]===`[`){let t=0,r=o+1;for(;o<n.length;o++)if(n[o]===`[`)t++;else if(n[o]===`]`&&(t--,t===0))break;t!==0&&e.error(`Invalid assignment: ${n}`),a=kO(n.slice(r,o)),o++}let s=n[o]===`+`;s&&o++,n[o]!==`=`&&e.error(`Invalid assignment: ${n}`),o++;let c=n.slice(o);if(c===`(`){let t=YO(e);e.expect(Z.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return X.assignment(n,null,s,t)}if(c===``&&e.check(Z.LPAREN)){let n=e.current();if(t.end===n.start){e.advance();let t=YO(e);e.expect(Z.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return X.assignment(n,null,s,t)}}let l=c?e.parseWordFromString(c,t.quoted,t.singleQuoted,!0):null;t.end===e.current().start&&e.isProcessSubstitutionStart()&&(l=e.parseAdjacentWordParts(l?.parts??[],t.end,JD.Assignment));let u=a===void 0?i:`${i}[${a}]`;return X.assignment(u,l,s,null)}var JO=new Set([Z.AMP,Z.PIPE,Z.PIPE_AMP,Z.SEMICOLON,Z.AND_AND,Z.OR_OR,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND]);function YO(e){let t=[];for(e.skipNewlines();!e.check(Z.RPAREN,Z.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):JO.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}function XO(e,t){e.expect(Z.IF);let n=[],r=e.parseCompoundList();e.expect(Z.THEN);let i=e.parseCompoundList();if(i.length===0){let t=e.check(Z.FI)?`fi`:e.check(Z.ELSE)?`else`:e.check(Z.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}for(n.push({condition:r,body:i});e.check(Z.ELIF);){e.advance();let t=e.parseCompoundList();e.expect(Z.THEN);let r=e.parseCompoundList();if(r.length===0){let t=e.check(Z.FI)?`fi`:e.check(Z.ELSE)?`else`:e.check(Z.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}n.push({condition:t,body:r})}let a=null;e.check(Z.ELSE)&&(e.advance(),a=e.parseCompoundList(),a.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(Z.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.ifNode(n,a,o)}function ZO(e,t){let n=e.expect(Z.FOR);if(e.check(Z.DPAREN_START))return QO(e,t,e.getSourceLine(n));e.isWord()||e.error(`Expected variable name in for loop`);let r=e.advance().value,i=null;if(e.skipNewlines(),e.check(Z.IN))for(e.advance(),i=[];!e.check(Z.SEMICOLON,Z.NEWLINE,Z.DO,Z.EOF)&&e.isWord();)i.push(e.parseWord());e.check(Z.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(Z.DO);let a=e.parseCompoundList();e.expect(Z.DONE);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.forNode(r,i,a,o)}function QO(e,t,n){e.expect(Z.DPAREN_START);let r=null,i=null,a=null,o=[``,``,``],s=0,c=0;for(;!e.check(Z.DPAREN_END,Z.EOF);){let t=e.advance();if(t.type===Z.SEMICOLON&&c===0){if(s++,s>2)break}else t.value===`(`&&c++,t.value===`)`&&c--,o[s]+=t.value}e.expect(Z.DPAREN_END),o[0].trim()&&(r=sO(e,o[0].trim())),o[1].trim()&&(i=sO(e,o[1].trim())),o[2].trim()&&(a=sO(e,o[2].trim())),e.skipNewlines(),e.check(Z.SEMICOLON)&&e.advance(),e.skipNewlines();let l;e.check(Z.LBRACE)?(e.advance(),l=e.parseCompoundList(),e.expect(Z.RBRACE)):(e.expect(Z.DO),l=e.parseCompoundList(),e.expect(Z.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:`CStyleFor`,init:r,condition:i,update:a,body:l,redirections:u,line:n}}function $O(e,t){e.expect(Z.WHILE);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.whileNode(n,r,i)}function ek(e,t){e.expect(Z.UNTIL);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.untilNode(n,r,i)}function tk(e,t){e.expect(Z.CASE),e.isWord()||e.error(`Expected word after 'case'`);let n=e.parseWord();e.skipNewlines(),e.expect(Z.IN),e.skipNewlines();let r=[];for(;!e.check(Z.ESAC,Z.EOF);){e.checkIterationLimit();let t=e.getPos(),n=nk(e);if(n&&r.push(n),e.skipNewlines(),e.getPos()===t&&!n)break}e.expect(Z.ESAC);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.caseNode(n,r,i)}function nk(e){e.check(Z.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(Z.PIPE));)e.advance();if(t.length===0)return null;e.expect(Z.RPAREN),e.skipNewlines();let n=[];for(;!e.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND,Z.ESAC,Z.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===Z.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(Z.LPAREN)&&e.peek(1).type===Z.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let t=e.getPos(),r=e.parseStatement();if(r&&n.push(r),e.skipSeparators(!1),e.getPos()===t&&!r)break}let r=`;;`;return e.check(Z.DSEMI)?(e.advance(),r=`;;`):e.check(Z.SEMI_AND)?(e.advance(),r=`;&`):e.check(Z.SEMI_SEMI_AND)&&(e.advance(),r=`;;&`),X.caseItem(t,n,r)}function rk(e,t){e.expect(Z.LPAREN);let n=e.parseCompoundList();e.expect(Z.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.subshell(n,r)}function ik(e,t){e.expect(Z.LBRACE);let n=e.parseCompoundList();e.expect(Z.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.group(n,r)}var ak=`-a.-b.-c.-d.-e.-f.-g.-h.-k.-p.-r.-s.-t.-u.-w.-x.-G.-L.-N.-O.-S.-z.-n.-o.-v.-R`.split(`.`),ok=[`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`];function sk(e){return e.isWord()||e.check(Z.LBRACE)||e.check(Z.RBRACE)||e.check(Z.ASSIGNMENT_WORD)}function ck(e){if(e.check(Z.BANG)&&e.peek(1).type===Z.LPAREN){e.advance(),e.advance();let t=1,n=`!(`;for(;t>0&&!e.check(Z.EOF);)if(e.check(Z.LPAREN))t++,n+=`(`,e.advance();else if(e.check(Z.RPAREN))t--,t>0&&(n+=`)`),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(Z.PIPE))n+=`|`,e.advance();else break;return n+=`)`,e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function lk(e){return e.skipNewlines(),uk(e)}function uk(e){let t=dk(e);for(e.skipNewlines();e.check(Z.OR_OR);){e.advance(),e.skipNewlines();let n=dk(e);t={type:`CondOr`,left:t,right:n},e.skipNewlines()}return t}function dk(e){let t=fk(e);for(e.skipNewlines();e.check(Z.AND_AND);){e.advance(),e.skipNewlines();let n=fk(e);t={type:`CondAnd`,left:t,right:n},e.skipNewlines()}return t}function fk(e){return e.skipNewlines(),e.check(Z.BANG)?(e.advance(),e.skipNewlines(),{type:`CondNot`,operand:e.withDepth(()=>fk(e))}):pk(e)}function pk(e){if(e.check(Z.LPAREN)){e.advance();let t=e.withDepth(()=>lk(e));return e.expect(Z.RPAREN),{type:`CondGroup`,expression:t}}if(sk(e)){let t=e.current(),n=t.value;if(ak.includes(n)&&!t.quoted){if(e.advance(),e.check(Z.DBRACK_END)&&e.error(`Expected operand after ${n}`),sk(e))return{type:`CondUnary`,operator:n,operand:e.parseWordNoBraceExpansion()};let t=e.current();e.error(`unexpected argument \`${t.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&ok.includes(e.current().value)){let t=e.advance().value,n;return n=t===`=~`?mk(e):t===`==`||t===`!=`?ck(e):e.parseWordNoBraceExpansion(),{type:`CondBinary`,operator:t,left:r,right:n}}return e.check(Z.LESS)?(e.advance(),{type:`CondBinary`,operator:`<`,left:r,right:e.parseWordNoBraceExpansion()}):e.check(Z.GREAT)?(e.advance(),{type:`CondBinary`,operator:`>`,left:r,right:e.parseWordNoBraceExpansion()}):e.isWord()&&e.current().value===`=`?(e.advance(),{type:`CondBinary`,operator:`==`,left:r,right:ck(e)}):{type:`CondWord`,word:r}}e.error(`Expected conditional expression`)}function mk(e){let t=[],n=0,r=-1,i=e.getInput(),a=()=>e.check(Z.DBRACK_END)||e.check(Z.AND_AND)||e.check(Z.OR_OR)||e.check(Z.NEWLINE)||e.check(Z.EOF);for(;!a();){let a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let e=i.slice(r,a.start);t.push({type:`Literal`,value:e})}if(e.isWord()||e.check(Z.ASSIGNMENT_WORD)){let n=e.parseWordForRegex();t.push(...n.parts),r=e.peek(-1).end}else if(e.check(Z.LPAREN)){let i=e.advance();t.push({type:`Literal`,value:`(`}),n++,r=i.end}else if(e.check(Z.DPAREN_START)){let i=e.advance();t.push({type:`Literal`,value:`((`}),n+=2,r=i.end}else if(e.check(Z.DPAREN_END))if(n>=2){let i=e.advance();t.push({type:`Literal`,value:`))`}),n-=2,r=i.end}else{if(n===1)break;break}else if(e.check(Z.RPAREN))if(n>0){let i=e.advance();t.push({type:`Literal`,value:`)`}),n--,r=i.end}else break;else if(e.check(Z.PIPE)){let n=e.advance();t.push({type:`Literal`,value:`|`}),r=n.end}else if(e.check(Z.SEMICOLON))if(n>0){let n=e.advance();t.push({type:`Literal`,value:`;`}),r=n.end}else break;else if(n>0&&e.check(Z.LESS)){let n=e.advance();t.push({type:`Literal`,value:`<`}),r=n.end}else if(n>0&&e.check(Z.GREAT)){let n=e.advance();t.push({type:`Literal`,value:`>`}),r=n.end}else if(n>0&&e.check(Z.DGREAT)){let n=e.advance();t.push({type:`Literal`,value:`>>`}),r=n.end}else if(n>0&&e.check(Z.DLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<`}),r=n.end}else if(n>0&&e.check(Z.LESSAND)){let n=e.advance();t.push({type:`Literal`,value:`<&`}),r=n.end}else if(n>0&&e.check(Z.GREATAND)){let n=e.advance();t.push({type:`Literal`,value:`>&`}),r=n.end}else if(n>0&&e.check(Z.LESSGREAT)){let n=e.advance();t.push({type:`Literal`,value:`<>`}),r=n.end}else if(n>0&&e.check(Z.CLOBBER)){let n=e.advance();t.push({type:`Literal`,value:`>|`}),r=n.end}else if(n>0&&e.check(Z.TLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<<`}),r=n.end}else if(n>0&&e.check(Z.AMP)){let n=e.advance();t.push({type:`Literal`,value:`&`}),r=n.end}else if(n>0&&e.check(Z.LBRACE)){let n=e.advance();t.push({type:`Literal`,value:`{`}),r=n.end}else if(n>0&&e.check(Z.RBRACE)){let n=e.advance();t.push({type:`Literal`,value:`}`}),r=n.end}else break}return t.length===0&&e.error(`Expected regex pattern after =~`),{type:`Word`,parts:t}}function hk(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=e[n+1];if(r!==`\\`||i===void 0){t+=r;continue}`\\[]^-`.includes(i)&&(t+=`\\`),t+=i,n++}return t}function gk(e){return e.length>0?e:[X.literal(``)]}function _k(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(`@*+?!`.includes(t)&&r+1<e.length&&e[r+1]===`(`){r++,n++,r++;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function vk(e,t,n){let r=n+1,i=t[r];if(`@*#?$!-0123456789`.includes(i))return{part:X.parameterExpansion(i),endIndex:r+1};let a=``;for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)a+=t[r],r++;return{part:X.parameterExpansion(a),endIndex:r}}function yk(e,t,n,r=!1){let i=n+2,a=!1;t[i]===`!`&&(a=!0,i++);let o=!1;t[i]===`#`&&!/[}:#%/^,]/.test(t[i+1]||`}`)&&(o=!0,i++);let s=``,c=t[i];if(/[@*#?$!-]/.test(c)&&!/[a-zA-Z0-9_]/.test(t[i+1]||``))s=c,i++;else for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)s+=t[i],i++;if(t[i]===`[`){let r=MO(e,t,i,`[`,`]`);if(s+=`[${kO(t.slice(i+1,r))}]`,i=r+1,t[i]===`[`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}}if(s===``&&!a&&!o&&t[i]!==`}`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;if(e>0)throw new QD(`unexpected EOF while looking for matching '}'`,0,0);let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}let l=null;if(a){let n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n)if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let a=bk(e,t,i,s,r);a.operation?(l={type:`Indirection`,innerOp:a.operation},i=a.endIndex):(l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``)}else l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``;else if(t[i]===`*`||t[i]===`@`&&!/[QPaAEKkuUL]/.test(t[i+1]||``)){let e=t[i];i++,l={type:`VarNamePrefix`,prefix:s,star:e===`*`},s=``}else if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let n=bk(e,t,i,s,r);n.operation?(l={type:`Indirection`,innerOp:n.operation},i=n.endIndex):l={type:`Indirection`}}else l={type:`Indirection`}}else if(o)if(t[i]===`:`)for(l={type:`LengthSliceError`};i<t.length&&t[i]!==`}`;)i++;else t[i]!==`}`&&/[-+=?]/.test(t[i])||t[i]===`/`?e.error(`\${#${s}${t.slice(i,t.indexOf(`}`,i))}}: bad substitution`):l={type:`Length`};if(!l&&i<t.length&&t[i]!==`}`){let n=bk(e,t,i,s,r);l=n.operation,i=n.endIndex}if(i<t.length&&t[i]!==`}`){let r=t[i];if(!/[:\-+=?#%/^,@[]/.test(r)){let r=i;for(;r<t.length&&t[r]!==`}`;)r++;let a=t.slice(n,r+1);e.error(`\${${a.slice(2,-1)}}: bad substitution`)}}for(;i<t.length&&t[i]!==`}`;)i++;if(i>=t.length)throw new QD(`unexpected EOF while looking for matching '}'`,0,0);return{part:X.parameterExpansion(s,l),endIndex:i+1}}function bk(e,t,n,r,i=!1){let a=n,o=t[a],s=t[a+1]||``;if(o===`:`){let n=s;if(`-=?+`.includes(n)){a+=2;let r=NO(e,t,a),o=t.slice(a,r),s=e.withDepth(()=>wk(e,o,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(gk(s));if(n===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!0},endIndex:r};if(n===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!0},endIndex:r};if(n===`?`)return{operation:{type:`ErrorIfUnset`,word:c,checkEmpty:!0},endIndex:r};if(n===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!0},endIndex:r}}a++;let r=NO(e,t,a),o=t.slice(a,r),c=-1,l=0,u=0;for(let e=0;e<o.length;e++){let t=o[e];if(t===`(`||t===`[`)l++;else if(t===`)`||t===`]`)l--;else if(t===`?`&&l===0)u++;else if(t===`:`&&l===0)if(u>0)u--;else{c=e;break}}let d=c>=0?o.slice(0,c):o,f=c>=0?o.slice(c+1):null;return{operation:{type:`Substring`,offset:RO(e,d),length:f===null?null:RO(e,f)},endIndex:r}}if(`-=?+`.includes(o)){a++;let n=NO(e,t,a),r=t.slice(a,n),s=e.withDepth(()=>wk(e,r,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(gk(s));if(o===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!1},endIndex:n};if(o===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!1},endIndex:n};if(o===`?`)return{operation:{type:`ErrorIfUnset`,word:r?c:null,checkEmpty:!1},endIndex:n};if(o===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!1},endIndex:n}}if(o===`#`||o===`%`){let n=s===o,r=o===`#`?`prefix`:`suffix`;a+=n?2:1;let i=NO(e,t,a),c=t.slice(a,i),l=e.withDepth(()=>wk(e,c,!1,!1,!1));return{operation:{type:`PatternRemoval`,pattern:X.word(gk(l)),side:r,greedy:n},endIndex:i}}if(o===`/`){let n=s===`/`;a+=n?2:1;let r=null;t[a]===`#`?(r=`start`,a++):t[a]===`%`&&(r=`end`,a++);let i;i=r!==null&&(t[a]===`/`||t[a]===`}`)?a:PO(e,t,a);let o=t.slice(a,i),c=e.withDepth(()=>wk(e,o,!1,!1,!1)),l=X.word(gk(c)),u=null,d=i;if(t[i]===`/`){let n=i+1,r=NO(e,t,n),a=t.slice(n,r),o=e.withDepth(()=>wk(e,a,!1,!1,!1));u=X.word(gk(o)),d=r}return{operation:{type:`PatternReplacement`,pattern:l,replacement:u,all:n,anchor:r},endIndex:d}}if(o===`^`||o===`,`){let n=s===o,r=o===`^`?`upper`:`lower`;a+=n?2:1;let i=NO(e,t,a),c=t.slice(a,i);return{operation:{type:`CaseModification`,direction:r,all:n,pattern:c?X.word([X.literal(c)]):null},endIndex:i}}return o===`@`&&/[QPaAEKkuUL]/.test(s)?{operation:{type:`Transform`,operator:s},endIndex:a+2}:{operation:null,endIndex:a}}function xk(e,t,n,r=!1){let i=n+1;if(i>=t.length)return{part:X.literal(`$`),endIndex:i};let a=t[i];if(a===`(`&&t[i+1]===`(`)return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(a===`[`){let n=1,r=i+1;for(;r<t.length&&n>0;)t[r]===`[`?n++:t[r]===`]`&&n--,n>0&&r++;if(n===0){let n=sO(e,t.slice(i+1,r));return{part:X.arithmeticExpansion(n),endIndex:r+1}}}return a===`(`?e.parseCommandSubstitution(t,n):a===`{`?yk(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(a)?vk(e,t,n):{part:X.literal(`$`),endIndex:i}}function Sk(e,t){let n=[],r=0,i=``,a=()=>{i&&=(n.push(X.literal(i)),``)};for(;r<t.length;){let o=t[r];if(o===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`"`||e===`\\`){i+=e,r+=2;continue}i+=o,r++;continue}if(o===`$`){a();let{part:i,endIndex:o}=xk(e,t,r,!0);i&&n.push(i),r=o;continue}if(o==="`"){a();let{part:i,endIndex:o}=e.parseBacktickSubstitution(t,r,!0);n.push(i),r=o;continue}i+=o,r++}return a(),n}function Ck(e,t,n){let r=[],i=n,a=``,o=()=>{a&&=(r.push(X.literal(a)),``)};for(;i<t.length&&t[i]!==`"`;){let n=t[i];if(n===`\\`&&i+1<t.length){let e=t[i+1];if(`"\\$\`
888
+ `,i+=2;break;case`t`:r+=` `,i+=2;break;case`r`:r+=`\r`,i+=2;break;case`\\`:r+=`\\`,i+=2;break;case`'`:r+=`'`,i+=2;break;case`"`:r+=`"`,i+=2;break;case`a`:r+=`\x07`,i+=2;break;case`b`:r+=`\b`,i+=2;break;case`e`:case`E`:r+=`\x1B`,i+=2;break;case`f`:r+=`\f`,i+=2;break;case`v`:r+=`\v`,i+=2;break;case`x`:{let e=[],n=i;for(;n+1<t.length&&t[n]===`\\`&&t[n+1]===`x`;){let r=t.slice(n+2,n+4),i=parseInt(r,16);if(!Number.isNaN(i)&&r.length>0)e.push(i),n+=2+r.length;else break}e.length>0?(r+=AO(e),i=n):(r+=`\\x`,i+=2);break}case`u`:{let e=t.slice(i+2,i+6),n=parseInt(e,16);Number.isNaN(n)?(r+=`\\u`,i+=2):(r+=String.fromCharCode(n),i+=6);break}case`c`:if(i+2<t.length){let e=t[i+2].charCodeAt(0)&31;r+=String.fromCharCode(e),i+=3}else r+=`\\c`,i+=2;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let e=``,n=i+1;for(;n<t.length&&n<i+4&&/[0-7]/.test(t[n]);)e+=t[n],n++;let a=parseInt(e,8);r+=String.fromCharCode(a),i=n;break}default:r+=e,i++}else r+=e,i++}return i<t.length&&t[i]===`'`&&i++,{part:X.literal(r),endIndex:i}}function RO(e,t){let n=t.trim();return n===``?{type:`ArithmeticExpression`,expression:{type:`ArithNumber`,value:0}}:sO(e,n)}function zO(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`{`?(r++,n+=a):a===`}`?(r--,n+=a):a===`,`&&r===0?(t.push(n),n=``):n+=a}return t.push(n),t}function BO(e,t,n,r){let i=MO(e,t,n,`{`,`}`);if(i===-1)return null;let a=t.slice(n+1,i),o=a.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:`BraceExpansion`,items:[{type:`Range`,start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:i+1};let s=a.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return s?{part:{type:`BraceExpansion`,items:[{type:`Range`,start:s[1],end:s[2],step:s[3]?Number.parseInt(s[3],10):void 0}]},endIndex:i+1}:a.includes(`,`)&&r?{part:{type:`BraceExpansion`,items:zO(a).map(t=>e.withDepth(()=>({type:`Word`,word:X.word(r(e,t,!1,!1,!1))})))},endIndex:i+1}:a.includes(`,`)?{part:{type:`BraceExpansion`,items:zO(a).map(e=>({type:`Word`,word:X.word([X.literal(e)])}))},endIndex:i+1}:null}function VO(e,t){let n=``;for(let r of t.parts)switch(r.type){case`Literal`:n+=r.value;break;case`SingleQuoted`:n+=`'${r.value}'`;break;case`Escaped`:n+=r.value;break;case`DoubleQuoted`:n+=`"`;for(let e of r.parts)e.type===`Literal`||e.type===`Escaped`?n+=e.value:e.type===`ParameterExpansion`&&(n+=`\${${e.parameter}}`);n+=`"`;break;case`ParameterExpansion`:n+=`\${${r.parameter}}`;break;case`Glob`:n+=r.pattern;break;case`TildeExpansion`:n+=`~`,r.user&&(n+=r.user);break;case`BraceExpansion`:{n+=`{`;let t=[];for(let n of r.items)if(n.type===`Range`){let e=n.startStr??String(n.start),r=n.endStr??String(n.end);n.step===void 0?t.push(`${e}..${r}`):t.push(`${e}..${r}..${n.step}`)}else t.push(VO(e,n.word));t.length===1&&r.items[0].type===`Range`?n+=t[0]:n+=t.join(`,`),n+=`}`;break}default:n+=r.type}return n}function HO(e,t){return{[Z.LESS]:`<`,[Z.GREAT]:`>`,[Z.DGREAT]:`>>`,[Z.LESSAND]:`<&`,[Z.GREATAND]:`>&`,[Z.LESSGREAT]:`<>`,[Z.CLOBBER]:`>|`,[Z.TLESS]:`<<<`,[Z.AND_GREAT]:`&>`,[Z.AND_DGREAT]:`&>>`,[Z.DLESS]:`<`,[Z.DLESSDASH]:`<`}[t]||`>`}function UO(e){let t=e.current(),n=t.type;if(n===Z.NUMBER){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:XD.has(n.type)}if(n===Z.FD_VARIABLE){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:ZD.has(n.type)}return!e.isProcessSubstitutionStart()&&YD.has(n)}function WO(e){let t=null,n;e.check(Z.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(Z.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),i=HO(e,r.type);if(r.type===Z.DLESS||r.type===Z.DLESSDASH)return GO(e,t,n,r.type===Z.DLESSDASH);e.isWord()||e.error(`Expected redirection target`);let a=e.parseWord();return X.redirection(i,a,t,n)}function GO(e,t,n,r){e.isWord()||e.error(`Expected here-document delimiter`);let i=e.advance(),a=i.heredocDelimiter??i.value,o=i.quoted||!1,s=X.redirection(r?`<<-`:`<<`,X.hereDoc(a,X.word([]),r,o),t,n);return e.addPendingHeredoc(s,a,r,o),s}function KO(e){let t=e.getSourceLine(),n=[],r=null,i=[],a=[];for(;e.check(Z.ASSIGNMENT_WORD)||UO(e);)e.checkIterationLimit(),e.check(Z.ASSIGNMENT_WORD)?n.push(qO(e)):a.push(WO(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(Z.DBRACK_START)||e.check(Z.DPAREN_START))){let t=e.advance();r=X.word([X.literal(t.value)])}for(;(!e.isStatementEnd()||e.check(Z.RBRACE))&&!e.check(Z.PIPE,Z.PIPE_AMP);)if(e.checkIterationLimit(),UO(e))a.push(WO(e));else if(e.check(Z.ASSIGNMENT_WORD)){let t=e.advance(),n=t.value,r=n.endsWith(`=`),a=n.endsWith(`=(`);if((r||a)&&(a||e.check(Z.LPAREN))){let t=a?n.slice(0,-2):n.slice(0,-1);a||e.expect(Z.LPAREN);let r=YO(e);e.expect(Z.RPAREN);let o=`${t}=(${r.map(t=>VO(e,t)).join(` `)})`;i.push(e.parseWordFromString(o,!1,!1,!0))}else{let r=e.parseWordFromString(n,t.quoted,t.singleQuoted,!0);i.push(e.parseAdjacentWordParts(r.parts,t.end,JD.Assignment))}}else if(e.isWord())i.push(e.parseWord());else if(e.check(Z.RBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.DBRACK_END)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=X.simpleCommand(r,i,n,a);return o.line=t,o}function qO(e){let t=e.expect(Z.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let i=r[0],a,o=i.length;if(n[o]===`[`){let t=0,r=o+1;for(;o<n.length;o++)if(n[o]===`[`)t++;else if(n[o]===`]`&&(t--,t===0))break;t!==0&&e.error(`Invalid assignment: ${n}`),a=kO(n.slice(r,o)),o++}let s=n[o]===`+`;s&&o++,n[o]!==`=`&&e.error(`Invalid assignment: ${n}`),o++;let c=n.slice(o);if(c===`(`){let t=YO(e);e.expect(Z.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return X.assignment(n,null,s,t)}if(c===``&&e.check(Z.LPAREN)){let n=e.current();if(t.end===n.start){e.advance();let t=YO(e);e.expect(Z.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return X.assignment(n,null,s,t)}}let l=c?e.parseWordFromString(c,t.quoted,t.singleQuoted,!0):null;t.end===e.current().start&&e.isProcessSubstitutionStart()&&(l=e.parseAdjacentWordParts(l?.parts??[],t.end,JD.Assignment));let u=a===void 0?i:`${i}[${a}]`;return X.assignment(u,l,s,null)}var JO=new Set([Z.AMP,Z.PIPE,Z.PIPE_AMP,Z.SEMICOLON,Z.AND_AND,Z.OR_OR,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND]);function YO(e){let t=[];for(e.skipNewlines();!e.check(Z.RPAREN,Z.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):JO.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}function XO(e,t){e.expect(Z.IF);let n=[],r=e.parseCompoundList();e.expect(Z.THEN);let i=e.parseCompoundList();if(i.length===0){let t=e.check(Z.FI)?`fi`:e.check(Z.ELSE)?`else`:e.check(Z.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}for(n.push({condition:r,body:i});e.check(Z.ELIF);){e.advance();let t=e.parseCompoundList();e.expect(Z.THEN);let r=e.parseCompoundList();if(r.length===0){let t=e.check(Z.FI)?`fi`:e.check(Z.ELSE)?`else`:e.check(Z.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}n.push({condition:t,body:r})}let a=null;e.check(Z.ELSE)&&(e.advance(),a=e.parseCompoundList(),a.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(Z.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.ifNode(n,a,o)}function ZO(e,t){let n=e.expect(Z.FOR);if(e.check(Z.DPAREN_START))return QO(e,t,e.getSourceLine(n));e.isWord()||e.error(`Expected variable name in for loop`);let r=e.advance().value,i=null;if(e.skipNewlines(),e.check(Z.IN))for(e.advance(),i=[];!e.check(Z.SEMICOLON,Z.NEWLINE,Z.DO,Z.EOF)&&e.isWord();)i.push(e.parseWord());e.check(Z.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(Z.DO);let a=e.parseCompoundList();e.expect(Z.DONE);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.forNode(r,i,a,o)}function QO(e,t,n){e.expect(Z.DPAREN_START);let r=null,i=null,a=null,o=[``,``,``],s=0,c=0;for(;!e.check(Z.DPAREN_END,Z.EOF);){let t=e.advance();if(t.type===Z.SEMICOLON&&c===0){if(s++,s>2)break}else t.value===`(`&&c++,t.value===`)`&&c--,o[s]+=t.value}e.expect(Z.DPAREN_END),o[0].trim()&&(r=sO(e,o[0].trim())),o[1].trim()&&(i=sO(e,o[1].trim())),o[2].trim()&&(a=sO(e,o[2].trim())),e.skipNewlines(),e.check(Z.SEMICOLON)&&e.advance(),e.skipNewlines();let l;e.check(Z.LBRACE)?(e.advance(),l=e.parseCompoundList(),e.expect(Z.RBRACE)):(e.expect(Z.DO),l=e.parseCompoundList(),e.expect(Z.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:`CStyleFor`,init:r,condition:i,update:a,body:l,redirections:u,line:n}}function $O(e,t){e.expect(Z.WHILE);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.whileNode(n,r,i)}function ek(e,t){e.expect(Z.UNTIL);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.untilNode(n,r,i)}function tk(e,t){e.expect(Z.CASE),e.isWord()||e.error(`Expected word after 'case'`);let n=e.parseWord();e.skipNewlines(),e.expect(Z.IN),e.skipNewlines();let r=[];for(;!e.check(Z.ESAC,Z.EOF);){e.checkIterationLimit();let t=e.getPos(),n=nk(e);if(n&&r.push(n),e.skipNewlines(),e.getPos()===t&&!n)break}e.expect(Z.ESAC);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.caseNode(n,r,i)}function nk(e){e.check(Z.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(Z.PIPE));)e.advance();if(t.length===0)return null;e.expect(Z.RPAREN),e.skipNewlines();let n=[];for(;!e.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND,Z.ESAC,Z.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===Z.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(Z.LPAREN)&&e.peek(1).type===Z.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let t=e.getPos(),r=e.parseStatement();if(r&&n.push(r),e.skipSeparators(!1),e.getPos()===t&&!r)break}let r=`;;`;return e.check(Z.DSEMI)?(e.advance(),r=`;;`):e.check(Z.SEMI_AND)?(e.advance(),r=`;&`):e.check(Z.SEMI_SEMI_AND)&&(e.advance(),r=`;;&`),X.caseItem(t,n,r)}function rk(e,t){e.expect(Z.LPAREN);let n=e.parseCompoundList();e.expect(Z.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.subshell(n,r)}function ik(e,t){e.expect(Z.LBRACE);let n=e.parseCompoundList();e.expect(Z.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.group(n,r)}var ak=`-a.-b.-c.-d.-e.-f.-g.-h.-k.-p.-r.-s.-t.-u.-w.-x.-G.-L.-N.-O.-S.-z.-n.-o.-v.-R`.split(`.`),ok=[`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`];function sk(e){return e.isWord()||e.check(Z.LBRACE)||e.check(Z.RBRACE)||e.check(Z.ASSIGNMENT_WORD)}function ck(e){if(e.check(Z.BANG)&&e.peek(1).type===Z.LPAREN){e.advance(),e.advance();let t=1,n=`!(`;for(;t>0&&!e.check(Z.EOF);)if(e.check(Z.LPAREN))t++,n+=`(`,e.advance();else if(e.check(Z.RPAREN))t--,t>0&&(n+=`)`),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(Z.PIPE))n+=`|`,e.advance();else break;return n+=`)`,e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function lk(e){return e.skipNewlines(),uk(e)}function uk(e){let t=dk(e);for(e.skipNewlines();e.check(Z.OR_OR);){e.advance(),e.skipNewlines();let n=dk(e);t={type:`CondOr`,left:t,right:n},e.skipNewlines()}return t}function dk(e){let t=fk(e);for(e.skipNewlines();e.check(Z.AND_AND);){e.advance(),e.skipNewlines();let n=fk(e);t={type:`CondAnd`,left:t,right:n},e.skipNewlines()}return t}function fk(e){return e.skipNewlines(),e.check(Z.BANG)?(e.advance(),e.skipNewlines(),{type:`CondNot`,operand:e.withDepth(()=>fk(e))}):pk(e)}function pk(e){if(e.check(Z.LPAREN)){e.advance();let t=e.withDepth(()=>lk(e));return e.expect(Z.RPAREN),{type:`CondGroup`,expression:t}}if(sk(e)){let t=e.current(),n=t.value;if(ak.includes(n)&&!t.quoted){if(e.advance(),e.check(Z.DBRACK_END)&&e.error(`Expected operand after ${n}`),sk(e))return{type:`CondUnary`,operator:n,operand:e.parseWordNoBraceExpansion()};let t=e.current();e.error(`unexpected argument \`${t.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&ok.includes(e.current().value)){let t=e.advance().value,n;return n=t===`=~`?mk(e):t===`==`||t===`!=`?ck(e):e.parseWordNoBraceExpansion(),{type:`CondBinary`,operator:t,left:r,right:n}}return e.check(Z.LESS)?(e.advance(),{type:`CondBinary`,operator:`<`,left:r,right:e.parseWordNoBraceExpansion()}):e.check(Z.GREAT)?(e.advance(),{type:`CondBinary`,operator:`>`,left:r,right:e.parseWordNoBraceExpansion()}):e.isWord()&&e.current().value===`=`?(e.advance(),{type:`CondBinary`,operator:`==`,left:r,right:ck(e)}):{type:`CondWord`,word:r}}e.error(`Expected conditional expression`)}function mk(e){let t=[],n=0,r=-1,i=e.getInput(),a=()=>e.check(Z.DBRACK_END)||e.check(Z.AND_AND)||e.check(Z.OR_OR)||e.check(Z.NEWLINE)||e.check(Z.EOF);for(;!a();){let a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let e=i.slice(r,a.start);t.push({type:`Literal`,value:e})}if(e.isWord()||e.check(Z.ASSIGNMENT_WORD)){let n=e.parseWordForRegex();t.push(...n.parts),r=e.peek(-1).end}else if(e.check(Z.LPAREN)){let i=e.advance();t.push({type:`Literal`,value:`(`}),n++,r=i.end}else if(e.check(Z.DPAREN_START)){let i=e.advance();t.push({type:`Literal`,value:`((`}),n+=2,r=i.end}else if(e.check(Z.DPAREN_END)){if(n>=2){let i=e.advance();t.push({type:`Literal`,value:`))`}),n-=2,r=i.end}else{if(n===1)break;break}}else if(e.check(Z.RPAREN)){if(n>0){let i=e.advance();t.push({type:`Literal`,value:`)`}),n--,r=i.end}else break}else if(e.check(Z.PIPE)){let n=e.advance();t.push({type:`Literal`,value:`|`}),r=n.end}else if(e.check(Z.SEMICOLON)){if(n>0){let n=e.advance();t.push({type:`Literal`,value:`;`}),r=n.end}else break}else if(n>0&&e.check(Z.LESS)){let n=e.advance();t.push({type:`Literal`,value:`<`}),r=n.end}else if(n>0&&e.check(Z.GREAT)){let n=e.advance();t.push({type:`Literal`,value:`>`}),r=n.end}else if(n>0&&e.check(Z.DGREAT)){let n=e.advance();t.push({type:`Literal`,value:`>>`}),r=n.end}else if(n>0&&e.check(Z.DLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<`}),r=n.end}else if(n>0&&e.check(Z.LESSAND)){let n=e.advance();t.push({type:`Literal`,value:`<&`}),r=n.end}else if(n>0&&e.check(Z.GREATAND)){let n=e.advance();t.push({type:`Literal`,value:`>&`}),r=n.end}else if(n>0&&e.check(Z.LESSGREAT)){let n=e.advance();t.push({type:`Literal`,value:`<>`}),r=n.end}else if(n>0&&e.check(Z.CLOBBER)){let n=e.advance();t.push({type:`Literal`,value:`>|`}),r=n.end}else if(n>0&&e.check(Z.TLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<<`}),r=n.end}else if(n>0&&e.check(Z.AMP)){let n=e.advance();t.push({type:`Literal`,value:`&`}),r=n.end}else if(n>0&&e.check(Z.LBRACE)){let n=e.advance();t.push({type:`Literal`,value:`{`}),r=n.end}else if(n>0&&e.check(Z.RBRACE)){let n=e.advance();t.push({type:`Literal`,value:`}`}),r=n.end}else break}return t.length===0&&e.error(`Expected regex pattern after =~`),{type:`Word`,parts:t}}function hk(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=e[n+1];if(r!==`\\`||i===void 0){t+=r;continue}`\\[]^-`.includes(i)&&(t+=`\\`),t+=i,n++}return t}function gk(e){return e.length>0?e:[X.literal(``)]}function _k(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(`@*+?!`.includes(t)&&r+1<e.length&&e[r+1]===`(`){r++,n++,r++;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function vk(e,t,n){let r=n+1,i=t[r];if(`@*#?$!-0123456789`.includes(i))return{part:X.parameterExpansion(i),endIndex:r+1};let a=``;for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)a+=t[r],r++;return{part:X.parameterExpansion(a),endIndex:r}}function yk(e,t,n,r=!1){let i=n+2,a=!1;t[i]===`!`&&(a=!0,i++);let o=!1;t[i]===`#`&&!/[}:#%/^,]/.test(t[i+1]||`}`)&&(o=!0,i++);let s=``,c=t[i];if(/[@*#?$!-]/.test(c)&&!/[a-zA-Z0-9_]/.test(t[i+1]||``))s=c,i++;else for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)s+=t[i],i++;if(t[i]===`[`){let r=MO(e,t,i,`[`,`]`);if(s+=`[${kO(t.slice(i+1,r))}]`,i=r+1,t[i]===`[`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}}if(s===``&&!a&&!o&&t[i]!==`}`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;if(e>0)throw new QD(`unexpected EOF while looking for matching '}'`,0,0);let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}let l=null;if(a){let n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let a=bk(e,t,i,s,r);a.operation?(l={type:`Indirection`,innerOp:a.operation},i=a.endIndex):(l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``)}else l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``}else if(t[i]===`*`||t[i]===`@`&&!/[QPaAEKkuUL]/.test(t[i+1]||``)){let e=t[i];i++,l={type:`VarNamePrefix`,prefix:s,star:e===`*`},s=``}else if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let n=bk(e,t,i,s,r);n.operation?(l={type:`Indirection`,innerOp:n.operation},i=n.endIndex):l={type:`Indirection`}}else l={type:`Indirection`}}else if(o){if(t[i]===`:`)for(l={type:`LengthSliceError`};i<t.length&&t[i]!==`}`;)i++;else t[i]!==`}`&&/[-+=?]/.test(t[i])||t[i]===`/`?e.error(`\${#${s}${t.slice(i,t.indexOf(`}`,i))}}: bad substitution`):l={type:`Length`}}if(!l&&i<t.length&&t[i]!==`}`){let n=bk(e,t,i,s,r);l=n.operation,i=n.endIndex}if(i<t.length&&t[i]!==`}`){let r=t[i];if(!/[:\-+=?#%/^,@[]/.test(r)){let r=i;for(;r<t.length&&t[r]!==`}`;)r++;let a=t.slice(n,r+1);e.error(`\${${a.slice(2,-1)}}: bad substitution`)}}for(;i<t.length&&t[i]!==`}`;)i++;if(i>=t.length)throw new QD(`unexpected EOF while looking for matching '}'`,0,0);return{part:X.parameterExpansion(s,l),endIndex:i+1}}function bk(e,t,n,r,i=!1){let a=n,o=t[a],s=t[a+1]||``;if(o===`:`){let n=s;if(`-=?+`.includes(n)){a+=2;let r=NO(e,t,a),o=t.slice(a,r),s=e.withDepth(()=>wk(e,o,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(gk(s));if(n===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!0},endIndex:r};if(n===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!0},endIndex:r};if(n===`?`)return{operation:{type:`ErrorIfUnset`,word:c,checkEmpty:!0},endIndex:r};if(n===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!0},endIndex:r}}a++;let r=NO(e,t,a),o=t.slice(a,r),c=-1,l=0,u=0;for(let e=0;e<o.length;e++){let t=o[e];if(t===`(`||t===`[`)l++;else if(t===`)`||t===`]`)l--;else if(t===`?`&&l===0)u++;else if(t===`:`&&l===0){if(u>0)u--;else{c=e;break}}}let d=c>=0?o.slice(0,c):o,f=c>=0?o.slice(c+1):null;return{operation:{type:`Substring`,offset:RO(e,d),length:f===null?null:RO(e,f)},endIndex:r}}if(`-=?+`.includes(o)){a++;let n=NO(e,t,a),r=t.slice(a,n),s=e.withDepth(()=>wk(e,r,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(gk(s));if(o===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!1},endIndex:n};if(o===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!1},endIndex:n};if(o===`?`)return{operation:{type:`ErrorIfUnset`,word:r?c:null,checkEmpty:!1},endIndex:n};if(o===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!1},endIndex:n}}if(o===`#`||o===`%`){let n=s===o,r=o===`#`?`prefix`:`suffix`;a+=n?2:1;let i=NO(e,t,a),c=t.slice(a,i),l=e.withDepth(()=>wk(e,c,!1,!1,!1));return{operation:{type:`PatternRemoval`,pattern:X.word(gk(l)),side:r,greedy:n},endIndex:i}}if(o===`/`){let n=s===`/`;a+=n?2:1;let r=null;t[a]===`#`?(r=`start`,a++):t[a]===`%`&&(r=`end`,a++);let i;i=r!==null&&(t[a]===`/`||t[a]===`}`)?a:PO(e,t,a);let o=t.slice(a,i),c=e.withDepth(()=>wk(e,o,!1,!1,!1)),l=X.word(gk(c)),u=null,d=i;if(t[i]===`/`){let n=i+1,r=NO(e,t,n),a=t.slice(n,r),o=e.withDepth(()=>wk(e,a,!1,!1,!1));u=X.word(gk(o)),d=r}return{operation:{type:`PatternReplacement`,pattern:l,replacement:u,all:n,anchor:r},endIndex:d}}if(o===`^`||o===`,`){let n=s===o,r=o===`^`?`upper`:`lower`;a+=n?2:1;let i=NO(e,t,a),c=t.slice(a,i);return{operation:{type:`CaseModification`,direction:r,all:n,pattern:c?X.word([X.literal(c)]):null},endIndex:i}}return o===`@`&&/[QPaAEKkuUL]/.test(s)?{operation:{type:`Transform`,operator:s},endIndex:a+2}:{operation:null,endIndex:a}}function xk(e,t,n,r=!1){let i=n+1;if(i>=t.length)return{part:X.literal(`$`),endIndex:i};let a=t[i];if(a===`(`&&t[i+1]===`(`)return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(a===`[`){let n=1,r=i+1;for(;r<t.length&&n>0;)t[r]===`[`?n++:t[r]===`]`&&n--,n>0&&r++;if(n===0){let n=sO(e,t.slice(i+1,r));return{part:X.arithmeticExpansion(n),endIndex:r+1}}}return a===`(`?e.parseCommandSubstitution(t,n):a===`{`?yk(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(a)?vk(e,t,n):{part:X.literal(`$`),endIndex:i}}function Sk(e,t){let n=[],r=0,i=``,a=()=>{i&&=(n.push(X.literal(i)),``)};for(;r<t.length;){let o=t[r];if(o===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`"`||e===`\\`){i+=e,r+=2;continue}i+=o,r++;continue}if(o===`$`){a();let{part:i,endIndex:o}=xk(e,t,r,!0);i&&n.push(i),r=o;continue}if(o==="`"){a();let{part:i,endIndex:o}=e.parseBacktickSubstitution(t,r,!0);n.push(i),r=o;continue}i+=o,r++}return a(),n}function Ck(e,t,n){let r=[],i=n,a=``,o=()=>{a&&=(r.push(X.literal(a)),``)};for(;i<t.length&&t[i]!==`"`;){let n=t[i];if(n===`\\`&&i+1<t.length){let e=t[i+1];if(`"\\$\`
889
889
  `.includes(e)){a+=e,i+=2;continue}a+=n,i++;continue}if(n===`$`){o();let{part:n,endIndex:a}=xk(e,t,i,!0);n&&r.push(n),i=a;continue}if(n==="`"){o();let{part:n,endIndex:a}=e.parseBacktickSubstitution(t,i,!0);r.push(n),i=a;continue}a+=n,i++}return o(),{part:X.doubleQuoted(r),endIndex:i}}function wk(e,t,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!0){if(r)return[X.singleQuoted(t)];if(n){let n=Sk(e,t);return[X.doubleQuoted(n)]}if(t.length>=2&&t[0]===`"`&&t[t.length-1]===`"`){let n=t.slice(1,-1),r=!1;for(let e=0;e<n.length;e++){if(n[e]===`"`){r=!0;break}n[e]===`\\`&&e+1<n.length&&e++}if(!r){let t=Sk(e,n);return[X.doubleQuoted(t)]}}let d=[],f=0,p=``,m=()=>{p&&=(d.push(X.literal(p)),``)};for(;f<t.length;){let n=t[f];if(n===`\\`&&f+1<t.length){let e=t[f+1];if(c){m(),d.push(X.escaped(e)),f+=2;continue}if(!a&&!o){e!==`
890
890
  `&&(m(),d.push(X.escaped(e))),f+=2;continue}let n=a?e===`$`||e==="`"||e===`
891
891
  `:e===`$`||e==="`"||e===`"`||e===`'`||e===`
@@ -911,27 +911,27 @@ ${t}
911
911
  esac${qk(e.redirections)}`}function tA(e){let t=e.patterns.map(Pk).join(` | `),n=Jk(e.body);return n?`${t})
912
912
  ${n}
913
913
  ${e.terminator}`:`${t})
914
- ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}function rA(e){return`{ ${Jk(e.body)}; }${qk(e.redirections)}`}function iA(e){return`((${sA(e.expression.expression)}))${qk(e.redirections)}`}function aA(e){return`[[ ${cA(e.expression)} ]]${qk(e.redirections)}`}function oA(e){let t=jk(e.body);return`${e.name}() ${t}${qk(e.redirections)}`}function sA(e){switch(e.type){case`ArithNumber`:return String(e.value);case`ArithVariable`:return e.hasDollarPrefix?`$${e.name}`:e.name;case`ArithSpecialVar`:return`$${e.name}`;case`ArithBinary`:return`${sA(e.left)} ${e.operator} ${sA(e.right)}`;case`ArithUnary`:return e.prefix?`${e.operator}${sA(e.operand)}`:`${sA(e.operand)}${e.operator}`;case`ArithTernary`:return`${sA(e.condition)} ? ${sA(e.consequent)} : ${sA(e.alternate)}`;case`ArithAssignment`:return`${e.subscript?`${e.variable}[${sA(e.subscript)}]`:e.stringKey===void 0?e.variable:`${e.variable}[${e.stringKey}]`} ${e.operator} ${sA(e.value)}`;case`ArithDynamicAssignment`:return`${e.subscript?`${sA(e.target)}[${sA(e.subscript)}]`:sA(e.target)} ${e.operator} ${sA(e.value)}`;case`ArithDynamicElement`:return`${sA(e.nameExpr)}[${sA(e.subscript)}]`;case`ArithGroup`:return`(${sA(e.expression)})`;case`ArithNested`:return`$((${sA(e.expression)}))`;case`ArithCommandSubst`:return`$(${e.command})`;case`ArithBracedExpansion`:return`\${${e.content}}`;case`ArithArrayElement`:return e.stringKey===void 0?e.index?`${e.array}[${sA(e.index)}]`:e.array:`${e.array}[${e.stringKey}]`;case`ArithDynamicBase`:return`\${${e.baseExpr}}#${e.value}`;case`ArithDynamicNumber`:return`\${${e.prefix}}${e.suffix}`;case`ArithConcat`:return e.parts.map(sA).join(``);case`ArithDoubleSubscript`:return`${e.array}[${sA(e.index)}]`;case`ArithNumberSubscript`:return`${e.number}[${e.errorToken}]`;case`ArithSyntaxError`:return e.errorToken;case`ArithSingleQuote`:return`'${e.content}'`;default:throw Error(`Unsupported arithmetic expression type: ${e.type}`)}}function cA(e){switch(e.type){case`CondBinary`:return`${Pk(e.left)} ${e.operator} ${Pk(e.right)}`;case`CondUnary`:return`${e.operator} ${Pk(e.operand)}`;case`CondNot`:return`! ${cA(e.operand)}`;case`CondAnd`:return`${cA(e.left)} && ${cA(e.right)}`;case`CondOr`:return`${cA(e.left)} || ${cA(e.right)}`;case`CondGroup`:return`( ${cA(e.expression)} )`;case`CondWord`:return Pk(e.word);default:throw Error(`Unsupported conditional expression type: ${e.type}`)}}j();var lA=`BASH_ALIAS_`;function uA(e,t,n,r){let i=O(t);if(i>n-r.value)throw new A(`alias expansion exceeds string length limit (${n} bytes)`,`string_length`);return r.value+=i,e+t}function dA(e){return e.parts.length===1&&e.parts[0].type===`Literal`}function fA(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type===`Literal`?t.value:null}function pA(e,t){return e.env.get(`${lA}${t}`)}function mA(e,t,n){return hA(e,t,n)}function hA(e,t,n,r=!0){if(!t.name||!dA(t.name))return t;let i=fA(t.name);if(!i)return t;let a=pA(e,i);if(!a||n.has(i))return t;try{n.add(i);let o=new Tk,s={value:0},c=uA(``,a,e.limits.maxStringLength,s),l=a.endsWith(` `);if(!l)for(let n of t.args){let t=Pk(n);c=uA(c,` ${t}`,e.limits.maxStringLength,s)}let u;try{u=o.parse(c)}catch(e){if(e instanceof QD)throw e;return t}if(u.statements.length!==1||u.statements[0].pipelines.length!==1||u.statements[0].pipelines[0].commands.length!==1)return gA(e,t,a);let d=u.statements[0].pipelines[0].commands[0];if(d.type!==`SimpleCommand`)return gA(e,t,a);let f={...d,assignments:[...t.assignments,...d.assignments],redirections:[...d.redirections,...t.redirections],line:t.line};if(l&&t.args.length>0){f={...f,args:[...f.args,...t.args]};let i=1;for(;r&&f.args.length>0;){let t=f.args[0];if(!dA(t))break;let r=fA(t),a=r?pA(e,r):null;if(!a)break;if(i>=e.limits.maxCallDepth)throw new A(`alias expansion depth limit exceeded (${e.limits.maxCallDepth})`,`recursion`);i++;let o={type:`SimpleCommand`,name:t,args:f.args.slice(1),assignments:[],redirections:[]},s=hA(e,o,n,!1);if(s===o||(f={...f,name:s.name,args:[...s.args]},!a.endsWith(` `)))break}}return f}catch(e){throw n.delete(i),e}}function gA(e,t,n){let r={value:0},i=uA(``,n,e.limits.maxStringLength,r);for(let n of t.args){let t=Pk(n);i=uA(i,` ${t}`,e.limits.maxStringLength,r)}let a=new Tk,o=a.parseWordFromString(`eval`,!1,!1),s=0;for(let e of i)e===`'`&&s++;if(r.value+2+s*3>e.limits.maxStringLength)throw new A(`alias expansion exceeds string length limit (${e.limits.maxStringLength} bytes)`,`string_length`);return{type:`SimpleCommand`,name:o,args:[a.parseWordFromString(`'${i.replace(/'/g,`'\\''`)}'`,!1,!1)],assignments:t.assignments,redirections:t.redirections,line:t.line}}j(),j(),mc(),qr(),mc();var _A=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 vA(e){return _A.get(e)??``}function yA(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`[`){for(n+=i,r++,r<e.length&&(e[r]===`!`||e[r]===`^`)&&(n+=e[r],r++),r<e.length&&e[r]===`]`&&(n+=e[r],r++);r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){n+=e.slice(r,t+2),r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]===`]`&&(n+=e[r],r++)}else i===`:`?(n!==``&&t.push(n),n=``,r++):i===`\\`&&r+1<e.length?(n+=i+e[r+1],r+=2):(n+=i,r++)}return n!==``&&t.push(n),t}function bA(e){let t=`^`;for(let n=0;n<e.length;n++){let r=e[n];if(r===`*`)t+=`[^/]*`;else if(r===`?`)t+=`[^/]`;else if(r===`[`){let r=n+1,i=`[`;r<e.length&&(e[r]===`^`||e[r]===`!`)&&(i+=`^`,r++),r<e.length&&e[r]===`]`&&(i+=`\\]`,r++);let a=r;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=r;for(;r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){let n=vA(e.slice(r+2,t));i+=n,r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){i+=`\\${e[r+1]}`,r+=2;continue}if(e[r]===`-`){let e=r===o,t=r+1===a;i+=e||t?`\\-`:`-`}else i+=e[r];r++}i+=`]`,t+=i,n=r}else if(r===`\\`&&n+1<e.length){let r=e[n+1];/[.+^${}()|\\*?[\]]/.test(r)?t+=`\\${r}`:t+=r,n++}else/[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+=`$`,U(t)}function xA(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function SA(e){let t=[],n=``,r=0,i=!1,a=0;for(;a<e.length;){let o=e[a];if(o===`'`&&!i){i=!0,n+=`\0QUOTE_START\0`,a++;continue}if(o===`'`&&i){i=!1,n+=`\0QUOTE_END\0`,a++;continue}if(i){n+=o,a++;continue}if(o===`\\`){n+=o,a+1<e.length?(n+=e[a+1],a+=2):a++;continue}o===`(`?(r++,n+=o):o===`)`?(r--,n+=o):o===`|`&&r===0?(t.push(n),n=``):n+=o,a++}return t.push(n),t}var CA=5,wA=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;consumeOperation;constructor(e,t,n,r){this.fs=e,this.cwd=t,typeof r==`boolean`?(this.globstar=r,this.maxOps=1e5):r?(this.globstar=r.globstar??!1,this.nullglob=r.nullglob??!1,this.failglob=r.failglob??!1,this.dotglob=r.dotglob??!1,this.extglob=r.extglob??!1,this.globskipdots=r.globskipdots??!0,this.maxOps=r.maxGlobOperations??1e5,this.consumeOperation=r.consumeOperation):this.maxOps=1e5;let i=n?.get(`GLOBIGNORE`);i!==void 0&&i!==``&&(this.hasGlobignore=!0,this.globignorePatterns=yA(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new A(`Glob operation limit exceeded (${this.maxOps})`,`glob_operations`);this.consumeOperation?.()}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(e=>{let t=e.split(`/`).pop()||e;if((this.hasGlobignore||this.globskipdots)&&(t===`.`||t===`..`))return!1;if(this.hasGlobignore){for(let t of this.globignorePatterns)if(this.matchGlobignorePattern(e,t))return!1}return!0})}matchGlobignorePattern(e,t){return bA(t).test(e)}isGlobPattern(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,t){let n=e.map((e,n)=>(t?.[n]??!1)||!this.isGlobPattern(e)?null:this.expand(e)),r=await Promise.all(n.map(e=>e||Promise.resolve(null))),i=[];for(let t=0;t<e.length;t++){let n=r[t];n===null?i.push(e[t]):n.length>0?i.push(...n):i.push(e[t])}return i}async expand(e){if(this.globstar){let t=e.split(`/`),n=0;for(let e of t)if(e===`**`&&(n++,n>CA))throw new A(`Glob pattern has too many ** segments (max ${CA})`,`glob_operations`)}let t;if(e.includes(`**`)&&this.globstar&&this.isGlobstarValid(e))t=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,`*`);t=await this.expandSimple(n)}return this.filterGlobignore(t)}isGlobstarValid(e){let t=e.split(`/`);for(let e of t)if(e.includes(`**`)&&e!==`**`)return!1;return!0}hasGlobChars(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e!==``),r=-1;for(let e=0;e<n.length;e++)if(this.hasGlobChars(n[e])){r=e;break}if(r===-1)return[e];let i,a;if(r===0)t?(i=`/`,a=`/`):(i=this.cwd,a=``);else{let e=n.slice(0,r);t?(i=`/${e.join(`/`)}`,a=`/${e.join(`/`)}`):(i=this.fs.resolvePath(this.cwd,e.join(`/`)),a=e.join(`/`))}let o=n.slice(r);return(await this.expandSegments(i,a,o)).sort()}async expandSegments(e,t,n){if(this.checkOpsLimit(),n.length===0)return[t];let[r,...i]=n,a=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let n=await this.fs.readdirWithFileTypes(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;if(r.startsWith(`.`)||this.dotglob){let e=n.some(e=>e.name===`.`),t=n.some(e=>e.name===`..`);e||s.push({name:`.`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}),t||s.push({name:`..`,isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let n of s)if(!(n.name.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n.name,r)){let r=e===`/`?`/${n.name}`:`${e}/${n.name}`,a;a=t===``?n.name:t===`/`?`/${n.name}`:`${t}/${n.name}`,i.length===0?o.push(Promise.resolve([a])):n.isDirectory&&o.push(this.expandSegments(r,a,i))}let l=await Promise.all(o);for(let e of l)a.push(...e)}else{this.checkOpsLimit();let n=await this.fs.readdir(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;(r.startsWith(`.`)||this.dotglob)&&(n.includes(`.`)||s.push(`.`),n.includes(`..`)||s.push(`..`));for(let n of s)if(!(n.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n,r)){let r=e===`/`?`/${n}`:`${e}/${n}`,a;a=t===``?n:t===`/`?`/${n}`:`${t}/${n}`,i.length===0?o.push(Promise.resolve([a])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory)return this.expandSegments(r,a,i)}catch(e){if(e instanceof A)throw e}return[]})())}let l=await Promise.all(o);for(let e of l)a.push(...e)}}catch(e){if(e instanceof A)throw e}return a}async expandRecursive(e){let t=[],n=e.indexOf(`**`),r=e.slice(0,n).replace(/\/$/,``)||`.`,i=e.slice(n+2).replace(/^\//,``);return i.includes(`**`)&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(r,i,t),[...new Set(t)].sort()):(await this.walkDirectory(r,i,t),t.sort())}async walkDirectoryMultiGlobstar(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(r):null;if(i){let r=[];for(let t of i){let n=e===`.`?t.name:`${e}/${t.name}`;t.isDirectory&&r.push(n)}let a=e===`.`?t:`${e}/${t}`,o=await this.expandRecursive(a);n.push(...o);for(let e=0;e<r.length;e+=100){let i=r.slice(e,e+100);await Promise.all(i.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t of i){let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory&&a.push(n)}catch(e){if(e instanceof A)throw e}}let o=e===`.`?t:`${e}/${t}`,s=await this.expandRecursive(o);n.push(...s);for(let e=0;e<a.length;e+=100){let r=a.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}}catch(e){if(e instanceof A)throw e}}async walkDirectory(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(r),a=[],o=[];for(let n of i){let r=e===`.`?n.name:`${e}/${n.name}`;n.isDirectory?o.push(r):t&&this.matchPattern(n.name,t)&&a.push(r)}n.push(...a);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t=0;t<i.length;t+=100){let n=i.slice(t,t+100),r=await Promise.all(n.map(async t=>{let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{return this.checkOpsLimit(),{name:t,path:n,isDirectory:(await this.fs.stat(r)).isDirectory}}catch(e){if(e instanceof A)throw e;return null}}));a.push(...r.filter(e=>e!==null))}for(let e of a)!e.isDirectory&&t&&this.matchPattern(e.name,t)&&n.push(e.path);let o=a.filter(e=>e.isDirectory);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e.path,t,n)))}}}catch(e){if(e instanceof A)throw e}}matchPattern(e,t){return this.patternToRegex(t).test(e)}patternToRegex(e){return U(`^${this.patternToRegexStr(e)}$`)}patternToRegexStr(e){let t=``,n=!1;for(let r=0;r<e.length;r++){if(e.slice(r,r+13)===`\0QUOTE_START\0`){n=!0,r+=12;continue}if(e.slice(r,r+11)===`\0QUOTE_END\0`){n=!1,r+=10;continue}let i=e[r];if(n){/[.+^${}()|\\*?[\]]/.test(i)?t+=`\\${i}`:t+=i;continue}if(this.extglob&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let n=xA(e,r+1);if(n!==-1){let a=SA(e.slice(r+2,n)),o=a.map(e=>this.patternToRegexStr(e)),s=o.length>0?o.join(`|`):`(?:)`;if(i===`@`)t+=`(?:${s})`;else if(i===`*`)t+=`(?:${s})*`;else if(i===`+`)t+=`(?:${s})+`;else if(i===`?`)t+=`(?:${s})?`;else if(i===`!`)if(n<e.length-1){let e=a.map(e=>this.computePatternLength(e));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let n=e[0];if(n===0)t+=`(?:.+)`;else{let e=[];n>0&&e.push(`.{0,${n-1}}`),e.push(`.{${n+1},}`),e.push(`(?!(?:${s})).{${n}}`),t+=`(?:${e.join(`|`)})`}}else t+=`(?:(?!(?:${s})).)*?`}else t+=`(?!(?:${s})$).*`;r=n;continue}}if(i===`*`)t+=`.*`;else if(i===`?`)t+=`.`;else if(i===`[`){let n=r+1,i=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(i+=`^`,n++),n<e.length&&e[n]===`]`&&(i+=`\\]`,n++);let a=n;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=n;for(;n<e.length&&e[n]!==`]`;){if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=vA(e.slice(n+2,t));i+=r,n=t+2;continue}}if(e[n]===`\\`&&n+1<e.length){i+=`\\${e[n+1]}`,n+=2;continue}if(e[n]===`-`){let e=n===o,t=n+1===a;i+=e||t?`\\-`:`-`}else i+=e[n];n++}i+=`]`,t+=i,r=n}else if(i===`\\`&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\*?[\]]/.test(n)?t+=`\\${n}`:t+=n,r++}else/[.+^${}()|]/.test(i)?t+=`\\${i}`:t+=i}return t}computePatternLength(e){let t=0,n=0,r=!1;for(;n<e.length;){if(e.slice(n,n+13)===`\0QUOTE_START\0`){r=!0,n+=13;continue}if(e.slice(n,n+11)===`\0QUOTE_END\0`){r=!1,n+=11;continue}let i=e[n];if(r){t+=1,n++;continue}if((i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&n+1<e.length&&e[n+1]===`(`){let r=xA(e,n+1);if(r!==-1){if(i===`@`){let i=SA(e.slice(n+2,r)).map(e=>this.computePatternLength(e));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){t+=i[0],n=r+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){t+=1,n++;continue}if(i===`[`){let r=e.indexOf(`]`,n+1);if(r!==-1){t+=1,n=r+1;continue}t+=1,n++;continue}if(i===`\\`){t+=1,n+=2;continue}t+=1,n++}return t}};j();function TA(e){for(let t=0;t<e.length;t++){if(e[t]===`\\`){t++;continue}if(e[t]===`$`){let n=e[t+1];if(n===`{`||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function EA(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n)return!1;for(let e of n)if(e.type===`DoubleQuoted`||e.type===`SingleQuoted`)return!0;return!1}function DA(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n||n.length===0)return!1;for(let e of n)if(e.type!==`DoubleQuoted`&&e.type!==`SingleQuoted`)return!1;return!0}function OA(e){let t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1;for(let c of e){if((c.type===`SingleQuoted`||c.type===`DoubleQuoted`)&&(t=!0,c.type===`DoubleQuoted`))for(let e of c.parts)e.type===`ParameterExpansion`&&(e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!e.operation||e.operation.type===`PatternRemoval`||e.operation.type===`PatternReplacement`)&&(i=!0),(e.operation?.type===`VarNamePrefix`||e.operation?.type===`ArrayKeys`)&&(o=!0),e.operation?.type===`Indirection`&&(s=!0));c.type===`CommandSubstitution`&&(n=!0),c.type===`ParameterExpansion`&&(a=!0,(c.parameter===`@`||c.parameter===`*`)&&(r=!0),EA(c)&&(t=!0),(c.operation?.type===`VarNamePrefix`||c.operation?.type===`ArrayKeys`)&&(o=!0),c.operation?.type===`Indirection`&&(s=!0)),c.type===`Glob`&&TA(c.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:i,hasParamExpansion:a,hasVarNamePrefixExpansion:o,hasIndirection:s}}j(),j();var kA=`
914
+ ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}function rA(e){return`{ ${Jk(e.body)}; }${qk(e.redirections)}`}function iA(e){return`((${sA(e.expression.expression)}))${qk(e.redirections)}`}function aA(e){return`[[ ${cA(e.expression)} ]]${qk(e.redirections)}`}function oA(e){let t=jk(e.body);return`${e.name}() ${t}${qk(e.redirections)}`}function sA(e){switch(e.type){case`ArithNumber`:return String(e.value);case`ArithVariable`:return e.hasDollarPrefix?`$${e.name}`:e.name;case`ArithSpecialVar`:return`$${e.name}`;case`ArithBinary`:return`${sA(e.left)} ${e.operator} ${sA(e.right)}`;case`ArithUnary`:return e.prefix?`${e.operator}${sA(e.operand)}`:`${sA(e.operand)}${e.operator}`;case`ArithTernary`:return`${sA(e.condition)} ? ${sA(e.consequent)} : ${sA(e.alternate)}`;case`ArithAssignment`:return`${e.subscript?`${e.variable}[${sA(e.subscript)}]`:e.stringKey===void 0?e.variable:`${e.variable}[${e.stringKey}]`} ${e.operator} ${sA(e.value)}`;case`ArithDynamicAssignment`:return`${e.subscript?`${sA(e.target)}[${sA(e.subscript)}]`:sA(e.target)} ${e.operator} ${sA(e.value)}`;case`ArithDynamicElement`:return`${sA(e.nameExpr)}[${sA(e.subscript)}]`;case`ArithGroup`:return`(${sA(e.expression)})`;case`ArithNested`:return`$((${sA(e.expression)}))`;case`ArithCommandSubst`:return`$(${e.command})`;case`ArithBracedExpansion`:return`\${${e.content}}`;case`ArithArrayElement`:return e.stringKey===void 0?e.index?`${e.array}[${sA(e.index)}]`:e.array:`${e.array}[${e.stringKey}]`;case`ArithDynamicBase`:return`\${${e.baseExpr}}#${e.value}`;case`ArithDynamicNumber`:return`\${${e.prefix}}${e.suffix}`;case`ArithConcat`:return e.parts.map(sA).join(``);case`ArithDoubleSubscript`:return`${e.array}[${sA(e.index)}]`;case`ArithNumberSubscript`:return`${e.number}[${e.errorToken}]`;case`ArithSyntaxError`:return e.errorToken;case`ArithSingleQuote`:return`'${e.content}'`;default:throw Error(`Unsupported arithmetic expression type: ${e.type}`)}}function cA(e){switch(e.type){case`CondBinary`:return`${Pk(e.left)} ${e.operator} ${Pk(e.right)}`;case`CondUnary`:return`${e.operator} ${Pk(e.operand)}`;case`CondNot`:return`! ${cA(e.operand)}`;case`CondAnd`:return`${cA(e.left)} && ${cA(e.right)}`;case`CondOr`:return`${cA(e.left)} || ${cA(e.right)}`;case`CondGroup`:return`( ${cA(e.expression)} )`;case`CondWord`:return Pk(e.word);default:throw Error(`Unsupported conditional expression type: ${e.type}`)}}j();var lA=`BASH_ALIAS_`;function uA(e,t,n,r){let i=O(t);if(i>n-r.value)throw new A(`alias expansion exceeds string length limit (${n} bytes)`,`string_length`);return r.value+=i,e+t}function dA(e){return e.parts.length===1&&e.parts[0].type===`Literal`}function fA(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type===`Literal`?t.value:null}function pA(e,t){return e.env.get(`${lA}${t}`)}function mA(e,t,n){return hA(e,t,n)}function hA(e,t,n,r=!0){if(!t.name||!dA(t.name))return t;let i=fA(t.name);if(!i)return t;let a=pA(e,i);if(!a||n.has(i))return t;try{n.add(i);let o=new Tk,s={value:0},c=uA(``,a,e.limits.maxStringLength,s),l=a.endsWith(` `);if(!l)for(let n of t.args){let t=Pk(n);c=uA(c,` ${t}`,e.limits.maxStringLength,s)}let u;try{u=o.parse(c)}catch(e){if(e instanceof QD)throw e;return t}if(u.statements.length!==1||u.statements[0].pipelines.length!==1||u.statements[0].pipelines[0].commands.length!==1)return gA(e,t,a);let d=u.statements[0].pipelines[0].commands[0];if(d.type!==`SimpleCommand`)return gA(e,t,a);let f={...d,assignments:[...t.assignments,...d.assignments],redirections:[...d.redirections,...t.redirections],line:t.line};if(l&&t.args.length>0){f={...f,args:[...f.args,...t.args]};let i=1;for(;r&&f.args.length>0;){let t=f.args[0];if(!dA(t))break;let r=fA(t),a=r?pA(e,r):null;if(!a)break;if(i>=e.limits.maxCallDepth)throw new A(`alias expansion depth limit exceeded (${e.limits.maxCallDepth})`,`recursion`);i++;let o={type:`SimpleCommand`,name:t,args:f.args.slice(1),assignments:[],redirections:[]},s=hA(e,o,n,!1);if(s===o||(f={...f,name:s.name,args:[...s.args]},!a.endsWith(` `)))break}}return f}catch(e){throw n.delete(i),e}}function gA(e,t,n){let r={value:0},i=uA(``,n,e.limits.maxStringLength,r);for(let n of t.args){let t=Pk(n);i=uA(i,` ${t}`,e.limits.maxStringLength,r)}let a=new Tk,o=a.parseWordFromString(`eval`,!1,!1),s=0;for(let e of i)e===`'`&&s++;if(r.value+2+s*3>e.limits.maxStringLength)throw new A(`alias expansion exceeds string length limit (${e.limits.maxStringLength} bytes)`,`string_length`);return{type:`SimpleCommand`,name:o,args:[a.parseWordFromString(`'${i.replace(/'/g,`'\\''`)}'`,!1,!1)],assignments:t.assignments,redirections:t.redirections,line:t.line}}j(),j(),mc(),qr(),mc();var _A=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 vA(e){return _A.get(e)??``}function yA(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`[`){for(n+=i,r++,r<e.length&&(e[r]===`!`||e[r]===`^`)&&(n+=e[r],r++),r<e.length&&e[r]===`]`&&(n+=e[r],r++);r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){n+=e.slice(r,t+2),r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]===`]`&&(n+=e[r],r++)}else i===`:`?(n!==``&&t.push(n),n=``,r++):i===`\\`&&r+1<e.length?(n+=i+e[r+1],r+=2):(n+=i,r++)}return n!==``&&t.push(n),t}function bA(e){let t=`^`;for(let n=0;n<e.length;n++){let r=e[n];if(r===`*`)t+=`[^/]*`;else if(r===`?`)t+=`[^/]`;else if(r===`[`){let r=n+1,i=`[`;r<e.length&&(e[r]===`^`||e[r]===`!`)&&(i+=`^`,r++),r<e.length&&e[r]===`]`&&(i+=`\\]`,r++);let a=r;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=r;for(;r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){let n=vA(e.slice(r+2,t));i+=n,r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){i+=`\\${e[r+1]}`,r+=2;continue}if(e[r]===`-`){let e=r===o,t=r+1===a;i+=e||t?`\\-`:`-`}else i+=e[r];r++}i+=`]`,t+=i,n=r}else if(r===`\\`&&n+1<e.length){let r=e[n+1];/[.+^${}()|\\*?[\]]/.test(r)?t+=`\\${r}`:t+=r,n++}else/[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+=`$`,U(t)}function xA(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function SA(e){let t=[],n=``,r=0,i=!1,a=0;for(;a<e.length;){let o=e[a];if(o===`'`&&!i){i=!0,n+=`\0QUOTE_START\0`,a++;continue}if(o===`'`&&i){i=!1,n+=`\0QUOTE_END\0`,a++;continue}if(i){n+=o,a++;continue}if(o===`\\`){n+=o,a+1<e.length?(n+=e[a+1],a+=2):a++;continue}o===`(`?(r++,n+=o):o===`)`?(r--,n+=o):o===`|`&&r===0?(t.push(n),n=``):n+=o,a++}return t.push(n),t}var CA=5,wA=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;consumeOperation;constructor(e,t,n,r){this.fs=e,this.cwd=t,typeof r==`boolean`?(this.globstar=r,this.maxOps=1e5):r?(this.globstar=r.globstar??!1,this.nullglob=r.nullglob??!1,this.failglob=r.failglob??!1,this.dotglob=r.dotglob??!1,this.extglob=r.extglob??!1,this.globskipdots=r.globskipdots??!0,this.maxOps=r.maxGlobOperations??1e5,this.consumeOperation=r.consumeOperation):this.maxOps=1e5;let i=n?.get(`GLOBIGNORE`);i!==void 0&&i!==``&&(this.hasGlobignore=!0,this.globignorePatterns=yA(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new A(`Glob operation limit exceeded (${this.maxOps})`,`glob_operations`);this.consumeOperation?.()}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(e=>{let t=e.split(`/`).pop()||e;if((this.hasGlobignore||this.globskipdots)&&(t===`.`||t===`..`))return!1;if(this.hasGlobignore){for(let t of this.globignorePatterns)if(this.matchGlobignorePattern(e,t))return!1}return!0})}matchGlobignorePattern(e,t){return bA(t).test(e)}isGlobPattern(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,t){let n=e.map((e,n)=>(t?.[n]??!1)||!this.isGlobPattern(e)?null:this.expand(e)),r=await Promise.all(n.map(e=>e||Promise.resolve(null))),i=[];for(let t=0;t<e.length;t++){let n=r[t];n===null?i.push(e[t]):n.length>0?i.push(...n):i.push(e[t])}return i}async expand(e){if(this.globstar){let t=e.split(`/`),n=0;for(let e of t)if(e===`**`&&(n++,n>CA))throw new A(`Glob pattern has too many ** segments (max ${CA})`,`glob_operations`)}let t;if(e.includes(`**`)&&this.globstar&&this.isGlobstarValid(e))t=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,`*`);t=await this.expandSimple(n)}return this.filterGlobignore(t)}isGlobstarValid(e){let t=e.split(`/`);for(let e of t)if(e.includes(`**`)&&e!==`**`)return!1;return!0}hasGlobChars(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e!==``),r=-1;for(let e=0;e<n.length;e++)if(this.hasGlobChars(n[e])){r=e;break}if(r===-1)return[e];let i,a;if(r===0)t?(i=`/`,a=`/`):(i=this.cwd,a=``);else{let e=n.slice(0,r);t?(i=`/${e.join(`/`)}`,a=`/${e.join(`/`)}`):(i=this.fs.resolvePath(this.cwd,e.join(`/`)),a=e.join(`/`))}let o=n.slice(r);return(await this.expandSegments(i,a,o)).sort()}async expandSegments(e,t,n){if(this.checkOpsLimit(),n.length===0)return[t];let[r,...i]=n,a=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let n=await this.fs.readdirWithFileTypes(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;if(r.startsWith(`.`)||this.dotglob){let e=n.some(e=>e.name===`.`),t=n.some(e=>e.name===`..`);e||s.push({name:`.`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}),t||s.push({name:`..`,isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let n of s)if(!(n.name.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n.name,r)){let r=e===`/`?`/${n.name}`:`${e}/${n.name}`,a;a=t===``?n.name:t===`/`?`/${n.name}`:`${t}/${n.name}`,i.length===0?o.push(Promise.resolve([a])):n.isDirectory&&o.push(this.expandSegments(r,a,i))}let l=await Promise.all(o);for(let e of l)a.push(...e)}else{this.checkOpsLimit();let n=await this.fs.readdir(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;(r.startsWith(`.`)||this.dotglob)&&(n.includes(`.`)||s.push(`.`),n.includes(`..`)||s.push(`..`));for(let n of s)if(!(n.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n,r)){let r=e===`/`?`/${n}`:`${e}/${n}`,a;a=t===``?n:t===`/`?`/${n}`:`${t}/${n}`,i.length===0?o.push(Promise.resolve([a])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory)return this.expandSegments(r,a,i)}catch(e){if(e instanceof A)throw e}return[]})())}let l=await Promise.all(o);for(let e of l)a.push(...e)}}catch(e){if(e instanceof A)throw e}return a}async expandRecursive(e){let t=[],n=e.indexOf(`**`),r=e.slice(0,n).replace(/\/$/,``)||`.`,i=e.slice(n+2).replace(/^\//,``);return i.includes(`**`)&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(r,i,t),[...new Set(t)].sort()):(await this.walkDirectory(r,i,t),t.sort())}async walkDirectoryMultiGlobstar(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(r):null;if(i){let r=[];for(let t of i){let n=e===`.`?t.name:`${e}/${t.name}`;t.isDirectory&&r.push(n)}let a=e===`.`?t:`${e}/${t}`,o=await this.expandRecursive(a);n.push(...o);for(let e=0;e<r.length;e+=100){let i=r.slice(e,e+100);await Promise.all(i.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t of i){let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory&&a.push(n)}catch(e){if(e instanceof A)throw e}}let o=e===`.`?t:`${e}/${t}`,s=await this.expandRecursive(o);n.push(...s);for(let e=0;e<a.length;e+=100){let r=a.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}}catch(e){if(e instanceof A)throw e}}async walkDirectory(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(r),a=[],o=[];for(let n of i){let r=e===`.`?n.name:`${e}/${n.name}`;n.isDirectory?o.push(r):t&&this.matchPattern(n.name,t)&&a.push(r)}n.push(...a);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t=0;t<i.length;t+=100){let n=i.slice(t,t+100),r=await Promise.all(n.map(async t=>{let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{return this.checkOpsLimit(),{name:t,path:n,isDirectory:(await this.fs.stat(r)).isDirectory}}catch(e){if(e instanceof A)throw e;return null}}));a.push(...r.filter(e=>e!==null))}for(let e of a)!e.isDirectory&&t&&this.matchPattern(e.name,t)&&n.push(e.path);let o=a.filter(e=>e.isDirectory);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e.path,t,n)))}}}catch(e){if(e instanceof A)throw e}}matchPattern(e,t){return this.patternToRegex(t).test(e)}patternToRegex(e){return U(`^${this.patternToRegexStr(e)}$`)}patternToRegexStr(e){let t=``,n=!1;for(let r=0;r<e.length;r++){if(e.slice(r,r+13)===`\0QUOTE_START\0`){n=!0,r+=12;continue}if(e.slice(r,r+11)===`\0QUOTE_END\0`){n=!1,r+=10;continue}let i=e[r];if(n){/[.+^${}()|\\*?[\]]/.test(i)?t+=`\\${i}`:t+=i;continue}if(this.extglob&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let n=xA(e,r+1);if(n!==-1){let a=SA(e.slice(r+2,n)),o=a.map(e=>this.patternToRegexStr(e)),s=o.length>0?o.join(`|`):`(?:)`;if(i===`@`)t+=`(?:${s})`;else if(i===`*`)t+=`(?:${s})*`;else if(i===`+`)t+=`(?:${s})+`;else if(i===`?`)t+=`(?:${s})?`;else if(i===`!`){if(n<e.length-1){let e=a.map(e=>this.computePatternLength(e));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let n=e[0];if(n===0)t+=`(?:.+)`;else{let e=[];n>0&&e.push(`.{0,${n-1}}`),e.push(`.{${n+1},}`),e.push(`(?!(?:${s})).{${n}}`),t+=`(?:${e.join(`|`)})`}}else t+=`(?:(?!(?:${s})).)*?`}else t+=`(?!(?:${s})$).*`}r=n;continue}}if(i===`*`)t+=`.*`;else if(i===`?`)t+=`.`;else if(i===`[`){let n=r+1,i=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(i+=`^`,n++),n<e.length&&e[n]===`]`&&(i+=`\\]`,n++);let a=n;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=n;for(;n<e.length&&e[n]!==`]`;){if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=vA(e.slice(n+2,t));i+=r,n=t+2;continue}}if(e[n]===`\\`&&n+1<e.length){i+=`\\${e[n+1]}`,n+=2;continue}if(e[n]===`-`){let e=n===o,t=n+1===a;i+=e||t?`\\-`:`-`}else i+=e[n];n++}i+=`]`,t+=i,r=n}else if(i===`\\`&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\*?[\]]/.test(n)?t+=`\\${n}`:t+=n,r++}else/[.+^${}()|]/.test(i)?t+=`\\${i}`:t+=i}return t}computePatternLength(e){let t=0,n=0,r=!1;for(;n<e.length;){if(e.slice(n,n+13)===`\0QUOTE_START\0`){r=!0,n+=13;continue}if(e.slice(n,n+11)===`\0QUOTE_END\0`){r=!1,n+=11;continue}let i=e[n];if(r){t+=1,n++;continue}if((i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&n+1<e.length&&e[n+1]===`(`){let r=xA(e,n+1);if(r!==-1){if(i===`@`){let i=SA(e.slice(n+2,r)).map(e=>this.computePatternLength(e));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){t+=i[0],n=r+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){t+=1,n++;continue}if(i===`[`){let r=e.indexOf(`]`,n+1);if(r!==-1){t+=1,n=r+1;continue}t+=1,n++;continue}if(i===`\\`){t+=1,n+=2;continue}t+=1,n++}return t}};j();function TA(e){for(let t=0;t<e.length;t++){if(e[t]===`\\`){t++;continue}if(e[t]===`$`){let n=e[t+1];if(n===`{`||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function EA(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n)return!1;for(let e of n)if(e.type===`DoubleQuoted`||e.type===`SingleQuoted`)return!0;return!1}function DA(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n||n.length===0)return!1;for(let e of n)if(e.type!==`DoubleQuoted`&&e.type!==`SingleQuoted`)return!1;return!0}function OA(e){let t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1;for(let c of e){if((c.type===`SingleQuoted`||c.type===`DoubleQuoted`)&&(t=!0,c.type===`DoubleQuoted`))for(let e of c.parts)e.type===`ParameterExpansion`&&(e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!e.operation||e.operation.type===`PatternRemoval`||e.operation.type===`PatternReplacement`)&&(i=!0),(e.operation?.type===`VarNamePrefix`||e.operation?.type===`ArrayKeys`)&&(o=!0),e.operation?.type===`Indirection`&&(s=!0));c.type===`CommandSubstitution`&&(n=!0),c.type===`ParameterExpansion`&&(a=!0,(c.parameter===`@`||c.parameter===`*`)&&(r=!0),EA(c)&&(t=!0),(c.operation?.type===`VarNamePrefix`||c.operation?.type===`ArrayKeys`)&&(o=!0),c.operation?.type===`Indirection`&&(s=!0)),c.type===`Glob`&&TA(c.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:i,hasParamExpansion:a,hasVarNamePrefixExpansion:o,hasIndirection:s}}j(),j();var kA=`
915
915
  `;function AA(e,t){if(e>=t)throw new A(`array element limit exceeded (${t})`,`array_elements`)}function jA(e,t,n,r,i){AA(e.length,i),AA(t.length,i),e.push(n),t.push(r)}function MA(e){return e.get(`IFS`)??kA}function NA(e){return e.get(`IFS`)===``}function PA(e){let t=MA(e);if(t===``)return!0;for(let e of t)if(e!==` `&&e!==` `&&e!==`
916
916
  `)return!1;return!0}function FA(e){let t=!1,n=[];for(let r of e.split(``))r===`-`?t=!0:/[\\^$.*+?()[\]{}|]/.test(r)?n.push(`\\${r}`):r===` `?n.push(`\\t`):r===`
917
917
  `?n.push(`\\n`):n.push(r);return t&&n.push(`\\-`),n.join(``)}function IA(e){let t=e.get(`IFS`);return t===void 0?` `:t[0]||``}var LA=`
918
918
  `;function RA(e){return LA.includes(e)}function zA(e){let t=new Set,n=new Set;for(let r of e)RA(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function BA(e,t,n,r,i){if(t===``)return e===``?{words:[],wordStarts:[]}:(AA(0,n),{words:[e],wordStarts:[0]});let{whitespace:a,nonWhitespace:o}=zA(t),s=[],c=[],l=0;for(;l<e.length&&a.has(e[l]);)l++;if(l>=e.length)return{words:[],wordStarts:[]};if(o.has(e[l]))for(jA(s,c,``,l,n),l++;l<e.length&&a.has(e[l]);)l++;for(;l<e.length&&!(r!==void 0&&s.length>=r);){let t=l;for(;l<e.length;){let t=e[l];if(!i&&t===`\\`){l++,l<e.length&&l++;continue}if(a.has(t)||o.has(t))break;l++}if(jA(s,c,e.substring(t,l),t,n),l>=e.length)break;for(;l<e.length&&a.has(e[l]);)l++;if(l<e.length&&o.has(e[l])){for(l++;l<e.length&&a.has(e[l]);)l++;for(;l<e.length&&o.has(e[l])&&!(r!==void 0&&s.length>=r);)for(jA(s,c,``,l,n),l++;l<e.length&&a.has(e[l]);)l++}}return{words:s,wordStarts:c}}function VA(e,t,n){if(t===``)return e&&AA(0,n),{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e===``)return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:r,nonWhitespace:i}=zA(t),a=[],o=0,s=!1,c=!1,l=o;for(;o<e.length&&r.has(e[o]);)o++;if(o>l&&(s=!0),o>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(i.has(e[o]))for(AA(a.length,n),a.push(``),o++;o<e.length&&r.has(e[o]);)o++;for(;o<e.length;){let t=o;for(;o<e.length;){let t=e[o];if(r.has(t)||i.has(t))break;o++}if(AA(a.length,n),a.push(e.substring(t,o)),o>=e.length){c=!1;break}let s=o;for(;o<e.length&&r.has(e[o]);)o++;if(o<e.length&&i.has(e[o])){for(o++;o<e.length&&r.has(e[o]);)o++;for(;o<e.length&&i.has(e[o]);)for(AA(a.length,n),a.push(``),o++;o<e.length&&r.has(e[o]);)o++}o>=e.length&&o>s&&(c=!0)}return{words:a,hadLeadingDelimiter:s,hadTrailingDelimiter:c}}function HA(e,t,n){return VA(e,t,n).words}function UA(e,t){for(let n of e)if(t.has(n))return!0;return!1}function WA(e,t,n){if(t===``)return e;let{whitespace:r,nonWhitespace:i}=zA(t),a=e.length;for(;a>0&&r.has(e[a-1]);){if(!n&&a>=2){let t=0,n=a-2;for(;n>=0&&e[n]===`\\`;)t++,n--;if(t%2==1)break}a--}let o=e.substring(0,a);if(o.length>=1&&i.has(o[o.length-1])){if(!n&&o.length>=2){let e=0,t=o.length-2;for(;t>=0&&o[t]===`\\`;)e++,t--;if(e%2==1)return o}let e=o.substring(0,o.length-1);if(!UA(e,i))return e}return o}function GA(e,t){return e.state.namerefs?.has(t)??!1}function KA(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function qA(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function JA(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function YA(e,t){return e.state.invalidNamerefs?.has(t)??!1}function XA(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function ZA(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=iD(e,t),i=e.state.associativeArrays?.has(t)??!1;return r||i}return iD(e,t)?!0:e.state.env.has(t)}function QA(e,t,n=100){if(!GA(e,t)||YA(e,t))return t;let r=new Set,i=t;for(;n-->0;){if(r.has(i))return;if(r.add(i),!GA(e,i))return i;let t=e.state.env.get(i);if(t===void 0||t===``||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return i;i=t}}function $A(e,t){if(GA(e,t))return e.state.env.get(t)}function ej(e,t,n,r=100){if(!GA(e,t)||YA(e,t))return t;let i=new Set,a=t;for(;r-->0;){if(i.has(a))return;if(i.add(a),!GA(e,a))return a;let t=e.state.env.get(a);if(t===void 0||t===``)return n===void 0||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&ZA(e,n)?a:null;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return a;a=t}}function tj(e,t){let n=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(t,n)=>e.state.env.get(n)??``);return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(t,n)=>e.state.env.get(n)??``),n}function nj(e,t){return t===`FUNCNAME`?(e.state.funcNameStack??[]).map((e,t)=>[t,e]):t===`BASH_LINENO`?(e.state.callLineStack??[]).map((e,t)=>[t,String(e)]):t===`BASH_SOURCE`?(e.state.sourceStack??[]).map((e,t)=>[t,e]):e.state.associativeArrays?.has(t)?fD(e,t).map(n=>[n,aD(e,t,n)??``]):uD(e,t).map(n=>[n,aD(e,t,n)??``])}function rj(e,t){return t===`FUNCNAME`?(e.state.funcNameStack?.length??0)>0:t===`BASH_LINENO`?(e.state.callLineStack?.length??0)>0:t===`BASH_SOURCE`?(e.state.sourceStack?.length??0)>0:(e.state.associativeArrays?.has(t),iD(e,t))}async function ij(e,t,n=!0,r=!1){switch(t){case`?`:return String(e.state.lastExitCode);case`$`:return String(e.state.virtualPid);case`#`:return e.state.env.get(`#`)||`0`;case`@`:return e.state.env.get(`@`)||``;case`_`:return e.state.lastArg;case`-`:{let t=``;return t+=`h`,e.state.options.errexit&&(t+=`e`),e.state.options.noglob&&(t+=`f`),e.state.options.nounset&&(t+=`u`),e.state.options.verbose&&(t+=`v`),e.state.options.xtrace&&(t+=`x`),t+=`B`,e.state.options.noclobber&&(t+=`C`),t+=`s`,t}case`*`:{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t===0)return``;let n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return n.join(IA(e.state.env))}case`0`:return e.state.env.get(`0`)||`bash`;case`PWD`:return e.state.env.get(`PWD`)??``;case`OLDPWD`:return e.state.env.get(`OLDPWD`)??``;case`PPID`:return String(e.state.virtualPpid);case`UID`:return String(e.state.virtualUid);case`EUID`:return String(e.state.virtualUid);case`RANDOM`:return String(Math.floor(Math.random()*32768));case`SECONDS`:return String(Math.floor((Date.now()-e.state.startTime)/1e3));case`BASH_VERSION`:return GE;case`!`:return String(e.state.lastBackgroundPid);case`BASHPID`:return String(e.state.bashPid);case`LINENO`:return String(e.state.currentLine);case`FUNCNAME`:{let t=e.state.funcNameStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new Cr(`FUNCNAME`);return``}case`BASH_LINENO`:{let t=e.state.callLineStack?.[0];if(t!==void 0)return String(t);if(n&&e.state.options.nounset)throw new Cr(`BASH_LINENO`);return``}case`BASH_SOURCE`:{let t=e.state.sourceStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new Cr(`BASH_SOURCE`);return``}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new Er(`\${${t}}`);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let t=i[1],r=i[2];if(GA(e,t)){let n=QA(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return``;t=n}}if(r===`@`||r===`*`){let n=nj(e,t);if(n.length>0)return n.map(([,e])=>e).join(` `);let r=e.state.env.get(t);return r===void 0?``:r}if(t===`FUNCNAME`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.funcNameStack?.[t]??``:``}if(t===`BASH_LINENO`){let t=Number.parseInt(r,10);if(!Number.isNaN(t)&&t>=0){let n=e.state.callLineStack?.[t];return n===void 0?``:String(n)}return``}if(t===`BASH_SOURCE`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.sourceStack?.[t]??``:``}if(e.state.associativeArrays?.has(t)){let i=pD(r);i=tj(e,i);let a=aD(e,t,i);if(a===void 0&&n&&e.state.options.nounset)throw new Cr(`${t}[${r}]`);return a||``}let a;if(/^-?\d+$/.test(r))a=Number.parseInt(r,10);else try{a=await rP(e,sO(new Tk,r).expression)}catch{let t=e.state.env.get(r);a=t?Number.parseInt(t,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let n=nj(e,t),r=e.state.currentLine;if(n.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
919
919
  `,``;let i=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+a;return i<0?(e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
920
- `,``):aD(e,t,i)||``}let o=aD(e,t,a);if(o!==void 0)return o;if(a===0){let n=e.state.env.get(t);if(n!==void 0)return n}if(n&&e.state.options.nounset)throw new Cr(`${t}[${a}]`);return``}if(/^[1-9][0-9]*$/.test(t)){let r=e.state.env.get(t);if(r===void 0&&n&&e.state.options.nounset)throw new Cr(t);return r||``}if(GA(e,t)){let i=QA(e,t);if(i===void 0)return``;if(i!==t)return await ij(e,i,n,r);let a=e.state.env.get(t);if((a===void 0||a===``)&&n&&e.state.options.nounset)throw new Cr(t);return a||``}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(e=>e.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(rj(e,t)){let r=aD(e,t,0);if(r!==void 0)return r;if(n&&e.state.options.nounset)throw new Cr(t);return``}if(n&&e.state.options.nounset)throw new Cr(t);return``}async function aj(e,t){if(new Set([`?`,`$`,`#`,`_`,`-`,`0`,`PPID`,`UID`,`EUID`,`RANDOM`,`SECONDS`,`BASH_VERSION`,`!`,`BASHPID`,`LINENO`]).has(t))return!0;if(t===`@`||t===`*`)return Number.parseInt(e.state.env.get(`#`)||`0`,10)>0;if(t===`PWD`||t===`OLDPWD`)return e.state.env.has(t);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(GA(e,t)){let n=QA(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;t=n}}if(r===`@`||r===`*`)return nj(e,t).length>0||e.state.env.has(t);if(e.state.associativeArrays?.has(t)){let n=tj(e,pD(r));return oD(e,t,n)}let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else try{i=await rP(e,sO(new Tk,r).expression)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0,Number.isNaN(i)&&(i=0)}if(i<0){let n=nj(e,t);if(n.length===0)return!1;let r=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+i;return r<0?!1:oD(e,t,r)}return oD(e,t,i)}if(GA(e,t)){let n=QA(e,t);return n===void 0||n===t?e.state.env.has(t):aj(e,n)}return e.state.env.has(t)?!0:rj(e,t)?oD(e,t,0):!1}async function oj(e,t){let n=``,r=0;for(;r<t.length;){if(t[r]===`$`){if(t[r+1]===`{`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`{`?e++:t[i]===`}`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]===`(`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[0-9]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[0-9]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[*@#?\-!$]/.test(t[r+1]||``)){let i=t[r+1],a=await ij(e,i);n+=a,r+=2;continue}}if(t[r]===`"`){for(n+=`"`,r++;r<t.length&&t[r]!==`"`;)if(t[r]===`$`&&/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i}else t[r]===`\\`?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+=`"`,r++);continue}n+=t[r],r++}return n}async function sj(e,t){let n=t,r=t.startsWith(`"`)&&t.endsWith(`"`),i=t.startsWith(`'`)&&t.endsWith(`'`);if((r||i)&&(n=t.slice(1,-1)),i)return n;let a=``,o=0;for(;o<n.length;)if(n[o]===`$`)if(n[o+1]===`(`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`(`&&n[r-1]===`$`||n[r]===`(`?t++:n[r]===`)`&&t--,r++;let i=n.slice(o+2,r-1);if(e.execFn){let t=await e.execFn(i,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=r}else if(n[o+1]===`{`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`{`?t++:n[r]===`}`&&t--,r++;let i=await ij(e,n.slice(o+2,r-1));a+=i,o=r}else if(/[a-zA-Z_]/.test(n[o+1]||``)){let t=o+1;for(;t<n.length&&/[a-zA-Z0-9_]/.test(n[t]);)t++;let r=await ij(e,n.slice(o+1,t));a+=r,o=t}else a+=n[o],o++;else if(n[o]==="`"){let t=o+1;for(;t<n.length&&n[t]!=="`";)t++;let r=n.slice(o+1,t);if(e.execFn){let t=await e.execFn(r,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=t+1}else a+=n[o],o++;return a}Lr(),j();var cj=1e4,lj={maxResults:cj,maxStringBytes:10485760};function uj(e,t,n,r){if(e.length>=n.maxResults)return!1;let i=O(t);if(i>n.maxStringBytes-r.value)throw new A(`brace expansion string limit exceeded (${n.maxStringBytes} bytes)`,`string_length`);return e.push(t),r.value+=i,!0}function dj(e,t,n,r,i,a=lj){let o=n??1;o===0&&(o=1);let s=Math.abs(o),c=[],l=0;if(r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,``).length)),i?.match(/^-?0\d/)&&(l=Math.max(l,i.replace(/^-/,``).length)),l>a.maxStringBytes)throw new A(`brace expansion padding limit exceeded (${a.maxStringBytes} bytes)`,`string_length`);let u={value:0},d=e=>{if(l>0){let t=e<0,n=String(Math.abs(e)).padStart(l,`0`);return t?`-${n}`:n}return String(e)};if(e<=t)for(let n=e,r=0;n<=t&&r<cj&&uj(c,d(n),a,u);n+=s,r++);else for(let n=e,r=0;n>=t&&r<cj&&uj(c,d(n),a,u);n-=s,r++);return c}function fj(e,t,n,r=lj){let i=n??1;i===0&&(i=1);let a=e.charCodeAt(0),o=t.charCodeAt(0),s=Math.abs(i);if(e>=`A`&&e<=`Z`&&t>=`a`&&t<=`z`||e>=`a`&&e<=`z`&&t>=`A`&&t<=`Z`){let r=n===void 0?``:`..${n}`;throw new Or(`{${e}..${t}${r}}: invalid sequence`)}let c=[],l={value:0};if(a<=o)for(let e=a,t=0;e<=o&&t<cj&&uj(c,String.fromCharCode(e),r,l);e+=s,t++);else for(let e=a,t=0;e>=o&&t<cj&&uj(c,String.fromCharCode(e),r,l);e-=s,t++);return c}function pj(e,t,n,r,i,a=lj){let o=n===void 0?``:`..${n}`;return typeof e==`number`&&typeof t==`number`?{expanded:dj(e,t,n,r,i,a),literal:`{${e}..${t}${o}}`}:typeof e==`string`&&typeof t==`string`?{expanded:fj(e,t,n,a),literal:`{${e}..${t}${o}}`}:{expanded:null,literal:`{${e}..${t}${o}}`}}function mj(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!==`SimpleCommand`)return null;let i=r;if(i.name!==null||i.args.length!==0||i.assignments.length!==0||i.redirections.length!==1)return null;let a=i.redirections[0];return a.operator!==`<`||a.target.type!==`Word`?null:{target:a.target}}function hj(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function gj(e){let t=``,n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function _j(e){return e.replace(/([*?[\]\\()|])/g,`\\$1`)}function vj(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`)}mc(),j();function yj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function bj(e,t,n=!1){let r=``,i=0;for(;i<e.length;){let a=e[i];if(n&&(a===`@`||a===`*`||a===`+`||a===`?`||a===`!`)&&i+1<e.length&&e[i+1]===`(`){let o=xj(e,i+1);if(o!==-1){let s=Sj(e.slice(i+2,o)).map(e=>bj(e,t,n)),c=s.length>0?s.join(`|`):`(?:)`;a===`@`?r+=`(?:${c})`:a===`*`?r+=`(?:${c})*`:a===`+`?r+=`(?:${c})+`:a===`?`?r+=`(?:${c})?`:a===`!`&&(r+=`(?!(?:${c})$).*`),i=o+1;continue}}if(a===`\\`)if(i+1<e.length){let t=e[i+1];/[\\^$.|+(){}[\]*?]/.test(t)?r+=`\\${t}`:r+=t,i+=2}else r+=`\\\\`,i++;else if(a===`*`)r+=t?`.*`:`.*?`,i++;else if(a===`?`)r+=`.`,i++;else if(a===`[`){let t=Cj(e,i);if(t===-1)r+=`\\[`,i++;else{let n=e.slice(i+1,t);r+=wj(n),i=t+1}}else/[\^$.|+(){}]/.test(a)?(r+=`\\${a}`,i++):(r+=a,i++)}return r}function xj(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Sj(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function Cj(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){if(e[n]===`\\`&&n+1<e.length){n+=2;continue}if(e[n]===`]`)return n;if(e[n]===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}n++}return-1}function wj(e){let t=`[`,n=0;for((e[0]===`^`||e[0]===`!`)&&(t+=`^`,n++);n<e.length;){if(e[n]===`'`){let r=e.indexOf(`'`,n+1);if(r!==-1){let i=e.slice(n+1,r);for(let e of i)t+=e===`\\`?`\\\\`:e===`]`?`\\]`:e===`^`&&t===`[`?`\\^`:e;n=r+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r);t+=Ej(i),n=r+2;continue}}let r=e[n];r===`\\`?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+=`\\\\`,n++):r===`-`&&n>0&&n<e.length-1?(t+=`-`,n++):r===`^`&&n===0?(t+=`^`,n++):(t+=r===`]`&&n===0?`\\]`:r,n++)}return t+=`]`,t}var Tj=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 Ej(e){return Tj.get(e)??``}mc();function Dj(e,t,n,r,i){if(r===`prefix`)return e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`),U(`^${n}`,`s`).replace(t,``);let a=U(`${n}$`,`s`);if(i)return e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`),a.replace(t,``);e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`);let o=U(`^(?:.*)(${n})$`,`s`).exec(t);if(!o)return t;let s=o[1]??``;return t.slice(0,t.length-s.length)}function Oj(e,t){let n=new Set;for(let r of e.state.env.keys())r.startsWith(t)&&n.add(r);for(let r of e.state.arrays?.keys()??[])r.startsWith(t)&&n.add(r);return[...n].sort()}Wi(),j();function kj(e,t,n,r,i){let a=new Ui(e.limits.maxStringLength,`pattern replacement`,()=>new A(`pattern replacement: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`));n.lastIndex=0;let o=0,s=n.exec(t);for(;s!==null&&(e.executionScope.consumeLimited(`pattern_operations`,1,e.limits.maxGlobOperations,`pattern replacement`),!(i&&s[0].length===0&&s.index===t.length||(a.append(t.slice(o,s.index)),a.append(r),o=s.index+s[0].length,!i)));)s[0].length===0&&(o++,n.lastIndex<=s.index&&(n.lastIndex=s.index+1)),s=n.exec(t);return a.append(t.slice(o)),n.lastIndex=0,a.build()}Lr(),j();function Aj(e){let t=[],n=0;return{append(r){let i=O(r);if(i>e-n)throw new A(`prompt expansion exceeds string length limit (${e} bytes)`,`string_length`);r&&t.push(r),n+=i},build:()=>t.join(``)}}function jj(e,t,n){let r=(e,t=2)=>String(e).padStart(t,`0`);if(e===``)return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}`;let i=Aj(n),a=0;for(;a<e.length;)if(e[a]===`%`){if(a+1>=e.length){i.append(`%`),a++;continue}let n=e[a+1];switch(n){case`H`:i.append(r(t.getHours()));break;case`M`:i.append(r(t.getMinutes()));break;case`S`:i.append(r(t.getSeconds()));break;case`d`:i.append(r(t.getDate()));break;case`m`:i.append(r(t.getMonth()+1));break;case`Y`:i.append(String(t.getFullYear()));break;case`y`:i.append(r(t.getFullYear()%100));break;case`I`:{let e=t.getHours()%12;e===0&&(e=12),i.append(r(e));break}case`p`:i.append(t.getHours()<12?`AM`:`PM`);break;case`P`:i.append(t.getHours()<12?`am`:`pm`);break;case`%`:i.append(`%`);break;case`a`:i.append([`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.getDay()]);break;case`b`:i.append([`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()]);break;default:i.append(`%${n}`)}a+=2}else i.append(e[a]),a++;return i.build()}function Mj(e,t){let n=Aj(e.limits.maxStringLength),r=0,i=e.state.env.get(`USER`)||e.state.env.get(`LOGNAME`)||`user`,a=e.state.env.get(`HOSTNAME`)||`localhost`,o=a.split(`.`)[0],s=e.state.env.get(`PWD`)||`/`,c=e.state.env.get(`HOME`)||`/`,l=s.startsWith(c)?`~${s.slice(c.length)}`:s,u=s.split(`/`).pop()||s,d=new Date,f=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],p=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],m=e.state.env.get(`__COMMAND_NUMBER`)||`1`;for(;r<t.length;){let s=t[r];if(s===`\\`){if(r+1>=t.length){n.append(`\\`),r++;continue}let s=t[r+1];if(s>=`0`&&s<=`7`){let e=``,i=r+1;for(;i<t.length&&i<r+4&&t[i]>=`0`&&t[i]<=`7`;)e+=t[i],i++;let a=Number.parseInt(e,8)%256;n.append(String.fromCharCode(a)),r=i;continue}switch(s){case`\\`:n.append(`\\`),r+=2;break;case`a`:n.append(`\x07`),r+=2;break;case`e`:n.append(`\x1B`),r+=2;break;case`n`:n.append(`
920
+ `,``):aD(e,t,i)||``}let o=aD(e,t,a);if(o!==void 0)return o;if(a===0){let n=e.state.env.get(t);if(n!==void 0)return n}if(n&&e.state.options.nounset)throw new Cr(`${t}[${a}]`);return``}if(/^[1-9][0-9]*$/.test(t)){let r=e.state.env.get(t);if(r===void 0&&n&&e.state.options.nounset)throw new Cr(t);return r||``}if(GA(e,t)){let i=QA(e,t);if(i===void 0)return``;if(i!==t)return await ij(e,i,n,r);let a=e.state.env.get(t);if((a===void 0||a===``)&&n&&e.state.options.nounset)throw new Cr(t);return a||``}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(e=>e.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(rj(e,t)){let r=aD(e,t,0);if(r!==void 0)return r;if(n&&e.state.options.nounset)throw new Cr(t);return``}if(n&&e.state.options.nounset)throw new Cr(t);return``}async function aj(e,t){if(new Set([`?`,`$`,`#`,`_`,`-`,`0`,`PPID`,`UID`,`EUID`,`RANDOM`,`SECONDS`,`BASH_VERSION`,`!`,`BASHPID`,`LINENO`]).has(t))return!0;if(t===`@`||t===`*`)return Number.parseInt(e.state.env.get(`#`)||`0`,10)>0;if(t===`PWD`||t===`OLDPWD`)return e.state.env.has(t);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(GA(e,t)){let n=QA(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;t=n}}if(r===`@`||r===`*`)return nj(e,t).length>0||e.state.env.has(t);if(e.state.associativeArrays?.has(t)){let n=tj(e,pD(r));return oD(e,t,n)}let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else try{i=await rP(e,sO(new Tk,r).expression)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0,Number.isNaN(i)&&(i=0)}if(i<0){let n=nj(e,t);if(n.length===0)return!1;let r=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+i;return r<0?!1:oD(e,t,r)}return oD(e,t,i)}if(GA(e,t)){let n=QA(e,t);return n===void 0||n===t?e.state.env.has(t):aj(e,n)}return e.state.env.has(t)?!0:rj(e,t)?oD(e,t,0):!1}async function oj(e,t){let n=``,r=0;for(;r<t.length;){if(t[r]===`$`){if(t[r+1]===`{`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`{`?e++:t[i]===`}`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]===`(`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[0-9]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[0-9]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[*@#?\-!$]/.test(t[r+1]||``)){let i=t[r+1],a=await ij(e,i);n+=a,r+=2;continue}}if(t[r]===`"`){for(n+=`"`,r++;r<t.length&&t[r]!==`"`;)if(t[r]===`$`&&/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i}else t[r]===`\\`?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+=`"`,r++);continue}n+=t[r],r++}return n}async function sj(e,t){let n=t,r=t.startsWith(`"`)&&t.endsWith(`"`),i=t.startsWith(`'`)&&t.endsWith(`'`);if((r||i)&&(n=t.slice(1,-1)),i)return n;let a=``,o=0;for(;o<n.length;)if(n[o]===`$`){if(n[o+1]===`(`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`(`&&n[r-1]===`$`||n[r]===`(`?t++:n[r]===`)`&&t--,r++;let i=n.slice(o+2,r-1);if(e.execFn){let t=await e.execFn(i,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=r}else if(n[o+1]===`{`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`{`?t++:n[r]===`}`&&t--,r++;let i=await ij(e,n.slice(o+2,r-1));a+=i,o=r}else if(/[a-zA-Z_]/.test(n[o+1]||``)){let t=o+1;for(;t<n.length&&/[a-zA-Z0-9_]/.test(n[t]);)t++;let r=await ij(e,n.slice(o+1,t));a+=r,o=t}else a+=n[o],o++}else if(n[o]==="`"){let t=o+1;for(;t<n.length&&n[t]!=="`";)t++;let r=n.slice(o+1,t);if(e.execFn){let t=await e.execFn(r,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=t+1}else a+=n[o],o++;return a}Lr(),j();var cj=1e4,lj={maxResults:cj,maxStringBytes:10485760};function uj(e,t,n,r){if(e.length>=n.maxResults)return!1;let i=O(t);if(i>n.maxStringBytes-r.value)throw new A(`brace expansion string limit exceeded (${n.maxStringBytes} bytes)`,`string_length`);return e.push(t),r.value+=i,!0}function dj(e,t,n,r,i,a=lj){let o=n??1;o===0&&(o=1);let s=Math.abs(o),c=[],l=0;if(r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,``).length)),i?.match(/^-?0\d/)&&(l=Math.max(l,i.replace(/^-/,``).length)),l>a.maxStringBytes)throw new A(`brace expansion padding limit exceeded (${a.maxStringBytes} bytes)`,`string_length`);let u={value:0},d=e=>{if(l>0){let t=e<0,n=String(Math.abs(e)).padStart(l,`0`);return t?`-${n}`:n}return String(e)};if(e<=t)for(let n=e,r=0;n<=t&&r<cj&&uj(c,d(n),a,u);n+=s,r++);else for(let n=e,r=0;n>=t&&r<cj&&uj(c,d(n),a,u);n-=s,r++);return c}function fj(e,t,n,r=lj){let i=n??1;i===0&&(i=1);let a=e.charCodeAt(0),o=t.charCodeAt(0),s=Math.abs(i);if(e>=`A`&&e<=`Z`&&t>=`a`&&t<=`z`||e>=`a`&&e<=`z`&&t>=`A`&&t<=`Z`){let r=n===void 0?``:`..${n}`;throw new Or(`{${e}..${t}${r}}: invalid sequence`)}let c=[],l={value:0};if(a<=o)for(let e=a,t=0;e<=o&&t<cj&&uj(c,String.fromCharCode(e),r,l);e+=s,t++);else for(let e=a,t=0;e>=o&&t<cj&&uj(c,String.fromCharCode(e),r,l);e-=s,t++);return c}function pj(e,t,n,r,i,a=lj){let o=n===void 0?``:`..${n}`;return typeof e==`number`&&typeof t==`number`?{expanded:dj(e,t,n,r,i,a),literal:`{${e}..${t}${o}}`}:typeof e==`string`&&typeof t==`string`?{expanded:fj(e,t,n,a),literal:`{${e}..${t}${o}}`}:{expanded:null,literal:`{${e}..${t}${o}}`}}function mj(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!==`SimpleCommand`)return null;let i=r;if(i.name!==null||i.args.length!==0||i.assignments.length!==0||i.redirections.length!==1)return null;let a=i.redirections[0];return a.operator!==`<`||a.target.type!==`Word`?null:{target:a.target}}function hj(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function gj(e){let t=``,n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function _j(e){return e.replace(/([*?[\]\\()|])/g,`\\$1`)}function vj(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`)}mc(),j();function yj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function bj(e,t,n=!1){let r=``,i=0;for(;i<e.length;){let a=e[i];if(n&&(a===`@`||a===`*`||a===`+`||a===`?`||a===`!`)&&i+1<e.length&&e[i+1]===`(`){let o=xj(e,i+1);if(o!==-1){let s=Sj(e.slice(i+2,o)).map(e=>bj(e,t,n)),c=s.length>0?s.join(`|`):`(?:)`;a===`@`?r+=`(?:${c})`:a===`*`?r+=`(?:${c})*`:a===`+`?r+=`(?:${c})+`:a===`?`?r+=`(?:${c})?`:a===`!`&&(r+=`(?!(?:${c})$).*`),i=o+1;continue}}if(a===`\\`){if(i+1<e.length){let t=e[i+1];/[\\^$.|+(){}[\]*?]/.test(t)?r+=`\\${t}`:r+=t,i+=2}else r+=`\\\\`,i++}else if(a===`*`)r+=t?`.*`:`.*?`,i++;else if(a===`?`)r+=`.`,i++;else if(a===`[`){let t=Cj(e,i);if(t===-1)r+=`\\[`,i++;else{let n=e.slice(i+1,t);r+=wj(n),i=t+1}}else/[\^$.|+(){}]/.test(a)?(r+=`\\${a}`,i++):(r+=a,i++)}return r}function xj(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Sj(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function Cj(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){if(e[n]===`\\`&&n+1<e.length){n+=2;continue}if(e[n]===`]`)return n;if(e[n]===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}n++}return-1}function wj(e){let t=`[`,n=0;for((e[0]===`^`||e[0]===`!`)&&(t+=`^`,n++);n<e.length;){if(e[n]===`'`){let r=e.indexOf(`'`,n+1);if(r!==-1){let i=e.slice(n+1,r);for(let e of i)t+=e===`\\`?`\\\\`:e===`]`?`\\]`:e===`^`&&t===`[`?`\\^`:e;n=r+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r);t+=Ej(i),n=r+2;continue}}let r=e[n];r===`\\`?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+=`\\\\`,n++):r===`-`&&n>0&&n<e.length-1?(t+=`-`,n++):r===`^`&&n===0?(t+=`^`,n++):(t+=r===`]`&&n===0?`\\]`:r,n++)}return t+=`]`,t}var Tj=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 Ej(e){return Tj.get(e)??``}mc();function Dj(e,t,n,r,i){if(r===`prefix`)return e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`),U(`^${n}`,`s`).replace(t,``);let a=U(`${n}$`,`s`);if(i)return e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`),a.replace(t,``);e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`);let o=U(`^(?:.*)(${n})$`,`s`).exec(t);if(!o)return t;let s=o[1]??``;return t.slice(0,t.length-s.length)}function Oj(e,t){let n=new Set;for(let r of e.state.env.keys())r.startsWith(t)&&n.add(r);for(let r of e.state.arrays?.keys()??[])r.startsWith(t)&&n.add(r);return[...n].sort()}Wi(),j();function kj(e,t,n,r,i){let a=new Ui(e.limits.maxStringLength,`pattern replacement`,()=>new A(`pattern replacement: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`));n.lastIndex=0;let o=0,s=n.exec(t);for(;s!==null&&(e.executionScope.consumeLimited(`pattern_operations`,1,e.limits.maxGlobOperations,`pattern replacement`),!(i&&s[0].length===0&&s.index===t.length||(a.append(t.slice(o,s.index)),a.append(r),o=s.index+s[0].length,!i)));)s[0].length===0&&(o++,n.lastIndex<=s.index&&(n.lastIndex=s.index+1)),s=n.exec(t);return a.append(t.slice(o)),n.lastIndex=0,a.build()}Lr(),j();function Aj(e){let t=[],n=0;return{append(r){let i=O(r);if(i>e-n)throw new A(`prompt expansion exceeds string length limit (${e} bytes)`,`string_length`);r&&t.push(r),n+=i},build:()=>t.join(``)}}function jj(e,t,n){let r=(e,t=2)=>String(e).padStart(t,`0`);if(e===``)return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}`;let i=Aj(n),a=0;for(;a<e.length;)if(e[a]===`%`){if(a+1>=e.length){i.append(`%`),a++;continue}let n=e[a+1];switch(n){case`H`:i.append(r(t.getHours()));break;case`M`:i.append(r(t.getMinutes()));break;case`S`:i.append(r(t.getSeconds()));break;case`d`:i.append(r(t.getDate()));break;case`m`:i.append(r(t.getMonth()+1));break;case`Y`:i.append(String(t.getFullYear()));break;case`y`:i.append(r(t.getFullYear()%100));break;case`I`:{let e=t.getHours()%12;e===0&&(e=12),i.append(r(e));break}case`p`:i.append(t.getHours()<12?`AM`:`PM`);break;case`P`:i.append(t.getHours()<12?`am`:`pm`);break;case`%`:i.append(`%`);break;case`a`:i.append([`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.getDay()]);break;case`b`:i.append([`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()]);break;default:i.append(`%${n}`)}a+=2}else i.append(e[a]),a++;return i.build()}function Mj(e,t){let n=Aj(e.limits.maxStringLength),r=0,i=e.state.env.get(`USER`)||e.state.env.get(`LOGNAME`)||`user`,a=e.state.env.get(`HOSTNAME`)||`localhost`,o=a.split(`.`)[0],s=e.state.env.get(`PWD`)||`/`,c=e.state.env.get(`HOME`)||`/`,l=s.startsWith(c)?`~${s.slice(c.length)}`:s,u=s.split(`/`).pop()||s,d=new Date,f=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],p=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],m=e.state.env.get(`__COMMAND_NUMBER`)||`1`;for(;r<t.length;){let s=t[r];if(s===`\\`){if(r+1>=t.length){n.append(`\\`),r++;continue}let s=t[r+1];if(s>=`0`&&s<=`7`){let e=``,i=r+1;for(;i<t.length&&i<r+4&&t[i]>=`0`&&t[i]<=`7`;)e+=t[i],i++;let a=Number.parseInt(e,8)%256;n.append(String.fromCharCode(a)),r=i;continue}switch(s){case`\\`:n.append(`\\`),r+=2;break;case`a`:n.append(`\x07`),r+=2;break;case`e`:n.append(`\x1B`),r+=2;break;case`n`:n.append(`
921
921
  `),r+=2;break;case`r`:n.append(`\r`),r+=2;break;case`$`:n.append(`$`),r+=2;break;case`[`:case`]`:r+=2;break;case`u`:n.append(i),r+=2;break;case`h`:n.append(o),r+=2;break;case`H`:n.append(a),r+=2;break;case`w`:n.append(l),r+=2;break;case`W`:n.append(u),r+=2;break;case`d`:{let e=String(d.getDate()).padStart(2,` `);n.append(`${f[d.getDay()]} ${p[d.getMonth()]} ${e}`),r+=2;break}case`t`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`),i=String(d.getSeconds()).padStart(2,`0`);n.append(`${e}:${t}:${i}`),r+=2;break}case`T`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=String(d.getSeconds()).padStart(2,`0`);n.append(`${t}:${i}:${a}`),r+=2;break}case`@`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=d.getHours()<12?`AM`:`PM`;n.append(`${t}:${i} ${a}`),r+=2;break}case`A`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`);n.append(`${e}:${t}`),r+=2;break}case`D`:if(r+2<t.length&&t[r+2]===`{`){let i=t.indexOf(`}`,r+3);if(i!==-1){let a=t.slice(r+3,i);n.append(jj(a,d,e.limits.maxStringLength)),r=i+1}else n.append(`\\D`),r+=2}else n.append(`\\D`),r+=2;break;case`s`:n.append(`bash`),r+=2;break;case`v`:n.append(`5.0`),r+=2;break;case`V`:n.append(`5.0.0`),r+=2;break;case`j`:n.append(`0`),r+=2;break;case`l`:n.append(`tty`),r+=2;break;case`#`:n.append(m),r+=2;break;case`!`:n.append(m),r+=2;break;case`x`:n.append(`\\x`),r+=2;break;default:n.append(`\\${s}`),r+=2}}else n.append(s),r++}return n.build()}function Nj(e){if(e===``)return`''`;if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let t=`$'`;for(let n of e)switch(n){case`'`:t+=`\\'`;break;case`\\`:t+=`\\\\`;break;case`
922
922
  `:t+=`\\n`;break;case`\r`:t+=`\\r`;break;case` `:t+=`\\t`;break;default:{let e=n.charCodeAt(0);t+=e<32||e===127?`\\${e.toString(8).padStart(3,`0`)}`:n}}return`${t}'`}return`'${e}'`}j();function Pj(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function Fj(e,t){return e.state.readonlyVars?.has(t)??!1}function Ij(e,t,n=`bash`){if(Fj(e,t)){let e=`${n}: ${t}: readonly variable
923
923
  `;throw new wr(1,``,e)}return null}function Lj(e,t){let n=e.state.exportedVars?.has(t)??!1;if(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t),e.state.localScopes.length>0&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!n){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length<e.state.localScopes.length;)e.state.localExportedVars.push(new Set);e.state.localExportedVars[e.state.localExportedVars.length-1].add(t)}}function Rj(e,t){e.state.exportedVars?.delete(t)}function zj(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return``;let n=``,r=tD(e,t)?.kind===`indexed`,i=e.state.associativeArrays?.has(t)??!1;return r&&!i&&(n+=`a`),i&&(n+=`A`),e.state.integerVars?.has(t)&&(n+=`i`),GA(e,t)&&(n+=`n`),Fj(e,t)&&(n+=`r`),e.state.exportedVars?.has(t)&&(n+=`x`),n}async function Bj(e,t,n,r){return e.coverage?.hit(`bash:expansion:default_value`),(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function Vj(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:assign_default`),(r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let a=await i(e,n.word.parts,r.inDoubleQuotes),o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let[,t,n]=o,r;if(/^\d+$/.test(n))r=Number.parseInt(n,10);else{try{r=await rP(e,sO(new Tk,n).expression)}catch{let t=e.state.env.get(n);r=t?Number.parseInt(t,10):0}Number.isNaN(r)&&(r=0)}Y(e,t,r,a)}else e.state.env.set(t,a);return a}return r.effectiveValue}async function Hj(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:error_if_unset`),r.isUnset||n.checkEmpty&&r.isEmpty){let a=n.word?await i(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new wr(1,``,`bash: ${a}
924
- `)}return r.effectiveValue}async function Uj(e,t,n,r){return e.coverage?.hit(`bash:expansion:use_alternative`),!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):``}async function Wj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_removal`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=bj(t.pattern,n.greedy,o);else if(t.type===`Literal`)a+=bj(t.value,n.greedy,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await i(e,t);a+=bj(r,n.greedy,o)}else{let n=await i(e,t);a+=yj(n)}return Dj(e,t,a,n.side,n.greedy)}async function Gj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_replacement`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=bj(t.pattern,!0,o);else if(t.type===`Literal`)a+=bj(t.value,!0,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=yj(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);a+=bj(n,!0,o)}else{let n=await i(e,t);a+=yj(n)}let s=n.replacement?await r(e,n.replacement.parts):``;if(n.anchor===`start`?a=`^${a}`:n.anchor===`end`&&(a=`${a}$`),a===``)return t;let c=n.all?`gs`:`s`;try{return kj(e,t,U(a,c),s,n.all)}catch(e){if(e instanceof A)throw e;return t}}function Kj(e,t,n){e.coverage?.hit(`bash:expansion:length`);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=nj(e,t);return n.length>0?String(n.length):e.state.env.get(t)===void 0?`0`:`1`}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&rj(e,t)){if(t===`FUNCNAME`){let t=e.state.funcNameStack?.[0]||``;return String([...t].length)}if(t===`BASH_LINENO`){let t=e.state.callLineStack?.[0];return String(t===void 0?0:[...String(t)].length)}let n=aD(e,t,0)||``;return String([...n].length)}return String([...n].length)}async function qj(e,t,n,r){e.coverage?.hit(`bash:expansion:substring`);let i=await rP(e,r.offset.expression),a=r.length?await rP(e,r.length.expression):void 0;if(t===`@`||t===`*`){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);let r=e.state.env.get(`0`)||`bash`,o,s;if(i<=0)if(o=[r,...n],i<0){if(s=o.length+i,s<0)return``}else s=0;else o=n,s=i-1;if(s<0||s>=o.length)return``;if(a!==void 0){let e=a<0?o.length+a:s+a;return o.slice(s,Math.max(s,e)).join(` `)}return o.slice(s).join(` `)}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let t=o[1];if(e.state.associativeArrays?.has(t))throw new wr(1,``,`bash: \${${t}[@]: 0: 3}: bad substitution
924
+ `)}return r.effectiveValue}async function Uj(e,t,n,r){return e.coverage?.hit(`bash:expansion:use_alternative`),!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):``}async function Wj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_removal`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=bj(t.pattern,n.greedy,o);else if(t.type===`Literal`)a+=bj(t.value,n.greedy,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await i(e,t);a+=bj(r,n.greedy,o)}else{let n=await i(e,t);a+=yj(n)}return Dj(e,t,a,n.side,n.greedy)}async function Gj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_replacement`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=bj(t.pattern,!0,o);else if(t.type===`Literal`)a+=bj(t.value,!0,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=yj(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);a+=bj(n,!0,o)}else{let n=await i(e,t);a+=yj(n)}let s=n.replacement?await r(e,n.replacement.parts):``;if(n.anchor===`start`?a=`^${a}`:n.anchor===`end`&&(a=`${a}$`),a===``)return t;let c=n.all?`gs`:`s`;try{return kj(e,t,U(a,c),s,n.all)}catch(e){if(e instanceof A)throw e;return t}}function Kj(e,t,n){e.coverage?.hit(`bash:expansion:length`);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=nj(e,t);return n.length>0?String(n.length):e.state.env.get(t)===void 0?`0`:`1`}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&rj(e,t)){if(t===`FUNCNAME`){let t=e.state.funcNameStack?.[0]||``;return String([...t].length)}if(t===`BASH_LINENO`){let t=e.state.callLineStack?.[0];return String(t===void 0?0:[...String(t)].length)}let n=aD(e,t,0)||``;return String([...n].length)}return String([...n].length)}async function qj(e,t,n,r){e.coverage?.hit(`bash:expansion:substring`);let i=await rP(e,r.offset.expression),a=r.length?await rP(e,r.length.expression):void 0;if(t===`@`||t===`*`){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);let r=e.state.env.get(`0`)||`bash`,o,s;if(i<=0){if(o=[r,...n],i<0){if(s=o.length+i,s<0)return``}else s=0}else o=n,s=i-1;if(s<0||s>=o.length)return``;if(a!==void 0){let e=a<0?o.length+a:s+a;return o.slice(s,Math.max(s,e)).join(` `)}return o.slice(s).join(` `)}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let t=o[1];if(e.state.associativeArrays?.has(t))throw new wr(1,``,`bash: \${${t}[@]: 0: 3}: bad substitution
925
925
  `);let n=nj(e,t),r=0;if(i<0){if(n.length>0){let e=n[n.length-1][0],t=(typeof e==`number`?e:0)+1+i;if(t<0||(r=n.findIndex(([e])=>typeof e==`number`&&e>=t),r<0))return``}}else if(r=n.findIndex(([e])=>typeof e==`number`&&e>=i),r<0)return``;if(a!==void 0){if(a<0)throw new Tr(`${o[1]}[@]: substring expression < 0`);return n.slice(r,r+a).map(([,e])=>e).join(` `)}return n.slice(r).map(([,e])=>e).join(` `)}let s=[...n],c=i;if(c<0&&(c=Math.max(0,s.length+c)),a!==void 0){if(a<0){let e=s.length+a;return s.slice(c,Math.max(c,e)).join(``)}return s.slice(c,c+a).join(``)}return s.slice(c).join(``)}async function Jj(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:case_modification`),n.pattern){let a=e.state.shoptOptions.extglob,o=``;for(let t of n.pattern.parts)if(t.type===`Glob`)o+=bj(t.pattern,!0,a);else if(t.type===`Literal`)o+=bj(t.value,!0,a);else if(t.type===`SingleQuoted`||t.type===`Escaped`)o+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);o+=yj(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);o+=bj(n,!0,a)}let s=U(`^(?:${o})$`),c=n.direction===`upper`?e=>e.toUpperCase():e=>e.toLowerCase(),l=``,u=!1;for(let e of t)!n.all&&u?l+=e:s.test(e)?(l+=c(e),u=!0):l+=e;return l}return n.direction===`upper`?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function Yj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:transform`);let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(a&&i.operator===`Q`)return nj(e,a[1]).map(([,e])=>Nj(e)).join(` `);if(a&&i.operator===`a`)return zj(e,a[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&i.operator===`a`)return zj(e,o[1]);switch(i.operator){case`Q`:return r?``:Nj(n);case`P`:return Mj(e,n);case`a`:return zj(e,t);case`A`:return r?``:`${t}=${Nj(n)}`;case`E`:return n.replace(/\\([\\abefnrtv'"?])/g,(e,t)=>{switch(t){case`\\`:return`\\`;case`a`:return`\x07`;case`b`:return`\b`;case`e`:return`\x1B`;case`f`:return`\f`;case`n`:return`
926
926
  `;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`'`:return`'`;case`"`:return`"`;case`?`:return`?`;default:return t}});case`K`:case`k`:return r?``:Nj(n);case`u`:return n.charAt(0).toUpperCase()+n.slice(1);case`U`:return n.toUpperCase();case`L`:return n.toLowerCase();default:return n}}async function Xj(e,t,n,r,i,a,o=!1){if(e.coverage?.hit(`bash:expansion:indirection`),GA(e,t))return $A(e,t)||``;let s=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(i.innerOp?.type===`UseAlternative`)return``;throw new Er(`\${!${t}}`)}let c=n;if(s&&(c===``||c.includes(` `)))throw new Er(`\${!${t}}`);let l=c.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(l&&l[1].includes(`~`))throw new Er(`\${!${t}}`);return i.innerOp?a(e,{type:`ParameterExpansion`,parameter:c,operation:i.innerOp},o):await ij(e,c)}function Zj(e,t){e.coverage?.hit(`bash:expansion:array_keys`);let n=nj(e,t.array).map(([e])=>String(e));return t.star?n.join(IA(e.state.env)):n.join(` `)}function Qj(e,t){e.coverage?.hit(`bash:expansion:var_name_prefix`);let n=Oj(e,t.prefix);return t.star?n.join(IA(e.state.env)):n.join(` `)}function $j(e,t,n,r){let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t===`*`)return{isEmpty:i===0,effectiveValue:n};if(t===`@`)return{isEmpty:i===0||i===1&&e.state.env.get(`1`)===``,effectiveValue:n};if(a){let[,t,n]=a,i=nj(e,t);if(i.length===0)return{isEmpty:!0,effectiveValue:``};if(n===`*`){let t=IA(e.state.env),n=i.map(([,e])=>e).join(t);return{isEmpty:r?n===``:!1,effectiveValue:n}}return{isEmpty:i.length===1&&i.every(([,e])=>e===``),effectiveValue:i.map(([,e])=>e).join(` `)}}return{isEmpty:n===``,effectiveValue:n}}j();function eM(e){let t=0;for(;t<e.length;){let n=e[t];if(n===`\\`&&t+1<e.length){t+=2;continue}if(n===`'`){let n=e.indexOf(`'`,t+1);if(n!==-1){t=n+1;continue}}if(n===`$`&&t+1<e.length&&e[t+1]===`(`||n==="`")return!0;t++}return!1}function tM(e,t){let n=1,r=t,i=!1,a=!1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`&&!i&&r+1<e.length){r+=2;continue}if(t===`'`&&!a){i=!i,r++;continue}if(t===`"`&&!i){a=!a,r++;continue}if(!i&&!a){if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}r++}return-1}async function nM(e,t){let n=new Tk,r;try{r=n.parse(t)}catch{return``}let i=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let a=new Map(e.state.env),o=eD(e.state.arrays),s=e.state.cwd,c=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let t=await e.executeScript(r),n=t.exitCode;return e.state.env=a,e.state.arrays=o,e.state.cwd=s,e.state.suppressVerbose=c,e.state.lastExitCode=n,e.state.env.set(`?`,String(n)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr),e.state.bashPid=i,t.stdout.replace(/\n+$/,``)}catch(t){if(e.state.env=a,e.state.arrays=o,e.state.cwd=s,e.state.bashPid=i,e.state.suppressVerbose=c,t instanceof A)throw t;return t instanceof wr?(e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stdout?.replace(/\n+$/,``)??``):``}}function rM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=_j(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=iM(e,t.slice(r+1,i));n+=_j(a),r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}function iM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}async function aM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=_j(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=await oM(e,t.slice(r+1,i));n+=_j(a),r=i+1;continue}}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=tM(t,r+2);if(i!==-1){let a=await nM(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await nM(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}async function oM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=tM(t,r+2);if(i!==-1){let a=await nM(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await nM(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}function sM(e,t){if(!t.startsWith(`~`))return t;e.coverage?.hit(`bash:expansion:tilde`);let n=e.state.env.get(`HOME`)===void 0?`/home/user`:e.state.env.get(`HOME`);if(t===`~`||t.startsWith(`~/`))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let i=t.slice(1,r),a=t.slice(r);return a!==``&&!a.startsWith(`/`)?t:i===`root`?`/root${a}`:t}function cM(e,t){return t.split(`:`).map(t=>sM(e,t)).join(`:`)}j(),j();function lM(e,t,n,r){if(e.length>n-t.length)throw new A(`${r} element limit exceeded (${n})`,`array_elements`);for(let n of t)e.push(n)}mc();async function uM(e,t,n,r){let i=``;for(let a of t.parts)if(a.type===`Glob`)i+=bj(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)i+=bj(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)i+=yj(a.value);else if(a.type===`DoubleQuoted`){let t=await n(e,a.parts);i+=yj(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);i+=bj(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);i+=yj(t)}return i}async function dM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternReplacement`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=nj(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``;l.pattern&&(f=await uM(e,l.pattern,n,r));let p=l.replacement?await n(e,l.replacement.parts):``,m=f;l.anchor===`start`?m=`^${f}`:l.anchor===`end`&&(m=`${f}$`);let h=[];try{let e=U(m,l.all?`g`:``);for(let t of d)h.push(e.replace(t,p))}catch{h.push(...d)}if(c){let t=IA(e.state.env);return{values:[h.join(t)],quoted:!0}}return{values:h,quoted:!0}}async function fM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternRemoval`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=nj(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``,p=e.state.shoptOptions.extglob;if(l.pattern)for(let t of l.pattern.parts)if(t.type===`Glob`)f+=bj(t.pattern,l.greedy,p);else if(t.type===`Literal`)f+=bj(t.value,l.greedy,p);else if(t.type===`SingleQuoted`||t.type===`Escaped`)f+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);f+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);f+=bj(n,l.greedy,p)}else{let n=await r(e,t);f+=yj(n)}let m=[];for(let t of d)m.push(Dj(e,t,f,l.side,l.greedy));if(c){let t=IA(e.state.env);return{values:[m.join(t)],quoted:!0}}return{values:m,quoted:!0}}mc();async function pM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`DefaultValue`&&n.parts[0].operation?.type!==`UseAlternative`&&n.parts[0].operation?.type!==`AssignDefault`)return null;let r=n.parts[0],i=r.operation,a=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,s=!1;if(a){let t=a[1];s=a[2]===`*`;let n=nj(e,t),r=n.length>0||e.state.env.has(t),c=n.length===0||n.length===1&&n.every(([,e])=>e===``),l=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?r&&!(l&&c):!r||l&&c,!o){if(n.length>0){let t=n.map(([,e])=>e);if(s){let n=IA(e.state.env);return{values:[t.join(n)],quoted:!0}}return{values:t,quoted:!0}}let r=e.state.env.get(t);return r===void 0?{values:[],quoted:!0}:{values:[r],quoted:!0}}}else{let t=r.parameter,n=await aj(e,t),a=await ij(e,t),s=a===``,c=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?n&&!(c&&s):!n||c&&s,!o)return{values:[a],quoted:!0}}if(o&&i.word){let t=i.word.parts,n=null,r=!1;for(let e of t)if(e.type===`ParameterExpansion`&&!e.operation){let t=e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){n=t[1],r=t[2]===`*`;break}}if(n){let t=nj(e,n);if(t.length>0){let n=t.map(([,e])=>e);if(r||s){let t=IA(e.state.env);return{values:[n.join(t)],quoted:!0}}return{values:n,quoted:!0}}let i=e.state.env.get(n);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}}return null}async function mM(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0],o=-1,s=``,c=!1,l=null;for(let e=0;e<a.parts.length;e++){let t=a.parts[e];if(t.type===`ParameterExpansion`&&(t.operation?.type===`PatternRemoval`||t.operation?.type===`PatternReplacement`)){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){o=e,s=n[1],c=n[2]===`*`,l=t.operation;break}}}if(o===-1||o===0&&o===a.parts.length-1)return null;let u=``;for(let t=0;t<o;t++)u+=await r(e,a.parts[t]);let d=``;for(let t=o+1;t<a.parts.length;t++)d+=await r(e,a.parts[t]);let f=nj(e,s),p=f.map(([,e])=>e);if(f.length===0){let t=e.state.env.get(s);if(t!==void 0)p=[t];else{if(c)return{values:[u+d],quoted:!0};let e=u+d;return{values:e?[e]:[],quoted:!0}}}if(l?.type===`PatternRemoval`){let t=l,n=``,a=e.state.shoptOptions.extglob;if(t.pattern)for(let o of t.pattern.parts)if(o.type===`Glob`)n+=bj(o.pattern,t.greedy,a);else if(o.type===`Literal`)n+=bj(o.value,t.greedy,a);else if(o.type===`SingleQuoted`||o.type===`Escaped`)n+=yj(o.value);else if(o.type===`DoubleQuoted`){let t=await i(e,o.parts);n+=yj(t)}else if(o.type===`ParameterExpansion`){let i=await r(e,o);n+=bj(i,t.greedy,a)}else{let t=await r(e,o);n+=yj(t)}p=p.map(r=>Dj(e,r,n,t.side,t.greedy))}else if(l?.type===`PatternReplacement`){let t=l,n=``;if(t.pattern)for(let a of t.pattern.parts)if(a.type===`Glob`)n+=bj(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)n+=bj(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)n+=yj(a.value);else if(a.type===`DoubleQuoted`){let t=await i(e,a.parts);n+=yj(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);n+=bj(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);n+=yj(t)}let a=t.replacement?await i(e,t.replacement.parts):``,o=n;t.anchor===`start`?o=`^${n}`:t.anchor===`end`&&(o=`${n}$`);try{let e=U(o,t.all?`g`:``);p=p.map(t=>e.replace(t,a))}catch{}}if(c){let t=IA(e.state.env);return{values:[u+p.join(t)+d],quoted:!0}}return p.length===1?{values:[u+p[0]+d],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+d],quoted:!0}}async function hM(e,t,n,r){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=``,s=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&!t.operation){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){a=e,o=n[1],s=n[2]===`*`;break}}}if(a===-1)return null;let c=``;for(let t=0;t<a;t++)c+=await r(e,i.parts[t]);let l=``;for(let t=a+1;t<i.parts.length;t++)l+=await r(e,i.parts[t]);let u=nj(e,o),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(o);if(t!==void 0)return{values:[c+t+l],quoted:!0};if(s)return{values:[c+l],quoted:!0};let n=c+l;return{values:n?[n]:[],quoted:!0}}if(s){let t=IA(e.state.env);return{values:[c+d.join(t)+l],quoted:!0}}return d.length===1?{values:[c+d[0]+l],quoted:!0}:{values:[c+d[0],...d.slice(1,-1),d[d.length-1]+l],quoted:!0}}Lr(),j();async function gM(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==`ParameterExpansion`||r.parts[0].operation?.type!==`Substring`)return null;let i=r.parts[0],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],s=a[2]===`*`,c=i.operation;if(e.state.associativeArrays?.has(o))throw new wr(1,``,`bash: \${${o}[@]: 0: 3}: bad substitution
927
- `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=nj(e,o);if(d.length>e.limits.maxArrayElements)throw new A(`array transform element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let f=0;if(l<0){if(d.length>0){let e=d[d.length-1][0],t=(typeof e==`number`?e:0)+1+l;if(t<0)return{values:[],quoted:!0};f=d.findIndex(([e])=>typeof e==`number`&&e>=t),f<0&&(f=d.length)}}else f=d.findIndex(([e])=>typeof e==`number`&&e>=l),f<0&&(f=d.length);let p;if(u!==void 0){if(u<0)throw new Tr(`${o}[@]: substring expression < 0`);p=d.slice(f,f+u).map(([,e])=>e)}else p=d.slice(f).map(([,e])=>e);if(p.length===0)return{values:[],quoted:!0};if(s){let t=IA(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,quoted:!0}}function _M(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`Transform`)return null;let r=n.parts[0],i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let a=i[1],o=i[2]===`*`,s=r.operation,c=nj(e,a);if(c.length===0){let t=e.state.env.get(a);if(t!==void 0){let n;switch(s.operator){case`a`:n=``;break;case`P`:n=Mj(e,t);break;case`Q`:n=Nj(t);break;default:n=t}if(O(n)>e.limits.maxStringLength)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[n],quoted:!0}}return o?{values:[``],quoted:!0}:{values:[],quoted:!0}}let l=zj(e,a),u=[],d=0;for(let[,t]of c){let n;switch(s.operator){case`a`:n=l;break;case`P`:n=Mj(e,t);break;case`Q`:n=Nj(t);break;case`u`:n=t.charAt(0).toUpperCase()+t.slice(1);break;case`U`:n=t.toUpperCase();break;case`L`:n=t.toLowerCase();break;default:n=t}let r=O(n);if(r>e.limits.maxStringLength-d)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);u.push(n),d+=r}if(o){let t=IA(e.state.env);if(Math.max(0,u.length-1)*O(t)>e.limits.maxStringLength-d)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[u.join(t)],quoted:!0}}return{values:u,quoted:!0}}function vM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`)return null;let r=n.parts[0];if(r.operation)return null;let i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!i)return null;let a=i[1];if(GA(e,a)){let t=$A(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=nj(e,a);if(o.length>0)return{values:o.map(([,e])=>e),quoted:!0};let s=e.state.env.get(a);return s===void 0?{values:[],quoted:!0}:{values:[s],quoted:!0}}function yM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation)return null;let r=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)||!GA(e,r))return null;let i=$A(e,r);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],s=nj(e,o);if(s.length>0)return{values:s.map(([,e])=>e),quoted:!0};let c=e.state.env.get(o);return c===void 0?{values:[],quoted:!0}:{values:[c],quoted:!0}}j();async function bM(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=o.operation,c=await ij(e,o.parameter),l=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l){if(!s.innerOp&&(c===`@`||c===`*`)){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return c===`*`?{values:[n.join(IA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=nj(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return xM(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return SM(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=zj(e,u),n=f.map(()=>t);return d?{values:[n.join(IA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}let t=[];for(let[,n]of f){let i={type:`ParameterExpansion`,parameter:`_indirect_elem_`,operation:s.innerOp},a=e.state.env.get(`_indirect_elem_`);e.state.env.set(`_indirect_elem_`,n);try{let n=await r(e,i,!0);t.push(n)}finally{a===void 0?e.state.env.delete(`_indirect_elem_`):e.state.env.set(`_indirect_elem_`,a)}}return d?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let p=e.state.env.get(u);return p===void 0?{values:[],quoted:!0}:{values:[p],quoted:!0}}async function xM(e,t,n,r,i){let a=i.offset?await rP(e,i.offset.expression):0,o=i.length?await rP(e,i.length.expression):void 0,s=0;if(a<0){if(t.length>0){let e=t[t.length-1][0],n=(typeof e==`number`?e:0)+1+a;if(n<0||(s=t.findIndex(([e])=>typeof e==`number`&&e>=n),s<0))return{values:[],quoted:!0}}}else if(s=t.findIndex(([e])=>typeof e==`number`&&e>=a),s<0)return{values:[],quoted:!0};let c;if(o!==void 0){if(o<0)throw new Tr(`${n}[@]: substring expression < 0`);c=t.slice(s,s+o)}else c=t.slice(s);let l=c.map(([,e])=>e);return r?{values:[l.join(IA(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function SM(e,t,n,r,i,a){let o=i.checkEmpty??!1,s=t.map(([,e])=>e),c=t.length===0,l=t.length===0;if(i.type===`UseAlternative`)return!l&&!(o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(i.type===`DefaultValue`)return(l||o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0};if(i.type===`AssignDefault`){if((l||o&&c)&&i.word){let t=await a(e,i.word.parts,!0);return Y(e,n,0,t),{values:[t],quoted:!0}}return r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function CM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`UseAlternative`&&t[0].operation?.type!==`DefaultValue`)return null;let n=t[0],r=n.operation,i=r?.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await ij(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await aj(e,n.parameter),l=await ij(e,n.parameter)===``,u=r.checkEmpty??!1,d;if(d=r.type===`UseAlternative`?c&&!(u&&l):!c||u&&l,d){let t=s[1],n=s[2]===`*`,r=nj(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}async function wM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`Indirection`)return null;let n=t[0],r=n.operation.innerOp;if(!r||r.type!==`UseAlternative`&&r.type!==`DefaultValue`)return null;let i=r.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await ij(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await ij(e,n.parameter),l=await aj(e,n.parameter),u=c===``,d=r.checkEmpty??!1,f;if(f=r.type===`UseAlternative`?l&&!(d&&u):!l||d&&u,f){let t=s[1],n=s[2]===`*`,r=nj(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}Lr(),mc(),j();function TM(e){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t>e.limits.maxArrayElements)throw new A(`positional parameter element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=[],r=0;for(let i=1;i<=t;i++){let t=e.state.env.get(String(i))||``,a=O(t);if(a>e.limits.maxStringLength-r)throw new A(`positional parameter string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n.push(t),r+=a}return n}function EM(e,t,n){if(O(t)>n-O(e))throw new A(`positional expansion string limit exceeded (${n} bytes)`,`string_length`);return e+t}function DM(e,t,n,r){if(e.length>=r.limits.maxArrayElements)throw new A(`positional expansion element limit exceeded (${r.limits.maxArrayElements})`,`array_elements`);let i=O(t);if(i>r.limits.maxStringLength-n.value)throw new A(`positional expansion string limit exceeded (${r.limits.maxStringLength} bytes)`,`string_length`);e.push(t),n.value+=i}async function OM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`Substring`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=s.offset?await n(e,s.offset.expression):0,l=s.length?await n(e,s.length.expression):void 0,u=Number.parseInt(e.state.env.get(`#`)||`0`,10),d=[];for(let t=1;t<=u;t++)d.push(e.state.env.get(String(t))||``);let f=e.state.env.get(`0`)||`bash`,p;if(c<=0){let e=[f,...d],t=e.length+c;if(t<0)p=[];else{let n=c<0?t:0;if(l!==void 0){let t=l<0?e.length+l:n+l;p=e.slice(n,Math.max(n,t))}else p=e.slice(n)}}else{let e=c-1;if(e>=d.length)p=[];else if(l!==void 0){let t=l<0?d.length+l:e+l;p=d.slice(e,Math.max(e,t))}else p=d.slice(e)}let m=``;for(let t=0;t<a;t++)m+=await r(e,i.parts[t]);let h=``;for(let t=a+1;t<i.parts.length;t++)h+=await r(e,i.parts[t]);if(p.length===0){let e=m+h;return{values:e?[e]:[],quoted:!0}}if(o){let t=IA(e.state.env);return{values:[m+p.join(t)+h],quoted:!0}}return p.length===1?{values:[m+p[0]+h],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+h],quoted:!0}}async function kM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternReplacement`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=TM(e),l=``;for(let t=0;t<a;t++)l=EM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=EM(u,await n(e,i.parts[t]),e.limits.maxStringLength);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=bj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)d+=bj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=bj(r,!0,e.state.shoptOptions.extglob)}else{let r=await n(e,t);d+=yj(r)}let f=s.replacement?await r(e,s.replacement.parts):``,p=d;s.anchor===`start`?p=`^${d}`:s.anchor===`end`&&(p=`${d}$`);let m=[],h={value:0};try{let t=U(p,s.all?`g`:``);for(let n of c){let r=0;t.lastIndex=0;for(let e=t.exec(n);e&&(r++,s.all);e=t.exec(n))e[0].length===0&&t.lastIndex++;let i=O(n),a=O(f),o=0,c=/\$(?:\$|&|\d+|<[^>]+>|`|')/g;for(;c.exec(f)!==null;)o++;if(i+r*a+r*o*i>e.limits.maxStringLength-h.value)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);DM(m,t.replace(n,f),h,e)}}catch(t){if(t instanceof A)throw t;for(let t of c)DM(m,t,h,e)}if(o){let t=IA(e.state.env);if(h.value+Math.max(0,m.length-1)*O(t)+O(l)+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+m.join(t)+u],quoted:!0}}if(O(l)+h.value+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return m.length===1?{values:[l+m[0]+u],quoted:!0}:{values:[l+m[0],...m.slice(1,-1),m[m.length-1]+u],quoted:!0}}async function AM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternRemoval`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=TM(e),l=``;for(let t=0;t<a;t++)l=EM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=EM(u,await n(e,i.parts[t]),e.limits.maxStringLength);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``,f=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=bj(t.pattern,s.greedy,f);else if(t.type===`Literal`)d+=bj(t.value,s.greedy,f);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=bj(r,s.greedy,f)}else{let r=await n(e,t);d+=yj(r)}let p=[],m={value:0};for(let t of c)DM(p,Dj(e,t,d,s.side,s.greedy),m,e);if(o){let t=IA(e.state.env);if(m.value+Math.max(0,p.length-1)*O(t)+O(l)+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+p.join(t)+u],quoted:!0}}if(O(l)+m.value+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return p.length===1?{values:[l+p[0]+u],quoted:!0}:{values:[l+p[0],...p.slice(1,-1),p[p.length-1]+u],quoted:!0}}async function jM(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0],i=-1,a=!1;for(let e=0;e<r.parts.length;e++){let t=r.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)){i=e,a=t.parameter===`*`;break}}if(i===-1)return null;let o=r.parts[i];if(o.type===`ParameterExpansion`&&o.operation)return null;let s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=``;for(let t=0;t<i;t++)c+=await n(e,r.parts[t]);let l=``;for(let t=i+1;t<r.parts.length;t++)l+=await n(e,r.parts[t]);if(s===0){if(a)return{values:[c+l],quoted:!0};let e=c+l;return{values:e?[e]:[],quoted:!0}}let u=[];for(let t=1;t<=s;t++)u.push(e.state.env.get(String(t))||``);if(a){let t=IA(e.state.env);return{values:[c+u.join(t)+l],quoted:!0}}return u.length===1?{values:[c+u[0]+l],quoted:!0}:{values:[c+u[0],...u.slice(1,-1),u[u.length-1]+l],quoted:!0}}k(),mc(),j();function MM(e,t,n,r){if(t.length>=e.limits.maxArrayElements)throw new A(`unquoted expansion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let i=O(n);if(i>e.limits.maxStringLength-r.value)throw new A(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);t.push(n),r.value+=i}function NM(e,t,n,r){let i=O(n),a=Math.max(0,t.length-1);if(i>0&&a>Math.floor((e.limits.maxStringLength-r)/i))throw new A(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return t.join(n)}function PM(e){return new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)})}async function FM(e,t){if(e.state.options.noglob)return t;let n=PM(e),r=[];for(let i of t)if(hj(i,e.state.shoptOptions.extglob)){let t=await n.expand(i);if(t.length>0)lM(r,t,e.limits.maxArrayElements,`unquoted glob expansion`);else{if(n.hasFailglob())throw new Dr(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function IM(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternReplacement`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=nj(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=bj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=bj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=bj(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=yj(n)}let d=s.replacement?await n(e,s.replacement.parts):``,f=u;s.anchor===`start`?f=`^${u}`:s.anchor===`end`&&(f=`${u}$`);let p=[],m={value:0};try{let t=U(f,s.all?`g`:``);for(let n of l)MM(e,p,kj(e,n,t,d,s.all),m)}catch(t){if(t instanceof A)throw t;for(let t of l)MM(e,p,t,m)}let h=MA(e.state.env),g=NA(e.state.env);if(o){let t=NM(e,p,IA(e.state.env),m.value);return g?{values:t?[t]:[],quoted:!1}:{values:HA(t,h,e.limits.maxArrayElements),quoted:!1}}if(g)return{values:p,quoted:!1};let _=[],v={value:0};for(let t of p)if(t===``)MM(e,_,``,v);else for(let n of HA(t,h,e.limits.maxArrayElements))MM(e,_,n,v);return{values:_,quoted:!1}}async function LM(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternRemoval`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=nj(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``,d=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=bj(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=bj(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=bj(n,s.greedy,d)}else{let n=await r(e,t);u+=yj(n)}let f=[],p={value:0};for(let t of l)MM(e,f,Dj(e,t,u,s.side,s.greedy),p);let m=MA(e.state.env),h=NA(e.state.env);if(o){let t=NM(e,f,IA(e.state.env),p.value);return h?{values:t?[t]:[],quoted:!1}:{values:HA(t,m,e.limits.maxArrayElements),quoted:!1}}if(h)return{values:f,quoted:!1};let g=[],_={value:0};for(let t of f)if(t===``)MM(e,g,``,_);else for(let n of HA(t,m,e.limits.maxArrayElements))MM(e,g,n,_);return{values:g,quoted:!1}}async function RM(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`PatternRemoval`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=[];for(let t=1;t<=s;t++)c.push(e.state.env.get(String(t))||``);if(c.length===0)return{values:[],quoted:!1};let l=``,u=e.state.shoptOptions.extglob;if(o.pattern)for(let t of o.pattern.parts)if(t.type===`Glob`)l+=bj(t.pattern,o.greedy,u);else if(t.type===`Literal`)l+=bj(t.value,o.greedy,u);else if(t.type===`SingleQuoted`||t.type===`Escaped`)l+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);l+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);l+=bj(n,o.greedy,u)}else{let n=await r(e,t);l+=yj(n)}let d=[],f={value:0};for(let t of c)MM(e,d,Dj(e,t,l,o.side,o.greedy),f);let p=MA(e.state.env),m=NA(e.state.env);if(a){let t=NM(e,d,IA(e.state.env),f.value);return m?{values:t?[t]:[],quoted:!1}:{values:HA(t,p,e.limits.maxArrayElements),quoted:!1}}if(m)return{values:d,quoted:!1};let h=[],g={value:0};for(let t of d)if(t===``)MM(e,h,``,g);else for(let n of HA(t,p,e.limits.maxArrayElements))MM(e,h,n,g);return{values:h,quoted:!1}}async function zM(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`Substring`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=o.offset?await n(e,o.offset.expression):0,c=o.length?await n(e,o.length.expression):void 0,l=Number.parseInt(e.state.env.get(`#`)||`0`,10),u=[];for(let t=1;t<=l;t++)u.push(e.state.env.get(String(t))||``);let d=e.state.env.get(`0`)||`bash`,f;if(s<=0){let e=[d,...u],t=e.length+s;if(t<0)f=[];else{let n=s<0?t:0;if(c!==void 0){let t=c<0?e.length+c:n+c;f=e.slice(n,Math.max(n,t))}else f=e.slice(n)}}else{let e=s-1;if(e>=u.length)f=[];else if(c!==void 0){let t=c<0?u.length+c:e+c;f=u.slice(e,Math.max(e,t))}else f=u.slice(e)}let p=``;for(let n=0;n<i;n++)p+=await r(e,t[n]);let m=``;for(let n=i+1;n<t.length;n++)m+=await r(e,t[n]);let h=MA(e.state.env),g=NA(e.state.env);if(f.length===0){let t=p+m;return t?g?{values:[t],quoted:!1}:{values:HA(t,h,e.limits.maxArrayElements),quoted:!1}:{values:[],quoted:!1}}let _;if(a){let t=IA(e.state.env),n=p+f.join(t)+m;_=g?n?[n]:[]:HA(n,h,e.limits.maxArrayElements)}else if(g)_=f.length===1?[p+f[0]+m]:[p+f[0],...f.slice(1,-1),f[f.length-1]+m];else{_=[];for(let t=0;t<f.length;t++){let n=f[t];if(t===0&&(n=p+n),t===f.length-1&&(n+=m),n===``)_.push(``);else{let t=HA(n,h,e.limits.maxArrayElements);lM(_,t,e.limits.maxArrayElements,`unquoted expansion`)}}}return{values:await FM(e,_),quoted:!1}}async function BM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].parameter!==`@`&&t[0].parameter!==`*`||t[0].operation)return null;let n=t[0].parameter===`*`,r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(r===0)return{values:[],quoted:!1};let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=MA(e.state.env),o=NA(e.state.env),s=PA(e.state.env),c;if(n)if(o)c=i.filter(e=>e!==``);else{let t=IA(e.state.env);c=HA(i.join(t),a,e.limits.maxArrayElements)}else if(o)c=i.filter(e=>e!==``);else if(s){c=[];for(let t of i){if(t===``)continue;let n=HA(t,a,e.limits.maxArrayElements);lM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{c=[];for(let t of i)if(t===``)c.push(``);else{let n=HA(t,a,e.limits.maxArrayElements);lM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await FM(e,c),quoted:!1}}async function VM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],i=n[2]===`*`,a=nj(e,r),o;if(a.length===0){let t=e.state.env.get(r);if(t!==void 0)o=[t];else return{values:[],quoted:!1}}else o=a.map(([,e])=>e);let s=MA(e.state.env),c=NA(e.state.env),l=PA(e.state.env),u;if(i)if(c)u=o.filter(e=>e!==``);else{let t=IA(e.state.env);u=HA(o.join(t),s,e.limits.maxArrayElements)}else if(c)u=o.filter(e=>e!==``);else if(l){u=[];for(let t of o){if(t===``)continue;let n=HA(t,s,e.limits.maxArrayElements);lM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{u=[];for(let t of o)if(t===``)u.push(``);else{let n=HA(t,s,e.limits.maxArrayElements);lM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await FM(e,u),quoted:!1}}function HM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=Oj(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=MA(e.state.env),a=NA(e.state.env),o;if(n.star)if(a)o=r;else{let t=IA(e.state.env);o=HA(r.join(t),i,e.limits.maxArrayElements)}else if(a)o=r;else{o=[];for(let t of r){let n=HA(t,i,e.limits.maxArrayElements);lM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}function UM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=nj(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=MA(e.state.env),a=NA(e.state.env),o;if(n.star)if(a)o=r;else{let t=IA(e.state.env);o=HA(r.join(t),i,e.limits.maxArrayElements)}else if(a)o=r;else{o=[];for(let t of r){let n=HA(t,i,e.limits.maxArrayElements);lM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}async function WM(e,t,n){let r=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&!n.operation){r=e;break}}if(r===-1||t.length<=1)return null;let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=[];for(let t=1;t<=i;t++)a.push(e.state.env.get(String(t))||``);let o=``;for(let i=0;i<r;i++)o+=await n(e,t[i]);let s=``;for(let i=r+1;i<t.length;i++)s+=await n(e,t[i]);let c=MA(e.state.env),l=NA(e.state.env),u=PA(e.state.env);if(i===0){let e=o+s;return{values:e?[e]:[],quoted:!1}}let d;{let t=[];for(let e=0;e<a.length;e++){let n=a[e];e===0&&(n=o+n),e===a.length-1&&(n+=s),t.push(n)}if(l)d=t.filter(e=>e!==``);else if(u){d=[];for(let n of t){if(n===``)continue;let t=HA(n,c,e.limits.maxArrayElements);lM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}}else{d=[];for(let n of t)if(n===``)d.push(``);else{let t=HA(n,c,e.limits.maxArrayElements);lM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}for(;d.length>0&&d[d.length-1]===``;)d.pop()}}return d.length===0?{values:[],quoted:!1}:{values:await FM(e,d),quoted:!1}}async function GM(e,t,n){e.coverage?.hit(`bash:expansion:word_glob`);let r=t.parts,{hasQuoted:i,hasCommandSub:a,hasArrayVar:o,hasArrayAtExpansion:s,hasParamExpansion:c,hasVarNamePrefixExpansion:l,hasIndirection:u}=OA(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return KM(e,d,i);let f=await qM(e,r,s,l,u,n);if(f!==null)return f;let p=await YM(e,r,n);if(p!==null)return p;let m=await XM(e,r,n);if(m!==null)return m;let h=await $M(e,r,n.expandPart);if(h!==null)return eN(e,h);if((a||o||c)&&!NA(e.state.env)){let t=MA(e.state.env),i=n.buildIfsCharClassPattern(t);return eN(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return nN(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function KM(e,t,n){let r=[];for(let i of t)!n&&i===``||(!n&&!e.state.options.noglob&&hj(i,e.state.shoptOptions.extglob)?lM(r,await tN(e,i),e.limits.maxArrayElements,`brace/glob expansion`):r.push(i));return{values:r,quoted:!1}}async function qM(e,t,n,r,i,a){if(n){let n=vM(e,t);if(n!==null)return n}{let n=yM(e,t);if(n!==null)return n}{let n=await pM(e,t);if(n!==null)return n}{let r=await mM(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await hM(e,t,n,a.expandPart);if(r!==null)return r}{let n=await gM(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=_M(e,t);if(n!==null)return n}{let n=await dM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await fM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=JM(e,t);if(n!==null)return n}{let n=await bM(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await CM(e,t);if(n!==null)return n}{let n=await wM(e,t);if(n!==null)return n}return null}function JM(e,t){let n=t[0];if(n.type!==`DoubleQuoted`)return null;if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`VarNamePrefix`){let t=n.parts[0].operation,r=Oj(e,t.prefix);return t.star?{values:[r.join(IA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`ArrayKeys`){let t=n.parts[0].operation,r=nj(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(IA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function YM(e,t,n){{let r=await OM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await kM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await AM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await jM(e,t,n.expandPart);if(r!==null)return r}return null}async function XM(e,t,n){{let r=await IM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await LM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await RM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await zM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await BM(e,t);if(n!==null)return n}{let n=await VM(e,t);if(n!==null)return n}{let n=HM(e,t);if(n!==null)return n}{let n=UM(e,t);if(n!==null)return n}{let r=await WM(e,t,n.expandPart);if(r!==null)return r}return null}function ZM(e){if(e.type!==`DoubleQuoted`)return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!==`ParameterExpansion`||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:`array`,name:r[1],atIndex:t,isStar:r[2]===`*`};if(n.parameter===`@`||n.parameter===`*`)return{type:`positional`,atIndex:t,isStar:n.parameter===`*`}}return null}async function QM(e,t,n,r){let i=``;for(let a=0;a<n.atIndex;a++)i+=await r(e,t.parts[a]);let a=``;for(let i=n.atIndex+1;i<t.parts.length;i++)a+=await r(e,t.parts[i]);let o;if(n.type===`array`){if(o=nj(e,n.name).map(([,e])=>e),o.length===0){let t=e.state.env.get(n.name);t!==void 0&&(o=[t])}}else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);o=[];for(let n=1;n<=t;n++)o.push(e.state.env.get(String(n))||``)}if(n.isStar){let t=IA(e.state.env),n=o.join(t);return[i+n+a]}if(o.length===0){let e=i+a;return e?[e]:[]}return o.length===1?[i+o[0]+a]:[i+o[0],...o.slice(1,-1),o[o.length-1]+a]}async function $M(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if(ZM(e)){r=!0;break}if(!r)return null;let i=MA(e.state.env),a=NA(e.state.env),o=[];for(let r of t){let t=ZM(r);if(t&&r.type===`DoubleQuoted`){let i=await QM(e,r,t,n);o.push(i)}else if(r.type===`DoubleQuoted`||r.type===`SingleQuoted`){let t=await n(e,r);o.push([t])}else if(r.type===`Literal`)o.push([r.value]);else if(r.type===`ParameterExpansion`){let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=HA(t,i,e.limits.maxArrayElements);o.push(n)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=HA(t,i,e.limits.maxArrayElements);o.push(n)}}}let s=[];for(let t of o)if(t.length!==0)if(s.length===0)lM(s,t,e.limits.maxArrayElements,`word expansion`);else{let e=s.length-1;s[e]=s[e]+t[0];for(let e=1;e<t.length;e++)s.push(t[e])}return s}async function eN(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)hj(r,e.state.shoptOptions.extglob)?lM(n,await tN(e,r),e.limits.maxArrayElements,`glob expansion`):n.push(r);return{values:n,quoted:!1}}async function tN(e,t){let n=new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new Dr(t);return n.hasNullglob()?[]:[t]}async function nN(e,t,n,r,i,a){let o=n.some(e=>e.type===`Glob`);if(!e.state.options.noglob&&o){let n=await a(e,t);if(hj(n,e.state.shoptOptions.extglob)){let t=await tN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=gj(r);return NA(e.state.env)?{values:[i],quoted:!1}:{values:HA(i,MA(e.state.env),e.limits.maxArrayElements),quoted:!1}}if(!i&&!e.state.options.noglob&&hj(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(hj(n,e.state.shoptOptions.extglob)){let t=await tN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1}}}if(r===``&&!i)return{values:[],quoted:!1};if(o&&!i){let t=gj(r);return NA(e.state.env)?{values:[t],quoted:!1}:{values:HA(t,MA(e.state.env),e.limits.maxArrayElements),quoted:!1}}return{values:[r],quoted:i}}j();function rN(e,t,n){if(t.length>=e.limits.maxArrayElements)throw new A(`word splitting element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);t.push(n)}async function iN(e,t){let n=t.operation;if(!n||n.type!==`DefaultValue`&&n.type!==`AssignDefault`&&n.type!==`UseAlternative`)return null;let r=n.word;if(!r||r.parts.length===0)return null;let i=await aj(e,t.parameter),a=await ij(e,t.parameter,!1)===``,o=n.checkEmpty??!1,s;return s=n.type===`UseAlternative`?i&&!(o&&a):!i||o&&a,s?r.parts:null}function aN(e){return e.type===`SingleQuoted`||e.type===`DoubleQuoted`&&e.parts.every(e=>e.type===`Literal`)}async function oN(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await iN(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>aN(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function sN(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?TA(e.pattern):!(e.type!==`ParameterExpansion`&&e.type!==`CommandSubstitution`&&e.type!==`ArithmeticExpansion`||e.type===`ParameterExpansion`&&DA(e))}async function cN(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await iN(e,a);if(o&&o.length>0&&o.length>1&&o.some(e=>e.type===`DoubleQuoted`||e.type===`SingleQuoted`)&&o.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`))return uN(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=sN(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await oN(e,n):null,c=await i(e,n);a.push({value:c,isSplittable:t,isQuoted:r,mixedDefaultParts:s??void 0}),t&&(o=!0)}if(!o){let e=a.map(e=>e.value).join(``);return e?[e]:[]}let s=[],c=``,l=!1,u=!1,d=!1;for(let t of a)if(!t.isSplittable)u?t.isQuoted&&t.value===``?(c!==``&&rN(e,s,c),rN(e,s,``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&rN(e,s,c),c=t.value,u=!1,d=!1):(c+=t.value,d=t.isQuoted&&t.value===``);else if(t.mixedDefaultParts){let a=await uN(e,t.mixedDefaultParts,n,r,i);if(a.length!==0)if(a.length===1)c+=a[0],l=!0;else{c+=a[0],rN(e,s,c),l=!0;for(let t=1;t<a.length-1;t++)rN(e,s,a[t]);c=a[a.length-1]}u=!1,d=!1}else{let{words:r,hadLeadingDelimiter:i,hadTrailingDelimiter:a}=VA(t.value,n,e.limits.maxArrayElements);if(d&&i&&c===``&&(rN(e,s,``),l=!0),r.length===0)a&&(u=!0);else if(r.length===1)c+=r[0],l=!0,u=a;else{c+=r[0],rN(e,s,c),l=!0;for(let t=1;t<r.length-1;t++)rN(e,s,r[t]);c=r[r.length-1],u=a}d=!1}return c===``?s.length===0&&l&&rN(e,s,``):rN(e,s,c),s}function lN(e,t){return e.length>0&&t.includes(e[0])}async function uN(e,t,n,r,i){let a=[];for(let n of t){let t=n.type!==`DoubleQuoted`&&n.type!==`SingleQuoted`,r=await i(e,n);a.push({value:r,isSplittable:t})}let o=[],s=``,c=!1,l=!1;for(let t of a)if(!t.isSplittable)l&&t.value!==``?(s!==``&&rN(e,o,s),s=t.value,l=!1):s+=t.value;else{lN(t.value,n)&&s!==``&&(rN(e,o,s),s=``,c=!0);let{words:r,hadTrailingDelimiter:i}=VA(t.value,n,e.limits.maxArrayElements);if(r.length===0)i&&(l=!0);else if(r.length===1)s+=r[0],c=!0,l=i;else{s+=r[0],rN(e,o,s),c=!0;for(let t=1;t<r.length-1;t++)rN(e,o,r[t]);s=r[r.length-1],l=i}}return s===``?o.length===0&&c&&rN(e,o,``):rN(e,o,s),o}function dN(e){switch(e.type){case`Literal`:return e.value;case`SingleQuoted`:return e.value;case`Escaped`:return e.value;default:return null}}function fN(e){switch(e.type){case`SingleQuoted`:case`Escaped`:case`DoubleQuoted`:return!0;case`Literal`:return e.value===``;default:return!1}}k(),k(),Zi();var pN=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new WE,e?.mounts)for(let{mountPoint:t,filesystem:n}of e.mounts)this.mount(t,n)}mount(e,t){this.validateMountPath(e);let n=I(e);this.validateMount(n),this.mounts.set(n,{mountPoint:n,filesystem:t})}unmount(e){let t=I(e);if(!this.mounts.has(t))throw Error(`No filesystem mounted at '${e}'`);this.mounts.delete(t)}getMounts(){return Array.from(this.mounts.values()).map(e=>({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let t=I(e);return this.mounts.has(t)}validateMountPath(e){let t=e.split(`/`);for(let n of t)if(n===`.`||n===`..`)throw Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e===`/`)throw Error(`Cannot mount at root '/'`);for(let t of this.mounts.keys())if(t!==e){if(e.startsWith(`${t}/`))throw Error(`Cannot mount at '${e}': inside existing mount '${t}'`);if(t.startsWith(`${e}/`))throw Error(`Cannot mount at '${e}': would contain existing mount '${t}'`)}}routePath(e){Ki(e,`access`);let t=I(e),n=null,r=0;for(let e of this.mounts.values()){let i=e.mountPoint;if(t===i)return{fs:e.filesystem,relativePath:`/`};t.startsWith(`${i}/`)&&i.length>r&&(n=e,r=i.length)}if(n){let e=t.slice(r);return{fs:n.filesystem,relativePath:e||`/`}}return{fs:this.baseFs,relativePath:t}}getChildMountPoints(e){let t=I(e),n=t===`/`?`/`:`${t}/`,r=[];for(let e of this.mounts.keys())if(e.startsWith(n)){let t=e.slice(n.length).split(`/`)[0];t&&!r.includes(t)&&r.push(t)}return r}async readFile(e,t){let{fs:n,relativePath:r}=this.routePath(e);return n.readFile(r,t)}async readFileBytes(e){let{fs:t,relativePath:n}=this.routePath(e);return lr(t,n)}async readFileBuffer(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readFileBuffer(n)}async writeFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.writeFile(i,t,n)}async appendFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.appendFile(i,t,n)}async exists(e){let t=I(e);if(this.mounts.has(t)||this.getChildMountPoints(t).length>0)return!0;let{fs:n,relativePath:r}=this.routePath(e);return n.exists(r)}async stat(e){let t=I(e),n=this.mounts.get(t);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(t).length>0)try{return await this.baseFs.stat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.stat(i)}async lstat(e){let t=I(e),n=this.mounts.get(t);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(t).length>0)try{return await this.baseFs.lstat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.lstat(i)}async mkdir(e,t){let n=I(e);if(this.mounts.has(n)){if(t?.recursive)return;throw Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(n).length>0&&t?.recursive)return;let{fs:r,relativePath:i}=this.routePath(e);return r.mkdir(i,t)}async readdir(e){let t=I(e),n=new Set,r=null,{fs:i,relativePath:a}=this.routePath(e);try{let e=await i.readdir(a);for(let t of e)n.add(t)}catch(e){let t=e.code,n=e.message||``;if(t!==`ENOENT`&&!n.includes(`ENOENT`))throw e;r=e}let o=this.getChildMountPoints(t);for(let e of o)n.add(e);if(n.size===0&&r&&!this.mounts.has(t))throw r;return Array.from(n).sort()}async rm(e,t){let n=I(e);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(n).length>0)throw Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:r,relativePath:i}=this.routePath(e);return r.rm(i,t)}async cp(e,t,n){if((await this.stat(e)).isDirectory&&Gi(e,t))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);let r=this.routePath(e),i=this.routePath(t);return r.fs===i.fs?r.fs.cp(r.relativePath,i.relativePath,n):this.crossMountCopy(e,t,n)}async mv(e,t){let n=I(e);if((await this.stat(e)).isDirectory&&Gi(e,t))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot move '${e}'`);let r=this.routePath(e),i=this.routePath(t);if(r.fs===i.fs)return r.fs.mv(r.relativePath,i.relativePath);await this.cp(e,t,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,t){return Ji(e,t)}getAllPaths(){let e=new Set;for(let t of this.baseFs.getAllPaths())e.add(t);for(let t of this.mounts.keys()){let n=t.split(`/`).filter(Boolean),r=``;for(let t of n)r=`${r}/${t}`,e.add(r);let i=this.mounts.get(t);if(i)for(let n of i.filesystem.getAllPaths())n===`/`?e.add(t):e.add(`${t}${n}`)}return Array.from(e).sort()}async chmod(e,t){let n=I(e),r=this.mounts.get(n);if(r)return r.filesystem.chmod(`/`,t);let{fs:i,relativePath:a}=this.routePath(e);return i.chmod(a,t)}async symlink(e,t){let{fs:n,relativePath:r}=this.routePath(t);return n.symlink(e,r)}async link(e,t){let n=this.routePath(e),r=this.routePath(t);if(n.fs!==r.fs)throw Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${t}'`);return n.fs.link(n.relativePath,r.relativePath)}async readlink(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readlink(n)}async realpath(e){let t=I(e);if(this.mounts.get(t))return t;let{fs:n,relativePath:r}=this.routePath(e),i=await n.realpath(r);for(let[e,n]of this.mounts)if(t===e||t.startsWith(`${e}/`))return i===`/`?e:`${e}${i}`;return i}async crossMountCopy(e,t,n){let r=await this.lstat(e);if(r.isFile){let n=await this.readFileBuffer(e);await this.writeFile(t,n),await this.chmod(t,r.mode)}else if(r.isDirectory){if(!n?.recursive)throw Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(t,{recursive:!0});let r=await this.readdir(e);for(let i of r){let r=Yi(e,i),a=Yi(t,i);await this.crossMountCopy(r,a,n)}}else if(r.isSymbolicLink){let n=await this.readlink(e);await this.symlink(n,t)}}async utimes(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.utimes(i,t,n)}};j();var mN=`/dev/fd`,hN=63,gN=hN-10+1,_N=class extends WE{isLiveDescriptor;constructor(e){super(),this.isLiveDescriptor=e}assertLiveDescriptor(e,t){this.isLiveDescriptor(e)||this.refuse(e,t)}refuse(e,t){throw Error(`EROFS: read-only file system, ${t} '${mN}${e}'`)}async writeFile(e,t,n){return this.assertLiveDescriptor(e,`write`),super.writeFile(e,t,n)}async appendFile(e,t,n){return this.assertLiveDescriptor(e,`append`),super.appendFile(e,t,n)}async rm(e,t){return this.assertLiveDescriptor(e,`rm`),super.rm(e,t)}async mkdir(e,t){this.refuse(e,`mkdir`)}async cp(e,t){this.refuse(t,`cp`)}async mv(e,t){this.refuse(t,`mv`)}async symlink(e,t){this.refuse(t,`symlink`)}async link(e,t){this.refuse(t,`link`)}async chmod(e,t){this.refuse(e,`chmod`)}async utimes(e,t,n){this.refuse(e,`utimes`)}};function vN(e){let t=new _N(t=>xN(e).some(e=>e.path===`${mN}${t}`));e.fs=new pN({base:e.fs,mounts:[{mountPoint:mN,filesystem:t}]}),e.state.processSubstitutionFsMounted=!0}async function yN(e,t,n){try{await e.fs.writeFile(t,n,`binary`);return}catch(t){if(e.state.processSubstitutionFsMounted)throw t;vN(e)}await e.fs.writeFile(t,n,`binary`)}async function bN(e,t){try{await e.fs.rm(t,{force:!0})}catch{}}function xN(e){let t=e.state.processSubstitutions;if(t)return t;let n=[];return e.state.processSubstitutions=n,n}async function SN(e,t,n){let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new A(`Process substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth,o=new Map(e.state.env),s=eD(e.state.arrays),c=e.state.cwd,l=e.state.bashPid,u=e.state.suppressVerbose,d=e.state.groupStdin,f=e.state.lastExitCode,p=e.state.env.get(`?`);e.substitutionDepth=r+1,e.state.bashPid=e.state.nextVirtualPid++,e.state.suppressVerbose=!0,n!==void 0&&(e.state.groupStdin=n);let m;try{m=await e.executeScript(t)}catch(e){if(e instanceof A)throw e;if(e instanceof wr)return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode};throw e}finally{e.substitutionDepth=a,e.state.env=o,e.state.arrays=s,e.state.cwd=c,e.state.bashPid=l,e.state.suppressVerbose=u,e.state.groupStdin=d,e.state.lastExitCode=f,p===void 0?e.state.env.delete(`?`):e.state.env.set(`?`,p)}return m}async function CN(e,t){let n=xN(e);if(n.length>=gN)throw new A(`Process substitution limit exceeded (${gN} concurrent)`,`file_descriptors`);let r=``;if(t.direction===`input`){let n=await SN(e,t.body,void 0);if(n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),r=dr(n),r.length>e.limits.maxStringLength)throw new A(`process substitution: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)}let i=hN-n.length,a=`${mN}/${i}`;n.push({fd:i,path:a,direction:t.direction,body:t.body});try{await yN(e,a,r)}catch(e){throw n.pop(),e}return a}function wN(e){return e.state.processSubstitutions?.length??0}var TN={stdout:``,stderr:``};async function EN(e,t){let n=e.state.processSubstitutions;if(!n||n.length<=t)return TN;let r=``,i=``;for(;n.length>t;){let t=n[n.length-1],a=``;if(t.direction===`output`)try{a=await lr(e.fs,t.path)}catch{}if(await bN(e,t.path),n.pop(),t.direction===`output`){let n=await SN(e,t.body,a);r+=dr(n),i+=n.stderr}}return{stdout:r,stderr:i}}function DN(e,t,n){if(e.length>t)throw new A(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function ON(e,t,n=!1){let r=[];for(let i of t)r.push(await KN(e,i,n));return r.join(``)}function kN(e){return fN(e)}function AN(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!kN(t))return!1;return!0}function jN(e,t,n=!1){let r=dN(t);if(r!==null)return r;switch(t.type){case`TildeExpansion`:return n?t.user===null?`~`:`~${t.user}`:(e.coverage?.hit(`bash:expansion:tilde`),t.user===null?e.state.env.get(`HOME`)??`/home/user`:t.user===`root`?`/root`:`~${t.user}`);case`Glob`:return rM(e,t.pattern);default:return null}}async function MN(e,t){return GN(e,t)}async function NN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(vj(r.value));else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await KN(e,r);n.push(vj(t))}else n.push(await KN(e,r));return n.join(``)}async function PN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`){let e=r.value;`()|*?[]`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`SingleQuoted`)n.push(_j(r.value));else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(_j(t))}else n.push(await KN(e,r));return n.join(``)}async function FN(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(_j(r.value));else if(r.type===`Escaped`){let e=r.value;`*?[]\\()|`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(_j(t))}else r.type===`Glob`?eM(r.pattern)?n.push(await aM(e,r.pattern)):n.push(rM(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await KN(e,r));return n.join(``)}function IN(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&IN(t.parts))return!0;return!1}var LN=1e5;async function RN(e,t,n={count:0}){let r=()=>{n.count++,e.executionScope.consumeLimited(`brace_operations`,1,Math.min(LN,e.limits.maxBraceExpansionResults),`brace expansion`)},i=(t,n)=>{if(t.length>=e.limits.maxBraceExpansionResults)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),t.push(n)},a=[[]];for(let o of t)if(o.type===`BraceExpansion`){let t=[],s=!1,c=``;for(let r of o.items)if(r.type===`Range`){let n=pj(r.start,r.end,r.step,r.startStr,r.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(n.expanded)for(let e of n.expanded)i(t,e);else{s=!0,c=n.literal;break}}else{let a=await RN(e,r.word.parts,n);for(let n of a){let r=[];for(let t of n)typeof t==`string`?r.push(t):r.push(await KN(e,t));i(t,r.join(``))}}if(s){for(let e of a)r(),e.push(c);continue}if(a.length*t.length>e.limits.maxBraceExpansionResults||n.count>LN)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);let l=[];for(let n of a)for(let i of t){if(l.length>=e.limits.maxBraceExpansionResults)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),l.push([...n,i])}a=l}else for(let e of a)r(),e.push(o);return a}async function zN(e,t){let n=t.parts;if(!IN(n))return[await MN(e,t)];let r=await RN(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await KN(e,r));i.push(sM(e,n.join(``)))}return i}function BN(){return{expandWordAsync:GN,expandWordForGlobbing:FN,expandWordWithBracesAsync:zN,expandWordPartsAsync:ON,expandPart:KN,expandParameterAsync:qN,hasBraceExpansion:IN,evaluateArithmetic:rP,buildIfsCharClassPattern:FA,smartWordSplit:cN}}async function VN(e,t){return GM(e,t,BN())}function HN(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function UN(e,t){if(Number.parseInt(e.state.env.get(`#`)||`0`,10)<2)return!1;function n(e){for(let t of e)if(t.type===`DoubleQuoted`){for(let e of t.parts)if(e.type===`ParameterExpansion`&&e.parameter===`@`&&!e.operation)return!0}return!1}return n(t.parts)}async function WN(e,t){if(UN(e,t))return{error:`bash: $@: ambiguous redirect
927
+ `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=nj(e,o);if(d.length>e.limits.maxArrayElements)throw new A(`array transform element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let f=0;if(l<0){if(d.length>0){let e=d[d.length-1][0],t=(typeof e==`number`?e:0)+1+l;if(t<0)return{values:[],quoted:!0};f=d.findIndex(([e])=>typeof e==`number`&&e>=t),f<0&&(f=d.length)}}else f=d.findIndex(([e])=>typeof e==`number`&&e>=l),f<0&&(f=d.length);let p;if(u!==void 0){if(u<0)throw new Tr(`${o}[@]: substring expression < 0`);p=d.slice(f,f+u).map(([,e])=>e)}else p=d.slice(f).map(([,e])=>e);if(p.length===0)return{values:[],quoted:!0};if(s){let t=IA(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,quoted:!0}}function _M(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`Transform`)return null;let r=n.parts[0],i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let a=i[1],o=i[2]===`*`,s=r.operation,c=nj(e,a);if(c.length===0){let t=e.state.env.get(a);if(t!==void 0){let n;switch(s.operator){case`a`:n=``;break;case`P`:n=Mj(e,t);break;case`Q`:n=Nj(t);break;default:n=t}if(O(n)>e.limits.maxStringLength)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[n],quoted:!0}}return o?{values:[``],quoted:!0}:{values:[],quoted:!0}}let l=zj(e,a),u=[],d=0;for(let[,t]of c){let n;switch(s.operator){case`a`:n=l;break;case`P`:n=Mj(e,t);break;case`Q`:n=Nj(t);break;case`u`:n=t.charAt(0).toUpperCase()+t.slice(1);break;case`U`:n=t.toUpperCase();break;case`L`:n=t.toLowerCase();break;default:n=t}let r=O(n);if(r>e.limits.maxStringLength-d)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);u.push(n),d+=r}if(o){let t=IA(e.state.env);if(Math.max(0,u.length-1)*O(t)>e.limits.maxStringLength-d)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[u.join(t)],quoted:!0}}return{values:u,quoted:!0}}function vM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`)return null;let r=n.parts[0];if(r.operation)return null;let i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!i)return null;let a=i[1];if(GA(e,a)){let t=$A(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=nj(e,a);if(o.length>0)return{values:o.map(([,e])=>e),quoted:!0};let s=e.state.env.get(a);return s===void 0?{values:[],quoted:!0}:{values:[s],quoted:!0}}function yM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation)return null;let r=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)||!GA(e,r))return null;let i=$A(e,r);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],s=nj(e,o);if(s.length>0)return{values:s.map(([,e])=>e),quoted:!0};let c=e.state.env.get(o);return c===void 0?{values:[],quoted:!0}:{values:[c],quoted:!0}}j();async function bM(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=o.operation,c=await ij(e,o.parameter),l=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l){if(!s.innerOp&&(c===`@`||c===`*`)){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return c===`*`?{values:[n.join(IA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=nj(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return xM(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return SM(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=zj(e,u),n=f.map(()=>t);return d?{values:[n.join(IA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}let t=[];for(let[,n]of f){let i={type:`ParameterExpansion`,parameter:`_indirect_elem_`,operation:s.innerOp},a=e.state.env.get(`_indirect_elem_`);e.state.env.set(`_indirect_elem_`,n);try{let n=await r(e,i,!0);t.push(n)}finally{a===void 0?e.state.env.delete(`_indirect_elem_`):e.state.env.set(`_indirect_elem_`,a)}}return d?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let p=e.state.env.get(u);return p===void 0?{values:[],quoted:!0}:{values:[p],quoted:!0}}async function xM(e,t,n,r,i){let a=i.offset?await rP(e,i.offset.expression):0,o=i.length?await rP(e,i.length.expression):void 0,s=0;if(a<0){if(t.length>0){let e=t[t.length-1][0],n=(typeof e==`number`?e:0)+1+a;if(n<0||(s=t.findIndex(([e])=>typeof e==`number`&&e>=n),s<0))return{values:[],quoted:!0}}}else if(s=t.findIndex(([e])=>typeof e==`number`&&e>=a),s<0)return{values:[],quoted:!0};let c;if(o!==void 0){if(o<0)throw new Tr(`${n}[@]: substring expression < 0`);c=t.slice(s,s+o)}else c=t.slice(s);let l=c.map(([,e])=>e);return r?{values:[l.join(IA(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function SM(e,t,n,r,i,a){let o=i.checkEmpty??!1,s=t.map(([,e])=>e),c=t.length===0,l=t.length===0;if(i.type===`UseAlternative`)return!l&&!(o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(i.type===`DefaultValue`)return(l||o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0};if(i.type===`AssignDefault`){if((l||o&&c)&&i.word){let t=await a(e,i.word.parts,!0);return Y(e,n,0,t),{values:[t],quoted:!0}}return r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function CM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`UseAlternative`&&t[0].operation?.type!==`DefaultValue`)return null;let n=t[0],r=n.operation,i=r?.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await ij(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await aj(e,n.parameter),l=await ij(e,n.parameter)===``,u=r.checkEmpty??!1,d;if(d=r.type===`UseAlternative`?c&&!(u&&l):!c||u&&l,d){let t=s[1],n=s[2]===`*`,r=nj(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}async function wM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`Indirection`)return null;let n=t[0],r=n.operation.innerOp;if(!r||r.type!==`UseAlternative`&&r.type!==`DefaultValue`)return null;let i=r.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await ij(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await ij(e,n.parameter),l=await aj(e,n.parameter),u=c===``,d=r.checkEmpty??!1,f;if(f=r.type===`UseAlternative`?l&&!(d&&u):!l||d&&u,f){let t=s[1],n=s[2]===`*`,r=nj(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}Lr(),mc(),j();function TM(e){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t>e.limits.maxArrayElements)throw new A(`positional parameter element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=[],r=0;for(let i=1;i<=t;i++){let t=e.state.env.get(String(i))||``,a=O(t);if(a>e.limits.maxStringLength-r)throw new A(`positional parameter string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n.push(t),r+=a}return n}function EM(e,t,n){if(O(t)>n-O(e))throw new A(`positional expansion string limit exceeded (${n} bytes)`,`string_length`);return e+t}function DM(e,t,n,r){if(e.length>=r.limits.maxArrayElements)throw new A(`positional expansion element limit exceeded (${r.limits.maxArrayElements})`,`array_elements`);let i=O(t);if(i>r.limits.maxStringLength-n.value)throw new A(`positional expansion string limit exceeded (${r.limits.maxStringLength} bytes)`,`string_length`);e.push(t),n.value+=i}async function OM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`Substring`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=s.offset?await n(e,s.offset.expression):0,l=s.length?await n(e,s.length.expression):void 0,u=Number.parseInt(e.state.env.get(`#`)||`0`,10),d=[];for(let t=1;t<=u;t++)d.push(e.state.env.get(String(t))||``);let f=e.state.env.get(`0`)||`bash`,p;if(c<=0){let e=[f,...d],t=e.length+c;if(t<0)p=[];else{let n=c<0?t:0;if(l!==void 0){let t=l<0?e.length+l:n+l;p=e.slice(n,Math.max(n,t))}else p=e.slice(n)}}else{let e=c-1;if(e>=d.length)p=[];else if(l!==void 0){let t=l<0?d.length+l:e+l;p=d.slice(e,Math.max(e,t))}else p=d.slice(e)}let m=``;for(let t=0;t<a;t++)m+=await r(e,i.parts[t]);let h=``;for(let t=a+1;t<i.parts.length;t++)h+=await r(e,i.parts[t]);if(p.length===0){let e=m+h;return{values:e?[e]:[],quoted:!0}}if(o){let t=IA(e.state.env);return{values:[m+p.join(t)+h],quoted:!0}}return p.length===1?{values:[m+p[0]+h],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+h],quoted:!0}}async function kM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternReplacement`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=TM(e),l=``;for(let t=0;t<a;t++)l=EM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=EM(u,await n(e,i.parts[t]),e.limits.maxStringLength);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=bj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)d+=bj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=bj(r,!0,e.state.shoptOptions.extglob)}else{let r=await n(e,t);d+=yj(r)}let f=s.replacement?await r(e,s.replacement.parts):``,p=d;s.anchor===`start`?p=`^${d}`:s.anchor===`end`&&(p=`${d}$`);let m=[],h={value:0};try{let t=U(p,s.all?`g`:``);for(let n of c){let r=0;t.lastIndex=0;for(let e=t.exec(n);e&&(r++,s.all);e=t.exec(n))e[0].length===0&&t.lastIndex++;let i=O(n),a=O(f),o=0,c=/\$(?:\$|&|\d+|<[^>]+>|`|')/g;for(;c.exec(f)!==null;)o++;if(i+r*a+r*o*i>e.limits.maxStringLength-h.value)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);DM(m,t.replace(n,f),h,e)}}catch(t){if(t instanceof A)throw t;for(let t of c)DM(m,t,h,e)}if(o){let t=IA(e.state.env);if(h.value+Math.max(0,m.length-1)*O(t)+O(l)+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+m.join(t)+u],quoted:!0}}if(O(l)+h.value+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return m.length===1?{values:[l+m[0]+u],quoted:!0}:{values:[l+m[0],...m.slice(1,-1),m[m.length-1]+u],quoted:!0}}async function AM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternRemoval`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=TM(e),l=``;for(let t=0;t<a;t++)l=EM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=EM(u,await n(e,i.parts[t]),e.limits.maxStringLength);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``,f=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=bj(t.pattern,s.greedy,f);else if(t.type===`Literal`)d+=bj(t.value,s.greedy,f);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=bj(r,s.greedy,f)}else{let r=await n(e,t);d+=yj(r)}let p=[],m={value:0};for(let t of c)DM(p,Dj(e,t,d,s.side,s.greedy),m,e);if(o){let t=IA(e.state.env);if(m.value+Math.max(0,p.length-1)*O(t)+O(l)+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+p.join(t)+u],quoted:!0}}if(O(l)+m.value+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return p.length===1?{values:[l+p[0]+u],quoted:!0}:{values:[l+p[0],...p.slice(1,-1),p[p.length-1]+u],quoted:!0}}async function jM(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0],i=-1,a=!1;for(let e=0;e<r.parts.length;e++){let t=r.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)){i=e,a=t.parameter===`*`;break}}if(i===-1)return null;let o=r.parts[i];if(o.type===`ParameterExpansion`&&o.operation)return null;let s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=``;for(let t=0;t<i;t++)c+=await n(e,r.parts[t]);let l=``;for(let t=i+1;t<r.parts.length;t++)l+=await n(e,r.parts[t]);if(s===0){if(a)return{values:[c+l],quoted:!0};let e=c+l;return{values:e?[e]:[],quoted:!0}}let u=[];for(let t=1;t<=s;t++)u.push(e.state.env.get(String(t))||``);if(a){let t=IA(e.state.env);return{values:[c+u.join(t)+l],quoted:!0}}return u.length===1?{values:[c+u[0]+l],quoted:!0}:{values:[c+u[0],...u.slice(1,-1),u[u.length-1]+l],quoted:!0}}k(),mc(),j();function MM(e,t,n,r){if(t.length>=e.limits.maxArrayElements)throw new A(`unquoted expansion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let i=O(n);if(i>e.limits.maxStringLength-r.value)throw new A(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);t.push(n),r.value+=i}function NM(e,t,n,r){let i=O(n),a=Math.max(0,t.length-1);if(i>0&&a>Math.floor((e.limits.maxStringLength-r)/i))throw new A(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return t.join(n)}function PM(e){return new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)})}async function FM(e,t){if(e.state.options.noglob)return t;let n=PM(e),r=[];for(let i of t)if(hj(i,e.state.shoptOptions.extglob)){let t=await n.expand(i);if(t.length>0)lM(r,t,e.limits.maxArrayElements,`unquoted glob expansion`);else{if(n.hasFailglob())throw new Dr(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function IM(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternReplacement`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=nj(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=bj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=bj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=bj(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=yj(n)}let d=s.replacement?await n(e,s.replacement.parts):``,f=u;s.anchor===`start`?f=`^${u}`:s.anchor===`end`&&(f=`${u}$`);let p=[],m={value:0};try{let t=U(f,s.all?`g`:``);for(let n of l)MM(e,p,kj(e,n,t,d,s.all),m)}catch(t){if(t instanceof A)throw t;for(let t of l)MM(e,p,t,m)}let h=MA(e.state.env),g=NA(e.state.env);if(o){let t=NM(e,p,IA(e.state.env),m.value);return g?{values:t?[t]:[],quoted:!1}:{values:HA(t,h,e.limits.maxArrayElements),quoted:!1}}if(g)return{values:p,quoted:!1};let _=[],v={value:0};for(let t of p)if(t===``)MM(e,_,``,v);else for(let n of HA(t,h,e.limits.maxArrayElements))MM(e,_,n,v);return{values:_,quoted:!1}}async function LM(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternRemoval`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=nj(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``,d=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=bj(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=bj(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=bj(n,s.greedy,d)}else{let n=await r(e,t);u+=yj(n)}let f=[],p={value:0};for(let t of l)MM(e,f,Dj(e,t,u,s.side,s.greedy),p);let m=MA(e.state.env),h=NA(e.state.env);if(o){let t=NM(e,f,IA(e.state.env),p.value);return h?{values:t?[t]:[],quoted:!1}:{values:HA(t,m,e.limits.maxArrayElements),quoted:!1}}if(h)return{values:f,quoted:!1};let g=[],_={value:0};for(let t of f)if(t===``)MM(e,g,``,_);else for(let n of HA(t,m,e.limits.maxArrayElements))MM(e,g,n,_);return{values:g,quoted:!1}}async function RM(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`PatternRemoval`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=[];for(let t=1;t<=s;t++)c.push(e.state.env.get(String(t))||``);if(c.length===0)return{values:[],quoted:!1};let l=``,u=e.state.shoptOptions.extglob;if(o.pattern)for(let t of o.pattern.parts)if(t.type===`Glob`)l+=bj(t.pattern,o.greedy,u);else if(t.type===`Literal`)l+=bj(t.value,o.greedy,u);else if(t.type===`SingleQuoted`||t.type===`Escaped`)l+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);l+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);l+=bj(n,o.greedy,u)}else{let n=await r(e,t);l+=yj(n)}let d=[],f={value:0};for(let t of c)MM(e,d,Dj(e,t,l,o.side,o.greedy),f);let p=MA(e.state.env),m=NA(e.state.env);if(a){let t=NM(e,d,IA(e.state.env),f.value);return m?{values:t?[t]:[],quoted:!1}:{values:HA(t,p,e.limits.maxArrayElements),quoted:!1}}if(m)return{values:d,quoted:!1};let h=[],g={value:0};for(let t of d)if(t===``)MM(e,h,``,g);else for(let n of HA(t,p,e.limits.maxArrayElements))MM(e,h,n,g);return{values:h,quoted:!1}}async function zM(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`Substring`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=o.offset?await n(e,o.offset.expression):0,c=o.length?await n(e,o.length.expression):void 0,l=Number.parseInt(e.state.env.get(`#`)||`0`,10),u=[];for(let t=1;t<=l;t++)u.push(e.state.env.get(String(t))||``);let d=e.state.env.get(`0`)||`bash`,f;if(s<=0){let e=[d,...u],t=e.length+s;if(t<0)f=[];else{let n=s<0?t:0;if(c!==void 0){let t=c<0?e.length+c:n+c;f=e.slice(n,Math.max(n,t))}else f=e.slice(n)}}else{let e=s-1;if(e>=u.length)f=[];else if(c!==void 0){let t=c<0?u.length+c:e+c;f=u.slice(e,Math.max(e,t))}else f=u.slice(e)}let p=``;for(let n=0;n<i;n++)p+=await r(e,t[n]);let m=``;for(let n=i+1;n<t.length;n++)m+=await r(e,t[n]);let h=MA(e.state.env),g=NA(e.state.env);if(f.length===0){let t=p+m;return t?g?{values:[t],quoted:!1}:{values:HA(t,h,e.limits.maxArrayElements),quoted:!1}:{values:[],quoted:!1}}let _;if(a){let t=IA(e.state.env),n=p+f.join(t)+m;_=g?n?[n]:[]:HA(n,h,e.limits.maxArrayElements)}else if(g)_=f.length===1?[p+f[0]+m]:[p+f[0],...f.slice(1,-1),f[f.length-1]+m];else{_=[];for(let t=0;t<f.length;t++){let n=f[t];if(t===0&&(n=p+n),t===f.length-1&&(n+=m),n===``)_.push(``);else{let t=HA(n,h,e.limits.maxArrayElements);lM(_,t,e.limits.maxArrayElements,`unquoted expansion`)}}}return{values:await FM(e,_),quoted:!1}}async function BM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].parameter!==`@`&&t[0].parameter!==`*`||t[0].operation)return null;let n=t[0].parameter===`*`,r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(r===0)return{values:[],quoted:!1};let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=MA(e.state.env),o=NA(e.state.env),s=PA(e.state.env),c;if(n){if(o)c=i.filter(e=>e!==``);else{let t=IA(e.state.env);c=HA(i.join(t),a,e.limits.maxArrayElements)}}else if(o)c=i.filter(e=>e!==``);else if(s){c=[];for(let t of i){if(t===``)continue;let n=HA(t,a,e.limits.maxArrayElements);lM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{c=[];for(let t of i)if(t===``)c.push(``);else{let n=HA(t,a,e.limits.maxArrayElements);lM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await FM(e,c),quoted:!1}}async function VM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],i=n[2]===`*`,a=nj(e,r),o;if(a.length===0){let t=e.state.env.get(r);if(t!==void 0)o=[t];else return{values:[],quoted:!1}}else o=a.map(([,e])=>e);let s=MA(e.state.env),c=NA(e.state.env),l=PA(e.state.env),u;if(i){if(c)u=o.filter(e=>e!==``);else{let t=IA(e.state.env);u=HA(o.join(t),s,e.limits.maxArrayElements)}}else if(c)u=o.filter(e=>e!==``);else if(l){u=[];for(let t of o){if(t===``)continue;let n=HA(t,s,e.limits.maxArrayElements);lM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{u=[];for(let t of o)if(t===``)u.push(``);else{let n=HA(t,s,e.limits.maxArrayElements);lM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await FM(e,u),quoted:!1}}function HM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=Oj(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=MA(e.state.env),a=NA(e.state.env),o;if(n.star){if(a)o=r;else{let t=IA(e.state.env);o=HA(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=HA(t,i,e.limits.maxArrayElements);lM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}function UM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=nj(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=MA(e.state.env),a=NA(e.state.env),o;if(n.star){if(a)o=r;else{let t=IA(e.state.env);o=HA(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=HA(t,i,e.limits.maxArrayElements);lM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}async function WM(e,t,n){let r=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&!n.operation){r=e;break}}if(r===-1||t.length<=1)return null;let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=[];for(let t=1;t<=i;t++)a.push(e.state.env.get(String(t))||``);let o=``;for(let i=0;i<r;i++)o+=await n(e,t[i]);let s=``;for(let i=r+1;i<t.length;i++)s+=await n(e,t[i]);let c=MA(e.state.env),l=NA(e.state.env),u=PA(e.state.env);if(i===0){let e=o+s;return{values:e?[e]:[],quoted:!1}}let d;{let t=[];for(let e=0;e<a.length;e++){let n=a[e];e===0&&(n=o+n),e===a.length-1&&(n+=s),t.push(n)}if(l)d=t.filter(e=>e!==``);else if(u){d=[];for(let n of t){if(n===``)continue;let t=HA(n,c,e.limits.maxArrayElements);lM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}}else{d=[];for(let n of t)if(n===``)d.push(``);else{let t=HA(n,c,e.limits.maxArrayElements);lM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}for(;d.length>0&&d[d.length-1]===``;)d.pop()}}return d.length===0?{values:[],quoted:!1}:{values:await FM(e,d),quoted:!1}}async function GM(e,t,n){e.coverage?.hit(`bash:expansion:word_glob`);let r=t.parts,{hasQuoted:i,hasCommandSub:a,hasArrayVar:o,hasArrayAtExpansion:s,hasParamExpansion:c,hasVarNamePrefixExpansion:l,hasIndirection:u}=OA(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return KM(e,d,i);let f=await qM(e,r,s,l,u,n);if(f!==null)return f;let p=await YM(e,r,n);if(p!==null)return p;let m=await XM(e,r,n);if(m!==null)return m;let h=await $M(e,r,n.expandPart);if(h!==null)return eN(e,h);if((a||o||c)&&!NA(e.state.env)){let t=MA(e.state.env),i=n.buildIfsCharClassPattern(t);return eN(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return nN(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function KM(e,t,n){let r=[];for(let i of t)!n&&i===``||(!n&&!e.state.options.noglob&&hj(i,e.state.shoptOptions.extglob)?lM(r,await tN(e,i),e.limits.maxArrayElements,`brace/glob expansion`):r.push(i));return{values:r,quoted:!1}}async function qM(e,t,n,r,i,a){if(n){let n=vM(e,t);if(n!==null)return n}{let n=yM(e,t);if(n!==null)return n}{let n=await pM(e,t);if(n!==null)return n}{let r=await mM(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await hM(e,t,n,a.expandPart);if(r!==null)return r}{let n=await gM(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=_M(e,t);if(n!==null)return n}{let n=await dM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await fM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=JM(e,t);if(n!==null)return n}{let n=await bM(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await CM(e,t);if(n!==null)return n}{let n=await wM(e,t);if(n!==null)return n}return null}function JM(e,t){let n=t[0];if(n.type!==`DoubleQuoted`)return null;if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`VarNamePrefix`){let t=n.parts[0].operation,r=Oj(e,t.prefix);return t.star?{values:[r.join(IA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`ArrayKeys`){let t=n.parts[0].operation,r=nj(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(IA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function YM(e,t,n){{let r=await OM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await kM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await AM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await jM(e,t,n.expandPart);if(r!==null)return r}return null}async function XM(e,t,n){{let r=await IM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await LM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await RM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await zM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await BM(e,t);if(n!==null)return n}{let n=await VM(e,t);if(n!==null)return n}{let n=HM(e,t);if(n!==null)return n}{let n=UM(e,t);if(n!==null)return n}{let r=await WM(e,t,n.expandPart);if(r!==null)return r}return null}function ZM(e){if(e.type!==`DoubleQuoted`)return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!==`ParameterExpansion`||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:`array`,name:r[1],atIndex:t,isStar:r[2]===`*`};if(n.parameter===`@`||n.parameter===`*`)return{type:`positional`,atIndex:t,isStar:n.parameter===`*`}}return null}async function QM(e,t,n,r){let i=``;for(let a=0;a<n.atIndex;a++)i+=await r(e,t.parts[a]);let a=``;for(let i=n.atIndex+1;i<t.parts.length;i++)a+=await r(e,t.parts[i]);let o;if(n.type===`array`){if(o=nj(e,n.name).map(([,e])=>e),o.length===0){let t=e.state.env.get(n.name);t!==void 0&&(o=[t])}}else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);o=[];for(let n=1;n<=t;n++)o.push(e.state.env.get(String(n))||``)}if(n.isStar){let t=IA(e.state.env),n=o.join(t);return[i+n+a]}if(o.length===0){let e=i+a;return e?[e]:[]}return o.length===1?[i+o[0]+a]:[i+o[0],...o.slice(1,-1),o[o.length-1]+a]}async function $M(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if(ZM(e)){r=!0;break}if(!r)return null;let i=MA(e.state.env),a=NA(e.state.env),o=[];for(let r of t){let t=ZM(r);if(t&&r.type===`DoubleQuoted`){let i=await QM(e,r,t,n);o.push(i)}else if(r.type===`DoubleQuoted`||r.type===`SingleQuoted`){let t=await n(e,r);o.push([t])}else if(r.type===`Literal`)o.push([r.value]);else if(r.type===`ParameterExpansion`){let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=HA(t,i,e.limits.maxArrayElements);o.push(n)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=HA(t,i,e.limits.maxArrayElements);o.push(n)}}}let s=[];for(let t of o)if(t.length!==0){if(s.length===0)lM(s,t,e.limits.maxArrayElements,`word expansion`);else{let e=s.length-1;s[e]=s[e]+t[0];for(let e=1;e<t.length;e++)s.push(t[e])}}return s}async function eN(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)hj(r,e.state.shoptOptions.extglob)?lM(n,await tN(e,r),e.limits.maxArrayElements,`glob expansion`):n.push(r);return{values:n,quoted:!1}}async function tN(e,t){let n=new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new Dr(t);return n.hasNullglob()?[]:[t]}async function nN(e,t,n,r,i,a){let o=n.some(e=>e.type===`Glob`);if(!e.state.options.noglob&&o){let n=await a(e,t);if(hj(n,e.state.shoptOptions.extglob)){let t=await tN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=gj(r);return NA(e.state.env)?{values:[i],quoted:!1}:{values:HA(i,MA(e.state.env),e.limits.maxArrayElements),quoted:!1}}if(!i&&!e.state.options.noglob&&hj(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(hj(n,e.state.shoptOptions.extglob)){let t=await tN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1}}}if(r===``&&!i)return{values:[],quoted:!1};if(o&&!i){let t=gj(r);return NA(e.state.env)?{values:[t],quoted:!1}:{values:HA(t,MA(e.state.env),e.limits.maxArrayElements),quoted:!1}}return{values:[r],quoted:i}}j();function rN(e,t,n){if(t.length>=e.limits.maxArrayElements)throw new A(`word splitting element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);t.push(n)}async function iN(e,t){let n=t.operation;if(!n||n.type!==`DefaultValue`&&n.type!==`AssignDefault`&&n.type!==`UseAlternative`)return null;let r=n.word;if(!r||r.parts.length===0)return null;let i=await aj(e,t.parameter),a=await ij(e,t.parameter,!1)===``,o=n.checkEmpty??!1,s;return s=n.type===`UseAlternative`?i&&!(o&&a):!i||o&&a,s?r.parts:null}function aN(e){return e.type===`SingleQuoted`||e.type===`DoubleQuoted`&&e.parts.every(e=>e.type===`Literal`)}async function oN(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await iN(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>aN(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function sN(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?TA(e.pattern):!(e.type!==`ParameterExpansion`&&e.type!==`CommandSubstitution`&&e.type!==`ArithmeticExpansion`||e.type===`ParameterExpansion`&&DA(e))}async function cN(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await iN(e,a);if(o&&o.length>0&&o.length>1&&o.some(e=>e.type===`DoubleQuoted`||e.type===`SingleQuoted`)&&o.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`))return uN(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=sN(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await oN(e,n):null,c=await i(e,n);a.push({value:c,isSplittable:t,isQuoted:r,mixedDefaultParts:s??void 0}),t&&(o=!0)}if(!o){let e=a.map(e=>e.value).join(``);return e?[e]:[]}let s=[],c=``,l=!1,u=!1,d=!1;for(let t of a)if(!t.isSplittable)u?t.isQuoted&&t.value===``?(c!==``&&rN(e,s,c),rN(e,s,``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&rN(e,s,c),c=t.value,u=!1,d=!1):(c+=t.value,d=t.isQuoted&&t.value===``);else if(t.mixedDefaultParts){let a=await uN(e,t.mixedDefaultParts,n,r,i);if(a.length!==0){if(a.length===1)c+=a[0],l=!0;else{c+=a[0],rN(e,s,c),l=!0;for(let t=1;t<a.length-1;t++)rN(e,s,a[t]);c=a[a.length-1]}}u=!1,d=!1}else{let{words:r,hadLeadingDelimiter:i,hadTrailingDelimiter:a}=VA(t.value,n,e.limits.maxArrayElements);if(d&&i&&c===``&&(rN(e,s,``),l=!0),r.length===0)a&&(u=!0);else if(r.length===1)c+=r[0],l=!0,u=a;else{c+=r[0],rN(e,s,c),l=!0;for(let t=1;t<r.length-1;t++)rN(e,s,r[t]);c=r[r.length-1],u=a}d=!1}return c===``?s.length===0&&l&&rN(e,s,``):rN(e,s,c),s}function lN(e,t){return e.length>0&&t.includes(e[0])}async function uN(e,t,n,r,i){let a=[];for(let n of t){let t=n.type!==`DoubleQuoted`&&n.type!==`SingleQuoted`,r=await i(e,n);a.push({value:r,isSplittable:t})}let o=[],s=``,c=!1,l=!1;for(let t of a)if(!t.isSplittable)l&&t.value!==``?(s!==``&&rN(e,o,s),s=t.value,l=!1):s+=t.value;else{lN(t.value,n)&&s!==``&&(rN(e,o,s),s=``,c=!0);let{words:r,hadTrailingDelimiter:i}=VA(t.value,n,e.limits.maxArrayElements);if(r.length===0)i&&(l=!0);else if(r.length===1)s+=r[0],c=!0,l=i;else{s+=r[0],rN(e,o,s),c=!0;for(let t=1;t<r.length-1;t++)rN(e,o,r[t]);s=r[r.length-1],l=i}}return s===``?o.length===0&&c&&rN(e,o,``):rN(e,o,s),o}function dN(e){switch(e.type){case`Literal`:return e.value;case`SingleQuoted`:return e.value;case`Escaped`:return e.value;default:return null}}function fN(e){switch(e.type){case`SingleQuoted`:case`Escaped`:case`DoubleQuoted`:return!0;case`Literal`:return e.value===``;default:return!1}}k(),k(),Zi();var pN=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new WE,e?.mounts)for(let{mountPoint:t,filesystem:n}of e.mounts)this.mount(t,n)}mount(e,t){this.validateMountPath(e);let n=I(e);this.validateMount(n),this.mounts.set(n,{mountPoint:n,filesystem:t})}unmount(e){let t=I(e);if(!this.mounts.has(t))throw Error(`No filesystem mounted at '${e}'`);this.mounts.delete(t)}getMounts(){return Array.from(this.mounts.values()).map(e=>({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let t=I(e);return this.mounts.has(t)}validateMountPath(e){let t=e.split(`/`);for(let n of t)if(n===`.`||n===`..`)throw Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e===`/`)throw Error(`Cannot mount at root '/'`);for(let t of this.mounts.keys())if(t!==e){if(e.startsWith(`${t}/`))throw Error(`Cannot mount at '${e}': inside existing mount '${t}'`);if(t.startsWith(`${e}/`))throw Error(`Cannot mount at '${e}': would contain existing mount '${t}'`)}}routePath(e){Ki(e,`access`);let t=I(e),n=null,r=0;for(let e of this.mounts.values()){let i=e.mountPoint;if(t===i)return{fs:e.filesystem,relativePath:`/`};t.startsWith(`${i}/`)&&i.length>r&&(n=e,r=i.length)}if(n){let e=t.slice(r);return{fs:n.filesystem,relativePath:e||`/`}}return{fs:this.baseFs,relativePath:t}}getChildMountPoints(e){let t=I(e),n=t===`/`?`/`:`${t}/`,r=[];for(let e of this.mounts.keys())if(e.startsWith(n)){let t=e.slice(n.length).split(`/`)[0];t&&!r.includes(t)&&r.push(t)}return r}async readFile(e,t){let{fs:n,relativePath:r}=this.routePath(e);return n.readFile(r,t)}async readFileBytes(e){let{fs:t,relativePath:n}=this.routePath(e);return lr(t,n)}async readFileBuffer(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readFileBuffer(n)}async writeFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.writeFile(i,t,n)}async appendFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.appendFile(i,t,n)}async exists(e){let t=I(e);if(this.mounts.has(t)||this.getChildMountPoints(t).length>0)return!0;let{fs:n,relativePath:r}=this.routePath(e);return n.exists(r)}async stat(e){let t=I(e),n=this.mounts.get(t);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(t).length>0)try{return await this.baseFs.stat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.stat(i)}async lstat(e){let t=I(e),n=this.mounts.get(t);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(t).length>0)try{return await this.baseFs.lstat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.lstat(i)}async mkdir(e,t){let n=I(e);if(this.mounts.has(n)){if(t?.recursive)return;throw Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(n).length>0&&t?.recursive)return;let{fs:r,relativePath:i}=this.routePath(e);return r.mkdir(i,t)}async readdir(e){let t=I(e),n=new Set,r=null,{fs:i,relativePath:a}=this.routePath(e);try{let e=await i.readdir(a);for(let t of e)n.add(t)}catch(e){let t=e.code,n=e.message||``;if(t!==`ENOENT`&&!n.includes(`ENOENT`))throw e;r=e}let o=this.getChildMountPoints(t);for(let e of o)n.add(e);if(n.size===0&&r&&!this.mounts.has(t))throw r;return Array.from(n).sort()}async rm(e,t){let n=I(e);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(n).length>0)throw Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:r,relativePath:i}=this.routePath(e);return r.rm(i,t)}async cp(e,t,n){if((await this.stat(e)).isDirectory&&Gi(e,t))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);let r=this.routePath(e),i=this.routePath(t);return r.fs===i.fs?r.fs.cp(r.relativePath,i.relativePath,n):this.crossMountCopy(e,t,n)}async mv(e,t){let n=I(e);if((await this.stat(e)).isDirectory&&Gi(e,t))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot move '${e}'`);let r=this.routePath(e),i=this.routePath(t);if(r.fs===i.fs)return r.fs.mv(r.relativePath,i.relativePath);await this.cp(e,t,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,t){return Ji(e,t)}getAllPaths(){let e=new Set;for(let t of this.baseFs.getAllPaths())e.add(t);for(let t of this.mounts.keys()){let n=t.split(`/`).filter(Boolean),r=``;for(let t of n)r=`${r}/${t}`,e.add(r);let i=this.mounts.get(t);if(i)for(let n of i.filesystem.getAllPaths())n===`/`?e.add(t):e.add(`${t}${n}`)}return Array.from(e).sort()}async chmod(e,t){let n=I(e),r=this.mounts.get(n);if(r)return r.filesystem.chmod(`/`,t);let{fs:i,relativePath:a}=this.routePath(e);return i.chmod(a,t)}async symlink(e,t){let{fs:n,relativePath:r}=this.routePath(t);return n.symlink(e,r)}async link(e,t){let n=this.routePath(e),r=this.routePath(t);if(n.fs!==r.fs)throw Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${t}'`);return n.fs.link(n.relativePath,r.relativePath)}async readlink(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readlink(n)}async realpath(e){let t=I(e);if(this.mounts.get(t))return t;let{fs:n,relativePath:r}=this.routePath(e),i=await n.realpath(r);for(let[e,n]of this.mounts)if(t===e||t.startsWith(`${e}/`))return i===`/`?e:`${e}${i}`;return i}async crossMountCopy(e,t,n){let r=await this.lstat(e);if(r.isFile){let n=await this.readFileBuffer(e);await this.writeFile(t,n),await this.chmod(t,r.mode)}else if(r.isDirectory){if(!n?.recursive)throw Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(t,{recursive:!0});let r=await this.readdir(e);for(let i of r){let r=Yi(e,i),a=Yi(t,i);await this.crossMountCopy(r,a,n)}}else if(r.isSymbolicLink){let n=await this.readlink(e);await this.symlink(n,t)}}async utimes(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.utimes(i,t,n)}};j();var mN=`/dev/fd`,hN=63,gN=hN-10+1,_N=class extends WE{isLiveDescriptor;constructor(e){super(),this.isLiveDescriptor=e}assertLiveDescriptor(e,t){this.isLiveDescriptor(e)||this.refuse(e,t)}refuse(e,t){throw Error(`EROFS: read-only file system, ${t} '${mN}${e}'`)}async writeFile(e,t,n){return this.assertLiveDescriptor(e,`write`),super.writeFile(e,t,n)}async appendFile(e,t,n){return this.assertLiveDescriptor(e,`append`),super.appendFile(e,t,n)}async rm(e,t){return this.assertLiveDescriptor(e,`rm`),super.rm(e,t)}async mkdir(e,t){this.refuse(e,`mkdir`)}async cp(e,t){this.refuse(t,`cp`)}async mv(e,t){this.refuse(t,`mv`)}async symlink(e,t){this.refuse(t,`symlink`)}async link(e,t){this.refuse(t,`link`)}async chmod(e,t){this.refuse(e,`chmod`)}async utimes(e,t,n){this.refuse(e,`utimes`)}};function vN(e){let t=new _N(t=>xN(e).some(e=>e.path===`${mN}${t}`));e.fs=new pN({base:e.fs,mounts:[{mountPoint:mN,filesystem:t}]}),e.state.processSubstitutionFsMounted=!0}async function yN(e,t,n){try{await e.fs.writeFile(t,n,`binary`);return}catch(t){if(e.state.processSubstitutionFsMounted)throw t;vN(e)}await e.fs.writeFile(t,n,`binary`)}async function bN(e,t){try{await e.fs.rm(t,{force:!0})}catch{}}function xN(e){let t=e.state.processSubstitutions;if(t)return t;let n=[];return e.state.processSubstitutions=n,n}async function SN(e,t,n){let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new A(`Process substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth,o=new Map(e.state.env),s=eD(e.state.arrays),c=e.state.cwd,l=e.state.bashPid,u=e.state.suppressVerbose,d=e.state.groupStdin,f=e.state.lastExitCode,p=e.state.env.get(`?`);e.substitutionDepth=r+1,e.state.bashPid=e.state.nextVirtualPid++,e.state.suppressVerbose=!0,n!==void 0&&(e.state.groupStdin=n);let m;try{m=await e.executeScript(t)}catch(e){if(e instanceof A)throw e;if(e instanceof wr)return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode};throw e}finally{e.substitutionDepth=a,e.state.env=o,e.state.arrays=s,e.state.cwd=c,e.state.bashPid=l,e.state.suppressVerbose=u,e.state.groupStdin=d,e.state.lastExitCode=f,p===void 0?e.state.env.delete(`?`):e.state.env.set(`?`,p)}return m}async function CN(e,t){let n=xN(e);if(n.length>=gN)throw new A(`Process substitution limit exceeded (${gN} concurrent)`,`file_descriptors`);let r=``;if(t.direction===`input`){let n=await SN(e,t.body,void 0);if(n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),r=dr(n),r.length>e.limits.maxStringLength)throw new A(`process substitution: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)}let i=hN-n.length,a=`${mN}/${i}`;n.push({fd:i,path:a,direction:t.direction,body:t.body});try{await yN(e,a,r)}catch(e){throw n.pop(),e}return a}function wN(e){return e.state.processSubstitutions?.length??0}var TN={stdout:``,stderr:``};async function EN(e,t){let n=e.state.processSubstitutions;if(!n||n.length<=t)return TN;let r=``,i=``;for(;n.length>t;){let t=n[n.length-1],a=``;if(t.direction===`output`)try{a=await lr(e.fs,t.path)}catch{}if(await bN(e,t.path),n.pop(),t.direction===`output`){let n=await SN(e,t.body,a);r+=dr(n),i+=n.stderr}}return{stdout:r,stderr:i}}function DN(e,t,n){if(e.length>t)throw new A(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function ON(e,t,n=!1){let r=[];for(let i of t)r.push(await KN(e,i,n));return r.join(``)}function kN(e){return fN(e)}function AN(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!kN(t))return!1;return!0}function jN(e,t,n=!1){let r=dN(t);if(r!==null)return r;switch(t.type){case`TildeExpansion`:return n?t.user===null?`~`:`~${t.user}`:(e.coverage?.hit(`bash:expansion:tilde`),t.user===null?e.state.env.get(`HOME`)??`/home/user`:t.user===`root`?`/root`:`~${t.user}`);case`Glob`:return rM(e,t.pattern);default:return null}}async function MN(e,t){return GN(e,t)}async function NN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(vj(r.value));else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await KN(e,r);n.push(vj(t))}else n.push(await KN(e,r));return n.join(``)}async function PN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`){let e=r.value;`()|*?[]`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`SingleQuoted`)n.push(_j(r.value));else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(_j(t))}else n.push(await KN(e,r));return n.join(``)}async function FN(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(_j(r.value));else if(r.type===`Escaped`){let e=r.value;`*?[]\\()|`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(_j(t))}else r.type===`Glob`?eM(r.pattern)?n.push(await aM(e,r.pattern)):n.push(rM(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await KN(e,r));return n.join(``)}function IN(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&IN(t.parts))return!0;return!1}var LN=1e5;async function RN(e,t,n={count:0}){let r=()=>{n.count++,e.executionScope.consumeLimited(`brace_operations`,1,Math.min(LN,e.limits.maxBraceExpansionResults),`brace expansion`)},i=(t,n)=>{if(t.length>=e.limits.maxBraceExpansionResults)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),t.push(n)},a=[[]];for(let o of t)if(o.type===`BraceExpansion`){let t=[],s=!1,c=``;for(let r of o.items)if(r.type===`Range`){let n=pj(r.start,r.end,r.step,r.startStr,r.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(n.expanded)for(let e of n.expanded)i(t,e);else{s=!0,c=n.literal;break}}else{let a=await RN(e,r.word.parts,n);for(let n of a){let r=[];for(let t of n)typeof t==`string`?r.push(t):r.push(await KN(e,t));i(t,r.join(``))}}if(s){for(let e of a)r(),e.push(c);continue}if(a.length*t.length>e.limits.maxBraceExpansionResults||n.count>LN)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);let l=[];for(let n of a)for(let i of t){if(l.length>=e.limits.maxBraceExpansionResults)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),l.push([...n,i])}a=l}else for(let e of a)r(),e.push(o);return a}async function zN(e,t){let n=t.parts;if(!IN(n))return[await MN(e,t)];let r=await RN(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await KN(e,r));i.push(sM(e,n.join(``)))}return i}function BN(){return{expandWordAsync:GN,expandWordForGlobbing:FN,expandWordWithBracesAsync:zN,expandWordPartsAsync:ON,expandPart:KN,expandParameterAsync:qN,hasBraceExpansion:IN,evaluateArithmetic:rP,buildIfsCharClassPattern:FA,smartWordSplit:cN}}async function VN(e,t){return GM(e,t,BN())}function HN(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function UN(e,t){if(Number.parseInt(e.state.env.get(`#`)||`0`,10)<2)return!1;function n(e){for(let t of e)if(t.type===`DoubleQuoted`){for(let e of t.parts)if(e.type===`ParameterExpansion`&&e.parameter===`@`&&!e.operation)return!0}return!1}return n(t.parts)}async function WN(e,t){if(UN(e,t))return{error:`bash: $@: ambiguous redirect
928
928
  `};let n=t.parts,{hasQuoted:r}=OA(n);if(IN(n)&&(await zN(e,t)).length>1)return{error:`bash: ${n.map(e=>e.type===`Literal`?e.value:e.type===`BraceExpansion`?`{${e.items.map(e=>{if(e.type===`Range`){let t=e.step?`..${e.step}`:``;return`${e.startStr??e.start}..${e.endStr??e.end}${t}`}return e.word.parts.map(e=>e.type===`Literal`?e.value:``).join(``)}).join(`,`)}}`:``).join(``)}: ambiguous redirect
929
929
  `};let i=await GN(e,t),{hasParamExpansion:a,hasCommandSub:o}=OA(n);if((a||o)&&!r&&!NA(e.state.env)&&HA(i,MA(e.state.env),e.limits.maxArrayElements).length>1)return{error:`bash: $${HN(n)}: ambiguous redirect
930
930
  `};if(r||e.state.options.noglob||n.some(e=>e.type===`ProcessSubstitution`))return{target:i};let s=await FN(e,t);if(!hj(s,e.state.shoptOptions.extglob))return{target:i};let c=new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)}),l=await c.expand(s);return l.length===0?c.hasFailglob()?{error:`bash: no match: ${i}
931
931
  `}:{target:i}:l.length===1?{target:l[0]}:{error:`bash: ${i}: ambiguous redirect
932
932
  `}}async function GN(e,t){let n=t.parts,r=n.length;if(r===1){let t=await KN(e,n[0]);return DN(t,e.limits.maxStringLength,`word expansion`),t}let i=[];for(let t=0;t<r;t++)i.push(await KN(e,n[t]));let a=i.join(``);return DN(a,e.limits.maxStringLength,`word expansion`),a}async function KN(e,t,n=!1){if(t.type===`ParameterExpansion`)return qN(e,t,n);let r=jN(e,t,n);if(r!==null)return r;switch(t.type){case`DoubleQuoted`:{let n=[];for(let r of t.parts)n.push(await KN(e,r,!0));return n.join(``)}case`CommandSubstitution`:{let n=mj(t.body);if(n)try{let t=await MN(e,n.target),r=t.startsWith(`/`)?t:`${e.state.cwd}/${t}`,i=await e.fs.readFile(r);e.state.lastExitCode=0,e.state.env.set(`?`,`0`);let a=i.replace(/\n+$/,``);return DN(a,e.limits.maxStringLength,`command substitution`),a}catch(t){if(t instanceof A)throw t;return e.state.lastExitCode=1,e.state.env.set(`?`,`1`),``}let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new A(`Command substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth;e.substitutionDepth=r+1;let o=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let s=new Map(e.state.env),c=eD(e.state.arrays),l=e.state.cwd,u=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let n=await e.executeScript(t.body),r=n.exitCode;e.state.env=s,e.state.arrays=c,e.state.cwd=l,e.state.suppressVerbose=u,e.state.lastExitCode=r,e.state.env.set(`?`,String(r)),n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),e.state.bashPid=o,e.substitutionDepth=a;let i=n.stdout.replace(/\n+$/,``);return DN(i,e.limits.maxStringLength,`command substitution`),i}catch(t){if(e.state.env=s,e.state.arrays=c,e.state.cwd=l,e.state.bashPid=o,e.substitutionDepth=a,e.state.suppressVerbose=u,t instanceof A)throw t;if(t instanceof wr){e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr);let n=t.stdout.replace(/\n+$/,``);return DN(n,e.limits.maxStringLength,`command substitution`),n}throw t}}case`ProcessSubstitution`:return CN(e,t);case`ArithmeticExpansion`:{let n=t.expression.originalText;if(n&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(n)){let t=await oj(e,n),r=sO(new Tk,t);return String(await rP(e,r.expression,!0))}return String(await rP(e,t.expression.expression,!0))}case`BraceExpansion`:{let n=[];for(let r of t.items)if(r.type===`Range`){let t=pj(r.start,r.end,r.step,r.startStr,r.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(t.expanded)n.push(...t.expanded);else return t.literal}else n.push(await MN(e,r.word));return n.join(` `)}default:return``}}async function qN(e,t,n=!1){let{parameter:r}=t,{operation:i}=t,a=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,t,n]=a;(e.state.associativeArrays?.has(t)||n.includes(`$(`)||n.includes("`")||n.includes("${"))&&(r=`${t}[${await sj(e,n)}]`)}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&GA(e,r)){let t=QA(e,r);if(t&&t!==r){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let[,t,i]=n;(e.state.associativeArrays?.has(t)||i.includes(`$(`)||i.includes("`")||i.includes("${"))&&(r=`${t}[${await sj(e,i)}]`)}}}let o=i&&(i.type===`DefaultValue`||i.type===`AssignDefault`||i.type===`UseAlternative`||i.type===`ErrorIfUnset`),s=await ij(e,r,!o);if(!i)return s;let c=!await aj(e,r),{isEmpty:l,effectiveValue:u}=$j(e,r,s,n),d={value:s,isUnset:c,isEmpty:l,effectiveValue:u,inDoubleQuotes:n};switch(i.type){case`DefaultValue`:return Bj(e,i,d,ON);case`AssignDefault`:return Vj(e,r,i,d,ON);case`ErrorIfUnset`:return Hj(e,r,i,d,ON);case`UseAlternative`:return Uj(e,i,d,ON);case`PatternRemoval`:{let t=await Wj(e,s,i,ON,KN);return DN(t,e.limits.maxStringLength,`pattern removal`),t}case`PatternReplacement`:{let t=await Gj(e,s,i,ON,KN);return DN(t,e.limits.maxStringLength,`pattern replacement`),t}case`Length`:return Kj(e,r,s);case`LengthSliceError`:throw new Er(r);case`BadSubstitution`:throw new Er(i.text);case`Substring`:return qj(e,r,s,i);case`CaseModification`:{let t=await Jj(e,s,i,ON,qN);return DN(t,e.limits.maxStringLength,`case modification`),t}case`Transform`:return Yj(e,r,s,c,i);case`Indirection`:return Xj(e,r,s,c,i,qN,n);case`ArrayKeys`:return Zj(e,i);case`VarNamePrefix`:return Qj(e,i);default:return s}}function JN(){return{visited:new Set,depth:0}}function YN(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:if(t===0)throw new Tr(`division by 0`);return Math.trunc(e/t);case`%`:if(t===0)throw new Tr(`division by 0`);return e%t;case`**`:if(t<0)throw new Tr(`exponent less than 0`);return e**t;case`<<`:return e<<t;case`>>`:return e>>t;case`<`:return+(e<t);case`<=`:return+(e<=t);case`>`:return+(e>t);case`>=`:return+(e>=t);case`==`:return+(e===t);case`!=`:return e===t?0:1;case`&`:return e&t;case`|`:return e|t;case`^`:return e^t;case`,`:return t;default:return 0}}function XN(e,t,n){switch(n){case`=`:return t;case`+=`:return e+t;case`-=`:return e-t;case`*=`:return e*t;case`/=`:return t===0?0:Math.trunc(e/t);case`%=`:return t===0?0:e%t;case`<<=`:return e<<t;case`>>=`:return e>>t;case`&=`:return e&t;case`|=`:return e|t;case`^=`:return e^t;default:return t}}function ZN(e,t){switch(t){case`-`:return-e;case`+`:return+e;case`!`:return+(e===0);case`~`:return~e;default:return e}}async function QN(e,t){let n=e.state.env.get(t);if(n!==void 0)return n;let r=aD(e,t,0);return r===void 0?await ij(e,t):r}async function $N(e,t,n){if(!t)return 0;let r=Number.parseInt(t,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(t.trim()))return r;let i=t.trim();if(!i)return 0;let{expr:a,pos:o}=uO(new Tk,i,0);if(o<i.length){let e=i.slice(o).trim(),t=e.split(/\s+/)[0]||e;throw new Tr(`syntax error in expression (error token is "${t}")`,``,``)}return await iP(e,a,!1,n)}async function eP(e,t,n,r){if(r.depth>100)throw new Tr(`maximum variable indirection depth exceeded`);if(r.visited.has(t))throw new Tr(`arithmetic variable cycle detected at ${t}`);r.visited.add(t),r.depth++;try{return await $N(e,n,r)}finally{r.depth--,r.visited.delete(t)}}async function tP(e,t,n){if(n.depth>100)throw new Tr(`maximum variable indirection depth exceeded`);if(n.visited.has(t))throw new Tr(`arithmetic variable cycle detected at ${t}`);n.visited.add(t),n.depth++;try{let r=await QN(e,t);if(!r)return 0;let i=Number.parseInt(r,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(r.trim()))return i;let a=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return await tP(e,a,n);let{expr:o,pos:s}=uO(new Tk,a,0);if(s<a.length){let e=a.slice(s).trim(),t=e.split(/\s+/)[0]||e;throw new Tr(`${a}: syntax error in expression (error token is "${t}")`)}return await iP(e,o,!1,n)}finally{n.depth--,n.visited.delete(t)}}async function nP(e,t){if(t.startsWith(`#`)){let n=t.slice(1),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=nj(e,t);return String(n.length)}let i=e.state.env.get(n)||``;return String(i.length)}if(t.startsWith(`!`)){let n=t.slice(1),r=e.state.env.get(n)||``;return e.state.env.get(r)||``}let n=[`:-`,`:=`,`:?`,`:+`,`-`,`=`,`?`,`+`],r=-1,i=``;for(let e of n){let n=t.indexOf(e);n>0&&(r===-1||n<r)&&(r=n,i=e)}if(r===-1)return await ij(e,t);let a=t.slice(0,r),o=t.slice(r+i.length),s=e.state.env.get(a),c=s===void 0,l=s===``,u=i.startsWith(`:`);switch(i){case`:-`:case`-`:return c||u&&l?o:s||``;case`:=`:case`=`:return c||u&&l?(e.state.env.set(a,o),o):s||``;case`:+`:case`+`:return c||u&&l?``:o;case`:?`:case`?`:if(c||u&&l)throw Error(o||`${a}: parameter null or not set`);return s||``;default:return s||``}}async function rP(e,t,n=!1){return iP(e,t,n,JN())}async function iP(e,t,n,r){let i=(t,i=n)=>iP(e,t,i,r);switch(t.type){case`ArithNumber`:if(Number.isNaN(t.value))throw new Tr(`value too great for base`);return t.value;case`ArithVariable`:return await tP(e,t.name,r);case`ArithSpecialVar`:{let n=(await ij(e,t.name)).trim();if(!n)return 0;let r=Number.parseInt(n,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(n))return r;let{expr:a}=uO(new Tk,n,0);return await i(a)}case`ArithNested`:return await i(t.expression);case`ArithCommandSubst`:if(e.execFn){let n=await e.execFn(t.command,{signal:e.state.signal});n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr);let r=n.stdout.trim();return Number.parseInt(r,10)||0}return 0;case`ArithBracedExpansion`:{let n=await nP(e,t.content);return Number.parseInt(n,10)||0}case`ArithDynamicBase`:{let n=await nP(e,t.baseExpr),r=Number.parseInt(n,10);return r<2||r>64?0:nO(`${r}#${t.value}`)}case`ArithDynamicNumber`:return nO(await nP(e,t.prefix)+t.suffix);case`ArithArrayElement`:{let n=e.state.associativeArrays?.has(t.array),a=async n=>{let i=aD(e,t.array,n);return i===void 0?0:await eP(e,`${t.array}[${n}]`,i,r)};if(t.stringKey!==void 0)return await a(t.stringKey);if(n&&t.index?.type===`ArithVariable`&&!t.index.hasDollarPrefix)return await a(t.index.name);if(n&&t.index?.type===`ArithVariable`&&t.index.hasDollarPrefix)return await a(await ij(e,t.index.name));if(t.index){let n=await i(t.index);if(n<0){let r=nj(e,t.array),i=e.state.currentLine;if(r.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript
933
933
  `,0;let a=Math.max(...r.map(([e])=>typeof e==`number`?e:0))+1+n;if(a<0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript
934
- `,0;n=a}let a=`${t.array}[${n}]`,o=aD(e,t.array,n);if(o!==void 0)return eP(e,a,o,r);if(n===0){let n=e.state.env.get(t.array);if(n!==void 0)return eP(e,t.array,n,r)}if(e.state.options.nounset&&!(e.state.env.has(t.array)||iD(e,t.array)))throw new Cr(`${t.array}[${n}]`);return 0}return 0}case`ArithDoubleSubscript`:throw new Tr(`double subscript`,``,``);case`ArithNumberSubscript`:throw new Tr(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case`ArithSyntaxError`:throw new Tr(t.message,``,``,!0);case`ArithSingleQuote`:if(n)throw new Tr(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value;case`ArithBinary`:return t.operator===`||`?await i(t.left)||await i(t.right)?1:0:t.operator===`&&`?await i(t.left)&&await i(t.right)?1:0:YN(await i(t.left),await i(t.right),t.operator);case`ArithUnary`:{let a=await i(t.operand);if(t.operator===`++`||t.operator===`--`){if(t.operand.type===`ArithVariable`){let n=t.operand.name,r=Number.parseInt(await ij(e,n),10)||0,i=t.operator===`++`?r+1:r-1;return e.state.env.set(n,String(i)),t.prefix?i:r}if(t.operand.type===`ArithArrayElement`){let n=t.operand.array,r=e.state.associativeArrays?.has(n),o;if(t.operand.stringKey!==void 0)o=t.operand.stringKey;else if(r&&t.operand.index?.type===`ArithVariable`&&!t.operand.index.hasDollarPrefix)o=t.operand.index.name;else if(r&&t.operand.index?.type===`ArithVariable`&&t.operand.index.hasDollarPrefix)o=await ij(e,t.operand.index.name);else if(t.operand.index){let e=await i(t.operand.index);o=String(e)}else return a;let s=Number.parseInt(aD(e,n,o)||`0`,10)||0,c=t.operator===`++`?s+1:s-1;return Y(e,n,o,String(c),r?`associative`:`indexed`),t.prefix?c:s}if(t.operand.type===`ArithConcat`){let i=``;for(let a of t.operand.parts)i+=await aP(e,a,n,r);if(i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){let n=Number.parseInt(e.state.env.get(i)||`0`,10)||0,r=t.operator===`++`?n+1:n-1;return e.state.env.set(i,String(r)),t.prefix?r:n}}if(t.operand.type===`ArithDynamicElement`){let a=``;if(t.operand.nameExpr.type===`ArithConcat`)for(let i of t.operand.nameExpr.parts)a+=await aP(e,i,n,r);else t.operand.nameExpr.type===`ArithVariable`&&(a=t.operand.nameExpr.hasDollarPrefix?await ij(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(a&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){let n=await i(t.operand.subscript),r=Number.parseInt(aD(e,a,n)||`0`,10)||0,o=t.operator===`++`?r+1:r-1;return Y(e,a,n,String(o)),t.prefix?o:r}}return a}return ZN(a,t.operator)}case`ArithTernary`:return await i(t.condition)?await i(t.consequent):await i(t.alternate);case`ArithAssignment`:{let n=t.variable,r=n,a;if(t.stringKey!==void 0)a=t.stringKey;else if(t.subscript){let r=e.state.associativeArrays?.has(n);if(r&&t.subscript.type===`ArithVariable`&&!t.subscript.hasDollarPrefix)a=t.subscript.name;else if(r&&t.subscript.type===`ArithVariable`&&t.subscript.hasDollarPrefix)a=await ij(e,t.subscript.name)||`\\`;else if(r){let e=await i(t.subscript);a=String(e)}else{let r=await i(t.subscript);if(r<0){let t=nj(e,n);t.length>0&&(r=Math.max(...t.map(([e])=>typeof e==`number`?e:0))+1+r)}a=String(r)}}let o=a===void 0?e.state.env.get(r):aD(e,n,a),s=XN(Number.parseInt(o||`0`,10)||0,await i(t.value),t.operator);return a===void 0?e.state.env.set(r,String(s)):Y(e,n,a,String(s),e.state.associativeArrays?.has(n)?`associative`:`indexed`),s}case`ArithGroup`:return await i(t.expression);case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await aP(e,a,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?await tP(e,i,r):Number.parseInt(i,10)||0}case`ArithDynamicAssignment`:{let a=``;if(t.target.type===`ArithConcat`)for(let i of t.target.parts)a+=await aP(e,i,n,r);else t.target.type===`ArithVariable`&&(a=t.target.hasDollarPrefix?await ij(e,t.target.name):t.target.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=a;if(t.subscript){let e=await i(t.subscript);o=`${a}_${e}`}let s=XN(Number.parseInt(e.state.env.get(o)||`0`,10)||0,await i(t.value),t.operator);return e.state.env.set(o,String(s)),s}case`ArithDynamicElement`:{let a=``;if(t.nameExpr.type===`ArithConcat`)for(let i of t.nameExpr.parts)a+=await aP(e,i,n,r);else t.nameExpr.type===`ArithVariable`&&(a=t.nameExpr.hasDollarPrefix?await ij(e,t.nameExpr.name):t.nameExpr.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=await i(t.subscript),s=`${a}_${o}`,c=e.state.env.get(s);return c===void 0?0:eP(e,s,c,r)}default:return 0}}async function aP(e,t,n=!1,r=JN()){switch(t.type){case`ArithNumber`:return String(t.value);case`ArithSingleQuote`:return String(await iP(e,t,n,r));case`ArithVariable`:return t.hasDollarPrefix?await ij(e,t.name):t.name;case`ArithSpecialVar`:return await ij(e,t.name);case`ArithBracedExpansion`:return await nP(e,t.content);case`ArithCommandSubst`:return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():`0`;case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await aP(e,a,n,r);return i}default:return String(await iP(e,t,n,r))}}Lr(),j();async function oP(e,t){let n=``,r=0;for(let i of t.parts){let t=i.type===`Literal`?i.value:`\0`,a=O(t);if(a>e.limits.maxStringLength-r)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n+=t,r+=a}let i=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!i||!n.endsWith(`)`))return null;let a=i[1],o=[],s=[],c=!1,l=``,u=0,d=0,f=!1,p=!0,m=t=>{let n=O(t);if(n>e.limits.maxStringLength-d-u)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);l+=t,u+=n},h=(t,n=!1)=>{if(o.length>=e.limits.maxArrayElements)throw new A(`array assignment element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let r=O(t);if(r>e.limits.maxStringLength-d)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);o.push(t),s.push(n),d+=r},g=()=>{h(l,p),l=``,u=0,f=!1,p=!0};for(let n of t.parts)if(n.type===`Literal`){let e=n.value;if(!c){let t=e.indexOf(`=(`);t!==-1&&(c=!0,e=e.slice(t+2))}if(c){e.endsWith(`)`)&&(e=e.slice(0,-1));for(let t of e)/\s/.test(t)?(l||f)&&g():m(t)}}else if(c)if(n.type===`BraceExpansion`)if(/^\[.+\]=/.test(l))m(gD({type:`Word`,parts:[n]}));else{(l||f)&&g();let t=await VN(e,{type:`Word`,parts:[n]});for(let e of t.values)h(e)}else(n.type===`SingleQuoted`||n.type===`DoubleQuoted`||n.type===`Escaped`)&&(f=!0),p=!1,m(await MN(e,{type:`Word`,parts:[n]}));(l||f)&&g();let _=o.splice(0),v=s.splice(0);d=0;for(let t=0;t<_.length;t++){let n=_[t];if(!v[t]){h(n);continue}let r=n.match(/^(\[[^\]]+\]=)(.*)$/s);if(r){let t=cM(e,r[2]);n=r[1]+t}if(n.includes(`{`)&&n.includes(`}`)){let t=new Tk().parseWordFromString(n,!1,!1);if(t.parts.some(e=>e.type===`BraceExpansion`)){let n=await VN(e,t);for(let e of n.values)h(e);continue}}h(n)}let y=[`${a}=(`],b=O(y[0]);for(let t=0;t<o.length;t++){let n=o[t],r;r=/^\[.+\]=/.test(n)?n:n===``?`''`:/[\s"'\\$`!*?[\]{}|&;<>()]/.test(n)&&!n.startsWith(`'`)&&!n.startsWith(`"`)?`'${n.replace(/'/g,`'\\''`)}'`:n;let i=`${t>0?` `:``}${r}`,a=O(i);if(a+1>e.limits.maxStringLength-b)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);y.push(i),b+=a}return y.push(`)`),y.join(``)}async function sP(e,t){let n=-1,r=-1,i=!1;for(let e=0;e<t.parts.length;e++){let a=t.parts[e];if(a.type===`Literal`){let t=a.value.indexOf(`+=`);if(t!==-1){let o=a.value.slice(0,t);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){n=e,r=t,i=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(o)){n=e,r=t,i=!0;break}}let o=a.value.indexOf(`=`);if(o!==-1&&(o===0||a.value[o-1]!==`+`)){let t=a.value.slice(0,o);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(t)){n=e,r=o;break}}}}if(n===-1)return null;let a=t.parts.slice(0,n),o=t.parts[n];if(o.type!==`Literal`)return null;let s=i?2:1,c=o.value.slice(0,r),l=o.value.slice(r+s),u=t.parts.slice(n+1),d=``;for(let t of a)d+=await MN(e,{type:`Word`,parts:[t]});d+=c;let f={type:`Word`,parts:l===``?u:[{type:`Literal`,value:l},...u]},p=f.parts.length>0?await MN(e,f):``;return`${d}${i?`+=`:`=`}${p}`}var cP=[`tar`,`yq`,`xan`,`sqlite3`,`python3`,`python`];function lP(e){return cP.includes(e)}k(),ea(),Su(),qn(),Yb(),nr(),j(),j();var uP=Object.freeze({stdout:``,stderr:``,exitCode:0,internalStdinConsumed:0});function dP(e=``){return{stdout:e,stderr:``,exitCode:0}}function Q(e,t=1){return{stdout:``,stderr:e,exitCode:t}}function $(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function fP(e){return{stdout:``,stderr:``,exitCode:+!e,internalStdinConsumed:0}}function pP(e,t,n=``,r=``){throw new A(e,t,n,r)}function mP(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new A(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,`file_descriptors`)}function hP(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ar;return uP}if(t.length>1)throw new wr(1,``,`bash: break: too many arguments
934
+ `,0;n=a}let a=`${t.array}[${n}]`,o=aD(e,t.array,n);if(o!==void 0)return eP(e,a,o,r);if(n===0){let n=e.state.env.get(t.array);if(n!==void 0)return eP(e,t.array,n,r)}if(e.state.options.nounset&&!(e.state.env.has(t.array)||iD(e,t.array)))throw new Cr(`${t.array}[${n}]`);return 0}return 0}case`ArithDoubleSubscript`:throw new Tr(`double subscript`,``,``);case`ArithNumberSubscript`:throw new Tr(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case`ArithSyntaxError`:throw new Tr(t.message,``,``,!0);case`ArithSingleQuote`:if(n)throw new Tr(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value;case`ArithBinary`:return t.operator===`||`?await i(t.left)||await i(t.right)?1:0:t.operator===`&&`?await i(t.left)&&await i(t.right)?1:0:YN(await i(t.left),await i(t.right),t.operator);case`ArithUnary`:{let a=await i(t.operand);if(t.operator===`++`||t.operator===`--`){if(t.operand.type===`ArithVariable`){let n=t.operand.name,r=Number.parseInt(await ij(e,n),10)||0,i=t.operator===`++`?r+1:r-1;return e.state.env.set(n,String(i)),t.prefix?i:r}if(t.operand.type===`ArithArrayElement`){let n=t.operand.array,r=e.state.associativeArrays?.has(n),o;if(t.operand.stringKey!==void 0)o=t.operand.stringKey;else if(r&&t.operand.index?.type===`ArithVariable`&&!t.operand.index.hasDollarPrefix)o=t.operand.index.name;else if(r&&t.operand.index?.type===`ArithVariable`&&t.operand.index.hasDollarPrefix)o=await ij(e,t.operand.index.name);else if(t.operand.index){let e=await i(t.operand.index);o=String(e)}else return a;let s=Number.parseInt(aD(e,n,o)||`0`,10)||0,c=t.operator===`++`?s+1:s-1;return Y(e,n,o,String(c),r?`associative`:`indexed`),t.prefix?c:s}if(t.operand.type===`ArithConcat`){let i=``;for(let a of t.operand.parts)i+=await aP(e,a,n,r);if(i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){let n=Number.parseInt(e.state.env.get(i)||`0`,10)||0,r=t.operator===`++`?n+1:n-1;return e.state.env.set(i,String(r)),t.prefix?r:n}}if(t.operand.type===`ArithDynamicElement`){let a=``;if(t.operand.nameExpr.type===`ArithConcat`)for(let i of t.operand.nameExpr.parts)a+=await aP(e,i,n,r);else t.operand.nameExpr.type===`ArithVariable`&&(a=t.operand.nameExpr.hasDollarPrefix?await ij(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(a&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){let n=await i(t.operand.subscript),r=Number.parseInt(aD(e,a,n)||`0`,10)||0,o=t.operator===`++`?r+1:r-1;return Y(e,a,n,String(o)),t.prefix?o:r}}return a}return ZN(a,t.operator)}case`ArithTernary`:return await i(t.condition)?await i(t.consequent):await i(t.alternate);case`ArithAssignment`:{let n=t.variable,r=n,a;if(t.stringKey!==void 0)a=t.stringKey;else if(t.subscript){let r=e.state.associativeArrays?.has(n);if(r&&t.subscript.type===`ArithVariable`&&!t.subscript.hasDollarPrefix)a=t.subscript.name;else if(r&&t.subscript.type===`ArithVariable`&&t.subscript.hasDollarPrefix)a=await ij(e,t.subscript.name)||`\\`;else if(r){let e=await i(t.subscript);a=String(e)}else{let r=await i(t.subscript);if(r<0){let t=nj(e,n);t.length>0&&(r=Math.max(...t.map(([e])=>typeof e==`number`?e:0))+1+r)}a=String(r)}}let o=a===void 0?e.state.env.get(r):aD(e,n,a),s=XN(Number.parseInt(o||`0`,10)||0,await i(t.value),t.operator);return a===void 0?e.state.env.set(r,String(s)):Y(e,n,a,String(s),e.state.associativeArrays?.has(n)?`associative`:`indexed`),s}case`ArithGroup`:return await i(t.expression);case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await aP(e,a,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?await tP(e,i,r):Number.parseInt(i,10)||0}case`ArithDynamicAssignment`:{let a=``;if(t.target.type===`ArithConcat`)for(let i of t.target.parts)a+=await aP(e,i,n,r);else t.target.type===`ArithVariable`&&(a=t.target.hasDollarPrefix?await ij(e,t.target.name):t.target.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=a;if(t.subscript){let e=await i(t.subscript);o=`${a}_${e}`}let s=XN(Number.parseInt(e.state.env.get(o)||`0`,10)||0,await i(t.value),t.operator);return e.state.env.set(o,String(s)),s}case`ArithDynamicElement`:{let a=``;if(t.nameExpr.type===`ArithConcat`)for(let i of t.nameExpr.parts)a+=await aP(e,i,n,r);else t.nameExpr.type===`ArithVariable`&&(a=t.nameExpr.hasDollarPrefix?await ij(e,t.nameExpr.name):t.nameExpr.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=await i(t.subscript),s=`${a}_${o}`,c=e.state.env.get(s);return c===void 0?0:eP(e,s,c,r)}default:return 0}}async function aP(e,t,n=!1,r=JN()){switch(t.type){case`ArithNumber`:return String(t.value);case`ArithSingleQuote`:return String(await iP(e,t,n,r));case`ArithVariable`:return t.hasDollarPrefix?await ij(e,t.name):t.name;case`ArithSpecialVar`:return await ij(e,t.name);case`ArithBracedExpansion`:return await nP(e,t.content);case`ArithCommandSubst`:return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():`0`;case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await aP(e,a,n,r);return i}default:return String(await iP(e,t,n,r))}}Lr(),j();async function oP(e,t){let n=``,r=0;for(let i of t.parts){let t=i.type===`Literal`?i.value:`\0`,a=O(t);if(a>e.limits.maxStringLength-r)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n+=t,r+=a}let i=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!i||!n.endsWith(`)`))return null;let a=i[1],o=[],s=[],c=!1,l=``,u=0,d=0,f=!1,p=!0,m=t=>{let n=O(t);if(n>e.limits.maxStringLength-d-u)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);l+=t,u+=n},h=(t,n=!1)=>{if(o.length>=e.limits.maxArrayElements)throw new A(`array assignment element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let r=O(t);if(r>e.limits.maxStringLength-d)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);o.push(t),s.push(n),d+=r},g=()=>{h(l,p),l=``,u=0,f=!1,p=!0};for(let n of t.parts)if(n.type===`Literal`){let e=n.value;if(!c){let t=e.indexOf(`=(`);t!==-1&&(c=!0,e=e.slice(t+2))}if(c){e.endsWith(`)`)&&(e=e.slice(0,-1));for(let t of e)/\s/.test(t)?(l||f)&&g():m(t)}}else if(c){if(n.type===`BraceExpansion`){if(/^\[.+\]=/.test(l))m(gD({type:`Word`,parts:[n]}));else{(l||f)&&g();let t=await VN(e,{type:`Word`,parts:[n]});for(let e of t.values)h(e)}}else(n.type===`SingleQuoted`||n.type===`DoubleQuoted`||n.type===`Escaped`)&&(f=!0),p=!1,m(await MN(e,{type:`Word`,parts:[n]}))}(l||f)&&g();let _=o.splice(0),v=s.splice(0);d=0;for(let t=0;t<_.length;t++){let n=_[t];if(!v[t]){h(n);continue}let r=n.match(/^(\[[^\]]+\]=)(.*)$/s);if(r){let t=cM(e,r[2]);n=r[1]+t}if(n.includes(`{`)&&n.includes(`}`)){let t=new Tk().parseWordFromString(n,!1,!1);if(t.parts.some(e=>e.type===`BraceExpansion`)){let n=await VN(e,t);for(let e of n.values)h(e);continue}}h(n)}let y=[`${a}=(`],b=O(y[0]);for(let t=0;t<o.length;t++){let n=o[t],r;r=/^\[.+\]=/.test(n)?n:n===``?`''`:/[\s"'\\$`!*?[\]{}|&;<>()]/.test(n)&&!n.startsWith(`'`)&&!n.startsWith(`"`)?`'${n.replace(/'/g,`'\\''`)}'`:n;let i=`${t>0?` `:``}${r}`,a=O(i);if(a+1>e.limits.maxStringLength-b)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);y.push(i),b+=a}return y.push(`)`),y.join(``)}async function sP(e,t){let n=-1,r=-1,i=!1;for(let e=0;e<t.parts.length;e++){let a=t.parts[e];if(a.type===`Literal`){let t=a.value.indexOf(`+=`);if(t!==-1){let o=a.value.slice(0,t);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){n=e,r=t,i=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(o)){n=e,r=t,i=!0;break}}let o=a.value.indexOf(`=`);if(o!==-1&&(o===0||a.value[o-1]!==`+`)){let t=a.value.slice(0,o);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(t)){n=e,r=o;break}}}}if(n===-1)return null;let a=t.parts.slice(0,n),o=t.parts[n];if(o.type!==`Literal`)return null;let s=i?2:1,c=o.value.slice(0,r),l=o.value.slice(r+s),u=t.parts.slice(n+1),d=``;for(let t of a)d+=await MN(e,{type:`Word`,parts:[t]});d+=c;let f={type:`Word`,parts:l===``?u:[{type:`Literal`,value:l},...u]},p=f.parts.length>0?await MN(e,f):``;return`${d}${i?`+=`:`=`}${p}`}var cP=[`tar`,`yq`,`xan`,`sqlite3`,`python3`,`python`];function lP(e){return cP.includes(e)}k(),ea(),Su(),qn(),Yb(),nr(),j(),j();var uP=Object.freeze({stdout:``,stderr:``,exitCode:0,internalStdinConsumed:0});function dP(e=``){return{stdout:e,stderr:``,exitCode:0}}function Q(e,t=1){return{stdout:``,stderr:e,exitCode:t}}function $(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function fP(e){return{stdout:``,stderr:``,exitCode:+!e,internalStdinConsumed:0}}function pP(e,t,n=``,r=``){throw new A(e,t,n,r)}function mP(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new A(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,`file_descriptors`)}function hP(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ar;return uP}if(t.length>1)throw new wr(1,``,`bash: break: too many arguments
935
935
  `);let n=1;if(t.length>0){let e=Number.parseInt(t[0],10);if(Number.isNaN(e)||e<1)throw new wr(128,``,`bash: break: ${t[0]}: numeric argument required
936
936
  `);n=e}throw new yr(n)}async function gP(e,t){let n,r=!1,i=!1,a=0;for(;a<t.length;)if(t[a]===`--`){a++;break}else if(t[a]===`-L`)i=!1,a++;else if(t[a]===`-P`)i=!0,a++;else if(t[a].startsWith(`-`)&&t[a]!==`-`)a++;else break;let o=t.slice(a);if(o.length===0||o[0]===`~`?n=e.state.env.get(`HOME`)||`/`:o[0]===`-`?(n=e.state.previousDir,r=!0):n=o[0],!n.startsWith(`/`)&&!n.startsWith(`./`)&&!n.startsWith(`../`)&&n!==`.`&&n!==`..`){let t=e.state.env.get(`CDPATH`);if(t){let i=t.split(`:`).filter(e=>e);for(let t of i){let i=t.startsWith(`/`)?`${t}/${n}`:`${e.state.cwd}/${t}/${n}`;try{if((await e.fs.stat(i)).isDirectory){n=i,r=!0;break}}catch{}}}}let s=(n.startsWith(`/`)?n:`${e.state.cwd}/${n}`).split(`/`).filter(e=>e&&e!==`.`),c=``;for(let t of s)if(t===`..`)c=c.split(`/`).slice(0,-1).join(`/`)||`/`;else{c=c?`${c}/${t}`:`/${t}`;try{if(!(await e.fs.stat(c)).isDirectory)return Q(`bash: cd: ${n}: Not a directory
937
937
  `)}catch{return Q(`bash: cd: ${n}: No such file or directory
@@ -940,7 +940,7 @@ ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}fun
940
940
  `,!1}return oD(e,t,i)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?fD(e,t).length>0:uD(e,t).length>0}async function NP(e,t){switch(t.type){case`CondBinary`:{let n=await MN(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(e=>e.type===`SingleQuoted`||e.type===`DoubleQuoted`||e.type===`Escaped`&&t.operator!==`=~`),i;if(i=t.operator===`=~`?r?vj(await MN(e,t.right)):await NN(e,t.right):DP(t.operator)&&!r?await PN(e,t.right):await MN(e,t.right),DP(t.operator)){let a=e.state.shoptOptions.nocasematch;return OP(t.operator,n,i,!r,a,!0,e.limits.maxCallDepth)}if(TP(t.operator))return EP(t.operator,await qP(e,n),await qP(e,i));if(SP(t.operator))return CP(e,t.operator,n,i);switch(t.operator){case`=~`:try{let t=e.state.shoptOptions.nocasematch,r=U(ZP(i),t?`i`:``).match(n);if(dD(e,`BASH_REMATCH`),r)for(let t=0;t<r.length;t++)Y(e,`BASH_REMATCH`,t,r[t]||``);return r!==null}catch{throw Error(`syntax error in regular expression`)}case`<`:return n<i;case`>`:return n>i;default:return!1}}case`CondUnary`:{let n=await MN(e,t.operand);return yP(t.operator)?bP(e,t.operator,n):AP(t.operator)?jP(t.operator,n):t.operator===`-v`?await MP(e,n):t.operator===`-o`&&KP(e,n)}case`CondNot`:return e.state.shoptOptions.extglob&&t.operand.type===`CondGroup`&&t.operand.expression.type===`CondWord`?`!(${await MN(e,t.operand.expression.word)})`!=``:!await NP(e,t.operand);case`CondAnd`:return await NP(e,t.left)?await NP(e,t.right):!1;case`CondOr`:return await NP(e,t.left)?!0:await NP(e,t.right);case`CondGroup`:return await NP(e,t.expression);case`CondWord`:return await MN(e,t.word)!==``;default:return!1}}async function PP(e,t){if(t.length===0)return $(``,``,1);if(t.length===1)return fP(!!t[0]);if(t.length===2){let n=t[0],r=t[1];return n===`(`?Q(`test: '(' without matching ')'
941
941
  `,2):yP(n)?fP(await bP(e,n,r)):AP(n)?fP(jP(n,r)):n===`!`?fP(!r):n===`-v`?fP(await MP(e,r)):n===`-o`?fP(KP(e,r)):n===`=`||n===`==`||n===`!=`||n===`<`||n===`>`||n===`-eq`||n===`-ne`||n===`-lt`||n===`-le`||n===`-gt`||n===`-ge`||n===`-nt`||n===`-ot`||n===`-ef`?Q(`test: ${n}: unary operator expected
942
942
  `,2):$(``,``,1)}if(t.length===3){let n=t[0],r=t[1],i=t[2];if(DP(r))return fP(OP(r,n,i));if(TP(r)){let e=XP(n),t=XP(i);return!e.valid||!t.valid?$(``,``,2):fP(EP(r,e.value,t.value))}if(SP(r))return fP(await CP(e,r,n,i));switch(r){case`-a`:return fP(n!==``&&i!==``);case`-o`:return fP(n!==``||i!==``);case`>`:return fP(n>i);case`<`:return fP(n<i)}if(n===`!`){let t=await PP(e,[r,i]);return $(``,t.stderr,t.exitCode===0?1:t.exitCode===1?0:t.exitCode)}if(n===`(`&&i===`)`)return fP(r!==``)}if(t.length===4){if(t[0]===`!`){let n=await PP(e,t.slice(1));return $(``,n.stderr,n.exitCode===0?1:n.exitCode===1?0:n.exitCode)}if(t[0]===`(`&&t[3]===`)`)return PP(e,[t[1],t[2]])}let n=await FP(e,t,0);return n.pos<t.length?Q(`test: too many arguments
943
- `,2):fP(n.value)}async function FP(e,t,n){return IP(e,t,n)}async function IP(e,t,n){let{value:r,pos:i}=await LP(e,t,n);for(;t[i]===`-o`;){let n=await LP(e,t,i+1);r||=n.value,i=n.pos}return{value:r,pos:i}}async function LP(e,t,n){let{value:r,pos:i}=await RP(e,t,n);for(;t[i]===`-a`;){let n=await RP(e,t,i+1);r&&=n.value,i=n.pos}return{value:r,pos:i}}async function RP(e,t,n){let r=e.executionScope.enterDepth(`test_expression`,e.limits.maxCallDepth,`test expression`);try{if(t[n]===`!`){let{value:r,pos:i}=await RP(e,t,n+1);return{value:!r,pos:i}}return zP(e,t,n)}finally{r.release()}}async function zP(e,t,n){let r=t[n];if(r===`(`){let{value:r,pos:i}=await FP(e,t,n+1);return{value:r,pos:t[i]===`)`?i+1:i}}let i=t[n+1];if(DP(i))return{value:OP(i,r,t[n+2]??``),pos:n+3};if(TP(i)){let e=XP(r),a=XP(t[n+2]??`0`);return!e.valid||!a.valid?{value:!1,pos:n+3}:{value:EP(i,e.value,a.value),pos:n+3}}return SP(i)?{value:await CP(e,i,r,t[n+2]??``),pos:n+3}:yP(r)?{value:await bP(e,r,t[n+1]??``),pos:n+2}:AP(r)?{value:jP(r,t[n+1]??``),pos:n+2}:r===`-v`?{value:await MP(e,t[n+1]??``),pos:n+2}:r===`-o`?{value:KP(e,t[n+1]??``),pos:n+2}:{value:r!==void 0&&r!==``,pos:n+1}}function BP(e,t,n=!1,r=!1,i=256){return r&&VP(t,i),U(`^${HP(t,r)}$`,n?`is`:`s`).test(e)}function VP(e,t){let n=0,r=[];for(let i=0;i<e.length;i++){if(e[i]===`\\`){i++;continue}if(e[i]===`(`){let a=i>0&&`@*+?!`.includes(e[i-1]);if(r.push(a),a&&n++,n>t)throw new A(`extglob maximum depth (${t}) exceeded`,`recursion`)}else e[i]===`)`&&r.length>0&&r.pop()&&n--}}function HP(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(t&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let a=UP(e,r+1);if(a!==-1){let o=WP(e.slice(r+2,a)),s=o.map(e=>HP(e,t)),c=s.length>0?s.join(`|`):`(?:)`;if(i===`@`)n+=`(?:${c})`;else if(i===`*`)n+=`(?:${c})*`;else if(i===`+`)n+=`(?:${c})+`;else if(i===`?`)n+=`(?:${c})?`;else if(i===`!`)if(a<e.length-1){let e=o.map(e=>GP(e,t));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let t=e[0];if(t===0)n+=`(?:.+)`;else{let e=[];t>0&&e.push(`.{0,${t-1}}`),e.push(`.{${t+1},}`),e.push(`(?!(?:${c})).{${t}}`),n+=`(?:${e.join(`|`)})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`;r=a;continue}}if(i===`\\`)if(r+1<e.length){let t=e[r+1];/[\\^$.|+(){}[\]*?]/.test(t)?n+=`\\${t}`:n+=t,r++}else n+=`\\\\`;else if(i===`*`)n+=`.*`;else if(i===`?`)n+=`.`;else if(i===`[`){let t=e.indexOf(`]`,r+1);t===-1?n+=`\\[`:(n+=e.slice(r,t+1),r=t)}else/[\\^$.|+(){}]/.test(i)?n+=`\\${i}`:n+=i}return n}function UP(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function WP(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function GP(e,t){let n=0,r=0;for(;r<e.length;){let i=e[r];if(t&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let a=UP(e,r+1);if(a!==-1){if(i===`@`){let i=WP(e.slice(r+2,a)).map(e=>GP(e,t));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){n+=i[0],r=a+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){n+=1,r++;continue}if(i===`[`){let t=e.indexOf(`]`,r+1);if(t!==-1){n+=1,r=t+1;continue}n+=1,r++;continue}if(i===`\\`){n+=1,r+=2;continue}n+=1,r++}return n}function KP(e,t){let n=new Map([[`errexit`,()=>e.state.options.errexit===!0],[`nounset`,()=>e.state.options.nounset===!0],[`pipefail`,()=>e.state.options.pipefail===!0],[`xtrace`,()=>e.state.options.xtrace===!0],[`e`,()=>e.state.options.errexit===!0],[`u`,()=>e.state.options.nounset===!0],[`x`,()=>e.state.options.xtrace===!0]]).get(t);return n?n():!1}async function qP(e,t){if(t=t.trim(),t===``)return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return YP(t);try{return await rP(e,sO(new Tk,t).expression)}catch{return YP(t)}}function JP(e,t){let n=0;for(let r of e){let e;if(r>=`0`&&r<=`9`)e=r.charCodeAt(0)-48;else if(r>=`a`&&r<=`z`)e=r.charCodeAt(0)-97+10;else if(r>=`A`&&r<=`Z`)e=r.charCodeAt(0)-65+36;else if(r===`@`)e=62;else if(r===`_`)e=63;else return NaN;if(e>=t)return NaN;n=n*t+e}return n}function YP(e){if(e=e.trim(),e===``)return 0;let t=!1;e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1));let n,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let e=Number.parseInt(r[1],10);n=e>=2&&e<=64?JP(r[2],e):0}else n=/^0[xX][0-9a-fA-F]+$/.test(e)?Number.parseInt(e,16):/^0[0-7]+$/.test(e)?Number.parseInt(e,8):Number.parseInt(e,10);return Number.isNaN(n)&&(n=0),t?-n:n}function XP(e){if(e=e.trim(),e===``)return{value:0,valid:!0};let t=!1;if(e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let n=Number.parseInt(e,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:t?-n:n,valid:!0}}function ZP(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length)t+=e[n]+e[n+1],n+=2;else if(e[n]===`[`){let r=QP(e,n);t+=r.converted,n=r.endIndex}else t+=e[n],n++;return t}function QP(e,t){let n=t+1,r=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(r+=`^`,n++);let i=!1;n<e.length&&e[n]===`]`&&(i=!0,n++);let a=!1;n<e.length&&e[n]===`[`&&n+1<e.length&&e[n+1]!==`:`&&(a=!0,n++);let o=``,s=!1;for(;n<e.length;){let t=e[n];if(t===`]`){s=!0,n++;break}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=e.slice(n+2,t);o+=$P(r),n=t+2;continue}}if(t===`[`&&n+1<e.length){let t=e[n+1];if(t===`.`||t===`=`){let r=`${t}]`,i=e.indexOf(r,n+2);if(i!==-1){let t=e.slice(n+2,i);o+=t,n=i+2;continue}}}if(t===`\\`&&n+1<e.length){o+=t+e[n+1],n+=2;continue}o+=t,n++}return s?(i&&(r+=`\\]`),a&&(r+=`\\[`),r+=o,r+=`]`,{converted:r,endIndex:n}):{converted:`\\[`,endIndex:t+1}}function $P(e){return 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`]]).get(e)??``}j(),k(),j();function eF(e,t,n){if(n&&e.length>=n.maxElements)throw new A(`array element limit exceeded (${n.maxElements})`,`array_elements`);e.push(t)}function tF(e,t){if(t&&O(e)>t.maxStringBytes)throw new A(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,`string_length`);let n=[],r=``,i=!1,a=!1,o=!1,s=!1;for(let c of e){if(o){r+=c,o=!1,s=!0;continue}if(c===`\\`){o=!0;continue}if(c===`'`&&!a){i||(s=!0),i=!i;continue}if(c===`"`&&!i){a||(s=!0),a=!a;continue}if((c===` `||c===` `||c===`
943
+ `,2):fP(n.value)}async function FP(e,t,n){return IP(e,t,n)}async function IP(e,t,n){let{value:r,pos:i}=await LP(e,t,n);for(;t[i]===`-o`;){let n=await LP(e,t,i+1);r||=n.value,i=n.pos}return{value:r,pos:i}}async function LP(e,t,n){let{value:r,pos:i}=await RP(e,t,n);for(;t[i]===`-a`;){let n=await RP(e,t,i+1);r&&=n.value,i=n.pos}return{value:r,pos:i}}async function RP(e,t,n){let r=e.executionScope.enterDepth(`test_expression`,e.limits.maxCallDepth,`test expression`);try{if(t[n]===`!`){let{value:r,pos:i}=await RP(e,t,n+1);return{value:!r,pos:i}}return zP(e,t,n)}finally{r.release()}}async function zP(e,t,n){let r=t[n];if(r===`(`){let{value:r,pos:i}=await FP(e,t,n+1);return{value:r,pos:t[i]===`)`?i+1:i}}let i=t[n+1];if(DP(i))return{value:OP(i,r,t[n+2]??``),pos:n+3};if(TP(i)){let e=XP(r),a=XP(t[n+2]??`0`);return!e.valid||!a.valid?{value:!1,pos:n+3}:{value:EP(i,e.value,a.value),pos:n+3}}return SP(i)?{value:await CP(e,i,r,t[n+2]??``),pos:n+3}:yP(r)?{value:await bP(e,r,t[n+1]??``),pos:n+2}:AP(r)?{value:jP(r,t[n+1]??``),pos:n+2}:r===`-v`?{value:await MP(e,t[n+1]??``),pos:n+2}:r===`-o`?{value:KP(e,t[n+1]??``),pos:n+2}:{value:r!==void 0&&r!==``,pos:n+1}}function BP(e,t,n=!1,r=!1,i=256){return r&&VP(t,i),U(`^${HP(t,r)}$`,n?`is`:`s`).test(e)}function VP(e,t){let n=0,r=[];for(let i=0;i<e.length;i++){if(e[i]===`\\`){i++;continue}if(e[i]===`(`){let a=i>0&&`@*+?!`.includes(e[i-1]);if(r.push(a),a&&n++,n>t)throw new A(`extglob maximum depth (${t}) exceeded`,`recursion`)}else e[i]===`)`&&r.length>0&&r.pop()&&n--}}function HP(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(t&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let a=UP(e,r+1);if(a!==-1){let o=WP(e.slice(r+2,a)),s=o.map(e=>HP(e,t)),c=s.length>0?s.join(`|`):`(?:)`;if(i===`@`)n+=`(?:${c})`;else if(i===`*`)n+=`(?:${c})*`;else if(i===`+`)n+=`(?:${c})+`;else if(i===`?`)n+=`(?:${c})?`;else if(i===`!`){if(a<e.length-1){let e=o.map(e=>GP(e,t));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let t=e[0];if(t===0)n+=`(?:.+)`;else{let e=[];t>0&&e.push(`.{0,${t-1}}`),e.push(`.{${t+1},}`),e.push(`(?!(?:${c})).{${t}}`),n+=`(?:${e.join(`|`)})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`}r=a;continue}}if(i===`\\`){if(r+1<e.length){let t=e[r+1];/[\\^$.|+(){}[\]*?]/.test(t)?n+=`\\${t}`:n+=t,r++}else n+=`\\\\`}else if(i===`*`)n+=`.*`;else if(i===`?`)n+=`.`;else if(i===`[`){let t=e.indexOf(`]`,r+1);t===-1?n+=`\\[`:(n+=e.slice(r,t+1),r=t)}else/[\\^$.|+(){}]/.test(i)?n+=`\\${i}`:n+=i}return n}function UP(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function WP(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function GP(e,t){let n=0,r=0;for(;r<e.length;){let i=e[r];if(t&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let a=UP(e,r+1);if(a!==-1){if(i===`@`){let i=WP(e.slice(r+2,a)).map(e=>GP(e,t));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){n+=i[0],r=a+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){n+=1,r++;continue}if(i===`[`){let t=e.indexOf(`]`,r+1);if(t!==-1){n+=1,r=t+1;continue}n+=1,r++;continue}if(i===`\\`){n+=1,r+=2;continue}n+=1,r++}return n}function KP(e,t){let n=new Map([[`errexit`,()=>e.state.options.errexit===!0],[`nounset`,()=>e.state.options.nounset===!0],[`pipefail`,()=>e.state.options.pipefail===!0],[`xtrace`,()=>e.state.options.xtrace===!0],[`e`,()=>e.state.options.errexit===!0],[`u`,()=>e.state.options.nounset===!0],[`x`,()=>e.state.options.xtrace===!0]]).get(t);return n?n():!1}async function qP(e,t){if(t=t.trim(),t===``)return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return YP(t);try{return await rP(e,sO(new Tk,t).expression)}catch{return YP(t)}}function JP(e,t){let n=0;for(let r of e){let e;if(r>=`0`&&r<=`9`)e=r.charCodeAt(0)-48;else if(r>=`a`&&r<=`z`)e=r.charCodeAt(0)-97+10;else if(r>=`A`&&r<=`Z`)e=r.charCodeAt(0)-65+36;else if(r===`@`)e=62;else if(r===`_`)e=63;else return NaN;if(e>=t)return NaN;n=n*t+e}return n}function YP(e){if(e=e.trim(),e===``)return 0;let t=!1;e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1));let n,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let e=Number.parseInt(r[1],10);n=e>=2&&e<=64?JP(r[2],e):0}else n=/^0[xX][0-9a-fA-F]+$/.test(e)?Number.parseInt(e,16):/^0[0-7]+$/.test(e)?Number.parseInt(e,8):Number.parseInt(e,10);return Number.isNaN(n)&&(n=0),t?-n:n}function XP(e){if(e=e.trim(),e===``)return{value:0,valid:!0};let t=!1;if(e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let n=Number.parseInt(e,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:t?-n:n,valid:!0}}function ZP(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length)t+=e[n]+e[n+1],n+=2;else if(e[n]===`[`){let r=QP(e,n);t+=r.converted,n=r.endIndex}else t+=e[n],n++;return t}function QP(e,t){let n=t+1,r=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(r+=`^`,n++);let i=!1;n<e.length&&e[n]===`]`&&(i=!0,n++);let a=!1;n<e.length&&e[n]===`[`&&n+1<e.length&&e[n+1]!==`:`&&(a=!0,n++);let o=``,s=!1;for(;n<e.length;){let t=e[n];if(t===`]`){s=!0,n++;break}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=e.slice(n+2,t);o+=$P(r),n=t+2;continue}}if(t===`[`&&n+1<e.length){let t=e[n+1];if(t===`.`||t===`=`){let r=`${t}]`,i=e.indexOf(r,n+2);if(i!==-1){let t=e.slice(n+2,i);o+=t,n=i+2;continue}}}if(t===`\\`&&n+1<e.length){o+=t+e[n+1],n+=2;continue}o+=t,n++}return s?(i&&(r+=`\\]`),a&&(r+=`\\[`),r+=o,r+=`]`,{converted:r,endIndex:n}):{converted:`\\[`,endIndex:t+1}}function $P(e){return 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`]]).get(e)??``}j(),k(),j();function eF(e,t,n){if(n&&e.length>=n.maxElements)throw new A(`array element limit exceeded (${n.maxElements})`,`array_elements`);e.push(t)}function tF(e,t){if(t&&O(e)>t.maxStringBytes)throw new A(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,`string_length`);let n=[],r=``,i=!1,a=!1,o=!1,s=!1;for(let c of e){if(o){r+=c,o=!1,s=!0;continue}if(c===`\\`){o=!0;continue}if(c===`'`&&!a){i||(s=!0),i=!i;continue}if(c===`"`&&!i){a||(s=!0),a=!a;continue}if((c===` `||c===` `||c===`
944
944
  `)&&!i&&!a){s&&=(eF(n,r,t),r=``,!1);continue}r+=c,s=!0}return s&&eF(n,r,t),n}function nF(e,t){if(t&&O(e)>t.maxStringBytes)throw new A(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,`string_length`);let n=[],r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;if(e[r]!==`[`){r++;continue}r++;let i=``;if(e[r]===`'`||e[r]===`"`){let t=e[r];for(r++;r<e.length&&e[r]!==t;)i+=e[r],r++;e[r]===t&&r++}else for(;r<e.length&&e[r]!==`]`&&e[r]!==`=`;)i+=e[r],r++;for(;r<e.length&&e[r]!==`]`;)r++;if(e[r]===`]`&&r++,e[r]!==`=`)continue;r++;let a=``;if(e[r]===`'`||e[r]===`"`){let t=e[r];for(r++;r<e.length&&e[r]!==t;)e[r]===`\\`&&r+1<e.length&&r++,a+=e[r],r++;e[r]===t&&r++}else for(;r<e.length&&!/\s/.test(e[r]);)a+=e[r],r++;eF(n,[i,a],t)}return n}function rF(e,t){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(n)return{name:n[1],isArray:!0,arrayElements:tF(n[2],t)};let r=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(r)return{name:r[1],isArray:!1,arrayIndex:r[2],value:r[3]};if(e.includes(`=`)){let t=e.indexOf(`=`);return{name:e.slice(0,t),isArray:!1,value:e.slice(t+1)}}return{name:e,isArray:!1}}async function iF(e,t){try{return await rP(e,sO(new Tk,t).expression)}catch{let e=parseInt(t,10);return Number.isNaN(e)?0:e}}async function aF(e,t,n={}){let{name:r,isArray:i,arrayElements:a,value:o,arrayIndex:s}=t,{makeReadonly:c=!1,checkReadonly:l=!0}=n;if(l){let t=Ij(e,r);if(t)return t}if(i&&a){e.executionScope.consumeWork(a.length,`array assignment`);let t=tD(e,r),n=t?$E(t):void 0,i=e.state.env.get(r);try{dD(e,r);for(let t=0;t<a.length;t++)Y(e,r,t,a[t]);e.state.env.delete(r)}catch(t){throw e.state.arrays??=new Map,n?e.state.arrays.set(r,n):e.state.arrays.delete(r),i===void 0?e.state.env.delete(r):e.state.env.set(r,i),t}}else s!==void 0&&o!==void 0?Y(e,r,await iF(e,s),o):o!==void 0&&e.state.env.set(r,o);return c&&Pj(e,r),null}function oF(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function sF(e,t){return e.state.localVarDepth?.get(t)}function cF(e,t){e.state.localVarDepth?.delete(t)}function lF(e,t,n){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:n,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function uF(e,t){let n=e.state.localVarStack?.get(t);if(!(!n||n.length===0))return n.pop()}function dF(e,t){if(e.state.localVarStack)for(let[n,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(n)}}j();var fF=new Set([`:`,`.`,`break`,`continue`,`eval`,`exec`,`exit`,`export`,`readonly`,`return`,`set`,`shift`,`trap`,`unset`]);function pF(e){return fF.has(e)}var mF=new Set([`if`,`then`,`else`,`elif`,`fi`,`case`,`esac`,`for`,`select`,`while`,`until`,`do`,`done`,`in`,`function`,`{`,`}`,`time`,`[[`,`]]`,`!`]),hF=new Set(`:,true,false,cd,export,unset,exit,local,set,break,continue,return,eval,shift,getopts,compgen,complete,compopt,pushd,popd,dirs,source,.,read,mapfile,readarray,declare,typeset,readonly,let,command,shopt,exec,test,[,echo,printf,pwd,alias,unalias,type,hash,ulimit,umask,trap,times,wait,kill,jobs,fg,bg,disown,suspend,fc,history,help,enable,builtin,caller`.split(`,`));k(),j();var gF=`__file__:`,_F=`__file_append__:`,vF=`__rw__:`,yF=`__dupout__:`,bF=`__dupin__:`,xF=3;function SF(e){let t=e.slice(vF.length),n=t.indexOf(`:`);if(n===-1)return null;let r=Number.parseInt(t.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let i=n+1,a=t.slice(i,i+r),o=t.slice(i+r+1),s=o.indexOf(`:`);if(s===-1)return null;let c=Number.parseInt(o.slice(0,s),10);return Number.isNaN(c)||c<0?null:{path:a,position:c,content:o.slice(s+1)}}function CF(e,t){let n=Number.parseInt(e.slice(t.length),10);return Number.isNaN(n)?null:n}function wF(e){if(e.startsWith(gF))return{kind:`output`,path:e.slice(gF.length),append:!1};if(e.startsWith(_F))return{kind:`output`,path:e.slice(_F.length),append:!0};if(e.startsWith(vF)){let t=SF(e);if(t)return{kind:`readwrite`,...t}}if(e.startsWith(yF)){let t=CF(e,yF);if(t!==null)return{kind:`dup-out`,sourceFd:t}}if(e.startsWith(bF)){let t=CF(e,bF);if(t!==null)return{kind:`dup-in`,sourceFd:t}}return{kind:`input`,content:e}}function TF(e){switch(e.kind){case`input`:return e.content;case`output`:return`${e.append?_F:gF}${e.path}`;case`readwrite`:return`${vF}${e.path.length}:${e.path}:${e.position}:${e.content}`;case`dup-out`:return`${yF}${e.sourceFd}`;case`dup-in`:return`${bF}${e.sourceFd}`;case`closed`:throw Error(`Closed descriptors have no table encoding`)}}function EF(e){return e.state.fileDescriptors??=new Map,e.state.fileDescriptors}function DF(e,t,n){n?(e.state.inputFds??=new Set,e.state.inputFds.add(t)):e.state.inputFds?.delete(t)}function OF(e,t){return e.state.fdAliases?.get(t)}function kF(e,t){return[...OF(e,t)??[t]]}function AF(e,t){let n=OF(e,t);if(n&&(n.delete(t),e.state.fdAliases?.delete(t),n.size<2))for(let t of n)e.state.fdAliases?.delete(t)}function jF(e,t,n){if(t===n)return;e.state.fdAliases??=new Map;let r=OF(e,n)??new Set([n]);r.add(t);for(let t of r)e.state.fdAliases.set(t,r)}function MF(e,t){return e.state.fileDescriptors?.get(t)}function NF(e,t){let n=MF(e,t);if(n!==void 0)return e.state.inputFds?.has(t)?{kind:`input`,content:n}:wF(n)}function PF(e,t){return e.state.fileDescriptors?.has(t)===!0}function FF(e,t,n,r){let i=EF(e);i.has(t)||mP(e),i.set(t,n),DF(e,t,r)}function IF(e,t,n,r=!1){AF(e,t),FF(e,t,n,r)}function LF(e,t,n){IF(e,t,TF(n),n.kind===`input`)}function RF(e,t){e.state.fileDescriptors?.delete(t),e.state.inputFds?.delete(t),AF(e,t)}function zF(e,t,n){let r=MF(e,n);return r!==void 0&&(IF(e,t,r,e.state.inputFds?.has(n)===!0),jF(e,t,n),!0)}function BF(e,t,n){let r=MF(e,n);if(r===void 0)return!1;if(t===n)return!0;let i=e.state.inputFds?.has(n)===!0,a=[...OF(e,n)??[]].filter(e=>e!==n);RF(e,n),IF(e,t,r,i);let o=a.find(t=>PF(e,t));return o!==void 0&&jF(e,t,o),!0}function VF(e,t){let n=NF(e,t);if(n===void 0)return{error:`not-open`};switch(n.kind){case`input`:return{content:n.content};case`readwrite`:return{content:n.content.slice(n.position)};case`output`:case`dup-out`:return{error:`write-only`};case`dup-in`:return{error:`not-open`};case`closed`:return{error:`not-open`}}}function HF(e,t,n){let r=NF(e,t);if(r===void 0)return;let i;if(r.kind===`input`)i={kind:`input`,content:r.content.slice(n)};else if(r.kind===`readwrite`)i={...r,position:r.position+n};else return;let a=TF(i),o=i.kind===`input`;for(let n of OF(e,t)??[t])FF(e,n,a,o)}async function UF(e,t,n,r,i){if(t.kind===`output`)return await e.fs.appendFile(t.path,r,i),!0;let a=n.map(t=>NF(e,t)).find(e=>e?.kind===`readwrite`)??t;if(a.kind!==`readwrite`)return!1;let o=a.content.slice(0,a.position)+r+a.content.slice(a.position+r.length),s={...a,position:a.position+r.length,content:o};await e.fs.writeFile(a.path,o,i);let c=TF(s);for(let t of n)PF(e,t)&&FF(e,t,c,!1);return!0}function WF(e,t,n){if(t.has(n))return;let r=OF(e,n);t.set(n,{raw:MF(e,n),isInput:e.state.inputFds?.has(n)===!0,aliases:r?[...r].filter(e=>e!==n):[]})}function GF(e,t){let n=e.state.fileDescriptors;if(n)for(let[r,{raw:i,isInput:a,aliases:o}]of t){if(i===void 0){RF(e,r);continue}IF(e,r,i,a);let t=o.find(e=>n.has(e));t!==void 0&&jF(e,r,t)}}function KF(e){switch(e.operator){case`<`:case`<>`:case`<<`:case`<<-`:case`<<<`:case`<&`:return e.fd??0;case`>`:case`>>`:case`>|`:case`>&`:return e.fd??1;default:return null}}function qF(e){if(e.fdVariable)return!1;let t=KF(e);return t!==null&&t>=xF}async function JF(e,t,n,r){try{if(!await e.fs.exists(t))return null;if((await e.fs.stat(t)).isDirectory)return`bash: ${n}: Is a directory
945
945
  `;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&n!==`/dev/null`)return`bash: ${n}: cannot overwrite existing file
946
946
  `}catch{return`bash: ${n}: cannot open redirect target
@@ -965,8 +965,8 @@ ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}fun
965
965
  `});else if(d.operator===`<`||d.operator===`<>`){let n=await aI(e,v,d.operator===`<>`);if(n.error)return p(n.error,o);LF(e,t,n.entry)}continue}if(y){if(v===`-`){f===0&&(l=``,u=-1),f!==null&&f<xF&&(s.set(f,{kind:`closed`}),r.policy===`persistent`&&(RF(e,f),e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(f)));continue}let t=nI(v);if(!t){if(d.operator===`<&`)return p($(``,`bash: ${v}: ambiguous redirect
966
966
  `,1),o);let t=await iI(e,v,!1,!1,!1);if(t.error)return p(t.error,o);let n=t.entry;a.set(o,{kind:`entry`,entry:n,descriptors:[]}),d.fd==null?(h(1,n),h(2,n)):h(f,n);continue}let i=_(t.sourceFd,d.operator===`<&`);if(!i)return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
967
967
  `,1),o);if(a.set(o,i),i.kind===`entry`&&r.policy===`persistent`&&f!==null&&f<xF&&t.sourceFd>=xF){if(!zF(e,f,t.sourceFd))return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
968
- `,1),o);s.set(f,NF(e,f)),e.state.closedStandardFds?.delete(f)}else i.kind===`standard`?h(f,{kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:i.fd}):h(f,i.entry);if(d.operator===`<&`&&f===0)if(i.kind===`standard`)l=i.fd===0?n:``,u=-1;else if(i.entry.kind===`input`||i.entry.kind===`readwrite`){let n=t.sourceFd<xF&&!PF(e,t.sourceFd)?{content:i.entry.kind===`input`?i.entry.content:i.entry.content.slice(i.entry.position)}:VF(e,t.sourceFd);if(`error`in n)return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
969
- `,1),o);l=n.content,u=PF(e,t.sourceFd)?t.sourceFd:-1}else l=n,u=-1;t.move&&(t.sourceFd>=xF?RF(e,t.sourceFd):(s.set(t.sourceFd,{kind:`closed`}),r.policy===`persistent`&&(RF(e,t.sourceFd),e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(t.sourceFd))));continue}if(d.operator===`>`||d.operator===`>|`||d.operator===`>>`||d.operator===`&>`||d.operator===`&>>`){let t=await iI(e,v,d.operator===`>>`||d.operator===`&>>`,d.operator===`>|`,!1);if(t.error)return p(t.error,o);let n=t.entry;d.operator===`&>`||d.operator===`&>>`?(h(1,n),h(2,n)):h(f,n);continue}if(d.operator===`<<<`)l=sr(`${v}
968
+ `,1),o);s.set(f,NF(e,f)),e.state.closedStandardFds?.delete(f)}else i.kind===`standard`?h(f,{kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:i.fd}):h(f,i.entry);if(d.operator===`<&`&&f===0){if(i.kind===`standard`)l=i.fd===0?n:``,u=-1;else if(i.entry.kind===`input`||i.entry.kind===`readwrite`){let n=t.sourceFd<xF&&!PF(e,t.sourceFd)?{content:i.entry.kind===`input`?i.entry.content:i.entry.content.slice(i.entry.position)}:VF(e,t.sourceFd);if(`error`in n)return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
969
+ `,1),o);l=n.content,u=PF(e,t.sourceFd)?t.sourceFd:-1}else l=n,u=-1}t.move&&(t.sourceFd>=xF?RF(e,t.sourceFd):(s.set(t.sourceFd,{kind:`closed`}),r.policy===`persistent`&&(RF(e,t.sourceFd),e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(t.sourceFd))));continue}if(d.operator===`>`||d.operator===`>|`||d.operator===`>>`||d.operator===`&>`||d.operator===`&>>`){let t=await iI(e,v,d.operator===`>>`||d.operator===`&>>`,d.operator===`>|`,!1);if(t.error)return p(t.error,o);let n=t.entry;d.operator===`&>`||d.operator===`&>>`?(h(1,n),h(2,n)):h(f,n);continue}if(d.operator===`<<<`)l=sr(`${v}
970
970
  `),u=-1,h(f,{kind:`input`,content:l});else if(d.operator===`<`){let t=e.fs.resolvePath(e.state.cwd,v);try{l=await lr(e.fs,t),u=-1,h(f,{kind:`input`,content:l})}catch{return p($(``,`bash: ${v}: No such file or directory
971
971
  `,1),o)}}else if(d.operator===`<>`){let t=await aI(e,v,!0);if(t.error)return p(t.error,o);let n=t.entry;h(f,n),f===0&&n.kind===`readwrite`&&(l=n.content,u=-1)}}return f()}function cI(e,t,n){let r={numericSnapshot:new Map,fdVariableSnapshot:new Map,standardSnapshot:new Map,standardClosedSnapshot:new Map,fdVariableEnv:new Map,nextFd:e.state.nextFd,policy:n},i=!1;return{prepare:(n=``)=>sI(e,t,n,r),finish:()=>{if(!i){if(i=!0,n!==`persistent`&&GF(e,r.numericSnapshot),n!==`persistent`){GF(e,r.standardSnapshot);for(let[t,n]of r.standardClosedSnapshot)n?(e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(t)):e.state.closedStandardFds?.delete(t)}if(n===`bare`){GF(e,r.fdVariableSnapshot);for(let[t,n]of r.fdVariableEnv)n===void 0?e.state.env.delete(t):e.state.env.set(t,n);e.state.nextFd=r.nextFd}}}}}function lI(e){if(!e.error)throw Error(`Expected a redirection error`);if(e.errorCause)throw e.errorCause.stdout=e.error.stdout,e.errorCause.stderr=e.error.stderr,e.errorCause;return e.error}async function uI(e,t,n,r){let i=t instanceof wr||t instanceof xr||t instanceof Sr?t.exitCode:t instanceof A?A.EXIT_CODE:0,a=await fI(e,$(t.stdout,t.stderr,i),n,r.targets,r.dupSources,r.standardRoutes);t.stdout=a.stdout,t.stderr=a.stderr,t.internalOutputAccounting=a.internalOutputAccounting??{stdout:O(a.stdout),stderr:O(a.stderr)}}async function dI(e,t,n,r){let i=cI(e,t,XF),a;try{if(a=await i.prepare(n),a.error)return lI(a);let o=e.state.groupStdin,s=e.state.groupStdinSourceFd;a.stdin!==void 0&&(e.state.groupStdin=a.stdin,e.state.groupStdinSourceFd=a.stdinSourceFd);try{return await fI(e,await r(a),t,a.targets,a.dupSources,a.standardRoutes)}finally{a.stdin!==void 0&&(e.state.groupStdin=o,e.state.groupStdinSourceFd=s)}}catch(n){throw!(n instanceof vr)||!a||await uI(e,n,t,a),n}finally{i.finish()}}async function fI(e,t,n,r,i=new Map,a=new Map,o=`bash`,s=!1){n.length>0&&(t=e.executionScope.accountResult(t,`redirection`));let{stdout:c,stderr:l,exitCode:u}=t,d=t.stdoutKind===`bytes`||t.stdoutKind===void 0&&t.stdoutEncoding===`binary`?`binary`:`utf8`,f=e=>d,p={kind:`live-stdout`},m={kind:`live-stderr`},h=e=>{if(!e)return null;if(e.kind===`entry`){if(e.entry.kind===`dup-out`){if(e.entry.sourceFd===1)return{kind:`live-stdout`};if(e.entry.sourceFd===2)return{kind:`live-stderr`}}return e.entry.kind===`output`||e.entry.kind===`readwrite`?{kind:`descriptor`,source:e}:null}return e.fd===1?p:e.fd===2?m:null},g=t=>{let n=a.get(t)??NF(e,t);return n?n.kind===`closed`||n.kind===`input`||n.kind===`dup-in`?{kind:`invalid-output`,fd:t}:n.kind===`dup-out`?n.sourceFd===1?{kind:`live-stdout`}:n.sourceFd===2?{kind:`live-stderr`}:null:n.kind===`output`||n.kind===`readwrite`?{kind:`descriptor`,source:{kind:`entry`,entry:n,descriptors:kF(e,t)}}:null:null};p=g(1)??p,m=g(2)??m;for(let t=0;t<n.length;t++){let a=n[t];if(a.target.type===`HereDoc`||a.fdVariable)continue;let o=r.get(t);if(o!==void 0)switch(a.operator){case`>`:case`>|`:case`>>`:{let t=a.fd??1;if(t!==1&&t!==2)break;let n=a.operator===`>>`;if(o===`/dev/stdout`){t===2&&(m=p);break}if(o===`/dev/stderr`){t===1&&(p=m);break}if(o===`/dev/full`){l+=`bash: echo: write error: No space left on device
972
972
  `,u=1,t===1&&(c=``);break}if(o===`/dev/null`&&t===2){m={kind:`discard`};break}let r=e.fs.resolvePath(e.state.cwd,o);t===1?p={kind:`file`,path:r,append:n}:m={kind:`file`,path:r,append:n};break}case`>&`:case`<&`:{let e=a.fd??(a.operator===`<&`?0:1);if(e>=xF||e===0)break;if(o===`-`){e===1?p={kind:`discard`}:m={kind:`discard`};break}let n=h(i.get(t));if(!n)break;a.fd==null&&nI(o)===null?(p=n,m=n):e===1?p=n:e===2&&(m=n);break}case`&>`:p={kind:`file`,path:e.fs.resolvePath(e.state.cwd,o),append:!1},m=p;break;case`&>>`:p={kind:`file`,path:e.fs.resolvePath(e.state.cwd,o),append:!0},m=p;break}}if(c!==``||l!==``){let t=c,n=l;c=``,l=``,p.kind===`invalid-output`&&t!==``&&(t=``,n+=`${s?``:`bash: `}${o}: write error: Bad file descriptor
@@ -984,7 +984,7 @@ ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}fun
984
984
  `,2);u=t[e]}else if(o===`-G`){if(e++,e>=t.length)return Q(`compgen: -G: option requires an argument
985
985
  `,2)}else if(o===`--`){p.push(...t.slice(e+1));break}else o.startsWith(`-`)||p.push(o)}o=p[0]??null;let h=[],g=new Set,_=()=>e.limits.maxArrayElements-h.length,v=t=>{for(let n of t){if(h.length>=e.limits.maxArrayElements)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(O(n)>e.limits.maxStringLength)throw new A(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);e.executionScope.consumeWork(1,`compgen completion`),h.push(n),g.add(n)}};c&&v(await kI(e,o,_())),l&&v(await AI(e,o,_()));for(let t of n)t===`variable`?v(xI(e,o,_())):t===`export`?v(SI(e,o,_())):t===`function`?v(CI(e,o,_())):t===`builtin`?v(wI(e,o,_())):t===`keyword`?v(TI(e,o,_())):t===`alias`?v(EI(e,o,_())):t===`shopt`?v(DI(e,o,_())):t===`helptopic`?v(OI(e,o,_())):t===`directory`?v(await kI(e,o,_())):t===`file`?v(await AI(e,o,_())):t===`user`?v(jI(e,o,_())):t===`command`&&v(await MI(e,o,_()));if(r!==null)try{let t=FI(e,await PI(e,r),_(),o);for(let e of t)v([e])}catch(e){if(e instanceof A)throw e;return $(``,``,1)}if(s){let t=await kI(e,o,_(),g);for(let e of t)g.has(e)||v([e])}let y=``;if(d!==null){let t=e.state.functions.get(d);if(t){let n=new Map,r=tD(e,`COMP_WORDS`),i=r?$E(r):void 0;dD(e,`COMP_WORDS`),nD(e,`COMP_WORDS`),n.set(`COMP_CWORD`,e.state.env.get(`COMP_CWORD`)),e.state.env.set(`COMP_CWORD`,`-1`),n.set(`COMP_LINE`,e.state.env.get(`COMP_LINE`)),e.state.env.set(`COMP_LINE`,``),n.set(`COMP_POINT`,e.state.env.get(`COMP_POINT`)),e.state.env.set(`COMP_POINT`,`0`);let a=tD(e,`COMPREPLY`),o=a?$E(a):void 0,s=e.state.env.get(`COMPREPLY`);dD(e,`COMPREPLY`),e.state.env.delete(`COMPREPLY`);let c=[`compgen`,p[0]??``,``];try{let r=await mI(e,t,c,``);if(r.exitCode!==0)return II(e,n),LI(e,`COMP_WORDS`,i),LI(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s),$(``,r.stderr,1);y=r.stdout,v(RI(e,_()))}catch(t){if(t instanceof A)throw t;return II(e,n),LI(e,`COMP_WORDS`,i),LI(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s),$(``,``,1)}II(e,n),LI(e,`COMP_WORDS`,i),LI(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s)}}if(f!==null)try{let t=Ek(f),n=await e.executeScript(t);if(n.exitCode!==0)return $(``,n.stderr,n.exitCode);if(n.stdout)for(let e of zI(n.stdout))e.length>0&&v([e])}catch(e){if(e.name===`ParseException`)return Q(`compgen: -C: ${e.message}
986
986
  `,2);throw e}let b=h;if(u!==null){let t=u.startsWith(`!`),n=t?u.slice(1):u;b=h.filter(r=>{let i=BP(r,n,!1,!0,e.limits.maxCallDepth);return t?i:!i})}if(b.length===0&&o!==null)return $(y,``,1);let x=new Ui(e.limits.maxOutputSize,`compgen`);x.append(y);for(let e of b)x.append(i).append(e).append(a).append(`
987
- `);return dP(x.build())}function xI(e,t,n){let r=NI(e,t,n);for(let t of e.state.env.keys())/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&r.add(t);for(let t of e.state.arrays?.keys()??[])r.add(t);return r.build()}function SI(e,t,n){let r=NI(e,t,n),i=e.state.exportedVars??new Set;for(let t of i)e.state.env.has(t)&&r.add(t);return r.build()}function CI(e,t,n){let r=NI(e,t,n);for(let t of e.state.functions.keys())r.add(t);return r.build()}function wI(e,t,n){let r=NI(e,t,n);for(let e of _I)r.add(e);return r.build()}function TI(e,t,n){let r=NI(e,t,n);for(let e of gI)r.add(e);return r.build()}function EI(e,t,n){let r=NI(e,t,n);for(let t of e.state.env.keys())if(t.startsWith(`BASH_ALIAS_`)){let e=t.slice(11);r.add(e)}return r.build()}function DI(e,t,n){let r=NI(e,t,n);for(let e of vI)r.add(e);return r.build()}function OI(e,t,n){let r=NI(e,t,n);for(let e of yI)r.add(e);return r.build()}async function kI(e,t,n=e.limits.maxArrayElements,r){let i=NI(e,null,n,r);try{let n=e.state.cwd,r=t??``;if(t){let i=t.lastIndexOf(`/`);if(i!==-1){let a=t.slice(0,i)||`/`;r=t.slice(i+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let o of a){e.executionScope.consumeWork(1,`compgen directory scan`);let a=`${n}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!r||o.startsWith(r)))if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),n=t.slice(0,e+1);i.add(n+o)}else i.add(o)}catch(e){if(e instanceof A)throw e}}}catch(e){if(e instanceof A)throw e}return i.build()}async function AI(e,t,n=e.limits.maxArrayElements){let r=NI(e,null,n);try{let n=e.state.cwd,i=t??``;if(t){let r=t.lastIndexOf(`/`);if(r!==-1){let a=t.slice(0,r)||`/`;i=t.slice(r+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let n of a)if(e.executionScope.consumeWork(1,`compgen file scan`),!i||n.startsWith(i))if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),i=t.slice(0,e+1);r.add(i+n)}else r.add(n)}catch(e){if(e instanceof A)throw e}return r.build()}function jI(e,t,n){let r=NI(e,t,n);return r.add(`root`),r.add(`nobody`),r.build()}async function MI(e,t,n){let r=NI(e,t,n);for(let e of _I)r.add(e);for(let t of e.state.functions.keys())r.add(t);for(let t of e.state.env.keys())t.startsWith(`BASH_ALIAS_`)&&r.add(t.slice(11));for(let e of gI)r.add(e);let i=e.state.env.get(`PATH`)??`/usr/bin:/bin`;for(let t of i.split(`:`))if(t)try{let n=await e.fs.readdir(t);for(let e of n)r.add(e)}catch(e){if(e instanceof A)throw e}return r.build()}function NI(e,t,n,r){let i=new Set;return{add(a){if(e.executionScope.consumeWork(1,`compgen candidate collection`),!(t!==null&&!a.startsWith(t))&&!r?.has(a)&&!i.has(a)){if(i.size>=n)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(O(a)>e.limits.maxStringLength)throw new A(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);i.add(a)}},build(){return Array.from(i).sort()}}}async function PI(e,t){let n=new Tk().parseWordFromString(t,!1,!1);return await MN(e,X.word(n.parts.map(hI)))}function FI(e,t,n,r){let i=e.state.env.get(`IFS`)??`
987
+ `);return dP(x.build())}function xI(e,t,n){let r=NI(e,t,n);for(let t of e.state.env.keys())/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&r.add(t);for(let t of e.state.arrays?.keys()??[])r.add(t);return r.build()}function SI(e,t,n){let r=NI(e,t,n),i=e.state.exportedVars??new Set;for(let t of i)e.state.env.has(t)&&r.add(t);return r.build()}function CI(e,t,n){let r=NI(e,t,n);for(let t of e.state.functions.keys())r.add(t);return r.build()}function wI(e,t,n){let r=NI(e,t,n);for(let e of _I)r.add(e);return r.build()}function TI(e,t,n){let r=NI(e,t,n);for(let e of gI)r.add(e);return r.build()}function EI(e,t,n){let r=NI(e,t,n);for(let t of e.state.env.keys())if(t.startsWith(`BASH_ALIAS_`)){let e=t.slice(11);r.add(e)}return r.build()}function DI(e,t,n){let r=NI(e,t,n);for(let e of vI)r.add(e);return r.build()}function OI(e,t,n){let r=NI(e,t,n);for(let e of yI)r.add(e);return r.build()}async function kI(e,t,n=e.limits.maxArrayElements,r){let i=NI(e,null,n,r);try{let n=e.state.cwd,r=t??``;if(t){let i=t.lastIndexOf(`/`);if(i!==-1){let a=t.slice(0,i)||`/`;r=t.slice(i+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let o of a){e.executionScope.consumeWork(1,`compgen directory scan`);let a=`${n}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!r||o.startsWith(r))){if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),n=t.slice(0,e+1);i.add(n+o)}else i.add(o)}}catch(e){if(e instanceof A)throw e}}}catch(e){if(e instanceof A)throw e}return i.build()}async function AI(e,t,n=e.limits.maxArrayElements){let r=NI(e,null,n);try{let n=e.state.cwd,i=t??``;if(t){let r=t.lastIndexOf(`/`);if(r!==-1){let a=t.slice(0,r)||`/`;i=t.slice(r+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let n of a)if(e.executionScope.consumeWork(1,`compgen file scan`),!i||n.startsWith(i)){if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),i=t.slice(0,e+1);r.add(i+n)}else r.add(n)}}catch(e){if(e instanceof A)throw e}return r.build()}function jI(e,t,n){let r=NI(e,t,n);return r.add(`root`),r.add(`nobody`),r.build()}async function MI(e,t,n){let r=NI(e,t,n);for(let e of _I)r.add(e);for(let t of e.state.functions.keys())r.add(t);for(let t of e.state.env.keys())t.startsWith(`BASH_ALIAS_`)&&r.add(t.slice(11));for(let e of gI)r.add(e);let i=e.state.env.get(`PATH`)??`/usr/bin:/bin`;for(let t of i.split(`:`))if(t)try{let n=await e.fs.readdir(t);for(let e of n)r.add(e)}catch(e){if(e instanceof A)throw e}return r.build()}function NI(e,t,n,r){let i=new Set;return{add(a){if(e.executionScope.consumeWork(1,`compgen candidate collection`),!(t!==null&&!a.startsWith(t))&&!r?.has(a)&&!i.has(a)){if(i.size>=n)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(O(a)>e.limits.maxStringLength)throw new A(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);i.add(a)}},build(){return Array.from(i).sort()}}}async function PI(e,t){let n=new Tk().parseWordFromString(t,!1,!1);return await MN(e,X.word(n.parts.map(hI)))}function FI(e,t,n,r){let i=e.state.env.get(`IFS`)??`
988
988
  `;if(i.length===0){if(r!==null&&!t.startsWith(r))return[];if(n===0)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);return[t]}let a=new Set(i.split(``)),o=[],s=t=>{if(!(r!==null&&!t.startsWith(r))){if(o.length>=n)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);o.push(t)}},c=``,l=0;for(;l<t.length;){let e=t[l];if(e===`\\`&&l+1<t.length){let e=t[l+1];c+=e,l+=2}else a.has(e)?(c.length>0&&(s(c),c=``),l++):(c+=e,l++)}return c.length>0&&s(c),o}function II(e,t){for(let[n,r]of t)r===void 0?e.state.env.delete(n):e.state.env.set(n,r)}function LI(e,t,n){e.state.arrays??=new Map,n?e.state.arrays.set(t,$E(n)):e.state.arrays.delete(t)}function RI(e,t){let n=[],r=r=>{if(n.length>=t)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);n.push(r)};if(iD(e,`COMPREPLY`)){let t=nj(e,`COMPREPLY`);for(let[,e]of t)r(e)}else{let t=e.state.env.get(`COMPREPLY`);t!==void 0&&r(t)}return n}function*zI(e){let t=0;for(;t<=e.length;){let n=e.indexOf(`
989
989
  `,t),r=n===-1?e.length:n;if(r>t&&(yield e.slice(t,r)),n===-1)return;t=n+1}}k();function BI(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!0}return!1}function VI(e){let t=`$'`;for(let n=0;n<e.length;n++){let r=e[n],i=e.charCodeAt(n);t+=i===7?`\\a`:i===8?`\\b`:i===9?`\\t`:i===10?`\\n`:i===11?`\\v`:i===12?`\\f`:i===13?`\\r`:i===27?`\\e`:i===39?`\\'`:i===92?`\\\\`:i<32||i===127?`\\${i.toString(8).padStart(3,`0`)}`:r}return t+=`'`,t}function HI(e){if(BI(e))return KI(e);if(e===``)return 2;if(/^[a-zA-Z0-9_/.:\-@%+,=]+$/.test(e))return O(e);let t=O(e)+2;for(let n of e)n===`'`&&(t+=3);return t}function UI(e){return BI(e)?VI(e):e===``?`''`:/^[a-zA-Z0-9_/.:\-@%+,=]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function WI(e){if(BI(e))return KI(e);let t=O(e)+2;for(let n of e)(n===`\\`||n===`"`||n===`$`||n==="`")&&t++;return t}function GI(e){return BI(e)?VI(e):`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}"`}function KI(e){let t=3;for(let n of e){let e=n.codePointAt(0)??0;t+=e===7||e===8||e===9||e===10||e===11||e===12||e===13||e===27||e===39||e===92?2:e<32||e===127?4:O(n)}return t}function qI(e){return BI(e)?VI(e):`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}"`}var JI=[`bashdefault`,`default`,`dirnames`,`filenames`,`noquote`,`nosort`,`nospace`,`plusdirs`];function YI(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let n=!1,r=!1,i=!1,a,o,s,c=[],l=[],u=[];for(let e=0;e<t.length;e++){let d=t[e];if(d===`-p`)n=!0;else if(d===`-r`)r=!0;else if(d===`-D`)i=!0;else if(d===`-W`){if(e++,e>=t.length)return Q(`complete: -W: option requires an argument
990
990
  `,2);a=t[e]}else if(d===`-F`){if(e++,e>=t.length)return Q(`complete: -F: option requires an argument
@@ -1041,7 +1041,7 @@ ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}fun
1041
1041
  `,C=1;continue}let s=Ij(e,r);if(s)return s;if(b(r),c){if(i!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i)){ee+=`bash: declare: \`${i}': invalid variable name for name reference
1042
1042
  `,C=1;continue}e.state.env.set(r,i),KA(e,r),i!==``&&ZA(e,i)&&XA(e,r),S(r),a&&Pj(e,r),o&&Lj(e,r);continue}if(f&&cL(e,r),p&&uL(e,r),m&&fL(e,r),lL(e,r)&&(i=await hL(e,i)),i=mL(e,r,i),GA(e,r)){let t=QA(e,r);t&&t!==r?e.state.env.set(t,i):e.state.env.set(r,i)}else e.state.env.set(r,i);S(r),a&&Pj(e,r),o&&Lj(e,r),e.state.options.allexport&&!d&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(r))}else{let n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){ee+=`bash: typeset: \`${n}': not a valid identifier
1043
1043
  `,C=1;continue}if(r||i?x(n):b(n),c){KA(e,n);let t=e.state.env.get(n);t!==void 0&&t!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t)?JA(e,n):t&&ZA(e,t)&&XA(e,n),S(n),a&&Pj(e,n),o&&Lj(e,n);continue}if(f&&cL(e,n),p&&uL(e,n),m&&fL(e,n),i){if(uD(e,n).length>0){ee+=`bash: declare: ${n}: cannot convert indexed to associative array
1044
- `,C=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(n),rD(e,n,`associative`)}let s=iD(e,n);!e.state.env.has(n)&&!s&&(r||i?rD(e,n,i?`associative`:`indexed`):(e.state.declaredVars??=new Set,e.state.declaredVars.add(n))),S(n),a&&Pj(e,n),o&&Lj(e,n)}}return $(``,ee,C)}async function vL(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength},r=[];for(let e=0;e<t.length;e++){let n=t[e];if(n!==`-a`&&n!==`-A`&&n!==`-p`)if(n===`--`){r.push(...t.slice(e+1));break}else n.startsWith(`-`)||r.push(n)}if(r.length===0){let t=``,n=Array.from(e.state.readonlyVars||[]).sort();for(let r of n){let n=e.state.env.get(r);if(n!==void 0){let e=n.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`);t+=`declare -r ${r}="${e}"
1044
+ `,C=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(n),rD(e,n,`associative`)}let s=iD(e,n);!e.state.env.has(n)&&!s&&(r||i?rD(e,n,i?`associative`:`indexed`):(e.state.declaredVars??=new Set,e.state.declaredVars.add(n))),S(n),a&&Pj(e,n),o&&Lj(e,n)}}return $(``,ee,C)}async function vL(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength},r=[];for(let e=0;e<t.length;e++){let n=t[e];if(n!==`-a`&&n!==`-A`&&n!==`-p`){if(n===`--`){r.push(...t.slice(e+1));break}n.startsWith(`-`)||r.push(n)}}if(r.length===0){let t=``,n=Array.from(e.state.readonlyVars||[]).sort();for(let r of n){let n=e.state.env.get(r);if(n!==void 0){let e=n.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`);t+=`declare -r ${r}="${e}"
1045
1045
  `}}return dP(t)}for(let t of r){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(r){let t=r[1],i=r[2],a=Ij(e,t);if(a)return a;let o=tF(i,n);if(e.state.associativeArrays?.has(t)){let r=nF(i,n);e.executionScope.consumeWork(r.length,`readonly array append`),sD(e,t,r.map(([e])=>e));for(let[n,i]of r)Y(e,t,n,i,`associative`)}else{e.executionScope.consumeWork(o.length,`readonly array append`);let n=uD(e,t),r=0,i=e.state.env.get(t);n.length===0&&i!==void 0?(Y(e,t,0,i),e.state.env.delete(t),r=1):n.length>0&&(r=Math.max(...n)+1),sD(e,t,Array.from({length:o.length},(e,t)=>r+t));for(let n=0;n<o.length;n++)Y(e,t,r+n,o[n])}Pj(e,t);continue}let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(i){let t=i[1],n=i[2],r=Ij(e,t);if(r)return r;let a=e.state.env.get(t)??``;e.state.env.set(t,Hi([a,n],``,e.limits.maxStringLength,`readonly append`)),Pj(e,t);continue}let a=rF(t,n);if(a.value===void 0&&!a.isArray){Pj(e,a.name);continue}let o=await aF(e,a,{makeReadonly:!0});if(o)return o}return uP}function yL(e){return e.state.directoryStack??=[],e.state.directoryStack}function bL(e,t){return t&&e===t?`~`:t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function xL(e){let t=e.split(`/`).filter(e=>e&&e!==`.`),n=[];for(let e of t)e===`..`?n.pop():n.push(e);return`/${n.join(`/`)}`}async function SL(e,t){let n=yL(e),r;for(let e=0;e<t.length;e++){let n=t[e];if(n===`--`){if(e+1<t.length){if(r!==void 0)return Q(`bash: pushd: too many arguments
1046
1046
  `,2);r=t[e+1],e++}}else{if(n.startsWith(`-`)&&n!==`-`)return Q(`bash: pushd: ${n}: invalid option
1047
1047
  `,2);if(r!==void 0)return Q(`bash: pushd: too many arguments
@@ -1054,9 +1054,9 @@ ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}fun
1054
1054
  `,2);if(n.length===0)return Q(`bash: popd: directory stack empty
1055
1055
  `,1);let r=n.shift();if(!r)return Q(`bash: popd: directory stack empty
1056
1056
  `,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,e.state.env.set(`PWD`,r),e.state.env.set(`OLDPWD`,e.state.previousDir);let i=e.state.env.get(`HOME`)||``;return dP(`${[r,...n].map(e=>bL(e,i)).join(` `)}
1057
- `)}function wL(e,t){let n=yL(e),r=!1,i=!1,a=!1,o=!1;for(let e of t)if(e!==`--`)if(e.startsWith(`-`))for(let t of e.slice(1))if(t===`c`)r=!0;else if(t===`l`)i=!0;else if(t===`p`)a=!0;else if(t===`v`)a=!0,o=!0;else return Q(`bash: dirs: -${t}: invalid option
1057
+ `)}function wL(e,t){let n=yL(e),r=!1,i=!1,a=!1,o=!1;for(let e of t)if(e!==`--`){if(e.startsWith(`-`))for(let t of e.slice(1))if(t===`c`)r=!0;else if(t===`l`)i=!0;else if(t===`p`)a=!0;else if(t===`v`)a=!0,o=!0;else return Q(`bash: dirs: -${t}: invalid option
1058
1058
  `,2);else return Q(`bash: dirs: too many arguments
1059
- `,1);if(r)return e.state.directoryStack=[],uP;let s=[e.state.cwd,...n],c=e.state.env.get(`HOME`)||``,l;return o?(l=s.map((e,t)=>` ${t} ${i?e:bL(e,c)}`).join(`
1059
+ `,1)}if(r)return e.state.directoryStack=[],uP;let s=[e.state.cwd,...n],c=e.state.env.get(`HOME`)||``,l;return o?(l=s.map((e,t)=>` ${t} ${i?e:bL(e,c)}`).join(`
1060
1060
  `),l+=`
1061
1061
  `):l=a?s.map(e=>i?e:bL(e,c)).join(`
1062
1062
  `)+`
@@ -1068,10 +1068,10 @@ eval: usage: eval [arg ...]
1068
1068
  `,n=2;else{let t=BigInt(e);n=Number((t%256n+256n)%256n)}}throw new wr(n,``,r)}function DL(e,t){let n=!1,r=[];for(let e of t)e===`-n`?n=!0:e===`-p`||e===`--`||r.push(e);if(r.length===0&&!n){let t=``,n=e.state.exportedVars??new Set,r=Array.from(n).sort();for(let n of r){let r=e.state.env.get(n);r!==void 0&&(t+=`declare -x ${n}=${qI(r)}
1069
1069
  `)}return dP(t)}if(n){for(let t of r){let n,r;if(t.includes(`=`)){let e=t.indexOf(`=`);n=t.slice(0,e),r=t.slice(e+1)}else n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return $(``,`bash: export: \`${t}': not a valid identifier
1070
1070
  `,1);r!==void 0&&(Ij(e,n),e.state.env.set(n,r)),Rj(e,n)}return uP}let i=``,a=0;for(let t of r){let n,r,o=!1,s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(s)n=s[1],r=s[2],o=!0;else if(t.includes(`=`)){let e=t.indexOf(`=`);n=t.slice(0,e),r=t.slice(e+1)}else n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){i+=`bash: export: \`${t}': not a valid identifier
1071
- `,a=1;continue}if(r!==void 0)if(Ij(e,n),o){let t=e.state.env.get(n)??``;e.state.env.set(n,t+r)}else e.state.env.set(n,r);else e.state.env.has(n)||e.state.env.set(n,``);Lj(e,n)}return $(``,i,a)}function OL(e,t){if(t.length<2)return Q(`bash: getopts: usage: getopts optstring name [arg ...]
1071
+ `,a=1;continue}if(r!==void 0){if(Ij(e,n),o){let t=e.state.env.get(n)??``;e.state.env.set(n,t+r)}else e.state.env.set(n,r)}else e.state.env.has(n)||e.state.env.set(n,``);Lj(e,n)}return $(``,i,a)}function OL(e,t){if(t.length<2)return Q(`bash: getopts: usage: getopts optstring name [arg ...]
1072
1072
  `);let n=t[0],r=t[1],i=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),a=n.startsWith(`:`),o=a?n.slice(1):n,s;if(t.length>2)s=t.slice(2);else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);s=[];for(let n=1;n<=t;n++)s.push(e.state.env.get(String(n))||``)}let c=Number.parseInt(e.state.env.get(`OPTIND`)||`1`,10);c<1&&(c=1);let l=Number.parseInt(e.state.env.get(`__GETOPTS_CHARINDEX`)||`0`,10);if(e.state.env.set(`OPTARG`,``),c>s.length)return i||e.state.env.set(r,`?`),e.state.env.set(`OPTIND`,String(s.length+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),{exitCode:i?2:1,stdout:``,stderr:``};let u=s[c-1];if(!u||u===`-`||!u.startsWith(`-`))return i||e.state.env.set(r,`?`),{exitCode:i?2:1,stdout:``,stderr:``};if(u===`--`)return e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),i||e.state.env.set(r,`?`),{exitCode:i?2:1,stdout:``,stderr:``};let d=l===0?1:l,f=u[d];if(!f)return e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),OL(e,t);let p=o.indexOf(f);if(p===-1){let t=``;return a?e.state.env.set(`OPTARG`,f):t=`bash: illegal option -- ${f}
1073
- `,i||e.state.env.set(r,`?`),d+1<u.length?(e.state.env.set(`__GETOPTS_CHARINDEX`,String(d+1)),e.state.env.set(`OPTIND`,String(c))):(e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`)),{exitCode:i?2:0,stdout:``,stderr:t}}if(p+1<o.length&&o[p+1]===`:`)if(d+1<u.length)e.state.env.set(`OPTARG`,u.slice(d+1)),e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`);else{if(c>=s.length){let t=``;return a?(e.state.env.set(`OPTARG`,f),i||e.state.env.set(r,`:`)):(t=`bash: option requires an argument -- ${f}
1074
- `,i||e.state.env.set(r,`?`)),e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),{exitCode:i?2:0,stdout:``,stderr:t}}e.state.env.set(`OPTARG`,s[c]),e.state.env.set(`OPTIND`,String(c+2)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`)}else d+1<u.length?(e.state.env.set(`__GETOPTS_CHARINDEX`,String(d+1)),e.state.env.set(`OPTIND`,String(c))):(e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`));return i||e.state.env.set(r,f),{exitCode:i?2:0,stdout:``,stderr:``}}async function kL(e,t){e.state.hashTable||(e.state.hashTable=new Map);let n=!1,r=!1,i=!1,a=!1,o=!1,s=``,c=[],l=0;for(;l<t.length;){let e=t[l];if(e===`--`){l++,c.push(...t.slice(l));break}if(e===`-r`)n=!0,l++;else if(e===`-d`)r=!0,l++;else if(e===`-l`)i=!0,l++;else if(e===`-t`)o=!0,l++;else if(e===`-p`){if(a=!0,l++,l>=t.length)return Q(`bash: hash: -p: option requires an argument
1073
+ `,i||e.state.env.set(r,`?`),d+1<u.length?(e.state.env.set(`__GETOPTS_CHARINDEX`,String(d+1)),e.state.env.set(`OPTIND`,String(c))):(e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`)),{exitCode:i?2:0,stdout:``,stderr:t}}if(p+1<o.length&&o[p+1]===`:`){if(d+1<u.length)e.state.env.set(`OPTARG`,u.slice(d+1)),e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`);else{if(c>=s.length){let t=``;return a?(e.state.env.set(`OPTARG`,f),i||e.state.env.set(r,`:`)):(t=`bash: option requires an argument -- ${f}
1074
+ `,i||e.state.env.set(r,`?`)),e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),{exitCode:i?2:0,stdout:``,stderr:t}}e.state.env.set(`OPTARG`,s[c]),e.state.env.set(`OPTIND`,String(c+2)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`)}}else d+1<u.length?(e.state.env.set(`__GETOPTS_CHARINDEX`,String(d+1)),e.state.env.set(`OPTIND`,String(c))):(e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`));return i||e.state.env.set(r,f),{exitCode:i?2:0,stdout:``,stderr:``}}async function kL(e,t){e.state.hashTable||(e.state.hashTable=new Map);let n=!1,r=!1,i=!1,a=!1,o=!1,s=``,c=[],l=0;for(;l<t.length;){let e=t[l];if(e===`--`){l++,c.push(...t.slice(l));break}if(e===`-r`)n=!0,l++;else if(e===`-d`)r=!0,l++;else if(e===`-l`)i=!0,l++;else if(e===`-t`)o=!0,l++;else if(e===`-p`){if(a=!0,l++,l>=t.length)return Q(`bash: hash: -p: option requires an argument
1075
1075
  `,1);s=t[l],l++}else if(e.startsWith(`-`)&&e.length>1){for(let t of e.slice(1))if(t===`r`)n=!0;else if(t===`d`)r=!0;else if(t===`l`)i=!0;else if(t===`t`)o=!0;else return Q(t===`p`?`bash: hash: -p: option requires an argument
1076
1076
  `:`bash: hash: -${t}: invalid option
1077
1077
  `,1);l++}else c.push(e),l++}if(n)return e.state.hashTable.clear(),uP;if(r){if(c.length===0)return Q(`bash: hash: -d: option requires an argument
@@ -1444,7 +1444,7 @@ ${i}
1444
1444
  `)}function FL(e){let t=[],n=``,r=0;for(let i of e){for(let e of i)e===`(`?r++:e===`)`&&r--;n?n+=` ${i}`:n=i,r===0&&(t.push(n),n=``)}return n&&t.push(n),t}async function IL(e,t){if(t.length===0)return Q(`bash: let: expression expected
1445
1445
  `);let n=FL(t),r=0;for(let t of n)try{let n=Ek(`(( ${t} ))`).statements[0];if(n&&n.pipelines.length>0&&n.pipelines[0].commands.length>0){let t=n.pipelines[0].commands[0];t.type===`ArithmeticCommand`&&(r=await rP(e,t.expression.expression))}}catch(e){return Q(`bash: let: ${t}: ${e.message}
1446
1446
  `)}return $(``,``,+(r===0))}Wi();async function LL(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength};if(e.state.localScopes.length===0)return Q(`bash: local: can only be used in a function
1447
- `);let r=e.state.localScopes[e.state.localScopes.length-1];for(e.state.localArrayScopes??=[];e.state.localArrayScopes.length<e.state.localScopes.length;)e.state.localArrayScopes.push(new Map);let i=e.state.localArrayScopes.at(-1),a=t=>{if(r.has(t)||r.set(t,e.state.env.get(t)),i&&!i.has(t)){let n=tD(e,t);i.set(t,n?$E(n):void 0)}},o=``,s=0,c=!1,l=!1,u=[];for(let e of t)if(e===`-n`)c=!0;else if(e===`-a`)l=!0;else if(e!==`-p`)if(e.startsWith(`-`)&&!e.includes(`=`))for(let t of e.slice(1))t===`n`?c=!0:t===`a`&&(l=!0);else u.push(e);if(u.length===0){let t=``,n=Array.from(r.keys()).sort();for(let r of n){let n=e.state.env.get(r);n!==void 0&&(t+=`${r}=${n}
1447
+ `);let r=e.state.localScopes[e.state.localScopes.length-1];for(e.state.localArrayScopes??=[];e.state.localArrayScopes.length<e.state.localScopes.length;)e.state.localArrayScopes.push(new Map);let i=e.state.localArrayScopes.at(-1),a=t=>{if(r.has(t)||r.set(t,e.state.env.get(t)),i&&!i.has(t)){let n=tD(e,t);i.set(t,n?$E(n):void 0)}},o=``,s=0,c=!1,l=!1,u=[];for(let e of t)if(e===`-n`)c=!0;else if(e===`-a`)l=!0;else if(e!==`-p`){if(e.startsWith(`-`)&&!e.includes(`=`))for(let t of e.slice(1))t===`n`?c=!0:t===`a`&&(l=!0);else u.push(e)}if(u.length===0){let t=``,n=Array.from(r.keys()).sort();for(let r of n){let n=e.state.env.get(r);n!==void 0&&(t+=`${r}=${n}
1448
1448
  `)}return $(t,``,0)}for(let t of u){let i,u,d=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(d){i=d[1];let r=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){o+=`bash: local: \`${t}': not a valid identifier
1449
1449
  `,s=1;continue}Ij(e,i,`bash`);let l=tF(r,n);e.executionScope.consumeWork(l.length,`local array assignment`),a(i),dD(e,i),rD(e,i,`indexed`);for(let t=0;t<l.length;t++)Y(e,i,t,l[t]);oF(e,i),c&&KA(e,i);continue}let f=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(f){i=f[1];let t=f[2];Ij(e,i,`bash`),a(i);let r=tF(t,n);e.executionScope.consumeWork(r.length,`local array append`);let o=uD(e,i),s=0,l=e.state.env.get(i);o.length===0&&l!==void 0?(Y(e,i,0,l),e.state.env.delete(i),s=1):o.length>0&&(s=Math.max(...o)+1),sD(e,i,Array.from({length:r.length},(e,t)=>s+t));for(let t=0;t<r.length;t++)Y(e,i,s+t,r[t]);oF(e,i),c&&KA(e,i);continue}let p=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(p){i=p[1];let t=p[2];Ij(e,i,`bash`),r.has(i)||r.set(i,e.state.env.get(i));let n=e.state.env.get(i)??``;e.state.env.set(i,Hi([n,t],``,e.limits.maxStringLength,`local append`)),oF(e,i),c&&KA(e,i);continue}let m=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(m){i=m[1];let t=m[2],n=m[3];Ij(e,i,`bash`),a(i);let r;try{r=await rP(e,sO(new Tk,t).expression)}catch{let e=parseInt(t,10);r=Number.isNaN(e)?0:e}Y(e,i,r,n),oF(e,i),c&&KA(e,i);continue}if(t.includes(`=`)){let e=t.indexOf(`=`);i=t.slice(0,e),u=t.slice(e+1)}else i=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){o+=`bash: local: \`${t}': not a valid identifier
1450
1450
  `,s=1;continue}let h=r.has(i);if(u!==void 0){let t=e.state.env.get(i);if(e.state.tempEnvBindings){let n=e.state.accessedTempEnvVars?.has(i),r=e.state.mutatedTempEnvVars?.has(i);if(!n&&!r)for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(i)){t=r.get(i);break}}}lF(e,i,t)}if(!h){let t=e.state.env.get(i);if(e.state.tempEnvBindings)for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(i)){t=r.get(i);break}}r.set(i,t),l&&a(i)}if(l&&u===void 0)dD(e,i),rD(e,i,`indexed`);else if(u!==void 0){if(Ij(e,i,`bash`),c&&u!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(u)){o+=`bash: local: \`${u}': invalid variable name for name reference
@@ -1521,7 +1521,7 @@ ${VL}`;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}return nR(e,t.s
1521
1521
  `)}
1522
1522
  `:``}}function vR(e,t,n,r,i,a){let o=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),s=new Map([[`errexit`,`errexit`],[`pipefail`,`pipefail`],[`nounset`,`nounset`],[`xtrace`,`xtrace`],[`verbose`,`verbose`],[`posix`,`posix`],[`allexport`,`allexport`],[`noclobber`,`noclobber`],[`noglob`,`noglob`],[`noexec`,`noexec`],[`vi`,`vi`],[`emacs`,`emacs`]]),c=[`braceexpand`,`errtrace`,`functrace`,`hashall`,`histexpand`,`history`,`ignoreeof`,`interactive-comments`,`keyword`,`monitor`,`nolog`,`notify`,`onecmd`,`physical`,`privileged`],l=[...s.keys(),...c].sort();if(t.length===0){let t=[];for(let a of l){let o=c.includes(a),l=s.get(a),u=o||!l?!1:e.state.options[l];n&&!u||r&&u||t.push(i?`set ${u?`-o`:`+o`} ${a}`:`${a} ${u?`on`:`off`}`)}return{exitCode:0,stdout:t.length>0?`${t.join(`
1523
1523
  `)}
1524
- `:``,stderr:``}}let u=!1,d=[],f=0,p=[],m=0;for(let l of t){let t=s.has(l),h=c.includes(l);if(!t&&!h){f=fR(d,`shopt: ${l}: invalid option name`,f,o),u=!0;continue}if(h){n||r||(a?u=!0:i?(m=fR(p,`set +o ${l}`,m,o),u=!0):(m=fR(p,`${l} off`,m,o),u=!0));continue}let g=s.get(l);if(g)if(n)g===`vi`?e.state.options.emacs=!1:g===`emacs`&&(e.state.options.vi=!1),e.state.options[g]=!0,bD(e);else if(r)e.state.options[g]=!1,bD(e);else{let t=e.state.options[g];a?t||(u=!0):i?(m=fR(p,`set ${t?`-o`:`+o`} ${l}`,m,o),t||(u=!0)):(m=fR(p,`${l} ${t?`on`:`off`}`,m,o),t||(u=!0))}}return{exitCode:+!!u,stdout:p.length>0?`${p.join(`
1524
+ `:``,stderr:``}}let u=!1,d=[],f=0,p=[],m=0;for(let l of t){let t=s.has(l),h=c.includes(l);if(!t&&!h){f=fR(d,`shopt: ${l}: invalid option name`,f,o),u=!0;continue}if(h){n||r||(a?u=!0:i?(m=fR(p,`set +o ${l}`,m,o),u=!0):(m=fR(p,`${l} off`,m,o),u=!0));continue}let g=s.get(l);if(g){if(n)g===`vi`?e.state.options.emacs=!1:g===`emacs`&&(e.state.options.vi=!1),e.state.options[g]=!0,bD(e);else if(r)e.state.options[g]=!1,bD(e);else{let t=e.state.options[g];a?t||(u=!0):i?(m=fR(p,`set ${t?`-o`:`+o`} ${l}`,m,o),t||(u=!0)):(m=fR(p,`${l} ${t?`on`:`off`}`,m,o),t||(u=!0))}}}return{exitCode:+!!u,stdout:p.length>0?`${p.join(`
1525
1525
  `)}
1526
1526
  `:``,stderr:d.length>0?`${d.join(`
1527
1527
  `)}
@@ -1534,7 +1534,7 @@ ${VL}`;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}return nR(e,t.s
1534
1534
  `,1)};let s=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let a=await zR(e,t,s[1],s[2],o,i.append,n);if(a.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:a.error};if(a.continueToNext)continue}let c=await HR(e,t,a,o,i.append,n);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:n}}async function PR(e,t,n,r,i,a){let o=``;if(/\[.+\]$/.test(n))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: cannot assign list to array member
1535
1535
  `,1)};if(GA(e,n)){let t=$A(e,n);if(t===void 0||t===``)throw new wr(1,``,``);let r=QA(e,n);if(r&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(r))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: cannot assign list to array member
1536
1536
  `,1)}}if(Fj(e,n)){if(t.name)return o+=`bash: ${n}: readonly variable
1537
- `,{continueToNext:!0,xtraceOutput:o};let r=Ij(e,n);if(r)return{continueToNext:!1,xtraceOutput:``,error:r}}let s=e.state.associativeArrays?.has(n),c=tD(e,n),l=c?$E(c):void 0,u=e.state.env.get(n),d=()=>{e.state.arrays??=new Map,l?e.state.arrays.set(n,l):e.state.arrays.delete(n),u===void 0?e.state.env.delete(n):e.state.env.set(n,u)},f=FR(r),p=()=>{dD(e,n),e.state.env.delete(n)};try{s&&f?await IR(e,t,n,r,i,p,e=>{o+=e}):f?await LR(e,n,r,i,p):await RR(e,n,r,i,p)}catch(e){throw d(),e}if(t.name){a.set(n,e.state.env.get(n));let t=`(${r.map(e=>gD(e)).join(` `)})`;e.state.env.set(n,t)}return{continueToNext:!0,xtraceOutput:o}}function FR(e){return e.some(e=>{if(e.parts.length>=2){let t=e.parts[0],n=e.parts[1];if(t.type!==`Glob`||!t.pattern.startsWith(`[`))return!1;if(t.pattern===`[`&&(n.type===`DoubleQuoted`||n.type===`SingleQuoted`)){if(e.parts.length<3)return!1;let t=e.parts[2];return t.type===`Literal`?t.value.startsWith(`]=`)||t.value.startsWith(`]+=`):!1}return n.type===`Literal`?n.value.startsWith(`]`)?n.value.startsWith(`]=`)||n.value.startsWith(`]+=`):t.pattern.endsWith(`]`)?n.value.startsWith(`=`)||n.value.startsWith(`+=`):!1:!1}return!1})}async function IR(e,t,n,r,i,a,o){let s=[];for(let t of r){if(s.length>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=mD(t);if(n){let{key:t,valueParts:r,append:i}=n,a;r.length>0?(a=await MN(e,{type:`Word`,parts:r}),r.every(e=>e.type===`Literal`||e.type===`TildeExpansion`)&&(a=cM(e,a))):a=``,s.push({type:`keyed`,key:t,value:a,append:i})}else{let n=await MN(e,t);s.push({type:`invalid`,expandedValue:n})}}e.executionScope.consumeWork(s.length,`associative array assignment`),i||a();for(let r of s)if(r.type===`keyed`)if(r.append){let t=aD(e,n,r.key)??``;Y(e,n,r.key,MR(e,t,r.value),`associative`)}else Y(e,n,r.key,r.value,`associative`);else o(`bash: line ${t.line??e.state.currentLine??1}: ${n}: ${r.expandedValue}: must use subscript when assigning associative array
1537
+ `,{continueToNext:!0,xtraceOutput:o};let r=Ij(e,n);if(r)return{continueToNext:!1,xtraceOutput:``,error:r}}let s=e.state.associativeArrays?.has(n),c=tD(e,n),l=c?$E(c):void 0,u=e.state.env.get(n),d=()=>{e.state.arrays??=new Map,l?e.state.arrays.set(n,l):e.state.arrays.delete(n),u===void 0?e.state.env.delete(n):e.state.env.set(n,u)},f=FR(r),p=()=>{dD(e,n),e.state.env.delete(n)};try{s&&f?await IR(e,t,n,r,i,p,e=>{o+=e}):f?await LR(e,n,r,i,p):await RR(e,n,r,i,p)}catch(e){throw d(),e}if(t.name){a.set(n,e.state.env.get(n));let t=`(${r.map(e=>gD(e)).join(` `)})`;e.state.env.set(n,t)}return{continueToNext:!0,xtraceOutput:o}}function FR(e){return e.some(e=>{if(e.parts.length>=2){let t=e.parts[0],n=e.parts[1];if(t.type!==`Glob`||!t.pattern.startsWith(`[`))return!1;if(t.pattern===`[`&&(n.type===`DoubleQuoted`||n.type===`SingleQuoted`)){if(e.parts.length<3)return!1;let t=e.parts[2];return t.type===`Literal`?t.value.startsWith(`]=`)||t.value.startsWith(`]+=`):!1}return n.type===`Literal`?n.value.startsWith(`]`)?n.value.startsWith(`]=`)||n.value.startsWith(`]+=`):t.pattern.endsWith(`]`)?n.value.startsWith(`=`)||n.value.startsWith(`+=`):!1:!1}return!1})}async function IR(e,t,n,r,i,a,o){let s=[];for(let t of r){if(s.length>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=mD(t);if(n){let{key:t,valueParts:r,append:i}=n,a;r.length>0?(a=await MN(e,{type:`Word`,parts:r}),r.every(e=>e.type===`Literal`||e.type===`TildeExpansion`)&&(a=cM(e,a))):a=``,s.push({type:`keyed`,key:t,value:a,append:i})}else{let n=await MN(e,t);s.push({type:`invalid`,expandedValue:n})}}e.executionScope.consumeWork(s.length,`associative array assignment`),i||a();for(let r of s)if(r.type===`keyed`){if(r.append){let t=aD(e,n,r.key)??``;Y(e,n,r.key,MR(e,t,r.value),`associative`)}else Y(e,n,r.key,r.value,`associative`)}else o(`bash: line ${t.line??e.state.currentLine??1}: ${n}: ${r.expandedValue}: must use subscript when assigning associative array
1538
1538
  `)}async function LR(e,t,n,r,i){let a=[],o=0;for(let t of n){let n=mD(t);if(n){if(o>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let{key:t,valueParts:r,append:i}=n,s;r.length>0?(s=await MN(e,{type:`Word`,parts:r}),r.every(e=>e.type===`Literal`||e.type===`TildeExpansion`)&&(s=cM(e,s))):s=``,a.push({type:`keyed`,indexExpr:t,value:s,append:i}),o++}else{let n=await VN(e,t);if(n.values.length>e.limits.maxArrayElements-o)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push({type:`non-keyed`,values:n.values}),o+=n.values.length}}e.executionScope.consumeWork(o,`indexed array assignment`),r||i();let s=0;for(let n of a)if(n.type===`keyed`){let r;try{r=await rP(e,sO(new Tk,n.indexExpr).expression,!1)}catch{if(/^-?\d+$/.test(n.indexExpr))r=Number.parseInt(n.indexExpr,10);else{let t=e.state.env.get(n.indexExpr);r=t?Number.parseInt(t,10):0,Number.isNaN(r)&&(r=0)}}if(n.append){let i=aD(e,t,r)??``;Y(e,t,r,MR(e,i,n.value))}else Y(e,t,r,n.value);s=r+1}else for(let r of n.values)Y(e,t,s++,r)}async function RR(e,t,n,r,i){let a=[];for(let t of n){let n=await VN(e,t);for(let t of n.values){if(a.length>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push(t)}}let o=0;if(e.executionScope.consumeWork(a.length,`indexed array assignment`),r){let n=nj(e,t);if(n.length>0)o=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1;else{let n=e.state.env.get(t);n!==void 0&&(Y(e,t,0,n),e.state.env.delete(t),o=1)}}else i();for(let n=0;n<a.length;n++)Y(e,t,o+n,a[n])}async function zR(e,t,n,r,i,a,o){let s=n;if(GA(e,n)){let t=QA(e,n);if(t&&t!==n){if(t.includes(`[`))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: \`${t}': not a valid identifier
1539
1539
  `,1)};s=t}}if(Fj(e,s)){if(t.name)return{continueToNext:!0,xtraceOutput:``};let n=Ij(e,s);if(n)return{continueToNext:!1,xtraceOutput:``,error:n}}let c=e.state.associativeArrays?.has(s),l;if(c)l=await BR(e,r);else{let t=await VR(e,s,r);if(t.error)return{continueToNext:!1,xtraceOutput:``,error:t.error};l=String(t.index)}let u=a?MR(e,aD(e,s,l)||``,i):i;return t.name||Y(e,s,l,u,c?`associative`:`indexed`),{continueToNext:!0,xtraceOutput:``}}async function BR(e,t){let n;if(t.startsWith(`'`)&&t.endsWith(`'`))n=t.slice(1,-1);else if(t.startsWith(`"`)&&t.endsWith(`"`)){let r=t.slice(1,-1);n=await MN(e,new Tk().parseWordFromString(r,!0,!1))}else n=t.includes(`$`)?await MN(e,new Tk().parseWordFromString(t,!1,!1)):t;return n}async function VR(e,t,n){let r=n;n.startsWith(`"`)&&n.endsWith(`"`)&&n.length>=2&&(r=n.slice(1,-1));let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{i=await rP(e,sO(new Tk,r).expression,!1)}catch(r){if(r instanceof wr)throw r;if(r instanceof Tr){let t=`bash: line ${e.state.currentLine}: ${n}: ${r.message}
1540
1540
  `;if(r.fatal)throw new wr(1,``,t);return{index:0,error:$(``,t,1)}}let i=e.state.currentLine;return{index:0,error:$(``,`bash: line ${i}: ${t}[${n}]: bad array subscript
@@ -1544,15 +1544,15 @@ ${VL}`;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}return nR(e,t.s
1544
1544
  `,1)};if(t===null)return{continueToNext:!0,xtraceOutput:``};s=t;let i=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);i&&(c={arrayName:i[1],subscriptExpr:i[2]},s=i[1])}if(Fj(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable
1545
1545
  `,{continueToNext:!0,xtraceOutput:o};let n=Ij(e,s);if(n)return{continueToNext:!1,xtraceOutput:``,error:n}}let l;if(lL(e,s))try{let t=new Tk;if(i){let n=sO(t,`(${e.state.env.get(s)||`0`}) + (${r})`);l=String(await rP(e,n.expression))}else{let n=sO(t,r);l=String(await rP(e,n.expression))}}catch{l=`0`}else{let t=rj(e,s)?aD(e,s,0):e.state.env.get(s);l=i?MR(e,t||``,r):r}l=mL(e,s,l),o+=await jR(e,s,l);let u;return c?u=await UR(e,c):rj(e,s)&&(u=`0`),t.name?u===void 0&&(a.set(s,e.state.env.get(s)),e.state.env.set(s,l)):(u===void 0?e.state.env.set(s,l):Y(e,s,u,l),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(s)),e.state.tempEnvBindings?.some(e=>e.has(s))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(s))),{continueToNext:!1,xtraceOutput:o}}async function UR(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return BR(e,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{i=await rP(e,sO(new Tk,r).expression,!1)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let t=nj(e,n);t.length>0&&(i=Math.max(...t.map(e=>e[0]))+1+i)}return String(i)}async function WR(e,t,n,r){let i=!1,a=!1,o=!1,s=!1,c=!1,l=[];for(let e of t)if(e.startsWith(`-`)&&e.length>1)for(let t of e.slice(1))t===`t`?i=!0:t===`p`?a=!0:t===`P`?o=!0:t===`a`?s=!0:t===`f`&&(c=!0);else l.push(e);let u=``,d=``,f=0,p=!1,m=!1;for(let t of l){let l=!1;if(o){if(s){let e=await r(t);if(e.length>0){for(let t of e)u+=`${t}
1546
1546
  `;p=!0,l=!0}}else{let e=await n(t);e&&(u+=`${e}
1547
- `,p=!0,l=!0)}l||(m=!0);continue}let f=!c&&e.state.functions.has(t);if(s&&f){if(!a)if(i)u+=`function
1547
+ `,p=!0,l=!0)}l||(m=!0);continue}let f=!c&&e.state.functions.has(t);if(s&&f){if(!a){if(i)u+=`function
1548
1548
  `;else{let n=e.state.functions.get(t),r=n?GR(t,n):`${t} is a function
1549
- `;u+=r}l=!0}let h=e.state.env.get(`BASH_ALIAS_${t}`);if(!(h!==void 0&&(s||!l)&&(a||(u+=i?`alias
1549
+ `;u+=r}}l=!0}let h=e.state.env.get(`BASH_ALIAS_${t}`);if(!(h!==void 0&&(s||!l)&&(a||(u+=i?`alias
1550
1550
  `:`${t} is aliased to \`${h}'
1551
1551
  `),l=!0,!s)||mF.has(t)&&(s||!l)&&(a||(u+=i?`keyword
1552
1552
  `:`${t} is a shell keyword
1553
- `),l=!0,!s))){if(!s&&f&&!l){if(!a)if(i)u+=`function
1553
+ `),l=!0,!s))){if(!s&&f&&!l){if(!a){if(i)u+=`function
1554
1554
  `;else{let n=e.state.functions.get(t),r=n?GR(t,n):`${t} is a function
1555
- `;u+=r}l=!0;continue}if(!(hF.has(t)&&(s||!l)&&(a||(u+=i?`builtin
1555
+ `;u+=r}}l=!0;continue}if(!(hF.has(t)&&(s||!l)&&(a||(u+=i?`builtin
1556
1556
  `:`${t} is a shell builtin
1557
1557
  `),l=!0,!s))){if(s){let e=await r(t);for(let n of e)u+=a?`${n}
1558
1558
  `:i?`file
@@ -1619,7 +1619,7 @@ ${e.join(`
1619
1619
  `],[`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(e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=_B(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:r,arrays:new Map,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`,yD(this.state.options)),this.state.env.set(`BASHOPTS`,SD(this.state.shoptOptions)),QE(t,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),n!==`/`&&t instanceof WE)try{t.mkdirSync(n,{recursive:!0})}catch{}for(let t of CE(e.commands))this.registerBundledCommand(t);if(e.fetch||e.network)for(let e of wE())this.registerBundledCommand(e);if(e.python)for(let e of TE())this.registerBundledCommand(e);let i=typeof e.javascript==`object`?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let e of EE())this.registerBundledCommand(e);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let t of e.customCommands)if(FE(t)){let e=LE(t);this.registerCommandInternal(e,!0)}else this.registerCommandInternal(t,!0)}registerCommand(e){this.registerCommandInternal(e,!0)}registerBundledCommand(e){this.registerCommandInternal(e,!1)}registerCommandInternal(e,t,n=t?e.trusted??!0:e.trusted){let r=this.commands.get(e.name),i=t?r?.internalOriginalCommand??(r&&!r.internalIsExtension?r:void 0):void 0,a={name:e.name,trusted:n,internalIsExtension:t,internalOriginalCommand:i,execute:(t,n)=>e.execute(t,n)};this.commands.set(e.name,a);let o=this.fs;if(typeof o.writeFileSync==`function`){let t=`#!/bin/bash
1620
1620
  # Built-in command: ${e.name}
1621
1621
  `;try{o.writeFileSync(`/bin/${e.name}`,t)}catch{}try{o.writeFileSync(`/usr/bin/${e.name}`,t)}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=TB(e.stdout),e.stderr=TB(e.stderr),e}async exec(e,t){let n=new zE(this.limits,t?.signal),r;try{r=await this.execInScope(e,t,n,0,t?.signal,!1,!1)}catch(e){try{await n.close()}catch{}throw e}let i=r;try{await n.close()}catch{i={...r,stderr:`${r.stderr}bash: execution cleanup failed
1622
- `,exitCode:126}}return e.trim()?this.logResult(i):i}async execInScope(e,t,n,r,i,a=!1,o=!0){let s=e=>o?this.logResult(e):e,c=rr(i,t?.signal),l=t?{...t,signal:c.signal}:{signal:c.signal};try{if(n.assertExecDepth(r),bB(e,this.limits.maxSourceBytes),!e.trim())return{stdout:``,stderr:``,exitCode:0,env:id(this.state.env,l.env)};this.logger?.info(`exec`,{command:e});let t=l.cwd??this.state.cwd,i,o=t;if(l.cwd)if(l.env&&`PWD`in l.env)i=l.env.PWD;else if(l.env&&!(`PWD`in l.env))try{i=await this.fs.realpath(t),o=i}catch{i=t}else i=t;let c=l.replaceEnv?new Map:new Map(this.state.env);if(l.env)for(let[e,t]of Object.entries(l.env))c.set(e,t);i!==void 0&&c.set(`PWD`,i);let u={...this.state,env:c,arrays:l.replaceEnv?new Map:eD(this.state.arrays),cwd:o,previousDir:l.env?.OLDPWD??this.state.previousDir,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:EB(l.stdin,l.stdinKind,this.limits.maxInputBytes,this.limits.maxStringLength,n,a),signal:l.signal,extraArgs:l.args},d=e;l.rawScript||(d=CB(e));let f=this.defenseInDepthConfig?Kn.getInstance(this.defenseInDepthConfig):null,p=f?.activate();try{let e=async()=>{let e=Ek(d,{maxHeredocSize:this.limits.maxHeredocSize}),t;if(this.transformPlugins.length>0){let n=Object.create(null);for(let t of this.transformPlugins){let r=t.transform({ast:e,metadata:n});e=r.ast,r.metadata&&(n=ad(n,r.metadata))}t=n}let i=await new Fz({fs:this.fs,commands:this.commands,limits:this.limits,executionScope:n,exec:(e,t,i=!1)=>this.execInScope(e,t,n,r+1,l.signal,i),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:f?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},u).executeScript(e);return t&&(i.metadata=t),s(i)};return p?await p.run(e):await e()}catch(e){if(e instanceof wr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,internalOutputAccounting:e.internalOutputAccounting,env:id(this.state.env,l.env)});if(e instanceof jr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,env:id(this.state.env,l.env)});if(e instanceof Tr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:1,env:id(this.state.env,l.env)});if(e instanceof kr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:id(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:$i(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:id(this.state.env,l.env)});if(e instanceof D)return s({stdout:``,stderr:`bash: security violation: ${$i(e.message)}
1622
+ `,exitCode:126}}return e.trim()?this.logResult(i):i}async execInScope(e,t,n,r,i,a=!1,o=!0){let s=e=>o?this.logResult(e):e,c=rr(i,t?.signal),l=t?{...t,signal:c.signal}:{signal:c.signal};try{if(n.assertExecDepth(r),bB(e,this.limits.maxSourceBytes),!e.trim())return{stdout:``,stderr:``,exitCode:0,env:id(this.state.env,l.env)};this.logger?.info(`exec`,{command:e});let t=l.cwd??this.state.cwd,i,o=t;if(l.cwd){if(l.env&&`PWD`in l.env)i=l.env.PWD;else if(l.env&&!(`PWD`in l.env))try{i=await this.fs.realpath(t),o=i}catch{i=t}else i=t}let c=l.replaceEnv?new Map:new Map(this.state.env);if(l.env)for(let[e,t]of Object.entries(l.env))c.set(e,t);i!==void 0&&c.set(`PWD`,i);let u={...this.state,env:c,arrays:l.replaceEnv?new Map:eD(this.state.arrays),cwd:o,previousDir:l.env?.OLDPWD??this.state.previousDir,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:EB(l.stdin,l.stdinKind,this.limits.maxInputBytes,this.limits.maxStringLength,n,a),signal:l.signal,extraArgs:l.args},d=e;l.rawScript||(d=CB(e));let f=this.defenseInDepthConfig?Kn.getInstance(this.defenseInDepthConfig):null,p=f?.activate();try{let e=async()=>{let e=Ek(d,{maxHeredocSize:this.limits.maxHeredocSize}),t;if(this.transformPlugins.length>0){let n=Object.create(null);for(let t of this.transformPlugins){let r=t.transform({ast:e,metadata:n});e=r.ast,r.metadata&&(n=ad(n,r.metadata))}t=n}let i=await new Fz({fs:this.fs,commands:this.commands,limits:this.limits,executionScope:n,exec:(e,t,i=!1)=>this.execInScope(e,t,n,r+1,l.signal,i),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:f?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},u).executeScript(e);return t&&(i.metadata=t),s(i)};return p?await p.run(e):await e()}catch(e){if(e instanceof wr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,internalOutputAccounting:e.internalOutputAccounting,env:id(this.state.env,l.env)});if(e instanceof jr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,env:id(this.state.env,l.env)});if(e instanceof Tr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:1,env:id(this.state.env,l.env)});if(e instanceof kr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:id(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:$i(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:id(this.state.env,l.env)});if(e instanceof D)return s({stdout:``,stderr:`bash: security violation: ${$i(e.message)}
1623
1623
  `,exitCode:1,env:id(this.state.env,l.env)});if(e.name===`ParseException`)return s({stdout:``,stderr:`bash: syntax error: ${$i(e.message)}
1624
1624
  `,exitCode:2,env:id(this.state.env,l.env)});if(e instanceof MD)return s({stdout:``,stderr:`bash: ${$i(e.message)}
1625
1625
  `,exitCode:2,env:id(this.state.env,l.env)});if(e instanceof RangeError)return s({stdout:``,stderr:`bash: ${$i(e.message)}