@preventive/triage 1.0.0-alpha.4 → 1.0.0-alpha.40

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 (311) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/README.md +16 -0
  3. package/api/reap.ts +17 -0
  4. package/cli.js +6 -0
  5. package/client/dependency-paths.d.ts +2 -0
  6. package/client/dependency-paths.js +24 -0
  7. package/client/finding-link.js +305 -0
  8. package/client/linked-findings.d.ts +1 -0
  9. package/client/linked-findings.js +112 -0
  10. package/common/bundle-commit.d.ts +1 -0
  11. package/common/bundle-commit.js +4 -0
  12. package/common/bundle-compare-diff.d.ts +3 -0
  13. package/common/bundle-compare-diff.js +522 -0
  14. package/common/bundle-compare-inputs.d.ts +2 -0
  15. package/common/bundle-compare-inputs.js +65 -0
  16. package/common/bundle-metadata.d.ts +14 -0
  17. package/common/bundle-metadata.js +226 -0
  18. package/common/bundle-pkg-of.d.ts +1 -0
  19. package/common/bundle-pkg-of.js +90 -0
  20. package/common/bundle-reasons.d.ts +2 -0
  21. package/common/bundle-reasons.js +21 -0
  22. package/common/bundle-source-links.d.ts +6 -0
  23. package/common/bundle-source-links.js +216 -0
  24. package/common/bundle-sourcemap.d.ts +10 -0
  25. package/common/bundle-sourcemap.js +100 -0
  26. package/common/bundle-sources.d.ts +7 -0
  27. package/common/bundle-sources.js +310 -0
  28. package/common/bundle-stats.js +41 -0
  29. package/common/bundle-tabs.js +1 -0
  30. package/common/code-language.js +65 -0
  31. package/common/default-scan-models.ts +31 -0
  32. package/common/dependency-reviews.d.ts +23 -0
  33. package/common/dependency-reviews.js +81 -0
  34. package/common/finding-duplicates.js +58 -0
  35. package/common/finding-filters.js +274 -0
  36. package/common/finding-id.js +47 -0
  37. package/common/github-issue-labels.d.ts +1 -0
  38. package/common/github-issue-labels.js +11 -0
  39. package/common/github-pr.ts +56 -0
  40. package/common/gzip.js +59 -0
  41. package/common/line-diff.d.ts +8 -0
  42. package/common/line-diff.js +56 -0
  43. package/common/linked-workspace-groups.js +63 -0
  44. package/common/managed/comments.ts +34 -0
  45. package/common/managed/npm-packages.d.ts +5 -0
  46. package/common/managed/npm-packages.js +34 -0
  47. package/common/managed/permissions.ts +31 -0
  48. package/common/managed/report-content.ts +72 -0
  49. package/common/managed/report-filter.ts +108 -0
  50. package/common/managed/repository-alias.ts +65 -0
  51. package/common/managed/roles.ts +28 -0
  52. package/common/managed/routes.d.ts +2 -0
  53. package/common/managed/routes.js +254 -0
  54. package/common/managed/scan-models.ts +6 -0
  55. package/common/managed/team-app.d.ts +2 -0
  56. package/common/managed/team-app.js +31 -0
  57. package/common/managed/triage.ts +83 -0
  58. package/common/managed/upload-seal.ts +126 -0
  59. package/common/pretty-print.d.ts +5 -0
  60. package/common/pretty-print.js +24 -0
  61. package/common/revalidation-conflicts.js +48 -0
  62. package/common/revalidation-input-groups.js +56 -0
  63. package/common/save-error-reason.ts +20 -7
  64. package/common/scan-server.ts +13 -0
  65. package/common/server-info.ts +35 -0
  66. package/common/utf8.d.ts +3 -0
  67. package/common/utf8.js +45 -0
  68. package/common/workspace-app.js +23 -0
  69. package/common/workspace-groups.js +176 -0
  70. package/out/brotli-fallback.js +3 -3
  71. package/out/chunk-2KBF5TZ7.js +2 -0
  72. package/out/chunk-2XUEZHIP.js +28 -0
  73. package/out/chunk-35VE6CDH.js +2 -0
  74. package/out/chunk-3BZ7JERB.js +1 -0
  75. package/out/chunk-4F6JSF57.js +3 -0
  76. package/out/chunk-4XCDFGDP.js +10 -0
  77. package/out/chunk-AQ75QITE.js +1 -0
  78. package/out/chunk-B2RQY6OP.js +2 -0
  79. package/out/chunk-C4Z6ZBXV.js +10 -0
  80. package/out/chunk-CMQA4DM6.js +1 -0
  81. package/out/chunk-CVVJAXVY.js +2 -0
  82. package/out/chunk-DIJJNTRH.js +10 -0
  83. package/out/chunk-GJ4IUCNS.js +1 -0
  84. package/out/chunk-GNXOKIGP.js +80 -0
  85. package/out/chunk-GZ4MS3TE.js +13 -0
  86. package/out/chunk-IISEF2BZ.js +1 -0
  87. package/out/chunk-IU3CCINR.js +3 -0
  88. package/out/chunk-K3X5EJBQ.js +2 -0
  89. package/out/chunk-KEX2ATEW.js +2 -0
  90. package/out/chunk-KYCNJVB7.js +1 -0
  91. package/out/chunk-MYDDTA7W.js +225 -0
  92. package/out/chunk-NRPC74AM.js +1 -0
  93. package/out/chunk-OOJM4CTU.js +1 -0
  94. package/out/chunk-PNHBZGDD.js +1 -0
  95. package/out/chunk-R5O6FAW4.js +2 -0
  96. package/out/chunk-RFZQQXSG.js +17 -0
  97. package/out/chunk-RSHMVYNS.js +1 -0
  98. package/out/chunk-TGANXVTA.js +1 -0
  99. package/out/chunk-TUII34K2.js +1 -0
  100. package/out/chunk-TZ5KB2Y5.js +10 -0
  101. package/out/chunk-UN5ZSYLE.js +1 -0
  102. package/out/chunk-UNTRGE26.js +2 -0
  103. package/out/chunk-UXNUAIIC.js +33 -0
  104. package/out/chunk-UYAXVRVL.js +1 -0
  105. package/out/chunk-V3ME6FI5.js +2 -0
  106. package/out/chunk-V5O7M2YT.js +1 -0
  107. package/out/chunk-VIHGO77Y.js +1 -0
  108. package/out/chunk-VQJCXGIY.js +7 -0
  109. package/out/chunk-W4J3MGLB.js +1 -0
  110. package/out/chunk-WGG7KQUH.js +1 -0
  111. package/out/chunk-WZDTZE64.js +1 -0
  112. package/out/chunk-XYDGU6BM.js +51 -0
  113. package/out/chunk-XYFXXB2G.js +10 -0
  114. package/out/chunk-YVZH5SHP.js +1 -0
  115. package/out/chunk-ZBBOBQ43.js +1 -0
  116. package/out/chunk-ZMQQCGF6.js +2 -0
  117. package/out/client-managed-import.js +4 -0
  118. package/out/client-managed.js +37 -0
  119. package/out/client-sync.js +10 -13
  120. package/out/github-issue-authorized.html +3 -0
  121. package/out/github-issue-authorized.js +1 -0
  122. package/out/graph.js +17 -4
  123. package/out/index.html +90 -8
  124. package/out/prism.js +6 -2
  125. package/out/stasis.svg +20 -0
  126. package/out/terminal.js +365 -39
  127. package/out/view.css +1 -1
  128. package/out/view.js +83 -117
  129. package/package.json +297 -59
  130. package/risk/files/characters.js +196 -0
  131. package/risk/files/hosts.js +205 -0
  132. package/risk/files/readability.js +171 -0
  133. package/risk/files/runs-code.js +358 -0
  134. package/risk/files/script.js +114 -0
  135. package/risk/files/stamps.js +46 -0
  136. package/risk/index.d.ts +142 -0
  137. package/risk/index.js +7 -0
  138. package/risk/npm/assess.js +219 -0
  139. package/risk/npm/combined.js +65 -0
  140. package/risk/npm/compare.js +228 -0
  141. package/risk/npm/dependencies.js +153 -0
  142. package/risk/npm/diff.js +43 -0
  143. package/risk/npm/downloads.js +84 -0
  144. package/risk/npm/files.js +34 -0
  145. package/risk/npm/held.js +60 -0
  146. package/risk/npm/install-scripts.js +34 -0
  147. package/risk/npm/malware.js +36 -0
  148. package/risk/npm/manifest.js +65 -0
  149. package/risk/npm/new-dependency.js +30 -0
  150. package/risk/npm/old-version.js +108 -0
  151. package/risk/npm/registry.js +282 -0
  152. package/risk/npm/release.js +85 -0
  153. package/risk/npm/specs.js +124 -0
  154. package/risk/npm/tarball.js +113 -0
  155. package/server-common/database-config.ts +16 -0
  156. package/server-common/initialize.ts +18 -0
  157. package/server-common/npm-advisories.ts +101 -0
  158. package/{server → server-common}/origin.ts +5 -5
  159. package/server-common/reap.ts +48 -0
  160. package/server-common/scan-config.ts +19 -0
  161. package/server-common/standalone.ts +29 -0
  162. package/server-common/storage-crypto.ts +182 -0
  163. package/server-common/storage-log.ts +38 -0
  164. package/server-common/vercel-blob.ts +103 -0
  165. package/server-e2e/app.ts +486 -0
  166. package/{server → server-e2e}/auth.ts +5 -1
  167. package/{server → server-e2e}/bus-receiver.ts +2 -1
  168. package/{server → server-e2e}/cli.js +9 -4
  169. package/{server → server-e2e}/config.ts +56 -35
  170. package/{server → server-e2e}/db-neon.ts +2 -2
  171. package/{server → server-e2e}/db-revision-sql.ts +1 -1
  172. package/{server → server-e2e}/db-stmt.ts +2 -2
  173. package/{server → server-e2e}/db.ts +7 -7
  174. package/{server → server-e2e}/http.ts +116 -18
  175. package/{server → server-e2e}/hub.ts +40 -9
  176. package/server-e2e/index.ts +17 -0
  177. package/server-e2e/lifecycle.ts +95 -0
  178. package/{server → server-e2e}/neon-driver.ts +2 -2
  179. package/{server → server-e2e}/npm-proxy.ts +12 -145
  180. package/{server → server-e2e}/objstore/blob-vercel.ts +10 -114
  181. package/{server → server-e2e}/objstore/blob.ts +1 -1
  182. package/server-e2e/objstore/fetch-mint-guard.ts +74 -0
  183. package/{server → server-e2e}/objstore/handlers.ts +9 -8
  184. package/{server → server-e2e}/objstore/init.ts +35 -18
  185. package/{server → server-e2e}/objstore/reaper.ts +1 -1
  186. package/server-e2e/objstore/rest-deny.ts +28 -0
  187. package/server-e2e/objstore/rest-mint.ts +224 -0
  188. package/{server → server-e2e}/objstore/rest.ts +27 -26
  189. package/{server → server-e2e}/objstore/sign.ts +105 -0
  190. package/{server → server-e2e}/objstore/store-neon.ts +6 -10
  191. package/{server → server-e2e}/objstore/store.ts +7 -7
  192. package/{server → server-e2e}/objstore/tokens.ts +2 -2
  193. package/{server → server-e2e}/pubsub.ts +12 -9
  194. package/{server → server-e2e}/sign.ts +4 -4
  195. package/{server → server-e2e}/sse-server.ts +102 -68
  196. package/{server → server-e2e}/sse-session.ts +28 -8
  197. package/{server → server-e2e}/static.ts +31 -21
  198. package/server-e2e/sync-handlers.ts +408 -0
  199. package/{server → server-e2e}/ws-server.ts +20 -9
  200. package/server-managed/activity.ts +245 -0
  201. package/server-managed/avatar-store.ts +12 -0
  202. package/server-managed/blob-store.ts +17 -0
  203. package/server-managed/brotli.ts +10 -0
  204. package/server-managed/bundle-advisories.ts +120 -0
  205. package/server-managed/bundle-advisory-inventory.ts +77 -0
  206. package/server-managed/bundle-build-diagnostics.d.ts +10 -0
  207. package/server-managed/bundle-build-diagnostics.js +23 -0
  208. package/server-managed/bundle-build-leases.ts +41 -0
  209. package/server-managed/bundle-build-worker.js +111 -0
  210. package/server-managed/bundle-build.ts +198 -0
  211. package/server-managed/bundle-cache.ts +199 -0
  212. package/server-managed/bundle-catalog.ts +29 -0
  213. package/server-managed/bundle-commits.ts +140 -0
  214. package/server-managed/bundle-store.ts +24 -0
  215. package/server-managed/bundle-summary-cache.ts +130 -0
  216. package/server-managed/bundle.ts +120 -0
  217. package/server-managed/cache-storage.ts +19 -0
  218. package/server-managed/cli.js +21 -0
  219. package/server-managed/combined.ts +46 -0
  220. package/server-managed/comments.ts +151 -0
  221. package/server-managed/config.ts +158 -0
  222. package/server-managed/content-access.ts +15 -0
  223. package/server-managed/crypto.ts +25 -0
  224. package/server-managed/db-methods.ts +1725 -0
  225. package/server-managed/db-neon.ts +367 -0
  226. package/server-managed/db-schema.ts +227 -0
  227. package/server-managed/db-table-names.ts +22 -0
  228. package/server-managed/db.ts +132 -0
  229. package/server-managed/dependency-reviews.ts +248 -0
  230. package/server-managed/github-app.ts +391 -0
  231. package/server-managed/github-errors.ts +68 -0
  232. package/server-managed/github-issue-links.ts +127 -0
  233. package/server-managed/github-issue-oauth.ts +47 -0
  234. package/server-managed/github-issues.ts +152 -0
  235. package/server-managed/github-metadata.ts +213 -0
  236. package/server-managed/github-oauth.ts +235 -0
  237. package/server-managed/github-pulls.ts +227 -0
  238. package/server-managed/http-response.ts +50 -0
  239. package/server-managed/http.ts +3472 -0
  240. package/server-managed/import-triage.ts +51 -0
  241. package/server-managed/index.ts +187 -0
  242. package/server-managed/kept.ts +28 -0
  243. package/server-managed/link-reports.ts +158 -0
  244. package/server-managed/locked-packages.ts +85 -0
  245. package/server-managed/lru.ts +30 -0
  246. package/server-managed/managed-issues.ts +75 -0
  247. package/server-managed/management-catalog.ts +45 -0
  248. package/server-managed/management.ts +99 -0
  249. package/server-managed/npm-insights.ts +440 -0
  250. package/server-managed/npm-kept.ts +65 -0
  251. package/server-managed/npm-loads.ts +167 -0
  252. package/server-managed/npm-manifest.ts +115 -0
  253. package/server-managed/npm-packages.ts +378 -0
  254. package/server-managed/npm-provenance.ts +123 -0
  255. package/server-managed/npm-risk.ts +177 -0
  256. package/server-managed/object-storage-disk.ts +148 -0
  257. package/server-managed/object-storage-vercel.ts +67 -0
  258. package/server-managed/object-storage.ts +74 -0
  259. package/server-managed/package-entry-points.ts +51 -0
  260. package/server-managed/pretty-print.ts +352 -0
  261. package/server-managed/public-workspace.ts +220 -0
  262. package/server-managed/rename-diff-worker.js +26 -0
  263. package/server-managed/rename-diff.ts +270 -0
  264. package/server-managed/repo-path.ts +21 -0
  265. package/server-managed/report-migration.ts +35 -0
  266. package/server-managed/report-query.ts +10 -0
  267. package/server-managed/report-response.ts +16 -0
  268. package/server-managed/report-sources.ts +178 -0
  269. package/server-managed/report-store.ts +47 -0
  270. package/server-managed/repository-aliases.ts +91 -0
  271. package/server-managed/repository-browser.ts +153 -0
  272. package/server-managed/repository-discovery.ts +82 -0
  273. package/server-managed/repository-policy.ts +27 -0
  274. package/server-managed/repository-risk.ts +418 -0
  275. package/server-managed/revisions.ts +35 -0
  276. package/server-managed/session.ts +92 -0
  277. package/server-managed/slugs.ts +38 -0
  278. package/server-managed/solidity-entry-points.ts +69 -0
  279. package/server-managed/sql-postgres.ts +31 -0
  280. package/server-managed/sql.ts +76 -0
  281. package/server-managed/static.ts +28 -0
  282. package/server-managed/storage-command.ts +16 -0
  283. package/server-managed/storage-db.ts +175 -0
  284. package/server-managed/storage-encryption.ts +279 -0
  285. package/server-managed/storage-maintenance.ts +256 -0
  286. package/server-managed/storage-payload.ts +103 -0
  287. package/server-managed/storage-stores.ts +85 -0
  288. package/server-managed/storage.ts +78 -0
  289. package/server-managed/team-app.ts +94 -0
  290. package/server-managed/team-catalog.ts +7 -0
  291. package/server-managed/team-feed.ts +173 -0
  292. package/server-managed/team-npm-scopes.ts +77 -0
  293. package/server-managed/team-reports.ts +228 -0
  294. package/server-managed/triage-response.ts +16 -0
  295. package/server-managed/type-only-worker.js +19 -0
  296. package/server-managed/type-only.ts +103 -0
  297. package/server-managed/uploads.ts +86 -0
  298. package/server-managed/upstream-cache.ts +215 -0
  299. package/server-managed/view-as.ts +58 -0
  300. package/server-managed/workspace-shares.ts +166 -0
  301. package/server.ts +50 -0
  302. package/server/index.ts +0 -477
  303. package/server/lifecycle.ts +0 -204
  304. package/server/sync-handlers.ts +0 -320
  305. /package/{LICENSE → LICENSE-MIT} +0 -0
  306. /package/{server → server-e2e}/config.example.json +0 -0
  307. /package/{server → server-e2e}/objstore/blob-fs.ts +0 -0
  308. /package/{server → server-e2e}/objstore/fs.ts +0 -0
  309. /package/{server → server-e2e}/peer.ts +0 -0
  310. /package/{server → server-e2e}/util.ts +0 -0
  311. /package/{server → server-e2e}/validation.ts +0 -0
package/out/terminal.js CHANGED
@@ -1,39 +1,365 @@
1
- var Z=globalThis[Symbol.for("@rray/frontend")];if(!Z)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:Q,html:C,nothing:q,unsafeCSS:J,render:Sn,StateElement:vn,classMap:yn,repeat:$n,styleMap:kn}=Z;function tt(t,e){if(t.length===0)return{argv:[],quoted:new Set};let r=[t[0]],n=new Set;e.has(0)&&n.add(0);for(let s=1;s<t.length;s++){let i=t[s];if(e.has(s)){n.add(r.length),r.push(i);continue}for(let o of et(i))r.push(o)}return{argv:r,quoted:n}}function et(t){for(let e=0;e<t.length;e++){if(t[e]!=="{")continue;let r=Pt(t,e);if(r===-1)continue;let n=Bt(t.slice(e+1,r));if(n.length<2)continue;let s=t.slice(0,e),i=t.slice(r+1),o=[];for(let u of n)o.push(...et(s+u+i));return o}return[t]}function Pt(t,e){let r=1;for(let n=e+1;n<t.length;n++)if(t[n]==="{")r++;else if(t[n]==="}"&&(r--,r===0))return n;return-1}function Bt(t){let e=[],r=0,n=0;for(let s=0;s<t.length;s++)t[s]==="{"?r++:t[s]==="}"?r--:t[s]===","&&r===0&&(e.push(t.slice(n,s)),n=s+1);return e.push(t.slice(n)),e}function nt(t){let e=Xt(t);for(let s of e)if(s.kind==="amp")throw new Error("background processes (`&`) are not supported");for(;e.length>0&&e.at(-1).kind==="semi";)e.pop();let{steps:r,consumed:n}=st(e,0,!1);if(n!==e.length)throw new Error("unexpected `)`");return rt(r),r}function rt(t){for(let e of t){if(e.stages.length===0)throw new Error("empty pipeline stage");for(let r of e.stages)if(r.group)rt(r.group);else if(r.argv.length===0)throw new Error("empty pipeline stage")}}function st(t,e,r){let n=[{gate:"first",stages:[]}],s={argv:[],quoted:new Set},i=e;for(;i<t.length;){let o=t[i];if(o.kind==="paren_close"){if(!r)throw new Error("unexpected `)`");return Ht(n,s,i+1)}if(o.kind==="paren_open"){if(s.group||s.argv.length>0)throw new Error("unexpected `(`");let u=st(t,i+1,!0);s.group=u.steps,i=u.consumed;continue}if(o.kind==="pipe"||o.kind==="and"||o.kind==="or"||o.kind==="semi"){n.at(-1).stages.push(s),s={argv:[],quoted:new Set},o.kind==="and"?n.push({gate:"and",stages:[]}):o.kind==="or"?n.push({gate:"or",stages:[]}):o.kind==="semi"&&n.push({gate:"seq",stages:[]}),i++;continue}if(o.kind==="redir"){i=zt(s,t,i)+1;continue}if(s.group)throw new Error("unexpected token after `)`");o.quoted&&s.quoted.add(s.argv.length),s.argv.push(o.value),i++}if(r)throw new Error("unmatched `(`");return n.at(-1).stages.push(s),{steps:n,consumed:i}}function Ht(t,e,r){let n=t.at(-1);if(!e.group&&e.argv.length===0&&!Gt(e)&&n.stages.length===0){if(t.length===1)throw new Error("empty subshell `()`");t.pop()}else n.stages.push(e);return{steps:t,consumed:r}}function Gt(t){return!!(t.stdoutToNull||t.stderrToNull||t.mergeStderrToStdout||t.mergeStdoutToStderr)}function zt(t,e,r){let n=e[r],s=n.fd==="1"?"":n.fd;if(n.toFd)return n.fd==="2"&&n.toFd==="1"?t.mergeStderrToStdout=!0:n.fd==="1"&&n.toFd==="2"&&(t.mergeStdoutToStderr=!0),r;let i=e[r+1],o=s+">"+(n.append?">":"");if(n.append)throw new Error(`filesystem is read-only \u2014 \`${o}\` append is not supported; use \`|\` to pipe or \`${s}>/dev/null\` to discard`);if(!i||i.kind!=="word")throw new Error(`redirect \`${o}\` requires a target`);if(i.value!=="/dev/null")throw new Error(`filesystem is read-only \u2014 use \`|\` to pipe between commands, or \`${o}/dev/null\` to discard`);return n.fd==="1"?t.stdoutToNull=!0:t.stderrToNull=!0,r+1}function Xt(t){let e=[],r="",n=null,s=!1,i=!1,o=()=>{s&&e.push({kind:"word",value:r,quoted:i}),r="",s=!1,i=!1};for(let u=0;u<t.length;u++){let c=t[u];if(n){c===n?n=null:r+=c;continue}if(c==="'"||c==='"'){n=c,s=!0,i=!0;continue}if(!s&&(c==="1"||c==="2")&&t[u+1]===">"){if(o(),t[u+2]==="&"){let l=t[u+3],f=t[u+4];if((l==="1"||l==="2")&&(f===void 0||/[\s|&>;()]/u.test(f))){e.push({kind:"redir",fd:c,toFd:l}),u+=3;continue}throw new Error(`redirect \`${c}>&\` requires fd 1 or 2 followed by a token boundary`)}t[u+2]===">"?(e.push({kind:"redir",fd:c,append:!0}),u+=2):(e.push({kind:"redir",fd:c,append:!1}),u+=1);continue}if(c==="|"){o(),t[u+1]==="|"?(e.push({kind:"or"}),u++):e.push({kind:"pipe"});continue}if(c==="&"){o(),t[u+1]==="&"?(e.push({kind:"and"}),u++):e.push({kind:"amp"});continue}if(c===">"){o(),t[u+1]===">"?(e.push({kind:"redir",fd:"1",append:!0}),u++):e.push({kind:"redir",fd:"1",append:!1});continue}if(c===";"){o(),e.push({kind:"semi"});continue}if(c==="("){o(),e.push({kind:"paren_open"});continue}if(c===")"){o(),e.push({kind:"paren_close"});continue}if(/\s/u.test(c)){o();continue}r+=c,s=!0}if(n)throw new Error(`unterminated ${n==="'"?"single":"double"} quote`);return o(),e}function p(t,e={}){let r=D(e.short),n=D(e.long),s=D(e.valueShort),i=D(e.valueLong),o=D(e.repeatable),u=e.stopAtFirstPositional??!1,c=new Set,l=new Map,f=[];for(let a=0;a<t.length;a++){let d=t[a];if(d==="--"){f.push(...t.slice(a+1));break}if(/^-+$/u.test(d)){f.push(d);continue}if(d.startsWith("--")&&d.length>2){let m=d.slice(2);if(i.has(m)||o.has(m))O(l,o,m,it(t,++a,`--${m}`));else if(n.has(m))c.add(m);else throw new Error(`unknown option: --${m}`);continue}if(d.startsWith("-")&&d.length>1&&!/^-\d/u.test(d)){a=Vt(t,a,r,s,o,c,l);continue}if(u){f.push(...t.slice(a));break}f.push(d)}return{flags:c,values:l,positional:f}}function D(t){return t instanceof Set?t:new Set(t??[])}function it(t,e,r){if(e>=t.length)throw new Error(`${r} requires an argument`);return t[e]}function O(t,e,r,n){if(!e.has(r)){t.set(r,n);return}let s=t.get(r);s?s.push(n):t.set(r,[n])}function Vt(t,e,r,n,s,i,o){let u=t[e].slice(1);for(let c=0;c<u.length;c++){let l=u[c];if(n.has(l)||s.has(l))return c+1<u.length?(O(o,s,l,u.slice(c+1)),e):(O(o,s,l,it(t,++e,`-${l}`)),e);if(!r.has(l))throw new Error(`unknown option: -${l}`);i.add(l)}return e}function M(t){let e=t.startsWith("/"),r=t.split("/").filter(Boolean),n=[];for(let s of r)if(s!=="."){if(s===".."){n.length>0&&n.at(-1)!==".."?n.pop():e||n.push("..");continue}n.push(s)}return e?"/"+n.join("/"):n.length===0?".":n.join("/")}function w(t,e){return e.startsWith("/")?M(e):M(t+"/"+e)}function I(t){let e=M(t);if(e==="/")return"/";let r=e.lastIndexOf("/");return r<0?".":r===0?"/":e.slice(0,r)}function F(t){let e=M(t);if(e==="/")return"/";let r=e.lastIndexOf("/");return e.slice(r+1)}function A(t,e){return t==="/"?"/"+e:t+"/"+e}function L(t,e){return t==="/"?e.slice(1):e.slice(t.length+1)}function ot(t){let e=new Map,r=t instanceof Map?t.entries():Object.entries(t??{});for(let[i,o]of r)typeof o=="string"&&e.set(M("/"+String(i)),o);let n=new Map([["/",{dirs:[],files:[]}]]);for(let i of e.keys()){let o=I(i);Kt(n,o),n.get(o).files.push(F(i))}for(let i of n.values())i.dirs.sort(),i.files.sort();let s={isFile:i=>e.has(i),isDir:i=>n.has(i),readFile:i=>e.get(i),listDir:i=>{let o=n.get(i);if(!o)throw new Error(`not a directory: ${i}`);return o},walkFiles:i=>Ut(s,i)};return s}function*P(t,e,r=Number.POSITIVE_INFINITY){if(t.isFile(e)){yield{path:e,kind:"file",depth:0};return}if(!t.isDir(e))return;yield{path:e,kind:"dir",depth:0};let n=[{path:e,depth:0}];for(let s=0;s<n.length;s++){let i=n[s];if(i.depth>=r)continue;let{dirs:o,files:u}=t.listDir(i.path),c=i.depth+1;for(let l of o){let f=A(i.path,l);yield{path:f,kind:"dir",depth:c},n.push({path:f,depth:c})}for(let l of u)yield{path:A(i.path,l),kind:"file",depth:c}}}function*Ut(t,e){for(let r of P(t,e))r.kind==="file"&&(yield r.path)}function Kt(t,e){let r=[],n=e;for(;n!=="/"&&!t.has(n);)r.push(n),n=I(n);for(let s=r.length-1;s>=0;s--){let i=r[s];t.set(i,{dirs:[],files:[]}),t.get(I(i)).dirs.push(F(i))}}var g=(t="")=>({stdout:t,stderr:"",exitCode:0}),h=(t,e=1)=>({stdout:"",stderr:t.endsWith(`
2
- `)?t:t+`
3
- `,exitCode:e}),k=t=>h(`usage: ${t}`,2);function S(t){if(t==="")return[];let e=t.split(`
4
- `);return e.at(-1)===""&&e.pop(),e}var v=t=>t.length===0?"":t.join(`
5
- `)+`
6
- `;function B(t,e,r){let n=[],s="",i=!1;for(let o of e){let u=w(r.cwd,o);if(r.fs.isDir(u)){s+=`${t}: ${o}: is a directory
7
- `,i=!0;continue}if(!r.fs.isFile(u)){s+=`${t}: ${o}: no such file or directory
8
- `,i=!0;continue}n.push({name:o,content:r.fs.readFile(u)})}return{inputs:n,stderr:s,failed:i}}function E(t,e,r,n){return e.length===0?{inputs:[{name:null,content:r}],stderr:"",failed:!1}:B(t,e,n)}function W(t,e,r,n){let s=E(t,e,r,n);return{content:s.inputs.map(i=>i.content).join(""),stderr:s.stderr,failed:s.failed}}var y=(t,e)=>({stdout:t,stderr:e.stderr,exitCode:e.failed?1:0});function T(t,e){if(typeof t!="string"||!/^\d+$/u.test(t))return{error:h(`${e}: invalid count: ${t}`)};let r=Number(t);return Number.isSafeInteger(r)?{value:r}:{error:h(`${e}: out of range: ${t}`)}}function Yt(t,e,r){let{positional:n}=p(e),s=E("tac",n,t,r),i=[];for(let{content:o}of s.inputs)i.push(...S(o).toReversed());return y(v(i),s)}var ut=1e6;function Zt(t,e){let{positional:r}=p(e);if(r.length===0||r.length>3)return k("seq LAST | seq FIRST LAST | seq FIRST INCR LAST");let n=[];for(let f of r){if(!/^-?\d+$/u.test(f))return h(`seq: invalid integer: ${f}`);n.push(Number(f))}let s,i,o;if(n.length===1?(s=1,i=1,o=n[0]):n.length===2?(s=n[0],o=n[1],i=s<=o?1:-1):[s,i,o]=n,i===0)return h("seq: increment must be non-zero");let c=(i>0?s<=o:s>=o)?Math.floor(Math.abs(o-s)/Math.abs(i))+1:0;if(c>ut)return h(`seq: range too large: ${c} elements exceeds limit of ${ut}`);let l=[];if(i>0)for(let f=s;f<=o;f+=i)l.push(String(f));else for(let f=s;f>=o;f+=i)l.push(String(f));return g(v(l))}function Qt(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["b"]}),i=n.get("b")??"t";if(i!=="a"&&i!=="t")return h(`nl: -b: only \`a\` and \`t\` are supported (got \`${i}\`)`);let o=E("nl",s,t,r),u=[],c=0;for(let{content:l}of o.inputs)for(let f of S(l))i==="a"||f!==""?(c++,u.push(`${String(c).padStart(6)} ${f}`)):u.push(f);return y(v(u),o)}function Jt(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["d","f","c"]}),i=n.has("f"),o=n.has("c");if(i===o)return k("cut -f LIST [-d DELIM] [file...] | cut -c LIST [file...]");if(o&&n.has("d"))return h("cut: -d is only valid with -f");let u=te(i?n.get("f"):n.get("c"));if(u.error)return u.error;let c=n.get("d")??" ";if(i&&c.length!==1)return h("cut: -d delimiter must be a single character");let l=E("cut",s,t,r),f=[];for(let{content:a}of l.inputs)for(let d of S(a))f.push(i?ee(d,c,u.ranges):lt([...d],u.ranges).join(""));return y(v(f),l)}function te(t){let e=[];for(let r of t.split(",")){if(r==="")return{error:h(`cut: empty list item in \`${t}\``)};if(/^\d+$/u.test(r)){let o=Number(r);if(o<1)return{error:h("cut: list items must be >= 1")};e.push([o,o]);continue}let n=r.match(/^(\d*)-(\d*)$/u);if(!n||n[1]===""&&n[2]==="")return{error:h(`cut: invalid list item: ${r}`)};let s=n[1]===""?1:Number(n[1]),i=n[2]===""?Number.POSITIVE_INFINITY:Number(n[2]);if(s<1)return{error:h("cut: list items must be >= 1")};if(i<s)return{error:h(`cut: reversed range: ${r}`)};e.push([s,i])}return{ranges:e}}function lt(t,e){let r=new Set,n=[];for(let[s,i]of e)for(let o=s;o<=Math.min(i,t.length);o++)r.has(o)||(r.add(o),n.push(o));return n.sort((s,i)=>s-i),n.map(s=>t[s-1])}function ee(t,e,r){let n=t.split(e);return n.length===1?t:lt(n,r).join(e)}function ne(t,e){let{flags:r,positional:n}=p(e,{short:["d","s"]}),s=r.has("d"),i=r.has("s");if(s&&i)return h("tr: -d combined with -s is not supported");let o=s||i?1:2;if(n.length!==o)return k("tr SET1 SET2 | tr -d SET | tr -s SET");let u=ct(n[0]);if(u.error)return u.error;if(s){let a=new Set(u.chars);return g([...t].filter(d=>!a.has(d)).join(""))}if(i)return g(re(t,new Set(u.chars)));let c=ct(n[1]);if(c.error)return c.error;if(c.chars.length===0)return h("tr: SET2 must not be empty");let l=new Map,f=c.chars.at(-1);for(let a=0;a<u.chars.length;a++)l.set(u.chars[a],c.chars[a]??f);return g([...t].map(a=>l.get(a)??a).join(""))}function ct(t){let e=[...t],r=[],n=0,s=()=>{if(e[n]!=="\\")return e[n++];if(n+1>=e.length)return null;let i=e[n+1];return n+=2,i==="n"?`
9
- `:i==="t"?" ":i==="\\"?"\\":i==="0"?"\0":i};for(;n<e.length;){let i=s();if(i===null)return{error:h("tr: trailing backslash in set")};if(e[n]==="-"&&n+1<e.length){n++;let o=s();if(o===null)return{error:h("tr: trailing backslash in set")};let u=i.codePointAt(0),c=o.codePointAt(0);if(c<u)return{error:h(`tr: reversed range: ${i}-${o}`)};for(let l=u;l<=c;l++)r.push(String.fromCodePoint(l))}else r.push(i)}return{chars:r}}function re(t,e){let r="",n=null;for(let s of t)e.has(s)&&s===n||(r+=s,n=s);return r}function se(t,e,r){let{positional:n}=p(e);if(n.length===0)return k("which COMMAND...");let s=[],i=0;for(let o of n)r.hasCommand(o)?s.push(`/usr/bin/${o}`):(s.push(`${o} not found`),i=1);return{stdout:v(s),stderr:"",exitCode:i}}var ft={cut:Jt,tac:Yt,tr:ne,seq:Zt,nl:Qt,which:se};var at=/[*?]/u;function G(t){return new RegExp("^"+t.replace(/[.+^${}()|[\]\\]/gu,"\\$&").replace(/\*/gu,".*").replace(/\?/gu,".")+"$","u")}function ht(t,e,r){if(t.length===0)return[];let n=[t[0]];for(let s=1;s<t.length;s++){let i=t[s];if(e.has(s)||!at.test(i)){n.push(i);continue}let o=ie(i,r);o.length>0?n.push(...o):n.push(i)}return n}function ie(t,e){let r=t.startsWith("/"),n=t.startsWith("./"),s=t.endsWith("/")&&t.length>1,i=t.split("/").filter(Boolean);if(i.length===0)return r?["/"]:[];let o=[r?"/":"."];for(let u=0;u<i.length;u++){let c=i[u];if(!at.test(c)){o=o.map(l=>H(l,c));continue}o=ue(o,c,u===i.length-1,e)}return s?o=o.filter(u=>e.fs.isDir(w(e.cwd,u))).map(u=>u==="/"?u:u+"/"):o=o.filter(u=>oe(u,e)),n&&(o=o.map(u=>u.startsWith("./")?u:"./"+u)),o.sort(),o}function oe(t,e){let r=w(e.cwd,t);return e.fs.isFile(r)||e.fs.isDir(r)}function ue(t,e,r,n){let s=G(e),i=e.startsWith("."),o=c=>!i&&c.startsWith(".")?!1:s.test(c),u=[];for(let c of t){let l=w(n.cwd,c);if(!n.fs.isDir(l))continue;let{dirs:f,files:a}=n.fs.listDir(l);for(let d of f)o(d)&&u.push(H(c,d));if(r)for(let d of a)o(d)&&u.push(H(c,d))}return u}function H(t,e){return t==="."?e:A(t,e)}var dt=new Set(["name","type","path","mindepth","maxdepth"]);function pt(t,e,r){let n=ce(e);if(n.error)return n.error;let{starts:s,minDepth:i,maxDepth:o,groups:u}=n,c=[];for(let l of s){let f=w(r.cwd,l);if(!r.fs.isDir(f)&&!r.fs.isFile(f))return h(`find: ${l}: no such file or directory`);for(let a of P(r.fs,f,o)){if(a.depth<i)continue;let d=ge(l,f,a.path);de(u,{kind:a.kind,path:d})&&c.push(d)}}return g(c.length===0?"":c.join(`
10
- `)+`
11
- `)}function ce(t){let e=le(t);return e.error?e:fe(e.tokens,e.minDepth,e.maxDepth)}function le(t){let e=[],r=0,n=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s++){let i=t[s],o=i==="-mindepth"||i==="--mindepth"?"mindepth":i==="-maxdepth"||i==="--maxdepth"?"maxdepth":null;if(o){if(s+1>=t.length)return{error:h(`find: -${o} requires a value`)};let u=T(t[s+1],`find: -${o}`);if(u.error)return u;o==="mindepth"?r=u.value:n=u.value,s++;continue}if(i==="--"){e.push(...t.slice(s));break}e.push(i)}return{tokens:e,minDepth:r,maxDepth:n}}function fe(t,e,r){let n=[[]],s=[],i=!1,o=!1,u=!1,c=null;for(let l=0;l<t.length;l++){let f=t[l];if(o){s.push(f);continue}if(f==="-not"||f==="!"){if(i)return{error:h("find: `-not` cannot precede another `-not`")};i=!0,u=!0;continue}if(f==="-a"||f==="-and"||f==="--and"){if(i)return{error:h("find: `-not` must be followed by a primary")};if(c)return{error:h(`find: \`${c}\` with no right-hand expression`)};if(n.at(-1).length===0)return{error:h("find: `-a` with no left-hand expression")};c="-a",u=!0;continue}if(f==="-o"||f==="-or"||f==="--or"){if(i)return{error:h("find: `-not` must be followed by a primary")};if(c)return{error:h(`find: \`${c}\` with no right-hand expression`)};if(n.at(-1).length===0)return{error:h("find: `-o` with no left-hand expression")};n.push([]),c="-o",u=!0;continue}let a=ae(f);if(a!==null){if(l+1>=t.length)return{error:h(`find: ${f} requires a value`)};let d=t[l+1],m=he(a,d);if(m.error)return m;let x={kind:a,value:d,negate:i};(a==="name"||a==="path")&&(x.re=G(d)),n.at(-1).push(x),i=!1,c=null,u=!0,l++;continue}if(f==="--"){o=!0;continue}if(i)return{error:h(`find: \`-not\` must be followed by a primary, got: ${f}`)};if(f.startsWith("-")&&f!=="-"&&!/^-\d/u.test(f))return{error:h(`find: unknown option: ${f}`)};if(u)return{error:h(`find: paths must precede expression: ${f}`)};s.push(f)}return i?{error:h("find: trailing `-not` with no primary")}:c?{error:h(`find: \`${c}\` with no right-hand expression`)}:{starts:s.length>0?s:["."],minDepth:e,maxDepth:r,groups:n}}function ae(t){return/^--?(?:min|max)depth$/u.test(t)?null:t.startsWith("--")&&dt.has(t.slice(2))?t.slice(2):t.startsWith("-")&&dt.has(t.slice(1))?t.slice(1):null}function he(t,e){return t==="type"&&e!=="f"&&e!=="d"?{error:h(`find: -type/--type expects 'f' or 'd', got: ${e}`)}:{}}function de(t,e){return t.some(r=>r.every(n=>pe(n,e)))}function pe(t,e){let r=me(t,e);return t.negate?!r:r}function me(t,e){return t.kind==="type"?t.value==="f"?e.kind==="file":e.kind==="dir":t.kind==="name"?t.re.test(F(e.path)):t.kind==="path"?t.re.test(e.path):!1}function ge(t,e,r){if(r===e)return t;let n=L(e,r);return t.endsWith("/")?t+n:t+"/"+n}function we(t,e,r){return p(e),g(r.cwd+`
12
- `)}function xe(t,e,r){let{positional:n}=p(e),s=n[0]??"/",i=w(r.cwd,s);return r.fs.isDir(i)?(r.cwd=i,g()):h(`cd: not a directory: ${s}`)}function be(t,e,r){let{flags:n,positional:s}=p(Se(e),{short:["l","a"]}),i={long:n.has("l"),all:n.has("a")},o=s.length>0?s:["."],u=[],c=[],l=0;for(let f=0;f<o.length;f++){let a=ve(o[f],o.length>1,i,r);if(a.error){l=1,c.push(a.error);continue}f>0&&o.length>1&&u.push(""),u.push(...a.lines)}return{stdout:u.length===0?"":u.join(`
13
- `)+`
14
- `,stderr:c.length===0?"":c.join(`
15
- `)+`
16
- `,exitCode:l}}function Se(t){let e=[],r=!1;for(let n of t){if(r){e.push(n);continue}if(n==="--"){e.push(n),r=!0;continue}if(n!=="-1"){if(/^-[a-zA-Z0-9]+$/u.test(n)&&n.includes("1")&&/[a-zA-Z]/u.test(n)){e.push("-"+n.slice(1).replaceAll("1",""));continue}e.push(n)}}return e}function ve(t,e,r,n){let s=w(n.cwd,t);if(n.fs.isFile(s))return{lines:[z(t,n.fs.readFile(s).length,!1,r.long)]};if(!n.fs.isDir(s))return{error:`ls: ${t}: no such file or directory`};let i=e?[`${t}:`]:[],{dirs:o,files:u}=n.fs.listDir(s);for(let c of o)!r.all&&c.startsWith(".")||i.push(z(c,0,!0,r.long));for(let c of u){if(!r.all&&c.startsWith("."))continue;let l=A(s,c);i.push(z(c,n.fs.readFile(l).length,!1,r.long))}return{lines:i}}function z(t,e,r,n){let s=t+(r?"/":"");return n?`${r?"d":"-"} ${String(e).padStart(8)} ${s}`:s}function ye(t,e,r){let{positional:n}=p(e),s=n[0]??".",i=w(r.cwd,s);if(!r.fs.isDir(i))return h(`tree: ${s}: not a directory`);let o=[s];return $e(r.fs,i,o),g(o.join(`
17
- `)+`
18
- `)}function $e(t,e,r){let n=[{dir:e,prefix:"",items:mt(t,e),i:0}];for(;n.length>0;){let s=n.at(-1);if(s.i>=s.items.length){n.pop();continue}let{n:i,isDir:o}=s.items[s.i],u=s.i===s.items.length-1;if(r.push(s.prefix+(u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+i+(o?"/":"")),s.i++,!o)continue;let c=A(s.dir,i);n.push({dir:c,prefix:s.prefix+(u?" ":"\u2502 "),items:mt(t,c),i:0})}}function mt(t,e){let{dirs:r,files:n}=t.listDir(e);return[...r.map(s=>({n:s,isDir:!0})),...n.map(s=>({n:s,isDir:!1}))]}function ke(t,e){let{positional:r}=p(e);return r.length===0?k("basename PATH"):g(F(r[0])+`
19
- `)}function Ee(t,e){let{positional:r}=p(e);return r.length===0?k("dirname PATH"):g(I(r[0])+`
20
- `)}var gt={pwd:we,cd:xe,ls:be,find:pt,tree:ye,basename:ke,dirname:Ee};var Te=/^(\d+)(?:,(\d+))?p$/u;function wt(t,e,r){let n;try{n=p(e,{short:["n"]})}catch{return X()}let{flags:s,positional:i}=n;if(!s.has("n")||i.length===0)return X();let o=Te.exec(i[0]);if(!o)return X();let u=Number(o[1]),c=o[2]===void 0?u:Number(o[2]);if(u<1||c<1)return h("sed: line numbers must be >= 1");if(c<u)return h(`sed: reversed range: ${u},${c}`);let l=i.slice(1);if(l.length>1)return h("sed: at most one input file is supported");let f=E("sed",l,t,r),a=f.inputs[0]?.content??"",m=S(a).slice(u-1,c);return y(m.length>0?m.join(`
21
- `)+`
22
- `:"",f)}function X(){return h("sed: only `-n 'X[,Y]p'` (line range print) is supported")}function xt(t,e){let r=t[e+1];if(r===void 0)return-1;if("^$\\.*+?()[]{}|/bBdDsSwW".includes(r)||r>="1"&&r<="9")return 2;let n=i=>i!==void 0&&/[0-9A-Fa-f]/u.test(i),s=(i,o)=>{if(t[e+2]!==i)return 0;let u=t.indexOf(o,e+3);return u>e+3?u-e+1:0};if(r==="x")return n(t[e+2])&&n(t[e+3])?4:0;if(r==="u"){if(t[e+2]==="{"){let i=s("{","}"),o=i?t.slice(e+3,e+i-1):"";return o.length>=1&&o.length<=6&&[...o].every(n)&&parseInt(o,16)<=1114111?i:0}return[2,3,4,5].every(i=>n(t[e+i]))?6:0}return r==="p"||r==="P"?s("{","}"):r==="c"?/[A-Za-z]/u.test(t[e+2]??"")?3:0:r==="k"?s("<",">"):0}function St(t){let e="(){}+?|",r="",n=!1;for(let s=0;s<t.length;s++){let i=t[s];if(n){if(i==="\\"){let o=xt(t,s);if(o===-1)return{error:"trailing backslash (\\)"};if(o>0){r+=t.slice(s,s+o),s+=o-1;continue}r+=t[s+1],s++;continue}r+=i,i==="]"&&(n=!1);continue}if(i==="["){r+=i,n=!0,t[s+1]==="^"&&(r+="^",s++),t[s+1]==="]"&&(r+="\\]",s++);continue}if(i==="\\"){if(s+1>=t.length)return{error:"trailing backslash (\\)"};let o=t[s+1];if(e.includes(o)){r+=o,s++;continue}if(o==="<"||o===">"){r+="\\b",s++;continue}let u=xt(t,s);if(u>0){r+=t.slice(s,s+u),s+=u-1;continue}r+=o,s++;continue}if(i==="*"&&(s===0||t[s-1]==="^"&&bt(t,s-1))){r+="\\*";continue}if(i==="^"&&!bt(t,s)){r+="\\^";continue}if(i==="$"&&!(s===t.length-1||t[s+1]==="\\"&&(t[s+2]===")"||t[s+2]==="|"))){r+="\\$";continue}if(e.includes(i)){r+="\\"+i;continue}r+=i}return{source:r}}function bt(t,e){return e===0?!0:e>=2&&t[e-2]==="\\"&&(t[e-1]==="("||t[e-1]==="|")}var vt="[-i] [-v] [-n] [-r] [-w] [-o] [-E|-F|-G] [-l] [-L] [-c] [-h] [-H] [-A N] [-B N] [-C N]",_e=`grep ${vt} PATTERN [PATH...]
23
- or: grep ${vt} -e PATTERN ... [PATH...]`,Ce=["i","v","n","r","l","L","c","w","h","H","o","E","F","G"],Ne=["A","B","C"];function $t(t,e,r){let n;try{n=p(e,{short:Ce,valueShort:Ne,repeatable:["e"]})}catch(Ot){return h(`grep: ${Ot.message}`,2)}let{flags:s,values:i,positional:o}=n,u=i.get("e")??[],c,l;if(u.length>0)c=u,l=o;else if(o.length>0)c=[o[0]],l=o.slice(1);else return k(_e);let f=Ae(s);if(f)return f;let a=Fe(c,s);if(a.error)return a.error;let d=De(i);if(d.error)return d.error;let m=s.has("r"),x=Ie(m,t,l,r),b=Me(s,m,l.length),_=s.has("v"),$={showName:b,invert:_,showLine:s.has("n"),only:s.has("o"),after:d.after,before:d.before},N=s.has("l")?yt(x.inputs,a.res,_,!1):s.has("L")?yt(x.inputs,a.res,_,!0):s.has("c")?Oe(x.inputs,a.res,_,b):Re(x.inputs,a.res,$);return x.failed?{stdout:N.stdout,stderr:x.stderr+N.stderr,exitCode:2}:N}function Ae(t){if(t.has("h")&&t.has("H"))return h("grep: -h and -H are mutually exclusive");let e=["l","L","c"].filter(n=>t.has(n));if(e.length>1)return h(`grep: ${e.map(n=>`-${n}`).join(" / ")} are mutually exclusive`);let r=["E","F","G"].filter(n=>t.has(n));return r.length>1?h(`grep: ${r.map(n=>`-${n}`).join(" / ")} are mutually exclusive`):null}function Fe(t,e){let r=[],n=e.has("i")?"iu":"u";for(let s of t){let i;if(e.has("F"))i=RegExp.escape(s);else if(e.has("E"))i=s;else{let o=St(s);if(o.error)return{error:h(`grep: ${o.error}`,2)};i=o.source}e.has("w")&&(i=`\\b(?:${i})\\b`);try{r.push(new RegExp(i,n))}catch(o){let u=e.has("F")?`fixed-string /${n}`:e.has("E")?`ERE / ECMAScript /${n}`:`BRE /${n}`;return{error:h(`grep: invalid pattern (${u}): ${o.message}`,2)}}}return{res:r}}function R(t,e){return t.some(r=>r.test(e))}var V=()=>({stdout:"",stderr:"",exitCode:1});function De(t){let e=t.get("C"),r=e===void 0?null:T(e,"grep: -C");if(r?.error)return r;let n=T(t.get("A")??e??"0","grep: -A");if(n.error)return n;let s=T(t.get("B")??e??"0","grep: -B");return s.error?s:{after:n.value,before:s.value}}function Me(t,e,r){return t.has("h")?!1:t.has("H")?!0:e||r>1}function Ie(t,e,r,n){return t?Le("grep",r.length>0?r:["."],n):r.length>0?B("grep",r,n):{inputs:[{name:null,content:e}],stderr:"",failed:!1}}function Le(t,e,r){let n=[],s="",i=!1;for(let o of e){let u=w(r.cwd,o);if(r.fs.isFile(u)){n.push({name:o,content:r.fs.readFile(u)});continue}if(!r.fs.isDir(u)){s+=`${t}: ${o}: no such file or directory
24
- `,i=!0;continue}for(let c of r.fs.walkFiles(u))n.push({name:We(o,u,c),content:r.fs.readFile(c)})}return{inputs:n,stderr:s,failed:i}}function We(t,e,r){let n=L(e,r);return t==="."?n:t.endsWith("/")?t+n:t+"/"+n}function Re(t,e,r){let n=[],s=!1;for(let{name:o,content:u}of t){let c=S(u),l=je(c,e,o,r);l.matched&&(s=!0),l.lines.length>0&&n.push(l.lines.join(`
25
- `))}let i=n.join(`
26
- `);return s?g(i+(i?`
27
- `:"")):V()}function je(t,e,r,n){let{invert:s,after:i,before:o,only:u}=n,c=o>0||i>0,l=[],f=!1,a=-1;for(let d=0;d<t.length;d++){if(R(e,t[d])===s)continue;if(f=!0,u){l.push(...qe(t[d],r,d+1,e,n));continue}let m=Math.max(0,d-o),x=Math.min(t.length-1,d+i);c&&a>=0&&m>a+1&&l.push("--");for(let b=Math.max(m,a+1);b<=x;b++){let _=b===d||R(e,t[b])!==s;l.push(kt(t[b],r,b+1,_,n))}a=x}return{lines:l,matched:f}}function qe(t,e,r,n,s){let i=[];for(let c of n){let l=new RegExp(c.source,c.flags+"g");for(let f of t.matchAll(l))f[0].length>0&&i.push({index:f.index,text:f[0]})}i.sort((c,l)=>c.index-l.index||l.text.length-c.text.length);let o=[],u=0;for(let c of i)c.index<u||(o.push(kt(c.text,e,r,!0,s)),u=c.index+c.text.length);return o}function kt(t,e,r,n,s){let{showName:i,showLine:o}=s,u=n?":":"-",c=[];return i&&c.push(e??"(standard input)"),o&&c.push(String(r)),c.length>0?c.join(u)+u+t:t}function yt(t,e,r,n){let s=[];for(let{name:i,content:o}of t){let c=S(o).some(l=>R(e,l)!==r);(n?!c:c)&&s.push(i??"(standard input)")}return s.length>0?g(v(s)):V()}function Oe(t,e,r,n){let s=[],i=!1;for(let{name:o,content:u}of t){let c=S(u),l=0;for(let f of c)R(e,f)!==r&&l++;l>0&&(i=!0),n?s.push(`${o??"(standard input)"}:${l}`):s.push(String(l))}return s.length===0?V():{stdout:v(s),stderr:"",exitCode:i?0:1}}function Pe(t,e,r){let{flags:n,positional:s}=p(e,{short:["n"]}),i=W("cat",s,t,r);return y(n.has("n")?Be(i.content):i.content,i)}function Be(t){if(t==="")return"";let e=t.endsWith(`
28
- `)?`
29
- `:"";return(e?t.slice(0,-1).split(`
30
- `):t.split(`
31
- `)).map((n,s)=>`${String(s+1).padStart(6)} ${n}`).join(`
32
- `)+e}function He(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["n"]});Ct(n,s);let i=T(n.get("n")??"10","head: -n");return i.error?i.error:Nt("head",t,s,r,o=>o.slice(0,i.value))}function Ge(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["n"]});Ct(n,s);let i=T(n.get("n")??"10","tail: -n");return i.error?i.error:Nt("tail",t,s,r,o=>i.value===0?[]:o.slice(-i.value))}function Ct(t,e){t.has("n")||e[0]&&/^-\d+$/u.test(e[0])&&t.set("n",e.shift().slice(1))}function Nt(t,e,r,n,s){let i=E(t,r,e,n),o=i.inputs.length>1,u=[];for(let c=0;c<i.inputs.length;c++){let{name:l,content:f}=i.inputs[c],a=s(S(f)).join(`
33
- `);o?u.push(`${c>0?`
34
- `:""}==> ${l} <==
35
- ${a}${a?`
36
- `:""}`):a.length>0&&u.push(a+`
37
- `)}return y(u.join(""),i)}function ze(t,e,r){let{flags:n,positional:s}=p(e,{short:["l","w","c"]}),i=Xe(n),o=E("wc",s,t,r),u=[],c={l:0,w:0,c:0};for(let{name:l,content:f}of o.inputs){let a=Ue(f);u.push(Et(a,l,i)),c.l+=a.l,c.w+=a.w,c.c+=a.c}return o.inputs.length>1&&u.push(Et(c,"total",i)),y(v(u),o)}function Xe(t){return t.has("l")||t.has("w")||t.has("c")?{l:t.has("l"),w:t.has("w"),c:t.has("c")}:{l:!0,w:!0,c:!0}}var Ve=new TextEncoder;function Ue(t){return{l:(t.match(/\n/gu)??[]).length,w:(t.match(/\S+/gu)??[]).length,c:Ve.encode(t).length}}function Et(t,e,r){let n=[];return r.l&&n.push(String(t.l).padStart(7)),r.w&&n.push(String(t.w).padStart(7)),r.c&&n.push(String(t.c).padStart(7)),n.join(" ")+(e?" "+e:"")}function Ke(t,e,r){let{flags:n,positional:s}=p(e,{short:["n","r","u"]}),i=W("sort",s,t,r),o=S(i.content),u=n.has("n"),c=n.has("u");if(u){let l=o.map(f=>({line:f,key:Tt(f)}));l.sort(c?(f,a)=>f.key-a.key:(f,a)=>f.key-a.key||(f.line<a.line?-1:f.line>a.line?1:0)),o=l.map(f=>f.line)}else o.sort();if(c){let l=new Set;o=o.filter(f=>{let a=u?Tt(f):f;return l.has(a)?!1:(l.add(a),!0)})}return n.has("r")&&o.reverse(),y(v(o),i)}function Tt(t){let e=/^[ \t]*(-?(?:\d+\.?\d*|\.\d+))/u.exec(t);return e?Number(e[1]):0}function Ye(t,e,r){let{flags:n,positional:s}=p(e,{short:["c","d","u","i"]}),i=W("uniq",s,t,r),o=n.has("c"),u=n.has("d"),c=n.has("u"),l=n.has("i"),f=$=>l?$.toLowerCase():$,a=S(i.content),d=[],m=null,x=null,b=0,_=()=>{if(m===null)return;let $=b>=2;!(u&&c)&&(u?$:!c||!$)&&d.push(o?`${String(b).padStart(7)} ${m}`:m)};for(let $ of a){let N=f($);if(N===x){b++;continue}_(),m=$,x=N,b=1}return _(),y(v(d),i)}function Ze(t,e){let{flags:r,positional:n}=p(e,{short:["n","e","E"]}),s=n.join(" "),i=!r.has("n");if(r.has("e")){let o=Qe(s);s=o.text,o.stop&&(i=!1)}return g(i?s+`
38
- `:s)}function Qe(t){let e={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,"\\":92},r="";for(let n=0;n<t.length;n++){if(t[n]!=="\\"||n+1>=t.length){r+=t[n];continue}let s=t[++n];if(s==="c")return{text:r,stop:!0};if(s in e){r+=String.fromCodePoint(e[s]);continue}if(s==="0"){let i="";for(;i.length<3&&/[0-7]/u.test(t[n+1]??"");)i+=t[++n];r+=String.fromCodePoint(i===""?0:parseInt(i,8));continue}if(s==="x"&&/[0-9a-fA-F]/u.test(t[n+1]??"")){let i="";for(;i.length<2&&/[0-9a-fA-F]/u.test(t[n+1]??"");)i+=t[++n];r+=String.fromCodePoint(parseInt(i,16));continue}r+="\\"+s}return{text:r,stop:!1}}function Je(t,e,r){let{flags:n,values:s,positional:i}=p(e,{short:["r"],valueShort:["n"],stopAtFirstPositional:!0}),[o="echo",...u]=i,c=t.split(/\s+/u).filter(Boolean);if(c.length===0)return n.has("r")?g():r.dispatch(o,u,"");let l=s.has("n")?T(s.get("n"),"xargs: -n"):{value:c.length};return l.error?l.error:s.has("n")&&l.value===0?h("xargs: -n: must be at least 1"):tn(r,o,u,c,l.value)}function tn(t,e,r,n,s){let i="",o="",u=0;for(let c=0;c<n.length;c+=s){let l=t.dispatch(e,[...r,...n.slice(c,c+s)],"");i+=l.stdout,o+=l.stderr,l.exitCode!==0&&(u=l.exitCode)}return{stdout:i,stderr:o,exitCode:u}}function _t(){return g()}function en(){return{stdout:"",stderr:"",exitCode:1}}var At={cat:Pe,grep:$t,head:He,tail:Ge,wc:ze,sort:Ke,uniq:Ye,echo:Ze,xargs:Je},Ft={true:_t,false:en,":":_t};function Dt(t,e,r){let{index:n,pipe:s}=rn(t),i=t.slice(n),o=sn(i),u=i.slice(o),c=i.slice(0,o).trim(),l=c==="",f=l?"":r.resolveCommand(c.split(/\s+/u)[0]),a=t.slice(0,n+o),d=s&&a.endsWith("|")?" ":"";return nn(u,l,s,f,e,r).map(m=>a+d+m)}function nn(t,e,r,n,s,i){if(!e)return r?[]:on(t,s,n==="cd");let o=r?i.pipeNames:i.names;for(let u of i.binPrefixes)if(t.startsWith(u)){let c=t.slice(u.length);return o.filter(l=>l.startsWith(c)).map(l=>u+l)}return t.startsWith("/")||t.startsWith("./")?[]:o.filter(u=>u.startsWith(t))}function rn(t){let e=0,r=!1,n=0;for(;n<t.length;){let s=t[n];if(s==="|"){let i=t[n+1]==="|";n+=i?2:1,e=n,r=!i}else s==="&"&&t[n+1]==="&"?(n+=2,e=n,r=!1):s===";"?(n++,e=n,r=!1):n++}return{index:e,pipe:r}}function sn(t){for(let e=t.length-1;e>=0;e--)if(/\s/u.test(t[e]))return e+1;return 0}function on(t,e,r=!1){let n=t.lastIndexOf("/"),s=t.slice(0,n+1),i=t.slice(n+1),o=w(e.cwd,s);if(!e.fs.isDir(o))return[];let{dirs:u,files:c}=e.fs.listDir(o),l=i.startsWith("."),f=[];for(let a of u)!l&&a.startsWith(".")||a.startsWith(i)&&f.push(s+a+"/");if(r)return f;for(let a of c)!l&&a.startsWith(".")||a.startsWith(i)&&f.push(s+a);return f}var j={__proto__:null,...At,...gt,...ft},U={__proto__:null,sed:wt,...Ft},un=["ls","cd","cat","grep","find","head","tail","wc","tree","sort","uniq","cut","tr","nl","tac","xargs","echo","pwd","seq","which","basename","dirname"],Mt=fn(),cn=Mt.join(", "),ln=["grep","head","tail","wc","sort","uniq","cut","xargs","tr","nl","tac","cat"];function fn(){let t=new Set(Object.keys(j)),e=[];for(let r of un)t.delete(r)&&e.push(r);return e.push(...[...t].sort()),e}function It(t,e={}){let r=ot(t),s={cwd:e.cwd===void 0?"/":w("/",e.cwd),fs:r};if(s.dispatch=(i,o,u)=>Rt(i,o,u,s),s.hasCommand=i=>!!(j[i]||U[i]),!r.isDir(s.cwd))throw new Error(`createTerminal: cwd is not a directory: ${s.cwd}`);return{run:i=>an(i,s),cwd:()=>s.cwd,complete:i=>Dt(i,s,{names:Mt,pipeNames:ln,binPrefixes:Lt,resolveCommand:Wt})}}var Lt=["/usr/local/bin/","/usr/bin/","/bin/","/sbin/"];function Wt(t){for(let e of Lt)if(t.startsWith(e)){let r=t.slice(e.length);if(j[r]||U[r])return r}return t}function Rt(t,e,r,n){let s=Wt(t),i=j[s]??U[s];if(!i)return mn(t);try{return i(r,e,n)}catch(o){return h(`${t}: ${o.message}`)}}function an(t,e){try{let r=t.trim();if(r==="")return{stdout:"",stderr:"",exitCode:0,cwd:e.cwd};let n=nt(r);return{...jt(n,e,""),cwd:e.cwd}}catch(r){return{...h(`error: ${r.message}`),cwd:e.cwd}}}function jt(t,e,r){let n="",s="",i=0,o=!1;for(let u=0;u<t.length;u++){let c=t[u];if(c.gate==="and"&&i!==0||c.gate==="or"&&i===0)continue;let l=hn(c.stages,e,u===0?r:"");n+=l.stdout,s+=l.stderr,i=l.exitCode,o=!0}return o||(i=0),{stdout:n,stderr:s,exitCode:i}}function hn(t,e,r){let n=r,s="";for(let i=0;i<t.length;i++){let o=t[i],u=o.group?pn(o.group,e,n):dn(o,e,n),c=u.stdout,l=u.stderr;if(o.mergeStderrToStdout&&(c+=l,l=""),o.mergeStdoutToStderr&&(l+=c,c=""),o.stdoutToNull&&(c=""),o.stderrToNull&&(l=""),s+=l,i===t.length-1)return{stdout:c,stderr:s,exitCode:u.exitCode};n=c}return{stdout:"",stderr:s,exitCode:0}}function dn(t,e,r){let n=tt(t.argv,t.quoted??new Set),s=ht(n.argv,n.quoted,e);return Rt(s[0],s.slice(1),r,e)}function pn(t,e,r){let n=e.cwd;try{return jt(t,e,r)}finally{e.cwd=n}}function mn(t){return h(`${t}: command not found. Available: ${cn}`,127)}var qt=`:host{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--bg, #0c0c0c);color:var(--text, #e6edf3);font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:13px;line-height:1.45}.output{flex:1 1 auto;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;padding:12px 14px 6px;cursor:text}.banner{color:var(--muted, #8b949e);margin-bottom:8px}.banner .cmd{color:var(--accent, #58a6ff)}.banner .cmd:hover{text-decoration:underline}.line{white-space:pre-wrap;overflow-wrap:break-word}.cwd{color:var(--accent, #58a6ff)}.sigil{color:var(--muted, #8b949e);margin:0 6px 0 4px}.stdout,.stderr{margin:0 0 4px;font:inherit;white-space:pre-wrap;overflow-wrap:break-word}.stderr{color:var(--critical, #d8413a)}.form{flex:0 0 auto;display:flex;align-items:center;padding:8px 14px 10px;border-top:1px solid var(--border, #2c2c2c)}.form:focus-within{border-top-color:var(--accent, #58a6ff)}.form .cwd{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none}.form .sigil{flex:0 0 auto;user-select:none}.input-wrap{flex:1 1 auto;min-width:0;position:relative;display:flex;align-items:center}.input{width:100%;background:transparent;border:none;outline:none;color:inherit;font:inherit;padding:0;position:relative}.ghost{position:absolute;inset:0;display:flex;align-items:center;font:inherit;white-space:pre;overflow:hidden;pointer-events:none;user-select:none;color:var(--muted, #8b949e);opacity:.55}.ghost-pad{color:transparent}
39
- `;function wn(t){let r=["ls","find /",`grep -r ${xn(t)} .`];if(!t||t.size===0)return r;let n=null;for(let s of t.keys()){let i=bn(s);(n===null||i.length<n.length)&&(n=i)}return n&&r.push(`cat ${n} | head -n 20`),r}var K=["TODO","FIXME","XXX","HACK","NOTE","BUG","export","import","require","//"];function xn(t){if(!t||t.size===0)return K[0];for(let e of K)for(let r of t.values())if(r.includes(e))return e;return K[0]}function bn(t){return t.startsWith("./")?t.slice(2):t.startsWith("/")?t.slice(1):t}var Y=class t extends Q{static properties={sources:{attribute:!1},_lines:{state:!0},_input:{state:!0},_cwd:{state:!0},_ghost:{state:!0}};static styles=J(qt);#n=null;#c=null;#e=[];#t=-1;#s="";#r=null;#i=null;static#a=200;constructor(){super(),this.sources=null,this._lines=[],this._input="",this._cwd="/",this._ghost=""}willUpdate(e){e.has("sources")&&this.sources!==this.#c&&(this.#n=this.sources?It(this.sources):null,this._cwd=this.#n?this.#n.cwd():"/",this._lines=[{kind:"banner",commands:wn(this.sources)}],this.#e=[],this.#t=-1,this.#s="",this.#r=null,this._input="",this.#c=this.sources),e.has("_input")&&(this.#u(),this.#f())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#l())}disconnectedCallback(){super.disconnectedCallback(),this.#u()}firstUpdated(){this.#o()}updated(e){(e.has("_lines")||e.has("sources"))&&this.#l()}#o(){let e=this.renderRoot.querySelector(".input");e&&e.focus()}#l(){let e=this.renderRoot.querySelector(".output");e&&(e.scrollTop=e.scrollHeight)}#h=e=>{if(e.preventDefault(),!this.#n)return;let r=this._input,n=r.trim();if(n==="clear"){this._lines=[],this._input="",n.length>0&&(this.#e=[...this.#e,r]),this.#t=-1;return}let s=this._cwd,i=this.#n.run(r);this._cwd=i.cwd;let o=[...this._lines,{kind:"prompt",cwd:s,text:r}];i.stdout&&o.push({kind:"stdout",text:i.stdout}),i.stderr&&o.push({kind:"stderr",text:i.stderr}),this._lines=o,n.length>0&&(this.#e=[...this.#e,r]),this.#t=-1,this._input=""};#d=e=>{if(e.key==="Tab"&&!e.shiftKey){e.preventDefault(),this.#p();return}this.#r=null,e.key==="ArrowUp"?(e.preventDefault(),this.#g()):e.key==="ArrowDown"&&(e.preventDefault(),this.#w()),this.#u(),this.#f()};#p(){if(!this.#n)return;let e=this.#r;if(e&&e.items[e.index]===this._input){e.index=(e.index+1)%e.items.length,this._input=e.items[e.index];return}let r=this.#n.complete(this._input);if(r.length===0){this.#r=null;return}this._input=r[0],this.#r=r.length>1?{items:r,index:0}:null}#u(){this._ghost="",this.#i!==null&&(clearTimeout(this.#i),this.#i=null)}#f(){this.#i=setTimeout(()=>{this.#i=null,this.#m()},t.#a)}#m(){if(!this.#n||this.#r)return;let e=this._input,r=e.slice(-1),n=e===""||r===" "||r==="|",s=/[\w./]/u.test(r);if(!n&&!s)return;let i=this.#n.complete(e);if(i.length===0)return;let o=i[0];!o.startsWith(e)||o===e||s&&i.includes(e)||(this._ghost=o.slice(e.length))}#g(){this.#e.length!==0&&(this.#t<0?(this.#s=this._input,this.#t=this.#e.length-1):this.#t=Math.max(0,this.#t-1),this._input=this.#e[this.#t])}#w(){if(this.#t<0)return;let e=this.#t+1;e>=this.#e.length?(this.#t=-1,this._input=this.#s,this.#s=""):(this.#t=e,this._input=this.#e[e])}#x=e=>{this._input=e.target.value};#b=e=>{this._input=e,this.#t=-1,this.#s="",this.#o()};#S=()=>{let e=this.renderRoot.getSelection?.()??document.getSelection();e&&!e.isCollapsed||this.#o()};render(){return C`<div class="output" @click="${this.#S}">${this._lines.map(e=>this.#v(e))}</div><form class="form" @submit="${this.#h}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?C`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:q} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#x}" @keydown="${this.#d}"></div></form>`}#v(e){return e.kind==="banner"?C`<div class="banner">Virtual shell over the bundle source tree. Try ${e.commands.map((r,n)=>C`${n>0?", ":""}\`<span class="cmd" @click="${()=>this.#b(r)}">${r}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:e.kind==="prompt"?C`<div class="line"><span class="cwd">${e.cwd}</span><span class="sigil">$</span>${e.text}</div>`:e.kind==="stdout"?C`<pre class="stdout">${e.text}</pre>`:e.kind==="stderr"?C`<pre class="stderr">${e.text}</pre>`:q}};customElements.define("bundle-terminal",Y);function vr(t,e){let r=document.createElement("bundle-terminal");return r.dataset.integrity=e??"",r.sources=t,r}export{vr as createTerminalElement};
1
+ import{a as fc,b as hr,c as Kt,d as dc,e as Xe,f as et,g as Fs,h as pc,i as On,j as Co,k as Jt,l as hc,m as Qt,n as T,o as mr,p as mc,q as _o,r as Rs,s as Ms,t as Ds,v as gc,w as Us,z as Lo}from"./chunk-RFZQQXSG.js";import{a as cc}from"./chunk-TZ5KB2Y5.js";import"./chunk-XYFXXB2G.js";import"./chunk-C4Z6ZBXV.js";import{a as uc,c as Ge,g as Ls,j as lc}from"./chunk-2XUEZHIP.js";import{b as nx}from"./chunk-OOJM4CTU.js";var rx={__proto__:null,ENOENT:"No such file or directory",ENOTDIR:"Not a directory",EISDIR:"Is a directory",EEXIST:"File exists",ENOTEMPTY:"Directory not empty",ELOOP:"Too many levels of symbolic links",EINVAL:"Invalid argument",EPERM:"Operation not permitted",EBUSY:"Device or resource busy",EILSEQ:"Invalid or incomplete multibyte or wide character",ENAMETOOLONG:"File name too long"},ox=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/gu,ix=e=>`${e}`.replaceAll(ox,t=>`\\u${t.codePointAt(0).toString(16).padStart(4,"0")}`),Ue=(e,t,n="a string")=>new TypeError(`${e} must be ${n}, not ${t===null?"null":typeof t}`),F=class extends Error{constructor(t,n){super(`${ix(n)}: ${rx[t]??t}`),this.name="VfsError",this.code=t,this.path=n}};var wc=(e,t="path")=>{if(typeof e!="string")throw Ue(t,e);return e};function yc(e,t){let n=Math.min(wc(e).length,wc(t).length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.codePointAt(r)-t.codePointAt(r);return e.length-t.length}var gr=e=>[...e.entries.keys()].sort(yc),Fo=(e,t)=>t===""?e:e==="/"?`/${t}`:`${e}/${t}`;function*en(e,t=r=>r,n=()=>!0){let r=[{name:"",node:e,depth:0}];for(;r.length>0;){let o=r.pop();if(yield t(o),o.node.type!=="directory"||!n(o))continue;let i=gr(o.node);for(let s=i.length-1;s>=0;s--){let a=o.name===""?i[s]:`${o.name}/${i[s]}`;r.push({name:a,leaf:i[s],parent:o.node,node:o.node.entries.get(i[s]),depth:o.depth+1})}}}var sx=new Set(["error","keep","replace"]);function xc(e,t,n="'error', 'keep' or 'replace'"){if(typeof e!="string")throw Ue(t,e,n);if(!sx.has(e))throw new RangeError(`${t} must be ${n}, not ${JSON.stringify(e)}`);return e}function bc({clash:e="error",fold:t}){if(typeof e!="function"&&xc(e,"clash","'error', 'keep', 'replace' or a function"),t!==void 0&&typeof t!="function")throw Ue("fold",t,"a function");return{fold:t,settle:typeof e=="function"?(n,r)=>xc(e(n,r),"what clash returns"):()=>e}}function kc(e,t,n,{settle:r,fold:o},i){let s=ax(t,i.copy),a=new Map([[s,{into:e}]]),u=[];for(let{name:l,leaf:c,parent:f,node:d}of en(s,void 0,p=>a.has(p.node))){if(f===void 0)continue;let p=a.get(f),h=p.into.entries.get(c);if(h?.type==="directory"&&d.type==="directory"){a.set(d,{into:h});continue}let m=h===void 0?ux(p,f,c,o):[c];if(m.length>0){let g=Fo(n,l),w=r(g,m.map(y=>g.slice(0,-c.length)+y));if(w==="error")throw new F("EEXIST",g);if(w==="keep")continue}u.push({dir:p.into,name:c,node:d,taken:m})}for(let{dir:l,name:c,node:f,taken:d}of u){for(let p of en(f))i.number(p.node);for(let p of d)l.entries.delete(p);l.entries.set(c,f)}}function*vc(e,t,n){for(let{name:r,node:o}of en(e))if(o.type==="directory")for(let i of Map.groupBy(gr(o),s=>n(s)).values())i.length>1&&(yield{path:Fo(t,r),names:i})}function ax(e,t){let n=new Map;for(let{node:r,parent:o,leaf:i}of en(e))n.has(r)||n.set(r,t(r)),o!==void 0&&n.get(o).entries.set(i,n.get(r));return n.get(e)}function ux(e,t,n,r){return r===void 0?[]:(e.keys??=Map.groupBy(gr(e.into).filter(o=>!t.entries.has(o)),o=>r(o)),e.keys.get(r(n))??[])}var lx=40,cx=255,Sc=4096,fx=new Uint8Array,Ac={file:420,directory:493,symlink:511},dx=new TextEncoder,px=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),Ro=e=>typeof e=="string"&&e.endsWith("/"),In=class{#t;#s=0;constructor(){this.#t=this.#e()}#n(t,n,r=Ac[t],o=0){return{ino:++this.#s,type:t,mode:Uo(r),mtime:Po(o),...n}}#e(t,n){return this.#n("directory",{entries:new Map},t,n)}#i(t,{follow:n=!0,mkdirs:r=!1,create:o=!1}={}){if(typeof t!="string")throw Ue("a path",t);if(t.includes("\0"))throw new F("EINVAL",t);if(t==="")throw new F("ENOENT",t);let i=t.endsWith("/"),s=[Ec(t)],a=[{name:"",node:this.#t}],u=lx,l,c,f,d;for(;;){for(;s.length>1&&Ps(s.at(-1));)s.pop();if(Ps(s.at(-1))){({name:f,node:d}=a.pop()),l=void 0;break}if(c=s.length>1,f=hx(s.at(-1)),f===".")continue;if(f===".."){a.length>1&&a.pop();continue}l=a.at(-1).node;let p=s.every(Ps);if(d=l.entries.get(f),o&&!p&&s.every(zs)){i=!0;break}if(d===void 0){if(p)break;if(!r||c)throw new F("ENOENT",t);Do(f,t),d=this.#e(),l.entries.set(f,d)}if(d.type==="symlink"&&(!p||n)){if(u--===0)throw new F("ELOOP",t);d.target.startsWith("/")&&(a.length=1),s.push(Ec(d.target,!0));continue}if(p){if(i&&!o&&d.type!=="directory")throw new F("ENOTDIR",t);break}if(d.type!=="directory")throw new F("ENOTDIR",t);a.push({name:f,node:d})}return{dir:l,name:f,node:d,trailing:i,chain:a,linked:c}}#r(t,n=!0){let r=this.#i(t,{follow:n});if(r.node===void 0)throw new F("ENOENT",t);return r}#o(t,n){return this.#r(t,n).node}#u(t,n,r){Do(t.name,r),t.dir.entries.set(t.name,n)}#a(t,n){if(t.dir!==void 0)return t.dir;throw new F(Bs(n,0)===n.length?"EBUSY":"EINVAL",n)}#l(t,n,r){try{return this.#o(t,r).type===n}catch(o){if(o instanceof F)return!1;throw o}}stat(t){return $c(this.#o(t,!0))}lstat(t){return $c(this.#o(t,Ro(t)))}isFile(t){return this.#l(t,"file",!0)}isDirectory(t){return this.#l(t,"directory",!0)}isSymlink(t){return this.#l(t,"symlink",!1)}realpath(t){return Mo(this.#r(t))}readFile(t){let n=this.#o(t,!0);if(n.type==="directory")throw new F("EISDIR",t);return n.bytes}readText(t){let n=this.readFile(t);try{return px.decode(n)}catch{throw new F("EILSEQ",t)}}readlink(t){let n=this.#o(t,Ro(t));if(n.type!=="symlink")throw new F("EINVAL",t);return n.target}readdir(t){let n=this.#o(t,!0);if(n.type!=="directory")throw new F("ENOTDIR",t);return gr(n)}#c(t,n,r,o,i){let s=Ic(n,t),a=this.#i(t,{follow:!Ro(t),create:!0});if(a.trailing||a.node?.type==="directory")throw new F("EISDIR",t);a.node===void 0?this.#u(a,this.#n("file",{bytes:s},o,i),t):r(a.node,s)}writeFile(t,n,{mode:r,mtime:o}={}){this.#c(t,n,(i,s)=>Object.assign(i,{bytes:s,...mx(i,r,o)}),r,o)}appendFile(t,n){this.#c(t,n,(r,o)=>{r.bytes=wx(r.bytes,o)})}mkdir(t,{recursive:n=!1,mode:r,mtime:o}={}){let i=this.#i(t,{follow:n,mkdirs:n,create:!n});if(i.node===void 0){if(i.linked)throw new F("ENOENT",t);this.#u(i,this.#e(r,o),t)}else if(!n||i.node.type!=="directory")throw new F("EEXIST",t)}symlink(t,n,{mode:r,mtime:o}={}){if(typeof t!="string")throw Ue("a link target",t);if(t===""||t.includes("\0"))throw new F("EINVAL",n);Do(t,n,Sc),this.#u(this.#f(n),this.#n("symlink",{target:t,size:Nc(t)},r,o),n)}hardlink(t,n){let r=this.#o(t,Ro(t)),o=this.#f(n);if(r.type==="directory")throw new F("EPERM",t);this.#u(o,r,n)}#f(t){let n=this.#i(t,{follow:!1,create:!0});if(n.node!==void 0)throw new F("EEXIST",t);if(n.trailing)throw new F("ENOENT",t);return n}unlink(t){this.rm(t)}rmdir(t){let n=this.#r(t,!1);if(n.node.type!=="directory")throw new F("ENOTDIR",t);let r=this.#a(n,t);if(n.node.entries.size>0)throw new F("ENOTEMPTY",t);r.entries.delete(n.name)}rm(t,{recursive:n=!1}={}){let r=this.#r(t,!1);if(r.node.type==="directory"&&!n)throw new F("EISDIR",t);this.#a(r,t).entries.delete(r.name)}rename(t,n){let r=this.#i(t,{follow:!1,create:!0}),o=this.#i(n,{follow:!1,create:!0}),i=this.#a(r,t),s=this.#a(o,n);if(r.node===void 0)throw new F("ENOENT",t);Do(o.name,n);let a=r.node.type==="directory";if(!a&&(r.trailing||o.trailing))throw new F("ENOTDIR",r.trailing?t:n);if(o.chain.some(u=>u.node===r.node))throw new F("EINVAL",n);if(r.chain.some(u=>u.node===o.node))throw new F("ENOTEMPTY",n);if(o.node!==r.node){if(o.node!==void 0&&o.node.type==="directory"!==a)throw new F(a?"ENOTDIR":"EISDIR",n);if(o.node?.type==="directory"&&o.node.entries.size>0)throw new F("ENOTEMPTY",n);i.entries.delete(r.name),s.entries.set(o.name,r.node)}}chmod(t,n){this.#o(t,!0).mode=Uo(n)}utimes(t,n){this.#o(t,!0).mtime=Po(n)}mount(t,n="/",r={}){if(t===null||typeof t!="object"||!(#t in t))throw Ue("a tree",t,"a Vfs");let o=bc(r),i=this.#r(n);if(i.node.type!=="directory")throw new F("ENOTDIR",n);kc(i.node,t.#t,Mo(i),o,{copy:gx,number:s=>{s.ino||=++this.#s}})}walk(t="/"){let n=this.#r(t),r=Mo(n);return en(n.node,({name:o,node:i,depth:s})=>({path:Fo(r,o),type:i.type,depth:s}))}collisions(t,n="/"){if(typeof t!="function")throw Ue("fold",t,"a function");let r=this.#r(n);return vc(r.node,Mo(r),t)}entries(t="/"){let n=this.#r(t),r=n.node.type==="directory"?".":n.name,o=new Map;return en(n.node,({name:i,node:s})=>{let a=i===""?r:i,u={name:a,type:s.type,mode:s.mode,mtime:s.mtime,linkname:"",data:fx},l=o.get(s);return l!==void 0?(u.type="hardlink",u.linkname=l):s.type==="symlink"?(o.set(s,a),u.linkname=s.target):s.type==="file"&&(o.set(s,a),u.data=s.bytes),u})}},Ec=(e,t=!1)=>({text:e,at:Bs(e,0),dot:t&&e.endsWith("/")}),zs=e=>e.at===e.text.length,Ps=e=>zs(e)&&!e.dot,Bs=(e,t)=>{let n=t;for(;e[n]==="/";)n++;return n};function hx(e){if(zs(e))return e.dot=!1,".";let t=e.text.indexOf("/",e.at),n=t===-1?e.text.length:t,r=e.text.slice(e.at,n);return e.at=Bs(e.text,n),r}var Mo=({chain:e,name:t})=>`/${[...e.slice(1).map(n=>n.name),t].filter(Boolean).join("/")}`,$c=e=>({type:e.type,ino:e.ino,mode:e.mode,mtime:e.mtime,size:e.bytes?.length??e.size??0}),mx=(e,t=e.mode,n=e.mtime)=>({mode:Uo(t),mtime:Po(n)});function Do(e,t,n=cx){if(!e.isWellFormed())throw new F("EILSEQ",t);if(Oc(e,n))throw new F("ENAMETOOLONG",t)}function Nc(e){let t=0;for(let n of e){let r=n.codePointAt(0);t+=r<128?1:r<2048?2:r<65536?3:4}return t}var Oc=(e,t)=>e.length>t||e.length*3>t&&Nc(e)>t;function Uo(e){if(!Number.isInteger(e)||e<0||e>4095)throw new RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`);return e}function Po(e){if(!Number.isSafeInteger(e))throw new RangeError(`an mtime must be an integer of whole seconds, not ${e}`);return e}function Ic(e,t){if(typeof e=="string"){if(!e.isWellFormed())throw new F("EILSEQ",t);return dx.encode(e)}if(e instanceof Uint8Array)return new Uint8Array(e);throw Ue("file contents",e,"a string or a Uint8Array")}function gx({type:e,mode:t,mtime:n,bytes:r,target:o,size:i}){let s={ino:0,type:e,mode:t,mtime:n};return e==="directory"?s.entries=new Map:e==="symlink"?Object.assign(s,{target:o,size:i}):s.bytes=r.byteOffset+r.length===r.buffer.byteLength?r:r.slice(),s}function wx(e,t){let n=e.length+t.length,r=e.byteOffset+n<=e.buffer.byteLength,o=r?new Uint8Array(e.buffer,e.byteOffset,n):new Uint8Array(Math.max(n,e.length*2)).subarray(0,n);return r||o.set(e),o.set(t,e.length),o}function zo(e){if(Object.keys(e).length>0)throw new TypeError("Unexpected extra options")}var p4=Object.getPrototypeOf(Uint8Array);var Cc=globalThis.atob,_c=Uint8Array.prototype.toBase64,Tc=8192,yx=_c&&Cc;function js(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return"";if(yx&&r>=256&&r<1e8&&e.toBase64===_c&&e.BYTES_PER_ELEMENT===1){let i=t===0&&n===e.length?e:e.subarray(t,n);return Cc(i.toBase64())}if(r>Tc){let i="";for(let s=t;s<n;){let a=Math.min(n,s+Tc);i+=String.fromCharCode.apply(String,e.subarray(s,a)),s=a}return i}let o=t===0&&n===e.length?e:e.subarray(t,n);return String.fromCharCode.apply(String,o)}var Tn=hr?e=>e.byteLength>=768&&!dc?hr.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):et.decode(e):Fs?e=>Fs.decode(e):e=>js(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var Lc=e=>fc(e,new Uint8Array(e.length)),xx=Kt&&Xe?.encodeInto,wr=xx?(e,t)=>{let n=new Uint8Array(e.length+4),r=Xe.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw new SyntaxError(t);return n.subarray(0,e.length)}:hr?(e,t)=>{let n=hr.from(e,"utf8");if(n.length!==e.length)throw new SyntaxError(t);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}:(e,t)=>{let n=Xe.encode(e);if(n.length!==e.length)throw new SyntaxError(t);return n};var Gs={};nx(Gs,{E_CHAR:()=>Cn,E_LAST:()=>Ws,E_LENGTH:()=>Pc,E_PADDING:()=>Uc,fromBase64:()=>Hs,toBase64:()=>qs});var Fc=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],Rc=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],Mc={},Dc={},Cn="Invalid character in base64 input",Uc="Invalid base64 padding",Pc="Invalid base64 length",Ws="Invalid last chunk";function qs(e,t,n){let r=e.length/3|0,o=r*3,i="",s=0,a=t?Rc:Fc,u=t?Dc:Mc;if(!u.pairs)if(u.pairs=[],et){u.codepairs=new Uint16Array(4096);let h=u.codepairs,m=new Uint8Array(h.buffer,h.byteOffset,h.byteLength);for(let g=0;g<64;g++){let w=a[g].charCodeAt(0);for(let y=0;y<64;y++)m[g<<7|y<<1]=m[y<<7|(g<<1)+1]=w}}else{let h=u.pairs;for(let m=0;m<64;m++)for(let g=0;g<64;g++)h.push(`${a[m]}${a[g]}`)}let{pairs:l,codepairs:c}=u;if(et){let h=new Uint16Array(r*2),m=0;for(let g=e.length-11;s<g;s+=12,m+=8){let w=e[s],y=e[s+1],$=e[s+2],S=e[s+3],_=e[s+4],W=e[s+5],H=e[s+6],re=e[s+7],le=e[s+8],ce=e[s+9],An=e[s+10],Nn=e[s+11];h[m]=c[w<<4|y>>4],h[m+1]=c[(y&15)<<8|$],h[m+2]=c[S<<4|_>>4],h[m+3]=c[(_&15)<<8|W],h[m+4]=c[H<<4|re>>4],h[m+5]=c[(re&15)<<8|le],h[m+6]=c[ce<<4|An>>4],h[m+7]=c[(An&15)<<8|Nn]}for(let g=e.length-2;s<g;s+=3,m+=2){let w=e[s],y=e[s+1],$=e[s+2];h[m]=c[w<<4|y>>4],h[m+1]=c[(y&15)<<8|$]}i=Tn(h)}else for(;s<o;s+=3){let h=e[s],m=e[s+1],g=e[s+2];i+=l[h<<4|m>>4],i+=l[(m&15)<<8|g]}let f=0,d=2,p=e.length;for(;s<p;s++){let h=e[s];i+=a[f|h>>d],d===6&&(d=0,i+=a[h&63]),f=h<<6-d&63,d+=2}return d!==2&&(i+=a[f]),n&&(i+=["","==","="][p-o]),i}var bx=Xe?128:65536;function Hs(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,o=n%4,i=n-o;if(o===1)throw new SyntaxError(Pc);if(r>3||r!==0&&e.length%4!==0)throw new SyntaxError(Uc);let s=t?Rc:Fc,a=t?Dc:Mc;a.fromMap||(a.fromMap=new Int8Array(bx).fill(-1),s.forEach((h,m)=>a.fromMap[h.charCodeAt(0)]=m));let u=a.fromMap,l=new Uint8Array(Math.floor(n*3/4)),c=0,f=0;if(Xe){let h=wr(e,Cn);for(;f<i;f+=4){let m=h[f],g=h[f+1],w=h[f+2],y=h[f+3],$=u[m]<<18|u[g]<<12|u[w]<<6|u[y];if($<0)throw new SyntaxError(Cn);l[c]=$>>16,l[c+1]=$>>8&255,l[c+2]=$&255,c+=3}}else for(;f<i;f+=4){let h=e.charCodeAt(f),m=e.charCodeAt(f+1),g=e.charCodeAt(f+2),w=e.charCodeAt(f+3),y=u[h]<<18|u[m]<<12|u[g]<<6|u[w];if(y<0)throw new SyntaxError(Cn);l[c]=y>>16,l[c+1]=y>>8&255,l[c+2]=y&255,c+=3}if(o<2)return l;let d=u[e.charCodeAt(f++)]<<6|u[e.charCodeAt(f++)];if(d<0)throw new SyntaxError(Cn);if(l[c++]=d>>4,o<3){if(d&15)throw new SyntaxError(Ws);return l}let p=u[e.charCodeAt(f++)];if(p<0)throw new SyntaxError(Cn);if(l[c++]=d<<4&255|p>>2,p&3)throw new SyntaxError(Ws);return l}var{Buffer:tn,atob:Hc,btoa:Gc}=globalThis,Xc=tn&&!tn.TYPED_ARRAY_SUPPORT,{toBase64:zc}=Uint8Array.prototype,{E_CHAR:yr,E_PADDING:br,E_LENGTH:kx,E_LAST:vx}=Gs,Ex=Gc&&Kt,$x=Hc&&Kt,Sx=e=>e.constructor===tn&&tn.isBuffer(e),Ax=e=>Sx(e)?e:tn.from(e.buffer,e.byteOffset,e.byteLength);function Bc(e,t){if(t)return e;let n=e.indexOf("=",e.length-3);return n===-1?e:e.slice(0,n)}function jc(e,t){return t&&e.length%4!==0?e+"=".repeat(4-e.length%4):e}var Nx=e=>zc&&e.toBase64===zc;function kr(e,{padding:t=!0}={}){return On(e),Nx(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):Xc?Bc(Ax(e).base64Slice(0,e.byteLength),t):Ex?Bc(Gc(js(e)),t):qs(e,!1,t)}function vr(e,t){if(typeof t=="string"&&(t={format:t}),!t)return Wc(e,!1,"both","uint8",null);let{format:n="uint8",padding:r="both",...o}=t;return Wc(e,!1,r,n,o)}function Wc(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Co);o!==null&&zo(o);let i=n==="both"?e.endsWith("="):void 0;if(n===!0||i===!0){if(e.length%4!==0)throw new SyntaxError(br);if(e[e.length-3]==="=")throw new SyntaxError(br)}else if(n===!1||i===!1){if(e.length%4===1)throw new SyntaxError(kx);if(n===!1&&e.endsWith("="))throw new SyntaxError("Did not expect padding in base64 input")}else throw new TypeError("Invalid padding option");return xr(e,t,n,r)}var Ox=/[\t\n\f\r ]/;function qc(e,t){let n=e.indexOf("=",e.length-3),r=n>=0?e.length-n:0,o=e.length-r,i=o%4,s=t.length-(o-i)/4*3;return i===0&&s===0||i===2&&s===1||i===3&&s===2}var xr;Uint8Array.fromBase64?xr=(e,t,n,r)=>{let o=t?"base64url":"base64",i;if(n===!0)i=Uint8Array.fromBase64(e,{alphabet:o,lastChunkHandling:"strict"});else try{let s=e.length%4>0?`${e}${"=".repeat(4-e.length%4)}`:e;i=Uint8Array.fromBase64(s,{alphabet:o,lastChunkHandling:"strict"})}catch(s){throw Ox.test(e)?new SyntaxError(yr):s}if(!qc(e,i))throw new SyntaxError(yr);return Jt(i,r)}:Xc?xr=(e,t,n,r)=>{let o=tn.byteLength(e,"base64"),i=tn.allocUnsafeSlow(o);if(i.base64Write(e)!==o)throw new SyntaxError(br);let s=t?i.base64urlSlice(0,i.length):i.base64Slice(0,i.length);if(e!==s){if(n===!t)throw new SyntaxError(br);if(jc(e,!0)!==jc(s,t))throw new SyntaxError(br)}return hc(i,r)}:$x?xr=(e,t,n,r)=>{let o;if(t){if(/[\t\n\f\r +/]/.test(e))throw new SyntaxError(yr);e=e.replaceAll("-","+").replaceAll("_","/")}try{o=Lc(Hc(e))}catch{throw new SyntaxError(yr)}if(!t&&!qc(e,o))throw new SyntaxError(yr);if(o.length%3!==0){let i=kr(o.subarray(-(o.length%3))),s=e.length%4===0?e.slice(-4):e.slice(-(e.length%4)).padEnd(4,"=");if(i!==s)throw new SyntaxError(vx)}return Jt(o,r)}:xr=(e,t,n,r)=>Jt(Hs(e,t),r);var R=(e="")=>({stdout:e,stderr:"",exitCode:0}),b=(e,t=1)=>({stdout:"",stderr:e.endsWith(`
2
+ `)?e:e+`
3
+ `,exitCode:t}),xe=(e,t=1)=>b(`usage: ${e}`,t);var Zc=Symbol("unsupported");function C(e){if(e==null)return null;try{return e[Zc]??null}catch{return null}}function v(e,t,n,r,o=1){return X(b(r,o),e,t,n,r)}function X(e,t,n,r,o){return Object.defineProperty(e,Zc,{value:{kind:t,command:n,detail:r,message:o},enumerable:!1,configurable:!0}),e}function Q(e,t,n,r){let o=C(e);return o?v(o.kind,t,o.detail,n,r):b(n,r)}var x=class extends Error{constructor(t,n,r){super(r),this.name="UnsupportedError",X(this,t,null,n,r)}};function Xs(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let o=JSON.stringify([n.kind,r,n.detail]);e.has(o)||(e.add(o),t.push(Object.freeze(n)))}}}function I(e){try{return Qt(e)}catch(t){throw t instanceof TypeError?new x("feature","unpaired surrogate","unpaired UTF-16 surrogates cannot be encoded as UTF-8"):t}}var Ix=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Bo(e){for(let t=0;t<e.length;){let n=Kc[e[t]],r=n===1?e[t]:n===0?-1:Vc(e,t,n);yield r,t+=r<0?1:n}}var Tx=[0,0,128,2048,65536];function Vc(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let o=1;o<n;o++){if((e[t+o]&192)!==128)return-1;r=r<<6|e[t+o]&63}return r<Tx[n]||r>1114111||r>=55296&&r<=57343?-1:r}var Ys=e=>mc(e);function ve(e){let t;try{t=mr(e)}catch{}return t}function Vs(e){let t=ve(e);if(t!==void 0)return t;let n=new Uint16Array(e.length),r=0;for(let i=0;i<e.length;){let s=Kc[e[i]],a=s===1?e[i]:s===0?-1:Vc(e,i,s);if(a<0){n[r++]=56320+e[i++];continue}a>65535?(n[r++]=55232+(a>>10),n[r++]=56320+(a&1023)):n[r++]=a,i+=s}let o="";for(let i=0;i<r;i+=Yc)o+=String.fromCharCode.apply(null,n.subarray(i,Math.min(r,i+Yc)));return o}var Yc=4096,Kc=Uint8Array.from({length:256},(e,t)=>Ix(t)),nn="\\uDC80-\\uDCFF",_n=new RegExp(`[${nn}]`,"u"),_t=e=>e>=56448&&e<=56575;function Ks(e){if(!_n.test(e))return I(e);let t=new Uint8Array(e.length*3),n=0;for(let r=0;r<e.length;r++){let o=e.codePointAt(r);if(o<128)t[n++]=o;else if(_t(o))t[n++]=o-56320;else if(o<2048)n=Zs(t,n,192|o>>6,o,1);else if(o<65536){if(o>=55296&&o<=57343)return I(e);n=Zs(t,n,224|o>>12,o,2)}else n=Zs(t,n,240|o>>18,o,3),r++}return t.slice(0,n)}function Zs(e,t,n,r,o){e[t++]=n;for(let i=o-1;i>=0;i--)e[t++]=128|r>>6*i&63;return t}function Ze(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((r,o)=>r+o.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function G(e){try{return mr(e)}catch{throw new x("feature","partial UTF-8 byte sequence","byte output that is not valid UTF-8 cannot be represented by this string-based terminal")}}function Ln(e){let t=e.startsWith("/"),n=e.split("/").filter(Boolean),r=[];for(let o of n)if(o!=="."){if(o===".."){r.length>0&&r.at(-1)!==".."?r.pop():t||r.push("..");continue}r.push(o)}return t?"/"+r.join("/"):r.length===0?".":r.join("/")}function j(e,t){return t.startsWith("/")?Ln(t):Ln(e+"/"+t)}var Cx=40,jo=(e,t)=>e.isLink?.(t)===!0;function E(e,t,n,{follow:r=!0}={}){let o=tt(e,t,n,{follow:r});return o.error?{path:null,error:o.error}:t.endsWith("/")&&!n.isDir(o.path)?{path:null,error:"Not a directory"}:{path:o.path,error:null}}function tt(e,t,n,{follow:r=!0,lenient:o=!1}={}){if(t===""||t.includes("\0"))return{path:"/",error:"No such file or directory",rest:[]};let i=(t.startsWith("/")?t:e+"/"+t).split("/").filter(Boolean),s=r||t.endsWith("/"),a=Cx,u="/";for(;i.length>0;){let c=i.shift();if(!n.isDir(u)){if(!o){let d=n.isFile(u)||jo(n,u)?"Not a directory":"No such file or directory";return{path:u,error:d,rest:[c,...i]}}c===".."?u=oe(u):c!=="."&&(u=he(u,c));continue}if(c===".."){u=oe(u);continue}if(c!=="."&&(u=he(u,c)),!jo(n,u)||i.length===0&&!s)continue;if(a--===0)return{path:u,error:"Too many levels of symbolic links",rest:[...i]};let f=n.readLink(u);u=f.startsWith("/")?"/":oe(u),i.unshift(...f.split("/").filter(Boolean),...f.endsWith("/")?["."]:[])}let l=!n.isDir(u)&&!n.isFile(u)&&!jo(n,u);return{path:u,error:l?"No such file or directory":null,rest:[]}}var me=(e,t,n,r=!0)=>n===""||n.includes("\0")?j(t,n):tt(t,n,e,{follow:r,lenient:!0}).path;function gt(e,t,n,r=E(e,t,n)){if(r.path!==null)return null;if(t===""||t.includes("\0")||t.endsWith("/")||r.error!=="No such file or directory")return r.error;let o=tt(e,t,n);return o.rest.length>0?o.error:n.isDir(oe(o.path))?null:"Not a directory"}function oe(e){let t=Ln(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return n<0?".":n===0?"/":t.slice(0,n)}function Ne(e){let t=Ln(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return t.slice(n+1)}function q(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e.codePointAt(n)-t.codePointAt(n);return e.length-t.length}function he(e,t){return e==="/"?"/"+t:e+"/"+t}function nt(e,t){return e==="/"?t.slice(1):t.slice(e.length+1)}function Lt(e,t,n="reading them as text"){let r=ve(e);if(r===void 0)throw new x("feature","binary file",`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var Er=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r]);function*rt(e,t,n=Number.POSITIVE_INFINITY,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:"file",depth:0};return}if(!e.isDir(t)){jo(e,t)&&(yield{path:t,kind:"link",depth:0});return}let o=[{path:t,kind:"dir",depth:0}];for(;o.length;){let i=o.pop();if(yield i,i.kind!=="dir"||i.depth>=n||!r(i.path))continue;let{dirs:s,files:a,links:u=[]}=e.listDir(i.path),l=s.length-1,c=a.length-1,f=u.length-1;for(;l>=0||c>=0||f>=0;){let d=l>=0?"dir":null,p=l>=0?s[l]:null;c>=0&&(p===null||q(a[c],p)>=0)&&(d="file",p=a[c]),f>=0&&(p===null||q(u[f],p)>=0)&&(d="link",p=u[f]),d==="dir"?l--:d==="file"?c--:f--,o.push({path:he(i.path,p),kind:d,depth:i.depth+1})}}}function*Jc(e,t){for(let n of rt(e,t))n.kind==="file"&&(yield n.path)}function rf(e,t="/"){let n=new In;try{n.mkdir(t,{recursive:!0})}catch(o){throw Js(o,`mount ${JSON.stringify(t)}`)}let r={declared:new Map,made:new Set(["/",t])};for(let[o,i]of Mx(e)){let s=String(o);if(s.includes("\0"))throw new TypeError("createTerminal: source paths must not contain NUL characters");let a=Ux(i,s),u=Ln("/"+s);_x(n,r,t==="/"?u:u==="/"?t:t+u,a,s)}return Fx(n)}function _x(e,t,n,r,o){let i=t.declared.get(n);if(i!==void 0){if(i===r.type&&Lx(e,n,r))return;throw new TypeError(`createTerminal: source ${JSON.stringify(o)} names the same path as an earlier source, which declared something else there`)}t.declared.set(n,r.type);let s=n.slice(0,n.lastIndexOf("/"))||"/";if(!t.made.has(s)){try{e.mkdir(s,{recursive:!0})}catch(a){throw a?.code==="ENOENT"?Qc(o):Js(a?.code==="EEXIST"?new F("ENOTDIR",s):a,`source ${JSON.stringify(o)}`)}if(e.realpath(s)!==s)throw Qc(o);t.made.add(s)}try{if(r.type==="file")e.writeFile(n,r.data);else if(r.type==="symlink")e.symlink(r.target,n);else{try{e.mkdir(n)}catch(a){if(a?.code!=="EEXIST"||e.lstat(n).type!=="directory")throw a}t.made.add(n)}}catch(a){throw Js(a,`source ${JSON.stringify(o)}`)}}var Qc=e=>new TypeError(`createTerminal: source ${JSON.stringify(e)} is declared through a symbolic link; declare it where the link leads`);function Js(e,t){return e instanceof F?new TypeError(`createTerminal: ${t}: ${e.message}`,{cause:e}):e}function Lx(e,t,n){return n.type==="directory"?!0:n.type==="symlink"?e.readlink(t)===n.target:Er(e.readFile(t),typeof n.data=="string"?I(n.data):n.data)}var of={directory:"dirs",file:"files",symlink:"links"},Wo=e=>e.slice(0,e.lastIndexOf("/"))||"/",Qs=()=>({dirs:[],files:[],links:[]});function Fx(e){let t=null,n=null,r={children:new Map,types:new Map},o=()=>n??=Rx(e,s),i=new WeakMap,s=d=>t!==null&&(d===t||d.startsWith(t+"/")),a=d=>{let p=r.children.get(d);if(p!==void 0)return p;p={listing:Qs(),types:new Map};for(let h of e.readdir(d)){let{type:m}=e.lstat(he(d,h));p.types.set(h,m),p.listing[of[m]].push(h)}return r.children.set(d,p),p},u=d=>{if(typeof d!="string"||!d.startsWith("/"))return;if(d==="/")return"directory";let p=[],h=d;for(;s(Wo(h))&&!r.types.has(h);)p.push(h),h=Wo(h);let m=s(Wo(h))?r.types.get(h):o().types.get(h)??"";for(let g=p.length-1;g>=0;g--){let w=p[g];m=m==="directory"?a(Wo(w)).types.get(w.slice(w.lastIndexOf("/")+1))??"":"",r.types.set(w,m)}return m||void 0},l=d=>u(d)===void 0?void 0:e.lstat(d),c=d=>u(d)==="file"?e.readFile(d):void 0,f={vfs:e,writableAt:d=>{t=d,n=null,r={children:new Map,types:new Map}},reshaped:()=>{r={children:new Map,types:new Map}},isFile:d=>u(d)==="file",isDir:d=>u(d)==="directory",isLink:d=>u(d)==="symlink",readLink:d=>u(d)==="symlink"?e.readlink(d):void 0,readFile:d=>{let p=c(d),h=p&&i.get(p);return p&&h===void 0&&i.set(p,h=Lt(p,JSON.stringify(d))),h},readBytes:d=>c(d),fileSize:d=>{let p=l(d);return p===void 0||p.type==="directory"?void 0:p.size},sameFileContents:(d,p)=>Er(c(d),c(p)),exactBytes:c,isBytes:d=>u(d)==="file",isEmptyFile:d=>{let p=l(d);return p?.type==="file"&&p.size===0},listDir:d=>{if(u(d)!=="directory")throw new Error(`not a directory: ${d}`);return s(d)?a(d).listing:o().children.get(d)},walkFiles:d=>Jc(f,d)};return f}function Rx(e,t){let n=new Map([["/",Qs()]]),r=new Map([["/","directory"]]),o=["/"];for(let{path:i,type:s,depth:a}of e.walk("/")){if(a===0)continue;let u=o[a-1];s==="directory"&&(o[a]=i),!t(u)&&(s==="directory"&&n.set(i,Qs()),n.get(u)[of[s]].push(i.slice(u.length+(u==="/"?0:1))),r.set(i,s))}return{children:n,types:r}}function Mx(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}var ef={file:["data"],directory:[],symlink:["target"]},Dx=new Set(["mode","mtime"]);function Ux(e,t){let n=JSON.stringify(t);if(typeof e=="string")return{type:"file",data:tf(e,t)};if(ArrayBuffer.isView(e))return{type:"file",data:nf(e,t)};if(e instanceof ArrayBuffer)throw new TypeError(`createTerminal: source ${n} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(e===null||typeof e!="object"||Array.isArray(e)){let i=e===null?"null":Array.isArray(e)?"an array":e===void 0?"undefined":`a ${typeof e}`;throw new TypeError(`createTerminal: source ${n} is ${i}; a source is text, a Uint8Array, or an object declaring its type`)}if(e.format!==void 0)return{type:"file",data:Px(e,t)};let{type:r}=e;if(r==="link")throw new TypeError(`createTerminal: source ${n} declares type "link"; a symbolic link is declared as { type: 'symlink', target }`);if(r==="hardlink")throw new TypeError(`createTerminal: source ${n} declares a hard link, which is not supported: each file here has the one name`);if(r===void 0)throw new TypeError(`createTerminal: source ${n} declares no type; an object declares { type: 'file' | 'directory' | 'symlink' } or { format: 'base64', data }`);if(!Object.hasOwn(ef,r))throw new TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(r)}; the types are 'file', 'directory' and 'symlink'`);for(let i of Object.keys(e))if(!(i==="type"||ef[r].includes(i)))throw new TypeError(Dx.has(i)?`createTerminal: source ${n} declares \`${i}\`, which this terminal does not keep yet`:`createTerminal: source ${n} declares \`${i}\`, which a ${r} does not have`);if(r==="directory")return{type:r};if(r==="symlink"){let{target:i}=e;if(typeof i!="string"||i===""||i.includes("\0"))throw new TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{type:r,target:i}}let{data:o=""}=e;if(typeof o=="string")return{type:r,data:tf(o,t)};if(ArrayBuffer.isView(o))return{type:r,data:nf(o,t)};throw new TypeError(`createTerminal: source ${n} declares \`data\` that is neither text nor a Uint8Array`)}function tf(e,t){if(!e.isWellFormed())throw new TypeError(`createTerminal: source ${JSON.stringify(t)} holds a lone surrogate, which no UTF-8 spells; declare the file's bytes as a Uint8Array`);return e}function Px(e,t){let n=JSON.stringify(t);if(e.format!=="base64")throw new TypeError(`createTerminal: source ${n} declares format ${JSON.stringify(e.format)}; the only format is { format: 'base64', data }`);let r=Object.keys(e).find(o=>o!=="format"&&o!=="data");if(r!==void 0)throw new TypeError(`createTerminal: source ${n} declares \`${r}\`, which base64 contents do not have`);if(typeof e.data!="string")throw new TypeError(`createTerminal: source ${n} must declare its base64 as a string in \`data\``);try{return vr(e.data)}catch(o){throw o instanceof SyntaxError?new TypeError(`createTerminal: source ${n} declares base64 that does not decode`,{cause:o}):o}}function nf(e,t){if(e.BYTES_PER_ELEMENT!==1)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is a ${e[Symbol.toStringTag]??"view"}; declare a file's bytes as a Uint8Array`);return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var rn={__proto__:null,alpha:"A-Za-z",digit:"0-9",alnum:"0-9A-Za-z",upper:"A-Z",lower:"a-z",space:" \\t\\n\\v\\f\\r",blank:" \\t",punct:"!-\\/:-@\\[-`{-~",xdigit:"0-9A-Fa-f",cntrl:"\\x00-\\x1F\\x7F",print:"\\x20-\\x7E",graph:"\\x21-\\x7E",word:"0-9A-Za-z_"},$r={__proto__:null};for(let[e,t]of Object.entries(rn)){let n=new RegExp(`[${t}]`,"u"),r=[];for(let o=0;o<128;o++){if(!n.test(String.fromCodePoint(o)))continue;let i=r.at(-1);i&&i[1]===o-1?i[1]=o:r.push([o,o])}$r[e]=r}var qo=32767;function sf(e,t){if(e>qo||t!==void 0&&t>qo)throw new Error("Regular expression too big")}function Ho(e,t,n=!1){let r=t+1;e[r]==="^"&&r++;let o=!0,i=!1;for(;r<e.length;){let s=e[r];if(s==="]"&&!o)return r;if(o=!1,s==="["&&":.=".includes(e[r+1]??"")){let l=e[r+1],c=e.indexOf(l+"]",r+2);if(c===-1)throw new Error("Unmatched [, [^, [:, [., or [=");if(l===":"&&!(e.slice(r+2,c)in rn))throw new Error("Invalid character class name");if(l!==":"&&n&&/\P{ASCII}/u.test(e.slice(r+2,c)))throw new Error("Invalid collation character");r=c+2,i=l!==".";continue}if(s==="-"&&i&&r+1<e.length&&e[r+1]!=="]")throw new Error("Invalid range end");let a=s==="\\"&&r+1<e.length?2:1;if(e[r+a]==="-"&&e[r+a+1]!==void 0&&e[r+a+1]!=="]"){let l=r+a+1,c=e[l]==="["?e[l+1]:void 0;if(c===":"||c==="=")throw new Error("Invalid range end");let f=c==="."?e.indexOf(".]",l+2):-1;if(c==="."&&f===-1)throw new Error("Unmatched [, [^, [:, [., or [=");let d=c==="."?l+2:l+(e[l]==="\\"?1:0);if(n&&(e.codePointAt(r+a-1)>127||e.codePointAt(d)>127))throw new Error("Invalid collation character");r=f===-1?l+(e[l]==="\\"?2:1):f+2,i=!0;continue}r+=a,i=!1}throw new Error("Unmatched [, [^, [:, [., or [=")}function Fn(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let o=n.classes?n.classes.body(r[1]):rn[r[1]];if(o===void 0){if(n?.unknown!=="empty")throw new Error(`invalid character class \`[:${r[1]}:]\``);return{body:"",end:t+r[0].length}}return{body:o,end:t+r[0].length}}var Go={alpha:"1t:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,3:3,3:7,2:1,2:1,1:0,8:0,4:1,1:4,2:b,a:0,4:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,4:4,4:1,2:1,4:0,7:3,1:0,7:f,b:2,1:8,1:2,1:l,1:6,1:1,1:4,3:8,1:2,1:1,3:0,f:3,2:9,9:3,4:2,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,9:1,4:1,1:4,2:9,1:0,g:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:2,3:0,6:0,e:9,g:c,1:2,1:m,1:f,3:7,1:2,1:2,8:1,1:2,2:0,2:3,2:9,g:3,1:7,1:2,1:m,1:9,1:4,3:7,1:2,1:2,8:1,6:1,1:3,2:9,1:2,c:c,1:2,1:14,2:7,1:2,1:2,1:0,5:3,7:4,2:9,a:5,1:2,1:h,3:n,1:8,1:0,2:6,8:5,1:0,1:7,6:9,2:1,d:1l,5:6,6:0,2:9,13:1,1:0,1:4,1:n,1:0,1:i,1:2,2:4,1:0,6:0,2:9,2:3,w:0,v:9,m:7,1:z,4:i,4:f,1:z,1v:1i,1:0,2:e,6:25,2:11,1:0,5:0,2:16,1:98,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,11:f,g:2d,2:5,3:h7,2:g,1:p,5:22,3:a,7:j,b:k,c:j,c:c,1:2,1:1,c:1f,2:i,e:0,4:0,3:9,12:9,6:2g,7:16,5:1x,a:u,1:b,4:8,d:13,2:4,b:17,4:p,6:9,12:r,4:1q,2:j,b:9,6:9,d:0,n:1,b:2,1d:1f,1:e,1:7,3:9,12:15,2:1l,1:a,e:1i,9:9,3:1c,2:8,7:16,2:2,15:3,1:5,1:1,3:0,5:5b,13:d,b:7p,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:6,1:0,3:2,1:6,3:3,2:5,4:c,5:2,1:6,38:0,d:0,g:c,2t:0,4:0,2:9,1:0,3:4,6:0,1:0,1:0,1:3,1:a,2:3,5:4,4:0,h:14,ml:1f,1ee:6c,6:3,3:1,c:11,1:0,5:0,2:1j,7:0,g:m,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:v,1b:0,d1:2,p:8,7:4,2:4,4:2d,6:2,1:2h,1:3,5:16,1:2l,h:v,1c:f,e8:533,1s:h3g,1v:19,2:7g,3:r,k:1a,5:7,3:34,13:8,2:2u,2:1r,5:1,1:0,1:4,o:j,1:w,o:1f,c:1v,1:0,a:9,o:5,3:0,1:19,5:y,d:s,3:1e,1:b,f:a,6:u,1:1i,9:d,2:9,6:m,3:1w,1:0,1:0,o:2,2:f,2:3,b:5,2:5,2:5,9:6,1:6,1:16,1:d,6:3e,5:9,6:8mb,c:m,4:1c,6is:a5,2:2x,12:6,c:4,5:b,1:c,1:4,1:0,1:1,1:1,1:2z,x:a2,i:1r,2:1h,14:b,38:4,1:3q,j:9,7:p,6:p,b:2g,3:5,2:5,2:5,2:2,z:b,1:p,1:i,1:1,1:e,2:d,y:3e,1x:1g,7f:s,3:1c,1b:v,d:t,5:16,5:t,2:z,4:7,1:4,16:4d,2:9,6:z,4:z,4:13,8:1f,c:a,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,a:m,9:u,1t:i,1:1,a:l,a:p,1y:1j,6:1,1s:3,1:1,5:7,1:2,1:s,16:s,3:s,z:7,1:r,r:1h,a:l,a:i,d:h,32:20,1j:1e,d:1e,d:13,8:9,92:15,1:1,3:1,26:s,a:0,8:l,16:h,1a:k,r:m,9:1x,w:9,1:4,a:1k,9:0,d:o,7:9,6:1e,3:9,4:3,8:y,3:0,9:1r,1:3,9:c,1:0,z:h,1:x,2:0,6:3,1q:6,1:0,1:3,1:e,1:9,7:1k,7:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,3:0,6:0,5:6,4c:1t,1:2,1:3,5:9,5:2,u:1t,2:1,1:0,8:9,4m:1h,2:6,p:5,y:1q,1:0,3:0,b:9,12:1h,2:0,7:9,1i:q,2:d,5:9,6:6,55:1k,2v:21,l:7,2:0,2:7,1:1,1:t,1:1,2:1,2:3,d:9,1y:7,2:19,2:5,1:0,1:1,r:1e,2:9,h:1z,5:0,i:20,7b:8,1:18,1:6,1:0,f:9,o:t,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:2,1:0,2:1,8:9,6:5,1:1,1:10,1:1,1:3,1:0,7:9,8m:m,9:g,1:14,3:2,f:9,2e:0,27:pl,2u:32,h:5f,218:2o,f:tr,h:5,33t:g6,6nt:fs,7:u,1:9,6:26,1:9,6:t,i:1b,g:3,c:9,9:k,5:i,j4:1r,3k:22,4:1k,7:g,1s:1,1:0,c:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,4:0,4m9:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:o,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:7,2:1d,1ds:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,a:6,2:9,4:0,8x:t,i:17,4:9,d2:r,4:9,km:6,1:3,1:1,1:e,1:5g,1n:1v,3:0,3:0,4:9,x2:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,hg:p,6:p,6:p,21y:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f",digit:"1c:9",alnum:"1c:9,7:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,3:3,3:7,2:1,2:1,1:0,8:0,4:1,1:4,2:b,a:0,4:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,4:4,4:1,2:1,4:0,7:3,1:0,7:f,b:2,1:8,1:2,1:l,1:6,1:1,1:4,3:8,1:2,1:1,3:0,f:3,2:9,9:3,4:2,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,9:1,4:1,1:4,2:9,1:0,g:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:2,3:0,6:0,e:9,g:c,1:2,1:m,1:f,3:7,1:2,1:2,8:1,1:2,2:0,2:3,2:9,g:3,1:7,1:2,1:m,1:9,1:4,3:7,1:2,1:2,8:1,6:1,1:3,2:9,1:2,c:c,1:2,1:14,2:7,1:2,1:2,1:0,5:3,7:4,2:9,a:5,1:2,1:h,3:n,1:8,1:0,2:6,8:5,1:0,1:7,6:9,2:1,d:1l,5:6,6:0,2:9,13:1,1:0,1:4,1:n,1:0,1:i,1:2,2:4,1:0,6:0,2:9,2:3,w:0,v:9,m:7,1:z,4:i,4:f,1:z,1v:1i,1:0,2:e,6:25,2:11,1:0,5:0,2:16,1:98,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,11:f,g:2d,2:5,3:h7,2:g,1:p,5:22,3:a,7:j,b:k,c:j,c:c,1:2,1:1,c:1f,2:i,e:0,4:0,3:9,12:9,6:2g,7:16,5:1x,a:u,1:b,4:8,d:13,2:4,b:17,4:p,6:9,12:r,4:1q,2:j,b:9,6:9,d:0,n:1,b:2,1d:1f,1:e,1:7,3:9,12:15,2:1l,1:a,e:1i,9:9,3:1c,2:8,7:16,2:2,15:3,1:5,1:1,3:0,5:5b,13:d,b:7p,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:6,1:0,3:2,1:6,3:3,2:5,4:c,5:2,1:6,38:0,d:0,g:c,2t:0,4:0,2:9,1:0,3:4,6:0,1:0,1:0,1:3,1:a,2:3,5:4,4:0,h:14,ml:1f,1ee:6c,6:3,3:1,c:11,1:0,5:0,2:1j,7:0,g:m,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:v,1b:0,d1:2,p:8,7:4,2:4,4:2d,6:2,1:2h,1:3,5:16,1:2l,h:v,1c:f,e8:533,1s:h3g,1v:19,2:7g,3:r,k:1a,5:7,3:34,13:8,2:2u,2:1r,5:1,1:0,1:4,o:j,1:w,o:1f,c:1v,1:0,a:9,o:5,3:0,1:19,5:y,d:s,3:1e,1:b,f:a,6:u,1:1i,9:d,2:9,6:m,3:1w,1:0,1:0,o:2,2:f,2:3,b:5,2:5,2:5,9:6,1:6,1:16,1:d,6:3e,5:9,6:8mb,c:m,4:1c,6is:a5,2:2x,12:6,c:4,5:b,1:c,1:4,1:0,1:1,1:1,1:2z,x:a2,i:1r,2:1h,14:b,38:4,1:3q,j:9,7:p,6:p,b:2g,3:5,2:5,2:5,2:2,z:b,1:p,1:i,1:1,1:e,2:d,y:3e,1x:1g,7f:s,3:1c,1b:v,d:t,5:16,5:t,2:z,4:7,1:4,16:4d,2:9,6:z,4:z,4:13,8:1f,c:a,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,a:m,9:u,1t:i,1:1,a:l,a:p,1y:1j,6:1,1s:3,1:1,5:7,1:2,1:s,16:s,3:s,z:7,1:r,r:1h,a:l,a:i,d:h,32:20,1j:1e,d:1e,d:13,8:9,92:15,1:1,3:1,26:s,a:0,8:l,16:h,1a:k,r:m,9:1x,w:9,1:4,a:1k,9:0,d:o,7:9,6:1e,3:9,4:3,8:y,3:0,9:1r,1:3,9:c,1:0,z:h,1:x,2:0,6:3,1q:6,1:0,1:3,1:e,1:9,7:1k,7:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,3:0,6:0,5:6,4c:1t,1:2,1:3,5:9,5:2,u:1t,2:1,1:0,8:9,4m:1h,2:6,p:5,y:1q,1:0,3:0,b:9,12:1h,2:0,7:9,1i:q,2:d,5:9,6:6,55:1k,2v:21,l:7,2:0,2:7,1:1,1:t,1:1,2:1,2:3,d:9,1y:7,2:19,2:5,1:0,1:1,r:1e,2:9,h:1z,5:0,i:20,7b:8,1:18,1:6,1:0,f:9,o:t,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:2,1:0,2:1,8:9,6:5,1:1,1:10,1:1,1:3,1:0,7:9,8m:m,9:g,1:14,3:2,f:9,2e:0,27:pl,2u:32,h:5f,218:2o,f:tr,h:5,33t:g6,6nt:fs,7:u,1:9,6:26,1:9,6:t,i:1b,g:3,c:9,9:k,5:i,j4:1r,3k:22,4:1k,7:g,1s:1,1:0,c:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,4:0,4m9:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:o,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:7,2:1d,1ds:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,a:6,2:9,4:0,8x:t,i:17,4:9,d2:r,4:9,km:6,1:3,1:1,1:e,1:5g,1n:1v,3:0,3:0,4:9,x2:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,hg:p,6:p,6:p,21y:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f",upper:"1t:p,2t:m,1:6,x:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,3:1,1:0,1:1,1:2,2:3,1:1,1:2,3:1,1:1,1:0,1:0,1:1,1:0,2:0,1:1,1:2,1:0,1:1,3:0,7:1,1:1,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:1,1:0,1:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,7:1,1:1,2:0,1:3,1:0,1:0,1:0,1:0,81:0,1:0,3:0,8:0,6:0,1:2,1:0,1:1,1:g,1:8,z:0,2:2,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,5:0,2:0,1:1,2:1e,1c:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:11,289:11,1:0,5:0,k2:2d,1p6:16,2:2,8w:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:7,8:5,a:7,8:7,8:5,b:0,1:0,1:0,1:0,8:7,o:7,8:7,8:7,8:4,b:4,b:3,c:4,b:4,79:0,4:0,3:2,2:2,2:0,3:4,6:0,1:0,1:0,1:3,2:3,a:1,5:0,q:f,j:0,mq:p,1f4:1b,1c:0,1:2,2:0,1:0,1:0,1:3,1:0,2:0,8:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,8:0,1:0,4:0,nyl:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,j:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,3r:0,1:0,1:0,1:0,1:0,1:0,1:0,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,a:0,1:0,1:1,1:0,1:0,1:0,1:0,4:0,1:0,2:0,1:0,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:4,1:4,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:3,1:0,6:0,5:0,1:0,s:0,h7v:p,xx:13,3s:z,4c:a,1:e,1:6,1:1,1d6:1e,2ct:v,gw0:v,k2o:p,q:p,q:p,q:0,1:1,2:0,2:1,2:3,1:7,q:p,q:1,1:3,2:7,1:6,r:1,1:3,1:4,1:0,3:6,r:p,q:p,q:p,q:p,q:p,q:p,u:o,x:o,x:o,x:o,x:o,x:0,3ed:x,1la:p,6:p,6:p",lower:"2p:p,1b:0,a:0,4:0,10:n,1:7,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:2,2:0,1:0,2:0,3:1,4:0,2:0,3:2,2:0,2:0,1:0,1:0,2:0,1:1,1:0,2:0,3:0,1:0,2:1,2:2,5:1,1:1,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:1,1:0,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:6,2:0,2:1,1:0,4:0,1:0,1:0,1:0,1:1w,1:z,7:1,u:4,2o:0,17:0,1:0,3:0,2:3,i:0,r:y,1:1,3:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:4,1:0,2:0,2:1,1f:1b,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1c:14,287:16,1:3,l4:5,1oi:8,3b:5b,1t:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:8,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:8,8:5,a:7,8:7,8:5,a:7,8:7,8:d,2:7,8:7,8:7,8:4,1:1,6:0,3:2,1:1,8:3,2:1,8:7,a:2,1:1,3d:0,d:0,g:c,31:0,3:1,3:0,r:0,4:0,4:0,2:1,8:3,4:0,x:f,4:0,nf:p,1fq:1b,1:0,3:1,1:0,1:0,1:0,4:0,1:1,1:7,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,7:0,1:0,4:0,c:11,1:0,5:0,nwz:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,j:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:2,3p:0,1:0,1:0,1:0,1:0,1:0,1:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:9,1:0,1:0,2:0,1:0,1:0,1:0,1:0,4:0,1:0,2:0,1:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,5:0,5:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,4:0,1:0,6:0,1:0,1:0,1:0,1:0,o:2,1:0,1:2,mt:16,1:d,6:27,fnk:6,c:4,tl:p,y5:13,3s:z,4b:a,1:e,1:6,1:1,cj:0,2:2,1:15,1:8,zp:1e,2bx:v,gw0:v,k2i:p,q:6,1:h,q:p,q:3,1:0,1:6,1:a,q:p,q:p,q:p,q:p,q:p,q:p,q:p,q:p,q:r,s:o,1:5,q:o,1:5,q:o,1:5,q:o,1:5,q:o,1:5,1:0,1f8:9,1:j,6:5,79:1p,1pw:x",space:"9:4,i:0,4f3:0,1vj:6,1:2,t:1,1h:0,334:0",blank:"9:0,m:0,4f3:0,1vj:6,1:2,2c:0,334:0",punct:"x:e,a:6,q:5,q:3,x:9,1:9,1:3,1:4,n:0,v:0,cq:3,c:d,5:6,1:0,1:2d,1:15,5:0,8:0,5:1,1:0,32:0,3v:7,5s:5,15:1,2:2,1:u,e:0,1:0,2:0,2:0,18:1,b:f,b:4,1k:0,h:3,2u:0,8:3,8:3,g:1,1:d,1:0,1c:a,4g:8,2:3,3:2,o:1,j:0,2:e,q:2,2:0,15:0,7:1,6:7,16:9,c:2,7:5,24:0,g:0,3:3,f:1,a:0,23:0,g:0,10:9,1:1,1p:0,g:0,14:0,1x:0,g:0,y:1,b:2,1o:0,g:0,7:0,q:0,1:5,2d:0,y:a,1t:0,g:0,15:8,4:0,1j:0,g:0,31:1,g:0,1:0,8:6,h:9,28:0,15:0,22:0,7:5,1:1,a:1,2m:0,d:4,1:0,1e:u,a:l,1w:3,1i:e,1:c,2k:0,1:1,f:5,26:1,2j:0,gx:v,j:9,2u:0,h8:1,18:1,26:2,12:1,u:2,3h:1,j:d,1:3,1:0,i:9,6:f,89:2,4:0,3:1,44:0,3:x,u:1,1s:0,k:7,2:0,w:6,1:5,2:e,2:a,2w:0,f:0,l:10,17:1,1m:0,b:1,8:3,1j:0,3:4,1q:1,1s:7,8:o,4:0,6:0,2:2,5i:12,e:a,cd:0,1:2,b:2,d:2,d:2,d:1,8:0,3:s,2:1g,1:4,1:a,3:a,1:e,h:w,f:w,f:1,1:3,1:1,a:0,1:2,5:5,1:0,1:0,1:0,4:0,b:1,4:4,5:3,1:g,15:2,4:ie,p:a,l:2d,1g:1ah,2:v,1:2w,6d:5,4:2,7:6,34:0,e:0,3k:1a,1:19,y:p,1:2g,c:5x,q:f,1:3,3:o,9:6,5:1,5:2,2h:3,3:0,2i:0,44:f,w:z,b:0,g:u,1:db,534:1r,h3k:1i,1j:1,7h:2,2n:4,8:2,35:7,8:m,9:1,2v:1,3f:0,x:4,3:9,1m:3,24:0,9:1,g:h,6:2,1:0,1a:4,z:0,b:0,2b:0,c:d,g:1,3g:3,n:2,1x:0,1:0,s:1,g:1,4:0,2s:0,e:1,3j:2,aaa:4xr,fd:0,3s:g,aj:h,3j:0,18:t,6:1e,1:i,1:3,43:0,1:e,a:6,q:5,q:a,3e:6,1:6,a:4,76:2,4:18,3:8,1h:p,1:c,3:0,1b:19,6a:r,10:3,3f:0,1c:0,bi:0,kn:8,n:8,13:8,23:4,m:5,3:0,v:0,3g:1,2:f,2:19,1k:2,4:9,7:8,10:2,t:2,14:0,s:1,4:b,1u:6,o:7,o:7,p:3,c:6,96:5,9s:u,1a:0,27:2,t:9,v:j,14:7,1n:6,3e:7,4:j,a:0,e:0,1l:8,b:0,2t:1,b:3,1b:2,22:0,4:8,d:0,1:2,1:j,1s:1,1:5,2z:0,1r:1,28:1,g:0,o:6,3:4,5p:0,3:0,4:4,a:1,1:1,2r:1,2:0,6w:o,2v:0,1:2,s:c,21:1,1:0,35:0,e:5,6x:2,4u:8,22:1,4:3,49:0,1:0,28:1,a:8,28:4,1:4,2l:9,8l:0,1:4,k:i,3:1,5s:0,1:1,29:0,9r:1,20:e,34:1d,d:0,vk:4,29o:1,u5:g,6:e,aoo:1,3k:5,1m:f,4:1,l:6,m6:q,93:0,1:0,f5j:1,1:4,3mk:19,2:m,9:37,1o:6t,a:12,2:5d,l:1x,3e:j,c:j,c:2e,9:o,nc:0,p:0,v:0,p:0,v:0,p:0,v:0,p:0,v:0,p:0,1o:i3,f:4,1:e,1a8:6,o:0,9q:0,1p:3,f:0,do:3,rb:f,31:2,1:2,j:1,lt:1v,24:1o,c2:1,7i:17,4:2r,c:e,2:e,1:e,1:10,a:1b,q:5,q:5,q:z,1k:s,d:17,4:8,7:1,e:5,4a:rb,4:g,3:c,3:3a,4:2m,6:b,4:0,f:b,4:1j,8:9,6:13,8:t,2:1,26:9f,c:d,2:c,3:8,7:19,1:6,8:d,4:8,7:8,7:42,1:1i,gvna:0,u:2n,3k:6n,1e6o:1ekd,2:1ekd",xdigit:"1c:9,7:5,q:5",cntrl:"0:v,2n:w,688:1",print:"w:2m,x:k7,2:5,4:6,1:0,1:j,1:b0,1:11,2:1d,2:2,1:1i,8:q,4:5,b:7h,1:1n,2:2s,e:1m,2:1c,2:e,1:r,2:0,1:a,5:u,1:1,6:6j,1:7,2:1,2:l,1:6,1:0,3:3,2:8,2:1,2:3,8:0,4:1,1:4,2:o,2:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,2:0,1:4,4:1,2:2,3:0,7:3,1:0,7:g,a:2,1:8,1:2,1:l,1:6,1:1,1:4,2:9,1:2,1:2,2:0,f:3,2:b,7:6,1:2,1:7,2:1,2:l,1:6,1:1,1:4,2:8,2:1,2:2,7:2,4:1,1:4,2:h,a:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:3,2:0,6:0,e:k,5:c,1:2,1:m,1:f,2:8,1:2,1:3,7:1,1:2,2:0,2:3,2:9,7:l,1:2,1:m,1:9,1:4,2:8,1:2,1:3,7:1,6:1,1:3,2:9,1:2,c:c,1:2,1:1e,1:2,1:5,4:f,2:p,1:2,1:h,3:n,1:8,1:0,2:6,3:0,4:5,1:0,1:7,6:9,2:2,c:1l,4:s,11:1,1:0,1:4,1:n,1:0,1:m,2:4,1:0,1:6,1:9,2:3,w:1z,1:z,4:12,1:z,1:e,1:c,11:5h,1:0,5:0,2:ag,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,2:v,3:p,6:2d,2:5,2:ik,3:2g,7:l,9:n,9:j,c:c,1:2,1:1,c:2l,2:9,6:9,6:p,6:2g,7:16,5:1x,a:u,1:b,4:b,4:0,3:15,2:4,b:17,4:p,6:a,3:1p,2:1s,1:s,2:a,6:9,6:d,2:u,1d:24,3:1a,1:37,8:1n,3:e,3:1n,7:16,2:a,8:16,5:et,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:e,1:d,2:5,1:i,2:2,1:8,1:13,2:1m,1:b,2:q,1:c,3:w,f:w,f:3v,4:ie,p:a,l:1eb,2:v,1:9o,5:18,1:0,5:0,2:1j,7:1,e:n,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:3h,y:p,1:2g,c:5x,q:27,1:2d,2:2u,5:16,1:2l,1:2b,b:1b,1:mlo,3:1i,9:9n,k:53,8:5m,5:1,1:0,1:4,o:1m,3:9,6:1j,8:1x,8:b,6:37,b:t,3:25,1:a,4:w,1:1i,9:d,2:9,2:2u,o:r,a:5,2:5,2:5,9:6,1:6,1:1n,4:3h,2:9,6:8mb,c:m,4:1c,1l0:57x,2:2x,12:6,c:4,5:p,1:4,1:0,1:1,1:1,1:3g,g:cc,2:1h,7:0,w:15,6:1e,1:i,1:3,4:4,1:3q,2:0,1:59,3:5,2:5,2:5,2:2,3:6,1:6,a:4,2:b,1:p,1:i,1:1,1:e,2:d,y:3e,5:2,4:18,3:2f,1:c,3:0,1b:19,3m:s,3:1c,f:r,4:z,9:t,5:16,5:t,1:10,4:d,16:4d,2:9,6:z,4:z,4:13,8:1f,b:b,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,1:1z,8:8,1c:i,1:1,5:w,3:q,5:0,1s:1j,4:j,2:1d,1:1,5:7,1:2,1:s,2:2,4:9,7:8,7:1r,w:12,4:b,9:1h,3:s,2:q,5:p,7:3,c:6,28:20,1j:1e,d:1e,7:19,8:9,86:u,1:15,1:2,2:1,23:16,8:15,m:p,12:r,k:m,9:25,4:z,9:1v,a:0,2:o,7:9,6:1g,1:h,8:12,9:2n,1:j,b:h,1:1a,1q:6,1:0,1:3,1:e,1:a,6:1m,5:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,1:9,2:1,2:2,2:0,6:0,5:6,2:6,3:4,3v:2j,1:4,u:1z,8:9,4m:1h,2:11,y:1w,b:9,6:c,j:1l,6:9,1i:q,2:e,4:m,55:1n,2s:2a,c:7,2:0,2:7,1:1,1:t,1:1,2:b,9:9,1y:7,2:19,2:a,r:1z,8:2a,d:20,7:9,6u:8,1:18,1:d,a:s,3:v,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:8,8:9,6:5,1:1,1:10,1:1,1:5,7:9,8m:o,7:g,1:14,3:r,2e:0,f:1d,d:pm,2u:32,1:4,b:5f,218:2q,d:ut,33e:g6,6nt:fs,7:u,1:9,4:28,1:9,6:t,2:5,a:1x,a:9,1:6,1:k,5:i,j4:2i,2t:22,4:1k,7:g,1s:4,b:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,2:7,3mk:19,2:m,9:37,1o:6t,a:12,2:5d,l:1x,3e:j,c:j,c:2e,9:o,3r:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:83,2:jh,f:4,1:e,uo:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,3:d,2:9,4:1,8w:u,h:1l,5:0,cw:15,km:6,1:3,1:1,1:e,1:5g,2:f,15:23,4:9,4:1,lt:1v,24:1o,5e:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,1g:1,7i:17,4:2r,c:e,2:e,1:e,1:10,a:4t,1k:s,d:17,4:8,7:1,e:5,4a:rb,4:g,3:c,3:3a,4:2m,6:b,4:0,f:b,4:1j,8:9,6:13,8:t,2:1,26:9f,c:d,2:c,3:8,7:19,1:6,8:d,4:8,7:8,7:42,1:1i,11:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f,f975:0,u:2n,3k:6n,1e6o:1ekd,2:1ekd",graph:"x:2l,x:k7,2:5,4:6,1:0,1:j,1:b0,1:11,2:1d,2:2,1:1i,8:q,4:5,b:7h,1:1n,2:2s,e:1m,2:1c,2:e,1:r,2:0,1:a,5:u,1:1,6:6j,1:7,2:1,2:l,1:6,1:0,3:3,2:8,2:1,2:3,8:0,4:1,1:4,2:o,2:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,2:0,1:4,4:1,2:2,3:0,7:3,1:0,7:g,a:2,1:8,1:2,1:l,1:6,1:1,1:4,2:9,1:2,1:2,2:0,f:3,2:b,7:6,1:2,1:7,2:1,2:l,1:6,1:1,1:4,2:8,2:1,2:2,7:2,4:1,1:4,2:h,a:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:3,2:0,6:0,e:k,5:c,1:2,1:m,1:f,2:8,1:2,1:3,7:1,1:2,2:0,2:3,2:9,7:l,1:2,1:m,1:9,1:4,2:8,1:2,1:3,7:1,6:1,1:3,2:9,1:2,c:c,1:2,1:1e,1:2,1:5,4:f,2:p,1:2,1:h,3:n,1:8,1:0,2:6,3:0,4:5,1:0,1:7,6:9,2:2,c:1l,4:s,11:1,1:0,1:4,1:n,1:0,1:m,2:4,1:0,1:6,1:9,2:3,w:1z,1:z,4:12,1:z,1:e,1:c,11:5h,1:0,5:0,2:ag,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,2:v,3:p,6:2d,2:5,2:hr,1:r,3:2g,7:l,9:n,9:j,c:c,1:2,1:1,c:2l,2:9,6:9,6:p,6:2g,7:16,5:1x,a:u,1:b,4:b,4:0,3:15,2:4,b:17,4:p,6:a,3:1p,2:1s,1:s,2:a,6:9,6:d,2:u,1d:24,3:1a,1:37,8:1n,3:e,3:1n,7:16,2:a,8:16,5:et,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:e,1:d,2:5,1:i,2:2,1:8,8:0,3:s,2:1g,1:4,1:b,2:q,1:c,3:w,f:w,f:3v,4:ie,p:a,l:1eb,2:v,1:9o,5:18,1:0,5:0,2:1j,7:1,e:n,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:3h,y:p,1:2g,c:5x,q:f,1:1q,1:2d,2:2u,5:16,1:2l,1:2b,b:1b,1:mlo,3:1i,9:9n,k:53,8:5m,5:1,1:0,1:4,o:1m,3:9,6:1j,8:1x,8:b,6:37,b:t,3:25,1:a,4:w,1:1i,9:d,2:9,2:2u,o:r,a:5,2:5,2:5,9:6,1:6,1:1n,4:3h,2:9,6:8mb,c:m,4:1c,1l0:57x,2:2x,12:6,c:4,5:p,1:4,1:0,1:1,1:1,1:3g,g:cc,2:1h,7:0,w:15,6:1e,1:i,1:3,4:4,1:3q,2:0,1:59,3:5,2:5,2:5,2:2,3:6,1:6,a:4,2:b,1:p,1:i,1:1,1:e,2:d,y:3e,5:2,4:18,3:2f,1:c,3:0,1b:19,3m:s,3:1c,f:r,4:z,9:t,5:16,5:t,1:10,4:d,16:4d,2:9,6:z,4:z,4:13,8:1f,b:b,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,1:1z,8:8,1c:i,1:1,5:w,3:q,5:0,1s:1j,4:j,2:1d,1:1,5:7,1:2,1:s,2:2,4:9,7:8,7:1r,w:12,4:b,9:1h,3:s,2:q,5:p,7:3,c:6,28:20,1j:1e,d:1e,7:19,8:9,86:u,1:15,1:2,2:1,23:16,8:15,m:p,12:r,k:m,9:25,4:z,9:1v,a:0,2:o,7:9,6:1g,1:h,8:12,9:2n,1:j,b:h,1:1a,1q:6,1:0,1:3,1:e,1:a,6:1m,5:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,1:9,2:1,2:2,2:0,6:0,5:6,2:6,3:4,3v:2j,1:4,u:1z,8:9,4m:1h,2:11,y:1w,b:9,6:c,j:1l,6:9,1i:q,2:e,4:m,55:1n,2s:2a,c:7,2:0,2:7,1:1,1:t,1:1,2:b,9:9,1y:7,2:19,2:a,r:1z,8:2a,d:20,7:9,6u:8,1:18,1:d,a:s,3:v,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:8,8:9,6:5,1:1,1:10,1:1,1:5,7:9,8m:o,7:g,1:14,3:r,2e:0,f:1d,d:pm,2u:32,1:4,b:5f,218:2q,d:ut,33e:g6,6nt:fs,7:u,1:9,4:28,1:9,6:t,2:5,a:1x,a:9,1:6,1:k,5:i,j4:2i,2t:22,4:1k,7:g,1s:4,b:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,2:7,3mk:19,2:m,9:37,1o:6t,a:12,2:5d,l:1x,3e:j,c:j,c:2e,9:o,3r:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:83,2:jh,f:4,1:e,uo:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,3:d,2:9,4:1,8w:u,h:1l,5:0,cw:15,km:6,1:3,1:1,1:e,1:5g,2:f,15:23,4:9,4:1,lt:1v,24:1o,5e:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,1g:1,7i:17,4:2r,c:e,2:e,1:e,1:10,a:4t,1k:s,d:17,4:8,7:1,e:5,4a:rb,4:g,3:c,3:3a,4:2m,6:b,4:0,f:b,4:1j,8:9,6:13,8:t,2:1,26:9f,c:d,2:c,3:8,7:19,1:6,8:d,4:8,7:8,7:42,1:1i,11:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f,f975:0,u:2n,3k:6n,1e6o:1ekd,2:1ekd"},af="2p:q:-w:1,51:1:kn:1,68:n:-w:1,6w:7:-w:1,73:1:3d:1,75:o:-1:2,8h:1:-6g:1,8j:3:-1:2,8q:8:-1:2,97:n:-1:2,ai:3:-1:2,an:1:-8c:1,ao:1:5f:1,ar:2:-1:2,aw:1:-1:1,b0:1:-1:1,b6:1:-1:1,b9:1:2p:1,bd:1:-1:1,be:1:4j:1,bi:1:3m:1,bl:3:-1:2,bs:1:-1:1,bx:1:-1:1,c0:1:-1:1,c4:2:-1:2,c9:1:-1:1,cd:1:-1:1,cf:1:1k:1,cl:1:-1:1,cm:1:-2:1,co:1:-1:1,cp:1:-2:1,cr:1:-1:1,cs:1:-2:1,cu:8:-1:2,d9:1:-27:1,db:9:-1:2,du:1:-1:1,dv:1:-2:1,dx:1:-1:1,e1:k:-1:2,f7:9:-1:2,fw:1:-1:1,fz:2:8cf:1,g2:1:-1:1,g7:5:-1:2,gg:1:8bj:1,gh:1:8bg:1,gi:1:8bi:1,gj:1:-5u:1,gk:1:-5q:1,gm:2:-5p:1,gp:1:-5m:1,gr:1:-5n:1,gs:1:wnj:1,gw:1:-5p:1,gx:1:wnf:1,gz:1:-5r:1,h1:1:wmg:1,h2:1:wn8:1,h4:1:-5t:1,h5:1:-5v:1,h6:1:wn8:1,h7:1:8af:1,h8:1:wn5:1,hb:1:-5v:1,hd:1:8al:1,he:1:-5x:1,hh:1:-5y:1,hp:1:89z:1,hs:1:-62:1,hu:1:wn7:1,hv:1:-62:1,hz:1:wmi:1,i0:1:-62:1,i1:1:-1x:1,i2:2:-61:1,i4:1:-1z:1,ia:1:-63:1,il:1:wlx:1,im:1:wlu:1,n9:1:2c:1,oh:2:-1:2,on:1:-1:1,or:3:3m:1,q4:1:-12:1,q5:3:-11:1,q9:h:-w:1,qq:1:-v:1,qr:9:-w:1,r0:1:-1s:1,r1:2:-1r:1,r4:1:-1q:1,r5:1:-1l:1,r9:1:-1b:1,ra:1:-1i:1,rb:1:-8:1,rd:c:-1:2,s0:1:-2e:1,s1:1:-28:1,s2:1:7:1,s3:1:-38:1,s5:1:-2o:1,s8:1:-1:1,sb:1:-1:1,ts:w:-w:1,uo:g:-28:1,v5:h:-1:2,wb:r:-1:2,xu:7:-1:2,y7:1:-f:1,y9:1c:-1:2,129:12:-1c:1,3bk:17:2bk:1,3ct:3:2bk:1,3y0:6:-8:1,5mo:1:-4tq:1,5mp:1:-4tp:1,5mq:1:-4tg:1,5mr:2:-4te:1,5mt:1:-4tf:1,5mu:1:-4t8:1,5mv:1:-4rp:1,5mw:1:r7m:1,5tl:1:r9g:1,5tp:1:2xy:1,5u6:1:raw:1,5xd:23:-1:2,61n:1:-1n:1,61t:1c:-1:2,64g:8:8:1,64w:6:8:1,65c:8:8:1,65s:8:8:1,668:6:8:1,66p:4:8:2,674:8:8:1,67k:2:22:1,67m:4:2e:1,67q:2:2s:1,67s:2:3k:1,67u:2:34:1,67w:2:3i:1,680:8:8:1,68g:8:8:1,68w:8:8:1,69c:2:8:1,69f:1:9:1,69q:1:-5k5:1,69v:1:9:1,6a8:2:8:1,6ao:2:8:1,6at:1:7:1,6b7:1:9:1,6ku:1:-s:1,6ls:g:-g:1,6mc:1:-1:1,79s:q:-q:1,8q8:1c:-1c:1,8rl:1:-1:1,8rp:1:-8bv:1,8rq:1:-8bs:1,8rs:3:-1:2,8s3:1:-1:1,8s6:1:-1:1,8sh:1e:-1:2,8vg:2:-1:2,8vn:1:-1:1,8w0:12:-5ls:1,8x3:1:-5ls:1,8x9:1:-5ls:1,wu9:n:-1:2,ww1:e:-1:2,x0j:7:-1:2,x0z:v:-1:2,x2y:2:-1:2,x33:5:-1:2,x3g:1:-1:1,x3l:2:-1:2,x3o:1:1c:1,x3r:a:-1:2,x4l:8:-1:2,x54:2:-1:2,x5d:1:-1:1,x5j:2:-1:2,x6e:1:-1:1,xub:1:-ps:1,xv4:28:-tzk:1,1ef5:q:-w:1,1fe0:14:-14:1,1fiw:10:-14:1,1fo7:b:-13:1,1foj:f:-13:1,1foz:7:-13:1,1fp7:2:-13:1,1h34:1f:-1s:1,1jgg:w:-w:1,20dc:w:-w:1,2oma:y:-y:1",uf="1t:q:w:1,5c:n:w:1,60:7:w:1,74:o:1:2,8g:1:-5j:1,8i:3:1:2,8p:8:1:2,96:n:1:2,ag:1:-3d:1,ah:3:1:2,ap:1:5u:1,aq:2:1:2,au:1:5q:1,av:1:1:1,ax:2:5p:1,az:1:1:1,b2:1:27:1,b3:1:5m:1,b4:1:5n:1,b5:1:1:1,b7:1:5p:1,b8:1:5r:1,ba:1:5v:1,bb:1:5t:1,bc:1:1:1,bg:1:5v:1,bh:1:5x:1,bj:1:5y:1,bk:3:1:2,bq:1:62:1,br:1:1:1,bt:1:62:1,bw:1:1:1,by:1:62:1,bz:1:1:1,c1:2:61:1,c3:2:1:2,c7:1:63:1,c8:1:1:1,cc:1:1:1,ck:1:2:1,cl:1:1:1,cn:1:2:1,co:1:1:1,cq:1:2:1,cr:9:1:2,da:9:1:2,dt:1:2:1,du:2:1:2,dy:1:-2p:1,dz:1:-1k:1,e0:k:1:2,f4:1:-3m:1,f6:9:1:2,fu:1:8bv:1,fv:1:1:1,fx:1:-4j:1,fy:1:8bs:1,g1:1:1:1,g3:1:-5f:1,g4:1:1x:1,g5:1:1z:1,g6:5:1:2,og:2:1:2,om:1:1:1,ov:1:38:1,p2:1:12:1,p4:3:11:1,p8:1:1s:1,pa:2:1r:1,pd:h:w:1,pv:9:w:1,r3:1:8:1,rc:c:1:2,s4:1:-1o:1,s7:1:1:1,s9:1:-7:1,sa:1:1:1,sd:3:-3m:1,sg:g:28:1,sw:w:w:1,v4:h:1:2,wa:r:1:2,xs:1:f:1,xt:7:1:2,y8:1c:1:2,10x:12:1c:1,3a8:12:5ls:1,3bb:1:5ls:1,3bh:1:5ls:1,3vk:28:tzk:1,3xs:6:8:1,5n4:17:-2bk:1,5od:3:-2bk:1,5xc:23:1:2,61q:1:-5vj:1,61s:1c:1:2,64o:8:-8:1,654:6:-8:1,65k:8:-8:1,660:8:-8:1,66g:6:-8:1,66x:4:-8:2,67c:8:-8:1,688:8:-8:1,68o:8:-8:1,694:8:-8:1,69k:2:-8:1,69m:2:-22:1,69o:1:-9:1,6a0:4:-2e:1,6a4:1:-9:1,6ag:2:-8:1,6ai:2:-2s:1,6aw:2:-8:1,6ay:2:-34:1,6b0:1:-7:1,6bc:2:-3k:1,6be:2:-3i:1,6bg:1:-9:1,6jq:1:-5st:1,6ju:1:-6gv:1,6jv:1:-6di:1,6k2:1:s:1,6lc:g:g:1,6mb:1:1:1,792:q:q:1,8ow:1c:1c:1,8rk:1:1:1,8rm:1:-8af:1,8rn:1:-2xy:1,8ro:1:-89z:1,8rr:3:1:2,8rx:1:-8bg:1,8ry:1:-8al:1,8rz:1:-8bj:1,8s0:1:-8bi:1,8s2:1:1:1,8s5:1:1:1,8se:2:-8cf:1,8sg:1e:1:2,8vf:2:1:2,8vm:1:1:1,wu8:n:1:2,ww0:e:1:2,x0i:7:1:2,x0y:v:1:2,x2x:2:1:2,x31:1:-r9g:1,x32:5:1:2,x3f:1:1:1,x3h:1:-wmg:1,x3k:2:1:2,x3q:a:1:2,x4a:1:-wn8:1,x4b:1:-wnj:1,x4c:1:-wnf:1,x4d:1:-wn5:1,x4e:1:-wn8:1,x4g:1:-wlu:1,x4h:1:-wmi:1,x4i:1:-wlx:1,x4j:1:ps:1,x4k:8:1:2,x50:1:-1c:1,x51:1:-wn7:1,x52:1:-raw:1,x53:2:1:2,x5c:1:1:1,x5i:2:1:2,x6d:1:1:1,1ee9:q:w:1,1fcw:14:14:1,1fhs:10:14:1,1fn4:b:13:1,1fng:f:13:1,1fnw:7:13:1,1fo4:2:13:1,1h1c:1f:1s:1,1jfk:w:w:1,20cg:w:w:1,2olc:y:y:1";var ie="C.UTF-8",Xo="only the C.UTF-8 locale is supported",ta=e=>typeof e=="string"&&/^C\.UTF-?8$/iu.test(e),zx=new Set(["LANG","LC_ALL","LC_CTYPE"]);function ff(e){if(e.locale===void 0||ta(e.locale))return ie;throw new TypeError(`createTerminal: ${Xo} (got ${JSON.stringify(e.locale)})`)}function df(e,t){if(!(zx.has(e)?ta(t)||e!=="LANG"&&t==="":ta(t)||t==="C"||t==="POSIX"||t===""))throw new x("feature",e,`${e}: ${Xo}`)}var Zo=e=>e==="C"||e==="POSIX",ee=e=>Zo(e.locale);function lf(e){let t=[],n=-1;for(let r of e.split(",")){let[o,i]=r.split(":").map(a=>parseInt(a,36)),s=n+1+o;t.push([s,s+i]),n=s+i}return t}function Bx(e){let t=e.findIndex(([n])=>n>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function ea(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):e<128?"\\x"+e.toString(16).padStart(2,"0"):String.fromCodePoint(e)}var jx=e=>e.map(([t,n])=>t===n?ea(t):`${ea(t)}-${ea(n)}`).join("");function Wx(e,t){let n=e.length-1,r=0;for(;r<=n;){let o=r+n>>1;if(t<e[o][0])n=o-1;else if(t>e[o][1])r=o+1;else return!0}return!1}var Yo=e=>e==="upper"||e==="lower"?"alpha":e,qx=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],on=/[\u1C80-\u1C88]/u;function cf(e){let t=new Map;for(let n of e.split(",")){let[r,o,i,s]=n.split(":").map(a=>parseInt(a,36));for(let a=0;a<o;a++)t.set(r+a*s,r+a*s+i)}return t}var pf=(e,t)=>({up:e,low:t,folds:new Map});function Hx(){let e=new Map,t=new Map;for(let n=97;n<=122;n++)e.set(n,n-32),t.set(n-32,n);return pf(e,t)}function Gx(e){let t=[];for(let[n,r]of e.sort((o,i)=>o[0]-i[0])){let o=t.at(-1);o&&n<=o[1]+1?o[1]=Math.max(o[1],r):t.push([n,r])}return t}function na(e){let t=`[${e}]`;return{"<":`(?<!${t})(?=${t})`,">":`(?<=${t})(?!${t})`,boundary:`(?:(?<!${t})(?=${t})|(?<=${t})(?!${t}))`,inside:`(?:(?<=${t})(?=${t})|(?<!${t})(?!${t}))`}}function hf(e,t,n,r,o){let i=new Map,s=new Map,a=null,u=f=>(s.has(f)||s.set(f,n(f)),s.get(f)),l=()=>a??=o(),c={name:e,multibyte:t,ranges:u,body(f){return i.has(f)||i.set(f,r(f,u(f))),i.get(f)},has(f,d){let p=u(f);return p!==void 0&&Wx(p,d)},assertions(){if(c.js)return c.js;let f=c.body("space");return c.js={__proto__:null,...na(c.body("word")),word:`[${c.body("word")}]`,nonWord:`[^${c.body("word")}]`,space:`[${f}]`,nonSpace:`[^${f}]`},c.js},up:f=>l().up.get(f)??f,low:f=>l().low.get(f)??f,fold(f){let{folds:d}=l(),p=d.get(f);if(p===void 0){let h=c.up(f),m=c.low(h),g=new Set([f,h]);m!==h&&c.up(m)===h&&g.add(m);for(let w of qx)c.up(w)===h&&g.add(w);p=[...g].sort((w,y)=>w-y),d.set(f,p)}return p},foldRange(f,d){let{up:p}=l(),h=p.get(f)??f,m=p.get(d)??d;if(h>m)return null;let g=[],w=[];for(let[S,_]of p){let W=S>=h&&S<=m;W!==(_>=h&&_<=m)&&(W?g:w).push(S)}let y=[],$=h;for(let S of g.sort((_,W)=>_-W))S>$&&y.push([$,S-1]),$=S+1;return $<=m&&y.push([$,m]),Gx([...y,...w.map(S=>[S,S])])}};return c}var Xx=hf("C",!1,e=>$r[e],e=>rn[e],Hx),Zx=hf(ie,!0,e=>e==="word"?Bx(lf(Go.alnum)):Object.hasOwn(Go,e)?lf(Go[e]):void 0,(e,t)=>t===void 0?void 0:jx(t),()=>pf(cf(af),cf(uf)));function se(e){if(e===ie)return Zx;if(Zo(e))return Xx;throw new x("feature","locale",`matching in the ${e} locale is not supported`)}var ge=(1n<<63n)-1n,wt=-ge-1n,yt=(1n<<64n)-1n;function D(e,t,n,r){let o=E(e.cwd,n,e.fs,r);return P(e,t,n,o.error),o}function P(e,t,n,r){if(r!=="No such file or directory"||typeof n!="string")return;let o=n.startsWith("/"),i=o?"/":e.cwd,s=n.replace(/^\/+/u,""),a=new Set;for(let c of new Set(["/",e.mount??"/",e.home??"/"])){if(c===i)continue;let f=E(c,s,e.fs);f.error||a.add(f.path)}if(!a.size)return;let u=o?"":` from cwd ${JSON.stringify(e.cwd)}`,l=`${o?"absolute":"relative"} path ${JSON.stringify(n)} was not found${u}`;e.notes?.add(`${t}: ${l}. ${Yx(e,a)}`)}function Yx(e,t){let n=[...t].sort(q),r=n.map(a=>JSON.stringify(a));if(n.length===1)return`A ${e.fs.isDir(n[0])?"dir":"file"} exists at ${r[0]}.`;let i=n.every(a=>!e.fs.isDir(a)&&e.fs.isFile(a))&&n.some(a=>!e.fs.sameFileContents(n[0],a)),s=`${r.slice(0,-1).join(", ")} and ${r.at(-1)}`;return`${n.length===2?"Both":"All"} of ${s} exist${i?", and they differ in contents":""}.`}function Rn(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(".")&&e.add(j(t,r))},emit(t,n,r,o=""){Ft(t,{command:n,action:"omitted",noun:["hidden entry","hidden entries"],explanation:r,context:o,paths:e})}}}var mf=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function gf(e,t){for(let n of t.split(`
4
+ `))mf.test(n)&&e.discarded?.add(n)}function ra(e,t,n){let r=new Map;for(let o of e){if(t.includes(o))continue;let{command:i,operand:s,reason:a}=mf.exec(o).groups,u=/'([^']*)'$/u.exec(s)?.[1]??s;if([...n].some(c=>c.includes(JSON.stringify(u))))continue;let l=`${i}: ${a}`;r.has(l)||r.set(l,new Set),r.get(l).add(u)}return[...r].map(([o,i])=>`${o}: ${[...i].map(s=>JSON.stringify(s)).join(", ")}.`)}function wf(e,t){return e==="status"?null:{name:t,search:e==="search"}}function yf(){let e=null,t=0;return{skip(n,r){!t&&n&&(e={...n,exitCode:r}),t++},flush(n){if(t&&e){let r=t===1?"the command":`the ${t} commands`,o=e.search&&e.exitCode===1?" A search that selects no lines exits 1, which is not a failure.":"";n.add(`${e.name}: exited ${e.exitCode}, so ${r} after && did not run.${o}`)}e=null,t=0}}}function Ft(e,t){Vx(e,t,t.paths.size,t.paths)}function Vx(e,{command:t,action:n,noun:r,explanation:o="",context:i=""},s,a){if(!s)return;let u=s<10?": "+[...a].sort(q).map(c=>JSON.stringify(c)).join(", "):"",l=Array.isArray(r)?r[s===1?0:1]:r;e.add(`${t}: ${n} ${s} ${l}${i}${u}.${o?" "+o:""}`)}function we(e,t=`
5
+ `){if(e==="")return[];let n=e.split(t);return n.at(-1)===""&&n.pop(),n}function Sr(e){let t=0,n=typeof e=="string"?`
6
+ `:10;for(let r=e.indexOf(n);r>=0;r=e.indexOf(n,r+1))t++;return t}var Ee=(e,t=`
7
+ `)=>e.length===0?"":e.join(t)+t;function ot(e,t=`
8
+ `){let n=[];for(let r=0;r<e.length;){let o=e.indexOf(t,r),i=o<0?e.length:o+t.length;n.push(e.slice(r,i)),r=i}return n}var sn=e=>e.stdinTerminal===!0,xt=e=>(e.outputFds?.[1]==="out"||e.outputFds?.[1]==="err")&&!e.substitutionDepth;function z(e,t="",n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&Lt(e.stdinBytes,Mn(null,e)),e.stdinLeft=t,e.stdinBytes=r}function bt(e,t,n,r="",o={}){let i=[],s="",a=r,u=o.read??"text",l=u==="bytes"||u==="loose-bytes",c=l?"bytes":"content",f=p=>l?u==="loose-bytes"?T(p):I(p):p,d=(p,h)=>{if(l){p.bytes=fe(n.fs,h,u==="loose-bytes");return}if(u==="text"||n.fs.isBytes?.(h)!==!0){p.content=n.fs.readFile(h);return}p.bytes=n.fs.readBytes(h),p.content=u==="maybe-text"?ve(p.bytes):void 0};for(let p of t){let h={name:p,[c]:f(""),kind:"file"},m;if(p==="/dev/stdin"&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),h[c]=f(n.stdinOrigin);else if(p==="-"||p==="/dev/stdin"){let g=a===r?n.stdinBytes??null:null;Object.assign(h,g===null?xf(a,u,l):bf(g,u,l,e,n)),h.shared=!0,a="",z(n,"",!0)}else if(p!=="/dev/null"){let g=D(n,e,p);g.error?(h.kind="missing",m=g.error):n.fs.isDir(g.path)?(h.kind="dir",o.noRead||(m="Is a directory")):d(h,g.path)}if(i.push(h),m&&(s+=h.failure=oa(e,p,m,h.kind==="dir")),h.kind!=="file"&&(o.stopOnError||h.kind==="dir"&&o.stopOnDir))break}return{inputs:i.filter(p=>p.kind==="file"),entries:i,stderr:s,failed:s!==""}}var Kx={head:["cannot open '%s' for reading: %r","error reading '%s': Is a directory"],tail:["cannot open '%s' for reading: %r","error reading '%s': Is a directory"],sort:["cannot read: %s: %r","read failed: %s: Is a directory"],sed:["can't read %s: %r","read error on %s: Is a directory"],tac:["failed to open '%s' for reading: %r","%s: read error: Invalid argument"],base32:[null,"read error: Is a directory"],base64:[null,"read error: Is a directory"],uniq:[null,"error reading '%s': Is a directory"]};function oa(e,t,n,r=!1){let o=Kx[e]?.[r?1:0],i=o?o.replace(/%[sr]/gu,s=>s==="%s"?t:n):`${t}: ${n}`;return`${e}: ${i}
9
+ `}function fe(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let o=e.readFile(t);if(o!==void 0)return n?T(o):I(o)}function it(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:ve(n),bytes:n}}function ae(e,t,n,r,o){if(t.length===0){let i=r.stdinBytes??null;z(r,"",!0);let s=o?.read,a=s==="bytes"||s==="loose-bytes",u=[{name:null,kind:"file",...i===null?xf(n,s,a):bf(i,s,a,e,r)}];return{inputs:u,entries:u,stderr:"",failed:!1}}return bt(e,t,r,n,o)}var xf=(e,t,n)=>n?{bytes:t==="loose-bytes"?T(e):I(e)}:{content:e};function bf(e,t,n,r,o){return n||t==="as-held"?{bytes:e}:t==="maybe-text"?{bytes:e,content:ve(e)}:{content:Lt(e,Mn(null,o))}}function Mn(e,t){return e===null||e==="-"||e==="/dev/stdin"?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):"standard input":JSON.stringify(E(t.cwd,e,t.fs).path??e)}function kf(e,t,n,r){let o=ae(e,t,n,r);return{content:o.inputs.map(i=>i.content).join(""),stderr:o.stderr,failed:o.failed}}var ue=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:t.failed?1:0});function Pe(e,t,n=e,{max:r=1/0,digitsOnly:o=!1}={}){if(typeof e!="string"||!(o?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:b(`${t}: invalid count: ${n}`)};let i=Number(e);return i>r?{error:b(`${t}: out of range: ${n}`)}:{value:Math.min(i,Number.MAX_SAFE_INTEGER)}}function vf(e,t){if(typeof e!="string")return{error:b(`${t}: invalid count: ${e}`)};let n=e[0]==="+"||e[0]==="-"?e[0]:"",r=n==="-"?e.slice(1):e,o=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),i=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!o&&!i)return{error:b(`${t}: invalid count: ${e}`)};let s=o?.[2]??(i?r:""),a=ia(BigInt(o?.[1]??"1"),s,t,e);return a.error?a:{...a,sign:n}}function ia(e,t,n,r){let o=1n;t==="b"?o=512n:t&&(o=(t.length===2?1000n:1024n)**BigInt("KMGTPEZYRQ".indexOf(t[0].toUpperCase())+1));let i=e*o;return i>yt?{error:b(`${n}: count out of range: ${r}`)}:{value:Number(i>BigInt(Number.MAX_SAFE_INTEGER)?BigInt(Number.MAX_SAFE_INTEGER):i)}}function K(e){try{let t=e?.message;return typeof t=="string"&&t!==""?t:String(e)}catch{return"threw a value with no message"}}var J=e=>e==="/tmp"||e.startsWith("/tmp/"),Ef=new Uint8Array;function Sf(e){e.vfs.mkdir("/tmp",{recursive:!0}),e.writableAt("/tmp");let t=Jx(e),n=o=>t.observer?.read(t.identity(o)??o),r={...e,observeIo:o=>{t.observer=o},fileIdentity:t.identity,readIdentity:o=>(t.observer?.read(o),G(sa(e.vfs,o))),readFile:o=>(n(o),e.readFile(o)),readBytes:o=>(n(o),e.readBytes(o)),openWritable:(o,i,s=!1)=>eb(r,t,o,i,s),makeWritableDir:(o,i)=>tb(r,t,o,i),makeWritableLink:(o,i,s)=>nb(r,t,o,i,s),removeWritableDir:(o,i)=>sb(r,t,o,i),copyWritable:(o,i,s)=>rb(r,t,o,i,s),replaceWritable:(o,i,s,a)=>ob(r,t,o,i,s,a),removeWritable:(o,i)=>ib(r,t,o,i)};return r}function Jx(e){let{vfs:t}=e,n=new Map;return{base:e,vfs:t,observer:void 0,identity:r=>{if(!J(String(r))||!e.isFile(r))return;let{ino:o}=t.lstat(r),i=n.get(o);return i===void 0&&n.set(o,i={path:t.realpath(r),detached:void 0}),i},leaving:r=>{let o=e.isFile(r)?t.lstat(r).ino:void 0,i=n.get(o);return i&&{cell:i,ino:o,bytes:t.readFile(r)}},release:r=>{r&&(r.cell.detached=r.bytes,n.delete(r.ino))},change:(r,o)=>{try{return o()}catch(i){throw i instanceof F?Ye(r,Qx(i.code)):i}finally{e.reshaped()}}}}var Qx=e=>new F(e,"").message.slice(2),sa=(e,t)=>t.detached??e.readFile(t.path);function eb(e,t,n,r,o){let i=me(e,n,r);if(!J(i))return null;Ar(e,n,r);let s=t.identity(i);return s===void 0?(t.change(r,()=>t.vfs.writeFile(i,Ef)),s=t.identity(i)):o||(t.observer?.write(s),t.vfs.writeFile(i,Ef)),ub(t.vfs,i,s,o,()=>t.observer?.write(s))}function tb(e,t,n,r){let o=me(e,n,r,!1);if(!J(o))return!1;if(e.isDir(o))return!0;if(Ar(e,n,r),e.isFile(o)||e.isLink(o))throw new Error(`${r}: File exists`);return t.change(r,()=>t.vfs.mkdir(o)),!0}function nb(e,t,n,r,o){let i=me(e,n,r,!1);return i.startsWith("/tmp/")?(ab(e,n,r),t.change(r,()=>t.vfs.symlink(o,i)),!0):!1}function rb(e,t,n,r,o){let i=me(e,n,o);if(!i.startsWith("/tmp/"))return!1;Ar(e,n,o);let s=t.identity(r);if(r===i||s!==void 0&&s===t.identity(i))throw new Error("source and destination are the same file");return t.observer?.read(s??r),e.openWritable(n,o).writeBytes(t.base.readBytes(r)),!0}function ob(e,t,n,r,o,i){let s=me(e,n,r,!1),a=i===void 0?null:me(e,n,i,!1);if(!s.startsWith("/tmp/")||a!==null&&!a.startsWith("/tmp/"))return!1;if(Ar(e,n,r),!e.isFile(s)&&!e.isLink(s))throw Ye(r,"No such file or directory");a!==null&&Ar(e,n,i);let u=I(o),{vfs:l}=t;return t.change(r,()=>{if(a!==null&&a!==s){let c=t.leaving(s),f=t.leaving(a);l.rename(s,a),t.release(f),c&&(c.cell.path=a)}else{let c=t.leaving(s);l.unlink(s),t.release(c)}l.writeFile(s,u)}),!0}function ib(e,t,n,r){let o=me(e,n,r,!1);if(!J(o))return!1;let i=E(n,r,e,{follow:!1});if(i.error)throw Ye(r,i.error);if(e.isDir(i.path))throw new Error(`${r}: Is a directory`);if(!J(i.path))return!1;let s=t.leaving(i.path);return t.change(r,()=>t.vfs.unlink(i.path)),t.release(s),!0}function sb(e,t,n,r){let o=me(e,n,r,!1);if(!J(o))return!1;let i=E(n,r,e);if(i.error)throw Ye(r,i.error);if(!J(i.path)||!e.isDir(i.path))throw new Error(`${r}: Not a directory`);if(i.path==="/tmp")throw new Error(`${r}: Device or resource busy`);let{dirs:s,files:a,links:u}=e.listDir(i.path);if(s.length||a.length||u.length)throw new Error(`${r}: Directory not empty`);return t.change(r,()=>t.vfs.rmdir(i.path)),!0}function Ar(e,t,n){let r=tt(t,n,e);if(r.error===null){if(e.isDir(r.path))throw new Error(`${n}: Is a directory`);if(n.endsWith("/"))throw Ye(n,"Not a directory");return}if(r.rest.length>0||n.endsWith("/")||n.includes("\0"))throw Ye(n,r.error);if(!e.isDir(oe(r.path)))throw Ye(n,"No such file or directory")}function ab(e,t,n){if(n===""||n.includes("\0"))throw Ye(n,"No such file or directory");let r=tt(t,n,e,{follow:!1});if(r.error===null)throw Ye(n,"File exists");if(r.rest.length>0||n.endsWith("/"))throw Ye(n,r.error);if(!e.isDir(oe(r.path)))throw Ye(n,"Not a directory")}function Ye(e,t){return Object.assign(new Error(`${e}: ${t}`),{path:e,fsError:t})}function ub(e,t,n,r,o){let i=0,s=a=>{let u=sa(e,n),l=r?u.length:i;n.detached!==void 0?n.detached=$f(u,l,a):l===u.length?e.appendFile(n.path,a):e.writeFile(n.path,$f(u,l,a)),i=l+a.length};return{path:t,identity:n,get position(){return r?sa(e,n).length:i},write(a){a!==""&&(o(),s(I(a)))},writeBytes(a){a.length!==0&&(o(),s(a))}}}function $f(e,t,n){let r=Math.max(e.length,t+n.length),o=t===e.length&&e.byteOffset+r<=e.buffer.byteLength,i=o?new Uint8Array(e.buffer,e.byteOffset,r):new Uint8Array(Math.max(r,e.length*2)).subarray(0,r);return o||i.set(e),i.set(n,t),i}var Af=["cwd","home","user","inherit"];function Nf(e,t){let n=Nr(t,"mount","/"),r=Nr(t,"home",n),o=Nr(t,"cwd",n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!=="/tmp/")throw new TypeError("createTerminal: writable must be '/tmp/', false, or undefined");let i=t.writable==="/tmp/";if(i&&(n==="/"||n==="/tmp"||n.startsWith("/tmp/")))throw new Error("createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'");let s=rf(e,n);return{fs:i?Sf(s):s,cwd:o,home:r,mount:n,writable:i,locale:ff(t)}}function Of(e,t){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`fork: options must be an object (got ${t===null?"null":Array.isArray(t)?"an array":typeof t})`);for(let n of Object.keys(t))if(!Af.includes(n))throw new Error(`fork: unknown option \`${n}\` (known: ${Af.join(", ")}; the sources, the mount, the /tmp/ overlay, the network and the commands come from the parent)`);if(t.inherit!==void 0&&typeof t.inherit!="boolean")throw new TypeError(`fork: inherit must be true or false (got ${t.inherit===null?"null":typeof t.inherit})`);return{cwd:Nr(t,"cwd",e.cwd,"fork",e.cwd),home:Nr(t,"home",e.home,"fork",e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function Nr(e,t,n,r="createTerminal",o="/"){let i=e[t]===void 0?n:e[t];if(typeof i!="string"||i.includes("\0"))throw new TypeError(`${r}: ${t} must be a string without NUL characters`);return j(o,i)}function Oe(e,t=0,n=e.value.length){return{value:e.value.slice(t,n),mask:e.mask===null?null:e.mask.slice(t,n),...e.empty?{empty:e.empty.filter(r=>r>=t&&r<=n).map(r=>r-t)}:{}}}function Or(e){let t=/^([A-Za-z_][A-Za-z0-9_]*)=/u.exec(e.value);return!t||e.mask!==null&&/[12]/u.test(e.mask.slice(0,t[0].length))||e.empty?.some(n=>n<t[0].length)?null:{name:t[1],end:t[0].length}}var If=(e,t)=>e.mask===null?"0":e.mask[t];function Tf(e,t=!1){let n=new Set;if(!e.value.includes("~"))return n;let r=e.value,o=a=>If(e,a)==="0",i=t?null:Or(e)?.end??null,s=a=>t===!0||i!==null&&a>=i;for(let a=0;a<r.length;a++){let u=a===0||a===i||s(a)&&r[a-1]===":"&&o(a-1),l=s(a)||t==="parameterAssign";if(!u||r[a]!=="~"||!o(a)||!lb(e,a,l))continue;let c=r[a+1];if(c&&c!=="/"&&c!==":"&&o(a+1))throw new x("feature","tilde prefix","named-user and directory-stack tilde prefixes are not supported");(c===void 0||o(a+1)&&(c==="/"||c===":"&&l))&&n.add(a)}return n}function lb(e,t,n){for(let r=t;r<=e.value.length;r++){if(e.empty?.includes(r))return!1;if(r===e.value.length)return!0;if(If(e,r)!=="0")return!1;if(e.value[r]==="/"||n&&e.value[r]===":")return!0}return!0}function Cf(...e){let t="",n="",r=[];for(let o of e){for(let i of o.empty??[])r.push(t.length+i);t+=o.value,n+=o.mask??"0".repeat(o.value.length)}return{value:t,mask:e.every(o=>o.mask===null)?null:n,...r.length?{empty:r}:{}}}var Dn=64;function kt(e,t){let n="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(o!=="\\"){n+=o;continue}let i=e[r+1];if(i==="`")throw new x("feature","\\`","nested backtick command substitution is not supported; use `$( )` instead");if(i==="$"||i==="\\"){n+=i,r++;continue}if(i===`
10
+ `){r++;continue}n+=o}throw new Error("unterminated backtick substitution")}var _f=()=>({value:"",quoted:!1,started:!1}),Lf=()=>new x("feature","command substitution depth",`command substitution nesting above ${Dn} is not supported`);function aa(e,t,n,r,o){if(r>=Dn)throw Lf();let i={line:e,i:n+1,depth:r,helpers:o,parens:0,quote:null,word:_f(),command:!0,target:null,heredocs:[]};for(;i.i<e.length;)if(cb(i))return{raw:e.slice(t,i.i+1),command:e.slice(n+1,i.i)};throw i.quote?new Error(`unterminated ${i.quote==="'"?"single":"double"} quote`):new Error("unterminated command substitution")}function Rt(e,t,n=!1){e.word.value+=t,e.word.quoted||=n,e.word.started=!0}function ua(e){let t=e.word;if(t.started){if(e.target)e.target.op==="heredoc"&&(e.target.delim=t.value,e.target.quotedDelim=t.quoted),e.target=null;else if(e.command&&!t.quoted){if(t.value==="case")throw new x("feature","case","`case` patterns inside command substitutions are not supported");e.command=["!","{","do","then","else","elif","if","while","until"].includes(t.value)||/^[A-Za-z_][A-Za-z0-9_]*=/u.test(t.value)}else e.command=!1;e.word=_f()}}function cb(e){let{line:t,i:n,quote:r}=e,o=t[n];if(r&&o===r)return e.quote=null,e.word.quoted=!0,e.i++,!1;if(r==="'")return Rt(e,o,!0),e.i++,!1;if(o==="\\")return fb(e),!1;if(o==="$")return db(e),!1;if(o==="`")return pb(e),!1;if(r)return Rt(e,o,!0),e.i++,!1;if(o==="'"||o==='"')return e.quote=o,e.word.started=!0,e.i++,!1;if(e.command&&!e.target&&!e.word.started&&t.startsWith("[[",n)&&/[ \t\n()<>;&|]|^$/u.test(t[n+2]??"")){let s=e.helpers.readConditional(t,n,e.helpers,e.depth+e.parens+1);return e.i+=s.raw.length,e.command=!1,!1}if(o==="#"&&!e.word.started){let s=t.indexOf(`
11
+ `,n);return e.i=s===-1?t.length:s,!1}if(o===`
12
+ `)return mb(e),!1;if(o===" "||o===" ")return ua(e),e.i++,!1;let i;try{i=e.helpers.readOperator(t,n,!e.word.started)}catch(s){if(!(s instanceof x))throw s;return e.i++,!1}return i?hb(e,i):(Rt(e,o),e.i++,!1)}function fb(e){let t=e.line[e.i+1];if(t===`
13
+ `){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(Rt(e,t,!0),e.i+=2):(Rt(e,"\\",!!e.quote),e.i++)}function db(e){let{line:t,i:n}=e,r=e.helpers.skipContinuations(t,n+1);if(!e.quote&&t[r]==="'"){let s=e.helpers.decodeAnsiC(t,r+1);Rt(e,s.text,!0),e.i=s.end;return}if(!e.quote&&t[r]==='"'){e.quote='"',e.word.started=!0,e.i=r+1;return}let i=e.helpers.readExpansion(t,n,e.depth+e.parens+1,e.quote==='"')?.raw??"$";Rt(e,i,!!e.quote),e.i+=i.length}function pb(e){let t=e.i++;for(;e.i<e.line.length;){let n=e.line[e.i++];if(n==="`"){Rt(e,e.line.slice(t,e.i),!!e.quote);return}n==="\\"&&e.i<e.line.length&&e.i++}throw new Error("unterminated backtick substitution")}function hb(e,t){ua(e);let n=t.token;if(n.kind==="paren_close"){if(e.parens===0){if(e.heredocs.length)throw new x("feature","command substitution heredoc","a command substitution heredoc must finish before its closing parenthesis");return!0}e.parens--,e.command=!1}else if(n.kind==="paren_open"){if(e.depth+ ++e.parens>=Dn)throw Lf();e.command=!0}else n.kind==="redir"?(e.command=!1,n.op==="heredoc"&&e.heredocs.push(n),["dup","close"].includes(n.op)||(e.target=n)):e.command=!0;return e.i=t.end,!1}function mb(e){if(ua(e),e.heredocs.some(t=>t.delim===null))throw new Error("heredoc requires a delimiter");e.heredocs.length&&(e.i=e.helpers.readHeredocBodies(e.line,e.i,e.heredocs),e.heredocs=[]),e.command=!0,e.i++}function st(e){return Number.isInteger(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)}var Ve=e=>e>65535?2:1,ze=(e,t)=>Ve(e.codePointAt(t)),Un=e=>`(?:^|(?<=[^]))(?:${e})`;var gb=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])(?![\s\S])/u,wb=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])/u;function an(e,t="unsupported or malformed parameter expansion"){return new x("feature","${",`${t}: \${${e}}`)}var la=e=>/^[0-9]+$/u.test(e)?e.replace(/^0+(?=[0-9])/u,""):e;function ca(e){let t=e.replaceAll(`\\
14
+ `,"");if(t.startsWith("#")&&t.length>1&&gb.test(t.slice(1)))return{name:la(t.slice(1)),operator:"length"};if(/^#[A-Za-z_0-9]/u.test(t))throw an(e);let n=wb.exec(t)?.[0];if(!n)throw an(e);let r=t.slice(n.length);if(!r)return{name:la(n),operator:""};if(n==="#"&&/^[%:=+/]$/u.test(r))throw an(e);let o=/^(?::[-+=?]|[-+=?]|##?|%%?|:|\/\/?)/u.exec(r)?.[0];if(!o)throw an(e);return{name:la(n),operator:o,word:e.slice(yb(e,n.length+o.length))}}function yb(e,t){let n=0;for(;t>0;)e[n]==="\\"&&e[n+1]===`
15
+ `?n+=2:(t--,n++);return n}var Mt=(e,t)=>new x("feature",e,t),Ff=e=>{if(e>=64)throw Mt("expansion depth","shell expansion nesting above 64 levels is not supported")};function Rf(e,t,n,r,o,i){Ff(r);let s=n+1,a=null;for(let u=s;u<e.length;u++){let l=e[u];if(a==="'"){l==="'"&&(a=null);continue}if(l==="\\"){u++;continue}if(l==='"'){a=a==='"'?null:'"';continue}if(l==="'"&&!a){a="'";continue}if(l==="`")throw Mt("`","command substitution (backticks) is not supported");if(l==="$"){let c=u+1;for(;e[c]==="\\"&&e[c+1]===`
16
+ `;)c+=2;if(e[c]==="'"&&!a){let d=i.decodeAnsiC(e,c+1),p=ca(e.slice(s,u)).operator;if(o&&/[-+?=]/u.test(p)&&/[$`"'\\}]/u.test(d.text))throw Mt("${","active characters in ANSI-C quoted parameter operands are not supported");u=d.end-1;continue}let f=i.readExpansion(e,u,r+1,o||a==='"');if(f){u+=f.raw.length-1;continue}}if(l==="}"&&!a){let c=ca(e.slice(s,u));return{raw:e.slice(t,u+1),parameter:c}}}throw Mt("${","unterminated parameter expansion")}function Mf(e,t,n,r,o){Ff(r);let i=0;for(let s=n+1;s<e.length;s++){let a=e[s];if(a==="\\"){s++;continue}if(a==="$"){let l=o.readExpansion(e,s,r+1,!0);if(l){s+=l.raw.length-1;continue}}if(a==="`")throw Mt("`","command substitution (backticks) is not supported");if(a==='"'||a==="'")throw Mt("$((","quotes in arithmetic expressions are not supported");if(a==="("&&i++,a!==")")continue;if(i){i--;continue}let u=s+1;for(;e[u]==="\\"&&e[u+1]===`
17
+ `;)u+=2;if(e[u]!==")")throw Mt("$((","arithmetic expansion requires a closing `))`");return{raw:e.slice(t,u+1),arithmetic:e.slice(n+1,s)}}throw Mt("$((","unterminated arithmetic expansion")}var xb=/^-[abcdefghknoprstuvwxzGLNORS]$/u,bb=new Set(["=","==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]),kb=new Set(["end","&&","||",")"]),vb=/^[A-Za-z_][A-Za-z0-9_]*$/u;function Ir(e,t,n,r=0){let o={line:e,i:t+2,helpers:n,token:null,depth:0,terms:0,removed:0,expansionDepth:r};try{at(o,!0);let i=zf(o);return o.token.kind!=="end"&&Dt(`unexpected token \`${o.token.value??o.token.kind}\``),{raw:e.slice(t,o.i+o.removed),expression:i}}catch(i){if(i instanceof x||i.conditional)throw i;Dt(i.message)}}function zf(e){let t=Df(e);for(;e.token.kind==="||";)at(e,!0),t={kind:"or",left:t,right:Df(e)};return t}function Df(e){let t=fa(e);for(;e.token.kind==="&&";)at(e,!0),t={kind:"and",left:t,right:fa(e)};return t}function fa(e){if(++e.terms>128)throw new x("feature","[[ complexity","conditional expressions above 128 terms are not supported");if(++e.depth>64)throw new x("feature","[[ nesting","conditional nesting above 64 levels is not supported");try{let t=e.token;if(t.kind==="("){at(e,!0);let o=zf(e);return e.token.kind!==")"&&Dt("expected `)`"),at(e,!0),o}if(Bf(t,"!"))return at(e,!0),{kind:"not",expression:fa(e)};if(t.kind!=="word"&&Dt("expected an operand"),at(e),!t.quoted&&xb.test(t.value)){let o=Uf(e);return at(e,!0),{kind:"unary",op:t.value,word:o}}if(kb.has(e.token.kind))return{kind:"unary",op:"-n",word:t};let n=e.token;if((n.quoted||!bb.has(n.value))&&Dt("conditional binary operator expected"),n.value==="=~")throw new x("feature","[[ =~","regular expression comparisons in [[ are not supported");at(e);let r=Uf(e);return at(e,!0),{kind:"binary",op:n.value,left:t,right:r}}finally{e.depth--}}var Bf=(e,t)=>e.kind==="word"&&!e.quoted&&e.value===t,Dt=e=>{throw Object.assign(new Error(`[[ ${e}`),{conditional:!0})};function Uf(e){return e.token.kind!=="word"&&Dt("expected an operand"),e.token}function at(e,t=!1){if(e.token=Pf(e),t)for(;e.token.kind==="newline";)e.token=Pf(e)}function Pf(e){for(;e.i<e.line.length;){let t=e.line[e.i];if(t===" "||t===" "){e.i++;continue}if(t==="\\"&&e.line[e.i+1]===`
18
+ `){e.i+=2;continue}if(t==="#"){let o=e.line.indexOf(`
19
+ `,e.i);e.i=o<0?e.line.length:o;continue}if(t===`
20
+ `)return e.i++,{kind:"newline"};let n=e.line.slice(e.i,e.i+2);if(n==="<("||n===">(")throw new x("feature",n,`process substitution (\`${n}\u2026\`) is not supported`);if(n==="&&"||n==="||")return e.i+=2,{kind:n};if("()<>;&|".includes(t))return e.i++,{kind:t,value:t};let r=Eb(e);return Bf(r,"]]")?{kind:"end"}:r}Dt("missing `]]`")}function Eb(e){let t={kind:"word",value:"",mask:"",quoted:!1,empty:[]},n=null,r=0;for(;e.i<e.line.length;){let o=e.line[e.i];if(n&&o===n){t.value.length===r&&t.empty.push(r),t.quoted=!0,n=null,e.i++;continue}if(n==="'"){Be(t,o,"1"),e.i++;continue}if(o==="\\"){$b(e,t,n);continue}if(o==="$"){if(Sb(e),!n&&e.line[e.i+1]==='"'){n='"',r=t.value.length,e.i+=2;continue}Ab(e,t,n);continue}if(o==="`"){let i=kt(e.line,e.i);Be(t,"`",n?"2":"0"),Be(t,i.raw.slice(1),"1"),e.i+=i.raw.length;continue}if(n){Be(t,o,"2"),e.i++;continue}if(o==="'"||o==='"'){n=o,r=t.value.length,e.i++;continue}if(o==="("&&t.mask.at(-1)==="0"&&/[?*+@!]/u.test(t.value.at(-1))&&!t.empty.includes(t.value.length))throw new x("feature","[[ extglob","extended glob patterns in [[ are not supported");if(/[ \t\n()<>;&|]/u.test(o))break;Be(t,o,"0"),e.i++}return n&&Dt(`unterminated ${n==="'"?"single":"double"} quote`),!t.quoted&&!/[12]/u.test(t.mask)&&(t.mask=null),t.empty.length===0&&delete t.empty,t}function Be(e,t,n,r=n!=="0"){e.value+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function $b(e,t,n){let r=e.line[e.i+1];if(r===`
21
+ `){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(Be(t,r,"1"),e.i+=2):(Be(t,"\\",n?"2":"1"),e.i++)}function Sb(e){for(;e.line[e.i+1]==="\\"&&e.line[e.i+2]===`
22
+ `;)e.line=e.line.slice(0,e.i+1)+e.line.slice(e.i+3),e.removed+=2}function Ab(e,t,n){let r=n?"2":"0";if(!n&&e.line[e.i+1]==="'"){let i=e.helpers.decodeAnsiC(e.line,e.i+2);i.text===""&&t.empty.push(t.value.length),Be(t,i.text,"1"),e.i=i.end;return}let o=e.helpers.readExpansion(e.line,e.i,e.expansionDepth+1,!!n);if(!o){Be(t,"$","1"),e.i++;return}if(o.command!==void 0||o.parameter!==void 0||o.arithmetic!==void 0)Be(t,"$",r),Be(t,o.raw.slice(1),"1",!1);else{let i=e.line[e.i+o.raw.length],s=vb.test(o.name)&&(i==="'"||i==='"')?"${"+o.name+"}":o.raw;Be(t,s,r)}e.i+=o.raw.length}var un=/^[A-Za-z_][A-Za-z0-9_]*$/u,Nb=/[A-Za-z0-9_]/u,Ob=/[?#@*$!0-9-]/u;function ye(e,t){for(;e[t]==="\\"&&e[t+1]===`
23
+ `;)t+=2;return t}function da(e,t,n=null){let r=s=>s<e.length&&(n===null||n[s]===n[t]);if(!r(t+1))return null;let o=e[t+1];if(Ob.test(o))return{name:o,raw:e.slice(t,t+2)};if(!/[A-Za-z_]/u.test(o))return null;let i=t+2;for(;r(i)&&Nb.test(e[i]);)i++;return{name:e.slice(t+1,i),raw:e.slice(t,i)}}function Et(e,t,n=0,r=!1,o={}){let i=(u,l,c,f)=>Et(u,l,c,f,o),s=ye(e,t+1),a=e[s];if(a==="("){let u=ye(e,s+1);if(e[u]==="(")return Mf(e,t,u,n,{readExpansion:i});let l=aa(e,t,s,n,{readExpansion:i,decodeAnsiC:Pn,readHeredocBodies:Cr,readOperator:Vo,readConditional:Ir,skipContinuations:ye});return o.validateSubstitution?.(l.command),l}if(a==="{")return Rf(e,t,s,n,r,{readExpansion:i,decodeAnsiC:Pn});if(a==="[")throw new x("feature","$[","arithmetic expansion (`$[\u2026]`) is not supported");return da(e,t)}function qf(e,t,n={}){let r=(s,a,u,l)=>Et(s,a,u,l,n),o=ye(e,t+1),i=aa(e,t,o,0,{readExpansion:r,decodeAnsiC:Pn,readHeredocBodies:Cr,readOperator:Vo,readConditional:Ir,skipContinuations:ye});return n.validateSubstitution?.(i.command),i}var jf={a:"\x07",b:"\b",e:"\x1B",E:"\x1B",f:"\f",n:`
24
+ `,r:"\r",t:" ",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function Ib(e,t){for(let n=t;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==="'")return n;throw new Error("unterminated single quote")}function Pn(e,t){let n=Ib(e,t),r=[],o=s=>{for(let a of T(s))r.push(a)};for(let s=t;s<n;s++){if(e[s]!=="\\"){let l=String.fromCodePoint(e.codePointAt(s));o(l),s+=l.length-1;continue}let a=e[s+1];if(a in jf){o(jf[a]),s++;continue}if(a==="x"&&e[s+2]==="{")throw new x("feature","ANSI-C hexadecimal escape","braced hexadecimal escapes in ANSI-C quotes are not supported");let u=/^(?:[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{1,4}|U[0-9a-fA-F]{1,8})/u.exec(e.slice(s+1,n));if(u){let l=u[0],c=/^[0-7]/u.test(l),f=c?parseInt(l,8):parseInt(l.slice(1),16);if(c||l[0]==="x")r.push(f&255);else{if(!st(f))throw new x("feature","ANSI-C Unicode escape","ANSI-C escapes outside Unicode scalar values are not supported");o(String.fromCodePoint(f))}s+=l.length;continue}if(a==="c"&&s+2<n){let l=e.codePointAt(s+2);if(l>127)throw new x("feature","ANSI-C control escape","ANSI-C control escapes require an ASCII character");r.push(l===63?127:l&31),s+=2,l===92&&e[s+1]==="\\"&&s++;continue}o("\\")}let i=r.indexOf(0);return{text:G(Uint8Array.from(i===-1?r:r.slice(0,i))),end:n+1}}function Vo(e,t,n){let r=e[t];if(n&&/[0-9]/u.test(r)){let s="",a=t;for(;/[0-9]/u.test(e[a]??"");)s+=e[a],a=ye(e,a+1);return e[a]!==">"&&e[a]!=="<"||e[ye(e,a+1)]==="("?null:Wf(e,a,Number(s))}let o=ye(e,t+1),i=e[o];switch(r){case"|":return i==="|"?vt("or",o+1):i==="&"?vt("pipe_err",o+1):vt("pipe",t+1);case"&":if(i==="&")return vt("and",o+1);if(i===">"){let s=ye(e,o+1),a=e[s]===">";return Ut(1,a?"bothAppend":"both",(a?s:o)+1)}return vt("amp",t+1);case";":return i===";"?vt("dsemi",o+1):vt("semi",t+1);case"(":return vt("paren_open",t+1);case")":return vt("paren_close",t+1);case"<":case">":return Wf(e,t,r==="<"?0:1);default:return null}}var Tb={semi:";",dsemi:";;",pipe:"|",pipe_err:"|&",and:"&&",or:"||",amp:"&",paren_open:"(",paren_close:")"},Cb={write:">",append:">>",read:"<",heredoc:"<<",herestring:"<<<",both:"&>",bothAppend:"&>>",dup:">&",close:">&-"};function Tr(e){if(e.kind==="word")return e.quoted?`"${e.value}"`:e.value;if(e.kind==="redir"){let t=Cb[e.op];if(e.op==="both"||e.op==="bothAppend")return t;let n=e.fd===(e.op==="read"||e.op==="heredoc"||e.op==="herestring"?0:1)?"":String(e.fd);return e.op==="dup"?`${n}${e.fd===0?"<&":">&"}${e.toFd}`:e.op==="close"?`${n}${e.fd===0?"<&-":">&-"}`:n+t}return Tb[e.kind]}var vt=(e,t)=>({token:{kind:e},end:t}),Ut=(e,t,n,r)=>({token:{kind:"redir",fd:e,op:t,...r},end:n});function Wf(e,t,n){let r=e[t],o=ye(e,t+1),i=e[o];if(i==="&")return _b(e,o,n,r==="<"?"<&":`${n===1&&r===">"?"":n}>&`);if(r==="<"){if(i===">")throw new x("feature","<>","read/write file redirects are not supported");if(i==="<"){let s=ye(e,o+1);if(e[s]==="<")return Ut(n,"herestring",s+1);let a=e[s]==="-";return Ut(n,"heredoc",(a?s:o)+1,{strip:a,delim:null,body:null})}return Ut(n,"read",t+1)}return i===">"?Ut(n,"append",o+1):Ut(n,"write",(i==="|"?o:t)+1)}function _b(e,t,n,r){let o=ye(e,t+1),i=e[o],s=e[ye(e,o+1)],a=s===void 0||/[ \t\n|&>;()<]/u.test(s);if(/[0-9]/u.test(i??"")&&a)return Ut(n,"dup",o+1,{toFd:Number(i)});if(i==="-"&&a)return Ut(n,"close",o+1);throw new x("feature","redirect target",`redirect \`${r}\` requires a file descriptor number (or \`-\`) followed by a token boundary`)}function Cr(e,t,n){let r=t+1;for(let o of n){let i=[],s=!1;for(;r<e.length;){let a,u="";for(;;){a=e.indexOf(`
25
+ `,r);let l=a===-1?e.length:a;if(u+=e.slice(r,l),r=l+1,o.quotedDelim||a===-1||!Lb(u))break;u=u.slice(0,-1)}if(a===-1&&u==="")break;if(o.strip&&(u=u.replace(/^\t+/u,"")),u===o.delim){s=!0;break}if(i.push(u),a===-1)break}o.body=i.length===0?"":i.join(`
26
+ `)+`
27
+ `,s||(o.warning=`warning: here-document delimited by end-of-file (wanted \`${o.delim}')
28
+ `)}return r-1}function Lb(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t++;return t%2===1}var Fb=new Set(["semi","amp","and","or","pipe","pipe_err","paren_open"]),Rb=e=>e===" "||e===" ";function Ko(e,t={}){return Xf(pa(e,t),!1).tokens}function Gf(e,t={}){let n=pa(e,t);return{read:()=>Xf(n,!0),reset:()=>{n.tokens=[]}}}function Xf(e,t){for(;e.i<e.line.length;){let n=e.line[e.i];if(e.quote&&n===e.quote){Zf(e),e.i++;continue}if(e.quote==="'"){be(e,n,"1"),e.i++;continue}if(n==="\\"){Yf(e);continue}if(n==="$"){Kf(e);continue}if(n==="`"){Jf(e);continue}if(e.quote){be(e,n,"2"),e.i++;continue}if(n==="'"||n==='"'){ma(e,n),e.i++;continue}let r=e.cur!==""||e.empty.length>0;if(!r&&e.line.startsWith("[[",e.i)&&/[ \t\n()<>;&|]|^$/u.test(e.line[e.i+2]??"")&&Ub(e.tokens)){let i=Ir(e.line,e.i,{readExpansion:e.readExpansion,decodeAnsiC:Pn});Hf(e,{kind:"condition",expression:i.expression}),e.i+=i.raw.length;continue}if(n==="#"&&!r){zb(e);continue}if(n===`
29
+ `){if(Bb(e),t)return{tokens:e.tokens,done:e.i>=e.line.length};continue}if(Rb(n)){_r(e),e.i++;continue}if(n==="("&&e.mask.at(-1)==="0"&&/[?*+@!]/u.test(e.cur.at(-1))&&!e.empty.includes(e.cur.length))throw new x("feature","extglob","extended glob patterns are not supported");if((n==="<"||n===">")&&e.line[ye(e.line,e.i+1)]==="("){Pb(e);continue}let o=Vo(e.line,e.i,!r);if(o?.token.kind==="paren_open"&&(o.token.wordAdjacent=r),o){_r(e),Hf(e,o.token),e.i=o.end;continue}be(e,n,"0"),e.i++}if(e.quote)throw new Error(`unterminated ${e.quote==="'"?"single":"double"} quote`);return _r(e),e.heredocs.length>0&&Cr(e.line,e.line.length,e.heredocs),{tokens:e.tokens,done:!0}}function pa(e,t={}){return{line:e,i:0,tokens:[],cur:"",mask:"",empty:[],quoted:!1,quoteStart:0,quote:null,heredocs:[],lastParenAt:-2,readExpansion:(n,r,o=0,i=!1)=>Et(n,r,o,i,t),readProcess:(n,r)=>qf(n,r,t)}}function ha(e,t=!1){let n={...pa(e),fragment:!0,fragmentQuoted:t};for(;n.i<n.line.length;){let r=n.line[n.i];if(n.quote&&r===n.quote){Zf(n),n.i++;continue}if(n.quote==="'"){be(n,r,"1"),n.i++;continue}if(r==="\\"){Yf(n);continue}if(r==="$"){Kf(n);continue}if(r==="`"){Jf(n);continue}if(n.quote){be(n,r,"2"),n.i++;continue}if(r==='"'||r==="'"&&!t){ma(n,r),n.i++;continue}if(!t&&(r==="<"||r===">")&&n.line[ye(n.line,n.i+1)]==="(")throw new x("feature",`${r}(`,"process substitution in parameter operands is not supported");be(n,r,t?"2":"0"),n.i++}if(n.quote)throw new x("feature","${","unterminated quote in parameter operand");return _r(n),n.tokens[0]??{value:"",mask:t?"":null}}var Mb=new Set(["semi","and","or","pipe","pipe_err","amp","paren_open"]),Db=new Set(["!","{","if","then","else","elif","while","until","do"]);function Ub(e){let t=!0,n=null,r=!1;for(let o of e){let i=Mb.has(o.kind)||o.kind==="paren_close"&&n?.kind==="paren_open";if(n=o,i){t=!0,r=!1;continue}if(o.kind==="redir"){t=!1,r=!["dup","close"].includes(o.op);continue}if(r){r=!1;continue}(!t||o.kind!=="word"||o.quoted||!Db.has(o.value))&&(t=!1)}return t&&!r}function ma(e,t){e.quoteStart=e.cur.length,e.quote=t}function Zf(e){e.cur.length===e.quoteStart&&e.empty.push(e.cur.length),e.quote=null}function be(e,t,n,r=n!=="0"){e.cur+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function _r(e){if(e.cur!==""||e.empty.length>0){let t=e.empty.length>0||e.quoted,n={kind:"word",value:e.cur,mask:/[12]/u.test(e.mask)||t?e.mask:null,quoted:t,...e.empty.length?{empty:e.empty}:{}};e.tokens.push(n);let r=e.heredocs.find(o=>o.delim===null);r&&(r.delim=n.value,r.quotedDelim=t)}e.cur="",e.mask="",e.empty=[],e.quoted=!1}function Hf(e,t){t.kind==="paren_open"&&(t.adjacent=ye(e.line,e.lastParenAt+1)===e.i,e.lastParenAt=e.i),t.kind==="redir"&&t.op==="heredoc"&&e.heredocs.push(t),e.tokens.push(t)}function Yf(e){let t=e.line[e.i+1];if(t===`
30
+ `){e.i+=2;return}t!==void 0&&(!(e.quote||e.fragmentQuoted)||'$`"\\'.includes(t)||e.fragment&&t==="}")?(be(e,t,"1"),e.i+=2):(be(e,"\\",e.quote||e.fragmentQuoted?"2":"1"),e.i++)}function Vf(e,t){let n=ye(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function Kf(e){Vf(e,e.i+1);let{line:t}=e,n=e.quote==='"'||e.fragmentQuoted?"2":"0",r=t[e.i+1];if((n==="0"||e.fragmentQuoted&&!e.quote)&&r==="'"){let a=Pn(t,e.i+2);if(e.fragmentQuoted&&/[$`"\\]/u.test(a.text))throw new x("feature","${","active characters in ANSI-C quoted parameter operands are not supported");a.text===""&&e.empty.push(e.cur.length),be(e,a.text,"1"),e.i=a.end;return}if((n==="0"||e.fragmentQuoted&&!e.quote)&&r==='"'){ma(e,'"'),e.i+=2;return}let o=e.readExpansion(t,e.i,0,n==="2");if(!o){be(e,"$","1"),e.i++;return}if(o.command!==void 0||o.parameter!==void 0||o.arithmetic!==void 0){be(e,"$",n),be(e,o.raw.slice(1),"1",!1),e.i+=o.raw.length;return}let i=t[e.i+o.raw.length],s=un.test(o.name)&&(i==='"'||i==="'")?"${"+o.name+"}":o.raw;be(e,s,n),e.i+=o.raw.length}function Pb(e){Vf(e,e.i+1);let{raw:t}=e.readProcess(e.line,e.i);be(e,e.line[e.i],"0"),be(e,t.slice(1),"1",!1),e.i+=t.length}function Jf(e){let t=e.quote==='"'||e.fragmentQuoted?"2":"0",{raw:n}=kt(e.line,e.i);be(e,"`",t),be(e,n.slice(1),"1",!1),e.i+=n.length}function zb(e){for(;e.i<e.line.length&&e.line[e.i]!==`
31
+ `;)e.i++}function Bb(e){_r(e),e.heredocs.length>0&&(e.i=Cr(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!Fb.has(t.kind)?e.tokens.push({kind:"semi",newline:!0}):(t?.kind==="semi"||t?.kind==="amp")&&(t.lineEnd=!0),e.i++}function Jo(e,t,n){let r={aliases:new Set(t),hasCommand:n};return Pt(e,r),r.aliases}var Lr=(e,t)=>new Set([...e,...t]);function Pt(e,t){let n=null;for(let r of e){let o=r.gate==="and"||r.gate==="or";if(o&&n!==null&&r.gate==="and"!=(n===0))continue;let i=o&&n===null?new Set(t.aliases):null,s=r.stages.length===1?r.stages[0]:null;n=s&&!s.isolate?jb(s,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=Lr(i,t.aliases),n=null)}return n}function jb(e,t){if(e.group)return Pt(e.group,t);if(e.conditional)return Wb(e.conditional,t);if(e.loop){if(e.loop.condition&&Pt(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let o=new Set(t.aliases);Pt(e.loop.body,t),t.aliases=Lr(o,t.aliases)}return null}let n=e.words[0]?.value;if(e.redirs.length===0&&(n==="true"||n==="false"))return+(n==="false");if(!["alias","unalias"].includes(n)||t.hasCommand(n))return null;let r=e.words.slice(1).map(o=>o.value);for(;r[0]?.startsWith("-")&&r[0]!=="-";){let o=r.shift();if(o==="--")break;if(!(n==="alias"?/^-p+$/u:/^-a+$/u).test(o))return null;if(n==="unalias")return t.aliases.clear(),null}for(let o of r)if(n==="unalias")t.aliases.delete(o);else{let i=o.indexOf("="),s=o.slice(0,i);i>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(s)&&t.aliases.add(s)}return null}function Wb(e,t){let n=new Set;for(let r of e.branches){let o=Pt(r.condition,t);if(o===0)return Pt(r.body,t),t.aliases=Lr(n,t.aliases),null;if(o===null){let i={...t,aliases:new Set(t.aliases)};Pt(r.body,i),n=Lr(n,i.aliases)}}return e.otherwise&&Pt(e.otherwise,t),t.aliases=Lr(n,t.aliases),null}var ut=class extends Error{constructor(t){super(t.message),this.finalError=t}},zt=e=>new ut(new Error(e));function Ie(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let n=e.read();e.raw=n.tokens,e.done=n.done}return e.raw[t]}function Qf(e,t,n){let r=t.validation??new Map;return{validateSubstitution(o){r.has(o)||(ga(o,!0,e,{validation:r,syntaxOnly:!0},n),r.set(o,!0))}}}function ga(e,t,n,r,o){try{return o(Ko(e,Qf(n,r,o)),t,n,r)}catch(i){throw i instanceof ut?i.finalError:i}}function qb(e,t,n,r){let o=Gf(e,Qf(n,{},r)),i=new Set,s=!1;return()=>{let a={aliases:i,aliasUsed:s,read:o.read,unit:!0},u=r([],t,n,a);return s=a.aliasUsed,i=Jo(u,i,n),o.reset(),{steps:u,done:a.done}}}function*ed(e,t,n,r){let o=qb(e,t,n,r);for(;;){let i;try{i=o()}catch(s){throw s instanceof ut?s.finalError:s}if(i.steps.length>0&&(yield i.steps),i.done)return}}var Hb=["elif","else","fi"];function nd(e,t){let n=[],r;do{lt(e);let i=t(e,"then");lt(e);let s=t(e,Hb);n.push({condition:i,body:s}),r=e.raw[e.i-1].value}while(r==="elif");let o=null;return r==="else"&&(lt(e),o=t(e,"fi")),{branches:n,otherwise:o}}function rd(e,t){let{raw:n}=e,r=e.loop;e.loop="for";let o=Ie(e);if(o?.kind==="paren_open")throw new x("feature","for ((","arithmetic `for ((\u2026))` loops are not supported; use `for NAME in WORD...`");if(o===void 0||o.kind!=="word")throw new Error("for: expected a variable name");let i=o.value;if(o.quoted||!un.test(i))throw new Error(`for: \`${i}\` is not a valid variable name`);e.i++;let s=Ie(e);s?.kind==="semi"&&e.i++;let a=Ie(e);if(s?.kind==="semi"&&!s.newline&&zn(a,"in"))throw new Error("for: unexpected `in` after `;`");if(!zn(a,"in")){if(zn(a,"do")||a===void 0){let d=new x("feature","for NAME; do",`\`for ${i}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${i} in WORD...\``);throw a===void 0?new ut(d):d}throw new Error(`for: expected \`in\` after \`${i}\``)}e.i++;let u=[],l=!1;for(let d;(d=Ie(e))&&d.kind!=="semi";e.i++){if(d.kind!=="word")throw new Error(`for: unexpected \`${Tr(d)}\` in word list`);zn(d,"do")&&(l=!0),u.push(Oe(d))}n[e.i]?.kind==="semi"&&e.i++;let c=Ie(e);if(!zn(c,"do"))throw c===void 0?zt(l?"for: expected `;` or newline before `do`":"for: missing `do`"):l?new Error("for: expected `;` or newline before `do`"):new Error(`for: expected \`do\`, got \`${Tr(c)}\``);e.i++,lt(e);let f={name:i,words:u,body:t(e,"done")};return e.loop=r,f}function od(e,t,n){let r=e.loop;e.loop=t,lt(e);let o=n(e,"do");lt(e);let i={until:t==="until",condition:o,body:n(e,"done")};return e.loop=r,i}function id(e,t,n){if(t.quoted||!un.test(t.value))throw new x("feature","function",`shell functions named \`${t.value}\` are not supported`);e.i+=2,lt(e);let r=Ie(e);if(!zn(r,"{"))throw new x("feature","function",`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,lt(e);let o=n(e,"}");if(!ln(o))throw new x("feature","function",`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:o}}var ln=e=>e.every(t=>t.stages.every(Gb));function Gb(e){return e.assigns.length>0||e.define?!1:e.test?Qo(e.test)&&e.redirs.every(td):e.group?ln(e.group):e.conditional?e.conditional.branches.every(t=>ln(t.condition)&&ln(t.body))&&ln(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(Bn)&&ln(e.loop.condition??[])&&ln(e.loop.body):e.words.every(Bn)&&e.redirs.every(td)}function Qo(e){return e.kind==="and"||e.kind==="or"?Qo(e.left)&&Qo(e.right):e.kind==="not"?Qo(e.expression):e.kind==="unary"?Bn(e.word):Bn(e.left)&&Bn(e.right)}var td=e=>e.op==="text"?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||Bn(e.word);function Bn(e){for(let t=0;t<e.value.length;t++){let n=e.value[t];if((n==="$"||n==="`")&&(e.mask===null||e.mask[t]!=="1"))return!1}return!0}function lt(e){for(let t;(t=Ie(e))?.kind==="semi"&&t.newline;)e.i++}function zn(e,t){return e!==void 0&&e.kind==="word"&&!e.quoted&&e.value===t}var fd=(e,t=!1,n=()=>!1,r={})=>ga(e,t,n,r,pd),dd=(e,t=!1,n=()=>!1)=>ed(e,t,n,pd);function pd(e,t,n,r){let o={raw:e,i:0,done:!r.read,read:r.read,unitOnly:r.unit,emptyStage:!1,writable:t,aliases:r.aliases??new Set,aliasUsed:r.aliasUsed??!1,hasCommand:n,syntaxOnly:r.syntaxOnly};try{let i=Ie(o)?cn(o,null):[];if(o.emptyStage)throw new Error("empty pipeline stage");return r.aliasUsed=o.aliasUsed,r.done=o.done,i}catch(i){if(o.aliasUsed&&!(i instanceof x)){let s=new x("feature","alias expansion","alias expansion is not supported; input using aliases cannot be parsed");throw i instanceof ut?new ut(s):s}throw i}}function ya(e,t,n){t.stages.push(n),!ei(n)&&!xa(n)&&(e.emptyStage=!0)}var xa=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,ei=e=>e.group||e.loop||e.conditional||e.test||e.define,sd=()=>({words:[],assigns:[],redirs:[]}),wa=e=>({gate:e,stages:[],negate:!1,bang:!1}),ad=(e,t)=>e.bang&&e.stages.length===0&&jn(t)&&t.redirs.length===0,jn=e=>!ei(e)&&e.words.length===0&&e.assigns.length===0,Xb=new Set(["for","while","until","do","done","if","{","}","!"]),Zb=new Set(["then","else","elif","fi","esac","in"]),ud=new Map([["case","`case` statements are not supported; gate on exit status with `&&` / `||` instead"],["select","`select` loops are not supported"],["function","shell functions are not supported"],["time","`time` is not supported"],["coproc","`coproc` is not supported"]]),Yb=new Set(["alias","declare","typeset","local","readonly","export","eval","let"]),Vb=new Set(["pipe","pipe_err","and","or","semi","amp"]),ld=new Set(["semi","amp"]);function cn(e,t){let{raw:n}=e,r=[wa("first")];t===null&&(e.unit=r[0]);let o=0,i=sd();for(let s;s=Ie(e);){if(s.kind==="condition"){if(!jn(i))throw new Error("unexpected `[[`");i.test=s.expression,e.i++;continue}if(s.kind==="paren_close"){if(t!==")")throw new Error("unexpected `)`");return e.i++,cd(e,r,i,t)}if(s.kind==="paren_open"){Kb(e,i);continue}if(Vb.has(s.kind)){if(s.kind==="pipe_err"&&(xa(i)||ei(i))&&i.redirs.push({fd:2,op:"dup",toFd:1}),s.kind==="semi"&&ad(r.at(-1),i)||ya(e,r.at(-1),i),s.kind==="amp"&&(r.at(-1).background=!0),i=sd(),s.kind==="and"||s.kind==="or"?r.push(wa(s.kind)):ld.has(s.kind)&&r.push(wa("seq")),t===null&&(s.newline||s.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=Jo(r.slice(o,-1),e.aliases,e.hasCommand),o=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(s.kind==="dsemi")throw new Error("syntax error near unexpected token `;;`");if(s.kind==="redir"){if(s.warning&&(e.unit.warnings=(e.unit.warnings??"")+s.warning),i.define)throw new x("feature","function",`\`${i.define.name}()\` with a redirect of its own is not supported`);let u=n2(e);u&&i.redirs.push(u);continue}if(i.group||i.define)throw new Error(`unexpected token after \`${i.isolate?")":"}"}\``);if(i.loop)throw new Error("unexpected token after `done`");if(i.conditional)throw new Error("unexpected token after `fi`");if(i.test)throw new Error("unexpected token after `]]`");if(!s.quoted&&i.words.length===0&&e.aliases.has(s.value)&&(e.aliasUsed=!0),!s.quoted&&jn(i)){if(Array.isArray(t)?t.includes(s.value):s.value===t)return e.i++,cd(e,r,i,t);if(Jb(s,e,r.at(-1),i))continue}let a=i.words.length===0?Or(s):null;a===null?i.words.push(Oe(s)):i.assigns.push({name:a.name,word:Oe(s,a.end)}),e.i++}if(t===")")throw zt("unmatched `(`");if(t==="}")throw zt("unmatched `{`");if(t==="do"||t==="done")throw zt(`${e.loop}: missing \`${t}\``);if(t)throw zt(`if: missing \`${t==="then"?"then":"fi"}\``);if(!e.emptyStage&&!ei(i)&&!xa(i)&&["and","or","pipe","pipe_err"].includes(n.at(-1)?.kind))throw zt("empty pipeline stage");return ld.has(n.at(-1)?.kind)?r.pop():ad(r.at(-1),i)||ya(e,r.at(-1),i),r}function Kb(e,t){let{raw:n,i:r}=e,o=Ie(e,r+1),i=n[r-1],s=t.words[0],a=t.words.at(-1);if(!(n[r-2]?.kind==="redir"&&!["dup","close"].includes(n[r-2].op))&&(t.words.length===0&&t.assigns.length>0||a&&a.value===i?.value&&(t.words.length===1||s.mask===null&&Yb.has(s.value)))&&n[r].wordAdjacent&&i?.kind==="word"&&!i.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(i.value))throw new x("feature","array assignment","shell array assignments are not supported");if(o?.kind==="paren_open"&&o.adjacent&&jn(t))throw new x("feature","((","arithmetic evaluation (`((\u2026))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&o?.kind==="paren_close"){t.define=id(e,t.words.pop(),cn);return}if(!jn(t))throw new Error("unexpected `(`");e.i++,t.group=cn(e,")"),t.isolate=!0}function Jb(e,t,n,r){let o=e.value;if(ud.has(o))throw new x("feature",o,ud.get(o));if(Zb.has(o))throw new Error(`syntax error near unexpected token \`${o}\``);if(!Xb.has(o))return!1;if(t.i++,o==="!"){if(n.stages.length>0||r.redirs.length>0)throw new Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(o==="{")return lt(t),r.group=cn(t,"}"),r.isolate=!1,!0;if(o==="}")throw new Error("syntax error near unexpected token `}`");if(o==="done")throw new Error("unexpected `done`");if(o==="do")throw new Error("unexpected `do`");return o==="if"?r.conditional=nd(t,cn):r.loop=o==="for"?rd(t,cn):od(t,o,cn),!0}var Qb={")":"empty subshell `()`","}":"empty group `{ }`"},e2=(e,t)=>t==="do"?`${e.loop}: empty condition`:t==="done"?`${e.loop}: empty loop body`:t==="then"?"if: empty condition":"if: empty branch body";function cd(e,t,n,r){let o=t.at(-1),i=jn(n)&&n.redirs.length===0&&o.stages.length===0;if(i&&t.length===1)throw new Error(Qb[r]??e2(e,r));if(i&&o.bang)throw new Error("syntax error near unexpected token after `!`");return i&&o.gate==="seq"?t.pop():ya(e,o,n),t}var t2=new Set(["/dev/null","/dev/stdout","/dev/stderr"]);function n2(e){let t=e.raw[e.i++],n=Tr(t);if(e.syntaxOnly){if(!["dup","close"].includes(t.op)){let a=Ie(e,e.i++);if(!a||a.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new x("feature",n,`only file descriptors 0, 1 and 2 are supported (got \`${n}\`)`);if(t.op==="dup"){if(t.fd===0&&t.toFd===0)return null;if(t.fd===0||t.toFd===0)throw new x("feature",n,`duplicating file descriptor 0 (\`${n}\`) is not supported`);return{fd:t.fd,op:"dup",toFd:t.toFd}}if(t.op==="close"){if(t.fd===0)throw new x("feature","0<&-","closing standard input is not supported");return{fd:t.fd,op:"close"}}let r=Ie(e,e.i++);if(!r||r.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`);if(t.op==="heredoc"||t.op==="herestring"||t.op==="read"){if(t.fd!==0)throw new x("feature",n,`reading into file descriptor ${t.fd} (\`${n}\`) is not supported`);return t.op==="heredoc"?{fd:0,op:"text",body:t.body??"",expand:!t.quotedDelim}:{fd:0,op:t.op,word:Oe(r)}}if(t.fd===0)throw new x("feature",n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let o=t.op==="both"||t.op==="bothAppend",i=t.op==="append"||t.op==="bothAppend",s=Oe(r);if(r2(s))return{fd:t.fd,op:"to",word:s,both:o,append:i,label:n};if(!e.writable&&!t2.has(s.value))throw ba(n,s.value,e.writable);return{fd:t.fd,op:"to",target:s.value,both:o,append:i,label:n}}function r2(e){for(let t=0;t<e.value.length;t++){let n=e.value[t],r=e.mask===null?"0":e.mask[t];if((n==="$"||n==="`")&&r!=="1"||r==="0"&&(/[~*?[{]/u.test(n)||(n==="<"||n===">")&&e.value[t+1]==="("))return!0}return!1}function ba(e,t,n){let r=n?"only `/tmp/` is writable":"the filesystem is read-only";return new x("feature",e,`\`${e}\` cannot write to \`${t}\`: ${r}`)}var o2=/^[a-zA-Z0-9][\w.+-]*$/u,ka=["run","pipe","hidden"],va=["stdout","stderr","exitCode"];function md(e,t){let n={__proto__:null},r=[],o=[];for(let[i,s]of i2(e)){let{run:a,pipe:u,hidden:l}=s2(i,s,t);l&&r.includes(i)||(n[i]=(c,f,d)=>a2(i,a,c,f,d),!l&&(r.push(i),u&&o.push(i)))}return{handlers:n,names:r,pipeNames:o}}function i2(e){if(e==null)return[];if(Array.isArray(e))throw new TypeError("createTerminal: opts.commands must be an object or a Map (got an array)");if(typeof e!="object")throw new TypeError(`createTerminal: opts.commands must be an object or a Map (got ${typeof e})`);if(typeof e.entries=="function")return[...e.entries()];let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new TypeError("createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)");return Object.entries(e)}function s2(e,t,n){if(typeof e!="string")throw new TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!o2.test(e))throw new Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw new Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t=="function"){for(let o of Object.keys(t))if(ka.includes(o))throw new Error(`createTerminal: ${e}: \`${o}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(t===null||typeof t!="object")throw new TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!="function")throw new TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let o of Object.keys(t))if(!ka.includes(o))throw new Error(`createTerminal: ${e}: unknown option \`${o}\` (known: ${ka.join(", ")})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function a2(e,t,n,r,o){o.io?.bufferOutput(),z(o);let i={cwd:o.cwd,fs:o.fs,mount:o.mount,home:o.home,get notes(){return o.notes},command:e,stdinFile:o.stdinFile,stdinOrigin:o.stdinOrigin},s=!0,a=()=>{s=!1},u={name:e,args:r,stdin:n,cwd:i.cwd,fs:u2(i),readInputs:(c=[])=>{if(typeof c=="string")throw new TypeError(`readInputs: expected an array of paths, got a string: ${c}`);return ae(e,[...c],n,i)},run:c=>{if(!s)throw new Error("run: the command this belongs to has finished, and its turn with it");return o.runLine(c)}},l=t(u);return typeof l?.then!="function"?(a(),hd(l)):l.then(hd).finally(a)}function u2(e){let t=n=>E(e.cwd,n,e.fs).path;return{resolve:n=>j(e.cwd,n),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:n=>e.fs.isLink?.(E(e.cwd,n,e.fs,{follow:!1}).path)===!0,readLink:n=>e.fs.readLink?.(E(e.cwd,n,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>fe(e.fs,t(n))?.slice(),listDir:n=>{let{path:r,error:o}=D(e,e.command,n);if(!e.fs.isDir(r))throw new Error(`${n}: ${o??"Not a directory"}`);let{dirs:i,files:s,links:a=[]}=e.fs.listDir(r);return{dirs:[...i],files:[...s],links:[...a]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function hd(e){if(e==null)return R();if(typeof e=="string")return R(e);if(typeof e!="object")throw new TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw new TypeError("invalid result: expected a string or an object, got an array (join the lines first)");let t=Object.keys(e);for(let i of t)if(!va.includes(i))throw new TypeError(`invalid result: unknown field \`${i}\` (known: ${va.join(", ")})`);if(t.length===0)throw new TypeError(`invalid result: an object with none of ${va.join(", ")} \u2014 return a string for plain output`);let{stdout:n="",stderr:r="",exitCode:o=0}=e;if(typeof n!="string")throw new TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!="string")throw new TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(o)||o<0)throw new TypeError(`invalid result: exitCode must be a non-negative integer (got ${o})`);return{stdout:n,stderr:r===""||r.endsWith(`
32
+ `)?r:r+`
33
+ `,exitCode:o}}var $e=new Uint8Array(0),Fr=e=>e.every(t=>t<128),ti=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function ct(e){let t=new Uint8Array(e.reduce((r,o)=>r+o.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}var k=class extends Error{constructor(t,n){super(n===void 0?t:`${t} at byte ${n}`),this.name="ArchiveError",this.offset=n}};function Wn(e,t){try{return e()}catch(n){throw!(n instanceof k)||n.offset!==void 0?n:new k(n.message,t)}}var qn=class extends k{constructor(t,{bytes:n,limited:r=!1,cause:o}){super(t),this.name="CompressionError",this.bytes=n,this.limited=r,this.cause=o}};function Re(e){try{return[new CompressionStream(e),new DecompressionStream(e)].every(Boolean)}catch{return!1}}async function*l2(e){if(Symbol.asyncIterator in e)return yield*e;let t=e.getReader();for(let n=await t.read();!n.done;n=await t.read())yield n.value}function c2(e){let t=0;return new TransformStream({transform(n,r){t+=n.length,t<=e?r.enqueue(n):r.error(new RangeError(`output past ${e} bytes`))}})}async function Ea(e,t,n,r,o,i){if(!(e instanceof Uint8Array))throw new k("the data is not a Uint8Array");let s=new t(n),a=[],u=0,l=()=>i!==void 0?i.subarray(0,u):a.length===1?a[0]:ct(a);try{for await(let c of l2(new Blob([e]).stream().pipeThrough(s).pipeThrough(c2(r))))i===void 0?a.push(c):i.set(c,u),u+=c.length}catch(c){let f=c instanceof RangeError;throw new qn(f?`the data ${o}es past ${r} bytes`:`the data does not ${o}`,{bytes:l(),limited:f,cause:c})}return l()}var je=(e,t,{limit:n=1/0}={})=>Ea(e,CompressionStream,t,n,"compress"),$a=(e,t,{limit:n=1/0}={})=>Ea(e,DecompressionStream,t,n,"decompress"),gd=(e,t,n)=>Ea(e,DecompressionStream,t,n.length,"decompress",n);var $t=e=>e.type==="directory"?`${e.name}/`:e.name,ni=e=>/(?:^|\/)\.(?:\/|$)/u.test(e)?["dot-segment names","names stored with `.' segments are not supported"]:["directory names","directories stored without a trailing slash are not supported"];function ri(e){return e.name==="."||e.storedName!==$t(e)?e.storedName:e.storedLinkname!==void 0&&e.storedLinkname!==e.linkname?e.storedLinkname:null}function O(e){return e.length<=200?JSON.stringify(e):JSON.stringify(`${e.slice(0,e.codePointAt(199)>65535?199:200)}\u2026`)}var f2=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/u,d2=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\\]/u,Bt=(e,t)=>(t?d2:f2).test(e);function fn(e,t){if(typeof e!="string")throw new k(`${t} is not a string`);if(!e.isWellFormed())throw new k(`${t} is not well-formed Unicode`)}function p2(e){let t=0;for(let n of e){let r=n.codePointAt(0);t+=r<128?1:r<2048?2:r<65536?3:4}return t}var oi=(e,t)=>e.length>t||e.length*3>t&&p2(e)>t;function jt(e,t){try{return Qt(e)}catch{throw new k(`${t} is not well-formed Unicode`)}}function We(e,t,n){try{return mr(e)}catch{throw new k(`${t} is not valid UTF-8`,n)}}var Hn={file:420,directory:493,symlink:511},Sa=e=>e==="file"||e==="contiguous-file",ii=e=>e.type==="directory"?`${e.name}/`:e.name;function si(e,t){if(e===null||typeof e!="object")throw new k("an entry is not an object");let n=e.type??"file";if(typeof n!="string")throw new k("entry type is not a string");if(!Object.hasOwn(t,n))throw new k(`entry type ${O(n)} is not one this package writes`);let{name:r}=e;fn(r,"entry name");let o=e.data??$e;if(!(o instanceof Uint8Array))throw new k(`data of ${O(r)} is not a Uint8Array`);if(o.length!==0&&!Sa(n))throw new k(`a ${n} cannot carry data (${O(r)})`);let i=e.linkname??"";if(fn(i,`link target of ${O(r)}`),i!==""&&n!=="hardlink"&&n!=="symlink")throw new k(`a ${n} cannot have a link target (${O(r)})`);return{name:r,type:n,data:o,linkname:i}}var Se=512,Gn=e=>e==="character-device"||e==="block-device",dn={file:48,hardlink:49,symlink:50,"character-device":51,"block-device":52,directory:53,fifo:54,"contiguous-file":55},Xn={pax:120,global:103,longname:76,longlink:75},Te=100,Zn=155,pn=32,wd=0,yd=[["mode",100,8],["uid",108,8],["gid",116,8],["size",124,12],["mtime",136,12]],ui=148,xd=156,bd=157,Na=257,kd=265,vd=297,Ed=329,$d=337,Sd=345,h2=386,m2=495,Ad="ustar\x0000",Nd="ustar \0",Oa=e=>Uint8Array.from(e,t=>t.codePointAt(0)),Od=e=>String.fromCodePoint(...e),Wt=(e,t,n,r)=>e.subarray(t,t+n).set(r),Ia=e=>8**(e-1)-1,Ta=(e,t)=>e>=0&&e<=Ia(t);function Aa(e,t,n,r,o){if(Ta(r,n)){Wt(e,t,n,Oa(r.toString(8).padStart(n-1,"0")));return}if(!o)throw new k(`${r} does not fit an octal field of ${n-1} digits`);e[t]=r<0?255:128;let i=BigInt.asUintN((n-1)*8,BigInt(r));for(let s=t+n-1;s>t;s--)e[s]=Number(i&0xffn),i>>=8n}function ai(e,t,n,r,o,i=!1){let s=e[t];if(s===128||s===255){let u=0n;for(let l=t+1;l<t+n;l++)u=u<<8n|BigInt(e[l]);if(s===255&&(u=BigInt.asIntN((n-1)*8,u)),u<0n&&!i)throw new k(`the ${r} field is negative`,o);if(u>BigInt(Number.MAX_SAFE_INTEGER)||u<-BigInt(Number.MAX_SAFE_INTEGER))throw new k(`the ${r} field is too large`,o);return Number(u)}let a=/^ *([0-7]*) *$/u.exec(Od(li(e.subarray(t,t+n))));if(!a)throw new k(`the ${r} field is not an octal number`,o);return a[1]===""?0:Number.parseInt(a[1],8)}function li(e){let t=e.indexOf(0);return t===-1?e:e.subarray(0,t)}var Rr=(e,t,n)=>li(e.subarray(t,t+n));function Id(e){let t=256;for(let n=0;n<ui;n++)t+=e[n];for(let n=ui+8;n<Se;n++)t+=e[n];return t}var Mr=e=>e.every(t=>t===0);function Ca(e){let t=new Uint8Array(Se);Wt(t,wd,Te,e.name);for(let[n,r,o]of yd)Aa(t,r,o,e[n],e.gnu);return t[xd]=e.typeflag,Wt(t,bd,Te,e.linkname),Wt(t,Na,8,Oa(e.gnu?Nd:Ad)),Wt(t,kd,pn-1,e.uname),Wt(t,vd,pn-1,e.gname),e.devmajor!==null&&Aa(t,Ed,8,e.devmajor,e.gnu),e.devminor!==null&&Aa(t,$d,8,e.devminor,e.gnu),Wt(t,Sd,Zn,e.prefix),Wt(t,ui,8,Oa(`${Id(t).toString(8).padStart(6,"0")}\0 `)),t}function Td(e,t){if(Id(e)!==ai(e,ui,8,"checksum",t))throw new k("header checksum does not match",t);let n=Od(e.subarray(Na,Na+8)),r=n===Nd;if(!r&&n!==Ad)throw new k("header is not in the ustar, pax or gnu format",t);if(r&&!Mr(e.subarray(h2,m2)))throw new k("header carries an old GNU sparse map or real size",t);let o=e[xd],i=o===dn["character-device"]||o===dn["block-device"];return{gnu:r,typeflag:o,name:Rr(e,wd,Te),prefix:r?$e:Rr(e,Sd,Zn),linkname:Rr(e,bd,Te),uname:Rr(e,kd,pn),gname:Rr(e,vd,pn),...Object.fromEntries(yd.map(([s,a,u])=>[s,ai(e,a,u,s,t,s==="mtime")])),devmajor:i?ai(e,Ed,8,"devmajor",t):0,devminor:i?ai(e,$d,8,"devminor",t):0}}var ci=4096,Cd=255;function Fd(e,t){if(fn(e,t),e==="")throw new k(`${t} is empty`);if(Bt(e,!0))throw new k(`${t} ${O(e)} holds a control or formatting character, or a backslash`);if(e.startsWith("/"))throw new k(`${t} ${O(e)} is absolute`);let n=e.split("/");if(/^[a-zA-Z]:/u.test(n.find(r=>r!==".")??""))throw new k(`${t} ${O(e)} starts with a drive letter`);if(oi(e,ci))throw new k(`${t} ${O(e)} is longer than ${ci} bytes`);for(let r of n)if(oi(r,Cd))throw new k(`${t} ${O(e)} has a segment longer than ${Cd} bytes`);return n}function _d(e,t,n=!1){let r=Fd(e,t),o=r.at(-1)==="";if(o){if(!n)throw new k(`${t} ${O(e)} ends in a slash but is not a directory`);r.pop()}let i=r.filter(a=>a!==".");for(let a of i){if(a==="")throw new k(`${t} ${O(e)} has an empty segment`);if(a==="..")throw new k(`${t} ${O(e)} has a .. segment`)}if(i.length===0){if(!n)throw new k(`${t} ${O(e)} names the archive root but is not a directory`);return"."}let s=o||i.length<r.length?i.join("/"):e;if(oi(s,ci-(n?1:0)))throw new k(`${t} ${O(e)} is longer than ${ci} bytes`);return s}function Rd(e,t){let n=Fd(t,`symlink target of ${O(e)}`).filter(o=>o!==""&&o!=="."),r=e.split("/").length-1;for(let o of n)if(r+=o===".."?-1:1,r<0)throw new k(`symlink ${O(e)} points outside the archive, to ${O(t)}`);return n}function qt(e,t,n){let r=_d(e,"entry name",t==="directory"),o=n;return t==="symlink"?Rd(r,n):t==="hardlink"&&(o=_d(n,`hard link target of ${O(r)}`)),{name:r,linkname:o}}var Md=()=>({kind:void 0,entry:void 0,symlink:void 0,first:void 0,firstNode:void 0,rest:void 0});function _a(e,t,n=!0){if(e.first===t)return e.firstNode;let r=e.rest?.get(t);return r!==void 0||!n||(r=Md(),e.first===void 0?(e.first=t,e.firstNode=r):(e.rest??=new Map,e.rest.set(t,r))),r}var Ld=["type","mode","uid","gid","mtime","uname","gname","linkname","devmajor","devminor"],ft=class{#t=Md();#s;constructor(t=!1){this.#s=t}add(t){let{name:n,type:r}=t,o=r==="symlink"?t.linkname:void 0;if(r==="hardlink"){let l=this.#r(t.linkname);if(l?.kind!=="entry")throw new k(`hard link ${O(n)} targets ${O(t.linkname)}, which is not an earlier non-directory entry`);o=l.symlink,o!==void 0&&this.#n(n,o,`hard link ${O(n)} to symlink ${O(t.linkname)}`)}let i=n.split("/"),s=this.#i(i),a=s.at(-1);if(a.kind!==void 0&&a.kind!=="implied"){let l=Ld.find(c=>a.entry[c]!==t[c]);if(l!==void 0)throw new k(`duplicate entry ${O(n)} differs in ${l}`);if(a.entry.data===void 0)throw new k(`duplicate entry ${O(n)}, which only the in-memory call can compare with the earlier one`);if(!ti(a.entry.data,t.data))throw new k(`duplicate entry ${O(n)} differs in data`);return}let u=r==="directory"?"directory":"entry";if(a.kind!==void 0&&u!=="directory")throw new k(`${O(n)} is already a directory, so it cannot be a ${r}`);for(let l=1;l<i.length;l++)this.#e(s[l],()=>`${O(n)} is inside ${O(i.slice(0,l).join("/"))}, which is not a directory`);a.kind=u,a.symlink=o,a.entry=this.#s?t:Object.fromEntries(Ld.map(l=>[l,t[l]])),r==="symlink"&&this.#n(n,t.linkname,`symlink ${O(n)}`)}#n(t,n,r){let o=Rd(t,n),i=t.split("/").slice(0,-1),s=this.#i(i);for(let[a,u]of o.entries())u===".."?(i.pop(),s.pop()):(i.push(u),s.push(_a(s.at(-1),u))),a<o.length-1&&i.length&&this.#e(s.at(-1),()=>`the target of ${r} passes through ${O(i.join("/"))}, which is not a directory`)}#e(t,n){if(t.kind==="entry")throw new k(n());t.kind??="implied"}#i(t){let n=[this.#t];for(let r of t)n.push(_a(n.at(-1),r));return n}#r(t){let n=this.#t;for(let r of t.split("/"))if(n=_a(n,r,!1),n===void 0)return;return n}};function g2(e,t){let n=Qt(` ${e}=${t}
34
+ `),r=String(n.length).length,o=n.length+r+(String(n.length+r).length>r?1:0);return ct([Qt(String(o)),n])}var Dd=e=>ct(e.map(([t,n])=>g2(t,n))),La="pax records cannot be changed",Dr=class extends Map{set(){throw new TypeError(La)}delete(){throw new TypeError(La)}clear(){throw new TypeError(La)}},w2=(e,t,n)=>Map.prototype.set.call(e,t,n);function Fa(e,t){let n=new Dr;for(let r=0;r<e.length;){let o=r,i=0;for(;o<e.length&&e[o]>=48&&e[o]<=57;o++)i=i*10+(e[o]-48);if(o===r||e[r]===48||e[o]!==32)throw new k("a pax record does not begin with its length",t);let s=r+i;if(s>e.length||e[s-1]!==10)throw new k("a pax record is not as long as it says",t);let a=e.indexOf(61,o+1);if(a===-1||a>=s-1)throw new k("a pax record has no keyword=value",t);let u=We(e.subarray(o+1,a),"a pax record",t);if(u===""||Bt(u,!1)||u.includes(" "))throw new k(`pax keyword ${O(u)} is malformed`,t);if(n.has(u))throw new k(`pax keyword ${u} repeats`,t);w2(n,u,We(e.subarray(a+1,s-1),"a pax record",t)),r=s}return n}var y2=new Set(["gnu","ustar","pax"]),Ud=47;function Yn(e,t,n=!1){if(!Number.isSafeInteger(e)||!n&&e<0)throw new k(`${t} ${String(e)} is not ${n?"an integer":"a non-negative integer"}`);return e}function Pd(e,t){if(fn(e,t),Bt(e,!1))throw new k(`${t} ${O(e)} holds a control or formatting character`);return e}function x2(e){let t=si(e,dn),{name:n,type:r}=t,o=Yn(e.devmajor??0,"devmajor"),i=Yn(e.devminor??0,"devminor");if((o!==0||i!==0)&&!Gn(r))throw new k(`a ${r} cannot have device numbers (${O(n)})`);let s=Yn(e.mode??Hn[r]??420,"mode");if(s>4095)throw new k(`mode ${s.toString(8)} has bits beyond the permission bits`);return{...t,mode:s,uid:Yn(e.uid??0,"uid"),gid:Yn(e.gid??0,"gid"),mtime:Yn(e.mtime??0,"mtime",!0),uname:Pd(e.uname??"","uname"),gname:Pd(e.gname??"","gname"),devmajor:o,devminor:i}}function Bd(e,t=e.length){let n=new Uint8Array(Math.ceil(t/Se)*Se);return n.set(e),n}var jd=(e,t,n,r,o)=>Ca({gnu:o,name:jt(e,"header name").subarray(0,Te),prefix:$e,linkname:$e,uname:$e,gname:$e,typeflag:r,mode:420,uid:0,gid:0,size:t,mtime:n,devmajor:null,devminor:null}),zd=(e,t)=>[jd("././@LongLink",e.length+1,0,t,!0),Bd(e,e.length+1)];function b2(e,t){let n=Dd(t),r=e.name.lastIndexOf("/"),o=r===-1?`./PaxHeaders/${e.name}`:`${e.name.slice(0,r)}/PaxHeaders/${e.name.slice(r+1)}`;return[jd(o,n.length,Math.max(0,Math.min(e.mtime,Ia(12))),Xn.pax,!1),Bd(n)]}function k2(e,t){let{length:n}=e;if(n>Zn+Te+1)throw new k(`name ${O(t)} is longer than 256 bytes, which ustar cannot hold`);let r=n;r>Zn+1?r=Zn+1:e[r-1]===Ud&&r--;let o=r-1;for(;o>0&&e[o]!==Ud;)o--;let i=n-o-1;if(o===0||i>Te||i===0)throw new k(`name ${O(t)} cannot be split into ustar's prefix and name fields`);return{prefix:e.subarray(0,o),name:e.subarray(o+1)}}function v2(e,t){let n=t==="gnu",r=[],o=[],i=ii(e),s=jt(i,"entry name"),a=$e,u=jt(e.linkname,`link target of ${O(e.name)}`);if(u.length>Te){if(n)o.push(...zd(u,Xn.longlink));else if(t==="pax")r.push(["linkpath",e.linkname]);else throw new k(`link target of ${O(e.name)} is longer than 100 bytes, which ustar cannot hold`);u=u.subarray(0,Te)}t==="pax"&&(s.length>Te||!Fr(s))&&r.push(["path",i]),s.length>Te&&(n?o.push(...zd(s,Xn.longname)):t==="ustar"&&({prefix:a,name:s}=k2(s,e.name)),s.length>Te&&(s=s.subarray(0,Te)));let l=(h,m,g)=>{if(n||Ta(m,g))return m;if(t==="pax")return r.push([h,String(m)]),0;throw new k(`${h} ${m} of ${O(e.name)} does not fit the ustar format`)},c=(h,m)=>{let g=jt(m,h);if(g.length<pn&&(t!=="pax"||Fr(g)))return g;if(t!=="pax")throw new k(`${h} of ${O(e.name)} is longer than 31 bytes, which the ${t} format cannot hold`);return r.push([h,m]),g.subarray(0,pn-1)},f=Gn(e.type),d={gnu:n,name:s,prefix:a,linkname:u,typeflag:dn[e.type],mode:e.mode,uid:l("uid",e.uid,8),gid:l("gid",e.gid,8),size:l("size",e.data.length,12),mtime:l("mtime",e.mtime,12),devmajor:f?l("devmajor",e.devmajor,8):null,devminor:f?l("devminor",e.devminor,8):null,uname:c("uname",e.uname),gname:c("gname",e.gname)};r.length&&o.push(...b2(e,r)),o.push(Ca(d));let p=e.data.length%Se;return e.data.length&&o.push(e.data),p&&o.push(new Uint8Array(Se-p)),o}function E2({format:e="gnu",blocking:t=20}={},n=!1){if(!y2.has(e))throw new k(`format ${O(String(e))} is not gnu, ustar or pax`);if(!Number.isSafeInteger(t)||t<1)throw new k("blocking is not a positive integer");let r=new ft(n),o=0;return{add(i){let s=x2(i),a={...s,...qt(s.name,s.type,s.linkname)};r.add(a);let u=v2(a,e);for(let l of u)o+=l.length;return u},end(){let i=t*Se,s=(o+2*Se)%i;return[new Uint8Array(2*Se+(s?i-s:0))]}}}function Ra(e,t){let n=E2(t,!0),r=[];for(let o of e)r.push(...n.add(o));return ct([...r,...n.end()])}var Gd=e=>Object.entries(e).map(([t,n])=>[n,t]),$2=new Map([...Gd(dn),[0,"file"]]),S2=new Map(Gd(Xn)),A2=1<<20,N2=new Set(["SCHILY.realsize","SUN.holesdata"]);function Wd(e,t){for(let n of e)if(n.startsWith("GNU.sparse.")||N2.has(n))throw new k("sparse entries are not supported",t)}function O2(e,t,n){if(!/^(?:0|[1-9][0-9]*)$/u.test(e)||!Number.isSafeInteger(Number(e)))throw new k(`pax ${t}=${O(e)} is not a whole number this package can hold`,n);return Number(e)}function I2(e,t,n){let r=/^(-?)([0-9]+)(?:\.([0-9]+))?$/u.exec(e);if(!r)throw new k(`pax ${t}=${O(e)} is not a time`,n);let[,o,i,s=""]=r,a=Number(o+i)-(o&&/[1-9]/u.test(s)?1:0);if(!Number.isSafeInteger(a))throw new k(`pax ${t}=${O(e)} is out of range`,n);return a}var qd=()=>({pax:null,longname:null,longlink:null}),Hd=new Dr,Ma=class{#t=[];#s=0;#n=0;#e=0;#i;#r=qd();#o=null;#u=null;#a=0;#l=!1;constructor(t=!1){this.#i=new ft(t)}push(t){if(!(t instanceof Uint8Array))throw new k("a chunk is not a Uint8Array");if(this.#l)return this.#f(t,this.#e),this.#e+=t.length,[];t.length&&(this.#t.push(t),this.#n+=t.length);let n=[],r=!0;for(;r&&!this.#l;)r=this.#u===null?this.#d():this.#p(n);return n}end(){if(!this.#l)throw this.#e===0&&this.#n===0?new k("the archive is empty"):this.#u===null&&this.#n===0?new k(this.#a?"the archive ends with a lone zero block":"the archive has no end marker",this.#e):new k("the archive is truncated",this.#e)}#c(t){if(this.#n<t)return null;if(t===0)return $e;let n;if(this.#s+t<=this.#t[0].length)n=this.#t[0].subarray(this.#s,this.#s+t),this.#s+=t;else{n=new Uint8Array(t);let r=0;for(let o=0,i=this.#s;o<t;r++,i=0){let s=this.#t[r].subarray(i,i+t-o);n.set(s,o),o+=s.length,this.#s=i+s.length}this.#t=this.#t.slice(r-1)}return this.#s===this.#t[0].length&&(this.#t.shift(),this.#s=0),this.#n-=t,this.#e+=t,n}#f(t,n){if(!Mr(t))throw new k("data after the end of the archive",n)}#d(){let t=this.#c(Se);if(t===null)return!1;let n=this.#e-Se;if(Mr(t)){if(Object.values(this.#r).some(i=>i!==null))throw new k("an extended header is not followed by an entry",n);if(++this.#a===2){this.#l=!0;let i=this.#e;this.#f(this.#c(this.#n),i)}return!0}if(this.#a)throw new k("a lone zero block where a header should be",n);let r=Td(t,n),o=S2.get(r.typeflag);if(o===void 0)this.#u={extended:null,at:n,...this.#h(r,n)};else{if(r.size>A2)throw new k(`a ${o} header of ${r.size} bytes is longer than any tar writes`,n);this.#u={extended:o,size:r.size,at:n,entry:null}}return!0}#p(t){let{extended:n,size:r,at:o,entry:i}=this.#u,s=Math.ceil(r/Se)*Se,a=this.#c(s);if(a===null)return!1;if(!Mr(a.subarray(r)))throw new k("the padding after an entry is not zero",o);this.#u=null;let u=a.subarray(0,r);if(n===null)i.data=u,Wn(()=>this.#i.add(i),o),t.push(i);else if(n==="global"){this.#o=Fa(u,o);for(let l of["path","linkpath","size"])if(this.#o.has(l))throw new k(`a global header sets ${l}`,o);Wd(this.#o.keys(),o)}else{if(this.#r[n]!==null)throw new k(`two ${n} headers ahead of one entry`,o);this.#r[n]=n==="pax"?Fa(u,o):We(li(u),`a ${n} header`,o)}return!0}#h(t,n){let r=$2.get(t.typeflag);if(r===void 0)throw new k(`entry type ${O(String.fromCodePoint(t.typeflag))} is not one this package reads`,n);let{pax:o,longname:i,longlink:s}=this.#r;this.#r=qd();let a=g=>o?.get(g)??this.#o?.get(g);if(o!==null&&Wd(o.keys(),n),i!==null&&a("path")!==void 0)throw new k("both a long name header and a pax path name one entry",n);if(s!==null&&a("linkpath")!==void 0)throw new k("both a long link header and a pax linkpath name one entry",n);let u=i??a("path")??this.#m(t,n),l=s??a("linkpath")??We(t.linkname,"link target",n),{name:c,linkname:f}=Wn(()=>qt(u,r,l),n),d=(g,w=O2)=>{let y=a(g);return y===void 0?t[g]:w(y,g,n)},p=d("size");if(p!==0&&!Sa(r))throw new k(`a ${r} entry has a size`,n);if(f!==""&&r!=="hardlink"&&r!=="symlink")throw new k(`a ${r} entry has a link target`,n);let h=g=>{let w=a(g)??We(t[g],g,n);if(Bt(w,!1))throw new k(`${g} ${O(w)} holds a control or formatting character`,n);return w};return{entry:{name:c,type:r,mode:t.mode&4095,uid:d("uid"),gid:d("gid"),mtime:d("mtime",I2),uname:h("uname"),gname:h("gname"),linkname:f,devmajor:Gn(r)?d("devmajor"):0,devminor:Gn(r)?d("devminor"):0,data:$e,storedName:u,storedLinkname:l,pax:o??Hd,globalPax:this.#o??Hd},size:p}}#m(t,n){let r=We(t.name,"entry name",n);return t.prefix.length?`${We(t.prefix,"name prefix",n)}/${r}`:r}};function Da(e){let t=new Ma(!0),n=t.push(e);return t.end(),n}var Xd=new Map([[7,"a"],[8,"b"],[12,"f"],[10,"n"],[13,"r"],[9,"t"],[11,"v"]]),T2=e=>"\\"+e.toString(8).padStart(3,"0");function St(e,t){let n=ee(t),r=se(t.locale),o="";for(let i of e){let s=i.codePointAt(0);if(i==="\\")o+="\\\\";else if(Xd.has(s))o+="\\"+Xd.get(s);else if(s<128?s>=32&&s<127:!n&&r.has("print",s))o+=i;else for(let a of I(i))o+=T2(a)}return o}var C2={__proto__:null,file:"-","contiguous-file":"C",directory:"d",symlink:"l",hardlink:"h",fifo:"p","character-device":"c","block-device":"b"};function Zd(e,t){let n=[..."rwxrwxrwx"].map((o,i)=>(t&256>>i)===0?"-":o),r=(o,i,s)=>{(t&o)!==0&&(n[i]=n[i]==="x"?s:s.toUpperCase())};return r(2048,2,"s"),r(1024,5,"s"),r(512,8,"t"),C2[e]+n.join("")}var Yd=e=>I(e).length,_2=new Set(["character-device","block-device"]);function fi(e,{numericOwner:t=!1,utc:n=!1}={}){let r=19,o=16,i=n||e.vars.has("TZ"),s=a=>{let u=!t&&a.uname!==""?a.uname:String(a.uid),l=!t&&a.gname!==""?a.gname:String(a.gid),c=_2.has(a.type)?`${a.devmajor},${a.devminor}`:String(a.data.length),f=Yd(u)+1+Yd(l)+1+c.length;f>r&&(r=f);let d=F2(a.mtime,i);return d.length>o&&(o=d.length),`${Zd(a.type,a.mode)} ${u}/${l} ${" ".repeat(r-f)}${c} ${d.padEnd(o)} `+St($t(a),e)+L2(a,e)};return s.mkdir=a=>`${Zd("directory",448)} ${"Creating directory:".padStart(r+1+o)} ${St(a,e)}`,s}function L2(e,t){return e.type==="symlink"?` -> ${St(e.linkname,t)}`:e.type==="hardlink"?` link to ${St(e.linkname,t)}`:""}function F2(e,t){let n=new Date(e*1e3);if(Number.isNaN(n.getTime()))throw new x("feature","archive time",`a modification time of ${e} seconds is past what this terminal can print`);return Ht(n,"%Y-%m-%d %H:%M",t)}var de=(e,t)=>St(e,t).replaceAll(":","\\:");function Gt(e,t){let n=St(e,t);return ee(t)?`'${n.replaceAll("'","\\'")}'`:`\u2018${n}\u2019`}function Ua(e){let t=e.length;for(;t>1&&e[t-1]==="/";)t--;return e.slice(0,t)}function R2(e){for(let t=0;t<e.length;t++)if(e[t]==="\\")t++;else if("?*[]".includes(e[t]))return!0;return!1}var M2=(e,t)=>t===e||t.startsWith(e)&&t[e.length]==="/";function Vd(e){let t=[],n=[];for(let o of e)o.dir!==void 0?n.push(o.dir):o.name!==""&&t.push({given:o.name,operand:Ua(o.name),dirs:[...n],found:!1});let r={dirs:n};return{names:t,match(o){if(t.length===0)return r;let i=t.find(s=>M2(s.operand,o));return i!==void 0&&(i.found=!0),i??null}}}function Kd(e,t,n){for(let r of e.names)r.found||(!n&&R2(r.operand)&&(t.warn("Pattern matching characters used in file names"),t.warn("Use --wildcards to enable pattern matching, or --no-wildcards to suppress this warning")),t.error(`${de(r.operand,t.ctx)}: Not found in archive`))}function di(e,t,n){let{ctx:r}=n,o=E(e,t,r.fs),i=o.error??(r.fs.isDir(o.path)?null:"Not a directory");return i===null?o.path:(n.fatal(`${de(t,r)}: Cannot open: ${i}`),null)}async function Ur(e,t){try{return{bytes:await $a(e,t),error:null}}catch(n){if(!(n instanceof qn))throw n;return{bytes:n.bytes,error:n.cause?.cause?.message??n.cause?.message??"corrupt input"}}}var D2=10,U2=8,P2=8,z2=16,B2=4,j2=2,W2=8,Jd="gzip",Qd="deflate-raw",q2=(e,t)=>e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216;function H2(e,t){if(e[t]!==31||e[t+1]!==139||e[t+2]!==P2)return-1;let n=e[t+3],r=t+D2;if((n&B2)!==0){if(r+2>e.length)return-1;r+=2+e[r]+e[r+1]*256}for(let o of[W2,z2])if((n&o)!==0){for(;r<e.length&&e[r]!==0;)r++;r++}return(n&j2)!==0&&(r+=2),r<=e.length?r-t:-1}var G2=64;async function X2(e,t){let n=H2(e,t);if(n<0)return null;let o=(await Ur(e.subarray(t+n),Qd)).bytes.length%4294967296,i=G2;for(let s=t+n+U2;s<=e.length&&i>0;s++){if(q2(e,s-4)!==o)continue;i--;let a=await Ur(e.subarray(t,s),Jd);if(a.error===null)return{bytes:a.bytes,end:s}}return null}async function pi(e){let t=await Ur(e,Jd);if(t.error===null||!Re(Qd))return{...t,rest:null};let n=[],r=0;for(;;){let o=await X2(e,r);if(o===null)break;n.push(o.bytes),r=o.end}return r===0||r===e.length?{...t,rest:null}:{bytes:Ze(n),error:t.error,rest:e.subarray(r)}}function N(e,t={}){let n=Pr(t.short),r=Pr(t.long),o=Pr(t.valueShort),i=Pr(t.valueLong),s=Pr(t.repeatable),a=new Set,u=new Map,l=[],c=[],f=0;function d(p,h,m=!1){let g=(m?"--":"-")+p,w=(m?i:o).has(p)||s.has(p)&&(!m||p.length>1);if(w){let y=h??e[++f];if(h===null&&f>=e.length)throw new Error(g+" requires an argument");if(s.has(p)){let $=u.get(p);$?$.push(y):u.set(p,[y])}else u.set(p,y);c.push({name:p,value:y})}else{if(!(m?r:n).has(p))throw new x("option",g,"unknown option: "+g);if(m&&h!==null)throw new Error("option "+g+" doesn't allow an argument");a.add(p),c.push({name:p})}return w}for(;f<e.length;f++){let p=e[f];if(p==="--"){l.push(...e.slice(f+1));break}if(p.startsWith("--")&&p.length>2){let h=p.indexOf("=");d(h===-1?p.slice(2):p.slice(2,h),h===-1?null:p.slice(h+1),!0);continue}if(p.startsWith("-")&&p.length>1&&!(t.numericOperands&&Z2(p,n,o,s))){for(let h=1;h<p.length&&!d(p[h],h+1<p.length?p.slice(h+1):null);h++);continue}if(t.stopAtFirstPositional){l.push(...e.slice(f));break}l.push(p)}return{flags:a,values:u,positional:l,order:c}}function Z2(e,t,n,r){if(!/^-\d/u.test(e))return!1;let o=e[1];return!t.has(o)&&!n.has(o)&&!r.has(o)}function Pr(e){return e instanceof Set?e:new Set(e??[])}var Pa="gzip",Y2=(e,t,n)=>Ba(e,["-d",...t],n),ep=(e,t,n)=>Ba(e,["-d","-c",...t],n),ap=Re(Pa)?{gzip:Ba,gunzip:Y2,zcat:ep,gzcat:ep}:{},tp=Object.freeze([31,139]),jr=e=>e!==void 0&&e.length>=2&&e[0]===tp[0]&&e[1]===tp[1],V2=Object.freeze([[31,158],[31,30],[31,157],[31,160]]),K2=Object.freeze([80,75,3,4]),np=(e,t)=>e.length>=t.length&&t.every((n,r)=>e[r]===n),rp=(e,t)=>V2.some(n=>np(e,n))||t&&np(e,K2);function op(e,t){return t.gap??=v("feature","gzip","other formats",`gzip: ${e}: data compressed other than by gzip is not supported`,1),!1}var J2={__proto__:null,"unexpected end of file":"unexpected end of file","incorrect data check":"invalid compressed data--crc error"},ip=e=>J2[e]??"invalid compressed data--format violated",Q2=8;function za(e,t){let n=t.rest,r=o=>({text:`
35
+ gzip: ${e}: ${o}
36
+ `,status:1,whole:!1});return n===null?r(ip(t.error)):n.every(o=>o===0)?null:n.length>=2&&!jr(n)?{text:`
37
+ gzip: ${e}: decompression OK, trailing garbage ignored
38
+ `,status:2,whole:!0}:n.length>2&&n[2]!==Q2?{text:`gzip: ${e}: unknown method ${n[2]} -- not supported
39
+ `,status:1,whole:!0}:r(ip(t.error))}function ek(e,t,n){let r=za(t,n);return r===null||(e.stderr+=r.text,e.status=e.status===1?1:r.status),!1}var up=Object.freeze({__proto__:null,".gz":"",".tgz":".tar",".taz":".tar","-gz":"",".z":"","-z":"",_z:""}),tk=".gz",sp=Object.freeze(["1","2","3","4","5","6","7","8","9"]);async function Ba(e,t,n){let{flags:r,positional:o}=N(t,{short:[...sp,"d","c","k","f"],long:["decompress","uncompress","stdout","to-stdout","keep","force"]}),i=sp.find(l=>r.has(l));if(i!==void 0)return v("option","gzip",`-${i}`,`gzip: -${i}: choosing a compression level is not supported`,1);let s={decompressing:["d","decompress","uncompress"].some(l=>r.has(l)),stdout:["c","stdout","to-stdout"].some(l=>r.has(l)),keep:r.has("k")||r.has("keep"),force:r.has("f")||r.has("force")},a={ctx:n,events:[],stderr:"",status:0,gap:null,stopped:!1};if(o.length===0)await lp(s,a);else for(let l of o)if(await nk(l,s,a),a.stopped)break;if(a.gap)return a.gap;let u=[...a.events,...a.stderr?[{fd:2,text:a.stderr}]:[]];return{stdout:"",stderr:a.stderr,exitCode:a.status,events:u}}async function lp(e,t){if(!e.force&&(e.decompressing?sn(t.ctx):xt(t.ctx))){let[o,i]=e.decompressing?["read from","decompression"]:["written to","compression"];t.stderr+=`gzip: compressed data not ${o} a terminal. Use -f to force ${i}.
40
+ For help, type: gzip -h
41
+ `,t.status=1,t.stopped=!0;return}let n=t.ctx.stdinLeft,r=t.ctx.stdinBytes;return z(t.ctx,"",!0),e.decompressing?cp("stdin",r??I(n),{...e,stdout:!0},t):Br(await je(r??I(n),Pa),t)}function nk(e,t,n){let{ctx:r}=n;if(e==="-")return lp(t,n);if(!t.stdout&&!t.force&&rk(e,r))return At(n,`${e}: Too many levels of symbolic links`,1);let o=D(r,"gzip",e);return o.error?At(n,`${e}: ${o.error}`,1):r.fs.isDir(o.path)?At(n,`${e} is a directory -- ignored`,2):t.decompressing?uk(e,o.path,t,n):ok(e,o.path,t,n)}function rk(e,t){let n=E(t.cwd,e,t.fs,{follow:!1});return n.path!==null&&t.fs.isLink?.(n.path)===!0}async function ok(e,t,n,r){let{ctx:o}=r,i=ja(e);if(!n.stdout&&!n.force&&i!==void 0)return fk(r,`${e} already has ${i} suffix -- unchanged`);let s=ak(await je(fe(o.fs,t),Pa),e.slice(e.lastIndexOf("/")+1),ik(o));return n.stdout?Br(s,r):fp(e+tk,s,e,n,r)}var ik=e=>Math.floor(e.createdAt/1e3),zr=10,sk=8;function ak(e,t,n){let r=I(t);if(e.length<zr||e[3]!==0||r.includes(0))return e;let o=new Uint8Array(e.length+r.length+1);o.set(e.subarray(0,zr)),o[3]=sk;for(let i=0;i<4;i++)o[4+i]=n>>>8*i&255;return o.set(r,zr),o.set(e.subarray(zr),zr+r.length+1),o}function uk(e,t,n,r){let{ctx:o}=r;return!n.stdout&&ja(e)===void 0?At(r,`${e}: unknown suffix -- ignored`,2):cp(e,fe(o.fs,t),n,r,t)}async function cp(e,t,n,r,o=null){let{ctx:i}=r,s=n.force&&n.stdout;if(t!==void 0&&rp(t,!0))return op(e,r);if(!jr(t))return s?Br(t,r):ck(r,`${e}: ${lk(t,o,i)?"unexpected end of file":"not in gzip format"}`);let a=await pi(t),u=a.rest,l=u!==null&&u.length>0&&!jr(u)?u:null;if(l!==null&&rp(l,!1))return op(e,r);let c=ja(e);if(n.stdout?Br(a.bytes,r):fp(e.slice(0,-c.length)+up[c],a.bytes,e,n,r)){if(l!==null&&s)return Br(l,r);a.error&&ek(r,e,a)}}var ja=e=>Object.keys(up).find(t=>e.length>t.length&&e.endsWith(t));function lk(e,t,n){let r=e??T(n.fs.readFile(t).slice(0,2));return r.length===0||r.length===1&&r[0]!==0}var Br=(e,t)=>(t.events.push({fd:1,bytes:e}),!0);function fp(e,t,n,r,o){let{ctx:i}=o,s=E(i.cwd,e,i.fs,{follow:!1}).path;if(s!==null&&!r.force)return At(o,`${e} already exists;${sn(i)?" do you wish to overwrite (y or n)? ":""} not overwritten`,2);if(s!==null&&i.fs.isLink?.(s)!==!0&&i.fs.isDir(s))return At(o,`${e}: Is a directory`,1);s!==null&&i.fs.removeWritable(i.cwd,e);let a;try{a=i.writable&&i.fs.openWritable?.(i.cwd,e)}catch(u){return At(o,`${e}: ${u.message}`,1)}return a?(a.writeBytes(t),r.keep||i.fs.removeWritable(i.cwd,n),!0):(o.gap??=v("feature","gzip","read-only target",`gzip: ${e}: file system is read-only`,1),!1)}var ck=(e,t)=>At(e,t,1,`
42
+ `),fk=(e,t)=>At(e,t,e.status);function At(e,t,n,r=""){return e.stderr+=`${r}gzip: ${t}
43
+ `,e.status=e.status===1?1:n,!1}var dk=new Set(["atime","charset","comment","ctime","gid","gname","linkpath","mtime","path","size","uid","uname","RHT.security.selinux","SCHILY.acl.access","SCHILY.acl.default"]),pk=e=>dk.has(e)||e.startsWith("SCHILY.xattr."),hk=e=>e==="GNU.dumpdir"||e.startsWith("GNU.volume."),mk=-(2n**63n),gk=2n**63n-1n;function wk(e){let t=/^(-?[0-9]+)(?:\.([0-9]*))?$/u.exec(e);if(t===null)return!1;let n=BigInt(t[1])-(t[1].startsWith("-")&&/[1-9]/u.test(t[2]??"")?1n:0n);return n>=mk&&n<=gk}function dp(e,t){for(let[n,r]of e){if(hk(n))return["extended header",`${t(n)}: records of multi-volume and incremental archives are not supported`];if((n==="atime"||n==="ctime")&&!wk(r))return["extended header",`${t(`${n}=${r}`)}: extended header times GNU would reject are not supported`]}return null}function pp(e,t){let n=[],r=[],o=null;for(let i of e){let s=(i.globalPax===o?null:dp(i.globalPax,t))??dp(i.pax,t);if(s!==null)return{gap:s};o=i.globalPax;let a=ri(i);if(a!==null){let[l,c]=ni(a);return{gap:[l,`${t(a)}: ${c}`]}}n.push([...i.pax.keys()].filter(l=>!pk(l)).map(l=>`Ignoring unknown extended header keyword '${l}'`));let u=i.pax.get("mtime")??i.globalPax.get("mtime");r.push(u===void 0?i.mtime:Number(u))}return{warnings:n,mtimes:r}}var qa=512,yk=10,Ha=e=>({entries:[],child:e,warnings:[],mtimes:[]}),xk=[{bytes:[31,157],option:"-Z"},{bytes:[31,139],option:"-z"},{bytes:[66,90,104],option:"-j"},{bytes:[76,90,73,80],option:"--lzip"},{bytes:[255,76,90,77,65,0],option:"--lzma"},{bytes:[93,0,0],option:"--lzma"},{bytes:[137,76,90,79],option:"--lzop"},{bytes:[253,55,122,88,90,0],option:"-J"},{bytes:[40,181,47,253],option:"--zstd"}],bk=e=>xk.find(({bytes:t})=>t.length<=e.length&&t.every((n,r)=>e[r]===n)),kk={__proto__:null,gz:"-z",tgz:"-z",taz:"-z",Z:"-Z",taZ:"-Z",bz2:"-j",tbz:"-j",tbz2:"-j",tz2:"-j",lz:"--lzip",lzma:"--lzma",tlz:"--lzma",lzo:"--lzop",xz:"-J",txz:"-J",zst:"--zstd",tzst:"--zstd"};function Ga(e){let t=e.lastIndexOf(".");return t===-1?void 0:kk[e.slice(t+1)]}function hi(e,t){return e.refuse("option",t,`${t}: archives compressed other than with gzip are not supported`),null}var Xa=e=>{let t=e.indexOf(":");return t!==-1&&!e.slice(0,t).includes("/")};function vk(e,t){let{ctx:n}=t,r=e.archive;if(r==="-"){if(sn(n))return t.fatal("Refusing to read archive contents from terminal (missing -f option?)");let i=n.stdinBytes??I(n.stdinLeft);return z(n,"",!0),{bytes:i,name:r,stdin:!0}}if(Xa(r))return t.refuse("feature","remote archive",`${r}: remote archives are not supported`);if(r==="/dev/null")return{bytes:new Uint8Array,name:r,stdin:!1};if(r.startsWith("/dev/"))return t.refuse("feature","special file",`${r}: reading an archive from a device is not supported`);let o=D(n,"tar",r);return o.error?t.fatal(`${de(r,n)}: Cannot open: ${o.error}`):n.fs.isDir(o.path)?(t.warn(`${de(r,n)}: Cannot read: Is a directory`),t.fatal("At beginning of tape, quitting now")):{bytes:fe(n.fs,o.path),name:r,stdin:!1}}function hp(e,t){let n=vk(e,t);if(!n)return null;let r=n.bytes;if(e.gzip)return Wa(r,t);let o=r.length>=qa?mp(r):null;if(o?.entries!==void 0)return wp(o.entries,t,0);let i=bk(r);if(i!==void 0)return n.stdin?t.fatal(`Archive is compressed. Use ${i.option} option`):i.option==="-z"?Wa(r,t):hi(t,i.option);let s=r.length<qa;s&&t.error("This does not look like a tar archive");let a=n.stdin?void 0:Ga(n.name);return a!==void 0&&a!=="-z"?hi(t,a):s?a===void 0?Ha(0):Wa(r,t):gp(o.error,t)}async function Wa(e,t){if(!Re("gzip"))return t.refuse("option","-z","this runtime has no gzip stream");if(!jr(e))return t.say(2,`
44
+ gzip: stdin: ${e.length<2?"unexpected end of file":"not in gzip format"}
45
+ `),Ha(1);let n=await pi(e),r=n.error===null?null:za("stdin",n);if(r!==null&&!r.whole&&e.length>yk)return t.refuse("feature","damaged gzip stream","the gzip stream is damaged, and how much of it GNU gzip would inflate is not known here"),null;r!==null&&t.say(2,r.text);let o=r?.status??0;if(n.bytes.length<qa)return Ha(o);let i=mp(n.bytes);return i.entries===void 0?gp(i.error,t):wp(i.entries,t,o)}function mp(e){try{return{entries:Da(e)}}catch(t){if(!(t instanceof k))throw t;return{error:t}}}function gp(e,t){return t.refuse("feature","archive",`this archive is not one this terminal reads: ${e.message}`),null}function wp(e,t,n){let r=pp(e,o=>de(o,t.ctx));return r.gap===void 0?{entries:e,child:n,...r}:(t.refuse("feature",...r.gap),null)}var yp=512,xp={file:384,directory:448,symlink:511};async function kp(e,t){let{ctx:n}=t;if(e.archive==="-"&&xt(n))return t.fatal("Refusing to write archive contents to terminal (missing -f option?)");if(e.format==="pax")return t.refuse("option","--format=pax","the pax format records access and change times, which this tree does not have");let r=Ek(e,t),o=r&&$k(e,t);if(o===null||!r)return;if(o&&!Re("gzip"))return t.refuse("option","-z","this runtime has no gzip stream");let i=Sk(e.archive,t);if(!i)return;if(o&&i.kind==="stdout"&&t.closedOut)return t.refuse("feature","closed stdout","writing a compressed archive to a closed stdout is not supported");(i.kind==="stdout"||e.toStdout)&&(t.listTo=2);let s={state:t,owners:r,target:i,entries:[],verbose:e.verbose,many:e.items.filter(l=>l.name!==void 0).length>1,mtime:Math.floor(n.createdAt/1e3),members:new Set,links:new Set,line:e.verbose>1?fi(n,e):null,archived:new Map},a=n.cwd,u=[];for(let l of e.items){if(l.dir!==void 0){u.push(l.dir);continue}for(let c of u)if(a=di(a,c,t),a===null)return bp(s,e,o,!0);if(u=[],Ak(l.name,a,s),t.stopped)return}if(u.length){t.warn("The following options were used after non-option arguments. These options are positional and affect only arguments that follow them. Please, rearrange them properly.");for(let l of u)t.error(`-C ${Gt(l,n)} has no effect`)}await bp(s,e,o,!1)}function Ek(e,t){let{owner:n,group:r,numericOwner:o}=e,i=s=>s!==void 0&&s.id!==null&&(s.name!==null||o);return!i(n)||!i(r)?(t.refuse("feature","file owners","the files here have no numeric owner or group to record; give them with --owner=NAME:UID and --group=NAME:GID, or as ids with --numeric-owner"),null):{uid:n.id,gid:r.id,uname:o?"":n.name,gname:o?"":r.name}}function $k(e,t){if(e.gzip)return!0;let n=e.auto&&e.archive!=="-"?Ga(e.archive):void 0;return n===void 0?!1:n==="-z"?!0:hi(t,n)}function Sk(e,t){let{ctx:n}=t;if(e==="-")return{kind:"stdout"};if(e==="/dev/null")return{kind:"null"};if(Xa(e))return t.refuse("feature","remote archive",`${e}: remote archives are not supported`);if(e.startsWith("/dev/"))return t.refuse("feature","special file",`${e}: writing an archive to a device is not supported`);let r=de(e,n),o=j(n.cwd,e),i=E(n.cwd,e,n.fs);if(i.path!==null&&n.fs.isDir(i.path))return t.fatal(`${r}: Cannot open: Is a directory`);let s=E(n.cwd,oe(o),n.fs);if(i.path===null&&(s.error||!n.fs.isDir(s.path)))return t.fatal(`${r}: Cannot open: ${s.error??"Not a directory"}`);let a=n.writable&&J(i.path??o)?n.fs.openWritable(n.cwd,e):null;return a?{kind:"file",handle:a,path:a.path}:t.refuse("feature","read-only target",`${r}: Cannot open: Read-only file system`)}function vp(e,t){let n=0;for(let o=0;o<e.length;){e.startsWith("..",o)&&(o+2===e.length||e[o+2]==="/")&&(n=o+2);let i=e.indexOf("/",o);o=i===-1?e.length:i+1}for(;e[n]==="/";)n++;let r=e.slice(0,n);return e===""?t.state.warn("Substituting `.' for empty member name"):r!==""&&!t.members.has(r)&&(t.members.add(r),t.state.warn(`Removing leading \`${r}' from member names`)),{prefix:r,name:n===e.length?".":e.slice(n)}}function Ak(e,t,n){let{ctx:r}=n.state,o=Ua(e);if(o==="/dev"||o.startsWith("/dev/")){n.state.refuse("feature","special file",`${de(o,r)}: archiving special files is not supported`);return}let i=vp(o,n),s=E(t,o,r.fs,{follow:!1});s.error?n.state.error(`${de(o,r)}: Cannot stat: ${s.error}`):Ep(s.path,o,i,n)}function Ep(e,t,n,r){let{state:o}=r,{fs:i}=o.ctx,s=i.isDir(e),a=!s&&i.isLink?.(e)===!0;if(r.target.kind==="file"&&r.target.path===e)return o.warn(`${de(t,o.ctx)}: archive cannot contain itself; not dumped`);if(n.name!=="."&&n.name.split("/").some(h=>h==="."||h===""))return o.refuse("feature","dot-segment names",`${de(t,o.ctx)}: member names with \`.' or empty segments are not supported`);let u=s?"directory":a?"symlink":"file",l=r.many&&!s?r.archived.get(e):void 0;if(l===n.name)return o.refuse("feature","repeated name",`${de(t,o.ctx)}: storing a name again, as a hard link to itself, is not supported`);r.many&&!s&&l===void 0&&r.archived.set(e,n.name);let c=l===void 0?{name:n.name,type:u,mode:xp[u],mtime:r.mtime,...r.owners,linkname:a?i.readLink(e):"",data:u==="file"?fe(i,e):void 0}:{name:n.name,type:"hardlink",mode:xp[u],mtime:r.mtime,...r.owners,linkname:l};if(r.entries.push(c),r.verbose&&o.list(r.line?r.line({...c,name:t,data:c.data??new Uint8Array}):s?`${t}/`:t),r.many&&!s&&l===void 0&&n.prefix!==""&&!r.links.has(n.prefix)&&(r.links.add(n.prefix),o.warn(`Removing leading \`${n.prefix}' from hard link targets`)),!s)return;let{dirs:f,files:d,links:p=[]}=i.listDir(e);for(let h of[...new Set([...f,...d,...p])].sort(q)){let m=t==="/"?`/${h}`:`${t}/${h}`;if(Ep(he(e,h),m,vp(m,r),r),o.stopped)return}}async function bp(e,t,n,r){let{state:o,target:i}=e,s;try{s=Ra(e.entries,{format:t.format,blocking:r?1:t.blocking})}catch(a){if(!(a instanceof k))throw a;return o.refuse("feature","archive",`this archive cannot be written here: ${a.message}`)}if(r){let a=t.blocking*yp;s=s.subarray(0,Math.floor((s.length-2*yp)/a)*a)}n&&(s=await je(s,"gzip")),i.kind==="stdout"&&!o.closedOut?o.bytes(s):i.kind==="file"&&i.handle.writeBytes(s)}var Nk=new Set(["file","contiguous-file","directory","symlink"]);function $p(e,t){let n=e.split("/").filter(r=>r!=="");return n.length<=t?null:n.slice(t).join("/")}var Sp=(e,t)=>j(e,t);function Ap(e,t,n,r,o,i=()=>{}){let{ctx:s}=r,a=de(t,s);if(!Nk.has(e.type)){let h=e.type==="hardlink"?"hard links":"special files";return r.refuse("feature",e.type,`${a}: extracting ${h} is not supported`)}let u=e.type==="directory"?"mkdir":"open",l=()=>r.refuse("feature","read-only target",`${a}: Cannot ${u}: Read-only file system`);if(!s.writable||!J(n))return l();let c=Ok(oe(n),r);if(c==="read-only")return l();if(typeof c=="string")return r.error(`${a}: Cannot ${u}: ${c}`);if(c>0&&i(c),e.type==="directory")return Ik(n,a,r);let f=e.type==="symlink"?`Cannot create symlink to ${Gt(e.linkname,s)}`:"Cannot open";if(E("/",n,s.fs,{follow:!1}).path!==null&&(o||!Np(n,s.fs)))return r.error(`${a}: ${f}: File exists`);if(e.type==="symlink")return s.fs.makeWritableLink("/",n,e.linkname)||l();let p=s.fs.openWritable("/",n);return p?(p.writeBytes(e.data),!0):l()}function Ok(e,t){let{fs:n}=t.ctx,r=[];for(let o=e;;o=oe(o)){let i=E("/",o,n);if(i.path!==null){if(!n.isDir(i.path))return"Not a directory";break}if(E("/",o,n,{follow:!1}).path!==null)return"File exists";r.push(o)}for(let o of r.toReversed())if(!J(o)||!n.makeWritableDir("/",o))return"read-only";return r.length}function Ik(e,t,n){let{fs:r}=n.ctx,o=E("/",e,r,{follow:!1});return o.path!==null&&r.isDir(o.path)&&!r.isLink?.(o.path)?!0:o.path!==null&&!Np(e,r)?n.error(`${t}: Cannot mkdir: File exists`):(r.makeWritableDir("/",e),!0)}function Np(e,t){let n=E("/",e,t,{follow:!1});if(t.isDir(n.path)&&!t.isLink?.(n.path)){let{dirs:r,files:o,links:i}=t.listDir(n.path);return r.length||o.length||i.length?!1:(t.removeWritableDir("/",e),!0)}return t.removeWritable("/",e),!0}var Tk=new Set(["create","list","extract"]),_p={__proto__:null,c:"create",t:"list",x:"extract",f:"file",v:"verbose",z:"gzip",C:"directory",O:"to-stdout",a:"auto-compress",H:"format",b:"blocking-factor",k:"keep-old-files"},Ck={__proto__:null,create:"create",list:"list",extract:"extract",get:"extract",file:"file",verbose:"verbose",gzip:"gzip",gunzip:"gzip",ungzip:"gzip",directory:"directory","to-stdout":"to-stdout","auto-compress":"auto-compress",format:"format","blocking-factor":"blocking-factor","keep-old-files":"keep-old-files","strip-components":"strip-components",owner:"owner",group:"group","numeric-owner":"numeric-owner",utc:"utc","no-wildcards":"no-wildcards",sort:"sort"},Za=new Set(["file","directory","format","blocking-factor","strip-components","owner","group","sort"]),_k="Try 'tar --help' or 'tar --usage' for more information.",Ke=(e,t=2)=>({usage:{text:`tar: ${e}
46
+ ${_k}
47
+ `,status:t}});function Lk(e){if(e.length===0||e[0].startsWith("-"))return{words:e};let t=e.slice(1),n=[],r=0;for(let o of e[0])if(n.push("-"+o),!!Za.has(_p[o])){if(r>=t.length)return Ke(`Old option '${o}' requires an argument.`);n.push(t[r++])}return{words:[...n,...t.slice(r)],old:!0}}function Lp(e,t){let n=Lk(e);if(n.usage)return n;let{words:r}=n,o={mode:null,items:[],verbose:0,values:new Map,flags:new Set,files:0};for(let i=0;i<r.length;i++){let s=r[i];if(s==="--"){for(let u of r.slice(i+1))o.items.push({name:u});break}let a=null;if(s.startsWith("--")){let u=s.indexOf("="),l=u===-1?s.slice(2):s.slice(2,u),c=Ck[l];if(c===void 0)throw new x("option",`--${l}`,`unknown option: --${l}`);Za.has(c)?u!==-1?a=Vn(o,c,s.slice(u+1),t):i+1<r.length?a=Vn(o,c,r[++i],t):a=Ke(`option '--${l}' requires an argument`,64):a=u===-1?Vn(o,c,void 0,t):Ke(`option '--${l}' doesn't allow an argument`,64)}else if(s.startsWith("-")&&s.length>1)for(let u=1;u<s.length&&a===null;u++){let l=s[u],c=_p[l];if(c===void 0)throw new x("option",`-${l}`,`unknown option: -${l}`);if(!Za.has(c)){a=Vn(o,c,void 0,t);continue}u+1<s.length?a=Vn(o,c,s.slice(u+1),t):i+1<r.length?a=Vn(o,c,r[++i],t):a=Ke(`option requires an argument -- '${l}'`,64);break}else o.items.push({name:s});if(a!==null)return a}return Mk(o)}function Vn(e,t,n,r){if(Tk.has(t)){if(e.mode!==null&&e.mode!==t)return Ke("You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option");e.mode=t,t==="list"&&e.verbose++}else if(t==="verbose")e.verbose++;else if(t==="directory")e.items.push({dir:n});else if(n===void 0)e.flags.add(t);else{let o=Fk[t]?.(n,r)??{value:n};if(o.gap)throw new x("option",o.gap.detail,o.gap.message);if(o.usage)return o;t==="file"&&e.files++,e.values.set(t,o.value)}return null}var Fk={__proto__:null,"strip-components":e=>{let t=Cp(e);return t===null||t<0?Ke(`${e}: Invalid number of elements`):{value:t}},"blocking-factor":e=>{let t=Cp(e);return t===null||t<1||t>2147483647?Ke(`${e}: Invalid blocking factor`):{value:t}},format:e=>{let t=Dk[e];return t===void 0?Ke(`${e}: Invalid archive format`):t===null?{gap:{detail:`--format=${e}`,message:`the ${e} archive format is not supported`}}:{value:t}},sort:(e,t)=>{let n=Uk(e,Ip);if(n.error){let r=Ip.map(o=>` - ${Gt(o,t)}
48
+ `).join("");return{usage:{text:`tar: ${n.error} argument ${Gt(e,t)} for ${Gt("--sort",t)}
49
+ Valid arguments are:
50
+ ${r}`,status:2}}}return n.value==="inode"?{gap:{detail:"--sort=inode",message:"--sort=inode is not supported"}}:n},owner:(e,t)=>Op(e,t),group:(e,t)=>Op(e,t)},Rk=4294967295;function Op(e,t){let n=e.indexOf(":"),r=n===-1?e:e.slice(n+1),o=n===-1?/^\d+$/u.exec(e):/^[ \t\n\v\f\r]*\+?(\d+)$/u.exec(r);if(n===-1&&o===null)return{value:{name:e,id:null}};let i=o===null?null:Number(BigInt(o.at(-1))>BigInt(Rk)?-1:o.at(-1));return i===null||i<0?{usage:{text:`tar: ${de(r,t)}: Invalid owner or group ID
51
+ tar: Error is not recoverable: exiting now
52
+ `,status:2}}:{value:{name:n>0?e.slice(0,n):null,id:i}}}function Mk(e){return e.mode===null?Ke("You must specify one of the '-Acdtrux', '--delete' or '--test-label' options"):e.files>1?Ke("Multiple archive files require '-M' option"):e.mode==="create"&&!e.items.some(t=>t.name!==void 0)?Ke("Cowardly refusing to create an empty archive"):{mode:e.mode,items:e.items,verbose:e.flags.has("utc")?Math.max(e.verbose,2):e.verbose,archive:e.values.get("file")??"-",gzip:e.flags.has("gzip"),auto:e.flags.has("auto-compress"),toStdout:e.flags.has("to-stdout"),keepOld:e.flags.has("keep-old-files"),numericOwner:e.flags.has("numeric-owner"),utc:e.flags.has("utc"),noWildcards:e.flags.has("no-wildcards"),owner:e.values.get("owner"),group:e.values.get("group"),strip:e.values.get("strip-components")??0,blocking:e.values.get("blocking-factor")??20,format:e.values.get("format")??"gnu"}}var Dk={__proto__:null,gnu:"gnu",ustar:"ustar",pax:"pax",posix:"pax",oldgnu:null,v7:null},Ip=["none","name","inode"];function Uk(e,t){if(t.includes(e))return{value:e};let n=t.filter(r=>r.startsWith(e));return n.length===1?{value:n[0]}:{error:n.length?"ambiguous":"invalid"}}var Tp=2n**63n-1n;function Cp(e){let t=/^[ \t\n\v\f\r]*([+-]?)(\d+)$/u.exec(e);if(!t)return null;let n=BigInt(t[1]+t[2]);return n>Tp||n<-Tp-1n?null:n<0n?-1:Number(n>BigInt(Number.MAX_SAFE_INTEGER)?Number.MAX_SAFE_INTEGER:n)}function Fp(e){let t={ctx:e,events:[],status:0,stopped:!1,gap:null,listTo:1,closedOut:e.closed?.out===!0,lostListing:null,say(n,r){t.events.push({fd:n,text:r})},list(n,r=!0){t.listTo===1&&t.closedOut?t.lostListing=r?"flushed":"pending":t.say(t.listTo,n+`
53
+ `)},bytes(n){t.events.push({fd:1,bytes:n})},warn(n){t.say(2,`tar: ${n}
54
+ `)},error(n){t.warn(n),t.status=2},fatal(n){t.warn(n),t.warn("Error is not recoverable: exiting now"),t.status=2,t.stopped=!0},refuse(n,r,o){t.warn(o),t.gap={kind:n,detail:r,message:`tar: ${o}`},t.status=2,t.stopped=!0}};return t}function Rp(e){!e.stopped&&e.status===2&&e.warn("Exiting with failure status due to previous errors"),!e.stopped&&e.lostListing!==null&&(e.warn(e.lostListing==="pending"?"stdout: write error: Bad file descriptor":"stdout: write error"),e.status=2);let t=r=>e.events.filter(o=>o.fd===r&&o.text!==void 0).map(o=>o.text).join(""),n={stdout:t(1),stderr:t(2),exitCode:e.status,events:e.events};return e.gap===null?n:X(n,e.gap.kind,"tar",e.gap.detail,e.gap.message)}var Pk=32768;async function Mp(e,t,n){let r=Lp(t,n);if(r.usage)return{stdout:"",stderr:r.usage.text,exitCode:r.usage.status};let o=Fp(n);return r.blocking>Pk?o.refuse("option","--blocking-factor",`${r.blocking}: a record of that many blocks is more than this terminal holds`):r.mode==="create"?await kp(r,o):await zk(r,o),Rp(o)}async function zk(e,t){let{ctx:n}=t,r=Date.now(),o=await hp(e,t);if(!o)return;let i=Vd(e.items),s=e.mode==="extract";e.toStdout&&(t.listTo=2);let a=e.verbose>1?fi(n,e):null,u=new Map;for(let[l,c]of o.entries.entries()){for(let m of o.warnings[l])t.warn(m);let f=$t(c),d=i.match(f);if(d===null)continue;let p=qk(d,u,t);if(p===null)return;let h=s?$p(f,e.strip):f;if(h!==null&&(e.verbose>0&&t.list(a?a(c):St(f,n)),s&&e.toStdout?(c.type==="file"||c.type==="contiguous-file")&&Bk(c.data,h,t):s&&Ap(c,h,Sp(p,h),t,e.keepOld,m=>jk(h,m,a,t))&&Wk(o.mtimes[l],h,r,t),t.stopped))return}if(o.child)return t.fatal(`Child returned status ${o.child}`);Kd(i,t,e.noWildcards)}function Bk(e,t,n){n.closedOut?e.length>0&&n.error(`${de(t,n.ctx)}: Cannot write: Bad file descriptor`):n.bytes(e)}function jk(e,t,n,r){if(!n)return;let o=e.split("/").slice(0,-1);for(let i=o.length-t;i<o.length;i++)r.list(n.mkdir(o.slice(0,i+1).join("/")),!1)}function Wk(e,t,n,r){e>=0&&e*1e3<=n||r.refuse("feature","archive times",`${de(t,r.ctx)}: extracting an entry dated before 1970 or in the future is not supported`)}function qk(e,t,n){if(t.has(e))return t.get(e);let r=n.ctx.cwd;for(let o of e.dirs)if(r=di(r,o,n),r===null)return null;return t.set(e,r),r}var mi=67324752,gi=33639248,wi=101010256,Dp=61440,Xt={file:32768,directory:16384,symlink:40960},yi=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function Wr(e){let t=new Uint8Array(e.reduce((o,[i])=>o+i,0)),n=yi(t),r=0;for(let[o,i]of e){if(!Number.isInteger(i)||i<0||i>=2**(8*o))throw new RangeError(`${i} does not fit ${o} bytes`);o===1?n.setUint8(r,i):o===2?n.setUint16(r,i,!0):n.setUint32(r,i,!0),r+=o}return t}var Up=e=>je(e,"deflate-raw"),Hk=1032;async function Pp(e,t,n){if(t>e.length*Hk)throw new k("an entry declares more than its data can inflate to",n);let r;try{r=await gd(e,"deflate-raw",new Uint8Array(t))}catch(o){throw new k(o.limited?"an entry inflates to more than its declared size":"an entry does not inflate",n)}if(r.length!==t)throw new k("an entry inflates to less than its declared size",n);return r}function zp(e){let t=new Date(e*1e3),n=t.getUTCFullYear();return n<1980||n>2107?null:{time:t.getUTCHours()<<11|t.getUTCMinutes()<<5|t.getUTCSeconds()>>1,date:n-1980<<9|t.getUTCMonth()+1<<5|t.getUTCDate()}}function Bp(e){let t=zp(e);if(t===null)throw new k(`mtime ${e} is outside DOS time, 1980 to 2107`);return t}function jp(e,t,n){let r=Date.UTC(1980+(e>>9),(e>>5&15)-1,e&31,t>>11,t>>5&63,(t&31)*2)/1e3,o=zp(r);if(o===null||o.time!==t||o.date!==e)throw new k("an entry has an invalid DOS time",n);return r}var Gk=new Set(["deflate","store"]),Xk=788,Zk=2048,Wp=315532800,Yk=2147483647,qp=65534,Ya=4294967294;function Hp(e,t,n,r){if(!Number.isSafeInteger(e)||e<n||e>r)throw new k(`${t} ${String(e)} is not an integer from ${n} to ${r}`);return e}function Vk(e){let t=si(e,Xt);return{...t,mode:Hp(e.mode??Hn[t.type],"mode",0,4095),mtime:Hp(e.mtime??Wp,"mtime",Wp,Yk)}}var Kk=e=>Wr([[2,21589],[2,5],[1,1],[4,e]]);async function Va(e,{method:t="deflate"}={}){if(!Gk.has(t))throw new k(`method ${O(String(t))} is not deflate or store`);let n=new ft(!0),r=[],o=[],i=0,s=0;for(let l of e){let c=Vk(l),f={...c,...qt(c.name,c.type,c.linkname)};if(n.add(f),++s>qp)throw new k(`more than ${qp} entries would need zip64`);let d=jt(ii(f),"entry name"),p=f.type==="symlink"?jt(f.linkname,"symlink target"):f.data;if(p.length>Ya||i>Ya)throw new k(`${O(f.name)} would need zip64`);let h=p,m=0;if(t==="deflate"&&f.type==="file"&&p.length){let _=await Up(p);_.length<p.length&&(h=_,m=8)}let{time:g,date:w}=Bp(f.mtime),y=Kk(f.mtime),$=[[2,m===8?20:10],[2,Fr(d)?0:Zk],[2,m],[2,g],[2,w],[4,_o(p)],[4,h.length],[4,p.length],[2,d.length],[2,y.length]];r.push(Wr([[4,mi],...$]),d,y,h);let S=(Xt[f.type]|f.mode)*65536+(f.type==="directory"?16:0);o.push(Wr([[4,gi],[2,Xk],...$,[2,0],[2,0],[2,0],[4,S],[4,i]]),d,y),i+=30+d.length+y.length+h.length}let a=ct(o);if(i+a.length>Ya)throw new k("the archive would need zip64");let u=Wr([[4,wi],[2,0],[2,0],[2,s],[2,s],[4,a.length],[4,i],[2,0]]);return ct([...r,a,u])}var Jk=134695760,Qk=117853008,ev=1,tv=21589,nv=28789,rv=1,ov=8,iv=16;function Ka(e,t=0){let n=yi(e),r=(o,i)=>{if(o<t||o+i>t+e.length)throw new k("the archive is truncated",o)};return{u16:o=>(r(o,2),n.getUint16(o-t,!0)),u32:o=>(r(o,4),n.getUint32(o-t,!0)),slice:(o,i)=>(r(o,i),e.subarray(o-t,o-t+i))}}function sv(e){if(e instanceof Uint8Array){let t=Ka(e);return{size:e.length,read:(n,r)=>e.subarray(n,r),window:()=>t}}if(e instanceof Blob){let t=async(n,r)=>new Uint8Array(await e.slice(n,r).arrayBuffer());return{size:e.size,read:t,window:async(n,r)=>Ka(await t(n,Math.min(r,e.size)),n)}}throw new k("the archive is not a Uint8Array or a Blob")}var av=65536;function Gp(e){let t,n=0,r=0;return async(o,i,s=1/0)=>{let a=Math.min(o+i,e.size);return(t===void 0||o<n||a>r)&&(n=o,r=Math.max(a,Math.min(o+av,s,e.size)),t=await e.window(n,r)),t}}async function uv(e){let{size:t}=e,n=await e.window(Math.max(0,t-22-65535-20),t);for(let r=t-22;r>=Math.max(0,t-22-65535);r--)if(n.u32(r)===wi&&r+22+n.u16(r+20)===t){if(r>=20&&n.u32(r-20)===Qk)throw new k("zip64 is not supported",r-20);return{end:r,r:n}}throw new k("no end of central directory record")}function Xp(e,t){let n=new Map,r=Ka(e);for(let o=0;o<e.length;){let i=r.u16(o),s=r.u16(o+2);if(o+4+s>e.length)throw new k("an extra field runs past its room",t);if(i===ev)throw new k("zip64 is not supported",t);if(i===nv)throw new k("an entry carries a second name in a Unicode path extra field",t);n.has(i)||n.set(i,e.subarray(o+4,o+4+s)),o+=4+s}return n}async function lv(e,t){let n=await e(t,46);if(n.u32(t)!==gi)throw new k("no central directory entry where one is counted",t);let r=n.u16(t+28),o=n.u16(t+30);n=await e(t,46+r+o);let i={at:t,madeBy:n.u16(t+4),version:n.u16(t+6),flags:n.u16(t+8),method:n.u16(t+10),time:n.u16(t+12),date:n.u16(t+14),crc:n.u32(t+16),csize:n.u32(t+20),usize:n.u32(t+24),attributes:n.u32(t+38),offset:n.u32(t+42),name:n.slice(t+46,r).slice(),next:t+46+r+o+n.u16(t+32)};if(n.u16(t+34)!==0)throw new k("the archive spans several disks",t);if(i.flags&rv)throw new k("an entry is encrypted",t);if(i.method!==0&&i.method!==8)throw new k(`compression method ${i.method} is not stored or deflate`,t);if(i.csize===4294967295||i.usize===4294967295||i.offset===4294967295)throw new k("zip64 is not supported",t);i.mtime=jp(i.date,i.time,t);let s=Xp(n.slice(t+46+r,o),t).get(tv);if(s!==void 0&&s[0]&1){if(s.length<5)throw new k("an extended timestamp is cut short",t);i.mtime=yi(s).getInt32(1,!0)}return i}async function cv(e,t,n,r){let o=t.offset,i=await e(o,30,r);if(i.u32(o)!==mi)throw new k("no local header where the central directory points",o);let s=i.u16(o+26),a=i.u16(o+28);if(i=await e(o,30+s+a,r),!ti(i.slice(o+30,s),t.name))throw new k("the local header names a different entry",o);let u=[[4,"version","a different version"],[6,"flags","different flags"],[8,"method","a different compression method"],[10,"time","a different time"],[12,"date","a different date"]];for(let[d,p,h]of u)if(i.u16(o+d)!==t[p])throw new k(`the local header has ${h}`,o);Xp(i.slice(o+30+s,a),o);let l=t.flags&ov,c=(d,p)=>i.u32(o+d)===p||l&&i.u32(o+d)===0;if(!c(14,t.crc)||!c(18,t.csize)||!c(22,t.usize))throw new k("the local header disagrees with the central directory",o);t.dataAt=o+30+s+a;let f=t.dataAt+t.csize;if(l){let d=await e(f,16,n),p=m=>d.u32(m)===t.crc&&d.u32(m+4)===t.csize&&d.u32(m+8)===t.usize,h=d.u32(f)===Jk&&p(f+4);if(p(f)&&!(h&&f+16===n))f+=12;else if(h)f+=16;else throw new k("the data descriptor disagrees with the central directory",f)}return f}function fv(e,t,n){let r=n&Dp;if(t.endsWith("/")){if(r!==0&&r!==Xt.directory)throw new k(`${O(t)} is a directory by its name but not by its mode`,e.at);return"directory"}if(r===Xt.directory)throw new k(`${O(t)} is a directory by its mode but not by its name`,e.at);if(e.attributes&iv)throw new k(`${O(t)} is a directory by its attributes but not by its name`,e.at);if(r===Xt.symlink)return"symlink";if(r===0||r===Xt.file)return"file";throw new k(`the mode of ${O(t)} (${n.toString(8)}) is not one this package reads`,e.at)}async function dv(e,t,n){let{at:r,method:o,csize:i,usize:s}=t,a=We(t.name,"entry name",r),u=t.madeBy>>8===3?t.attributes>>>16:0,l=fv(t,a,u);if(l==="directory"&&s!==0)throw new k(`directory ${O(a)} has data`,r);if(o===0&&i!==s)throw new k("a stored entry has two sizes",r);let c=await e.read(t.dataAt,t.dataAt+i);if(c.length!==i)throw new k("the archive is truncated",t.dataAt);let f=o===8?await Pp(c,s,r):c;if(_o(f)!==t.crc)throw new k("the data does not match its CRC-32",r);let d=l==="symlink"?We(f,"symlink target",r):"",h={...Wn(()=>qt(a,l,d),r),type:l,mode:u===0?Hn[l]:u&4095,mtime:t.mtime,data:l==="file"?f:$e,storedName:a};return Wn(()=>n.add(h),r),h}async function*pv(e,{limit:t=1/0}={},n=!1){if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw new k(`limit ${String(t)} is not a whole number of bytes`);let{end:r,r:o}=await uv(e),i=o.u16(r+8);if(o.u16(r+4)!==0||o.u16(r+6)!==0||i!==o.u16(r+10))throw new k("the archive spans several disks",r);let s=o.u32(r+12),a=o.u32(r+16);if(i===65535||s===4294967295||a===4294967295)throw new k("zip64 is not supported",r);if(a+s!==r)throw new k("the central directory does not end at the end record",r);let u=Gp(e),l=[],c=a,f=0;for(let y=0;y<i;y++){let $=await lv(u,c);if(f+=$.usize,f>t)throw new k(`the entries come to more than ${t} bytes`,c);l.push($),c=$.next}if(c!==r)throw new k("the central directory does not hold what the end record counts",c);let d=0,p=l.toSorted((y,$)=>y.offset-$.offset),h=p.map((y,$)=>p[$+1]?.offset??a),m=[];for(let y=p.length-1;y>=0;y--)m[y]=p[y].csize===0&&y+1<p.length?m[y+1]:h[y]-p[y].csize;let g=Gp(e);for(let[y,$]of p.entries()){if($.offset!==d)throw new k($.offset>d?"bytes belong to no entry":"two entries overlap",d);d=await cv(g,$,h[y],m[y])}if(d!==a)throw new k("bytes belong to no entry",d);let w=new ft(n);for(let y of l)yield await dv(e,y,w)}async function Ja(e,t){if(!(e instanceof Uint8Array))throw new k("the archive is not a Uint8Array");return await Array.fromAsync(pv(sv(e),t,!0))}var hv=(e,t)=>e===null?t:`${e.endsWith("/")?e.slice(0,-1):e}/${t}`;function Zp(e,t,n){let r=wv(t.exdir,n);if(r===null)return!1;let o=[],i=mv(e,r,o,t,n);for(let s of o)gv(s,n);return i}function mv(e,t,n,r,o){let{ctx:i}=o;for(let s of e){let a=s.type==="directory";if(r.junk&&a)continue;let u=r.junk?Ne(s.name):s.name,l=j(t,u),c=hv(r.exdir,a?`${u}/`:u),f=Yp(l,i)?yv(oe(l),i):"read-only";if(f==="read-only")return xi(c,o);if(f!==null)return o.refuse("feature","name taken",`${c}: extracting under a name that is not a directory is not supported`),!1;if(a){if(!xv(l,c,o))return!1;continue}if(o.quiet===0)return o.refuse("feature","extraction listing","whether each file was stored or deflated is not known here, and an extraction that is not quiet names it (-q extracts without it)"),!1;let d=bv(l,c,r,o);if(d===null)return!1;if(d==="skip")continue;let p=i.fs.openWritable("/",l);if(!p)return xi(c,o);let h=s.type==="symlink";p.writeBytes(h?I(s.linkname):s.data),h&&n.push({path:l,shown:c,target:s.linkname})}return!0}function gv({path:e,shown:t,target:n},r){let{fs:o}=r.ctx,i=E("/",e,o),s=i.path!==null&&o.isFile(i.path)?fe(o,i.path):null,a=I(n);if(s===null||s.length!==a.length||s.some((u,l)=>u!==a[l])){r.say(2,`warning: deferred symlink (${t}) failed:
55
+ invalid placeholder file
56
+ `);return}o.removeWritable("/",e),o.makeWritableLink("/",e,n)}var Yp=(e,t)=>t.writable&&J(e);function xi(e,t){return t.refuse("feature","read-only target",`${e}: Read-only file system`),!1}function wv(e,t){let{ctx:n}=t;if(e===null)return n.cwd;let r=j(n.cwd,e),o=E("/",r,n.fs);if(o.path!==null&&n.fs.isDir(o.path))return o.path;if(o.path!==null)return t.refuse("feature","extraction directory",`${e}: an extraction directory that is not a directory is not supported`),null;let i=E("/",oe(r),n.fs);return i.error!==null?(t.say(2,`checkdir: cannot create extraction directory: ${e}
57
+ ${i.error}
58
+ `),t.status=2,null):!Yp(r,n)||!n.fs.makeWritableDir("/",r)?(xi(e,t),null):r}function yv(e,t){let n=[],r=e;for(;E("/",r,t.fs).path===null;r=oe(r)){if(E("/",r,t.fs,{follow:!1}).path!==null)return"File exists";n.push(r)}if(!t.fs.isDir(E("/",r,t.fs).path))return"Not a directory";for(let o of n.toReversed())if(!J(o)||!t.fs.makeWritableDir("/",o))return"read-only";return null}function xv(e,t,n){let{fs:r}=n.ctx,o=E("/",e,r,{follow:!1});return o.path===null?r.makeWritableDir("/",e)?(n.quiet===0&&n.say(1,` creating: ${t}
59
+ `),!0):xi(t,n):r.isDir(o.path)?!0:(n.refuse("feature","name taken",`${t}: a directory entry over a file already there is not supported`),!1)}function bv(e,t,n,r){let{fs:o}=r.ctx,i=E("/",e,o,{follow:!1});return i.path===null?"write":o.isDir(i.path)?(r.refuse("feature","name taken",`${t}: a file entry over a directory already there is not supported`),null):(n.overwrite===null&&kv(t,n,r),n.overwrite==="none"?"skip":(n.overwrite==="all"&&o.removeWritable("/",e),n.overwrite==="all"?"write":null))}function kv(e,t,n){let{ctx:r}=n;if(r.stdinLeft!==""||r.stdinBytes!==null){n.refuse("feature","overwrite prompt","answering the overwrite question from stdin is not supported (-o and -n answer it)");return}n.say(2,`replace ${e}? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
60
+ (EOF or read error, treating as "[N]one" ...)
61
+ `),t.overwrite="none",n.status=1}var Vp={__proto__:null,l:"list",t:"test",p:"pipe",c:"crt",v:"verbose"},Kp={usage:{text:`error: must specify directory to which to extract with -d option
62
+ `,status:10}};function Jp(e){let t={modes:new Set,lists:0,quiet:0,overwriteAll:!1,overwriteNone:!1,junk:!1,exdir:null,archive:null,members:[],excludes:[]},n=0;for(;n<e.length&&e[n].startsWith("-")&&e[n].length>1;n++){let a=e[n];for(let u=1;u<a.length;u++){let l=a[u];if(l==="d"){if(t.exdir=u+1<a.length?a.slice(u+1):e[++n],t.exdir===void 0)return Kp;break}if(l==="l"&&t.lists++,Vp[l])t.modes.add(Vp[l]);else if(l==="q")t.quiet++;else if(l==="o")t.overwriteAll=!0;else if(l==="n")t.overwriteNone=!0;else if(l==="j")t.junk=!0;else throw new x("option",`-${l}`,`unknown option: -${l}`)}}if(t.modes.size>1)throw new x("option","modes","combining -c, -l, -p, -t and -v is not supported");if(n>=e.length)throw new x("feature","usage","printing the usage summary is not supported");t.archive=e[n++];let r=!1;for(;n<e.length;n++){let a=e[n];if(a==="-x")r=!0;else if(a.startsWith("-d")){if(t.exdir=a.length>2?a.slice(2):e[++n],t.exdir===void 0)return Kp}else(r?t.excludes:t.members).push(a)}let[o="extract"]=t.modes,i=o==="list"&&t.lists>1?"verbose":o,s=t.overwriteNone?"none":t.overwriteAll?"all":null;return{...t,mode:i,overwrite:s,bothOverwrites:t.overwriteAll&&t.overwriteNone}}function Kn(e,t,n,r){if(t>=e.length)return r>=n.length?1:0;let o=e[t++];if(o===63)return r<n.length?Kn(e,t,n,r+1):0;if(o===42){if(t>=e.length)return 1;for(;r<n.length;r++){let i=Kn(e,t,n,r);if(i!==0)return i}return 2}if(o===91)return vv(e,t,n,r);if(o===92){if(t>=e.length)return 0;o=e[t++]}return r<n.length&&n[r]===o?Kn(e,t,n,r+1):0}function vv(e,t,n,r){if(r>=n.length)return 0;let o=e[t]===33||e[t]===94,i=t+(o?1:0),s=i;for(let l=!1;s<e.length;s++)if(l)l=!1;else if(e[s]===92)l=!0;else if(e[s]===93)break;if(s>=e.length)return 0;let a=0,u=e[i]===45;for(;i<s;i++)if(!u&&e[i]===92)u=!0;else if(!u&&e[i]===45)a=e[i-1];else{if(e[i+1]!==45&&n[r]>=(a||e[i])&&n[r]<=e[i])return o?0:Kn(e,s+1,n,r+1);a=0,u=!1}return o?Kn(e,s+1,n,r+1):0}var Qp=(e,t)=>Kn(e,0,t,0)===1;var Ev=[" End-of-central-directory signature not found. Either this file is not"," a zipfile, or it constitutes one disk of a multi-part archive. In the"," latter case the central directory and zipfile comment will be found on"," the last disk(s) of this archive."].join(`
63
+ `)+`
64
+ `;async function eh(e,t,n){let r=Jp(t);if(r.usage)return{stdout:"",stderr:r.usage.text,exitCode:r.usage.status};let o=_v(n,r);if(r.bothOverwrites&&o.say(2,`caution: both -n and -o specified; ignoring -o
65
+ `),r.exdir!==null&&r.mode!=="extract"&&o.say(2,`caution: not extracting; -d ignored
66
+ `),r.mode==="crt"||r.mode==="verbose"){let c=r.mode==="crt"?"-c":r.lists>1?"-ll":"-v";return o.refuse("option",c,"how each entry is stored is not known here, which this listing prints")}let i=$v(r.archive,n);if(!i)return o.say(2,`unzip: cannot find or open ${r.archive}, ${r.archive}.zip or ${r.archive}.ZIP.
67
+ `),o.end(9);let s=fe(n.fs,i.path),a;try{a=await Ja(s)}catch(c){if(!(c instanceof k))throw c;return Sv(s)?o.refuse("feature","archive",`this archive is not one this terminal reads: ${c.message}`):(o.heading(i.name,!0),o.say(2,Ev),r.mode!=="pipe"&&o.say(2,`unzip: cannot find zipfile directory in one of ${r.archive} or
68
+ ${r.archive}.zip, and cannot find ${r.archive}.ZIP, period.
69
+ `),o.end(9))}let u=a.map(ri).find(c=>c!==null);if(u!==void 0){let[c,f]=ni(u);return o.refuse("feature",c,`${u}: ${f}`)}if(a.length===0)return o.heading(i.name,!1),o.say(2,`warning [${i.name}]: zipfile is empty
70
+ `),o.end(1);let l=Av(a,r);if(r.mode==="list")return Cv(l,i.name,o);if(o.heading(i.name,!1),r.mode==="test")Iv(l,i.name,o);else if(r.mode==="pipe")for(let c of l.entries)o.bytes(c.type==="symlink"?I(c.linkname):c.data);else if(!Zp(l.entries,r,o))return o.end(o.gap?1:o.status);return Nv(l,o),r.mode==="test"&&Tv(l,i.name,o),o.end(l.missed?11:o.status)}function $v(e,t){for(let n of[e,`${e}.zip`,`${e}.ZIP`]){let r=n===e?D(t,"unzip",n):D({...t,notes:null},"unzip",n);if(!r.error&&!t.fs.isDir(r.path))return{name:n,path:r.path}}return null}function Sv(e){for(let t=e.length-4;t>=Math.max(0,e.length-22-65535);t--)if(e[t]===80&&e[t+1]===75&&e[t+2]===5&&e[t+3]===6)return!0;return!1}var qr=e=>I(e);function Av(e,t){let n=t.members.map(s=>({text:s,pattern:qr(s),hit:!1})),r=t.excludes.map(s=>({text:s,pattern:qr(s),hit:!1})),o=(s,a)=>{let u=!1;for(let l of s)Qp(l.pattern,a)&&(l.hit=!0,u=!0);return u};return{entries:e.filter(s=>{let a=qr($t(s)),u=n.length===0||o(n,a);return!o(r,a)&&u}),include:n,exclude:r,all:n.length===0&&r.length===0,missed:n.some(s=>!s.hit)}}function Nv(e,t){for(let n of e.include)n.hit||t.say(2,`caution: filename not matched: ${n.text}
71
+ `);for(let n of e.exclude)n.hit||t.say(2,`caution: excluded filename not matched: ${n.text}
72
+ `)}var Ov=(e,t)=>e+" ".repeat(Math.max(0,t-qr(e).length));function Iv(e,t,n){if(n.quiet===0)for(let r of e.entries)n.say(1,` testing: ${Ov($t(r),22)} OK
73
+ `)}function Tv(e,t,n){n.quiet>1||(e.missed?n.say(1,`At least one error was detected in ${t}.
74
+ `):e.all?n.say(1,`No errors detected in compressed data of ${t}.
75
+ `):n.say(1,`No errors detected in ${t} for the ${e.entries.length} file${e.entries.length===1?"":"s"} tested.
76
+ `))}function Cv(e,t,n){let{ctx:r}=n,o=r.vars.has("TZ"),i=l=>Ht(new Date(l.mtime*1e3),"%Y-%m-%d %H:%M",o);if(!o&&e.entries.some(l=>i(l)!==Ht(new Date(l.mtime*1e3),"%Y-%m-%d %H:%M",!0)))return n.refuse("feature","archive times","whether an entry's time is exact or a DOS time is not known here, and outside UTC the two are listed differently (TZ=UTC answers it)");let s=l=>l.type==="symlink"?qr(l.linkname).length:l.data.length;n.heading(t,!1),n.quiet<2&&n.say(1,` Length Date Time Name
77
+ --------- ---------- ----- ----
78
+ `);let a=0;for(let l of e.entries)a+=s(l),n.say(1,`${String(s(l)).padStart(9)} ${i(l)} ${$t(l)}
79
+ `);let u=e.entries.length;return n.quiet<2&&n.say(1,`--------- -------
80
+ ${String(a).padStart(9)} ${u} file${u===1?"":"s"}
81
+ `),n.end(u===0&&e.include.length>0?11:0)}function _v(e,t){let n=t.mode==="test",r={ctx:e,events:[],status:0,gap:null,quiet:t.mode==="pipe"?Math.max(t.quiet,1):t.quiet,say(o,i){r.events.push({fd:n?1:o,text:i})},bytes(o){r.events.push({fd:1,bytes:o})},heading(o,i){r.quiet===0?r.say(1,`Archive: ${o}
82
+ `):i&&r.say(2,`[${o}]
83
+ `)},refuse(o,i,s){return r.say(2,`unzip: ${s}
84
+ `),r.gap={kind:o,detail:i,message:`unzip: ${s}`},r.end(1)},end(o=r.status){let i=a=>r.events.filter(u=>u.fd===a&&u.text!==void 0).map(u=>u.text).join(""),s={stdout:i(1),stderr:i(2),exitCode:o,events:r.events};return r.gap?X(s,r.gap.kind,"unzip",r.gap.detail,r.gap.message):s}};return r}var Lv={file:384,directory:448,symlink:511},th={__proto__:null,r:"recurse",q:"quiet",j:"junk",0:"store",y:"symlinks",D:"noDirectories"};function Fv(e){let t={recurse:!1,quiet:!1,junk:!1,store:!1,symlinks:!1,noDirectories:!1,archive:null,names:[]};for(let n of e){if(n.startsWith("--"))throw new x("option",n.split("=")[0],`unknown option: ${n.split("=")[0]}`);if(n.startsWith("-")&&n.length>1)for(let r of n.slice(1)){if(!th[r])throw new x("option",`-${r}`,`unknown option: -${r}`);t[th[r]]=!0}else t.archive===null?t.archive=n:t.names.push(n)}return t}async function rh(e,t,n){let r=Fv(t);if(r.archive===null||r.archive==="-"){if(t.length>0&&xt(n))return{stdout:"",stderr:`
85
+ zip error: Invalid command arguments (cannot write zip file to terminal)
86
+ `,exitCode:16};throw new x("feature","streamed archive","writing an archive to stdout is not supported")}let o={events:[],status:0},i=g=>o.events.push({fd:1,text:g}),s=Ne(r.archive).includes(".")?r.archive:`${r.archive}.zip`;if(E(n.cwd,s,n.fs,{follow:!1}).path!==null)return Jn(o,"feature","existing archive",`${s}: adding to an archive that is already there is not supported`);let u={ctx:n,opts:r,entries:[],seen:new Set,out:i,gap:null};for(let g of r.names){if(g==="-")return Jn(o,"feature","stdin input","adding what stdin holds, as the entry `-`, is not supported");if(jv(g,u),u.gap)return Jn(o,...u.gap)}if(u.entries.length===0)return i(`
87
+ zip error: Nothing to do! (${s})
88
+ `),Hr(o,12);let l=Wv(u);if(l)return i(l),Hr(o,16);let c=r.store?new Map:await Uv(u.entries.filter(g=>g.type==="file")),f=[...c.keys()].filter(Dv);if(f.length>0&&f.length<c.size)return Jn(o,"feature","stored suffix",`${f[0].name}: storing a file as Info-ZIP stores one by its suffix, beside files it deflates, is not supported`);for(let g of f)c.delete(g);let d=u.entries.map(g=>Pv(g,c.get(g))),p;try{p=await Va(u.entries,{method:c.size>0?"deflate":"store"})}catch(g){if(!(g instanceof k))throw g;return Jn(o,"feature","archive",`this archive cannot be written here: ${g.message}`)}let h=j(n.cwd,s),m=n.writable&&J(h)?Rv(n,s):null;if(m===null)return Jn(o,"feature","read-only target",`${s}: Read-only file system`);if(m.error)return i(`zip I/O error: ${m.error}
89
+ zip error: Could not create output file (${s})
90
+ `),Hr(o,15);if(!r.quiet)for(let g of d)i(g);return m.writeBytes(p),Hr(o,0)}function Rv(e,t){try{return e.fs.openWritable(e.cwd,t)}catch(n){return{error:n.fsError??"No such file or directory"}}}var Mv=[".Z",".zip",".zoo",".arc",".lzh",".arj"],Dv=e=>Mv.some(t=>e.name.endsWith(t));async function Uv(e){let t=await Promise.all(e.map(async n=>n.data.length===0?0:(await je(n.data,"deflate-raw")).length));return new Map(e.flatMap((n,r)=>t[r]<n.data.length?[[n,t[r]]]:[]))}function Pv(e,t){let n=e.type==="directory"?`${e.name}/`:e.name;return t===void 0?` adding: ${n} (stored 0%)
91
+ `:` adding: ${n} (deflated ${zv(e.data.length,t)}%)
92
+ `}function zv(e,t){let[n,r]=[e,t];return n>16777215&&(n=Math.floor((n+128)/256),r=Math.floor((r+128)/256)),n>r?Math.floor((1+Math.floor(200*(n-r)/n))/2):0}function Bv(e,t){if(t.junk)return Ne(e);let n=e.replace(/^\/+/u,"");for(;n.startsWith("./");)n=n.slice(2);return n==="."?"":n}function jv(e,t){let{ctx:n,opts:r}=t,o=E(n.cwd,e,n.fs,{follow:!r.symlinks});if(o.error){t.out(` zip warning: name not matched: ${e}
93
+ `);return}let i=e.length>1?e.replace(/\/+$/u,""):e,s=Bv(i,r);oh(o.path,s,!r.junk&&s===""?"":i,t)}function oh(e,t,n,r){let{ctx:o,opts:i}=r,{fs:s}=o,a=i.symlinks&&s.isLink?.(e)===!0,u=!a&&s.isDir(e);if(t!==""&&t.split("/").some(p=>p==="."||p===".."||p===""))return nh(r,"dot-segment names",`${t}: names with \`.', \`..' or empty segments are not supported`);let l=a?"symlink":u?"directory":"file";if(t!==""&&(!u||!(i.junk||i.noDirectories))&&r.entries.push({name:t,full:u?`${n}/`:n,type:l,mode:Lv[l],mtime:Math.floor(o.createdAt/1e3),linkname:a?s.readLink(e):"",data:l==="file"?fe(s,e):void 0}),!u||!i.recurse)return;if(r.seen.has(e))return nh(r,"link loop",`${t}: a directory inside itself through a link is not supported`);r.seen.add(e);let{dirs:c,files:f,links:d=[]}=s.listDir(e);for(let p of[...new Set([...c,...f,...d])].sort(q)){let h=he(e,p),m=E("/",h,s,{follow:!i.symlinks});if(m.error?r.out(` zip warning: name not matched: ${t}/${p}
94
+ `):oh(m.path,i.junk||t===""?p:`${t}/${p}`,n===""?p:`${n}/${p}`,r),r.gap)break}r.seen.delete(e)}function Wv(e){let t=e.entries.toSorted((o,i)=>q(o.name,i.name)||q(o.full,i.full)),n=[];for(let o of t){let i=n.at(-1);if(i?.name!==o.name)n.push(o);else if(i.full!==o.full){let s=o.type==="directory"?`${o.name}/`:o.name,a=e.opts.junk?` this may be a result of using -j
95
+ `:"";return` zip warning: first full name: ${i.full}
96
+ second full name: ${o.full}
97
+ name in zip file repeated: ${s}
98
+ ${a}
99
+ zip error: Invalid command arguments (cannot repeat names in zip file)
100
+ `}}let r=new Set(n);return e.entries=e.entries.filter(o=>r.has(o)),null}function nh(e,t,n){e.gap??=["feature",t,n]}function Jn(e,t,n,r){return e.events.push({fd:2,text:`zip: ${r}
101
+ `}),X(Hr(e,1),t,"zip",n,`zip: ${r}`)}function Hr(e,t){let n=r=>e.events.filter(o=>o.fd===r).map(o=>o.text).join("");return{stdout:n(1),stderr:n(2),exitCode:t,events:e.events}}var ih={tar:Mp,...Re("deflate-raw")?{zip:rh,unzip:eh}:{}};var Qa="brotli",bi=".br",ah=Re(Qa)?{brotli:Hv}:{},uh="con",lh=Object.freeze(["0","1","2","3","4","5","6","7","8","9"]),qv=`Usage: brotli [OPTION]... [FILE]...
102
+ `;async function Hv(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:[...lh,"d","c","k","j","f","Z"],long:["decompress","stdout","keep","rm","force","best"],valueShort:["q"],valueLong:["quality"]}),s=Gv(r,o);if(s!==void 0)return v("option","brotli",s,`brotli: ${s}: choosing a compression level is not supported`,1);let a={decompressing:r.has("d")||r.has("decompress"),stdout:r.has("c")||r.has("stdout"),remove:r.has("j")||r.has("rm"),force:r.has("f")||r.has("force")};if(a.stdout&&i.length>1)return{stdout:qv,stderr:"",exitCode:1};let u={ctx:n,events:[],stderr:"",status:0,gap:null};for(let c of i.length===0?["-"]:i)if(!await Xv(c,e,a,u))break;if(u.gap)return u.gap;let l=[...u.events,...u.stderr?[{fd:2,text:u.stderr}]:[]];return{stdout:"",stderr:u.stderr,exitCode:u.status,events:l}}function Gv(e,t){let n=[...lh,"Z"].find(r=>e.has(r));return n!==void 0?"-"+n:e.has("best")?"--best":t.has("q")?"-q":t.has("quality")?"--quality":void 0}function Xv(e,t,n,r){let{ctx:o}=r;if(e==="-"){if(!n.force&&(n.decompressing?sn(o):xt(o)))return Nt(r,`Use -h help. Use -f to force ${n.decompressing?"input from":"output to"} a terminal.`);let a=o.stdinBytes,u=o.stdinLeft;return z(o,"",!0),sh(a??I(u),uh,null,n,r)}let i=null;if(!n.stdout)if(!n.decompressing)i=e+bi;else{if(e.length<=bi.length)return Nt(r,`empty output file name for [${e}] input file`);if(e.endsWith(bi))i=e.slice(0,-bi.length);else return Nt(r,`input file [${e}] suffix mismatch`)}let s=D(o,"brotli",e);return s.error?Nt(r,`failed to open input file [${e}]: ${s.error}`):i!==null&&!n.force&&D(o,"brotli",i).error===null?Nt(r,`failed to open output file [${i}]: File exists`):i===null&&!n.decompressing&&!n.force&&xt(o)?Nt(r,"Use -h help. Use -f to force output to a terminal."):o.fs.isDir(s.path)?Nt(r,`failed to read input [${e}]: Is a directory`):sh(fe(o.fs,s.path),e,i,n,r)}async function sh(e,t,n,r,o){let{ctx:i}=o,s=r.decompressing?await Ur(e,Qa):{bytes:await je(e,Qa),error:null};if(s.error)return Nt(o,`corrupt input [${t}]`);if(n===null)o.events.push({fd:1,bytes:s.bytes});else if(!Zv(n,s.bytes,o))return!1;return r.remove&&t!==uh&&i.fs.removeWritable(i.cwd,t),!0}function Zv(e,t,n){let{ctx:r}=n,o;try{o=r.writable&&r.fs.openWritable?.(r.cwd,e)}catch(i){return Nt(n,`failed to open output file [${e}]: ${i.message}`)}return o?(o.writeBytes(t),!0):(n.gap??=v("feature","brotli","read-only target",`brotli: ${e}: file system is read-only`,1),!1)}function Nt(e,t){return e.stderr+=`${t}
103
+ `,e.status=1,!1}var Yv=Object.freeze({__proto__:null,1:"SHA-1",256:"SHA-256",384:"SHA-384",512:"SHA-512"}),Vv=Object.freeze(["1","224","256","384","512","512224","512256"]),Kv=()=>{try{return typeof crypto?.subtle?.digest=="function"}catch{return!1}};async function Jv(e,t){let n=new Uint8Array(await crypto.subtle.digest(e,t));return Array.from(n,r=>r.toString(16).padStart(2,"0")).join("")}function Qv(e,t,n){let r=e==="shasum"?n.get("a")??"1":String(t);if(e==="shasum"&&!Vv.includes(r))return{error:b(`${e}: Unrecognized algorithm
104
+ Type shasum -h for help
105
+ `,1)};let o=Yv[r];return o===void 0?{error:v("feature",e,`SHA-${r}`,`${e}: this runtime's crypto does not digest SHA-${r}`,1)}:{algorithm:o}}function Gr(e,t){return async(n,r,o)=>{let{flags:i,order:s,positional:a,values:u}=N(r,{short:e==="shasum"?["b","t","c"]:["b","t","c","z"],long:e==="shasum"?["binary","text","check","tag"]:["binary","text","check","tag","zero"],valueShort:e==="shasum"?["a"]:[]});if(i.has("c")||i.has("check"))return v("feature",e,"-c",`${e}: reading a list of digests back is not supported`,1);let{algorithm:l,error:c}=Qv(e,t,u);if(c)return c;let{mode:f,error:d}=rE(e,i,s);if(d)return d;let p=ae(e,a,n,o,{read:"bytes"}),h=await Promise.all(p.inputs.map(g=>Jv(l,g.bytes))),m=oE(l,i,f);return ue(p.inputs.map((g,w)=>m(h[w],g.name??"-")).join(""),p)}}var eE=new Set(["b","binary"]),tE=new Set(["t","text"]);function nE(e,t){let n=!1,r=null,o=!1;for(let{name:i}of t)eE.has(i)?(n=!0,r="binary"):tE.has(i)?(o=!0,r="text"):i==="tag"&&(r="binary");return e==="shasum"?{binary:n,text:o&&!n,ambiguous:n&&o}:{binary:r==="binary",text:r==="text",ambiguous:!1}}function rE(e,t,n){let r=nE(e,n),o=e==="shasum"?`Type ${e} -h for help
106
+ `:`Try '${e} --help' for more information.
107
+ `;return r.ambiguous?{error:b(`${e}: Ambiguous file mode
108
+ ${o}`,1)}:t.has("tag")&&r.text?{error:b(`${e}: --tag does not support --text mode
109
+ ${o}`,1)}:{mode:r}}function oE(e,t,n){let r=t.has("z")||t.has("zero")?"\0":`
110
+ `;if(t.has("tag")){let o=e.replace("-","");return(i,s)=>`${o} (${s}) = ${i}${r}`}return(o,i)=>`${o}${n.binary?" *":" "}${i}${r}`}var ch=Kv()?{sha1sum:Gr("sha1sum",1),sha256sum:Gr("sha256sum",256),sha384sum:Gr("sha384sum",384),sha512sum:Gr("sha512sum",512),shasum:Gr("shasum",1)}:{};var fh=()=>typeof fetch=="function";function dh(e){if(e.network!==void 0&&typeof e.network!="boolean")throw new TypeError(`createTerminal: network must be true or false (got ${e.network===null?"null":typeof e.network})`);return e.network===!0}var iE=Object.freeze(["http:","https:"]),sE=/^[a-zA-Z][a-zA-Z0-9+.-]*:/u;function ph(e){let t=sE.test(e)?e:"http://"+e,n;try{n=new URL(t)}catch{return{malformed:!0}}return iE.includes(n.protocol)?n.hostname===""?{malformed:!0}:{url:n}:{protocol:n.protocol.slice(0,-1)}}var aE=new Set(["ENOTFOUND","EAI_AGAIN"]),uE=new Set(["ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT"]),lE=new Set(["ECONNRESET","ECONNABORTED","EPIPE"]),cE=new Set(["CERT_HAS_EXPIRED","CERT_NOT_YET_VALID","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","ERR_TLS_CERT_ALTNAME_INVALID"]),fE=new Set(["TimeoutError","AbortError"]);function hh(e,t,n){let r=pE(e),o=mh(e),i=`Failed to connect to ${t.hostname} port ${dE(t)}`;return fE.has(e?.name)||uE.has(r)?{code:28,message:n===null?`Operation timed out: ${o}`:`Operation timed out after ${n} milliseconds`}:aE.has(r)?{code:6,message:`Could not resolve host: ${t.hostname}`}:cE.has(r)?{code:60,message:`SSL certificate problem: ${o}`}:lE.has(r)?{code:56,message:`Recv failure: ${o}`}:{code:7,message:`${i}: ${o}`}}var dE=e=>e.port===""?e.protocol==="https:"?443:80:e.port;function pE(e){for(let t=e,n=0;t!=null&&n<8;t=t.cause,n++)if(typeof t.code=="string")return t.code;return null}function mh(e){let t=typeof e?.message=="string"&&e.message!==""?e.message:"transfer failed";for(let n=e?.cause,r=0;n!=null&&r<8;n=n.cause,r++)typeof n.message=="string"&&n.message!==""&&(t=n.message);return t}async function gh(e,t,n=null){try{return{response:await fetch(e.href,t)}}catch(r){return{failed:hh(r,e,n)}}}async function wh(e,t,n=null){try{return{bytes:new Uint8Array(await e.arrayBuffer())}}catch(r){let{code:o,message:i}=hh(r,t,n);return{failed:o===7?{code:56,message:`Recv failure: ${mh(r)}`}:{code:o,message:i}}}}async function ki(e){try{await e.body?.cancel()}catch{}}var hE={short:["h","s","S","i","I","L","f","O","k","v","G","n"],long:["help","silent","show-error","no-progress-meter","include","head","location","location-trusted","fail","remote-name","compressed","insecure","verbose","get","netrc"],valueShort:["X","A","m","u","e","b","c","w","x","T","r","C","E","D","F"],valueLong:["request","user-agent","max-time","user","max-redirs","referer","cookie","cookie-jar","write-out","proxy","proxy-user","upload-file","range","continue-at","cert","key","cacert","capath","dump-header","connect-timeout","retry","limit-rate","resolve","interface","form"],repeatable:["H","header","d","data","data-raw","data-ascii","data-binary","json","o","output"]},mE=new Map([["k","certificates are the runtime's to check, and nothing here can tell it not to"],["insecure","certificates are the runtime's to check, and nothing here can tell it not to"],["v","the trace is of a connection this code never sees; `-i` prints the response headers"],["verbose","the trace is of a connection this code never sees; `-i` prints the response headers"],["location-trusted","a credential is for the origin it was given for; `-L` follows the hop without it"],["G","moving the data into the query string is not implemented; put it in the URL"],["get","moving the data into the query string is not implemented; put it in the URL"],["n","there is no home directory here to read a `.netrc` from"],["netrc","there is no home directory here to read a `.netrc` from"],["b",'there is no cookie jar here; a cookie to send is `-H "Cookie: \u2026"`'],["cookie",'there is no cookie jar here; a cookie to send is `-H "Cookie: \u2026"`'],["c","there is no cookie jar here to write"],["cookie-jar","there is no cookie jar here to write"],["w","the transfer keeps no measurements of its own to write out"],["write-out","the transfer keeps no measurements of its own to write out"],["x","a proxy is the runtime's own setting, and nothing here passes it one"],["proxy","a proxy is the runtime's own setting, and nothing here passes it one"],["proxy-user","a proxy is the runtime's own setting, and nothing here passes it one"],["F","a multipart body is not implemented; `--data-binary` sends one you spell out yourself"],["form","a multipart body is not implemented; `--data-binary` sends one you spell out yourself"],["T","uploading a file is not implemented; `-X PUT --data-binary @file` sends the same bytes"],["upload-file","uploading a file is not implemented; `-X PUT --data-binary @file` sends the same bytes"],["r",'a ranged request is `-H "Range: bytes=\u2026"`'],["range",'a ranged request is `-H "Range: bytes=\u2026"`'],["C","there is nothing to resume: a transfer here is one request and its answer"],["continue-at","there is nothing to resume: a transfer here is one request and its answer"],["E","client certificates are the runtime's own"],["cert","client certificates are the runtime's own"],["key","client certificates are the runtime's own"],["cacert","the trust store is the runtime's own"],["capath","the trust store is the runtime's own"],["e",'a referer is `-H "Referer: \u2026"`'],["referer",'a referer is `-H "Referer: \u2026"`'],["D","writing the headers to a file of their own is not implemented; `-i` writes them in front of the body"],["dump-header","writing the headers to a file of their own is not implemented; `-i` writes them in front of the body"],["connect-timeout","only the whole transfer can be timed here, which is `--max-time`"],["retry","retrying is not implemented: a transfer here is one request and its answer"],["limit-rate","the runtime reads the response at its own pace"],["resolve","name resolution is the runtime's own"],["interface","the interface a request leaves by is the runtime's own"]]),gE=new Map([["d","text"],["data","text"],["data-ascii","text"],["data-raw","raw"],["data-binary","binary"],["json","json"]]),wE=new Set(["H","header"]),yE=new Set(["o","output"]),xE=new Set(["O","remote-name"]),bE="application/x-www-form-urlencoded",yh="application/json",kE=50,vE=new Set([10,13]);function kh(e,t,n){let{flags:r,values:o,positional:i,order:s}=N(e,hE);if(r.has("h")||r.has("help"))return{help:!0};let a=EE(r,o);return a?{refusal:a}:{opts:$E(r,o,s,t,n),urls:i,targets:CE(s)}}function EE(e,t){for(let[n,r]of mE){if(!e.has(n)&&!t.has(n))continue;let o=(n.length===1?"-":"--")+n;return v("option","curl",o,`curl: ${o}: ${r}`,2)}return null}function $E(e,t,n,r,o){o.quiet=(e.has("s")||e.has("silent"))&&!e.has("S")&&!e.has("show-error");let i=SE(n,r,o);if(i===null)return null;let s=IE(t,n,i,o);if(s===null)return null;let a=xh(t.get("max-redirs"),"--max-redirs",o),u=xh(t.get("m")??t.get("max-time"),"--max-time",o);if(a===null||u===null)return null;if(u!==void 0&&typeof AbortSignal?.timeout!="function")return hn(o,"feature","--max-time",2,"this runtime cannot put a deadline on a request");let l=e.has("I")||e.has("head");return{headers:s,body:i.bytes,head:l,include:e.has("i")||e.has("include"),location:e.has("L")||e.has("location"),failEarly:e.has("f")||e.has("fail"),method:t.get("X")??t.get("request")??(l?"HEAD":i.bytes===null?"GET":"POST"),redirects:a===void 0?kE:a<0?1/0:a,timeout:u===void 0?null:Math.round(u*1e3)}}function xh(e,t,n){if(e===void 0)return;let r=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/u.test(e.trim())?Number(e.trim()):Number.NaN;return Number.isFinite(r)?r:(n.stderr+=`curl: option ${t}: expected a proper numerical parameter
111
+ `,n.status=2,null)}function SE(e,t,n){let r=[],o=new Set;for(let{name:a,value:u}of e){let l=gE.get(a);if(l===void 0)continue;let c=AE(l,u,t,n);if(c===null)return null;o.add(l==="json"?"json":"form"),r.push(c)}if(r.length===0)return{bytes:null,json:!1};if(o.size>1)return n.stderr+=`curl: --json cannot be mixed with --data
112
+ `,n.status=2,null;let i=o.has("json"),s=[];for(let[a,u]of r.entries())a>0&&!i&&s.push(I("&")),s.push(u);return{bytes:Ze([...s,new Uint8Array]),json:i}}function AE(e,t,n,r){if(e==="raw"||!t.startsWith("@"))return I(t);let o=t.slice(1),i=o==="-"?NE(n,r.ctx):OE(o,r);return i===null?null:e==="text"?i.filter(s=>!vE.has(s)):i}function NE(e,t){let n=t.stdinBytes,r=t.stdinLeft===""?e:t.stdinLeft;return z(t,"",!0),n??I(r)}function OE(e,t){let{ctx:n}=t,r=D(n,"curl",e);return r.error||n.fs.isDir(r.path)?(dt(t,26,"Failed to open/read local data from file/application"),null):fe(n.fs,r.path)}function IE(e,t,n,r){let o=new Headers;n.bytes!==null&&o.set("content-type",n.json?yh:bE),n.json&&o.set("accept",yh);let i=e.get("A")??e.get("user-agent");i!==void 0&&o.set("user-agent",i);let s=e.get("u")??e.get("user");if(s!==void 0){if(!s.includes(":"))return hn(r,"feature","-u",2,"there is no interactive input here to read a password from");o.set("authorization",`Basic ${kr(I(s))}`)}for(let{name:a,value:u}of t)if(wE.has(a)&&!TE(o,u,r))return null;return o}function TE(e,t,n){let r=t.indexOf(":");if(r===-1)return t.endsWith(";")?bh(e,t.slice(0,-1),"",n):vh(n,t);let o=t.slice(r+1).trim();return o===""?(hn(n,"option","-H",2,`-H "${t}": taking away a header the runtime sends is not supported`),!1):bh(e,t.slice(0,r),o,n)}function bh(e,t,n,r){try{e.set(t.trim(),n)}catch{return vh(r,t.trim())}return!0}function vh(e,t){return e.stderr+=`curl: -H: not a header: ${t}
113
+ `,e.status=2,!1}function CE(e){let t=[];for(let{name:n,value:r}of e)yE.has(n)?t.push(r==="-"?null:{file:r}):xE.has(n)&&t.push({remote:!0});return t}function dt(e,t,n){return e.quiet||(e.stderr+=`curl: (${t}) ${n}
114
+ `),e.status=t,!1}function hn(e,t,n,r,o){return e.gap??={kind:t,detail:n,message:`curl: (${r}) ${o}`},dt(e,r,o),null}var _E=new Set([301,302,303,307,308]),LE=new Set([301,302,303]);async function Ah(e,t,n){let r={ctx:n,events:[],stderr:"",status:0,gap:null,quiet:!1},{help:o,refusal:i,opts:s,urls:a,targets:u}=kh(t,e,r);if(o)return{stdout:RE,stderr:"",exitCode:0};if(i)return i;if(s===null)return Eh(r);if(a.length===0)return FE();for(let[l,c]of a.entries())await ME(c,u[l]??null,s,r);return Eh(r)}var FE=()=>({stdout:"",stderr:`curl: try 'curl --help' for more information
115
+ `,exitCode:2}),RE=`Usage: curl [options...] <url>
116
+ -d, --data <data> send data in a POST body; @file reads a file, @- the pipe
117
+ --data-raw <data> the same, taking a leading @ as data rather than a name
118
+ --data-binary <data> the same, keeping a file's line endings
119
+ --json <data> send data as JSON, and ask for JSON back
120
+ -f, --fail write no body, and exit 22, on a failing status
121
+ -H, --header <header> send a header: "Name: value", or "Name;" to send it empty
122
+ -A, --user-agent <name> send a user agent
123
+ -u, --user <user:pass> send basic authentication
124
+ -i, --include write the response headers in front of the body
125
+ -I, --head ask for the headers alone
126
+ -L, --location follow a redirect, up to --max-redirs <num>
127
+ -m, --max-time <seconds> give up on a transfer that takes longer
128
+ -o, --output <file> write to a file rather than to stdout ("-" is stdout)
129
+ -O, --remote-name write to a file named after the URL
130
+ -s, --silent say nothing about a transfer that failed
131
+ -S, --show-error say it anyway, alongside -s
132
+ -X, --request <method> use another method
133
+ --compressed ask for a compressed answer, which the runtime does anyway
134
+ -h, --help this list
135
+
136
+ Every other option curl carries is refused by name, and says what would have
137
+ to exist here for it to work.
138
+ `;function Eh(e){let t=[...e.events,...e.stderr?[{fd:2,text:e.stderr}]:[]],n={stdout:"",stderr:e.stderr,exitCode:e.status,events:t};return e.gap?X(n,e.gap.kind,"curl",e.gap.detail,e.gap.message):n}async function ME(e,t,n,r){let o=ph(e);if(o.protocol)return hn(r,"feature","protocol",1,$h(o.protocol));if(o.malformed)return dt(r,3,"URL using bad/illegal format or missing URL");let i=t?.remote?DE(o.url):t?.file??null,s={url:o.url,method:n.method,body:n.body,headers:n.headers},a=n.timeout===null?null:AbortSignal.timeout(n.timeout),u="";for(let l=0;;l++){let{response:c,failed:f}=await gh(s.url,UE(s,a),n.timeout);if(f)return dt(r,f.code,f.message);(n.include||n.head)&&(u+=HE(c,r.ctx));let d=PE(c,s,n);if(d===null)return WE(c,s.url,u,i,n,r);if(await ki(c),l>=n.redirects)return dt(r,47,`Maximum (${n.redirects}) redirects followed`);if(d.protocol)return hn(r,"feature","protocol",1,$h(d.protocol));Object.assign(s,d)}}var $h=e=>`Protocol "${e}" not supported or disabled in libcurl`,DE=e=>e.pathname.slice(e.pathname.lastIndexOf("/")+1),UE=(e,t)=>({method:e.method,headers:e.headers,redirect:"manual",...e.body===null?{}:{body:e.body},...t===null?{}:{signal:t}});function PE(e,t,n){if(!n.location||!_E.has(e.status))return null;let r=e.headers.get("location");if(r===null||r==="")return null;let o;try{o=new URL(r,t.url)}catch{return null}if(o.protocol!=="http:"&&o.protocol!=="https:")return{protocol:o.protocol.slice(0,-1)};let i=LE.has(e.status)&&t.method!=="HEAD"&&t.method!=="GET";return{url:o,method:i?"GET":t.method,body:i?null:t.body,headers:jE(t.headers,i,o.origin!==t.url.origin)}}var zE=Object.freeze(["content-type","content-length"]),BE=Object.freeze(["authorization","cookie","proxy-authorization"]);function jE(e,t,n){if(!t&&!n)return e;let r=new Headers(e);if(t)for(let o of zE)r.delete(o);if(n)for(let o of BE)r.delete(o);return r}async function WE(e,t,n,r,o,i){if(o.failEarly&&e.status>=400)return await ki(e),dt(i,22,`The requested URL returned error: ${e.status}`);if(o.head)return await ki(e),Sh(n,null,r,i);let s=await wh(e,t,o.timeout);return s.failed?dt(i,s.failed.code,s.failed.message):Sh(n,s.bytes,r,i)}function Sh(e,t,n,r){return n!==null?qE(n,e,t,r):(e!==""&&r.events.push({fd:1,text:e}),t!==null&&t.length>0&&r.events.push({fd:1,bytes:t}),!0)}function qE(e,t,n,r){let{ctx:o}=r;if(e==="")return dt(r,23,"Remote filename has no length");let i;try{i=o.writable&&o.fs.openWritable?.(o.cwd,e)}catch(s){return dt(r,23,`Failure writing output to destination: ${s.message}`)}return i?(i.writeBytes(Ze([I(t),n??new Uint8Array])),!0):hn(r,"feature","read-only target",23,`${e}: file system is read-only`)}function HE(e,t){t.notes?.add("curl: response header names are lowercased and sorted, and the status line reads HTTP/1.1 whatever the connection spoke.");let n=[`HTTP/1.1 ${e.status}${e.statusText===""?"":` ${e.statusText}`}`],r=e.headers.getSetCookie?.()??[],o=!1;for(let[i,s]of e.headers){if(i!=="set-cookie"){n.push(`${i}: ${s}`);continue}if(r.length===0){n.push(`${i}: ${s}`);continue}if(!o){o=!0;for(let a of r)n.push(`${i}: ${a}`)}}return n.join(`\r
139
+ `)+`\r
140
+ \r
141
+ `}var Nh={...ap,...ah,...ch,...ih},Oh=Object.freeze({__proto__:null,curl:Ah}),eu=Object.freeze(Object.keys(Oh)),tu=e=>e===!0&&fh()?Oh:null;var vi,pt;function Ih(e){vi||(vi=Array.from({length:256},(n,r)=>r.toString(16).padStart(2,"0")));let t=e.length;if(et){if(!pt){pt=new Uint16Array(256);let o=new Uint8Array(pt.buffer,pt.byteOffset,pt.byteLength);for(let i=0;i<256;i++){let s=vi[i];o[2*i]=s.charCodeAt(0),o[2*i+1]=s.charCodeAt(1)}}let n=new Uint16Array(t),r=0;for(let o=e.length-3;!(r>=o);r+=4){let i=e[r],s=e[r+1],a=e[r+2],u=e[r+3];n[r]=pt[i],n[r+1]=pt[s],n[r+2]=pt[a],n[r+3]=pt[u]}for(;r<t;r++)n[r]=pt[e[r]];return Tn(n)}return pc(e,0,t,vi)}var{toHex:Th}=Uint8Array.prototype;function Ch(e){return On(e),e.length===0?"":Th&&e.toHex===Th?e.toHex():Ih(e)}var XE=new Uint8Array;function Ei(e,t,n,r,o){let i=_h(e,o.skip,o.skipFlag,0),s=_h(e,o.len,o.lenFlag,Number.POSITIVE_INFINITY);if(i.error||s.error)return{error:i.error??s.error};let a=s.value,u=i.value,l=0,c=n,f=r.stdinBytes,d=[],p={stderr:"",failed:!1};for(let g of t.length?t:[null]){let w=ae(e,g===null?[]:[g],c,r,{read:"loose-bytes",noRead:a===0&&u===0}),y=w.entries[0]?.kind==="dir";if(p.stderr+=w.stderr,p.failed||=w.failed&&!(e==="hexdump"&&y),u&&y)return{error:v("feature",e,"skip across unreadable input",`${e}: skipping across a directory operand is not supported`)};if(y&&e==="xxd")return{error:b(p.stderr,2)};if(!w.inputs.length&&!y)continue;let $=w.inputs[0],S=$&&($.shared||$.name===null);if(e==="hexdump"&&u&&S&&!r.stdinFile)return z(r,c,!0,f),{error:b("hexdump: standard input: Illegal seek")};let _=S&&r.stdinFile&&o.skip!==void 0&&(e==="xxd"||e==="hexdump"&&i.value>0),W=_?T(r.stdinOrigin):$?.bytes??XE,H=Math.min(u,W.length);u-=H,l+=H;let re=Math.min(a,W.length-H);if(d.push(W.subarray(H,H+re)),a-=re,S){let le=W.subarray(H+re),ce=f!==null&&!_&&le.length>0?le:null;c=ce===null?G(le):ve(le)??"",z(r,c,!0,ce)}if(_&&u&&(l=i.value,u=0),a===0&&u===0)break}if(u&&o.skipPastEofErrors)return{error:b(p.stderr+`${e}: cannot skip past end of combined input`)};let h=new Uint8Array(d.reduce((g,w)=>g+w.length,0)),m=0;for(let g of d)h.set(g,m),m+=g.length;return{bytes:h,start:l,r:p}}function _h(e,t,n,r){if(t===void 0)return{value:r};if(e==="xxd"&&!/^(?:0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.test(t))return{error:v("feature",e,`${n} ${t}`,`xxd: this offset/count spelling is not supported: ${t}`)};if(e==="hexdump")return/^[ \t\n\r\v\f]*[+\d-]/u.test(t)?!/^\d+$/u.test(t)||/^0\d/u.test(t)?{error:v("feature",e,`${n} ${t}`,`hexdump: this offset/count spelling is not supported: ${t}`)}:BigInt(t)>BigInt(Number.MAX_SAFE_INTEGER)?{error:v("feature",e,"large byte count","hexdump: counts beyond exact integer precision are not supported")}:{value:Number(t)}:{error:b(`${e}: ${n}: invalid count: ${t}`)};let o=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(t);if(!o)return{error:b(`${e}: ${n}: invalid count: ${t}`)};let i=/^0\d/u.test(o[1])?"0o"+o[1].slice(1):o[1];return ia(BigInt(i),o[2],`${e}: ${n}`,t)}var Xr=16,ZE=47,YE=39;function Rh(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["C","v"],valueShort:["n","s"]});if(i.includes("-"))return v("feature","hexdump","hyphen input operand","hexdump: a hyphen input operand is not supported; omit operands to read stdin");let s=Ei("hexdump",i,e,n,{skip:o.get("s"),len:o.get("n"),skipFlag:"-s",lenFlag:"-n"});return s.error?s.error:ue(nu(s.bytes,s.start,r.has("v"),r.has("C")?KE:VE),s.r)}function Mh(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["v"],valueShort:["j","N"]});if(!r.size&&!o.size&&(i.length===1&&/^\+\d/u.test(i[0])||i.length===2&&/^\+?\d/u.test(i[1])))return v("feature","od","legacy offset operand","od: legacy offset operands are not supported; use -j OFFSET");let s=Ei("od",i,e,n,{skip:o.get("j"),len:o.get("N"),skipFlag:"-j",lenFlag:"-N",skipPastEofErrors:!0});return s.error?s.error:ue(nu(s.bytes,s.start,r.has("v"),JE),s.r)}function Dh(e,t,n){let{values:r,positional:o}=N(t,{valueShort:["s","l"]});if(o.length>2)return b("xxd: too many operands");if(o.length===2&&o[1]!=="-")return v("feature","xxd","output file","xxd: output files are not supported (filesystem is read-only)");let i=Ei("xxd",o.slice(0,1),e,n,{skip:r.get("s"),len:r.get("l"),skipFlag:"-s",lenFlag:"-l"});return i.error?i.error:ue(nu(i.bytes,i.start,!1,QE),i.r)}function nu(e,t,n,r){let o=r.hex?Ch(e):"",i=[],s=null,a=!1;for(let l=0;l<e.length;l+=Xr){let c=e.subarray(l,l+Xr),f=r.hex?o.slice(l*2,(l+Xr)*2):"";r.compress&&!n&&s!==null&&c.length===Xr&&n$(c,s)?a||(i.push("*"),a=!0):(i.push(r.row(t+l,c,f)),a=!1),s=c}let u=t+e.length;return(r.trailer==="always"||r.trailer==="nonzero"&&u>0)&&i.push(r.addr(u)),Ee(i)}var VE={compress:!0,trailer:"nonzero",addr:Lh,row:(e,t)=>(Lh(e)+" "+Uh(t).map(r$).join(" ")).padEnd(ZE)},KE={compress:!0,trailer:"nonzero",addr:ru,hex:!0,row:e$},JE={compress:!0,trailer:"always",addr:Fh,row:(e,t)=>Fh(e)+" "+Uh(t).map(o$).join(" ")},QE={compress:!1,trailer:"never",hex:!0,row:(e,t,n)=>`${ru(e)}: ${t$(t,n).join(" ").padEnd(YE)} ${Ph(t)}`};function Lh(e){return e.toString(16).padStart(7,"0")}function ru(e){return e.toString(16).padStart(8,"0")}function Fh(e){return e.toString(8).padStart(7,"0")}function e$(e,t,n){let r=[];for(let s=0;s<Xr;s++)r.push(s<t.length?n.slice(s*2,s*2+2):" ");let o=r.slice(0,8).join(" "),i=r.slice(8).join(" ");return`${ru(e)} ${o} ${i} |${Ph(t)}|`}function Uh(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(n+1<e.length?e[n]|e[n+1]<<8:e[n]);return t}function t$(e,t){let n=[];for(let r=0;r<e.length;r+=2)n.push(t.slice(r*2,r*2+4));return n}function Ph(e){let t="";for(let n of e)t+=n>=32&&n<=126?String.fromCodePoint(n):".";return t}function n$(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}var r$=e=>e.toString(16).padStart(4,"0"),o$=e=>e.toString(8).padStart(6,"0");var i$=76;function $i(e,{encode:t,decode:n}){return(r,o,i)=>{let{flags:s,positional:a,order:u}=N(o,{short:["d","i"],long:["decode","ignore-garbage"],valueShort:["w"],valueLong:["wrap"]}),l=i$;for(let{name:p,value:h}of u){if(p!=="w"&&p!=="wrap")continue;if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(h)||BigInt(h)<0n)return b(`${e}: invalid wrap size: ${h}`);let m=BigInt(h);l=m>ge?0:Number(m)}if(a.length>1)return b(`${e}: extra operand: ${a[1]}`);let c=ae(e,a,r,i,{read:"as-held"});if(c.failed)return b(c.stderr);let{content:f,bytes:d}=c.inputs[0];return s.has("d")||s.has("decode")?a$(e,n(f??Ys(d),s.has("i")||s.has("ignore-garbage"))):s$(t(d??I(f)),l)}}function s$(e,t){if(!t||e==="")return R(e);let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return R(n.join(`
142
+ `)+`
143
+ `)}function a$(e,{bytes:t,valid:n}){let r=ve(t),o=n?"":`${e}: invalid input
144
+ `;if(r!==void 0&&n)return R(r);let i=r===void 0?{fd:1,bytes:t}:{fd:1,text:r};return{stdout:r??"",stderr:o,exitCode:n?0:1,events:[...t.length?[i]:[],...o?[{fd:2,text:o}]:[]]}}var zh=[{},{},{}],Bh=[[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],[..."0123456789ABCDEFGHIJKLMNOPQRSTUV"],[..."0123456789ABCDEFGHJKMNPQRSTVWXYZ"]],mn="Invalid character in base32 input",ou="Invalid base32 padding",u$="Invalid base32 length",Si="Invalid last chunk",l$=Kt;function jh(e,t,n){On(e);let r=Math.floor(e.length/5),o=r*5,i="",s=0,a=Bh[t],u=zh[t];if(!u.pairs)if(u.pairs=[],et){u.codepairs=new Uint16Array(1024);let p=u.codepairs,h=new Uint8Array(p.buffer,p.byteOffset,p.byteLength);for(let m=0;m<32;m++){let g=a[m].charCodeAt(0);for(let w=0;w<32;w++)h[m<<6|w<<1]=h[w<<6|(m<<1)+1]=g}}else{let p=u.pairs;for(let h=0;h<32;h++)for(let m=0;m<32;m++)p.push(`${a[h]}${a[m]}`)}let{pairs:l,codepairs:c}=u;if(et){let p=new Uint16Array(r*4);for(let h=0;s<o;s+=5){let m=e[s],g=e[s+1],w=e[s+2],y=e[s+3],$=e[s+4],S=m<<2|g>>6,_=(g&63)<<4|w>>4,W=(w&15)<<6|y>>2,H=(y&3)<<8|$;p[h]=c[S],p[h+1]=c[_],p[h+2]=c[W],p[h+3]=c[H],h+=4}i=Tn(p)}else if(l$)for(;s<o;s+=5){let p=e[s],h=e[s+1],m=e[s+2],g=e[s+3],w=e[s+4],y=p<<2|h>>6,$=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,_=(g&3)<<8|w;i+=`${l[y]}${l[$]}${l[S]}${l[_]}`}else for(;s<o;s+=5){let p=e[s],h=e[s+1],m=e[s+2],g=e[s+3],w=e[s+4],y=p<<2|h>>6,$=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,_=(g&3)<<8|w;i+=l[y],i+=l[$],i+=l[S],i+=l[_]}let f=0,d=3;for(;s<e.length;s++){let p=e[s];i+=a[f|p>>d],d>=5&&(d-=5,i+=a[p>>d&31]),f=p<<5-d&31,d+=3}return d!==3&&(i+=a[f]),n&&(i+=["","======","====","===","="][e.length-o]),i}var c$=Xe?128:65536;function Wh(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,o=n%8,i=n-o;if(![0,2,4,5,7].includes(o))throw new SyntaxError(u$);if(r>7||r!==0&&e.length%8!==0)throw new SyntaxError(ou);let s=Bh[t],a=zh[t];if(!a.fromMap){a.fromMap=new Int8Array(c$).fill(-1);let g=a.fromMap;s.forEach((w,y)=>{g[w.charCodeAt(0)]=g[w.toLowerCase().charCodeAt(0)]=y}),t===2&&(g[73]=g[76]=g[105]=g[108]=g[49],g[79]=g[111]=g[48])}let u=a.fromMap,l=new Uint8Array(Math.floor(n*5/8)),c=0,f=0;if(Xe){let g=wr(e,mn);for(;f<i;f+=8){let w=g[f],y=g[f+1],$=g[f+2],S=g[f+3],_=g[f+4],W=g[f+5],H=g[f+6],re=g[f+7],le=u[w]<<15|u[y]<<10|u[$]<<5|u[S],ce=u[_]<<15|u[W]<<10|u[H]<<5|u[re];if(le<0||ce<0)throw new SyntaxError(mn);l[c]=le>>12,l[c+1]=le>>4&255,l[c+2]=le<<4&255|ce>>16,l[c+3]=ce>>8&255,l[c+4]=ce&255,c+=5}}else for(;f<i;f+=8){let g=e.charCodeAt(f),w=e.charCodeAt(f+1),y=e.charCodeAt(f+2),$=e.charCodeAt(f+3),S=e.charCodeAt(f+4),_=e.charCodeAt(f+5),W=e.charCodeAt(f+6),H=e.charCodeAt(f+7),re=u[g]<<15|u[w]<<10|u[y]<<5|u[$],le=u[S]<<15|u[_]<<10|u[W]<<5|u[H];if(re<0||le<0)throw new SyntaxError(mn);l[c]=re>>12,l[c+1]=re>>4&255,l[c+2]=re<<4&255|le>>16,l[c+3]=le>>8&255,l[c+4]=le&255,c+=5}if(o<2)return l;let d=u[e.charCodeAt(f++)]<<5|u[e.charCodeAt(f++)];if(d<0)throw new SyntaxError(mn);if(l[c++]=d>>2,o<4){if(d&3)throw new SyntaxError(Si);return l}let p=u[e.charCodeAt(f++)]<<5|u[e.charCodeAt(f++)];if(p<0)throw new SyntaxError(mn);if(l[c++]=d<<6&255|p>>4,o<5){if(p&15)throw new SyntaxError(Si);return l}let h=u[e.charCodeAt(f++)];if(h<0)throw new SyntaxError(mn);if(l[c++]=p<<4&255|h>>1,o<7){if(h&1)throw new SyntaxError(Si);return l}let m=u[e.charCodeAt(f++)]<<5|u[e.charCodeAt(f++)];if(m<0)throw new SyntaxError(mn);if(l[c++]=h<<7&255|m>>3,m&7)throw new SyntaxError(Si);return l}function qh(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Co);if(o!==null&&zo(o),n===!0){if(e.length%8!==0)throw new SyntaxError(ou)}else if(n===!1){if(e.endsWith("="))throw new SyntaxError("Did not expect padding in base32 input")}else if(n!=="both")throw new TypeError("Invalid padding option");return Jt(Wh(e,t),r)}var iu=e=>(t,n)=>{if(!n)return qh(t,e,"both","uint8",null);let{format:r="uint8",padding:o="both",...i}=n;return qh(t,e,o,r,i)},Hh=iu(0),lR=iu(1),cR=iu(2),Gh=(e,{padding:t=!1}={})=>jh(e,0,t);var d$="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",Zr=8,p$=Object.freeze([2,4,5,7,8]),Xh=$i("base32",{encode:e=>Gh(e,{padding:!0}),decode:m$}),h$=/[a-z]/u;function m$(e,t=!1){let n=e.replace(t?/[^A-Z2-7=]/gu:/\n/gu,"");try{let r=Hh(n,{padding:!0});if(!h$.test(n))return{bytes:r,valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r}return g$(n)}function g$(e){let t=new Uint8Array(Math.ceil(e.length/Zr)*5),n=0,r=0,o=!0;for(;r<e.length;){if(e.length-r<Zr){o=!1;break}let i=e.slice(r,r+Zr),s=/^[A-Z2-7]*/u.exec(i)[0];if(n+=w$(i,s,t.subarray(n)),!p$.includes(s.length)||i.slice(s.length)!=="=".repeat(Zr-s.length)){o=!1;break}r+=Zr}return{bytes:t.subarray(0,n),valid:o}}function w$(e,t,n){let r=0,o=0,i=0;for(let s of t)o=o<<5|d$.indexOf(s),r+=5,!(r<8)&&(r-=8,n[i++]=o>>r&255);return i}var su="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zh=$i("base64",{encode:kr,decode:y$});function y$(e,t=!1){let n=e.replace(t?/[^A-Za-z0-9+/=]/gu:/\n/gu,"");try{return{bytes:vr(n,{padding:!0}),valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r;return x$(n)}}function x$(e){let t=new Uint8Array(Math.ceil(e.length/4)*3),n=/[A-Za-z0-9+/]*/uy,r=0,o=0,i=!0;for(;o<e.length;){n.lastIndex=o;let s=n.exec(e)[0].length,a=s-s%4;if(a){let p=vr(e.slice(o,o+a));t.set(p,r),r+=p.length,o+=a}if(o===e.length)break;let u=s%4;if(u<2){i=!1;break}let l=su.indexOf(e[o]),c=su.indexOf(e[o+1]),f=u===3?su.indexOf(e[o+2]):0;t[r++]=l<<2|c>>4,u===3&&(t[r++]=c<<4|f>>2);let d=4-u;if(o+=u,e.slice(o,o+d)!=="=".repeat(d)){i=!1;break}o+=d}return{bytes:t.subarray(0,r),valid:i}}var b$=["n","N","i","s","w","F","v","l","c","q","u","a","H","I"],k$=["line-number","no-line-number","ignore-case","case-sensitive","word-regexp","fixed-strings","invert-match","files-with-matches","files-without-match","count","quiet","hidden","no-ignore","no-heading","with-filename","no-filename","text","unrestricted"],Vh={short:b$,long:k$,valueShort:["A","B","C"],valueLong:["after-context","before-context","context"],repeatable:["e","regexp"]},v$=new Map(Object.entries({"line-number":"n","no-line-number":"N","ignore-case":"i","case-sensitive":"s","word-regexp":"w","fixed-strings":"F","invert-match":"v","files-with-matches":"l","files-without-match":"L",count:"c",quiet:"q",text:"a",unrestricted:"u","with-filename":"H","no-filename":"I",regexp:"e","after-context":"A","before-context":"B",context:"C"})),E$=new Set(["no-heading","no-ignore"]),Yr=(e,t)=>new x("feature",e,`rg: ${t}`);function Kh(e){let t={patterns:[],context:[],mode:null,showName:null,ignoreCase:!1,lineNumbers:!1,word:!1,literal:!1,invert:!1,quiet:!1,text:!1,hidden:!1,unrestricted:0};for(let{name:o,value:i}of e.order)E$.has(o)||$$(t,v$.get(o)??o,i,au(o));let n=o=>t.context.findLast(([i])=>i===o)?.[1],r=o=>t.context.findLast(([i])=>i===o)?.[2]??"-"+o;if(t.after=Yh(n("A")??n("C"),n("A")===void 0?r("C"):r("A")),t.before=Yh(n("B")??n("C"),n("B")===void 0?r("C"):r("B")),t.unrestricted>=2&&(t.hidden=!0),t.unrestricted>=3)throw Yr("-uuu","searching binary files is not supported");return t}function $$(e,t,n,r){switch(t){case"i":e.ignoreCase=!0;return;case"s":e.ignoreCase=!1;return;case"n":e.lineNumbers=!0;return;case"N":e.lineNumbers=!1;return;case"l":case"L":case"c":e.mode=t;return;case"H":e.showName="H";return;case"I":e.showName="h";return;case"w":e.word=!0;return;case"F":e.literal=!0;return;case"v":e.invert=!0;return;case"q":e.quiet=!0;return;case"a":e.text=!0;return;case"e":e.patterns.push(n);return;case"hidden":e.hidden=!0;return;case"u":e.unrestricted++;return;case"A":case"B":case"C":e.context.push([t,n,r]);return;default:throw Yr(au(t),`${au(t)} is not supported`)}}function Yh(e,t){if(e===void 0)return 0;if(!/^\d+$/u.test(e))throw Yr(`${t} value`,`error parsing flag ${t}: value is not a valid number`);return Number(e)}var au=e=>(e.length===1?"-":"--")+e;function Jh(e,t){return t?e.flatMap(n=>["-e",n]):["-e",e.length===1?e[0]:e.map(n=>`(?:${n})`).join("|")]}var S$=[[/\\[1-9]/u,"backreference"],[/\(\?<?[=!]/u,"look-around"],[/\\[QE]/u,"\\Q\u2026\\E literal span"]];function A$(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`
145
+ `)return!0;if(n!=="\\")continue;let r=e[t+1];if(r==="n"||r==="x"&&/^x\{?0*a\}?/iu.test(e.slice(t+1)))return!0;t++}return!1}function Qh(e,t){if(!t)for(let n of e){for(let[r,o]of S$)if(r.test(n))throw Yr(o,`${o} is not supported; ripgrep's regex engine rejects it too`);if(A$(n))throw Yr("newline in a pattern","a newline in a pattern is not supported; ripgrep rejects one outside multiline mode")}}var A=class extends Error{constructor(t,n=null,r=null,o="syntax error"){super(t),this.line=n,this.gap=r,this.kind=o}},e1=new Set(["BEGIN","END","BEGINFILE","ENDFILE","function","func","if","else","while","for","do","break","continue","next","nextfile","exit","return","delete","in","getline","print","printf","switch","case","default"]),uu={__proto__:null,length:[0,1],substr:[2,3],index:[2,2],split:[2,3],sub:[2,3],gsub:[2,3],gensub:[3,4],match:[2,3],sprintf:[1,1/0],sin:[1,1],cos:[1,1],atan2:[2,2],exp:[1,1],log:[1,1],sqrt:[1,1],int:[1,1],rand:[0,0],srand:[0,1],tolower:[1,1],toupper:[1,1],close:[1,2],fflush:[0,1],systime:[0,0],strtonum:[1,1],and:[2,1/0],or:[2,1/0],xor:[2,1/0],lshift:[2,2],rshift:[2,2],compl:[1,1],typeof:[1,1],isarray:[1,1]},Ai=new Map([["system","system() is not supported: this terminal runs no processes"],["strftime","strftime() is not supported (gawk extension)"],["mktime","mktime() is not supported (gawk extension)"],["asort","asort() is not supported (gawk extension)"],["asorti","asorti() is not supported (gawk extension)"],["patsplit","patsplit() is not supported (gawk extension)"]]),t1=new Set([...Object.keys(uu),...Ai.keys()]),Vr=5e6,lu=100,Me=1e6,Ni="this terminal runs no processes";function Oi(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;default:return t**n}}var n1={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},N$='^$.[]|()*+?{}\\/"',cu=1e3,r1=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),o1=e=>e!==void 0&&e>="0"&&e<="7",fu=class{constructor(t,n,r,o){this.src=t,this.i=0,this.warn=n,this.tables=r,this.ignoreCase=o,this.groups=0}fail(t){throw new A(`invalid regex /${this.src}/: ${t}`)}peek(){return this.src[this.i]}literal(){let t=this.src.codePointAt(this.i);return this.i+=Ve(t),this.charNode(t)}charNode(t){let n=this.ignoreCase?this.tables.fold(t):[t];return n.length===1?{type:"char",code:t}:{type:"set",negate:!1,items:n.map(r=>[r,r])}}parse(){return this.alternation(0)}alternation(t){let n=[this.concatenation(t)];for(;this.peek()==="|";)this.i++,n.push(this.concatenation(t));return n.length===1?n[0]:{type:"alt",nodes:n}}concatenation(t){let n=[];for(;!this.endsConcatenation(t);)n.push(this.quantified(this.atom(n.length===0,t)));return n.length===1?n[0]:{type:"cat",nodes:n}}endsConcatenation(t){let n=this.peek();return n===void 0||n==="|"||n===")"&&t>0}quantified(t){let n=t;for(;;){let r=this.peek();if(r==="*"){this.i++,n={type:"rep",node:n,min:0,max:null};continue}if(r==="+"){this.i++,n={type:"rep",node:n,min:1,max:null};continue}if(r==="?"){this.i++,n={type:"rep",node:n,min:0,max:1};continue}if(r==="{"){let o=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!o&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail("invalid content of {}"),!o||o[1]===""&&o[2]===void 0)return n;let i=o[1]===""?0:Number(o[1]),s=o[2]===void 0?i:o[3]===""?null:Number(o[3]);if(s!==null&&s<i&&this.fail(`invalid interval {${i},${s}}`),i>cu||s!==null&&s>cu)throw new A(`interval count above ${cu} is not supported`,null,"regex interval limit");this.i+=o[0].length,n={type:"rep",node:n,min:i,max:s};continue}return n}}atom(t,n){let r=this.peek();if(r==="("){this.i++;let o=++this.groups,i=this.alternation(n+1);return this.peek()!==")"&&this.fail("missing `)`"),this.i++,{type:"group",index:o,node:i}}return r==="["?this.bracket():r==="\\"?this.escape():(this.i++,r==="."?{type:"any"}:r==="^"||r==="$"?{type:"assert",kind:r}:((r==="*"||r==="+"||r==="?")&&!t&&this.fail(`unexpected \`${r}\``),this.i--,this.literal()))}escape(){this.i++;let t=this.peek();return t===void 0&&this.fail("trailing backslash"),this.i++,t==="y"?{type:"assert",kind:"y"}:t==="<"||t===">"||t==="B"?{type:"assert",kind:t}:t==="`"?{type:"assert",kind:"^"}:t==="'"?{type:"assert",kind:"$"}:t==="s"||t==="S"?{type:"set",negate:t==="S",items:this.tables.ranges("space")}:t==="w"||t==="W"?{type:"set",negate:t==="W",items:this.tables.ranges("word")}:(t==="b"&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(t,!0)))}escapedCode(t,n){if(t in n1)return n1[t];if(o1(t)){let o=t;for(;o.length<3&&o1(this.peek());)o+=this.src[this.i++];return i1(o,8)}if(t==="x"&&r1(this.peek())){let o="";for(;o.length<2&&r1(this.peek());)o+=this.src[this.i++];return i1(o,16)}let r=this.src.codePointAt(this.i-1);return!N$.includes(t)&&n&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(r)}' is not a known regexp operator`),this.i+=Ve(r)-1,r}bracket(){this.i++;let t=!1;this.peek()==="^"&&(t=!0,this.i++);let n=[],r=!0;for(;;){this.i>=this.src.length&&this.fail("unterminated bracket expression");let o=this.peek();if(o==="]"&&!r){this.i++;break}if(r=!1,o==="["&&this.src[this.i+1]===":"){let s=this.src.indexOf(":]",this.i+2);if(s!==-1){let a=this.src.slice(this.i+2,s),u=this.tables.ranges(this.ignoreCase?Yo(a):a);u===void 0&&this.fail(`invalid character class \`[:${a}:]\``),n.push(...u),this.i=s+2;continue}}let i=this.bracketChar();if(this.peek()==="-"&&this.src[this.i+1]!=="]"&&this.src[this.i+1]!==void 0){this.i++;let s=this.bracketChar(),a=this.ignoreCase?this.tables.foldRange(i,s):s<i?null:[[i,s]];a===null&&this.fail("invalid range end"),n.push(...a)}else this.ignoreCase?n.push(...this.tables.fold(i).map(s=>[s,s])):n.push([i,i])}return{type:"set",negate:t,items:n}}bracketChar(){let t=this.peek();if(t==="["&&(this.src[this.i+1]==="."||this.src[this.i+1]==="=")){let r=this.src.indexOf(this.src[this.i+1]+"]",this.i+2);if(r!==-1&&r>this.i+2){Array.from(this.src.slice(this.i+2,r)).length!==1&&this.fail("invalid collation character");let o=this.src.codePointAt(this.i+2);return this.i=r+2,o}}if(t==="\\"){this.i++,this.peek()===void 0&&this.fail("trailing backslash");let r=this.src[this.i++];return this.escapedCode(r,!1)}let n=this.src.codePointAt(this.i);return this.i+=Ve(n),n}};function Ti(e,t=null,n=se(ie),r=!1){let o=new fu(e,t,n,r);return{ast:o.parse(),groups:o.groups}}function i1(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new A("non-ASCII regex byte escapes are not supported",null,"regex byte escapes");return n}var O$=e=>`\\u{${e.toString(16)}}`,Ii=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):O$(e);function I$(e,t){if(e==="^"||e==="$")return e;let n=t.assertions();return e==="y"?n.boundary:e==="B"?n.inside:n[e]}function du(e,t=se(ie)){let n=r=>du(r,t);switch(e.type){case"char":return Ii(e.code);case"any":return".";case"set":return`[${e.negate?"^":""}${e.items.map(([r,o])=>r===o?Ii(r):`${Ii(r)}-${Ii(o)}`).join("")}]`;case"assert":return I$(e.kind,t);case"group":return`(${n(e.node)})`;case"cat":return e.nodes.map(n).join("");case"alt":return`(?:${e.nodes.map(n).join("|")})`;case"rep":{let r=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${r}*`:e.min===1?`${r}+`:`${r}{${e.min},}`:e.min===0&&e.max===1?`${r}?`:`${r}{${e.min},${e.max}}`}default:throw new A(`internal: unknown regex node ${e.type}`)}}var T$=5e4;function C$(e,t){let n=r=>{for(let o=0;o<e.length;o++)if(r>=e[o][0]&&r<=e[o][1])return!0;return!1};return t?r=>!n(r):n}function Ci(e,t=se(ie)){let n=[],r=l=>{if(n.length>=T$)throw new A("regex too large",null,"regex state limit");return n.push(l),n.length-1};function o(l,c){switch(l.type){case"char":return r({op:"char",codes:[l.code],next:c});case"any":return r({op:"any",next:c});case"set":return r({op:"set",test:C$(l.items,l.negate),next:c});case"assert":return r({op:"assert",kind:l.kind,next:c});case"group":return o(l.node,c);case"cat":{let f=c;for(let d=l.nodes.length-1;d>=0;d--)f=o(l.nodes[d],f);return f}case"alt":{let f=l.nodes.map(p=>o(p,c)),d=f.at(-1);for(let p=f.length-2;p>=0;p--)d=r({op:"split",x:f[p],y:d});return d}case"rep":return i(l,c);default:throw new A(`internal: unknown regex node ${l.type}`)}}function i(l,c){let f=c;if(l.max===null){let d=r({op:"split",x:-1,y:c});n[d].x=o(l.node,d),f=d}else for(let d=l.max-l.min;d>0;d--)f=r({op:"split",x:o(l.node,f),y:c});for(let d=0;d<l.min;d++)f=o(l.node,f);return f}let s=o(e,r({op:"match"})),a="",u=s;for(;n[u].op==="char"&&n[u].codes.length===1&&n[u].codes[0]<128;)a+=String.fromCodePoint(n[u].codes[0]),u=n[u].next;return(n[u].op!=="match"||a==="")&&(a=null),{states:n,start:s,literal:a,isWord:l=>t.has("word",l),gen:new Int32Array(n.length).fill(-1),stamp:0}}function _$(e,t){if(t<=0)return-1;let n=e.codePointAt(t-1);if(n<56320||n>57343||t<2)return n;let r=e.codePointAt(t-2);return r>65535?r:n}function L$(e,t,n,r){if(e==="^")return n===0;if(e==="$")return n===t.length;let o=r(_$(t,n)),i=n<t.length&&r(t.codePointAt(n));return e==="y"?o!==i:e==="B"?o===i:e==="<"?!o&&i:o&&!i}function F$(e,t){return e.op==="char"?e.codes.includes(t):e.op==="any"?!0:e.test(t)}function _i(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let p=t.indexOf(e.literal,n);return p<0?null:{start:p,end:p+e.literal.length}}let{states:r,gen:o}=e,i=t.length,s=[],a=(p,h,m,g,w)=>{for(s.push(h);s.length>0;){let y=s.pop();if(o[y]===w)continue;o[y]=w;let $=r[y];$.op==="split"?s.push($.y,$.x):$.op==="assert"?L$($.kind,t,g,e.isWord)&&s.push($.next):p.push(y,m)}},u=[],l=[],c=null,f=n,d=++e.stamp;for(;;){c===null&&a(u,e.start,f,f,d);let p=f<i?t.codePointAt(f):-1,h=Ve(p);if(u.length===0){if(c!==null||f>=i)break;f+=h,d=++e.stamp;continue}let m=++e.stamp;for(let g=0;g<u.length;g+=2){let w=u[g],y=u[g+1];if(c!==null&&y>c.start)continue;let $=r[w];if($.op==="match"){(c===null||y<c.start||y===c.start&&f>c.end)&&(c={start:y,end:f});continue}p!==-1&&F$($,p)&&a(l,$.next,y,f+h,m)}if(u.length=0,[u,l]=[l,u],d=m,f>=i)break;f+=h}return c}var Li=new Map,Ot=class{constructor(t,n,r,o=se(ie)){let{ast:i,groups:s}=Ti(t,r,o,n);this.src=t,this.ignoreCase=n,this.tables=o,this.groupCount=s,this.source=du(i,o),this.flags="su";try{this.js=new RegExp(Un(this.source),this.flags)}catch(a){throw new A(`cannot compile regex /${t}/: ${a.message}`,null,"regex engine limit")}this.ast=i,this.nfa=null,this.capture=null,this.captureShape=s1(i)}test(t){return this.checkCase(t),this.js.test(t)}checkCase(t){if(this.ignoreCase&&on.test(t+this.src))throw new A("case-insensitive matching over Cyrillic Extended-C letters is not supported",null,"locale-sensitive regex")}search(t,n=0){return this.checkCase(t),this.nfa===null&&(this.nfa=Ci(this.ast,this.tables)),_i(this.nfa,t,n)}groups(t,n,r){if(this.captureShape.unsafe)throw new A("capture extraction across repeated or alternative groups is not supported",null,"regex capture semantics");let o=this.capture??=new RegExp(this.source,this.flags+"dy");o.lastIndex=n;let i=o.exec(t);if(!i||i.index!==n||n+i[0].length!==r){let s=Array.from(t.slice(r)).length,a=new RegExp(`(?:${this.source})(?=.{${s}}(?![^]))`,this.flags+"dy");a.lastIndex=n,i=a.exec(t)}if(!i)throw new A("capture extraction for this match is not supported",null,"regex capture semantics");return i.indices.map((s,a)=>s===void 0?void 0:{text:i[a],start:s[0],end:s[1]})}};function s1(e){let n=(e.nodes??(e.node?[e.node]:[])).map(s1),r=n.reduce((s,a)=>s+a.groups,e.type==="group"?1:0),o=e.type==="assert"||(e.type==="group"||e.type==="cat")&&n.every(s=>s.nullable)||e.type==="alt"&&n.some(s=>s.nullable)||e.type==="rep"&&(e.min===0||n[0].nullable),i=e.type==="rep"&&(e.max===null||e.max>1)&&(r>1||r>0&&n[0].nullable);return{groups:r,nullable:o,unsafe:i||e.type==="alt"&&r>0||n.some(s=>s.unsafe)}}function qe(e,t=!1,n=null,r=se(ie)){let o=(t?"i":"c")+r.name+"\0"+e,i=Li.get(o);if(i)return i;Li.size>=500&&Li.clear();let s=new Ot(e,t,n,r);return Li.set(o,s),s}function pu(e,t,n){for(;;){let r=t.search(e,n);if(!r||r.start!==r.end)return r;if(r.end>=e.length)return null;n=r.end+ze(e,r.end)}}function hu(e,t){let n=[],r=0;for(;;){let o=pu(e,t,r);if(!o)break;n.push(e.slice(r,o.start)),r=o.end}return n.push(e.slice(r)),n}function Kr(e,t,n,r){let o=r!=="first",i=e.length,s="",a=0,u=-1,l=0;for(;a<=i;){let c=t.search(e,a);if(!c)break;let f=c.start===c.end;if(f&&c.start===u&&r!=="nth"){if(c.start>=i)break;let p=ze(e,c.start);s+=e.slice(a,c.start+p),a=c.start+p;continue}l++;let d=n(c.start,c.end,l);if(s+=e.slice(a,c.start)+(d===null?e.slice(c.start,c.end):d),u=c.end,f){if(c.end>=i){a=i;break}let p=ze(e,c.end);s+=e.slice(c.end,c.end+p),a=c.end+p}else a=c.end;if(!o)break}return{out:s+e.slice(a),count:l}}function Fi(e,t){let n="(){}+?|",r=!1,o=0,i=!1,s="";for(let a=0;a<e.length;a++){let u=e[a];if(i){if(u==="["&&(e[a+1]==="."||e[a+1]==="="))throw new x("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");if(u==="["){let l=Fn(e,a,{classes:t});if(l){s+=l.body,a=l.end-1;continue}}s+=u,u==="]"&&(i=!1,r=!0);continue}if(u==="["){s+=u,i=!0,e[a+1]==="^"&&(s+="^",a++),e[a+1]==="]"&&(s+="\\]",a++);continue}if(u==="\\"){let l=e[++a];if(l===void 0)return{error:"trailing backslash (\\)"};if(n.includes(l)){if((l==="+"||l==="?")&&!r){s+="\\"+l,r=!0;continue}if(l==="("&&o++,l===")"&&o--===0)return{error:"Unmatched ) or \\)"};(l==="("||l==="|")&&(r=!1),(l===")"||l==="}")&&(r=!0),s+=l}else s+="^$\\.*[]/bBsSwW<>`'123456789".includes(l)?"\\"+l:l,r=!"bB<>`'".includes(l);continue}if(u==="*"){s+=r?"*":"\\*",r=!0;continue}if(u==="^"){r=!R$(e,a),s+=r?"\\^":"^";continue}if(u==="$"){r=!(a===e.length-1||e[a+1]==="\\"&&(e[a+2]===")"||e[a+2]==="|")),s+=r?"\\$":"$";continue}s+=n.includes(u)?"\\"+u:u,r=!0}return o>0?{error:"Unmatched ( or \\("}:{source:s}}function R$(e,t){if(t===0)return!0;if(t<2||e[t-2]!=="\\"||e[t-1]!=="("&&e[t-1]!=="|")return!1;let n=0;for(let r=t-3;r>=0&&e[r]==="\\";r--)n++;return n%2===0}function Ri(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,o=!1,i=0,s=!1,a=[],u=new Set,l=!1;for(let c=0;c<e.length;c++){let f=e[c];if(f==="\\"){let d=e[++c];if(!o&&/[1-9]/u.test(d??"")){let p=Number(d);if(!t.has(p))throw new Error("Invalid back reference");(!u.has(p)||r.has(p))&&(s=!0)}a=[];continue}if(o){f==="]"&&(o=!1);continue}if(f==="["){o=!0,a=[];continue}if(f==="(")n.push({id:++i,entry:new Set(u),branches:[],start:c}),a=[];else if(f==="|"){let d=n.at(-1);d&&d.branches.push(u),u=new Set(d?.entry),a=[]}else if(f===")"){let d=n.pop();if(!d)continue;u=d.branches.reduce((p,h)=>p.intersection(h),u),u.add(d.id),t.add(d.id),a=[...u.difference(d.entry)],l=M$(e.slice(d.start,c+1))}else if(f==="*"||f==="?"||f==="+"){if(f!=="?"&&l)for(let d of a)r.add(d);if(f!=="+")for(let d of a)u.delete(d)}else if(f==="{"){let d=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(c));if(d){Number(d[1])===0&&(u=u.difference(new Set(a)));let p=d[2]===void 0?Number(d[1]):d[2]===""?1/0:Number(d[2]);l&&p>1&&a.forEach(h=>r.add(h)),c+=d[0].length-1}else a=[]}else a=[]}return s}function M$(e){try{return new RegExp(`^(?:${e})$`,"su").test("")}catch{return!0}}var D$="bBsSwW";function Jr(e,t){let n="";for(let r=0;r<e.length;){let o=e[r];if(o==="["){let l=U$(e,r,t);n+=l.text,r=l.end;continue}let i=o==="\\",s=e.codePointAt(r+(i?1:0)),a=(i?1:0)+Ve(s),u=i&&D$.includes(e[r+1])?null:t.fold(s);n+=u===null||u.length===1?e.slice(r,r+a):`[${String.fromCodePoint(...u)}]`,r+=a}return n}function a1(e,t){let n="";for(let r of e){let o=t.fold(r.codePointAt(0));n+=o.length===1?RegExp.escape(r):`[${String.fromCodePoint(...o)}]`}return n}function U$(e,t,n){let r=t+1,o="[";e[r]==="^"&&(o+="^",r++);let i=!0;for(;;){let s=e[r];if(s==="]"&&!i)return{text:o+"]",end:r+1};if(i=!1,s==="["&&":.=".includes(e[r+1])){let l=e[r+1],c=e.indexOf(l+"]",r+2);o+=l===":"?`[:${Yo(e.slice(r+2,c))}:]`:e.slice(r,c+2),r=c+2;continue}let a=e.codePointAt(r),u=r+Ve(a);if(e[u]==="-"&&e[u+1]!==void 0&&e[u+1]!=="]"){let l=e.codePointAt(u+1),c=u+1+Ve(l);o+=P$(a,l,e.slice(r,c),n),r=c;continue}o+=String.fromCodePoint(...n.fold(a)),r=u}}function P$(e,t,n,r){let o=r.foldRange(e,t);if(o===null)throw new Error("Invalid range end");return o.length===1&&o[0][0]===e&&o[0][1]===t?n:o.map(([i,s])=>i===s?String.fromCodePoint(i):`${String.fromCodePoint(i)}-${String.fromCodePoint(s)}`).join("")}function l1({pattern:e,tables:t},n){return[...e].map(r=>(n?t.fold(r.codePointAt(0)):[r.codePointAt(0)]).map(i=>I(String.fromCodePoint(i))))}function wu(e,t){return t.every(n=>n.literal?(n.literalMask??=l1(n.literal,n.folded),!f1(e,n.literalMask)):!1)}function c1(e,t,n,r=ie){let o=se(r);return t.every(i=>(n||!p1.test(i))&&i.isWellFormed()&&!f1(e,l1({pattern:i,tables:o},!1)))}function f1(e,t){if(t.length===0)return!0;for(let n of new Set(t[0].map(r=>r[0])))for(let r=e.indexOf(n);r>=0&&r+t.length<=e.length;r=e.indexOf(n,r+1))if(d1(e,r,t,0))return!0;return!1}function d1(e,t,n,r){return r===n.length?!0:n[r].some(o=>o.every((i,s)=>e[t+s]===i)&&d1(e,t+o.length,n,r+1))}var p1=/[\\.^$*+?()[\]{}|]/u,z$=new Set("\\.[*^$"),B$=new Set("\\.[*^$+?(){}|");function h1(e,t){if(t.has("F"))return e;if(t.has("P"))return p1.test(e)?null:e;let n=t.has("E")?B$:z$,r="";for(let o=0;o<e.length;o++){let i=e[o]==="\\",s=i?e[++o]:e[o];if(n.has(s)!==i)return null;r+=s}return r}var mu=new Map;function m1(e){if(mu.has(e))return mu.get(e);let t=e.assertions(),n="";for(let i=128;i<=255;i++)e.has("word",i)&&(n+=`\\u${(56320+i).toString(16)}`);let r=na(e.body("word")+n),o={"<":r["<"],">":r[">"],b:r.boundary,B:r.inside,W:Mi(t.nonWord),S:Mi(t.nonSpace)};return mu.set(e,o),o}var Mi=e=>`(?:(?![${nn}])${e})`;function g1(e){let t=Ci(e.ast,e.tables),n=t.states.map(o=>o.op==="any"?{op:"set",test:i=>!_t(i),next:o.next}:o.op==="set"?{...o,test:i=>!_t(i)&&o.test(i)}:o),r={...t,states:n,isWord:o=>e.tables.has("word",_t(o)?o-56320:o)};return{search:(o,i)=>_i(r,o,i)}}var j$=[0,0,0,0,1114112,2097152,67108864],u1=(e,t)=>_t(e.codePointAt(t))?e.codePointAt(t)-56320:-1;function w1(e,t){let n=u1(e,t),r=n===237?3:n>=240&&n<=247?4:n>=248&&n<=251?5:n===252||n===253?6:0,o=n&127>>r;for(let i=1;i<r;i++){let s=u1(e,t+i);if(s<128||s>191)return 0;o=o<<6|s&63}return r===3?o>=55296&&o<=57343?3:0:r&&o>=j$[r]?r:0}function y1(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>65535&&t++,!_t(n))continue;let r=w1(e,t);if(r===0||r===3)return!0;t+=r-1}return!1}var W$=/[\uDCED\uDCF0-\uDCFD][\uDC80-\uDCBF]{2,5}/gu;function x1(e){let t={long:!1,surrogate:!1};for(let[n]of e.matchAll(W$)){let r=w1(n,0);if(r===3?t.surrogate=!0:r&&(t.long=!0),t.long&&t.surrogate)break}return t}function b1(e,t){let n={negated:!1,dot:!1,regex:t,wordEdge:!1};for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"){let i=e[++r]??"";"<>bB".includes(i)&&(n.wordEdge=!0),"<>bBwsWS".includes(i)&&(n.regex=!0),"WS".includes(i)&&(n.negated=!0)}else if(o===".")n.dot=!0;else if(o==="["){let i=Ho(e,r),s=e.slice(r+1,i);s.startsWith("^")&&(n.negated=!0),/\[:|.-./u.test(s.replace(/^\^?\]?/u,""))&&(n.regex=!0),r=i}}return n}function k1(e,t,n){return t.long||t.surrogate?e.wordEdge||(e.dot||e.negated)&&(e.regex||n)?!0:t.long&&e.negated:!1}var gu=new Map;function v1(e){return gu.has(e)||gu.set(e,new RegExp(`[^\\x00-\\x7f${nn}${e.body("word")}]`,"u")),gu.get(e)}function De(e){throw new x("feature","PCRE "+e,`PCRE ${e} is not supported`)}function E1(e){let t={captures:0,closed:new Set,names:new Map,stack:[],behind:0,references:!1,risky:!1},n="";for(let r=0;r<e.length;){let o=e[r];if(o==="\\"){let i=$1(e,r,t,!1);n+=i.source,r=i.end;continue}if(o==="["){let i=G$(e,r,t);n+=i.source,r=i.end;continue}if(o==="("){let i=q$(e,r,t);n+=i.source,r=i.end;continue}if(o===")"){let i=t.stack.pop();i?.capture&&t.closed.add(i.capture),i?.behind&&t.behind--}if("*+?".includes(o)&&(t.behind&&De("variable-length lookbehind"),e[r+1]==="+"&&De("possessive repetition"),o!=="+"&&(t.risky=!0)),o==="|"&&(t.risky=!0),o==="{"){let i=H$(e,r,t);n+=i.source,r=i.end;continue}n+=o==="]"||o==="}"?"\\"+o:o,r++}return t.references&&t.risky&&De("conditional backreference"),n}function q$(e,t,n){let r=!1,o=null,i="(";if(e[t+1]==="*"&&De("control verb"),e[t+1]==="?"){let s=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(s||De("group"),i=s[0],r=i==="(?<="||i==="(?<!",!s[1]&&i!=="(?:"&&(n.risky=!0),s[1]){if(o=++n.captures,n.names.has(s[1]))throw new Error("duplicate PCRE capture name");n.names.set(s[1],o)}}else o=++n.captures;return r&&n.behind++,n.stack.push({capture:o,behind:r}),{source:i,end:t+i.length}}function H$(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&De("repetition"),{source:"\\{",end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&De("variable-length lookbehind"),Number(r[1])>65535||Number(r[2])>65535)throw new Error("PCRE repetition count exceeds 65535");return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]==="+"&&De("possessive repetition"),{source:r[0],end:t+r[0].length}}function G$(e,t,n){let r=t+1,o="[";for(e[r]==="^"&&(o+="^",r++),e[r]==="]"&&(o+="\\]",r++);r<e.length&&e[r]!=="]";)if(e[r]==="["&&":.=".includes(e[r+1]??"")&&De("character class"),e[r]==="\\"){let i=$1(e,r,n,!0);o+=i.source,r=i.end}else o+=e[r]==="["?"\\[":e[r],r++;return{source:o+(e[r]==="]"?"]":""),end:r+1}}function $1(e,t,n,r){let o=e[t+1];if(o===void 0)throw new Error("trailing backslash");if(o==="Q"){let s=e.indexOf("\\E",t+2);return{source:RegExp.escape(e.slice(t+2,s<0?void 0:s)),end:s<0?e.length:s+2}}if(o==="E")return{source:"",end:t+2};if(o==="x"||o==="0"||r&&/[1-7]/u.test(o))return X$(e,t);if(o==="a"||o==="e")return{source:o==="a"?"\\u0007":"\\u001B",end:t+2};if("AzZ".includes(o)&&!r)return{source:o==="A"?"^":"$",end:t+2};if(/[1-9]/u.test(o)&&!r)return(/\d/u.test(e[t+2]??"")||!n.closed.has(Number(o)))&&De("forward or ambiguous backreference"),n.references=!0,{source:"\\"+o,end:t+2};if(o==="k"&&!r){let s=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return(!s||!n.closed.has(n.names.get(s[1])))&&De("named backreference"),n.references=!0,{source:s[0],end:t+s[0].length}}if("dDsSwWfnrtbB".includes(o))return{source:"\\"+o,end:t+2};/[A-Za-z0-9]/u.test(o)&&De("escape \\"+o);let i=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(i),end:t+1+i.length}}function X$(e,t){let n=e[t+1]==="x",r=(n?/^\\x(?:\{([\da-fA-F]+)\}|([\da-fA-F]{1,2}))/u:/^\\([0-7]{1,3})/u).exec(e.slice(t));if(!r)throw new Error("invalid PCRE character escape");let o=n?16:8,i=parseInt(r[1]??r[2],o);return st(i)||De("character escape"),{source:`\\u{${i.toString(16)}}`,end:t+r[0].length}}function xu(e,t){let n="",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"){let s=e[++o]??"";n+=r?i+s:Z$(s);continue}if(r&&i==="["){if(e[o+1]==="."||e[o+1]==="=")throw new x("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");let s=Fn(e,o,{classes:t});if(s){n+=s.body,o=s.end-1;continue}}if(i==="["&&!r){n+="[",r=!0,e[o+1]==="^"&&(n+="^",o++),e[o+1]==="]"&&(n+="\\]",o++);continue}i==="]"&&(r=!1),n+=i}return n}function Z$(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?"\\"+e:RegExp.escape(e)}function Y$(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"){if("bBsSwW<>".includes(e[++t]??""))return!0}else if(".[*+?{".includes(e[t]))return!0;return!1}function gn(e,t="js",n=se(ie)){let r=t==="extent",o=t==="marked",i=r?{b:"\\y"}:o?{...S1(n),...m1(n)}:S1(n),s="",a=!1;for(let u=0;u<e.length;u++){let l=e[u];if(l==="\\"){let c=e[++u];s+=!a&&Object.hasOwn(i,c)?i[c]:l+c,!r&&!a&&/[1-9]/u.test(c)&&/\d/u.test(e[u+1]??"")&&(s+="(?:)")}else if(o&&l==="["){let c=C1(e,u);s+=Mi(e.slice(u,c+1)),u=c}else o&&l==="."?s+=`[^${nn}]`:(l==="["&&(a=!0),l==="]"&&(a=!1),s+=l)}return s}function S1(e){let t=e.assertions();return{"<":t["<"],">":t[">"],b:t.boundary,B:t.inside,w:t.word,W:t.nonWord,s:t.space,S:t.nonSpace,"`":"^","'":"$"}}var bu=e=>e.plain??=new RegExp(e.source,e.flags);function T1(e){return e.markedSource===void 0?bu(e):(e.marked??=new RegExp(Un(gn(e.markedSource,"marked",e.tables)),e.flags),e.marked)}var ku=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,V$=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function A1(e,t,n){let r=(n?ku:V$).exec(e.slice(t));if(!r&&!n)throw new Error("invalid repetition count");r&&sf(Number(r[1]),r[2]===void 0||r[2]===""?void 0:Number(r[2]))}var N1={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function K$(e){if(N1[e])return N1[e];let t=ku.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===""?1/0:Number(t[2])}}var O1=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function J$(e,t){let n=Math.max(t.min,1);if(n>t.max)return{min:0,max:0};if(e.min>0&&(t.min===0&&e.min>1||e.max!==1/0&&t.max>n&&(n+1)*e.min>n*e.max+1))return null;let r=O1(t.max,e.max);return r!==1/0&&r>qo?null:{min:O1(t.min,e.min),max:r}}function yu(e){return e.max===1/0?e.min===0?"*":e.min===1?"+":`{${e.min},}`:e.min===0&&e.max===1?"?":e.min===e.max?`{${e.min}}`:`{${e.min},${e.max}}`}var Q$=e=>!e.startsWith("(")&&!/^\\[1-9]/u.test(e);function eS(e,t){if(t.length===1)return e+yu(t[0].bounds);let n=t[0].bounds,r=null;for(let o=1;o<t.length;o++){let{bounds:i,text:s}=t[o],a=r===null?J$(n,i):null;if(a){n=a;continue}if(!(r===null&&n.min===n.max&&Q$(e))&&i.max>1)throw new Error("stacked quantifier needs ambiguous nesting");r=`(?:${r??e+yu(n)})${s}`}return r??e+yu(n)}function C1(e,t){let n=t+1;for(e[n]==="^"&&n++;n<e.length;n++){if(e[n]==="\\"){n++;continue}if(e[n]==="]")return n}return e.length-1}function I1(e){let t="",n=-1,r=-1,o=[],i=()=>{o.length>0&&(t=t.slice(0,n)+eS(t.slice(n,r),o)),o=[]},s=u=>{i(),n=t.length,r=-1,t+=u},a=[];for(let u=0;u<e.length;u++){let l=e[u];if(l==="\\"){s(l+(e[++u]??""));continue}if(l==="["){let f=C1(e,u);s(e.slice(u,f+1)),u=f;continue}if(l==="("){i(),a.push(t.length),n=-1,t+=l;continue}if(l===")"){i(),t+=l,n=a.pop()??-1,r=-1;continue}if(l==="|"||l==="^"||l==="$"){i(),t+=l,n=-1;continue}let c=l==="{"?ku.exec(e.slice(u)):null;if(l==="*"||l==="+"||l==="?"||c){let f=c?c[0]:l;if(u+=f.length-1,n<0){t+=f;continue}o.length===0&&(r=t.length),o.push({bounds:K$(f),text:f});continue}s(l)}return i(),t}function vu(e,t,n=!1){let r=-1;for(let o=0;o<e.length;o++){let i=o<=r,s=e[o];if(s==="\\"){let a=e[++o];if(a===void 0)throw new Error("trailing backslash");if(i||a&&"dDxXuUpPkKcC".includes(a))throw new x("feature","regex escape","grep: this regex escape is not supported with GNU semantics");!t&&a==="{"&&A1(e,o-1,!1)}else if(s==="["&&!i)r=Ho(e,o,n);else{if(i)continue;if(t&&s==="{")A1(e,o,!0);else if(t&&s==="("&&e[o+1]==="?")throw new x("feature","regex extension","grep: ECMAScript group extensions are not supported in ERE")}}}function tS(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"&&/[1-9]/u.test(e[++t]??""))return!0;return!1}function nS(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(r==="\\"){n++;continue}if(t){r==="]"&&(t=!1);continue}if(r==="."||r==="["&&(t=!0,e[n+1]==="^"))return!0}return!1}function _1(e,t,n=ie){let r=se(n),o=[],i=t.has("x"),s=t.has("w")&&!i;if(t.has("P")&&new Set(e).size>1)return{error:b("grep: -P only supports a single pattern",2)};for(let a of e){let u=!t.has("F")&&!t.has("P");u&&vu(a,t.has("E"),r.multibyte);let l=u&&tS(a),c=t.has("i")&&!t.has("P")&&!l,f=t.has("i")&&!c?"isu":"su",d;if(t.has("F"))d=c?a1(a,r):RegExp.escape(a);else if(t.has("P"))d=E1(a);else if(t.has("E"))d=xu(c?Jr(a,r):a,r);else{let h=Fi(c?Jr(a,r):a,r);if(h.error)return{error:b(`grep: ${h.error}`,2)};d=h.source}let p=d;if(u&&Ri(p))return{error:v("feature","grep","conditional backreference","grep: backreferences with conditional or repeated-empty captures are not supported",2)};s&&(d=`(?<!${r.assertions().word})(?:${d})(?!${r.assertions().word})`),i&&(d=`^(?:${d})$`);try{let h=u?I1(d):d,m=new RegExp(Un(u?gn(h,"js",r):d),f);u&&Object.assign(m,{markedSource:h,tables:r,shape:b1(a,l)}),m.pcre=t.has("P"),m.localeSensitive=m.pcre?t.has("i")||s||Y$(p)||/\\[dD]/u.test(p):t.has("i")&&l,m.folded=c,m.extendedC=c&&on.test(a),m.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(a),m.wellFormed=a.isWellFormed(),m.emptyWord=s&&!m.pcre&&new RegExp(u?gn(I1(p),"js",r):p,f).test(""),m.anyCharacter=nS(p);let g=h1(a,t);if(g?.isWellFormed()&&(c||!t.has("i"))&&(m.literal={pattern:g,tables:r}),t.has("o")&&u&&!i){if(s||/\\[1-9]|\(\?/u.test(d))return{error:v("feature","grep","-o regex extent","grep: only-matching with backreferences, lookarounds or word constraints is not supported",2)};try{m.extent=new Ot(gn(d,"extent",r),!1,null,r)}catch{return{error:v("feature","grep","-o regex extent","grep: POSIX match extent for this pattern is not supported",2)}}}o.push(m)}catch(h){if(!t.has("P")&&rS(p,t))return{error:v("feature","grep","GNU regex syntax","grep: this GNU regular expression cannot be represented by the JavaScript matcher",2)};let m=t.has("F")?`fixed-string /${f}`:t.has("P")?`PCRE subset /${f}`:t.has("E")?`ERE / ECMAScript /${f}`:`BRE /${f}`;return{error:b(`grep: invalid pattern (${m}): ${h.message}`,2)}}}return{res:o}}function rS(e,t){if(!t.has("E")&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return Ti(gn(e,"extent")),!0}catch(n){return!!n.gap}}function Eu(e,t,n=ie,r=!1){let o=(c,f)=>v("feature","grep",c,`grep: ${f}`,2);if(e.marked){if(t.some(c=>c.pcre))return o("binary input","PCRE matching over bytes that spell no text is not supported");if(t.some(c=>!c.wellFormed))return o("unpaired surrogate","a pattern holding an unpaired UTF-16 surrogate cannot be matched against bytes")}if(t.some(c=>c.emptyWord)&&v1(se(n)).test(e.content))return o("empty word match","-w with a pattern that can match nothing, over non-ASCII text that is not word characters, is not supported");let i=e.marked?t.filter(c=>c.shape&&(c.shape.wordEdge||c.shape.dot||c.shape.negated)):[],s=i.length?x1(e.content):null;if(i.some(c=>k1(c.shape,s,r)))return o("binary input","matching this pattern beside bytes glibc reads as a character is not supported");let a=()=>t.some(c=>c.unicodePattern)||/[\u0080-\u{10FFFF}]/u.test(e.content);if(n!==ie&&t.some(c=>c.localeSensitive||c.folded||c.anyCharacter)&&a())return o("locale",`matching non-ASCII text in the ${n} locale is not supported`);if(t.some(c=>c.extendedC)||t.some(c=>c.folded)&&on.test(e.content))return o("locale-sensitive regex","case-insensitive matching over Cyrillic Extended-C letters is not supported");let u=t.filter(c=>c.localeSensitive);if(u.length===0||!a())return null;let l=u.some(c=>c.pcre)?"PCRE matching":"case-insensitive matching with backreferences";return o("non-ASCII regex semantics",`${l} on non-ASCII input is not supported`)}var $u=/[*?[]/u,Su=/\P{ASCII}/u,oS=/[.+*?^${}()|[\]\\/]/u;function He(e,t={}){try{return iS(e,t)}catch(n){throw n instanceof x?n:new x("feature","glob pattern",`unsupported glob pattern: ${n.message}`)}}function iS(e,t){let n="^",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"&&o+1<e.length){let s=e[o+1];n+=L1(s,t.ignoreCase),o++}else if(i==="*"){for(;e[o+1]==="*";)o++;n+=".*"}else if(i==="?")n+=".";else if(i==="["){let s=F1(e,o,t);if(s?.voided)return/^(?!)$/u;s?(n+=s.source,o=s.end,r||=s.nonAsciiRange):n+="\\["}else n+=L1(i,t.ignoreCase)}return aS(new RegExp(n+"(?![\\s\\S])","us"),e,t,r)}function L1(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:oS.test(e)?"\\"+e:e}function sS(e,t,n){let r=new RegExp(`[${e}]`,"ui"),o=new RegExp(`[${t}]`,"u"),i="";for(let s=0;s<128;s++){let a=String.fromCodePoint(s);(r.test(a)||o.test(a))&&(i+="\\x"+s.toString(16).padStart(2,"0"))}return`[${n?"^":""}${i}]`}function aS(e,t,n,r){let o=/[?[]/u.test(t),i=Su.test(t);return{test(s){if(r||n.ignoreCase&&i||(o||n.ignoreCase)&&Su.test(s))throw new x("feature","non-ASCII glob matching","locale-dependent glob matching of non-ASCII names is not supported");return e.test(s)}}}function F1(e,t,n){let{ignoreCase:r}=n,o=t+1,i=!1;(e[o]==="!"||e[o]==="^")&&(i=!0,o++);let s="",a="",u=!1,l=!1,c=!1,f=!1,d="",p=0,h="",m=0;for(e[o]==="]"&&(s+="\\]",o++,u=!0,d="]");o<e.length&&e[o]!=="]";o++){let g=e[o];if(g==="["&&(e[o+1]==="."||e[o+1]==="="))throw new x("feature","glob collating or equivalence class","glob collating symbols and equivalence classes are not supported");if(g==="["&&e[o+1]===":"){let w=n.bash?uS(e,o):Fn(e,o,{unknown:"empty"});if(w){if(!n.bash&&w.body==="")throw new x("feature","glob character class","unknown POSIX classes in command filename patterns are not supported");l&&(f=!0),r?a+=w.body:s+=w.body,o=w.end-1,u=!1,l=!1;continue}if(n.bash)continue}if(g==="-"&&u)m=p,h=d,s+="-",l=!0,u=!1;else{let w=g==="\\"&&o+1<e.length?e[++o]:g;p=s.length,d=w,l&&Su.test(h+w)&&(c=!0),l&&w.codePointAt(0)<h.codePointAt(0)?s=s.slice(0,m):s+=/[\]\\^[-]/u.test(w)?`\\${w}`:w,u=!l,l=!1}}return o>=e.length?null:f?{voided:!0,end:o}:{source:r?sS(s,a,i):`[${i?"^":""}${s}]`,end:o,nonAsciiRange:c}}function uS(e,t){let n=e.indexOf(":]",t+2);if(n===-1)return null;let r=e.slice(t+2,n).replace(/\\([\s\S]|$)/gu,"$1");return{body:r==="ascii"?"\\x00-\\x7F":rn[r]??"",end:n+2}}function R1(e,t){return He(t).test(e)}function M1(e){let{value:t,mask:n}=e;if(n===null)return $u.test(t);for(let r=0;r<t.length;r++)if(n[r]==="0"&&$u.test(t[r]))return!0;return!1}function Qr(e){let t=n=>!e.mask||e.mask[n]==="0";for(let n=0;n<e.value.length;n++){let r=e.value[n];if(t(n)){if(r==="\\")n++;else if(r==="[")n=lS(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]==="("&&t(n+1))return!0}}return!1}function lS(e,t,n){let{value:r}=e,o=t+1;for(/[!^]/u.test(r[o])&&n(o)&&o++,r[o]==="]"&&n(o)&&o++;o<r.length;o++)if(n(o))if(r[o]==="\\")o++;else{if(r[o]==="]")return o;if(r[o]==="["&&/[.:=]/u.test(r[o+1])&&n(o+1)){let i=r.indexOf(r[o+1]+"]",o+2);i!==-1&&(o=i+1)}}return t}var cS=/[*?[\]^!\\:.=-]/u;function Qn(e){let{value:t,mask:n}=e;if(n===null)return t;let r="";for(let o=0;o<t.length;o++){let i=t[o];r+=n[o]!=="0"&&cS.test(i)?"\\"+i:i}return r}function D1(e,t){let n=Qn(e),r=n.match(/[^/]+|\/+/gu)??[],o=Rn(),i=new Set,s=[{path:"",marks:null}],a;try{for(let l=0;l<r.length;l++){let c=r[l];if(c.startsWith("/")||!$u.test(c)){s=s.map(f=>({...f,path:f.path+dS(c)}));continue}s=pS(s,c,l===r.length-1,t,i)}let u=s.filter(l=>E(t.cwd,l.path,t.fs,{follow:!1}).path!==null);for(let l of u)for(let c of l.marks??[])o.add(c);return a=u.filter(l=>l.marks===null).map(l=>l.path).sort(q),a}finally{if(a===void 0)for(let u of i)o.add(u);o.emit(t.notes,"glob","",` while expanding ${JSON.stringify(n)}`),a?.length===0&&r.some(fS)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function fS(e){for(let t=0;t<e.length;t++)if(e[t]==="\\")t++;else{if(e[t]==="*"||e[t]==="?")return!0;if(e[t]==="[")try{if(F1(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var dS=e=>e.replace(/\\(.)/gu,"$1");function pS(e,t,n,r,o){let i=He(t,{bash:!0}),s=t.startsWith(".")||t.startsWith("\\."),a=[];for(let u of e){let l=E(r.cwd,u.path||".",r.fs).path;if(!r.fs.isDir(l))continue;let{dirs:c,files:f,links:d}=r.fs.listDir(l),p=n?d:d.filter(h=>r.fs.isDir(E(l,h,r.fs).path));for(let h of n?[...c,...f,...p]:[...c,...p]){let m=!s&&h.startsWith(".");if(!m&&u.marks===null)i.test(h)&&a.push({path:u.path+h,marks:null});else if(hS(i,h)){if(!m){a.push({path:u.path+h,marks:u.marks});continue}let g=j(l,h);o.add(g),a.push({path:u.path+h,marks:[...u.marks??[],g]})}}}return a}function hS(e,t){try{return e.test(t)}catch{return!0}}var eo=(e,t)=>e.some(n=>n.test(t)),z1=()=>({stdout:"",stderr:"",exitCode:1}),wn=e=>e.failure!==void 0,Ui=e=>e.name??"(standard input)",B1=e=>e.binaryLine===void 0?e.content:e.content.replaceAll("\0",`
146
+ `),zi=(e,t)=>t.map(e.marked?T1:bu);function Bi(e,t,n,r){if(r===0)return 0;let o=zi(e,t),i=B1(e),s=0;if(r===1/0){for(let u of we(i))eo(o,u)!==n&&s++;return s}let a=0;for(;a<i.length&&s<r;){let u=i.indexOf(`
147
+ `,a);u<0&&(u=i.length),eo(o,i.slice(a,u))!==n&&s++,a=u+1}return s}function j1(){let e=[],t=(n,r)=>{let o=e.at(-1);o?.fd===n&&o.text!==void 0?o.text+=r:e.push({fd:n,text:r})};return{events:e,out(n){n&&t(1,n)},lines(n,r,o){if(!r||!_n.test(n))return this.out(n);if(!o.isWellFormed())throw new x("feature","unpaired surrogate","unpaired UTF-16 surrogates cannot be encoded as UTF-8");e.push({fd:1,bytes:Ks(n)})},err(n){n&&t(2,n)}}}function W1(e,t){let n=o=>e.filter(i=>i.fd===o&&i.text!==void 0).map(i=>i.text).join("");return{stdout:e.some(o=>o.bytes!==void 0)?"":n(1),stderr:n(2),exitCode:t?0:1,events:e}}function q1(e,t,n){let r={used:!1,write:j1(),selected:!1};for(let o of e)wn(o)?r.write.err(o.failure):mS(o,t,n,r);return W1(r.write.events,r.selected)}function mS(e,t,n,r){if(e.binaryLine===0)return gS(e,t,n,r);let o=B1(e),i={input:e,opts:n,run:r,lines:we(o),res:t,tests:zi(e,t),bufbeg:0,name:n.showName??e.recursive?Ui(e):null,out:[],lastout:null,pending:0,outleft:n.max??1/0,quiet:!1,heldBack:!1},s=i.lines.length,a=s>0&&!o.endsWith(`
148
+ `)?s-1:s,u=U1(i,0,a);if(i.pending>0&&Pi(i,a),a<s&&!(i.outleft===0&&i.pending===0)&&!i.quiet){let l=a;for(let c=0;c<n.before&&l>0&&l!==i.lastout;c++)l--;l!==i.lastout&&(i.lastout=null),i.bufbeg=l,i.outleft>0&&(u+=U1(i,a,s)),i.pending>0&&Pi(i,s)}r.write.lines(Ee(i.out),e.marked,i.name??""),u>0&&(r.selected=!0),(i.heldBack||i.quiet)&&H1(e,n,r)}function gS(e,t,n,r){Bi(e,t,n.invert,1)!==0&&(r.used=r.selected=!0,H1(e,n,r))}function H1(e,t,n){t.binaryFiles==="binary"&&n.write.err(`grep: ${Ui(e)}: binary file matches
149
+ `)}function U1(e,t,n){let{invert:r}=e.opts,o=e.input.binaryLine??1/0,i=0;for(let s=t;s<n;){let a=s;for(;a<n&&!eo(e.tests,e.lines[a]);)a++;if(a===n&&!r)break;if(!r||s<a){if(r&&s<o&&a>o){if(i+=Au(e,s,o),e.outleft===0)break;s=o}if(!e.quiet&&(r?s:a)>=o&&(e.pending>0&&Pi(e,o),e.quiet=!0),i+=r?Au(e,s,a):Au(e,a,a+1),e.outleft===0||e.quiet)break}s=a+1}return i}function Au(e,t,n){let{before:r,after:o,hasContext:i,invert:s}=e.opts;!e.quiet&&e.pending>0&&Pi(e,t);let a=t;if(!e.quiet){let l=e.lastout??e.bufbeg;for(let c=0;c<r;c++)a>l&&a--;for(i&&e.run.used&&a!==e.lastout&&e.out.push("--");a<t;a++)Di(e,a,!1)}let u;if(s)for(u=0;a<n&&u<e.outleft;u++,a++)e.quiet||Di(e,a,!0);else e.quiet||Di(e,t,!0),u=1;return e.pending=e.quiet?0:o,e.run.used=!0,e.outleft-=u,u}function Pi(e,t){for(e.lastout??=e.bufbeg;e.pending>0&&e.lastout<t;e.pending--)Di(e,e.lastout,!1)}function Di(e,t,n){let r=e.lines[t];if(e.opts.only)n!==e.opts.invert&&wS(e,r,t,n);else{if(e.input.marked&&e.opts.binaryFiles!=="text"&&_n.test(r)&&y1(r)){e.heldBack=!0;return}e.out.push(G1(e,r,t,n))}e.lastout=t+1}function wS(e,t,n,r){let o=e.input.marked&&_n.test(t),i=0;for(;i<t.length;){let s=null;for(let a=0;a<e.res.length;a++){let u=yS(e.res[a],e.tests[a],t,i,o);u&&(!s||u.start<s.start||u.start===s.start&&u.end>s.end)&&(s=u)}if(!s)break;if(s.end===s.start){i=s.end+ze(t,s.end);continue}e.out.push(G1(e,t.slice(s.start,s.end),n,r)),i=s.end}}var P1=new WeakMap;function yS(e,t,n,r,o){if(e.extent)return(o?e.markedExtent??=g1(e.extent):e.extent).search(n,r);let i=P1.get(t);i||P1.set(t,i=new RegExp(t.source,t.flags+"g")),i.lastIndex=r;let s=i.exec(n);if(s&&s[0]===""&&e.pcre)throw new x("feature","PCRE empty match extent","only-matching with empty PCRE matches is not supported");return s?{start:s.index,end:s.index+s[0].length}:null}function G1(e,t,n,r){let o=r?":":"-";return(e.name===null?"":e.name+o)+(e.opts.showLine?n+1+o:"")+t}function X1(e,t,{mode:n,invert:r,showName:o,max:i=1/0}){let s=j1(),a=!1,u=n==="c"?i:Math.min(1,i);for(let l of e){if(wn(l)){s.err(l.failure);continue}let c=Bi(l,t,r,u);c>0&&(a=!0),n==="c"?s.out((o??l.recursive?Ui(l)+":"+c:String(c))+`
150
+ `):c>0==(n==="l")&&s.out(Ui(l)+`
151
+ `)}return W1(s.events,a)}function Z1(e,t,n){let r=e.order.filter(s=>["e","f","file"].includes(s.name)),o=e.positional;if(r.length===0)return o.length?{patterns:o[0].split(`
152
+ `),rest:o.slice(1),stdin:t}:null;let i=new Set;for(let{name:s,value:a}of r){if(s==="e"){for(let c of a.split(`
153
+ `))i.add(c);continue}let u=bt("grep",[a],n,t);if(u.failed)return{error:b(u.stderr,2)};let l=u.inputs[0];for(let c of we(l.content))i.add(c);l.shared&&(t="")}return{patterns:[...i],rest:o,stdin:t}}var Y1="[-i] [-a|-I] [-s] [-v] [-n] [-r|-R] [-w] [-x] [-o] [-E|-F|-G|-P] [-l] [-L] [-c] [-q] [-m N] [-h] [-H] [-A N] [-B N] [-C N] [--include=GLOB] [--exclude=GLOB] [--exclude-dir=GLOB]",xS=`grep ${Y1} PATTERN [PATH...]
154
+ or: grep ${Y1} [-e PATTERN] [-f FILE] ... [PATH...]`,bS=["i","v","n","r","R","l","L","c","w","x","h","H","o","E","F","G","P","q","I","a","s"],kS=["A","B","C","m"],Q1={short:bS,long:["text","no-messages"],valueShort:kS,repeatable:["e","f","file","include","exclude","exclude-dir"]};function em(e){try{return N(e,Q1).flags.has("q")}catch{return!1}}function ji(e,t,n){let r;try{r=N(t,Q1)}catch(m){return Q(m,"grep",`grep: ${m.message}`,2)}let{flags:o,values:i}=r,s=Z1(r,e,n);if(!s)return xe(xS,2);if(s.error)return s.error;let{patterns:a,rest:u}=s;e=s.stdin;let l=NS(o);if(l)return l;let c;try{c=_1(a,o,n.locale)}catch(m){return Q(m,"grep",`grep: ${m.message}`,2)}if(c.error)return c.error;let f=IS(i);if(f.error)return f.error;if((f.max===0||OS(a,o))&&(!o.has("L")||o.has("q")))return z1();if(f.max!==0&&n.stdinFile&&(o.has("q")||o.has("l")||o.has("L")||i.has("m"))&&(u.length===0||u.includes("-")))return v("feature","grep","partial stdin reads","grep: early termination on shared file input is not supported",2);let d=o.has("r")||o.has("R"),p=_S(r,n),h=r.order.findLast(m=>["a","I","text"].includes(m.name))?.name;p.binaryFiles=h==="a"||h==="text"?"text":h==="I"?"without-match":"binary",p.silent=o.has("s")||o.has("no-messages"),p.follow=o.has("R");try{return vS(e,u,n,d,p,c,o,f)}finally{AS(p,n.notes)}}function vS(e,t,n,r,o,i,s,a){if(s.has("q"))return ES(e,t,n,r,o,i.res,s.has("v"));let u=om(r,e,t,n,o);a.max===0&&z(n,e);let l=s.has("v"),c=["l","L","c"].find(g=>s.has(g)),f=u.items;o.name.length>0&&(f=f.filter(g=>wn(g)||im(g,o)));let d=null;if(a.max!==0&&(f=f.flatMap(g=>{if(wn(g))return[g];let w=tm(g,o,i.res,l,n),y=Eu(w,i.res,n.locale,!c&&s.has("o"))??(c?null:$S(w,i.res,l,a.after)??SS(w,a,s,o,n));return d??=y,y?[]:[w]}),d&&f.every(wn)))return d;let h={showName:TS(s,t.length),invert:l,showLine:s.has("n"),only:s.has("o"),binaryFiles:o.binaryFiles,...a},m;try{m=c?X1(f,i.res,{...h,mode:c}):q1(f,i.res,h)}catch(g){return g instanceof A&&g.gap?v("feature","grep",g.gap,`grep: ${g.message}`,2):Q(g,"grep",`grep: ${g.message}`,2)}if(d){let g=C(d),w={...m,stderr:m.stderr+d.stderr,exitCode:2,events:[...m.events,{fd:2,text:d.stderr}]};return X(w,g.kind,g.command,g.detail,g.message)}return u.failed?{...m,exitCode:2}:m}function ES(e,t,n,r,o,i,s){let a="",u=!1;for(let l of t.length?t.map(c=>[c]):[[]]){let c=om(r,e,l,n,o);u||=c.failed,(l.includes("-")||l.includes("/dev/stdin")&&!n.stdinFile)&&(e="");for(let f of c.items){if(wn(f)){a+=f.failure;continue}if(!im(f,o))continue;let d=tm(f,o,i,s,n),p=Eu(d,i,n.locale);if(p)return p.stderr=a+p.stderr,p;if(Bi(d,i,s,1)>0)return{stdout:"",stderr:a,exitCode:0}}}return{stdout:"",stderr:a,exitCode:u?2:1}}function tm(e,t,n,r,o){let i=rm(e,o),s=t.binaryFiles==="without-match",a=t.binaryFiles==="text";if(e.content===void 0){if(!r&&wu(e.bytes,n))return{...e,content:""};let c=a?-1:e.bytes.indexOf(0);if(c>=0&&s)return K1(e,t,c>=i);let f={...e,content:Vs(e.bytes),marked:!0};return c<0?f:V1(f,e.bytes,c,i)}let u=a?-1:e.content.indexOf("\0");if(u<0)return e;let l=T(e.content.slice(0,Math.min(u,i)));return s?K1(e,t,l.length>=i):V1(e,l,l.length,i)}function V1(e,t,n,r){if(n<r)return{...e,binaryLine:0};let o=e.content.lastIndexOf(`
155
+ `,e.content.indexOf("\0"))+1;return{...e,lineStart:o,readLines:Sr(t.subarray(0,r)),binaryLine:Sr(e.content.slice(0,o))}}var nm=e=>e.name===null||e.name==="/dev/stdin",rm=(e,t)=>nm(e)&&!t.stdinFile?64*1024:96*1024;function $S(e,t,n,r){if(e.readLines===void 0)return null;let o=we(e.content.slice(0,e.lineStart)),i=zi(e,t),s=(a,u)=>o.slice(a,u).some(l=>eo(i,l)!==n);return!s(e.readLines)&&!(r>0&&s(Math.max(0,e.readLines-r),e.readLines))?null:v("feature","grep","late binary detection","grep: binary detection after the initial input buffer is not supported",2)}function SS(e,t,n,r,o){return!e.marked||e.binaryLine!==void 0||!t.hasContext||n.has("o")||r.binaryFiles==="text"||e.bytes.length<=rm(e,o)?null:v("feature","grep","binary context across reads","grep: context around lines held back past the first read is not supported",2)}function K1(e,t,n){if(n)throw new x("feature","late binary detection","grep: binary detection after the initial input buffer is not supported");let r=nm(e)?t.stdinPath:j(t.cwd,e.name);return r?t.binary.add(r):t.binaryStdin=!0,{...e,content:""}}function AS(e,t){let n="Binary input is treated as text with -a.";Ft(t,{command:"grep",action:"skipped",noun:["binary file","binary files"],paths:e.binary,explanation:n}),e.binaryStdin&&t.add("grep: skipped binary standard input. "+n),Ft(t,{command:"grep",action:"excluded",noun:["entry","entries"],paths:e.excluded,context:" by --include/--exclude/--exclude-dir rules"})}function NS(e){if(e.has("h")&&e.has("H"))return v("option","grep","-h -H","grep: combining -h and -H is not supported");let t=["l","L","c"].filter(r=>e.has(r));if(t.length>1)return v("option","grep","combined output modes",`grep: ${t.map(r=>`-${r}`).join(" / ")} are mutually exclusive`);let n=["E","F","G","P"].filter(r=>e.has(r));return n.length>1?b(`grep: ${n.map(r=>`-${r}`).join(" / ")} are mutually exclusive`,2):null}function OS(e,t){return e.length===0?!t.has("v"):t.has("v")&&!t.has("x")&&!t.has("w")&&e.every(n=>n==="")}function IS(e){let t={A:0,B:0,m:void 0};for(let n of["C","A","B","m"]){if(!e.has(n))continue;let r=Pe(e.get(n),"grep: -"+n);if(r.error)return n==="m"&&(r.error.exitCode=2),r;n==="C"?t.A=t.B=r.value:t[n]=r.value}return{after:t.A,before:t.B,max:t.m,hasContext:["A","B","C"].some(n=>e.has(n))}}function TS(e,t){return e.has("h")?!1:e.has("H")||t>1?!0:void 0}function om(e,t,n,r,o){let i=l=>o.silent?[]:[{failure:l}];if(!e){let l=ae("grep",n,t,r,{read:"maybe-text"});return{items:l.entries.flatMap(f=>f.kind==="file"?[f.name==="-"?{...f,name:null}:f]:i(f.failure)),failed:l.failed}}let s=[],a=!1,u=l=>{s.push(...i(l)),a=!0};for(let l of n.length?n:["."]){if(l==="-"||l==="/dev/stdin"||l==="/dev/null"){let p=bt("grep",[l],r,t);s.push(...p.inputs.map(h=>({...h,name:l==="-"?null:l}))),(l==="-"||l==="/dev/stdin")&&(t="");continue}let{path:c,error:f}=D(r,"grep",l);if(r.fs.isFile(c)){s.push({name:l,...Nu(r,c)});continue}if(f){u(`grep: ${l}: ${f}
156
+ `);continue}if(LS(l,o.dir)){o.excluded.add(c);continue}let d=p=>p===c||o.dir.length===0||!Ou(o.dir,Ne(p))?!0:(o.excluded.add(p),!1);for(let p of rt(r.fs,c,1/0,d)){if(p.kind==="link"){if(!o.follow)continue;let m=CS(p.path,J1(n.length?l:"",c,p.path),r,o);m?.input&&s.push(m.input),m?.error&&u(m.error);continue}if(p.kind!=="file")continue;let h=p.path;s.push({name:J1(n.length?l:"",c,h),...Nu(r,h),recursive:!0})}}return{items:s,failed:a}}function CS(e,t,n,r){let o=E(n.cwd,e,n.fs),i=n.fs.isDir(o.path);if(!(i?r.dir.length===0||!Ou(r.dir,Ne(e)):sm(Ne(e),r.name)))return r.excluded.add(e),null;if(i)throw new x("option","-R",`following a symbolic link to a directory is not supported: ${t}`);return o.error?{error:`grep: ${t}: ${o.error}
157
+ `}:{input:{name:t,...Nu(n,o.path),recursive:!0}}}function Nu(e,t){let{text:n,bytes:r}=it(e.fs,t);return n===void 0?{content:void 0,bytes:r}:{content:n}}function _S(e,t){let n=e.order.filter(o=>o.name==="include"||o.name==="exclude").map(o=>({include:o.name==="include",re:He(o.value)})),r=(e.values.get("exclude-dir")??[]).map(o=>He(o));return{name:n,dir:r,binary:new Set,excluded:new Set,cwd:t.cwd,stdinPath:t.stdinHandle?.path}}function Ou(e,t){return e.some(n=>n.test(t))}function im(e,t){return e.name===null||sm(Ne(e.name),t.name)?!0:(t.excluded.add(j(t.cwd,e.name)),!1)}function sm(e,t){if(t.length===0)return!0;let n=null;for(let r of t)r.re.test(e)&&(n=r);return n?n.include:!t[0].include}function LS(e,t){return t.length===0||e.endsWith("/")?!1:Ou(t,e.slice(e.lastIndexOf("/")+1))}function J1(e,t,n){let r=nt(t,n);return e===""?r:e.endsWith("/")?e+r:e+"/"+r}var to=(e,t)=>v("feature","rg",e,`rg: ${t}`,2);function am(e,t,n){let r=C(e)??e.note;return r?v(r.kind,"rg",r.detail,t,2):v(n,"rg",e.detail??t.replace(/^rg: /u,""),t,2)}function lm(e,t,n){let r,o;try{o=N(t,Vh),r=Kh(o)}catch(d){return am(d,d.message.startsWith("rg: ")?d.message:`rg: ${d.message}`,"option")}let i=[...o.positional];if(!r.patterns.length){if(!i.length)return to("usage","a pattern is required");r.patterns.push(i.shift())}try{Qh(r.patterns,r.literal)}catch(d){return am(d,d.message,"feature")}let a=!i.length&&!!n.stdinPiped?{roots:[],recursive:!1,stdin:!0}:DS(i,n,r.hidden);if(a.error)return a.error;if(!o.flags.has("no-ignore")&&!r.unrestricted&&a.recursive){let d=US(a.roots,n);if(d)return to("ignore rules",`${JSON.stringify(d)} would change which files are searched, and its rules are not implemented`)}let u=FS(i,a,r,n),l=r.text?null:PS(i,n);if(l)return to("named binary file",`${JSON.stringify(l)} is binary, and reporting a binary match is not supported`);let c=RS(u,r,n)??(a.stdin?MS(r,n):null);return c?to(c.detail,c.message):(a.stdin||i.length?1:u.length)===0?{stdout:"",exitCode:2,stderr:`rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
158
+ Running with --debug will show why files are being skipped.
159
+ `}:zS(e,r,i,a,n)}function FS(e,t,n,r){let o=e.map(i=>E(r.cwd,i,r.fs).path).filter(Boolean).map(i=>({path:i,named:!0}));for(let i of t.roots)for(let s of rt(r.fs,i)){if(s.kind!=="file")continue;let a=nt(i==="/"?"/":i,s.path).split("/");(n.hidden||a.every(u=>!u.startsWith(".")))&&o.push({path:s.path,named:!1})}return o}function RS(e,t,n){for(let{path:r,named:o}of e){if(n.fs.isDir(r))continue;let{text:i,bytes:s}=it(n.fs,r);if(i!==void 0&&!i.startsWith("\uFEFF")||(s===void 0?i.includes("\0"):s.includes(0))&&!o&&!t.text)continue;let u=JSON.stringify(nt(n.cwd==="/"?"/":n.cwd,r)||r);if(i===void 0){let l=cm(s,u,t,n);if(l)return l;continue}if(i.startsWith("\uFEFF"))return{detail:"byte-order mark",message:`${u} begins with a byte-order mark, which ripgrep strips before matching`}}return null}function cm(e,t,n,r){return!n.invert&&!n.ignoreCase&&c1(e,n.patterns,n.literal,r.locale)?null:{detail:"unreadable bytes",message:`${t} holds bytes that are not text, and searching them is not supported`}}function MS(e,t){let n=t.stdinBytes;return!n||!e.text&&n.includes(0)||ve(n)!==void 0?null:cm(n,Mn(null,t),e,t)}function DS(e,t,n){let r=[],o=!1;for(let s of e){let a=E(t.cwd,s,t.fs);a.path!==null&&t.fs.isDir(a.path)&&r.push(a.path),s.split("/").some(u=>u.startsWith(".")&&u!=="."&&u!=="..")&&(o=!0)}e.length||r.push(t.cwd);let i=r.length>0;return!n&&i&&o&&e.length?{error:to("named hidden path","a hidden path named beside a directory is searched by ripgrep but skipped while walking, and both cannot apply at once")}:{roots:r,recursive:i}}function US(e,t){let n=l=>nt(t.cwd==="/"?"/":t.cwd,l)||l,r=(l,c=!0)=>{for(let f of e){for(let d of rt(t.fs,f))if(Ne(d.path)===l&&Iu(d.path,c,t))return d.path;for(let d=f;d!=="/";d=oe(d)){let p=E(oe(d),l,t.fs);if(p.path!==null&&Iu(p.path,c,t))return p.path}}return null},o=r(".ignore")??r(".rgignore");if(o)return n(o);let i=r(".git",!1);if(!i)return null;let s=E(i,"info/exclude",t.fs).path,a=s!==null&&Iu(s,!0,t)?s:null,u=r(".gitignore")??a;return u?n(u):null}function Iu(e,t,n){if(!t||n.fs.isDir(e))return!0;let r=E("/",e,n.fs).path,{text:o}=it(n.fs,r??e);return(o??" ").split(`
160
+ `).some(i=>i.trim()!==""&&!i.trimStart().startsWith("#"))}function PS(e,t){for(let n of e){let r=E(t.cwd,n,t.fs);if(r.path===null||t.fs.isDir(r.path))continue;let{text:o,bytes:i}=it(t.fs,r.path);if(i===void 0?o?.includes("\0"):i.includes(0))return n}return null}function zS(e,t,n,r,o){let i=t.literal?["-F"]:["-P"];t.ignoreCase&&i.push("-i"),t.lineNumbers&&i.push("-n"),t.word&&i.push("-w"),t.invert&&i.push("-v"),t.quiet&&i.push("-q"),t.mode&&i.push("-"+t.mode),t.showName&&i.push("-"+t.showName),i.push(t.text?"-a":"-I"),t.after&&i.push("-A",String(t.after)),t.before&&i.push("-B",String(t.before)),r.recursive&&i.push("-r"),r.recursive&&!t.hidden&&i.push("--exclude=.*","--exclude-dir=.[!.]*","--exclude-dir=..?*"),i.push(...Jh(t.patterns,t.literal)),r.stdin||i.push("--",...n.length?n:["."]);let s=new Set(o.notes),a=ji(e,i,o);return delete a.events,HS(o.notes,s,r),qS(BS(a,t),n,t.patterns)}function BS(e,t){if(t.mode!=="c")return e;let n=e.stdout.split(`
161
+ `).filter(r=>r!==""&&r!=="0"&&!r.endsWith(":0"));return{...e,stdout:n.length?n.join(`
162
+ `)+`
163
+ `:""}}var um=new Map([["No such file or directory",2],["Not a directory",20],["Is a directory",21]]),jS=e=>e.replaceAll(/^(rg: .*: )([A-Z][a-z].*)$/gmu,(t,n,r)=>um.has(r)?`${n}${r} (os error ${um.get(r)})`:t),WS=/^rg: (?:invalid pattern[^\n]*|trailing backslash)$/mu;function qS(e,t,n){let r=s=>t.length?s:s.replaceAll(/^\.\//gmu,""),o={...e,stdout:r(e.stdout),stderr:jS(r(e.stderr).replaceAll(/^grep: /gmu,"rg: "))},i=C(e);return i?.detail==="non-ASCII regex semantics"?v("feature","rg","non-ASCII matching","rg: Unicode-aware matching on non-ASCII input is not supported",2):i?v(i.kind,"rg",i.detail,o.stderr.trimEnd()||i.message,e.exitCode):WS.test(o.stderr)?v("feature","rg","regex parse error",`rg: regex parse error in ${JSON.stringify(n.join(" "))}; the reason ripgrep gives is not reproduced here`,2):o}function HS(e,t,n){let r=[];for(let o of e)!t.has(o)&&o.startsWith("grep: excluded ")&&r.push(o);for(let o of r)e.delete(o),n.recursive&&e.add(o.replace(/^grep: excluded (\d+) (entry|entries) by --include\/--exclude\/--exclude-dir rules/u,"rg: skipped $1 hidden $2").replace(/\.$/u,". Hidden entries are searched with --hidden."))}var pm=6,hm=" ",GS=" ".repeat(pm+hm.length);function mm(e,t,n){let{values:r,positional:o,order:i}=N(t,{valueShort:["b","v"],valueLong:["starting-line-number"]}),s=r.get("b")??"t";if(!["a","t","n"].includes(s)){let c=`nl: -b: only \`a\`, \`t\` and \`n\` are supported (got \`${s}\`)`;return s.startsWith("p")?v("option","nl","-b p",c):b(c)}let a=1n;for(let{name:c,value:f}of i)if(!(c!=="v"&&c!=="starting-line-number")){if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(f))return b(`nl: invalid starting line number: ${f}`);if(a=BigInt(f),a<wt||a>ge)return b(`nl: invalid starting line number: ${f}`)}let u=ae("nl",o,e,n);if(u.inputs.some(({content:c})=>/(?:^|\n)(?:\\:){1,3}(?:\n|$)/u.test(c)))return v("feature","nl","logical pages","nl: logical page delimiters are not supported");let l=[];for(let{content:c}of u.inputs)for(let f of we(c))if(s==="a"||s==="t"&&f!==""){if(a>ge)return{stdout:Ee(l),stderr:u.stderr+`nl: line number overflow
164
+ `,exitCode:1};l.push(`${String(a).padStart(pm)}${hm}${f}`),a++}else l.push(GS+f);return ue(Ee(l),u)}function gm(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["s"],valueShort:["d","f","c"]}),s=o.has("f"),a=o.has("c");if(s===a)return xe("cut -f LIST [-d DELIM] [-s] [file...] | cut -c LIST [file...]");if(a&&o.has("d"))return b("cut: -d is only valid with -f");if(a&&r.has("s"))return b("cut: -s is only valid with -f");let u=VS(s?o.get("f"):o.get("c"),s?"field":"position");if(u.error)return u.error;let l=o.get("d")===""?"\0":o.get("d")??" ";if(s&&T(l).length!==1)return b("cut: -d delimiter must be a single byte");let c=ae("cut",i,e,n),f=[];for(let{content:d}of c.inputs)for(let p of s&&l===`
165
+ `?d===""?[]:[d]:we(d)){if(s&&!p.includes(l)){r.has("s")||f.push(p);continue}f.push(s?KS(p,l,u.ranges):XS(p,u.ranges))}return ue(Ee(f),c)}function XS(e,t){let n=T(e);return G(Uint8Array.from(wm(n,t)))}var ZS={field:{zero:"fields are numbered from 1",range:"invalid field range",value:e=>`invalid field value '${e}'`,large:e=>`field number '${e}' is too large`},position:{zero:"byte/character positions are numbered from 1",range:"invalid byte or character range",value:e=>`invalid byte/character position '${e}'`,large:e=>`byte/character offset '${e}' is too large`}},YS=/^(\d*)(-?)(\d*)/u;function VS(e,t){let n=ZS[t],r=s=>({error:b(`cut: ${s}`)}),o=[];for(let s of e.split(/[, \t]/u)){if(s==="")return r(n.zero);let[a,u,l,c]=YS.exec(s),f=s.slice(a.length);if(f!=="")return r(f.startsWith("-")?n.range:n.value(f));for(let h of[u,c])if(h!==""&&BigInt(h)>yt)return r(n.large(h));if(u===""&&c===""&&l==="")return r(n.value(s));let d=u===""?1:Number(u),p=l===""?d:c===""?1/0:Number(c);if(d<1)return r(n.zero);if(p<d)return r("invalid decreasing range");o.push([d,p])}o.sort((s,a)=>s[0]-a[0]);let i=[];for(let s of o){let a=i.at(-1);a&&s[0]<=a[1]+1?a[1]=Math.max(a[1],s[1]):i.push(s)}return{ranges:i}}function wm(e,t){return t.flatMap(([n,r])=>Array.from(e.slice(n-1,r)))}function KS(e,t,n){let r=t===`
166
+ `?we(e):e.split(t);return wm(r,n).join(t)}function ym(e,t,n){let{flags:r,positional:o}=N(t,{short:["c","d","s"]}),i=r.has("d"),s=r.has("s"),a=r.has("c");if(i&&s)return v("option","tr","-d -s","tr: -d combined with -s is not supported");if(s&&!i&&o.length===2)return v("feature","tr","translate and squeeze","tr: combined translation and squeezing is not supported");let u=i||s?1:2;if(o.length!==u)return xe("tr [-c] SET1 SET2 | tr [-c] -d SET | tr [-c] -s SET");if(/\P{ASCII}/u.test(e+o.join("")))return v("feature","tr","non-ASCII bytes","tr: translation of non-ASCII bytes is not supported");if(o.some(w=>/\[[.=]/u.test(w)))return v("feature","tr","set expressions","tr: equivalence classes and collating symbols are not supported");if(o.some(w=>/\[[^\]]*\*/u.test(w)))return v("feature","tr","repeat expressions","tr: repetition expressions in a set are not supported");if(o.some(w=>/\\[0-7]{2}|\\[1-7abfrv]/u.test(w)))return v("feature","tr","set escapes","tr: these set escape sequences are not supported");if(o.some(w=>/(?:^|[^\\])(?:\\\\)*\\$/u.test(w)))return v("feature","tr","trailing backslash","tr: an unescaped trailing backslash in a set is not supported");let l=dm(o[0]);if(l.error)return l.error;let c=new Set(l.chars),f=w=>a!==c.has(w);if(i)return z(n),R([...e].filter(w=>!f(w)).join(""));if(s)return z(n),R(tA(e,f));let d=dm(o[1]);if(d.error)return d.error;let p=eA(l,d,a);if(p)return p;if(d.chars.length===0)return b("tr: when not truncating set1, string2 must be non-empty");z(n);let h=a?Array.from({length:256},(w,y)=>String.fromCodePoint(y)).filter(w=>!c.has(w)):l.chars,m=new Map,g=d.chars.at(-1);for(let w=0;w<h.length;w++)m.set(h[w],d.chars[w]??g);return R([...e].map(w=>m.get(w)??w).join(""))}var JS=Object.freeze(Object.fromEntries(Object.entries($r).filter(([e])=>e!=="word").map(([e,t])=>[e,t.flatMap(([n,r])=>Array.from({length:r-n+1},(o,i)=>String.fromCodePoint(n+i)))]))),fm={__proto__:null,lower:"upper",upper:"lower"};function QS(e,t){if(e[t]!=="["||e[t+1]!==":")return null;let n=e.indexOf(":]",t+2);return n<0?null:{name:e.slice(t+2,n),next:n+2,text:e.slice(t,n+2)}}function eA(e,t,n){if(t.classes.find(s=>fm[s.name]===void 0))return b(`tr: when translating, the only character classes that may appear in
167
+ string2 are 'upper' and 'lower'`);let o=s=>e.classes.some(a=>a.name===fm[s.name]&&a.start===s.start&&a.end===s.end);return(n?null:t.classes.find(s=>!o(s)))?b("tr: misaligned [:upper:] and/or [:lower:] construct"):t.classes.some(s=>s.end===t.chars.length)&&(n||e.chars.length>t.chars.length)?b(`tr: when translating with string1 longer than string2,
168
+ the latter string must not end with a character class`):n&&e.classes.length>0&&t.chars.length!==1?b(`tr: when translating with complemented character classes,
169
+ string2 must map all characters in the domain to one`):null}function dm(e){let t=[],n=[],r=0,o=()=>{if(e[r]!=="\\")return e[r++];if(r+1>=e.length)return null;let i=e[r+1];return r+=2,i==="n"?`
170
+ `:i==="t"?" ":i==="\\"?"\\":i==="0"?"\0":i};for(;r<e.length;){let i=QS(e,r);if(i){if(i.name==="")return{error:b(`tr: missing character class name '${i.text}'`)};let a=JS[i.name];if(a===void 0)return{error:b(`tr: invalid character class '${i.name}'`)};n.push({name:i.name,start:t.length,end:t.length+a.length}),t.push(...a),r=i.next;continue}let s=o();if(e[r]==="-"&&r+1<e.length){r++;let a=o();if(a===null)return{error:b("tr: trailing backslash in set")};let u=s.codePointAt(0),l=a.codePointAt(0);if(l<u)return{error:b(`tr: range-endpoints of '${s}-${a}' are in reverse collating sequence order`)};for(let c=u;c<=l;c++)t.push(String.fromCodePoint(c))}else t.push(s)}return{chars:t,classes:n}}function tA(e,t){let n="",r=null;for(let o of e)t(o)&&o===r||(n+=o,r=o);return n}var xm=e=>e.text??G(e.bytes),Cu=(e,t)=>{e.bytes===void 0?t.write(e.text):t.writeBytes(e.bytes)},er=e=>e.events??[...e.stdout?[{fd:1,text:e.stdout}]:[],...e.stderr?[{fd:2,text:e.stderr}]:[]],Tu=e=>e.unordered??(!e.events&&e.stdout!==""&&e.stderr!==""),B=(e="")=>({stdout:"",stderr:e,exitCode:0,ignored:!1,events:e?[{fd:2,text:e}]:[],unordered:!1});function U(e,t){e.stdout+=t.stdout,e.stderr+=t.stderr,e.exitCode=t.exitCode,e.ignored=t.ignored??!1,e.events.push(...er(t)),e.unordered||=Tu(t)}function Wi(e,t){t&&U(e.expansionOutput,tr(B(t),{fds:e.expansionFds},e))}function tr(e,t,n){let r=o=>nA(e,t,n,o);return n.io?n.io.output(e,t,r):r(Cu)}function nA(e,t,n,r){let o=e,i=t.fds[1],s=t.fds[2];(i===s&&i!=="null"&&i!=="closed"||(i?.identity&&s?.identity?i.identity===s.identity:i?.path&&i.path===s?.path))&&Tu(o)&&(o=v("feature",null,"combined output ordering","error: merging this command\u2019s stdout and stderr in order is not supported"),n.unsupported.add(C(o)));let u=[],l="",c="";for(let f of er(o)){let d=t.fds[f.fd];if(typeof d=="object"){r(f,d);continue}if(t.deferred?.[f.fd]&&f.bytes!==void 0){u.push(f);continue}if(d!=="out"&&d!=="err"){f.fd===2&&gf(n,xm(f));continue}let p=xm(f);u.push({fd:d==="out"?1:2,text:p}),d==="out"?c+=p:l+=p}return{...o,stdout:c,stderr:l,events:u,unordered:Tu(o)&&c!==""&&l!==""}}var rA=new Map([["ls",2],["grep",2],["egrep",2],["fgrep",2],["sort",2],["xxd",3],["sed",4],["diff",2],["patch",2],["xargs",123],["hexdump",0],["tree",0],["zip",0],["unzip",0]]),oA=e=>e.stdout!==""||er(e).some(t=>t.fd===1&&(t.bytes?.length??0)>0);function _u(e,t,n){return n.closed.out&&oA(t)?iA(e,t,n):t}function iA(e,t,n){let r=rA.get(n.registry.resolveCommand(e))??1,o=er(t).filter(u=>u.fd!==1),i=r===0?"":`${e}: write error: Bad file descriptor
171
+ `;i&&o.push({fd:2,text:i});let s={...t,stdout:"",stderr:t.stderr+i,exitCode:r||t.exitCode,events:o,unordered:!1},a=C(t);return a?X(s,a.kind,a.command,a.detail,a.message):s}var sA=new Map([["\0","0"],["\x07","a"],["\b","b"],["\f","f"],[`
172
+ `,"n"],["\r","r"],[" ","t"],["\v","v"]]);function V(e,t){let n=ee(t),r=n?Array.from(I(e),s=>String.fromCodePoint(s)):[...e];if(!n&&r.some(s=>s.codePointAt(0)>127&&/[\p{C}\p{Zl}\p{Zp}]/u.test(s)))throw new x("feature","filename quoting","quoting nonprinting Unicode filenames is not supported");if(e.includes("'")&&r.every(s=>/[-a-zA-Z0-9 %+,./:_\]']/u.test(s)||!n&&s.codePointAt(0)>127))return'"'+e+'"';let o=!1,i="'";for(let s of r){let a=s.codePointAt(0),u=sA.get(s)??(a<32||a===127||n&&a>127?a.toString(8).padStart(3,"0"):null);u!==null?(o||(i+="'$'"),o=!0,i+="\\"+u):s==="'"?(i+="'\\''",o=!1):(o&&(i+="''"),o=!1,i+=s)}return i+"'"}var aA=/^[#%+,\-./0-9@A-Z\]_a-z{}~]+$/u;function pe(e,t){return aA.test(e)&&!"#~".includes(e[0])?e:V(e,t)}var uA=new Map([["\x07","a"],["\b","b"],["\f","f"],[`
173
+ `,"n"],["\r","r"],[" ","t"],["\v","v"],['"','"'],["\\","\\"]]);function Lu(e,t){let n=ee(t),r="",o=!1;for(let i of e){let s=i.codePointAt(0),a=uA.get(i);if(a!==void 0)r+="\\"+a,o=!0;else if(i===" ")r+=i,o=!0;else if(s<32||s===127||s>127&&(n||/[\p{C}\p{Zl}\p{Zp}]/u.test(i))){for(let u of T(i))r+="\\"+u.toString(8).padStart(3,"0");o=!0}else r+=i}return o?`"${r}"`:e}var lA=new Set(["/dev/null","/dev/stdin","/dev/stdout","/dev/stderr"]);function km(e,t,n){let r=N(t,{short:["f","n","v","T","r","R"],long:["force","no-clobber","verbose","no-target-directory","recursive"],valueShort:["t"],valueLong:["target-directory"]}),o=cA(r,n);if(o.error)return b("cp: "+o.error);let{sources:i,target:s,directory:a}=o,{flags:u}=r,l=u.has("v")||u.has("verbose"),c=u.has("r")||u.has("R")||u.has("recursive"),f=i.map(h=>[h,a?s.replace(/\/+$/u,"")+"/"+pA(h):s]),d=u.has("n")||u.has("no-clobber"),p={ctx:n,result:B(),failed:!1,sources:new Set,copied:new Set,noClobber:d,force:u.has("f")||u.has("force"),verbose:l,recursive:c,outputOverlap:l&&gA(f,n,{recursive:c,noClobber:d})};for(let[h,m]of f){n.io.setReads([]);try{Sm(h,m,p)}catch(g){P(n,"cp",g?.path,g?.fsError);let w=C(g),y="cp: "+K(g);if(w)return n.unsupported.add({...w,command:w.command??"cp",message:y}),U(p.result,b(y)),p.result;yn(p,y+`
174
+ `,!0)}}return p.result.exitCode=p.failed?1:0,p.result}function cA({positional:e,flags:t,order:n},r){let o=n.filter(({name:c})=>c==="t"||c==="target-directory");if(o.length>1)return{error:"multiple target directories specified"};let i=o[0]?.value,s=t.has("T")||t.has("no-target-directory");if(e.length===0)return{error:"missing file operand"};if(i===void 0&&e.length===1)return{error:"missing destination file operand after "+V(e[0],r)};if(i!==void 0&&s)return{error:"cannot combine --target-directory (-t) and --no-target-directory (-T)"};if(s&&e.length>2)return{error:"extra operand "+V(e[2],r)};let a=i??e.at(-1),u=E(r.cwd,a,r.fs),l=!s&&r.fs.isDir(u.path);return!l&&(i!==void 0||e.length>2)?(P(r,"cp",a,u.error),{error:`${i===void 0?"target":"target directory"} ${V(a,r)}: ${u.error??"Not a directory"}`}):{target:a,directory:l,sources:i===void 0?e.slice(0,-1):e}}function fA(e,t,n){let{ctx:r}=n,o=E(r.cwd,e,r.fs,{follow:!1}).path;if(o===null)return;let i=e.replace(/\/+$/u,""),s=t.replace(/\/+$/u,"");for(let a of rt(r.fs,o)){if(a.kind!=="link")continue;let u=a.path===o?null:nt(o,a.path);if(!vm(u===null?t:`${s}/${u}`,n)&&!(u!==null&&dA(s,u,n)))throw Em(u===null?e:`${i}/${u}`)}}var vm=(e,t)=>t.noClobber&&E(t.ctx.cwd,e,t.ctx.fs,{follow:!1}).path!==null;function dA(e,t,n){let{ctx:r}=n,o=t.split("/");for(let i=1;i<o.length;i++){let s=E(r.cwd,`${e}/${o.slice(0,i).join("/")}`,r.fs,{follow:!1});if(s.path!==null&&!r.fs.isDir(s.path))return!0}return!1}var Em=e=>new x("feature","symbolic link",`copying a symbolic link is not supported: ${e} (a recursive copy keeps the link, which cp does not make here)`),$m=(e,t,n)=>n.path===null&&e.fs.isLink?.(E(e.cwd,t,e.fs,{follow:!1}).path)===!0,pA=e=>{let t=e.replace(/\/+$/u,"").split("/").at(-1);return t===".."?".":t};function Sm(e,t,n,r=null){let{ctx:o}=n;if(bm(e,o.cwd)||bm(t,o.cwd))throw new x("feature","special file","copying special files is not supported");let i=V(e,o),s=V(t,o);if(n.recursive&&o.fs.isLink?.(E(o.cwd,e,o.fs,{follow:!1}).path)){if(!vm(t,n))throw Em(e);return}let a=D(o,"cp",e),u=d=>yn(n,"cp: "+d+`
175
+ `,!0);if(a.error)return u(`cannot stat ${i}: ${a.error}`);if(o.fs.isDir(a.path))return n.recursive?hA(e,a.path,t,n,r??{source:i,target:s},r===null):u(`-r not specified; omitting directory ${i}`);if(r===null){if(n.sources.has(a.path))return yn(n,`cp: warning: source file ${i} specified more than once
176
+ `,!1,!0);n.sources.add(a.path)}let l=E(o.cwd,t,o.fs);if(l.error&&l.error!=="No such file or directory")return u(`cannot stat ${s}: ${l.error}`);if(n.noClobber&&l.path!==null)return;if(Om(a.path,l.path,o.fs))return u(`${i} and ${s} are the same file`);if(o.fs.isDir(l.path))return u(`cannot overwrite directory ${s} with non-directory ${i}`);let c=me(o.fs,o.cwd,t);if(r===null&&n.copied.has(c))return u(`will not overwrite just-created ${s} with ${i}`);let f=gt(o.cwd,t,o.fs,l);if(Am(i,s,n),$m(o,t,l))return u(`not writing through dangling symlink ${s}`);if(f)return P(o,"cp",t,f),u(`cannot create regular file ${s}: ${f}`);try{if(!o.fs.copyWritable?.(o.cwd,a.path,t))return u(`${n.force&&l.path!==null?"cannot remove":"cannot create regular file"} ${s}: Read-only file system`)}catch(d){if(C(d))throw d;P(o,"cp",d?.path,d?.fsError);let p=K(d);return u(`cannot create regular file ${s}: ${p.startsWith(t+": ")?p.slice(t.length+2):p}`)}r===null&&n.copied.add(c)}function hA(e,t,n,r,o,i){let{ctx:s}=r,a=V(e,s),u=V(n,s),l=y=>yn(r,"cp: "+y+`
177
+ `,!0),c=E(s.cwd,n,s.fs,{follow:!1});if(c.error&&c.error!=="No such file or directory")return l(`cannot stat ${u}: ${c.error}`);let f=n.replace(/\/+$/u,"")||n;if(me(s.fs,s.cwd,f,!0)===t)return l(`${a} and ${u} are the same file`);if(c.path!==null&&!s.fs.isDir(c.path))return l(`cannot overwrite non-directory ${u} with directory ${a}`);let d=me(s.fs,s.cwd,f,!1);if(c.path===null){let y=gt(s.cwd,f,s.fs);if(y)return P(s,"cp",f,y),l(`cannot create directory ${u}: ${y}`);if(!s.writable||!J(d))return l(`cannot create directory ${u}: Read-only file system`)}if(d.startsWith(t==="/"?"/":t+"/"))return l(`cannot copy a directory, ${o.source}, into itself, ${o.target}`);if(i){if(r.sources.has(t))return yn(r,`cp: warning: source directory ${a} specified more than once
178
+ `,!1,!0);r.sources.add(t)}i&&fA(e,n,r);let{dirs:p,files:h,links:m}=s.fs.listDir(t);if(c.path===null&&!mA(e,n,f,d,r))return;let g=e.replace(/\/+$/u,""),w=n.replace(/\/+$/u,"");for(let y of[...p,...h,...m].sort(q))s.io.setReads([]),Sm(`${g}/${y}`,`${w}/${y}`,r,o)}function mA(e,t,n,r,o){let{ctx:i}=o,s=V(t,i),a=l=>(yn(o,"cp: cannot create directory "+s+": "+l+`
179
+ `,!0),!1),u=i.writable&&J(r);u&&Nm(o);try{if(!u||!i.fs.makeWritableDir?.(i.cwd,n))return a("Read-only file system")}catch(l){if(C(l))throw l;P(i,"cp",l?.path,l?.fsError);let c=K(l);return a(c.startsWith(n+": ")?c.slice(n.length+2):c)}return Am(V(e,i),s,o),!0}function Am(e,t,n){n.verbose&&(Nm(n),yn(n,`${e} -> ${t}
180
+ `))}function Nm(e){if(e.outputOverlap)throw new x("feature","copy output buffering","buffered verbose output sharing a copied file is not supported")}function Om(e,t,n){if(e===t)return!0;let r=n.fileIdentity?.(e);return r!==void 0&&r===n.fileIdentity(t)}function gA(e,t,{recursive:n,noClobber:r}){let o=t.outputFds[1];if(typeof o!="object")return!1;let i={ctx:t,recursive:n,noClobber:r,holds:s=>o.identity===void 0?o.path===s:o.identity===t.fs.fileIdentity?.(s),made:new Set,sources:new Set,copied:new Set};return e.some(([s,a])=>wA(s,a,i))}function wA(e,t,n){let{ctx:r}=n,o=E(r.cwd,e,r.fs),i=o.path??j(r.cwd,e),s=o.error==="No such file or directory"&&(n.made.has(i)||bA(i,n));if(o.error&&!s)return!1;let a=me(r.fs,r.cwd,t);return(o.error===null?r.fs.isDir(o.path):!n.made.has(i))?!n.recursive||!vA(i,t,r)||n.sources.has(i)?!1:(n.sources.add(i),yA(i,a,n)):n.sources.has(i)||(n.sources.add(i),n.copied.has(a)||!kA(i,a,t,r,n.noClobber))?!1:(n.copied.add(a),n.made.add(a),n.holds(i)||n.holds(a))}function yA(e,t,n){let{ctx:r}=n,o=e==="/"?0:e.length;for(let i of xA(e,n)){let s=t+i.slice(o);if(!Im(i,s,E(r.cwd,s,r.fs),r,n.noClobber)&&(n.made.add(s),n.holds(i)||n.holds(s)))return!0}return!1}function xA(e,t){let n=e==="/"?"/":e+"/",r=t.ctx.fs.isDir(e)?[...t.ctx.fs.walkFiles(e)]:[];return new Set([...r,...[...t.made].filter(o=>o.startsWith(n))])}var bA=(e,t)=>[...t.made].some(n=>n.startsWith(e+"/"));function Im(e,t,n,r,o){return n.error&&n.error!=="No such file or directory"||o&&n.path!==null||Om(e,n.path,r.fs)||r.fs.isDir(n.path)?!0:!r.writable||!J(t)}function kA(e,t,n,r,o){let i=E(r.cwd,n,r.fs);return!Im(e,t,i,r,o)&&!$m(r,n,i)&&!gt(r.cwd,n,r.fs,i)}function vA(e,t,n){let r=E(n.cwd,t,n.fs,{follow:!1});if(r.error&&r.error!=="No such file or directory")return!1;let o=t.replace(/\/+$/u,"")||t;if(r.path!==null&&!n.fs.isDir(r.path)||r.path===null&&gt(n.cwd,o,n.fs))return!1;let i=me(n.fs,n.cwd,o,!1);return me(n.fs,n.cwd,o,!0)===e||i.startsWith(e==="/"?"/":e+"/")?!1:!!n.writable&&J(i)}function bm(e,t){let n=e.startsWith("/")?e:t+"/"+e;return lA.has(n.replace(/\/\.(?=\/)/gu,"").replace(/\/+/gu,"/"))}function yn(e,t,n=!1,r=!1){let o=n||r?B(t):{...B(),stdout:t,events:[{fd:1,text:t}]};U(e.result,e.ctx.flushOutput(o)),e.failed||=n}function Tm(e,t,n){let{flags:r,positional:o}=N(t,{short:["f","v","r","R"],long:["force","verbose","recursive"]}),i=r.has("f")||r.has("force"),s=r.has("v")||r.has("verbose"),a=r.has("r")||r.has("R")||r.has("recursive");if(o.length===0)return i?R(""):b("rm: missing operand");let u={ctx:n,force:i,verbose:s,recursive:a,events:[],stdout:"",stderr:""};try{for(let l of o)EA(l,u)}catch(l){P(n,"rm",l?.path,l?.fsError);let c=Q(l,"rm","rm: "+K(l));return c.events=[...u.events,{fd:2,text:c.stderr}],c.stdout=u.stdout,c.stderr=u.stderr+c.stderr,c}return{stdout:u.stdout,stderr:u.stderr,events:u.events,exitCode:u.stderr?1:0}}function EA(e,t){let{ctx:n}=t,r=E(n.cwd,e,n.fs,{follow:!1}),o=r.error;if(!(t.force&&(o==="No such file or directory"||o==="Not a directory"))){if(P(n,"rm",e,o),o===null&&n.fs.isDir(r.path))if(!t.recursive)o="Is a directory";else{if([".",".."].includes(e.replace(/\/+$/u,"").split("/").at(-1)))return Ru(t,`rm: refusing to remove '.' or '..' directory: skipping ${V(e,n)}
181
+ `);if(r.path==="/tmp")o="Device or resource busy";else if(!n.writable||!J(r.path))o="Read-only file system";else return Cm(e,r.path,t,$A(n,e)?"Not a directory":null)}Fu(e,r.path,t,!1,o)}}function $A(e,t){let n=t.replace(/\/+$/u,"");return n===t||n===""?!1:e.fs.isLink?.(E(e.cwd,n,e.fs,{follow:!1}).path)===!0}function Cm(e,t,n,r=null){let{ctx:o}=n,{dirs:i,files:s,links:a=[]}=o.fs.listDir(t),u=e.replace(/\/+$/u,"");for(let l of[...i,...s,...a].sort(q)){let c=he(t,l);o.fs.isDir(c)?Cm(`${u}/${l}`,c,n):Fu(`${u}/${l}`,c,n,!1,null)}Fu(e,t,n,!0,r)}function Fu(e,t,n,r,o){let{ctx:i}=n,s=n.verbose||o!==null||!i.writable||!t?.startsWith("/tmp/")?V(e,i):"",a=()=>r?i.fs.removeWritableDir?.(i.cwd,e):i.fs.removeWritable?.(i.cwd,e);try{o===null&&!a()&&(o="Read-only file system")}catch(u){if(C(u))throw u;P(i,"rm",u?.path,u?.fsError);let l=K(u);o=u?.fsError??(l.startsWith(e+": ")?l.slice(e.length+2):l)}if(o)return Ru(n,`rm: cannot remove ${s}: ${o}
182
+ `);n.verbose&&Ru(n,`removed ${r?"directory ":""}${s}
183
+ `,1)}function Ru(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Lm(e,t,n){let{flags:r,positional:o}=N(t,{short:["p","v"],long:["parents","verbose"]});if(o.length===0)return b("mkdir: missing operand");let i={ctx:n,events:[],stdout:"",stderr:"",parents:r.has("p")||r.has("parents"),verbose:r.has("v")||r.has("verbose")};try{for(let s of o)i.parents?SA(s,i):Mu(s,i,!0)}catch(s){P(n,"mkdir",s?.path,s?.fsError);let a=Q(s,"mkdir","mkdir: "+K(s));return a.events=[...i.events,{fd:2,text:a.stderr}],a.stdout=i.stdout,a.stderr=i.stderr+a.stderr,a}return{stdout:i.stdout,stderr:i.stderr,events:i.events,exitCode:i.stderr?1:0}}function SA(e,t){let n=e.split("/"),r=[];for(let o=0;o<n.length;o++)n[o]!==""&&r.push(n.slice(0,o+1).join("/"));if(r.length===0){e===""&&Mu(e,t,!0);return}r[r.length-1]=e;for(let[o,i]of r.entries())if(!Mu(i,t,o===r.length-1))return}function Mu(e,t,n){let{ctx:r}=t,o=V(e,r),i=l=>(_m(t,`mkdir: cannot create directory ${o}: ${l}
184
+ `),!1),s=e.replace(/\/+$/u,"")||e,a=E(r.cwd,s,r.fs);if(a.error===null)return t.parents?r.fs.isDir(a.path)?!0:i(n?"File exists":"Not a directory"):i("File exists");if(E(r.cwd,s,r.fs,{follow:!1}).error===null)return i(!t.parents||n||a.error!=="Not a directory"?"File exists":"Not a directory");let u=gt(r.cwd,s,r.fs,a);if(u)return P(r,"mkdir",s,u),i(u);try{if(!r.fs.makeWritableDir?.(r.cwd,s))return i("Read-only file system")}catch(l){if(C(l))throw l;P(r,"mkdir",l?.path,l?.fsError);let c=K(l);return i(c.startsWith(s+": ")?c.slice(s.length+2):c)}return t.verbose&&_m(t,`mkdir: created directory ${o}
185
+ `,1),!0}function _m(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Fm(e,t,n){let{flags:r,positional:o}=N(t,{short:["c"],long:["no-create"]});if(o.length===0)return b("touch: missing file operand");let i=r.has("c")||r.has("no-create"),s={ctx:n,stderr:"",failed:!1,gap:null};for(let u of o)AA(u,i,s);let a={stdout:"",stderr:s.stderr,exitCode:s.failed?1:0};return s.gap?X(a,"feature","touch","times",s.gap):a}function AA(e,t,n){let{ctx:r}=n,o=V(e,r),i=E(r.cwd,e,r.fs);if(i.error===null)return NA(e,o,i.path,n);let s=t||e.endsWith("/");if(t&&i.error==="No such file or directory")return;if(P(r,"touch",e,i.error),s)return no(n,`setting times of ${o}: ${i.error}`);let a=gt(r.cwd,e,r.fs,i);if(a)return no(n,`cannot touch ${o}: ${a}`);try{r.fs.openWritable?.(r.cwd,e,!0)||no(n,`cannot touch ${o}: Read-only file system`)}catch(u){if(C(u))throw u;P(r,"touch",u?.path,u?.fsError);let l=K(u);no(n,`cannot touch ${o}: ${l.startsWith(e+": ")?l.slice(e.length+2):l}`)}}function NA(e,t,n,r){let{ctx:o}=r;if(!o.writable||!J(n))return no(r,`setting times of ${t}: Read-only file system`);let i=`touch: setting the times of ${t} is not supported (every entry here carries the one time this filesystem keeps)`;r.gap??=i,r.stderr+=i+`
186
+ `,r.failed=!0}function no(e,t){e.stderr+=`touch: ${t}
187
+ `,e.failed=!0}function ro(e,t,n,r){if(t===""||t.includes("\0"))return{error:"No such file or directory"};if(r==="none")return OA(e,t,n);let o=t;if(r==="logical"){let s=n==="m"?{path:j(e.cwd,t)}:Dm(e,t);if(s.error)return s;o=s.path+(t.endsWith("/")?"/":"")}let i=tt(e.cwd,o,e.fs,{lenient:n==="m"});return n==="m"?{path:i.rest.length?j(i.path,i.rest.join("/")):i.path}:i.error==="No such file or directory"&&i.rest.length===0&&n!=="e"?{path:i.path}:i.error?{error:i.error}:t.endsWith("/")&&!e.fs.isDir(i.path)?{error:"Not a directory"}:{path:i.path}}function OA(e,t,n){if(n==="m")return{path:j(e.cwd,t)};let r=Dm(e,t);if(r.error||n!=="e")return r;let o=E("/",r.path,e.fs);return o.error?{error:o.error}:r}function Dm(e,t){let n=(t.startsWith("/")?t:e.cwd+"/"+t).split("/").filter(Boolean),r="/";for(let o=0;o<n.length;o++){let i=n[o];if(i==="..")r=oe(r);else if(i!=="."){r=he(r,i);let s=o+1;for(;n[s]===".";)s++;let a=n[s]===".."||s===n.length&&(o<n.length-1||t.endsWith("/"));if(a||o===n.length-1){let u=E("/",r+(a?"/":""),e.fs);if(u.error&&!(u.error==="No such file or directory"&&o===n.length-1))return u}}}return{path:r}}function Du(e,t){let n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o++;return[...n.slice(o).map(()=>".."),...r.slice(o)].join("/")||"."}var Um=(e,t)=>e==="/"||t===e||t.startsWith(e+"/"),Rm={e:"e","canonicalize-existing":"e",m:"m","canonicalize-missing":"m"},Mm={P:"physical",physical:"physical",L:"logical",logical:"logical",s:"none",strip:"none","no-symlinks":"none"};function IA(e,t,n,r){let o=t.get("relative-base"),i=t.get("relative-to")??o,s={};for(let[a,u]of[["target",i],["base",o]]){if(u===void 0)continue;let l=ro(e,u,n,r),c=l.error??(n==="e"&&!e.fs.isDir(l.path)?"Not a directory":null);if(c)return P(e,"realpath",u,c),{error:b(`realpath: ${pe(u,e)}: ${c}`)};s[a]=l.path}return s.base&&!Um(s.base,s.target)&&delete s.target,s}function Pm(e,t,n){let{flags:r,values:o,positional:i,order:s}=N(t,{short:["e","m","L","P","s","q","z"],long:["canonicalize-existing","canonicalize-missing","logical","physical","strip","no-symlinks","quiet","zero"],valueLong:["relative-to","relative-base"]});if(!i.length)return b("realpath: missing operand");let a="physical",u="E";for(let{name:h}of s)Object.hasOwn(Rm,h)&&(u=Rm[h]),Object.hasOwn(Mm,h)&&(a=Mm[h]);let l=IA(n,o,u,a);if(l.error)return l.error;let c=r.has("q")||r.has("quiet"),f=r.has("z")||r.has("zero")?"\0":`
188
+ `,d=B(),p=!1;for(let h of i){let m=ro(n,h,u,a);if(m.error)P(n,"realpath",h,m.error),c||U(d,b(`realpath: ${pe(h,n)}: ${m.error}`)),p=!0;else{let g=l.target&&(!l.base||Um(l.base,m.path))?Du(l.target,m.path):m.path;U(d,R(g+f))}}return d.exitCode=p?1:0,d}var qi={symbolic:"s",force:"f","no-dereference":"n","no-target-directory":"T",verbose:"v",relative:"r",logical:"L",physical:"P"};function Bm(e,t,n){let r=N(t,{short:Object.values(qi),long:Object.keys(qi),valueShort:["t"],valueLong:["target-directory"]}),o=l=>r.flags.has(l)||r.flags.has(Object.keys(qi).find(c=>qi[c]===l)),i={force:o("f"),noDereference:o("n"),noTargetDirectory:o("T"),verbose:o("v"),relative:o("r")},s=r.order.findLast(({name:l})=>l==="t"||l==="target-directory")?.value??null,a=r.positional;if(s!==null&&i.noTargetDirectory)return b("ln: cannot combine --target-directory and --no-target-directory");if(i.relative&&!o("s"))return b("ln: cannot do --relative without --symbolic");if(a.length===0)return b("ln: missing file operand");if(!o("s"))return v("feature","ln","hard link",`ln: hard links are not supported: ${V(a[0],n)} (ln -s makes a symbolic one)`);let u={ctx:n,events:[],stdout:"",stderr:""};try{let l=TA(a,s,i,n);if(l.error)return l.error;for(let[c,f,d]of l)CA(c,f,i,u,d)}catch(l){P(n,"ln",l?.path,l?.fsError);let c=Q(l,"ln","ln: "+K(l));return c.events=[...u.events,{fd:2,text:c.stderr}],c.stdout=u.stdout,c.stderr=u.stderr+c.stderr,c}return{stdout:u.stdout,stderr:u.stderr,events:u.events,exitCode:u.stderr?1:0}}function TA(e,t,n,r){let o=u=>V(u,r);if(t!==null){let u=E(r.cwd,t,r.fs);return u.error?(P(r,"ln",t,u.error),{error:b(`ln: failed to access ${o(t)}: ${u.error}`)}):r.fs.isDir(u.path)?e.map(l=>Uu(t,l)):{error:b(`ln: target ${o(t)} is not a directory`)}}if(e.length===1)return n.noTargetDirectory?{error:b(`ln: missing destination file operand after ${o(e[0])}`)}:[Uu(".",e[0])];if(e.length===2){let u=E(r.cwd,e[1],r.fs,{follow:!n.noDereference});if(n.noTargetDirectory||u.error!==null||!r.fs.isDir(u.path))return[[e[0],e[1]]]}if(n.noTargetDirectory)return{error:b(`ln: extra operand ${o(e[2])}`)};let i=e.at(-1),s=E(r.cwd,i,r.fs),a=s.error??(r.fs.isDir(s.path)?null:"Not a directory");return a?(P(r,"ln",i,a),{error:b(`ln: target ${o(i)}: ${a}`)}):e.slice(0,-1).map(u=>Uu(i,u))}function Uu(e,t){let n=t.replace(/\/+$/u,"").split("/").at(-1);return[t,e+(e.endsWith("/")?"":"/")+n,n===""]}function CA(e,t,n,r,o=!1){let{ctx:i}=r,s=V(t,i),a=n.relative?LA(i,e,t):e,u=c=>Pu(r,`ln: failed to create symbolic link ${s}${c}
189
+ `);if(a==="")return u(` -> ${V(a,i)}: No such file or directory`);if(o)return u(": No such file or directory");if(n.force){let c=E(i.cwd,t,i.fs,{follow:!1});if(c.error===null){if(i.fs.isDir(c.path))return Pu(r,`ln: ${pe(t,i)}: cannot overwrite directory
190
+ `);try{if(!i.fs.removeWritable?.(i.cwd,t))return u(": Read-only file system")}catch(f){if(C(f))throw f;return u(`: ${zm(f,t)}`)}}}let l=_A(i,t);if(l)return P(i,"ln",t,l),u(`: ${l}`);try{if(!i.fs.makeWritableLink?.(i.cwd,t,a))return u(": Read-only file system")}catch(c){if(C(c))throw c;return P(i,"ln",c?.path,c?.fsError),u(`: ${zm(c,t)}`)}n.verbose&&Pu(r,`${s} -> ${V(a,i)}
191
+ `,1)}function _A(e,t){if(t===""||t.includes("\0"))return"No such file or directory";let n=t.replace(/\/+$/u,"");if(n==="")return"File exists";let r=E(e.cwd,n,e.fs,{follow:!1});if(r.error===null)return"File exists";if(r.error!=="No such file or directory"||t!==n)return r.error;let o=tt(e.cwd,n,e.fs);return o.rest.length>0?o.error:null}function LA(e,t,n){let r=ro(e,oe(n),"m","physical"),o=ro(e,t,"m","physical");return r.error||o.error?t:Du(r.path,o.path)}function zm(e,t){let n=K(e);return e?.fsError??(n.startsWith(t+": ")?n.slice(t.length+2):n)}function Pu(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function jm(e,t,n){let{flags:r,positional:o}=N(t,{short:["a","i","p"],long:["append","ignore-interrupts"]}),i=r.has("a")||r.has("append"),s=n.stdinBytes;z(n,"",!0);let a=s??I(e),u={stderr:"",status:0,gap:null};for(let d of o)FA(d,a,i,u,n);let l=[{fd:1,bytes:a},...u.stderr?[{fd:2,text:u.stderr}]:[]],c=s===null?{stdout:e,stderr:u.stderr,exitCode:u.status}:{stdout:"",stderr:u.stderr,exitCode:u.status,events:l};if(!u.gap)return c;let f=C(u.gap);return X({...c,exitCode:1},f.kind,f.command,f.detail,f.message)}function FA(e,t,n,r,o){if(e==="/dev/null")return;let i;try{i=o.writable&&o.fs.openWritable?.(o.cwd,e,n)}catch(s){r.stderr+=`tee: ${s.message}
192
+ `,r.status=1;return}if(!i){r.gap??=v("feature","tee","read-only target",`tee: ${e}: Read-only file system`,1),r.stderr+=`tee: ${e}: Read-only file system
193
+ `;return}i.writeBytes(t)}var Wm={cp:km,rm:Tm,mkdir:Lm,touch:Fm,ln:Bm,tee:jm};function RA(e,t,n){let{positional:r}=N(t),o=ae("tac",r,e,n),i=[];for(let{content:s}of o.inputs)i.push(...ot(s).toReversed());return ue(i.join(""),o)}var qm=1e6;function MA(e,t){let{flags:n,values:r,positional:o}=N(t,{short:["w"],valueShort:["s"],numericOperands:!0});if(o.length===0||o.length>3)return xe("seq [-w] [-s SEP] LAST | seq FIRST LAST | seq FIRST INCR LAST");let i=[];for(let p of o){if(!/^[+-]?\d+$/u.test(p))return Number.isFinite(Number(p))&&p.trim()!==""||/^[+-]?inf(?:inity)?$/iu.test(p)?v("feature","seq","non-integer operands","seq: non-integer operands are not supported"):b(`seq: invalid integer: ${p}`);i.push(BigInt(p))}let s=i.length===1?1n:i[0],a=i.length===3?i[1]:1n,u=i.at(-1);if(a===0n)return b("seq: increment must be non-zero");let c=(a>0?s<=u:s>=u)?(u>s?u-s:s-u)/(a>0n?a:-a)+1n:0;if(c>qm)return v("feature","seq","sequence limit",`seq: range too large: ${c} elements exceeds limit of ${qm}`);let f=n.has("w")?Math.max(...[o[0],o.at(-1)].map(p=>p.replace(/^\+/u,"").length)):0,d=[];for(let p=0,h=s;p<c;p++,h+=a)d.push(DA(String(h),f));return R(d.length===0?"":d.join(r.get("s")??`
194
+ `)+`
195
+ `)}function DA(e,t){if(e.length>=t)return e;let n=e.startsWith("-"),r=n?e.slice(1):e;return(n?"-":"")+r.padStart(t-(n?1:0),"0")}function UA(e,t,n){let{positional:r}=N(t);if(r.length===0)return xe("which COMMAND...");let o=[],i=0;for(let s of r)n.hasCommand(s)?o.push(`/usr/bin/${s}`):(o.push(`${s} not found`),i=1);return{stdout:Ee(o),stderr:"",exitCode:i}}function PA(e,t,n){let{positional:r}=N(t);return r.length>0?b(`whoami: extra operand: ${r[0]}`):R((n.user??"user")+`
196
+ `)}function zA(e,t,n){let{flags:r,positional:o}=N(t,{short:["u"]});if(o.length>1)return b(`date: at most one +FORMAT argument is supported (got: ${o[1]})`);let i="%a %b %e %T %Z %Y";if(o.length===1){if(!o[0].startsWith("+"))return xe("date [-u] [+FORMAT]");i=o[0].slice(1)}return(i.match(/%./gu)??[]).some(s=>/%[-_0^#0-9:EOcCDgGhIjklNpPrRuUVwWxXy+]/u.test(s))?v("feature","date","format","date: this format directive or modifier is not supported"):R(Ht(new Date,i,r.has("u")||n.vars.has("TZ"))+`
197
+ `)}var BA=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],jA=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],WA=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],qA=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ht(e,t,n){let r="get"+(n?"UTC":""),[o,i,s,a,u,l,c]=["FullYear","Month","Date","Hours","Minutes","Seconds","Day"].map(p=>e[r+p]()),f=(p,h="0")=>String(p).padStart(2,h),d={__proto__:null,Y:String(o),m:f(i+1),d:f(s),e:f(s," "),H:f(a),M:f(u),S:f(l),T:[a,u,l].map(p=>f(p)).join(":"),F:[o,f(i+1),f(s)].join("-"),q:String(Math.floor(i/3)+1),s:String(Math.floor(e.getTime()/1e3)),a:BA[c],A:jA[c],b:WA[i],B:qA[i],Z:()=>HA(e,n),z:()=>GA(e,n),n:`
198
+ `,t:" ","%":"%"};return t.replace(/%./gu,p=>{let h=d[p[1]];return typeof h=="function"?h():h??p})}function HA(e,t){if(t)return"UTC";try{return new Intl.DateTimeFormat("en-US",{timeZoneName:"short"}).formatToParts(e).find(o=>o.type==="timeZoneName")?.value??"Local"}catch{return"Local"}}function GA(e,t){if(t)return"+0000";let n=-e.getTimezoneOffset(),r=n>=0?"+":"-",o=Math.abs(n);return`${r}${String(Math.floor(o/60)).padStart(2,"0")}${String(o%60).padStart(2,"0")}`}var Hm={rg:lm,cut:gm,tac:RA,tr:ym,seq:MA,nl:mm,which:UA,hexdump:Rh,base64:Zh,...Wm},Gm={whoami:PA,date:zA,od:Mh,xxd:Dh,base32:Xh,...Nh};var zu=new Map(Object.entries({all:"a","apparent-size":"A",bytes:"b",total:"c",null:"0","count-links":"l",summarize:"s","separate-dirs":"S","human-readable":"h","max-depth":"d","block-size":"B",dereference:"L","dereference-args":"D","no-dereference":"P"})),Xm={P:"none",D:"args",H:"args",L:"all"};function Ym(e,t){let n=N(e,{short:["0","a","A","b","c","h","H","k","l","m","s","S","L","D","P"],long:[...zu.keys()].filter(i=>!["d","B"].includes(zu.get(i))).concat(["inodes","si"]),valueShort:["d","B"],valueLong:["max-depth","block-size"]}),r={operands:n.positional.length?n.positional:["."],depth:1/0,flags:new Set,links:"none",scale:null,stderr:""};for(let{name:i,value:s}of n.order){let a=zu.get(i)??i;r.flags.add(a),Object.hasOwn(Xm,a)&&(r.links=Xm[a]),a==="d"&&(r.depth=XA(s)),a==="B"&&(r.scale=Zm(s)),a==="b"&&(r.flags.add("A"),r.scale={unit:1n}),(a==="k"||a==="m")&&(r.scale={unit:a==="k"?1024n:1024n**2n}),(a==="h"||a==="si")&&(r.scale={base:a==="h"?1024n:1000n,unit:1n})}let{flags:o}=r;if(o.has("a")&&o.has("s"))throw new Error("cannot both summarize and show all entries");if(o.has("s")&&o.has("d")){if(r.depth!==0)throw new Error(`summarizing conflicts with --max-depth=${r.depth}`);r.stderr+=`du: warning: summarizing is the same as using --max-depth=0
199
+ `}if(o.has("s")&&(r.depth=0),o.has("inodes")&&o.has("A")&&(r.stderr+=`du: warning: options --apparent-size and -b are ineffective with --inodes
200
+ `),!r.scale){let i=t.vars.get("DU_BLOCK_SIZE")??t.vars.get("BLOCK_SIZE")??t.vars.get("BLOCKSIZE");try{r.scale=i===void 0?{unit:t.vars.has("POSIXLY_CORRECT")?512n:1024n}:Zm(i)}catch(s){throw s instanceof x?s:new x("feature","invalid block size environment","invalid block size environment settings are not supported")}}return o.has("inodes")&&(r.scale={...r.scale,unit:1n,suffix:r.scale.suffix?.endsWith("B")?"B":""}),r.scale.base&&ju(t,r.scale.base),r}function ju(e,t=1024n){let n=e.vars.get("LC_ALL")||e.vars.get("LC_NUMERIC")||e.locale;if(!/^(?:C|POSIX|C\.UTF-?8)$/iu.test(n))throw new x("feature","numeric locale","human-readable sizes in this numeric locale are not supported");return{base:t,unit:1n}}function XA(e){let t=/^[ \t\n\r\v\f]*([+-]?)(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.exec(e);if(!t)throw new Error(`invalid maximum depth: ${e}`);let n=Vm(t[2]);if(n>ge||t[1]==="-"&&n!==0n)throw new Error(`invalid maximum depth: ${e}`);return Number(n)}function Vm(e){return BigInt(/^0[0-7]+$/u.test(e)?"0o"+e:e)}function Zm(e){let t=e&&["human-readable","si"].find(u=>u.startsWith(e));if(t)return{base:t==="si"?1000n:1024n,unit:1n};if(e.startsWith("'"))throw new x("feature","grouped block sizes","grouped block sizes are not supported");let n=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)?([kKmMgGtTPEZYRQ](?:i?B|D)?)?$/u.exec(e);if(!n||!n[1]&&e!==n[2])throw new Error(`invalid block size: ${e}`);let r=n[2]??"",o=r?"KMGTPEZYRQ".indexOf(r[0].toUpperCase())+1:0,i=/[BD]$/u.test(r)&&!r.endsWith("iB")?1000n:1024n,s=(n[1]?Vm(n[1]):1n)*i**BigInt(o);if(s===0n||s>yt)throw new Error(`invalid block size: ${e}`);let a=n[1]||!r?"":(o===1&&r.endsWith("B")&&i===1000n?"k":r[0].toUpperCase())+(r.endsWith("B")?i===1000n?"B":"iB":"");return{unit:s,suffix:a}}var xn=4096,ZA=60,Hi=(e,t)=>t==="dir"?xn:t==="link"&&e<ZA?0:Math.ceil(e/xn)*xn,Bu=(e,t)=>(e+t-1n)/t;function oo(e,{base:t,unit:n,suffix:r=""}){if(!t)return String(Bu(e,n))+r;let o=1n,i=0;for(;e>=o*t;)o*=t,i++;if(!i)return String(e);let s=Bu(e*10n,o),a;return s<100n?a=`${s/10n}.${s%10n}`:(s=Bu(e,o),s===t?(i++,a="1.0"):a=String(s)),a+(i===1&&t===1000n?"k":"KMGTPEZYRQ"[i-1])}var YA=31556952*1e3/2;function Km(e,t){for(let c of["LS_BLOCK_SIZE","BLOCK_SIZE","BLOCKSIZE"])if(e.vars.has(c))throw new x("feature","block size environment",`${c} is not supported in a long listing`);let n=t?ju(e):null,r=e.user??"user",o=e.createdAt,i=Date.now(),s=o<=i&&i-o<YA,a=Ht(new Date(o),s?"%b %e %H:%M":"%b %e %Y",e.vars.has("TZ")),u=c=>n?oo(BigInt(c),n):String(c),l=c=>Math.max(0,...c.map(f=>f.length));return{lines(c,f){let d=c.map(({name:g,abs:w,kind:y,target:$})=>{let S=y==="dir",_=S?xn:e.fs.fileSize(w)??I(e.fs.readFile(w)).length,W=S?"drwx------":y==="link"?"lrwxrwxrwx":"-rw-------",H=Hi(_,y)/512;return{name:y==="link"?`${g} -> ${$}`:g,mode:W,units:H,links:String(S?2+e.fs.listDir(w).dirs.length:1),size:u(_)}}),p=l(d.map(g=>g.links)),h=l(d.map(g=>g.size)),m=d.map(g=>`${g.mode} ${g.links.padStart(p)} ${r} ${r} ${g.size.padStart(h)} ${a} ${g.name}`);if(f){let g=d.reduce((w,y)=>w+y.units,0);m.unshift("total "+(n?oo(BigInt(g)*512n,n):String(g/2)))}return m}}}var Jm=Object.freeze({utf8:{down:"\u251C\u2500\u2500 ",last:"\u2514\u2500\u2500 ",through:"\u2502\xA0\xA0 ",past:" "},ascii:{down:"|-- ",last:"`-- ",through:"| ",past:" "}}),VA=e=>ee(e)?Jm.ascii:Jm.utf8;function Qm(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["a","d","F"],long:["noreport"],valueShort:["L"]});if(i.length>1)return v("feature","tree","multiple roots","tree: multiple roots are not supported");let s=o.has("L")?Pe(o.get("L"),"tree: -L",o.get("L"),{max:2147483647}):{value:Number.POSITIVE_INFINITY};if(s.error)return s.error;if(!s.value)return b("tree: -L must be greater than zero");let a=i[0]??".",{path:u,error:l}=D(n,"tree",a),c=!l&&n.fs.isDir(u),f=E(n.cwd,a,n.fs,{follow:!1}),d=!!l&&!!f.error,p={dirs:c&&Gi(n.fs,u,r).length?1:0,files:!d&&!c?1:0},h=[a+KA(n,r,f,c)+(c?"":" [error opening dir]")];if(c){let m=new Set,g=Rn();try{let w=JA(n.fs,u,h,r,s.value,p,m,g,VA(n));if(w)return w}finally{Ft(n.notes,{command:"tree",action:"depth limit omitted contents of",noun:["directory","directories"],paths:m}),g.emit(n.notes,"tree","Hidden entries are included with -a.")}}if(!r.has("noreport")){let m=`${p.dirs} ${p.dirs===1?"directory":"directories"}`,g=`${p.files} ${p.files===1?"file":"files"}`;h.push("",r.has("d")?m:`${m}, ${g}`)}return{stdout:h.join(`
201
+ `)+`
202
+ `,stderr:"",exitCode:d?2:0}}function KA(e,t,n,r){return t.has("F")?!n.error&&e.fs.isLink?.(n.path)===!0?"@":r&&!t.has("d")?"/":"":""}function JA(e,t,n,r,o,i,s,a,u){let l=[{dir:t,prefix:"",items:Gi(e,t,r,a),i:0,depth:0}];for(;l.length;){let c=l.at(-1);if(c.i>=c.items.length){l.pop();continue}let{n:f,isDir:d,target:p}=c.items[c.i++];if([...f+(p??"")].some(y=>y.codePointAt(0)<32||y.codePointAt(0)===127||y==="\\"))return v("feature","tree","filename escaping","tree: listing names requiring escaping is not supported");let h=c.i===c.items.length,m=d&&r.has("F")&&!r.has("d")?"/":"";if(n.push(c.prefix+(h?u.last:u.down)+f+(p===void 0?m:" -> "+p+m)),i[d?"dirs":"files"]++,!d||p!==void 0)continue;let g=he(c.dir,f);if(c.depth+1>=o){Gi(e,g,r).length&&s.add(g);continue}let w=Gi(e,g,r,a);l.push({dir:g,prefix:c.prefix+(h?u.past:u.through),items:w,i:0,depth:c.depth+1})}}function Gi(e,t,n,r=null){let{dirs:o,files:i,links:s}=e.listDir(t),a=s.map(l=>{let c=E(t,l,e);return{n:l,isDir:!c.error&&e.isDir(c.path),target:e.readLink(he(t,l))}}),u=n.has("d")?a.filter(({isDir:l})=>l):[...i.map(l=>({n:l,isDir:!1})),...a];return r&&!n.has("a")&&r.collect(t,[...o,...u.map(({n:l})=>l)]),[...o.map(l=>({n:l,isDir:!0})),...u].filter(({n:l})=>n.has("a")||!l.startsWith(".")).sort((l,c)=>q(l.n,c.n))}var QA=new Set(["name","iname","type","path","ipath","lname","ilname","size","mindepth","maxdepth"]),io=(e,t)=>e==="-"+t||e==="--"+t;function t0(e){let t={tokens:e,i:0,depth:{minDepth:0,maxDepth:Number.POSITIVE_INFINITY,deepestFirst:!1},hasAction:!1,batches:[],error:null},n=[];for(e[0]==="--"&&t.i++;t.i<e.length&&!/^(?:-.+|!|\()$/u.test(e[t.i]);)n.push(e[t.i++]);let r=n0(t,0);if(t.error)return{error:t.error};if(!t.hasAction)for(let o of r)o.push({kind:"print"});return{starts:n.length?n:["."],...t.depth,groups:r,batches:t.batches}}function n0(e,t){let n=[[]],r=!1;if(t>128)return e.error=v("feature","find","expression depth","find: expression nesting above 128 is not supported"),n;for(;e.i<e.tokens.length&&!e.error;){let o=e.tokens[e.i];if(o===")"){t||(e.error=b("find: unexpected closing parenthesis"));break}if(o==="-a"||io(o,"and")||o==="-o"||io(o,"or")){if(r||n.at(-1).length===0){e.error=b(`find: ${o} with no left-hand expression`);break}(o==="-o"||io(o,"or"))&&n.push([]),e.i++,r=o;continue}let i=eN(e,t);i&&n.at(-1).push(i),r=!1}return!e.error&&r&&(e.error=b(`find: ${r} with no right-hand expression`)),!e.error&&t&&n.at(-1).length===0&&(e.error=b("find: expected an expression")),!e.error&&t&&(e.tokens[e.i]===")"?e.i++:e.error=b("find: missing closing parenthesis")),n}function eN(e,t){let n=e.i,r=!1;for(;e.tokens[e.i]==="!"||e.tokens[e.i]==="-not";)r=!r,e.i++;let o=e.tokens[e.i++];if(o==="(")return{kind:"group",groups:n0(e,t+1),negate:r};if(o===void 0||o===")"||o==="-a"||o==="-o"||io(o,"and")||io(o,"or"))return e.error=b(`find: -not or operator ${o??""} must be followed by a primary`),null;let i=o.startsWith("--")?o.slice(2):o.startsWith("-")?o.slice(1):null;if(["print","print0","prune","empty"].includes(i))return(i==="print"||i==="print0")&&(e.hasAction=!0),{kind:i,negate:r};if(i==="depth"||i==="d")return e.depth.deepestFirst=!0,{kind:"true",negate:r};if(i==="exec"){let s=aN(e.tokens,e.i-1,r);return s.error?(e.error=s.error,null):(e.i=s.nextI+1,e.hasAction=!0,s.pred.mode==="batch"&&e.batches.push(s.pred),s.pred)}if(QA.has(i)){if(e.i===e.tokens.length)return e.error=b(`find: ${o} requires a value`),null;let s=tN(i,e.tokens[e.i++],r,e.depth);return s.error?(e.error=s.error,null):s}return o===","?(e.error=v("feature","find","comma operator","find: comma expressions are not supported"),null):e.i-1>n&&!o.startsWith("-")?(e.error=b(`find: -not must be followed by a primary, got: ${o}`),null):(e.error=o==="--"||!o.startsWith("-")?b(`find: paths must precede expression: ${o}`):v("option","find",o,`find: unknown option: ${o}`),null)}function tN(e,t,n,r){if(e==="type"){let o=sN(t);return o.error?o:{kind:e,negate:n,types:o.types}}if(e==="size")return oN(t,n);if(e==="mindepth"||e==="maxdepth"){let o=Pe(t,`find: -${e}`,t,{max:2147483647,digitsOnly:!0});return o.error?o:(r[e==="mindepth"?"minDepth":"maxDepth"]=o.value,{kind:"true",negate:n})}return{kind:e,negate:n,re:He(t,{ignoreCase:e.startsWith("i")})}}var nN={__proto__:null,b:512,c:1,w:2,k:1024,M:1048576,G:1073741824},rN=/^([+-]?)(\d+)([a-zA-Z]?)$/u;function oN(e,t){if(e==="")return{error:b("find: invalid null argument to -size")};let n=rN.exec(e);if(!n||!Number.isSafeInteger(Number(n[2])))return{error:b(`find: Invalid argument \`${e}' to -size`)};let[,r,o,i]=n,s=nN[i===""?"b":i];return s===void 0?{error:b(`find: invalid -size type \`${i}'`)}:{kind:"size",negate:t,sign:r,count:Number(o),unit:s}}var e0="fdl",iN="bcps";function sN(e){let t=e.split(","),n=t.find((i,s)=>t.indexOf(i)!==s);if(n!==void 0)return{error:b(`find: Duplicate file type '${n}' in the argument list to -type.`)};if(t.every(i=>i.length===1&&e0.includes(i)))return{types:t};let r=`find: -type/--type expects 'f', 'd' or 'l', got: ${e}`;return{error:t.every(i=>i.length===1&&(e0+iN).includes(i))?v("option","find",`-type ${e}`,r):b(r)}}function aN(e,t,n){let r=t+1;for(;r<e.length&&e[r]!==";"&&!(e[r]==="+"&&e[r-1]==="{}");)r++;if(r>=e.length)return{error:b("find: -exec: missing terminator (`;` or `{} +`); quote or escape `;`")};if(r===t+1)return{error:b("find: -exec: requires a command")};let o=e.slice(t+1,r),i=e[r]===";"?"each":"batch";if(i==="batch"){if(o.slice(0,-1).some(a=>a.includes("{}")))return{error:b("find: -exec ... +: only one instance of `{}` is supported")};if(n)return{error:v("feature","find","-not -exec ... +","find: `-not -exec ... +` is not supported (the `+` form has no meaningful negation)")}}let s={kind:"exec",mode:i,cmd:o[0],args:o.slice(1),negate:n};return i==="batch"&&(s.collected=[]),{pred:s,nextI:r}}var uN={file:"f",dir:"d",link:"l"},lN=(e,t)=>e.kind==="dir"?xn:t.fs.fileSize?.(e.abs)??I(t.fs.readFile(e.abs)).length;async function r0(e,t,n){let r=t0(t);if(r.error)return r.error;if(e!==""&&t.some(d=>d==="-exec"||d==="--exec"))return v("feature","find","-exec stdin","find: passing shared standard input to -exec is not supported");let{starts:o,minDepth:i,maxDepth:s,deepestFirst:a,groups:u,batches:l}=r,c=B(),f=new Set;try{for(let d of o){let{path:p,error:h}=D(n,"find",d,{follow:!1});if(h){Wu(c,n.flushOutput(B(`find: '${d}': ${h}
203
+ `))),c.exitCode=1;continue}let m=new Set,g=rt(n.fs,p,s,w=>!m.has(w));for(let w of a?cN(g):g){let y=dN(d,p,w.path);if(w.depth>=i&&await o0(u,{kind:w.kind,path:y,abs:w.path,prune:m},n,c),w.kind!=="dir"||w.depth!==s||m.has(w.path))continue;let{dirs:$,files:S,links:_}=n.fs.listDir(w.path);($.length||S.length||_.length)&&f.add(y)}}for(let d of l){if(d.collected.length===0)continue;let p=d.args.slice(0,-1).concat(d.collected);await i0(d.cmd,p,n,c)||(c.exitCode=1)}}finally{Ft(n.notes,{command:"find",action:"depth limit omitted contents of",noun:["directory","directories"],paths:f})}return c}function*cN(e){let t=[];for(let n of e){for(;t.length>0&&t.at(-1).depth>=n.depth;)yield t.pop();n.kind==="dir"?t.push(n):yield n}for(;t.length>0;)yield t.pop()}async function o0(e,t,n,r){for(let o of e){let i=!0;for(let s of o)if(await fN(s,t,n,r)===!!s.negate){i=!1;break}if(i)return!0}return!1}function fN(e,t,n,r){if(e.kind==="group")return o0(e.groups,t,n,r);if(e.kind==="true")return!0;if(e.kind==="type")return e.types.includes(uN[t.kind]);if(e.kind==="name"||e.kind==="iname")return e.re.test(t.path.replace(/\/+$/u,"").split("/").at(-1)||"/");if(e.kind==="prune")return t.kind==="dir"&&t.prune.add(t.abs),!0;if(e.kind==="empty"){if(t.kind==="link")return!1;if(t.kind==="file")return n.fs.isEmptyFile(t.abs);let{dirs:o,files:i,links:s}=n.fs.listDir(t.abs);return o.length+i.length+s.length===0}if(e.kind==="path"||e.kind==="ipath")return e.re.test(t.path);if(e.kind==="lname"||e.kind==="ilname")return t.kind==="link"&&e.re.test(n.fs.readLink?.(t.abs)??"");if(e.kind==="size"){let o=Math.ceil(lN(t,n)/e.unit);return e.sign==="+"?o>e.count:e.sign==="-"?o<e.count:o===e.count}return e.kind==="print"||e.kind==="print0"?(Wu(r,n.flushOutput({stdout:t.path+(e.kind==="print"?`
204
+ `:"\0"),stderr:"",exitCode:0})),!0):e.mode==="batch"?(e.collected.push(t.path),!0):i0(e.cmd,e.args.map(o=>o.replaceAll("{}",t.path)),n,r)}async function i0(e,t,n,r){let o=await n.dispatch(e,t,"");return Wu(r,o),o.exitCode===0}function Wu(e,t){let n=e.exitCode;U(e,t),e.exitCode=n}function dN(e,t,n){if(n===t)return e;let r=nt(t,n);return e.endsWith("/")?e+r:e+"/"+r}var Hu=1e5,pN=/^([+-]?\d+)\.\.([+-]?\d+)(?:\.\.([+-]?\d+))?$/u,hN=/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([+-]?\d+))?$/u,s0=2n**63n-1n,a0=-(2n**63n),qu=e=>{let t=BigInt(e);return t>s0||t<a0?null:t},u0=(e,t)=>e.mask===null?"0":e.mask[t];function Gu(e,t=Hu){if(!e.value.includes("{"))return[e];let n=mN(e);for(let r=0;r<e.value.length;r++){if(e.value[r]!=="{"||u0(e,r)!=="0")continue;let o=n.get(r);if(!o)continue;let{end:i,commas:s}=o,a=s.length?[]:wN(Oe(e,r+1,i));if(s.length){let f=r+1;for(let d of[...s,i])a.push(Oe(e,f,d)),f=d+1}if(a===null)continue;let u=Oe(e,0,r),l=Oe(e,i+1),c=[];for(let f of a)if(c.push(...Gu(Cf(u,f,l),t)),c.length>t)throw new x("feature","brace expansion limit",`brace expansion \`${e.value}\` would produce more than ${t} words`);return c}return[e]}function mN(e){let t=[],n=new Map;for(let r=0;r<e.value.length;r++){if(u0(e,r)!=="0")continue;let o=e.value[r];if(o==="{")t.push({start:r,commas:[]});else if(o==="}"&&t.length){let{start:i,commas:s}=t.pop();n.set(i,{end:r,commas:s})}else o===","&&t.length&&t.at(-1).commas.push(r)}return n}function gN(e){if(e.mask!==null&&/[12]/u.test(e.mask))return null;let t=pN.exec(e.value),n=t??hN.exec(e.value);if(!n)return null;let[r,o]=t?[qu(t[1]),qu(t[2])]:[BigInt(n[1].codePointAt(0)),BigInt(n[2].codePointAt(0))],i=n[3]===void 0?1n:qu(n[3]);if(r===null||o===null||i===null||i===a0)return null;let s=o>=r?o-r:r-o;return s>s0?null:{num:t,range:n,from:r,to:o,step:(i<0n?-i:i)||1n,span:s}}function wN(e){let t=gN(e);if(t===null)return null;let{num:n,from:r,to:o,step:i,span:s}=t,a=s/i+1n;if(a>Hu)throw new x("feature","brace expansion limit",`brace expansion \`{${e.value}}\` would produce ${a} words (limit ${Hu})`);let u=n?yN(n[1],n[2]):0,l=[],c=o>=r?1n:-1n;for(let f=0n;f<a;f++){let d=r+c*f*i,p=n?xN(d,u):String.fromCodePoint(Number(d));l.push({value:p,mask:null})}return l}function yN(e,t){let n=r=>/^-?0\d/u.test(r);return n(e)||n(t)?Math.max(e.length,t.length):0}function xN(e,t){let n=String(e<0n?-e:e),r=e<0n?"-":"";return r+n.padStart(t-r.length,"0")}var Xu=new Set(["CDPATH","GLOBIGNORE","GLOBSORT","BASH_COMPAT","POSIXLY_CORRECT","PATH","RANDOM","SRANDOM","SECONDS","EPOCHSECONDS","EPOCHREALTIME","BASHOPTS","SHELLOPTS","OPTIND"]),ht=class extends Map{constructor(t){super(t),this.unsetNames=new Set(t?.unsetNames)}set(t,n){if(this.expansionTargets?.has(t))throw new x("feature","temporary assignment side effects","modifying a temporary assignment target while expanding assignment values is not supported");if(Xu.has(t)||t==="TZ"&&!["UTC","UTC0",""].includes(n))throw new x("feature",t,`shell variable ${t} is not supported with this value`);return(t==="LANG"||t.startsWith("LC_"))&&df(t,n),this.bound?.add(t),this.unsetNames?.delete(t),super.set(t,n)}delete(t){return this.unsetNames.add(t),super.delete(t)}};var l0=new Set(["$","!","0","-","_"]),bN=new Set(["PPID","UID","EUID","BASHPID","BASH_SUBSHELL","BASH_VERSION","BASH_VERSINFO","BASH_REMATCH","DIRSTACK","PIPESTATUS","FUNCNAME","LINENO","REPLY","BASH","BASH_COMMAND","BASH_ARGV0","BASH_ARGC","BASH_ARGV","BASH_SOURCE","BASH_LINENO","BASH_ALIASES","BASH_CMDS","GROUPS","HOSTTYPE","OSTYPE","MACHTYPE","HOSTNAME","SHLVL","SHELL","TERM","PS4","OPTERR","HISTCMD","BASH_EXECUTION_STRING","BASH_LOADABLES_PATH","COMP_WORDBREAKS"]);function Zt(e,t){if(l0.has(e))throw Zu(e);let n=Yu(e,t);if(n)return n;if(c0(e))throw Zu(e);return{value:"",set:!1}}var c0=e=>Xu.has(e)||bN.has(e),Zu=e=>new x("feature",`$${e}`,`shell parameter ${e} is not supported`),f0=(e,t)=>Yu(e,t)?.value??"";function Yu(e,t){return e==="?"?{value:String(t.lastExit),set:!0}:e==="#"?{value:"0",set:!0}:e==="@"?{value:"",set:!1,omit:!0}:e==="*"?{value:"",set:!1}:/^[1-9][0-9]*$/u.test(e)?{value:"",set:!1}:t.vars.has(e)?{value:t.vars.get(e),set:!0}:t.vars.unsetNames.has(e)?{value:"",set:!1}:e==="IFS"?{value:`
205
+ `,set:!0}:e==="PWD"?{value:t.cwd,set:!0}:e==="HOME"?{value:t.home,set:!0}:e==="USER"||e==="LOGNAME"?{value:t.user,set:!0}:e==="LANG"?{value:t.locale,set:!0}:null}function Vu(e,t){if(l0.has(e))throw new x("feature",`$${e}`,`shell parameter ${e} is not supported (this terminal runs no process)`);let n=Yu(e,t);if(n)return n;if(c0(e))throw Zu(e);return kN(t,`$${e}`,`warning: $${e} is unset (this shell has no environment variables; only \`for\` bindings and \`NAME=value\` assignments)`),{value:""}}function kN(e,t,n){Wi(e,n+`
206
+ `),e.unsupported.add({kind:"feature",command:null,detail:t,message:n})}var d0=16e6,so=e=>new x("feature","${",e);function p0(e,t,n){if(Qr(t))throw so("extended glob patterns in parameter expansion are not supported");let r=Qn({value:t.value,mask:t.mask??null}),o=n[0]==="#",i=m0(r);if(i!==null)return o?e.startsWith(i)?e.slice(i.length):e:e.endsWith(i)?e.slice(0,e.length-i.length):e;let s=He(r,{bash:!0}),a=n.length===2,u=o===a,l=u?e.length:0,c=0;for(;l>=0&&l<=e.length;){let f=o?e.slice(0,l):e.slice(l);if(c+=f.length+r.length,c>d0)throw so("parameter pattern removal exceeds the matching work limit");if(s.test(f))return o?e.slice(l):e.slice(0,l);l=Xi(e,l,u)}return e}function h0(e,t,n,r){let o="";if(!r&&/^[#%]/u.test(t.value)&&(!t.mask||t.mask[0]==="0")&&(o=t.value[0],t={value:t.value.slice(1),mask:t.mask?.slice(1)??null}),Qr(t))throw so("extended glob patterns in parameter expansion are not supported");let i=Qn({value:t.value,mask:t.mask??null}),s={work:0},a=$N(n,s);if(!i)return o==="#"?a("")+e:o==="%"?e+a(""):e;if((/\\+$/u.exec(i)?.[0].length??0)%2)throw so("unescaped trailing backslashes in replacement patterns are not supported");let u=m0(i),l=u===null?EN(e,i,o,s):vN(e,u,o),c=[],f=0;do{let d=l(f);if(!d)break;let[p,h]=d,m=a(e.slice(p,h));if(Ku(s,p-f),c.push(e.slice(f,p),m),f=h,!r)break;if(p===h){let g=Xi(e,f,!1);c.push(e.slice(f,g)),f=g}}while(f<e.length);return c.push(e.slice(f)),c.join("")}function vN(e,t,n){return r=>{let o=n==="%"?e.length-t.length:e.indexOf(t,r);return o<r||n==="#"&&o!==0||e.slice(o,o+t.length)!==t?null:[o,o+t.length]}}function EN(e,t,n,r){let o=He(t,{bash:!0});return i=>{for(let s=i;s<=e.length;s=Xi(e,s,!1)){for(let a=e.length;a>=s;a=Xi(e,a,!0)){if(Ku(r,a-s+t.length),o.test(e.slice(s,a)))return[s,a];if(n==="%")break}if(n==="#")break}return null}}function Ku(e,t){if(e.work+=t,e.work>d0)throw so("parameter replacement exceeds the matching work limit")}function $N(e,t){let n="";for(let r=0;r<e.value.length;r++){let o=e.value[r];e.mask?.[r]!==void 0&&e.mask[r]!=="0"&&(o==="&"||o==="\\")&&(n+="\\"),n+=o}return r=>{let o=[];for(let i=0;i<n.length;i++){let s=n[i],a=s==="\\"&&/[&\\]/u.test(n[i+1]??"")?n[++i]:s==="&"?r:s;Ku(t,a.length),o.push(a)}return o.join("")}}function Xi(e,t,n){let r=t+(n?-1:1);return r>0&&r<e.length&&/[\uDC00-\uDFFF]/u.test(e[r])&&/[\uD800-\uDBFF]/u.test(e[r-1])?r+(n?-1:1):r}function m0(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r==="\\"&&n+1<e.length)t+=e[++n];else{if(/[*?[]/u.test(r))return null;t+=r}}return t}var Je=e=>BigInt.asIntN(64,e),te=(e,t)=>new x("feature","arithmetic "+e,"arithmetic expansion: "+t);function g0(e){let t=10n,n=!1,r=0n,o=0;if(e[0]==="0"&&(o=1,t=8n,n=!0,(e[1]==="x"||e[1]==="X")&&(t=16n,o=2)),o===2&&e.length===2)throw te("number","hexadecimal constant has no digits");for(;o<e.length;o++){let i=e[o];if(i==="#"){if(n||r<2n||r>64n||o===e.length-1)throw te("number","invalid arithmetic base or integer constant");t=r,r=0n,n=!0;continue}let s=i.codePointAt(0),a=s>=48&&s<=57?s-48:s>=97&&s<=122?s-87:s>=65&&s<=90?s-(t<=36n?55:29):i==="@"?62:i==="_"?63:-1;if(a<0||BigInt(a)>=t)throw te("number","value too great for base in "+e.slice(0,40));r=Je(r*t+BigInt(a))}return r}function SN(e,t){if(t<0n)throw te("exponent","exponent less than zero");let n=1n;for(let r=t,o=e;r!==0n;r>>=1n,o=Je(o*o))r&1n&&(n=Je(n*o));return n}function Ju(e,t,n,r){switch(e){case"+":return Je(t+n);case"-":return Je(t-n);case"*":return Je(t*n);case"/":case"%":{if(n===0n&&r)throw te("division","division by zero");let o=n===0n?1n:n;return Je(e==="/"?t/o:t%o)}case"**":return SN(t,n);case"<<":case">>":{if(n<0n||n>63n)throw te("shift count","shift counts outside 0..63 are not supported");return Je(e==="<<"?t<<n:t>>n)}case"&":return t&n;case"^":return t^n;case"|":return t|n;case"<":return BigInt(t<n);case"<=":return BigInt(t<=n);case">":return BigInt(t>n);case">=":return BigInt(t>=n);case"==":return BigInt(t===n);case"!=":return BigInt(t!==n);default:throw te("operator","unsupported operator "+e)}}var AN=new Set(["=","+=","-=","*=","/=","%=","<<=",">>=","&=","^=","|="]),NN=[["||"],["&&"],["|"],["^"],["&"],["==","!="],["<","<=",">",">="],["<<",">>"],["+","-"],["*","/","%"],["**"]],ON=new Map(NN.flatMap((e,t)=>e.map(n=>[n,t+3]))),IN=/^(?:<<=|>>=|\+\+|--|\*\*|&&|\|\||<<|>>|[+\-*/%&^|=!<>]=|[+\-*/%&^|=!~<>?:,()])/u;function TN(e){let t=[];for(let n=0;n<e.length;){if(t.length>=1e4)throw te("limit","expression token limit exceeded");let r=e.slice(n),o=/^[ \t\n]+/u.exec(r);if(o){n+=o[0].length;continue}let i=/^[0-9][A-Za-z0-9#@_]*/u.exec(r),s=/^[A-Za-z_][A-Za-z0-9_]*/u.exec(r),a=IN.exec(r);if(i)t.push({type:"number",value:g0(i[0]),raw:i[0]});else if(s)t.push({type:"name",value:s[0],raw:s[0]});else if(a)t.push({type:"operator",value:a[0],raw:a[0]});else throw te(r[0]==="["||r[0]==="]"?"arrays":"syntax","unsupported expression token "+JSON.stringify(r[0]));n+=t.at(-1).raw.length}return t.push({type:"end",value:""}),t}function w0(e){let t=new Qu(TN(e));if(t.token.type==="end")return{type:"number",value:0n};let n=t.expression();if(t.token.type!=="end")throw te("syntax","unexpected token "+t.token.value);return n}var Qu=class{constructor(t){this.tokens=t,this.at=0,this.depth=0}get token(){return this.tokens[this.at]}next(){return this.tokens[this.at++]}accept(t){return this.token.value===t?this.next():null}expect(t){if(!this.accept(t))throw te("syntax","expected "+t)}expression(t=0){if(++this.depth>128)throw te("limit","expression nesting limit exceeded");let n=this.prefix();for(;;){let r=this.token.value;if(r==="?"&&t<=2){this.next();let a=this.expression();this.expect(":"),n={type:"condition",test:n,consequent:a,alternate:this.expression(2)};continue}let o=AN.has(r),i=r===","?0:o?1:ON.get(r);if(i===void 0||i<t)break;if(this.next(),o&&n.type!=="name")throw te("assignment","attempted assignment to non-variable");let s=this.expression(i+(o||r==="**"?0:1));n={type:o?"assignment":"binary",op:r,left:n,right:s}}return this.depth--,n}prefix(){let t=this.next();if(["+","-","!","~"].includes(t.value))return{type:"unary",op:t.value,value:this.expression(14)};if(t.value==="++"||t.value==="--"){let n=this.next();if(n.type!=="name")throw te("increment","increment requires a scalar variable");return{type:"increment",op:t.value,name:n.value,post:!1}}if(t.value==="("){let n=this.expression();return this.expect(")"),{type:"group",value:n}}if(t.type!=="number"&&t.type!=="name")throw te("syntax","operand expected");return t.type==="name"&&(this.token.value==="++"||this.token.value==="--")?{type:"increment",op:this.next().value,name:t.value,post:!0}:t}};function bn(e,t,n=0){return x0(e,{ctx:t,steps:1e4,characters:2e5},n,!0)}function x0(e,t,n,r){if(typeof e!="string")throw te("value","expression must be a string");if(t.characters-=e.length,e.length>1e5||t.characters<0)throw te("limit","expression size limit exceeded");if(n>128)throw te("limit","variable recursion limit exceeded");return b0(w0(e),t,n+1,r)}function el(e,t,n,r){if(!r)return 0n;let o;try{o=Zt(e,t.ctx)}catch(i){throw te("variable",K(i))}return o.set&&o.value!==""?x0(o.value,t,n+1,!0):0n}function y0(e,t,n,r){if(r)try{Zt(e,n.ctx),n.ctx.vars.set(e,t.toString())}catch(o){throw te("assignment",K(o))}return t}function b0(e,t,n,r){if(--t.steps<0||n>128)throw te("limit","expression evaluation limit exceeded");let o=(i,s=r)=>b0(i,t,n+1,s);switch(e.type){case"number":return e.value;case"name":return el(e.value,t,n,r);case"group":return o(e.value);case"unary":{let i=o(e.value);return e.op==="+"?i:e.op==="-"?Je(-i):e.op==="!"?BigInt(i===0n):~i}case"increment":{let i=el(e.name,t,n,r),s=y0(e.name,Je(i+(e.op==="++"?1n:-1n)),t,r);return e.post?i:s}case"assignment":{let i=e.left.value,s=e.op==="="?0n:el(i,t,n,r),a=o(e.right);return y0(i,e.op==="="?a:Ju(e.op.slice(0,-1),s,a,r),t,r)}case"condition":{let i=o(e.test)!==0n,s=o(e.consequent,r&&i),a=o(e.alternate,r&&!i);return i?s:a}case"binary":{let i=o(e.left),s=r&&(e.op==="&&"?i!==0n:e.op==="||"?i===0n:!0),a=o(e.right,s);return e.op===","?a:e.op==="&&"?BigInt(i!==0n&&a!==0n):e.op==="||"?BigInt(i!==0n||a!==0n):Ju(e.op,i,a,r)}default:throw te("syntax","unsupported expression")}}var Zi=e=>new x("feature","${",e);async function k0(e,t,n,r){if(e.name==="@"||e.name==="*")throw Zi("substring and replacement of positional parameter lists are not supported");if(!t.set)return t;if(e.operator===":")try{return{value:await CN(t.value,e.word,n,r)}}catch(l){throw l.halt=!0,l}let o=e.word,i=0;for(;o[i]==="\\"&&o[i+1]===`
207
+ `;)i+=2;let s=v0(o,"/",r.readExpansion,o[i]==="/"?i+1:0),a=await r.expand(o.slice(0,s),{pattern:!0}),u=await r.expand(s<o.length?o.slice(s+1):"",{replacement:!0});return{value:h0(t.value,a,u,e.operator==="//")}}async function CN(e,t,n,r){if(/\P{ASCII}/u.test(e))throw Zi("locale-dependent slicing of non-ASCII parameters is not supported");let o=v0(t,":",r.readExpansion),i=async l=>bn((await r.expand(l,{arithmetic:!0})).value,n),s=await i(t.slice(0,o)),a=BigInt(e.length);if(s<0n&&(s+=a),s<0n||s>a)return"";let u=a;if(o<t.length){let l=await i(t.slice(o+1));if(u=l<0n?a+l:s+l,u>ge)throw Zi("substring length overflows the shell integer range");if(u<s){let c=new Error(`${t.slice(o+1)}: substring expression < 0`);throw c.exitCode=1,c.halt=!0,c}}return e.slice(Number(s),Number(u>a?a:u))}function v0(e,t,n,r=0){let o=0,i=null,s=0;for(let a=r;a<e.length;a++){let u=e[a];if(i==="'"){u==="'"&&(i=null);continue}if(i==="ansi"){u==="\\"?a++:u==="'"&&(i=null);continue}if(u==="\\"){a++;continue}if(t===":"&&(u==="'"||u==='"'))throw Zi("quoted substring arithmetic is not supported");if(u==='"'){i=i==='"'?null:'"';continue}if(u==="'"&&!i){i=u;continue}if(u==="$"){let l=n(e,a,0,t===":"||i==='"');if(l){a+=l.raw.length-1;continue}let c=a+1;for(;e[c]==="\\"&&e[c+1]===`
208
+ `;)c+=2;if(!i&&e[c]==="'"){i="ansi",a=c;continue}}if(!i){if(t===":"){if(u==="(")o++;else if(u===")")o--;else if(o===0&&u==="?")s++;else if(o===0&&u===":"&&s){s--;continue}if(o!==0)continue}if(u===t)return a}}return e.length}var _N=/^[A-Za-z_][A-Za-z0-9_]*$/u;async function E0(e,t,n){let{lookup:r,expand:o}=n,{name:i,operator:s,word:a=""}=e,u=r(i,{quiet:s!==""});if(!s)return u;if(s==="length")return LN(i,u.value,t);if(s===":"||s.startsWith("/"))return k0(e,u,t,n);if(s[0]==="#"||s[0]==="%")return!u.value||!a?u:{value:p0(u.value,await o(a,{pattern:!0}),s)};let l=!u.set||s.startsWith(":")&&u.value==="",c=s[s.length-1];if(c==="+")return l?{value:"",...u.omit?{omit:!0}:{}}:o(a,{});if(!l)return u;if(c==="?")throw await FN(i,a,s.startsWith(":"),o,t);if(c!=="=")return o(a,{});if(!_N.test(i)){let d=new Error(`$${i}: cannot assign in this way`);throw d.exitCode=1,d.halt=!0,d}let f=await o(a,{assignment:!0});return t.vars.set(i,f.value),{value:t.vars.get(i)}}function LN(e,t,n){if(e==="*"||e==="@")return{value:"0"};if(ee(n))return{value:String(T(t).length)};if(/\P{ASCII}/u.test(t))throw an("#"+e,"locale-dependent length of non-ASCII parameters is not supported");return{value:String(t.length)}}async function FN(e,t,n,r,o){let i=t?RN(await r(t,{error:!0}),o):n?"parameter null or not set":"parameter not set",s=new Error(`${e}: ${i}`);return s.exitCode=1,s.halt=!0,s}function RN(e,t){let n=t.vars.get("IFS")??`
209
+ `;if(n==="")return e.value;if(n!==`
210
+ `)throw an("?","custom IFS separators in parameter errors are not supported");let r=new Set(e.empty),o=[],i=!1,s="",a=()=>{(s||i)&&o.push(s),s="",i=!1};for(let u=0;u<=e.value.length&&(r.has(u)&&(i=!0),u!==e.value.length);u++){let l=e.value[u],c=!e.mask||e.mask[u]==="0";c&&/[ \t\n]/u.test(l)?a():(s+=l,i||=!c)}return a(),o.join(" ")}function Yt(e,t){return ke(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new ht(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function ke(e,t,n){let r=Object.fromEntries(Object.keys(t).map(o=>[o,e[o]]));Object.assign(e,t);try{return await n()}finally{Object.assign(e,r)}}async function ao(e,t){let n=[],r=e[0],o=r?.value==="export"&&!/[12]/u.test(r.mask??"")&&!r.empty?.length;for(let i of e)for(let s of Gu(i)){let a=o&&s===i&&Or(i);if(a){let u=await DN(s,a.end,t);n.push({value:u,mask:"1".repeat(u.length),q:!0})}else n.push(...await S0(Yi(s,t,s===i?!1:"word"),t,!0))}return{argv:MN(n,t)}}function MN(e,t){let n=[];for(let r of e){if(M1(r)){let o=D1(r,t);if(o.length>0){n.push(...o);continue}}(r.value!==""||r.q)&&n.push(r.value)}return n}async function tl(e,t){let{argv:n}=await ao([e],t);return n.length===1?{value:n[0]}:{error:`${e.value}: ambiguous redirect`}}async function DN(e,t,n){let r=Oe(e,t);return e.value.slice(0,t)+await kn(r,n,!0)}async function kn(e,t,n=!1){return(await S0(Yi(e,t,n),t,!1,n))[0].value}var rr=e=>e.vars.get("HOME")??e.home,$0=(e,t)=>e.mask===null?"0":e.mask[t];function Yi(e,t,n=!1){let r=Tf(e,n);if(r.size===0)return e;let o=e.value,i=rr(t),s="",a="",u=[];for(let l=0;l<o.length;l++){if(e.empty?.includes(l)&&u.push(s.length),r.has(l)){let c=i==="/"&&o[l+1]==="/"?"":i;s+=c,a+="1".repeat(c.length);continue}s+=o[l],a+=$0(e,l)}return e.empty?.includes(o.length)&&u.push(s.length),{value:s,mask:/[12]/u.test(a)?a:null,...u.length?{empty:u}:{}}}function nl(e,t){return ke(t,{strictExpansion:!0},()=>rl(Yi(e,t),t))}async function S0(e,t,n,r=!1){let o=await rl(e,t,r);return n?zN(o,t):[o]}async function rl(e,t,n=!1){let r={value:"",mask:"",empty:[],split:!1},o=(i,s)=>{r.value+=i,r.mask+=s};e.value===""&&e.mask!==null&&r.empty.push(0);for(let i=0;i<=e.value.length&&(e.empty?.includes(i)&&r.empty.push(r.value.length),i!==e.value.length);i++){let s=$0(e,i),a=e.value[i];if(s==="0"&&(a==="<"||a===">")&&e.value[i+1]==="(")throw new x("feature",`${a}(`,`process substitution (\`${a}(\u2026)\`) is not supported`);let u=s!=="1"&&(a==="$"||a==="`"),l=e.value[i+1]==="("||e.value[i+1]==="{",c=u?UN(e,i,a,s,l):null;if(!c){o(e.value[i],s);continue}i+=c.raw.length-1;let f=await PN(c,t,s==="2",n);if(f.literal){o(c.raw,s.repeat(c.raw.length));continue}if(!f.omit)if(s==="2")f.value===""&&r.empty.push(r.value.length),o(f.value,"2".repeat(f.value.length));else{r.split=!0;for(let d of f.empty??[])r.empty.push(r.value.length+d);f.q&&!f.value&&!f.empty?.length&&r.empty.push(r.value.length),o(f.value,f.mask??"0".repeat(f.value.length))}}return r.q=r.empty.length>0||/[12]/u.test(r.mask),r}function UN(e,t,n,r,o){return n==="`"?kt(e.value,t):o?Et(e.value,t,0,r==="2"):da(e.value,t,e.mask)}async function PN(e,t,n,r){if(e.command!==void 0)return{value:await t.substitute(e.command,e.backtick)};if(e.arithmetic!==void 0)try{let o=await ke(t,{strictExpansion:!0},()=>kn(ha(e.arithmetic,!0),t));return{value:String(bn(o,t))}}catch(o){throw o.halt=!0,o}return e.parameter!==void 0?e.parameter.operator===""&&!t.strictExpansion&&!/^[0-9]{2,}$/u.test(e.parameter.name)?Vu(e.parameter.name,t):E0(e.parameter,t,{lookup:o=>Zt(o,t),readExpansion:Et,expand:(o,i={})=>{let s=i.pattern||i.error||i.replacement||i.arithmetic,a=ha(o,i.arithmetic||!s&&n),u=!s&&(i.assignment||r),l=i.assignment?"parameterAssign":u?!0:"parameter";return ke(t,{strictExpansion:!0},()=>rl(i.arithmetic?a:Yi(a,t,l),t,u))}}):t.strictExpansion?Zt(e.name,t):Vu(e.name,t)}function zN(e,t){if(!e.split)return e.value!==""||e.q?[e]:[];let n=t.vars.get("IFS")??`
211
+ `;if(n!==""&&n!==`
212
+ `)throw new x("feature","IFS","custom IFS separators are not supported");let r=[],o={value:"",mask:"",q:!1},i=()=>{(o.value!==""||o.q)&&r.push(o),o={value:"",mask:"",q:!1}},s=new Set(e.empty);for(let a=0;a<=e.value.length&&(s.has(a)&&(o.q=!0),a!==e.value.length);a++){let u=e.value[a],l=e.mask[a];if(n!==""&&l==="0"&&/[ \t\n]/u.test(u)){i();continue}o.value+=u,o.mask+=l,o.q||=l!=="0"}return i(),r}function A0(e,t,n){let r=Ym(t,n),o={ctx:n,options:r,seen:new Set,result:B(),total:0n,failed:!1};r.stderr&&U(o.result,n.flushOutput(B(r.stderr)));for(let i of r.operands){let s=i.length>2?i.replace(/\/+$/u,"/"):i,a=D(n,"du",s,{follow:r.links!=="none"});if(a.error){U(o.result,n.flushOutput(b(`du: cannot access ${V(s,n)}: ${a.error}`))),o.failed=!0;continue}try{BN(a.path,s,o)}catch(u){let l=C(u),c="du: "+K(u);if(l&&n.unsupported.add({...l,command:l.command??"du",message:c}),U(o.result,n.flushOutput(b(c))),o.failed=!0,l)return o.result}}return r.flags.has("c")&&ol(o.total,"total",o),o.result.exitCode=o.failed?1:0,o.result}function BN(e,t,n){let{ctx:r,options:o}=n;if(!o.flags.has("inodes")&&r.fs.isDir(e)&&Object.values(r.outputFds??{}).some(s=>typeof s=="object"&&s.path?.startsWith(e==="/"?"/":e+"/")))throw new x("feature","recursive metadata output overlap","output within a measured directory is not supported");let i=[{path:e,name:t,depth:0}];for(;i.length;){let s=i.pop();if(s.total!==void 0){s.depth<=o.depth&&ol(s.total,s.name,n),s.parent&&!o.flags.has("S")&&(s.parent.total+=s.total);continue}let a=r.fs.isDir(s.path);if(!a&&o.links==="all"&&r.fs.isLink?.(s.path))throw new x("option","dereference",`following symbolic links is not supported: ${s.name}`);let u=a?s.path:r.fs.fileIdentity?.(s.path)??s.path;if(!o.flags.has("l")&&n.seen.has(u))continue;n.seen.add(u);let l=a?"dir":r.fs.isLink?.(s.path)?"link":"file",c=a?0:r.fs.fileSize(s.path),f=o.flags.has("inodes")?1n:o.flags.has("A")?BigInt(c):BigInt(Hi(c,l));if(n.total+=f,a){s.total=f,i.push(s);let d=r.fs.listDir(s.path),p=[...new Set([...d.dirs,...d.files,...d.links])].sort(q),h=s.name.endsWith("/")?s.name:s.name+"/";for(let m=p.length-1;m>=0;m--)i.push({path:he(s.path,p[m]),name:h+p[m],depth:s.depth+1,parent:s})}else s.parent&&(s.parent.total+=f),(s.depth===0||o.flags.has("a")&&s.depth<=o.depth)&&ol(f,s.name,n)}}function ol(e,t,n){let r=`${oo(e,n.options.scale)} ${t}${n.options.flags.has("0")?"\0":`
213
+ `}`;U(n.result,n.ctx.flushOutput({...B(),stdout:r,events:[{fd:1,text:r}]}))}var jN=/^%([-+ 0#']*)(\d+|\*)?'?(?:\.(\d+|\*)?)?[hlL]?(.)?/su,WN="diouxXeEfFgGcs";function Ki(e){let t=[],n="";for(let r=0;r<e.length;r++){if(e[r]!=="%"){n+=e[r];continue}if(e[r+1]==="%"){n+="%",r++;continue}if(/^%[^a-zA-Z%]*\$/u.test(e.slice(r)))throw new A("positional printf arguments are not supported",null,"positional format arguments");let o=jN.exec(e.slice(r)),i=o[4];if(i==="a"||i==="A")throw new A("hexadecimal floating-point formats are not supported",null,"hexadecimal float format");if(i==="%"){n+="%",r+=o[0].length-1;continue}if(i===void 0||!WN.includes(i)){n+=o[0],r+=o[0].length-1;continue}n!==""&&(t.push(n),n="");let s=o[1];t.push({minus:s.includes("-"),plus:s.includes("+"),space:s.includes(" "),zero:s.includes("0"),alt:s.includes("#"),width:o[2]===void 0?null:o[2]==="*"?"*":Number(o[2]),precision:o[3]===void 0?o[0].includes(".")?0:null:o[3]==="*"?"*":Number(o[3]),conv:i}),r+=o[0].length-1}return n!==""&&t.push(n),t}function Vt(e,t,n,r){let o=n.width??0;if(o>Me)throw new A("format width exceeds the output limit",null,"format size limit");let i=o-e.length-[...t].length;return i<=0?e+t:n.minus?e+t+" ".repeat(i):n.zero&&r?e+"0".repeat(i)+t:" ".repeat(i)+e+t}var I0=e=>e.plus?"+":e.space?" ":"",T0=e=>e==="X"||e==="E"||e==="G"||e==="F";function vn(e,t){if(t.precision>Me)throw new A("format precision exceeds the output limit",null,"format size limit");let{conv:n}=t;if(!Number.isFinite(e)){if(Number.isNaN(e))throw new A("formatting signed NaN is not supported",null,"signed NaN");let r=e<0?"-inf":"+inf";return T0(n)?r.toUpperCase():r}return"ouxX".includes(n)&&(e>=2**64||e<-(2**63))?N0(e,{...t,conv:"g"}):"diouxX".includes(n)?qN(e,t):N0(e,t)}function qN(e,t){let{conv:n}=t,r=n==="d"||n==="i",o=r?Math.trunc(e)===0:e===0,i=BigInt(Math.trunc(e)),s=!1;i<0n&&(r?(s=!0,i=-i):i=BigInt.asUintN(64,i));let a=n==="o"?8:n==="x"||n==="X"?16:10,u=i.toString(a);n==="X"&&(u=u.toUpperCase()),t.precision!==null&&(t.precision===0&&o?u=t.alt&&!r?"0":"":u=u.padStart(t.precision,"0"));let l=s?"-":r&&u!==""?I0(t):"";return t.alt&&!o&&(n==="o"&&(u="0"+u),(n==="x"||n==="X")&&(l+=n==="x"?"0x":"0X")),Vt(l,u,t,t.precision===null)}var Vi=100;function N0(e,t){let{conv:n}=t;if(t.precision>Vi)throw new A(`floating-point precision above ${Vi} is not supported`,null,"float precision limit");let r=t.precision??6,o=e<0||Object.is(e,-0),i=Math.abs(e),s;return n==="e"||n==="E"?s=_0(i,r):n==="f"||n==="F"?s=L0(i,r):s=HN(i,r,t.alt),t.alt&&r===0&&n!=="g"&&n!=="G"&&(s=n==="e"||n==="E"?s.replace("e",".e"):s+"."),T0(n)&&(s=s.toUpperCase()),Vt(o?"-":I0(t),s,t,!0)}function C0(e,t,n,r){let o=t.slice(r);if(!/^50*$/u.test(o))return e;let i=t.slice(0,n),s=i.at(-1);return Number(s)%2===0?i:e}function _0(e,t){let n=e.toExponential(Vi),r=n.indexOf("."),o=n.indexOf("e"),[i,s]=e.toExponential(t).split("e"),a=C0(i,n.slice(0,o),t===0?r:r+1+t,r+1+t),u=Number(a===i?s:n.slice(o+1));return`${a}e${u<0?"-":"+"}${String(Math.abs(u)).padStart(2,"0")}`}function L0(e,t){if(e>=1e21)return BigInt(e).toString()+(t>0?"."+"0".repeat(t):"");let n=e.toFixed(Vi),r=n.indexOf(".");return C0(e.toFixed(t),n,t===0?r:r+1+t,r+1+t)}function HN(e,t,n){let r=t===0?1:t;if(e===0)return n?"0."+"0".repeat(r-1):"0";let o=_0(e,r-1),i=o.indexOf("e"),s=Number(o.slice(i+1));if(s<-4||s>=r)return n?o.includes(".")?o:o.slice(0,i)+"."+o.slice(i):O0(o.slice(0,i))+o.slice(i);let a=L0(e,r-1-s);return n?a.includes(".")?a:a+".":O0(a)}var O0=e=>e.includes(".")?e.replace(/\.?0+$/u,""):e;var GN=/^[+-]?(?:0[bB][01]+|0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)/u,XN=/^[+-]?(?:0[xX](?:[\da-fA-F]+(?:\.[\da-fA-F]*)?|\.[\da-fA-F]+)(?:[pP][+-]?\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|inf(?:inity)?|nan(?:\([\w]*\))?)/iu;function M0(e,t){if(e?.[0]!=="'"&&e?.[0]!=='"')return null;let n=e.slice(1);if(n==="")return null;let r=T(n),o=t.byteLocale?1:T(String.fromCodePoint(n.codePointAt(0))).length;return r.length>o&&(t.stderr+=`printf: warning: ${G(r.slice(o))}: character(s) following character constant have been ignored
214
+ `),t.byteLocale?r[0]:n.codePointAt(0)}function D0(e,t,n){if(e===void 0||e==="")return"0";let r=e.replace(/^[ \t\n\r\f\v]+/u,""),o=t.exec(r)?.[0]??"";return(o.length!==r.length||o==="")&&(n.stderr+=`printf: ${U0(e,n)}: ${o?"value not completely converted":"expected a numeric value"}
215
+ `,n.failed=!0),o||"0"}var F0={"\x07":"\\a","\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r","\\":"\\\\","'":"\\'"},R0=e=>"\\"+e.toString(8).padStart(3,"0");function U0(e,t){let n="";for(let r of e){if(F0[r]!==void 0){n+=F0[r];continue}let o=r.codePointAt(0);if(o<32||o===127){n+=R0(o);continue}n+=o>127&&t.byteLocale?T(r).map(R0).join(""):r}return`'${n}'`}function Ji(e,t,n){let r=M0(e,n);if(r!==null)return BigInt(r);let o=D0(e,GN,n),i=o[0]==="-",s=o.replace(/^[+-]/u,""),a=BigInt(/^0[0-7]+$/u.test(s)?"0o"+s:s),u=i?-a:a;return(t?a>yt:u<wt||u>ge)?(n.stderr+=`printf: ${U0(e,n)}: Numerical result out of range
216
+ `,n.failed=!0,t?yt:i?wt:ge):t?BigInt.asUintN(64,u):u}function Qi(e,t){let{conv:n}=t,r=n==="d"||n==="i",o=e<0n,i=n==="o"?8:n==="x"||n==="X"?16:10,s=(o?-e:e).toString(i);n==="X"&&(s=s.toUpperCase()),e===0n&&t.precision===0&&(s=""),s=s.padStart(t.precision??0,"0");let a=o?"-":r?t.plus?"+":t.space?" ":"":"";return t.alt&&(n==="o"&&!s.startsWith("0")&&(s="0"+s),e!==0n&&(n==="x"||n==="X")&&(a=n==="x"?"0x":"0X")),Vt(a,s,t,t.precision===null)}function P0(e,t,n){let r=M0(e,n),o=r===null?D0(e,XN,n):String(r),i=o.replace(/^[+-]/u,"");if(/^(?:inf|nan)/iu.test(i)){let u=o.startsWith("-")?"-":t.plus?"+":t.space?" ":"",l=/^nan/iu.test(i)?"nan":"inf";return t.conv===t.conv.toUpperCase()&&(l=l.toUpperCase()),Vt(u,l,t,!1)}let s=JN(i),a=o.startsWith("-")?-s.value:s.value;if(t.precision>100||"gG".includes(t.conv)&&t.precision>96)throw new x("feature","float precision limit","floating-point precision exceeds the supported limit");try{let u=vn(a,t);if(!s.exact){let[l,c]=ZN(s.value);for(let f of[l,c])if(vn(o.startsWith("-")?-f:f,t)!==u)throw new x("feature","floating-point precision","floating-point formatting at this precision is not supported")}return u}catch(u){throw u.gap?new x("feature",u.gap,u.message):u}}var or=new DataView(new ArrayBuffer(8));function z0(e){return or.setFloat64(0,e),or.getBigUint64(0)}function ZN(e){let t=z0(e);or.setBigUint64(0,t-1n);let n=or.getFloat64(0);return or.setBigUint64(0,t+1n),[n,or.getFloat64(0)]}function YN(e){let t=z0(e),n=Number(t>>52n);return{coefficient:t&(1n<<52n)-1n|(n?1n<<52n:0n),exponent:n?n-1075:-1074}}function il(e,t){let n=e.replace(/^0+|0+$/gu,"");return{digits:n||"0",exponent:n?t+e.length-e.replace(/0+$/u,"").length:0}}function VN({coefficient:e,exponent:t}){return t<0?il((e*5n**BigInt(-t)).toString(),t):il((e<<BigInt(t)).toString(),0)}function KN(e,t){let n=e.exponent-t.exponent;return n>=0?e.coefficient<<BigInt(n)===t.coefficient:e.coefficient===t.coefficient<<BigInt(-n)}function JN(e){let t=/^0x/iu.test(e),n,r;if(t)n=QN(e),r=e3(n);else{let[a,u="0"]=e.split(/[eE]/u),[l,c=""]=a.split(".");n=il(l+c,Number(u)-c.length),r=Number(e)}if(!Number.isFinite(r))throw new x("feature","floating-point range","floating-point values outside the JavaScript number range are not supported");if(r===0){if(t?n.coefficient!==0n:n.digits!=="0")throw new x("feature","floating-point range","floating-point underflow is not supported");return{value:r,exact:!0}}let o=YN(r),i=VN(o),s=t?KN(n,o):n.digits===i.digits&&n.exponent===i.exponent;return{value:r,exact:s&&i.exponent>=-100&&i.digits.length<=101}}function QN(e){let[t,n="0"]=e.slice(2).split(/[pP]/u),[r,o=""]=t.split("."),i=(r+o).replace(/^0+/u,"")||"0";if(i.length>4096)throw new x("feature","floating-point input limit","hexadecimal floating-point significands above 4096 digits are not supported");return{coefficient:BigInt("0x"+i),exponent:Number(n)-4*o.length}}function e3({coefficient:e,exponent:t}){if(e===0n)return 0;let n=e.toString(2).length,r=t+n-1;if(r>1023)return 1/0;if(r<-1075)return 0;let o=Math.max(0,n-53,-1074-t),i=e>>BigInt(o);if(o>0){let s=e-(i<<BigInt(o)),a=1n<<BigInt(o-1);(s>a||s===a&&i%2n!==0n)&&i++}return Number(i)*2**(t+o)}var B0={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,'"':34,"\\":92};function W0(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]==="%"){if(e[r+1]==="%"||r+1===e.length){n.push([37]),r+=2;continue}let o=/^%([-+ #0']*)(\d+)?(?:\.(\d*))?([\s\S])?/u.exec(e.slice(r)),[,i,s,a,u]=o;if(!u||u==="%")throw new Error(`invalid directive: ${o[0]}`);if(!"nsF".includes(u))throw new x("feature","%"+u,`format %${u} is not supported`);if(i.includes("'"))throw new x("feature","grouped format","digit grouping in stat formats is not supported");let l={field:u,conv:"u",width:Number(s??0),precision:a===void 0?null:Number(a||0),minus:i.includes("-"),zero:i.includes("0"),plus:i.includes("+"),space:i.includes(" "),alt:i.includes("#")};if(l.width>Me||l.precision>Me)throw new x("feature","format size limit","format width or precision exceeds the output limit");n.push(l),r+=o[0].length}else if(e[r]==="\\"&&t){let o=e[r+1],i=/^(?:[0-7]{1,3}|x[\da-fA-F]{1,2})/u.exec(e.slice(r+1))?.[0];if(i){let s=i[0]==="x"?16:8;n.push([parseInt(s===16?i.slice(1):i,s)&255]),r+=i.length+1}else if(Object.hasOwn(B0,o))n.push([B0[o]]),r+=2;else throw new x("feature","format escape",`format escape ${JSON.stringify(e.slice(r,r+2))} is not supported`)}else{let o=r+1;for(;o<e.length&&e[o]!=="%"&&!(t&&e[o]==="\\");)o++;n.push(I(e.slice(r,o))),r=o}return t||n.push([10]),n}function q0(e,t,n,r){let o=r.isDir(n),i=!o&&r.isLink?.(n)===!0,s,a=e.map(c=>{if(!c.field)return c;if(c.field==="n")return j0(t,c);if(c.field==="s"&&o)throw new x("feature","directory byte size",`directory byte sizes are not available: ${t}`);return s??=o?0:r.fileSize(n),c.field==="F"?j0(o?"directory":i?"symbolic link":s===0?"regular empty file":"regular file",c):I(Qi(BigInt(s),c))}),u=new Uint8Array(a.reduce((c,f)=>c+f.length,0)),l=0;for(let c of a)u.set(c,l),l+=c.length;return G(u)}function j0(e,t){let n=I(e);t.precision!==null&&(n=n.subarray(0,t.precision));let r=Math.max(0,t.width-n.length);if(!r)return n;let o=new Uint8Array(n.length+r).fill(32);return o.set(n,t.minus?0:r),o}function H0(e,t,n){let{order:r,positional:o}=N(t,{short:["L","t"],long:["dereference","terse"],valueShort:["c"],valueLong:["format","printf","cached"]});if(!o.length)return b("stat: missing operand");let i=r.some(({name:c})=>c==="L"||c==="dereference"),s;for(let c of r)if(c.name==="cached"){if(!c.value||!["always","never","default"].some(f=>f.startsWith(c.value)))return b(`stat: invalid cache mode: ${c.value}`)}else["c","format","printf"].includes(c.name)&&(s=c);if(!s)return v("feature","stat","default metadata","stat: default output requires filesystem metadata that is not available");let a=W0(s.value,s.name==="printf");if(a.some(c=>c.field==="s"||c.field==="F")&&n3(o,n,i))return v("feature","stat","metadata output overlap","stat: buffered output sharing a measured file is not supported");let u=B(),l=!1;for(let c of o){let f=t3(a,c,n,i);U(u,f),l||=f.exitCode!==0}return u.exitCode=l?1:0,u}function t3(e,t,n,r){if(t==="-"){let i=v("feature","stat","standard input metadata","stat: standard input metadata is not supported");return n.unsupported.add({kind:"feature",command:"stat",detail:"standard input metadata",message:i.stderr.trimEnd()}),i}let o=D(n,"stat",t,{follow:r});if(o.error)return b(`stat: cannot statx ${V(t,n)}: ${o.error}`);try{return R(q0(e,t,o.path,n.fs))}catch(i){let s=Q(i,"stat","stat: "+K(i)),a=C(s);return a&&n.unsupported.add(a),s}}function n3(e,t,n){let r=Object.values(t.outputFds).filter(o=>typeof o=="object");return r.length?e.some(o=>{let i=E(t.cwd,o,t.fs,{follow:n});return!i.error&&r.some(s=>s.path===i.path||s.identity!==void 0&&s.identity===t.fs.fileIdentity?.(i.path))}):!1}var r3=[" 1970-01-01 00:00:00.000000000 +0000"," Thu Jan 1 00:00:00 1970"];function G0(e,t,n,r,o){let{ctx:i,opts:s}=e,a=o3(s,t);if(a==="")return"";let u=f=>s.labels[f]??Lu(n[f],i)+(r[f]?r3[s.style==="context"?1:0]:""),l=f=>s.labels[f]??Lu(n[f],i),c=o?`diff${s.switches} ${l(0)} ${l(1)}
217
+ `:"";return s.style==="unified"?`${c}--- ${u(0)}
218
+ +++ ${u(1)}
219
+ ${a}`:s.style==="context"?`${c}*** ${u(0)}
220
+ --- ${u(1)}
221
+ ${a}`:c+a}function o3(e,t){let n=e.showFunction?ot(t[0]):null;return Lo(t[0],t[1],{format:e.style??"normal",context:e.context,label:n?r=>s3(n,r):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace,horizon:e.horizon})}var i3=/^[A-Za-z$_]/u;function s3(e,t){for(let n=t-1;n>=0;n--){if(!i3.test(e[n]))continue;let r=T(e[n].replace(/\n$/u,"")),o=Math.min(40,r.length);for(;o>0&&a3(r[o-1]);)o--;return u3(r.subarray(0,o))}return null}var a3=e=>e===32||e>=9&&e<=13;function u3(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return G(e.subarray(0,t))}catch{}return""}var l3=["q","s","r","N","a","i","w","b","Z","p","d","u","c","e","n","y","t","T","l","E","B","P","v","H"],c3=["brief","report-identical-files","recursive","new-file","text","ignore-case","ignore-all-space","ignore-space-change","ignore-trailing-space","strip-trailing-cr","show-c-function","minimal","normal","unified","context","ed","rcs","side-by-side","expand-tabs","initial-tab","paginate","ignore-tab-expansion","ignore-blank-lines","unidirectional-new-file","version","help","suppress-common-lines","speed-large-files","ignore-file-name-case","no-ignore-file-name-case","no-dereference","left-column"],Z0=["U","C","x","X","S","F","W","I","D"],Y0=["show-function-line","exclude-from","starting-file","from-file","to-file","ifdef","width","tabsize","horizon-lines","ignore-matching-lines","line-format","old-line-format","new-line-format","unchanged-line-format","old-group-format","new-group-format","unchanged-group-format","changed-group-format","color","palette"],f3=["L","label","x","exclude"],d3=new Map([["e","ed script output"],["ed","ed script output"],["n","RCS output"],["rcs","RCS output"],["y","side-by-side output"],["side-by-side","side-by-side output"],["W","side-by-side output"],["width","side-by-side output"],["suppress-common-lines","side-by-side output"],["left-column","side-by-side output"],["t","tab expansion"],["expand-tabs","tab expansion"],["T","initial tabs"],["initial-tab","initial tabs"],["tabsize","tab expansion"],["E","tab expansion"],["ignore-tab-expansion","tab expansion"],["B","ignoring blank lines"],["ignore-blank-lines","ignoring blank lines"],["I","ignoring matching lines"],["ignore-matching-lines","ignoring matching lines"],["D","merged #ifdef output"],["ifdef","merged #ifdef output"],["l","pagination"],["paginate","pagination"],["F","a custom function regex"],["show-function-line","a custom function regex"],["X","reading exclusions from a file"],["exclude-from","reading exclusions from a file"],["S","a starting file"],["starting-file","a starting file"],["from-file","comparing one file to many"],["to-file","comparing one file to many"],["P","one-sided new files"],["unidirectional-new-file","one-sided new files"],["v","a version banner"],["version","a version banner"],["help","a help text"],["H","large-file heuristics"],["speed-large-files","large-file heuristics"],["ignore-file-name-case","case-insensitive names"],["no-ignore-file-name-case","case-insensitive names"],["no-dereference","symbolic links"],["color","colored output"],["palette","colored output"],["line-format","custom line formats"],["old-line-format","custom line formats"],["new-line-format","custom line formats"],["unchanged-line-format","custom line formats"],["old-group-format","custom group formats"],["new-group-format","custom group formats"],["unchanged-group-format","custom group formats"],["changed-group-format","custom group formats"]]),ir=e=>b(`diff: ${e}
222
+ diff: Try 'diff --help' for more information.`,2);function p3(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--"){t.push(...e.slice(n));break}if(r==="--unified"||r==="--context")t.push("-"+(r==="--unified"?"u":"c"));else if(r.startsWith("--unified=")||r.startsWith("--context="))t.push(r.startsWith("--u")?"-U":"-C",r.slice(10));else{if(r.startsWith("--color"))return{refused:"colored output",label:r};t.push(r)}}return{tokens:t}}function V0(e){let t=p3(e);if(t.refused)return{refused:v("option","diff",t.label.replace(/=.*/u,""),`diff: ${t.label}: ${t.refused} is not supported`,2)};let n;try{n=N(t.tokens,{short:l3,long:c3,valueShort:Z0,valueLong:Y0,repeatable:f3})}catch(o){let i=C(o);return i?{refused:v(i.kind,"diff",i.detail,`diff: ${o.message}`,2)}:{error:ir(o.message)}}let r={style:null,context:-1,horizon:0,labels:[],excludes:[],whitespace:"none",switches:m3(e)};for(let{name:o,value:i}of n.order){let s=d3.get(o),a=(o.length===1?"-":"--")+o;if(s)return{refused:v("option","diff",a,`diff: ${a}: ${s} is not supported`,2)};let u=h3(r,o,i);if(u)return{error:u}}return r.showFunction&&r.style===null&&(r.style="context"),r.context<0&&(r.context=3),n.positional.length<2?{error:ir(`missing operand after '${n.positional[0]??"diff"}'`)}:n.positional.length>2?{error:ir(`extra operand '${n.positional[2]}'`)}:{opts:r,operands:n.positional}}function h3(e,t,n){let r=o=>e.style!==null&&e.style!==o?ir("conflicting output style options"):(e.style=o,null);switch(t){case"u":case"c":{let o=r(t==="u"?"unified":"context");return e.context<3&&(e.context=3),o}case"U":case"C":{let o=X0(n);if(o===null)return ir(`invalid context length '${n}'`);let i=r(t==="U"?"unified":"context");return e.context<o&&(e.context=o),i}case"normal":return r("normal");case"horizon-lines":{let o=X0(n);return o===null?ir(`invalid horizon length '${n}'`):(e.horizon=Math.max(e.horizon,o),null)}case"q":case"brief":return e.brief=!0,null;case"s":case"report-identical-files":return e.identical=!0,null;case"r":case"recursive":return e.recursive=!0,null;case"N":case"new-file":return e.newFile=!0,null;case"a":case"text":return e.text=!0,null;case"i":case"ignore-case":return e.ignoreCase=!0,null;case"w":case"ignore-all-space":return e.whitespace="all",null;case"b":case"ignore-space-change":return e.whitespace!=="all"&&(e.whitespace="change"),null;case"Z":case"ignore-trailing-space":return e.whitespace==="none"&&(e.whitespace="trailing"),null;case"strip-trailing-cr":return e.stripCr=!0,null;case"p":case"show-c-function":return e.showFunction=!0,null;case"d":case"minimal":return e.minimal=!0,null;case"L":case"label":return e.labels.length===2?b("diff: too many file label options",2):(e.labels.push(n),null);case"x":case"exclude":return e.excludes.push(n),null;default:return null}}function X0(e){if(e==="")return 0;let t=/^[ \t\n\v\f\r]*([-+]?)(\d+)$/u.exec(e);return!t||t[1]==="-"&&/[1-9]/u.test(t[2])?null:Math.min(Number(t[2]),Number.MAX_SAFE_INTEGER)}function m3(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--")break;!r.startsWith("-")||r==="-"||(t.push(r),g3(r)&&n+1<e.length&&t.push(e[++n]))}return t.map(n=>" "+pe(n,{vars:new Map})).join("")}function g3(e){if(e.startsWith("--"))return!e.includes("=")&&(Y0.includes(e.slice(2))||e==="--label"||e==="--exclude");for(let t=1;t<e.length;t++){let n=e[t];if(Z0.includes(n)||n==="L")return t+1===e.length}return!1}function ns(e,t,n){let{ctx:r,opts:o}=e,i=x3(Q0(e,t),Q0(e,n));for(let[s,a,u]of i){let l=ts(t,s),c=ts(n,s),f=a?J0(r,l):null,d=u?J0(r,c):null;if(a&&u){y3(e,[l,c],[f,d]);continue}o.newFile?w3(e,[l,c],f??d,[a,u]):Ce(e,`Only in ${a?t:n}: ${s}
223
+ `,1)}}function w3(e,[t,n],r,o){es(r)?e.opts.recursive?eg(e,[t,n],o.map(i=>i?r:null)):Ce(e,`Common subdirectories: ${t} and ${n}
224
+ `):uo(e,t,n,!0,o)}function y3(e,[t,n],[r,o]){let{opts:i}=e,s=[r,o].indexOf("gone");if(s!==-1&&es([r,o][1-s])){let a=[t,n][s];return Ce(e,`diff: ${a}: ${E(e.ctx.cwd,a,e.ctx.fs).error}
225
+ `,2,!0)}if(es(r)&&es(o))i.recursive?eg(e,[t,n],[r,o]):Ce(e,`Common subdirectories: ${t} and ${n}
226
+ `);else if(r===o||s!==-1)uo(e,t,n,!0,[!0,!0]);else{let a=(u,l)=>i.labels[u]??l;Ce(e,`File ${a(0,t)} is a ${K0[r]} while file ${a(1,n)} is a ${K0[o]}
227
+ `,1)}}var K0={dir:"directory",link:"directory",file:"regular file"},es=e=>e==="dir"||e==="link";function J0(e,t){let n=E(e.cwd,t,e.fs);return n.error?"gone":e.fs.isDir(n.path)?e.fs.isLink?.(E(e.cwd,t,e.fs,{follow:!1}).path)?"link":"dir":"file"}function eg(e,[t,n],[r,o]){for(let[i,s]of[[r,t],[o,n]])if(i==="link")throw new x("feature","symbolic link to a directory",`comparing what a symbolic link to a directory holds is not supported: ${s}`);ns(e,t,n)}function Q0(e,t){let{ctx:n,opts:r}=e,o=E(n.cwd,t,n.fs);if(o.error||!n.fs.isDir(o.path))return[];let{dirs:i,files:s,links:a}=n.fs.listDir(o.path),u=[...i,...s,...a].sort(q);return r.excludes.length?u.filter(l=>!r.excludes.some(c=>R1(l,c))):u}function x3(e,t){let n=[],r=0,o=0;for(;r<e.length||o<t.length;){let i=r===e.length?1:o===t.length?-1:q(e[r],t[o]);i===0?(n.push([e[r++],!0,!0]),o++):i<0?n.push([e[r++],!0,!1]):n.push([t[o++],!1,!0])}return n}function og(e,t,n){let r=V0(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:o,operands:i}=r,s={ctx:n,opts:o,stdin:e,out:B(),status:0},[a,u]=i,l=i.map(c=>tg(s,c));if(l[0]==="dir"&&l[1]==="dir"&&b3(s,a,u))return s.out;if(l[0]==="dir"&&l[1]==="dir")ns(s,a,u);else if(l[0]==="dir"||l[1]==="dir"){let c=l[0]==="dir"?0:1,f=i[1-c];if(f==="-")return b("diff: cannot compare '-' to a directory",2);if(l[1-c]==="missing"){let d=E(s.ctx.cwd,f,s.ctx.fs).error;o.newFile&&d==="No such file or directory"?ns(s,a,u):Ce(s,`diff: ${f}: ${d}
228
+ `,2,!0)}else{let d=ts(i[c],Ne(f)),p=c===0?[d,f]:[f,d];tg(s,d)==="missing"?Ce(s,`diff: ${d}: No such file or directory
229
+ `,2,!0):uo(s,p[0],p[1],!1)}}else uo(s,a,u,!1);return s.out.exitCode=s.status,s.out}function ts(e,t){let n=e.replace(/\/+$/u,"");return(n===""?"/":n+"/")+t}function b3(e,t,n){return E(e.ctx.cwd,t,e.ctx.fs).path===E(e.ctx.cwd,n,e.ctx.fs).path}function tg(e,t){if(t==="-")return"stdin";let n=E(e.ctx.cwd,t,e.ctx.fs);return n.error?"missing":e.ctx.fs.isDir(n.path)?"dir":"file"}function Ce(e,t,n=0,r=!1){U(e.out,r?B(t):{...B(),stdout:t,events:[{fd:1,text:t}]}),e.status=Math.max(e.status,n)}function uo(e,t,n,r,o=null){let{opts:i}=e,s=[t,n].map(p=>E3(e,p)),a=s.map(p=>p.content===null),u=i.newFile&&!(a[0]&&a[1]),l=!1;for(let p=0;p<2;p++)!a[p]||(o?!o[p]:u)||(Ce(e,`diff: ${[t,n][p]}: ${s[p].error??"No such file or directory"}
230
+ `,2,!0),l=!0);if(l)return;if(s[0].identity!==void 0&&s[0].identity===s[1].identity&&!a[0])return lo(e,t,n);let c=p=>i.labels[p]??[t,n][p];if(!i.text&&s.some(v3))return ng(s)?lo(e,t,n):Ce(e,`${i.brief?"Files":"Binary files"} ${c(0)} and ${c(1)} differ
231
+ `,1);if(s.some(p=>p.content===void 0)){if(ng(s))return lo(e,t,n);if(i.brief&&!i.ignoreCase&&!i.stripCr&&i.whitespace==="none")return Ce(e,`Files ${c(0)} and ${c(1)} differ
232
+ `,1)}for(let[p,h]of s.entries())h.content===void 0&&Lt(h.bytes,JSON.stringify(c(p)));let f=s.map(p=>p.content??"");if(i.stripCr&&(f=f.map(k3)),i.brief)return Lo(f[0],f[1],{format:"brief",ignoreCase:i.ignoreCase,whitespace:i.whitespace})===""?lo(e,t,n):Ce(e,`Files ${c(0)} and ${c(1)} differ
233
+ `,1);let d;try{d=G0(e,f,[t,n],a,r)}catch(p){if(!(p instanceof Us)&&!(p instanceof gc))throw p;let h=`diff: ${t} ${n}: ${p.message}`,m=p instanceof Us?"change set verification":"diff rendering verification";U(e.out,v("feature","diff",m,h,2)),e.status=2;return}if(d==="")return lo(e,t,n);Ce(e,d,1)}function lo(e,t,n){e.opts.identical&&Ce(e,`Files ${t} and ${n} are identical
234
+ `)}var k3=e=>e.replace(/\r\n/gu,`
235
+ `),v3=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes("\0")===!0,ng=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:Er(e.bytes??rg,t.bytes??rg),rg=new Uint8Array;function E3(e,t){let{ctx:n}=e;if(t==="-")return z(n),{content:e.stdin,identity:n.stdinHandle?.identity??Symbol("stdin")};let r=D(n,"diff",t);if(r.error||n.fs.isDir(r.path))return{content:null,bytes:null,identity:void 0,error:r.error};let{text:o,bytes:i}=it(n.fs,r.path);return{content:o,bytes:i,identity:n.fs.fileIdentity?.(r.path)??r.path}}var sr=(e,t,n)=>{throw new ne(`malformed patch at line ${Math.min(t,e.lines.length-1)+1}: ${n??""}`)};function co(e,t){return!!e.lines[t+1]?.startsWith("\\")}function ag(e){let{lines:t}=e,n=e.pos,r=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: (.*))?\n$/u.exec(t[n]??"");if(!r)return null;let o=n,i=Number(r[3]),s=Number(r[1]),a=r[2]===void 0?1:Number(r[2]),u=r[4]===void 0?1:Number(r[4]);a===0&&s++,u===0&&i++;let l=[],c=[],f=0,d=n,p=-1;for(n++;c.length<a||l.length<u;n+=1){let h=t[n]!==void 0;if(!h&&u-l.length>3)throw new ne("unexpected end of file in patch");let m=h?t[n]:`
236
+ `;h&&(d=n);let g=m[0],w=m;g===" "||g===`
237
+ `?g=" ":w=m.slice(1),g!=="-"&&g!=="+"&&g!==" "&&sr(e,n,m);let y=!1;g!=="+"&&(c.length>=a&&sr(e,n,m),y=h&&c.length+1===a&&co(e,n),y&&(w=w.replace(/\n$/u,"")),c.push({tag:g,text:w}),g===" "&&f++),g!=="-"&&(l.length>=u&&sr(e,n,m),!y&&h&&l.length+1===u&&co(e,n)&&(y=!0,w=w.replace(/\n$/u,"")),l.push({tag:g,text:w})),g!==" "&&(p===-1&&(p=f),f=0),y&&n++}return p===-1&&sr(e,d,t[d]),e.pos=n,{oldStart:s,oldLines:c,newStart:i,newLines:l,prefix:p,suffix:f,fn:r[5]===void 0?null:" "+r[5],marks:null,line:o}}function sl(e){let{lines:t}=e,n=e.pos;if(!t[n]?.startsWith("********"))return null;let r=n,o=/^\*+( .*)?\n$/u.exec(t[n])?.[1]??null,i=/^\*\*\* (\d+)(?:,(\d+))?/u.exec(t[++n]??"");if(!i)throw new ne(`unexpected '***' at line ${n+1}: ${t[n]??""}`);let s=ig(i),a=[],u=f=>/^--- (\d+)(?:,(\d+))? ----/u.exec(t[f]??"")??/^--- (\d+)(?:,(\d+))?/u.exec(t[f]??"");for(n++;!u(n);n++){if(t[n]===void 0||a.length>=s.count)throw new ne(`no '---' found in patch at line ${r+1}`);a.push(sg(e,n,a.length+1===s.count)),a.at(-1).skip&&n++}let l=ig(u(n)),c=[];for(n++;c.length<l.count;n++){let f=t[n];if(f===void 0||!/^[ !+\-\t\n]/u.test(f)||f.startsWith("***"))break;c.push(sg(e,n,c.length+1===l.count)),c.at(-1).skip&&n++}return c.length!==0&&c.length<l.count&&sr(e,n,t[n]),e.pos=n,$3({oldRange:s,oldSide:a,newRange:l,newSide:c,fn:o,line:r})}function ig(e){let t=Number(e[1]),n=e[2]===void 0?t:Number(e[2]);return t===0&&e[2]===void 0?{first:1,count:0}:{first:t,count:n-t+1}}function sg(e,t,n){let r=e.lines[t],o=r[0];o===" "||o===`
238
+ `?o=" ":(r=r.slice(1),(r[0]===" "||r[0]===" ")&&(r=r.slice(1)));let i=n&&co(e,t);return{mark:o,text:i?r.replace(/\n$/u,""):r,skip:i}}function $3({oldRange:e,oldSide:t,newRange:n,newSide:r,fn:o,line:i}){let s=r,a=t;if(t.length===0&&e.count&&(a=r.filter(p=>p.mark===" ")),r.length===0&&n.count&&(s=t.filter(p=>p.mark===" ")),a.length!==e.count||s.length!==n.count)throw new ne(`replacement text or line numbers mangled in hunk at line ${i+1}`);let u=a.map(p=>({tag:p.mark===" "?" ":"-",text:p.text})),l=s.map(p=>({tag:p.mark===" "?" ":"+",text:p.text})),c=p=>{let h=0;for(let m of p){if(m.tag!==" ")break;h++}return h},f=Math.min(c(u),c(l)),d=Math.min(c(u.toReversed()),c(l.toReversed()));if(u.every(p=>p.tag===" ")&&l.every(p=>p.tag===" "))throw new ne(`replacement text or line numbers mangled in hunk at line ${i+1}`);return{oldStart:e.first,oldLines:u,newStart:n.first,newLines:l,prefix:f,suffix:d,fn:o,marks:{old:a.map(p=>p.mark),new:s.map(p=>p.mark)},line:i}}function ug(e){let{lines:t}=e,n=e.pos,r=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n$/u.exec(t[n]??"");if(!r)return null;let o=n,i=Number(r[1]),s=r[3]==="a"?0:r[2]===void 0?1:Number(r[2])-i+1;r[3]==="a"&&i++;let a=Number(r[4]),u=r[5]===void 0?a:Number(r[5]);r[3]==="d"&&a++;let l=u-a+1;(s<0||l<0)&&sr(e,n,t[n]);let c=[],f=[];n++;for(let d=0;d<s;d++,n++){if(t[n]===void 0)throw new ne(`unexpected end of file in patch at line ${n}`);if(!/^<[ \t]/u.test(t[n]))throw new ne(`'<' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===s&&co(e,n);f.push({tag:"-",text:p?t[n].slice(2).replace(/\n$/u,""):t[n].slice(2)}),p&&n++}if(r[3]==="c"){if(t[n]===void 0)throw new ne(`unexpected end of file in patch at line ${n}`);if(!t[n].startsWith("-"))throw new ne(`'---' expected at line ${n+1} of patch`);n++}for(let d=0;d<l;d++,n++){if(t[n]===void 0)throw new ne(`unexpected end of file in patch at line ${n}`);if(!/^>[ \t]/u.test(t[n]))throw new ne(`'>' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===l&&co(e,n);c.push({tag:"+",text:p?t[n].slice(2).replace(/\n$/u,""):t[n].slice(2)}),p&&n++}return e.pos=n,{oldStart:i,oldLines:f,newStart:a,newLines:c,prefix:0,suffix:0,fn:null,marks:null,line:o}}function rs(e){let t=(r,o,i)=>r.map(s=>({tag:s.tag===o?i:s.tag,text:s.text})),n=(r,o,i)=>r.map(s=>s===o?i:s);return{...e,oldStart:e.newStart,newStart:e.oldStart,oldLines:t(e.newLines,"+","-"),newLines:t(e.oldLines,"-","+"),marks:e.marks&&{old:n(e.marks.new,"+","-"),new:n(e.marks.old,"-","+")}}}var ne=class extends Error{constructor(t){super(t),this.name="PatchFatal"}},ar=(e,t)=>{throw new x("feature",e,t)};function pg(e){let t=ot(e);return t.length&&!t.at(-1).endsWith(`
239
+ `)&&(t[t.length-1]+=`
240
+ `),{lines:t,pos:0,base:0,empty:e===""}}var S3=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u,lg=/^(?:\d+(?:,\d+)?)?(?:[acdi]|s\/\.\/\/)[ \t]*\n$/u,cg=/^[0-9a-fA-F]+/u;function hg(e,{needHeader:t,strip:n,format:r}){let{lines:o}=e,i={names:{old:null,new:null,index:null},stamps:{old:-1,new:-1},timestrs:{old:null,new:null},says:[0,0],git:!1,rename:[!1,!1],copy:[!1,!1],extended:!1},s=t&&r!=="normal"&&r!=="ed",a=!1,u=-1,l=!1,c=!1;for(let f=e.pos;;f++){if(f>=o.length)return a&&ar("ed script","ed scripts are not supported"),i.extended?{...i,type:"unified",start:f,hunkLine:f,empty:!0}:null;let d=o[f],p=d.replace(/^[ \tX]+/u,""),h=/^\d/u.test(p)&&S3.test(p);!s&&u<0&&(lg.test(p)||h)&&(u=f,a=lg.test(p));let m=A3(d,i,n,c);if(m==="binary"&&ar("git binary patch","git binary diffs are not supported"),m==="prereq"&&ar("Prereq","Prereq: lines are not supported"),m==="git"&&i.extended)return{...i,type:"unified",start:f,hunkLine:f,empty:!0};m&&(s=!1);let g=d.startsWith("********");if(/^[ \t]+(?:@@ -\d|\*{8})/u.test(d)&&ar("indented patch","indented patches are not supported"),!s){if(d.endsWith(`\r
241
+ `)&&(d.startsWith("@@ -")||c)&&ar("CRLF patch","patches with CRLF line endings are not supported"),(r===null||r==="ed")&&u>=0&&d===`.
242
+ `&&ar("ed script","ed scripts are not supported"),(r===null||r==="unified")&&d.startsWith("@@ -"))return O3(i,f,d);if((r===null||r==="context")&&c&&d.startsWith("*** "))return I3(e,i,f,d);if((r===null||r==="normal")&&l&&(d.startsWith("< ")||d.startsWith("> ")))return{...i,type:"normal",start:f-1,hunkLine:f-1}}c=g,l=h}}function A3(e,t,n,r){if(!r&&e.startsWith("*** ")||e.startsWith("+++ "))return al(t,"old",e.slice(4),n);if(e.startsWith("Index:"))return t.names.index=gg(e.slice(6),n,!1).name,"index";if(e.startsWith("Prereq:"))return"prereq";if(e.startsWith("diff --git ")){let i=fg(e.slice(11),n),s=i.name===null?null:fg(i.rest,n);return t.names.old=s&&s.rest.trim()===""?i.name:null,t.names.new=t.names.old===null?null:s.name,t.git=!0,t.stamps.old=t.stamps.new=-1,"git"}if(t.git){let i=N3(e,t);if(i)return i}let o=e;for(;o.startsWith("- ");)o=o.slice(2);return o.startsWith("--- ")?al(t,"new",o.slice(4),n):null}function N3(e,t){if(e.startsWith("index ")){let n=cg.exec(e.slice(6)),r=n?e.slice(6+n[0].length):"",o=r.startsWith("..")?cg.exec(r.slice(2)):null;return o?(t.says[0]=/^0+$/u.test(n[0])?2:0,t.says[1]=/^0+$/u.test(o[0])?2:0,t.extended=!0,"index"):null}return e.startsWith("old mode ")||e.startsWith("new mode ")?(t.extended=!0,"mode"):e.startsWith("deleted file mode ")?(t.says[1]=2,t.extended=!0,"mode"):e.startsWith("new file mode ")?(t.says[0]=2,t.extended=!0,"mode"):e.startsWith("rename from ")?(t.rename[0]=!0,t.extended=!0,"rename"):e.startsWith("rename to ")?(t.rename[1]=!0,t.extended=!0,"rename"):e.startsWith("copy from ")?(t.copy[0]=!0,t.extended=!0,"copy"):e.startsWith("copy to ")?(t.copy[1]=!0,t.extended=!0,"copy"):e.startsWith("GIT binary patch")?"binary":null}function al(e,t,n,r){let o=gg(n,r,!0);return o.stamp!==void 0&&(e.stamps[t]=o.stamp),o.name!==void 0&&(e.names[t]=o.name,e.timestrs[t]=o.timestr),"name"}function O3(e,t,n){let r={names:{...e.names,old:e.names.new,new:e.names.old},stamps:{old:e.stamps.new,new:e.stamps.old},timestrs:{old:e.timestrs.new,new:e.timestrs.old}},o=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/u.exec(n),i=[...e.says];return o&&o[1]==="0"&&(i[0]=1+(r.stamps.old===0?1:0)),o&&o[3]==="0"&&(i[1]=1+(r.stamps.new===0?1:0)),{...e,...r,says:i,type:"unified",start:t,hunkLine:t}}function I3(e,t,n,r){let o=[...t.says];/^\*\*\* 0(?!\d)/u.test(r)&&(o[0]=1+(t.stamps.old===0?1:0));let i={...e,pos:n-1};try{let s=sl(i);s&&s.newLines.length===0&&s.newStart===1&&(o[1]=1+(t.stamps.new===0?1:0))}catch{}return{...t,says:o,type:"context",start:n-1,hunkLine:n-1}}function mg(e,t){return t==="unified"?ag(e):t==="context"?sl(e):ug(e)}function gg(e,t,n){let r=e.replace(/^[ \t\n\v\f\r]+/u,""),o,i;if(r.startsWith('"')){let u=yg(r);if(!u)return{};o=u.value,i=u.rest}else{let u=0;for(;u<r.length;u++){if(!/[ \t\n\v\f\r]/u.test(r[u]))continue;let l=u;for(;r[l]!==" "&&/[ \t\n\v\f\r]/u.test(r[l+1]??"");)l++;if(!(r[l]!==" "&&r.indexOf(n?" ":`
243
+ `,l+1)!==-1))break}o=r.slice(0,u),i=r.slice(u)}if(o==="/dev/null")return{stamp:0};let s=wg(o,t);if(s===null)return{};let a=i.replace(/\r?\n$/u,"");return{name:s,timestr:a,stamp:n&&a!==""?T3(a):-1}}function T3(e){let t=/^\s*(\d{4})-(\d\d)-(\d\d)[ T](\d\d):(\d\d):(\d\d)(?:\.\d+)?\s*(?:([+-])(\d\d):?(\d\d))?/u.exec(e),n;if(t){let[,r,o,i,s,a,u,l,c,f]=t;n=Date.UTC(Number(r),Number(o)-1,Number(i),Number(s),Number(a),Number(u))/1e3,l&&(n-=(l==="-"?-1:1)*(Number(c)*3600+Number(f)*60))}else{let r=/^\s*[A-Z][a-z]{2} ([A-Z][a-z]{2}) +(\d+) (\d\d):(\d\d):(\d\d) (\d{4})/u.exec(e);if(!r)return-1;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],[,i,s,a,u,l,c]=r;n=Date.UTC(Number(c),o.indexOf(i),Number(s),Number(a),Number(u),Number(l))/1e3}return n>-25*3600&&n<26*3600?0:n}function wg(e,t){let n=t,r=0;for(let o=0;o<e.length;o++)if(e[o]==="/"){for(;e[o+1]==="/";)o++;(t<0||--n>=0)&&(r=o+1)}return(t<0||n<=0)&&r<e.length?e.slice(r):null}function fg(e,t){let n=e.replace(/^[ \t\n\v\f\r]+/u,""),r,o;if(n.startsWith('"')){let i=yg(n);if(!i)return{name:null,rest:""};r=i.value,o=i.rest}else{let i=n.search(/[ \t\n\v\f\r]/u);r=i<0?n:n.slice(0,i),o=i<0?"":n.slice(i)}return{name:wg(r,t),rest:o}}var dg={a:"\x07",b:"\b",f:"\f",n:`
244
+ `,r:"\r",t:" ",v:"\v","\\":"\\",'"':'"'};function yg(e){let t="";for(let n=1;n<e.length;n++){let r=e[n];if(r==='"')return{value:t,rest:e.slice(n+1)};if(r!=="\\"){t+=r;continue}let o=e[++n];if(o===void 0)return null;if(/[0-7]/u.test(o)){let i=/^[0-7]{1,3}/u.exec(e.slice(n))[0];t+=String.fromCodePoint(Number.parseInt(i,8)),n+=i.length-1}else if(o in dg)t+=dg[o];else return null}return null}function xg(e,t){let n=i=>i.split("/").length-1,r=i=>i.slice(i.lastIndexOf("/")+1).length,o=-1;for(let i=0;i<e.length;i++){let s=e[i];if(s===null||t[i])continue;if(o===-1){o=i;continue}let[a,u]=[n(s),n(e[o])];if(a!==u){a<u&&(o=i);continue}let[l,c]=[r(s),r(e[o])];if(l!==c){l<c&&(o=i);continue}s.length<e[o].length&&(o=i)}return o}function ul(e,t){let{opts:n}=e;return(n.noReverse||!(n.force&&n.silent))&&e.say(t),n.noReverse?(e.say(` Skipping patch.
245
+ `),e.skipRest=!0,!1):n.force?(n.silent||e.say(` Applying it anyway.
246
+ `),!1):n.batch?(e.say(e.reverse?` Ignoring -R.
247
+ `:` Assuming -R.
248
+ `),!0):(e.say(e.reverse?` Ignore -R? [n]
249
+ `:` Assume -R? [n]
250
+ `),e.say(`Apply anyway? [n]
251
+ `),n.silent||e.say(`Skipping patch.
252
+ `),e.skipRest=!0,!1)}function bg(e,t,n,r,o){let i=e.reverse?1:0,s=t.says,a=(o?0:1)<s[i^(o?1:0)];if(o&&s[i^(r?1:0)]===1&&s[1-i^(r?1:0)]===2)return!1;if(a){let u=r?"delete":o?"empty out":"create",l=r?"does not exist":o?"is already empty":"already exists";ul(e,`The next patch${e.reverse?", when reversed,":""} would ${u} the file ${e.quote(n)},
253
+ which ${l}!`)&&(e.reverse=!e.reverse)}return a}function kg(e,t,n,r){let o=[t.names.old,t.names.new,t.names.index];(o[0]!==null||o[1]!==null)&&o[2]!==null&&(o[2]=null);let i=-1;if(n===null){let a=o.map(c=>c===null?null:r(c)),u=a.map(c=>c===null||!c.exists);i=xg(o,u);let l=o.findIndex(c=>c!==null);if(l!==-1&&(i===-1||!a[i].isDir)){let c=i===-1;bg(e,t,o[c?l:i],c,c||a[i].size===0)&&c&&(i=l)}i===-1&&t.says[e.reverse?1:0]&&(i=xg(o,o.map(()=>!1)))}if((t.rename[0]||t.rename[1]||t.copy[0]||t.copy[1])&&n===null&&!((i===0||i===1)&&o[0]!==null&&o[1]!==null)&&(e.say(`Cannot ${t.rename[0]||t.rename[1]?"rename":"copy"} file without two valid file names
254
+ `),e.skipRest=!0),i===-1){if(n===null)return null;let a=r(n);return(!a.exists||!a.isDir)&&bg(e,t,n,!a.exists,!a.exists||a.size===0),n}return o[i]}function Eg(e){return{input:e,frozen:0,inOffset:0,outOffset:0,out:[]}}var C3=(e,t)=>t<1||t>e.input.length?"":e.input[t-1];function _3(e,t){let n=r=>r.replace(/\n$/u,"").replace(/[ \t]+$/u,"").replace(/[ \t]+/gu," ");return n(e)===n(t)}function os(e,t,n,r,o,i,s){let a=t.oldLines,u=a.length-i;for(let l=n+r+o,c=o;c<u;c++,l++){let f=C3(e,l),d=a[c].text;if(s?!_3(f,d):f!==d)return!1}return!0}function vg(e,t,n,r){let o=t.oldStart+e.inOffset,i=t.oldLines.length,s=Math.max(t.prefix,t.suffix),a=n+t.prefix-s,u=n+t.suffix-s,l=e.input.length,c=l-(i-u)+1,f=e.frozen+1,d=c-o,p=o-f,h=Math.max(d,p);if(!i)return o;o<=p&&(p=o-1);let m=w=>(e.inOffset+=w,o+w);if(a<0&&t.oldStart<=1){if(u<0&&(i!==l||t.prefix<e.frozen))return 0;let w=1-o;return e.frozen<=t.prefix&&w<=d&&os(e,t,o,w,0,u,r)?m(w):0}else a<0&&(a=0);if(u<0){let w=o-(l-i+1);return w<=p&&os(e,t,o,-w,a,0,r)?m(-w):0}let g=d<0?o-c:p<0?o-f:0;for(let w=g;w<=h;w++){if(w<=d&&os(e,t,o,w,a,u,r))return m(w);if(w<=p&&os(e,t,o,-w,a,u,r))return m(-w)}return 0}function is(e,t){if(e.frozen>t)return!1;for(;e.frozen<t;)e.frozen<e.input.length&&e.out.push(e.input[e.frozen]),e.frozen++;return!0}function L3(e,t,n){let r=n-1,o=t.newLines,i=t.oldLines,s=0,a=0,u=()=>{throw new ne(`Out-of-sync patch, lines ${t.line+1+a+1},${t.line+1+i.length+s+1} -- mangled text or line numbers, maybe?`)};for(;a<i.length;)if(i[a].tag==="-"){if(!is(e,r+a))return!1;e.frozen++,a++}else{if(s>=o.length)break;if(o[s].tag==="+"){if(!is(e,r+a))return!1;e.out.push(o[s++].text)}else o[s].tag===i[a].tag?(a++,s++):u()}for(;s<o.length&&o[s].tag==="+";s++){if(!is(e,r+a))return!1;e.out.push(o[s].text)}return e.outOffset+=o.length-i.length,!0}var $g=e=>e.frozen>=e.input.length||is(e,e.input.length),Sg=e=>e.map((t,n)=>n<e.length-1&&!t.endsWith(`
255
+ `)?t+`
256
+ `:t).join("");function Ag(e,t,n,r,o){let{opts:i}=e,s={count:0,failed:0,mismatch:!1,applyAnyway:!1};for(let a=n();a;a=n()){s.count++;let u=e.skipRest?{hunk:e.reverse?rs(a):a,where:0,fuzz:0}:F3(e,r,e.reverse?rs(a):a,s),{hunk:l,where:c,fuzz:f}=u,d=(c||l.oldStart)+r.outOffset,p=c===1&&t.says[e.reverse?1:0]===2&&r.input.length>0;if(e.skipRest||p||!c||!L3(r,l,c))e.skipRejectFile||o.add(l,s.failed===0,r.outOffset,e.reverse),s.failed++,!e.skipRest&&!i.silent&&e.say(`Hunk #${s.count} FAILED at ${d}.
257
+ `);else if(!i.silent&&(f||r.inOffset)){let h=r.inOffset?` (offset ${r.inOffset} line${r.inOffset===1?"":"s"})`:"";e.say(`Hunk #${s.count} succeeded at ${d}${f?` with fuzz ${f}`:""}${h}.
258
+ `)}}return s}function F3(e,t,n,r){let{opts:o}=e,i=0,s=n,a=0,u=Math.min(o.fuzz,Math.max(s.prefix,s.suffix));do if(a=vg(t,s,i,o.loose),(!a||i||t.inOffset)&&(r.mismatch=!0),r.count===1&&!a&&!(o.force||r.applyAnyway)&&e.reverse===e.reverseFlag){let l=rs(s);a=vg(t,l,i,o.loose),a&&ul(e,`${e.reverse?"Unreversed":"Reversed (or previously applied)"} patch detected!`)?(e.reverse=!e.reverse,s=l):a&&(r.applyAnyway=!0,i--,a=0)}while(!e.skipRest&&!a&&++i<=u);return{hunk:s,where:a,fuzz:i}}var fo=(e,t)=>e+t;function Ig(e,t){let n="",r=(i,s)=>`${i} ${e.names[s]??"/dev/null"}${e.timestrs[s]??""}
259
+ `,o=e.names.index===null?"":`Index: ${e.names.index}
260
+ `;return{get text(){return n},add(i,s,a,u){let l=u?["new","old"]:["old","new"];t==="unified"?(s&&(n+=o+r("---",l[0])+r("+++",l[1])),n+=R3(i,a)):(s&&(n+=o+r("***",l[0])+r("---",l[1])),n+=M3(i,a,t))}}}var Ng=(e,t)=>t===0?`${e-1},0`:t===1?`${e}`:`${e},${t}`;function R3(e,t){let n=e.newLines,r=e.oldLines,o=`@@ -${Ng(e.oldStart+t,r.length)} +${Ng(e.newStart+t,n.length)} @@${e.fn??""}
261
+ `,i=0,s=0;for(;;s++,i++){for(;s<r.length&&r[s].tag==="-";s++)o+=fo("-",r[s].text);for(;i<n.length&&n[i].tag==="+";i++)o+=fo("+",n[i].text);if(s>=r.length)break;o+=fo(" ",r[s].text)}return o}function Og(e,t){let n=e+t-1;return n<e?"0":n===e?`${e}`:`${e},${n}`}function M3(e,t,n){let r=n!=="normal",o=e.marks??(n==="normal"?D3(e):U3(e)),i=`***************${e.fn??""}
262
+ `;return i+=`*** ${Og(e.oldStart+t,e.oldLines.length)}${r?" ****":""}
263
+ `,e.oldLines.forEach((s,a)=>{i+=fo(o.old[a]+" ",s.text)}),i+=`--- ${Og(e.newStart+t,e.newLines.length)}${r?" ----":" -----"}
264
+ `,e.newLines.forEach((s,a)=>{i+=fo(o.new[a]+" ",s.text)}),i}var D3=e=>({old:e.oldLines.map(t=>t.tag),new:e.newLines.map(t=>t.tag)});function U3(e){let t=e.newLines.map(i=>i.tag),n=e.oldLines.map(i=>i.tag),r=0,o=0;for(;o<n.length;)if(n[o]==="-")if(r<t.length&&t[r]==="+"){do n[o++]="!";while(o<n.length&&n[o]==="-");do t[r++]="!";while(r<t.length&&t[r]==="+")}else do o++;while(o<n.length&&n[o]==="-");else if(r<t.length&&t[r]==="+")do r++;while(r<t.length&&t[r]==="+");else o++,r++;return{old:n,new:t}}var P3=["R","N","f","t","s","b","l","E","T","Z","e","u","c","n","v"],z3=["reverse","forward","force","batch","silent","quiet","backup","ignore-whitespace","remove-empty-files","dry-run","verbose","unified","context","normal","ed","binary","no-backup-if-mismatch","backup-if-mismatch","posix","follow-symlinks","help","version","set-time","set-utc"],B3=["p","i","o","d","r","F","z","B","Y","V","g","D","x"],j3=["strip","input","output","directory","reject-file","fuzz","suffix","prefix","basename-prefix","version-control","get","reject-format","quoting-style","read-only","merge","debug"],Tg=new Map([["T","setting file times"],["Z","setting file times"],["set-time","setting file times"],["set-utc","setting file times"],["e","ed scripts"],["ed","ed scripts"],["v","a version banner"],["version","a version banner"],["help","a help text"],["verbose","verbose output"],["B","backup prefixes"],["prefix","backup prefixes"],["Y","backup prefixes"],["basename-prefix","backup prefixes"],["V","numbered backups"],["version-control","numbered backups"],["g","version control"],["get","version control"],["D","merged #ifdef output"],["x","debugging output"],["debug","debugging output"],["posix","POSIX mode"],["follow-symlinks","symbolic links"],["quoting-style","quoting styles"],["read-only","read-only handling"],["merge","merging"]]),Cg=e=>b(`patch: ${e}
265
+ patch: Try 'patch --help' for more information.`,2);function Lg(e){for(let r of e){if(r==="--")break;let o=r.replace(/=.*/u,"");if(o==="--merge"||o==="--read-only")return{refused:v("option","patch",o,`patch: ${o}: ${Tg.get(o.slice(2))} is not supported`,2)}}let t;try{t=N(e,{short:P3,long:z3,valueShort:B3,valueLong:j3})}catch(r){let o=C(r);return o?{refused:v(o.kind,"patch",o.detail,`patch: ${r.message}`,2)}:{error:Cg(r.message)}}let n={strip:-1,input:null,output:null,directory:null,rejectFile:null,fuzz:2,suffix:".orig",format:null,rejectFormat:null,reverse:!1,noReverse:!1,force:!1,batch:!1,silent:!1,backup:!1,backupIfMismatch:!0,loose:!1,removeEmpty:!1,dryRun:!1};for(let{name:r,value:o}of t.order){let i=(r.length===1?"-":"--")+r,s=Tg.get(r);if(s)return{refused:v("option","patch",i,`patch: ${i}: ${s} is not supported`,2)};let a=W3(n,r,o);if(a)return{error:a}}return t.positional.length>2?{error:Cg(`${t.positional[2]}: extra operand`)}:{opts:n,operands:t.positional}}function _g(e,t){if(!/^[+-]?\d+$/u.test(e))return{error:b(`patch: **** ${t} ${pe(e,{vars:new Map})} is not a number`,2)};let n=Number(e);return n<0?{error:b(`patch: **** ${t} ${e} is negative`,2)}:{value:Math.min(n,Number.MAX_SAFE_INTEGER)}}function W3(e,t,n){switch(t){case"p":case"strip":{let r=_g(n,"strip count");return r.error?r.error:(e.strip=r.value,null)}case"F":case"fuzz":{let r=_g(n,"fuzz factor");return r.error?r.error:(e.fuzz=r.value,null)}case"i":case"input":return e.input=n,null;case"o":case"output":return e.output=n,null;case"d":case"directory":return e.directory=n,null;case"r":case"reject-file":return e.rejectFile=n,null;case"z":case"suffix":return n===""?b("patch: **** backup suffix is empty",2):(e.suffix=n,null);case"R":case"reverse":return e.reverse=!0,null;case"N":case"forward":return e.noReverse=!0,null;case"f":case"force":return e.force=!0,null;case"t":case"batch":return e.batch=!0,null;case"s":case"silent":case"quiet":return e.silent=!0,null;case"b":case"backup":return e.backup=!0,null;case"l":case"ignore-whitespace":return e.loose=!0,null;case"E":case"remove-empty-files":return e.removeEmpty=!0,null;case"dry-run":return e.dryRun=!0,null;case"u":case"unified":return e.format="unified",null;case"c":case"context":return e.format="context",null;case"n":case"normal":return e.format="normal",null;case"no-backup-if-mismatch":return e.backupIfMismatch=!1,null;case"backup-if-mismatch":return e.backupIfMismatch=!0,null;case"reject-format":return n!=="unified"&&n!=="context"?b(`patch: **** unknown reject format ${n}`,2):(e.rejectFormat=n,null);default:return null}}function Rg(e,t,n){let r=Lg(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:o,operands:i}=r,s={ctx:n,opts:o,dir:n.cwd,events:[],stdout:"",stderr:"",skipRest:!1,skipRejectFile:!1,reverse:o.reverse,reverseFlag:o.reverse,someFailed:!1,rejectsMade:new Set,output:""},a=o.output==="-"?2:1;s.quote=u=>pe(u,n),s.say=u=>{a===1?s.stdout+=u:s.stderr+=u,s.events.push({fd:a,text:u})};try{if(o.directory!==null){let l=E(n.cwd,o.directory,n.fs);if(l.error||!n.fs.isDir(l.path))throw new ne(`Can't change to directory ${pe(o.directory,n)} : ${l.error??"Not a directory"}`);s.dir=l.path}let u=q3(s,e,o.input??i[1]??null);H3(s,pg(u),i[0]??null),o.output!==null&&o.output!=="-"&&as(s,o.output,s.output,!1)}catch(u){if(!(u instanceof ne)){let c=C(u);if(!c)throw u;let f=`patch: ${u.message}`,d={stdout:s.stdout,stderr:s.stderr+f+`
266
+ `,events:[...s.events,{fd:2,text:f+`
267
+ `}],exitCode:2};return X(d,c.kind,"patch",c.detail,f)}let l=`patch: **** ${u.message}
268
+ `;return{stdout:s.stdout,stderr:s.stderr+l,events:[...s.events,{fd:2,text:l}],exitCode:2}}return{stdout:s.stdout,stderr:s.stderr,events:s.events,exitCode:s.someFailed?1:0}}function q3(e,t,n){if(n===null)return z(e.ctx),t;if(n==="-")return z(e.ctx),t;let r=D(e.ctx,"patch",n);if(r.error||e.ctx.fs.isDir(r.path))throw new ne(`Can't open patch file ${pe(n,e.ctx)} : ${r.error??"Is a directory"}`);return e.ctx.fs.readFile(r.path)}function H3(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let o=hg(t,{needHeader:n===null,strip:r.strip,format:r.format});if(o===null){if(t.base===0&&!t.empty)throw new ne("Only garbage was found in the patch input.");return}e.skipRest=!1,e.skipRejectFile=!1,e.reverse=e.reverseFlag;let i=kg(e,o,n,s=>us(e,s));i===null&&(i=G3(e,t,o)),e.skipRest&&(e.someFailed=!0),t.pos=o.start,X3(e,t,o,i),t.base=t.pos}}function G3(e,t,n){let{opts:r}=e;if(r.silent||(e.say(`can't find file to patch at input line ${n.hunkLine+1}
269
+ `),n.type!=="normal"&&e.say(r.strip===-1?`Perhaps you should have used the -p or --strip option?
270
+ `:`Perhaps you used the wrong -p or --strip option?
271
+ `)),t.base<n.start){e.say(`The text leading up to this was:
272
+ --------------------------
273
+ `);for(let o=t.base;o<n.start;o++)e.say("|"+t.lines[o]);e.say(`--------------------------
274
+ `)}return r.force||r.batch?e.say(`No file to patch. Skipping patch.
275
+ `):(e.say(`File to patch:
276
+ `),e.say(`Skip this patch? [y]
277
+ `),r.silent||e.say(`Skipping patch.
278
+ `)),e.skipRest=!0,null}function X3(e,t,n,r){let{opts:o}=e,i=n.copy[0]||n.copy[1]||n.rename[0]||n.rename[1],s=null;e.skipRest||(s=o.output??(i?n.names[e.reverse?"old":"new"]:r));let a={exists:!1,isDir:!1,content:""};e.skipRest||(a=us(e,r),(a.isDir||a.link)&&(e.say(`File ${pe(r,e.ctx)} is not a regular file -- refusing to patch
279
+ `),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!o.dryRun&&o.output===null&&(po(e,s),i&&r!==s&&po(e,r));let u=Eg(ot(a.exists?a.content:""));if(!e.skipRest&&!o.silent){let p=r!==s,h=!p&&(n.rename[0]||n.rename[1]),m=n.copy[0]||n.copy[1]?"copied":n.rename[0]||n.rename[1]?"renamed":"read",g=h?n.names[r===n.names.old?"new":"old"]:r,w=p||h?` (${h?"already ":""}${m} from ${g})`:"";e.say(`${o.dryRun?"checking":"patching"} file ${pe(s,e.ctx)}${w}
280
+ `)}let l=Ig(n,o.rejectFormat??n.type),f=Ag(e,n,()=>n.empty?null:mg(t,n.type),u,l);!e.skipRest&&!$g(u)&&(e.say(`misordered hunks! output would be garbled
281
+ Skipping patch.
282
+ `),e.skipRest=!0);let d=Sg(u.out);o.output!==null&&!e.skipRest&&(o.output==="-"?(e.stdout+=d,e.events.push({fd:1,text:d})):e.output+=d),!e.skipRest&&o.output===null&&Z3(e,n,{inname:r,outname:s,input:a,content:d,result:f,empty:u.out.length===0,renaming:i}),f.failed&&!e.skipRejectFile&&Y3(e,s,f,l.text)}function Z3(e,t,n){let{opts:r}=e,{inname:o,outname:i,input:s,content:a,result:u,empty:l,renaming:c}=n,f=r.backup||r.backupIfMismatch&&(u.mismatch||u.failed>0),d=t.says[e.reverse?0:1]===2;if(l&&(r.removeEmpty||d)){r.dryRun||Fg(e,i,f);return}if(!l&&d&&(e.someFailed=!0,r.silent||e.say(`Not deleting file ${pe(i,e.ctx)} as content differs from patch
283
+ `)),!r.dryRun){if(u.failed<u.count||c)as(e,i,a,f),c&&o!==i&&(t.rename[0]||t.rename[1])&&Fg(e,o,!1);else if(f){if(!s.exists)throw new ne(`Can't reopen file ${pe(i,e.ctx)} : No such file or directory`);as(e,ss(e,i),s.content,!1)}}}function Y3(e,t,n,r){let{opts:o}=e;if(e.someFailed=!0,e.say(`${n.failed} out of ${n.count} hunk${n.count===1?"":"s"} ${e.skipRest?"ignored":"FAILED"}`),t===null||o.rejectFile==="-"){e.say(`
284
+ `);return}let i=o.rejectFile??t+".rej";if(o.dryRun){e.say(`
285
+ `);return}e.say(` -- saving rejects to file ${pe(i,e.ctx)}
286
+ `),po(e,i);let s=e.rejectsMade.has(j(e.dir,i));e.rejectsMade.add(j(e.dir,i));let a=s?us(e,i).content:"";as(e,i,a+r,!1)}var ss=(e,t)=>t+e.opts.suffix;function us(e,t){let n=E(e.dir,t,e.ctx.fs,{follow:!1}),r=!n.error&&e.ctx.fs.isLink?.(n.path)===!0,o=E(e.dir,t,e.ctx.fs);if(o.error)return{exists:!1,isDir:!1,link:r,size:0,content:""};if(e.ctx.fs.isDir(o.path))return{exists:!0,isDir:!0,link:r,size:0,content:""};let i=e.ctx.fs.readFile(o.path);return{exists:!0,isDir:!1,link:r,size:i.length,content:i}}function po(e,t){let n=me(e.ctx.fs,e.dir,t,!1);if(!(e.ctx.writable&&n.startsWith("/tmp/")))throw new x("feature","read-only target",`${t}: file system is read-only`)}function as(e,t,n,r){let{ctx:o}=e;po(e,t);let i=E(e.dir,t,o.fs);try{if(!i.error){o.fs.replaceWritable(e.dir,t,n,r?ss(e,t):void 0);return}r&&o.fs.openWritable(e.dir,ss(e,t)),o.fs.openWritable(e.dir,t).write(n)}catch(s){throw new ne(`Can't create file ${pe(t,e.ctx)} : ${s?.fsError??s.message}`)}}function Fg(e,t,n){let{ctx:r}=e;po(e,t);let o=us(e,t);o.exists&&(n&&r.fs.openWritable(e.dir,ss(e,t)).write(o.content),r.fs.removeWritable(e.dir,t))}var Mg={du:A0,stat:H0,realpath:Pm,diff:og,patch:Rg};function V3(e,t,n){return N(t),R(n.cwd+`
287
+ `)}function K3(e,t,n){let{positional:r}=N(t);if(r.length>1)return b("cd: too many arguments");if(!r.length&&n.vars.unsetNames.has("HOME"))return b("cd: HOME not set");let o=r[0]??rr(n);if(o==="-"){if(!n.vars.has("OLDPWD"))return b("cd: OLDPWD not set");o=n.vars.get("OLDPWD")}let i=r[0]==="-"?o+`
288
+ `:"";if(o==="")return R(i);let{path:s,error:a}=D(n,"cd",o);return a?b(`cd: ${o}: ${a}`):n.fs.isDir(s)?s!==j(n.cwd,o)?v("feature","cd","symbolic link cwd",`cd: ${o}: a working directory reached through a symbolic link is not supported (it leads to ${s})`):(n.vars.set("OLDPWD",n.cwd),n.vars.set("PWD",s),n.cwd=s,R(i)):b(`cd: ${o}: Not a directory`)}var J3={dir:"/",link:"@",file:""};function Q3(e,t,n){let{flags:r,positional:o}=N(t,{short:["1","l","a","A","R","d","r","F","h"]}),i=r.has("l")?Km(n,r.has("h")):null,s=(o.length?o:["."]).toSorted(q);r.has("r")&&s.reverse();let a=[],u=[],l=[],c=Rn(),f=r.has("a")||r.has("A"),d=y=>n.fs.isDir(y)?"dir":n.fs.isLink?.(y)?"link":"file",p=y=>r.has("F")?J3[y]:"",h=(y,$,S)=>({raw:y,abs:$,kind:S,name:S==="link"&&i?y:y+(y.endsWith("/")?"":p(S)),target:S==="link"?n.fs.readLink($)+p(d(E(n.cwd,$,n.fs).path??"")):null}),m=(y,$)=>i?i.lines(y,$):y.map(S=>S.name),g=!(r.has("l")||r.has("F")||r.has("d"));for(let y of s){let{path:$,error:S}=D(n,"ls",y,{follow:!1}),_=S||!g||!n.fs.isLink?.($)?$:E(n.cwd,y,n.fs).path;S?u.push(`ls: cannot access '${y}': ${S}`):r.has("d")||n.fs.isFile($)||!n.fs.isDir(_)?l.push(h(y,$,d($))):a.push({path:y,abs:_})}let w=l.length?[m(l,!1).join(`
289
+ `)]:[];for(let y of a){let $=[y];for(;$.length;){let{path:S,abs:_}=$.pop(),W=n.fs.listDir(_);f||c.collect(_,[...W.dirs,...W.files,...W.links]);let H=(ce,An)=>ce.filter(Nn=>f||!Nn.startsWith(".")).map(Nn=>h(Nn,j(_,Nn),An)),re=[...H(W.dirs,"dir"),...H(W.files,"file"),...H(W.links,"link")];r.has("a")&&re.push(h(".",_,"dir"),h("..",j(_,".."),"dir")),re.sort((ce,An)=>q(ce.raw,An.raw)),r.has("r")&&re.reverse();let le=m(re,!0);if((s.length>1||r.has("R"))&&le.unshift(S+":"),le.length&&w.push(le.join(`
290
+ `)),!!r.has("R"))for(let ce of re.toReversed())ce.raw==="."||ce.raw===".."||!n.fs.isDir(ce.abs)||$.push({path:S.endsWith("/")?S+ce.raw:S+"/"+ce.raw,abs:ce.abs})}}return c.emit(n.notes,"ls","Hidden entries are included with -a."),{stdout:w.length?w.join(`
291
+
292
+ `)+`
293
+ `:"",stderr:u.length?u.join(`
294
+ `)+`
295
+ `:"",exitCode:u.length?2:0}}function eO(e,t){let{positional:n}=N(t);if(n.length===0)return xe("basename PATH [SUFFIX]");if(n.length>2)return b(`basename: extra operand: ${n[2]}`);let r=n[0].replace(/\/+$/u,""),o=r===""?n[0]===""?"":"/":r.slice(r.lastIndexOf("/")+1);return R(tO(o,n[1])+`
296
+ `)}function tO(e,t){return!t||t===e||!e.endsWith(t)?e:e.slice(0,-t.length)}function nO(e,t){let{positional:n}=N(t);return n.length===0?xe("dirname PATH"):R(n.map(r=>{let o=r.replace(/\/+$/u,""),i=o.lastIndexOf("/");return i<0?r.startsWith("/")?"/":".":o.slice(0,i).replace(/\/+$/u,"")||"/"}).join(`
297
+ `)+`
298
+ `)}var Dg={pwd:V3,cd:K3,ls:Q3,find:r0,tree:Qm,basename:eO,dirname:nO,...Mg};function Bg(e,t,n){let{flags:r,positional:o}=N(t,{short:["n","b","s","v","E","T","A","e","t"]}),i=a=>iO(a,r),s=rO(o,e,n,i,r.size!==0);if(s.bytes===void 0)return ue(i(s.content),s);if(r.size)throw new x("feature","binary file","cat: formatting bytes that spell no text is not supported");return{stdout:"",stderr:s.stderr,exitCode:s.failed?1:0,events:[{fd:1,bytes:s.bytes},...s.stderr?[{fd:2,text:s.stderr}]:[]]}}function Ug(e,t,n){let r=ae("cat",e,t,n,{read:"maybe-text"});return{parts:r.inputs.map(o=>o.content??o.bytes),stderr:r.stderr,failed:r.failed}}var Pg=e=>e.every(t=>typeof t=="string")?{content:e.join("")}:{bytes:Ze([...e.map(t=>typeof t=="string"?I(t):t),new Uint8Array])};function rO(e,t,n,r,o){let i=n.outputFds[1];if(!i?.path&&!n.outputFds[2]?.path){let c=Ug(e,t,n);return{...Pg(c.parts),stderr:c.stderr,failed:c.failed}}let s=[],a="",u=t,l="";for(let c of e.length?e:["-"]){let f=c==="-",d=f||c==="/dev/stdin",p=d?n.stdinHandle?.path:E(n.cwd,c,n.fs).path,h=d?n.stdinHandle?.identity:n.fs.fileIdentity?.(p);if(l&&zg(p,h,n.outputFds[2]))throw new x("feature","cat input modified by diagnostics","cat: reading an input after writing diagnostics to the same file is not supported");if(zg(p,h,i)){if((f?T(n.stdinHandle.content).length-T(u).length:0)<i.position+oO(s,a,r)){l+=`cat: ${c}: input file is output file
299
+ `;continue}let w=f?u:d?n.stdinOrigin:n.fs.readFile(p);if(o&&w!=="")throw new x("feature","cat transforms its input file","cat: transforming an input file through its own output descriptor is not supported")}let m=Ug([c],u,n);s.push(...m.parts),a+=m.parts.filter(g=>typeof g=="string").join(""),l+=m.stderr,(f||c==="/dev/stdin"&&!n.stdinFile)&&(u="")}return{...Pg(s),stderr:l,failed:l!==""}}var oO=(e,t,n)=>e.every(r=>typeof r=="string")?T(n(t)).length:e.reduce((r,o)=>r+(typeof o=="string"?T(o).length:o.length),0);function zg(e,t,n){return!e||!n?.path?!1:t!==void 0&&n.identity!==void 0?t===n.identity:e===n.path}function iO(e,t){if(!t.size)return e;let n=t.has("E")||t.has("A")||t.has("e"),r=t.has("T")||t.has("A")||t.has("t"),o=t.has("v")||t.has("A")||t.has("e")||t.has("t"),i=t.has("s")?sO(e):e,s=0;return ot(i).map(u=>{let l=u.endsWith(`
300
+ `),c=l?u.slice(0,-1):u,f=(t.has("b")?c!=="":t.has("n"))?`${String(++s).padStart(6)} `:"";return o?c=[...T(c)].map(d=>jg(d,r)).join(""):(r&&(c=c.replaceAll(" ","^I")),n&&l&&c.endsWith("\r")&&(c=c.slice(0,-1)+"^M")),f+c+(l?n?`$
301
+ `:`
302
+ `:"")}).join("")}function jg(e,t){return e===9?t?"^I":" ":e>=128?"M-"+jg(e-128,!0):e<32?"^"+String.fromCodePoint(e+64):e===127?"^?":String.fromCodePoint(e)}function sO(e){return e.replace(/(^|\n)\n+/gu,`$1
303
+ `)}var ls="sed: supported commands are p, P, n, N, d, D, a, i, c, g, G, h, H, x, w, q, =, y, :, b, t, T, { }, and s/regexp/replacement/[NgiIpw]",ll=1e6,cs=16*1024*1024,Wg=64*1024*1024;function _e(e="script"){throw new x("feature",e,ls)}function fs(e){return e.gap?v("feature","sed",e.gap,`sed: ${e.message}`):e instanceof RangeError?v("feature","sed","regex runtime limit",`sed: ${e.message}`):Q(e,"sed",`sed: ${e.message.replace(/^sed: /u,"")}`,e.exitCode)}function qg(e){let t=[],n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="--"){t.push(...e.slice(r));break}if(o==="--in-place"||o.startsWith("--in-place=")){n=o==="--in-place"?"":o.slice(11);continue}if(o.startsWith("--")||!o.startsWith("-")){t.push(o),(o==="--expression"||o==="--file")&&r+1<e.length&&t.push(e[++r]);continue}let i=o;for(let s=1;s<o.length;s++){let a=o[s];if(a==="i"){n=o.slice(s+1),i=o.slice(0,s);break}if(a==="e"||a==="f"){t.push(o),s+1===o.length&&r+1<e.length&&t.push(e[++r]),i="";break}if(!"nErsz".includes(a))break}i&&(i!=="-"||o==="-")&&t.push(i)}return{tokens:t,inPlace:n}}function Hg(e,t,n,r,o){if(e.files.length===0)return b("sed: no input files",4);let i=B(),s=new Set([...t,"s"]),a=!1;for(let u of e.files){let l=aO(u,n);if(l.error){if(U(i,n.flushOutput(l.error)),l.error.exitCode!==2)return ds(i,l.error);a=!0;continue}let c=o({...e,files:[l.path]},s),{content:f,...d}=c;if(U(i,d),c.failed||C(c))return ds(i,c);let p=uO(u,r),h;try{h=n.fs.replaceWritable(n.cwd,u,f,p)}catch(m){P(n,"sed",m?.path,m?.fsError);let g=Q(m,"sed",`sed: ${m.message}`,4);return U(i,g),ds(i,g)}if(!h){let m=cl(p??u);return U(i,m),ds(i,m)}if(c.quit)break}return a&&(i.exitCode=2),i}function aO(e,t){if(e==="/dev/null"||e==="/dev/stdin"&&!t.stdinFile||e==="/dev/stdout"&&!t.outputFds[1]?.path||e==="/dev/stderr"&&!t.outputFds[2]?.path)return{error:b(`sed: couldn't edit ${e}: not a regular file`,4)};if(e==="/dev/stdin"||e==="/dev/stdout"||e==="/dev/stderr")return{error:cl(e)};let n=D(t,"sed",e);if(n.error)return{error:b(oa("sed",e,n.error).trimEnd(),2)};if(t.fs.isDir(n.path))return{error:b(`sed: couldn't edit ${e}: not a regular file`,4)};let r=E(t.cwd,e,t.fs,{follow:!1}).path;return!t.writable||!r.startsWith("/tmp/")?{error:cl(e)}:n}function uO(e,t){if(!(t===""||t==="*"))return t.includes("*")?t.replaceAll("*",()=>e):e+t}function cl(e){return v("feature","sed","-i",`sed: ${e}: file system is read-only`)}function ds(e,t){let n=C(t);return n?X(e,n.kind,n.command,n.detail,n.message):e}function fl(e,t){let n=!1;return(r,o)=>{e((n?t:"")+r+(o??"")),n=o===""}}function Gg(e,t){let n=new Map,r=0,o,i,s,a=()=>e.io.setReads([o,i?.identity]);function u(c,f){if(f==="")return;l(f),a();let d=e.outputFds[c];if(d?.path){d.write(f);return}if(d==="closed"){let p=new Error("write error: Bad file descriptor");throw p.exitCode=4,p}s[c===1?"stdout":"stderr"]+=f,s.events.push({fd:c,text:f})}function l(c){if(r+=c.length,r>Wg)throw new x("feature","output limit","sed: output limit exceeded")}return{start(c){return s=B(),i=c,o=void 0,a(),s},record(c){o=c?.identity,a()},finish(){o=void 0,i=null,a()},stream:u,account:l,openWrite(c){if(n.has(c))return n.get(c);let f;if(c==="/dev/null")f=()=>{};else if(c==="/dev/stdout"||c==="/dev/stderr")f=p=>u(c==="/dev/stdout"?1:2,p);else{let p;try{p=e.writable&&e.fs.openWritable(e.cwd,c)}catch(h){throw P(e,"sed",h?.path,h?.fsError),h.exitCode=4,h}if(!p)throw new x("feature","output file",`sed: ${c}: Read-only file system`);f=h=>{l(h),a(),p.write(h)}}let d=fl(f,t);return n.set(c,d),d}}}function ho(e,t){let n=t.stdinHandle;if(!n)return e;let r=t.io.bufferReads(()=>t.fs.readIdentity(n.identity));if(r===n.content)return e;if(e!==n.content)throw new x("feature","modified redirected input","sed: reading an input file changed after partial consumption is not supported");return t.stdinHandle={...n,content:r},t.stdinOrigin=t.stdinLeft=r,r}function Xg(e,t,n,r,o,i){let s=e.length?e:["-"],a={stderr:"",failed:!1},u=0,l=0,c=t,f=null;function d(){for(;f===null||f.pos===f.content.length;){if(u===s.length)return!1;f=null;let h=s[u++];h==="-"?c=ho(c,n):h==="/dev/stdin"&&n.stdinHandle&&(n.stdinOrigin=n.io.bufferReads(()=>n.fs.readIdentity(n.stdinHandle.identity)));let m=bt("sed",[h],n,c);if(a.stderr+=m.stderr,a.failed||=m.failed,f=m.inputs.length?{...m.inputs[0],identity:lO(h,n),pos:0,first:!0}:null,m.stderr&&i&&i(m.stderr),m.entries.some(g=>g.kind==="dir"))return a.directory=!0,u=s.length,!1;f?.shared&&z(n,c),o&&(l=0)}return!0}function p(){if(!d())return null;let h=f.pos,m=f.content.indexOf(r,h),g=m<0?"":r,w=f.content.slice(h,m<0?f.content.length:m);f.pos=m<0?f.content.length:m+r.length,f.shared&&(c=f.content.slice(f.pos),z(n,c));let y=f.first;f.first=!1;let $;return{text:w,terminator:g,line:++l,reset:y,identity:f.identity,last:()=>$??=f.pos<f.content.length?!1:o||!d()}}return{next:p,status:a,get identity(){return f?.identity}}}function lO(e,t){return e==="-"||e==="/dev/stdin"?t.stdinHandle?.identity:t.fs.fileIdentity?.(E(t.cwd,e,t.fs).path??j(t.cwd,e))}var ps={n:`
304
+ `,t:" ",r:"\r",a:"\x07",f:"\f",v:"\v"};function mo(e,t="substitute command"){let n=e.script[e.i++];if(n===void 0||n===`
305
+ `)throw new Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw new Error("delimiter character is not a single-byte character");return n}function hs(e,t,n,r="substitute command"){let o="",i=!1;for(;e.i<e.script.length;){let s=e.script[e.i++];if(s===`
306
+ `)throw new Error(`unterminated ${r}`);if(s===t&&!i)return o;if(s==="\\"){let a=e.script[e.i++];if(a===void 0||a===`
307
+ `&&i)throw new Error(`unterminated ${r}`);if(a===`
308
+ `){o+=a;continue}o+=!i&&a===t&&(n||a!=="&")?a:s+a;continue}if(n&&s==="["&&!i){i=!0,o+=s,e.script[e.i]==="^"&&(o+=e.script[e.i++]),e.script[e.i]==="]"&&(o+=e.script[e.i++]);continue}if(n&&i&&s==="["&&/[:.=]/u.test(e.script[e.i]??"")){let a=e.script.indexOf(e.script[e.i]+"]",e.i+1);if(a<0)throw new Error("unterminated character class");if(e.script.slice(e.i,a).includes(`
309
+ `))throw new Error(`unterminated ${r}`);o+=s+e.script.slice(e.i,a+2),e.i=a+2;continue}n&&s==="]"&&(i=!1),o+=s}throw new Error(`unterminated ${r}`)}function Zg(e){let t=mo(e),n=hs(e,t,!0),r=hs(e,t,!1),o=dO(r),i=cO(e);if(n===""&&(i.ignoreCase||i.multiline))throw new Error("cannot specify modifiers on empty regexp");i.multiline&&Yg(i.multiline);let s=pl(n,e.extended,!1,i.ignoreCase,e.locale);for(let a of o)if(typeof a=="number"&&a>s.re?.groupCount)throw new Error(`invalid reference \\${a} in replacement`);return{...s,parts:o,...i}}function cO(e){let t={global:!1,print:!1,nth:null};for(;e.i<e.script.length;){let n=e.script[e.i];if(/[;\n#}]/u.test(n))break;if(e.i++,!/[ \t]/u.test(n)){if(n==="\r"&&e.script[e.i]===`
310
+ `)break;if(/\d/u.test(n)){if(t.nth!==null)throw new Error("multiple number options to substitute command");let r=/^\d*/u.exec(e.script.slice(e.i))[0];if(e.i+=r.length,t.nth=Number(n+r),t.nth===0)throw new Error("number option to substitute command may not be zero");Number.isSafeInteger(t.nth)||_e("substitution occurrence limit")}else if(n==="g"||n==="p"){let r=n==="g"?"global":"print";if(t[r])throw new Error("multiple substitution flags");t[r]=!0}else if(n==="w"){Object.assign(t,dl(e));break}else if(n==="i"||n==="I")t.ignoreCase=!0;else if(n==="m"||n==="M")t.multiline=n;else if(n==="e")Yg(n);else throw new Error(`unknown option to substitute command: '${n}'`)}}return t}function Yg(e){let t=e==="e"?"command evaluation":"multiline regex matching";throw new x("feature",`substitution flag ${e}`,`sed: substitution flag '${e}' (${t}) is not supported`)}function dl(e){let t=/^[ \t]*([^\n]*)/u.exec(e.script.slice(e.i));e.i+=t[0].length;let n=t[1].split("\0",1)[0];if(n==="")throw new Error("missing filename in r/R/w/W commands");return e.openWrite?{writer:e.openWrite(n)}:{writeName:n}}function pl(e,t,n=!1,r=!1,o=ie){if(!e){if(r)throw new Error("cannot specify modifiers on empty regexp");return{re:null}}let i=se(o);vu(e,t,i.multibyte);let s=e.replace(/\\(.)/gu,(c,f)=>(f==="o"&&_e("regex escape"),Object.hasOwn(ps,f)?ps[f]:c)),a=r?Jr(s,i):s,u=t?{source:xu(a,i)}:Fi(a,i);if(u.error)throw new Error(u.error);fO(u.source,t),Ri(u.source);for(let[,c]of u.source.matchAll(/\\(.)/gu))/[1-9]/u.test(c)&&_e("regex backreferences");return{re:new Ot(gn(u.source,"extent",i),!1,null,i),noSub:n,locale:o,ignoreCase:r,pattern:s}}function fO(e,t){let n=!1,r=0,o=!1,i=!1;for(let s=0;s<e.length;s++){let a=e[s];if(a==="\\"){let u=e[++s];n||(o=!"bB<>`'".includes(u),i=!1);continue}if(n){a==="]"&&(n=!1,o=!0,i=!1);continue}if(a==="["){n=!0;continue}if(a==="("){r++,o=!1,i=!1;continue}if(a===")"){if(--r<0)throw new Error("unmatched )")}else if(a==="|"||a==="^"||a==="$"){o=!1,i=!1;continue}else if("*+?{".includes(a)){let u=a==="{"?/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u.exec(e.slice(s)):null;if(a==="{"&&u===null)throw new Error("invalid repetition count");if(!o||!t&&i&&(a==="*"||a==="{"))throw new Error("Invalid preceding regular expression");u&&(s+=u[0].length-1),i=!0;continue}o=!0,i=!1}if(r>0)throw new Error("unmatched (")}function dO(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="&"){t.push(0);continue}if(r!=="\\"){t.push(r);continue}let o=e[++n];/[0-9]/u.test(o)?t.push(Number(o)):o==="\\"||o==="&"?t.push(o):Object.hasOwn(ps,o)?t.push(ps[o]):_e("replacement escape")}return t}function hl(e,t){if(/[\u0080-\u{10FFFF}]/u.test(e+t.re.src)){if(t.locale!==ie)throw new x("feature","locale",`matching non-ASCII text in the ${t.locale} locale is not supported`);t.ignoreCase&&on.test(e+t.pattern)&&_e("case folding of Cyrillic Extended-C letters")}}function ml(e,t,n=null){let r=e.re===null?t.last:e;if(!r)throw new Error("no previous regular expression");if(t.last=r,n!==null&&r.noSub){if(n>r.re.groupCount)throw new Error(`invalid reference \\${n} in replacement`);r.noSub=!1}return r}function gl(e,t,n){let r=t.parts.reduce((l,c)=>typeof c=="number"?Math.max(l,c):l,0),o=ml(t,n,r);hl(e,o);let i=t.parts.some(l=>typeof l=="number"&&l>0&&l<=o.re.groupCount),s=0,a=t.nth&&!t.global?{search:(l,c)=>s?null:o.re.search(l,c)}:o.re;return{out:Kr(e,a,(l,c,f)=>{if(t.nth&&f<t.nth)return null;s++;let d=i?o.re.groups(e,l,c):null;return t.parts.map(p=>typeof p=="string"?p:p===0?e.slice(l,c):d?.[p]?.text??"").join("")},t.global||t.nth?"global":"first").out,count:s}}var Vg={a:7,f:12,n:10,r:13,t:9,v:11,"\n":10},Kg={d:10,o:8,x:16};function Qg(e,t){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;if(e.i===e.script.length)throw new Error("expected \\ after 'a', 'c' or 'i'");if(t.text=null,e.textState.pending={command:t,raw:""},e.script[e.i]==="\\"){let n=e.script[++e.i];if(n===void 0)return;e.i++,n!==`
311
+ `&&(e.textState.pending.raw=n)}yl(e)}function yl(e){let t=e.textState.pending;if(!t)return;let n=t.raw;for(;e.i<e.script.length&&e.script[e.i]!==`
312
+ `;){let r=e.script[e.i++];if(r==="\\"){if(e.i===e.script.length){t.raw=n+`
313
+ `;return}n+=r+e.script[e.i++]}else n+=r}t.command.text=pO(n+`
314
+ `),e.textState.pending=null}function xl(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function pO(e){return G(wl(e))}function wl(e){let t=T(e),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(o!==92||r+1===t.length){n.push(o);continue}let i=String.fromCodePoint(t[++r]);if(Object.hasOwn(Vg,i)){n.push(Vg[i]);continue}if(Object.hasOwn(Kg,i)){let s=Kg[i],a=s===16?2:3,u=0,l=0;for(;u<a&&r+1<t.length;){let c=t[r+1],f=c>=48&&c<=57?c-48:(c|32)>=97&&(c|32)<=102?(c|32)-87:-1;if(f<0||f>=s)break;l=l*s+f,u++,r++}n.push(u?l&255:i.codePointAt(0))}else if(i==="c"){if(++r===t.length)continue;let s=t[r];if(s===92&&t[++r]!==92)throw new Error("recursive escaping after \\c not allowed");n.push((s>=97&&s<=122?s-32:s)^64)}else n.push(i.codePointAt(0))}return Uint8Array.from(n)}function ew(e){let t=mo(e,"'y' command"),n=wl(Jg(e,t)),r=wl(Jg(e,t)),o=e.byteLocale?n:[...G(n)],i=e.byteLocale?r:[...G(r)];if(o.length!==i.length)throw new Error("'y' command strings have different lengths");let s=e.byteLocale?Uint8Array.from({length:256},(a,u)=>u):new Map;for(let a=0;a<o.length;a++)e.byteLocale?s[o[a]]=i[a]:s.has(o[a])||s.set(o[a],i[a]);return{translation:s,byteLocale:e.byteLocale}}function Jg(e,t){let n="";for(;e.i<e.script.length;){let r=e.script[e.i++];if(r===`
315
+ `)break;if(r===t)return n;if(r!=="\\"){n+=r;continue}let o=e.script[e.i++];if(o===void 0)break;n+=o===t||o===`
316
+ `?o:r+o}throw new Error("unterminated 'y' command")}function tw(e,t){if(t.byteLocale)return G(T(e).map(r=>t.translation[r]));let n="";for(let r of e)n+=t.translation.get(r)??r;return n}function bl(e,t=!1,n=ie,r=null){let o={script:e,i:0,extended:t,locale:n,byteLocale:Zo(n),textState:r??{},openWrite:r?.openWrite},i=[];for(yl(o);o.i<e.length;){if(/[;\n\r\f\v \t]/u.test(e[o.i])){o.i++;continue}e[o.i]==="#"&&_e("comments");let s=nw(o),a=null;if(s&&e[o.i]===","&&(o.i++,a=nw(o,!0),a===null))throw new Error("missing second address");e[o.i]==="~"&&_e("step address");let u=s?.type==="line"&&s.value===0;if(u&&a?.type!=="regex")throw new Error("line numbers must be >= 1");let l=!1;if(e[o.i]==="!"){for(l=!0,o.i++;/[ \t]/u.test(e[o.i]??"");)o.i++;if(e[o.i]==="!")throw new Error("multiple '!'s")}let c=e[o.i++],f={kind:c,start:s,end:a,active:u,negated:l};if(c&&"pPnNdD=gGhHx".includes(c))i.push(f);else if(c==="w"){i.push({...f,...dl(o)});continue}else if(c===":"||c==="b"||c==="t"||c==="T"){i.push({...f,label:hO(o,f)});continue}else if(c==="s")i.push({...f,...Zg(o)});else if(c==="a"||c==="i"||c==="c")Qg(o,f),i.push(f);else if(c==="y")i.push({...f,...ew(o)});else if(c==="q"){if(a!==null)throw new Error("command only uses one address");let d=/^[ \t]*(\d*)/u.exec(e.slice(o.i));o.i+=d[0].length;let p=BigInt.asIntN(32,BigInt(d[1]||"0"));i.push({...f,exitCode:p===-1n?0:Number(BigInt.asUintN(8,p))})}else if(c==="{"){o.textState.blockDepth=(o.textState.blockDepth??0)+1,i.push(f);continue}else if(c==="}"){if(!o.textState.blockDepth)throw new Error("unexpected '}'");if(s!==null)throw new Error("'}' doesn't want any addresses");o.textState.blockDepth--,i.push(f)}else{if(c===void 0)throw new Error("missing command");if("QlLFzrRWev".includes(c))_e();else throw new Error(`unknown command: '${c}'`)}for(;/[ \t]/u.test(e[o.i]??"");)o.i++;if(e[o.i]==="#"&&_e("comments"),o.i<e.length&&!/[;\n}]/u.test(e[o.i]))throw new Error("extra characters after command")}return r===null&&xl(o.textState),i}function kl(e,t){let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.kind==="{"&&n.push(o),o.kind==="}"){if(n.length===0)throw new Error("unexpected '}'");n.pop().jump=r}}if(n.length)throw new Error("unmatched '{'");return xl(t),mO(e),e}function hO(e,t){if(t.kind===":"&&t.start!==null)throw new Error("':' doesn't want any addresses");let n=/^[ \t]*([^ \t\n;}#]*)/u.exec(e.script.slice(e.i));e.i+=n[0].length;let r=n[1].split("\0",1)[0];if(t.kind===":"&&r==="")throw new Error("':' lacks a label");return r}function mO(e){let t=new Map;for(let n=0;n<e.length;n++)e[n].kind===":"&&t.set(e[n].label,n);for(let n=e.length-1;n>=0;n--){let r=e[n];if(!["b","t","T"].includes(r.kind))continue;let o=r.label===""?e.length:t.get(r.label);if(o===void 0)throw Object.assign(new Error(`can't find label for jump to \`${r.label}'`),{exitCode:4});r.jump=o}}function nw(e,t=!1){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;e.script[e.i]==="~"&&_e("step address");let n=/^(\d+|\+[ \t]*\d+)/u.exec(e.script.slice(e.i)),r=null;if(n){let o=n[0][0]==="+";if(o&&!t)throw new Error("relative address requires a range");let i=Number(n[0].replace(/[ \t]/gu,""));Number.isSafeInteger(i)||_e("address limit"),e.i+=n[0].length,r={type:o?"offset":"line",value:i}}else if(e.script[e.i]==="$")e.i++,r={type:"last"};else if(e.script[e.i]==="/"||e.script[e.i]==="\\"){e.script[e.i]==="\\"&&e.i++;let o=mo(e,"address regex"),i=hs(e,o,!0,"address regex"),s=!1;for(;;){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;let a=e.script[e.i];if(a!=="I"&&a!=="M")break;if(i==="")throw new Error("cannot specify modifiers on empty regexp");a==="M"&&_e("address regex flags"),s=!0,e.i++}r={type:"regex",...pl(i,e.extended,!0,s,e.locale)}}for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;return r}function rw(e,t,n,r,o){let{start:i,end:s}=e;if(i===null)return!0;if(s===null)return ms(i,t,n,r,o);if(!e.active){if(i.type==="line"){if(e.closed||n<i.value)return!1}else if(!ms(i,t,n,r,o))return!1;if(e.active=!0,s.type==="regex")return!0;if(s.type==="offset"&&(e.until=n+s.value),s.type==="line")return e.active=n<s.value,e.closed=!e.active,n<=s.value||ms(i,t,n,r,o)}return s.type==="line"?(e.active=n<s.value,e.closed=!e.active,n<=s.value):((s.type==="offset"?n>=e.until:ms(s,t,n,r,o))&&(e.active=!1,e.closed=!0),!0)}function ms(e,t,n,r,o){if(e.type==="line")return n===e.value;if(e.type==="last")return typeof r=="function"?r():r;let i=ml(e,o);return hl(t,i),i.re.search(t)!==null}function vl(e,t,n,r=!1){let{output:o,delimiter:i}=e,s=t.has("n")||t.has("quiet")||t.has("silent"),a=t.has("s")||t.has("separate"),u=Xg(e.files,e.stdin,n,i,a,p=>o.stream(2,p)),l=o.start(u),c=[],f=fl(r?p=>{o.account(p),c.push(p)}:p=>o.stream(1,p),i),d={delimiter:i,quiet:s,separate:a,hold:e.hold,regexState:e.regexState,budget:e.budget,emit:f,input:u,output:o};try{let p=gO(e.commands,d);l.quit=p!==null,l.exitCode=u.status.failed?u.status.directory?4:2:p??0,l.failed=u.status.failed}catch(p){let h=fs(p);U(l,h);let m=C(h);m&&X(l,m.kind,m.command,m.detail,m.message),l.failed=!0}finally{o.finish()}return r&&(l.content=c.join("")),l}function gO(e,t){let n=!0;for(let r=t.input.next();r;r=t.input.next()){if(n||t.separate&&r.reset){t.hold.text="";for(let s of e)s.active=s.start?.type==="line"&&s.start.value===0,s.closed=!1;n=!1}t.output.record(r);let o={...r,...t,append:[],exitCode:null,replaced:!1},i=wO(e,o);if(!t.quiet&&!i&&t.emit(o.text,o.terminator),o.exitCode!==null&&t.emit(""),ow(o),o.exitCode!==null)return o.exitCode;t.output.record(null)}return null}function wO(e,t){for(let n=0;n<e.length;n++){if(++t.budget.steps>ll)throw new x("feature","execution limit",`sed: execution limit reached after ${ll} commands (infinite loop?)`);let r=e[n];if(r.kind==="}"||r.kind===":")continue;if(rw(r,t.text,t.line,t.last,t.regexState)===!!r.negated){r.kind==="{"&&(n=r.jump);continue}let i=r.kind;if(i!=="{"){if(i==="b"||i==="t"||i==="T"){let s=i==="b"||(i==="t"?t.replaced:!t.replaced);i!=="b"&&(t.replaced=!1),s&&(n=r.jump-1);continue}if(i==="q"){t.exitCode=r.exitCode;break}if(i==="d")return!0;if(i==="D"){let s=t.text.indexOf(t.delimiter);if(s<0)return!0;t.text=t.text.slice(s+t.delimiter.length),n=-1;continue}if(i==="n"||i==="N"){if(!bO(t,i==="N"))return!0;continue}if(i==="c")return!r.active&&r.text!==null&&t.emit(r.text.slice(0,-1),t.delimiter),!0;if(yO(r,t),t.text.length>cs)throw new x("feature","pattern space limit","sed: pattern space limit exceeded")}}return!1}function yO(e,t){let{kind:n}=e;if(n==="a"){t.append.push(e.text);return}if(n==="i")e.text!==null&&t.emit(e.text.slice(0,-1),t.delimiter);else if(n==="p")t.emit(t.text,t.terminator);else if(n==="P"){let r=t.text.indexOf(t.delimiter);t.emit(r<0?t.text:t.text.slice(0,r),r<0?t.terminator:t.delimiter)}else if(n==="=")t.emit(String(t.line),t.delimiter);else if(n==="w")e.writer(t.text,t.terminator);else if("gGhHx".includes(n))xO(n,t);else if(n==="y")t.text=tw(t.text,e);else{let r=gl(t.text,e,t.regexState);if(t.text=r.out,!r.count)return;t.replaced=!0,e.print&&t.emit(t.text,t.terminator),e.writer&&e.writer(t.text,t.terminator)}}function xO(e,t){let n=t.hold;if(e==="x"){let{text:r,terminator:o}=t;Object.assign(t,n),Object.assign(n,{text:r,terminator:o})}else{let r=e==="h"||e==="H"?t:n,o=r===n?t:n;o.text=e==="G"||e==="H"?o.text+t.delimiter+r.text:r.text,o.terminator=r.terminator}if(n.text.length>cs)throw new x("feature","hold space limit","sed: hold space limit exceeded")}function bO(e,t){if(!t&&!e.quiet&&e.emit(e.text,e.terminator),e.last())return t&&!e.quiet&&e.emit(e.text,e.terminator),!1;ow(e);let n=e.input.next();if(!n)return t&&!e.quiet&&e.emit(e.text,e.delimiter),!1;let r=t?e.text+e.delimiter+n.text:n.text;if(r.length>cs)throw new x("feature","pattern space limit","sed: pattern space limit exceeded");return Object.assign(e,n,{text:r,replaced:!1}),e.output.record(n),!0}function ow(e){if(e.append.length!==0){e.emit("");for(let t of e.append)e.emit(t??"");e.append.length=0}}function iw(e,t,n){try{let{tokens:r,inPlace:o}=qg(t),i=N(r,{short:["n","E","r","s","z"],long:["regexp-extended","quiet","silent","separate","null-data","zero-terminated"],repeatable:["e","expression","f","file"]}),s=i.flags.has("z")||i.flags.has("null-data")||i.flags.has("zero-terminated")?"\0":`
317
+ `,a=Gg(n,s),u=kO(i,e,n,a.openWrite);return u===null?b(ls):u.error?u.error:(Object.assign(u,{output:a,delimiter:s,hold:{text:"",terminator:s},regexState:{last:null},budget:{steps:0}}),u.stdin=ho(u.stdin,n),o===null?vl(u,i.flags,n):Hg(u,i.flags,n,o,(l,c)=>vl(l,c,n,!0)))}catch(r){return fs(r)}}function kO({order:e,positional:t},n,r,o){let i=[],s={openWrite:o},a=!1,u=!1;for(let{name:l,value:c}of e){if((l==="E"||l==="r"||l==="regexp-extended")&&(a=!0),!["e","expression","f","file"].includes(l))continue;u=!0;let f=c;if(l==="f"||l==="file"){n=ho(n,r);let d=n,p=r.io.bufferReads(()=>bt("sed",[c],r,d));if(p.failed)return{error:b(p.stderr,4)};f=p.inputs[0].content,p.inputs[0].shared&&(n="")}for(let d of bl(f,a,r.locale,s))i.push(d)}return u?{commands:kl(i,s),files:t,stdin:n}:t.length===0?null:{commands:kl(bl(t[0],a,r.locale,s),s),files:t.slice(1),stdin:n}}var vO=new Set(["-b","-c","-g","-k","-p","-r","-t","-u","-v","-w","-x","-G","-N","-O","-R","-S","-o"]),EO=new Set(["-nt","-ot","-ef","<",">"]),wo={__proto__:null,"-eq":(e,t)=>e===t,"-ne":(e,t)=>e!==t,"-lt":(e,t)=>e<t,"-le":(e,t)=>e<=t,"-gt":(e,t)=>e>t,"-ge":(e,t)=>e>=t},$O=String(ge).length,SO=new Set(["/dev/stdin","/dev/stdout","/dev/stderr"]);function uw(e,t,n){return cw("test",t,n)}function lw(e,t,n){return t.at(-1)!=="]"?b("[: missing `]'",2):cw("[",t.slice(0,-1),n)}function cw(e,t,n){try{return{...R(),exitCode:El(t,n)?0:1}}catch(r){return Q(r,e,`${e}: ${r.message}`,2)}}function El(e,t){let[n,r,o]=e;if(e.length===0)return!1;if(e.length===1)return n!=="";if(e.length===2){if(n==="!")return r==="";if(n==="-n")return r!=="";if(n==="-z")return r==="";if(["-a","-e","-f","-d","-h","-L","-s"].includes(n))return $l(n,r,t);throw vO.has(n)&&go(n),new Error(`${n}: unary operator expected`)}if(e.length===3){if(r==="="||r==="==")return n===o;if(r==="!=")return n!==o;if(Object.hasOwn(wo,r))return wo[r](sw(n),sw(o));EO.has(r)&&go(r),(r==="-a"||r==="-o")&&go("compound expressions")}if(e.length<=4){if(n==="!")return!El(e.slice(1),t);if(n==="("&&e.at(-1)===")")return El(e.slice(1,-1),t)}throw e.some(i=>["-a","-o","!","(",")"].includes(i))&&go("compound expressions"),new Error(e.length>3?"too many arguments":`${r}: binary operator expected`)}function sw(e){let t=/^[ \t\n\r\f\v]*([+-]?)(\d+)[ \t]*$/u.exec(e);if(t&&t[0].length===e.length){let n=t[2].replace(/^0+/u,"")||"0";if(n.length<=$O){let r=BigInt(t[1]+n);if(r>=wt&&r<=ge)return r}}throw new Error(`${e}: integer expression expected`)}function $l(e,t,n){let r={isDir:a=>a==="/dev"||a==="/dev/fd"||n.fs.isDir(a),isFile:a=>a==="/dev/null"||aw(a)||n.fs.isFile(a),isLink:a=>n.fs.isLink?.(a)===!0,readLink:a=>n.fs.readLink?.(a)},o=e==="-h"||e==="-L",{path:i,error:s}=E(n.cwd,t,r,{follow:!o});return s?!1:(aw(i)&&go("stream device metadata"),o?r.isLink(i):e==="-e"||e==="-a"?!0:e==="-d"?r.isDir(i):e==="-s"?r.isDir(i)||i!=="/dev/null"&&AO(n,i)>0:i!=="/dev/null"&&n.fs.isFile(i))}var AO=(e,t)=>e.fs.fileSize?.(t)??I(e.fs.readFile(t)).length;function aw(e){return SO.has(e)||/^\/dev\/fd\/\d+$/u.test(e)}function go(e){throw new x("feature",e,`${e} is not supported`)}function pw(e){let t=e.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/gu,""),n=/^[+-]?\d+$/u.test(t)?BigInt(t):null,r=n!==null&&n>=wt&&n<=ge?n:null;return{arg:t,n:r}}var ur=e=>({...e,halt:!0});function NO(e,t,n){let r=t[0]==="--"?t.slice(1):t;if(r.length===0)return ur({...R(),exitCode:n.lastExit});let{arg:o,n:i}=pw(r[0]);return i===null?ur(b(`exit: ${o}: numeric argument required`,2)):r.length>1?ur(b("exit: too many arguments")):ur({...R(),exitCode:Number((i%256n+256n)%256n)})}function fw(e){return(t,n,r)=>{let o=n[0]==="--"?n.slice(1):n;if(o.length>1)return ur(b(`${e}: too many arguments`));let{arg:i,n:s}=pw(o[0]??"1");return s===null?ur(b(`${e}: ${i}: numeric argument required`,128)):s<=0?{...b(`${e}: ${i}: loop count out of range`),control:r.loopDepth?{type:"break",levels:r.loopDepth}:void 0}:r.loopDepth===0?b(`${e}: only meaningful in a \`for\`, \`while\` or \`until\` loop`,0):{...R(),control:{type:e,levels:Number(s>BigInt(r.loopDepth)?BigInt(r.loopDepth):s)}}}}function OO(e,t,n){let r=t[0]==="--",o=r?t.slice(1):t;if(o.length===0||!r&&o[0]==="-p")return v("option","export","-p","export: listing the environment is not supported (there is none)");let i="";for(let s of o){let a=s.indexOf("="),u=a>0&&s[a-1]==="+",l=a===-1?s:s.slice(0,u?a-1:a);if(!r&&s.startsWith("-"))return v("option","export",s,`export: option \`${s}\` is not supported`);if(!un.test(l)){i+=`export: \`${l}': not a valid identifier
318
+ `;continue}a!==-1?n.vars.set(l,(u?f0(l,n):"")+s.slice(a+1)):n.vars.has(l)&&n.vars.set(l,n.vars.get(l))}return{stdout:"",stderr:i,exitCode:i?1:0}}function IO(e,t,n){let r=t[0]==="-v"?1:0,o=t[r]==="--";o&&r++;let i=t.slice(r);for(let s of i){if(!o&&s.startsWith("-"))return v("option","unset",s,`unset: option \`${s}\` is not supported`);if(s.includes("["))return v("feature","unset","array subscript","unset: array subscripts are not supported");if(s==="LANG")return v("feature","unset","LANG",`unset: LANG: ${Xo}`);n.vars.delete(s)}return R()}function TO(e,t,n){let r=null;for(let o=0;o<t.length;o++){let i=t[o];if(i==="-e"||i==="+e")r=i==="-e";else if((i==="-o"||i==="+o")&&t[o+1]==="errexit")r=i==="-o",o++;else return dw()}return r===null?dw():(n.errexit=r,R())}var dw=()=>v("feature","set","set","set: `set` is supported only as `set -e` or `set +e`",127),Sl={exit:NO,break:fw("break"),continue:fw("continue"),export:OO,set:TO,unset:IO},hw=new Map([["return"," (there are no shell functions)"],["source"," (nothing can be sourced into this shell)"],[".","","`.` (source)"],"eval","exec",["read"," (there is no interactive input)"],["shift"," (there are no positional parameters)"],"shopt",["local"," (there are no shell functions)"],["declare","; use `NAME=value`"],["typeset","; use `NAME=value`"],["readonly","; use `NAME=value`"],["let"," (no arithmetic)"],["type","; use `which`"],["command","; run the command directly"],"builtin","hash","alias","unalias","trap",["wait"," (nothing runs in the background)"],["kill"," (there are no processes)"],["jobs"," (there are no processes)"],["bg"," (there are no processes)"],["fg"," (there are no processes)"],["disown"," (there are no processes)"],"suspend","times","ulimit","umask",["pushd","; use `cd`"],["popd","; use `cd -`"],"dirs","history","help","logout","getopts","mapfile","readarray","caller","enable","compgen","complete","bind","fc"].map(e=>{let[t,n="",r="`"+t+"`"]=Array.isArray(e)?e:[e];return[t,r+" is not supported"+n]}));function mw(e,t){let n=0,r=!0,o=!1;for(;n<t.length&&/^-[neE]+$/u.test(t[n]);n++)for(let s of t[n].slice(1))s==="n"?r=!1:o=s==="e";let i=t.slice(n).join(" ");if(o){let s=CO(i);i=s.text,s.stop&&(r=!1)}return R(r?i+`
319
+ `:i)}function CO(e){let t={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92},n=[],r=i=>{for(let s of T(i))n.push(s)},o=i=>({text:G(Uint8Array.from(n)),stop:i});for(let i=0;i<e.length;i++){if(e[i]!=="\\"||i+1>=e.length){let l=e.indexOf("\\",i+1),c=l<0?e.length:l;r(e.slice(i,c)),i=c-1;continue}let s=e[++i];if(s==="c")return o(!0);if(s in t){n.push(t[s]);continue}if(s==="0"){let l="";for(;l.length<3&&/[0-7]/u.test(e[i+1]??"");)l+=e[++i];n.push(l===""?0:parseInt(l,8)&255);continue}let a=s==="x"?2:s==="u"?4:s==="U"?8:0;if(a>0&&/[0-9a-fA-F]/u.test(e[i+1]??"")){let l="";for(;l.length<a&&/[0-9a-fA-F]/u.test(e[i+1]??"");)l+=e[++i];let c=parseInt(l,16);if(s==="x")n.push(c);else{if(!st(c))throw new x("feature","echo Unicode escape","echo: escapes outside Unicode scalar values are not supported");r(String.fromCodePoint(c))}continue}let u=i+ze(e,i);r("\\"+e.slice(i,u)),i=u-1}return o(!1)}var gw={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92};function Al(e,t,n,r){let o=e[t+1],i=t+2;if(o===void 0)return{bytes:[92],end:t+1};if(n&&o==="c")return{bytes:[],end:i,stop:!0};if(Object.hasOwn(gw,o))return{bytes:[gw[o]],end:i};if(!n&&`'"?`.includes(o))return{bytes:[o.codePointAt(0)],end:i};if(/[0-7]/u.test(o)){let a=n&&o==="0"?4:3;for(;i<t+1+a&&/[0-7]/u.test(e[i]??"");)i++;return{bytes:[parseInt(e.slice(t+1,i),8)&255],end:i}}let s=o==="x"?2:o==="u"?4:o==="U"?8:0;if(s){for(;i<t+2+s&&/[\da-fA-F]/u.test(e[i]??"");)i++;if(i===t+2||o!=="x"&&i!==t+2+s)return r.stderr+=`printf: missing hexadecimal number in escape
320
+ `,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let a=parseInt(e.slice(t+2,i),16);if(o==="x")return{bytes:[a],end:i};if(!st(a))throw new x("feature","Unicode escape","escapes outside Unicode scalar values are not supported");if(r.byteLocale&&a>127)throw new x("feature","Unicode escape in C locale","non-ASCII Unicode escapes in the C locale are not supported");return{bytes:T(String.fromCodePoint(a)),end:i}}return i=t+1+ze(e,t+1),{bytes:T(e.slice(t,i)),end:i}}function ww(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]==="\\"){let o=Al(e,r,!0,t);for(let i of o.bytes)n.push(i);if(r=o.end,o.stop){t.stop=!0;break}}else{let o=e.indexOf("\\",r),i=o<0?e.length:o;for(let s of T(e.slice(r,i)))n.push(s);r=i}return Uint8Array.from(n)}var LO=/^%([-+ #0']*)(\d+|\*)?(?:\.(-?\d+|\*)?)?([hlLjzt]*)(.)?/su,FO=8e6;function yw(e,t,n){let r=t[0]==="--"?t.slice(1):t;if(r.length===0)return xe("printf format [arguments]");if(t[0]!=="--"&&/^-./su.test(t[0])){let s=t[0].startsWith("-v")?"-v":t[0];return v("option","printf",s,`printf: option ${s} is not supported`,2)}let o={args:r.slice(1),index:0,chunks:[],size:0,stderr:"",failed:!1,stop:!1,byteLocale:ee(n)},i;try{if(r.some(s=>s.includes("\0")))throw new x("feature","NUL in argument","NUL bytes in command arguments are not supported");do{let s=o.index;if(MO(r[0],o),o.index===s)break}while(!o.stop&&o.index<o.args.length);i=R()}catch(s){i=Q(s,"printf",`printf: ${s.message}`)}try{i.stdout=RO(o)}catch(s){let a=C(i);a&&n.unsupported.add(a,"printf");let u=Q(s,"printf",`printf: ${s.message}`);u.stderr=i.stderr+u.stderr,i=u}return i.stderr=o.stderr+i.stderr,o.failed&&i.exitCode===0&&(i.exitCode=1),i}function En(e,t){if(e.size+t.length>FO)throw new x("feature","format size limit","formatted output exceeds the output limit");t.length&&e.chunks.push(t),e.size+=t.length}function RO(e){let t=new Uint8Array(e.size),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return G(t)}var Nl=e=>e.args[e.index++];function MO(e,t){for(let n=0;n<e.length&&!t.stop;)if(e[n]==="\\"){let r=Al(e,n,!1,t);En(t,r.bytes),n=r.end}else if(e[n]==="%"){if(e[n+1]==="%"){En(t,[37]),n+=2;continue}let r=DO(e.slice(n),t);n+=r.length;let o=Nl(t);if("sbc".includes(r.conv))UO(o??"",r,t);else{let i="diouxX".includes(r.conv)?Qi(Ji(o,"ouxX".includes(r.conv),t),r):P0(o,r,t);En(t,T(i))}}else{let r=n+1;for(;r<e.length&&e[r]!=="%"&&e[r]!=="\\";)r++;En(t,T(e.slice(n,r))),n=r}}function DO(e,t){if(/^%[-+ #0'\d.*]*\$/u.test(e))throw new x("feature","positional format arguments","positional format arguments are not supported");let n=LO.exec(e),[,r,o,i,s,a]=n;if(a===void 0)throw new Error("missing format character");if(!"sbcdiouxXeEfFgG".includes(a))throw"aAqQnCS(p%I".includes(a)?new x("feature","%"+a,`format %${a} is not supported`):new Error(`invalid format character: ${a}`);if(s&&"sbc".includes(a))throw new x("feature","format length modifier","length modifiers on string and character formats are not supported");let u={conv:a,length:n[0].length,minus:r.includes("-"),plus:r.includes("+"),space:r.includes(" "),zero:r.includes("0"),alt:r.includes("#"),width:Number(o==="*"?Ji(Nl(t),!1,t):o??0),precision:i==="*"?Number(Ji(Nl(t),!1,t)):i===void 0?n[0].includes(".")?0:null:Number(i)};if(o==="*"&&Math.abs(u.width)>2147483647||i==="*"&&(u.precision<-2147483648||u.precision>2147483647))throw new x("feature","format size limit","star width or precision outside the signed 32-bit range is not supported");if(u.width<0&&(u.minus=!0,u.width=-u.width),u.precision<0&&(u.precision=null),u.width>Me||u.precision>Me)throw new x("feature","format size limit","format width or precision exceeds the output limit");return u}function UO(e,t,n){let r=t.conv==="b"?ww(e,n):T(e);t.conv==="c"?r=r.length?r.subarray(0,1):new Uint8Array(1):t.precision!==null&&(r=r.subarray(0,t.precision));let o=Math.max(0,t.width-r.length),i=o?new Uint8Array(o).fill(32):[];t.minus||En(n,i),En(n,r),t.minus&&En(n,i)}function PO(e,t){if(!e.includes(`
321
+ `))return e;let n=ee(t);if(!n&&/[\u0080-\u009F\u2028\u2029]/u.test(e))throw new x("feature","filename quoting","wc: locale-sensitive filename quoting is not supported");let r=n?Array.from(T(e),a=>String.fromCodePoint(a)):[...e],o={7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r"},i=!1,s="'";for(let a of r){let u=a.codePointAt(0);u<32||u===127||n&&u>127?(i||(s+="'$'"),s+=o[u]??"\\"+u.toString(8).padStart(3,"0"),i=!0):(a==="'"?s+="'\\''":s+=(i?"''":"")+a,i=!1)}return s+"'"}function xw(e,t,n,r,o){let i=[];for(let s of["l","w","m","c"])n[s]&&i.push(String(e[s]).padStart(r));return i.join(" ")+(t?" "+PO(t,o):"")}var zO=["**=","**","++","--","+=","-=","*=","/=","%=","^=","==","!=","<=",">=","&&","||","!~",">>","|&","+","-","*","/","%","^","!",">","<","|","?",":","~","$","=","(",")","{","}","[","]",";",","],BO=new Set(["number","string","name","builtin"]),jO=new Set([")","]","++","--"]),WO=/^(?:0[xX][0-9a-fA-F]+|\d+\.?\d*(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/u,qO=e=>e!==void 0&&/[A-Za-z_]/u.test(e),HO=e=>e!==void 0&&/[A-Za-z0-9_]/u.test(e),bw=e=>e!==void 0&&e>="0"&&e<="9";function Ew(e,t=null){let n=[],r=1,o=0,i=(a,u)=>n.push({type:a,value:u,line:r}),s=()=>{let a=n.at(-1);return a?BO.has(a.type)?!1:!(a.type==="punct"&&jO.has(a.value)):!0};for(;o<e.length;){let a=e[o];if(a===`
322
+ `){n.at(-1)?.type!=="newline"&&i("newline",`
323
+ `),r++,o++;continue}if(a===" "||a===" "||a==="\r"){o++;continue}if(a==="\\"&&(e[o+1]===`
324
+ `||e[o+1]==="\r"&&e[o+2]===`
325
+ `)){o+=e[o+1]===`
326
+ `?2:3,r++;continue}if(a==="#"){for(;o<e.length&&e[o]!==`
327
+ `;)o++;continue}if(a==='"'){let c=$w(e,o+1,t,r);i("string",c.value),o=c.end;continue}if(a==="/"&&s()){let c=ZO(e,o+1,r);i("regex",c.value),o=c.end;continue}if(bw(a)||a==="."&&bw(e[o+1])){let c=GO(e,o);i("number",c.value),o=c.end;continue}if(qO(a)){let c=o+1;for(;HO(e[c]);)c++;let f=e.slice(o,c);if(e.slice(c,c+2)==="::")throw new A("namespaces are not supported",r,"namespaces");o=c,e1.has(f)?i("keyword",f==="func"?"function":f):t1.has(f)?i("builtin",f):i(e[c]==="("?"funcname":"name",f);continue}let u=o,l=zO.find(c=>e.startsWith(c,u));if(a==="@")throw new A("typed regexes, indirect calls and source directives are not supported",r,"@ extensions");if(!l)throw new A(`unexpected character \`${a}\``,r);i("punct",l),o+=l.length}return i("eof",""),n}function GO(e,t){let n=WO.exec(e.slice(t))[0],r=n;return/^0[xX]/u.test(n)?r=String(Number.parseInt(n.slice(2),16)):/^0[0-7]+$/u.test(n)&&(r=String(Number.parseInt(n,8))),{value:r,end:t+n.length}}var kw={__proto__:null,n:`
328
+ `,t:" ",r:"\r",a:"\x07",b:"\b",f:"\f",v:"\v",'"':'"',"\\":"\\"};function XO(e,t,n){let r=e[t+1];if(r===void 0)return{text:"\\",end:t+1};if(r in kw)return{text:kw[r],end:t+2};if(r>="0"&&r<="7"){let o=t+1;for(;o<t+4&&e[o]>="0"&&e[o]<="7";)o++;return{byte:Number.parseInt(e.slice(t+1,o),8)&255,end:o}}if(r==="x"&&/[0-9a-fA-F]/u.test(e[t+2]??"")){let o=t+2;for(;o<t+4&&/[0-9a-fA-F]/u.test(e[o]??"");)o++;return{byte:Number.parseInt(e.slice(t+2,o),16),end:o}}if(r.codePointAt(0)>127)throw new A("non-ASCII characters after an escape are not supported",null,"non-ASCII string escape");return n?.(`escape sequence \`\\${r}' treated as plain \`${r}'`),{text:r,end:t+2}}function $w(e,t,n,r=null){let o=[],i=t;for(;i<e.length;){let s=e[i];if(r!==null){if(s==='"')return{value:G(Uint8Array.from(o)),end:i+1};if(s===`
329
+ `)break;if(s==="\\"&&e[i+1]===`
330
+ `){i+=2;continue}}if(s==="\\"){let a=XO(e,i,n);vw(o,a),i=a.end}else{let a=String.fromCodePoint(e.codePointAt(i));vw(o,{text:a}),i+=a.length}}if(r!==null)throw new A("unterminated string",r);return{value:G(Uint8Array.from(o)),end:i}}function ZO(e,t,n){let r=t,o=!1;for(;r<e.length;){let i=e[r];if(i===`
331
+ `)break;if(i==="\\"){r+=2;continue}if(o){if(i==="["&&e[r+1]===":"){let s=e.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}i==="]"&&(o=!1),r++;continue}if(i==="["){o=!0,r++,e[r]==="^"&&r++,e[r]==="]"&&r++;continue}if(i==="/")return{value:e.slice(t,r),end:r+1};r++}throw new A("unterminated regexp",n)}function yo(e,t=null){return $w(e,0,t).value}function vw(e,t){if(t.byte===void 0)for(let n of T(t.text))e.push(n);else e.push(t.byte)}var YO=new Set(["=","+=","-=","*=","/=","%=","^=","**="]),Sw=new Set(["<","<=","==","!=",">",">="]),bo=e=>e.type==="var"||e.type==="index"||e.type==="field";function Aw(e){let t=e.tok;return Ow(e)||t.type==="regex"||t.type==="keyword"&&t.value==="getline"||t.type==="punct"&&["!","-","+"].includes(t.value)}function lr(e,t){let n=[Le(e,t)];for(;e.accept(",");)e.skipNewlines(),n.push(Le(e,t));return n}function Le(e,t){let n=VO(e,t),r=e.tok;if(r.type==="punct"&&YO.has(r.value)){bo(n)||e.fail(`cannot assign to ${n.type==="regex"?"a regex":"a non-variable"} (left side of \`${r.value}\`)`),e.next();let o=Le(e,t);return{type:"assign",op:r.value==="**="?"^=":r.value,target:n,value:o}}return n}function VO(e,t){let n=Ol(e,t);if(!e.accept("?"))return n;e.skipNewlines();let r=Le(e,t);return e.skipNewlines(),e.expect(":"),e.skipNewlines(),{type:"cond",test:n,consequent:r,alternate:Le(e,t)}}var KO=[["or",["||"]],["and",["&&"]],["in",["in"]],["match",["~","!~"]],["compare",[...Sw]],["concat",[]],["binary",["+","-"]],["binary",["*","/","%"]]],JO=new Map(KO.flatMap(([e,t],n)=>t.map(r=>[r,{type:e,precedence:n}]))),QO={type:"concat",precedence:5};function Ol(e,t,n=0){let r=gs(e,t),o=1/0;for(;;){let i=e.tok;n<=4&&o>4&&!t.noGt&&(e.is("|")||e.is("|&"))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${Ni}`,'"cmd" | getline');let s=Ow(e)?QO:i.type==="punct"||i.type==="keyword"&&i.value==="in"?JO.get(i.value):void 0;if(!s||s.precedence<n||s.precedence>o||t.noGt&&e.is(">"))return r;let{type:a,precedence:u}=s,l=a==="concat"?null:e.next().value;if(o=u,(a==="or"||a==="and")&&e.skipNewlines(),a==="in"){r={type:a,keys:[r],array:Nw(e)};continue}let c=Ol(e,t,u+1);(l==="/"||l==="%")&&xo(c)===0&&xo(r)!==null&&e.fail(l==="/"?"division by zero attempted":"division by zero attempted in `%`",null,"error"),a==="compare"&&eI(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),a==="binary"||a==="compare"?r={type:a,op:l,left:r,right:c}:a==="match"?r={type:a,negate:l==="!~",left:r,right:c}:r={type:a,left:r,right:c}}}function Nw(e){return e.tok.type!=="name"&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var eI=(e,t)=>e.tok.type==="punct"&&Sw.has(e.tok.value)&&!(t.noGt&&e.tok.value===">");function Ow(e){let t=e.tok;return t.type==="number"||t.type==="string"||t.type==="name"||t.type==="funcname"||t.type==="builtin"?!0:t.type==="punct"&&["$","(","++","--"].includes(t.value)}function Iw(e,t){return Ol(e,t,5)}function xo(e){if(e.type==="num")return e.value;if(e.type==="neg"||e.type==="plus"){let r=xo(e.expr);return r===null?null:e.type==="neg"?-r:r}if(e.type!=="binary")return null;let t=xo(e.left),n=xo(e.right);return t===null||n===null?null:Oi(e.op,t,n)}var tI={__proto__:null,"!":"not","-":"neg","+":"plus"};function gs(e,t,n=!1){if(n&&(e.is("$")||e.is("++")||e.is("--")))return ws(e,t);let r=e.tok.type==="punct"&&tI[e.tok.value];return r?(e.next(),{type:r,expr:gs(e,t,n)}):n?Cw(e,t):nI(e,t)}function nI(e,t){let n=Tw(e,t);return!e.is("^")&&!e.is("**")?n:(e.next(),{type:"binary",op:"^",left:n,right:gs(e,t)})}function Tw(e,t){let n=ws(e,t);for(;(e.is("++")||e.is("--"))&&bo(n);)n={type:"postinc",op:e.next().value,target:n};return n}function ws(e,t){if(e.accept("$"))return{type:"field",index:gs(e,t,!0)};if(e.is("++")||e.is("--")){let n=e.next().value,r=ws(e,t);return bo(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:"preinc",op:n,target:r}}return Cw(e,t)}function Cw(e,t){let n=e.tok;switch(n.type){case"number":return e.next(),{type:"num",value:Number(n.value)};case"string":return e.next(),{type:"str",value:n.value};case"regex":return e.next(),{type:"regex",source:n.value,re:rI(e,n.value)};case"name":return oI(e);case"funcname":return iI(e);case"builtin":return aI(e);case"keyword":return n.value==="getline"?uI(e,t):e.unexpected();case"punct":return n.value==="("?sI(e):e.unexpected();default:return e.unexpected()}}function rI(e,t){try{return qe(t,!1,n=>e.warn(n))}catch(n){return e.fail(n.message,n.gap??null)}}function Il(e){if(!e.accept("["))return null;let t=lr(e,{});return e.expect("]"),e.is("[")&&e.fail("arrays of arrays are not supported","arrays of arrays"),t}function oI(e){let t=e.next().value,n=Il(e);return n!==null?{type:"index",name:t,subs:n}:(e.is("(")&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:"var",name:t})}function iI(e){return{type:"call",name:e.next().value,args:_w(e)}}function _w(e){e.expect("(");let t=e.is(")")?[]:lr(e,{});return e.expect(")"),t}function sI(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=lr(e,{});if(e.expect(")"),n.length===1){for(;t-- >0;)e.expect(")");return n[0]}return e.isKw("in")||e.fail("a parenthesized list must be followed by `in ARRAY`"),e.next(),{type:"in",keys:n,array:Nw(e)}}function aI(e){let t=e.next().value;if(Ai.has(t)&&e.fail(Ai.get(t),`${t}()`),!e.is("(")){if(t==="length")return{type:"builtin",name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=_w(e),[r,o]=uu[t];return(n.length<r||n.length>o)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?"":"s"}; it takes ${r===o?r:`${r} to ${o===1/0?"any number":o}`}`),(t==="sub"||t==="gsub")&&n[2]&&!bo(n[2])&&e.fail(`${t}(): substitution into a temporary value is not supported`,"substitution into temporary value"),t==="split"&&n[1].type!=="var"&&e.fail("split(): second argument must be an array name"),t==="match"&&n[2]&&n[2].type!=="var"&&e.fail("match(): third argument must be an array name"),{type:"builtin",name:t,args:n}}function uI(e,t){e.next();let n=null;(e.tok.type==="name"||e.is("$"))&&(n=ws(e,t),bo(n)||e.fail("getline: target must be a variable, field or array element"));let r=null;return e.accept("<")&&(r=Tw(e,t)),{type:"getline",target:n,file:r}}var lI=new Set(["/dev/stdout","/dev/stderr","/dev/null"]),Tl=class{constructor(t,n){this.toks=t,this.i=0,this.warnings=n,this.funcs=new Set,this.parens=new Map;let r=[];for(let o=0;o+1<t.length;o++){let i=t[o],s=t[o+1];i.type==="punct"&&(i.value==="("?r.push(o):i.value===")"&&r.length>0&&this.parens.set(r.pop(),o)),i.type==="keyword"&&i.value==="function"&&(s.type==="name"||s.type==="funcname")&&this.funcs.add(s.value)}this.loopDepth=0,this.switchDepth=0,this.context="main"}get tok(){return this.toks[this.i]}peek(t){return this.toks[Math.min(this.i+t,this.toks.length-1)]}is(t,n="punct"){return this.tok.type===n&&this.tok.value===t}isKw(t){return this.is(t,"keyword")}next(){return this.toks[this.i++]}accept(t,n="punct"){return this.is(t,n)?this.next():null}expect(t,n="punct"){return this.is(t,n)||this.fail(`expected \`${t}\` but found ${$n(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type==="newline";)this.i++}skipTerminators(){for(;this.tok.type==="newline"||this.is(";");)this.i++}fail(t,n=null,r="syntax error"){throw new A(t,this.tok.line,n,r)}warn(t){this.warnings.push(t)}unexpected(){this.fail(`unexpected ${$n(this.tok)}`)}};function $n(e){return e.type==="eof"?"end of program":e.type==="newline"?"newline":e.type==="string"?`string "${e.value}"`:e.type==="regex"?`regex /${e.value}/`:`\`${e.value}\``}var Lw={__proto__:null,BEGIN:"begin",END:"end",BEGINFILE:"beginFile",ENDFILE:"endFile"};function Mw(e){let t=[],n=new Tl(Ew(e,o=>t.push(o)),t),r={begin:[],end:[],beginFile:[],endFile:[],rules:[],functions:new Map,warnings:t};for(n.skipNewlines();n.tok.type!=="eof";)n.is(";")&&n.fail("each rule must have a pattern or an action part"),cI(n,r),n.accept(";"),n.skipNewlines();return r}function cI(e,t){if(e.isKw("function")){fI(e,t);return}if(e.tok.type==="keyword"&&e.tok.value in Lw){let i=e.next().value;e.is("{")||e.fail(`${i} requires an action: ${i} { ... }`),t[Lw[i]].push(...ko(e,i.toLowerCase()));return}if(e.is("{")){t.rules.push({pattern:null,action:ko(e,"main")});return}let n=Le(e,{}),r=n;e.accept(",")&&(e.skipNewlines(),r={type:"range",from:n,to:Le(e,{})});let o=e.is("{")?ko(e,"main"):null;o===null&&!(e.tok.type==="newline"||e.tok.type==="eof"||e.is(";"))&&e.unexpected(),t.rules.push({pattern:r,action:o})}function fI(e,t){e.next();let n=e.tok;n.type==="builtin"&&e.fail(`cannot redefine builtin function \`${n.value}\``),n.type!=="name"&&n.type!=="funcname"&&e.fail(`expected a function name but found ${$n(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect("(");let o=[];for(;!e.is(")");){let i=e.tok;if(i.type!=="name"&&e.fail(`expected a parameter name but found ${$n(i)}`),(i.value===r||o.includes(i.value))&&e.fail(`duplicate parameter \`${i.value}\` in function \`${r}\``),o.push(e.next().value),!e.accept(","))break;e.skipNewlines()}e.expect(")"),e.skipNewlines(),t.functions.set(r,{params:o,body:ko(e,"function")})}function ko(e,t=e.context){let n=e.context;e.context=t,e.expect("{");let r=[];for(e.skipTerminators();!e.is("}");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),r.push(Cl(e)),e.skipTerminators();return e.next(),e.context=n,r}function vo(e){if(e.is(";")||e.tok.type==="newline"){e.next();return}e.is("}")||e.tok.type==="eof"||e.unexpected()}var dI={__proto__:null,if:pI,while:hI,do:mI,for:gI,switch:wI,break:e=>cr(e,"break"),continue:e=>cr(e,"continue"),next:e=>cr(e,"next"),nextfile:e=>cr(e,"nextfile"),exit:e=>cr(e,"exit"),return:e=>cr(e,"return"),delete:xI,print:e=>Rw(e,"print"),printf:e=>Rw(e,"printf")};function Cl(e){if(e.is("{"))return{type:"block",body:ko(e)};if(e.is(";"))return e.next(),{type:"empty"};let t=e.tok.type==="keyword"?dI[e.tok.value]:void 0;if(t)return t(e);let n=Le(e,{});return vo(e),{type:"expr",expr:n}}function fr(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=Cl(e);return t&&e.loopDepth--,n}function ys(e){e.next(),e.expect("(");let t=Le(e,{});return e.expect(")"),t}function pI(e){let t=ys(e),n=fr(e,!1),r=e.i;return e.skipNewlines(),e.isKw("else")?(e.next(),{type:"if",test:t,consequent:n,alternate:fr(e,!1)}):(e.i=r,{type:"if",test:t,consequent:n,alternate:null})}function hI(e){return{type:"while",test:ys(e),body:fr(e,!0)}}function mI(e){e.next();let t=fr(e,!0);e.skipTerminators(),e.isKw("while")||e.fail("`do` body must be followed by `while (...)`");let n=ys(e);return vo(e),{type:"do",body:t,test:n}}function gI(e){if(e.next(),e.expect("("),e.tok.type==="name"&&e.peek(1).type==="keyword"&&e.peek(1).value==="in"&&e.peek(2).type==="name"&&e.peek(3).value===")"){let o=e.next().value;e.next();let i=e.next().value;return e.next(),{type:"forin",name:o,array:i,body:fr(e,!0)}}let t=e.is(";")?null:Le(e,{});e.expect(";"),e.skipNewlines();let n=e.is(";")?null:Le(e,{});e.expect(";"),e.skipNewlines();let r=e.is(")")?null:Le(e,{});return e.expect(")"),{type:"for",init:t,test:n,step:r,body:fr(e,!0)}}function wI(e){let t=ys(e);e.skipNewlines(),e.expect("{");let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is("}");e.skipTerminators()){let o=null;e.accept("case","keyword")?o=yI(e):e.accept("default","keyword")||e.fail(`expected \`case\` or \`default\` in switch body but found ${$n(e.tok)}`);let i=o===null?"default":o.type==="regex"?`/${o.source}/`:String(o.value);r.has(i)&&e.fail(`duplicate case values in switch body: ${i}`),r.add(i),e.expect(":");let s=[];for(e.skipTerminators();!e.is("}")&&!e.isKw("case")&&!e.isKw("default");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),s.push(Cl(e)),e.skipTerminators();n.push({test:o,body:s})}return e.switchDepth--,e.next(),{type:"switch",expr:t,cases:n}}function yI(e){let t=e.accept("-")?-1:(e.accept("+"),1),n=e.tok;return n.type==="number"?(e.next(),{type:"num",value:t*Number(n.value)}):t===1&&n.type==="string"?(e.next(),{type:"str",value:n.value}):t===1&&n.type==="regex"?(e.next(),{type:"regex",source:n.value,re:qe(n.value,!1,r=>e.warn(r))}):e.fail(`case value must be a number, string or regex constant, found ${$n(n)}`)}function cr(e,t){t==="break"&&e.loopDepth===0&&e.switchDepth===0&&e.fail("`break` is not allowed outside a loop or switch"),t==="continue"&&e.loopDepth===0&&e.fail("`continue` is not allowed outside a loop"),t==="next"&&e.context!=="main"&&e.context!=="function"&&e.fail(`\`next\` cannot be used in a ${e.context.toUpperCase()} action`),t==="nextfile"&&(e.context==="begin"||e.context==="end"||e.context==="endfile")&&e.fail(`\`nextfile\` cannot be used in a ${e.context.toUpperCase()} action`),t==="return"&&e.context!=="function"&&e.fail("`return` is only allowed inside a function"),e.next();let n={type:t};return(t==="exit"||t==="return")&&(n.value=Aw(e)?Le(e,{}):null),vo(e),n}function xI(e){e.next(),e.tok.type!=="name"&&e.fail(`\`delete\` needs an array name but found ${$n(e.tok)}`);let t=e.next().value,n=Il(e);return vo(e),{type:"delete",name:t,subs:n}}var Fw=e=>e.is(";")||e.is("}")||e.is(">")||e.is(">>")||e.is("|")||e.is("|&")||e.tok.type==="newline"||e.tok.type==="eof";function Rw(e,t){e.next();let n=null;if(e.is("(")){let o=e.i;e.next();let i=e.is(")")?[]:lr(e,{});e.accept(")")&&Fw(e)?n=i:e.i=o}n===null&&(n=Fw(e)?[]:lr(e,{noGt:!0})),t==="printf"&&n.length===0&&e.fail("printf needs a format string");let r=null;return(e.is("|")||e.is("|&"))&&e.fail(`output pipes (\`${t} ... | "cmd"\`) are not supported: ${Ni}`,`${t} | "cmd"`),(e.accept(">")||e.accept(">>"))&&(r=Iw(e,{noGt:!0}),r.type==="str"&&!lI.has(r.value)&&e.fail(_l(r.value),`${t} > FILE`)),vo(e),{type:t,args:n,dest:r}}function _l(e){return`cannot redirect output to \`${e}\`: the filesystem is read-only (only /dev/stdout, /dev/stderr and /dev/null). To print a comparison, parenthesize it: print (a > b)`}var Y=class{constructor(t){this.s=t,this.number=void 0,this.numeric=void 0}},Eo="[ \\t\\n\\r\\f\\v]*",Pw="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",bI=new RegExp(`^${Eo}${Pw}${Eo}$`,"u"),kI=new RegExp(`^${Eo}(${Pw})`,"u"),zw=new RegExp(`^${Eo}([+-])(inf|nan)${Eo}$`,"iu"),Ll=e=>bI.test(e)||zw.test(e);function Dw(e){let t=kI.exec(e);if(t)return Number(t[1]);let n=zw.exec(e);return n?n[2].toLowerCase()==="nan"?Number.NaN:n[1]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:0}var Fl=()=>new A("attempt to use an array in a scalar context");function Z(e){if(typeof e=="number")return e;if(e===void 0)return 0;if(e instanceof Y)return e.number??=Dw(e.s);if(typeof e=="string")return Dw(e);throw Fl()}var xs=new Map;function Bw(e,t){if(Number.isNaN(e))throw new A("formatting signed NaN is not supported",null,"signed NaN");if(!Number.isFinite(e))return e<0?"-inf":"+inf";if(Number.isInteger(e))return Math.abs(e)<2**53?String(e):BigInt(e).toString();let n=xs.get(t);if(n===void 0){xs.size>64&&xs.clear(),n=Ki(t);let r=n.filter(o=>typeof o!="string");if(r.length>1||r.some(o=>!"diouxXeEfFgG".includes(o.conv)||o.width==="*"||o.precision==="*"))throw new A("this numeric conversion format is not supported",null,"numeric conversion format");xs.set(t,n)}return n.map(r=>typeof r=="string"?r:vn(e,r)).join("")}var jw=e=>typeof e=="string"?e:e instanceof Y?e.s:"%.6g",vI=e=>jw(e.globals.get("CONVFMT")),EI=e=>jw(e.globals.get("OFMT"));function M(e,t){if(typeof e=="string")return It(t,e);if(e instanceof Y)return It(t,e.s);if(typeof e=="number")return Bw(e,vI(t));if(e===void 0)return"";throw Fl()}function It(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new A("non-ASCII AWK text in a byte locale is not supported",null,"byte locale text");return t}function Sn(e,t=!1){return[...e].map(n=>{let r=t?n.toUpperCase():n.toLowerCase();if([...r].length!==1)throw new A("Unicode case expansion is not supported",null,"Unicode case mapping");return r}).join("")}function Ww(e,t){return typeof e=="number"?Bw(e,EI(t)):M(e,t)}var Rl=e=>e.numeric??=Ll(e.s),Uw=e=>typeof e=="number"||e===void 0||e instanceof Y&&Rl(e),Qe=e=>Fe(e.globals.get("IGNORECASE"));function bs(e,t,n){if(Uw(e)&&Uw(t)){let i=Z(e),s=Z(t);return i<s?-1:i>s?1:i===s?0:Number.NaN}let r=M(e,n),o=M(t,n);return Qe(n)&&(r=Sn(r),o=Sn(o)),q(r,o)}function Fe(e){if(typeof e=="number")return e!==0&&!Number.isNaN(e);if(typeof e=="string")return e!=="";if(e instanceof Y)return Rl(e)?Z(e)!==0:e.s!=="";if(e===void 0)return!1;throw Fl()}var Ml=(e,t)=>Number.isSafeInteger(e)?String(e):M(e,t);function Dl(e){return e instanceof Map?"array":e===void 0?"untyped":typeof e=="number"?"number":e instanceof Y&&Rl(e)?"strnum":"string"}function qw(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t==="")return $I(e);let o,i;if(t.length===1){let a=r.indexOf(t,e.pos);i=a===-1?r.length:a,o=a===-1?r.length:a+1}else{let a=pu(r,qe(t,n),e.pos);i=a?.start??r.length,o=a?.end??r.length}let s=r.slice(e.pos,i);return e.pos=o,{rec:s,rt:r.slice(i,o)}}function $I(e){let{text:t}=e,n=e.pos;for(;t[n]===`
332
+ `;)n++;if(n>=t.length)return e.pos=n,null;let r=/\n\n+/gu;r.lastIndex=n;let o=r.exec(t);if(!o){e.pos=t.length;let i=t.slice(n).replace(/\n+$/u,"");return{rec:i,rt:t.slice(n+i.length)}}return e.pos=o.index+o[0].length,{rec:t.slice(n,o.index),rt:o[0]}}function zl(e,t,n,r){if(e==="")return[];if(t instanceof Ot)return hu(e,t);if(t===" "){let i=e.replace(/^[ \t\n]+|[ \t\n]+$/gu,"");return i===""?[]:i.split(/[ \t\n]+/u)}if(t==="")return[...e];if(t.length===1&&(!n||t===`
333
+ `))return e.split(t);if(n&&t==="^")throw new A('paragraph splitting with FS="^" is not supported',null,"paragraph FS caret");let o=t.length===1?`[${"^$.[]|()*+?{}\\".includes(t)?"\\"+t:t}
334
+ ]`:t;return hu(e,qe(o,r))}function Hw(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let o=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),i=o?.[1]===void 0?0:Number(o[1]),s=o?.[2]==="*"?4294967295:Number(o?.[2]);if(!o||o[1]!==void 0&&i===0||i>4294967295||!(s>0&&s<=4294967295)||o[2]==="*"&&r!==t.length-1)throw new A(`invalid FIELDWIDTHS value \`${e}'`);return{skip:i,width:s}})}function SI(e,t){let n=[...e],r=[],o=0;for(let{skip:i,width:s}of t){if(o>=n.length)break;o+=i,r.push(n.slice(o,o+s).join("")),o+=s}return r}function AI(e,t){let n=[],r=0;for(;r<e.length;){let o=t.search(e.slice(r));if(n.length>0&&o?.end===0&&(r+=ze(e,r),o=t.search(e.slice(r))),!o)break;n.push(e.slice(r+o.start,r+o.end)),r+=o.end}return n}function Gw(e,t){let n=Qe(e);return e.fieldMode==="FIELDWIDTHS"?SI(t,e.widths):e.fieldMode==="FPAT"?AI(t,qe(M(e.globals.get("FPAT"),e),n,e.warn)):zl(t,M(e.globals.get("FS"),e),M(e.globals.get("RS"),e)==="",n)}var NI=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,Pl=e=>e!==void 0&&e.type==="exit",ks=class{constructor(t,n){this.ctx=t,this.stdin=n,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(t){for(;this.exitSignal===void 0;){if(this.src){let n=qw(this.src,M(t.globals.get("RS"),t),Qe(t));if(n!==null)return t.globals.set("NR",Z(t.globals.get("NR"))+1),t.globals.set("FNR",Z(t.globals.get("FNR"))+1),t.globals.set("RT",n.rt),n.rec;this.closeFile(t);continue}if(!this.open(t))return null}return null}open(t){for(;this.idx<Math.trunc(Z(t.globals.get("ARGC")));){if(++t.steps>Vr)throw new A("input operand scan exceeded execution limit",null,"execution limit");let n=M(t.globals.get("ARGV").get(String(this.idx++)),t);if(n==="")continue;t.globals.set("ARGIND",this.idx-1);let r=NI.exec(n);if(r){t.assign(r[1],new Y(yo(r[2],t.warn)));continue}this.sawFile=!0;let{text:o,error:i}=this.readOperand(n);if(i==="Is a directory"){this.failFile(t,n,i),this.exitSignal===void 0&&t.warn(`command line argument \`${n}' is a directory: skipped`);continue}if(i){let s=this.failFile(t,n,i);if(s!==void 0&&s.type==="nextfile")continue;if(this.exitSignal!==void 0)return!1;throw new A(`${n}: ${i}`)}if(this.use(t,n,o))return!0}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(t,"-",this.takeStdin()))}readOperand(t){if(t==="/dev/null")return{text:""};if(t==="-"||t==="/dev/stdin")return{text:t==="/dev/stdin"&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:n,error:r}=D(this.ctx,"awk",t);return this.ctx.fs.isDir(n)?{error:"Is a directory"}:r?{error:r}:{text:this.ctx.fs.readFile(n)}}takeStdin(){let t=this.stdin;return this.stdin="",z(this.ctx),t}use(t,n,r){this.src={text:r,pos:0},t.globals.set("FILENAME",n),t.globals.set("FNR",0),t.globals.set("ERRNO","");let o=t.fileRule("begin");return Pl(o)?(this.exitSignal=o,this.src=null,!1):o!==void 0&&o.type==="nextfile"?(this.closeFile(t),!1):(It(t,r),!0)}failFile(t,n,r){if(t.globals.set("ERRNO",r),!t.hasFileRules)return;t.globals.set("FILENAME",n),t.globals.set("FNR",0);let o=t.fileRule("begin");return Pl(o)&&(this.exitSignal=o),o}closeFile(t){this.src=null;let n=t.fileRule("end");Pl(n)&&(this.exitSignal=n)}readNamed(t,n){let r=this.readers.get(n);if(!r){let{text:i,error:s}=this.readOperand(n);if(s)return t.globals.set("ERRNO",s),{status:-1};r={text:It(t,i),pos:0},this.readers.set(n,r)}let o=qw(r,M(t.globals.get("RS"),t),Qe(t));return o===null?{status:0}:(t.globals.set("RT",o.rt),{status:1,record:o.rec})}close(t,n){return this.readers.delete(n)?0:(t.globals.set("ERRNO","close of redirection that was never opened"),-1)}};var OI=(e,t)=>({isRef:!0,scope:e,name:t}),$o=e=>typeof e=="object"&&e!==null&&e.isRef===!0,So=class extends Error{constructor(t){super(t.type),this.signal=t}},Yw=e=>new A(`attempt to use array \`${e}\` in a scalar context`);function vs(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function II(e){let t=e;for(;$o(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function dr(e,t){let n=vs(e,t).get(t);return $o(n)?II(n):n}var TI=new Set(["FS","FIELDWIDTHS","FPAT"]);function Es(e,t,n){let r=vs(e,t);if(r.get(t)instanceof Map)throw Yw(t);if(r===e.globals){if(t==="NF"){_I(e,n);return}if(t==="FIELDWIDTHS"&&(e.widths=Hw(M(n,e))),(t==="FPAT"||(t==="FS"||t==="RS")&&M(n,e).length>1)&&qe(M(n,e),Qe(e),e.warn,e.tables),TI.has(t)){e.fieldMode=t;let o=e.globals.get("PROCINFO");o instanceof Map&&o.set("FS",t)}}r.set(t,n)}function Tt(e,t){let n=vs(e,t),r=t,o=n,i=o.get(r);if(i instanceof Map)return i;let s=$o(i);for(;$o(i);)o=i.scope,r=i.name,i=o.get(r);if(!(i instanceof Map)){if(i!==void 0)throw new A(`attempt to use scalar \`${r}\` as an array`);i=new Map,o.set(r,i)}return s&&n.set(t,i),i}function $s(e,t,n=new Y(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...Gw(e,t).map(r=>new Y(r))],e.nf=e.fields.length-1,e.globals.set("NF",e.nf)}function Vw(e){let t=M(e.globals.get("OFS"),e);e.record=e.fields.slice(1).map(n=>M(n,e)).join(t),e.recordValue=e.record}function Kw(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function CI(e,t,n){if(t===0){let r=M(n,e);$s(e,r,typeof n=="number"?r:n);return}for(;e.nf<t;)e.fields[++e.nf]="";e.fields[t]=n,e.globals.set("NF",e.nf),Vw(e)}function _I(e,t){let n=Math.trunc(Z(t));if(n<0)throw new A(`NF set to negative value ${n}`);for(;e.nf<n;)e.fields[++e.nf]="";e.fields.length=n+1,e.nf=n,e.globals.set("NF",n),Vw(e)}function Jw(e,t){let n=Z(L(e,t));if(!(n>=0))throw new A(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function Ao(e,t){if(t.length===1)return Ml(L(e,t[0]),e);let n=M(e.globals.get("SUBSEP"),e);return t.map(r=>Ml(L(e,r),e)).join(n)}function Bl(e,t){return t.type==="var"?t:t.type==="index"?{type:"index",arr:Tt(e,t.name),key:Ao(e,t.subs)}:{type:"field",i:Jw(e,t.index)}}function Qw(e,t){return t.type==="var"?ey(dr(e,t.name),t.name):t.type==="index"?t.arr.get(t.key):Kw(e,t.i)}function jl(e,t,n){t.type==="var"?Es(e,t.name,n):t.type==="index"?t.arr.set(t.key,n):CI(e,t.i,n)}function Wl(e,t,n){jl(e,Bl(e,t),n)}function Xw(e,t,n){if(n===0&&(e==="/"||e==="%"))throw new A(e==="/"?"division by zero attempted":"division by zero attempted in `%`");return Oi(e,t,n)}var LI={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function Ct(e,t){let n=Qe(e);return t.type==="regex"?n?qe(t.source,!0,null,e.tables):t.re:qe(M(L(e,t),e),n,e.warn,e.tables)}function ey(e,t){if(e instanceof Map)throw Yw(t);return e}function Zw(e,t,n){let r=Bl(e,t.target),o=Z(Qw(e,r)),i=t.op==="++"?o+1:o-1;return jl(e,r,i),n?o:i}function L(e,t){switch(t.type){case"num":case"str":return t.value;case"regex":return Ct(e,t).test(e.record)?1:0;case"var":return ey(dr(e,t.name),t.name);case"index":{let n=Tt(e,t.name),r=Ao(e,t.subs),o=n.get(r);return o===void 0&&n.set(r,void 0),o}case"field":return Kw(e,Jw(e,t.index));case"assign":{let n=Bl(e,t.target),r=L(e,t.value);if(r instanceof Map)throw new A("attempt to use an array in a scalar context");return t.op!=="="&&(r=Xw(t.op[0],Z(Qw(e,n)),Z(r))),jl(e,n,r),r}case"cond":return L(e,Fe(L(e,t.test))?t.consequent:t.alternate);case"or":return Fe(L(e,t.left))||Fe(L(e,t.right))?1:0;case"and":return Fe(L(e,t.left))&&Fe(L(e,t.right))?1:0;case"not":return Fe(L(e,t.expr))?0:1;case"neg":return-Z(L(e,t.expr));case"plus":return Z(L(e,t.expr));case"binary":return Xw(t.op,Z(L(e,t.left)),Z(L(e,t.right)));case"concat":return M(L(e,t.left),e)+M(L(e,t.right),e);case"compare":return LI[t.op](bs(L(e,t.left),L(e,t.right),e))?1:0;case"match":{let n=M(L(e,t.left),e);return Ct(e,t.right).test(n)===t.negate?0:1}case"in":return Tt(e,t.array).has(Ao(e,t.keys))?1:0;case"preinc":return Zw(e,t,!1);case"postinc":return Zw(e,t,!0);case"call":return FI(e,t);case"builtin":return e.callBuiltin(e,t);case"getline":return MI(e,t);default:throw new A(`unknown expression: ${t.type}`)}}function FI(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new A(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new A(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=lu)throw new A(`function call nesting deeper than ${lu} levels (runaway recursion?)`,null,"call depth limit");let r=e.frame,o=new Map;for(let i=0;i<n.params.length;i++)o.set(n.params[i],i<t.args.length?RI(e,t.args[i]):void 0);e.frame=o,e.callDepth++;try{let i=e.execStmts(e,n.body);if(i===void 0||i.type==="return")return i?.value;throw new So(i)}finally{e.frame=r,e.callDepth--}}function RI(e,t){if(t.type!=="var")return L(e,t);let n=vs(e,t.name),r=n.get(t.name);return r instanceof Map||$o(r)?r:r===void 0?OI(n,t.name):r}function MI(e,t){let n;if(t.file===null){if(n=e.input.next(e),n===null)return 0}else{let r=e.input.readNamed(e,M(L(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?$s(e,n):Wl(e,t.target,new Y(n)),1}var mt=(e,t)=>Z(L(e,t)),ql=2**32;function ny(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var ry=()=>({seed:1,state:ny(1)});function DI(e){e.rng.state=(e.rng.state+1831565813)%ql;let t=e.rng.state;t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61);let n=t^t>>>14;return(n<0?n+ql:n)/ql}function UI(e,t){let n=e.rng.seed,r=t.length>0?mt(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=ny(r),n}function PI(e,t){let n=mt(e,t[0]);return n<0&&e.warn(`log: received negative argument ${M(n,e)}`),Math.log(n)}function zI(e,t){let n=mt(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${M(n,e)}`),Math.sqrt(n)}function BI(e,t){let n=mt(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${M(n,e)} is out of range`),r}function jI(e,t){let n=L(e,t[0]);if(typeof n=="number")return n;let r=n instanceof Y?n.s:M(n,e),o=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(o)return o[1]===""?0:Number.parseInt(o[1],16);let i=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return i?Number.parseInt(i[0],8):Z(new Y(r))}function No(e,t,n,r){let o=mt(e,n);if(o<0)throw new A(`${t}: argument ${r} negative value ${M(o,e)} is not allowed`);if(!Number.isFinite(o))throw new A(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(o)))}function Gl(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function Hl(e,t){return(n,r)=>{if(r.length<2)throw new A(`${e}: called with less than two arguments`);let o=No(n,e,r[0],1);for(let i=1;i<r.length;i++)o=t(o,No(n,e,r[i],i+1));return Gl(o)}}function ty(e,t){return(n,r)=>{let o=No(n,e,r[0],1),i=No(n,e,r[1],2)%64n;return Gl(BigInt.asUintN(64,t?o<<i:o>>i))}}var oy={__proto__:null,sin:(e,t)=>Math.sin(mt(e,t[0])),cos:(e,t)=>Math.cos(mt(e,t[0])),atan2:(e,t)=>Math.atan2(mt(e,t[0]),mt(e,t[1])),exp:BI,log:PI,sqrt:zI,int:(e,t)=>Math.trunc(mt(e,t[0])),rand:DI,srand:UI,systime:()=>Math.floor(Date.now()/1e3),strtonum:jI,and:Hl("and",(e,t)=>e&t),or:Hl("or",(e,t)=>e|t),xor:Hl("xor",(e,t)=>e^t),lshift:ty("lshift",!0),rshift:ty("rshift",!1),compl:(e,t)=>Gl(BigInt.asUintN(64,~No(e,"compl",t[0],1)))};var Ss=new Map;function WI(e){let t=Ss.get(e);return t||(Ss.size>=256&&Ss.clear(),t=Ki(e),Ss.set(e,t)),t}function As(e,t,n){let r=0,o=()=>{if(r>=n.length)throw new A("printf: not enough arguments to satisfy format string");return n[r++]},i="";for(let s of WI(t)){if(typeof s=="string"){i+=s;continue}let a={...s};if(s.width==="*"){let u=Math.trunc(Z(o()));u<0?(a.minus=!0,a.width=-u):a.width=u}if(s.precision==="*"){let u=Math.trunc(Z(o()));a.precision=u<0?null:u}if(a.width>Me||a.precision>Me)throw new A(`printf: field width or precision above ${Me} is not supported`,null,"format size limit");i+=qI(e,a,o())}return i}function qI(e,t,n){if(t.conv==="s"){let r=M(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join("")),Vt("",r,t,!1)}return t.conv==="c"?Vt("",It(e,HI(n)),t,!1):vn(Z(n),t)}function HI(e){if(typeof e=="number"||e instanceof Y&&Ll(e.s)){let r=Math.trunc(Z(e));if(!st(r))throw new A("printf: character code outside Unicode scalar values is not supported",null,"character code");return String.fromCodePoint(r)}let n=e instanceof Y?e.s:e??"";return n===""?"\0":String.fromCodePoint(n.codePointAt(0))}var Ae=(e,t)=>M(L(e,t),e),iy=(e,t)=>Z(L(e,t)),GI={type:"field",index:{type:"num",value:0}};function XI(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"){if(e[r+1]==="\\"&&e[r+2]==="\\"&&(e[r+3]==="&"||e[r+3]==="\\")){n+="\\"+e[r+3],r+=3;continue}if(e[r+1]==="\\"&&e[r+2]==="&"){n+="\\"+t,r+=2;continue}if(e[r+1]==="&"){n+="&",r++;continue}}n+=o==="&"?t:o}return n}function sy(e,t,n){let r=Ct(e,t[0]),o=Ae(e,t[1]),i=t[2]??GI,s=Ae(e,i),{out:a,count:u}=Kr(s,r,(l,c)=>XI(o,s.slice(l,c)),n?"global":"first");return u>0&&Wl(e,i,a),u}function ZI(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"&&r+1===e.length)throw new A("gensub with a trailing replacement backslash is not supported",null,"gensub trailing backslash");if(o==="\\"&&r+1<e.length){let i=e[++r];i>="0"&&i<="9"?n+=t[Number(i)]?.text??"":n+=i;continue}n+=o==="&"?t[0].text:o}return n}function YI(e,t){let n=Ct(e,t[0]),r=Ae(e,t[1]),o=L(e,t[2]),i=M(o,e),s=i.startsWith("g")||i.startsWith("G"),a=0;s||(a=Math.trunc(Z(o)),a<1&&(e.warn(`gensub: third argument \`${i}' treated as 1`),a=1));let u=t[3]?Ae(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return Kr(u,n,(c,f,d)=>!s&&d!==a?null:ZI(r,l?n.groups(u,c,f):[{text:u.slice(c,f)}]),s?"global":"nth").out}function VI(e,t){let n=Ae(e,t[0]),r=Ct(e,t[1]),o=r.search(n,0),i=o?Array.from(n.slice(0,o.start)).length+1:0;if(e.globals.set("RSTART",i),e.globals.set("RLENGTH",o?Array.from(n.slice(o.start,o.end)).length:-1),t[2]){let s=Tt(e,t[2].name);if(s.clear(),o){let a=M(e.globals.get("SUBSEP"),e);r.groups(n,o.start,o.end).forEach((u,l)=>{u!==void 0&&(s.set(String(l),new Y(u.text)),s.set(`${l}${a}start`,Array.from(n.slice(0,u.start)).length+1),s.set(`${l}${a}length`,[...u.text].length))})}}return i}function KI(e,t){let n=Ae(e,t[0]),r=Tt(e,t[1].name),o;t[2]===void 0?o=M(e.globals.get("FS"),e):t[2].type==="regex"?o=Ct(e,t[2]):o=Ae(e,t[2]);let i=zl(n,o,!1,Qe(e));return r.clear(),i.forEach((s,a)=>r.set(String(a+1),new Y(s))),i.length}function JI(e,t){let n=[...Ae(e,t[0])],r=Math.trunc(iy(e,t[1])),o=Number.isNaN(r)?1:Math.max(r,1),i=n.length+1;if(t[2]){let s=Math.trunc(iy(e,t[2]));if(!(s>=1))return"";i=Math.min(i,o+s)}return i>o?n.slice(o-1,i-1).join(""):""}function QI(e,t){if(t.length===0)return[...e.record].length;if(t[0].type==="var"){let n=dr(e,t[0].name);return n instanceof Map?n.size:[...M(n,e)].length}return[...Ae(e,t[0])].length}function eT(e,t){let n=Ae(e,t[0]),r=Ae(e,t[1]);Qe(e)&&(n=Sn(n),r=Sn(r));let o=n.indexOf(r);return o<0?0:Array.from(n.slice(0,o)).length+1}function tT(e,t){let n=Ae(e,t[0]);return n==="/dev/stdout"||n==="/dev/stderr"||n==="/dev/null"?0:e.input.close(e,n)}var nT=(e,t)=>t[0].type==="var"?Dl(dr(e,t[0].name)):Dl(L(e,t[0])),rT={__proto__:null,...oy,length:QI,substr:JI,index:eT,split:KI,sub:(e,t)=>sy(e,t,!1),gsub:(e,t)=>sy(e,t,!0),gensub:YI,match:VI,sprintf:(e,t)=>As(e,Ae(e,t[0]),t.slice(1).map(n=>L(e,n))),tolower:(e,t)=>Sn(Ae(e,t[0])),toupper:(e,t)=>Sn(Ae(e,t[0]),!0),close:tT,fflush:()=>0,typeof:nT,isarray:(e,t)=>t[0].type==="var"&&dr(e,t[0].name)instanceof Map?1:0};function ay(e,t){let n=rT[t.name];if(!n)throw new A(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var Os={type:"break"},Zl={type:"continue"},oT={type:"next"},iT={type:"nextfile"},sT={type:"exit"};function uy(e,t,n,r){let o=new Map([["0","awk"]]);r.forEach((a,u)=>o.set(String(u+1),new Y(a)));let i=new Map([["FS"," "],["OFS"," "],["ORS",`
335
+ `],["RS",`
336
+ `],["RT",""],["NR",0],["NF",0],["FNR",0],["FILENAME",""],["SUBSEP",""],["CONVFMT","%.6g"],["OFMT","%.6g"],["RSTART",0],["RLENGTH",-1],["ERRNO",""],["IGNORECASE",0],["FIELDWIDTHS",""],["FPAT","[^[:space:]]+"],["ENVIRON",new Ns("ENVIRON")],["PROCINFO",new Ns("PROCINFO",[["FS","FS"]])],["ARGC",r.length+1],["ARGV",o],["ARGIND",0]]),s={program:e,globals:i,frame:void 0,callDepth:0,record:"",recordValue:new Y(""),fields:[void 0],nf:0,fieldMode:"FS",out:[],errOut:[],steps:0,exitCode:0,ranges:[],rng:ry(),input:new ks(t,n),byteLocale:ee(t),tables:se(t.locale),hasFileRules:e.beginFile.length>0,callBuiltin:ay,execStmts:Is,assign:(a,u)=>Es(s,a,u),warn:a=>s.errOut.push(`awk: warning: ${a}
337
+ `),fileRule:a=>aT(s,a)};return s}var Ns=class extends Map{constructor(t,n=[]){super(n),this.systemName=t}check(t){if(!this.systemName||this.systemName==="PROCINFO"&&t==="FS")return;let n=this.systemName==="ENVIRON"?"ENVIRON":`PROCINFO[${t??"*"}]`;throw new A(`${n} is not supported without the corresponding environment or process metadata`,null,n)}get(t){return this.check(t),super.get(t)}has(t){return this.check(t),super.has(t)}set(t,n){return this.check(t),super.set(t,n)}delete(t){return this.check(t),super.delete(t)}clear(){return this.check(),super.clear()}get size(){return this.check(),super.size}keys(){return this.check(),super.keys()}values(){return this.check(),super.values()}entries(){return this.check(),super.entries()}[Symbol.iterator](){return this.check(),super[Symbol.iterator]()}};function ly(e){let{program:t}=e,n=Xl(e,t.begin,"BEGIN"),r=t.rules.length>0||t.end.length>0||t.beginFile.length>0||t.endFile.length>0;return!cy(n)&&r&&uT(e),Xl(e,t.end,"END"),e.exitCode}var cy=e=>e!==void 0&&e.type==="exit";function Xl(e,t,n){let r=fy(e,t);if(r!==void 0&&(r.type==="next"||r.type==="nextfile"&&(n==="BEGIN"||n==="END")))throw new A(`\`${r.type}' cannot be called from a ${n} rule`);return r}function aT(e,t){let n=t==="begin"?e.program.beginFile:e.program.endFile;return n.length===0?void 0:Xl(e,n,t==="begin"?"BEGINFILE":"ENDFILE")}function uT(e){for(;;){let t=e.input.next(e);if(t===null)return e.input.exitSignal;$s(e,t);let n=lT(e);if(cy(n))return n;n!==void 0&&n.type==="nextfile"&&e.input.closeFile(e)}}function lT(e){let{rules:t}=e.program;for(let n=0;n<t.length;n++){let r=t[n];if(!cT(e,r,n))continue;if(r.action===null){Yl(e,null,e.record+M(e.globals.get("ORS"),e));continue}let o=fy(e,r.action);if(o!==void 0)return o}}function fy(e,t){try{return Is(e,t)}catch(n){if(!(n instanceof So))throw n;return n.signal}}function cT(e,t,n){let{pattern:r}=t;if(r===null)return!0;if(r.type!=="range")return Fe(L(e,r));if(!e.ranges[n]){if(!Fe(L(e,r.from)))return!1;e.ranges[n]=!0}return Fe(L(e,r.to))&&(e.ranges[n]=!1),!0}function Is(e,t){for(let n of t){let r=Oo(e,n);if(r!==void 0)return r}}function Oo(e,t){if(++e.steps>Vr)throw new A(`execution stopped after ${Vr} statements (infinite loop?)`,null,"execution limit");switch(t.type){case"block":return Is(e,t.body);case"empty":return;case"expr":L(e,t.expr);return;case"print":return hT(e,t);case"printf":return mT(e,t);case"if":return Fe(L(e,t.test))?Oo(e,t.consequent):t.alternate===null?void 0:Oo(e,t.alternate);case"while":case"do":case"for":return fT(e,t);case"forin":return dT(e,t);case"switch":return pT(e,t);case"break":return Os;case"continue":return Zl;case"next":return oT;case"nextfile":return iT;case"exit":return gT(e,t);case"return":return{type:"return",value:t.value===null?void 0:L(e,t.value)};case"delete":{let n=Tt(e,t.name);t.subs===null?n.clear():n.delete(Ao(e,t.subs));return}default:throw new A(`unknown statement: ${t.type}`)}}function fT(e,t){t.init&&L(e,t.init);let n=!0;for(;t.type==="do"&&n||t.test===null||Fe(L(e,t.test));){n=!1;let r=Oo(e,t.body);if(r===Os)return;if(r!==void 0&&r!==Zl)return r;t.step&&L(e,t.step)}}function dT(e,t){let n=Tt(e,t.array);for(let r of Array.from(n.keys())){Es(e,t.name,new Y(r));let o=Oo(e,t.body);if(o===Os)return;if(o!==void 0&&o!==Zl)return o}}function pT(e,t){let n=L(e,t.expr),r=i=>i.test.type==="regex"?Ct(e,i.test).test(M(n,e)):bs(n,i.test.value,e)===0,o=t.cases.findIndex(i=>i.test!==null&&r(i));if(o===-1&&(o=t.cases.findIndex(i=>i.test===null)),o!==-1)for(let i=o;i<t.cases.length;i++){let s=Is(e,t.cases[i].body);if(s===Os)return;if(s!==void 0)return s}}function Yl(e,t,n){if(t===null){e.out.push(n);return}let r=M(L(e,t),e);if(r==="/dev/stdout")e.out.push(n);else if(r==="/dev/stderr")e.errOut.push(n);else if(r!=="/dev/null")throw new A(_l(r),null,"output redirection")}function hT(e,t){let n=M(e.globals.get("ORS"),e),r;if(t.args.length===0)r=e.record;else{let o=M(e.globals.get("OFS"),e);r=t.args.map(i=>Ww(L(e,i),e)).join(o)}Yl(e,t.dest,r+n)}function mT(e,t){let n=t.args.map(r=>L(e,r));Yl(e,t.dest,As(e,M(n[0],e),n.slice(1)))}function gT(e,t){if(t.value!==null){let n=Math.trunc(Z(L(e,t.value)));e.exitCode=(n%256+256)%256}return sT}var wT="awk [-F fs] [-v var=value] 'program' [file ...] | awk [-F fs] [-v var=value] -f progfile [file ...]",yT=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u;function dy(e,t,n){let{values:r,positional:o}=N(bT(t),{valueShort:["F"],repeatable:["v","f"],stopAtFirstPositional:!0}),i=kT(r.get("f")??[],o,n);if(i.error)return i.error;let s;try{It({byteLocale:ee(n)},i.text),s=Mw(i.text)}catch(f){if(f instanceof RangeError)return v("feature","awk","parser depth limit",`awk: program too deeply nested (${f.message})`);if(C(f))return Q(f,"awk",`awk: ${f.message}`);if(!(f instanceof A))throw f;let d=f.line===null?`awk: ${f.message}`:`awk: ${f.kind} at line ${f.line}: ${f.message}`;return f.gap===null?b(d):v("feature","awk",f.gap,d)}let a=uy(s,n,e,i.operands);for(let f of s.warnings)a.warn(f);let u,l=null;try{r.has("F")&&a.assign("FS",yo(r.get("F"),a.warn));for(let f of r.get("v")??[]){let d=yT.exec(f);if(!d)return b(`awk: -v: expected var=value but got \`${f}\``);a.assign(d[1],new Y(yo(d[2],a.warn)))}u=ly(a)}catch(f){let d=C(f);if(!(f instanceof A)&&!(f instanceof RangeError)&&!d)throw f;a.errOut.push(`awk: ${f.message}
338
+ `),u=2,f instanceof RangeError&&(l={detail:"runtime limit",message:`awk: ${f.message}`}),f.gap&&(l={detail:f.gap,message:`awk: ${f.message}`}),d&&(l={detail:d.detail,message:`awk: ${f.message}`})}let c={stdout:a.out.join(""),stderr:a.errOut.join(""),exitCode:u};return l===null?c:X(c,"feature","awk",l.detail,l.message)}var xT=/^-[Fvf]\S*\s/su;function bT(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="-F"||r==="-v"||r==="-f"){t.push(r),n+1<e.length&&t.push(e[++n]);continue}if(xT.test(r)){t.push(r.slice(0,2),r.slice(2));continue}if(!r.startsWith("-")||r==="-"||r==="--"){t.push(...e.slice(n));break}t.push(r)}return t}function kT(e,t,n){if(e.length===0)return t.length===0?{error:xe(wT,2)}:{text:t[0],operands:t.slice(1)};let r=[];for(let o of e){let{path:i,error:s}=D(n,"awk",o);if(s||!n.fs.isFile(i))return{error:b(`awk: cannot open program file \`${o}\`: ${s??"Is a directory"}`,2)};r.push(n.fs.readFile(i))}return{text:r.join(`
339
+ `),operands:t}}function hy(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["n","r","u","f","b","z"],valueShort:["t","o"],valueLong:["output"],repeatable:["k","o","output"]}),s=[...o.get("o")??[],...o.get("output")??[]];if(s.length>1)return b("sort: multiple output files specified",2);let a=o.get("t");if(a!==void 0&&T(a).length!==1)return b(`sort: multi-character tab '${a}'`,2);let u={n:r.has("n"),f:r.has("f"),b:r.has("b"),r:r.has("r")},l=OT(o.get("k")??[],u);if(l.error)return l.error;let c=ae("sort",i,e,n,{stopOnError:!0});if(c.failed)return{stdout:"",stderr:c.stderr,exitCode:2};let f=r.has("z")?"\0":`
340
+ `,d=c.inputs.flatMap(({content:g})=>we(g,f)),p=l.specs.length?l.specs:[{start:1,...u}],h=_T(d,p,a,r.has("u"),u.r),m=Ee(h,f);return s.length===0?ue(m,c):vT(s[0],m,n,c)}function vT(e,t,n,r){if(e==="/dev/null")return ue("",r);if(e==="/dev/stdout")return ue(t,r);n.io?.setReads([]);let o;try{o=n.writable&&n.fs.openWritable(n.cwd,e),o&&o.write(t)}catch(i){return P(n,"sort",i?.path,i?.fsError),Q(i,"sort",`sort: open failed: ${i.message}`,2)}return o?ue("",r):v("feature","sort","-o",`sort: open failed: ${e}: Read-only file system`,2)}var ET="nrfb",$T="bdfghiMnRrV",ST=/^[ \t]*\+?(\d+)/u,AT=(e,t)=>b(`sort: ${e}: invalid count at start of '${t}'`,2),Ts=(e,t)=>b(`sort: ${e}: invalid field specification '${t}'`,2);function NT(e){let t=0,n=null,r=a=>{let u=ST.exec(e.slice(t));return u===null?(n=AT(a,e.slice(t)),null):(t+=u[0].length,Number(u[1]))},o=a=>{let u=r(a);if(u===null)return null;let l=null;if(e[t]==="."&&(t++,l=r("invalid number after '.'"),l===null))return null;let c=t;for(;t<e.length&&/[a-zA-Z]/u.test(e[t]);)t++;return{field:u,offset:l,mods:e.slice(c,t)}},i=o("invalid number at field start");if(i===null)return{error:n};let s=null;return e[t]===","&&(t++,s=o("invalid number after ','"),s===null)?{error:n}:i.field===0||s?.field===0?{error:Ts("field number is zero",e)}:i.offset===0?{error:Ts("character offset is zero",e)}:t!==e.length?{error:Ts("stray character in field spec",e)}:{from:i,to:s}}function OT(e,t){let n=[];for(let r of e){let o=NT(r);if(o.error)return{error:o.error};let{from:i,to:s}=o,a=i.mods+(s?.mods??"");for(let l of a)if(!ET.includes(l))return $T.includes(l)?{error:v("option","sort",`-k${r}`,`sort: unknown key option \`${l}\` in ${r}`,2)}:{error:Ts("stray character in field spec",r)};if(i.offset!==null||(s?.offset??0)!==0)return{error:v("option","sort",`-k${r}`,`sort: invalid key specification: ${r} (character offsets are not supported)`,2)};let u=a.length>0;n.push({start:i.field,end:s?.field,n:u?a.includes("n"):t.n,r:u?a.includes("r"):t.r,f:u?a.includes("f"):t.f,b:u?i.mods.includes("b"):t.b})}return{specs:n}}function IT(e,t){let n=[];if(t!==void 0){let o=0;for(;;){let i=e.indexOf(t,o);if(i===-1){n.push([o,e.length]);break}n.push([o,i]),o=i+t.length}return n}let r=0;do{let o=r;for(;r<e.length&&/[ \t]/u.test(e[r]);)r++;for(;r<e.length&&!/[ \t]/u.test(e[r]);)r++;n.push([o,r])}while(r<e.length);return n}function TT(e,t,n){if(t.start>n.length)return"";let r=n[t.start-1][0],o=t.end===void 0||t.end>n.length?e.length:n[t.end-1][1];if(t.b)for(;r<o&&/[ \t]/u.test(e[r]);)r++;return e.slice(r,Math.max(r,o))}var CT=e=>e.replace(/[a-z]/gu,t=>t.toUpperCase());function _T(e,t,n,r,o){let i=t.every(l=>l.start===1&&l.end===void 0);if(i&&t.length===1&&!t[0].n&&!t[0].f&&!t[0].b)return e.sort(e.some(l=>/[\u{10000}-\u{10FFFF}]/u.test(l))?q:void 0),t[0].r&&e.reverse(),r?e.filter((l,c)=>c===0||l!==e[c-1]):e;let s=e.map(l=>{let c=i?[[0,l.length]]:IT(l,n);return{line:l,keys:t.map(f=>{let d=TT(l,f,c);return f.n?LT(d):f.f?CT(d):d})}}),a=(l,c)=>{for(let f=0;f<t.length;f++){let d=t[f],p=d.n?FT(l.keys[f],c.keys[f]):q(l.keys[f],c.keys[f]);if(p!==0)return d.r?-p:p}return r?0:(o?-1:1)*q(l.line,c.line)};s.sort(a);let u=[];for(let l=0;l<s.length;l++)r&&l>0&&a(s[l-1],s[l])===0||u.push(s[l].line);return u}function LT(e){let t=/^[ \t]*(-?)(?:(\d+)(?:\.(\d*))?|\.(\d+))/u.exec(e),n=(t?.[2]??"").replace(/^0+/u,"")||"0",r=(t?.[3]??t?.[4]??"").replace(/0+$/u,"");return{integer:n,fraction:r,negative:t?.[1]==="-"&&(n!=="0"||r!=="")}}var py=(e,t)=>e<t?-1:e>t?1:0;function FT(e,t){if(e.negative!==t.negative)return e.negative?-1:1;let n=e.integer.length-t.integer.length||py(e.integer,t.integer)||py(e.fraction,t.fraction);return e.negative?-n:n}async function gy(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["r","0"],valueShort:["n","I"],stopAtFirstPositional:!0}),[s="echo",...a]=i,u=o.get("I"),l=o.has("n")?Pe(o.get("n"),"xargs: -n"):{value:void 0};if(l.error)return l.error;if(l.value===0)return b("xargs: -n: must be at least 1");if(u==="")return b("xargs: -I: replacement string must not be empty");if(u!==void 0&&l.value!==void 0)return v("option","xargs","-I -n","xargs: combining replacement and chunk limits is not supported");if(z(n),!r.has("0")&&e.includes("\0"))return v("feature","xargs","NUL input","xargs: NUL input requires -0");let c;if(r.has("0"))c=we(e,"\0");else if(u===void 0)c=RT(e);else{if(/["'\\]/u.test(e))return v("feature","xargs","-I input quoting","xargs: quoted or escaped replacement lines are not supported");c=we(e).map(h=>h.replace(/^[ \t\r\f\v]+/u,"")).filter(Boolean)}if(c.length===0&&(r.has("r")||u!==void 0))return R();let f=u===void 0?l.value??Math.max(1,c.length):1,d=B(),p=0;for(let h=0;h<Math.max(1,c.length);h+=f){let m=c[h],g=u===void 0?[...a,...c.slice(h,h+f)]:a.map(y=>y.replaceAll(u,m)),w=await n.dispatch(s,g,"",{devNull:!0});if(U(d,w),w.exitCode===255)return U(d,{...B(`xargs: ${s}: exited with status 255; aborting
341
+ `),exitCode:124}),d;if(w.exitCode===127&&!n.hasCommand(n.registry.resolveCommand(s)))return{...d,exitCode:127};w.exitCode!==0&&(p=123)}return{...d,exitCode:p,ignored:!1}}var my=e=>new Error(`unmatched ${e==="'"?"single":"double"} quote; by default quotes are special to xargs unless you use the -0 option`);function RT(e){let t=[],n=null,r=!1,o="";for(let i=0;i<e.length;i++){let s=e[i];if(!(!r&&/[ \t\n\r\f\v]/u.test(s)))if(n)if(s===n)n=null;else{if(s===`
342
+ `)throw my(n);o+=s}else if(s==='"'||s==="'")n=s,r=!0;else if(s==="\\"){if(i+1>=e.length)break;o+=e[++i],r=!0}else s===" "||s===" "||s===`
343
+ `?(r&&t.push(o),o="",r=!1):(o+=s,r=!0)}if(n)throw my(n);return r&&t.push(o),t}function wy(e,t,n,r){let{values:o,positional:i,order:s}=N(DT(n),{short:["q","v"],valueShort:["c","n"]}),a=s.findLast(w=>w.name==="n"||w.name==="c")?.name??"n",u=vf(o.get(a)??"10",e+": -"+a);if(u.error)return u.error;let l=s.findLast(w=>w.name==="q"||w.name==="v"),c=l?l.name==="v":null,f=e==="head",d=u.sign==="+";if(f&&u.value===0&&u.sign!=="-")return yy(e,t,i,r,()=>"",{unit:a,banner:c,leftover:w=>w,readOptions:{noRead:!0}});if(!f&&u.value===0&&!d){if(!r.stdinFile&&(!i.length||i.includes("-")||i.includes("/dev/stdin"))){let w=vy(e,t,"",a,"standard input");w&&r.notes.add(w)}return R()}let p=w=>f?[0,u.sign==="-"?Math.max(0,w-u.value):u.value]:[d?Math.min(w,Math.max(0,u.value-1)):Math.max(0,w-u.value),w],h=w=>{if(a==="c")return ky(w,p);let y=f?u.sign==="-":!d,$=f||y?u.value:Math.max(0,u.value-1),S=by(w,$,y);return f?w.slice(0,S):w.slice(S)},m=f?MT(u,a,r):void 0;return yy(e,t,i,r,h,{unit:a,banner:c,leftover:m,readOptions:!f&&d?{stopOnDir:!0}:void 0})}function MT(e,t,n){return e.sign==="-"||t==="n"&&!n.stdinFile?()=>"":t==="c"?r=>ky(r,o=>[Math.min(e.value,o),o]):r=>r.slice(by(r,e.value))}function by(e,t,n=!1){if(n){if(t===0)return e.length;let o=e.length-Number(e.endsWith(`
344
+ `));for(let i=0;i<t;i++)if(o<=0||(o=e.lastIndexOf(`
345
+ `,o-1),o<0))return 0;return o+1}let r=0;for(let o=0;o<t&&r<e.length;o++){let i=e.indexOf(`
346
+ `,r);r=i===-1?e.length:i+1}return r}function DT(e){return/^-\d+$/u.test(e[0]??"")?["-n",e[0].slice(1),...e.slice(1)]:e}function ky(e,t){let n=T(e),[r,o]=t(n.length);return r===0&&o>=n.length?e:G(n.subarray(r,o))}function yy(e,t,n,r,o,{unit:i,banner:s,leftover:a=()=>"",readOptions:u}){let l=ae(e,n,t,r,u),c=s??n.length>1,f=l.entries.filter(m=>m.kind!=="missing"),d=[],p=[],h=null;for(let m=0;m<f.length;m++){let{name:g,kind:w,shared:y}=f[m],{content:$}=f[m];(y||g===null)&&(h!==null&&($=h),h=a($),z(r,h));let S=w==="dir"?"":o($);if(w==="file"&&S!==$){let W=vy(e,$,S,i,Mn(g,r));W&&p.push(W)}let _=g===null||g==="-"?"standard input":g;d.push(c?`${m>0?`
347
+ `:""}==> ${_} <==
348
+ ${S}`:S)}for(let m of p)r.notes.add(m);return ue(d.join(""),l)}function UT(e){let t=+(e.length>0&&!e.endsWith(`
349
+ `));for(let n=e.indexOf(`
350
+ `);n!==-1;n=e.indexOf(`
351
+ `,n+1))t++;return t}function vy(e,t,n,r,o){let i=r==="c"?l=>T(l).length:UT,s=i(n),a=i(t);if(s>=a)return null;let u=(r==="c"?"byte":"line")+(a===1?"":"s");return`${e}: selected ${s} of ${a} ${u} from ${o}.`}function PT(e,t,n){let{flags:r,positional:o}=N(t,{short:["l","w","c","m"]}),i=BT(r),s=ae("wc",o,e,n,{read:"as-held"}),a=o.length>1||Object.values(i).filter(Boolean).length>1,u=[],l={l:0,w:0,m:0,c:0};for(let{name:f,content:d,bytes:p,kind:h,shared:m}of s.entries.filter(g=>g.kind!=="missing")){let g=jT(p??d,n,i,a);u.push({counts:g,name:f,kind:h,shared:m}),l.l+=g.l,l.w+=g.w,l.m+=g.m,l.c+=g.c}let c=a?zT(u,n.stdinFile):1;return o.length>1&&u.push({counts:l,name:"total"}),ue(Ee(u.map(f=>xw(f.counts,f.name,i,c,n))),s)}function zT(e,t){let n=0,r=1;for(let{name:o,kind:i,shared:s,counts:a}of e)i==="dir"||(o===null||s)&&!t?r=7:n+=a.c;return Math.max(r,String(n).length)}function BT(e){return e.size===0?{l:!0,w:!0,m:!1,c:!0}:{l:e.has("l"),w:e.has("w"),m:e.has("m"),c:e.has("c")}}function jT(e,t,n,r){let o=ee(t),i=n.c||r||n.m&&o?WT(e):0;return{l:n.l?Sr(e):0,w:n.w?YT(e,t):0,m:n.m?o?i:qT(e):0,c:i}}var WT=e=>typeof e=="string"?T(e).length:e.length;function qT(e){if(typeof e=="string")return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of Bo(e))n>=0&&t++;return t}var HT=new Set([9,10,11,12,13,32]),GT=new Set([160,8199,8239,8288]),Vl=1,Kl=0,Jl=2,XT=Uint8Array.from({length:128},(e,t)=>HT.has(t)?Vl:t>32&&t<127?Jl:Kl),ZT=(e,t)=>t.has("print",e)?t.has("space",e)||GT.has(e)?Vl:Jl:Kl;function YT(e,t){let n=se(t.locale),r=0,o=!1;for(let i of VT(e,t)){let s=i<0?Kl:i<128?XT[i]:ZT(i,n);s===Vl?(o&&r++,o=!1):s===Jl&&(o=!0)}return o?r+1:r}function*VT(e,t){if(typeof e!="string"){yield*ee(t)?e:Bo(e);return}if(ee(t)){yield*T(e);return}for(let n=0;n<e.length;){let r=e.codePointAt(n);yield r>=55296&&r<=57343?65533:r,n+=r>65535?2:1}}function KT(e,t){let n=0;for(let r=0;r<t&&n<e.length;r++){for(;n<e.length&&/[ \t]/u.test(e[n]);)n++;for(;n<e.length&&!/[ \t]/u.test(e[n]);)n++}return e.slice(n)}function JT(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["c","d","u","i","D"],valueShort:["f","s","w"]});if(i.length>2)return b(`uniq: extra operand: ${i[2]}`);if(i.length===2&&i[1]!=="-")return v("feature","uniq","output file","uniq: output files are not supported (filesystem is read-only)");let s=Pe(o.get("f")??"0","uniq: -f");if(s.error)return s.error;let a=Pe(o.get("s")??"0","uniq: -s");if(a.error)return a.error;let u=o.has("w")?Pe(o.get("w"),"uniq: -w"):{value:void 0};if(u.error)return u.error;let l=r.has("D"),c=r.has("c");if(l&&c)return b("uniq: printing all duplicated lines and repeat counts is meaningless");let f=kf("uniq",i.slice(0,1),e,n),d=r.has("d"),p=r.has("u"),h=r.has("i"),m=S=>{let _=s.value>0?KT(S,s.value):S;if(a.value===0&&u.value===void 0){let H=_.toWellFormed();return h?H.replace(/[A-Z]/gu,re=>re.toLowerCase()):H}let W=T(_).subarray(a.value,u.value===void 0?void 0:a.value+u.value);return(h?W.map(H=>H>=65&&H<=90?H+32:H):W).join(",")},g=we(f.content),w=[],y=0,$=g.length?m(g[0]):null;for(let S=1;S<=g.length;S++){let _=S===g.length?null:m(g[S]);if(S<g.length&&_===$)continue;let W=S-y,H=W>=2;(l?H:!(d&&p)&&(d?H:!p||!H))&&(l?w.push(...g.slice(y+(p?1:0),S)):w.push(c?String(W).padStart(7)+" "+g[y]:g[y])),y=S,$=_}return ue(Ee(w),f)}function xy(){return R()}function QT(){return{stdout:"",stderr:"",exitCode:1}}var Ql={grep:ji,head:(e,t,n)=>wy("head",e,t,n),tail:(e,t,n)=>wy("tail",e,t,n),wc:PT,sort:hy,uniq:JT,echo:mw,printf:yw,xargs:gy,awk:dy},Ey={true:xy,false:QT,":":xy};var Oy={test:uw,cat:Bg,...Ql,...Dg,...Hm},$y=(e,t)=>(n,r,o)=>{let i=Ql.grep(n,[t,...r],o),s=C(i);return s?X(i,s.kind,e,s.detail,s.message):i},ec={__proto__:null,sed:iw,egrep:$y("egrep","-E"),fgrep:$y("fgrep","-F"),"[":lw,...Gm,...Ey,...Sl,...Oy},Iy=new Set(["cd",":",...Object.keys(Sl)]),e6=e=>!!ec[e],t6=new Set(["basename","cp","dirname","ln","mkdir","patch","rm","tee","touch"]),Ty=Object.fromEntries(Object.entries(Oy).filter(([e])=>!t6.has(e))),n6=["ls","cd","cat","grep","rg","find","head","tail","wc","tree","du","stat","realpath","sort","uniq","cut","tr","awk","nl","tac","hexdump","base64","xargs","echo","printf","test","diff","pwd","seq","which"],Sy=Object.keys(ec).filter(e=>!Iy.has(e)&&!Object.hasOwn(Ty,e)).sort(),r6=new Set(["base32","brotli","egrep","fgrep","gunzip","gzcat","gzip","od","sed","sha1sum","sha256sum","sha384sum","sha512sum","shasum","tar","tee","xxd","zcat"]),Ay=i6(),o6=["grep","head","tail","wc","sort","uniq","cut","xargs","awk","tr","nl","tac","hexdump","cat","base64","diff","patch"];function i6(){let e=new Set(Object.keys(Ty)),t=[];for(let n of n6)e.delete(n)&&t.push(n);return t.push(...[...e].sort()),t}var Cy=Object.freeze(["/usr/local/bin/","/usr/bin/","/bin/","/sbin/"]);function _y(e,t){for(let n of Cy)if(e.startsWith(n)){let r=e.slice(n.length);if(t(r))return r}return e}var s6=new Set(["test","[","true","false"]),a6=new Set(["grep","egrep","fgrep"]);function u6(e,t){let n=_y(e[0],t);return s6.has(n)?"status":a6.has(n)?em(e.slice(1))?"status":"search":"work"}function Cs(e,t=!1){let n=tu(t),r=n===null?[]:eu,o=md(e,u=>e6(u)||r.includes(u)),i=Object.freeze({__proto__:null,...ec,...n,...o.handlers}),s=u=>!!i[u],a=Object.freeze([...Ay,...r,...Sy,...o.names]);return Object.freeze({commands:i,names:a,pipeNames:Object.freeze([...o6,...r,...Sy.filter(u=>r6.has(u)),...o.pipeNames]),binPrefixes:Cy,has:s,shellOnly:u=>Iy.has(u),resolveCommand:u=>_y(u,s),chainRole:u=>u6(u,s),known:[...Ay,...r,...o.names].join(", ")})}var l6=Cs(),Ny=null,Ly=e=>e?(Ny??=Cs(void 0,!0),Ny):l6;function Fy(e,t){let n=hw.get(e);return n!==void 0?v("feature",e,e,`${e}: ${n}`,127):v("command",e,e,`${e}: command not found. Available: ${t.known}`,127)}function My(e,t,n){let r=p6(e);if(!r)return[];let{start:o,pipe:i,quote:s,words:a}=r;for(;c6.has(a[0]);)a.shift();if(f6.has(a[0]))return[];if(a[0]==="for"&&a.length<=2)return[];let u=e.slice(o),l=Ry(u,s);if(!l)return[];let c=a.length===0,f=c?"":n.resolveCommand(Ry(a[0],null)?.value??""),d=c?d6(l.value,i,n,t.functions):i?[]:m6(l,t,f==="cd"),p=e.slice(0,o),h=i&&u===""&&p.endsWith("|")?" ":"";return d.map(m=>p+h+u+h6(m.slice(l.value.length),s))}var c6=new Set(["!","{","do","then","else","elif","if","while","until"]),f6=new Set(["done","fi","}","esac"]);function d6(e,t,n,r){let o=t?n.pipeNames:n.names;for(let s of n.binPrefixes)if(e.startsWith(s))return o.filter(a=>a.startsWith(e.slice(s.length))).map(a=>s+a);if(e.startsWith("/")||e.startsWith("./"))return[];let i=[...r.keys()].filter(s=>!o.includes(s));return[...o,...i].filter(s=>s.startsWith(e))}function p6(e){let t=0,n=!1,r=null,o=!1,i=-1,s=[];for(let a=0;a<e.length;a++){let u=e[a];if(r==="'"){u===r&&(r=null);continue}if(u==="\\"&&(!r||'$`"\\\n'.includes(e[a+1]))){if(a+1===e.length)return null;e[++a]!==`
352
+ `&&(o=!0);continue}if(u==="`"||u==="$"&&e[a+1]==="(")return null;if(r){u===r&&(r=null);continue}if(u==="'"||u==='"'){r=u,o=!0;continue}if(u==="#"&&!o){let f=e.indexOf(`
353
+ `,a);if(f===-1)return null;a=f-1;continue}if(u===" "||u===" "){o&&s.push(e.slice(t,a)),t=a+1,o=!1;continue}let l=u==="|"&&e[a+1]==="|",c=u==="&"&&e[a+1]==="&";if(u==="|"||c||u===";"||u===`
354
+ `||u==="("||u===")"&&i===a-1){(l||c)&&a++,u==="("&&(i=a),t=a+1,n=u==="|"&&!l,s.length=0,o=!1;continue}o=!0}return{start:t,pipe:n,quote:r,words:s}}function Ry(e,t){if(e==="")return{value:"",mask:null};try{let n=Ko(e+(t??""));if(n.length!==1||n[0].kind!=="word")return null;let r=n[0];for(let o=0;o<r.value.length;o++){let i=r.mask?.[o]??"0";if(i!=="1"&&r.value[o]==="$"||i==="0"&&"*?[{".includes(r.value[o]))return null}return r}catch{return null}}function h6(e,t){return t==="'"?e.replaceAll("'","'\\''")+"'":t==='"'?e.replace(/[\\$`"]/gu,"\\$&")+'"':e.replace(/[\s\\'"`$&|;()<>*?[\]{}!#~]/gu,n=>n===`
355
+ `?`'
356
+ '`:"\\"+n)}function m6(e,t,n=!1){let r=e.value,o=r.startsWith("~")&&(e.mask?.[0]??"0")==="0"&&!e.empty?.some(h=>h<=1)&&(r.length===1||(e.mask?.[1]??"0")==="0");if(o&&r==="~")return t.fs.isDir(E(t.cwd,rr(t),t.fs).path)?["~/"]:[];if(o&&!r.startsWith("~/"))return[];let i=r.lastIndexOf("/"),s=r.slice(0,i+1),a=r.slice(i+1),u=o?rr(t)+s.slice(1):s||".",l=E(t.cwd,u,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:c,files:f,links:d}=t.fs.listDir(l),p=c.map(h=>h+"/");for(let h of d)t.fs.isDir(E(l,h,t.fs).path)?p.push(h+"/"):n||p.push(h);return n||p.push(...f),p.filter(h=>h.startsWith(a)&&(a.startsWith(".")||!h.startsWith("."))).filter(h=>s!==""||a===""||!h.startsWith("-")).map(h=>s===""&&h.startsWith("-")?"./"+h:s+h)}async function Dy(e,t,n,r=!1){let o=(t.substitutionDepth??0)+1;if(o>Dn)throw new x("feature","command substitution nesting limit",`command substitution nesting beyond ${Dn} levels is not supported`);let i=t.expansionFds[2],a=await ke(t,{substitutionDepth:o,outputFds:{1:"out",2:typeof i=="object"||i==="closed"?i:"err"},errexitOff:!0,closed:{out:!1,err:i==="closed"}},()=>Yt(t,()=>{let f;try{f=fd(e,t.writable,t.registry.has)}catch(p){let h=C(p);if(!h){if(r)return b(`error: command substitution: ${p.message}`,2);throw new x("feature","command substitution syntax",`runtime command substitution syntax errors are not supported: ${p.message}`)}return t.unsupported.add(h),b(`error: ${p.message}`,1)}let d=f.length===1&&!f[0].negate&&f[0].stages.length===1?f[0].stages[0]:null;return d&&!d.group&&!d.loop&&!d.conditional&&!d.test&&d.words.length===0&&d.assigns.length===0&&d.redirs.length===1&&d.redirs[0].op==="read"&&d.words.push({value:"cat",mask:null}),n(f,t,{text:t.stdinLeft,bytes:t.stdinBytes})}));t.lastExit=t.substitutionExit=a.exitCode;let u=a.stdout,l=a.stderr;if(u.includes("\0")){let f=u.length;u=u.replaceAll("\0","");let d=f-u.length;t.notes.add(`command substitution: discarded ${d} NUL ${d===1?"byte":"bytes"}.`),l+=`warning: command substitution: ignored null byte in input
357
+ `}Wi(t,l);let c=u.length;for(;c>0&&u[c-1]===`
358
+ `;)c--;return u.slice(0,c)}async function Uy(e,t){return{stdout:"",stderr:"",exitCode:await pr(e,t)?0:1}}var tc=async(e,t)=>(await nl(e,t)).value;async function pr(e,t){let{kind:n}=e;if(n==="not")return!await pr(e.expression,t);if(n==="and")return await pr(e.left,t)&&await pr(e.right,t);if(n==="or")return await pr(e.left,t)||await pr(e.right,t);let{op:r}=e;if(n==="unary"){let a=await tc(e.word,t);if(r==="-n")return a!=="";if(r==="-z")return a==="";if(["-a","-e","-f","-d"].includes(r))return $l(r,a,t);if(r==="-v")return g6(a,t);Io(r)}["<",">","-nt","-ot","-ef"].includes(r)&&Io(r);let o=await tc(e.left,t);if(Object.hasOwn(wo,r)){let a=await tc(e.right,t);return wo[r](bn(o,t),bn(a,t))}let i=await nl(e.right,t);Qr(i)&&Io("extglob");let s=He(Qn(i),{bash:!0}).test(o);return r==="!="?!s:s}function g6(e,t){return e.includes("[")&&Io("-v array subscript"),/^[ \t\n\r\f\v]*[+-]?0+[ \t]*$/u.test(e)&&Io("-v positional parameter"),/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?Zt(e,t).set:!1}function Io(e){throw new x("feature",`[[ ${e}`,`${e} in [[ is not supported`)}function zy(e,t,n,r){return e.define?(t.functions.set(e.define.name,e.define.body),B()):e.test?Uy(e.test,t):e.group?k6(e,t,n,r):e.loop?e.loop.words?x6(e.loop,t,r):w6(e.loop,t,r):b6(e.conditional,t,n,r)}var By=1e4,Py={kind:"feature",command:null,detail:"loop limit",message:`a loop running more than ${By} times is not supported`};async function w6(e,t,n){let r=B(),o={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let i=0;;i++){if(i===By){t.unsupported.add(Py),U(r,b(`error: ${Py.message}`,1));break}let s=r.ignored,a=r.exitCode,u=await n(e.condition,t,o,!0);if(U(r,u),r.exitCode=a,r.ignored=s,u.halt||u.control)return{...r,halt:u.halt,control:u.control,blame:u.blame};if(u.exitCode===0==!!e.until)break;let l=await n(e.body,t,o);if(U(r,l),r.blame=l.blame,l.halt)return{...r,halt:!0};if(l.control?.levels>1)return{...r,control:{...l.control,levels:l.control.levels-1}};if(l.control?.type==="break")break}}finally{t.loopDepth--}return r}var y6={value:"for",mask:null};async function x6(e,t,n){let r=await ao([y6,...e.words],t),o=B(),i={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let s of r.argv.slice(1)){t.vars.set(e.name,s);let a=await n(e.body,t,i);if(U(o,a),o.blame=a.blame,a.halt)return{...o,halt:!0};if(a.control?.levels>1)return{...o,control:{...a.control,levels:a.control.levels-1}};if(a.control?.type==="break")break}}finally{t.loopDepth--}return o}async function b6(e,t,n,r){let o=B(),i={text:n,bytes:t.stdinBytes};for(let a of e.branches){let u=await r(a.condition,t,i,!0);if(U(o,u),u.halt||u.control)return{...o,halt:u.halt,control:u.control,blame:u.blame};if(u.exitCode!==0)continue;let l=await r(a.body,t,i);return U(o,l),{...o,halt:l.halt,control:l.control,blame:l.blame}}if(!e.otherwise)return o.exitCode=0,o.ignored=!1,o;let s=await r(e.otherwise,t,i);return U(o,s),{...o,halt:s.halt,control:s.control,blame:s.blame}}async function k6(e,t,n,r){let o={text:n,bytes:t.stdinBytes};return e.isolate?{...await Yt(t,()=>r(e.group,t,o)),halt:!1,control:void 0,ignored:!1}:r(e.group,t,o)}var v6=new Set(["sort","cat"]),E6=new Set(["wc","tac"]);function nc(e){let t=null,n=null,r=i=>{t&&!t.bufferReads&&t.reads.push(i)},o=i=>{if(i!==void 0)for(let s=t;s;s=s.parent){if(!s.reads.includes(i)||s===t&&n?.scope===s&&(n.unsupported||s.buffered||n.fd===1&&(v6.has(s.name)||E6.has(s.name)&&!s.reads.slice(1).includes(i))))continue;if(s.failure)throw s.failure;let a=s===t&&n?.fd===2,u=a?"input modified by diagnostics":"streaming self-output",l=a?"reading input while diagnostics write to the same file is not supported":"writing to an actively read input file is not supported";throw s.failure=X(new x("feature",u,l),"feature",s.name,u,l),s.failure}};return e.observeIo?.({read:r,write:o}),{read:r,bufferOutput(){t&&(t.buffered=!0)},bufferReads(i){if(!t)return i();let s=t,a=s.bufferReads;s.bufferReads=!0;try{return i()}finally{s.bufferReads=a}},setReads(i){t&&(t.reads=i)},async run(i,s){let a=t;t={name:i,reads:[],parent:a};try{return await s()}finally{t=a}},output(i,s,a){let u=n;n={scope:t,fd:null,unsupported:!!C(i)};try{for(let l of er(i))l.text!==""&&(n.fd=l.fd,o(s.fds[l.fd]?.identity));return a((l,c)=>{n.fd=l.fd,Cu(l,c)})}finally{n=u}}}}function oc(e,t){let n={1:t.outputFds[1]?.path?t.outputFds[1]:"out",2:t.outputFds[2]?.path?t.outputFds[2]:"err"},r={1:jy(t.outputFds[1]),2:jy(t.outputFds[2])};return tr(e,{fds:n,deferred:r},t)}var jy=e=>e!=="out"&&e!=="err"&&!e?.path;async function To(e,t,n,r=!1){if(e.some(a=>a.background))throw new x("feature","&","background processes (`&`) are not supported");let o=B(),i=null,s=null;for(let[a,u]of e.entries()){if(u.warnings&&U(o,tr({...B(u.warnings),exitCode:o.exitCode,ignored:o.ignored},{fds:t.outputFds},t)),u.gate==="and"&&o.exitCode!==0){(s??=yf()).skip(r?null:i,o.exitCode);continue}if(u.gate==="or"&&o.exitCode===0)continue;s?.flush(t.notes);let l=r||u.negate||$6(e,a),c=await(l?ke(t,{errexitOff:!0},()=>Wy(u.stages,t,n)):Wy(u.stages,t,n));if(U(o,c),u.negate&&!c.halt&&(o.exitCode=c.exitCode===0?1:0),l&&(o.ignored=!0),i=u.negate?null:c.blame,t.lastExit=o.exitCode,c.halt||c.control){Object.assign(o,{halt:c.halt,control:c.control});break}if(o.exitCode!==0&&!o.ignored&&t.errexit&&!t.errexitOff){o.halt=!0;break}}return s?.flush(t.notes),t.stdinLeft=n.text,t.stdinBytes=n.bytes??null,Object.assign(o,{blame:i})}var $6=(e,t)=>["and","or"].includes(e[t+1]?.gate);async function Wy(e,t,n){let r=B(),o=n.text,i=n.bytes??null;for(let s=0;s<e.length;s++){let a=e[s],u=s===0,l=s<e.length-1?S6():null,c={...t.outputFds};l&&(c[1]=l);let f=i,d=o,p=()=>A6(a,t,{stdin:d,stdinBytes:f,stdinFile:u&&t.stdinFile,fds:c,stdinPiped:u?t.stdinPiped:!0,stdinTerminal:u&&t.stdinTerminal}),h=e.length>1?{...await Yt(t,p),ignored:!1}:await p();u&&(n.text=h.inputLeft,n.bytes=h.bytesLeft??null),U(r,h);let m=l?.carried()??{text:""};i=m.bytes??null,o=m.text??ve(m.bytes)??"",r.blame=h.blame,e.length===1&&(r.halt=h.halt,r.control=h.control)}return r}function S6(){let e="",t=null;return{write(n){t===null?e+=n:n!==""&&t.push(I(n))},writeBytes(n){t===null&&(t=e===""?[]:[I(e)],e=""),t.push(n)},carried:()=>t===null?{text:e}:{bytes:Ze([...t,new Uint8Array])}}}function A6(e,t,{stdin:n,stdinBytes:r,stdinFile:o,fds:i,stdinPiped:s,stdinTerminal:a}){let u={fds:i,stdin:n,stdinBytes:r,stdinFile:o,stdinPiped:s,stdinTerminal:a,stdinOrigin:o?t.stdinOrigin:null,stdinHandle:o?t.stdinHandle:null};return ke(t,{substitutionExit:null,expansionOutput:B(),expansionFds:i},()=>rc(u,t,async()=>{let l=!e.group&&!e.loop&&!e.conditional&&!e.test&&!e.define,c,f;try{l&&(c=await ao(e.words,t),c.argv.length===0?await _6(e.assigns,t):c.temps=await L6(e.assigns,t))}catch(y){f=_s(t,y)}if(f)return U(t.expansionOutput,qy(f,u,t)),{...t.expansionOutput,inputLeft:t.stdinLeft,bytesLeft:t.stdinBytes,halt:f.halt};let d=await N6(e,t,t.stdinLeft,o,i);t.expansionFds=d.fds;let p=!1,h=null,m=await rc(d,t,()=>O6(t,async()=>{if(d.error)return d.error;if(!l){let _=await zy(e,t,d.stdin,To);return p=!0,h=_.blame??null,_}let y=c.argv.length>0?c.argv[0]:null,$=y===null?void 0:t.functions.get(y);if($){if(p=!0,t.calling.has(y)){let _=v("feature",y,"function recursion",`${y}: a function calling itself is not supported`);return t.unsupported.add(C(_)),_}t.calling.add(y);try{return await ke(t,{loopDepth:0},async()=>({...await Hy(c.temps,t,()=>To($,t,{text:d.stdin,bytes:d.stdinBytes})),ignored:!1}))}finally{t.calling.delete(y)}}let S=await C6(t,c);return c.argv.length&&(h=wf(t.registry.chainRole(c.argv),c.argv[0])),S})),g=d.inherited?t.stdinLeft:d.parentLeft,w=d.inherited?t.stdinBytes:d.parentBytes;return U(t.expansionOutput,p?m:qy(m,d,t)),{...t.expansionOutput,inputLeft:g,bytesLeft:w,halt:m.halt,control:m.control,blame:h}}))}function qy(e,t,n){try{return tr(e,t,n)}catch(r){return tr(_s(n,r),t,n)}}async function N6(e,t,n,r,o){let i={...o},s=n,a=r,u=a?t.stdinOrigin:null,l=a?t.stdinHandle:null,c=!0,f=n,d=!1,p=t.stdinTerminal,h=t.stdinBytes,m=h,g=y=>({error:y,fds:i,stdin:s,stdinBytes:h,stdinFile:a,stdinPiped:d||t.stdinPiped,stdinTerminal:p,stdinOrigin:a?u:null,stdinHandle:a?l:null,inherited:c,parentLeft:f,parentBytes:m}),w=async y=>{let $=await ke(t,{expansionFds:i},()=>rc({fds:i,stdin:s,stdinBytes:h,stdinFile:a,stdinOrigin:u,stdinHandle:l},t,y));return s=t.stdinLeft,h=t.stdinBytes,c&&(f=s,m=h),$};try{for(let y of e.redirs)if(y.op==="dup"){if(i[y.toFd]===void 0||i[y.toFd]==="closed")return g(b(`error: ${y.toFd}: Bad file descriptor`));i[y.fd]=i[y.toFd]}else if(y.op==="close")i[y.fd]="closed";else if(y.op==="to"){let $=y.target===void 0?await w(()=>tl(y.word,t)):{value:y.target};if($.error)return g(b(`error: ${$.error}`));let S=$.value==="/dev/null"?"null":$.value==="/dev/stdout"?i[1]:$.value==="/dev/stderr"?i[2]:t.writable?t.fs.openWritable(t.cwd,$.value,y.append):null;if(S===null){let _=ba(y.label,$.value,t.writable);return t.unsupported.add(C(_)),g(b(`error: ${_.message}`))}if(S==="closed")return g(b(`error: ${$.value}: No such file or directory`));i[y.fd]=S,y.both&&(i[2]=S)}else if(y.op==="text")s=y.expand?await w(()=>kn(I6(y.body),t)):y.body,a=!1,c=!1,h=null,p=!1;else if(y.op==="herestring")s=await w(()=>kn(y.word,t))+`
359
+ `,a=!1,c=!1,h=null,p=!1;else{let $=await w(()=>tl(y.word,t)),S=$.error?{error:b(`error: ${$.error}`)}:T6($.value,t,a?u:s);if(S.error)return g(S.error);s=S.content,$.value!=="/dev/stdin"&&(h=S.bytes??null),($.value!=="/dev/stdin"||a)&&(c=!1),$.value!=="/dev/stdin"&&(a=$.value!=="/dev/null",u=a?s:null,l=S.handle,d=a,p=!1)}if(a&&l){let y=t.io.bufferReads(()=>t.fs.readIdentity(l.identity));if(y!==l.content){if(c||s!==l.content)throw new x("feature","modified redirected input","reading an inherited input file after it changes is not supported");s=u=y,l={...l,content:y}}}}catch(y){return g(_s(t,y))}return g()}function _s(e,t){P(e,"shell",t?.path,t?.fsError);let n=C(t);return n&&e.unsupported.add(n),{...b(`error: ${K(t)}`,1),...t?.halt?{halt:!0}:{}}}async function O6(e,t){try{return await t()}catch(n){return _s(e,n)}}function rc(e,t,n){let r={outputFds:e.fds,closed:{out:e.fds[1]==="closed",err:e.fds[2]==="closed"},stdinFile:!!e.stdinFile,stdinPiped:e.stdinPiped??t.stdinPiped,stdinTerminal:e.stdinTerminal??t.stdinTerminal,stdinOrigin:e.stdinOrigin,stdinHandle:e.stdinHandle};return t.stdinLeft=e.stdin,t.stdinBytes=e.stdinBytes??null,ke(t,r,n)}function I6(e){let t="",n="";for(let r=0;r<e.length;r++){let o=e[r],i=e[r+1];if(o==="\\"&&(i==="$"||i==="\\"||i==="`")){t+=i,n+="1",r++;continue}if(o==="`"){let s=kt(e,r);t+=s.raw,n+="2"+"1".repeat(s.raw.length-1),r+=s.raw.length-1;continue}if(o==="$"){let s=Et(e,r,0,!0);if(s?.command!==void 0||s?.parameter!==void 0||s?.arithmetic!==void 0){t+=s.raw,n+="2"+"1".repeat(s.raw.length-1),r+=s.raw.length-1;continue}}t+=o,n+="2"}return{value:t,mask:n}}function T6(e,t,n){if(e==="/dev/null")return{content:""};if(e==="/dev/stdin")return{content:n};let{path:r,error:o}=D(t,"shell",e);if(o)return{error:b(`error: ${e}: ${o}`)};if(t.fs.isFile(r)){let{text:i,bytes:s}=it(t.fs,r),a=i??"";return{content:a,bytes:i===void 0?s:void 0,handle:t.writable&&r.startsWith("/tmp/")?{path:r,content:a,identity:t.fs.fileIdentity(r)}:null}}return{error:b(`error: ${e}: Is a directory`)}}function C6(e,t){let{argv:n}=t;return n.length===0?{stdout:"",stderr:"",exitCode:e.substitutionExit??0}:Hy(t.temps,e,()=>e.invoke(n[0],n.slice(1),e.stdinLeft))}async function _6(e,t){for(let n of e)t.vars.set(n.name,await kn(n.word,t,!0))}async function L6(e,t){if(e.length===0)return null;let n=t.vars,r=new ht(n),o=new Set(e.map(i=>i.name));r.bound=new Set;try{await ke(t,{vars:r},async()=>{for(let i of e){r.expansionTargets=o;let s=await kn(i.word,t,!0);r.expansionTargets=null,r.set(i.name,s)}})}finally{r.expansionTargets=null;for(let i of r.bound)o.has(i)||n.set(i,r.get(i))}return{vars:r,names:o}}async function Hy(e,t,n){if(!e)return n();let r=t.vars,o=new ht(r),i=e.names;for(let s of i)o.set(s,e.vars.get(s));t.vars=o;try{return o.bound=new Set,await n()}finally{t.vars=r;for(let[s,a]of o)(!i.has(s)||o.bound?.has(s))&&r.set(s,a);for(let s of o.unsetNames)i.has(s)||r.delete(s)}}function Xy(e,t={}){let{fs:n,cwd:r,home:o,mount:i,writable:s,locale:a}=Nf(e,t),u=dh(t),l=t.commands===void 0?Ly(u):Cs(t.commands,u),c={fs:n,io:nc(n),mount:i,writable:s,registry:l,createdAt:Date.now(),lock:{turn:Promise.resolve()}};return Vy(Yy(c,{cwd:r,home:o,user:t.user??"user",locale:a,...Zy()}),"createTerminal")}var Zy=()=>({vars:new ht,functions:new Map,lastExit:0,errexit:!1}),F6=e=>({vars:new ht(e.vars),functions:new Map(e.functions),lastExit:e.lastExit,errexit:e.errexit});function R6(e,t={}){let{cwd:n,home:r,user:o,locale:i,inherit:s}=Of(e,t),a=s?F6(e):Zy();return Vy(Yy(e,{cwd:n,home:r,user:o,locale:i,...a}),"fork")}function Yy({fs:e,io:t,mount:n,writable:r,registry:o,createdAt:i,lock:s},a){let u={fs:e,io:t,mount:n,writable:r,registry:o,createdAt:i,lock:s,...a,calling:new Set,outputFds:{1:"out",2:"err"},loopDepth:0,closed:{out:!1,err:!1},stdinFile:!1,stdinPiped:!1,stdinTerminal:!0,stdinOrigin:null,stdinHandle:null,stdinLeft:"",stdinBytes:null,unsupported:Xs(),notes:new Set};return u.dispatch=(l,c,f,{devNull:d=!1}={})=>ke(u,{stdinLeft:u.stdinLeft,stdinBytes:u.stdinBytes,stdinFile:!1,stdinPiped:!1,stdinTerminal:u.stdinTerminal&&!d,stdinOrigin:null,stdinHandle:null},()=>Yt(u,()=>Gy(l,c,f,u,!0))),u.flushOutput=l=>oc(l,u),u.hasCommand=l=>o.has(l)&&!o.shellOnly(l),u.invoke=(l,c,f)=>Gy(l,c,f,u),u.substitute=(l,c)=>Dy(l,u,To,c),u.runLine=l=>Ky(l,u),u}function Vy(e,t){if(!e.fs.isDir(e.cwd))throw new Error(`${t}: cwd is not a directory: ${e.cwd}`);return{run:n=>D6(e,n),cwd:()=>e.cwd,complete:n=>My(n,e,e.registry),fork:n=>R6(e,n)}}async function Gy(e,t,n,r,o=!1){let i=r.registry,s=i.resolveCommand(e),a=()=>{if((o||e!==s)&&i.shellOnly(s))return v("command",e,e,`${e}: shell builtin cannot be invoked as an external command`,127);let l=i.commands[s];return l?l(n,t,r):Fy(e,i)},u=l=>oc(M6(r,_u(e,l,r),s),r);try{return await r.io.run(s,async()=>u(await a()))}catch(l){P(r,e,l?.path,l?.fsError);let c=`${e}: ${K(l)}`,f=C(l);return f&&r.unsupported.add({...f,command:f.command??e,message:c},f.command??s),u(b(c))}}function M6(e,t,n){let r=C(t);return r&&e.unsupported.add(r,n),t}function D6(e,t){let{lock:n}=e,r=n.turn.then(()=>Ky(t,e));return n.turn=r.then(()=>null,()=>null),r}function Ky(e,t){let n=Xs();return ke(t,{unsupported:n,notes:new Set,discarded:new Set,stdinFile:!1,stdinPiped:!1,stdinTerminal:!0,stdinOrigin:null,stdinHandle:null,stdinBytes:null,closed:{out:!1,err:!1},outputFds:{1:"out",2:"err"}},async()=>{let r={stdout:"",stderr:"",exitCode:0},o={text:""};try{for(let i of dd(e,t.writable,t.registry.has)){let s=await To(i,t,o);if(r.stdout+=s.stdout,r.stderr+=s.stderr,r.exitCode=s.exitCode,s.halt||s.control)break}}catch(i){let s=C(i);s&&n.add(s),t.lastExit=i.exitCode??(s?1:2),r.stderr+=`error: ${i.message}
360
+ `,r.exitCode=t.lastExit}return U6(r,t,n)})}var U6=(e,t,n)=>({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,cwd:t.cwd,unsupported:Object.freeze(n.entries),notes:Object.freeze([...t.notes,...ra(t.discarded,e.stderr,t.notes)])});var P6={unified:[[/^--- /u,"bold"],[/^\+\+\+ /u,"bold"],[Rs,"cyan"],[/^\+/u,"green"],[/^-/u,"red"],[/^\\ /u,"gray"]],context:[[Ms,"cyan"],[/^\*{3} \d/u,"cyan"],[/^--- \d/u,"cyan"],[/^\*{3} /u,"bold"],[/^--- /u,"bold"],[/^! /u,"yellow"],[/^\+ /u,"green"],[/^- /u,"red"]],normal:[[Ds,"cyan"],[/^< /u,"red"],[/^> /u,"green"],[/^---$/u,"gray"]]};function z6(e){return e.some(t=>Ms.test(t))?"context":e.some(t=>Rs.test(t))?"unified":e.some(t=>Ds.test(t))?"normal":null}function Jy(e){let t=e.split(`
361
+ `),n=P6[z6(t)];return n===void 0?null:t.map(r=>n.find(([o])=>o.test(r))?.[1]??null)}var B6={bold:"head",cyan:"hunk",green:"add",red:"del",yellow:"chg",gray:"meta"};function Qy(e){let t=Jy(e);return t===null?null:e.split(`
362
+ `).map((n,r)=>({text:n,kind:t[r]===null?"":B6[t[r]]??""}))}function ex({stdout:e,stderr:t,unsupported:n}){return n.filter(r=>!t.includes(r.message)&&!e.includes(r.message)).map(r=>r.message)}var tx=`:host{display:flex;flex-direction:column;position:relative;height:100%;min-height:0;background:var(--bg, #0c0c0c);color:var(--text, #e6edf3);font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:13px;line-height:1.45}.output{flex:1 1 auto;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;padding:var(--terminal-output-padding, 12px 14px 6px);cursor:text}.banner{color:var(--muted, #8b949e);margin-bottom:8px;user-select:none}.banner .cmd{color:var(--accent, #58a6ff)}.banner .cmd:hover{text-decoration:underline}.line{white-space:pre-wrap;overflow-wrap:break-word}.cwd{color:var(--accent, #58a6ff)}.sigil{color:var(--muted, #8b949e)}.stdout,.stderr{margin:0 0 4px;font:inherit;white-space:pre-wrap;overflow-wrap:break-word}.stderr{color:var(--critical, #d8413a)}.diff-head{color:var(--text, #e6edf3);font-weight:600}.diff-hunk{color:var(--accent, #58a6ff)}.diff-add{color:var(--green, #3fb950)}.diff-del{color:var(--critical, #d8413a)}.diff-chg{color:var(--yellow, #d29922)}.diff-meta{color:var(--muted, #8b949e)}.form{flex:0 0 auto;display:flex;align-items:center;padding:var(--terminal-form-padding, 8px 14px 10px);border-top:1px solid var(--border, #2c2c2c)}.form:focus-within{border-top-color:var(--accent, #58a6ff)}.form[aria-busy=true] .sigil{opacity:.4}.form[aria-busy=true] .input{caret-color:transparent}.form .cwd{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none}.form .sigil{flex:0 0 auto;user-select:none;margin:0 1ch}.input-wrap{flex:1 1 auto;min-width:0;position:relative;display:flex;align-items:center}.input{width:100%;background:transparent;border:none;outline:none;color:inherit;font:inherit;padding:0;position:relative}.ghost{position:absolute;inset:0;display:flex;align-items:center;font:inherit;white-space:pre;overflow:hidden;pointer-events:none;user-select:none;color:var(--muted, #8b949e);opacity:.55}.ghost-pad{color:transparent}.notes{position:absolute;top:8px;right:14px;z-index:2;display:flex;flex-direction:column;align-items:flex-end;gap:6px;max-width:min(52%,320px);pointer-events:none}.note{box-sizing:border-box;padding:5px 9px;border:1px solid var(--border, #2c2c2c);border-radius:var(--ui-radius, 5px);background:var(--bg, #0c0c0c);color:var(--muted, #8b949e);font-size:12px;line-height:1.4;text-align:left;overflow-wrap:break-word;animation:note-in .14s ease-out,note-out .4s ease-in var(--dwell-out, 5.6s) forwards}.note-gap{border-color:var(--warning, #d97706);color:var(--text, #e6edf3)}@keyframes note-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}@keyframes note-out{to{opacity:0;transform:translateY(-4px)}}@media(prefers-reduced-motion:reduce){.note{animation:none}}
363
+ `;var sc="/sources",W6={mount:sc,home:"/",writable:"/tmp/"};function q6(e){let n=["ls","find /",`grep -r ${H6(e)} .`];if(!e||e.size===0)return n;let r=null;for(let[o,i]of e){if(typeof i!="string")continue;let s=G6(o);(r===null||s.length<r.length)&&(r=s)}return r&&n.push(`cat ${r} | head -n 20`),n}var ic=["TODO","FIXME","XXX","HACK","NOTE","BUG","export","import","require","//"];function H6(e){if(!e||e.size===0)return ic[0];for(let t of ic)for(let n of e.values())if(typeof n=="string"&&n.includes(t))return t;return ic[0]}function G6(e){return e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e}var ac=class e extends lc{static properties={sources:{attribute:!1},_lines:{state:!0},_input:{state:!0},_cwd:{state:!0},_ghost:{state:!0},_notes:{state:!0},_running:{state:!0}};static styles=uc(tx);#t=null;#s=null;#n=[];#e=-1;#i="";#r=null;#o=null;static#u=200;#a=new Map;#l=0;static#c=3;static#f=400;constructor(){super(),this.sources=null,this._lines=[],this._input="",this._cwd=sc,this._ghost="",this._notes=[],this._running=!1}willUpdate(t){t.has("sources")&&this.sources!==this.#s&&(this.#t=this.sources?Xy(this.sources,W6):null,this._cwd=this.#t?this.#t.cwd():sc,this._lines=[{kind:"banner",commands:q6(this.sources)}],this.#n=[],this.#e=-1,this.#i="",this.#r=null,this._input="",this.#w(),this.#s=this.sources),t.has("_input")&&(this.#g(),this.#y())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#p())}disconnectedCallback(){super.disconnectedCallback(),this.#g(),this.#w()}firstUpdated(){this.#d()}updated(t){(t.has("_lines")||t.has("sources"))&&this.#p()}#d(){let t=this.renderRoot.querySelector(".input");t&&t.focus()}#p(){let t=this.renderRoot.querySelector(".output");t&&(t.scrollTop=t.scrollHeight)}#h=async t=>{if(t.preventDefault(),!this.#t||this._running)return;let n=this._input,r=n.trim();if(r==="clear"){this._lines=[],this.#w(),this._input="",r.length>0&&(this.#n=[...this.#n,n]),this.#e=-1;return}let o=this._cwd;r.length>0&&(this.#n=[...this.#n,n]),this.#e=-1,this._input="";let i;this._running=!0;try{i=await this.#t.run(n)}catch(a){this._lines=[...this._lines,{kind:"prompt",cwd:o,text:n},{kind:"stderr",text:`${a?.message??a}
364
+ `}];return}finally{this._running=!1}this._cwd=i.cwd;let s=[...this._lines,{kind:"prompt",cwd:o,text:n}];i.stdout&&s.push({kind:"stdout",text:i.stdout,diff:Qy(i.stdout)}),i.stderr&&s.push({kind:"stderr",text:i.stderr}),this._lines=s,this.#v(i)};#m=t=>{if(t.key==="Tab"&&!t.shiftKey){t.preventDefault(),this.#b();return}this.#r=null,t.key==="ArrowUp"?(t.preventDefault(),this.#N()):t.key==="ArrowDown"&&(t.preventDefault(),this.#O()),this.#g(),this.#y()};#b(){if(!this.#t)return;let t=this.#r;if(t&&t.items[t.index]===this._input){t.index=(t.index+1)%t.items.length,this._input=t.items[t.index];return}let n=this.#t.complete(this._input);if(n.length===0){this.#r=null;return}this._input=n[0],this.#r=n.length>1?{items:n,index:0}:null}#g(){this._ghost="",this.#o!==null&&(clearTimeout(this.#o),this.#o=null)}#y(){this.#o=setTimeout(()=>{this.#o=null,this.#k()},e.#u)}#k(){if(!this.#t||this.#r)return;let t=this._input,n=t.slice(-1),r=t===""||n===" "||n==="|",o=/[\w./]/u.test(n);if(!r&&!o)return;let i=this.#t.complete(t);if(i.length===0)return;let s=i[0];!s.startsWith(t)||s===t||o&&i.includes(t)||(this._ghost=s.slice(t.length))}#v(t){let n=t.notes.map(r=>({text:r,kind:"note"}));for(let r of ex(t))n.push({text:`silenced: ${r}`,kind:"gap"});this.#E(n)}#E(t){if(t.length===0)return;let n=[...this._notes];for(let{text:r,kind:o}of t){let i=n.findIndex(s=>s.text===r);i!==-1&&this.#x(n,i),n.push({id:++this.#l,text:r,kind:o,dwell:e.#$(r)})}for(;n.length>e.#c;)this.#x(n,0);for(let r of n)this.#a.has(r.id)||this.#a.set(r.id,setTimeout(()=>this.#A(r.id),r.dwell));this._notes=n}static#$(t){return Math.min(1e4,3200+t.length*55)}#x(t,n){let[r]=t.splice(n,1);this.#S(r.id)}#S(t){let n=this.#a.get(t);n!==void 0&&(clearTimeout(n),this.#a.delete(t))}#A(t){this.#a.delete(t),this._notes=this._notes.filter(n=>n.id!==t)}#w(){for(let t of this.#a.values())clearTimeout(t);this.#a.clear(),this._notes=[]}#N(){this.#n.length!==0&&(this.#e<0?(this.#i=this._input,this.#e=this.#n.length-1):this.#e=Math.max(0,this.#e-1),this._input=this.#n[this.#e])}#O(){if(this.#e<0)return;let t=this.#e+1;t>=this.#n.length?(this.#e=-1,this._input=this.#i,this.#i=""):(this.#e=t,this._input=this.#n[t])}#I=t=>{this._input=t.target.value};#T=t=>{this._input=t,this.#e=-1,this.#i="",this.#d()};#C=()=>{let t=this.renderRoot.getSelection?.()??document.getSelection();t&&!t.isCollapsed||this.#d()};render(){return Ge`<div class="notes" role="log" aria-atomic="false">${cc(this._notes,t=>t.id,t=>Ge`<div class="note ${t.kind==="gap"?"note-gap":""}" style="--dwell-out: ${t.dwell-e.#f}ms">${t.text}</div>`)}</div><div class="output" @click="${this.#C}">${this._lines.map(t=>this.#_(t))}</div><form class="form" @submit="${this.#h}" aria-busy="${this._running?"true":"false"}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?Ge`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:Ls} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#I}" @keydown="${this.#m}"></div></form>`}#_(t){return t.kind==="banner"?Ge`<div class="banner">Virtual shell over the bundle source tree. Try ${t.commands.map((n,r)=>Ge`${r>0?", ":""}\`<span class="cmd" @click="${()=>this.#T(n)}">${n}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:t.kind==="prompt"?Ge`<div class="line"><span class="cwd">${t.cwd}</span>${" "}<span class="sigil">$</span>${" "}${t.text}</div>`:t.kind==="stdout"?this.#L(t):t.kind==="stderr"?Ge`<pre class="stderr">${t.text}</pre>`:Ls}#L(t){if(!t.diff)return Ge`<pre class="stdout">${t.text}</pre>`;let n=t.diff.flatMap((r,o)=>{let i=r.kind?Ge`<span class="diff-${r.kind}">${r.text}</span>`:r.text;return o===0?[i]:[`
365
+ `,i]});return Ge`<pre class="stdout">${n}</pre>`}};customElements.define("bundle-terminal",ac);function uW(e,t){let n=document.createElement("bundle-terminal");return n.dataset.integrity=t??"",n.sources=e,n}export{uW as createTerminalElement};