sliccy 6.66.0 → 6.67.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 (152) hide show
  1. package/README.md +1 -0
  2. package/dist/node-server/_shared/fetch-proxy-protocol.d.ts +24 -2
  3. package/dist/node-server/_shared/fetch-proxy-protocol.d.ts.map +1 -1
  4. package/dist/node-server/_shared/fetch-proxy-protocol.js +6 -0
  5. package/dist/node-server/_shared/fetch-proxy-protocol.js.map +1 -1
  6. package/dist/node-server/_shared/tray-signaling.d.ts +29 -3
  7. package/dist/node-server/_shared/tray-signaling.d.ts.map +1 -1
  8. package/dist/node-server/_shared/tray-signaling.js.map +1 -1
  9. package/dist/node-server/_shared/tray-sync-protocol.d.ts +80 -19
  10. package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -1
  11. package/dist/node-server/_shared/tray-sync-protocol.js +4 -2
  12. package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -1
  13. package/dist/node-server/sudo/endpoint.js +1 -1
  14. package/dist/node-server/sudo/types.d.ts +2 -1
  15. package/dist/ui/assets/account-store-Ce2if9Jn.js +95 -0
  16. package/dist/ui/assets/account-store-wPg0Ynxp.js +63 -0
  17. package/dist/ui/assets/{adobe-I4Li2W8c.js → adobe-C1RyxBcm.js} +1 -1
  18. package/dist/ui/assets/{adobe-em2JnvDe.js → adobe-DebDqXSq.js} +1 -1
  19. package/dist/ui/assets/{agent-message-to-chat-CqqyKeXB.js → agent-message-to-chat-ChAiEgvC.js} +1 -1
  20. package/dist/ui/assets/agent-message-to-chat-_cvF5A5g.js +1 -0
  21. package/dist/ui/assets/{apply-layout-BoNRmL8Y.js → apply-layout-BaWZ_-Lt.js} +1 -1
  22. package/dist/ui/assets/{apps-BnqBbyNp.js → apps-DxgX5Xmi.js} +1 -1
  23. package/dist/ui/assets/{azure-openai-BvqmZ3j-.js → azure-openai-CL0rMpn9.js} +1 -1
  24. package/dist/ui/assets/{azure-openai-CoLE0LUD.js → azure-openai-DagOTo7L.js} +1 -1
  25. package/dist/ui/assets/browser-DdY1FBRp.js +420 -0
  26. package/dist/ui/assets/{bsh-watchdog-CGQrf53U.js → bsh-watchdog-BM2oq7W2.js} +1 -1
  27. package/dist/ui/assets/{cerebras-N3RQI-E8.js → cerebras-B1c9MjR9.js} +1 -1
  28. package/dist/ui/assets/{cerebras-DbA65bj4.js → cerebras-BleeSfAS.js} +1 -1
  29. package/dist/ui/assets/{client-CzWrT-Mo.js → client-CSGMDS3X.js} +1 -1
  30. package/dist/ui/assets/{connect-surface-tt-w6xlI.js → connect-surface-CB3Mrmdc.js} +1 -1
  31. package/dist/ui/assets/cost-command-AOg9dLn6.js +1660 -0
  32. package/dist/ui/assets/{ensure-speech-assets-DFTUzaeJ.js → ensure-speech-assets-DmEHLJmO.js} +1 -1
  33. package/dist/ui/assets/{esbuild-wasm-zvHYk_-8.js → esbuild-wasm-C_e51T2J.js} +1 -1
  34. package/dist/ui/assets/{secret-topology-CnKyhZKB.js → float-topology-De3nA4jm.js} +1 -1
  35. package/dist/ui/assets/{fs-cBZmg_kC.js → fs-BL3WQ_sh.js} +2 -2
  36. package/dist/ui/assets/{fs-DeZlD-ik.js → fs-gCKR9Bi5.js} +1 -1
  37. package/dist/ui/assets/{github-hPgu49Tm.js → github-Ck_w6usI.js} +2 -2
  38. package/dist/ui/assets/{github-copilot-Cn2uwaOz.js → github-copilot-B9UAv3Hq.js} +1 -1
  39. package/dist/ui/assets/{github-copilot-CBY8CRcA.js → github-copilot-r-EvotN-.js} +1 -1
  40. package/dist/ui/assets/{github-install-KIjL0H0J.js → github-install-C2ZvAUxe.js} +1 -1
  41. package/dist/ui/assets/{github-Cb3uz-zz.js → github-tHarzLKE.js} +1 -1
  42. package/dist/ui/assets/{github-zip-8H0xOMtl.js → github-zip-O7ea_WqC.js} +1 -1
  43. package/dist/ui/assets/{hear-BT-M2Vy2.js → hear-Dv1RlcVG.js} +1 -1
  44. package/dist/ui/assets/{host-command-CJMUZX5D.js → host-command-C-OOmT75.js} +1 -1
  45. package/dist/ui/assets/image-markers-BXtVm4og.js +1 -0
  46. package/dist/ui/assets/image-markers-CdcIBWOf.js +1 -0
  47. package/dist/ui/assets/{installer-B-fHQejE.js → installer-BCqXfKT9.js} +1 -1
  48. package/dist/ui/assets/{kernel-worker-DPdX_UPh.js → kernel-worker-DCkApA6P.js} +656 -649
  49. package/dist/ui/assets/{kokoro-engine-bmxDo1Gw.js → kokoro-engine-Bx78jmwN.js} +1 -1
  50. package/dist/ui/assets/libesm-BI4UHVqp.js +13 -0
  51. package/dist/ui/assets/libesm-zfj8k-QN.js +13 -0
  52. package/dist/ui/assets/{lick-urls-BNkRZVQv.js → lick-urls-CH_kuOHQ.js} +1 -1
  53. package/dist/ui/assets/{lick-ws-bridge-D31ae-_r.js → lick-ws-bridge-Bu-qQPAM.js} +1 -1
  54. package/dist/ui/assets/{local-llm-Cf7mXYDm.js → local-llm-C3VZeUmB.js} +1 -1
  55. package/dist/ui/assets/{local-llm-CFDzVee5.js → local-llm-a5wvw7lr.js} +1 -1
  56. package/dist/ui/assets/{magick-wasm-B4biLaC_.js → magick-wasm-DVJe3sB9.js} +1 -1
  57. package/dist/ui/assets/{main-CrfRGoiY.js → main-C-QxUYRK.js} +3 -3
  58. package/dist/ui/assets/{mount-SE5SDH9H.js → mount-QTRu2Wbi.js} +2 -2
  59. package/dist/ui/assets/{mount-recovery-C6wEeW8B.js → mount-recovery-ClCOKUdP.js} +1 -1
  60. package/dist/ui/assets/mount-yKsRf04-.js +1 -0
  61. package/dist/ui/assets/new-session-G64UTqSH.js +2 -0
  62. package/dist/ui/assets/oauth-bootstrap-DbrjearK.js +2 -0
  63. package/dist/ui/assets/{oauth-service-PiotCIHi.js → oauth-service-BWDgBZaN.js} +1 -1
  64. package/dist/ui/assets/{openai-codex-BXoeCcit.js → openai-codex-DT6sDiaC.js} +1 -1
  65. package/dist/ui/assets/{openai-codex-D22K7BxU.js → openai-codex-j9lUl3Er.js} +1 -1
  66. package/dist/ui/assets/{openrouter-CFqh-FJJ.js → openrouter-BkAFLPSp.js} +1 -1
  67. package/dist/ui/assets/{openrouter-B8LZPyMD.js → openrouter-DZvCG6xn.js} +1 -1
  68. package/dist/ui/assets/{openrouter-oauth-BTGNWaZn.js → openrouter-oauth-B7DcYTdw.js} +1 -1
  69. package/dist/ui/assets/{openrouter-oauth-DH3ddD0t.js → openrouter-oauth-CnwAvShX.js} +1 -1
  70. package/dist/ui/assets/page-approval-service-D6ou384J.js +1 -0
  71. package/dist/ui/assets/panel-rpc-handlers-D7TW8OJE.js +2 -0
  72. package/dist/ui/assets/{port-bridge-client-BdgO9OHy.js → port-bridge-client-V3i4ld9z.js} +1 -1
  73. package/dist/ui/assets/provider-BPypI15y.js +2 -0
  74. package/dist/ui/assets/{provider-DXcmqPiT.js → provider-DDA4hGb9.js} +1 -1
  75. package/dist/ui/assets/{provider-settings-J3jY6tvg.js → provider-settings-C3pzEPN9.js} +1 -1
  76. package/dist/ui/assets/{provider-settings-CWTb76gs.js → provider-settings-D3zanPa9.js} +1 -1
  77. package/dist/ui/assets/provider-store-access-CNpTsxNX.js +1 -0
  78. package/dist/ui/assets/{provider-store-access-CbvRTx4j.js → provider-store-access-CRQnitC5.js} +2 -2
  79. package/dist/ui/assets/providers-DDLUVTss.js +2 -0
  80. package/dist/ui/assets/{providers-CQtEzKMK.js → providers-kctq1ECj.js} +1 -1
  81. package/dist/ui/assets/proxied-fetch-Cf4bBarA.js +1 -0
  82. package/dist/ui/assets/{quick-llm-D6BlUnJj.js → quick-llm-Dk-1DMJw.js} +1 -1
  83. package/dist/ui/assets/{recovery-screen-qbyPoetC.js → recovery-screen-BzZPZiRZ.js} +1 -1
  84. package/dist/ui/assets/{redirect-uri-BA8odcwp.js → redirect-uri-B8mkY_jT.js} +1 -1
  85. package/dist/ui/assets/{remote-terminal-view-COEuyBI3.js → remote-terminal-view-Dc-DMywu.js} +1 -1
  86. package/dist/ui/assets/secret-env-0q_I_PmT.js +1 -0
  87. package/dist/ui/assets/secret-topology-3L5_wLhL.js +1 -0
  88. package/dist/ui/assets/{session-freezer-CD4XjCYL.js → session-freezer-xdZ0Flnz.js} +3 -3
  89. package/dist/ui/assets/{setup-feature-flags-remote-DDhA70it.js → setup-feature-flags-remote-Cg7Wdn90.js} +1 -1
  90. package/dist/ui/assets/{setup-standalone-prelude-BeO4Mtp7.js → setup-standalone-prelude-CuAVO_f7.js} +1 -1
  91. package/dist/ui/assets/setup-sudo-BxZr-DZI.js +2 -0
  92. package/dist/ui/assets/{shared-cWEjpC_y.js → shared-DqziuFis.js} +1 -1
  93. package/dist/ui/assets/skills-ClWAw7d4.js +6 -0
  94. package/dist/ui/assets/{speak-D3by19rv.js → speak-DgpN06qn.js} +1 -1
  95. package/dist/ui/assets/sql-wasm-DO685FZu.js +2 -0
  96. package/dist/ui/assets/{store-DFuBnyTD.js → store-CN4Rhukb.js} +1 -1
  97. package/dist/ui/assets/{store-CltppgY2.js → store-xmk9Imtl.js} +1 -1
  98. package/dist/ui/assets/sudo-BrlKw-T9.js +5 -0
  99. package/dist/ui/assets/{transformers-env-B4ZkPJhD.js → transformers-env-DTXizU3q.js} +1 -1
  100. package/dist/ui/assets/{tray-runtime-config-B76Ys57e.js → tray-runtime-config-BXoU8ne0.js} +1 -1
  101. package/dist/ui/assets/{tray-sync-protocol-y3ZAs0Go.js → tray-sync-protocol-DV_QG_Ey.js} +1 -1
  102. package/dist/ui/assets/{upgrade-detection-BtMa0Hh1.js → upgrade-detection-CtqO1pM9.js} +1 -1
  103. package/dist/ui/assets/{wc-extension-e9Jb49g6.js → wc-extension-By0PuxPp.js} +2 -2
  104. package/dist/ui/assets/wc-follower-Ca1RRpFQ.js +17 -0
  105. package/dist/ui/assets/wc-live-C6p7-mBc.js +8 -0
  106. package/dist/ui/assets/wc-nav-CtH1jOnH.js +2 -0
  107. package/dist/ui/assets/{wc-onboarding-BVOcEBUT.js → wc-onboarding-CWcmzbPZ.js} +2 -2
  108. package/dist/ui/assets/{wc-permissions-W2s7R66b.js → wc-permissions-gFKCQht9.js} +2 -2
  109. package/dist/ui/assets/wc-placeholder-CvM2uhAN.js +4 -0
  110. package/dist/ui/assets/{wc-settings-jcxcJvmY.js → wc-settings-ssPjSbWf.js} +2 -2
  111. package/dist/ui/assets/{wc-shell-DcOC5zAq.js → wc-shell-BqrVvQ2e.js} +3 -3
  112. package/dist/ui/assets/{wc-sprinkles-BuG9vz2t.js → wc-sprinkles-Cp0K35KB.js} +2 -2
  113. package/dist/ui/assets/wc-sudo-approval-C3gSJjkF.js +1 -0
  114. package/dist/ui/assets/wc-transcript-export-DKIleW7-.js +2 -0
  115. package/dist/ui/assets/wc-tray-CA13iETm.js +2 -0
  116. package/dist/ui/assets/wc-tray-scoops-BIkr1dfd.js +5 -0
  117. package/dist/ui/assets/{whisper-engine-DNkpDZPo.js → whisper-engine-BFSyNK_g.js} +1 -1
  118. package/dist/ui/assets/{xai-grok-Bo6feQJ7.js → xai-grok-B0GCSkZx.js} +1 -1
  119. package/dist/ui/assets/{xai-grok-BZaBR5-0.js → xai-grok-Bl0XAm6J.js} +1 -1
  120. package/dist/ui/index.html +10 -8
  121. package/dist/ui/llm-proxy-sw.js +1 -1
  122. package/dist/ui/packages/webapp/index.html +10 -8
  123. package/package.json +1 -1
  124. package/dist/ui/assets/account-store-B3zyaJZE.js +0 -100
  125. package/dist/ui/assets/account-store-qa3Ronwd.js +0 -68
  126. package/dist/ui/assets/agent-message-to-chat-BuL6bt3T.js +0 -1
  127. package/dist/ui/assets/base64-Ba7QB87Z.js +0 -1
  128. package/dist/ui/assets/browser-BCEjSsoK.js +0 -507
  129. package/dist/ui/assets/cost-command-C9faxPNJ.js +0 -1614
  130. package/dist/ui/assets/mount-hPTNwCT-.js +0 -1
  131. package/dist/ui/assets/new-session-BoZ9-0tu.js +0 -2
  132. package/dist/ui/assets/oauth-bootstrap-Cyo9E-Z0.js +0 -2
  133. package/dist/ui/assets/panel-responder-B6PI12mV.js +0 -1
  134. package/dist/ui/assets/panel-rpc-handlers-CX1coE9E.js +0 -2
  135. package/dist/ui/assets/provider-2wLV0p1S.js +0 -2
  136. package/dist/ui/assets/provider-store-access-DhfxPZfY.js +0 -1
  137. package/dist/ui/assets/providers-CCMmRBfc.js +0 -2
  138. package/dist/ui/assets/proxied-fetch-B30CBbDZ.js +0 -1
  139. package/dist/ui/assets/secret-env-DR5erlOp.js +0 -1
  140. package/dist/ui/assets/setup-sudo-DKShVrkx.js +0 -2
  141. package/dist/ui/assets/skills-Cv1rJnI0.js +0 -6
  142. package/dist/ui/assets/sql-wasm-BJoHkdU1.js +0 -2
  143. package/dist/ui/assets/sudo-CyhegXjO.js +0 -5
  144. package/dist/ui/assets/tool-result-images-D3dq_p6D.js +0 -1
  145. package/dist/ui/assets/tool-result-images-D8kQ0hH0.js +0 -1
  146. package/dist/ui/assets/wc-follower-B8uZ6Gdd.js +0 -17
  147. package/dist/ui/assets/wc-live-Dsn7fqZG.js +0 -8
  148. package/dist/ui/assets/wc-nav-Cl-tpYzB.js +0 -2
  149. package/dist/ui/assets/wc-placeholder-DlcY3zTv.js +0 -4
  150. package/dist/ui/assets/wc-transcript-export-B17cQHtd.js +0 -2
  151. package/dist/ui/assets/wc-tray-B2TQQbmx.js +0 -2
  152. package/dist/ui/assets/wc-tray-scoops-04hA__JQ.js +0 -5
@@ -0,0 +1,1660 @@
1
+ import{n as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{t as n}from"./libesm-zfj8k-QN.js";var r=t((e=>{(function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(e){return i(o(e),arguments)}function r(e,t){return n.apply(null,[e].concat(t||[]))}function i(e,r){var i=1,a=e.length,o,s=``,c,l,u,d,f,p,m,h;for(c=0;c<a;c++)if(typeof e[c]==`string`)s+=e[c];else if(typeof e[c]==`object`){if(u=e[c],u.keys)for(o=r[i],l=0;l<u.keys.length;l++){if(o==null)throw Error(n(`[sprintf] Cannot access property "%s" of undefined value "%s"`,u.keys[l],u.keys[l-1]));o=o[u.keys[l]]}else o=u.param_no?r[u.param_no]:r[i++];if(t.not_type.test(u.type)&&t.not_primitive.test(u.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(u.type)&&typeof o!=`number`&&isNaN(o))throw TypeError(n(`[sprintf] expecting number but found %T`,o));switch(t.number.test(u.type)&&(m=o>=0),u.type){case`b`:o=parseInt(o,10).toString(2);break;case`c`:o=String.fromCharCode(parseInt(o,10));break;case`d`:case`i`:o=parseInt(o,10);break;case`j`:o=JSON.stringify(o,null,u.width?parseInt(u.width):0);break;case`e`:o=u.precision?parseFloat(o).toExponential(u.precision):parseFloat(o).toExponential();break;case`f`:o=u.precision?parseFloat(o).toFixed(u.precision):parseFloat(o);break;case`g`:o=u.precision?String(Number(o.toPrecision(u.precision))):parseFloat(o);break;case`o`:o=(parseInt(o,10)>>>0).toString(8);break;case`s`:o=String(o),o=u.precision?o.substring(0,u.precision):o;break;case`t`:o=String(!!o),o=u.precision?o.substring(0,u.precision):o;break;case`T`:o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=u.precision?o.substring(0,u.precision):o;break;case`u`:o=parseInt(o,10)>>>0;break;case`v`:o=o.valueOf(),o=u.precision?o.substring(0,u.precision):o;break;case`x`:o=(parseInt(o,10)>>>0).toString(16);break;case`X`:o=(parseInt(o,10)>>>0).toString(16).toUpperCase()}t.json.test(u.type)?s+=o:(t.number.test(u.type)&&(!m||u.sign)?(h=m?`+`:`-`,o=o.toString().replace(t.sign,``)):h=``,f=u.pad_char?u.pad_char===`0`?`0`:u.pad_char.charAt(1):` `,p=u.width-(h+o).length,d=u.width&&p>0?f.repeat(p):``,s+=u.align?h+o+d:f===`0`?h+d+o:d+h+o)}return s}var a=Object.create(null);function o(e){if(a[e])return a[e];for(var n=e,r,i=[],o=0;n;){if((r=t.text.exec(n))!==null)i.push(r[0]);else if((r=t.modulo.exec(n))!==null)i.push(`%`);else if((r=t.placeholder.exec(n))!==null){if(r[2]){o|=1;var s=[],c=r[2],l=[];if((l=t.key.exec(c))!==null)for(s.push(l[1]);(c=c.substring(l[0].length))!==``;)if((l=t.key_access.exec(c))!==null)s.push(l[1]);else if((l=t.index_access.exec(c))!==null)s.push(l[1]);else throw SyntaxError(`[sprintf] failed to parse named argument key`);else throw SyntaxError(`[sprintf] failed to parse named argument key`);r[2]=s}else o|=2;if(o===3)throw Error(`[sprintf] mixing positional and named placeholders is not (yet) supported`);i.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}else throw SyntaxError(`[sprintf] unexpected placeholder`);n=n.substring(r[0].length)}return a[e]=i}e!==void 0&&(e.sprintf=n,e.vsprintf=r),typeof window<`u`&&(window.sprintf=n,window.vsprintf=r,typeof define==`function`&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()}))();const i=(e,t,n)=>{let r=e instanceof RegExp?a(e,n):e,i=t instanceof RegExp?a(t,n):t,s=r!==null&&i!=null&&o(r,i,n);return s&&{start:s[0],end:s[1],pre:n.slice(0,s[0]),body:n.slice(s[0]+r.length,s[1]),post:n.slice(s[1]+i.length)}},a=(e,t)=>{let n=t.match(e);return n?n[0]:null},o=(e,t,n)=>{let r,i,a,o,s,c=n.indexOf(e),l=n.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(r=[],a=n.length;u>=0&&!s;){if(u===c)r.push(u),c=n.indexOf(e,u+1);else if(r.length===1){let e=r.pop();e!==void 0&&(s=[e,l])}else i=r.pop(),i!==void 0&&i<a&&(a=i,o=l),l=n.indexOf(t,u+1);u=c<l&&c>=0?c:l}r.length&&o!==void 0&&(s=[a,o])}return s},s=`\0SLASH`+Math.random()+`\0`,c=`\0OPEN`+Math.random()+`\0`,l=`\0CLOSE`+Math.random()+`\0`,u=`\0COMMA`+Math.random()+`\0`,d=`\0PERIOD`+Math.random()+`\0`,f=new RegExp(s,`g`),p=new RegExp(c,`g`),m=new RegExp(l,`g`),h=new RegExp(u,`g`),g=new RegExp(d,`g`),_=/\\\\/g,v=/\\{/g,y=/\\}/g,b=/\\,/g,x=/\\\./g;function S(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function ee(e){return e.replace(_,s).replace(v,c).replace(y,l).replace(b,u).replace(x,d)}function C(e){return e.replace(f,`\\`).replace(p,`{`).replace(m,`}`).replace(h,`,`).replace(g,`.`)}function te(e){if(!e)return[``];let t=[],n=i(`{`,`}`,e);if(!n)return e.split(`,`);let{pre:r,body:a,post:o}=n,s=r.split(`,`);s[s.length-1]+=`{`+a+`}`;let c=te(o);return o.length&&(s[s.length-1]+=c.shift(),s.push.apply(s,c)),t.push.apply(t,s),t}function ne(e,t={}){if(!e)return[];let{max:n=1e5,maxLength:r=4e6}=t;return e.slice(0,2)===`{}`&&(e=`\\{\\}`+e.slice(2)),ce(ee(e),n,r,!0).map(C)}function w(e){return`{`+e+`}`}function re(e){return/^-?0\d/.test(e)}function ie(e,t){return e<=t}function ae(e,t){return e>=t}function oe(e,t,n,r,i,a){let o=[],s=0;for(let c=0;c<e.length;c++)for(let l=0;l<n.length;l++){if(o.length>=r)return o;let u=e[c]+t+n[l];if(!(a&&!u)){if(s+u.length>i)return o;o.push(u),s+=u.length}}return o}function se(e,t,n,r){let i=e.split(/\.\./),a=[];if(i[0]===void 0||i[1]===void 0)return a;let o=S(i[0]),s=S(i[1]),c=Math.max(i[0].length,i[1].length),l=i.length===3&&i[2]!==void 0?Math.max(Math.abs(S(i[2])),1):1,u=ie;s<o&&(l*=-1,u=ae);let d=i.some(re),f=0;for(let e=o;u(e,s)&&a.length<n;e+=l){let n;if(t)n=String.fromCharCode(e),n===`\\`&&(n=``);else if(n=String(e),d){let t=c-n.length;if(t>0){let r=Array(t+1).join(`0`);n=e<0?`-`+r+n.slice(1):r+n}}if(f+n.length>r)break;a.push(n),f+=n.length}return a}function ce(e,t,n,r){let a=[``],o=!1,s=!0;for(;;){let c=i(`{`,`}`,e);if(!c)return oe(a,e,[``],t,n,o);let u=c.pre;if(/\$$/.test(u)){if(a=oe(a,u+`{`+c.body+`}`,[``],t,n,o&&!c.post.length),s=!1,!c.post.length)break;e=c.post;continue}let d=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(c.body),f=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(c.body),p=d||f,m=c.body.indexOf(`,`)>=0;if(!p&&!m){if(c.post.match(/,(?!,).*\}/)){e=c.pre+`{`+c.body+l+c.post,r=!0;continue}return oe(a,u+`{`+c.body+`}`+c.post,[``],t,n,o)}s&&=(o=r&&!p,!1);let h;if(p)h=se(c.body,f,t,n);else{let r=te(c.body);if(r.length===1&&r[0]!==void 0&&(r=ce(r[0],t,n,!1).map(w),r.length===1)){if(a=oe(a,u+r[0],[``],t,n,o&&!c.post.length),!c.post.length)break;e=c.post;continue}let i=o&&!c.post.length&&!u;for(let e=0;i&&e<a.length;e++)a[e]&&(i=!1);h=[];let s=0;outer:for(let e=0;e<r.length;e++){let a=ce(r[e],t,n,!1);for(let e=0;e<a.length;e++){let r=a[e];if(!(i&&!r)){if(h.length>=t||s+r.length>n)break outer;h.push(r),s+=r.length}}}}if(a=oe(a,u,h,t,n,o&&!c.post.length),!c.post.length)break;e=c.post}return a}const le=e=>{if(typeof e!=`string`)throw TypeError(`invalid pattern`);if(e.length>65536)throw TypeError(`pattern is too long`)},ue={"[:alnum:]":[`\\p{L}\\p{Nl}\\p{Nd}`,!0],"[:alpha:]":[`\\p{L}\\p{Nl}`,!0],"[:ascii:]":[`\\x00-\\x7f`,!1],"[:blank:]":[`\\p{Zs}\\t`,!0],"[:cntrl:]":[`\\p{Cc}`,!0],"[:digit:]":[`\\p{Nd}`,!0],"[:graph:]":[`\\p{Z}\\p{C}`,!0,!0],"[:lower:]":[`\\p{Ll}`,!0],"[:print:]":[`\\p{C}`,!0],"[:punct:]":[`\\p{P}`,!0],"[:space:]":[`\\p{Z}\\t\\r\\n\\v\\f`,!0],"[:upper:]":[`\\p{Lu}`,!0],"[:word:]":[`\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}`,!0],"[:xdigit:]":[`A-Fa-f0-9`,!1]},de=e=>e.replace(/[[\]\\-]/g,`\\$&`),fe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),pe=e=>e.join(``),me=(e,t)=>{let n=t;if(e.charAt(n)!==`[`)throw Error(`not in a brace expression`);let r=[],i=[],a=n+1,o=!1,s=!1,c=!1,l=!1,u=n,d=``;WHILE:for(;a<e.length;){let t=e.charAt(a);if((t===`!`||t===`^`)&&a===n+1){l=!0,a++;continue}if(t===`]`&&o&&!c){u=a+1;break}if(o=!0,t===`\\`&&!c){c=!0,a++;continue}if(t===`[`&&!c){for(let[t,[o,c,l]]of Object.entries(ue))if(e.startsWith(t,a)){if(d)return[`$.`,!1,e.length-n,!0];a+=t.length,l?i.push(o):r.push(o),s||=c;continue WHILE}}if(c=!1,d){t>d?r.push(de(d)+`-`+de(t)):t===d&&r.push(de(t)),d=``,a++;continue}if(e.startsWith(`-]`,a+1)){r.push(de(t+`-`)),a+=2;continue}if(e.startsWith(`-`,a+1)){d=t,a+=2;continue}r.push(de(t)),a++}if(u<a)return[``,!1,0,!1];if(!r.length&&!i.length)return[`$.`,!1,e.length-n,!0];if(i.length===0&&r.length===1&&/^\\?.$/.test(r[0])&&!l){let e=r[0].length===2?r[0].slice(-1):r[0];return[fe(e),!1,u-n,!1]}let f=`[`+(l?`^`:``)+pe(r)+`]`,p=`[`+(l?``:`^`)+pe(i)+`]`;return[r.length&&i.length?`(`+f+`|`+p+`)`:r.length?f:p,s,u-n,!0]},he=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!0}={})=>n?t?e.replace(/\[([^/\\])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\])\]/g,`$1$2`).replace(/\\([^/])/g,`$1`):t?e.replace(/\[([^/\\{}])\]/g,`$1`):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,`$1$2`).replace(/\\([^/{}])/g,`$1`);var ge;const _e=new Set([`!`,`?`,`+`,`*`,`@`]),ve=e=>_e.has(e),ye=e=>ve(e.type),be=new Map([[`!`,[`@`]],[`?`,[`?`,`@`]],[`@`,[`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`]]]),xe=new Map([[`!`,[`?`]],[`@`,[`?`]],[`+`,[`?`,`*`]]]),Se=new Map([[`!`,[`?`,`@`]],[`?`,[`?`,`@`]],[`@`,[`?`,`@`]],[`*`,[`*`,`+`,`?`,`@`]],[`+`,[`+`,`@`,`?`,`*`]]]),Ce=new Map([[`!`,new Map([[`!`,`@`]])],[`?`,new Map([[`*`,`*`],[`+`,`*`]])],[`@`,new Map([[`!`,`!`],[`?`,`?`],[`@`,`@`],[`*`,`*`],[`+`,`+`]])],[`+`,new Map([[`?`,`*`],[`*`,`*`]])]]),we=`(?!\\.)`,Te=new Set([`[`,`.`]),Ee=new Set([`..`,`.`]),De=new Set(`().*{}+?[]^$\\!`),Oe=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),ke=`[^/]+?`;let Ae=0;var je=class{type;#e;#t;#n=!1;#r=[];#i;#a;#o;#s=!1;#c;#l;#u=!1;id=++Ae;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for(`nodejs.util.inspect.custom`)](){return{"@@type":`AST`,id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(e,t,n={}){this.type=e,e&&(this.#t=!0),this.#i=t,this.#e=this.#i?this.#i.#e:this,this.#c=this.#e===this?n:this.#e.#c,this.#o=this.#e===this?[]:this.#e.#o,e===`!`&&!this.#e.#s&&this.#o.push(this),this.#a=this.#i?this.#i.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!=`string`&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#l===void 0?this.#l=this.type?this.type+`(`+this.#r.map(e=>String(e)).join(`|`)+`)`:this.#r.map(e=>String(e)).join(``):this.#l}#d(){if(this!==this.#e)throw Error(`should only call on root`);if(this.#s)return this;this.toString(),this.#s=!0;let e;for(;e=this.#o.pop();){if(e.type!==`!`)continue;let t=e,n=t.#i;for(;n;){for(let r=t.#a+1;!n.type&&r<n.#r.length;r++)for(let t of e.#r){if(typeof t==`string`)throw Error(`string part in extglob AST??`);t.copyIn(n.#r[r])}t=n,n=t.#i}}return this}push(...e){for(let t of e)if(t!==``){if(typeof t!=`string`&&!(t instanceof ge&&t.#i===this))throw Error(`invalid part: `+t);this.#r.push(t)}}toJSON(){let e=this.type===null?this.#r.slice().map(e=>typeof e==`string`?e:e.toJSON()):[this.type,...this.#r.map(e=>e.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#i?.type===`!`)&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#a===0)return!0;let e=this.#i;for(let t=0;t<this.#a;t++){let n=e.#r[t];if(!(n instanceof ge&&n.type===`!`))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type===`!`)return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let e=this.#i?this.#i.#r.length:0;return this.#a===e-1}copyIn(e){typeof e==`string`?this.push(e):this.push(e.clone(this))}clone(e){let t=new ge(this.type,e);for(let e of this.#r)t.copyIn(e);return t}static#f(e,t,n,r,i){let a=r.maxExtglobRecursion??2,o=!1,s=!1,c=-1,l=!1;if(t.type===null){let u=n,d=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,d+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),d+=n;continue}if(n===`[`){s=!0,c=u,l=!1,d+=n;continue}if(!r.noext&&ve(n)&&e.charAt(u)===`(`&&i<=a){t.push(d),d=``;let a=new ge(n,t);u=ge.#f(e,a,u,r,i+1),t.push(a);continue}d+=n}return t.push(d),u}let u=n+1,d=new ge(null,t),f=[],p=``;for(;u<e.length;){let n=e.charAt(u++);if(o||n===`\\`){o=!o,p+=n;continue}if(s){u===c+1?(n===`^`||n===`!`)&&(l=!0):n===`]`&&!(u===c+2&&l)&&(s=!1),p+=n;continue}if(n===`[`){s=!0,c=u,l=!1,p+=n;continue}if(!r.noext&&ve(n)&&e.charAt(u)===`(`&&(i<=a||t&&t.#h(n))){let a=t&&t.#h(n)?0:1;d.push(p),p=``;let o=new ge(n,d);d.push(o),u=ge.#f(e,o,u,r,i+a);continue}if(n===`|`){d.push(p),p=``,f.push(d),d=new ge(null,t);continue}if(n===`)`)return p===``&&t.#r.length===0&&(t.#u=!0),d.push(p),p=``,t.push(...f,d),u;p+=n}return t.type=null,t.#t=void 0,t.#r=[e.substring(n-1)],u}#p(e){return this.#m(e,xe)}#m(e,t=be){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null)return!1;let n=e.#r[0];return!n||typeof n!=`object`||n.type===null?!1:this.#h(n.type,t)}#h(e,t=Se){return!!t.get(this.type)?.includes(e)}#g(e,t){let n=e.#r[0],r=new ge(null,n,this.options);r.#r.push(``),n.push(r),this.#_(e,t)}#_(e,t){let n=e.#r[0];this.#r.splice(t,1,...n.#r);for(let e of n.#r)typeof e==`object`&&(e.#i=this);this.#l=void 0}#v(e){return!!Ce.get(this.type)?.has(e)}#y(e){if(!e||typeof e!=`object`||e.type!==null||e.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let t=e.#r[0];return!t||typeof t!=`object`||t.type===null?!1:this.#v(t.type)}#b(e){let t=Ce.get(this.type),n=e.#r[0],r=t?.get(n.type);if(!r)return!1;this.#r=n.#r;for(let e of this.#r)typeof e==`object`&&(e.#i=this);this.type=r,this.#l=void 0,this.#u=!1}static fromGlob(e,t={}){let n=new ge(null,void 0,t);return ge.#f(e,n,0,t,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[t,n,r,i]=this.toRegExpSource();if(!(r||this.#t||this.#c.nocase&&!this.#c.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#c.nocase?`i`:``)+(i?`u`:``);return Object.assign(RegExp(`^${t}$`,a),{_src:t,_glob:e})}get options(){return this.#c}toRegExpSource(e){let t=e??!!this.#c.dot;if(this.#e===this&&(this.#x(),this.#d()),!ye(this)){let n=this.isStart()&&this.isEnd()&&!this.#r.some(e=>typeof e!=`string`),r=this.#r.map(t=>{let[r,i,a,o]=typeof t==`string`?ge.#C(t,this.#t,n):t.toRegExpSource(e);return this.#t=this.#t||a,this.#n=this.#n||o,r}).join(``),i=``;if(this.isStart()&&typeof this.#r[0]==`string`&&!(this.#r.length===1&&Ee.has(this.#r[0]))){let n=Te,a=t&&n.has(r.charAt(0))||r.startsWith(`\\.`)&&n.has(r.charAt(2))||r.startsWith(`\\.\\.`)&&n.has(r.charAt(4)),o=!t&&!e&&n.has(r.charAt(0));i=a?`(?!(?:^|/)\\.\\.?(?:$|/))`:o?we:``}let a=``;return this.isEnd()&&this.#e.#s&&this.#i?.type===`!`&&(a=`(?:$|\\/)`),[i+r+a,he(r),this.#t=!!this.#t,this.#n]}let n=this.type===`*`||this.type===`+`,r=this.type===`!`?`(?:(?!(?:`:`(?:`,i=this.#S(t);if(this.isStart()&&this.isEnd()&&!i&&this.type!==`!`){let e=this.toString(),t=this;return t.#r=[e],t.type=null,t.#t=void 0,[e,he(this.toString()),!1,!1]}let a=!n||e||t?``:this.#S(!0);a===i&&(a=``),a&&(i=`(?:${i})(?:${a})*?`);let o=``;if(this.type===`!`&&this.#u)o=(this.isStart()&&!t?we:``)+ke;else{let n=this.type===`!`?`))`+(this.isStart()&&!t&&!e?we:``)+`[^/]*?)`:this.type===`@`?`)`:this.type===`?`?`)?`:this.type===`+`&&a?`)`:this.type===`*`&&a?`)?`:`)${this.type}`;o=r+i+n}return[o,he(i),this.#t=!!this.#t,this.#n]}#x(){if(ye(this)){let e=0,t=!1;do{t=!0;for(let e=0;e<this.#r.length;e++){let n=this.#r[e];typeof n==`object`&&(n.#x(),this.#m(n)?(t=!1,this.#_(n,e)):this.#p(n)?(t=!1,this.#g(n,e)):this.#y(n)&&(t=!1,this.#b(n)))}}while(!t&&++e<10)}else for(let e of this.#r)typeof e==`object`&&e.#x();this.#l=void 0}#S(e){return this.#r.map(t=>{if(typeof t==`string`)throw Error(`string type in extglob ast??`);let[n,r,i,a]=t.toRegExpSource(e);return this.#n=this.#n||a,n}).filter(e=>!(this.isStart()&&this.isEnd())||!!e).join(`|`)}static#C(e,t,n=!1){let r=!1,i=``,a=!1,o=!1;for(let s=0;s<e.length;s++){let c=e.charAt(s);if(r){r=!1,i+=(De.has(c)?`\\`:``)+c;continue}if(c===`*`){if(o)continue;o=!0,i+=n&&/^[*]+$/.test(e)?ke:`[^/]*?`,t=!0;continue}if(o=!1,c===`\\`){s===e.length-1?i+=`\\\\`:r=!0;continue}if(c===`[`){let[n,r,o,c]=me(e,s);if(o){i+=n,a||=r,s+=o-1,t||=c;continue}}if(c===`?`){i+=`[^/]`,t=!0;continue}i+=Oe(c)}return[i,he(e),!!t,a]}};ge=je;const Me=(e,{windowsPathsNoEscape:t=!1,magicalBraces:n=!1}={})=>n?t?e.replace(/[?*()[\]{}]/g,`[$&]`):e.replace(/[?*()[\]\\{}]/g,`\\$&`):t?e.replace(/[?*()[\]]/g,`[$&]`):e.replace(/[?*()[\]\\]/g,`\\$&`),Ne=(e,t,n={})=>(le(t),!n.nocomment&&t.charAt(0)===`#`?!1:new st(t,n).match(e)),Pe=/^\*+([^+@!?*[(]*)$/,Fe=e=>t=>!t.startsWith(`.`)&&t.endsWith(e),Ie=e=>t=>t.endsWith(e),Le=e=>(e=e.toLowerCase(),t=>!t.startsWith(`.`)&&t.toLowerCase().endsWith(e)),Re=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ze=/^\*+\.\*+$/,Be=e=>!e.startsWith(`.`)&&e.includes(`.`),Ve=e=>e!==`.`&&e!==`..`&&e.includes(`.`),He=/^\.\*+$/,Ue=e=>e!==`.`&&e!==`..`&&e.startsWith(`.`),We=/^\*+$/,Ge=e=>e.length!==0&&!e.startsWith(`.`),Ke=e=>e.length!==0&&e!==`.`&&e!==`..`,qe=/^\?+([^+@!?*[(]*)?$/,Je=([e,t=``])=>{let n=Qe([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Ye=([e,t=``])=>{let n=$e([e]);return t?(t=t.toLowerCase(),e=>n(e)&&e.toLowerCase().endsWith(t)):n},Xe=([e,t=``])=>{let n=$e([e]);return t?e=>n(e)&&e.endsWith(t):n},Ze=([e,t=``])=>{let n=Qe([e]);return t?e=>n(e)&&e.endsWith(t):n},Qe=([e])=>{let t=e.length;return e=>e.length===t&&!e.startsWith(`.`)},$e=([e])=>{let t=e.length;return e=>e.length===t&&e!==`.`&&e!==`..`},et=typeof process==`object`&&process?{}.__MINIMATCH_TESTING_PLATFORM__||process.platform:`posix`,tt={win32:{sep:`\\`},posix:{sep:`/`}};Ne.sep=et===`win32`?tt.win32.sep:tt.posix.sep;const nt=Symbol(`globstar **`);Ne.GLOBSTAR=nt,Ne.filter=(e,t={})=>n=>Ne(n,e,t);const rt=(e,t={})=>Object.assign({},e,t);Ne.defaults=e=>{if(!e||typeof e!=`object`||!Object.keys(e).length)return Ne;let t=Ne;return Object.assign((n,r,i={})=>t(n,r,rt(e,i)),{Minimatch:class extends t.Minimatch{constructor(t,n={}){super(t,rt(e,n))}static defaults(n){return t.defaults(rt(e,n)).Minimatch}},AST:class extends t.AST{constructor(t,n,r={}){super(t,n,rt(e,r))}static fromGlob(n,r={}){return t.AST.fromGlob(n,rt(e,r))}},unescape:(n,r={})=>t.unescape(n,rt(e,r)),escape:(n,r={})=>t.escape(n,rt(e,r)),filter:(n,r={})=>t.filter(n,rt(e,r)),defaults:n=>t.defaults(rt(e,n)),makeRe:(n,r={})=>t.makeRe(n,rt(e,r)),braceExpand:(n,r={})=>t.braceExpand(n,rt(e,r)),match:(n,r,i={})=>t.match(n,r,rt(e,i)),sep:t.sep,GLOBSTAR:nt})};const it=(e,t={})=>(le(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:ne(e,{max:t.braceExpandMax}));Ne.braceExpand=it,Ne.makeRe=(e,t={})=>new st(e,t).makeRe(),Ne.match=(e,t,n={})=>{let r=new st(t,n);return e=e.filter(e=>r.match(e)),r.options.nonull&&!e.length&&e.push(t),e};const at=/[?*]|[+@!]\(.*?\)|\[|\]/,ot=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`);var st=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(e,t={}){le(e),t||={},this.options=t,this.maxGlobstarRecursion=t.maxGlobstarRecursion??200,this.pattern=e,this.platform=t.platform||et,this.isWindows=this.platform===`win32`,this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,`/`)),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot===void 0?!!(this.isWindows&&this.nocase):t.windowsNoMagicRoot,this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let t of e)if(typeof t!=`string`)return!0;return!1}debug(...e){}make(){let e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)===`#`){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=(...e)=>console.error(...e)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(e=>this.slashSplit(e));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let r=this.globParts.map((e,t,n)=>{if(this.isWindows&&this.windowsNoMagicRoot){let t=e[0]===``&&e[1]===``&&(e[2]===`?`||!at.test(e[2]))&&!at.test(e[3]),n=/^[a-z]:/i.test(e[0]);if(t)return[...e.slice(0,4),...e.slice(4).map(e=>this.parse(e))];if(n)return[e[0],...e.slice(1).map(e=>this.parse(e))]}return e.map(e=>this.parse(e))});if(this.debug(this.pattern,r),this.set=r.filter(e=>e.indexOf(!1)===-1),this.isWindows)for(let e=0;e<this.set.length;e++){let t=this.set[e];t[0]===``&&t[1]===``&&this.globParts[e][2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3])&&(t[2]=`?`)}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let t of e)for(let e=0;e<t.length;e++)t[e]===`**`&&(t[e]=`*`);let{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(e=>{let t=-1;for(;(t=e.indexOf(`**`,t+1))!==-1;){let n=t;for(;e[n+1]===`**`;)n++;n!==t&&e.splice(t,n-t)}return e})}levelOneOptimize(e){return e.map(e=>(e=e.reduce((e,t)=>{let n=e[e.length-1];return t===`**`&&n===`**`?e:t===`..`&&n&&n!==`..`&&n!==`.`&&n!==`**`?(e.pop(),e):(e.push(t),e)},[]),e.length===0?[``]:e))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let n=1;n<e.length-1;n++){let r=e[n];(n!==1||r!==``||e[0]!==``)&&(r===`.`||r===``)&&(t=!0,e.splice(n,1),n--)}e[0]===`.`&&e.length===2&&(e[1]===`.`||e[1]===``)&&(t=!0,e.pop())}let n=0;for(;(n=e.indexOf(`..`,n+1))!==-1;){let r=e[n-1];r&&r!==`.`&&r!==`..`&&r!==`**`&&!(this.isWindows&&/^[a-z]:$/i.test(r))&&(t=!0,e.splice(n-1,2),n-=2)}}while(t);return e.length===0?[``]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let n of e){let r=-1;for(;(r=n.indexOf(`**`,r+1))!==-1;){let i=r;for(;n[i+1]===`**`;)i++;i>r&&n.splice(r+1,i-r);let a=n[r+1],o=n[r+2],s=n[r+3];if(a!==`..`||!o||o===`.`||o===`..`||!s||s===`.`||s===`..`)continue;t=!0,n.splice(r,1);let c=n.slice(0);c[r]=`**`,e.push(c),r--}if(!this.preserveMultipleSlashes){for(let e=1;e<n.length-1;e++){let r=n[e];(e!==1||r!==``||n[0]!==``)&&(r===`.`||r===``)&&(t=!0,n.splice(e,1),e--)}n[0]===`.`&&n.length===2&&(n[1]===`.`||n[1]===``)&&(t=!0,n.pop())}let i=0;for(;(i=n.indexOf(`..`,i+1))!==-1;){let e=n[i-1];if(e&&e!==`.`&&e!==`..`&&e!==`**`){t=!0;let e=i===1&&n[i+1]===`**`?[`.`]:[];n.splice(i-1,2,...e),n.length===0&&n.push(``),i-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let n=t+1;n<e.length;n++){let r=this.partsMatch(e[t],e[n],!this.preserveMultipleSlashes);if(r){e[t]=[],e[n]=r;break}}return e.filter(e=>e.length)}partsMatch(e,t,n=!1){let r=0,i=0,a=[],o=``;for(;r<e.length&&i<t.length;)if(e[r]===t[i])a.push(o===`b`?t[i]:e[r]),r++,i++;else if(n&&e[r]===`**`&&t[i]===e[r+1])a.push(e[r]),r++;else if(n&&t[i]===`**`&&e[r]===t[i+1])a.push(t[i]),i++;else if(e[r]===`*`&&t[i]&&(this.options.dot||!t[i].startsWith(`.`))&&t[i]!==`**`){if(o===`b`)return!1;o=`a`,a.push(e[r]),r++,i++}else if(t[i]===`*`&&e[r]&&(this.options.dot||!e[r].startsWith(`.`))&&e[r]!==`**`){if(o===`a`)return!1;o=`b`,a.push(t[i]),r++,i++}else return!1;return e.length===t.length&&a}parseNegate(){if(this.nonegate)return;let e=this.pattern,t=!1,n=0;for(let r=0;r<e.length&&e.charAt(r)===`!`;r++)t=!t,n++;n&&(this.pattern=e.slice(n)),this.negate=t}matchOne(e,t,n=!1){let r=0,i=0;if(this.isWindows){let n=typeof e[0]==`string`&&/^[a-z]:$/i.test(e[0]),a=!n&&e[0]===``&&e[1]===``&&e[2]===`?`&&/^[a-z]:$/i.test(e[3]),o=typeof t[0]==`string`&&/^[a-z]:$/i.test(t[0]),s=!o&&t[0]===``&&t[1]===``&&t[2]===`?`&&typeof t[3]==`string`&&/^[a-z]:$/i.test(t[3]),c=a?3:n?0:void 0,l=s?3:o?0:void 0;if(typeof c==`number`&&typeof l==`number`){let[n,a]=[e[c],t[l]];n.toLowerCase()===a.toLowerCase()&&(t[l]=n,i=l,r=c)}}let{optimizationLevel:a=1}=this.options;return a>=2&&(e=this.levelTwoFileOptimize(e)),t.includes(nt)?this.#e(e,t,n,r,i):this.#n(e,t,n,r,i)}#e(e,t,n,r,i){let a=t.indexOf(nt,i),o=t.lastIndexOf(nt),[s,c,l]=n?[t.slice(i,a),t.slice(a+1),[]]:[t.slice(i,a),t.slice(a+1,o),t.slice(o+1)];if(s.length){let t=e.slice(r,r+s.length);if(!this.#n(t,s,n,0,0))return!1;r+=s.length,i+=s.length}let u=0;if(l.length){if(l.length+r>e.length)return!1;let t=e.length-l.length;if(this.#n(e,l,n,t,0))u=l.length;else{if(e[e.length-1]!==``||r+l.length===e.length||(t--,!this.#n(e,l,n,t,0)))return!1;u=l.length+1}}if(!c.length){let t=!!u;for(let n=r;n<e.length-u;n++){let r=String(e[n]);if(t=!0,r===`.`||r===`..`||!this.options.dot&&r.startsWith(`.`))return!1}return n||t}let d=[[[],0]],f=d[0],p=0,m=[0];for(let e of c)e===nt?(m.push(p),f=[[],0],d.push(f)):(f[0].push(e),p++);let h=d.length-1,g=e.length-u;for(let e of d)e[1]=g-(m[h--]+e[0].length);return!!this.#t(e,d,r,0,n,0,!!u)}#t(e,t,n,r,i,a,o){let s=t[r];if(!s){for(let t=n;t<e.length;t++){o=!0;let n=e[t];if(n===`.`||n===`..`||!this.options.dot&&n.startsWith(`.`))return!1}return o}let[c,l]=s;for(;n<=l;){if(this.#n(e.slice(0,n+c.length),c,i,n,0)&&a<this.maxGlobstarRecursion){let s=this.#t(e,t,n+c.length,r+1,i,a+1,o);if(s!==!1)return s}let s=e[n];if(s===`.`||s===`..`||!this.options.dot&&s.startsWith(`.`))return!1;n++}return i||null}#n(e,t,n,r,i){let a,o,s,c;for(a=r,o=i,c=e.length,s=t.length;a<c&&o<s;a++,o++){this.debug(`matchOne loop`);let n=t[o],r=e[a];if(this.debug(t,n,r),n===!1||n===nt)return!1;let i;if(typeof n==`string`?(i=r===n,this.debug(`string match`,n,r,i)):(i=n.test(r),this.debug(`pattern match`,n,r,i)),!i)return!1}if(a===c&&o===s)return!0;if(a===c)return n;if(o===s)return a===c-1&&e[a]===``;throw Error(`wtf?`)}braceExpand(){return it(this.pattern,this.options)}parse(e){le(e);let t=this.options;if(e===`**`)return nt;if(e===``)return``;let n,r=null;(n=e.match(We))?r=t.dot?Ke:Ge:(n=e.match(Pe))?r=(t.nocase?t.dot?Re:Le:t.dot?Ie:Fe)(n[1]):(n=e.match(qe))?r=(t.nocase?t.dot?Ye:Je:t.dot?Xe:Ze)(n):(n=e.match(ze))?r=t.dot?Ve:Be:(n=e.match(He))&&(r=Ue);let i=je.fromGlob(e,this.options).toMMPattern();return r&&typeof i==`object`&&Reflect.defineProperty(i,"test",{value:r}),i}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let t=this.options,n=t.noglobstar?`[^/]*?`:t.dot?`(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?`:`(?:(?!(?:\\/|^)\\.).)*?`,r=new Set(t.nocase?[`i`]:[]),i=e.map(e=>{let t=e.map(e=>{if(e instanceof RegExp)for(let t of e.flags.split(``))r.add(t);return typeof e==`string`?ot(e):e===nt?nt:e._src});t.forEach((e,r)=>{let i=t[r+1],a=t[r-1];e===nt&&a!==nt&&(a===void 0?i!==void 0&&i!==nt?t[r+1]=`(?:\\/|`+n+`\\/)?`+i:t[r]=n:i===void 0?t[r-1]=a+`(?:\\/|\\/`+n+`)?`:i!==nt&&(t[r-1]=a+`(?:\\/|\\/`+n+`\\/)`+i,t[r+1]=nt))});let i=t.filter(e=>e!==nt);if(this.partial&&i.length>=1){let e=[];for(let t=1;t<=i.length;t++)e.push(i.slice(0,t).join(`/`));return`(?:`+e.join(`|`)+`)`}return i.join(`/`)}).join(`|`),[a,o]=e.length>1?[`(?:`,`)`]:[``,``];i=`^`+a+i+o+`$`,this.partial&&(i=`^(?:\\/|`+a+i.slice(1,-1)+o+`)$`),this.negate&&(i=`^(?!`+i+`).+$`);try{this.regexp=new RegExp(i,[...r].join(``))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split(`/`):this.isWindows&&/^\/\/[^/]+/.test(e)?[``,...e.split(/\/+/)]:e.split(/\/+/)}match(e,t=this.partial){if(this.debug(`match`,e,this.pattern),this.comment)return!1;if(this.empty)return e===``;if(e===`/`&&t)return!0;let n=this.options;this.isWindows&&(e=e.split(`\\`).join(`/`));let r=this.slashSplit(e);this.debug(this.pattern,`split`,r);let i=this.set;this.debug(this.pattern,`set`,i);let a=r[r.length-1];if(!a)for(let e=r.length-2;!a&&e>=0;e--)a=r[e];for(let e of i){let i=r;if(n.matchBase&&e.length===1&&(i=[a]),this.matchOne(i,e,t))return n.flipNegate?!0:!this.negate}return!n.flipNegate&&this.negate}static defaults(e){return Ne.defaults(e).Minimatch}};Ne.AST=je,Ne.Minimatch=st,Ne.escape=Me,Ne.unescape=he;const ct={};function lt(){throw Error(`gunzipSync is not available in the browser`)}function ut(){throw Error(`gzipSync is not available in the browser`)}function dt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}function ft(e,t){return Array(t+1).join(e)}function pt(e){return e.replace(/^\n*/,``)}function mt(e){for(var t=e.length;t>0&&e[t-1]===`
2
+ `;)t--;return e.substring(0,t)}function ht(e){return mt(pt(e))}var gt=`ADDRESS.ARTICLE.ASIDE.AUDIO.BLOCKQUOTE.BODY.CANVAS.CENTER.DD.DIR.DIV.DL.DT.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.FRAMESET.H1.H2.H3.H4.H5.H6.HEADER.HGROUP.HR.HTML.ISINDEX.LI.MAIN.MENU.NAV.NOFRAMES.NOSCRIPT.OL.OUTPUT.P.PRE.SECTION.TABLE.TBODY.TD.TFOOT.TH.THEAD.TR.UL`.split(`.`);function _t(e){return wt(e,gt)}var vt=[`AREA`,`BASE`,`BR`,`COL`,`COMMAND`,`EMBED`,`HR`,`IMG`,`INPUT`,`KEYGEN`,`LINK`,`META`,`PARAM`,`SOURCE`,`TRACK`,`WBR`];function yt(e){return wt(e,vt)}function bt(e){return Tt(e,vt)}var xt=[`A`,`TABLE`,`THEAD`,`TBODY`,`TFOOT`,`TH`,`TD`,`IFRAME`,`SCRIPT`,`AUDIO`,`VIDEO`];function St(e){return wt(e,xt)}function Ct(e){return Tt(e,xt)}function wt(e,t){return t.indexOf(e.nodeName)>=0}function Tt(e,t){return e.getElementsByTagName&&t.some(function(t){return e.getElementsByTagName(t).length})}var Et=[[/\\/g,`\\\\`],[/\*/g,`\\*`],[/^-/g,`\\-`],[/^\+ /g,`\\+ `],[/^(=+)/g,`\\$1`],[/^(#{1,6}) /g,`\\$1 `],[/`/g,"\\`"],[/^~~~/g,`\\~~~`],[/\[/g,`\\[`],[/\]/g,`\\]`],[/^>/g,`\\>`],[/_/g,`\\_`],[/^(\d+)\. /g,`$1\\. `]];function Dt(e){return Et.reduce(function(e,t){return e.replace(t[0],t[1])},e)}var Ot={};Ot.paragraph={filter:`p`,replacement:function(e){return`
3
+
4
+ `+e+`
5
+
6
+ `}},Ot.lineBreak={filter:`br`,replacement:function(e,t,n){return n.br+`
7
+ `}},Ot.heading={filter:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],replacement:function(e,t,n){var r=Number(t.nodeName.charAt(1));if(n.headingStyle===`setext`&&r<3){var i=ft(r===1?`=`:`-`,e.length);return`
8
+
9
+ `+e+`
10
+ `+i+`
11
+
12
+ `}return`
13
+
14
+ `+ft(`#`,r)+` `+e+`
15
+
16
+ `}},Ot.blockquote={filter:`blockquote`,replacement:function(e){return e=ht(e).replace(/^/gm,`> `),`
17
+
18
+ `+e+`
19
+
20
+ `}},Ot.list={filter:[`ul`,`ol`],replacement:function(e,t){var n=t.parentNode;return n.nodeName===`LI`&&n.lastElementChild===t?`
21
+ `+e:`
22
+
23
+ `+e+`
24
+
25
+ `}},Ot.listItem={filter:`li`,replacement:function(e,t,n){var r=n.bulletListMarker+` `,i=t.parentNode;if(i.nodeName===`OL`){var a=i.getAttribute(`start`),o=Array.prototype.indexOf.call(i.children,t);r=(a?Number(a)+o:o+1)+`. `}var s=/\n$/.test(e);return e=ht(e)+(s?`
26
+ `:``),e=e.replace(/\n/gm,`
27
+ `+` `.repeat(r.length)),r+e+(t.nextSibling?`
28
+ `:``)}},Ot.indentedCodeBlock={filter:function(e,t){return t.codeBlockStyle===`indented`&&e.nodeName===`PRE`&&e.firstChild&&e.firstChild.nodeName===`CODE`},replacement:function(e,t,n){return`
29
+
30
+ `+t.firstChild.textContent.replace(/\n/g,`
31
+ `)+`
32
+
33
+ `}},Ot.fencedCodeBlock={filter:function(e,t){return t.codeBlockStyle===`fenced`&&e.nodeName===`PRE`&&e.firstChild&&e.firstChild.nodeName===`CODE`},replacement:function(e,t,n){for(var r=((t.firstChild.getAttribute(`class`)||``).match(/language-(\S+)/)||[null,``])[1],i=t.firstChild.textContent,a=n.fence.charAt(0),o=3,s=RegExp(`^`+a+`{3,}`,`gm`),c;c=s.exec(i);)c[0].length>=o&&(o=c[0].length+1);var l=ft(a,o);return`
34
+
35
+ `+l+r+`
36
+ `+i.replace(/\n$/,``)+`
37
+ `+l+`
38
+
39
+ `}},Ot.horizontalRule={filter:`hr`,replacement:function(e,t,n){return`
40
+
41
+ `+n.hr+`
42
+
43
+ `}},Ot.inlineLink={filter:function(e,t){return t.linkStyle===`inlined`&&e.nodeName===`A`&&e.getAttribute(`href`)},replacement:function(e,t){var n=At(t.getAttribute(`href`)),r=jt(kt(t.getAttribute(`title`))),i=r?` "`+r+`"`:``;return`[`+e+`](`+n+i+`)`}},Ot.referenceLink={filter:function(e,t){return t.linkStyle===`referenced`&&e.nodeName===`A`&&e.getAttribute(`href`)},replacement:function(e,t,n){var r=At(t.getAttribute(`href`)),i=kt(t.getAttribute(`title`));i&&=` "`+jt(i)+`"`;var a,o;switch(n.linkReferenceStyle){case`collapsed`:a=`[`+e+`][]`,o=`[`+e+`]: `+r+i;break;case`shortcut`:a=`[`+e+`]`,o=`[`+e+`]: `+r+i;break;default:var s=this.references.length+1;a=`[`+e+`][`+s+`]`,o=`[`+s+`]: `+r+i}return this.references.push(o),a},references:[],append:function(e){var t=``;return this.references.length&&(t=`
44
+
45
+ `+this.references.join(`
46
+ `)+`
47
+
48
+ `,this.references=[]),t}},Ot.emphasis={filter:[`em`,`i`],replacement:function(e,t,n){return e.trim()?n.emDelimiter+e+n.emDelimiter:``}},Ot.strong={filter:[`strong`,`b`],replacement:function(e,t,n){return e.trim()?n.strongDelimiter+e+n.strongDelimiter:``}},Ot.code={filter:function(e){var t=e.previousSibling||e.nextSibling,n=e.parentNode.nodeName===`PRE`&&!t;return e.nodeName===`CODE`&&!n},replacement:function(e){if(!e)return``;e=e.replace(/\r?\n|\r/g,` `);for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?` `:``,n="`",r=e.match(/`+/gm)||[];r.indexOf(n)!==-1;)n+="`";return n+t+e+t+n}},Ot.image={filter:`img`,replacement:function(e,t){var n=Dt(kt(t.getAttribute(`alt`))),r=At(t.getAttribute(`src`)||``),i=kt(t.getAttribute(`title`)),a=i?` "`+jt(i)+`"`:``;return r?`![`+n+`](`+r+a+`)`:``}};function kt(e){return e?e.replace(/(\n+\s*)+/g,`
49
+ `):``}function At(e){var t=e.replace(/([<>()])/g,`\\$1`);return t.indexOf(` `)>=0?`<`+t+`>`:t}function jt(e){return e.replace(/"/g,`\\"`)}function Mt(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}Mt.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return``}})},forNode:function(e){if(e.isBlank)return this.blankRule;var t;return(t=Nt(this.array,e,this.options))||(t=Nt(this._keep,e,this.options))||(t=Nt(this._remove,e,this.options))?t:this.defaultRule},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};function Nt(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(Pt(i,t,n))return i}}function Pt(e,t,n){var r=e.filter;if(typeof r==`string`){if(r===t.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(t.nodeName.toLowerCase())>-1)return!0}else if(typeof r==`function`){if(r.call(e,t,n))return!0}else throw TypeError("`filter` needs to be a string, array, or function")}function Ft(e){var t=e.element,n=e.isBlock,r=e.isVoid,i=e.isPre||function(e){return e.nodeName===`PRE`};if(!(!t.firstChild||i(t))){for(var a=null,o=!1,s=null,c=Lt(s,t,i);c!==t;){if(c.nodeType===3||c.nodeType===4){var l=c.data.replace(/[ \r\n\t]+/g,` `);if((!a||/ $/.test(a.data))&&!o&&l[0]===` `&&(l=l.substr(1)),!l){c=It(c);continue}c.data=l,a=c}else if(c.nodeType===1)n(c)||c.nodeName===`BR`?(a&&(a.data=a.data.replace(/ $/,``)),a=null,o=!1):r(c)||i(c)?(a=null,o=!0):a&&(o=!1);else{c=It(c);continue}var u=Lt(s,c,i);s=c,c=u}a&&(a.data=a.data.replace(/ $/,``),a.data||It(a))}}function It(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function Lt(e,t,n){return e&&e.parentNode===t||n(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}var Rt=typeof window<`u`?window:{};function zt(){var e=Rt.DOMParser,t=!1;try{new e().parseFromString(``,`text/html`)&&(t=!0)}catch{}return t}function Bt(){var e=function(){};return Vt()?e.prototype.parseFromString=function(e){var t=new window.ActiveXObject(`htmlfile`);return t.designMode=`on`,t.open(),t.write(e),t.close(),t}:e.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument(``);return t.open(),t.write(e),t.close(),t},e}function Vt(){var e=!1;try{document.implementation.createHTMLDocument(``).open()}catch{Rt.ActiveXObject&&(e=!0)}return e}var Ht=zt()?Rt.DOMParser:Bt();function Ut(e,t){var n=typeof e==`string`?Gt().parseFromString(`<x-turndown id="turndown-root">`+e+`</x-turndown>`,`text/html`).getElementById(`turndown-root`):e.cloneNode(!0);return Ft({element:n,isBlock:_t,isVoid:yt,isPre:t.preformattedCode?Kt:null}),n}var Wt;function Gt(){return Wt||=new Ht,Wt}function Kt(e){return e.nodeName===`PRE`||e.nodeName===`CODE`}function qt(e,t){return e.isBlock=_t(e),e.isCode=e.nodeName===`CODE`||e.parentNode.isCode,e.isBlank=Jt(e),e.flankingWhitespace=Yt(e,t),e}function Jt(e){return!yt(e)&&!St(e)&&/^\s*$/i.test(e.textContent)&&!bt(e)&&!Ct(e)}function Yt(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:``,trailing:``};var n=Xt(e.textContent);return n.leadingAscii&&Zt(`left`,e,t)&&(n.leading=n.leadingNonAscii),n.trailingAscii&&Zt(`right`,e,t)&&(n.trailing=n.trailingNonAscii),{leading:n.leading,trailing:n.trailing}}function Xt(e){var t=e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);return{leading:t[1],leadingAscii:t[2],leadingNonAscii:t[3],trailing:t[4],trailingNonAscii:t[5],trailingAscii:t[6]}}function Zt(e,t,n){var r,i,a;return e===`left`?(r=t.previousSibling,i=/ $/):(r=t.nextSibling,i=/^ /),r&&(r.nodeType===3?a=i.test(r.nodeValue):n.preformattedCode&&r.nodeName===`CODE`?a=!1:r.nodeType===1&&!_t(r)&&(a=i.test(r.textContent))),a}var Qt=Array.prototype.reduce;function $t(e){if(!(this instanceof $t))return new $t(e);var t={rules:Ot,headingStyle:`setext`,hr:`* * *`,bulletListMarker:`*`,codeBlockStyle:`indented`,fence:"```",emDelimiter:`_`,strongDelimiter:`**`,linkStyle:`inlined`,linkReferenceStyle:`full`,br:` `,preformattedCode:!1,blankReplacement:function(e,t){return t.isBlock?`
50
+
51
+ `:``},keepReplacement:function(e,t){return t.isBlock?`
52
+
53
+ `+t.outerHTML+`
54
+
55
+ `:t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?`
56
+
57
+ `+e+`
58
+
59
+ `:e}};this.options=dt({},t,e),this.rules=new Mt(this.options)}$t.prototype={turndown:function(e){if(!an(e))throw TypeError(e+` is not a string, or an element/document/fragment node.`);if(e===``)return``;var t=en.call(this,new Ut(e,this.options));return tn.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else if(typeof e==`function`)e(this);else throw TypeError(`plugin must be a Function or an Array of Functions`);return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return Dt(e)}};function en(e){var t=this;return Qt.call(e.childNodes,function(e,n){n=new qt(n,t.options);var r=``;return n.nodeType===3?r=n.isCode?n.nodeValue:t.escape(n.nodeValue):n.nodeType===1&&(r=nn.call(t,n)),rn(e,r)},``)}function tn(e){var t=this;return this.rules.forEach(function(n){typeof n.append==`function`&&(e=rn(e,n.append(t.options)))}),e.replace(/^[\t\r\n]+/,``).replace(/[\t\r\n\s]+$/,``)}function nn(e){var t=this.rules.forNode(e),n=en.call(this,e),r=e.flankingWhitespace;return(r.leading||r.trailing)&&(n=n.trim()),r.leading+t.replacement(n,e,this.options)+r.trailing}function rn(e,t){var n=mt(e),r=pt(t),i=Math.max(e.length-n.length,t.length-r.length);return n+`
60
+
61
+ `.substring(0,i)+r}function an(e){return e!=null&&(typeof e==`string`||e.nodeType&&(e.nodeType===1||e.nodeType===9||e.nodeType===11))}var on=e({Bash:()=>xB,InMemoryFs:()=>WE,MountableFs:()=>pN,NetworkAccessDeniedError:()=>eB,RedirectNotAllowedError:()=>nB,TooManyRedirectsError:()=>tB,createCommandContext:()=>PE,defineCommand:()=>IE,getCommandNames:()=>xE,getNetworkCommandNames:()=>SE}),sn=Object.create,cn=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,un=Object.getOwnPropertyNames,dn=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty,T=(e,t)=>()=>(e&&(t=e(e=0)),t),pn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),E=(e,t)=>{for(var n in t)cn(e,n,{get:t[n],enumerable:!0})},mn=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of un(t))!fn.call(e,i)&&i!==n&&cn(e,i,{get:()=>t[i],enumerable:!(r=ln(t,i))||r.enumerable});return e},hn=(e,t,n)=>(n=e==null?{}:sn(dn(e)),mn(t||!e||!e.__esModule?cn(n,`default`,{value:e,enumerable:!0}):n,e)),gn={};E(gn,{AsyncLocalStorage:()=>vn,Module:()=>yn,lookup:()=>_n});function _n(){throw Error(`node:dns is not available in browser environments`)}var vn,yn,bn=T(()=>{vn=void 0,yn=void 0});function xn(){return Cn||Sn(),Cn}function Sn(){let e=[{prop:`Function`,target:globalThis,violationType:`function_constructor`,strategy:`throw`,reason:`Function constructor allows arbitrary code execution`},{prop:`eval`,target:globalThis,violationType:`eval`,strategy:`throw`,reason:`eval() allows arbitrary code execution`},{prop:`setTimeout`,target:globalThis,violationType:`setTimeout`,strategy:`throw`,reason:`setTimeout with string argument allows code execution`},{prop:`setInterval`,target:globalThis,violationType:`setInterval`,strategy:`throw`,reason:`setInterval with string argument allows code execution`},{prop:`setImmediate`,target:globalThis,violationType:`setImmediate`,strategy:`throw`,reason:`setImmediate could be used to escape sandbox context`},{prop:`env`,target:process,violationType:`process_env`,strategy:`throw`,reason:`process.env could leak sensitive environment variables`,allowedKeys:new Set([`NODE_V8_COVERAGE`,`NODE_DEBUG`,`NODE_DEBUG_NATIVE`,`NODE_COMPILE_CACHE`,`NODE_ENV`,`WATCH_REPORT_DEPENDENCIES`,`FORCE_COLOR`,`DEBUG`,`UNDICI_NO_FG`,`JEST_WORKER_ID`,`__MINIMATCH_TESTING_PLATFORM__`,`LOG_TOKENS`,`LOG_STREAM`])},{prop:`binding`,target:process,violationType:`process_binding`,strategy:`throw`,reason:`process.binding provides access to native Node.js modules`},{prop:`_linkedBinding`,target:process,violationType:`process_binding`,strategy:`throw`,reason:`process._linkedBinding provides access to native Node.js modules`},{prop:`dlopen`,target:process,violationType:`process_dlopen`,strategy:`throw`,reason:`process.dlopen allows loading native addons`},{prop:`getBuiltinModule`,target:process,violationType:`process_get_builtin_module`,strategy:`throw`,reason:`process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)`},{prop:`exit`,target:process,violationType:`process_exit`,strategy:`throw`,reason:`process.exit could terminate the interpreter`},{prop:`abort`,target:process,violationType:`process_exit`,strategy:`throw`,reason:`process.abort could crash the interpreter`},{prop:`kill`,target:process,violationType:`process_kill`,strategy:`throw`,reason:`process.kill could signal other processes`},{prop:`setuid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setuid could escalate privileges`},{prop:`setgid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setgid could escalate privileges`},{prop:`seteuid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.seteuid could escalate effective user privileges`},{prop:`setegid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setegid could escalate effective group privileges`},{prop:`initgroups`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.initgroups could modify supplementary group IDs`},{prop:`setgroups`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setgroups could modify supplementary group IDs`},{prop:`umask`,target:process,violationType:`process_umask`,strategy:`throw`,reason:`process.umask could modify file creation permissions`},{prop:`argv`,target:process,violationType:`process_argv`,strategy:`throw`,reason:`process.argv may contain secrets in CLI arguments`},{prop:`cwd`,target:process,violationType:`process_chdir`,strategy:`throw`,reason:`process.cwd could disclose real host working directory path`},{prop:`chdir`,target:process,violationType:`process_chdir`,strategy:`throw`,reason:`process.chdir could confuse the interpreter's CWD tracking`},{prop:`report`,target:process,violationType:`process_report`,strategy:`throw`,reason:`process.report could disclose full environment, host paths, and system info`},{prop:`loadEnvFile`,target:process,violationType:`process_env`,strategy:`throw`,reason:`process.loadEnvFile could load env files bypassing env proxy`},{prop:`setUncaughtExceptionCaptureCallback`,target:process,violationType:`process_exception_handler`,strategy:`throw`,reason:`setUncaughtExceptionCaptureCallback could intercept security errors`},...[`on`,`once`,`addListener`,`prependListener`,`prependOnceListener`].map(e=>({prop:e,target:process,violationType:`process_exception_handler`,strategy:`throw`,reason:`process-global listeners can outlive the sandbox and lose its security context`})),{prop:`send`,target:process,violationType:`process_send`,strategy:`throw`,reason:`process.send could communicate with parent process in IPC contexts`},{prop:`channel`,target:process,violationType:`process_channel`,strategy:`throw`,reason:`process.channel could access IPC channel to parent process`},{prop:`cpuUsage`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.cpuUsage could enable timing side-channel attacks`},{prop:`memoryUsage`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.memoryUsage could enable timing side-channel attacks`},{prop:`hrtime`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.hrtime could enable timing side-channel attacks`},{prop:`WeakRef`,target:globalThis,violationType:`weak_ref`,strategy:`throw`,reason:`WeakRef could be used to leak references outside sandbox`},{prop:`FinalizationRegistry`,target:globalThis,violationType:`finalization_registry`,strategy:`throw`,reason:`FinalizationRegistry could be used to leak references outside sandbox`},{prop:`Reflect`,target:globalThis,violationType:`reflect`,strategy:`freeze`,reason:`Reflect provides introspection capabilities`},{prop:`Proxy`,target:globalThis,violationType:`proxy`,strategy:`throw`,reason:`Proxy allows intercepting and modifying object behavior`},{prop:`WebAssembly`,target:globalThis,violationType:`webassembly`,strategy:`throw`,reason:`WebAssembly allows executing arbitrary compiled code`},{prop:`SharedArrayBuffer`,target:globalThis,violationType:`shared_array_buffer`,strategy:`throw`,reason:`SharedArrayBuffer could enable side-channel communication or timing attacks`},{prop:`Atomics`,target:globalThis,violationType:`atomics`,strategy:`throw`,reason:`Atomics could enable side-channel communication or timing attacks`},{prop:`performance`,target:globalThis,violationType:`performance_timing`,strategy:`throw`,reason:`performance.now() provides sub-millisecond timing for side-channel attacks`},{prop:`stdout`,target:process,violationType:`process_stdout`,strategy:`throw`,reason:`process.stdout could bypass interpreter output to write to host stdout`},{prop:`stderr`,target:process,violationType:`process_stderr`,strategy:`throw`,reason:`process.stderr could bypass interpreter output to write to host stderr`},{prop:`__defineGetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__defineGetter__ allows prototype pollution via getter injection`},{prop:`__defineSetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__defineSetter__ allows prototype pollution via setter injection`},{prop:`__lookupGetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__lookupGetter__ enables introspection for prototype pollution attacks`},{prop:`__lookupSetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__lookupSetter__ enables introspection for prototype pollution attacks`},{prop:`JSON`,target:globalThis,violationType:`json_mutation`,strategy:`freeze`,reason:`Freeze JSON to prevent mutation of parsing/serialization`},{prop:`Math`,target:globalThis,violationType:`math_mutation`,strategy:`freeze`,reason:`Freeze Math to prevent mutation of math utilities`}];try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&e.push({prop:`constructor`,target:Object.getPrototypeOf(async()=>{}),violationType:`async_function_constructor`,strategy:`throw`,reason:`AsyncFunction constructor allows arbitrary async code execution`})}catch{}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&e.push({prop:`constructor`,target:Object.getPrototypeOf(function*(){}),violationType:`generator_function_constructor`,strategy:`throw`,reason:`GeneratorFunction constructor allows arbitrary generator code execution`})}catch{}try{let t=Object.getPrototypeOf(async function*(){}).constructor;t&&t!==Function&&t!==Object.getPrototypeOf(async()=>{}).constructor&&e.push({prop:`constructor`,target:Object.getPrototypeOf(async function*(){}),violationType:`async_generator_function_constructor`,strategy:`throw`,reason:`AsyncGeneratorFunction constructor allows arbitrary async generator code execution`})}catch{}let t=e.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}});return Cn??=new Set(t.map(({violationType:e})=>e)),t}var Cn,wn=T(()=>{});function Tn(){return Math.floor(En+Dn())}var En,Dn,On=T(()=>{En=performance.timeOrigin,Dn=performance.now.bind(performance)});function kn(e){let t=e?.find(e=>jn.has(e));if(t)throw RangeError(`defenseInDepth.excludeViolationTypes cannot disable the non-excludable "${t}" protection`)}function An(e,t,n){let r=n&&!jn.has(t)?`
62
+
63
+ If this access is required by trusted host-runtime code, add "${t}" to defenseInDepth.excludeViolationTypes.`:``;return e+Mn+r}var jn,Mn,Nn=T(()=>{jn=new Set([`function_constructor`,`async_function_constructor`,`generator_function_constructor`,`async_generator_function_constructor`]),Mn=`
64
+
65
+ This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`});function Pn(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function Fn(e,t,...n){return Un.run(e,()=>t(...n))}function In(){return!zn&&typeof Vn?.registerHooks==`function`}function Ln(e){let t=typeof e==`boolean`?{enabled:e}:e??{};if(kn(t.excludeViolationTypes),t.enabled!==void 0&&t.enabled!==!0&&t.enabled!==!1&&t.enabled!==`auto`)throw RangeError(`defenseInDepth.enabled must be true, false, or "auto"`);let n={...Gn,...t},r=n.enabled===`auto`?`auto`:n.enabled?`enabled`:`disabled`,i={...n,enabled:r!==`disabled`,requested:r};return i.excludeViolationTypes&&=[...new Set(i.excludeViolationTypes)].sort(),i}function Rn(e,t){if(e.enabled!==t.enabled||e.auditMode!==t.auditMode||e.processLifetimeIntrinsicHardening!==t.processLifetimeIntrinsicHardening||e.onViolation!==t.onViolation)return!1;let n=e.excludeViolationTypes??[],r=t.excludeViolationTypes??[];return n.length===r.length&&n.every((e,t)=>e===r[t])}var zn,Bn,Vn,Hn,D,Un,Wn,Gn,Kn,qn=T(()=>{if(bn(),bn(),wn(),On(),Nn(),zn=!0,Bn=null,Vn=null,Hn=null,!zn)try{Bn=void 0,Vn=gn,Hn=Vn.Module??Vn.default??null}catch{}D=class extends Error{violation;constructor(e,t){super(An(e,t.type,t.type===`error_prepare_stack_trace`||xn().has(t.type))),this.violation=t,this.name=`SecurityViolationError`}},Un=!zn&&Bn?new Bn:null,Wn=1e3,Gn={enabled:!0,auditMode:!1,processLifetimeIntrinsicHardening:!1},Kn=class e{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];temporaryIntrinsicDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(t){let n=Ln(t);if(!e.instance)e.instance=new e(n);else{let t=e.instance.config;if(!Rn(n,t))throw Error(`DefenseInDepthBox config conflict: all resolved defense options, including exclusions and the violation callback, must match across Bash instances. Call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return e.instance}static resetInstance(){e.instance&&=(e.instance.forceDeactivate(),null),e.trustedExecutionDepth.clear()}static isInSandboxedContext(){return Un?Un?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(Un)return Un?.getStore()?.executionId}static enterTrustedScope(t){let n=e.trustedExecutionDepth.get(t)??0;e.trustedExecutionDepth.set(t,n+1)}static leaveTrustedScope(t){let n=e.trustedExecutionDepth.get(t);if(n){if(n===1){e.trustedExecutionDepth.delete(t);return}e.trustedExecutionDepth.set(t,n-1)}}static isTrustedScopeActive(t){return t?(e.trustedExecutionDepth.get(t)??0)>0:!1}static isTrustedContext(t){return!t||t.forceUntrusted?!1:t.trusted===!0||e.isTrustedScopeActive(t.executionId)}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}static bindCurrentContext(t){if(!Un)return t;let n=Un.getStore(),r=n?.sandboxActive===!0?n.executionId:void 0;if(!r)return t;let i=e.instance?.getCachedContext(r)??{sandboxActive:!0,executionId:r},a=n?.forceUntrusted?{...i,forceUntrusted:!0}:i;return((...n)=>{let i=e.instance;if(!(i&&!i.isExecutionIdActive(r)&&(i.recordViolation(`bound_callback_after_deactivate`,`bound callback`,`Bound callback blocked after originating execution was deactivated`),!i.config.auditMode)))return Fn(a,t,...n)})}isEnabled(){return this.getStatus().state===`enabled`}getStatus(){let e=In();return this.config.requested===`disabled`?{requested:`disabled`,state:`disabled`,level:`none`,contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?`process-lifetime`:`scoped-best-effort`}:!Un||zn?{requested:this.config.requested,state:`unsupported`,level:`none`,contextualDynamicImportProtection:!1,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?`process-lifetime`:`scoped-best-effort`,reason:`context-aware ESM loader hooks (node:module.registerHooks) are unavailable`}:{requested:this.config.requested,state:`enabled`,level:this.config.auditMode?`none`:e?`full`:`best-effort`,contextualDynamicImportProtection:e,processLifetimeIntrinsicHardening:this.config.processLifetimeIntrinsicHardening===!0,intrinsicProtection:this.config.processLifetimeIntrinsicHardening?`process-lifetime`:`scoped-best-effort`,reason:this.config.auditMode?`audit mode records violations but does not block them`:e?void 0:`best-effort protection; context-aware ESM loader hooks are unavailable`}}updateConfig(e){if(this.refCount>0)throw Error(`DefenseInDepthBox configuration cannot change while protection is active`);this.config=Ln({...this.config,...e})}activate(){if(!zn&&this.config.enabled&&!Un)throw Error(`DefenseInDepthBox: enabled protection requires node:async_hooks and node:module`);if(zn||!this.config.enabled){let e=Pn(),t=!1;return{run:e=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):e(),deactivate:()=>{t=!0},executionId:e}}if(this.refCount++,this.refCount===1){try{this.applyPatches()}catch(e){throw this.restorePatches(),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0,e}this.activationTime=Date.now()}let e=Pn(),t=!1;return{run:n=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):(this.activeExecutionIds.add(e),Un.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(t){if(!Un)return t();let n=Un.getStore();if(!n)return t();let{executionId:r}=n;return Un.run({...n,trusted:!0,forceUntrusted:!1},()=>{e.enterTrustedScope(r);try{let n=t();return typeof n==`object`&&n&&`finally`in n&&typeof n.finally==`function`?n.finally(()=>{e.leaveTrustedScope(r)}):(e.leaveTrustedScope(r),n)}catch(t){throw e.leaveTrustedScope(r),t}})}static async runTrustedAsync(t){if(!Un)return t();let n=Un.getStore();if(!n)return t();let{executionId:r}=n;return Un.run({...n,trusted:!0,forceUntrusted:!1},async()=>{e.enterTrustedScope(r);try{return await t()}finally{e.leaveTrustedScope(r)}})}static async runUntrustedAsync(e){if(!Un)return e();let t=Un.getStore();return t?Un.run({...t,trusted:!1,forceUntrusted:!0},e):e()}shouldBlock(){if(zn||this.config.auditMode||!Un)return!1;let t=Un?.getStore();return!(t?.sandboxActive!==!0||e.isTrustedContext(t))}shouldAudit(){if(!this.config.auditMode||!Un)return!1;let t=Un.getStore();return t?.sandboxActive===!0&&!e.isTrustedContext(t)}recordViolation(e,t,n){let r={timestamp:Tn(),type:e,message:n,path:t,stack:Error().stack,executionId:Un?.getStore()?.executionId};if(this.violations.length<Wn&&this.violations.push(r),this.config.onViolation)try{this.config.onViolation(r)}catch(e){console.debug(`[DefenseInDepthBox] onViolation callback threw:`,e instanceof Error?e.message:e)}return r}createBlockingProxy(e,t,n){let r=this;return new Proxy(e,{apply(e,i,a){if(r.shouldBlock()){let e=`${t} is blocked during script execution`,i=r.recordViolation(n,t,e);throw new D(e,i)}return r.shouldAudit()&&r.recordViolation(n,t,`${t} called (audit mode)`),Reflect.apply(e,i,a)},construct(e,i,a){if(r.shouldBlock()){let e=`${t} constructor is blocked during script execution`,i=r.recordViolation(n,t,e);throw new D(e,i)}return r.shouldAudit()&&r.recordViolation(n,t,`${t} constructor called (audit mode)`),Reflect.construct(e,i,a)}})}createBlockingObjectProxy(e,t,n,r){let i=this;return new Proxy(e,{get(e,a,o){if(i.shouldBlock()){if(r&&typeof a==`string`&&r.has(a))return Reflect.get(e,a,o);let s=`${t}.${String(a)}`,c=`${s} is blocked during script execution`,l=i.recordViolation(n,s,c);throw new D(c,l)}if(i.shouldAudit()){let e=`${t}.${String(a)}`;i.recordViolation(n,e,`${e} accessed (audit mode)`)}return Reflect.get(e,a,o)},set(e,r,a,o){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} modification is blocked during script execution`,o=i.recordViolation(n,e,a);throw new D(a,o)}return t===`process.env`&&r===`DEBUG`?Reflect.set(e,r,a):Reflect.set(e,r,a,o)},ownKeys(e){if(i.shouldBlock()){let e=`${t} enumeration is blocked during script execution`,r=i.recordViolation(n,t,e);throw new D(e,r)}return Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} descriptor access is blocked during script execution`,o=i.recordViolation(n,e,a);throw new D(a,o)}return Reflect.getOwnPropertyDescriptor(e,r)},has(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} existence check is blocked during script execution`,o=i.recordViolation(n,e,a);throw new D(a,o)}return Reflect.has(e,r)},deleteProperty(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} deletion is blocked during script execution`,o=i.recordViolation(n,e,a);throw new D(a,o)}return Reflect.deleteProperty(e,r)},setPrototypeOf(e,r){if(i.shouldBlock()){let e=`${t} setPrototypeOf is blocked during script execution`,r=i.recordViolation(n,t,e);throw new D(e,r)}return Reflect.setPrototypeOf(e,r)},defineProperty(e,r,a){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} defineProperty is blocked during script execution`,o=i.recordViolation(n,e,a);throw new D(a,o)}return Reflect.defineProperty(e,r,a)}})}createReadonlyObjectProxy(e,t,n){let r=this,i=e=>{let i=`${t} ${e} is blocked during script execution`,a=r.recordViolation(n,t,i);throw new D(i,a)};return new Proxy(e,{set(e,t,n,a){return r.shouldBlock()&&i(`modification`),Reflect.set(e,t,n,a)},defineProperty(e,t,n){return r.shouldBlock()&&i(`defineProperty`),Reflect.defineProperty(e,t,n)},deleteProperty(e,t){return r.shouldBlock()&&i(`deletion`),Reflect.deleteProperty(e,t)},setPrototypeOf(e,t){return r.shouldBlock()&&i(`setPrototypeOf`),Reflect.setPrototypeOf(e,t)},preventExtensions(e){return r.shouldBlock()&&i(`preventExtensions`),Reflect.preventExtensions(e)}})}applyPatches(){this.patchFailures=[];let e=Sn(),t=new Set(this.config.excludeViolationTypes??[]),n=new Set([`process_send`,`process_channel`,`process_stdout`,`process_stderr`]),r=[];for(let i of e)if(!t.has(i.violationType)&&!n.has(i.violationType)){if(i.strategy===`freeze`){r.push(i);continue}this.applyPatch(i)}this.protectConstructorChain(),t.has(`error_prepare_stack_trace`)||this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),In()&&this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.protectProxyRevocable();let i=[`Function.prototype.constructor`,`Module._load`,`Module._resolveFilename`],a=this.patchFailures.filter(e=>i.includes(e));if(a.length>0)throw this.restorePatches(),Error(`DefenseInDepthBox: critical patches failed: ${a.join(`, `)}`);this.config.processLifetimeIntrinsicHardening||this.protectReversibleIntrinsics(r);for(let e of r)this.applyPatch(e,this.config.processLifetimeIntrinsicHardening===!0);this.config.processLifetimeIntrinsicHardening&&this.lockWellKnownSymbols()}protectReversibleIntrinsics(e){let t=new Set,n=(e,t)=>{let n=Object.getOwnPropertyDescriptor(e,t);!n||!(`value`in n)||n.writable!==!0||n.configurable!==!0||(this.temporaryIntrinsicDescriptors.push({target:e,prop:t,descriptor:n}),Object.defineProperty(e,t,{...n,writable:!1}))};for(let{target:r,prop:i}of e){let e=r[i];if(!(typeof e!=`object`||!e)){t.add(e);for(let t of Reflect.ownKeys(e))n(e,t)}}let r=[];for(let e of[Array,Map,Set,RegExp,Promise])r.push([e,Symbol.species]);for(let e of[Array.prototype,String.prototype,Map.prototype,Set.prototype])r.push([e,Symbol.iterator]);r.push([Symbol.prototype,Symbol.toPrimitive],[Date.prototype,Symbol.toPrimitive],[Function.prototype,Symbol.hasInstance],[Array.prototype,Symbol.unscopables]);for(let e of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])r.push([RegExp.prototype,e]);for(let e of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])r.push([e,Symbol.toStringTag]);for(let[e,i]of r)t.add(e),n(e,i);let i=(e,n,r)=>{let i=Object.getOwnPropertyDescriptor(e,n);if(!i||!(`value`in i)||typeof i.value!=`function`||i.configurable!==!0)return;let a=i.value,o=this,s=function(...e){let i=e[0];if(o.shouldBlock()&&typeof i==`object`&&i&&t.has(i)){let e=`${r}.${n}`,t=`${e} is blocked for protected intrinsics during script execution`,i=o.recordViolation(`prototype_mutation`,e,t);throw new D(t,i)}return Reflect.apply(a,this,e)};this.temporaryIntrinsicDescriptors.push({target:e,prop:n,descriptor:i}),Object.defineProperty(e,n,{...i,value:s,writable:!1})};for(let e of[`assign`,`defineProperties`,`defineProperty`,`freeze`,`preventExtensions`,`seal`,`setPrototypeOf`])i(Object,e,`Object`);for(let e of[`defineProperty`,`deleteProperty`,`preventExtensions`,`set`,`setPrototypeOf`])i(Reflect,e,`Reflect`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,`Function.prototype.constructor`,`function_constructor`);try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`AsyncFunction.prototype.constructor`,`async_function_constructor`)}catch(e){this.patchFailures.push(`AsyncFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`GeneratorFunction.prototype.constructor`,`generator_function_constructor`)}catch(e){this.patchFailures.push(`GeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,`AsyncGeneratorFunction.prototype.constructor`,`async_generator_function_constructor`)}catch(e){this.patchFailures.push(`AsyncGeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,`prepareStackTrace`);this.originalDescriptors.push({target:Error,prop:`prepareStackTrace`,descriptor:t});let n=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(t){if(e.shouldBlock()){let t=`Error.prepareStackTrace modification is blocked during script execution`,n=e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,t);throw new D(t,n)}e.shouldAudit()&&e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,`Error.prepareStackTrace set (audit mode)`),n=t},configurable:!0})}catch(e){this.patchFailures.push(`Error.prepareStackTrace`),console.debug(`[DefenseInDepthBox] Could not protect Error.prepareStackTrace:`,e instanceof Error?e.message:e)}}protectPromiseThen(){let e=this;try{let t=function(...e){return Un.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation(`promise_then_after_deactivate`,`Promise.then`,`Promise.then callback is blocked after defense deactivation`),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,e);if(this.kind===`fulfilled`)return e[0];throw e[0]}return Reflect.apply(this.cb,void 0,e)})},n=Object.getOwnPropertyDescriptor(Promise.prototype,`then`);this.originalDescriptors.push({target:Promise.prototype,prop:`then`,descriptor:n});let r=n?.value;if(typeof r!=`function`)return;Object.defineProperty(Promise.prototype,"then",{value:function(n,i){if(!Un)return Reflect.apply(r,this,[n,i]);let a=Un.getStore(),o=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!o)return Reflect.apply(r,this,[n,i]);let s=e.getCachedContext(o),c=a?.forceUntrusted?{...s,forceUntrusted:!0}:s,l=(n,r)=>typeof n==`function`?t.bind({box:e,executionId:o,captured:c,cb:n,kind:r}):n;return Reflect.apply(r,this,[l(n,`fulfilled`),l(i,`rejected`)])},writable:!0,configurable:!0})}catch(e){this.patchFailures.push(`Promise.prototype.then`),console.debug(`[DefenseInDepthBox] Could not protect Promise.prototype.then:`,e instanceof Error?e.message:e)}}patchPrototypeConstructor(e,t,n){let r=this;try{let i=Object.getOwnPropertyDescriptor(e,`constructor`);this.originalDescriptors.push({target:e,prop:`constructor`,descriptor:i});let a=i?.value;Object.defineProperty(e,"constructor",{get(){if(r.shouldBlock()){let e=`${t} access is blocked during script execution`,i=r.recordViolation(n,t,e);throw new D(e,i)}return r.shouldAudit()&&r.recordViolation(n,t,`${t} accessed (audit mode)`),a},set(e){if(r.shouldBlock()){let e=`${t} modification is blocked during script execution`,i=r.recordViolation(n,t,e);throw new D(e,i)}Object.defineProperty(this,"constructor",{value:e,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,e instanceof Error?e.message:e)}}protectProcessMainModule(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`mainModule`);this.originalDescriptors.push({target:process,prop:`mainModule`,descriptor:t});let n=t?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let t=`process.mainModule access is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new D(t,n)}return e.shouldAudit()&&e.recordViolation(`process_main_module`,`process.mainModule`,`process.mainModule accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.mainModule modification is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new D(t,n)}Object.defineProperty(process,"mainModule",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.mainModule`),console.debug(`[DefenseInDepthBox] Could not protect process.mainModule:`,e instanceof Error?e.message:e)}}protectProcessExecPath(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`execPath`);this.originalDescriptors.push({target:process,prop:`execPath`,descriptor:t});let n=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let t=`process.execPath access is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new D(t,n)}return e.shouldAudit()&&e.recordViolation(`process_exec_path`,`process.execPath`,`process.execPath accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.execPath modification is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new D(t,n)}Object.defineProperty(process,"execPath",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.execPath`),console.debug(`[DefenseInDepthBox] Could not protect process.execPath:`,e instanceof Error?e.message:e)}}lockWellKnownSymbols(){let e=(e,t)=>{try{let n=Object.getOwnPropertyDescriptor(e,t);if(n?.configurable){if(`value`in n){Object.defineProperty(e,t,{...n,configurable:!1,writable:!1});return}Object.defineProperty(e,t,{...n,configurable:!1})}}catch{}};for(let t of[Array,Map,Set,RegExp,Promise])e(t,Symbol.species);for(let t of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(t,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let t of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,t);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let t of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(t,Symbol.toStringTag)}protectProxyRevocable(){let e=this;try{let t=Proxy.revocable;if(typeof t!=`function`)return;let n=Object.getOwnPropertyDescriptor(Proxy,`revocable`);this.originalDescriptors.push({target:Proxy,prop:`revocable`,descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(n,r){if(e.shouldBlock()){let t=`Proxy.revocable is blocked during script execution`,n=e.recordViolation(`proxy`,`Proxy.revocable`,t);throw new D(t,n)}return e.shouldAudit()&&e.recordViolation(`proxy`,`Proxy.revocable`,`Proxy.revocable called (audit mode)`),t(n,r)},writable:!1,configurable:!0})}catch(e){this.patchFailures.push(`Proxy.revocable`),console.debug(`[DefenseInDepthBox] Could not protect Proxy.revocable:`,e instanceof Error?e.message:e)}}protectDynamicImport(){if(!(zn||e.importHooksRegistered))try{let t=Vn;if(!t)throw Error(`node:module is unavailable`);let n=new Set;for(let e of t.builtinModules??[]){let t=e.startsWith(`node:`)?e.slice(5):e;n.add(t);let r=t.indexOf(`/`);r>0&&n.add(t.slice(0,r))}let r=e=>{if(e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/`)||e.startsWith(`file:`)||e.startsWith(`data:`)||e.startsWith(`blob:`)||e.startsWith(`http:`)||e.startsWith(`https:`))return!1;let r=e.startsWith(`node:`)?e.slice(5):e;if(!r)return!1;if(typeof t.isBuiltin==`function`&&t.isBuiltin(r)||n.has(r))return!0;let i=r.indexOf(`/`);return i>0&&n.has(r.slice(0,i))},i=t=>{let n=Un?.getStore();return t.config.auditMode===!0&&n?.sandboxActive===!0&&!e.isTrustedContext(n)};if(typeof t.registerHooks==`function`){t.registerHooks({resolve(t,n,a){let o=e.instance;if(!o)return a(t,n);if((t.startsWith(`data:`)||t.startsWith(`blob:`))&&o.shouldBlock()){let e=`import(${t.startsWith(`data:`)?`data:`:`blob:`})`,n=`dynamic import of ${t.startsWith(`data:`)?`data:`:`blob:`} URLs is blocked by defense-in-depth`,r=o.recordViolation(`dynamic_import_builtin`,e,n);throw new D(n,r)}if(r(t)){let e=`import(${t})`,n=`dynamic import of Node.js builtin '${t}' is blocked during script execution`;if(o.shouldBlock()){let t=o.recordViolation(`dynamic_import_builtin`,e,n);throw new D(n,t)}i(o)&&o.recordViolation(`dynamic_import_builtin`,e,`dynamic import of Node.js builtin '${t}' called (audit mode)`)}return a(t,n)}}),e.importHooksRegistered=!0;return}throw Error(`context-aware ESM loader hooks (node:module.registerHooks) are unavailable`)}catch(e){throw Error(`DefenseInDepthBox: could not register dynamic-import hooks: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}protectModuleLoad(){this.protectModuleMethod(`_load`,`module_load`)}protectModuleResolveFilename(){this.protectModuleMethod(`_resolveFilename`,`module_resolve_filename`)}protectModuleMethod(e,t){if(zn)return;let n=`Module.${e}`;try{let r=Hn,i=r?.[e];if(!r||typeof i!=`function`)throw Error(`node:module Module class or method is unavailable`);let a=Object.getOwnPropertyDescriptor(r,e);if(!a)throw Error(`method has no own property descriptor`);if(a.configurable===!1&&a.writable===!1)throw Error(`method is non-configurable and non-writable`);let o=this.createBlockingProxy(i,n,t);this.originalDescriptors.push({target:r,prop:e,descriptor:a}),Object.defineProperty(r,e,{...a,value:o});let s=Object.getOwnPropertyDescriptor(r,e);if(r[e]!==o||s?.value!==o)throw Error(`installed patch failed verification`)}catch{this.patchFailures.push(n)}}applyPatch(e,t=!1){let{target:n,prop:r,violationType:i,strategy:a}=e;try{let o=n[r];if(o===void 0)return;let s=Object.getOwnPropertyDescriptor(n,r);if(this.originalDescriptors.push({target:n,prop:r,descriptor:s}),a===`freeze`){if(typeof o==`object`&&o){t&&Object.freeze(o);let e=this.getPathForTarget(n,r),a=this.createReadonlyObjectProxy(o,e,i);Object.defineProperty(n,r,{...s,value:a})}}else{let t=this.getPathForTarget(n,r),a=typeof o==`function`?this.createBlockingProxy(o,t,i):this.createBlockingObjectProxy(o,t,i,e.allowedKeys);Object.defineProperty(n,r,{value:a,writable:!0,configurable:!0})}}catch(e){let t=this.getPathForTarget(n,r);this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,e instanceof Error?e.message:e)}}restorePatches(){for(let e=this.temporaryIntrinsicDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:r}=this.temporaryIntrinsicDescriptors[e];try{Object.defineProperty(t,n,r)}catch(e){console.debug(`[DefenseInDepthBox] Could not restore temporary intrinsic ${String(n)}:`,e instanceof Error?e.message:e)}}this.temporaryIntrinsicDescriptors=[];for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:r}=this.originalDescriptors[e];try{r?Object.defineProperty(t,n,r):delete t[n]}catch(e){let r=this.getPathForTarget(t,n);console.debug(`[DefenseInDepthBox] Could not restore ${r}:`,e instanceof Error?e.message:e)}}this.originalDescriptors=[]}}});function Jn(e){return typeof e==`function`?Kn.bindCurrentContext(e):e}function Yn(e,t){if(t===1/0)return;let n=Jn(e),r={cleared:!1,remainingMs:Math.max(0,t),timer:void 0},i=()=>{if(r.cleared)return;let e=Math.min(r.remainingMs,tr);r.timer=Zn(()=>{r.cleared||(r.remainingMs-=e,r.remainingMs>0?i():n())},e)};return i(),r}function Xn(e){e&&(e.cleared=!0,e.timer!==void 0&&Qn(e.timer))}var Zn,Qn,$n,er,tr,nr=T(()=>{qn(),Zn=globalThis.setTimeout.bind(globalThis),Qn=globalThis.clearTimeout.bind(globalThis),globalThis.setInterval.bind(globalThis),globalThis.clearInterval.bind(globalThis),$n=((e,t,...n)=>Zn(Jn(e),t,...n)),er=Qn,tr=2147483647});function rr(...e){let t=[...new Set(e.filter(e=>e!==void 0))];if(t.length===0)return{signal:void 0,cleanup(){}};if(t.length===1)return{signal:t[0],cleanup(){}};let n=new AbortController,r=[];for(let e of t){if(e.aborted){n.abort(e.reason);break}let t=()=>n.abort(e.reason);e.addEventListener(`abort`,t,{once:!0}),r.push([e,t])}return{signal:n.signal,cleanup(){for(let[e,t]of r)e.removeEventListener(`abort`,t)}}}var ir=T(()=>{});function ar(e,t,n){if(!Number.isSafeInteger(e)||e<0||!Number.isSafeInteger(t)||t<0||e>t)throw RangeError(`${n}: byte conversion limit exceeded (${t} bytes)`)}function O(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<=127)t++;else if(r<=2047)t+=2;else if(r>=55296&&r<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=4,n++):t+=3}else t+=3}return t}function or(e,t=hr){let n=e;if(!n)return n;ar(n.length,t,`UTF-8 decode`);let r=!1;for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);if(t>255)return n;t>127&&(r=!0)}if(!r)return n;let i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);try{return pr.decode(i)}catch{return n}}function sr(e,t=hr){if(!e)return e;ar(O(e),t,`UTF-8 encode`);let n=mr.encode(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return r}function cr(e,t=hr){ar(e.byteLength,t,`byte-string conversion`);let n=``;for(let t=0;t<e.length;t++)n+=String.fromCharCode(e[t]);return n}async function lr(e,t){return typeof e.readFileBytes==`function`?e.readFileBytes(t):cr(await e.readFileBuffer(t))}function ur(e){return e.stdoutKind?e.stdoutKind:e.stdoutEncoding===`binary`?`bytes`:`text`}function dr(e){return ur(e)===`bytes`?e.stdout:sr(e.stdout)}function fr(e){return ur(e)===`bytes`?or(e.stdout):e.stdout}var pr,mr,hr,gr,k=T(()=>{pr=new TextDecoder(`utf-8`,{fatal:!0}),mr=new TextEncoder,hr=536870912,gr=``});function _r(e){return e instanceof yr||e instanceof br||e instanceof xr}var vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,A,kr,Ar,jr,j=T(()=>{k(),vr=class extends Error{stdout;stderr;internalOutputAccounting={stdout:0,stderr:0};constructor(e,t=``,n=``){super(e),this.stdout=t,this.stderr=n}prependOutput(e,t){this.stdout=e+this.stdout,this.stderr=t+this.stderr,this.internalOutputAccounting.stdout+=O(e),this.internalOutputAccounting.stderr+=O(t)}},yr=class extends vr{levels;name=`BreakError`;constructor(e=1,t=``,n=``){super(`break`,t,n),this.levels=e}},br=class extends vr{levels;name=`ContinueError`;constructor(e=1,t=``,n=``){super(`continue`,t,n),this.levels=e}},xr=class extends vr{exitCode;name=`ReturnError`;constructor(e=0,t=``,n=``){super(`return`,t,n),this.exitCode=e}},Sr=class extends vr{exitCode;name=`ErrexitError`;constructor(e,t=``,n=``){super(`errexit: command exited with status ${e}`,t,n),this.exitCode=e}},Cr=class extends vr{varName;name=`NounsetError`;constructor(e,t=``){super(`${e}: unbound variable`,t,`bash: ${e}: unbound variable
66
+ `),this.varName=e}},wr=class extends vr{exitCode;name=`ExitError`;constructor(e,t=``,n=``){super(`exit`,t,n),this.exitCode=e}},Tr=class extends vr{name=`ArithmeticError`;fatal;constructor(e,t=``,n=``,r=!1){super(e,t,n),this.stderr=n||`bash: ${e}
67
+ `,this.fatal=r}},Er=class extends vr{name=`BadSubstitutionError`;constructor(e,t=``,n=``){super(e,t,n),this.stderr=n||`bash: ${e}: bad substitution
68
+ `}},Dr=class extends vr{name=`GlobError`;constructor(e,t=``,n=``){super(`no match: ${e}`,t,n),this.stderr=n||`bash: no match: ${e}
69
+ `}},Or=class extends vr{name=`BraceExpansionError`;constructor(e,t=``,n=``){super(e,t,n),this.stderr=n||`bash: ${e}
70
+ `}},A=class extends vr{limitType;name=`ExecutionLimitError`;static EXIT_CODE=126;constructor(e,t,n=``,r=``){super(e,n,r),this.limitType=t,this.stderr=r||`bash: ${e}
71
+ `}},kr=class extends vr{name=`ExecutionAbortedError`;constructor(e=``,t=``){super(`execution aborted`,e,t)}},Ar=class extends vr{name=`SubshellExitError`;constructor(e=``,t=``){super(`subshell exit`,e,t)}},jr=class extends vr{exitCode;name=`PosixFatalError`;constructor(e,t=``,n=``){super(`posix fatal error`,t,n),this.exitCode=e}}});function Mr(e,t,n){let r=n===`width`?Math.abs(e):e;if(!Number.isFinite(e)||!Number.isSafeInteger(e)||r<0||r>t)throw new A(`format ${n} limit exceeded (${t} bytes)`,`string_length`)}function Nr(e,t,n,r=Ir){Mr(t,r,`width`),n!==-1&&Mr(n,r,`precision`);let i=e;n>=0&&i.length>n&&(i=i.slice(0,n));let a=Math.abs(t);if(a>i.length){if(O(i)+a-i.length>r)throw new A(`formatted value size limit exceeded (${r} bytes)`,`string_length`);i=t<0?i.padEnd(a,` `):i.padStart(a,` `)}if(O(i)>r)throw new A(`formatted value size limit exceeded (${r} bytes)`,`string_length`);return i}function Pr(e,t,n=Ir){let r=t,i=0,a=-1,o=!1;for(r<e.length&&e[r]===`-`&&(o=!0,r++);r<e.length&&/\d/.test(e[r]);)i=i*10+parseInt(e[r],10),r++;if(r<e.length&&e[r]===`.`)for(r++,a=0;r<e.length&&/\d/.test(e[r]);)a=a*10+parseInt(e[r],10),r++;return o&&i>0&&(i=-i),Mr(i,n,`width`),a!==-1&&Mr(a,n,`precision`),[i,a,r-t]}function Fr(e,t=Ir){if(O(e)>t)throw new A(`escaped string size limit exceeded (${t} bytes)`,`string_length`);let n=``,r=0;for(;r<e.length;)if(e[r]===`\\`&&r+1<e.length)switch(e[r+1]){case`n`:n+=`
72
+ `,r+=2;break;case`t`:n+=` `,r+=2;break;case`r`:n+=`\r`,r+=2;break;case`\\`:n+=`\\`,r+=2;break;case`a`:n+=`\x07`,r+=2;break;case`b`:n+=`\b`,r+=2;break;case`f`:n+=`\f`,r+=2;break;case`v`:n+=`\v`,r+=2;break;case`e`:case`E`:n+=`\x1B`,r+=2;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let t=``,i=r+1;for(;i<e.length&&i<r+4&&/[0-7]/.test(e[i]);)t+=e[i],i++;n+=String.fromCharCode(parseInt(t,8)),r=i;break}case`x`:{let t=[],i=r;for(;i+3<e.length&&e[i]===`\\`&&e[i+1]===`x`&&/[0-9a-fA-F]{2}/.test(e.slice(i+2,i+4));)t.push(parseInt(e.slice(i+2,i+4),16)),i+=4;if(t.length>0){try{let e=new TextDecoder(`utf-8`,{fatal:!0});n+=e.decode(new Uint8Array(t))}catch{for(let e of t)n+=String.fromCharCode(e)}r=i}else n+=e[r],r++;break}case`u`:{let t=``,i=r+2;for(;i<e.length&&i<r+6&&/[0-9a-fA-F]/.test(e[i]);)t+=e[i],i++;t?(n+=String.fromCodePoint(parseInt(t,16)),r=i):(n+=`\\u`,r+=2);break}case`U`:{let t=``,i=r+2;for(;i<e.length&&i<r+10&&/[0-9a-fA-F]/.test(e[i]);)t+=e[i],i++;t?(n+=String.fromCodePoint(parseInt(t,16)),r=i):(n+=`\\U`,r+=2);break}default:n+=e[r],r++}else n+=e[r],r++;return n}var Ir,Lr=T(()=>{k(),j(),k(),Ir=10485760}),Rr={};E(Rr,{echoCommand:()=>Br,flagsForFuzzing:()=>Vr});function zr(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`\\`){if(n+1>=e.length){t+=`\\`;break}let r=e[n+1];switch(r){case`\\`:t+=`\\`,n+=2;break;case`n`:t+=`
73
+ `,n+=2;break;case`t`:t+=` `,n+=2;break;case`r`:t+=`\r`,n+=2;break;case`a`:t+=`\x07`,n+=2;break;case`b`:t+=`\b`,n+=2;break;case`f`:t+=`\f`,n+=2;break;case`v`:t+=`\v`,n+=2;break;case`e`:case`E`:t+=`\x1B`,n+=2;break;case`c`:return{output:t,stop:!0};case`0`:{let r=``,i=n+2;for(;i<e.length&&i<n+5&&/[0-7]/.test(e[i]);)r+=e[i],i++;if(r.length===0)t+=`\0`;else{let e=parseInt(r,8)%256;t+=String.fromCharCode(e)}n=i;break}case`x`:{let r=``,i=n+2;for(;i<e.length&&i<n+4&&/[0-9a-fA-F]/.test(e[i]);)r+=e[i],i++;if(r.length===0)t+=`\\x`,n+=2;else{let e=parseInt(r,16);t+=String.fromCharCode(e),n=i}break}case`u`:{let r=``,i=n+2;for(;i<e.length&&i<n+6&&/[0-9a-fA-F]/.test(e[i]);)r+=e[i],i++;if(r.length===0)t+=`\\u`,n+=2;else{let e=parseInt(r,16);t+=String.fromCodePoint(e),n=i}break}case`U`:{let r=``,i=n+2;for(;i<e.length&&i<n+10&&/[0-9a-fA-F]/.test(e[i]);)r+=e[i],i++;if(r.length===0)t+=`\\U`,n+=2;else{let e=parseInt(r,16);try{t+=String.fromCodePoint(e)}catch{t+=`\\U${r}`}n=i}break}default:t+=`\\${r}`,n+=2}}else t+=e[n],n++;return{output:t,stop:!1}}var Br,Vr,Hr=T(()=>{Br={name:`echo`,async execute(e,t){let n=!1,r=t.xpgEcho??!1,i=0;for(;i<e.length;){let t=e[i];if(t===`-n`)n=!0,i++;else if(t===`-e`)r=!0,i++;else if(t===`-E`)r=!1,i++;else if(t===`-ne`||t===`-en`)n=!0,r=!0,i++;else break}let a=e.slice(i).join(` `);if(r){let e=zr(a);if(a=e.output,e.stop)return{stdout:a,stderr:``,exitCode:0,internalStdinConsumed:0}}return n||(a+=`
74
+ `),{stdout:a,stderr:``,exitCode:0,internalStdinConsumed:0}}},Vr={name:`echo`,flags:[{flag:`-n`,type:`boolean`},{flag:`-e`,type:`boolean`},{flag:`-E`,type:`boolean`}],stdinType:`none`,needsArgs:!0}});function Ur(e){if(e instanceof A||e instanceof kr||e instanceof D)throw e}var Wr=T(()=>{j(),qn()});function M(e){let t=`${e.name} - ${e.summary}
75
+
76
+ `;if(t+=`Usage: ${e.usage}
77
+ `,e.description){if(t+=`
78
+ Description:
79
+ `,typeof e.description==`string`)for(let n of e.description.split(`
80
+ `))t+=n?` ${n}
81
+ `:`
82
+ `;else if(e.description.length>0)for(let n of e.description)t+=n?` ${n}
83
+ `:`
84
+ `}if(e.options&&e.options.length>0){t+=`
85
+ Options:
86
+ `;for(let n of e.options)t+=` ${n}
87
+ `}if(e.examples&&e.examples.length>0){t+=`
88
+ Examples:
89
+ `;for(let n of e.examples)t+=` ${n}
90
+ `}if(e.notes&&e.notes.length>0){t+=`
91
+ Notes:
92
+ `;for(let n of e.notes)t+=` ${n}
93
+ `}return{stdout:t,stderr:``,exitCode:0}}function N(e){return e.includes(`--help`)}function P(e,t){return{stdout:``,stderr:t.startsWith(`--`)?`${e}: unrecognized option '${t}'
94
+ `:`${e}: invalid option -- '${t.replace(/^-/,``)}'
95
+ `,exitCode:1}}var F=T(()=>{});function Gr(e,t,n){let r=new Map,i=new Map;for(let[e,t]of Object.entries(n)){let n={name:e,type:t.type};t.short&&r.set(t.short,n),t.long&&i.set(t.long,n)}let a=Object.create(null);for(let[e,t]of Object.entries(n))t.default===void 0?t.type===`boolean`&&(a[e]=!1):a[e]=t.default;let o=[],s=!1;for(let n=0;n<t.length;n++){let c=t[n];if(s||!c.startsWith(`-`)||c===`-`){o.push(c);continue}if(c===`--`){s=!0;continue}if(c.startsWith(`--`)){let r=c.indexOf(`=`),o,s;r===-1?o=c.slice(2):(o=c.slice(2,r),s=c.slice(r+1));let l=i.get(o);if(!l)return{ok:!1,error:P(e,c)};let{name:u,type:d}=l;if(d===`boolean`)a[u]=!0;else{if(s===void 0){if(n+1>=t.length)return{ok:!1,error:{stdout:``,stderr:`${e}: option '--${o}' requires an argument
96
+ `,exitCode:1}};s=t[++n]}a[u]=d===`number`?parseInt(s,10):s}}else{let i=c.slice(1);for(let o=0;o<i.length;o++){let s=i[o],c=r.get(s);if(!c)return{ok:!1,error:P(e,`-${s}`)};let{name:l,type:u}=c;if(u===`boolean`)a[l]=!0;else{let r;if(o+1<i.length)r=i.slice(o+1);else if(n+1<t.length)r=t[++n];else return{ok:!1,error:{stdout:``,stderr:`${e}: option requires an argument -- '${s}'
97
+ `,exitCode:1}};a[l]=u===`number`?parseInt(r,10):r;break}}}}return{ok:!0,result:{flags:a,positional:o}}}var Kr=T(()=>{F()}),qr=T(()=>{});function Jr(e,t,n){if(!Number.isSafeInteger(t)||t<0||t>e.limits.maxInputBytes)throw new A(`${n}: input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);e.executionScope?.consumeInput(t,n)}async function Yr(e,t,n){let{cmdName:r,allowStdinMarker:i=!0,stopOnError:a=!1,batchSize:o=100}=n;if(t.length===0)return{files:[{filename:``,content:e.stdin}],stderr:``,exitCode:0};let s=[],c=``,l=0;for(let n=0;n<t.length;n+=o){let u=t.slice(n,n+o),d=await Promise.all(u.map(async t=>{if(i&&t===`-`)return{filename:`-`,content:e.stdin,error:null};try{let n=e.fs.resolvePath(e.cwd,t);return{filename:t,content:await lr(e.fs,n),error:null}}catch{return{filename:t,content:gr,error:`${r}: ${t}: No such file or directory
98
+ `}}}));for(let e of d)if(e.error){if(c+=e.error,l=1,a)return{files:s,stderr:c,exitCode:l}}else s.push({filename:e.filename,content:e.content})}return{files:s,stderr:c,exitCode:l}}async function Xr(e,t,n){let r=await Yr(e,t,{...n,stopOnError:!0});return r.exitCode===0?{ok:!0,content:r.files.map(e=>e.content).join(``)}:{ok:!1,error:{stdout:``,stderr:r.stderr,exitCode:r.exitCode}}}var Zr=T(()=>{k(),j(),qr()}),Qr={};E(Qr,{catCommand:()=>ii,flagsForFuzzing:()=>ai});function $r(e){if(e>=32){if(e<127)return String.fromCharCode(e);if(e===127)return`^?`;let t=e-128;return t>=32?t===127?`M-^?`:`M-${String.fromCharCode(t)}`:`M-^${String.fromCharCode(t+64)}`}return`^${String.fromCharCode(e+64)}`}function ei(e,t,n){if(!t.showNonprinting&&!t.showTabs)return e;let r=``,i=e=>{if(e.length>n-r.length)throw new A(`cat: output size limit exceeded`,`output_size`);r+=e};for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r===9?i(t.showTabs?`^I`:` `):t.showNonprinting?i($r(r)):i(e[n])}return r}function ti(e,t,n,r){let i=1;for(let t=0;t<e.length;t++)if(e.charCodeAt(t)===10&&i++,i>r)throw new A(`cat: array element limit exceeded (${r})`,`array_elements`);let a=e.split(`
99
+ `),o=``,s=1,c=!1,l=e=>{if(e.length>n-o.length)throw new A(`cat: output size limit exceeded (${n} bytes)`,`output_size`);o+=e};for(let e=0;e<a.length;e++){let r=e===a.length-1,i=!r,u=a[e];if(r&&u===``)break;let d=u===``;if(t.squeeze&&d&&c)continue;c=d;let f=``;(t.numberAll||t.numberNonblank&&!d)&&(f=`${String(s).padStart(6,` `)} `,s++);let p=n-o.length-f.length;if(p<0)throw new A(`cat: output size limit exceeded (${n} bytes)`,`output_size`);l(f+ei(u,t,p)),i&&l(t.showEnds?`$
100
+ `:`
101
+ `)}return o}var ni,ri,ii,ai,oi=T(()=>{k(),Wr(),j(),Kr(),Zr(),F(),ni={name:`cat`,summary:`concatenate files and print on the standard output`,usage:`cat [OPTION]... [FILE]...`,options:[`-A, --show-all equivalent to -vET`,`-b, --number-nonblank number nonempty output lines, overrides -n`,`-e equivalent to -vE`,`-E, --show-ends display $ at end of each line`,`-n, --number number all output lines`,`-s, --squeeze-blank suppress repeated empty output lines`,`-t equivalent to -vT`,`-T, --show-tabs display TAB characters as ^I`,`-u (ignored)`,`-v, --show-nonprinting use ^ and M- notation, except for LFD and TAB`,` --help display this help and exit`]},ri={number:{short:`n`,long:`number`,type:`boolean`},numberNonblank:{short:`b`,long:`number-nonblank`,type:`boolean`},showEnds:{short:`E`,long:`show-ends`,type:`boolean`},showTabs:{short:`T`,long:`show-tabs`,type:`boolean`},showNonprinting:{short:`v`,long:`show-nonprinting`,type:`boolean`},showAll:{short:`A`,long:`show-all`,type:`boolean`},squeeze:{short:`s`,long:`squeeze-blank`,type:`boolean`},vE:{short:`e`,type:`boolean`},vT:{short:`t`,type:`boolean`},ignored:{short:`u`,type:`boolean`}},ii={name:`cat`,async execute(e,t){if(N(e))return M(ni);let n=Gr(`cat`,e,ri);if(!n.ok)return n.error;let r=n.result.flags,i=r.showEnds||r.showAll||r.vE,a=r.showTabs||r.showAll||r.vT,o=r.showNonprinting||r.showAll||r.vE||r.vT,s=r.squeeze,c=r.numberNonblank,l=r.number&&!c,u={numberAll:l,numberNonblank:c,showEnds:i,showTabs:a,showNonprinting:o,squeeze:s},d=n.result.positional,f=t.limits.maxStringLength,p=Math.min(f,t.limits.maxOutputSize),m=d.length===0?[`-`]:d,h=``,g=0,_=0,v,y=i||a||o||s||l||c,b=``;for(let e of m)try{let n=e===`-`?t.stdin:await lr(t.fs,t.fs.resolvePath(t.cwd,e)),r=n.length,i=Math.min(y?f:p,t.limits.maxInputBytes);if(r>i-_)throw new A(`cat: ${y?`input`:`output`} size limit exceeded (${i} bytes)`,y?`string_length`:`output_size`);e!==`-`&&Jr(t,r,`cat`),_+=r,b+=n}catch(t){Ur(t),h+=`cat: ${e}: No such file or directory
102
+ `,g=1}return v=y?ti(b,u,p,t.limits.maxArrayElements):b,{stdout:v,stderr:h,exitCode:g,stdoutEncoding:`binary`}}},ai={name:`cat`,flags:[{flag:`-n`,type:`boolean`},{flag:`-A`,type:`boolean`},{flag:`-b`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-e`,type:`boolean`},{flag:`-t`,type:`boolean`}],stdinType:`text`,needsFiles:!0}});function si(e){return e instanceof Error?e.message:String(e)}var ci=T(()=>{});function li(e,t,n,r={}){let i=new Date(t*1e3),a=ui(i,n),o=``,s=0,c=0,l=0,u=new Map,d=e=>{let t=O(e);if(r.maxOutputBytes!==void 0&&t>r.maxOutputBytes-s)throw new A(`strftime: output size limit exceeded (${r.maxOutputBytes} bytes)`,`output_size`);o+=e,s+=t};for(;c<e.length;){if(l++,r.maxOperations!==void 0&&l>r.maxOperations)throw new A(`strftime: iteration limit exceeded (${r.maxOperations})`,`iterations`);if(e[c]===`%`&&c+1<e.length){let t=e[c+1],r;u.has(t)?r=u.get(t)??null:(r=di(i,a,t,n),u.set(t,r)),r===null?(d(e[c]),c++):(d(r),c+=2)}else d(e[c]),c++}return o}function ui(e,t){let n={year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,weekday:`short`,hour12:!1,timeZone:t};try{let t=new Intl.DateTimeFormat(`en-US`,n).formatToParts(e),r=e=>t.find(t=>t.type===e)?.value??``,i=new Map([[`Sun`,0],[`Mon`,1],[`Tue`,2],[`Wed`,3],[`Thu`,4],[`Fri`,5],[`Sat`,6]]),a=r(`weekday`),o=(e,t)=>{let n=Number.parseInt(e,10);return Number.isNaN(n)?t:n};return{year:o(r(`year`),e.getFullYear()),month:o(r(`month`),e.getMonth()+1),day:o(r(`day`),e.getDate()),hour:o(r(`hour`),e.getHours())%24,minute:o(r(`minute`),e.getMinutes()),second:o(r(`second`),e.getSeconds()),weekday:i.get(a)??e.getDay()}}catch{return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),weekday:e.getDay()}}}function di(e,t,n,r){let i=(e,t=2)=>String(e).padStart(t,`0`),a=mi(t.year,t.month,t.day),o=hi(t.year,t.month,t.day,t.weekday,0),s=hi(t.year,t.month,t.day,t.weekday,1);switch(n){case`a`:return[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.weekday];case`A`:return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`][t.weekday];case`b`:case`h`:return[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.month-1];case`B`:return[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`][t.month-1];case`c`:return`${[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.weekday]} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.month-1]} ${String(t.day).padStart(2,` `)} ${i(t.hour)}:${i(t.minute)}:${i(t.second)} ${t.year}`;case`C`:return i(Math.floor(t.year/100));case`d`:return i(t.day);case`D`:return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case`e`:return String(t.day).padStart(2,` `);case`F`:return`${t.year}-${i(t.month)}-${i(t.day)}`;case`g`:return i(_i(t.year,t.month,t.day)%100);case`G`:return String(_i(t.year,t.month,t.day));case`H`:return i(t.hour);case`I`:return i(t.hour%12||12);case`j`:return String(a).padStart(3,`0`);case`k`:return String(t.hour).padStart(2,` `);case`l`:return String(t.hour%12||12).padStart(2,` `);case`m`:return i(t.month);case`M`:return i(t.minute);case`n`:return`
103
+ `;case`N`:return`000000000`;case`p`:return t.hour<12?`AM`:`PM`;case`P`:return t.hour<12?`am`:`pm`;case`r`:return`${i(t.hour%12||12)}:${i(t.minute)}:${i(t.second)} ${t.hour<12?`AM`:`PM`}`;case`R`:return`${i(t.hour)}:${i(t.minute)}`;case`s`:return String(Math.floor(e.getTime()/1e3));case`S`:return i(t.second);case`t`:return` `;case`T`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`u`:return String(t.weekday===0?7:t.weekday);case`U`:return i(o);case`V`:return i(gi(t.year,t.month,t.day));case`w`:return String(t.weekday);case`W`:return i(s);case`x`:return`${i(t.month)}/${i(t.day)}/${i(t.year%100)}`;case`X`:return`${i(t.hour)}:${i(t.minute)}:${i(t.second)}`;case`y`:return i(t.year%100);case`Y`:return String(t.year);case`z`:return fi(e,r);case`Z`:return pi(e,r);case`%`:return`%`;default:return null}}function fi(e,t){if(!t){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.floor(Math.abs(t)/60),i=Math.abs(t)%60;return`${n}${String(r).padStart(2,`0`)}${String(i).padStart(2,`0`)}`}try{let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`longOffset`}).formatToParts(e).find(e=>e.type===`timeZoneName`);if(n){let e=n.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(e)return`${e[1]}${e[2]}${e[3]}`;if(n.value===`GMT`||n.value===`UTC`)return`+0000`}}catch{}let n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`,i=Math.floor(Math.abs(n)/60),a=Math.abs(n)%60;return`${r}${String(i).padStart(2,`0`)}${String(a).padStart(2,`0`)}`}function pi(e,t){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:t,timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??`UTC`}catch{return`UTC`}}function mi(e,t,n){let r=[31,28,31,30,31,30,31,31,30,31,30,31];(e%4==0&&e%100!=0||e%400==0)&&(r[1]=29);let i=n;for(let e=0;e<t-1;e++)i+=r[e];return i}function hi(e,t,n,r,i){let a=mi(e,t,n),o=new Date(e,0,1).getDay(),s=a-(1+(7+i-o)%7);return s<0?0:Math.floor(s/7)+1}function gi(e,t,n){let r=new Date(e,t-1,n,12,0,0);r.setDate(r.getDate()+3-(r.getDay()+6)%7);let i=new Date(r.getFullYear(),0,4);i.setDate(i.getDate()+3-(i.getDay()+6)%7);let a=r.getTime()-i.getTime();return 1+Math.round(a/6048e5)}function _i(e,t,n){let r=new Date(e,t-1,n,12,0,0);return r.setDate(r.getDate()+3-(r.getDay()+6)%7),r.getFullYear()}var vi=T(()=>{j(),Lr()}),yi={};E(yi,{flagsForFuzzing:()=>Ii,printfCommand:()=>Pi});function bi(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function xi(e,t,n,r,i=10485760){let a=``,o=0,s=0,c=!1,l=``,u=0,d=e=>{let t=O(e);if(t>i-u)throw new A(`printf: output size limit exceeded (${i} bytes)`,`string_length`);a+=e,u+=t};for(;o<e.length;)if(e[o]===`%`&&o+1<e.length){let f=o;if(o++,e[o]===`%`){d(`%`),o++;continue}let p=e.slice(f).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(p){let e=p[1]?parseInt(p[1],10):0,a=p[2]?parseInt(p[2],10):-1;Mr(e,i,`width`),a!==-1&&Mr(a,i,`precision`);let c=p[3],l=p[0],m=t[n+s]||``;s++;let h;h=m===``||m===`-1`||m===`-2`?Math.floor(Date.now()/1e3):parseInt(m,10)||0;let g=li(c,h,r,{maxOperations:i-u,maxOutputBytes:i-u});g=Nr(g,e,a,i-u),d(g),o=f+l.length;continue}for(;o<e.length&&`+-0 #'`.includes(e[o]);)o++;let m=!1;if(e[o]===`*`)m=!0,o++;else for(;o<e.length&&/\d/.test(e[o]);)o++;let h=!1;if(e[o]===`.`)if(o++,e[o]===`*`)h=!0,o++;else for(;o<e.length&&/\d/.test(e[o]);)o++;o<e.length&&`hlL`.includes(e[o])&&o++;let g=e[o]||``;o++;let _=e.slice(f,o);if(m){let e=parseInt(t[n+s]||`0`,10);Mr(e,i-u,`width`),s++,_=_.replace(`*`,String(e))}if(h){let e=parseInt(t[n+s]||`0`,10);e>=0?Mr(e,i-u,`precision`):Number.isSafeInteger(e)||Mr(e,i-u,`precision`),s++,_=_.replace(`.*`,`.${e}`)}Ci(_,i-u);let v=t[n+s]||``;s++;let{value:y,parseError:b,parseErrMsg:x,stopped:S}=Si(_,g,v,i-u);if(d(y),b&&(c=!0,x&&(l=x)),S)return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!0}}else d(e[o]),o++;return{result:a,argsConsumed:s,error:c,errMsg:l,stopped:!1}}function Si(e,t,n,i){let a=!1,o=``;switch(t){case`d`:case`i`:{let t=wi(n);return a=Fi,a&&(o=`printf: ${n}: invalid number
104
+ `),{value:Ti(e,t),parseError:a,parseErrMsg:o}}case`o`:{let t=wi(n);return a=Fi,a&&(o=`printf: ${n}: invalid number
105
+ `),{value:Ei(e,t),parseError:a,parseErrMsg:o}}case`u`:{let t=wi(n);a=Fi,a&&(o=`printf: ${n}: invalid number
106
+ `);let r=t<0?t>>>0:t;return{value:Ti(e.replace(`u`,`d`),r),parseError:a,parseErrMsg:o}}case`x`:case`X`:{let t=wi(n);return a=Fi,a&&(o=`printf: ${n}: invalid number
107
+ `),{value:Di(e,t),parseError:a,parseErrMsg:o}}case`e`:case`E`:case`f`:case`F`:case`g`:case`G`:return{value:ji(e,t,parseFloat(n)||0),parseError:!1,parseErrMsg:``};case`c`:{if(n===``)return{value:``,parseError:!1,parseErrMsg:``};let e=new TextEncoder().encode(n)[0];return{value:String.fromCharCode(e),parseError:!1,parseErrMsg:``}}case`s`:return{value:ki(e,n,i),parseError:!1,parseErrMsg:``};case`q`:return{value:Ai(e,n,i),parseError:!1,parseErrMsg:``};case`b`:{let e=Mi(n,i);return{value:e.value,parseError:!1,parseErrMsg:``,stopped:e.stopped}}default:try{return{value:(0,r.sprintf)(e,n),parseError:!1,parseErrMsg:``}}catch{return{value:``,parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
108
+ `}}}}function Ci(e,t){let n=e.match(/^%[-+0 #' ]*(\d*)(?:\.(\d*))?/);if(!n)return;let r=n[1]?Number(n[1]):0,i=n[2]===void 0?-1:Number(n[2]);Mr(r,t,`width`),i!==-1&&Mr(i,t,`precision`)}function wi(e){Fi=!1;let t=e.trimStart(),n=t!==t.trimEnd();if(e=t.trimEnd(),e.startsWith(`'`)&&e.length>=2||e.startsWith(`"`)&&e.length>=2)return e.charCodeAt(1);if(e.startsWith(`\\'`)&&e.length>=3||e.startsWith(`\\"`)&&e.length>=3)return e.charCodeAt(2);if(e.startsWith(`+`)&&(e=e.slice(1)),e.startsWith(`0x`)||e.startsWith(`0X`)){let t=parseInt(e,16);return Number.isNaN(t)?(Fi=!0,0):(n&&(Fi=!0),t)}if(e.startsWith(`0`)&&e.length>1&&/^-?0[0-7]+$/.test(e))return n&&(Fi=!0),parseInt(e,8)||0;if(/^\d+#/.test(e)){Fi=!0;let t=e.match(/^(\d+)#/);return t?parseInt(t[1],10):0}if(e!==``&&!/^-?\d+$/.test(e)){Fi=!0;let t=parseInt(e,10);return Number.isNaN(t)?0:t}return n&&(Fi=!0),parseInt(e,10)||0}function Ti(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return(0,r.sprintf)(e.replace(/\.\d*/,``),t);let i=n[1]||``,a=n[2]?parseInt(n[2],10):0,o=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0,s=t<0,c=String(Math.abs(t));o>=0&&(c=c.padStart(o,`0`));let l=``;s?l=`-`:i.includes(`+`)?l=`+`:i.includes(` `)&&(l=` `);let u=l+c;return a>u.length&&(u=i.includes(`-`)?u.padEnd(a,` `):i.includes(`0`)&&o<0?l+c.padStart(a-l.length,`0`):u.padStart(a,` `)),u}function Ei(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return(0,r.sprintf)(e,t);let i=n[1]||``,a=n[2]?parseInt(n[2],10):0,o=n[3]===void 0?-1:n[4]?parseInt(n[4],10):0,s=Math.abs(t).toString(8);o>=0&&(s=s.padStart(o,`0`)),i.includes(`#`)&&!s.startsWith(`0`)&&(s=`0${s}`);let c=s;return a>c.length&&(c=i.includes(`-`)?c.padEnd(a,` `):i.includes(`0`)&&o<0?c.padStart(a,`0`):c.padStart(a,` `)),c}function Di(e,t){let n=e.includes(`X`),i=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!i)return(0,r.sprintf)(e,t);let a=i[1]||``,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?-1:i[4]?parseInt(i[4],10):0,c=Math.abs(t).toString(16);n&&(c=c.toUpperCase()),s>=0&&(c=c.padStart(s,`0`));let l=``;a.includes(`#`)&&t!==0&&(l=n?`0X`:`0x`);let u=l+c;return o>u.length&&(u=a.includes(`-`)?u.padEnd(o,` `):a.includes(`0`)&&s<0?l+c.padStart(o-l.length,`0`):u.padStart(o,` `)),u}function Oi(e,t){if(e===``){if(t<2)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`);return`''`}if(/^[a-zA-Z0-9_./-]+$/.test(e)){if(O(e)>t)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`);return e}let n=/[\x00-\x1f\x7f-\xff]/.test(e),r=n?3:0;for(let i of e){let e=i.charCodeAt(0);if(r+=n?i===`'`||i===`\\`||i===`
109
+ `||i===` `||i===`\r`||i===`\x07`||i===`\b`||i===`\f`||i===`\v`||i===`\x1B`||i===`"`?2:e<32||e>=127&&e<=255?4:O(i):O(i)+ +!!` |&;<>()$\`\\"'*?[#~=%!{}`.includes(i),r>t)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`)}if(n){let t=`$'`;for(let n of e){let e=n.charCodeAt(0);t+=n===`'`?`\\'`:n===`\\`?`\\\\`:n===`
110
+ `?`\\n`:n===` `?`\\t`:n===`\r`?`\\r`:n===`\x07`?`\\a`:n===`\b`?`\\b`:n===`\f`?`\\f`:n===`\v`?`\\v`:n===`\x1B`?`\\E`:e<32||e>=127&&e<=255?`\\${e.toString(8).padStart(3,`0`)}`:n===`"`?`\\"`:n}return t+=`'`,t}let i=``;for(let t of e)` |&;<>()$\`\\"'*?[#~=%!{}`.includes(t)?i+=`\\${t}`:i+=t;return i}function ki(e,t,n){let i=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!i)return(0,r.sprintf)(e.replace(/0+(?=\d)/,``),t);let a=i[1]===`-`,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?-1:i[4]?parseInt(i[4],10):0;return Nr(t,a?-o:o,s,n)}function Ai(e,t,n){let r=Oi(t,n),i=e.match(/^%(-?)(\d*)q$/);if(!i)return r;let a=i[1]===`-`,o=i[2]?parseInt(i[2],10):0;return Nr(r,a?-o:o,-1,n)}function ji(e,t,n){let i=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!i)return(0,r.sprintf)(e,n);let a=i[1]||``,o=i[2]?parseInt(i[2],10):0,s=i[3]===void 0?6:i[4]?parseInt(i[4],10):0,c,l=t.toLowerCase();if(l===`e`?(c=n.toExponential(s),c=c.replace(/e([+-])(\d)$/,`e$10$2`),t===`E`&&(c=c.toUpperCase())):l===`f`?(c=n.toFixed(s),a.includes(`#`)&&s===0&&!c.includes(`.`)&&(c+=`.`)):l===`g`?(c=n.toPrecision(s||1),a.includes(`#`)||(c=c.replace(/\.?0+$/,``),c=c.replace(/\.?0+e/,`e`)),c=c.replace(/e([+-])(\d)$/,`e$10$2`),t===`G`&&(c=c.toUpperCase())):c=n.toString(),n>=0&&(a.includes(`+`)?c=`+${c}`:a.includes(` `)&&(c=` ${c}`)),o>c.length)if(a.includes(`-`))c=c.padEnd(o,` `);else if(a.includes(`0`)){let e=c.match(/^[+ -]/)?.[0]||``;c=e+(e?c.slice(1):c).padStart(o-e.length,`0`)}else c=c.padStart(o,` `);return c}function Mi(e,t){if(O(e)>t)throw new A(`printf: output size limit exceeded (${t} bytes)`,`string_length`);let n=``,r=0;for(;r<e.length;)if(e[r]===`\\`&&r+1<e.length)switch(e[r+1]){case`n`:n+=`
111
+ `,r+=2;break;case`t`:n+=` `,r+=2;break;case`r`:n+=`\r`,r+=2;break;case`\\`:n+=`\\`,r+=2;break;case`a`:n+=`\x07`,r+=2;break;case`b`:n+=`\b`,r+=2;break;case`f`:n+=`\f`,r+=2;break;case`v`:n+=`\v`,r+=2;break;case`c`:return{value:n,stopped:!0};case`x`:{let t=[],i=r;for(;i+1<e.length&&e[i]===`\\`&&e[i+1]===`x`;){let n=``,r=i+2;for(;r<e.length&&r<i+4&&/[0-9a-fA-F]/.test(e[r]);)n+=e[r],r++;if(n)t.push(parseInt(n,16)),i=r;else break}t.length>0?(n+=bi(t),r=i):(n+=`\\x`,r+=2);break}case`u`:{let t=``,i=r+2;for(;i<e.length&&i<r+6&&/[0-9a-fA-F]/.test(e[i]);)t+=e[i],i++;t?(n+=String.fromCodePoint(parseInt(t,16)),r=i):(n+=`\\u`,r+=2);break}case`0`:{let t=``,i=r+2;for(;i<e.length&&i<r+5&&/[0-7]/.test(e[i]);)t+=e[i],i++;n+=t?String.fromCharCode(parseInt(t,8)):`\0`,r=i;break}case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let t=``,i=r+1;for(;i<e.length&&i<r+4&&/[0-7]/.test(e[i]);)t+=e[i],i++;n+=String.fromCharCode(parseInt(t,8)),r=i;break}default:n+=e[r],r++}else n+=e[r],r++;return{value:n,stopped:!1}}var Ni,Pi,Fi,Ii,Li=T(()=>{j(),ci(),F(),Lr(),vi(),Ni={name:`printf`,summary:`format and print data`,usage:`printf [-v var] FORMAT [ARGUMENT...]`,options:[` -v var assign the output to shell variable VAR rather than display it`,` --help display this help and exit`],notes:[`FORMAT controls the output like in C printf.`,`Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)`,`Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)`,`Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)`,`Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)`]},Pi={name:`printf`,async execute(e,t){if(N(e))return M(Ni);if(e.length===0)return{stdout:``,stderr:`printf: usage: printf format [arguments]
112
+ `,exitCode:2,internalStdinConsumed:0};let n=null,r=0;for(;r<e.length;){let t=e[r];if(t===`--`){r++;break}if(t===`-v`){if(r+1>=e.length)return{stdout:``,stderr:`printf: -v: option requires an argument
113
+ `,exitCode:1,internalStdinConsumed:0};if(n=e[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(?:\[[^\]\n]+\])?$/.test(n)||/[;\r\\]/.test(n)||n.includes(`..`))return{stdout:``,stderr:`printf: \`${n}': not a valid identifier
114
+ `,exitCode:2,internalStdinConsumed:0};r+=2}else{if(t.startsWith(`-`)&&t!==`-`)break;break}}if(r>=e.length)return{stdout:``,stderr:`printf: usage: printf format [arguments]
115
+ `,exitCode:1,internalStdinConsumed:0};let i=e[r],a=e.slice(r+1);try{let e=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),r=Fr(i,e),o=``,s=0,c=0,l=!1,u=``,d=t.env.get(`TZ`);do{let{result:t,argsConsumed:n,error:i,errMsg:f,stopped:p}=xi(r,a,c,d,e-s),m=O(t);if(m>e-s)throw new A(`printf: output size limit exceeded (${e} bytes)`,`string_length`);if(o+=t,s+=m,c+=n,i&&(l=!0,f&&(u=f)),p)break}while(c<a.length&&c>0);if(c===0&&a.length,n){let e=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(e){let n=e[1],r=e[3];if(r=r.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>t.env.get(n)??``),t.assignShellVariable)await t.assignShellVariable(n,o,r);else throw Error(`printf -v array assignment requires an interpreter assignment gateway`)}else if(t.assignShellVariable)await t.assignShellVariable(n,o);else{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))throw Error(`${n}: not a valid identifier`);t.env.set(n,o)}return{stdout:``,stderr:u,exitCode:+!!l,internalStdinConsumed:0}}return{stdout:o,stderr:u,exitCode:+!!l,internalStdinConsumed:0}}catch(e){if(e instanceof A||typeof e==`object`&&e&&`name`in e&&e.name===`ExitError`)throw e;return{stdout:``,stderr:`printf: ${si(e)}
116
+ `,exitCode:1,internalStdinConsumed:0}}}},Fi=!1,Ii={name:`printf`,flags:[{flag:`-v`,type:`value`,valueHint:`string`}],stdinType:`none`,needsArgs:!0}});function Ri(e,t){if(!Number.isSafeInteger(e)||e<0)throw new A(`${t}: invalid bounded allocation count`,`array_elements`)}function zi(e){return new A(`${e}: invalid bounded allocation count`,`array_elements`)}function Bi(e,t,n){Ri(e,n),Ri(t,n);let r=e+t;if(!Number.isSafeInteger(r))throw zi(n);return r}function Vi(e,t,n){if(Ri(e,n),Ri(t,n),e!==0&&t>Math.floor((2**53-1)/e))throw zi(n);return e*t}function Hi(e,t,n,r){let i=new Ui(n,r);for(let n=0;n<e.length;n++)n>0&&i.append(t),i.append(e[n]);return i.build()}var Ui,Wi=T(()=>{k(),j(),Ui=class{maxBytes;label;createLimitError;reservedBytes;chunks=[];usedBytes=0;constructor(e,t,n=void 0,r=0){this.maxBytes=e,this.label=t,this.createLimitError=n,this.reservedBytes=r,Ri(e,t),Ri(r,t),r>e&&this.fail()}fail(){throw this.createLimitError?.()??new A(`${this.label}: output size limit exceeded (${this.maxBytes} bytes)`,`output_size`)}get byteLength(){return this.usedBytes}get remainingBytes(){return this.maxBytes-this.reservedBytes-this.usedBytes}reserve(e){Ri(e,this.label),e>this.remainingBytes&&this.fail()}append(e){let t=O(e);return this.reserve(t),e&&this.chunks.push(e),this.usedBytes+=t,this}repeat(e,t){Ri(t,this.label);let n=O(e);return n!==0&&t>Math.floor(this.remainingBytes/n)&&this.fail(),this.append(e.repeat(t))}reset(){this.chunks.length=0,this.usedBytes=0}build(){return this.chunks.join(``)}}});function I(e){if(!e||e===`/`)return`/`;let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;t.startsWith(`/`)||(t=`/${t}`);let n=t.split(`/`).filter(e=>e&&e!==`.`),r=[];for(let e of n)e===`..`?r.pop():r.push(e);return`/${r.join(`/`)}`||`/`}function Gi(e,t){let n=I(e),r=I(t);return r===n||n===`/`||r.startsWith(`${n}/`)}function Ki(e,t){if(e.includes(`\0`))throw Error(`ENOENT: path contains null byte, ${t} '${e}'`)}function qi(e){let t=I(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n===0?`/`:t.slice(0,n)}function Ji(e,t){return t.startsWith(`/`)?I(t):I(e===`/`?`/${t}`:`${e}/${t}`)}function Yi(e,t){return e===`/`?`/${t}`:`${e}/${t}`}function Xi(e,t){return t.startsWith(`/`)?I(t):I(Yi(qi(e),t))}var Zi=T(()=>{});function Qi(e,t,n){if(!e)return e;let r=e.replace(/\n\s+at\s.*/g,``);return n&&(r=r.replace(/\bfile:\/\/\/?[^\s'",)}\]:]+/g,`<path>`)),r=r.replace(t?/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap|workspace|root|srv|mnt|app))\b[^\s'",)}\]:]*/g:/(?:\/(?:Users|home|private|var|opt|Library|System|usr|etc|tmp|nix|snap))\b[^\s'",)}\]:]*/g,`<path>`),r=r.replace(/node:internal\/[^\s'",)}\]:]+/g,`<internal>`),r=r.replace(/[A-Z]:\\[^\s'",)}\]:]+/g,`<path>`),n&&(r=r.replace(/\\\\[^\s\\]+\\[^\s'",)}\]:]+/g,`<path>`)),r}function $i(e){return Qi(e,!1,!1)}var ea=T(()=>{});function ta(e){if(e.identity!==void 0)return`identity:${e.identity}`;if(e.dev!==void 0&&e.ino!==void 0)return`inode:${String(e.dev)}:${String(e.ino)}`}function na(e){let t=e instanceof Error?e.message:String(e);return t.includes(`ENOENT`)||t.includes(`no such file`)}async function ra(e,t,n){let r=I(t),i;try{i=await e.stat(r)}catch(e){if(!na(e))return{existence:`unknown`}}if(i!==void 0){let t=ta(i);try{return{existence:`existing`,canonicalPath:I(await e.realpath(r)),stableIdentity:t}}catch{return t===void 0?{existence:`unknown`}:{existence:`existing`,stableIdentity:t}}}let a=[],o=r;for(;;){n?.checkpoint();let t=qi(o);if(t===o)return{existence:`unknown`};a.unshift(o.slice(t===`/`?1:t.length+1)),o=t;try{let t=I(await e.realpath(o));return{existence:`missing`,canonicalPath:a.reduce((e,t)=>Yi(e,t),t)}}catch(e){if(!na(e))return{existence:`missing`}}}}async function ia(e,t,n){let[r,i]=await Promise.all([ra(e,t),ra(e,n)]);return r.existence===`unknown`||i.existence===`unknown`?`unknown`:r.existence===`missing`||i.existence===`missing`?r.existence===i.existence?r.canonicalPath!==void 0&&r.canonicalPath===i.canonicalPath?`same`:`unknown`:`different`:r.stableIdentity!==void 0&&i.stableIdentity!==void 0?r.stableIdentity===i.stableIdentity?`same`:`different`:r.canonicalPath!==void 0&&r.canonicalPath===i.canonicalPath?`same`:`unknown`}async function aa(e,t,n,r){let[i,a]=await Promise.all([ra(e,t,r),ra(e,n,r)]);return i.existence!==`existing`||i.canonicalPath===void 0||a.existence===`unknown`||a.canonicalPath===void 0?`unknown`:Gi(i.canonicalPath,a.canonicalPath)?`inside`:`outside`}async function oa(e,t){let n=e.budget??new ca(e),r=[{kind:`enter`,path:I(e.root),depth:0}],i=new Set;for(;r.length>0;){n.checkpoint(0);let a=r.pop();if(!a)break;if(a.kind===`leave`){e.includeLeave&&await t({path:a.path,depth:a.depth,stat:a.stat,isSymlink:a.isSymlink,phase:`leave`}),a.identity&&i.delete(a.identity);continue}n.visit(a.depth);let o=await e.fs.lstat(a.path),s=o.isSymbolicLink,c=s&&e.symlinks===`follow`?await e.fs.stat(a.path):o;if(await t({path:a.path,depth:a.depth,stat:c,isSymlink:s,phase:`enter`}),!c.isDirectory||s&&e.symlinks!==`follow`)continue;let l=ta(c)??await e.fs.realpath(a.path).then(I).catch(()=>{});if(l!==void 0){if(i.has(l))throw new sa(e.site,a.path,`symbolic-link directory cycle detected`);i.add(l)}r.push({kind:`leave`,path:a.path,depth:a.depth,stat:c,isSymlink:s,identity:l});let u=await e.fs.readdir(a.path);n.checkpoint(),u.sort((e,t)=>e.localeCompare(t));for(let e=u.length-1;e>=0;e--)r.push({kind:`enter`,path:Yi(a.path,u[e]),depth:a.depth+1})}}var sa,ca,la=T(()=>{j(),Zi(),ea(),sa=class extends Error{operation;virtualPath;name=`FileSystemPolicyError`;constructor(e,t,n){super(`${e}: ${$i(n)}`),this.operation=e,this.virtualPath=t}},ca=class{options;entries=0;discoveredEntries=1;work=0;constructor(e){this.options=e}checkpoint(e=1){if(this.options.signal?.aborted)throw new kr;if(this.options.executionScope?.throwIfAborted(this.options.site),!Number.isSafeInteger(e)||e<0||e>this.options.limits.maxTraversalWork-this.work)throw new A(`${this.options.site}: ${this.options.label??`filesystem traversal work`} limit exceeded (${this.options.limits.maxTraversalWork})`,`iterations`);this.work+=e,this.options.executionScope?.consumeWork(e,`${this.options.site} filesystem traversal`)}visit(e){if(this.checkpoint(),e>this.options.limits.maxTraversalDepth)throw new A(`${this.options.site}: ${this.options.label??`filesystem traversal`} depth limit exceeded (${this.options.limits.maxTraversalDepth})`,`recursion`);if(++this.entries>this.options.limits.maxTraversalEntries)throw new A(`${this.options.site}: ${this.options.label??`filesystem traversal`} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,`iterations`)}discover(e){if(!Number.isSafeInteger(e)||e<0||e>this.options.limits.maxTraversalEntries-this.discoveredEntries)throw new A(`${this.options.site}: ${this.options.label??`filesystem traversal`} entry limit exceeded (${this.options.limits.maxTraversalEntries})`,`iterations`);this.checkpoint(e),this.discoveredEntries+=e}}}),ua={};E(ua,{flagsForFuzzing:()=>xa,lsCommand:()=>ba});function da(e,t,n){if(O(n)>e.limits.maxOutputSize-O(t))throw new A(`ls: output size limit exceeded (${e.limits.maxOutputSize} bytes)`,`output_size`);return t+n}function fa(e,t){let n=new Ui(e.limits.maxOutputSize,`ls`);for(let e=0;e<t.length;e++)e>0&&n.append(`
117
+ `),n.append(t[e]);return t.length>0&&n.append(`
118
+ `),n.build()}function pa(e){if(e<1024)return String(e);if(e<1048576){let t=e/1024;return t<10?`${t.toFixed(1)}K`:`${Math.round(t)}K`}if(e<1073741824){let t=e/1048576;return t<10?`${t.toFixed(1)}M`:`${Math.round(t)}M`}let t=e/1073741824;return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function ma(e){let t=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()],n=String(e.getDate()).padStart(2,` `);return e>new Date(new Date().getTime()-15552e6)?`${t} ${n} ${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`:`${t} ${n} ${e.getFullYear()}`}function ha(e){return e.isDirectory?`/`:e.isSymbolicLink?`@`:e.mode&73?`*`:``}async function ga(e,t,n,r,i,a=!1,o=!1,s=!1,c=!1,l){let u=n||r,d=t.fs.getAllPaths(),f=t.fs.resolvePath(t.cwd,`.`),p=[];for(let t of d){l?.visit(t.split(`/`).length-1);let n=(t===f||f===`/`||t.startsWith(`${f}/`))&&t.slice(f===`/`?1:f.length+1)||t;if(Ne(n,e)||Ne(t,e)){let e=n.split(`/`).pop()||n;if(!u&&e.startsWith(`.`))continue;p.push(n||t)}}if(p.length===0)return{stdout:``,stderr:`ls: ${e}: No such file or directory
119
+ `,exitCode:2};if(s){let e=[];for(let n of p){let r=t.fs.resolvePath(t.cwd,n);try{let i=await t.fs.stat(r);e.push({path:n,size:i.size??0})}catch{e.push({path:n,size:0})}}e.sort((e,t)=>t.size-e.size),p.length=0,p.push(...e.map(e=>e.path))}else p.sort();if(a&&p.reverse(),i){let e=[];for(let n of p){let r=t.fs.resolvePath(t.cwd,n);try{let i=await t.fs.stat(r),a=i.isDirectory?`drwxr-xr-x`:`-rw-r--r--`,s=c?ha(await t.fs.lstat(r)):i.isDirectory?`/`:``,l=i.size??0,u=o?pa(l).padStart(5):String(l).padStart(5),d=ma(i.mtime??new Date(0));e.push(`${a} 1 user user ${u} ${d} ${n}${s}`)}catch{e.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${n}`)}}return{stdout:fa(t,e),stderr:``,exitCode:0}}if(c){let e=[];for(let n of p){let r=t.fs.resolvePath(t.cwd,n);try{let i=await t.fs.lstat(r);e.push(`${n}${ha(i)}`)}catch{e.push(n)}}return{stdout:fa(t,e),stderr:``,exitCode:0}}return{stdout:fa(t,p),stderr:``,exitCode:0}}async function _a(e,t,n,r,i,a,o,s=!1,c=!1,l=!1,u=!1,d=!1,f=new ca({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`ls`}),p=0,m=new Set){let h=n||r,g=t.fs.resolvePath(t.cwd,e);try{f.visit(p);let d=await t.fs.stat(g);if(!d.isDirectory){let n=u?ha(await t.fs.lstat(g)):``;if(i){let t=d.size??0;return{stdout:`-rw-r--r-- 1 user user ${c?pa(t).padStart(5):String(t).padStart(5)} ${ma(d.mtime??new Date(0))} ${e}${n}
120
+ `,stderr:``,exitCode:0}}return{stdout:`${e}${n}
121
+ `,stderr:``,exitCode:0}}let _=d.identity??(d.dev!==void 0&&d.ino!==void 0?`${String(d.dev)}:${String(d.ino)}`:await t.fs.realpath(g).catch(()=>{}));if(_!==void 0&&m.has(_))return{stdout:``,stderr:`ls: ${e}: symbolic link cycle detected
122
+ `,exitCode:2};let v=new Set(m);_!==void 0&&v.add(_);let y=await t.fs.readdir(g);if(f.checkpoint(),h||(y=y.filter(e=>!e.startsWith(`.`))),l){let e=[];for(let n of y){let r=g===`/`?`/${n}`:`${g}/${n}`;try{let i=await t.fs.stat(r);e.push({name:n,size:i.size??0})}catch{e.push({name:n,size:0})}}e.sort((e,t)=>t.size-e.size),y=e.map(e=>e.name)}else y.sort();n&&(y=[`.`,`..`,...y]),s&&y.reverse();let b=``,x=``,S=0;if((a||o)&&(b=da(t,b,`${e}:
123
+ `)),i){b=da(t,b,`total ${y.length}
124
+ `);let e=y.filter(e=>e===`.`||e===`..`),n=y.filter(e=>e!==`.`&&e!==`..`);for(let n of e)b=da(t,b,`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${n}
125
+ `);let r=[];for(let e=0;e<n.length;e+=100){let i=n.slice(e,e+100),a=await Promise.all(i.map(async e=>{let n=g===`/`?`/${e}`:`${g}/${e}`;try{let r=await t.fs.stat(n),i=r.isDirectory?`drwxr-xr-x`:`-rw-r--r--`,a=u?ha(await t.fs.lstat(n)):r.isDirectory?`/`:``,o=r.size??0;return{name:e,line:`${i} 1 user user ${c?pa(o).padStart(5):String(o).padStart(5)} ${ma(r.mtime??new Date(0))} ${e}${a}
126
+ `}}catch{return{name:e,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${e}
127
+ `}}}));r.push(...a)}let i=new Map(n.map((e,t)=>[e,t]));r.sort((e,t)=>(i.get(e.name)??0)-(i.get(t.name)??0));for(let{line:e}of r)b=da(t,b,e)}else if(u){let e=[],n=y.filter(e=>e!==`.`&&e!==`..`),r=y.filter(e=>e===`.`||e===`..`);for(let t of r)e.push(`${t}/`);for(let r=0;r<n.length;r+=100){let i=n.slice(r,r+100),a=await Promise.all(i.map(async e=>{let n=g===`/`?`/${e}`:`${g}/${e}`;try{return`${e}${ha(await t.fs.lstat(n))}`}catch{return e}}));e.push(...a)}b=da(t,b,fa(t,e))}else b=da(t,b,fa(t,y));if(a){let o=y.filter(e=>e!==`.`&&e!==`..`),d=[];if(t.fs.readdirWithFileTypes)d=(await t.fs.readdirWithFileTypes(g)).filter(e=>e.isDirectory&&o.includes(e.name)).map(e=>({name:e.name,isDirectory:!0}));else for(let e=0;e<o.length;e+=100){let n=o.slice(e,e+100),r=await Promise.all(n.map(async e=>{let n=g===`/`?`/${e}`:`${g}/${e}`;try{return{name:e,isDirectory:(await t.fs.stat(n)).isDirectory}}catch{return{name:e,isDirectory:!1}}}));d.push(...r.filter(e=>e.isDirectory))}d.sort((e,t)=>e.name.localeCompare(t.name)),s&&d.reverse();let m=[];for(let o=0;o<d.length;o+=100){let h=d.slice(o,o+100),g=await Promise.all(h.map(async o=>{let d=await _a(e===`.`?`./${o.name}`:`${e}/${o.name}`,t,n,r,i,a,!1,s,c,l,u,!0,f,p+1,v);return{name:o.name,result:d}}));m.push(...g)}m.sort((e,t)=>e.name.localeCompare(t.name)),s&&m.reverse();for(let{result:e}of m)b=da(t,b,`
128
+ `),b=da(t,b,e.stdout),x=da(t,x,e.stderr),e.exitCode!==0&&(S=e.exitCode)}return{stdout:b,stderr:x,exitCode:S}}catch(t){if(t instanceof A||t instanceof kr)throw t;return{stdout:``,stderr:`ls: ${e}: No such file or directory
129
+ `,exitCode:2}}}var va,ya,ba,xa,Sa=T(()=>{Wi(),k(),la(),j(),Kr(),qr(),F(),va={name:`ls`,summary:`list directory contents`,usage:`ls [OPTION]... [FILE]...`,options:[`-a, --all do not ignore entries starting with .`,`-A, --almost-all do not list . and ..`,`-d, --directory list directories themselves, not their contents`,`-F, --classify append indicator (one of */=>@) to entries`,`-h, --human-readable with -l, print sizes like 1K 234M 2G etc.`,`-l use a long listing format`,`-r, --reverse reverse order while sorting`,`-R, --recursive list subdirectories recursively`,`-S sort by file size, largest first`,`-t sort by time, newest first`,`-1 list one file per line`,` --help display this help and exit`]},ya={showAll:{short:`a`,long:`all`,type:`boolean`},showAlmostAll:{short:`A`,long:`almost-all`,type:`boolean`},longFormat:{short:`l`,type:`boolean`},humanReadable:{short:`h`,long:`human-readable`,type:`boolean`},recursive:{short:`R`,long:`recursive`,type:`boolean`},reverse:{short:`r`,long:`reverse`,type:`boolean`},sortBySize:{short:`S`,type:`boolean`},classifyFiles:{short:`F`,long:`classify`,type:`boolean`},directoryOnly:{short:`d`,long:`directory`,type:`boolean`},sortByTime:{short:`t`,type:`boolean`},onePerLine:{short:`1`,type:`boolean`}},ba={name:`ls`,async execute(e,t){if(N(e))return M(va);let n=Gr(`ls`,e,ya);if(!n.ok)return n.error;let r=n.result.flags.showAll,i=n.result.flags.showAlmostAll,a=n.result.flags.longFormat,o=n.result.flags.humanReadable,s=n.result.flags.recursive,c=n.result.flags.reverse,l=n.result.flags.sortBySize,u=n.result.flags.classifyFiles,d=n.result.flags.directoryOnly;n.result.flags.sortByTime,n.result.flags.onePerLine;let f=n.result.positional;f.length===0&&f.push(`.`);let p=``,m=``,h=0,g=new ca({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`ls`});for(let e=0;e<f.length;e++){let n=f[e];if(e>0&&p&&!p.endsWith(`
130
+
131
+ `)&&(p=da(t,p,`
132
+ `)),d){let e=t.fs.resolvePath(t.cwd,n);try{let r=await t.fs.stat(e);if(a){let i=r.isDirectory?`drwxr-xr-x`:`-rw-r--r--`,a=u?ha(await t.fs.lstat(e)):r.isDirectory?`/`:``,s=r.size??0,c=o?pa(s).padStart(5):String(s).padStart(5),l=ma(r.mtime??new Date(0));p=da(t,p,`${i} 1 user user ${c} ${l} ${n}${a}
133
+ `)}else{let r=u?ha(await t.fs.lstat(e)):``;p=da(t,p,`${n}${r}
134
+ `)}}catch{m=da(t,m,`ls: cannot access '${n}': No such file or directory
135
+ `),h=2}continue}if(n.includes(`*`)||n.includes(`?`)||n.includes(`[`)){let e=await ga(n,t,r,i,a,c,o,l,u,g);p=da(t,p,e.stdout),m=da(t,m,e.stderr),e.exitCode!==0&&(h=e.exitCode)}else{let e=await _a(n,t,r,i,a,s,f.length>1,c,o,l,u,!1,g,0,new Set);p=da(t,p,e.stdout),m=da(t,m,e.stderr),e.exitCode!==0&&(h=e.exitCode)}}return{stdout:p,stderr:m,exitCode:h}}},xa={name:`ls`,flags:[{flag:`-a`,type:`boolean`},{flag:`-A`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-t`,type:`boolean`},{flag:`-1`,type:`boolean`}],needsFiles:!0}}),Ca={};E(Ca,{flagsForFuzzing:()=>Ea,mkdirCommand:()=>Ta});var wa,Ta,Ea,Da=T(()=>{ea(),ci(),Kr(),wa={recursive:{short:`p`,long:`parents`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},Ta={name:`mkdir`,async execute(e,t){let n=Gr(`mkdir`,e,wa);if(!n.ok)return n.error;let r=n.result.flags.recursive,i=n.result.flags.verbose,a=n.result.positional;if(a.length===0)return{stdout:``,stderr:`mkdir: missing operand
136
+ `,exitCode:1};let o=``,s=``,c=0;for(let e of a)try{let n=t.fs.resolvePath(t.cwd,e);await t.fs.mkdir(n,{recursive:r}),i&&(o+=`mkdir: created directory '${e}'
137
+ `)}catch(t){let n=si(t);n.includes(`ENOENT`)||n.includes(`no such file`)?s+=`mkdir: cannot create directory '${e}': No such file or directory
138
+ `:n.includes(`EEXIST`)||n.includes(`already exists`)?s+=`mkdir: cannot create directory '${e}': File exists
139
+ `:s+=`mkdir: cannot create directory '${e}': ${$i(n)}
140
+ `,c=1}return{stdout:o,stderr:s,exitCode:c}}},Ea={name:`mkdir`,flags:[{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),Oa={};E(Oa,{flagsForFuzzing:()=>Fa,rmdirCommand:()=>Pa});async function ka(e,t,n,r,i){let a=``,o=``,s=e.fs.resolvePath(e.cwd,t),c=await Aa(e,s,t,r);if(a+=c.stdout,o+=c.stderr,c.exitCode!==0)return{stdout:a,stderr:o,exitCode:c.exitCode};if(n){let n=s,o=t;for(;;){i.visit(0);let t=ja(n),s=ja(o);if(t===n||t===`/`||t===`.`||s===`.`||s===``)break;let c=await Aa(e,t,s,r);if(a+=c.stdout,c.exitCode!==0)break;n=t,o=s}}return{stdout:a,stderr:o,exitCode:0}}async function Aa(e,t,n,r){try{if(!await e.fs.exists(t))return{stdout:``,stderr:`rmdir: failed to remove '${n}': No such file or directory
141
+ `,exitCode:1};if(!(await e.fs.stat(t)).isDirectory)return{stdout:``,stderr:`rmdir: failed to remove '${n}': Not a directory
142
+ `,exitCode:1};if((await e.fs.readdir(t)).length>0)return{stdout:``,stderr:`rmdir: failed to remove '${n}': Directory not empty
143
+ `,exitCode:1};await e.fs.rm(t,{recursive:!1,force:!1});let i=``;return r&&(i=`rmdir: removing directory, '${n}'
144
+ `),{stdout:i,stderr:``,exitCode:0}}catch(e){return{stdout:``,stderr:`rmdir: failed to remove '${n}': ${si(e)}
145
+ `,exitCode:1}}}function ja(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?`.`:n===0?`/`:t.substring(0,n)}var Ma,Na,Pa,Fa,Ia=T(()=>{la(),ci(),Kr(),Ma=`Usage: rmdir [-pv] DIRECTORY...
146
+ Remove empty directories.
147
+
148
+ Options:
149
+ -p, --parents Remove DIRECTORY and its ancestors
150
+ -v, --verbose Output a diagnostic for every directory processed`,Na={parents:{short:`p`,long:`parents`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`},help:{long:`help`,type:`boolean`}},Pa={name:`rmdir`,async execute(e,t){let n=Gr(`rmdir`,e,Na);if(!n.ok)return n.error;if(n.result.flags.help)return{stdout:`${Ma}
151
+ `,stderr:``,exitCode:0};let r=n.result.flags.parents,i=n.result.flags.verbose,a=n.result.positional;if(a.length===0)return{stdout:``,stderr:`rmdir: missing operand
152
+ `,exitCode:1};let o=``,s=``,c=0,l=new ca({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`rmdir`,label:`parent traversal`});for(let e of a){let n=await ka(t,e,r,i,l);o+=n.stdout,s+=n.stderr,n.exitCode!==0&&(c=n.exitCode)}return{stdout:o,stderr:s,exitCode:c}}},Fa={name:`rmdir`,flags:[{flag:`-p`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),La={};E(La,{flagsForFuzzing:()=>Ba,touchCommand:()=>za});function Ra(e){let t=e.replace(/\//g,`-`),n=new Date(t);if(!Number.isNaN(n.getTime()))return n;let r=t.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(r){let[,e,t,i]=r;if(n=new Date(Number.parseInt(e,10),Number.parseInt(t,10)-1,Number.parseInt(i,10)),!Number.isNaN(n.getTime()))return n}let i=t.match(/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})$/);if(i){let[,e,t,r,a,o,s]=i;if(n=new Date(Number.parseInt(e,10),Number.parseInt(t,10)-1,Number.parseInt(r,10),Number.parseInt(a,10),Number.parseInt(o,10),Number.parseInt(s,10)),!Number.isNaN(n.getTime()))return n}return null}var za,Ba,Va=T(()=>{ci(),F(),za={name:`touch`,async execute(e,t){let n=[],r=null,i=!1;for(let t=0;t<e.length;t++){let a=e[t];if(a===`--`){n.push(...e.slice(t+1));break}if(a===`-d`||a===`--date`){if(t+1>=e.length)return{stdout:``,stderr:`touch: option requires an argument -- 'd'
153
+ `,exitCode:1};r=e[++t]}else if(a.startsWith(`--date=`))r=a.slice(7);else if(a===`-c`||a===`--no-create`)i=!0;else if(a===`-a`||a===`-m`||a===`-r`||a===`-t`)(a===`-r`||a===`-t`)&&t++;else{if(a.startsWith(`--`))return P(`touch`,a);if(a.startsWith(`-`)&&a.length>1){let n=!1;for(let o of a.slice(1))if(o===`c`)i=!0;else if(o!==`a`&&o!==`m`)if(o===`d`){if(t+1>=e.length)return{stdout:``,stderr:`touch: option requires an argument -- 'd'
154
+ `,exitCode:1};r=e[++t],n=!0;break}else if(o===`r`||o===`t`){t++,n=!0;break}else return P(`touch`,`-${o}`);if(n)continue}else n.push(a)}}if(n.length===0)return{stdout:``,stderr:`touch: missing file operand
155
+ `,exitCode:1};let a=null;if(r!==null&&(a=Ra(r),a===null))return{stdout:``,stderr:`touch: invalid date format '${r}'
156
+ `,exitCode:1};let o=``,s=0;for(let e of n)try{let n=t.fs.resolvePath(t.cwd,e);if(!await t.fs.exists(n)){if(i)continue;await t.fs.writeFile(n,``)}let r=a??new Date;await t.fs.utimes(n,r,r)}catch(t){o+=`touch: cannot touch '${e}': ${si(t)}
157
+ `,s=1}return{stdout:``,stderr:o,exitCode:s}}},Ba={name:`touch`,flags:[{flag:`-c`,type:`boolean`},{flag:`-a`,type:`boolean`},{flag:`-m`,type:`boolean`},{flag:`-d`,type:`value`,valueHint:`string`}],needsArgs:!0}}),Ha={};E(Ha,{flagsForFuzzing:()=>Ga,rmCommand:()=>Wa});var Ua,Wa,Ga,Ka=T(()=>{ea(),ci(),Kr(),Ua={recursive:{short:`r`,long:`recursive`,type:`boolean`},recursiveUpper:{short:`R`,type:`boolean`},force:{short:`f`,long:`force`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},Wa={name:`rm`,async execute(e,t){let n=Gr(`rm`,e,Ua);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,i=n.result.flags.force,a=n.result.flags.verbose,o=n.result.positional;if(o.length===0)return i?{stdout:``,stderr:``,exitCode:0}:{stdout:``,stderr:`rm: missing operand
158
+ `,exitCode:1};let s=``,c=``,l=0;for(let e of o)try{let n=t.fs.resolvePath(t.cwd,e);if((await t.fs.stat(n)).isDirectory&&!r){c+=`rm: cannot remove '${e}': Is a directory
159
+ `,l=1;continue}await t.fs.rm(n,{recursive:r,force:i}),a&&(s+=`removed '${e}'
160
+ `)}catch(t){if(!i){let n=si(t);n.includes(`ENOENT`)||n.includes(`no such file`)?c+=`rm: cannot remove '${e}': No such file or directory
161
+ `:n.includes(`ENOTEMPTY`)||n.includes(`not empty`)?c+=`rm: cannot remove '${e}': Directory not empty
162
+ `:c+=`rm: cannot remove '${e}': ${$i(n)}
163
+ `,l=1}}return{stdout:s,stderr:c,exitCode:l}}},Ga={name:`rm`,flags:[{flag:`-r`,type:`boolean`},{flag:`-R`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0}}),qa={};E(qa,{cpCommand:()=>Xa,flagsForFuzzing:()=>Za});var Ja,Ya,Xa,Za,Qa=T(()=>{Zi(),la(),j(),ci(),Kr(),F(),Ja={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`]},Ya={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`}},Xa={name:`cp`,async execute(e,t){if(N(e))return M(Ja);let n=Gr(`cp`,e,Ya);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
164
+ `,exitCode:1};let s=o.pop()??``,c=o,l=t.fs.resolvePath(t.cwd,s),u=``,d=``,f=0,p=new ca({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
165
+ `,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}'
166
+ `,f=1;continue}if(o.isDirectory){let r=await aa(t.fs,n,s,p);if(Gi(n,s)||r===`inside`){d+=`cp: cannot copy '${e}' into itself, '${s}'
167
+ `,f=1;continue}if(r===`unknown`){d+=`cp: cannot safely determine whether '${s}' is inside '${e}'
168
+ `,f=1;continue}}if(i)try{await t.fs.stat(s);continue}catch{}let c=await ia(t.fs,n,s);if(c===`same`){d+=`cp: '${e}' and '${s}' are the same file
169
+ `,f=1;continue}if(c===`unknown`){d+=`cp: cannot safely determine whether '${e}' and '${s}' are the same file
170
+ `,f=1;continue}o.isDirectory&&await oa({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}'
171
+ `)}catch(t){if(t instanceof A||t instanceof kr)throw t;let n=si(t);n.includes(`ENOENT`)||n.includes(`no such file`)?d+=`cp: cannot stat '${e}': No such file or directory
172
+ `:d+=`cp: cannot copy '${e}': ${n}
173
+ `,f=1}return{stdout:u,stderr:d,exitCode:f}}},Za={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}}),$a={};E($a,{flagsForFuzzing:()=>ro,mvCommand:()=>no});var eo,to,no,ro,io=T(()=>{Zi(),la(),j(),ci(),Kr(),F(),eo={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`]},to={force:{short:`f`,long:`force`,type:`boolean`},noClobber:{short:`n`,long:`no-clobber`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`}},no={name:`mv`,async execute(e,t){if(N(e))return M(eo);let n=Gr(`mv`,e,to);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
174
+ `,exitCode:1};let o=a.pop()??``,s=a,c=t.fs.resolvePath(t.cwd,o),l=``,u=``,d=0,f=new ca({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
175
+ `,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 aa(t.fs,n,s,f);if(Gi(n,s)||r===`inside`){u+=`mv: cannot move '${e}' into itself, '${s}'
176
+ `,d=1;continue}if(r===`unknown`){u+=`mv: cannot safely determine whether '${s}' is inside '${e}'
177
+ `,d=1;continue}}if(r)try{await t.fs.stat(s);continue}catch{}let m=await ia(t.fs,n,s);if(m===`same`)continue;if(m===`unknown`){u+=`mv: cannot safely determine whether '${e}' and '${s}' are the same file
178
+ `,d=1;continue}if(a.isDirectory&&await oa({fs:t.fs,root:n,limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`mv`,symlinks:`never`,budget:f},()=>{}),await t.fs.mv(n,s),i){let t=p?`${o}/${e.split(`/`).pop()||e}`:o;l+=`renamed '${e}' -> '${t}'
179
+ `}}catch(t){if(t instanceof A||t instanceof kr)throw t;let n=si(t);n.includes(`ENOENT`)||n.includes(`no such file`)?u+=`mv: cannot stat '${e}': No such file or directory
180
+ `:u+=`mv: cannot move '${e}': ${n}
181
+ `,d=1}return{stdout:l,stderr:u,exitCode:d}}},ro={name:`mv`,flags:[{flag:`-f`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),ao={};E(ao,{flagsForFuzzing:()=>co,lnCommand:()=>so});var oo,so,co,lo=T(()=>{ea(),F(),oo={name:`ln`,summary:`make links between files`,usage:`ln [OPTIONS] TARGET LINK_NAME`,options:[`-s create a symbolic link instead of a hard link`,`-f remove existing destination files`,`-n treat LINK_NAME as a normal file if it is a symbolic link to a directory`,`-v print name of each linked file`,` --help display this help and exit`]},so={name:`ln`,async execute(e,t){if(N(e))return M(oo);let n=!1,r=!1,i=!1,a=0;for(;a<e.length&&e[a].startsWith(`-`);){let t=e[a];if(t===`-s`||t===`--symbolic`)n=!0,a++;else if(t===`-f`||t===`--force`)r=!0,a++;else if(t===`-v`||t===`--verbose`)i=!0,a++;else if(t===`-n`||t===`--no-dereference`)a++;else if(/^-[sfvn]+$/.test(t))t.includes(`s`)&&(n=!0),t.includes(`f`)&&(r=!0),t.includes(`v`)&&(i=!0),a++;else if(t===`--`){a++;break}else return P(`ln`,t)}let o=e.slice(a);if(o.length<2)return{stdout:``,stderr:`ln: missing file operand
182
+ `,exitCode:1};if(o.length>2)return{stdout:``,stderr:`ln: extra operand '${o[2]}'
183
+ `,exitCode:1};let s=o[0],c=o[1],l=t.fs.resolvePath(t.cwd,c);if(await t.fs.exists(l))if(r)try{await t.fs.rm(l,{force:!0})}catch{return{stdout:``,stderr:`ln: cannot remove '${c}': Permission denied
184
+ `,exitCode:1}}else return{stdout:``,stderr:`ln: failed to create ${n?`symbolic `:``}link '${c}': File exists
185
+ `,exitCode:1};try{if(n)await t.fs.symlink(s,l);else{let e=t.fs.resolvePath(t.cwd,s);if(!await t.fs.exists(e))return{stdout:``,stderr:`ln: failed to access '${s}': No such file or directory
186
+ `,exitCode:1};await t.fs.link(e,l)}}catch(e){let t=e;return t.message.includes(`EPERM`)?{stdout:``,stderr:`ln: '${s}': hard link not allowed for directory
187
+ `,exitCode:1}:{stdout:``,stderr:`ln: ${$i(t.message)}
188
+ `,exitCode:1}}let u=``;return i&&(u=`'${c}' -> '${s}'
189
+ `),{stdout:u,stderr:``,exitCode:0}}},co={name:`ln`,flags:[{flag:`-s`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),uo={};E(uo,{chmodCommand:()=>ho,flagsForFuzzing:()=>go});async function fo(e,t,n,r,i,a){let o=new ca({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`chmod`});await oa({fs:e.fs,root:t,symlinks:`never`,budget:o,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`chmod`},async t=>{if(t.depth===0||t.phase!==`enter`)return;let o=n===void 0?r===void 0?420:po(r,t.stat.mode):n;await e.fs.chmod(t.path,o),i&&a.append(`mode of '${t.path}' changed to ${o.toString(8).padStart(4,`0`)}
190
+ `)})}function po(e,t=420){if(/^[0-7]+$/.test(e))return parseInt(e,8);let n=t&4095,r=e.split(`,`);for(let t of r){let r=t.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!r)throw Error(`Invalid mode: ${e}`);let i=r[1]||`a`,a=r[2],o=r[3];(i===`a`||i===``)&&(i=`ugo`);let s=0;o.includes(`r`)&&(s|=4),o.includes(`w`)&&(s|=2),(o.includes(`x`)||o.includes(`X`))&&(s|=1);let c=0;o.includes(`s`)&&(i.includes(`u`)&&(c|=2048),i.includes(`g`)&&(c|=1024)),o.includes(`t`)&&(c|=512);for(let e of i){let t=0;e===`u`?t=6:e===`g`?t=3:e===`o`&&(t=0);let r=s<<t;a===`+`?n|=r:a===`-`?n&=~r:a===`=`&&(n&=~(7<<t),e===`u`&&(n&=-2049),e===`g`&&(n&=-1025),e===`o`&&(n&=-513),n|=r)}a===`+`?n|=c:a===`-`?n&=~c:a===`=`&&(o.includes(`s`)&&(i.includes(`u`)&&(n|=c&2048),i.includes(`g`)&&(n|=c&1024)),o.includes(`t`)&&(n|=c&512))}return n}var mo,ho,go,_o=T(()=>{Wi(),Wr(),la(),F(),mo={name:`chmod`,summary:`change file mode bits`,usage:`chmod [OPTIONS] MODE FILE...`,options:[`-R change files recursively`,`-v output a diagnostic for every file processed`,` --help display this help and exit`]},ho={name:`chmod`,async execute(e,t){if(N(e))return M(mo);if(e.length<2)return{stdout:``,stderr:`chmod: missing operand
191
+ `,exitCode:1};let n=!1,r=!1,i=0;for(;i<e.length&&e[i].startsWith(`-`);){let t=e[i];if(t===`-R`||t===`--recursive`)n=!0,i++;else if(t===`-v`||t===`--verbose`)r=!0,i++;else if(t===`--`){i++;break}else{if(/^[+-]?[rwxugo]+/.test(t)||/^\d+$/.test(t))break;if(/^-[Rv]+$/.test(t)){t.includes(`R`)&&(n=!0),t.includes(`v`)&&(r=!0),i++;continue}return P(`chmod`,t)}}if(e.length-i<2)return{stdout:``,stderr:`chmod: missing operand
192
+ `,exitCode:1};let a=e[i],o=e.slice(i+1),s=/^[0-7]+$/.test(a),c;if(s)c=parseInt(a,8);else try{po(a,420)}catch{return{stdout:``,stderr:`chmod: invalid mode: '${a}'
193
+ `,exitCode:1}}let l=new Ui(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`chmod`),u=``,d=!1;for(let e of o){let i=t.fs.resolvePath(t.cwd,e);try{let o;o=s&&c!==void 0?c:po(a,(await t.fs.stat(i)).mode),await t.fs.chmod(i,o),r&&l.append(`mode of '${e}' changed to ${o.toString(8).padStart(4,`0`)}
194
+ `),n&&(await t.fs.stat(i)).isDirectory&&await fo(t,i,s?c:void 0,s?void 0:a,r,l)}catch(t){Ur(t),u+=`chmod: cannot access '${e}': No such file or directory
195
+ `,d=!0}}return{stdout:l.build(),stderr:u,exitCode:+!!d}}},go={name:`chmod`,flags:[{flag:`-R`,type:`boolean`},{flag:`-v`,type:`boolean`}],needsArgs:!0,minArgs:2}}),vo={};E(vo,{flagsForFuzzing:()=>bo,pwdCommand:()=>yo});var yo,bo,xo=T(()=>{yo={name:`pwd`,async execute(e,t){let n=!1;for(let t of e)if(t===`-P`)n=!0;else if(t===`-L`)n=!1;else{if(t===`--`)break;t.startsWith(`-`)}let r=t.cwd;if(n)try{r=await t.fs.realpath(t.cwd)}catch{}return{stdout:`${r}
196
+ `,stderr:``,exitCode:0}}},bo={name:`pwd`,flags:[{flag:`-P`,type:`boolean`},{flag:`-L`,type:`boolean`}]}}),So={};E(So,{flagsForFuzzing:()=>To,readlinkCommand:()=>wo});var Co,wo,To,Eo=T(()=>{la(),j(),F(),Co={name:`readlink`,summary:`print resolved symbolic links or canonical file names`,usage:`readlink [OPTIONS] FILE...`,options:[`-f canonicalize by following every symlink in every component of the given name recursively`,` --help display this help and exit`]},wo={name:`readlink`,async execute(e,t){if(N(e))return M(Co);let n=!1,r=0;for(;r<e.length&&e[r].startsWith(`-`);){let t=e[r];if(t===`-f`||t===`--canonicalize`)n=!0,r++;else if(t===`--`){r++;break}else return P(`readlink`,t)}let i=e.slice(r);if(i.length===0)return{stdout:``,stderr:`readlink: missing operand
197
+ `,exitCode:1};let a=``,o=!1,s=new ca({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`readlink`,label:`symlink traversal`});for(let e of i){let r=t.fs.resolvePath(t.cwd,e);try{if(n){let e=r,n=new Set;for(;s.visit(n.size),!n.has(e);){n.add(e);try{let n=await t.fs.readlink(e);if(n.startsWith(`/`))e=n;else{let r=e.substring(0,e.lastIndexOf(`/`))||`/`;e=t.fs.resolvePath(r,n)}}catch{break}}a+=`${e}
198
+ `}else{let e=await t.fs.readlink(r);a+=`${e}
199
+ `}}catch(e){if(e instanceof A||e instanceof kr)throw e;n?a+=`${r}
200
+ `:o=!0}}return{stdout:a,stderr:``,exitCode:+!!o}}},To={name:`readlink`,flags:[{flag:`-f`,type:`boolean`},{flag:`-e`,type:`boolean`}],needsArgs:!0}});function Do(e,t){let n=10,r=null,i=!1,a=!1,o=!1,s=[];for(let c=0;c<e.length;c++){let l=e[c];if(l===`-n`&&c+1<e.length){let r=e[++c];t===`tail`&&r.startsWith(`+`)?(o=!0,n=parseInt(r.slice(1),10)):n=parseInt(r,10)}else if(t===`tail`&&l.startsWith(`-n+`))o=!0,n=parseInt(l.slice(3),10);else if(l.startsWith(`-n`))n=parseInt(l.slice(2),10);else if(l===`-c`&&c+1<e.length)r=parseInt(e[++c],10);else if(l.startsWith(`-c`))r=parseInt(l.slice(2),10);else if(l.startsWith(`--bytes=`))r=parseInt(l.slice(8),10);else if(l.startsWith(`--lines=`))n=parseInt(l.slice(8),10);else if(l===`-q`||l===`--quiet`||l===`--silent`)i=!0;else if(l===`-v`||l===`--verbose`)a=!0;else if(l.match(/^-\d+$/))n=parseInt(l.slice(1),10);else{if(l.startsWith(`--`)||l.startsWith(`-`)&&l!==`-`)return{ok:!1,error:P(t,l)};s.push(l)}}return r!==null&&(Number.isNaN(r)||r<0)?{ok:!1,error:{stdout:``,stderr:`${t}: invalid number of bytes
201
+ `,exitCode:1}}:Number.isNaN(n)||n<0?{ok:!1,error:{stdout:``,stderr:`${t}: invalid number of lines
202
+ `,exitCode:1}}:{ok:!0,options:{lines:n,bytes:r,quiet:i,verbose:a,files:s,fromLine:o}}}async function Oo(e,t,n,r){let{quiet:i,verbose:a,files:o}=t;if(o.length>e.limits.maxArrayElements)throw new A(`${n}: file operand limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(o.length===0)return{stdout:r(e.stdin),stderr:``,exitCode:0,stdoutEncoding:`binary`};let s=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),c=new Ui(s,n),l=new Ui(s,n),u=0,d=0,f=a||!i&&o.length>1,p=0;for(let t=0;t<o.length;t++){let i=o[t];try{let t=e.fs.resolvePath(e.cwd,i);if((await e.fs.stat(t)).size>e.limits.maxInputBytes-d)throw new A(`${n}: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);let a=await lr(e.fs,t);if(a.length>e.limits.maxInputBytes-d)throw new A(`${n}: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);d+=a.length,e.executionScope?.consumeInput(a.length,n),f&&(p>0&&c.append(`
203
+ `),c.append(sr(`==> ${i} <==
204
+ `))),c.append(r(a)),p++}catch(e){Ur(e),l.append(`${n}: ${i}: No such file or directory
205
+ `),u=1}}return{stdout:c.build(),stderr:l.build(),exitCode:u,stdoutEncoding:`binary`}}function ko(e,t,n){if(n!==null)return e.slice(0,n);if(t===0)return``;let r=0,i=0,a=e.length;for(;r<a&&i<t;){let t=e.indexOf(`
206
+ `,r);if(t===-1)return e;i++,r=t+1}return r>0?e.slice(0,r):``}function Ao(e,t,n,r){if(n!==null)return n===0?``:e.slice(-n);let i=e.length;if(i===0)return``;if(r){let n=0,r=1;for(;n<i&&r<t;){let t=e.indexOf(`
207
+ `,n);if(t===-1)return``;r++,n=t+1}return e.slice(n)}if(t===0)return``;let a=i-1;e[a]===`
208
+ `&&a--;let o=0;for(;a>=0&&o<t;){if(e[a]===`
209
+ `&&(o++,o===t)){a++;break}a--}return a<0&&(a=0),e.slice(a)}var jo=T(()=>{Wi(),k(),Wr(),j(),F()}),Mo={};E(Mo,{flagsForFuzzing:()=>Fo,headCommand:()=>Po});var No,Po,Fo,Io=T(()=>{F(),jo(),No={name:`head`,summary:`output the first part of files`,usage:`head [OPTION]... [FILE]...`,options:[`-c, --bytes=NUM print the first NUM bytes`,`-n, --lines=NUM print the first NUM lines (default 10)`,`-q, --quiet never print headers giving file names`,`-v, --verbose always print headers giving file names`,` --help display this help and exit`]},Po={name:`head`,async execute(e,t){if(N(e))return M(No);let n=Do(e,`head`);if(!n.ok)return n.error;let{lines:r,bytes:i}=n.options;return Oo(t,n.options,`head`,e=>ko(e,r,i))}},Fo={name:`head`,flags:[{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-c`,type:`value`,valueHint:`number`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),Lo={};E(Lo,{flagsForFuzzing:()=>Bo,tailCommand:()=>zo});var Ro,zo,Bo,Vo=T(()=>{jo(),F(),Ro={name:`tail`,summary:`output the last part of files`,usage:`tail [OPTION]... [FILE]...`,options:[`-c, --bytes=NUM print the last NUM bytes`,`-n, --lines=NUM print the last NUM lines (default 10)`,`-n +NUM print starting from line NUM`,`-q, --quiet never print headers giving file names`,`-v, --verbose always print headers giving file names`,` --help display this help and exit`]},zo={name:`tail`,async execute(e,t){if(N(e))return M(Ro);let n=Do(e,`tail`);if(!n.ok)return n.error;let{lines:r,bytes:i,fromLine:a}=n.options;return Oo(t,n.options,`tail`,e=>Ao(e,r,i,a??!1))}},Bo={name:`tail`,flags:[{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-c`,type:`value`,valueHint:`number`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),Ho={};E(Ho,{flagsForFuzzing:()=>Jo,wcCommand:()=>qo});function Uo(e,t){let n=e,r=n.length,i=t?Array.from(or(e)).length:r,a=0,o=0,s=!1;for(let e=0;e<r;e++){let t=n[e];t===`
210
+ `?(a++,s&&=(o++,!1)):t===` `||t===` `||t===`\r`?s&&=(o++,!1):s=!0}return s&&o++,{lines:a,words:o,third:i}}function Wo(e,t,n,r,i,a){let o=[];t&&o.push(String(e.lines).padStart(a)),n&&o.push(String(e.words).padStart(a)),r&&o.push(String(e.third).padStart(a));let s=o.join(` `);return i&&(s+=` ${i}`),s}var Go,Ko,qo,Jo,Yo=T(()=>{k(),Kr(),Zr(),F(),Go={name:`wc`,summary:`print newline, word, and byte counts for each file`,usage:`wc [OPTION]... [FILE]...`,options:[`-c, --bytes print the byte counts`,`-m, --chars print the character counts`,`-l, --lines print the newline counts`,`-w, --words print the word counts`,` --help display this help and exit`]},Ko={lines:{short:`l`,long:`lines`,type:`boolean`},words:{short:`w`,long:`words`,type:`boolean`},bytes:{short:`c`,long:`bytes`,type:`boolean`},chars:{short:`m`,long:`chars`,type:`boolean`}},qo={name:`wc`,async execute(e,t){if(N(e))return M(Go);let n=Gr(`wc`,e,Ko);if(!n.ok)return n.error;let{lines:r,words:i}=n.result.flags,a=n.result.flags.bytes,o=n.result.flags.chars,s=n.result.positional;!r&&!i&&!a&&!o&&(r=i=a=!0);let c=a||o,l=await Yr(t,s,{cmdName:`wc`,stopOnError:!1});if(s.length===0)return{stdout:`${Wo(Uo(l.files[0].content,o),r,i,c,``,0)}
211
+ `,stderr:``,exitCode:0};let u=[],d=0,f=0,p=0;for(let{filename:e,content:t}of l.files){let n=Uo(t,o);d+=n.lines,f+=n.words,p+=n.third,u.push({filename:e,stats:n})}let m=s.length>1?d:Math.max(...u.map(e=>e.stats.lines)),h=s.length>1?f:Math.max(...u.map(e=>e.stats.words)),g=s.length>1?p:Math.max(...u.map(e=>e.stats.third)),_=s.length>1?3:0;r&&(_=Math.max(_,String(m).length)),i&&(_=Math.max(_,String(h).length)),c&&(_=Math.max(_,String(g).length));let v=``;for(let{filename:e,stats:t}of u)v+=`${Wo(t,r,i,c,e,_)}
212
+ `;return s.length>1&&(v+=`${Wo({lines:d,words:f,third:p},r,i,c,`total`,_)}
213
+ `),{stdout:v,stderr:l.stderr,exitCode:l.exitCode}}},Jo={name:`wc`,flags:[{flag:`-l`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-m`,type:`boolean`}],stdinType:`text`,needsFiles:!0}});function Xo(e,t){return(t?`d`:`-`)+[e&256?`r`:`-`,e&128?`w`:`-`,e&64?`x`:`-`,e&32?`r`:`-`,e&16?`w`:`-`,e&8?`x`:`-`,e&4?`r`:`-`,e&2?`w`:`-`,e&1?`x`:`-`].join(``)}var Zo=T(()=>{}),Qo={};E(Qo,{flagsForFuzzing:()=>ns,statCommand:()=>ts});var $o,es,ts,ns,rs=T(()=>{k(),Wr(),j(),Kr(),Zo(),F(),$o={name:`stat`,summary:`display file or file system status`,usage:`stat [OPTION]... FILE...`,options:[`-c FORMAT use the specified FORMAT instead of the default`,` --help display this help and exit`]},es={format:{short:`c`,type:`string`}},ts={name:`stat`,async execute(e,t){if(N(e))return M($o);let n=Gr(`stat`,e,es);if(!n.ok)return n.error;let r=n.result.flags.format??null,i=n.result.positional;if(i.length===0)return{stdout:``,stderr:`stat: missing operand
214
+ `,exitCode:1};let a=``,o=``,s=!1,c=0,l=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),u=e=>{let t=O(e);if(t>l-c)throw new A(`stat: output size limit exceeded (${l} bytes)`,`output_size`);a+=e,c+=t};for(let e of i){let n=t.fs.resolvePath(t.cwd,e);try{let i=await t.fs.stat(n);if(r){let t=i.mode.toString(8),n=Xo(i.mode,i.isDirectory),a=new Map([[`%n`,e],[`%N`,`'${e}'`],[`%s`,String(i.size)],[`%F`,i.isDirectory?`directory`:`regular file`],[`%a`,t],[`%A`,n],[`%u`,`1000`],[`%U`,`user`],[`%g`,`1000`],[`%G`,`group`]]);u(`${r.replace(/%[nNsFaAuUgG]/g,e=>a.get(e)??e)}
215
+ `)}else{let t=i.mode.toString(8).padStart(4,`0`),n=Xo(i.mode,i.isDirectory);u(` File: ${e}
216
+ Size: ${i.size} Blocks: ${Math.ceil(i.size/512)}
217
+ Access: (${t}/${n})
218
+ Modify: ${i.mtime.toISOString()}
219
+ `)}}catch(t){Ur(t),o+=`stat: cannot stat '${e}': No such file or directory
220
+ `,s=!0}}return{stdout:a,stderr:o,exitCode:+!!s}}},ns={name:`stat`,flags:[{flag:`-c`,type:`value`,valueHint:`format`},{flag:`-L`,type:`boolean`}],needsArgs:!0}}),L,R,z,is,B,as,os,ss,cs,ls,us,ds,fs,ps,ms,hs,gs,_s,vs,ys,bs,V,xs,Ss,Cs,ws,Ts,Es,Ds,H,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec,tc,nc,rc,ic,ac,oc=T(()=>{L=class e{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=e.CLASS_NL|e.DOT_NL;static PERL=e.CLASS_NL|e.ONE_LINE|e.PERL_X|e.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},R=class{static CODES=new Map([[`\x07`,7],[`\b`,8],[` `,9],[`
221
+ `,10],[`\v`,11],[`\f`,12],[`\r`,13],[` `,32],[`"`,34],[`$`,36],[`&`,38],[`(`,40],[`)`,41],[`*`,42],[`+`,43],[`-`,45],[`.`,46],[`0`,48],[`1`,49],[`2`,50],[`3`,51],[`4`,52],[`5`,53],[`6`,54],[`7`,55],[`8`,56],[`9`,57],[`:`,58],[`<`,60],[`>`,62],[`?`,63],[`A`,65],[`B`,66],[`C`,67],[`F`,70],[`P`,80],[`Q`,81],[`U`,85],[`Z`,90],[`[`,91],[`\\`,92],[`]`,93],[`^`,94],[`_`,95],[`a`,97],[`b`,98],[`f`,102],[`i`,105],[`m`,109],[`n`,110],[`r`,114],[`s`,115],[`t`,116],[`v`,118],[`x`,120],[`z`,122],[`{`,123],[`|`,124],[`}`,125]]);static toUpperCase(e){let t=String.fromCodePoint(e).toUpperCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toLowerCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}static toLowerCase(e){let t=String.fromCodePoint(e).toLowerCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toUpperCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}},z=class{SIZE=3;constructor(e){this.data=e}getLo(e){return this.data[e*this.SIZE]}getHi(e){return this.data[e*this.SIZE+1]}getStride(e){return this.data[e*this.SIZE+2]}get(e){let t=e*this.SIZE;return[this.data[t],this.data[t+1],this.data[t+2]]}get length(){return this.data.length/this.SIZE}},is=class e{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[68944,68976],[68976,68944],[68945,68977],[68977,68945],[68946,68978],[68978,68946],[68947,68979],[68979,68947],[68948,68980],[68980,68948],[68949,68981],[68981,68949],[68950,68982],[68982,68950],[68951,68983],[68983,68951],[68952,68984],[68984,68952],[68953,68985],[68985,68953],[68954,68986],[68986,68954],[68955,68987],[68987,68955],[68956,68988],[68988,68956],[68957,68989],[68989,68957],[68958,68990],[68990,68958],[68959,68991],[68991,68959],[68960,68992],[68992,68960],[68961,68993],[68993,68961],[68962,68994],[68994,68962],[68963,68995],[68995,68963],[68964,68996],[68996,68964],[68965,68997],[68997,68965],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[93771,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=new z(new Uint32Array([0,31,1,127,159,1,173,888,715,889,896,7,897,899,1,907,909,2,930,1328,398,1367,1368,1,1419,1420,1,1424,1480,56,1481,1487,1,1515,1518,1,1525,1541,1,1564,1757,193,1806,1807,1,1867,1868,1,1970,1983,1,2043,2044,1,2094,2095,1,2111,2140,29,2141,2143,2,2155,2159,1,2191,2198,1,2274,2436,162,2445,2446,1,2449,2450,1,2473,2481,8,2483,2485,1,2490,2491,1,2501,2502,1,2505,2506,1,2511,2518,1,2520,2523,1,2526,2532,6,2533,2559,26,2560,2564,4,2571,2574,1,2577,2578,1,2601,2609,8,2612,2618,3,2619,2621,2,2627,2630,1,2633,2634,1,2638,2640,1,2642,2648,1,2653,2655,2,2656,2661,1,2679,2688,1,2692,2702,10,2706,2729,23,2737,2740,3,2746,2747,1,2758,2766,4,2767,2769,2,2770,2783,1,2788,2789,1,2802,2808,1,2816,2820,4,2829,2830,1,2833,2834,1,2857,2865,8,2868,2874,6,2875,2885,10,2886,2889,3,2890,2894,4,2895,2900,1,2904,2907,1,2910,2916,6,2917,2936,19,2937,2945,1,2948,2955,7,2956,2957,1,2961,2966,5,2967,2968,1,2971,2973,2,2976,2978,1,2981,2983,1,2987,2989,1,3002,3005,1,3011,3013,1,3017,3022,5,3023,3025,2,3026,3030,1,3032,3045,1,3067,3071,1,3085,3089,4,3113,3130,17,3131,3141,10,3145,3150,5,3151,3156,1,3159,3163,4,3164,3166,2,3167,3172,5,3173,3184,11,3185,3190,1,3213,3217,4,3241,3252,11,3258,3259,1,3269,3273,4,3278,3284,1,3287,3292,1,3295,3300,5,3301,3312,11,3316,3327,1,3341,3345,4,3397,3401,4,3408,3411,1,3428,3429,1,3456,3460,4,3479,3481,1,3506,3516,10,3518,3519,1,3527,3529,1,3531,3534,1,3541,3543,2,3552,3557,1,3568,3569,1,3573,3584,1,3643,3646,1,3676,3712,1,3715,3717,2,3723,3748,25,3750,3774,24,3775,3781,6,3783,3791,8,3802,3803,1,3808,3839,1,3912,3949,37,3950,3952,1,3992,4029,37,4045,4059,14,4060,4095,1,4294,4296,2,4297,4300,1,4302,4303,1,4681,4686,5,4687,4695,8,4697,4702,5,4703,4745,42,4750,4751,1,4785,4790,5,4791,4799,8,4801,4806,5,4807,4823,16,4881,4886,5,4887,4955,68,4956,4989,33,4990,4991,1,5018,5023,1,5110,5111,1,5118,5119,1,5789,5791,1,5881,5887,1,5910,5918,1,5943,5951,1,5972,5983,1,5997,6001,4,6004,6015,1,6110,6111,1,6122,6127,1,6138,6143,1,6158,6170,12,6171,6175,1,6265,6271,1,6315,6319,1,6390,6399,1,6431,6444,13,6445,6447,1,6460,6463,1,6465,6467,1,6510,6511,1,6517,6527,1,6572,6575,1,6602,6607,1,6619,6621,1,6684,6685,1,6751,6781,30,6782,6794,12,6795,6799,1,6810,6815,1,6830,6831,1,6863,6911,1,6989,7156,167,7157,7163,1,7224,7226,1,7242,7244,1,7307,7311,1,7355,7356,1,7368,7375,1,7419,7423,1,7958,7959,1,7966,7967,1,8006,8007,1,8014,8015,1,8024,8030,2,8062,8063,1,8117,8133,16,8148,8149,1,8156,8176,20,8177,8181,4,8191,8203,12,8204,8207,1,8234,8238,1,8288,8303,1,8306,8307,1,8335,8349,14,8350,8351,1,8385,8399,1,8433,8447,1,8588,8591,1,9258,9279,1,9291,9311,1,11124,11125,1,11158,11508,350,11509,11512,1,11558,11560,2,11561,11564,1,11566,11567,1,11624,11630,1,11633,11646,1,11671,11679,1,11687,11743,8,11870,11903,1,11930,12020,90,12021,12031,1,12246,12271,1,12352,12439,87,12440,12544,104,12545,12548,1,12592,12687,95,12774,12782,1,12831,42125,29294,42126,42127,1,42183,42191,1,42540,42559,1,42744,42751,1,42958,42959,1,42962,42964,2,42973,42993,1,43053,43055,1,43066,43071,1,43128,43135,1,43206,43213,1,43226,43231,1,43348,43358,1,43389,43391,1,43470,43482,12,43483,43485,1,43519,43575,56,43576,43583,1,43598,43599,1,43610,43611,1,43715,43738,1,43767,43776,1,43783,43784,1,43791,43792,1,43799,43807,1,43815,43823,8,43884,43887,1,44014,44015,1,44026,44031,1,55204,55215,1,55239,55242,1,55292,63743,1,64110,64111,1,64218,64255,1,64263,64274,1,64280,64284,1,64311,64317,6,64319,64325,3,64451,64466,1,64912,64913,1,64968,64974,1,64976,65007,1,65050,65055,1,65107,65127,20,65132,65135,1,65141,65277,136,65278,65280,1,65471,65473,1,65480,65481,1,65488,65489,1,65496,65497,1,65501,65503,1,65511,65519,8,65520,65531,1,65534,65535,1,65548,65575,27,65595,65598,3,65614,65615,1,65630,65663,1,65787,65791,1,65795,65798,1,65844,65846,1,65935,65949,14,65950,65951,1,65953,65999,1,66046,66175,1,66205,66207,1,66257,66271,1,66300,66303,1,66340,66348,1,66379,66383,1,66427,66431,1,66462,66500,38,66501,66503,1,66518,66559,1,66718,66719,1,66730,66735,1,66772,66775,1,66812,66815,1,66856,66863,1,66916,66926,1,66939,66955,16,66963,66966,3,66978,66994,16,67002,67005,3,67006,67007,1,67060,67071,1,67383,67391,1,67414,67423,1,67432,67455,1,67462,67505,43,67515,67583,1,67590,67591,1,67593,67638,45,67641,67643,1,67645,67646,1,67670,67743,73,67744,67750,1,67760,67807,1,67827,67830,3,67831,67834,1,67868,67870,1,67898,67902,1,67904,67967,1,68024,68027,1,68048,68049,1,68100,68103,3,68104,68107,1,68116,68120,4,68150,68151,1,68155,68158,1,68169,68175,1,68185,68191,1,68256,68287,1,68327,68330,1,68343,68351,1,68406,68408,1,68438,68439,1,68467,68471,1,68498,68504,1,68509,68520,1,68528,68607,1,68681,68735,1,68787,68799,1,68851,68857,1,68904,68911,1,68922,68927,1,68966,68968,1,68998,69005,1,69008,69215,1,69247,69290,43,69294,69295,1,69298,69313,1,69317,69371,1,69416,69423,1,69466,69487,1,69514,69551,1,69580,69599,1,69623,69631,1,69710,69713,1,69750,69758,1,69821,69827,6,69828,69839,1,69865,69871,1,69882,69887,1,69941,69960,19,69961,69967,1,70007,70015,1,70112,70133,21,70134,70143,1,70162,70210,48,70211,70271,1,70279,70281,2,70286,70302,16,70314,70319,1,70379,70383,1,70394,70399,1,70404,70413,9,70414,70417,3,70418,70441,23,70449,70452,3,70458,70469,11,70470,70473,3,70474,70478,4,70479,70481,2,70482,70486,1,70488,70492,1,70500,70501,1,70509,70511,1,70517,70527,1,70538,70540,2,70541,70543,2,70582,70593,11,70595,70596,1,70598,70603,5,70614,70617,3,70618,70624,1,70627,70655,1,70748,70754,6,70755,70783,1,70856,70863,1,70874,71039,1,71094,71095,1,71134,71167,1,71237,71247,1,71258,71263,1,71277,71295,1,71354,71359,1,71370,71375,1,71396,71423,1,71451,71452,1,71468,71471,1,71495,71679,1,71740,71839,1,71923,71934,1,71943,71944,1,71946,71947,1,71956,71959,3,71990,71993,3,71994,72007,13,72008,72015,1,72026,72095,1,72104,72105,1,72152,72153,1,72165,72191,1,72264,72271,1,72355,72367,1,72441,72447,1,72458,72639,1,72674,72687,1,72698,72703,1,72713,72759,46,72774,72783,1,72813,72815,1,72848,72849,1,72872,72887,15,72888,72959,1,72967,72970,3,73015,73017,1,73019,73022,3,73032,73039,1,73050,73055,1,73062,73065,3,73103,73106,3,73113,73119,1,73130,73439,1,73465,73471,1,73489,73531,42,73532,73533,1,73563,73647,1,73649,73663,1,73714,73726,1,74650,74751,1,74863,74869,6,74870,74879,1,75076,77711,1,77811,77823,1,78896,78911,1,78934,78943,1,82939,82943,1,83527,90367,1,90426,92159,1,92729,92735,1,92767,92778,11,92779,92781,1,92863,92874,11,92875,92879,1,92910,92911,1,92918,92927,1,92998,93007,1,93018,93026,8,93048,93052,1,93072,93503,1,93562,93759,1,93851,93951,1,94027,94030,1,94088,94094,1,94112,94175,1,94181,94191,1,94194,94207,1,100344,100351,1,101590,101630,1,101641,110575,1,110580,110588,8,110591,110883,292,110884,110897,1,110899,110927,1,110931,110932,1,110934,110947,1,110952,110959,1,111356,113663,1,113771,113775,1,113789,113791,1,113801,113807,1,113818,113819,1,113824,117759,1,118010,118015,1,118452,118527,1,118574,118575,1,118599,118607,1,118724,118783,1,119030,119039,1,119079,119080,1,119155,119162,1,119275,119295,1,119366,119487,1,119508,119519,1,119540,119551,1,119639,119647,1,119673,119807,1,119893,119965,72,119968,119969,1,119971,119972,1,119975,119976,1,119981,119994,13,119996,120004,8,120070,120075,5,120076,120085,9,120093,120122,29,120127,120133,6,120135,120137,1,120145,120486,341,120487,120780,293,120781,121484,703,121485,121498,1,121504,121520,16,121521,122623,1,122655,122660,1,122667,122879,1,122887,122905,18,122906,122914,8,122917,122923,6,122924,122927,1,122990,123022,1,123024,123135,1,123181,123183,1,123198,123199,1,123210,123213,1,123216,123535,1,123567,123583,1,123642,123646,1,123648,124111,1,124154,124367,1,124411,124414,1,124416,124895,1,124903,124908,5,124911,124927,16,125125,125126,1,125143,125183,1,125260,125263,1,125274,125277,1,125280,126064,1,126133,126208,1,126270,126463,1,126468,126496,28,126499,126501,2,126502,126504,2,126515,126520,5,126522,126524,2,126525,126529,1,126531,126534,1,126536,126540,2,126544,126547,3,126549,126550,1,126552,126560,2,126563,126565,2,126566,126571,5,126579,126589,5,126591,126602,11,126620,126624,1,126628,126634,6,126652,126703,1,126706,126975,1,127020,127023,1,127124,127135,1,127151,127152,1,127168,127184,16,127222,127231,1,127406,127461,1,127491,127503,1,127548,127551,1,127561,127567,1,127570,127583,1,127590,127743,1,128728,128731,1,128749,128751,1,128765,128767,1,128887,128890,1,128986,128991,1,129004,129007,1,129009,129023,1,129036,129039,1,129096,129103,1,129114,129119,1,129160,129167,1,129198,129199,1,129212,129215,1,129218,129279,1,129620,129631,1,129646,129647,1,129661,129663,1,129674,129678,1,129735,129741,1,129757,129758,1,129770,129775,1,129785,129791,1,129939,130042,103,130043,131071,1,173792,173823,1,177978,177983,1,178206,178207,1,183970,183983,1,191457,191471,1,192094,194559,1,195102,196607,1,201547,201551,1,205744,917759,1,918e3,1114111,1]));static Cc=new z(new Uint32Array([0,31,1,127,159,1]));static Cf=new z(new Uint32Array([173,1536,1363,1537,1541,1,1564,1757,193,1807,2192,385,2193,2274,81,6158,8203,2045,8204,8207,1,8234,8238,1,8288,8292,1,8294,8303,1,65279,65529,250,65530,65531,1,69821,69837,16,78896,78911,1,113824,113827,1,119155,119162,1,917505,917536,31,917537,917631,1]));static Co=new z(new Uint32Array([57344,63743,1,983040,1048573,1,1048576,1114109,1]));static Cs=new z(new Uint32Array([55296,57343,1]));static L=new z(new Uint32Array([65,90,1,97,122,1,170,181,11,186,192,6,193,214,1,216,246,1,248,705,1,710,721,1,736,740,1,748,750,2,880,884,1,886,887,1,890,893,1,895,902,7,904,906,1,908,910,2,911,929,1,931,1013,1,1015,1153,1,1162,1327,1,1329,1366,1,1369,1376,7,1377,1416,1,1488,1514,1,1519,1522,1,1568,1610,1,1646,1647,1,1649,1747,1,1749,1765,16,1766,1774,8,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2036,2037,1,2042,2048,6,2049,2069,1,2074,2084,10,2088,2112,24,2113,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2249,1,2308,2361,1,2365,2384,19,2392,2401,1,2417,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3654,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3782,3804,22,3805,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4256,18,4257,4293,1,4295,4301,6,4304,4346,1,4348,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5024,5109,1,5112,5117,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6103,6108,5,6176,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6823,6917,94,6918,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7293,1,7296,7306,1,7312,7354,1,7357,7359,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,7424,6,7425,7615,1,7680,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8124,1,8126,8130,4,8131,8132,1,8134,8140,1,8144,8147,1,8150,8155,1,8160,8172,1,8178,8180,1,8182,8188,1,8305,8319,14,8336,8348,1,8450,8455,5,8458,8467,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8495,8505,1,8508,8511,1,8517,8521,1,8526,8579,53,8580,11264,2684,11265,11492,1,11499,11502,1,11506,11507,1,11520,11557,1,11559,11565,6,11568,11623,1,11631,11648,17,11649,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11823,12293,470,12294,12337,43,12338,12341,1,12347,12348,1,12353,12438,1,12445,12447,1,12449,12538,1,12540,12543,1,12549,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,42124,1,42192,42237,1,42240,42508,1,42512,42527,1,42538,42539,1,42560,42606,1,42623,42653,1,42656,42725,1,42775,42783,1,42786,42888,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43471,43488,17,43489,43492,1,43494,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43741,1,43744,43754,1,43762,43764,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43866,1,43868,43881,1,43888,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65313,65338,1,65345,65370,1,65382,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66560,66717,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68736,68786,1,68800,68850,1,68864,68899,1,68938,68965,1,68975,68997,1,69248,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71840,71903,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,92992,92995,1,93027,93047,1,93053,93071,1,93504,93548,1,93760,93823,1,93952,94026,1,94032,94099,67,94100,94111,1,94176,94177,1,94179,94208,29,94209,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120512,1,120514,120538,1,120540,120570,1,120572,120596,1,120598,120628,1,120630,120654,1,120656,120686,1,120688,120712,1,120714,120744,1,120746,120770,1,120772,120779,1,122624,122654,1,122661,122666,1,122928,122989,1,123136,123180,1,123191,123197,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124139,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125184,125251,1,125259,126464,1205,126465,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static foldL=new z(new Uint32Array([837,837,1]));static Ll=new z(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,311,2,312,328,2,329,375,2,378,382,2,383,384,1,387,389,2,392,396,4,397,402,5,405,409,4,410,411,1,414,417,3,419,421,2,424,426,2,427,429,2,432,436,4,438,441,3,442,445,3,446,447,1,454,460,3,462,476,2,477,495,2,496,499,3,501,505,4,507,563,2,564,569,1,572,575,3,576,578,2,583,591,2,592,659,1,661,687,1,881,883,2,887,891,4,892,893,1,912,940,28,941,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1020,1072,52,1073,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1376,1416,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7424,118,7425,7467,1,7531,7543,1,7545,7578,1,7681,7829,2,7830,7837,1,7839,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8016,8023,1,8032,8039,1,8048,8061,1,8064,8071,1,8080,8087,1,8096,8103,1,8112,8116,1,8118,8119,1,8126,8130,4,8131,8132,1,8134,8135,1,8144,8147,1,8150,8151,1,8160,8167,1,8178,8180,1,8182,8183,1,8458,8462,4,8463,8467,4,8495,8505,5,8508,8509,1,8518,8521,1,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11377,11379,2,11380,11382,2,11383,11387,1,11393,11491,2,11492,11500,8,11502,11507,5,11520,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42800,42801,1,42803,42865,2,42866,42872,1,42874,42876,2,42879,42887,2,42892,42894,2,42897,42899,2,42900,42901,1,42903,42921,2,42927,42933,6,42935,42947,2,42952,42954,2,42957,42961,4,42963,42971,2,42998,43002,4,43824,43866,1,43872,43880,1,43888,43967,1,64256,64262,1,64275,64279,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,119834,119859,1,119886,119892,1,119894,119911,1,119938,119963,1,119990,119993,1,119995,119997,2,119998,120003,1,120005,120015,1,120042,120067,1,120094,120119,1,120146,120171,1,120198,120223,1,120250,120275,1,120302,120327,1,120354,120379,1,120406,120431,1,120458,120485,1,120514,120538,1,120540,120545,1,120572,120596,1,120598,120603,1,120630,120654,1,120656,120661,1,120688,120712,1,120714,120719,1,120746,120770,1,120772,120777,1,120779,122624,1845,122625,122633,1,122635,122654,1,122661,122666,1,125218,125251,1]));static foldLl=new z(new Uint32Array([65,90,1,192,214,1,216,222,1,256,302,2,306,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,453,1,455,456,1,458,459,1,461,475,2,478,494,2,497,498,1,500,502,2,503,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,837,880,43,882,886,4,895,902,7,904,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,984,9,986,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8072,8079,1,8088,8095,1,8104,8111,1,8120,8124,1,8136,8140,1,8152,8155,1,8168,8172,1,8184,8188,1,8486,8490,4,8491,8498,7,8579,11264,2685,11265,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,125184,125217,1]));static Lm=new z(new Uint32Array([688,705,1,710,721,1,736,740,1,748,750,2,884,890,6,1369,1600,231,1765,1766,1,2036,2037,1,2042,2074,32,2084,2088,4,2249,2417,168,3654,3782,128,4348,6103,1755,6211,6823,612,7288,7293,1,7468,7530,1,7544,7579,35,7580,7615,1,8305,8319,14,8336,8348,1,11388,11389,1,11631,11823,192,12293,12337,44,12338,12341,1,12347,12445,98,12446,12540,94,12541,12542,1,40981,42232,1251,42233,42237,1,42508,42623,115,42652,42653,1,42775,42783,1,42864,42888,24,42994,42996,1,43e3,43001,1,43471,43494,23,43632,43741,109,43763,43764,1,43868,43871,1,43881,65392,21511,65438,65439,1,67456,67461,1,67463,67504,1,67506,67514,1,68942,68975,33,92992,92995,1,93504,93506,1,93547,93548,1,94099,94111,1,94176,94177,1,94179,110576,16397,110577,110579,1,110581,110587,1,110589,110590,1,122928,122989,1,123191,123197,1,124139,125259,1120]));static Lo=new z(new Uint32Array([170,186,16,443,448,5,449,451,1,660,1488,828,1489,1514,1,1519,1522,1,1568,1599,1,1601,1610,1,1646,1647,1,1649,1747,1,1749,1774,25,1775,1786,11,1787,1788,1,1791,1808,17,1810,1839,1,1869,1957,1,1969,1994,25,1995,2026,1,2048,2069,1,2112,2136,1,2144,2154,1,2160,2183,1,2185,2190,1,2208,2248,1,2308,2361,1,2365,2384,19,2392,2401,1,2418,2432,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2493,2510,17,2524,2525,1,2527,2529,1,2544,2545,1,2556,2565,9,2566,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2649,2652,1,2654,2674,20,2675,2676,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2749,2768,19,2784,2785,1,2809,2821,12,2822,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2877,2908,31,2909,2911,2,2912,2913,1,2929,2947,18,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3024,3077,53,3078,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3133,3160,27,3161,3162,1,3165,3168,3,3169,3200,31,3205,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3261,3293,32,3294,3296,2,3297,3313,16,3314,3332,18,3333,3340,1,3342,3344,1,3346,3386,1,3389,3406,17,3412,3414,1,3423,3425,1,3450,3455,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3585,3632,1,3634,3635,1,3648,3653,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3760,1,3762,3763,1,3773,3776,3,3777,3780,1,3804,3807,1,3840,3904,64,3905,3911,1,3913,3948,1,3976,3980,1,4096,4138,1,4159,4176,17,4177,4181,1,4186,4189,1,4193,4197,4,4198,4206,8,4207,4208,1,4213,4225,1,4238,4352,114,4353,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4992,5007,1,5121,5740,1,5743,5759,1,5761,5786,1,5792,5866,1,5873,5880,1,5888,5905,1,5919,5937,1,5952,5969,1,5984,5996,1,5998,6e3,1,6016,6067,1,6108,6176,68,6177,6210,1,6212,6264,1,6272,6276,1,6279,6312,1,6314,6320,6,6321,6389,1,6400,6430,1,6480,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6656,6678,1,6688,6740,1,6917,6963,1,6981,6988,1,7043,7072,1,7086,7087,1,7098,7141,1,7168,7203,1,7245,7247,1,7258,7287,1,7401,7404,1,7406,7411,1,7413,7414,1,7418,8501,1083,8502,8504,1,11568,11623,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,12294,12348,54,12353,12438,1,12447,12449,2,12450,12538,1,12543,12549,6,12550,12591,1,12593,12686,1,12704,12735,1,12784,12799,1,13312,19903,1,19968,40980,1,40982,42124,1,42192,42231,1,42240,42507,1,42512,42527,1,42538,42539,1,42606,42656,50,42657,42725,1,42895,42999,104,43003,43009,1,43011,43013,1,43015,43018,1,43020,43042,1,43072,43123,1,43138,43187,1,43250,43255,1,43259,43261,2,43262,43274,12,43275,43301,1,43312,43334,1,43360,43388,1,43396,43442,1,43488,43492,1,43495,43503,1,43514,43518,1,43520,43560,1,43584,43586,1,43588,43595,1,43616,43631,1,43633,43638,1,43642,43646,4,43647,43695,1,43697,43701,4,43702,43705,3,43706,43709,1,43712,43714,2,43739,43740,1,43744,43754,1,43762,43777,15,43778,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43968,44002,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64285,64287,2,64288,64296,1,64298,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64433,1,64467,64829,1,64848,64911,1,64914,64967,1,65008,65019,1,65136,65140,1,65142,65276,1,65382,65391,1,65393,65437,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,66176,66204,1,66208,66256,1,66304,66335,1,66349,66368,1,66370,66377,1,66384,66421,1,66432,66461,1,66464,66499,1,66504,66511,1,66640,66717,1,66816,66855,1,66864,66915,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67680,67702,1,67712,67742,1,67808,67826,1,67828,67829,1,67840,67861,1,67872,67897,1,67968,68023,1,68030,68031,1,68096,68112,16,68113,68115,1,68117,68119,1,68121,68149,1,68192,68220,1,68224,68252,1,68288,68295,1,68297,68324,1,68352,68405,1,68416,68437,1,68448,68466,1,68480,68497,1,68608,68680,1,68864,68899,1,68938,68941,1,68943,69248,305,69249,69289,1,69296,69297,1,69314,69316,1,69376,69404,1,69415,69424,9,69425,69445,1,69488,69505,1,69552,69572,1,69600,69622,1,69635,69687,1,69745,69746,1,69749,69763,14,69764,69807,1,69840,69864,1,69891,69926,1,69956,69959,3,69968,70002,1,70006,70019,13,70020,70066,1,70081,70084,1,70106,70108,2,70144,70161,1,70163,70187,1,70207,70208,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70312,1,70320,70366,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70461,70480,19,70493,70497,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70609,26,70611,70656,45,70657,70708,1,70727,70730,1,70751,70753,1,70784,70831,1,70852,70853,1,70855,71040,185,71041,71086,1,71128,71131,1,71168,71215,1,71236,71296,60,71297,71338,1,71352,71424,72,71425,71450,1,71488,71494,1,71680,71723,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71983,1,71999,72001,2,72096,72103,1,72106,72144,1,72161,72163,2,72192,72203,11,72204,72242,1,72250,72272,22,72284,72329,1,72349,72368,19,72369,72440,1,72640,72672,1,72704,72712,1,72714,72750,1,72768,72818,50,72819,72847,1,72960,72966,1,72968,72969,1,72971,73008,1,73030,73056,26,73057,73061,1,73063,73064,1,73066,73097,1,73112,73440,328,73441,73458,1,73474,73476,2,73477,73488,1,73490,73523,1,73648,73728,80,73729,74649,1,74880,75075,1,77712,77808,1,77824,78895,1,78913,78918,1,78944,82938,1,82944,83526,1,90368,90397,1,92160,92728,1,92736,92766,1,92784,92862,1,92880,92909,1,92928,92975,1,93027,93047,1,93053,93071,1,93507,93546,1,93952,94026,1,94032,94208,176,94209,100343,1,100352,101589,1,101631,101640,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,122634,123136,502,123137,123180,1,123214,123536,322,123537,123565,1,123584,123627,1,124112,124138,1,124368,124397,1,124400,124896,496,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Lt=new z(new Uint32Array([453,459,3,498,8072,7574,8073,8079,1,8088,8095,1,8104,8111,1,8124,8140,16,8188,8188,1]));static foldLt=new z(new Uint32Array([452,454,2,455,457,2,458,460,2,497,499,2,8064,8071,1,8080,8087,1,8096,8103,1,8115,8131,16,8179,8179,1]));static Lu=new z(new Uint32Array([65,90,1,192,214,1,216,222,1,256,310,2,313,327,2,330,376,2,377,381,2,385,386,1,388,390,2,391,393,2,394,395,1,398,401,1,403,404,1,406,408,1,412,413,1,415,416,1,418,422,2,423,425,2,428,430,2,431,433,2,434,435,1,437,439,2,440,444,4,452,461,3,463,475,2,478,494,2,497,500,3,502,504,1,506,562,2,570,571,1,573,574,1,577,579,2,580,582,1,584,590,2,880,882,2,886,895,9,902,904,2,905,906,1,908,910,2,911,913,2,914,929,1,931,939,1,975,978,3,979,980,1,984,1006,2,1012,1015,3,1017,1018,1,1021,1071,1,1120,1152,2,1162,1216,2,1217,1229,2,1232,1326,2,1329,1366,1,4256,4293,1,4295,4301,6,5024,5109,1,7305,7312,7,7313,7354,1,7357,7359,1,7680,7828,2,7838,7934,2,7944,7951,1,7960,7965,1,7976,7983,1,7992,7999,1,8008,8013,1,8025,8031,2,8040,8047,1,8120,8123,1,8136,8139,1,8152,8155,1,8168,8172,1,8184,8187,1,8450,8455,5,8459,8461,1,8464,8466,1,8469,8473,4,8474,8477,1,8484,8490,2,8491,8493,1,8496,8499,1,8510,8511,1,8517,8579,62,11264,11311,1,11360,11362,2,11363,11364,1,11367,11373,2,11374,11376,1,11378,11381,3,11390,11392,1,11394,11490,2,11499,11501,2,11506,42560,31054,42562,42604,2,42624,42650,2,42786,42798,2,42802,42862,2,42873,42877,2,42878,42886,2,42891,42893,2,42896,42898,2,42902,42922,2,42923,42926,1,42928,42932,1,42934,42948,2,42949,42951,1,42953,42955,2,42956,42960,4,42966,42972,2,42997,65313,22316,65314,65338,1,66560,66599,1,66736,66771,1,66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,68736,68786,1,68944,68965,1,71840,71871,1,93760,93791,1,119808,119833,1,119860,119885,1,119912,119937,1,119964,119966,2,119967,119973,3,119974,119977,3,119978,119980,1,119982,119989,1,120016,120041,1,120068,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120120,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120172,120197,1,120224,120249,1,120276,120301,1,120328,120353,1,120380,120405,1,120432,120457,1,120488,120512,1,120546,120570,1,120604,120628,1,120662,120686,1,120720,120744,1,120778,125184,4406,125185,125217,1]));static Upper=this.Lu;static foldLu=new z(new Uint32Array([97,122,1,181,223,42,224,246,1,248,255,1,257,303,2,307,311,2,314,328,2,331,375,2,378,382,2,383,384,1,387,389,2,392,396,4,402,405,3,409,411,1,414,417,3,419,421,2,424,429,5,432,436,4,438,441,3,445,447,2,453,454,1,456,457,1,459,460,1,462,476,2,477,495,2,498,499,1,501,505,4,507,543,2,547,563,2,572,575,3,576,578,2,583,591,2,592,596,1,598,599,1,601,603,2,604,608,4,609,611,2,612,614,1,616,620,1,623,625,2,626,629,3,637,640,3,642,643,1,647,652,1,658,669,11,670,837,167,881,883,2,887,891,4,892,893,1,940,943,1,945,974,1,976,977,1,981,983,1,985,1007,2,1008,1011,1,1013,1019,3,1072,1119,1,1121,1153,2,1163,1215,2,1218,1230,2,1231,1327,2,1377,1414,1,4304,4346,1,4349,4351,1,5112,5117,1,7296,7304,1,7306,7545,239,7549,7566,17,7681,7829,2,7835,7841,6,7843,7935,2,7936,7943,1,7952,7957,1,7968,7975,1,7984,7991,1,8e3,8005,1,8017,8023,2,8032,8039,1,8048,8061,1,8112,8113,1,8126,8144,18,8145,8160,15,8161,8165,4,8526,8580,54,11312,11359,1,11361,11365,4,11366,11372,2,11379,11382,3,11393,11491,2,11500,11502,2,11507,11520,13,11521,11557,1,11559,11565,6,42561,42605,2,42625,42651,2,42787,42799,2,42803,42863,2,42874,42876,2,42879,42887,2,42892,42897,5,42899,42900,1,42903,42921,2,42933,42947,2,42952,42954,2,42957,42961,4,42967,42971,2,42998,43859,861,43888,43967,1,65345,65370,1,66600,66639,1,66776,66811,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,68800,68850,1,68976,68997,1,71872,71903,1,93792,93823,1,125218,125251,1]));static M=new z(new Uint32Array([768,879,1,1155,1161,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2307,1,2362,2364,1,2366,2383,1,2385,2391,1,2402,2403,1,2433,2435,1,2492,2494,2,2495,2500,1,2503,2504,1,2507,2509,1,2519,2530,11,2531,2558,27,2561,2563,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2672,31,2673,2677,4,2689,2691,1,2748,2750,2,2751,2757,1,2759,2761,1,2763,2765,1,2786,2787,1,2810,2815,1,2817,2819,1,2876,2878,2,2879,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2914,2915,1,2946,3006,60,3007,3010,1,3014,3016,1,3018,3021,1,3031,3072,41,3073,3076,1,3132,3134,2,3135,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3203,1,3260,3262,2,3263,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3298,3299,1,3315,3328,13,3329,3331,1,3387,3388,1,3390,3396,1,3398,3400,1,3402,3405,1,3415,3426,11,3427,3457,30,3458,3459,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3570,3571,1,3633,3636,3,3637,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3902,3903,1,3953,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4139,101,4140,4158,1,4182,4185,1,4190,4192,1,4194,4196,1,4199,4205,1,4209,4212,1,4226,4237,1,4239,4250,11,4251,4253,1,4957,4959,1,5906,5909,1,5938,5940,1,5970,5971,1,6002,6003,1,6068,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6443,1,6448,6459,1,6679,6683,1,6741,6750,1,6752,6780,1,6783,6832,49,6833,6862,1,6912,6916,1,6964,6980,1,7019,7027,1,7040,7042,1,7073,7085,1,7142,7155,1,7204,7223,1,7376,7378,1,7380,7400,1,7405,7412,7,7415,7417,1,7616,7679,1,8400,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12335,1,12441,12442,1,42607,42610,1,42612,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43043,24,43044,43047,1,43052,43136,84,43137,43188,51,43189,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43347,1,43392,43395,1,43443,43456,1,43493,43561,68,43562,43574,1,43587,43596,9,43597,43643,46,43644,43645,1,43696,43698,2,43699,43700,1,43703,43704,1,43710,43711,1,43713,43755,42,43756,43759,1,43765,43766,1,44003,44010,1,44012,44013,1,64286,65024,738,65025,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69632,69634,1,69688,69702,1,69744,69747,3,69748,69759,11,69760,69762,1,69808,69818,1,69826,69888,62,69889,69890,1,69927,69940,1,69957,69958,1,70003,70016,13,70017,70018,1,70067,70080,1,70089,70092,1,70094,70095,1,70188,70199,1,70206,70209,3,70367,70378,1,70400,70403,1,70459,70460,1,70462,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70502,3,70503,70508,1,70512,70516,1,70584,70592,1,70594,70597,3,70599,70602,1,70604,70608,1,70610,70625,15,70626,70709,83,70710,70726,1,70750,70832,82,70833,70851,1,71087,71093,1,71096,71104,1,71132,71133,1,71216,71232,1,71339,71351,1,71453,71467,1,71724,71738,1,71984,71989,1,71991,71992,1,71995,71998,1,72e3,72002,2,72003,72145,142,72146,72151,1,72154,72160,1,72164,72193,29,72194,72202,1,72243,72249,1,72251,72254,1,72263,72273,10,72274,72283,1,72330,72345,1,72751,72758,1,72760,72767,1,72850,72871,1,72873,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73098,67,73099,73102,1,73104,73105,1,73107,73111,1,73459,73462,1,73472,73473,1,73475,73524,49,73525,73530,1,73534,73538,1,73562,78912,5350,78919,78933,1,90398,90415,1,92912,92916,1,92976,92982,1,94031,94033,2,94034,94087,1,94095,94098,1,94180,94192,12,94193,113821,19628,113822,118528,4706,118529,118573,1,118576,118598,1,119141,119145,1,119149,119154,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldM=new z(new Uint32Array([921,953,32,8126,8126,1]));static Mc=new z(new Uint32Array([2307,2363,56,2366,2368,1,2377,2380,1,2382,2383,1,2434,2435,1,2494,2496,1,2503,2504,1,2507,2508,1,2519,2563,44,2622,2624,1,2691,2750,59,2751,2752,1,2761,2763,2,2764,2818,54,2819,2878,59,2880,2887,7,2888,2891,3,2892,2903,11,3006,3007,1,3009,3010,1,3014,3016,1,3018,3020,1,3031,3073,42,3074,3075,1,3137,3140,1,3202,3203,1,3262,3264,2,3265,3268,1,3271,3272,1,3274,3275,1,3285,3286,1,3315,3330,15,3331,3390,59,3391,3392,1,3398,3400,1,3402,3404,1,3415,3458,43,3459,3535,76,3536,3537,1,3544,3551,1,3570,3571,1,3902,3903,1,3967,4139,172,4140,4145,5,4152,4155,3,4156,4182,26,4183,4194,11,4195,4196,1,4199,4205,1,4227,4228,1,4231,4236,1,4239,4250,11,4251,4252,1,5909,5940,31,6070,6078,8,6079,6085,1,6087,6088,1,6435,6438,1,6441,6443,1,6448,6449,1,6451,6456,1,6681,6682,1,6741,6743,2,6753,6755,2,6756,6765,9,6766,6770,1,6916,6965,49,6971,6973,2,6974,6977,1,6979,6980,1,7042,7073,31,7078,7079,1,7082,7143,61,7146,7148,1,7150,7154,4,7155,7204,49,7205,7211,1,7220,7221,1,7393,7415,22,12334,12335,1,43043,43044,1,43047,43136,89,43137,43188,51,43189,43203,1,43346,43347,1,43395,43444,49,43445,43450,5,43451,43454,3,43455,43456,1,43567,43568,1,43571,43572,1,43597,43643,46,43645,43755,110,43758,43759,1,43765,44003,238,44004,44006,2,44007,44009,2,44010,44012,2,69632,69634,2,69762,69808,46,69809,69810,1,69815,69816,1,69932,69957,25,69958,70018,60,70067,70069,1,70079,70080,1,70094,70188,94,70189,70190,1,70194,70195,1,70197,70368,171,70369,70370,1,70402,70403,1,70462,70463,1,70465,70468,1,70471,70472,1,70475,70477,1,70487,70498,11,70499,70584,85,70585,70586,1,70594,70597,3,70599,70602,1,70604,70605,1,70607,70709,102,70710,70711,1,70720,70721,1,70725,70832,107,70833,70834,1,70841,70843,2,70844,70846,1,70849,71087,238,71088,71089,1,71096,71099,1,71102,71216,114,71217,71218,1,71227,71228,1,71230,71340,110,71342,71343,1,71350,71454,104,71456,71457,1,71462,71724,262,71725,71726,1,71736,71984,248,71985,71989,1,71991,71992,1,71997,72e3,3,72002,72145,143,72146,72147,1,72156,72159,1,72164,72249,85,72279,72280,1,72343,72751,408,72766,72873,107,72881,72884,3,73098,73102,1,73107,73108,1,73110,73461,351,73462,73475,13,73524,73525,1,73534,73535,1,73537,90410,16873,90411,90412,1,94033,94087,1,94192,94193,1,119141,119142,1,119149,119154,1]));static Me=new z(new Uint32Array([1160,1161,1,6846,8413,1567,8414,8416,1,8418,8420,1,42608,42610,1]));static Mn=new z(new Uint32Array([768,879,1,1155,1159,1,1425,1469,1,1471,1473,2,1474,1476,2,1477,1479,2,1552,1562,1,1611,1631,1,1648,1750,102,1751,1756,1,1759,1764,1,1767,1768,1,1770,1773,1,1809,1840,31,1841,1866,1,1958,1968,1,2027,2035,1,2045,2070,25,2071,2073,1,2075,2083,1,2085,2087,1,2089,2093,1,2137,2139,1,2199,2207,1,2250,2273,1,2275,2306,1,2362,2364,2,2369,2376,1,2381,2385,4,2386,2391,1,2402,2403,1,2433,2492,59,2497,2500,1,2509,2530,21,2531,2558,27,2561,2562,1,2620,2625,5,2626,2631,5,2632,2635,3,2636,2637,1,2641,2672,31,2673,2677,4,2689,2690,1,2748,2753,5,2754,2757,1,2759,2760,1,2765,2786,21,2787,2810,23,2811,2815,1,2817,2876,59,2879,2881,2,2882,2884,1,2893,2901,8,2902,2914,12,2915,2946,31,3008,3021,13,3072,3076,4,3132,3134,2,3135,3136,1,3142,3144,1,3146,3149,1,3157,3158,1,3170,3171,1,3201,3260,59,3263,3270,7,3276,3277,1,3298,3299,1,3328,3329,1,3387,3388,1,3393,3396,1,3405,3426,21,3427,3457,30,3530,3538,8,3539,3540,1,3542,3633,91,3636,3642,1,3655,3662,1,3761,3764,3,3765,3772,1,3784,3790,1,3864,3865,1,3893,3897,2,3953,3966,1,3968,3972,1,3974,3975,1,3981,3991,1,3993,4028,1,4038,4141,103,4142,4144,1,4146,4151,1,4153,4154,1,4157,4158,1,4184,4185,1,4190,4192,1,4209,4212,1,4226,4229,3,4230,4237,7,4253,4957,704,4958,4959,1,5906,5908,1,5938,5939,1,5970,5971,1,6002,6003,1,6068,6069,1,6071,6077,1,6086,6089,3,6090,6099,1,6109,6155,46,6156,6157,1,6159,6277,118,6278,6313,35,6432,6434,1,6439,6440,1,6450,6457,7,6458,6459,1,6679,6680,1,6683,6742,59,6744,6750,1,6752,6754,2,6757,6764,1,6771,6780,1,6783,6832,49,6833,6845,1,6847,6862,1,6912,6915,1,6964,6966,2,6967,6970,1,6972,6978,6,7019,7027,1,7040,7041,1,7074,7077,1,7080,7081,1,7083,7085,1,7142,7144,2,7145,7149,4,7151,7153,1,7212,7219,1,7222,7223,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8400,8412,1,8417,8421,4,8422,8432,1,11503,11505,1,11647,11744,97,11745,11775,1,12330,12333,1,12441,12442,1,42607,42612,5,42613,42621,1,42654,42655,1,42736,42737,1,43010,43014,4,43019,43045,26,43046,43052,6,43204,43205,1,43232,43249,1,43263,43302,39,43303,43309,1,43335,43345,1,43392,43394,1,43443,43446,3,43447,43449,1,43452,43453,1,43493,43561,68,43562,43566,1,43569,43570,1,43573,43574,1,43587,43596,9,43644,43696,52,43698,43700,1,43703,43704,1,43710,43711,1,43713,43756,43,43757,43766,9,44005,44008,3,44013,64286,20273,65024,65039,1,65056,65071,1,66045,66272,227,66422,66426,1,68097,68099,1,68101,68102,1,68108,68111,1,68152,68154,1,68159,68325,166,68326,68900,574,68901,68903,1,68969,68973,1,69291,69292,1,69372,69375,1,69446,69456,1,69506,69509,1,69633,69688,55,69689,69702,1,69744,69747,3,69748,69759,11,69760,69761,1,69811,69814,1,69817,69818,1,69826,69888,62,69889,69890,1,69927,69931,1,69933,69940,1,70003,70016,13,70017,70070,53,70071,70078,1,70089,70092,1,70095,70191,96,70192,70193,1,70196,70198,2,70199,70206,7,70209,70367,158,70371,70378,1,70400,70401,1,70459,70460,1,70464,70502,38,70503,70508,1,70512,70516,1,70587,70592,1,70606,70610,2,70625,70626,1,70712,70719,1,70722,70724,1,70726,70750,24,70835,70840,1,70842,70847,5,70848,70850,2,70851,71090,239,71091,71093,1,71100,71101,1,71103,71104,1,71132,71133,1,71219,71226,1,71229,71231,2,71232,71339,107,71341,71344,3,71345,71349,1,71351,71453,102,71455,71458,3,71459,71461,1,71463,71467,1,71727,71735,1,71737,71738,1,71995,71996,1,71998,72003,5,72148,72151,1,72154,72155,1,72160,72193,33,72194,72202,1,72243,72248,1,72251,72254,1,72263,72273,10,72274,72278,1,72281,72283,1,72330,72342,1,72344,72345,1,72752,72758,1,72760,72765,1,72767,72850,83,72851,72871,1,72874,72880,1,72882,72883,1,72885,72886,1,73009,73014,1,73018,73020,2,73021,73023,2,73024,73029,1,73031,73104,73,73105,73109,4,73111,73459,348,73460,73472,12,73473,73526,53,73527,73530,1,73536,73538,2,73562,78912,5350,78919,78933,1,90398,90409,1,90413,90415,1,92912,92916,1,92976,92982,1,94031,94095,64,94096,94098,1,94180,113821,19641,113822,118528,4706,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,119362,119364,1,121344,121398,1,121403,121452,1,121461,121476,15,121499,121503,1,121505,121519,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,123023,123184,161,123185,123190,1,123566,123628,62,123629,123631,1,124140,124143,1,124398,124399,1,125136,125142,1,125252,125258,1,917760,917999,1]));static foldMn=new z(new Uint32Array([921,953,32,8126,8126,1]));static N=new z(new Uint32Array([48,57,1,178,179,1,185,188,3,189,190,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2548,2553,1,2662,2671,1,2790,2799,1,2918,2927,1,2930,2935,1,3046,3058,1,3174,3183,1,3192,3198,1,3302,3311,1,3416,3422,1,3430,3448,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3891,1,4160,4169,1,4240,4249,1,4969,4988,1,5870,5872,1,6112,6121,1,6128,6137,1,6160,6169,1,6470,6479,1,6608,6618,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,8304,8308,4,8309,8313,1,8320,8329,1,8528,8578,1,8581,8585,1,9312,9371,1,9450,9471,1,10102,10131,1,11517,12295,778,12321,12329,1,12344,12346,1,12690,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,42528,42537,1,42726,42735,1,43056,43061,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,65799,65843,1,65856,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,66369,66378,9,66513,66517,1,66720,66729,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,68912,68921,1,68928,68937,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70113,70132,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71483,1,71904,71922,1,72016,72025,1,72688,72697,1,72784,72812,1,73040,73049,1,73120,73129,1,73552,73561,1,73664,73684,1,74752,74862,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93019,93025,1,93552,93561,1,93824,93846,1,118e3,118009,1,119488,119507,1,119520,119539,1,119648,119672,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125127,125135,1,125264,125273,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1,130032,130041,1]));static Nd=new z(new Uint32Array([48,57,1,1632,1641,1,1776,1785,1,1984,1993,1,2406,2415,1,2534,2543,1,2662,2671,1,2790,2799,1,2918,2927,1,3046,3055,1,3174,3183,1,3302,3311,1,3430,3439,1,3558,3567,1,3664,3673,1,3792,3801,1,3872,3881,1,4160,4169,1,4240,4249,1,6112,6121,1,6160,6169,1,6470,6479,1,6608,6617,1,6784,6793,1,6800,6809,1,6992,7001,1,7088,7097,1,7232,7241,1,7248,7257,1,42528,42537,1,43216,43225,1,43264,43273,1,43472,43481,1,43504,43513,1,43600,43609,1,44016,44025,1,65296,65305,1,66720,66729,1,68912,68921,1,68928,68937,1,69734,69743,1,69872,69881,1,69942,69951,1,70096,70105,1,70384,70393,1,70736,70745,1,70864,70873,1,71248,71257,1,71360,71369,1,71376,71395,1,71472,71481,1,71904,71913,1,72016,72025,1,72688,72697,1,72784,72793,1,73040,73049,1,73120,73129,1,73552,73561,1,90416,90425,1,92768,92777,1,92864,92873,1,93008,93017,1,93552,93561,1,118e3,118009,1,120782,120831,1,123200,123209,1,123632,123641,1,124144,124153,1,124401,124410,1,125264,125273,1,130032,130041,1]));static Nl=new z(new Uint32Array([5870,5872,1,8544,8578,1,8581,8584,1,12295,12321,26,12322,12329,1,12344,12346,1,42726,42735,1,65856,65908,1,66369,66378,9,66513,66517,1,74752,74862,1]));static No=new z(new Uint32Array([178,179,1,185,188,3,189,190,1,2548,2553,1,2930,2935,1,3056,3058,1,3192,3198,1,3416,3422,1,3440,3448,1,3882,3891,1,4969,4988,1,6128,6137,1,6618,8304,1686,8308,8313,1,8320,8329,1,8528,8543,1,8585,9312,727,9313,9371,1,9450,9471,1,10102,10131,1,11517,12690,1173,12691,12693,1,12832,12841,1,12872,12879,1,12881,12895,1,12928,12937,1,12977,12991,1,43056,43061,1,65799,65843,1,65909,65912,1,65930,65931,1,66273,66299,1,66336,66339,1,67672,67679,1,67705,67711,1,67751,67759,1,67835,67839,1,67862,67867,1,68028,68029,1,68032,68047,1,68050,68095,1,68160,68168,1,68221,68222,1,68253,68255,1,68331,68335,1,68440,68447,1,68472,68479,1,68521,68527,1,68858,68863,1,69216,69246,1,69405,69414,1,69457,69460,1,69573,69579,1,69714,69733,1,70113,70132,1,71482,71483,1,71914,71922,1,72794,72812,1,73664,73684,1,93019,93025,1,93824,93846,1,119488,119507,1,119520,119539,1,119648,119672,1,125127,125135,1,126065,126123,1,126125,126127,1,126129,126132,1,126209,126253,1,126255,126269,1,127232,127244,1]));static P=new z(new Uint32Array([33,35,1,37,42,1,44,47,1,58,59,1,63,64,1,91,93,1,95,123,28,125,161,36,167,171,4,182,183,1,187,191,4,894,903,9,1370,1375,1,1417,1418,1,1470,1472,2,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3898,38,3899,3901,1,3973,4048,75,4049,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5120,5742,622,5787,5788,1,5867,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8208,829,8209,8231,1,8240,8259,1,8261,8273,1,8275,8286,1,8317,8318,1,8333,8334,1,8968,8971,1,9001,9002,1,10088,10101,1,10181,10182,1,10214,10223,1,10627,10648,1,10712,10715,1,10748,10749,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11822,1,11824,11855,1,11858,11869,1,12289,12291,1,12296,12305,1,12308,12319,1,12336,12349,13,12448,12539,91,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,64830,20819,64831,65040,209,65041,65049,1,65072,65106,1,65108,65121,1,65123,65128,5,65130,65131,1,65281,65283,1,65285,65290,1,65292,65295,1,65306,65307,1,65311,65312,1,65339,65341,1,65343,65371,28,65373,65375,2,65376,65381,1,65792,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,68974,69293,319,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Pc=new z(new Uint32Array([95,8255,8160,8256,8276,20,65075,65076,1,65101,65103,1,65343,65343,1]));static Pd=new z(new Uint32Array([45,1418,1373,1470,5120,3650,6150,8208,2058,8209,8213,1,11799,11802,3,11834,11835,1,11840,11869,29,12316,12336,20,12448,65073,52625,65074,65112,38,65123,65293,170,68974,69293,319]));static Pe=new z(new Uint32Array([41,93,52,125,3899,3774,3901,5788,1887,8262,8318,56,8334,8969,635,8971,9002,31,10089,10101,2,10182,10215,33,10217,10223,2,10628,10648,2,10713,10715,2,10749,11811,1062,11813,11817,2,11862,11868,2,12297,12305,2,12309,12315,2,12318,12319,1,64830,65048,218,65078,65092,2,65096,65114,18,65116,65118,2,65289,65341,52,65373,65379,3]));static Pf=new z(new Uint32Array([187,8217,8030,8221,8250,29,11779,11781,2,11786,11789,3,11805,11809,4]));static Pi=new z(new Uint32Array([171,8216,8045,8219,8220,1,8223,8249,26,11778,11780,2,11785,11788,3,11804,11808,4]));static Po=new z(new Uint32Array([33,35,1,37,39,1,42,46,2,47,58,11,59,63,4,64,92,28,161,167,6,182,183,1,191,894,703,903,1370,467,1371,1375,1,1417,1472,55,1475,1478,3,1523,1524,1,1545,1546,1,1548,1549,1,1563,1565,2,1566,1567,1,1642,1645,1,1748,1792,44,1793,1805,1,2039,2041,1,2096,2110,1,2142,2404,262,2405,2416,11,2557,2678,121,2800,3191,391,3204,3572,368,3663,3674,11,3675,3844,169,3845,3858,1,3860,3973,113,4048,4052,1,4057,4058,1,4170,4175,1,4347,4960,613,4961,4968,1,5742,5867,125,5868,5869,1,5941,5942,1,6100,6102,1,6104,6106,1,6144,6149,1,6151,6154,1,6468,6469,1,6686,6687,1,6816,6822,1,6824,6829,1,6990,6991,1,7002,7008,1,7037,7039,1,7164,7167,1,7227,7231,1,7294,7295,1,7360,7367,1,7379,8214,835,8215,8224,9,8225,8231,1,8240,8248,1,8251,8254,1,8257,8259,1,8263,8273,1,8275,8277,2,8278,8286,1,11513,11516,1,11518,11519,1,11632,11776,144,11777,11782,5,11783,11784,1,11787,11790,3,11791,11798,1,11800,11801,1,11803,11806,3,11807,11818,11,11819,11822,1,11824,11833,1,11836,11839,1,11841,11843,2,11844,11855,1,11858,11860,1,12289,12291,1,12349,12539,190,42238,42239,1,42509,42511,1,42611,42622,11,42738,42743,1,43124,43127,1,43214,43215,1,43256,43258,1,43260,43310,50,43311,43359,48,43457,43469,1,43486,43487,1,43612,43615,1,43742,43743,1,43760,43761,1,44011,65040,21029,65041,65046,1,65049,65072,23,65093,65094,1,65097,65100,1,65104,65106,1,65108,65111,1,65119,65121,1,65128,65130,2,65131,65281,150,65282,65283,1,65285,65287,1,65290,65294,2,65295,65306,11,65307,65311,4,65312,65340,28,65377,65380,3,65381,65792,411,65793,65794,1,66463,66512,49,66927,67671,744,67871,67903,32,68176,68184,1,68223,68336,113,68337,68342,1,68409,68415,1,68505,68508,1,69461,69465,1,69510,69513,1,69703,69709,1,69819,69820,1,69822,69825,1,69952,69955,1,70004,70005,1,70085,70088,1,70093,70107,14,70109,70111,1,70200,70205,1,70313,70612,299,70613,70615,2,70616,70731,115,70732,70735,1,70746,70747,1,70749,70854,105,71105,71127,1,71233,71235,1,71264,71276,1,71353,71484,131,71485,71486,1,71739,72004,265,72005,72006,1,72162,72255,93,72256,72262,1,72346,72348,1,72350,72354,1,72448,72457,1,72673,72769,96,72770,72773,1,72816,72817,1,73463,73464,1,73539,73551,1,73727,74864,1137,74865,74868,1,77809,77810,1,92782,92783,1,92917,92983,66,92984,92987,1,92996,93549,553,93550,93551,1,93847,93850,1,94178,113823,19645,121479,121483,1,124415,125278,863,125279,125279,1]));static Ps=new z(new Uint32Array([40,91,51,123,3898,3775,3900,5787,1887,8218,8222,4,8261,8317,56,8333,8968,635,8970,9001,31,10088,10100,2,10181,10214,33,10216,10222,2,10627,10647,2,10712,10714,2,10748,11810,1062,11812,11816,2,11842,11861,19,11863,11867,2,12296,12304,2,12308,12314,2,12317,64831,52514,65047,65077,30,65079,65091,2,65095,65113,18,65115,65117,2,65288,65339,51,65371,65375,4,65378,65378,1]));static S=new z(new Uint32Array([36,43,7,60,62,1,94,96,2,124,126,2,162,166,1,168,169,1,172,174,2,175,177,1,180,184,4,215,247,32,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,1014,113,1154,1421,267,1422,1423,1,1542,1544,1,1547,1550,3,1551,1758,207,1769,1789,20,1790,2038,248,2046,2047,1,2184,2546,362,2547,2554,7,2555,2801,246,2928,3059,131,3060,3066,1,3199,3407,208,3449,3647,198,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6107,366,6464,6622,158,6623,6655,1,7009,7018,1,7028,7036,1,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,8260,8274,14,8314,8316,1,8330,8332,1,8352,8384,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8472,1,8478,8483,1,8485,8489,2,8494,8506,12,8507,8512,5,8513,8516,1,8522,8525,1,8527,8586,59,8587,8592,5,8593,8967,1,8972,9e3,1,9003,9257,1,9280,9290,1,9372,9449,1,9472,10087,1,10132,10180,1,10183,10213,1,10224,10626,1,10649,10711,1,10716,10747,1,10750,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12443,12444,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,42752,42774,1,42784,42785,1,42889,42890,1,43048,43051,1,43062,43065,1,43639,43641,1,43867,43882,15,43883,64297,20414,64434,64450,1,64832,64847,1,64975,65020,45,65021,65023,1,65122,65124,2,65125,65126,1,65129,65284,155,65291,65308,17,65309,65310,1,65342,65344,2,65372,65374,2,65504,65510,1,65512,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,69006,710,69007,71487,2480,73685,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,123647,432,126124,126128,4,126254,126704,450,126705,126976,271,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Sc=new z(new Uint32Array([36,162,126,163,165,1,1423,1547,124,2046,2047,1,2546,2547,1,2555,2801,246,3065,3647,582,6107,8352,2245,8353,8384,1,43064,65020,21956,65129,65284,155,65504,65505,1,65509,65510,1,73693,73696,1,123647,126128,2481]));static Sk=new z(new Uint32Array([94,96,2,168,175,7,180,184,4,706,709,1,722,735,1,741,747,1,749,751,2,752,767,1,885,900,15,901,2184,1283,8125,8127,2,8128,8129,1,8141,8143,1,8157,8159,1,8173,8175,1,8189,8190,1,12443,12444,1,42752,42774,1,42784,42785,1,42889,42890,1,43867,43882,15,43883,64434,20551,64435,64450,1,65342,65344,2,65507,127995,62488,127996,127999,1]));static Sm=new z(new Uint32Array([43,60,17,61,62,1,124,126,2,172,177,5,215,247,32,1014,1542,528,1543,1544,1,8260,8274,14,8314,8316,1,8330,8332,1,8472,8512,40,8513,8516,1,8523,8592,69,8593,8596,1,8602,8603,1,8608,8614,3,8622,8654,32,8655,8658,3,8660,8692,32,8693,8959,1,8992,8993,1,9084,9115,31,9116,9139,1,9180,9185,1,9655,9665,10,9720,9727,1,9839,10176,337,10177,10180,1,10183,10213,1,10224,10239,1,10496,10626,1,10649,10711,1,10716,10747,1,10750,11007,1,11056,11076,1,11079,11084,1,64297,65122,825,65124,65126,1,65291,65308,17,65309,65310,1,65372,65374,2,65506,65513,7,65514,65516,1,69006,69007,1,120513,120539,26,120571,120597,26,120629,120655,26,120687,120713,26,120745,120771,26,126704,126705,1]));static So=new z(new Uint32Array([166,169,3,174,176,2,1154,1421,267,1422,1550,128,1551,1758,207,1769,1789,20,1790,2038,248,2554,2928,374,3059,3064,1,3066,3199,133,3407,3449,42,3841,3843,1,3859,3861,2,3862,3863,1,3866,3871,1,3892,3896,2,4030,4037,1,4039,4044,1,4046,4047,1,4053,4056,1,4254,4255,1,5008,5017,1,5741,6464,723,6622,6655,1,7009,7018,1,7028,7036,1,8448,8449,1,8451,8454,1,8456,8457,1,8468,8470,2,8471,8478,7,8479,8483,1,8485,8489,2,8494,8506,12,8507,8522,15,8524,8525,1,8527,8586,59,8587,8597,10,8598,8601,1,8604,8607,1,8609,8610,1,8612,8613,1,8615,8621,1,8623,8653,1,8656,8657,1,8659,8661,2,8662,8691,1,8960,8967,1,8972,8991,1,8994,9e3,1,9003,9083,1,9085,9114,1,9140,9179,1,9186,9257,1,9280,9290,1,9372,9449,1,9472,9654,1,9656,9664,1,9666,9719,1,9728,9838,1,9840,10087,1,10132,10175,1,10240,10495,1,11008,11055,1,11077,11078,1,11085,11123,1,11126,11157,1,11159,11263,1,11493,11498,1,11856,11857,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12292,12306,14,12307,12320,13,12342,12343,1,12350,12351,1,12688,12689,1,12694,12703,1,12736,12773,1,12783,12800,17,12801,12830,1,12842,12871,1,12880,12896,16,12897,12927,1,12938,12976,1,12992,13311,1,19904,19967,1,42128,42182,1,43048,43051,1,43062,43063,1,43065,43639,574,43640,43641,1,64832,64847,1,64975,65021,46,65022,65023,1,65508,65512,4,65517,65518,1,65532,65533,1,65847,65855,1,65913,65929,1,65932,65934,1,65936,65948,1,65952,66e3,48,66001,66044,1,67703,67704,1,68296,71487,3191,73685,73692,1,73697,73713,1,92988,92991,1,92997,113820,20823,117760,117999,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119140,1,119146,119148,1,119171,119172,1,119180,119209,1,119214,119274,1,119296,119361,1,119365,119552,187,119553,119638,1,120832,121343,1,121399,121402,1,121453,121460,1,121462,121475,1,121477,121478,1,123215,126124,2909,126254,126976,722,126977,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127245,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,127994,1,128e3,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130031,1]));static Z=new z(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8232,8233,1,8239,8287,48,12288,12288,1]));static Zl=new z(new Uint32Array([8232,8232,1]));static Zp=new z(new Uint32Array([8233,8233,1]));static Zs=new z(new Uint32Array([32,160,128,5760,8192,2432,8193,8202,1,8239,8287,48,12288,12288,1]));static Adlam=new z(new Uint32Array([125184,125259,1,125264,125273,1,125278,125279,1]));static Ahom=new z(new Uint32Array([71424,71450,1,71453,71467,1,71472,71494,1]));static Anatolian_Hieroglyphs=new z(new Uint32Array([82944,83526,1]));static Arabic=new z(new Uint32Array([1536,1540,1,1542,1547,1,1549,1562,1,1564,1566,1,1568,1599,1,1601,1610,1,1622,1647,1,1649,1756,1,1758,1791,1,1872,1919,1,2160,2190,1,2192,2193,1,2199,2273,1,2275,2303,1,64336,64450,1,64467,64829,1,64832,64911,1,64914,64967,1,64975,65008,33,65009,65023,1,65136,65140,1,65142,65276,1,69216,69246,1,69314,69316,1,69372,69375,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1]));static Armenian=new z(new Uint32Array([1329,1366,1,1369,1418,1,1421,1423,1,64275,64279,1]));static Avestan=new z(new Uint32Array([68352,68405,1,68409,68415,1]));static Balinese=new z(new Uint32Array([6912,6988,1,6990,7039,1]));static Bamum=new z(new Uint32Array([42656,42743,1,92160,92728,1]));static Bassa_Vah=new z(new Uint32Array([92880,92909,1,92912,92917,1]));static Batak=new z(new Uint32Array([7104,7155,1,7164,7167,1]));static Bengali=new z(new Uint32Array([2432,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1]));static Bhaiksuki=new z(new Uint32Array([72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1]));static Bopomofo=new z(new Uint32Array([746,747,1,12549,12591,1,12704,12735,1]));static Brahmi=new z(new Uint32Array([69632,69709,1,69714,69749,1,69759,69759,1]));static Braille=new z(new Uint32Array([10240,10495,1]));static Buginese=new z(new Uint32Array([6656,6683,1,6686,6687,1]));static Buhid=new z(new Uint32Array([5952,5971,1]));static Canadian_Aboriginal=new z(new Uint32Array([5120,5759,1,6320,6389,1,72368,72383,1]));static Carian=new z(new Uint32Array([66208,66256,1]));static Caucasian_Albanian=new z(new Uint32Array([66864,66915,1,66927,66927,1]));static Chakma=new z(new Uint32Array([69888,69940,1,69942,69959,1]));static Cham=new z(new Uint32Array([43520,43574,1,43584,43597,1,43600,43609,1,43612,43615,1]));static Cherokee=new z(new Uint32Array([5024,5109,1,5112,5117,1,43888,43967,1]));static Chorasmian=new z(new Uint32Array([69552,69579,1]));static Common=new z(new Uint32Array([0,64,1,91,96,1,123,169,1,171,185,1,187,191,1,215,247,32,697,735,1,741,745,1,748,767,1,884,894,10,901,903,2,1541,1548,7,1563,1567,4,1600,1757,157,2274,2404,130,2405,3647,1242,4053,4056,1,4347,5867,1520,5868,5869,1,5941,5942,1,6146,6147,1,6149,7379,1230,7393,7401,8,7402,7404,1,7406,7411,1,7413,7415,1,7418,8192,774,8193,8203,1,8206,8292,1,8294,8304,1,8308,8318,1,8320,8334,1,8352,8384,1,8448,8485,1,8487,8489,1,8492,8497,1,8499,8525,1,8527,8543,1,8585,8587,1,8592,9257,1,9280,9290,1,9312,10239,1,10496,11123,1,11126,11157,1,11159,11263,1,11776,11869,1,12272,12292,1,12294,12296,2,12297,12320,1,12336,12343,1,12348,12351,1,12443,12444,1,12448,12539,91,12540,12688,148,12689,12703,1,12736,12773,1,12783,12832,49,12833,12895,1,12927,13007,1,13055,13144,89,13145,13311,1,19904,19967,1,42752,42785,1,42888,42890,1,43056,43065,1,43310,43471,161,43867,43882,15,43883,64830,20947,64831,65040,209,65041,65049,1,65072,65106,1,65108,65126,1,65128,65131,1,65279,65281,2,65282,65312,1,65339,65344,1,65371,65381,1,65392,65438,46,65439,65504,65,65505,65510,1,65512,65518,1,65529,65533,1,65792,65794,1,65799,65843,1,65847,65855,1,65936,65948,1,66e3,66044,1,66273,66299,1,113824,113827,1,117760,118009,1,118016,118451,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119142,1,119146,119162,1,119171,119172,1,119180,119209,1,119214,119274,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,120831,1,126065,126132,1,126209,126269,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127487,1,127489,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,917505,917536,31,917537,917631,1]));static foldCommon=new z(new Uint32Array([924,956,32]));static Coptic=new z(new Uint32Array([994,1007,1,11392,11507,1,11513,11519,1]));static Cuneiform=new z(new Uint32Array([73728,74649,1,74752,74862,1,74864,74868,1,74880,75075,1]));static Cypriot=new z(new Uint32Array([67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3]));static Cypro_Minoan=new z(new Uint32Array([77712,77810,1]));static Cyrillic=new z(new Uint32Array([1024,1156,1,1159,1327,1,7296,7306,1,7467,7544,77,11744,11775,1,42560,42655,1,65070,65071,1,122928,122989,1,123023,123023,1]));static Deseret=new z(new Uint32Array([66560,66639,1]));static Devanagari=new z(new Uint32Array([2304,2384,1,2389,2403,1,2406,2431,1,43232,43263,1,72448,72457,1]));static Dives_Akuru=new z(new Uint32Array([71936,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1]));static Dogra=new z(new Uint32Array([71680,71739,1]));static Duployan=new z(new Uint32Array([113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1]));static Egyptian_Hieroglyphs=new z(new Uint32Array([77824,78933,1,78944,82938,1]));static Elbasan=new z(new Uint32Array([66816,66855,1]));static Elymaic=new z(new Uint32Array([69600,69622,1]));static Ethiopic=new z(new Uint32Array([4608,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,11648,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,124896,124902,1,124904,124907,1,124909,124910,1,124912,124926,1]));static Garay=new z(new Uint32Array([68928,68965,1,68969,68997,1,69006,69007,1]));static Georgian=new z(new Uint32Array([4256,4293,1,4295,4301,6,4304,4346,1,4348,4351,1,7312,7354,1,7357,7359,1,11520,11557,1,11559,11565,6]));static Glagolitic=new z(new Uint32Array([11264,11359,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1]));static Gothic=new z(new Uint32Array([66352,66378,1]));static Grantha=new z(new Uint32Array([70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70460,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1]));static Greek=new z(new Uint32Array([880,883,1,885,887,1,890,893,1,895,900,5,902,904,2,905,906,1,908,910,2,911,929,1,931,993,1,1008,1023,1,7462,7466,1,7517,7521,1,7526,7530,1,7615,7936,321,7937,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8486,43877,35391,65856,65934,1,65952,119296,53344,119297,119365,1]));static foldGreek=new z(new Uint32Array([181,837,656]));static Gujarati=new z(new Uint32Array([2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1]));static Gunjala_Gondi=new z(new Uint32Array([73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1]));static Gurmukhi=new z(new Uint32Array([2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1]));static Gurung_Khema=new z(new Uint32Array([90368,90425,1]));static Han=new z(new Uint32Array([11904,11929,1,11931,12019,1,12032,12245,1,12293,12295,2,12321,12329,1,12344,12347,1,13312,19903,1,19968,40959,1,63744,64109,1,64112,64217,1,94178,94179,1,94192,94193,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1]));static Hangul=new z(new Uint32Array([4352,4607,1,12334,12335,1,12593,12686,1,12800,12830,1,12896,12926,1,43360,43388,1,44032,55203,1,55216,55238,1,55243,55291,1,65440,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1]));static Hanifi_Rohingya=new z(new Uint32Array([68864,68903,1,68912,68921,1]));static Hanunoo=new z(new Uint32Array([5920,5940,1]));static Hatran=new z(new Uint32Array([67808,67826,1,67828,67829,1,67835,67839,1]));static Hebrew=new z(new Uint32Array([1425,1479,1,1488,1514,1,1519,1524,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64335,1]));static Hiragana=new z(new Uint32Array([12353,12438,1,12445,12447,1,110593,110879,1,110898,110928,30,110929,110930,1,127488,127488,1]));static Imperial_Aramaic=new z(new Uint32Array([67648,67669,1,67671,67679,1]));static Inherited=new z(new Uint32Array([768,879,1,1157,1158,1,1611,1621,1,1648,2385,737,2386,2388,1,6832,6862,1,7376,7378,1,7380,7392,1,7394,7400,1,7405,7412,7,7416,7417,1,7616,7679,1,8204,8205,1,8400,8432,1,12330,12333,1,12441,12442,1,65024,65039,1,65056,65069,1,66045,66272,227,70459,118528,48069,118529,118573,1,118576,118598,1,119143,119145,1,119163,119170,1,119173,119179,1,119210,119213,1,917760,917999,1]));static foldInherited=new z(new Uint32Array([921,953,32,8126,8126,1]));static Inscriptional_Pahlavi=new z(new Uint32Array([68448,68466,1,68472,68479,1]));static Inscriptional_Parthian=new z(new Uint32Array([68416,68437,1,68440,68447,1]));static Javanese=new z(new Uint32Array([43392,43469,1,43472,43481,1,43486,43487,1]));static Kaithi=new z(new Uint32Array([69760,69826,1,69837,69837,1]));static Kannada=new z(new Uint32Array([3200,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1]));static Katakana=new z(new Uint32Array([12449,12538,1,12541,12543,1,12784,12799,1,13008,13054,1,13056,13143,1,65382,65391,1,65393,65437,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110880,288,110881,110882,1,110933,110948,15,110949,110951,1]));static Kawi=new z(new Uint32Array([73472,73488,1,73490,73530,1,73534,73562,1]));static Kayah_Li=new z(new Uint32Array([43264,43309,1,43311,43311,1]));static Kharoshthi=new z(new Uint32Array([68096,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1]));static Khitan_Small_Script=new z(new Uint32Array([94180,101120,6940,101121,101589,1,101631,101631,1]));static Khmer=new z(new Uint32Array([6016,6109,1,6112,6121,1,6128,6137,1,6624,6655,1]));static Khojki=new z(new Uint32Array([70144,70161,1,70163,70209,1]));static Khudawadi=new z(new Uint32Array([70320,70378,1,70384,70393,1]));static Kirat_Rai=new z(new Uint32Array([93504,93561,1]));static Lao=new z(new Uint32Array([3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1]));static Latin=new z(new Uint32Array([65,90,1,97,122,1,170,186,16,192,214,1,216,246,1,248,696,1,736,740,1,7424,7461,1,7468,7516,1,7522,7525,1,7531,7543,1,7545,7614,1,7680,7935,1,8305,8319,14,8336,8348,1,8490,8491,1,8498,8526,28,8544,8584,1,11360,11391,1,42786,42887,1,42891,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43007,1,43824,43866,1,43868,43876,1,43878,43881,1,64256,64262,1,65313,65338,1,65345,65370,1,67456,67461,1,67463,67504,1,67506,67514,1,122624,122654,1,122661,122666,1]));static Lepcha=new z(new Uint32Array([7168,7223,1,7227,7241,1,7245,7247,1]));static Limbu=new z(new Uint32Array([6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6479,1]));static Linear_A=new z(new Uint32Array([67072,67382,1,67392,67413,1,67424,67431,1]));static Linear_B=new z(new Uint32Array([65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1]));static Lisu=new z(new Uint32Array([42192,42239,1,73648,73648,1]));static Lycian=new z(new Uint32Array([66176,66204,1]));static Lydian=new z(new Uint32Array([67872,67897,1,67903,67903,1]));static Mahajani=new z(new Uint32Array([69968,70006,1]));static Makasar=new z(new Uint32Array([73440,73464,1]));static Malayalam=new z(new Uint32Array([3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1]));static Mandaic=new z(new Uint32Array([2112,2139,1,2142,2142,1]));static Manichaean=new z(new Uint32Array([68288,68326,1,68331,68342,1]));static Marchen=new z(new Uint32Array([72816,72847,1,72850,72871,1,72873,72886,1]));static Masaram_Gondi=new z(new Uint32Array([72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1]));static Medefaidrin=new z(new Uint32Array([93760,93850,1]));static Meetei_Mayek=new z(new Uint32Array([43744,43766,1,43968,44013,1,44016,44025,1]));static Mende_Kikakui=new z(new Uint32Array([124928,125124,1,125127,125142,1]));static Meroitic_Cursive=new z(new Uint32Array([68e3,68023,1,68028,68047,1,68050,68095,1]));static Meroitic_Hieroglyphs=new z(new Uint32Array([67968,67999,1]));static Miao=new z(new Uint32Array([93952,94026,1,94031,94087,1,94095,94111,1]));static Modi=new z(new Uint32Array([71168,71236,1,71248,71257,1]));static Mongolian=new z(new Uint32Array([6144,6145,1,6148,6150,2,6151,6169,1,6176,6264,1,6272,6314,1,71264,71276,1]));static Mro=new z(new Uint32Array([92736,92766,1,92768,92777,1,92782,92783,1]));static Multani=new z(new Uint32Array([70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1]));static Myanmar=new z(new Uint32Array([4096,4255,1,43488,43518,1,43616,43647,1,71376,71395,1]));static Nabataean=new z(new Uint32Array([67712,67742,1,67751,67759,1]));static Nag_Mundari=new z(new Uint32Array([124112,124153,1]));static Nandinagari=new z(new Uint32Array([72096,72103,1,72106,72151,1,72154,72164,1]));static New_Tai_Lue=new z(new Uint32Array([6528,6571,1,6576,6601,1,6608,6618,1,6622,6623,1]));static Newa=new z(new Uint32Array([70656,70747,1,70749,70753,1]));static Nko=new z(new Uint32Array([1984,2042,1,2045,2047,1]));static Nushu=new z(new Uint32Array([94177,110960,16783,110961,111355,1]));static Nyiakeng_Puachue_Hmong=new z(new Uint32Array([123136,123180,1,123184,123197,1,123200,123209,1,123214,123215,1]));static Ogham=new z(new Uint32Array([5760,5788,1]));static Ol_Chiki=new z(new Uint32Array([7248,7295,1]));static Ol_Onal=new z(new Uint32Array([124368,124410,1,124415,124415,1]));static Old_Hungarian=new z(new Uint32Array([68736,68786,1,68800,68850,1,68858,68863,1]));static Old_Italic=new z(new Uint32Array([66304,66339,1,66349,66351,1]));static Old_North_Arabian=new z(new Uint32Array([68224,68255,1]));static Old_Permic=new z(new Uint32Array([66384,66426,1]));static Old_Persian=new z(new Uint32Array([66464,66499,1,66504,66517,1]));static Old_Sogdian=new z(new Uint32Array([69376,69415,1]));static Old_South_Arabian=new z(new Uint32Array([68192,68223,1]));static Old_Turkic=new z(new Uint32Array([68608,68680,1]));static Old_Uyghur=new z(new Uint32Array([69488,69513,1]));static Oriya=new z(new Uint32Array([2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1]));static Osage=new z(new Uint32Array([66736,66771,1,66776,66811,1]));static Osmanya=new z(new Uint32Array([66688,66717,1,66720,66729,1]));static Pahawh_Hmong=new z(new Uint32Array([92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1]));static Palmyrene=new z(new Uint32Array([67680,67711,1]));static Pau_Cin_Hau=new z(new Uint32Array([72384,72440,1]));static Phags_Pa=new z(new Uint32Array([43072,43127,1]));static Phoenician=new z(new Uint32Array([67840,67867,1,67871,67871,1]));static Psalter_Pahlavi=new z(new Uint32Array([68480,68497,1,68505,68508,1,68521,68527,1]));static Rejang=new z(new Uint32Array([43312,43347,1,43359,43359,1]));static Runic=new z(new Uint32Array([5792,5866,1,5870,5880,1]));static Samaritan=new z(new Uint32Array([2048,2093,1,2096,2110,1]));static Saurashtra=new z(new Uint32Array([43136,43205,1,43214,43225,1]));static Sharada=new z(new Uint32Array([70016,70111,1]));static Shavian=new z(new Uint32Array([66640,66687,1]));static Siddham=new z(new Uint32Array([71040,71093,1,71096,71133,1]));static SignWriting=new z(new Uint32Array([120832,121483,1,121499,121503,1,121505,121519,1]));static Sinhala=new z(new Uint32Array([3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,70113,70132,1]));static Sogdian=new z(new Uint32Array([69424,69465,1]));static Sora_Sompeng=new z(new Uint32Array([69840,69864,1,69872,69881,1]));static Soyombo=new z(new Uint32Array([72272,72354,1]));static Sundanese=new z(new Uint32Array([7040,7103,1,7360,7367,1]));static Sunuwar=new z(new Uint32Array([72640,72673,1,72688,72697,1]));static Syloti_Nagri=new z(new Uint32Array([43008,43052,1]));static Syriac=new z(new Uint32Array([1792,1805,1,1807,1866,1,1869,1871,1,2144,2154,1]));static Tagalog=new z(new Uint32Array([5888,5909,1,5919,5919,1]));static Tagbanwa=new z(new Uint32Array([5984,5996,1,5998,6e3,1,6002,6003,1]));static Tai_Le=new z(new Uint32Array([6480,6509,1,6512,6516,1]));static Tai_Tham=new z(new Uint32Array([6688,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1]));static Tai_Viet=new z(new Uint32Array([43648,43714,1,43739,43743,1]));static Takri=new z(new Uint32Array([71296,71353,1,71360,71369,1]));static Tamil=new z(new Uint32Array([2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,73664,73713,1,73727,73727,1]));static Tangsa=new z(new Uint32Array([92784,92862,1,92864,92873,1]));static Tangut=new z(new Uint32Array([94176,94208,32,94209,100343,1,100352,101119,1,101632,101640,1]));static Telugu=new z(new Uint32Array([3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3199,1]));static Thaana=new z(new Uint32Array([1920,1969,1]));static Thai=new z(new Uint32Array([3585,3642,1,3648,3675,1]));static Tibetan=new z(new Uint32Array([3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4052,1,4057,4058,1]));static Tifinagh=new z(new Uint32Array([11568,11623,1,11631,11632,1,11647,11647,1]));static Tirhuta=new z(new Uint32Array([70784,70855,1,70864,70873,1]));static Todhri=new z(new Uint32Array([67008,67059,1]));static Toto=new z(new Uint32Array([123536,123566,1]));static Tulu_Tigalari=new z(new Uint32Array([70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1]));static Ugaritic=new z(new Uint32Array([66432,66461,1,66463,66463,1]));static Vai=new z(new Uint32Array([42240,42539,1]));static Vithkuqi=new z(new Uint32Array([66928,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1]));static Wancho=new z(new Uint32Array([123584,123641,1,123647,123647,1]));static Warang_Citi=new z(new Uint32Array([71840,71922,1,71935,71935,1]));static Yezidi=new z(new Uint32Array([69248,69289,1,69291,69293,1,69296,69297,1]));static Yi=new z(new Uint32Array([40960,42124,1,42128,42182,1]));static Zanabazar_Square=new z(new Uint32Array([72192,72263,1]));static CATEGORIES=new Map([[`C`,e.C],[`Cc`,e.Cc],[`Cf`,e.Cf],[`Co`,e.Co],[`Cs`,e.Cs],[`L`,e.L],[`Ll`,e.Ll],[`Lm`,e.Lm],[`Lo`,e.Lo],[`Lt`,e.Lt],[`Lu`,e.Lu],[`M`,e.M],[`Mc`,e.Mc],[`Me`,e.Me],[`Mn`,e.Mn],[`N`,e.N],[`Nd`,e.Nd],[`Nl`,e.Nl],[`No`,e.No],[`P`,e.P],[`Pc`,e.Pc],[`Pd`,e.Pd],[`Pe`,e.Pe],[`Pf`,e.Pf],[`Pi`,e.Pi],[`Po`,e.Po],[`Ps`,e.Ps],[`S`,e.S],[`Sc`,e.Sc],[`Sk`,e.Sk],[`Sm`,e.Sm],[`So`,e.So],[`Z`,e.Z],[`Zl`,e.Zl],[`Zp`,e.Zp],[`Zs`,e.Zs]]);static SCRIPTS=new Map([[`Adlam`,e.Adlam],[`Ahom`,e.Ahom],[`Anatolian_Hieroglyphs`,e.Anatolian_Hieroglyphs],[`Arabic`,e.Arabic],[`Armenian`,e.Armenian],[`Avestan`,e.Avestan],[`Balinese`,e.Balinese],[`Bamum`,e.Bamum],[`Bassa_Vah`,e.Bassa_Vah],[`Batak`,e.Batak],[`Bengali`,e.Bengali],[`Bhaiksuki`,e.Bhaiksuki],[`Bopomofo`,e.Bopomofo],[`Brahmi`,e.Brahmi],[`Braille`,e.Braille],[`Buginese`,e.Buginese],[`Buhid`,e.Buhid],[`Canadian_Aboriginal`,e.Canadian_Aboriginal],[`Carian`,e.Carian],[`Caucasian_Albanian`,e.Caucasian_Albanian],[`Chakma`,e.Chakma],[`Cham`,e.Cham],[`Cherokee`,e.Cherokee],[`Chorasmian`,e.Chorasmian],[`Common`,e.Common],[`Coptic`,e.Coptic],[`Cuneiform`,e.Cuneiform],[`Cypriot`,e.Cypriot],[`Cypro_Minoan`,e.Cypro_Minoan],[`Cyrillic`,e.Cyrillic],[`Deseret`,e.Deseret],[`Devanagari`,e.Devanagari],[`Dives_Akuru`,e.Dives_Akuru],[`Dogra`,e.Dogra],[`Duployan`,e.Duployan],[`Egyptian_Hieroglyphs`,e.Egyptian_Hieroglyphs],[`Elbasan`,e.Elbasan],[`Elymaic`,e.Elymaic],[`Ethiopic`,e.Ethiopic],[`Garay`,e.Garay],[`Georgian`,e.Georgian],[`Glagolitic`,e.Glagolitic],[`Gothic`,e.Gothic],[`Grantha`,e.Grantha],[`Greek`,e.Greek],[`Gujarati`,e.Gujarati],[`Gunjala_Gondi`,e.Gunjala_Gondi],[`Gurmukhi`,e.Gurmukhi],[`Gurung_Khema`,e.Gurung_Khema],[`Han`,e.Han],[`Hangul`,e.Hangul],[`Hanifi_Rohingya`,e.Hanifi_Rohingya],[`Hanunoo`,e.Hanunoo],[`Hatran`,e.Hatran],[`Hebrew`,e.Hebrew],[`Hiragana`,e.Hiragana],[`Imperial_Aramaic`,e.Imperial_Aramaic],[`Inherited`,e.Inherited],[`Inscriptional_Pahlavi`,e.Inscriptional_Pahlavi],[`Inscriptional_Parthian`,e.Inscriptional_Parthian],[`Javanese`,e.Javanese],[`Kaithi`,e.Kaithi],[`Kannada`,e.Kannada],[`Katakana`,e.Katakana],[`Kawi`,e.Kawi],[`Kayah_Li`,e.Kayah_Li],[`Kharoshthi`,e.Kharoshthi],[`Khitan_Small_Script`,e.Khitan_Small_Script],[`Khmer`,e.Khmer],[`Khojki`,e.Khojki],[`Khudawadi`,e.Khudawadi],[`Kirat_Rai`,e.Kirat_Rai],[`Lao`,e.Lao],[`Latin`,e.Latin],[`Lepcha`,e.Lepcha],[`Limbu`,e.Limbu],[`Linear_A`,e.Linear_A],[`Linear_B`,e.Linear_B],[`Lisu`,e.Lisu],[`Lycian`,e.Lycian],[`Lydian`,e.Lydian],[`Mahajani`,e.Mahajani],[`Makasar`,e.Makasar],[`Malayalam`,e.Malayalam],[`Mandaic`,e.Mandaic],[`Manichaean`,e.Manichaean],[`Marchen`,e.Marchen],[`Masaram_Gondi`,e.Masaram_Gondi],[`Medefaidrin`,e.Medefaidrin],[`Meetei_Mayek`,e.Meetei_Mayek],[`Mende_Kikakui`,e.Mende_Kikakui],[`Meroitic_Cursive`,e.Meroitic_Cursive],[`Meroitic_Hieroglyphs`,e.Meroitic_Hieroglyphs],[`Miao`,e.Miao],[`Modi`,e.Modi],[`Mongolian`,e.Mongolian],[`Mro`,e.Mro],[`Multani`,e.Multani],[`Myanmar`,e.Myanmar],[`Nabataean`,e.Nabataean],[`Nag_Mundari`,e.Nag_Mundari],[`Nandinagari`,e.Nandinagari],[`New_Tai_Lue`,e.New_Tai_Lue],[`Newa`,e.Newa],[`Nko`,e.Nko],[`Nushu`,e.Nushu],[`Nyiakeng_Puachue_Hmong`,e.Nyiakeng_Puachue_Hmong],[`Ogham`,e.Ogham],[`Ol_Chiki`,e.Ol_Chiki],[`Ol_Onal`,e.Ol_Onal],[`Old_Hungarian`,e.Old_Hungarian],[`Old_Italic`,e.Old_Italic],[`Old_North_Arabian`,e.Old_North_Arabian],[`Old_Permic`,e.Old_Permic],[`Old_Persian`,e.Old_Persian],[`Old_Sogdian`,e.Old_Sogdian],[`Old_South_Arabian`,e.Old_South_Arabian],[`Old_Turkic`,e.Old_Turkic],[`Old_Uyghur`,e.Old_Uyghur],[`Oriya`,e.Oriya],[`Osage`,e.Osage],[`Osmanya`,e.Osmanya],[`Pahawh_Hmong`,e.Pahawh_Hmong],[`Palmyrene`,e.Palmyrene],[`Pau_Cin_Hau`,e.Pau_Cin_Hau],[`Phags_Pa`,e.Phags_Pa],[`Phoenician`,e.Phoenician],[`Psalter_Pahlavi`,e.Psalter_Pahlavi],[`Rejang`,e.Rejang],[`Runic`,e.Runic],[`Samaritan`,e.Samaritan],[`Saurashtra`,e.Saurashtra],[`Sharada`,e.Sharada],[`Shavian`,e.Shavian],[`Siddham`,e.Siddham],[`SignWriting`,e.SignWriting],[`Sinhala`,e.Sinhala],[`Sogdian`,e.Sogdian],[`Sora_Sompeng`,e.Sora_Sompeng],[`Soyombo`,e.Soyombo],[`Sundanese`,e.Sundanese],[`Sunuwar`,e.Sunuwar],[`Syloti_Nagri`,e.Syloti_Nagri],[`Syriac`,e.Syriac],[`Tagalog`,e.Tagalog],[`Tagbanwa`,e.Tagbanwa],[`Tai_Le`,e.Tai_Le],[`Tai_Tham`,e.Tai_Tham],[`Tai_Viet`,e.Tai_Viet],[`Takri`,e.Takri],[`Tamil`,e.Tamil],[`Tangsa`,e.Tangsa],[`Tangut`,e.Tangut],[`Telugu`,e.Telugu],[`Thaana`,e.Thaana],[`Thai`,e.Thai],[`Tibetan`,e.Tibetan],[`Tifinagh`,e.Tifinagh],[`Tirhuta`,e.Tirhuta],[`Todhri`,e.Todhri],[`Toto`,e.Toto],[`Tulu_Tigalari`,e.Tulu_Tigalari],[`Ugaritic`,e.Ugaritic],[`Vai`,e.Vai],[`Vithkuqi`,e.Vithkuqi],[`Wancho`,e.Wancho],[`Warang_Citi`,e.Warang_Citi],[`Yezidi`,e.Yezidi],[`Yi`,e.Yi],[`Zanabazar_Square`,e.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([[`L`,e.foldL],[`Ll`,e.foldLl],[`Lt`,e.foldLt],[`Lu`,e.foldLu],[`M`,e.foldM],[`Mn`,e.foldMn]]);static FOLD_SCRIPT=new Map([[`Common`,e.foldCommon],[`Greek`,e.foldGreek],[`Inherited`,e.foldInherited]]);static Print=new z(new Uint32Array([33,126,1,161,172,1,174,887,1,890,895,1,900,906,1,908,910,2,911,929,1,931,1327,1,1329,1366,1,1369,1418,1,1421,1423,1,1425,1479,1,1488,1514,1,1519,1524,1,1542,1563,1,1565,1756,1,1758,1805,1,1808,1866,1,1869,1969,1,1984,2042,1,2045,2093,1,2096,2110,1,2112,2139,1,2142,2144,2,2145,2154,1,2160,2190,1,2199,2273,1,2275,2435,1,2437,2444,1,2447,2448,1,2451,2472,1,2474,2480,1,2482,2486,4,2487,2489,1,2492,2500,1,2503,2504,1,2507,2510,1,2519,2524,5,2525,2527,2,2528,2531,1,2534,2558,1,2561,2563,1,2565,2570,1,2575,2576,1,2579,2600,1,2602,2608,1,2610,2611,1,2613,2614,1,2616,2617,1,2620,2622,2,2623,2626,1,2631,2632,1,2635,2637,1,2641,2649,8,2650,2652,1,2654,2662,8,2663,2678,1,2689,2691,1,2693,2701,1,2703,2705,1,2707,2728,1,2730,2736,1,2738,2739,1,2741,2745,1,2748,2757,1,2759,2761,1,2763,2765,1,2768,2784,16,2785,2787,1,2790,2801,1,2809,2815,1,2817,2819,1,2821,2828,1,2831,2832,1,2835,2856,1,2858,2864,1,2866,2867,1,2869,2873,1,2876,2884,1,2887,2888,1,2891,2893,1,2901,2903,1,2908,2909,1,2911,2915,1,2918,2935,1,2946,2947,1,2949,2954,1,2958,2960,1,2962,2965,1,2969,2970,1,2972,2974,2,2975,2979,4,2980,2984,4,2985,2986,1,2990,3001,1,3006,3010,1,3014,3016,1,3018,3021,1,3024,3031,7,3046,3066,1,3072,3084,1,3086,3088,1,3090,3112,1,3114,3129,1,3132,3140,1,3142,3144,1,3146,3149,1,3157,3158,1,3160,3162,1,3165,3168,3,3169,3171,1,3174,3183,1,3191,3212,1,3214,3216,1,3218,3240,1,3242,3251,1,3253,3257,1,3260,3268,1,3270,3272,1,3274,3277,1,3285,3286,1,3293,3294,1,3296,3299,1,3302,3311,1,3313,3315,1,3328,3340,1,3342,3344,1,3346,3396,1,3398,3400,1,3402,3407,1,3412,3427,1,3430,3455,1,3457,3459,1,3461,3478,1,3482,3505,1,3507,3515,1,3517,3520,3,3521,3526,1,3530,3535,5,3536,3540,1,3542,3544,2,3545,3551,1,3558,3567,1,3570,3572,1,3585,3642,1,3647,3675,1,3713,3714,1,3716,3718,2,3719,3722,1,3724,3747,1,3749,3751,2,3752,3773,1,3776,3780,1,3782,3784,2,3785,3790,1,3792,3801,1,3804,3807,1,3840,3911,1,3913,3948,1,3953,3991,1,3993,4028,1,4030,4044,1,4046,4058,1,4096,4293,1,4295,4301,6,4304,4680,1,4682,4685,1,4688,4694,1,4696,4698,2,4699,4701,1,4704,4744,1,4746,4749,1,4752,4784,1,4786,4789,1,4792,4798,1,4800,4802,2,4803,4805,1,4808,4822,1,4824,4880,1,4882,4885,1,4888,4954,1,4957,4988,1,4992,5017,1,5024,5109,1,5112,5117,1,5120,5759,1,5761,5788,1,5792,5880,1,5888,5909,1,5919,5942,1,5952,5971,1,5984,5996,1,5998,6e3,1,6002,6003,1,6016,6109,1,6112,6121,1,6128,6137,1,6144,6157,1,6159,6169,1,6176,6264,1,6272,6314,1,6320,6389,1,6400,6430,1,6432,6443,1,6448,6459,1,6464,6468,4,6469,6509,1,6512,6516,1,6528,6571,1,6576,6601,1,6608,6618,1,6622,6683,1,6686,6750,1,6752,6780,1,6783,6793,1,6800,6809,1,6816,6829,1,6832,6862,1,6912,6988,1,6990,7155,1,7164,7223,1,7227,7241,1,7245,7306,1,7312,7354,1,7357,7367,1,7376,7418,1,7424,7957,1,7960,7965,1,7968,8005,1,8008,8013,1,8016,8023,1,8025,8031,2,8032,8061,1,8064,8116,1,8118,8132,1,8134,8147,1,8150,8155,1,8157,8175,1,8178,8180,1,8182,8190,1,8208,8231,1,8240,8286,1,8304,8305,1,8308,8334,1,8336,8348,1,8352,8384,1,8400,8432,1,8448,8587,1,8592,9257,1,9280,9290,1,9312,11123,1,11126,11157,1,11159,11507,1,11513,11557,1,11559,11565,6,11568,11623,1,11631,11632,1,11647,11670,1,11680,11686,1,11688,11694,1,11696,11702,1,11704,11710,1,11712,11718,1,11720,11726,1,11728,11734,1,11736,11742,1,11744,11869,1,11904,11929,1,11931,12019,1,12032,12245,1,12272,12287,1,12289,12351,1,12353,12438,1,12441,12543,1,12549,12591,1,12593,12686,1,12688,12773,1,12783,12830,1,12832,42124,1,42128,42182,1,42192,42539,1,42560,42743,1,42752,42957,1,42960,42961,1,42963,42965,2,42966,42972,1,42994,43052,1,43056,43065,1,43072,43127,1,43136,43205,1,43214,43225,1,43232,43347,1,43359,43388,1,43392,43469,1,43471,43481,1,43486,43518,1,43520,43574,1,43584,43597,1,43600,43609,1,43612,43714,1,43739,43766,1,43777,43782,1,43785,43790,1,43793,43798,1,43808,43814,1,43816,43822,1,43824,43883,1,43888,44013,1,44016,44025,1,44032,55203,1,55216,55238,1,55243,55291,1,63744,64109,1,64112,64217,1,64256,64262,1,64275,64279,1,64285,64310,1,64312,64316,1,64318,64320,2,64321,64323,2,64324,64326,2,64327,64450,1,64467,64911,1,64914,64967,1,64975,65008,33,65009,65049,1,65056,65106,1,65108,65126,1,65128,65131,1,65136,65140,1,65142,65276,1,65281,65470,1,65474,65479,1,65482,65487,1,65490,65495,1,65498,65500,1,65504,65510,1,65512,65518,1,65532,65533,1,65536,65547,1,65549,65574,1,65576,65594,1,65596,65597,1,65599,65613,1,65616,65629,1,65664,65786,1,65792,65794,1,65799,65843,1,65847,65934,1,65936,65948,1,65952,66e3,48,66001,66045,1,66176,66204,1,66208,66256,1,66272,66299,1,66304,66339,1,66349,66378,1,66384,66426,1,66432,66461,1,66463,66499,1,66504,66517,1,66560,66717,1,66720,66729,1,66736,66771,1,66776,66811,1,66816,66855,1,66864,66915,1,66927,66938,1,66940,66954,1,66956,66962,1,66964,66965,1,66967,66977,1,66979,66993,1,66995,67001,1,67003,67004,1,67008,67059,1,67072,67382,1,67392,67413,1,67424,67431,1,67456,67461,1,67463,67504,1,67506,67514,1,67584,67589,1,67592,67594,2,67595,67637,1,67639,67640,1,67644,67647,3,67648,67669,1,67671,67742,1,67751,67759,1,67808,67826,1,67828,67829,1,67835,67867,1,67871,67897,1,67903,67968,65,67969,68023,1,68028,68047,1,68050,68099,1,68101,68102,1,68108,68115,1,68117,68119,1,68121,68149,1,68152,68154,1,68159,68168,1,68176,68184,1,68192,68255,1,68288,68326,1,68331,68342,1,68352,68405,1,68409,68437,1,68440,68466,1,68472,68497,1,68505,68508,1,68521,68527,1,68608,68680,1,68736,68786,1,68800,68850,1,68858,68903,1,68912,68921,1,68928,68965,1,68969,68997,1,69006,69007,1,69216,69246,1,69248,69289,1,69291,69293,1,69296,69297,1,69314,69316,1,69372,69415,1,69424,69465,1,69488,69513,1,69552,69579,1,69600,69622,1,69632,69709,1,69714,69749,1,69759,69820,1,69822,69826,1,69840,69864,1,69872,69881,1,69888,69940,1,69942,69959,1,69968,70006,1,70016,70111,1,70113,70132,1,70144,70161,1,70163,70209,1,70272,70278,1,70280,70282,2,70283,70285,1,70287,70301,1,70303,70313,1,70320,70378,1,70384,70393,1,70400,70403,1,70405,70412,1,70415,70416,1,70419,70440,1,70442,70448,1,70450,70451,1,70453,70457,1,70459,70468,1,70471,70472,1,70475,70477,1,70480,70487,7,70493,70499,1,70502,70508,1,70512,70516,1,70528,70537,1,70539,70542,3,70544,70581,1,70583,70592,1,70594,70597,3,70599,70602,1,70604,70613,1,70615,70616,1,70625,70626,1,70656,70747,1,70749,70753,1,70784,70855,1,70864,70873,1,71040,71093,1,71096,71133,1,71168,71236,1,71248,71257,1,71264,71276,1,71296,71353,1,71360,71369,1,71376,71395,1,71424,71450,1,71453,71467,1,71472,71494,1,71680,71739,1,71840,71922,1,71935,71942,1,71945,71948,3,71949,71955,1,71957,71958,1,71960,71989,1,71991,71992,1,71995,72006,1,72016,72025,1,72096,72103,1,72106,72151,1,72154,72164,1,72192,72263,1,72272,72354,1,72368,72440,1,72448,72457,1,72640,72673,1,72688,72697,1,72704,72712,1,72714,72758,1,72760,72773,1,72784,72812,1,72816,72847,1,72850,72871,1,72873,72886,1,72960,72966,1,72968,72969,1,72971,73014,1,73018,73020,2,73021,73023,2,73024,73031,1,73040,73049,1,73056,73061,1,73063,73064,1,73066,73102,1,73104,73105,1,73107,73112,1,73120,73129,1,73440,73464,1,73472,73488,1,73490,73530,1,73534,73562,1,73648,73664,16,73665,73713,1,73727,74649,1,74752,74862,1,74864,74868,1,74880,75075,1,77712,77810,1,77824,78895,1,78912,78933,1,78944,82938,1,82944,83526,1,90368,90425,1,92160,92728,1,92736,92766,1,92768,92777,1,92782,92862,1,92864,92873,1,92880,92909,1,92912,92917,1,92928,92997,1,93008,93017,1,93019,93025,1,93027,93047,1,93053,93071,1,93504,93561,1,93760,93850,1,93952,94026,1,94031,94087,1,94095,94111,1,94176,94180,1,94192,94193,1,94208,100343,1,100352,101589,1,101631,101640,1,110576,110579,1,110581,110587,1,110589,110590,1,110592,110882,1,110898,110928,30,110929,110930,1,110933,110948,15,110949,110951,1,110960,111355,1,113664,113770,1,113776,113788,1,113792,113800,1,113808,113817,1,113820,113823,1,117760,118009,1,118016,118451,1,118528,118573,1,118576,118598,1,118608,118723,1,118784,119029,1,119040,119078,1,119081,119154,1,119163,119274,1,119296,119365,1,119488,119507,1,119520,119539,1,119552,119638,1,119648,119672,1,119808,119892,1,119894,119964,1,119966,119967,1,119970,119973,3,119974,119977,3,119978,119980,1,119982,119993,1,119995,119997,2,119998,120003,1,120005,120069,1,120071,120074,1,120077,120084,1,120086,120092,1,120094,120121,1,120123,120126,1,120128,120132,1,120134,120138,4,120139,120144,1,120146,120485,1,120488,120779,1,120782,121483,1,121499,121503,1,121505,121519,1,122624,122654,1,122661,122666,1,122880,122886,1,122888,122904,1,122907,122913,1,122915,122916,1,122918,122922,1,122928,122989,1,123023,123136,113,123137,123180,1,123184,123197,1,123200,123209,1,123214,123215,1,123536,123566,1,123584,123641,1,123647,124112,465,124113,124153,1,124368,124410,1,124415,124896,481,124897,124902,1,124904,124907,1,124909,124910,1,124912,124926,1,124928,125124,1,125127,125142,1,125184,125259,1,125264,125273,1,125278,125279,1,126065,126132,1,126209,126269,1,126464,126467,1,126469,126495,1,126497,126498,1,126500,126503,3,126505,126514,1,126516,126519,1,126521,126523,2,126530,126535,5,126537,126541,2,126542,126543,1,126545,126546,1,126548,126551,3,126553,126561,2,126562,126564,2,126567,126570,1,126572,126578,1,126580,126583,1,126585,126588,1,126590,126592,2,126593,126601,1,126603,126619,1,126625,126627,1,126629,126633,1,126635,126651,1,126704,126705,1,126976,127019,1,127024,127123,1,127136,127150,1,127153,127167,1,127169,127183,1,127185,127221,1,127232,127405,1,127462,127490,1,127504,127547,1,127552,127560,1,127568,127569,1,127584,127589,1,127744,128727,1,128732,128748,1,128752,128764,1,128768,128886,1,128891,128985,1,128992,129003,1,129008,129024,16,129025,129035,1,129040,129095,1,129104,129113,1,129120,129159,1,129168,129197,1,129200,129211,1,129216,129217,1,129280,129619,1,129632,129645,1,129648,129660,1,129664,129673,1,129679,129734,1,129742,129756,1,129759,129769,1,129776,129784,1,129792,129938,1,129940,130041,1,131072,173791,1,173824,177977,1,177984,178205,1,178208,183969,1,183984,191456,1,191472,192093,1,194560,195101,1,196608,201546,1,201552,205743,1,917760,917999,1]))},B=class{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2),a=e.getLo(i),o=e.getHi(i);if(a<=t&&t<=o){let n=e.getStride(i);return(t-a)%n===0}t<a?r=i:n=i+1}return!1}static is(e,t){if(t<=this.MAX_LATIN1){for(let n=0;n<e.length;n++){if(t>e.getHi(n))continue;let r=e.getLo(n);if(t<r)return!1;let i=e.getStride(n);return(t-r)%i===0}return!1}return e.length>0&&t>=e.getLo(0)&&this.is32(e,t)}static isUpper(e){if(e<=this.MAX_LATIN1){let t=String.fromCodePoint(e);return t.toUpperCase()===t&&t.toLowerCase()!==t}return this.is(is.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?e>=32&&e<this.MAX_ASCII||e>=161&&e!==173:this.is(is.Print,e)}static simpleFold(e){if(is.CASE_ORBIT.has(e))return is.CASE_ORBIT.get(e);let t=R.toLowerCase(e);return t===e?R.toUpperCase(e):t}static equalsIgnoreCase(e,t){if(e<0||t<0||e===t)return!0;if(e<=this.MAX_ASCII&&t<=this.MAX_ASCII)return R.CODES.get(`A`)<=e&&e<=R.CODES.get(`Z`)&&(e|=32),R.CODES.get(`A`)<=t&&t<=R.CODES.get(`Z`)&&(t|=32),e===t;for(let n=this.simpleFold(e);n!==e;n=this.simpleFold(n))if(n===t)return!0;return!1}},as=class{static METACHARACTERS=`\\.+*?()|[]{}^$`;static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return R.CODES.get(`0`)<=e&&e<=R.CODES.get(`9`)||R.CODES.get(`a`)<=e&&e<=R.CODES.get(`z`)||R.CODES.get(`A`)<=e&&e<=R.CODES.get(`Z`)}static unhex(e){return R.CODES.get(`0`)<=e&&e<=R.CODES.get(`9`)?e-R.CODES.get(`0`):R.CODES.get(`a`)<=e&&e<=R.CODES.get(`f`)?e-R.CODES.get(`a`)+10:R.CODES.get(`A`)<=e&&e<=R.CODES.get(`F`)?e-R.CODES.get(`A`)+10:-1}static escapeRune(e){let t=``;if(B.isPrint(e))this.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(t+=`\\`),t+=String.fromCodePoint(e);else switch(e){case R.CODES.get(`"`):t+=`\\"`;break;case R.CODES.get(`\\`):t+=`\\\\`;break;case R.CODES.get(` `):t+=`\\t`;break;case R.CODES.get(`
222
+ `):t+=`\\n`;break;case R.CODES.get(`\r`):t+=`\\r`;break;case R.CODES.get(`\b`):t+=`\\b`;break;case R.CODES.get(`\f`):t+=`\\f`;break;default:{let n=e.toString(16);e<256?(t+=`\\x`,n.length===1&&(t+=`0`),t+=n):t+=`\\x{${n}}`;break}}return t}static stringToRunes(e){return String(e).split(``).map(e=>e.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return R.CODES.get(`a`)<=e&&e<=R.CODES.get(`z`)||R.CODES.get(`A`)<=e&&e<=R.CODES.get(`Z`)||R.CODES.get(`0`)<=e&&e<=R.CODES.get(`9`)||e===R.CODES.get(`_`)}static emptyOpContext(e,t){let n=0;return e<0&&(n|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===R.CODES.get(`
223
+ `)&&(n|=this.EMPTY_BEGIN_LINE),t<0&&(n|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===R.CODES.get(`
224
+ `)&&(n|=this.EMPTY_END_LINE),this.isWordRune(e)===this.isWordRune(t)?n|=this.EMPTY_NO_WORD_BOUNDARY:n|=this.EMPTY_WORD_BOUNDARY,n}static quoteMeta(e){return e.split(``).map(e=>this.METACHARACTERS.indexOf(e)>=0?`\\${e}`:e).join(``)}static charCount(e){return e>B.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder(`utf-8`).decode(new Uint8Array(e));{let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)}}},os=(e=[],t=0)=>{let n={};for(let r=0;r<e.length;r++){let i=e[r],a=t+r;n[i]=a,n[a]=i}return Object.freeze(n)},ss=class e{static Encoding=os([`UTF_16`,`UTF_8`]);getEncoding(){throw Error(`not implemented`)}isUTF8Encoding(){return this.getEncoding()===e.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===e.Encoding.UTF_16}},cs=class extends ss{constructor(e=null){super(),this.bytes=e}getEncoding(){return ss.Encoding.UTF_8}asCharSequence(){return as.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},ls=class extends ss{constructor(e=null){super(),this.charSequence=e}getEncoding(){return ss.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split(``).map(e=>e.codePointAt(0))}length(){return this.charSequence.length}},us=class{static utf16(e){return new ls(e)}static utf8(e){return Array.isArray(e)?new cs(e):new cs(as.stringToUtf8ByteArray(e))}},ds=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},fs=class extends ds{constructor(e,t=0,n=e.length){super(),this.bytes=e,this.start=t,this.end=n}step(e){if(e+=this.start,e>=this.end)return ds.EOF();let t=this.bytes[e++]&255;return t&128?(t&224)==192?(t&=31,e>=this.end?ds.EOF():(t=t<<6|this.bytes[e++]&63,t<<3|2)):(t&240)==224?(t&=15,e+1>=this.end?ds.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|3)):(t&=7,e+2>=this.end?ds.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|4)):t<<3|1}index(e,t){t+=this.start;let n=this.indexOf(this.bytes,e.prefixUTF8,t);return n<0?n:n-t}context(e){e+=this.start;let t=-1;if(e>this.start&&e<=this.end){let n=e-1;if(t=this.bytes[n--],t>=128){let r=e-4;for(r<this.start&&(r=this.start);n>=r&&(this.bytes[n]&192)==128;)n--;n<this.start&&(n=this.start),t=this.step(n)>>3}}let n=e<this.end?this.step(e)>>3:-1;return as.emptyOpContext(t,n)}indexOf(e,t,n=0){let r=t.length;if(r===0)return-1;let i=e.length;for(let a=n;a<=i-r;a++)for(let n=0;n<r&&e[a+n]===t[n];n++)if(n===r-1)return a;return-1}},ps=class extends ds{constructor(e,t=0,n=e.length){super(),this.charSequence=e,this.start=t,this.end=n}step(e){if(e+=this.start,e<this.end){let t=this.charSequence.codePointAt(e);return t<<3|as.charCount(t)}return ds.EOF()}index(e,t){t+=this.start;let n=this.charSequence.indexOf(e.prefix,t);return n<0?n:n-t}context(e){e+=this.start;let t=e>0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,n=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return as.emptyOpContext(t,n)}},ms=class{static fromUTF8(e,t=0,n=e.length){return new fs(e,t,n)}static fromUTF16(e,t=0,n=e.length){return new ps(e,t,n)}},hs=class extends Error{constructor(e){super(e),this.name=`RE2JSException`}},gs=class extends hs{constructor(e,t=null){let n=`error parsing regexp: ${e}`;t&&(n+=`: \`${t}\``),super(n),this.name=`RE2JSSyntaxException`,this.message=n,this.error=e,this.input=t}getDescription(){return this.error}getPattern(){return this.input}},_s=class extends hs{constructor(e){super(e),this.name=`RE2JSCompileException`}},vs=class extends hs{constructor(e){super(e),this.name=`RE2JSGroupException`}},ys=class extends hs{constructor(e){super(e),this.name=`RE2JSFlagsException`}},bs=class{static quoteReplacement(e){return e.indexOf(`\\`)<0&&e.indexOf(`$`)<0?e:e.split(``).map(e=>{let t=e.codePointAt(0);return t===R.CODES.get(`\\`)||t===R.CODES.get(`$`)?`\\${e}`:e}).join(``)}constructor(e,t){if(e===null)throw Error(`pattern is null`);this.patternInput=e;let n=this.patternInput.re2();this.patternGroupCount=n.numberOfCapturingGroups(),this.groups=[],this.namedGroups=n.namedGroups,this.numberOfInstructions=n.numberOfInstructions(),t instanceof ss?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(us.utf8(t)):this.resetMatcherInput(us.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw Error(`input is null`);return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}programSize(){return this.numberOfInstructions}group(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new vs(`group '${e}' not found`);e=t}let t=this.start(e),n=this.end(e);return t<0&&n<0?null:this.substring(t,n)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new vs(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new vs(`perhaps no match attempted`);if(e===0||this.hasGroups)return;let t=this.groups[1]+1;t>this.matcherInputLength&&(t=this.matcherInputLength);let n=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!n[0])throw new vs(`inconsistency in matching group data`);this.groups=n[1],this.hasGroups=!0}matches(){return this.genMatch(0,L.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,L.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new vs(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,L.UNANCHORED)}genMatch(e,t){let n=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return n[0]?(this.groups=n[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0):!1}substring(e,t){return this.matcherInput.isUTF8Encoding()?as.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let n=``,r=this.start(),i=this.end();return this.appendPos<r&&(n+=this.substring(this.appendPos,r)),this.appendPos=i,n+=t?this.appendReplacementInternalPerl(e):this.appendReplacementInternal(e),n}appendReplacementInternal(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++){if(e.codePointAt(i)===R.CODES.get(`\\`)){n<i&&(t+=e.substring(n,i)),i++,n=i;continue}if(e.codePointAt(i)===R.CODES.get(`$`)){let a=e.codePointAt(i+1);if(R.CODES.get(`0`)<=a&&a<=R.CODES.get(`9`)){let o=a-R.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<R.CODES.get(`0`)||a>R.CODES.get(`9`)||o*10+a-R.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-R.CODES.get(`0`);if(o>this.patternGroupCount)throw new vs(`n > number of groups: ${o}`);let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}if(a===R.CODES.get(`{`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==R.CODES.get(`}`)&&e.codePointAt(r)!==R.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==R.CODES.get(`}`))throw new vs(`named capture group is missing trailing '}'`);let a=e.substring(i+1,r);t+=this.group(a),n=r+1}}}return n<r&&(t+=e.substring(n,r)),t}appendReplacementInternalPerl(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++)if(e.codePointAt(i)===R.CODES.get(`$`)){let a=e.codePointAt(i+1);if(R.CODES.get(`$`)===a){n<i&&(t+=e.substring(n,i)),t+=`$`,i++,n=i+1;continue}if(R.CODES.get(`&`)===a){n<i&&(t+=e.substring(n,i));let r=this.group(0);t+=r===null?`$&`:r,i++,n=i+1;continue}if(R.CODES.get(`1`)<=a&&a<=R.CODES.get(`9`)){let o=a-R.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<R.CODES.get(`0`)||a>R.CODES.get(`9`)||o*10+a-R.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-R.CODES.get(`0`);if(o>this.patternGroupCount){t+=`$${o}`,n=i,i--;continue}let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}if(a===R.CODES.get(`<`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==R.CODES.get(`>`)&&e.codePointAt(r)!==R.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==R.CODES.get(`>`)){t+=e.substring(i-1,r+1),n=r+1;continue}let a=e.substring(i+1,r);Object.prototype.hasOwnProperty.call(this.namedGroups,a)?t+=this.group(a):t+=`$<${a}>`,n=r+1}}return n<r&&(t+=e.substring(n,r)),t}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,t=!1){return this.replace(e,!0,t)}replaceFirst(e,t=!1){return this.replace(e,!1,t)}replace(e,t=!0,n=!1){let r=``;for(this.reset();this.find()&&(r+=this.appendReplacement(e,n),t););return r+=this.appendTail(),r}},V=class e{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(t){return e.RUNE<=t&&t<=e.RUNE_ANY_NOT_NL}static escapeRunes(e){let t=`"`;for(let n of e)t+=as.escapeRune(n);return t+=`"`,t}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=[]}matchRune(e){if(this.runes.length===1){let t=this.runes[0];return(this.arg&L.FOLD_CASE)===0?e===t:B.equalsIgnoreCase(t,e)}for(let t=0;t<this.runes.length&&t<=8;t+=2){if(e<this.runes[t])return!1;if(e<=this.runes[t+1])return!0}let t=0,n=this.runes.length/2|0;for(;t<n;){let r=t+((n-t)/2|0);if(this.runes[2*r]<=e){if(e<=this.runes[2*r+1])return!0;t=r+1}else n=r}return!1}toString(){switch(this.op){case e.ALT:return`alt -> ${this.out}, ${this.arg}`;case e.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case e.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case e.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case e.MATCH:return`match`;case e.FAIL:return`fail`;case e.NOP:return`nop -> ${this.out}`;case e.RUNE:return this.runes===null?`rune <null>`:[`rune `,e.escapeRunes(this.runes),(this.arg&L.FOLD_CASE)===0?``:`/i`,` -> `,this.out].join(``);case e.RUNE1:return`rune1 ${e.escapeRunes(this.runes)} -> ${this.out}`;case e.RUNE_ANY:return`any -> ${this.out}`;case e.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw Error(`unhandled case in Inst.toString`)}}},xs=class{constructor(){this.inst=null,this.cap=[]}},Ss=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let t=this.sparse[e];return t<this.size&&this.densePcs[t]===e}isEmpty(){return this.size===0}add(e){let t=this.size++;return this.sparse[e]=t,this.denseThreads[t]=null,this.densePcs[t]=e,t}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e=`{`;for(let t=0;t<this.size;t++)t!==0&&(e+=`, `),e+=this.densePcs[t];return e+=`}`,e}},Cs=class e{static fromRE2(t){let n=new e;return n.prog=t.prog,n.re2=t,n.q0=new Ss(n.prog.numInst()),n.q1=new Ss(n.prog.numInst()),n.pool=[],n.poolSize=0,n.matched=!1,n.matchcap=Array(n.prog.numCap<2?2:n.prog.numCap).fill(0),n.ncap=0,n}static fromMachine(t){let n=new e;return n.re2=t.re2,n.prog=t.prog,n.q0=t.q0,n.q1=t.q1,n.pool=t.pool,n.poolSize=t.poolSize,n.matched=t.matched,n.matchcap=t.matchcap,n.ncap=t.ncap,n}init(e){this.ncap=e,e>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}}initNewCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}this.matchcap=Array(e).fill(0)}submatches(){return this.ncap===0?as.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let t;return this.poolSize>0?(this.poolSize--,t=this.pool[this.poolSize]):t=new xs,t.inst=e,t}freeQueue(e,t=0){let n=e.size-t,r=this.poolSize+n;this.pool.length<r&&(this.pool=this.pool.slice(0,Math.max(this.pool.length*2,r)));for(let n=t;n<e.size;n++){let t=e.denseThreads[n];t!==null&&(this.pool[this.poolSize]=t,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,this.pool.length*2)),this.pool[this.poolSize]=e,this.poolSize++}match(e,t,n){let r=this.re2.cond;if(r===as.EMPTY_ALL||(n===L.ANCHOR_START||n===L.ANCHOR_BOTH)&&t!==0)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,a=this.q1,o=e.step(t),s=o>>3,c=o&7,l=-1,u=0;o!==ds.EOF()&&(o=e.step(t+c),l=o>>3,u=o&7);let d;for(d=t===0?as.emptyOpContext(-1,s):e.context(t);;){if(i.isEmpty()){if((r&as.EMPTY_BEGIN_TEXT)!==0&&t!==0||this.matched)break;if(this.re2.prefix.length!==0&&l!==this.re2.prefixRune&&e.canCheckPrefix()){let n=e.index(this.re2,t);if(n<0)break;t+=n,o=e.step(t),s=o>>3,c=o&7,o=e.step(t+c),l=o>>3,u=o&7}}!this.matched&&(t===0||n===L.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=t),this.add(i,this.prog.start,t,this.matchcap,d,null));let f=t+c;if(d=e.context(f),this.step(i,a,t,f,s,d,n,t===e.endPos()),c===0||this.ncap===0&&this.matched)break;t+=c,s=l,c=u,s!==-1&&(o=e.step(t+c),l=o>>3,u=o&7);let p=i;i=a,a=p}return this.freeQueue(a),this.matched}step(e,t,n,r,i,a,o,s){let c=this.re2.longest;for(let l=0;l<e.size;l++){let u=e.denseThreads[l];if(u===null)continue;if(c&&this.matched&&this.ncap>0&&this.matchcap[0]<u.cap[0]){this.freeThread(u);continue}let d=u.inst,f=!1;switch(d.op){case V.MATCH:if(o===L.ANCHOR_BOTH&&!s)break;this.ncap>0&&(!c||!this.matched||this.matchcap[1]<n)&&(u.cap[1]=n,this.matchcap=u.cap.slice(0,this.ncap)),c||this.freeQueue(e,l+1),this.matched=!0;break;case V.RUNE:f=d.matchRune(i);break;case V.RUNE1:f=i===d.runes[0];break;case V.RUNE_ANY:f=!0;break;case V.RUNE_ANY_NOT_NL:f=i!==R.CODES.get(`
225
+ `);break;default:throw Error(`bad inst`)}f&&(u=this.add(t,d.out,r,u.cap,a,u)),u!==null&&(this.freeThread(u),e.denseThreads[l]=null)}e.clear()}add(e,t,n,r,i,a){if(t===0||e.contains(t))return a;let o=e.add(t),s=this.prog.inst[t];switch(s.op){case V.FAIL:break;case V.ALT:case V.ALT_MATCH:a=this.add(e,s.out,n,r,i,a),a=this.add(e,s.arg,n,r,i,a);break;case V.EMPTY_WIDTH:(s.arg&~i)===0&&(a=this.add(e,s.out,n,r,i,a));break;case V.NOP:a=this.add(e,s.out,n,r,i,a);break;case V.CAPTURE:if(s.arg<this.ncap){let t=r[s.arg];r[s.arg]=n,this.add(e,s.out,n,r,i,null),r[s.arg]=t}else a=this.add(e,s.out,n,r,i,a);break;case V.MATCH:case V.RUNE:case V.RUNE1:case V.RUNE_ANY:case V.RUNE_ANY_NOT_NL:a===null?a=this.alloc(s):a.inst=s,this.ncap>0&&a.cap!==r&&(a.cap=r.slice(0,this.ncap)),e.denseThreads[o]=a,a=null;break;default:throw Error(`unhandled`)}return a}},ws=e=>{let t=-2128831035;for(let n=0;n<e.length;n++)t^=e[n],t=Math.imul(t,16777619);return t},Ts=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Es=class{constructor(e,t){this.nfaStates=e,this.isMatch=t,this.nextAscii=Array(B.MAX_ASCII+1).fill(null),this.nextMap=new Map}},Ds=class{constructor(e){this.prog=e,this.stateCache=new Map,this.stateCount=0,this.startState=null,this.stateLimit=1e4}computeClosure(e){let t=new Set,n=[...e],r=!1;for(;n.length>0;){let e=n.pop();if(t.has(e))continue;t.add(e);let i=this.prog.getInst(e);switch(i.op){case V.MATCH:r=!0;break;case V.ALT:case V.ALT_MATCH:n.push(i.out),n.push(i.arg);break;case V.NOP:case V.CAPTURE:n.push(i.out);break;case V.EMPTY_WIDTH:return null}}return{pcs:Int32Array.from(t).sort(),isMatch:r}}getState(e){let t=this.computeClosure(e);if(!t)return null;let n=t.pcs,r=ws(n),i=this.stateCache.get(r);if(i)for(let e=0;e<i.length;e++){let t=i[e];if(Ts(t.nfaStates,n))return t}else i=[],this.stateCache.set(r,i);if(this.stateCount>=this.stateLimit)return this.stateCache.clear(),this.stateCount=0,this.startState=null,null;let a=new Es(n,t.isMatch);return i.push(a),this.stateCount++,a}step(e,t,n){if(n===L.UNANCHORED&&t<=B.MAX_ASCII){let n=e.nextAscii[t];if(n!==null)return n}else{let r=t+(n===L.UNANCHORED?0:B.MAX_RUNE+1);if(e.nextMap.has(r))return e.nextMap.get(r)}let r=[];for(let n=0;n<e.nfaStates.length;n++){let i=e.nfaStates[n],a=this.prog.getInst(i);V.isRuneOp(a.op)&&a.matchRune(t)&&r.push(a.out)}n===L.UNANCHORED&&r.push(this.prog.start);let i=this.getState(r);if(n===L.UNANCHORED&&t<=B.MAX_ASCII)e.nextAscii[t]=i;else{let r=t+(n===L.UNANCHORED?0:B.MAX_RUNE+1);e.nextMap.set(r,i)}return i}match(e,t,n){if((n===L.ANCHOR_START||n===L.ANCHOR_BOTH)&&t!==0)return!1;if(!this.startState&&(this.startState=this.getState([this.prog.start]),!this.startState))return null;let r=e.endPos(),i=this.startState;if(i.isMatch)if(n===L.ANCHOR_BOTH){if(t===r)return!0}else return!0;let a=t;for(;a<r;){let t=e.step(a),o=t>>3,s=t&7;if(s===0)break;if(i=this.step(i,o,n),i===null)return null;if(i.isMatch)if(n===L.ANCHOR_BOTH){if(a+s===r)return!0}else return!0;if(i.nfaStates.length===0&&n!==L.UNANCHORED)return!1;a+=s}return!1}},H=class e{static Op=os([`NO_MATCH`,`EMPTY_MATCH`,`LITERAL`,`CHAR_CLASS`,`ANY_CHAR_NOT_NL`,`ANY_CHAR`,`BEGIN_LINE`,`END_LINE`,`BEGIN_TEXT`,`END_TEXT`,`WORD_BOUNDARY`,`NO_WORD_BOUNDARY`,`CAPTURE`,`STAR`,`PLUS`,`QUEST`,`REPEAT`,`CONCAT`,`ALTERNATE`,`LEFT_PAREN`,`VERTICAL_BAR`]);static isPseudoOp(t){return t>=e.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===R.CODES.get(`-`)?`\\`:``}static fromRegexp(t){let n=new e(t.op);return n.flags=t.flags,n.subs=t.subs,n.runes=t.runes,n.cap=t.cap,n.min=t.min,n.max=t.max,n.name=t.name,n.namedGroups=t.namedGroups,n}constructor(t){this.op=t,this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=e.emptySubs(),this.runes=[],this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t=``;switch(this.op){case e.Op.NO_MATCH:t+=`[^\\x00-\\x{10FFFF}]`;break;case e.Op.EMPTY_MATCH:t+=`(?:)`;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:case e.Op.REPEAT:{let n=this.subs[0];switch(n.op>e.Op.CAPTURE||n.op===e.Op.LITERAL&&n.runes.length>1?t+=`(?:${n.appendTo()})`:t+=n.appendTo(),this.op){case e.Op.STAR:t+=`*`;break;case e.Op.PLUS:t+=`+`;break;case e.Op.QUEST:t+=`?`;break;case e.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=`,`,this.max>=0&&(t+=this.max)),t+=`}`}(this.flags&L.NON_GREEDY)!==0&&(t+=`?`);break}case e.Op.CONCAT:for(let n of this.subs)n.op===e.Op.ALTERNATE?t+=`(?:${n.appendTo()})`:t+=n.appendTo();break;case e.Op.ALTERNATE:{let e=``;for(let n of this.subs)t+=e,e=`|`,t+=n.appendTo();break}case e.Op.LITERAL:(this.flags&L.FOLD_CASE)!==0&&(t+=`(?i:`);for(let e of this.runes)t+=as.escapeRune(e);(this.flags&L.FOLD_CASE)!==0&&(t+=`)`);break;case e.Op.ANY_CHAR_NOT_NL:t+=`(?-s:.)`;break;case e.Op.ANY_CHAR:t+=`(?s:.)`;break;case e.Op.CAPTURE:this.name===null||this.name.length===0?t+=`(`:t+=`(?P<${this.name}>`,this.subs[0].op!==e.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=`)`;break;case e.Op.BEGIN_TEXT:t+=`\\A`;break;case e.Op.END_TEXT:(this.flags&L.WAS_DOLLAR)===0?t+=`\\z`:t+=`(?-m:$)`;break;case e.Op.BEGIN_LINE:t+=`^`;break;case e.Op.END_LINE:t+=`$`;break;case e.Op.WORD_BOUNDARY:t+=`\\b`;break;case e.Op.NO_WORD_BOUNDARY:t+=`\\B`;break;case e.Op.CHAR_CLASS:if(this.runes.length%2!=0){t+=`[invalid char class]`;break}if(t+=`[`,this.runes.length===0)t+=`^\\x00-\\x{10FFFF}`;else if(this.runes[0]===0&&this.runes[this.runes.length-1]===B.MAX_RUNE){t+=`^`;for(let n=1;n<this.runes.length-1;n+=2){let r=this.runes[n]+1,i=this.runes[n+1]-1;t+=e.quoteIfHyphen(r),t+=as.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=as.escapeRune(i))}}else for(let n=0;n<this.runes.length;n+=2){let r=this.runes[n],i=this.runes[n+1];t+=e.quoteIfHyphen(r),t+=as.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=as.escapeRune(i))}t+=`]`;break;default:t+=this.op}return t}maxCap(){let t=0;if(this.op===e.Op.CAPTURE&&(t=this.cap),this.subs!==null)for(let e of this.subs){let n=e.maxCap();t<n&&(t=n)}return t}equals(t){if(!(t!==null&&t instanceof e)||this.op!==t.op)return!1;switch(this.op){case e.Op.END_TEXT:if((this.flags&L.WAS_DOLLAR)!==(t.flags&L.WAS_DOLLAR))return!1;break;case e.Op.LITERAL:case e.Op.CHAR_CLASS:if(this.runes===null&&t.runes===null)break;if(this.runes===null||t.runes===null||this.runes.length!==t.runes.length)return!1;for(let e=0;e<this.runes.length;e++)if(this.runes[e]!==t.runes[e])return!1;break;case e.Op.ALTERNATE:case e.Op.CONCAT:if(this.subs.length!==t.subs.length)return!1;for(let e=0;e<this.subs.length;++e)if(!this.subs[e].equals(t.subs[e]))return!1;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:if((this.flags&L.NON_GREEDY)!==(t.flags&L.NON_GREEDY)||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.REPEAT:if((this.flags&L.NON_GREEDY)!==(t.flags&L.NON_GREEDY)||this.min!==t.min||this.max!==t.max||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.CAPTURE:if(this.cap!==t.cap||(this.name===null?t.name!==null:this.name!==t.name)||!this.subs[0].equals(t.subs[0]))return!1}return!0}},Os=class{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new V(e))}skipNop(e){let t=this.inst[e];for(;t.op===V.NOP||t.op===V.CAPTURE;)t=this.inst[e],e=t.out;return t}prefix(){let e=``,t=this.skipNop(this.start);if(!V.isRuneOp(t.op)||t.runes.length!==1)return[t.op===V.MATCH,e];for(;V.isRuneOp(t.op)&&t.runes.length===1&&(t.arg&L.FOLD_CASE)===0;)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===V.MATCH,e]}startCond(){let e=0,t=this.start;e:for(;;){let n=this.inst[t];switch(n.op){case V.EMPTY_WIDTH:e|=n.arg;break;case V.FAIL:return-1;case V.CAPTURE:case V.NOP:break;default:break e}t=n.out}return e}next(e){let t=this.inst[e>>1];return e&1?t.arg:t.out}patch(e,t){for(;e!==0;){let n=this.inst[e>>1];e&1?(e=n.arg,n.arg=t):(e=n.out,n.out=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let n=e;for(;;){let e=this.next(n);if(e===0)break;n=e}let r=this.inst[n>>1];return n&1?r.arg=t:r.out=t,e}toString(){let e=``;for(let t=0;t<this.inst.length;t++){let n=e.length;e+=t,t===this.start&&(e+=`*`),e+=` `.substring(e.length-n),e+=this.inst[t],e+=`
226
+ `}return e}},ks=class{constructor(e=0,t=0,n=!1){this.i=e,this.out=t,this.nullable=n}},As=class e{static ANY_RUNE_NOT_NL(){return[0,R.CODES.get(`
227
+ `)-1,R.CODES.get(`
228
+ `)+1,B.MAX_RUNE]}static ANY_RUNE(){return[0,B.MAX_RUNE]}static compileRegexp(t){let n=new e,r=n.compile(t);return n.prog.patch(r.out,n.newInst(V.MATCH).i),n.prog.start=r.i,n.prog}constructor(){this.prog=new Os,this.newInst(V.FAIL)}newInst(e){return this.prog.addInst(e),new ks(this.prog.numInst()-1,0,!0)}nop(){let e=this.newInst(V.NOP);return e.out=e.i<<1,e}fail(){return new ks}cap(e){let t=this.newInst(V.CAPTURE);return t.out=t.i<<1,this.prog.getInst(t.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),t}cat(e,t){return e.i===0||t.i===0?this.fail():(this.prog.patch(e.out,t.i),new ks(e.i,t.out,e.nullable&&t.nullable))}alt(e,t){if(e.i===0)return t;if(t.i===0)return e;let n=this.newInst(V.ALT),r=this.prog.getInst(n.i);return r.out=e.i,r.arg=t.i,n.out=this.prog.append(e.out,t.out),n.nullable=e.nullable||t.nullable,n}loop(e,t){let n=this.newInst(V.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),this.prog.patch(e.out,n.i),n}quest(e,t){let n=this.newInst(V.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),n.out=this.prog.append(n.out,e.out),n}star(e,t){return e.nullable?this.quest(this.plus(e,t),t):this.loop(e,t)}plus(e,t){return new ks(e.i,this.loop(e,t).out,e.nullable)}empty(e){let t=this.newInst(V.EMPTY_WIDTH);return this.prog.getInst(t.i).arg=e,t.out=t.i<<1,t}rune(e,t){let n=this.newInst(V.RUNE);n.nullable=!1;let r=this.prog.getInst(n.i);return r.runes=e,t&=L.FOLD_CASE,(e.length!==1||B.simpleFold(e[0])===e[0])&&(t&=-2),r.arg=t,n.out=n.i<<1,(t&L.FOLD_CASE)===0&&e.length===1||e.length===2&&e[0]===e[1]?r.op=V.RUNE1:e.length===2&&e[0]===0&&e[1]===B.MAX_RUNE?r.op=V.RUNE_ANY:e.length===4&&e[0]===0&&e[1]===R.CODES.get(`
229
+ `)-1&&e[2]===R.CODES.get(`
230
+ `)+1&&e[3]===B.MAX_RUNE&&(r.op=V.RUNE_ANY_NOT_NL),n}compile(t){switch(t.op){case H.Op.NO_MATCH:return this.fail();case H.Op.EMPTY_MATCH:return this.nop();case H.Op.LITERAL:if(t.runes.length===0)return this.nop();{let e=null;for(let n of t.runes){let r=this.rune([n],t.flags);e=e===null?r:this.cat(e,r)}return e}case H.Op.CHAR_CLASS:return this.rune(t.runes,t.flags);case H.Op.ANY_CHAR_NOT_NL:return this.rune(e.ANY_RUNE_NOT_NL(),0);case H.Op.ANY_CHAR:return this.rune(e.ANY_RUNE(),0);case H.Op.BEGIN_LINE:return this.empty(as.EMPTY_BEGIN_LINE);case H.Op.END_LINE:return this.empty(as.EMPTY_END_LINE);case H.Op.BEGIN_TEXT:return this.empty(as.EMPTY_BEGIN_TEXT);case H.Op.END_TEXT:return this.empty(as.EMPTY_END_TEXT);case H.Op.WORD_BOUNDARY:return this.empty(as.EMPTY_WORD_BOUNDARY);case H.Op.NO_WORD_BOUNDARY:return this.empty(as.EMPTY_NO_WORD_BOUNDARY);case H.Op.CAPTURE:{let e=this.cap(t.cap<<1),n=this.compile(t.subs[0]),r=this.cap(t.cap<<1|1);return this.cat(this.cat(e,n),r)}case H.Op.STAR:return this.star(this.compile(t.subs[0]),(t.flags&L.NON_GREEDY)!==0);case H.Op.PLUS:return this.plus(this.compile(t.subs[0]),(t.flags&L.NON_GREEDY)!==0);case H.Op.QUEST:return this.quest(this.compile(t.subs[0]),(t.flags&L.NON_GREEDY)!==0);case H.Op.CONCAT:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.cat(e,t)}return e}case H.Op.ALTERNATE:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.alt(e,t)}return e}default:throw new _s(`regexp: unhandled case in compile`)}}},js=class e{static simplify(t){if(t===null)return null;switch(t.op){case H.Op.CAPTURE:case H.Op.CONCAT:case H.Op.ALTERNATE:{let n=t;for(let r=0;r<t.subs.length;r++){let i=t.subs[r],a=e.simplify(i);n===t&&a!==i&&(n=H.fromRegexp(t),n.runes=[],n.subs=t.subs.slice(0,t.subs.length)),n!==t&&(n.subs[r]=a)}return n}case H.Op.STAR:case H.Op.PLUS:case H.Op.QUEST:{let n=e.simplify(t.subs[0]);return e.simplify1(t.op,t.flags,n,t)}case H.Op.REPEAT:{if(t.min===0&&t.max===0)return new H(H.Op.EMPTY_MATCH);let n=e.simplify(t.subs[0]);if(t.max===-1){if(t.min===0)return e.simplify1(H.Op.STAR,t.flags,n,null);if(t.min===1)return e.simplify1(H.Op.PLUS,t.flags,n,null);let r=new H(H.Op.CONCAT),i=[];for(let e=0;e<t.min-1;e++)i.push(n);return i.push(e.simplify1(H.Op.PLUS,t.flags,n,null)),r.subs=i.slice(0),r}if(t.min===1&&t.max===1)return n;let r=null;if(t.min>0){r=[];for(let e=0;e<t.min;e++)r.push(n)}if(t.max>t.min){let i=e.simplify1(H.Op.QUEST,t.flags,n,null);for(let r=t.min+1;r<t.max;r++){let r=new H(H.Op.CONCAT);r.subs=[n,i],i=e.simplify1(H.Op.QUEST,t.flags,r,null)}if(r===null)return i;r.push(i)}if(r!==null){let e=new H(H.Op.CONCAT);return e.subs=r.slice(0),e}return new H(H.Op.NO_MATCH)}}return t}static simplify1(e,t,n,r){return n.op===H.Op.EMPTY_MATCH||e===n.op&&(t&L.NON_GREEDY)===(n.flags&L.NON_GREEDY)?n:(r!==null&&r.op===e&&(r.flags&L.NON_GREEDY)===(t&L.NON_GREEDY)&&n===r.subs[0]||(r=new H(e),r.flags=t,r.subs=[n]),r)}},Ms=class{constructor(e,t){this.sign=e,this.cls=t}},Ns=[48,57],Ps=[9,10,12,13,32,32],Fs=[48,57,65,90,95,95,97,122],Is=new Map([[`\\d`,new Ms(1,Ns)],[`\\D`,new Ms(-1,Ns)],[`\\s`,new Ms(1,Ps)],[`\\S`,new Ms(-1,Ps)],[`\\w`,new Ms(1,Fs)],[`\\W`,new Ms(-1,Fs)]]),Ls=[48,57,65,90,97,122],Rs=[65,90,97,122],zs=[0,127],Bs=[9,9,32,32],Vs=[0,31,127,127],Hs=[48,57],Us=[33,126],Ws=[97,122],Gs=[32,126],Ks=[33,47,58,64,91,96,123,126],qs=[9,13,32,32],Js=[65,90],Ys=[48,57,65,90,95,95,97,122],Xs=[48,57,65,70,97,102],Zs=new Map([[`[:alnum:]`,new Ms(1,Ls)],[`[:^alnum:]`,new Ms(-1,Ls)],[`[:alpha:]`,new Ms(1,Rs)],[`[:^alpha:]`,new Ms(-1,Rs)],[`[:ascii:]`,new Ms(1,zs)],[`[:^ascii:]`,new Ms(-1,zs)],[`[:blank:]`,new Ms(1,Bs)],[`[:^blank:]`,new Ms(-1,Bs)],[`[:cntrl:]`,new Ms(1,Vs)],[`[:^cntrl:]`,new Ms(-1,Vs)],[`[:digit:]`,new Ms(1,Hs)],[`[:^digit:]`,new Ms(-1,Hs)],[`[:graph:]`,new Ms(1,Us)],[`[:^graph:]`,new Ms(-1,Us)],[`[:lower:]`,new Ms(1,Ws)],[`[:^lower:]`,new Ms(-1,Ws)],[`[:print:]`,new Ms(1,Gs)],[`[:^print:]`,new Ms(-1,Gs)],[`[:punct:]`,new Ms(1,Ks)],[`[:^punct:]`,new Ms(-1,Ks)],[`[:space:]`,new Ms(1,qs)],[`[:^space:]`,new Ms(-1,qs)],[`[:upper:]`,new Ms(1,Js)],[`[:^upper:]`,new Ms(-1,Js)],[`[:word:]`,new Ms(1,Ys)],[`[:^word:]`,new Ms(-1,Ys)],[`[:xdigit:]`,new Ms(1,Xs)],[`[:^xdigit:]`,new Ms(-1,Xs)]]),Qs=class e{static charClassToString(e,t){let n=`[`;for(let r=0;r<t;r+=2){r>0&&(n+=` `);let t=e[r],i=e[r+1];n+=t===i?`0x${t.toString(16)}`:`0x${t.toString(16)}-0x${i.toString(16)}`}return n+=`]`,n}static cmp(e,t,n,r){let i=e[t]-n;return i===0?r-e[t+1]:i}static qsortIntPair(t,n,r){let i=((n+r)/2|0)&-2,a=t[i],o=t[i+1],s=n,c=r;for(;s<=c;){for(;s<r&&e.cmp(t,s,a,o)<0;)s+=2;for(;c>n&&e.cmp(t,c,a,o)>0;)c-=2;if(s<=c){if(s!==c){let e=t[s];t[s]=t[c],t[c]=e,e=t[s+1],t[s+1]=t[c+1],t[c+1]=e}s+=2,c-=2}}n<c&&e.qsortIntPair(t,n,c),s<r&&e.qsortIntPair(t,s,r)}constructor(e=as.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;e.qsortIntPair(this.r,0,this.len-2);let t=2;for(let e=2;e<this.len;e+=2){let n=this.r[e],r=this.r[e+1];if(n<=this.r[t-1]+1){r>this.r[t-1]&&(this.r[t-1]=r);continue}this.r[t]=n,this.r[t+1]=r,t+=2}return this.len=t,this}appendLiteral(e,t){return(t&L.FOLD_CASE)===0?this.appendRange(e,e):this.appendFoldedRange(e,e)}appendRange(e,t){if(this.len>0){for(let n=2;n<=4;n+=2)if(this.len>=n){let r=this.r[this.len-n],i=this.r[this.len-n+1];if(e<=i+1&&r<=t+1)return e<r&&(this.r[this.len-n]=e),t>i&&(this.r[this.len-n+1]=t),this}}return this.r[this.len++]=e,this.r[this.len++]=t,this}appendFoldedRange(e,t){if(e<=B.MIN_FOLD&&t>=B.MAX_FOLD||t<B.MIN_FOLD||e>B.MAX_FOLD)return this.appendRange(e,t);e<B.MIN_FOLD&&(this.appendRange(e,B.MIN_FOLD-1),e=B.MIN_FOLD),t>B.MAX_FOLD&&(this.appendRange(B.MAX_FOLD+1,t),t=B.MAX_FOLD);for(let n=e;n<=t;n++){this.appendRange(n,n);for(let e=B.simpleFold(n);e!==n;e=B.simpleFold(e))this.appendRange(e,e)}return this}appendClass(e){for(let t=0;t<e.length;t+=2)this.appendRange(e[t],e[t+1]);return this}appendFoldedClass(e){for(let t=0;t<e.length;t+=2)this.appendFoldedRange(e[t],e[t+1]);return this}appendNegatedClass(e){let t=0;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t<=r-1&&this.appendRange(t,r-1),t=i+1}return t<=B.MAX_RUNE&&this.appendRange(t,B.MAX_RUNE),this}appendTable(e){for(let t=0;t<e.length;++t){let n=e.getLo(t),r=e.getHi(t),i=e.getStride(t);if(i===1){this.appendRange(n,r);continue}for(let e=n;e<=r;e+=i)this.appendRange(e,e)}return this}appendNegatedTable(e){let t=0;for(let n=0;n<e.length;++n){let r=e.getLo(n),i=e.getHi(n),a=e.getStride(n);if(a===1){t<=r-1&&this.appendRange(t,r-1),t=i+1;continue}for(let e=r;e<=i;e+=a)t<=e-1&&this.appendRange(t,e-1),t=e+1}return t<=B.MAX_RUNE&&this.appendRange(t,B.MAX_RUNE),this}appendTableWithSign(e,t){return t<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,t=0;for(let n=0;n<this.len;n+=2){let r=this.r[n],i=this.r[n+1];e<=r-1&&(this.r[t]=e,this.r[t+1]=r-1,t+=2),e=i+1}return this.len=t,e<=B.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=B.MAX_RUNE),this}appendClassWithSign(e,t){return t<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(t,n){let r=t.cls;return n&&(r=new e().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,t.sign)}toString(){return e.charClassToString(this.r,this.len)}},$s=class e{static of(t,n){return new e(t,n)}constructor(e,t){this.first=e,this.second=t}},ec=class{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){let e=this.str.codePointAt(this.position);return this.position+=as.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}},tc=class e{static ERR_INTERNAL_ERROR=`regexp/syntax: internal error`;static ERR_INVALID_CHAR_RANGE=`invalid character class range`;static ERR_INVALID_ESCAPE=`invalid escape sequence`;static ERR_INVALID_NAMED_CAPTURE=`invalid named capture`;static ERR_INVALID_PERL_OP=`invalid or unsupported Perl syntax`;static ERR_INVALID_REPEAT_OP=`invalid nested repetition operator`;static ERR_INVALID_REPEAT_SIZE=`invalid repeat count`;static ERR_MISSING_BRACKET=`missing closing ]`;static ERR_MISSING_PAREN=`missing closing )`;static ERR_MISSING_REPEAT_ARGUMENT=`missing argument to repetition operator`;static ERR_TRAILING_BACKSLASH=`trailing backslash at end of expression`;static ERR_DUPLICATE_NAMED_CAPTURE=`duplicate capture group name`;static ERR_UNEXPECTED_PAREN=`unexpected )`;static ERR_NESTING_DEPTH=`expression nests too deeply`;static ERR_LARGE=`expression too large`;static MAX_HEIGHT=1e3;static MAX_SIZE=3355443;static MAX_RUNES=33554432;static ANY_TABLE=new z(new Uint32Array([0,B.MAX_RUNE,1]));static unicodeTable(t){return t===`Any`?$s.of(e.ANY_TABLE,e.ANY_TABLE):is.CATEGORIES.has(t)?$s.of(is.CATEGORIES.get(t),is.FOLD_CATEGORIES.get(t)):is.SCRIPTS.has(t)?$s.of(is.SCRIPTS.get(t),is.FOLD_SCRIPT.get(t)):null}static minFoldRune(e){if(e<B.MIN_FOLD||e>B.MAX_FOLD)return e;let t=e,n=e;for(e=B.simpleFold(e);e!==n;e=B.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){if(e.op===H.Op.EMPTY_MATCH)return null;if(e.op===H.Op.CONCAT&&e.subs.length>0){let t=e.subs[0];return t.op===H.Op.EMPTY_MATCH?null:t}return e}static literalRegexp(e,t){let n=new H(H.Op.LITERAL);return n.flags=t,n.runes=as.stringToRunes(e),n}static parse(t,n){return new e(t,n).parseInternal()}static parseRepeat(t){let n=t.pos();if(!t.more()||!t.lookingAt(`{`))return-1;t.skip(1);let r=e.parseInt(t);if(r===-1||!t.more())return-1;let i;if(!t.lookingAt(`,`))i=r;else{if(t.skip(1),!t.more())return-1;if(t.lookingAt(`}`))i=-1;else if((i=e.parseInt(t))===-1)return-1}if(!t.more()||!t.lookingAt(`}`))return-1;if(t.skip(1),r<0||r>1e3||i===-2||i>1e3||i>=0&&r>i)throw new gs(e.ERR_INVALID_REPEAT_SIZE,t.from(n));return r<<16|i&B.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n!==R.CODES.get(`_`)&&!as.isalnum(n))return!1}return!0}static parseInt(e){let t=e.pos();for(;e.more()&&e.peek()>=R.CODES.get(`0`)&&e.peek()<=R.CODES.get(`9`);)e.skip(1);let n=e.from(t);return n.length===0||n.length>1&&n.codePointAt(0)===R.CODES.get(`0`)?-1:n.length>8?-2:parseFloat(n,10)}static isCharClass(e){return e.op===H.Op.LITERAL&&e.runes.length===1||e.op===H.Op.CHAR_CLASS||e.op===H.Op.ANY_CHAR_NOT_NL||e.op===H.Op.ANY_CHAR}static matchRune(e,t){switch(e.op){case H.Op.LITERAL:return e.runes.length===1&&e.runes[0]===t;case H.Op.CHAR_CLASS:for(let n=0;n<e.runes.length;n+=2)if(e.runes[n]<=t&&t<=e.runes[n+1])return!0;return!1;case H.Op.ANY_CHAR_NOT_NL:return t!==R.CODES.get(`
231
+ `);case H.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(t,n){switch(t.op){case H.Op.ANY_CHAR:break;case H.Op.ANY_CHAR_NOT_NL:e.matchRune(n,R.CODES.get(`
232
+ `))&&(t.op=H.Op.ANY_CHAR);break;case H.Op.CHAR_CLASS:t.runes=n.op===H.Op.LITERAL?new Qs(t.runes).appendLiteral(n.runes[0],n.flags).toArray():new Qs(t.runes).appendClass(n.runes).toArray();break;case H.Op.LITERAL:if(n.runes[0]===t.runes[0]&&n.flags===t.flags)break;t.op=H.Op.CHAR_CLASS,t.runes=new Qs().appendLiteral(t.runes[0],t.flags).appendLiteral(n.runes[0],n.flags).toArray()}}static parseEscape(t){let n=t.pos();if(t.skip(1),!t.more())throw new gs(e.ERR_TRAILING_BACKSLASH);let r=t.pop();e:switch(r){case R.CODES.get(`1`):case R.CODES.get(`2`):case R.CODES.get(`3`):case R.CODES.get(`4`):case R.CODES.get(`5`):case R.CODES.get(`6`):case R.CODES.get(`7`):if(!t.more()||t.peek()<R.CODES.get(`0`)||t.peek()>R.CODES.get(`7`))break;case R.CODES.get(`0`):{let e=r-R.CODES.get(`0`);for(let n=1;n<3&&!(!t.more()||t.peek()<R.CODES.get(`0`)||t.peek()>R.CODES.get(`7`));n++)e=e*8+t.peek()-R.CODES.get(`0`),t.skip(1);return e}case R.CODES.get(`x`):{if(!t.more())break;if(r=t.pop(),r===R.CODES.get(`{`)){let e=0,n=0;for(;;){if(!t.more())break e;if(r=t.pop(),r===R.CODES.get(`}`))break;let i=as.unhex(r);if(i<0||(n=n*16+i,n>B.MAX_RUNE))break e;e++}if(e===0)break e;return n}let e=as.unhex(r);if(!t.more())break;r=t.pop();let n=as.unhex(r);if(e<0||n<0)break;return e*16+n}case R.CODES.get(`a`):return R.CODES.get(`\x07`);case R.CODES.get(`f`):return R.CODES.get(`\f`);case R.CODES.get(`n`):return R.CODES.get(`
233
+ `);case R.CODES.get(`r`):return R.CODES.get(`\r`);case R.CODES.get(`t`):return R.CODES.get(` `);case R.CODES.get(`v`):return R.CODES.get(`\v`);default:if(r<=B.MAX_ASCII&&!as.isalnum(r))return r}throw new gs(e.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new gs(e.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt(`\\`)?e.parseEscape(t):t.pop()}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):(t=new H(e),this.numRegexp+=1),t}reuse(e){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,e)&&delete this.height[e],e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}checkLimits(t){if(this.numRunes>e.MAX_RUNES)throw new gs(e.ERR_LARGE);this.checkSize(t),this.checkHeight(t)}checkSize(t){if(this.size===null){if(this.repeats===0&&(this.repeats=1),t.op===H.Op.REPEAT){let n=t.max;n===-1&&(n=t.min),n<=0&&(n=1),n>e.MAX_SIZE/this.repeats?this.repeats=e.MAX_SIZE:this.repeats*=n}if(this.numRegexp<e.MAX_SIZE/this.repeats)return;this.size={};for(let e of this.stack)this.checkSize(e)}if(this.calcSize(t,!0)>e.MAX_SIZE)throw new gs(e.ERR_LARGE)}calcSize(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.size,e))return this.size[e];let n=0;switch(e.op){case H.Op.LITERAL:n=e.runes.length;break;case H.Op.CAPTURE:case H.Op.STAR:n=2+this.calcSize(e.subs[0]);break;case H.Op.PLUS:case H.Op.QUEST:n=1+this.calcSize(e.subs[0]);break;case H.Op.CONCAT:for(let t of e.subs)n+=this.calcSize(t);break;case H.Op.ALTERNATE:for(let t of e.subs)n+=this.calcSize(t);e.subs.length>1&&(n=n+e.subs.length-1);break;case H.Op.REPEAT:{let t=this.calcSize(e.subs[0]);if(e.max===-1){n=e.min===0?2+t:1+e.min*t;break}n=e.max*t+(e.max-e.min);break}}return n=Math.max(1,n),this.size[e]=n,n}checkHeight(t){if(!(this.numRegexp<e.MAX_HEIGHT)){if(this.height===null){this.height={};for(let e of this.stack)this.checkHeight(e)}if(this.calcHeight(t,!0)>e.MAX_HEIGHT)throw new gs(e.ERR_NESTING_DEPTH)}}calcHeight(e,t=!1){if(!t&&Object.prototype.hasOwnProperty.call(this.height,e))return this.height[e];let n=1;for(let t of e.subs){let e=this.calcHeight(t);n<1+e&&(n=1+e)}return this.height[e]=n,n}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,t=e;for(;t>0&&!H.isPseudoOp(this.stack[t-1].op);)t--;let n=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),n}push(e){if(this.numRunes+=e.runes.length,e.op===H.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&-2))return null;e.op=H.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&-2}else if(e.op===H.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&B.simpleFold(e.runes[0])===e.runes[2]&&B.simpleFold(e.runes[2])===e.runes[0]||e.op===H.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&B.simpleFold(e.runes[0])===e.runes[1]&&B.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|L.FOLD_CASE))return null;e.op=H.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|L.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),this.checkLimits(e),e}maybeConcat(t,n){let r=this.stack.length;if(r<2)return!1;let i=this.stack[r-1],a=this.stack[r-2];return i.op!==H.Op.LITERAL||a.op!==H.Op.LITERAL||(i.flags&L.FOLD_CASE)!==(a.flags&L.FOLD_CASE)?!1:(a.runes=e.concatRunes(a.runes,i.runes),t>=0?(i.runes=[t],i.flags=n,!0):(this.pop(),this.reuse(i),!1))}newLiteral(t,n){let r=this.newRegexp(H.Op.LITERAL);return r.flags=n,(n&L.FOLD_CASE)!==0&&(t=e.minFoldRune(t)),r.runes=[t],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(t,n,r,i,a,o){let s=this.flags;if((s&L.PERL_X)!==0&&(a.more()&&a.lookingAt(`?`)&&(a.skip(1),s^=L.NON_GREEDY),o!==-1))throw new gs(e.ERR_INVALID_REPEAT_OP,a.from(o));let c=this.stack.length;if(c===0)throw new gs(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let l=this.stack[c-1];if(H.isPseudoOp(l.op))throw new gs(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let u=this.newRegexp(t);if(u.min=n,u.max=r,u.flags=s,u.subs=[l],this.stack[c-1]=u,this.checkLimits(u),t===H.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new gs(e.ERR_INVALID_REPEAT_SIZE,a.from(i))}repeatIsValid(e,t){if(e.op===H.Op.REPEAT){let n=e.max;if(n===0)return!0;if(n<0&&(n=e.min),n>t)return!1;n>0&&(t=Math.trunc(t/n))}for(let n of e.subs)if(!this.repeatIsValid(n,t))return!1;return!0}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(H.Op.EMPTY_MATCH)):this.push(this.collapse(e,H.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(H.Op.NO_MATCH)):this.push(this.collapse(e,H.Op.ALTERNATE))}cleanAlt(e){e.op===H.Op.CHAR_CLASS&&(e.runes=new Qs(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===B.MAX_RUNE?(e.runes=[],e.op=H.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===R.CODES.get(`
234
+ `)-1&&e.runes[2]===R.CODES.get(`
235
+ `)+1&&e.runes[3]===B.MAX_RUNE&&(e.runes=[],e.op=H.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let n=0;for(let r of e)n+=r.op===t?r.subs.length:1;let r=Array(n).fill(null),i=0;for(let n of e)n.op===t?(r.splice(i,n.subs.length,...n.subs),i+=n.subs.length,this.reuse(n)):r[i++]=n;let a=this.newRegexp(t);if(a.subs=r,t===H.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let e=a;a=a.subs[0],this.reuse(e)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,i=0,a=null,o=0,s=0,c=0;for(let e=0;e<=r;e++){let l=null,u=0,d=0;if(e<r){let r=t[n+e];if(r.op===H.Op.CONCAT&&r.subs.length>0&&(r=r.subs[0]),r.op===H.Op.LITERAL&&(l=r.runes,u=r.runes.length,d=r.flags&L.FOLD_CASE),d===s){let e=0;for(;e<o&&e<u&&a[e]===l[e];)e++;if(e>0){o=e;continue}}}if(e!==c)if(e===c+1)t[i++]=t[n+c];else{let r=this.newRegexp(H.Op.LITERAL);r.flags=s,r.runes=a.slice(0,o);for(let r=c;r<e;r++)t[n+r]=this.removeLeadingString(t[n+r],o),this.checkLimits(t[n+r]);let l=this.collapse(t.slice(n+c,n+e),H.Op.ALTERNATE),u=this.newRegexp(H.Op.CONCAT);u.subs=[r,l],t[i++]=u}c=e,a=l,o=u,s=d}r=i,n=0,c=0,i=0;let l=null;for(let a=0;a<=r;a++){let o=null;if(!(a<r&&(o=e.leadingRegexp(t[n+a]),l!==null&&l.equals(o)&&(e.isCharClass(l)||l.op===H.Op.REPEAT&&l.min===l.max&&e.isCharClass(l.subs[0]))))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let e=l;for(let e=c;e<a;e++){let r=e!==c;t[n+e]=this.removeLeadingRegexp(t[n+e],r),this.checkLimits(t[n+e])}let r=this.collapse(t.slice(n+c,n+a),H.Op.ALTERNATE),o=this.newRegexp(H.Op.CONCAT);o.subs=[e,r],t[i++]=o}c=a,l=o}}r=i,n=0,c=0,i=0;for(let a=0;a<=r;a++)if(!(a<r&&e.isCharClass(t[n+a]))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let r=c;for(let e=c+1;e<a;e++){let i=t[n+r],a=t[n+e];(i.op<a.op||i.op===a.op&&(i.runes===null?0:i.runes.length)<(a.runes===null?0:a.runes.length))&&(r=e)}let o=t[n+c];t[n+c]=t[n+r],t[n+r]=o;for(let r=c+1;r<a;r++)e.mergeCharClass(t[n+c],t[n+r]),this.reuse(t[n+r]);this.cleanAlt(t[n+c]),t[i++]=t[n+c]}a<r&&(t[i++]=t[n+a]),c=a+1}r=i,n=0,c=0,i=0;for(let e=0;e<r;++e)e+1<r&&t[n+e].op===H.Op.EMPTY_MATCH&&t[n+e+1].op===H.Op.EMPTY_MATCH||(t[i++]=t[n+e]);return r=i,n=0,t.slice(n,r)}removeLeadingString(e,t){if(e.op===H.Op.CONCAT&&e.subs.length>0){let n=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=n,n.op===H.Op.EMPTY_MATCH)switch(this.reuse(n),e.subs.length){case 0:case 1:e.op=H.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let t=e;e=e.subs[1],this.reuse(t);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===H.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=H.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===H.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=H.Op.EMPTY_MATCH,e.subs=H.emptySubs();break;case 1:{let t=e;e=e.subs[0],this.reuse(t);break}}return e}return t&&this.reuse(e),this.newRegexp(H.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&L.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,i=new ec(this.wholeRegexp);for(;i.more();){let a=-1;e:switch(i.peek()){case R.CODES.get(`(`):if((this.flags&L.PERL_X)!==0&&i.lookingAt(`(?`)){this.parsePerlFlags(i);break}this.op(H.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case R.CODES.get(`|`):this.parseVerticalBar(),i.skip(1);break;case R.CODES.get(`)`):this.parseRightParen(),i.skip(1);break;case R.CODES.get(`^`):(this.flags&L.ONE_LINE)===0?this.op(H.Op.BEGIN_LINE):this.op(H.Op.BEGIN_TEXT),i.skip(1);break;case R.CODES.get(`$`):(this.flags&L.ONE_LINE)===0?this.op(H.Op.END_LINE):this.op(H.Op.END_TEXT).flags|=L.WAS_DOLLAR,i.skip(1);break;case R.CODES.get(`.`):(this.flags&L.DOT_NL)===0?this.op(H.Op.ANY_CHAR_NOT_NL):this.op(H.Op.ANY_CHAR),i.skip(1);break;case R.CODES.get(`[`):this.parseClass(i);break;case R.CODES.get(`*`):case R.CODES.get(`+`):case R.CODES.get(`?`):{a=i.pos();let e=null;switch(i.pop()){case R.CODES.get(`*`):e=H.Op.STAR;break;case R.CODES.get(`+`):e=H.Op.PLUS;break;case R.CODES.get(`?`):e=H.Op.QUEST}this.repeat(e,n,r,a,i,t);break}case R.CODES.get(`{`):{a=i.pos();let o=e.parseRepeat(i);if(o<0){i.rewindTo(a),this.literal(i.pop());break}n=o>>16,r=(o&B.MAX_BMP)<<16>>16,this.repeat(H.Op.REPEAT,n,r,a,i,t);break}case R.CODES.get(`\\`):{let t=i.pos();if(i.skip(1),(this.flags&L.PERL_X)!==0&&i.more())switch(i.pop()){case R.CODES.get(`A`):this.op(H.Op.BEGIN_TEXT);break e;case R.CODES.get(`b`):this.op(H.Op.WORD_BOUNDARY);break e;case R.CODES.get(`B`):this.op(H.Op.NO_WORD_BOUNDARY);break e;case R.CODES.get(`C`):throw new gs(e.ERR_INVALID_ESCAPE,`\\C`);case R.CODES.get(`Q`):{let e=i.rest(),t=e.indexOf(`\\E`);t>=0&&(e=e.substring(0,t)),i.skipString(e),i.skipString(`\\E`);let n=0;for(;n<e.length;){let t=e.codePointAt(n);this.literal(t),n+=as.charCount(t)}break e}case R.CODES.get(`z`):this.op(H.Op.END_TEXT);break e;default:i.rewindTo(t);break}let n=this.newRegexp(H.Op.CHAR_CLASS);if(n.flags=this.flags,i.lookingAt(`\\p`)||i.lookingAt(`\\P`)){let e=new Qs;if(this.parseUnicodeClass(i,e)){n.runes=e.toArray(),this.push(n);break e}}let r=new Qs;if(this.parsePerlClassEscape(i,r)){n.runes=r.toArray(),this.push(n);break e}i.rewindTo(t),this.reuse(n),this.literal(e.parseEscape(i));break}default:this.literal(i.pop())}t=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new gs(e.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){let n=t.pos(),r=t.rest();if(r.startsWith(`(?P<`)||r.startsWith(`(?<`)){let n=r.charAt(2)===`P`?4:3,i=r.indexOf(`>`);if(i<0)throw new gs(e.ERR_INVALID_NAMED_CAPTURE,r);let a=r.substring(n,i);if(t.skipString(a),t.skip(n+1),!e.isValidCaptureName(a))throw new gs(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,i+1));let o=this.op(H.Op.LEFT_PAREN);if(o.cap=++this.numCap,this.namedGroups[a])throw new gs(e.ERR_DUPLICATE_NAMED_CAPTURE,a);this.namedGroups[a]=this.numCap,o.name=a;return}t.skip(2);let i=this.flags,a=1,o=!1;e:for(;t.more();){let e=t.pop();switch(e){case R.CODES.get(`i`):i|=L.FOLD_CASE,o=!0;break;case R.CODES.get(`m`):i&=-17,o=!0;break;case R.CODES.get(`s`):i|=L.DOT_NL,o=!0;break;case R.CODES.get(`U`):i|=L.NON_GREEDY,o=!0;break;case R.CODES.get(`-`):if(a<0)break e;a=-1,i=~i,o=!1;break;case R.CODES.get(`:`):case R.CODES.get(`)`):if(a<0){if(!o)break e;i=~i}e===R.CODES.get(`:`)&&this.op(H.Op.LEFT_PAREN),this.flags=i;return;default:break e}}throw new gs(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(H.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===H.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let e=r;r=n,n=e,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let e=this.stack[t-1],n=this.stack[t-2];if(n.op===H.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=e,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new gs(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let t=this.pop(),n=this.pop();if(n.op!==H.Op.LEFT_PAREN)throw new gs(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=n.flags,n.cap===0?this.push(t):(n.op=H.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(e,t){let n=e.pos();if((this.flags&L.PERL_X)===0||!e.more()||e.pop()!==R.CODES.get(`\\`)||!e.more())return!1;e.pop();let r=e.from(n),i=Is.has(r)?Is.get(r):null;return i!==null&&(t.appendGroup(i,(this.flags&L.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),i=r.indexOf(`:]`);if(i<0)return!1;let a=r.substring(0,i+2);t.skipString(a);let o=Zs.has(a)?Zs.get(a):null;if(o===null)throw new gs(e.ERR_INVALID_CHAR_RANGE,a);return n.appendGroup(o,(this.flags&L.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&L.UNICODE_GROUPS)===0||!t.lookingAt(`\\p`)&&!t.lookingAt(`\\P`))return!1;t.skip(1);let i=1,a=t.pop();if(a===R.CODES.get(`P`)&&(i=-1),!t.more())throw t.rewindTo(r),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest());a=t.pop();let o;if(a!==R.CODES.get(`{`))o=as.runeToString(a);else{let n=t.rest(),i=n.indexOf(`}`);if(i<0)throw t.rewindTo(r),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest());o=n.substring(0,i),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===R.CODES.get(`^`)&&(i=0-i,o=o.substring(1));let s=e.unicodeTable(o);if(s===null)throw new gs(e.ERR_INVALID_CHAR_RANGE,t.from(r));let c=s.first,l=s.second;if((this.flags&L.FOLD_CASE)===0||l===null)n.appendTableWithSign(c,i);else{let e=new Qs().appendTable(c).appendTable(l).cleanClass().toArray();n.appendClassWithSign(e,i)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(H.Op.CHAR_CLASS);r.flags=this.flags;let i=new Qs,a=1;t.more()&&t.lookingAt(`^`)&&(a=-1,t.skip(1),(this.flags&L.CLASS_NL)===0&&i.appendRange(R.CODES.get(`
236
+ `),R.CODES.get(`
237
+ `)));let o=!0;for(;!t.more()||t.peek()!==R.CODES.get(`]`)||o;){if(t.more()&&t.lookingAt(`-`)&&(this.flags&L.PERL_X)===0&&!o){let r=t.rest();if(r===`-`||!r.startsWith(`-]`))throw t.rewindTo(n),new gs(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let r=t.pos();if(t.lookingAt(`[:`)){if(this.parseNamedClass(t,i))continue;t.rewindTo(r)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(r);let a=e.parseClassChar(t,n),s=a;if(t.more()&&t.lookingAt(`-`)){if(t.skip(1),t.more()&&t.lookingAt(`]`))t.skip(-1);else if(s=e.parseClassChar(t,n),s<a)throw new gs(e.ERR_INVALID_CHAR_RANGE,t.from(r))}(this.flags&L.FOLD_CASE)===0?i.appendRange(a,s):i.appendFoldedRange(a,s)}t.skip(1),i.cleanClass(),a<0&&i.negateClass(),r.runes=i.toArray(),this.push(r)}},nc=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e&&(this.value=t,!0)}},rc=class e{static initTest(t){let n=e.compile(t),r=new e(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(t){return e.compileImpl(t,L.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,L.POSIX,!0)}static compileImpl(t,n,r){let i=tc.parse(t,n),a=i.maxCap();i=js.simplify(i);let o=As.compileRegexp(i),s=new e(t,o,a,r),[c,l]=o.prefix();return s.prefixComplete=c,s.prefix=l,s.prefixUTF8=as.stringToUtf8ByteArray(s.prefix),s.prefix.length>0&&(s.prefixRune=s.prefix.codePointAt(0)),s.namedGroups=i.namedGroups,s}static match(t,n){return e.compile(t).match(n)}constructor(e,t,n=0,r=0){this.expr=e,this.prog=t,this.numSubexp=n,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new nc,this.dfa=new Ds(t)}executeEngine(e,t,n,r){if(r>0)return this.doExecuteNFA(e,t,n,r);let i=this.dfa.match(e,t,n);return i===null?this.doExecuteNFA(e,t,n,r):i?[]:null}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let n=this.pooled.get();do n=this.pooled.get(),!t&&n&&(e=Cs.fromMachine(e),t=!0),e.next!==n&&(e.next=n);while(!this.pooled.compareAndSet(n,e))}toString(){return this.expr}doExecuteNFA(e,t,n,r){let i=this.get(),a=!1;i?i.next!==null&&(i=Cs.fromMachine(i),a=!0):(i=Cs.fromRE2(this),a=!0),i.init(r);let o=i.match(e,t,n)?i.submatches():null;return this.put(i,a),o}match(e){return this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,0)!==null}matchWithGroup(e,t,n,r,i){return e instanceof ss||(e=us.utf16(e)),this.matchMachineInput(e,t,n,r,i)}matchMachineInput(e,t,n,r,i){if(t>n)return[!1,null];let a=e.isUTF16Encoding()?ms.fromUTF16(e.asCharSequence(),0,n):ms.fromUTF8(e.asBytes(),0,n),o=this.executeEngine(a,t,r,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(e){return this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,n){let r=0,i=0,a=``,o=ms.fromUTF16(e),s=0;for(;i<=e.length;){let c=this.executeEngine(o,i,L.UNANCHORED,2);if(c===null||c.length===0)break;a+=e.substring(r,c[0]),(c[1]>r||c[0]===0)&&(a+=t(e.substring(c[0],c[1])),s++),r=c[1];let l=o.step(i)&7;if(i+l>c[1]?i+=l:i+1>c[1]?i++:i=c[1],s>=n)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let n=Array(t).fill(-1);for(let t=0;t<e.length;t++)n[t]=e[t];e=n}return e}allMatches(e,t,n=e=>e){let r=[],i=e.endPos();t<0&&(t=i+1);let a=0,o=0,s=-1;for(;o<t&&a<=i;){let t=this.executeEngine(e,a,L.UNANCHORED,this.prog.numCap);if(t===null||t.length===0)break;let c=!0;if(t[1]===a){t[0]===s&&(c=!1);let n=e.step(a);n<0?a=i+1:a+=n&7}else a=t[1];s=t[1],c&&(r.push(n(this.pad(t))),o++)}return r}findUTF8(e){let t=this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){let t=this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){let t=this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,2);return t===null?``:e.substring(t[0],t[1])}findIndex(e){return this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,2)}findUTF8Submatch(e){let t=this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n}findUTF8SubmatchIndex(e){return this.pad(this.executeEngine(ms.fromUTF8(e),0,L.UNANCHORED,this.prog.numCap))}findSubmatch(e){let t=this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n}findSubmatchIndex(e){return this.pad(this.executeEngine(ms.fromUTF16(e),0,L.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){let n=this.allMatches(ms.fromUTF8(e),t,t=>e.slice(t[0],t[1]));return n.length===0?null:n}findAllUTF8Index(e,t){let n=this.allMatches(ms.fromUTF8(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAll(e,t){let n=this.allMatches(ms.fromUTF16(e),t,t=>e.substring(t[0],t[1]));return n.length===0?null:n}findAllIndex(e,t){let n=this.allMatches(ms.fromUTF16(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(e,t){let n=this.allMatches(ms.fromUTF8(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllUTF8SubmatchIndex(e,t){let n=this.allMatches(ms.fromUTF8(e),t);return n.length===0?null:n}findAllSubmatch(e,t){let n=this.allMatches(ms.fromUTF16(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllSubmatchIndex(e,t){let n=this.allMatches(ms.fromUTF16(e),t);return n.length===0?null:n}},ic=class e{static isUpperCaseAlpha(e){return`A`<=e&&e<=`Z`}static isHexadecimal(e){return`0`<=e&&e<=`9`||`A`<=e&&e<=`F`||`a`<=e&&e<=`f`}static getUtf8CharSize(e){let t=e.charCodeAt(0);return t<128?1:t<2048?2:t<65536?3:4}static translate(t){if(typeof t!=`string`)return t;let n=``,r=!1,i=t.length;i===0&&(n=`(?:)`,r=!0);let a=0;for(;a<i;){let o=t[a];if(o===`\\`){if(a+1<i)switch(o=t[a+1],o){case`\\`:n+=`\\\\`,a+=2;continue;case`c`:if(a+2<i){let i=t[a+2];if(e.isUpperCaseAlpha(i)){n+=`\\x`,n+=(i.charCodeAt(0)-64>>4).toString(16).toUpperCase(),n+=(i.charCodeAt(0)-64&15).toString(16).toUpperCase(),a+=3,r=!0;continue}}n+=`\\c`,a+=2;continue;case`u`:if(a+2<i){let o=t[a+2];if(e.isHexadecimal(o)){n+=`\\x{`+o,a+=3;for(let r=0;r<3&&a<i&&(o=t[a],e.isHexadecimal(o));++a,++r)n+=o;n+=`}`,r=!0;continue}if(o===`{`){n+=`\\x`,a+=2,r=!0;continue}}n+=`\\u`,a+=2;continue;default:{n+=`\\`;let r=e.getUtf8CharSize(o);n+=t.substring(a+1,a+1+r),a+=r+1;continue}}}else if(o===`/`){n+=`\\/`,a+=1,r=!0;continue}else if(o===`(`&&a+2<i&&t[a+1]===`?`&&t[a+2]===`<`&&(a+3>=i||t[a+3]!==`=`&&t[a+3]!==`!`)){n+=`(?P<`,a+=3,r=!0;continue}let s=e.getUtf8CharSize(o);n+=t.substring(a,a+s),a+=s}return r?n:t}},ac=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return as.quoteMeta(e)}static translateRegExp(e){return ic.translate(e)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new ys(`Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH`);let i=L.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(i&=-129);let a=new e(t,n);return a.re2Input=rc.compileImpl(r,i,(n&e.LONGEST_MATCH)!==0),a}static matches(t,n){return e.compile(t).testExact(n)}static initTest(t,n,r){if(t==null)throw Error(`pattern is null`);if(r==null)throw Error(`re2 is null`);let i=new e(t,n);return i.re2Input=r,i}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.testExact(e)}matcher(e){return Array.isArray(e)&&(e=us.utf8(e)),new bs(this,e)}test(e){return Array.isArray(e)?this.re2Input.matchUTF8(e):this.re2Input.match(e)}testExact(e){let t=Array.isArray(e)?ms.fromUTF8(e):ms.fromUTF16(e);return this.re2Input.executeEngine(t,0,L.ANCHOR_BOTH,0)!==null}split(e,t=0){let n=this.matcher(e),r=[],i=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(t>0&&r.length===t-1)break;if(a===n.start()){if(t===0){i+=1,a=n.end();continue}}else for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.start())),a=n.end()}if(t===0&&a!==n.inputLength()){for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.inputLength()))}return(t!==0||r.length===0)&&r.push(n.substring(a,n.inputLength())),r}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}});function sc(e){let t=0;return e.includes(`i`)&&(t|=ac.CASE_INSENSITIVE),e.includes(`m`)&&(t|=ac.MULTILINE),e.includes(`s`)&&(t|=ac.DOTALL),t}function cc(e){return ac.translateRegExp(e)}function U(e,t=``,n={}){return new dc(e,t,n)}var lc,uc,dc,fc,pc=T(()=>{oc(),Wi(),j(),lc=1e6,uc=67108864,dc=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;_matcher=null;_matcherInput=null;maxResults;maxOutputBytes;signal;assertResultCount(e){if(this.signal?.aborted)throw Error(`regular expression aborted`);if(e>this.maxResults)throw new A(`regular expression result limit exceeded (${this.maxResults})`,`array_elements`)}expandReplacement(e,t){let n=new Ui(this.maxOutputBytes,`regular expression replacement`),r=this._re2.groupCount(),i=this._re2.namedGroups();for(let a=0;a<t.length;a++){let o=t[a];if(o===`\\`&&a+1<t.length){n.append(t[++a]);continue}if(o!==`$`||a+1>=t.length){n.append(o);continue}if(t[a+1]===`{`){let r=t.indexOf(`}`,a+2);if(r!==-1){let o=t.slice(a+2,r),s=i?.[o];if(s!==void 0){n.append(e.group(s)??``),a=r;continue}}}if(/\d/.test(t[a+1])){let i=a+1,o=0;for(;i<t.length&&/\d/.test(t[i]);){let e=o*10+Number(t[i]);if(e>r)break;o=e,i++}n.append(e.group(o)??``),a=i-1;continue}n.append(o)}return n.build()}acquireMatcher(e){return this._matcher===null?(this._matcher=this._re2.matcher(e),this._matcherInput=e,this._matcher):(this._matcherInput!==e&&(this._matcher.matcherInput.charSequence=e,this._matcherInput=e),this._matcher.reset(),this._matcher)}constructor(e,t=``,n={}){if(this._pattern=e,this._flags=t,this._global=t.includes(`g`),this._ignoreCase=t.includes(`i`),this._multiline=t.includes(`m`),this.maxResults=n.maxResults??lc,this.maxOutputBytes=n.maxOutputBytes??uc,this.signal=n.signal,!Number.isSafeInteger(this.maxResults)||this.maxResults<0||!Number.isSafeInteger(this.maxOutputBytes)||this.maxOutputBytes<0)throw Error(`invalid regular expression limits`);try{let n=cc(e),r=sc(t);this._re2=ac.compile(n,r)}catch(t){if(t instanceof gs){let n=t.message||``,r=``;throw n.includes(`(?=`)||n.includes(`(?!`)||n.includes(`(?<`)||n.includes(`(?<!`)||e.includes(`(?=`)||e.includes(`(?!`)||e.includes(`(?<=`)||e.includes(`(?<!`)?r=` Lookahead (?=, ?!) and lookbehind (?<=, ?<!) assertions are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support these features.`:(n.includes(`backreference`)||/\\[1-9]/.test(e))&&(r=` Backreferences (\\1, \\2, etc.) are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support backreferences.`),SyntaxError(`Invalid regular expression: /${e}/: ${n}${r}`)}throw t}}test(e){return this._global&&(this._lastIndex=0),this.acquireMatcher(e).find()}exec(e){let t=this.acquireMatcher(e),n=this._global?this._lastIndex:0;if(!t.find(n))return this._global&&(this._lastIndex=0),null;let r=this._re2.groupCount(),i=[];i.push(t.group(0)??``);for(let e=1;e<=r;e++){let n=t.group(e);i.push(n)}let a=i;a.index=t.start(0),a.input=e;let o=this._re2.namedGroups();if(o&&Object.keys(o).length>0){let e=Object.create(null);for(let[n,r]of Object.entries(o)){let i=t.group(r);i!==null&&(e[n]=i)}a.groups=e}return this._global&&(this._lastIndex=t.end(0),t.start(0)===t.end(0)&&this._lastIndex++),a}match(e){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(e);let t=[],n=this.acquireMatcher(e),r=0;for(;n.find(r);){let i=n.group(0)??``;if(this.assertResultCount(t.length+1),t.push(i),r=n.end(0),n.start(0)===n.end(0)&&r++,r>e.length)break}return t.length>0?t:null}replace(e,t){if(this._global&&(this._lastIndex=0),typeof t==`string`){let n=this._re2.matcher(e),r=new Ui(this.maxOutputBytes,`regular expression replacement`),i=0,a=0,o=0;for(;n.find(a);){this.assertResultCount(++o);let s=n.start(0),c=n.end(0);if(r.append(e.slice(i,s)),r.append(this.expandReplacement(n,t)),i=c,a=c>s?c:c+1,!this._global||a>e.length)break}return r.append(e.slice(i)),r.build()}let n=new Ui(this.maxOutputBytes,`regular expression replacement`),r=this._re2.matcher(e),i=0,a=0,o=0,s=this._re2.groupCount(),c=this._re2.namedGroups();for(;r.find(a);){this.assertResultCount(++o),n.append(e.slice(i,r.start(0)));let l=[],u=r.group(0)??``;for(let e=1;e<=s;e++)l.push(r.group(e));if(l.push(r.start(0)),l.push(e),c&&Object.keys(c).length>0){let e=Object.create(null);for(let[t,n]of Object.entries(c))e[t]=r.group(n)??``;l.push(e)}let d=r.start(0),f=r.end(0);if(n.append(t(u,...l)),i=f,a=i,d===f&&a++,!this._global||a>e.length)break}return n.append(e.slice(i)),n.build()}split(e,t){if(t===0)return[];let n=t===void 0||t<0?this.maxResults:Math.min(t,this.maxResults),r=[],i=this._re2.matcher(e),a=0,o=0;for(;r.length<n&&i.find(o);)this.assertResultCount(r.length+1),r.push(e.slice(a,i.start(0))),a=i.end(0),o=i.end(0)>i.start(0)?i.end(0):i.end(0)+1;return r.length<n&&r.push(e.slice(a)),r}search(e){let t=this.acquireMatcher(e);return t.find()?t.start(0):-1}*matchAll(e){if(!this._global)throw Error(`matchAll requires global flag`);this._lastIndex=0;let t=this._re2.matcher(e),n=this._re2.groupCount(),r=this._re2.namedGroups(),i=0,a=0;for(;t.find(i);){this.assertResultCount(++a);let o=[];o.push(t.group(0)??``);for(let e=1;e<=n;e++)o.push(t.group(e));let s=o;if(s.index=t.start(0),s.input=e,r&&Object.keys(r).length>0){let e=Object.create(null);for(let[n,i]of Object.entries(r)){let r=t.group(i);r!==null&&(e[n]=r)}s.groups=e}if(yield s,i=t.end(0),t.start(0)===t.end(0)&&i++,i>e.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=RegExp(``,this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(e){this._lastIndex=e}},fc=class{_regex;constructor(e){this._regex=e}test(e){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(e)}exec(e){return this._regex.exec(e)}match(e){return this._regex.global&&(this._regex.lastIndex=0),e.match(this._regex)}replace(e,t){return this._regex.global&&(this._regex.lastIndex=0),e.replace(this._regex,t)}split(e,t){return e.split(this._regex,t)}search(e){return e.search(this._regex)}*matchAll(e){if(!this._regex.global)throw Error(`matchAll requires global flag`);this._regex.lastIndex=0;let t=this._regex.exec(e);for(;t!==null;)yield t,t[0].length===0&&this._regex.lastIndex++,t=this._regex.exec(e)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(e){this._regex.lastIndex=e}}}),mc=T(()=>{pc()});function hc(e,t,n){let r=typeof n==`boolean`?{ignoreCase:n}:n??{},i=t;r.stripQuotes&&(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1));let a=r.ignoreCase?`i:${i}`:i,o=vc.get(a);if(!o){if(o=gc(i,r.ignoreCase),vc.size>=_c){let e=vc.keys().next().value;e!==void 0&&vc.delete(e)}vc.set(a,o)}return o.test(e)}function gc(e,t){let n=`^`;for(let t=0;t<e.length;t++){let r=e[t];if(r===`*`)n+=`.*`;else if(r===`?`)n+=`.`;else if(r===`[`){let r=t+1;for(;r<e.length&&e[r]!==`]`;)r++;n+=e.slice(t,r+1),t=r}else n+=r===`.`||r===`+`||r===`^`||r===`$`||r===`{`||r===`}`||r===`(`||r===`)`||r===`|`||r===`\\`?`\\${r}`:r}return n+=`$`,U(n,t?`i`:``)}var _c,vc,yc=T(()=>{mc(),_c=2048,vc=new Map});function bc(e,t){let n=e.ignoreCase?t.toLowerCase():t,r=e.needles;for(let e=0;e<r.length;e++)if(n.indexOf(r[e])!==-1)return!0;return!1}function xc(e,t){return e.replace(/\$(&|\d+|<([^>]+)>)/g,(e,n,r)=>n===`&`?t[0]:r===void 0?t[parseInt(n,10)]??``:t.groups?.[r]??``)}function Sc(e,t,n={}){let{invertMatch:r=!1,showLineNumbers:i=!1,countOnly:a=!1,countMatches:o=!1,filename:s=``,onlyMatching:c=!1,beforeContext:l=0,afterContext:u=0,maxCount:d=0,contextSeparator:f=`--`,showColumn:p=!1,vimgrep:m=!1,showByteOffset:h=!1,replace:g=null,passthru:_=!1,multiline:v=!1,kResetGroup:y,preFilter:b,maxWork:x,maxMatches:S,signal:ee}=n;if(v)return Cc(e,t,{invertMatch:r,showLineNumbers:i,countOnly:a,countMatches:o,filename:s,onlyMatching:c,beforeContext:l,afterContext:u,maxCount:d,contextSeparator:f,showColumn:p,showByteOffset:h,replace:g,kResetGroup:y,preFilter:b,maxWork:x,maxMatches:S,signal:ee});let C=0,te=(e=1)=>{if(ee?.aborted)throw new kr;if(C+=e,x!==void 0&&C>x)throw new A(`search: matching work limit exceeded (${x})`,`iterations`)},ne=(e,t)=>{if(S!==void 0&&e.length>=S)throw new A(`search: result limit exceeded (${S})`,`array_elements`);e.push(t)},w=1;for(let t=0;t<e.length;t++)if(!(t&1023)&&te(),e.charCodeAt(t)===10&&(w++,S!==void 0&&w>S))throw new A(`search: line limit exceeded (${S})`,`array_elements`);let re=e.split(`
238
+ `),ie=re.length,ae=ie>0&&re[ie-1]===``?ie-1:ie;if(a||o){let e=0,n=(o||c)&&!r;for(let i=0;i<ae;i++){te();let a=re[i];if(!(b&&!r&&!bc(b,a)))if(t.lastIndex=0,n)for(let n=t.exec(a);n!==null;n=t.exec(a))te(),e++,n[0].length===0&&t.lastIndex++;else t.test(a)!==r&&e++}return{output:`${s?`${s}:${e}`:String(e)}
239
+ `,matched:e>0,matchCount:e}}if(l===0&&u===0&&!_){let e=[],n=!1,a=0,o=0;for(let l=0;l<ae&&(te(),!(d>0&&a>=d));l++){let u=re[l],d=null;if(b&&!bc(b,u)||(t.lastIndex=0,d=t.exec(u)),d!==null!==r)if(n=!0,a++,c)for(let n=d;n!==null;n=t.exec(u)){te();let r=y===void 0?n[0]:n[y]??``,a=g===null?r:xc(g,n),c=s?`${s}:`:``;h&&(c+=`${o+n.index}:`),i&&(c+=`${l+1}:`),p&&(c+=`${n.index+1}:`),ne(e,c+a),n[0].length===0&&t.lastIndex++}else if(m)for(let n=d;n!==null;n=t.exec(u)){te();let r=s?`${s}:`:``;h&&(r+=`${o+n.index}:`),i&&(r+=`${l+1}:`),p&&(r+=`${n.index+1}:`),ne(e,r+u),n[0].length===0&&t.lastIndex++}else{let n=d?d.index+1:1,r=u;g!==null&&(t.lastIndex=0,r=t.replace(u,(...e)=>{if(e[0].length===0)return``;let t=e,n=e[e.length-1];return typeof n==`object`&&n?(t.groups=n,t.input=e[e.length-2],t.index=e[e.length-3]):(t.input=e[e.length-1],t.index=e[e.length-2]),xc(g,t)}));let a=s?`${s}:`:``;h&&(a+=`${o+(d?d.index:0)}:`),i&&(a+=`${l+1}:`),p&&(a+=`${n}:`),ne(e,a+r)}o+=u.length+1}return{output:e.length>0?`${e.join(`
240
+ `)}
241
+ `:``,matched:n,matchCount:a}}if(_){let e=[],n=!1,a=0;for(let o=0;o<ae;o++){te();let c=re[o],l;b&&!bc(b,c)?l=!1:(t.lastIndex=0,l=t.test(c));let u=l!==r;u&&(n=!0,a++);let d=u?`:`:`-`,f=s?`${s}${d}`:``;i&&(f+=`${o+1}${d}`),ne(e,f+c)}return{output:e.length>0?`${e.join(`
242
+ `)}
243
+ `:``,matched:n,matchCount:a}}let oe=[],se=0,ce=new Set,le=-1,ue=[];for(let e=0;e<ae&&(te(),!(d>0&&se>=d));e++){let n=re[e],i;if(b&&!bc(b,n)?i=!1:(t.lastIndex=0,i=t.test(n)),i!==r){if(S!==void 0&&ue.length>=S)throw new A(`search: match limit exceeded (${S})`,`array_elements`);ue.push(e),se++}}for(let e of ue){te();let n=Math.max(0,e-l);le>=0&&n>le+1&&ne(oe,f);for(let t=n;t<e;t++)if(te(),!ce.has(t)){ce.add(t),le=t;let e=re[t];i&&(e=`${t+1}-${e}`),s&&(e=`${s}-${e}`),ne(oe,e)}if(!ce.has(e)){ce.add(e),le=e;let n=re[e];if(c){t.lastIndex=0;for(let r=t.exec(n);r!==null;r=t.exec(n)){te();let n=y===void 0?r[0]:r[y]??``,a=g===null?n:g,o=s?`${s}:`:``;i&&(o+=`${e+1}:`),p&&(o+=`${r.index+1}:`),ne(oe,o+a),r[0].length===0&&t.lastIndex++}}else{let t=n;i&&(t=`${e+1}:${t}`),s&&(t=`${s}:${t}`),ne(oe,t)}}let r=Math.min(ae-1,e+u);for(let t=e+1;t<=r;t++)if(te(),!ce.has(t)){ce.add(t),le=t;let e=re[t];i&&(e=`${t+1}-${e}`),s&&(e=`${s}-${e}`),ne(oe,e)}}return{output:oe.length>0?`${oe.join(`
244
+ `)}
245
+ `:``,matched:se>0,matchCount:se}}function Cc(e,t,n){let{invertMatch:r,showLineNumbers:i,countOnly:a,countMatches:o,filename:s,onlyMatching:c,beforeContext:l,afterContext:u,maxCount:d,contextSeparator:f,showColumn:p,showByteOffset:m,replace:h,kResetGroup:g,preFilter:_,maxWork:v,maxMatches:y,signal:b}=n,x=0,S=(e=1)=>{if(b?.aborted)throw new kr;if(x+=e,v!==void 0&&x>v)throw new A(`search: matching work limit exceeded (${v})`,`iterations`)};if(_&&!r&&!bc(_,e))return a||o?{output:`${s?`${s}:0`:`0`}
246
+ `,matched:!1,matchCount:0}:{output:``,matched:!1,matchCount:0};let ee=[0];for(let t=0;t<e.length;t++)if(!(t&1023)&&S(),e[t]===`
247
+ `){if(y!==void 0&&ee.length>=y)throw new A(`search: line index limit exceeded (${y})`,`array_elements`);ee.push(t+1)}let C=e.split(`
248
+ `),te=C.length,ne=te>0&&C[te-1]===``?te-1:te,w=e=>{let t=0,n=ee.length;for(;t<n;){let r=t+Math.floor((n-t)/2);ee[r]<=e?t=r+1:n=r}return Math.max(0,t-1)},re=e=>{let t=w(e);return e-ee[t]+1};if(a||o){let n=0,i=0,a=-1;t.lastIndex=0;for(let r=t.exec(e);r!==null&&(S(),!(d>0&&n>=d));r=t.exec(e)){if(n++,!o){let e=w(r.index),t=w(r.index+Math.max(0,r[0].length-1)),n=Math.max(e,a+1);n<=t&&(i+=t-n+1,a=t)}r[0].length===0&&t.lastIndex++}let c=o?r?0:n:r?ne-i:i;return{output:`${s?`${s}:${c}`:String(c)}
249
+ `,matched:c>0,matchCount:c}}let ie=[];t.lastIndex=0;for(let n=t.exec(e);n!==null&&(S(),!(d>0&&ie.length>=d));n=t.exec(e)){if(y!==void 0&&ie.length>=y)throw new A(`search: match limit exceeded (${y})`,`array_elements`);let e=w(n.index),r=w(n.index+Math.max(0,n[0].length-1)),i=g===void 0?n[0]:n[g]??``;ie.push({startLine:e,endLine:r,byteOffset:n.index,column:re(n.index),matchText:i}),n[0].length===0&&t.lastIndex++}if(r){let e=new Set;for(let t of ie)for(let n=t.startLine;n<=t.endLine;n++)S(),e.add(n);let t=[];for(let n=0;n<ne;n++)if(S(),!e.has(n)){let e=C[n];i&&(e=`${n+1}:${e}`),s&&(e=`${s}:${e}`),t.push(e)}return{output:t.length>0?`${t.join(`
250
+ `)}
251
+ `:``,matched:t.length>0,matchCount:t.length}}if(ie.length===0)return{output:``,matched:!1,matchCount:0};let ae=new Set,oe=-1,se=[];for(let e of ie){S();let n=Math.max(0,e.startLine-l),r=Math.min(ne-1,e.endLine+u);oe>=0&&n>oe+1&&se.push(f);for(let t=n;t<e.startLine;t++)if(S(),!ae.has(t)){ae.add(t),oe=t;let e=C[t];i&&(e=`${t+1}-${e}`),s&&(e=`${s}-${e}`),se.push(e)}if(c){let t=h===null?e.matchText:h,n=s?`${s}:`:``;m&&(n+=`${e.byteOffset}:`),i&&(n+=`${e.startLine+1}:`),p&&(n+=`${e.column}:`),se.push(n+t);for(let t=e.startLine;t<=e.endLine;t++)S(),ae.add(t),oe=t}else for(let n=e.startLine;n<=e.endLine&&n<ne;n++)if(S(),!ae.has(n)){ae.add(n),oe=n;let r=C[n];h!==null&&n===e.startLine&&(t.lastIndex=0,r=t.replace(r,h));let a=s?`${s}:`:``;m&&n===e.startLine&&(a+=`${e.byteOffset}:`),i&&(a+=`${n+1}:`),p&&n===e.startLine&&(a+=`${e.column}:`),se.push(a+r)}for(let t=e.endLine+1;t<=r;t++)if(S(),!ae.has(t)){ae.add(t),oe=t;let e=C[t];i&&(e=`${t+1}-${e}`),s&&(e=`${s}-${e}`),se.push(e)}}return{output:se.length>0?`${se.join(`
252
+ `)}
253
+ `:``,matched:!0,matchCount:ie.length}}var wc=T(()=>{j()});function Tc(e){let t=``,n=0;for(;n<e.length;){if(e.slice(n,n+7)===`[[:<:]]`){t+=`\\b`,n+=7;continue}if(e.slice(n,n+7)===`[[:>:]]`){t+=`\\b`,n+=7;continue}if(e[n]===`[`){let r=`[`;for(n++,n<e.length&&(e[n]===`^`||e[n]===`!`)&&(r+=`^`,n++),n<e.length&&e[n]===`]`&&(r+=`\\]`,n++);n<e.length&&e[n]!==`]`;){if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let i=e.slice(n+2,t),a=Vc.get(i);if(a){r+=a,n=t+2;continue}}}if(e[n]===`\\`&&n+1<e.length){r+=e[n]+e[n+1],n+=2;continue}r+=e[n],n++}n<e.length&&e[n]===`]`&&(r+=`]`,n++),t+=r;continue}if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++}return t}function Ec(e,t){let n,r;switch(t.mode){case`fixed`:n=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);break;case`extended`:case`perl`:if(n=Tc(e),n=n.replace(/\(\?P<([^>]+)>/g,`(?<$1>`),t.mode===`perl`){n=Ac(n),n=jc(n),n=Mc(n);let e=Ic(n);n=e.pattern,r=e.kResetGroup}break;default:n=Tc(e),n=Bc(n)}t.wholeWord&&(n=`\\b(?:${n})\\b`),t.lineRegexp&&(n=`^(?:${n})$`);let i=/\\u\{[0-9A-Fa-f]+\}/.test(n),a=`g`+(t.ignoreCase?`i`:``)+(t.multiline?`m`:``)+(t.multilineDotall?`s`:``)+(i?`u`:``),o=Dc(n,t.ignoreCase??!1);return{regex:U(n,a),kResetGroup:r,preFilter:o??void 0}}function Dc(e,t){let n=e;if(n.startsWith(`\\b(?:`)&&n.endsWith(`)\\b`)?n=n.slice(5,n.length-3):n.startsWith(`\\b`)&&n.endsWith(`\\b`)&&n.length>=4&&(n=n.slice(2,n.length-2)),n.length===0)return null;let r=Oc(n);if(r===null)return null;let i=[];for(let e of r){let t=kc(e);if(t===null||t.length===0)return null;i.push(t)}return i.length===0?null:{needles:t?i.map(e=>e.toLowerCase()):i,ignoreCase:t}}function Oc(e){let t=[],n=0,r=!1,i=0;for(let a=0;a<e.length;a++){let o=e[a];if(o===`\\`){a++;continue}if(r){o===`]`&&(r=!1);continue}if(o===`[`)r=!0;else if(o===`(`)n++;else if(o===`)`){if(n--,n<0)return null}else o===`|`&&n===0&&(t.push(e.slice(i,a)),i=a+1)}return n!==0||r?null:(t.push(e.slice(i)),t)}function kc(e){let t=e;if(t.startsWith(`^`)&&(t=t.slice(1)),t.endsWith(`$`)){let e=0;for(let n=t.length-2;n>=0&&t[n]===`\\`;n--)e++;e%2==0&&(t=t.slice(0,-1))}if(t.length===0)return null;let n=``;for(let e=0;e<t.length;e++){let r=t[e];if(r===`\\`){let r=t[e+1];if(r===void 0||/[dDwWsSbBAZzGQE0-9ckpPNXRxuU]/.test(r))return null;n+=r===`n`?`
254
+ `:r===`t`?` `:r===`r`?`\r`:r===`f`?`\f`:r===`v`?`\v`:r,e++;continue}if(/[.*+?^${}()|[\]]/.test(r))return null;n+=r}return n}function Ac(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length&&e[n+1]===`Q`){n+=2;let r=``;for(;n<e.length;){if(e[n]===`\\`&&n+1<e.length&&e[n+1]===`E`){n+=2;break}r+=e[n],n++}t+=r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}else t+=e[n],n++;return t}function jc(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,`\\u{$1}`)}function Mc(e){let t=``,n=0;for(;n<e.length;){if(e[n]===`(`&&n+1<e.length&&e[n+1]===`?`){let r=e.slice(n).match(/^\(\?([imsx]*)(-[imsx]*)?(:|$|\))/);if(r){let i=r[1]||``,a=r[2]||``,o=r[3];if(o===`:`){let o=n+r[0].length-1,s=Nc(e,n);if(s!==-1){let r=Pc(e.slice(o+1,s),i,a);t+=`(?:${r})`,n=s+1;continue}}else if(o===`)`||o===``){n+=r[0].length;continue}}}t+=e[n],n++}return t}function Nc(e,t){let n=0,r=t;for(;r<e.length;){if(e[r]===`\\`){r+=2;continue}if(e[r]===`[`){for(r++;r<e.length&&e[r]!==`]`;)e[r]===`\\`&&r++,r++;r++;continue}if(e[r]===`(`)n++;else if(e[r]===`)`&&(n--,n===0))return r;r++}return-1}function Pc(e,t,n){let r=e;return t.includes(`i`)&&(r=Fc(r)),r}function Fc(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`\\`){n+1<e.length?(t+=r+e[n+1],n+=2):(t+=r,n++);continue}if(r===`[`){t+=r,n++,n<e.length&&e[n]===`^`&&(t+=e[n],n++);let i=[];for(;n<e.length&&e[n]!==`]`;)if(e[n]===`\\`)i.push(e[n]),n++,n<e.length&&(i.push(e[n]),n++);else if(e[n]===`-`&&i.length>0&&n+1<e.length&&e[n+1]!==`]`){let t=i[i.length-1],r=e[n+1];i.push(`-`),i.push(r),/[a-z]/.test(t)&&/[a-z]/.test(r)?(i.push(t.toUpperCase()),i.push(`-`),i.push(r.toUpperCase())):/[A-Z]/.test(t)&&/[A-Z]/.test(r)&&(i.push(t.toLowerCase()),i.push(`-`),i.push(r.toLowerCase())),n+=2}else{let t=e[n];if(i.push(t),/[a-zA-Z]/.test(t)){let e=t===t.toLowerCase()?t.toUpperCase():t.toLowerCase();i.includes(e)||i.push(e)}n++}t+=i.join(``),n<e.length&&(t+=e[n],n++);continue}if(/[a-zA-Z]/.test(r)){let e=r.toLowerCase(),n=r.toUpperCase();t+=`[${n}${e}]`}else t+=r;n++}return t}function Ic(e){let t=Lc(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),i=Rc(n);return{pattern:`(?:${n})(${r})`,kResetGroup:i+1}}function Lc(e){let t=0;for(;t<e.length-1;)if(e[t]===`\\`){if(e[t+1]===`K`){let n=0,r=t-1;for(;r>=0&&e[r]===`\\`;)n++,r--;if(n%2==0)return t}t+=2}else t++;return-1}function Rc(e){let t=0,n=0;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`[`){for(n++;n<e.length&&e[n]!==`]`;)e[n]===`\\`&&n++,n++;n++;continue}if(e[n]===`(`)if(n+1<e.length&&e[n+1]===`?`){if(n+2<e.length){let r=e[n+2];if(r===`:`||r===`=`||r===`!`){n++;continue}if(r===`<`&&n+3<e.length){let r=e[n+3];if(r===`=`||r===`!`){n++;continue}t++,n++;continue}}}else t++;n++}return t}function zc(e){let t=e.replace(/\$\{0\}|\$0(?![0-9])/g,`$$&`);return t=t.replace(/\$\{([^0-9}][^}]*)\}/g,`$$<$1>`),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,`$$<$1>`),t}function Bc(e){let t=``,n=0,r=!0,i=0;for(;n<e.length;){let a=e[n];if(a===`[`){for(t+=a,n++,n<e.length&&(e[n]===`^`||e[n]===`!`)&&(t+=e[n],n++),n<e.length&&e[n]===`]`&&(t+=e[n],n++);n<e.length&&e[n]!==`]`;)e[n]===`\\`&&n+1<e.length?(t+=e[n]+e[n+1],n+=2):(t+=e[n],n++);n<e.length&&e[n]===`]`&&(t+=e[n],n++),r=!1;continue}if(a===`\\`&&n+1<e.length){let o=e[n+1];if(o===`|`){t+=`|`,n+=2,r=!0;continue}if(o===`(`){t+=`(`,n+=2,i++,r=!0;continue}if(o===`)`){t+=`)`,n+=2,i=Math.max(0,i-1),r=!1;continue}if(o===`{`){let i=e.slice(n).match(/^\\{(\d+)(,(\d*)?)?\\}/);if(i){let e=i[1],a=i[2]!==void 0,o=i[3]||``;t+=a?`{${e},${o}}`:`{${e}}`,n+=i[0].length,r=!1;continue}t+=`\\{`,n+=2,r=!1;continue}if(o===`}`){t+=`\\}`,n+=2,r=!1;continue}t+=a+o,n+=2,r=!1;continue}if(a===`*`&&r){t+=`\\*`,n++;continue}if(a===`^`){if(r){t+=`^`,n++;continue}t+=`\\^`,n++;continue}if(a===`$`){let i=n===e.length-1,a=n+2<e.length&&e[n+1]===`\\`&&e[n+2]===`)`;t+=i||a?`$`:`\\$`,n++,r=!1;continue}t+=a===`+`||a===`?`||a===`|`||a===`(`||a===`)`||a===`{`||a===`}`?`\\${a}`:a,n++,r=!1}return t}var Vc,Hc=T(()=>{mc(),Vc=new Map([[`alpha`,`a-zA-Z`],[`digit`,`0-9`],[`alnum`,`a-zA-Z0-9`],[`lower`,`a-z`],[`upper`,`A-Z`],[`xdigit`,`0-9A-Fa-f`],[`space`,` \\t\\n\\r\\f\\v`],[`blank`,` \\t`],[`punct`,"!-/:-@\\[-`{-~"],[`graph`,`!-~`],[`print`,` -~`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`ascii`,`\\x00-\\x7F`],[`word`,`a-zA-Z0-9_`]])}),Uc=T(()=>{wc(),Hc()}),Wc={};E(Wc,{egrepCommand:()=>ol,egrepFlagsForFuzzing:()=>ll,fgrepCommand:()=>al,fgrepFlagsForFuzzing:()=>cl,flagsForFuzzing:()=>sl,grepCommand:()=>rl});function Gc(e){let t=e.limits.maxLoopIterations,n=e.limits.maxArrayElements;return Math.max(t,Math.min(n,t*10))}function Kc(e){if(++e.operations>e.maxOperations)throw new A(`grep: glob operation limit exceeded (${e.maxOperations})`,`glob_operations`)}function qc(e){if(e.results>=e.maxResults)throw new A(`grep: array element limit exceeded (${e.maxResults})`,`array_elements`);e.results++}function Jc(e){return e.split(`
255
+ `)}function Yc(e){if(e===``)return[];let t=e.split(`
256
+ `);return t[t.length-1]===``&&t.pop(),t}function Xc(e,t){return e.length===1?{pattern:e[0],mode:t}:t===`fixed`?{pattern:e.map(e=>`(?:${e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`).join(`|`),mode:`extended`}:t===`basic`?{pattern:e.join(`\\|`),mode:t}:{pattern:e.map(e=>`(?:${e})`).join(`|`),mode:t}}async function Zc(e,t,n,r,i,a=0){if(a>=il)return;let o=n.fs.resolvePath(n.cwd,e);try{if(Kc(i),!(await n.fs.stat(o)).isDirectory){let n=e.split(`/`).pop()||``;t&&hc(n,t.replace(/^\//,``),{stripQuotes:!0})&&(qc(i),r.push(e));return}Kc(i);let s=await n.fs.readdir(o);for(let o of s){let s=e===`.`?o:`${e}/${o}`,c=n.fs.resolvePath(n.cwd,s);Kc(i),(await n.fs.stat(c)).isDirectory?await Zc(s,t,n,r,i,a+1):t&&hc(o,t.replace(/^\//,``),{stripQuotes:!0})&&(qc(i),r.push(s))}}catch(e){Ur(e)}}async function Qc(e,t,n){let r=[],i=e.lastIndexOf(`/`),a,o;if(i===-1?(a=t.cwd,o=e):(a=e.slice(0,i)||`/`,o=e.slice(i+1)),e.includes(`**`)){let r=[],i=e.split(`**`);return await Zc(i[0].replace(/\/$/,``)||`.`,i[1]||``,t,r,n),r.map(e=>({path:e}))}let s=t.fs.resolvePath(t.cwd,a);try{if(t.fs.readdirWithFileTypes){Kc(n);let e=await t.fs.readdirWithFileTypes(s);for(let t of e)if(Kc(n),hc(t.name,o,{stripQuotes:!0})){let e=i===-1?t.name:`${a}/${t.name}`;qc(n),r.push({path:e,isFile:t.isFile})}}else{Kc(n);let e=await t.fs.readdir(s);for(let t of e)if(Kc(n),hc(t,o,{stripQuotes:!0})){let e=i===-1?t:`${a}/${t}`;qc(n),r.push({path:e})}}}catch(e){Ur(e)}return r.sort((e,t)=>e.path.localeCompare(t.path))}async function $c(e,t,n=[],r=[],i=[],a,o={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},s=[],c=0){if(c>=il)return s;let l=t.fs.resolvePath(t.cwd,e);try{let u,d;if(a!==void 0)u=a,d=!a;else{Kc(o);let e=await t.fs.stat(l);u=e.isFile,d=e.isDirectory}if(u){let t=e.split(`/`).pop()||e;return r.length>0&&r.some(e=>hc(t,e,{stripQuotes:!0}))||n.length>0&&!n.some(e=>hc(t,e,{stripQuotes:!0}))||(qc(o),s.push({path:e,isFile:!0})),s}if(!d)return s;let f=e.split(`/`).pop()||e;if(i.length>0&&i.some(e=>hc(f,e,{stripQuotes:!0})))return s;if(t.fs.readdirWithFileTypes){Kc(o);let a=await t.fs.readdirWithFileTypes(l);for(let l of a)Kc(o),!l.name.startsWith(`.`)&&await $c(e===`.`?l.name:`${e}/${l.name}`,t,n,r,i,l.isFile,o,s,c+1)}else{Kc(o);let a=await t.fs.readdir(l);for(let l of a)Kc(o),!l.startsWith(`.`)&&await $c(e===`.`?l:`${e}/${l}`,t,n,r,i,void 0,o,s,c+1)}}catch(e){Ur(e)}return s}var el,tl,nl,rl,il,al,ol,sl,cl,ll,ul=T(()=>{k(),Wr(),j(),yc(),F(),Uc(),el=`(standard input)`,tl=`[^\\s\\S]`,nl={name:`grep`,summary:`print lines that match patterns`,usage:`grep [OPTION]... PATTERN [FILE]...`,description:[`Search for PATTERN in each FILE.`,`With no FILE, or when FILE is -, read standard input.`],options:[`-E, --extended-regexp PATTERN is an extended regular expression`,`-P, --perl-regexp PATTERN is a Perl regular expression`,`-F, --fixed-strings PATTERN is a set of newline-separated strings`,`-i, --ignore-case ignore case distinctions`,`-v, --invert-match select non-matching lines`,`-w, --word-regexp match only whole words`,`-x, --line-regexp match only whole lines`,`-c, --count print only a count of matching lines`,`-l, --files-with-matches print only names of files with matches`,`-L, --files-without-match print names of files with no matches`,`-m NUM, --max-count=NUM stop after NUM matches`,`-n, --line-number print line number with output lines`,`-h, --no-filename suppress the file name prefix on output`,`-o, --only-matching show only nonempty parts of lines that match`,`-q, --quiet, --silent suppress all normal output`,`-r, -R, --recursive search directories recursively`,`-A NUM print NUM lines of trailing context`,`-B NUM print NUM lines of leading context`,`-C NUM print NUM lines of context`,`-e PATTERN use PATTERN for matching`,`-f FILE, --file=FILE obtain patterns from FILE, one per line`,` --include=GLOB search only files matching GLOB`,` --exclude=GLOB skip files matching GLOB`,` --exclude-dir=DIR skip directories matching DIR`,` --help display this help and exit`]},rl={name:`grep`,async execute(e,t){let n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=!1,p=!1,m=!1,h=!1,g=!1,_=0,v=0,y=0,b=[],x=[],S=[],ee=null,C=[],te=[],ne=!0;for(let t=0;t<e.length;t++){let w=e[t];if(ne&&w===`--`){ne=!1;continue}if(ne&&w===`--help`)return M(nl);if(ne&&w.startsWith(`-`)&&w!==`-`){if(w===`-e`&&t+1<e.length){ee=e[++t];continue}if(w.startsWith(`--file=`)){C.push(w.slice(7));continue}if(w.startsWith(`--include=`)){b.push(w.slice(10));continue}if(w.startsWith(`--exclude=`)){x.push(w.slice(10));continue}if(w.startsWith(`--exclude-dir=`)){S.push(w.slice(14));continue}if(w.startsWith(`--max-count=`)){_=parseInt(w.slice(12),10);continue}let te=w.match(/^-m(\d+)$/);if(te){_=parseInt(te[1],10);continue}if(w===`-m`&&t+1<e.length){_=parseInt(e[++t],10);continue}let ne=w.match(/^-([ABC])(\d+)$/);if(ne){let e=parseInt(ne[2],10);ne[1]===`A`?y=e:ne[1]===`B`?v=e:ne[1]===`C`&&(v=e,y=e);continue}if((w===`-A`||w===`-B`||w===`-C`)&&t+1<e.length){let n=parseInt(e[++t],10);w===`-A`?y=n:w===`-B`?v=n:(v=n,y=n);continue}let re=w.startsWith(`--`)?[w]:w.slice(1).split(``);for(let _=0;_<re.length;_++){let v=re[_];if(v===`f`||v===`--file`){let n=v===`f`?re.slice(_+1).join(``):``;if(n.length>0)C.push(n);else if(t+1<e.length)C.push(e[++t]);else return{stdout:``,stderr:v===`f`?`grep: option requires an argument -- 'f'
257
+ `:`grep: option '--file' requires an argument
258
+ `,exitCode:2};break}if(v===`i`||v===`--ignore-case`)n=!0;else if(v===`n`||v===`--line-number`)r=!0;else if(v===`v`||v===`--invert-match`)i=!0;else if(v===`c`||v===`--count`)a=!0;else if(v===`l`||v===`--files-with-matches`)o=!0;else if(v===`L`||v===`--files-without-match`)s=!0;else if(v===`r`||v===`R`||v===`--recursive`)c=!0;else if(v===`w`||v===`--word-regexp`)l=!0;else if(v===`x`||v===`--line-regexp`)u=!0;else if(v===`E`||v===`--extended-regexp`)d=!0;else if(v===`P`||v===`--perl-regexp`)f=!0;else if(v===`F`||v===`--fixed-strings`)p=!0;else if(v===`o`||v===`--only-matching`)m=!0;else if(v===`h`||v===`--no-filename`)h=!0;else if(v===`q`||v===`--quiet`||v===`--silent`)g=!0;else{if(v.startsWith(`--`))return P(`grep`,v);if(v.length===1)return P(`grep`,`-${v}`)}}}else te.push(w)}if(ee===null&&C.length===0&&(ee=te.shift()??null,ee===null))return{stdout:``,stderr:`grep: missing pattern
259
+ `,exitCode:2};let w=te,re=ee===null?[]:Jc(ee),ie=!1;for(let e of C){let n;if(e===``)return{stdout:``,stderr:`grep: : No such file or directory
260
+ `,exitCode:2};if(e===`-`)n=ie?``:or(t.stdin),ie=!0;else try{let r=t.fs.resolvePath(t.cwd,e);if((await t.fs.stat(r)).isDirectory)return{stdout:``,stderr:`grep: ${e}: Is a directory
261
+ `,exitCode:2};n=await t.fs.readFile(r)}catch(t){return Ur(t),{stdout:``,stderr:`grep: ${e}: No such file or directory
262
+ `,exitCode:2}}let r=Yc(n);if(re.length+r.length>t.limits.maxArrayElements)throw new A(`grep: array element limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);re.push(...r)}if(re.length===0&&!i&&!s)return{stdout:``,stderr:``,exitCode:1};let ae=p?`fixed`:d?`extended`:f?`perl`:`basic`;if(ae===`perl`&&new Set(re).size>1)return{stdout:``,stderr:`grep: the -P option only supports a single pattern
263
+ `,exitCode:2};if(re.length>1&&ae!==`fixed`)for(let e of re)try{Ec(e,{mode:ae})}catch{return{stdout:``,stderr:`grep: invalid regular expression: ${e}
264
+ `,exitCode:2}}let oe=re.length===0?{pattern:tl,mode:`extended`}:Xc(re,ae),se,ce,le;try{let e=Ec(oe.pattern,{mode:oe.mode,ignoreCase:n,wholeWord:l,lineRegexp:u});se=e.regex,ce=e.kResetGroup,le=e.preFilter}catch{return{stdout:``,stderr:`grep: invalid regular expression: ${re.join(`
265
+ `)}
266
+ `,exitCode:2}}if(w.length===0&&t.stdin!==void 0){let e=Sc(ie?``:or(t.stdin),se,{invertMatch:i,showLineNumbers:r,countOnly:a,filename:``,onlyMatching:m,beforeContext:v,afterContext:y,maxCount:_,kResetGroup:ce,preFilter:le,maxWork:Gc(t),maxMatches:t.limits.maxArrayElements,signal:t.signal});return g?{stdout:``,stderr:``,exitCode:+!e.matched}:{stdout:e.output,stderr:``,exitCode:+!e.matched}}if(w.length===0)return{stdout:``,stderr:`grep: no input files
267
+ `,exitCode:2};let ue=``,de=``,fe=!1,pe=!1,me=[],he={operations:0,results:0,maxOperations:t.limits.maxGlobOperations,maxResults:t.limits.maxArrayElements},ge=e=>{if(e.length>he.maxResults-me.length)throw new A(`grep: array element limit exceeded (${he.maxResults})`,`array_elements`);me.push(...e)},_e=!1,ve=!1;for(let e of w){if(e===`-`){if(me.length>=he.maxResults)throw new A(`grep: array element limit exceeded (${he.maxResults})`,`array_elements`);me.push({path:el,isFile:!0,isStdin:!0,stdinAtEof:_e}),_e=!0;continue}if(ve=!0,e.includes(`*`)||e.includes(`?`)||e.includes(`[`)){let n=await Qc(e,t,he);if(c)for(let e of n)ge(await $c(e.path,t,b,x,S,e.isFile,he));else ge(n)}else if(c)ge(await $c(e,t,b,x,S,void 0,he));else{if(me.length>=he.maxResults)throw new A(`grep: array element limit exceeded (${he.maxResults})`,`array_elements`);me.push({path:e})}}let ye=(me.length>1||c&&ve)&&!h;for(let e=0;e<me.length;e+=50){let n=me.slice(e,e+50),l=await Promise.all(n.map(async e=>{let n=e.path,o=n.split(`/`).pop()||n;if(x.length>0&&!c&&!e.isStdin&&x.some(e=>hc(o,e,{stripQuotes:!0}))||b.length>0&&!c&&!e.isStdin&&!b.some(e=>hc(o,e,{stripQuotes:!0})))return null;try{let o;if(e.isStdin)o=e.stdinAtEof||t.stdin===void 0?``:or(t.stdin);else{let r=t.fs.resolvePath(t.cwd,n),i=!1;if(i=e.isFile===void 0?(await t.fs.stat(r)).isDirectory:!e.isFile,i)return c?null:{error:`grep: ${n}: Is a directory
268
+ `};o=await t.fs.readFile(r)}if(le&&!i){let e=le.ignoreCase?o.toLowerCase():o;if(!le.needles.some(t=>e.includes(t)))return a?{file:n,result:{output:`${ye?`${n}:0`:`0`}
269
+ `,matched:!1,matchCount:0}}:{file:n,result:{output:``,matched:!1,matchCount:0}}}return{file:n,result:Sc(o,se,{invertMatch:i,showLineNumbers:r,countOnly:a,filename:ye?n:``,onlyMatching:m,beforeContext:v,afterContext:y,maxCount:_,kResetGroup:ce,preFilter:le,maxWork:Gc(t),maxMatches:t.limits.maxArrayElements,signal:t.signal})}}catch(e){return Ur(e),{error:`grep: ${n}: No such file or directory
270
+ `}}}));for(let e of l){if(e===null)continue;if(`error`in e&&e.error){de+=e.error,e.error.includes(`Is a directory`)||(pe=!0);continue}if(!(`file`in e)||!e.result)continue;let{file:t,result:n}=e;if(n.matched){if(fe=!0,g)return{stdout:``,stderr:``,exitCode:0};o?ue+=`${t}
271
+ `:s||(ue+=n.output)}else s?ue+=`${t}
272
+ `:a&&!o&&(ue+=n.output)}}let be;return be=pe?2:+!fe,g?{stdout:``,stderr:``,exitCode:be}:{stdout:ue,stderr:de,exitCode:be}}},il=256,al={name:`fgrep`,async execute(e,t){return rl.execute([`-F`,...e],t)}},ol={name:`egrep`,async execute(e,t){return rl.execute([`-E`,...e],t)}},sl={name:`grep`,flags:[{flag:`-E`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-P`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-x`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-L`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-o`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-m`,type:`value`,valueHint:`number`},{flag:`-A`,type:`value`,valueHint:`number`},{flag:`-B`,type:`value`,valueHint:`number`},{flag:`-C`,type:`value`,valueHint:`number`},{flag:`-e`,type:`value`,valueHint:`pattern`},{flag:`-f`,type:`value`,valueHint:`path`}],stdinType:`text`,needsArgs:!0},cl={name:`fgrep`,flags:[],stdinType:`text`,needsArgs:!0},ll={name:`egrep`,flags:[],stdinType:`text`,needsArgs:!0}});function dl(e,t){if(Array.isArray(e))throw TypeError(`${t}: expected object, got array`);if(Object.getPrototypeOf(e)!==null)throw TypeError(`${t}: expected null-prototype object, got prototypal object`)}function fl(e){return!bl.has(e)}function pl(e,t,n){dl(e,`safeSet`),fl(t)&&(e[t]=n)}function ml(e,t){return dl(e,`safeHasOwn`),Object.hasOwn(e,t)}function hl(e,t={}){let n=t.maxDepth??2e3,r=t.maxElements??1e6,i=new WeakMap,a=t.elementBudget??{used:0};if(!Number.isSafeInteger(a.used)||a.used<0||a.used>r)throw new A(`query input element limit exceeded (${r})`,`array_elements`);let o=()=>{if(++a.used>r)throw new A(`query input element limit exceeded (${r})`,`array_elements`)},s=(e,t,r)=>{if(typeof e!=`object`||!e||e instanceof Date)return e;let a=i.get(e);if(a!==void 0)return a;if(t>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let o=Array.isArray(e)?[]:Object.create(null);return i.set(e,o),r.push({source:e,target:o,depth:t}),o},c=[],l=s(e,0,c);for(;c.length>0;){let e=c.pop();if(!e)break;let{source:t,target:n,depth:i}=e;if(Array.isArray(t)&&Array.isArray(n)){if(t.length>r-a.used)throw new A(`query input element limit exceeded (${r})`,`array_elements`);n.length=t.length;for(let e=t.length-1;e>=0;e--)o(),n[e]=s(t[e],i+1,c);continue}let l=t,u=n,d=Object.keys(l);if(d.length>r-a.used)throw new A(`query input element limit exceeded (${r})`,`array_elements`);for(let e=0;e<d.length;e++){o();let t=d[e];u[t]=s(l[t],i+1,c)}}return l}function gl(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function _l(e){return Object.assign(Object.create(null),e)}function vl(e){return Object.assign(Object.create(null),e)}function yl(...e){return Object.assign(Object.create(null),...e)}var bl,xl=T(()=>{j(),bl=new Set([`__proto__`,`constructor`,`prototype`]),[...bl]});function Sl(){let e=[];for(let[t,n]of Object.entries(Cl).sort()){let r=[];for(let e of n.extensions)r.push(`*${e}`);for(let e of n.globs)r.push(e);e.push(`${t}: ${r.join(`, `)}`)}return`${e.join(`
273
+ `)}
274
+ `}var Cl,wl,Tl=T(()=>{mc(),xl(),Cl=_l({js:{extensions:[`.js`,`.mjs`,`.cjs`,`.jsx`],globs:[]},ts:{extensions:[`.ts`,`.tsx`,`.mts`,`.cts`],globs:[]},html:{extensions:[`.html`,`.htm`,`.xhtml`],globs:[]},css:{extensions:[`.css`,`.scss`,`.sass`,`.less`],globs:[]},json:{extensions:[`.json`,`.jsonc`,`.json5`],globs:[]},xml:{extensions:[`.xml`,`.xsl`,`.xslt`],globs:[]},c:{extensions:[`.c`,`.h`],globs:[]},cpp:{extensions:[`.cpp`,`.cc`,`.cxx`,`.hpp`,`.hh`,`.hxx`,`.h`],globs:[]},rust:{extensions:[`.rs`],globs:[]},go:{extensions:[`.go`],globs:[]},zig:{extensions:[`.zig`],globs:[]},java:{extensions:[`.java`],globs:[]},kotlin:{extensions:[`.kt`,`.kts`],globs:[]},scala:{extensions:[`.scala`,`.sc`],globs:[]},clojure:{extensions:[`.clj`,`.cljc`,`.cljs`,`.edn`],globs:[]},py:{extensions:[`.py`,`.pyi`,`.pyw`],globs:[]},rb:{extensions:[`.rb`,`.rake`,`.gemspec`],globs:[`Rakefile`,`Gemfile`]},php:{extensions:[`.php`,`.phtml`,`.php3`,`.php4`,`.php5`],globs:[]},perl:{extensions:[`.pl`,`.pm`,`.pod`,`.t`],globs:[]},lua:{extensions:[`.lua`],globs:[]},sh:{extensions:[`.sh`,`.bash`,`.zsh`,`.fish`],globs:[`.bashrc`,`.zshrc`,`.profile`]},bat:{extensions:[`.bat`,`.cmd`],globs:[]},ps:{extensions:[`.ps1`,`.psm1`,`.psd1`],globs:[]},yaml:{extensions:[`.yaml`,`.yml`],globs:[]},toml:{extensions:[`.toml`],globs:[`Cargo.toml`,`pyproject.toml`]},ini:{extensions:[`.ini`,`.cfg`,`.conf`],globs:[]},csv:{extensions:[`.csv`,`.tsv`],globs:[]},md:{extensions:[`.md`,`.mdx`,`.markdown`,`.mdown`,`.mkd`],globs:[]},markdown:{extensions:[`.md`,`.mdx`,`.markdown`,`.mdown`,`.mkd`],globs:[]},rst:{extensions:[`.rst`],globs:[]},txt:{extensions:[`.txt`,`.text`],globs:[]},tex:{extensions:[`.tex`,`.ltx`,`.sty`,`.cls`],globs:[]},sql:{extensions:[`.sql`],globs:[]},graphql:{extensions:[`.graphql`,`.gql`],globs:[]},proto:{extensions:[`.proto`],globs:[]},make:{extensions:[`.mk`,`.mak`],globs:[`Makefile`,`GNUmakefile`,`makefile`]},docker:{extensions:[],globs:[`Dockerfile`,`Dockerfile.*`,`*.dockerfile`]},tf:{extensions:[`.tf`,`.tfvars`],globs:[]}}),wl=class{types;constructor(){this.types=new Map(Object.entries(Cl).map(([e,t])=>[e,{extensions:[...t.extensions],globs:[...t.globs]}]))}addType(e){let t=e.indexOf(`:`);if(t===-1)return;let n=e.slice(0,t),r=e.slice(t+1);if(r.startsWith(`include:`)){let e=r.slice(8),t=this.types.get(e);if(t){let e=this.types.get(n)||{extensions:[],globs:[]};e.extensions.push(...t.extensions),e.globs.push(...t.globs),this.types.set(n,e)}}else{let e=this.types.get(n)||{extensions:[],globs:[]};if(r.startsWith(`*.`)&&!r.slice(2).includes(`*`)){let t=r.slice(1);e.extensions.includes(t)||e.extensions.push(t)}else e.globs.includes(r)||e.globs.push(r);this.types.set(n,e)}}clearType(e){let t=this.types.get(e);t&&(t.extensions=[],t.globs=[])}getType(e){return this.types.get(e)}getAllTypes(){return this.types}matchesType(e,t){let n=e.toLowerCase();for(let r of t){if(r===`all`){if(this.matchesAnyType(e))return!0;continue}let t=this.types.get(r);if(t){for(let e of t.extensions)if(n.endsWith(e))return!0;for(let r of t.globs)if(r.includes(`*`)){if(U(`^${r.replace(/\./g,`\\.`).replace(/\*/g,`.*`)}$`,`i`).test(e))return!0}else if(n===r.toLowerCase())return!0}}return!1}matchesAnyType(e){let t=e.toLowerCase();for(let n of this.types.values()){for(let e of n.extensions)if(t.endsWith(e))return!0;for(let r of n.globs)if(r.includes(`*`)){if(U(`^${r.replace(/\./g,`\\.`).replace(/\*/g,`.*`)}$`,`i`).test(e))return!0}else if(t===r.toLowerCase())return!0}return!1}}});function El(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:`--`,quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:`path`,json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:256,maxFilesize:536870912,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var Dl=T(()=>{});function Ol(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let n=parseInt(t[1],10);switch((t[2]||``).toUpperCase()){case`K`:return n*1024;case`M`:return n*1024*1024;case`G`:return n*1024*1024*1024;default:return n}}function kl(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:``,stderr:`rg: invalid --max-filesize value: ${e}
275
+ `,exitCode:1}}function Al(e,t){return!/^\d+$/.test(t)||!Number.isSafeInteger(Number(t))?{stdout:``,stderr:`rg: invalid --${e} value: ${t}
276
+ `,exitCode:1}:null}function jl(e){return null}function Ml(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function Nl(e,t,n){let r=e[t];for(let i of Bl){if(r.startsWith(`--${i.long}=`)){let e=Fl(n,i,r.slice(`--${i.long}=`.length));return e?{newIndex:t,error:e}:{newIndex:t}}if(i.short&&r.startsWith(`-${i.short}`)&&r.length>2){let e=Fl(n,i,r.slice(2));return e?{newIndex:t,error:e}:{newIndex:t}}if(i.short&&r===`-${i.short}`||r===`--${i.long}`){if(t+1>=e.length)return null;let r=e[t+1],a=Fl(n,i,r);return a?{newIndex:t+1,error:a}:{newIndex:t+1}}}return null}function Pl(e){return Bl.find(t=>t.short===e)}function Fl(e,t,n){if(t.validate){let e=t.validate(n);if(e)return e}if(t.ignored||!t.target)return;let r=t.parse?t.parse(n):n;t.multi?e[t.target].push(r):e[t.target]=r}function Il(e,t){let n=e[t];if(n===`--sort`&&t+1<e.length){let n=e[t+1];if(n===`path`||n===`none`)return{value:n,newIndex:t+1}}if(n.startsWith(`--sort=`)){let e=n.slice(7);if(e===`path`||e===`none`)return{value:e,newIndex:t}}return null}function Ll(e,t){let n=e[t],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:t}:(n===`-A`||n===`-B`||n===`-C`)&&t+1<e.length?{flag:n[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function Rl(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function zl(e){let t=El(),n=null,r=[],i=-1,a=-1,o=-1,s=!1;for(let c=0;c<e.length;c++){let l=e[c];if(l.startsWith(`-`)&&l!==`-`){let n=Ll(e,c);if(n){let{flag:e,value:t,newIndex:r}=n;e===`A`?i=Math.max(i,t):e===`B`?a=Math.max(a,t):o=t,c=r;continue}let r=Rl(l);if(r!==null){t.maxCount=r;continue}let u=Nl(e,c,t);if(u){if(u.error)return{success:!1,error:u.error};c=u.newIndex;continue}let d=Il(e,c);if(d){t.sort=d.value,c=d.newIndex;continue}let f=l.startsWith(`--`)?[l]:l.slice(1).split(``);for(let n of f){if(Hl.has(n)){t.lineNumber=!0,s=!0;continue}if(n===`u`||n===`--unrestricted`){Ml(t);continue}if(n===`P`||n===`--pcre2`)return{success:!1,error:{stdout:``,stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
277
+ `,exitCode:1}};if(n.length===1){let r=Pl(n);if(r){if(c+1>=e.length)return{success:!1,error:P(`rg`,`-${n}`)};let i=Fl(t,r,e[c+1]);if(i)return{success:!1,error:i};c++;continue}}let r=Vl.get(n);if(r){r(t);continue}if(n.startsWith(`--`))return{success:!1,error:P(`rg`,n)};if(n.length===1)return{success:!1,error:P(`rg`,`-${n}`)}}}else n===null&&t.patterns.length===0&&t.patternFiles.length===0?n=l:r.push(l)}return(i>=0||o>=0)&&(t.afterContext=Math.max(i>=0?i:0,o>=0?o:0)),(a>=0||o>=0)&&(t.beforeContext=Math.max(a>=0?a:0,o>=0?o:0)),n!==null&&t.patterns.push(n),(t.column||t.vimgrep)&&(s=!0),{success:!0,options:t,paths:r,explicitLineNumbers:s}}var Bl,Vl,Hl,Ul=T(()=>{F(),Dl(),Bl=[{short:`g`,long:`glob`,target:`globs`,multi:!0},{long:`iglob`,target:`iglobs`,multi:!0},{short:`t`,long:`type`,target:`types`,multi:!0,validate:jl},{short:`T`,long:`type-not`,target:`typesNot`,multi:!0,validate:jl},{long:`type-add`,target:`typeAdd`,multi:!0},{long:`type-clear`,target:`typeClear`,multi:!0},{short:`m`,long:`max-count`,target:`maxCount`,parse:parseInt},{short:`e`,long:`regexp`,target:`patterns`,multi:!0},{short:`f`,long:`file`,target:`patternFiles`,multi:!0},{short:`r`,long:`replace`,target:`replace`},{short:`d`,long:`max-depth`,target:`maxDepth`,parse:e=>Number(e),validate:e=>Al(`max-depth`,e)},{long:`max-filesize`,target:`maxFilesize`,parse:Ol,validate:kl},{long:`context-separator`,target:`contextSeparator`},{short:`j`,long:`threads`,ignored:!0},{long:`ignore-file`,target:`ignoreFiles`,multi:!0},{long:`pre`,target:`preprocessor`},{long:`pre-glob`,target:`preprocessorGlobs`,multi:!0}],Vl=new Map([[`i`,e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],[`--ignore-case`,e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],[`s`,e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],[`--case-sensitive`,e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],[`S`,e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],[`--smart-case`,e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],[`F`,e=>{e.fixedStrings=!0}],[`--fixed-strings`,e=>{e.fixedStrings=!0}],[`w`,e=>{e.wordRegexp=!0}],[`--word-regexp`,e=>{e.wordRegexp=!0}],[`x`,e=>{e.lineRegexp=!0}],[`--line-regexp`,e=>{e.lineRegexp=!0}],[`v`,e=>{e.invertMatch=!0}],[`--invert-match`,e=>{e.invertMatch=!0}],[`U`,e=>{e.multiline=!0}],[`--multiline`,e=>{e.multiline=!0}],[`--multiline-dotall`,e=>{e.multilineDotall=!0,e.multiline=!0}],[`c`,e=>{e.count=!0}],[`--count`,e=>{e.count=!0}],[`--count-matches`,e=>{e.countMatches=!0}],[`l`,e=>{e.filesWithMatches=!0}],[`--files`,e=>{e.files=!0}],[`--files-with-matches`,e=>{e.filesWithMatches=!0}],[`--files-without-match`,e=>{e.filesWithoutMatch=!0}],[`--stats`,e=>{e.stats=!0}],[`o`,e=>{e.onlyMatching=!0}],[`--only-matching`,e=>{e.onlyMatching=!0}],[`q`,e=>{e.quiet=!0}],[`--quiet`,e=>{e.quiet=!0}],[`N`,e=>{e.lineNumber=!1}],[`--no-line-number`,e=>{e.lineNumber=!1}],[`H`,e=>{e.withFilename=!0}],[`--with-filename`,e=>{e.withFilename=!0}],[`I`,e=>{e.noFilename=!0}],[`--no-filename`,e=>{e.noFilename=!0}],[`0`,e=>{e.nullSeparator=!0}],[`--null`,e=>{e.nullSeparator=!0}],[`b`,e=>{e.byteOffset=!0}],[`--byte-offset`,e=>{e.byteOffset=!0}],[`--column`,e=>{e.column=!0,e.lineNumber=!0}],[`--no-column`,e=>{e.column=!1}],[`--vimgrep`,e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0}],[`--json`,e=>{e.json=!0}],[`--hidden`,e=>{e.hidden=!0}],[`--no-ignore`,e=>{e.noIgnore=!0}],[`--no-ignore-dot`,e=>{e.noIgnoreDot=!0}],[`--no-ignore-vcs`,e=>{e.noIgnoreVcs=!0}],[`L`,e=>{e.followSymlinks=!0}],[`--follow`,e=>{e.followSymlinks=!0}],[`z`,e=>{e.searchZip=!0}],[`--search-zip`,e=>{e.searchZip=!0}],[`a`,e=>{e.searchBinary=!0}],[`--text`,e=>{e.searchBinary=!0}],[`--heading`,e=>{e.heading=!0}],[`--passthru`,e=>{e.passthru=!0}],[`--include-zero`,e=>{e.includeZero=!0}],[`--glob-case-insensitive`,e=>{e.globCaseInsensitive=!0}]]),Hl=new Set([`n`,`--line-number`])});function Wl(e){return`'${e.replace(/'/g,`'\\''`)}'`}function Gl(e){return e.map(Wl).join(` `)}var Kl=T(()=>{});async function ql(e,t,n=!1,r=!1,i=[]){let a=new Yl(e,t,n,r);await a.load(t);for(let n of i)try{let r=e.resolvePath(t,n),i=await e.readFile(r);a.addPatternsFromContent(i,t)}catch{}return a}var Jl,Yl,Xl=T(()=>{mc(),Jl=class{patterns=[];basePath;constructor(e=`/`){this.basePath=e}parse(e){let t=e.split(`
278
+ `);for(let e of t){let t=e.replace(/\s+$/,``);if(!t||t.startsWith(`#`))continue;let n=!1;t.startsWith(`!`)&&(n=!0,t=t.slice(1));let r=!1;t.endsWith(`/`)&&(r=!0,t=t.slice(0,-1));let i=!1;t.startsWith(`/`)?(i=!0,t=t.slice(1)):t.includes(`/`)&&!t.startsWith(`**/`)&&(i=!0);let a=this.patternToRegex(t,i);this.patterns.push({pattern:e,regex:a,negated:n,directoryOnly:r,rooted:i})}}patternToRegex(e,t){let n=``;n=t?`^`:`(?:^|/)`;let r=0;for(;r<e.length;){let t=e[r];if(t===`*`)e[r+1]===`*`?e[r+2]===`/`?(n+=`(?:.*/)?`,r+=3):(r+2,e.length,n+=`.*`,r+=2):(n+=`[^/]*`,r++);else if(t===`?`)n+=`[^/]`,r++;else if(t===`[`){let t=r+1;for(t<e.length&&e[t]===`!`&&t++,t<e.length&&e[t]===`]`&&t++;t<e.length&&e[t]!==`]`;)t++;if(t<e.length){let i=e.slice(r,t+1);i.startsWith(`[!`)&&(i=`[^${i.slice(2)}`),n+=i,r=t+1}else n+=`\\[`,r++}else t===`/`?(n+=`/`,r++):(n+=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r++)}return n+=`(?:/.*)?$`,U(n)}matches(e,t){let n=e.replace(/^\.\//,``);n=n.replace(/^\//,``);let r=!1;for(let e of this.patterns)e.directoryOnly&&!t||e.regex.test(n)&&(r=!e.negated);return r}isWhitelisted(e,t){let n=e.replace(/^\.\//,``);n=n.replace(/^\//,``);for(let e of this.patterns)if(!(e.directoryOnly&&!t)&&e.negated&&e.regex.test(n))return!0;return!1}getBasePath(){return this.basePath}},Yl=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(e,t,n=!1,r=!1){this.fs=e,this.skipDotIgnore=n,this.skipVcsIgnore=r}async load(e){let t=[],n=e;for(;;){t.unshift(n);let e=this.fs.resolvePath(n,`..`);if(e===n)break;n=e}let r=[];this.skipVcsIgnore||r.push(`.gitignore`),this.skipDotIgnore||r.push(`.rgignore`,`.ignore`);for(let e of t){this.loadedDirs.add(e);for(let t of r){let n=this.fs.resolvePath(e,t);try{let t=await this.fs.readFile(n),r=new Jl(e);r.parse(t),this.parsers.push(r)}catch{}}}}async loadForDirectory(e){if(this.loadedDirs.has(e))return;this.loadedDirs.add(e);let t=[];this.skipVcsIgnore||t.push(`.gitignore`),this.skipDotIgnore||t.push(`.rgignore`,`.ignore`);for(let n of t){let t=this.fs.resolvePath(e,n);try{let n=await this.fs.readFile(t),r=new Jl(e);r.parse(n),this.parsers.push(r)}catch{}}}addPatternsFromContent(e,t){let n=new Jl(t);n.parse(e),this.parsers.push(n)}matches(e,t){for(let n of this.parsers){let r=n.getBasePath();if(!e.startsWith(r))continue;let i=e.slice(r.length).replace(/^\//,``);if(n.matches(i,t))return!0}return!1}isWhitelisted(e,t){for(let n of this.parsers){let r=n.getBasePath();if(!e.startsWith(r))continue;let i=e.slice(r.length).replace(/^\//,``);if(n.isWhitelisted(i,t))return!0}return!1}static isCommonIgnored(e){return new Set([`node_modules`,`.git`,`.svn`,`.hg`,`__pycache__`,`.pytest_cache`,`.mypy_cache`,`venv`,`.venv`,`.next`,`.nuxt`,`.cargo`]).has(e)}}});function Zl(e){return e.length>=2&&e[0]===31&&e[1]===139}function Ql(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r===`[`&&!t?t=!0:r===`]`&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}function $l(e,t){if(!Number.isSafeInteger(t)||t<0||t>e.limits.maxStringLength||t>Math.floor(e.limits.maxLiveBytes/3))throw new A(t>e.limits.maxStringLength?`rg: pattern file exceeds string limit (${e.limits.maxStringLength} bytes)`:`rg: live byte limit exceeded (${e.limits.maxLiveBytes} bytes)`,`string_length`);return e.executionScope?.reserveBytes(`rg pattern files`,t*3,`rg`)??{release:()=>{}}}function eu(e,t,n){let r=0;for(let i=0;i<=t.length;i++)if(!(i<t.length&&t.charCodeAt(i)!==10)){if(i>r){if(e.length>=n.limits.maxArrayElements)throw new A(`rg: pattern limit exceeded (${n.limits.maxArrayElements})`,`iterations`);n.executionScope?.consumeWork(1,`rg pattern insertion`),e.push(t.slice(r,i))}r=i+1}}function tu(e,t,n){if(t>e.limits.maxInputBytes-n)throw new A(`rg: aggregate input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);return e.executionScope?.consumeInput(t,`rg pattern files`),n+t}async function nu(e){let{ctx:t,options:n,paths:r,explicitLineNumbers:i}=e;for(let e of n.globs){let t=Ql(e.startsWith(`!`)?e.slice(1):e);if(t)return{stdout:``,stderr:`${t}
279
+ `,exitCode:1}}if(n.files)return lu(t,[...n.patterns,...r],n);if(n.patterns.length>t.limits.maxArrayElements)throw new A(`rg: pattern limit exceeded (${t.limits.maxArrayElements})`,`iterations`);let a=n.patterns.slice(),o=[],s=0,c,l;try{for(let e of n.patternFiles)try{let n,r;if(e===`-`)n=t.stdin,r=t.stdin.length,s=tu(t,r,s);else{let i=t.fs.resolvePath(t.cwd,e);r=(await t.fs.stat(i)).size,s=tu(t,r,s);let a=$l(t,r);o.push(a),n=await lr(t.fs,i);let c=n.length;if(c>r)throw new A(`rg: pattern file grew while being read`,`string_length`);r=c}e===`-`&&o.push($l(t,r));let i=or(n,t.limits.maxStringLength);t.executionScope?.consumeWork(i.length,`rg pattern file parsing`),eu(a,i,t)}catch(t){return Ur(t),{stdout:``,stderr:`rg: ${e}: No such file or directory
280
+ `,exitCode:2}}if(a.length===0)return n.patternFiles.length>0?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`rg: no pattern given
281
+ `,exitCode:2};let e=ru(n,a);try{let t=iu(a,n,e);c=t.regex,l=t.kResetGroup}catch{return{stdout:``,stderr:`rg: invalid regex: ${a.join(`, `)}
282
+ `,exitCode:2}}}finally{for(let e of o)e.release()}let u=n.patternFiles.includes(`-`),d=or(t.stdin);if(r.length===0&&d.length>0&&!u){let e=Sc(d,c,{invertMatch:n.invertMatch,showLineNumbers:n.lineNumber,countOnly:n.count,countMatches:n.countMatches,filename:``,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace===null?null:zc(n.replace),passthru:n.passthru,multiline:n.multiline,kResetGroup:l,maxWork:t.limits.maxLoopIterations,maxMatches:t.limits.maxArrayElements,signal:t.signal});return n.quiet?{stdout:``,stderr:``,exitCode:+!e.matched}:n.filesWithMatches?{stdout:e.matched?`(standard input)
283
+ `:``,stderr:``,exitCode:+!e.matched}:n.filesWithoutMatch?{stdout:e.matched?``:`(standard input)
284
+ `,stderr:``,exitCode:+!!e.matched}:{stdout:e.output,stderr:``,exitCode:+!e.matched}}let f=r.length===0?[`.`]:r,p=null;n.noIgnore||(p=await ql(t.fs,t.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let m=new wl;for(let e of n.typeClear)m.clearType(e);for(let e of n.typeAdd)m.addType(e);let{files:h,singleExplicitFile:g}=await au(t,f,n,p,m);if(h.length===0)return{stdout:``,stderr:``,exitCode:1};let _=!n.noFilename&&(n.withFilename||!g||h.length>1),v=n.lineNumber;return i||(g&&h.length===1&&(v=!1),n.onlyMatching&&(v=!1)),pu(t,h,c,n,_,v,l)}function ru(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(e=>/[A-Z]/.test(e)):!1}function iu(e,t,n){let r;return r=e.length===1?e[0]:e.map(e=>t.fixedStrings?e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`):`(?:${e})`).join(`|`),Ec(r,{mode:t.fixedStrings&&e.length===1?`fixed`:`perl`,ignoreCase:n,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function au(e,t,n,r,i){let a=[],o=new ca({limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`rg`}),s=0,c=0;for(let l of t){o.checkpoint();let t=e.fs.resolvePath(e.cwd,l);try{let u=await e.fs.stat(t);if(u.isFile){if(s++,n.maxFilesize>0&&u.size>n.maxFilesize)continue;if(su(l,n,r,t,i)){if(a.length>=e.limits.maxArrayElements)throw new A(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push(l)}}else u.isDirectory&&(c++,await ou(e,l,t,0,n,r,i,a,o,new Set))}catch(e){Ur(e)}}return{files:n.sort===`path`?a.sort():a,singleExplicitFile:s===1&&c===0}}async function ou(e,t,n,r,i,a,o,s,c,l){if(r>=i.maxDepth)return;c.visit(r);let u;if(i.followSymlinks)try{let t=await e.fs.stat(n);if(u=t.identity===void 0?t.dev!==void 0&&t.ino!==void 0?`inode:${String(t.dev)}:${String(t.ino)}`:`path:${await e.fs.realpath(n)}`:`identity:${t.identity}`,l.has(u))return;l.add(u)}catch(e){Ur(e);return}a&&await a.loadForDirectory(n);try{let u=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(n):(await e.fs.readdir(n)).map(e=>({name:e,isFile:void 0}));for(let d of u){c.checkpoint();let u=d.name;if(!i.noIgnore&&Yl.isCommonIgnored(u))continue;let f=u.startsWith(`.`),p=t===`.`?u:t===`./`?`./${u}`:t.endsWith(`/`)?`${t}${u}`:`${t}/${u}`,m=e.fs.resolvePath(n,u),h,g,_=!1;if(d.isFile!==void 0&&`isDirectory`in d){let t=d;if(_=t.isSymbolicLink===!0,_&&!i.followSymlinks)continue;if(_&&i.followSymlinks)try{let t=await e.fs.stat(m);h=t.isFile,g=t.isDirectory}catch{continue}else h=t.isFile,g=t.isDirectory}else try{let t=e.fs.lstat?await e.fs.lstat(m):await e.fs.stat(m);if(_=t.isSymbolicLink===!0,_&&!i.followSymlinks)continue;let n=_&&i.followSymlinks?await e.fs.stat(m):t;h=n.isFile,g=n.isDirectory}catch{continue}if(!a?.matches(m,g)&&!(f&&!i.hidden&&!a?.isWhitelisted(m,g))){if(g)await ou(e,p,m,r+1,i,a,o,s,c,l);else if(h){if(c.visit(r+1),i.maxFilesize>0)try{if((await e.fs.stat(m)).size>i.maxFilesize)continue}catch{continue}if(su(p,i,a,m,o)){if(s.length>=e.limits.maxArrayElements)throw new A(`rg: file collection limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);s.push(p)}}}}}catch(e){Ur(e)}finally{u!==void 0&&l.delete(u)}}function su(e,t,n,r,i){let a=e.split(`/`).pop()||e;if(n?.matches(r,!1)||t.types.length>0&&!i.matchesType(a,t.types)||t.typesNot.length>0&&i.matchesType(a,t.typesNot))return!1;if(t.globs.length>0){let n=t.globCaseInsensitive,r=t.globs.filter(e=>!e.startsWith(`!`)),i=t.globs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(r.length>0){let t=!1;for(let i of r)if(cu(a,i,n)||cu(e,i,n)){t=!0;break}if(!t)return!1}for(let t of i)if(t.startsWith(`/`)){if(cu(e,t.slice(1),n))return!1}else if(cu(a,t,n)||cu(e,t,n))return!1}if(t.iglobs.length>0){let n=t.iglobs.filter(e=>!e.startsWith(`!`)),r=t.iglobs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(n.length>0){let t=!1;for(let r of n)if(cu(a,r,!0)||cu(e,r,!0)){t=!0;break}if(!t)return!1}for(let t of r)if(t.startsWith(`/`)){if(cu(e,t.slice(1),!0))return!1}else if(cu(a,t,!0)||cu(e,t,!0))return!1}return!0}function cu(e,t,n=!1){let r=`^`;for(let e=0;e<t.length;e++){let n=t[e];if(n===`*`)t[e+1]===`*`?(r+=`.*`,e++):r+=`[^/]*`;else if(n===`?`)r+=`[^/]`;else if(n===`[`){let n=e+1;for(n<t.length&&t[n]===`!`&&n++,n<t.length&&t[n]===`]`&&n++;n<t.length&&t[n]!==`]`;)n++;if(n<t.length){let i=t.slice(e,n+1);i.startsWith(`[!`)&&(i=`[^${i.slice(2)}`),r+=i,e=n}else r+=`\\[`}else r+=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}return r+=`$`,U(r,n?`i`:``).test(e)}async function lu(e,t,n){let r=null;n.noIgnore||(r=await ql(e.fs,e.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let i=new wl;for(let e of n.typeClear)i.clearType(e);for(let e of n.typeAdd)i.addType(e);let{files:a}=await au(e,t.length===0?[`.`]:t,n,r,i);if(a.length===0)return{stdout:``,stderr:``,exitCode:1};if(n.quiet)return{stdout:``,stderr:``,exitCode:0};let o=n.nullSeparator?`\0`:`
285
+ `,s=new Ui(Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),`rg`);for(let e of a)s.append(e).append(o);return{stdout:s.build(),stderr:``,exitCode:0}}function uu(e,t){if(t.length===0)return!0;for(let n of t)if(cu(e,n,!1))return!0;return!1}async function du(e,t,n,r){let i;try{if(r.preprocessor&&e.exec&&uu(n.split(`/`).pop()||n,r.preprocessorGlobs)){let n=await e.exec(Gl([r.preprocessor]),{cwd:e.cwd,signal:e.signal,args:[t]});if(n.exitCode===0&&n.stdout){i=e.executionScope?.reserveBytes(`rg preprocessor text`,n.stdout.length,`rg preprocessor`);let t=or(n.stdout);return e.executionScope?.consumeInput(O(t),`rg preprocessor`),{content:t,isBinary:t.slice(0,8192).includes(`\0`),lease:i}}}if(r.searchZip&&n.endsWith(`.gz`)){let n=await e.fs.stat(t),r=e.executionScope?.reserveBytes(`rg compressed input`,n.size,`rg`),i=await e.fs.readFileBuffer(t);if(i.byteLength>n.size)throw r?.release(),new A(`rg: file grew while being read`,`string_length`);if(e.executionScope?.consumeInput(i.byteLength,`rg`),Zl(i)){let t;try{let n=Math.min(e.limits.maxStringLength,e.limits.maxOutputSize,Math.floor((e.executionScope?.remainingLiveBytes??e.limits.maxLiveBytes)/2));t=e.executionScope?.reserveBytes(`rg decompressed text`,n*2,`rg`);let a=lt(i,{maxOutputLength:n}),o=new TextDecoder().decode(a);return{content:o,isBinary:o.slice(0,8192).includes(`\0`),lease:fu(r,t)}}catch(e){return t?.release(),r?.release(),Ur(e),null}}r?.release()}let a=await e.fs.stat(t);i=e.executionScope?.reserveBytes(`rg file text`,a.size*2,`rg`);let o=await lr(e.fs,t),s=o.length;if(s>a.size)throw new A(`rg: file grew while being read`,`string_length`);e.executionScope?.consumeInput(s,`rg`);let c=or(o,e.limits.maxStringLength);return{content:c,isBinary:c.slice(0,8192).includes(`\0`),lease:i}}catch(e){return i?.release(),Ur(e),null}}function fu(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return{release:()=>{for(let e of t)e.release()}}}async function pu(e,t,n,r,i,a,o){let s=``,c=!1,l=[],u=0,d=0,f=0,p=r.searchZip?2:50;e:for(let m=0;m<t.length;m+=p){let h=t.slice(m,m+p),g=await Promise.all(h.map(async t=>{let s=await du(e,e.fs.resolvePath(e.cwd,t),t,r);if(!s)return null;let{content:c,isBinary:l,lease:u}=s;if(f+=c.length,l&&!r.searchBinary)return u?.release(),null;let d=i&&!r.heading?t:``;try{let i=Sc(c,n,{invertMatch:r.invertMatch,showLineNumbers:a,countOnly:r.count,countMatches:r.countMatches,filename:d,onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace===null?null:zc(r.replace),passthru:r.passthru,multiline:r.multiline,kResetGroup:o,maxWork:e.limits.maxLoopIterations,maxMatches:e.limits.maxArrayElements,signal:e.signal});return r.json&&i.matched?{file:t,result:i,content:c,isBinary:!1,lease:u}:(u?.release(),{file:t,result:i})}catch(e){throw u?.release(),e}}));for(let e of g){if(!e)continue;let{file:t,result:i}=e;if(i.matched){if(c=!0,d++,u+=i.matchCount,r.quiet&&!r.json)break e;if(r.json&&!r.quiet){let a=e.content||``;l.push(JSON.stringify({type:`begin`,data:{path:{text:t}}}));let o=a.split(`
286
+ `);n.lastIndex=0;let s=0;for(let e=0;e<o.length;e++){let i=o[e];n.lastIndex=0;let a=[];for(let e=n.exec(i);e!==null;e=n.exec(i)){let t={match:{text:e[0]},start:e.index,end:e.index+e[0].length};r.replace!==null&&(t.replacement={text:r.replace}),a.push(t),e[0].length===0&&n.lastIndex++}if(a.length>0){let n={type:`match`,data:{path:{text:t},lines:{text:`${i}
287
+ `},line_number:e+1,absolute_offset:s,submatches:a}};l.push(JSON.stringify(n))}s+=i.length+1}l.push(JSON.stringify({type:`end`,data:{path:{text:t},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:`0s`},searches:1,searches_with_match:1,bytes_searched:a.length,bytes_printed:0,matched_lines:i.matchCount,matches:i.matchCount}}}))}else if(r.filesWithMatches){let e=r.nullSeparator?`\0`:`
288
+ `;s+=`${t}${e}`}else r.filesWithoutMatch||(r.heading&&!r.noFilename&&(s+=`${t}
289
+ `),s+=i.output)}else if(r.filesWithoutMatch){let e=r.nullSeparator?`\0`:`
290
+ `;s+=`${t}${e}`}else r.includeZero&&(r.count||r.countMatches)&&(s+=i.output);e.lease?.release()}}r.json&&(l.push(JSON.stringify({type:`summary`,data:{elapsed_total:{secs:0,nanos:0,human:`0s`},stats:{elapsed:{secs:0,nanos:0,human:`0s`},searches:t.length,searches_with_match:d,bytes_searched:f,bytes_printed:0,matched_lines:u,matches:u}}})),s=`${l.join(`
291
+ `)}
292
+ `);let m=r.quiet&&!r.json?``:s;if(r.stats&&!r.json){let e=[``,`${u} matches`,`${u} matched lines`,`${d} files contained matches`,`${t.length} files searched`,`${f} bytes searched`].join(`
293
+ `);m+=`${e}
294
+ `}let h;return h=r.filesWithoutMatch?s.length>0?0:1:+!c,{stdout:m,stderr:``,exitCode:h}}var mu=T(()=>{Wi(),k(),Wr(),la(),Kl(),j(),mc(),Uc(),Tl(),Xl()}),hu={};E(hu,{flagsForFuzzing:()=>vu,rgCommand:()=>_u});var gu,_u,vu,yu=T(()=>{F(),Tl(),Ul(),mu(),gu={name:`rg`,summary:`recursively search for a pattern`,usage:`rg [OPTIONS] PATTERN [PATH ...]`,description:`rg (ripgrep) recursively searches directories for a regex pattern.
295
+ Unlike grep, rg is recursive by default and respects .gitignore files.
296
+
297
+ EXAMPLES:
298
+ rg foo Search for 'foo' in current directory
299
+ rg foo src/ Search in src/ directory
300
+ rg -i foo Case-insensitive search
301
+ rg -w foo Match whole words only
302
+ rg -t js foo Search only JavaScript files
303
+ rg -g '*.ts' foo Search files matching glob
304
+ rg --hidden foo Include hidden files
305
+ rg -l foo List files with matches only`,options:[`-e, --regexp PATTERN search for PATTERN (can be used multiple times)`,`-f, --file FILE read patterns from FILE, one per line`,`-i, --ignore-case case-insensitive search`,`-s, --case-sensitive case-sensitive search (overrides smart-case)`,`-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)`,`-F, --fixed-strings treat pattern as literal string`,`-w, --word-regexp match whole words only`,`-x, --line-regexp match whole lines only`,`-v, --invert-match select non-matching lines`,`-r, --replace TEXT replace matches with TEXT`,`-c, --count print count of matching lines per file`,` --count-matches print count of individual matches per file`,`-l, --files-with-matches print only file names with matches`,` --files-without-match print file names without matches`,` --files list files that would be searched`,`-o, --only-matching print only matching parts`,`-m, --max-count NUM stop after NUM matches per file`,`-q, --quiet suppress output, exit 0 on match`,` --stats print search statistics`,`-n, --line-number print line numbers (default: on)`,`-N, --no-line-number do not print line numbers`,`-I, --no-filename suppress the prefixing of file names`,`-0, --null use NUL as filename separator`,`-b, --byte-offset show byte offset of each match`,` --column show column number of first match`,` --vimgrep show results in vimgrep format`,` --json show results in JSON Lines format`,`-A NUM print NUM lines after each match`,`-B NUM print NUM lines before each match`,`-C NUM print NUM lines before and after each match`,` --context-separator SEP separator for context groups (default: --)`,`-U, --multiline match patterns across lines`,`-z, --search-zip search in compressed files (gzip only)`,`-g, --glob GLOB include files matching GLOB`,`-t, --type TYPE only search files of TYPE (e.g., js, py, ts)`,`-T, --type-not TYPE exclude files of TYPE`,`-L, --follow follow symbolic links`,`-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)`,`-a, --text search binary files as text`,` --hidden search hidden files and directories`,` --no-ignore don't respect .gitignore/.ignore files`,`-d, --max-depth NUM maximum search depth`,` --sort TYPE sort files (path, none)`,` --heading show file path above matches`,` --passthru print all lines (non-matches use - separator)`,` --include-zero include files with 0 matches in count output`,` --type-list list all available file types`,` --help display this help and exit`]},_u={name:`rg`,async execute(e,t){if(N(e))return M(gu);if(e.includes(`--type-list`))return{stdout:Sl(),stderr:``,exitCode:0};let n=zl(e);return n.success?nu({ctx:t,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}},vu={name:`rg`,flags:[{flag:`-i`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`-F`,type:`boolean`},{flag:`-w`,type:`boolean`},{flag:`-x`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-o`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-N`,type:`boolean`},{flag:`--hidden`,type:`boolean`},{flag:`--no-ignore`,type:`boolean`},{flag:`-m`,type:`value`,valueHint:`number`},{flag:`-A`,type:`value`,valueHint:`number`},{flag:`-B`,type:`value`,valueHint:`number`},{flag:`-C`,type:`value`,valueHint:`number`},{flag:`-g`,type:`value`,valueHint:`pattern`},{flag:`-t`,type:`value`,valueHint:`string`},{flag:`-T`,type:`value`,valueHint:`string`}],needsArgs:!0}});function bu(e,t,n){if(!e||Kn.isInSandboxedContext())return;let r=`${t} ${n} attempted outside defense context`;throw new D(r,{timestamp:Date.now(),type:`missing_defense_context`,message:r,path:`DefenseInDepthBox.context`,stack:Error().stack,executionId:Kn.getCurrentExecutionId()})}async function xu(e,t,n,r){bu(e,t,`${n} (pre-await)`);let i=await r();return bu(e,t,`${n} (post-await)`),i}var Su=T(()=>{qn()});function Cu(e){let t=``,n=0,r=!1;for(;n<e.length;){if(e[n]===`[`&&!r){if(e[n+1]===`[`&&e[n+2]===`:`){let r=e.indexOf(`:]]`,n+3);if(r!==-1){let i=e.slice(n+3,r),a=Eu.get(i);if(a){t+=`[${a}]`,n=r+3;continue}}}if(e[n+1]===`^`&&e[n+2]===`[`&&e[n+3]===`:`){let r=e.indexOf(`:]]`,n+4);if(r!==-1){let i=e.slice(n+4,r),a=Eu.get(i);if(a){t+=`[^${a}]`,n=r+3;continue}}}t+=`[`,n++,r=!0,n<e.length&&e[n]===`^`&&(t+=`^`,n++),n<e.length&&e[n]===`]`&&(t+=`\\]`,n++);continue}if(r){if(e[n]===`]`){t+=`]`,n++,r=!1;continue}if(e[n]===`[`&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r),a=Eu.get(i);if(a){t+=a,n=r+2;continue}}}if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++;continue}if(e[n]===`\\`&&n+1<e.length){let r=e[n+1];if(r===`+`||r===`?`||r===`|`){t+=r,n+=2;continue}if(r===`(`||r===`)`){t+=r,n+=2;continue}if(r===`{`||r===`}`){t+=r,n+=2;continue}if(r===`t`){t+=` `,n+=2;continue}if(r===`n`){t+=`
306
+ `,n+=2;continue}if(r===`r`){t+=`\r`,n+=2;continue}t+=e[n]+r,n+=2;continue}if(e[n]===`+`||e[n]===`?`||e[n]===`|`||e[n]===`(`||e[n]===`)`){t+=`\\${e[n]}`,n++;continue}if(e[n]===`^`&&!(t===``||t.endsWith(`(`))){t+=`\\^`,n++;continue}if(e[n]===`$`){let r=n===e.length-1,i=n+2<e.length&&e[n+1]===`\\`&&e[n+2]===`)`;if(!r&&!i){t+=`\\$`,n++;continue}}t+=e[n],n++}return t}function wu(e){let t=``,n=!1;for(let r=0;r<e.length;r++)e[r]===`[`&&!n?(n=!0,t+=`[`,r++,r<e.length&&e[r]===`^`&&(t+=`^`,r++),r<e.length&&e[r]===`]`&&(t+=`]`,r++),r--):e[r]===`]`&&n?(n=!1,t+=`]`):!n&&e[r]===`{`&&e[r+1]===`,`?(t+=`{0,`,r++):t+=e[r];return t}function Tu(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=r.charCodeAt(0);t+=r===`\\`?`\\\\`:r===` `?`\\t`:r===`
307
+ `?`$
308
+ `:r===`\r`?`\\r`:r===`\x07`?`\\a`:r===`\b`?`\\b`:r===`\f`?`\\f`:r===`\v`?`\\v`:i<32||i>=127?`\\${i.toString(8).padStart(3,`0`)}`:r}return`${t}$`}var Eu,Du=T(()=>{Eu=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9A-Fa-f`]])});function Ou(e,t,n){return{patternSpace:``,holdSpace:``,lineNumber:0,totalLines:e,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,errorMessage:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],nCommandOutput:[],restartCycle:!1,inDRestartedCycle:!1,currentFilename:t,pendingFileReads:[],pendingFileWrites:[],rangeStates:n||new Map,linesConsumedInCycle:0}}function ku(e){return typeof e==`object`&&`first`in e&&`step`in e}function Au(e){return typeof e==`object`&&`offset`in e}function ju(e,t,n,r,i){if(e===`$`)return t===n;if(typeof e==`number`)return t===e;if(ku(e)){let{first:n,step:r}=e;return r===0?t===n:(t-n)%r===0&&t>=n}if(typeof e==`object`&&`pattern`in e)try{let t=e.pattern;return t===``&&i?.lastPattern?t=i.lastPattern:t!==``&&i&&(i.lastPattern=t),U(wu(Cu(t))).test(r)}catch{return!1}return!1}function Mu(e){let t=e=>e===void 0?`undefined`:e===`$`?`$`:typeof e==`number`?String(e):`pattern`in e?`/${e.pattern}/`:`first`in e?`${e.first}~${e.step}`:`unknown`;return`${t(e.start)},${t(e.end)}`}function Nu(e,t,n,r,i,a){if(!e||!e.start&&!e.end)return!0;let o=e.start,s=e.end;if(o!==void 0&&s===void 0)return ju(o,t,n,r,a);if(o!==void 0&&s!==void 0){let c=typeof o==`object`&&`pattern`in o,l=typeof s==`object`&&`pattern`in s,u=Au(s);if(u&&i){let c=Mu(e),l=i.get(c);return l||(l={active:!1},i.set(c,l)),l.active?(t>=(l.startLine||t)+s.offset&&(l.active=!1,i.set(c,l)),!0):ju(o,t,n,r,a)?(l.active=!0,l.startLine=t,i.set(c,l),s.offset===0&&(l.active=!1,i.set(c,l)),!0):!1}if(!c&&!l&&!u){let r=typeof o==`number`?o:o===`$`?n:1,a=typeof s==`number`?s:n;if(r<=a)return t>=r&&t<=a;if(i){let n=Mu(e),a=i.get(n);return a||(a={active:!1},i.set(n,a)),!a.completed&&t>=r&&(a.completed=!0,i.set(n,a),!0)}return!1}if(i){let c=Mu(e),l=i.get(c);if(l||(l={active:!1},i.set(c,l)),l.active)return ju(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0;{if(l.completed)return!1;let e=!1;return e=typeof o==`number`?t>=o:ju(o,t,n,r,a),e?(l.active=!0,l.startLine=t,i.set(c,l),ju(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0):!1}}return ju(o,t,n,r,a)}return!0}function Pu(e,t,n,r,i,a){let o=Nu(e,t,n,r,i,a);return e?.negated?!o:o}function Fu(e,t,n,r){let i=``,a=0,o=!1;for(;a<=e.length;){t.lastIndex=a;let n=t.exec(e);if(!n){i+=e.slice(a);break}if(n.index!==a){i+=e.slice(a,n.index),a=n.index,o=!1;continue}let s=n[0],c=n.slice(1);if(o&&s.length===0){if(a<e.length)i+=e[a],a++;else break;o=!1;continue}if(i+=r(s,c),o=!1,s.length===0)if(a<e.length)i+=e[a],a++;else break;else a+=s.length,o=!0}return i}function Iu(e,t,n){let r=``,i=0;for(;i<e.length;){if(e[i]===`\\`&&i+1<e.length){let a=e[i+1];if(a===`&`){r+=`&`,i+=2;continue}if(a===`n`){r+=`
309
+ `,i+=2;continue}if(a===`t`){r+=` `,i+=2;continue}if(a===`r`){r+=`\r`,i+=2;continue}let o=parseInt(a,10);if(o===0){r+=t,i+=2;continue}if(o>=1&&o<=9){r+=n[o-1]||``,i+=2;continue}r+=a,i+=2;continue}if(e[i]===`&`){r+=t,i++;continue}r+=e[i],i++}return r}function Lu(e,t,n){if(t>0&&e.length>t)throw new A(`sed: ${n} size limit exceeded (${t} bytes)`,`string_length`)}function Ru(e,t,n){let{lineNumber:r,totalLines:i,patternSpace:a}=t;if(e.type===`label`){t.coverage?.hit(`sed:cmd:${e.type}`);return}if(Pu(e.address,r,i,a,t.rangeStates,t))switch(t.coverage?.hit(`sed:cmd:${e.type}`),e.type){case`substitute`:{let n=e,r=``;n.global&&(r+=`g`),n.ignoreCase&&(r+=`i`);let i=n.pattern;i===``&&t.lastPattern?i=t.lastPattern:i!==``&&(t.lastPattern=i);let a=wu(n.extendedRegex?i:Cu(i));try{let e=U(a,r),i=e.test(t.patternSpace);if(e.lastIndex=0,i){if(t.substitutionMade=!0,n.nthOccurrence&&n.nthOccurrence>0&&!n.global){let e=0,r=n.nthOccurrence;t.patternSpace=U(a,`g${n.ignoreCase?`i`:``}`).replace(t.patternSpace,(t,...i)=>{if(e++,e===r){let e=i.slice(0,-2);return Iu(n.replacement,t,e)}return t})}else if(n.global){let e=U(a,`g${n.ignoreCase?`i`:``}`);t.patternSpace=Fu(t.patternSpace,e,n.replacement,(e,t)=>Iu(n.replacement,e,t))}else t.patternSpace=e.replace(t.patternSpace,(e,...t)=>{let r=t.slice(0,-2);return Iu(n.replacement,e,r)});n.printOnMatch&&t.lineNumberOutput.push(t.patternSpace)}}catch{}break}case`print`:t.lineNumberOutput.push(t.patternSpace);break;case`printFirstLine`:{let e=t.patternSpace.indexOf(`
310
+ `);e===-1?t.lineNumberOutput.push(t.patternSpace):t.lineNumberOutput.push(t.patternSpace.slice(0,e));break}case`delete`:t.deleted=!0;break;case`deleteFirstLine`:{let e=t.patternSpace.indexOf(`
311
+ `);e===-1?t.deleted=!0:(t.patternSpace=t.patternSpace.slice(e+1),t.restartCycle=!0,t.inDRestartedCycle=!0);break}case`zap`:t.patternSpace=``;break;case`append`:t.appendBuffer.push(e.text);break;case`insert`:t.appendBuffer.unshift(`__INSERT__${e.text}`);break;case`change`:t.deleted=!0,t.changedText=e.text;break;case`hold`:t.holdSpace=t.patternSpace;break;case`holdAppend`:t.holdSpace?t.holdSpace+=`
312
+ ${t.patternSpace}`:t.holdSpace=t.patternSpace,Lu(t.holdSpace,n?.maxStringLength??0,`hold space`);break;case`get`:t.patternSpace=t.holdSpace;break;case`getAppend`:t.patternSpace+=`
313
+ ${t.holdSpace}`,Lu(t.patternSpace,n?.maxStringLength??0,`pattern space`);break;case`exchange`:{let e=t.patternSpace;t.patternSpace=t.holdSpace,t.holdSpace=e;break}case`next`:t.printed=!0;break;case`quit`:t.quit=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case`quitSilent`:t.quit=!0,t.quitSilent=!0,e.exitCode!==void 0&&(t.exitCode=e.exitCode);break;case`list`:{let e=Tu(t.patternSpace);t.lineNumberOutput.push(e);break}case`printFilename`:t.currentFilename&&t.lineNumberOutput.push(t.currentFilename);break;case`version`:{let n=[4,8,0];if(e.minVersion){let r=e.minVersion.split(`.`),i=[],a=!1;for(let n of r){let r=parseInt(n,10);if(Number.isNaN(r)||r<0){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: invalid version string: ${e.minVersion}`,a=!0;break}i.push(r)}if(!a){for(;i.length<3;)i.push(0);for(let r=0;r<3;r++){if(i[r]>n[r]){t.quit=!0,t.exitCode=1,t.errorMessage=`sed: this is not GNU sed version ${e.minVersion}`;break}if(i[r]<n[r])break}}}break}case`readFile`:t.pendingFileReads.push({filename:e.filename,wholeFile:!0});break;case`readFileLine`:t.pendingFileReads.push({filename:e.filename,wholeFile:!1});break;case`writeFile`:t.pendingFileWrites.push({filename:e.filename,content:`${t.patternSpace}
314
+ `});break;case`writeFirstLine`:{let n=t.patternSpace.indexOf(`
315
+ `),r=n===-1?t.patternSpace:t.patternSpace.slice(0,n);t.pendingFileWrites.push({filename:e.filename,content:`${r}
316
+ `});break}case`execute`:t.errorMessage=`sed: e command (shell execution) is not supported in sandboxed environment`,t.quit=!0;break;case`transliterate`:t.patternSpace=zu(t.patternSpace,e);break;case`lineNumber`:t.lineNumberOutput.push(String(t.lineNumber));break;case`branch`:break;case`branchOnSubst`:break;case`branchOnNoSubst`:break;case`group`:break}}function zu(e,t){let n=``;for(let r of e){let e=t.source.indexOf(r);n+=e===-1?r:t.dest[e]}return n}function Bu(e,t,n,r){let i=new Map;for(let t=0;t<e.length;t++){let n=e[t];n.type===`label`&&i.set(n.name,t)}let a=r?.maxIterations??Vu,o=0,s=0;for(;s<e.length;){if(o++,o>a)throw new A(`sed: command execution exceeded maximum iterations (${a})`,`iterations`);if(t.deleted||t.quit||t.quitSilent||t.restartCycle)break;let c=e[s];if(c.type===`next`){if(Pu(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t))if(t.coverage?.hit(`sed:cmd:next`),t.nCommandOutput.push(t.patternSpace),n&&n.currentLineIndex+t.linesConsumedInCycle+1<n.lines.length)t.linesConsumedInCycle++,t.patternSpace=n.lines[n.currentLineIndex+t.linesConsumedInCycle],t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1,t.substitutionMade=!1;else{t.quit=!0,t.deleted=!0;break}s++;continue}if(c.type===`nextAppend`){if(Pu(c.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t))if(t.coverage?.hit(`sed:cmd:nextAppend`),n&&n.currentLineIndex+t.linesConsumedInCycle+1<n.lines.length){t.linesConsumedInCycle++;let e=n.lines[n.currentLineIndex+t.linesConsumedInCycle];t.patternSpace+=`
317
+ ${e}`,t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1}else{t.quit=!0;break}s++;continue}if(c.type===`branch`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)){if(t.coverage?.hit(`sed:cmd:branch`),e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`branchOnSubst`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:branchOnSubst`),t.substitutionMade)){if(t.substitutionMade=!1,e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`branchOnNoSubst`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:branchOnNoSubst`),!t.substitutionMade)){if(e.label){let n=i.get(e.label);if(n!==void 0){s=n;continue}t.branchRequest=e.label;break}break}s++;continue}if(c.type===`group`){let e=c;if(Pu(e.address,t.lineNumber,t.totalLines,t.patternSpace,t.rangeStates,t)&&(t.coverage?.hit(`sed:cmd:group`),Bu(e.commands,t,n,r),t.branchRequest)){let e=i.get(t.branchRequest);if(e!==void 0){t.branchRequest=void 0,s=e;continue}break}s++;continue}Ru(c,t,r),s++}return t.linesConsumedInCycle}var Vu,Hu=T(()=>{j(),mc(),Du(),Vu=1e4}),W,Uu,Wu=T(()=>{j(),(function(e){e.NUMBER=`NUMBER`,e.DOLLAR=`DOLLAR`,e.PATTERN=`PATTERN`,e.STEP=`STEP`,e.RELATIVE_OFFSET=`RELATIVE_OFFSET`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.COMMA=`COMMA`,e.NEGATION=`NEGATION`,e.COMMAND=`COMMAND`,e.SUBSTITUTE=`SUBSTITUTE`,e.TRANSLITERATE=`TRANSLITERATE`,e.LABEL_DEF=`LABEL_DEF`,e.BRANCH=`BRANCH`,e.BRANCH_ON_SUBST=`BRANCH_ON_SUBST`,e.BRANCH_ON_NO_SUBST=`BRANCH_ON_NO_SUBST`,e.TEXT_CMD=`TEXT_CMD`,e.FILE_READ=`FILE_READ`,e.FILE_READ_LINE=`FILE_READ_LINE`,e.FILE_WRITE=`FILE_WRITE`,e.FILE_WRITE_LINE=`FILE_WRITE_LINE`,e.EXECUTE=`EXECUTE`,e.VERSION=`VERSION`,e.EOF=`EOF`,e.ERROR=`ERROR`})(W||={}),Uu=class{maxInputLength;maxTokens;input;pos=0;line=1;column=1;constructor(e,t=1048576,n=1e5){this.maxInputLength=t,this.maxTokens=n,this.input=e}tokenize(){if(this.input.length>this.maxInputLength)throw new A(`sed: script size limit exceeded (${this.maxInputLength} bytes)`,`string_length`);let e=[];for(;this.pos<this.input.length;){let t=this.nextToken();if(t){if(e.length>=this.maxTokens-1)throw new A(`sed: token limit exceeded (${this.maxTokens})`,`array_elements`);e.push(t)}}return e.push(this.makeToken(W.EOF,``)),e}makeToken(e,t,n){return{type:e,value:t,line:this.line,column:this.column,...n}}peek(e=0){return this.input[this.pos+e]||``}advance(){let e=this.input[this.pos++]||``;return e===`
318
+ `?(this.line++,this.column=1):this.column++,e}readEscapedString(e){let t=``;for(;this.pos<this.input.length&&this.peek()!==e;)if(this.peek()===`\\`){this.advance();let e=this.advance();t+=e===`n`?`
319
+ `:e===`t`?` `:e}else{if(this.peek()===`
320
+ `)return null;t+=this.advance()}return t}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===` `||e===` `||e===`\r`)this.advance();else if(e===`#`)for(;this.pos<this.input.length&&this.peek()!==`
321
+ `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,t=this.column,n=this.peek();return n===`
322
+ `?(this.advance(),{type:W.NEWLINE,value:`
323
+ `,line:e,column:t}):n===`;`?(this.advance(),{type:W.SEMICOLON,value:`;`,line:e,column:t}):n===`{`?(this.advance(),{type:W.LBRACE,value:`{`,line:e,column:t}):n===`}`?(this.advance(),{type:W.RBRACE,value:`}`,line:e,column:t}):n===`,`?(this.advance(),{type:W.COMMA,value:`,`,line:e,column:t}):n===`!`?(this.advance(),{type:W.NEGATION,value:`!`,line:e,column:t}):n===`$`?(this.advance(),{type:W.DOLLAR,value:`$`,line:e,column:t}):this.isDigit(n)?this.readNumber():n===`+`&&this.isDigit(this.input[this.pos+1]||``)?this.readRelativeOffset():n===`/`?this.readPattern():n===`:`?this.readLabelDef():this.readCommand()}readNumber(){let e=this.line,t=this.column,n=``;for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()===`~`){this.advance();let r=``;for(;this.isDigit(this.peek());)r+=this.advance();let i=parseInt(n,10),a=parseInt(r,10)||0;return{type:W.STEP,value:`${i}~${a}`,first:i,step:a,line:e,column:t}}return{type:W.NUMBER,value:parseInt(n,10),line:e,column:t}}readRelativeOffset(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.isDigit(this.peek());)n+=this.advance();let r=parseInt(n,10)||0;return{type:W.RELATIVE_OFFSET,value:`+${r}`,offset:r,line:e,column:t}}readPattern(){let e=this.line,t=this.column;this.advance();let n=``,r=!1;for(;this.pos<this.input.length;){let e=this.peek();if(e===`/`&&!r)break;if(e===`\\`)n+=this.advance(),this.pos<this.input.length&&this.peek()!==`
324
+ `&&(n+=this.advance());else{if(e===`
325
+ `)break;e===`[`&&!r?(r=!0,n+=this.advance(),this.peek()===`^`&&(n+=this.advance()),this.peek()===`]`&&(n+=this.advance())):(e===`]`&&r&&(r=!1),n+=this.advance())}}return this.peek()===`/`&&this.advance(),{type:W.PATTERN,value:n,pattern:n,line:e,column:t}}readLabelDef(){let e=this.line,t=this.column;for(this.advance();this.peek()===` `||this.peek()===` `;)this.advance();let n=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===` `||e===` `||e===`
326
+ `||e===`;`||e===`}`||e===`{`)break;n+=this.advance()}return{type:W.LABEL_DEF,value:n,label:n,line:e,column:t}}readCommand(){let e=this.line,t=this.column,n=this.advance();switch(n){case`s`:return this.readSubstitute(e,t);case`y`:return this.readTransliterate(e,t);case`a`:case`i`:case`c`:return this.readTextCommand(n,e,t);case`b`:return this.readBranch(W.BRANCH,`b`,e,t);case`t`:return this.readBranch(W.BRANCH_ON_SUBST,`t`,e,t);case`T`:return this.readBranch(W.BRANCH_ON_NO_SUBST,`T`,e,t);case`r`:return this.readFileCommand(W.FILE_READ,`r`,e,t);case`R`:return this.readFileCommand(W.FILE_READ_LINE,`R`,e,t);case`w`:return this.readFileCommand(W.FILE_WRITE,`w`,e,t);case`W`:return this.readFileCommand(W.FILE_WRITE_LINE,`W`,e,t);case`e`:return this.readExecute(e,t);case`p`:case`P`:case`d`:case`D`:case`h`:case`H`:case`g`:case`G`:case`x`:case`n`:case`N`:case`q`:case`Q`:case`z`:case`=`:case`l`:case`F`:return{type:W.COMMAND,value:n,line:e,column:t};case`v`:return this.readVersion(e,t);default:return{type:W.ERROR,value:n,line:e,column:t}}}readSubstitute(e,t){let n=this.advance();if(!n||n===`
327
+ `)return{type:W.ERROR,value:`s`,line:e,column:t};let r=``,i=!1;for(;this.pos<this.input.length;){let e=this.peek();if(e===n&&!i)break;if(e===`\\`)this.advance(),this.pos<this.input.length&&this.peek()!==`
328
+ `?(this.peek()===n&&!i||(r+=`\\`),r+=this.advance()):r+=`\\`;else{if(e===`
329
+ `)break;e===`[`&&!i?(i=!0,r+=this.advance(),this.peek()===`^`&&(r+=this.advance()),this.peek()===`]`&&(r+=this.advance())):(e===`]`&&i&&(i=!1),r+=this.advance())}}if(this.peek()!==n)return{type:W.ERROR,value:`unterminated substitution pattern`,line:e,column:t};this.advance();let a=``;for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()===`\\`)if(this.advance(),this.pos<this.input.length){let e=this.peek();e===`\\`?(this.advance(),this.pos<this.input.length&&this.peek()===`
330
+ `?(a+=`
331
+ `,this.advance()):a+=`\\`):e===`
332
+ `?(a+=`
333
+ `,this.advance()):a+=`\\${this.advance()}`}else a+=`\\`;else{if(this.peek()===`
334
+ `)break;a+=this.advance()}this.peek()===n&&this.advance();let o=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===`g`||e===`i`||e===`p`||e===`I`||this.isDigit(e))o+=this.advance();else break}return{type:W.SUBSTITUTE,value:`s${n}${r}${n}${a}${n}${o}`,pattern:r,replacement:a,flags:o,line:e,column:t}}readTransliterate(e,t){let n=this.advance();if(!n||n===`
335
+ `)return{type:W.ERROR,value:`y`,line:e,column:t};let r=this.readEscapedString(n);if(r===null||this.peek()!==n)return{type:W.ERROR,value:`unterminated transliteration source`,line:e,column:t};this.advance();let i=this.readEscapedString(n);if(i===null||this.peek()!==n)return{type:W.ERROR,value:`unterminated transliteration dest`,line:e,column:t};this.advance();let a=this.peek();for(;a===` `||a===` `;)this.advance(),a=this.peek();return a!==``&&a!==`;`&&a!==`
336
+ `&&a!==`}`?{type:W.ERROR,value:`extra text at the end of a transform command`,line:e,column:t}:{type:W.TRANSLITERATE,value:`y${n}${r}${n}${i}${n}`,source:r,dest:i,line:e,column:t}}readTextCommand(e,t,n){let r=!1;this.peek()===`\\`&&this.pos+1<this.input.length&&(this.input[this.pos+1]===`
337
+ `||this.input[this.pos+1]===` `||this.input[this.pos+1]===` `)&&(r=!0,this.advance()),(this.peek()===` `||this.peek()===` `)&&this.advance(),this.peek()===`\\`&&this.pos+1<this.input.length&&(this.input[this.pos+1]===` `||this.input[this.pos+1]===` `)&&this.advance(),r&&this.peek()===`
338
+ `&&this.advance();let i=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===`
339
+ `){if(i.endsWith(`\\`)){i=`${i.slice(0,-1)}
340
+ `,this.advance();continue}break}if(e===`\\`&&this.pos+1<this.input.length){let e=this.input[this.pos+1];if(e===`n`){i+=`
341
+ `,this.advance(),this.advance();continue}if(e===`t`){i+=` `,this.advance(),this.advance();continue}if(e===`r`){i+=`\r`,this.advance(),this.advance();continue}}i+=this.advance()}return{type:W.TEXT_CMD,value:e,text:i,line:t,column:n}}readBranch(e,t,n,r){for(;this.peek()===` `||this.peek()===` `;)this.advance();let i=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===` `||e===` `||e===`
342
+ `||e===`;`||e===`}`||e===`{`)break;i+=this.advance()}return{type:e,value:t,label:i||void 0,line:n,column:r}}readVersion(e,t){for(;this.peek()===` `||this.peek()===` `;)this.advance();let n=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===` `||e===` `||e===`
343
+ `||e===`;`||e===`}`||e===`{`)break;n+=this.advance()}return{type:W.VERSION,value:`v`,label:n||void 0,line:e,column:t}}readFileCommand(e,t,n,r){for(;this.peek()===` `||this.peek()===` `;)this.advance();let i=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===`
344
+ `||e===`;`)break;i+=this.advance()}return{type:e,value:t,filename:i.trim(),line:n,column:r}}readExecute(e,t){for(;this.peek()===` `||this.peek()===` `;)this.advance();let n=``;for(;this.pos<this.input.length;){let e=this.peek();if(e===`
345
+ `||e===`;`)break;n+=this.advance()}return{type:W.EXECUTE,value:`e`,command:n.trim()||void 0,line:e,column:t}}isDigit(e){return e>=`0`&&e<=`9`}}});function Gu(e,t=!1,n){if(n){if(e.length>n.maxArrayElements)throw new A(`sed: script count limit exceeded (${n.maxArrayElements})`,`array_elements`);let t=Math.max(0,e.length-1);for(let r of e)if(t+=O(r),t>n.maxStringLength)throw new A(`sed: script size limit exceeded (${n.maxStringLength} bytes)`,`string_length`)}let r=!1,i=!1,a=[];for(let t=0;t<e.length;t++){let n=e[t];if(a.length===0&&t===0){let e=n.match(/^#([nr]+)\s*(?:\n|$)/i);if(e){let t=e[1].toLowerCase();t.includes(`n`)&&(r=!0),t.includes(`r`)&&(i=!0),n=n.slice(e[0].length)}}if(a.length>0&&a[a.length-1].endsWith(`\\`)){let e=a[a.length-1];a[a.length-1]=`${e}
346
+ ${n}`}else a.push(n)}let o=a.join(`
347
+ `),s=new Yu([o],t||i,n).parse();if(!s.error&&s.commands.length>0){let e=Ku(s.commands);if(e)return{commands:[],error:e,silentMode:r,extendedRegexMode:i}}return{...s,silentMode:r,extendedRegexMode:i}}function Ku(e){let t=new Set;qu(e,t);let n=Ju(e,t);if(n)return`undefined label '${n}'`}function qu(e,t){for(let n of e)n.type===`label`?t.add(n.name):n.type===`group`&&qu(n.commands,t)}function Ju(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=Ju(n.commands,t);if(e)return e}}}var Yu,Xu=T(()=>{j(),Lr(),Wu(),Yu=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 Uu(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}}}),Zu={};E(Zu,{flagsForFuzzing:()=>td,sedCommand:()=>ed});async function Qu(e,t,n,r={}){let{limits:i,filename:a,fs:o,cwd:s,coverage:c,requireDefenseContext:l}=r;bu(l,`sed`,`processing entry`);let u=(e,t)=>xu(l,`sed`,e,t),d=e.endsWith(`
348
+ `),f=e.split(`
349
+ `);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={...Ou(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=[],Bu(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(`
350
+ `)),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}
351
+ `);let d=r.lineNumberOutput.length>0;for(let e of r.lineNumberOutput)v(`${e}
352
+ `);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}
353
+ `);let ne=!1;!r.deleted&&!r.quitSilent?n?r.printed&&(v(`${r.patternSpace}
354
+ `),ne=!0):(v(`${r.patternSpace}
355
+ `),ne=!0):r.changedText!==void 0&&(v(`${r.changedText}
356
+ `),ne=!0);for(let e of _)v(`${e}
357
+ `);if(g=(d||ne)&&_.length===0,r.quit||r.quitSilent){if(r.exitCode!==void 0&&(h=r.exitCode),r.errorMessage)return{output:``,exitCode:h||1,errorMessage:r.errorMessage};break}}if(o&&s)for(let[e,t]of C)try{await u(`flush pending file writes`,()=>o.writeFile(e,t))}catch(e){if(e instanceof D)throw e}return!d&&g&&m.endsWith(`
358
+ `)&&(m=m.slice(0,-1)),{output:m,exitCode:h}}var $u,ed,td,nd=T(()=>{k(),ea(),j(),Su(),qn(),F(),Hu(),Xu(),$u={name:`sed`,summary:`stream editor for filtering and transforming text`,usage:`sed [OPTION]... {script} [input-file]...`,options:[`-n, --quiet, --silent suppress automatic printing of pattern space`,`-e script add the script to commands to be executed`,`-f script-file read script from file`,`-i, --in-place edit files in place`,`-E, -r, --regexp-extended use extended regular expressions`,` --help display this help and exit`],description:`Commands:
359
+ s/regexp/replacement/[flags] substitute
360
+ d delete pattern space
361
+ p print pattern space
362
+ a\\ text append text after line
363
+ i\\ text insert text before line
364
+ c\\ text change (replace) line with text
365
+ h copy pattern space to hold space
366
+ H append pattern space to hold space
367
+ g copy hold space to pattern space
368
+ G append hold space to pattern space
369
+ x exchange pattern and hold spaces
370
+ n read next line into pattern space
371
+ N append next line to pattern space
372
+ y/source/dest/ transliterate characters
373
+ = print line number
374
+ l list pattern space (escape special chars)
375
+ b [label] branch to label
376
+ t [label] branch on substitution
377
+ T [label] branch if no substitution
378
+ :label define label
379
+ q quit
380
+ Q quit without printing
381
+
382
+ Addresses:
383
+ N line number
384
+ $ last line
385
+ /regexp/ lines matching regexp
386
+ N,M range from line N to M
387
+ first~step every step-th line starting at first`},ed={name:`sed`,async execute(e,t){bu(t.requireDefenseContext,`sed`,`execution entry`);let n=(e,n)=>xu(t.requireDefenseContext,`sed`,e,n);if(N(e))return M($u);let r=[],i=[],a=!1,o=!1,s=!1,c=[];for(let t=0;t<e.length;t++){let n=e[t];if(n===`-n`||n===`--quiet`||n===`--silent`)a=!0;else if(n===`-i`||n===`--in-place`)o=!0;else if(n.startsWith(`-i`))o=!0;else if(n===`-E`||n===`-r`||n===`--regexp-extended`)s=!0;else if(n===`-e`)t+1<e.length&&r.push(e[++t]);else if(n===`-f`)t+1<e.length&&i.push(e[++t]);else{if(n.startsWith(`--`))return P(`sed`,n);if(n===`-`)c.push(n);else if(n.startsWith(`-`)&&n.length>1){for(let e of n.slice(1))if(e!==`n`&&e!==`e`&&e!==`f`&&e!==`i`&&e!==`E`&&e!==`r`)return P(`sed`,`-${e}`);n.includes(`n`)&&(a=!0),n.includes(`i`)&&(o=!0),(n.includes(`E`)||n.includes(`r`))&&(s=!0),n.includes(`e`)&&!n.includes(`n`)&&!n.includes(`i`)&&t+1<e.length&&r.push(e[++t]),n.includes(`f`)&&!n.includes(`e`)&&t+1<e.length&&i.push(e[++t])}else!n.startsWith(`-`)&&r.length===0&&i.length===0?r.push(n):n.startsWith(`-`)||c.push(n)}}for(let e of i){let i=t.fs.resolvePath(t.cwd,e);try{let e=await n(`script file read`,()=>t.fs.readFile(i));for(let t of e.split(`
388
+ `)){let e=t.trim();e&&!e.startsWith(`#`)&&r.push(e)}}catch(t){if(t instanceof D)throw t;return{stdout:``,stderr:`sed: couldn't open file ${e}: No such file or directory
389
+ `,exitCode:1}}}if(r.length===0)return{stdout:``,stderr:`sed: no script specified
390
+ `,exitCode:1};let{commands:l,error:u,silentMode:d}=Gu(r,s,t.limits);if(u)return{stdout:``,stderr:`sed: ${u}
391
+ `,exitCode:1};let f=!!(a||d);if(o){if(c.length===0)return{stdout:``,stderr:`sed: -i requires at least one file argument
392
+ `,exitCode:1};for(let e of c){if(e===`-`)continue;let r=t.fs.resolvePath(t.cwd,e);try{let i=await n(`in-place input read`,()=>t.fs.readFile(r)),a=await n(`in-place processing`,()=>Qu(i,l,f,{limits:t.limits,filename:e,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));if(a.errorMessage)return{stdout:``,stderr:`${a.errorMessage}
393
+ `,exitCode:a.exitCode??1};await n(`in-place output write`,()=>t.fs.writeFile(r,a.output))}catch(t){if(t instanceof D)throw t;return t instanceof A?{stdout:``,stderr:`sed: ${$i(t.message)}
394
+ `,exitCode:A.EXIT_CODE}:{stdout:``,stderr:`sed: ${e}: No such file or directory
395
+ `,exitCode:1}}}return{stdout:``,stderr:``,exitCode:0}}let p=``;if(c.length===0){p=or(t.stdin);try{let e=await n(`stdin processing`,()=>Qu(p,l,f,{limits:t.limits,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));return{stdout:e.output,stderr:e.errorMessage?`${e.errorMessage}
396
+ `:``,exitCode:e.exitCode??0}}catch(e){if(e instanceof D)throw e;if(e instanceof A)return{stdout:``,stderr:`sed: ${$i(e.message)}
397
+ `,exitCode:A.EXIT_CODE};throw e}}let m=!1;for(let e of c){let r;if(e===`-`)m?r=``:(r=or(t.stdin),m=!0);else{let i=t.fs.resolvePath(t.cwd,e);try{r=await n(`input file read`,()=>t.fs.readFile(i))}catch(t){if(t instanceof D)throw t;return t instanceof A?{stdout:``,stderr:`sed: ${$i(t.message)}
398
+ `,exitCode:A.EXIT_CODE}:{stdout:``,stderr:`sed: ${e}: No such file or directory
399
+ `,exitCode:1}}}p.length>0&&r.length>0&&!p.endsWith(`
400
+ `)&&(p+=`
401
+ `),p+=r}try{let e=await n(`final processing`,()=>Qu(p,l,f,{limits:t.limits,filename:c.length===1?c[0]:void 0,fs:t.fs,cwd:t.cwd,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext}));return{stdout:e.output,stderr:e.errorMessage?`${e.errorMessage}
402
+ `:``,exitCode:e.exitCode??0}}catch(e){if(e instanceof D)throw e;if(e instanceof A)return{stdout:``,stderr:`sed: ${$i(e.message)}
403
+ `,exitCode:A.EXIT_CODE};throw e}}},td={name:`sed`,flags:[{flag:`-n`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-E`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-e`,type:`value`,valueHint:`string`}],stdinType:`text`,needsArgs:!0}});function rd(e){return Object.assign(Object.create(null),Object.fromEntries(e))}function id(e,t){return Object.assign(Object.create(null),Object.fromEntries(e),t)}function ad(...e){return Object.assign(Object.create(null),...e)}var od=T(()=>{});function sd(e={}){let{fieldSep:t=ud,maxIterations:n=cd,maxRecursionDepth:r=ld,maxOutputSize:i=0,maxArrayElements:a=1e5,fs:o,cwd:s,exec:c,coverage:l,requireDefenseContext:u}=e;return{FS:` `,OFS:` `,ORS:`
404
+ `,OFMT:`%.6g`,NR:0,NF:0,FNR:0,FILENAME:``,RSTART:0,RLENGTH:-1,SUBSEP:``,fields:[],line:``,vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,getlineCommandStreams:new Map,getlineFileStreams:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:r,maxOutputSize:i,maxArrayElements:a,arrayElementCount:0,recordsProcessed:0,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:``,openedFiles:new Set,fs:o,cwd:s,exec:c,coverage:l,requireDefenseContext:u}}var cd,ld,ud,dd=T(()=>{mc(),cd=1e4,ld=100,ud=new fc(/\s+/)});function fd(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:return t===0?0:e/t;case`%`:return t===0?0:e%t;case`^`:case`**`:return e**t;default:return 0}}var pd=T(()=>{});function md(e){if(typeof e==`number`)return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function hd(e){return typeof e==`string`?e:String(e)}function gd(e){return new Ui(e,`awk string`,()=>new A(`string size limit exceeded (${e} bytes)`,`string_length`))}function _d(e){return e.maxOutputSize>0?e.maxOutputSize:Jd}function vd(e,t,n,r,i){let a=gd(i),o=0,s=0,c=0;for(let i of t.matchAll(e)){let t=i.index??0;s++,a.append(e.slice(o,t)),n(s)?(a.append(r(i)),c++):a.append(i[0]),o=t+i[0].length}return a.append(e.slice(o)),{value:a.build(),replacements:c}}async function yd(e,t){if(e.type===`regex`)return e.pattern;let n=hd(await t.evalExpr(e));return n.startsWith(`/`)&&n.endsWith(`/`)&&(n=n.slice(1,-1)),n}async function bd(e,t){return e?e.type===`variable`?e.name:e.type===`field`?`$${Math.floor(md(await t.evalExpr(e.index)))}`:`$0`:`$0`}function xd(e,t){if(e===`$0`)return t.line;if(e.startsWith(`$`)){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||``}return hd(t.vars[e]??``)}function Sd(e,t,n){if(e===`$0`)n.line=t,n.fields=n.FS===` `?t.trim().split(/\s+/).filter(Boolean):n.fieldSep.split(t),n.NF=n.fields.length;else if(e.startsWith(`$`)){let r=parseInt(e.slice(1),10)-1;for(;n.fields.length<=r;)n.fields.push(``);n.fields[r]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function Cd(e,t,n){return e.length===0?t.line.length:hd(await n.evalExpr(e[0])).length}async function wd(e,t,n){if(e.length<2)return``;let r=hd(await n.evalExpr(e[0])),i=Math.floor(md(await n.evalExpr(e[1])))-1;if(e.length>=3){let t=Math.floor(md(await n.evalExpr(e[2])));return r.substr(Math.max(0,i),t)}return r.substr(Math.max(0,i))}async function Td(e,t,n){if(e.length<2)return 0;let r=hd(await n.evalExpr(e[0])),i=hd(await n.evalExpr(e[1])),a=r.indexOf(i);return a===-1?0:a+1}async function Ed(e,t,n){if(e.length<2)return 0;let r=hd(await n.evalExpr(e[0])),i=e[1];if(i.type!==`variable`)return 0;let a=i.name,o=t.FS;if(e.length>=3){let t=e[2];if(t.type===`regex`)o=U(t.pattern);else{let e=hd(await n.evalExpr(t));o=e===` `?U(`\\s+`):e}}else t.FS===` `&&(o=U(`\\s+`));let s=Object.keys(t.arrays[a]??{}).length,c=t.maxArrayElements-t.arrayElementCount+s,l=typeof o==`string`?r.split(o,c+1):o.split(r,c+1);if(l.length>c)throw new A(`array element limit exceeded (${t.maxArrayElements})`,`array_elements`);t.arrays[a]=Object.create(null);for(let e=0;e<l.length;e++)t.arrays[a][String(e+1)]=l[e];return t.arrayElementCount+=l.length-s,l.length}async function Dd(e,t,n){if(e.length<2)return 0;let r=await yd(e[0],n),i=hd(await n.evalExpr(e[1])),a=await bd(e[2],n),o=xd(a,t);try{let e=vd(o,U(r,`g`),e=>e===1,e=>kd(i,e[0],_d(t)),_d(t));return Sd(a,e.value,t),e.replacements}catch(e){return Ur(e),0}}async function Od(e,t,n){if(e.length<2)return 0;let r=await yd(e[0],n),i=hd(await n.evalExpr(e[1])),a=await bd(e[2],n),o=xd(a,t);try{let e=vd(o,U(r,`g`),()=>!0,e=>kd(i,e[0],_d(t)),_d(t));return Sd(a,e.value,t),e.replacements}catch(e){return Ur(e),0}}function kd(e,t,n){let r=gd(n),i=0;for(;i<e.length;)if(e[i]===`\\`&&i+1<e.length){let t=e[i+1];t===`&`?(r.append(`&`),i+=2):t===`\\`?(r.append(`\\`),i+=2):(r.append(e[i+1]),i+=2)}else e[i]===`&`?(r.append(t),i++):(r.append(e[i]),i++);return r.build()}async function Ad(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let r=hd(await n.evalExpr(e[0])),i=await yd(e[1],n);try{let e=U(i).exec(r);if(e)return t.RSTART=e.index+1,t.RLENGTH=e[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function jd(e,t,n){if(e.length<3)return``;let r=await yd(e[0],n),i=hd(await n.evalExpr(e[1])),a=hd(await n.evalExpr(e[2])),o=e.length>=4?hd(await n.evalExpr(e[3])):t.line;try{let e=a.toLowerCase()===`g`,n=e?0:parseInt(a,10)||1;return e?vd(o,U(r,`g`),()=>!0,e=>Md(i,e[0],e.slice(1),_d(t)),_d(t)).value:vd(o,U(r,`g`),e=>e===n,e=>Md(i,e[0],e.slice(1),_d(t)),_d(t)).value}catch(e){return Ur(e),o}}function Md(e,t,n,r){let i=gd(r),a=0;for(;a<e.length;)if(e[a]===`\\`&&a+1<e.length){let r=e[a+1];if(r===`&`)i.append(`&`),a+=2;else if(r===`0`)i.append(t),a+=2;else if(r>=`1`&&r<=`9`){let e=parseInt(r,10)-1;i.append(n[e]||``),a+=2}else r===`n`?(i.append(`
405
+ `),a+=2):r===`t`?(i.append(` `),a+=2):(i.append(r),a+=2)}else e[a]===`&`?(i.append(t),a++):(i.append(e[a]),a++);return i.build()}async function Nd(e,t,n){return e.length===0?``:hd(await n.evalExpr(e[0])).toLowerCase()}async function Pd(e,t,n){return e.length===0?``:hd(await n.evalExpr(e[0])).toUpperCase()}async function Fd(e,t,n){if(e.length===0)return``;let r=hd(await n.evalExpr(e[0])),i=[];for(let t=1;t<e.length;t++)i.push(await n.evalExpr(e[t]));return qd(r,i,_d(t))}async function Id(e,t,n){return e.length===0?0:Math.floor(md(await n.evalExpr(e[0])))}async function Ld(e,t,n){return e.length===0?0:Math.sqrt(md(await n.evalExpr(e[0])))}async function Rd(e,t,n){return e.length===0?0:Math.sin(md(await n.evalExpr(e[0])))}async function zd(e,t,n){return e.length===0?0:Math.cos(md(await n.evalExpr(e[0])))}async function Bd(e,t,n){let r=e.length>0?md(await n.evalExpr(e[0])):0,i=e.length>1?md(await n.evalExpr(e[1])):0;return Math.atan2(r,i)}async function Vd(e,t,n){return e.length===0?0:Math.log(md(await n.evalExpr(e[0])))}async function Hd(e,t,n){return e.length===0?1:Math.exp(md(await n.evalExpr(e[0])))}function Ud(e,t,n){return t.random?t.random():Math.random()}async function Wd(e,t,n){let r=e.length>0?md(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=r,r}function Gd(e,t){return()=>{throw Error(`${e}() is not supported - ${t}`)}}function Kd(e){return()=>{throw Error(`function '${e}()' is not implemented`)}}function qd(e,t,n=Jd){let r=0,i=``,a=0,o=0,s=Math.min(Yd,n),c=e=>{let t=O(e);if(t>n-a)throw new A(`formatted string size limit exceeded (${n} bytes)`,`string_length`);i+=e,a+=t};for(;o<e.length;)if(e[o]===`%`&&o+1<e.length){let n=o+1,i=``,a=``,l=``,u,d=n;for(;n<e.length&&/\d/.test(e[n]);)n++;n>d&&e[n]===`$`?(u=parseInt(e.substring(d,n),10)-1,n++):n=d;let f=()=>{if(n<e.length){if(n+1<e.length&&(e[n]===`h`&&e[n+1]===`h`||e[n]===`l`&&e[n+1]===`l`)){n+=2;return}/[lzjh]/.test(e[n])&&n++}};for(;n<e.length&&/[-+ #0]/.test(e[n]);)i+=e[n++];if(e[n]===`*`){let e=t[r++],o=e===void 0?0:Math.floor(Number(e));if(!Number.isFinite(o)||!Number.isSafeInteger(o))throw new A(`printf width limit exceeded (${s} bytes)`,`string_length`);o<0?(i+=`-`,a=String(-o)):a=String(o),n++}else for(;n<e.length&&/\d/.test(e[n]);)a+=e[n++];if(a&&parseInt(a,10)>s)throw new A(`printf width limit exceeded (${s} bytes)`,`string_length`);if(e[n]===`.`){if(n++,e[n]===`*`){let e=t[r++],i=e===void 0?0:Math.floor(Number(e));if(!Number.isFinite(i)||!Number.isSafeInteger(i))throw new A(`printf precision limit exceeded (${s} bytes)`,`string_length`);l=i<0?``:String(i),n++}else for(;n<e.length&&/\d/.test(e[n]);)l+=e[n++];if(l&&parseInt(l,10)>s)throw new A(`printf precision limit exceeded (${s} bytes)`,`string_length`)}f();let p=e[n],m=t[u===void 0?r:u];switch(p){case`s`:{let e=m===void 0?``:String(m);if(l&&(e=e.substring(0,parseInt(l,10))),a){let t=parseInt(a,10);e=i.includes(`-`)?e.padEnd(t):e.padStart(t)}c(e),u===void 0&&r++;break}case`d`:case`i`:{let e=m===void 0?0:Math.floor(Number(m));Number.isNaN(e)&&(e=0);let t=e<0,n=Math.abs(e).toString();if(l){let e=parseInt(l,10);n=n.padStart(e,`0`)}let o=``;t?o=`-`:i.includes(`+`)?o=`+`:i.includes(` `)&&(o=` `);let s=o+n;if(a){let e=parseInt(a,10);s=i.includes(`-`)?s.padEnd(e):i.includes(`0`)&&!l?o+n.padStart(e-o.length,`0`):s.padStart(e)}c(s),u===void 0&&r++;break}case`f`:{let e=m===void 0?0:Number(m);Number.isNaN(e)&&(e=0);let t=l?parseInt(l,10):6;if(t>100)throw new A(`printf floating-point precision limit exceeded (100 digits)`,`string_length`);let n=e.toFixed(t);if(a){let e=parseInt(a,10);n=i.includes(`-`)?n.padEnd(e):n.padStart(e)}c(n),u===void 0&&r++;break}case`e`:case`E`:{let e=m===void 0?0:Number(m);Number.isNaN(e)&&(e=0);let t=l?parseInt(l,10):6;if(t>100)throw new A(`printf floating-point precision limit exceeded (100 digits)`,`string_length`);let n=e.toExponential(t);if(p===`E`&&(n=n.toUpperCase()),a){let e=parseInt(a,10);n=i.includes(`-`)?n.padEnd(e):n.padStart(e)}c(n),u===void 0&&r++;break}case`g`:case`G`:{let e=m===void 0?0:Number(m);Number.isNaN(e)&&(e=0);let t=l?parseInt(l,10):6;if(t>100)throw new A(`printf floating-point precision limit exceeded (100 digits)`,`string_length`);let n=e===0?0:Math.floor(Math.log10(Math.abs(e))),o;if(e===0?o=`0`:n<-4||n>=t?(o=e.toExponential(t-1),p===`G`&&(o=o.toUpperCase())):o=e.toPrecision(t),o.includes(`.`)&&(o=o.replace(/\.?0+$/,``).replace(/\.?0+e/,`e`)),o.includes(`e`)&&(o=o.replace(/\.?0+e/,`e`)),a){let e=parseInt(a,10);o=i.includes(`-`)?o.padEnd(e):o.padStart(e)}c(o),u===void 0&&r++;break}case`x`:case`X`:{let e=m===void 0?0:Math.floor(Number(m));Number.isNaN(e)&&(e=0);let t=Math.abs(e).toString(16);if(p===`X`&&(t=t.toUpperCase()),l){let e=parseInt(l,10);t=t.padStart(e,`0`)}let n=e<0?`-`:``,o=n+t;if(a){let e=parseInt(a,10);o=i.includes(`-`)?o.padEnd(e):i.includes(`0`)&&!l?n+t.padStart(e-n.length,`0`):o.padStart(e)}c(o),u===void 0&&r++;break}case`o`:{let e=m===void 0?0:Math.floor(Number(m));Number.isNaN(e)&&(e=0);let t=Math.abs(e).toString(8);if(l){let e=parseInt(l,10);t=t.padStart(e,`0`)}let n=e<0?`-`:``,o=n+t;if(a){let e=parseInt(a,10);o=i.includes(`-`)?o.padEnd(e):i.includes(`0`)&&!l?n+t.padStart(e-n.length,`0`):o.padStart(e)}c(o),u===void 0&&r++;break}case`c`:c(typeof m==`number`?String.fromCharCode(m):String(m??``).charAt(0)||``),u===void 0&&r++;break;case`%`:c(`%`);break;default:c(e.substring(o,n+1))}o=n+1}else if(e[o]===`\\`&&o+1<e.length){let t=e[o+1];switch(t){case`n`:c(`
406
+ `);break;case`t`:c(` `);break;case`r`:c(`\r`);break;case`\\`:c(`\\`);break;default:c(t)}o+=2}else c(e[o++]);return i}var Jd,Yd,Xd,Zd=T(()=>{Wi(),k(),Wr(),j(),mc(),Jd=10485760,Yd=1e4,Xd=new Map([[`length`,Cd],[`substr`,wd],[`index`,Td],[`split`,Ed],[`sub`,Dd],[`gsub`,Od],[`match`,Ad],[`gensub`,jd],[`tolower`,Nd],[`toupper`,Pd],[`sprintf`,Fd],[`int`,Id],[`sqrt`,Ld],[`sin`,Rd],[`cos`,zd],[`atan2`,Bd],[`log`,Vd],[`exp`,Hd],[`rand`,Ud],[`srand`,Wd],[`system`,Gd(`system`,`shell execution not allowed in sandboxed environment`)],[`close`,()=>0],[`fflush`,()=>0],[`systime`,Kd(`systime`)],[`mktime`,Kd(`mktime`)],[`strftime`,Kd(`strftime`)]])});function Qd(e){return typeof e==`number`?e!==0:e!==``&&e!==`0`}function $d(e){if(typeof e==`number`)return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function ef(e){return typeof e==`string`?e:String(e)}function tf(e){if(typeof e==`number`)return!0;let t=String(e).trim();return t!==``&&!Number.isNaN(Number(t))}function nf(e,t){try{return U(e).test(t)}catch{return!1}}var rf=T(()=>{mc()});function af(e,t){return t===``?[]:e.FS===` `?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function of(e,t){return t===0?e.line:t<0||t>e.fields.length?``:e.fields[t-1]??``}function sf(e,t,n){if(t===0)e.line=ef(n),e.fields=af(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push(``);e.fields[t-1]=ef(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function cf(e,t){e.line=t,e.fields=af(e,t),e.NF=e.fields.length}function lf(e,t){if(e.FS=t,t===` `)e.fieldSep=new fc(/\s+/);else try{e.fieldSep=U(t)}catch{e.fieldSep=U(t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`))}}var uf=T(()=>{mc(),rf()});function df(e,t){switch(t){case`FS`:return e.FS;case`OFS`:return e.OFS;case`ORS`:return e.ORS;case`OFMT`:return e.OFMT;case`NR`:return e.NR;case`NF`:return e.NF;case`FNR`:return e.FNR;case`FILENAME`:return e.FILENAME;case`RSTART`:return e.RSTART;case`RLENGTH`:return e.RLENGTH;case`SUBSEP`:return e.SUBSEP;case`ARGC`:return e.ARGC}return e.vars[t]??``}function ff(e,t,n){switch(t){case`FS`:lf(e,ef(n));return;case`OFS`:e.OFS=ef(n);return;case`ORS`:e.ORS=ef(n);return;case`OFMT`:e.OFMT=ef(n);return;case`NR`:e.NR=Math.floor($d(n));return;case`NF`:{let t=Math.floor($d(n));if(t<e.NF)e.fields=e.fields.slice(0,t),e.line=e.fields.join(e.OFS);else if(t>e.NF){for(;e.fields.length<t;)e.fields.push(``);e.line=e.fields.join(e.OFS)}e.NF=t;return}case`FNR`:e.FNR=Math.floor($d(n));return;case`FILENAME`:e.FILENAME=ef(n);return;case`RSTART`:e.RSTART=Math.floor($d(n));return;case`RLENGTH`:e.RLENGTH=Math.floor($d(n));return;case`SUBSEP`:e.SUBSEP=ef(n);return}e.vars[t]=n}function pf(e,t){let n=t,r=new Set,i=e.arrayAliases.get(n);for(;i!==void 0&&!r.has(n);)r.add(n),n=i,i=e.arrayAliases.get(n);return n}function mf(e,t,n){if(t===`ARGV`)return e.ARGV[n]??``;if(t===`ENVIRON`)return e.ENVIRON[n]??``;let r=pf(e,t);return e.arrays[r]?.[n]??``}function hf(e,t,n,r){let i=pf(e,t);if(e.arrays[i]||(e.arrays[i]=Object.create(null)),!(n in e.arrays[i])){if(e.arrayElementCount>=e.maxArrayElements)throw new A(`array element limit exceeded (${e.maxArrayElements})`,`array_elements`);e.arrayElementCount++}e.arrays[i][n]=r}function gf(e,t,n){if(t===`ARGV`)return e.ARGV[n]!==void 0;if(t===`ENVIRON`)return e.ENVIRON[n]!==void 0;let r=pf(e,t);return e.arrays[r]?.[n]!==void 0}function _f(e,t,n){let r=pf(e,t);e.arrays[r]&&(n in e.arrays[r]&&e.arrayElementCount--,delete e.arrays[r][n])}function vf(e,t){let n=pf(e,t);e.arrayElementCount-=Object.keys(e.arrays[n]??{}).length,delete e.arrays[n]}var yf=T(()=>{j(),uf(),rf()});function bf(e){Hf=e}function xf(e,t){bu(e.requireDefenseContext,`awk`,t)}function Sf(e,t,n){return xu(e.requireDefenseContext,`awk`,t,n)}async function G(e,t){switch(xf(e,`expression evaluation`),e.coverage?.hit(`awk:expr:${t.type}`),t.type){case`number`:return t.value;case`string`:return t.value;case`regex`:return+!!nf(t.pattern,e.line);case`field`:return Cf(e,t);case`variable`:return df(e,t.name);case`array_access`:return wf(e,t);case`binary`:return Tf(e,t);case`unary`:return Of(e,t);case`ternary`:return Qd(await Sf(e,`ternary condition evaluation`,()=>G(e,t.condition)))?await Sf(e,`ternary consequent evaluation`,()=>G(e,t.consequent)):await Sf(e,`ternary alternate evaluation`,()=>G(e,t.alternate));case`call`:return kf(e,t.name,t.args);case`assignment`:return jf(e,t);case`pre_increment`:return Nf(e,t.operand);case`pre_decrement`:return Pf(e,t.operand);case`post_increment`:return Ff(e,t.operand);case`post_decrement`:return If(e,t.operand);case`in`:return Lf(e,t.key,t.array);case`getline`:return Rf(e,t.variable,t.file,t.command);case`tuple`:return Vf(e,t.elements);default:return``}}async function Cf(e,t){return xf(e,`field reference evaluation`),of(e,Math.floor($d(await Sf(e,`field index evaluation`,()=>G(e,t.index)))))}async function wf(e,t){xf(e,`array access evaluation`);let n=ef(await Sf(e,`array key evaluation`,()=>G(e,t.key)));return mf(e,t.array,n)}async function Tf(e,t){xf(e,`binary expression evaluation`);let n=t.operator;if(n===`||`)return Qd(await Sf(e,`logical-or left evaluation`,()=>G(e,t.left)))||Qd(await Sf(e,`logical-or right evaluation`,()=>G(e,t.right)))?1:0;if(n===`&&`)return Qd(await Sf(e,`logical-and left evaluation`,()=>G(e,t.left)))&&Qd(await Sf(e,`logical-and right evaluation`,()=>G(e,t.right)))?1:0;if(n===`~`){let n=await Sf(e,`regex left evaluation`,()=>G(e,t.left));t.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let r=t.right.type===`regex`?t.right.pattern:ef(await Sf(e,`regex right evaluation`,()=>G(e,t.right)));try{return+!!U(r).test(ef(n))}catch{return 0}}if(n===`!~`){let n=await Sf(e,`negated-regex left evaluation`,()=>G(e,t.left));t.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let r=t.right.type===`regex`?t.right.pattern:ef(await Sf(e,`negated-regex right evaluation`,()=>G(e,t.right)));try{return+!U(r).test(ef(n))}catch{return 1}}let r=await Sf(e,`binary left evaluation`,()=>G(e,t.left)),i=await Sf(e,`binary right evaluation`,()=>G(e,t.right));if(n===` `){let t=ef(r)+ef(i);if(e.maxOutputSize>0&&t.length>e.maxOutputSize)throw new A(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output);return t}return Ef(n)?Df(r,i,n):fd($d(r),$d(i),n)}function Ef(e){return[`<`,`<=`,`>`,`>=`,`==`,`!=`].includes(e)}function Df(e,t,n){let r=tf(e),i=tf(t);if(r&&i){let r=$d(e),i=$d(t);switch(n){case`<`:return+(r<i);case`<=`:return+(r<=i);case`>`:return+(r>i);case`>=`:return+(r>=i);case`==`:return+(r===i);case`!=`:return r===i?0:1}}let a=ef(e),o=ef(t);switch(n){case`<`:return+(a<o);case`<=`:return+(a<=o);case`>`:return+(a>o);case`>=`:return+(a>=o);case`==`:return+(a===o);case`!=`:return a===o?0:1}return 0}async function Of(e,t){xf(e,`unary expression evaluation`);let n=await Sf(e,`unary operand evaluation`,()=>G(e,t.operand));switch(t.operator){case`!`:return+!Qd(n);case`-`:return-$d(n);case`+`:return+$d(n);default:return n}}async function kf(e,t,n){xf(e,`function call evaluation`);let r=Xd.get(t);if(r)return r(n,e,{evalExpr:t=>G(e,t)});let i=e.functions.get(t);return i?Af(e,i,n):``}async function Af(e,t,n){if(xf(e,`user function call`),e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new A(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,`recursion`,e.output);let r=Object.create(null);for(let n of t.params)r[n]=e.vars[n];let i=[];for(let r=0;r<t.params.length;r++){let a=t.params[r];if(r<n.length){let t=n[r];t.type===`variable`&&(e.arrayAliases.set(a,t.name),i.push(a));let o=await Sf(e,`user function argument evaluation`,()=>G(e,t));e.vars[a]=o}else e.vars[a]=``}e.hasReturn=!1,e.returnValue=void 0;let a=Hf;a&&await Sf(e,`user function body execution`,()=>a(e,t.body.statements));let o=e.returnValue??``;for(let n of t.params)r[n]===void 0?delete e.vars[n]:e.vars[n]=r[n];for(let t of i)e.arrayAliases.delete(t);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,o}async function jf(e,t){xf(e,`assignment evaluation`);let n=await Sf(e,`assignment value evaluation`,()=>G(e,t.value)),r=t.target,i=t.operator,a;if(i===`=`)a=n;else{let t;if(r.type===`field`)t=of(e,Math.floor($d(await Sf(e,`assignment field index`,()=>G(e,r.index)))));else if(r.type===`variable`)t=df(e,r.name);else{let n=ef(await Sf(e,`assignment array key`,()=>G(e,r.key)));t=mf(e,r.array,n)}let o=$d(t),s=$d(n);switch(i){case`+=`:a=o+s;break;case`-=`:a=o-s;break;case`*=`:a=o*s;break;case`/=`:a=s===0?0:o/s;break;case`%=`:a=s===0?0:o%s;break;case`^=`:a=o**s;break;default:a=n}}if(r.type===`field`)sf(e,Math.floor($d(await Sf(e,`assignment target field index`,()=>G(e,r.index)))),a);else if(r.type===`variable`)ff(e,r.name,a);else{let t=ef(await Sf(e,`assignment target array key`,()=>G(e,r.key)));hf(e,r.array,t,a)}return a}async function Mf(e,t,n,r){xf(e,`inc/dec evaluation`);let i;if(t.type===`field`){let r=Math.floor($d(await Sf(e,`inc/dec field index`,()=>G(e,t.index))));i=$d(of(e,r)),sf(e,r,i+n)}else if(t.type===`variable`)i=$d(df(e,t.name)),ff(e,t.name,i+n);else{let r=ef(await Sf(e,`inc/dec array key`,()=>G(e,t.key)));i=$d(mf(e,t.array,r)),hf(e,t.array,r,i+n)}return r?i+n:i}async function Nf(e,t){return Mf(e,t,1,!0)}async function Pf(e,t){return Mf(e,t,-1,!0)}async function Ff(e,t){return Mf(e,t,1,!1)}async function If(e,t){return Mf(e,t,-1,!1)}async function Lf(e,t,n){xf(e,`in-expression evaluation`);let r;if(t.type===`tuple`){e.coverage?.hit(`awk:expr:tuple`);let n=[];for(let r of t.elements)n.push(ef(await Sf(e,`tuple key element evaluation`,()=>G(e,r))));r=n.join(e.SUBSEP)}else r=ef(await Sf(e,`in-expression key evaluation`,()=>G(e,t)));return+!!gf(e,n,r)}async function Rf(e,t,n,r){if(xf(e,`getline evaluation`),r)return zf(e,t,r);if(n)return Bf(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let i=e.lineIndex+1;if(i>=e.lines.length)return 0;let a=e.lines[i];return t?ff(e,t,a):cf(e,a),e.NR++,e.lineIndex=i,1}async function zf(e,t,n){let r=e.exec;if(!r)return-1;xf(e,`getline command source`);let i=ef(await Sf(e,`getline command expression`,()=>G(e,n))),a=e.getlineCommandStreams.get(i);if(!a)try{let t=or((await Sf(e,`getline command exec`,()=>r(i))).stdout).split(`
407
+ `);t.length>0&&t[t.length-1]===``&&t.pop(),a={lines:t,index:-1},e.getlineCommandStreams.set(i,a)}catch(e){if(e instanceof D)throw e;return-1}let o=a.index+1;if(o>=a.lines.length)return 0;let s=a.lines[o];return a.index=o,t?ff(e,t,s):cf(e,s),1}async function Bf(e,t,n){let r=e.fs;if(!r||!e.cwd)return-1;xf(e,`getline file source`);let i=ef(await Sf(e,`getline filename evaluation`,()=>G(e,n)));if(i===`/dev/null`)return 0;let a=r.resolvePath(e.cwd,i),o=e.getlineFileStreams.get(a);if(!o)try{let t=(await Sf(e,`getline file read`,()=>r.readFile(a))).split(`
408
+ `);t.length>0&&t[t.length-1]===``&&t.pop(),o={lines:t,index:-1},e.getlineFileStreams.set(a,o)}catch(e){if(e instanceof D)throw e;return-1}let s=o.index+1;if(s>=o.lines.length)return 0;let c=o.lines[s];return o.index=s,t?ff(e,t,c):cf(e,c),1}async function Vf(e,t){if(xf(e,`tuple evaluation`),t.length===0)return``;for(let n=0;n<t.length-1;n++)await Sf(e,`tuple intermediate element`,()=>G(e,t[n]));return Sf(e,`tuple final element`,()=>G(e,t[t.length-1]))}var Hf,Uf=T(()=>{k(),j(),mc(),Su(),qn(),pd(),Zd(),uf(),rf(),yf(),Hf=null});function Wf(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new A(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output)}function Gf(e,t){bu(e.requireDefenseContext,`awk`,t)}function Kf(e,t,n){return xu(e.requireDefenseContext,`awk`,t,n)}async function qf(e,t){Gf(e,`block execution`);for(let n of t)if(await Kf(e,`statement execution`,()=>Yf(e,n)),Jf(e))break}function Jf(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function Yf(e,t){switch(Gf(e,`single statement execution`),e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case`block`:await Kf(e,`nested block statement`,()=>qf(e,t.statements));break;case`expr_stmt`:await Kf(e,`expression statement`,()=>G(e,t.expression));break;case`print`:await Kf(e,`print statement`,()=>Xf(e,t.args,t.output));break;case`printf`:await Kf(e,`printf statement`,()=>Zf(e,t.format,t.args,t.output));break;case`if`:await Kf(e,`if statement`,()=>$f(e,t));break;case`while`:await Kf(e,`while statement`,()=>ep(e,t));break;case`do_while`:await Kf(e,`do-while statement`,()=>tp(e,t));break;case`for`:await Kf(e,`for statement`,()=>np(e,t));break;case`for_in`:await Kf(e,`for-in statement`,()=>rp(e,t));break;case`break`:e.loopBreak=!0;break;case`continue`:e.loopContinue=!0;break;case`next`:e.shouldNext=!0;break;case`nextfile`:e.shouldNextFile=!0;break;case`exit`:e.shouldExit=!0;{let n=t.code;e.exitCode=n?Math.floor($d(await Kf(e,`exit code expression`,()=>G(e,n)))):0}break;case`return`:e.hasReturn=!0;{let n=t.value;e.returnValue=n?await Kf(e,`return expression`,()=>G(e,n)):``}break;case`delete`:await Kf(e,`delete statement`,()=>ip(e,t.target))}}async function Xf(e,t,n){Gf(e,`print execution`);let r=[];for(let n of t){let t=await Kf(e,`print argument evaluation`,()=>G(e,n));typeof t==`number`?Number.isInteger(t)&&Math.abs(t)<2**53-1?r.push(String(t)):r.push(qd(e.OFMT,[t],e.maxOutputSize||void 0)):r.push(ef(t))}let i=r.join(e.OFS)+e.ORS;n?await Kf(e,`print redirection write`,()=>Qf(e,n.redirect,n.file,i)):(e.output+=i,Wf(e))}async function Zf(e,t,n,r){Gf(e,`printf execution`);let i=ef(await Kf(e,`printf format evaluation`,()=>G(e,t))),a=[];for(let t of n)a.push(await Kf(e,`printf argument evaluation`,()=>G(e,t)));let o=qd(i,a,e.maxOutputSize>0?Math.max(0,e.maxOutputSize-O(e.output)):void 0);r?await Kf(e,`printf redirection write`,()=>Qf(e,r.redirect,r.file,o)):(e.output+=o,Wf(e))}async function Qf(e,t,n,r){Gf(e,`file write execution`);let i=e.fs;if(!i||!e.cwd){e.output+=r,Wf(e);return}let a=ef(await Kf(e,`redirection filename evaluation`,()=>G(e,n))),o=i.resolvePath(e.cwd,a);t===`>`?e.openedFiles.has(o)?await Kf(e,`redirection append write`,()=>i.appendFile(o,r)):(await Kf(e,`redirection overwrite write`,()=>i.writeFile(o,r)),e.openedFiles.add(o)):(e.openedFiles.has(o)||e.openedFiles.add(o),await Kf(e,`redirection append mode write`,()=>i.appendFile(o,r)))}async function $f(e,t){if(Gf(e,`if execution`),Qd(await Kf(e,`if condition evaluation`,()=>G(e,t.condition))))await Kf(e,`if consequent execution`,()=>Yf(e,t.consequent));else if(t.alternate){let n=t.alternate;await Kf(e,`if alternate execution`,()=>Yf(e,n))}}async function ep(e,t){Gf(e,`while execution`);let n=0;for(;Qd(await Kf(e,`while condition evaluation`,()=>G(e,t.condition)));){if(n++,n>e.maxIterations)throw new A(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await Kf(e,`while body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function tp(e,t){Gf(e,`do-while execution`);let n=0;do{if(n++,n>e.maxIterations)throw new A(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await Kf(e,`do-while body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(Qd(await Kf(e,`do-while condition evaluation`,()=>G(e,t.condition))))}async function np(e,t){Gf(e,`for execution`);let n=t.init,r=t.condition,i=t.update;n&&await Kf(e,`for init evaluation`,()=>G(e,n));let a=0;for(;!r||Qd(await Kf(e,`for condition evaluation`,()=>G(e,r)));){if(a++,a>e.maxIterations)throw new A(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await Kf(e,`for body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;i&&await Kf(e,`for update evaluation`,()=>G(e,i))}}async function rp(e,t){Gf(e,`for-in execution`);let n=e.arrays[t.array];if(n)for(let r of Object.keys(n)){if(e.vars[t.variable]=r,e.loopContinue=!1,await Kf(e,`for-in body execution`,()=>Yf(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function ip(e,t){if(Gf(e,`delete execution`),t.type===`array_access`){let n=ef(await Kf(e,`delete key evaluation`,()=>G(e,t.key)));_f(e,t.array,n)}else t.type===`variable`&&vf(e,t.name)}var ap=T(()=>{j(),Su(),Lr(),Zd(),Uf(),rf(),yf(),bf(qf)}),op,sp=T(()=>{j(),Su(),Uf(),uf(),ap(),rf(),op=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}assertDefenseContext(e){bu(this.ctx.requireDefenseContext,`awk`,e)}withDefenseContext(e,t){return xu(this.ctx.requireDefenseContext,`awk`,e,t)}execute(e){this.assertDefenseContext(`program initialization`),this.program=e,this.ctx.output=``;for(let t of e.functions)this.ctx.functions.set(t.name,t);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.assertDefenseContext(`BEGIN execution entry`),this.program){for(let e of this.program.rules)if(e.pattern?.type===`begin`&&(await this.withDefenseContext(`BEGIN block execution`,()=>qf(this.ctx,e.action.statements)),this.ctx.shouldExit))break}}async executeLine(e){if(this.assertDefenseContext(`line execution entry`),!(!this.program||this.ctx.shouldExit)){if(this.ctx.recordsProcessed++,this.ctx.recordsProcessed>this.ctx.maxIterations)throw new A(`record limit exceeded (${this.ctx.maxIterations})`,`iterations`);cf(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let e=0;e<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);e++){let t=this.program.rules[e];t.pattern?.type===`begin`||t.pattern?.type===`end`||await this.withDefenseContext(`rule match`,()=>this.matchesRule(t,e))&&await this.withDefenseContext(`rule block execution`,()=>qf(this.ctx,t.action.statements))}}}async executeEnd(){if(this.assertDefenseContext(`END execution entry`),this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let e of this.program.rules)if(e.pattern?.type===`end`&&(await this.withDefenseContext(`END block execution`,()=>qf(this.ctx,e.action.statements)),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,t){this.assertDefenseContext(`rule matching`);let n=e.pattern;if(!n)return!0;switch(n.type){case`begin`:case`end`:return!1;case`regex_pattern`:return nf(n.pattern,this.ctx.line);case`expr_pattern`:return Qd(await this.withDefenseContext(`expression pattern evaluation`,()=>G(this.ctx,n.expression)));case`range`:{let e=await this.withDefenseContext(`range start pattern`,()=>this.matchPattern(n.start)),r=await this.withDefenseContext(`range end pattern`,()=>this.matchPattern(n.end));return this.rangeStates[t]?(r&&(this.rangeStates[t]=!1),!0):e?(this.rangeStates[t]=!0,r&&(this.rangeStates[t]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(this.assertDefenseContext(`pattern matching`),e.type){case`regex_pattern`:return nf(e.pattern,this.ctx.line);case`expr_pattern`:return Qd(await this.withDefenseContext(`nested expression pattern`,()=>G(this.ctx,e.expression)));default:return!1}}}}),cp=T(()=>{dd(),sp()});function lp(e){return e.replace(/\[\[:space:\]\]/g,`[ \\t\\n\\r\\f\\v]`).replace(/\[\[:blank:\]\]/g,`[ \\t]`).replace(/\[\[:alpha:\]\]/g,`[a-zA-Z]`).replace(/\[\[:digit:\]\]/g,`[0-9]`).replace(/\[\[:alnum:\]\]/g,`[a-zA-Z0-9]`).replace(/\[\[:upper:\]\]/g,`[A-Z]`).replace(/\[\[:lower:\]\]/g,`[a-z]`).replace(/\[\[:punct:\]\]/g,`[!"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_\`{|}~]`).replace(/\[\[:xdigit:\]\]/g,`[0-9A-Fa-f]`).replace(/\[\[:graph:\]\]/g,`[!-~]`).replace(/\[\[:print:\]\]/g,`[ -~]`).replace(/\[\[:cntrl:\]\]/g,`[\\x00-\\x1f\\x7f]`)}var K,up,dp,fp,pp=T(()=>{j(),(function(e){e.NUMBER=`NUMBER`,e.STRING=`STRING`,e.REGEX=`REGEX`,e.IDENT=`IDENT`,e.BEGIN=`BEGIN`,e.END=`END`,e.IF=`IF`,e.ELSE=`ELSE`,e.WHILE=`WHILE`,e.DO=`DO`,e.FOR=`FOR`,e.IN=`IN`,e.BREAK=`BREAK`,e.CONTINUE=`CONTINUE`,e.NEXT=`NEXT`,e.NEXTFILE=`NEXTFILE`,e.EXIT=`EXIT`,e.RETURN=`RETURN`,e.DELETE=`DELETE`,e.FUNCTION=`FUNCTION`,e.PRINT=`PRINT`,e.PRINTF=`PRINTF`,e.GETLINE=`GETLINE`,e.PLUS=`PLUS`,e.MINUS=`MINUS`,e.STAR=`STAR`,e.SLASH=`SLASH`,e.PERCENT=`PERCENT`,e.CARET=`CARET`,e.EQ=`EQ`,e.NE=`NE`,e.LT=`LT`,e.GT=`GT`,e.LE=`LE`,e.GE=`GE`,e.MATCH=`MATCH`,e.NOT_MATCH=`NOT_MATCH`,e.AND=`AND`,e.OR=`OR`,e.NOT=`NOT`,e.ASSIGN=`ASSIGN`,e.PLUS_ASSIGN=`PLUS_ASSIGN`,e.MINUS_ASSIGN=`MINUS_ASSIGN`,e.STAR_ASSIGN=`STAR_ASSIGN`,e.SLASH_ASSIGN=`SLASH_ASSIGN`,e.PERCENT_ASSIGN=`PERCENT_ASSIGN`,e.CARET_ASSIGN=`CARET_ASSIGN`,e.INCREMENT=`INCREMENT`,e.DECREMENT=`DECREMENT`,e.QUESTION=`QUESTION`,e.COLON=`COLON`,e.COMMA=`COMMA`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.LBRACKET=`LBRACKET`,e.RBRACKET=`RBRACKET`,e.DOLLAR=`DOLLAR`,e.APPEND=`APPEND`,e.PIPE=`PIPE`,e.EOF=`EOF`})(K||={}),up=new Map([[`BEGIN`,K.BEGIN],[`END`,K.END],[`if`,K.IF],[`else`,K.ELSE],[`while`,K.WHILE],[`do`,K.DO],[`for`,K.FOR],[`in`,K.IN],[`break`,K.BREAK],[`continue`,K.CONTINUE],[`next`,K.NEXT],[`nextfile`,K.NEXTFILE],[`exit`,K.EXIT],[`return`,K.RETURN],[`delete`,K.DELETE],[`function`,K.FUNCTION],[`print`,K.PRINT],[`printf`,K.PRINTF],[`getline`,K.GETLINE]]),dp=new Set([K.COMMA,K.LBRACE,K.AND,K.OR,K.QUESTION,K.COLON,K.DO,K.ELSE,K.IF,K.WHILE]),fp=class{maxTokens;input;pos=0;line=1;column=1;lastTokenType=null;constructor(e,t=1e5){this.maxTokens=t,this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let t=this.nextToken();if(t){if(e.length>=this.maxTokens)throw new A(`awk: token limit exceeded (${this.maxTokens})`,`array_elements`);e.push(t),this.lastTokenType=t.type}}if(e.length>=this.maxTokens)throw new A(`awk: token limit exceeded (${this.maxTokens})`,`array_elements`);return e.push(this.makeToken(K.EOF,``)),e}makeToken(e,t){return{type:e,value:t,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||``}advance(){let e=this.input[this.pos++]||``;return e===`
409
+ `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===` `||e===` `||e===`\r`)this.advance();else if(e===`\\`)if(this.peek(1)===`
410
+ `)this.advance(),this.advance();else break;else if(e===`#`)for(;this.pos<this.input.length&&this.peek()!==`
411
+ `;)this.advance();else break}}nextToken(){for(this.skipWhitespace();this.peek()===`
412
+ `&&this.lastTokenType!==null&&dp.has(this.lastTokenType);)this.advance(),this.skipWhitespace();if(this.pos>=this.input.length)return null;let e=this.line,t=this.column,n=this.peek();return n===`
413
+ `?(this.advance(),{type:K.NEWLINE,value:`
414
+ `,line:e,column:t}):n===`"`?this.readString():n===`/`&&this.canBeRegex()?this.readRegex():this.isDigit(n)||n===`.`&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(n)||n===`_`?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,K.NEWLINE,K.SEMICOLON,K.LBRACE,K.RBRACE,K.LPAREN,K.LBRACKET,K.COMMA,K.ASSIGN,K.PLUS_ASSIGN,K.MINUS_ASSIGN,K.STAR_ASSIGN,K.SLASH_ASSIGN,K.PERCENT_ASSIGN,K.CARET_ASSIGN,K.AND,K.OR,K.NOT,K.MATCH,K.NOT_MATCH,K.QUESTION,K.COLON,K.LT,K.GT,K.LE,K.GE,K.EQ,K.NE,K.PLUS,K.MINUS,K.STAR,K.PERCENT,K.CARET,K.PRINT,K.PRINTF,K.IF,K.WHILE,K.DO,K.FOR,K.RETURN]).has(this.lastTokenType)}readString(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.pos<this.input.length&&this.peek()!==`"`;)if(this.peek()===`\\`){this.advance();let e=this.advance();switch(e){case`n`:n+=`
415
+ `;break;case`t`:n+=` `;break;case`r`:n+=`\r`;break;case`f`:n+=`\f`;break;case`b`:n+=`\b`;break;case`v`:n+=`\v`;break;case`a`:n+=`\x07`;break;case`\\`:n+=`\\`;break;case`"`:n+=`"`;break;case`/`:n+=`/`;break;case`x`:{let e=``;for(;e.length<2&&/[0-9a-fA-F]/.test(this.peek());)e+=this.advance();e.length>0?n+=String.fromCharCode(parseInt(e,16)):n+=`x`;break}default:if(/[0-7]/.test(e)){let t=e;for(;t.length<3&&/[0-7]/.test(this.peek());)t+=this.advance();n+=String.fromCharCode(parseInt(t,8))}else n+=e}}else n+=this.advance();return this.peek()===`"`&&this.advance(),{type:K.STRING,value:n,line:e,column:t}}readRegex(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.pos<this.input.length&&this.peek()!==`/`;)if(this.peek()===`\\`)n+=this.advance(),this.pos<this.input.length&&(n+=this.advance());else{if(this.peek()===`
416
+ `)break;n+=this.advance()}return this.peek()===`/`&&this.advance(),n=lp(n),{type:K.REGEX,value:n,line:e,column:t}}readNumber(){let e=this.line,t=this.column,n=``;for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()===`.`&&this.isDigit(this.peek(1)))for(n+=this.advance();this.isDigit(this.peek());)n+=this.advance();if(this.peek()===`e`||this.peek()===`E`)for(n+=this.advance(),(this.peek()===`+`||this.peek()===`-`)&&(n+=this.advance());this.isDigit(this.peek());)n+=this.advance();return{type:K.NUMBER,value:parseFloat(n),line:e,column:t}}readIdentifier(){let e=this.line,t=this.column,n=``;for(;this.isAlphaNumeric(this.peek())||this.peek()===`_`;)n+=this.advance();let r=up.get(n);return r===void 0?{type:K.IDENT,value:n,line:e,column:t}:{type:r,value:n,line:e,column:t}}readOperator(){let e=this.line,t=this.column,n=this.advance(),r=this.peek();switch(n){case`+`:return r===`+`?(this.advance(),{type:K.INCREMENT,value:`++`,line:e,column:t}):r===`=`?(this.advance(),{type:K.PLUS_ASSIGN,value:`+=`,line:e,column:t}):{type:K.PLUS,value:`+`,line:e,column:t};case`-`:return r===`-`?(this.advance(),{type:K.DECREMENT,value:`--`,line:e,column:t}):r===`=`?(this.advance(),{type:K.MINUS_ASSIGN,value:`-=`,line:e,column:t}):{type:K.MINUS,value:`-`,line:e,column:t};case`*`:return r===`*`?(this.advance(),{type:K.CARET,value:`**`,line:e,column:t}):r===`=`?(this.advance(),{type:K.STAR_ASSIGN,value:`*=`,line:e,column:t}):{type:K.STAR,value:`*`,line:e,column:t};case`/`:return r===`=`?(this.advance(),{type:K.SLASH_ASSIGN,value:`/=`,line:e,column:t}):{type:K.SLASH,value:`/`,line:e,column:t};case`%`:return r===`=`?(this.advance(),{type:K.PERCENT_ASSIGN,value:`%=`,line:e,column:t}):{type:K.PERCENT,value:`%`,line:e,column:t};case`^`:return r===`=`?(this.advance(),{type:K.CARET_ASSIGN,value:`^=`,line:e,column:t}):{type:K.CARET,value:`^`,line:e,column:t};case`=`:return r===`=`?(this.advance(),{type:K.EQ,value:`==`,line:e,column:t}):{type:K.ASSIGN,value:`=`,line:e,column:t};case`!`:return r===`=`?(this.advance(),{type:K.NE,value:`!=`,line:e,column:t}):r===`~`?(this.advance(),{type:K.NOT_MATCH,value:`!~`,line:e,column:t}):{type:K.NOT,value:`!`,line:e,column:t};case`<`:return r===`=`?(this.advance(),{type:K.LE,value:`<=`,line:e,column:t}):{type:K.LT,value:`<`,line:e,column:t};case`>`:return r===`=`?(this.advance(),{type:K.GE,value:`>=`,line:e,column:t}):r===`>`?(this.advance(),{type:K.APPEND,value:`>>`,line:e,column:t}):{type:K.GT,value:`>`,line:e,column:t};case`&`:return r===`&`?(this.advance(),{type:K.AND,value:`&&`,line:e,column:t}):{type:K.IDENT,value:`&`,line:e,column:t};case`|`:return r===`|`?(this.advance(),{type:K.OR,value:`||`,line:e,column:t}):{type:K.PIPE,value:`|`,line:e,column:t};case`~`:return{type:K.MATCH,value:`~`,line:e,column:t};case`?`:return{type:K.QUESTION,value:`?`,line:e,column:t};case`:`:return{type:K.COLON,value:`:`,line:e,column:t};case`,`:return{type:K.COMMA,value:`,`,line:e,column:t};case`;`:return{type:K.SEMICOLON,value:`;`,line:e,column:t};case`(`:return{type:K.LPAREN,value:`(`,line:e,column:t};case`)`:return{type:K.RPAREN,value:`)`,line:e,column:t};case`{`:return{type:K.LBRACE,value:`{`,line:e,column:t};case`}`:return{type:K.RBRACE,value:`}`,line:e,column:t};case`[`:return{type:K.LBRACKET,value:`[`,line:e,column:t};case`]`:return{type:K.RBRACKET,value:`]`,line:e,column:t};case`$`:return{type:K.DOLLAR,value:`$`,line:e,column:t};default:return{type:K.IDENT,value:n,line:e,column:t}}}isDigit(e){return e>=`0`&&e<=`9`}isAlpha(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}}});function mp(e){e.expect(q.PRINT);let t=[];if(e.check(q.NEWLINE)||e.check(q.SEMICOLON)||e.check(q.RBRACE)||e.check(q.PIPE)||e.check(q.GT)||e.check(q.APPEND))t.push({type:`field`,index:{type:`number`,value:0}});else for(e.assertArrayLength(t.length),t.push(hp(e));e.check(q.COMMA);)e.advance(),e.assertArrayLength(t.length),t.push(hp(e));let n;return e.check(q.GT)?(e.advance(),n={redirect:`>`,file:e.parsePrimary()}):e.check(q.APPEND)&&(e.advance(),n={redirect:`>>`,file:e.parsePrimary()}),{type:`print`,args:t,output:n}}function hp(e){return _p(e)?gp(e,!0):gp(e,!1)}function gp(e,t){let n=t?e.parseTernary():vp(e);if(e.match(q.ASSIGN,q.PLUS_ASSIGN,q.MINUS_ASSIGN,q.STAR_ASSIGN,q.SLASH_ASSIGN,q.PERCENT_ASSIGN,q.CARET_ASSIGN)){let r=e.advance(),i=e.withDepth(()=>gp(e,t));if(n.type!==`variable`&&n.type!==`field`&&n.type!==`array_access`)throw Error(`Invalid assignment target`);return{type:`assignment`,operator:new Map([[`=`,`=`],[`+=`,`+=`],[`-=`,`-=`],[`*=`,`*=`],[`/=`,`/=`],[`%=`,`%=`],[`^=`,`^=`]]).get(r.value)??`=`,target:n,value:i}}return n}function _p(e){let t=0,n=e.pos;for(;n<e.tokens.length;){e.useOperation();let r=e.tokens[n];if(r.type===q.LPAREN&&t++,r.type===q.RPAREN&&t--,r.type===q.QUESTION&&t===0)return!0;if(r.type===q.NEWLINE||r.type===q.SEMICOLON||r.type===q.RBRACE||r.type===q.COMMA||r.type===q.PIPE)return!1;n++}return!1}function vp(e){let t=yp(e);for(;e.check(q.OR);){e.advance();let n=yp(e);t={type:`binary`,operator:`||`,left:t,right:n}}return t}function yp(e){let t=bp(e);for(;e.check(q.AND);){e.advance();let n=bp(e);t={type:`binary`,operator:`&&`,left:t,right:n}}return t}function bp(e){let t=xp(e);return e.check(q.IN)?(e.advance(),{type:`in`,key:t,array:String(e.expect(q.IDENT).value)}):t}function xp(e){let t=Sp(e);for(;wp(e)&&!Tp(e);){let n=Sp(e);t={type:`binary`,operator:` `,left:t,right:n}}return t}function Sp(e){let t=Cp(e);for(;e.match(q.MATCH,q.NOT_MATCH);){let n=e.advance().type===q.MATCH?`~`:`!~`,r=Cp(e);t={type:`binary`,operator:n,left:t,right:r}}return t}function Cp(e){let t=e.parseAddSub();for(;e.match(q.LT,q.LE,q.GE,q.EQ,q.NE);){let n=e.advance(),r=e.parseAddSub();t={type:`binary`,operator:new Map([[`<`,`<`],[`<=`,`<=`],[`>=`,`>=`],[`==`,`==`],[`!=`,`!=`]]).get(n.value)??`==`,left:t,right:r}}return t}function wp(e){return e.match(q.NUMBER,q.STRING,q.IDENT,q.DOLLAR,q.LPAREN,q.NOT,q.MINUS,q.PLUS,q.INCREMENT,q.DECREMENT)}function Tp(e){return e.match(q.AND,q.OR,q.QUESTION,q.ASSIGN,q.PLUS_ASSIGN,q.MINUS_ASSIGN,q.STAR_ASSIGN,q.SLASH_ASSIGN,q.PERCENT_ASSIGN,q.CARET_ASSIGN,q.COMMA,q.SEMICOLON,q.NEWLINE,q.RBRACE,q.RPAREN,q.RBRACKET,q.COLON,q.PIPE,q.APPEND,q.GT,q.IN)}function Ep(e){e.expect(q.PRINTF);let t=e.check(q.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():hp(e),r=[];for(;e.check(q.COMMA);)e.advance(),t&&e.skipNewlines(),e.assertArrayLength(r.length),r.push(t?e.parseExpression():hp(e));t&&(e.skipNewlines(),e.expect(q.RPAREN));let i;return e.check(q.GT)?(e.advance(),i={redirect:`>`,file:e.parsePrimary()}):e.check(q.APPEND)&&(e.advance(),i={redirect:`>>`,file:e.parsePrimary()}),{type:`printf`,format:n,args:r,output:i}}var q,Dp=T(()=>{q={LPAREN:`LPAREN`,RPAREN:`RPAREN`,QUESTION:`QUESTION`,NEWLINE:`NEWLINE`,SEMICOLON:`SEMICOLON`,RBRACE:`RBRACE`,COMMA:`COMMA`,PIPE:`PIPE`,GT:`GT`,APPEND:`APPEND`,AND:`AND`,OR:`OR`,ASSIGN:`ASSIGN`,PLUS_ASSIGN:`PLUS_ASSIGN`,MINUS_ASSIGN:`MINUS_ASSIGN`,STAR_ASSIGN:`STAR_ASSIGN`,SLASH_ASSIGN:`SLASH_ASSIGN`,PERCENT_ASSIGN:`PERCENT_ASSIGN`,CARET_ASSIGN:`CARET_ASSIGN`,RBRACKET:`RBRACKET`,COLON:`COLON`,IN:`IN`,PRINT:`PRINT`,PRINTF:`PRINTF`,IDENT:`IDENT`,LT:`LT`,LE:`LE`,GE:`GE`,EQ:`EQ`,NE:`NE`,MATCH:`MATCH`,NOT_MATCH:`NOT_MATCH`,NUMBER:`NUMBER`,STRING:`STRING`,DOLLAR:`DOLLAR`,NOT:`NOT`,MINUS:`MINUS`,PLUS:`PLUS`,INCREMENT:`INCREMENT`,DECREMENT:`DECREMENT`}}),Op,kp=T(()=>{j(),pp(),Dp(),Op=class{tokens=[];pos=0;depth=0;operations=0;limits;constructor(e={}){this.limits={maxSourceLength:e.maxSourceLength??10485760,maxTokens:e.maxTokens??1e5,maxDepth:e.maxDepth??100,maxOperations:e.maxOperations??1e5}}parse(e){if(e.length>this.limits.maxSourceLength)throw new A(`awk: source length limit exceeded (${this.limits.maxSourceLength})`,`string_length`);let t=new fp(e,this.limits.maxTokens);this.tokens=t.tokenize(),this.pos=0,this.depth=0,this.operations=0;let n=0;for(let e of this.tokens)if(this.useOperation(),e.type===K.LPAREN||e.type===K.LBRACKET||e.type===K.LBRACE){if(n++,n>this.limits.maxDepth)throw new A(`awk: parser depth limit exceeded (${this.limits.maxDepth})`,`recursion`)}else(e.type===K.RPAREN||e.type===K.RBRACKET||e.type===K.RBRACE)&&(n=Math.max(0,n-1));return this.parseProgram()}setPos(e){this.pos=e}current(){return this.tokens[this.pos]||{type:K.EOF,value:``,line:0,column:0}}advance(){this.useOperation();let e=this.current();return this.pos<this.tokens.length&&this.pos++,e}useOperation(e=1){if(e>this.limits.maxOperations-this.operations)throw new A(`awk: parser operation limit exceeded (${this.limits.maxOperations})`,`iterations`);this.operations+=e}withDepth(e){if(this.depth>=this.limits.maxDepth)throw new A(`awk: parser depth limit exceeded (${this.limits.maxDepth})`,`recursion`);this.depth++;try{return e()}finally{this.depth--}}assertArrayLength(e){if(e>=this.limits.maxTokens)throw new A(`awk: AST array limit exceeded (${this.limits.maxTokens})`,`array_elements`)}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,t){if(!this.check(e)){let n=this.current();throw Error(t||`Expected ${e}, got ${n.type} at line ${n.line}:${n.column}`)}return this.advance()}skipNewlines(){for(;this.check(K.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(K.NEWLINE)||this.check(K.SEMICOLON);)this.advance()}parseProgram(){let e=[],t=[];for(this.skipNewlines();!this.check(K.EOF)&&(this.skipNewlines(),!this.check(K.EOF));)this.check(K.FUNCTION)?e.push(this.parseFunction()):t.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:t}}parseFunction(){this.expect(K.FUNCTION);let e=this.expect(K.IDENT).value;this.expect(K.LPAREN);let t=[];if(!this.check(K.RPAREN))for(t.push(this.expect(K.IDENT).value);this.check(K.COMMA);)this.advance(),t.push(this.expect(K.IDENT).value);return this.expect(K.RPAREN),this.skipNewlines(),{name:e,params:t,body:this.parseBlock()}}parseRule(){let e;if(this.check(K.BEGIN))this.advance(),e={type:`begin`};else if(this.check(K.END))this.advance(),e={type:`end`};else if(this.check(K.LBRACE))e=void 0;else if(this.check(K.REGEX)){let t=this.advance();if(this.check(K.AND)||this.check(K.OR)){let n={type:`binary`,operator:`~`,left:{type:`field`,index:{type:`number`,value:0}},right:{type:`regex`,pattern:t.value}};e={type:`expr_pattern`,expression:this.parseLogicalOrRest(n)}}else{let n={type:`regex_pattern`,pattern:t.value};if(this.check(K.COMMA)){this.advance();let t;t=this.check(K.REGEX)?{type:`regex_pattern`,pattern:this.advance().value}:{type:`expr_pattern`,expression:this.parseExpression()},e={type:`range`,start:n,end:t}}else e=n}}else{let t={type:`expr_pattern`,expression:this.parseExpression()};if(this.check(K.COMMA)){this.advance();let n;n=this.check(K.REGEX)?{type:`regex_pattern`,pattern:this.advance().value}:{type:`expr_pattern`,expression:this.parseExpression()},e={type:`range`,start:t,end:n}}else e=t}this.skipNewlines();let t;return t=this.check(K.LBRACE)?this.parseBlock():{type:`block`,statements:[{type:`print`,args:[{type:`field`,index:{type:`number`,value:0}}]}]},{pattern:e,action:t}}parseBlock(){this.expect(K.LBRACE),this.skipNewlines();let e=[];for(;!this.check(K.RBRACE)&&!this.check(K.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(K.RBRACE),{type:`block`,statements:e}}parseStatement(){return this.withDepth(()=>this.parseStatementAtDepth())}parseStatementAtDepth(){if(this.check(K.SEMICOLON)||this.check(K.NEWLINE))return this.advance(),{type:`block`,statements:[]};if(this.check(K.LBRACE))return this.parseBlock();if(this.check(K.IF))return this.parseIf();if(this.check(K.WHILE))return this.parseWhile();if(this.check(K.DO))return this.parseDoWhile();if(this.check(K.FOR))return this.parseFor();if(this.check(K.BREAK))return this.advance(),{type:`break`};if(this.check(K.CONTINUE))return this.advance(),{type:`continue`};if(this.check(K.NEXT))return this.advance(),{type:`next`};if(this.check(K.NEXTFILE))return this.advance(),{type:`nextfile`};if(this.check(K.EXIT)){this.advance();let e;return!this.check(K.NEWLINE)&&!this.check(K.SEMICOLON)&&!this.check(K.RBRACE)&&!this.check(K.EOF)&&(e=this.parseExpression()),{type:`exit`,code:e}}if(this.check(K.RETURN)){this.advance();let e;return!this.check(K.NEWLINE)&&!this.check(K.SEMICOLON)&&!this.check(K.RBRACE)&&!this.check(K.EOF)&&(e=this.parseExpression()),{type:`return`,value:e}}if(this.check(K.DELETE)){this.advance();let e=this.parsePrimary();if(e.type!==`array_access`&&e.type!==`variable`)throw Error(`delete requires array element or array`);return{type:`delete`,target:e}}return this.check(K.PRINT)?mp(this):this.check(K.PRINTF)?Ep(this):{type:`expr_stmt`,expression:this.parseExpression()}}parseIf(){this.expect(K.IF),this.expect(K.LPAREN);let e=this.parseExpression();this.expect(K.RPAREN),this.skipNewlines();let t=this.parseStatement();this.skipTerminators();let n;return this.check(K.ELSE)&&(this.advance(),this.skipNewlines(),n=this.parseStatement()),{type:`if`,condition:e,consequent:t,alternate:n}}parseWhile(){this.expect(K.WHILE),this.expect(K.LPAREN);let e=this.parseExpression();return this.expect(K.RPAREN),this.skipNewlines(),{type:`while`,condition:e,body:this.parseStatement()}}parseDoWhile(){this.expect(K.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(K.WHILE),this.expect(K.LPAREN);let t=this.parseExpression();return this.expect(K.RPAREN),{type:`do_while`,body:e,condition:t}}parseFor(){if(this.expect(K.FOR),this.expect(K.LPAREN),this.check(K.IDENT)){let e=this.advance();if(this.check(K.IN)){this.advance();let t=this.expect(K.IDENT).value;this.expect(K.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:`for_in`,variable:e.value,array:t,body:n}}this.pos--}let e;this.check(K.SEMICOLON)||(e=this.parseExpression()),this.expect(K.SEMICOLON);let t;this.check(K.SEMICOLON)||(t=this.parseExpression()),this.expect(K.SEMICOLON);let n;this.check(K.RPAREN)||(n=this.parseExpression()),this.expect(K.RPAREN),this.skipNewlines();let r=this.parseStatement();return{type:`for`,init:e,condition:t,update:n,body:r}}parseExpression(){return this.withDepth(()=>this.parseAssignment())}parseAssignment(){let e=this.parseTernary();if(this.match(K.ASSIGN,K.PLUS_ASSIGN,K.MINUS_ASSIGN,K.STAR_ASSIGN,K.SLASH_ASSIGN,K.PERCENT_ASSIGN,K.CARET_ASSIGN)){let t=this.advance(),n=this.parseExpression();if(e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid assignment target`);let r=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`^=`]),i=t.value;if(!r.has(i))throw Error(`Unknown assignment operator: ${i}`);return{type:`assignment`,operator:i,target:e,value:n}}return e}parseTernary(){let e=this.parsePipeGetline();if(this.check(K.QUESTION)){this.advance();let t=this.parseExpression();this.expect(K.COLON);let n=this.parseExpression();e={type:`ternary`,condition:e,consequent:t,alternate:n}}return e}parsePipeGetline(){let e=this.parseOr();if(this.check(K.PIPE)){if(this.advance(),!this.check(K.GETLINE))throw Error(`Expected 'getline' after '|' in expression context`);this.advance();let t;return this.check(K.IDENT)&&(t=this.advance().value),{type:`getline`,command:e,variable:t}}return e}parseOr(){let e=this.parseAnd();for(;this.check(K.OR);){this.advance();let t=this.parseAnd();e={type:`binary`,operator:`||`,left:e,right:t}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(K.OR);){this.advance();let t=this.parseAnd();e={type:`binary`,operator:`||`,left:e,right:t}}return e}parseLogicalAndRest(e){for(;this.check(K.AND);){this.advance();let t=this.parseIn();e={type:`binary`,operator:`&&`,left:e,right:t}}return e}parseAnd(){let e=this.parseIn();for(;this.check(K.AND);){this.advance();let t=this.parseIn();e={type:`binary`,operator:`&&`,left:e,right:t}}return e}parseIn(){let e=this.parseConcatenation();return this.check(K.IN)?(this.advance(),{type:`in`,key:e,array:this.expect(K.IDENT).value}):e}parseConcatenation(){let e=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let t=this.parseMatch();e={type:`binary`,operator:` `,left:e,right:t}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(K.MATCH,K.NOT_MATCH);){let t=this.advance().type===K.MATCH?`~`:`!~`,n=this.parseComparison();e={type:`binary`,operator:t,left:e,right:n}}return e}parseComparison(){let e=this.parseAddSub();for(;this.match(K.LT,K.LE,K.GT,K.GE,K.EQ,K.NE);){let t=this.advance(),n=this.parseAddSub();e={type:`binary`,operator:new Map([[`<`,`<`],[`<=`,`<=`],[`>`,`>`],[`>=`,`>=`],[`==`,`==`],[`!=`,`!=`]]).get(t.value)??`==`,left:e,right:n}}return e}canStartExpression(){return this.match(K.NUMBER,K.STRING,K.IDENT,K.DOLLAR,K.LPAREN,K.NOT,K.MINUS,K.PLUS,K.INCREMENT,K.DECREMENT)}isConcatTerminator(){return this.match(K.AND,K.OR,K.QUESTION,K.ASSIGN,K.PLUS_ASSIGN,K.MINUS_ASSIGN,K.STAR_ASSIGN,K.SLASH_ASSIGN,K.PERCENT_ASSIGN,K.CARET_ASSIGN,K.COMMA,K.SEMICOLON,K.NEWLINE,K.RBRACE,K.RPAREN,K.RBRACKET,K.COLON,K.PIPE,K.APPEND,K.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(K.PLUS,K.MINUS);){let t=this.advance().value,n=this.parseMulDiv();e={type:`binary`,operator:t,left:e,right:n}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(K.STAR,K.SLASH,K.PERCENT);){let t=this.advance(),n=this.parseUnary();e={type:`binary`,operator:new Map([[`*`,`*`],[`/`,`/`],[`%`,`%`]]).get(t.value)??`*`,left:e,right:n}}return e}parseUnary(){if(this.check(K.INCREMENT)){this.advance();let e=this.withDepth(()=>this.parseUnary());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`+`,operand:{type:`unary`,operator:`+`,operand:e}}:{type:`pre_increment`,operand:e}}if(this.check(K.DECREMENT)){this.advance();let e=this.withDepth(()=>this.parseUnary());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`-`,operand:{type:`unary`,operator:`-`,operand:e}}:{type:`pre_decrement`,operand:e}}return this.match(K.NOT,K.MINUS,K.PLUS)?{type:`unary`,operator:this.advance().value,operand:this.withDepth(()=>this.parseUnary())}:this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(K.CARET)){this.advance();let t=this.withDepth(()=>this.parsePower());e={type:`binary`,operator:`^`,left:e,right:t}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(K.INCREMENT)){if(this.advance(),e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid increment operand`);return{type:`post_increment`,operand:e}}if(this.check(K.DECREMENT)){if(this.advance(),e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid decrement operand`);return{type:`post_decrement`,operand:e}}return e}parseFieldIndex(){if(this.check(K.INCREMENT)){this.advance();let e=this.withDepth(()=>this.parseFieldIndex());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`+`,operand:{type:`unary`,operator:`+`,operand:e}}:{type:`pre_increment`,operand:e}}if(this.check(K.DECREMENT)){this.advance();let e=this.withDepth(()=>this.parseFieldIndex());return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`-`,operand:{type:`unary`,operator:`-`,operand:e}}:{type:`pre_decrement`,operand:e}}return this.match(K.NOT,K.MINUS,K.PLUS)?{type:`unary`,operator:this.advance().value,operand:this.withDepth(()=>this.parseFieldIndex())}:this.parseFieldIndexPower()}parseFieldIndexPower(){let e=this.parseFieldIndexPrimary();if(this.check(K.CARET)){this.advance();let t=this.withDepth(()=>this.parseFieldIndexPower());e={type:`binary`,operator:`^`,left:e,right:t}}return e}parseFieldIndexPrimary(){if(this.check(K.NUMBER))return{type:`number`,value:this.advance().value};if(this.check(K.STRING))return{type:`string`,value:this.advance().value};if(this.check(K.DOLLAR))return this.advance(),{type:`field`,index:this.parseFieldIndex()};if(this.check(K.LPAREN)){this.advance();let e=this.parseExpression();return this.expect(K.RPAREN),e}if(this.check(K.IDENT)){let e=this.advance().value;if(this.check(K.LPAREN)){this.advance();let t=[];if(!this.check(K.RPAREN))for(t.push(this.parseExpression());this.check(K.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(K.RPAREN),{type:`call`,name:e,args:t}}if(this.check(K.LBRACKET)){this.advance();let t=this.parseExpression();if(this.check(K.COMMA)){let n=[t];for(;this.check(K.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(K.RBRACKET),{type:`array_access`,array:e,key:n.reduce((e,t)=>({type:`binary`,operator:` `,left:{type:`binary`,operator:` `,left:e,right:{type:`variable`,name:`SUBSEP`}},right:t}))}}return this.expect(K.RBRACKET),{type:`array_access`,array:e,key:t}}return{type:`variable`,name:e}}throw Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(K.NUMBER))return{type:`number`,value:this.advance().value};if(this.check(K.STRING))return{type:`string`,value:this.advance().value};if(this.check(K.REGEX))return{type:`regex`,pattern:this.advance().value};if(this.check(K.DOLLAR))return this.advance(),{type:`field`,index:this.parseFieldIndex()};if(this.check(K.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(K.COMMA)){let t=[e];for(;this.check(K.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(K.RPAREN),{type:`tuple`,elements:t}}return this.expect(K.RPAREN),e}if(this.check(K.GETLINE)){this.advance();let e,t;return this.check(K.IDENT)&&(e=this.advance().value),this.check(K.LT)&&(this.advance(),t=this.parsePrimary()),{type:`getline`,variable:e,file:t}}if(this.check(K.IDENT)){let e=this.advance().value;if(this.check(K.LPAREN)){this.advance();let t=[];if(this.skipNewlines(),!this.check(K.RPAREN))for(t.push(this.parseExpression());this.check(K.COMMA);)this.advance(),this.skipNewlines(),t.push(this.parseExpression());return this.skipNewlines(),this.expect(K.RPAREN),{type:`call`,name:e,args:t}}if(this.check(K.LBRACKET)){this.advance();let t=[this.parseExpression()];for(;this.check(K.COMMA);)this.advance(),t.push(this.parseExpression());this.expect(K.RBRACKET);let n;if(t.length===1)n=t[0];else{n=t[0];for(let e=1;e<t.length;e++)n={type:`binary`,operator:` `,left:{type:`binary`,operator:` `,left:n,right:{type:`variable`,name:`SUBSEP`}},right:t[e]}}return{type:`array_access`,array:e,key:n}}return{type:`variable`,name:e}}throw Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}}}),Ap={};E(Ap,{awkCommand2:()=>Fp,flagsForFuzzing:()=>Ip});function jp(e){return e.replace(/\\t/g,` `).replace(/\\n/g,`
417
+ `).replace(/\\r/g,`\r`).replace(/\\b/g,`\b`).replace(/\\f/g,`\f`).replace(/\\a/g,`\x07`).replace(/\\v/g,`\v`).replace(/\\\\/g,`\\`)}function Mp(e){if(e===` `)return U(`\\s+`);if(/[[\](){}.*+?^$|\\]/.test(e))try{return U(e)}catch{return U(Np(e))}return U(Np(e))}function Np(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var Pp,Fp,Ip,Lp=T(()=>{k(),Wr(),od(),j(),mc(),Su(),qn(),F(),Lr(),cp(),kp(),Pp={name:`awk`,summary:`pattern scanning and text processing language`,usage:`awk [OPTIONS] 'PROGRAM' [FILE...]`,options:[`-F FS use FS as field separator`,`-v VAR=VAL assign VAL to variable VAR`,` --help display this help and exit`]},Fp={name:`awk`,async execute(e,t){bu(t.requireDefenseContext,`awk`,`execution entry`);let n=(e,n)=>xu(t.requireDefenseContext,`awk`,e,n);if(N(e))return M(Pp);let r=new fc(/\s+/),i=` `,a=Object.create(null),o=0;for(let t=0;t<e.length;t++){let n=e[t];if(n===`-F`&&t+1<e.length)i=jp(e[++t]),r=Mp(i),o=t+1;else if(n.startsWith(`-F`))i=jp(n.slice(2)),r=Mp(i),o=t+1;else if(n===`-v`&&t+1<e.length){let n=e[++t],r=n.indexOf(`=`);if(r>0){let e=n.slice(0,r);a[e]=jp(n.slice(r+1))}o=t+1}else{if(n.startsWith(`--`))return P(`awk`,n);if(n.startsWith(`-`)&&n.length>1){let e=n[1];if(e!==`F`&&e!==`v`)return P(`awk`,`-${e}`);o=t+1}else if(!n.startsWith(`-`)){o=t;break}}}if(o>=e.length)return{stdout:``,stderr:`awk: missing program
418
+ `,exitCode:1};let s=e[o],c=e.slice(o+1),l=new Op({maxSourceLength:t.limits.maxStringLength,maxTokens:t.limits.maxAwkParserTokens,maxDepth:t.limits.maxAwkParserDepth,maxOperations:t.limits.maxAwkParserOperations}),u;try{u=l.parse(s)}catch(e){return Ur(e),{stdout:``,stderr:`awk: ${e instanceof Error?e.message:String(e)}
419
+ `,exitCode:1}}let d={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(e,r)=>{try{let i=await n(`appendFile read`,()=>t.fs.readFile(e));await n(`appendFile write`,()=>t.fs.writeFile(e,i+r))}catch(i){if(i instanceof D)throw i;await n(`appendFile create`,()=>t.fs.writeFile(e,r))}},resolvePath:t.fs.resolvePath.bind(t.fs)},f=t.exec,p=sd({fieldSep:r,maxIterations:t.limits.maxAwkIterations,maxOutputSize:Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),maxArrayElements:t.limits.maxArrayElements,fs:d,cwd:t.cwd,exec:f?e=>n(`command pipe exec`,()=>f(e,{cwd:t.cwd,signal:t.signal})):void 0,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext});p.FS=i,p.vars=Object.assign(Object.create(null),a),p.ARGC=c.length+1,p.ARGV=Object.create(null),p.ARGV[0]=`awk`;for(let e=0;e<c.length;e++)p.ARGV[String(e+1)]=c[e];p.ENVIRON=rd(t.env);let m=new op(p);m.execute(u);let h=u.rules.some(e=>e.pattern?.type!==`begin`&&e.pattern?.type!==`end`),g=u.rules.some(e=>e.pattern?.type===`end`);try{if(await n(`BEGIN execution`,()=>m.executeBegin()),p.shouldExit)return await n(`END execution after BEGIN exit`,()=>m.executeEnd()),{stdout:m.getOutput(),stderr:``,exitCode:m.getExitCode()};if(!h&&!g)return{stdout:m.getOutput(),stderr:``,exitCode:m.getExitCode()};let e=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),r=t.limits.maxArrayElements,i=0,a=async(t,a)=>{let o=O(a);if(o>e-i)throw new A(`aggregate input size limit exceeded (${e} bytes)`,`string_length`);i+=o;let s=+(a.length>0);for(let e=0;e<a.length;e++)if(a.charCodeAt(e)===10&&s++,s>r+1)throw new A(`record array limit exceeded (${r})`,`array_elements`);let c=a.split(`
420
+ `);if(c.length>0&&c[c.length-1]===``&&c.pop(),c.length>r)throw new A(`record array limit exceeded (${r})`,`array_elements`);for(p.FILENAME=t,p.FNR=0,p.lines=c,p.lineIndex=-1,p.shouldNextFile=!1;p.lineIndex<c.length-1;){p.lineIndex++;let e=p.lineIndex;if(await n(`line execution`,()=>m.executeLine(c[e])),p.shouldExit||p.shouldNextFile)break}};if(c.length>0)for(let r of c){let o;try{let a=t.fs.resolvePath(t.cwd,r);if((await n(`input file stat`,()=>t.fs.stat(a))).size>e-i)throw new A(`aggregate input size limit exceeded (${e} bytes)`,`string_length`);o=await n(`input file read`,()=>t.fs.readFile(a))}catch(e){if(e instanceof D||e instanceof A)throw e;return{stdout:``,stderr:`awk: ${r}: No such file or directory
421
+ `,exitCode:1}}if(await n(`input processing`,()=>a(r,o)),p.shouldExit)break}else await n(`stdin processing`,()=>a(``,or(t.stdin)));return await n(`END execution`,()=>m.executeEnd()),{stdout:m.getOutput(),stderr:``,exitCode:m.getExitCode()}}catch(e){if(e instanceof D)throw e;let t=e instanceof Error?e.message:String(e),n=e instanceof A?A.EXIT_CODE:2;return{stdout:m.getOutput(),stderr:`awk: ${t}
422
+ `,exitCode:n}}}},Ip={name:`awk`,flags:[{flag:`-F`,type:`value`,valueHint:`delimiter`},{flag:`-v`,type:`value`,valueHint:`string`}],stdinType:`text`,needsArgs:!0}});function Rp(e){let t=e.trim(),n=t.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!n){let e=parseFloat(t);return Number.isNaN(e)?0:e}let r=parseFloat(n[1]),i=(n[2]||``).toLowerCase();return r*(Kp.get(i)??1)}function zp(e){let t=e.trim().toLowerCase().slice(0,3);return qp.get(t)??0}function Bp(e,t){let n=e.split(/(\d+)/),r=t.split(/(\d+)/),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]||``,i=r[e]||``,a=/^\d+$/.test(t)?parseInt(t,10):null,o=/^\d+$/.test(i)?parseInt(i,10):null;if(a!==null&&o!==null){if(a!==o)return a-o}else if(t!==i)return t.localeCompare(i)}return 0}function Vp(e){return e.replace(/[^a-zA-Z0-9\s]/g,``)}function Hp(e,t,n){let r=n===null?/\s+/:n,i=e.split(r),a=t.startField-1;if(a>=i.length)return``;if(t.endField===void 0){let e=i[a]||``;return t.startChar!==void 0&&(e=e.slice(t.startChar-1)),t.ignoreLeading&&(e=e.trimStart()),e}let o=Math.min(t.endField-1,i.length-1),s=``;for(let e=a;e<=o&&e<i.length;e++){let r=i[e]||``;if(e===a&&t.startChar!==void 0&&(r=r.slice(t.startChar-1)),e===o&&t.endChar!==void 0){let n=e===a&&t.startChar!==void 0?t.endChar-t.startChar+1:t.endChar;r=r.slice(0,n)}e>a&&(s+=n||` `),s+=r}return t.ignoreLeading&&(s=s.trimStart()),s}function Up(e,t,n){let r=e,i=t;return n.dictionaryOrder&&(r=Vp(r),i=Vp(i)),n.ignoreCase&&(r=r.toLowerCase(),i=i.toLowerCase()),n.monthSort?zp(r)-zp(i):n.humanNumeric?Rp(r)-Rp(i):n.versionSort?Bp(r,i):n.numeric?(parseFloat(r)||0)-(parseFloat(i)||0):r.localeCompare(i)}function Wp(e){let{keys:t,fieldDelimiter:n,numeric:r,ignoreCase:i,reverse:a,humanNumeric:o,versionSort:s,dictionaryOrder:c,monthSort:l,ignoreLeadingBlanks:u,stable:d}=e;return(e,f)=>{let p=e,m=f;if(u&&(p=p.trimStart(),m=m.trimStart()),t.length===0){let t=Up(p,m,{numeric:r,ignoreCase:i,humanNumeric:o,versionSort:s,dictionaryOrder:c,monthSort:l});if(t!==0)return a?-t:t;if(!d){let t=e.localeCompare(f);return a?-t:t}return 0}for(let e of t){let t=Hp(p,e,n),u=Hp(m,e,n);e.ignoreLeading&&(t=t.trimStart(),u=u.trimStart());let d={numeric:e.numeric??r,ignoreCase:e.ignoreCase??i,humanNumeric:e.humanNumeric??o,versionSort:e.versionSort??s,dictionaryOrder:e.dictionaryOrder??c,monthSort:e.monthSort??l},f=e.reverse??a,h=Up(t,u,d);if(h!==0)return f?-h:h}if(!d){let t=e.localeCompare(f);return a?-t:t}return 0}}function Gp(e,t){if(t.keys.length===0){if(t.ignoreCase){let t=new Set;return e.filter(e=>{let n=e.toLowerCase();return!t.has(n)&&(t.add(n),!0)})}return[...new Set(e)]}let n=t.keys[0],r=new Set;return e.filter(e=>{let i=Hp(e,n,t.fieldDelimiter);return(n.ignoreCase??t.ignoreCase)&&(i=i.toLowerCase()),!r.has(i)&&(r.add(i),!0)})}var Kp,qp,Jp=T(()=>{Kp=new Map([[``,1],[`k`,1024],[`m`,1048576],[`g`,1073741824],[`t`,1099511627776],[`p`,0x4000000000000],[`e`,0x1000000000000000]]),qp=new Map([[`jan`,1],[`feb`,2],[`mar`,3],[`apr`,4],[`may`,5],[`jun`,6],[`jul`,7],[`aug`,8],[`sep`,9],[`oct`,10],[`nov`,11],[`dec`,12]])});function Yp(e){let t={startField:1},n=``,r=e,i=r.match(/([bdfhMnrV]+)$/);i&&(n=i[1],r=r.slice(0,-n.length)),n.includes(`n`)&&(t.numeric=!0),n.includes(`r`)&&(t.reverse=!0),n.includes(`f`)&&(t.ignoreCase=!0),n.includes(`b`)&&(t.ignoreLeading=!0),n.includes(`h`)&&(t.humanNumeric=!0),n.includes(`V`)&&(t.versionSort=!0),n.includes(`d`)&&(t.dictionaryOrder=!0),n.includes(`M`)&&(t.monthSort=!0);let a=r.split(`,`);if(a.length===0||a[0]===``)return null;let o=a[0].split(`.`),s=parseInt(o[0],10);if(Number.isNaN(s)||s<1)return null;if(t.startField=s,o.length>1&&o[1]){let e=parseInt(o[1],10);!Number.isNaN(e)&&e>=1&&(t.startChar=e)}if(a.length>1&&a[1]){let e=a[1],n=e.match(/([bdfhMnrV]+)$/);if(n){let r=n[1];r.includes(`n`)&&(t.numeric=!0),r.includes(`r`)&&(t.reverse=!0),r.includes(`f`)&&(t.ignoreCase=!0),r.includes(`b`)&&(t.ignoreLeading=!0),r.includes(`h`)&&(t.humanNumeric=!0),r.includes(`V`)&&(t.versionSort=!0),r.includes(`d`)&&(t.dictionaryOrder=!0),r.includes(`M`)&&(t.monthSort=!0),e=e.slice(0,-r.length)}let r=e.split(`.`);if(r[0]){let e=parseInt(r[0],10);if(!Number.isNaN(e)&&e>=1&&(t.endField=e),r.length>1&&r[1]){let e=parseInt(r[1],10);!Number.isNaN(e)&&e>=1&&(t.endChar=e)}}}return t}var Xp=T(()=>{}),Zp={};E(Zp,{flagsForFuzzing:()=>em,sortCommand:()=>$p});var Qp,$p,em,tm=T(()=>{k(),Zr(),F(),Jp(),Xp(),Qp={name:`sort`,summary:`sort lines of text files`,usage:`sort [OPTION]... [FILE]...`,options:[`-b, --ignore-leading-blanks ignore leading blanks`,`-d, --dictionary-order consider only blanks and alphanumeric characters`,`-f, --ignore-case fold lower case to upper case characters`,`-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)`,`-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'`,`-n, --numeric-sort compare according to string numerical value`,`-r, --reverse reverse the result of comparisons`,`-V, --version-sort natural sort of (version) numbers within text`,`-c, --check check for sorted input; do not sort`,`-o, --output=FILE write result to FILE instead of stdout`,`-s, --stable stabilize sort by disabling last-resort comparison`,`-u, --unique output only unique lines`,`-k, --key=KEYDEF sort via a key; KEYDEF gives location and type`,`-t, --field-separator=SEP use SEP as field separator`,` --help display this help and exit`],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
423
+ F is a field number (1-indexed)
424
+ C is a character position within the field (1-indexed)
425
+ OPTS can be: b d f h M n r V (per-key modifiers)
426
+
427
+ Examples:
428
+ -k1 sort by first field
429
+ -k2,2 sort by second field only
430
+ -k1.3 sort by first field starting at 3rd character
431
+ -k1,2n sort by fields 1-2 numerically
432
+ -k2 -k1 sort by field 2, then by field 1`},$p={name:`sort`,async execute(e,t){if(N(e))return M(Qp);let n={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},r=[];for(let t=0;t<e.length;t++){let i=e[t];if(i===`-r`||i===`--reverse`)n.reverse=!0;else if(i===`-n`||i===`--numeric-sort`)n.numeric=!0;else if(i===`-u`||i===`--unique`)n.unique=!0;else if(i===`-f`||i===`--ignore-case`)n.ignoreCase=!0;else if(i===`-h`||i===`--human-numeric-sort`)n.humanNumeric=!0;else if(i===`-V`||i===`--version-sort`)n.versionSort=!0;else if(i===`-d`||i===`--dictionary-order`)n.dictionaryOrder=!0;else if(i===`-M`||i===`--month-sort`)n.monthSort=!0;else if(i===`-b`||i===`--ignore-leading-blanks`)n.ignoreLeadingBlanks=!0;else if(i===`-s`||i===`--stable`)n.stable=!0;else if(i===`-c`||i===`--check`)n.checkOnly=!0;else if(i===`-o`||i===`--output`)n.outputFile=e[++t]||null;else if(i.startsWith(`-o`))n.outputFile=i.slice(2)||null;else if(i.startsWith(`--output=`))n.outputFile=i.slice(9)||null;else if(i===`-t`||i===`--field-separator`)n.fieldDelimiter=e[++t]||null;else if(i.startsWith(`-t`))n.fieldDelimiter=i.slice(2)||null;else if(i.startsWith(`--field-separator=`))n.fieldDelimiter=i.slice(18)||null;else if(i===`-k`||i===`--key`){let r=e[++t];if(r){let e=Yp(r);e&&n.keys.push(e)}}else if(i.startsWith(`-k`)){let e=Yp(i.slice(2));e&&n.keys.push(e)}else if(i.startsWith(`--key=`)){let e=Yp(i.slice(6));e&&n.keys.push(e)}else{if(i.startsWith(`--`))return P(`sort`,i);if(i.startsWith(`-`)&&!i.startsWith(`--`)){let e=!1;for(let t of i.slice(1))if(t===`r`)n.reverse=!0;else if(t===`n`)n.numeric=!0;else if(t===`u`)n.unique=!0;else if(t===`f`)n.ignoreCase=!0;else if(t===`h`)n.humanNumeric=!0;else if(t===`V`)n.versionSort=!0;else if(t===`d`)n.dictionaryOrder=!0;else if(t===`M`)n.monthSort=!0;else if(t===`b`)n.ignoreLeadingBlanks=!0;else if(t===`s`)n.stable=!0;else if(t===`c`)n.checkOnly=!0;else{e=!0;break}if(e)return P(`sort`,i)}else r.push(i)}}let i=await Xr(t,r,{cmdName:`sort`});if(!i.ok)return i.error;let a=or(i.content).split(`
433
+ `);a.length>0&&a[a.length-1]===``&&a.pop();let o=Wp(n);if(n.checkOnly){let e=r.length>0?r[0]:`-`;for(let t=1;t<a.length;t++)if(o(a[t-1],a[t])>0)return{stdout:``,stderr:`sort: ${e}:${t+1}: disorder: ${a[t]}
434
+ `,exitCode:1};return{stdout:``,stderr:``,exitCode:0}}a.sort(o),n.unique&&(a=Gp(a,n));let s=a.length>0?`${a.join(`
435
+ `)}
436
+ `:``;if(n.outputFile){let e=t.fs.resolvePath(t.cwd,n.outputFile);return await t.fs.writeFile(e,s),{stdout:``,stderr:``,exitCode:0}}return{stdout:s,stderr:``,exitCode:0}}},em={name:`sort`,flags:[{flag:`-r`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-u`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-V`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-M`,type:`boolean`},{flag:`-b`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-k`,type:`value`,valueHint:`string`},{flag:`-t`,type:`value`,valueHint:`delimiter`},{flag:`-o`,type:`value`,valueHint:`path`}],stdinType:`text`,needsFiles:!0}}),nm={};E(nm,{flagsForFuzzing:()=>om,uniqCommand:()=>am});var rm,im,am,om,sm=T(()=>{k(),Kr(),Zr(),F(),rm={name:`uniq`,summary:`report or omit repeated lines`,usage:`uniq [OPTION]... [INPUT [OUTPUT]]`,options:[`-c, --count prefix lines by the number of occurrences`,`-d, --repeated only print duplicate lines`,`-i, --ignore-case ignore case when comparing`,`-u, --unique only print unique lines`,` --help display this help and exit`]},im={count:{short:`c`,long:`count`,type:`boolean`},duplicatesOnly:{short:`d`,long:`repeated`,type:`boolean`},uniqueOnly:{short:`u`,long:`unique`,type:`boolean`},ignoreCase:{short:`i`,long:`ignore-case`,type:`boolean`}},am={name:`uniq`,async execute(e,t){if(N(e))return M(rm);let n=Gr(`uniq`,e,im);if(!n.ok)return n.error;let{count:r,duplicatesOnly:i,uniqueOnly:a,ignoreCase:o}=n.result.flags,s=n.result.positional,c=await Xr(t,s,{cmdName:`uniq`});if(!c.ok)return c.error;let l=(o?or(c.content):c.content).split(`
437
+ `);if(l.length>0&&l[l.length-1]===``&&l.pop(),l.length===0)return{stdout:``,stderr:``,exitCode:0};let u=[],d=l[0],f=1,p=(e,t)=>o?e.toLowerCase()===t.toLowerCase():e===t;for(let e=1;e<l.length;e++)p(l[e],d)?f++:(u.push({line:d,count:f}),d=l[e],f=1);u.push({line:d,count:f});let m=u;i?m=u.filter(e=>e.count>1):a&&(m=u.filter(e=>e.count===1));let h=``;for(let{line:e,count:t}of m)h+=r?`${String(t).padStart(4)} ${e}
438
+ `:`${e}
439
+ `;return o?{stdout:h,stderr:``,exitCode:0}:{stdout:h,stderr:``,exitCode:0,stdoutKind:`bytes`,stdoutEncoding:`binary`}}},om={name:`uniq`,flags:[{flag:`-c`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-u`,type:`boolean`},{flag:`-i`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),cm={};E(cm,{commCommand:()=>um,flagsForFuzzing:()=>dm});var lm,um,dm,fm=T(()=>{k(),F(),lm={name:`comm`,summary:`compare two sorted files line by line`,usage:`comm [OPTION]... FILE1 FILE2`,options:[`-1 suppress column 1 (lines unique to FILE1)`,`-2 suppress column 2 (lines unique to FILE2)`,`-3 suppress column 3 (lines that appear in both files)`,` --help display this help and exit`]},um={name:`comm`,async execute(e,t){if(N(e))return M(lm);let n=!1,r=!1,i=!1,a=[];for(let t of e)if(t===`-1`)n=!0;else if(t===`-2`)r=!0;else if(t===`-3`)i=!0;else if(t===`-12`||t===`-21`)n=!0,r=!0;else if(t===`-13`||t===`-31`)n=!0,i=!0;else if(t===`-23`||t===`-32`)r=!0,i=!0;else if(t===`-123`||t===`-132`||t===`-213`||t===`-231`||t===`-312`||t===`-321`)n=!0,r=!0,i=!0;else{if(t.startsWith(`-`)&&t!==`-`)return P(`comm`,t);a.push(t)}if(a.length!==2)return{stdout:``,stderr:`comm: missing operand
440
+ Try 'comm --help' for more information.
441
+ `,exitCode:1};let o=async e=>{if(e===`-`)return or(t.stdin);try{let n=t.fs.resolvePath(t.cwd,e);return await t.fs.readFile(n)}catch{return null}},s=await o(a[0]);if(s===null)return{stdout:``,stderr:`comm: ${a[0]}: No such file or directory
442
+ `,exitCode:1};let c=await o(a[1]);if(c===null)return{stdout:``,stderr:`comm: ${a[1]}: No such file or directory
443
+ `,exitCode:1};let l=s.split(`
444
+ `),u=c.split(`
445
+ `);l.length>0&&l[l.length-1]===``&&l.pop(),u.length>0&&u[u.length-1]===``&&u.pop();let d=0,f=0,p=``,m=n?``:` `,h=(n?``:` `)+(r?``:` `);for(;d<l.length||f<u.length;)d>=l.length?(r||(p+=`${m}${u[f]}
446
+ `),f++):f>=u.length||l[d]<u[f]?(n||(p+=`${l[d]}
447
+ `),d++):l[d]>u[f]?(r||(p+=`${m}${u[f]}
448
+ `),f++):(i||(p+=`${h}${l[d]}
449
+ `),d++,f++);return{stdout:p,stderr:``,exitCode:0}}},dm={name:`comm`,flags:[{flag:`-1`,type:`boolean`},{flag:`-2`,type:`boolean`},{flag:`-3`,type:`boolean`}],needsArgs:!0,minArgs:2}}),pm={};E(pm,{cutCommand:()=>_m,flagsForFuzzing:()=>vm});function mm(e,t){let n=[],r=e.split(`,`);if(r.length>t)throw new A(`cut: range count limit exceeded (${t})`,`array_elements`);for(let e of r)if(e.includes(`-`)){let[t,r]=e.split(`-`),i=t?Number(t):1,a=r?Number(r):null;if(!Number.isSafeInteger(i)||i<1||a!==null&&(!Number.isSafeInteger(a)||a<i))throw new A(`cut: invalid range`,`array_elements`);n.push({start:i,end:a})}else{let t=Number(e);if(!Number.isSafeInteger(t)||t<1)throw new A(`cut: invalid range`,`array_elements`);n.push({start:t,end:t})}return n}function hm(e,t){let n=[],r=new Set;for(let i of t){let t=i.start-1,a=i.end===null?e.length:i.end;for(let i=t;i<a&&i<e.length;i++)i>=0&&!r.has(i)&&(r.add(i),n.push(e[i]))}return n}var gm,_m,vm,ym=T(()=>{Wi(),k(),j(),Zr(),F(),gm={name:`cut`,summary:`remove sections from each line of files`,usage:`cut [OPTION]... [FILE]...`,options:[`-c LIST select only these characters`,`-d DELIM use DELIM instead of TAB for field delimiter`,`-f LIST select only these fields`,`-s, --only-delimited do not print lines without delimiters`,` --help display this help and exit`]},_m={name:`cut`,async execute(e,t){if(N(e))return M(gm);let n=` `,r=null,i=null,a=!1,o=[];for(let t=0;t<e.length;t++){let s=e[t];if(s===`-d`)n=e[++t]||` `;else if(s.startsWith(`-d`))n=s.slice(2);else if(s===`-f`)r=e[++t];else if(s.startsWith(`-f`))r=s.slice(2);else if(s===`-c`)i=e[++t];else if(s.startsWith(`-c`))i=s.slice(2);else if(s===`-s`||s===`--only-delimited`)a=!0;else{if(s.startsWith(`--`))return P(`cut`,s);if(s.startsWith(`-`)){let e=!1;for(let t of s.slice(1))if(t===`s`)a=!0;else if(!`dfc`.includes(t)){e=!0;break}if(e)return P(`cut`,s)}else o.push(s)}}if(!r&&!i)return{stdout:``,stderr:`cut: you must specify a list of bytes, characters, or fields
450
+ `,exitCode:1};let s=await Xr(t,o,{cmdName:`cut`});if(!s.ok)return s.error;let c=(i?or(s.content):s.content).split(`
451
+ `);c.length>0&&c[c.length-1]===``&&c.pop();let l=mm(r||i||`1`,t.limits.maxArrayElements),u=new Ui(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`cut`),d=0,f=e=>{if(!Number.isSafeInteger(e)||e<0||e>t.limits.maxLoopIterations-d)throw new A(`cut: range expansion limit exceeded (${t.limits.maxLoopIterations})`,`iterations`);d+=e,t.executionScope?.consumeWork(e,`cut range expansion`)};for(let e of c)if(i){let t=Array.from(e),n=[];for(let e of l){let r=e.start-1,i=e.end===null?t.length:e.end;f(Math.max(0,Math.min(i,t.length)-r));for(let e=r;e<i&&e<t.length;e++)e>=0&&n.push(t[e])}u.append(`${n.join(``)}
452
+ `)}else{if(a&&!e.includes(n))continue;let t=e.split(n);for(let e of l){let n=e.start-1,r=e.end===null?t.length:e.end;f(Math.max(0,Math.min(r,t.length)-n))}let r=hm(t,l);u.append(`${r.join(n)}
453
+ `)}return i?{stdout:u.build(),stderr:``,exitCode:0}:{stdout:u.build(),stderr:``,exitCode:0,stdoutKind:`bytes`,stdoutEncoding:`binary`}}},vm={name:`cut`,flags:[{flag:`-d`,type:`value`,valueHint:`delimiter`},{flag:`-f`,type:`value`,valueHint:`string`},{flag:`-c`,type:`value`,valueHint:`string`},{flag:`-s`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),bm={};E(bm,{flagsForFuzzing:()=>Tm,pasteCommand:()=>wm});function xm(e,t){if(e.length===0)return``;if(e.length===1)return e[0];if(t.length===0)return e.join(``);let n=e[0];for(let r=1;r<e.length;r++){let i=(r-1)%t.length;n+=t[i]+e[r]}return n}var Sm,Cm,wm,Tm,Em=T(()=>{Wi(),k(),Wr(),j(),Kr(),F(),Sm={name:`paste`,summary:`merge lines of files`,usage:`paste [OPTION]... [FILE]...`,description:[`Write lines consisting of the sequentially corresponding lines from`,`each FILE, separated by TABs, to standard output.`,``,`With no FILE, or when FILE is -, read standard input.`],options:[`-d, --delimiters=LIST reuse characters from LIST instead of TABs`,`-s, --serial paste one file at a time instead of in parallel`,` --help display this help and exit`],examples:[`paste file1 file2 Merge file1 and file2 side by side`,`paste -d, file1 file2 Use comma as delimiter`,`paste -s file1 Paste all lines of file1 on one line`,`paste - - < file Paste pairs of lines from file`]},Cm={delimiter:{short:`d`,long:`delimiters`,type:`string`,default:` `},serial:{short:`s`,long:`serial`,type:`boolean`}},wm={name:`paste`,async execute(e,t){if(N(e))return M(Sm);let n=Gr(`paste`,e,Cm);if(!n.ok)return n.error;let r=n.result.flags.delimiter,i=n.result.flags.serial,a=n.result.positional;if(a.length>t.limits.maxArrayElements)throw new A(`paste: file operand limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);if(O(r)>t.limits.maxStringLength)throw new A(`paste: delimiter size limit exceeded (${t.limits.maxStringLength} bytes)`,`string_length`);if(a.length===0)return{stdout:``,stderr:`usage: paste [-s] [-d delimiters] file ...
454
+ `,exitCode:1};let o=or(t.stdin),s=o?o.split(`
455
+ `):[``];s.length>0&&s[s.length-1]===``&&s.pop();let c=a.filter(e=>e===`-`).length,l=[],u=0,d=O(o),f=e=>{if(e.length>t.limits.maxArrayElements-u)throw new A(`paste: line limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);u+=e.length,t.executionScope?.consumeWork(e.length,`paste lines`)},p=0;for(let e of a)if(e===`-`){let e=[];for(let t=p;t<s.length;t+=c)e.push(s[t]);f(e),l.push(e),p++}else{let n=t.fs.resolvePath(t.cwd,e);try{let e=await t.fs.readFile(n),r=O(e);if(r>t.limits.maxInputBytes-d)throw new A(`paste: aggregate input size limit exceeded (${t.limits.maxInputBytes} bytes)`,`string_length`);d+=r,t.executionScope?.consumeInput(r,`paste`);let i=e.split(`
456
+ `);i.length>0&&i[i.length-1]===``&&i.pop(),f(i),l.push(i)}catch(t){return Ur(t),{stdout:``,stderr:`paste: ${e}: No such file or directory
457
+ `,exitCode:1}}}let m=new Ui(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`paste`);if(i)for(let e of l)e&&m.append(`${xm(e,r)}
458
+ `);else{let e=0;for(let t of l)e=Math.max(e,t?.length??0);for(let t=0;t<e;t++){let e=[];for(let n of l)e.push(n?.[t]??``);m.append(`${xm(e,r)}
459
+ `)}}return{stdout:m.build(),stderr:``,exitCode:0}}},Tm={name:`paste`,flags:[{flag:`-d`,type:`value`,valueHint:`delimiter`},{flag:`-s`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),Dm={};E(Dm,{flagsForFuzzing:()=>Nm,trCommand:()=>Mm});function Om(e,t,n,r){let i=``,a=0,o=e=>{if(e.length>t-i.length)throw new A(`tr: expanded SET exceeds string length limit (${t})`,`string_length`);i+=e},s=(e=1)=>{if(e>n-r.iterations)throw new A(`tr: SET expansion iteration limit exceeded (${n})`,`iterations`);r.iterations+=e};for(;a<e.length;){if(s(),e[a]===`[`&&e[a+1]===`:`){let t=!1;for(let[n,r]of Am)if(e.slice(a).startsWith(n)){o(r),a+=n.length,t=!0;break}if(t)continue}if(e[a]===`\\`&&a+1<e.length){let t=e[a+1];o(t===`n`?`
460
+ `:t===`t`?` `:t===`r`?`\r`:t),a+=2;continue}if(a+2<e.length&&e[a+1]===`-`){let n=e.charCodeAt(a),r=e.charCodeAt(a+2),o=r>=n?r-n+1:0;if(s(o),o>t-i.length)throw new A(`tr: expanded SET exceeds string length limit (${t})`,`string_length`);for(let e=n;e<=r;e++)i+=String.fromCharCode(e);a+=3;continue}o(e[a]),a++}return i}var km,Am,jm,Mm,Nm,Pm=T(()=>{k(),Wr(),ea(),j(),Kr(),F(),km={name:`tr`,summary:`translate or delete characters`,usage:`tr [OPTION]... SET1 [SET2]`,options:[`-c, -C, --complement use the complement of SET1`,`-d, --delete delete characters in SET1`,`-s, --squeeze-repeats squeeze repeated characters`,` --help display this help and exit`],description:`SET syntax:
461
+ a-z character range
462
+ [:alnum:] all letters and digits
463
+ [:alpha:] all letters
464
+ [:digit:] all digits
465
+ [:lower:] all lowercase letters
466
+ [:upper:] all uppercase letters
467
+ [:space:] all whitespace
468
+ [:blank:] horizontal whitespace
469
+ [:punct:] all punctuation
470
+ [:print:] all printable characters
471
+ [:graph:] all printable characters except space
472
+ [:cntrl:] all control characters
473
+ [:xdigit:] all hexadecimal digits
474
+ \\n, \\t, \\r escape sequences`},Am=new Map([[`[:alnum:]`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`],[`[:alpha:]`,`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`],[`[:blank:]`,` `],[`[:cntrl:]`,Array.from({length:32},(e,t)=>String.fromCharCode(t)).join(``).concat(``)],[`[:digit:]`,`0123456789`],[`[:graph:]`,Array.from({length:94},(e,t)=>String.fromCharCode(33+t)).join(``)],[`[:lower:]`,`abcdefghijklmnopqrstuvwxyz`],[`[:print:]`,Array.from({length:95},(e,t)=>String.fromCharCode(32+t)).join(``)],[`[:punct:]`,`!"#$%&'()*+,-./:;<=>?@[\\]^_\`{|}~`],[`[:space:]`,`
475
+ \r\f\v`],[`[:upper:]`,`ABCDEFGHIJKLMNOPQRSTUVWXYZ`],[`[:xdigit:]`,`0123456789ABCDEFabcdef`]]),jm={complement:{short:`c`,long:`complement`,type:`boolean`},complementUpper:{short:`C`,type:`boolean`},delete:{short:`d`,long:`delete`,type:`boolean`},squeeze:{short:`s`,long:`squeeze-repeats`,type:`boolean`}},Mm={name:`tr`,async execute(e,t){if(N(e))return M(km);let n=Gr(`tr`,e,jm);if(!n.ok)return n.error;let r=n.result.flags.complement||n.result.flags.complementUpper,i=n.result.flags.delete,a=n.result.flags.squeeze,o=n.result.positional;if(o.length<1)return{stdout:``,stderr:`tr: missing operand
476
+ `,exitCode:1};if(!i&&!a&&o.length<2)return{stdout:``,stderr:`tr: missing operand after SET1
477
+ `,exitCode:1};let s,c,l=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),u=t.limits.maxLoopIterations,d=t.limits.maxArrayElements,f=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength);try{let e={iterations:0};s=Om(o[0],l,u,e),c=o.length>1?Om(o[1],l,u,e):``}catch(e){return Ur(e),{stdout:``,stderr:`${$i(e.message)}
478
+ `,exitCode:1}}if(t.stdin.length>l)throw new A(`tr: input size limit exceeded (${l} bytes)`,`string_length`);let p=or(t.stdin);if(s.length>d||c.length>d)throw new A(`tr: array element limit exceeded (${d})`,`array_elements`);let m=new Set(s),h=new Set(c),g=e=>{let t=m.has(e);return r?!t:t},_=``,v=0,y=e=>{let t=O(e);if(t>f-v)throw new A(`tr: output size limit exceeded (${f} bytes)`,`output_size`);_+=e,v+=t};if(i)for(let e of p)g(e)||y(e);else if(a&&o.length===1){let e=``;for(let t of p)g(t)&&t===e||(y(t),e=t)}else{let e=``,t=t=>{a&&h.has(t)&&t===e||(y(t),e=t)};if(r){let e=c.length>0?c[c.length-1]:``;for(let n of p)m.has(n)?t(n):t(e)}else{let e=new Map;for(let t=0;t<s.length;t++){let n=t<c.length?c[t]:c[c.length-1];e.set(s[t],n)}for(let n of p)t(e.get(n)??n)}}return{stdout:_,stderr:``,exitCode:0}}},Nm={name:`tr`,flags:[{flag:`-c`,type:`boolean`},{flag:`-C`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-s`,type:`boolean`}],stdinType:`text`,needsArgs:!0}}),Fm={};E(Fm,{flagsForFuzzing:()=>zm,rev:()=>Rm});function Im(e){return Array.from(e).reverse().join(``)}var Lm,Rm,zm,Bm=T(()=>{k(),F(),Lm={name:`rev`,summary:`reverse lines characterwise`,usage:`rev [file ...]`,description:`Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.`,examples:[`echo 'hello' | rev # Output: olleh`,`rev file.txt # Reverse each line in file`]},Rm={name:`rev`,execute:async(e,t)=>{if(N(e))return M(Lm);let n=[];for(let t of e)if(t===`--`){let r=e.indexOf(t);n.push(...e.slice(r+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return P(`rev`,t);n.push(t)}let r=``,i=e=>{let t=e.split(`
479
+ `),n=e.endsWith(`
480
+ `)&&t[t.length-1]===``;return n&&t.pop(),t.map(Im).join(`
481
+ `)+(n?`
482
+ `:``)};if(n.length===0)r=i(or(t.stdin)??``);else for(let e of n)if(e===`-`){let e=or(t.stdin)??``;r+=i(e)}else{let n=t.fs.resolvePath(t.cwd,e),a=await t.fs.readFile(n);if(a===null)return{exitCode:1,stdout:r,stderr:`rev: ${e}: No such file or directory
483
+ `};r+=i(a)}return{exitCode:0,stdout:r,stderr:``}}},zm={name:`rev`,flags:[],stdinType:`text`,needsFiles:!0}}),Vm={};E(Vm,{flagsForFuzzing:()=>qm,nl:()=>Km});function Hm(e,t,n){let r=String(e);switch(t){case`ln`:return r.padEnd(n);case`rn`:return r.padStart(n);case`rz`:return r.padStart(n,`0`);default:return t}}function Um(e,t){switch(t){case`a`:return!0;case`t`:return e.trim().length>0;case`n`:return!1;default:return t}}function Wm(e,t,n,r){if(e===``)return{output:``,nextNumber:n};let i=e.split(`
484
+ `),a=[],o=0,s=n,c=e.endsWith(`
485
+ `)&&i[i.length-1]===``;c&&i.pop();for(let e of i){let n=+(a.length>0),i=O(t.separator)+O(e);if(Um(e,t.bodyStyle)){let c=Math.max(String(s).length,t.width)+i+n;if(c>r-o)throw new A(`nl: output size limit exceeded (${r} bytes)`,`output_size`);let l=`${Hm(s,t.numberFormat,t.width)}${t.separator}${e}`;a.push(l),o+=c,s+=t.increment}else{let s=t.width+i+n;if(s>r-o)throw new A(`nl: output size limit exceeded (${r} bytes)`,`output_size`);let c=`${` `.repeat(t.width)}${t.separator}${e}`;a.push(c),o+=s}}if(c&&o+1>r)throw new A(`nl: output size limit exceeded (${r} bytes)`,`output_size`);return{output:a.join(`
486
+ `)+(c?`
487
+ `:``),nextNumber:s}}var Gm,Km,qm,Jm=T(()=>{k(),j(),F(),Gm={name:`nl`,summary:`number lines of files`,usage:`nl [OPTION]... [FILE]...`,description:`Write each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.`,options:[`-b STYLE Body numbering style: a (all), t (non-empty), n (none)`,`-n FORMAT Number format: ln (left), rn (right), rz (right zeros)`,`-w WIDTH Number width (default: 6)`,`-s SEP Separator after number (default: TAB)`,`-v START Starting line number (default: 1)`,`-i INCR Line number increment (default: 1)`],examples:[`nl file.txt # Number non-empty lines`,`nl -ba file.txt # Number all lines`,`nl -n rz -w 3 file.txt # Right-justified with zeros`,`nl -s ': ' file.txt # Use ': ' as separator`]},Km={name:`nl`,execute:async(e,t)=>{if(N(e))return M(Gm);let n={bodyStyle:`t`,numberFormat:`rn`,width:6,separator:` `,startNumber:1,increment:1},r=[],i=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),a=i,o=0;for(;o<e.length;){let t=e[o];if(t===`-b`&&o+1<e.length){let t=e[o+1];if(t!==`a`&&t!==`t`&&t!==`n`)return{exitCode:1,stdout:``,stderr:`nl: invalid body numbering style: '${t}'
488
+ `};n.bodyStyle=t,o+=2}else if(t.startsWith(`-b`)){let e=t.slice(2);if(e!==`a`&&e!==`t`&&e!==`n`)return{exitCode:1,stdout:``,stderr:`nl: invalid body numbering style: '${e}'
489
+ `};n.bodyStyle=e,o++}else if(t===`-n`&&o+1<e.length){let t=e[o+1];if(t!==`ln`&&t!==`rn`&&t!==`rz`)return{exitCode:1,stdout:``,stderr:`nl: invalid line numbering format: '${t}'
490
+ `};n.numberFormat=t,o+=2}else if(t.startsWith(`-n`)){let e=t.slice(2);if(e!==`ln`&&e!==`rn`&&e!==`rz`)return{exitCode:1,stdout:``,stderr:`nl: invalid line numbering format: '${e}'
491
+ `};n.numberFormat=e,o++}else if(t===`-w`&&o+1<e.length){let t=/^\d+$/.test(e[o+1])?Number(e[o+1]):NaN;if(!Number.isSafeInteger(t)||t<1||t>i)return{exitCode:1,stdout:``,stderr:`nl: invalid line number field width: '${e[o+1]}'
492
+ `};n.width=t,o+=2}else if(t.startsWith(`-w`)){let e=/^\d+$/.test(t.slice(2))?Number(t.slice(2)):NaN;if(!Number.isSafeInteger(e)||e<1||e>i)return{exitCode:1,stdout:``,stderr:`nl: invalid line number field width: '${t.slice(2)}'
493
+ `};n.width=e,o++}else if(t===`-s`&&o+1<e.length)n.separator=e[o+1],o+=2;else if(t.startsWith(`-s`))n.separator=t.slice(2),o++;else if(t===`-v`&&o+1<e.length){let t=parseInt(e[o+1],10);if(Number.isNaN(t))return{exitCode:1,stdout:``,stderr:`nl: invalid starting line number: '${e[o+1]}'
494
+ `};n.startNumber=t,o+=2}else if(t.startsWith(`-v`)){let e=parseInt(t.slice(2),10);if(Number.isNaN(e))return{exitCode:1,stdout:``,stderr:`nl: invalid starting line number: '${t.slice(2)}'
495
+ `};n.startNumber=e,o++}else if(t===`-i`&&o+1<e.length){let t=parseInt(e[o+1],10);if(Number.isNaN(t))return{exitCode:1,stdout:``,stderr:`nl: invalid line number increment: '${e[o+1]}'
496
+ `};n.increment=t,o+=2}else if(t.startsWith(`-i`)){let e=parseInt(t.slice(2),10);if(Number.isNaN(e))return{exitCode:1,stdout:``,stderr:`nl: invalid line number increment: '${t.slice(2)}'
497
+ `};n.increment=e,o++}else if(t===`--`){r.push(...e.slice(o+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return P(`nl`,t);r.push(t),o++}}let s=``,c=n.startNumber;if(r.length===0)s=Wm(or(t.stdin)??``,n,c,a).output;else for(let e of r){let r=t.fs.resolvePath(t.cwd,e),i=await t.fs.readFile(r);if(i===null)return{exitCode:1,stdout:s,stderr:`nl: ${e}: No such file or directory
498
+ `};let o=Wm(i,n,c,a-O(s));s+=o.output,c=o.nextNumber}return{exitCode:0,stdout:s,stderr:``}}},qm={name:`nl`,flags:[{flag:`-b`,type:`value`,valueHint:`string`},{flag:`-n`,type:`value`,valueHint:`string`},{flag:`-w`,type:`value`,valueHint:`number`},{flag:`-s`,type:`value`,valueHint:`string`},{flag:`-v`,type:`value`,valueHint:`number`},{flag:`-i`,type:`value`,valueHint:`number`}],stdinType:`text`,needsFiles:!0}}),Ym={};E(Ym,{flagsForFuzzing:()=>th,fold:()=>eh});function Xm(e,t,n){return n?O(e):e===` `?8-t%8:e===`\b`?-1:1}function Zm(e,t){if(e.length===0)return e;let{width:n,breakAtSpaces:r,countBytes:i}=t,a=[],o=``,s=0,c=-1,l=0;for(let t of e){let e=Xm(t,s,i);s+e>n&&o.length>0?r&&c>=0?(a.push(o.slice(0,c+1)),o=o.slice(c+1)+t,s=s-l-1+e,c=-1,l=0):(a.push(o),o=t,s=e,c=-1,l=0):(o+=t,s+=e,(t===` `||t===` `)&&(c=o.length-1,l=s-e))}return o.length>0&&a.push(o),a.join(`
499
+ `)}function Qm(e,t){if(e===``)return``;let n=e.split(`
500
+ `),r=e.endsWith(`
501
+ `)&&n[n.length-1]===``;return r&&n.pop(),n.map(e=>Zm(e,t)).join(`
502
+ `)+(r?`
503
+ `:``)}var $m,eh,th,nh=T(()=>{k(),F(),$m={name:`fold`,summary:`wrap each input line to fit in specified width`,usage:`fold [OPTION]... [FILE]...`,description:`Wrap input lines in each FILE, writing to standard output. If no FILE is specified, standard input is read.`,options:[`-w WIDTH Use WIDTH columns instead of 80`,`-s Break at spaces`,`-b Count bytes rather than columns`],examples:[`fold -w 40 file.txt # Wrap at 40 columns`,`fold -sw 40 file.txt # Word wrap at 40 columns`,`echo 'long line' | fold -w 5 # Force wrap at 5`]},eh={name:`fold`,execute:async(e,t)=>{if(N(e))return M($m);let n={width:80,breakAtSpaces:!1,countBytes:!1},r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`-w`&&i+1<e.length){let t=parseInt(e[i+1],10);if(Number.isNaN(t)||t<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${e[i+1]}'
504
+ `};n.width=t,i+=2}else if(t.startsWith(`-w`)&&t.length>2){let e=parseInt(t.slice(2),10);if(Number.isNaN(e)||e<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${t.slice(2)}'
505
+ `};n.width=e,i++}else if(t===`-s`)n.breakAtSpaces=!0,i++;else if(t===`-b`)n.countBytes=!0,i++;else if(t===`-bs`||t===`-sb`)n.breakAtSpaces=!0,n.countBytes=!0,i++;else if(t.match(/^-[sb]+w\d+$/)){t.includes(`s`)&&(n.breakAtSpaces=!0),t.includes(`b`)&&(n.countBytes=!0);let e=t.replace(/^-[sb]+w/,``),r=parseInt(e,10);if(Number.isNaN(r)||r<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${e}'
506
+ `};n.width=r,i++}else if(t.match(/^-[sb]+w$/)&&i+1<e.length){t.includes(`s`)&&(n.breakAtSpaces=!0),t.includes(`b`)&&(n.countBytes=!0);let r=parseInt(e[i+1],10);if(Number.isNaN(r)||r<1)return{exitCode:1,stdout:``,stderr:`fold: invalid number of columns: '${e[i+1]}'
507
+ `};n.width=r,i+=2}else if(t===`--`){r.push(...e.slice(i+1));break}else if(t.startsWith(`-`)&&t!==`-`){let e=t.slice(1),r=!1;for(let t of e)if(t===`s`)n.breakAtSpaces=!0;else if(t===`b`)n.countBytes=!0;else{r=!0;break}if(r)return P(`fold`,t);i++}else r.push(t),i++}let a=``;if(r.length===0)a=Qm(or(t.stdin)??``,n);else for(let e of r){let r=t.fs.resolvePath(t.cwd,e),i=await t.fs.readFile(r);if(i===null)return{exitCode:1,stdout:a,stderr:`fold: ${e}: No such file or directory
508
+ `};a+=Qm(i,n)}return{exitCode:0,stdout:a,stderr:``}}},th={name:`fold`,flags:[{flag:`-w`,type:`value`,valueHint:`number`},{flag:`-s`,type:`boolean`},{flag:`-b`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),rh={};E(rh,{expand:()=>lh,flagsForFuzzing:()=>uh});function ih(e,t,n){let r=e.split(`,`).map(e=>e.trim());if(r.length>n)return null;let i=[];for(let e of r){let n=/^\d+$/.test(e)?Number(e):NaN;if(!Number.isSafeInteger(n)||n<1||n>t)return null;i.push(n)}for(let e=1;e<i.length;e++)if(i[e]<=i[e-1])return null;return i}function ah(e,t){if(t.length===1){let n=t[0];return n-e%n}for(let n of t)if(n>e)return n-e;if(t.length>=2){let n=t[t.length-1]-t[t.length-2],r=t[t.length-1];return r+(Math.floor((e-r)/n)+1)*n-e}return 1}function oh(e,t,n){let{tabStops:r,leadingOnly:i}=t,a=``,o=0,s=!0,c=0;for(let t of e)if(t===` `)if(i&&!s){if(c+1>n)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c++,o++}else{let e=ah(o,r);if(e>n-c)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=` `.repeat(e),c+=e,o+=e}else{t!==` `&&t!==` `&&(s=!1);let e=O(t);if(e>n-c)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);a+=t,c+=e,o++}return a}function sh(e,t,n){if(e===``)return``;let r=e.split(`
509
+ `),i=e.endsWith(`
510
+ `)&&r[r.length-1]===``;i&&r.pop();let a=[],o=0;for(let e of r){let r=+(a.length>0),i=oh(e,t,n-o-r);o+=r+O(i),a.push(i)}if(i&&o+1>n)throw new A(`expand: output size limit exceeded (${n} bytes)`,`output_size`);return a.join(`
511
+ `)+(i?`
512
+ `:``)}var ch,lh,uh,dh=T(()=>{k(),j(),F(),Lr(),ch={name:`expand`,summary:`convert tabs to spaces`,usage:`expand [OPTION]... [FILE]...`,description:`Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.`,options:[`-t N Use N spaces per tab (default: 8)`,`-t LIST Use comma-separated list of tab stops`,`-i Only convert leading tabs on each line`],examples:[`expand file.txt # Convert all tabs to 8 spaces`,`expand -t 4 file.txt # Use 4-space tabs`,`expand -t 4,8,12 file.txt # Custom tab stops`]},lh={name:`expand`,execute:async(e,t)=>{if(N(e))return M(ch);let n={tabStops:[8],leadingOnly:!1},r=[],i=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),a=t.limits.maxArrayElements,o=0;for(;o<e.length;){let t=e[o];if(t===`-t`&&o+1<e.length){let t=ih(e[o+1],i,a);if(!t)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${e[o+1]}'
513
+ `};n.tabStops=t,o+=2}else if(t.startsWith(`-t`)&&t.length>2){let e=ih(t.slice(2),i,a);if(!e)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${t.slice(2)}'
514
+ `};n.tabStops=e,o++}else if(t===`--tabs`&&o+1<e.length){let t=ih(e[o+1],i,a);if(!t)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${e[o+1]}'
515
+ `};n.tabStops=t,o+=2}else if(t.startsWith(`--tabs=`)){let e=ih(t.slice(7),i,a);if(!e)return{exitCode:1,stdout:``,stderr:`expand: invalid tab size: '${t.slice(7)}'
516
+ `};n.tabStops=e,o++}else if(t===`-i`||t===`--initial`)n.leadingOnly=!0,o++;else if(t===`--`){r.push(...e.slice(o+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return P(`expand`,t);r.push(t),o++}}let s=``;if(r.length===0)s=sh(or(t.stdin)??``,n,i);else for(let e of r){let r=t.fs.resolvePath(t.cwd,e),a=await t.fs.readFile(r);if(a===null)return{exitCode:1,stdout:s,stderr:`expand: ${e}: No such file or directory
517
+ `};s+=sh(a,n,i-O(s))}return{exitCode:0,stdout:s,stderr:``}}},uh={name:`expand`,flags:[{flag:`-t`,type:`value`,valueHint:`number`},{flag:`-i`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),fh={};E(fh,{flagsForFuzzing:()=>yh,unexpand:()=>vh});function ph(e){let t=e.split(`,`).map(e=>e.trim()),n=[];for(let e of t){let t=parseInt(e,10);if(Number.isNaN(t)||t<1)return null;n.push(t)}for(let e=1;e<n.length;e++)if(n[e]<=n[e-1])return null;return n}function mh(e,t){if(t.length===1){let n=t[0];return e+(n-e%n)}for(let n of t)if(n>e)return n;if(t.length>=2){let n=t[t.length-1]-t[t.length-2],r=t[t.length-1];return r+(Math.floor((e-r)/n)+1)*n}return-1}function hh(e,t){let{tabStops:n,allBlanks:r}=t,i=``,a=0,o=``,s=0,c=!0,l=()=>{if(o.length===0)return;let e=s+o.length;if(!r&&!c){i+=o,o=``;return}let t=s,a=``;for(;t<e;){let r=mh(t,n);if(r<=e&&r>t)a+=` `,t=r;else break}let l=e-t;l>0&&(a+=` `.repeat(l)),i+=a,o=``};for(let t of e)t===` `?(o.length===0&&(s=a),o+=t,a++):t===` `?(l(),i+=t,a=mh(a,n)):(l(),i+=t,a++,c=!1);return l(),i}function gh(e,t){if(e===``)return``;let n=e.split(`
518
+ `),r=e.endsWith(`
519
+ `)&&n[n.length-1]===``;return r&&n.pop(),n.map(e=>hh(e,t)).join(`
520
+ `)+(r?`
521
+ `:``)}var _h,vh,yh,bh=T(()=>{k(),F(),_h={name:`unexpand`,summary:`convert spaces to tabs`,usage:`unexpand [OPTION]... [FILE]...`,description:`Convert blanks in each FILE to TABs, writing to standard output. If no FILE is specified, standard input is read.`,options:[`-t N Use N spaces per tab (default: 8)`,`-t LIST Use comma-separated list of tab stops`,`-a Convert all sequences of blanks (not just leading)`],examples:[`unexpand file.txt # Convert leading spaces to tabs`,`unexpand -a file.txt # Convert all space sequences`,`unexpand -t 4 file.txt # Use 4-space tabs`]},vh={name:`unexpand`,execute:async(e,t)=>{if(N(e))return M(_h);let n={tabStops:[8],allBlanks:!1},r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`-t`&&i+1<e.length){let t=ph(e[i+1]);if(!t)return{exitCode:1,stdout:``,stderr:`unexpand: invalid tab size: '${e[i+1]}'
522
+ `};n.tabStops=t,i+=2}else if(t.startsWith(`-t`)&&t.length>2){let e=ph(t.slice(2));if(!e)return{exitCode:1,stdout:``,stderr:`unexpand: invalid tab size: '${t.slice(2)}'
523
+ `};n.tabStops=e,i++}else if(t===`--tabs`&&i+1<e.length){let t=ph(e[i+1]);if(!t)return{exitCode:1,stdout:``,stderr:`unexpand: invalid tab size: '${e[i+1]}'
524
+ `};n.tabStops=t,i+=2}else if(t.startsWith(`--tabs=`)){let e=ph(t.slice(7));if(!e)return{exitCode:1,stdout:``,stderr:`unexpand: invalid tab size: '${t.slice(7)}'
525
+ `};n.tabStops=e,i++}else if(t===`-a`||t===`--all`)n.allBlanks=!0,i++;else if(t===`--`){r.push(...e.slice(i+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return P(`unexpand`,t);r.push(t),i++}}let a=``;if(r.length===0)a=gh(or(t.stdin)??``,n);else for(let e of r){let r=t.fs.resolvePath(t.cwd,e),i=await t.fs.readFile(r);if(i===null)return{exitCode:1,stdout:a,stderr:`unexpand: ${e}: No such file or directory
526
+ `};a+=gh(i,n)}return{exitCode:0,stdout:a,stderr:``}}},yh={name:`unexpand`,flags:[{flag:`-t`,type:`value`,valueHint:`number`},{flag:`-a`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),xh={};E(xh,{flagsForFuzzing:()=>Dh,strings:()=>Eh});function Sh(e){return e>=32&&e<=126||e===9}function Ch(e,t){if(t===null)return``;switch(t){case`o`:return`${e.toString(8).padStart(7,` `)} `;case`x`:return`${e.toString(16).padStart(7,` `)} `;case`d`:return`${e.toString(10).padStart(7,` `)} `;default:return t}}function wh(e,t,n,r=!1,i){let a=[],o=0,s=0,c=typeof e==`string`&&!r?new TextEncoder().encode(e):e;if(c.length>n.maxStringLength-n.inputBytes)throw new A(`strings: aggregate input size limit exceeded (${n.maxStringLength} bytes)`,`string_length`);n.inputBytes+=c.length;let l=new TextDecoder,u=(e,t)=>typeof c==`string`?c.slice(e,t):l.decode(c.subarray(e,t)),d=e=>{if(++n.iterations>n.maxIterations)throw new A(`strings: iteration limit exceeded (${n.maxIterations})`,`iterations`);if(n.resultCount>=n.maxArrayElements)throw new A(`strings: array element limit exceeded (${n.maxArrayElements})`,`array_elements`);let t=e.length+1;if(t>n.maxOutputSize-n.outputBytes)throw new A(`strings: output size limit exceeded (${n.maxOutputSize} bytes)`,`output_size`);a.push(e),n.resultCount++,n.outputBytes+=t};for(let e=0;e<c.length;e++){if(!(e&4095)&&i?.aborted)throw new kr;if(Sh(typeof c==`string`?c.charCodeAt(e)&255:c[e])){if(o===0&&(s=e),o>=n.maxStringLength)throw new A(`strings: string length limit exceeded (${n.maxStringLength} bytes)`,`string_length`);o++}else o>=t.minLength&&d(`${Ch(s,t.offsetFormat)}${u(s,e)}`),o=0}return o>=t.minLength&&d(`${Ch(s,t.offsetFormat)}${u(s,c.length)}`),a}var Th,Eh,Dh,Oh=T(()=>{j(),F(),Th={name:`strings`,summary:`print the sequences of printable characters in files`,usage:`strings [OPTION]... [FILE]...`,description:`For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.`,options:[`-n MIN Print sequences of at least MIN characters (default: 4)`,`-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)`,`-a Scan the entire file (default behavior)`,`-e ENCODING Select character encoding (s=7-bit, S=8-bit)`],examples:[`strings file.bin # Extract strings (min 4 chars)`,`strings -n 8 file.bin # Extract strings (min 8 chars)`,`strings -t x file.bin # Show hex offset`,`echo 'hello' | strings # Read from stdin`]},Eh={name:`strings`,execute:async(e,t)=>{if(N(e))return M(Th);let n={minLength:4,offsetFormat:null},r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`-n`&&i+1<e.length){let t=Number.parseInt(e[i+1],10);if(Number.isNaN(t)||t<1)return{exitCode:1,stdout:``,stderr:`strings: invalid minimum string length: '${e[i+1]}'
527
+ `};n.minLength=t,i+=2}else if(t.match(/^-n\d+$/)){let e=Number.parseInt(t.slice(2),10);if(Number.isNaN(e)||e<1)return{exitCode:1,stdout:``,stderr:`strings: invalid minimum string length: '${t.slice(2)}'
528
+ `};n.minLength=e,i++}else if(t.match(/^-\d+$/)){let e=Number.parseInt(t.slice(1),10);if(Number.isNaN(e)||e<1)return{exitCode:1,stdout:``,stderr:`strings: invalid minimum string length: '${t.slice(1)}'
529
+ `};n.minLength=e,i++}else if(t===`-t`&&i+1<e.length){let t=e[i+1];if(t!==`o`&&t!==`x`&&t!==`d`)return{exitCode:1,stdout:``,stderr:`strings: invalid radix: '${t}'
530
+ `};n.offsetFormat=t,i+=2}else if(t.startsWith(`-t`)&&t.length===3){let e=t[2];if(e!==`o`&&e!==`x`&&e!==`d`)return{exitCode:1,stdout:``,stderr:`strings: invalid radix: '${e}'
531
+ `};n.offsetFormat=e,i++}else if(t===`-a`||t===`--all`||t===`-`)t===`-`&&r.push(t),i++;else if(t===`-e`&&i+1<e.length){let t=e[i+1];if(t!==`s`&&t!==`S`)return{exitCode:1,stdout:``,stderr:`strings: invalid encoding: '${t}'
532
+ `};i+=2}else if(t.startsWith(`-e`)&&t.length===3){let e=t[2];if(e!==`s`&&e!==`S`)return{exitCode:1,stdout:``,stderr:`strings: invalid encoding: '${e}'
533
+ `};i++}else if(t===`--`){r.push(...e.slice(i+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return P(`strings`,t);r.push(t),i++}}let a=``,o={maxArrayElements:t.limits.maxArrayElements,maxIterations:t.limits.maxLoopIterations,maxStringLength:Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),maxOutputSize:Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),iterations:0,inputBytes:0,resultCount:0,outputBytes:0},s=()=>t.stdin;if(r.length===0){let e=wh(s(),n,o,!0,t.signal);a=e.length>0?`${e.join(`
534
+ `)}
535
+ `:``}else for(let e of r){let r;if(e===`-`)r=s();else{let n=t.fs.resolvePath(t.cwd,e);try{r=await t.fs.readFileBuffer(n)}catch{return{exitCode:1,stdout:a,stderr:`strings: ${e}: No such file or directory
536
+ `}}}let i=wh(r,n,o,typeof r==`string`,t.signal);i.length>0&&(a+=`${i.join(`
537
+ `)}
538
+ `)}return{exitCode:0,stdout:a,stderr:``}}},Dh={name:`strings`,flags:[{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-t`,type:`value`,valueHint:`string`},{flag:`-a`,type:`boolean`},{flag:`-e`,type:`value`,valueHint:`string`}],stdinType:`text`,needsFiles:!0}}),kh={};E(kh,{flagsForFuzzing:()=>Gh,split:()=>Wh});function Ah(e){return Uint8Array.from(e,e=>e.charCodeAt(0))}function jh(e){let t=e.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!t)return null;let n=Number(t[1]);if(!Number.isSafeInteger(n)||n<1)return null;let r=(t[2]||``).toUpperCase(),i=new Map([[``,1],[`K`,1024],[`M`,1048576],[`G`,1073741824],[`T`,1099511627776],[`P`,0x4000000000000]]).get(r);return i===void 0||n>Math.floor((2**53-1)/i)?null:n*i}function Mh(e){if(!/^[0-9]+$/.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}function Nh(e,t,n){if(t)return e.toString().padStart(n,`0`);let r=Array(n),i=e;for(let e=n-1;e>=0;e--)r[e]=`abcdefghijklmnopqrstuvwxyz`[i%26],i=Math.floor(i/26);return r.join(``)}function Ph(e,t){let n=[],r=0,i=0;for(let a=0;a<e.length;a++)e[a]===10&&(i++,i===t&&(n.push(e.subarray(r,a+1)),r=a+1,i=0));return r<e.length&&n.push(e.subarray(r)),n}function Fh(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}function Ih(e,t){let n=[],r=Math.ceil(e.length/t);for(let i=0;i<t;i++){let t=i*r,a=Math.min(t+r,e.length);t<a&&n.push(e.subarray(t,a))}return n}function Lh(e,t){let n=e?10**t:26**t;return Number.isSafeInteger(n)?n:2**53-1}function Rh(e){if(e.existence!==`unknown`)return e.existence===`existing`?e.stableIdentity:e.canonicalPath===void 0?void 0:`missing:${e.canonicalPath}`}function zh(e,t){return e.existence!==t.existence||e.existence===`unknown`||t.existence===`unknown`?!1:e.existence===`missing`&&t.existence===`missing`?e.canonicalPath===t.canonicalPath:e.existence===`existing`&&t.existence===`existing`&&e.stableIdentity!==void 0&&e.stableIdentity===t.stableIdentity}async function Bh(e,t,n){let r=t.lastIndexOf(`/`),i=r<=0?`/`:t.slice(0,r),a=t.slice(r+1);for(let t=0;t<100;t++){let t=Uh++,r=e.fs.resolvePath(i,`.${a}.just-bash-split-${n}-${t}`),o=await ra(e.fs,r);if(o.existence===`missing`)return r;if(o.existence===`unknown`)break}throw Error(`unable to allocate transaction path`)}var Vh,Hh,Uh,Wh,Gh,Kh=T(()=>{k(),Wr(),la(),j(),F(),Vh={name:`split`,summary:`split a file into pieces`,usage:`split [OPTION]... [FILE [PREFIX]]`,description:`Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.`,options:[`-l N Put N lines per output file`,`-b SIZE Put SIZE bytes per output file (K, M, G suffixes)`,`-n CHUNKS Split into CHUNKS equal-sized files`,`-d Use numeric suffixes (00, 01, ...) instead of alphabetic`,`-a LENGTH Use suffixes of length LENGTH (default: 2)`,`--additional-suffix=SUFFIX Append SUFFIX to file names`],examples:[`split -l 100 file.txt # Split into 100-line chunks`,`split -b 1M file.bin # Split into 1MB chunks`,`split -n 5 file.txt # Split into 5 equal parts`,`split -d file.txt part_ # part_00, part_01, ...`,`split -a 3 -d file.txt x # x000, x001, ...`]},Hh=1e5,Uh=0,Wh={name:`split`,execute:async(e,t)=>{if(N(e))return M(Vh);let n={mode:`lines`,lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:``},r=[],i=0;for(;i<e.length;){let a=e[i];if(a===`-l`&&i+1<e.length){let t=Mh(e[i+1]);if(t===null)return{exitCode:1,stdout:``,stderr:`split: invalid number of lines: '${e[i+1]}'
539
+ `};n.mode=`lines`,n.lines=t,i+=2}else if(a.match(/^-l\d+$/)){let e=Mh(a.slice(2));if(e===null)return{exitCode:1,stdout:``,stderr:`split: invalid number of lines: '${a.slice(2)}'
540
+ `};n.mode=`lines`,n.lines=e,i++}else if(a===`-b`&&i+1<e.length){let t=jh(e[i+1]);if(t===null)return{exitCode:1,stdout:``,stderr:`split: invalid number of bytes: '${e[i+1]}'
541
+ `};n.mode=`bytes`,n.bytes=t,i+=2}else if(a.match(/^-b.+$/)){let e=jh(a.slice(2));if(e===null)return{exitCode:1,stdout:``,stderr:`split: invalid number of bytes: '${a.slice(2)}'
542
+ `};n.mode=`bytes`,n.bytes=e,i++}else if(a===`-n`&&i+1<e.length){let t=Mh(e[i+1]);if(t===null)return{exitCode:1,stdout:``,stderr:`split: invalid number of chunks: '${e[i+1]}'
543
+ `};n.mode=`chunks`,n.chunks=t,i+=2}else if(a.match(/^-n\d+$/)){let e=Mh(a.slice(2));if(e===null)return{exitCode:1,stdout:``,stderr:`split: invalid number of chunks: '${a.slice(2)}'
544
+ `};n.mode=`chunks`,n.chunks=e,i++}else if(a===`-a`&&i+1<e.length){let r=Mh(e[i+1]);if(r===null||r>Math.min(t.limits.maxStringLength,t.limits.maxArrayElements))return{exitCode:1,stdout:``,stderr:`split: invalid suffix length: '${e[i+1]}'
545
+ `};n.suffixLength=r,i+=2}else if(a.match(/^-a\d+$/)){let e=Mh(a.slice(2));if(e===null||e>Math.min(t.limits.maxStringLength,t.limits.maxArrayElements))return{exitCode:1,stdout:``,stderr:`split: invalid suffix length: '${a.slice(2)}'
546
+ `};n.suffixLength=e,i++}else if(a===`-d`||a===`--numeric-suffixes`)n.useNumericSuffix=!0,i++;else if(a.startsWith(`--additional-suffix=`))n.additionalSuffix=a.slice(20),i++;else if(a===`--additional-suffix`&&i+1<e.length)n.additionalSuffix=e[i+1],i+=2;else if(a===`--`){r.push(...e.slice(i+1));break}else{if(a.startsWith(`-`)&&a!==`-`)return P(`split`,a);r.push(a),i++}}let a=`-`,o=`x`;if(r.length>=1&&(a=r[0]),r.length>=2&&(o=r[1]),r.length>2)return{exitCode:1,stdout:``,stderr:`split: extra operand '${r[2]}'
547
+ `};if(O(o)>t.limits.maxStringLength||O(n.additionalSuffix)>t.limits.maxStringLength||n.suffixLength>t.limits.maxStringLength-Math.min(t.limits.maxStringLength,O(o))-Math.min(t.limits.maxStringLength,O(n.additionalSuffix)))return{exitCode:1,stdout:``,stderr:`split: output filename exceeds configured string limit
548
+ `};let s,c=null,l;if(a===`-`){let e=t.stdin.length;l=t.executionScope?.reserveBytes(`split transaction`,e*2,`split`),s=Ah(t.stdin)}else{c=t.fs.resolvePath(t.cwd,a);try{let e=await t.fs.stat(c);if(l=t.executionScope?.reserveBytes(`split transaction`,e.size*2,`split`),s=await t.fs.readFileBuffer(c),s.byteLength>e.size)throw new A(`split: input grew while being read`,`string_length`);t.executionScope?.consumeInput(s.byteLength,`split`)}catch(e){return l?.release(),Ur(e),{exitCode:1,stdout:``,stderr:`split: ${a}: No such file or directory
549
+ `}}}try{if(s.length===0)return{exitCode:0,stdout:``,stderr:``};if(n.mode===`chunks`&&n.chunks>Hh)return{exitCode:1,stdout:``,stderr:`split: too many output files (${n.chunks}), limit is ${Hh}
550
+ `};let e;switch(n.mode){case`lines`:e=Ph(s,n.lines);break;case`bytes`:e=Fh(s,n.bytes);break;case`chunks`:e=Ih(s,n.chunks);break;default:return n.mode}if(e.length>Hh)return{exitCode:1,stdout:``,stderr:`split: too many output files (${e.length}), limit is ${Hh}
551
+ `};let r=Lh(n.useNumericSuffix,n.suffixLength);if(e.length>r)return{exitCode:1,stdout:``,stderr:`split: output file suffixes exhausted at ${r} files
552
+ `};t.executionScope?.consumeWork(e.length*n.suffixLength,`split suffix generation`);let i=[],a=new Set,l=c?await ra(t.fs,c):null;if(l?.existence===`unknown`)return{exitCode:1,stdout:``,stderr:`split: cannot safely identify input file
553
+ `};for(let r=0;r<e.length;r++){let s=Nh(r,n.useNumericSuffix,n.suffixLength),c=`${o}${s}${n.additionalSuffix}`,u=t.fs.resolvePath(t.cwd,c),d=await ra(t.fs,u),f=Rh(d);if(d.existence===`unknown`||f===void 0)return{exitCode:1,stdout:``,stderr:`split: cannot safely identify output file '${c}'
554
+ `};if(f!==void 0&&a.has(f))return{exitCode:1,stdout:``,stderr:`split: duplicate output file '${c}'
555
+ `};if(l!==null&&(l.existence===`existing`&&d.existence===`existing`&&l.stableIdentity!==void 0&&l.stableIdentity===d.stableIdentity||l.canonicalPath!==void 0&&l.canonicalPath===d.canonicalPath))return{exitCode:1,stdout:``,stderr:`split: output file '${c}' would overwrite input
556
+ `};f!==void 0&&a.add(f),i.push({path:u,displayName:c,content:e[r],initialIdentity:d,stagePath:``,committed:!1})}try{for(let e of i)e.stagePath=await Bh(t,e.path,`stage`),await t.fs.writeFile(e.stagePath,e.content);if(c!==null&&l!==null&&!zh(l,await ra(t.fs,c)))throw Error(`input identity changed during split`);for(let e of i){let n=await ra(t.fs,e.path);if(!zh(e.initialIdentity,n))throw Error(`output identity changed during split`);if(l?.existence===`existing`&&n.existence===`existing`&&l.stableIdentity===n.stableIdentity)throw Error(`output aliases input`)}for(let e of i){if(!zh(e.initialIdentity,await ra(t.fs,e.path)))throw Error(`output identity changed during split`);e.initialIdentity.existence===`existing`&&(e.backupPath=await Bh(t,e.path,`backup`),await t.fs.mv(e.path,e.backupPath)),await t.fs.mv(e.stagePath,e.path),e.committed=!0}for(let e of i)e.backupPath&&=(await t.fs.rm(e.backupPath,{force:!0,recursive:!0}).catch(()=>{}),void 0)}catch{for(let e of[...i].reverse())e.committed&&await t.fs.rm(e.path,{force:!0,recursive:!0}).catch(()=>{}),e.backupPath&&await t.fs.mv(e.backupPath,e.path).catch(()=>{}),e.stagePath&&await t.fs.rm(e.stagePath,{force:!0,recursive:!0}).catch(()=>{});return{exitCode:1,stdout:``,stderr:`split: failed to write output
557
+ `}}return{exitCode:0,stdout:``,stderr:``}}finally{l?.release()}}},Gh={name:`split`,flags:[{flag:`-l`,type:`value`,valueHint:`number`},{flag:`-b`,type:`value`,valueHint:`string`},{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-d`,type:`boolean`},{flag:`-a`,type:`value`,valueHint:`number`}],needsFiles:!0}}),qh={};E(qh,{column:()=>eg,flagsForFuzzing:()=>tg});function Jh(e,t,n,r){return t?n?e.split(t,r):e.split(t,r).filter(e=>e.length>0):n?e.split(/[ \t]/,r):e.split(/[ \t]+/,r).filter(e=>e.length>0)}function Yh(e){let t=[];for(let n of e)for(let e=0;e<n.length;e++){let r=n[e].length;(t[e]===void 0||r>t[e])&&(t[e]=r)}return t}function Xh(e,t,n){if(e.length===0)return``;let r=Yh(e),i=new Ui(n,`column`,void 0,1);for(let n=0;n<e.length;n++){let a=e[n];n>0&&i.append(`
558
+ `);for(let e=0;e<a.length;e++)e>0&&i.append(t),i.append(a[e]),e<a.length-1&&i.repeat(` `,r[e]-a[e].length)}return i.build()}function Zh(e,t,n,r){if(e.length===0)return``;let i=0;for(let t of e)i=Math.max(i,t.length);let a=n.length,o=i+a,s=Math.max(1,Math.floor((t+a)/o)),c=Math.ceil(e.length/s),l=new Ui(r,`column`,void 0,1);for(let t=0;t<c;t++){t>0&&l.append(`
559
+ `);let r=!1;for(let a=0;a<s;a++){let o=a*c+t;o<e.length&&(a===s-1||(a+1)*c+t>=e.length?(r&&l.append(n),l.append(e[o])):(r&&l.append(n),l.append(e[o]),l.repeat(` `,i-e[o].length)),r=!0)}}return l.build()}var Qh,$h,eg,tg,ng=T(()=>{Wi(),k(),j(),Kr(),F(),Qh={name:`column`,summary:`columnate lists`,usage:`column [OPTION]... [FILE]...`,description:`Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.`,options:[`-t Create a table (determine columns from input)`,`-s SEP Input field delimiter (default: whitespace)`,`-o SEP Output field delimiter (default: two spaces)`,`-c WIDTH Output width for fill mode (default: 80)`,`-n Don't merge multiple adjacent delimiters`],examples:[`ls | column # Fill columns with ls output`,`cat data | column -t # Format as table`,`column -t -s ',' file # Format CSV as table`,`column -c 40 file # Fill 40-char wide columns`]},$h={table:{short:`t`,long:`table`,type:`boolean`},separator:{short:`s`,type:`string`},outputSep:{short:`o`,type:`string`},width:{short:`c`,type:`number`,default:80},noMerge:{short:`n`,type:`boolean`}},eg={name:`column`,execute:async(e,t)=>{if(N(e))return M(Qh);let n=Gr(`column`,e,$h);if(!n.ok)return n.error;let{table:r,separator:i,outputSep:a,width:o,noMerge:s}=n.result.flags,c=n.result.positional,l=a??` `,u=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),d=t.limits.maxArrayElements,f=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize);if(!Number.isFinite(o)||!Number.isSafeInteger(o)||o<=0||o>10485760)return{exitCode:1,stdout:``,stderr:`column: invalid width: ${o}
560
+ `};let p;if(c.length===0)p=or(t.stdin)??``;else{let e=[],n=0;for(let r of c)if(r===`-`){let r=or(t.stdin)??``;if(n+=O(r),n>u)throw new A(`column: input size limit exceeded (${u} bytes)`,`string_length`);e.push(r)}else{let i=t.fs.resolvePath(t.cwd,r),a=await t.fs.readFile(i);if(a===null)return{exitCode:1,stdout:``,stderr:`column: ${r}: No such file or directory
561
+ `};if(n+=O(a),n>u)throw new A(`column: input size limit exceeded (${u} bytes)`,`string_length`);e.push(a)}p=e.join(``)}if(O(p)>u)throw new A(`column: input size limit exceeded (${u} bytes)`,`string_length`);if(p===``||p.trim()===``)return{exitCode:0,stdout:``,stderr:``};let m=p.split(`
562
+ `,d+1);if(m.length>d)throw new A(`column: field limit exceeded (${d})`,`array_elements`);p.endsWith(`
563
+ `)&&m[m.length-1]===``&&m.pop();let h=m.filter(e=>e.trim().length>0),g;if(r){let e=[],t=0;for(let n of h){let r=Jh(n,i,s,d-t+1);if(t+=r.length,t>d)throw new A(`column: field limit exceeded (${d})`,`array_elements`);e.push(r)}g=Xh(e,l,f)}else{let e=[];for(let t of h){let n=d-e.length,r=Jh(t,i,s,n+1);if(r.length>n)throw new A(`column: field limit exceeded (${d})`,`array_elements`);for(let t of r)e.push(t)}g=Zh(e,o,l,f)}return g.length>0&&(g+=`
564
+ `),{exitCode:0,stdout:g,stderr:``}}},tg={name:`column`,flags:[{flag:`-t`,type:`boolean`},{flag:`-s`,type:`value`,valueHint:`delimiter`},{flag:`-o`,type:`value`,valueHint:`string`},{flag:`-c`,type:`value`,valueHint:`number`},{flag:`-n`,type:`boolean`}],stdinType:`text`,needsFiles:!0}}),rg={};E(rg,{flagsForFuzzing:()=>ug,join:()=>lg});function ig(e,t){return t?e.split(t):e.split(/[ \t]+/).filter(e=>e.length>0)}function ag(e,t,n,r){let i=ig(e,t),a=i[n-1]??``;return r&&(a=a.toLowerCase()),{fields:i,joinKey:a,original:e}}function og(e,t,n){let r=n.separator??` `;if(n.outputFormat){let i=[];for(let{file:r,field:a}of n.outputFormat){let o=r===1?e:t;o&&a===0?i.push(o.joinKey):o&&o.fields[a-1]!==void 0?i.push(o.fields[a-1]):i.push(n.emptyString)}return i.join(r)}let i=[],a=e?.joinKey??t?.joinKey??``;if(i.push(a),e)for(let t=0;t<e.fields.length;t++)t!==n.field1-1&&i.push(e.fields[t]);if(t)for(let e=0;e<t.fields.length;e++)e!==n.field2-1&&i.push(t.fields[e]);return i.join(r)}function sg(e){let t=e.split(`,`),n=[];for(let e of t){let t=e.trim().match(/^(\d+)\.(\d+)$/);if(!t)return null;let r=Number.parseInt(t[1],10),i=Number.parseInt(t[2],10);if(r!==1&&r!==2)return null;n.push({file:r,field:i})}return n}var cg,lg,ug,dg=T(()=>{k(),j(),F(),Lr(),cg={name:`join`,summary:`join lines of two files on a common field`,usage:`join [OPTION]... FILE1 FILE2`,description:`For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.`,options:[`-1 FIELD Join on this FIELD of file 1 (default: 1)`,`-2 FIELD Join on this FIELD of file 2 (default: 1)`,`-t CHAR Use CHAR as input and output field separator`,`-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)`,`-v FILENUM Like -a but only output unpairable lines`,`-e STRING Replace missing fields with STRING`,`-o FORMAT Output format (comma-separated list of FILENUM.FIELD)`,`-i Ignore case when comparing fields`],examples:[`join file1 file2 # Join on first field`,`join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1`,`join -t ',' file1.csv file2.csv # Join CSV files`,`join -a 1 file1 file2 # Left outer join`]},lg={name:`join`,execute:async(e,t)=>{if(N(e))return M(cg);let n={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:``,outputFormat:null,ignoreCase:!1},r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`-1`&&i+1<e.length){let t=Number.parseInt(e[i+1],10);if(Number.isNaN(t)||t<1)return{exitCode:1,stdout:``,stderr:`join: invalid field number: '${e[i+1]}'
565
+ `};n.field1=t,i+=2}else if(t===`-2`&&i+1<e.length){let t=Number.parseInt(e[i+1],10);if(Number.isNaN(t)||t<1)return{exitCode:1,stdout:``,stderr:`join: invalid field number: '${e[i+1]}'
566
+ `};n.field2=t,i+=2}else if((t===`-t`||t===`--field-separator`)&&i+1<e.length)n.separator=e[i+1],i+=2;else if(t.startsWith(`-t`)&&t.length>2)n.separator=t.slice(2),i++;else if(t===`-a`&&i+1<e.length){let t=Number.parseInt(e[i+1],10);if(t!==1&&t!==2)return{exitCode:1,stdout:``,stderr:`join: invalid file number: '${e[i+1]}'
567
+ `};n.printUnpairable.add(t),i+=2}else if(t.match(/^-a[12]$/))n.printUnpairable.add(Number.parseInt(t[2],10)),i++;else if(t===`-v`&&i+1<e.length){let t=Number.parseInt(e[i+1],10);if(t!==1&&t!==2)return{exitCode:1,stdout:``,stderr:`join: invalid file number: '${e[i+1]}'
568
+ `};n.onlyUnpairable.add(t),i+=2}else if(t.match(/^-v[12]$/))n.onlyUnpairable.add(Number.parseInt(t[2],10)),i++;else if(t===`-e`&&i+1<e.length)n.emptyString=e[i+1],i+=2;else if(t===`-o`&&i+1<e.length){let t=sg(e[i+1]);if(!t)return{exitCode:1,stdout:``,stderr:`join: invalid field spec: '${e[i+1]}'
569
+ `};n.outputFormat=t,i+=2}else if(t===`-i`||t===`--ignore-case`)n.ignoreCase=!0,i++;else if(t===`--`){r.push(...e.slice(i+1));break}else{if(t.startsWith(`-`)&&t!==`-`)return P(`join`,t);r.push(t),i++}}if(r.length!==2)return{exitCode:1,stdout:``,stderr:r.length<2?`join: missing file operand
570
+ `:`join: extra operand
571
+ `};let a=[];for(let e of r)if(e===`-`)a.push(or(t.stdin)??``);else{let n=t.fs.resolvePath(t.cwd,e),r=await t.fs.readFile(n);if(r===null)return{exitCode:1,stdout:``,stderr:`join: ${e}: No such file or directory
572
+ `};a.push(r)}let o=t.limits.maxArrayElements,s=t.limits.maxLoopIterations,c=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),l=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength);if(a.reduce((e,t)=>e+O(t),0)>c)throw new A(`join: aggregate input size limit exceeded (${c} bytes)`,`string_length`);let u=0,d=0,f=()=>{if(++d>s)throw new A(`join: iteration limit exceeded (${s})`,`iterations`)},p=(e,t)=>{let r=+(e.length>0);for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&t+1<e.length&&r++;if(r>o-u)throw new A(`join: array element limit exceeded (${o})`,`array_elements`);u+=r;let i=e.split(`
573
+ `);return e.endsWith(`
574
+ `)&&i[i.length-1]===``&&i.pop(),i.filter(e=>e.length>0).map(e=>ag(e,n.separator,t,n.ignoreCase))},m=p(a[0],n.field1),h=p(a[1],n.field2),g=new Map;for(let e of h){let t=g.get(e.joinKey);t?t.push(e):g.set(e.joinKey,[e])}let _=[],v=0,y=e=>{if(f(),_.length>=o)throw new A(`join: array element limit exceeded (${o})`,`array_elements`);let t=O(e)+1;if(t>l-v)throw new A(`join: output size limit exceeded (${l} bytes)`,`output_size`);_.push(e),v+=t},b=new Set;for(let e of m){let t=g.get(e.joinKey);if(t&&t.length>0){if(b.add(e.joinKey),n.onlyUnpairable.size===0)for(let r of t)y(og(e,r,n))}else(n.printUnpairable.has(1)||n.onlyUnpairable.has(1))&&y(og(e,null,n))}if(n.printUnpairable.has(2)||n.onlyUnpairable.has(2))for(let e of h)b.has(e.joinKey)||y(og(null,e,n));return{exitCode:0,stdout:sr(_.length>0?`${_.join(`
575
+ `)}
576
+ `:``),stderr:``,stdoutEncoding:`binary`}}},ug={name:`join`,flags:[{flag:`-1`,type:`value`,valueHint:`number`},{flag:`-2`,type:`value`,valueHint:`number`},{flag:`-t`,type:`value`,valueHint:`delimiter`},{flag:`-a`,type:`value`,valueHint:`number`},{flag:`-v`,type:`value`,valueHint:`number`},{flag:`-e`,type:`value`,valueHint:`string`},{flag:`-o`,type:`value`,valueHint:`format`},{flag:`-i`,type:`boolean`}],needsArgs:!0,minArgs:2}}),fg={};E(fg,{flagsForFuzzing:()=>gg,teeCommand:()=>hg});var pg,mg,hg,gg,_g=T(()=>{k(),Kr(),F(),pg={name:`tee`,summary:`read from stdin and write to stdout and files`,usage:`tee [OPTION]... [FILE]...`,options:[`-a, --append append to the given FILEs, do not overwrite`,` --help display this help and exit`]},mg={append:{short:`a`,long:`append`,type:`boolean`}},hg={name:`tee`,async execute(e,t){if(N(e))return M(pg);let n=Gr(`tee`,e,mg);if(!n.ok)return n.error;let{append:r}=n.result.flags,i=n.result.positional,a=t.stdin,o=``,s=0;for(let e of i)try{let n=t.fs.resolvePath(t.cwd,e);r?await t.fs.appendFile(n,a,`binary`):await t.fs.writeFile(n,a,`binary`)}catch{o+=`tee: ${e}: No such file or directory
577
+ `,s=1}return{stdout:a,stderr:o,exitCode:s,stdoutEncoding:`binary`}}},gg={name:`tee`,flags:[{flag:`-a`,type:`boolean`}],stdinType:`text`,needsArgs:!0}}),vg,yg=T(()=>{k(),j(),vg=class{scope;site;stdoutChunks=[];stderrChunks=[];stdoutBytes=0;stderrBytes=0;attachedErrors=new WeakSet;constructor(e,t){this.scope=e,this.site=t}append(e,t,n=0,r=`text`){let i;try{i=this.scope.appendOutput(e,t,this.site,n,r)}catch(e){throw this.prependTo(e),e}t&&(e===`stdout`?this.stdoutChunks:this.stderrChunks).push(t),e===`stdout`?this.stdoutBytes+=i:this.stderrBytes+=i}prependTo(e){e instanceof vr&&(this.attachedErrors.has(e)||(this.attachedErrors.add(e),e.prependOutput(this.stdout,this.stderr)))}appendResult(e,t=e.stdout){let n=e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`,r=n===`bytes`?t.length:O(t);this.append(`stdout`,t,Math.min(e.internalOutputAccounting?.stdout??0,r),n),this.append(`stderr`,e.stderr,e.internalOutputAccounting?.stderr??0)}build(e,t){return{stdout:this.stdoutChunks.join(``),stderr:this.stderrChunks.join(``),exitCode:e,...t,internalOutputAccounting:{stdout:this.stdoutBytes,stderr:this.stderrBytes}}}get stdout(){return this.stdoutChunks.join(``)}get stderr(){return this.stderrChunks.join(``)}}});function bg(e,t){switch(e.type){case`name`:{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let n=r[1],i=t.name;if(e.ignoreCase){if(!i.toLowerCase().endsWith(n.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(n))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:hc(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case`path`:{let n=e.pattern,r=t.relativePath,i=n.split(`/`);for(let t=0;t<i.length-1;t++){let n=i[t];if(n&&n!==`.`&&n!==`..`&&!n.includes(`*`)&&!n.includes(`?`)&&!n.includes(`[`)){let t=`/${n}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(t))return{matches:!1,pruned:!1,printed:!1}}}let a=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let t=a[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(t))return{matches:!1,pruned:!1,printed:!1}}return{matches:hc(r,n,e.ignoreCase),pruned:!1,printed:!1}}case`regex`:try{let n=e.ignoreCase?`i`:``;return{matches:U(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case`type`:return e.fileType===`f`?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType===`d`?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case`empty`:return{matches:t.isEmpty,pruned:!1,printed:!1};case`mtime`:{let n=(Date.now()-t.mtime)/864e5,r;return r=e.comparison===`more`?n>e.days:e.comparison===`less`?n<e.days:Math.floor(n)===e.days,{matches:r,pruned:!1,printed:!1}}case`newer`:{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case`size`:{let n=e.value;switch(e.unit){case`c`:n=e.value;break;case`k`:n=e.value*1024;break;case`M`:n=e.value*1024*1024;break;case`G`:n=e.value*1024*1024*1024;break;case`b`:n=e.value*512}let r;return r=e.comparison===`more`?t.size>n:e.comparison===`less`?t.size<n:e.unit===`b`?Math.ceil(t.size/512)===e.value:t.size===n,{matches:r,pruned:!1,printed:!1}}case`perm`:{let n=t.mode&511,r=e.mode&511,i;return i=e.matchType===`exact`?n===r:e.matchType===`all`?(n&r)===r:(n&r)!==0,{matches:i,pruned:!1,printed:!1}}case`prune`:return{matches:!0,pruned:!0,printed:!1};case`action`:return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case`not`:{let n=bg(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1,actions:n.actions}}case`and`:{let n=bg(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1,actions:n.actions};let r=bg(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed,actions:[...n.actions??[],...r.actions??[]]}}case`or`:{let n=bg(e.left,t);if(n.matches)return n;let r=bg(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed,actions:[...n.actions??[],...r.actions??[]]}}}}function xg(e){if(!e)return!1;switch(e.type){case`name`:case`path`:case`regex`:case`type`:case`prune`:return!1;case`action`:return!1;case`empty`:case`mtime`:case`newer`:case`size`:case`perm`:return!0;case`not`:return xg(e.expr);case`and`:case`or`:return xg(e.left)||xg(e.right)}}function Sg(e){if(!e)return!1;switch(e.type){case`empty`:return!0;case`not`:return Sg(e.expr);case`and`:case`or`:return Sg(e.left)||Sg(e.right);default:return!1}}function Cg(e){let t=[],n=e=>{e&&(e.type===`newer`?t.push(e.refPath):e.type===`not`?n(e.expr):(e.type===`and`||e.type===`or`)&&(n(e.left),n(e.right)))};return n(e),t}function wg(e){if(!e)return!0;switch(e.type){case`name`:case`path`:case`regex`:case`type`:case`prune`:return!0;case`action`:return!1;case`empty`:case`mtime`:case`newer`:case`size`:case`perm`:return!1;case`not`:return wg(e.expr);case`and`:case`or`:return wg(e.left)&&wg(e.right)}}function Tg(e,t,n,r,i){switch(e.type){case`name`:{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let n=r[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(n.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(n))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:hc(t,n,e.ignoreCase),pruned:!1,printed:!1}}case`path`:{let t=e.pattern,r=t.split(`/`);for(let t=0;t<r.length-1;t++){let i=r[t];if(i&&i!==`.`&&i!==`..`&&!i.includes(`*`)&&!i.includes(`?`)&&!i.includes(`[`)){let t=`/${i}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(t))return{matches:!1,pruned:!1,printed:!1}}}let i=t.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let t=i[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(t.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(t))return{matches:!1,pruned:!1,printed:!1}}return{matches:hc(n,t,e.ignoreCase),pruned:!1,printed:!1}}case`regex`:try{let t=e.ignoreCase?`i`:``;return{matches:U(e.pattern,t).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case`type`:return e.fileType===`f`?{matches:r,pruned:!1,printed:!1}:e.fileType===`d`?{matches:i,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case`prune`:return{matches:!0,pruned:!0,printed:!1};case`action`:return{matches:!0,pruned:!1,printed:!1,actions:[e.action]};case`not`:{let a=Tg(e.expr,t,n,r,i);return{matches:!a.matches,pruned:a.pruned,printed:!1,actions:a.actions}}case`and`:{let a=Tg(e.left,t,n,r,i);if(!a.matches)return{matches:!1,pruned:a.pruned,printed:!1,actions:a.actions};let o=Tg(e.right,t,n,r,i);return{matches:o.matches,pruned:a.pruned||o.pruned,printed:a.printed||o.printed,actions:[...a.actions??[],...o.actions??[]]}}case`or`:{let a=Tg(e.left,t,n,r,i);if(a.matches)return a;let o=Tg(e.right,t,n,r,i);return{matches:o.matches,pruned:a.pruned||o.pruned,printed:o.printed,actions:[...a.actions??[],...o.actions??[]]}}default:return{matches:!1,pruned:!1,printed:!1}}}function Eg(e){if(!e)return!1;switch(e.type){case`prune`:return!0;case`not`:return Eg(e.expr);case`and`:case`or`:return Eg(e.left)||Eg(e.right);default:return!1}}function Dg(e){switch(e.type){case`name`:case`path`:case`regex`:case`type`:case`prune`:return!0;case`action`:return!1;case`empty`:case`mtime`:case`newer`:case`size`:case`perm`:return!1;case`not`:return Dg(e.expr);case`and`:case`or`:return Dg(e.left)&&Dg(e.right)}}function Og(e,t){return!e||!t.isDirectory?{shouldPrune:!1}:Dg(e)?{shouldPrune:bg(e,{name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map}).pruned}:kg(e,t)}function kg(e,t){switch(e.type){case`or`:if(Dg(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(bg(e.left,n).pruned)return{shouldPrune:!0}}return kg(e.right,t);case`and`:if(Dg(e.left)&&Dg(e.right))return{shouldPrune:bg(e,{name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map}).pruned};if(Dg(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return bg(e.left,n).matches?kg(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1};case`not`:return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Ag=T(()=>{mc(),yc()});function jg(e,t){let n=[],r=t,i=e=>({expr:null,pathIndex:r,error:`find: missing argument to \`${e}'
578
+ `}),a=(e,t)=>({expr:null,pathIndex:r,error:`find: invalid argument \`${t}' to \`${e}'
579
+ `});for(;r<e.length;){let t=e[r];if(t===`(`||t===`\\(`){n.push({type:`lparen`}),r++;continue}if(t===`)`||t===`\\)`){n.push({type:`rparen`}),r++;continue}if(t===`-name`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`name`,pattern:e[++r]}})}else if(t===`-iname`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`name`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-path`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`path`,pattern:e[++r]}})}else if(t===`-ipath`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`path`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-regex`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`regex`,pattern:e[++r]}})}else if(t===`-iregex`){if(r+1>=e.length)return i(t);n.push({type:`expr`,expr:{type:`regex`,pattern:e[++r],ignoreCase:!0}})}else if(t===`-type`){if(r+1>=e.length)return i(t);let a=e[++r];if(a===`f`||a===`d`)n.push({type:`expr`,expr:{type:`type`,fileType:a}});else return{expr:null,pathIndex:r,error:`find: Unknown argument to -type: ${a}
580
+ `}}else if(t===`-empty`)n.push({type:`expr`,expr:{type:`empty`}});else if(t===`-mtime`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1)),!/^\d+$/.test(c))return a(t,o);let l=Number(c);if(!Number.isSafeInteger(l))return a(t,o);n.push({type:`expr`,expr:{type:`mtime`,days:l,comparison:s}})}else if(t===`-newer`){if(r+1>=e.length)return i(t);let a=e[++r];n.push({type:`expr`,expr:{type:`newer`,refPath:a}})}else if(t===`-size`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;o.startsWith(`+`)?(s=`more`,c=o.slice(1)):o.startsWith(`-`)&&(s=`less`,c=o.slice(1));let l=c.match(/^(\d+)([ckMGb])?$/);if(!l)return a(t,o);let u=Number(l[1]);if(!Number.isSafeInteger(u))return a(t,o);let d=l[2]||`b`,f=d===`G`?1024**3:d===`M`?1024**2:d===`k`?1024:d===`b`?512:1;if(!Number.isSafeInteger(u*f))return a(t,o);n.push({type:`expr`,expr:{type:`size`,value:u,unit:d,comparison:s}})}else if(t===`-perm`){if(r+1>=e.length)return i(t);let o=e[++r],s=`exact`,c=o;if(o.startsWith(`-`)?(s=`all`,c=o.slice(1)):o.startsWith(`/`)&&(s=`any`,c=o.slice(1)),!/^[0-7]{1,4}$/.test(c))return a(t,o);let l=Number.parseInt(c,8);n.push({type:`expr`,expr:{type:`perm`,mode:l,matchType:s}})}else if(t===`-prune`)n.push({type:`expr`,expr:{type:`prune`}});else if(t===`-not`||t===`!`)n.push({type:`not`});else if(t===`-o`||t===`-or`)n.push({type:`op`,op:`or`});else if(t===`-a`||t===`-and`)n.push({type:`op`,op:`and`});else if(t===`-maxdepth`||t===`-mindepth`){if(r+1>=e.length)return i(t);r++}else if(t!==`-depth`)if(t===`-exec`){let t=[];for(r++;r<e.length&&e[r]!==`;`&&e[r]!==`+`;)t.push(e[r]),r++;if(r>=e.length)return{expr:null,pathIndex:r,error:`find: missing argument to \`-exec'
581
+ `};if(t.length===0)return i(`-exec`);let o=e[r]===`+`;if(o&&(t.at(-1)!==`{}`||t.filter(e=>e===`{}`).length!==1))return a(`-exec`,`+`);n.push({type:`expr`,expr:{type:`action`,action:{type:`exec`,command:t,batchMode:o}}})}else if(t===`-print`)n.push({type:`expr`,expr:{type:`action`,action:{type:`print`}}});else if(t===`-print0`)n.push({type:`expr`,expr:{type:`action`,action:{type:`print0`}}});else if(t===`-printf`){if(r+1>=e.length)return i(t);let a=e[++r];n.push({type:`expr`,expr:{type:`action`,action:{type:`printf`,format:a}}})}else if(t===`-delete`)n.push({type:`expr`,expr:{type:`action`,action:{type:`delete`}}});else return t.startsWith(`-`)?{expr:null,pathIndex:r,error:`find: unknown predicate '${t}'
582
+ `}:{expr:null,pathIndex:r,error:`find: paths must precede expression: \`${t}'
583
+ `};r++}if(n.length===0)return{expr:null,pathIndex:r};let o=Mg(n);return o.error?{expr:null,pathIndex:r,error:o.error}:{expr:o.expr,pathIndex:r}}function Mg(e){let t=0,n;function r(){let r=i();if(!r)return null;for(;t<e.length;){let a=e[t];if(a.type===`op`&&a.op===`or`){t++;let e=i();if(!e)return n=`find: expected an expression after \`-o'
584
+ `,null;r={type:`or`,left:r,right:e}}else break}return r}function i(){let r=a();if(!r)return null;for(;t<e.length;){let i=e[t];if(i.type===`op`&&i.op===`and`){t++;let e=a();if(!e)return n=`find: expected an expression after \`-a'
585
+ `,null;r={type:`and`,left:r,right:e}}else if(i.type===`expr`||i.type===`not`||i.type===`lparen`){let e=a();if(!e)return r;r={type:`and`,left:r,right:e}}else break}return r}function a(){if(t<e.length&&e[t].type===`not`){t++;let e=a();return e?{type:`not`,expr:e}:(n=`find: expected an expression after \`!'
586
+ `,null)}return o()}function o(){if(t>=e.length)return null;let i=e[t];if(i.type===`lparen`){t++;let i=r();return!i||t>=e.length||e[t].type!==`rparen`?(n=`find: missing closing \`)'
587
+ `,null):(t++,i)}return i.type===`expr`?(t++,i.expr):(i.type,null)}let s=r();return!n&&t<e.length&&(n=e[t].type===`rparen`?`find: unexpected \`)'
588
+ `:`find: invalid expression
589
+ `),!n&&s&&Ng(s)&&(n=`find: refusing to evaluate \`-delete' under negation
590
+ `),{expr:n?null:s,error:n}}function Ng(e,t=!1){return e.type===`action`?t&&e.action.type===`delete`:e.type===`not`?Ng(e.expr,!t):e.type===`and`||e.type===`or`?Ng(e.left,t)||Ng(e.right,t):!1}var Pg=T(()=>{}),Fg={};E(Fg,{findCommand:()=>Wg,flagsForFuzzing:()=>Gg});function Ig(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function Lg(e,t,n){e({category:`find`,name:`summary`,durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}function Rg(e){return e?e.type===`action`?[e.action]:e.type===`not`?Rg(e.expr):e.type===`and`||e.type===`or`?[...Rg(e.left),...Rg(e.right)]:[]:[]}function zg(e,t){let n=Fr(e),r=``,i=0;for(;i<n.length;)if(n[i]===`%`&&i+1<n.length){if(i++,n[i]===`%`){r+=`%`,i++;continue}let[e,a,o]=Pr(n,i);if(i+=o,i>=n.length){r+=`%`;break}let s=n[i],c;switch(s){case`f`:c=t.name,i++;break;case`h`:{let e=t.path.lastIndexOf(`/`);c=e>0?t.path.slice(0,e):`.`,i++;break}case`p`:c=t.path,i++;break;case`P`:{let e=t.startingPoint;c=t.path===e?``:t.path.startsWith(`${e}/`)?t.path.slice(e.length+1):e===`.`&&t.path.startsWith(`./`)?t.path.slice(2):t.path,i++;break}case`s`:c=String(t.size),i++;break;case`d`:c=String(t.depth),i++;break;case`m`:c=(t.mode&511).toString(8),i++;break;case`M`:c=Xo(t.mode,t.isDirectory),i++;break;case`t`:c=Bg(new Date(t.mtime)),i++;break;case`T`:if(i+1<n.length){let e=n[i+1];c=Vg(new Date(t.mtime),e),i+=2}else c=`%T`,i++;break;default:r+=`%${e!==0||a!==-1?`${e}.${a}`:``}${s}`,i++;continue}r+=Nr(c,e,a)}else r+=n[i],i++;return r}function Bg(e){return`${[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][e.getDay()]} ${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()]} ${String(e.getDate()).padStart(2,` `)} ${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)} ${e.getFullYear()}`}function Vg(e,t){switch(t){case`@`:return String(e.getTime()/1e3);case`Y`:return String(e.getFullYear());case`m`:return String(e.getMonth()+1).padStart(2,`0`);case`d`:return String(e.getDate()).padStart(2,`0`);case`H`:return String(e.getHours()).padStart(2,`0`);case`M`:return String(e.getMinutes()).padStart(2,`0`);case`S`:return String(e.getSeconds()).padStart(2,`0`);case`T`:return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}`;case`F`:return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;default:return`%T${t}`}}var Hg,Ug,Wg,Gg,Kg=T(()=>{k(),yg(),la(),Kl(),j(),Zo(),F(),Lr(),Ag(),Pg(),Hg=500,Ug={name:`find`,summary:`search for files in a directory hierarchy`,usage:`find [path...] [expression]`,options:`-name PATTERN file name matches shell pattern PATTERN.-iname PATTERN like -name but case insensitive.-path PATTERN file path matches shell pattern PATTERN.-ipath PATTERN like -path but case insensitive.-regex PATTERN file path matches regular expression PATTERN.-iregex PATTERN like -regex but case insensitive.-type TYPE file is of type: f (regular file), d (directory).-empty file is empty or directory is empty.-mtime N file's data was modified N*24 hours ago.-newer FILE file was modified more recently than FILE.-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks).-perm MODE file's permission bits are exactly MODE (octal).-perm -MODE all permission bits MODE are set.-perm /MODE any permission bits MODE are set.-maxdepth LEVELS descend at most LEVELS directories.-mindepth LEVELS do not apply tests at levels less than LEVELS.-depth process directory contents before directory itself.-prune do not descend into this directory.-not, ! negate the following expression.-a, -and logical AND (default).-o, -or logical OR.-exec CMD {} ; execute CMD on each file ({} is replaced by filename).-exec CMD {} + execute CMD with multiple files at once.-print print the full file name (default action).-print0 print the full file name followed by a null character.-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t.-delete delete found files/directories. --help display this help and exit`.split(`.`)},Wg={name:`find`,async execute(e,t){if(N(e))return M(Ug);let n=[],r=null,i=null,a=!1,o=e.length;for(let t=0;t<e.length;t++){let r=e[t];if(r.startsWith(`-`)||r===`(`||r===`\\(`||r===`)`||r===`\\)`||r===`!`){o=t;break}n.push(r)}n.length===0&&n.push(`.`);for(let t=o;t<e.length;t++){let n=e[t];if(n===`-exec`)for(t++;t<e.length&&e[t]!==`;`&&e[t]!==`+`;)t++;else if(n===`-maxdepth`||n===`-mindepth`){let a=e[t+1];if(a===void 0||!/^\d+$/.test(a))return{stdout:``,stderr:a===void 0?`find: missing argument to \`${n}'
591
+ `:`find: invalid argument \`${a}' to \`${n}'
592
+ `,exitCode:1};let o=Number(a);if(!Number.isSafeInteger(o))return{stdout:``,stderr:`find: invalid argument \`${a}' to \`${n}'
593
+ `,exitCode:1};n===`-maxdepth`?r=o:i=o,t++}else n===`-depth`&&(a=!0)}let{expr:s,error:c}=jg(e,o);if(c)return{stdout:``,stderr:c,exitCode:1};let l=Rg(s),u=l.length>0;l.some(e=>e.type===`delete`)&&(a=!0);let d=[],f=0,p=t.executionScope?new vg(t.executionScope,`find`):void 0,m=[],h=[],g=0,_=new ca({limits:t.limits,signal:t.signal,executionScope:t.executionScope,site:`find`}),v=e=>{if(p)p.append(`stdout`,e);else{let n=O(e);if(n>t.limits.maxOutputSize-g)throw new A(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,`output_size`);e&&m.push(e),g+=n}},y=e=>{if(p)p.append(`stderr`,e);else{let n=O(e);if(n>t.limits.maxOutputSize-g)throw new A(`find: output size limit exceeded (${t.limits.maxOutputSize} bytes)`,`output_size`);e&&h.push(e),g+=n}},b=Cg(s),x=new Map;for(let e of b){let n=t.fs.resolvePath(t.cwd,e);try{let r=await t.fs.stat(n);x.set(e,r.mtime?.getTime()??Date.now())}catch{}}let S=l.some(e=>{if(e.type!==`printf`)return!1;let t=e.format.replace(/%%/g,``);return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(t)}),ee=xg(s)||S,C=Sg(s),te=Eg(s),ne=wg(s),w=typeof t.fs.readdirWithFileTypes==`function`;for(let e of n){let n=function(t){if(!(i===null||t.depth>=i))return[];let n=!0,r=[];if(s!==null){let e=Date.now(),i;if(ne)i=Tg(s,t.name,t.relativePath,t.isFile,t.isDirectory);else{let e={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:t.isEmpty,mtime:t.stat?.mtime?.getTime()??Date.now(),size:t.stat?.size??0,mode:t.stat?.mode??420,newerRefTimes:x};i=bg(s,e)}n=i.matches,r=i.actions??[],c.evalCalls++,c.evalTime+=Date.now()-e}if(!u&&n&&(r=[{type:`print`}]),r.length===0)return[];let a={path:t.relativePath,name:t.name,size:t.stat?.size??0,mtime:t.stat?.mtime?.getTime()??Date.now(),mode:t.stat?.mode??420,isDirectory:t.isDirectory,depth:t.depth,startingPoint:e};_.checkpoint(r.length);let o=[];for(let e of r)o.push({action:e,path:t.relativePath,printfData:a});return o};e.length>1&&e.endsWith(`/`)&&(e=e.slice(0,-1));let o=t.fs.resolvePath(t.cwd,e);try{await t.fs.stat(o)}catch{y(`find: ${e}: No such file or directory
594
+ `),f=1;continue}let c=Ig(),l=Date.now();async function p(n){let{path:i,depth:l,typeInfo:u}=n;if(_.visit(l),c.nodeCount++,l>(r??t.limits.maxTraversalDepth))return null;let d,f,p;if(u&&!ee)d=u.isFile,f=u.isDirectory;else{try{let e=Date.now();p=await t.fs.lstat(i),c.statCalls++,c.statTime+=Date.now()-e}catch{return null}if(!p)return null;d=p.isFile,f=p.isDirectory}let m;m=i===o?e.split(`/`).pop()||e:i.split(`/`).pop()||``;let h=i===o?e:e===`.`?`./${i.slice(o===`/`?o.length:o.length+1)}`:e+i.slice(o.length),g=[],v=null,y=null,b=!1;f&&te&&!a&&(b=Og(s,{name:m,relativePath:h,isFile:d,isDirectory:f}).shouldPrune,b&&c.earlyPrunes++);let S=!(l>=(r??t.limits.maxTraversalDepth))&&!b;if(f&&(S||C)&&!b){let e=Date.now();if(w&&t.fs.readdirWithFileTypes){v=await t.fs.readdirWithFileTypes(i),_.checkpoint(),_.discover(v.length),y=[];for(let e of v)y.push(e.name);if(c.readdirCalls++,c.readdirTime+=Date.now()-e,S)for(let e=0;e<v.length;e++){let t=v[e];g.push({path:i===`/`?`/${t.name}`:`${i}/${t.name}`,depth:l+1,typeInfo:{isFile:t.isFile,isDirectory:t.isDirectory},resultIndex:e})}}else if(y=await t.fs.readdir(i),_.checkpoint(),_.discover(y.length),c.readdirCalls++,c.readdirTime+=Date.now()-e,S)for(let e=0;e<y.length;e++){let t=y[e];g.push({path:i===`/`?`/${t}`:`${i}/${t}`,depth:l+1,resultIndex:e})}}let ne=d?(p?.size??0)===0:y!==null&&y.length===0,re=b;if(!a&&s!==null&&!b&&te){let e=Date.now(),t={name:m,relativePath:h,isFile:d,isDirectory:f,isEmpty:ne,mtime:p?.mtime?.getTime()??Date.now(),size:p?.size??0,mode:p?.mode??420,newerRefTimes:x};re=bg(s,t).pruned,c.evalCalls++,c.evalTime+=Date.now()-e}return{relativePath:h,name:m,isFile:d,isDirectory:f,isEmpty:ne,stat:p,depth:l,children:re?[]:g,pruned:re}}async function m(){let e={effects:[]};if(a){let t=[],r=[{item:{path:o,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],i=new Map,a=0;for(;a<r.length;){let e=Date.now(),n=Math.min(r.length,a+Hg),o=r.slice(a,n);a=n;let s=await Promise.all(o.map(e=>p(e.item)));c.batchCount++,c.batchTime+=Date.now()-e;for(let e=0;e<o.length;e++){let n=s[e],a=o[e];if(!n)continue;let c=t.length;if(a.parentIndex>=0){let e=i.get(a.parentIndex)||[];e.push(c),i.set(a.parentIndex,e)}t.push({node:n,parentIndex:a.parentIndex,childIndices:[]});for(let e=0;e<n.children.length;e++)r.push({item:n.children[e],parentIndex:c,childOrderInParent:e})}}for(let[e,n]of i)e>=0&&e<t.length&&(t[e].childIndices=n);if(t.length>0){let r=[{index:0,visited:!1}];for(;r.length>0;){_.checkpoint();let i=r.pop();if(!i)break;let a=t[i.index];if(a){if(i.visited){for(let t of n(a.node))e.effects.push(t);continue}r.push({index:i.index,visited:!0});for(let e=a.childIndices.length-1;e>=0;e--)r.push({index:a.childIndices[e],visited:!1})}}}}else{let t=new Map,r=0,i=[{item:{path:o,depth:0,resultIndex:0},orderIndex:r++}],a=new Map,s=0;for(;s<i.length;){let e=Date.now(),o=Math.min(i.length,s+Hg),l=i.slice(s,o);s=o;let u=await Promise.all(l.map(async({item:e,orderIndex:t})=>{let n=await p(e);return n?{node:n,orderIndex:t}:null}));c.batchCount++,c.batchTime+=Date.now()-e;for(let e of u){if(!e)continue;let{node:o,orderIndex:s}=e,c=n(o);if(c.length>0&&t.set(s,c),o.children.length>0){let e=[];for(let t of o.children){let n=r++;e.push(n),i.push({item:t,orderIndex:n})}a.set(s,e)}}}let l=[0];for(;l.length>0;){_.checkpoint();let n=l.pop();if(n===void 0)break;let r=t.get(n);if(r)for(let t of r)e.effects.push(t);let i=a.get(n);if(i)for(let e=i.length-1;e>=0;e--)l.push(i[e])}}return e}let h=await m();for(let e of h.effects)d.push(e);if(t.trace){let n=Date.now()-l;Lg(t.trace,c,n),t.trace({category:`find`,name:`searchPath`,durationMs:n,details:{path:e,resultsFound:h.effects.length}})}}let re=new Map;for(let e of d){let{action:n,path:r}=e;switch(n.type){case`print`:v(`${r}
595
+ `);break;case`print0`:v(`${r}\0`);break;case`printf`:v(zg(n.format,e.printfData));break;case`delete`:{let e=t.fs.resolvePath(t.cwd,r);try{await t.fs.rm(e,{recursive:!1})}catch(e){y(`find: cannot delete '${r}': ${e instanceof Error?e.message:String(e)}
596
+ `),f=1}break}case`exec`:{if(!t.exec)return{stdout:``,stderr:`find: -exec not supported in this context
597
+ `,exitCode:1};if(n.batchMode){let e=re.get(n)??[];e.push(r),re.set(n,e);break}let e=n.command.map(e=>e===`{}`?r:e),i=await t.exec(Gl([e[0]]),{cwd:t.cwd,signal:t.signal,args:e.slice(1)});p?p.appendResult(i):(v(i.stdout),y(i.stderr)),i.exitCode!==0&&(f=i.exitCode);break}}}for(let[e,n]of re){if(e.type!==`exec`||!t.exec||n.length===0)continue;let r=[];for(let t of e.command)t===`{}`?r.push(...n):r.push(t);let i=await t.exec(Gl([r[0]]),{cwd:t.cwd,signal:t.signal,args:r.slice(1)});p?p.appendResult(i):(v(i.stdout),y(i.stderr)),i.exitCode!==0&&(f=i.exitCode)}return p?.build(f)??{stdout:m.join(``),stderr:h.join(``),exitCode:f}}},Gg={name:`find`,flags:[{flag:`-name`,type:`value`,valueHint:`pattern`},{flag:`-iname`,type:`value`,valueHint:`pattern`},{flag:`-type`,type:`value`,valueHint:`string`},{flag:`-maxdepth`,type:`value`,valueHint:`number`},{flag:`-mindepth`,type:`value`,valueHint:`number`},{flag:`-empty`,type:`boolean`},{flag:`-print`,type:`boolean`},{flag:`-print0`,type:`boolean`}],needsFiles:!0}}),qg={};E(qg,{basenameCommand:()=>Yg,flagsForFuzzing:()=>Xg});var Jg,Yg,Xg,Zg=T(()=>{F(),Jg={name:`basename`,summary:`strip directory and suffix from filenames`,usage:`basename NAME [SUFFIX]
598
+ basename OPTION... NAME...`,options:[`-a, --multiple support multiple arguments`,`-s, --suffix=SUFFIX remove a trailing SUFFIX`,` --help display this help and exit`]},Yg={name:`basename`,async execute(e,t){if(N(e))return M(Jg);let n=!1,r=``,i=[];for(let t=0;t<e.length;t++){let a=e[t];a===`-a`||a===`--multiple`?n=!0:a===`-s`&&t+1<e.length?(r=e[++t],n=!0):a.startsWith(`--suffix=`)?(r=a.slice(9),n=!0):a.startsWith(`-`)||i.push(a)}if(i.length===0)return{stdout:``,stderr:`basename: missing operand
599
+ `,exitCode:1};!n&&i.length>=2&&(r=i.pop()??``);let a=[];for(let e of i){let t=e.replace(/\/+$/,``),n=t.split(`/`).pop()||t;r&&n.endsWith(r)&&(n=n.slice(0,-r.length)),a.push(n)}return{stdout:`${a.join(`
600
+ `)}
601
+ `,stderr:``,exitCode:0}}},Xg={name:`basename`,flags:[{flag:`-a`,type:`boolean`},{flag:`-s`,type:`value`,valueHint:`string`}],needsArgs:!0}}),Qg={};E(Qg,{dirnameCommand:()=>e_,flagsForFuzzing:()=>t_});var $g,e_,t_,n_=T(()=>{F(),$g={name:`dirname`,summary:`strip last component from file name`,usage:`dirname [OPTION] NAME...`,options:[` --help display this help and exit`]},e_={name:`dirname`,async execute(e,t){if(N(e))return M($g);let n=e.filter(e=>!e.startsWith(`-`));if(n.length===0)return{stdout:``,stderr:`dirname: missing operand
602
+ `,exitCode:1};let r=[];for(let e of n){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);n===-1?r.push(`.`):n===0?r.push(`/`):r.push(t.slice(0,n))}return{stdout:`${r.join(`
603
+ `)}
604
+ `,stderr:``,exitCode:0}}},t_={name:`dirname`,flags:[],needsArgs:!0}}),r_={};E(r_,{flagsForFuzzing:()=>l_,treeCommand:()=>c_});async function i_(e,t,n,r,i){let a={output:``,stderr:``,dirCount:0,fileCount:0},o=e.fs.resolvePath(e.cwd,t);try{if(!(await e.fs.stat(o)).isDirectory)return a.output=`${t}
605
+ `,a.fileCount=1,a}catch{return a.stderr=`tree: ${t}: No such file or directory
606
+ `,a}if(a.output=`${t}
607
+ `,n.maxDepth!==null&&i>=n.maxDepth)return a;try{let t=[];if(e.fs.readdirWithFileTypes)t=(await e.fs.readdirWithFileTypes(o)).map(e=>({name:e.name,isDirectory:e.isDirectory}));else{let n=await e.fs.readdir(o);for(let r=0;r<n.length;r+=100){let i=n.slice(r,r+100),a=await Promise.all(i.map(async t=>{let n=o===`/`?`/${t}`:`${o}/${t}`;try{return{name:t,isDirectory:(await e.fs.stat(n)).isDirectory}}catch{return null}}));t.push(...a.filter(e=>e!==null))}}let s=t.filter(e=>!(!n.showHidden&&e.name.startsWith(`.`)||n.directoriesOnly&&!e.isDirectory));s.sort((e,t)=>e.name.localeCompare(t.name));for(let t=0;t<s.length;t++){let c=s[t],l=o===`/`?`/${c.name}`:`${o}/${c.name}`,u=t===s.length-1,d=u?"`-- ":`|-- `,f=r+(u?` `:`| `);if(c.isDirectory){a.dirCount++;let t=n.fullPath?l:c.name;if(a.output+=`${r+d+t}
608
+ `,n.maxDepth===null||i+1<n.maxDepth){let t=await a_(e,l,n,f,i+1);a.output+=t.output,a.dirCount+=t.dirCount,a.fileCount+=t.fileCount}}else{a.fileCount++;let e=n.fullPath?l:c.name;a.output+=`${r+d+e}
609
+ `}}}catch{a.stderr=`tree: ${t}: Permission denied
610
+ `}return a}async function a_(e,t,n,r,i){let a={output:``,stderr:``,dirCount:0,fileCount:0};if(n.maxDepth!==null&&i>=n.maxDepth)return a;try{let o=[];if(e.fs.readdirWithFileTypes)o=(await e.fs.readdirWithFileTypes(t)).map(e=>({name:e.name,isDirectory:e.isDirectory}));else{let n=await e.fs.readdir(t);for(let r=0;r<n.length;r+=100){let i=n.slice(r,r+100),a=await Promise.all(i.map(async n=>{let r=t===`/`?`/${n}`:`${t}/${n}`;try{return{name:n,isDirectory:(await e.fs.stat(r)).isDirectory}}catch{return null}}));o.push(...a.filter(e=>e!==null))}}let s=o.filter(e=>!(!n.showHidden&&e.name.startsWith(`.`)||n.directoriesOnly&&!e.isDirectory));s.sort((e,t)=>e.name.localeCompare(t.name));for(let o=0;o<s.length;o++){let c=s[o],l=t===`/`?`/${c.name}`:`${t}/${c.name}`,u=o===s.length-1,d=u?"`-- ":`|-- `,f=r+(u?` `:`| `);if(c.isDirectory){a.dirCount++;let t=n.fullPath?l:c.name;a.output+=`${r+d+t}
611
+ `;let o=await a_(e,l,n,f,i+1);a.output+=o.output,a.dirCount+=o.dirCount,a.fileCount+=o.fileCount}else{a.fileCount++;let e=n.fullPath?l:c.name;a.output+=`${r+d+e}
612
+ `}}}catch{}return a}var o_,s_,c_,l_,u_=T(()=>{Kr(),qr(),F(),o_={name:`tree`,summary:`list contents of directories in a tree-like format`,usage:`tree [OPTION]... [DIRECTORY]...`,options:[`-a include hidden files`,`-d list directories only`,`-L LEVEL limit depth of directory tree`,`-f print full path prefix for each file`,` --help display this help and exit`]},s_={showHidden:{short:`a`,type:`boolean`},directoriesOnly:{short:`d`,type:`boolean`},fullPath:{short:`f`,type:`boolean`},maxDepth:{short:`L`,type:`number`}},c_={name:`tree`,async execute(e,t){if(N(e))return M(o_);let n=Gr(`tree`,e,s_);if(!n.ok)return n.error;let r={showHidden:n.result.flags.showHidden,directoriesOnly:n.result.flags.directoriesOnly,maxDepth:n.result.flags.maxDepth??null,fullPath:n.result.flags.fullPath},i=n.result.positional;i.length===0&&i.push(`.`);let a=``,o=``,s=0,c=0;for(let e of i){let n=await i_(t,e,r,``,0);a+=n.output,o+=n.stderr,s+=n.dirCount,c+=n.fileCount}return a+=`
613
+ ${s} director${s===1?`y`:`ies`}`,r.directoriesOnly||(a+=`, ${c} file${c===1?``:`s`}`),a+=`
614
+ `,{stdout:a,stderr:o,exitCode:+!!o}}},l_={name:`tree`,flags:[{flag:`-a`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-L`,type:`value`,valueHint:`number`}],needsFiles:!0}}),d_={};E(d_,{duCommand:()=>g_,flagsForFuzzing:()=>__});async function f_(e,t,n,r,i){let a={output:``,totalSize:0,stderr:``},o=new Map;return await oa({fs:e.fs,root:t,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:`du`,symlinks:`never`,includeLeave:!0},e=>{let s=e.path.slice(t.length).replace(/^\//,``),c=s?n===`.`?s:`${n}/${s}`:n,l=e.path===`/`?`/`:e.path.slice(0,e.path.lastIndexOf(`/`))||`/`;if(e.phase===`enter`){if(e.stat.isDirectory){o.set(e.path,0);return}o.set(l,(o.get(l)??0)+e.stat.size),(r.allFiles||e.depth===i)&&!r.summarize&&(a.output+=`${p_(e.stat.size,r.humanReadable)} ${c}
615
+ `),e.depth===i&&(a.totalSize=e.stat.size);return}let u=o.get(e.path)??0;e.depth>i?o.set(l,(o.get(l)??0)+u):a.totalSize=u;let d=e.depth-i;(r.summarize&&d===0||!r.summarize&&(r.maxDepth===null||d<=r.maxDepth))&&(a.output+=`${p_(u,r.humanReadable)} ${c}
616
+ `)}),a}function p_(e,t){return t?e<1024?`${e}`:e<1048576?`${(e/1024).toFixed(1)}K`:e<1073741824?`${(e/1048576).toFixed(1)}M`:`${(e/1073741824).toFixed(1)}G`:String(Math.ceil(e/1024)||1)}var m_,h_,g_,__,v_=T(()=>{la(),j(),Kr(),F(),m_={name:`du`,summary:`estimate file space usage`,usage:`du [OPTION]... [FILE]...`,options:[`-a write counts for all files, not just directories`,`-h print sizes in human readable format`,`-s display only a total for each argument`,`-c produce a grand total`,`--max-depth=N print total for directory only if N or fewer levels deep`,` --help display this help and exit`]},h_={allFiles:{short:`a`,type:`boolean`},humanReadable:{short:`h`,type:`boolean`},summarize:{short:`s`,type:`boolean`},grandTotal:{short:`c`,type:`boolean`},maxDepth:{long:`max-depth`,type:`number`}},g_={name:`du`,async execute(e,t){if(N(e))return M(m_);let n=Gr(`du`,e,h_);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},i=n.result.positional;i.length===0&&i.push(`.`);let a=``,o=``,s=0;for(let e of i){let n=t.fs.resolvePath(t.cwd,e);try{await t.fs.stat(n);let i=await f_(t,n,e,r,0);a+=i.output,s+=i.totalSize,o+=i.stderr}catch(t){if(t instanceof A||t instanceof kr)throw t;o+=`du: cannot access '${e}': No such file or directory
617
+ `}}return r.grandTotal&&i.length>0&&(a+=`${p_(s,r.humanReadable)} total
618
+ `),{stdout:a,stderr:o,exitCode:+!!o}}},__={name:`du`,flags:[{flag:`-a`,type:`boolean`},{flag:`-h`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`--max-depth`,type:`value`,valueHint:`number`}],needsFiles:!0}}),y_={};E(y_,{envCommand:()=>x_,flagsForFuzzing:()=>w_,printenvCommand:()=>C_,printenvFlagsForFuzzing:()=>T_});var b_,x_,S_,C_,w_,T_,E_=T(()=>{k(),od(),F(),b_={name:`env`,summary:`run a program in a modified environment`,usage:`env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]`,options:[`-i, --ignore-environment start with an empty environment`,`-u NAME, --unset=NAME remove NAME from the environment`,` --help display this help and exit`]},x_={name:`env`,async execute(e,t){if(N(e))return M(b_);let n=!1,r=[],i=new Map,a=-1;for(let t=0;t<e.length;t++){let o=e[t];if(o===`-i`||o===`--ignore-environment`)n=!0;else if(o===`-u`&&t+1<e.length)r.push(e[++t]);else if(o.startsWith(`-u`))r.push(o.slice(2));else if(o.startsWith(`--unset=`))r.push(o.slice(8));else{if(o.startsWith(`--`)&&o!==`--`)return P(`env`,o);if(o.startsWith(`-`)&&o!==`-`){for(let e of o.slice(1))if(e!==`i`&&e!==`u`)return P(`env`,`-${e}`);o.includes(`i`)&&(n=!0)}else if(o.includes(`=`)&&a===-1){let e=o.indexOf(`=`),t=o.slice(0,e),n=o.slice(e+1);i.set(t,n)}else{a=t;break}}}let o;if(n)o=new Map(i);else{o=new Map(t.env);for(let e of r)o.delete(e);for(let[e,t]of i)o.set(e,t)}if(a===-1){let e=[];for(let[t,n]of o)e.push(`${t}=${n}`);return{stdout:e.join(`
619
+ `)+(e.length>0?`
620
+ `:``),stderr:``,exitCode:0}}if(!t.exec)return{stdout:``,stderr:`env: command execution not supported in this context
621
+ `,exitCode:1};let s=e.slice(a);return t.exec(`command`,{cwd:t.cwd,env:rd(o),replaceEnv:!0,stdin:t.stdin,stdinKind:`bytes`,signal:t.signal,args:s})}},S_={name:`printenv`,summary:`print all or part of environment`,usage:`printenv [OPTION]... [VARIABLE]...`,options:[` --help display this help and exit`]},C_={name:`printenv`,async execute(e,t){if(N(e))return M(S_);let n=e.filter(e=>!e.startsWith(`-`));if(n.length===0){let e=[];for(let[n,r]of t.env)e.push(`${n}=${r}`);return{stdout:e.join(`
622
+ `)+(e.length>0?`
623
+ `:``),stderr:``,exitCode:0}}let r=[],i=0;for(let e of n){let n=t.env.get(e);n===void 0?i=1:r.push(n)}return{stdout:r.join(`
624
+ `)+(r.length>0?`
625
+ `:``),stderr:``,exitCode:i}}},w_={name:`env`,flags:[{flag:`-i`,type:`boolean`},{flag:`-u`,type:`value`,valueHint:`string`}]},T_={name:`printenv`,flags:[]}}),D_={};E(D_,{aliasCommand:()=>A_,flagsForFuzzing:()=>M_,unaliasCommand:()=>j_,unaliasFlagsForFuzzing:()=>N_});var O_,k_,A_,j_,M_,N_,P_=T(()=>{F(),O_={name:`alias`,summary:`define or display aliases`,usage:`alias [name[=value] ...]`,options:[` --help display this help and exit`]},k_=`BASH_ALIAS_`,A_={name:`alias`,async execute(e,t){if(N(e))return M(O_);if(e.length===0){let e=``;for(let[n,r]of t.env)if(n.startsWith(k_)){let t=n.slice(k_.length);e+=`alias ${t}='${r}'
626
+ `}return{stdout:e,stderr:``,exitCode:0}}let n=e[0]===`--`?e.slice(1):e;for(let e of n){let n=e.indexOf(`=`);if(n===-1){let n=k_+e;return t.env.get(n)?{stdout:`alias ${e}='${t.env.get(n)}'
627
+ `,stderr:``,exitCode:0}:{stdout:``,stderr:`alias: ${e}: not found
628
+ `,exitCode:1}}{let r=e.slice(0,n),i=e.slice(n+1);(i.startsWith(`'`)&&i.endsWith(`'`)||i.startsWith(`"`)&&i.endsWith(`"`))&&(i=i.slice(1,-1)),t.env.set(k_+r,i)}}return{stdout:``,stderr:``,exitCode:0}}},j_={name:`unalias`,async execute(e,t){if(N(e))return M({name:`unalias`,summary:`remove alias definitions`,usage:`unalias name [name ...]`,options:[`-a remove all aliases`,` --help display this help and exit`]});if(e.length===0)return{stdout:``,stderr:`unalias: usage: unalias [-a] name [name ...]
629
+ `,exitCode:1};if(e[0]===`-a`){for(let e of t.env.keys())e.startsWith(k_)&&t.env.delete(e);return{stdout:``,stderr:``,exitCode:0}}let n=e[0]===`--`?e.slice(1):e,r=!1,i=``;for(let e of n){let n=k_+e;t.env.get(n)?t.env.delete(n):(i+=`unalias: ${e}: not found
630
+ `,r=!0)}return{stdout:``,stderr:i,exitCode:+!!r}}},M_={name:`alias`,flags:[]},N_={name:`unalias`,flags:[{flag:`-a`,type:`boolean`}]}}),F_={};E(F_,{flagsForFuzzing:()=>z_,historyCommand:()=>R_});var I_,L_,R_,z_,B_=T(()=>{F(),I_={name:`history`,summary:`display command history`,usage:`history [n]`,options:[`-c clear the history list`,` --help display this help and exit`]},L_=`BASH_HISTORY`,R_={name:`history`,async execute(e,t){if(N(e))return M(I_);let n=t.env.get(L_)||`[]`,r;try{r=JSON.parse(n)}catch{r=[]}if(e[0]===`-c`)return t.env.set(L_,`[]`),{stdout:``,stderr:``,exitCode:0};let i=r.length;e[0]&&/^\d+$/.test(e[0])&&(i=Math.min(parseInt(e[0],10),r.length));let a=r.length-i,o=``;for(let e=a;e<r.length;e++){let t=(e+1).toString().padStart(5,` `);o+=`${t} ${r[e]}
631
+ `}return{stdout:o,stderr:``,exitCode:0}}},z_={name:`history`,flags:[{flag:`-c`,type:`boolean`}]}}),V_={};E(V_,{flagsForFuzzing:()=>K_,xargsCommand:()=>G_});function H_(e,t,n){if(t.length===0)throw Error(`xargs: delimiter must not be empty`);let r=[],i=0;for(;i<=e.length;){let a=e.indexOf(t,i),o=e.slice(i,a===-1?e.length:a);if(o.length>0){if(r.length>=n)throw new A(`xargs: array element limit exceeded (${n})`,`array_elements`);r.push(o)}if(a===-1)break;i=a+t.length}return r}function U_(e,t){let n=[],r=-1;for(let i=0;i<=e.length;i++){let a=i===e.length||/\s/.test(e[i]);if(!a&&r===-1&&(r=i),a&&r!==-1){if(n.length>=t)throw new A(`xargs: array element limit exceeded (${t})`,`array_elements`);n.push(e.slice(r,i)),r=-1}}return n}var W_,G_,K_,q_=T(()=>{k(),yg(),Kl(),j(),F(),Lr(),W_={name:`xargs`,summary:`build and execute command lines from standard input`,usage:`xargs [OPTION]... [COMMAND [INITIAL-ARGS]]`,options:[`-I REPLACE replace occurrences of REPLACE with input`,`-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)`,`-n NUM use at most NUM arguments per command line`,`-P NUM run at most NUM processes at a time`,`-0, --null items are separated by null, not whitespace`,`-t, --verbose print commands before executing`,`-r, --no-run-if-empty do not run command if input is empty`,` --help display this help and exit`]},G_={name:`xargs`,async execute(e,t){if(N(e))return M(W_);let n=null,r=null,i=null,a=null,o=!1,s=!1,c=0;for(let t=0;t<e.length;t++){let l=e[t];if(l===`-I`&&t+1<e.length)n=e[++t],c=t+1;else if(l===`-d`&&t+1<e.length)r=e[++t].replace(/\\n/g,`
632
+ `).replace(/\\t/g,` `).replace(/\\r/g,`\r`).replace(/\\0/g,`\0`).replace(/\\\\/g,`\\`),c=t+1;else if(l===`-n`&&t+1<e.length){let n=e[++t],r=Number(n);if(!/^\d+$/.test(n)||!Number.isSafeInteger(r)||r<1)return{stdout:``,stderr:`xargs: invalid number for -n: '${n}'
633
+ `,exitCode:1};i=r,c=t+1}else if(l===`-P`&&t+1<e.length){let n=e[++t],r=Number(n);if(!/^\d+$/.test(n)||!Number.isSafeInteger(r))return{stdout:``,stderr:`xargs: invalid number for -P: '${n}'
634
+ `,exitCode:1};a=r,c=t+1}else if(l===`-0`||l===`--null`)o=!0,c=t+1;else if(l===`-t`||l===`--verbose`)s=!0,c=t+1;else if(l===`-r`||l===`--no-run-if-empty`)c=t+1;else{if(l.startsWith(`--`))return P(`xargs`,l);if(l.startsWith(`-`)&&l.length>1){for(let e of l.slice(1))if(!`0tr`.includes(e))return P(`xargs`,`-${e}`);l.includes(`0`)&&(o=!0),l.includes(`t`)&&(s=!0),l.includes(`r`),c=t+1}else if(!l.startsWith(`-`)){c=t;break}}}let l=e.slice(c);l.length===0&&l.push(`echo`);let u=or(t.stdin),d=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength),f=t.limits.maxArrayElements,p=t.limits.maxLoopIterations,m=t.limits.maxOutputSize;if(O(u)>d)throw new A(`xargs: input size limit exceeded (${d} bytes)`,`string_length`);if(a!==null&&a>f)throw new A(`xargs: array element limit exceeded (${f})`,`array_elements`);let h;if(o)h=H_(u,`\0`,f);else if(r!==null){let e=u.replace(/\n$/,``);try{h=H_(e,r,f)}catch(e){if(e instanceof A)throw e;return{stdout:``,stderr:`xargs: delimiter must not be empty
635
+ `,exitCode:1}}}else h=U_(u,f);if(h.length===0)return{stdout:``,stderr:``,exitCode:0};let g=[],_=[],v=0,y=0,b=0,x=t.executionScope?new vg(t.executionScope,`xargs`):void 0,S=e=>{if(x){x.appendResult(e);return}let t=O(e.stdout)+O(e.stderr);if(t>m-y)throw new A(`xargs: output size limit exceeded (${m} bytes)`,`output_size`);e.stdout&&g.push(e.stdout),e.stderr&&_.push(e.stderr),y+=t},ee=e=>{if(x){x.append(`stderr`,e);return}let t=O(e);if(t>m-y)throw new A(`xargs: output size limit exceeded (${m} bytes)`,`output_size`);e&&_.push(e),y+=t},C=e=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(e)?`"${e.replace(/([\\"`$])/g,`\\$1`)}"`:e,te=async e=>{if(++b>p)throw new A(`xargs: iteration limit exceeded (${p})`,`iterations`);if(e.length>f)throw new A(`xargs: array element limit exceeded (${f})`,`array_elements`);for(let t of e)if(O(t)>d)throw new A(`xargs: string length limit exceeded (${d} bytes)`,`string_length`);if(s){let t=e.map(C).join(` `);ee(`${t}
636
+ `)}return t.exec?t.exec(Gl([e[0]]),{cwd:t.cwd,signal:t.signal,args:e.slice(1)}):{stdout:`${e.map(C).join(` `)}
637
+ `,stderr:``,exitCode:0}},ne=async e=>{if(a!==null&&a>1)for(let t=0;t<e.length;t+=a){let n=e.slice(t,t+a),r=await Promise.all(n.map(te));for(let e of r)S(e),e.exitCode!==0&&(v=e.exitCode)}else for(let t of e){let e=await te(t);S(e),e.exitCode!==0&&(v=e.exitCode)}};if(n!==null){if(h.length>p)throw new A(`xargs: iteration limit exceeded (${p})`,`iterations`);if(n.length===0)return{stdout:``,stderr:`xargs: replacement string must not be empty
638
+ `,exitCode:1};if(l.length>0&&h.length>Math.floor(f/l.length))throw new A(`xargs: array element limit exceeded (${f})`,`array_elements`);let e=(e,t)=>{let r=0,i=0;for(;i=e.indexOf(n,i),i!==-1;)r++,i+=n.length;if(O(e)+r*(O(t)-O(n))>d)throw new A(`xargs: string length limit exceeded (${d} bytes)`,`string_length`);return e.replaceAll(n,t)};await ne(h.map(t=>l.map(n=>e(n,t))))}else if(i!==null){let e=[],t=Math.ceil(h.length/i);if(t>Math.min(f,p))throw new A(`xargs: iteration limit exceeded (${p})`,`iterations`);if(h.length+t*l.length>f)throw new A(`xargs: array element limit exceeded (${f})`,`array_elements`);for(let t=0;t<h.length;t+=i){let n=h.slice(t,t+i);e.push([...l,...n])}await ne(e)}else{let e=await te([...l,...h]);S(e),v=e.exitCode}return x?.build(v)??{stdout:g.join(``),stderr:_.join(``),exitCode:v}}},K_={name:`xargs`,flags:[{flag:`-I`,type:`value`,valueHint:`string`},{flag:`-d`,type:`value`,valueHint:`delimiter`},{flag:`-n`,type:`value`,valueHint:`number`},{flag:`-0`,type:`boolean`},{flag:`-t`,type:`boolean`},{flag:`-r`,type:`boolean`}],stdinType:`text`}}),J_={};E(J_,{falseCommand:()=>X_,falseFlagsForFuzzing:()=>Q_,flagsForFuzzing:()=>Z_,trueCommand:()=>Y_});var Y_,X_,Z_,Q_,$_=T(()=>{Y_={name:`true`,async execute(){return{stdout:``,stderr:``,exitCode:0}}},X_={name:`false`,async execute(){return{stdout:``,stderr:``,exitCode:1}}},Z_={name:`true`,flags:[]},Q_={name:`false`,flags:[]}}),ev={};E(ev,{clearCommand:()=>nv,flagsForFuzzing:()=>rv});var tv,nv,rv,iv=T(()=>{F(),tv={name:`clear`,summary:`clear the terminal screen`,usage:`clear [OPTIONS]`,options:[` --help display this help and exit`]},nv={name:`clear`,async execute(e,t){return N(e)?M(tv):{stdout:`\x1B[2J\x1B[H`,stderr:``,exitCode:0}}},rv={name:`clear`,flags:[]}}),av={};E(av,{bashCommand:()=>cv,flagsForFuzzing:()=>uv,shCommand:()=>lv,shFlagsForFuzzing:()=>dv});async function ov(e,t,n,r){if(!r.exec)return{stdout:``,stderr:`bash: internal error: exec function not available
639
+ `,exitCode:1};let i=ad(r.exportedEnv||{},{0:t,"#":String(n.length),"@":n.join(` `),"*":n.join(` `)});n.forEach((e,t)=>{i[String(t+1)]=e});let a=e;if(a.startsWith(`#!`)){let e=a.indexOf(`
640
+ `);e!==-1&&(a=a.slice(e+1))}let o=r.execWithInheritedStdin;return o?await o(a,{env:i,cwd:r.cwd,signal:r.signal}):await r.exec(a,{env:i,cwd:r.cwd,stdin:r.stdin,stdinKind:`bytes`,signal:r.signal})}var sv,cv,lv,uv,dv,fv=T(()=>{k(),od(),F(),sv={name:`bash`,summary:`execute shell commands or scripts`,usage:`bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]`,options:[`-c COMMAND execute COMMAND string`,` --help display this help and exit`],notes:[`Without -c, reads and executes commands from SCRIPT_FILE.`,`Arguments are passed as $1, $2, etc. to the script.`,`$0 is set to the script name (or "bash" with -c).`]},cv={name:`bash`,async execute(e,t){if(N(e))return M(sv);if(e[0]===`-c`&&e.length>=2){let n=e[1];return ov(n,e[2]||`bash`,e.slice(3),t)}if(e.length===0){let e=or(t.stdin);return e.trim()?ov(e,`bash`,[],t):{stdout:``,stderr:``,exitCode:0}}let n=e[0],r=e.slice(1);try{let e=t.fs.resolvePath(t.cwd,n);return ov(await t.fs.readFile(e),n,r,t)}catch{return{stdout:``,stderr:`bash: ${n}: No such file or directory
641
+ `,exitCode:127}}}},lv={name:`sh`,async execute(e,t){if(N(e))return M({...sv,name:`sh`,summary:`execute shell commands or scripts (POSIX shell)`});if(e[0]===`-c`&&e.length>=2){let n=e[1];return ov(n,e[2]||`sh`,e.slice(3),t)}if(e.length===0){let e=or(t.stdin);return e.trim()?ov(e,`sh`,[],t):{stdout:``,stderr:``,exitCode:0}}let n=e[0],r=e.slice(1);try{let e=t.fs.resolvePath(t.cwd,n);return ov(await t.fs.readFile(e),n,r,t)}catch{return{stdout:``,stderr:`sh: ${n}: No such file or directory
642
+ `,exitCode:127}}}},uv={name:`bash`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`},dv={name:`sh`,flags:[{flag:`-c`,type:`value`,valueHint:`string`}],stdinType:`text`}});function pv(e,t,n=1){let r=e.limits.maxArrayElements;if(n<0||t>r-n)throw new A(`query result element limit exceeded (${r})`,`array_elements`)}function mv(e,t,n,r,i,a,o,s,c,l){switch(t){case`sort`:return Array.isArray(e)?[[...e].sort(o)]:[null];case`sort_by`:return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)})];case`bsearch`:if(!Array.isArray(e))throw Error(`${e===null?`null`:typeof e==`object`?`object`:typeof e} (${JSON.stringify(e)}) cannot be searched from`);return n.length===0?[null]:i(e,n[0],r).map(t=>{let n=0,r=e.length;for(;n<r;){let i=n+r>>>1;o(e[i],t)<0?n=i+1:r=i}return n<e.length&&o(e[n],t)===0?n:-n-1});case`unique_by`:{if(!Array.isArray(e)||n.length===0)return[null];let t=new Map;for(let a of e){let e=i(a,n[0],r)[0],o=JSON.stringify(e);t.has(o)||t.set(o,{item:a,key:e})}let a=[...t.values()];return a.sort((e,t)=>o(e.key,t.key)),[a.map(e=>e.item)]}case`group_by`:{if(!Array.isArray(e)||n.length===0)return[null];let t=new Map;for(let a of e){let e=JSON.stringify(i(a,n[0],r)[0]);t.has(e)||t.set(e,[]),t.get(e)?.push(a)}return[[...t.values()]]}case`max`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)>0?e:t)]:[null];case`max_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)>0?e:t})];case`min`:return Array.isArray(e)&&e.length>0?[e.reduce((e,t)=>o(e,t)<0?e:t)]:[null];case`min_by`:return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((e,t)=>{let a=i(e,n[0],r)[0],s=i(t,n[0],r)[0];return o(a,s)<0?e:t})];case`add`:{let t=e=>{let t=e.filter(e=>e!==null);return t.length===0?null:t.every(e=>typeof e==`number`)?t.reduce((e,t)=>e+t,0):t.every(e=>typeof e==`string`)?t.join(``):t.every(e=>Array.isArray(e))?t.flat():t.every(e=>e&&typeof e==`object`&&!Array.isArray(e))?ad(...t):null};return n.length>=1?[t(i(e,n[0],r))]:Array.isArray(e)?[t(e)]:[null]}case`any`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(i(e,n[1],r).some(s))return[!0]}catch(e){if(e instanceof l)throw e}return[!1]}return n.length===1?Array.isArray(e)?[e.some(e=>s(i(e,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(s)]:[!1];case`all`:if(n.length>=2){try{let t=a(e,n[0],r);for(let e of t)if(!i(e,n[1],r).some(s))return[!1]}catch(e){if(e instanceof l)throw e}return[!0]}return n.length===1?Array.isArray(e)?[e.every(e=>s(i(e,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(s)]:[!0];case`select`:return n.length===0||i(e,n[0],r).some(s)?[e]:[];case`map`:{if(n.length===0||!Array.isArray(e))return[null];pv(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);pv(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}case`map_values`:if(n.length===0)return[null];if(Array.isArray(e)){pv(r,0,e.length);let t=[];for(let a of e){let e=i(a,n[0],r);pv(r,t.length,e.length);for(let n of e)t.push(n)}return[t]}if(e&&typeof e==`object`){let t=Object.create(null),a=Object.keys(e);pv(r,0,a.length);for(let o of a){if(!fl(o))continue;let a=e[o],s=i(a,n[0],r);s.length>0&&pl(t,o,s[0])}return[t]}return[null];case`has`:{if(n.length===0)return[!1];let t=i(e,n[0],r)[0];return Array.isArray(e)&&typeof t==`number`?[t>=0&&t<e.length]:e&&typeof e==`object`&&typeof t==`string`?[Object.hasOwn(e,t)]:[!1]}case`in`:{if(n.length===0)return[!1];let t=i(e,n[0],r)[0];return Array.isArray(t)&&typeof e==`number`?[e>=0&&e<t.length]:t&&typeof t==`object`&&typeof e==`string`?[Object.hasOwn(t,e)]:[!1]}case`contains`:return n.length===0?[!1]:[c(e,i(e,n[0],r)[0])];case`inside`:return n.length===0?[!1]:[c(i(e,n[0],r)[0],e)];default:return null}}var hv=T(()=>{od(),j(),xl()});function gv(e,t,n,r,i,a,o,s){switch(t){case`first`:if(n.length>0)try{let t=a(e,n[0],r);return t.length>0?[t[0]]:[]}catch(e){if(e instanceof s)throw e;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case`last`:if(n.length>0){let t=i(e,n[0],r);return t.length>0?[t[t.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case`nth`:{if(n.length<1)return[null];let t=i(e,n[0],r);if(n.length>1){for(let e of t)if(e<0)throw Error(`nth doesn't support negative indices`);let i;try{i=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;i=[]}return t.flatMap(e=>{let t=e;return t<i.length?[i[t]]:[]})}return Array.isArray(e)?t.flatMap(t=>{let n=t;if(n<0)throw Error(`nth doesn't support negative indices`);return n<e.length?[e[n]]:[null]}):[null]}case`range`:{if(n.length===0)return[];let t=r.limits.maxArrayElements,a=(e,n)=>{if(e.length>=t)throw new s(`query result element limit exceeded (${t})`,`array_elements`);e.push(n)},o=i(e,n[0],r);if(n.length===1){let e=[];for(let t of o){let n=t;for(let t=0;t<n;t++)a(e,t)}return e}let c=i(e,n[1],r);if(n.length===2){let e=[];for(let t of o)for(let n of c){let r=t,i=n;for(let t=r;t<i;t++)a(e,t)}return e}let l=i(e,n[2],r),u=[];for(let e of o)for(let t of c)for(let n of l){let r=e,i=t,o=n;if(o!==0)if(o>0)for(let e=r;e<i;e+=o)a(u,e);else for(let e=r;e>i;e+=o)a(u,e)}return u}case`limit`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let i=t;if(i<0)throw Error(`limit doesn't support negative count`);if(i===0)return[];let o;try{o=a(e,n[1],r)}catch(e){if(e instanceof s)throw e;o=[]}return o.slice(0,i)});case`isempty`:if(n.length<1)return[!0];try{return[a(e,n[0],r).length===0]}catch(e){if(e instanceof s)throw e;return[!0]}case`isvalid`:if(n.length<1)return[!0];try{return[i(e,n[0],r).length>0]}catch(e){if(e instanceof s)throw e;return[!1]}case`skip`:return n.length<2?[]:i(e,n[0],r).flatMap(t=>{let a=t;if(a<0)throw Error(`skip doesn't support negative count`);return i(e,n[1],r).slice(a)});case`until`:{if(n.length<2)return[e];let t=e,a=r.limits.maxIterations;for(let e=0;e<a;e++){if(i(t,n[0],r).some(o))return[t];let e=i(t,n[1],r);if(e.length===0)return[t];t=e[0]}throw new s(`jq until: too many iterations (${a}), increase executionLimits.maxJqIterations`,`iterations`)}case`while`:{if(n.length<2)return[e];let t=[],a=e,c=r.limits.maxIterations;for(let e=0;e<c&&i(a,n[0],r).some(o);e++){t.push(a);let e=i(a,n[1],r);if(e.length===0)break;a=e[0]}if(t.length>=c)throw new s(`jq while: too many iterations (${c}), increase executionLimits.maxJqIterations`,`iterations`);return t}case`repeat`:{if(n.length===0)return[e];let t=[],a=e,o=r.limits.maxIterations;for(let e=0;e<o;e++){t.push(a);let e=i(a,n[0],r);if(e.length===0)break;a=e[0]}if(t.length>=o)throw new s(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,`iterations`);return t}default:return null}}var _v=T(()=>{});function vv(e,t){if(!Number.isFinite(e)||Math.abs(e)>864e10)throw Error(`${t} timestamp is outside the supported range`);return new Date(e*1e3)}function yv(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(!t)return null;let[,n,r,i,a,o,s]=t.map(Number),c=Date.UTC(n,r-1,i,a,o,s);if(!Number.isFinite(c))return null;let l=new Date(c);return l.getUTCFullYear()!==n||l.getUTCMonth()!==r-1||l.getUTCDate()!==i||l.getUTCHours()!==a||l.getUTCMinutes()!==o||l.getUTCSeconds()!==s?null:l}function bv(e,t,n,r,i){switch(t){case`now`:return[Date.now()/1e3];case`gmtime`:{if(typeof e!=`number`)return[null];let t=vv(e,`gmtime`),n=t.getUTCFullYear(),r=t.getUTCMonth(),i=t.getUTCDate(),a=t.getUTCHours(),o=t.getUTCMinutes(),s=t.getUTCSeconds(),c=t.getUTCDay(),l=Date.UTC(n,0,1);return[[n,r,i,a,o,s,c,Math.floor((t.getTime()-l)/864e5)]]}case`mktime`:{if(!Array.isArray(e))throw Error(`mktime requires parsed datetime inputs`);let[t,n,r,i=0,a=0,o=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`mktime requires parsed datetime inputs`);return[Math.floor(Date.UTC(t,n,r??1,i??0,a??0,o??0)/1e3)]}case`strftime`:{if(n.length===0)return[null];let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strftime/1 requires a string format`);let a;if(typeof e==`number`)a=vv(e,`strftime`);else if(Array.isArray(e)){let[t,n,r,i=0,o=0,s=0]=e;if(typeof t!=`number`||typeof n!=`number`)throw Error(`strftime/1 requires parsed datetime inputs`);a=new Date(Date.UTC(t,n,r??1,i??0,o??0,s??0))}else throw Error(`strftime/1 requires parsed datetime inputs`);let o=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],s=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],c=(e,t=2)=>String(e).padStart(t,`0`);return[t.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,c(a.getUTCMonth()+1)).replace(/%d/g,c(a.getUTCDate())).replace(/%H/g,c(a.getUTCHours())).replace(/%M/g,c(a.getUTCMinutes())).replace(/%S/g,c(a.getUTCSeconds())).replace(/%A/g,o[a.getUTCDay()]).replace(/%B/g,s[a.getUTCMonth()]).replace(/%Z/g,`UTC`).replace(/%%/g,`%`)]}case`strptime`:{if(n.length===0)return[null];if(typeof e!=`string`)throw Error(`strptime/1 requires a string input`);let t=i(e,n[0],r)[0];if(typeof t!=`string`)throw Error(`strptime/1 requires a string format`);if(t!==xv)throw Error(`strptime format is not supported: ${t}`);let a=yv(e);if(a){let e=a.getUTCFullYear(),t=a.getUTCMonth(),n=a.getUTCDate(),r=a.getUTCHours(),i=a.getUTCMinutes(),o=a.getUTCSeconds(),s=a.getUTCDay(),c=Date.UTC(e,0,1);return[[e,t,n,r,i,o,s,Math.floor((a.getTime()-c)/864e5)]]}throw Error(`Cannot parse date: ${e}`)}case`fromdate`:{if(typeof e!=`string`)throw Error(`fromdate requires a string input`);let t=yv(e);if(!t)throw Error(`date "${e}" does not match format "${xv}"`);return[Math.floor(t.getTime()/1e3)]}case`todate`:if(typeof e!=`number`)throw Error(`todate requires a number input`);return[vv(e,`todate`).toISOString().replace(/\.\d{3}Z$/,`Z`)];default:return null}}var xv,Sv=T(()=>{xv=`%Y-%m-%dT%H:%M:%SZ`});function Cv(e){return e!==!1&&e!==null}function wv(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Tv(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`string`&&typeof t==`string`?e.localeCompare(t):0}function Ev(e,t,n={}){let r=n.maxDepth??2e3,i=vl(e),a=[{target:i,source:t,depth:0}];for(;a.length>0;){let e=a.pop();if(!e)break;if(e.depth>r)throw new A(`query depth limit exceeded (${r})`,`recursion`);for(let t of Object.keys(e.source)){if(n.visit?.(),!fl(t))continue;let r=ml(e.target,t)?gl(e.target[t]):null,i=gl(e.source[t]);if(r&&i){let n=vl(r);pl(e.target,t,n),a.push({target:n,source:i,depth:e.depth+1})}else pl(e.target,t,e.source[t])}}return i}function Dv(e,t=3e3){if(typeof e!=`object`||!e)return 0;if(t<=1)return t;let n=(e,t)=>({value:e,keys:Array.isArray(e)?void 0:Object.keys(e),nextChild:0,pathDepth:t,maxChildDepth:0}),r=e=>e.keys===void 0?e.value.length:e.keys.length,i=e=>{if(e.keys){let t=e.keys[e.nextChild++];return e.value[t]}return e.value[e.nextChild++]},a=new WeakMap,o=new WeakMap,s=e,c=[n(s,1)];for(a.set(s,`visiting`);c.length>0;){let e=c[c.length-1];if(e.nextChild<r(e)){let r=i(e);if(typeof r!=`object`||!r)continue;let s=a.get(r);if(s===`visiting`)return t;if(s===`done`){let n=o.get(r)??0;if(e.pathDepth+n>=t)return t;e.maxChildDepth=Math.max(e.maxChildDepth,n);continue}let l=e.pathDepth+1;if(l>=t)return t;let u=r;a.set(r,`visiting`),c.push(n(u,l));continue}let s=e.maxChildDepth+1;o.set(e.value,s),a.set(e.value,`done`),c.pop();let l=c.at(-1);if(l)l.maxChildDepth=Math.max(l.maxChildDepth,s);else return s}return 0}function Ov(e,t){let n=e=>e===null?0:typeof e==`boolean`?1:typeof e==`number`?2:typeof e==`string`?3:Array.isArray(e)?4:typeof e==`object`?5:6,r=n(e),i=n(t);if(r!==i)return r-i;if(typeof e==`number`&&typeof t==`number`)return e-t;if(typeof e==`string`&&typeof t==`string`)return e.localeCompare(t);if(typeof e==`boolean`&&typeof t==`boolean`)return!!e-+!!t;if(Array.isArray(e)&&Array.isArray(t)){for(let n=0;n<Math.min(e.length,t.length);n++){let r=Ov(e[n],t[n]);if(r!==0)return r}return e.length-t.length}let a=gl(e),o=gl(t);if(a&&o){let e=Object.keys(a).sort(),t=Object.keys(o).sort();for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n].localeCompare(t[n]);if(r!==0)return r}if(e.length!==t.length)return e.length-t.length;for(let t of e){let e=Ov(a[t],o[t]);if(e!==0)return e}}return 0}function kv(e,t){if(wv(e,t))return!0;if(typeof e==`string`&&typeof t==`string`)return e.includes(t);if(Array.isArray(e)&&Array.isArray(t))return t.every(t=>e.some(e=>kv(e,t)));let n=gl(e),r=gl(t);return n&&r?Object.keys(r).every(e=>ml(n,e)&&kv(n[e],r[e])):!1}var Av=T(()=>{j(),xl()});function jv(e){let t=[];for(let n=0;n<e.length;n+=32768){let r=Math.min(n+32768,e.length),i=``;for(let t=n;t<r;t++)i+=String.fromCharCode(e[t]);t.push(i)}return t.join(``)}function Mv(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function Nv(e,t,n){switch(t){case`@base64`:if(typeof e==`string`){if(typeof Buffer<`u`)return[Buffer.from(e,`utf-8`).toString(`base64`)];let t=new TextEncoder().encode(e);return[btoa(jv(t))]}return[null];case`@base64d`:if(typeof e==`string`){if(typeof Buffer<`u`)return[Buffer.from(e,`base64`).toString(`utf-8`)];let t=Mv(atob(e));return[new TextDecoder(`utf-8`,{fatal:!1}).decode(t)]}return[null];case`@uri`:return typeof e==`string`?[encodeURIComponent(e).replace(/!/g,`%21`).replace(/'/g,`%27`).replace(/\(/g,`%28`).replace(/\)/g,`%29`).replace(/\*/g,`%2A`)]:[null];case`@urid`:return typeof e==`string`?[decodeURIComponent(e)]:[null];case`@csv`:return Array.isArray(e)?[e.map(e=>{if(e===null)return``;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return String(e);let t=String(e);return t.includes(`,`)||t.includes(`"`)||t.includes(`
643
+ `)||t.includes(`\r`)?`"${t.replace(/"/g,`""`)}"`:t}).join(`,`)]:[null];case`@tsv`:return Array.isArray(e)?[e.map(e=>String(e??``).replace(/\t/g,`\\t`).replace(/\n/g,`\\n`)).join(` `)]:[null];case`@json`:{let t=n??Pv;return Dv(e,t+1)>t?[null]:[JSON.stringify(e)]}case`@html`:return typeof e==`string`?[e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/'/g,`&apos;`).replace(/"/g,`&quot;`)]:[null];case`@sh`:return typeof e==`string`?[`'${e.replace(/'/g,`'\\''`)}'`]:[null];case`@text`:return typeof e==`string`?[e]:e==null?[``]:[String(e)];default:return null}}var Pv,Fv=T(()=>{Av(),Pv=2e3});function Iv(e,t,n,r,i,a){switch(t){case`index`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){if(t===``&&e===``)return null;let n=e.indexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=0;n<=e.length-t.length;n++){let r=!0;for(let i=0;i<t.length;i++)if(!a(e[n+i],t[i])){r=!1;break}if(r)return n}return null}let n=e.findIndex(e=>a(e,t));return n>=0?n:null}return null});case`rindex`:return n.length===0?[null]:i(e,n[0],r).map(t=>{if(typeof e==`string`&&typeof t==`string`){let n=e.lastIndexOf(t);return n>=0?n:null}if(Array.isArray(e)){if(Array.isArray(t)){for(let n=e.length-t.length;n>=0;n--){let r=!0;for(let i=0;i<t.length;i++)if(!a(e[n+i],t[i])){r=!1;break}if(r)return n}return null}for(let n=e.length-1;n>=0;n--)if(a(e[n],t))return n;return null}return null});case`indices`:return n.length===0?[[]]:i(e,n[0],r).map(t=>{let n=[];if(typeof e==`string`&&typeof t==`string`){let r=e.indexOf(t);for(;r!==-1;)n.push(r),r=e.indexOf(t,r+1)}else if(Array.isArray(e))if(Array.isArray(t)){let r=t.length;if(r===0)for(let t=0;t<=e.length;t++)n.push(t);else for(let i=0;i<=e.length-r;i++){let o=!0;for(let n=0;n<r;n++)if(!a(e[i+n],t[n])){o=!1;break}o&&n.push(i)}}else for(let r=0;r<e.length;r++)a(e[r],t)&&n.push(r);return n});default:return null}}var Lv=T(()=>{});function Rv(e,t,n,r,i){switch(t){case`fabs`:case`abs`:return typeof e==`number`?[Math.abs(e)]:typeof e==`string`?[e]:[null];case`exp10`:return typeof e==`number`?[10**e]:[null];case`exp2`:return typeof e==`number`?[2**e]:[null];case`pow`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[o**s]}case`atan2`:{if(n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=t[0],s=a[0];return typeof o!=`number`||typeof s!=`number`?[null]:[Math.atan2(o,s)]}case`hypot`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.hypot(e,t)]}case`fma`:{if(typeof e!=`number`||n.length<2)return[null];let t=i(e,n[0],r)[0],a=i(e,n[1],r)[0];return[e*t+a]}case`copysign`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.sign(t)*Math.abs(e)]}case`drem`:case`remainder`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[e-Math.round(e/t)*t]}case`fdim`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(0,e-t)]}case`fmax`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.max(e,t)]}case`fmin`:{if(typeof e!=`number`||n.length===0)return[null];let t=i(e,n[0],r)[0];return[Math.min(e,t)]}case`ldexp`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`scalbn`:case`scalbln`:return typeof e!=`number`||n.length===0?[null]:[e*2**i(e,n[0],r)[0]];case`nearbyint`:return typeof e==`number`?[Math.round(e)]:[null];case`logb`:return typeof e==`number`?[Math.floor(Math.log2(Math.abs(e)))]:[null];case`significand`:return typeof e==`number`?[e/2**Math.floor(Math.log2(Math.abs(e)))]:[null];case`frexp`:if(typeof e==`number`){if(e===0)return[[0,0]];let t=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**t,t]]}return[null];case`modf`:if(typeof e==`number`){let t=Math.trunc(e);return[[e-t,t]]}return[null];default:return null}}var zv=T(()=>{});function Bv(e){let t=e.limits.maxIterations;return{maxDepth:e.limits.maxDepth,maxResults:e.limits.maxArrayElements,maxIterations:t}}function Vv(e){throw new A(e,`array_elements`)}function Hv(e,t){let n=1;for(let r of e){if(!Number.isSafeInteger(r)||r<0)throw Error(`combinations requires finite array lengths`);r!==0&&n>Math.floor(t/r)&&Vv(`query combination limit exceeded (${t})`),n*=r}return n}function Uv(e,t,n,r,i,a,o,s){switch(t){case`recurse`:{let t=[],o=Bv(r),s=n.length>=2?n[1]:null,c=[{value:e,depth:0}],l=0;for(;c.length>0;){let e=c.pop();if(!e)break;if(++l>o.maxIterations)throw new A(`query iteration limit exceeded (${o.maxIterations})`,`iterations`);if(e.depth>o.maxDepth)throw new A(`query depth limit exceeded (${o.maxDepth})`,`recursion`);if(s&&!i(e.value,s,r).some(a))continue;t.length>=o.maxResults&&Vv(`query result element limit exceeded (${o.maxResults})`),t.push(e.value);let u=[];n.length===0?Array.isArray(e.value)?u=e.value:e.value&&typeof e.value==`object`&&(u=Object.keys(e.value).map(t=>e.value[t])):u=i(e.value,n[0],r).filter(e=>e!=null),c.length>o.maxResults-u.length&&Vv(`query traversal queue limit exceeded (${o.maxResults})`);for(let t=u.length-1;t>=0;t--)c.push({value:u[t],depth:e.depth+1})}return t}case`recurse_down`:return s(e,`recurse`,n,r);case`walk`:{if(n.length===0)return[e];let t=Bv(r),a=new WeakSet,o=new WeakMap,s=[{value:e,depth:0,expanded:!1}],c=e,l=0;for(;s.length>0;){let e=s.pop();if(!e)break;if(++l>t.maxIterations)throw new A(`query iteration limit exceeded (${t.maxIterations})`,`iterations`);if(e.depth>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let u=e.value!==null&&typeof e.value==`object`?e.value:null;if(!e.expanded&&u){if(a.has(u))continue;a.add(u),s.push({...e,expanded:!0});let n=gl(e.value),r=Array.isArray(e.value)?e.value:Object.keys(n??{}).map(e=>n?.[e]);s.length>t.maxResults-r.length&&Vv(`query traversal queue limit exceeded (${t.maxResults})`);for(let t=r.length-1;t>=0;t--)s.push({value:r[t],depth:e.depth+1,expanded:!1});continue}let d=e.value;if(Array.isArray(e.value))d=e.value.map(e=>typeof e==`object`&&e?o.get(e)??e:e);else if(u){let t=Object.create(null),n=gl(e.value);for(let e of Object.keys(n??{})){if(!fl(e))continue;let r=n?.[e];pl(t,e,typeof r==`object`&&r?o.get(r)??r:r)}d=t}let f=i(d,n[0],r)[0];u&&o.set(u,f),e.depth===0&&(c=f)}return[c]}case`transpose`:{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let t=Bv(r),n=0;for(let t of e)Array.isArray(t)&&(n=Math.max(n,t.length));Hv([e.length,n],t.maxResults);let i=[];for(let t=0;t<n;t++)i.push(e.map(e=>Array.isArray(e)?e[t]:null));return[i]}case`combinations`:{if(n.length>0){let t=i(e,n[0],r)[0];if(!Array.isArray(e))return[];if(!Number.isFinite(t)||!Number.isSafeInteger(t)||t<0)throw Error(`combinations length must be a finite non-negative integer`);let a=Bv(r);if(t>a.maxDepth||t>a.maxResults)throw new A(`query depth limit exceeded (${a.maxDepth})`,`recursion`);if(t===0)return a.maxResults<1&&Vv(`query combination limit exceeded (0)`),[[]];let o=Hv(Array.from({length:t},()=>e.length),a.maxResults);if(o===0)return[];let s=[],c=Array(t).fill(0);for(let n=0;n<o;n++){s.push(c.map(t=>e[t]));for(let n=t-1;n>=0&&(c[n]++,!(c[n]<e.length));n--)c[n]=0}return s}if(!Array.isArray(e))return[];if(e.length===0)return Bv(r).maxResults<1&&Vv(`query combination limit exceeded (0)`),[[]];for(let t of e)if(!Array.isArray(t))return[];let t=Bv(r),a=e;if(a.length>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`);let o=Hv(a.map(e=>e.length),t.maxResults);if(o===0)return[];let s=[],c=Array(a.length).fill(0);for(let e=0;e<o;e++){s.push(c.map((e,t)=>a[t][e]));for(let e=a.length-1;e>=0&&(c[e]++,!(c[e]<a[e].length));e--)c[e]=0}return s}case`parent`:{if(r.root===void 0||r.currentPath===void 0)return[];let t=r.currentPath;if(t.length===0)return[];let a=n.length>0?i(e,n[0],r)[0]:1;if(a>=0){if(a>t.length)return[];let e=t.slice(0,t.length-a);return[o(r.root,e)]}{let n=-a-1;if(n>=t.length)return[e];let i=t.slice(0,n);return[o(r.root,i)]}}case`parents`:{if(r.root===void 0||r.currentPath===void 0)return[[]];let e=r.currentPath,t=[];for(let n=e.length-1;n>=0;n--)t.push(o(r.root,e.slice(0,n)));return[t]}case`root`:return r.root===void 0?[]:[r.root];default:return null}}var Wv=T(()=>{j(),xl()});function Gv(e){return e.limits.maxArrayElements}function Kv(e,t){let n=Gv(e);if(t>=n)throw new A(`query result element limit exceeded (${n})`,`array_elements`)}function qv(e,t){let n=t.limits.maxDepth??Yv;if(e.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new A(`query array index limit exceeded (${r})`,`array_elements`)}else if(typeof t!=`string`)throw Error(`stream path components must be strings or integers`)}function Jv(e,t,n,r,i){switch(t){case`keys`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e).sort()]:[null];case`keys_unsorted`:return Array.isArray(e)?[e.map((e,t)=>t)]:e&&typeof e==`object`?[Object.keys(e)]:[null];case`length`:return typeof e==`string`||Array.isArray(e)?[e.length]:e&&typeof e==`object`?[Object.keys(e).length]:e===null?[0]:typeof e==`number`?[Math.abs(e)]:[null];case`utf8bytelength`:{if(typeof e==`string`)return[O(e)];let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) only strings have UTF-8 byte length`)}case`to_entries`:{let t=gl(e);if(t){let e=Object.keys(t);if(e.length>Gv(r))throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);return[e.map(e=>{let n=Object.create(null);return pl(n,`key`,e),pl(n,`value`,t[e]),n})]}return[null]}case`from_entries`:if(Array.isArray(e)){let t=Object.create(null);for(let n of e){let e=gl(n);if(e){let n=e.key??e.Key??e.name??e.Name??e.k,r=e.value??e.Value??e.v;if(n!==void 0){let e=String(n);fl(e)&&pl(t,e,r)}}}return[t]}return[null];case`with_entries`:{if(n.length===0)return[e];let t=gl(e);if(t){let e=Object.keys(t);if(e.length>Gv(r))throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);let a=[];for(let o of e){let e=Object.create(null);pl(e,`key`,o),pl(e,`value`,t[o]);let s=i(e,n[0],r);if(a.length>Gv(r)-s.length)throw new A(`query result element limit exceeded (${Gv(r)})`,`array_elements`);for(let e of s)a.push(e)}let o=Object.create(null);for(let e of a){let t=gl(e);if(t){let e=t.key??t.name??t.k,n=t.value??t.v;if(e!==void 0){let t=String(e);fl(t)&&pl(o,t,n)}}}return[o]}return[null]}case`reverse`:return Array.isArray(e)?[[...e].reverse()]:typeof e==`string`?[e.split(``).reverse().join(``)]:[null];case`flatten`:return Array.isArray(e)?(n.length>0?i(e,n[0],r):[1/0]).map(t=>{let n=t;if(n<0)throw Error(`flatten depth must not be negative`);return e.flat(n)}):[null];case`unique`:if(Array.isArray(e)){let t=new Set,n=[];for(let r of e){let e=JSON.stringify(r);t.has(e)||(t.add(e),n.push(r))}return[n]}return[null];case`tojson`:case`tojsonstream`:{let t=r.limits.maxDepth??Yv;return Dv(e,t+1)>t?[null]:[JSON.stringify(e)]}case`fromjson`:if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`nan`)return[NaN];if(t===`inf`||t===`infinity`)return[1/0];if(t===`-inf`||t===`-infinity`)return[-1/0];try{return[hl(JSON.parse(e),{maxDepth:r.limits.maxDepth,maxElements:r.limits.maxArrayElements})]}catch(t){throw t instanceof A?t:Error(`Invalid JSON: ${e}`)}}return[e];case`tostring`:return typeof e==`string`?[e]:[JSON.stringify(e)];case`tonumber`:if(typeof e==`number`)return[e];if(typeof e==`string`){let t=Number(e);if(Number.isNaN(t))throw Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[t]}throw Error(`${typeof e} cannot be parsed as a number`);case`toboolean`:{if(typeof e==`boolean`)return[e];if(typeof e==`string`){if(e===`true`)return[!0];if(e===`false`)return[!1];throw Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let t=e===null?`null`:Array.isArray(e)?`array`:typeof e,n=t===`array`||t===`object`?JSON.stringify(e):String(e);throw Error(`${t} (${n}) cannot be parsed as a boolean`)}case`tostream`:{let t=[],n=r.limits.maxDepth??Yv,i=[{value:e,path:[]}],a=new WeakSet,o=0;for(;i.length>0;){let e=i.pop();if(!e)break;if(++o>r.limits.maxIterations)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);if(e.path.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let s=e.value;if(typeof s!=`object`||!s)Kv(r,t.length),t.push([e.path,s]);else if(Array.isArray(s)){if(a.has(s))throw new A(`cyclic value cannot be converted to a stream`,`recursion`);if(a.add(s),s.length===0)Kv(r,t.length),t.push([e.path,[]]);else{if(i.length>Gv(r)-s.length)throw new A(`query traversal queue limit exceeded (${Gv(r)})`,`array_elements`);for(let t=s.length-1;t>=0;t--)i.push({value:s[t],path:[...e.path,t]})}}else{if(a.has(s))throw new A(`cyclic value cannot be converted to a stream`,`recursion`);a.add(s);let n=Object.keys(s);if(n.length===0)Kv(r,t.length),t.push([e.path,Object.create(null)]);else{if(i.length>Gv(r)-n.length)throw new A(`query traversal queue limit exceeded (${Gv(r)})`,`array_elements`);for(let t=n.length-1;t>=0;t--){let r=n[t];i.push({value:s[r],path:[...e.path,r]})}}}}return Kv(r,t.length),t.push([[]]),t}case`fromstream`:{if(n.length===0)return[e];let t=i(e,n[0],r);if(t.length>Gv(r))throw new A(`query stream item limit exceeded (${Gv(r)})`,`array_elements`);let a=null,o=0;for(let e of t){if(!Array.isArray(e)||e.length===1&&Array.isArray(e[0])&&e[0].length===0||e.length!==2)continue;let[t,n]=e;if(!Array.isArray(t))continue;if(qv(t,r),t.length===0){a=n;continue}a===null&&(a=typeof t[0]==`number`?[]:Object.create(null));let i=a;for(let e=0;e<t.length-1;e++){let n=t[e],a=t[e+1];if(Array.isArray(i)&&typeof n==`number`){let e=n+1-i.length;if(e>r.limits.maxIterations-o)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=n;)i.push(null);i[n]===null&&(i[n]=typeof a==`number`?[]:Object.create(null)),i=i[n]}else{let e=gl(i);if(e){let t=String(n);if(!fl(t))continue;(e[t]===null||e[t]===void 0)&&pl(e,t,typeof a==`number`?[]:Object.create(null)),i=e[t]}}}let s=t[t.length-1];if(Array.isArray(i)&&typeof s==`number`){let e=s+1-i.length;if(e>r.limits.maxIterations-o)throw new A(`query iteration limit exceeded (${r.limits.maxIterations})`,`iterations`);for(o+=Math.max(0,e);i.length<=s;)i.push(null);i[s]=n}else{let e=gl(i);if(e){let t=String(s);fl(t)&&pl(e,t,n)}}}return[a]}case`truncate_stream`:{let t=typeof e==`number`?Math.floor(e):0;if(n.length===0)return[];let a=[],o=i(e,n[0],r);for(let e of o)if(Array.isArray(e)){if(e.length===1&&Array.isArray(e[0])){let n=e[0];n.length>t&&a.push([n.slice(t)]);continue}if(e.length===2&&Array.isArray(e[0])){let n=e[0],r=e[1];n.length>t&&a.push([n.slice(t),r])}}return a}default:return null}}var Yv,Xv=T(()=>{k(),j(),xl(),Av(),Yv=2e3});function Zv(e,t){if(!Array.isArray(e))throw Error(`path must be an array`);let n=t.limits.maxDepth;if(e.length>n)throw new A(`query depth limit exceeded (${n})`,`recursion`);let r=t.limits.maxArrayElements,i=0;for(let t of e)if(typeof t==`number`){if(!Number.isSafeInteger(t)||t<0||t>=r)throw new A(`query array index limit exceeded (${r})`,`array_elements`);let e=t+1;if(i>r-e)throw new A(`query cumulative array allocation limit exceeded (${r})`,`array_elements`);i+=e}else if(typeof t!=`string`)throw Error(`path components must be strings or integers`);return gy(t,i+e.length),e}function Qv(e,t,n){let r=[],i=[{value:e,path:[],isRoot:!0}];for(;i.length>0;){let e=i.pop();if(!e)break;if(gy(t),e.path.length>t.limits.maxDepth)throw new A(`query depth limit exceeded (${t.limits.maxDepth})`,`recursion`);if(e.value===null||typeof e.value!=`object`){(n||!e.isRoot)&&(_y(t,r.length),r.push(e.path));continue}!n&&!e.isRoot&&(_y(t,r.length),r.push(e.path));let a=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);_y(t,r.length,i.length+a.length);for(let t=a.length-1;t>=0;t--){let[n,r]=a[t],o=[...e.path,n];i.push({value:r,path:o,isRoot:!1})}}return r}function $v(e,t,n,r,i,a,o,s,c,l){switch(t){case`getpath`:{if(n.length===0)return[null];let t=i(e,n[0],r),a=[];for(let n of t){let t=n,r=e;for(let e of t){if(r==null){r=null;break}if(Array.isArray(r)&&typeof e==`number`)r=r[e];else if(typeof e==`string`){let t=gl(r);if(!t||!Object.hasOwn(t,e)){r=null;break}r=t[e]}else{r=null;break}}a.push(r)}return a}case`setpath`:{if(n.length<2)return[null];let t=Zv(i(e,n[0],r)[0],r),a=i(e,n[1],r)[0];return[o(e,t,a)]}case`delpaths`:{if(n.length===0)return[e];let t=i(e,n[0],r)[0],a=e;for(let e of t.sort((e,t)=>t.length-e.length))a=s(a,e);return[a]}case`path`:{if(n.length===0)return[[]];let t=[];return l(e,n[0],r,[],t),t}case`del`:return n.length===0?[e]:[c(e,n[0],r)];case`pick`:{if(n.length===0)return[null];let t=[];for(let i of n)l(e,i,r,[],t);let i=null;for(let n of t){for(let e of n)if(typeof e==`number`&&e<0)throw Error(`Out of bounds negative array index`);Zv(n,r);let t=e;for(let e of n){if(t==null)break;if(Array.isArray(t)&&typeof e==`number`)t=t[e];else if(typeof e==`string`){let n=gl(t);if(!n||!Object.hasOwn(n,e)){t=null;break}t=n[e]}else{t=null;break}}i=o(i,n,t)}return[i]}case`paths`:{let t=Qv(e,r,!1);return n.length>0?t.filter(t=>{let o=e;for(let e of t)if(Array.isArray(o)&&typeof e==`number`)o=o[e];else if(typeof e==`string`){let t=gl(o);if(!t||!Object.hasOwn(t,e))return!1;o=t[e]}else return!1;return i(o,n[0],r).some(a)}):t}case`leaf_paths`:return Qv(e,r,!0);default:return null}}var ey=T(()=>{j(),By(),xl()});function ty(e,t,n,r,i,a){switch(t){case`IN`:{if(n.length===0)return[!1];if(n.length===1){let t=i(e,n[0],r);for(let n of t)if(a(e,n))return[!0];return[!1]}let t=i(e,n[0],r),o=i(e,n[1],r),s=new Set(o.map(e=>JSON.stringify(e)));for(let e of t)if(s.has(JSON.stringify(e)))return[!0];return[!1]}case`INDEX`:{if(n.length===0)return[Object.create(null)];if(n.length===1){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=String(e);fl(t)&&pl(a,t,e)}return[a]}if(n.length===2){let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r);if(t.length>0){let n=String(t[0]);fl(n)&&pl(a,n,e)}}return[a]}let t=i(e,n[0],r),a=Object.create(null);for(let e of t){let t=i(e,n[1],r),o=i(e,n[2],r);if(t.length>0&&o.length>0){let e=String(t[0]);fl(e)&&pl(a,e,o[0])}}return[a]}case`JOIN`:{if(n.length<2)return[null];let t=gl(i(e,n[0],r)[0]);if(!t||!Array.isArray(e))return[null];let a=[];for(let o of e){let e=i(o,n[1],r),s=e.length>0?String(e[0]):``,c=ml(t,s)?t[s]:null;a.push([o,c])}return[a]}default:return null}}var ny=T(()=>{xl()});function ry(e){return e.limits.maxArrayElements}function iy(e){return Math.min(e.limits.maxStringLength,e.limits.maxOutputSize)}function ay(e,t){let n=ry(e);if(!Number.isSafeInteger(t)||t<0||t>n)throw new A(`query result element limit exceeded (${n})`,`array_elements`)}function oy(e,t,n){if(e===``)return t===``?0:1;if(t===``)return e.length;let r=1,i=0;for(;;){let a=e.indexOf(t,i);if(a<0||(r++,r>n))return r;i=a+t.length}}function sy(e,t,n,r,i){switch(t){case`join`:{if(!Array.isArray(e))return[null];let t=n.length>0?i(e,n[0],r):[``];for(let t of e)if(Array.isArray(t)||typeof t==`object`&&t)throw Error(`cannot join: contains arrays or objects`);return ay(r,t.length),t.map(t=>{let n=String(t),i=0;for(let t=0;t<e.length;t++){let a=e[t]===null?``:typeof e[t]==`string`?e[t]:String(e[t]);if(i+=O(a),t>0&&(i+=O(n)),i>iy(r))throw new A(`query string size limit exceeded (${iy(r)} bytes)`,`string_length`)}return e.map(e=>e===null?``:typeof e==`string`?e:String(e)).join(n)})}case`split`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);return ay(r,oy(e,a,ry(r))),[e.split(a)]}case`splits`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):`g`,o=U(a,t.includes(`g`)?t:`${t}g`),s=1;for(let t of o.matchAll(e))s+=Math.max(1,t.length),ay(r,s);let c=o.split(e);return ay(r,c.length),c}catch(e){if(e instanceof A)throw e;return[]}}case`scan`:{if(typeof e!=`string`||n.length===0)return[];let t=i(e,n[0],r),a=String(t[0]);try{let t=n.length>1?String(i(e,n[1],r)[0]):``,o=U(a,t.includes(`g`)?t:`${t}g`),s=[];for(let t of o.matchAll(e))ay(r,s.length+1),t.length>1?(ay(r,t.length-1),s.push(t.slice(1))):s.push(t[0]);return s}catch(e){if(e instanceof A)throw e;return[]}}case`test`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r),a=String(t[0]);try{return[U(a,n.length>1?String(i(e,n[1],r)[0]):``).test(e)]}catch{return[!1]}}case`match`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=U(a,`${n.length>1?String(i(e,n[1],r)[0]):``}d`).exec(e);if(!t)return[];let o=t.indices;return[{offset:t.index,length:t[0].length,string:t[0],captures:t.slice(1).map((e,t)=>({offset:o?.[t+1]?.[0]??null,length:e?.length??0,string:e??``,name:null}))}]}catch{return[null]}}case`capture`:{if(typeof e!=`string`||n.length===0)return[null];let t=i(e,n[0],r),a=String(t[0]);try{let t=U(a,n.length>1?String(i(e,n[1],r)[0]):``).match(e);return!t||!t.groups?[Object.create(null)]:[t.groups]}catch{return[null]}}case`sub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{return[U(o,n.length>2?String(i(e,n[2],r)[0]):``).replace(e,s)]}catch{return[e]}}case`gsub`:{if(typeof e!=`string`||n.length<2)return[null];let t=i(e,n[0],r),a=i(e,n[1],r),o=String(t[0]),s=String(a[0]);try{let t=n.length>2?String(i(e,n[2],r)[0]):`g`;return[U(o,t.includes(`g`)?t:`${t}g`).replace(e,s)]}catch{return[e]}}case`ascii_downcase`:return typeof e==`string`?[e.replace(/[A-Z]/g,e=>String.fromCharCode(e.charCodeAt(0)+32))]:[null];case`ascii_upcase`:return typeof e==`string`?[e.replace(/[a-z]/g,e=>String.fromCharCode(e.charCodeAt(0)-32))]:[null];case`ltrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return[e.startsWith(a)?e.slice(a.length):e]}case`rtrimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);return a===``?[e]:[e.endsWith(a)?e.slice(0,-a.length):e]}case`trimstr`:{if(typeof e!=`string`||n.length===0)return[e];let t=i(e,n[0],r),a=String(t[0]);if(a===``)return[e];let o=e;return o.startsWith(a)&&(o=o.slice(a.length)),o.endsWith(a)&&(o=o.slice(0,-a.length)),[o]}case`trim`:if(typeof e==`string`)return[e.trim()];throw Error(`trim input must be a string`);case`ltrim`:if(typeof e==`string`)return[e.trimStart()];throw Error(`trim input must be a string`);case`rtrim`:if(typeof e==`string`)return[e.trimEnd()];throw Error(`trim input must be a string`);case`startswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.startsWith(String(t[0]))]}case`endswith`:{if(typeof e!=`string`||n.length===0)return[!1];let t=i(e,n[0],r);return[e.endsWith(String(t[0]))]}case`ascii`:return typeof e==`string`&&e.length>0?[e.charCodeAt(0)]:[null];case`explode`:if(typeof e==`string`){let t=0;for(let n of e)t++,ay(r,t);return[Array.from(e).map(e=>e.codePointAt(0))]}return[null];case`implode`:if(!Array.isArray(e))throw Error(`implode input must be an array`);return[e.map(e=>{if(typeof e==`string`)throw Error(`string (${JSON.stringify(e)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof e!=`number`||Number.isNaN(e))throw Error(`number (null) can't be imploded, unicode codepoint needs to be numeric`);let t=Math.trunc(e);return t<0||t>1114111||t>=55296&&t<=57343?String.fromCodePoint(65533):String.fromCodePoint(t)}).join(``)];default:return null}}var cy=T(()=>{j(),mc(),Lr()});function ly(e,t){switch(t){case`type`:return e===null?[`null`]:Array.isArray(e)?[`array`]:typeof e==`boolean`?[`boolean`]:typeof e==`number`?[`number`]:typeof e==`string`?[`string`]:typeof e==`object`?[`object`]:[`null`];case`infinite`:return[1/0];case`nan`:return[NaN];case`isinfinite`:return[typeof e==`number`&&!Number.isFinite(e)];case`isnan`:return[typeof e==`number`&&Number.isNaN(e)];case`isnormal`:return[typeof e==`number`&&Number.isFinite(e)&&e!==0];case`isfinite`:return[typeof e==`number`&&Number.isFinite(e)];case`numbers`:return typeof e==`number`?[e]:[];case`strings`:return typeof e==`string`?[e]:[];case`booleans`:return typeof e==`boolean`?[e]:[];case`nulls`:return e===null?[e]:[];case`arrays`:return Array.isArray(e)?[e]:[];case`objects`:return e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`iterables`:return Array.isArray(e)||e&&typeof e==`object`&&!Array.isArray(e)?[e]:[];case`scalars`:return!Array.isArray(e)&&!(e&&typeof e==`object`)?[e]:[];case`values`:return e===null?[]:[e];case`not`:return e===!1||e===null?[!0]:[!1];case`null`:return[null];case`true`:return[!0];case`false`:return[!1];case`empty`:return[];default:return null}}var uy=T(()=>{}),dy=T(()=>{hv(),_v(),Sv(),Fv(),Lv(),zv(),Wv(),Xv(),ey(),ny(),cy(),uy()});function fy(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(typeof r==`number`){if(e&&typeof e==`object`&&!Array.isArray(e))throw Error(`Cannot index object with number`);if(r>536870911)throw Error(`Array index too large`);if(r<0)throw Error(`Out of bounds negative array index`);let t=Array.isArray(e)?[...e]:[];for(;t.length<=r;)t.push(null);return t[r]=fy(t[r],i,n),t}if(Array.isArray(e))throw Error(`Cannot index array with string`);if(!fl(r))return e??Object.create(null);let a=gl(e),o=a?vl(a):Object.create(null);return pl(o,r,fy(Object.hasOwn(o,r)?o[r]:void 0,i,n)),o}function py(e,t){if(t.length===0)return null;if(t.length===1){let n=t[0];if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t.splice(n,1),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!fl(t))return e;let r=vl(e);return delete r[t],r}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n==`number`){let t=[...e];return t[n]=py(t[n],r),t}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=String(n);if(!fl(t))return e;let i=vl(e);return Object.hasOwn(i,t)&&pl(i,t,py(i[t],r)),i}return e}var my=T(()=>{xl()});function hy(e,t){return new A(e,t)}function gy(e,t=1){if(!Number.isSafeInteger(t)||t<0||e.budget.operations>e.limits.maxIterations-t)throw hy(`query evaluation: too many iterations (${e.limits.maxIterations})`,`iterations`);e.budget.operations+=t}function _y(e,t,n=1){let r=e.limits.maxArrayElements;if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<0||n<0||t>r-n)throw hy(`query result element limit exceeded (${r})`,`array_elements`)}function vy(e,t,n){_y(e,t.length,n.length);for(let e of n)t.push(e)}function yy(e,t,n){let r=[];for(let i of t)gy(e),vy(e,r,n(i));return r}function by(e){let t=new Map;if(e?.namedArgs)for(let[n,r]of e.namedArgs)t.set(`$${n}`,r);return{vars:t,limits:{maxIterations:e?.limits?.maxIterations??Iy,maxDepth:e?.limits?.maxDepth??Ry,maxStringLength:e?.limits?.maxStringLength??Ly,maxOutputSize:e?.limits?.maxOutputSize??Ly,maxArrayElements:e?.limits?.maxArrayElements??1e5},env:e?.env,namedArgs:e?.namedArgs,positionalArgs:e?.positionalArgs,coverage:e?.coverage,requireDefenseContext:e?.requireDefenseContext,defenseContextChecked:!1,budget:e?.budget??{operations:0,callDepth:0}}}function xy(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,namedArgs:e.namedArgs,positionalArgs:e.positionalArgs,requireDefenseContext:e.requireDefenseContext,defenseContextChecked:e.defenseContextChecked,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels,coverage:e.coverage,budget:e.budget}}function Sy(e,t,n){switch(t.type){case`var`:return xy(e,t.name,n);case`array`:{if(!Array.isArray(n))return null;let r=e;for(let e=0;e<t.elements.length;e++){let i=t.elements[e],a=e<n.length?n[e]:null,o=Sy(r,i,a);if(o===null)return null;r=o}return r}case`object`:{let r=gl(n);if(!r)return null;let i=e;for(let a of t.fields){let t;if(typeof a.key==`string`)t=a.key;else{let r=J(n,a.key,e);if(r.length===0)return null;t=String(r[0])}let o=ml(r,t)?r[t]:null;a.keyVar&&(i=xy(i,a.keyVar,o));let s=Sy(i,a.pattern,o);if(s===null)return null;i=s}return i}}}function Cy(e,t){let n=e;for(let e of t)if(n&&typeof n==`object`)if(Array.isArray(n))if(typeof e==`number`)n=n[e];else return;else{let t=gl(n);if(t&&typeof e==`string`&&Object.hasOwn(t,e))n=t[e];else return}else return;return n}function wy(e){if(e.type===`Identity`)return[];if(e.type===`Field`){let t=e.base?wy(e.base):[];return t===null?null:[...t,e.name]}if(e.type===`Index`&&e.index.type===`Literal`){let t=e.base?wy(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n==`number`||typeof n==`string`?[...t,n]:null}if(e.type===`Pipe`){let t=wy(e.left);return t===null?null:Ty(t,e.right)}if(e.type===`Call`){if(e.name===`parent`||e.name===`root`)return null;if(e.name===`first`&&e.args.length===0)return[0];if(e.name===`last`&&e.args.length===0)return[-1]}return null}function Ty(e,t){if(t.type===`Call`){if(t.name===`parent`){let n=1;if(t.args.length>0&&t.args[0].type===`Literal`){let e=t.args[0].value;typeof e==`number`&&(n=e)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let t=-n-1;return e.slice(0,Math.min(t,e.length))}}if(t.name===`root`)return[]}if(t.type===`Field`){let n=wy(t);if(n!==null)return[...e,...n]}if(t.type===`Index`&&t.index.type===`Literal`){let n=wy(t);if(n!==null)return[...e,...n]}if(t.type===`Pipe`){let n=Ty(e,t.left);return n===null?null:Ty(n,t.right)}return t.type===`Identity`?e:null}function Ey(e,t,n){if(t.type===`Comma`){let r=[];try{vy(n,r,J(e,t.left,n))}catch(e){if(e instanceof A)throw e;if(r.length>0)return r;throw Error(`evaluation failed`)}try{vy(n,r,J(e,t.right,n))}catch(e){if(e instanceof A)throw e;return r}return r}return J(e,t,n)}function J(e,t,n){let r=n&&`vars`in n?n:by(n);if(r.defenseContextChecked||(bu(r.requireDefenseContext,`query-engine`,`evaluation`),r={...r,defenseContextChecked:!0}),r.root===void 0&&(r={...r,root:e,currentPath:[]}),gy(r),r.budget.callDepth++,r.budget.callDepth>r.limits.maxDepth)throw r.budget.callDepth--,hy(`query depth limit exceeded (${r.limits.maxDepth})`,`recursion`);try{let n=Dy(e,t,r);return _y(r,0,n.length),n}finally{r.budget.callDepth--}}function Dy(e,t,n){switch(n.coverage?.hit(`jq:node:${t.type}`),t.type){case`Identity`:return[e];case`Field`:return yy(n,t.base?J(e,t.base,n):[e],e=>{let n=gl(e);if(n){if(!Object.hasOwn(n,t.name))return[null];let e=n[t.name];return[e===void 0?null:e]}if(e===null)return[null];throw Error(`Cannot index ${Array.isArray(e)?`array`:typeof e} with string "${t.name}"`)});case`Index`:return yy(n,t.base?J(e,t.base,n):[e],e=>yy(n,J(e,t.index,n),t=>{if(typeof t==`number`&&Array.isArray(e)){if(Number.isNaN(t))return[null];let n=Math.trunc(t),r=n<0?e.length+n:n;return r>=0&&r<e.length?[e[r]]:[null]}if(typeof t==`string`){let n=gl(e);return!n||!Object.hasOwn(n,t)?[null]:[n[t]]}return[null]}));case`Slice`:return yy(n,t.base?J(e,t.base,n):[e],r=>{if(r===null)return[null];if(!Array.isArray(r)&&typeof r!=`string`)throw Error(`Cannot slice ${typeof r} (${JSON.stringify(r)})`);let i=r.length,a=t.start?J(e,t.start,n):[0],o=t.end?J(e,t.end,n):[i];return _y(n,0,a.length*o.length),yy(n,a,e=>o.map(t=>{let n=e,a=t,o=Number.isNaN(n)?0:Number.isInteger(n)?n:Math.floor(n),s=Number.isNaN(a)?i:Number.isInteger(a)?a:Math.ceil(a),c=Oy(o,i),l=Oy(s,i);return r.slice(c,l)}))});case`Iterate`:return yy(n,t.base?J(e,t.base,n):[e],e=>Array.isArray(e)?e:e&&typeof e==`object`?Object.values(e):[]);case`Pipe`:{let r=J(e,t.left,n),i=wy(t.left),a=[];for(let e of r)try{if(i!==null){let r={...n,currentPath:[...n.currentPath??[],...i]};vy(n,a,J(e,t.right,r))}else vy(n,a,J(e,t.right,n))}catch(e){throw e instanceof Py?e.withPrependedResults(a):e}return a}case`Comma`:{let r=J(e,t.left,n),i=J(e,t.right,n);return _y(n,r.length,i.length),[...r,...i]}case`Literal`:return[t.value];case`Array`:return t.elements?[J(e,t.elements,n)]:[[]];case`Object`:{let r=[Object.create(null)];for(let i of t.entries){let t=typeof i.key==`string`?[i.key]:J(e,i.key,n),a=J(e,i.value,n),o=[],s=t.filter(e=>typeof e==`string`&&fl(e)).length,c=s+(t.length-s);_y(n,0,r.length*c*a.length);for(let e of r)for(let n of t){if(typeof n!=`string`)throw Error(`Cannot use ${n===null?`null`:Array.isArray(n)?`array`:typeof n} (${JSON.stringify(n)}) as object key`);if(!fl(n)){for(let t of a)o.push(vl(e));continue}for(let t of a){let r=vl(e);pl(r,n,t),o.push(r)}}r.length=0,vy(n,r,o)}return r}case`Paren`:return J(e,t.expr,n);case`BinaryOp`:return jy(e,t.op,t.left,t.right,n);case`UnaryOp`:return J(e,t.operand,n).map(e=>{if(t.op===`-`){if(typeof e==`number`)return-e;if(typeof e==`string`)throw Error(`string (${(e=>e.length>5?`"${e.slice(0,3)}...`:JSON.stringify(e))(e)}) cannot be negated`);return null}return t.op===`not`?!Cv(e):null});case`Cond`:return yy(n,J(e,t.cond,n),r=>{if(Cv(r))return J(e,t.then,n);for(let r of t.elifs)if(J(e,r.cond,n).some(Cv))return J(e,r.then,n);return t.else?J(e,t.else,n):[e]});case`Try`:try{return J(e,t.body,n)}catch(e){if(e instanceof A)throw e;return t.catch?J(e instanceof Fy?e.value:e instanceof Error?e.message:String(e),t.catch,n):[]}case`Call`:return My(e,t.name,t.args,n);case`VarBind`:return yy(n,J(e,t.value,n),r=>{let i=null,a=[];if(t.pattern?a.push(t.pattern):t.name&&a.push({type:`var`,name:t.name}),t.alternatives)for(let e of t.alternatives)a.push(e);for(let e of a)if(i=Sy(n,e,r),i!==null)break;return i===null?[]:J(e,t.body,i)});case`VarRef`:{if(t.name===`$ENV`)return[n.env?rd(n.env):Object.create(null)];if(t.name===`$ARGS`){let e=Object.create(null);if(n.namedArgs)for(let[t,r]of n.namedArgs)Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0});let t=Object.create(null);return t.positional=n.positionalArgs?[...n.positionalArgs]:[],t.named=e,[t]}let e=n.vars.get(t.name);return e===void 0?[null]:[e]}case`Recurse`:{let t=[],r=new WeakSet,i=[{val:e,depth:0}];for(;i.length>0;){let e=i.pop();if(!e)break;let{val:a,depth:o}=e;if(gy(n),o>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);if(a&&typeof a==`object`){if(r.has(a))continue;r.add(a)}if(_y(n,t.length),t.push(a),Array.isArray(a))for(let e=a.length-1;e>=0;e--)i.push({val:a[e],depth:o+1});else if(a&&typeof a==`object`){let e=Object.keys(a);for(let t=e.length-1;t>=0;t--)i.push({val:a[e[t]],depth:o+1})}}return t}case`Optional`:try{return J(e,t.expr,n)}catch(e){if(e instanceof A)throw e;return[]}case`StringInterp`:{let r=new Ui(n.limits.maxStringLength,`query string interpolation`,()=>new A(`string size limit exceeded (${n.limits.maxStringLength} bytes)`,`string_length`));for(let i of t.parts){if(typeof i==`string`){r.append(i);continue}let t=J(e,i,n);for(let e of t){if(gy(n),Dv(e,n.limits.maxDepth+1)>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);r.append(typeof e==`string`?e:JSON.stringify(e))}}return[r.build()]}case`UpdateOp`:return[ky(e,t.path,t.op,t.value,n)];case`Reduce`:{let r=J(e,t.expr,n),i=J(e,t.init,n)[0],a=n.limits.maxDepth??Ry;for(let e of r){let r;if(t.pattern){if(r=Sy(n,t.pattern,e),r===null)continue}else r=xy(n,t.varName,e);if(i=J(i,t.update,r)[0],Dv(i,a+1)>a)return[null]}return[i]}case`Foreach`:{let r=J(e,t.expr,n),i=J(e,t.init,n)[0],a=[];for(let e of r)try{let r;if(t.pattern){if(r=Sy(n,t.pattern,e),r===null)continue}else r=xy(n,t.varName,e);i=J(i,t.update,r)[0],t.extract?vy(n,a,J(i,t.extract,r)):(_y(n,a.length),a.push(i))}catch(e){throw e instanceof Py?e.withPrependedResults(a):e}return a}case`Label`:try{return J(e,t.body,{...n,labels:new Set([...n.labels??[],t.name])})}catch(e){if(e instanceof Py&&e.label===t.name)return e.partialResults;throw e}case`Break`:throw new Py(t.name);case`Def`:{let r=new Map(n.funcs??[]),i=`${t.name}/${t.params.length}`;r.set(i,{params:t.params,body:t.funcBody,closure:new Map(n.funcs??[])});let a={...n,funcs:r};return J(e,t.body,a)}default:throw Error(`Unknown AST node type: ${t.type}`)}}function Oy(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function ky(e,t,n,r,i){function a(e,t){switch(n){case`=`:return t;case`|=`:return J(e,r,i)[0]??null;case`+=`:return typeof e==`number`&&typeof t==`number`||typeof e==`string`&&typeof t==`string`?e+t:Array.isArray(e)&&Array.isArray(t)?(_y(i,e.length,t.length),[...e,...t]):e&&t&&typeof e==`object`&&typeof t==`object`?yl(e,t):t;case`-=`:return typeof e==`number`&&typeof t==`number`?e-t:e;case`*=`:return typeof e==`number`&&typeof t==`number`?e*t:e;case`/=`:return typeof e==`number`&&typeof t==`number`?e/t:e;case`%=`:return typeof e==`number`&&typeof t==`number`?e%t:e;case`//=`:return e===null||e===!1?t:e;default:return t}}function o(t,n,r){switch(n.type){case`Identity`:return r(t);case`Field`:if(!fl(n.name))return t;if(n.base)return o(t,n.base,e=>{if(e&&typeof e==`object`&&!Array.isArray(e)){let t=vl(e),i=Object.hasOwn(t,n.name)?t[n.name]:void 0;return pl(t,n.name,r(i)),t}return e});if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t),i=Object.hasOwn(e,n.name)?e[n.name]:void 0;return pl(e,n.name,r(i)),e}return t;case`Index`:{let a=J(e,n.index,i)[0];if(typeof a==`number`&&Number.isNaN(a))throw Error(`Cannot set array element at NaN index`);if(typeof a==`number`&&!Number.isFinite(a))throw Error(`array index must be finite`);if(typeof a==`number`&&!Number.isInteger(a)&&(a=Math.trunc(a)),n.base)return o(t,n.base,e=>{if(typeof a==`number`&&Array.isArray(e)){let t=[...e],n=a<0?t.length+a:a;if(n>=0){_y(i,0,n+1),t.length<=n&&(t.length=n+1);for(let r=e.length;r<n;r++)t[r]=null;t[n]=r(t[n])}return t}if(typeof a==`string`&&e&&typeof e==`object`&&!Array.isArray(e)){if(!fl(a))return e;let t=vl(e),n=Object.hasOwn(t,a)?t[a]:void 0;return pl(t,a,r(n)),t}return e});if(typeof a==`number`){if(!Number.isSafeInteger(a)||a>536870911)throw Error(`Array index too large`);if(a<0&&(!t||!Array.isArray(t)))throw Error(`Out of bounds negative array index`);if(Array.isArray(t)){let e=[...t],n=a<0?e.length+a:a;if(n>=0){_y(i,0,n+1),e.length<=n&&(e.length=n+1);for(let r=t.length;r<n;r++)e[r]=null;e[n]=r(e[n])}return e}if(t==null){_y(i,0,a+1);let e=Array(a+1).fill(null);return e[a]=r(null),e}return t}if(typeof a==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(a))return t;let e=vl(t),n=Object.hasOwn(e,a)?e[a]:void 0;return pl(e,a,r(n)),e}return t}case`Iterate`:{let e=e=>{if(Array.isArray(e)){_y(i,0,e.length);let t=[];for(let n of e)gy(i),t.push(r(n));return t}if(e&&typeof e==`object`){let t=Object.create(null);for(let[n,i]of Object.entries(e))fl(n)&&pl(t,n,r(i));return t}return e};return n.base?o(t,n.base,e):e(t)}case`Pipe`:return o(o(t,n.left,e=>e),n.right,r);default:return r(t)}}return o(e,t,t=>n===`|=`?a(t,t):a(t,J(e,r,i)[0]??null))}function Ay(e,t,n){function r(t,i,a){switch(i.type){case`Identity`:return a;case`Field`:if(!fl(i.name))return t;if(i.base){let e=J(t,i.base,n)[0],o=r(e,{type:`Field`,name:i.name},a);return r(t,i.base,o)}if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t);return pl(e,i.name,a),e}return t;case`Index`:{if(i.base){let e=J(t,i.base,n)[0],o=r(e,{type:`Index`,index:i.index},a);return r(t,i.base,o)}let o=J(e,i.index,n)[0];if(typeof o==`number`&&Array.isArray(t)){let e=[...t],n=o<0?e.length+o:o;return n>=0&&n<e.length&&(e[n]=a),e}if(typeof o==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(o))return t;let e=vl(t);return pl(e,o,a),e}return t}default:return t}}function i(t,a){switch(a.type){case`Identity`:return null;case`Field`:if(!fl(a.name))return t;if(a.base){let e=J(t,a.base,n)[0];if(e==null)return t;let o=i(e,{type:`Field`,name:a.name});return r(t,a.base,o)}if(t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(a.name))return t;let e=vl(t);return delete e[a.name],e}return t;case`Index`:{if(a.base){let e=J(t,a.base,n)[0];if(e==null)return t;let o=i(e,{type:`Index`,index:a.index});return r(t,a.base,o)}let o=J(e,a.index,n)[0];if(typeof o==`number`&&Array.isArray(t)){let e=[...t],n=o<0?e.length+o:o;return n>=0&&n<e.length&&e.splice(n,1),e}if(typeof o==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(o))return t;let e=vl(t);return delete e[o],e}return t}case`Iterate`:return Array.isArray(t)?[]:t&&typeof t==`object`?Object.create(null):t;case`Pipe`:{let r=function(t,i,a){switch(i.type){case`Identity`:return a;case`Field`:if(!fl(i.name))return t;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=vl(t);return pl(e,i.name,a),e}return t;case`Index`:{let r=J(e,i.index,n)[0];if(typeof r==`number`&&Array.isArray(t)){let e=[...t],n=r<0?e.length+r:r;return n>=0&&n<e.length&&(e[n]=a),e}if(typeof r==`string`&&t&&typeof t==`object`&&!Array.isArray(t)){if(!fl(r))return t;let e=vl(t);return pl(e,r,a),e}return t}case`Pipe`:{let e=J(t,i.left,n)[0],o=r(e,i.right,a);return r(t,i.left,o)}default:return t}},o=a.left,s=a.right,c=J(t,o,n)[0];return c==null?t:r(t,o,i(c,s))}default:return t}}return i(e,t)}function jy(e,t,n,r,i){if(t===`and`)return yy(i,J(e,n,i),t=>Cv(t)?yy(i,J(e,r,i),e=>[Cv(e)]):[!1]);if(t===`or`)return yy(i,J(e,n,i),t=>Cv(t)?[!0]:yy(i,J(e,r,i),e=>[Cv(e)]));if(t===`//`){let t=J(e,n,i).filter(e=>e!=null&&e!==!1);return t.length>0?t:J(e,r,i)}let a=J(e,n,i),o=J(e,r,i),s=a.length*o.length;return _y(i,0,s),gy(i,s),a.flatMap(e=>o.map(n=>{switch(t){case`+`:if(e===null)return n;if(n===null)return e;if(typeof e==`number`&&typeof n==`number`)return e+n;if(typeof e==`string`&&typeof n==`string`){let t=i.limits.maxStringLength;if(O(e)+O(n)>t)throw new A(`string size limit exceeded (${t} bytes)`,`string_length`);return e+n}return Array.isArray(e)&&Array.isArray(n)?(_y(i,e.length,n.length),[...e,...n]):e&&n&&typeof e==`object`&&typeof n==`object`&&!Array.isArray(e)&&!Array.isArray(n)?yl(e,n):null;case`-`:if(typeof e==`number`&&typeof n==`number`)return e-n;if(Array.isArray(e)&&Array.isArray(n)){let t=new Set(n.map(e=>JSON.stringify(e)));return e.filter(e=>!t.has(JSON.stringify(e)))}if(typeof e==`string`&&typeof n==`string`){let t=e=>e.length>10?`"${e.slice(0,10)}...`:JSON.stringify(e);throw Error(`string (${t(e)}) and string (${t(n)}) cannot be subtracted`)}return null;case`*`:if(typeof e==`number`&&typeof n==`number`)return e*n;if(typeof e==`string`&&typeof n==`number`){if(!Number.isFinite(n))throw Error(`invalid string repetition count: ${n}`);let t=Math.trunc(n);if(t<0)return null;let r=O(e),a=i.limits.maxStringLength;if(r>0&&t>Math.floor(a/r))throw new A(`string size limit exceeded (${a} bytes)`,`string_length`);return e.repeat(t)}{let t=gl(e),r=gl(n);if(t&&r)return Ev(t,r,{maxDepth:i.limits.maxDepth,visit:()=>gy(i)})}return null;case`/`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided because the divisor is zero`);return e/n}return typeof e==`string`&&typeof n==`string`?e.split(n):null;case`%`:if(typeof e==`number`&&typeof n==`number`){if(n===0)throw Error(`number (${e}) and number (${n}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(e)&&!Number.isNaN(e)?!Number.isFinite(n)&&!Number.isNaN(n)&&e<0&&n>0?-1:0:e%n}return null;case`==`:return wv(e,n);case`!=`:return!wv(e,n);case`<`:return Tv(e,n)<0;case`<=`:return Tv(e,n)<=0;case`>`:return Tv(e,n)>0;case`>=`:return Tv(e,n)>=0;default:return null}}))}function My(e,t,n,r){let i=zy.get(t);if(i)return typeof e==`number`?[i(e)]:[null];let a=Rv(e,t,n,r,J);if(a!==null)return a;let o=sy(e,t,n,r,J);if(o!==null)return o;let s=bv(e,t,n,r,J);if(s!==null)return s;let c=Nv(e,t,r.limits.maxDepth);if(c!==null)return c;let l=ly(e,t);if(l!==null)return l;let u=Jv(e,t,n,r,J);if(u!==null)return u;let d=mv(e,t,n,r,J,Ey,Ov,Cv,kv,A);if(d!==null)return d;let f=$v(e,t,n,r,J,Cv,fy,py,Ay,Ny);if(f!==null)return f;let p=Iv(e,t,n,r,J,wv);if(p!==null)return p;let m=gv(e,t,n,r,J,Ey,Cv,A);if(m!==null)return m;let h=Uv(e,t,n,r,J,Cv,Cy,My);if(h!==null)return h;let g=ty(e,t,n,r,J,wv);if(g!==null)return g;switch(t){case`builtins`:return[`add/0.all/0.all/1.all/2.any/0.any/1.any/2.arrays/0.ascii/0.ascii_downcase/0.ascii_upcase/0.booleans/0.bsearch/1.builtins/0.combinations/0.combinations/1.contains/1.debug/0.del/1.delpaths/1.empty/0.env/0.error/0.error/1.explode/0.first/0.first/1.flatten/0.flatten/1.floor/0.from_entries/0.fromdate/0.fromjson/0.getpath/1.gmtime/0.group_by/1.gsub/2.gsub/3.has/1.implode/0.IN/1.IN/2.INDEX/1.INDEX/2.index/1.indices/1.infinite/0.inside/1.isempty/1.isnan/0.isnormal/0.isvalid/1.iterables/0.join/1.keys/0.keys_unsorted/0.last/0.last/1.length/0.limit/2.ltrimstr/1.map/1.map_values/1.match/1.match/2.max/0.max_by/1.min/0.min_by/1.mktime/0.modulemeta/1.nan/0.not/0.nth/1.nth/2.null/0.nulls/0.numbers/0.objects/0.path/1.paths/0.paths/1.pick/1.range/1.range/2.range/3.recurse/0.recurse/1.recurse_down/0.repeat/1.reverse/0.rindex/1.rtrimstr/1.scalars/0.scan/1.scan/2.select/1.setpath/2.skip/2.sort/0.sort_by/1.split/1.splits/1.splits/2.sqrt/0.startswith/1.strftime/1.strings/0.strptime/1.sub/2.sub/3.test/1.test/2.to_entries/0.toboolean/0.todate/0.tojson/0.tostream/0.fromstream/1.truncate_stream/1.tonumber/0.tostring/0.transpose/0.trim/0.ltrim/0.rtrim/0.type/0.unique/0.unique_by/1.until/2.utf8bytelength/0.values/0.walk/1.while/2.with_entries/1`.split(`.`)];case`error`:{let t=n.length>0?J(e,n[0],r)[0]:e;throw new Fy(t)}case`env`:return[r.env?rd(r.env):Object.create(null)];case`debug`:return[e];case`input_line_number`:return[1];default:{let i=`${t}/${n.length}`,a=r.funcs?.get(i);if(a){let t=a.closure??r.funcs??new Map,o=new Map(t);o.set(i,a);for(let t=0;t<a.params.length;t++){let i=a.params[t],s=n[t];if(s){let t=J(e,s,r),n;if(t.length===0)n={type:`Call`,name:`empty`,args:[]};else if(t.length===1)n={type:`Literal`,value:t[0]};else{n={type:`Literal`,value:t[t.length-1]};for(let e=t.length-2;e>=0;e--)n={type:`Comma`,left:{type:`Literal`,value:t[e]},right:n}}o.set(`${i}/0`,{params:[],body:n})}}let s={...r,funcs:o};return J(e,a.body,s)}throw Error(`Unknown function: ${t}`)}}}function Ny(e,t,n,r,i){if(gy(n),r.length>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);let a=e=>{if(e.length>n.limits.maxDepth)throw hy(`query depth limit exceeded (${n.limits.maxDepth})`,`recursion`);_y(n,i.length),i.push(e)};if(t.type===`Comma`){let a=t;Ny(e,a.left,n,r,i),Ny(e,a.right,n,r,i);return}let o=wy(t);if(o!==null){a([...r,...o]);return}if(t.type===`Iterate`){if(Array.isArray(e))for(let t=0;t<e.length;t++)gy(n),a([...r,t]);else if(e&&typeof e==`object`)for(let t of Object.keys(e))gy(n),a([...r,t]);return}if(t.type===`Recurse`){let t=[{value:e,path:[]}];for(;t.length>0;){let e=t.pop();if(!e)break;if(gy(n),a([...r,...e.path]),e.value&&typeof e.value==`object`){let r=Array.isArray(e.value)?e.value.map((e,t)=>[t,e]):Object.keys(e.value).map(t=>[t,e.value[t]]);_y(n,0,t.length+r.length);for(let n=r.length-1;n>=0;n--){let[i,a]=r[n];t.push({value:a,path:[...e.path,i]})}}}return}if(t.type===`Pipe`){let a=wy(t.left);if(a!==null){let o=J(e,t.left,n);for(let e of o)Ny(e,t.right,n,[...r,...a],i);return}}J(e,t,n).length>0&&a(r)}var Py,Fy,Iy,Ly,Ry,zy,By=T(()=>{Wi(),od(),j(),Su(),Lr(),dy(),my(),xl(),Av(),Py=class e extends Error{label;partialResults;constructor(e,t=[]){super(`break ${e}`),this.label=e,this.partialResults=t,this.name=`BreakError`}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},Fy=class extends Error{value;constructor(e){super(typeof e==`string`?e:JSON.stringify(e)),this.value=e,this.name=`JqError`}},Iy=1e4,Ly=10485760,Ry=2e3,zy=new Map([[`floor`,Math.floor],[`ceil`,Math.ceil],[`round`,Math.round],[`sqrt`,Math.sqrt],[`log`,Math.log],[`log10`,Math.log10],[`log2`,Math.log2],[`exp`,Math.exp],[`sin`,Math.sin],[`cos`,Math.cos],[`tan`,Math.tan],[`asin`,Math.asin],[`acos`,Math.acos],[`atan`,Math.atan],[`sinh`,Math.sinh],[`cosh`,Math.cosh],[`tanh`,Math.tanh],[`asinh`,Math.asinh],[`acosh`,Math.acosh],[`atanh`,Math.atanh],[`cbrt`,Math.cbrt],[`expm1`,Math.expm1],[`log1p`,Math.log1p],[`trunc`,Math.trunc]])});function Vy(e){let t=[],n=0,r=(t=0)=>e[n+t],i=()=>e[n++],a=()=>n>=e.length,o=e=>e>=`0`&&e<=`9`,s=e=>e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`,c=e=>s(e)||o(e);for(;!a();){let l=n,u=i();if(u!==` `&&u!==` `&&u!==`
644
+ `&&u!==`\r`){if(u===`#`){for(;!a()&&r()!==`
645
+ `;)i();continue}if(u===`.`&&r()===`.`){i(),t.push({type:`DOTDOT`,pos:l});continue}if(u===`=`&&r()===`=`){i(),t.push({type:`EQ`,pos:l});continue}if(u===`!`&&r()===`=`){i(),t.push({type:`NE`,pos:l});continue}if(u===`<`&&r()===`=`){i(),t.push({type:`LE`,pos:l});continue}if(u===`>`&&r()===`=`){i(),t.push({type:`GE`,pos:l});continue}if(u===`/`&&r()===`/`){i(),r()===`=`?(i(),t.push({type:`UPDATE_ALT`,pos:l})):t.push({type:`ALT`,pos:l});continue}if(u===`+`&&r()===`=`){i(),t.push({type:`UPDATE_ADD`,pos:l});continue}if(u===`-`&&r()===`=`){i(),t.push({type:`UPDATE_SUB`,pos:l});continue}if(u===`*`&&r()===`=`){i(),t.push({type:`UPDATE_MUL`,pos:l});continue}if(u===`/`&&r()===`=`){i(),t.push({type:`UPDATE_DIV`,pos:l});continue}if(u===`%`&&r()===`=`){i(),t.push({type:`UPDATE_MOD`,pos:l});continue}if(u===`=`&&r()!==`=`){t.push({type:`ASSIGN`,pos:l});continue}if(u===`.`){t.push({type:`DOT`,pos:l});continue}if(u===`|`){r()===`=`?(i(),t.push({type:`UPDATE_PIPE`,pos:l})):t.push({type:`PIPE`,pos:l});continue}if(u===`,`){t.push({type:`COMMA`,pos:l});continue}if(u===`:`){t.push({type:`COLON`,pos:l});continue}if(u===`;`){t.push({type:`SEMICOLON`,pos:l});continue}if(u===`(`){t.push({type:`LPAREN`,pos:l});continue}if(u===`)`){t.push({type:`RPAREN`,pos:l});continue}if(u===`[`){t.push({type:`LBRACKET`,pos:l});continue}if(u===`]`){t.push({type:`RBRACKET`,pos:l});continue}if(u===`{`){t.push({type:`LBRACE`,pos:l});continue}if(u===`}`){t.push({type:`RBRACE`,pos:l});continue}if(u===`?`){t.push({type:`QUESTION`,pos:l});continue}if(u===`+`){t.push({type:`PLUS`,pos:l});continue}if(u===`-`){t.push({type:`MINUS`,pos:l});continue}if(u===`*`){t.push({type:`STAR`,pos:l});continue}if(u===`/`){t.push({type:`SLASH`,pos:l});continue}if(u===`%`){t.push({type:`PERCENT`,pos:l});continue}if(u===`<`){t.push({type:`LT`,pos:l});continue}if(u===`>`){t.push({type:`GT`,pos:l});continue}if(o(u)){let s=u;for(;!a()&&(o(r())||r()===`.`||r()===`e`||r()===`E`);)(r()===`e`||r()===`E`)&&(e[n+1]===`+`||e[n+1]===`-`)&&(s+=i()),s+=i();t.push({type:`NUMBER`,value:Number(s),pos:l});continue}if(u===`"`){let e=``,n=0;for(;!a();){let t=r();if(n===0&&t===`"`)break;if(n===0&&t===`\\`){if(i(),a())break;let t=i();switch(t){case`n`:e+=`
646
+ `;break;case`r`:e+=`\r`;break;case`t`:e+=` `;break;case`\\`:e+=`\\`;break;case`"`:e+=`"`;break;case`(`:e+=`\\(`,n=1;break;default:e+=t}continue}if(n>0){if(t===`"`){for(e+=i();!a();){let t=r();if(t===`\\`){e+=i(),a()||(e+=i());continue}if(e+=i(),t===`"`)break}continue}t===`(`?n++:t===`)`&&n--,e+=i();continue}e+=i()}a()||i(),t.push({type:`STRING`,value:e,pos:l});continue}if(s(u)||u===`$`||u===`@`){let e=u;for(;!a()&&c(r());)e+=i();let n=Uy.get(e);n?t.push({type:n,value:e,pos:l}):t.push({type:`IDENT`,value:e,pos:l});continue}throw Error(`Unexpected character '${u}' at position ${l}`)}}return t.push({type:`EOF`,pos:n}),t}function Hy(e,t={}){let n=t.maxDepth??256,r=t.maxTokens??1e5,i=t.maxSourceLength??1048576;if(e.length>i)throw Error(`query source length limit exceeded (${i} characters)`);if(e.length+1>r)throw Error(`query token limit exceeded (${r})`);let a=Vy(e);return new Gy(a,n).parse()}var Uy,Wy,Gy,Ky=T(()=>{Uy=new Map([[`and`,`AND`],[`or`,`OR`],[`not`,`NOT`],[`if`,`IF`],[`then`,`THEN`],[`elif`,`ELIF`],[`else`,`ELSE`],[`end`,`END`],[`as`,`AS`],[`try`,`TRY`],[`catch`,`CATCH`],[`true`,`TRUE`],[`false`,`FALSE`],[`null`,`NULL`],[`reduce`,`REDUCE`],[`foreach`,`FOREACH`],[`label`,`LABEL`],[`break`,`BREAK`],[`def`,`DEF`]]),Wy=new Set(Uy.values()),Gy=class e{maxDepth;tokens;pos=0;depth;constructor(e,t,n=0){this.maxDepth=t,this.tokens=e,this.depth=n}peek(e=0){return this.tokens[this.pos+e]??{type:`EOF`,pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let t of e)if(this.check(t))return this.advance();return null}expect(e,t){if(!this.check(e))throw Error(`${t} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}withDepth(e){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return e()}finally{this.depth--}}isFieldNameAfterDot(e=0){let t=this.peek(e),n=this.peek(e+1);return n.type===`STRING`?!0:n.type===`IDENT`||Wy.has(n.type)?n.pos===t.pos+1:!1}isIdentLike(){let e=this.peek().type;return e===`IDENT`||Wy.has(e)}consumeFieldNameAfterDot(e){let t=this.peek();return t.type===`STRING`||(t.type===`IDENT`||Wy.has(t.type))&&t.pos===e.pos+1?this.advance().value:null}parse(){let e=this.parseExpr();if(!this.check(`EOF`))throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePipe()}finally{this.depth--}}parsePattern(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parsePatternInner()}finally{this.depth--}}parsePatternInner(){if(this.match(`LBRACKET`)){let e=[];if(!this.check(`RBRACKET`))for(e.push(this.parsePattern());this.match(`COMMA`)&&!this.check(`RBRACKET`);)e.push(this.parsePattern());return this.expect(`RBRACKET`,`Expected ']' after array pattern`),{type:`array`,elements:e}}if(this.match(`LBRACE`)){let e=[];if(!this.check(`RBRACE`))for(e.push(this.parsePatternField());this.match(`COMMA`)&&!this.check(`RBRACE`);)e.push(this.parsePatternField());return this.expect(`RBRACE`,`Expected '}' after object pattern`),{type:`object`,fields:e}}let e=this.expect(`IDENT`,`Expected variable name in pattern`),t=e.value;if(!t.startsWith(`$`))throw Error(`Variable name must start with $ at position ${e.pos}`);return{type:`var`,name:t}}parsePatternField(){if(this.match(`LPAREN`)){let e=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after computed key`),this.expect(`COLON`,`Expected ':' after computed key`),{key:e,pattern:this.parsePattern()}}let e=this.peek();if(e.type===`IDENT`||Wy.has(e.type)){let t=e.value;if(t.startsWith(`$`)){if(this.advance(),this.match(`COLON`)){let e=this.parsePattern();return{key:t.slice(1),pattern:e,keyVar:t}}return{key:t.slice(1),pattern:{type:`var`,name:t}}}return this.advance(),this.match(`COLON`)?{key:t,pattern:this.parsePattern()}:{key:t,pattern:{type:`var`,name:`$${t}`}}}throw Error(`Expected field name in object pattern at position ${e.pos}`)}parsePipe(){let e=this.parseComma();for(;this.match(`PIPE`);){let t=this.parseComma();e={type:`Pipe`,left:e,right:t}}return e}parseComma(){let e=this.parseVarBind();for(;this.match(`COMMA`);){let t=this.parseVarBind();e={type:`Comma`,left:e,right:t}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match(`AS`)){let t=this.parsePattern(),n=[];for(;this.check(`QUESTION`)&&this.peekAhead(1)?.type===`ALT`;)this.advance(),this.advance(),n.push(this.parsePattern());this.expect(`PIPE`,`Expected '|' after variable binding`);let r=this.parseExpr();return t.type===`var`&&n.length===0?{type:`VarBind`,name:t.name,value:e,body:r}:{type:`VarBind`,name:t.type===`var`?t.name:``,value:e,body:r,pattern:t.type===`var`?void 0:t,alternatives:n.length>0?n:void 0}}return e}peekAhead(e){let t=this.pos+e;return t<this.tokens.length?this.tokens[t]:void 0}parseUpdate(){let e=this.parseAlt(),t=new Map([[`ASSIGN`,`=`],[`UPDATE_ADD`,`+=`],[`UPDATE_SUB`,`-=`],[`UPDATE_MUL`,`*=`],[`UPDATE_DIV`,`/=`],[`UPDATE_MOD`,`%=`],[`UPDATE_ALT`,`//=`],[`UPDATE_PIPE`,`|=`]]),n=this.match(`ASSIGN`,`UPDATE_ADD`,`UPDATE_SUB`,`UPDATE_MUL`,`UPDATE_DIV`,`UPDATE_MOD`,`UPDATE_ALT`,`UPDATE_PIPE`);if(n){let r=this.withDepth(()=>this.parseVarBind()),i=t.get(n.type);if(i)return{type:`UpdateOp`,op:i,path:e,value:r}}return e}parseAlt(){let e=this.parseOr();for(;this.match(`ALT`);){let t=this.parseOr();e={type:`BinaryOp`,op:`//`,left:e,right:t}}return e}parseOr(){let e=this.parseAnd();for(;this.match(`OR`);){let t=this.parseAnd();e={type:`BinaryOp`,op:`or`,left:e,right:t}}return e}parseAnd(){let e=this.parseNot();for(;this.match(`AND`);){let t=this.parseNot();e={type:`BinaryOp`,op:`and`,left:e,right:t}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),t=new Map([[`EQ`,`==`],[`NE`,`!=`],[`LT`,`<`],[`LE`,`<=`],[`GT`,`>`],[`GE`,`>=`]]),n=this.match(`EQ`,`NE`,`LT`,`LE`,`GT`,`GE`);if(n){let r=t.get(n.type);if(r){let t=this.parseAddSub();e={type:`BinaryOp`,op:r,left:e,right:t}}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match(`PLUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`+`,left:e,right:t}}else if(this.match(`MINUS`)){let t=this.parseMulDiv();e={type:`BinaryOp`,op:`-`,left:e,right:t}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match(`STAR`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`*`,left:e,right:t}}else if(this.match(`SLASH`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`/`,left:e,right:t}}else if(this.match(`PERCENT`)){let t=this.parseUnary();e={type:`BinaryOp`,op:`%`,left:e,right:t}}else break;return e}parseUnary(){let e=0;for(;this.match(`MINUS`);)if(e++,this.depth+e>this.maxDepth)throw Error(`query parse depth limit exceeded (${this.maxDepth})`);let t=this.parsePostfix();for(;e-->0;)t={type:`UnaryOp`,op:`-`,operand:t};return t}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match(`QUESTION`))e={type:`Optional`,expr:e};else if(this.check(`DOT`)&&this.isFieldNameAfterDot())this.advance(),e={type:`Field`,name:this.advance().value,base:e};else if(this.check(`LBRACKET`))if(this.advance(),this.match(`RBRACKET`))e={type:`Iterate`,base:e};else if(this.check(`COLON`)){this.advance();let t=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,end:t,base:e}}else{let t=this.parseExpr();if(this.match(`COLON`)){let n=this.check(`RBRACKET`)?void 0:this.parseExpr();this.expect(`RBRACKET`,`Expected ']'`),e={type:`Slice`,start:t,end:n,base:e}}else this.expect(`RBRACKET`,`Expected ']'`),e={type:`Index`,index:t,base:e}}else break;return e}parsePrimary(){if(this.match(`DOTDOT`))return{type:`Recurse`};if(this.check(`DOT`)){let e=this.advance();if(this.check(`LBRACKET`)){if(this.advance(),this.match(`RBRACKET`))return{type:`Iterate`};if(this.check(`COLON`)){this.advance();let e=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,end:e}}let e=this.parseExpr();if(this.match(`COLON`)){let t=this.check(`RBRACKET`)?void 0:this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Slice`,start:e,end:t}}return this.expect(`RBRACKET`,`Expected ']'`),{type:`Index`,index:e}}let t=this.consumeFieldNameAfterDot(e);return t===null?{type:`Identity`}:{type:`Field`,name:t}}if(this.match(`TRUE`))return{type:`Literal`,value:!0};if(this.match(`FALSE`))return{type:`Literal`,value:!1};if(this.match(`NULL`))return{type:`Literal`,value:null};if(this.check(`NUMBER`))return{type:`Literal`,value:this.advance().value};if(this.check(`STRING`)){let e=this.advance().value;return e.includes(`\\(`)?this.parseStringInterpolation(e):{type:`Literal`,value:e}}if(this.match(`LBRACKET`)){if(this.match(`RBRACKET`))return{type:`Array`};let e=this.parseExpr();return this.expect(`RBRACKET`,`Expected ']'`),{type:`Array`,elements:e}}if(this.match(`LBRACE`))return this.parseObjectConstruction();if(this.match(`LPAREN`)){let e=this.parseExpr();return this.expect(`RPAREN`,`Expected ')'`),{type:`Paren`,expr:e}}if(this.match(`IF`))return this.parseIf();if(this.match(`TRY`)){let e=this.withDepth(()=>this.parsePostfix()),t;return this.match(`CATCH`)&&(t=this.withDepth(()=>this.parsePostfix())),{type:`Try`,body:e,catch:t}}if(this.match(`REDUCE`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after reduce expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr();return this.expect(`RPAREN`,`Expected ')' after update expression`),{type:`Reduce`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,pattern:t.type===`var`?void 0:t}}if(this.match(`FOREACH`)){let e=this.parseAddSub();this.expect(`AS`,`Expected 'as' after foreach expression`);let t=this.parsePattern();this.expect(`LPAREN`,`Expected '(' after variable`);let n=this.parseExpr();this.expect(`SEMICOLON`,`Expected ';' after init expression`);let r=this.parseExpr(),i;return this.match(`SEMICOLON`)&&(i=this.parseExpr()),this.expect(`RPAREN`,`Expected ')' after expressions`),{type:`Foreach`,expr:e,varName:t.type===`var`?t.name:``,init:n,update:r,extract:i,pattern:t.type===`var`?void 0:t}}if(this.match(`LABEL`)){let e=this.expect(`IDENT`,`Expected label name (e.g., $out)`),t=e.value;if(!t.startsWith(`$`))throw Error(`Label name must start with $ at position ${e.pos}`);return this.expect(`PIPE`,`Expected '|' after label name`),{type:`Label`,name:t,body:this.parseExpr()}}if(this.match(`BREAK`)){let e=this.expect(`IDENT`,`Expected label name to break to`),t=e.value;if(!t.startsWith(`$`))throw Error(`Break label must start with $ at position ${e.pos}`);return{type:`Break`,name:t}}if(this.match(`DEF`)){let e=this.expect(`IDENT`,`Expected function name after def`).value,t=[];if(this.match(`LPAREN`)){if(!this.check(`RPAREN`)){let e=this.expect(`IDENT`,`Expected parameter name`);for(t.push(e.value);this.match(`SEMICOLON`);){let e=this.expect(`IDENT`,`Expected parameter name`);t.push(e.value)}}this.expect(`RPAREN`,`Expected ')' after parameters`)}this.expect(`COLON`,`Expected ':' after function name`);let n=this.parseExpr();return this.expect(`SEMICOLON`,`Expected ';' after function body`),{type:`Def`,name:e,params:t,funcBody:n,body:this.parseExpr()}}if(this.match(`NOT`))return{type:`Call`,name:`not`,args:[]};if(this.check(`IDENT`)){let e=this.advance().value;if(e.startsWith(`$`))return{type:`VarRef`,name:e};if(this.match(`LPAREN`)){let t=[];if(!this.check(`RPAREN`))for(t.push(this.parseExpr());this.match(`SEMICOLON`);)t.push(this.parseExpr());return this.expect(`RPAREN`,`Expected ')'`),{type:`Call`,name:e,args:t}}return{type:`Call`,name:e,args:[]}}throw Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){if(this.depth++,this.depth>this.maxDepth)throw this.depth--,Error(`query parse depth limit exceeded (${this.maxDepth})`);try{return this.parseObjectConstructionInner()}finally{this.depth--}}parseObjectConstructionInner(){let e=[];if(!this.check(`RBRACE`))do{let t,n;if(this.match(`LPAREN`))t=this.parseExpr(),this.expect(`RPAREN`,`Expected ')'`),this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else if(this.isIdentLike()){let e=this.advance().value;this.match(`COLON`)?(t=e,n=this.parseObjectValue()):(t=e,n={type:`Field`,name:e})}else if(this.check(`STRING`))t=this.advance().value,this.expect(`COLON`,`Expected ':'`),n=this.parseObjectValue();else throw Error(`Expected object key at position ${this.peek().pos}`);e.push({key:t,value:n})}while(this.match(`COMMA`));return this.expect(`RBRACE`,`Expected '}'`),{type:`Object`,entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match(`PIPE`);){let t=this.parseVarBind();e={type:`Pipe`,left:e,right:t}}return e}parseIf(){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then'`);let t=this.parseExpr(),n=[];for(;this.match(`ELIF`);){let e=this.parseExpr();this.expect(`THEN`,`Expected 'then' after elif`);let t=this.parseExpr();n.push({cond:e,then:t})}let r;return this.match(`ELSE`)&&(r=this.parseExpr()),this.expect(`END`,`Expected 'end'`),{type:`Cond`,cond:e,then:t,elifs:n,else:r}}parseStringInterpolation(t){let n=[],r=``,i=0;for(;i<t.length;)if(t[i]===`\\`&&t[i+1]===`(`){r&&=(n.push(r),``),i+=2;let a=1,o=``;for(;i<t.length&&a>0;){let e=t[i];if(e===`"`){for(o+=e,i++;i<t.length;){let e=t[i];if(e===`\\`){o+=e,i++,i<t.length&&(o+=t[i],i++);continue}if(o+=e,i++,e===`"`)break}continue}e===`(`?a++:e===`)`&&a--,a>0&&(o+=e),i++}let s=Vy(o),c=new e(s,this.maxDepth,this.depth);n.push(c.parse())}else r+=t[i],i++;return r&&n.push(r),{type:`StringInterp`,parts:n}}}}),qy=T(()=>{By(),Ky()});function Jy(e,t,n={}){let r=new Ui(t,`query JSON output`,()=>new A(`output size limit exceeded (${t} bytes)`,n.limitKind??`output_size`));return Yy(r,e,n,0),r.build()}function Yy(e,t,n,r){if(t==null){e.append(`null`);return}if(typeof t==`boolean`){e.append(String(t));return}if(typeof t==`number`){e.append(Number.isFinite(t)?String(t):`null`);return}if(typeof t==`string`){n.raw&&r===0?e.append(t):Xy(e,t);return}let i=n.compact??!1,a=n.indent??2,o=n.useTab?` `:` `.repeat(a);if(Array.isArray(t)){e.append(`[`);for(let a=0;a<t.length;a++)e.append(i?a===0?``:`,`:a===0?`
647
+ `:`,
648
+ `),i||e.repeat(o,r+1),Yy(e,t[a],n,r+1);!i&&t.length>0&&e.append(`
649
+ `).repeat(o,r),e.append(`]`);return}let s=Object.keys(t);n.sortKeys&&(s=s.sort()),e.append(`{`);for(let a=0;a<s.length;a++){let c=s[a];e.append(i?a===0?``:`,`:a===0?`
650
+ `:`,
651
+ `),i||e.repeat(o,r+1),Xy(e,c),e.append(i?`:`:`: `),Yy(e,t[c],n,r+1)}!i&&s.length>0&&e.append(`
652
+ `).repeat(o,r),e.append(`}`)}function Xy(e,t){e.append(`"`);let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r),a=``;i===34?a=`\\"`:i===92?a=`\\\\`:i===8?a=`\\b`:i===9?a=`\\t`:i===10?a=`\\n`:i===12?a=`\\f`:i===13?a=`\\r`:i<32&&(a=`\\u${i.toString(16).padStart(4,`0`)}`),a&&(e.append(t.slice(n,r)).append(a),n=r+1)}e.append(t.slice(n)).append(`"`)}var Zy=T(()=>{Wi(),j()}),Qy={};E(Qy,{flagsForFuzzing:()=>ob,jqCommand:()=>ab});function $y(e){switch(e){case`\b`:return`\\b`;case`\f`:return`\\f`;case`
653
+ `:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;default:return`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`}}function eb(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(r){t+=a,r=!1;continue}if(a===`\\`){t+=a,r=!0;continue}if(a===`"`){t+=a,n=!n;continue}if(n&&a.charCodeAt(0)<=31){t+=$y(a);continue}t+=a}return t}function tb(e,t,n){return JSON.parse(eb(e.slice(t,n)))}function nb(e,t){let n=[],r=e=>{if(n.length>=t.maxElements)throw new A(`query result element limit exceeded (${t.maxElements})`,`array_elements`);n.push(e)},i=0,a=e.length;for(;i<a;){for(;i<a&&/\s/.test(e[i]);)i++;if(i>=a)break;let n=i,o=e[i];if(o===`{`||o===`[`){let s=[o===`{`?`}`:`]`],c=!1,l=!1;for(i++;i<a&&s.length>0;){let n=e[i];if(l)l=!1;else if(n===`\\`)l=!0;else if(n===`"`)c=!c;else if(!c){if(n===`{`||n===`[`){if(s.push(n===`{`?`}`:`]`),s.length>t.maxDepth)throw new A(`query depth limit exceeded (${t.maxDepth})`,`recursion`)}else if((n===`}`||n===`]`)&&s.pop()!==n)throw Error(`Mismatched JSON delimiter at position ${i}`)}i++}if(s.length!==0)throw Error(`Unexpected end of JSON input at position ${i} (unclosed ${o})`);r(hl(tb(e,n,i),{maxDepth:t.maxDepth,maxElements:t.maxElements}))}else if(o===`"`){let o=!1;for(i++;i<a;){let t=e[i];if(o)o=!1;else if(t===`\\`)o=!0;else if(t===`"`){i++;break}i++}r(hl(tb(e,n,i),t))}else if(o===`-`||o>=`0`&&o<=`9`){for(;i<a&&/[\d.eE+-]/.test(e[i]);)i++;r(hl(tb(e,n,i),t))}else if(e.slice(i,i+4)===`true`)r(!0),i+=4;else if(e.slice(i,i+5)===`false`)r(!1),i+=5;else if(e.slice(i,i+4)===`null`)r(null),i+=4;else{let t=e.slice(i,i+10);throw Error(`Invalid JSON at position ${n}: unexpected '${t.split(/\s/)[0]}'`)}}return n}function rb(e){return{stdout:``,stderr:`jq: ${e}
654
+ `,exitCode:2}}var ib,ab,ob,sb=T(()=>{k(),ea(),j(),Su(),qn(),Zr(),F(),Lr(),qy(),Zy(),xl(),Av(),ib={name:`jq`,summary:`command-line JSON processor`,usage:`jq [OPTIONS] FILTER [FILE...]`,options:[`-R, --raw-input read each line as string instead of JSON`,`-r, --raw-output output strings without quotes`,`-c, --compact-output compact instead of pretty-printed output`,`-e, --exit-status set exit status based on output`,`-s, --slurp read entire input into array`,`-n, --null-input don't read any input`,`-j, --join-output don't print newlines after each output`,`-a, --ascii force ASCII output`,`-S, --sort-keys sort object keys`,`-C, --color colorize output (ignored)`,`-M, --monochrome monochrome output (ignored)`,` --tab use tabs for indentation`,` --arg NAME VALUE bind $NAME to the string VALUE`,` --argjson NAME JSON bind $NAME to the JSON-decoded value JSON`,` --rawfile NAME FILE bind $NAME to the raw contents of FILE`,` --slurpfile NAME FILE bind $NAME to the array of JSON values in FILE`,` --args remaining arguments are string positional args ($ARGS.positional)`,` --jsonargs remaining arguments are JSON positional args ($ARGS.positional)`,` --help display this help and exit`]},ab={name:`jq`,async execute(e,t){bu(t.requireDefenseContext,`jq`,`execution entry`);let n=(e,n)=>xu(t.requireDefenseContext,`jq`,e,n);if(N(e))return M(ib);let r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=`.`,p=!1,m=`none`,h=[],g=new Map,_=[],v=[],y={maxDepth:t.limits.maxQueryDepth,maxElements:t.limits.maxQueryElements};for(let t=0;t<e.length;t++){let n=e[t];if(n===`-R`||n===`--raw-input`)i=!0;else if(n===`-r`||n===`--raw-output`)r=!0;else if(n===`-c`||n===`--compact-output`)a=!0;else if(n===`-e`||n===`--exit-status`)o=!0;else if(n===`-s`||n===`--slurp`)s=!0;else if(n===`-n`||n===`--null-input`)c=!0;else if(n===`-j`||n===`--join-output`)l=!0;else if(n!==`-a`&&n!==`--ascii`){if(n===`-S`||n===`--sort-keys`)u=!0;else if(n!==`-C`&&n!==`--color`&&n!==`-M`&&n!==`--monochrome`)if(n===`--tab`)d=!0;else if(n===`--arg`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--arg takes two parameters (e.g. --arg varname value)`);g.set(n,r),t+=2}else if(n===`--argjson`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--argjson takes two parameters (e.g. --argjson varname text)`);let i;try{i=nb(r.trim(),y)}catch{return rb(`invalid JSON text passed to --argjson`)}if(i.length!==1)return rb(`invalid JSON text passed to --argjson`);g.set(n,i[0]),t+=2}else if(n===`--rawfile`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--rawfile takes two parameters (e.g. --rawfile varname filename)`);v.push({name:n,file:r,mode:`raw`}),t+=2}else if(n===`--slurpfile`){let n=e[t+1],r=e[t+2];if(n===void 0||r===void 0)return rb(`--slurpfile takes two parameters (e.g. --slurpfile varname filename)`);v.push({name:n,file:r,mode:`slurp`}),t+=2}else if(n===`--args`)m=`args`;else if(n===`--jsonargs`)m=`jsonargs`;else if(n===`-`)h.push(`-`);else{if(n.startsWith(`--`))return P(`jq`,n);if(n.startsWith(`-`)){for(let e of n.slice(1))if(e===`R`)i=!0;else if(e===`r`)r=!0;else if(e===`c`)a=!0;else if(e===`e`)o=!0;else if(e===`s`)s=!0;else if(e===`n`)c=!0;else if(e===`j`)l=!0;else if(e!==`a`){if(e===`S`)u=!0;else if(e!==`C`&&e!==`M`)return P(`jq`,`-${e}`)}}else if(!p)f=n,p=!0;else if(m===`args`)_.push(n);else if(m===`jsonargs`){let e;try{e=nb(n.trim(),y)}catch{return rb(`invalid JSON text passed to --jsonargs`)}if(e.length!==1)return rb(`invalid JSON text passed to --jsonargs`);_.push(e[0])}else h.push(n)}}}if(v.length>0){let e=await n(`arg file read`,()=>Yr(t,v.map(e=>e.file),{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};for(let t=0;t<v.length;t++){let{name:n,mode:r}=v[t],i=or(e.files[t].content);if(r===`raw`)g.set(n,i);else{let e=i.trim();try{g.set(n,e?nb(e,y):[])}catch{return rb(`invalid JSON text passed to --slurpfile`)}}}}let b=[];if(!c)if(h.length===0||h.length===1&&h[0]===`-`)b.push({source:`stdin`,content:or(t.stdin)});else{let e=await n(`file read`,()=>Yr(t,h,{cmdName:`jq`,stopOnError:!0}));if(e.exitCode!==0)return{stdout:``,stderr:e.stderr,exitCode:2};b=e.files.map(e=>({source:e.filename||`stdin`,content:or(e.content)}))}try{let e=Hy(f,{maxDepth:t.limits.maxQueryDepth,maxTokens:t.limits.maxQueryTokens,maxSourceLength:t.limits.maxStringLength}),n=[],p={limits:t.limits?{maxIterations:t.limits.maxJqIterations,maxStringLength:t.limits.maxStringLength,maxOutputSize:t.limits.maxOutputSize,maxArrayElements:t.limits.maxQueryElements,maxDepth:t.limits.maxQueryDepth}:void 0,env:t.env,namedArgs:g,positionalArgs:_,coverage:t.coverage,requireDefenseContext:t.requireDefenseContext,budget:{operations:0,callDepth:0}},m=(e,n)=>{if(n.length>t.limits.maxQueryElements-e.length)throw new A(`query result element limit exceeded (${t.limits.maxQueryElements})`,`array_elements`);for(let t of n)e.push(t)};if(c)n=J(null,e,p);else if(i&&s)n=J(b.map(({content:e})=>e).join(``),e,p);else if(i){let t=``;for(let{content:r}of b){let i=t+r,a=0,o=i.indexOf(`
655
+ `,a);for(;o!==-1;)m(n,J(i.slice(a,o),e,p)),a=o+1,o=i.indexOf(`
656
+ `,a);t=i.slice(a)}t!==``&&m(n,J(t,e,p))}else if(s){let t=[];for(let{content:e}of b){let n=e.trim();n&&m(t,nb(n,y))}n=J(t,e,p)}else for(let{content:t}of b){let r=t.trim();if(!r)continue;let i=nb(r,y);for(let t of i)m(n,J(t,e,p))}let h=l?``:`
657
+ `,v=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize),x=[],S=0;for(let e of n){let n=x.length>0?h.length:0,i=+!l,o=v-S-n-i;if(o<0)throw new A(`output size limit exceeded (${v} bytes)`,`string_length`);if(Dv(e,t.limits.maxQueryDepth+1)>t.limits.maxQueryDepth)throw new A(`query depth limit exceeded (${t.limits.maxQueryDepth})`,`recursion`);let s=Jy(e,o,{compact:a,raw:r,sortKeys:u,useTab:d,limitKind:`string_length`}),c=O(s);if(S+n+c+i>v)throw new A(`output size limit exceeded (${v} bytes)`,`string_length`);S+=n+c,x.push(s)}let ee=x.join(h),C=o&&(n.length===0||n.every(e=>e==null||e===!1))?1:0;return{stdout:ee?l?ee:`${ee}
658
+ `:``,stderr:``,exitCode:C}}catch(e){if(e instanceof D)throw e;if(e instanceof A)return{stdout:``,stderr:`jq: ${$i(e.message)}
659
+ `,exitCode:A.EXIT_CODE};let t=$i(e.message);return t.includes(`Unknown function`)?{stdout:``,stderr:`jq: error: ${t}
660
+ `,exitCode:3}:{stdout:``,stderr:`jq: parse error: ${t}
661
+ `,exitCode:5}}}},ob={name:`jq`,flags:[{flag:`-R`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-c`,type:`boolean`},{flag:`-e`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-j`,type:`boolean`},{flag:`-S`,type:`boolean`},{flag:`--tab`,type:`boolean`}],stdinType:`json`,needsArgs:!0}}),cb={};E(cb,{base64Command:()=>hb,flagsForFuzzing:()=>gb});function lb(e,t,n,r){if(e>t)throw new A(`base64: ${n} limit exceeded (${t} bytes)`,r)}function ub(e){let t=[];for(let n=0;n<e.length;n+=32768)t.push(String.fromCharCode(...e.subarray(n,n+32768)));return t.join(``)}function db(e){if(e.length===0)return 0;let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.max(0,Math.ceil(e.length/4)*3-t)}async function fb(e,t,n){let r=Math.min(e.limits.maxInputBytes,e.limits.maxStringLength),i=e.stdin;if(t.length===0||t.length===1&&t[0]===`-`)return lb(i.length,r,`input size`,`string_length`),{ok:!0,data:Uint8Array.from(i,e=>e.charCodeAt(0))};let a=[],o=0;for(let s of t){if(s===`-`){lb(o+i.length,r,`input size`,`string_length`),a.push(Uint8Array.from(i,e=>e.charCodeAt(0))),o+=i.length;continue}try{let t=e.fs.resolvePath(e.cwd,s),i=await e.fs.stat(t);lb(o+i.size,r,`input size`,`string_length`);let c=await e.fs.readFileBuffer(t);lb(o+c.length,r,`input size`,`string_length`),Jr(e,c.length,n),a.push(c),o+=c.length}catch(e){return Ur(e),{ok:!1,error:{stdout:``,stderr:`${n}: ${s}: No such file or directory
662
+ `,exitCode:1}}}}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return{ok:!0,data:s}}var pb,mb,hb,gb,_b=T(()=>{k(),Wr(),j(),Kr(),Zr(),F(),pb={name:`base64`,summary:`base64 encode/decode data and print to standard output`,usage:`base64 [OPTION]... [FILE]`,options:[`-d, --decode decode data`,`-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)`,` --help display this help and exit`]},mb={decode:{short:`d`,long:`decode`,type:`boolean`},wrap:{short:`w`,long:`wrap`,type:`number`,default:76}},hb={name:`base64`,async execute(e,t){if(N(e))return M(pb);let n=Gr(`base64`,e,mb);if(!n.ok)return n.error;let r=n.result.flags.decode,i=n.result.flags.wrap,a=n.result.positional;if(!Number.isSafeInteger(i)||i<0)return{stdout:``,stderr:`base64: invalid wrap size
663
+ `,exitCode:1};try{if(r){let e=await fb(t,a,`base64`);if(!e.ok)return e.error;if(typeof Buffer<`u`){let n=Buffer.from(e.data).toString(`utf8`).replace(/\s/g,``),r=db(n);lb(r,t.limits.maxStringLength,`decoded size`,`string_length`),lb(r,t.limits.maxOutputSize,`output size`,`output_size`);let i=Buffer.from(n,`base64`);return lb(i.length,t.limits.maxOutputSize,`output size`,`output_size`),{stdout:i.toString(`latin1`),stderr:``,exitCode:0,stdoutEncoding:`binary`}}let n=ub(e.data).replace(/\s/g,``),r=db(n);lb(r,t.limits.maxStringLength,`decoded size`,`string_length`),lb(r,t.limits.maxOutputSize,`output size`,`output_size`);let i=atob(n);return lb(i.length,t.limits.maxOutputSize,`output size`,`output_size`),{stdout:i,stderr:``,exitCode:0,stdoutEncoding:`binary`}}let e=await fb(t,a,`base64`);if(!e.ok)return e.error;let n=Math.ceil(e.data.length/3)*4,o=i>0&&n>0?Math.ceil(n/i):0;if(o>t.limits.maxArrayElements)throw new A(`base64: wrapped line limit exceeded (${t.limits.maxArrayElements})`,`array_elements`);lb(n,t.limits.maxStringLength,`encoded size`,`string_length`),lb(n+o,t.limits.maxOutputSize,`output size`,`output_size`);let s;if(s=typeof Buffer<`u`?Buffer.from(e.data).toString(`base64`):btoa(ub(e.data)),i>0){let e=[];for(let t=0;t<s.length;t+=i)e.push(s.slice(t,t+i));s=e.join(`
664
+ `)+(s.length>0?`
665
+ `:``)}return{stdout:s,stderr:``,exitCode:0}}catch(e){return Ur(e),{stdout:``,stderr:`base64: invalid input
666
+ `,exitCode:1}}}},gb={name:`base64`,flags:[{flag:`-d`,type:`boolean`},{flag:`-w`,type:`value`,valueHint:`number`}],stdinType:`text`,needsFiles:!0}}),vb={};E(vb,{diffCommand:()=>xb,flagsForFuzzing:()=>Sb});var yb,bb,xb,Sb,Cb=T(()=>{k(),Kr(),F(),yb={name:`diff`,summary:`compare files line by line`,usage:`diff [OPTION]... FILE1 FILE2`,options:[`-u, --unified output unified diff format (default)`,`-q, --brief report only whether files differ`,`-s, --report-identical-files report when files are the same`,`-i, --ignore-case ignore case differences`,` --help display this help and exit`]},bb={unified:{short:`u`,long:`unified`,type:`boolean`},brief:{short:`q`,long:`brief`,type:`boolean`},reportSame:{short:`s`,long:`report-identical-files`,type:`boolean`},ignoreCase:{short:`i`,long:`ignore-case`,type:`boolean`}},xb={name:`diff`,async execute(e,t){if(N(e))return M(yb);let r=Gr(`diff`,e,bb);if(!r.ok)return r.error;let i=r.result.flags.brief,a=r.result.flags.reportSame,o=r.result.flags.ignoreCase,s=r.result.positional;if(r.result.flags.unified,s.length<2)return{stdout:``,stderr:`diff: missing operand
667
+ `,exitCode:2};let c,l,[u,d]=s;try{c=u===`-`?or(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,u))}catch{return{stdout:``,stderr:`diff: ${u}: No such file or directory
668
+ `,exitCode:2}}try{l=d===`-`?or(t.stdin):await t.fs.readFile(t.fs.resolvePath(t.cwd,d))}catch{return{stdout:``,stderr:`diff: ${d}: No such file or directory
669
+ `,exitCode:2}}let f=c,p=l;return o&&(f=f.toLowerCase(),p=p.toLowerCase()),f===p?a?{stdout:`Files ${u} and ${d} are identical
670
+ `,stderr:``,exitCode:0}:{stdout:``,stderr:``,exitCode:0}:i?{stdout:`Files ${u} and ${d} differ
671
+ `,stderr:``,exitCode:1}:{stdout:n(u,d,c,l,``,``,{context:3}),stderr:``,exitCode:1}}},Sb={name:`diff`,flags:[{flag:`-u`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-s`,type:`boolean`},{flag:`-i`,type:`boolean`}],needsArgs:!0,minArgs:2}}),wb={};E(wb,{dateCommand:()=>Ab,flagsForFuzzing:()=>jb});function Tb(e){try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),!0}catch{return!1}}function Eb(e,t){let n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).formatToParts(e),r=e=>n.find(t=>t.type===e)?.value??`00`,i=Number.parseInt(r(`hour`),10)%24,a=new Date(`${r(`year`)}-${r(`month`)}-${r(`day`)}T${String(i).padStart(2,`0`)}:${r(`minute`)}:${r(`second`)}Z`);return Number.isNaN(a.getTime())?null:a}function Db(e,t){let n=e.match(/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?)?$/);if(!n)return null;let[,r,i,a,o=`00`,s=`00`,c=`00`]=n,l=new Date(`${r}-${i}-${a}T${o}:${s}:${c}Z`);if(Number.isNaN(l.getTime()))return null;try{let e=l;for(let n=0;n<3;n++){let n=Eb(e,t);if(n===null)return null;let r=n.getTime()-l.getTime();if(r===0)return e;e=new Date(e.getTime()-r)}return e}catch{return null}}function Ob(e,t){if(e.startsWith(`@`)){let t=e.slice(1);if(!/^-?\d+$/.test(t))return null;let n=Number(t);if(!Number.isSafeInteger(n))return null;let r=new Date(n*1e3);return Number.isNaN(r.getTime())?null:r}let n=e.toLowerCase().trim();if(n===`now`||n===`today`)return new Date;if(n===`yesterday`)return new Date(Date.now()-864e5);if(n===`tomorrow`)return new Date(Date.now()+864e5);if(t&&!/Z$/i.test(e)&&!/[+-]\d{2}:?\d{2}$/.test(e)){let n=Db(e,t);if(n)return n}let r=new Date(e);return Number.isNaN(r.getTime())?null:r}var kb,Ab,jb,Mb=T(()=>{F(),vi(),kb={name:`date`,summary:`display the current time in the given FORMAT`,usage:`date [OPTION]... [+FORMAT]`,options:[`-d, --date=STRING display time described by STRING, not 'now'`,`-u, --utc print Coordinated Universal Time (UTC)`,`-I, --iso-8601 output date/time in ISO 8601 format`,`-R, --rfc-email output RFC 5322 date format`,` --help display this help and exit`]},Ab={name:`date`,async execute(e,t){if(N(e))return M(kb);let n=!1,r=null,i=null,a=!1,o=!1;for(let t=0;t<e.length;t++){let s=e[t];if(s===`-u`||s===`--utc`)n=!0;else if(s===`-d`||s===`--date`)r=e[++t]??``;else if(s.startsWith(`--date=`))r=s.slice(7);else if(s===`-I`||s===`--iso-8601`)a=!0;else if(s===`-R`||s===`--rfc-email`)o=!0;else if(s.startsWith(`+`))i=s.slice(1);else{if(s.startsWith(`--`))return P(`date`,s);if(s.startsWith(`-`))for(let e of s.slice(1))if(e===`u`)n=!0;else if(e===`I`)a=!0;else if(e===`R`)o=!0;else return P(`date`,`-${e}`)}}let s=t.env.get(`TZ`);s&&!Tb(s)&&(s=void 0);let c=n?`UTC`:s??`UTC`,l=r===null?new Date:Ob(r,s);if(!l)return{stdout:``,stderr:`date: invalid date '${r}'
672
+ `,exitCode:1};let u=Math.floor(l.getTime()/1e3),d,f={maxOperations:t.limits.maxLoopIterations,maxOutputBytes:Math.min(t.limits.maxStringLength,t.limits.maxOutputSize)-1};return d=li(i||(a?`%Y-%m-%dT%H:%M:%S%z`:o?`%a, %d %b %Y %H:%M:%S %z`:`%a %b %e %H:%M:%S %Z %Y`),u,c,f),{stdout:`${d}
673
+ `,stderr:``,exitCode:0}}},jb={name:`date`,flags:[{flag:`-d`,type:`value`,valueHint:`string`},{flag:`-u`,type:`boolean`},{flag:`-I`,type:`boolean`},{flag:`-R`,type:`boolean`}]}});function Nb(e){let t=e.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!t)return null;let n=parseFloat(t[1]);switch(t[2]||`s`){case`s`:return n*1e3;case`m`:return n*60*1e3;case`h`:return n*60*60*1e3;case`d`:return n*24*60*60*1e3;default:return null}}var Pb=T(()=>{}),Fb={};E(Fb,{flagsForFuzzing:()=>zb,sleepCommand:()=>Rb});var Ib,Lb,Rb,zb,Bb=T(()=>{nr(),Pb(),F(),Ib={name:`sleep`,summary:`delay for a specified amount of time`,usage:`sleep NUMBER[SUFFIX]`,description:`Pause for NUMBER seconds. SUFFIX may be:
674
+ s - seconds (default)
675
+ m - minutes
676
+ h - hours
677
+ d - days
678
+
679
+ NUMBER may be a decimal number.`,options:[` --help display this help and exit`]},Lb=36e5,Rb={name:`sleep`,async execute(e,t){if(N(e))return M(Ib);if(e.length===0)return{stdout:``,stderr:`sleep: missing operand
680
+ `,exitCode:1};let n=0;for(let t of e){let e=Nb(t);if(e===null)return{stdout:``,stderr:`sleep: invalid time interval '${t}'
681
+ `,exitCode:1};n+=e}if(n>Lb&&(n=Lb),t.signal?.aborted)return{stdout:``,stderr:``,exitCode:0};if(t.sleep){let e=Promise.resolve(t.sleep(n));if(t.signal){let n,r=new Promise(e=>{n=e,t.signal?.addEventListener(`abort`,n,{once:!0}),t.signal?.aborted&&e()});try{await Promise.race([e,r])}finally{n&&t.signal.removeEventListener(`abort`,n)}}else await e}else t.signal?await new Promise(e=>{let r=()=>{er(i),e()},i=$n(()=>{t.signal?.removeEventListener(`abort`,r),e()},n);t.signal?.addEventListener(`abort`,r,{once:!0})}):await new Promise(e=>$n(e,n));return{stdout:``,stderr:``,exitCode:0}}},zb={name:`sleep`,flags:[],needsArgs:!0}}),Vb={};E(Vb,{flagsForFuzzing:()=>Wb,timeoutCommand:()=>Ub});var Hb,Ub,Wb,Gb=T(()=>{ir(),k(),Kl(),nr(),Pb(),F(),Hb={name:`timeout`,summary:`run a command with a time limit`,usage:`timeout [OPTION] DURATION COMMAND [ARG]...`,description:`Start COMMAND, and kill it if still running after DURATION.
682
+
683
+ DURATION is a number with optional suffix:
684
+ s - seconds (default)
685
+ m - minutes
686
+ h - hours
687
+ d - days`,options:[`-k, --kill-after=DURATION send KILL signal after DURATION if still running`,`-s, --signal=SIGNAL specify signal to send (default: TERM)`,` --preserve-status exit with same status as COMMAND, even on timeout`,` --foreground run command in foreground`,` --help display this help and exit`]},Ub={name:`timeout`,async execute(e,t){if(N(e))return M(Hb);let n=0;for(let t=0;t<e.length;t++){let r=e[t];if(r===`--preserve-status`)n=t+1;else if(r===`--foreground`)n=t+1;else if(r===`-k`||r===`--kill-after`)t++,n=t+1;else if(r.startsWith(`--kill-after=`))n=t+1;else if(r===`-s`||r===`--signal`)t++,n=t+1;else if(r.startsWith(`--signal=`))n=t+1;else{if(r.startsWith(`--`)&&r!==`--`)return P(`timeout`,r);if(r.startsWith(`-`)&&r.length>1&&r!==`--`)if(r.startsWith(`-k`))n=t+1;else if(r.startsWith(`-s`))n=t+1;else return P(`timeout`,r);else{n=t;break}}}let r=e.slice(n);if(r.length===0)return{stdout:``,stderr:`timeout: missing operand
688
+ `,exitCode:1};let i=r[0],a=Nb(i);if(a===null)return{stdout:``,stderr:`timeout: invalid time interval '${i}'
689
+ `,exitCode:1};let o=r.slice(1);if(o.length===0)return{stdout:``,stderr:`timeout: missing operand
690
+ `,exitCode:1};if(!t.exec)return{stdout:``,stderr:`timeout: exec not available
691
+ `,exitCode:1};let s=new AbortController,c=rr(t.signal,s.signal),l,u;try{let e=new Promise(e=>{u=()=>e({timedOut:!0}),c.signal?.addEventListener(`abort`,u,{once:!0}),l=$n(()=>{s.abort()},a)}),n=t.exec(Gl([o[0]]),{cwd:t.cwd,signal:c.signal,stdin:t.stdin,stdinKind:`bytes`,args:o.slice(1)}).then(e=>({timedOut:!1,result:e})),r=await Promise.race([e,n]);return r.timedOut?(await n.catch(()=>{}),{stdout:``,stderr:``,exitCode:124}):r.result}finally{l!==void 0&&er(l),u&&c.signal?.removeEventListener(`abort`,u),c.cleanup()}}},Wb={name:`timeout`,flags:[{flag:`-k`,type:`value`,valueHint:`string`},{flag:`-s`,type:`value`,valueHint:`string`},{flag:`--preserve-status`,type:`boolean`},{flag:`--foreground`,type:`boolean`}],needsArgs:!0,minArgs:2}}),Kb,qb,Jb,Yb=T(()=>{globalThis.SharedArrayBuffer,globalThis.Atomics,Kb=performance.now.bind(performance),qb=globalThis.Headers,Jb=globalThis.Proxy}),Xb={};E(Xb,{flagsForFuzzing:()=>$b,timeCommand:()=>Qb});function Zb(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${n.toString().padStart(2,`0`)}:${r.toFixed(2).padStart(5,`0`)}`:`${n}:${r.toFixed(2).padStart(5,`0`)}`}var Qb,$b,ex=T(()=>{k(),ea(),od(),Kl(),Yb(),Qb={name:`time`,async execute(e,t){let n=`%e %M`,r=null,i=!1,a=!1,o=0;for(;o<e.length;){let t=e[o];if(t===`-f`||t===`--format`){if(o++,o>=e.length)return{stdout:``,stderr:`time: missing argument to '-f'
692
+ `,exitCode:1};n=e[o],o++}else if(t===`-o`||t===`--output`){if(o++,o>=e.length)return{stdout:``,stderr:`time: missing argument to '-o'
693
+ `,exitCode:1};r=e[o],o++}else if(t===`-a`||t===`--append`)i=!0,o++;else if(t===`-v`||t===`--verbose`)n=`Command being timed: %C
694
+ Elapsed (wall clock) time: %e seconds
695
+ Maximum resident set size (kbytes): %M`,o++;else if(t===`-p`||t===`--portability`)a=!0,o++;else if(t===`--`){o++;break}else if(t.startsWith(`-`))o++;else break}let s=e.slice(o);if(s.length===0)return{stdout:``,stderr:``,exitCode:0};let c=Kb(),l=s.join(` `),u;try{if(!t.exec)return{stdout:``,stderr:`time: exec not available
696
+ `,exitCode:1};u=await t.exec(Gl([s[0]]),{env:rd(t.env),cwd:t.cwd,stdin:t.stdin,stdinKind:`bytes`,signal:t.signal,args:s.slice(1)})}catch(e){u={stdout:``,stderr:`time: ${$i(e.message)}
697
+ `,exitCode:127}}let d=(Kb()-c)/1e3,f;if(a?f=`real ${d.toFixed(2)}
698
+ user 0.00
699
+ sys 0.00
700
+ `:(f=n.replace(/%e/g,d.toFixed(2)).replace(/%E/g,Zb(d)).replace(/%M/g,`0`).replace(/%S/g,`0.00`).replace(/%U/g,`0.00`).replace(/%P/g,`0%`).replace(/%C/g,l),f.endsWith(`
701
+ `)||(f+=`
702
+ `)),r)try{let e=t.fs.resolvePath(t.cwd,r);if(i&&await t.fs.exists(e)){let n=await t.fs.readFile(e);await t.fs.writeFile(e,n+f)}else await t.fs.writeFile(e,f)}catch(e){let t=$i(e.message);return{stdout:u.stdout,stderr:u.stderr+`time: cannot write to '${r}': ${t}
703
+ `,exitCode:u.exitCode}}else u={...u,stderr:u.stderr+f};return u}},$b={name:`time`,flags:[{flag:`-p`,type:`boolean`}],needsArgs:!0}}),tx={};E(tx,{flagsForFuzzing:()=>rx,seqCommand:()=>nx});var nx,rx,ix=T(()=>{Wi(),k(),j(),nx={name:`seq`,async execute(e,t){let n=`
704
+ `,r=!1,i=[],a=0;for(;a<e.length;){let t=e[a];if(t===`-s`&&a+1<e.length){n=e[a+1],a+=2;continue}if(t===`-w`){r=!0,a++;continue}if(t===`--`){a++;break}if(t.startsWith(`-`)&&t!==`-`){if(t.startsWith(`-s`)&&t.length>2){n=t.slice(2),a++;continue}if((t===`-ws`||t===`-sw`)&&(r=!0,a+1<e.length)){n=e[a+1],a+=2;continue}}i.push(t),a++}for(;a<e.length;)i.push(e[a]),a++;if(i.length===0)return{stdout:``,stderr:`seq: missing operand
705
+ `,exitCode:1};let o=1,s=1,c;if(i.length===1?c=parseFloat(i[0]):i.length===2?(o=parseFloat(i[0]),c=parseFloat(i[1])):(o=parseFloat(i[0]),s=parseFloat(i[1]),c=parseFloat(i[2])),!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(c))return{stdout:``,stderr:`seq: invalid floating point argument: '${i.find(e=>!Number.isFinite(parseFloat(e)))}'
706
+ `,exitCode:1};if(s===0)return{stdout:``,stderr:`seq: invalid Zero increment value: '0'
707
+ `,exitCode:1};let l=[],u=e=>{let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1},d=Math.max(u(o),u(s),u(c)),f=Math.min(t.limits.maxLoopIterations,t.limits.maxArrayElements),p=Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),m=O(n),h=0,g=0,_=e=>{if(g>=f)throw new A(`seq: iteration limit exceeded (${f})`,`iterations`);let t=Bi(Bi(h,l.length>0?m:0,`seq`),Bi(O(e),1,`seq`),`seq`);if(t>p)throw new A(`seq: output size limit exceeded (${p} bytes)`,`output_size`);h=t-1,l.push(e),g++};if(s>0)for(let e=o;e<=c+1e-10;e+=s)_(d>0?e.toFixed(d):String(Math.round(e)));else for(let e=o;e>=c-1e-10;e+=s)_(d>0?e.toFixed(d):String(Math.round(e)));if(r&&l.length>0){let e=0;for(let t of l)e=Math.max(e,t.startsWith(`-`)?t.length-1:t.length);if(Bi(Bi(l.reduce((t,n)=>Bi(t,e+ +!!n.startsWith(`-`),`seq`),0),Vi(m,Math.max(0,l.length-1),`seq`),`seq`),1,`seq`)>p)throw new A(`seq: output size limit exceeded (${p} bytes)`,`output_size`);for(let t=0;t<l.length;t++){let n=l[t].startsWith(`-`),r=(n?l[t].slice(1):l[t]).padStart(e,`0`);l[t]=n?`-${r}`:r}}let v=Hi(l,n,p-1,`seq`);return{stdout:v?`${v}
708
+ `:``,stderr:``,exitCode:0}}},rx={name:`seq`,flags:[{flag:`-s`,type:`value`,valueHint:`string`},{flag:`-w`,type:`boolean`}],needsArgs:!0}}),ax={};E(ax,{exprCommand:()=>sx,flagsForFuzzing:()=>cx});function ox(e,t){if(e.length===1)return e[0];let n=0;function r(){let t=i();for(;n<e.length&&e[n]===`|`;){n++;let e=i();if(t!==`0`&&t!==``)return t;t=e}return t}function i(){let t=a();for(;n<e.length&&e[n]===`&`;){n++;let e=a();(t===`0`||t===``||e===`0`||e===``)&&(t=`0`)}return t}function a(){let t=o();for(;n<e.length;){let r=e[n];if([`=`,`!=`,`<`,`>`,`<=`,`>=`].includes(r)){n++;let e=o(),i=parseInt(t,10),a=parseInt(e,10),s=!Number.isNaN(i)&&!Number.isNaN(a),c;c=r===`=`?s?i===a:t===e:r===`!=`?s?i!==a:t!==e:r===`<`?s?i<a:t<e:r===`>`?s?i>a:t>e:r===`<=`?s?i<=a:t<=e:s?i>=a:t>=e,t=c?`1`:`0`}else break}return t}function o(){let t=s();for(;n<e.length;){let r=e[n];if(r===`+`||r===`-`){n++;let e=s(),i=parseInt(t,10),a=parseInt(e,10);if(Number.isNaN(i)||Number.isNaN(a))throw Error(`non-integer argument`);t=String(r===`+`?i+a:i-a)}else break}return t}function s(){let t=c();for(;n<e.length;){let r=e[n];if(r===`*`||r===`/`||r===`%`){n++;let e=c(),i=parseInt(t,10),a=parseInt(e,10);if(Number.isNaN(i)||Number.isNaN(a))throw Error(`non-integer argument`);if((r===`/`||r===`%`)&&a===0)throw Error(`division by zero`);t=String(r===`*`?i*a:r===`/`?Math.trunc(i/a):i%a)}else break}return t}function c(){let t=l();for(;n<e.length&&e[n]===`:`;){n++;let e=U(`^${l()}`).match(t);t=e?e[1]===void 0?String(e[0].length):e[1]:`0`}return t}function l(){if(n>=e.length)throw Error(`syntax error`);let i=e[n];if(i===`match`){n++;let e=l(),t=U(l()).match(e);return t?t[1]===void 0?String(t[0].length):t[1]:`0`}if(i===`substr`){n++;let e=l(),t=parseInt(l(),10),r=parseInt(l(),10);if(Number.isNaN(t)||Number.isNaN(r))throw Error(`non-integer argument`);return e.substring(t-1,t-1+r)}if(i===`index`){n++;let e=l(),r=l();t(r.length+e.length);let i=new Set;for(let e=0;e<r.length;e++)i.add(r[e]);for(let t=0;t<e.length;t++)if(i.has(e[t]))return String(t+1);return`0`}if(i===`length`){n++;let e=l();return String(e.length)}if(i===`(`){n++;let t=r();if(n>=e.length||e[n]!==`)`)throw Error(`syntax error`);return n++,t}return n++,i}let u=r();if(n!==e.length)throw Error(`syntax error`);return u}var sx,cx,lx=T(()=>{Wr(),ea(),mc(),sx={name:`expr`,async execute(e,t){if(e.length===0)return{stdout:``,stderr:`expr: missing operand
709
+ `,exitCode:2};try{let n=ox(e,e=>t.executionScope?.consumeWork(e,`expr index`)),r=+(n===`0`||n===``);return{stdout:`${n}
710
+ `,stderr:``,exitCode:r}}catch(e){return Ur(e),{stdout:``,stderr:`expr: ${$i(e.message)}
711
+ `,exitCode:2}}}},cx={name:`expr`,flags:[],needsArgs:!0}});function ux(e){function t(e,t){return e<<t|e>>>32-t}let n=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),r=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],i=e.length*8,a=(e.length%64<56?56:120)-e.length%64,o=new Uint8Array(e.length+a+8);o.set(e),o[e.length]=128;let s=new DataView(o.buffer);s.setUint32(o.length-8,i>>>0,!0),s.setUint32(o.length-4,Math.floor(i/4294967296),!0);let c=1732584193,l=4023233417,u=2562383102,d=271733878;for(let e=0;e<o.length;e+=64){let i=new Uint32Array(16);for(let t=0;t<16;t++)i[t]=s.getUint32(e+t*4,!0);let a=c,o=l,f=u,p=d;for(let e=0;e<64;e++){let s,c;e<16?(s=o&f|~o&p,c=e):e<32?(s=p&o|~p&f,c=(5*e+1)%16):e<48?(s=o^f^p,c=(3*e+5)%16):(s=f^(o|~p),c=7*e%16),s=s+a+n[e]+i[c]>>>0,a=p,p=f,f=o,o=o+t(s,r[e])>>>0}c=c+a>>>0,l=l+o>>>0,u=u+f>>>0,d=d+p>>>0}let f=new Uint8Array(16);return new DataView(f.buffer).setUint32(0,c,!0),new DataView(f.buffer).setUint32(4,l,!0),new DataView(f.buffer).setUint32(8,u,!0),new DataView(f.buffer).setUint32(12,d,!0),Array.from(f).map(e=>e.toString(16).padStart(2,`0`)).join(``)}async function dx(e,t){if(e===`md5`)return ux(t);let n=px.get(e);if(!n)throw Error(`Unknown algorithm: ${e}`);let r=await globalThis.crypto.subtle.digest(n,new Uint8Array(t).buffer);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function fx(e,t,n){let r={name:e,summary:n,usage:`${e} [OPTION]... [FILE]...`,options:[`-c, --check read checksums from FILEs and check them`,` --help display this help and exit`]};return{name:e,async execute(n,i){if(N(n))return M(r);let a=!1,o=[];for(let t of n)if(t===`-c`||t===`--check`)a=!0;else if(t!==`-b`&&t!==`-t`&&t!==`--binary`&&t!==`--text`){if(t.startsWith(`-`)&&t!==`-`)return P(e,t);o.push(t)}o.length===0&&o.push(`-`);let s=async e=>{if(e===`-`)return Uint8Array.from(i.stdin,e=>e.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,e))}catch{return null}};if(a){let n=0,r=``;for(let a of o){let o=a===`-`?or(i.stdin):await i.fs.readFile(i.fs.resolvePath(i.cwd,a)).catch(()=>null);if(o===null)return{stdout:``,stderr:`${e}: ${a}: No such file or directory
712
+ `,exitCode:1};for(let e of o.split(`
713
+ `)){let i=e.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!i)continue;let[,a,o]=i,c=await s(o);if(c===null){r+=`${o}: FAILED open or read
714
+ `,n++;continue}let l=await dx(t,c)===a.toLowerCase();r+=`${o}: ${l?`OK`:`FAILED`}
715
+ `,l||n++}}return n>0&&(r+=`${e}: WARNING: ${n} computed checksum${n>1?`s`:``} did NOT match
716
+ `),{stdout:r,stderr:``,exitCode:+(n>0)}}let c=``,l=0;for(let n of o){let r=await s(n);if(r===null){c+=`${e}: ${n}: No such file or directory
717
+ `,l=1;continue}c+=`${await dx(t,r)} ${n}
718
+ `}return{stdout:c,stderr:``,exitCode:l}}}}var px,mx=T(()=>{k(),F(),px=new Map([[`sha1`,`SHA-1`],[`sha256`,`SHA-256`]])}),hx={};E(hx,{flagsForFuzzing:()=>_x,md5sumCommand:()=>gx});var gx,_x,vx=T(()=>{mx(),gx=fx(`md5sum`,`md5`,`compute MD5 message digest`),_x={name:`md5sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),yx={};E(yx,{flagsForFuzzing:()=>xx,sha1sumCommand:()=>bx});var bx,xx,Sx=T(()=>{mx(),bx=fx(`sha1sum`,`sha1`,`compute SHA1 message digest`),xx={name:`sha1sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),Cx={};E(Cx,{flagsForFuzzing:()=>Tx,sha256sumCommand:()=>wx});var wx,Tx,Ex=T(()=>{mx(),wx=fx(`sha256sum`,`sha256`,`compute SHA256 message digest`),Tx={name:`sha256sum`,flags:[{flag:`-c`,type:`boolean`}],needsFiles:!0}}),Dx=pn(e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else{if(a===c)return o?NaN:(p?-1:1)*(1/0);o+=2**r,a-=l}return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}});function Ox(){if(!(typeof globalThis.TextDecoder>`u`))return Bx??=new globalThis.TextDecoder(`utf-8`)}function kx(e,t=`utf-8`){switch(t.toLowerCase()){case`utf-8`:case`utf8`:{let t=Ox();return t?t.decode(e):Nx(e)}case`utf-16le`:return Px(e);case`us-ascii`:case`ascii`:return Fx(e);case`latin1`:case`iso-8859-1`:return Ix(e);case`windows-1252`:return Lx(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function Ax(e,t){t.length!==0&&(e.push(String.fromCharCode.apply(null,t)),t.length=0)}function jx(e,t,n){t.push(n),t.length>=Vx&&Ax(e,t)}function Mx(e,t,n){if(n<=65535){jx(e,t,n);return}n-=65536,jx(e,t,55296+(n>>10)),jx(e,t,56320+(n&1023))}function Nx(e){let t=[],n=[],r=0;for(e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(r=3);r<e.length;){let i=e[r];if(i<=127){jx(t,n,i),r++;continue}if(i<194||i>244){jx(t,n,Hx),r++;continue}if(i<=223){if(r+1>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1];if((a&192)!=128){jx(t,n,Hx),r++;continue}jx(t,n,(i&31)<<6|a&63),r+=2;continue}if(i<=239){if(r+2>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1],o=e[r+2];if(!((a&192)==128&&(o&192)==128&&!(i===224&&a<160)&&!(i===237&&a>=160))){jx(t,n,Hx),r++;continue}jx(t,n,(i&15)<<12|(a&63)<<6|o&63),r+=3;continue}if(r+3>=e.length){jx(t,n,Hx),r++;continue}let a=e[r+1],o=e[r+2],s=e[r+3];if(!((a&192)==128&&(o&192)==128&&(s&192)==128&&!(i===240&&a<144)&&!(i===244&&a>143))){jx(t,n,Hx),r++;continue}Mx(t,n,(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63),r+=4}return Ax(t,n),t.join(``)}function Px(e){let t=[],n=[],r=e.length,i=0;for(;i+1<r;){let a=e[i]|e[i+1]<<8;if(i+=2,a>=55296&&a<=56319){if(i+1<r){let r=e[i]|e[i+1]<<8;r>=56320&&r<=57343?(jx(t,n,a),jx(t,n,r),i+=2):jx(t,n,Hx)}else jx(t,n,Hx);continue}if(a>=56320&&a<=57343){jx(t,n,Hx);continue}jx(t,n,a)}return i<r&&jx(t,n,Hx),Ax(t,n),t.join(``)}function Fx(e){let t=[];for(let n=0;n<e.length;n+=Vx){let r=Math.min(e.length,n+Vx),i=Array(r-n);for(let t=n,a=0;t<r;t++,a++)i[a]=e[t]&127;t.push(String.fromCharCode.apply(null,i))}return t.join(``)}function Ix(e){let t=[];for(let n=0;n<e.length;n+=Vx){let r=Math.min(e.length,n+Vx),i=Array(r-n);for(let t=n,a=0;t<r;t++,a++)i[a]=e[t];t.push(String.fromCharCode.apply(null,i))}return t.join(``)}function Lx(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r],a=i>=128&&i<=159?Rx[i]:void 0;n+=a??String.fromCharCode(i),n.length>=Vx&&(t.push(n),n=``)}return n&&t.push(n),t.join(``)}var Rx,zx,Bx,Vx,Hx,Ux=T(()=>{Rx={128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`},zx={};for(let[e,t]of Object.entries(Rx))zx[t]=Number.parseInt(e,10);Vx=32768,Hx=65533});function Wx(e){return new DataView(e.buffer,e.byteOffset)}var Gx,Kx,qx,Jx,Yx,Xx,Zx,Qx,$x=T(()=>{hn(Dx(),1),Ux(),Gx={len:1,get(e,t){return Wx(e).getUint8(t)},put(e,t,n){return Wx(e).setUint8(t,n),t+1}},Kx={len:2,get(e,t){return Wx(e).getUint16(t,!0)},put(e,t,n){return Wx(e).setUint16(t,n,!0),t+2}},qx={len:2,get(e,t){return Wx(e).getUint16(t)},put(e,t,n){return Wx(e).setUint16(t,n),t+2}},Jx={len:4,get(e,t){return Wx(e).getUint32(t,!0)},put(e,t,n){return Wx(e).setUint32(t,n,!0),t+4}},Yx={len:4,get(e,t){return Wx(e).getUint32(t)},put(e,t,n){return Wx(e).setUint32(t,n),t+4}},Xx={len:4,get(e,t){return Wx(e).getInt32(t)},put(e,t,n){return Wx(e).setInt32(t,n),t+4}},Zx={len:8,get(e,t){return Wx(e).getBigUint64(t,!0)},put(e,t,n){return Wx(e).setBigUint64(t,n,!0),t+8}},Qx=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){return kx(e.subarray(t,t+this.len),this.encoding)}}}),eS,tS,nS,rS=T(()=>{eS=`End-Of-Stream`,tS=class extends Error{constructor(){super(eS),this.name=`EndOfStreamError`}},nS=class extends Error{constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}}}),iS=T(()=>{}),aS,oS=T(()=>{rS(),aS=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new tS;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let r=this.peekQueue.pop();if(!r)throw Error(`peekData should be defined`);let i=Math.min(r.length,t);e.set(r.subarray(0,i),n),n+=i,t-=i,i<r.length&&this.peekQueue.push(r.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new nS;let r=await this.readFromStream(e.subarray(n),t);if(r===0)break;n+=r}if(!t&&n<e.length)throw new tS;return n}}}),sS=T(()=>{rS(),iS(),oS()}),cS,lS=T(()=>{oS(),cS=class extends aS{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}}),uS,dS=T(()=>{lS(),uS=class extends cS{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}}}),fS,pS=T(()=>{rS(),oS(),fS=class extends aS{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),this.buffer=n<t.length?t.subarray(n):null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(n+=this.writeChunk(e.subarray(n),t.value))}if(!t&&n===0&&this.endOfStream)throw new tS;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function mS(e){try{let t=e.getReader({mode:`byob`});return t instanceof ReadableStreamDefaultReader?new fS(t):new uS(t)}catch(t){if(t instanceof TypeError)return new fS(e.getReader());throw t}}var hS=T(()=>{dS(),pS()}),gS=T(()=>{rS(),sS(),dS(),pS(),hS()}),_S,vS=T(()=>{gS(),_S=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener(`abort`,()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})<e.len)throw new tS;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:t})<e.len)throw new tS;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new tS;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new tS;return e.get(this.numBuffer,0)}async ignore(e){if(e<0)throw RangeError(`ignore length must be ≥ 0 bytes`);if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}}}),yS,bS,xS=T(()=>{vS(),gS(),yS=256e3,bS=class extends _S{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new tS;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=0;if(n.position){let t=n.position-this.position;if(t>0){let i=new Uint8Array(n.length+t);return r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),e.set(i.subarray(t)),r-t}if(t<0)throw Error(`Cannot peek from a negative offset in a stream`)}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof tS)return 0;throw e}if(!n.mayBeLess&&r<n.length)throw new tS}return r}async ignore(e){if(e<0)throw RangeError(`ignore length must be ≥ 0 bytes`);let t=Math.min(yS,e),n=new Uint8Array(t),r=0;for(;r<e;){let i=e-r,a=await this.readBuffer(n,{length:Math.min(t,i)});if(a<0)return a;r+=a}return r}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}}),SS,CS=T(()=>{gS(),vS(),SS=class extends _S{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new tS;return e.set(this.uint8Array.subarray(n.position,n.position+r)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}}),wS,TS=T(()=>{gS(),vS(),wS=class extends _S{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new tS;let i=await this.blob.slice(n.position,n.position+r).arrayBuffer();return e.set(new Uint8Array(i)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});function ES(e,t){let n=mS(e),r=t??{},i=r.onClose;return r.onClose=async()=>{if(await n.close(),i)return i()},new bS(n,r)}function DS(e,t){return new SS(e,t)}function OS(e,t){return new wS(e,t)}var kS=T(()=>{gS(),xS(),CS(),TS(),gS(),vS()}),AS=pn((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}),jS=pn((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=AS(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(typeof t>`u`?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n}),MS=pn((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t={}.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=jS()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}}),NS,PS,FS,IS,LS,RS=T(()=>{$x(),NS={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},PS={get(e){return{signature:Jx.get(e,0),compressedSize:Jx.get(e,8),uncompressedSize:Jx.get(e,12)}},len:16},FS={get(e){let t=Kx.get(e,6);return{signature:Jx.get(e,0),minVersion:Kx.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Kx.get(e,8),compressedSize:Jx.get(e,18),uncompressedSize:Jx.get(e,22),filenameLength:Kx.get(e,26),extraFieldLength:Kx.get(e,28),filename:null}},len:30},IS={get(e){return{signature:Jx.get(e,0),nrOfThisDisk:Kx.get(e,4),nrOfThisDiskWithTheStart:Kx.get(e,6),nrOfEntriesOnThisDisk:Kx.get(e,8),nrOfEntriesOfSize:Kx.get(e,10),sizeOfCd:Jx.get(e,12),offsetOfStartOfCd:Jx.get(e,16),zipFileCommentLength:Kx.get(e,20)}},len:22},LS={get(e){let t=Kx.get(e,8);return{signature:Jx.get(e,0),minVersion:Kx.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Kx.get(e,10),compressedSize:Jx.get(e,20),uncompressedSize:Jx.get(e,24),filenameLength:Kx.get(e,28),extraFieldLength:Kx.get(e,30),fileCommentLength:Kx.get(e,32),relativeOffsetOfLocalHeader:Jx.get(e,42),filename:null}},len:46}});function zS(e){let t=new Uint8Array(Jx.len);return Jx.put(t,0,e),t}function BS(e,t){let n=e.length,r=t.length;if(r>n)return-1;for(let i=0;i<=n-r;i++){let n=!0;for(let a=0;a<r;a++)if(e[i+a]!==t[a]){n=!1;break}if(n)return i}return-1}function VS(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var HS,US,WS,GS,KS,qS,JS=T(()=>{$x(),HS=hn(MS(),1),RS(),US=(0,HS.default)(`tokenizer:inflate`),WS=262144,GS=zS(NS.DataDescriptor),KS=zS(NS.EndOfCentralDirectory),qS=class e{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(WS)}async isZip(){return await this.peekSignature()===NS.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Jx)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16384,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let r=n.length-4;r>=0;r--)if(n[r]===KS[0]&&n[r+1]===KS[1]&&n[r+2]===KS[2]&&n[r+3]===KS[3])return e.fileInfo.size-t+r;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){US(`Cannot reading central-directory without random-read support`);return}US(`Reading central-directory...`);let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){US(`Central-directory 32-bit signature found`);let n=await this.tokenizer.readToken(IS,t),r=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let e=0;e<n.nrOfEntriesOfSize;++e){let t=await this.tokenizer.readToken(LS);if(t.signature!==NS.CentralFileHeader)throw Error(`Expected Central-File-Header signature`);t.filename=await this.tokenizer.readToken(new Qx(t.filenameLength,`utf-8`)),await this.tokenizer.ignore(t.extraFieldLength),await this.tokenizer.ignore(t.fileCommentLength),r.push(t),US(`Add central-directory file-entry: n=${e+1}/${r.length}: filename=${r[e].filename}`)}return this.tokenizer.setPosition(e),r}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let n=!1;do{let t=await this.readLocalFileHeader();if(!t)break;let r=e(t);n=!!r.stop;let i;if(await this.tokenizer.ignore(t.extraFieldLength),t.dataDescriptor&&t.compressedSize===0){let e=[],n=WS;US(`Compressed-file-size unknown, scanning for next data-descriptor-signature....`);let i=-1;for(;i<0&&n===WS;){n=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),i=BS(this.syncBuffer.subarray(0,n),GS);let t=i>=0?i:n;if(r.handler){let n=new Uint8Array(t);await this.tokenizer.readBuffer(n),e.push(n)}else await this.tokenizer.ignore(t)}US(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),r.handler&&await this.inflate(t,VS(e),r.handler)}else r.handler?(US(`Reading compressed-file-data: ${t.compressedSize} bytes`),i=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(t,i,r.handler)):(US(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(US(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor&&(await this.tokenizer.readToken(PS)).signature!==134695760)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-PS.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let e=t(n);if(e.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);let r=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(r),await this.inflate(t,r,e.handler)}}if(e.stop)break}}async inflate(t,n,r){if(t.compressedMethod===0)return r(n);if(t.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);return US(`Decompress filename=${t.filename}, compressed-size=${n.length}`),r(await e.decompressDeflateRaw(n))}static async decompressDeflateRaw(e){let t=new ReadableStream({start(t){t.enqueue(e),t.close()}}),n=new DecompressionStream(`deflate-raw`),r=t.pipeThrough(n);try{let e=await new Response(r).arrayBuffer();return new Uint8Array(e)}catch(e){let t=e instanceof Error?`Failed to deflate ZIP entry: ${e.message}`:`Unknown decompression error in ZIP entry`;throw TypeError(t)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(Jx);if(e===NS.LocalFileHeader){let e=await this.tokenizer.readToken(FS);return e.filename=await this.tokenizer.readToken(new Qx(e.filenameLength,`utf-8`)),e}if(e===NS.CentralFileHeader)return!1;throw Error(e===3759263696?`Encrypted ZIP`:`Unexpected signature`)}}}),YS,XS=T(()=>{YS=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),r=await e.readBuffer(n,{mayBeLess:!0});if(r===0){t.close();return}t.enqueue(n.subarray(0,r))}}).pipeThrough(new DecompressionStream(`gzip`))}}}),ZS=T(()=>{JS(),XS()});function QS(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}var $S=T(()=>{new globalThis.TextDecoder(`utf8`),new globalThis.TextEncoder,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`))});function eC(e,t){if(t===`utf-16le`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r&255,r>>8&255)}return t}if(t===`utf-16be`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r>>8&255,r&255)}return t}return[...e].map(e=>e.charCodeAt(0))}function tC(e,t=0){let n=Number.parseInt(new Qx(6).get(e,148).replace(/\0.*$/,``).trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let n=t;n<t+148;n++)r+=e[n];for(let n=t+156;n<t+512;n++)r+=e[n];return n===r}var nC,rC=T(()=>{$x(),nC={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}}),iC,aC,oC=T(()=>{iC=`jpg,png,apng,gif,webp,flif,xcf,cr2,cr3,orf,arw,dng,nef,rw2,raf,tif,bmp,icns,jxr,psd,indd,zip,tar,rar,gz,bz2,7z,dmg,mp4,mid,mkv,webm,mov,avi,mpg,mp2,mp3,m4a,oga,ogg,ogv,opus,flac,wav,spx,amr,pdf,epub,elf,macho,exe,swf,rtf,wasm,woff,woff2,eot,ttf,otf,ttc,ico,flv,ps,xz,sqlite,nes,crx,xpi,cab,deb,ar,rpm,Z,lz,cfb,mxf,mts,blend,bpg,docx,pptx,xlsx,3gp,3g2,j2c,jp2,jpm,jpx,mj2,aif,qcp,odt,ods,odp,xml,mobi,heic,cur,ktx,ape,wv,dcm,ics,glb,pcap,dsf,lnk,alias,voc,ac3,m4v,m4p,m4b,f4v,f4p,f4b,f4a,mie,asf,ogm,ogx,mpc,arrow,shp,aac,mp1,it,s3m,xm,skp,avif,eps,lzh,pgp,asar,stl,chm,3mf,zst,jxl,vcf,jls,pst,dwg,parquet,class,arj,cpio,ace,avro,icc,fbx,vsdx,vtt,apk,drc,lz4,potx,xltx,dotx,xltm,ott,ots,otp,odg,otg,xlsm,docm,dotm,potm,pptm,jar,jmp,rm,sav,ppsm,ppsx,tar.gz,reg,dat`.split(`,`),aC=`image/jpeg,image/png,image/gif,image/webp,image/flif,image/x-xcf,image/x-canon-cr2,image/x-canon-cr3,image/tiff,image/bmp,image/vnd.ms-photo,image/vnd.adobe.photoshop,application/x-indesign,application/epub+zip,application/x-xpinstall,application/vnd.ms-powerpoint.slideshow.macroenabled.12,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/zip,application/x-tar,application/x-rar-compressed,application/gzip,application/x-bzip2,application/x-7z-compressed,application/x-apple-diskimage,application/vnd.apache.arrow.file,video/mp4,audio/midi,video/matroska,video/webm,video/quicktime,video/vnd.avi,audio/wav,audio/qcelp,audio/x-ms-asf,video/x-ms-asf,application/vnd.ms-asf,video/mpeg,video/3gpp,audio/mpeg,audio/mp4,video/ogg,audio/ogg,audio/ogg; codecs=opus,application/ogg,audio/flac,audio/ape,audio/wavpack,audio/amr,application/pdf,application/x-elf,application/x-mach-binary,application/x-msdownload,application/x-shockwave-flash,application/rtf,application/wasm,font/woff,font/woff2,application/vnd.ms-fontobject,font/ttf,font/otf,font/collection,image/x-icon,video/x-flv,application/postscript,application/eps,application/x-xz,application/x-sqlite3,application/x-nintendo-nes-rom,application/x-google-chrome-extension,application/vnd.ms-cab-compressed,application/x-deb,application/x-unix-archive,application/x-rpm,application/x-compress,application/x-lzip,application/x-cfb,application/x-mie,application/mxf,video/mp2t,application/x-blender,image/bpg,image/j2c,image/jp2,image/jpx,image/jpm,image/mj2,audio/aiff,application/xml,application/x-mobipocket-ebook,image/heif,image/heif-sequence,image/heic,image/heic-sequence,image/icns,image/ktx,application/dicom,audio/x-musepack,text/calendar,text/vcard,text/vtt,model/gltf-binary,application/vnd.tcpdump.pcap,audio/x-dsf,application/x.ms.shortcut,application/x.apple.alias,audio/x-voc,audio/vnd.dolby.dd-raw,audio/x-m4a,image/apng,image/x-olympus-orf,image/x-sony-arw,image/x-adobe-dng,image/x-nikon-nef,image/x-panasonic-rw2,image/x-fujifilm-raf,video/x-m4v,video/3gpp2,application/x-esri-shape,audio/aac,audio/x-it,audio/x-s3m,audio/x-xm,video/MP1S,video/MP2P,application/vnd.sketchup.skp,image/avif,application/x-lzh-compressed,application/pgp-encrypted,application/x-asar,model/stl,application/vnd.ms-htmlhelp,model/3mf,image/jxl,application/zstd,image/jls,application/vnd.ms-outlook,image/vnd.dwg,application/vnd.apache.parquet,application/java-vm,application/x-arj,application/x-cpio,application/x-ace-compressed,application/avro,application/vnd.iccprofile,application/x.autodesk.fbx,application/vnd.visio,application/vnd.android.package-archive,application/vnd.google.draco,application/x-lz4,application/vnd.openxmlformats-officedocument.presentationml.template,application/vnd.openxmlformats-officedocument.spreadsheetml.template,application/vnd.openxmlformats-officedocument.wordprocessingml.template,application/vnd.ms-excel.template.macroenabled.12,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.spreadsheet-template,application/vnd.oasis.opendocument.presentation-template,application/vnd.oasis.opendocument.graphics,application/vnd.oasis.opendocument.graphics-template,application/vnd.ms-excel.sheet.macroenabled.12,application/vnd.ms-word.document.macroenabled.12,application/vnd.ms-word.template.macroenabled.12,application/vnd.ms-powerpoint.template.macroenabled.12,application/vnd.ms-powerpoint.presentation.macroenabled.12,application/java-archive,application/vnd.rn-realmedia,application/x-spss-sav,application/x-ms-regedit,application/x-ft-windows-registry-hive,application/x-jmp-data`.split(`,`)});function sC(e){let t=e?.streamReader;if(t?.constructor?.name!==`WebStreamByobReader`)return e;let{reader:n}=t,r=async()=>{await n.cancel(),n.releaseLock()};return t.close=r,t.abort=async()=>{t.interrupted=!0,await r()},e}function cC(e,t,n){if(!Number.isFinite(e)||e<0||e>t)throw new cw(`${n} has invalid size ${e} (maximum ${t} bytes)`);return e}async function lC(e,t,{maximumLength:n=BC,reason:r=`skip`}={}){let i=cC(t,n,r);await e.ignore(i)}async function uC(e,t,n,{maximumLength:r=t.length,reason:i=`read`}={}){let a=cC(n?.length??t.length,r,i);return e.readBuffer(t,{...n,length:a})}async function dC(e,{maximumLength:t=LC}={}){let n=new ReadableStream({start(t){t.enqueue(e),t.close()}}).pipeThrough(new DecompressionStream(`deflate-raw`)).getReader(),r=[],i=0;try{for(;;){let{done:e,value:a}=await n.read();if(e)break;if(i+=a.length,i>t)throw await n.cancel(),Error(`ZIP entry decompressed data exceeds ${t} bytes`);r.push(a)}}finally{n.releaseLock()}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}function fC(e,t){if(e.length<uw)return-1;let n=e.length-uw;for(let r=0;r<=n;r++)if(Jx.get(e,r)===lw&&Jx.get(e,r+8)===t+r)return r;return-1}function pC(e){return!!(e.codePointAt(0)&32)}function mC(e,t){let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}async function hC(e,{shouldBuffer:t,maximumLength:n=LC}={}){let{syncBuffer:r}=e,{length:i}=r,a=[],o=0;for(;;){let s=await e.tokenizer.peekBuffer(r,{mayBeLess:!0}),c=fC(r.subarray(0,s),o),l=c>=0?0:s===i?Math.min(dw,s-1):0,u=c>=0?c:s-l;if(u===0)break;if(o+=u,o>n)throw Error(`ZIP entry compressed data exceeds ${n} bytes`);if(t){let t=new Uint8Array(u);await e.tokenizer.readBuffer(t),a.push(t)}else await e.tokenizer.ignore(u);if(c>=0)break}if(EC(e.tokenizer)||(e.knownSizeDescriptorScannedBytes+=o),t)return mC(a,o)}function gC(e,t){return EC(e.tokenizer)?Math.max(0,BC-(e.tokenizer.position-t)):Math.max(0,LC-e.knownSizeDescriptorScannedBytes)}async function _C(e,t,{shouldBuffer:n,maximumDescriptorLength:r=LC}={}){if(t.dataDescriptor&&t.compressedSize===0)return hC(e,{shouldBuffer:n,maximumLength:r});if(!n){await lC(e.tokenizer,t.compressedSize,{maximumLength:EC(e.tokenizer)?LC:e.tokenizer.fileInfo.size,reason:`ZIP entry compressed data`});return}let i=OC(e.tokenizer);if(!Number.isFinite(t.compressedSize)||t.compressedSize<0||t.compressedSize>i)throw Error(`ZIP entry compressed data exceeds ${i} bytes`);let a=new Uint8Array(t.compressedSize);return await e.tokenizer.readBuffer(a),a}function vC(e,t){let n=e.getReader(),r=0,i=!1,a=!1,o=async e=>{i||a||(a=!0,await n.cancel(e))};return new ReadableStream({async pull(e){if(r>=t){e.close(),await o();return}let{done:a,value:s}=await n.read();if(a||!s){i=!0,e.close();return}let c=t-r;if(s.length>c){e.enqueue(s.subarray(0,c)),r+=c,e.close(),await o();return}e.enqueue(s),r+=s.length},async cancel(e){await o(e)}})}async function yC(e,t){return new fw(t).fromBuffer(e)}function bC(e){switch(e=e.toLowerCase(),e){case`application/epub+zip`:return{ext:`epub`,mime:e};case`application/vnd.oasis.opendocument.text`:return{ext:`odt`,mime:e};case`application/vnd.oasis.opendocument.text-template`:return{ext:`ott`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet`:return{ext:`ods`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet-template`:return{ext:`ots`,mime:e};case`application/vnd.oasis.opendocument.presentation`:return{ext:`odp`,mime:e};case`application/vnd.oasis.opendocument.presentation-template`:return{ext:`otp`,mime:e};case`application/vnd.oasis.opendocument.graphics`:return{ext:`odg`,mime:e};case`application/vnd.oasis.opendocument.graphics-template`:return{ext:`otg`,mime:e};case`application/vnd.openxmlformats-officedocument.presentationml.slideshow`:return{ext:`ppsx`,mime:e};case`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`:return{ext:`xlsx`,mime:e};case`application/vnd.ms-excel.sheet.macroenabled`:return{ext:`xlsm`,mime:`application/vnd.ms-excel.sheet.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.spreadsheetml.template`:return{ext:`xltx`,mime:e};case`application/vnd.ms-excel.template.macroenabled`:return{ext:`xltm`,mime:`application/vnd.ms-excel.template.macroenabled.12`};case`application/vnd.ms-powerpoint.slideshow.macroenabled`:return{ext:`ppsm`,mime:`application/vnd.ms-powerpoint.slideshow.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.document`:return{ext:`docx`,mime:e};case`application/vnd.ms-word.document.macroenabled`:return{ext:`docm`,mime:`application/vnd.ms-word.document.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.template`:return{ext:`dotx`,mime:e};case`application/vnd.ms-word.template.macroenabledtemplate`:return{ext:`dotm`,mime:`application/vnd.ms-word.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.template`:return{ext:`potx`,mime:e};case`application/vnd.ms-powerpoint.template.macroenabled`:return{ext:`potm`,mime:`application/vnd.ms-powerpoint.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.presentation`:return{ext:`pptx`,mime:e};case`application/vnd.ms-powerpoint.presentation.macroenabled`:return{ext:`pptm`,mime:`application/vnd.ms-powerpoint.presentation.macroenabled.12`};case`application/vnd.ms-visio.drawing`:return{ext:`vsdx`,mime:`application/vnd.visio`};case`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`:return{ext:`3mf`,mime:`model/3mf`}}}function xC(e,t,n){n={offset:0,...n};for(let[r,i]of t.entries())if(n.mask){if(i!==(n.mask[r]&e[r+n.offset]))return!1}else if(i!==e[r+n.offset])return!1;return!0}function SC(e){return Number.isFinite(e)?Math.max(1,Math.trunc(e)):FC}function CC(e,t,n){return n===void 0?e.read(t):(n.throwIfAborted(),new Promise((r,i)=>{let a=()=>{n.removeEventListener(`abort`,o)},o=()=>{let t=n.reason;a(),(async()=>{try{await e.cancel(t)}catch{}})(),i(t)};n.addEventListener(`abort`,o,{once:!0}),(async()=>{try{let n=await e.read(t);a(),r(n)}catch(e){a(),i(e)}})()}))}function wC(e){return Number.isFinite(e)?Math.max(0,Math.min(IC,Math.trunc(e))):0}function TC(e){return Number.isFinite(e)?Math.max(0,e):2**53-1}function EC(e){let t=e.fileInfo.size;return!Number.isFinite(t)||t===2**53-1}function DC(e,t,n){return EC(e)&&e.position-t>n}function OC(e){let t=e.fileInfo.size,n=Number.isFinite(t)?Math.max(0,t-e.position):2**53-1;return Math.min(n,zC)}function kC(e){if(e instanceof tS||e instanceof cw)return!0;if(!(e instanceof Error))return!1;if(aw.has(e.message)||sw.has(e.code))return!0;for(let t of ow)if(e.message.startsWith(t))return!0;return!1}function AC(e,t=LC){let n=[e.compressedSize,e.uncompressedSize];for(let e of n)if(!Number.isFinite(e)||e<0||e>t)return!1;return!0}function jC(){return{hasContentTypesEntry:!1,hasParsedContentTypesEntry:!1,isParsingContentTypes:!1,hasUnparseableContentTypes:!1,hasWordDirectory:!1,hasPresentationDirectory:!1,hasSpreadsheetDirectory:!1,hasThreeDimensionalModelEntry:!1}}function MC(e,t){t.startsWith(`word/`)&&(e.hasWordDirectory=!0),t.startsWith(`ppt/`)&&(e.hasPresentationDirectory=!0),t.startsWith(`xl/`)&&(e.hasSpreadsheetDirectory=!0),t.startsWith(`3D/`)&&t.endsWith(`.model`)&&(e.hasThreeDimensionalModelEntry=!0)}function NC(e){if(!(!e.hasContentTypesEntry||e.hasUnparseableContentTypes||e.isParsingContentTypes||e.hasParsedContentTypesEntry)){if(e.hasWordDirectory)return{ext:`docx`,mime:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`};if(e.hasPresentationDirectory)return{ext:`pptx`,mime:`application/vnd.openxmlformats-officedocument.presentationml.presentation`};if(e.hasSpreadsheetDirectory)return{ext:`xlsx`,mime:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`};if(e.hasThreeDimensionalModelEntry)return{ext:`3mf`,mime:`model/3mf`}}}function PC(e){let t=e.indexOf(`.main+xml"`);if(t===-1){let t=`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`;return e.includes(`ContentType="${t}"`)?t:void 0}let n=e.slice(0,t),r=n.lastIndexOf(`"`);return n.slice(r+1)}var FC,IC,LC,RC,zC,BC,VC,HC,UC,WC,GC,KC,qC,JC,YC,XC,ZC,QC,$C,ew,tw,nw,rw,iw,aw,ow,sw,cw,lw,uw,dw,fw,pw=T(()=>{$x(),kS(),ZS(),$S(),rC(),oC(),FC=4100,IC=FC-2,LC=1048576,RC=1024,zC=2**31-1,BC=16777216,VC=LC,HC=LC,UC=BC,WC=1,GC=100,KC=BC,qC=64,JC=VC,YC=256,XC=512,ZC=BC,QC=512,$C=512,ew=256,tw=VC,nw=VC,rw=VC,iw=BC,aw=new Set([`Unexpected signature`,`Encrypted ZIP`,`Expected Central-File-Header signature`]),ow=[`ZIP entry count exceeds `,`Unsupported ZIP compression method:`,`ZIP entry compressed data exceeds `,`ZIP entry decompressed data exceeds `,`Expected data-descriptor-signature at position `],sw=new Set([`Z_BUF_ERROR`,`Z_DATA_ERROR`,`ERR_INVALID_STATE`]),cw=class extends Error{},lw=134695760,uw=16,dw=uw-1,qS.prototype.inflate=async function(e,t,n){if(e.compressedMethod===0)return n(t);if(e.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);return n(await dC(t,{maximumLength:LC}))},qS.prototype.unzip=async function(e){let t=!1,n=0,r=this.tokenizer.position;this.knownSizeDescriptorScannedBytes=0;do{if(DC(this.tokenizer,r,BC))throw new cw(`ZIP stream probing exceeds ${BC} bytes`);let i=await this.readLocalFileHeader();if(!i)break;if(n++,n>RC)throw Error(`ZIP entry count exceeds ${RC}`);let a=e(i);t=!!a.stop,await this.tokenizer.ignore(i.extraFieldLength);let o=await _C(this,i,{shouldBuffer:!!a.handler,maximumDescriptorLength:Math.min(LC,gC(this,r))});if(a.handler&&await this.inflate(i,o,a.handler),i.dataDescriptor){let e=new Uint8Array(uw);if(await this.tokenizer.readBuffer(e),Jx.get(e,0)!==lw)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-e.length}`)}if(DC(this.tokenizer,r,BC))throw new cw(`ZIP stream probing exceeds ${BC} bytes`)}while(!t)},fw=class e{constructor(e){let t=wC(e?.mpegOffsetTolerance);this.options={...e,mpegOffsetTolerance:t},this.detectors=[...this.options.customDetectors??[],{id:`core`,detect:this.detectConfident},{id:`core.imprecise`,detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:this.options.signal},this.gzipProbeDepth=0}getTokenizerOptions(){return{...this.tokenizerOptions}}createTokenizerFromWebStream(e){return sC(ES(e,this.getTokenizerOptions()))}async parseTokenizer(e,t=0){this.detectionReentryCount=t;let n=e.position;for(let t of this.detectors){let r;try{r=await t.detect(e)}catch(e){if(e instanceof tS||e instanceof cw)return;throw e}if(r)return r;if(n!==e.position)return}}async fromTokenizer(e){try{return await this.parseTokenizer(e)}finally{await e.close()}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(DS(t,this.getTokenizerOptions()))}async fromBlob(e){this.options.signal?.throwIfAborted();let t=OS(e,this.getTokenizerOptions());return this.fromTokenizer(t)}async fromStream(e){this.options.signal?.throwIfAborted();let t=this.createTokenizerFromWebStream(e);return this.fromTokenizer(t)}async toDetectionStream(e,t){let n=SC(t?.sampleSize??FC),r,i,a=e.getReader({mode:`byob`});try{let{value:e,done:t}=await CC(a,new Uint8Array(n),this.options.signal);if(i=e,!t&&e)try{r=await this.fromBuffer(e.subarray(0,n))}catch(e){if(!(e instanceof tS))throw e;r=void 0}i=e}finally{a.releaseLock()}let o=new TransformStream({async start(e){e.enqueue(i)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(o);return s.fileType=r,s}async detectGzip(t){if(this.gzipProbeDepth>=WC)return{ext:`gz`,mime:`application/gzip`};let n=vC(new YS(t).inflate(),UC),r=EC(t),i,a,o,s;if(r){let t=new AbortController;i=setTimeout(()=>{t.abort(new DOMException(`Operation timed out after ${GC} ms`,`TimeoutError`))},GC),a=this.options.signal===void 0?t.signal:AbortSignal.any([this.options.signal,t.signal]),o=new e({...this.options,signal:a}),o.gzipProbeDepth=this.gzipProbeDepth+1}else this.gzipProbeDepth++;try{s=await(o??this).fromStream(n)}catch(e){if(e?.name===`AbortError`&&a?.reason?.name!==`TimeoutError`)throw e}finally{clearTimeout(i),r||this.gzipProbeDepth--}return s?.ext===`tar`?{ext:`tar.gz`,mime:`application/gzip`}:{ext:`gz`,mime:`application/gzip`}}check(e,t){return xC(this.buffer,e,t)}checkString(e,t){return this.check(eC(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(FC),e.fileInfo.size===void 0&&(e.fileInfo.size=2**53-1),this.tokenizer=e,EC(e)&&(await e.peekBuffer(this.buffer,{length:3,mayBeLess:!0}),this.check([31,139,8])))return this.detectGzip(e);if(await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:`bmp`,mime:`image/bmp`};if(this.check([11,119]))return{ext:`ac3`,mime:`audio/vnd.dolby.dd-raw`};if(this.check([120,1]))return{ext:`dmg`,mime:`application/x-apple-diskimage`};if(this.check([77,90]))return{ext:`exe`,mime:`application/x-msdownload`};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString(`PS-Adobe-`,{offset:2})&&this.checkString(` EPSF-`,{offset:14})?{ext:`eps`,mime:`application/eps`}:{ext:`ps`,mime:`application/postscript`};if(this.check([31,160])||this.check([31,157]))return{ext:`Z`,mime:`application/x-compress`};if(this.check([199,113]))return{ext:`cpio`,mime:`application/x-cpio`};if(this.check([96,234]))return{ext:`arj`,mime:`application/x-arj`};if(this.check([239,187,191]))return this.detectionReentryCount>=ew?void 0:(this.detectionReentryCount++,await this.tokenizer.ignore(3),this.detectConfident(e));if(this.check([71,73,70]))return{ext:`gif`,mime:`image/gif`};if(this.check([73,73,188]))return{ext:`jxr`,mime:`image/vnd.ms-photo`};if(this.check([31,139,8]))return this.detectGzip(e);if(this.check([66,90,104]))return{ext:`bz2`,mime:`application/x-bzip2`};if(this.checkString(`ID3`)){await lC(e,6,{maximumLength:6,reason:`ID3 header prefix`});let t=await e.readToken(nC),n=EC(e);if(!Number.isFinite(t)||t<0||n&&(t>KC||e.position+t>KC))return;if(e.position+t>e.fileInfo.size)return n?void 0:{ext:`mp3`,mime:`audio/mpeg`};try{await lC(e,t,{maximumLength:n?KC:e.fileInfo.size,reason:`ID3 payload`})}catch(e){if(e instanceof tS)return;throw e}return this.detectionReentryCount>=ew?void 0:(this.detectionReentryCount++,this.parseTokenizer(e,this.detectionReentryCount))}if(this.checkString(`MP+`))return{ext:`mpc`,mime:`audio/x-musepack`};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:`swf`,mime:`application/x-shockwave-flash`};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:`jls`,mime:`image/jls`}:{ext:`jpg`,mime:`image/jpeg`};if(this.check([79,98,106,1]))return{ext:`avro`,mime:`application/avro`};if(this.checkString(`FLIF`))return{ext:`flif`,mime:`image/flif`};if(this.checkString(`8BPS`))return{ext:`psd`,mime:`image/vnd.adobe.photoshop`};if(this.checkString(`MPCK`))return{ext:`mpc`,mime:`audio/x-musepack`};if(this.checkString(`FORM`))return{ext:`aif`,mime:`audio/aiff`};if(this.checkString(`icns`,{offset:0}))return{ext:`icns`,mime:`image/icns`};if(this.check([80,75,3,4])){let t,n=jC();try{await new qS(e).unzip(e=>{MC(n,e.filename);let r=e.filename===`[Content_Types].xml`,i=NC(n);if(!r&&i)return t=i,{stop:!0};switch(e.filename){case`META-INF/mozilla.rsa`:return t={ext:`xpi`,mime:`application/x-xpinstall`},{stop:!0};case`META-INF/MANIFEST.MF`:return t={ext:`jar`,mime:`application/java-archive`},{stop:!0};case`mimetype`:return AC(e,HC)?{async handler(e){t=bC(new TextDecoder(`utf-8`).decode(e).trim())},stop:!0}:{};case`[Content_Types].xml`:return n.hasContentTypesEntry=!0,AC(e,HC)?(n.isParsingContentTypes=!0,{async handler(e){let r=PC(new TextDecoder(`utf-8`).decode(e));r&&(t=bC(r)),n.hasParsedContentTypesEntry=!0,n.isParsingContentTypes=!1},stop:!0}):(n.hasUnparseableContentTypes=!0,{});default:return/classes\d*\.dex/.test(e.filename)?(t={ext:`apk`,mime:`application/vnd.android.package-archive`},{stop:!0}):{}}})}catch(e){if(!kC(e))throw e;n.isParsingContentTypes&&(n.isParsingContentTypes=!1,n.hasUnparseableContentTypes=!0)}return t??NC(n)??{ext:`zip`,mime:`application/zip`}}if(this.checkString(`OggS`)){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),xC(t,[79,112,117,115,72,101,97,100])?{ext:`opus`,mime:`audio/ogg; codecs=opus`}:xC(t,[128,116,104,101,111,114,97])?{ext:`ogv`,mime:`video/ogg`}:xC(t,[1,118,105,100,101,111,0])?{ext:`ogm`,mime:`video/ogg`}:xC(t,[127,70,76,65,67])?{ext:`oga`,mime:`audio/ogg`}:xC(t,[83,112,101,101,120,32,32])?{ext:`spx`,mime:`audio/ogg`}:xC(t,[1,118,111,114,98,105,115])?{ext:`ogg`,mime:`audio/ogg`}:{ext:`ogx`,mime:`application/ogg`}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:`zip`,mime:`application/zip`};if(this.checkString(`MThd`))return{ext:`mid`,mime:`audio/midi`};if(this.checkString(`wOFF`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff`,mime:`font/woff`};if(this.checkString(`wOF2`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff2`,mime:`font/woff2`};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:`pcap`,mime:`application/vnd.tcpdump.pcap`};if(this.checkString(`DSD `))return{ext:`dsf`,mime:`audio/x-dsf`};if(this.checkString(`LZIP`))return{ext:`lz`,mime:`application/x-lzip`};if(this.checkString(`fLaC`))return{ext:`flac`,mime:`audio/flac`};if(this.check([66,80,71,251]))return{ext:`bpg`,mime:`image/bpg`};if(this.checkString(`wvpk`))return{ext:`wv`,mime:`audio/wavpack`};if(this.checkString(`%PDF`))return{ext:`pdf`,mime:`application/pdf`};if(this.check([0,97,115,109]))return{ext:`wasm`,mime:`application/wasm`};if(this.check([73,73])){let e=await this.readTiffHeader(!1);if(e)return e}if(this.check([77,77])){let e=await this.readTiffHeader(!0);if(e)return e}if(this.checkString(`MAC `))return{ext:`ape`,mime:`audio/ape`};if(this.check([26,69,223,163])){async function t(){let t=await e.peekNumber(Gx),n=128,r=0;for(;(t&n)===0&&n!==0;)++r,n>>=1;let i=new Uint8Array(r+1);return await uC(e,i,void 0,{maximumLength:i.length,reason:`EBML field`}),i}async function n(){let e=await t(),n=await t();n[0]^=128>>n.length-1;let r=Math.min(6,n.length),i=new DataView(e.buffer),a=new DataView(n.buffer,n.length-r,r);return{id:QS(i),len:QS(a)}}async function r(t){let r=0;for(;t>0;){if(r++,r>YC||DC(e,a,BC))return;let i=e.position,o=await n();if(o.id===17026){if(o.len>qC)return;let t=cC(o.len,qC,`EBML DocType`);return(await e.readToken(new Qx(t))).replaceAll(/\00.*$/g,``)}if(EC(e)&&(!Number.isFinite(o.len)||o.len<0||o.len>JC)||(await lC(e,o.len,{maximumLength:EC(e)?JC:e.fileInfo.size,reason:`EBML payload`}),--t,e.position<=i))return}}let i=await n(),a=e.position;switch(await r(i.len)){case`webm`:return{ext:`webm`,mime:`video/webm`};case`matroska`:return{ext:`mkv`,mime:`video/matroska`};default:return}}if(this.checkString(`SQLi`))return{ext:`sqlite`,mime:`application/x-sqlite3`};if(this.check([78,69,83,26]))return{ext:`nes`,mime:`application/x-nintendo-nes-rom`};if(this.checkString(`Cr24`))return{ext:`crx`,mime:`application/x-google-chrome-extension`};if(this.checkString(`MSCF`)||this.checkString(`ISc(`))return{ext:`cab`,mime:`application/vnd.ms-cab-compressed`};if(this.check([237,171,238,219]))return{ext:`rpm`,mime:`application/x-rpm`};if(this.check([197,208,211,198]))return{ext:`eps`,mime:`application/eps`};if(this.check([40,181,47,253]))return{ext:`zst`,mime:`application/zstd`};if(this.check([127,69,76,70]))return{ext:`elf`,mime:`application/x-elf`};if(this.check([33,66,68,78]))return{ext:`pst`,mime:`application/vnd.ms-outlook`};if(this.checkString(`PAR1`)||this.checkString(`PARE`))return{ext:`parquet`,mime:`application/vnd.apache.parquet`};if(this.checkString(`ttcf`))return{ext:`ttc`,mime:`font/collection`};if(this.check([254,237,250,206])||this.check([254,237,250,207])||this.check([206,250,237,254])||this.check([207,250,237,254]))return{ext:`macho`,mime:`application/x-mach-binary`};if(this.check([4,34,77,24]))return{ext:`lz4`,mime:`application/x-lz4`};if(this.checkString(`regf`))return{ext:`dat`,mime:`application/x-ft-windows-registry-hive`};if(this.checkString(`$FL2`)||this.checkString(`$FL3`))return{ext:`sav`,mime:`application/x-spss-sav`};if(this.check([79,84,84,79,0]))return{ext:`otf`,mime:`font/otf`};if(this.checkString(`#!AMR`))return{ext:`amr`,mime:`audio/amr`};if(this.checkString(`{\\rtf`))return{ext:`rtf`,mime:`application/rtf`};if(this.check([70,76,86,1]))return{ext:`flv`,mime:`video/x-flv`};if(this.checkString(`IMPM`))return{ext:`it`,mime:`audio/x-it`};if(this.checkString(`-lh0-`,{offset:2})||this.checkString(`-lh1-`,{offset:2})||this.checkString(`-lh2-`,{offset:2})||this.checkString(`-lh3-`,{offset:2})||this.checkString(`-lh4-`,{offset:2})||this.checkString(`-lh5-`,{offset:2})||this.checkString(`-lh6-`,{offset:2})||this.checkString(`-lh7-`,{offset:2})||this.checkString(`-lzs-`,{offset:2})||this.checkString(`-lz4-`,{offset:2})||this.checkString(`-lz5-`,{offset:2})||this.checkString(`-lhd-`,{offset:2}))return{ext:`lzh`,mime:`application/x-lzh-compressed`};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:`mpg`,mime:`video/MP1S`};if(this.check([68],{offset:4,mask:[196]}))return{ext:`mpg`,mime:`video/MP2P`}}if(this.checkString(`ITSF`))return{ext:`chm`,mime:`application/vnd.ms-htmlhelp`};if(this.check([202,254,186,190])){let e=Yx.get(this.buffer,4),t=qx.get(this.buffer,6);if(e>0&&e<=30)return{ext:`macho`,mime:`application/x-mach-binary`};if(t>30)return{ext:`class`,mime:`application/java-vm`}}if(this.checkString(`.RMF`))return{ext:`rm`,mime:`application/vnd.rn-realmedia`};if(this.checkString(`DRACO`))return{ext:`drc`,mime:`application/vnd.google.draco`};if(this.check([253,55,122,88,90,0]))return{ext:`xz`,mime:`application/x-xz`};if(this.checkString(`<?xml `))return{ext:`xml`,mime:`application/xml`};if(this.check([55,122,188,175,39,28]))return{ext:`7z`,mime:`application/x-7z-compressed`};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:`rar`,mime:`application/x-rar-compressed`};if(this.checkString(`solid `))return{ext:`stl`,mime:`model/stl`};if(this.checkString(`AC`)){let e=new Qx(4,`latin1`).get(this.buffer,2);if(e.match(`^d*`)&&e>=1e3&&e<=1050)return{ext:`dwg`,mime:`image/vnd.dwg`}}if(this.checkString(`070707`))return{ext:`cpio`,mime:`application/x-cpio`};if(this.checkString(`BLENDER`))return{ext:`blend`,mime:`application/x-blender`};if(this.checkString(`!<arch>`))return await e.ignore(8),await e.readToken(new Qx(13,`ascii`))===`debian-binary`?{ext:`deb`,mime:`application/x-deb`}:{ext:`ar`,mime:`application/x-unix-archive`};if(this.checkString(`WEBVTT`)&&[`
719
+ `,`\r`,` `,` `,`\0`].some(e=>this.checkString(e,{offset:6})))return{ext:`vtt`,mime:`text/vtt`};if(this.check([137,80,78,71,13,10,26,10])){let t={ext:`png`,mime:`image/png`},n={ext:`apng`,mime:`image/apng`};await e.ignore(8);async function r(){return{length:await e.readToken(Xx),type:await e.readToken(new Qx(4,`latin1`))}}let i=EC(e),a=e.position,o=0,s=!1;do{if(o++,o>XC||DC(e,a,ZC))break;let c=e.position,l=await r();if(l.length<0)return;if(l.type===`IHDR`){if(l.length!==13)return;s=!0}switch(l.type){case`IDAT`:return t;case`acTL`:return n;default:if(!s&&l.type!==`CgBI`)return;if(i&&l.length>tw)return s&&pC(l.type)?t:void 0;try{await lC(e,l.length+4,{maximumLength:i?tw+4:e.fileInfo.size,reason:`PNG chunk payload`})}catch(e){if(!i&&(e instanceof cw||e instanceof tS))return t;throw e}}if(e.position<=c)break}while(e.position+8<e.fileInfo.size);return t}if(this.check([65,82,82,79,87,49,0,0]))return{ext:`arrow`,mime:`application/vnd.apache.arrow.file`};if(this.check([103,108,84,70,2,0,0,0]))return{ext:`glb`,mime:`model/gltf-binary`};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:`mov`,mime:`video/quicktime`};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:`orf`,mime:`image/x-olympus-orf`};if(this.checkString(`gimp xcf `))return{ext:`xcf`,mime:`image/x-xcf`};if(this.checkString(`ftyp`,{offset:4})&&this.buffer[8]&96){let e=new Qx(4,`latin1`).get(this.buffer,8).replace(`\0`,` `).trim();switch(e){case`avif`:case`avis`:return{ext:`avif`,mime:`image/avif`};case`mif1`:return{ext:`heic`,mime:`image/heif`};case`msf1`:return{ext:`heic`,mime:`image/heif-sequence`};case`heic`:case`heix`:return{ext:`heic`,mime:`image/heic`};case`hevc`:case`hevx`:return{ext:`heic`,mime:`image/heic-sequence`};case`qt`:return{ext:`mov`,mime:`video/quicktime`};case`M4V`:case`M4VH`:case`M4VP`:return{ext:`m4v`,mime:`video/x-m4v`};case`M4P`:return{ext:`m4p`,mime:`video/mp4`};case`M4B`:return{ext:`m4b`,mime:`audio/mp4`};case`M4A`:return{ext:`m4a`,mime:`audio/x-m4a`};case`F4V`:return{ext:`f4v`,mime:`video/mp4`};case`F4P`:return{ext:`f4p`,mime:`video/mp4`};case`F4A`:return{ext:`f4a`,mime:`audio/mp4`};case`F4B`:return{ext:`f4b`,mime:`audio/mp4`};case`crx`:return{ext:`cr3`,mime:`image/x-canon-cr3`};default:return e.startsWith(`3g`)?e.startsWith(`3g2`)?{ext:`3g2`,mime:`video/3gpp2`}:{ext:`3gp`,mime:`video/3gpp`}:{ext:`mp4`,mime:`video/mp4`}}}if(this.checkString(`REGEDIT4\r
720
+ `))return{ext:`reg`,mime:`application/x-ms-regedit`};if(this.check([82,73,70,70])){if(this.checkString(`WEBP`,{offset:8}))return{ext:`webp`,mime:`image/webp`};if(this.check([65,86,73],{offset:8}))return{ext:`avi`,mime:`video/vnd.avi`};if(this.check([87,65,86,69],{offset:8}))return{ext:`wav`,mime:`audio/wav`};if(this.check([81,76,67,77],{offset:8}))return{ext:`qcp`,mime:`audio/qcelp`}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:`rw2`,mime:`image/x-panasonic-rw2`};if(this.check([48,38,178,117,142,102,207,17,166,217])){let t=!1;try{async function n(){let t=new Uint8Array(16);return await uC(e,t,void 0,{maximumLength:t.length,reason:`ASF header GUID`}),{id:t,size:Number(await e.readToken(Zx))}}await lC(e,30,{maximumLength:30,reason:`ASF header prelude`});let r=EC(e),i=e.position,a=0;for(;e.position+24<e.fileInfo.size&&(a++,!(a>QC||DC(e,i,BC)));){let i=e.position,a=await n(),o=a.size-24;if(!Number.isFinite(o)||o<0){t=!0;break}if(xC(a.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let t=new Uint8Array(16);if(o-=await uC(e,t,void 0,{maximumLength:t.length,reason:`ASF stream type GUID`}),xC(t,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`audio/x-ms-asf`};if(xC(t,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`video/x-ms-asf`};break}if(r&&o>nw){t=!0;break}if(await lC(e,o,{maximumLength:r?nw:e.fileInfo.size,reason:`ASF header payload`}),e.position<=i){t=!0;break}}}catch(n){if(n instanceof tS||n instanceof cw)EC(e)&&(t=!0);else throw n}return t?void 0:{ext:`asf`,mime:`application/vnd.ms-asf`}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:`ktx`,mime:`image/ktx`};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:`mie`,mime:`application/x-mie`};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:`shp`,mime:`application/x-esri-shape`};if(this.check([255,79,255,81]))return{ext:`j2c`,mime:`image/j2c`};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Qx(4,`ascii`))){case`jp2 `:return{ext:`jp2`,mime:`image/jp2`};case`jpx `:return{ext:`jpx`,mime:`image/jpx`};case`jpm `:return{ext:`jpm`,mime:`image/jpm`};case`mjp2`:return{ext:`mj2`,mime:`image/mj2`};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:`jxl`,mime:`image/jxl`};if(this.check([254,255]))return this.checkString(`<?xml `,{offset:2,encoding:`utf-16be`})?{ext:`xml`,mime:`application/xml`}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:`cfb`,mime:`application/x-cfb`};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:`icc`,mime:`application/vnd.iccprofile`};if(this.checkString(`**ACE`,{offset:7})&&this.checkString(`**`,{offset:12}))return{ext:`ace`,mime:`application/x-ace-compressed`};if(this.checkString(`BEGIN:`)){if(this.checkString(`VCARD`,{offset:6}))return{ext:`vcf`,mime:`text/vcard`};if(this.checkString(`VCALENDAR`,{offset:6}))return{ext:`ics`,mime:`text/calendar`}}if(this.checkString(`FUJIFILMCCD-RAW`))return{ext:`raf`,mime:`image/x-fujifilm-raf`};if(this.checkString(`Extended Module:`))return{ext:`xm`,mime:`audio/x-xm`};if(this.checkString(`Creative Voice File`))return{ext:`voc`,mime:`audio/x-voc`};if(this.check([4,0,0,0])&&this.buffer.length>=16){let e=new DataView(this.buffer.buffer).getUint32(12,!0);if(e>12&&this.buffer.length>=e+16)try{let t=new TextDecoder().decode(this.buffer.subarray(16,e+16));if(JSON.parse(t).files)return{ext:`asar`,mime:`application/x-asar`}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:`mxf`,mime:`application/mxf`};if(this.checkString(`SCRM`,{offset:44}))return{ext:`s3m`,mime:`audio/x-s3m`};if(this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:`mts`,mime:`video/mp2t`};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:`mobi`,mime:`application/x-mobipocket-ebook`};if(this.check([68,73,67,77],{offset:128}))return{ext:`dcm`,mime:`application/dicom`};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:`lnk`,mime:`application/x.ms.shortcut`};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:`alias`,mime:`application/x.apple.alias`};if(this.checkString(`Kaydara FBX Binary \0`))return{ext:`fbx`,mime:`application/x.autodesk.fbx`};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:`eot`,mime:`application/vnd.ms-fontobject`};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:`indd`,mime:`application/x-indesign`};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:`jmp`,mime:`application/x-jmp-data`};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString(`ustar`,{offset:257})&&(this.checkString(`\0`,{offset:262})||this.checkString(` `,{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&tC(this.buffer))return{ext:`tar`,mime:`application/x-tar`};if(this.check([255,254])){let e=`utf-16le`;return this.checkString(`<?xml `,{offset:2,encoding:e})?{ext:`xml`,mime:`application/xml`}:this.check([255,14],{offset:2})&&this.checkString(`SketchUp Model`,{offset:4,encoding:e})?{ext:`skp`,mime:`application/vnd.sketchup.skp`}:this.checkString(`Windows Registry Editor Version 5.00\r
721
+ `,{offset:2,encoding:e})?{ext:`reg`,mime:`application/x-ms-regedit`}:void 0}if(this.checkString(`-----BEGIN PGP MESSAGE-----`))return{ext:`pgp`,mime:`application/pgp-encrypted`}};detectImprecise=async e=>{this.buffer=new Uint8Array(FC);let t=TC(e.fileInfo.size);if(await e.peekBuffer(this.buffer,{length:Math.min(8,t),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:`mpg`,mime:`video/mpeg`};if(this.check([0,1,0,0,0]))return{ext:`ttf`,mime:`font/ttf`};if(this.check([0,0,1,0]))return{ext:`ico`,mime:`image/x-icon`};if(this.check([0,0,2,0]))return{ext:`cur`,mime:`image/x-icon`};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let e=0;e<=this.options.mpegOffsetTolerance;++e){let t=this.scanMpeg(e);if(t)return t}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?qx:Kx);switch(await this.tokenizer.ignore(10),t){case 50341:return{ext:`arw`,mime:`image/x-sony-arw`};case 50706:return{ext:`dng`,mime:`image/x-adobe-dng`}}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?qx:Kx);if(!(t>$C)&&!(EC(this.tokenizer)&&2+t*12>iw))for(let n=0;n<t;++n){let t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){let t={ext:`tif`,mime:`image/tiff`},n=(e?qx:Kx).get(this.buffer,2),r=(e?Yx:Jx).get(this.buffer,4);if(n===42){if(r>=6){if(this.checkString(`CR`,{offset:8}))return{ext:`cr2`,mime:`image/x-canon-cr2`};if(r>=8){let t=(e?qx:Kx).get(this.buffer,8),n=(e?qx:Kx).get(this.buffer,10);if(t===28&&n===254||t===31&&n===11)return{ext:`nef`,mime:`image/x-nikon-nef`}}}if(EC(this.tokenizer)&&r>rw)return t;let n=EC(this.tokenizer)?iw:this.tokenizer.fileInfo.size;try{await lC(this.tokenizer,r,{maximumLength:n,reason:`TIFF IFD offset`})}catch(e){if(e instanceof tS)return;throw e}let i;try{i=await this.readTiffIFD(e)}catch(e){if(e instanceof tS)return;throw e}return i??t}if(n===43)return t}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]}),{ext:`aac`,mime:`audio/aac`};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:`mp3`,mime:`audio/mpeg`};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:`mp2`,mime:`audio/mpeg`};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:`mp1`,mime:`audio/mpeg`}}}},new Set(iC),new Set(aC)}),mw={};E(mw,{fileCommand:()=>Sw,flagsForFuzzing:()=>Cw});function hw(e,t){let n=xw.get(e);if(n)return n;let[r,i]=t.split(`/`),a=i?.split(`+`)[0]?.replace(/-/g,` `)||e;switch(r){case`image`:return`${a.toUpperCase()} image data`;case`audio`:return`${a.toUpperCase()} audio`;case`video`:return`${a.toUpperCase()} video`;case`font`:return`${a} font`;case`model`:return`${a} 3D model`;case`application`:return i?.includes(`zip`)||i?.includes(`compressed`)?`${a} archive data`:i?.includes(`executable`)?`${a} executable`:`${e.toUpperCase()} data`;default:return`${e.toUpperCase()} data`}}function gw(e){let t=e.split(`/`).pop()||e;if(t.startsWith(`.`)&&!t.includes(`.`,1))return t;let n=t.lastIndexOf(`.`);return n===-1||n===0?``:t.slice(n).toLowerCase()}function _w(e,t){if(e.startsWith(`#!`)){let t=e.split(`
722
+ `)[0];return t.includes(`python`)?{description:`Python script, ASCII text executable`,mime:`text/x-python`}:t.includes(`node`)||t.includes(`bun`)||t.includes(`deno`)?{description:`JavaScript script, ASCII text executable`,mime:`text/javascript`}:t.includes(`bash`)?{description:`Bourne-Again shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`sh`)?{description:`POSIX shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`ruby`)?{description:`Ruby script, ASCII text executable`,mime:`text/x-ruby`}:t.includes(`perl`)?{description:`Perl script, ASCII text executable`,mime:`text/x-perl`}:{description:`script, ASCII text executable`,mime:`text/plain`}}let n=e.trimStart();if(n.startsWith(`<?xml`))return{description:`XML document`,mime:`application/xml`};if(n.startsWith(`<!DOCTYPE html`)||n.toLowerCase().startsWith(`<html`))return{description:`HTML document`,mime:`text/html`};let r=e.includes(`\r
723
+ `),i=e.includes(`\r`)&&!r,a=``;r?a=`, with CRLF line terminators`:i&&(a=`, with CR line terminators`);let o=gw(t),s=o?bw.get(o):void 0;if(s)return s.mime.startsWith(`text/`)&&a?{description:`${s.description}${a}`,mime:s.mime}:s;let c=!1;for(let t=0;t<Math.min(e.length,8192);t++)if(e.charCodeAt(t)>127){c=!0;break}return c?{description:`UTF-8 Unicode text${a}`,mime:`text/plain; charset=utf-8`}:{description:`ASCII text${a}`,mime:`text/plain`}}async function vw(e,t){if(t.length===0)return{description:`empty`,mime:`inode/x-empty`};let n=await yC(t);return n?{description:hw(n.ext,n.mime),mime:n.mime}:_w(new TextDecoder(`utf-8`,{fatal:!1}).decode(t),e)}var yw,bw,xw,Sw,Cw,ww=T(()=>{pw(),Wi(),Wr(),F(),yw={name:`file`,summary:`determine file type`,usage:`file [OPTION]... FILE...`,options:[`-b, --brief do not prepend filenames to output`,`-i, --mime output MIME type strings`,`-L, --dereference follow symlinks`,` --help display this help and exit`]},bw=new Map([[`.js`,{description:`JavaScript source`,mime:`text/javascript`}],[`.mjs`,{description:`JavaScript module`,mime:`text/javascript`}],[`.cjs`,{description:`CommonJS module`,mime:`text/javascript`}],[`.ts`,{description:`TypeScript source`,mime:`text/typescript`}],[`.tsx`,{description:`TypeScript JSX source`,mime:`text/typescript`}],[`.jsx`,{description:`JavaScript JSX source`,mime:`text/javascript`}],[`.py`,{description:`Python script`,mime:`text/x-python`}],[`.rb`,{description:`Ruby script`,mime:`text/x-ruby`}],[`.go`,{description:`Go source`,mime:`text/x-go`}],[`.rs`,{description:`Rust source`,mime:`text/x-rust`}],[`.c`,{description:`C source`,mime:`text/x-c`}],[`.h`,{description:`C header`,mime:`text/x-c`}],[`.cpp`,{description:`C++ source`,mime:`text/x-c++`}],[`.hpp`,{description:`C++ header`,mime:`text/x-c++`}],[`.java`,{description:`Java source`,mime:`text/x-java`}],[`.sh`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.bash`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.zsh`,{description:`Zsh shell script`,mime:`text/x-shellscript`}],[`.json`,{description:`JSON data`,mime:`application/json`}],[`.yaml`,{description:`YAML data`,mime:`text/yaml`}],[`.yml`,{description:`YAML data`,mime:`text/yaml`}],[`.xml`,{description:`XML document`,mime:`application/xml`}],[`.csv`,{description:`CSV text`,mime:`text/csv`}],[`.toml`,{description:`TOML data`,mime:`text/toml`}],[`.html`,{description:`HTML document`,mime:`text/html`}],[`.htm`,{description:`HTML document`,mime:`text/html`}],[`.css`,{description:`CSS stylesheet`,mime:`text/css`}],[`.svg`,{description:`SVG image`,mime:`image/svg+xml`}],[`.md`,{description:`Markdown document`,mime:`text/markdown`}],[`.markdown`,{description:`Markdown document`,mime:`text/markdown`}],[`.txt`,{description:`ASCII text`,mime:`text/plain`}],[`.rst`,{description:`reStructuredText`,mime:`text/x-rst`}],[`.env`,{description:`ASCII text`,mime:`text/plain`}],[`.gitignore`,{description:`ASCII text`,mime:`text/plain`}],[`.dockerignore`,{description:`ASCII text`,mime:`text/plain`}]]),xw=new Map([[`jpg`,`JPEG image data`],[`jpeg`,`JPEG image data`],[`png`,`PNG image data`],[`gif`,`GIF image data`],[`webp`,`WebP image data`],[`bmp`,`PC bitmap`],[`ico`,`MS Windows icon resource`],[`tif`,`TIFF image data`],[`tiff`,`TIFF image data`],[`psd`,`Adobe Photoshop Document`],[`avif`,`AVIF image`],[`heic`,`HEIC image`],[`heif`,`HEIF image`],[`jxl`,`JPEG XL image`],[`icns`,`Mac OS X icon`],[`svg`,`SVG Scalable Vector Graphics image`],[`pdf`,`PDF document`],[`epub`,`EPUB document`],[`mobi`,`Mobipocket E-book`],[`djvu`,`DjVu document`],[`zip`,`Zip archive data`],[`gz`,`gzip compressed data`],[`gzip`,`gzip compressed data`],[`bz2`,`bzip2 compressed data`],[`xz`,`XZ compressed data`],[`tar`,`POSIX tar archive`],[`rar`,`RAR archive data`],[`7z`,`7-zip archive data`],[`lz`,`lzip compressed data`],[`lzma`,`LZMA compressed data`],[`zst`,`Zstandard compressed data`],[`cab`,`Microsoft Cabinet archive`],[`ar`,`Unix ar archive`],[`rpm`,`RPM package`],[`deb`,`Debian binary package`],[`apk`,`Android Package`],[`dmg`,`Apple disk image`],[`iso`,`ISO 9660 CD-ROM filesystem data`],[`vhd`,`Microsoft Virtual Hard Disk`],[`vhdx`,`Microsoft Virtual Hard Disk (new format)`],[`qcow2`,`QEMU QCOW Image`],[`mp3`,`Audio file with ID3`],[`m4a`,`MPEG-4 audio`],[`aac`,`AAC audio`],[`wav`,`RIFF (little-endian) data, WAVE audio`],[`flac`,`FLAC audio bitstream data`],[`ogg`,`Ogg data`],[`oga`,`Ogg audio`],[`opus`,`Ogg Opus audio`],[`aiff`,`AIFF audio`],[`wma`,`Windows Media Audio`],[`amr`,`AMR audio`],[`mid`,`MIDI audio`],[`midi`,`MIDI audio`],[`ape`,`Monkey's Audio`],[`mp4`,`ISO Media, MPEG-4`],[`m4v`,`MPEG-4 video`],[`webm`,`WebM`],[`avi`,`RIFF (little-endian) data, AVI`],[`mov`,`ISO Media, Apple QuickTime movie`],[`mkv`,`Matroska data`],[`wmv`,`Windows Media Video`],[`flv`,`Flash Video`],[`3gp`,`3GPP multimedia`],[`3g2`,`3GPP2 multimedia`],[`ogv`,`Ogg video`],[`mts`,`MPEG transport stream`],[`m2ts`,`MPEG transport stream`],[`ts`,`MPEG transport stream`],[`mpg`,`MPEG video`],[`mpeg`,`MPEG video`],[`exe`,`PE32 executable`],[`dll`,`PE32 DLL`],[`elf`,`ELF executable`],[`mach`,`Mach-O executable`],[`wasm`,`WebAssembly (wasm) binary module`],[`dex`,`Android Dalvik executable`],[`class`,`Java class file`],[`swf`,`Adobe Flash`],[`doc`,`Microsoft Word Document`],[`docx`,`Microsoft Word 2007+ Document`],[`xls`,`Microsoft Excel Spreadsheet`],[`xlsx`,`Microsoft Excel 2007+ Spreadsheet`],[`ppt`,`Microsoft PowerPoint Presentation`],[`pptx`,`Microsoft PowerPoint 2007+ Presentation`],[`odt`,`OpenDocument Text`],[`ods`,`OpenDocument Spreadsheet`],[`odp`,`OpenDocument Presentation`],[`ttf`,`TrueType Font`],[`otf`,`OpenType Font`],[`woff`,`Web Open Font Format`],[`woff2`,`Web Open Font Format 2`],[`eot`,`Embedded OpenType font`],[`stl`,`Stereolithography CAD`],[`obj`,`Wavefront 3D Object`],[`gltf`,`GL Transmission Format`],[`glb`,`GL Transmission Format (binary)`],[`sqlite`,`SQLite 3.x database`],[`mdb`,`Microsoft Access Database`],[`xml`,`XML document`],[`json`,`JSON data`],[`macho`,`Mach-O binary`],[`ics`,`iCalendar data`],[`vcf`,`vCard data`],[`msi`,`Microsoft Installer`],[`ps`,`PostScript`],[`ai`,`Adobe Illustrator`],[`indd`,`Adobe InDesign`],[`sketch`,`Sketch design file`],[`fig`,`Figma design file`],[`xd`,`Adobe XD`],[`blend`,`Blender`],[`fbx`,`Autodesk FBX`],[`lnk`,`MS Windows shortcut`],[`alias`,`Mac OS alias`],[`torrent`,`BitTorrent file`],[`pcap`,`pcap capture file`],[`arrow`,`Apache Arrow`],[`parquet`,`Apache Parquet`]]),Sw={name:`file`,async execute(e,t){if(N(e))return M(yw);let n=!1,r=!1,i=!1,a=[];for(let t of e)if(t.startsWith(`--`))if(t===`--brief`)n=!0;else if(t===`--mime`||t===`--mime-type`)r=!0;else if(t===`--dereference`)i=!0;else return P(`file`,t);else if(t.startsWith(`-`)&&t!==`-`)for(let e of t.slice(1))if(e===`b`)n=!0;else if(e===`i`)r=!0;else if(e===`L`)i=!0;else return P(`file`,`-${e}`);else a.push(t);if(a.length===0)return{stdout:``,stderr:`Usage: file [-bLi] FILE...
724
+ `,exitCode:1};let o=new Ui(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`file`),s=0;for(let e of a){t.executionScope?.consumeLimited(`file-operands`,1,t.limits.maxArrayElements,`file`);try{let a=t.fs.resolvePath(t.cwd,e),s=i?await t.fs.stat(a):await t.fs.lstat(a);if(s.isSymbolicLink){let i=await t.fs.readlink(a),s=r?`inode/symlink`:`symbolic link to ${i}`;o.append(n?`${s}
725
+ `:`${e}: ${s}
726
+ `);continue}if(s.isDirectory){let t=r?`inode/directory`:`directory`;o.append(n?`${t}
727
+ `:`${e}: ${t}
728
+ `);continue}let c=await t.fs.readFileBuffer(a);t.executionScope?.consumeInput(c.byteLength,`file`);let l=await vw(e,c),u=r?l.mime:l.description;o.append(n?`${u}
729
+ `:`${e}: ${u}
730
+ `)}catch(t){Ur(t),o.append(n?`cannot open
731
+ `:`${e}: cannot open (No such file or directory)
732
+ `),s=1}}return{stdout:o.build(),stderr:``,exitCode:s}}},Cw={name:`file`,flags:[{flag:`-b`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-L`,type:`boolean`}],needsArgs:!0}}),Tw={};E(Tw,{flagsForFuzzing:()=>Ow,htmlToMarkdownCommand:()=>Dw});var Ew,Dw,Ow,kw=T(()=>{k(),Wr(),j(),F(),Ew={name:`html-to-markdown`,summary:`convert HTML to Markdown (BashEnv extension)`,usage:`html-to-markdown [OPTION]... [FILE]`,description:[`Convert HTML content to Markdown format using the turndown library.`,`This is a non-standard BashEnv extension command, not available in regular bash.`,``,`Read HTML from FILE or standard input and output Markdown to standard output.`,`Commonly used with curl to convert web pages:`,` curl -s https://example.com | html-to-markdown`,``,`Supported HTML elements:`,` - Headings (h1-h6) → # Markdown headings`,` - Paragraphs (p) → Plain text with blank lines`,` - Links (a) → [text](url)`,` - Images (img) → ![alt](src)`,` - Bold/Strong → **text**`,` - Italic/Em → _text_`," - Code (code, pre) → `inline` or fenced blocks",` - Lists (ul, ol, li) → - or 1. items`,` - Blockquotes → > quoted text`,` - Horizontal rules (hr) → ---`],options:[`-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)`,"-c, --code=FENCE fence style for code blocks (``` or ~~~)",`-r, --hr=STRING string for horizontal rules (default: ---)`,` --heading-style=STYLE`,` heading style: 'atx' for # headings (default),`,` 'setext' for underlined headings (h1/h2 only)`,` --help display this help and exit`],examples:[`echo '<h1>Hello</h1><p>World</p>' | html-to-markdown`,`html-to-markdown page.html`,`curl -s https://example.com | html-to-markdown > page.md`]},Dw={name:`html-to-markdown`,async execute(e,t){if(N(e))return M(Ew);let n=`-`,r="```",i=`---`,a=`atx`,o=[];for(let t=0;t<e.length;t++){let s=e[t];if(s===`-b`||s===`--bullet`)n=e[++t]??`-`;else if(s.startsWith(`--bullet=`))n=s.slice(9);else if(s===`-c`||s===`--code`)r=e[++t]??"```";else if(s.startsWith(`--code=`))r=s.slice(7);else if(s===`-r`||s===`--hr`)i=e[++t]??`---`;else if(s.startsWith(`--hr=`))i=s.slice(5);else if(s.startsWith(`--heading-style=`)){let e=s.slice(16);(e===`setext`||e===`atx`)&&(a=e)}else if(s===`-`)o.push(`-`);else{if(s.startsWith(`--`)||s.startsWith(`-`))return P(`html-to-markdown`,s);o.push(s)}}let s,c=Math.min(t.limits.maxInputBytes,t.limits.maxStringLength);if(o.length===0||o.length===1&&o[0]===`-`){if(t.stdin.length>c)throw new A(`html-to-markdown: input size limit exceeded (${c} bytes)`,`string_length`);s=or(t.stdin)}else try{let e=t.fs.resolvePath(t.cwd,o[0]);if((await t.fs.stat(e)).size>c||(s=await t.fs.readFile(e),O(s)>c))throw new A(`html-to-markdown: input size limit exceeded (${c} bytes)`,`string_length`)}catch(e){return Ur(e),{stdout:``,stderr:`html-to-markdown: ${o[0]}: No such file or directory
733
+ `,exitCode:1}}if(!s.trim())return{stdout:``,stderr:``,exitCode:0};if(![`-`,`+`,`*`].includes(n))return{stdout:``,stderr:`html-to-markdown: invalid bullet marker
734
+ `,exitCode:1};if(r!=="```"&&r!==`~~~`)return{stdout:``,stderr:`html-to-markdown: invalid code fence
735
+ `,exitCode:1};let l=0,u=t.limits.maxLoopIterations;for(let e=0;e<s.length;e++)if(s.charCodeAt(e)===60&&++l>u)throw new A(`html-to-markdown: complexity limit exceeded (${u} tags)`,`iterations`);t.executionScope?.consumeWork(l,`html-to-markdown tags`);let d=O(s),f=Math.min(t.limits.maxStringLength,t.limits.maxOutputSize);if(d>Math.floor((f-1)/4))throw new A(`html-to-markdown: prospective output size limit exceeded (${f} bytes)`,`output_size`);let p=d*4+1,m=t.executionScope?.reserveBytes(`html input`,d,`html-to-markdown`),h=t.executionScope?.reserveBytes(`html prospective output`,p,`html-to-markdown`);try{let e=new $t({bulletListMarker:n,codeBlockStyle:`fenced`,fence:r,hr:i,headingStyle:a});e.remove([`script`,`style`,`footer`]);let t=e.turndown(s).trim();if(O(t)+1>f)throw new A(`html-to-markdown: output size limit exceeded (${f} bytes)`,`output_size`);return{stdout:`${t}
736
+ `,stderr:``,exitCode:0}}catch(e){return Ur(e),{stdout:``,stderr:`html-to-markdown: conversion error: ${e.message}
737
+ `,exitCode:1}}finally{h?.release(),m?.release()}}},Ow={name:`html-to-markdown`,flags:[],stdinType:`text`}}),Aw={};E(Aw,{flagsForFuzzing:()=>Pw,helpCommand:()=>Nw});function jw(e){let t=[],n=new Set(e);t.push(`Available commands:
738
+ `);let r=[];for(let[e,r]of Mw){let i=r.filter(e=>n.has(e));if(i.length>0){t.push(` ${e}:`),t.push(` ${i.join(`, `)}
739
+ `);for(let e of i)n.delete(e)}}for(let e of n)r.push(e);return r.length>0&&(t.push(` Other:`),t.push(` ${r.sort().join(`, `)}
740
+ `)),t.push(`Use '<command> --help' for details on a specific command.`),`${t.join(`
741
+ `)}
742
+ `}var Mw,Nw,Pw,Fw=T(()=>{Kl(),Mw=new Map([[`File operations`,[`ls`,`cat`,`head`,`tail`,`wc`,`touch`,`mkdir`,`rm`,`cp`,`mv`,`ln`,`chmod`,`stat`,`readlink`]],[`Text processing`,[`grep`,`sed`,`awk`,`sort`,`uniq`,`cut`,`tr`,`tee`,`diff`]],[`Search`,[`find`]],[`Navigation & paths`,[`pwd`,`basename`,`dirname`,`tree`,`du`]],[`Environment & shell`,[`echo`,`printf`,`env`,`printenv`,`export`,`alias`,`unalias`,`history`,`clear`,`true`,`false`,`bash`,`sh`]],[`Data processing`,[`xargs`,`jq`,`base64`,`date`]],[`Network`,[`curl`,`html-to-markdown`]]]),Nw={name:`help`,async execute(e,t){if(e.includes(`--help`)||e.includes(`-h`))return{stdout:`help - display available commands
743
+
744
+ Usage: help [command]
745
+
746
+ Options:
747
+ -h, --help Show this help message
748
+
749
+ If a command name is provided, shows help for that command.
750
+ Otherwise, lists all available commands.
751
+ `,stderr:``,exitCode:0};if(e.length>0&&t.exec){let n=e[0];return t.exec(Gl([n]),{cwd:t.cwd,signal:t.signal,args:[`--help`]})}return{stdout:jw(t.getRegisteredCommands?.()??[]),stderr:``,exitCode:0}}},Pw={name:`help`,flags:[]}}),Iw={};E(Iw,{flagsForFuzzing:()=>Bw,whichCommand:()=>zw});var Lw,Rw,zw,Bw,Vw=T(()=>{Kr(),F(),Lw={name:`which`,summary:`locate a command`,usage:`which [-as] program ...`,options:[`-a List all instances of executables found`,`-s No output, just return 0 if found, 1 if not`,`--help display this help and exit`]},Rw={showAll:{short:`a`,type:`boolean`},silent:{short:`s`,type:`boolean`}},zw={name:`which`,async execute(e,t){if(N(e))return M(Lw);let n=Gr(`which`,e,Rw);if(!n.ok)return n.error;let r=n.result.flags.showAll,i=n.result.flags.silent,a=n.result.positional;if(a.length===0)return{stdout:``,stderr:``,exitCode:1};let o=(t.env.get(`PATH`)||`/usr/bin:/bin`).split(`:`),s=``,c=!0;for(let e of a){let n=!1;for(let a of o){if(!a)continue;let o=t.fs.resolvePath(a,e);if(await t.fs.exists(o)&&(n=!0,i||(s+=`${o}
752
+ `),!r))break}n||(c=!1)}return{stdout:s,stderr:``,exitCode:+!c}}},Bw={name:`which`,flags:[{flag:`-a`,type:`boolean`},{flag:`-s`,type:`boolean`}],needsArgs:!0}}),Hw={};E(Hw,{flagsForFuzzing:()=>Gw,tac:()=>Ww});async function Uw(e,t){if(e.length>0&&e[0]!==`-`){let n=t.fs.resolvePath(t.cwd,e[0]);try{let e=(await t.fs.readFile(n)).split(`
753
+ `);e[e.length-1]===``&&e.pop();let r=e.reverse();return{stdout:r.length>0?`${r.join(`
754
+ `)}
755
+ `:``,stderr:``,exitCode:0}}catch{return{stdout:``,stderr:`tac: ${e[0]}: No such file or directory
756
+ `,exitCode:1}}}let n=t.stdin.split(`
757
+ `);n[n.length-1]===``&&n.pop();let r=n.reverse();return{stdout:r.length>0?`${r.join(`
758
+ `)}
759
+ `:``,stderr:``,exitCode:0,stdoutKind:`bytes`}}var Ww,Gw,Kw=T(()=>{k(),Ww={name:`tac`,execute:Uw},Gw={name:`tac`,flags:[],stdinType:`text`,needsFiles:!0}}),qw={};E(qw,{flagsForFuzzing:()=>Xw,hostname:()=>Yw});async function Jw(e,t){return{stdout:`localhost
760
+ `,stderr:``,exitCode:0}}var Yw,Xw,Zw=T(()=>{Yw={name:`hostname`,execute:Jw},Xw={name:`hostname`,flags:[]}}),Qw={};E(Qw,{flagsForFuzzing:()=>tT,whoami:()=>eT});async function $w(e,t){return{stdout:`user
761
+ `,stderr:``,exitCode:0}}var eT,tT,nT=T(()=>{eT={name:`whoami`,execute:$w},tT={name:`whoami`,flags:[]}}),rT={};E(rT,{flagsForFuzzing:()=>oT,od:()=>aT});async function iT(e,t){let n=`octal`,r=[],i=[];for(let t=0;t<e.length;t++){let a=e[t];if(a===`-c`)r.push(`char`);else if(a===`-An`||a===`-A`&&e[t+1]===`n`)n=`none`,a===`-A`&&t++;else if(a===`-t`&&e[t+1]){let n=e[++t];n===`x1`?r.push(`hex`):n===`c`?r.push(`char`):n.startsWith(`o`)&&r.push(`octal`)}else(!a.startsWith(`-`)||a===`-`)&&i.push(a)}r.length===0&&r.push(`octal`);let a=new Ui(t.limits.maxInputBytes,`od input`),o=i.length===0?[`-`]:i;for(let e of o){if(e===`-`){a.append(t.stdin);continue}let n=e.startsWith(`/`)?e:`${t.cwd}/${e}`;try{let e=await lr(t.fs,n);t.executionScope?.consumeInput(e.length,`od`),a.append(e)}catch(t){return Ur(t),{stdout:``,stderr:`od: ${e}: No such file or directory
762
+ `,exitCode:1}}}let s=r.includes(`char`);function c(e){return e===0?` \\0`:e===7?` \\a`:e===8?` \\b`:e===9?` \\t`:e===10?` \\n`:e===11?` \\v`:e===12?` \\f`:e===13?` \\r`:e>=32&&e<127?` ${String.fromCharCode(e)}`:` ${e.toString(8).padStart(3,`0`)}`}function l(e){return s?` ${e.toString(16).padStart(2,`0`)}`:` ${e.toString(16).padStart(2,`0`)}`}function u(e){return` ${e.toString(8).padStart(3,`0`)}`}let d=a.build(),f=new Ui(Math.min(t.limits.maxOutputSize,t.limits.maxStringLength),`od`),p=r.length;if(p>0&&d.length>Math.floor(t.limits.maxLoopIterations/p))throw new A(`od: format work limit exceeded (${t.limits.maxLoopIterations})`,`iterations`);t.executionScope?.consumeWork(d.length*p,`od formatting`);for(let e=0;e<d.length;e+=16)for(let t=0;t<r.length;t++){let i=r[t],a;a=i===`char`?Array.from(d.slice(e,e+16),e=>c(e.charCodeAt(0))):i===`hex`?Array.from(d.slice(e,e+16),e=>l(e.charCodeAt(0))):Array.from(d.slice(e,e+16),e=>u(e.charCodeAt(0)));let o=``;t===0&&n!==`none`?o=`${e.toString(8).padStart(7,`0`)} `:(t>0||n===`none`)&&(o=n===`none`?``:` `),f.append(o+a.join(``)).append(`
763
+ `)}return n!==`none`&&d.length>0&&f.append(d.length.toString(8).padStart(7,`0`)).append(`
764
+ `),{stdout:f.build(),stderr:``,exitCode:0}}var aT,oT,sT=T(()=>{Wi(),k(),Wr(),j(),aT={name:`od`,execute:iT},oT={name:`od`,flags:[{flag:`-c`,type:`boolean`},{flag:`-A`,type:`value`,valueHint:`string`},{flag:`-t`,type:`value`,valueHint:`string`},{flag:`-N`,type:`value`,valueHint:`number`}],stdinType:`text`,needsFiles:!0}}),cT,lT=T(()=>{cT=class{options;inputBytes=0;outputBytes=0;workBytes=0;label;constructor(e){this.options=e,this.label=e.label??`codec`;for(let[t,n]of[[`maxInputBytes`,e.maxInputBytes],[`maxOutputBytes`,e.maxOutputBytes],[`maxExpansionRatio`,e.maxExpansionRatio],[`ratioGraceBytes`,e.ratioGraceBytes],[`maxWorkBytes`,e.maxWorkBytes]])if(n!==void 0&&(!Number.isSafeInteger(n)||n<0))throw Error(`${this.label}: invalid ${t}`)}checkpoint(){if(this.options.signal?.aborted)throw Error(`${this.label}: operation aborted`)}acceptInput(e){this.checkpoint(),this.inputBytes=this.addWithinLimit(this.inputBytes,e,this.options.maxInputBytes,`input`),this.chargeWork(e)}acceptOutput(e){this.checkpoint();let t=this.addWithinLimit(this.outputBytes,e,this.options.maxOutputBytes,`output`),n=this.options.ratioGraceBytes??1048576,r=this.options.maxExpansionRatio;if(r!==void 0&&t>n&&(this.inputBytes===0||t>this.inputBytes*r))throw Error(`${this.label}: expansion ratio exceeds limit (${r}:1)`);this.outputBytes=t,this.chargeWork(e)}get inputLength(){return this.inputBytes}get outputLength(){return this.outputBytes}chargeWork(e){let t=this.options.maxWorkBytes??this.options.maxInputBytes+this.options.maxOutputBytes;this.workBytes=this.addWithinLimit(this.workBytes,e,t,`work`)}addWithinLimit(e,t,n,r){if(!Number.isSafeInteger(t)||t<0||t>n-e)throw Error(`${this.label}: ${r} exceeds limit (${n} bytes)`);return e+t}}}),uT={};E(uT,{flagsForFuzzing:()=>PT,gunzipCommand:()=>MT,gunzipFlagsForFuzzing:()=>FT,gzipCommand:()=>jT,zcatCommand:()=>NT,zcatFlagsForFuzzing:()=>IT});function dT(e){return e.best?ct.Z_BEST_COMPRESSION:e.level8?8:e.level7?7:e.level6?6:e.level5?5:e.level4?4:e.level3?3:e.level2?2:e.fast?ct.Z_BEST_SPEED:ct.Z_DEFAULT_COMPRESSION}function fT(e){if(e.length<10||e[0]!==31||e[1]!==139)return{originalName:null,mtime:null,headerSize:0};let t=e[3],n=e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r=10;if(t&4){if(r+2>e.length)return{originalName:null,mtime:null,headerSize:0};let t=e[r]|e[r+1]<<8;r+=2+t}let i=null;if(t&8){let t=r;for(;r<e.length&&e[r]!==0;)r++;r<e.length&&(i=new TextDecoder().decode(e.slice(t,r)),r++)}if(t&16){for(;r<e.length&&e[r]!==0;)r++;r++}return t&2&&(r+=2),{originalName:i,mtime:n>0?new Date(n*1e3):null,headerSize:r}}function pT(e){return e.length===0||e===`.`||e===`..`||e.includes(`/`)||e.includes(`\\`)||/[\0-\x1f\x7f]/.test(e)?null:e}function mT(e){if(e.length<4)return 0;let t=e.length;return e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24}function hT(e){return e.length>=2&&e[0]===31&&e[1]===139}function gT(e){return Buffer.from(e).toString(`latin1`)}function _T(e){return e.limits.maxOutputSize}function vT(e,t,n,r,i){if(t<=0)throw Error(`decompressed data exceeds limit (0 bytes)`);let a=new cT({maxInputBytes:n,maxOutputBytes:t,maxExpansionRatio:1e4,signal:r,label:`gzip`});if(a.acceptInput(e.length),mT(e)>t)throw Error(`decompressed data exceeds limit (${t} bytes)`);let o;try{let n=Math.min(t,Math.floor((i?.executionScope?.remainingLiveBytes??t*2)/2));if(n<=0)throw Error(`gzip: live byte limit exceeded`);o=i?.executionScope?.reserveBytes(`gzip output`,n*2,`gzip`);let r=lt(e,{maxOutputLength:n});return a.acceptOutput(r.length),{data:r,lease:o}}catch(e){throw o?.release(),e}}function yT(e,t,n){let r=new cT({maxInputBytes:n.limits.maxInputBytes,maxOutputBytes:n.limits.maxOutputSize,signal:n.signal,label:`gzip`});r.acceptInput(e.length);let i;try{let a=Math.min(n.limits.maxOutputSize,Math.floor((n.executionScope?.remainingLiveBytes??n.limits.maxOutputSize*2)/2));if(a<=0)throw Error(`gzip: live byte limit exceeded`);i=n.executionScope?.reserveBytes(`gzip output`,a*2,`gzip`);let o=ut(e,{level:t,maxOutputLength:a});return r.acceptOutput(o.length),{data:o,lease:i}}catch(e){throw i?.release(),e}}async function bT(e,t,n){let r=await e.fs.stat(t);if(r.size>e.limits.maxInputBytes)throw new A(`input size limit exceeded (${e.limits.maxInputBytes} bytes)`,`string_length`);let i=e.executionScope?.reserveBytes(`gzip input`,r.size,n);try{let a=await e.fs.readFileBuffer(t);if(a.byteLength>r.size)throw new A(`gzip: input grew while being read`,`string_length`);return e.executionScope?.consumeInput(a.byteLength,n),{data:a,lease:i}}catch(e){throw i?.release(),e}}async function xT(e,t,n){if(t!==`-`&&t!==``)return bT(e,e.fs.resolvePath(e.cwd,t),n);let r=e.stdin,i=e.executionScope?.reserveBytes(`gzip input`,r.length,n);try{return{data:Uint8Array.from(r,e=>e.charCodeAt(0)),lease:i}}catch(e){throw i?.release(),e}}async function ST(e,t,n,r,i,a){let o=n.suffix,s,c,l,u=_T(e);if(t===`-`||t===``){let t=e.stdin,a=e.executionScope?.reserveBytes(`gzip input`,t.length,r),o;try{if(l=Uint8Array.from(t,e=>e.charCodeAt(0)),i){if(!hT(l))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: stdin: not in gzip format
765
+ `,exitCode:1};try{let t=vT(l,u,e.limits.maxInputBytes,e.signal,e);return o=t.lease,{stdout:gT(t.data),stderr:``,exitCode:0}}catch(e){return Ur(e),{stdout:``,stderr:`${r}: stdin: ${e instanceof Error?e.message:`unknown error`}
766
+ `,exitCode:1}}}{let t=yT(l,dT(n),e);return o=t.lease,{stdout:gT(t.data),stderr:``,exitCode:0}}}finally{o?.release(),a?.release()}}s=e.fs.resolvePath(e.cwd,t);try{let o=await e.fs.stat(s);if(o.size>e.limits.maxInputBytes)return{stdout:``,stderr:`${r}: ${t}: input size limit exceeded (${e.limits.maxInputBytes} bytes)
767
+ `,exitCode:1};if(o.isDirectory)return n.recursive?await CT(e,s,n,r,i,a):n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: is a directory -- ignored
768
+ `,exitCode:1}}catch{return{stdout:``,stderr:`${r}: ${t}: No such file or directory
769
+ `,exitCode:1}}let d,f;try{let t=await bT(e,s,r);l=t.data,d=t.lease}catch(e){return Ur(e),{stdout:``,stderr:`${r}: ${t}: No such file or directory
770
+ `,exitCode:1}}try{if(i){if(!t.endsWith(o))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: unknown suffix -- ignored
771
+ `,exitCode:1};if(!hT(l))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: not in gzip format
772
+ `,exitCode:1};let i;try{let t=vT(l,u,e.limits.maxInputBytes,e.signal,e);i=t.data,f=t.lease}catch(e){return Ur(e),{stdout:``,stderr:`${r}: ${t}: ${e instanceof Error?e.message:`unknown error`}
773
+ `,exitCode:1}}if(a)return{stdout:gT(i),stderr:``,exitCode:0};if(n.name){let t=fT(l),n=t.originalName?pT(t.originalName):null;c=n?e.fs.resolvePath(e.cwd,n):s.slice(0,-o.length)}else c=s.slice(0,-o.length);if(!n.force)try{return await e.fs.stat(c),{stdout:``,stderr:`${r}: ${c} already exists; not overwritten
774
+ `,exitCode:1}}catch{}return await e.fs.writeFile(c,i),!n.keep&&!a&&await e.fs.rm(s),n.verbose?{stdout:``,stderr:`${t}: ${l.length>0?((1-l.length/i.length)*100).toFixed(1):`0.0`}% -- replaced with ${c.split(`/`).pop()}
775
+ `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}{if(t.endsWith(o))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t} already has ${o} suffix -- unchanged
776
+ `,exitCode:1};let i=dT(n),u;try{let t=yT(l,i,e);u=t.data,f=t.lease}catch(e){return Ur(e),{stdout:``,stderr:`${r}: ${t}: ${e instanceof Error?e.message:`unknown error`}
777
+ `,exitCode:1}}if(a)return{stdout:gT(u),stderr:``,exitCode:0};if(c=s+o,!n.force)try{return await e.fs.stat(c),{stdout:``,stderr:`${r}: ${c} already exists; not overwritten
778
+ `,exitCode:1}}catch{}return await e.fs.writeFile(c,u),!n.keep&&!a&&await e.fs.rm(s),n.verbose?{stdout:``,stderr:`${t}: ${l.length>0?((1-u.length/l.length)*100).toFixed(1):`0.0`}% -- replaced with ${c.split(`/`).pop()}
779
+ `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}}finally{f?.release(),d?.release()}}async function CT(e,t,n,r,i,a){let o=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),s=new Ui(o,r),c=new Ui(o,r),l=0;return await oa({fs:e.fs,root:t,symlinks:`never`,limits:e.limits,signal:e.signal,executionScope:e.executionScope,site:r},async t=>{if(t.depth===0||t.phase!==`enter`||!t.stat.isFile)return;let o=n.suffix;if(i&&!t.path.endsWith(o)||!i&&t.path.endsWith(o))return;let u=await ST(e,t.path.startsWith(`${e.cwd}/`)?t.path.slice(e.cwd.length+1):t.path,n,r,i,a);s.append(u.stdout),c.append(u.stderr),u.exitCode!==0&&(l=u.exitCode)}),{stdout:s.build(),stderr:c.build(),exitCode:l}}async function wT(e,t,n,r){let i,a;try{let n=await xT(e,t,r);i=n.data,a=n.lease}catch(e){return Ur(e),{stdout:``,stderr:`${r}: ${t}: No such file or directory
780
+ `,exitCode:1}}try{if(!hT(i))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: not in gzip format
781
+ `,exitCode:1};let e=i.length,a=mT(i),o=a>0?((1-e/a)*100).toFixed(1):`0.0`,s=fT(i).originalName||(t===`-`?``:t.replace(/\.gz$/,``));return{stdout:`${e.toString().padStart(10)} ${a.toString().padStart(10)} ${o.padStart(5)}% ${s}
782
+ `,stderr:``,exitCode:0}}finally{a?.release()}}async function TT(e,t,n,r){let i,a;try{let n=await xT(e,t,r);i=n.data,a=n.lease}catch(e){return Ur(e),{stdout:``,stderr:`${r}: ${t}: No such file or directory
783
+ `,exitCode:1}}try{if(!hT(i))return n.quiet?{stdout:``,stderr:``,exitCode:1}:{stdout:``,stderr:`${r}: ${t}: not in gzip format
784
+ `,exitCode:1};try{return vT(i,_T(e),e.limits.maxInputBytes,e.signal,e).lease?.release(),n.verbose?{stdout:``,stderr:`${t}: OK
785
+ `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}catch(e){return Ur(e),{stdout:``,stderr:`${r}: ${t}: ${e instanceof Error?e.message:`invalid`}
786
+ `,exitCode:1}}}finally{a?.release()}}async function ET(e,t,n){let r=n===`zcat`?kT:n===`gunzip`?OT:DT;if(N(e))return M(r);let i=Gr(n,e,AT);if(!i.ok)return i.error.stderr.includes(`unrecognized option`),i.error;let a=i.result.flags,o=i.result.positional,s=n===`gunzip`||n===`zcat`||a.decompress||a.uncompress,c=n===`zcat`||a.stdout||a.toStdout;if(a.list){o.length===0&&(o=[`-`]);let e=` compressed uncompressed ratio uncompressed_name
787
+ `,r=``,i=0;for(let s of o){let o=await wT(t,s,a,n);e+=o.stdout,r+=o.stderr,o.exitCode!==0&&(i=o.exitCode)}return{stdout:e,stderr:r,exitCode:i}}if(a.test){o.length===0&&(o=[`-`]);let e=``,r=``,i=0;for(let s of o){let o=await TT(t,s,a,n);e+=o.stdout,r+=o.stderr,o.exitCode!==0&&(i=o.exitCode)}return{stdout:e,stderr:r,exitCode:i}}o.length===0&&(o=[`-`]);let l=``,u=``,d=0;for(let e of o){let r=await ST(t,e,a,n,s,c);l+=r.stdout,u+=r.stderr,r.exitCode!==0&&(d=r.exitCode)}return{stdout:l,stderr:u,exitCode:d}}var DT,OT,kT,AT,jT,MT,NT,PT,FT,IT,LT=T(()=>{Wi(),k(),Wr(),la(),j(),Kr(),lT(),F(),DT={name:`gzip`,summary:`compress or expand files`,usage:`gzip [OPTION]... [FILE]...`,description:`Compress FILEs (by default, in-place).
788
+
789
+ When no FILE is given, or when FILE is -, read from standard input.
790
+
791
+ With -d, decompress instead.`,options:[`-c, --stdout write to standard output, keep original files`,`-d, --decompress decompress`,`-f, --force force overwrite of output file`,`-k, --keep keep (don't delete) input files`,`-l, --list list compressed file contents`,`-n, --no-name do not save or restore the original name and timestamp`,`-N, --name save or restore the original file name and timestamp`,`-q, --quiet suppress all warnings`,`-r, --recursive operate recursively on directories`,`-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)`,`-t, --test test compressed file integrity`,`-v, --verbose verbose mode`,`-1, --fast compress faster`,`-9, --best compress better`,` --help display this help and exit`]},OT={name:`gunzip`,summary:`decompress files`,usage:`gunzip [OPTION]... [FILE]...`,description:`Decompress FILEs (by default, in-place).
792
+
793
+ When no FILE is given, or when FILE is -, read from standard input.`,options:[`-c, --stdout write to standard output, keep original files`,`-f, --force force overwrite of output file`,`-k, --keep keep (don't delete) input files`,`-l, --list list compressed file contents`,`-n, --no-name do not restore the original name and timestamp`,`-N, --name restore the original file name and timestamp`,`-q, --quiet suppress all warnings`,`-r, --recursive operate recursively on directories`,`-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)`,`-t, --test test compressed file integrity`,`-v, --verbose verbose mode`,` --help display this help and exit`]},kT={name:`zcat`,summary:`decompress files to stdout`,usage:`zcat [OPTION]... [FILE]...`,description:`Decompress FILEs to standard output.
794
+
795
+ When no FILE is given, or when FILE is -, read from standard input.`,options:[`-f, --force force; read compressed data even from a terminal`,`-l, --list list compressed file contents`,`-q, --quiet suppress all warnings`,`-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)`,`-t, --test test compressed file integrity`,`-v, --verbose verbose mode`,` --help display this help and exit`]},AT={stdout:{short:`c`,long:`stdout`,type:`boolean`},toStdout:{long:`to-stdout`,type:`boolean`},decompress:{short:`d`,long:`decompress`,type:`boolean`},uncompress:{long:`uncompress`,type:`boolean`},force:{short:`f`,long:`force`,type:`boolean`},keep:{short:`k`,long:`keep`,type:`boolean`},list:{short:`l`,long:`list`,type:`boolean`},noName:{short:`n`,long:`no-name`,type:`boolean`},name:{short:`N`,long:`name`,type:`boolean`},quiet:{short:`q`,long:`quiet`,type:`boolean`},recursive:{short:`r`,long:`recursive`,type:`boolean`},suffix:{short:`S`,long:`suffix`,type:`string`,default:`.gz`},test:{short:`t`,long:`test`,type:`boolean`},verbose:{short:`v`,long:`verbose`,type:`boolean`},fast:{short:`1`,long:`fast`,type:`boolean`},level2:{short:`2`,type:`boolean`},level3:{short:`3`,type:`boolean`},level4:{short:`4`,type:`boolean`},level5:{short:`5`,type:`boolean`},level6:{short:`6`,type:`boolean`},level7:{short:`7`,type:`boolean`},level8:{short:`8`,type:`boolean`},best:{short:`9`,long:`best`,type:`boolean`}},jT={name:`gzip`,async execute(e,t){return{...await ET(e,t,`gzip`),stdoutEncoding:`binary`}}},MT={name:`gunzip`,async execute(e,t){return{...await ET(e,t,`gunzip`),stdoutEncoding:`binary`}}},NT={name:`zcat`,async execute(e,t){return{...await ET(e,t,`zcat`),stdoutEncoding:`binary`}}},PT={name:`gzip`,flags:[{flag:`-c`,type:`boolean`},{flag:`-d`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-k`,type:`boolean`},{flag:`-l`,type:`boolean`},{flag:`-n`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-r`,type:`boolean`},{flag:`-t`,type:`boolean`},{flag:`-v`,type:`boolean`},{flag:`-1`,type:`boolean`},{flag:`-9`,type:`boolean`}],stdinType:`binary`,needsFiles:!0},FT={name:`gunzip`,flags:[{flag:`-c`,type:`boolean`},{flag:`-f`,type:`boolean`},{flag:`-k`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`binary`,needsFiles:!0},IT={name:`zcat`,flags:[{flag:`-f`,type:`boolean`},{flag:`-q`,type:`boolean`},{flag:`-v`,type:`boolean`}],stdinType:`binary`,needsFiles:!0}});function RT(e,t){if(e instanceof Uint8Array)return e;if(t===`base64`)return Uint8Array.from(atob(e),e=>e.charCodeAt(0));if(t===`hex`){let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}if(t===`binary`||t===`latin1`){if(e.length<=65536)return Uint8Array.from(e,e=>e.charCodeAt(0));let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}return VT.encode(e)}function zT(e,t){if(t===`base64`){if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=65536,n=``;for(let r=0;r<e.length;r+=t){let i=e.subarray(r,r+t);n+=String.fromCharCode(...i)}return btoa(n)}if(t===`hex`)return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``);if(t===`binary`||t===`latin1`){if(typeof Buffer<`u`)return Buffer.from(e).toString(t);let n=65536;if(e.length<=n)return String.fromCharCode(...e);let r=``;for(let t=0;t<e.length;t+=n){let i=e.subarray(t,t+n);r+=String.fromCharCode(...i)}return r}return HT.decode(e)}function BT(e){if(e!=null)return typeof e==`string`?e:e.encoding??void 0}var VT,HT,UT=T(()=>{VT=new TextEncoder,HT=new TextDecoder});function WT(e){return encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16)}`).replace(/%20/g,`+`).replace(/%[0-9A-F]{2}/g,e=>e.toLowerCase())}function GT(e){let t=e.indexOf(`=`);if(t>=0){let n=e.slice(0,t),r=WT(e.slice(t+1));return n?`${n}=${r}`:r}return WT(e)}function KT(e){let t=e.indexOf(`=`);if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),i,a,o=r.match(/;type=([^;]+)$/);o&&(a=o[1],r=r.slice(0,-o[0].length));let s=r.match(/;filename=([^;]+)/);return s&&(i=s[1],r=r.replace(s[0],``)),(r.startsWith(`@`)||r.startsWith(`<`))&&(i??=r.slice(1).split(`/`).pop()),{name:n,value:r,filename:i,contentType:a}}function qT(e,t){let n=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let i of e){let e=i.value;if(e.startsWith(`@`)||e.startsWith(`<`)){let n=e.slice(1);e=t.get(n)??``}let a=`--${n}\r
796
+ `;i.filename?(a+=`Content-Disposition: form-data; name="${i.name}"; filename="${i.filename}"\r
797
+ `,i.contentType&&(a+=`Content-Type: ${i.contentType}\r
798
+ `)):a+=`Content-Disposition: form-data; name="${i.name}"\r
799
+ `,a+=`\r
800
+ ${e}\r
801
+ `,r.push(a)}return r.push(`--${n}--\r
802
+ `),{body:r.join(``),boundary:n}}var JT=T(()=>{}),YT,XT=T(()=>{YT={name:`curl`,summary:`transfer a URL`,usage:`curl [OPTIONS] URL`,options:[`-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)`,`-H, --header HEADER Add header (can be used multiple times)`,`-d, --data DATA HTTP POST data (DATA=@file reads from file, strips newlines)`,`-G, --get Append data payloads to URL query string`,` --data-raw DATA HTTP POST data (no @ interpretation)`,` --data-binary DATA HTTP POST binary data (DATA=@file reads file verbatim)`,` --data-urlencode DATA URL-encode and POST data (supports @file and name@file)`,`-F, --form NAME=VALUE Multipart form data`,`-u, --user USER:PASS HTTP authentication`,`-A, --user-agent STR Set User-Agent header`,`-e, --referer URL Set Referer header`,`-b, --cookie DATA Send cookies (name=value or @file)`,`-c, --cookie-jar FILE Save cookies to file`,`-T, --upload-file FILE Upload file (PUT)`,`-o, --output FILE Write output to file`,`-O, --remote-name Write to file named from URL`,`-I, --head Show headers only (HEAD request)`,`-i, --include Include response headers in output`,`-s, --silent Silent mode (no progress)`,`-S, --show-error Show errors even when silent`,`-f, --fail Fail silently on HTTP errors (no output)`,`-L, --location Follow redirects (default)`,` --max-redirs NUM Maximum redirects (default: 20)`,`-m, --max-time SECS Maximum time for request`,` --connect-timeout SECS Connection timeout`,`-w, --write-out FMT Output format after completion`,`-v, --verbose Verbose output`,` --help Display this help and exit`,``,`Note: Network access must be configured via BashEnv network option.`,` curl is not available by default for security reasons.`]}});function ZT(e,t,n){n.allowFile&&t.startsWith(`@`)?e.dataParts.push({file:{path:t.slice(1),mode:n.binary?`binary`:`ascii`}}):e.dataParts.push({value:t}),n.binary&&(e.dataBinary=!0)}function QT(e,t){if(t.startsWith(`@`)){e.dataParts.push({file:{path:t.slice(1),mode:`urlencode`}});return}let n=t.indexOf(`@`),r=t.indexOf(`=`);if(n>0&&(r<0||n<r)){e.dataParts.push({file:{path:t.slice(n+1),mode:`urlencode`,name:t.slice(0,n)}});return}e.dataParts.push({value:GT(t)})}function $T(e){let t={method:`GET`,headers:new qb,dataParts:[],dataBinary:!1,getMode:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1},n=!1,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`-X`||a===`--request`)t.method=e[++i]??`GET`,r=!0;else if(a.startsWith(`-X`))t.method=a.slice(2),r=!0;else if(a.startsWith(`--request=`))t.method=a.slice(10),r=!0;else if(a===`-H`||a===`--header`){let n=e[++i];if(n){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();t.headers.append(r,i)}}}else if(a.startsWith(`--header=`)){let e=a.slice(9),n=e.indexOf(`:`);if(n>0){let r=e.slice(0,n).trim(),i=e.slice(n+1).trim();t.headers.append(r,i)}}else if(a===`-G`||a===`--get`)t.getMode=!0,r||(t.method=`GET`);else if(a===`-d`||a===`--data`)ZT(t,e[++i]??``,{binary:!1,allowFile:!0}),n=!0;else if(a===`--data-raw`)ZT(t,e[++i]??``,{binary:!1,allowFile:!1}),n=!0;else if(a.startsWith(`-d`))ZT(t,a.slice(2),{binary:!1,allowFile:!0}),n=!0;else if(a.startsWith(`--data=`))ZT(t,a.slice(7),{binary:!1,allowFile:!0}),n=!0;else if(a.startsWith(`--data-raw=`))ZT(t,a.slice(11),{binary:!1,allowFile:!1}),n=!0;else if(a===`--data-binary`)ZT(t,e[++i]??``,{binary:!0,allowFile:!0}),n=!0;else if(a.startsWith(`--data-binary=`))ZT(t,a.slice(14),{binary:!0,allowFile:!0}),n=!0;else if(a===`--data-urlencode`)QT(t,e[++i]??``),n=!0;else if(a.startsWith(`--data-urlencode=`))QT(t,a.slice(17)),n=!0;else if(a===`-F`||a===`--form`){let r=KT(e[++i]??``);r&&t.formFields.push(r),n=!0}else if(a.startsWith(`--form=`)){let e=KT(a.slice(7));e&&t.formFields.push(e),n=!0}else if(a===`-u`||a===`--user`)t.user=e[++i];else if(a.startsWith(`-u`))t.user=a.slice(2);else if(a.startsWith(`--user=`))t.user=a.slice(7);else if(a===`-A`||a===`--user-agent`)t.headers.set(`User-Agent`,e[++i]??``);else if(a.startsWith(`-A`))t.headers.set(`User-Agent`,a.slice(2));else if(a.startsWith(`--user-agent=`))t.headers.set(`User-Agent`,a.slice(13));else if(a===`-e`||a===`--referer`)t.headers.set(`Referer`,e[++i]??``);else if(a.startsWith(`-e`))t.headers.set(`Referer`,a.slice(2));else if(a.startsWith(`--referer=`))t.headers.set(`Referer`,a.slice(10));else if(a===`-b`||a===`--cookie`)t.headers.set(`Cookie`,e[++i]??``);else if(a.startsWith(`-b`))t.headers.set(`Cookie`,a.slice(2));else if(a.startsWith(`--cookie=`))t.headers.set(`Cookie`,a.slice(9));else if(a===`-c`||a===`--cookie-jar`)t.cookieJar=e[++i];else if(a.startsWith(`--cookie-jar=`))t.cookieJar=a.slice(13);else if(a===`-T`||a===`--upload-file`)t.uploadFile=e[++i],t.method===`GET`&&(t.method=`PUT`);else if(a.startsWith(`--upload-file=`))t.uploadFile=a.slice(14),t.method===`GET`&&(t.method=`PUT`);else if(a===`-m`||a===`--max-time`){let n=parseFloat(e[++i]??`0`);!Number.isNaN(n)&&n>0&&(t.timeoutMs=n*1e3)}else if(a.startsWith(`--max-time=`)){let e=parseFloat(a.slice(11));!Number.isNaN(e)&&e>0&&(t.timeoutMs=e*1e3)}else if(a===`--connect-timeout`){let n=parseFloat(e[++i]??`0`);!Number.isNaN(n)&&n>0&&t.timeoutMs===void 0&&(t.timeoutMs=n*1e3)}else if(a.startsWith(`--connect-timeout=`)){let e=parseFloat(a.slice(18));!Number.isNaN(e)&&e>0&&t.timeoutMs===void 0&&(t.timeoutMs=e*1e3)}else if(a===`-o`||a===`--output`)t.outputFile=e[++i];else if(a.startsWith(`--output=`))t.outputFile=a.slice(9);else if(a===`-O`||a===`--remote-name`)t.useRemoteName=!0;else if(a===`-I`||a===`--head`)t.headOnly=!0,t.method=`HEAD`,r=!0;else if(a===`-i`||a===`--include`)t.includeHeaders=!0;else if(a===`-s`||a===`--silent`)t.silent=!0;else if(a===`-S`||a===`--show-error`)t.showError=!0;else if(a===`-f`||a===`--fail`)t.failSilently=!0;else if(a===`-L`||a===`--location`)t.followRedirects=!0;else if(a===`--max-redirs`){let n=e[++i];if(n===void 0||!/^\d+$/.test(n))return{stdout:``,stderr:`curl: option --max-redirs: expected a non-negative integer
803
+ `,exitCode:2};let r=Number(n);if(!Number.isSafeInteger(r))return{stdout:``,stderr:`curl: option --max-redirs: value is out of range
804
+ `,exitCode:2};t.maxRedirects=r}else if(a.startsWith(`--max-redirs=`)){let e=a.slice(13);if(!/^\d+$/.test(e)||!Number.isSafeInteger(Number(e)))return{stdout:``,stderr:`curl: option --max-redirs: expected a non-negative integer
805
+ `,exitCode:2};t.maxRedirects=Number(e)}else if(a===`-w`||a===`--write-out`)t.writeOut=e[++i];else if(a.startsWith(`--write-out=`))t.writeOut=a.slice(12);else if(a===`-v`||a===`--verbose`)t.verbose=!0;else{if(a.startsWith(`--`)&&a!==`--`)return P(`curl`,a);if(a.startsWith(`-`)&&a!==`-`)for(let e of a.slice(1))switch(e){case`s`:t.silent=!0;break;case`S`:t.showError=!0;break;case`f`:t.failSilently=!0;break;case`L`:t.followRedirects=!0;break;case`I`:t.headOnly=!0,t.method=`HEAD`,r=!0;break;case`i`:t.includeHeaders=!0;break;case`O`:t.useRemoteName=!0;break;case`v`:t.verbose=!0;break;case`G`:t.getMode=!0,r||(t.method=`GET`);break;default:return P(`curl`,`-${e}`)}else a.startsWith(`-`)||(t.url=a)}}return n&&!r&&!t.getMode&&(t.method=`POST`),t}var eE=T(()=>{Yb(),F(),JT()});function tE(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`\r
806
+ `)}function nE(e){try{return new URL(e).pathname.split(`/`).pop()||`index.html`}catch{return`index.html`}}function rE(e,t){let n=e;return n=n.replace(/%\{http_code\}/g,String(t.status)),n=n.replace(/%\{content_type\}/g,t.headers[`content-type`]||``),n=n.replace(/%\{url_effective\}/g,t.url),n=n.replace(/%\{size_download\}/g,String(t.bodyLength)),n=n.replace(/\\n/g,`
807
+ `),n}var iE=T(()=>{}),aE={};E(aE,{curlCommand:()=>pE});async function oE(e,t){if(e.dataParts.length===0)return;let n=[];for(let r of e.dataParts)if(r.file){let e=t.fs.resolvePath(t.cwd,r.file.path),i=await t.fs.readFile(e);if(r.file.mode===`ascii`)n.push(i.replace(/[\r\n]/g,``));else if(r.file.mode===`binary`)n.push(i);else{let e=WT(i);n.push(r.file.name?`${r.file.name}=${e}`:e)}}else n.push(r.value??``);return n.join(`&`)}async function sE(e,t,n){if(e.uploadFile){let n=t.fs.resolvePath(t.cwd,e.uploadFile);return{body:await t.fs.readFile(n)}}if(e.formFields.length>0){let n=new Map;for(let r of e.formFields)if(r.value.startsWith(`@`)||r.value.startsWith(`<`)){let e=t.fs.resolvePath(t.cwd,r.value.slice(1));try{let i=await t.fs.readFile(e);n.set(r.value.slice(1),i)}catch{n.set(r.value.slice(1),``)}}let{body:r,boundary:i}=qT(e.formFields,n);return{body:r,contentType:`multipart/form-data; boundary=${i}`}}return n!==void 0&&!e.getMode?{body:n,contentType:`application/x-www-form-urlencoded`}:{}}function cE(e,t){if(!t)return e;let n=e.indexOf(`#`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n);return`${r}${r.endsWith(`?`)||r.endsWith(`&`)?``:r.includes(`?`)?`&`:`?`}${t}${i}`}function lE(e,t){let n=new qb(e.headers);if(e.user){let t=Buffer.from(e.user).toString(`base64`);n.set(`Authorization`,`Basic ${t}`)}return t&&!n.has(`Content-Type`)&&n.set(`Content-Type`,t),n}async function uE(e,t,n){if(!e.cookieJar)return;let r=t[`set-cookie`];if(!r)return;let i=n.fs.resolvePath(n.cwd,e.cookieJar);await n.fs.writeFile(i,r)}function dE(e){return zT(e,`binary`)}function fE(e,t,n){let r=``;if(e.verbose){r+=`> ${e.method} ${n}
808
+ `;for(let[t,n]of e.headers)r+=`> ${t}: ${n}
809
+ `;r+=`>
810
+ `,r+=`< HTTP/1.1 ${t.status} ${t.statusText}
811
+ `;for(let[e,n]of Object.entries(t.headers))r+=`< ${e}: ${n}
812
+ `;r+=`<
813
+ `}return e.includeHeaders&&!e.verbose&&(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r
814
+ `,r+=tE(t.headers),r+=`\r
815
+ \r
816
+ `),e.headOnly?e.includeHeaders||e.verbose||(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r
817
+ `,r+=tE(t.headers),r+=`\r
818
+ `):r+=dE(t.body),e.writeOut&&(r+=rE(e.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.byteLength})),r}var pE,mE=T(()=>{UT(),ci(),Yb(),F(),JT(),XT(),eE(),iE(),pE={name:`curl`,async execute(e,t){if(N(e))return M(YT);let n=$T(e);if(`exitCode`in n)return n;let r=n;if(!r.url)return{stdout:``,stderr:`curl: no URL specified
819
+ `,exitCode:2};if(!t.fetch)return{stdout:``,stderr:`curl: internal error: fetch not available
820
+ `,exitCode:1};let i=r.url;i.match(/^https?:\/\//)||(i=`https://${i}`);try{let e=await oE(r,t);r.getMode&&(i=cE(i,e));let{body:n,contentType:a}=await sE(r,t,e),o=lE(r,a),s=await t.fetch(i,{method:r.method,headers:o,body:n,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs,maxRedirects:r.maxRedirects,signal:t.signal});if(await uE(r,s.headers,t),r.failSilently&&s.status>=400)return{stdout:``,stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${s.status}
821
+ `:``,exitCode:22};let c=fE(r,s,i);if(r.outputFile||r.useRemoteName){let e=r.outputFile||nE(i),n=t.fs.resolvePath(t.cwd,e);await t.fs.writeFile(n,r.headOnly?``:s.body),r.verbose||(c=``),r.writeOut&&(c=rE(r.writeOut,{status:s.status,headers:s.headers,url:s.url,bodyLength:s.body.byteLength}))}return{stdout:c,stderr:``,exitCode:0,stdoutKind:`bytes`}}catch(e){let t=si(e),n=1;return t.includes(`Network access denied`)?n=7:t.includes(`HTTP method`)&&t.includes(`not allowed`)?n=3:t.includes(`Redirect target not in allow-list`)||t.includes(`Too many redirects`)?n=47:t.includes(`aborted`)&&(n=28),{stdout:``,stderr:!r.silent||r.showError?`curl: (${n}) ${t}
822
+ `:``,exitCode:n}}}}});nr(),ir(),Lr(),qn();var hE=[{name:`echo`,load:async()=>(await Promise.resolve().then(()=>(Hr(),Rr))).echoCommand},{name:`cat`,load:async()=>(await Promise.resolve().then(()=>(oi(),Qr))).catCommand},{name:`printf`,load:async()=>(await Promise.resolve().then(()=>(Li(),yi))).printfCommand},{name:`ls`,load:async()=>(await Promise.resolve().then(()=>(Sa(),ua))).lsCommand},{name:`mkdir`,load:async()=>(await Promise.resolve().then(()=>(Da(),Ca))).mkdirCommand},{name:`rmdir`,load:async()=>(await Promise.resolve().then(()=>(Ia(),Oa))).rmdirCommand},{name:`touch`,load:async()=>(await Promise.resolve().then(()=>(Va(),La))).touchCommand},{name:`rm`,load:async()=>(await Promise.resolve().then(()=>(Ka(),Ha))).rmCommand},{name:`cp`,load:async()=>(await Promise.resolve().then(()=>(Qa(),qa))).cpCommand},{name:`mv`,load:async()=>(await Promise.resolve().then(()=>(io(),$a))).mvCommand},{name:`ln`,load:async()=>(await Promise.resolve().then(()=>(lo(),ao))).lnCommand},{name:`chmod`,load:async()=>(await Promise.resolve().then(()=>(_o(),uo))).chmodCommand},{name:`pwd`,load:async()=>(await Promise.resolve().then(()=>(xo(),vo))).pwdCommand},{name:`readlink`,load:async()=>(await Promise.resolve().then(()=>(Eo(),So))).readlinkCommand},{name:`head`,load:async()=>(await Promise.resolve().then(()=>(Io(),Mo))).headCommand},{name:`tail`,load:async()=>(await Promise.resolve().then(()=>(Vo(),Lo))).tailCommand},{name:`wc`,load:async()=>(await Promise.resolve().then(()=>(Yo(),Ho))).wcCommand},{name:`stat`,load:async()=>(await Promise.resolve().then(()=>(rs(),Qo))).statCommand},{name:`grep`,load:async()=>(await Promise.resolve().then(()=>(ul(),Wc))).grepCommand},{name:`fgrep`,load:async()=>(await Promise.resolve().then(()=>(ul(),Wc))).fgrepCommand},{name:`egrep`,load:async()=>(await Promise.resolve().then(()=>(ul(),Wc))).egrepCommand},{name:`rg`,load:async()=>(await Promise.resolve().then(()=>(yu(),hu))).rgCommand},{name:`sed`,load:async()=>(await Promise.resolve().then(()=>(nd(),Zu))).sedCommand},{name:`awk`,load:async()=>(await Promise.resolve().then(()=>(Lp(),Ap))).awkCommand2},{name:`sort`,load:async()=>(await Promise.resolve().then(()=>(tm(),Zp))).sortCommand},{name:`uniq`,load:async()=>(await Promise.resolve().then(()=>(sm(),nm))).uniqCommand},{name:`comm`,load:async()=>(await Promise.resolve().then(()=>(fm(),cm))).commCommand},{name:`cut`,load:async()=>(await Promise.resolve().then(()=>(ym(),pm))).cutCommand},{name:`paste`,load:async()=>(await Promise.resolve().then(()=>(Em(),bm))).pasteCommand},{name:`tr`,load:async()=>(await Promise.resolve().then(()=>(Pm(),Dm))).trCommand},{name:`rev`,load:async()=>(await Promise.resolve().then(()=>(Bm(),Fm))).rev},{name:`nl`,load:async()=>(await Promise.resolve().then(()=>(Jm(),Vm))).nl},{name:`fold`,load:async()=>(await Promise.resolve().then(()=>(nh(),Ym))).fold},{name:`expand`,load:async()=>(await Promise.resolve().then(()=>(dh(),rh))).expand},{name:`unexpand`,load:async()=>(await Promise.resolve().then(()=>(bh(),fh))).unexpand},{name:`strings`,load:async()=>(await Promise.resolve().then(()=>(Oh(),xh))).strings},{name:`split`,load:async()=>(await Promise.resolve().then(()=>(Kh(),kh))).split},{name:`column`,load:async()=>(await Promise.resolve().then(()=>(ng(),qh))).column},{name:`join`,load:async()=>(await Promise.resolve().then(()=>(dg(),rg))).join},{name:`tee`,load:async()=>(await Promise.resolve().then(()=>(_g(),fg))).teeCommand},{name:`find`,load:async()=>(await Promise.resolve().then(()=>(Kg(),Fg))).findCommand},{name:`basename`,load:async()=>(await Promise.resolve().then(()=>(Zg(),qg))).basenameCommand},{name:`dirname`,load:async()=>(await Promise.resolve().then(()=>(n_(),Qg))).dirnameCommand},{name:`tree`,load:async()=>(await Promise.resolve().then(()=>(u_(),r_))).treeCommand},{name:`du`,load:async()=>(await Promise.resolve().then(()=>(v_(),d_))).duCommand},{name:`env`,load:async()=>(await Promise.resolve().then(()=>(E_(),y_))).envCommand},{name:`printenv`,load:async()=>(await Promise.resolve().then(()=>(E_(),y_))).printenvCommand},{name:`alias`,load:async()=>(await Promise.resolve().then(()=>(P_(),D_))).aliasCommand},{name:`unalias`,load:async()=>(await Promise.resolve().then(()=>(P_(),D_))).unaliasCommand},{name:`history`,load:async()=>(await Promise.resolve().then(()=>(B_(),F_))).historyCommand},{name:`xargs`,load:async()=>(await Promise.resolve().then(()=>(q_(),V_))).xargsCommand},{name:`true`,load:async()=>(await Promise.resolve().then(()=>($_(),J_))).trueCommand},{name:`false`,load:async()=>(await Promise.resolve().then(()=>($_(),J_))).falseCommand},{name:`clear`,load:async()=>(await Promise.resolve().then(()=>(iv(),ev))).clearCommand},{name:`bash`,load:async()=>(await Promise.resolve().then(()=>(fv(),av))).bashCommand},{name:`sh`,load:async()=>(await Promise.resolve().then(()=>(fv(),av))).shCommand},{name:`jq`,load:async()=>(await Promise.resolve().then(()=>(sb(),Qy))).jqCommand},{name:`base64`,load:async()=>(await Promise.resolve().then(()=>(_b(),cb))).base64Command},{name:`diff`,load:async()=>(await Promise.resolve().then(()=>(Cb(),vb))).diffCommand},{name:`date`,load:async()=>(await Promise.resolve().then(()=>(Mb(),wb))).dateCommand},{name:`sleep`,load:async()=>(await Promise.resolve().then(()=>(Bb(),Fb))).sleepCommand},{name:`timeout`,load:async()=>(await Promise.resolve().then(()=>(Gb(),Vb))).timeoutCommand},{name:`time`,load:async()=>(await Promise.resolve().then(()=>(ex(),Xb))).timeCommand},{name:`seq`,load:async()=>(await Promise.resolve().then(()=>(ix(),tx))).seqCommand},{name:`expr`,load:async()=>(await Promise.resolve().then(()=>(lx(),ax))).exprCommand},{name:`md5sum`,load:async()=>(await Promise.resolve().then(()=>(vx(),hx))).md5sumCommand},{name:`sha1sum`,load:async()=>(await Promise.resolve().then(()=>(Sx(),yx))).sha1sumCommand},{name:`sha256sum`,load:async()=>(await Promise.resolve().then(()=>(Ex(),Cx))).sha256sumCommand},{name:`file`,load:async()=>(await Promise.resolve().then(()=>(ww(),mw))).fileCommand},{name:`html-to-markdown`,load:async()=>(await Promise.resolve().then(()=>(kw(),Tw))).htmlToMarkdownCommand},{name:`help`,load:async()=>(await Promise.resolve().then(()=>(Fw(),Aw))).helpCommand},{name:`which`,load:async()=>(await Promise.resolve().then(()=>(Vw(),Iw))).whichCommand},{name:`tac`,load:async()=>(await Promise.resolve().then(()=>(Kw(),Hw))).tac},{name:`hostname`,load:async()=>(await Promise.resolve().then(()=>(Zw(),qw))).hostname},{name:`whoami`,load:async()=>(await Promise.resolve().then(()=>(nT(),Qw))).whoami},{name:`od`,load:async()=>(await Promise.resolve().then(()=>(sT(),rT))).od},{name:`gzip`,load:async()=>(await Promise.resolve().then(()=>(LT(),uT))).gzipCommand},{name:`gunzip`,load:async()=>(await Promise.resolve().then(()=>(LT(),uT))).gunzipCommand},{name:`zcat`,load:async()=>(await Promise.resolve().then(()=>(LT(),uT))).zcatCommand}],gE=[],_E=[],vE=[{name:`curl`,load:async()=>(await Promise.resolve().then(()=>(mE(),aE))).curlCommand}],yE=new Map;function bE(e){return{name:e.name,async execute(t,n){let r=yE.get(e.name);return r||(r=await Kn.runTrustedAsync(()=>e.load()),yE.set(e.name,r)),n.coverage,r.execute(t,n)}}}function xE(){return hE.map(e=>e.name)}function SE(){return vE.map(e=>e.name)}function CE(e){return(e?hE.filter(t=>e.includes(t.name)):hE).map(bE)}function wE(){return vE.map(bE)}function TE(){return gE.map(bE)}function EE(){return _E.map(bE)}k();var DE=new WeakMap,OE=new WeakSet;function kE(e){let t=DE.get(e);return t===void 0&&(t=Object.freeze(Object.create(null)),DE.set(e,t),OE.add(t)),t}function AE(e){return OE.has(e)}var jE={maxSourceBytes:67108864,maxExecDepth:64,maxCallDepth:100,maxCommandCount:1e5,maxLoopIterations:1e5,maxAwkIterations:1e5,maxSedIterations:1e5,maxJqIterations:1e7,maxQueryTokens:1e5,maxQueryDepth:1e3,maxQueryElements:1e6,maxAwkParserTokens:1e5,maxAwkParserDepth:256,maxAwkParserOperations:1e6,maxCsvRows:1e6,maxCsvCells:1e7,maxWorkUnits:1e8,maxTraversalEntries:1e6,maxTraversalDepth:1e3,maxTraversalWork:1e6,maxLiveBytes:536870912,maxInputBytes:536870912,maxFileSystemBytes:1073741824,maxDatabaseBytes:1073741824,maxDatabaseResultBytes:268435456,maxArchiveBytes:1073741824,maxArchiveCompressedBytes:536870912,maxArchiveEntryBytes:536870912,maxArchiveEntries:1e6,maxWorkerMessageBytes:67108864,maxExecutionTimeMs:36e5,maxExtensionCleanupTimeMs:100,maxSqliteTimeoutMs:3e4,maxPythonTimeoutMs:3e4,maxJsTimeoutMs:3e4,maxGlobOperations:1e6,maxStringLength:67108864,maxArrayElements:1e6,maxHeredocSize:67108864,maxSubstitutionDepth:50,maxBraceExpansionResults:1e5,maxOutputSize:268435456,maxFileDescriptors:4096,maxSourceDepth:100},ME={...jE,maxSourceBytes:8388608,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:1e4,maxJsTimeoutMs:1e4,maxExtensionCleanupTimeMs:25,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxBraceExpansionResults:1e4,maxOutputSize:10485760,maxFileDescriptors:1024,maxQueryTokens:25e3,maxQueryDepth:256,maxQueryElements:1e5,maxAwkParserTokens:25e3,maxAwkParserDepth:128,maxAwkParserOperations:1e5,maxCsvRows:1e5,maxCsvCells:1e6,maxWorkUnits:1e5,maxTraversalEntries:1e5,maxTraversalDepth:256,maxTraversalWork:1e5,maxLiveBytes:67108864,maxInputBytes:33554432,maxFileSystemBytes:134217728,maxDatabaseBytes:67108864,maxDatabaseResultBytes:16777216,maxArchiveBytes:134217728,maxArchiveCompressedBytes:67108864,maxArchiveEntryBytes:67108864,maxArchiveEntries:1e5,maxWorkerMessageBytes:16777216,maxExecutionTimeMs:3e4};function NE(e,t=`normal`){if(t!==`normal`&&t!==`hardened`)throw RangeError(`executionLimitProfile must be "normal" or "hardened"`);let n=t===`hardened`?ME:jE;if(!e)return{...n};let r={maxSourceBytes:e.maxSourceBytes??n.maxSourceBytes,maxExecDepth:e.maxExecDepth??n.maxExecDepth,maxCallDepth:e.maxCallDepth??n.maxCallDepth,maxCommandCount:e.maxCommandCount??n.maxCommandCount,maxLoopIterations:e.maxLoopIterations??n.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??n.maxAwkIterations,maxSedIterations:e.maxSedIterations??n.maxSedIterations,maxJqIterations:e.maxJqIterations??n.maxJqIterations,maxQueryTokens:e.maxQueryTokens??n.maxQueryTokens,maxQueryDepth:e.maxQueryDepth??n.maxQueryDepth,maxQueryElements:e.maxQueryElements??n.maxQueryElements,maxAwkParserTokens:e.maxAwkParserTokens??n.maxAwkParserTokens,maxAwkParserDepth:e.maxAwkParserDepth??n.maxAwkParserDepth,maxAwkParserOperations:e.maxAwkParserOperations??n.maxAwkParserOperations,maxCsvRows:e.maxCsvRows??n.maxCsvRows,maxCsvCells:e.maxCsvCells??n.maxCsvCells,maxWorkUnits:e.maxWorkUnits??n.maxWorkUnits,maxTraversalEntries:e.maxTraversalEntries??n.maxTraversalEntries,maxTraversalDepth:e.maxTraversalDepth??n.maxTraversalDepth,maxTraversalWork:e.maxTraversalWork??n.maxTraversalWork,maxLiveBytes:e.maxLiveBytes??n.maxLiveBytes,maxInputBytes:e.maxInputBytes??n.maxInputBytes,maxFileSystemBytes:e.maxFileSystemBytes??n.maxFileSystemBytes,maxDatabaseBytes:e.maxDatabaseBytes??n.maxDatabaseBytes,maxDatabaseResultBytes:e.maxDatabaseResultBytes??n.maxDatabaseResultBytes,maxArchiveBytes:e.maxArchiveBytes??n.maxArchiveBytes,maxArchiveCompressedBytes:e.maxArchiveCompressedBytes??n.maxArchiveCompressedBytes,maxArchiveEntryBytes:e.maxArchiveEntryBytes??n.maxArchiveEntryBytes,maxArchiveEntries:e.maxArchiveEntries??n.maxArchiveEntries,maxWorkerMessageBytes:e.maxWorkerMessageBytes??n.maxWorkerMessageBytes,maxExecutionTimeMs:e.maxExecutionTimeMs??n.maxExecutionTimeMs,maxExtensionCleanupTimeMs:e.maxExtensionCleanupTimeMs??n.maxExtensionCleanupTimeMs,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??n.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??n.maxPythonTimeoutMs,maxJsTimeoutMs:e.maxJsTimeoutMs??n.maxJsTimeoutMs,maxGlobOperations:e.maxGlobOperations??n.maxGlobOperations,maxStringLength:e.maxStringLength??n.maxStringLength,maxArrayElements:e.maxArrayElements??n.maxArrayElements,maxHeredocSize:e.maxHeredocSize??n.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??n.maxSubstitutionDepth,maxBraceExpansionResults:e.maxBraceExpansionResults??n.maxBraceExpansionResults,maxOutputSize:e.maxOutputSize??n.maxOutputSize,maxFileDescriptors:e.maxFileDescriptors??n.maxFileDescriptors,maxSourceDepth:e.maxSourceDepth??n.maxSourceDepth};for(let e of Object.keys(r)){let t=r[e];if(t!==1/0&&(!Number.isSafeInteger(t)||t<0))throw RangeError(`${e} must be a non-negative safe integer or positive Infinity`)}return r}function PE(e){let{executionLimits:t,executionLimitProfile:n,fs:r,stdin:i=gr,...a}=e;return{fs:r,fsIdentity:a.fsIdentity??kE(r),cwd:`/`,env:new Map,stdin:i,limits:NE(t,n),...a}}function FE(e){return`load`in e&&typeof e.load==`function`}function IE(e,t,n={}){return{name:e,trusted:n.trusted!==!1,execute:t}}function LE(e){let t=null,n=null;return{name:e.name,trusted:e.trusted!==!1,async execute(r,i){if(!t){let r=n;r||(r=e.load().then(e=>(t=e,e)),n=r);try{t=await r}catch(e){throw n===r&&(n=null),e}}let a=t;if(!a)throw Error(`Failed to load command: ${e.name}`);return a.execute(r,i)}}}k(),k(),j(),nr();var RE=Object.freeze(Object.create(null)),zE=class{limits;signal;commandCount=0;workUnits=0;liveBytes=0;inputBytes=0;outputBytes=0;countersByKind=new Map;bytesByKind=new Map;depthByKind=new Map;cleanupCallbacks=[];poisoned;closed=!1;startedAt=Date.now();get remainingLiveBytes(){return Math.max(0,this.limits.maxLiveBytes-this.liveBytes)}get outputBytesUsed(){return this.outputBytes}constructor(e,t=void 0){this.limits=e,this.signal=t}fail(e){throw this.poisoned??=e,this.poisoned}poisonAfterAbort(e){this.poisoned??=e}assertUsable(){if(this.poisoned)throw this.poisoned;if(this.closed)throw Error(`execution budget is already closed`);this.throwIfAborted()}chargeCommand(){return this.consume(`commands`,1,`execution`)}consumeWork(e=1,t=`execution`){return this.consume(`work`,e,t)}consumeLimited(e,t,n,r=e){this.assertUsable();let i=this.countersByKind.get(e)??0;return(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n)||n<0||t>n-i)&&this.fail(new A(`${r}: ${e} work limit exceeded (${n})`,`iterations`)),t>this.limits.maxWorkUnits-this.workUnits&&this.fail(new A(`${r}: aggregate work limit exceeded (${this.limits.maxWorkUnits})`,`iterations`)),this.countersByKind.set(e,i+t),this.workUnits+=t,i+t}consumeInput(e,t=`execution`){return this.assertUsable(),(!Number.isSafeInteger(e)||e<0||e>this.limits.maxInputBytes-this.inputBytes)&&this.fail(new A(`${t}: aggregate input size limit exceeded (${this.limits.maxInputBytes} bytes)`,`string_length`)),this.inputBytes+=e,this.inputBytes}consume(e,t=1,n=e){this.assertUsable();let r=this.countersByKind.get(e)??0,i=e===`commands`?this.commandCount:this.workUnits,a=e===`commands`?this.limits.maxCommandCount:this.limits.maxWorkUnits;(!Number.isSafeInteger(t)||t<0||t>a-i)&&this.fail(new A(e===`commands`?`too many commands executed (>${a}), increase executionLimits.maxCommandCount`:`${n}: ${e} work limit exceeded (${a})`,e===`commands`?`commands`:`iterations`));let o=i+t;return e===`commands`?this.commandCount=o:this.workUnits=o,this.countersByKind.set(e,r+t),o}reserveBytes(e,t,n){this.assertUsable();let r=typeof e==`string`?e:`live`,i=typeof e==`string`?t:e,a=typeof e==`string`?n??r:t??`execution`;(!Number.isSafeInteger(i)||i<0||i>this.limits.maxLiveBytes-this.liveBytes)&&this.fail(new A(`${a}: live byte limit exceeded (${this.limits.maxLiveBytes} bytes)`,`string_length`)),this.liveBytes+=i,this.bytesByKind.set(r,(this.bytesByKind.get(r)??0)+i);let o=!1;return{release:()=>{if(o)return;o=!0,this.liveBytes-=i;let e=(this.bytesByKind.get(r)??i)-i;e<=0?this.bytesByKind.delete(r):this.bytesByKind.set(r,e)}}}appendOutput(e,t,n=`execution`,r=0,i=`text`){this.assertUsable();let a=i===`bytes`?t.length:O(t);(!Number.isSafeInteger(r)||r<0||r>a)&&this.fail(new A(`${n}: invalid ${e} accounting`,`output_size`));let o=a-r;return o>this.limits.maxOutputSize-this.outputBytes&&this.fail(new A(`${n}: total output size exceeded (>${this.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,`output_size`)),this.outputBytes+=o,a}accountResult(e,t=`execution`,n=1/0){let r=e.internalOutputAccounting,i=Math.min(r?.stdout??0,n),a=Math.min(r?.stderr??0,Math.max(0,n-i)),o=this.appendOutput(`stdout`,e.stdout,t,i,e.stdoutKind===`bytes`||e.stdoutEncoding===`binary`?`bytes`:`text`),s=this.appendOutput(`stderr`,e.stderr,t,a);return Object.isExtensible(e)?(e.internalOutputAccounting={stdout:o,stderr:s},e):o===0&&s===0?e:{...e,internalOutputAccounting:{stdout:o,stderr:s}}}relinquishOutput(e,t,n){this.assertUsable(),n!==RE&&this.fail(new A(`${t}: unauthorized output accounting release`,`output_size`)),(!Number.isSafeInteger(e)||e<0||e>this.outputBytes)&&this.fail(new A(`${t}: invalid output accounting release`,`output_size`)),this.outputBytes-=e}enterDepth(e,t=this.limits.maxCallDepth,n){this.assertUsable();let r=typeof t==`number`?t:this.limits.maxCallDepth,i=typeof t==`string`?t:n??e,a=this.depthByKind.get(e)??0;a>=r&&this.fail(new A(`${i}: maximum depth (${r}) exceeded`,`recursion`)),this.depthByKind.set(e,a+1);let o=!1;return{release:()=>{if(o)return;o=!0;let t=(this.depthByKind.get(e)??1)-1;t<=0?this.depthByKind.delete(e):this.depthByKind.set(e,t)}}}throwIfAborted(e=`execution`){this.signal?.aborted&&this.fail(new kr(``,`bash: ${e} aborted
823
+ `)),Date.now()-this.startedAt>this.limits.maxExecutionTimeMs&&this.fail(new kr(``,`bash: ${e} exceeded execution deadline (${this.limits.maxExecutionTimeMs}ms)
824
+ `))}remainingTimeMs(){return Math.max(0,this.limits.maxExecutionTimeMs-(Date.now()-this.startedAt))}registerCleanup(e){this.assertUsable(),this.cleanupCallbacks.push(e);let t=!0;return()=>{if(!t)return;t=!1;let n=this.cleanupCallbacks.indexOf(e);n>=0&&this.cleanupCallbacks.splice(n,1)}}async close(){if(this.closed)return;this.closed=!0;let e=[],t=Date.now()+this.limits.maxExtensionCleanupTimeMs;for(let n=this.cleanupCallbacks.length-1;n>=0;n--)try{let r=t-Date.now();if(r<=0){e.push(Error(`execution cleanup grace period exceeded`));break}let i,a=await Promise.race([Promise.resolve().then(this.cleanupCallbacks[n]).then(()=>({ok:!0}),e=>({ok:!1,error:e})),new Promise(e=>{i=Yn(()=>e({ok:!1,error:Error(`execution cleanup grace period exceeded`)}),r)})]);if(Xn(i),!a.ok&&(e.push(a.error),Date.now()>=t))break}catch(t){e.push(t)}if(this.cleanupCallbacks.length=0,this.depthByKind.clear(),this.bytesByKind.clear(),this.liveBytes=0,e.length>0)throw AggregateError(e,`execution cleanup failed`)}assertExecDepth(e){this.assertUsable(),e>this.limits.maxExecDepth&&this.fail(new A(`maximum nested execution depth (${this.limits.maxExecDepth}) exceeded`,`recursion`))}};function BE(e){let t=Object.create(null);return Object.defineProperties(t,{remainingLiveBytes:{enumerable:!0,get:()=>e.remainingLiveBytes},consumeWork:{enumerable:!0,value:e.consumeWork.bind(e)},consumeLimited:{enumerable:!0,value:e.consumeLimited.bind(e)},consumeInput:{enumerable:!0,value:e.consumeInput.bind(e)},reserveBytes:{enumerable:!0,value:e.reserveBytes.bind(e)},enterDepth:{enumerable:!0,value:e.enterDepth.bind(e)},throwIfAborted:{enumerable:!0,value:e.throwIfAborted.bind(e)},remainingTimeMs:{enumerable:!0,value:e.remainingTimeMs.bind(e)},registerCleanup:{enumerable:!0,value:e.registerCleanup.bind(e)}}),Object.freeze(t)}function VE(e,t,n=`pipeline`){e.relinquishOutput(t,n,RE)}k(),UT(),Zi();var HE=new TextEncoder;function UE(e){return typeof e==`object`&&!!e&&!(e instanceof Uint8Array)&&`content`in e}var WE=class{data=new Map;entryIdentities=new WeakMap;nextEntryIdentity=1;maxTotalBytes;retainedBytes=0;contentReferences=new WeakMap;materializedContent(e){return e?.type===`file`&&`content`in e?e.content:null}storedByteLength(e){return e===null?0:e instanceof Uint8Array?e.byteLength:O(e)}wouldReleaseBytes(e){let t=this.materializedContent(e);return t===null?0:t instanceof Uint8Array?this.contentReferences.get(t)===1?t.byteLength:0:this.storedByteLength(t)}assertCanAllocate(e,t){let n=this.wouldReleaseBytes(this.data.get(e));if(!Number.isSafeInteger(t)||t<0||t>this.maxTotalBytes-this.retainedBytes+n)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`)}setEntry(e,t){let n=this.data.get(e),r=this.materializedContent(n),i=this.materializedContent(t);if(r===i){this.data.set(e,t);return}let a=this.wouldReleaseBytes(n),o=i instanceof Uint8Array?this.contentReferences.has(i)?0:i.byteLength:this.storedByteLength(i);if(o>this.maxTotalBytes-this.retainedBytes+a)throw Error(`ENOSPC: in-memory filesystem byte limit exceeded (${this.maxTotalBytes} bytes)`);if(r instanceof Uint8Array){let e=this.contentReferences.get(r)??0;e<=1?this.contentReferences.delete(r):this.contentReferences.set(r,e-1)}i instanceof Uint8Array&&this.contentReferences.set(i,(this.contentReferences.get(i)??0)+1),this.retainedBytes+=o-a,this.data.set(e,t)}deleteEntry(e){let t=this.data.get(e);if(!t)return!1;let n=this.materializedContent(t),r=this.wouldReleaseBytes(t);if(n instanceof Uint8Array){let e=this.contentReferences.get(n)??0;e<=1?this.contentReferences.delete(n):this.contentReferences.set(n,e-1)}return this.retainedBytes-=r,this.data.delete(e)}contentByteLength(e,t){if(e instanceof Uint8Array)return e.byteLength;if(t===`hex`)return Math.floor(e.length/2);if(t===`base64`){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`);return Math.max(0,Math.floor(e.length*3/4)-t)}return t===`binary`||t===`latin1`?e.length:O(e)}identityFor(e){let t=this.entryIdentities.get(e);return t||(t=`memfs:${this.nextEntryIdentity++}`,this.entryIdentities.set(e,t)),t}constructor(e,t={}){if(this.maxTotalBytes=t.maxTotalBytes??1073741824,!Number.isSafeInteger(this.maxTotalBytes)||this.maxTotalBytes<0)throw Error(`InMemoryFs: invalid maxTotalBytes`);if(this.data.set(`/`,{type:`directory`,mode:493,mtime:new Date}),e)for(let[t,n]of Object.entries(e))typeof n==`function`?this.writeFileLazy(t,n):UE(n)?this.writeFileSync(t,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(t,n)}ensureParentDirs(e){let t=qi(e);t!==`/`&&(this.data.has(t)||(this.ensureParentDirs(t),this.data.set(t,{type:`directory`,mode:493,mtime:new Date})))}writeFileSync(e,t,n,r){Ki(e,`write`);let i=I(e);this.ensureParentDirs(i);let a=BT(n);this.assertCanAllocate(i,this.contentByteLength(t,a));let o=RT(t,a);this.setEntry(i,{type:`file`,content:o,mode:r?.mode??420,mtime:r?.mtime??new Date})}writeFileLazy(e,t,n){Ki(e,`write`);let r=I(e);this.ensureParentDirs(r),this.setEntry(r,{type:`file`,lazy:t,mode:n?.mode??420,mtime:n?.mtime??new Date})}async materializeLazy(e,t){let n=await t.lazy(),r=typeof n==`string`?HE.encode(n):n,i={type:`file`,content:r,mode:t.mode,mtime:t.mtime};return this.assertCanAllocate(e,r.byteLength),this.setEntry(e,i),i}async readFile(e,t){return zT(await this.readFileBuffer(e),BT(t))}async readFileBytes(e){return zT(await this.readFileBuffer(e),`binary`)}async readFileBuffer(e){Ki(e,`open`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!==`file`)throw Error(`EISDIR: illegal operation on a directory, read '${e}'`);if(`lazy`in n){let e=await this.materializeLazy(t,n);return e.content instanceof Uint8Array?e.content:HE.encode(e.content)}return n.content instanceof Uint8Array?n.content:HE.encode(n.content)}async writeFile(e,t,n){this.writeFileSync(e,t,n)}async appendFile(e,t,n){Ki(e,`append`);let r=I(e),i=this.data.get(r);if(i&&i.type===`directory`)throw Error(`EISDIR: illegal operation on a directory, write '${e}'`);let a=BT(n),o=this.contentByteLength(t,a);if(i?.type===`file`){let e=i;`lazy`in e&&(e=await this.materializeLazy(r,e));let n=`content`in e&&e.content instanceof Uint8Array?e.content:HE.encode(`content`in e?e.content:``);this.assertCanAllocate(r,n.byteLength+o);let s=RT(t,a),c=new Uint8Array(n.length+s.length);c.set(n),c.set(s,n.length),this.setEntry(r,{type:`file`,content:c,mode:e.mode,mtime:new Date})}else this.writeFileSync(e,t,n)}async exists(e){if(e.includes(`\0`))return!1;try{let t=this.resolvePathWithSymlinks(e);return this.data.has(t)}catch{return!1}}async stat(e){Ki(e,`stat`);let t=this.resolvePathWithSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, stat '${e}'`);n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:HE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}async lstat(e){Ki(e,`lstat`);let t=this.resolveIntermediateSymlinks(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, lstat '${e}'`);if(n.type===`symlink`)return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};n.type===`file`&&`lazy`in n&&(n=await this.materializeLazy(t,n));let r=0;return n.type===`file`&&`content`in n&&n.content&&(r=n.content instanceof Uint8Array?n.content.length:HE.encode(n.content).length),{isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:!1,mode:n.mode,size:r,mtime:n.mtime||new Date,identity:this.identityFor(n)}}resolveIntermediateSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`);if(n.length<=1)return t;let r=``,i=new Set;for(let t=0;t<n.length-1;t++){let a=n[t];r=`${r}/${a}`;let o=this.data.get(r),s=0;for(;o&&o.type===`symlink`&&s<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(r),r=Xi(r,o.target),o=this.data.get(r),s++}if(s>=40)throw Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${r}/${n[n.length-1]}`}resolvePathWithSymlinks(e){let t=I(e);if(t===`/`)return`/`;let n=t.slice(1).split(`/`),r=``,i=new Set;for(let t of n){r=`${r}/${t}`;let n=this.data.get(r),a=0;for(;n&&n.type===`symlink`&&a<40;){if(i.has(r))throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(r),r=Xi(r,n.target),n=this.data.get(r),a++}if(a>=40)throw Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return r}async mkdir(e,t){this.mkdirSync(e,t)}mkdirSync(e,t){Ki(e,`mkdir`);let n=I(e);if(this.data.has(n)){if(this.data.get(n)?.type===`file`)throw Error(`EEXIST: file already exists, mkdir '${e}'`);if(!t?.recursive)throw Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let r=qi(n);if(r!==`/`&&!this.data.has(r))if(t?.recursive)this.mkdirSync(r,{recursive:!0});else throw Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(n,{type:`directory`,mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(e=>e.name)}async readdirWithFileTypes(e){Ki(e,`scandir`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Set;for(;n&&n.type===`symlink`;){if(r.has(t))throw Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);r.add(t),t=Xi(t,n.target),n=this.data.get(t)}if(!n)throw Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!==`directory`)throw Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=t===`/`?`/`:`${t}/`,a=new Map;for(let[e,n]of this.data.entries())if(e!==t&&e.startsWith(i)){let t=e.slice(i.length),r=t.split(`/`)[0];r&&!t.includes(`/`,r.length)&&!a.has(r)&&a.set(r,{name:r,isFile:n.type===`file`,isDirectory:n.type===`directory`,isSymbolicLink:n.type===`symlink`})}return Array.from(a.values()).sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}async rm(e,t){Ki(e,`rm`);let n=I(e),r=this.data.get(n);if(!r){if(t?.force)return;throw Error(`ENOENT: no such file or directory, rm '${e}'`)}if(r.type===`directory`){let r=await this.readdir(n);if(r.length>0){if(!t?.recursive)throw Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let e of r){let r=Yi(n,e);await this.rm(r,t)}}}this.deleteEntry(n)}async cp(e,t,n){Ki(e,`cp`),Ki(t,`cp`);let r=I(e),i=I(t),a=this.data.get(r);if(!a)throw Error(`ENOENT: no such file or directory, cp '${e}'`);if(a.type===`file`)if(this.ensureParentDirs(i),`content`in a){let e=a.content instanceof Uint8Array?a.content.byteLength:HE.encode(a.content).byteLength;this.assertCanAllocate(i,e);let t=a.content instanceof Uint8Array?new Uint8Array(a.content):a.content;this.setEntry(i,{...a,content:t})}else this.setEntry(i,{...a});else if(a.type===`symlink`)this.ensureParentDirs(i),this.data.set(i,{...a});else if(a.type===`directory`){if(!n?.recursive)throw Error(`EISDIR: is a directory, cp '${e}'`);if(Gi(r,i))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(r);for(let e of a){let t=Yi(r,e),a=Yi(i,e);await this.cp(t,a,n)}}}async mv(e,t){Ki(e,`mv`),Ki(t,`mv`);let n=I(e),r=I(t);if(n===r)return;let i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, mv '${e}'`);if(i.type===`directory`&&Gi(n,r))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(i.type===`directory`){await this.mkdir(r,{recursive:!0});let e=await this.readdir(n);for(let t of e)await this.mv(Yi(n,t),Yi(r,t));this.deleteEntry(n);return}this.ensureParentDirs(r),this.setEntry(r,i),this.deleteEntry(n)}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,t){return Ji(e,t)}async chmod(e,t){Ki(e,`chmod`);let n=I(e),r=this.data.get(n);if(!r)throw Error(`ENOENT: no such file or directory, chmod '${e}'`);r.mode=t}async symlink(e,t){Ki(t,`symlink`);let n=I(t);if(this.data.has(n))throw Error(`EEXIST: file already exists, symlink '${t}'`);this.ensureParentDirs(n),this.data.set(n,{type:`symlink`,target:e,mode:511,mtime:new Date})}async link(e,t){Ki(e,`link`),Ki(t,`link`);let n=I(e),r=I(t),i=this.data.get(n);if(!i)throw Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!==`file`)throw Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(r))throw Error(`EEXIST: file already exists, link '${t}'`);let a=i;`lazy`in a&&(a=await this.materializeLazy(n,a)),this.ensureParentDirs(r);let o={type:`file`,content:a.content,mode:a.mode,mtime:a.mtime};this.entryIdentities.set(o,this.identityFor(a)),this.setEntry(r,o)}async readlink(e){Ki(e,`readlink`);let t=I(e),n=this.data.get(t);if(!n)throw Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!==`symlink`)throw Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}async realpath(e){Ki(e,`realpath`);let t=this.resolvePathWithSymlinks(e);if(!this.data.has(t))throw Error(`ENOENT: no such file or directory, realpath '${e}'`);return t}async utimes(e,t,n){Ki(e,`utimes`);let r=I(e),i=this.resolvePathWithSymlinks(r),a=this.data.get(i);if(!a)throw Error(`ENOENT: no such file or directory, utimes '${e}'`);a.mtime=n}},GE=`5.1.0(1)-release`,KE=`Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT`;function qE(e){let{pid:t,ppid:n,uid:r,gid:i}=e;return`Name: bash
825
+ State: R (running)
826
+ Pid: ${t}
827
+ PPid: ${n}
828
+ Uid: ${r} ${r} ${r} ${r}
829
+ Gid: ${i} ${i} ${i} ${i}
830
+ `}function JE(e){let t=e;return typeof t.mkdirSync==`function`&&typeof t.writeFileSync==`function`}function YE(e,t){e.mkdirSync(`/bin`,{recursive:!0}),e.mkdirSync(`/usr/bin`,{recursive:!0}),t&&(e.mkdirSync(`/home/user`,{recursive:!0}),e.mkdirSync(`/tmp`,{recursive:!0}))}function XE(e){e.mkdirSync(`/dev`,{recursive:!0}),e.mkdirSync(`/dev/fd`,{recursive:!0}),e.writeFileSync(`/dev/null`,``),e.writeFileSync(`/dev/zero`,new Uint8Array),e.writeFileSync(`/dev/stdin`,``),e.writeFileSync(`/dev/stdout`,``),e.writeFileSync(`/dev/stderr`,``)}function ZE(e,t){e.mkdirSync(`/proc/self/fd`,{recursive:!0}),e.writeFileSync(`/proc/version`,`${KE}
831
+ `),e.writeFileSync(`/proc/self/exe`,`/bin/bash`),e.writeFileSync(`/proc/self/cmdline`,`bash\0`),e.writeFileSync(`/proc/self/comm`,`bash
832
+ `),e.writeFileLazy?e.writeFileLazy(`/proc/self/status`,()=>qE(t)):e.writeFileSync(`/proc/self/status`,qE(t)),e.writeFileSync(`/proc/self/fd/0`,`/dev/stdin`),e.writeFileSync(`/proc/self/fd/1`,`/dev/stdout`),e.writeFileSync(`/proc/self/fd/2`,`/dev/stderr`)}function QE(e,t,n={pid:1,ppid:0,uid:1e3,gid:1e3}){JE(e)&&(YE(e,t),XE(e),ZE(e,n))}ea(),od(),j(),k(),j();function $E(e){return{kind:e.kind,elements:new Map(e.elements)}}function eD(e){return new Map(Array.from(e??[],([e,t])=>[e,$E(t)]))}function tD(e,t){return e.state.arrays?.get(t)}function nD(e,t,n=`indexed`){e.state.arrays??=new Map;let r=e.state.arrays.get(t);return r||(r={kind:n,elements:new Map},e.state.arrays.set(t,r)),r}function rD(e,t,n){let r=nD(e,t,n);return r.kind=n,r}function iD(e,t){return e.state.arrays?.has(t)??!1}function aD(e,t,n){return tD(e,t)?.elements.get(String(n))}function oD(e,t,n){return tD(e,t)?.elements.has(String(n))??!1}function Y(e,t,n,r,i){let a=nD(e,t,i),o=String(n);if(!a.elements.has(o)&&a.elements.size>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(O(r)>e.limits.maxStringLength)throw new A(`array value string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);a.elements.set(o,r)}function sD(e,t,n,r=!1){let i=new Set(r?[]:tD(e,t)?.elements.keys()??[]);for(let t of n)if(i.add(String(t)),i.size>e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`)}function cD(e,t,n){return tD(e,t)?.elements.delete(String(n))??!1}function lD(e,t){e.state.arrays?.delete(t),e.state.associativeArrays?.delete(t)}function uD(e,t){return Array.from(tD(e,t)?.elements.keys()??[]).filter(e=>/^(0|[1-9]\d*)$/.test(e)).map(Number).sort((e,t)=>e-t)}function dD(e,t){nD(e,t,e.state.associativeArrays?.has(t)?`associative`:`indexed`).elements.clear()}function fD(e,t){return Array.from(tD(e,t)?.elements.keys()??[]).sort()}function pD(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function mD(e){if(e.parts.length<2)return null;let t=e.parts[0],n=e.parts[1];if(t.type!==`Glob`||!t.pattern.startsWith(`[`))return null;let r,i=n,a=1;if(n.type===`Literal`&&n.value.startsWith(`]`)){let o=n.value.slice(1);if(o.startsWith(`+=`)||o.startsWith(`=`))r=t.pattern.slice(1);else if(o===``){if(e.parts.length<3)return null;let n=e.parts[2];if(n.type!==`Literal`||!n.value.startsWith(`=`)&&!n.value.startsWith(`+=`))return null;r=t.pattern.slice(1),i=n,a=2}else return null}else if(t.pattern===`[`&&(n.type===`DoubleQuoted`||n.type===`SingleQuoted`)){if(e.parts.length<3)return null;let t=e.parts[2];if(t.type!==`Literal`||!t.value.startsWith(`]=`)&&!t.value.startsWith(`]+=`))return null;if(n.type===`SingleQuoted`)r=n.value;else{r=``;for(let e of n.parts)(e.type===`Literal`||e.type===`Escaped`)&&(r+=e.value)}i=t,a=2}else if(t.pattern.endsWith(`]`)){if(n.type!==`Literal`||!n.value.startsWith(`=`)&&!n.value.startsWith(`+=`))return null;r=t.pattern.slice(1,-1)}else return null;r=pD(r);let o;if(i.type!==`Literal`)return null;o=i.value.startsWith(`]=`)||i.value.startsWith(`]+=`)?i.value.slice(1):i.value;let s=o.startsWith(`+=`);if(!s&&!o.startsWith(`=`))return null;let c=[],l=s?2:1,u=o.slice(l);u&&c.push({type:`Literal`,value:u});for(let t=a+1;t<e.parts.length;t++){let n=e.parts[t];n.type===`BraceExpansion`?c.push({type:`Literal`,value:hD(n)}):c.push(n)}return{key:r,valueParts:c,append:s}}function hD(e){return`{${e.items.map(e=>{if(e.type===`Range`){let t=`${e.startStr??String(e.start)}..${e.endStr??String(e.end)}`;return e.step&&(t+=`..${e.step}`),t}return gD(e.word)}).join(`,`)}}`}function gD(e){let t=``;for(let n of e.parts)switch(n.type){case`Literal`:t+=n.value;break;case`Glob`:t+=n.pattern;break;case`SingleQuoted`:t+=n.value;break;case`DoubleQuoted`:for(let e of n.parts)(e.type===`Literal`||e.type===`Escaped`)&&(t+=e.value);break;case`Escaped`:t+=n.value;break;case`BraceExpansion`:t+=`{`,t+=n.items.map(e=>e.type===`Range`?`${e.startStr}..${e.endStr}${e.step?`..${e.step}`:``}`:gD(e.word)).join(`,`),t+=`}`;break;case`TildeExpansion`:t+=`~`,n.user&&(t+=n.user);break}return t}var _D=[`allexport`,`errexit`,`noglob`,`noclobber`,`noexec`,`nounset`,`pipefail`,`posix`,`verbose`,`xtrace`],vD=[`braceexpand`,`hashall`,`interactive-comments`];function yD(e){let t=[],n=[...vD.map(e=>({name:e,enabled:!0})),..._D.map(t=>({name:t,enabled:e[t]}))].sort((e,t)=>e.name.localeCompare(t.name));for(let e of n)e.enabled&&t.push(e.name);return t.join(`:`)}function bD(e){e.state.env.set(`SHELLOPTS`,yD(e.state.options))}var xD=[`dotglob`,`expand_aliases`,`extglob`,`failglob`,`globskipdots`,`globstar`,`lastpipe`,`nocaseglob`,`nocasematch`,`nullglob`,`xpg_echo`];function SD(e){let t=[];for(let n of xD)e[n]&&t.push(n);return t.join(`:`)}function CD(e){e.state.env.set(`BASHOPTS`,SD(e.state.shoptOptions))}k(),yg(),od();var X={script(e){return{type:`Script`,statements:e}},statement(e,t=[],n=!1,r,i){let a={type:`Statement`,pipelines:e,operators:t,background:n};return r&&(a.deferredError=r),i!==void 0&&(a.sourceText=i),a},pipeline(e,t=!1,n=!1,r=!1,i){return{type:`Pipeline`,commands:e,negated:t,timed:n,timePosix:r,pipeStderr:i}},simpleCommand(e,t=[],n=[],r=[]){return{type:`SimpleCommand`,name:e,args:t,assignments:n,redirections:r}},word(e){return{type:`Word`,parts:e}},literal(e){return{type:`Literal`,value:e}},singleQuoted(e){return{type:`SingleQuoted`,value:e}},doubleQuoted(e){return{type:`DoubleQuoted`,parts:e}},escaped(e){return{type:`Escaped`,value:e}},parameterExpansion(e,t=null){return{type:`ParameterExpansion`,parameter:e,operation:t}},commandSubstitution(e,t=!1){return{type:`CommandSubstitution`,body:e,legacy:t}},arithmeticExpansion(e){return{type:`ArithmeticExpansion`,expression:e}},processSubstitution(e,t){return{type:`ProcessSubstitution`,body:e,direction:t}},assignment(e,t,n=!1,r=null){return{type:`Assignment`,name:e,value:t,append:n,array:r}},redirection(e,t,n=null,r){let i={type:`Redirection`,fd:n,operator:e,target:t};return r&&(i.fdVariable=r),i},hereDoc(e,t,n=!1,r=!1,i){let a={type:`HereDoc`,delimiter:e,content:t,stripTabs:n,quoted:r};return i!==void 0&&(a.terminated=i),a},ifNode(e,t=null,n=[]){return{type:`If`,clauses:e,elseBody:t,redirections:n}},forNode(e,t,n,r=[]){return{type:`For`,variable:e,words:t,body:n,redirections:r}},whileNode(e,t,n=[]){return{type:`While`,condition:e,body:t,redirections:n}},untilNode(e,t,n=[]){return{type:`Until`,condition:e,body:t,redirections:n}},caseNode(e,t,n=[]){return{type:`Case`,word:e,items:t,redirections:n}},caseItem(e,t,n=`;;`){return{type:`CaseItem`,patterns:e,body:t,terminator:n}},subshell(e,t=[]){return{type:`Subshell`,body:e,redirections:t}},group(e,t=[]){return{type:`Group`,body:e,redirections:t}},functionDef(e,t,n=[],r){return{type:`FunctionDef`,name:e,body:t,redirections:n,sourceFile:r}},conditionalCommand(e,t=[],n){return{type:`ConditionalCommand`,expression:e,redirections:t,line:n}},arithmeticCommand(e,t=[],n){return{type:`ArithmeticCommand`,expression:e,redirections:t,line:n}}};function wD(e,t){let n=e.length,r=t+3,i=2,a=!1,o=!1;for(;r<n&&i>0;){let t=e[r];if(a){t===`'`&&(a=!1),r++;continue}if(o){if(t===`\\`){r+=2;continue}t===`"`&&(o=!1),r++;continue}if(t===`'`){a=!0,r++;continue}if(t===`"`){o=!0,r++;continue}if(t===`\\`){r+=2;continue}if(t===`(`){i++,r++;continue}if(t===`)`){if(i--,i===1){let t=r+1;return!(t<n&&e[t]===`)`)}if(i===0)return!1;r++;continue}if(i===1&&(t===`|`&&r+1<n&&e[r+1]===`|`||t===`&`&&r+1<n&&e[r+1]===`&`||t===`|`&&r+1<n&&e[r+1]!==`|`))return!0;r++}return!1}function TD(e,t){let n=``,r=t,i=0,a=!1,o,s=e=>e===` `||e===` `||e===`
833
+ `||e===`;`||e===`&`||e===`|`||e===`<`||e===`>`||e===`(`||e===`)`;for(;r<e.length;){let t=e[r];if(t===`'`){let s=i>0;for(s||(a=!0),s&&(n+=t),r++;r<e.length&&e[r]!==`'`;)n+=e[r],r++;r<e.length?(s&&(n+=e[r]),r++):o=t;continue}if(t===`"`){let s=i>0;for(s||(a=!0),s&&(n+=t),r++;r<e.length&&e[r]!==`"`;){if(e[r]===`\\`&&r+1<e.length){if(s){n+=e.slice(r,r+2),r+=2;continue}let t=e[r+1];if(t===`$`||t==="`"||t===`"`||t===`\\`||t===`
834
+ `){r+=2,t!==`
835
+ `&&(n+=t);continue}}n+=e[r],r++}r<e.length?(s&&(n+=e[r]),r++):o=t;continue}if(t===`\\`&&r+1<e.length){if(i>0){n+=e.slice(r,r+2),r+=2;continue}a=!0;let t=e[r+1];t!==`
836
+ `&&(n+=t),r+=2;continue}if(i===0&&(t===`$`||t===`<`||t===`>`)&&e[r+1]===`(`){n+=`${t}(`,i=1,r+=2;continue}if(i===0&&s(t))break;i>0&&(t===`(`?i++:t===`)`&&i--),n+=t,r++}return{delim:n,endPos:r,quoted:a,unclosedQuote:o,unclosedSubstitution:i>0}}function ED(e,t,n){let r=t+1;for(let{delim:t,stripTabs:i}of n)for(;;){if(r>=e.length)return e.length;let n=e.indexOf(`
837
+ `,r);n===-1&&(n=e.length);let a=e.slice(r,n);if(i&&(a=a.replace(/^\t+/,``)),a===t){r=n+1;break}if(n>=e.length)return e.length;r=n+1}return Math.min(r,e.length)}function DD(e,t,n){let r=1,i=t,a=!1,o=!1,s=0,c=!1,l=``,u=[],d=0;for(;i<e.length&&r>0;){let t=e[i];if(a)t===`'`&&(a=!1);else if(o)t===`\\`&&i+1<e.length?i++:t===`"`&&(o=!1);else{if(t===`(`&&e[i+1]===`(`?d++:t===`)`&&e[i+1]===`)`&&d>0&&d--,d===0&&t===`<`&&e[i+1]===`<`&&e[i+2]!==`<`){let t=i+2,r=!1;for(e[t]===`-`&&(r=!0,t++);e[t]===` `||e[t]===` `;)t++;let{delim:a,endPos:o,unclosedQuote:s,unclosedSubstitution:c}=TD(e,t);if(s&&n(`unexpected EOF while looking for matching \`${s}'`),c&&n("unexpected EOF while looking for matching `)'"),a.length>0){u.push({delim:a,stripTabs:r}),l=``,i=o;continue}}if(t===`
838
+ `&&u.length>0){let t=ED(e,i,u);u.length=0,l=``,i=t;continue}t===`'`?(a=!0,l=``):t===`"`?(o=!0,l=``):t===`\\`&&i+1<e.length?(i++,l=``):/[a-zA-Z_]/.test(t)?l+=t:(l===`case`?(s++,c=!1):l===`in`&&s>0?c=!0:l===`esac`&&s>0&&(s--,c=!1),l=``,t===`(`?i>0&&e[i-1]===`$`?r++:c||r++:t===`)`?c?c=!1:r--:t===`;`&&s>0&&i+1<e.length&&e[i+1]===`;`&&(c=!0))}r>0&&i++}return r>0&&n("unexpected EOF while looking for matching `)'"),i}function OD(e,t,n,r){let i=t+2,a=DD(e,i,r),o=e.slice(i,a),s=n().parse(o);return{part:X.commandSubstitution(s,!1),endIndex:a+1}}function kD(e,t,n,r){let i=e[t]===`<`?`input`:`output`,a=t+2,o=DD(e,a,r),s=n().parse(e.slice(a,o));return{part:X.processSubstitution(s,i),endIndex:o+1}}function AD(e,t,n,r,i){let a=t+1,o=``;for(;a<e.length&&e[a]!=="`";)if(e[a]===`\\`){let t=e[a+1];t===`$`||t==="`"||t===`\\`||t===`
839
+ `||n&&t===`"`?(t!==`
840
+ `&&(o+=t),a+=2):(o+=e[a],a++)}else o+=e[a],a++;a>=e.length&&i("unexpected EOF while looking for matching ``'");let s=r().parse(o);return{part:X.commandSubstitution(s,!0),endIndex:a+1}}var jD=10485760,Z;(function(e){e.EOF=`EOF`,e.NEWLINE=`NEWLINE`,e.SEMICOLON=`SEMICOLON`,e.AMP=`AMP`,e.PIPE=`PIPE`,e.PIPE_AMP=`PIPE_AMP`,e.AND_AND=`AND_AND`,e.OR_OR=`OR_OR`,e.BANG=`BANG`,e.LESS=`LESS`,e.GREAT=`GREAT`,e.DLESS=`DLESS`,e.DGREAT=`DGREAT`,e.LESSAND=`LESSAND`,e.GREATAND=`GREATAND`,e.LESSGREAT=`LESSGREAT`,e.DLESSDASH=`DLESSDASH`,e.CLOBBER=`CLOBBER`,e.TLESS=`TLESS`,e.AND_GREAT=`AND_GREAT`,e.AND_DGREAT=`AND_DGREAT`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.DSEMI=`DSEMI`,e.SEMI_AND=`SEMI_AND`,e.SEMI_SEMI_AND=`SEMI_SEMI_AND`,e.DBRACK_START=`DBRACK_START`,e.DBRACK_END=`DBRACK_END`,e.DPAREN_START=`DPAREN_START`,e.DPAREN_END=`DPAREN_END`,e.IF=`IF`,e.THEN=`THEN`,e.ELSE=`ELSE`,e.ELIF=`ELIF`,e.FI=`FI`,e.FOR=`FOR`,e.WHILE=`WHILE`,e.UNTIL=`UNTIL`,e.DO=`DO`,e.DONE=`DONE`,e.CASE=`CASE`,e.ESAC=`ESAC`,e.IN=`IN`,e.FUNCTION=`FUNCTION`,e.SELECT=`SELECT`,e.TIME=`TIME`,e.COPROC=`COPROC`,e.WORD=`WORD`,e.NAME=`NAME`,e.NUMBER=`NUMBER`,e.ASSIGNMENT_WORD=`ASSIGNMENT_WORD`,e.FD_VARIABLE=`FD_VARIABLE`,e.COMMENT=`COMMENT`,e.HEREDOC_CONTENT=`HEREDOC_CONTENT`})(Z||={});var MD=class extends Error{line;column;constructor(e,t,n){super(`line ${t}: ${e}`),this.line=t,this.column=n,this.name=`LexerError`}},ND=new Map([[`if`,Z.IF],[`then`,Z.THEN],[`else`,Z.ELSE],[`elif`,Z.ELIF],[`fi`,Z.FI],[`for`,Z.FOR],[`while`,Z.WHILE],[`until`,Z.UNTIL],[`do`,Z.DO],[`done`,Z.DONE],[`case`,Z.CASE],[`esac`,Z.ESAC],[`in`,Z.IN],[`function`,Z.FUNCTION],[`select`,Z.SELECT],[`time`,Z.TIME],[`coproc`,Z.COPROC]]),PD=new Set(ND.values());function FD(e){return PD.has(e)}function ID(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let n=e.slice(t[0].length);if(n===``||n===`+`)return!0;if(n[0]===`[`){let e=0,t=0;for(;t<n.length;t++)if(n[t]===`[`)e++;else if(n[t]===`]`&&(e--,e===0))break;if(e!==0||t>=n.length)return!1;let r=n.slice(t+1);return r===``||r===`+`}return!1}function LD(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r===`[`)t++;else if(r===`]`)t--;else{if(t===0&&r===`=`)return n;if(t===0&&r===`+`&&e[n+1]===`=`)return n+1}}return-1}var RD=[[`;`,`;`,`&`,Z.SEMI_SEMI_AND],[`<`,`<`,`<`,Z.TLESS],[`&`,`>`,`>`,Z.AND_DGREAT]],zD=[[`[`,`[`,Z.DBRACK_START],[`]`,`]`,Z.DBRACK_END],[`(`,`(`,Z.DPAREN_START],[`)`,`)`,Z.DPAREN_END],[`&`,`&`,Z.AND_AND],[`|`,`|`,Z.OR_OR],[`;`,`;`,Z.DSEMI],[`;`,`&`,Z.SEMI_AND],[`|`,`&`,Z.PIPE_AMP],[`>`,`>`,Z.DGREAT],[`<`,`&`,Z.LESSAND],[`>`,`&`,Z.GREATAND],[`<`,`>`,Z.LESSGREAT],[`>`,`|`,Z.CLOBBER],[`&`,`>`,Z.AND_GREAT]],BD=new Map([[`|`,Z.PIPE],[`&`,Z.AMP],[`;`,Z.SEMICOLON],[`(`,Z.LPAREN],[`)`,Z.RPAREN],[`<`,Z.LESS],[`>`,Z.GREAT]]);function VD(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function HD(e){return e===` `||e===` `||e===`
841
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`}var UD=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];pendingHeredocDelimiterMode;dparenDepth=0;maxHeredocSize;constructor(e,t){this.input=e,this.maxHeredocSize=t?.maxHeredocSize??jD}tokenize(){let e=this.input.length,t=this.tokens,n=this.pendingHeredocs;for(;this.pos<e;){if(n.length>0&&t.length>0&&t[t.length-1].type===Z.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=e)break;let r=this.nextToken();r&&t.push(r)}return n.length>0&&this.readHeredocContent(),t.push({type:Z.EOF,value:``,start:this.pos,end:this.pos,line:this.line,column:this.column}),t}skipWhitespace(){let e=this.input,t=e.length,n=this.pos,r=this.column,i=this.line;for(;n<t;){let t=e[n];if(t===` `||t===` `)n++,r++;else if(t===`\\`&&e[n+1]===`
842
+ `)n+=2,i++,r=1;else break}this.pos=n,this.column=r,this.line=i}nextToken(){let e=this.input,t=this.pos,n=this.line,r=this.column,i=e[t],a=e[t+1],o=e[t+2],s=this.pendingHeredocDelimiterMode;if(this.pendingHeredocDelimiterMode=void 0,s!==void 0&&i!==`
843
+ `&&(i!==`#`||this.dparenDepth!==0))return this.readHeredocDelimiterToken(t,n,r,s);if(i===`#`&&this.dparenDepth===0)return this.readComment(t,n,r);if(i===`
844
+ `)return this.pos=t+1,this.line++,this.column=1,{type:Z.NEWLINE,value:`
845
+ `,start:t,end:t+1,line:n,column:r};if(i===`<`&&a===`<`&&o===`-`)return this.pos=t+3,this.column=r+3,this.pendingHeredocDelimiterMode=!0,this.makeToken(Z.DLESSDASH,`<<-`,t,n,r);for(let[e,s,c,l]of RD)if(i===e&&a===s&&o===c)return this.pos=t+3,this.column=r+3,this.makeToken(l,e+s+c,t,n,r);if(i===`<`&&a===`<`)return this.pos=t+2,this.column=r+2,this.pendingHeredocDelimiterMode=!1,this.makeToken(Z.DLESS,`<<`,t,n,r);if(i===`(`&&a===`(`){let e=this.tokens[this.tokens.length-1];return this.dparenDepth===0&&e?.end===t&&(e.type===Z.LESS||e.type===Z.GREAT)?(this.pos=t+1,this.column=r+1,this.makeToken(Z.LPAREN,`(`,t,n,r)):this.dparenDepth>0?(this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(Z.LPAREN,`(`,t,n,r)):this.looksLikeNestedSubshells(t+2)||this.dparenClosesWithSpacedParens(t+2)?(this.pos=t+1,this.column=r+1,this.makeToken(Z.LPAREN,`(`,t,n,r)):(this.pos=t+2,this.column=r+2,this.dparenDepth=1,this.makeToken(Z.DPAREN_START,`((`,t,n,r))}if(i===`)`&&a===`)`)return this.dparenDepth===1?(this.pos=t+2,this.column=r+2,this.dparenDepth=0,this.makeToken(Z.DPAREN_END,`))`,t,n,r)):this.dparenDepth>1?(this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(Z.RPAREN,`)`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(Z.RPAREN,`)`,t,n,r));for(let[o,s,c]of zD)if(!(o===`(`&&s===`(`||o===`)`&&s===`)`)&&!(this.dparenDepth>0&&o===`;`&&(c===Z.DSEMI||c===Z.SEMI_AND||c===Z.SEMI_SEMI_AND))&&i===o&&a===s){if(c===Z.DBRACK_START||c===Z.DBRACK_END){let n=e[t+2];if(n!==void 0&&n!==` `&&n!==` `&&n!==`
846
+ `&&n!==`;`&&n!==`&`&&n!==`|`&&n!==`(`&&n!==`)`&&n!==`<`&&n!==`>`)break}return this.pos=t+2,this.column=r+2,this.makeToken(c,o+s,t,n,r)}if(i===`(`&&this.dparenDepth>0)return this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(Z.LPAREN,`(`,t,n,r);if(i===`)`&&this.dparenDepth>1)return this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(Z.RPAREN,`)`,t,n,r);let c=BD.get(i);if(c!==void 0)return this.pos=t+1,this.column=r+1,this.makeToken(c,i,t,n,r);if(i===`{`){let e=this.scanFdVariable(t);return e===null?a===`}`?(this.pos=t+2,this.column=r+2,{type:Z.WORD,value:`{}`,start:t,end:t+2,line:n,column:r,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(t)===null&&this.scanLiteralBraceWord(t)===null?a!==void 0&&a!==` `&&a!==` `&&a!==`
847
+ `?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(Z.LBRACE,`{`,t,n,r)):this.readWordWithBraceExpansion(t,n,r):(this.pos=e.end,this.column=r+(e.end-t),{type:Z.FD_VARIABLE,value:e.varname,start:t,end:e.end,line:n,column:r})}return i===`}`?this.isWordCharFollowing(t+1)?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(Z.RBRACE,`}`,t,n,r)):i===`!`?a===`=`?(this.pos=t+2,this.column=r+2,this.makeToken(Z.WORD,`!=`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(Z.BANG,`!`,t,n,r)):this.readWord(t,n,r)}looksLikeNestedSubshells(e){let t=this.input,n=t.length,r=e;for(;r<n&&(t[r]===` `||t[r]===` `);)r++;if(r>=n)return!1;let i=t[r];if(i===`(`)return this.looksLikeNestedSubshells(r+1);let a=/[a-zA-Z_]/.test(i),o=i===`!`||i===`[`;if(!a&&!o)return!1;let s=r;for(;s<n&&/[a-zA-Z0-9_\-.]/.test(t[s]);)s++;if(s===r)return o;let c=s;for(;c<n&&(t[c]===` `||t[c]===` `);)c++;if(c>=n)return!1;let l=t[c];if(l===`=`&&t[c+1]!==`=`||l===`
848
+ `||s===c&&/[+\-*/%<>&|^!~?:]/.test(l)&&l!==`-`||l===`)`&&t[c+1]===`)`)return!1;if(c>s&&(l===`-`||l===`"`||l===`'`||l===`$`||/[a-zA-Z_/.]/.test(l))){let e=c;for(;e<n&&t[e]!==`
849
+ `;){if(t[e]===`)`)return!0;e++}return!1}if(l===`)`){let e=c+1;for(;e<n&&(t[e]===` `||t[e]===` `);)e++;if(t[e]===`|`&&t[e+1]===`|`||t[e]===`&`&&t[e+1]===`&`||t[e]===`;`||t[e]===`|`&&t[e+1]!==`|`)return!0}return!1}makeToken(e,t,n,r,i){return{type:e,value:t,start:n,end:this.pos,line:r,column:i}}readComment(e,t,n){let r=this.input,i=r.length,a=this.pos;for(;a<i&&r[a]!==`
850
+ `;)a++;let o=r.slice(e,a);return this.pos=a,this.column=n+(a-e),{type:Z.COMMENT,value:o,start:e,end:a,line:t,column:n}}readWord(e,t,n){let r=this.input,i=r.length,a=this.pos,o=a;for(;a<i;){let e=r[a];if(e===` `||e===` `||e===`
851
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`||e===`'`||e===`"`||e===`\\`||e===`$`||e==="`"||e===`{`||e===`}`||e===`~`||e===`*`||e===`?`||e===`[`)break;a++}if(a>o){let s=r[a];if(!(s===`(`&&a>o&&`@*+?!`.includes(r[a-1]))&&(a>=i||s===` `||s===` `||s===`
852
+ `||s===`;`||s===`&`||s===`|`||s===`(`||s===`)`||s===`<`||s===`>`)){let i=r.slice(o,a);this.pos=a,this.column=n+(a-o);let s=ND.get(i);if(s!==void 0)return{type:s,value:i,start:e,end:a,line:t,column:n};let c=LD(i);return c>0&&ID(i.slice(0,c))?{type:Z.ASSIGNMENT_WORD,value:i,start:e,end:a,line:t,column:n}:/^[0-9]+$/.test(i)?{type:Z.NUMBER,value:i,start:e,end:a,line:t,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?{type:Z.NAME,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}:{type:Z.WORD,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}}a=this.pos;let s=this.column,c=this.line,l=``,u=!1,d=!1,f=!1,p=!1,m=r[a]===`"`||r[a]===`'`,h=!1,g=0;for(;a<i;){let e=r[a];if(!f&&!p){if(e===`(`&&l.length>0&&`@*+?!`.includes(l[l.length-1])){let e=this.scanExtglobPattern(a);if(e!==null){l+=e.content,a=e.end,s+=e.content.length;continue}}if(e===`[`&&g===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){let t=a+1<i?r[a+1]:``;if(t===`^`||t===`!`){l+=e,a++,s++;continue}g=1,l+=e,a++,s++;continue}}else if(e===`[`&&g>0){l.length>0&&l[l.length-1]!==`\\`&&g++,l+=e,a++,s++;continue}else if(e===`]`&&g>0){l.length>0&&l[l.length-1]!==`\\`&&g--,l+=e,a++,s++;continue}if(g>0){if(e===`
853
+ `)break;l+=e,a++,s++;continue}if(e===` `||e===` `||e===`
854
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+1<i&&r[a+1]===`'`&&!f&&!p){for(l+=`$'`,a+=2,s+=2;a<i&&r[a]!==`'`;)r[a]===`\\`&&a+1<i?(l+=r[a]+r[a+1],a+=2,s+=2):(l+=r[a],a++,s++);a<i&&(l+=`'`,a++,s++);continue}if(e===`$`&&a+1<i&&r[a+1]===`"`&&!f&&!p){a++,s++,p=!0,u=!0,l===``&&(m=!0),a++,s++;continue}if(e===`'`&&!p){if(f)if(f=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!HD(t)&&t!==`'`&&(t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else f=!0,m&&!h?(d=!0,u=!0):l+=e;a++,s++;continue}if(e===`"`&&!f){if(p)if(p=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!HD(t)&&t!==`"`&&(t===`'`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else p=!0,m&&!h?u=!0:l+=e;a++,s++;continue}if(e===`\\`&&!f&&a+1<i){let t=r[a+1];if(t===`
855
+ `){a+=2,c++,s=1;continue}if(p){if(t===`"`||t===`\\`||t===`$`||t==="`"||t===`
856
+ `){if(t===`
857
+ `){a+=2,s=1,c++;continue}l+=e+t,a+=2,s+=2;continue}}else{l+=e+t,a+=2,s+=2;continue}}if(e===`$`&&a+1<i&&r[a+1]===`(`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1,n=!1,o=!1,u=0,d=!1,f=``,p=[],m=r[a]===`(`&&!this.dollarDparenIsSubshell(a),h=+!!m;for(;t>0&&a<i;){let e=r[a];if(l+=e,n)e===`'`&&(n=!1);else if(o)e===`\\`&&a+1<i?(l+=r[a+1],a++,s++):e===`"`&&(o=!1);else{if(e===`(`&&r[a+1]===`(`?h++:e===`)`&&r[a+1]===`)`&&h>0&&h--,h===0&&e===`<`&&r[a+1]===`<`&&r[a+2]!==`<`){let e=a+2,t=!1;for(r[e]===`-`&&(t=!0,e++);r[e]===` `||r[e]===` `;)e++;let{delim:n,endPos:i,unclosedQuote:o,unclosedSubstitution:u}=TD(r,e);if(o)throw new MD(`unexpected EOF while looking for matching \`${o}'`,c,s);if(u)throw new MD("unexpected EOF while looking for matching `)'",c,s);if(n.length>0){l+=r.slice(a+1,i),s+=i-a,p.push({delim:n,stripTabs:t}),a=i;continue}}if(e===`
858
+ `&&p.length>0){c++,s=0;let e=a+1;for(let{delim:t,stripTabs:n}of p)for(;!(e>=i);){let a=r.indexOf(`
859
+ `,e);a===-1&&(a=i);let o=r.slice(e,a),s=n?o.replace(/^\t+/,``):o;l+=r.slice(e,Math.min(a+1,i)),a<i&&c++;let u=a>=i;if(e=a+1,s===t||u)break}p.length=0,s=0,a=Math.min(e,i);continue}if(e===`'`)n=!0,f=``;else if(e===`"`)o=!0,f=``;else if(e===`\\`&&a+1<i)l+=r[a+1],a++,s++,f=``;else if(e===`$`&&a+1<i&&r[a+1]===`{`){a++,s++,l+=r[a],a++,s++;let e=1,t=!1,n=!1;for(;e>0&&a<i;){let o=r[a];if(o===`\\`&&a+1<i&&!t){l+=o,a++,s++,l+=r[a],a++,s++;continue}l+=o,t?o===`'`&&(t=!1):n?o===`"`&&(n=!1):o===`'`?t=!0:o===`"`?n=!0:o===`{`?e++:o===`}`&&e--,o===`
860
+ `?(c++,s=0):s++,a++}f=``;continue}else if(e===`#`&&!m&&(f===``||/\s/.test(r[a-1]||``))){for(;a+1<i&&r[a+1]!==`
861
+ `;)a++,s++,l+=r[a];f=``}else/[a-zA-Z_]/.test(e)?f+=e:(f===`case`?(u++,d=!1):f===`in`&&u>0?d=!0:f===`esac`&&u>0&&(u--,d=!1),f=``,e===`(`?a>0&&r[a-1]===`$`?t++:d||t++:e===`)`?d?d=!1:t--:e===`;`&&u>0&&(a+1<i&&r[a+1]===`;`||a+1<i&&r[a+1]===`&`)&&(d=!0))}e===`
862
+ `&&(c++,s=0,f=``),a++,s++}continue}if(e===`$`&&a+1<i&&r[a+1]===`[`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1;for(;t>0&&a<i;){let e=r[a];l+=e,e===`[`?t++:e===`]`?t--:e===`
863
+ `&&(c++,s=0),a++,s++}continue}if(e===`$`&&a+1<i&&r[a+1]===`{`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1,n=!1,o=!1,u=c,d=s,f=c,p=s;for(;t>0&&a<i;){let e=r[a];if(e===`\\`&&a+1<i&&r[a+1]===`
864
+ `){a+=2,c++,s=1;continue}if(e===`\\`&&a+1<i&&!n){l+=e,a++,s++,l+=r[a],a++,s++;continue}l+=e,n?e===`'`&&(n=!1):o?e===`"`&&(o=!1):e===`'`?(n=!0,u=c,d=s):e===`"`?(o=!0,f=c,p=s):e===`{`?t++:e===`}`&&t--,e===`
865
+ `&&(c++,s=0),a++,s++}if(n)throw new MD("unexpected EOF while looking for matching `''",u,d);if(o)throw new MD(`unexpected EOF while looking for matching \`"'`,f,p);continue}if(e===`$`&&a+1<i&&!f){let t=r[a+1];if(t===`#`||t===`?`||t===`$`||t===`!`||t===`@`||t===`*`||t===`-`||t>=`0`&&t<=`9`){l+=e+t,a+=2,s+=2;continue}}if(e==="`"&&!f){for(l+=e,a++,s++;a<i&&r[a]!=="`";){let e=r[a];l+=e,e===`\\`&&a+1<i&&(l+=r[a+1],a++,s++),e===`
866
+ `&&(c++,s=0),a++,s++}a<i&&(l+=r[a],a++,s++);continue}l+=e,a++,e===`
867
+ `?(c++,s=1):s++}if(this.pos=a,this.column=s,this.line=c,h&&m&&(l=r[e]+l,u=!1,d=!1),f||p)throw new MD(`unexpected EOF while looking for matching \`${f?`'`:`"`}'`,t,n);if(!m&&l.length>=2){if(l[0]===`'`&&l[l.length-1]===`'`){let e=l.slice(1,-1);!e.includes(`'`)&&!e.includes(`"`)&&(l=e,u=!0,d=!0)}else if(l[0]===`"`&&l[l.length-1]===`"`){let e=l.slice(1,-1),t=!1;for(let n=0;n<e.length;n++){if(e[n]===`"`){t=!0;break}e[n]===`\\`&&n+1<e.length&&n++}t||(l=e,u=!0,d=!1)}}if(l===``)return{type:Z.WORD,value:``,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d};let _=ND.get(l);if(!u&&_!==void 0)return{type:_,value:l,start:e,end:a,line:t,column:n};if(!m){let r=LD(l);if(r>0&&ID(l.slice(0,r)))return{type:Z.ASSIGNMENT_WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}return/^[0-9]+$/.test(l)?{type:Z.NUMBER,value:l,start:e,end:a,line:t,column:n}:VD(l)?{type:Z.NAME,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}:{type:Z.WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let t=this.pos,n=this.line,r=this.column,i=``,a=!1;for(;this.pos<this.input.length;){let t=``,o=``,s=``;for(;;){for(t=``;this.pos<this.input.length&&this.input[this.pos]!==`
868
+ `;)t+=this.input[this.pos],this.pos++,this.column++;let n=0;for(let e=t.length-1;t[e]===`\\`;--e)n+=1;if(s+=t,e.quoted||n%2==0||this.pos+1>=this.input.length)break;s=s.slice(0,-1),o+=`${t}
869
+ `,this.pos++,this.line++,this.column=1}if((e.stripTabs?s.replace(/^\t+/,``):s)===e.delimiter){a=!0,this.pos<this.input.length&&this.input[this.pos]===`
870
+ `&&(this.pos++,this.line++,this.column=1);break}if(i+=o,i+=t,this.pos<this.input.length&&this.input[this.pos]===`
871
+ `?(i+=`
872
+ `,this.pos++,this.line++,this.column=1):t.length>0&&(i+=`
873
+ `),i.length>this.maxHeredocSize)throw new MD(`Heredoc size limit exceeded (${this.maxHeredocSize} bytes)`,n,r)}this.tokens.push({type:Z.HEREDOC_CONTENT,value:i,start:t,end:this.pos,line:n,column:r,heredocTerminated:a})}}readHeredocDelimiterToken(e,t,n,r){let i=this.input,{delim:a,endPos:o,quoted:s,unclosedQuote:c,unclosedSubstitution:l}=TD(i,e);if(c)throw new MD(`unexpected EOF while looking for matching \`${c}'`,t,n);if(l)throw new MD("unexpected EOF while looking for matching `)'",t,n);if(o===e)throw new MD(`Expected here-document delimiter`,t,n);let u=t,d=n;for(let t=e;t<o;t++)i[t]===`
874
+ `?(u+=1,d=1):d+=1;return this.pos=o,this.line=u,this.column=d,this.pendingHeredocs.push({delimiter:a,stripTabs:r,quoted:s}),{type:Z.WORD,value:i.slice(e,o),start:e,end:o,line:t,column:n,quoted:s,heredocDelimiter:a}}isWordCharFollowing(e){if(e>=this.input.length)return!1;let t=this.input[e];return t!==` `&&t!==` `&&t!==`
875
+ `&&t!==`;`&&t!==`&`&&t!==`|`&&t!==`(`&&t!==`)`&&t!==`<`&&t!==`>`}readWordWithBraceExpansion(e,t,n){let r=this.input,i=r.length,a=e,o=n;for(;a<i;){let e=r[a];if(e===` `||e===` `||e===`
876
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break;if(e===`{`){if(this.scanBraceExpansion(a)!==null){let e=1;for(a++,o++;a<i&&e>0;)r[a]===`{`?e++:r[a]===`}`&&e--,a++,o++;continue}a++,o++;continue}if(e===`}`){a++,o++;continue}if(e===`$`&&a+1<i&&r[a+1]===`(`){a++,o++,a++,o++;let e=1;for(;e>0&&a<i;)r[a]===`(`?e++:r[a]===`)`&&e--,a++,o++;continue}if(e===`$`&&a+1<i&&r[a+1]===`{`){a++,o++,a++,o++;let e=1;for(;e>0&&a<i;)r[a]===`{`?e++:r[a]===`}`&&e--,a++,o++;continue}if(e==="`"){for(a++,o++;a<i&&r[a]!=="`";)r[a]===`\\`&&a+1<i?(a+=2,o+=2):(a++,o++);a<i&&(a++,o++);continue}a++,o++}let s=r.slice(e,a);return this.pos=a,this.column=o,{type:Z.WORD,value:s,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}scanBraceExpansion(e){let t=this.input,n=t.length,r=e+1,i=1,a=!1,o=!1;for(;r<n&&i>0;){let e=t[r];if(e===`{`)i++,r++;else if(e===`}`)i--,r++;else if(e===`,`&&i===1)a=!0,r++;else if(e===`.`&&r+1<n&&t[r+1]===`.`)o=!0,r+=2;else{if(e===` `||e===` `||e===`
877
+ `||e===`;`||e===`&`||e===`|`)return null;r++}}return i===0&&(a||o)?t.slice(e,r):null}scanLiteralBraceWord(e){let t=this.input,n=t.length,r=e+1,i=1;for(;r<n&&i>0;){let n=t[r];if(n===`{`)i++,r++;else if(n===`}`){if(i--,i===0)return t.slice(e,r+1);r++}else{if(n===` `||n===` `||n===`
878
+ `||n===`;`||n===`&`||n===`|`)return null;r++}}return null}scanExtglobPattern(e){let t=this.input,n=t.length,r=e+1,i=1;for(;r<n&&i>0;){let e=t[r];if(e===`\\`&&r+1<n){r+=2;continue}if(`@*+?!`.includes(e)&&r+1<n&&t[r+1]===`(`){r++,i++,r++;continue}if(e===`(`)i++,r++;else if(e===`)`)i--,r++;else{if(e===`
879
+ `)return null;r++}}return i===0?{content:t.slice(e,r),end:r}:null}scanFdVariable(e){let t=this.input,n=t.length,r=e+1,i=r;for(;r<n;){let e=t[r];if(r===i){if(!(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`))return null}else if(!(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`_`))break;r++}if(r===i)return null;let a=t.slice(i,r);if(r>=n||t[r]!==`}`||(r++,r>=n))return null;let o=t[r],s=r+1<n?t[r+1]:``;return o===`>`||o===`<`||o===`&`&&(s===`>`||s===`<`)?{varname:a,end:r}:null}dollarDparenIsSubshell(e){let t=this.input,n=t.length,r=e+1,i=2,a=!1,o=!1,s=!1;for(;r<n&&i>0;){let e=t[r];if(a){e===`'`&&(a=!1),e===`
880
+ `&&(s=!0),r++;continue}if(o){if(e===`\\`){r+=2;continue}e===`"`&&(o=!1),e===`
881
+ `&&(s=!0),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`
882
+ `&&(s=!0),e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e<n&&t[e]===`)`)return!1;let i=e,a=!1;for(;i<n&&(t[i]===` `||t[i]===` `||t[i]===`
883
+ `);)a=!0,i++;if(a&&i<n&&t[i]===`)`||s)return!0}if(i===0)return!1;r++;continue}r++}return!1}dparenClosesWithSpacedParens(e){let t=this.input,n=t.length,r=e,i=2,a=!1,o=!1;for(;r<n&&i>0;){let e=t[r];if(a){e===`'`&&(a=!1),r++;continue}if(o){if(e===`\\`){r+=2;continue}e===`"`&&(o=!1),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e<n&&t[e]===`)`)return!1;let i=e,a=!1;for(;i<n&&(t[i]===` `||t[i]===` `||t[i]===`
884
+ `);)a=!0,i++;if(a&&i<n&&t[i]===`)`)return!0}if(i===0)return!1;r++;continue}if(i===1&&(e===`|`&&r+1<n&&t[r+1]===`|`||e===`&`&&r+1<n&&t[r+1]===`&`||e===`|`&&r+1<n&&t[r+1]!==`|`))return!0;r++}return!1}},WD=1e6,GD=1e5,KD=1e6,qD=200,JD;(function(e){e[e.Default=0]=`Default`,e[e.Assignment=1]=`Assignment`,e[e.NoBraceExpansion=2]=`NoBraceExpansion`,e[e.Regex=4]=`Regex`})(JD||={});var YD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),XD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS]),ZD=new Set([Z.LESS,Z.GREAT,Z.DLESS,Z.DGREAT,Z.LESSAND,Z.GREATAND,Z.LESSGREAT,Z.DLESSDASH,Z.CLOBBER,Z.TLESS,Z.AND_GREAT,Z.AND_DGREAT]),QD=class extends Error{line;column;token;constructor(e,t,n,r=void 0){super(`Parse error at ${t}:${n}: ${e}`),this.line=t,this.column=n,this.token=r,this.name=`ParseException`}},$D=class{iterations=0;tokens=0;depth=0;reset(){this.iterations=0,this.tokens=0,this.depth=0}chargeIteration(e,t){if(this.iterations++,this.iterations>KD)throw new QD(`Maximum parse iterations exceeded (possible infinite loop)`,e,t)}chargeTokens(e,t=1,n=1){if(this.tokens+=e,this.tokens>GD)throw new QD(`Too many tokens: cumulative count exceeds limit of ${GD}`,t,n)}enter(e,t){if(this.depth++,this.depth>qD)throw this.depth--,new QD(`Maximum parser nesting depth exceeded (${qD})`,e,t);let n=!0;return()=>{n&&(n=!1,this.depth--)}}};qn(),Lr(),j();function eO(e,t){for(;t<e.length;){if(e[t]===`\\`&&e[t+1]===`
885
+ `){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}var tO=[`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`|=`,`^=`];function nO(e){if(e.includes(`#`)){let t=e.split(`#`);if(t.length!==2)return NaN;let[n,r]=t;if(!/^\d+$/.test(n)||r.length===0)return NaN;let i=Number.parseInt(n,10);if(i<2||i>64)return NaN;let a=0;for(let e of r){let t;if(/[0-9]/.test(e))t=e.charCodeAt(0)-48;else if(/[a-z]/.test(e))t=e.charCodeAt(0)-97+10;else if(/[A-Z]/.test(e))t=e.charCodeAt(0)-65+(i<=36?10:36);else if(e===`@`)t=62;else if(e===`_`)t=63;else return NaN;if(t>=i)return NaN;if(a=a*i+t,a>2**53-1)return 2**53-1}return a}if(e.startsWith(`0x`)||e.startsWith(`0X`)){let t=Number.parseInt(e.slice(2),16);return t>2**53-1?2**53-1:t}if(e.startsWith(`0`)&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return NaN;let t=Number.parseInt(e,8);return t>2**53-1?2**53-1:t}let t=Number.parseInt(e,10);return t>2**53-1?2**53-1:t}function rO(e,t,n,r){if(n.slice(r,r+3)!==`$((`)return null;let i=r+3,a=1,o=i;for(;i<n.length-1&&a>0;)n[i]===`(`&&n[i+1]===`(`?(a++,i+=2):n[i]===`)`&&n[i+1]===`)`?(a--,a>0&&(i+=2)):i++;let{expr:s}=e(t,n.slice(o,i),0);return i+=2,{expr:{type:`ArithNested`,expression:s},pos:i}}function iO(e,t){if(e.slice(t,t+2)!==`$'`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`'`;)if(e[n]===`\\`&&n+1<e.length){let t=e[n+1];switch(t){case`n`:r+=`
886
+ `;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`\\`:r+=`\\`;break;case`'`:r+=`'`;break;default:r+=t}n+=2}else r+=e[n],n++;e[n]===`'`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function aO(e,t){if(e.slice(t,t+2)!==`$"`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]===`"`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function oO(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function sO(e,t){let n=oO(t),{expr:r,pos:i}=uO(e,n,0),a=eO(n,i);if(a<n.length){let e=t.slice(a).trim();if(e)return{type:`ArithmeticExpression`,originalText:t,expression:{type:`ArithSyntaxError`,errorToken:e,message:`${e}: syntax error: invalid arithmetic operator (error token is "${e}")`}}}return{type:`ArithmeticExpression`,expression:r,originalText:t}}function cO(e,t){return{expr:{type:`ArithSyntaxError`,errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function lO(e,t){return eO(e,t)>=e.length}function uO(e,t,n){return fO(e,t,n)}function dO(e,t,n){return e.withDepth(()=>uO(e,t,n))}function fO(e,t,n){let{expr:r,pos:i}=pO(e,t,n);for(i=eO(t,i);t[i]===`,`;){if(i++,lO(t,i))return cO(`,`,i);let{expr:n,pos:a}=pO(e,t,i);r={type:`ArithBinary`,operator:`,`,left:r,right:n},i=eO(t,a)}return{expr:r,pos:i}}function pO(e,t,n){let{expr:r,pos:i}=mO(e,t,n);if(i=eO(t,i),t[i]===`?`){i++;let{expr:n,pos:a}=dO(e,t,i);if(i=eO(t,a),t[i]===`:`){i++;let{expr:a,pos:o}=dO(e,t,i);return{expr:{type:`ArithTernary`,condition:r,consequent:n,alternate:a},pos:o}}}return{expr:r,pos:i}}function mO(e,t,n){let{expr:r,pos:i}=hO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`||`;){if(i+=2,lO(t,i))return cO(`||`,i);let{expr:n,pos:a}=hO(e,t,i);r={type:`ArithBinary`,operator:`||`,left:r,right:n},i=a}return{expr:r,pos:i}}function hO(e,t,n){let{expr:r,pos:i}=gO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`&&`;){if(i+=2,lO(t,i))return cO(`&&`,i);let{expr:n,pos:a}=gO(e,t,i);r={type:`ArithBinary`,operator:`&&`,left:r,right:n},i=a}return{expr:r,pos:i}}function gO(e,t,n){let{expr:r,pos:i}=_O(e,t,n);for(;i=eO(t,i),t[i]===`|`&&t[i+1]!==`|`;){if(i++,lO(t,i))return cO(`|`,i);let{expr:n,pos:a}=_O(e,t,i);r={type:`ArithBinary`,operator:`|`,left:r,right:n},i=a}return{expr:r,pos:i}}function _O(e,t,n){let{expr:r,pos:i}=vO(e,t,n);for(;i=eO(t,i),t[i]===`^`;){if(i++,lO(t,i))return cO(`^`,i);let{expr:n,pos:a}=vO(e,t,i);r={type:`ArithBinary`,operator:`^`,left:r,right:n},i=a}return{expr:r,pos:i}}function vO(e,t,n){let{expr:r,pos:i}=yO(e,t,n);for(;i=eO(t,i),t[i]===`&`&&t[i+1]!==`&`;){if(i++,lO(t,i))return cO(`&`,i);let{expr:n,pos:a}=yO(e,t,i);r={type:`ArithBinary`,operator:`&`,left:r,right:n},i=a}return{expr:r,pos:i}}function yO(e,t,n){let{expr:r,pos:i}=bO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`==`||t.slice(i,i+2)===`!=`;){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=bO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function bO(e,t,n){let{expr:r,pos:i}=xO(e,t,n);for(;;)if(i=eO(t,i),t.slice(i,i+2)===`<=`||t.slice(i,i+2)===`>=`){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=xO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else if(t[i]===`<`||t[i]===`>`){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=xO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function xO(e,t,n){let{expr:r,pos:i}=SO(e,t,n);for(;i=eO(t,i),t.slice(i,i+2)===`<<`||t.slice(i,i+2)===`>>`;){let n=t.slice(i,i+2);if(i+=2,lO(t,i))return cO(n,i);let{expr:a,pos:o}=SO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function SO(e,t,n){let{expr:r,pos:i}=CO(e,t,n);for(;i=eO(t,i),(t[i]===`+`||t[i]===`-`)&&t[i+1]!==t[i];){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=CO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function CO(e,t,n){let{expr:r,pos:i}=wO(e,t,n);for(;;)if(i=eO(t,i),t[i]===`*`&&t[i+1]!==`*`){if(i++,lO(t,i))return cO(`*`,i);let{expr:n,pos:a}=wO(e,t,i);r={type:`ArithBinary`,operator:`*`,left:r,right:n},i=a}else if(t[i]===`/`||t[i]===`%`){let n=t[i];if(i++,lO(t,i))return cO(n,i);let{expr:a,pos:o}=wO(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function wO(e,t,n){let{expr:r,pos:i}=TO(e,t,n),a=eO(t,i);if(t.slice(a,a+2)===`**`){if(a+=2,lO(t,a))return cO(`**`,a);let{expr:n,pos:i}=e.withDepth(()=>wO(e,t,a));return{expr:{type:`ArithBinary`,operator:`**`,left:r,right:n},pos:i}}return{expr:r,pos:i}}function TO(e,t,n){let r=eO(t,n);if(t.slice(r,r+2)===`++`||t.slice(r,r+2)===`--`){let n=t.slice(r,r+2);r+=2;let{expr:i,pos:a}=e.withDepth(()=>TO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}if(t[r]===`+`||t[r]===`-`||t[r]===`!`||t[r]===`~`){let n=t[r];r++;let{expr:i,pos:a}=e.withDepth(()=>TO(e,t,r));return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}return DO(e,t,r)}function EO(e,t){let n=e[t];return n===`$`||n==="`"}function DO(e,t,n){let{expr:r,pos:i}=OO(e,t,n,!1),a=[r];for(;EO(t,i);){let{expr:n,pos:r}=OO(e,t,i,!0);a.push(n),i=r}a.length>1&&(r={type:`ArithConcat`,parts:a});let o;if(t[i]===`[`&&r.type===`ArithConcat`){i++;let{expr:n,pos:r}=dO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(o&&r.type===`ArithConcat`&&(r={type:`ArithDynamicElement`,nameExpr:r,subscript:o},o=void 0),i=eO(t,i),r.type===`ArithConcat`||r.type===`ArithVariable`||r.type===`ArithDynamicElement`){for(let n of tO)if(t.slice(i,i+n.length)===n&&t.slice(i,i+n.length+1)!==`==`){i+=n.length;let{expr:a,pos:o}=e.withDepth(()=>pO(e,t,i));return r.type===`ArithDynamicElement`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r.nameExpr,subscript:r.subscript,value:a},pos:o}:r.type===`ArithConcat`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r,value:a},pos:o}:{expr:{type:`ArithAssignment`,operator:n,variable:r.name,value:a},pos:o}}}if(t.slice(i,i+2)===`++`||t.slice(i,i+2)===`--`){let e=t.slice(i,i+2);return i+=2,{expr:{type:`ArithUnary`,operator:e,operand:r,prefix:!1},pos:i}}return{expr:r,pos:i}}function OO(e,t,n,r=!1){let i=eO(t,n),a=rO(dO,e,t,i);if(a)return a;let o=iO(t,i);if(o)return o;let s=aO(t,i);if(s)return s;if(t.slice(i,i+2)===`$(`&&t[i+2]!==`(`){i+=2;let e=1,n=i;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,e>0&&i++;let r=t.slice(n,i);return i++,{expr:{type:`ArithCommandSubst`,command:r},pos:i}}if(t[i]==="`"){i++;let e=i;for(;i<t.length&&t[i]!=="`";)i++;let n=t.slice(e,i);return t[i]==="`"&&i++,{expr:{type:`ArithCommandSubst`,command:n},pos:i}}if(t[i]===`(`){i++;let{expr:n,pos:r}=dO(e,t,i);return i=eO(t,r),t[i]===`)`&&i++,{expr:{type:`ArithGroup`,expression:n},pos:i}}if(t[i]===`'`){i++;let e=``;for(;i<t.length&&t[i]!==`'`;)e+=t[i],i++;t[i]===`'`&&i++;let n=Number.parseInt(e,10);return{expr:{type:`ArithSingleQuote`,content:e,value:Number.isNaN(n)?0:n},pos:i}}if(t[i]===`"`){i++;let n=``;for(;i<t.length&&t[i]!==`"`;)t[i]===`\\`&&i+1<t.length?(n+=t[i+1],i+=2):(n+=t[i],i++);t[i]===`"`&&i++;let r=n.trim();if(!r)return{expr:{type:`ArithNumber`,value:0},pos:i};let{expr:a}=dO(e,r,0);return{expr:a,pos:i}}if(/[0-9]/.test(t[i])){let e=``,n=!1,r=!1;for(;i<t.length;){let a=t[i];if(n)if(/[0-9a-zA-Z@_]/.test(a))e+=a,i++;else break;else if(a===`#`)n=!0,e+=a,i++;else if(e===`0`&&(a===`x`||a===`X`)&&i+1<t.length&&/[0-9a-fA-F]/.test(t[i+1]))r=!0,e+=a,i++;else if(r&&/[0-9a-fA-F]/.test(a))e+=a,i++;else if(!r&&/[0-9]/.test(a))e+=a,i++;else break}if(i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=e;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: value too great for base (error token is "${n}")`},pos:i}}if(t[i]===`.`&&/[0-9]/.test(t[i+1]))throw new Tr(`${e}.${t[i+1]}...: syntax error: invalid arithmetic operator`);if(t[i]===`[`){let n=t.slice(i).trim();return{expr:{type:`ArithNumberSubscript`,number:e,errorToken:n},pos:t.length}}return{expr:{type:`ArithNumber`,value:nO(e)},pos:i}}if(t[i]===`$`&&t[i+1]===`{`){let e=i+2,n=1,r=e;for(;r<t.length&&n>0;)t[r]===`{`?n++:t[r]===`}`&&n--,n>0&&r++;let a=t.slice(e,r),o=r+1;if(t[o]===`#`){let e=o+1;for(;e<t.length&&/[0-9a-zA-Z@_]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicBase`,baseExpr:a,value:t.slice(o+1,e)},pos:e}}if(/[0-9]/.test(t[o])||t[o]===`x`||t[o]===`X`){let e=o;if(t[o]===`x`||t[o]===`X`)for(e++;e<t.length&&/[0-9a-fA-F]/.test(t[e]);)e++;else for(;e<t.length&&/[0-9]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicNumber`,prefix:a,suffix:t.slice(o,e)},pos:e}}return i=o,{expr:{type:`ArithBracedExpansion`,content:a},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[0-9]/.test(t[i+1])){i++;let e=``;for(;i<t.length&&/[0-9]/.test(t[i]);)e+=t[i],i++;return{expr:{type:`ArithVariable`,name:e,hasDollarPrefix:!0},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[*@#?\-!$]/.test(t[i+1])){let e=t[i+1];return i+=2,{expr:{type:`ArithSpecialVar`,name:e},pos:i}}let c=!1;if(t[i]===`$`&&i+1<t.length&&/[a-zA-Z_]/.test(t[i+1])&&(c=!0,i++),i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=``;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;if(t[i]===`[`&&!r){i++;let a;if(t[i]===`'`||t[i]===`"`){let e=t[i];for(i++,a=``;i<t.length&&t[i]!==e;)a+=t[i],i++;t[i]===e&&i++,i=eO(t,i),t[i]===`]`&&i++}let o;if(a===void 0){let{expr:n,pos:r}=dO(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(i=eO(t,i),t[i]===`[`&&o)return{expr:{type:`ArithDoubleSubscript`,array:n,index:o},pos:i};if(!r){for(let r of tO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:s,pos:c}=e.withDepth(()=>pO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,subscript:o,stringKey:a,value:s},pos:c}}}return{expr:{type:`ArithArrayElement`,array:n,index:o,stringKey:a},pos:i}}if(i=eO(t,i),!r){for(let r of tO)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:a,pos:o}=e.withDepth(()=>pO(e,t,i));return{expr:{type:`ArithAssignment`,operator:r,variable:n,value:a},pos:o}}}return{expr:{type:`ArithVariable`,name:n,hasDollarPrefix:c},pos:i}}if(t[i]===`#`){let e=i+1;for(;e<t.length&&t[e]!==`
887
+ `;)e++;let n=t.slice(i,e).trim()||`#`;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: syntax error: invalid arithmetic operator (error token is "${n}")`},pos:t.length}}return{expr:{type:`ArithNumber`,value:0},pos:i}}var kO=e=>{let t,n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`&&t===`"`&&r+1<e.length){n+=i+e[r+1],r+=1;continue}if(i===`'`||i===`"`){t===i?t=void 0:t||=i,n+=i;continue}if(i===`\\`&&!t&&r+1<e.length){let t=e[r+1];n+=t===`$`||t==="`"?`\\${t}`:t,r+=1;continue}n+=i}return n};function AO(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function jO(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function MO(e,t,n,r,i){let a=1,o=n+1;for(;o<t.length&&a>0;)t[o]===r?a++:t[o]===i&&a--,a>0&&o++;return a===0?o:-1}function NO(e,t,n){let r=n,i=1;for(;r<t.length&&i>0;){let e=t[r];if(e===`\\`&&r+1<t.length){r+=2;continue}if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++;continue}e===`{`?i++:e===`}`&&i--,i>0&&r++}return r}function PO(e,t,n){let r=n,i=!1;for(;r<t.length;){let e=t[r];if(e===`/`&&i||e===`}`)break;if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1,i=!0;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++,i=!0;continue}e===`\\`?(r+=2,i=!0):(r++,i=!0)}return r}function FO(e,t,n){let r=n,i=``;for(;r<t.length;){let e=t[r];if(e===`*`||e===`?`)i+=e,r++;else if(e===`[`){let n=IO(t,r);n===-1?(i+=e,r++):(i+=t.slice(r,n+1),r=n+1)}else break}return{pattern:i,endIndex:r}}function IO(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){let t=e[n];if(t===`\\`&&n+1<e.length){let t=e[n+1];if(t===`"`||t===`'`)return-1;n+=2;continue}if(t===`]`)return n;if(t===`"`||t===`$`||t==="`")return-1;if(t===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}if(t===`[`&&n+1<e.length&&(e[n+1]===`.`||e[n+1]===`=`)){let t=`${e[n+1]}]`,r=e.indexOf(t,n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function LO(e,t,n){let r=``,i=n;for(;i<t.length&&t[i]!==`'`;){let e=t[i];if(e===`\\`&&i+1<t.length)switch(t[i+1]){case`n`:r+=`
888
+ `,i+=2;break;case`t`:r+=` `,i+=2;break;case`r`:r+=`\r`,i+=2;break;case`\\`:r+=`\\`,i+=2;break;case`'`:r+=`'`,i+=2;break;case`"`:r+=`"`,i+=2;break;case`a`:r+=`\x07`,i+=2;break;case`b`:r+=`\b`,i+=2;break;case`e`:case`E`:r+=`\x1B`,i+=2;break;case`f`:r+=`\f`,i+=2;break;case`v`:r+=`\v`,i+=2;break;case`x`:{let e=[],n=i;for(;n+1<t.length&&t[n]===`\\`&&t[n+1]===`x`;){let r=t.slice(n+2,n+4),i=parseInt(r,16);if(!Number.isNaN(i)&&r.length>0)e.push(i),n+=2+r.length;else break}e.length>0?(r+=AO(e),i=n):(r+=`\\x`,i+=2);break}case`u`:{let e=t.slice(i+2,i+6),n=parseInt(e,16);Number.isNaN(n)?(r+=`\\u`,i+=2):(r+=String.fromCharCode(n),i+=6);break}case`c`:if(i+2<t.length){let e=t[i+2].charCodeAt(0)&31;r+=String.fromCharCode(e),i+=3}else r+=`\\c`,i+=2;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let e=``,n=i+1;for(;n<t.length&&n<i+4&&/[0-7]/.test(t[n]);)e+=t[n],n++;let a=parseInt(e,8);r+=String.fromCharCode(a),i=n;break}default:r+=e,i++}else r+=e,i++}return i<t.length&&t[i]===`'`&&i++,{part:X.literal(r),endIndex:i}}function RO(e,t){let n=t.trim();return n===``?{type:`ArithmeticExpression`,expression:{type:`ArithNumber`,value:0}}:sO(e,n)}function zO(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`{`?(r++,n+=a):a===`}`?(r--,n+=a):a===`,`&&r===0?(t.push(n),n=``):n+=a}return t.push(n),t}function BO(e,t,n,r){let i=MO(e,t,n,`{`,`}`);if(i===-1)return null;let a=t.slice(n+1,i),o=a.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:`BraceExpansion`,items:[{type:`Range`,start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:i+1};let s=a.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return s?{part:{type:`BraceExpansion`,items:[{type:`Range`,start:s[1],end:s[2],step:s[3]?Number.parseInt(s[3],10):void 0}]},endIndex:i+1}:a.includes(`,`)&&r?{part:{type:`BraceExpansion`,items:zO(a).map(t=>e.withDepth(()=>({type:`Word`,word:X.word(r(e,t,!1,!1,!1))})))},endIndex:i+1}:a.includes(`,`)?{part:{type:`BraceExpansion`,items:zO(a).map(e=>({type:`Word`,word:X.word([X.literal(e)])}))},endIndex:i+1}:null}function VO(e,t){let n=``;for(let r of t.parts)switch(r.type){case`Literal`:n+=r.value;break;case`SingleQuoted`:n+=`'${r.value}'`;break;case`Escaped`:n+=r.value;break;case`DoubleQuoted`:n+=`"`;for(let e of r.parts)e.type===`Literal`||e.type===`Escaped`?n+=e.value:e.type===`ParameterExpansion`&&(n+=`\${${e.parameter}}`);n+=`"`;break;case`ParameterExpansion`:n+=`\${${r.parameter}}`;break;case`Glob`:n+=r.pattern;break;case`TildeExpansion`:n+=`~`,r.user&&(n+=r.user);break;case`BraceExpansion`:{n+=`{`;let t=[];for(let n of r.items)if(n.type===`Range`){let e=n.startStr??String(n.start),r=n.endStr??String(n.end);n.step===void 0?t.push(`${e}..${r}`):t.push(`${e}..${r}..${n.step}`)}else t.push(VO(e,n.word));t.length===1&&r.items[0].type===`Range`?n+=t[0]:n+=t.join(`,`),n+=`}`;break}default:n+=r.type}return n}function HO(e,t){return{[Z.LESS]:`<`,[Z.GREAT]:`>`,[Z.DGREAT]:`>>`,[Z.LESSAND]:`<&`,[Z.GREATAND]:`>&`,[Z.LESSGREAT]:`<>`,[Z.CLOBBER]:`>|`,[Z.TLESS]:`<<<`,[Z.AND_GREAT]:`&>`,[Z.AND_DGREAT]:`&>>`,[Z.DLESS]:`<`,[Z.DLESSDASH]:`<`}[t]||`>`}function UO(e){let t=e.current(),n=t.type;if(n===Z.NUMBER){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:XD.has(n.type)}if(n===Z.FD_VARIABLE){let n=e.peek(1);return t.end!==n.start||e.isProcessSubstitutionStart(1)?!1:ZD.has(n.type)}return!e.isProcessSubstitutionStart()&&YD.has(n)}function WO(e){let t=null,n;e.check(Z.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(Z.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),i=HO(e,r.type);if(r.type===Z.DLESS||r.type===Z.DLESSDASH)return GO(e,t,n,r.type===Z.DLESSDASH);e.isWord()||e.error(`Expected redirection target`);let a=e.parseWord();return X.redirection(i,a,t,n)}function GO(e,t,n,r){e.isWord()||e.error(`Expected here-document delimiter`);let i=e.advance(),a=i.heredocDelimiter??i.value,o=i.quoted||!1,s=X.redirection(r?`<<-`:`<<`,X.hereDoc(a,X.word([]),r,o),t,n);return e.addPendingHeredoc(s,a,r,o),s}function KO(e){let t=e.getSourceLine(),n=[],r=null,i=[],a=[];for(;e.check(Z.ASSIGNMENT_WORD)||UO(e);)e.checkIterationLimit(),e.check(Z.ASSIGNMENT_WORD)?n.push(qO(e)):a.push(WO(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(Z.DBRACK_START)||e.check(Z.DPAREN_START))){let t=e.advance();r=X.word([X.literal(t.value)])}for(;(!e.isStatementEnd()||e.check(Z.RBRACE))&&!e.check(Z.PIPE,Z.PIPE_AMP);)if(e.checkIterationLimit(),UO(e))a.push(WO(e));else if(e.check(Z.ASSIGNMENT_WORD)){let t=e.advance(),n=t.value,r=n.endsWith(`=`),a=n.endsWith(`=(`);if((r||a)&&(a||e.check(Z.LPAREN))){let t=a?n.slice(0,-2):n.slice(0,-1);a||e.expect(Z.LPAREN);let r=YO(e);e.expect(Z.RPAREN);let o=`${t}=(${r.map(t=>VO(e,t)).join(` `)})`;i.push(e.parseWordFromString(o,!1,!1,!0))}else{let r=e.parseWordFromString(n,t.quoted,t.singleQuoted,!0);i.push(e.parseAdjacentWordParts(r.parts,t.end,JD.Assignment))}}else if(e.isWord())i.push(e.parseWord());else if(e.check(Z.RBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.DBRACK_END)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(Z.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=X.simpleCommand(r,i,n,a);return o.line=t,o}function qO(e){let t=e.expect(Z.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let i=r[0],a,o=i.length;if(n[o]===`[`){let t=0,r=o+1;for(;o<n.length;o++)if(n[o]===`[`)t++;else if(n[o]===`]`&&(t--,t===0))break;t!==0&&e.error(`Invalid assignment: ${n}`),a=kO(n.slice(r,o)),o++}let s=n[o]===`+`;s&&o++,n[o]!==`=`&&e.error(`Invalid assignment: ${n}`),o++;let c=n.slice(o);if(c===`(`){let t=YO(e);e.expect(Z.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return X.assignment(n,null,s,t)}if(c===``&&e.check(Z.LPAREN)){let n=e.current();if(t.end===n.start){e.advance();let t=YO(e);e.expect(Z.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return X.assignment(n,null,s,t)}}let l=c?e.parseWordFromString(c,t.quoted,t.singleQuoted,!0):null;t.end===e.current().start&&e.isProcessSubstitutionStart()&&(l=e.parseAdjacentWordParts(l?.parts??[],t.end,JD.Assignment));let u=a===void 0?i:`${i}[${a}]`;return X.assignment(u,l,s,null)}var JO=new Set([Z.AMP,Z.PIPE,Z.PIPE_AMP,Z.SEMICOLON,Z.AND_AND,Z.OR_OR,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND]);function YO(e){let t=[];for(e.skipNewlines();!e.check(Z.RPAREN,Z.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):JO.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}function XO(e,t){e.expect(Z.IF);let n=[],r=e.parseCompoundList();e.expect(Z.THEN);let i=e.parseCompoundList();if(i.length===0){let t=e.check(Z.FI)?`fi`:e.check(Z.ELSE)?`else`:e.check(Z.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}for(n.push({condition:r,body:i});e.check(Z.ELIF);){e.advance();let t=e.parseCompoundList();e.expect(Z.THEN);let r=e.parseCompoundList();if(r.length===0){let t=e.check(Z.FI)?`fi`:e.check(Z.ELSE)?`else`:e.check(Z.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}n.push({condition:t,body:r})}let a=null;e.check(Z.ELSE)&&(e.advance(),a=e.parseCompoundList(),a.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(Z.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.ifNode(n,a,o)}function ZO(e,t){let n=e.expect(Z.FOR);if(e.check(Z.DPAREN_START))return QO(e,t,e.getSourceLine(n));e.isWord()||e.error(`Expected variable name in for loop`);let r=e.advance().value,i=null;if(e.skipNewlines(),e.check(Z.IN))for(e.advance(),i=[];!e.check(Z.SEMICOLON,Z.NEWLINE,Z.DO,Z.EOF)&&e.isWord();)i.push(e.parseWord());e.check(Z.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(Z.DO);let a=e.parseCompoundList();e.expect(Z.DONE);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.forNode(r,i,a,o)}function QO(e,t,n){e.expect(Z.DPAREN_START);let r=null,i=null,a=null,o=[``,``,``],s=0,c=0;for(;!e.check(Z.DPAREN_END,Z.EOF);){let t=e.advance();if(t.type===Z.SEMICOLON&&c===0){if(s++,s>2)break}else t.value===`(`&&c++,t.value===`)`&&c--,o[s]+=t.value}e.expect(Z.DPAREN_END),o[0].trim()&&(r=sO(e,o[0].trim())),o[1].trim()&&(i=sO(e,o[1].trim())),o[2].trim()&&(a=sO(e,o[2].trim())),e.skipNewlines(),e.check(Z.SEMICOLON)&&e.advance(),e.skipNewlines();let l;e.check(Z.LBRACE)?(e.advance(),l=e.parseCompoundList(),e.expect(Z.RBRACE)):(e.expect(Z.DO),l=e.parseCompoundList(),e.expect(Z.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:`CStyleFor`,init:r,condition:i,update:a,body:l,redirections:u,line:n}}function $O(e,t){e.expect(Z.WHILE);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.whileNode(n,r,i)}function ek(e,t){e.expect(Z.UNTIL);let n=e.parseCompoundList();e.expect(Z.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(Z.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.untilNode(n,r,i)}function tk(e,t){e.expect(Z.CASE),e.isWord()||e.error(`Expected word after 'case'`);let n=e.parseWord();e.skipNewlines(),e.expect(Z.IN),e.skipNewlines();let r=[];for(;!e.check(Z.ESAC,Z.EOF);){e.checkIterationLimit();let t=e.getPos(),n=nk(e);if(n&&r.push(n),e.skipNewlines(),e.getPos()===t&&!n)break}e.expect(Z.ESAC);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.caseNode(n,r,i)}function nk(e){e.check(Z.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(Z.PIPE));)e.advance();if(t.length===0)return null;e.expect(Z.RPAREN),e.skipNewlines();let n=[];for(;!e.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND,Z.ESAC,Z.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===Z.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(Z.LPAREN)&&e.peek(1).type===Z.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let t=e.getPos(),r=e.parseStatement();if(r&&n.push(r),e.skipSeparators(!1),e.getPos()===t&&!r)break}let r=`;;`;return e.check(Z.DSEMI)?(e.advance(),r=`;;`):e.check(Z.SEMI_AND)?(e.advance(),r=`;&`):e.check(Z.SEMI_SEMI_AND)&&(e.advance(),r=`;;&`),X.caseItem(t,n,r)}function rk(e,t){e.expect(Z.LPAREN);let n=e.parseCompoundList();e.expect(Z.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.subshell(n,r)}function ik(e,t){e.expect(Z.LBRACE);let n=e.parseCompoundList();e.expect(Z.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return X.group(n,r)}var ak=`-a.-b.-c.-d.-e.-f.-g.-h.-k.-p.-r.-s.-t.-u.-w.-x.-G.-L.-N.-O.-S.-z.-n.-o.-v.-R`.split(`.`),ok=[`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`];function sk(e){return e.isWord()||e.check(Z.LBRACE)||e.check(Z.RBRACE)||e.check(Z.ASSIGNMENT_WORD)}function ck(e){if(e.check(Z.BANG)&&e.peek(1).type===Z.LPAREN){e.advance(),e.advance();let t=1,n=`!(`;for(;t>0&&!e.check(Z.EOF);)if(e.check(Z.LPAREN))t++,n+=`(`,e.advance();else if(e.check(Z.RPAREN))t--,t>0&&(n+=`)`),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(Z.PIPE))n+=`|`,e.advance();else break;return n+=`)`,e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function lk(e){return e.skipNewlines(),uk(e)}function uk(e){let t=dk(e);for(e.skipNewlines();e.check(Z.OR_OR);){e.advance(),e.skipNewlines();let n=dk(e);t={type:`CondOr`,left:t,right:n},e.skipNewlines()}return t}function dk(e){let t=fk(e);for(e.skipNewlines();e.check(Z.AND_AND);){e.advance(),e.skipNewlines();let n=fk(e);t={type:`CondAnd`,left:t,right:n},e.skipNewlines()}return t}function fk(e){return e.skipNewlines(),e.check(Z.BANG)?(e.advance(),e.skipNewlines(),{type:`CondNot`,operand:e.withDepth(()=>fk(e))}):pk(e)}function pk(e){if(e.check(Z.LPAREN)){e.advance();let t=e.withDepth(()=>lk(e));return e.expect(Z.RPAREN),{type:`CondGroup`,expression:t}}if(sk(e)){let t=e.current(),n=t.value;if(ak.includes(n)&&!t.quoted){if(e.advance(),e.check(Z.DBRACK_END)&&e.error(`Expected operand after ${n}`),sk(e))return{type:`CondUnary`,operator:n,operand:e.parseWordNoBraceExpansion()};let t=e.current();e.error(`unexpected argument \`${t.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&ok.includes(e.current().value)){let t=e.advance().value,n;return n=t===`=~`?mk(e):t===`==`||t===`!=`?ck(e):e.parseWordNoBraceExpansion(),{type:`CondBinary`,operator:t,left:r,right:n}}return e.check(Z.LESS)?(e.advance(),{type:`CondBinary`,operator:`<`,left:r,right:e.parseWordNoBraceExpansion()}):e.check(Z.GREAT)?(e.advance(),{type:`CondBinary`,operator:`>`,left:r,right:e.parseWordNoBraceExpansion()}):e.isWord()&&e.current().value===`=`?(e.advance(),{type:`CondBinary`,operator:`==`,left:r,right:ck(e)}):{type:`CondWord`,word:r}}e.error(`Expected conditional expression`)}function mk(e){let t=[],n=0,r=-1,i=e.getInput(),a=()=>e.check(Z.DBRACK_END)||e.check(Z.AND_AND)||e.check(Z.OR_OR)||e.check(Z.NEWLINE)||e.check(Z.EOF);for(;!a();){let a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let e=i.slice(r,a.start);t.push({type:`Literal`,value:e})}if(e.isWord()||e.check(Z.ASSIGNMENT_WORD)){let n=e.parseWordForRegex();t.push(...n.parts),r=e.peek(-1).end}else if(e.check(Z.LPAREN)){let i=e.advance();t.push({type:`Literal`,value:`(`}),n++,r=i.end}else if(e.check(Z.DPAREN_START)){let i=e.advance();t.push({type:`Literal`,value:`((`}),n+=2,r=i.end}else if(e.check(Z.DPAREN_END))if(n>=2){let i=e.advance();t.push({type:`Literal`,value:`))`}),n-=2,r=i.end}else{if(n===1)break;break}else if(e.check(Z.RPAREN))if(n>0){let i=e.advance();t.push({type:`Literal`,value:`)`}),n--,r=i.end}else break;else if(e.check(Z.PIPE)){let n=e.advance();t.push({type:`Literal`,value:`|`}),r=n.end}else if(e.check(Z.SEMICOLON))if(n>0){let n=e.advance();t.push({type:`Literal`,value:`;`}),r=n.end}else break;else if(n>0&&e.check(Z.LESS)){let n=e.advance();t.push({type:`Literal`,value:`<`}),r=n.end}else if(n>0&&e.check(Z.GREAT)){let n=e.advance();t.push({type:`Literal`,value:`>`}),r=n.end}else if(n>0&&e.check(Z.DGREAT)){let n=e.advance();t.push({type:`Literal`,value:`>>`}),r=n.end}else if(n>0&&e.check(Z.DLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<`}),r=n.end}else if(n>0&&e.check(Z.LESSAND)){let n=e.advance();t.push({type:`Literal`,value:`<&`}),r=n.end}else if(n>0&&e.check(Z.GREATAND)){let n=e.advance();t.push({type:`Literal`,value:`>&`}),r=n.end}else if(n>0&&e.check(Z.LESSGREAT)){let n=e.advance();t.push({type:`Literal`,value:`<>`}),r=n.end}else if(n>0&&e.check(Z.CLOBBER)){let n=e.advance();t.push({type:`Literal`,value:`>|`}),r=n.end}else if(n>0&&e.check(Z.TLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<<`}),r=n.end}else if(n>0&&e.check(Z.AMP)){let n=e.advance();t.push({type:`Literal`,value:`&`}),r=n.end}else if(n>0&&e.check(Z.LBRACE)){let n=e.advance();t.push({type:`Literal`,value:`{`}),r=n.end}else if(n>0&&e.check(Z.RBRACE)){let n=e.advance();t.push({type:`Literal`,value:`}`}),r=n.end}else break}return t.length===0&&e.error(`Expected regex pattern after =~`),{type:`Word`,parts:t}}function hk(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=e[n+1];if(r!==`\\`||i===void 0){t+=r;continue}`\\[]^-`.includes(i)&&(t+=`\\`),t+=i,n++}return t}function gk(e){return e.length>0?e:[X.literal(``)]}function _k(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(`@*+?!`.includes(t)&&r+1<e.length&&e[r+1]===`(`){r++,n++,r++;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function vk(e,t,n){let r=n+1,i=t[r];if(`@*#?$!-0123456789`.includes(i))return{part:X.parameterExpansion(i),endIndex:r+1};let a=``;for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)a+=t[r],r++;return{part:X.parameterExpansion(a),endIndex:r}}function yk(e,t,n,r=!1){let i=n+2,a=!1;t[i]===`!`&&(a=!0,i++);let o=!1;t[i]===`#`&&!/[}:#%/^,]/.test(t[i+1]||`}`)&&(o=!0,i++);let s=``,c=t[i];if(/[@*#?$!-]/.test(c)&&!/[a-zA-Z0-9_]/.test(t[i+1]||``))s=c,i++;else for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)s+=t[i],i++;if(t[i]===`[`){let r=MO(e,t,i,`[`,`]`);if(s+=`[${kO(t.slice(i+1,r))}]`,i=r+1,t[i]===`[`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}}if(s===``&&!a&&!o&&t[i]!==`}`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;if(e>0)throw new QD(`unexpected EOF while looking for matching '}'`,0,0);let a=t.slice(n+2,r);return{part:X.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}let l=null;if(a){let n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n)if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let a=bk(e,t,i,s,r);a.operation?(l={type:`Indirection`,innerOp:a.operation},i=a.endIndex):(l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``)}else l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``;else if(t[i]===`*`||t[i]===`@`&&!/[QPaAEKkuUL]/.test(t[i+1]||``)){let e=t[i];i++,l={type:`VarNamePrefix`,prefix:s,star:e===`*`},s=``}else if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let n=bk(e,t,i,s,r);n.operation?(l={type:`Indirection`,innerOp:n.operation},i=n.endIndex):l={type:`Indirection`}}else l={type:`Indirection`}}else if(o)if(t[i]===`:`)for(l={type:`LengthSliceError`};i<t.length&&t[i]!==`}`;)i++;else t[i]!==`}`&&/[-+=?]/.test(t[i])||t[i]===`/`?e.error(`\${#${s}${t.slice(i,t.indexOf(`}`,i))}}: bad substitution`):l={type:`Length`};if(!l&&i<t.length&&t[i]!==`}`){let n=bk(e,t,i,s,r);l=n.operation,i=n.endIndex}if(i<t.length&&t[i]!==`}`){let r=t[i];if(!/[:\-+=?#%/^,@[]/.test(r)){let r=i;for(;r<t.length&&t[r]!==`}`;)r++;let a=t.slice(n,r+1);e.error(`\${${a.slice(2,-1)}}: bad substitution`)}}for(;i<t.length&&t[i]!==`}`;)i++;if(i>=t.length)throw new QD(`unexpected EOF while looking for matching '}'`,0,0);return{part:X.parameterExpansion(s,l),endIndex:i+1}}function bk(e,t,n,r,i=!1){let a=n,o=t[a],s=t[a+1]||``;if(o===`:`){let n=s;if(`-=?+`.includes(n)){a+=2;let r=NO(e,t,a),o=t.slice(a,r),s=e.withDepth(()=>wk(e,o,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(gk(s));if(n===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!0},endIndex:r};if(n===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!0},endIndex:r};if(n===`?`)return{operation:{type:`ErrorIfUnset`,word:c,checkEmpty:!0},endIndex:r};if(n===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!0},endIndex:r}}a++;let r=NO(e,t,a),o=t.slice(a,r),c=-1,l=0,u=0;for(let e=0;e<o.length;e++){let t=o[e];if(t===`(`||t===`[`)l++;else if(t===`)`||t===`]`)l--;else if(t===`?`&&l===0)u++;else if(t===`:`&&l===0)if(u>0)u--;else{c=e;break}}let d=c>=0?o.slice(0,c):o,f=c>=0?o.slice(c+1):null;return{operation:{type:`Substring`,offset:RO(e,d),length:f===null?null:RO(e,f)},endIndex:r}}if(`-=?+`.includes(o)){a++;let n=NO(e,t,a),r=t.slice(a,n),s=e.withDepth(()=>wk(e,r,!1,!1,!0,!1,i,!1,!1,!0)),c=X.word(gk(s));if(o===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!1},endIndex:n};if(o===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!1},endIndex:n};if(o===`?`)return{operation:{type:`ErrorIfUnset`,word:r?c:null,checkEmpty:!1},endIndex:n};if(o===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!1},endIndex:n}}if(o===`#`||o===`%`){let n=s===o,r=o===`#`?`prefix`:`suffix`;a+=n?2:1;let i=NO(e,t,a),c=t.slice(a,i),l=e.withDepth(()=>wk(e,c,!1,!1,!1));return{operation:{type:`PatternRemoval`,pattern:X.word(gk(l)),side:r,greedy:n},endIndex:i}}if(o===`/`){let n=s===`/`;a+=n?2:1;let r=null;t[a]===`#`?(r=`start`,a++):t[a]===`%`&&(r=`end`,a++);let i;i=r!==null&&(t[a]===`/`||t[a]===`}`)?a:PO(e,t,a);let o=t.slice(a,i),c=e.withDepth(()=>wk(e,o,!1,!1,!1)),l=X.word(gk(c)),u=null,d=i;if(t[i]===`/`){let n=i+1,r=NO(e,t,n),a=t.slice(n,r),o=e.withDepth(()=>wk(e,a,!1,!1,!1));u=X.word(gk(o)),d=r}return{operation:{type:`PatternReplacement`,pattern:l,replacement:u,all:n,anchor:r},endIndex:d}}if(o===`^`||o===`,`){let n=s===o,r=o===`^`?`upper`:`lower`;a+=n?2:1;let i=NO(e,t,a),c=t.slice(a,i);return{operation:{type:`CaseModification`,direction:r,all:n,pattern:c?X.word([X.literal(c)]):null},endIndex:i}}return o===`@`&&/[QPaAEKkuUL]/.test(s)?{operation:{type:`Transform`,operator:s},endIndex:a+2}:{operation:null,endIndex:a}}function xk(e,t,n,r=!1){let i=n+1;if(i>=t.length)return{part:X.literal(`$`),endIndex:i};let a=t[i];if(a===`(`&&t[i+1]===`(`)return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(a===`[`){let n=1,r=i+1;for(;r<t.length&&n>0;)t[r]===`[`?n++:t[r]===`]`&&n--,n>0&&r++;if(n===0){let n=sO(e,t.slice(i+1,r));return{part:X.arithmeticExpansion(n),endIndex:r+1}}}return a===`(`?e.parseCommandSubstitution(t,n):a===`{`?yk(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(a)?vk(e,t,n):{part:X.literal(`$`),endIndex:i}}function Sk(e,t){let n=[],r=0,i=``,a=()=>{i&&=(n.push(X.literal(i)),``)};for(;r<t.length;){let o=t[r];if(o===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`"`||e===`\\`){i+=e,r+=2;continue}i+=o,r++;continue}if(o===`$`){a();let{part:i,endIndex:o}=xk(e,t,r,!0);i&&n.push(i),r=o;continue}if(o==="`"){a();let{part:i,endIndex:o}=e.parseBacktickSubstitution(t,r,!0);n.push(i),r=o;continue}i+=o,r++}return a(),n}function Ck(e,t,n){let r=[],i=n,a=``,o=()=>{a&&=(r.push(X.literal(a)),``)};for(;i<t.length&&t[i]!==`"`;){let n=t[i];if(n===`\\`&&i+1<t.length){let e=t[i+1];if(`"\\$\`
889
+ `.includes(e)){a+=e,i+=2;continue}a+=n,i++;continue}if(n===`$`){o();let{part:n,endIndex:a}=xk(e,t,i,!0);n&&r.push(n),i=a;continue}if(n==="`"){o();let{part:n,endIndex:a}=e.parseBacktickSubstitution(t,i,!0);r.push(n),i=a;continue}a+=n,i++}return o(),{part:X.doubleQuoted(r),endIndex:i}}function wk(e,t,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!0){if(r)return[X.singleQuoted(t)];if(n){let n=Sk(e,t);return[X.doubleQuoted(n)]}if(t.length>=2&&t[0]===`"`&&t[t.length-1]===`"`){let n=t.slice(1,-1),r=!1;for(let e=0;e<n.length;e++){if(n[e]===`"`){r=!0;break}n[e]===`\\`&&e+1<n.length&&e++}if(!r){let t=Sk(e,n);return[X.doubleQuoted(t)]}}let d=[],f=0,p=``,m=()=>{p&&=(d.push(X.literal(p)),``)};for(;f<t.length;){let n=t[f];if(n===`\\`&&f+1<t.length){let e=t[f+1];if(c){m(),d.push(X.escaped(e)),f+=2;continue}if(!a&&!o){e!==`
890
+ `&&(m(),d.push(X.escaped(e))),f+=2;continue}let n=a?e===`$`||e==="`"||e===`
891
+ `:e===`$`||e==="`"||e===`"`||e===`'`||e===`
892
+ `||l&&e===`}`,r=o?`*?[]\\`.includes(e):`*?[]\\(){}.^+`.includes(e);n?e!==`
893
+ `&&(p+=e):r?(m(),d.push(X.escaped(e))):p+=`\\${e}`,f+=2;continue}if(n===`'`&&!o&&!a){m();let e=t.indexOf(`'`,f+1);if(e===-1){p+=t.slice(f);break}d.push(X.singleQuoted(t.slice(f+1,e))),f=e+1;continue}if(n===`"`&&!a){m();let{part:n,endIndex:r}=Ck(e,t,f+1);d.push(n),f=r+1;continue}if(n===`$`&&t[f+1]===`'`){m();let{part:n,endIndex:r}=LO(e,t,f+2);d.push(n),f=r;continue}if(n===`$`){m();let{part:n,endIndex:r}=xk(e,t,f);n&&d.push(n),f=r;continue}if(n==="`"){m();let{part:n,endIndex:r}=e.parseBacktickSubstitution(t,f);d.push(n),f=r;continue}if((n===`<`||n===`>`)&&t[f+1]===`(`&&!a&&!o){m();let{part:n,endIndex:r}=e.parseProcessSubstitutionFromString(t,f);d.push(n),f=r;continue}if(n===`~`){let n=f>0?t[f-1]:``;if(f===0&&u||n===`=`||i&&n===`:`){let n=jO(e,t,f),r=t[n];if(r===void 0||r===`/`||r===`:`){m();let e=t.slice(f+1,n)||null;d.push({type:`TildeExpansion`,user:e}),f=n;continue}}}if(`@*+?!`.includes(n)&&f+1<t.length&&t[f+1]===`(`){let e=_k(t,f+1);if(e!==-1){m();let n=t.slice(f,e+1);d.push({type:`Glob`,pattern:n}),f=e+1;continue}}if(n===`*`||n===`?`||n===`[`){m();let{pattern:n,endIndex:r}=FO(e,t,f);d.push({type:`Glob`,pattern:c?hk(n):n}),f=r;continue}if(n===`{`&&!i&&!s&&!a){let n=BO(e,t,f,wk);if(n){m(),d.push(n.part),f=n.endIndex;continue}}p+=n,f++}return m(),d}var Tk=class e{tokens=[];pos=0;pendingHeredocs=[];parseBudget;ownsParseBudget;_input=``;processLineState;constructor(e){this.parseBudget=e??new $D,this.ownsParseBudget=e===void 0}getInput(){return this._input}checkIterationLimit(){let e=this.current();this.parseBudget.chargeIteration(e?.line??1,e?.column??1)}enterDepth(){let e=this.current();return this.parseBudget.enter(e?.line??1,e?.column??1)}withDepth(e){let t=this.enterDepth();try{return e()}finally{t()}}parse(e,t){this.ownsParseBudget&&this.parseBudget.reset();let n=this.ownsParseBudget?void 0:this.enterDepth();try{if(e.length>WD)throw new QD(`Input too large: ${e.length} bytes exceeds limit of ${WD}`,1,1);this._input=e,this.processLineState=void 0;let n=new UD(e,t);if(this.tokens=n.tokenize(),this.tokens.length>GD)throw new QD(`Too many tokens: ${this.tokens.length} exceeds limit of ${GD}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseBudget.chargeTokens(this.tokens.length),this.parseScript()}finally{n?.()}}parseTokens(e){this.ownsParseBudget&&this.parseBudget.reset();let t=this.ownsParseBudget?void 0:this.enterDepth();try{return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.processLineState=void 0,this.parseBudget.chargeTokens(e.length),this.parseScript()}finally{t?.()}}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}getSourceLine(e=this.current()){let t=this.processLineState;return t?(t.currentPhysicalLine===void 0?t.currentPhysicalLine=e.line:e.line>t.currentPhysicalLine&&(t.currentPhysicalLine=e.line,t.currentLogicalLine+=1),t.currentLogicalLine):e.line}check(e,t,n,r,...i){let a=this.tokens[this.pos]?.type;return a===e||t!==void 0&&a===t||n!==void 0&&a===n||r!==void 0&&a===r||i.length>0&&i.includes(a)}expect(e,t){if(this.check(e))return this.advance();let n=this.current();throw new QD(t||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let t=this.current();throw new QD(e,t.line,t.column,t)}skipNewlines(){for(;this.check(Z.NEWLINE,Z.COMMENT);)this.check(Z.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(Z.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(Z.SEMICOLON,Z.COMMENT)){this.advance();continue}if(e&&this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,t,n,r){this.pendingHeredocs.push({redirect:e,delimiter:t,stripTabs:n,quoted:r})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(Z.HEREDOC_CONTENT)){let t=this.advance(),n;n=e.quoted?X.word([X.literal(t.value)]):this.parseWordFromString(t.value,!1,!1,!1,!0),e.redirect.target=X.hereDoc(e.delimiter,n,e.stripTabs,e.quoted,t.heredocTerminated??!1)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(Z.EOF,Z.NEWLINE,Z.SEMICOLON,Z.AMP,Z.AND_AND,Z.OR_OR,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return this.isWord()||e===Z.ASSIGNMENT_WORD||e===Z.FD_VARIABLE||e===Z.LPAREN||e===Z.LBRACE||e===Z.DPAREN_START||e===Z.DBRACK_START||UO(this)}parseScript(){let e=[],t=0;for(this.skipNewlines();!this.check(Z.EOF);){t++,t>1e4&&this.error(`Parser stuck: too many iterations (>10000)`);let n=this.checkUnexpectedToken();if(n){e.push(n),this.skipSeparators(!1);continue}let r=this.pos,i=this.parseStatement();i&&e.push(i),this.check(Z.HEREDOC_CONTENT)&&this.processHeredocs(),this.skipSeparators(!1),this.check(Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===r&&!this.check(Z.EOF)&&this.error(`syntax error near unexpected token \`${this.current().value}'`)}return X.script(e)}checkUnexpectedToken(){let e=this.current().type,t=this.current().value;if(this.currentTokenJoinsProcessSubstitution())return null;if((e===Z.DO||e===Z.DONE||e===Z.THEN||e===Z.ELSE||e===Z.ELIF||e===Z.FI||e===Z.ESAC)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.RBRACE||e===Z.RPAREN){let e=`syntax error near unexpected token \`${t}'`;return this.advance(),X.statement([X.pipeline([X.simpleCommand(null,[],[],[])])],[],!1,{message:e,token:t})}return(e===Z.DSEMI||e===Z.SEMI_AND||e===Z.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${t}'`),e===Z.SEMICOLON&&this.error(`syntax error near unexpected token \`${t}'`),(e===Z.AMP||e===Z.AND_AND||e===Z.OR_OR||e===Z.PIPE||e===Z.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${t}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,t=[],n=[],r=!1,i=this.parsePipeline();for(t.push(i);this.check(Z.AND_AND,Z.OR_OR);){let e=this.advance();n.push(e.type===Z.AND_AND?`&&`:`||`),this.skipNewlines();let r=this.parsePipeline();t.push(r)}this.check(Z.AMP)&&(this.advance(),r=!0);let a=this.pos>0?this.tokens[this.pos-1].end:e,o=this._input.slice(e,a);return X.statement(t,n,r,void 0,o)}parseTimePrefix(){if(!this.check(Z.TIME)||this.currentTokenJoinsProcessSubstitution())return;this.advance();let e=!1;return this.check(Z.WORD,Z.NAME)&&this.current().value===`-p`&&(this.advance(),e=!0),e}parsePipeline(){let e=!1,t=!1,n=0;for(;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++;if(n===0){let r=this.parseTimePrefix();if(r!==void 0)for(e=!0,t=r;this.check(Z.BANG)&&!this.currentTokenJoinsProcessSubstitution();)this.advance(),n++}let r=n%2==1,i=[],a=[],o=this.parseCommand();for(i.push(o);this.check(Z.PIPE,Z.PIPE_AMP);){let e=this.advance();this.skipNewlines(),a.push(e.type===Z.PIPE_AMP);let t=this.parseCommand();i.push(t)}return X.pipeline(i,r,e,t,a.length>0?a:void 0)}parseCommand(){if(this.currentTokenJoinsProcessSubstitution())return KO(this);let e=this.current();switch(e.type){case Z.IF:return XO(this);case Z.FOR:return ZO(this);case Z.WHILE:return $O(this);case Z.UNTIL:return ek(this);case Z.CASE:return tk(this);case Z.LPAREN:return rk(this);case Z.LBRACE:return ik(this);case Z.DPAREN_START:return this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand();case Z.DBRACK_START:return this.parseConditionalCommand();case Z.FUNCTION:return this.parseFunctionDef();case Z.TIME:break;case Z.BANG:this.error(`syntax error near unexpected token \`${e.value}'`);break;default:FD(e.type)&&this.error(`syntax error near unexpected token \`${e.value}'`)}return this.check(Z.NAME,Z.WORD)&&this.peek(1).type===Z.LPAREN&&this.peek(2).type===Z.RPAREN?this.parseFunctionDef():KO(this)}dparenClosesWithSpacedParens(){let e=1,t=1;for(;t<this.tokens.length-this.pos;){let n=this.peek(t);if(n.type===Z.EOF)return!1;if(n.type===Z.DPAREN_START||n.type===Z.LPAREN)e++;else if(n.type===Z.DPAREN_END){if(e-=2,e<=0)return!1}else if(n.type===Z.RPAREN&&(e--,e===0&&this.peek(t+1).type===Z.RPAREN))return!0;t++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(Z.RPAREN),this.expect(Z.RPAREN);let t=this.parseOptionalRedirections(),n=X.subshell(e,[]);return X.subshell([X.statement([X.pipeline([n],!1,!1,!1)])],t)}isWord(){return this.isWordToken(JD.Default)||this.isProcessSubstitutionStart()||this.currentTokenJoinsProcessSubstitution()}isWordToken(e){let t=this.current().type;return t===Z.WORD||t===Z.NAME||t===Z.NUMBER||FD(t)||t===Z.BANG||t===Z.ASSIGNMENT_WORD&&(e&JD.Regex)!==0}isProcessSubstitutionStart(e=0){let t=this.peek(e),n=this.peek(e+1);return(t.type===Z.LESS||t.type===Z.GREAT)&&n.type===Z.LPAREN&&t.end===n.start}currentTokenJoinsProcessSubstitution(){return this.current().type===Z.COMMENT||!this.isAdjacentWordToken(JD.Default)?!1:this.current().end===this.peek(1).start&&this.isProcessSubstitutionStart(1)}isAdjacentWordToken(e){let t=this.current().type;return this.isWordToken(e)||t===Z.ASSIGNMENT_WORD||t===Z.COMMENT||t===Z.LBRACE||t===Z.RBRACE||t===Z.DBRACK_START||t===Z.DBRACK_END||t===Z.FD_VARIABLE}parseWord(e=JD.Default){if(this.isProcessSubstitutionStart())return this.parseAdjacentWordParts([],this.current().start,e);let t=this.advance(),n=this.parseWordToken(t,e);return this.parseAdjacentWordParts(n.parts,t.end,e)}parseAdjacentWordParts(e,t,n=JD.Default){for(;t===this.current().start;){if(this.isProcessSubstitutionStart()){e.push(this.parseProcessSubstitution()),t=this.tokens[this.pos-1].end;continue}if(!this.isAdjacentWordToken(n))break;let r=this.advance();e.push(...this.parseWordToken(r,n,e.length===0).parts),t=r.end}return X.word(e)}parseWordNoBraceExpansion(){return this.parseWord(JD.NoBraceExpansion)}parseWordForRegex(){return this.parseWord(JD.NoBraceExpansion|JD.Regex)}parseWordToken(e,t,n=!0){return e.type===Z.LBRACE||e.type===Z.RBRACE||e.type===Z.DBRACK_START||e.type===Z.DBRACK_END||e.type===Z.FD_VARIABLE?X.word([X.literal(e.type===Z.FD_VARIABLE?`{${e.value}}`:e.value)]):this.parseWordFromString(e.value,e.quoted,e.singleQuoted,(t&JD.Assignment)!==0,!1,(t&JD.NoBraceExpansion)!==0,(t&JD.Regex)!==0,n)}parseWordFromString(e,t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!0){let c=wk(this,e,t,n,r,i,!1,a,o,!1,s);return X.word(c)}parseCommandSubstitution(t,n){return OD(t,n,()=>new e(this.parseBudget),e=>this.error(e))}parseProcessSubstitutionFromString(t,n){return kD(t,n,()=>new e(this.parseBudget),e=>this.error(e))}parseProcessSubstitution(){let e=this.advance();this.expect(Z.LPAREN);let t=this.processLineState,n=this.getSourceLine(e);this.processLineState={currentLogicalLine:n};let r;try{r=X.script(this.parseCompoundList())}finally{this.processLineState=t}return this.check(Z.EOF)&&this.error("unexpected EOF while looking for matching `)'"),this.expect(Z.RPAREN),X.processSubstitution(r,e.type===Z.LESS?`input`:`output`)}parseBacktickSubstitution(t,n,r=!1){return AD(t,n,r,()=>new e(this.parseBudget),e=>this.error(e))}isDollarDparenSubshell(e,t){return wD(e,t)}parseArithmeticExpansion(e,t){let n=t+3,r=1,i=0,a=n;for(;a<e.length-1&&r>0;)e[a]===`$`&&e[a+1]===`(`?e[a+2]===`(`?(r++,a+=3):(i++,a+=2):e[a]===`(`&&e[a+1]===`(`?(r++,a+=2):e[a]===`)`&&e[a+1]===`)`?i>0?(i--,a++):(r--,r>0&&(a+=2)):e[a]===`(`?(i++,a++):(e[a]===`)`&&i>0&&i--,a++);let o=e.slice(n,a),s=this.parseArithmeticExpression(o);return{part:X.arithmeticExpansion(s),endIndex:a+2}}parseArithmeticCommand(){let e=this.expect(Z.DPAREN_START),t=``,n=1,r=0,i=!1,a=!1;for(;n>0&&!this.check(Z.EOF);){if(i){if(i=!1,r>0){r--,t+=`)`;continue}if(this.check(Z.RPAREN)){n--,a=!0,this.advance();continue}if(this.check(Z.DPAREN_END)){n--,a=!0;continue}t+=`)`;continue}if(this.check(Z.DPAREN_START))n++,t+=`((`,this.advance();else if(this.check(Z.DPAREN_END))r>=2?(r-=2,t+=`))`,this.advance()):r===1?(r--,t+=`)`,i=!0,this.advance()):(n--,a=!0,n>0&&(t+=`))`),this.advance());else if(this.check(Z.LPAREN))r++,t+=`(`,this.advance();else if(this.check(Z.RPAREN))r>0&&r--,t+=`)`,this.advance();else{let e=this.current().value,n=t.length>0?t[t.length-1]:``;t.length>0&&!t.endsWith(` `)&&!(e===`=`&&/[|&^+\-*/%<>]$/.test(t))&&(e!==`<`||n!==`<`)&&(e!==`>`||n!==`>`)&&(t+=` `),t+=e,this.advance()}}a||this.expect(Z.DPAREN_END);let o=this.parseArithmeticExpression(t.trim()),s=this.parseOptionalRedirections();return X.arithmeticCommand(o,s,this.getSourceLine(e))}parseConditionalCommand(){let e=this.expect(Z.DBRACK_START),t=lk(this);this.expect(Z.DBRACK_END);let n=this.parseOptionalRedirections();return X.conditionalCommand(t,n,this.getSourceLine(e))}parseFunctionDef(){let e;if(this.check(Z.FUNCTION)){if(this.advance(),this.check(Z.NAME)||this.check(Z.WORD))e=this.advance().value;else{let e=this.current();throw new QD(`Expected function name`,e.line,e.column,e)}this.check(Z.LPAREN)&&(this.advance(),this.expect(Z.RPAREN))}else e=this.advance().value,e.includes(`$`)&&this.error(`\`${e}': not a valid identifier`),this.expect(Z.LPAREN),this.expect(Z.RPAREN);this.skipNewlines();let t=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return X.functionDef(e,t,n)}parseCompoundCommandBody(e){let t=e?.forFunctionBody;if(this.check(Z.LBRACE))return ik(this,{skipRedirections:t});if(this.check(Z.LPAREN))return rk(this,{skipRedirections:t});if(this.check(Z.IF))return XO(this,{skipRedirections:t});if(this.check(Z.FOR))return ZO(this,{skipRedirections:t});if(this.check(Z.WHILE))return $O(this,{skipRedirections:t});if(this.check(Z.UNTIL))return ek(this,{skipRedirections:t});if(this.check(Z.CASE))return tk(this,{skipRedirections:t});this.error(`Expected compound command for function body`)}parseCompoundList(){let e=this.enterDepth();try{let e=[];for(this.skipNewlines();(this.currentTokenJoinsProcessSubstitution()||!this.check(Z.EOF,Z.FI,Z.ELSE,Z.ELIF,Z.THEN,Z.DO,Z.DONE,Z.ESAC,Z.RPAREN,Z.RBRACE,Z.DSEMI,Z.SEMI_AND,Z.SEMI_SEMI_AND))&&this.isCommandStart();){this.checkIterationLimit();let t=this.pos,n=this.parseStatement();if(n&&e.push(n),this.skipSeparators(),this.pos===t&&!n)break}return e}finally{e()}}parseOptionalRedirections(){let e=[];for(;UO(this);){this.checkIterationLimit();let t=this.pos;if(e.push(WO(this)),this.pos===t)break}return e}parseArithmeticExpression(e){return sO(this,e)}};function Ek(e,t){return new Tk().parse(e,t)}function Dk(e){return Ok(e)}function Ok(e){return e.statements.map(kk).join(`
894
+ `)}function kk(e){let t=[];for(let n=0;n<e.pipelines.length;n++)t.push(Ak(e.pipelines[n])),n<e.operators.length&&t.push(e.operators[n]);let n=t.join(` `);return e.background&&(n+=` &`),n}function Ak(e){let t=[];e.timed&&t.push(e.timePosix?`time -p`:`time`),e.negated&&t.push(`!`);let n=[];for(let t=0;t<e.commands.length;t++)if(n.push(jk(e.commands[t])),t<e.commands.length-1){let r=e.pipeStderr?.[t];n.push(r?`|&`:`|`)}return(t.length>0?`${t.join(` `)} `:``)+n.join(` `)}function jk(e){switch(e.type){case`SimpleCommand`:return Mk(e);case`If`:return Yk(e);case`For`:return Xk(e);case`CStyleFor`:return Zk(e);case`While`:return Qk(e);case`Until`:return $k(e);case`Case`:return eA(e);case`Subshell`:return nA(e);case`Group`:return rA(e);case`ArithmeticCommand`:return iA(e);case`ConditionalCommand`:return aA(e);case`FunctionDef`:return oA(e);default:throw Error(`Unsupported command type: ${e.type}`)}}function Mk(e){let t=[];for(let n of e.assignments)t.push(Nk(n));e.name&&t.push(Pk(e.name));for(let n of e.args)t.push(Pk(n));for(let n of e.redirections)t.push(Kk(n));return t.join(` `)}function Nk(e){let t=e.append?`+=`:`=`;if(e.array){let n=e.array.map(Pk).join(` `);return`${e.name}${t}(${n})`}return e.value?`${e.name}${t}${Pk(e.value)}`:`${e.name}${t}`}function Pk(e){return e.parts.map(e=>Ik(e,!1)).join(``)}function Fk(e){return e.parts.map(e=>Ik(e,!0)).join(``)}function Ik(e,t){switch(e.type){case`Literal`:return t?Rk(e.value):Lk(e.value);case`SingleQuoted`:return`'${e.value}'`;case`DoubleQuoted`:return`"${e.parts.map(e=>Ik(e,!0)).join(``)}"`;case`Escaped`:return`\\${e.value}`;case`ParameterExpansion`:return Vk(e);case`CommandSubstitution`:return e.legacy?`\`${Ok(e.body)}\``:`$(${Ok(e.body)})`;case`ArithmeticExpansion`:return`$((${sA(e.expression.expression)}))`;case`ProcessSubstitution`:return e.direction===`input`?`<(${Ok(e.body)})`:`>(${Ok(e.body)})`;case`BraceExpansion`:return Wk(e);case`TildeExpansion`:return e.user===null?`~`:`~${e.user}`;case`Glob`:return e.pattern;default:throw Error(`Unsupported word part type: ${e.type}`)}}function Lk(e){return e.replace(/[\s\\'"`!|&;()<>{}[\]*?~#]/g,`\\$&`)}function Rk(e){return e.replace(/[$`"\\]/g,`\\$&`)}function zk(e,t){return e.parts.map(e=>Bk(e,t)).join(``)}function Bk(e,t){switch(e.type){case`Literal`:return t?e.value:e.value.replace(/[$`]/g,`\\$&`);case`Escaped`:return`\\${e.value}`;case`ParameterExpansion`:return Vk(e);case`CommandSubstitution`:return e.legacy?`\`${Ok(e.body)}\``:`$(${Ok(e.body)})`;case`ArithmeticExpansion`:return`$((${sA(e.expression.expression)}))`;default:return Ik(e,!1)}}function Vk(e){return e.operation?`\${${Uk(e.parameter,e.operation)}}`:Hk(e.parameter)?`\${${e.parameter}}`:`$${e.parameter}`}function Hk(e){return!(/^[?#@*$!\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function Uk(e,t){switch(t.type){case`Length`:return`#${e}`;case`LengthSliceError`:return`#${e}:`;case`BadSubstitution`:return t.text;case`DefaultValue`:return`${e}${t.checkEmpty?`:`:``}-${Fk(t.word)}`;case`AssignDefault`:return`${e}${t.checkEmpty?`:`:``}=${Fk(t.word)}`;case`ErrorIfUnset`:return`${e}${t.checkEmpty?`:`:``}?${t.word?Fk(t.word):``}`;case`UseAlternative`:return`${e}${t.checkEmpty?`:`:``}+${Fk(t.word)}`;case`Substring`:{let n=sA(t.offset.expression);return t.length?`${e}:${n}:${sA(t.length.expression)}`:`${e}:${n}`}case`PatternRemoval`:{let n=t.side===`prefix`?`#`:`%`;return`${e}${t.greedy?`${n}${n}`:n}${Fk(t.pattern)}`}case`PatternReplacement`:{let n=`/`;t.all?n=`//`:t.anchor===`start`?n=`/#`:t.anchor===`end`&&(n=`/%`);let r=t.replacement?`/${Fk(t.replacement)}`:``;return`${e}${n}${Fk(t.pattern)}${r}`}case`CaseModification`:{let n=t.direction===`upper`?`^`:`,`;return`${e}${t.all?`${n}${n}`:n}${t.pattern?Fk(t.pattern):``}`}case`Transform`:return`${e}@${t.operator}`;case`Indirection`:return t.innerOp?`!${Uk(e,t.innerOp)}`:`!${e}`;case`ArrayKeys`:return`!${t.array}[${t.star?`*`:`@`}]`;case`VarNamePrefix`:return`!${t.prefix}${t.star?`*`:`@`}`;default:throw Error(`Unsupported parameter operation type: ${t.type}`)}}function Wk(e){return`{${e.items.map(Gk).join(`,`)}}`}function Gk(e){if(e.type===`Word`)return Pk(e.word);let t=e.startStr??String(e.start),n=e.endStr??String(e.end);return e.step===void 0?`${t}..${n}`:`${t}..${n}..${e.step}`}function Kk(e){let t=e.fdVariable?`{${e.fdVariable}}`:e.fd===null?``:String(e.fd);if(e.operator===`<<`||e.operator===`<<-`){let n=e.target;if(n.terminated===!1)throw Error(`Cannot serialize an unterminated here-document`);let r=n.quoted?`'${n.delimiter}'`:n.delimiter,i=zk(n.content,n.quoted);return`${t}${e.operator}${r}
895
+ ${i}${n.delimiter}`}return e.operator===`<<<`?`${t}<<< ${Pk(e.target)}`:e.operator===`&>`||e.operator===`&>>`?`${e.operator} ${Pk(e.target)}`:`${t}${e.operator} ${Pk(e.target)}`}function qk(e){return e.length===0?``:` ${e.map(Kk).join(` `)}`}function Jk(e){return e.map(kk).join(`
896
+ `)}function Yk(e){let t=[];for(let n=0;n<e.clauses.length;n++){let r=e.clauses[n],i=n===0?`if`:`elif`;t.push(`${i} ${Jk(r.condition)}; then
897
+ ${Jk(r.body)}`)}return e.elseBody&&t.push(`else
898
+ ${Jk(e.elseBody)}`),`${t.join(`
899
+ `)}
900
+ fi${qk(e.redirections)}`}function Xk(e){let t;if(e.words===null)t=`for ${e.variable}`;else{let n=e.words.map(Pk).join(` `);t=`for ${e.variable} in ${n}`}return`${t}; do
901
+ ${Jk(e.body)}
902
+ done${qk(e.redirections)}`}function Zk(e){return`for ((${e.init?sA(e.init.expression):``}; ${e.condition?sA(e.condition.expression):``}; ${e.update?sA(e.update.expression):``})); do
903
+ ${Jk(e.body)}
904
+ done${qk(e.redirections)}`}function Qk(e){return`while ${Jk(e.condition)}; do
905
+ ${Jk(e.body)}
906
+ done${qk(e.redirections)}`}function $k(e){return`until ${Jk(e.condition)}; do
907
+ ${Jk(e.body)}
908
+ done${qk(e.redirections)}`}function eA(e){let t=e.items.map(tA).join(`
909
+ `);return`case ${Pk(e.word)} in
910
+ ${t}
911
+ esac${qk(e.redirections)}`}function tA(e){let t=e.patterns.map(Pk).join(` | `),n=Jk(e.body);return n?`${t})
912
+ ${n}
913
+ ${e.terminator}`:`${t})
914
+ ${e.terminator}`}function nA(e){return`(${Jk(e.body)})${qk(e.redirections)}`}function rA(e){return`{ ${Jk(e.body)}; }${qk(e.redirections)}`}function iA(e){return`((${sA(e.expression.expression)}))${qk(e.redirections)}`}function aA(e){return`[[ ${cA(e.expression)} ]]${qk(e.redirections)}`}function oA(e){let t=jk(e.body);return`${e.name}() ${t}${qk(e.redirections)}`}function sA(e){switch(e.type){case`ArithNumber`:return String(e.value);case`ArithVariable`:return e.hasDollarPrefix?`$${e.name}`:e.name;case`ArithSpecialVar`:return`$${e.name}`;case`ArithBinary`:return`${sA(e.left)} ${e.operator} ${sA(e.right)}`;case`ArithUnary`:return e.prefix?`${e.operator}${sA(e.operand)}`:`${sA(e.operand)}${e.operator}`;case`ArithTernary`:return`${sA(e.condition)} ? ${sA(e.consequent)} : ${sA(e.alternate)}`;case`ArithAssignment`:return`${e.subscript?`${e.variable}[${sA(e.subscript)}]`:e.stringKey===void 0?e.variable:`${e.variable}[${e.stringKey}]`} ${e.operator} ${sA(e.value)}`;case`ArithDynamicAssignment`:return`${e.subscript?`${sA(e.target)}[${sA(e.subscript)}]`:sA(e.target)} ${e.operator} ${sA(e.value)}`;case`ArithDynamicElement`:return`${sA(e.nameExpr)}[${sA(e.subscript)}]`;case`ArithGroup`:return`(${sA(e.expression)})`;case`ArithNested`:return`$((${sA(e.expression)}))`;case`ArithCommandSubst`:return`$(${e.command})`;case`ArithBracedExpansion`:return`\${${e.content}}`;case`ArithArrayElement`:return e.stringKey===void 0?e.index?`${e.array}[${sA(e.index)}]`:e.array:`${e.array}[${e.stringKey}]`;case`ArithDynamicBase`:return`\${${e.baseExpr}}#${e.value}`;case`ArithDynamicNumber`:return`\${${e.prefix}}${e.suffix}`;case`ArithConcat`:return e.parts.map(sA).join(``);case`ArithDoubleSubscript`:return`${e.array}[${sA(e.index)}]`;case`ArithNumberSubscript`:return`${e.number}[${e.errorToken}]`;case`ArithSyntaxError`:return e.errorToken;case`ArithSingleQuote`:return`'${e.content}'`;default:throw Error(`Unsupported arithmetic expression type: ${e.type}`)}}function cA(e){switch(e.type){case`CondBinary`:return`${Pk(e.left)} ${e.operator} ${Pk(e.right)}`;case`CondUnary`:return`${e.operator} ${Pk(e.operand)}`;case`CondNot`:return`! ${cA(e.operand)}`;case`CondAnd`:return`${cA(e.left)} && ${cA(e.right)}`;case`CondOr`:return`${cA(e.left)} || ${cA(e.right)}`;case`CondGroup`:return`( ${cA(e.expression)} )`;case`CondWord`:return Pk(e.word);default:throw Error(`Unsupported conditional expression type: ${e.type}`)}}j();var lA=`BASH_ALIAS_`;function uA(e,t,n,r){let i=O(t);if(i>n-r.value)throw new A(`alias expansion exceeds string length limit (${n} bytes)`,`string_length`);return r.value+=i,e+t}function dA(e){return e.parts.length===1&&e.parts[0].type===`Literal`}function fA(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type===`Literal`?t.value:null}function pA(e,t){return e.env.get(`${lA}${t}`)}function mA(e,t,n){return hA(e,t,n)}function hA(e,t,n,r=!0){if(!t.name||!dA(t.name))return t;let i=fA(t.name);if(!i)return t;let a=pA(e,i);if(!a||n.has(i))return t;try{n.add(i);let o=new Tk,s={value:0},c=uA(``,a,e.limits.maxStringLength,s),l=a.endsWith(` `);if(!l)for(let n of t.args){let t=Pk(n);c=uA(c,` ${t}`,e.limits.maxStringLength,s)}let u;try{u=o.parse(c)}catch(e){if(e instanceof QD)throw e;return t}if(u.statements.length!==1||u.statements[0].pipelines.length!==1||u.statements[0].pipelines[0].commands.length!==1)return gA(e,t,a);let d=u.statements[0].pipelines[0].commands[0];if(d.type!==`SimpleCommand`)return gA(e,t,a);let f={...d,assignments:[...t.assignments,...d.assignments],redirections:[...d.redirections,...t.redirections],line:t.line};if(l&&t.args.length>0){f={...f,args:[...f.args,...t.args]};let i=1;for(;r&&f.args.length>0;){let t=f.args[0];if(!dA(t))break;let r=fA(t),a=r?pA(e,r):null;if(!a)break;if(i>=e.limits.maxCallDepth)throw new A(`alias expansion depth limit exceeded (${e.limits.maxCallDepth})`,`recursion`);i++;let o={type:`SimpleCommand`,name:t,args:f.args.slice(1),assignments:[],redirections:[]},s=hA(e,o,n,!1);if(s===o||(f={...f,name:s.name,args:[...s.args]},!a.endsWith(` `)))break}}return f}catch(e){throw n.delete(i),e}}function gA(e,t,n){let r={value:0},i=uA(``,n,e.limits.maxStringLength,r);for(let n of t.args){let t=Pk(n);i=uA(i,` ${t}`,e.limits.maxStringLength,r)}let a=new Tk,o=a.parseWordFromString(`eval`,!1,!1),s=0;for(let e of i)e===`'`&&s++;if(r.value+2+s*3>e.limits.maxStringLength)throw new A(`alias expansion exceeds string length limit (${e.limits.maxStringLength} bytes)`,`string_length`);return{type:`SimpleCommand`,name:o,args:[a.parseWordFromString(`'${i.replace(/'/g,`'\\''`)}'`,!1,!1)],assignments:t.assignments,redirections:t.redirections,line:t.line}}j(),j(),mc(),qr(),mc();var _A=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9a-fA-F`]]);function vA(e){return _A.get(e)??``}function yA(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`[`){for(n+=i,r++,r<e.length&&(e[r]===`!`||e[r]===`^`)&&(n+=e[r],r++),r<e.length&&e[r]===`]`&&(n+=e[r],r++);r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){n+=e.slice(r,t+2),r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]===`]`&&(n+=e[r],r++)}else i===`:`?(n!==``&&t.push(n),n=``,r++):i===`\\`&&r+1<e.length?(n+=i+e[r+1],r+=2):(n+=i,r++)}return n!==``&&t.push(n),t}function bA(e){let t=`^`;for(let n=0;n<e.length;n++){let r=e[n];if(r===`*`)t+=`[^/]*`;else if(r===`?`)t+=`[^/]`;else if(r===`[`){let r=n+1,i=`[`;r<e.length&&(e[r]===`^`||e[r]===`!`)&&(i+=`^`,r++),r<e.length&&e[r]===`]`&&(i+=`\\]`,r++);let a=r;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=r;for(;r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){let n=vA(e.slice(r+2,t));i+=n,r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){i+=`\\${e[r+1]}`,r+=2;continue}if(e[r]===`-`){let e=r===o,t=r+1===a;i+=e||t?`\\-`:`-`}else i+=e[r];r++}i+=`]`,t+=i,n=r}else if(r===`\\`&&n+1<e.length){let r=e[n+1];/[.+^${}()|\\*?[\]]/.test(r)?t+=`\\${r}`:t+=r,n++}else/[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+=`$`,U(t)}function xA(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function SA(e){let t=[],n=``,r=0,i=!1,a=0;for(;a<e.length;){let o=e[a];if(o===`'`&&!i){i=!0,n+=`\0QUOTE_START\0`,a++;continue}if(o===`'`&&i){i=!1,n+=`\0QUOTE_END\0`,a++;continue}if(i){n+=o,a++;continue}if(o===`\\`){n+=o,a+1<e.length?(n+=e[a+1],a+=2):a++;continue}o===`(`?(r++,n+=o):o===`)`?(r--,n+=o):o===`|`&&r===0?(t.push(n),n=``):n+=o,a++}return t.push(n),t}var CA=5,wA=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;consumeOperation;constructor(e,t,n,r){this.fs=e,this.cwd=t,typeof r==`boolean`?(this.globstar=r,this.maxOps=1e5):r?(this.globstar=r.globstar??!1,this.nullglob=r.nullglob??!1,this.failglob=r.failglob??!1,this.dotglob=r.dotglob??!1,this.extglob=r.extglob??!1,this.globskipdots=r.globskipdots??!0,this.maxOps=r.maxGlobOperations??1e5,this.consumeOperation=r.consumeOperation):this.maxOps=1e5;let i=n?.get(`GLOBIGNORE`);i!==void 0&&i!==``&&(this.hasGlobignore=!0,this.globignorePatterns=yA(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new A(`Glob operation limit exceeded (${this.maxOps})`,`glob_operations`);this.consumeOperation?.()}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(e=>{let t=e.split(`/`).pop()||e;if((this.hasGlobignore||this.globskipdots)&&(t===`.`||t===`..`))return!1;if(this.hasGlobignore){for(let t of this.globignorePatterns)if(this.matchGlobignorePattern(e,t))return!1}return!0})}matchGlobignorePattern(e,t){return bA(t).test(e)}isGlobPattern(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,t){let n=e.map((e,n)=>(t?.[n]??!1)||!this.isGlobPattern(e)?null:this.expand(e)),r=await Promise.all(n.map(e=>e||Promise.resolve(null))),i=[];for(let t=0;t<e.length;t++){let n=r[t];n===null?i.push(e[t]):n.length>0?i.push(...n):i.push(e[t])}return i}async expand(e){if(this.globstar){let t=e.split(`/`),n=0;for(let e of t)if(e===`**`&&(n++,n>CA))throw new A(`Glob pattern has too many ** segments (max ${CA})`,`glob_operations`)}let t;if(e.includes(`**`)&&this.globstar&&this.isGlobstarValid(e))t=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,`*`);t=await this.expandSimple(n)}return this.filterGlobignore(t)}isGlobstarValid(e){let t=e.split(`/`);for(let e of t)if(e.includes(`**`)&&e!==`**`)return!1;return!0}hasGlobChars(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e!==``),r=-1;for(let e=0;e<n.length;e++)if(this.hasGlobChars(n[e])){r=e;break}if(r===-1)return[e];let i,a;if(r===0)t?(i=`/`,a=`/`):(i=this.cwd,a=``);else{let e=n.slice(0,r);t?(i=`/${e.join(`/`)}`,a=`/${e.join(`/`)}`):(i=this.fs.resolvePath(this.cwd,e.join(`/`)),a=e.join(`/`))}let o=n.slice(r);return(await this.expandSegments(i,a,o)).sort()}async expandSegments(e,t,n){if(this.checkOpsLimit(),n.length===0)return[t];let[r,...i]=n,a=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let n=await this.fs.readdirWithFileTypes(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;if(r.startsWith(`.`)||this.dotglob){let e=n.some(e=>e.name===`.`),t=n.some(e=>e.name===`..`);e||s.push({name:`.`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}),t||s.push({name:`..`,isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let n of s)if(!(n.name.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n.name,r)){let r=e===`/`?`/${n.name}`:`${e}/${n.name}`,a;a=t===``?n.name:t===`/`?`/${n.name}`:`${t}/${n.name}`,i.length===0?o.push(Promise.resolve([a])):n.isDirectory&&o.push(this.expandSegments(r,a,i))}let l=await Promise.all(o);for(let e of l)a.push(...e)}else{this.checkOpsLimit();let n=await this.fs.readdir(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;(r.startsWith(`.`)||this.dotglob)&&(n.includes(`.`)||s.push(`.`),n.includes(`..`)||s.push(`..`));for(let n of s)if(!(n.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n,r)){let r=e===`/`?`/${n}`:`${e}/${n}`,a;a=t===``?n:t===`/`?`/${n}`:`${t}/${n}`,i.length===0?o.push(Promise.resolve([a])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory)return this.expandSegments(r,a,i)}catch(e){if(e instanceof A)throw e}return[]})())}let l=await Promise.all(o);for(let e of l)a.push(...e)}}catch(e){if(e instanceof A)throw e}return a}async expandRecursive(e){let t=[],n=e.indexOf(`**`),r=e.slice(0,n).replace(/\/$/,``)||`.`,i=e.slice(n+2).replace(/^\//,``);return i.includes(`**`)&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(r,i,t),[...new Set(t)].sort()):(await this.walkDirectory(r,i,t),t.sort())}async walkDirectoryMultiGlobstar(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(r):null;if(i){let r=[];for(let t of i){let n=e===`.`?t.name:`${e}/${t.name}`;t.isDirectory&&r.push(n)}let a=e===`.`?t:`${e}/${t}`,o=await this.expandRecursive(a);n.push(...o);for(let e=0;e<r.length;e+=100){let i=r.slice(e,e+100);await Promise.all(i.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t of i){let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory&&a.push(n)}catch(e){if(e instanceof A)throw e}}let o=e===`.`?t:`${e}/${t}`,s=await this.expandRecursive(o);n.push(...s);for(let e=0;e<a.length;e+=100){let r=a.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}}catch(e){if(e instanceof A)throw e}}async walkDirectory(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(r),a=[],o=[];for(let n of i){let r=e===`.`?n.name:`${e}/${n.name}`;n.isDirectory?o.push(r):t&&this.matchPattern(n.name,t)&&a.push(r)}n.push(...a);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t=0;t<i.length;t+=100){let n=i.slice(t,t+100),r=await Promise.all(n.map(async t=>{let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{return this.checkOpsLimit(),{name:t,path:n,isDirectory:(await this.fs.stat(r)).isDirectory}}catch(e){if(e instanceof A)throw e;return null}}));a.push(...r.filter(e=>e!==null))}for(let e of a)!e.isDirectory&&t&&this.matchPattern(e.name,t)&&n.push(e.path);let o=a.filter(e=>e.isDirectory);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e.path,t,n)))}}}catch(e){if(e instanceof A)throw e}}matchPattern(e,t){return this.patternToRegex(t).test(e)}patternToRegex(e){return U(`^${this.patternToRegexStr(e)}$`)}patternToRegexStr(e){let t=``,n=!1;for(let r=0;r<e.length;r++){if(e.slice(r,r+13)===`\0QUOTE_START\0`){n=!0,r+=12;continue}if(e.slice(r,r+11)===`\0QUOTE_END\0`){n=!1,r+=10;continue}let i=e[r];if(n){/[.+^${}()|\\*?[\]]/.test(i)?t+=`\\${i}`:t+=i;continue}if(this.extglob&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let n=xA(e,r+1);if(n!==-1){let a=SA(e.slice(r+2,n)),o=a.map(e=>this.patternToRegexStr(e)),s=o.length>0?o.join(`|`):`(?:)`;if(i===`@`)t+=`(?:${s})`;else if(i===`*`)t+=`(?:${s})*`;else if(i===`+`)t+=`(?:${s})+`;else if(i===`?`)t+=`(?:${s})?`;else if(i===`!`)if(n<e.length-1){let e=a.map(e=>this.computePatternLength(e));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let n=e[0];if(n===0)t+=`(?:.+)`;else{let e=[];n>0&&e.push(`.{0,${n-1}}`),e.push(`.{${n+1},}`),e.push(`(?!(?:${s})).{${n}}`),t+=`(?:${e.join(`|`)})`}}else t+=`(?:(?!(?:${s})).)*?`}else t+=`(?!(?:${s})$).*`;r=n;continue}}if(i===`*`)t+=`.*`;else if(i===`?`)t+=`.`;else if(i===`[`){let n=r+1,i=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(i+=`^`,n++),n<e.length&&e[n]===`]`&&(i+=`\\]`,n++);let a=n;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=n;for(;n<e.length&&e[n]!==`]`;){if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=vA(e.slice(n+2,t));i+=r,n=t+2;continue}}if(e[n]===`\\`&&n+1<e.length){i+=`\\${e[n+1]}`,n+=2;continue}if(e[n]===`-`){let e=n===o,t=n+1===a;i+=e||t?`\\-`:`-`}else i+=e[n];n++}i+=`]`,t+=i,r=n}else if(i===`\\`&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\*?[\]]/.test(n)?t+=`\\${n}`:t+=n,r++}else/[.+^${}()|]/.test(i)?t+=`\\${i}`:t+=i}return t}computePatternLength(e){let t=0,n=0,r=!1;for(;n<e.length;){if(e.slice(n,n+13)===`\0QUOTE_START\0`){r=!0,n+=13;continue}if(e.slice(n,n+11)===`\0QUOTE_END\0`){r=!1,n+=11;continue}let i=e[n];if(r){t+=1,n++;continue}if((i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&n+1<e.length&&e[n+1]===`(`){let r=xA(e,n+1);if(r!==-1){if(i===`@`){let i=SA(e.slice(n+2,r)).map(e=>this.computePatternLength(e));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){t+=i[0],n=r+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){t+=1,n++;continue}if(i===`[`){let r=e.indexOf(`]`,n+1);if(r!==-1){t+=1,n=r+1;continue}t+=1,n++;continue}if(i===`\\`){t+=1,n+=2;continue}t+=1,n++}return t}};j();function TA(e){for(let t=0;t<e.length;t++){if(e[t]===`\\`){t++;continue}if(e[t]===`$`){let n=e[t+1];if(n===`{`||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function EA(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n)return!1;for(let e of n)if(e.type===`DoubleQuoted`||e.type===`SingleQuoted`)return!0;return!1}function DA(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n||n.length===0)return!1;for(let e of n)if(e.type!==`DoubleQuoted`&&e.type!==`SingleQuoted`)return!1;return!0}function OA(e){let t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1;for(let c of e){if((c.type===`SingleQuoted`||c.type===`DoubleQuoted`)&&(t=!0,c.type===`DoubleQuoted`))for(let e of c.parts)e.type===`ParameterExpansion`&&(e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!e.operation||e.operation.type===`PatternRemoval`||e.operation.type===`PatternReplacement`)&&(i=!0),(e.operation?.type===`VarNamePrefix`||e.operation?.type===`ArrayKeys`)&&(o=!0),e.operation?.type===`Indirection`&&(s=!0));c.type===`CommandSubstitution`&&(n=!0),c.type===`ParameterExpansion`&&(a=!0,(c.parameter===`@`||c.parameter===`*`)&&(r=!0),EA(c)&&(t=!0),(c.operation?.type===`VarNamePrefix`||c.operation?.type===`ArrayKeys`)&&(o=!0),c.operation?.type===`Indirection`&&(s=!0)),c.type===`Glob`&&TA(c.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:i,hasParamExpansion:a,hasVarNamePrefixExpansion:o,hasIndirection:s}}j(),j();var kA=`
915
+ `;function AA(e,t){if(e>=t)throw new A(`array element limit exceeded (${t})`,`array_elements`)}function jA(e,t,n,r,i){AA(e.length,i),AA(t.length,i),e.push(n),t.push(r)}function MA(e){return e.get(`IFS`)??kA}function NA(e){return e.get(`IFS`)===``}function PA(e){let t=MA(e);if(t===``)return!0;for(let e of t)if(e!==` `&&e!==` `&&e!==`
916
+ `)return!1;return!0}function FA(e){let t=!1,n=[];for(let r of e.split(``))r===`-`?t=!0:/[\\^$.*+?()[\]{}|]/.test(r)?n.push(`\\${r}`):r===` `?n.push(`\\t`):r===`
917
+ `?n.push(`\\n`):n.push(r);return t&&n.push(`\\-`),n.join(``)}function IA(e){let t=e.get(`IFS`);return t===void 0?` `:t[0]||``}var LA=`
918
+ `;function RA(e){return LA.includes(e)}function zA(e){let t=new Set,n=new Set;for(let r of e)RA(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function BA(e,t,n,r,i){if(t===``)return e===``?{words:[],wordStarts:[]}:(AA(0,n),{words:[e],wordStarts:[0]});let{whitespace:a,nonWhitespace:o}=zA(t),s=[],c=[],l=0;for(;l<e.length&&a.has(e[l]);)l++;if(l>=e.length)return{words:[],wordStarts:[]};if(o.has(e[l]))for(jA(s,c,``,l,n),l++;l<e.length&&a.has(e[l]);)l++;for(;l<e.length&&!(r!==void 0&&s.length>=r);){let t=l;for(;l<e.length;){let t=e[l];if(!i&&t===`\\`){l++,l<e.length&&l++;continue}if(a.has(t)||o.has(t))break;l++}if(jA(s,c,e.substring(t,l),t,n),l>=e.length)break;for(;l<e.length&&a.has(e[l]);)l++;if(l<e.length&&o.has(e[l])){for(l++;l<e.length&&a.has(e[l]);)l++;for(;l<e.length&&o.has(e[l])&&!(r!==void 0&&s.length>=r);)for(jA(s,c,``,l,n),l++;l<e.length&&a.has(e[l]);)l++}}return{words:s,wordStarts:c}}function VA(e,t,n){if(t===``)return e&&AA(0,n),{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e===``)return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:r,nonWhitespace:i}=zA(t),a=[],o=0,s=!1,c=!1,l=o;for(;o<e.length&&r.has(e[o]);)o++;if(o>l&&(s=!0),o>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(i.has(e[o]))for(AA(a.length,n),a.push(``),o++;o<e.length&&r.has(e[o]);)o++;for(;o<e.length;){let t=o;for(;o<e.length;){let t=e[o];if(r.has(t)||i.has(t))break;o++}if(AA(a.length,n),a.push(e.substring(t,o)),o>=e.length){c=!1;break}let s=o;for(;o<e.length&&r.has(e[o]);)o++;if(o<e.length&&i.has(e[o])){for(o++;o<e.length&&r.has(e[o]);)o++;for(;o<e.length&&i.has(e[o]);)for(AA(a.length,n),a.push(``),o++;o<e.length&&r.has(e[o]);)o++}o>=e.length&&o>s&&(c=!0)}return{words:a,hadLeadingDelimiter:s,hadTrailingDelimiter:c}}function HA(e,t,n){return VA(e,t,n).words}function UA(e,t){for(let n of e)if(t.has(n))return!0;return!1}function WA(e,t,n){if(t===``)return e;let{whitespace:r,nonWhitespace:i}=zA(t),a=e.length;for(;a>0&&r.has(e[a-1]);){if(!n&&a>=2){let t=0,n=a-2;for(;n>=0&&e[n]===`\\`;)t++,n--;if(t%2==1)break}a--}let o=e.substring(0,a);if(o.length>=1&&i.has(o[o.length-1])){if(!n&&o.length>=2){let e=0,t=o.length-2;for(;t>=0&&o[t]===`\\`;)e++,t--;if(e%2==1)return o}let e=o.substring(0,o.length-1);if(!UA(e,i))return e}return o}function GA(e,t){return e.state.namerefs?.has(t)??!1}function KA(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function qA(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function JA(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function YA(e,t){return e.state.invalidNamerefs?.has(t)??!1}function XA(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function ZA(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=iD(e,t),i=e.state.associativeArrays?.has(t)??!1;return r||i}return iD(e,t)?!0:e.state.env.has(t)}function QA(e,t,n=100){if(!GA(e,t)||YA(e,t))return t;let r=new Set,i=t;for(;n-->0;){if(r.has(i))return;if(r.add(i),!GA(e,i))return i;let t=e.state.env.get(i);if(t===void 0||t===``||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return i;i=t}}function $A(e,t){if(GA(e,t))return e.state.env.get(t)}function ej(e,t,n,r=100){if(!GA(e,t)||YA(e,t))return t;let i=new Set,a=t;for(;r-->0;){if(i.has(a))return;if(i.add(a),!GA(e,a))return a;let t=e.state.env.get(a);if(t===void 0||t===``)return n===void 0||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&ZA(e,n)?a:null;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return a;a=t}}function tj(e,t){let n=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(t,n)=>e.state.env.get(n)??``);return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(t,n)=>e.state.env.get(n)??``),n}function nj(e,t){return t===`FUNCNAME`?(e.state.funcNameStack??[]).map((e,t)=>[t,e]):t===`BASH_LINENO`?(e.state.callLineStack??[]).map((e,t)=>[t,String(e)]):t===`BASH_SOURCE`?(e.state.sourceStack??[]).map((e,t)=>[t,e]):e.state.associativeArrays?.has(t)?fD(e,t).map(n=>[n,aD(e,t,n)??``]):uD(e,t).map(n=>[n,aD(e,t,n)??``])}function rj(e,t){return t===`FUNCNAME`?(e.state.funcNameStack?.length??0)>0:t===`BASH_LINENO`?(e.state.callLineStack?.length??0)>0:t===`BASH_SOURCE`?(e.state.sourceStack?.length??0)>0:(e.state.associativeArrays?.has(t),iD(e,t))}async function ij(e,t,n=!0,r=!1){switch(t){case`?`:return String(e.state.lastExitCode);case`$`:return String(e.state.virtualPid);case`#`:return e.state.env.get(`#`)||`0`;case`@`:return e.state.env.get(`@`)||``;case`_`:return e.state.lastArg;case`-`:{let t=``;return t+=`h`,e.state.options.errexit&&(t+=`e`),e.state.options.noglob&&(t+=`f`),e.state.options.nounset&&(t+=`u`),e.state.options.verbose&&(t+=`v`),e.state.options.xtrace&&(t+=`x`),t+=`B`,e.state.options.noclobber&&(t+=`C`),t+=`s`,t}case`*`:{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t===0)return``;let n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return n.join(IA(e.state.env))}case`0`:return e.state.env.get(`0`)||`bash`;case`PWD`:return e.state.env.get(`PWD`)??``;case`OLDPWD`:return e.state.env.get(`OLDPWD`)??``;case`PPID`:return String(e.state.virtualPpid);case`UID`:return String(e.state.virtualUid);case`EUID`:return String(e.state.virtualUid);case`RANDOM`:return String(Math.floor(Math.random()*32768));case`SECONDS`:return String(Math.floor((Date.now()-e.state.startTime)/1e3));case`BASH_VERSION`:return GE;case`!`:return String(e.state.lastBackgroundPid);case`BASHPID`:return String(e.state.bashPid);case`LINENO`:return String(e.state.currentLine);case`FUNCNAME`:{let t=e.state.funcNameStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new Cr(`FUNCNAME`);return``}case`BASH_LINENO`:{let t=e.state.callLineStack?.[0];if(t!==void 0)return String(t);if(n&&e.state.options.nounset)throw new Cr(`BASH_LINENO`);return``}case`BASH_SOURCE`:{let t=e.state.sourceStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new Cr(`BASH_SOURCE`);return``}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new Er(`\${${t}}`);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let t=i[1],r=i[2];if(GA(e,t)){let n=QA(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return``;t=n}}if(r===`@`||r===`*`){let n=nj(e,t);if(n.length>0)return n.map(([,e])=>e).join(` `);let r=e.state.env.get(t);return r===void 0?``:r}if(t===`FUNCNAME`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.funcNameStack?.[t]??``:``}if(t===`BASH_LINENO`){let t=Number.parseInt(r,10);if(!Number.isNaN(t)&&t>=0){let n=e.state.callLineStack?.[t];return n===void 0?``:String(n)}return``}if(t===`BASH_SOURCE`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.sourceStack?.[t]??``:``}if(e.state.associativeArrays?.has(t)){let i=pD(r);i=tj(e,i);let a=aD(e,t,i);if(a===void 0&&n&&e.state.options.nounset)throw new Cr(`${t}[${r}]`);return a||``}let a;if(/^-?\d+$/.test(r))a=Number.parseInt(r,10);else try{a=await rP(e,sO(new Tk,r).expression)}catch{let t=e.state.env.get(r);a=t?Number.parseInt(t,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let n=nj(e,t),r=e.state.currentLine;if(n.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
919
+ `,``;let i=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+a;return i<0?(e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
920
+ `,``):aD(e,t,i)||``}let o=aD(e,t,a);if(o!==void 0)return o;if(a===0){let n=e.state.env.get(t);if(n!==void 0)return n}if(n&&e.state.options.nounset)throw new Cr(`${t}[${a}]`);return``}if(/^[1-9][0-9]*$/.test(t)){let r=e.state.env.get(t);if(r===void 0&&n&&e.state.options.nounset)throw new Cr(t);return r||``}if(GA(e,t)){let i=QA(e,t);if(i===void 0)return``;if(i!==t)return await ij(e,i,n,r);let a=e.state.env.get(t);if((a===void 0||a===``)&&n&&e.state.options.nounset)throw new Cr(t);return a||``}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(e=>e.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(rj(e,t)){let r=aD(e,t,0);if(r!==void 0)return r;if(n&&e.state.options.nounset)throw new Cr(t);return``}if(n&&e.state.options.nounset)throw new Cr(t);return``}async function aj(e,t){if(new Set([`?`,`$`,`#`,`_`,`-`,`0`,`PPID`,`UID`,`EUID`,`RANDOM`,`SECONDS`,`BASH_VERSION`,`!`,`BASHPID`,`LINENO`]).has(t))return!0;if(t===`@`||t===`*`)return Number.parseInt(e.state.env.get(`#`)||`0`,10)>0;if(t===`PWD`||t===`OLDPWD`)return e.state.env.has(t);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(GA(e,t)){let n=QA(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;t=n}}if(r===`@`||r===`*`)return nj(e,t).length>0||e.state.env.has(t);if(e.state.associativeArrays?.has(t)){let n=tj(e,pD(r));return oD(e,t,n)}let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else try{i=await rP(e,sO(new Tk,r).expression)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0,Number.isNaN(i)&&(i=0)}if(i<0){let n=nj(e,t);if(n.length===0)return!1;let r=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+i;return r<0?!1:oD(e,t,r)}return oD(e,t,i)}if(GA(e,t)){let n=QA(e,t);return n===void 0||n===t?e.state.env.has(t):aj(e,n)}return e.state.env.has(t)?!0:rj(e,t)?oD(e,t,0):!1}async function oj(e,t){let n=``,r=0;for(;r<t.length;){if(t[r]===`$`){if(t[r+1]===`{`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`{`?e++:t[i]===`}`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]===`(`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[0-9]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[0-9]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[*@#?\-!$]/.test(t[r+1]||``)){let i=t[r+1],a=await ij(e,i);n+=a,r+=2;continue}}if(t[r]===`"`){for(n+=`"`,r++;r<t.length&&t[r]!==`"`;)if(t[r]===`$`&&/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await ij(e,t.slice(r+1,i));n+=a,r=i}else t[r]===`\\`?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+=`"`,r++);continue}n+=t[r],r++}return n}async function sj(e,t){let n=t,r=t.startsWith(`"`)&&t.endsWith(`"`),i=t.startsWith(`'`)&&t.endsWith(`'`);if((r||i)&&(n=t.slice(1,-1)),i)return n;let a=``,o=0;for(;o<n.length;)if(n[o]===`$`)if(n[o+1]===`(`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`(`&&n[r-1]===`$`||n[r]===`(`?t++:n[r]===`)`&&t--,r++;let i=n.slice(o+2,r-1);if(e.execFn){let t=await e.execFn(i,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=r}else if(n[o+1]===`{`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`{`?t++:n[r]===`}`&&t--,r++;let i=await ij(e,n.slice(o+2,r-1));a+=i,o=r}else if(/[a-zA-Z_]/.test(n[o+1]||``)){let t=o+1;for(;t<n.length&&/[a-zA-Z0-9_]/.test(n[t]);)t++;let r=await ij(e,n.slice(o+1,t));a+=r,o=t}else a+=n[o],o++;else if(n[o]==="`"){let t=o+1;for(;t<n.length&&n[t]!=="`";)t++;let r=n.slice(o+1,t);if(e.execFn){let t=await e.execFn(r,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=t+1}else a+=n[o],o++;return a}Lr(),j();var cj=1e4,lj={maxResults:cj,maxStringBytes:10485760};function uj(e,t,n,r){if(e.length>=n.maxResults)return!1;let i=O(t);if(i>n.maxStringBytes-r.value)throw new A(`brace expansion string limit exceeded (${n.maxStringBytes} bytes)`,`string_length`);return e.push(t),r.value+=i,!0}function dj(e,t,n,r,i,a=lj){let o=n??1;o===0&&(o=1);let s=Math.abs(o),c=[],l=0;if(r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,``).length)),i?.match(/^-?0\d/)&&(l=Math.max(l,i.replace(/^-/,``).length)),l>a.maxStringBytes)throw new A(`brace expansion padding limit exceeded (${a.maxStringBytes} bytes)`,`string_length`);let u={value:0},d=e=>{if(l>0){let t=e<0,n=String(Math.abs(e)).padStart(l,`0`);return t?`-${n}`:n}return String(e)};if(e<=t)for(let n=e,r=0;n<=t&&r<cj&&uj(c,d(n),a,u);n+=s,r++);else for(let n=e,r=0;n>=t&&r<cj&&uj(c,d(n),a,u);n-=s,r++);return c}function fj(e,t,n,r=lj){let i=n??1;i===0&&(i=1);let a=e.charCodeAt(0),o=t.charCodeAt(0),s=Math.abs(i);if(e>=`A`&&e<=`Z`&&t>=`a`&&t<=`z`||e>=`a`&&e<=`z`&&t>=`A`&&t<=`Z`){let r=n===void 0?``:`..${n}`;throw new Or(`{${e}..${t}${r}}: invalid sequence`)}let c=[],l={value:0};if(a<=o)for(let e=a,t=0;e<=o&&t<cj&&uj(c,String.fromCharCode(e),r,l);e+=s,t++);else for(let e=a,t=0;e>=o&&t<cj&&uj(c,String.fromCharCode(e),r,l);e-=s,t++);return c}function pj(e,t,n,r,i,a=lj){let o=n===void 0?``:`..${n}`;return typeof e==`number`&&typeof t==`number`?{expanded:dj(e,t,n,r,i,a),literal:`{${e}..${t}${o}}`}:typeof e==`string`&&typeof t==`string`?{expanded:fj(e,t,n,a),literal:`{${e}..${t}${o}}`}:{expanded:null,literal:`{${e}..${t}${o}}`}}function mj(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!==`SimpleCommand`)return null;let i=r;if(i.name!==null||i.args.length!==0||i.assignments.length!==0||i.redirections.length!==1)return null;let a=i.redirections[0];return a.operator!==`<`||a.target.type!==`Word`?null:{target:a.target}}function hj(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function gj(e){let t=``,n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function _j(e){return e.replace(/([*?[\]\\()|])/g,`\\$1`)}function vj(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`)}mc(),j();function yj(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function bj(e,t,n=!1){let r=``,i=0;for(;i<e.length;){let a=e[i];if(n&&(a===`@`||a===`*`||a===`+`||a===`?`||a===`!`)&&i+1<e.length&&e[i+1]===`(`){let o=xj(e,i+1);if(o!==-1){let s=Sj(e.slice(i+2,o)).map(e=>bj(e,t,n)),c=s.length>0?s.join(`|`):`(?:)`;a===`@`?r+=`(?:${c})`:a===`*`?r+=`(?:${c})*`:a===`+`?r+=`(?:${c})+`:a===`?`?r+=`(?:${c})?`:a===`!`&&(r+=`(?!(?:${c})$).*`),i=o+1;continue}}if(a===`\\`)if(i+1<e.length){let t=e[i+1];/[\\^$.|+(){}[\]*?]/.test(t)?r+=`\\${t}`:r+=t,i+=2}else r+=`\\\\`,i++;else if(a===`*`)r+=t?`.*`:`.*?`,i++;else if(a===`?`)r+=`.`,i++;else if(a===`[`){let t=Cj(e,i);if(t===-1)r+=`\\[`,i++;else{let n=e.slice(i+1,t);r+=wj(n),i=t+1}}else/[\^$.|+(){}]/.test(a)?(r+=`\\${a}`,i++):(r+=a,i++)}return r}function xj(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Sj(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function Cj(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){if(e[n]===`\\`&&n+1<e.length){n+=2;continue}if(e[n]===`]`)return n;if(e[n]===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}n++}return-1}function wj(e){let t=`[`,n=0;for((e[0]===`^`||e[0]===`!`)&&(t+=`^`,n++);n<e.length;){if(e[n]===`'`){let r=e.indexOf(`'`,n+1);if(r!==-1){let i=e.slice(n+1,r);for(let e of i)t+=e===`\\`?`\\\\`:e===`]`?`\\]`:e===`^`&&t===`[`?`\\^`:e;n=r+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r);t+=Ej(i),n=r+2;continue}}let r=e[n];r===`\\`?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+=`\\\\`,n++):r===`-`&&n>0&&n<e.length-1?(t+=`-`,n++):r===`^`&&n===0?(t+=`^`,n++):(t+=r===`]`&&n===0?`\\]`:r,n++)}return t+=`]`,t}var Tj=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9A-Fa-f`]]);function Ej(e){return Tj.get(e)??``}mc();function Dj(e,t,n,r,i){if(r===`prefix`)return e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`),U(`^${n}`,`s`).replace(t,``);let a=U(`${n}$`,`s`);if(i)return e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`),a.replace(t,``);e.executionScope.consumeLimited(`pattern-removal`,Math.max(1,t.length),e.limits.maxGlobOperations,`pattern removal`);let o=U(`^(?:.*)(${n})$`,`s`).exec(t);if(!o)return t;let s=o[1]??``;return t.slice(0,t.length-s.length)}function Oj(e,t){let n=new Set;for(let r of e.state.env.keys())r.startsWith(t)&&n.add(r);for(let r of e.state.arrays?.keys()??[])r.startsWith(t)&&n.add(r);return[...n].sort()}Wi(),j();function kj(e,t,n,r,i){let a=new Ui(e.limits.maxStringLength,`pattern replacement`,()=>new A(`pattern replacement: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`));n.lastIndex=0;let o=0,s=n.exec(t);for(;s!==null&&(e.executionScope.consumeLimited(`pattern_operations`,1,e.limits.maxGlobOperations,`pattern replacement`),!(i&&s[0].length===0&&s.index===t.length||(a.append(t.slice(o,s.index)),a.append(r),o=s.index+s[0].length,!i)));)s[0].length===0&&(o++,n.lastIndex<=s.index&&(n.lastIndex=s.index+1)),s=n.exec(t);return a.append(t.slice(o)),n.lastIndex=0,a.build()}Lr(),j();function Aj(e){let t=[],n=0;return{append(r){let i=O(r);if(i>e-n)throw new A(`prompt expansion exceeds string length limit (${e} bytes)`,`string_length`);r&&t.push(r),n+=i},build:()=>t.join(``)}}function jj(e,t,n){let r=(e,t=2)=>String(e).padStart(t,`0`);if(e===``)return`${r(t.getHours())}:${r(t.getMinutes())}:${r(t.getSeconds())}`;let i=Aj(n),a=0;for(;a<e.length;)if(e[a]===`%`){if(a+1>=e.length){i.append(`%`),a++;continue}let n=e[a+1];switch(n){case`H`:i.append(r(t.getHours()));break;case`M`:i.append(r(t.getMinutes()));break;case`S`:i.append(r(t.getSeconds()));break;case`d`:i.append(r(t.getDate()));break;case`m`:i.append(r(t.getMonth()+1));break;case`Y`:i.append(String(t.getFullYear()));break;case`y`:i.append(r(t.getFullYear()%100));break;case`I`:{let e=t.getHours()%12;e===0&&(e=12),i.append(r(e));break}case`p`:i.append(t.getHours()<12?`AM`:`PM`);break;case`P`:i.append(t.getHours()<12?`am`:`pm`);break;case`%`:i.append(`%`);break;case`a`:i.append([`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.getDay()]);break;case`b`:i.append([`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()]);break;default:i.append(`%${n}`)}a+=2}else i.append(e[a]),a++;return i.build()}function Mj(e,t){let n=Aj(e.limits.maxStringLength),r=0,i=e.state.env.get(`USER`)||e.state.env.get(`LOGNAME`)||`user`,a=e.state.env.get(`HOSTNAME`)||`localhost`,o=a.split(`.`)[0],s=e.state.env.get(`PWD`)||`/`,c=e.state.env.get(`HOME`)||`/`,l=s.startsWith(c)?`~${s.slice(c.length)}`:s,u=s.split(`/`).pop()||s,d=new Date,f=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],p=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],m=e.state.env.get(`__COMMAND_NUMBER`)||`1`;for(;r<t.length;){let s=t[r];if(s===`\\`){if(r+1>=t.length){n.append(`\\`),r++;continue}let s=t[r+1];if(s>=`0`&&s<=`7`){let e=``,i=r+1;for(;i<t.length&&i<r+4&&t[i]>=`0`&&t[i]<=`7`;)e+=t[i],i++;let a=Number.parseInt(e,8)%256;n.append(String.fromCharCode(a)),r=i;continue}switch(s){case`\\`:n.append(`\\`),r+=2;break;case`a`:n.append(`\x07`),r+=2;break;case`e`:n.append(`\x1B`),r+=2;break;case`n`:n.append(`
921
+ `),r+=2;break;case`r`:n.append(`\r`),r+=2;break;case`$`:n.append(`$`),r+=2;break;case`[`:case`]`:r+=2;break;case`u`:n.append(i),r+=2;break;case`h`:n.append(o),r+=2;break;case`H`:n.append(a),r+=2;break;case`w`:n.append(l),r+=2;break;case`W`:n.append(u),r+=2;break;case`d`:{let e=String(d.getDate()).padStart(2,` `);n.append(`${f[d.getDay()]} ${p[d.getMonth()]} ${e}`),r+=2;break}case`t`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`),i=String(d.getSeconds()).padStart(2,`0`);n.append(`${e}:${t}:${i}`),r+=2;break}case`T`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=String(d.getSeconds()).padStart(2,`0`);n.append(`${t}:${i}:${a}`),r+=2;break}case`@`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=d.getHours()<12?`AM`:`PM`;n.append(`${t}:${i} ${a}`),r+=2;break}case`A`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`);n.append(`${e}:${t}`),r+=2;break}case`D`:if(r+2<t.length&&t[r+2]===`{`){let i=t.indexOf(`}`,r+3);if(i!==-1){let a=t.slice(r+3,i);n.append(jj(a,d,e.limits.maxStringLength)),r=i+1}else n.append(`\\D`),r+=2}else n.append(`\\D`),r+=2;break;case`s`:n.append(`bash`),r+=2;break;case`v`:n.append(`5.0`),r+=2;break;case`V`:n.append(`5.0.0`),r+=2;break;case`j`:n.append(`0`),r+=2;break;case`l`:n.append(`tty`),r+=2;break;case`#`:n.append(m),r+=2;break;case`!`:n.append(m),r+=2;break;case`x`:n.append(`\\x`),r+=2;break;default:n.append(`\\${s}`),r+=2}}else n.append(s),r++}return n.build()}function Nj(e){if(e===``)return`''`;if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let t=`$'`;for(let n of e)switch(n){case`'`:t+=`\\'`;break;case`\\`:t+=`\\\\`;break;case`
922
+ `:t+=`\\n`;break;case`\r`:t+=`\\r`;break;case` `:t+=`\\t`;break;default:{let e=n.charCodeAt(0);t+=e<32||e===127?`\\${e.toString(8).padStart(3,`0`)}`:n}}return`${t}'`}return`'${e}'`}j();function Pj(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function Fj(e,t){return e.state.readonlyVars?.has(t)??!1}function Ij(e,t,n=`bash`){if(Fj(e,t)){let e=`${n}: ${t}: readonly variable
923
+ `;throw new wr(1,``,e)}return null}function Lj(e,t){let n=e.state.exportedVars?.has(t)??!1;if(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t),e.state.localScopes.length>0&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!n){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length<e.state.localScopes.length;)e.state.localExportedVars.push(new Set);e.state.localExportedVars[e.state.localExportedVars.length-1].add(t)}}function Rj(e,t){e.state.exportedVars?.delete(t)}function zj(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return``;let n=``,r=tD(e,t)?.kind===`indexed`,i=e.state.associativeArrays?.has(t)??!1;return r&&!i&&(n+=`a`),i&&(n+=`A`),e.state.integerVars?.has(t)&&(n+=`i`),GA(e,t)&&(n+=`n`),Fj(e,t)&&(n+=`r`),e.state.exportedVars?.has(t)&&(n+=`x`),n}async function Bj(e,t,n,r){return e.coverage?.hit(`bash:expansion:default_value`),(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function Vj(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:assign_default`),(r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let a=await i(e,n.word.parts,r.inDoubleQuotes),o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let[,t,n]=o,r;if(/^\d+$/.test(n))r=Number.parseInt(n,10);else{try{r=await rP(e,sO(new Tk,n).expression)}catch{let t=e.state.env.get(n);r=t?Number.parseInt(t,10):0}Number.isNaN(r)&&(r=0)}Y(e,t,r,a)}else e.state.env.set(t,a);return a}return r.effectiveValue}async function Hj(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:error_if_unset`),r.isUnset||n.checkEmpty&&r.isEmpty){let a=n.word?await i(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new wr(1,``,`bash: ${a}
924
+ `)}return r.effectiveValue}async function Uj(e,t,n,r){return e.coverage?.hit(`bash:expansion:use_alternative`),!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):``}async function Wj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_removal`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=bj(t.pattern,n.greedy,o);else if(t.type===`Literal`)a+=bj(t.value,n.greedy,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await i(e,t);a+=bj(r,n.greedy,o)}else{let n=await i(e,t);a+=yj(n)}return Dj(e,t,a,n.side,n.greedy)}async function Gj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_replacement`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=bj(t.pattern,!0,o);else if(t.type===`Literal`)a+=bj(t.value,!0,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=yj(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);a+=bj(n,!0,o)}else{let n=await i(e,t);a+=yj(n)}let s=n.replacement?await r(e,n.replacement.parts):``;if(n.anchor===`start`?a=`^${a}`:n.anchor===`end`&&(a=`${a}$`),a===``)return t;let c=n.all?`gs`:`s`;try{return kj(e,t,U(a,c),s,n.all)}catch(e){if(e instanceof A)throw e;return t}}function Kj(e,t,n){e.coverage?.hit(`bash:expansion:length`);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=nj(e,t);return n.length>0?String(n.length):e.state.env.get(t)===void 0?`0`:`1`}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&rj(e,t)){if(t===`FUNCNAME`){let t=e.state.funcNameStack?.[0]||``;return String([...t].length)}if(t===`BASH_LINENO`){let t=e.state.callLineStack?.[0];return String(t===void 0?0:[...String(t)].length)}let n=aD(e,t,0)||``;return String([...n].length)}return String([...n].length)}async function qj(e,t,n,r){e.coverage?.hit(`bash:expansion:substring`);let i=await rP(e,r.offset.expression),a=r.length?await rP(e,r.length.expression):void 0;if(t===`@`||t===`*`){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);let r=e.state.env.get(`0`)||`bash`,o,s;if(i<=0)if(o=[r,...n],i<0){if(s=o.length+i,s<0)return``}else s=0;else o=n,s=i-1;if(s<0||s>=o.length)return``;if(a!==void 0){let e=a<0?o.length+a:s+a;return o.slice(s,Math.max(s,e)).join(` `)}return o.slice(s).join(` `)}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let t=o[1];if(e.state.associativeArrays?.has(t))throw new wr(1,``,`bash: \${${t}[@]: 0: 3}: bad substitution
925
+ `);let n=nj(e,t),r=0;if(i<0){if(n.length>0){let e=n[n.length-1][0],t=(typeof e==`number`?e:0)+1+i;if(t<0||(r=n.findIndex(([e])=>typeof e==`number`&&e>=t),r<0))return``}}else if(r=n.findIndex(([e])=>typeof e==`number`&&e>=i),r<0)return``;if(a!==void 0){if(a<0)throw new Tr(`${o[1]}[@]: substring expression < 0`);return n.slice(r,r+a).map(([,e])=>e).join(` `)}return n.slice(r).map(([,e])=>e).join(` `)}let s=[...n],c=i;if(c<0&&(c=Math.max(0,s.length+c)),a!==void 0){if(a<0){let e=s.length+a;return s.slice(c,Math.max(c,e)).join(``)}return s.slice(c,c+a).join(``)}return s.slice(c).join(``)}async function Jj(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:case_modification`),n.pattern){let a=e.state.shoptOptions.extglob,o=``;for(let t of n.pattern.parts)if(t.type===`Glob`)o+=bj(t.pattern,!0,a);else if(t.type===`Literal`)o+=bj(t.value,!0,a);else if(t.type===`SingleQuoted`||t.type===`Escaped`)o+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);o+=yj(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);o+=bj(n,!0,a)}let s=U(`^(?:${o})$`),c=n.direction===`upper`?e=>e.toUpperCase():e=>e.toLowerCase(),l=``,u=!1;for(let e of t)!n.all&&u?l+=e:s.test(e)?(l+=c(e),u=!0):l+=e;return l}return n.direction===`upper`?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function Yj(e,t,n,r,i){e.coverage?.hit(`bash:expansion:transform`);let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(a&&i.operator===`Q`)return nj(e,a[1]).map(([,e])=>Nj(e)).join(` `);if(a&&i.operator===`a`)return zj(e,a[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&i.operator===`a`)return zj(e,o[1]);switch(i.operator){case`Q`:return r?``:Nj(n);case`P`:return Mj(e,n);case`a`:return zj(e,t);case`A`:return r?``:`${t}=${Nj(n)}`;case`E`:return n.replace(/\\([\\abefnrtv'"?])/g,(e,t)=>{switch(t){case`\\`:return`\\`;case`a`:return`\x07`;case`b`:return`\b`;case`e`:return`\x1B`;case`f`:return`\f`;case`n`:return`
926
+ `;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`'`:return`'`;case`"`:return`"`;case`?`:return`?`;default:return t}});case`K`:case`k`:return r?``:Nj(n);case`u`:return n.charAt(0).toUpperCase()+n.slice(1);case`U`:return n.toUpperCase();case`L`:return n.toLowerCase();default:return n}}async function Xj(e,t,n,r,i,a,o=!1){if(e.coverage?.hit(`bash:expansion:indirection`),GA(e,t))return $A(e,t)||``;let s=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(i.innerOp?.type===`UseAlternative`)return``;throw new Er(`\${!${t}}`)}let c=n;if(s&&(c===``||c.includes(` `)))throw new Er(`\${!${t}}`);let l=c.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(l&&l[1].includes(`~`))throw new Er(`\${!${t}}`);return i.innerOp?a(e,{type:`ParameterExpansion`,parameter:c,operation:i.innerOp},o):await ij(e,c)}function Zj(e,t){e.coverage?.hit(`bash:expansion:array_keys`);let n=nj(e,t.array).map(([e])=>String(e));return t.star?n.join(IA(e.state.env)):n.join(` `)}function Qj(e,t){e.coverage?.hit(`bash:expansion:var_name_prefix`);let n=Oj(e,t.prefix);return t.star?n.join(IA(e.state.env)):n.join(` `)}function $j(e,t,n,r){let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t===`*`)return{isEmpty:i===0,effectiveValue:n};if(t===`@`)return{isEmpty:i===0||i===1&&e.state.env.get(`1`)===``,effectiveValue:n};if(a){let[,t,n]=a,i=nj(e,t);if(i.length===0)return{isEmpty:!0,effectiveValue:``};if(n===`*`){let t=IA(e.state.env),n=i.map(([,e])=>e).join(t);return{isEmpty:r?n===``:!1,effectiveValue:n}}return{isEmpty:i.length===1&&i.every(([,e])=>e===``),effectiveValue:i.map(([,e])=>e).join(` `)}}return{isEmpty:n===``,effectiveValue:n}}j();function eM(e){let t=0;for(;t<e.length;){let n=e[t];if(n===`\\`&&t+1<e.length){t+=2;continue}if(n===`'`){let n=e.indexOf(`'`,t+1);if(n!==-1){t=n+1;continue}}if(n===`$`&&t+1<e.length&&e[t+1]===`(`||n==="`")return!0;t++}return!1}function tM(e,t){let n=1,r=t,i=!1,a=!1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`&&!i&&r+1<e.length){r+=2;continue}if(t===`'`&&!a){i=!i,r++;continue}if(t===`"`&&!i){a=!a,r++;continue}if(!i&&!a){if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}r++}return-1}async function nM(e,t){let n=new Tk,r;try{r=n.parse(t)}catch{return``}let i=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let a=new Map(e.state.env),o=eD(e.state.arrays),s=e.state.cwd,c=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let t=await e.executeScript(r),n=t.exitCode;return e.state.env=a,e.state.arrays=o,e.state.cwd=s,e.state.suppressVerbose=c,e.state.lastExitCode=n,e.state.env.set(`?`,String(n)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr),e.state.bashPid=i,t.stdout.replace(/\n+$/,``)}catch(t){if(e.state.env=a,e.state.arrays=o,e.state.cwd=s,e.state.bashPid=i,e.state.suppressVerbose=c,t instanceof A)throw t;return t instanceof wr?(e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stdout?.replace(/\n+$/,``)??``):``}}function rM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=_j(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=iM(e,t.slice(r+1,i));n+=_j(a),r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}function iM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}async function aM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=_j(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=await oM(e,t.slice(r+1,i));n+=_j(a),r=i+1;continue}}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=tM(t,r+2);if(i!==-1){let a=await nM(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await nM(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}async function oM(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=tM(t,r+2);if(i!==-1){let a=await nM(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await nM(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}function sM(e,t){if(!t.startsWith(`~`))return t;e.coverage?.hit(`bash:expansion:tilde`);let n=e.state.env.get(`HOME`)===void 0?`/home/user`:e.state.env.get(`HOME`);if(t===`~`||t.startsWith(`~/`))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let i=t.slice(1,r),a=t.slice(r);return a!==``&&!a.startsWith(`/`)?t:i===`root`?`/root${a}`:t}function cM(e,t){return t.split(`:`).map(t=>sM(e,t)).join(`:`)}j(),j();function lM(e,t,n,r){if(e.length>n-t.length)throw new A(`${r} element limit exceeded (${n})`,`array_elements`);for(let n of t)e.push(n)}mc();async function uM(e,t,n,r){let i=``;for(let a of t.parts)if(a.type===`Glob`)i+=bj(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)i+=bj(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)i+=yj(a.value);else if(a.type===`DoubleQuoted`){let t=await n(e,a.parts);i+=yj(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);i+=bj(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);i+=yj(t)}return i}async function dM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternReplacement`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=nj(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``;l.pattern&&(f=await uM(e,l.pattern,n,r));let p=l.replacement?await n(e,l.replacement.parts):``,m=f;l.anchor===`start`?m=`^${f}`:l.anchor===`end`&&(m=`${f}$`);let h=[];try{let e=U(m,l.all?`g`:``);for(let t of d)h.push(e.replace(t,p))}catch{h.push(...d)}if(c){let t=IA(e.state.env);return{values:[h.join(t)],quoted:!0}}return{values:h,quoted:!0}}async function fM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternRemoval`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=nj(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``,p=e.state.shoptOptions.extglob;if(l.pattern)for(let t of l.pattern.parts)if(t.type===`Glob`)f+=bj(t.pattern,l.greedy,p);else if(t.type===`Literal`)f+=bj(t.value,l.greedy,p);else if(t.type===`SingleQuoted`||t.type===`Escaped`)f+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);f+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);f+=bj(n,l.greedy,p)}else{let n=await r(e,t);f+=yj(n)}let m=[];for(let t of d)m.push(Dj(e,t,f,l.side,l.greedy));if(c){let t=IA(e.state.env);return{values:[m.join(t)],quoted:!0}}return{values:m,quoted:!0}}mc();async function pM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`DefaultValue`&&n.parts[0].operation?.type!==`UseAlternative`&&n.parts[0].operation?.type!==`AssignDefault`)return null;let r=n.parts[0],i=r.operation,a=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,s=!1;if(a){let t=a[1];s=a[2]===`*`;let n=nj(e,t),r=n.length>0||e.state.env.has(t),c=n.length===0||n.length===1&&n.every(([,e])=>e===``),l=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?r&&!(l&&c):!r||l&&c,!o){if(n.length>0){let t=n.map(([,e])=>e);if(s){let n=IA(e.state.env);return{values:[t.join(n)],quoted:!0}}return{values:t,quoted:!0}}let r=e.state.env.get(t);return r===void 0?{values:[],quoted:!0}:{values:[r],quoted:!0}}}else{let t=r.parameter,n=await aj(e,t),a=await ij(e,t),s=a===``,c=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?n&&!(c&&s):!n||c&&s,!o)return{values:[a],quoted:!0}}if(o&&i.word){let t=i.word.parts,n=null,r=!1;for(let e of t)if(e.type===`ParameterExpansion`&&!e.operation){let t=e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){n=t[1],r=t[2]===`*`;break}}if(n){let t=nj(e,n);if(t.length>0){let n=t.map(([,e])=>e);if(r||s){let t=IA(e.state.env);return{values:[n.join(t)],quoted:!0}}return{values:n,quoted:!0}}let i=e.state.env.get(n);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}}return null}async function mM(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0],o=-1,s=``,c=!1,l=null;for(let e=0;e<a.parts.length;e++){let t=a.parts[e];if(t.type===`ParameterExpansion`&&(t.operation?.type===`PatternRemoval`||t.operation?.type===`PatternReplacement`)){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){o=e,s=n[1],c=n[2]===`*`,l=t.operation;break}}}if(o===-1||o===0&&o===a.parts.length-1)return null;let u=``;for(let t=0;t<o;t++)u+=await r(e,a.parts[t]);let d=``;for(let t=o+1;t<a.parts.length;t++)d+=await r(e,a.parts[t]);let f=nj(e,s),p=f.map(([,e])=>e);if(f.length===0){let t=e.state.env.get(s);if(t!==void 0)p=[t];else{if(c)return{values:[u+d],quoted:!0};let e=u+d;return{values:e?[e]:[],quoted:!0}}}if(l?.type===`PatternRemoval`){let t=l,n=``,a=e.state.shoptOptions.extglob;if(t.pattern)for(let o of t.pattern.parts)if(o.type===`Glob`)n+=bj(o.pattern,t.greedy,a);else if(o.type===`Literal`)n+=bj(o.value,t.greedy,a);else if(o.type===`SingleQuoted`||o.type===`Escaped`)n+=yj(o.value);else if(o.type===`DoubleQuoted`){let t=await i(e,o.parts);n+=yj(t)}else if(o.type===`ParameterExpansion`){let i=await r(e,o);n+=bj(i,t.greedy,a)}else{let t=await r(e,o);n+=yj(t)}p=p.map(r=>Dj(e,r,n,t.side,t.greedy))}else if(l?.type===`PatternReplacement`){let t=l,n=``;if(t.pattern)for(let a of t.pattern.parts)if(a.type===`Glob`)n+=bj(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)n+=bj(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)n+=yj(a.value);else if(a.type===`DoubleQuoted`){let t=await i(e,a.parts);n+=yj(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);n+=bj(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);n+=yj(t)}let a=t.replacement?await i(e,t.replacement.parts):``,o=n;t.anchor===`start`?o=`^${n}`:t.anchor===`end`&&(o=`${n}$`);try{let e=U(o,t.all?`g`:``);p=p.map(t=>e.replace(t,a))}catch{}}if(c){let t=IA(e.state.env);return{values:[u+p.join(t)+d],quoted:!0}}return p.length===1?{values:[u+p[0]+d],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+d],quoted:!0}}async function hM(e,t,n,r){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=``,s=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&!t.operation){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){a=e,o=n[1],s=n[2]===`*`;break}}}if(a===-1)return null;let c=``;for(let t=0;t<a;t++)c+=await r(e,i.parts[t]);let l=``;for(let t=a+1;t<i.parts.length;t++)l+=await r(e,i.parts[t]);let u=nj(e,o),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(o);if(t!==void 0)return{values:[c+t+l],quoted:!0};if(s)return{values:[c+l],quoted:!0};let n=c+l;return{values:n?[n]:[],quoted:!0}}if(s){let t=IA(e.state.env);return{values:[c+d.join(t)+l],quoted:!0}}return d.length===1?{values:[c+d[0]+l],quoted:!0}:{values:[c+d[0],...d.slice(1,-1),d[d.length-1]+l],quoted:!0}}Lr(),j();async function gM(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==`ParameterExpansion`||r.parts[0].operation?.type!==`Substring`)return null;let i=r.parts[0],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],s=a[2]===`*`,c=i.operation;if(e.state.associativeArrays?.has(o))throw new wr(1,``,`bash: \${${o}[@]: 0: 3}: bad substitution
927
+ `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=nj(e,o);if(d.length>e.limits.maxArrayElements)throw new A(`array transform element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let f=0;if(l<0){if(d.length>0){let e=d[d.length-1][0],t=(typeof e==`number`?e:0)+1+l;if(t<0)return{values:[],quoted:!0};f=d.findIndex(([e])=>typeof e==`number`&&e>=t),f<0&&(f=d.length)}}else f=d.findIndex(([e])=>typeof e==`number`&&e>=l),f<0&&(f=d.length);let p;if(u!==void 0){if(u<0)throw new Tr(`${o}[@]: substring expression < 0`);p=d.slice(f,f+u).map(([,e])=>e)}else p=d.slice(f).map(([,e])=>e);if(p.length===0)return{values:[],quoted:!0};if(s){let t=IA(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,quoted:!0}}function _M(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`Transform`)return null;let r=n.parts[0],i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let a=i[1],o=i[2]===`*`,s=r.operation,c=nj(e,a);if(c.length===0){let t=e.state.env.get(a);if(t!==void 0){let n;switch(s.operator){case`a`:n=``;break;case`P`:n=Mj(e,t);break;case`Q`:n=Nj(t);break;default:n=t}if(O(n)>e.limits.maxStringLength)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[n],quoted:!0}}return o?{values:[``],quoted:!0}:{values:[],quoted:!0}}let l=zj(e,a),u=[],d=0;for(let[,t]of c){let n;switch(s.operator){case`a`:n=l;break;case`P`:n=Mj(e,t);break;case`Q`:n=Nj(t);break;case`u`:n=t.charAt(0).toUpperCase()+t.slice(1);break;case`U`:n=t.toUpperCase();break;case`L`:n=t.toLowerCase();break;default:n=t}let r=O(n);if(r>e.limits.maxStringLength-d)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);u.push(n),d+=r}if(o){let t=IA(e.state.env);if(Math.max(0,u.length-1)*O(t)>e.limits.maxStringLength-d)throw new A(`array transform string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[u.join(t)],quoted:!0}}return{values:u,quoted:!0}}function vM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`)return null;let r=n.parts[0];if(r.operation)return null;let i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!i)return null;let a=i[1];if(GA(e,a)){let t=$A(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=nj(e,a);if(o.length>0)return{values:o.map(([,e])=>e),quoted:!0};let s=e.state.env.get(a);return s===void 0?{values:[],quoted:!0}:{values:[s],quoted:!0}}function yM(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation)return null;let r=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)||!GA(e,r))return null;let i=$A(e,r);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],s=nj(e,o);if(s.length>0)return{values:s.map(([,e])=>e),quoted:!0};let c=e.state.env.get(o);return c===void 0?{values:[],quoted:!0}:{values:[c],quoted:!0}}j();async function bM(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=o.operation,c=await ij(e,o.parameter),l=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l){if(!s.innerOp&&(c===`@`||c===`*`)){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return c===`*`?{values:[n.join(IA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=nj(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return xM(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return SM(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=zj(e,u),n=f.map(()=>t);return d?{values:[n.join(IA(e.state.env))],quoted:!0}:{values:n,quoted:!0}}let t=[];for(let[,n]of f){let i={type:`ParameterExpansion`,parameter:`_indirect_elem_`,operation:s.innerOp},a=e.state.env.get(`_indirect_elem_`);e.state.env.set(`_indirect_elem_`,n);try{let n=await r(e,i,!0);t.push(n)}finally{a===void 0?e.state.env.delete(`_indirect_elem_`):e.state.env.set(`_indirect_elem_`,a)}}return d?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let p=e.state.env.get(u);return p===void 0?{values:[],quoted:!0}:{values:[p],quoted:!0}}async function xM(e,t,n,r,i){let a=i.offset?await rP(e,i.offset.expression):0,o=i.length?await rP(e,i.length.expression):void 0,s=0;if(a<0){if(t.length>0){let e=t[t.length-1][0],n=(typeof e==`number`?e:0)+1+a;if(n<0||(s=t.findIndex(([e])=>typeof e==`number`&&e>=n),s<0))return{values:[],quoted:!0}}}else if(s=t.findIndex(([e])=>typeof e==`number`&&e>=a),s<0)return{values:[],quoted:!0};let c;if(o!==void 0){if(o<0)throw new Tr(`${n}[@]: substring expression < 0`);c=t.slice(s,s+o)}else c=t.slice(s);let l=c.map(([,e])=>e);return r?{values:[l.join(IA(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function SM(e,t,n,r,i,a){let o=i.checkEmpty??!1,s=t.map(([,e])=>e),c=t.length===0,l=t.length===0;if(i.type===`UseAlternative`)return!l&&!(o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(i.type===`DefaultValue`)return(l||o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0};if(i.type===`AssignDefault`){if((l||o&&c)&&i.word){let t=await a(e,i.word.parts,!0);return Y(e,n,0,t),{values:[t],quoted:!0}}return r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(IA(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function CM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`UseAlternative`&&t[0].operation?.type!==`DefaultValue`)return null;let n=t[0],r=n.operation,i=r?.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await ij(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await aj(e,n.parameter),l=await ij(e,n.parameter)===``,u=r.checkEmpty??!1,d;if(d=r.type===`UseAlternative`?c&&!(u&&l):!c||u&&l,d){let t=s[1],n=s[2]===`*`,r=nj(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}async function wM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`Indirection`)return null;let n=t[0],r=n.operation.innerOp;if(!r||r.type!==`UseAlternative`&&r.type!==`DefaultValue`)return null;let i=r.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await ij(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await ij(e,n.parameter),l=await aj(e,n.parameter),u=c===``,d=r.checkEmpty??!1,f;if(f=r.type===`UseAlternative`?l&&!(d&&u):!l||d&&u,f){let t=s[1],n=s[2]===`*`,r=nj(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(IA(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}Lr(),mc(),j();function TM(e){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t>e.limits.maxArrayElements)throw new A(`positional parameter element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=[],r=0;for(let i=1;i<=t;i++){let t=e.state.env.get(String(i))||``,a=O(t);if(a>e.limits.maxStringLength-r)throw new A(`positional parameter string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n.push(t),r+=a}return n}function EM(e,t,n){if(O(t)>n-O(e))throw new A(`positional expansion string limit exceeded (${n} bytes)`,`string_length`);return e+t}function DM(e,t,n,r){if(e.length>=r.limits.maxArrayElements)throw new A(`positional expansion element limit exceeded (${r.limits.maxArrayElements})`,`array_elements`);let i=O(t);if(i>r.limits.maxStringLength-n.value)throw new A(`positional expansion string limit exceeded (${r.limits.maxStringLength} bytes)`,`string_length`);e.push(t),n.value+=i}async function OM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`Substring`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=s.offset?await n(e,s.offset.expression):0,l=s.length?await n(e,s.length.expression):void 0,u=Number.parseInt(e.state.env.get(`#`)||`0`,10),d=[];for(let t=1;t<=u;t++)d.push(e.state.env.get(String(t))||``);let f=e.state.env.get(`0`)||`bash`,p;if(c<=0){let e=[f,...d],t=e.length+c;if(t<0)p=[];else{let n=c<0?t:0;if(l!==void 0){let t=l<0?e.length+l:n+l;p=e.slice(n,Math.max(n,t))}else p=e.slice(n)}}else{let e=c-1;if(e>=d.length)p=[];else if(l!==void 0){let t=l<0?d.length+l:e+l;p=d.slice(e,Math.max(e,t))}else p=d.slice(e)}let m=``;for(let t=0;t<a;t++)m+=await r(e,i.parts[t]);let h=``;for(let t=a+1;t<i.parts.length;t++)h+=await r(e,i.parts[t]);if(p.length===0){let e=m+h;return{values:e?[e]:[],quoted:!0}}if(o){let t=IA(e.state.env);return{values:[m+p.join(t)+h],quoted:!0}}return p.length===1?{values:[m+p[0]+h],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+h],quoted:!0}}async function kM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternReplacement`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=TM(e),l=``;for(let t=0;t<a;t++)l=EM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=EM(u,await n(e,i.parts[t]),e.limits.maxStringLength);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=bj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)d+=bj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=bj(r,!0,e.state.shoptOptions.extglob)}else{let r=await n(e,t);d+=yj(r)}let f=s.replacement?await r(e,s.replacement.parts):``,p=d;s.anchor===`start`?p=`^${d}`:s.anchor===`end`&&(p=`${d}$`);let m=[],h={value:0};try{let t=U(p,s.all?`g`:``);for(let n of c){let r=0;t.lastIndex=0;for(let e=t.exec(n);e&&(r++,s.all);e=t.exec(n))e[0].length===0&&t.lastIndex++;let i=O(n),a=O(f),o=0,c=/\$(?:\$|&|\d+|<[^>]+>|`|')/g;for(;c.exec(f)!==null;)o++;if(i+r*a+r*o*i>e.limits.maxStringLength-h.value)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);DM(m,t.replace(n,f),h,e)}}catch(t){if(t instanceof A)throw t;for(let t of c)DM(m,t,h,e)}if(o){let t=IA(e.state.env);if(h.value+Math.max(0,m.length-1)*O(t)+O(l)+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+m.join(t)+u],quoted:!0}}if(O(l)+h.value+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return m.length===1?{values:[l+m[0]+u],quoted:!0}:{values:[l+m[0],...m.slice(1,-1),m[m.length-1]+u],quoted:!0}}async function AM(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternRemoval`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=TM(e),l=``;for(let t=0;t<a;t++)l=EM(l,await n(e,i.parts[t]),e.limits.maxStringLength);let u=``;for(let t=a+1;t<i.parts.length;t++)u=EM(u,await n(e,i.parts[t]),e.limits.maxStringLength);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``,f=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=bj(t.pattern,s.greedy,f);else if(t.type===`Literal`)d+=bj(t.value,s.greedy,f);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=yj(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=yj(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=bj(r,s.greedy,f)}else{let r=await n(e,t);d+=yj(r)}let p=[],m={value:0};for(let t of c)DM(p,Dj(e,t,d,s.side,s.greedy),m,e);if(o){let t=IA(e.state.env);if(m.value+Math.max(0,p.length-1)*O(t)+O(l)+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return{values:[l+p.join(t)+u],quoted:!0}}if(O(l)+m.value+O(u)>e.limits.maxStringLength)throw new A(`positional expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return p.length===1?{values:[l+p[0]+u],quoted:!0}:{values:[l+p[0],...p.slice(1,-1),p[p.length-1]+u],quoted:!0}}async function jM(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0],i=-1,a=!1;for(let e=0;e<r.parts.length;e++){let t=r.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)){i=e,a=t.parameter===`*`;break}}if(i===-1)return null;let o=r.parts[i];if(o.type===`ParameterExpansion`&&o.operation)return null;let s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=``;for(let t=0;t<i;t++)c+=await n(e,r.parts[t]);let l=``;for(let t=i+1;t<r.parts.length;t++)l+=await n(e,r.parts[t]);if(s===0){if(a)return{values:[c+l],quoted:!0};let e=c+l;return{values:e?[e]:[],quoted:!0}}let u=[];for(let t=1;t<=s;t++)u.push(e.state.env.get(String(t))||``);if(a){let t=IA(e.state.env);return{values:[c+u.join(t)+l],quoted:!0}}return u.length===1?{values:[c+u[0]+l],quoted:!0}:{values:[c+u[0],...u.slice(1,-1),u[u.length-1]+l],quoted:!0}}k(),mc(),j();function MM(e,t,n,r){if(t.length>=e.limits.maxArrayElements)throw new A(`unquoted expansion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let i=O(n);if(i>e.limits.maxStringLength-r.value)throw new A(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);t.push(n),r.value+=i}function NM(e,t,n,r){let i=O(n),a=Math.max(0,t.length-1);if(i>0&&a>Math.floor((e.limits.maxStringLength-r)/i))throw new A(`unquoted expansion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);return t.join(n)}function PM(e){return new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)})}async function FM(e,t){if(e.state.options.noglob)return t;let n=PM(e),r=[];for(let i of t)if(hj(i,e.state.shoptOptions.extglob)){let t=await n.expand(i);if(t.length>0)lM(r,t,e.limits.maxArrayElements,`unquoted glob expansion`);else{if(n.hasFailglob())throw new Dr(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function IM(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternReplacement`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=nj(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=bj(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=bj(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=bj(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=yj(n)}let d=s.replacement?await n(e,s.replacement.parts):``,f=u;s.anchor===`start`?f=`^${u}`:s.anchor===`end`&&(f=`${u}$`);let p=[],m={value:0};try{let t=U(f,s.all?`g`:``);for(let n of l)MM(e,p,kj(e,n,t,d,s.all),m)}catch(t){if(t instanceof A)throw t;for(let t of l)MM(e,p,t,m)}let h=MA(e.state.env),g=NA(e.state.env);if(o){let t=NM(e,p,IA(e.state.env),m.value);return g?{values:t?[t]:[],quoted:!1}:{values:HA(t,h,e.limits.maxArrayElements),quoted:!1}}if(g)return{values:p,quoted:!1};let _=[],v={value:0};for(let t of p)if(t===``)MM(e,_,``,v);else for(let n of HA(t,h,e.limits.maxArrayElements))MM(e,_,n,v);return{values:_,quoted:!1}}async function LM(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternRemoval`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=nj(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``,d=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=bj(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=bj(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=bj(n,s.greedy,d)}else{let n=await r(e,t);u+=yj(n)}let f=[],p={value:0};for(let t of l)MM(e,f,Dj(e,t,u,s.side,s.greedy),p);let m=MA(e.state.env),h=NA(e.state.env);if(o){let t=NM(e,f,IA(e.state.env),p.value);return h?{values:t?[t]:[],quoted:!1}:{values:HA(t,m,e.limits.maxArrayElements),quoted:!1}}if(h)return{values:f,quoted:!1};let g=[],_={value:0};for(let t of f)if(t===``)MM(e,g,``,_);else for(let n of HA(t,m,e.limits.maxArrayElements))MM(e,g,n,_);return{values:g,quoted:!1}}async function RM(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`PatternRemoval`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=[];for(let t=1;t<=s;t++)c.push(e.state.env.get(String(t))||``);if(c.length===0)return{values:[],quoted:!1};let l=``,u=e.state.shoptOptions.extglob;if(o.pattern)for(let t of o.pattern.parts)if(t.type===`Glob`)l+=bj(t.pattern,o.greedy,u);else if(t.type===`Literal`)l+=bj(t.value,o.greedy,u);else if(t.type===`SingleQuoted`||t.type===`Escaped`)l+=yj(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);l+=yj(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);l+=bj(n,o.greedy,u)}else{let n=await r(e,t);l+=yj(n)}let d=[],f={value:0};for(let t of c)MM(e,d,Dj(e,t,l,o.side,o.greedy),f);let p=MA(e.state.env),m=NA(e.state.env);if(a){let t=NM(e,d,IA(e.state.env),f.value);return m?{values:t?[t]:[],quoted:!1}:{values:HA(t,p,e.limits.maxArrayElements),quoted:!1}}if(m)return{values:d,quoted:!1};let h=[],g={value:0};for(let t of d)if(t===``)MM(e,h,``,g);else for(let n of HA(t,p,e.limits.maxArrayElements))MM(e,h,n,g);return{values:h,quoted:!1}}async function zM(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`Substring`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=o.offset?await n(e,o.offset.expression):0,c=o.length?await n(e,o.length.expression):void 0,l=Number.parseInt(e.state.env.get(`#`)||`0`,10),u=[];for(let t=1;t<=l;t++)u.push(e.state.env.get(String(t))||``);let d=e.state.env.get(`0`)||`bash`,f;if(s<=0){let e=[d,...u],t=e.length+s;if(t<0)f=[];else{let n=s<0?t:0;if(c!==void 0){let t=c<0?e.length+c:n+c;f=e.slice(n,Math.max(n,t))}else f=e.slice(n)}}else{let e=s-1;if(e>=u.length)f=[];else if(c!==void 0){let t=c<0?u.length+c:e+c;f=u.slice(e,Math.max(e,t))}else f=u.slice(e)}let p=``;for(let n=0;n<i;n++)p+=await r(e,t[n]);let m=``;for(let n=i+1;n<t.length;n++)m+=await r(e,t[n]);let h=MA(e.state.env),g=NA(e.state.env);if(f.length===0){let t=p+m;return t?g?{values:[t],quoted:!1}:{values:HA(t,h,e.limits.maxArrayElements),quoted:!1}:{values:[],quoted:!1}}let _;if(a){let t=IA(e.state.env),n=p+f.join(t)+m;_=g?n?[n]:[]:HA(n,h,e.limits.maxArrayElements)}else if(g)_=f.length===1?[p+f[0]+m]:[p+f[0],...f.slice(1,-1),f[f.length-1]+m];else{_=[];for(let t=0;t<f.length;t++){let n=f[t];if(t===0&&(n=p+n),t===f.length-1&&(n+=m),n===``)_.push(``);else{let t=HA(n,h,e.limits.maxArrayElements);lM(_,t,e.limits.maxArrayElements,`unquoted expansion`)}}}return{values:await FM(e,_),quoted:!1}}async function BM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].parameter!==`@`&&t[0].parameter!==`*`||t[0].operation)return null;let n=t[0].parameter===`*`,r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(r===0)return{values:[],quoted:!1};let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=MA(e.state.env),o=NA(e.state.env),s=PA(e.state.env),c;if(n)if(o)c=i.filter(e=>e!==``);else{let t=IA(e.state.env);c=HA(i.join(t),a,e.limits.maxArrayElements)}else if(o)c=i.filter(e=>e!==``);else if(s){c=[];for(let t of i){if(t===``)continue;let n=HA(t,a,e.limits.maxArrayElements);lM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{c=[];for(let t of i)if(t===``)c.push(``);else{let n=HA(t,a,e.limits.maxArrayElements);lM(c,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await FM(e,c),quoted:!1}}async function VM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],i=n[2]===`*`,a=nj(e,r),o;if(a.length===0){let t=e.state.env.get(r);if(t!==void 0)o=[t];else return{values:[],quoted:!1}}else o=a.map(([,e])=>e);let s=MA(e.state.env),c=NA(e.state.env),l=PA(e.state.env),u;if(i)if(c)u=o.filter(e=>e!==``);else{let t=IA(e.state.env);u=HA(o.join(t),s,e.limits.maxArrayElements)}else if(c)u=o.filter(e=>e!==``);else if(l){u=[];for(let t of o){if(t===``)continue;let n=HA(t,s,e.limits.maxArrayElements);lM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}}else{u=[];for(let t of o)if(t===``)u.push(``);else{let n=HA(t,s,e.limits.maxArrayElements);lM(u,n,e.limits.maxArrayElements,`unquoted expansion`)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await FM(e,u),quoted:!1}}function HM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=Oj(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=MA(e.state.env),a=NA(e.state.env),o;if(n.star)if(a)o=r;else{let t=IA(e.state.env);o=HA(r.join(t),i,e.limits.maxArrayElements)}else if(a)o=r;else{o=[];for(let t of r){let n=HA(t,i,e.limits.maxArrayElements);lM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}function UM(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=nj(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=MA(e.state.env),a=NA(e.state.env),o;if(n.star)if(a)o=r;else{let t=IA(e.state.env);o=HA(r.join(t),i,e.limits.maxArrayElements)}else if(a)o=r;else{o=[];for(let t of r){let n=HA(t,i,e.limits.maxArrayElements);lM(o,n,e.limits.maxArrayElements,`unquoted expansion`)}}return{values:o,quoted:!1}}async function WM(e,t,n){let r=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&!n.operation){r=e;break}}if(r===-1||t.length<=1)return null;let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=[];for(let t=1;t<=i;t++)a.push(e.state.env.get(String(t))||``);let o=``;for(let i=0;i<r;i++)o+=await n(e,t[i]);let s=``;for(let i=r+1;i<t.length;i++)s+=await n(e,t[i]);let c=MA(e.state.env),l=NA(e.state.env),u=PA(e.state.env);if(i===0){let e=o+s;return{values:e?[e]:[],quoted:!1}}let d;{let t=[];for(let e=0;e<a.length;e++){let n=a[e];e===0&&(n=o+n),e===a.length-1&&(n+=s),t.push(n)}if(l)d=t.filter(e=>e!==``);else if(u){d=[];for(let n of t){if(n===``)continue;let t=HA(n,c,e.limits.maxArrayElements);lM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}}else{d=[];for(let n of t)if(n===``)d.push(``);else{let t=HA(n,c,e.limits.maxArrayElements);lM(d,t,e.limits.maxArrayElements,`unquoted expansion`)}for(;d.length>0&&d[d.length-1]===``;)d.pop()}}return d.length===0?{values:[],quoted:!1}:{values:await FM(e,d),quoted:!1}}async function GM(e,t,n){e.coverage?.hit(`bash:expansion:word_glob`);let r=t.parts,{hasQuoted:i,hasCommandSub:a,hasArrayVar:o,hasArrayAtExpansion:s,hasParamExpansion:c,hasVarNamePrefixExpansion:l,hasIndirection:u}=OA(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return KM(e,d,i);let f=await qM(e,r,s,l,u,n);if(f!==null)return f;let p=await YM(e,r,n);if(p!==null)return p;let m=await XM(e,r,n);if(m!==null)return m;let h=await $M(e,r,n.expandPart);if(h!==null)return eN(e,h);if((a||o||c)&&!NA(e.state.env)){let t=MA(e.state.env),i=n.buildIfsCharClassPattern(t);return eN(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return nN(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function KM(e,t,n){let r=[];for(let i of t)!n&&i===``||(!n&&!e.state.options.noglob&&hj(i,e.state.shoptOptions.extglob)?lM(r,await tN(e,i),e.limits.maxArrayElements,`brace/glob expansion`):r.push(i));return{values:r,quoted:!1}}async function qM(e,t,n,r,i,a){if(n){let n=vM(e,t);if(n!==null)return n}{let n=yM(e,t);if(n!==null)return n}{let n=await pM(e,t);if(n!==null)return n}{let r=await mM(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await hM(e,t,n,a.expandPart);if(r!==null)return r}{let n=await gM(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=_M(e,t);if(n!==null)return n}{let n=await dM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await fM(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=JM(e,t);if(n!==null)return n}{let n=await bM(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await CM(e,t);if(n!==null)return n}{let n=await wM(e,t);if(n!==null)return n}return null}function JM(e,t){let n=t[0];if(n.type!==`DoubleQuoted`)return null;if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`VarNamePrefix`){let t=n.parts[0].operation,r=Oj(e,t.prefix);return t.star?{values:[r.join(IA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`ArrayKeys`){let t=n.parts[0].operation,r=nj(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(IA(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function YM(e,t,n){{let r=await OM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await kM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await AM(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await jM(e,t,n.expandPart);if(r!==null)return r}return null}async function XM(e,t,n){{let r=await IM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await LM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await RM(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await zM(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await BM(e,t);if(n!==null)return n}{let n=await VM(e,t);if(n!==null)return n}{let n=HM(e,t);if(n!==null)return n}{let n=UM(e,t);if(n!==null)return n}{let r=await WM(e,t,n.expandPart);if(r!==null)return r}return null}function ZM(e){if(e.type!==`DoubleQuoted`)return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!==`ParameterExpansion`||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:`array`,name:r[1],atIndex:t,isStar:r[2]===`*`};if(n.parameter===`@`||n.parameter===`*`)return{type:`positional`,atIndex:t,isStar:n.parameter===`*`}}return null}async function QM(e,t,n,r){let i=``;for(let a=0;a<n.atIndex;a++)i+=await r(e,t.parts[a]);let a=``;for(let i=n.atIndex+1;i<t.parts.length;i++)a+=await r(e,t.parts[i]);let o;if(n.type===`array`){if(o=nj(e,n.name).map(([,e])=>e),o.length===0){let t=e.state.env.get(n.name);t!==void 0&&(o=[t])}}else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);o=[];for(let n=1;n<=t;n++)o.push(e.state.env.get(String(n))||``)}if(n.isStar){let t=IA(e.state.env),n=o.join(t);return[i+n+a]}if(o.length===0){let e=i+a;return e?[e]:[]}return o.length===1?[i+o[0]+a]:[i+o[0],...o.slice(1,-1),o[o.length-1]+a]}async function $M(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if(ZM(e)){r=!0;break}if(!r)return null;let i=MA(e.state.env),a=NA(e.state.env),o=[];for(let r of t){let t=ZM(r);if(t&&r.type===`DoubleQuoted`){let i=await QM(e,r,t,n);o.push(i)}else if(r.type===`DoubleQuoted`||r.type===`SingleQuoted`){let t=await n(e,r);o.push([t])}else if(r.type===`Literal`)o.push([r.value]);else if(r.type===`ParameterExpansion`){let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=HA(t,i,e.limits.maxArrayElements);o.push(n)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let n=HA(t,i,e.limits.maxArrayElements);o.push(n)}}}let s=[];for(let t of o)if(t.length!==0)if(s.length===0)lM(s,t,e.limits.maxArrayElements,`word expansion`);else{let e=s.length-1;s[e]=s[e]+t[0];for(let e=1;e<t.length;e++)s.push(t[e])}return s}async function eN(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)hj(r,e.state.shoptOptions.extglob)?lM(n,await tN(e,r),e.limits.maxArrayElements,`glob expansion`):n.push(r);return{values:n,quoted:!1}}async function tN(e,t){let n=new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new Dr(t);return n.hasNullglob()?[]:[t]}async function nN(e,t,n,r,i,a){let o=n.some(e=>e.type===`Glob`);if(!e.state.options.noglob&&o){let n=await a(e,t);if(hj(n,e.state.shoptOptions.extglob)){let t=await tN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=gj(r);return NA(e.state.env)?{values:[i],quoted:!1}:{values:HA(i,MA(e.state.env),e.limits.maxArrayElements),quoted:!1}}if(!i&&!e.state.options.noglob&&hj(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(hj(n,e.state.shoptOptions.extglob)){let t=await tN(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1}}}if(r===``&&!i)return{values:[],quoted:!1};if(o&&!i){let t=gj(r);return NA(e.state.env)?{values:[t],quoted:!1}:{values:HA(t,MA(e.state.env),e.limits.maxArrayElements),quoted:!1}}return{values:[r],quoted:i}}j();function rN(e,t,n){if(t.length>=e.limits.maxArrayElements)throw new A(`word splitting element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);t.push(n)}async function iN(e,t){let n=t.operation;if(!n||n.type!==`DefaultValue`&&n.type!==`AssignDefault`&&n.type!==`UseAlternative`)return null;let r=n.word;if(!r||r.parts.length===0)return null;let i=await aj(e,t.parameter),a=await ij(e,t.parameter,!1)===``,o=n.checkEmpty??!1,s;return s=n.type===`UseAlternative`?i&&!(o&&a):!i||o&&a,s?r.parts:null}function aN(e){return e.type===`SingleQuoted`||e.type===`DoubleQuoted`&&e.parts.every(e=>e.type===`Literal`)}async function oN(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await iN(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>aN(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function sN(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?TA(e.pattern):!(e.type!==`ParameterExpansion`&&e.type!==`CommandSubstitution`&&e.type!==`ArithmeticExpansion`||e.type===`ParameterExpansion`&&DA(e))}async function cN(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await iN(e,a);if(o&&o.length>0&&o.length>1&&o.some(e=>e.type===`DoubleQuoted`||e.type===`SingleQuoted`)&&o.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`))return uN(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=sN(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await oN(e,n):null,c=await i(e,n);a.push({value:c,isSplittable:t,isQuoted:r,mixedDefaultParts:s??void 0}),t&&(o=!0)}if(!o){let e=a.map(e=>e.value).join(``);return e?[e]:[]}let s=[],c=``,l=!1,u=!1,d=!1;for(let t of a)if(!t.isSplittable)u?t.isQuoted&&t.value===``?(c!==``&&rN(e,s,c),rN(e,s,``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&rN(e,s,c),c=t.value,u=!1,d=!1):(c+=t.value,d=t.isQuoted&&t.value===``);else if(t.mixedDefaultParts){let a=await uN(e,t.mixedDefaultParts,n,r,i);if(a.length!==0)if(a.length===1)c+=a[0],l=!0;else{c+=a[0],rN(e,s,c),l=!0;for(let t=1;t<a.length-1;t++)rN(e,s,a[t]);c=a[a.length-1]}u=!1,d=!1}else{let{words:r,hadLeadingDelimiter:i,hadTrailingDelimiter:a}=VA(t.value,n,e.limits.maxArrayElements);if(d&&i&&c===``&&(rN(e,s,``),l=!0),r.length===0)a&&(u=!0);else if(r.length===1)c+=r[0],l=!0,u=a;else{c+=r[0],rN(e,s,c),l=!0;for(let t=1;t<r.length-1;t++)rN(e,s,r[t]);c=r[r.length-1],u=a}d=!1}return c===``?s.length===0&&l&&rN(e,s,``):rN(e,s,c),s}function lN(e,t){return e.length>0&&t.includes(e[0])}async function uN(e,t,n,r,i){let a=[];for(let n of t){let t=n.type!==`DoubleQuoted`&&n.type!==`SingleQuoted`,r=await i(e,n);a.push({value:r,isSplittable:t})}let o=[],s=``,c=!1,l=!1;for(let t of a)if(!t.isSplittable)l&&t.value!==``?(s!==``&&rN(e,o,s),s=t.value,l=!1):s+=t.value;else{lN(t.value,n)&&s!==``&&(rN(e,o,s),s=``,c=!0);let{words:r,hadTrailingDelimiter:i}=VA(t.value,n,e.limits.maxArrayElements);if(r.length===0)i&&(l=!0);else if(r.length===1)s+=r[0],c=!0,l=i;else{s+=r[0],rN(e,o,s),c=!0;for(let t=1;t<r.length-1;t++)rN(e,o,r[t]);s=r[r.length-1],l=i}}return s===``?o.length===0&&c&&rN(e,o,``):rN(e,o,s),o}function dN(e){switch(e.type){case`Literal`:return e.value;case`SingleQuoted`:return e.value;case`Escaped`:return e.value;default:return null}}function fN(e){switch(e.type){case`SingleQuoted`:case`Escaped`:case`DoubleQuoted`:return!0;case`Literal`:return e.value===``;default:return!1}}k(),k(),Zi();var pN=class{baseFs;mounts=new Map;constructor(e){if(this.baseFs=e?.base??new WE,e?.mounts)for(let{mountPoint:t,filesystem:n}of e.mounts)this.mount(t,n)}mount(e,t){this.validateMountPath(e);let n=I(e);this.validateMount(n),this.mounts.set(n,{mountPoint:n,filesystem:t})}unmount(e){let t=I(e);if(!this.mounts.has(t))throw Error(`No filesystem mounted at '${e}'`);this.mounts.delete(t)}getMounts(){return Array.from(this.mounts.values()).map(e=>({mountPoint:e.mountPoint,filesystem:e.filesystem}))}isMountPoint(e){let t=I(e);return this.mounts.has(t)}validateMountPath(e){let t=e.split(`/`);for(let n of t)if(n===`.`||n===`..`)throw Error(`Invalid mount point '${e}': contains '.' or '..' segments`)}validateMount(e){if(e===`/`)throw Error(`Cannot mount at root '/'`);for(let t of this.mounts.keys())if(t!==e){if(e.startsWith(`${t}/`))throw Error(`Cannot mount at '${e}': inside existing mount '${t}'`);if(t.startsWith(`${e}/`))throw Error(`Cannot mount at '${e}': would contain existing mount '${t}'`)}}routePath(e){Ki(e,`access`);let t=I(e),n=null,r=0;for(let e of this.mounts.values()){let i=e.mountPoint;if(t===i)return{fs:e.filesystem,relativePath:`/`};t.startsWith(`${i}/`)&&i.length>r&&(n=e,r=i.length)}if(n){let e=t.slice(r);return{fs:n.filesystem,relativePath:e||`/`}}return{fs:this.baseFs,relativePath:t}}getChildMountPoints(e){let t=I(e),n=t===`/`?`/`:`${t}/`,r=[];for(let e of this.mounts.keys())if(e.startsWith(n)){let t=e.slice(n.length).split(`/`)[0];t&&!r.includes(t)&&r.push(t)}return r}async readFile(e,t){let{fs:n,relativePath:r}=this.routePath(e);return n.readFile(r,t)}async readFileBytes(e){let{fs:t,relativePath:n}=this.routePath(e);return lr(t,n)}async readFileBuffer(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readFileBuffer(n)}async writeFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.writeFile(i,t,n)}async appendFile(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.appendFile(i,t,n)}async exists(e){let t=I(e);if(this.mounts.has(t)||this.getChildMountPoints(t).length>0)return!0;let{fs:n,relativePath:r}=this.routePath(e);return n.exists(r)}async stat(e){let t=I(e),n=this.mounts.get(t);if(n)try{return await n.filesystem.stat(`/`)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(t).length>0)try{return await this.baseFs.stat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.stat(i)}async lstat(e){let t=I(e),n=this.mounts.get(t);if(n)try{return await n.filesystem.lstat(`/`)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}if(this.getChildMountPoints(t).length>0)try{return await this.baseFs.lstat(t)}catch{return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:493,size:0,mtime:new Date}}let{fs:r,relativePath:i}=this.routePath(e);return r.lstat(i)}async mkdir(e,t){let n=I(e);if(this.mounts.has(n)){if(t?.recursive)return;throw Error(`EEXIST: directory already exists, mkdir '${e}'`)}if(this.getChildMountPoints(n).length>0&&t?.recursive)return;let{fs:r,relativePath:i}=this.routePath(e);return r.mkdir(i,t)}async readdir(e){let t=I(e),n=new Set,r=null,{fs:i,relativePath:a}=this.routePath(e);try{let e=await i.readdir(a);for(let t of e)n.add(t)}catch(e){let t=e.code,n=e.message||``;if(t!==`ENOENT`&&!n.includes(`ENOENT`))throw e;r=e}let o=this.getChildMountPoints(t);for(let e of o)n.add(e);if(n.size===0&&r&&!this.mounts.has(t))throw r;return Array.from(n).sort()}async rm(e,t){let n=I(e);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot remove '${e}'`);if(this.getChildMountPoints(n).length>0)throw Error(`EBUSY: contains mount points, cannot remove '${e}'`);let{fs:r,relativePath:i}=this.routePath(e);return r.rm(i,t)}async cp(e,t,n){if((await this.stat(e)).isDirectory&&Gi(e,t))throw Error(`EINVAL: cannot copy '${e}' into itself, '${t}'`);let r=this.routePath(e),i=this.routePath(t);return r.fs===i.fs?r.fs.cp(r.relativePath,i.relativePath,n):this.crossMountCopy(e,t,n)}async mv(e,t){let n=I(e);if((await this.stat(e)).isDirectory&&Gi(e,t))throw Error(`EINVAL: cannot move '${e}' into itself, '${t}'`);if(this.mounts.has(n))throw Error(`EBUSY: mount point, cannot move '${e}'`);let r=this.routePath(e),i=this.routePath(t);if(r.fs===i.fs)return r.fs.mv(r.relativePath,i.relativePath);await this.cp(e,t,{recursive:!0}),await this.rm(e,{recursive:!0})}resolvePath(e,t){return Ji(e,t)}getAllPaths(){let e=new Set;for(let t of this.baseFs.getAllPaths())e.add(t);for(let t of this.mounts.keys()){let n=t.split(`/`).filter(Boolean),r=``;for(let t of n)r=`${r}/${t}`,e.add(r);let i=this.mounts.get(t);if(i)for(let n of i.filesystem.getAllPaths())n===`/`?e.add(t):e.add(`${t}${n}`)}return Array.from(e).sort()}async chmod(e,t){let n=I(e),r=this.mounts.get(n);if(r)return r.filesystem.chmod(`/`,t);let{fs:i,relativePath:a}=this.routePath(e);return i.chmod(a,t)}async symlink(e,t){let{fs:n,relativePath:r}=this.routePath(t);return n.symlink(e,r)}async link(e,t){let n=this.routePath(e),r=this.routePath(t);if(n.fs!==r.fs)throw Error(`EXDEV: cross-device link not permitted, link '${e}' -> '${t}'`);return n.fs.link(n.relativePath,r.relativePath)}async readlink(e){let{fs:t,relativePath:n}=this.routePath(e);return t.readlink(n)}async realpath(e){let t=I(e);if(this.mounts.get(t))return t;let{fs:n,relativePath:r}=this.routePath(e),i=await n.realpath(r);for(let[e,n]of this.mounts)if(t===e||t.startsWith(`${e}/`))return i===`/`?e:`${e}${i}`;return i}async crossMountCopy(e,t,n){let r=await this.lstat(e);if(r.isFile){let n=await this.readFileBuffer(e);await this.writeFile(t,n),await this.chmod(t,r.mode)}else if(r.isDirectory){if(!n?.recursive)throw Error(`cp: ${e} is a directory (not copied)`);await this.mkdir(t,{recursive:!0});let r=await this.readdir(e);for(let i of r){let r=Yi(e,i),a=Yi(t,i);await this.crossMountCopy(r,a,n)}}else if(r.isSymbolicLink){let n=await this.readlink(e);await this.symlink(n,t)}}async utimes(e,t,n){let{fs:r,relativePath:i}=this.routePath(e);return r.utimes(i,t,n)}};j();var mN=`/dev/fd`,hN=63,gN=hN-10+1,_N=class extends WE{isLiveDescriptor;constructor(e){super(),this.isLiveDescriptor=e}assertLiveDescriptor(e,t){this.isLiveDescriptor(e)||this.refuse(e,t)}refuse(e,t){throw Error(`EROFS: read-only file system, ${t} '${mN}${e}'`)}async writeFile(e,t,n){return this.assertLiveDescriptor(e,`write`),super.writeFile(e,t,n)}async appendFile(e,t,n){return this.assertLiveDescriptor(e,`append`),super.appendFile(e,t,n)}async rm(e,t){return this.assertLiveDescriptor(e,`rm`),super.rm(e,t)}async mkdir(e,t){this.refuse(e,`mkdir`)}async cp(e,t){this.refuse(t,`cp`)}async mv(e,t){this.refuse(t,`mv`)}async symlink(e,t){this.refuse(t,`symlink`)}async link(e,t){this.refuse(t,`link`)}async chmod(e,t){this.refuse(e,`chmod`)}async utimes(e,t,n){this.refuse(e,`utimes`)}};function vN(e){let t=new _N(t=>xN(e).some(e=>e.path===`${mN}${t}`));e.fs=new pN({base:e.fs,mounts:[{mountPoint:mN,filesystem:t}]}),e.state.processSubstitutionFsMounted=!0}async function yN(e,t,n){try{await e.fs.writeFile(t,n,`binary`);return}catch(t){if(e.state.processSubstitutionFsMounted)throw t;vN(e)}await e.fs.writeFile(t,n,`binary`)}async function bN(e,t){try{await e.fs.rm(t,{force:!0})}catch{}}function xN(e){let t=e.state.processSubstitutions;if(t)return t;let n=[];return e.state.processSubstitutions=n,n}async function SN(e,t,n){let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new A(`Process substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth,o=new Map(e.state.env),s=eD(e.state.arrays),c=e.state.cwd,l=e.state.bashPid,u=e.state.suppressVerbose,d=e.state.groupStdin,f=e.state.lastExitCode,p=e.state.env.get(`?`);e.substitutionDepth=r+1,e.state.bashPid=e.state.nextVirtualPid++,e.state.suppressVerbose=!0,n!==void 0&&(e.state.groupStdin=n);let m;try{m=await e.executeScript(t)}catch(e){if(e instanceof A)throw e;if(e instanceof wr)return{stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode};throw e}finally{e.substitutionDepth=a,e.state.env=o,e.state.arrays=s,e.state.cwd=c,e.state.bashPid=l,e.state.suppressVerbose=u,e.state.groupStdin=d,e.state.lastExitCode=f,p===void 0?e.state.env.delete(`?`):e.state.env.set(`?`,p)}return m}async function CN(e,t){let n=xN(e);if(n.length>=gN)throw new A(`Process substitution limit exceeded (${gN} concurrent)`,`file_descriptors`);let r=``;if(t.direction===`input`){let n=await SN(e,t.body,void 0);if(n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),r=dr(n),r.length>e.limits.maxStringLength)throw new A(`process substitution: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)}let i=hN-n.length,a=`${mN}/${i}`;n.push({fd:i,path:a,direction:t.direction,body:t.body});try{await yN(e,a,r)}catch(e){throw n.pop(),e}return a}function wN(e){return e.state.processSubstitutions?.length??0}var TN={stdout:``,stderr:``};async function EN(e,t){let n=e.state.processSubstitutions;if(!n||n.length<=t)return TN;let r=``,i=``;for(;n.length>t;){let t=n[n.length-1],a=``;if(t.direction===`output`)try{a=await lr(e.fs,t.path)}catch{}if(await bN(e,t.path),n.pop(),t.direction===`output`){let n=await SN(e,t.body,a);r+=dr(n),i+=n.stderr}}return{stdout:r,stderr:i}}function DN(e,t,n){if(e.length>t)throw new A(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function ON(e,t,n=!1){let r=[];for(let i of t)r.push(await KN(e,i,n));return r.join(``)}function kN(e){return fN(e)}function AN(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!kN(t))return!1;return!0}function jN(e,t,n=!1){let r=dN(t);if(r!==null)return r;switch(t.type){case`TildeExpansion`:return n?t.user===null?`~`:`~${t.user}`:(e.coverage?.hit(`bash:expansion:tilde`),t.user===null?e.state.env.get(`HOME`)??`/home/user`:t.user===`root`?`/root`:`~${t.user}`);case`Glob`:return rM(e,t.pattern);default:return null}}async function MN(e,t){return GN(e,t)}async function NN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(vj(r.value));else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await KN(e,r);n.push(vj(t))}else n.push(await KN(e,r));return n.join(``)}async function PN(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`){let e=r.value;`()|*?[]`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`SingleQuoted`)n.push(_j(r.value));else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(_j(t))}else n.push(await KN(e,r));return n.join(``)}async function FN(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(_j(r.value));else if(r.type===`Escaped`){let e=r.value;`*?[]\\()|`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`DoubleQuoted`){let t=await ON(e,r.parts);n.push(_j(t))}else r.type===`Glob`?eM(r.pattern)?n.push(await aM(e,r.pattern)):n.push(rM(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await KN(e,r));return n.join(``)}function IN(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&IN(t.parts))return!0;return!1}var LN=1e5;async function RN(e,t,n={count:0}){let r=()=>{n.count++,e.executionScope.consumeLimited(`brace_operations`,1,Math.min(LN,e.limits.maxBraceExpansionResults),`brace expansion`)},i=(t,n)=>{if(t.length>=e.limits.maxBraceExpansionResults)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),t.push(n)},a=[[]];for(let o of t)if(o.type===`BraceExpansion`){let t=[],s=!1,c=``;for(let r of o.items)if(r.type===`Range`){let n=pj(r.start,r.end,r.step,r.startStr,r.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(n.expanded)for(let e of n.expanded)i(t,e);else{s=!0,c=n.literal;break}}else{let a=await RN(e,r.word.parts,n);for(let n of a){let r=[];for(let t of n)typeof t==`string`?r.push(t):r.push(await KN(e,t));i(t,r.join(``))}}if(s){for(let e of a)r(),e.push(c);continue}if(a.length*t.length>e.limits.maxBraceExpansionResults||n.count>LN)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);let l=[];for(let n of a)for(let i of t){if(l.length>=e.limits.maxBraceExpansionResults)throw new A(`brace expansion result limit exceeded (${e.limits.maxBraceExpansionResults})`,`array_elements`);r(),l.push([...n,i])}a=l}else for(let e of a)r(),e.push(o);return a}async function zN(e,t){let n=t.parts;if(!IN(n))return[await MN(e,t)];let r=await RN(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await KN(e,r));i.push(sM(e,n.join(``)))}return i}function BN(){return{expandWordAsync:GN,expandWordForGlobbing:FN,expandWordWithBracesAsync:zN,expandWordPartsAsync:ON,expandPart:KN,expandParameterAsync:qN,hasBraceExpansion:IN,evaluateArithmetic:rP,buildIfsCharClassPattern:FA,smartWordSplit:cN}}async function VN(e,t){return GM(e,t,BN())}function HN(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function UN(e,t){if(Number.parseInt(e.state.env.get(`#`)||`0`,10)<2)return!1;function n(e){for(let t of e)if(t.type===`DoubleQuoted`){for(let e of t.parts)if(e.type===`ParameterExpansion`&&e.parameter===`@`&&!e.operation)return!0}return!1}return n(t.parts)}async function WN(e,t){if(UN(e,t))return{error:`bash: $@: ambiguous redirect
928
+ `};let n=t.parts,{hasQuoted:r}=OA(n);if(IN(n)&&(await zN(e,t)).length>1)return{error:`bash: ${n.map(e=>e.type===`Literal`?e.value:e.type===`BraceExpansion`?`{${e.items.map(e=>{if(e.type===`Range`){let t=e.step?`..${e.step}`:``;return`${e.startStr??e.start}..${e.endStr??e.end}${t}`}return e.word.parts.map(e=>e.type===`Literal`?e.value:``).join(``)}).join(`,`)}}`:``).join(``)}: ambiguous redirect
929
+ `};let i=await GN(e,t),{hasParamExpansion:a,hasCommandSub:o}=OA(n);if((a||o)&&!r&&!NA(e.state.env)&&HA(i,MA(e.state.env),e.limits.maxArrayElements).length>1)return{error:`bash: $${HN(n)}: ambiguous redirect
930
+ `};if(r||e.state.options.noglob||n.some(e=>e.type===`ProcessSubstitution`))return{target:i};let s=await FN(e,t);if(!hj(s,e.state.shoptOptions.extglob))return{target:i};let c=new wA(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations,consumeOperation:()=>e.executionScope.consumeLimited(`glob_operations`,1,e.limits.maxGlobOperations,`glob expansion`)}),l=await c.expand(s);return l.length===0?c.hasFailglob()?{error:`bash: no match: ${i}
931
+ `}:{target:i}:l.length===1?{target:l[0]}:{error:`bash: ${i}: ambiguous redirect
932
+ `}}async function GN(e,t){let n=t.parts,r=n.length;if(r===1){let t=await KN(e,n[0]);return DN(t,e.limits.maxStringLength,`word expansion`),t}let i=[];for(let t=0;t<r;t++)i.push(await KN(e,n[t]));let a=i.join(``);return DN(a,e.limits.maxStringLength,`word expansion`),a}async function KN(e,t,n=!1){if(t.type===`ParameterExpansion`)return qN(e,t,n);let r=jN(e,t,n);if(r!==null)return r;switch(t.type){case`DoubleQuoted`:{let n=[];for(let r of t.parts)n.push(await KN(e,r,!0));return n.join(``)}case`CommandSubstitution`:{let n=mj(t.body);if(n)try{let t=await MN(e,n.target),r=t.startsWith(`/`)?t:`${e.state.cwd}/${t}`,i=await e.fs.readFile(r);e.state.lastExitCode=0,e.state.env.set(`?`,`0`);let a=i.replace(/\n+$/,``);return DN(a,e.limits.maxStringLength,`command substitution`),a}catch(t){if(t instanceof A)throw t;return e.state.lastExitCode=1,e.state.env.set(`?`,`1`),``}let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new A(`Command substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth;e.substitutionDepth=r+1;let o=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let s=new Map(e.state.env),c=eD(e.state.arrays),l=e.state.cwd,u=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let n=await e.executeScript(t.body),r=n.exitCode;e.state.env=s,e.state.arrays=c,e.state.cwd=l,e.state.suppressVerbose=u,e.state.lastExitCode=r,e.state.env.set(`?`,String(r)),n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),e.state.bashPid=o,e.substitutionDepth=a;let i=n.stdout.replace(/\n+$/,``);return DN(i,e.limits.maxStringLength,`command substitution`),i}catch(t){if(e.state.env=s,e.state.arrays=c,e.state.cwd=l,e.state.bashPid=o,e.substitutionDepth=a,e.state.suppressVerbose=u,t instanceof A)throw t;if(t instanceof wr){e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr);let n=t.stdout.replace(/\n+$/,``);return DN(n,e.limits.maxStringLength,`command substitution`),n}throw t}}case`ProcessSubstitution`:return CN(e,t);case`ArithmeticExpansion`:{let n=t.expression.originalText;if(n&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(n)){let t=await oj(e,n),r=sO(new Tk,t);return String(await rP(e,r.expression,!0))}return String(await rP(e,t.expression.expression,!0))}case`BraceExpansion`:{let n=[];for(let r of t.items)if(r.type===`Range`){let t=pj(r.start,r.end,r.step,r.startStr,r.endStr,{maxResults:e.limits.maxBraceExpansionResults,maxStringBytes:e.limits.maxStringLength});if(t.expanded)n.push(...t.expanded);else return t.literal}else n.push(await MN(e,r.word));return n.join(` `)}default:return``}}async function qN(e,t,n=!1){let{parameter:r}=t,{operation:i}=t,a=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,t,n]=a;(e.state.associativeArrays?.has(t)||n.includes(`$(`)||n.includes("`")||n.includes("${"))&&(r=`${t}[${await sj(e,n)}]`)}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&GA(e,r)){let t=QA(e,r);if(t&&t!==r){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let[,t,i]=n;(e.state.associativeArrays?.has(t)||i.includes(`$(`)||i.includes("`")||i.includes("${"))&&(r=`${t}[${await sj(e,i)}]`)}}}let o=i&&(i.type===`DefaultValue`||i.type===`AssignDefault`||i.type===`UseAlternative`||i.type===`ErrorIfUnset`),s=await ij(e,r,!o);if(!i)return s;let c=!await aj(e,r),{isEmpty:l,effectiveValue:u}=$j(e,r,s,n),d={value:s,isUnset:c,isEmpty:l,effectiveValue:u,inDoubleQuotes:n};switch(i.type){case`DefaultValue`:return Bj(e,i,d,ON);case`AssignDefault`:return Vj(e,r,i,d,ON);case`ErrorIfUnset`:return Hj(e,r,i,d,ON);case`UseAlternative`:return Uj(e,i,d,ON);case`PatternRemoval`:{let t=await Wj(e,s,i,ON,KN);return DN(t,e.limits.maxStringLength,`pattern removal`),t}case`PatternReplacement`:{let t=await Gj(e,s,i,ON,KN);return DN(t,e.limits.maxStringLength,`pattern replacement`),t}case`Length`:return Kj(e,r,s);case`LengthSliceError`:throw new Er(r);case`BadSubstitution`:throw new Er(i.text);case`Substring`:return qj(e,r,s,i);case`CaseModification`:{let t=await Jj(e,s,i,ON,qN);return DN(t,e.limits.maxStringLength,`case modification`),t}case`Transform`:return Yj(e,r,s,c,i);case`Indirection`:return Xj(e,r,s,c,i,qN,n);case`ArrayKeys`:return Zj(e,i);case`VarNamePrefix`:return Qj(e,i);default:return s}}function JN(){return{visited:new Set,depth:0}}function YN(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:if(t===0)throw new Tr(`division by 0`);return Math.trunc(e/t);case`%`:if(t===0)throw new Tr(`division by 0`);return e%t;case`**`:if(t<0)throw new Tr(`exponent less than 0`);return e**t;case`<<`:return e<<t;case`>>`:return e>>t;case`<`:return+(e<t);case`<=`:return+(e<=t);case`>`:return+(e>t);case`>=`:return+(e>=t);case`==`:return+(e===t);case`!=`:return e===t?0:1;case`&`:return e&t;case`|`:return e|t;case`^`:return e^t;case`,`:return t;default:return 0}}function XN(e,t,n){switch(n){case`=`:return t;case`+=`:return e+t;case`-=`:return e-t;case`*=`:return e*t;case`/=`:return t===0?0:Math.trunc(e/t);case`%=`:return t===0?0:e%t;case`<<=`:return e<<t;case`>>=`:return e>>t;case`&=`:return e&t;case`|=`:return e|t;case`^=`:return e^t;default:return t}}function ZN(e,t){switch(t){case`-`:return-e;case`+`:return+e;case`!`:return+(e===0);case`~`:return~e;default:return e}}async function QN(e,t){let n=e.state.env.get(t);if(n!==void 0)return n;let r=aD(e,t,0);return r===void 0?await ij(e,t):r}async function $N(e,t,n){if(!t)return 0;let r=Number.parseInt(t,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(t.trim()))return r;let i=t.trim();if(!i)return 0;let{expr:a,pos:o}=uO(new Tk,i,0);if(o<i.length){let e=i.slice(o).trim(),t=e.split(/\s+/)[0]||e;throw new Tr(`syntax error in expression (error token is "${t}")`,``,``)}return await iP(e,a,!1,n)}async function eP(e,t,n,r){if(r.depth>100)throw new Tr(`maximum variable indirection depth exceeded`);if(r.visited.has(t))throw new Tr(`arithmetic variable cycle detected at ${t}`);r.visited.add(t),r.depth++;try{return await $N(e,n,r)}finally{r.depth--,r.visited.delete(t)}}async function tP(e,t,n){if(n.depth>100)throw new Tr(`maximum variable indirection depth exceeded`);if(n.visited.has(t))throw new Tr(`arithmetic variable cycle detected at ${t}`);n.visited.add(t),n.depth++;try{let r=await QN(e,t);if(!r)return 0;let i=Number.parseInt(r,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(r.trim()))return i;let a=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return await tP(e,a,n);let{expr:o,pos:s}=uO(new Tk,a,0);if(s<a.length){let e=a.slice(s).trim(),t=e.split(/\s+/)[0]||e;throw new Tr(`${a}: syntax error in expression (error token is "${t}")`)}return await iP(e,o,!1,n)}finally{n.depth--,n.visited.delete(t)}}async function nP(e,t){if(t.startsWith(`#`)){let n=t.slice(1),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=nj(e,t);return String(n.length)}let i=e.state.env.get(n)||``;return String(i.length)}if(t.startsWith(`!`)){let n=t.slice(1),r=e.state.env.get(n)||``;return e.state.env.get(r)||``}let n=[`:-`,`:=`,`:?`,`:+`,`-`,`=`,`?`,`+`],r=-1,i=``;for(let e of n){let n=t.indexOf(e);n>0&&(r===-1||n<r)&&(r=n,i=e)}if(r===-1)return await ij(e,t);let a=t.slice(0,r),o=t.slice(r+i.length),s=e.state.env.get(a),c=s===void 0,l=s===``,u=i.startsWith(`:`);switch(i){case`:-`:case`-`:return c||u&&l?o:s||``;case`:=`:case`=`:return c||u&&l?(e.state.env.set(a,o),o):s||``;case`:+`:case`+`:return c||u&&l?``:o;case`:?`:case`?`:if(c||u&&l)throw Error(o||`${a}: parameter null or not set`);return s||``;default:return s||``}}async function rP(e,t,n=!1){return iP(e,t,n,JN())}async function iP(e,t,n,r){let i=(t,i=n)=>iP(e,t,i,r);switch(t.type){case`ArithNumber`:if(Number.isNaN(t.value))throw new Tr(`value too great for base`);return t.value;case`ArithVariable`:return await tP(e,t.name,r);case`ArithSpecialVar`:{let n=(await ij(e,t.name)).trim();if(!n)return 0;let r=Number.parseInt(n,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(n))return r;let{expr:a}=uO(new Tk,n,0);return await i(a)}case`ArithNested`:return await i(t.expression);case`ArithCommandSubst`:if(e.execFn){let n=await e.execFn(t.command,{signal:e.state.signal});n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr);let r=n.stdout.trim();return Number.parseInt(r,10)||0}return 0;case`ArithBracedExpansion`:{let n=await nP(e,t.content);return Number.parseInt(n,10)||0}case`ArithDynamicBase`:{let n=await nP(e,t.baseExpr),r=Number.parseInt(n,10);return r<2||r>64?0:nO(`${r}#${t.value}`)}case`ArithDynamicNumber`:return nO(await nP(e,t.prefix)+t.suffix);case`ArithArrayElement`:{let n=e.state.associativeArrays?.has(t.array),a=async n=>{let i=aD(e,t.array,n);return i===void 0?0:await eP(e,`${t.array}[${n}]`,i,r)};if(t.stringKey!==void 0)return await a(t.stringKey);if(n&&t.index?.type===`ArithVariable`&&!t.index.hasDollarPrefix)return await a(t.index.name);if(n&&t.index?.type===`ArithVariable`&&t.index.hasDollarPrefix)return await a(await ij(e,t.index.name));if(t.index){let n=await i(t.index);if(n<0){let r=nj(e,t.array),i=e.state.currentLine;if(r.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript
933
+ `,0;let a=Math.max(...r.map(([e])=>typeof e==`number`?e:0))+1+n;if(a<0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript
934
+ `,0;n=a}let a=`${t.array}[${n}]`,o=aD(e,t.array,n);if(o!==void 0)return eP(e,a,o,r);if(n===0){let n=e.state.env.get(t.array);if(n!==void 0)return eP(e,t.array,n,r)}if(e.state.options.nounset&&!(e.state.env.has(t.array)||iD(e,t.array)))throw new Cr(`${t.array}[${n}]`);return 0}return 0}case`ArithDoubleSubscript`:throw new Tr(`double subscript`,``,``);case`ArithNumberSubscript`:throw new Tr(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case`ArithSyntaxError`:throw new Tr(t.message,``,``,!0);case`ArithSingleQuote`:if(n)throw new Tr(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value;case`ArithBinary`:return t.operator===`||`?await i(t.left)||await i(t.right)?1:0:t.operator===`&&`?await i(t.left)&&await i(t.right)?1:0:YN(await i(t.left),await i(t.right),t.operator);case`ArithUnary`:{let a=await i(t.operand);if(t.operator===`++`||t.operator===`--`){if(t.operand.type===`ArithVariable`){let n=t.operand.name,r=Number.parseInt(await ij(e,n),10)||0,i=t.operator===`++`?r+1:r-1;return e.state.env.set(n,String(i)),t.prefix?i:r}if(t.operand.type===`ArithArrayElement`){let n=t.operand.array,r=e.state.associativeArrays?.has(n),o;if(t.operand.stringKey!==void 0)o=t.operand.stringKey;else if(r&&t.operand.index?.type===`ArithVariable`&&!t.operand.index.hasDollarPrefix)o=t.operand.index.name;else if(r&&t.operand.index?.type===`ArithVariable`&&t.operand.index.hasDollarPrefix)o=await ij(e,t.operand.index.name);else if(t.operand.index){let e=await i(t.operand.index);o=String(e)}else return a;let s=Number.parseInt(aD(e,n,o)||`0`,10)||0,c=t.operator===`++`?s+1:s-1;return Y(e,n,o,String(c),r?`associative`:`indexed`),t.prefix?c:s}if(t.operand.type===`ArithConcat`){let i=``;for(let a of t.operand.parts)i+=await aP(e,a,n,r);if(i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){let n=Number.parseInt(e.state.env.get(i)||`0`,10)||0,r=t.operator===`++`?n+1:n-1;return e.state.env.set(i,String(r)),t.prefix?r:n}}if(t.operand.type===`ArithDynamicElement`){let a=``;if(t.operand.nameExpr.type===`ArithConcat`)for(let i of t.operand.nameExpr.parts)a+=await aP(e,i,n,r);else t.operand.nameExpr.type===`ArithVariable`&&(a=t.operand.nameExpr.hasDollarPrefix?await ij(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(a&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){let n=await i(t.operand.subscript),r=Number.parseInt(aD(e,a,n)||`0`,10)||0,o=t.operator===`++`?r+1:r-1;return Y(e,a,n,String(o)),t.prefix?o:r}}return a}return ZN(a,t.operator)}case`ArithTernary`:return await i(t.condition)?await i(t.consequent):await i(t.alternate);case`ArithAssignment`:{let n=t.variable,r=n,a;if(t.stringKey!==void 0)a=t.stringKey;else if(t.subscript){let r=e.state.associativeArrays?.has(n);if(r&&t.subscript.type===`ArithVariable`&&!t.subscript.hasDollarPrefix)a=t.subscript.name;else if(r&&t.subscript.type===`ArithVariable`&&t.subscript.hasDollarPrefix)a=await ij(e,t.subscript.name)||`\\`;else if(r){let e=await i(t.subscript);a=String(e)}else{let r=await i(t.subscript);if(r<0){let t=nj(e,n);t.length>0&&(r=Math.max(...t.map(([e])=>typeof e==`number`?e:0))+1+r)}a=String(r)}}let o=a===void 0?e.state.env.get(r):aD(e,n,a),s=XN(Number.parseInt(o||`0`,10)||0,await i(t.value),t.operator);return a===void 0?e.state.env.set(r,String(s)):Y(e,n,a,String(s),e.state.associativeArrays?.has(n)?`associative`:`indexed`),s}case`ArithGroup`:return await i(t.expression);case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await aP(e,a,n,r);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?await tP(e,i,r):Number.parseInt(i,10)||0}case`ArithDynamicAssignment`:{let a=``;if(t.target.type===`ArithConcat`)for(let i of t.target.parts)a+=await aP(e,i,n,r);else t.target.type===`ArithVariable`&&(a=t.target.hasDollarPrefix?await ij(e,t.target.name):t.target.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=a;if(t.subscript){let e=await i(t.subscript);o=`${a}_${e}`}let s=XN(Number.parseInt(e.state.env.get(o)||`0`,10)||0,await i(t.value),t.operator);return e.state.env.set(o,String(s)),s}case`ArithDynamicElement`:{let a=``;if(t.nameExpr.type===`ArithConcat`)for(let i of t.nameExpr.parts)a+=await aP(e,i,n,r);else t.nameExpr.type===`ArithVariable`&&(a=t.nameExpr.hasDollarPrefix?await ij(e,t.nameExpr.name):t.nameExpr.name);if(!a||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a))return 0;let o=await i(t.subscript),s=`${a}_${o}`,c=e.state.env.get(s);return c===void 0?0:eP(e,s,c,r)}default:return 0}}async function aP(e,t,n=!1,r=JN()){switch(t.type){case`ArithNumber`:return String(t.value);case`ArithSingleQuote`:return String(await iP(e,t,n,r));case`ArithVariable`:return t.hasDollarPrefix?await ij(e,t.name):t.name;case`ArithSpecialVar`:return await ij(e,t.name);case`ArithBracedExpansion`:return await nP(e,t.content);case`ArithCommandSubst`:return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():`0`;case`ArithConcat`:{let i=``;for(let a of t.parts)i+=await aP(e,a,n,r);return i}default:return String(await iP(e,t,n,r))}}Lr(),j();async function oP(e,t){let n=``,r=0;for(let i of t.parts){let t=i.type===`Literal`?i.value:`\0`,a=O(t);if(a>e.limits.maxStringLength-r)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);n+=t,r+=a}let i=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!i||!n.endsWith(`)`))return null;let a=i[1],o=[],s=[],c=!1,l=``,u=0,d=0,f=!1,p=!0,m=t=>{let n=O(t);if(n>e.limits.maxStringLength-d-u)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);l+=t,u+=n},h=(t,n=!1)=>{if(o.length>=e.limits.maxArrayElements)throw new A(`array assignment element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let r=O(t);if(r>e.limits.maxStringLength-d)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);o.push(t),s.push(n),d+=r},g=()=>{h(l,p),l=``,u=0,f=!1,p=!0};for(let n of t.parts)if(n.type===`Literal`){let e=n.value;if(!c){let t=e.indexOf(`=(`);t!==-1&&(c=!0,e=e.slice(t+2))}if(c){e.endsWith(`)`)&&(e=e.slice(0,-1));for(let t of e)/\s/.test(t)?(l||f)&&g():m(t)}}else if(c)if(n.type===`BraceExpansion`)if(/^\[.+\]=/.test(l))m(gD({type:`Word`,parts:[n]}));else{(l||f)&&g();let t=await VN(e,{type:`Word`,parts:[n]});for(let e of t.values)h(e)}else(n.type===`SingleQuoted`||n.type===`DoubleQuoted`||n.type===`Escaped`)&&(f=!0),p=!1,m(await MN(e,{type:`Word`,parts:[n]}));(l||f)&&g();let _=o.splice(0),v=s.splice(0);d=0;for(let t=0;t<_.length;t++){let n=_[t];if(!v[t]){h(n);continue}let r=n.match(/^(\[[^\]]+\]=)(.*)$/s);if(r){let t=cM(e,r[2]);n=r[1]+t}if(n.includes(`{`)&&n.includes(`}`)){let t=new Tk().parseWordFromString(n,!1,!1);if(t.parts.some(e=>e.type===`BraceExpansion`)){let n=await VN(e,t);for(let e of n.values)h(e);continue}}h(n)}let y=[`${a}=(`],b=O(y[0]);for(let t=0;t<o.length;t++){let n=o[t],r;r=/^\[.+\]=/.test(n)?n:n===``?`''`:/[\s"'\\$`!*?[\]{}|&;<>()]/.test(n)&&!n.startsWith(`'`)&&!n.startsWith(`"`)?`'${n.replace(/'/g,`'\\''`)}'`:n;let i=`${t>0?` `:``}${r}`,a=O(i);if(a+1>e.limits.maxStringLength-b)throw new A(`array assignment string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);y.push(i),b+=a}return y.push(`)`),y.join(``)}async function sP(e,t){let n=-1,r=-1,i=!1;for(let e=0;e<t.parts.length;e++){let a=t.parts[e];if(a.type===`Literal`){let t=a.value.indexOf(`+=`);if(t!==-1){let o=a.value.slice(0,t);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){n=e,r=t,i=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(o)){n=e,r=t,i=!0;break}}let o=a.value.indexOf(`=`);if(o!==-1&&(o===0||a.value[o-1]!==`+`)){let t=a.value.slice(0,o);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(t)){n=e,r=o;break}}}}if(n===-1)return null;let a=t.parts.slice(0,n),o=t.parts[n];if(o.type!==`Literal`)return null;let s=i?2:1,c=o.value.slice(0,r),l=o.value.slice(r+s),u=t.parts.slice(n+1),d=``;for(let t of a)d+=await MN(e,{type:`Word`,parts:[t]});d+=c;let f={type:`Word`,parts:l===``?u:[{type:`Literal`,value:l},...u]},p=f.parts.length>0?await MN(e,f):``;return`${d}${i?`+=`:`=`}${p}`}var cP=[`tar`,`yq`,`xan`,`sqlite3`,`python3`,`python`];function lP(e){return cP.includes(e)}k(),ea(),Su(),qn(),Yb(),nr(),j(),j();var uP=Object.freeze({stdout:``,stderr:``,exitCode:0,internalStdinConsumed:0});function dP(e=``){return{stdout:e,stderr:``,exitCode:0}}function Q(e,t=1){return{stdout:``,stderr:e,exitCode:t}}function $(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function fP(e){return{stdout:``,stderr:``,exitCode:+!e,internalStdinConsumed:0}}function pP(e,t,n=``,r=``){throw new A(e,t,n,r)}function mP(e){let t=e.state.fileDescriptors;if(t&&t.size>=e.limits.maxFileDescriptors)throw new A(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,`file_descriptors`)}function hP(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ar;return uP}if(t.length>1)throw new wr(1,``,`bash: break: too many arguments
935
+ `);let n=1;if(t.length>0){let e=Number.parseInt(t[0],10);if(Number.isNaN(e)||e<1)throw new wr(128,``,`bash: break: ${t[0]}: numeric argument required
936
+ `);n=e}throw new yr(n)}async function gP(e,t){let n,r=!1,i=!1,a=0;for(;a<t.length;)if(t[a]===`--`){a++;break}else if(t[a]===`-L`)i=!1,a++;else if(t[a]===`-P`)i=!0,a++;else if(t[a].startsWith(`-`)&&t[a]!==`-`)a++;else break;let o=t.slice(a);if(o.length===0||o[0]===`~`?n=e.state.env.get(`HOME`)||`/`:o[0]===`-`?(n=e.state.previousDir,r=!0):n=o[0],!n.startsWith(`/`)&&!n.startsWith(`./`)&&!n.startsWith(`../`)&&n!==`.`&&n!==`..`){let t=e.state.env.get(`CDPATH`);if(t){let i=t.split(`:`).filter(e=>e);for(let t of i){let i=t.startsWith(`/`)?`${t}/${n}`:`${e.state.cwd}/${t}/${n}`;try{if((await e.fs.stat(i)).isDirectory){n=i,r=!0;break}}catch{}}}}let s=(n.startsWith(`/`)?n:`${e.state.cwd}/${n}`).split(`/`).filter(e=>e&&e!==`.`),c=``;for(let t of s)if(t===`..`)c=c.split(`/`).slice(0,-1).join(`/`)||`/`;else{c=c?`${c}/${t}`:`/${t}`;try{if(!(await e.fs.stat(c)).isDirectory)return Q(`bash: cd: ${n}: Not a directory
937
+ `)}catch{return Q(`bash: cd: ${n}: No such file or directory
938
+ `)}}let l=c||`/`;if(i)try{l=await e.fs.realpath(l)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=l,e.state.env.set(`PWD`,e.state.cwd),e.state.env.set(`OLDPWD`,e.state.previousDir),dP(r?`${l}
939
+ `:``)}Wi(),k(),mc(),j();function _P(e,t){return e.fs.resolvePath(e.state.cwd,t)}var vP=[`-e`,`-a`,`-f`,`-d`,`-r`,`-w`,`-x`,`-s`,`-L`,`-h`,`-k`,`-g`,`-u`,`-G`,`-O`,`-b`,`-c`,`-p`,`-S`,`-t`,`-N`];function yP(e){return vP.includes(e)}async function bP(e,t,n){let r=_P(e,n);switch(t){case`-e`:case`-a`:return e.fs.exists(r);case`-f`:return await e.fs.exists(r)?(await e.fs.stat(r)).isFile:!1;case`-d`:return await e.fs.exists(r)?(await e.fs.stat(r)).isDirectory:!1;case`-r`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&256):!1;case`-w`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&128):!1;case`-x`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&64):!1;case`-s`:return await e.fs.exists(r)?(await e.fs.stat(r)).size>0:!1;case`-L`:case`-h`:try{return(await e.fs.lstat(r)).isSymbolicLink}catch{return!1}case`-k`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&512):!1;case`-g`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&1024):!1;case`-u`:return await e.fs.exists(r)?!!((await e.fs.stat(r)).mode&2048):!1;case`-G`:case`-O`:return e.fs.exists(r);case`-b`:return!1;case`-c`:return[`/dev/null`,`/dev/zero`,`/dev/random`,`/dev/urandom`,`/dev/tty`,`/dev/stdin`,`/dev/stdout`,`/dev/stderr`].includes(r);case`-p`:return!1;case`-S`:return!1;case`-t`:return!1;case`-N`:return e.fs.exists(r);default:return!1}}var xP=[`-nt`,`-ot`,`-ef`];function SP(e){return xP.includes(e)}async function CP(e,t,n,r){let i=_P(e,n),a=_P(e,r);switch(t){case`-nt`:{let[t,n]=await Promise.all([e.fs.stat(i).catch(()=>null),e.fs.stat(a).catch(()=>null)]);return t!==null&&(n===null||t.mtime>n.mtime)}case`-ot`:{let[t,n]=await Promise.all([e.fs.stat(i).catch(()=>null),e.fs.stat(a).catch(()=>null)]);return n!==null&&(t===null||t.mtime<n.mtime)}case`-ef`:try{let[t,n]=await Promise.all([e.fs.realpath(i),e.fs.realpath(a)]);if(t===n)return!0;let[r,o]=await Promise.all([e.fs.stat(i),e.fs.stat(a)]);return r.dev!==void 0&&r.ino!==void 0&&o.dev!==void 0&&o.ino!==void 0?r.dev===o.dev&&r.ino===o.ino:r.identity&&o.identity?r.identity===o.identity:!1}catch{return!1}default:return!1}}var wP=new Set([`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`]);function TP(e){return wP.has(e)}function EP(e,t,n){switch(e){case`-eq`:return t===n;case`-ne`:return t!==n;case`-lt`:return t<n;case`-le`:return t<=n;case`-gt`:return t>n;case`-ge`:return t>=n}}function DP(e){return e===`=`||e===`==`||e===`!=`}function OP(e,t,n,r=!1,i=!1,a=!1,o=256){if(r){let r=BP(t,n,i,a,o);return e===`!=`?!r:r}if(i){let r=t.toLowerCase()===n.toLowerCase();return e===`!=`?!r:r}let s=t===n;return e===`!=`?!s:s}var kP=new Set([`-z`,`-n`]);function AP(e){return kP.has(e)}function jP(e,t){switch(e){case`-z`:return t===``;case`-n`:return t!==``}}async function MP(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(e.state.associativeArrays?.has(t)){let n=r;return(n.startsWith(`'`)&&n.endsWith(`'`)||n.startsWith(`"`)&&n.endsWith(`"`))&&(n=n.slice(1,-1)),n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(t,n)=>e.state.env.get(n)||``),oD(e,t,n)}let i;try{i=await rP(e,sO(new Tk,r).expression)}catch{if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0}}if(i<0){let n=uD(e,t),r=e.state.currentLine;if(n.length===0||(i=Math.max(...n)+1+i,i<0))return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
940
+ `,!1}return oD(e,t,i)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?fD(e,t).length>0:uD(e,t).length>0}async function NP(e,t){switch(t.type){case`CondBinary`:{let n=await MN(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(e=>e.type===`SingleQuoted`||e.type===`DoubleQuoted`||e.type===`Escaped`&&t.operator!==`=~`),i;if(i=t.operator===`=~`?r?vj(await MN(e,t.right)):await NN(e,t.right):DP(t.operator)&&!r?await PN(e,t.right):await MN(e,t.right),DP(t.operator)){let a=e.state.shoptOptions.nocasematch;return OP(t.operator,n,i,!r,a,!0,e.limits.maxCallDepth)}if(TP(t.operator))return EP(t.operator,await qP(e,n),await qP(e,i));if(SP(t.operator))return CP(e,t.operator,n,i);switch(t.operator){case`=~`:try{let t=e.state.shoptOptions.nocasematch,r=U(ZP(i),t?`i`:``).match(n);if(dD(e,`BASH_REMATCH`),r)for(let t=0;t<r.length;t++)Y(e,`BASH_REMATCH`,t,r[t]||``);return r!==null}catch{throw Error(`syntax error in regular expression`)}case`<`:return n<i;case`>`:return n>i;default:return!1}}case`CondUnary`:{let n=await MN(e,t.operand);return yP(t.operator)?bP(e,t.operator,n):AP(t.operator)?jP(t.operator,n):t.operator===`-v`?await MP(e,n):t.operator===`-o`&&KP(e,n)}case`CondNot`:return e.state.shoptOptions.extglob&&t.operand.type===`CondGroup`&&t.operand.expression.type===`CondWord`?`!(${await MN(e,t.operand.expression.word)})`!=``:!await NP(e,t.operand);case`CondAnd`:return await NP(e,t.left)?await NP(e,t.right):!1;case`CondOr`:return await NP(e,t.left)?!0:await NP(e,t.right);case`CondGroup`:return await NP(e,t.expression);case`CondWord`:return await MN(e,t.word)!==``;default:return!1}}async function PP(e,t){if(t.length===0)return $(``,``,1);if(t.length===1)return fP(!!t[0]);if(t.length===2){let n=t[0],r=t[1];return n===`(`?Q(`test: '(' without matching ')'
941
+ `,2):yP(n)?fP(await bP(e,n,r)):AP(n)?fP(jP(n,r)):n===`!`?fP(!r):n===`-v`?fP(await MP(e,r)):n===`-o`?fP(KP(e,r)):n===`=`||n===`==`||n===`!=`||n===`<`||n===`>`||n===`-eq`||n===`-ne`||n===`-lt`||n===`-le`||n===`-gt`||n===`-ge`||n===`-nt`||n===`-ot`||n===`-ef`?Q(`test: ${n}: unary operator expected
942
+ `,2):$(``,``,1)}if(t.length===3){let n=t[0],r=t[1],i=t[2];if(DP(r))return fP(OP(r,n,i));if(TP(r)){let e=XP(n),t=XP(i);return!e.valid||!t.valid?$(``,``,2):fP(EP(r,e.value,t.value))}if(SP(r))return fP(await CP(e,r,n,i));switch(r){case`-a`:return fP(n!==``&&i!==``);case`-o`:return fP(n!==``||i!==``);case`>`:return fP(n>i);case`<`:return fP(n<i)}if(n===`!`){let t=await PP(e,[r,i]);return $(``,t.stderr,t.exitCode===0?1:t.exitCode===1?0:t.exitCode)}if(n===`(`&&i===`)`)return fP(r!==``)}if(t.length===4){if(t[0]===`!`){let n=await PP(e,t.slice(1));return $(``,n.stderr,n.exitCode===0?1:n.exitCode===1?0:n.exitCode)}if(t[0]===`(`&&t[3]===`)`)return PP(e,[t[1],t[2]])}let n=await FP(e,t,0);return n.pos<t.length?Q(`test: too many arguments
943
+ `,2):fP(n.value)}async function FP(e,t,n){return IP(e,t,n)}async function IP(e,t,n){let{value:r,pos:i}=await LP(e,t,n);for(;t[i]===`-o`;){let n=await LP(e,t,i+1);r||=n.value,i=n.pos}return{value:r,pos:i}}async function LP(e,t,n){let{value:r,pos:i}=await RP(e,t,n);for(;t[i]===`-a`;){let n=await RP(e,t,i+1);r&&=n.value,i=n.pos}return{value:r,pos:i}}async function RP(e,t,n){let r=e.executionScope.enterDepth(`test_expression`,e.limits.maxCallDepth,`test expression`);try{if(t[n]===`!`){let{value:r,pos:i}=await RP(e,t,n+1);return{value:!r,pos:i}}return zP(e,t,n)}finally{r.release()}}async function zP(e,t,n){let r=t[n];if(r===`(`){let{value:r,pos:i}=await FP(e,t,n+1);return{value:r,pos:t[i]===`)`?i+1:i}}let i=t[n+1];if(DP(i))return{value:OP(i,r,t[n+2]??``),pos:n+3};if(TP(i)){let e=XP(r),a=XP(t[n+2]??`0`);return!e.valid||!a.valid?{value:!1,pos:n+3}:{value:EP(i,e.value,a.value),pos:n+3}}return SP(i)?{value:await CP(e,i,r,t[n+2]??``),pos:n+3}:yP(r)?{value:await bP(e,r,t[n+1]??``),pos:n+2}:AP(r)?{value:jP(r,t[n+1]??``),pos:n+2}:r===`-v`?{value:await MP(e,t[n+1]??``),pos:n+2}:r===`-o`?{value:KP(e,t[n+1]??``),pos:n+2}:{value:r!==void 0&&r!==``,pos:n+1}}function BP(e,t,n=!1,r=!1,i=256){return r&&VP(t,i),U(`^${HP(t,r)}$`,n?`is`:`s`).test(e)}function VP(e,t){let n=0,r=[];for(let i=0;i<e.length;i++){if(e[i]===`\\`){i++;continue}if(e[i]===`(`){let a=i>0&&`@*+?!`.includes(e[i-1]);if(r.push(a),a&&n++,n>t)throw new A(`extglob maximum depth (${t}) exceeded`,`recursion`)}else e[i]===`)`&&r.length>0&&r.pop()&&n--}}function HP(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(t&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let a=UP(e,r+1);if(a!==-1){let o=WP(e.slice(r+2,a)),s=o.map(e=>HP(e,t)),c=s.length>0?s.join(`|`):`(?:)`;if(i===`@`)n+=`(?:${c})`;else if(i===`*`)n+=`(?:${c})*`;else if(i===`+`)n+=`(?:${c})+`;else if(i===`?`)n+=`(?:${c})?`;else if(i===`!`)if(a<e.length-1){let e=o.map(e=>GP(e,t));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let t=e[0];if(t===0)n+=`(?:.+)`;else{let e=[];t>0&&e.push(`.{0,${t-1}}`),e.push(`.{${t+1},}`),e.push(`(?!(?:${c})).{${t}}`),n+=`(?:${e.join(`|`)})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`;r=a;continue}}if(i===`\\`)if(r+1<e.length){let t=e[r+1];/[\\^$.|+(){}[\]*?]/.test(t)?n+=`\\${t}`:n+=t,r++}else n+=`\\\\`;else if(i===`*`)n+=`.*`;else if(i===`?`)n+=`.`;else if(i===`[`){let t=e.indexOf(`]`,r+1);t===-1?n+=`\\[`:(n+=e.slice(r,t+1),r=t)}else/[\\^$.|+(){}]/.test(i)?n+=`\\${i}`:n+=i}return n}function UP(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function WP(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function GP(e,t){let n=0,r=0;for(;r<e.length;){let i=e[r];if(t&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let a=UP(e,r+1);if(a!==-1){if(i===`@`){let i=WP(e.slice(r+2,a)).map(e=>GP(e,t));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){n+=i[0],r=a+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){n+=1,r++;continue}if(i===`[`){let t=e.indexOf(`]`,r+1);if(t!==-1){n+=1,r=t+1;continue}n+=1,r++;continue}if(i===`\\`){n+=1,r+=2;continue}n+=1,r++}return n}function KP(e,t){let n=new Map([[`errexit`,()=>e.state.options.errexit===!0],[`nounset`,()=>e.state.options.nounset===!0],[`pipefail`,()=>e.state.options.pipefail===!0],[`xtrace`,()=>e.state.options.xtrace===!0],[`e`,()=>e.state.options.errexit===!0],[`u`,()=>e.state.options.nounset===!0],[`x`,()=>e.state.options.xtrace===!0]]).get(t);return n?n():!1}async function qP(e,t){if(t=t.trim(),t===``)return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return YP(t);try{return await rP(e,sO(new Tk,t).expression)}catch{return YP(t)}}function JP(e,t){let n=0;for(let r of e){let e;if(r>=`0`&&r<=`9`)e=r.charCodeAt(0)-48;else if(r>=`a`&&r<=`z`)e=r.charCodeAt(0)-97+10;else if(r>=`A`&&r<=`Z`)e=r.charCodeAt(0)-65+36;else if(r===`@`)e=62;else if(r===`_`)e=63;else return NaN;if(e>=t)return NaN;n=n*t+e}return n}function YP(e){if(e=e.trim(),e===``)return 0;let t=!1;e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1));let n,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let e=Number.parseInt(r[1],10);n=e>=2&&e<=64?JP(r[2],e):0}else n=/^0[xX][0-9a-fA-F]+$/.test(e)?Number.parseInt(e,16):/^0[0-7]+$/.test(e)?Number.parseInt(e,8):Number.parseInt(e,10);return Number.isNaN(n)&&(n=0),t?-n:n}function XP(e){if(e=e.trim(),e===``)return{value:0,valid:!0};let t=!1;if(e.startsWith(`-`)?(t=!0,e=e.slice(1)):e.startsWith(`+`)&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let n=Number.parseInt(e,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:t?-n:n,valid:!0}}function ZP(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length)t+=e[n]+e[n+1],n+=2;else if(e[n]===`[`){let r=QP(e,n);t+=r.converted,n=r.endIndex}else t+=e[n],n++;return t}function QP(e,t){let n=t+1,r=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(r+=`^`,n++);let i=!1;n<e.length&&e[n]===`]`&&(i=!0,n++);let a=!1;n<e.length&&e[n]===`[`&&n+1<e.length&&e[n+1]!==`:`&&(a=!0,n++);let o=``,s=!1;for(;n<e.length;){let t=e[n];if(t===`]`){s=!0,n++;break}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=e.slice(n+2,t);o+=$P(r),n=t+2;continue}}if(t===`[`&&n+1<e.length){let t=e[n+1];if(t===`.`||t===`=`){let r=`${t}]`,i=e.indexOf(r,n+2);if(i!==-1){let t=e.slice(n+2,i);o+=t,n=i+2;continue}}}if(t===`\\`&&n+1<e.length){o+=t+e[n+1],n+=2;continue}o+=t,n++}return s?(i&&(r+=`\\]`),a&&(r+=`\\[`),r+=o,r+=`]`,{converted:r,endIndex:n}):{converted:`\\[`,endIndex:t+1}}function $P(e){return new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9A-Fa-f`]]).get(e)??``}j(),k(),j();function eF(e,t,n){if(n&&e.length>=n.maxElements)throw new A(`array element limit exceeded (${n.maxElements})`,`array_elements`);e.push(t)}function tF(e,t){if(t&&O(e)>t.maxStringBytes)throw new A(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,`string_length`);let n=[],r=``,i=!1,a=!1,o=!1,s=!1;for(let c of e){if(o){r+=c,o=!1,s=!0;continue}if(c===`\\`){o=!0;continue}if(c===`'`&&!a){i||(s=!0),i=!i;continue}if(c===`"`&&!i){a||(s=!0),a=!a;continue}if((c===` `||c===` `||c===`
944
+ `)&&!i&&!a){s&&=(eF(n,r,t),r=``,!1);continue}r+=c,s=!0}return s&&eF(n,r,t),n}function nF(e,t){if(t&&O(e)>t.maxStringBytes)throw new A(`array assignment string limit exceeded (${t.maxStringBytes} bytes)`,`string_length`);let n=[],r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;if(e[r]!==`[`){r++;continue}r++;let i=``;if(e[r]===`'`||e[r]===`"`){let t=e[r];for(r++;r<e.length&&e[r]!==t;)i+=e[r],r++;e[r]===t&&r++}else for(;r<e.length&&e[r]!==`]`&&e[r]!==`=`;)i+=e[r],r++;for(;r<e.length&&e[r]!==`]`;)r++;if(e[r]===`]`&&r++,e[r]!==`=`)continue;r++;let a=``;if(e[r]===`'`||e[r]===`"`){let t=e[r];for(r++;r<e.length&&e[r]!==t;)e[r]===`\\`&&r+1<e.length&&r++,a+=e[r],r++;e[r]===t&&r++}else for(;r<e.length&&!/\s/.test(e[r]);)a+=e[r],r++;eF(n,[i,a],t)}return n}function rF(e,t){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(n)return{name:n[1],isArray:!0,arrayElements:tF(n[2],t)};let r=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(r)return{name:r[1],isArray:!1,arrayIndex:r[2],value:r[3]};if(e.includes(`=`)){let t=e.indexOf(`=`);return{name:e.slice(0,t),isArray:!1,value:e.slice(t+1)}}return{name:e,isArray:!1}}async function iF(e,t){try{return await rP(e,sO(new Tk,t).expression)}catch{let e=parseInt(t,10);return Number.isNaN(e)?0:e}}async function aF(e,t,n={}){let{name:r,isArray:i,arrayElements:a,value:o,arrayIndex:s}=t,{makeReadonly:c=!1,checkReadonly:l=!0}=n;if(l){let t=Ij(e,r);if(t)return t}if(i&&a){e.executionScope.consumeWork(a.length,`array assignment`);let t=tD(e,r),n=t?$E(t):void 0,i=e.state.env.get(r);try{dD(e,r);for(let t=0;t<a.length;t++)Y(e,r,t,a[t]);e.state.env.delete(r)}catch(t){throw e.state.arrays??=new Map,n?e.state.arrays.set(r,n):e.state.arrays.delete(r),i===void 0?e.state.env.delete(r):e.state.env.set(r,i),t}}else s!==void 0&&o!==void 0?Y(e,r,await iF(e,s),o):o!==void 0&&e.state.env.set(r,o);return c&&Pj(e,r),null}function oF(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function sF(e,t){return e.state.localVarDepth?.get(t)}function cF(e,t){e.state.localVarDepth?.delete(t)}function lF(e,t,n){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:n,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function uF(e,t){let n=e.state.localVarStack?.get(t);if(!(!n||n.length===0))return n.pop()}function dF(e,t){if(e.state.localVarStack)for(let[n,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(n)}}j();var fF=new Set([`:`,`.`,`break`,`continue`,`eval`,`exec`,`exit`,`export`,`readonly`,`return`,`set`,`shift`,`trap`,`unset`]);function pF(e){return fF.has(e)}var mF=new Set([`if`,`then`,`else`,`elif`,`fi`,`case`,`esac`,`for`,`select`,`while`,`until`,`do`,`done`,`in`,`function`,`{`,`}`,`time`,`[[`,`]]`,`!`]),hF=new Set(`:,true,false,cd,export,unset,exit,local,set,break,continue,return,eval,shift,getopts,compgen,complete,compopt,pushd,popd,dirs,source,.,read,mapfile,readarray,declare,typeset,readonly,let,command,shopt,exec,test,[,echo,printf,pwd,alias,unalias,type,hash,ulimit,umask,trap,times,wait,kill,jobs,fg,bg,disown,suspend,fc,history,help,enable,builtin,caller`.split(`,`));k(),j();var gF=`__file__:`,_F=`__file_append__:`,vF=`__rw__:`,yF=`__dupout__:`,bF=`__dupin__:`,xF=3;function SF(e){let t=e.slice(vF.length),n=t.indexOf(`:`);if(n===-1)return null;let r=Number.parseInt(t.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let i=n+1,a=t.slice(i,i+r),o=t.slice(i+r+1),s=o.indexOf(`:`);if(s===-1)return null;let c=Number.parseInt(o.slice(0,s),10);return Number.isNaN(c)||c<0?null:{path:a,position:c,content:o.slice(s+1)}}function CF(e,t){let n=Number.parseInt(e.slice(t.length),10);return Number.isNaN(n)?null:n}function wF(e){if(e.startsWith(gF))return{kind:`output`,path:e.slice(gF.length),append:!1};if(e.startsWith(_F))return{kind:`output`,path:e.slice(_F.length),append:!0};if(e.startsWith(vF)){let t=SF(e);if(t)return{kind:`readwrite`,...t}}if(e.startsWith(yF)){let t=CF(e,yF);if(t!==null)return{kind:`dup-out`,sourceFd:t}}if(e.startsWith(bF)){let t=CF(e,bF);if(t!==null)return{kind:`dup-in`,sourceFd:t}}return{kind:`input`,content:e}}function TF(e){switch(e.kind){case`input`:return e.content;case`output`:return`${e.append?_F:gF}${e.path}`;case`readwrite`:return`${vF}${e.path.length}:${e.path}:${e.position}:${e.content}`;case`dup-out`:return`${yF}${e.sourceFd}`;case`dup-in`:return`${bF}${e.sourceFd}`;case`closed`:throw Error(`Closed descriptors have no table encoding`)}}function EF(e){return e.state.fileDescriptors??=new Map,e.state.fileDescriptors}function DF(e,t,n){n?(e.state.inputFds??=new Set,e.state.inputFds.add(t)):e.state.inputFds?.delete(t)}function OF(e,t){return e.state.fdAliases?.get(t)}function kF(e,t){return[...OF(e,t)??[t]]}function AF(e,t){let n=OF(e,t);if(n&&(n.delete(t),e.state.fdAliases?.delete(t),n.size<2))for(let t of n)e.state.fdAliases?.delete(t)}function jF(e,t,n){if(t===n)return;e.state.fdAliases??=new Map;let r=OF(e,n)??new Set([n]);r.add(t);for(let t of r)e.state.fdAliases.set(t,r)}function MF(e,t){return e.state.fileDescriptors?.get(t)}function NF(e,t){let n=MF(e,t);if(n!==void 0)return e.state.inputFds?.has(t)?{kind:`input`,content:n}:wF(n)}function PF(e,t){return e.state.fileDescriptors?.has(t)===!0}function FF(e,t,n,r){let i=EF(e);i.has(t)||mP(e),i.set(t,n),DF(e,t,r)}function IF(e,t,n,r=!1){AF(e,t),FF(e,t,n,r)}function LF(e,t,n){IF(e,t,TF(n),n.kind===`input`)}function RF(e,t){e.state.fileDescriptors?.delete(t),e.state.inputFds?.delete(t),AF(e,t)}function zF(e,t,n){let r=MF(e,n);return r!==void 0&&(IF(e,t,r,e.state.inputFds?.has(n)===!0),jF(e,t,n),!0)}function BF(e,t,n){let r=MF(e,n);if(r===void 0)return!1;if(t===n)return!0;let i=e.state.inputFds?.has(n)===!0,a=[...OF(e,n)??[]].filter(e=>e!==n);RF(e,n),IF(e,t,r,i);let o=a.find(t=>PF(e,t));return o!==void 0&&jF(e,t,o),!0}function VF(e,t){let n=NF(e,t);if(n===void 0)return{error:`not-open`};switch(n.kind){case`input`:return{content:n.content};case`readwrite`:return{content:n.content.slice(n.position)};case`output`:case`dup-out`:return{error:`write-only`};case`dup-in`:return{error:`not-open`};case`closed`:return{error:`not-open`}}}function HF(e,t,n){let r=NF(e,t);if(r===void 0)return;let i;if(r.kind===`input`)i={kind:`input`,content:r.content.slice(n)};else if(r.kind===`readwrite`)i={...r,position:r.position+n};else return;let a=TF(i),o=i.kind===`input`;for(let n of OF(e,t)??[t])FF(e,n,a,o)}async function UF(e,t,n,r,i){if(t.kind===`output`)return await e.fs.appendFile(t.path,r,i),!0;let a=n.map(t=>NF(e,t)).find(e=>e?.kind===`readwrite`)??t;if(a.kind!==`readwrite`)return!1;let o=a.content.slice(0,a.position)+r+a.content.slice(a.position+r.length),s={...a,position:a.position+r.length,content:o};await e.fs.writeFile(a.path,o,i);let c=TF(s);for(let t of n)PF(e,t)&&FF(e,t,c,!1);return!0}function WF(e,t,n){if(t.has(n))return;let r=OF(e,n);t.set(n,{raw:MF(e,n),isInput:e.state.inputFds?.has(n)===!0,aliases:r?[...r].filter(e=>e!==n):[]})}function GF(e,t){let n=e.state.fileDescriptors;if(n)for(let[r,{raw:i,isInput:a,aliases:o}]of t){if(i===void 0){RF(e,r);continue}IF(e,r,i,a);let t=o.find(e=>n.has(e));t!==void 0&&jF(e,r,t)}}function KF(e){switch(e.operator){case`<`:case`<>`:case`<<`:case`<<-`:case`<<<`:case`<&`:return e.fd??0;case`>`:case`>>`:case`>|`:case`>&`:return e.fd??1;default:return null}}function qF(e){if(e.fdVariable)return!1;let t=KF(e);return t!==null&&t>=xF}async function JF(e,t,n,r){try{if(!await e.fs.exists(t))return null;if((await e.fs.stat(t)).isDirectory)return`bash: ${n}: Is a directory
945
+ `;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&n!==`/dev/null`)return`bash: ${n}: cannot overwrite existing file
946
+ `}catch{return`bash: ${n}: cannot open redirect target
947
+ `}return null}function YF(e){let t=Math.min(e.length,8192);for(let n=0;n<t;n++)if(e.charCodeAt(n)>127)return`utf8`;return`binary`}var XF=`scoped`,ZF=`bare`,QF=`persistent`,$F=e=>new A(`too many open file descriptors (max ${e.limits.maxFileDescriptors})`,`file_descriptors`),eI=(e,t)=>PF(e,t)||(e.state.fileDescriptors?.size??0)<e.limits.maxFileDescriptors,tI=e=>{let t=Math.max(e.state.nextFd??10,10);for(;PF(e,t);)t+=1;return t},nI=e=>{let t=e.endsWith(`-`),n=t?e.slice(0,-1):e;return/^\d+$/.test(n)?{sourceFd:Number.parseInt(n,10),move:t}:null},rI=(e,t,n)=>{let r=NF(e,t);return t<xF?r?{kind:`entry`,entry:r,descriptors:kF(e,t)}:{kind:`standard`,fd:t}:r?n?r.kind===`input`||r.kind===`readwrite`||r.kind===`dup-in`?{kind:`entry`,entry:r,descriptors:kF(e,t)}:null:r.kind===`output`||r.kind===`readwrite`||r.kind===`dup-out`?{kind:`entry`,entry:r,descriptors:kF(e,t)}:null:null};async function iI(e,t,n,r,i=!0){let a=e.fs.resolvePath(e.state.cwd,t),o=await JF(e,a,t,{checkNoclobber:!n,isClobber:r});if(o)return{error:$(``,o,1)};if(t===`/dev/full`)return{error:$(``,`bash: /dev/full: No space left on device
948
+ `,1)};if(t===`/dev/stdout`)return{entry:{kind:`dup-out`,sourceFd:1}};if(t===`/dev/stderr`)return{entry:{kind:`dup-out`,sourceFd:2}};try{n?await e.fs.appendFile(a,``,`binary`):await e.fs.writeFile(a,``,`binary`)}catch(e){if(!i)throw e;return{error:$(``,`bash: ${t}: cannot open redirect target
949
+ `,1)}}return{entry:{kind:`output`,path:a,append:n}}}async function aI(e,t,n){let r=e.fs.resolvePath(e.state.cwd,t);try{let t=await e.fs.readFile(r);return n?{entry:{kind:`readwrite`,path:r,position:0,content:t}}:{entry:{kind:`input`,content:t}}}catch{if(!n)return{error:$(``,`bash: ${t}: No such file or directory
950
+ `,1)};try{return await e.fs.writeFile(r,``,`binary`),{entry:{kind:`readwrite`,path:r,position:0,content:``}}}catch{return{error:$(``,`bash: ${t}: No such file or directory
951
+ `,1)}}}}var oI=async(e,t)=>{let n=await MN(e,t.content);return t.stripTabs?n.split(`
952
+ `).map(e=>e.replace(/^\t+/,``)).join(`
953
+ `):n};async function sI(e,t,n,r){let i=new Map,a=new Map,o=(t,n)=>e.state.closedStandardFds?.has(t)?{kind:`closed`}:NF(e,t)??n,s=new Map([[0,o(0,{kind:`dup-in`,sourceFd:0})],[1,o(1,{kind:`dup-out`,sourceFd:1})],[2,o(2,{kind:`dup-out`,sourceFd:2})]]),c=r.numericSnapshot,l,u=-1,d=s.get(0);d?.kind===`input`?(l=d.content,u=0):d?.kind===`readwrite`&&(l=d.content.slice(d.position),u=0);let f=()=>({targets:i,dupSources:a,standardRoutes:s,stdin:l,stdinSourceFd:u,error:null}),p=async(n,r,o)=>{let c={...f(),error:await fI(e,n,t.slice(0,r),i,a,s)};return o?{...c,errorCause:o}:c},m=async(t,n)=>{if(eI(e,t))return null;let r=$F(e);return p($(``,r.stderr,A.EXIT_CODE),n,r)},h=(t,n)=>{t!==null&&t<xF&&s.set(t,n),r.policy===`persistent`&&t!==null&&t<xF&&(e.state.closedStandardFds?.delete(t),LF(e,t,n))},g=(t,n)=>{s.set(t,n),WF(e,r.standardSnapshot,t),r.standardClosedSnapshot.has(t)||r.standardClosedSnapshot.set(t,e.state.closedStandardFds?.has(t)===!0),e.state.closedStandardFds?.delete(t),LF(e,t,n)},_=(t,n)=>{if(t<xF){let n=s.get(t);return n?.kind===`closed`?null:n?{kind:`entry`,entry:n,descriptors:kF(e,t)}:{kind:`standard`,fd:t}}return rI(e,t,n)};for(let o=0;o<t.length;o++){let d=t[o],f=KF(d);if(d.target.type===`HereDoc`){let t=await oI(e,d.target);if(d.fdVariable){try{Ij(e,d.fdVariable)}catch(e){if(!(e instanceof wr))throw e;return p($(e.stdout,e.stderr,e.exitCode),o,e)}let n=tI(e),i=await m(n,o);if(i)return i;WF(e,r.fdVariableSnapshot,n),r.fdVariableEnv.has(d.fdVariable)||r.fdVariableEnv.set(d.fdVariable,e.state.env.get(d.fdVariable)),LF(e,n,{kind:`input`,content:t}),e.state.env.set(d.fdVariable,String(n)),e.state.nextFd=n+1}else if(f!==null&&f>=xF){let n=await m(f,o);if(n)return n;WF(e,c,f),LF(e,f,{kind:`input`,content:t})}else if(f===0||f===null)l=sr(t),u=-1,h(f,{kind:`input`,content:l});else{let e={kind:`input`,content:t};r.policy===`persistent`?h(f,e):g(f,e)}continue}let v,y=d.operator===`>&`||d.operator===`<&`;if(y){if(UN(e,d.target))return p($(``,`bash: $@: ambiguous redirect
954
+ `,1),o);v=await MN(e,d.target)}else if(d.operator===`<<<`)v=await MN(e,d.target);else{let t=await WN(e,d.target);if(`error`in t)return p($(``,t.error,1),o);v=t.target}if(i.set(o,v),v.includes(`\0`))return p($(``,`bash: ${v.replace(/\0/g,``)}: No such file or directory
955
+ `,1),o);if(d.fdVariable){try{Ij(e,d.fdVariable)}catch(e){if(!(e instanceof wr))throw e;return p($(e.stdout,e.stderr,e.exitCode),o,e)}if(y&&v===`-`){let t=Number.parseInt(e.state.env.get(d.fdVariable)??``,10);Number.isNaN(t)||(WF(e,r.fdVariableSnapshot,t),RF(e,t));continue}let t=tI(e),n=y?nI(v):null;if(n&&!_(n.sourceFd,d.operator===`<&`))return p($(``,`bash: ${n.sourceFd}: Bad file descriptor
956
+ `,1),o);if(!(n?.move===!0&&n.sourceFd>=xF)){let e=await m(t,o);if(e)return e}WF(e,r.fdVariableSnapshot,t),r.fdVariableEnv.has(d.fdVariable)||r.fdVariableEnv.set(d.fdVariable,e.state.env.get(d.fdVariable));let i,a;if(y){let t=n;if(t){let e=_(t.sourceFd,d.operator===`<&`);if(!e)return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
957
+ `,1),o);a=t,e.kind===`standard`?i={kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:e.fd}:t.sourceFd<xF&&(i=e.entry)}else{if(d.operator===`<&`)return p($(``,`bash: ${v}: ambiguous redirect
958
+ `,1),o);let t=await iI(e,v,!1,!1);if(t.error)return p(t.error,o);i=t.entry}}else if(d.operator===`>`||d.operator===`>|`||d.operator===`>>`||d.operator===`&>`||d.operator===`&>>`){let t=d.operator===`>>`||d.operator===`&>>`,n=await iI(e,v,t,d.operator===`>|`);if(n.error)return p(n.error,o);i=n.entry}else if(d.operator===`<<<`)i={kind:`input`,content:`${v}
959
+ `};else if(d.operator===`<`||d.operator===`<>`){let t=await aI(e,v,d.operator===`<>`);if(t.error)return p(t.error,o);i=t.entry}if(a&&a.sourceFd>=xF){if(!(a.move?BF(e,t,a.sourceFd):zF(e,t,a.sourceFd)))return p($(``,`bash: ${a.sourceFd}: Bad file descriptor
960
+ `,1),o)}else i&&LF(e,t,i);a?.move&&a.sourceFd!==t&&a.sourceFd<xF&&RF(e,a.sourceFd),e.state.env.set(d.fdVariable,String(t)),e.state.nextFd=t+1;continue}if(qF(d)){let t=f;if(y&&v===`-`){WF(e,c,t),RF(e,t);continue}let n=y?nI(v):null;if(n&&!_(n.sourceFd,d.operator===`<&`))return p($(``,`bash: ${n.sourceFd}: Bad file descriptor
961
+ `,1),o);if(!(n?.move===!0&&n.sourceFd>=xF)){let e=await m(t,o);if(e)return e}if(WF(e,c,t),y){let r=n;if(!r){if(d.operator===`<&`)return p($(``,`bash: ${v}: ambiguous redirect
962
+ `,1),o);let n=await iI(e,v,!1,!1);if(n.error)return p(n.error,o);LF(e,t,n.entry);continue}let i=_(r.sourceFd,d.operator===`<&`);if(!i)return p($(``,`bash: ${r.sourceFd}: Bad file descriptor
963
+ `,1),o);if(i.kind===`standard`)LF(e,t,{kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:i.fd});else if(r.sourceFd<xF)LF(e,t,i.entry);else if(!(r.move?BF(e,t,r.sourceFd):zF(e,t,r.sourceFd)))return p($(``,`bash: ${r.sourceFd}: Bad file descriptor
964
+ `,1),o);r.move&&r.sourceFd!==t&&r.sourceFd<xF&&RF(e,r.sourceFd);continue}if(d.operator===`>`||d.operator===`>|`||d.operator===`>>`){let n=await iI(e,v,d.operator===`>>`,d.operator===`>|`);if(n.error)return p(n.error,o);LF(e,t,n.entry)}else if(d.operator===`<<<`)LF(e,t,{kind:`input`,content:`${v}
965
+ `});else if(d.operator===`<`||d.operator===`<>`){let n=await aI(e,v,d.operator===`<>`);if(n.error)return p(n.error,o);LF(e,t,n.entry)}continue}if(y){if(v===`-`){f===0&&(l=``,u=-1),f!==null&&f<xF&&(s.set(f,{kind:`closed`}),r.policy===`persistent`&&(RF(e,f),e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(f)));continue}let t=nI(v);if(!t){if(d.operator===`<&`)return p($(``,`bash: ${v}: ambiguous redirect
966
+ `,1),o);let t=await iI(e,v,!1,!1,!1);if(t.error)return p(t.error,o);let n=t.entry;a.set(o,{kind:`entry`,entry:n,descriptors:[]}),d.fd==null?(h(1,n),h(2,n)):h(f,n);continue}let i=_(t.sourceFd,d.operator===`<&`);if(!i)return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
967
+ `,1),o);if(a.set(o,i),i.kind===`entry`&&r.policy===`persistent`&&f!==null&&f<xF&&t.sourceFd>=xF){if(!zF(e,f,t.sourceFd))return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
968
+ `,1),o);s.set(f,NF(e,f)),e.state.closedStandardFds?.delete(f)}else i.kind===`standard`?h(f,{kind:d.operator===`<&`?`dup-in`:`dup-out`,sourceFd:i.fd}):h(f,i.entry);if(d.operator===`<&`&&f===0)if(i.kind===`standard`)l=i.fd===0?n:``,u=-1;else if(i.entry.kind===`input`||i.entry.kind===`readwrite`){let n=t.sourceFd<xF&&!PF(e,t.sourceFd)?{content:i.entry.kind===`input`?i.entry.content:i.entry.content.slice(i.entry.position)}:VF(e,t.sourceFd);if(`error`in n)return p($(``,`bash: ${t.sourceFd}: Bad file descriptor
969
+ `,1),o);l=n.content,u=PF(e,t.sourceFd)?t.sourceFd:-1}else l=n,u=-1;t.move&&(t.sourceFd>=xF?RF(e,t.sourceFd):(s.set(t.sourceFd,{kind:`closed`}),r.policy===`persistent`&&(RF(e,t.sourceFd),e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(t.sourceFd))));continue}if(d.operator===`>`||d.operator===`>|`||d.operator===`>>`||d.operator===`&>`||d.operator===`&>>`){let t=await iI(e,v,d.operator===`>>`||d.operator===`&>>`,d.operator===`>|`,!1);if(t.error)return p(t.error,o);let n=t.entry;d.operator===`&>`||d.operator===`&>>`?(h(1,n),h(2,n)):h(f,n);continue}if(d.operator===`<<<`)l=sr(`${v}
970
+ `),u=-1,h(f,{kind:`input`,content:l});else if(d.operator===`<`){let t=e.fs.resolvePath(e.state.cwd,v);try{l=await lr(e.fs,t),u=-1,h(f,{kind:`input`,content:l})}catch{return p($(``,`bash: ${v}: No such file or directory
971
+ `,1),o)}}else if(d.operator===`<>`){let t=await aI(e,v,!0);if(t.error)return p(t.error,o);let n=t.entry;h(f,n),f===0&&n.kind===`readwrite`&&(l=n.content,u=-1)}}return f()}function cI(e,t,n){let r={numericSnapshot:new Map,fdVariableSnapshot:new Map,standardSnapshot:new Map,standardClosedSnapshot:new Map,fdVariableEnv:new Map,nextFd:e.state.nextFd,policy:n},i=!1;return{prepare:(n=``)=>sI(e,t,n,r),finish:()=>{if(!i){if(i=!0,n!==`persistent`&&GF(e,r.numericSnapshot),n!==`persistent`){GF(e,r.standardSnapshot);for(let[t,n]of r.standardClosedSnapshot)n?(e.state.closedStandardFds??=new Set,e.state.closedStandardFds.add(t)):e.state.closedStandardFds?.delete(t)}if(n===`bare`){GF(e,r.fdVariableSnapshot);for(let[t,n]of r.fdVariableEnv)n===void 0?e.state.env.delete(t):e.state.env.set(t,n);e.state.nextFd=r.nextFd}}}}}function lI(e){if(!e.error)throw Error(`Expected a redirection error`);if(e.errorCause)throw e.errorCause.stdout=e.error.stdout,e.errorCause.stderr=e.error.stderr,e.errorCause;return e.error}async function uI(e,t,n,r){let i=t instanceof wr||t instanceof xr||t instanceof Sr?t.exitCode:t instanceof A?A.EXIT_CODE:0,a=await fI(e,$(t.stdout,t.stderr,i),n,r.targets,r.dupSources,r.standardRoutes);t.stdout=a.stdout,t.stderr=a.stderr,t.internalOutputAccounting=a.internalOutputAccounting??{stdout:O(a.stdout),stderr:O(a.stderr)}}async function dI(e,t,n,r){let i=cI(e,t,XF),a;try{if(a=await i.prepare(n),a.error)return lI(a);let o=e.state.groupStdin,s=e.state.groupStdinSourceFd;a.stdin!==void 0&&(e.state.groupStdin=a.stdin,e.state.groupStdinSourceFd=a.stdinSourceFd);try{return await fI(e,await r(a),t,a.targets,a.dupSources,a.standardRoutes)}finally{a.stdin!==void 0&&(e.state.groupStdin=o,e.state.groupStdinSourceFd=s)}}catch(n){throw!(n instanceof vr)||!a||await uI(e,n,t,a),n}finally{i.finish()}}async function fI(e,t,n,r,i=new Map,a=new Map,o=`bash`,s=!1){n.length>0&&(t=e.executionScope.accountResult(t,`redirection`));let{stdout:c,stderr:l,exitCode:u}=t,d=t.stdoutKind===`bytes`||t.stdoutKind===void 0&&t.stdoutEncoding===`binary`?`binary`:`utf8`,f=e=>d,p={kind:`live-stdout`},m={kind:`live-stderr`},h=e=>{if(!e)return null;if(e.kind===`entry`){if(e.entry.kind===`dup-out`){if(e.entry.sourceFd===1)return{kind:`live-stdout`};if(e.entry.sourceFd===2)return{kind:`live-stderr`}}return e.entry.kind===`output`||e.entry.kind===`readwrite`?{kind:`descriptor`,source:e}:null}return e.fd===1?p:e.fd===2?m:null},g=t=>{let n=a.get(t)??NF(e,t);return n?n.kind===`closed`||n.kind===`input`||n.kind===`dup-in`?{kind:`invalid-output`,fd:t}:n.kind===`dup-out`?n.sourceFd===1?{kind:`live-stdout`}:n.sourceFd===2?{kind:`live-stderr`}:null:n.kind===`output`||n.kind===`readwrite`?{kind:`descriptor`,source:{kind:`entry`,entry:n,descriptors:kF(e,t)}}:null:null};p=g(1)??p,m=g(2)??m;for(let t=0;t<n.length;t++){let a=n[t];if(a.target.type===`HereDoc`||a.fdVariable)continue;let o=r.get(t);if(o!==void 0)switch(a.operator){case`>`:case`>|`:case`>>`:{let t=a.fd??1;if(t!==1&&t!==2)break;let n=a.operator===`>>`;if(o===`/dev/stdout`){t===2&&(m=p);break}if(o===`/dev/stderr`){t===1&&(p=m);break}if(o===`/dev/full`){l+=`bash: echo: write error: No space left on device
972
+ `,u=1,t===1&&(c=``);break}if(o===`/dev/null`&&t===2){m={kind:`discard`};break}let r=e.fs.resolvePath(e.state.cwd,o);t===1?p={kind:`file`,path:r,append:n}:m={kind:`file`,path:r,append:n};break}case`>&`:case`<&`:{let e=a.fd??(a.operator===`<&`?0:1);if(e>=xF||e===0)break;if(o===`-`){e===1?p={kind:`discard`}:m={kind:`discard`};break}let n=h(i.get(t));if(!n)break;a.fd==null&&nI(o)===null?(p=n,m=n):e===1?p=n:e===2&&(m=n);break}case`&>`:p={kind:`file`,path:e.fs.resolvePath(e.state.cwd,o),append:!1},m=p;break;case`&>>`:p={kind:`file`,path:e.fs.resolvePath(e.state.cwd,o),append:!0},m=p;break}}if(c!==``||l!==``){let t=c,n=l;c=``,l=``,p.kind===`invalid-output`&&t!==``&&(t=``,n+=`${s?``:`bash: `}${o}: write error: Bad file descriptor
973
+ `,u=1),m.kind===`invalid-output`&&(n=``);let r=async(t,n,r)=>{t.append?await e.fs.appendFile(t.path,n,r):await e.fs.writeFile(t.path,n,r)};if(p===m&&(p.kind===`file`||p.kind===`descriptor`)){let i=t+n;i!==``&&(p.kind===`file`?await r(p,i,f(i)):await UF(e,p.source.entry,p.source.descriptors,i,f(i)))}else for(let[i,a,o]of[[t,p,!0],[n,m,!1]])if(i!==``)switch(a.kind){case`live-stdout`:c+=i;break;case`live-stderr`:l+=i;break;case`file`:await r(a,i,o?f(i):YF(i));break;case`descriptor`:await UF(e,a.source.entry,a.source.descriptors,i,o?f(i):YF(i));break;case`invalid-output`:break;case`discard`:break}}let _=$(c,l,u);if(t.stdoutKind&&(_.stdoutKind=t.stdoutKind),t.stdoutEncoding===`binary`&&(_.stdoutEncoding=`binary`),t.internalPipeStatusOverride&&(_.internalPipeStatusOverride=t.internalPipeStatusOverride),n.length>0||e.state.fileDescriptors?.has(1)===!0||e.state.fileDescriptors?.has(2)===!0){let n=(t.internalOutputAccounting?.stdout??0)+(t.internalOutputAccounting?.stderr??0),r=O(_.stdout),i=O(_.stderr),a=Math.min(r,n);_.internalOutputAccounting={stdout:a,stderr:Math.min(i,n-a)},e.executionScope.accountResult(_,`redirection`)}else t.internalOutputAccounting&&(_.internalOutputAccounting=t.internalOutputAccounting);return _}function pI(e,t){if(e.state.options.posix&&fF.has(t.name)){let n=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin
974
+ `;throw new wr(2,``,n)}let n={...t,sourceFile:t.sourceFile??e.state.currentSource??`main`};return e.state.functions.set(t.name,n),uP}async function mI(e,t,n,r=``,i,a=!1){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,pP(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,`recursion`)),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(i??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??`main`),e.state.localScopes.push(new Map),e.state.localArrayScopes??=[],e.state.localArrayScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let o=new Map,s=Number.parseInt(e.state.env.get(`#`)??`0`,10),c=Math.max(n.length,s);for(let t=0;t<c;t++){let r=String(t+1);o.set(r,e.state.env.get(r)),t<n.length?e.state.env.set(r,n[t]):e.state.env.delete(r)}o.set(`@`,e.state.env.get(`@`)),o.set(`#`,e.state.env.get(`#`)),e.state.env.set(`@`,n.join(` `)),e.state.env.set(`#`,String(n.length));let l=!1,u=()=>{if(l)return;l=!0;let t=e.state.localScopes.length-1,n=e.state.localScopes.pop(),r=e.state.localArrayScopes?.pop();if(n)for(let[t,r]of n)r===void 0?e.state.env.delete(t):e.state.env.set(t,r);if(r){e.state.arrays??=new Map;for(let[t,n]of r)n===void 0?(e.state.arrays.delete(t),e.state.associativeArrays?.delete(t)):(e.state.arrays.set(t,$E(n)),e.state.associativeArrays??=new Set,n.kind===`associative`?e.state.associativeArrays.add(t):e.state.associativeArrays.delete(t))}if(dF(e,t),e.state.fullyUnsetLocals)for(let[n,r]of e.state.fullyUnsetLocals.entries())r===t&&e.state.fullyUnsetLocals.delete(n);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let t=e.state.localExportedVars.pop();if(t)for(let n of t)e.state.exportedVars?.delete(n)}for(let[t,n]of o)n===void 0?e.state.env.delete(t):e.state.env.set(t,n);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},d=null,f=cI(e,t.redirections,XF);try{if(d=await f.prepare(r),d.error)return lI(d);let n=d.stdin??r,i=a||d.stdin!==void 0||r!==``;return fI(e,await e.executeCommand(t.body,n,i),t.redirections,d.targets,d.dupSources,d.standardRoutes)}catch(n){if(n instanceof vr&&d&&(await uI(e,n,t.redirections,d),n instanceof xr))return $(n.stdout,n.stderr,n.exitCode);throw n}finally{f.finish(),u()}}var hI=e=>e.type===`Escaped`?X.literal(`\\${e.value}`):e.type===`DoubleQuoted`?{...e,parts:e.parts.map(hI)}:e,gI=[`!`,`[[`,`]]`,`case`,`do`,`done`,`elif`,`else`,`esac`,`fi`,`for`,`function`,`if`,`in`,`then`,`time`,`until`,`while`,`{`,`}`],_I=`.,:,[,alias,bg,bind,break,builtin,caller,cd,command,compgen,complete,compopt,continue,declare,dirs,disown,echo,enable,eval,exec,exit,export,false,fc,fg,getopts,hash,help,history,jobs,kill,let,local,logout,mapfile,popd,printf,pushd,pwd,read,readarray,readonly,return,set,shift,shopt,source,suspend,test,times,trap,true,type,typeset,ulimit,umask,unalias,unset,wait`.split(`,`),vI=`autocd.assoc_expand_once.cdable_vars.cdspell.checkhash.checkjobs.checkwinsize.cmdhist.compat31.compat32.compat40.compat41.compat42.compat43.compat44.complete_fullquote.direxpand.dirspell.dotglob.execfail.expand_aliases.extdebug.extglob.extquote.failglob.force_fignore.globasciiranges.globstar.gnu_errfmt.histappend.histreedit.histverify.hostcomplete.huponexit.inherit_errexit.interactive_comments.lastpipe.lithist.localvar_inherit.localvar_unset.login_shell.mailwarn.no_empty_cmd_completion.nocaseglob.nocasematch.nullglob.progcomp.progcomp_alias.promptvars.restricted_shell.shift_verbose.sourcepath.xpg_echo`.split(`.`),yI=_I;async function bI(e,t){let n=[],r=null,i=``,a=``,o=null,s=!1,c=!1,l=!1,u=null,d=null,f=null,p=[],m=[`alias`,`arrayvar`,`binding`,`builtin`,`command`,`directory`,`disabled`,`enabled`,`export`,`file`,`function`,`group`,`helptopic`,`hostname`,`job`,`keyword`,`running`,`service`,`setopt`,`shopt`,`signal`,`stopped`,`user`,`variable`];for(let e=0;e<t.length;e++){let o=t[e];if(o===`-v`)n.push(`variable`);else if(o===`-e`)n.push(`export`);else if(o===`-f`)n.push(`file`);else if(o===`-d`)n.push(`directory`);else if(o===`-k`)n.push(`keyword`);else if(o===`-A`){if(e++,e>=t.length)return Q(`compgen: -A: option requires an argument
975
+ `,2);let r=t[e];if(!m.includes(r))return Q(`compgen: ${r}: invalid action name
976
+ `,2);n.push(r)}else if(o===`-W`){if(e++,e>=t.length)return Q(`compgen: -W: option requires an argument
977
+ `,2);r=t[e]}else if(o===`-P`){if(e++,e>=t.length)return Q(`compgen: -P: option requires an argument
978
+ `,2);i=t[e]}else if(o===`-S`){if(e++,e>=t.length)return Q(`compgen: -S: option requires an argument
979
+ `,2);a=t[e]}else if(o===`-o`){if(e++,e>=t.length)return Q(`compgen: -o: option requires an argument
980
+ `,2);let n=t[e];if(n===`plusdirs`)s=!0;else if(n===`dirnames`)c=!0;else if(n==="default")l=!0;else if(n!==`filenames`&&n!==`nospace`&&n!==`bashdefault`&&n!==`noquote`)return Q(`compgen: ${n}: invalid option name
981
+ `,2)}else if(o===`-F`){if(e++,e>=t.length)return Q(`compgen: -F: option requires an argument
982
+ `,2);d=t[e]}else if(o===`-C`){if(e++,e>=t.length)return Q(`compgen: -C: option requires an argument
983
+ `,2);f=t[e]}else if(o===`-X`){if(e++,e>=t.length)return Q(`compgen: -X: option requires an argument
984
+ `,2);u=t[e]}else if(o===`-G`){if(e++,e>=t.length)return Q(`compgen: -G: option requires an argument
985
+ `,2)}else if(o===`--`){p.push(...t.slice(e+1));break}else o.startsWith(`-`)||p.push(o)}o=p[0]??null;let h=[],g=new Set,_=()=>e.limits.maxArrayElements-h.length,v=t=>{for(let n of t){if(h.length>=e.limits.maxArrayElements)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(O(n)>e.limits.maxStringLength)throw new A(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);e.executionScope.consumeWork(1,`compgen completion`),h.push(n),g.add(n)}};c&&v(await kI(e,o,_())),l&&v(await AI(e,o,_()));for(let t of n)t===`variable`?v(xI(e,o,_())):t===`export`?v(SI(e,o,_())):t===`function`?v(CI(e,o,_())):t===`builtin`?v(wI(e,o,_())):t===`keyword`?v(TI(e,o,_())):t===`alias`?v(EI(e,o,_())):t===`shopt`?v(DI(e,o,_())):t===`helptopic`?v(OI(e,o,_())):t===`directory`?v(await kI(e,o,_())):t===`file`?v(await AI(e,o,_())):t===`user`?v(jI(e,o,_())):t===`command`&&v(await MI(e,o,_()));if(r!==null)try{let t=FI(e,await PI(e,r),_(),o);for(let e of t)v([e])}catch(e){if(e instanceof A)throw e;return $(``,``,1)}if(s){let t=await kI(e,o,_(),g);for(let e of t)g.has(e)||v([e])}let y=``;if(d!==null){let t=e.state.functions.get(d);if(t){let n=new Map,r=tD(e,`COMP_WORDS`),i=r?$E(r):void 0;dD(e,`COMP_WORDS`),nD(e,`COMP_WORDS`),n.set(`COMP_CWORD`,e.state.env.get(`COMP_CWORD`)),e.state.env.set(`COMP_CWORD`,`-1`),n.set(`COMP_LINE`,e.state.env.get(`COMP_LINE`)),e.state.env.set(`COMP_LINE`,``),n.set(`COMP_POINT`,e.state.env.get(`COMP_POINT`)),e.state.env.set(`COMP_POINT`,`0`);let a=tD(e,`COMPREPLY`),o=a?$E(a):void 0,s=e.state.env.get(`COMPREPLY`);dD(e,`COMPREPLY`),e.state.env.delete(`COMPREPLY`);let c=[`compgen`,p[0]??``,``];try{let r=await mI(e,t,c,``);if(r.exitCode!==0)return II(e,n),LI(e,`COMP_WORDS`,i),LI(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s),$(``,r.stderr,1);y=r.stdout,v(RI(e,_()))}catch(t){if(t instanceof A)throw t;return II(e,n),LI(e,`COMP_WORDS`,i),LI(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s),$(``,``,1)}II(e,n),LI(e,`COMP_WORDS`,i),LI(e,`COMPREPLY`,o),s!==void 0&&e.state.env.set(`COMPREPLY`,s)}}if(f!==null)try{let t=Ek(f),n=await e.executeScript(t);if(n.exitCode!==0)return $(``,n.stderr,n.exitCode);if(n.stdout)for(let e of zI(n.stdout))e.length>0&&v([e])}catch(e){if(e.name===`ParseException`)return Q(`compgen: -C: ${e.message}
986
+ `,2);throw e}let b=h;if(u!==null){let t=u.startsWith(`!`),n=t?u.slice(1):u;b=h.filter(r=>{let i=BP(r,n,!1,!0,e.limits.maxCallDepth);return t?i:!i})}if(b.length===0&&o!==null)return $(y,``,1);let x=new Ui(e.limits.maxOutputSize,`compgen`);x.append(y);for(let e of b)x.append(i).append(e).append(a).append(`
987
+ `);return dP(x.build())}function xI(e,t,n){let r=NI(e,t,n);for(let t of e.state.env.keys())/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&r.add(t);for(let t of e.state.arrays?.keys()??[])r.add(t);return r.build()}function SI(e,t,n){let r=NI(e,t,n),i=e.state.exportedVars??new Set;for(let t of i)e.state.env.has(t)&&r.add(t);return r.build()}function CI(e,t,n){let r=NI(e,t,n);for(let t of e.state.functions.keys())r.add(t);return r.build()}function wI(e,t,n){let r=NI(e,t,n);for(let e of _I)r.add(e);return r.build()}function TI(e,t,n){let r=NI(e,t,n);for(let e of gI)r.add(e);return r.build()}function EI(e,t,n){let r=NI(e,t,n);for(let t of e.state.env.keys())if(t.startsWith(`BASH_ALIAS_`)){let e=t.slice(11);r.add(e)}return r.build()}function DI(e,t,n){let r=NI(e,t,n);for(let e of vI)r.add(e);return r.build()}function OI(e,t,n){let r=NI(e,t,n);for(let e of yI)r.add(e);return r.build()}async function kI(e,t,n=e.limits.maxArrayElements,r){let i=NI(e,null,n,r);try{let n=e.state.cwd,r=t??``;if(t){let i=t.lastIndexOf(`/`);if(i!==-1){let a=t.slice(0,i)||`/`;r=t.slice(i+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let o of a){e.executionScope.consumeWork(1,`compgen directory scan`);let a=`${n}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!r||o.startsWith(r)))if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),n=t.slice(0,e+1);i.add(n+o)}else i.add(o)}catch(e){if(e instanceof A)throw e}}}catch(e){if(e instanceof A)throw e}return i.build()}async function AI(e,t,n=e.limits.maxArrayElements){let r=NI(e,null,n);try{let n=e.state.cwd,i=t??``;if(t){let r=t.lastIndexOf(`/`);if(r!==-1){let a=t.slice(0,r)||`/`;i=t.slice(r+1),n=a.startsWith(`/`)?a:`${e.state.cwd}/${a}`}}let a=await e.fs.readdir(n);for(let n of a)if(e.executionScope.consumeWork(1,`compgen file scan`),!i||n.startsWith(i))if(t?.includes(`/`)){let e=t.lastIndexOf(`/`),i=t.slice(0,e+1);r.add(i+n)}else r.add(n)}catch(e){if(e instanceof A)throw e}return r.build()}function jI(e,t,n){let r=NI(e,t,n);return r.add(`root`),r.add(`nobody`),r.build()}async function MI(e,t,n){let r=NI(e,t,n);for(let e of _I)r.add(e);for(let t of e.state.functions.keys())r.add(t);for(let t of e.state.env.keys())t.startsWith(`BASH_ALIAS_`)&&r.add(t.slice(11));for(let e of gI)r.add(e);let i=e.state.env.get(`PATH`)??`/usr/bin:/bin`;for(let t of i.split(`:`))if(t)try{let n=await e.fs.readdir(t);for(let e of n)r.add(e)}catch(e){if(e instanceof A)throw e}return r.build()}function NI(e,t,n,r){let i=new Set;return{add(a){if(e.executionScope.consumeWork(1,`compgen candidate collection`),!(t!==null&&!a.startsWith(t))&&!r?.has(a)&&!i.has(a)){if(i.size>=n)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);if(O(a)>e.limits.maxStringLength)throw new A(`compgen: completion string limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);i.add(a)}},build(){return Array.from(i).sort()}}}async function PI(e,t){let n=new Tk().parseWordFromString(t,!1,!1);return await MN(e,X.word(n.parts.map(hI)))}function FI(e,t,n,r){let i=e.state.env.get(`IFS`)??`
988
+ `;if(i.length===0){if(r!==null&&!t.startsWith(r))return[];if(n===0)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);return[t]}let a=new Set(i.split(``)),o=[],s=t=>{if(!(r!==null&&!t.startsWith(r))){if(o.length>=n)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);o.push(t)}},c=``,l=0;for(;l<t.length;){let e=t[l];if(e===`\\`&&l+1<t.length){let e=t[l+1];c+=e,l+=2}else a.has(e)?(c.length>0&&(s(c),c=``),l++):(c+=e,l++)}return c.length>0&&s(c),o}function II(e,t){for(let[n,r]of t)r===void 0?e.state.env.delete(n):e.state.env.set(n,r)}function LI(e,t,n){e.state.arrays??=new Map,n?e.state.arrays.set(t,$E(n)):e.state.arrays.delete(t)}function RI(e,t){let n=[],r=r=>{if(n.length>=t)throw new A(`compgen: completion element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);n.push(r)};if(iD(e,`COMPREPLY`)){let t=nj(e,`COMPREPLY`);for(let[,e]of t)r(e)}else{let t=e.state.env.get(`COMPREPLY`);t!==void 0&&r(t)}return n}function*zI(e){let t=0;for(;t<=e.length;){let n=e.indexOf(`
989
+ `,t),r=n===-1?e.length:n;if(r>t&&(yield e.slice(t,r)),n===-1)return;t=n+1}}k();function BI(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!0}return!1}function VI(e){let t=`$'`;for(let n=0;n<e.length;n++){let r=e[n],i=e.charCodeAt(n);t+=i===7?`\\a`:i===8?`\\b`:i===9?`\\t`:i===10?`\\n`:i===11?`\\v`:i===12?`\\f`:i===13?`\\r`:i===27?`\\e`:i===39?`\\'`:i===92?`\\\\`:i<32||i===127?`\\${i.toString(8).padStart(3,`0`)}`:r}return t+=`'`,t}function HI(e){if(BI(e))return KI(e);if(e===``)return 2;if(/^[a-zA-Z0-9_/.:\-@%+,=]+$/.test(e))return O(e);let t=O(e)+2;for(let n of e)n===`'`&&(t+=3);return t}function UI(e){return BI(e)?VI(e):e===``?`''`:/^[a-zA-Z0-9_/.:\-@%+,=]+$/.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function WI(e){if(BI(e))return KI(e);let t=O(e)+2;for(let n of e)(n===`\\`||n===`"`||n===`$`||n==="`")&&t++;return t}function GI(e){return BI(e)?VI(e):`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}"`}function KI(e){let t=3;for(let n of e){let e=n.codePointAt(0)??0;t+=e===7||e===8||e===9||e===10||e===11||e===12||e===13||e===27||e===39||e===92?2:e<32||e===127?4:O(n)}return t}function qI(e){return BI(e)?VI(e):`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}"`}var JI=[`bashdefault`,`default`,`dirnames`,`filenames`,`noquote`,`nosort`,`nospace`,`plusdirs`];function YI(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let n=!1,r=!1,i=!1,a,o,s,c=[],l=[],u=[];for(let e=0;e<t.length;e++){let d=t[e];if(d===`-p`)n=!0;else if(d===`-r`)r=!0;else if(d===`-D`)i=!0;else if(d===`-W`){if(e++,e>=t.length)return Q(`complete: -W: option requires an argument
990
+ `,2);a=t[e]}else if(d===`-F`){if(e++,e>=t.length)return Q(`complete: -F: option requires an argument
991
+ `,2);o=t[e]}else if(d===`-o`){if(e++,e>=t.length)return Q(`complete: -o: option requires an argument
992
+ `,2);let n=t[e];if(!JI.includes(n))return Q(`complete: ${n}: invalid option name
993
+ `,2);c.push(n)}else if(d===`-A`){if(e++,e>=t.length)return Q(`complete: -A: option requires an argument
994
+ `,2);l.push(t[e])}else if(d===`-C`){if(e++,e>=t.length)return Q(`complete: -C: option requires an argument
995
+ `,2);s=t[e]}else if(d===`-G`){if(e++,e>=t.length)return Q(`complete: -G: option requires an argument
996
+ `,2)}else if(d===`-P`){if(e++,e>=t.length)return Q(`complete: -P: option requires an argument
997
+ `,2)}else if(d===`-S`){if(e++,e>=t.length)return Q(`complete: -S: option requires an argument
998
+ `,2)}else if(d===`-X`){if(e++,e>=t.length)return Q(`complete: -X: option requires an argument
999
+ `,2)}else if(d===`--`){u.push(...t.slice(e+1));break}else d.startsWith(`-`)||u.push(d)}if(r){if(u.length===0)return e.state.completionSpecs.clear(),e.state.defaultCompletionSpec=void 0,e.state.emptyCompletionSpec=void 0,dP(``);for(let t of u)e.state.completionSpecs.delete(t);return dP(``)}if(n)return u.length===0?XI(e):XI(e,u);if(t.length===0||u.length===0&&!a&&!o&&!s&&c.length===0&&l.length===0&&!i)return XI(e);if(o&&u.length===0&&!i)return Q(`complete: -F: option requires a command name
1000
+ `,2);if(i){let t={isDefault:!0};return a!==void 0&&(t.wordlist=a),o!==void 0&&(t.function=o),s!==void 0&&(t.command=s),c.length>0&&(t.options=c),l.length>0&&(t.actions=l),e.state.defaultCompletionSpec=t,dP(``)}for(let t of u){let n=Object.create(null);a!==void 0&&(n.wordlist=a),o!==void 0&&(n.function=o),s!==void 0&&(n.command=s),c.length>0&&(n.options=c),l.length>0&&(n.actions=l),e.state.completionSpecs.set(t,n)}return dP(``)}function XI(e,t){let n=e.state.completionSpecs??new Map;if(n.size===0&&!e.state.defaultCompletionSpec){if(t&&t.length>0){let e=``;for(let n of t)e+=`complete: ${n}: no completion specification
1001
+ `;return $(``,e,1)}return dP(``)}let r=[],i=t||Array.from(n.keys());for(let e of i){let i=n.get(e);if(!i){if(t)return $(r.join(`
1002
+ `)+(r.length>0?`
1003
+ `:``),`complete: ${e}: no completion specification
1004
+ `,1);continue}let a=`complete`;if(i.options)for(let e of i.options)a+=` -o ${UI(e)}`;if(i.actions)for(let e of i.actions)a+=` -A ${UI(e)}`;i.wordlist!==void 0&&(i.wordlist.includes(` `)||i.wordlist.includes(`'`),a+=` -W ${UI(i.wordlist)}`),i.function!==void 0&&(a+=` -F ${UI(i.function)}`),i.command!==void 0&&(a+=` -C ${UI(i.command)}`),i.isDefault&&(a+=` -D`),a+=`${e.startsWith(`-`)?` -- `:` `}${UI(e)}`,r.push(a)}if(!t&&e.state.defaultCompletionSpec){let t=e.state.defaultCompletionSpec,n=`complete`;for(let e of t.options??[])n+=` -o ${UI(e)}`;for(let e of t.actions??[])n+=` -A ${UI(e)}`;t.wordlist!==void 0&&(n+=` -W ${UI(t.wordlist)}`),t.function!==void 0&&(n+=` -F ${UI(t.function)}`),t.command!==void 0&&(n+=` -C ${UI(t.command)}`),n+=` -D`,r.push(n)}return r.length===0?dP(``):dP(`${r.join(`
1005
+ `)}
1006
+ `)}var ZI=[`bashdefault`,`default`,`dirnames`,`filenames`,`noquote`,`nosort`,`nospace`,`plusdirs`];function QI(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let n=!1,r=!1,i=[],a=[],o=[];for(let e=0;e<t.length;e++){let s=t[e];if(s===`-D`)n=!0;else if(s===`-E`)r=!0;else if(s===`-o`){if(e++,e>=t.length)return Q(`compopt: -o: option requires an argument
1007
+ `,2);let n=t[e];if(!ZI.includes(n))return Q(`compopt: ${n}: invalid option name
1008
+ `,2);i.push(n)}else if(s===`+o`){if(e++,e>=t.length)return Q(`compopt: +o: option requires an argument
1009
+ `,2);let n=t[e];if(!ZI.includes(n))return Q(`compopt: ${n}: invalid option name
1010
+ `,2);a.push(n)}else if(s===`--`){o.push(...t.slice(e+1));break}else!s.startsWith(`-`)&&!s.startsWith(`+`)&&o.push(s)}if(n){let t=e.state.defaultCompletionSpec??{isDefault:!0},n=new Set(t.options??[]);for(let e of i)n.add(e);for(let e of a)n.delete(e);return t.options=n.size>0?Array.from(n):void 0,e.state.defaultCompletionSpec=t,dP(``)}if(r){let t=e.state.emptyCompletionSpec??Object.create(null),n=new Set(t.options??[]);for(let e of i)n.add(e);for(let e of a)n.delete(e);return t.options=n.size>0?Array.from(n):void 0,e.state.emptyCompletionSpec=t,dP(``)}if(o.length>0){for(let t of o){let n=e.state.completionSpecs.get(t)??{},r=new Set(n.options??[]);for(let e of i)r.add(e);for(let e of a)r.delete(e);n.options=r.size>0?Array.from(r):void 0,e.state.completionSpecs.set(t,n)}return dP(``)}return Q(`compopt: not currently executing completion function
1011
+ `,1)}j();function $I(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new Ar;return uP}if(t.length>1)throw new wr(1,``,`bash: continue: too many arguments
1012
+ `);let n=1;if(t.length>0){let e=Number.parseInt(t[0],10);if(Number.isNaN(e)||e<1)throw new wr(1,``,`bash: continue: ${t[0]}: numeric argument required
1013
+ `);n=e}throw new br(n)}Wi();function eL(e,t){let n=``;return e.state.integerVars?.has(t)&&(n+=`i`),e.state.lowercaseVars?.has(t)&&(n+=`l`),GA(e,t)&&(n+=`n`),e.state.readonlyVars?.has(t)&&(n+=`r`),e.state.uppercaseVars?.has(t)&&(n+=`u`),e.state.exportedVars?.has(t)&&(n+=`x`),n===``?`--`:`-${n}`}function tL(e){return UI(e)}function nL(e){return`'${e.replace(/'/g,`'\\''`)}'`}function rL(e,t){let n=``,r=``,i=!1;for(let a of t){let t=eL(e,a);if(e.state.associativeArrays?.has(a)){let t=fD(e,a);if(t.length===0)n+=`declare -A ${a}=()
1014
+ `;else{let r=t.map(t=>{let n=tL(aD(e,a,t)??``);return`[${nL(t)}]=${n}`});n+=`declare -A ${a}=(${r.join(` `)})
1015
+ `}continue}let o=uD(e,a);if(o.length>0){let t=o.map(t=>`[${t}]=${GI(aD(e,a,t)??``)}`);n+=`declare -a ${a}=(${t.join(` `)})
1016
+ `;continue}if(iD(e,a)){n+=`declare -a ${a}=()
1017
+ `;continue}let s=e.state.env.get(a);if(s!==void 0)n+=`declare ${t} ${a}=${qI(s)}
1018
+ `;else{let o=e.state.declaredVars?.has(a),s=e.state.localVarDepth?.has(a);o||s?n+=`declare ${t} ${a}
1019
+ `:(r+=`bash: declare: ${a}: not found
1020
+ `,i=!0)}}return $(n,r,+!!i)}function iL(e,t){let{filterExport:n,filterReadonly:r,filterNameref:i,filterIndexedArray:a,filterAssocArray:o}=t,s=n||r||i||a||o,c=``,l=new Set;for(let t of e.state.env.keys())t.startsWith(`BASH_`)||l.add(t);for(let t of e.state.arrays?.keys()??[])l.add(t);if(e.state.localVarDepth)for(let t of e.state.localVarDepth.keys())l.add(t);if(e.state.associativeArrays)for(let t of e.state.associativeArrays)l.add(t);let u=Array.from(l).sort();for(let t of u){let l=eL(e,t),u=e.state.associativeArrays?.has(t),d=uD(e,t),f=!u&&iD(e,t);if(s&&(o&&!u||a&&!f||n&&!e.state.exportedVars?.has(t)||r&&!e.state.readonlyVars?.has(t)||i&&!GA(e,t)))continue;if(u){let n=fD(e,t);if(n.length===0)c+=`declare -A ${t}=()
1021
+ `;else{let r=n.map(n=>{let r=tL(aD(e,t,n)??``);return`[${nL(n)}]=${r}`});c+=`declare -A ${t}=(${r.join(` `)})
1022
+ `}continue}if(d.length>0){let n=d.map(n=>`[${n}]=${GI(aD(e,t,n)??``)}`);c+=`declare -a ${t}=(${n.join(` `)})
1023
+ `;continue}if(iD(e,t)){c+=`declare -a ${t}=()
1024
+ `;continue}let p=e.state.env.get(t);p!==void 0&&(c+=`declare ${l} ${t}=${qI(p)}
1025
+ `)}return dP(c)}function aL(e){let t=``,n=Array.from(e.state.associativeArrays??[]).sort();for(let r of n){let n=fD(e,r);if(n.length===0)t+=`declare -A ${r}=()
1026
+ `;else{let i=n.map(t=>{let n=tL(aD(e,r,t)??``);return`[${nL(t)}]=${n}`});t+=`declare -A ${r}=(${i.join(` `)})
1027
+ `}}return dP(t)}function oL(e){let t=``,n=new Set(Array.from(e.state.arrays??[]).filter(([,e])=>e.kind===`indexed`).map(([e])=>e)),r=Array.from(n).sort();for(let n of r){let r=uD(e,n);if(r.length===0)t+=`declare -a ${n}=()
1028
+ `;else{let i=r.map(t=>`[${t}]=${GI(aD(e,n,t)??``)}`);t+=`declare -a ${n}=(${i.join(` `)})
1029
+ `}}return dP(t)}function sL(e){let t=``,n=new Set;for(let t of e.state.env.keys())t.startsWith(`BASH_`)||n.add(t);let r=Array.from(n).sort();for(let n of r){if(e.state.associativeArrays?.has(n)||uD(e,n).length>0||iD(e,n))continue;let r=e.state.env.get(n);r!==void 0&&(t+=`${n}=${UI(r)}
1030
+ `)}return dP(t)}function cL(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function lL(e,t){return e.state.integerVars?.has(t)??!1}function uL(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function dL(e,t){return e.state.lowercaseVars?.has(t)??!1}function fL(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function pL(e,t){return e.state.uppercaseVars?.has(t)??!1}function mL(e,t,n){return dL(e,t)?n.toLowerCase():pL(e,t)?n.toUpperCase():n}async function hL(e,t){try{let n=await rP(e,sO(new Tk,t).expression);return String(n)}catch{return`0`}}function gL(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let n=t[0],r=n.length;if(e[r]!==`[`)return null;let i=0,a=r+1;for(;r<e.length;r++)if(e[r]===`[`)i++;else if(e[r]===`]`&&(i--,i===0))break;if(i!==0)return null;let o=e.slice(a,r);return r++,e[r]===`=`?(r++,{name:n,indexExpr:o,value:e.slice(r)}):null}async function _L(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength},r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1,u=!1,d=!1,f=!1,p=!1,m=!1,h=!1,g=!1,_=!1,v=[];for(let e=0;e<t.length;e++){let n=t[e];if(n===`-a`)r=!0;else if(n===`-A`)i=!0;else if(n===`-r`)a=!0;else if(n===`-x`)o=!0;else if(n===`-p`)s=!0;else if(n===`-n`)c=!0;else if(n===`+n`)l=!0;else if(n===`+a`)u=!0;else if(n===`+x`)d=!0;else if(n===`--`){v.push(...t.slice(e+1));break}else if(n.startsWith(`+`)){for(let e of n.slice(1))if(e===`n`)l=!0;else if(e===`a`)u=!0;else if(e===`x`)d=!0;else if(e!==`r`&&e!==`i`&&e!==`f`&&e!==`F`)return $(``,`bash: typeset: +${e}: invalid option
1031
+ `,2)}else if(n===`-i`)f=!0;else if(n===`-l`)p=!0;else if(n===`-u`)m=!0;else if(n===`-f`)h=!0;else if(n===`-F`)g=!0;else if(n===`-g`)_=!0;else if(n.startsWith(`-`))for(let e of n.slice(1))if(e===`a`)r=!0;else if(e===`A`)i=!0;else if(e===`r`)a=!0;else if(e===`x`)o=!0;else if(e===`p`)s=!0;else if(e===`n`)c=!0;else if(e===`i`)f=!0;else if(e===`l`)p=!0;else if(e===`u`)m=!0;else if(e===`f`)h=!0;else if(e===`F`)g=!0;else if(e===`g`)_=!0;else return $(``,`bash: typeset: -${e}: invalid option
1032
+ `,2);else v.push(n)}let y=e.state.localScopes.length>0&&!_,b=t=>{if(!y)return;let n=e.state.localScopes[e.state.localScopes.length-1];n.has(t)||n.set(t,e.state.env.get(t))},x=t=>{if(!y)return;let n=e.state.localScopes[e.state.localScopes.length-1];for(n.has(t)||n.set(t,e.state.env.get(t)),e.state.localArrayScopes??=[];e.state.localArrayScopes.length<e.state.localScopes.length;)e.state.localArrayScopes.push(new Map);let r=e.state.localArrayScopes.at(-1);if(r&&!r.has(t)){let n=tD(e,t);r.set(t,n?$E(n):void 0)}},S=t=>{y&&oF(e,t)};if(g){if(v.length===0){let t=Array.from(e.state.functions.keys()).sort(),n=``;for(let e of t)n+=`declare -f ${e}
1033
+ `;return dP(n)}let t=!0,n=``;for(let r of v)e.state.functions.has(r)?n+=`${r}
1034
+ `:t=!1;return $(n,``,+!t)}if(h){if(v.length===0){let t=``,n=Array.from(e.state.functions.keys()).sort();for(let e of n)t+=`${e} ()
1035
+ {
1036
+ # function body
1037
+ }
1038
+ `;return dP(t)}let t=!0;for(let n of v)e.state.functions.has(n)||(t=!1);return $(``,``,+!t)}if(s&&v.length>0)return rL(e,v);if(s&&v.length===0)return iL(e,{filterExport:o,filterReadonly:a,filterNameref:c,filterIndexedArray:r,filterAssocArray:i});if(v.length===0&&i&&!s)return aL(e);if(v.length===0&&r&&!s)return oL(e);if(v.length===0&&!s)return sL(e);let ee=``,C=0;for(let t of v){let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(s&&!u){let t=s[1],c=s[2],l=Ij(e,t);if(l)return l;if(i&&uD(e,t).length>0){ee+=`bash: declare: ${t}: cannot convert indexed to associative array
1039
+ `,C=1;continue}if((r||!i&&!r)&&e.state.associativeArrays?.has(t)){ee+=`bash: declare: ${t}: cannot convert associative to indexed array
1040
+ `,C=1;continue}let u=i&&c.includes(`[`)?nF(c,n):void 0,d=u===void 0?tF(c,{...n,maxElements:i?n.maxElements*2:n.maxElements}):void 0;if(e.executionScope.consumeWork(u?.length??d?.length??0,`declare array assignment`),x(t),i?(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(t),rD(e,t,`associative`)):rD(e,t,`indexed`),dD(e,t),e.state.env.delete(t),i&&c.includes(`[`))for(let[n,r]of u??[])Y(e,t,n,cM(e,r),`associative`);else if(i){let n=d??[];for(let r=0;r<n.length;r+=2){let i=n[r];Y(e,t,i,r+1<n.length?n[r+1]:``,`associative`)}}else{let n=d??[];if(n.some(e=>/^\[[^\]]+\]=/.test(e))){let r=0;for(let i of n){let n=i.match(/^\[([^\]]+)\]=(.*)$/);if(n){let i=n[1],a=n[2],o;if(/^-?\d+$/.test(i))o=Number.parseInt(i,10);else try{o=await rP(e,sO(new Tk,i).expression)}catch{o=0}Y(e,t,o,cM(e,a)),r=o+1}else Y(e,t,r,i),r++}}else for(let r=0;r<n.length;r++)Y(e,t,r,n[r])}S(t),a&&Pj(e,t),o&&Lj(e,t);continue}if(l&&(qA(e,t.includes(`=`)?t.slice(0,t.indexOf(`=`)):t),!t.includes(`=`))||d&&(Rj(e,t.includes(`=`)?t.slice(0,t.indexOf(`=`)):t),!t.includes(`=`)))continue;let h=gL(t);if(h){let{name:t,indexExpr:n,value:r}=h,i=Ij(e,t);if(i)return i;x(t);let s;try{s=await rP(e,sO(new Tk,n).expression)}catch{let e=parseInt(n,10);s=Number.isNaN(e)?0:e}Y(e,t,s,r),S(t),a&&Pj(e,t),o&&Lj(e,t);continue}let g=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(g&&!u){let t=g[1],r=g[2],i=Ij(e,t);if(i)return i;x(t);let s=tF(r,n);if(e.state.associativeArrays?.has(t)){let i=nF(r,n);e.executionScope.consumeWork(i.length,`declare array append`),sD(e,t,i.map(([e])=>e));for(let[n,r]of i)Y(e,t,n,r,`associative`)}else{e.executionScope.consumeWork(s.length,`declare array append`);let n=uD(e,t),r=0,i=e.state.env.get(t);n.length===0&&i!==void 0?(Y(e,t,0,i),e.state.env.delete(t),r=1):n.length>0&&(r=Math.max(...n)+1),sD(e,t,Array.from({length:s.length},(e,t)=>r+t));for(let n=0;n<s.length;n++)Y(e,t,r+n,s[n])}S(t),a&&Pj(e,t),o&&Lj(e,t);continue}let _=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(_){let t=_[1],n=_[2],r=Ij(e,t);if(r)return r;b(t),f&&cL(e,t),p&&uL(e,t),m&&fL(e,t);let i=uD(e,t).length>0||e.state.associativeArrays?.has(t);if(lL(e,t)){let r=e.state.env.get(t)??`0`,i=parseInt(r,10)||0,a=parseInt(await hL(e,n),10)||0;n=String(i+a),e.state.env.set(t,n)}else if(i)n=mL(e,t,n),Y(e,t,0,Hi([aD(e,t,0)??``,n],``,e.limits.maxStringLength,`declare append`));else{n=mL(e,t,n);let r=e.state.env.get(t)??``;e.state.env.set(t,Hi([r,n],``,e.limits.maxStringLength,`declare append`))}S(t),a&&Pj(e,t),o&&Lj(e,t),e.state.options.allexport&&!d&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t));continue}if(t.includes(`=`)){let n=t.indexOf(`=`),r=t.slice(0,n),i=t.slice(n+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)){ee+=`bash: typeset: \`${r}': not a valid identifier
1041
+ `,C=1;continue}let s=Ij(e,r);if(s)return s;if(b(r),c){if(i!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i)){ee+=`bash: declare: \`${i}': invalid variable name for name reference
1042
+ `,C=1;continue}e.state.env.set(r,i),KA(e,r),i!==``&&ZA(e,i)&&XA(e,r),S(r),a&&Pj(e,r),o&&Lj(e,r);continue}if(f&&cL(e,r),p&&uL(e,r),m&&fL(e,r),lL(e,r)&&(i=await hL(e,i)),i=mL(e,r,i),GA(e,r)){let t=QA(e,r);t&&t!==r?e.state.env.set(t,i):e.state.env.set(r,i)}else e.state.env.set(r,i);S(r),a&&Pj(e,r),o&&Lj(e,r),e.state.options.allexport&&!d&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(r))}else{let n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){ee+=`bash: typeset: \`${n}': not a valid identifier
1043
+ `,C=1;continue}if(r||i?x(n):b(n),c){KA(e,n);let t=e.state.env.get(n);t!==void 0&&t!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t)?JA(e,n):t&&ZA(e,t)&&XA(e,n),S(n),a&&Pj(e,n),o&&Lj(e,n);continue}if(f&&cL(e,n),p&&uL(e,n),m&&fL(e,n),i){if(uD(e,n).length>0){ee+=`bash: declare: ${n}: cannot convert indexed to associative array
1044
+ `,C=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(n),rD(e,n,`associative`)}let s=iD(e,n);!e.state.env.has(n)&&!s&&(r||i?rD(e,n,i?`associative`:`indexed`):(e.state.declaredVars??=new Set,e.state.declaredVars.add(n))),S(n),a&&Pj(e,n),o&&Lj(e,n)}}return $(``,ee,C)}async function vL(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength},r=[];for(let e=0;e<t.length;e++){let n=t[e];if(n!==`-a`&&n!==`-A`&&n!==`-p`)if(n===`--`){r.push(...t.slice(e+1));break}else n.startsWith(`-`)||r.push(n)}if(r.length===0){let t=``,n=Array.from(e.state.readonlyVars||[]).sort();for(let r of n){let n=e.state.env.get(r);if(n!==void 0){let e=n.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`);t+=`declare -r ${r}="${e}"
1045
+ `}}return dP(t)}for(let t of r){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(r){let t=r[1],i=r[2],a=Ij(e,t);if(a)return a;let o=tF(i,n);if(e.state.associativeArrays?.has(t)){let r=nF(i,n);e.executionScope.consumeWork(r.length,`readonly array append`),sD(e,t,r.map(([e])=>e));for(let[n,i]of r)Y(e,t,n,i,`associative`)}else{e.executionScope.consumeWork(o.length,`readonly array append`);let n=uD(e,t),r=0,i=e.state.env.get(t);n.length===0&&i!==void 0?(Y(e,t,0,i),e.state.env.delete(t),r=1):n.length>0&&(r=Math.max(...n)+1),sD(e,t,Array.from({length:o.length},(e,t)=>r+t));for(let n=0;n<o.length;n++)Y(e,t,r+n,o[n])}Pj(e,t);continue}let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(i){let t=i[1],n=i[2],r=Ij(e,t);if(r)return r;let a=e.state.env.get(t)??``;e.state.env.set(t,Hi([a,n],``,e.limits.maxStringLength,`readonly append`)),Pj(e,t);continue}let a=rF(t,n);if(a.value===void 0&&!a.isArray){Pj(e,a.name);continue}let o=await aF(e,a,{makeReadonly:!0});if(o)return o}return uP}function yL(e){return e.state.directoryStack??=[],e.state.directoryStack}function bL(e,t){return t&&e===t?`~`:t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function xL(e){let t=e.split(`/`).filter(e=>e&&e!==`.`),n=[];for(let e of t)e===`..`?n.pop():n.push(e);return`/${n.join(`/`)}`}async function SL(e,t){let n=yL(e),r;for(let e=0;e<t.length;e++){let n=t[e];if(n===`--`){if(e+1<t.length){if(r!==void 0)return Q(`bash: pushd: too many arguments
1046
+ `,2);r=t[e+1],e++}}else{if(n.startsWith(`-`)&&n!==`-`)return Q(`bash: pushd: ${n}: invalid option
1047
+ `,2);if(r!==void 0)return Q(`bash: pushd: too many arguments
1048
+ `,2);r=n}}if(r===void 0){if(n.length<2)return Q(`bash: pushd: no other directory
1049
+ `,1);let e=n[0];n[0]=n[1],n[1]=e,r=n[0]}let i;if(r.startsWith(`/`))i=r;else if(r===`..`){let t=e.state.cwd.split(`/`).filter(e=>e);t.pop(),i=`/${t.join(`/`)}`}else i=r===`.`?e.state.cwd:r.startsWith(`~`)?(e.state.env.get(`HOME`)||`/`)+r.slice(1):`${e.state.cwd}/${r}`;i=xL(i);try{if(!(await e.fs.stat(i)).isDirectory)return Q(`bash: pushd: ${r}: Not a directory
1050
+ `,1)}catch{return Q(`bash: pushd: ${r}: No such file or directory
1051
+ `,1)}n.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=i,e.state.env.set(`PWD`,i),e.state.env.set(`OLDPWD`,e.state.previousDir);let a=e.state.env.get(`HOME`)||``;return dP(`${[i,...n].map(e=>bL(e,a)).join(` `)}
1052
+ `)}function CL(e,t){let n=yL(e);for(let e of t)if(e!==`--`)return e.startsWith(`-`)&&e!==`-`?Q(`bash: popd: ${e}: invalid option
1053
+ `,2):Q(`bash: popd: too many arguments
1054
+ `,2);if(n.length===0)return Q(`bash: popd: directory stack empty
1055
+ `,1);let r=n.shift();if(!r)return Q(`bash: popd: directory stack empty
1056
+ `,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,e.state.env.set(`PWD`,r),e.state.env.set(`OLDPWD`,e.state.previousDir);let i=e.state.env.get(`HOME`)||``;return dP(`${[r,...n].map(e=>bL(e,i)).join(` `)}
1057
+ `)}function wL(e,t){let n=yL(e),r=!1,i=!1,a=!1,o=!1;for(let e of t)if(e!==`--`)if(e.startsWith(`-`))for(let t of e.slice(1))if(t===`c`)r=!0;else if(t===`l`)i=!0;else if(t===`p`)a=!0;else if(t===`v`)a=!0,o=!0;else return Q(`bash: dirs: -${t}: invalid option
1058
+ `,2);else return Q(`bash: dirs: too many arguments
1059
+ `,1);if(r)return e.state.directoryStack=[],uP;let s=[e.state.cwd,...n],c=e.state.env.get(`HOME`)||``,l;return o?(l=s.map((e,t)=>` ${t} ${i?e:bL(e,c)}`).join(`
1060
+ `),l+=`
1061
+ `):l=a?s.map(e=>i?e:bL(e,c)).join(`
1062
+ `)+`
1063
+ `:s.map(e=>i?e:bL(e,c)).join(` `)+`
1064
+ `,dP(l)}j();async function TL(e,t,n,r=!1){let i=t;if(i.length>0){let e=i[0];if(e===`--`)i=i.slice(1);else if(e.startsWith(`-`)&&e!==`-`&&e.length>1)return Q(`bash: eval: ${e}: invalid option
1065
+ eval: usage: eval [arg ...]
1066
+ `,2)}if(i.length===0)return uP;let a=i.join(` `);if(a.trim()===``)return uP;let o=e.state.groupStdin,s=r||n!==void 0&&n!==``;s&&(e.state.groupStdin=n??``);try{let t=Ek(a);return await e.executeScript(t)}catch(e){if(e instanceof yr||e instanceof br||e instanceof xr||e instanceof wr)throw e;if(e.name===`ParseException`)return Q(`bash: eval: ${e.message}
1067
+ `);throw e}finally{(s||o!==void 0&&e.state.groupStdin===void 0)&&(e.state.groupStdin=o)}}j();function EL(e,t){let n,r=``;if(t.length===0)n=e.state.lastExitCode;else{let e=t[0];if(e===``||!/^-?\d+$/.test(e))r=`bash: exit: ${e}: numeric argument required
1068
+ `,n=2;else{let t=BigInt(e);n=Number((t%256n+256n)%256n)}}throw new wr(n,``,r)}function DL(e,t){let n=!1,r=[];for(let e of t)e===`-n`?n=!0:e===`-p`||e===`--`||r.push(e);if(r.length===0&&!n){let t=``,n=e.state.exportedVars??new Set,r=Array.from(n).sort();for(let n of r){let r=e.state.env.get(n);r!==void 0&&(t+=`declare -x ${n}=${qI(r)}
1069
+ `)}return dP(t)}if(n){for(let t of r){let n,r;if(t.includes(`=`)){let e=t.indexOf(`=`);n=t.slice(0,e),r=t.slice(e+1)}else n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n))return $(``,`bash: export: \`${t}': not a valid identifier
1070
+ `,1);r!==void 0&&(Ij(e,n),e.state.env.set(n,r)),Rj(e,n)}return uP}let i=``,a=0;for(let t of r){let n,r,o=!1,s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(s)n=s[1],r=s[2],o=!0;else if(t.includes(`=`)){let e=t.indexOf(`=`);n=t.slice(0,e),r=t.slice(e+1)}else n=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)){i+=`bash: export: \`${t}': not a valid identifier
1071
+ `,a=1;continue}if(r!==void 0)if(Ij(e,n),o){let t=e.state.env.get(n)??``;e.state.env.set(n,t+r)}else e.state.env.set(n,r);else e.state.env.has(n)||e.state.env.set(n,``);Lj(e,n)}return $(``,i,a)}function OL(e,t){if(t.length<2)return Q(`bash: getopts: usage: getopts optstring name [arg ...]
1072
+ `);let n=t[0],r=t[1],i=!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r),a=n.startsWith(`:`),o=a?n.slice(1):n,s;if(t.length>2)s=t.slice(2);else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);s=[];for(let n=1;n<=t;n++)s.push(e.state.env.get(String(n))||``)}let c=Number.parseInt(e.state.env.get(`OPTIND`)||`1`,10);c<1&&(c=1);let l=Number.parseInt(e.state.env.get(`__GETOPTS_CHARINDEX`)||`0`,10);if(e.state.env.set(`OPTARG`,``),c>s.length)return i||e.state.env.set(r,`?`),e.state.env.set(`OPTIND`,String(s.length+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),{exitCode:i?2:1,stdout:``,stderr:``};let u=s[c-1];if(!u||u===`-`||!u.startsWith(`-`))return i||e.state.env.set(r,`?`),{exitCode:i?2:1,stdout:``,stderr:``};if(u===`--`)return e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),i||e.state.env.set(r,`?`),{exitCode:i?2:1,stdout:``,stderr:``};let d=l===0?1:l,f=u[d];if(!f)return e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),OL(e,t);let p=o.indexOf(f);if(p===-1){let t=``;return a?e.state.env.set(`OPTARG`,f):t=`bash: illegal option -- ${f}
1073
+ `,i||e.state.env.set(r,`?`),d+1<u.length?(e.state.env.set(`__GETOPTS_CHARINDEX`,String(d+1)),e.state.env.set(`OPTIND`,String(c))):(e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`)),{exitCode:i?2:0,stdout:``,stderr:t}}if(p+1<o.length&&o[p+1]===`:`)if(d+1<u.length)e.state.env.set(`OPTARG`,u.slice(d+1)),e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`);else{if(c>=s.length){let t=``;return a?(e.state.env.set(`OPTARG`,f),i||e.state.env.set(r,`:`)):(t=`bash: option requires an argument -- ${f}
1074
+ `,i||e.state.env.set(r,`?`)),e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`),{exitCode:i?2:0,stdout:``,stderr:t}}e.state.env.set(`OPTARG`,s[c]),e.state.env.set(`OPTIND`,String(c+2)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`)}else d+1<u.length?(e.state.env.set(`__GETOPTS_CHARINDEX`,String(d+1)),e.state.env.set(`OPTIND`,String(c))):(e.state.env.set(`OPTIND`,String(c+1)),e.state.env.set(`__GETOPTS_CHARINDEX`,`0`));return i||e.state.env.set(r,f),{exitCode:i?2:0,stdout:``,stderr:``}}async function kL(e,t){e.state.hashTable||(e.state.hashTable=new Map);let n=!1,r=!1,i=!1,a=!1,o=!1,s=``,c=[],l=0;for(;l<t.length;){let e=t[l];if(e===`--`){l++,c.push(...t.slice(l));break}if(e===`-r`)n=!0,l++;else if(e===`-d`)r=!0,l++;else if(e===`-l`)i=!0,l++;else if(e===`-t`)o=!0,l++;else if(e===`-p`){if(a=!0,l++,l>=t.length)return Q(`bash: hash: -p: option requires an argument
1075
+ `,1);s=t[l],l++}else if(e.startsWith(`-`)&&e.length>1){for(let t of e.slice(1))if(t===`r`)n=!0;else if(t===`d`)r=!0;else if(t===`l`)i=!0;else if(t===`t`)o=!0;else return Q(t===`p`?`bash: hash: -p: option requires an argument
1076
+ `:`bash: hash: -${t}: invalid option
1077
+ `,1);l++}else c.push(e),l++}if(n)return e.state.hashTable.clear(),uP;if(r){if(c.length===0)return Q(`bash: hash: -d: option requires an argument
1078
+ `,1);let t=!1,n=``;for(let r of c)e.state.hashTable.has(r)?e.state.hashTable.delete(r):(n+=`bash: hash: ${r}: not found
1079
+ `,t=!0);return t?Q(n,1):uP}if(o){if(c.length===0)return Q(`bash: hash: -t: option requires an argument
1080
+ `,1);let t=``,n=!1,r=``;for(let i of c){let a=e.state.hashTable.get(i);a?c.length>1?t+=`${i} ${a}
1081
+ `:t+=`${a}
1082
+ `:(r+=`bash: hash: ${i}: not found
1083
+ `,n=!0)}return n?{exitCode:1,stdout:t,stderr:r}:dP(t)}if(a){if(c.length===0)return Q(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
1084
+ `,1);let t=c[0];return e.state.hashTable.set(t,s),uP}if(c.length===0){if(e.state.hashTable.size===0)return dP(`hash: hash table empty
1085
+ `);let t=``;if(i)for(let[n,r]of e.state.hashTable){let e=n.startsWith(`-`)?` --`:``;t+=`builtin hash -p ${UI(r)}${e} ${UI(n)}
1086
+ `}else{t=`hits command
1087
+ `;for(let[,n]of e.state.hashTable)t+=` 1 ${n}
1088
+ `}return dP(t)}let u=!1,d=``,f=(e.state.env.get(`PATH`)||`/usr/bin:/bin`).split(`:`);for(let t of c){if(t.includes(`/`)){d+=`bash: hash: ${t}: cannot use / in name
1089
+ `,u=!0;continue}let n=!1;for(let r of f){if(!r)continue;let i=`${r}/${t}`;if(await e.fs.exists(i)){e.state.hashTable.set(t,i),n=!0;break}}n||(d+=`bash: hash: ${t}: not found
1090
+ `,u=!0)}return u?Q(d,1):uP}mc();var AL=new Map([[`:`,[`: [arguments]`,`Null command.
1091
+ No effect; the command does nothing.
1092
+ Exit Status:
1093
+ Always succeeds.`]],[`.`,[`. filename [arguments]`,`Execute commands from a file in the current shell.
1094
+ Read and execute commands from FILENAME in the current shell.
1095
+ The entries in $PATH are used to find the directory containing FILENAME.
1096
+ Exit Status:
1097
+ Returns the status of the last command executed in FILENAME.`]],[`[`,[`[ arg... ]`,`Evaluate conditional expression.
1098
+ This is a synonym for the "test" builtin, but the last argument must
1099
+ be a literal \`]', to match the opening \`['.`]],[`alias`,[`alias [-p] [name[=value] ... ]`,`Define or display aliases.
1100
+ Without arguments, \`alias' prints the list of aliases in the reusable
1101
+ form \`alias NAME=VALUE' on standard output.
1102
+ Exit Status:
1103
+ alias returns true unless a NAME is supplied for which no alias has been
1104
+ defined.`]],[`bg`,[`bg [job_spec ...]`,`Move jobs to the background.
1105
+ Place the jobs identified by each JOB_SPEC in the background, as if they
1106
+ had been started with \`&'.`]],[`break`,[`break [n]`,`Exit for, while, or until loops.
1107
+ Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing
1108
+ loops.
1109
+ Exit Status:
1110
+ The exit status is 0 unless N is not greater than or equal to 1.`]],[`builtin`,[`builtin [shell-builtin [arg ...]]`,`Execute shell builtins.
1111
+ Execute SHELL-BUILTIN with arguments ARGs without performing command
1112
+ lookup. This is useful when you wish to reimplement a shell builtin
1113
+ as a shell function, but need to execute the builtin within the function.
1114
+ Exit Status:
1115
+ Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is
1116
+ not a shell builtin.`]],[`caller`,[`caller [expr]`,`Return the context of the current subroutine call.
1117
+ Without EXPR, returns "$line $filename". With EXPR, returns
1118
+ "$line $subroutine $filename"; this extra information can be used to
1119
+ provide a stack trace.
1120
+ Exit Status:
1121
+ Returns 0 unless the shell is not executing a subroutine call or
1122
+ EXPR is invalid.`]],[`cd`,[`cd [-L|-P] [dir]`,`Change the shell working directory.
1123
+ Change the current directory to DIR. The default DIR is the value of the
1124
+ HOME shell variable.
1125
+
1126
+ The variable CDPATH defines the search path for the directory containing
1127
+ DIR. Alternative directory names in CDPATH are separated by a colon (:).
1128
+ A null directory name is the same as the current directory. If DIR begins
1129
+ with a slash (/), then CDPATH is not used.
1130
+
1131
+ If the directory is not found, and the shell option \`cdable_vars' is set,
1132
+ the word is assumed to be a variable name. If that variable has a value,
1133
+ its value is used for DIR.
1134
+
1135
+ Options:
1136
+ -L force symbolic links to be followed
1137
+ -P use the physical directory structure without following symbolic
1138
+ links
1139
+
1140
+ The default is to follow symbolic links, as if \`-L' were specified.
1141
+
1142
+ Exit Status:
1143
+ Returns 0 if the directory is changed; non-zero otherwise.`]],[`command`,[`command [-pVv] command [arg ...]`,`Execute a simple command or display information about commands.
1144
+ Runs COMMAND with ARGS suppressing shell function lookup, or display
1145
+ information about the specified COMMANDs.
1146
+
1147
+ Options:
1148
+ -p use a default value for PATH that is guaranteed to find all of
1149
+ the standard utilities
1150
+ -v print a description of COMMAND similar to the \`type' builtin
1151
+ -V print a more verbose description of each COMMAND
1152
+
1153
+ Exit Status:
1154
+ Returns exit status of COMMAND, or failure if COMMAND is not found.`]],[`compgen`,[`compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word]`,`Display possible completions depending on the options.
1155
+ Intended to be used from within a shell function generating possible
1156
+ completions. If the optional WORD argument is supplied, matches against
1157
+ WORD are generated.
1158
+ Exit Status:
1159
+ Returns success unless an invalid option is supplied or an error occurs.`]],[`complete`,[`complete [-abcdefgjksuv] [-pr] [-DEI] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...]`,`Specify how arguments are to be completed.
1160
+ For each NAME, specify how arguments are to be completed.
1161
+ Exit Status:
1162
+ Returns success unless an invalid option is supplied or an error occurs.`]],[`continue`,[`continue [n]`,`Resume for, while, or until loops.
1163
+ Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.
1164
+ If N is specified, resumes the Nth enclosing loop.
1165
+ Exit Status:
1166
+ The exit status is 0 unless N is not greater than or equal to 1.`]],[`declare`,[`declare [-aAfFgilnrtux] [-p] [name[=value] ...]`,`Set variable values and attributes.
1167
+ Declare variables and give them attributes. If no NAMEs are given,
1168
+ display the attributes and values of all variables.
1169
+
1170
+ Options:
1171
+ -a to make NAMEs indexed arrays (if supported)
1172
+ -A to make NAMEs associative arrays (if supported)
1173
+ -i to make NAMEs have the \`integer' attribute
1174
+ -l to convert the value of each NAME to lower case on assignment
1175
+ -n make NAME a reference to the variable named by its value
1176
+ -r to make NAMEs readonly
1177
+ -t to make NAMEs have the \`trace' attribute
1178
+ -u to convert the value of each NAME to upper case on assignment
1179
+ -x to make NAMEs export
1180
+
1181
+ Exit Status:
1182
+ Returns success unless an invalid option is supplied or a variable
1183
+ assignment error occurs.`]],[`dirs`,[`dirs [-clpv] [+N] [-N]`,`Display directory stack.
1184
+ Display the list of currently remembered directories. Directories
1185
+ find their way onto the list with the \`pushd' command; you can get
1186
+ back up through the list with the \`popd' command.
1187
+ Exit Status:
1188
+ Returns success unless an invalid option is supplied or an error occurs.`]],[`disown`,[`disown [-h] [-ar] [jobspec ...]`,`Remove jobs from current shell.
1189
+ Without any JOBSPECs, remove the current job.`]],[`echo`,[`echo [-neE] [arg ...]`,`Write arguments to the standard output.
1190
+ Display the ARGs, separated by a single space character and followed by a
1191
+ newline, on the standard output.
1192
+
1193
+ Options:
1194
+ -n do not append a newline
1195
+ -e enable interpretation of the following backslash escapes
1196
+ -E explicitly suppress interpretation of backslash escapes
1197
+
1198
+ Exit Status:
1199
+ Returns success unless a write error occurs.`]],[`enable`,[`enable [-a] [-dnps] [-f filename] [name ...]`,`Enable and disable shell builtins.
1200
+ Enables and disables builtin shell commands.
1201
+ Exit Status:
1202
+ Returns success unless NAME is not a shell builtin or an error occurs.`]],[`eval`,[`eval [arg ...]`,`Execute arguments as a shell command.
1203
+ Combine ARGs into a single string, use the result as input to the shell,
1204
+ and execute the resulting commands.
1205
+ Exit Status:
1206
+ Returns exit status of command or success if command is null.`]],[`exec`,[`exec [-cl] [-a name] [command [arguments ...]] [redirection ...]`,`Replace the shell with the given command.
1207
+ Execute COMMAND, replacing this shell with the specified program.
1208
+ ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified,
1209
+ any redirections take effect in the current shell.
1210
+ Exit Status:
1211
+ Returns success unless COMMAND is not found or a redirection error occurs.`]],[`exit`,[`exit [n]`,`Exit the shell.
1212
+ Exits the shell with a status of N. If N is omitted, the exit status
1213
+ is that of the last command executed.`]],[`export`,[`export [-fn] [name[=value] ...] or export -p`,`Set export attribute for shell variables.
1214
+ Marks each NAME for automatic export to the environment of subsequently
1215
+ executed commands. If VALUE is supplied, assign VALUE before exporting.
1216
+
1217
+ Options:
1218
+ -f refer to shell functions
1219
+ -n remove the export property from each NAME
1220
+ -p display a list of all exported variables and functions
1221
+
1222
+ Exit Status:
1223
+ Returns success unless an invalid option is given or NAME is invalid.`]],[`false`,[`false`,`Return an unsuccessful result.
1224
+ Exit Status:
1225
+ Always fails.`]],[`fc`,[`fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]`,`Display or execute commands from the history list.
1226
+ Exit Status:
1227
+ Returns success or status of executed command.`]],[`fg`,[`fg [job_spec]`,`Move job to the foreground.
1228
+ Place the job identified by JOB_SPEC in the foreground, making it the
1229
+ current job.`]],[`getopts`,[`getopts optstring name [arg]`,`Parse option arguments.
1230
+ Getopts is used by shell procedures to parse positional parameters
1231
+ as options.
1232
+
1233
+ OPTSTRING contains the option letters to be recognized; if a letter
1234
+ is followed by a colon, the option is expected to have an argument,
1235
+ which should be separated from it by white space.
1236
+ Exit Status:
1237
+ Returns success if an option is found; fails if the end of options is
1238
+ encountered or an error occurs.`]],[`hash`,[`hash [-lr] [-p pathname] [-dt] [name ...]`,`Remember or display program locations.
1239
+ Determine and remember the full pathname of each command NAME.
1240
+ Exit Status:
1241
+ Returns success unless NAME is not found or an invalid option is given.`]],[`help`,[`help [-s] [pattern ...]`,`Display information about builtin commands.
1242
+ Displays brief summaries of builtin commands. If PATTERN is
1243
+ specified, gives detailed help on all commands matching PATTERN,
1244
+ otherwise the list of help topics is printed.
1245
+
1246
+ Options:
1247
+ -s output only a short usage synopsis for each topic matching
1248
+ PATTERN
1249
+
1250
+ Exit Status:
1251
+ Returns success unless PATTERN is not found.`]],[`history`,[`history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]`,`Display or manipulate the history list.
1252
+ Display the history list with line numbers, prefixing each modified
1253
+ entry with a \`*'.
1254
+ Exit Status:
1255
+ Returns success unless an invalid option is given or an error occurs.`]],[`jobs`,[`jobs [-lnprs] [jobspec ...] or jobs -x command [args]`,`Display status of jobs.
1256
+ Lists the active jobs.
1257
+ Exit Status:
1258
+ Returns success unless an invalid option is given or an error occurs.`]],[`kill`,[`kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]`,`Send a signal to a job.
1259
+ Send the processes identified by PID or JOBSPEC the signal named by
1260
+ SIGSPEC or SIGNUM.
1261
+ Exit Status:
1262
+ Returns success unless an invalid option is given or an error occurs.`]],[`let`,[`let arg [arg ...]`,`Evaluate arithmetic expressions.
1263
+ Evaluate each ARG as an arithmetic expression. Evaluation is done in
1264
+ fixed-width integers with no check for overflow, though division by 0
1265
+ is trapped and flagged as an error.
1266
+ Exit Status:
1267
+ If the last ARG evaluates to 0, let returns 1; 0 is returned otherwise.`]],[`local`,[`local [option] name[=value] ...`,`Define local variables.
1268
+ Create a local variable called NAME, and give it VALUE. OPTION can
1269
+ be any option accepted by \`declare'.
1270
+
1271
+ Local can only be used within a function; it makes the variable NAME
1272
+ have a visible scope restricted to that function and its children.
1273
+ Exit Status:
1274
+ Returns success unless an invalid option is supplied, a variable
1275
+ assignment error occurs, or the shell is not executing a function.`]],[`logout`,[`logout [n]`,`Exit a login shell.
1276
+ Exits a login shell with exit status N. Returns an error if not executed
1277
+ in a login shell.`]],[`mapfile`,[`mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]`,`Read lines from the standard input into an indexed array variable.
1278
+ Read lines from the standard input into the indexed array variable ARRAY,
1279
+ or from file descriptor FD if the -u option is supplied.
1280
+
1281
+ Options:
1282
+ -d delim Use DELIM to terminate lines, instead of newline
1283
+ -n count Copy at most COUNT lines
1284
+ -O origin Begin assigning to ARRAY at index ORIGIN
1285
+ -s count Discard the first COUNT lines read
1286
+ -t Remove a trailing DELIM from each line read (default newline)
1287
+ -u fd Read lines from file descriptor FD instead of standard input
1288
+
1289
+ Exit Status:
1290
+ Returns success unless an invalid option is given or ARRAY is readonly.`]],[`popd`,[`popd [-n] [+N | -N]`,`Remove directories from stack.
1291
+ Removes entries from the directory stack.
1292
+ Exit Status:
1293
+ Returns success unless an invalid argument is supplied or the directory
1294
+ change fails.`]],[`printf`,[`printf [-v var] format [arguments]`,`Formats and prints ARGUMENTS under control of the FORMAT.
1295
+
1296
+ Options:
1297
+ -v var assign the output to shell variable VAR rather than
1298
+ display it on the standard output
1299
+
1300
+ FORMAT is a character string which contains three types of objects: plain
1301
+ characters, which are simply copied to standard output; character escape
1302
+ sequences, which are converted and copied to the standard output; and
1303
+ format specifications, each of which causes printing of the next successive
1304
+ argument.
1305
+ Exit Status:
1306
+ Returns success unless an invalid option is given or a write or assignment
1307
+ error occurs.`]],[`pushd`,[`pushd [-n] [+N | -N | dir]`,`Add directories to stack.
1308
+ Adds a directory to the top of the directory stack, or rotates
1309
+ the stack, making the new top of the stack the current working
1310
+ directory.
1311
+ Exit Status:
1312
+ Returns success unless an invalid argument is supplied or the directory
1313
+ change fails.`]],[`pwd`,[`pwd [-LP]`,`Print the name of the current working directory.
1314
+
1315
+ Options:
1316
+ -L print the value of $PWD if it names the current working
1317
+ directory
1318
+ -P print the physical directory, without any symbolic links
1319
+
1320
+ By default, \`pwd' behaves as if \`-L' were specified.
1321
+ Exit Status:
1322
+ Returns 0 unless an invalid option is given or the current directory
1323
+ cannot be read.`]],[`read`,[`read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]`,`Read a line from the standard input and split it into fields.
1324
+ Reads a single line from the standard input, or from file descriptor FD
1325
+ if the -u option is supplied. The line is split into fields as with word
1326
+ splitting, and the first word is assigned to the first NAME, the second
1327
+ word to the second NAME, and so on, with any leftover words assigned to
1328
+ the last NAME.
1329
+ Exit Status:
1330
+ The return code is zero, unless end-of-file is encountered, read times out,
1331
+ or an invalid file descriptor is supplied as the argument to -u.`]],[`readarray`,[`readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]`,`Read lines from a file into an array variable.
1332
+ A synonym for \`mapfile'.`]],[`readonly`,[`readonly [-aAf] [name[=value] ...] or readonly -p`,`Mark shell variables as unchangeable.
1333
+ Mark each NAME as read-only; the values of these NAMEs may not be
1334
+ changed by subsequent assignment.
1335
+ Exit Status:
1336
+ Returns success unless an invalid option is given or NAME is invalid.`]],[`return`,[`return [n]`,`Return from a shell function.
1337
+ Causes a function or sourced script to exit with the return value
1338
+ specified by N. If N is omitted, the return status is that of the
1339
+ last command executed within the function or script.
1340
+ Exit Status:
1341
+ Returns N, or failure if the shell is not executing a function or script.`]],[`set`,[`set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]`,`Set or unset values of shell options and positional parameters.
1342
+ Change the value of shell attributes and positional parameters, or
1343
+ display the names and values of shell variables.
1344
+
1345
+ Options:
1346
+ -e Exit immediately if a command exits with a non-zero status.
1347
+ -u Treat unset variables as an error when substituting.
1348
+ -x Print commands and their arguments as they are executed.
1349
+ -o option-name
1350
+ Set the variable corresponding to option-name
1351
+
1352
+ Exit Status:
1353
+ Returns success unless an invalid option is given.`]],[`shift`,[`shift [n]`,`Shift positional parameters.
1354
+ Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is
1355
+ not given, it is assumed to be 1.
1356
+ Exit Status:
1357
+ Returns success unless N is negative or greater than $#.`]],[`shopt`,[`shopt [-pqsu] [-o] [optname ...]`,`Set and unset shell options.
1358
+ Change the setting of each shell option OPTNAME. Without any option
1359
+ arguments, list each supplied OPTNAME, or all shell options if no
1360
+ OPTNAMEs are given, with an indication of whether or not each is set.
1361
+
1362
+ Options:
1363
+ -o restrict OPTNAMEs to those defined for use with \`set -o'
1364
+ -p print each shell option with an indication of its status
1365
+ -q suppress output
1366
+ -s enable (set) each OPTNAME
1367
+ -u disable (unset) each OPTNAME
1368
+
1369
+ Exit Status:
1370
+ Returns success if OPTNAME is enabled; fails if an invalid option is
1371
+ given or OPTNAME is disabled.`]],[`source`,[`source filename [arguments]`,`Execute commands from a file in the current shell.
1372
+ Read and execute commands from FILENAME in the current shell.
1373
+ The entries in $PATH are used to find the directory containing FILENAME.
1374
+ Exit Status:
1375
+ Returns the status of the last command executed in FILENAME.`]],[`suspend`,[`suspend [-f]`,`Suspend shell execution.
1376
+ Suspend the execution of this shell until it receives a SIGCONT signal.`]],[`test`,[`test [expr]`,`Evaluate conditional expression.
1377
+ Exits with a status of 0 (true) or 1 (false) depending on
1378
+ the evaluation of EXPR. Expressions may be unary or binary.
1379
+ Exit Status:
1380
+ Returns success if EXPR evaluates to true; fails if EXPR evaluates to
1381
+ false or an invalid argument is given.`]],[`times`,[`times`,`Display process times.
1382
+ Prints the accumulated user and system times for the shell and all of its
1383
+ child processes.
1384
+ Exit Status:
1385
+ Always succeeds.`]],[`trap`,[`trap [-lp] [[arg] signal_spec ...]`,`Trap signals and other events.
1386
+ Defines and activates handlers to be run when the shell receives signals
1387
+ or other conditions.
1388
+ Exit Status:
1389
+ Returns success unless a SIGSPEC is invalid or an invalid option is given.`]],[`true`,[`true`,`Return a successful result.
1390
+ Exit Status:
1391
+ Always succeeds.`]],[`type`,[`type [-afptP] name [name ...]`,`Display information about command type.
1392
+ For each NAME, indicate how it would be interpreted if used as a
1393
+ command name.
1394
+
1395
+ Options:
1396
+ -a display all locations containing an executable named NAME
1397
+ -f suppress shell function lookup
1398
+ -P force a PATH search for each NAME, even if it is an alias,
1399
+ builtin, or function, and returns the name of the disk file
1400
+ that would be executed
1401
+ -p returns either the name of the disk file that would be executed,
1402
+ or nothing if \`type -t NAME' would not return \`file'
1403
+ -t output a single word which is one of \`alias', \`keyword',
1404
+ \`function', \`builtin', \`file' or \`', if NAME is an alias,
1405
+ shell reserved word, shell function, shell builtin, disk file,
1406
+ or not found, respectively
1407
+
1408
+ Exit Status:
1409
+ Returns success if all of the NAMEs are found; fails if any are not found.`]],[`typeset`,[`typeset [-aAfFgilnrtux] [-p] name[=value] ...`,`Set variable values and attributes.
1410
+ A synonym for \`declare'.`]],[`ulimit`,[`ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]`,`Modify shell resource limits.
1411
+ Provides control over the resources available to the shell and processes
1412
+ it creates, on systems that allow such control.
1413
+ Exit Status:
1414
+ Returns success unless an invalid option is supplied or an error occurs.`]],[`umask`,[`umask [-p] [-S] [mode]`,`Display or set file mode mask.
1415
+ Sets the user file-creation mask to MODE. If MODE is omitted, prints
1416
+ the current value of the mask.
1417
+ Exit Status:
1418
+ Returns success unless MODE is invalid or an invalid option is given.`]],[`unalias`,[`unalias [-a] name [name ...]`,`Remove each NAME from the list of defined aliases.
1419
+ Exit Status:
1420
+ Returns success unless a NAME is not an existing alias.`]],[`unset`,[`unset [-f] [-v] [-n] [name ...]`,`Unset values and attributes of shell variables and functions.
1421
+ For each NAME, remove the corresponding variable or function.
1422
+
1423
+ Options:
1424
+ -f treat each NAME as a shell function
1425
+ -v treat each NAME as a shell variable
1426
+ -n treat each NAME as a name reference and unset the variable itself
1427
+ rather than the variable it references
1428
+
1429
+ Without options, unset first tries to unset a variable, and if that fails,
1430
+ tries to unset a function.
1431
+ Exit Status:
1432
+ Returns success unless an invalid option is given or a NAME is read-only.`]],[`wait`,[`wait [-fn] [id ...]`,`Wait for job completion and return exit status.
1433
+ Waits for each process identified by an ID, which may be a process ID or a
1434
+ job specification, and reports its termination status.
1435
+ Exit Status:
1436
+ Returns the status of the last ID; fails if ID is invalid or an invalid
1437
+ option is given.`]]]),jL=[...AL.keys()].sort();function ML(e,t){let n=!1,r=[],i=0;for(;i<t.length;){let e=t[i];if(e===`--`){for(i++;i<t.length;)r.push(t[i]),i++;break}if(e.startsWith(`-`)&&e.length>1){for(let t=1;t<e.length;t++){let r=e[t];if(r===`s`)n=!0;else return Q(`bash: help: -${r}: invalid option
1438
+ `,2)}i++}else r.push(e),i++}if(r.length===0)return PL();let a=``,o=!1,s=``;for(let e of r){let t=NL(e);if(t.length===0){s+=`bash: help: no help topics match \`${e}'. Try \`help help' or \`man -k ${e}' or \`info ${e}'.
1439
+ `,o=!0;continue}for(let e of t){let t=AL.get(e);if(!t)continue;let[r,i]=t;a+=n?`${e}: ${r}
1440
+ `:`${e}: ${r}
1441
+ ${i}
1442
+ `}}return{exitCode:+!!o,stdout:a,stderr:s}}function NL(e){let t=U(`^${e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`.*`).replace(/\?/g,`.`)}$`);return jL.filter(e=>t.test(e))}function PL(){let e=[];e.push(`just-bash shell builtins`),e.push("These shell commands are defined internally. Type `help' to see this list."),e.push("Type `help name' to find out more about the function `name'."),e.push(``);let t=jL.slice(),n=Math.ceil(t.length/2);for(let r=0;r<n;r++){let i=t[r]||``,a=t[r+n]||``,o=i.padEnd(36);e.push(a?`${o}${a}`:i)}return dP(`${e.join(`
1443
+ `)}
1444
+ `)}function FL(e){let t=[],n=``,r=0;for(let i of e){for(let e of i)e===`(`?r++:e===`)`&&r--;n?n+=` ${i}`:n=i,r===0&&(t.push(n),n=``)}return n&&t.push(n),t}async function IL(e,t){if(t.length===0)return Q(`bash: let: expression expected
1445
+ `);let n=FL(t),r=0;for(let t of n)try{let n=Ek(`(( ${t} ))`).statements[0];if(n&&n.pipelines.length>0&&n.pipelines[0].commands.length>0){let t=n.pipelines[0].commands[0];t.type===`ArithmeticCommand`&&(r=await rP(e,t.expression.expression))}}catch(e){return Q(`bash: let: ${t}: ${e.message}
1446
+ `)}return $(``,``,+(r===0))}Wi();async function LL(e,t){let n={maxElements:e.limits.maxArrayElements,maxStringBytes:e.limits.maxStringLength};if(e.state.localScopes.length===0)return Q(`bash: local: can only be used in a function
1447
+ `);let r=e.state.localScopes[e.state.localScopes.length-1];for(e.state.localArrayScopes??=[];e.state.localArrayScopes.length<e.state.localScopes.length;)e.state.localArrayScopes.push(new Map);let i=e.state.localArrayScopes.at(-1),a=t=>{if(r.has(t)||r.set(t,e.state.env.get(t)),i&&!i.has(t)){let n=tD(e,t);i.set(t,n?$E(n):void 0)}},o=``,s=0,c=!1,l=!1,u=[];for(let e of t)if(e===`-n`)c=!0;else if(e===`-a`)l=!0;else if(e!==`-p`)if(e.startsWith(`-`)&&!e.includes(`=`))for(let t of e.slice(1))t===`n`?c=!0:t===`a`&&(l=!0);else u.push(e);if(u.length===0){let t=``,n=Array.from(r.keys()).sort();for(let r of n){let n=e.state.env.get(r);n!==void 0&&(t+=`${r}=${n}
1448
+ `)}return $(t,``,0)}for(let t of u){let i,u,d=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(d){i=d[1];let r=d[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){o+=`bash: local: \`${t}': not a valid identifier
1449
+ `,s=1;continue}Ij(e,i,`bash`);let l=tF(r,n);e.executionScope.consumeWork(l.length,`local array assignment`),a(i),dD(e,i),rD(e,i,`indexed`);for(let t=0;t<l.length;t++)Y(e,i,t,l[t]);oF(e,i),c&&KA(e,i);continue}let f=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(f){i=f[1];let t=f[2];Ij(e,i,`bash`),a(i);let r=tF(t,n);e.executionScope.consumeWork(r.length,`local array append`);let o=uD(e,i),s=0,l=e.state.env.get(i);o.length===0&&l!==void 0?(Y(e,i,0,l),e.state.env.delete(i),s=1):o.length>0&&(s=Math.max(...o)+1),sD(e,i,Array.from({length:r.length},(e,t)=>s+t));for(let t=0;t<r.length;t++)Y(e,i,s+t,r[t]);oF(e,i),c&&KA(e,i);continue}let p=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(p){i=p[1];let t=p[2];Ij(e,i,`bash`),r.has(i)||r.set(i,e.state.env.get(i));let n=e.state.env.get(i)??``;e.state.env.set(i,Hi([n,t],``,e.limits.maxStringLength,`local append`)),oF(e,i),c&&KA(e,i);continue}let m=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(m){i=m[1];let t=m[2],n=m[3];Ij(e,i,`bash`),a(i);let r;try{r=await rP(e,sO(new Tk,t).expression)}catch{let e=parseInt(t,10);r=Number.isNaN(e)?0:e}Y(e,i,r,n),oF(e,i),c&&KA(e,i);continue}if(t.includes(`=`)){let e=t.indexOf(`=`);i=t.slice(0,e),u=t.slice(e+1)}else i=t;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)){o+=`bash: local: \`${t}': not a valid identifier
1450
+ `,s=1;continue}let h=r.has(i);if(u!==void 0){let t=e.state.env.get(i);if(e.state.tempEnvBindings){let n=e.state.accessedTempEnvVars?.has(i),r=e.state.mutatedTempEnvVars?.has(i);if(!n&&!r)for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(i)){t=r.get(i);break}}}lF(e,i,t)}if(!h){let t=e.state.env.get(i);if(e.state.tempEnvBindings)for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(i)){t=r.get(i);break}}r.set(i,t),l&&a(i)}if(l&&u===void 0)dD(e,i),rD(e,i,`indexed`);else if(u!==void 0){if(Ij(e,i,`bash`),c&&u!==``&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(u)){o+=`bash: local: \`${u}': invalid variable name for name reference
1451
+ `,s=1;continue}e.state.env.set(i,u),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(i))}else{let t=e.state.tempEnvBindings?.some(e=>e.has(i));!h&&!t&&e.state.env.delete(i)}oF(e,i),c&&KA(e,i)}return $(``,o,s)}k(),j();function RL(e,t,n){let r=`
1452
+ `,i=0,a=0,o=0,s=!1,c=`MAPFILE`,l=0;for(;l<t.length;){let e=t[l];e===`-d`&&l+1<t.length?(r=t[l+1]===``?`\0`:t[l+1]||`
1453
+ `,l+=2):e===`-n`&&l+1<t.length?(i=Number.parseInt(t[l+1],10)||0,l+=2):e===`-O`&&l+1<t.length?(a=Number.parseInt(t[l+1],10)||0,l+=2):e===`-s`&&l+1<t.length?(o=Number.parseInt(t[l+1],10)||0,l+=2):e===`-t`?(s=!0,l++):e===`-u`||e===`-C`||e===`-c`?l+=2:(e.startsWith(`-`)||(c=e),l++)}if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(c))return $(``,`mapfile: ${c}: not a valid identifier
1454
+ `,1);if(!Number.isSafeInteger(a)||a<0)return $(``,`mapfile: invalid array origin
1455
+ `,1);Ij(e,c,`mapfile`);let u=n;!u&&e.state.groupStdin!==void 0&&(u=e.state.groupStdin);let d=[],f=0,p=0,m=0,h=e.limits.maxArrayElements,g=t=>{if(O(t)>e.limits.maxStringLength)throw new A(`mapfile: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);d.push(t)};for(;f<u.length;){e.executionScope.consumeWork(1,`mapfile input`);let t=u.indexOf(r,f);if(t===-1){if(f<u.length){if(m<o)m++;else if(i===0||p<i){let e=u.slice(f),t=e.indexOf(`\0`);if(t!==-1&&(e=e.substring(0,t)),d.length>=h)return $(``,`mapfile: array element limit exceeded (${h})
1456
+ `,1);g(e),p++}}break}let n=u.slice(f,t),a=n.indexOf(`\0`);if(a!==-1&&(n=n.substring(0,a)),!s&&r!==`\0`&&(n+=r),f=t+r.length,m<o){m++;continue}if(i>0&&p>=i)break;if(d.length>=h)return $(``,`mapfile: array element limit exceeded (${h})
1457
+ `,1);g(n),p++}let _=new Set(a===0?[]:e.state.arrays?.get(c)?.elements.keys()??[]);for(let e=0;e<d.length;e++)if(_.add(String(a+e)),_.size>h)return $(``,`mapfile: array element limit exceeded (${h})
1458
+ `,1);a===0&&dD(e,c);for(let t=0;t<d.length;t++)Y(e,c,a+t,d[t]);return e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=``),{...$(``,``,0),internalStdinConsumed:u.length}}k(),j();function zL(e,t,n,r=-1){let i=!1,a=`
1459
+ `,o=-1,s=-1,c=null,l=-1,u=-1,d=[],f=0,p=!1,m=(e,n)=>{let r=1;for(;r<e.length;){let d=e[r];if(d===`r`)i=!0,r++;else if(d===`s`)r++;else{if(d===`d`)return r+1<e.length?(a=e.substring(r+1),{nextArgIndex:n+1}):n+1<t.length?(a=t[n+1],{nextArgIndex:n+2}):{nextArgIndex:n+1};if(d===`n`){if(r+1<e.length){let t=e.substring(r+1);return o=Number.parseInt(t,10),(Number.isNaN(o)||o<0)&&(p=!0,o=0),{nextArgIndex:n+1}}return n+1<t.length?(o=Number.parseInt(t[n+1],10),(Number.isNaN(o)||o<0)&&(p=!0,o=0),{nextArgIndex:n+2}):{nextArgIndex:n+1}}if(d===`N`){if(r+1<e.length){let t=e.substring(r+1);return s=Number.parseInt(t,10),(Number.isNaN(s)||s<0)&&(p=!0,s=0),{nextArgIndex:n+1}}return n+1<t.length?(s=Number.parseInt(t[n+1],10),(Number.isNaN(s)||s<0)&&(p=!0,s=0),{nextArgIndex:n+2}):{nextArgIndex:n+1}}if(d===`a`)return r+1<e.length?(c=e.substring(r+1),{nextArgIndex:n+1}):n+1<t.length?(c=t[n+1],{nextArgIndex:n+2}):{nextArgIndex:n+1};if(d===`p`)return r+1<e.length?(e.substring(r+1),{nextArgIndex:n+1}):n+1<t.length?(t[n+1],{nextArgIndex:n+2}):{nextArgIndex:n+1};if(d===`u`){if(r+1<e.length){let t=e.substring(r+1);return l=Number.parseInt(t,10),Number.isNaN(l)||l<0?{nextArgIndex:-2}:{nextArgIndex:n+1}}return n+1<t.length?(l=Number.parseInt(t[n+1],10),Number.isNaN(l)||l<0?{nextArgIndex:-2}:{nextArgIndex:n+2}):{nextArgIndex:n+1}}if(d===`t`){if(r+1<e.length){let t=e.substring(r+1);return u=Number.parseFloat(t),Number.isNaN(u)&&(u=0),{nextArgIndex:n+1}}return n+1<t.length?(u=Number.parseFloat(t[n+1]),Number.isNaN(u)&&(u=0),{nextArgIndex:n+2}):{nextArgIndex:n+1}}if(d===`e`||d===`i`||d===`P`){if(d===`i`&&n+1<t.length)return{nextArgIndex:n+2};r++}else r++}}return{nextArgIndex:n+1}};for(;f<t.length;){let e=t[f];if(e.startsWith(`-`)&&e.length>1&&e!==`--`){let t=m(e,f);if(t.nextArgIndex===-1)return{stdout:``,stderr:``,exitCode:2};if(t.nextArgIndex===-2)return{stdout:``,stderr:``,exitCode:1};f=t.nextArgIndex}else if(e===`--`)for(f++;f<t.length;)d.push(t[f]),f++;else d.push(e),f++}if(p)return $(``,``,1);d.length===0&&c===null&&d.push(`REPLY`);let h=new Set;c&&h.add(c);for(let e of d)h.add(e);s>=0&&d.length===0&&h.add(`REPLY`);for(let t of h){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return $(``,`bash: read: \`${t}': not a valid identifier
1460
+ `,1);Ij(e,t,`bash`)}if(u===0){if(c)dD(e,c);else{for(let t of d)e.state.env.set(t,``);d.length===0&&e.state.env.set(`REPLY`,``)}return $(``,``,0)}if(u<0&&u!==-1)return $(``,``,1);let g=n,_=NF(e,l),v=l>0&&(_?.kind!==`dup-in`||_.sourceFd!==0);if(v){let t=VF(e,l);if(`error`in t)return $(``,t.error===`write-only`||l===1||l===2?`bash: read: read error: ${l}: Bad file descriptor
1461
+ `:`bash: read: ${l}: invalid file descriptor: Bad file descriptor
1462
+ `,1);g=t.content}else!g&&e.state.groupStdin!==void 0&&(g=e.state.groupStdin);let y=a===``?`\0`:a,b=``,x=0,S=t=>{let n=O(t);if(n>e.limits.maxStringLength-x)throw new A(`read: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`);b+=t,x+=n},ee=t=>{if(O(t)>e.limits.maxStringLength)throw new A(`read: string length limit exceeded (${e.limits.maxStringLength} bytes)`,`string_length`)},C=0,te=!0,ne=t=>{v?HF(e,l,t):r>=0?HF(e,r,t):e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=g.substring(t),e.state.groupStdinSourceFd!==void 0&&HF(e,e.state.groupStdinSourceFd,t))};if(s>=0){let t=Math.min(s,g.length);b=g.substring(0,t),ee(b),C=t,te=t>=s,ne(C);let n=d[0]||`REPLY`;e.state.env.set(n,b);for(let t=1;t<d.length;t++)e.state.env.set(d[t],``);return $(``,``,+!te)}if(o>=0){let e=0,t=0,n=!1;for(;t<g.length&&e<o;){let r=g[t];if(r===y){C=t+1,n=!0;break}if(!i&&r===`\\`&&t+1<g.length){let n=g[t+1];if(n===y&&y===`
1463
+ `){t+=2,C=t;continue}if(n===y){t+=2,e++,S(n),C=t;continue}S(n),t+=2,e++,C=t}else S(r),t++,e++,C=t}te=e>=o||n,ne(C)}else{C=0;let t=0;for(;t<g.length;){let e=g[t];if(e===y){C=t+y.length,te=!0;break}if(!i&&e===`\\`&&t+1<g.length){let n=g[t+1];if(n===`
1464
+ `){t+=2;continue}if(n===y){S(n),t+=2;continue}S(e),S(n),t+=2;continue}S(e),t++}if(t>=g.length&&(te=!1,C=t,b.length===0&&g.length===0)){for(let t of d)e.state.env.set(t,``);return c&&dD(e,c),$(``,``,1)}ne(C)}y===`
1465
+ `&&b.endsWith(`
1466
+ `)&&(b=b.slice(0,-1));let w=e=>i?e:e.replace(/\\(.)/g,`$1`);if(d.length===1&&d[0]===`REPLY`)return e.state.env.set(`REPLY`,w(b)),$(``,``,+!te);let re=MA(e.state.env),ie=e.limits.maxArrayElements;if(c){let{words:t}=BA(b,re,ie,void 0,i);dD(e,c);for(let n=0;n<t.length;n++)Y(e,c,n,w(t[n]));return $(``,``,+!te)}let ae=d.length,{words:oe,wordStarts:se}=BA(b,re,ie,ae,i);for(let t=0;t<d.length;t++){let n=d[t];if(t<d.length-1)e.state.env.set(n,w(oe[t]??``));else if(t<se.length){let r=b.substring(se[t]);r=WA(r,re,i),r=w(r),e.state.env.set(n,r)}else e.state.env.set(n,``)}return $(``,``,+!te)}j();function BL(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return Q(`bash: return: can only \`return' from a function or sourced script
1467
+ `);let n=e.state.lastExitCode;if(t.length>0){let e=t[0],r=Number.parseInt(e,10);if(e===``||Number.isNaN(r)||!/^-?\d+$/.test(e))return Q(`bash: return: ${e}: numeric argument required
1468
+ `,2);n=(r%256+256)%256}throw new xr(n)}Wi(),j();var VL=`set: usage: set [-eux] [+eux] [-o option] [+o option]
1469
+ Options:
1470
+ -e Exit immediately if a command exits with non-zero status
1471
+ +e Disable -e
1472
+ -u Treat unset variables as an error when substituting
1473
+ +u Disable -u
1474
+ -x Print commands and their arguments as they are executed
1475
+ +x Disable -x
1476
+ -o errexit Same as -e
1477
+ +o errexit Disable errexit
1478
+ -o nounset Same as -u
1479
+ +o nounset Disable nounset
1480
+ -o pipefail Return status of last failing command in pipeline
1481
+ +o pipefail Disable pipefail
1482
+ -o xtrace Same as -x
1483
+ +o xtrace Disable xtrace
1484
+ `,HL=new Map([[`e`,`errexit`],[`u`,`nounset`],[`x`,`xtrace`],[`v`,`verbose`],[`f`,`noglob`],[`C`,`noclobber`],[`a`,`allexport`],[`n`,`noexec`],[`h`,null],[`b`,null],[`m`,null],[`B`,null],[`H`,null],[`P`,null],[`T`,null],[`E`,null],[`p`,null]]),UL=new Map([[`errexit`,`errexit`],[`pipefail`,`pipefail`],[`nounset`,`nounset`],[`xtrace`,`xtrace`],[`verbose`,`verbose`],[`noclobber`,`noclobber`],[`noglob`,`noglob`],[`allexport`,`allexport`],[`noexec`,`noexec`],[`posix`,`posix`],[`vi`,`vi`],[`emacs`,`emacs`],[`notify`,null],[`monitor`,null],[`braceexpand`,null],[`histexpand`,null],[`physical`,null],[`functrace`,null],[`errtrace`,null],[`privileged`,null],[`hashall`,null],[`ignoreeof`,null],[`interactive-comments`,null],[`keyword`,null],[`onecmd`,null]]),WL=[`errexit`,`nounset`,`pipefail`,`verbose`,`xtrace`,`posix`,`allexport`,`noclobber`,`noglob`,`noexec`,`vi`,`emacs`],GL=[`braceexpand`,`errtrace`,`functrace`,`hashall`,`histexpand`,`history`,`ignoreeof`,`interactive-comments`,`keyword`,`monitor`,`nolog`,`notify`,`onecmd`,`physical`,`privileged`];function KL(e,t,n){t!==null&&(n&&(t===`vi`?e.state.options.emacs=!1:t===`emacs`&&(e.state.options.vi=!1)),e.state.options[t]=n,bD(e))}function qL(e,t){return t+1<e.length&&!e[t+1].startsWith(`-`)&&!e[t+1].startsWith(`+`)}function JL(e,t,n){let r=uD(e,n);if(r.length===0){t.append(n).append(`=()`);return}t.append(n).append(`=(`);for(let i=0;i<r.length;i++){let a=r[i],o=aD(e,n,a)??``;i>0&&t.append(` `),t.append(`[${a}]=`),t.reserve(WI(o)),t.append(GI(o))}t.append(`)`)}function YL(e,t){if(/^[a-zA-Z0-9_]+$/.test(t)){e.append(t);return}e.reserve(WI(t)),e.append(GI(t))}function XL(e,t,n){let r=fD(e,n);if(r.length===0){t.append(n).append(`=()`);return}t.append(n).append(`=(`);for(let i=0;i<r.length;i++){let a=r[i],o=aD(e,n,a)??``;i>0&&t.append(` `),t.append(`[`),YL(t,a),t.append(`]=`),t.reserve(WI(o)),t.append(GI(o))}t.append(` )`)}function ZL(e){let t=new Set,n=e.state.associativeArrays??new Set;for(let[r,i]of e.state.arrays??[])i.kind===`indexed`&&!n.has(r)&&t.add(r);return t}function QL(e){return e.state.associativeArrays??new Set}function $L(e){let t=WL.map(t=>`${t.padEnd(16)}${e.state.options[t]?`on`:`off`}`),n=GL.map(e=>`${e.padEnd(16)}off`);return`${[...t,...n].sort().join(`
1485
+ `)}
1486
+ `}function eR(e){let t=WL.map(t=>`set ${e.state.options[t]?`-o`:`+o`} ${t}`),n=GL.map(e=>`set +o ${e}`);return`${[...t,...n].sort().join(`
1487
+ `)}
1488
+ `}function tR(e,t){if(t.includes(`--help`))return dP(VL);if(t.length===0){let t=ZL(e),n=QL(e),r=[];for(let[i,a]of e.state.env)/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&(t.has(i)||n.has(i)||r.push([i,a]));let i=[...r.map(([e,t])=>({kind:`scalar`,name:e,value:t})),...Array.from(t,e=>({kind:`indexed`,name:e})),...Array.from(n,e=>({kind:`associative`,name:e}))];i.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name));let a=new Ui(e.limits.maxOutputSize,`set`);for(let t of i)e.executionScope.consumeWork(1,`set variable listing`),t.kind===`scalar`?(a.append(t.name).append(`=`),a.reserve(HI(t.value)),a.append(UI(t.value))):t.kind===`indexed`?JL(e,a,t.name):XL(e,a,t.name),a.append(`
1489
+ `);return dP(a.build())}let n=[],r=()=>n.length>0?dP(n.join(``)):uP,i=0;for(;i<t.length;){let a=t[i];if((a===`-o`||a===`+o`)&&qL(t,i)){let n=t[i+1];if(!UL.has(n)){let t=`bash: set: ${n}: invalid option name
1490
+ ${VL}`;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}KL(e,UL.get(n)??null,a===`-o`),i+=2;continue}if(a===`-o`){n.push($L(e)),i++;continue}if(a===`+o`){n.push(eR(e)),i++;continue}if(a.length>1&&(a[0]===`-`||a[0]===`+`)&&a[1]!==`-`){let r=a[0]===`-`,o=0;for(let s=1;s<a.length;s++){let c=a[s];if(c===`o`){let a=i+1+o;if(a<t.length&&!t[a].startsWith(`-`)&&!t[a].startsWith(`+`)){let n=t[a];if(!UL.has(n)){let t=`bash: set: ${n}: invalid option name
1491
+ ${VL}`;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}KL(e,UL.get(n)??null,r),o++;continue}n.push(r?$L(e):eR(e));continue}if(!HL.has(c)){let t=`bash: set: ${a[0]}${c}: invalid option
1492
+ ${VL}`;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}KL(e,HL.get(c)??null,r)}i+=1+o;continue}if(a===`--`)return nR(e,t.slice(i+1)),r();if(a===`-`){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,bD(e),i+1<t.length)return nR(e,t.slice(i+1)),r();i++;continue}if(a===`+`){i++;continue}if(a.startsWith(`-`)||a.startsWith(`+`)){let t=`bash: set: ${a}: invalid option
1493
+ ${VL}`;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}return nR(e,t.slice(i)),r()}return r()}function nR(e,t){let n=1;for(;e.state.env.has(String(n));)e.state.env.delete(String(n)),n++;for(let n=0;n<t.length;n++)e.state.env.set(String(n+1),t[n]);e.state.env.set(`#`,String(t.length)),e.state.env.set(`@`,t.join(` `)),e.state.env.set(`*`,t.join(` `))}j();function rR(e,t){let n=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<0){let n=`bash: shift: ${t[0]}: numeric argument required
1494
+ `;if(e.state.options.posix)throw new jr(1,``,n);return Q(n)}n=r}let r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(n>r){let t=`bash: shift: shift count out of range
1495
+ `;if(e.state.options.posix)throw new jr(1,``,t);return Q(t)}if(n===0)return uP;let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=i.slice(n);for(let t=1;t<=r;t++)e.state.env.delete(String(t));for(let t=0;t<a.length;t++)e.state.env.set(String(t+1),a[t]);return e.state.env.set(`#`,String(a.length)),e.state.env.set(`@`,a.join(` `)),uP}j();async function iR(e,t){let n=t;if(n.length>0&&n[0]===`--`&&(n=n.slice(1)),n.length===0)return $(``,`bash: source: filename argument required
1496
+ `,2);let r=n[0],i=null;if(r.includes(`/`)){let t=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(t)}catch{}}else{let t=(e.state.env.get(`PATH`)||``).split(`:`).filter(e=>e);for(let n of t){let t=e.fs.resolvePath(e.state.cwd,`${n}/${r}`);try{if((await e.fs.stat(t)).isDirectory)continue;i=await e.fs.readFile(t);break}catch{}}if(i===null){let t=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(t)}catch{}}}if(i===null)return Q(`bash: ${r}: No such file or directory
1497
+ `);let a=new Map;if(n.length>1){for(let t=1;t<=9;t++)a.set(String(t),e.state.env.get(String(t)));a.set(`#`,e.state.env.get(`#`)),a.set(`@`,e.state.env.get(`@`));let t=n.slice(1);e.state.env.set(`#`,String(t.length)),e.state.env.set(`@`,t.join(` `));for(let n=0;n<t.length&&n<9;n++)e.state.env.set(String(n+1),t[n]);for(let n=t.length+1;n<=9;n++)e.state.env.delete(String(n))}let o=e.state.currentSource,s=()=>{if(e.state.sourceDepth--,e.state.currentSource=o,n.length>1)for(let[t,n]of a)n===void 0?e.state.env.delete(t):e.state.env.set(t,n)};if(e.state.sourceDepth++,e.state.sourceDepth>e.limits.maxSourceDepth)throw e.state.sourceDepth--,new A(`source: maximum nesting depth (${e.limits.maxSourceDepth}) exceeded, increase executionLimits.maxSourceDepth`,`recursion`);e.state.currentSource=r;try{let t=Ek(i),n=await e.executeScript(t);return s(),n}catch(e){if(s(),e instanceof wr)throw e;if(e instanceof xr)return $(e.stdout,e.stderr,e.exitCode);if(e.name===`ParseException`)return Q(`bash: ${r}: ${e.message}
1498
+ `);throw e}}function aR(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function oR(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)}async function sR(e,t){if(oR(t))return null;try{return await rP(e,sO(new Tk,t).expression)}catch{let e=parseInt(t,10);return Number.isNaN(e)?0:e}}function cR(e,t){if(e.state.localVarStack?.has(t)){let n=uF(e,t);if(n){n.value===void 0?e.state.env.delete(t):e.state.env.set(t,n.value);let r=e.state.localVarStack?.get(t);if(!r||r.length===0)cF(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,n.scopeIndex),lR(e,t);else{let n=r[r.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,n.scopeIndex+1)}return!0}return e.state.env.delete(t),cF(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let n=e.state.localScopes.length-1;n>=0;n--){let r=e.state.localScopes[n];if(r.has(t)){let i=r.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),r.delete(t);let a=!1;for(let r=n-1;r>=0;r--)if(e.state.localScopes[r].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,r+1),a=!0;break}return a||cF(e,t),!0}}return!1}function lR(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(t)){let n=r.get(t);return n===void 0?e.state.env.delete(t):e.state.env.set(t,n),r.delete(t),!0}}return!1}async function uR(e,t){if(t.startsWith(`'`)&&t.endsWith(`'`))return t.slice(1,-1);if(t.startsWith(`"`)&&t.endsWith(`"`)){let n=t.slice(1,-1);return MN(e,new Tk().parseWordFromString(n,!0,!1))}return t.includes(`$`)?MN(e,new Tk().parseWordFromString(t,!1,!1)):t}async function dR(e,t){let n=`both`,r=``,i=0;for(let a of t){if(a===`-v`){n=`variable`;continue}if(a===`-f`){n=`function`;continue}if(n===`function`){e.state.functions.delete(a);continue}if(n===`variable`){let t=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(t){let n=t[1],a=t[2];if(Fj(e,n)){r+=`bash: unset: ${n}: cannot unset: readonly variable
1499
+ `,i=1;continue}if(a===`@`||a===`*`){lD(e,n),e.state.env.delete(n);continue}let o=e.state.associativeArrays?.has(n);if(o){cD(e,n,await uR(e,a));continue}let s=rj(e,n),c=e.state.declaredVars?.has(n);if((e.state.env.has(n)||c)&&!s&&!o){r+=`bash: unset: ${n}: not an array variable
1500
+ `,i=1;continue}let l=await sR(e,a);if(l===null&&s){r+=`bash: unset: ${a}: not a valid identifier
1501
+ `,i=1;continue}if(l===null)continue;if(l<0){let t=nj(e,n),a=t.length,o=e.state.currentLine;if(a===0){r+=`bash: line ${o}: unset: [${l}]: bad array subscript
1502
+ `,i=1;continue}let s=a+l;if(s<0){r+=`bash: line ${o}: unset: [${l}]: bad array subscript
1503
+ `,i=1;continue}let c=t[s][0];cD(e,n,c);continue}cD(e,n,l);continue}if(!aR(a)){r+=`bash: unset: \`${a}': not a valid identifier
1504
+ `,i=1;continue}let n=a;if(GA(e,a)){let t=QA(e,a);t&&t!==a&&(n=t)}if(Fj(e,n)){r+=`bash: unset: ${n}: cannot unset: readonly variable
1505
+ `,i=1;continue}lD(e,n);let o=sF(e,n);if(o!==void 0&&o!==e.state.callDepth)cR(e,n);else if(e.state.fullyUnsetLocals?.has(n))e.state.env.delete(n);else if(o!==void 0){let t=e.state.accessedTempEnvVars?.has(n),r=e.state.mutatedTempEnvVars?.has(n);if((t||r)&&e.state.localVarStack?.has(n)){let t=uF(e,n);t?t.value===void 0?e.state.env.delete(n):e.state.env.set(n,t.value):e.state.env.delete(n)}else e.state.env.delete(n)}else lR(e,n)||e.state.env.delete(n);e.state.exportedVars?.delete(n);continue}let t=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(t){let n=t[1],a=t[2];if(Fj(e,n)){r+=`bash: unset: ${n}: cannot unset: readonly variable
1506
+ `,i=1;continue}if(a===`@`||a===`*`){lD(e,n),e.state.env.delete(n);continue}let o=e.state.associativeArrays?.has(n);if(o){cD(e,n,await uR(e,a));continue}let s=rj(e,n);if(e.state.env.has(n)&&!s&&!o){r+=`bash: unset: ${n}: not an array variable
1507
+ `,i=1;continue}let c=await sR(e,a);if(c===null&&s){r+=`bash: unset: ${a}: not a valid identifier
1508
+ `,i=1;continue}if(c===null)continue;if(c<0){let t=nj(e,n),a=t.length,o=e.state.currentLine;if(a===0){r+=`bash: line ${o}: unset: [${c}]: bad array subscript
1509
+ `,i=1;continue}let s=a+c;if(s<0){r+=`bash: line ${o}: unset: [${c}]: bad array subscript
1510
+ `,i=1;continue}let l=t[s][0];cD(e,n,l);continue}cD(e,n,c);continue}if(!aR(a)){r+=`bash: unset: \`${a}': not a valid identifier
1511
+ `,i=1;continue}let o=a;if(GA(e,a)){let t=QA(e,a);t&&t!==a&&(o=t)}if(Fj(e,o)){r+=`bash: unset: ${o}: cannot unset: readonly variable
1512
+ `,i=1;continue}lD(e,o);let s=sF(e,o);if(s!==void 0&&s!==e.state.callDepth)cR(e,o);else if(e.state.fullyUnsetLocals?.has(o))e.state.env.delete(o);else if(s!==void 0){let t=e.state.accessedTempEnvVars?.has(o),n=e.state.mutatedTempEnvVars?.has(o);if((t||n)&&e.state.localVarStack?.has(o)){let t=uF(e,o);t?t.value===void 0?e.state.env.delete(o):e.state.env.set(o,t.value):e.state.env.delete(o)}else e.state.env.delete(o)}else lR(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(a)}return $(``,r,i)}Lr(),j();function fR(e,t,n,r){let i=n+O(t)+1;if(i>r)throw new A(`shopt: output size limit exceeded (${r} bytes)`,`output_size`);return e.push(t),i}var pR=[`extglob`,`dotglob`,`nullglob`,`failglob`,`globstar`,`globskipdots`,`nocaseglob`,`nocasematch`,`expand_aliases`,`lastpipe`,`xpg_echo`],mR=`autocd.cdable_vars.cdspell.checkhash.checkjobs.checkwinsize.cmdhist.compat31.compat32.compat40.compat41.compat42.compat43.compat44.complete_fullquote.direxpand.dirspell.execfail.extdebug.extquote.force_fignore.globasciiranges.gnu_errfmt.histappend.histreedit.histverify.hostcomplete.huponexit.inherit_errexit.interactive_comments.lithist.localvar_inherit.localvar_unset.login_shell.mailwarn.no_empty_cmd_completion.progcomp.progcomp_alias.promptvars.restricted_shell.shift_verbose.sourcepath`.split(`.`);function hR(e){return pR.includes(e)}function gR(e){return mR.includes(e)}function _R(e,t){let n=e.limits.maxArrayElements;if(t.length>n)throw new A(`shopt: argument limit exceeded (${n})`,`array_elements`);let r=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),i=!1,a=!1,o=!1,s=!1,c=!1,l=[],u=0;for(;u<t.length;){let e=t[u];if(e===`--`){u++;break}if(e.startsWith(`-`)&&e.length>1){for(let t=1;t<e.length;t++){let n=e[t];switch(n){case`s`:i=!0;break;case`u`:a=!0;break;case`p`:o=!0;break;case`q`:s=!0;break;case`o`:c=!0;break;default:return{exitCode:2,stdout:``,stderr:`shopt: -${n}: invalid option
1513
+ `}}}u++}else break}for(;u<t.length;)l.push(t[u]),u++;if(c)return vR(e,l,i,a,o,s);if(i&&a)return{exitCode:1,stdout:``,stderr:`shopt: cannot set and unset shell options simultaneously
1514
+ `};if(l.length===0){if(i||a){let t=[];for(let n of pR){let r=e.state.shoptOptions[n];i&&r?t.push(o?`shopt -s ${n}`:`${n} on`):a&&!r&&t.push(o?`shopt -u ${n}`:`${n} off`)}return{exitCode:0,stdout:t.length>0?`${t.join(`
1515
+ `)}
1516
+ `:``,stderr:``}}let t=[];for(let n of pR){let r=e.state.shoptOptions[n];t.push(o?`shopt ${r?`-s`:`-u`} ${n}`:`${n} ${r?`on`:`off`}`)}return{exitCode:0,stdout:`${t.join(`
1517
+ `)}
1518
+ `,stderr:``}}let d=!1,f=[],p=0,m=[],h=0;for(let t of l){if(!hR(t)&&!gR(t)){p=fR(f,`shopt: ${t}: invalid shell option name`,p,r),d=!0;continue}if(i)hR(t)&&(e.state.shoptOptions[t]=!0,CD(e));else if(a)hR(t)&&(e.state.shoptOptions[t]=!1,CD(e));else if(hR(t)){let n=e.state.shoptOptions[t];s?n||(d=!0):o?(h=fR(m,`shopt ${n?`-s`:`-u`} ${t}`,h,r),n||(d=!0)):(h=fR(m,`${t} ${n?`on`:`off`}`,h,r),n||(d=!0))}else s?d=!0:o?(h=fR(m,`shopt -u ${t}`,h,r),d=!0):(h=fR(m,`${t} off`,h,r),d=!0)}return{exitCode:+!!d,stdout:m.length>0?`${m.join(`
1519
+ `)}
1520
+ `:``,stderr:f.length>0?`${f.join(`
1521
+ `)}
1522
+ `:``}}function vR(e,t,n,r,i,a){let o=Math.min(e.limits.maxOutputSize,e.limits.maxStringLength),s=new Map([[`errexit`,`errexit`],[`pipefail`,`pipefail`],[`nounset`,`nounset`],[`xtrace`,`xtrace`],[`verbose`,`verbose`],[`posix`,`posix`],[`allexport`,`allexport`],[`noclobber`,`noclobber`],[`noglob`,`noglob`],[`noexec`,`noexec`],[`vi`,`vi`],[`emacs`,`emacs`]]),c=[`braceexpand`,`errtrace`,`functrace`,`hashall`,`histexpand`,`history`,`ignoreeof`,`interactive-comments`,`keyword`,`monitor`,`nolog`,`notify`,`onecmd`,`physical`,`privileged`],l=[...s.keys(),...c].sort();if(t.length===0){let t=[];for(let a of l){let o=c.includes(a),l=s.get(a),u=o||!l?!1:e.state.options[l];n&&!u||r&&u||t.push(i?`set ${u?`-o`:`+o`} ${a}`:`${a} ${u?`on`:`off`}`)}return{exitCode:0,stdout:t.length>0?`${t.join(`
1523
+ `)}
1524
+ `:``,stderr:``}}let u=!1,d=[],f=0,p=[],m=0;for(let l of t){let t=s.has(l),h=c.includes(l);if(!t&&!h){f=fR(d,`shopt: ${l}: invalid option name`,f,o),u=!0;continue}if(h){n||r||(a?u=!0:i?(m=fR(p,`set +o ${l}`,m,o),u=!0):(m=fR(p,`${l} off`,m,o),u=!0));continue}let g=s.get(l);if(g)if(n)g===`vi`?e.state.options.emacs=!1:g===`emacs`&&(e.state.options.vi=!1),e.state.options[g]=!0,bD(e);else if(r)e.state.options[g]=!1,bD(e);else{let t=e.state.options[g];a?t||(u=!0):i?(m=fR(p,`set ${t?`-o`:`+o`} ${l}`,m,o),t||(u=!0)):(m=fR(p,`${l} ${t?`on`:`off`}`,m,o),t||(u=!0))}}return{exitCode:+!!u,stdout:p.length>0?`${p.join(`
1525
+ `)}
1526
+ `:``,stderr:d.length>0?`${d.join(`
1527
+ `)}
1528
+ `:``}}function yR(e,t){return e===`/bin/${t}`||e===`/usr/bin/${t}`}async function bR(e,t,n){if(t.includes(`/`)){let n=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(n))return{error:`not_found`,path:n};try{let r=await e.fs.stat(n);if(r.isDirectory)return{error:`permission_denied`,path:n};let i=n.split(`/`).pop()||t,a=e.commands.get(i);return a&&yR(n,i)?{cmd:a,path:n}:r.mode&73?{script:!0,path:n}:{error:`permission_denied`,path:n}}catch{return{error:`not_found`,path:n}}}if(!n&&e.state.hashTable){let n=e.state.hashTable.get(t);if(n){try{let r=await e.fs.stat(n);if(!r.isDirectory){let i=e.commands.get(t);if(i&&yR(n,t))return{cmd:i,path:n};if(r.mode&73)return{script:!0,path:n}}}catch{}e.state.hashTable.delete(t)}}let r=(n??e.state.env.get(`PATH`)??`/usr/bin:/bin`).split(`:`);for(let n of r){if(!n)continue;let r=`${n.startsWith(`/`)?n:e.fs.resolvePath(e.state.cwd,n)}/${t}`;if(await e.fs.exists(r))try{let n=await e.fs.stat(r);if(n.isDirectory)continue;let i=!!(n.mode&73),a=e.commands.get(t),o=yR(r,t);if(a&&o)return{cmd:a,path:r};if(i&&(a&&!o||!a))return{script:!0,path:r}}catch{}}if(!await e.fs.exists(`/usr/bin`)){let n=e.commands.get(t);if(n)return{cmd:n,path:`/usr/bin/${t}`}}return null}async function xR(e,t){let n=[];if(t.includes(`/`)){let r=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(r))try{let i=await e.fs.stat(r);i.isDirectory||i.mode&73&&n.push(t)}catch{}return n}let r=(e.state.env.get(`PATH`)||`/usr/bin:/bin`).split(`:`);for(let i of r){if(!i)continue;let r=`${i.startsWith(`/`)?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(yR(r,t)&&e.commands.has(t)){n.push(r);continue}if(await e.fs.exists(r)){try{let t=await e.fs.stat(r);if(t.isDirectory||!(t.mode&73))continue}catch{continue}n.push(i.startsWith(`/`)?r:`${i}/${t}`)}}return n}Su();function SR(e){return typeof e==`object`&&!!e&&`then`in e&&typeof e.then==`function`}function CR(e,t,n,r){return((...i)=>{bu(t,n,`${r} call`);let a=e(...i);return SR(a)?a.then(e=>(bu(t,n,`${r} post-await`),e),e=>{throw bu(t,n,`${r} post-await`),e}):(bu(t,n,`${r} return`),a)})}function wR(e,t,n){let r={readFile:CR(e.readFile.bind(e),t,n,`fs.readFile`),...typeof e.readFileBytes==`function`?{readFileBytes:CR(e.readFileBytes.bind(e),t,n,`fs.readFileBytes`)}:Object.create(null),readFileBuffer:CR(e.readFileBuffer.bind(e),t,n,`fs.readFileBuffer`),writeFile:CR(e.writeFile.bind(e),t,n,`fs.writeFile`),appendFile:CR(e.appendFile.bind(e),t,n,`fs.appendFile`),exists:CR(e.exists.bind(e),t,n,`fs.exists`),stat:CR(e.stat.bind(e),t,n,`fs.stat`),mkdir:CR(e.mkdir.bind(e),t,n,`fs.mkdir`),readdir:CR(e.readdir.bind(e),t,n,`fs.readdir`),rm:CR(e.rm.bind(e),t,n,`fs.rm`),cp:CR(e.cp.bind(e),t,n,`fs.cp`),mv:CR(e.mv.bind(e),t,n,`fs.mv`),resolvePath:CR(e.resolvePath.bind(e),t,n,`fs.resolvePath`),getAllPaths:CR(e.getAllPaths.bind(e),t,n,`fs.getAllPaths`),chmod:CR(e.chmod.bind(e),t,n,`fs.chmod`),symlink:CR(e.symlink.bind(e),t,n,`fs.symlink`),link:CR(e.link.bind(e),t,n,`fs.link`),readlink:CR(e.readlink.bind(e),t,n,`fs.readlink`),lstat:CR(e.lstat.bind(e),t,n,`fs.lstat`),realpath:CR(e.realpath.bind(e),t,n,`fs.realpath`),utimes:CR(e.utimes.bind(e),t,n,`fs.utimes`)};return e.readdirWithFileTypes&&(r.readdirWithFileTypes=CR(e.readdirWithFileTypes.bind(e),t,n,`fs.readdirWithFileTypes`)),r}function TR(e,t){if(!e.requireDefenseContext)return e;let n=`command:${t}`,r=Object.getOwnPropertyDescriptors(e);r.fs={value:wR(e.fs,e.requireDefenseContext,n),enumerable:!0,configurable:!0,writable:!0};let i=Object.defineProperties(Object.create(Object.getPrototypeOf(e)),r);return e.exec&&(i.exec=CR(e.exec,e.requireDefenseContext,n,`exec`)),e.origCommand&&(i.origCommand=CR(e.origCommand,e.requireDefenseContext,n,`origCommand`)),e.fetch&&(i.fetch=CR(e.fetch,e.requireDefenseContext,n,`fetch`)),e.sleep&&(i.sleep=CR(e.sleep,e.requireDefenseContext,n,`sleep`)),e.getRegisteredCommands&&(i.getRegisteredCommands=CR(e.getRegisteredCommands,e.requireDefenseContext,n,`getRegisteredCommands`)),i}j(),ci(),Wi(),j(),j();var ER=`+ `;async function DR(e){let t=e.state.env.get(`PS4`);if(t===void 0)return ER;if(t===``)return``;let n=e.state.options.xtrace;e.state.options.xtrace=!1;try{return await MN(e,new Tk().parseWordFromString(t,!1,!1))}catch(n){if(n instanceof Tr&&!n.fatal)return t;if(n instanceof vr||n instanceof Error&&n.name===`AbortError`)throw n;return e.state.expansionStderr=`${e.state.expansionStderr||``}bash: ${t}: bad substitution
1529
+ `,t||ER}finally{e.state.options.xtrace=n}}function OR(e){return e.map(e=>kR(e)).join(` `)}function kR(e){if(e===``)return`''`;if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let t=/[\x00-\x1f\x7f]/.test(e),n=e.includes(`
1530
+ `),r=e.includes(` `),i=e.includes(`\\`),a=e.includes(`'`);if(t||n||r||i){let t=``;for(let n of e){let e=n.charCodeAt(0);t+=n===`
1531
+ `?`\\n`:n===` `?`\\t`:n===`\\`?`\\\\`:n===`'`?`'`:n===`"`?`"`:e<32||e===127?e<256?`\\x${e.toString(16).padStart(2,`0`)}`:`\\u${e.toString(16).padStart(4,`0`)}`:n}return`$'${t}'`}return a?`"${e.replace(/([\\$`"])/g,`\\$1`)}"`:`'${e}'`}async function AR(e,t,n){return e.state.options.xtrace?`${await DR(e)}${OR([t,...n])}
1532
+ `:``}async function jR(e,t,n){return e.state.options.xtrace?`${await DR(e)}${t}=${n}
1533
+ `:``}function MR(e,t,n){return Hi([t,n],``,e.limits.maxStringLength,`array assignment`)}async function NR(e,t){let n=new Map,r=``;for(let i of t.assignments){let a=i.name;if(i.array){let o=await PR(e,t,a,i.array,i.append,n);if(o.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:o.error};if(r+=o.xtraceOutput,o.continueToNext)continue}let o=i.value?await MN(e,i.value):``;if(a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:$(``,`bash: ${a}: bad array subscript
1534
+ `,1)};let s=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let a=await zR(e,t,s[1],s[2],o,i.append,n);if(a.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:a.error};if(a.continueToNext)continue}let c=await HR(e,t,a,o,i.append,n);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:n}}async function PR(e,t,n,r,i,a){let o=``;if(/\[.+\]$/.test(n))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: cannot assign list to array member
1535
+ `,1)};if(GA(e,n)){let t=$A(e,n);if(t===void 0||t===``)throw new wr(1,``,``);let r=QA(e,n);if(r&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(r))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: cannot assign list to array member
1536
+ `,1)}}if(Fj(e,n)){if(t.name)return o+=`bash: ${n}: readonly variable
1537
+ `,{continueToNext:!0,xtraceOutput:o};let r=Ij(e,n);if(r)return{continueToNext:!1,xtraceOutput:``,error:r}}let s=e.state.associativeArrays?.has(n),c=tD(e,n),l=c?$E(c):void 0,u=e.state.env.get(n),d=()=>{e.state.arrays??=new Map,l?e.state.arrays.set(n,l):e.state.arrays.delete(n),u===void 0?e.state.env.delete(n):e.state.env.set(n,u)},f=FR(r),p=()=>{dD(e,n),e.state.env.delete(n)};try{s&&f?await IR(e,t,n,r,i,p,e=>{o+=e}):f?await LR(e,n,r,i,p):await RR(e,n,r,i,p)}catch(e){throw d(),e}if(t.name){a.set(n,e.state.env.get(n));let t=`(${r.map(e=>gD(e)).join(` `)})`;e.state.env.set(n,t)}return{continueToNext:!0,xtraceOutput:o}}function FR(e){return e.some(e=>{if(e.parts.length>=2){let t=e.parts[0],n=e.parts[1];if(t.type!==`Glob`||!t.pattern.startsWith(`[`))return!1;if(t.pattern===`[`&&(n.type===`DoubleQuoted`||n.type===`SingleQuoted`)){if(e.parts.length<3)return!1;let t=e.parts[2];return t.type===`Literal`?t.value.startsWith(`]=`)||t.value.startsWith(`]+=`):!1}return n.type===`Literal`?n.value.startsWith(`]`)?n.value.startsWith(`]=`)||n.value.startsWith(`]+=`):t.pattern.endsWith(`]`)?n.value.startsWith(`=`)||n.value.startsWith(`+=`):!1:!1}return!1})}async function IR(e,t,n,r,i,a,o){let s=[];for(let t of r){if(s.length>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let n=mD(t);if(n){let{key:t,valueParts:r,append:i}=n,a;r.length>0?(a=await MN(e,{type:`Word`,parts:r}),r.every(e=>e.type===`Literal`||e.type===`TildeExpansion`)&&(a=cM(e,a))):a=``,s.push({type:`keyed`,key:t,value:a,append:i})}else{let n=await MN(e,t);s.push({type:`invalid`,expandedValue:n})}}e.executionScope.consumeWork(s.length,`associative array assignment`),i||a();for(let r of s)if(r.type===`keyed`)if(r.append){let t=aD(e,n,r.key)??``;Y(e,n,r.key,MR(e,t,r.value),`associative`)}else Y(e,n,r.key,r.value,`associative`);else o(`bash: line ${t.line??e.state.currentLine??1}: ${n}: ${r.expandedValue}: must use subscript when assigning associative array
1538
+ `)}async function LR(e,t,n,r,i){let a=[],o=0;for(let t of n){let n=mD(t);if(n){if(o>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);let{key:t,valueParts:r,append:i}=n,s;r.length>0?(s=await MN(e,{type:`Word`,parts:r}),r.every(e=>e.type===`Literal`||e.type===`TildeExpansion`)&&(s=cM(e,s))):s=``,a.push({type:`keyed`,indexExpr:t,value:s,append:i}),o++}else{let n=await VN(e,t);if(n.values.length>e.limits.maxArrayElements-o)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push({type:`non-keyed`,values:n.values}),o+=n.values.length}}e.executionScope.consumeWork(o,`indexed array assignment`),r||i();let s=0;for(let n of a)if(n.type===`keyed`){let r;try{r=await rP(e,sO(new Tk,n.indexExpr).expression,!1)}catch{if(/^-?\d+$/.test(n.indexExpr))r=Number.parseInt(n.indexExpr,10);else{let t=e.state.env.get(n.indexExpr);r=t?Number.parseInt(t,10):0,Number.isNaN(r)&&(r=0)}}if(n.append){let i=aD(e,t,r)??``;Y(e,t,r,MR(e,i,n.value))}else Y(e,t,r,n.value);s=r+1}else for(let r of n.values)Y(e,t,s++,r)}async function RR(e,t,n,r,i){let a=[];for(let t of n){let n=await VN(e,t);for(let t of n.values){if(a.length>=e.limits.maxArrayElements)throw new A(`array element limit exceeded (${e.limits.maxArrayElements})`,`array_elements`);a.push(t)}}let o=0;if(e.executionScope.consumeWork(a.length,`indexed array assignment`),r){let n=nj(e,t);if(n.length>0)o=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1;else{let n=e.state.env.get(t);n!==void 0&&(Y(e,t,0,n),e.state.env.delete(t),o=1)}}else i();for(let n=0;n<a.length;n++)Y(e,t,o+n,a[n])}async function zR(e,t,n,r,i,a,o){let s=n;if(GA(e,n)){let t=QA(e,n);if(t&&t!==n){if(t.includes(`[`))return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: \`${t}': not a valid identifier
1539
+ `,1)};s=t}}if(Fj(e,s)){if(t.name)return{continueToNext:!0,xtraceOutput:``};let n=Ij(e,s);if(n)return{continueToNext:!1,xtraceOutput:``,error:n}}let c=e.state.associativeArrays?.has(s),l;if(c)l=await BR(e,r);else{let t=await VR(e,s,r);if(t.error)return{continueToNext:!1,xtraceOutput:``,error:t.error};l=String(t.index)}let u=a?MR(e,aD(e,s,l)||``,i):i;return t.name||Y(e,s,l,u,c?`associative`:`indexed`),{continueToNext:!0,xtraceOutput:``}}async function BR(e,t){let n;if(t.startsWith(`'`)&&t.endsWith(`'`))n=t.slice(1,-1);else if(t.startsWith(`"`)&&t.endsWith(`"`)){let r=t.slice(1,-1);n=await MN(e,new Tk().parseWordFromString(r,!0,!1))}else n=t.includes(`$`)?await MN(e,new Tk().parseWordFromString(t,!1,!1)):t;return n}async function VR(e,t,n){let r=n;n.startsWith(`"`)&&n.endsWith(`"`)&&n.length>=2&&(r=n.slice(1,-1));let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{i=await rP(e,sO(new Tk,r).expression,!1)}catch(r){if(r instanceof wr)throw r;if(r instanceof Tr){let t=`bash: line ${e.state.currentLine}: ${n}: ${r.message}
1540
+ `;if(r.fatal)throw new wr(1,``,t);return{index:0,error:$(``,t,1)}}let i=e.state.currentLine;return{index:0,error:$(``,`bash: line ${i}: ${t}[${n}]: bad array subscript
1541
+ `,1)}}Number.isNaN(i)&&(i=0)}if(i<0){let r=nj(e,t);if(r.length===0){let r=e.state.currentLine;return{index:0,error:$(``,`bash: line ${r}: ${t}[${n}]: bad array subscript
1542
+ `,1)}}if(i=Math.max(...r.map(([e])=>typeof e==`number`?e:0))+1+i,i<0){let r=e.state.currentLine;return{index:0,error:$(``,`bash: line ${r}: ${t}[${n}]: bad array subscript
1543
+ `,1)}}}return{index:i}}async function HR(e,t,n,r,i,a){let o=``,s=n,c=null;if(GA(e,n)){let t=ej(e,n,r);if(t===void 0)return{continueToNext:!1,xtraceOutput:``,error:$(``,`bash: ${n}: circular name reference
1544
+ `,1)};if(t===null)return{continueToNext:!0,xtraceOutput:``};s=t;let i=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);i&&(c={arrayName:i[1],subscriptExpr:i[2]},s=i[1])}if(Fj(e,s)){if(t.name)return o+=`bash: ${s}: readonly variable
1545
+ `,{continueToNext:!0,xtraceOutput:o};let n=Ij(e,s);if(n)return{continueToNext:!1,xtraceOutput:``,error:n}}let l;if(lL(e,s))try{let t=new Tk;if(i){let n=sO(t,`(${e.state.env.get(s)||`0`}) + (${r})`);l=String(await rP(e,n.expression))}else{let n=sO(t,r);l=String(await rP(e,n.expression))}}catch{l=`0`}else{let t=rj(e,s)?aD(e,s,0):e.state.env.get(s);l=i?MR(e,t||``,r):r}l=mL(e,s,l),o+=await jR(e,s,l);let u;return c?u=await UR(e,c):rj(e,s)&&(u=`0`),t.name?u===void 0&&(a.set(s,e.state.env.get(s)),e.state.env.set(s,l)):(u===void 0?e.state.env.set(s,l):Y(e,s,u,l),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(s)),e.state.tempEnvBindings?.some(e=>e.has(s))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(s))),{continueToNext:!1,xtraceOutput:o}}async function UR(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return BR(e,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{i=await rP(e,sO(new Tk,r).expression,!1)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let t=nj(e,n);t.length>0&&(i=Math.max(...t.map(e=>e[0]))+1+i)}return String(i)}async function WR(e,t,n,r){let i=!1,a=!1,o=!1,s=!1,c=!1,l=[];for(let e of t)if(e.startsWith(`-`)&&e.length>1)for(let t of e.slice(1))t===`t`?i=!0:t===`p`?a=!0:t===`P`?o=!0:t===`a`?s=!0:t===`f`&&(c=!0);else l.push(e);let u=``,d=``,f=0,p=!1,m=!1;for(let t of l){let l=!1;if(o){if(s){let e=await r(t);if(e.length>0){for(let t of e)u+=`${t}
1546
+ `;p=!0,l=!0}}else{let e=await n(t);e&&(u+=`${e}
1547
+ `,p=!0,l=!0)}l||(m=!0);continue}let f=!c&&e.state.functions.has(t);if(s&&f){if(!a)if(i)u+=`function
1548
+ `;else{let n=e.state.functions.get(t),r=n?GR(t,n):`${t} is a function
1549
+ `;u+=r}l=!0}let h=e.state.env.get(`BASH_ALIAS_${t}`);if(!(h!==void 0&&(s||!l)&&(a||(u+=i?`alias
1550
+ `:`${t} is aliased to \`${h}'
1551
+ `),l=!0,!s)||mF.has(t)&&(s||!l)&&(a||(u+=i?`keyword
1552
+ `:`${t} is a shell keyword
1553
+ `),l=!0,!s))){if(!s&&f&&!l){if(!a)if(i)u+=`function
1554
+ `;else{let n=e.state.functions.get(t),r=n?GR(t,n):`${t} is a function
1555
+ `;u+=r}l=!0;continue}if(!(hF.has(t)&&(s||!l)&&(a||(u+=i?`builtin
1556
+ `:`${t} is a shell builtin
1557
+ `),l=!0,!s))){if(s){let e=await r(t);for(let n of e)u+=a?`${n}
1558
+ `:i?`file
1559
+ `:`${t} is ${n}
1560
+ `,p=!0,l=!0}else if(!l){let e=await n(t);e&&(u+=a?`${e}
1561
+ `:i?`file
1562
+ `:`${t} is ${e}
1563
+ `,p=!0,l=!0)}if(!l&&(m=!0,!i&&!a)){let n=!0;if(t.includes(`/`)){let r=e.fs.resolvePath(e.state.cwd,t);await e.fs.exists(r)&&(n=!1)}n&&(d+=`bash: type: ${t}: not found
1564
+ `)}}}}return f=a?m&&!p?1:0:+!!m,$(u,d,f)}function GR(e,t){let n;return n=t.body.type===`Group`?t.body.body.map(e=>KR(e)).join(`; `):KR(t.body),`${e} is a function
1565
+ ${e} ()
1566
+ {
1567
+ ${n}
1568
+ }
1569
+ `}function KR(e){if(Array.isArray(e))return e.map(e=>KR(e)).join(`; `);if(e.type===`Statement`){let t=[];for(let n=0;n<e.pipelines.length;n++){let r=e.pipelines[n];t.push(YR(r)),e.operators[n]&&t.push(e.operators[n])}return t.join(` `)}if(e.type===`SimpleCommand`){let t=e,n=[];t.name&&n.push(qR(t.name));for(let e of t.args)n.push(qR(e));return n.join(` `)}return e.type===`Group`?`{ ${e.body.map(e=>KR(e)).join(`; `)}; }`:`...`}function qR(e){return e.parts.map(JR).join(``)}function JR(e){switch(e.type){case`Literal`:return e.value;case`Escaped`:return`\\${e.value}`;case`SingleQuoted`:return`'${e.value}'`;case`DoubleQuoted`:return`"${e.parts.map(JR).join(``)}"`;default:return Pk(X.word([e]))}}function YR(e){let t=e.commands.map(e=>KR(e));return(e.negated?`! `:``)+t.join(` | `)}async function XR(e,t,n,r){let i=``,a=``,o=0;for(let n of t){if(!n){o=1;continue}let t=e.state.env.get(`BASH_ALIAS_${n}`);if(t!==void 0)i+=r?`${n} is an alias for "${t}"
1570
+ `:`alias ${n}='${t}'
1571
+ `;else if(mF.has(n))i+=r?`${n} is a shell keyword
1572
+ `:`${n}
1573
+ `;else if(hF.has(n))i+=r?`${n} is a shell builtin
1574
+ `:`${n}
1575
+ `;else if(e.state.functions.has(n))i+=r?`${n} is a function
1576
+ `:`${n}
1577
+ `;else if(n.includes(`/`)){let t=e.fs.resolvePath(e.state.cwd,n),s=!1;if(await e.fs.exists(t))try{let a=await e.fs.stat(t);a.isDirectory||a.mode&73&&(i+=r?`${n} is ${n}
1578
+ `:`${n}
1579
+ `,s=!0)}catch{}s||(r&&(a+=`${n}: not found
1580
+ `),o=1)}else if(e.commands.has(n)){let t=(e.state.env.get(`PATH`)??`/usr/bin:/bin`).split(`:`),a=null;for(let r of t){if(!r)continue;let t=`${r}/${n}`;try{let n=await e.fs.stat(t);if(!n.isDirectory&&n.mode&73){a=t;break}}catch{}}a||=`/usr/bin/${n}`,i+=r?`${n} is ${a}
1581
+ `:`${a}
1582
+ `}else r&&(a+=`${n}: not found
1583
+ `),o=1}return $(i,a,o)}async function ZR(e,t){if(t.includes(`/`)){let n=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(n)){try{let t=await e.fs.stat(n);if(t.isDirectory||!(t.mode&73))return null}catch{return null}return t}return null}let n=(e.state.env.get(`PATH`)??`/usr/bin:/bin`).split(`:`);for(let r of n){if(!r)continue;let n=`${r.startsWith(`/`)?r:e.fs.resolvePath(e.state.cwd,r)}/${t}`;if(await e.fs.exists(n)){try{let t=await e.fs.stat(n);if(t.isDirectory||!(t.mode&73))continue}catch{continue}return`${r}/${t}`}}if(e.commands.has(t)){for(let e of n)if(e===`/usr/bin`||e===`/bin`)return`${e}/${t}`;return`/usr/bin/${t}`}return null}function QR(e,t){let n=!0,r=e.signal?new AbortController:void 0,i=new WeakMap,a=()=>{if(!n)throw new kr(``,`bash: ${t} used its context after cancellation
1584
+ `)},o=e=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return e;let n=i.get(e);if(n!==void 0)return n;if(typeof e==`object`&&AE(e))return e;if(e instanceof Uint8Array){let t=new Uint8Array(e);return i.set(e,t),t}if(e instanceof ArrayBuffer){let t=e.slice(0);return i.set(e,t),t}if(e instanceof Promise){let t=e.then(e=>(a(),o(e)));return i.set(e,t),t}if(typeof e==`function`){let t=function(...t){return a(),o(Reflect.apply(e,this,t))};return i.set(e,t),t}let r=Object.getPrototypeOf(e);if(Array.isArray(e)||r===Object.prototype||r===null){let t=Array.isArray(e)?[]:Object.create(r);i.set(e,t);let n=Object.getOwnPropertyDescriptors(e);for(let t of Object.values(n)){if(`value`in t){let n=t.value;t.value=typeof n==`function`?(...t)=>(a(),o(Reflect.apply(n,e,t))):o(n)}if(t.get){let n=t.get;t.get=()=>(a(),o(Reflect.apply(n,e,[])))}if(t.set){let n=t.set;t.set=t=>{a(),Reflect.apply(n,e,[t])}}}return Object.defineProperties(t,n),t}let s=new Map,c=new Jb(e,{get(e,n){if(a(),n===`constructor`||n===`prototype`||n===`__proto__`)throw Error(`${t}: unsafe context property access`);let r=Reflect.get(e,n,e);if(typeof r!=`function`)return o(r);if(s.has(n))return s.get(n);let i=(...t)=>(a(),o(Reflect.apply(r,e,t)));return s.set(n,i),i},set(e,n,r){if(a(),n===`constructor`||n===`prototype`||n===`__proto__`)throw Error(`${t}: unsafe context property access`);return Reflect.set(e,n,r,e)}});return i.set(e,c),c},s=e=>o(e),c=e=>e&&((...t)=>(a(),o(e(...t)))),l=e=>({value:e,enumerable:!0,configurable:!0,writable:!0}),u=Object.getOwnPropertyDescriptors(e);return Object.assign(u,{fs:l(s(e.fs)),env:l(s(e.env)),limits:l(Object.freeze({...e.limits})),exportedEnv:l(e.exportedEnv?Object.freeze({...e.exportedEnv}):void 0),executionScope:l(e.executionScope?s(e.executionScope):void 0),fileDescriptors:l(e.fileDescriptors?s(e.fileDescriptors):void 0),coverage:l(e.coverage?s(e.coverage):void 0),assignShellVariable:l(c(e.assignShellVariable)),exec:l(c(e.exec)),origCommand:l(c(e.origCommand)),execWithInheritedStdin:l(c(e.execWithInheritedStdin)),fetch:l(c(e.fetch)),getRegisteredCommands:l(c(e.getRegisteredCommands)),sleep:l(c(e.sleep)),trace:l(c(e.trace)),invokeTool:l(c(e.invokeTool)),signal:l(r?.signal)}),{context:Object.defineProperties(Object.create(Object.getPrototypeOf(e)),u),revoke(){n=!1,r?.signal.aborted||r?.abort(new kr(``,`bash: ${t} context revoked
1585
+ `))}}}async function $R(e,t,n,r,i,a){let o=i.remainingTimeMs()??t.limits.maxExecutionTimeMs,s=t.limits.maxExtensionCleanupTimeMs,c,l,u,d=Promise.resolve().then(e).then(e=>({kind:`result`,result:e}),e=>({kind:`error`,error:e})),f=new Promise(e=>{let t=()=>{n(),e({kind:`abort`})};l=t,a?.addEventListener(`abort`,t,{once:!0}),a?.aborted&&t(),c=Yn(()=>{n(),e({kind:`deadline`})},o)});try{let e=await Promise.race([d,f]);if(e.kind===`result`)return e.result;if(e.kind===`error`)throw e.error;n();let t=await Promise.race([d.then(()=>!0),new Promise(e=>{u=Yn(()=>e(!1),s)})]),a=e.kind===`deadline`?new kr(``,`bash: ${r} exceeded its execution deadline
1586
+ `):new kr(``,`bash: execution aborted
1587
+ `);throw t||i.poisonAfterAbort(a),a}finally{n(),Xn(c),Xn(u),l&&a?.removeEventListener(`abort`,l)}}async function ez(e,t,n,r,i,a,o,s,c=!1){let{ctx:l,runCommand:u}=e;if(l.coverage&&hF.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t===`export`)return DL(l,n);if(t===`unset`)return dR(l,n);if(t===`exit`)return EL(l,n);if(t===`local`)return LL(l,n);if(t===`set`)return tR(l,n);if(t===`break`)return hP(l,n);if(t===`continue`)return $I(l,n);if(t===`return`)return BL(l,n);if(t===`eval`&&l.state.options.posix)return TL(l,n,i,c);if(t===`shift`)return rR(l,n);if(t===`getopts`)return OL(l,n);if(t===`compgen`)return bI(l,n);if(t===`complete`)return YI(l,n);if(t===`compopt`)return QI(l,n);if(t===`pushd`)return await SL(l,n);if(t===`popd`)return CL(l,n);if(t===`dirs`)return wL(l,n);if(t===`source`||t===`.`)return iR(l,n);if(t===`read`)return zL(l,n,i,s);if(t===`mapfile`||t===`readarray`)return RL(l,n,i);if(t===`declare`||t===`typeset`)return _L(l,n);if(t===`readonly`)return vL(l,n);if(!a){let e=l.state.functions.get(t);if(e)return mI(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
1588
+ `,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
1589
+ `,2);let n=Number(t);if(!Number.isSafeInteger(n)||n>255)return Q(`bash: invalid internal pipeline status restore
1590
+ `,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 TL(l,n,i,c);if(t===`cd`)return await gP(l,n);if(t===`:`||t===`true`)return uP;if(t===`false`)return fP(!1);if(t===`let`)return IL(l,n);if(t===`command`)return tz(e,n,i,c);if(t===`builtin`)return nz(e,n,i,c);if(t===`shopt`)return _R(l,n);if(t===`exec`){if(n.length===0)return uP;let[e,...t]=n;return{...await u(e,t,[],i,!1,!1,-1,c),internalProducerOmitsShellPrefix:!0}}if(t===`wait`)return uP;if(t===`type`)return await WR(l,n,e=>ZR(l,e),e=>xR(l,e));if(t===`hash`)return kL(l,n);if(t===`help`)return ML(l,n);if(t===`[`||t===`test`){let e=n;if(t===`[`){if(n[n.length-1]!==`]`)return Q(`[: missing \`]'
1591
+ `,2);e=n.slice(0,-1)}return PP(l,e)}return null}async function tz(e,t,n,r=!1){let{ctx:i,runCommand:a}=e;if(t.length===0)return uP;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 uP;if(c||s)return await XR(i,l,c,s);let[u,...d]=l;return a(u,d,[],n,!0,o,-1,r)}async function nz(e,t,n,r=!1){let{runCommand:i}=e;if(t.length===0)return uP;let a=t;if(a[0]===`--`&&(a=a.slice(1),a.length===0))return uP;let o=a[0];if(o!==`__just_bash_tee_restore`&&!hF.has(o))return Q(`bash: builtin: ${o}: not a shell builtin
1592
+ `);let[,...s]=a;return i(o,s,[],n,!0,!1,-1,r)}async function rz(e,t,n,r,i){let{ctx:a,buildExportedEnv:o,executeUserScript:s}=e,c=await bR(a,t,i?`/usr/bin:/bin`:void 0);if(!c)return lP(t)?Q(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
1593
+ `,127):Q(`bash: ${t}: command not found
1594
+ `,127);if(`error`in c)return c.error===`permission_denied`?Q(`bash: ${t}: Permission denied
1595
+ `,126):Q(`bash: ${t}: No such file or directory
1596
+ `,127);if(`script`in c)return t.includes(`/`)||(a.state.hashTable||(a.state.hashTable=new Map),a.state.hashTable.set(t,c.path)),await s(c.path,n,r);let{cmd:l,path:u}=c;t.includes(`/`)||(a.state.hashTable||(a.state.hashTable=new Map),a.state.hashTable.set(t,u));let d=r||a.state.groupStdin||``,f=!1,p=o();a.state.fileDescriptors??=new Map;let m={fs:a.fs,fsIdentity:kE(a.fs),cwd:a.state.cwd,env:a.state.env,assignShellVariable:async(e,t,n)=>{if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))throw Error(`${e}: not a valid identifier`);let r=n===void 0?e:`${e}[${n}]`,i=ej(a,e,t);if(i===void 0)throw Error(`${e}: circular name reference`);if(i===null)return;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)(?:\[(.*)\])?$/);if(!o)throw Error(`${r}: not a valid identifier`);let s=o[1],c=o[2]??n;if(Fj(a,e)||Fj(a,s))throw Error(`${s}: readonly variable`);if(c===void 0)a.state.env.set(s,t);else{let e=a.state.associativeArrays?.has(s)?`associative`:`indexed`;if(e===`associative`){Y(a,s,c,t,e);return}let n=await VR(a,s,c);if(n.error)throw new wr(n.error.exitCode,n.error.stdout,n.error.stderr);Y(a,s,n.index,t,e)}},exportedEnv:p,get stdin(){return f=!0,d},limits:a.limits,executionScope:l.internalIsExtension?BE(a.executionScope):a.executionScope,exec:(e,t)=>a.execFn(e,t,!1),execWithInheritedStdin:(e,t)=>a.execFn(e,{...t,stdin:d,stdinKind:`bytes`},!0),fetch:a.fetch,getRegisteredCommands:()=>Array.from(a.commands.keys()),sleep:a.sleep,trace:a.trace,fileDescriptors:a.state.fileDescriptors,xpgEcho:a.state.shoptOptions.xpg_echo,coverage:a.coverage,signal:a.state.signal,requireDefenseContext:a.requireDefenseContext,jsBootstrapCode:a.jsBootstrapCode,invokeTool:a.invokeTool},h=l.internalOriginalCommand,g=()=>{};if(h){let e=Object.getOwnPropertyDescriptors(m);e.executionScope={value:a.executionScope,enumerable:!0,configurable:!0,writable:!0};let t=QR(Object.defineProperties(Object.create(Object.getPrototypeOf(m)),e),h.name),n=TR(t.context,h.name);g=t.revoke,m.origCommand=e=>{let t=()=>h.execute(e,n);return h.trusted?Kn.runTrustedAsync(t):Kn.runUntrustedAsync(t)}}let _=QR(m,t),v=TR(_.context,t),y=()=>{_.revoke(),g()};try{let e=()=>xu(a.requireDefenseContext,`command`,`${t} execution`,()=>l.execute(n,v)),i=()=>$R(e,v,y,t,a.executionScope,a.state.signal),o=l.trusted?await Kn.runTrustedAsync(i):await i();return{...o,internalStdinConsumed:o.internalStdinConsumed??(f?r.length:0)}}catch(e){if(e instanceof A||e instanceof kr||e instanceof D)throw e;return Q(`${t}: ${$i(si(e))}
1597
+ `)}}k(),j(),yg();async function iz(e,t){let n=e.state.inCondition;e.state.inCondition=!0;let r=new vg(e.executionScope,`condition`),i=0;try{for(let n of t){let t=await e.executeStatement(n);r.appendResult(t),i=t.exitCode}}catch(e){throw r.prependTo(e),e}finally{e.state.inCondition=n}return r.build(i)}ci(),j(),ci();function az(e,t,n,r){if(e instanceof yr)return t+=e.stdout,n+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=n,{action:`rethrow`,stdout:t,stderr:n,error:e}):{action:`break`,stdout:t,stderr:n};if(e instanceof br)return t+=e.stdout,n+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=n,{action:`rethrow`,stdout:t,stderr:n,error:e}):{action:`continue`,stdout:t,stderr:n};if(e instanceof xr||e instanceof Sr||e instanceof wr||e instanceof A)return e.prependOutput(t,n),{action:`rethrow`,stdout:t,stderr:n,error:e};let i=si(e);return{action:`error`,stdout:t,stderr:`${n}${i}
1598
+ `,exitCode:1}}function oz(e,t){return e===void 0?t===``?{owns:!1}:{owns:!0,stdin:t}:{owns:!0,stdin:e}}var sz=class{ctx;stdoutChunks=[];stderrChunks=[];totalBytes=0;constructor(e){this.ctx=e}append(e,t){let n=O(e)+O(t);n>this.ctx.limits.maxOutputSize-this.totalBytes&&pP(`total output size exceeded (>${this.ctx.limits.maxOutputSize} bytes), increase executionLimits.maxOutputSize`,`output_size`),e&&this.stdoutChunks.push(e),t&&this.stderrChunks.push(t),this.totalBytes+=n}appendUnaccounted(e,t){this.ctx.executionScope.appendOutput(`stdout`,e,`control-flow`),this.ctx.executionScope.appendOutput(`stderr`,t,`control-flow`),this.append(e,t)}replace(e,t){this.stdoutChunks=[],this.stderrChunks=[],this.totalBytes=0,this.append(e,t)}get stdout(){return this.stdoutChunks.join(``)}get stderr(){return this.stderrChunks.join(``)}build(e){let t=this.stdout,n=this.stderr;return{stdout:t,stderr:n,exitCode:e,internalOutputAccounting:{stdout:O(t),stderr:O(n)}}}};async function cz(e,t,n){let r=0;try{for(let i of t){let t=await e.executeStatement(i);n.append(t.stdout,t.stderr),r=t.exitCode}}catch(e){if(_r(e)||e instanceof Sr||e instanceof wr||e instanceof A||e instanceof Ar)throw e.prependOutput(n.stdout,n.stderr),e;return n.appendUnaccounted(``,`${si(e)}
1599
+ `),n.build(1)}return n.build(r)}async function lz(e,t){return dI(e,t.redirections,``,()=>uz(e,t))}async function uz(e,t){let n=new sz(e);for(let r of t.clauses){let t=await iz(e,r.condition);if(n.append(t.stdout,t.stderr),t.exitCode===0)return cz(e,r.body,n)}return t.elseBody?cz(e,t.elseBody,n):n.build(0)}async function dz(e,t){return dI(e,t.redirections,``,()=>fz(e,t))}async function fz(e,t){let n=new sz(e),r=0,i=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return Q(`bash: \`${t.variable}': not a valid identifier
1600
+ `);let a=[];if(t.words===null)a=(e.state.env.get(`@`)||``).split(` `).filter(Boolean);else if(t.words.length===0)a=[];else try{for(let n of t.words){let t=await VN(e,n);lM(a,t.values,e.limits.maxArrayElements,`for-loop expansion`)}}catch(e){if(e instanceof Dr)return{stdout:``,stderr:e.stderr,exitCode:1};throw e}e.state.loopDepth++;try{for(let o of a){i++,i>e.limits.maxLoopIterations&&pP(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,n.stdout,n.stderr),e.state.env.set(t.variable,o);try{for(let i of t.body){let t=await e.executeStatement(i);n.append(t.stdout,t.stderr),r=t.exitCode}}catch(t){let r=az(t,n.stdout,n.stderr,e.state.loopDepth);if(n.replace(r.stdout,r.stderr),r.action===`break`)break;if(r.action===`continue`)continue;if(r.action===`error`)return n.build(r.exitCode??1);throw r.error}}}finally{e.state.loopDepth--}return n.build(r)}async function pz(e,t){return dI(e,t.redirections,``,()=>mz(e,t))}async function mz(e,t){let n=t.line;n!==void 0&&(e.state.currentLine=n);let r=new sz(e),i=0,a=0;t.init&&await rP(e,t.init.expression),e.state.loopDepth++;try{for(;a++,a>e.limits.maxLoopIterations&&pP(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,r.stdout,r.stderr),!(t.condition&&(n!==void 0&&(e.state.currentLine=n),await rP(e,t.condition.expression)===0));){try{for(let n of t.body){let t=await e.executeStatement(n);r.append(t.stdout,t.stderr),i=t.exitCode}}catch(n){let i=az(n,r.stdout,r.stderr,e.state.loopDepth);if(r.replace(i.stdout,i.stderr),i.action===`break`)break;if(i.action===`continue`){t.update&&await rP(e,t.update.expression);continue}if(i.action===`error`)return r.build(i.exitCode??1);throw i.error}t.update&&await rP(e,t.update.expression)}}finally{e.state.loopDepth--}return r.build(i)}async function hz(e,t,n=``){return dI(e,t.redirections,n,r=>gz(e,t,n,r))}async function gz(e,t,n,r){let i=new sz(e),a=0,o=0,s=oz(r.stdin,n),c=e.state.groupStdin;s.owns&&(e.state.groupStdin=s.stdin),e.state.loopDepth++;try{for(;;){o++,o>e.limits.maxLoopIterations&&pP(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,i.stdout,i.stderr);let n=0,r=!1,s=!1,c=e.state.inCondition;e.state.inCondition=!0;try{for(let r of t.condition){let t=await e.executeStatement(r);i.append(t.stdout,t.stderr),n=t.exitCode}}catch(t){if(t instanceof yr){if(i.append(t.stdout,t.stderr),t.levels>1&&e.state.loopDepth>1)throw t.levels--,t.stdout=i.stdout,t.stderr=i.stderr,e.state.inCondition=c,t;r=!0}else if(t instanceof br){if(i.append(t.stdout,t.stderr),t.levels>1&&e.state.loopDepth>1)throw t.levels--,t.stdout=i.stdout,t.stderr=i.stderr,e.state.inCondition=c,t;s=!0}else throw e.state.inCondition=c,t}finally{e.state.inCondition=c}if(r)break;if(!s){if(n!==0)break;try{for(let n of t.body){let t=await e.executeStatement(n);i.append(t.stdout,t.stderr),a=t.exitCode}}catch(t){let n=az(t,i.stdout,i.stderr,e.state.loopDepth);if(i.replace(n.stdout,n.stderr),n.action===`break`)break;if(n.action===`continue`)continue;if(n.action===`error`)return i.build(n.exitCode??1);throw n.error}}}}finally{e.state.loopDepth--,s.owns&&(e.state.groupStdin=c)}return i.build(a)}async function _z(e,t,n=``){return dI(e,t.redirections,n,r=>vz(e,t,n,r))}async function vz(e,t,n,r){let i=new sz(e),a=0,o=0,s=oz(r.stdin,n),c=e.state.groupStdin;s.owns&&(e.state.groupStdin=s.stdin),e.state.loopDepth++;try{for(;;){o++,o>e.limits.maxLoopIterations&&pP(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,`iterations`,i.stdout,i.stderr);let n=await iz(e,t.condition);if(i.append(n.stdout,n.stderr),n.exitCode===0)break;try{for(let n of t.body){let t=await e.executeStatement(n);i.append(t.stdout,t.stderr),a=t.exitCode}}catch(t){let n=az(t,i.stdout,i.stderr,e.state.loopDepth);if(i.replace(n.stdout,n.stderr),n.action===`break`)break;if(n.action===`continue`)continue;if(n.action===`error`)return i.build(n.exitCode??1);throw n.error}}}finally{e.state.loopDepth--,s.owns&&(e.state.groupStdin=c)}return i.build(a)}async function yz(e,t){return dI(e,t.redirections,``,()=>bz(e,t))}async function bz(e,t){let n=new sz(e),r=0,i=await MN(e,t.word),a=!1;for(let o=0;o<t.items.length;o++){let s=t.items[o],c=a;if(!a)for(let t of s.patterns){let n=await MN(e,t);AN(t)&&(n=_j(n));let r=e.state.shoptOptions.nocasematch,a=e.state.shoptOptions.extglob;if(BP(i,n,r,a,e.limits.maxCallDepth)){c=!0;break}}if(c){let t=await cz(e,s.body,n);if(n.replace(t.stdout,t.stderr),r=t.exitCode,s.terminator===`;;`)break;a=s.terminator===`;&`}else a=!1}return n.build(r)}j();function xz(e,t){if(e.parts.length!==1)return!1;let n=e.parts[0];return n.type===`Literal`&&t.includes(n.value)}k(),Yb(),j();async function Sz(e,t,n){let r=t.timed?Kb():0,i=``,a=uP,o=0,s=[],c=``,l=0,u=t.commands.length>1,d=e.state.lastArg,f=e.state.groupStdin,p=e.state.groupStdinSourceFd;for(let r=0;r<t.commands.length;r++){let d=t.commands[r],m=r===t.commands.length-1,h=r===0;u&&(e.state.lastArg=``,e.state.groupStdin=h?f:void 0,e.state.groupStdinSourceFd=h?p:void 0);let g=u&&(!m||!e.state.shoptOptions.lastpipe),_=g?new Map(e.state.env):null,v=g?eD(e.state.arrays):null,y,b=e.executionScope.outputBytesUsed;try{e.state.commandCount=e.executionScope.chargeCommand(),y=await n(d,i)}catch(n){if(n instanceof Er)y={stdout:n.stdout,stderr:n.stderr,exitCode:1};else if(n instanceof wr&&t.commands.length>1)y={stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode};else if(n instanceof Sr&&t.commands.length>1)y={stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode};else throw _&&(e.state.env=_,e.state.arrays=v??new Map),n}finally{u&&(h&&(f=e.state.groupStdin,p=e.state.groupStdinSourceFd),e.state.groupStdin=f,e.state.groupStdinSourceFd=p)}if(_&&(e.state.env=_,e.state.arrays=v??new Map),y=e.executionScope.accountResult(y,`pipeline`,e.executionScope.outputBytesUsed-b),!m){let n=t.pipeStderr?.[r]??!1,i=y.internalOutputAccounting?.stdout??0,a=n?y.internalOutputAccounting?.stderr??0:0;VE(e.executionScope,i+a,`pipeline`),y={...y,internalOutputAccounting:{stdout:0,stderr:n?0:y.internalOutputAccounting?.stderr??0}}}s.push(y.exitCode),y.exitCode!==0&&(o=y.exitCode),m?a=y:(t.pipeStderr?.[r]??!1?i=sr(y.stderr)+dr(y):(i=dr(y),c+=y.stderr,l+=y.internalOutputAccounting?.stderr??0),a={stdout:``,stderr:``,exitCode:y.exitCode})}c&&(a={...a,stderr:c+a.stderr,internalOutputAccounting:{stdout:a.internalOutputAccounting?.stdout??0,stderr:l+(a.internalOutputAccounting?.stderr??0)}});let m=t.commands.length>1||t.commands.length===1&&t.commands[0].type===`SimpleCommand`,h=a.internalPipeStatusOverride??s;if(m){dD(e,`PIPESTATUS`);for(let t=0;t<h.length;t++)Y(e,`PIPESTATUS`,t,String(h[t]))}if(e.state.options.pipefail&&o!==0&&(a={...a,exitCode:o}),t.negated&&(a={...a,exitCode:+(a.exitCode===0)}),t.timed){let e=(Kb()-r)/1e3,n=Math.floor(e/60),i=e%60,o;o=t.timePosix?`real ${e.toFixed(2)}
1601
+ user 0.00
1602
+ sys 0.00
1603
+ `:`
1604
+ real ${`${n}m${i.toFixed(3)}s`}
1605
+ user 0m0.000s
1606
+ sys 0m0.000s
1607
+ `,a={...a,stderr:a.stderr+o}}u&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=d),a=e.executionScope.accountResult(a,`pipeline`);let{internalPipeStatusOverride:g,..._}=a;return _}yg(),j(),ci();function Cz(e){return e?{...e,options:e.options?[...e.options]:void 0,actions:e.actions?[...e.actions]:void 0}:void 0}function wz(e){return e?new Map(Array.from(e,([e,t])=>[e,Cz(t)])):void 0}function Tz(e){if(!e)return;let t=new Map,n=new Map;for(let[r,i]of e){let e=t.get(i);e||(e=new Set(i),t.set(i,e)),n.set(r,e)}return n}function Ez(e){return e?.map(e=>new Map(Array.from(e,([e,t])=>[e,t?{kind:t.kind,elements:new Map(t.elements)}:void 0])))}function Dz(e){return e?new Map(Array.from(e,([e,t])=>[e,t.map(e=>({...e}))])):void 0}function Oz(e){let t={env:e.env,arrays:e.arrays,cwd:e.cwd,previousDir:e.previousDir,lastExitCode:e.lastExitCode,lastArg:e.lastArg,currentLine:e.currentLine,options:e.options,shoptOptions:e.shoptOptions,fileDescriptors:e.fileDescriptors,inputFds:e.inputFds,fdAliases:e.fdAliases,closedStandardFds:e.closedStandardFds,nextFd:e.nextFd,readonlyVars:e.readonlyVars,associativeArrays:e.associativeArrays,namerefs:e.namerefs,boundNamerefs:e.boundNamerefs,invalidNamerefs:e.invalidNamerefs,integerVars:e.integerVars,lowercaseVars:e.lowercaseVars,uppercaseVars:e.uppercaseVars,exportedVars:e.exportedVars,tempExportedVars:e.tempExportedVars,localExportedVars:e.localExportedVars,declaredVars:e.declaredVars,localScopes:e.localScopes,localArrayScopes:e.localArrayScopes,localVarDepth:e.localVarDepth,localVarStack:e.localVarStack,fullyUnsetLocals:e.fullyUnsetLocals,tempEnvBindings:e.tempEnvBindings,mutatedTempEnvVars:e.mutatedTempEnvVars,accessedTempEnvVars:e.accessedTempEnvVars,functions:e.functions,callDepth:e.callDepth,sourceDepth:e.sourceDepth,callLineStack:e.callLineStack,funcNameStack:e.funcNameStack,sourceStack:e.sourceStack,currentSource:e.currentSource,inCondition:e.inCondition,loopDepth:e.loopDepth,parentHasLoopContext:e.parentHasLoopContext,errexitSafe:e.errexitSafe,directoryStack:e.directoryStack,hashTable:e.hashTable,completionSpecs:e.completionSpecs,defaultCompletionSpec:e.defaultCompletionSpec,emptyCompletionSpec:e.emptyCompletionSpec,groupStdin:e.groupStdin,groupStdinSourceFd:e.groupStdinSourceFd,bashPid:e.bashPid,expansionExitCode:e.expansionExitCode,expansionStderr:e.expansionStderr};e.env=new Map(e.env),e.arrays=eD(e.arrays),e.options={...e.options},e.shoptOptions={...e.shoptOptions},e.fileDescriptors=e.fileDescriptors?new Map(e.fileDescriptors):void 0,e.inputFds=e.inputFds?new Set(e.inputFds):void 0,e.fdAliases=Tz(e.fdAliases),e.closedStandardFds=e.closedStandardFds?new Set(e.closedStandardFds):void 0,e.readonlyVars=new Set(e.readonlyVars),e.associativeArrays=new Set(e.associativeArrays),e.namerefs=new Set(e.namerefs),e.boundNamerefs=new Set(e.boundNamerefs),e.invalidNamerefs=new Set(e.invalidNamerefs),e.integerVars=new Set(e.integerVars),e.lowercaseVars=new Set(e.lowercaseVars),e.uppercaseVars=new Set(e.uppercaseVars),e.exportedVars=new Set(e.exportedVars),e.tempExportedVars=new Set(e.tempExportedVars),e.localExportedVars=e.localExportedVars?.map(e=>new Set(e)),e.declaredVars=new Set(e.declaredVars),e.localScopes=e.localScopes.map(e=>new Map(e)),e.localArrayScopes=Ez(e.localArrayScopes),e.localVarDepth=e.localVarDepth?new Map(e.localVarDepth):void 0,e.localVarStack=Dz(e.localVarStack),e.fullyUnsetLocals=e.fullyUnsetLocals?new Map(e.fullyUnsetLocals):void 0,e.tempEnvBindings=e.tempEnvBindings?.map(e=>new Map(e)),e.mutatedTempEnvVars=e.mutatedTempEnvVars?new Set(e.mutatedTempEnvVars):void 0,e.accessedTempEnvVars=e.accessedTempEnvVars?new Set(e.accessedTempEnvVars):void 0,e.functions=new Map(e.functions),e.callLineStack=e.callLineStack?[...e.callLineStack]:void 0,e.funcNameStack=e.funcNameStack?[...e.funcNameStack]:void 0,e.sourceStack=e.sourceStack?[...e.sourceStack]:void 0,e.directoryStack=e.directoryStack?[...e.directoryStack]:void 0,e.hashTable=e.hashTable?new Map(e.hashTable):void 0,e.completionSpecs=wz(e.completionSpecs),e.defaultCompletionSpec=Cz(e.defaultCompletionSpec),e.emptyCompletionSpec=Cz(e.emptyCompletionSpec);let n=!1;return()=>{n||(n=!0,Object.assign(e,t))}}async function kz(e,t,n,r,i=!1){let a=e.state.loopDepth,o=new Map;for(let t of e.state.fileDescriptors?.keys()??[]){let n=NF(e,t);n&&o.set(t,n)}let s=Oz(e.state);e.state.parentHasLoopContext=a>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++;try{return await dI(e,t.redirections,n,a=>Az(e,t,a.stdin??n,r,i||a.stdin!==void 0))}finally{let t=new Map;for(let[n,r]of o){let i=NF(e,n),a=r.kind===`input`&&i?.kind===`input`?r.content.length-i.content.length:r.kind===`readwrite`&&i?.kind===`readwrite`&&r.path===i.path?i.position-r.position:0;if(a<=0)continue;let o=Math.min(...kF(e,n));t.set(o,Math.max(t.get(o)??0,a))}s();for(let[n,r]of t)HF(e,n,r)}}async function Az(e,t,n,r,i){(i||n)&&(e.state.groupStdin=n);let a=new vg(e.executionScope,`subshell`),o=0;try{for(let e of t.body){let t=await r(e);a.appendResult(t),o=t.exitCode}}catch(e){if(e instanceof A)throw a.prependTo(e),e;return e instanceof Ar||e instanceof yr||e instanceof br?(a.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),a.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),a.build(0)):e instanceof wr||e instanceof xr||e instanceof Sr?(a.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),a.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),a.build(e.exitCode)):(a.append(`stderr`,`${si(e)}
1608
+ `),a.build(1))}return a.build(o)}async function jz(e,t,n,r,i=!1){return dI(e,t.redirections,n,a=>Mz(e,t,n,r,i,a))}async function Mz(e,t,n,r,i,a){let o=new vg(e.executionScope,`group`),s=0,c=a.stdin??n,l=i||n!==``||a.stdin!==void 0,u=e.state.groupStdin;l&&(e.state.groupStdin=c);let d=()=>{(l||u!==void 0&&e.state.groupStdin===void 0)&&(e.state.groupStdin=u)};try{for(let e of t.body){let t=await r(e);o.appendResult(t),s=t.exitCode}}catch(e){if(d(),e instanceof A)throw o.prependTo(e),e;if(_r(e)||e instanceof Sr||e instanceof wr)throw e.prependOutput(o.stdout,o.stderr),e;return o.append(`stderr`,`${si(e)}
1609
+ `),o.build(1)}return d(),o.build(s)}async function Nz(e,t,n,r,i){let a;try{a=await e.fs.readFile(t)}catch{return Q(`bash: ${t}: No such file or directory
1610
+ `,127)}if(a.startsWith(`#!`)){let e=a.indexOf(`
1611
+ `);e!==-1&&(a=a.slice(e+1))}let o=e.state.loopDepth,s=Oz(e.state);e.state.parentHasLoopContext=o>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,r&&(e.state.groupStdin=r),e.state.currentSource=t,e.state.env.set(`0`,t),e.state.env.set(`#`,String(n.length)),e.state.env.set(`@`,n.join(` `)),e.state.env.set(`*`,n.join(` `));for(let t=0;t<n.length&&t<9;t++)e.state.env.set(String(t+1),n[t]);for(let t=n.length+1;t<=9;t++)e.state.env.delete(String(t));try{let e=await i(new Tk().parse(a));return s(),e}catch(e){if(s(),e instanceof wr)return $(e.stdout,e.stderr,e.exitCode);if(e instanceof A)throw e;if(e.name===`ParseException`)return Q(`bash: ${t}: ${e.message}
1612
+ `);throw e}}function Pz(e){throw TypeError(`Unsupported command node: ${JSON.stringify(e)}`)}var Fz=class{ctx;constructor(e,t){this.ctx={state:t,fs:e.fs,commands:e.commands,limits:e.limits,executionScope:e.executionScope,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep,trace:e.trace,coverage:e.coverage,requireDefenseContext:e.requireDefenseContext??!1,jsBootstrapCode:e.jsBootstrapCode,invokeTool:e.invokeTool}}assertDefenseContext(e){if(!this.ctx.requireDefenseContext||Kn.isInSandboxedContext())return;let t=`interpreter ${e} attempted outside defense context`;throw new D(t,{timestamp:Date.now(),type:`missing_defense_context`,message:t,path:`DefenseInDepthBox.context`,stack:Error().stack,executionId:Kn.getCurrentExecutionId()})}buildExportedEnv(){let e=this.ctx.state.exportedVars,t=this.ctx.state.tempExportedVars,n=new Set;if(e)for(let t of e)n.add(t);if(t)for(let e of t)n.add(e);if(n.size===0)return Object.create(null);let r=Object.create(null);for(let e of n){let t=this.ctx.state.env.get(e);t!==void 0&&(r[e]=t)}return r}async executeScript(e){this.assertDefenseContext(`execution`);let t=0,n=new vg(this.ctx.executionScope,`script`);for(let r of e.statements)try{let e=await this.executeStatement(r);n.appendResult(e,fr(e)),t=e.exitCode,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t))}catch(e){if(e instanceof wr)throw e.prependOutput(n.stdout,n.stderr),e;if(e instanceof jr)return n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=e.exitCode,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t)),{...n.build(t),exitCode:t,env:rd(this.ctx.state.env)};if(e instanceof A)throw n.prependTo(e),e;if(e instanceof Sr)return n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=e.exitCode,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t)),{...n.build(t),exitCode:t,env:rd(this.ctx.state.env)};if(e instanceof Cr||e instanceof Er)return n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=1,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t)),{...n.build(t),exitCode:t,env:rd(this.ctx.state.env)};if(e instanceof Tr){n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=1,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t));continue}if(e instanceof Or){n.append(`stdout`,e.stdout,e.internalOutputAccounting.stdout),n.append(`stderr`,e.stderr,e.internalOutputAccounting.stderr),t=1,this.ctx.state.lastExitCode=t,this.ctx.state.env.set(`?`,String(t));continue}if(e instanceof yr||e instanceof br){if(this.ctx.state.loopDepth>0)throw e.prependOutput(n.stdout,n.stderr),e;n.append(`stdout`,e.stdout),n.append(`stderr`,e.stderr);continue}throw e instanceof xr&&e.prependOutput(n.stdout,n.stderr),e}return{...n.build(t),env:rd(this.ctx.state.env)}}async executeUserScript(e,t,n=``){return Nz(this.ctx,e,t,n,e=>this.executeScript(e))}async executeStatement(e){if(this.assertDefenseContext(`statement`),this.ctx.state.signal?.aborted)throw new kr;if(e.deferredError)throw new QD(e.deferredError.message,e.line??1,1);if(this.ctx.state.options.noexec)return uP;this.ctx.state.errexitSafe=!1;let t=new vg(this.ctx.executionScope,`statement`);this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&e.sourceText&&t.append(`stderr`,`${e.sourceText}
1613
+ `);let n=0,r=-1,i=!1;try{for(let a=0;a<e.pipelines.length;a++){let o=e.pipelines[a],s=a>0?e.operators[a-1]:null;if(s===`&&`&&n!==0||s===`||`&&n===0)continue;let c=await this.executePipeline(o);t.appendResult(c,fr(c)),n=c.exitCode,r=a,i=o.negated,this.ctx.state.lastExitCode=n,this.ctx.state.env.set(`?`,String(n))}}catch(e){throw t.prependTo(e),e}let a=r<e.pipelines.length-1,o=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||i||o,this.ctx.state.options.errexit&&n!==0&&r===e.pipelines.length-1&&!i&&!this.ctx.state.inCondition&&!o){let e=new Sr(n);throw e.prependOutput(t.stdout,t.stderr),e}return t.build(n)}async executePipeline(e){return Sz(this.ctx,e,(e,t)=>this.executeCommand(e,t))}async executeCommand(e,t,n=!1){let r=wN(this.ctx),i;try{i=await this.executeCommandInner(e,t,n)}catch(e){throw await EN(this.ctx,r).catch(()=>{}),e}let a=await EN(this.ctx,r);return!a.stdout&&!a.stderr?i:{...i,stdout:a.stdout?dr(i)+a.stdout:i.stdout,stdoutKind:a.stdout?`bytes`:i.stdoutKind,stderr:i.stderr+a.stderr}}async executeCommandInner(e,t,n){switch(this.assertDefenseContext(`command`),this.ctx.coverage?.hit(`bash:cmd:${e.type}`),e.type){case`SimpleCommand`:return this.executeSimpleCommand(e,t);case`If`:return lz(this.ctx,e);case`For`:return dz(this.ctx,e);case`CStyleFor`:return pz(this.ctx,e);case`While`:return hz(this.ctx,e,t);case`Until`:return _z(this.ctx,e,t);case`Case`:return yz(this.ctx,e);case`Subshell`:return this.executeSubshell(e,t,n);case`Group`:return this.executeGroup(e,t,n);case`FunctionDef`:return pI(this.ctx,e);case`ArithmeticCommand`:return this.executeArithmeticCommand(e);case`ConditionalCommand`:return this.executeConditionalCommand(e);default:return Pz(e)}}async executeSimpleCommand(e,t){let n;try{return await this.executeSimpleCommandInner(e,t,e=>{n=e})}catch(e){if(n?.finish(),e instanceof Dr)return Q(e.stderr);throw e}}async executeSimpleCommandInner(e,t,n){if(e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.shoptOptions.expand_aliases&&e.name){let t=e,n=0;for(;;){let e=this.expandAlias(t);if(e===t)break;if(n>=this.ctx.limits.maxCallDepth)throw new A(`alias expansion depth limit exceeded (${this.ctx.limits.maxCallDepth})`,`recursion`);n++,t=e}this.aliasExpansionStack.clear(),t!==e&&(e=t)}this.ctx.state.expansionStderr=``;let r=await NR(this.ctx,e);if(r.error)return r.error;let i=r.tempAssignments,a=r.xtraceOutput,o=()=>{for(let[e,t]of i)t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t)};if(!e.name){if(e.redirections.length>0){let r=cI(this.ctx,e.redirections,ZF);n(r);let i=await r.prepare(t);if(i.error){if(o(),!i.errorCause)return r.finish(),i.error;try{return lI(i)}finally{r.finish()}}let s=$(``,a,0),c=await fI(this.ctx,s,e.redirections,i.targets,i.dupSources,i.standardRoutes);return r.finish(),c}this.ctx.state.lastArg=``;let r=(this.ctx.state.expansionStderr||``)+a;return this.ctx.state.expansionStderr=``,$(``,r,this.ctx.state.lastExitCode)}let s=e.name&&xz(e.name,[`local`,`declare`,`typeset`,`export`,`readonly`]),c=Array.from(i.keys());if(c.length>0&&!s){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let e of c)this.ctx.state.tempExportedVars.add(e)}let l=await MN(this.ctx,e.name),u=[],d=[],f=(e,t)=>{if(u.length>=this.ctx.limits.maxArrayElements)throw new A(`expanded argument element limit exceeded (${this.ctx.limits.maxArrayElements})`,`array_elements`);u.push(e),d.push(t)};if(xz(e.name,[`local`,`declare`,`typeset`,`export`,`readonly`])&&(l===`local`||l===`declare`||l===`typeset`||l===`export`||l===`readonly`))for(let t of e.args){let e=await oP(this.ctx,t);if(e)f(e,!0);else{let e=await sP(this.ctx,t);if(e!==null)f(e,!0);else{let e=await VN(this.ctx,t);for(let t of e.values)f(t,e.quoted)}}}else for(let t of e.args){let e=await VN(this.ctx,t);for(let t of e.values)f(t,e.quoted)}let p=e.name.parts.every(e=>e.type===`CommandSubstitution`||e.type===`ParameterExpansion`||e.type===`ArithmeticExpansion`);!l&&p&&u.length>0&&(l=u.shift(),d.shift());let m=cI(this.ctx,e.redirections,l===`exec`?QF:XF);n(m);let h=await m.prepare(t);if(h.error)return o(),h.errorCause?lI(h):(m.finish(),h.error);let g=h.stdinSourceFd,_=h.stdin!==void 0;if(h.stdin!==void 0&&(t=h.stdin),!l)return p?(m.finish(),$(``,``,this.ctx.state.lastExitCode)):(m.finish(),Q(`bash: : command not found
1614
+ `,127));if(l===`exec`&&(u.length===0||u[0]===`--`)){for(let[e,t]of i)t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t);if(this.ctx.state.tempExportedVars)for(let e of i.keys())this.ctx.state.tempExportedVars.delete(e);return m.finish(),uP}if(this.ctx.state.extraArgs){let e=this.ctx.state.extraArgs;this.ctx.state.extraArgs=void 0;for(let t of e)f(t,!0)}let v=await AR(this.ctx,l,u);i.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(i)));let y,b=null;try{y=await this.runCommand(l,u,d,t,!1,!1,g,_)}catch(e){if(e instanceof yr||e instanceof br)b=e,y=uP;else throw e}g>=0&&l!==`read`&&HF(this.ctx,g,y.internalStdinConsumed??0);let x=a+v;if(x&&(y={...y,stderr:x+y.stderr}),y=await fI(this.ctx,y,e.redirections,h.targets,h.dupSources,h.standardRoutes,y.internalProducerCommand??l,y.internalProducerOmitsShellPrefix),m.finish(),b)throw b;if(u.length>0){let e=u[u.length-1];if((l===`declare`||l===`local`||l===`typeset`)&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(e)){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);t&&(e=t[1])}this.ctx.state.lastArg=e}else this.ctx.state.lastArg=l;let S=pF(l)&&l!==`unset`&&l!==`eval`;if(!this.ctx.state.options.posix||!S)for(let[e,t]of i)this.ctx.state.fullyUnsetLocals?.has(e)||(t===void 0?this.ctx.state.env.delete(e):this.ctx.state.env.set(e,t));if(this.ctx.state.tempExportedVars)for(let e of i.keys())this.ctx.state.tempExportedVars.delete(e);return i.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(y={...y,stderr:this.ctx.state.expansionStderr+y.stderr},this.ctx.state.expansionStderr=``),y}async runCommand(e,t,n,r,i=!1,a=!1,o=-1,s=!1){let c={ctx:this.ctx,runCommand:(e,t,n,r,i,a,o,s)=>this.runCommand(e,t,n,r,i,a,o,s),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(e,t,n)=>this.executeUserScript(e,t,n)},l=await ez(c,e,t,n,r,i,a,o,s);return l===null?{...await rz(c,e,t,r,a),internalProducerCommand:e}:l.internalProducerCommand===void 0?{...l,internalProducerCommand:e}:l}aliasExpansionStack=new Set;expandAlias(e){return mA({env:this.ctx.state.env,limits:this.ctx.limits},e,this.aliasExpansionStack)}async findCommandInPath(e){return xR(this.ctx,e)}async executeSubshell(e,t=``,n=!1){return kz(this.ctx,e,t,e=>this.executeStatement(e),n)}async executeGroup(e,t=``,n=!1){return jz(this.ctx,e,t,e=>this.executeStatement(e),n)}async executeArithmeticCommand(e){return e.line!==void 0&&(this.ctx.state.currentLine=e.line),dI(this.ctx,e.redirections,``,async()=>{try{let t=fP(await rP(this.ctx,e.expression.expression)!==0);return this.ctx.state.expansionStderr&&(t={...t,stderr:this.ctx.state.expansionStderr+t.stderr},this.ctx.state.expansionStderr=``),t}catch(e){return Q(`bash: arithmetic expression: ${e.message}
1615
+ `)}})}async executeConditionalCommand(e){return e.line!==void 0&&(this.ctx.state.currentLine=e.line),dI(this.ctx,e.redirections,``,async()=>{try{let t=fP(await NP(this.ctx,e.expression));return this.ctx.state.expansionStderr&&(t={...t,stderr:this.ctx.state.expansionStderr+t.stderr},this.ctx.state.expansionStderr=``),t}catch(e){let t=e instanceof Tr?1:2;return Q(`bash: conditional expression: ${e.message}
1616
+ `,t)}})}};bn(),ir(),qn(),nr();function Iz(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Lz(e){let t=Iz(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}var Rz=3;function zz(e){let t=e;for(let e=0;e<Rz;e++){if(t.includes(`\\`)||t.includes(`;`)||/%(?![0-9a-f]{2})/i.test(t))return!0;let e=t.toLowerCase();if(e.includes(`%2f`)||e.includes(`%2e`)||e.includes(`%5c`)||e.includes(`%3b`))return!0;let n;try{n=decodeURIComponent(t)}catch{return!0}if(n===t)return!1;t=n}return t.includes(`%`)}function Bz(e,t){return t===`/`||t===``?!0:t.endsWith(`/`)?e.startsWith(t):e===t||e.startsWith(`${t}/`)}function Vz(e,t){let n=Iz(e);if(!n)return!1;let r=Lz(t);return!r||n.origin!==r.origin||r.pathPrefix!==`/`&&r.pathPrefix!==``&&zz(n.pathname)?!1:Bz(n.pathname,r.pathPrefix)}function Hz(e){return typeof e==`string`?e:e.url}function Uz(e,t){return!t||t.length===0?!1:t.some(t=>Vz(e,Hz(t)))}function Wz(e){let t=Gz(e);if(t===`localhost`||t.endsWith(`.localhost`))return!0;let n=qz(t);if(n)return Yz(n);let r=Jz(t);return r?Xz(r):!1}function Gz(e){let t=e.trim().toLowerCase();return t.startsWith(`[`)&&t.endsWith(`]`)?t.slice(1,-1):t}function Kz(e){if(!e)return null;let t=10,n=e;if(n.startsWith(`0x`)||n.startsWith(`0X`)?(t=16,n=n.slice(2)):n.length>1&&n.startsWith(`0`)&&(t=8),!n||t===16&&!/^[0-9a-fA-F]+$/.test(n)||t===10&&!/^\d+$/.test(n)||t===8&&!/^[0-7]+$/.test(n))return null;let r=Number.parseInt(n,t);return!Number.isFinite(r)||r<0?null:r}function qz(e){let t=e.split(`.`);if(t.length===0||t.length>4)return null;let n=t.map(e=>Kz(e));if(n.some(e=>e===null))return null;let r=n;if(t.length===1){let e=r[0];return e>4294967295?null:[e>>>24&255,e>>>16&255,e>>>8&255,e&255]}if(t.length===2){let[e,t]=r;return e>255||t>16777215?null:[e,t>>>16&255,t>>>8&255,t&255]}if(t.length===3){let[e,t,n]=r;return e>255||t>255||n>65535?null:[e,t,n>>>8&255,n&255]}let[i,a,o,s]=r;return i>255||a>255||o>255||s>255?null:[i,a,o,s]}function Jz(e){let t=e,n=null;if(t.includes(`.`)){let e=t.lastIndexOf(`:`);if(e<0)return null;let r=qz(t.slice(e+1));if(!r)return null;n=r,t=t.slice(0,e)}let r=t.includes(`::`)?t.split(`::`).length-1:0;if(r>1)return null;let[i,a]=t.split(`::`),o=i?i.split(`:`).filter(Boolean):[],s=a?a.split(`:`).filter(Boolean):[],c=e=>/^[0-9a-f]{1,4}$/i.test(e)?Number.parseInt(e,16):null,l=o.map(c),u=s.map(c);if(l.some(e=>e===null)||u.some(e=>e===null))return null;let d=n?2:0,f=l.length+u.length+d,p=0;if(r===1){if(p=8-f,p<0)return null}else if(f!==8)return null;let m=[...l,...Array(p).fill(0),...u];return n&&(m.push(n[0]<<8|n[1]),m.push(n[2]<<8|n[3])),m.length===8?m:null}function Yz(e){let[t,n]=e;return t===127||t===10||t===172&&n>=16&&n<=31||t===192&&n===168||t===169&&n===254||t===0||t===100&&n>=64&&n<=127||t===198&&(n===18||n===19)||t===192&&n===0&&e[2]===0||t===192&&n===0&&e[2]===2||t===198&&n===51&&e[2]===100||t===203&&n===0&&e[2]===113||t>=240}function Xz(e){return e.every(e=>e===0)||e.slice(0,7).every(e=>e===0)&&e[7]===1||(e[0]&65472)==65152||(e[0]&65024)==64512?!0:e[0]===0&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===65535?Yz([e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255]):e[0]===8193&&e[1]===3512?!0:e[0]===100&&e[1]===65435&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===0?Yz([e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255]):e[0]===100&&e[1]===65435&&e[2]===1||e[0]===8194&&Yz([e[1]>>>8&255,e[1]&255,e[2]>>>8&255,e[2]&255])}function Zz(e){let t=[];for(let n of e){if(typeof n!=`string`&&(typeof n!=`object`||!n||!(`url`in n)||typeof n.url!=`string`)){t.push(`Invalid allow-list entry: must be a string URL or an object with a "url" string property`);continue}let e=Hz(n);if(!Iz(e)){t.push(`Invalid URL in allow-list: "${e}" - must be a valid URL with scheme and host (e.g., "https://example.com")`);continue}let r=new URL(e);if(r.protocol!==`http:`&&r.protocol!==`https:`){t.push(`Only http and https URLs are allowed in allow-list: "${e}"`);continue}if(!r.hostname){t.push(`Allow-list entry must include a hostname: "${e}"`);continue}if(r.pathname!==`/`&&r.pathname!==``&&zz(r.pathname)){t.push(`Allow-list entry contains ambiguous path separators: "${e}"`);continue}(r.search||r.hash)&&t.push(`Query strings and fragments are ignored in allow-list entries: "${e}"`)}return t}var Qz=class extends Error{constructor(){super(`DNS pinning is unavailable in this runtime`),this.name=`DnsPinningUnavailableError`}},$z=async e=>{throw new Qz},eB=class extends Error{constructor(e,t){super(`Network access denied: ${t??`URL not in allow-list`}: ${e}`),this.name=`NetworkAccessDeniedError`}},tB=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name=`TooManyRedirectsError`}},nB=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name=`RedirectNotAllowedError`}},rB=class extends Error{constructor(e,t){super(`HTTP method '${e}' not allowed. Allowed methods: ${t.join(`, `)}`),this.name=`MethodNotAllowedError`}},iB=class extends Error{constructor(e){super(`Response body too large (max: ${e} bytes)`),this.name=`ResponseTooLargeError`}};function aB(e){return new Promise((t,n)=>{_n(e,{all:!0},(e,r)=>{e?n(e):t(r)})})}var oB=20,sB=3e4,cB=10485760,lB=[`GET`,`HEAD`],uB=new Set([`GET`,`HEAD`,`OPTIONS`]),dB=new Set([301,302,303,307,308]);function fB(e){return e.reason instanceof Error?e.reason:new DOMException(`The operation was aborted`,`AbortError`)}function pB(e){if(e?.aborted)throw fB(e)}async function mB(e,t){if(!t)return e;if(t.aborted)throw e.catch(()=>{}),fB(t);let n,r=new Promise((e,r)=>{n=()=>r(fB(t)),t.addEventListener(`abort`,n,{once:!0})});try{return await Promise.race([e,r])}finally{n&&t.removeEventListener(`abort`,n)}}async function hB(e,t){try{return await mB(e,t)}catch(n){throw t?.aborted&&e.then(e=>Kn.runTrustedAsync(()=>e.close())).catch(()=>{}),n}}async function gB(e){e.body&&!e.body.locked&&await e.body.cancel()}function _B(e){let t=e.allowedUrlPrefixes??[];if(!e.dangerouslyAllowFullInternetAccess){let e=Zz(t);if(e.length>0)throw Error(`Invalid network allow-list:
1617
+ ${e.join(`
1618
+ `)}`)}let n=[];for(let e of t)typeof e==`object`&&e.transform&&e.transform.length>0&&n.push(e);function r(e){if(n.length===0)return null;let t=null;for(let r of n)if(Vz(e,r.url)&&r.transform){t||=new Headers;for(let e of r.transform)for(let[n,r]of Object.entries(e.headers))t.set(n,r)}return t}if(e.maxRedirects!==void 0&&(!Number.isSafeInteger(e.maxRedirects)||e.maxRedirects<0))throw RangeError(`maxRedirects must be a non-negative safe integer`);let i=e.maxRedirects??oB,a=e.timeoutMs??sB,o=e.maxResponseSize??cB,s=e.dangerouslyAllowFullInternetAccess?[`GET`,`HEAD`,`POST`,`PUT`,`DELETE`,`PATCH`,`OPTIONS`]:e.allowedMethods??lB,c=e.denyPrivateRanges??(typeof process<`u`&&!0),l=e._dnsResolve??aB,u=e._createConnectionOwner??$z;function d(e){let t=e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,-1):e;if(/^(?:0|[1-9]\d{0,2})(?:\.(?:0|[1-9]\d{0,2})){3}$/.test(t)&&t.split(`.`).every(e=>Number(e)<=255))return 4;if(t.includes(`:`)&&!t.includes(`%`))try{if(new URL(`http://[${t}]/`).hostname.length>2)return 6}catch{}return null}function f(e,t,n){let{address:r,family:i}=n;if(d(r)!==i)throw new eB(e,`DNS returned an invalid address for private IP check`);return{hostname:t,address:r,family:i}}async function p(n,r){if(pB(r),!e.dangerouslyAllowFullInternetAccess&&!Uz(n,t))throw new eB(n);if(!c)return null;let i;try{i=new URL(n)}catch{throw new eB(n,`invalid URL`)}if(Wz(i.hostname))throw new eB(n,`private/loopback IP address blocked`);let a=i.hostname;if(d(a)!==null)return null;let o;try{o=await mB(l(a),r)}catch{throw r?.aborted?fB(r):new eB(n,`DNS resolution failed for private IP check`)}if(!Array.isArray(o)||o.length===0)throw new eB(n,`DNS resolution returned no addresses for private IP check`);let s=o.map(e=>f(n,a,e));for(let{address:e}of s)if(Wz(e))throw new eB(n,`hostname resolves to private/loopback IP address`);return s[0]}function m(t){if(e.dangerouslyAllowFullInternetAccess)return;let n=t.toUpperCase();if(!s.includes(n))throw new rB(n,s)}async function h(e,t={}){let n=t.method?.toUpperCase()??`GET`,s=t.followRedirects??!0;if(t.maxRedirects!==void 0&&(!Number.isSafeInteger(t.maxRedirects)||t.maxRedirects<0))throw RangeError(`maxRedirects must be a non-negative safe integer`);let c=t.maxRedirects??i,l=Math.min(i,c),d=t.timeoutMs===void 0?a:Math.min(t.timeoutMs,a),f=new AbortController,h=$n(()=>f.abort(new DOMException(`The operation was aborted`,`AbortError`)),d),g=rr(t.signal,f.signal);try{let i=await p(e,g.signal);m(n);let a=e,c=0;for(;;){pB(g.signal);let e;try{let d=await Kn.runTrustedAsync(async()=>{let o=r(a),s=vB(t.headers,o),c={method:n,headers:s,signal:g.signal,redirect:`manual`};if(t.body&&!uB.has(n)&&(c.body=t.body),!i)return await mB(fetch(a,c),g.signal);try{return e=await hB(u(i),g.signal),await mB(e.fetch(a,c),g.signal)}catch(e){throw e instanceof Qz?new eB(a,`DNS pinning unavailable for private IP enforcement`):e}});if(dB.has(d.status)&&s){let e=d.headers.get(`location`);if(!e)return await yB(d,a,o,g.signal);let t=new URL(e,a).href;await mB(gB(d),g.signal);try{i=await p(t,g.signal)}catch{throw g.signal?.aborted?fB(g.signal):new nB(t)}if(c++,c>l)throw new tB(l);a=t;continue}return await yB(d,a,o,g.signal)}finally{if(e){let t=e;await mB(Kn.runTrustedAsync(()=>t.close()),g.signal)}}}}finally{er(h),g.cleanup()}}return h}function vB(e,t){if(!e&&!t)return;if(!t)return e;let n=(e instanceof Headers,new Headers(e));for(let[e,r]of t)n.set(e,r);return n}async function yB(e,t,n,r){let i=Object.create(null);if(e.headers.forEach((e,t)=>{i[t.toLowerCase()]=e}),n>0){let t=e.headers.get(`content-length`);if(t){let e=parseInt(t,10);if(!Number.isNaN(e)&&e>n)throw new iB(n)}}let a;if(n>0&&e.body){let t=e.body.getReader(),i=[],o=0;try{for(;;){let{done:e,value:a}=await mB(t.read(),r);if(e)break;if(a){if(o+=a.byteLength,o>n)throw await t.cancel(),new iB(n);i.push(a)}}}catch(e){throw r?.aborted&&await t.cancel(fB(r)).catch(()=>{}),e}a=new Uint8Array(o);let s=0;for(let e of i)a.set(e,s),s+=e.byteLength}else{let t=await mB(e.arrayBuffer(),r);if(n>0&&t.byteLength>n)throw new iB(n);a=new Uint8Array(t)}return{status:e.status,statusText:e.statusText,headers:i,body:a,url:t}}qn(),Lr(),j();function bB(e,t){if(e.length>t||O(e)>t)throw new A(`script input size limit exceeded (${t} bytes)`,`string_length`)}var xB=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(e={}){this.limits=NE({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}},e.executionLimitProfile);let t=e.fs??new WE(e.files,{maxTotalBytes:this.limits.maxFileSystemBytes});this.fs=t,this.useDefaultLayout=!e.cwd&&!e.files;let n=e.cwd||(this.useDefaultLayout?`/home/user`:`/`),r=new Map([[`HOME`,this.useDefaultLayout?`/home/user`:`/`],[`PATH`,`/usr/bin:/bin`],[`IFS`,`
1619
+ `],[`OSTYPE`,`linux-gnu`],[`MACHTYPE`,`x86_64-pc-linux-gnu`],[`HOSTTYPE`,`x86_64`],[`HOSTNAME`,`localhost`],[`PWD`,n],[`OLDPWD`,n],[`OPTIND`,`1`],...Object.entries(e.env??{})]);if(e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=_B(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:r,arrays:new Map,cwd:n,previousDir:`/home/user`,functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:``,startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set([`HOME`,`PATH`,`PWD`,`OLDPWD`,...Object.keys(e.env||{})]),readonlyVars:new Set([`SHELLOPTS`,`BASHOPTS`]),hashTable:new Map},this.state.env.set(`SHELLOPTS`,yD(this.state.options)),this.state.env.set(`BASHOPTS`,SD(this.state.shoptOptions)),QE(t,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),n!==`/`&&t instanceof WE)try{t.mkdirSync(n,{recursive:!0})}catch{}for(let t of CE(e.commands))this.registerBundledCommand(t);if(e.fetch||e.network)for(let e of wE())this.registerBundledCommand(e);if(e.python)for(let e of TE())this.registerBundledCommand(e);let i=typeof e.javascript==`object`?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let e of EE())this.registerBundledCommand(e);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let t of e.customCommands)if(FE(t)){let e=LE(t);this.registerCommandInternal(e,!0)}else this.registerCommandInternal(t,!0)}registerCommand(e){this.registerCommandInternal(e,!0)}registerBundledCommand(e){this.registerCommandInternal(e,!1)}registerCommandInternal(e,t,n=t?e.trusted??!0:e.trusted){let r=this.commands.get(e.name),i=t?r?.internalOriginalCommand??(r&&!r.internalIsExtension?r:void 0):void 0,a={name:e.name,trusted:n,internalIsExtension:t,internalOriginalCommand:i,execute:(t,n)=>e.execute(t,n)};this.commands.set(e.name,a);let o=this.fs;if(typeof o.writeFileSync==`function`){let t=`#!/bin/bash
1620
+ # Built-in command: ${e.name}
1621
+ `;try{o.writeFileSync(`/bin/${e.name}`,t)}catch{}try{o.writeFileSync(`/usr/bin/${e.name}`,t)}catch{}}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug(`stdout`,{output:e.stdout}),e.stderr&&this.logger.info(`stderr`,{output:e.stderr}),this.logger.info(`exit`,{exitCode:e.exitCode})),e.stdout=TB(e.stdout),e.stderr=TB(e.stderr),e}async exec(e,t){let n=new zE(this.limits,t?.signal),r;try{r=await this.execInScope(e,t,n,0,t?.signal,!1,!1)}catch(e){try{await n.close()}catch{}throw e}let i=r;try{await n.close()}catch{i={...r,stderr:`${r.stderr}bash: execution cleanup failed
1622
+ `,exitCode:126}}return e.trim()?this.logResult(i):i}async execInScope(e,t,n,r,i,a=!1,o=!0){let s=e=>o?this.logResult(e):e,c=rr(i,t?.signal),l=t?{...t,signal:c.signal}:{signal:c.signal};try{if(n.assertExecDepth(r),bB(e,this.limits.maxSourceBytes),!e.trim())return{stdout:``,stderr:``,exitCode:0,env:id(this.state.env,l.env)};this.logger?.info(`exec`,{command:e});let t=l.cwd??this.state.cwd,i,o=t;if(l.cwd)if(l.env&&`PWD`in l.env)i=l.env.PWD;else if(l.env&&!(`PWD`in l.env))try{i=await this.fs.realpath(t),o=i}catch{i=t}else i=t;let c=l.replaceEnv?new Map:new Map(this.state.env);if(l.env)for(let[e,t]of Object.entries(l.env))c.set(e,t);i!==void 0&&c.set(`PWD`,i);let u={...this.state,env:c,arrays:l.replaceEnv?new Map:eD(this.state.arrays),cwd:o,previousDir:l.env?.OLDPWD??this.state.previousDir,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:EB(l.stdin,l.stdinKind,this.limits.maxInputBytes,this.limits.maxStringLength,n,a),signal:l.signal,extraArgs:l.args},d=e;l.rawScript||(d=CB(e));let f=this.defenseInDepthConfig?Kn.getInstance(this.defenseInDepthConfig):null,p=f?.activate();try{let e=async()=>{let e=Ek(d,{maxHeredocSize:this.limits.maxHeredocSize}),t;if(this.transformPlugins.length>0){let n=Object.create(null);for(let t of this.transformPlugins){let r=t.transform({ast:e,metadata:n});e=r.ast,r.metadata&&(n=ad(n,r.metadata))}t=n}let i=await new Fz({fs:this.fs,commands:this.commands,limits:this.limits,executionScope:n,exec:(e,t,i=!1)=>this.execInScope(e,t,n,r+1,l.signal,i),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:f?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},u).executeScript(e);return t&&(i.metadata=t),s(i)};return p?await p.run(e):await e()}catch(e){if(e instanceof wr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,internalOutputAccounting:e.internalOutputAccounting,env:id(this.state.env,l.env)});if(e instanceof jr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,env:id(this.state.env,l.env)});if(e instanceof Tr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:1,env:id(this.state.env,l.env)});if(e instanceof kr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:id(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:$i(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:id(this.state.env,l.env)});if(e instanceof D)return s({stdout:``,stderr:`bash: security violation: ${$i(e.message)}
1623
+ `,exitCode:1,env:id(this.state.env,l.env)});if(e.name===`ParseException`)return s({stdout:``,stderr:`bash: syntax error: ${$i(e.message)}
1624
+ `,exitCode:2,env:id(this.state.env,l.env)});if(e instanceof MD)return s({stdout:``,stderr:`bash: ${$i(e.message)}
1625
+ `,exitCode:2,env:id(this.state.env,l.env)});if(e instanceof RangeError)return s({stdout:``,stderr:`bash: ${$i(e.message)}
1626
+ `,exitCode:1,env:id(this.state.env,l.env)});throw e}finally{p?.deactivate()}}catch(e){if(e instanceof kr)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:id(this.state.env,l.env)});if(e instanceof A)return s({stdout:e.stdout,stderr:$i(e.stderr),exitCode:A.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:id(this.state.env,l.env)});throw e}finally{c.cleanup()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,t){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),t)}getCwd(){return this.state.cwd}getEnv(){return rd(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){bB(e,this.limits.maxSourceBytes);let t=Ek(CB(e),{maxHeredocSize:this.limits.maxHeredocSize}),n=Object.create(null);for(let e of this.transformPlugins){let r=e.transform({ast:t,metadata:n});t=r.ast,r.metadata&&(n=ad(n,r.metadata))}return{script:Dk(t),ast:t,metadata:n}}};function SB(e,t){let n=t;for(let t=0;t<e.length;t++){let r=e[t];if(n===`single`)r===`'`&&(n=`none`);else if(n===`double`)r===`\\`?t++:r===`"`&&(n=`none`);else if(r===`'`)n=`single`;else if(r===`"`)n=`double`;else if(r===`\\`)t++;else if(r===`#`&&(t===0||/\s/.test(e[t-1])))break}return n}function CB(e){let t=e.split(`
1627
+ `),n=[],r=[],i=`none`;for(let e=0;e<t.length;e++){let a=t[e];if(r.length>0){let e=r[r.length-1];if((e.stripTabs?a.replace(/^\t+/,``):a)===e.delimiter){n.push(a.trimStart()),r.pop();continue}n.push(a);continue}let o=i,s=o===`none`?a.trimStart():a;if(n.push(s),i=SB(a,o),o===`none`)for(let e of s.matchAll(/<<(-?)\s*(['"]?)([\w-]+)\2/g)){let t=e[1]===`-`,n=e[3];r.push({delimiter:n,stripTabs:t})}}return n.join(`
1628
+ `)}var wB=new TextDecoder(`utf-8`,{fatal:!0});function TB(e){if(!e)return e;let t=!1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>255)return e;r>127&&(t=!0)}if(!t)return e;let n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);try{return wB.decode(n)}catch{return e}}function EB(e,t,n,r,i,a){if(e===void 0)return;let o=t===`bytes`?e.length:O(e);if(o>n||o>r)throw new A(`stdin size limit exceeded (${Math.min(n,r)} bytes)`,`string_length`);return a||i.consumeInput(o,`stdin`),t===`bytes`?e:sr(e)}
1629
+ /*! Bundled license information:
1630
+
1631
+ re2js/build/index.esm.js:
1632
+ (*!
1633
+ * re2js
1634
+ * RE2JS is the JavaScript port of RE2, a regular expression engine that provides linear time matching
1635
+ *
1636
+ * @version v1.3.3
1637
+ * @author Alexey Vasiliev
1638
+ * @homepage https://github.com/le0pard/re2js#readme
1639
+ * @repository github:le0pard/re2js
1640
+ * @license MIT
1641
+ *)
1642
+
1643
+ ieee754/index.js:
1644
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
1645
+ */
1646
+ var DB=e({createCostCommand:()=>RB,frozenSessionToCostData:()=>jB,registerSessionCostsProvider:()=>kB});let OB=null;function kB(e){OB=e}function AB(e){return typeof e==`number`&&Number.isFinite(e)?e:0}function jB(e){let t=Array.isArray(e.models)?e.models:[],n=t.map(e=>typeof e?.model==`string`?e.model:``).filter(Boolean),r=Number.isFinite(e.cost?.total);return{name:typeof e.title==`string`&&e.title.length>0?e.title:e.filename,type:`cone`,model:n[0]??`-`,models:n,source:`frozen`,costAvailable:r,usage:{input:null,output:null,cacheRead:null,cacheWrite:null,totalTokens:t.reduce((e,t)=>e+AB(t?.tokens),0),cost:{input:AB(e.cost?.input),output:AB(e.cost?.output),cacheRead:AB(e.cost?.cacheRead),cacheWrite:AB(e.cost?.cacheWrite),total:AB(e.cost?.total)}},turns:t.reduce((e,t)=>e+AB(t?.turns),0)}}function MB(){return`cost - show session cost breakdown
1647
+
1648
+ Usage: cost [options]
1649
+
1650
+ Options:
1651
+ --all Include dropped scoops and frozen sessions
1652
+ --json Output as JSON (for programmatic use)
1653
+ -h, --help Show this help message
1654
+ `}function NB(e){if(e===null)return`-`;let t=e/1e6;return t<.01?`<0.01`:t.toFixed(2)}function PB(e){return`$${e.toFixed(2)}`}function FB(e,t){if(!t||t===0)return`-`;let n=t/36e5;return n===0?`-`:`$${(e/n).toFixed(2)}`}function IB(e,t){return e.length<=t?e:e.slice(0,t-3)+`...`}function LB(e){let t=[];t.push(`Session Cost Breakdown:
1655
+ `);let n=` `+`Agent`.padEnd(16)+`Source`.padEnd(10)+`Model`.padEnd(18)+`MTok (in/out)`.padEnd(15)+`Cache (r/w)`.padEnd(15)+`Cost`.padStart(10)+`$/hour`.padStart(10),r=` `+`─`.repeat(94);t.push(n),t.push(r);let i=0,a=0,o=0,s=0,c=0;for(let n of e){let e=IB(n.name,16).padEnd(16),r=n.source.padEnd(10),l=IB(n.model,18).padEnd(18),u=`${NB(n.usage.input).padStart(5)} / ${NB(n.usage.output).padStart(5)}`.padEnd(15),d=`${NB(n.usage.cacheRead).padStart(5)} / ${NB(n.usage.cacheWrite).padStart(5)}`.padEnd(15),f=(n.costAvailable===!1?`-`:PB(n.usage.cost.total)).padStart(10),p=n.costAvailable===!1?`-`.padStart(10):FB(n.usage.cost.total,n.activeTimeMs).padStart(10);t.push(` ${e}${r}${l}${u}${d}${f}${p}`),i=i===null||n.usage.input===null?null:i+n.usage.input,a=a===null||n.usage.output===null?null:a+n.usage.output,o=o===null||n.usage.cacheRead===null?null:o+n.usage.cacheRead,s=s===null||n.usage.cacheWrite===null?null:s+n.usage.cacheWrite,c=c===null||n.costAvailable===!1?null:c+n.usage.cost.total}t.push(r);let l=`Total`.padEnd(16),u=``.padEnd(10),d=``.padEnd(18),f=`${NB(i).padStart(5)} / ${NB(a).padStart(5)}`.padEnd(15),p=`${NB(o).padStart(5)} / ${NB(s).padStart(5)}`.padEnd(15),m=(c===null?`-`:PB(c)).padStart(10),h=``.padStart(10);return t.push(` ${l}${u}${d}${f}${p}${m}${h}`),t.join(`
1656
+ `)+`
1657
+ `}function RB(){return IE(`cost`,async e=>{if(e.includes(`--help`)||e.includes(`-h`))return{stdout:MB(),stderr:``,exitCode:0};if(!OB)return{stdout:``,stderr:`Cost data not available.
1658
+ `,exitCode:1};let t=e.includes(`--all`)?`all`:`live`,n=await OB(t);return n.length===0?{stdout:`No session cost data yet.
1659
+ `,stderr:``,exitCode:0}:e.includes(`--json`)?{stdout:JSON.stringify(n,null,2)+`
1660
+ `,stderr:``,exitCode:0}:{stdout:LB(n),stderr:``,exitCode:0}})}export{xB as a,on as c,kB as i,xE as l,RB as n,IE as o,jB as r,SE as s,DB as t};