sliccy 6.192.0 → 6.193.0

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 (163) hide show
  1. package/dist/ui/.vite/manifest.json +182 -182
  2. package/dist/ui/assets/{MEMORY-CbB3xjAS.js → MEMORY-B9cGngY_.js} +6 -1
  3. package/dist/ui/assets/{SKILL-Be-LbAuP.js → SKILL-CVh4bFFa.js} +1 -1
  4. package/dist/ui/assets/{account-store-Bevys7WL.js → account-store-SimIXg8S.js} +1 -1
  5. package/dist/ui/assets/{account-store-irTFXEHq.js → account-store-b2cIu79O.js} +1 -1
  6. package/dist/ui/assets/adobe-BXH1mZBP.js +1 -0
  7. package/dist/ui/assets/{adobe-CxPY_Nvf.js → adobe-Baxaw9tF.js} +1 -1
  8. package/dist/ui/assets/{agent-panels-CDAHwcGe.js → agent-panels-SuTziiZF.js} +1 -1
  9. package/dist/ui/assets/{almost-bash-shell-headless-B6lKPYip.js → almost-bash-shell-headless-KRKIc_BC.js} +458 -458
  10. package/dist/ui/assets/{apply-layout-BaPTlEmq.js → apply-layout-BMXr012X.js} +1 -1
  11. package/dist/ui/assets/{apps-CWLDElDt.js → apps-ClHDPvz3.js} +1 -1
  12. package/dist/ui/assets/{azure-openai-CAmcCxYK.js → azure-openai-DBM2Ldvh.js} +1 -1
  13. package/dist/ui/assets/{azure-openai-BrEMU1w0.js → azure-openai-DLiuqAAg.js} +1 -1
  14. package/dist/ui/assets/{backend-hostfs-DVOOQmWO.js → backend-hostfs-CMvkeWSE.js} +1 -1
  15. package/dist/ui/assets/{browser-DL3zbJrM.js → browser-Don7GC1D.js} +16 -16
  16. package/dist/ui/assets/{cdp-l5Vq6Mtp.js → cdp-DDirvj-c.js} +1 -1
  17. package/dist/ui/assets/{cerebras-DyJkWRm7.js → cerebras-DuPDmIOB.js} +1 -1
  18. package/dist/ui/assets/{cerebras-COJ_qkGu.js → cerebras-lgyiolIY.js} +1 -1
  19. package/dist/ui/assets/{composer-speech-CYdWOXqF.js → composer-speech-DmZY4JVi.js} +1 -1
  20. package/dist/ui/assets/{connect-surface-DnaS1qCD.js → connect-surface-BOTHMD51.js} +1 -1
  21. package/dist/ui/assets/{cost-command-DC0JwdLM.js → cost-command-MXw_GKzX.js} +1 -1
  22. package/dist/ui/assets/{directed-approval-Bo1zb-ki.js → directed-approval-CerbvC2D.js} +1 -1
  23. package/dist/ui/assets/{emscripten-vfs-hook-DORb16y9.js → emscripten-vfs-hook-BuS59209.js} +1 -1
  24. package/dist/ui/assets/{ensure-speech-assets-DXQUrOok.js → ensure-speech-assets-p_8CXJAD.js} +1 -1
  25. package/dist/ui/assets/{frozen-archive-writer-C_qn0GDJ.js → frozen-archive-writer-CFfTnqU4.js} +2 -2
  26. package/dist/ui/assets/fs-BxDhct-3.js +1 -0
  27. package/dist/ui/assets/fs-C5DLxUuw.js +2 -0
  28. package/dist/ui/assets/{gelatiere-store-D0SzDyoX.js → gelatiere-store-BvgAd5Zk.js} +1 -1
  29. package/dist/ui/assets/{gelatiere-unit-D0eC3q8k.js → gelatiere-unit-s-jBG-uE.js} +1 -1
  30. package/dist/ui/assets/{github-DrXxnqrr.js → github-BXOGqSiK.js} +2 -2
  31. package/dist/ui/assets/{github-CMMdXD7-.js → github-DG9QiZYP.js} +1 -1
  32. package/dist/ui/assets/{github-auth-CVs8hOEW.js → github-auth-CwHehFvz.js} +1 -1
  33. package/dist/ui/assets/{github-copilot-BDW-hvGU.js → github-copilot-DGPlFE5e.js} +1 -1
  34. package/dist/ui/assets/{github-copilot-F_OWE6ig.js → github-copilot-Dt82sOhC.js} +1 -1
  35. package/dist/ui/assets/{github-install-B-rr32FO.js → github-install-jl4FPsHI.js} +1 -1
  36. package/dist/ui/assets/{github-zip-DA_-VtNu.js → github-zip-BAWKMgjN.js} +1 -1
  37. package/dist/ui/assets/{hear-B1QjKHJS.js → hear-TuDMtKj3.js} +1 -1
  38. package/dist/ui/assets/{help-C3q6Ha5a.js → help-BbUskVkl.js} +1 -1
  39. package/dist/ui/assets/{host-command-DTM6_CU_.js → host-command-D8TK1jxM.js} +1 -1
  40. package/dist/ui/assets/installer-08nILdgJ.js +4 -0
  41. package/dist/ui/assets/{js-realm-worker-CIzPgKVU.js → js-realm-worker-UfwUgA6T.js} +14 -14
  42. package/dist/ui/assets/{jsh-executor-8n8-NVRR.js → jsh-executor-DdHf6Js2.js} +2 -2
  43. package/dist/ui/assets/{kernel-worker-YhNfUQ_y.js → kernel-worker-DiHbIWEg.js} +62 -58
  44. package/dist/ui/assets/{lick-ws-bridge-CDPuY-EA.js → lick-ws-bridge-CtPW0aNT.js} +1 -1
  45. package/dist/ui/assets/{lick-ws-bridge-BWmnM4i8.js → lick-ws-bridge-Dglm_RzS.js} +1 -1
  46. package/dist/ui/assets/live-session-curation-BO60iZm7.js +1 -0
  47. package/dist/ui/assets/{live-session-snapshot-CAY9GlTD.js → live-session-snapshot-DSYdvZ1k.js} +1 -1
  48. package/dist/ui/assets/{local-llm-dPetWUMs.js → local-llm-CA-oC8S7.js} +1 -1
  49. package/dist/ui/assets/{local-llm-CsIWLXJ2.js → local-llm-hkLYzSvm.js} +1 -1
  50. package/dist/ui/assets/{main-DUD5pTDH.js → main-BcLR9n_M.js} +3 -3
  51. package/dist/ui/assets/{main-cherry-BoO4BB-J.js → main-cherry-D8lHtydB.js} +1 -1
  52. package/dist/ui/assets/memory-budget-CFfevxz_.js +1 -0
  53. package/dist/ui/assets/{memory-curation-seam-DFftwyHh.js → memory-curation-seam-BJN7RaZ_.js} +1 -1
  54. package/dist/ui/assets/{memory-health-DF6IEFmt.js → memory-health-CmDIs1jS.js} +1 -1
  55. package/dist/ui/assets/memory-write-execute-C6Ys0m3p.js +1 -0
  56. package/dist/ui/assets/{mount-BfPgf0TT.js → mount-3ssq_M3f.js} +1 -1
  57. package/dist/ui/assets/{mount-BsWbgqHU.js → mount-oJcDzYHJ.js} +3 -3
  58. package/dist/ui/assets/{new-session-n4ieWj9Q.js → new-session-DCVrxowi.js} +2 -2
  59. package/dist/ui/assets/{oauth-bootstrap-DEjPbx0S.js → oauth-bootstrap-D1FahnIy.js} +2 -2
  60. package/dist/ui/assets/{onboarding-orchestrator-DTq_WzOT.js → onboarding-orchestrator-UOkZjppy.js} +1 -1
  61. package/dist/ui/assets/{openai-codex-CZFJxrdp.js → openai-codex-B2yw-3yu.js} +1 -1
  62. package/dist/ui/assets/{openai-codex-CRBPHYXu.js → openai-codex-B5_xqxDd.js} +1 -1
  63. package/dist/ui/assets/{openrouter-Bp2hCSj0.js → openrouter-BfigMcxO.js} +1 -1
  64. package/dist/ui/assets/{openrouter-xrK_Q7tb.js → openrouter-BwQeVkB-.js} +1 -1
  65. package/dist/ui/assets/{openrouter-free-B1aHr6YX.js → openrouter-free-B_pyNu1H.js} +1 -1
  66. package/dist/ui/assets/{openrouter-free-Ciud-jQF.js → openrouter-free-Cmp0KK1x.js} +1 -1
  67. package/dist/ui/assets/{openrouter-oauth-BShl7mda.js → openrouter-oauth-CjE2dXpj.js} +1 -1
  68. package/dist/ui/assets/{openrouter-oauth-CBNfp9B7.js → openrouter-oauth-DxX2hvVP.js} +1 -1
  69. package/dist/ui/assets/{opfs-mount-DF1_TQm7.js → opfs-mount-5UoVuxDu.js} +1 -1
  70. package/dist/ui/assets/{panel-rpc-handlers-DYotibPR.js → panel-rpc-handlers-bRzKgfVJ.js} +2 -2
  71. package/dist/ui/assets/{panelize-shell-5hKkbwSl.js → panelize-shell-DAt5CNbQ.js} +1 -1
  72. package/dist/ui/assets/{pi-edit-execution-CcLt8vSI.js → pi-edit-execution-CUuZWLzj.js} +1 -1
  73. package/dist/ui/assets/{provider-BLshPMsZ.js → provider-BCi9Lt4r.js} +2 -2
  74. package/dist/ui/assets/{provider-DqEfigmv.js → provider-aSGF7d4k.js} +1 -1
  75. package/dist/ui/assets/{provider-settings-BuaTQYid.js → provider-settings-DBgiE3eI.js} +1 -1
  76. package/dist/ui/assets/provider-store-access-B-R3ftEl.js +1 -0
  77. package/dist/ui/assets/provider-store-access-DWKXxpFB.js +1 -0
  78. package/dist/ui/assets/{providers-CE4VqQs6.js → providers-CGp8gI0u.js} +2 -2
  79. package/dist/ui/assets/{providers-B3cOXz1H.js → providers-CuHIzVOH.js} +1 -1
  80. package/dist/ui/assets/{quick-llm-D1wGZooG.js → quick-llm-DoBxND6k.js} +1 -1
  81. package/dist/ui/assets/{realm-inprocess-Dcn5yLm3.js → realm-inprocess-CtMTK-aN.js} +11 -11
  82. package/dist/ui/assets/{realm-unhandled-rejections-BU76F0PI.js → realm-unhandled-rejections-Dqt1Gk_j.js} +1 -1
  83. package/dist/ui/assets/{realm-unhandled-rejections-BXxVemlU.js → realm-unhandled-rejections-mGOVnR3q.js} +1 -1
  84. package/dist/ui/assets/{recovery-screen-D6HBp0xj.js → recovery-screen-B5zo1B0l.js} +1 -1
  85. package/dist/ui/assets/{remote-terminal-view-BDO5t9M_.js → remote-terminal-view-DDLUNW_y.js} +2 -2
  86. package/dist/ui/assets/{restore-CdH_ze1C.js → restore-Dd8d_Hgn.js} +1 -1
  87. package/dist/ui/assets/{run-D2pF2y1_.js → run-6f72KPaA.js} +1 -1
  88. package/dist/ui/assets/{run-DNvbqTbo.js → run-Bksq7Mcn.js} +1 -1
  89. package/dist/ui/assets/{run-fHfrubKD.js → run-BtSi8XBr.js} +1 -1
  90. package/dist/ui/assets/{run-B4snw1GL.js → run-DFA1g9kE.js} +2 -2
  91. package/dist/ui/assets/{run-xrVX3llR.js → run-DSsM13ob.js} +1 -1
  92. package/dist/ui/assets/{run-C_6GKpBV.js → run-DaUWBY-8.js} +6 -5
  93. package/dist/ui/assets/{run-CK7bQLZ0.js → run-DthMAupa.js} +2 -2
  94. package/dist/ui/assets/{run-CkKb9UWF.js → run-TkhZNuOx.js} +2 -2
  95. package/dist/ui/assets/{run-DsYsM6Yl.js → run-pvy0ymSy.js} +1 -1
  96. package/dist/ui/assets/{session-command-memory-CGqbKVAE.js → session-command-memory-Bl7bZtJm.js} +2 -2
  97. package/dist/ui/assets/{session-jsonl-CgKvYDUr.js → session-jsonl-Bv4dRBT4.js} +1 -1
  98. package/dist/ui/assets/{session-jsonl-CbNA3lGB.js → session-jsonl-DrVVeoTe.js} +1 -1
  99. package/dist/ui/assets/{session-search-index-CKHuYyZd.js → session-search-index-DGDHOAzl.js} +2 -2
  100. package/dist/ui/assets/{setup-feature-flags-remote-DU_3gSCe.js → setup-feature-flags-remote-CIhV4D0j.js} +1 -1
  101. package/dist/ui/assets/{setup-model-catalog-CQmIQSJ6.js → setup-model-catalog-BVDWM2AV.js} +1 -1
  102. package/dist/ui/assets/{signed-fetch-DEi8arT4.js → signed-fetch-CI9UIEV3.js} +1 -1
  103. package/dist/ui/assets/{silent-renew-backoff-UU1St8tN.js → silent-renew-backoff-BcsYBz66.js} +1 -1
  104. package/dist/ui/assets/slicc-version-BUehjIK3.js +1 -0
  105. package/dist/ui/assets/{snapshot-BPuldVwP.js → snapshot-CuamLfhh.js} +1 -1
  106. package/dist/ui/assets/{snapshot-features-Ddz9jsBd.js → snapshot-features-C5OANvrP.js} +1 -1
  107. package/dist/ui/assets/{soundscape-Uopjnq2I.js → soundscape-BwoAG-sm.js} +1 -1
  108. package/dist/ui/assets/{speak-D_PLnidz.js → speak-DwgV2tTT.js} +1 -1
  109. package/dist/ui/assets/{sprinkle-manager-BpNh9Lri.js → sprinkle-manager-DNJheHds.js} +1 -1
  110. package/dist/ui/assets/{sprinkle-renderer-BljwWT0g.js → sprinkle-renderer-CumxYPMj.js} +1 -1
  111. package/dist/ui/assets/{ssh-DBPFvqmL.js → ssh-B58quV88.js} +1 -1
  112. package/dist/ui/assets/{state-CHrSe9Ro.js → state-D_VYopGz.js} +1 -1
  113. package/dist/ui/assets/{store-BvFCmAq8.js → store-DJqDctgs.js} +1 -1
  114. package/dist/ui/assets/{store-BikzV66S.js → store-Dr9vzNP5.js} +1 -1
  115. package/dist/ui/assets/{sudo-rquT1VWH.js → sudo-BlL3sTXW.js} +1 -1
  116. package/dist/ui/assets/{sudo-fs-C6r_MIIY.js → sudo-fs-CQphjEUf.js} +1 -1
  117. package/dist/ui/assets/{supervisor-MXcG8SU6.js → supervisor-smOiGe-0.js} +1 -1
  118. package/dist/ui/assets/{sync-dialog-zmsfROKR.js → sync-dialog-Dyg2UAEo.js} +1 -1
  119. package/dist/ui/assets/{transformers-env-DVU2J7Xd.js → transformers-env-UAM9w3LM.js} +1 -1
  120. package/dist/ui/assets/{tray-leader-5xt9j15D.js → tray-leader-DK60MjaP.js} +1 -1
  121. package/dist/ui/assets/{tray-leave-runtime-B5LmQl4b.js → tray-leave-runtime-xgABwff8.js} +1 -1
  122. package/dist/ui/assets/{tray-sidecar-pljn-63X.js → tray-sidecar-BASB7cHq.js} +1 -1
  123. package/dist/ui/assets/{upgrade-detection-Ta4nIJJR.js → upgrade-detection-CcWsY0kz.js} +1 -1
  124. package/dist/ui/assets/{upskill-lick-skip-IyN1i0IF.js → upskill-lick-skip-BXEN7tuy.js} +1 -1
  125. package/dist/ui/assets/{voice-reply-aiuvZ8F3.js → voice-reply-DiXcXbUh.js} +1 -1
  126. package/dist/ui/assets/{wc-attach-C1CTfWQ-.js → wc-attach-CY3wKM4q.js} +2 -2
  127. package/dist/ui/assets/{wc-browser-RbezSPht.js → wc-browser-DE6aJENW.js} +1 -1
  128. package/dist/ui/assets/{wc-computers-D4IEEM5M.js → wc-computers-C9GCAa4H.js} +1 -1
  129. package/dist/ui/assets/{wc-detached-CrVlYV_z.js → wc-detached-5v5K5mcQ.js} +1 -1
  130. package/dist/ui/assets/{wc-extension-BW5y8hdg.js → wc-extension-D52mizb7.js} +2 -2
  131. package/dist/ui/assets/{wc-follower-xchSJ13T.js → wc-follower-CJOYr6g8.js} +3 -3
  132. package/dist/ui/assets/{wc-follower-oauth-BArMqE7c.js → wc-follower-oauth-B-6WQQBu.js} +1 -1
  133. package/dist/ui/assets/{wc-gelatiere-CxGkXDNo.js → wc-gelatiere-B2Bep1GD.js} +1 -1
  134. package/dist/ui/assets/{wc-live-DdOUCb1z.js → wc-live-CvDfoeZP.js} +11 -6
  135. package/dist/ui/assets/{wc-nav-C-cqoNl9.js → wc-nav-TcvaUUjk.js} +2 -2
  136. package/dist/ui/assets/{wc-onboarding-CId-wqvG.js → wc-onboarding-CFQJPD-H.js} +2 -2
  137. package/dist/ui/assets/{wc-permissions-lj9xrdU-.js → wc-permissions-BN0L49tc.js} +2 -2
  138. package/dist/ui/assets/{wc-placeholder-bs83QBxc.js → wc-placeholder-C_2WDAIS.js} +3 -3
  139. package/dist/ui/assets/{wc-secret-request-BmVSG3Qe.js → wc-secret-request-Dg-LzTLD.js} +1 -1
  140. package/dist/ui/assets/{wc-settings-CE5aZbkW.js → wc-settings-qv3-GQuG.js} +3 -3
  141. package/dist/ui/assets/{wc-shell-DdSbkIp-.js → wc-shell-B2rVnxeB.js} +5 -5
  142. package/dist/ui/assets/{wc-shortcut-config-C2d66GP8.js → wc-shortcut-config-DxXBHdKj.js} +1 -1
  143. package/dist/ui/assets/{wc-sprinkles-ak7XBDCk.js → wc-sprinkles-RfofsinU.js} +2 -2
  144. package/dist/ui/assets/{wc-transcript-export-DYVbwupj.js → wc-transcript-export-DE4ckv6H.js} +2 -2
  145. package/dist/ui/assets/{wc-tray-CjkC7SwM.js → wc-tray-CBNoNpOV.js} +4 -4
  146. package/dist/ui/assets/welcome-detection-SGZmx8Ya.js +1 -0
  147. package/dist/ui/assets/{whisper-session-DBea3Pzc.js → whisper-session-Cl4_UhwI.js} +2 -2
  148. package/dist/ui/assets/{xai-grok-B-WV19uN.js → xai-grok-CQ-_7nZn.js} +1 -1
  149. package/dist/ui/assets/{xai-grok-CAPZiieq.js → xai-grok-DV6fnUIH.js} +1 -1
  150. package/dist/ui/index.html +3 -3
  151. package/dist/ui/packages/webapp/index.html +3 -3
  152. package/package.json +1 -1
  153. package/dist/ui/assets/adobe-C2Yk0FjU.js +0 -1
  154. package/dist/ui/assets/fs-D5UZBrBX.js +0 -1
  155. package/dist/ui/assets/fs-DouF0VP9.js +0 -2
  156. package/dist/ui/assets/installer-BamTBGiN.js +0 -4
  157. package/dist/ui/assets/live-session-curation-eGH4uyM1.js +0 -1
  158. package/dist/ui/assets/memory-budget-Bcf7Eolo.js +0 -1
  159. package/dist/ui/assets/memory-write-execute-C7SUGCPF.js +0 -1
  160. package/dist/ui/assets/provider-store-access-BABW1Cfu.js +0 -1
  161. package/dist/ui/assets/provider-store-access-C2xFS3NU.js +0 -1
  162. package/dist/ui/assets/slicc-version-D8Zbv4vp.js +0 -1
  163. package/dist/ui/assets/welcome-detection-BAQGL8Ld.js +0 -1
@@ -1 +1 @@
1
- import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-ak7XBDCk.js";var t=`focus`,n={type:`leaf`,surfaceId:`chat`};function r(e,t={},n={}){return{zones:{top:null,left:null,middle:null,right:null,bottom:null,...e},rowFr:{top:1,center:1,bottom:1,...n},colFr:{left:1,middle:1,right:1,...t}}}var i={focus:{name:`focus`,tree:r({left:n},{left:3,middle:1})}};function a(e){return i[e]??null}function o(n,r){switch(r.kind){case`set`:n.applyLayout(r.tree);break;case`reset`:{let e=a(t);e&&n.applyLayout(e.tree);break}case`chat`:n.moveSurfaceToZone(e,r.zone);break;case`open`:n.placeSurface(r.zone,r.surfaceId);break;case`close`:n.removeSurface(r.surfaceId);break;case`move`:n.moveSurfaceToZone(r.surfaceId,r.zone);break;case`size`:n.setSurfaceSize(r.surfaceId,r.size)}}export{o as applyLayout};
1
+ import{CHAT_SURFACE_ID as e}from"./wc-sprinkles-RfofsinU.js";var t=`focus`,n={type:`leaf`,surfaceId:`chat`};function r(e,t={},n={}){return{zones:{top:null,left:null,middle:null,right:null,bottom:null,...e},rowFr:{top:1,center:1,bottom:1,...n},colFr:{left:1,middle:1,right:1,...t}}}var i={focus:{name:`focus`,tree:r({left:n},{left:3,middle:1})}};function a(e){return i[e]??null}function o(n,r){switch(r.kind){case`set`:n.applyLayout(r.tree);break;case`reset`:{let e=a(t);e&&n.applyLayout(e.tree);break}case`chat`:n.moveSurfaceToZone(e,r.zone);break;case`open`:n.placeSurface(r.zone,r.surfaceId);break;case`close`:n.removeSurface(r.surfaceId);break;case`move`:n.moveSurfaceToZone(r.surfaceId,r.zone);break;case`size`:n.setSurfaceSize(r.surfaceId,r.size)}}export{o as applyLayout};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./slugify-BYJ6QVAt.js";import{t as n}from"./types-D8gIX-W-.js";import{t as r}from"./html-B_Hg2WOy.js";import{t as i}from"./global-db-DJXlpNui.js";const a=e(`mcp-apps`),o=`/workspace/.mcp/sprinkles`;async function s(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-D5UZBrBX.js`).then(e=>e.t);return await t.create({dbName:i})}function c(e){return t(e,{maxLen:64,fallback:`app`})}function l(e,t){let n=r(t.title??t.name),i=t.description?r(t.description):``,a=r(t.templateUri??`about:blank`),o=JSON.stringify(e),s=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{t}from"./slugify-BYJ6QVAt.js";import{t as n}from"./types-D8gIX-W-.js";import{t as r}from"./html-B_Hg2WOy.js";import{t as i}from"./global-db-DJXlpNui.js";const a=e(`mcp-apps`),o=`/workspace/.mcp/sprinkles`;async function s(e){if(e)return e;let{VirtualFS:t}=await import(`./fs-BxDhct-3.js`).then(e=>e.t);return await t.create({dbName:i})}function c(e){return t(e,{maxLen:64,fallback:`app`})}function l(e,t){let n=r(t.title??t.name),i=t.description?r(t.description):``,a=r(t.templateUri??`about:blank`),o=JSON.stringify(e),s=JSON.stringify(t.name);return`<div class="mcp-app" data-sprinkle-title="${n}" style="display:flex;flex-direction:column;height:100%;min-height:0;">
2
2
  <header class="mcp-app__header" style="padding:8px 12px;border-bottom:1px solid var(--s2-border-subtle,#3a3a3a);">
3
3
  <h2 style="font-size:14px;font-weight:600;margin:0;">${n}</h2>${i?`\n <p style="font-size:12px;margin:4px 0 0;color:var(--s2-content-secondary,#a0a0a0);">${i}</p>`:``}
4
4
  </header>
@@ -1,4 +1,4 @@
1
- import{a as e}from"./diagnostics-DN_idNHx.js";import{t}from"./models-BSkXF4T6.js";import{a as n}from"./compat-qQM4gjF_.js";import{S as r,v as i}from"./account-store-Bevys7WL.js";import{r as a,t as o}from"./transform-messages-BsQjTIEJ.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e),S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De,Oe=65536,ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
1
+ import{a as e}from"./diagnostics-DN_idNHx.js";import{t}from"./models-BSkXF4T6.js";import{a as n}from"./compat-qQM4gjF_.js";import{S as r,v as i}from"./account-store-SimIXg8S.js";import{r as a,t as o}from"./transform-messages-BsQjTIEJ.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}var l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}},ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e),S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}var Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De,Oe=65536,ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,Ee=new WeakMap,Te=new WeakSet,De=function(e){if(c(this,D,`f`)+e.length>c(this,T,`f`).length){let t=c(this,D,`f`)-c(this,E,`f`);if(c(this,E,`f`)>=c(this,T,`f`).length/2&&t+e.length<=c(this,T,`f`).length)c(this,T,`f`).copyWithin(0,c(this,E,`f`),c(this,D,`f`));else{let n=Math.max(c(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,r,`f`)}s(this,O,c(this,O,`f`)-c(this,E,`f`),`f`),s(this,D,t,`f`),s(this,E,0,`f`)}c(this,T,`f`).set(e,c(this,D,`f`)),s(this,D,c(this,D,`f`)+e.length,`f`)},ke.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),ke.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ae(e,t,n){for(let r=t;r<n;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}function je(e){for(let t=0;t<e.length-1;t++){let n=Me(e,t);if(n>0){let r=t+n,i=Me(e,r);if(i>0)return r+i}}return-1}function Me(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}var Ne={off:0,error:200,warn:300,info:400,debug:500},Pe=(e,t,n)=>{if(e){if(pe(Ne,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ne))}`)}};function Fe(){}function Ie(e,t,n){return!t||Ne[e]>Ne[n]?Fe:t[e].bind(t)}var Le={error:Fe,warn:Fe,info:Fe,debug:Fe},Re=new WeakMap;function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Le;let r=Re.get(t);if(r&&r[0]===n)return r[1];let i={error:Ie(`error`,t,n),warn:Ie(`warn`,t,n),info:Ie(`info`,t,n),debug:Ie(`debug`,t,n)};return Re.set(t,[n,i]),i}var ze=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),Be,Ve=class e{constructor(e,t,n){Be.set(this,void 0),this.iterator=e,this.controller=t,s(this,Be,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?k(r):console;async function*s(){if(a)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1,r=!1;try{for await(let e of He(t,n)){if(e.data.startsWith(`[DONE]`)){r=!0;break}if(e.event===null||!e.event.startsWith(`thread.`)){let n;try{n=JSON.parse(e.data)}catch(t){throw o.error(`Could not parse message into JSON:`,e.data),o.error(`From chunk:`,e.raw),t}if(n&&n.error)throw new p(void 0,n.error,void 0,t.headers);yield i?{event:e.event,data:n}:n}else{let t;try{t=JSON.parse(e.data)}catch(t){throw console.error(`Could not parse message into JSON:`,e.data),console.error(`From chunk:`,e.raw),t}if(e.event===`error`)throw new p(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||u(e)||n.signal.aborted&&e===n.signal.reason)return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new ke,r=t.getReader(),i=!1,a,o=()=>{a??=r.cancel(),a.catch(()=>void 0)};n.signal.addEventListener(`abort`,o,{once:!0});try{if(n.signal.aborted){o();return}for(;;){let{value:t,done:a}=await r.read();if(a){i=!0;break}if(n.signal.aborted)return;for(let r of e.decode(t)){if(n.signal.aborted)return;yield r}}if(n.signal.aborted)return;for(let t of e.flush()){if(n.signal.aborted)return;yield t}}finally{n.signal.removeEventListener(`abort`,o),i||o(),r.releaseLock()}}async function*o(){if(i)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(n.signal.aborted||u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Be=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,c(this,Be,`f`)),new e(()=>i(n),this.controller,c(this,Be,`f`))]}toReadableStream(){let e;return ve({start:async()=>{e=this[Symbol.asyncIterator]()},async pull(t){try{let{value:n,done:r}=await e.next();if(r)return t.close();let i=w(JSON.stringify(n)+`
4
4
  `);t.enqueue(i)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}};async function*He(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new f(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new f(`Attempted to iterate over a response with no body`);let n=new Ge,r=new ke,i=be(e.body);for await(let e of We(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}var Ue=3;async function*We(e){let t=new Uint8Array,n=0,r=0,i=0;for await(let a of e){if(a==null)continue;let e;if(e=a instanceof ArrayBuffer?new Uint8Array(a):typeof a==`string`?w(a):a,r+e.length>t.length){let a=r-n;if(n>=t.length/2&&a+e.length<=t.length)t.copyWithin(0,n,r);else{let i=new Uint8Array(Math.max(t.length*2,a+e.length));i.set(t.subarray(n,r)),t=i}i-=n,n=0,r=a}t.set(e,r),r+=e.length;let o;for(;(o=je(t.subarray(i,r)))!==-1;)o+=i,yield t.slice(n,o),n=o,i=n;i=Math.max(n,r-Ue)}r>n&&(yield t.slice(n,r))}var Ge=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.slice(0,-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -1,4 +1,4 @@
1
- import{c as e,o as t}from"./account-store-irTFXEHq.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-4WTk3EBD.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,t as o}from"./transform-messages-Jn8bw4-u.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e);let S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}let Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De;const Oe=65536;var ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
1
+ import{c as e,o as t}from"./account-store-b2cIu79O.js";import{a as n}from"./diagnostics-DN_idNHx.js";import{t as r}from"./models-4WTk3EBD.js";import{a as i}from"./compat-uEPf6-XW.js";import{r as a,t as o}from"./transform-messages-Jn8bw4-u.js";function s(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function c(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}let l=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return l=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))};function u(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}const d=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var f=class extends Error{},p=class e extends f{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.requestID=i?.get(`x-request-id`),this.error=n;let a=n;this.code=a?.code,this.param=a?.param,this.type=a?.type}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new h({message:r,cause:d(n)});let a=n?.error;return t===400?new _(t,a,r,i):t===401?new v(t,a,r,i):t===403?new y(t,a,r,i):t===404?new b(t,a,r,i):t===409?new x(t,a,r,i):t===422?new ee(t,a,r,i):t===429?new te(t,a,r,i):t>=500?new ne(t,a,r,i):new e(t,a,r,i)}},m=class extends p{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},h=class extends p{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},g=class extends h{constructor({message:e}={}){super({message:e??`Request timed out.`})}},_=class extends p{},v=class extends p{},y=class extends p{},b=class extends p{},x=class extends p{},ee=class extends p{},te=class extends p{},ne=class extends p{},re=class extends f{constructor(){super(`Could not parse response content as the length limit was reached`)}},ie=class extends f{constructor(){super(`Could not parse response content as the request was rejected by the content filter`)}},ae=class extends Error{constructor(e){super(e)}},oe=class extends p{constructor(e,t,n){let r=`OAuth2 authentication error`,i;if(t&&typeof t==`object`){let e=t;i=e.error;let n=e.error_description;n&&typeof n==`string`?r=n:i&&(r=i)}super(e,t,r,n),this.error_code=i}},se=class extends f{constructor(e,t,n){super(e),this.provider=t,this.cause=n}};const ce=/^[a-z][a-z0-9+.-]*:/i,le=e=>ce.test(e);let S=e=>(S=Array.isArray,S(e)),ue=S;function de(e){return typeof e==`object`?e??{}:{}}function fe(e){if(!e)return!0;for(let t in e)return!1;return!0}function pe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const me=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new f(`${e} must be an integer`);if(t<0)throw new f(`${e} must be a positive integer`);return t},he=e=>{try{return JSON.parse(e)}catch{return}},ge=e=>new Promise(t=>setTimeout(t,e));function _e(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function ve(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ye(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return ve({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.()}})}function be(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function xe(e){if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}let t=e.getReader(),n=t.cancel();t.releaseLock(),await n}let Se;function w(e){let t;return(Se??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}let Ce;function we(e){let t;return(Ce??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Te,T,E,D,O,Ee,De;const Oe=65536;var ke=class{constructor(){Te.add(this),T.set(this,void 0),E.set(this,void 0),D.set(this,void 0),O.set(this,void 0),Ee.set(this,void 0),s(this,T,new Uint8Array,`f`),s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),s(this,Ee,!1,`f`)}decode(e){if(e==null)return[];let t;if(t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?w(e):e,t.length===0||c(this,Ee,`f`)&&(s(this,Ee,!1,`f`),t[0]===10&&(t=t.subarray(1)),t.length===0))return[];c(this,Te,`m`,De).call(this,t);let n=[],r;for(;(r=Ae(c(this,T,`f`),c(this,O,`f`),c(this,D,`f`)))!=null;){let e=we(c(this,T,`f`).subarray(c(this,E,`f`),r.preceding));n.push(e),s(this,E,r.index,`f`),r.carriage&&(c(this,E,`f`)<c(this,D,`f`)&&c(this,T,`f`)[c(this,E,`f`)]===10?s(this,E,c(this,E,`f`)+1,`f`):c(this,E,`f`)===c(this,D,`f`)&&s(this,Ee,!0,`f`)),s(this,O,c(this,E,`f`),`f`)}if(s(this,O,c(this,D,`f`),`f`),c(this,E,`f`)===c(this,D,`f`))s(this,E,0,`f`),s(this,D,0,`f`),s(this,O,0,`f`),c(this,T,`f`).length>Oe&&s(this,T,new Uint8Array,`f`);else if(n.length>0&&c(this,T,`f`).length>Oe){let e=c(this,D,`f`)-c(this,E,`f`);if(e<=Oe||c(this,T,`f`).length>e*4){let t=e<=Oe?Math.min(Math.max(e*2,256),Oe):e*2,n=new Uint8Array(t);n.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,n,`f`),s(this,E,0,`f`),s(this,D,e,`f`),s(this,O,e,`f`)}}return n}flush(){return s(this,Ee,!1,`f`),c(this,E,`f`)===c(this,D,`f`)?[]:this.decode(`
2
2
  `)}};T=new WeakMap,E=new WeakMap,D=new WeakMap,O=new WeakMap,Ee=new WeakMap,Te=new WeakSet,De=function(e){if(c(this,D,`f`)+e.length>c(this,T,`f`).length){let t=c(this,D,`f`)-c(this,E,`f`);if(c(this,E,`f`)>=c(this,T,`f`).length/2&&t+e.length<=c(this,T,`f`).length)c(this,T,`f`).copyWithin(0,c(this,E,`f`),c(this,D,`f`));else{let n=Math.max(c(this,T,`f`).length*2,t+e.length,256),r=new Uint8Array(n);r.set(c(this,T,`f`).subarray(c(this,E,`f`),c(this,D,`f`))),s(this,T,r,`f`)}s(this,O,c(this,O,`f`)-c(this,E,`f`),`f`),s(this,D,t,`f`),s(this,E,0,`f`)}c(this,T,`f`).set(e,c(this,D,`f`)),s(this,D,c(this,D,`f`)+e.length,`f`)},ke.NEWLINE_CHARS=new Set([`
3
3
  `,`\r`]),ke.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ae(e,t,n){for(let r=t;r<n;r++){if(e[r]===10)return{preceding:r,index:r+1,carriage:!1};if(e[r]===13)return{preceding:r,index:r+1,carriage:!0}}return null}function je(e){for(let t=0;t<e.length-1;t++){let n=Me(e,t);if(n>0){let r=t+n,i=Me(e,r);if(i>0)return r+i}}return-1}function Me(e,t){return e[t]===10?1:e[t]===13?e[t+1]===10?2:1:0}const Ne={off:0,error:200,warn:300,info:400,debug:500},Pe=(e,t,n)=>{if(e){if(pe(Ne,e))return e;k(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Ne))}`)}};function Fe(){}function Ie(e,t,n){return!t||Ne[e]>Ne[n]?Fe:t[e].bind(t)}const Le={error:Fe,warn:Fe,info:Fe,debug:Fe};let Re=new WeakMap;function k(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Le;let r=Re.get(t);if(r&&r[0]===n)return r[1];let i={error:Ie(`error`,t,n),warn:Ie(`warn`,t,n),info:Ie(`info`,t,n),debug:Ie(`debug`,t,n)};return Re.set(t,[n,i]),i}const ze=e=>(e.options&&(e.options={...e.options},delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`authorization`||e.toLowerCase()===`api-key`||e.toLowerCase()===`x-api-key`||e.toLowerCase()===`x-amz-security-token`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var Be,Ve=class e{constructor(e,t,n){Be.set(this,void 0),this.iterator=e,this.controller=t,s(this,Be,n,`f`)}static fromSSEResponse(t,n,r,i){let a=!1,o=r?k(r):console;async function*s(){if(a)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let e=!1,r=!1;try{for await(let e of He(t,n)){if(e.data.startsWith(`[DONE]`)){r=!0;break}if(e.event===null||!e.event.startsWith(`thread.`)){let n;try{n=JSON.parse(e.data)}catch(t){throw o.error(`Could not parse message into JSON:`,e.data),o.error(`From chunk:`,e.raw),t}if(n&&n.error)throw new p(void 0,n.error,void 0,t.headers);yield i?{event:e.event,data:n}:n}else{let t;try{t=JSON.parse(e.data)}catch(t){throw console.error(`Could not parse message into JSON:`,e.data),console.error(`From chunk:`,e.raw),t}if(e.event===`error`)throw new p(void 0,t.error,t.message,void 0);yield{event:e.event,data:t}}}e=!0}catch(e){if(r||u(e)||n.signal.aborted&&e===n.signal.reason)return;throw e}finally{e||n.abort()}}return new e(s,n,r)}static fromReadableStream(t,n,r){let i=!1;async function*a(){let e=new ke,r=t.getReader(),i=!1,a,o=()=>{a??=r.cancel(),a.catch(()=>void 0)};n.signal.addEventListener(`abort`,o,{once:!0});try{if(n.signal.aborted){o();return}for(;;){let{value:t,done:a}=await r.read();if(a){i=!0;break}if(n.signal.aborted)return;for(let r of e.decode(t)){if(n.signal.aborted)return;yield r}}if(n.signal.aborted)return;for(let t of e.flush()){if(n.signal.aborted)return;yield t}}finally{n.signal.removeEventListener(`abort`,o),i||o(),r.releaseLock()}}async function*o(){if(i)throw new f("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let e=!1;try{for await(let t of a())e||t&&(yield JSON.parse(t));e=!0}catch(e){if(n.signal.aborted||u(e))return;throw e}finally{e||n.abort()}}return new e(o,n,r)}[(Be=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,c(this,Be,`f`)),new e(()=>i(n),this.controller,c(this,Be,`f`))]}toReadableStream(){let e;return ve({start:async()=>{e=this[Symbol.asyncIterator]()},async pull(t){try{let{value:n,done:r}=await e.next();if(r)return t.close();let i=w(JSON.stringify(n)+`
4
4
  `);t.enqueue(i)}catch(e){t.error(e)}},async cancel(){await e.return?.()}})}};async function*He(e,t){if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new f(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new f(`Attempted to iterate over a response with no body`);let n=new We,r=new ke,i=be(e.body);for await(let e of Ue(i))for(let t of r.decode(e)){let e=n.decode(t);e&&(yield e)}for(let e of r.flush()){let t=n.decode(e);t&&(yield t)}}async function*Ue(e){let t=new Uint8Array,n=0,r=0,i=0;for await(let a of e){if(a==null)continue;let e;if(e=a instanceof ArrayBuffer?new Uint8Array(a):typeof a==`string`?w(a):a,r+e.length>t.length){let a=r-n;if(n>=t.length/2&&a+e.length<=t.length)t.copyWithin(0,n,r);else{let i=new Uint8Array(Math.max(t.length*2,a+e.length));i.set(t.subarray(n,r)),t=i}i-=n,n=0,r=a}t.set(e,r),r+=e.length;let o;for(;(o=je(t.subarray(i,r)))!==-1;)o+=i,yield t.slice(n,o),n=o,i=n;i=Math.max(n,r-3)}r>n&&(yield t.slice(n,r))}var We=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.slice(0,-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(`
@@ -1 +1 @@
1
- import{s as e,t}from"./api-endpoint-DuEQRZ4g.js";import{t as n}from"./types-D8gIX-W-.js";import{n as r}from"./fs-DouF0VP9.js";import{t as i}from"./remote-cache-3KNT1gsp.js";function a(e){if(!Number.isFinite(e))return{run:e=>e(),get active(){return 0}};let t=Math.max(1,Math.floor(e)),n=[],r=0,i=()=>{let e=n.shift();if(e){e();return}--r};return{async run(e){r>=t?await new Promise(e=>n.push(e)):r+=1;try{return await e()}finally{i()}},get active(){return r}}}var o=104857600,s=new Set([`list`,`stat`,`mkdir`,`rename`,`remove`]),c=`/api/hostfs`,l=new Set([`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`]),u=new Set([`list`,`stat`,`read`,`mkdir`]),d=3,f=25,p=24,m=3e4,h=4194304,g=`no-store`;function _(e,t){return`hostfs:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}var v=e=>e.json(),y=async e=>({partial:e.status===206,body:await e.arrayBuffer()}),b=async e=>{await e.arrayBuffer()},x=e=>e>0?new Promise(t=>setTimeout(t,e)):Promise.resolve();function S(e,t,r,i,a){let o=r instanceof Error?r.message:String(r),s=a?` after ${i} attempt${i===1?``:`s`}`:` (not retried: non-idempotent op)`;return new n(`EIO`,`hostfs ${e} failed${s}: transient bridge error: ${o}`,t)}function C(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function w(t){let n={},i=C(t.ctime);i!==void 0&&(n.ctime=i);let a=C(t.ino);a!==void 0&&(n.ino=a);let o=C(t.dev);o!==void 0&&Number.isSafeInteger(o)&&o>=0&&(n.dev=o,n.identity=r(`hostfs:${e(c)}`,a,o));let s=C(t.uid);s!==void 0&&(n.uid=s);let l=C(t.gid);l!==void 0&&(n.gid=l);let u=C(t.mode);return u!==void 0&&(n.mode=u),n}var T=class{kind=`hostfs`;listingStatsMatchStat=!0;source;mountId;targetPath;hostPath;fetchImpl;limiter;maxAttempts;retryDelayMs;cache;maxCachedBodyBytes;cacheGeneration=0;closed=!1;stableEndpoint=!0;constructor(e){this.targetPath=e.targetPath,this.hostPath=e.hostPath,this.source=`hostfs://${e.hostPath}`,this.mountId=e.mountId??_(e.targetPath,e.hostPath),this.fetchImpl=e.fetchImpl??fetch,this.limiter=a(e.maxInflight??p),this.maxAttempts=Math.max(1,e.maxAttempts??d),this.retryDelayMs=e.retryDelayMs??f,this.maxCachedBodyBytes=Math.max(0,e.maxCachedBodyBytes??h),this.cache=e.cache??new i({mountId:this.mountId,ttlMs:e.cacheTtlMs??m})}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}bodyKey(e){return e.replace(/^\/+/,``)}async invalidateCachePrefixes(e){this.cacheGeneration+=1,await this.cache.invalidatePrefixes(e)}async cacheBodyIfCurrent(e,t,n,r){e!==this.cacheGeneration||n.byteLength>this.maxCachedBodyBytes||(await this.cache.putBody(t,n,r),e!==this.cacheGeneration&&await this.cache.invalidateBody(t))}async applyHostInvalidation(e){if(e.length===0){await this.invalidateCachePrefixes([]);return}let t=e.map(e=>e.replace(/^\/+/,``));if(t.some(e=>e.length===0||e===`.`)){await this.invalidateCachePrefixes([]);return}await this.invalidateCachePrefixes(t)}getCache(){return this.cache}url(t,n,r){let i=new URLSearchParams({mount:this.targetPath,path:n.replace(/^\/+/,``)});for(let[e,t]of Object.entries(r??{}))i.set(e,t);return e(`/api/hostfs/${t}?${i.toString()}`)}buildRequest(n,r,i){let a=t(i?.headers);if(this.stableEndpoint&&s.has(n))return{url:e(c),init:{method:`POST`,headers:{...a,"Content-Type":`application/json`},body:JSON.stringify({op:n,mount:this.targetPath,path:r.replace(/^\/+/,``),...i?.extra??{}})}};let{extra:o,...l}=i??{};return{url:this.url(n,r,i?.extra),init:{...l,headers:a}}}async request(e,t,n,r){return this.assertOpen(t),this.limiter.run(()=>this.attemptRequest(e,t,n,r))}async attemptRequest(e,t,r,i){let a=u.has(e)?this.maxAttempts:1,o=0,s;for(;o<a;){o+=1;try{return await this.routeAndConsume(e,t,r,i)}catch(e){if(e instanceof n)throw e;if(s=e,this.closed)break;o<a&&await x(this.retryDelayMs*o)}}throw S(e,t,s,o,a>1)}async routeAndConsume(e,t,n,r){let i=this.stableEndpoint&&s.has(e),a=this.buildRequest(e,t,r),o=await this.fetchImpl(a.url,a.init);if(o.ok||o.status===304)return await n(o);let{error:c,rawCode:l}=await this.errorFromResponse(e,t,o);if(i&&l===null&&(o.status===404||o.status===405))return this.stableEndpoint=!1,await this.routeAndConsume(e,t,n,r);throw c}async errorFromResponse(e,t,r){let i=`EIO`,a=null,o=`hostfs ${e} failed with HTTP ${r.status}`;try{let e=await r.json();typeof e.code==`string`&&(a=e.code,l.has(e.code)&&(i=e.code)),typeof e.message==`string`&&(o=e.message)}catch{}return{error:new n(i,o,t),rawCode:a}}async readDir(e){let t=await this.request(`list`,e,v);if(!Array.isArray(t.entries))return[];let n=[];for(let e of t.entries){let t=e;typeof t.name!=`string`||t.kind!==`file`&&t.kind!==`directory`||n.push({name:t.name,kind:t.kind,...typeof t.size==`number`?{size:t.size}:{},...typeof t.lastModified==`number`?{lastModified:t.lastModified}:{},...w(t)})}return n}async readFile(e){this.assertOpen(e);let t=this.cacheGeneration,r=this.bodyKey(e),i=await this.cache.getBody(r);if(i&&!this.cache.isStale(i.cachedAt))return i.body;let a={};i?.etag&&(a[`If-None-Match`]=i.etag);let s=await this.request(`read`,e,async e=>e.status===304?{kind:`not-modified`}:{kind:`body`,bytes:new Uint8Array(await e.arrayBuffer()),etag:e.headers.get(`etag`)??``},{cache:g,headers:a});if(s.kind===`not-modified`){if(!i)throw new n(`EIO`,`hostfs read got 304 without a cached body`,e);return await this.cacheBodyIfCurrent(t,r,i.body,i.etag),i.body}if(s.bytes.byteLength>o)throw new n(`EFBIG`,`file exceeds the hostfs body cap`,e);return await this.cacheBodyIfCurrent(t,r,s.bytes,s.etag),s.bytes}async readFileRange(e,t,r){if(!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<t)throw new n(`EINVAL`,`invalid byte range ${t}-${r}`,e);if(r===t)return new Uint8Array;if(r-t>o)throw new n(`EFBIG`,`byte range exceeds the hostfs body cap`,e);let{partial:i,body:a}=await this.request(`read`,e,y,{cache:g,headers:{Range:`bytes=${t}-${r-1}`}});return i?new Uint8Array(a):new Uint8Array(a).slice(t,r)}async writeFile(e,t){if(t.byteLength>o)throw new n(`EFBIG`,`body exceeds the hostfs body cap`,e);await this.request(`write`,e,b,{method:`PUT`,headers:{"Content-Type":`application/octet-stream`},body:new Uint8Array(t)});let r=this.bodyKey(e),i=++this.cacheGeneration;t.byteLength<=this.maxCachedBodyBytes?await this.cacheBodyIfCurrent(i,r,new Uint8Array(t),``):await this.cache.invalidateBody(r)}async stat(e){let t=await this.request(`stat`,e,v);return{kind:t.kind===`directory`?`directory`:`file`,size:typeof t.size==`number`?t.size:0,mtime:typeof t.mtime==`number`?t.mtime:0,...w(t)}}async mkdir(e){await this.request(`mkdir`,e,b,{method:`POST`})}async rename(e,t){let n=await this.request(`rename`,e,v,{method:`POST`,extra:{to:t.replace(/^\/+/,``)}}),r=this.bodyKey(e),i=this.bodyKey(t);return await this.invalidateCachePrefixes([r,i]),n.noop===!0?{noop:!0}:{}}async remove(e,t){await this.request(`remove`,e,b,{method:`DELETE`,extra:t?.recursive?{recursive:`1`}:void 0});let n=this.bodyKey(e);t?.recursive?await this.invalidateCachePrefixes([n]):(this.cacheGeneration+=1,await this.cache.invalidateBody(n))}async refresh(e){return this.assertOpen(this.targetPath),await this.invalidateCachePrefixes([]),{added:[],removed:[],changed:e?.bodies?[`*`]:[],unchanged:0,errors:[]}}describe(){return{displayName:this.hostPath.split(`/`).filter(Boolean).at(-1)??this.hostPath,source:this.source,extra:`configured via mount table (auto-mounted, live host view)`}}async close(){this.closed=!0}getHostPath(){return this.hostPath}getTargetPath(){return this.targetPath}};export{T as HostFsMountBackend};
1
+ import{s as e,t}from"./api-endpoint-DuEQRZ4g.js";import{t as n}from"./types-D8gIX-W-.js";import{n as r}from"./fs-C5DLxUuw.js";import{t as i}from"./remote-cache-3KNT1gsp.js";function a(e){if(!Number.isFinite(e))return{run:e=>e(),get active(){return 0}};let t=Math.max(1,Math.floor(e)),n=[],r=0,i=()=>{let e=n.shift();if(e){e();return}--r};return{async run(e){r>=t?await new Promise(e=>n.push(e)):r+=1;try{return await e()}finally{i()}},get active(){return r}}}var o=104857600,s=new Set([`list`,`stat`,`mkdir`,`rename`,`remove`]),c=`/api/hostfs`,l=new Set([`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`EIO`]),u=new Set([`list`,`stat`,`read`,`mkdir`]),d=3,f=25,p=24,m=3e4,h=4194304,g=`no-store`;function _(e,t){return`hostfs:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}var v=e=>e.json(),y=async e=>({partial:e.status===206,body:await e.arrayBuffer()}),b=async e=>{await e.arrayBuffer()},x=e=>e>0?new Promise(t=>setTimeout(t,e)):Promise.resolve();function S(e,t,r,i,a){let o=r instanceof Error?r.message:String(r),s=a?` after ${i} attempt${i===1?``:`s`}`:` (not retried: non-idempotent op)`;return new n(`EIO`,`hostfs ${e} failed${s}: transient bridge error: ${o}`,t)}function C(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function w(t){let n={},i=C(t.ctime);i!==void 0&&(n.ctime=i);let a=C(t.ino);a!==void 0&&(n.ino=a);let o=C(t.dev);o!==void 0&&Number.isSafeInteger(o)&&o>=0&&(n.dev=o,n.identity=r(`hostfs:${e(c)}`,a,o));let s=C(t.uid);s!==void 0&&(n.uid=s);let l=C(t.gid);l!==void 0&&(n.gid=l);let u=C(t.mode);return u!==void 0&&(n.mode=u),n}var T=class{kind=`hostfs`;listingStatsMatchStat=!0;source;mountId;targetPath;hostPath;fetchImpl;limiter;maxAttempts;retryDelayMs;cache;maxCachedBodyBytes;cacheGeneration=0;closed=!1;stableEndpoint=!0;constructor(e){this.targetPath=e.targetPath,this.hostPath=e.hostPath,this.source=`hostfs://${e.hostPath}`,this.mountId=e.mountId??_(e.targetPath,e.hostPath),this.fetchImpl=e.fetchImpl??fetch,this.limiter=a(e.maxInflight??p),this.maxAttempts=Math.max(1,e.maxAttempts??d),this.retryDelayMs=e.retryDelayMs??f,this.maxCachedBodyBytes=Math.max(0,e.maxCachedBodyBytes??h),this.cache=e.cache??new i({mountId:this.mountId,ttlMs:e.cacheTtlMs??m})}assertOpen(e){if(this.closed)throw new n(`EBADF`,`mount closed`,e)}bodyKey(e){return e.replace(/^\/+/,``)}async invalidateCachePrefixes(e){this.cacheGeneration+=1,await this.cache.invalidatePrefixes(e)}async cacheBodyIfCurrent(e,t,n,r){e!==this.cacheGeneration||n.byteLength>this.maxCachedBodyBytes||(await this.cache.putBody(t,n,r),e!==this.cacheGeneration&&await this.cache.invalidateBody(t))}async applyHostInvalidation(e){if(e.length===0){await this.invalidateCachePrefixes([]);return}let t=e.map(e=>e.replace(/^\/+/,``));if(t.some(e=>e.length===0||e===`.`)){await this.invalidateCachePrefixes([]);return}await this.invalidateCachePrefixes(t)}getCache(){return this.cache}url(t,n,r){let i=new URLSearchParams({mount:this.targetPath,path:n.replace(/^\/+/,``)});for(let[e,t]of Object.entries(r??{}))i.set(e,t);return e(`/api/hostfs/${t}?${i.toString()}`)}buildRequest(n,r,i){let a=t(i?.headers);if(this.stableEndpoint&&s.has(n))return{url:e(c),init:{method:`POST`,headers:{...a,"Content-Type":`application/json`},body:JSON.stringify({op:n,mount:this.targetPath,path:r.replace(/^\/+/,``),...i?.extra??{}})}};let{extra:o,...l}=i??{};return{url:this.url(n,r,i?.extra),init:{...l,headers:a}}}async request(e,t,n,r){return this.assertOpen(t),this.limiter.run(()=>this.attemptRequest(e,t,n,r))}async attemptRequest(e,t,r,i){let a=u.has(e)?this.maxAttempts:1,o=0,s;for(;o<a;){o+=1;try{return await this.routeAndConsume(e,t,r,i)}catch(e){if(e instanceof n)throw e;if(s=e,this.closed)break;o<a&&await x(this.retryDelayMs*o)}}throw S(e,t,s,o,a>1)}async routeAndConsume(e,t,n,r){let i=this.stableEndpoint&&s.has(e),a=this.buildRequest(e,t,r),o=await this.fetchImpl(a.url,a.init);if(o.ok||o.status===304)return await n(o);let{error:c,rawCode:l}=await this.errorFromResponse(e,t,o);if(i&&l===null&&(o.status===404||o.status===405))return this.stableEndpoint=!1,await this.routeAndConsume(e,t,n,r);throw c}async errorFromResponse(e,t,r){let i=`EIO`,a=null,o=`hostfs ${e} failed with HTTP ${r.status}`;try{let e=await r.json();typeof e.code==`string`&&(a=e.code,l.has(e.code)&&(i=e.code)),typeof e.message==`string`&&(o=e.message)}catch{}return{error:new n(i,o,t),rawCode:a}}async readDir(e){let t=await this.request(`list`,e,v);if(!Array.isArray(t.entries))return[];let n=[];for(let e of t.entries){let t=e;typeof t.name!=`string`||t.kind!==`file`&&t.kind!==`directory`||n.push({name:t.name,kind:t.kind,...typeof t.size==`number`?{size:t.size}:{},...typeof t.lastModified==`number`?{lastModified:t.lastModified}:{},...w(t)})}return n}async readFile(e){this.assertOpen(e);let t=this.cacheGeneration,r=this.bodyKey(e),i=await this.cache.getBody(r);if(i&&!this.cache.isStale(i.cachedAt))return i.body;let a={};i?.etag&&(a[`If-None-Match`]=i.etag);let s=await this.request(`read`,e,async e=>e.status===304?{kind:`not-modified`}:{kind:`body`,bytes:new Uint8Array(await e.arrayBuffer()),etag:e.headers.get(`etag`)??``},{cache:g,headers:a});if(s.kind===`not-modified`){if(!i)throw new n(`EIO`,`hostfs read got 304 without a cached body`,e);return await this.cacheBodyIfCurrent(t,r,i.body,i.etag),i.body}if(s.bytes.byteLength>o)throw new n(`EFBIG`,`file exceeds the hostfs body cap`,e);return await this.cacheBodyIfCurrent(t,r,s.bytes,s.etag),s.bytes}async readFileRange(e,t,r){if(!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<t)throw new n(`EINVAL`,`invalid byte range ${t}-${r}`,e);if(r===t)return new Uint8Array;if(r-t>o)throw new n(`EFBIG`,`byte range exceeds the hostfs body cap`,e);let{partial:i,body:a}=await this.request(`read`,e,y,{cache:g,headers:{Range:`bytes=${t}-${r-1}`}});return i?new Uint8Array(a):new Uint8Array(a).slice(t,r)}async writeFile(e,t){if(t.byteLength>o)throw new n(`EFBIG`,`body exceeds the hostfs body cap`,e);await this.request(`write`,e,b,{method:`PUT`,headers:{"Content-Type":`application/octet-stream`},body:new Uint8Array(t)});let r=this.bodyKey(e),i=++this.cacheGeneration;t.byteLength<=this.maxCachedBodyBytes?await this.cacheBodyIfCurrent(i,r,new Uint8Array(t),``):await this.cache.invalidateBody(r)}async stat(e){let t=await this.request(`stat`,e,v);return{kind:t.kind===`directory`?`directory`:`file`,size:typeof t.size==`number`?t.size:0,mtime:typeof t.mtime==`number`?t.mtime:0,...w(t)}}async mkdir(e){await this.request(`mkdir`,e,b,{method:`POST`})}async rename(e,t){let n=await this.request(`rename`,e,v,{method:`POST`,extra:{to:t.replace(/^\/+/,``)}}),r=this.bodyKey(e),i=this.bodyKey(t);return await this.invalidateCachePrefixes([r,i]),n.noop===!0?{noop:!0}:{}}async remove(e,t){await this.request(`remove`,e,b,{method:`DELETE`,extra:t?.recursive?{recursive:`1`}:void 0});let n=this.bodyKey(e);t?.recursive?await this.invalidateCachePrefixes([n]):(this.cacheGeneration+=1,await this.cache.invalidateBody(n))}async refresh(e){return this.assertOpen(this.targetPath),await this.invalidateCachePrefixes([]),{added:[],removed:[],changed:e?.bodies?[`*`]:[],unchanged:0,errors:[]}}describe(){return{displayName:this.hostPath.split(`/`).filter(Boolean).at(-1)??this.hostPath,source:this.source,extra:`configured via mount table (auto-mounted, live host view)`}}async close(){this.closed=!0}getHostPath(){return this.hostPath}getTargetPath(){return this.targetPath}};export{T as HostFsMountBackend};
@@ -166,17 +166,17 @@ Options:
166
166
  `)}catch(t){if(!i){let n=li(t);n.includes(`ENOENT`)||n.includes(`no such file`)?c+=`rm: cannot remove '${e}': No such file or directory
167
167
  `:n.includes(`ENOTEMPTY`)||n.includes(`not empty`)?c+=`rm: cannot remove '${e}': Directory not empty
168
168
  `:c+=`rm: cannot remove '${e}': ${ta(n)}
169
- `,l=1}}return{stdout:s,stderr:c,exitCode:l}}},qa={name:`rm`,flags:[{flag:`-r`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),Ya={};E(Ya,{cpCommand:()=>Qa,flagsForFuzzing:()=>$a});var Xa,Za,Qa,$a,eo=T(()=>{$i(),da(),j(),ui(),Jr(),F(),Xa={name:`cp`,summary:`copy files and directories`,usage:`cp [OPTION]... SOURCE... DEST`,options:[`-r, -R, --recursive copy directories recursively`,`-n, --no-clobber do not overwrite an existing file`,`-p, --preserve preserve file attributes`,`-v, --verbose explain what is being done`,` --help display this help and exit`]},Za={recursive:{short:`r`,long:`recursive`,type:`boolean`},recursiveUpper:{short:`R`,type:`boolean`},noClobber:{short:`n`,long:`no-clobber`,type:`boolean`},preserve:{short:`p`,long:`preserve`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},Qa={name:`cp`,async execute(e,t){if(N(e))return M(Xa);let n=qr(`cp`,e,Za);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,i=n.result.flags.noClobber;n.result.flags.preserve;let a=n.result.flags.verbose,o=n.result.positional;if(o.length<2)return{stdout:``,stderr:`cp: missing destination file operand
170
- `,exitCode:1};let s=o.pop()??``,c=o,l=t.fs.resolvePath(t.cwd,s),u=``,d=``,f=0,p=new ua({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`cp`}),m=!1;try{m=(await t.fs.stat(l)).isDirectory}catch{}if(c.length>1&&!m)return{stdout:``,stderr:`cp: target '${s}' is not a directory
171
- `,exitCode:1};for(let e of c)try{let n=t.fs.resolvePath(t.cwd,e),o=await t.fs.stat(n),s=l;if(m){let t=e.split(`/`).pop()||e;s=l===`/`?`/${t}`:`${l}/${t}`}if(o.isDirectory&&!r){d+=`cp: -r not specified; omitting directory '${e}'
172
- `,f=1;continue}if(o.isDirectory){let r=await sa(t.fs,n,s,p);if(qi(n,s)||r===`inside`){d+=`cp: cannot copy '${e}' into itself, '${s}'
173
- `,f=1;continue}if(r===`unknown`){d+=`cp: cannot safely determine whether '${s}' is inside '${e}'
174
- `,f=1;continue}}if(i)try{await t.fs.stat(s);continue}catch{}let c=await oa(t.fs,n,s);if(c===`same`){d+=`cp: '${e}' and '${s}' are the same file
175
- `,f=1;continue}if(c===`unknown`){d+=`cp: cannot safely determine whether '${e}' and '${s}' are the same file
176
- `,f=1;continue}o.isDirectory&&await ca({fs:t.fs,root:n,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`cp`,symlinks:`never`,budget:p},()=>{}),await t.fs.cp(n,s,{recursive:r}),a&&(u+=`'${e}' -> '${s}'
177
- `)}catch(t){if(t instanceof A||t instanceof jr)throw t;let n=li(t);n.includes(`ENOENT`)||n.includes(`no such file`)?d+=`cp: cannot stat '${e}': No such file or directory
178
- `:d+=`cp: cannot copy '${e}': ${n}
179
- `,f=1}return{stdout:u,stderr:d,exitCode:f}}},$a={name:`cp`,flags:[{flag:`-r`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),to={};E(to,{flagsForFuzzing:()=>ao,mvCommand:()=>io});var no,ro,io,ao,oo=T(()=>{$i(),da(),j(),ui(),Jr(),F(),no={name:`mv`,summary:`move (rename) files`,usage:`mv [OPTION]... SOURCE... DEST`,options:[`-f, --force do not prompt before overwriting`,`-n, --no-clobber do not overwrite an existing file`,`-v, --verbose explain what is being done`,` --help display this help and exit`]},ro={force:{short:`f`,long:`force`,type:`boolean`},noClobber:{short:`n`,long:`no-clobber`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},io={name:`mv`,async execute(e,t){if(N(e))return M(no);let n=qr(`mv`,e,ro);if(!n.ok)return n.error;n.result.flags.force;let r=n.result.flags.noClobber,i=n.result.flags.verbose,a=n.result.positional;if(a.length<2)return{stdout:``,stderr:`mv: missing destination file operand
169
+ `,l=1}}return{stdout:s,stderr:c,exitCode:l}}},qa={name:`rm`,flags:[{flag:`-r`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),Ya={};E(Ya,{cpCommand:()=>Qa,flagsForFuzzing:()=>$a});var Xa,Za,Qa,$a,eo=T(()=>{$i(),da(),j(),ui(),Jr(),F(),Xa={name:`cp`,summary:`copy files and directories`,usage:`cp [OPTION]... SOURCE... DEST`,options:[`-r, -R, --recursive copy directories recursively`,`-f, --force if a destination can't be written, remove it and try again`,`-n, --no-clobber do not overwrite an existing file`,`-p, --preserve preserve file attributes`,`-v, --verbose explain what is being done`,` --help display this help and exit`]},Za={recursive:{short:`r`,long:`recursive`,type:`boolean`},recursiveUpper:{short:`R`,type:`boolean`},force:{short:`f`,long:`force`,type:`boolean`},noClobber:{short:`n`,long:`no-clobber`,type:`boolean`},preserve:{short:`p`,long:`preserve`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},Qa={name:`cp`,async execute(e,t){if(N(e))return M(Xa);let n=qr(`cp`,e,Za);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,i=n.result.flags.noClobber;n.result.flags.preserve;let a=n.result.flags.verbose,o=n.result.flags.force,s=n.result.positional;if(s.length<2)return{stdout:``,stderr:`cp: missing destination file operand
170
+ `,exitCode:1};let c=s.pop()??``,l=s,u=t.fs.resolvePath(t.cwd,c),d=``,f=``,p=0,m=new ua({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`cp`}),h=!1;try{h=(await t.fs.stat(u)).isDirectory}catch{}if(l.length>1&&!h)return{stdout:``,stderr:`cp: target '${c}' is not a directory
171
+ `,exitCode:1};for(let e of l)try{let n=t.fs.resolvePath(t.cwd,e),s=await t.fs.stat(n),c=u;if(h){let t=e.split(`/`).pop()||e;c=u===`/`?`/${t}`:`${u}/${t}`}if(s.isDirectory&&!r){f+=`cp: -r not specified; omitting directory '${e}'
172
+ `,p=1;continue}if(s.isDirectory){let r=await sa(t.fs,n,c,m);if(qi(n,c)||r===`inside`){f+=`cp: cannot copy '${e}' into itself, '${c}'
173
+ `,p=1;continue}if(r===`unknown`){f+=`cp: cannot safely determine whether '${c}' is inside '${e}'
174
+ `,p=1;continue}}if(i)try{await t.fs.stat(c);continue}catch{}let l=await oa(t.fs,n,c);if(l===`same`){f+=`cp: '${e}' and '${c}' are the same file
175
+ `,p=1;continue}if(l===`unknown`){f+=`cp: cannot safely determine whether '${e}' and '${c}' are the same file
176
+ `,p=1;continue}s.isDirectory&&await ca({fs:t.fs,root:n,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`cp`,symlinks:`never`,budget:m},()=>{}),await(async()=>{try{await t.fs.cp(n,c,{recursive:r})}catch(e){if(e instanceof A||e instanceof jr||!o||(await t.fs.stat(n)).isDirectory)throw e;{let t=(e&&typeof e==`object`&&`code`in e&&e.code!=null?String(e.code):``)||String(e&&e.message||e);if(!/^(EACCES|EPERM|EEXIST|EISDIR|EROFS|EBUSY|ETXTBSY)$/i.test(t)&&!/\b(EACCES|EPERM|EEXIST|EISDIR|EROFS|EBUSY|ETXTBSY)\b/i.test(t))throw e}await t.fs.rm(c,{force:!0}),await t.fs.cp(n,c,{recursive:r})}})(),a&&(d+=`'${e}' -> '${c}'
177
+ `)}catch(t){if(t instanceof A||t instanceof jr)throw t;let n=li(t);n.includes(`ENOENT`)||n.includes(`no such file`)?f+=`cp: cannot stat '${e}': No such file or directory
178
+ `:f+=`cp: cannot copy '${e}': ${n}
179
+ `,p=1}return{stdout:d,stderr:f,exitCode:p}}},$a={name:`cp`,flags:[{flag:`-r`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),to={};E(to,{flagsForFuzzing:()=>ao,mvCommand:()=>io});var no,ro,io,ao,oo=T(()=>{$i(),da(),j(),ui(),Jr(),F(),no={name:`mv`,summary:`move (rename) files`,usage:`mv [OPTION]... SOURCE... DEST`,options:[`-f, --force do not prompt before overwriting`,`-n, --no-clobber do not overwrite an existing file`,`-v, --verbose explain what is being done`,` --help display this help and exit`]},ro={force:{short:`f`,long:`force`,type:`boolean`},noClobber:{short:`n`,long:`no-clobber`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},io={name:`mv`,async execute(e,t){if(N(e))return M(no);let n=qr(`mv`,e,ro);if(!n.ok)return n.error;n.result.flags.force;let r=n.result.flags.noClobber,i=n.result.flags.verbose,a=n.result.positional;if(a.length<2)return{stdout:``,stderr:`mv: missing destination file operand
180
180
  `,exitCode:1};let o=a.pop()??``,s=a,c=t.fs.resolvePath(t.cwd,o),l=``,u=``,d=0,f=new ua({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`mv`}),p=!1;try{p=(await t.fs.stat(c)).isDirectory}catch{}if(s.length>1&&!p)return{stdout:``,stderr:`mv: target '${o}' is not a directory
181
181
  `,exitCode:1};for(let e of s)try{let n=t.fs.resolvePath(t.cwd,e),a=await t.fs.stat(n),s=c;if(p){let t=e.split(`/`).pop()||e;s=c===`/`?`/${t}`:`${c}/${t}`}if(a.isDirectory){let r=await sa(t.fs,n,s,f);if(qi(n,s)||r===`inside`){u+=`mv: cannot move '${e}' into itself, '${s}'
182
182
  `,d=1;continue}if(r===`unknown`){u+=`mv: cannot safely determine whether '${s}' is inside '${e}'
@@ -323,7 +323,7 @@ ${t.patternSpace}`:t.holdSpace=t.patternSpace,zu(t.holdSpace,n?.maxStringLength?
323
323
  ${t.holdSpace}`,zu(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=Du(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}
324
324
  `});break;case`writeFirstLine`:{let n=t.patternSpace.indexOf(`
325
325
  `),r=n===-1?t.patternSpace:t.patternSpace.slice(0,n);t.pendingFileWrites.push({filename:e.filename,content:`${r}
326
- `});break}case`execute`:t.errorMessage=`sed: e command (shell execution) is not supported in sandboxed environment`,t.quit=!0;break;case`transliterate`:t.patternSpace=Vu(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 Vu(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 Hu(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??Uu,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(Iu(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(Iu(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+=`
326
+ `});break}case`execute`:t.errorMessage=`sed: e command (shell execution) is not supported in sandboxed environment`,t.quit=!0;break;case`transliterate`:t.patternSpace=Vu(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 Vu(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 Hu(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??Uu,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(Iu(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)){if(t.coverage?.hit(`sed:cmd:next`),t.lineNumberOutput.push({__jbN: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(Iu(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+=`
327
327
  ${e}`,t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1}else{t.quit=!0;break}}s++;continue}if(c.type===`branch`){let e=c;if(Iu(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(Iu(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(Iu(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(Iu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:group`),Hu(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}Bu(c,t,r),s++}return t.linesConsumedInCycle}var Uu,Wu=T(()=>{j(),gc(),ku(),Uu=1e4}),W,Gu,Ku=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||={}),Gu=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===`
328
328
  `?(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`?`
329
329
  `:e===`t`?` `:e}else{if(this.peek()===`
@@ -357,8 +357,8 @@ ${n}`}else a.push(n)}let o=a.join(`
357
357
  `),s=new Zu([o],t||i,n).parse();if(!s.error&&s.commands.length>0){let e=Ju(s.commands);if(e)return{commands:[],error:e,silentMode:r,extendedRegexMode:i}}return{...s,silentMode:r,extendedRegexMode:i}}function Ju(e){let t=new Set;Yu(e,t);let n=Xu(e,t);if(n)return`undefined label '${n}'`}function Yu(e,t){for(let n of e)n.type===`label`?t.add(n.name):n.type===`group`&&Yu(n.commands,t)}function Xu(e,t){for(let n of e){if((n.type===`branch`||n.type===`branchOnSubst`||n.type===`branchOnNoSubst`)&&n.label&&!t.has(n.label))return n.label;if(n.type===`group`){let e=Xu(n.commands,t);if(e)return e}}}var Zu,Qu=T(()=>{j(),zr(),Ku(),Zu=class{scripts;limits;tokens=[];pos=0;extendedRegex=!1;constructor(e,t=!1,n){this.scripts=e,this.limits=n,this.extendedRegex=t}parse(){let e=[];for(let t of this.scripts){let n=new Gu(t,this.limits?.maxStringLength,this.limits?.maxArrayElements);for(this.tokens=n.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(W.NEWLINE)||this.check(W.SEMICOLON)){this.advance();continue}let t=this.pos,n=this.parseCommand();if(n.error)return{commands:[],error:n.error};if(n.command&&e.push(n.command),this.pos===t&&!this.isAtEnd())return{commands:[],error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();if(e?.error)return{command:null,error:e.error};let t=e?.address;for(this.check(W.NEGATION)&&(this.advance(),t&&(t.negated=!0));this.check(W.NEWLINE)||this.check(W.SEMICOLON);)this.advance();if(this.isAtEnd())return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:`command expected`}:{command:null};let n=this.peek();switch(n.type){case W.COMMAND:return this.parseSimpleCommand(n,t);case W.SUBSTITUTE:return this.parseSubstituteFromToken(n,t);case W.TRANSLITERATE:return this.parseTransliterateFromToken(n,t);case W.LABEL_DEF:return this.advance(),{command:{type:`label`,name:n.label||``}};case W.BRANCH:return this.advance(),{command:{type:`branch`,address:t,label:n.label}};case W.BRANCH_ON_SUBST:return this.advance(),{command:{type:`branchOnSubst`,address:t,label:n.label}};case W.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:`branchOnNoSubst`,address:t,label:n.label}};case W.TEXT_CMD:return this.advance(),this.parseTextCommand(n,t);case W.FILE_READ:return this.advance(),{command:{type:`readFile`,address:t,filename:n.filename||``}};case W.FILE_READ_LINE:return this.advance(),{command:{type:`readFileLine`,address:t,filename:n.filename||``}};case W.FILE_WRITE:return this.advance(),{command:{type:`writeFile`,address:t,filename:n.filename||``}};case W.FILE_WRITE_LINE:return this.advance(),{command:{type:`writeFirstLine`,address:t,filename:n.filename||``}};case W.EXECUTE:return this.advance(),{command:{type:`execute`,address:t,command:n.command}};case W.VERSION:return this.advance(),{command:{type:`version`,address:t,minVersion:n.label}};case W.LBRACE:return this.parseGroup(t);case W.RBRACE:return{command:null};case W.ERROR:return{command:null,error:`invalid command: ${n.value}`};default:return t&&(t.start!==void 0||t.end!==void 0)?{command:null,error:`command expected`}:{command:null}}}parseSimpleCommand(e,t){this.advance();let n=e.value;switch(n){case`p`:return{command:{type:`print`,address:t}};case`P`:return{command:{type:`printFirstLine`,address:t}};case`d`:return{command:{type:`delete`,address:t}};case`D`:return{command:{type:`deleteFirstLine`,address:t}};case`h`:return{command:{type:`hold`,address:t}};case`H`:return{command:{type:`holdAppend`,address:t}};case`g`:return{command:{type:`get`,address:t}};case`G`:return{command:{type:`getAppend`,address:t}};case`x`:return{command:{type:`exchange`,address:t}};case`n`:return{command:{type:`next`,address:t}};case`N`:return{command:{type:`nextAppend`,address:t}};case`q`:return{command:{type:`quit`,address:t}};case`Q`:return{command:{type:`quitSilent`,address:t}};case`z`:return{command:{type:`zap`,address:t}};case`=`:return{command:{type:`lineNumber`,address:t}};case`l`:return{command:{type:`list`,address:t}};case`F`:return{command:{type:`printFilename`,address:t}};default:return{command:null,error:`unknown command: ${n}`}}}parseSubstituteFromToken(e,t){this.advance();let n=e.flags||``,r,i=n.match(/(\d+)/);return i&&(r=parseInt(i[1],10)),{command:{type:`substitute`,address:t,pattern:e.pattern||``,replacement:e.replacement||``,global:n.includes(`g`),ignoreCase:n.includes(`i`)||n.includes(`I`),printOnMatch:n.includes(`p`),nthOccurrence:r,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,t){this.advance();let n=e.source||``,r=e.dest||``;return n.length===r.length?{command:{type:`transliterate`,address:t,source:n,dest:r}}:{command:null,error:`transliteration sets must have same length`}}parseTextCommand(e,t){let n=e.value,r=e.text||``;switch(n){case`a`:return{command:{type:`append`,address:t,text:r}};case`i`:return{command:{type:`insert`,address:t,text:r}};case`c`:return{command:{type:`change`,address:t,text:r}};default:return{command:null,error:`unknown text command: ${n}`}}}parseGroup(e){this.advance();let t=[];for(;!this.isAtEnd()&&!this.check(W.RBRACE);){if(this.check(W.NEWLINE)||this.check(W.SEMICOLON)){this.advance();continue}let e=this.pos,n=this.parseCommand();if(n.error)return{command:null,error:n.error};if(n.command&&t.push(n.command),this.pos===e&&!this.isAtEnd())return{command:null,error:`unknown command: '${this.peek()?.value??this.peek()?.type}'`}}return this.check(W.RBRACE)?(this.advance(),{command:{type:`group`,address:e,commands:t}}):{command:null,error:`unmatched brace in grouped commands`}}parseAddressRange(){if(this.check(W.COMMA))return{error:`expected context address`};let e=this.parseAddress();if(e===void 0)return;let t;if(this.check(W.RELATIVE_OFFSET))t={offset:this.advance().offset||0};else if(this.check(W.COMMA)&&(this.advance(),t=this.parseAddress(),t===void 0))return{error:`expected context address`};return{address:{start:e,end:t}}}parseAddress(){let e=this.peek();switch(e.type){case W.NUMBER:return this.advance(),e.value;case W.DOLLAR:return this.advance(),`$`;case W.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case W.STEP:return this.advance(),{first:e.first||0,step:e.step||0};case W.RELATIVE_OFFSET:return this.advance(),{offset:e.offset||0};default:return}}peek(){return this.tokens[this.pos]||{type:W.EOF,value:``,line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===W.EOF}}}),$u={};E($u,{flagsForFuzzing:()=>rd,sedCommand:()=>nd});async function ed(e,t,n,r={}){let{limits:i,filename:a,fs:o,cwd:s,coverage:c,requireDefenseContext:l}=r;Su(l,`sed`,`processing entry`);let u=(e,t)=>Cu(l,`sed`,e,t),d=e.endsWith(`
358
358
  `),f=e.split(`
359
359
  `);f.length>0&&f[f.length-1]===``&&f.pop();let p=f.length,m=``,h,g=!1,_=i?.maxStringLength??0,v=e=>{if(m+=e,_>0&&m.length>_)throw new A(`sed: output size limit exceeded (${_} bytes)`,`string_length`)},y=``,b,x=new Map,S=new Map,ee=new Map,C=new Map,te=i?{maxIterations:i.maxSedIterations,maxStringLength:_}:void 0;for(let e=0;e<f.length;e++){let r={...Au(p,a,x),patternSpace:f[e],holdSpace:y,lastPattern:b,lineNumber:e+1,totalLines:p,substitutionMade:!1,coverage:c},i={lines:f,currentLineIndex:e},l=0;r.linesConsumedInCycle=0;do{if(l++,l>1e4)break;if(r.restartCycle=!1,r.pendingFileReads=[],r.pendingFileWrites=[],Hu(t,r,i,te),o&&s){for(let e of r.pendingFileReads){let t=o.resolvePath(s,e.filename);try{if(e.wholeFile){let e=await u(`read command file`,()=>o.readFile(t));r.appendBuffer.push(e.replace(/\n$/,``))}else{if(!S.has(t)){let e=await u(`read command file line cache`,()=>o.readFile(t));S.set(t,e.split(`
360
- `)),ee.set(t,0)}let e=S.get(t),n=ee.get(t);e&&n!==void 0&&n<e.length&&(r.appendBuffer.push(e[n]),ee.set(t,n+1))}}catch(e){if(e instanceof D)throw e}}for(let e of r.pendingFileWrites){let t=o.resolvePath(s,e.filename),n=C.get(t)||``;C.set(t,n+e.content)}}}while(r.restartCycle&&!r.deleted&&!r.quit&&!r.quitSilent);if(e+=r.linesConsumedInCycle,y=r.holdSpace,b=r.lastPattern,!n)for(let e of r.nCommandOutput)v(`${e}
361
- `);let d=r.lineNumberOutput.length>0;for(let e of r.lineNumberOutput)v(`${e}
360
+ `)),ee.set(t,0)}let e=S.get(t),n=ee.get(t);e&&n!==void 0&&n<e.length&&(r.appendBuffer.push(e[n]),ee.set(t,n+1))}}catch(e){if(e instanceof D)throw e}}for(let e of r.pendingFileWrites){let t=o.resolvePath(s,e.filename),n=C.get(t)||``;C.set(t,n+e.content)}}}while(r.restartCycle&&!r.deleted&&!r.quit&&!r.quitSilent);e+=r.linesConsumedInCycle,y=r.holdSpace,b=r.lastPattern;let d=r.lineNumberOutput.some(e=>typeof e!=`object`);for(let e of r.lineNumberOutput)typeof e==`object`?n||v(`${e.__jbN}
361
+ `):v(`${e}
362
362
  `);let m=[],_=[];for(let e of r.appendBuffer)e.startsWith(`__INSERT__`)?m.push(e.slice(10)):_.push(e);for(let e of m)v(`${e}
363
363
  `);let ne=!1;!r.deleted&&!r.quitSilent?n?r.printed&&(v(`${r.patternSpace}
364
364
  `),ne=!0):(v(`${r.patternSpace}
@@ -934,7 +934,7 @@ ${e.terminator}`}function iA(e){return`(${Xk(e.body)})${Yk(e.redirections)}`}fun
934
934
  `)}return r.effectiveValue}async function Gj(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 Kj(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+=Sj(t.pattern,n.greedy,o);else if(t.type===`Literal`)a+=Sj(t.value,n.greedy,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=xj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=xj(n)}else if(t.type===`ParameterExpansion`){let r=await i(e,t);a+=Sj(r,n.greedy,o)}else{let n=await i(e,t);a+=xj(n)}return kj(e,t,a,n.side,n.greedy)}async function qj(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+=Sj(t.pattern,!0,o);else if(t.type===`Literal`)a+=Sj(t.value,!0,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=xj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=xj(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);a+=Sj(n,!0,o)}else{let n=await i(e,t);a+=xj(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 jj(e,t,U(a,c),s,n.all)}catch(e){if(e instanceof A)throw e;return t}}function Jj(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=ij(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)&&aj(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=sD(e,t,0)||``;return String([...n].length)}return String([...n].length)}async function Yj(e,t,n,r){e.coverage?.hit(`bash:expansion:substring`);let i=await aP(e,r.offset.expression),a=r.length?await aP(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 Er(1,``,`bash: \${${t}[@]: 0: 3}: bad substitution
935
935
  `);let n=ij(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 Dr(`${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 Xj(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+=Sj(t.pattern,!0,a);else if(t.type===`Literal`)o+=Sj(t.value,!0,a);else if(t.type===`SingleQuoted`||t.type===`Escaped`)o+=xj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);o+=xj(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);o+=Sj(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 Zj(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 ij(e,a[1]).map(([,e])=>Fj(e)).join(` `);if(a&&i.operator===`a`)return Vj(e,a[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&i.operator===`a`)return Vj(e,o[1]);switch(i.operator){case`Q`:return r?``:Fj(n);case`P`:return Pj(e,n);case`a`:return Vj(e,t);case`A`:return r?``:`${t}=${Fj(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`
936
936
  `;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?``:Fj(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 Qj(e,t,n,r,i,a,o=!1){if(e.coverage?.hit(`bash:expansion:indirection`),qA(e,t))return tj(e,t)||``;let s=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(i.innerOp?.type===`UseAlternative`)return``;throw new Or(`\${!${t}}`)}let c=n;if(s&&(c===``||c.includes(` `)))throw new Or(`\${!${t}}`);let l=c.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(l&&l[1].includes(`~`))throw new Or(`\${!${t}}`);return i.innerOp?a(e,{type:`ParameterExpansion`,parameter:c,operation:i.innerOp},o):await oj(e,c)}function $j(e,t){e.coverage?.hit(`bash:expansion:array_keys`);let n=ij(e,t.array).map(([e])=>String(e));return t.star?n.join(RA(e.state.env)):n.join(` `)}function eM(e,t){e.coverage?.hit(`bash:expansion:var_name_prefix`);let n=Aj(e,t.prefix);return t.star?n.join(RA(e.state.env)):n.join(` `)}function tM(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=ij(e,t);if(i.length===0)return{isEmpty:!0,effectiveValue:``};if(n===`*`){let t=RA(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 nM(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 rM(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 iM(e,t){let n=new Dk,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=e.state.umask,s=nD(e.state.arrays),c=e.state.cwd,l=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let t=await e.executeScript(r),n=t.exitCode;return e.state.env=a,e.state.umask=o,e.state.arrays=s,e.state.cwd=c,e.state.suppressVerbose=l,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.umask=o,e.state.arrays=s,e.state.cwd=c,e.state.bashPid=i,e.state.suppressVerbose=l,t instanceof A)throw t;return t instanceof Er?(e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stdout?.replace(/\n+$/,``)??``):``}}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+=yj(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=oM(e,t.slice(r+1,i));n+=yj(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 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){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 sM(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+=yj(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 cM(e,t.slice(r+1,i));n+=yj(a),r=i+1;continue}}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=rM(t,r+2);if(i!==-1){let a=await iM(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 iM(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 cM(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=rM(t,r+2);if(i!==-1){let a=await iM(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 iM(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 lM(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 uM(e,t){return t.split(`:`).map(t=>lM(e,t)).join(`:`)}j(),j();function dM(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)}gc();async function fM(e,t,n,r){let i=``;for(let a of t.parts)if(a.type===`Glob`)i+=Sj(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)i+=Sj(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)i+=xj(a.value);else if(a.type===`DoubleQuoted`){let t=await n(e,a.parts);i+=xj(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);i+=Sj(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);i+=xj(t)}return i}async function pM(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=ij(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 fM(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=RA(e.state.env);return{values:[h.join(t)],quoted:!0}}return{values:h,quoted:!0}}async function mM(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=ij(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+=Sj(t.pattern,l.greedy,p);else if(t.type===`Literal`)f+=Sj(t.value,l.greedy,p);else if(t.type===`SingleQuoted`||t.type===`Escaped`)f+=xj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);f+=xj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);f+=Sj(n,l.greedy,p)}else{let n=await r(e,t);f+=xj(n)}let m=[];for(let t of d)m.push(kj(e,t,f,l.side,l.greedy));if(c){let t=RA(e.state.env);return{values:[m.join(t)],quoted:!0}}return{values:m,quoted:!0}}gc();async function hM(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=ij(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=RA(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 sj(e,t),a=await oj(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=ij(e,n);if(t.length>0){let n=t.map(([,e])=>e);if(r||s){let t=RA(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 gM(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=ij(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+=Sj(o.pattern,t.greedy,a);else if(o.type===`Literal`)n+=Sj(o.value,t.greedy,a);else if(o.type===`SingleQuoted`||o.type===`Escaped`)n+=xj(o.value);else if(o.type===`DoubleQuoted`){let t=await i(e,o.parts);n+=xj(t)}else if(o.type===`ParameterExpansion`){let i=await r(e,o);n+=Sj(i,t.greedy,a)}else{let t=await r(e,o);n+=xj(t)}p=p.map(r=>kj(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+=Sj(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)n+=Sj(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)n+=xj(a.value);else if(a.type===`DoubleQuoted`){let t=await i(e,a.parts);n+=xj(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);n+=Sj(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);n+=xj(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=RA(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 _M(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=ij(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=RA(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}}zr(),j();async function vM(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 Er(1,``,`bash: \${${o}[@]: 0: 3}: bad substitution
937
- `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=ij(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 Dr(`${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=RA(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,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?.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=ij(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=Pj(e,t);break;case`Q`:n=Fj(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=Vj(e,a),u=[],d=0;for(let[,t]of c){let n;switch(s.operator){case`a`:n=l;break;case`P`:n=Pj(e,t);break;case`Q`:n=Fj(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=RA(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 bM(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(qA(e,a)){let t=tj(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=ij(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 xM(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)||!qA(e,r))return null;let i=tj(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=ij(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 SM(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 oj(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(RA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=ij(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return CM(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return wM(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=Vj(e,u),n=f.map(()=>t);return d?{values:[n.join(RA(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(RA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(RA(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 CM(e,t,n,r,i){let a=i.offset?await aP(e,i.offset.expression):0,o=i.length?await aP(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 Dr(`${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(RA(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function wM(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(RA(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(RA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(RA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function TM(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 oj(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await sj(e,n.parameter),l=await oj(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=ij(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(RA(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 EM(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 oj(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await oj(e,n.parameter),l=await sj(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=ij(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(RA(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}}zr(),gc(),j();function DM(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 OM(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 kM(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 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===`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=RA(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 jM(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=DM(e),l=``;for(let t=0;t<a;t++)l=OM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=OM(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+=Sj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)d+=Sj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=xj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=xj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Sj(r,!0,e.state.shoptOptions.extglob)}else{let r=await n(e,t);d+=xj(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`);kM(m,t.replace(n,f),h,e)}}catch(t){if(t instanceof A)throw t;for(let t of c)kM(m,t,h,e)}if(o){let t=RA(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 MM(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=DM(e),l=``;for(let t=0;t<a;t++)l=OM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=OM(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+=Sj(t.pattern,s.greedy,f);else if(t.type===`Literal`)d+=Sj(t.value,s.greedy,f);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=xj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=xj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Sj(r,s.greedy,f)}else{let r=await n(e,t);d+=xj(r)}let p=[],m={value:0};for(let t of c)kM(p,kj(e,t,d,s.side,s.greedy),m,e);if(o){let t=RA(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 NM(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=RA(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(),gc(),j();function PM(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 FM(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 IM(e){return new EA(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 LM(e,t){if(e.state.options.noglob)return t;let n=IM(e),r=[];for(let i of t)if(_j(i,e.state.shoptOptions.extglob)){let t=await n.expand(i);if(t.length>0)dM(r,t,e.limits.maxArrayElements,`unquoted glob expansion`);else{if(n.hasFailglob())throw new kr(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function RM(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=ij(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+=Sj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=Sj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=xj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=xj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Sj(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=xj(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)PM(e,p,jj(e,n,t,d,s.all),m)}catch(t){if(t instanceof A)throw t;for(let t of l)PM(e,p,t,m)}let h=PA(e.state.env),g=FA(e.state.env);if(o){let t=FM(e,p,RA(e.state.env),m.value);return g?{values:t?[t]:[],quoted:!1}:{values:WA(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===``)PM(e,_,``,v);else for(let n of WA(t,h,e.limits.maxArrayElements))PM(e,_,n,v);return{values:_,quoted:!1}}async function zM(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=ij(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+=Sj(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=Sj(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=xj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=xj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Sj(n,s.greedy,d)}else{let n=await r(e,t);u+=xj(n)}let f=[],p={value:0};for(let t of l)PM(e,f,kj(e,t,u,s.side,s.greedy),p);let m=PA(e.state.env),h=FA(e.state.env);if(o){let t=FM(e,f,RA(e.state.env),p.value);return h?{values:t?[t]:[],quoted:!1}:{values:WA(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===``)PM(e,g,``,_);else for(let n of WA(t,m,e.limits.maxArrayElements))PM(e,g,n,_);return{values:g,quoted:!1}}async function BM(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+=Sj(t.pattern,o.greedy,u);else if(t.type===`Literal`)l+=Sj(t.value,o.greedy,u);else if(t.type===`SingleQuoted`||t.type===`Escaped`)l+=xj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);l+=xj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);l+=Sj(n,o.greedy,u)}else{let n=await r(e,t);l+=xj(n)}let d=[],f={value:0};for(let t of c)PM(e,d,kj(e,t,l,o.side,o.greedy),f);let p=PA(e.state.env),m=FA(e.state.env);if(a){let t=FM(e,d,RA(e.state.env),f.value);return m?{values:t?[t]:[],quoted:!1}:{values:WA(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===``)PM(e,h,``,g);else for(let n of WA(t,p,e.limits.maxArrayElements))PM(e,h,n,g);return{values:h,quoted:!1}}async function VM(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=PA(e.state.env),g=FA(e.state.env);if(f.length===0){let t=p+m;return t?g?{values:[t],quoted:!1}:{values:WA(t,h,e.limits.maxArrayElements),quoted:!1}:{values:[],quoted:!1}}let _;if(a){let t=RA(e.state.env),n=p+f.join(t)+m;_=g?n?[n]:[]:WA(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=WA(n,h,e.limits.maxArrayElements);dM(_,t,e.limits.maxArrayElements,`unquoted expansion`)}}}return{values:await LM(e,_),quoted:!1}}async function HM(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=PA(e.state.env),o=FA(e.state.env),s=IA(e.state.env),c;if(n){if(o)c=i.filter(e=>e!==``);else{let t=RA(e.state.env);c=WA(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=WA(t,a,e.limits.maxArrayElements);dM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{c=[];for(let t of i)if(t===``)c.push(``);else{let n=WA(t,a,e.limits.maxArrayElements);dM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await LM(e,c),quoted:!1}}async function UM(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=ij(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=PA(e.state.env),c=FA(e.state.env),l=IA(e.state.env),u;if(i){if(c)u=o.filter(e=>e!==``);else{let t=RA(e.state.env);u=WA(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=WA(t,s,e.limits.maxArrayElements);dM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{u=[];for(let t of o)if(t===``)u.push(``);else{let n=WA(t,s,e.limits.maxArrayElements);dM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await LM(e,u),quoted:!1}}function WM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=Aj(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=PA(e.state.env),a=FA(e.state.env),o;if(n.star){if(a)o=r;else{let t=RA(e.state.env);o=WA(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=WA(t,i,e.limits.maxArrayElements);dM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}function GM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=ij(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=PA(e.state.env),a=FA(e.state.env),o;if(n.star){if(a)o=r;else{let t=RA(e.state.env);o=WA(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=WA(t,i,e.limits.maxArrayElements);dM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}async function KM(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=PA(e.state.env),l=FA(e.state.env),u=IA(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=WA(n,c,e.limits.maxArrayElements);dM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}}else{d=[];for(let n of t)if(n===``)d.push(``);else{let t=WA(n,c,e.limits.maxArrayElements);dM(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 LM(e,d),quoted:!1}}async function qM(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}=AA(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return JM(e,d,i);let f=await YM(e,r,s,l,u,n);if(f!==null)return f;let p=await ZM(e,r,n);if(p!==null)return p;let m=await QM(e,r,n);if(m!==null)return m;let h=await tN(e,r,n.expandPart);if(h!==null)return nN(e,h);if((a||o||c)&&!FA(e.state.env)){let t=PA(e.state.env),i=n.buildIfsCharClassPattern(t);return nN(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return iN(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function JM(e,t,n){let r=[];for(let i of t)!n&&i===``||(!n&&!e.state.options.noglob&&_j(i,e.state.shoptOptions.extglob)?dM(r,await rN(e,i),e.limits.maxArrayElements,`brace/glob expansion`):r.push(i));return{values:r,quoted:!1}}async function YM(e,t,n,r,i,a){if(n){let n=bM(e,t);if(n!==null)return n}{let n=xM(e,t);if(n!==null)return n}{let n=await hM(e,t);if(n!==null)return n}{let r=await gM(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await _M(e,t,n,a.expandPart);if(r!==null)return r}{let n=await vM(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=yM(e,t);if(n!==null)return n}{let n=await pM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await mM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=XM(e,t);if(n!==null)return n}{let n=await SM(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await TM(e,t);if(n!==null)return n}{let n=await EM(e,t);if(n!==null)return n}return null}function XM(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=Aj(e,t.prefix);return t.star?{values:[r.join(RA(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=ij(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(RA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function ZM(e,t,n){{let r=await AM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await jM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await MM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await NM(e,t,n.expandPart);if(r!==null)return r}return null}async function QM(e,t,n){{let r=await RM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await zM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await BM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await VM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await HM(e,t);if(n!==null)return n}{let n=await UM(e,t);if(n!==null)return n}{let n=WM(e,t);if(n!==null)return n}{let n=GM(e,t);if(n!==null)return n}{let r=await KM(e,t,n.expandPart);if(r!==null)return r}return null}function $M(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 eN(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=ij(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=RA(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 tN(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if($M(e)){r=!0;break}if(!r)return null;let i=PA(e.state.env),a=FA(e.state.env),o=[];for(let r of t){let t=$M(r);if(t&&r.type===`DoubleQuoted`){let i=await eN(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=WA(t,i,e.limits.maxArrayElements);o.push(n)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=WA(t,i,e.limits.maxArrayElements);o.push(n)}}}let s=[];for(let t of o)if(t.length!==0){if(s.length===0)dM(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 nN(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)_j(r,e.state.shoptOptions.extglob)?dM(n,await rN(e,r),e.limits.maxArrayElements,`glob expansion`):n.push(r);return{values:n,quoted:!1}}async function rN(e,t){let n=new EA(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 kr(t);return n.hasNullglob()?[]:[t]}async function iN(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(_j(n,e.state.shoptOptions.extglob)){let t=await rN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=vj(r);return FA(e.state.env)?{values:[i],quoted:!1}:{values:WA(i,PA(e.state.env),e.limits.maxArrayElements),quoted:!1}}if(!i&&!e.state.options.noglob&&_j(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(_j(n,e.state.shoptOptions.extglob)){let t=await rN(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=vj(r);return FA(e.state.env)?{values:[t],quoted:!1}:{values:WA(t,PA(e.state.env),e.limits.maxArrayElements),quoted:!1}}return{values:[r],quoted:i}}j();function aN(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 oN(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 sj(e,t.parameter),a=await oj(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 sN(e){return e.type===`SingleQuoted`||e.type===`DoubleQuoted`&&e.parts.every(e=>e.type===`Literal`)}async function cN(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await oN(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>sN(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function lN(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?DA(e.pattern):!(e.type!==`ParameterExpansion`&&e.type!==`CommandSubstitution`&&e.type!==`ArithmeticExpansion`||e.type===`ParameterExpansion`&&kA(e))}async function uN(e,t,n,r,i){if(t.length===1&&t[0].type===`ParameterExpansion`){let n=await oN(e,t[0]),r=n?.length===1?n[0]:null,i=r?.type===`DoubleQuoted`&&r.parts.length===1?r.parts[0]:null;if(i?.type===`ParameterExpansion`&&i.parameter===`@`&&!i.operation){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 n}}if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await oN(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 fN(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=lN(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await cN(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!==``&&aN(e,s,c),aN(e,s,``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&aN(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 fN(e,t.mixedDefaultParts,n,r,i);if(a.length!==0){if(a.length===1)c+=a[0],l=!0;else{c+=a[0],aN(e,s,c),l=!0;for(let t=1;t<a.length-1;t++)aN(e,s,a[t]);c=a[a.length-1]}}u=!1,d=!1}else{let{words:r,hadLeadingDelimiter:i,hadTrailingDelimiter:a}=UA(t.value,n,e.limits.maxArrayElements);if(d&&i&&c===``&&(aN(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],aN(e,s,c),l=!0;for(let t=1;t<r.length-1;t++)aN(e,s,r[t]);c=r[r.length-1],u=a}d=!1}return c===``?s.length===0&&l&&aN(e,s,``):aN(e,s,c),s}function dN(e,t){return e.length>0&&t.includes(e[0])}async function fN(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!==``&&aN(e,o,s),s=t.value,l=!1):s+=t.value;else{dN(t.value,n)&&s!==``&&(aN(e,o,s),s=``,c=!0);let{words:r,hadTrailingDelimiter:i}=UA(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],aN(e,o,s),c=!0;for(let t=1;t<r.length-1;t++)aN(e,o,r[t]);s=r[r.length-1],l=i}}return s===``?o.length===0&&c&&aN(e,o,``):aN(e,o,s),o}function pN(e){switch(e.type){case`Literal`:return e.value;case`SingleQuoted`:return e.value;case`Escaped`:return e.value;default:return null}}function mN(e){switch(e.type){case`SingleQuoted`:case`Escaped`:case`DoubleQuoted`:return!0;case`Literal`:return e.value===``;default:return!1}}k(),k(),$i();var hN=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new KE,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){Ji(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 dr(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&&qi(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&&qi(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 Xi(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=Zi(e,i),a=Zi(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 gN=`/dev/fd`,_N=63,vN=_N-10+1,yN=class extends KE{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} '${gN}${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 bN(e){let t=new yN(t=>CN(e).some(e=>e.path===`${gN}${t}`));e.fs=new hN({base:e.fs,mounts:[{mountPoint:gN,filesystem:t}]}),e.state.processSubstitutionFsMounted=!0}async function xN(e,t,n){try{await e.fs.writeFile(t,n,`binary`);return}catch(t){if(e.state.processSubstitutionFsMounted)throw t;bN(e)}await e.fs.writeFile(t,n,`binary`)}async function SN(e,t){try{await e.fs.rm(t,{force:!0})}catch{}}function CN(e){let t=e.state.processSubstitutions;if(t)return t;let n=[];return e.state.processSubstitutions=n,n}async function wN(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=e.state.umask,c=nD(e.state.arrays),l=e.state.cwd,u=e.state.bashPid,d=e.state.suppressVerbose,f=e.state.groupStdin,p=e.state.lastExitCode,m=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 h;try{h=await e.executeScript(t)}catch(e){if(e instanceof A)throw e;if(e instanceof Er)return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode};throw e}finally{e.substitutionDepth=a,e.state.env=o,e.state.umask=s,e.state.arrays=c,e.state.cwd=l,e.state.bashPid=u,e.state.suppressVerbose=d,e.state.groupStdin=f,e.state.lastExitCode=p,m===void 0?e.state.env.delete(`?`):e.state.env.set(`?`,m)}return h}async function TN(e,t){let n=CN(e);if(n.length>=vN)throw new A(`Process substitution limit exceeded (${vN} concurrent)`,`file_descriptors`);let r=``;if(t.direction===`input`){let n=await wN(e,t.body,void 0);if(n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),r=pr(n),r.length>e.limits.maxStringLength)throw new A(`process substitution: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)}let i=_N-n.length,a=`${gN}/${i}`;n.push({fd:i,path:a,direction:t.direction,body:t.body});try{await xN(e,a,r)}catch(e){throw n.pop(),e}return a}function EN(e){return e.state.processSubstitutions?.length??0}var DN={stdout:``,stderr:``};async function ON(e,t){let n=e.state.processSubstitutions;if(!n||n.length<=t)return DN;let r=``,i=``;for(;n.length>t;){let t=n[n.length-1],a=``;if(t.direction===`output`)try{a=await dr(e.fs,t.path)}catch{}if(await SN(e,t.path),n.pop(),t.direction===`output`){let n=await wN(e,t.body,a);r+=pr(n),i+=n.stderr}}return{stdout:r,stderr:i}}function kN(e,t,n){if(e.length>t)throw new A(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function AN(e,t,n=!1){let r=[];for(let i of t)r.push(await JN(e,i,n));return r.join(``)}function jN(e){return mN(e)}function MN(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!jN(t))return!1;return!0}function NN(e,t,n=!1){let r=pN(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 aM(e,t.pattern);default:return null}}async function PN(e,t){return qN(e,t)}async function FN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(bj(r.value));else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await AN(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await JN(e,r);n.push(bj(t))}else n.push(await JN(e,r));return n.join(``)}async function IN(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(yj(r.value));else if(r.type===`DoubleQuoted`){let t=await AN(e,r.parts);n.push(yj(t))}else n.push(await JN(e,r));return n.join(``)}async function LN(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(yj(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 AN(e,r.parts);n.push(yj(t))}else r.type===`Glob`?nM(r.pattern)?n.push(await sM(e,r.pattern)):n.push(aM(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await JN(e,r));return n.join(``)}function RN(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&RN(t.parts))return!0;return!1}var zN=1e5;async function BN(e,t,n={count:0}){let r=()=>{n.count++,e.executionScope.consumeLimited(`brace_operations`,1,Math.min(zN,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=hj(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 BN(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 JN(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>zN)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 VN(e,t){let n=t.parts;if(!RN(n))return[await PN(e,t)];let r=await BN(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await JN(e,r));i.push(lM(e,n.join(``)))}return i}function HN(){return{expandWordAsync:qN,expandWordForGlobbing:LN,expandWordWithBracesAsync:VN,expandWordPartsAsync:AN,expandPart:JN,expandParameterAsync:YN,hasBraceExpansion:RN,evaluateArithmetic:aP,buildIfsCharClassPattern:LA,smartWordSplit:uN}}async function UN(e,t){return qM(e,t,HN())}function WN(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function GN(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 KN(e,t){if(GN(e,t))return{error:`bash: $@: ambiguous redirect
937
+ `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=ij(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 Dr(`${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=RA(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,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?.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=ij(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=Pj(e,t);break;case`Q`:n=Fj(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=Vj(e,a),u=[],d=0;for(let[,t]of c){let n;switch(s.operator){case`a`:n=l;break;case`P`:n=Pj(e,t);break;case`Q`:n=Fj(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=RA(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 bM(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(qA(e,a)){let t=tj(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=ij(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 xM(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)||!qA(e,r))return null;let i=tj(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=ij(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 SM(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 oj(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(RA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=ij(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return CM(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return wM(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=Vj(e,u),n=f.map(()=>t);return d?{values:[n.join(RA(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(RA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(RA(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 CM(e,t,n,r,i){let a=i.offset?await aP(e,i.offset.expression):0,o=i.length?await aP(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 Dr(`${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(RA(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function wM(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(RA(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(RA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(RA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function TM(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 oj(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await sj(e,n.parameter),l=await oj(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=ij(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(RA(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 EM(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 oj(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await oj(e,n.parameter),l=await sj(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=ij(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(RA(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}}zr(),gc(),j();function DM(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 OM(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 kM(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 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===`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=RA(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 jM(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=DM(e),l=``;for(let t=0;t<a;t++)l=OM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=OM(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+=Sj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)d+=Sj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=xj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=xj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Sj(r,!0,e.state.shoptOptions.extglob)}else{let r=await n(e,t);d+=xj(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`);kM(m,t.replace(n,f),h,e)}}catch(t){if(t instanceof A)throw t;for(let t of c)kM(m,t,h,e)}if(o){let t=RA(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 MM(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=DM(e),l=``;for(let t=0;t<a;t++)l=OM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=OM(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+=Sj(t.pattern,s.greedy,f);else if(t.type===`Literal`)d+=Sj(t.value,s.greedy,f);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=xj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=xj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Sj(r,s.greedy,f)}else{let r=await n(e,t);d+=xj(r)}let p=[],m={value:0};for(let t of c)kM(p,kj(e,t,d,s.side,s.greedy),m,e);if(o){let t=RA(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 NM(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=RA(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(),gc(),j();function PM(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 FM(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 IM(e){return new EA(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 LM(e,t){if(e.state.options.noglob)return t;let n=IM(e),r=[];for(let i of t)if(_j(i,e.state.shoptOptions.extglob)){let t=await n.expand(i);if(t.length>0)dM(r,t,e.limits.maxArrayElements,`unquoted glob expansion`);else{if(n.hasFailglob())throw new kr(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function RM(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=ij(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+=Sj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=Sj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=xj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=xj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Sj(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=xj(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)PM(e,p,jj(e,n,t,d,s.all),m)}catch(t){if(t instanceof A)throw t;for(let t of l)PM(e,p,t,m)}let h=PA(e.state.env),g=FA(e.state.env);if(o){let t=FM(e,p,RA(e.state.env),m.value);return g?{values:t?[t]:[],quoted:!1}:{values:WA(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===``)PM(e,_,``,v);else for(let n of WA(t,h,e.limits.maxArrayElements))PM(e,_,n,v);return{values:_,quoted:!1}}async function zM(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=ij(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+=Sj(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=Sj(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=xj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=xj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Sj(n,s.greedy,d)}else{let n=await r(e,t);u+=xj(n)}let f=[],p={value:0};for(let t of l)PM(e,f,kj(e,t,u,s.side,s.greedy),p);let m=PA(e.state.env),h=FA(e.state.env);if(o){let t=FM(e,f,RA(e.state.env),p.value);return h?{values:t?[t]:[],quoted:!1}:{values:WA(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===``)PM(e,g,``,_);else for(let n of WA(t,m,e.limits.maxArrayElements))PM(e,g,n,_);return{values:g,quoted:!1}}async function BM(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+=Sj(t.pattern,o.greedy,u);else if(t.type===`Literal`)l+=Sj(t.value,o.greedy,u);else if(t.type===`SingleQuoted`||t.type===`Escaped`)l+=xj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);l+=xj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);l+=Sj(n,o.greedy,u)}else{let n=await r(e,t);l+=xj(n)}let d=[],f={value:0};for(let t of c)PM(e,d,kj(e,t,l,o.side,o.greedy),f);let p=PA(e.state.env),m=FA(e.state.env);if(a){let t=FM(e,d,RA(e.state.env),f.value);return m?{values:t?[t]:[],quoted:!1}:{values:WA(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===``)PM(e,h,``,g);else for(let n of WA(t,p,e.limits.maxArrayElements))PM(e,h,n,g);return{values:h,quoted:!1}}async function VM(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=PA(e.state.env),g=FA(e.state.env);if(f.length===0){let t=p+m;return t?g?{values:[t],quoted:!1}:{values:WA(t,h,e.limits.maxArrayElements),quoted:!1}:{values:[],quoted:!1}}let _;if(a){let t=RA(e.state.env),n=p+f.join(t)+m;_=g?n?[n]:[]:WA(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=WA(n,h,e.limits.maxArrayElements);dM(_,t,e.limits.maxArrayElements,`unquoted expansion`)}}}return{values:await LM(e,_),quoted:!1}}async function HM(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=PA(e.state.env),o=FA(e.state.env),s=IA(e.state.env),c;if(n){if(o)c=i.filter(e=>e!==``);else{let t=RA(e.state.env);c=WA(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=WA(t,a,e.limits.maxArrayElements);dM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{c=[];for(let t of i)if(t===``)c.push(``);else{let n=WA(t,a,e.limits.maxArrayElements);dM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await LM(e,c),quoted:!1}}async function UM(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=ij(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=PA(e.state.env),c=FA(e.state.env),l=IA(e.state.env),u;if(i){if(c)u=o.filter(e=>e!==``);else{let t=RA(e.state.env);u=WA(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=WA(t,s,e.limits.maxArrayElements);dM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{u=[];for(let t of o)if(t===``)u.push(``);else{let n=WA(t,s,e.limits.maxArrayElements);dM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await LM(e,u),quoted:!1}}function WM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=Aj(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=PA(e.state.env),a=FA(e.state.env),o;if(n.star){if(a)o=r;else{let t=RA(e.state.env);o=WA(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=WA(t,i,e.limits.maxArrayElements);dM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}function GM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=ij(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=PA(e.state.env),a=FA(e.state.env),o;if(n.star){if(a)o=r;else{let t=RA(e.state.env);o=WA(r.join(t),i,e.limits.maxArrayElements)}}else if(a)o=r;else{o=[];for(let t of r){let n=WA(t,i,e.limits.maxArrayElements);dM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}async function KM(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=PA(e.state.env),l=FA(e.state.env),u=IA(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=WA(n,c,e.limits.maxArrayElements);dM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}}else{d=[];for(let n of t)if(n===``)d.push(``);else{let t=WA(n,c,e.limits.maxArrayElements);dM(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 LM(e,d),quoted:!1}}async function qM(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}=AA(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return JM(e,d,i);let f=await YM(e,r,s,l,u,n);if(f!==null)return f;let p=await ZM(e,r,n);if(p!==null)return p;let m=await QM(e,r,n);if(m!==null)return m;let h=await tN(e,r,n.expandPart);if(h!==null)return nN(e,h);if((a||o||c)&&!FA(e.state.env)){let t=PA(e.state.env),i=n.buildIfsCharClassPattern(t);return nN(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return iN(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function JM(e,t,n){let r=[];for(let i of t)!n&&i===``||(!n&&!e.state.options.noglob&&_j(i,e.state.shoptOptions.extglob)?dM(r,await rN(e,i),e.limits.maxArrayElements,`brace/glob expansion`):r.push(i));return{values:r,quoted:!1}}async function YM(e,t,n,r,i,a){if(n){let n=bM(e,t);if(n!==null)return n}{let n=xM(e,t);if(n!==null)return n}{let n=await hM(e,t);if(n!==null)return n}{let r=await gM(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await _M(e,t,n,a.expandPart);if(r!==null)return r}{let n=await vM(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=yM(e,t);if(n!==null)return n}{let n=await pM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await mM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=XM(e,t);if(n!==null)return n}{let n=await SM(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await TM(e,t);if(n!==null)return n}{let n=await EM(e,t);if(n!==null)return n}return null}function XM(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=Aj(e,t.prefix);return t.star?{values:[r.join(RA(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=ij(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(RA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function ZM(e,t,n){{let r=await AM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await jM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await MM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await NM(e,t,n.expandPart);if(r!==null)return r}return null}async function QM(e,t,n){{let r=await RM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await zM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await BM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await VM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await HM(e,t);if(n!==null)return n}{let n=await UM(e,t);if(n!==null)return n}{let n=WM(e,t);if(n!==null)return n}{let n=GM(e,t);if(n!==null)return n}{let r=await KM(e,t,n.expandPart);if(r!==null)return r}return null}function $M(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 eN(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=ij(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=RA(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 tN(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if($M(e)){r=!0;break}if(!r)return null;let i=PA(e.state.env),a=FA(e.state.env),o=[];for(let r of t){let t=$M(r);if(t&&r.type===`DoubleQuoted`){let i=await eN(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=WA(t,i,e.limits.maxArrayElements);o.push(n)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=WA(t,i,e.limits.maxArrayElements);o.push(n)}}}let s=[];for(let t of o)if(t.length!==0){if(s.length===0)dM(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 nN(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)_j(r,e.state.shoptOptions.extglob)?dM(n,await rN(e,r),e.limits.maxArrayElements,`glob expansion`):n.push(r);return{values:n,quoted:!1}}async function rN(e,t){let n=new EA(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 kr(t);return n.hasNullglob()?[]:[t]}async function iN(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(_j(n,e.state.shoptOptions.extglob)){let t=await rN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=vj(r);return FA(e.state.env)?{values:[i],quoted:!1}:{values:WA(i,PA(e.state.env),e.limits.maxArrayElements),quoted:!1}}if(!i&&!e.state.options.noglob&&_j(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(_j(n,e.state.shoptOptions.extglob)){let t=await rN(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=vj(r);return FA(e.state.env)?{values:[t],quoted:!1}:{values:WA(t,PA(e.state.env),e.limits.maxArrayElements),quoted:!1}}return{values:[r],quoted:i}}j();function aN(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 oN(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 sj(e,t.parameter),a=await oj(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 sN(e){return e.type===`SingleQuoted`||e.type===`DoubleQuoted`&&e.parts.every(e=>e.type===`Literal`)}async function cN(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await oN(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>sN(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function lN(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?DA(e.pattern):!(e.type!==`ParameterExpansion`&&e.type!==`CommandSubstitution`&&e.type!==`ArithmeticExpansion`||e.type===`ParameterExpansion`&&kA(e))}async function uN(e,t,n,r,i){if(t.length===1&&t[0].type===`ParameterExpansion`){let n=await oN(e,t[0]),r=n?.length===1?n[0]:null,i=r?.type===`DoubleQuoted`&&r.parts.length===1?r.parts[0]:null;if(i?.type===`ParameterExpansion`&&i.parameter===`@`&&!i.operation){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 n}}if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await oN(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 fN(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=lN(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await cN(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!==``&&aN(e,s,c),aN(e,s,``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&aN(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 fN(e,t.mixedDefaultParts,n,r,i);if(a.length!==0){if(a.length===1)c+=a[0],l=!0;else{c+=a[0],aN(e,s,c),l=!0;for(let t=1;t<a.length-1;t++)aN(e,s,a[t]);c=a[a.length-1]}}u=!1,d=!1}else{u&&c!==``&&(aN(e,s,c),c=``,u=!1,l=!0);let{words:r,hadLeadingDelimiter:i,hadTrailingDelimiter:a}=UA(t.value,n,e.limits.maxArrayElements),o=i&&c!==``;if(o&&(aN(e,s,c),c=``,l=!0,r[0]===``&&(r=r.slice(1))),d&&i&&!o&&c===``&&(aN(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],aN(e,s,c),l=!0;for(let t=1;t<r.length-1;t++)aN(e,s,r[t]);c=r[r.length-1],u=a}d=!1}return c===``?s.length===0&&l&&aN(e,s,``):aN(e,s,c),s}function dN(e,t){return e.length>0&&t.includes(e[0])}async function fN(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!==``&&aN(e,o,s),s=t.value,l=!1):s+=t.value;else{dN(t.value,n)&&s!==``&&(aN(e,o,s),s=``,c=!0);let{words:r,hadTrailingDelimiter:i}=UA(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],aN(e,o,s),c=!0;for(let t=1;t<r.length-1;t++)aN(e,o,r[t]);s=r[r.length-1],l=i}}return s===``?o.length===0&&c&&aN(e,o,``):aN(e,o,s),o}function pN(e){switch(e.type){case`Literal`:return e.value;case`SingleQuoted`:return e.value;case`Escaped`:return e.value;default:return null}}function mN(e){switch(e.type){case`SingleQuoted`:case`Escaped`:case`DoubleQuoted`:return!0;case`Literal`:return e.value===``;default:return!1}}k(),k(),$i();var hN=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new KE,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){Ji(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 dr(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&&qi(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&&qi(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 Xi(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=Zi(e,i),a=Zi(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 gN=`/dev/fd`,_N=63,vN=_N-10+1,yN=class extends KE{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} '${gN}${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 bN(e){let t=new yN(t=>CN(e).some(e=>e.path===`${gN}${t}`));e.fs=new hN({base:e.fs,mounts:[{mountPoint:gN,filesystem:t}]}),e.state.processSubstitutionFsMounted=!0}async function xN(e,t,n){try{await e.fs.writeFile(t,n,`binary`);return}catch(t){if(e.state.processSubstitutionFsMounted)throw t;bN(e)}await e.fs.writeFile(t,n,`binary`)}async function SN(e,t){try{await e.fs.rm(t,{force:!0})}catch{}}function CN(e){let t=e.state.processSubstitutions;if(t)return t;let n=[];return e.state.processSubstitutions=n,n}async function wN(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=e.state.umask,c=nD(e.state.arrays),l=e.state.cwd,u=e.state.bashPid,d=e.state.suppressVerbose,f=e.state.groupStdin,p=e.state.lastExitCode,m=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 h;try{h=await e.executeScript(t)}catch(e){if(e instanceof A)throw e;if(e instanceof Er)return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode};throw e}finally{e.substitutionDepth=a,e.state.env=o,e.state.umask=s,e.state.arrays=c,e.state.cwd=l,e.state.bashPid=u,e.state.suppressVerbose=d,e.state.groupStdin=f,e.state.lastExitCode=p,m===void 0?e.state.env.delete(`?`):e.state.env.set(`?`,m)}return h}async function TN(e,t){let n=CN(e);if(n.length>=vN)throw new A(`Process substitution limit exceeded (${vN} concurrent)`,`file_descriptors`);let r=``;if(t.direction===`input`){let n=await wN(e,t.body,void 0);if(n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),r=pr(n),r.length>e.limits.maxStringLength)throw new A(`process substitution: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)}let i=_N-n.length,a=`${gN}/${i}`;n.push({fd:i,path:a,direction:t.direction,body:t.body});try{await xN(e,a,r)}catch(e){throw n.pop(),e}return a}function EN(e){return e.state.processSubstitutions?.length??0}var DN={stdout:``,stderr:``};async function ON(e,t){let n=e.state.processSubstitutions;if(!n||n.length<=t)return DN;let r=``,i=``;for(;n.length>t;){let t=n[n.length-1],a=``;if(t.direction===`output`)try{a=await dr(e.fs,t.path)}catch{}if(await SN(e,t.path),n.pop(),t.direction===`output`){let n=await wN(e,t.body,a);r+=pr(n),i+=n.stderr}}return{stdout:r,stderr:i}}function kN(e,t,n){if(e.length>t)throw new A(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function AN(e,t,n=!1){let r=[];for(let i of t)r.push(await JN(e,i,n));return r.join(``)}function jN(e){return mN(e)}function MN(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!jN(t))return!1;return!0}function NN(e,t,n=!1){let r=pN(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 aM(e,t.pattern);default:return null}}async function PN(e,t){return qN(e,t)}async function FN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(bj(r.value));else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await AN(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await JN(e,r);n.push(bj(t))}else n.push(await JN(e,r));return n.join(``)}async function IN(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(yj(r.value));else if(r.type===`DoubleQuoted`){let t=await AN(e,r.parts);n.push(yj(t))}else n.push(await JN(e,r));return n.join(``)}async function LN(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(yj(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 AN(e,r.parts);n.push(yj(t))}else r.type===`Glob`?nM(r.pattern)?n.push(await sM(e,r.pattern)):n.push(aM(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await JN(e,r));return n.join(``)}function RN(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&RN(t.parts))return!0;return!1}var zN=1e5;async function BN(e,t,n={count:0}){let r=()=>{n.count++,e.executionScope.consumeLimited(`brace_operations`,1,Math.min(zN,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=hj(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 BN(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 JN(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>zN)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 VN(e,t){let n=t.parts;if(!RN(n))return[await PN(e,t)];let r=await BN(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await JN(e,r));i.push(lM(e,n.join(``)))}return i}function HN(){return{expandWordAsync:qN,expandWordForGlobbing:LN,expandWordWithBracesAsync:VN,expandWordPartsAsync:AN,expandPart:JN,expandParameterAsync:YN,hasBraceExpansion:RN,evaluateArithmetic:aP,buildIfsCharClassPattern:LA,smartWordSplit:uN}}async function UN(e,t){return qM(e,t,HN())}function WN(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function GN(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 KN(e,t){if(GN(e,t))return{error:`bash: $@: ambiguous redirect
938
938
  `};let n=t.parts,{hasQuoted:r}=AA(n);if(RN(n)&&(await VN(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
939
939
  `};let i=await qN(e,t),{hasParamExpansion:a,hasCommandSub:o}=AA(n);if((a||o)&&!r&&!FA(e.state.env)&&WA(i,PA(e.state.env),e.limits.maxArrayElements).length>1)return{error:`bash: $${WN(n)}: ambiguous redirect
940
940
  `};if(r||e.state.options.noglob||n.some(e=>e.type===`ProcessSubstitution`))return{target:i};let s=await LN(e,t);if(!_j(s,e.state.shoptOptions.extglob))return{target:i};let c=new EA(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}
@@ -1597,7 +1597,7 @@ ${e} ()
1597
1597
  `);throw t||i.poisonAfterAbort(a),a}finally{n(),Qn(c),Qn(u),l&&a?.removeEventListener(`abort`,l)}}async function nz(e,t,n,r,i,a,o,s,c=!1){let{ctx:l,runCommand:u}=e;if(l.coverage&&_F.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t===`export`)return kL(l,n);if(t===`unset`)return pR(l,n);if(t===`exit`)return OL(l,n);if(t===`local`)return zL(l,n);if(t===`set`)return rR(l,n);if(t===`break`)return _P(l,n);if(t===`continue`)return tL(l,n);if(t===`return`)return HL(l,n);if(t===`eval`&&l.state.options.posix)return DL(l,n,i,c);if(t===`shift`)return aR(l,n);if(t===`getopts`)return AL(l,n);if(t===`compgen`)return SI(l,n);if(t===`complete`)return ZI(l,n);if(t===`compopt`)return eL(l,n);if(t===`pushd`)return await wL(l,n);if(t===`popd`)return TL(l,n);if(t===`dirs`)return EL(l,n);if(t===`source`||t===`.`)return oR(l,n);if(t===`read`)return VL(l,n,i,s);if(t===`mapfile`||t===`readarray`)return BL(l,n,i);if(t===`declare`||t===`typeset`)return yL(l,n);if(t===`readonly`)return bL(l,n);if(!a){let e=l.state.functions.get(t);if(e)return gI(l,e,n,i,void 0,c)}if(t===`__just_bash_tee_restore`){if(n.length===0||n.length>l.limits.maxArrayElements)return Q(`bash: invalid internal pipeline status restore
1598
1598
  `,2);let e=[];for(let t of n){if(!/^(?:0|[1-9][0-9]{0,2})$/.test(t))return Q(`bash: invalid internal pipeline status restore
1599
1599
  `,2);let n=Number(t);if(!Number.isSafeInteger(n)||n>255)return Q(`bash: invalid internal pipeline status restore
1600
- `,2);e.push(n)}let t=e[e.length-1]??0,r=[...e].reverse().find(e=>e!==0);return{stdout:``,stderr:``,exitCode:l.state.options.pipefail&&r!==void 0?r:t,internalPipeStatusOverride:e}}if(t===`eval`)return DL(l,n,i,c);if(t===`umask`)return sn(l,n);if(t===`cd`)return await vP(l,n);if(t===`:`||t===`true`)return fP;if(t===`false`)return mP(!1);if(t===`let`)return RL(l,n);if(t===`command`)return rz(e,n,i,c);if(t===`builtin`)return iz(e,n,i,c);if(t===`shopt`)return yR(l,n);if(t===`exec`){if(n.length===0)return fP;let[e,...t]=n;return{...await u(e,t,[],i,!1,!1,-1,c),internalProducerOmitsShellPrefix:!0}}if(t===`wait`)return fP;if(t===`type`)return await KR(l,n,e=>$R(l,e),e=>CR(l,e));if(t===`hash`)return jL(l,n);if(t===`help`)return PL(l,n);if(t===`[`||t===`test`){let e=n;if(t===`[`){if(n[n.length-1]!==`]`)return Q(`[: missing \`]'
1600
+ `,2);e.push(n)}let t=e[e.length-1]??0,r=[...e].reverse().find(e=>e!==0);return{stdout:``,stderr:``,exitCode:l.state.options.pipefail&&r!==void 0?r:t,internalPipeStatusOverride:e}}if(t===`eval`)return DL(l,n,i,c);if(t===`umask`)return sn(l,n);if(t===`cd`)return await vP(l,n);if(t===`:`||t===`true`)return fP;if(t===`false`)return mP(!1);if(t===`let`)return RL(l,n);if(t===`command`)return rz(e,n,i,c);if(t===`builtin`)return iz(e,n,i,c);if(t===`shopt`)return yR(l,n);if(t===`exec`){if(n.length===0)return fP;let[e,...t]=n,r=await u(e,t,[],i,!1,!1,-1,c);throw new Er(r.exitCode,r.stdout,r.stderr)}if(t===`wait`)return fP;if(t===`type`)return await KR(l,n,e=>$R(l,e),e=>CR(l,e));if(t===`hash`)return jL(l,n);if(t===`help`)return PL(l,n);if(t===`[`||t===`test`){let e=n;if(t===`[`){if(n[n.length-1]!==`]`)return Q(`[: missing \`]'
1601
1601
  `,2);e=n.slice(0,-1)}return IP(l,e)}return null}async function rz(e,t,n,r=!1){let{ctx:i,runCommand:a}=e;if(t.length===0)return fP;let o=!1,s=!1,c=!1,l=t;for(;l.length>0&&l[0].startsWith(`-`);){let e=l[0];if(e===`--`){l=l.slice(1);break}for(let t of e.slice(1))t===`p`?o=!0:t===`V`?s=!0:t===`v`&&(c=!0);l=l.slice(1)}if(l.length===0)return fP;if(c||s)return await QR(i,l,c,s);let[u,...d]=l;return a(u,d,[],n,!0,o,-1,r)}async function iz(e,t,n,r=!1){let{runCommand:i}=e;if(t.length===0)return fP;let a=t;if(a[0]===`--`&&(a=a.slice(1),a.length===0))return fP;let o=a[0];if(o!==`__just_bash_tee_restore`&&!_F.has(o))return Q(`bash: builtin: ${o}: not a shell builtin
1602
1602
  `);let[,...s]=a;return i(o,s,[],n,!0,!1,-1,r)}async function az(e,t,n,r,i){let{ctx:a,buildExportedEnv:o,executeUserScript:s}=e,c=await SR(a,t,i?`/usr/bin:/bin`:void 0);if(!c)return dP(t)?Q(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
1603
1603
  `,127):Q(`bash: ${t}: command not found