@preventive/triage 1.0.0-alpha.37 → 1.0.0-alpha.39

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 (177) hide show
  1. package/README.md +16 -0
  2. package/common/bundle-compare-diff.d.ts +3 -0
  3. package/common/bundle-compare-diff.js +522 -0
  4. package/common/bundle-compare-inputs.d.ts +2 -0
  5. package/common/bundle-compare-inputs.js +65 -0
  6. package/common/bundle-metadata.d.ts +6 -2
  7. package/common/bundle-metadata.js +63 -20
  8. package/common/bundle-pkg-of.d.ts +1 -0
  9. package/common/bundle-pkg-of.js +90 -0
  10. package/common/bundle-source-links.js +7 -0
  11. package/common/bundle-sourcemap.d.ts +10 -0
  12. package/common/bundle-sourcemap.js +100 -0
  13. package/common/bundle-sources.d.ts +3 -1
  14. package/common/bundle-sources.js +47 -19
  15. package/common/code-language.js +16 -2
  16. package/common/default-scan-models.ts +2 -1
  17. package/common/dependency-reviews.d.ts +23 -0
  18. package/common/dependency-reviews.js +81 -0
  19. package/common/finding-duplicates.js +58 -0
  20. package/common/finding-filters.js +274 -0
  21. package/common/github-pr.ts +1 -1
  22. package/common/gzip.js +59 -0
  23. package/common/line-diff.d.ts +8 -0
  24. package/common/line-diff.js +56 -0
  25. package/common/linked-workspace-groups.js +63 -0
  26. package/common/managed/npm-packages.d.ts +5 -0
  27. package/common/managed/npm-packages.js +34 -0
  28. package/common/managed/permissions.ts +1 -5
  29. package/common/managed/routes.js +123 -12
  30. package/common/managed/team-app.d.ts +2 -0
  31. package/common/managed/team-app.js +31 -0
  32. package/common/managed/triage.ts +1 -1
  33. package/common/managed/upload-seal.ts +126 -0
  34. package/common/pretty-print.d.ts +5 -0
  35. package/common/pretty-print.js +24 -0
  36. package/common/revalidation-conflicts.js +48 -0
  37. package/common/revalidation-input-groups.js +56 -0
  38. package/common/workspace-app.js +23 -0
  39. package/common/workspace-groups.js +176 -0
  40. package/out/brotli-fallback.js +3 -3
  41. package/out/chunk-2KBF5TZ7.js +2 -0
  42. package/out/chunk-2XUEZHIP.js +28 -0
  43. package/out/chunk-35VE6CDH.js +2 -0
  44. package/out/chunk-3BZ7JERB.js +1 -0
  45. package/out/chunk-45WIN3SW.js +1 -0
  46. package/out/chunk-4XCDFGDP.js +10 -0
  47. package/out/chunk-6C76GAXK.js +1 -0
  48. package/out/chunk-7ZKDKGAH.js +1 -0
  49. package/out/chunk-ABW5FVSN.js +1 -0
  50. package/out/chunk-C4Z6ZBXV.js +10 -0
  51. package/out/chunk-CMQA4DM6.js +1 -0
  52. package/out/chunk-CVVJAXVY.js +2 -0
  53. package/out/chunk-DIJJNTRH.js +10 -0
  54. package/out/chunk-F4OMDNEY.js +1 -0
  55. package/out/chunk-GJ4IUCNS.js +1 -0
  56. package/out/chunk-GMFXFEUA.js +2 -0
  57. package/out/chunk-GNXOKIGP.js +80 -0
  58. package/out/chunk-GZ4MS3TE.js +13 -0
  59. package/out/chunk-HIV7SVI7.js +1 -0
  60. package/out/chunk-IU3CCINR.js +3 -0
  61. package/out/chunk-JVBB4LZX.js +1 -0
  62. package/out/chunk-K3X5EJBQ.js +2 -0
  63. package/out/chunk-KEX2ATEW.js +2 -0
  64. package/out/chunk-KYCNJVB7.js +1 -0
  65. package/out/chunk-NRPC74AM.js +1 -0
  66. package/out/chunk-OOJM4CTU.js +1 -0
  67. package/out/chunk-PNHBZGDD.js +1 -0
  68. package/out/chunk-QSLWGJBQ.js +223 -0
  69. package/out/chunk-R5O6FAW4.js +2 -0
  70. package/out/chunk-RFZQQXSG.js +17 -0
  71. package/out/chunk-TINZZKP5.js +33 -0
  72. package/out/chunk-TUII34K2.js +1 -0
  73. package/out/chunk-TZ5KB2Y5.js +10 -0
  74. package/out/chunk-UNTRGE26.js +2 -0
  75. package/out/chunk-UYAXVRVL.js +1 -0
  76. package/out/chunk-V3ME6FI5.js +2 -0
  77. package/out/chunk-V5O7M2YT.js +1 -0
  78. package/out/chunk-VIHGO77Y.js +1 -0
  79. package/out/chunk-W4J3MGLB.js +1 -0
  80. package/out/chunk-WGG7KQUH.js +1 -0
  81. package/out/chunk-XNGEQO7Y.js +2 -0
  82. package/out/chunk-XRWAV3DX.js +7 -0
  83. package/out/chunk-XYDGU6BM.js +51 -0
  84. package/out/chunk-XYFXXB2G.js +10 -0
  85. package/out/chunk-YVZH5SHP.js +1 -0
  86. package/out/chunk-ZPD5R5RP.js +3 -0
  87. package/out/client-managed-import.js +3 -87
  88. package/out/client-managed.js +26 -338
  89. package/out/client-sync.js +8 -14
  90. package/out/graph.js +17 -30
  91. package/out/index.html +34 -0
  92. package/out/prism.js +6 -2
  93. package/out/terminal.js +241 -257
  94. package/out/view.css +1 -1
  95. package/out/view.js +76 -520
  96. package/package.json +89 -7
  97. package/risk/files/characters.js +196 -0
  98. package/risk/files/hosts.js +205 -0
  99. package/risk/files/readability.js +171 -0
  100. package/risk/files/runs-code.js +358 -0
  101. package/risk/files/script.js +114 -0
  102. package/risk/files/stamps.js +46 -0
  103. package/risk/index.d.ts +142 -0
  104. package/risk/index.js +7 -0
  105. package/risk/npm/assess.js +219 -0
  106. package/risk/npm/combined.js +65 -0
  107. package/risk/npm/compare.js +228 -0
  108. package/risk/npm/dependencies.js +153 -0
  109. package/risk/npm/diff.js +43 -0
  110. package/risk/npm/downloads.js +84 -0
  111. package/risk/npm/files.js +34 -0
  112. package/risk/npm/held.js +60 -0
  113. package/risk/npm/install-scripts.js +34 -0
  114. package/risk/npm/malware.js +36 -0
  115. package/risk/npm/manifest.js +65 -0
  116. package/risk/npm/new-dependency.js +30 -0
  117. package/risk/npm/old-version.js +108 -0
  118. package/risk/npm/registry.js +282 -0
  119. package/risk/npm/release.js +85 -0
  120. package/risk/npm/specs.js +124 -0
  121. package/risk/npm/tarball.js +113 -0
  122. package/server-e2e/http.ts +7 -7
  123. package/server-e2e/npm-proxy.ts +1 -1
  124. package/server-e2e/objstore/fetch-mint-guard.ts +2 -2
  125. package/server-e2e/objstore/handlers.ts +1 -1
  126. package/server-e2e/objstore/tokens.ts +1 -1
  127. package/server-e2e/sign.ts +1 -1
  128. package/server-managed/bundle-advisories.ts +74 -12
  129. package/server-managed/bundle-cache.ts +37 -4
  130. package/server-managed/bundle-commits.ts +140 -0
  131. package/server-managed/bundle-summary-cache.ts +24 -10
  132. package/server-managed/config.ts +4 -0
  133. package/server-managed/db-methods.ts +98 -11
  134. package/server-managed/db-neon.ts +39 -4
  135. package/server-managed/db-schema.ts +14 -2
  136. package/server-managed/db-table-names.ts +1 -1
  137. package/server-managed/db.ts +7 -3
  138. package/server-managed/dependency-reviews.ts +248 -0
  139. package/server-managed/github-app.ts +9 -3
  140. package/server-managed/github-errors.ts +21 -2
  141. package/server-managed/github-issue-oauth.ts +5 -6
  142. package/server-managed/github-metadata.ts +115 -0
  143. package/server-managed/github-oauth.ts +38 -2
  144. package/server-managed/http-response.ts +26 -0
  145. package/server-managed/http.ts +952 -53
  146. package/server-managed/index.ts +11 -5
  147. package/server-managed/kept.ts +28 -0
  148. package/server-managed/locked-packages.ts +85 -0
  149. package/server-managed/lru.ts +30 -0
  150. package/server-managed/npm-insights.ts +440 -0
  151. package/server-managed/npm-kept.ts +65 -0
  152. package/server-managed/npm-loads.ts +167 -0
  153. package/server-managed/npm-manifest.ts +115 -0
  154. package/server-managed/npm-packages.ts +378 -0
  155. package/server-managed/npm-provenance.ts +123 -0
  156. package/server-managed/npm-risk.ts +177 -0
  157. package/server-managed/pretty-print.ts +352 -0
  158. package/server-managed/public-workspace.ts +78 -7
  159. package/server-managed/rename-diff-worker.js +26 -0
  160. package/server-managed/rename-diff.ts +270 -0
  161. package/server-managed/report-sources.ts +13 -2
  162. package/server-managed/repository-browser.ts +19 -5
  163. package/server-managed/repository-risk.ts +418 -0
  164. package/server-managed/session.ts +16 -2
  165. package/server-managed/sql.ts +5 -2
  166. package/server-managed/storage-encryption.ts +5 -3
  167. package/server-managed/storage-payload.ts +4 -0
  168. package/server-managed/storage-stores.ts +2 -0
  169. package/server-managed/storage.ts +6 -3
  170. package/server-managed/team-app.ts +94 -0
  171. package/server-managed/team-feed.ts +1 -1
  172. package/server-managed/team-npm-scopes.ts +77 -0
  173. package/server-managed/type-only-worker.js +19 -0
  174. package/server-managed/type-only.ts +103 -0
  175. package/server-managed/uploads.ts +25 -4
  176. package/server-managed/upstream-cache.ts +147 -5
  177. package/server-managed/view-as.ts +58 -0
package/out/terminal.js CHANGED
@@ -1,118 +1,118 @@
1
- var Wx=Object.defineProperty;var qx=(e,t)=>{for(var n in t)Wx(e,n,{get:t[n],enumerable:!0})};var If=globalThis[Symbol.for("@rray/frontend")];if(!If)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:Cf,html:Je,nothing:Xs,unsafeCSS:_f,render:EC,StateElement:vC,classMap:$C,repeat:Lf,styleMap:SC}=If;var Hx={__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"},Gx=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/gu,Xx=e=>`${e}`.replaceAll(Gx,t=>`\\u${t.codePointAt(0).toString(16).padStart(4,"0")}`),qe=(e,t,n="a string")=>new TypeError(`${e} must be ${n}, not ${t===null?"null":typeof t}`),R=class extends Error{constructor(t,n){super(`${Xx(n)}: ${Hx[t]??t}`),this.name="VfsError",this.code=t,this.path=n}};var Ff=(e,t="path")=>{if(typeof e!="string")throw qe(t,e);return e};function Rf(e,t){let n=Math.min(Ff(e).length,Ff(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 vr=e=>[...e.entries.keys()].sort(Rf),Wo=(e,t)=>t===""?e:e==="/"?`/${t}`:`${e}/${t}`;function*un(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=vr(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 Zx=new Set(["error","keep","replace"]);function Mf(e,t,n="'error', 'keep' or 'replace'"){if(typeof e!="string")throw qe(t,e,n);if(!Zx.has(e))throw new RangeError(`${t} must be ${n}, not ${JSON.stringify(e)}`);return e}function Df({clash:e="error",fold:t}){if(typeof e!="function"&&Mf(e,"clash","'error', 'keep', 'replace' or a function"),t!==void 0&&typeof t!="function")throw qe("fold",t,"a function");return{fold:t,settle:typeof e=="function"?(n,r)=>Mf(e(n,r),"what clash returns"):()=>e}}function Uf(e,t,n,{settle:r,fold:o},i){let s=Yx(t,i.copy),a=new Map([[s,{into:e}]]),u=[];for(let{name:l,leaf:f,parent:c,node:d}of un(s,void 0,p=>a.has(p.node))){if(c===void 0)continue;let p=a.get(c),h=p.into.entries.get(f);if(h?.type==="directory"&&d.type==="directory"){a.set(d,{into:h});continue}let m=h===void 0?Vx(p,c,f,o):[f];if(m.length>0){let g=Wo(n,l),w=r(g,m.map(y=>g.slice(0,-f.length)+y));if(w==="error")throw new R("EEXIST",g);if(w==="keep")continue}u.push({dir:p.into,name:f,node:d,taken:m})}for(let{dir:l,name:f,node:c,taken:d}of u){for(let p of un(c))i.number(p.node);for(let p of d)l.entries.delete(p);l.entries.set(f,c)}}function*Pf(e,t,n){for(let{name:r,node:o}of un(e))if(o.type==="directory")for(let i of Map.groupBy(vr(o),s=>n(s)).values())i.length>1&&(yield{path:Wo(t,r),names:i})}function Yx(e,t){let n=new Map;for(let{node:r,parent:o,leaf:i}of un(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 Vx(e,t,n,r){return r===void 0?[]:(e.keys??=Map.groupBy(vr(e.into).filter(o=>!t.entries.has(o)),o=>r(o)),e.keys.get(r(n))??[])}var Kx=40,Jx=255,jf=4096,Qx=new Uint8Array,Wf={file:420,directory:493,symlink:511},eb=new TextEncoder,tb=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),qo=e=>typeof e=="string"&&e.endsWith("/"),Mn=class{#t;#s=0;constructor(){this.#t=this.#e()}#n(t,n,r=Wf[t],o=0){return{ino:++this.#s,type:t,mode:Xo(r),mtime:Zo(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 qe("a path",t);if(t.includes("\0"))throw new R("EINVAL",t);if(t==="")throw new R("ENOENT",t);let i=t.endsWith("/"),s=[zf(t)],a=[{name:"",node:this.#t}],u=Kx,l,f,c,d;for(;;){for(;s.length>1&&Zs(s.at(-1));)s.pop();if(Zs(s.at(-1))){({name:c,node:d}=a.pop()),l=void 0;break}if(f=s.length>1,c=nb(s.at(-1)),c===".")continue;if(c===".."){a.length>1&&a.pop();continue}l=a.at(-1).node;let p=s.every(Zs);if(d=l.entries.get(c),o&&!p&&s.every(Ys)){i=!0;break}if(d===void 0){if(p)break;if(!r||f)throw new R("ENOENT",t);Go(c,t),d=this.#e(),l.entries.set(c,d)}if(d.type==="symlink"&&(!p||n)){if(u--===0)throw new R("ELOOP",t);d.target.startsWith("/")&&(a.length=1),s.push(zf(d.target,!0));continue}if(p){if(i&&!o&&d.type!=="directory")throw new R("ENOTDIR",t);break}if(d.type!=="directory")throw new R("ENOTDIR",t);a.push({name:c,node:d})}return{dir:l,name:c,node:d,trailing:i,chain:a,linked:f}}#r(t,n=!0){let r=this.#i(t,{follow:n});if(r.node===void 0)throw new R("ENOENT",t);return r}#o(t,n){return this.#r(t,n).node}#u(t,n,r){Go(t.name,r),t.dir.entries.set(t.name,n)}#a(t,n){if(t.dir!==void 0)return t.dir;throw new R(Vs(n,0)===n.length?"EBUSY":"EINVAL",n)}#l(t,n,r){try{return this.#o(t,r).type===n}catch(o){if(o instanceof R)return!1;throw o}}stat(t){return Bf(this.#o(t,!0))}lstat(t){return Bf(this.#o(t,qo(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 Ho(this.#r(t))}readFile(t){let n=this.#o(t,!0);if(n.type==="directory")throw new R("EISDIR",t);return n.bytes}readText(t){let n=this.readFile(t);try{return tb.decode(n)}catch{throw new R("EILSEQ",t)}}readlink(t){let n=this.#o(t,qo(t));if(n.type!=="symlink")throw new R("EINVAL",t);return n.target}readdir(t){let n=this.#o(t,!0);if(n.type!=="directory")throw new R("ENOTDIR",t);return vr(n)}#f(t,n,r,o,i){let s=Gf(n,t),a=this.#i(t,{follow:!qo(t),create:!0});if(a.trailing||a.node?.type==="directory")throw new R("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.#f(t,n,(i,s)=>Object.assign(i,{bytes:s,...rb(i,r,o)}),r,o)}appendFile(t,n){this.#f(t,n,(r,o)=>{r.bytes=ib(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 R("ENOENT",t);this.#u(i,this.#e(r,o),t)}else if(!n||i.node.type!=="directory")throw new R("EEXIST",t)}symlink(t,n,{mode:r,mtime:o}={}){if(typeof t!="string")throw qe("a link target",t);if(t===""||t.includes("\0"))throw new R("EINVAL",n);Go(t,n,jf),this.#u(this.#c(n),this.#n("symlink",{target:t,size:qf(t)},r,o),n)}hardlink(t,n){let r=this.#o(t,qo(t)),o=this.#c(n);if(r.type==="directory")throw new R("EPERM",t);this.#u(o,r,n)}#c(t){let n=this.#i(t,{follow:!1,create:!0});if(n.node!==void 0)throw new R("EEXIST",t);if(n.trailing)throw new R("ENOENT",t);return n}unlink(t){this.rm(t)}rmdir(t){let n=this.#r(t,!1);if(n.node.type!=="directory")throw new R("ENOTDIR",t);let r=this.#a(n,t);if(n.node.entries.size>0)throw new R("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 R("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 R("ENOENT",t);Go(o.name,n);let a=r.node.type==="directory";if(!a&&(r.trailing||o.trailing))throw new R("ENOTDIR",r.trailing?t:n);if(o.chain.some(u=>u.node===r.node))throw new R("EINVAL",n);if(r.chain.some(u=>u.node===o.node))throw new R("ENOTEMPTY",n);if(o.node!==r.node){if(o.node!==void 0&&o.node.type==="directory"!==a)throw new R(a?"ENOTDIR":"EISDIR",n);if(o.node?.type==="directory"&&o.node.entries.size>0)throw new R("ENOTEMPTY",n);i.entries.delete(r.name),s.entries.set(o.name,r.node)}}chmod(t,n){this.#o(t,!0).mode=Xo(n)}utimes(t,n){this.#o(t,!0).mtime=Zo(n)}mount(t,n="/",r={}){if(t===null||typeof t!="object"||!(#t in t))throw qe("a tree",t,"a Vfs");let o=Df(r),i=this.#r(n);if(i.node.type!=="directory")throw new R("ENOTDIR",n);Uf(i.node,t.#t,Ho(i),o,{copy:ob,number:s=>{s.ino||=++this.#s}})}walk(t="/"){let n=this.#r(t),r=Ho(n);return un(n.node,({name:o,node:i,depth:s})=>({path:Wo(r,o),type:i.type,depth:s}))}collisions(t,n="/"){if(typeof t!="function")throw qe("fold",t,"a function");let r=this.#r(n);return Pf(r.node,Ho(r),t)}entries(t="/"){let n=this.#r(t),r=n.node.type==="directory"?".":n.name,o=new Map;return un(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:Qx},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})}},zf=(e,t=!1)=>({text:e,at:Vs(e,0),dot:t&&e.endsWith("/")}),Ys=e=>e.at===e.text.length,Zs=e=>Ys(e)&&!e.dot,Vs=(e,t)=>{let n=t;for(;e[n]==="/";)n++;return n};function nb(e){if(Ys(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=Vs(e.text,n),r}var Ho=({chain:e,name:t})=>`/${[...e.slice(1).map(n=>n.name),t].filter(Boolean).join("/")}`,Bf=e=>({type:e.type,ino:e.ino,mode:e.mode,mtime:e.mtime,size:e.bytes?.length??e.size??0}),rb=(e,t=e.mode,n=e.mtime)=>({mode:Xo(t),mtime:Zo(n)});function Go(e,t,n=Jx){if(!e.isWellFormed())throw new R("EILSEQ",t);if(Hf(e,n))throw new R("ENAMETOOLONG",t)}function qf(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 Hf=(e,t)=>e.length>t||e.length*3>t&&qf(e)>t;function Xo(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 Zo(e){if(!Number.isSafeInteger(e))throw new RangeError(`an mtime must be an integer of whole seconds, not ${e}`);return e}function Gf(e,t){if(typeof e=="string"){if(!e.isWellFormed())throw new R("EILSEQ",t);return eb.encode(e)}if(e instanceof Uint8Array)return new Uint8Array(e);throw qe("file contents",e,"a string or a Uint8Array")}function ob({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 ib(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 Yo(e){if(Object.keys(e).length>0)throw new TypeError("Unexpected extra options")}var XC=Object.getPrototypeOf(Uint8Array);var{Buffer:Xf}=globalThis,Yf=Xf&&!Xf.TYPED_ARRAY_SUPPORT;var Vo=new Uint8Array(Uint16Array.of(258).buffer)[0]===2,Zf=e=>e&&(Yf||`${e}`.includes("[native code]"));!Yf&&Zf(()=>{})&&(Zf=()=>!1);function Ks(e,t,n,r){let o="",i=t;for(let s=n-3;i<s;i+=4){let a=e[i],u=e[i+1],l=e[i+2],f=e[i+3];o+=r[a],o+=r[u],o+=r[l],o+=r[f]}for(;i<n;)o+=r[e[i++]];return o}function Js(e,t){let n=e.length;for(let r=0;r<n;r++)t[r]=e.charCodeAt(r);return t}var $r=null,Qe=!1,Vf=!1,Ie=new TextEncoder,Se=new TextDecoder("utf-8",{ignoreBOM:!0}),Qs=new TextDecoder("latin1",{ignoreBOM:!0});function Kf(e,t,n,r){if(n-t>3e4){let o=[];for(let s=t;s<n;){let a=s+500,u=a>n?n:a;o.push(Ks(e,s,u,r)),s=u}let i=o.join("");return o.length=0,i}return Ks(e,t,n,r)}var ea=globalThis.Buffer;function at(e){if(!(e&&e instanceof Uint8Array))throw new TypeError("Expected an Uint8Array")}var Dn="Input is not a string",ta="Input is not well-formed Unicode";function ut(e,t){switch(t){case"uint8":if(e.constructor!==Uint8Array)throw new Error("Unexpected");return e;case"arraybuffer":if(e.byteLength!==e.buffer.byteLength)throw new Error("Unexpected");return e.buffer;case"buffer":return e.length<=64?ea.from(e):ea.from(e.buffer,e.byteOffset,e.byteLength)}throw new TypeError("Unexpected format")}function Jf(e,t){switch(t){case"uint8":return e.length<=64||e.byteOffset!==0||e.byteLength!==e.buffer.byteLength?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case"arraybuffer":return e.buffer.byteLength===e.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);case"buffer":if(e.constructor!==ea)throw new Error("Unexpected");return e}throw new TypeError("Unexpected format")}var ec=globalThis.atob,tc=Uint8Array.prototype.toBase64,Qf=8192,sb=tc&&ec;function na(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return"";if(sb&&r>=256&&r<1e8&&e.toBase64===tc&&e.BYTES_PER_ELEMENT===1){let i=t===0&&n===e.length?e:e.subarray(t,n);return ec(i.toBase64())}if(r>Qf){let i="";for(let s=t;s<n;){let a=Math.min(n,s+Qf);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 Un=$r?e=>e.byteLength>=768&&!Vf?$r.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):Se.decode(e):Qs?e=>Qs.decode(e):e=>na(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var nc=e=>Js(e,new Uint8Array(e.length)),ab=Qe&&Ie?.encodeInto,Sr=ab?(e,t)=>{let n=new Uint8Array(e.length+4),r=Ie.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw new SyntaxError(t);return n.subarray(0,e.length)}:$r?(e,t)=>{let n=$r.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=Ie.encode(e);if(n.length!==e.length)throw new SyntaxError(t);return n};var sa={};qx(sa,{E_CHAR:()=>Pn,E_LAST:()=>ra,E_LENGTH:()=>uc,E_PADDING:()=>ac,fromBase64:()=>ia,toBase64:()=>oa});var rc=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],oc=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],ic={},sc={},Pn="Invalid character in base64 input",ac="Invalid base64 padding",uc="Invalid base64 length",ra="Invalid last chunk";function oa(e,t,n){let r=e.length/3|0,o=r*3,i="",s=0,a=t?oc:rc,u=t?sc:ic;if(!u.pairs)if(u.pairs=[],Se){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:f}=u;if(Se){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=e[s+2],S=e[s+3],I=e[s+4],B=e[s+5],L=e[s+6],V=e[s+7],Q=e[s+8],q=e[s+9],ve=e[s+10],Rn=e[s+11];h[m]=f[w<<4|y>>4],h[m+1]=f[(y&15)<<8|E],h[m+2]=f[S<<4|I>>4],h[m+3]=f[(I&15)<<8|B],h[m+4]=f[L<<4|V>>4],h[m+5]=f[(V&15)<<8|Q],h[m+6]=f[q<<4|ve>>4],h[m+7]=f[(ve&15)<<8|Rn]}for(let g=e.length-2;s<g;s+=3,m+=2){let w=e[s],y=e[s+1],E=e[s+2];h[m]=f[w<<4|y>>4],h[m+1]=f[(y&15)<<8|E]}i=Un(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 c=0,d=2,p=e.length;for(;s<p;s++){let h=e[s];i+=a[c|h>>d],d===6&&(d=0,i+=a[h&63]),c=h<<6-d&63,d+=2}return d!==2&&(i+=a[c]),n&&(i+=["","==","="][p-o]),i}var ub=Ie?128:65536;function ia(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(uc);if(r>3||r!==0&&e.length%4!==0)throw new SyntaxError(ac);let s=t?oc:rc,a=t?sc:ic;a.fromMap||(a.fromMap=new Int8Array(ub).fill(-1),s.forEach((h,m)=>a.fromMap[h.charCodeAt(0)]=m));let u=a.fromMap,l=new Uint8Array(Math.floor(n*3/4)),f=0,c=0;if(Ie){let h=Sr(e,Pn);for(;c<i;c+=4){let m=h[c],g=h[c+1],w=h[c+2],y=h[c+3],E=u[m]<<18|u[g]<<12|u[w]<<6|u[y];if(E<0)throw new SyntaxError(Pn);l[f]=E>>16,l[f+1]=E>>8&255,l[f+2]=E&255,f+=3}}else for(;c<i;c+=4){let h=e.charCodeAt(c),m=e.charCodeAt(c+1),g=e.charCodeAt(c+2),w=e.charCodeAt(c+3),y=u[h]<<18|u[m]<<12|u[g]<<6|u[w];if(y<0)throw new SyntaxError(Pn);l[f]=y>>16,l[f+1]=y>>8&255,l[f+2]=y&255,f+=3}if(o<2)return l;let d=u[e.charCodeAt(c++)]<<6|u[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(Pn);if(l[f++]=d>>4,o<3){if(d&15)throw new SyntaxError(ra);return l}let p=u[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(Pn);if(l[f++]=d<<4&255|p>>2,p&3)throw new SyntaxError(ra);return l}var{Buffer:ln,atob:hc,btoa:mc}=globalThis,gc=ln&&!ln.TYPED_ARRAY_SUPPORT,{toBase64:lc}=Uint8Array.prototype,{E_CHAR:Ar,E_PADDING:Or,E_LENGTH:lb,E_LAST:fb}=sa,cb=mc&&Qe,db=hc&&Qe,pb=e=>e.constructor===ln&&ln.isBuffer(e),hb=e=>pb(e)?e:ln.from(e.buffer,e.byteOffset,e.byteLength);function fc(e,t){if(t)return e;let n=e.indexOf("=",e.length-3);return n===-1?e:e.slice(0,n)}function cc(e,t){return t&&e.length%4!==0?e+"=".repeat(4-e.length%4):e}var mb=e=>lc&&e.toBase64===lc;function Tr(e,{padding:t=!0}={}){return at(e),mb(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):gc?fc(hb(e).base64Slice(0,e.byteLength),t):cb?fc(mc(na(e)),t):oa(e,!1,t)}function Ir(e,t){if(typeof t=="string"&&(t={format:t}),!t)return dc(e,!1,"both","uint8",null);let{format:n="uint8",padding:r="both",...o}=t;return dc(e,!1,r,n,o)}function dc(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Dn);o!==null&&Yo(o);let i=n==="both"?e.endsWith("="):void 0;if(n===!0||i===!0){if(e.length%4!==0)throw new SyntaxError(Or);if(e[e.length-3]==="=")throw new SyntaxError(Or)}else if(n===!1||i===!1){if(e.length%4===1)throw new SyntaxError(lb);if(n===!1&&e.endsWith("="))throw new SyntaxError("Did not expect padding in base64 input")}else throw new TypeError("Invalid padding option");return Nr(e,t,n,r)}var gb=/[\t\n\f\r ]/;function pc(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 Nr;Uint8Array.fromBase64?Nr=(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 gb.test(e)?new SyntaxError(Ar):s}if(!pc(e,i))throw new SyntaxError(Ar);return ut(i,r)}:gc?Nr=(e,t,n,r)=>{let o=ln.byteLength(e,"base64"),i=ln.allocUnsafeSlow(o);if(i.base64Write(e)!==o)throw new SyntaxError(Or);let s=t?i.base64urlSlice(0,i.length):i.base64Slice(0,i.length);if(e!==s){if(n===!t)throw new SyntaxError(Or);if(cc(e,!0)!==cc(s,t))throw new SyntaxError(Or)}return Jf(i,r)}:db?Nr=(e,t,n,r)=>{let o;if(t){if(/[\t\n\f\r +/]/.test(e))throw new SyntaxError(Ar);e=e.replaceAll("-","+").replaceAll("_","/")}try{o=nc(hc(e))}catch{throw new SyntaxError(Ar)}if(!t&&!pc(e,o))throw new SyntaxError(Ar);if(o.length%3!==0){let i=Tr(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(fb)}return ut(o,r)}:Nr=(e,t,n,r)=>ut(ia(e,t),r);var M=(e="")=>({stdout:e,stderr:"",exitCode:0}),b=(e,t=1)=>({stdout:"",stderr:e.endsWith(`
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
2
  `)?e:e+`
3
- `,exitCode:t}),xe=(e,t=1)=>b(`usage: ${e}`,t);var wc=Symbol("unsupported");function C(e){if(e==null)return null;try{return e[wc]??null}catch{return null}}function v(e,t,n,r,o=1){return Z(b(r,o),e,t,n,r)}function Z(e,t,n,r,o){return Object.defineProperty(e,wc,{value:{kind:t,command:n,detail:r,message:o},enumerable:!1,configurable:!0}),e}function ne(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",Z(this,t,null,n,r)}};function aa(){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)))}}}var yb=Se,xb=Se?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):null,{isWellFormed:xc}=String.prototype;function bb(e,t,n){if(t||e.length===n.length)return n;if(xc){if(xc.call(e))return n;throw new TypeError(ta)}let r=0,o=n.length-3;for(;r<=o;){let i=n.indexOf(239,r);if(i===-1||i>o)break;if(r=i+1,n[i+1]===191&&n[i+2]===189){if(null)try{if(encodeURI(e)!==null)return n}catch{}else if(e===ua(n))return n;throw new TypeError(ta)}}return n}function bc(e,t=!1){if(typeof e!="string")throw new TypeError(Dn);return e.length===0?new Uint8Array:Ie||!null?bb(e,t,Ie.encode(e)):null(e,t)}function ua(e,t=!1){return at(e),e.byteLength===0?"":Se||!null?t?yb.decode(e):xb.decode(e):null(e,t)}var fn=(e,t="uint8")=>ut(bc(e,!1),t),_=(e,t="uint8")=>ut(bc(e,!0),t),Cr=e=>ua(e,!1),kc=e=>ua(e,!0);function T(e){try{return fn(e)}catch(t){throw t instanceof TypeError?new x("feature","unpaired surrogate","unpaired UTF-16 surrogates cannot be encoded as UTF-8"):t}}var kb=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Ko(e){for(let t=0;t<e.length;){let n=$c[e[t]],r=n===1?e[t]:n===0?-1:vc(e,t,n);yield r,t+=r<0?1:n}}var Eb=[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<Eb[n]||r>1114111||r>=55296&&r<=57343?-1:r}var fa=e=>kc(e);function $e(e){let t;try{t=Cr(e)}catch{}return t}function ca(e){let t=$e(e);if(t!==void 0)return t;let n=new Uint16Array(e.length),r=0;for(let i=0;i<e.length;){let s=$c[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+=Ec)o+=String.fromCharCode.apply(null,n.subarray(i,Math.min(r,i+Ec)));return o}var Ec=4096,$c=Uint8Array.from({length:256},(e,t)=>kb(t)),cn="\\uDC80-\\uDCFF",zn=new RegExp(`[${cn}]`,"u"),Bt=e=>e>=56448&&e<=56575;function da(e){if(!zn.test(e))return T(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(Bt(o))t[n++]=o-56320;else if(o<2048)n=la(t,n,192|o>>6,o,1);else if(o<65536){if(o>=55296&&o<=57343)return T(e);n=la(t,n,224|o>>12,o,2)}else n=la(t,n,240|o>>18,o,3),r++}return t.slice(0,n)}function la(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 et(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 X(e){try{return Cr(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 Bn(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 H(e,t){return t.startsWith("/")?Bn(t):Bn(e+"/"+t)}var vb=40,Jo=(e,t)=>e.isLink?.(t)===!0;function $(e,t,n,{follow:r=!0}={}){let o=lt(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 lt(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=vb,u="/";for(;i.length>0;){let f=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:[f,...i]}}f===".."?u=se(u):f!=="."&&(u=he(u,f));continue}if(f===".."){u=se(u);continue}if(f!=="."&&(u=he(u,f)),!Jo(n,u)||i.length===0&&!s)continue;if(a--===0)return{path:u,error:"Too many levels of symbolic links",rest:[...i]};let c=n.readLink(u);u=c.startsWith("/")?"/":se(u),i.unshift(...c.split("/").filter(Boolean),...c.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")?H(t,n):lt(t,n,e,{follow:r,lenient:!0}).path;function $t(e,t,n,r=$(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=lt(e,t,n);return o.rest.length>0?o.error:n.isDir(se(o.path))?null:"Not a directory"}function se(e){let t=Bn(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return n<0?".":n===0?"/":t.slice(0,n)}function Ce(e){let t=Bn(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return t.slice(n+1)}function G(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 ft(e,t){return e==="/"?t.slice(1):t.slice(e.length+1)}function jt(e,t,n="reading them as text"){let r=$e(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 _r=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r]);function*ct(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,f=a.length-1,c=u.length-1;for(;l>=0||f>=0||c>=0;){let d=l>=0?"dir":null,p=l>=0?s[l]:null;f>=0&&(p===null||G(a[f],p)>=0)&&(d="file",p=a[f]),c>=0&&(p===null||G(u[c],p)>=0)&&(d="link",p=u[c]),d==="dir"?l--:d==="file"?f--:c--,o.push({path:he(i.path,p),kind:d,depth:i.depth+1})}}}function*Sc(e,t){for(let n of ct(e,t))n.kind==="file"&&(yield n.path)}function Ic(e,t="/"){let n=new Mn;try{n.mkdir(t,{recursive:!0})}catch(o){throw pa(o,`mount ${JSON.stringify(t)}`)}let r={declared:new Map,made:new Set(["/",t])};for(let[o,i]of Ob(e)){let s=String(o);if(s.includes("\0"))throw new TypeError("createTerminal: source paths must not contain NUL characters");let a=Ib(i,s),u=Bn("/"+s);$b(n,r,t==="/"?u:u==="/"?t:t+u,a,s)}return Ab(n)}function $b(e,t,n,r,o){let i=t.declared.get(n);if(i!==void 0){if(i===r.type&&Sb(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"?Ac(o):pa(a?.code==="EEXIST"?new R("ENOTDIR",s):a,`source ${JSON.stringify(o)}`)}if(e.realpath(s)!==s)throw Ac(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 pa(a,`source ${JSON.stringify(o)}`)}}var Ac=e=>new TypeError(`createTerminal: source ${JSON.stringify(e)} is declared through a symbolic link; declare it where the link leads`);function pa(e,t){return e instanceof R?new TypeError(`createTerminal: ${t}: ${e.message}`,{cause:e}):e}function Sb(e,t,n){return n.type==="directory"?!0:n.type==="symlink"?e.readlink(t)===n.target:_r(e.readFile(t),typeof n.data=="string"?T(n.data):n.data)}var Cc={directory:"dirs",file:"files",symlink:"links"},Qo=e=>e.slice(0,e.lastIndexOf("/"))||"/",ha=()=>({dirs:[],files:[],links:[]});function Ab(e){let t=null,n=null,r={children:new Map,types:new Map},o=()=>n??=Nb(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:ha(),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[Cc[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(Qo(h))&&!r.types.has(h);)p.push(h),h=Qo(h);let m=s(Qo(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(Qo(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),f=d=>u(d)==="file"?e.readFile(d):void 0,c={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=f(d),h=p&&i.get(p);return p&&h===void 0&&i.set(p,h=jt(p,JSON.stringify(d))),h},readBytes:d=>f(d),fileSize:d=>{let p=l(d);return p===void 0||p.type==="directory"?void 0:p.size},sameFileContents:(d,p)=>_r(f(d),f(p)),exactBytes:f,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=>Sc(c,d)};return c}function Nb(e,t){let n=new Map([["/",ha()]]),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,ha()),n.get(u)[Cc[s]].push(i.slice(u.length+(u==="/"?0:1))),r.set(i,s))}return{children:n,types:r}}function Ob(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}var Nc={file:["data"],directory:[],symlink:["target"]},Tb=new Set(["mode","mtime"]);function Ib(e,t){let n=JSON.stringify(t);if(typeof e=="string")return{type:"file",data:Oc(e,t)};if(ArrayBuffer.isView(e))return{type:"file",data:Tc(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:Cb(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(Nc,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"||Nc[r].includes(i)))throw new TypeError(Tb.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:Oc(o,t)};if(ArrayBuffer.isView(o))return{type:r,data:Tc(o,t)};throw new TypeError(`createTerminal: source ${n} declares \`data\` that is neither text nor a Uint8Array`)}function Oc(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 Cb(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 Ir(e.data)}catch(o){throw o instanceof SyntaxError?new TypeError(`createTerminal: source ${n} declares base64 that does not decode`,{cause:o}):o}}function Tc(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 dn={__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_"},Lr={__proto__:null};for(let[e,t]of Object.entries(dn)){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])}Lr[e]=r}var ei=32767;function _c(e,t){if(e>ei||t!==void 0&&t>ei)throw new Error("Regular expression too big")}function ti(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],f=e.indexOf(l+"]",r+2);if(f===-1)throw new Error("Unmatched [, [^, [:, [., or [=");if(l===":"&&!(e.slice(r+2,f)in dn))throw new Error("Invalid character class name");if(l!==":"&&n&&/\P{ASCII}/u.test(e.slice(r+2,f)))throw new Error("Invalid collation character");r=f+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,f=e[l]==="["?e[l+1]:void 0;if(f===":"||f==="=")throw new Error("Invalid range end");let c=f==="."?e.indexOf(".]",l+2):-1;if(f==="."&&c===-1)throw new Error("Unmatched [, [^, [:, [., or [=");let d=f==="."?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=c===-1?l+(e[l]==="\\"?2:1):c+2,i=!0;continue}r+=a,i=!1}throw new Error("Unmatched [, [^, [:, [., or [=")}function jn(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]):dn[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 ni={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"},Lc="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",Fc="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 ae="C.UTF-8",ri="only the C.UTF-8 locale is supported",ga=e=>typeof e=="string"&&/^C\.UTF-?8$/iu.test(e),_b=new Set(["LANG","LC_ALL","LC_CTYPE"]);function Dc(e){if(e.locale===void 0||ga(e.locale))return ae;throw new TypeError(`createTerminal: ${ri} (got ${JSON.stringify(e.locale)})`)}function Uc(e,t){if(!(_b.has(e)?ga(t)||e!=="LANG"&&t==="":ga(t)||t==="C"||t==="POSIX"||t===""))throw new x("feature",e,`${e}: ${ri}`)}var oi=e=>e==="C"||e==="POSIX",re=e=>oi(e.locale);function Rc(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 Lb(e){let t=e.findIndex(([n])=>n>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function ma(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 Fb=e=>e.map(([t,n])=>t===n?ma(t):`${ma(t)}-${ma(n)}`).join("");function Rb(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 ii=e=>e==="upper"||e==="lower"?"alpha":e,Mb=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],pn=/[\u1C80-\u1C88]/u;function Mc(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 Pc=(e,t)=>({up:e,low:t,folds:new Map});function Db(){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 Pc(e,t)}function Ub(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 wa(e){let t=`[${e}]`;return{"<":`(?<!${t})(?=${t})`,">":`(?<=${t})(?!${t})`,boundary:`(?:(?<!${t})(?=${t})|(?<=${t})(?!${t}))`,inside:`(?:(?<=${t})(?=${t})|(?<!${t})(?!${t}))`}}function zc(e,t,n,r,o){let i=new Map,s=new Map,a=null,u=c=>(s.has(c)||s.set(c,n(c)),s.get(c)),l=()=>a??=o(),f={name:e,multibyte:t,ranges:u,body(c){return i.has(c)||i.set(c,r(c,u(c))),i.get(c)},has(c,d){let p=u(c);return p!==void 0&&Rb(p,d)},assertions(){if(f.js)return f.js;let c=f.body("space");return f.js={__proto__:null,...wa(f.body("word")),word:`[${f.body("word")}]`,nonWord:`[^${f.body("word")}]`,space:`[${c}]`,nonSpace:`[^${c}]`},f.js},up:c=>l().up.get(c)??c,low:c=>l().low.get(c)??c,fold(c){let{folds:d}=l(),p=d.get(c);if(p===void 0){let h=f.up(c),m=f.low(h),g=new Set([c,h]);m!==h&&f.up(m)===h&&g.add(m);for(let w of Mb)f.up(w)===h&&g.add(w);p=[...g].sort((w,y)=>w-y),d.set(c,p)}return p},foldRange(c,d){let{up:p}=l(),h=p.get(c)??c,m=p.get(d)??d;if(h>m)return null;let g=[],w=[];for(let[S,I]of p){let B=S>=h&&S<=m;B!==(I>=h&&I<=m)&&(B?g:w).push(S)}let y=[],E=h;for(let S of g.sort((I,B)=>I-B))S>E&&y.push([E,S-1]),E=S+1;return E<=m&&y.push([E,m]),Ub([...y,...w.map(S=>[S,S])])}};return f}var Pb=zc("C",!1,e=>Lr[e],e=>dn[e],Db),zb=zc(ae,!0,e=>e==="word"?Lb(Rc(ni.alnum)):Object.hasOwn(ni,e)?Rc(ni[e]):void 0,(e,t)=>t===void 0?void 0:Fb(t),()=>Pc(Mc(Lc),Mc(Fc)));function ue(e){if(e===ae)return zb;if(oi(e))return Pb;throw new x("feature","locale",`matching in the ${e} locale is not supported`)}var ge=(1n<<63n)-1n,St=-ge-1n,At=(1n<<64n)-1n;function U(e,t,n,r){let o=$(e.cwd,n,e.fs,r);return z(e,t,n,o.error),o}function z(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 f of new Set(["/",e.mount??"/",e.home??"/"])){if(f===i)continue;let c=$(f,s,e.fs);c.error||a.add(c.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}. ${Bb(e,a)}`)}function Bb(e,t){let n=[...t].sort(G),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 Wn(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(".")&&e.add(H(t,r))},emit(t,n,r,o=""){Wt(t,{command:n,action:"omitted",noun:["hidden entry","hidden entries"],explanation:r,context:o,paths:e})}}}var Bc=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function jc(e,t){for(let n of t.split(`
4
- `))Bc.test(n)&&e.discarded?.add(n)}function ya(e,t,n){let r=new Map;for(let o of e){if(t.includes(o))continue;let{command:i,operand:s,reason:a}=Bc.exec(o).groups,u=/'([^']*)'$/u.exec(s)?.[1]??s;if([...n].some(f=>f.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 Wc(e,t){return e==="status"?null:{name:t,search:e==="search"}}function qc(){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 Wt(e,t){jb(e,t,t.paths.size,t.paths)}function jb(e,{command:t,action:n,noun:r,explanation:o="",context:i=""},s,a){if(!s)return;let u=s<10?": "+[...a].sort(G).map(f=>JSON.stringify(f)).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 Fr(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 Ae=(e,t=`
7
- `)=>e.length===0?"":e.join(t)+t;function dt(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 hn=e=>e.stdinTerminal===!0,Nt=e=>(e.outputFds?.[1]==="out"||e.outputFds?.[1]==="err")&&!e.substitutionDepth;function j(e,t="",n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&jt(e.stdinBytes,qn(null,e)),e.stdinLeft=t,e.stdinBytes=r}function Ot(e,t,n,r="",o={}){let i=[],s="",a=r,u=o.read??"text",l=u==="bytes"||u==="loose-bytes",f=l?"bytes":"content",c=p=>l?u==="loose-bytes"?_(p):T(p):p,d=(p,h)=>{if(l){p.bytes=ce(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"?$e(p.bytes):void 0};for(let p of t){let h={name:p,[f]:c(""),kind:"file"},m;if(p==="/dev/stdin"&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),h[f]=c(n.stdinOrigin);else if(p==="-"||p==="/dev/stdin"){let g=a===r?n.stdinBytes??null:null;Object.assign(h,g===null?Hc(a,u,l):Gc(g,u,l,e,n)),h.shared=!0,a="",j(n,"",!0)}else if(p!=="/dev/null"){let g=U(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=xa(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 Wb={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 xa(e,t,n,r=!1){let o=Wb[e]?.[r?1:0],i=o?o.replace(/%[sr]/gu,s=>s==="%s"?t:n):`${t}: ${n}`;return`${e}: ${i}
9
- `}function ce(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?_(o):T(o)}function pt(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:$e(n),bytes:n}}function le(e,t,n,r,o){if(t.length===0){let i=r.stdinBytes??null;j(r,"",!0);let s=o?.read,a=s==="bytes"||s==="loose-bytes",u=[{name:null,kind:"file",...i===null?Hc(n,s,a):Gc(i,s,a,e,r)}];return{inputs:u,entries:u,stderr:"",failed:!1}}return Ot(e,t,r,n,o)}var Hc=(e,t,n)=>n?{bytes:t==="loose-bytes"?_(e):T(e)}:{content:e};function Gc(e,t,n,r,o){return n||t==="as-held"?{bytes:e}:t==="maybe-text"?{bytes:e,content:$e(e)}:{content:jt(e,qn(null,o))}}function qn(e,t){return e===null||e==="-"||e==="/dev/stdin"?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):"standard input":JSON.stringify($(t.cwd,e,t.fs).path??e)}function Xc(e,t,n,r){let o=le(e,t,n,r);return{content:o.inputs.map(i=>i.content).join(""),stderr:o.stderr,failed:o.failed}}var fe=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:t.failed?1:0});function _e(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 Zc(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=ba(BigInt(o?.[1]??"1"),s,t,e);return a.error?a:{...a,sign:n}}function ba(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>At?{error:b(`${n}: count out of range: ${r}`)}:{value:Number(i>BigInt(Number.MAX_SAFE_INTEGER)?BigInt(Number.MAX_SAFE_INTEGER):i)}}function ee(e){try{let t=e?.message;return typeof t=="string"&&t!==""?t:String(e)}catch{return"threw a value with no message"}}var te=e=>e==="/tmp"||e.startsWith("/tmp/"),Yc=new Uint8Array;function Kc(e){e.vfs.mkdir("/tmp",{recursive:!0}),e.writableAt("/tmp");let t=qb(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),X(ka(e.vfs,o))),readFile:o=>(n(o),e.readFile(o)),readBytes:o=>(n(o),e.readBytes(o)),openWritable:(o,i,s=!1)=>Gb(r,t,o,i,s),makeWritableDir:(o,i)=>Xb(r,t,o,i),makeWritableLink:(o,i,s)=>Zb(r,t,o,i,s),removeWritableDir:(o,i)=>Jb(r,t,o,i),copyWritable:(o,i,s)=>Yb(r,t,o,i,s),replaceWritable:(o,i,s,a)=>Vb(r,t,o,i,s,a),removeWritable:(o,i)=>Kb(r,t,o,i)};return r}function qb(e){let{vfs:t}=e,n=new Map;return{base:e,vfs:t,observer:void 0,identity:r=>{if(!te(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 R?tt(r,Hb(i.code)):i}finally{e.reshaped()}}}}var Hb=e=>new R(e,"").message.slice(2),ka=(e,t)=>t.detached??e.readFile(t.path);function Gb(e,t,n,r,o){let i=me(e,n,r);if(!te(i))return null;Rr(e,n,r);let s=t.identity(i);return s===void 0?(t.change(r,()=>t.vfs.writeFile(i,Yc)),s=t.identity(i)):o||(t.observer?.write(s),t.vfs.writeFile(i,Yc)),e2(t.vfs,i,s,o,()=>t.observer?.write(s))}function Xb(e,t,n,r){let o=me(e,n,r,!1);if(!te(o))return!1;if(e.isDir(o))return!0;if(Rr(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 Zb(e,t,n,r,o){let i=me(e,n,r,!1);return i.startsWith("/tmp/")?(Qb(e,n,r),t.change(r,()=>t.vfs.symlink(o,i)),!0):!1}function Yb(e,t,n,r,o){let i=me(e,n,o);if(!i.startsWith("/tmp/"))return!1;Rr(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 Vb(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(Rr(e,n,r),!e.isFile(s)&&!e.isLink(s))throw tt(r,"No such file or directory");a!==null&&Rr(e,n,i);let u=T(o),{vfs:l}=t;return t.change(r,()=>{if(a!==null&&a!==s){let f=t.leaving(s),c=t.leaving(a);l.rename(s,a),t.release(c),f&&(f.cell.path=a)}else{let f=t.leaving(s);l.unlink(s),t.release(f)}l.writeFile(s,u)}),!0}function Kb(e,t,n,r){let o=me(e,n,r,!1);if(!te(o))return!1;let i=$(n,r,e,{follow:!1});if(i.error)throw tt(r,i.error);if(e.isDir(i.path))throw new Error(`${r}: Is a directory`);if(!te(i.path))return!1;let s=t.leaving(i.path);return t.change(r,()=>t.vfs.unlink(i.path)),t.release(s),!0}function Jb(e,t,n,r){let o=me(e,n,r,!1);if(!te(o))return!1;let i=$(n,r,e);if(i.error)throw tt(r,i.error);if(!te(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 Rr(e,t,n){let r=lt(t,n,e);if(r.error===null){if(e.isDir(r.path))throw new Error(`${n}: Is a directory`);if(n.endsWith("/"))throw tt(n,"Not a directory");return}if(r.rest.length>0||n.endsWith("/")||n.includes("\0"))throw tt(n,r.error);if(!e.isDir(se(r.path)))throw tt(n,"No such file or directory")}function Qb(e,t,n){if(n===""||n.includes("\0"))throw tt(n,"No such file or directory");let r=lt(t,n,e,{follow:!1});if(r.error===null)throw tt(n,"File exists");if(r.rest.length>0||n.endsWith("/"))throw tt(n,r.error);if(!e.isDir(se(r.path)))throw tt(n,"Not a directory")}function tt(e,t){return Object.assign(new Error(`${e}: ${t}`),{path:e,fsError:t})}function e2(e,t,n,r,o){let i=0,s=a=>{let u=ka(e,n),l=r?u.length:i;n.detached!==void 0?n.detached=Vc(u,l,a):l===u.length?e.appendFile(n.path,a):e.writeFile(n.path,Vc(u,l,a)),i=l+a.length};return{path:t,identity:n,get position(){return r?ka(e,n).length:i},write(a){a!==""&&(o(),s(T(a)))},writeBytes(a){a.length!==0&&(o(),s(a))}}}function Vc(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 Jc=["cwd","home","user","inherit"];function Qc(e,t){let n=Mr(t,"mount","/"),r=Mr(t,"home",n),o=Mr(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=Ic(e,n);return{fs:i?Kc(s):s,cwd:o,home:r,mount:n,writable:i,locale:Dc(t)}}function ed(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(!Jc.includes(n))throw new Error(`fork: unknown option \`${n}\` (known: ${Jc.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:Mr(t,"cwd",e.cwd,"fork",e.cwd),home:Mr(t,"home",e.home,"fork",e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function Mr(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 H(o,i)}function Le(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 Dr(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 td=(e,t)=>e.mask===null?"0":e.mask[t];function nd(e,t=!1){let n=new Set;if(!e.value.includes("~"))return n;let r=e.value,o=a=>td(e,a)==="0",i=t?null:Dr(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)||!t2(e,a,l))continue;let f=r[a+1];if(f&&f!=="/"&&f!==":"&&o(a+1))throw new x("feature","tilde prefix","named-user and directory-stack tilde prefixes are not supported");(f===void 0||o(a+1)&&(f==="/"||f===":"&&l))&&n.add(a)}return n}function t2(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(td(e,r)!=="0")return!1;if(e.value[r]==="/"||n&&e.value[r]===":")return!0}return!0}function rd(...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 Hn=64;function Tt(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 od=()=>({value:"",quoted:!1,started:!1}),id=()=>new x("feature","command substitution depth",`command substitution nesting above ${Hn} is not supported`);function Ea(e,t,n,r,o){if(r>=Hn)throw id();let i={line:e,i:n+1,depth:r,helpers:o,parens:0,quote:null,word:od(),command:!0,target:null,heredocs:[]};for(;i.i<e.length;)if(n2(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 qt(e,t,n=!1){e.word.value+=t,e.word.quoted||=n,e.word.started=!0}function va(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=od()}}function n2(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 qt(e,o,!0),e.i++,!1;if(o==="\\")return r2(e),!1;if(o==="$")return o2(e),!1;if(o==="`")return i2(e),!1;if(r)return qt(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(`
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
11
  `,n);return e.i=s===-1?t.length:s,!1}if(o===`
12
- `)return a2(e),!1;if(o===" "||o===" ")return va(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?s2(e,i):(qt(e,o),e.i++,!1)}function r2(e){let t=e.line[e.i+1];if(t===`
13
- `){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(qt(e,t,!0),e.i+=2):(qt(e,"\\",!!e.quote),e.i++)}function o2(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);qt(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??"$";qt(e,i,!!e.quote),e.i+=i.length}function i2(e){let t=e.i++;for(;e.i<e.line.length;){let n=e.line[e.i++];if(n==="`"){qt(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 s2(e,t){va(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>=Hn)throw id();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 a2(e){if(va(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 ht(e){return Number.isInteger(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)}var nt=e=>e>65535?2:1,He=(e,t)=>nt(e.codePointAt(t)),Gn=e=>`(?:^|(?<=[^]))(?:${e})`;var u2=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])(?![\s\S])/u,l2=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])/u;function mn(e,t="unsupported or malformed parameter expansion"){return new x("feature","${",`${t}: \${${e}}`)}var $a=e=>/^[0-9]+$/u.test(e)?e.replace(/^0+(?=[0-9])/u,""):e;function Sa(e){let t=e.replaceAll(`\\
14
- `,"");if(t.startsWith("#")&&t.length>1&&u2.test(t.slice(1)))return{name:$a(t.slice(1)),operator:"length"};if(/^#[A-Za-z_0-9]/u.test(t))throw mn(e);let n=l2.exec(t)?.[0];if(!n)throw mn(e);let r=t.slice(n.length);if(!r)return{name:$a(n),operator:""};if(n==="#"&&/^[%:=+/]$/u.test(r))throw mn(e);let o=/^(?::[-+=?]|[-+=?]|##?|%%?|:|\/\/?)/u.exec(r)?.[0];if(!o)throw mn(e);return{name:$a(n),operator:o,word:e.slice(f2(e,n.length+o.length))}}function f2(e,t){let n=0;for(;t>0;)e[n]==="\\"&&e[n+1]===`
15
- `?n+=2:(t--,n++);return n}var Ht=(e,t)=>new x("feature",e,t),sd=e=>{if(e>=64)throw Ht("expansion depth","shell expansion nesting above 64 levels is not supported")};function ad(e,t,n,r,o,i){sd(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 Ht("`","command substitution (backticks) is not supported");if(l==="$"){let f=u+1;for(;e[f]==="\\"&&e[f+1]===`
16
- `;)f+=2;if(e[f]==="'"&&!a){let d=i.decodeAnsiC(e,f+1),p=Sa(e.slice(s,u)).operator;if(o&&/[-+?=]/u.test(p)&&/[$`"'\\}]/u.test(d.text))throw Ht("${","active characters in ANSI-C quoted parameter operands are not supported");u=d.end-1;continue}let c=i.readExpansion(e,u,r+1,o||a==='"');if(c){u+=c.raw.length-1;continue}}if(l==="}"&&!a){let f=Sa(e.slice(s,u));return{raw:e.slice(t,u+1),parameter:f}}}throw Ht("${","unterminated parameter expansion")}function ud(e,t,n,r,o){sd(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 Ht("`","command substitution (backticks) is not supported");if(a==='"'||a==="'")throw Ht("$((","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 Ht("$((","arithmetic expansion requires a closing `))`");return{raw:e.slice(t,u+1),arithmetic:e.slice(n+1,s)}}throw Ht("$((","unterminated arithmetic expansion")}var c2=/^-[abcdefghknoprstuvwxzGLNORS]$/u,d2=new Set(["=","==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]),p2=new Set(["end","&&","||",")"]),h2=/^[A-Za-z_][A-Za-z0-9_]*$/u;function Ur(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{mt(o,!0);let i=dd(o);return o.token.kind!=="end"&&Gt(`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;Gt(i.message)}}function dd(e){let t=ld(e);for(;e.token.kind==="||";)mt(e,!0),t={kind:"or",left:t,right:ld(e)};return t}function ld(e){let t=Aa(e);for(;e.token.kind==="&&";)mt(e,!0),t={kind:"and",left:t,right:Aa(e)};return t}function Aa(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==="("){mt(e,!0);let o=dd(e);return e.token.kind!==")"&&Gt("expected `)`"),mt(e,!0),o}if(pd(t,"!"))return mt(e,!0),{kind:"not",expression:Aa(e)};if(t.kind!=="word"&&Gt("expected an operand"),mt(e),!t.quoted&&c2.test(t.value)){let o=fd(e);return mt(e,!0),{kind:"unary",op:t.value,word:o}}if(p2.has(e.token.kind))return{kind:"unary",op:"-n",word:t};let n=e.token;if((n.quoted||!d2.has(n.value))&&Gt("conditional binary operator expected"),n.value==="=~")throw new x("feature","[[ =~","regular expression comparisons in [[ are not supported");mt(e);let r=fd(e);return mt(e,!0),{kind:"binary",op:n.value,left:t,right:r}}finally{e.depth--}}var pd=(e,t)=>e.kind==="word"&&!e.quoted&&e.value===t,Gt=e=>{throw Object.assign(new Error(`[[ ${e}`),{conditional:!0})};function fd(e){return e.token.kind!=="word"&&Gt("expected an operand"),e.token}function mt(e,t=!1){if(e.token=cd(e),t)for(;e.token.kind==="newline";)e.token=cd(e)}function cd(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]===`
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
18
  `){e.i+=2;continue}if(t==="#"){let o=e.line.indexOf(`
19
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=m2(e);return pd(r,"]]")?{kind:"end"}:r}Gt("missing `]]`")}function m2(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==="'"){Ge(t,o,"1"),e.i++;continue}if(o==="\\"){g2(e,t,n);continue}if(o==="$"){if(w2(e),!n&&e.line[e.i+1]==='"'){n='"',r=t.value.length,e.i+=2;continue}y2(e,t,n);continue}if(o==="`"){let i=Tt(e.line,e.i);Ge(t,"`",n?"2":"0"),Ge(t,i.raw.slice(1),"1"),e.i+=i.raw.length;continue}if(n){Ge(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;Ge(t,o,"0"),e.i++}return n&&Gt(`unterminated ${n==="'"?"single":"double"} quote`),!t.quoted&&!/[12]/u.test(t.mask)&&(t.mask=null),t.empty.length===0&&delete t.empty,t}function Ge(e,t,n,r=n!=="0"){e.value+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function g2(e,t,n){let r=e.line[e.i+1];if(r===`
21
- `){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(Ge(t,r,"1"),e.i+=2):(Ge(t,"\\",n?"2":"1"),e.i++)}function w2(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 y2(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),Ge(t,i.text,"1"),e.i=i.end;return}let o=e.helpers.readExpansion(e.line,e.i,e.expansionDepth+1,!!n);if(!o){Ge(t,"$","1"),e.i++;return}if(o.command!==void 0||o.parameter!==void 0||o.arithmetic!==void 0)Ge(t,"$",r),Ge(t,o.raw.slice(1),"1",!1);else{let i=e.line[e.i+o.raw.length],s=h2.test(o.name)&&(i==="'"||i==='"')?"${"+o.name+"}":o.raw;Ge(t,s,r)}e.i+=o.raw.length}var gn=/^[A-Za-z_][A-Za-z0-9_]*$/u,x2=/[A-Za-z0-9_]/u,b2=/[?#@*$!0-9-]/u;function ye(e,t){for(;e[t]==="\\"&&e[t+1]===`
23
- `;)t+=2;return t}function Na(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(b2.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)&&x2.test(e[i]);)i++;return{name:e.slice(t+1,i),raw:e.slice(t,i)}}function Ct(e,t,n=0,r=!1,o={}){let i=(u,l,f,c)=>Ct(u,l,f,c,o),s=ye(e,t+1),a=e[s];if(a==="("){let u=ye(e,s+1);if(e[u]==="(")return ud(e,t,u,n,{readExpansion:i});let l=Ea(e,t,s,n,{readExpansion:i,decodeAnsiC:Xn,readHeredocBodies:zr,readOperator:si,readConditional:Ur,skipContinuations:ye});return o.validateSubstitution?.(l.command),l}if(a==="{")return ad(e,t,s,n,r,{readExpansion:i,decodeAnsiC:Xn});if(a==="[")throw new x("feature","$[","arithmetic expansion (`$[\u2026]`) is not supported");return Na(e,t)}function gd(e,t,n={}){let r=(s,a,u,l)=>Ct(s,a,u,l,n),o=ye(e,t+1),i=Ea(e,t,o,0,{readExpansion:r,decodeAnsiC:Xn,readHeredocBodies:zr,readOperator:si,readConditional:Ur,skipContinuations:ye});return n.validateSubstitution?.(i.command),i}var hd={a:"\x07",b:"\b",e:"\x1B",E:"\x1B",f:"\f",n:`
24
- `,r:"\r",t:" ",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function k2(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 Xn(e,t){let n=k2(e,t),r=[],o=s=>{for(let a of _(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 hd){o(hd[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],f=/^[0-7]/u.test(l),c=f?parseInt(l,8):parseInt(l.slice(1),16);if(f||l[0]==="x")r.push(c&255);else{if(!ht(c))throw new x("feature","ANSI-C Unicode escape","ANSI-C escapes outside Unicode scalar values are not supported");o(String.fromCodePoint(c))}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:X(Uint8Array.from(i===-1?r:r.slice(0,i))),end:n+1}}function si(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:md(e,a,Number(s))}let o=ye(e,t+1),i=e[o];switch(r){case"|":return i==="|"?It("or",o+1):i==="&"?It("pipe_err",o+1):It("pipe",t+1);case"&":if(i==="&")return It("and",o+1);if(i===">"){let s=ye(e,o+1),a=e[s]===">";return Xt(1,a?"bothAppend":"both",(a?s:o)+1)}return It("amp",t+1);case";":return i===";"?It("dsemi",o+1):It("semi",t+1);case"(":return It("paren_open",t+1);case")":return It("paren_close",t+1);case"<":case">":return md(e,t,r==="<"?0:1);default:return null}}var E2={semi:";",dsemi:";;",pipe:"|",pipe_err:"|&",and:"&&",or:"||",amp:"&",paren_open:"(",paren_close:")"},v2={write:">",append:">>",read:"<",heredoc:"<<",herestring:"<<<",both:"&>",bothAppend:"&>>",dup:">&",close:">&-"};function Pr(e){if(e.kind==="word")return e.quoted?`"${e.value}"`:e.value;if(e.kind==="redir"){let t=v2[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 E2[e.kind]}var It=(e,t)=>({token:{kind:e},end:t}),Xt=(e,t,n,r)=>({token:{kind:"redir",fd:e,op:t,...r},end:n});function md(e,t,n){let r=e[t],o=ye(e,t+1),i=e[o];if(i==="&")return $2(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 Xt(n,"herestring",s+1);let a=e[s]==="-";return Xt(n,"heredoc",(a?s:o)+1,{strip:a,delim:null,body:null})}return Xt(n,"read",t+1)}return i===">"?Xt(n,"append",o+1):Xt(n,"write",(i==="|"?o:t)+1)}function $2(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 Xt(n,"dup",o+1,{toFd:Number(i)});if(i==="-"&&a)return Xt(n,"close",o+1);throw new x("feature","redirect target",`redirect \`${r}\` requires a file descriptor number (or \`-\`) followed by a token boundary`)}function zr(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||!S2(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(`
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
26
  `)+`
27
27
  `,s||(o.warning=`warning: here-document delimited by end-of-file (wanted \`${o.delim}')
28
- `)}return r-1}function S2(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t++;return t%2===1}var A2=new Set(["semi","amp","and","or","pipe","pipe_err","paren_open"]),N2=e=>e===" "||e===" ";function ai(e,t={}){return xd(Oa(e,t),!1).tokens}function yd(e,t={}){let n=Oa(e,t);return{read:()=>xd(n,!0),reset:()=>{n.tokens=[]}}}function xd(e,t){for(;e.i<e.line.length;){let n=e.line[e.i];if(e.quote&&n===e.quote){bd(e),e.i++;continue}if(e.quote==="'"){be(e,n,"1"),e.i++;continue}if(n==="\\"){kd(e);continue}if(n==="$"){vd(e);continue}if(n==="`"){$d(e);continue}if(e.quote){be(e,n,"2"),e.i++;continue}if(n==="'"||n==='"'){Ia(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]??"")&&I2(e.tokens)){let i=Ur(e.line,e.i,{readExpansion:e.readExpansion,decodeAnsiC:Xn});wd(e,{kind:"condition",expression:i.expression}),e.i+=i.raw.length;continue}if(n==="#"&&!r){_2(e);continue}if(n===`
29
- `){if(L2(e),t)return{tokens:e.tokens,done:e.i>=e.line.length};continue}if(N2(n)){Br(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)]==="("){C2(e);continue}let o=si(e.line,e.i,!r);if(o?.token.kind==="paren_open"&&(o.token.wordAdjacent=r),o){Br(e),wd(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 Br(e),e.heredocs.length>0&&zr(e.line,e.line.length,e.heredocs),{tokens:e.tokens,done:!0}}function Oa(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)=>Ct(n,r,o,i,t),readProcess:(n,r)=>gd(n,r,t)}}function Ta(e,t=!1){let n={...Oa(e),fragment:!0,fragmentQuoted:t};for(;n.i<n.line.length;){let r=n.line[n.i];if(n.quote&&r===n.quote){bd(n),n.i++;continue}if(n.quote==="'"){be(n,r,"1"),n.i++;continue}if(r==="\\"){kd(n);continue}if(r==="$"){vd(n);continue}if(r==="`"){$d(n);continue}if(n.quote){be(n,r,"2"),n.i++;continue}if(r==='"'||r==="'"&&!t){Ia(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 Br(n),n.tokens[0]??{value:"",mask:t?"":null}}var O2=new Set(["semi","and","or","pipe","pipe_err","amp","paren_open"]),T2=new Set(["!","{","if","then","else","elif","while","until","do"]);function I2(e){let t=!0,n=null,r=!1;for(let o of e){let i=O2.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||!T2.has(o.value))&&(t=!1)}return t&&!r}function Ia(e,t){e.quoteStart=e.cur.length,e.quote=t}function bd(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 Br(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 wd(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 kd(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 Ed(e,t){let n=ye(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function vd(e){Ed(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=Xn(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==='"'){Ia(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=gn.test(o.name)&&(i==='"'||i==="'")?"${"+o.name+"}":o.raw;be(e,s,n),e.i+=o.raw.length}function C2(e){Ed(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 $d(e){let t=e.quote==='"'||e.fragmentQuoted?"2":"0",{raw:n}=Tt(e.line,e.i);be(e,"`",t),be(e,n.slice(1),"1",!1),e.i+=n.length}function _2(e){for(;e.i<e.line.length&&e.line[e.i]!==`
31
- `;)e.i++}function L2(e){Br(e),e.heredocs.length>0&&(e.i=zr(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!A2.has(t.kind)?e.tokens.push({kind:"semi",newline:!0}):(t?.kind==="semi"||t?.kind==="amp")&&(t.lineEnd=!0),e.i++}function ui(e,t,n){let r={aliases:new Set(t),hasCommand:n};return Zt(e,r),r.aliases}var jr=(e,t)=>new Set([...e,...t]);function Zt(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?F2(s,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=jr(i,t.aliases),n=null)}return n}function F2(e,t){if(e.group)return Zt(e.group,t);if(e.conditional)return R2(e.conditional,t);if(e.loop){if(e.loop.condition&&Zt(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let o=new Set(t.aliases);Zt(e.loop.body,t),t.aliases=jr(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 R2(e,t){let n=new Set;for(let r of e.branches){let o=Zt(r.condition,t);if(o===0)return Zt(r.body,t),t.aliases=jr(n,t.aliases),null;if(o===null){let i={...t,aliases:new Set(t.aliases)};Zt(r.body,i),n=jr(n,i.aliases)}}return e.otherwise&&Zt(e.otherwise,t),t.aliases=jr(n,t.aliases),null}var gt=class extends Error{constructor(t){super(t.message),this.finalError=t}},Yt=e=>new gt(new Error(e));function Fe(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 Sd(e,t,n){let r=t.validation??new Map;return{validateSubstitution(o){r.has(o)||(Ca(o,!0,e,{validation:r,syntaxOnly:!0},n),r.set(o,!0))}}}function Ca(e,t,n,r,o){try{return o(ai(e,Sd(n,r,o)),t,n,r)}catch(i){throw i instanceof gt?i.finalError:i}}function M2(e,t,n,r){let o=yd(e,Sd(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=ui(u,i,n),o.reset(),{steps:u,done:a.done}}}function*Ad(e,t,n,r){let o=M2(e,t,n,r);for(;;){let i;try{i=o()}catch(s){throw s instanceof gt?s.finalError:s}if(i.steps.length>0&&(yield i.steps),i.done)return}}var D2=["elif","else","fi"];function Od(e,t){let n=[],r;do{wt(e);let i=t(e,"then");wt(e);let s=t(e,D2);n.push({condition:i,body:s}),r=e.raw[e.i-1].value}while(r==="elif");let o=null;return r==="else"&&(wt(e),o=t(e,"fi")),{branches:n,otherwise:o}}function Td(e,t){let{raw:n}=e,r=e.loop;e.loop="for";let o=Fe(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||!gn.test(i))throw new Error(`for: \`${i}\` is not a valid variable name`);e.i++;let s=Fe(e);s?.kind==="semi"&&e.i++;let a=Fe(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 gt(d):d}throw new Error(`for: expected \`in\` after \`${i}\``)}e.i++;let u=[],l=!1;for(let d;(d=Fe(e))&&d.kind!=="semi";e.i++){if(d.kind!=="word")throw new Error(`for: unexpected \`${Pr(d)}\` in word list`);Zn(d,"do")&&(l=!0),u.push(Le(d))}n[e.i]?.kind==="semi"&&e.i++;let f=Fe(e);if(!Zn(f,"do"))throw f===void 0?Yt(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 \`${Pr(f)}\``);e.i++,wt(e);let c={name:i,words:u,body:t(e,"done")};return e.loop=r,c}function Id(e,t,n){let r=e.loop;e.loop=t,wt(e);let o=n(e,"do");wt(e);let i={until:t==="until",condition:o,body:n(e,"done")};return e.loop=r,i}function Cd(e,t,n){if(t.quoted||!gn.test(t.value))throw new x("feature","function",`shell functions named \`${t.value}\` are not supported`);e.i+=2,wt(e);let r=Fe(e);if(!Zn(r,"{"))throw new x("feature","function",`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,wt(e);let o=n(e,"}");if(!wn(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 wn=e=>e.every(t=>t.stages.every(U2));function U2(e){return e.assigns.length>0||e.define?!1:e.test?li(e.test)&&e.redirs.every(Nd):e.group?wn(e.group):e.conditional?e.conditional.branches.every(t=>wn(t.condition)&&wn(t.body))&&wn(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(Yn)&&wn(e.loop.condition??[])&&wn(e.loop.body):e.words.every(Yn)&&e.redirs.every(Nd)}function li(e){return e.kind==="and"||e.kind==="or"?li(e.left)&&li(e.right):e.kind==="not"?li(e.expression):e.kind==="unary"?Yn(e.word):Yn(e.left)&&Yn(e.right)}var Nd=e=>e.op==="text"?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||Yn(e.word);function Yn(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 wt(e){for(let t;(t=Fe(e))?.kind==="semi"&&t.newline;)e.i++}function Zn(e,t){return e!==void 0&&e.kind==="word"&&!e.quoted&&e.value===t}var Dd=(e,t=!1,n=()=>!1,r={})=>Ca(e,t,n,r,Pd),Ud=(e,t=!1,n=()=>!1)=>Ad(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=Fe(o)?yn(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 gt?new gt(s):s}throw i}}function La(e,t,n){t.stages.push(n),!fi(n)&&!Fa(n)&&(e.emptyStage=!0)}var Fa=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,fi=e=>e.group||e.loop||e.conditional||e.test||e.define,_d=()=>({words:[],assigns:[],redirs:[]}),_a=e=>({gate:e,stages:[],negate:!1,bang:!1}),Ld=(e,t)=>e.bang&&e.stages.length===0&&Vn(t)&&t.redirs.length===0,Vn=e=>!fi(e)&&e.words.length===0&&e.assigns.length===0,P2=new Set(["for","while","until","do","done","if","{","}","!"]),z2=new Set(["then","else","elif","fi","esac","in"]),Fd=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"]]),B2=new Set(["alias","declare","typeset","local","readonly","export","eval","let"]),j2=new Set(["pipe","pipe_err","and","or","semi","amp"]),Rd=new Set(["semi","amp"]);function yn(e,t){let{raw:n}=e,r=[_a("first")];t===null&&(e.unit=r[0]);let o=0,i=_d();for(let s;s=Fe(e);){if(s.kind==="condition"){if(!Vn(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++,Md(e,r,i,t)}if(s.kind==="paren_open"){W2(e,i);continue}if(j2.has(s.kind)){if(s.kind==="pipe_err"&&(Fa(i)||fi(i))&&i.redirs.push({fd:2,op:"dup",toFd:1}),s.kind==="semi"&&Ld(r.at(-1),i)||La(e,r.at(-1),i),s.kind==="amp"&&(r.at(-1).background=!0),i=_d(),s.kind==="and"||s.kind==="or"?r.push(_a(s.kind)):Rd.has(s.kind)&&r.push(_a("seq")),t===null&&(s.newline||s.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=ui(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=Z2(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&&Vn(i)){if(Array.isArray(t)?t.includes(s.value):s.value===t)return e.i++,Md(e,r,i,t);if(q2(s,e,r.at(-1),i))continue}let a=i.words.length===0?Dr(s):null;a===null?i.words.push(Le(s)):i.assigns.push({name:a.name,word:Le(s,a.end)}),e.i++}if(t===")")throw Yt("unmatched `(`");if(t==="}")throw Yt("unmatched `{`");if(t==="do"||t==="done")throw Yt(`${e.loop}: missing \`${t}\``);if(t)throw Yt(`if: missing \`${t==="then"?"then":"fi"}\``);if(!e.emptyStage&&!fi(i)&&!Fa(i)&&["and","or","pipe","pipe_err"].includes(n.at(-1)?.kind))throw Yt("empty pipeline stage");return Rd.has(n.at(-1)?.kind)?r.pop():Ld(r.at(-1),i)||La(e,r.at(-1),i),r}function W2(e,t){let{raw:n,i:r}=e,o=Fe(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&&B2.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&&Vn(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=Cd(e,t.words.pop(),yn);return}if(!Vn(t))throw new Error("unexpected `(`");e.i++,t.group=yn(e,")"),t.isolate=!0}function q2(e,t,n,r){let o=e.value;if(Fd.has(o))throw new x("feature",o,Fd.get(o));if(z2.has(o))throw new Error(`syntax error near unexpected token \`${o}\``);if(!P2.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 wt(t),r.group=yn(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=Od(t,yn):r.loop=o==="for"?Td(t,yn):Id(t,o,yn),!0}var H2={")":"empty subshell `()`","}":"empty group `{ }`"},G2=(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 Md(e,t,n,r){let o=t.at(-1),i=Vn(n)&&n.redirs.length===0&&o.stages.length===0;if(i&&t.length===1)throw new Error(H2[r]??G2(e,r));if(i&&o.bang)throw new Error("syntax error near unexpected token after `!`");return i&&o.gate==="seq"?t.pop():La(e,o,n),t}var X2=new Set(["/dev/null","/dev/stdout","/dev/stderr"]);function Z2(e){let t=e.raw[e.i++],n=Pr(t);if(e.syntaxOnly){if(!["dup","close"].includes(t.op)){let a=Fe(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=Fe(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:Le(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=Le(r);if(Y2(s))return{fd:t.fd,op:"to",word:s,both:o,append:i,label:n};if(!e.writable&&!X2.has(s.value))throw Ra(n,s.value,e.writable);return{fd:t.fd,op:"to",target:s.value,both:o,append:i,label:n}}function Y2(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 Ra(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 V2=/^[a-zA-Z0-9][\w.+-]*$/u,Ma=["run","pipe","hidden"],Da=["stdout","stderr","exitCode"];function Bd(e,t){let n={__proto__:null},r=[],o=[];for(let[i,s]of K2(e)){let{run:a,pipe:u,hidden:l}=J2(i,s,t);l&&r.includes(i)||(n[i]=(f,c,d)=>Q2(i,a,f,c,d),!l&&(r.push(i),u&&o.push(i)))}return{handlers:n,names:r,pipeNames:o}}function K2(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 J2(e,t,n){if(typeof e!="string")throw new TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!V2.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(Ma.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(!Ma.includes(o))throw new Error(`createTerminal: ${e}: unknown option \`${o}\` (known: ${Ma.join(", ")})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function Q2(e,t,n,r,o){o.io?.bufferOutput(),j(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:ek(i),readInputs:(f=[])=>{if(typeof f=="string")throw new TypeError(`readInputs: expected an array of paths, got a string: ${f}`);return le(e,[...f],n,i)},run:f=>{if(!s)throw new Error("run: the command this belongs to has finished, and its turn with it");return o.runLine(f)}},l=t(u);return typeof l?.then!="function"?(a(),zd(l)):l.then(zd).finally(a)}function ek(e){let t=n=>$(e.cwd,n,e.fs).path;return{resolve:n=>H(e.cwd,n),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:n=>e.fs.isLink?.($(e.cwd,n,e.fs,{follow:!1}).path)===!0,readLink:n=>e.fs.readLink?.($(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=>ce(e.fs,t(n))?.slice(),listDir:n=>{let{path:r,error:o}=U(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 zd(e){if(e==null)return M();if(typeof e=="string")return M(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(!Da.includes(i))throw new TypeError(`invalid result: unknown field \`${i}\` (known: ${Da.join(", ")})`);if(t.length===0)throw new TypeError(`invalid result: an object with none of ${Da.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(`
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
32
  `)?r:r+`
33
- `,exitCode:o}}var Ne=new Uint8Array(0),Wr=e=>e.every(t=>t<128),ci=(e,t)=>e.length===t.length&&e.every((n,r)=>n===t[r]);function yt(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 Kn(e,t){try{return e()}catch(n){throw!(n instanceof k)||n.offset!==void 0?n:new k(n.message,t)}}var Jn=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 Be(e){try{return[new CompressionStream(e),new DecompressionStream(e)].every(Boolean)}catch{return!1}}async function*tk(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 nk(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 Ua(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]:yt(a);try{for await(let f of tk(new Blob([e]).stream().pipeThrough(s).pipeThrough(nk(r))))i===void 0?a.push(f):i.set(f,u),u+=f.length}catch(f){let c=f instanceof RangeError;throw new Jn(c?`the data ${o}es past ${r} bytes`:`the data does not ${o}`,{bytes:l(),limited:c,cause:f})}return l()}var Xe=(e,t,{limit:n=1/0}={})=>Ua(e,CompressionStream,t,n,"compress"),Pa=(e,t,{limit:n=1/0}={})=>Ua(e,DecompressionStream,t,n,"decompress"),jd=(e,t,n)=>Ua(e,DecompressionStream,t,n.length,"decompress",n);var _t=e=>e.type==="directory"?`${e.name}/`:e.name,di=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 pi(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 rk=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/u,ok=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\\]/u,Vt=(e,t)=>(t?ok:rk).test(e);function xn(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 ik(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 hi=(e,t)=>e.length>t||e.length*3>t&&ik(e)>t;function Kt(e,t){try{return fn(e)}catch{throw new k(`${t} is not well-formed Unicode`)}}function Ze(e,t,n){try{return Cr(e)}catch{throw new k(`${t} is not valid UTF-8`,n)}}var Qn={file:420,directory:493,symlink:511},za=e=>e==="file"||e==="contiguous-file",mi=e=>e.type==="directory"?`${e.name}/`:e.name;function gi(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;xn(r,"entry name");let o=e.data??Ne;if(!(o instanceof Uint8Array))throw new k(`data of ${O(r)} is not a Uint8Array`);if(o.length!==0&&!za(n))throw new k(`a ${n} cannot carry data (${O(r)})`);let i=e.linkname??"";if(xn(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 Oe=512,er=e=>e==="character-device"||e==="block-device",bn={file:48,hardlink:49,symlink:50,"character-device":51,"block-device":52,directory:53,fifo:54,"contiguous-file":55},tr={pax:120,global:103,longname:76,longlink:75},Re=100,nr=155,kn=32,Wd=0,qd=[["mode",100,8],["uid",108,8],["gid",116,8],["size",124,12],["mtime",136,12]],yi=148,Hd=156,Gd=157,ja=257,Xd=265,Zd=297,Yd=329,Vd=337,Kd=345,sk=386,ak=495,Jd="ustar\x0000",Qd="ustar \0",Wa=e=>Uint8Array.from(e,t=>t.codePointAt(0)),ep=e=>String.fromCodePoint(...e),Jt=(e,t,n,r)=>e.subarray(t,t+n).set(r),qa=e=>8**(e-1)-1,Ha=(e,t)=>e>=0&&e<=qa(t);function Ba(e,t,n,r,o){if(Ha(r,n)){Jt(e,t,n,Wa(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 wi(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(ep(xi(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 xi(e){let t=e.indexOf(0);return t===-1?e:e.subarray(0,t)}var qr=(e,t,n)=>xi(e.subarray(t,t+n));function tp(e){let t=256;for(let n=0;n<yi;n++)t+=e[n];for(let n=yi+8;n<Oe;n++)t+=e[n];return t}var Hr=e=>e.every(t=>t===0);function Ga(e){let t=new Uint8Array(Oe);Jt(t,Wd,Re,e.name);for(let[n,r,o]of qd)Ba(t,r,o,e[n],e.gnu);return t[Hd]=e.typeflag,Jt(t,Gd,Re,e.linkname),Jt(t,ja,8,Wa(e.gnu?Qd:Jd)),Jt(t,Xd,kn-1,e.uname),Jt(t,Zd,kn-1,e.gname),e.devmajor!==null&&Ba(t,Yd,8,e.devmajor,e.gnu),e.devminor!==null&&Ba(t,Vd,8,e.devminor,e.gnu),Jt(t,Kd,nr,e.prefix),Jt(t,yi,8,Wa(`${tp(t).toString(8).padStart(6,"0")}\0 `)),t}function np(e,t){if(tp(e)!==wi(e,yi,8,"checksum",t))throw new k("header checksum does not match",t);let n=ep(e.subarray(ja,ja+8)),r=n===Qd;if(!r&&n!==Jd)throw new k("header is not in the ustar, pax or gnu format",t);if(r&&!Hr(e.subarray(sk,ak)))throw new k("header carries an old GNU sparse map or real size",t);let o=e[Hd],i=o===bn["character-device"]||o===bn["block-device"];return{gnu:r,typeflag:o,name:qr(e,Wd,Re),prefix:r?Ne:qr(e,Kd,nr),linkname:qr(e,Gd,Re),uname:qr(e,Xd,kn),gname:qr(e,Zd,kn),...Object.fromEntries(qd.map(([s,a,u])=>[s,wi(e,a,u,s,t,s==="mtime")])),devmajor:i?wi(e,Yd,8,"devmajor",t):0,devminor:i?wi(e,Vd,8,"devminor",t):0}}var bi=4096,rp=255;function sp(e,t){if(xn(e,t),e==="")throw new k(`${t} is empty`);if(Vt(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(hi(e,bi))throw new k(`${t} ${O(e)} is longer than ${bi} bytes`);for(let r of n)if(hi(r,rp))throw new k(`${t} ${O(e)} has a segment longer than ${rp} bytes`);return n}function op(e,t,n=!1){let r=sp(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(hi(s,bi-(n?1:0)))throw new k(`${t} ${O(e)} is longer than ${bi} bytes`);return s}function ap(e,t){let n=sp(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=op(e,"entry name",t==="directory"),o=n;return t==="symlink"?ap(r,n):t==="hardlink"&&(o=op(n,`hard link target of ${O(r)}`)),{name:r,linkname:o}}var up=()=>({kind:void 0,entry:void 0,symlink:void 0,first:void 0,firstNode:void 0,rest:void 0});function Xa(e,t,n=!0){if(e.first===t)return e.firstNode;let r=e.rest?.get(t);return r!==void 0||!n||(r=up(),e.first===void 0?(e.first=t,e.firstNode=r):(e.rest??=new Map,e.rest.set(t,r))),r}var ip=["type","mode","uid","gid","mtime","uname","gname","linkname","devmajor","devminor"],xt=class{#t=up();#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=ip.find(f=>a.entry[f]!==t[f]);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(!ci(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(ip.map(l=>[l,t[l]])),r==="symlink"&&this.#n(n,t.linkname,`symlink ${O(n)}`)}#n(t,n,r){let o=ap(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(Xa(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(Xa(n.at(-1),r));return n}#r(t){let n=this.#t;for(let r of t.split("/"))if(n=Xa(n,r,!1),n===void 0)return;return n}};function uk(e,t){let n=fn(` ${e}=${t}
34
- `),r=String(n.length).length,o=n.length+r+(String(n.length+r).length>r?1:0);return yt([fn(String(o)),n])}var lp=e=>yt(e.map(([t,n])=>uk(t,n))),Za="pax records cannot be changed",Gr=class extends Map{set(){throw new TypeError(Za)}delete(){throw new TypeError(Za)}clear(){throw new TypeError(Za)}},lk=(e,t,n)=>Map.prototype.set.call(e,t,n);function Ya(e,t){let n=new Gr;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=Ze(e.subarray(o+1,a),"a pax record",t);if(u===""||Vt(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);lk(n,u,Ze(e.subarray(a+1,s-1),"a pax record",t)),r=s}return n}var fk=new Set(["gnu","ustar","pax"]),fp=47;function rr(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 cp(e,t){if(xn(e,t),Vt(e,!1))throw new k(`${t} ${O(e)} holds a control or formatting character`);return e}function ck(e){let t=gi(e,bn),{name:n,type:r}=t,o=rr(e.devmajor??0,"devmajor"),i=rr(e.devminor??0,"devminor");if((o!==0||i!==0)&&!er(r))throw new k(`a ${r} cannot have device numbers (${O(n)})`);let s=rr(e.mode??Qn[r]??420,"mode");if(s>4095)throw new k(`mode ${s.toString(8)} has bits beyond the permission bits`);return{...t,mode:s,uid:rr(e.uid??0,"uid"),gid:rr(e.gid??0,"gid"),mtime:rr(e.mtime??0,"mtime",!0),uname:cp(e.uname??"","uname"),gname:cp(e.gname??"","gname"),devmajor:o,devminor:i}}function pp(e,t=e.length){let n=new Uint8Array(Math.ceil(t/Oe)*Oe);return n.set(e),n}var hp=(e,t,n,r,o)=>Ga({gnu:o,name:Kt(e,"header name").subarray(0,Re),prefix:Ne,linkname:Ne,uname:Ne,gname:Ne,typeflag:r,mode:420,uid:0,gid:0,size:t,mtime:n,devmajor:null,devminor:null}),dp=(e,t)=>[hp("././@LongLink",e.length+1,0,t,!0),pp(e,e.length+1)];function dk(e,t){let n=lp(t),r=e.name.lastIndexOf("/"),o=r===-1?`./PaxHeaders/${e.name}`:`${e.name.slice(0,r)}/PaxHeaders/${e.name.slice(r+1)}`;return[hp(o,n.length,Math.max(0,Math.min(e.mtime,qa(12))),tr.pax,!1),pp(n)]}function pk(e,t){let{length:n}=e;if(n>nr+Re+1)throw new k(`name ${O(t)} is longer than 256 bytes, which ustar cannot hold`);let r=n;r>nr+1?r=nr+1:e[r-1]===fp&&r--;let o=r-1;for(;o>0&&e[o]!==fp;)o--;let i=n-o-1;if(o===0||i>Re||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 hk(e,t){let n=t==="gnu",r=[],o=[],i=mi(e),s=Kt(i,"entry name"),a=Ne,u=Kt(e.linkname,`link target of ${O(e.name)}`);if(u.length>Re){if(n)o.push(...dp(u,tr.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,Re)}t==="pax"&&(s.length>Re||!Wr(s))&&r.push(["path",i]),s.length>Re&&(n?o.push(...dp(s,tr.longname)):t==="ustar"&&({prefix:a,name:s}=pk(s,e.name)),s.length>Re&&(s=s.subarray(0,Re)));let l=(h,m,g)=>{if(n||Ha(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`)},f=(h,m)=>{let g=Kt(m,h);if(g.length<kn&&(t!=="pax"||Wr(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,kn-1)},c=er(e.type),d={gnu:n,name:s,prefix:a,linkname:u,typeflag:bn[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:c?l("devmajor",e.devmajor,8):null,devminor:c?l("devminor",e.devminor,8):null,uname:f("uname",e.uname),gname:f("gname",e.gname)};r.length&&o.push(...dk(e,r)),o.push(Ga(d));let p=e.data.length%Oe;return e.data.length&&o.push(e.data),p&&o.push(new Uint8Array(Oe-p)),o}function mk({format:e="gnu",blocking:t=20}={},n=!1){if(!fk.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 xt(n),o=0;return{add(i){let s=ck(i),a={...s,...Qt(s.name,s.type,s.linkname)};r.add(a);let u=hk(a,e);for(let l of u)o+=l.length;return u},end(){let i=t*Oe,s=(o+2*Oe)%i;return[new Uint8Array(2*Oe+(s?i-s:0))]}}}function Va(e,t){let n=mk(t,!0),r=[];for(let o of e)r.push(...n.add(o));return yt([...r,...n.end()])}var yp=e=>Object.entries(e).map(([t,n])=>[n,t]),gk=new Map([...yp(bn),[0,"file"]]),wk=new Map(yp(tr)),yk=1<<20,xk=new Set(["SCHILY.realsize","SUN.holesdata"]);function mp(e,t){for(let n of e)if(n.startsWith("GNU.sparse.")||xk.has(n))throw new k("sparse entries are not supported",t)}function bk(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 kk(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 gp=()=>({pax:null,longname:null,longlink:null}),wp=new Gr,Ka=class{#t=[];#s=0;#n=0;#e=0;#i;#r=gp();#o=null;#u=null;#a=0;#l=!1;constructor(t=!1){this.#i=new xt(t)}push(t){if(!(t instanceof Uint8Array))throw new k("a chunk is not a Uint8Array");if(this.#l)return this.#c(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)}#f(t){if(this.#n<t)return null;if(t===0)return Ne;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}#c(t,n){if(!Hr(t))throw new k("data after the end of the archive",n)}#d(){let t=this.#f(Oe);if(t===null)return!1;let n=this.#e-Oe;if(Hr(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.#c(this.#f(this.#n),i)}return!0}if(this.#a)throw new k("a lone zero block where a header should be",n);let r=np(t,n),o=wk.get(r.typeflag);if(o===void 0)this.#u={extended:null,at:n,...this.#h(r,n)};else{if(r.size>yk)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/Oe)*Oe,a=this.#f(s);if(a===null)return!1;if(!Hr(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,Kn(()=>this.#i.add(i),o),t.push(i);else if(n==="global"){this.#o=Ya(u,o);for(let l of["path","linkpath","size"])if(this.#o.has(l))throw new k(`a global header sets ${l}`,o);mp(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"?Ya(u,o):Ze(xi(u),`a ${n} header`,o)}return!0}#h(t,n){let r=gk.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=gp();let a=g=>o?.get(g)??this.#o?.get(g);if(o!==null&&mp(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")??Ze(t.linkname,"link target",n),{name:f,linkname:c}=Kn(()=>Qt(u,r,l),n),d=(g,w=bk)=>{let y=a(g);return y===void 0?t[g]:w(y,g,n)},p=d("size");if(p!==0&&!za(r))throw new k(`a ${r} entry has a size`,n);if(c!==""&&r!=="hardlink"&&r!=="symlink")throw new k(`a ${r} entry has a link target`,n);let h=g=>{let w=a(g)??Ze(t[g],g,n);if(Vt(w,!1))throw new k(`${g} ${O(w)} holds a control or formatting character`,n);return w};return{entry:{name:f,type:r,mode:t.mode&4095,uid:d("uid"),gid:d("gid"),mtime:d("mtime",kk),uname:h("uname"),gname:h("gname"),linkname:c,devmajor:er(r)?d("devmajor"):0,devminor:er(r)?d("devminor"):0,data:Ne,storedName:u,storedLinkname:l,pax:o??wp,globalPax:this.#o??wp},size:p}}#m(t,n){let r=Ze(t.name,"entry name",n);return t.prefix.length?`${Ze(t.prefix,"name prefix",n)}/${r}`:r}};function Ja(e){let t=new Ka(!0),n=t.push(e);return t.end(),n}var xp=new Map([[7,"a"],[8,"b"],[12,"f"],[10,"n"],[13,"r"],[9,"t"],[11,"v"]]),Ek=e=>"\\"+e.toString(8).padStart(3,"0");function Lt(e,t){let n=re(t),r=ue(t.locale),o="";for(let i of e){let s=i.codePointAt(0);if(i==="\\")o+="\\\\";else if(xp.has(s))o+="\\"+xp.get(s);else if(s<128?s>=32&&s<127:!n&&r.has("print",s))o+=i;else for(let a of T(i))o+=Ek(a)}return o}var vk={__proto__:null,file:"-","contiguous-file":"C",directory:"d",symlink:"l",hardlink:"h",fifo:"p","character-device":"c","block-device":"b"};function bp(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"),vk[e]+n.join("")}var kp=e=>T(e).length,$k=new Set(["character-device","block-device"]);function ki(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),f=$k.has(a.type)?`${a.devmajor},${a.devminor}`:String(a.data.length),c=kp(u)+1+kp(l)+1+f.length;c>r&&(r=c);let d=Ak(a.mtime,i);return d.length>o&&(o=d.length),`${bp(a.type,a.mode)} ${u}/${l} ${" ".repeat(r-c)}${f} ${d.padEnd(o)} `+Lt(_t(a),e)+Sk(a,e)};return s.mkdir=a=>`${bp("directory",448)} ${"Creating directory:".padStart(r+1+o)} ${Lt(a,e)}`,s}function Sk(e,t){return e.type==="symlink"?` -> ${Lt(e.linkname,t)}`:e.type==="hardlink"?` link to ${Lt(e.linkname,t)}`:""}function Ak(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 en(n,"%Y-%m-%d %H:%M",t)}var de=(e,t)=>Lt(e,t).replaceAll(":","\\:");function tn(e,t){let n=Lt(e,t);return re(t)?`'${n.replaceAll("'","\\'")}'`:`\u2018${n}\u2019`}function Qa(e){let t=e.length;for(;t>1&&e[t-1]==="/";)t--;return e.slice(0,t)}function Nk(e){for(let t=0;t<e.length;t++)if(e[t]==="\\")t++;else if("?*[]".includes(e[t]))return!0;return!1}var Ok=(e,t)=>t===e||t.startsWith(e)&&t[e.length]==="/";function Ep(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:Qa(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=>Ok(s.operand,o));return i!==void 0&&(i.found=!0),i??null}}}function vp(e,t,n){for(let r of e.names)r.found||(!n&&Nk(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 Ei(e,t,n){let{ctx:r}=n,o=$(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 Xr(e,t){try{return{bytes:await Pa(e,t),error:null}}catch(n){if(!(n instanceof Jn))throw n;return{bytes:n.bytes,error:n.cause?.cause?.message??n.cause?.message??"corrupt input"}}}var Tk=10,Ik=8,Ck=8,_k=16,Lk=4,Fk=2,Rk=8,$p="gzip",Sp="deflate-raw",Mk=(e,t)=>e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216;function Dk(e,t){if(e[t]!==31||e[t+1]!==139||e[t+2]!==Ck)return-1;let n=e[t+3],r=t+Tk;if((n&Lk)!==0){if(r+2>e.length)return-1;r+=2+e[r]+e[r+1]*256}for(let o of[Rk,_k])if((n&o)!==0){for(;r<e.length&&e[r]!==0;)r++;r++}return(n&Fk)!==0&&(r+=2),r<=e.length?r-t:-1}var Uk=64;async function Pk(e,t){let n=Dk(e,t);if(n<0)return null;let o=(await Xr(e.subarray(t+n),Sp)).bytes.length%4294967296,i=Uk;for(let s=t+n+Ik;s<=e.length&&i>0;s++){if(Mk(e,s-4)!==o)continue;i--;let a=await Xr(e.subarray(t,s),$p);if(a.error===null)return{bytes:a.bytes,end:s}}return null}async function vi(e){let t=await Xr(e,$p);if(t.error===null||!Be(Sp))return{...t,rest:null};let n=[],r=0;for(;;){let o=await Pk(e,r);if(o===null)break;n.push(o.bytes),r=o.end}return r===0||r===e.length?{...t,rest:null}:{bytes:et(n),error:t.error,rest:e.subarray(r)}}function N(e,t={}){let n=Zr(t.short),r=Zr(t.long),o=Zr(t.valueShort),i=Zr(t.valueLong),s=Zr(t.repeatable),a=new Set,u=new Map,l=[],f=[],c=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[++c];if(h===null&&c>=e.length)throw new Error(g+" requires an argument");if(s.has(p)){let E=u.get(p);E?E.push(y):u.set(p,[y])}else u.set(p,y);f.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),f.push({name:p})}return w}for(;c<e.length;c++){let p=e[c];if(p==="--"){l.push(...e.slice(c+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&&zk(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(c));break}l.push(p)}return{flags:a,values:u,positional:l,order:f}}function zk(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 Zr(e){return e instanceof Set?e:new Set(e??[])}var eu="gzip",Bk=(e,t,n)=>nu(e,["-d",...t],n),Ap=(e,t,n)=>nu(e,["-d","-c",...t],n),Lp=Be(eu)?{gzip:nu,gunzip:Bk,zcat:Ap,gzcat:Ap}:{},Np=Object.freeze([31,139]),Kr=e=>e!==void 0&&e.length>=2&&e[0]===Np[0]&&e[1]===Np[1],jk=Object.freeze([[31,158],[31,30],[31,157],[31,160]]),Wk=Object.freeze([80,75,3,4]),Op=(e,t)=>e.length>=t.length&&t.every((n,r)=>e[r]===n),Tp=(e,t)=>jk.some(n=>Op(e,n))||t&&Op(e,Wk);function Ip(e,t){return t.gap??=v("feature","gzip","other formats",`gzip: ${e}: data compressed other than by gzip is not supported`,1),!1}var qk={__proto__:null,"unexpected end of file":"unexpected end of file","incorrect data check":"invalid compressed data--crc error"},Cp=e=>qk[e]??"invalid compressed data--format violated",Hk=8;function tu(e,t){let n=t.rest,r=o=>({text:`
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
35
  gzip: ${e}: ${o}
36
- `,status:1,whole:!1});return n===null?r(Cp(t.error)):n.every(o=>o===0)?null:n.length>=2&&!Kr(n)?{text:`
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
37
  gzip: ${e}: decompression OK, trailing garbage ignored
38
- `,status:2,whole:!0}:n.length>2&&n[2]!==Hk?{text:`gzip: ${e}: unknown method ${n[2]} -- not supported
39
- `,status:1,whole:!0}:r(Cp(t.error))}function Gk(e,t,n){let r=tu(t,n);return r===null||(e.stderr+=r.text,e.status=e.status===1?1:r.status),!1}var Fp=Object.freeze({__proto__:null,".gz":"",".tgz":".tar",".taz":".tar","-gz":"",".z":"","-z":"",_z:""}),Xk=".gz",_p=Object.freeze(["1","2","3","4","5","6","7","8","9"]);async function nu(e,t,n){let{flags:r,positional:o}=N(t,{short:[..._p,"d","c","k","f"],long:["decompress","uncompress","stdout","to-stdout","keep","force"]}),i=_p.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 Rp(s,a);else for(let l of o)if(await Zk(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 Rp(e,t){if(!e.force&&(e.decompressing?hn(t.ctx):Nt(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}.
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
40
  For help, type: gzip -h
41
- `,t.status=1,t.stopped=!0;return}let n=t.ctx.stdinLeft,r=t.ctx.stdinBytes;return j(t.ctx,"",!0),e.decompressing?Mp("stdin",r??T(n),{...e,stdout:!0},t):Vr(await Xe(r??T(n),eu),t)}function Zk(e,t,n){let{ctx:r}=n;if(e==="-")return Rp(t,n);if(!t.stdout&&!t.force&&Yk(e,r))return Ft(n,`${e}: Too many levels of symbolic links`,1);let o=U(r,"gzip",e);return o.error?Ft(n,`${e}: ${o.error}`,1):r.fs.isDir(o.path)?Ft(n,`${e} is a directory -- ignored`,2):t.decompressing?eE(e,o.path,t,n):Vk(e,o.path,t,n)}function Yk(e,t){let n=$(t.cwd,e,t.fs,{follow:!1});return n.path!==null&&t.fs.isLink?.(n.path)===!0}async function Vk(e,t,n,r){let{ctx:o}=r,i=ru(e);if(!n.stdout&&!n.force&&i!==void 0)return rE(r,`${e} already has ${i} suffix -- unchanged`);let s=Qk(await Xe(ce(o.fs,t),eu),e.slice(e.lastIndexOf("/")+1),Kk(o));return n.stdout?Vr(s,r):Dp(e+Xk,s,e,n,r)}var Kk=e=>Math.floor(e.createdAt/1e3),Yr=10,Jk=8;function Qk(e,t,n){let r=T(t);if(e.length<Yr||e[3]!==0||r.includes(0))return e;let o=new Uint8Array(e.length+r.length+1);o.set(e.subarray(0,Yr)),o[3]=Jk;for(let i=0;i<4;i++)o[4+i]=n>>>8*i&255;return o.set(r,Yr),o.set(e.subarray(Yr),Yr+r.length+1),o}function eE(e,t,n,r){let{ctx:o}=r;return!n.stdout&&ru(e)===void 0?Ft(r,`${e}: unknown suffix -- ignored`,2):Mp(e,ce(o.fs,t),n,r,t)}async function Mp(e,t,n,r,o=null){let{ctx:i}=r,s=n.force&&n.stdout;if(t!==void 0&&Tp(t,!0))return Ip(e,r);if(!Kr(t))return s?Vr(t,r):nE(r,`${e}: ${tE(t,o,i)?"unexpected end of file":"not in gzip format"}`);let a=await vi(t),u=a.rest,l=u!==null&&u.length>0&&!Kr(u)?u:null;if(l!==null&&Tp(l,!1))return Ip(e,r);let f=ru(e);if(n.stdout?Vr(a.bytes,r):Dp(e.slice(0,-f.length)+Fp[f],a.bytes,e,n,r)){if(l!==null&&s)return Vr(l,r);a.error&&Gk(r,e,a)}}var ru=e=>Object.keys(Fp).find(t=>e.length>t.length&&e.endsWith(t));function tE(e,t,n){let r=e??_(n.fs.readFile(t).slice(0,2));return r.length===0||r.length===1&&r[0]!==0}var Vr=(e,t)=>(t.events.push({fd:1,bytes:e}),!0);function Dp(e,t,n,r,o){let{ctx:i}=o,s=$(i.cwd,e,i.fs,{follow:!1}).path;if(s!==null&&!r.force)return Ft(o,`${e} already exists;${hn(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 Ft(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 Ft(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 nE=(e,t)=>Ft(e,t,1,`
42
- `),rE=(e,t)=>Ft(e,t,e.status);function Ft(e,t,n,r=""){return e.stderr+=`${r}gzip: ${t}
43
- `,e.status=e.status===1?1:n,!1}var oE=new Set(["atime","charset","comment","ctime","gid","gname","linkpath","mtime","path","size","uid","uname","RHT.security.selinux","SCHILY.acl.access","SCHILY.acl.default"]),iE=e=>oE.has(e)||e.startsWith("SCHILY.xattr."),sE=e=>e==="GNU.dumpdir"||e.startsWith("GNU.volume."),aE=-(2n**63n),uE=2n**63n-1n;function lE(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>=aE&&n<=uE}function Up(e,t){for(let[n,r]of e){if(sE(n))return["extended header",`${t(n)}: records of multi-volume and incremental archives are not supported`];if((n==="atime"||n==="ctime")&&!lE(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:Up(i.globalPax,t))??Up(i.pax,t);if(s!==null)return{gap:s};o=i.globalPax;let a=pi(i);if(a!==null){let[l,f]=di(a);return{gap:[l,`${t(a)}: ${f}`]}}n.push([...i.pax.keys()].filter(l=>!iE(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 iu=512,fE=10,su=e=>({entries:[],child:e,warnings:[],mtimes:[]}),cE=[{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"}],dE=e=>cE.find(({bytes:t})=>t.length<=e.length&&t.every((n,r)=>e[r]===n)),pE={__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 au(e){let t=e.lastIndexOf(".");return t===-1?void 0:pE[e.slice(t+1)]}function $i(e,t){return e.refuse("option",t,`${t}: archives compressed other than with gzip are not supported`),null}var uu=e=>{let t=e.indexOf(":");return t!==-1&&!e.slice(0,t).includes("/")};function hE(e,t){let{ctx:n}=t,r=e.archive;if(r==="-"){if(hn(n))return t.fatal("Refusing to read archive contents from terminal (missing -f option?)");let i=n.stdinBytes??T(n.stdinLeft);return j(n,"",!0),{bytes:i,name:r,stdin:!0}}if(uu(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=U(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:ce(n.fs,o.path),name:r,stdin:!1}}function zp(e,t){let n=hE(e,t);if(!n)return null;let r=n.bytes;if(e.gzip)return ou(r,t);let o=r.length>=iu?Bp(r):null;if(o?.entries!==void 0)return Wp(o.entries,t,0);let i=dE(r);if(i!==void 0)return n.stdin?t.fatal(`Archive is compressed. Use ${i.option} option`):i.option==="-z"?ou(r,t):$i(t,i.option);let s=r.length<iu;s&&t.error("This does not look like a tar archive");let a=n.stdin?void 0:au(n.name);return a!==void 0&&a!=="-z"?$i(t,a):s?a===void 0?su(0):ou(r,t):jp(o.error,t)}async function ou(e,t){if(!Be("gzip"))return t.refuse("option","-z","this runtime has no gzip stream");if(!Kr(e))return t.say(2,`
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
44
  gzip: stdin: ${e.length<2?"unexpected end of file":"not in gzip format"}
45
- `),su(1);let n=await vi(e),r=n.error===null?null:tu("stdin",n);if(r!==null&&!r.whole&&e.length>fE)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<iu)return su(o);let i=Bp(n.bytes);return i.entries===void 0?jp(i.error,t):Wp(i.entries,t,o)}function Bp(e){try{return{entries:Ja(e)}}catch(t){if(!(t instanceof k))throw t;return{error:t}}}function jp(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 qp=512,Hp={file:384,directory:448,symlink:511};async function Xp(e,t){let{ctx:n}=t;if(e.archive==="-"&&Nt(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=mE(e,t),o=r&&gE(e,t);if(o===null||!r)return;if(o&&!Be("gzip"))return t.refuse("option","-z","this runtime has no gzip stream");let i=wE(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?ki(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 f of u)if(a=Ei(a,f,t),a===null)return Gp(s,e,o,!0);if(u=[],yE(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 ${tn(l,n)} has no effect`)}await Gp(s,e,o,!1)}function mE(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 gE(e,t){if(e.gzip)return!0;let n=e.auto&&e.archive!=="-"?au(e.archive):void 0;return n===void 0?!1:n==="-z"?!0:$i(t,n)}function wE(e,t){let{ctx:n}=t;if(e==="-")return{kind:"stdout"};if(e==="/dev/null")return{kind:"null"};if(uu(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=H(n.cwd,e),i=$(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=$(n.cwd,se(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&&te(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 Zp(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 yE(e,t,n){let{ctx:r}=n.state,o=Qa(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=Zp(o,n),s=$(t,o,r.fs,{follow:!1});s.error?n.state.error(`${de(o,r)}: Cannot stat: ${s.error}`):Yp(s.path,o,i,n)}function Yp(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 f=l===void 0?{name:n.name,type:u,mode:Hp[u],mtime:r.mtime,...r.owners,linkname:a?i.readLink(e):"",data:u==="file"?ce(i,e):void 0}:{name:n.name,type:"hardlink",mode:Hp[u],mtime:r.mtime,...r.owners,linkname:l};if(r.entries.push(f),r.verbose&&o.list(r.line?r.line({...f,name:t,data:f.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:c,files:d,links:p=[]}=i.listDir(e);for(let h of[...new Set([...c,...d,...p])].sort(G)){let m=t==="/"?`/${h}`:`${t}/${h}`;if(Yp(he(e,h),m,Zp(m,r),r),o.stopped)return}}async function Gp(e,t,n,r){let{state:o,target:i}=e,s;try{s=Va(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*qp;s=s.subarray(0,Math.floor((s.length-2*qp)/a)*a)}n&&(s=await Xe(s,"gzip")),i.kind==="stdout"&&!o.closedOut?o.bytes(s):i.kind==="file"&&i.handle.writeBytes(s)}var xE=new Set(["file","contiguous-file","directory","symlink"]);function Vp(e,t){let n=e.split("/").filter(r=>r!=="");return n.length<=t?null:n.slice(t).join("/")}var Kp=(e,t)=>H(e,t);function Jp(e,t,n,r,o,i=()=>{}){let{ctx:s}=r,a=de(t,s);if(!xE.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||!te(n))return l();let f=bE(se(n),r);if(f==="read-only")return l();if(typeof f=="string")return r.error(`${a}: Cannot ${u}: ${f}`);if(f>0&&i(f),e.type==="directory")return kE(n,a,r);let c=e.type==="symlink"?`Cannot create symlink to ${tn(e.linkname,s)}`:"Cannot open";if($("/",n,s.fs,{follow:!1}).path!==null&&(o||!Qp(n,s.fs)))return r.error(`${a}: ${c}: 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 bE(e,t){let{fs:n}=t.ctx,r=[];for(let o=e;;o=se(o)){let i=$("/",o,n);if(i.path!==null){if(!n.isDir(i.path))return"Not a directory";break}if($("/",o,n,{follow:!1}).path!==null)return"File exists";r.push(o)}for(let o of r.toReversed())if(!te(o)||!n.makeWritableDir("/",o))return"read-only";return r.length}function kE(e,t,n){let{fs:r}=n.ctx,o=$("/",e,r,{follow:!1});return o.path!==null&&r.isDir(o.path)&&!r.isLink?.(o.path)?!0:o.path!==null&&!Qp(e,r)?n.error(`${t}: Cannot mkdir: File exists`):(r.makeWritableDir("/",e),!0)}function Qp(e,t){let n=$("/",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 EE=new Set(["create","list","extract"]),oh={__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"},vE={__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"},lu=new Set(["file","directory","format","blocking-factor","strip-components","owner","group","sort"]),$E="Try 'tar --help' or 'tar --usage' for more information.",rt=(e,t=2)=>({usage:{text:`tar: ${e}
46
- ${$E}
47
- `,status:t}});function SE(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),!!lu.has(oh[o])){if(r>=t.length)return rt(`Old option '${o}' requires an argument.`);n.push(t[r++])}return{words:[...n,...t.slice(r)],old:!0}}function ih(e,t){let n=SE(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),f=vE[l];if(f===void 0)throw new x("option",`--${l}`,`unknown option: --${l}`);lu.has(f)?u!==-1?a=or(o,f,s.slice(u+1),t):i+1<r.length?a=or(o,f,r[++i],t):a=rt(`option '--${l}' requires an argument`,64):a=u===-1?or(o,f,void 0,t):rt(`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],f=oh[l];if(f===void 0)throw new x("option",`-${l}`,`unknown option: -${l}`);if(!lu.has(f)){a=or(o,f,void 0,t);continue}u+1<s.length?a=or(o,f,s.slice(u+1),t):i+1<r.length?a=or(o,f,r[++i],t):a=rt(`option requires an argument -- '${l}'`,64);break}else o.items.push({name:s});if(a!==null)return a}return OE(o)}function or(e,t,n,r){if(EE.has(t)){if(e.mode!==null&&e.mode!==t)return rt("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=AE[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 AE={__proto__:null,"strip-components":e=>{let t=rh(e);return t===null||t<0?rt(`${e}: Invalid number of elements`):{value:t}},"blocking-factor":e=>{let t=rh(e);return t===null||t<1||t>2147483647?rt(`${e}: Invalid blocking factor`):{value:t}},format:e=>{let t=TE[e];return t===void 0?rt(`${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=IE(e,th);if(n.error){let r=th.map(o=>` - ${tn(o,t)}
48
- `).join("");return{usage:{text:`tar: ${n.error} argument ${tn(e,t)} for ${tn("--sort",t)}
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
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)=>eh(e,t),group:(e,t)=>eh(e,t)},NE=4294967295;function eh(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(NE)?-1:o.at(-1));return i===null||i<0?{usage:{text:`tar: ${de(r,t)}: Invalid owner or group ID
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
51
  tar: Error is not recoverable: exiting now
52
- `,status:2}}:{value:{name:n>0?e.slice(0,n):null,id:i}}}function OE(e){return e.mode===null?rt("You must specify one of the '-Acdtrux', '--delete' or '--test-label' options"):e.files>1?rt("Multiple archive files require '-M' option"):e.mode==="create"&&!e.items.some(t=>t.name!==void 0)?rt("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 TE={__proto__:null,gnu:"gnu",ustar:"ustar",pax:"pax",posix:"pax",oldgnu:null,v7:null},th=["none","name","inode"];function IE(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 nh=2n**63n-1n;function rh(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>nh||n<-nh-1n?null:n<0n?-1:Number(n>BigInt(Number.MAX_SAFE_INTEGER)?Number.MAX_SAFE_INTEGER:n)}function sh(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+`
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
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 ah(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:Z(n,e.gap.kind,"tar",e.gap.detail,e.gap.message)}var CE=32768;async function uh(e,t,n){let r=ih(t,n);if(r.usage)return{stdout:"",stderr:r.usage.text,exitCode:r.usage.status};let o=sh(n);return r.blocking>CE?o.refuse("option","--blocking-factor",`${r.blocking}: a record of that many blocks is more than this terminal holds`):r.mode==="create"?await Xp(r,o):await _E(r,o),ah(o)}async function _E(e,t){let{ctx:n}=t,r=Date.now(),o=await zp(e,t);if(!o)return;let i=Ep(e.items),s=e.mode==="extract";e.toStdout&&(t.listTo=2);let a=e.verbose>1?ki(n,e):null,u=new Map;for(let[l,f]of o.entries.entries()){for(let m of o.warnings[l])t.warn(m);let c=_t(f),d=i.match(c);if(d===null)continue;let p=ME(d,u,t);if(p===null)return;let h=s?Vp(c,e.strip):c;if(h!==null&&(e.verbose>0&&t.list(a?a(f):Lt(c,n)),s&&e.toStdout?(f.type==="file"||f.type==="contiguous-file")&&LE(f.data,h,t):s&&Jp(f,h,Kp(p,h),t,e.keepOld,m=>FE(h,m,a,t))&&RE(o.mtimes[l],h,r,t),t.stopped))return}if(o.child)return t.fatal(`Child returned status ${o.child}`);vp(i,t,e.noWildcards)}function LE(e,t,n){n.closedOut?e.length>0&&n.error(`${de(t,n.ctx)}: Cannot write: Bad file descriptor`):n.bytes(e)}function FE(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 RE(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 ME(e,t,n){if(t.has(e))return t.get(e);let r=n.ctx.cwd;for(let o of e.dirs)if(r=Ei(r,o,n),r===null)return null;return t.set(e,r),r}function lh(){let e=new(Qe?Uint32Array:Int32Array)(4096);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}for(let t=0;t<256;t++){let n=e[t];for(let r=256+t;r<e.length;r+=256)n=e[r]=n>>>8^e[n&255]}return e}var ke=lh(),[fu,DE,UE,PE,zE,BE,jE,WE,qE,HE,GE,XE,ZE,YE,VE,KE]=Array.from({length:16},(e,t)=>ke.subarray(t*256,t*256+256));function Si(e){at(e);let t=-1,n=0,r=e.length;if(Vo&&r>1024){let o=4-(e.byteOffset&3)&3;for(;n<o;n++)t=fu[(t^e[n])&255]^t>>>8;let i=r-n>>>2,s=new(Qe?Uint32Array:Int32Array)(e.buffer,e.byteOffset+n,i),a=0;for(let u=i-3;a<u;a+=4){let l=s[a]^t,f=s[a+1],c=s[a+2],d=s[a+3];t=ke[3840+(l&255)]^ke[3584+(l>>>8&255)]^ke[3328+(l>>>16&255)]^ke[3072+(l>>>24)]^ke[2816+(f&255)]^ke[2560+(f>>>8&255)]^ke[2304+(f>>>16&255)]^ke[2048+(f>>>24)]^ke[1792+(c&255)]^ke[1536+(c>>>8&255)]^ke[1280+(c>>>16&255)]^ke[1024+(c>>>24)]^ke[768+(d&255)]^ke[512+(d>>>8&255)]^ke[256+(d>>>16&255)]^ke[d>>>24]}n+=a*4}else for(let o=r-15;n<o;n+=16)t=KE[(e[n]^t)&255]^VE[(e[n+1]^t>>>8)&255]^YE[(e[n+2]^t>>>16)&255]^ZE[e[n+3]^t>>>24]^XE[e[n+4]]^GE[e[n+5]]^HE[e[n+6]]^qE[e[n+7]]^WE[e[n+8]]^jE[e[n+9]]^BE[e[n+10]]^zE[e[n+11]]^PE[e[n+12]]^UE[e[n+13]]^DE[e[n+14]]^fu[e[n+15]];for(let o=n;o<r;o++)t=fu[(t^e[o])&255]^t>>>8;return~t>>>0}var Ai=67324752,Ni=33639248,Oi=101010256,fh=61440,nn={file:32768,directory:16384,symlink:40960},Ti=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function Jr(e){let t=new Uint8Array(e.reduce((o,[i])=>o+i,0)),n=Ti(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 ch=e=>Xe(e,"deflate-raw"),JE=1032;async function dh(e,t,n){if(t>e.length*JE)throw new k("an entry declares more than its data can inflate to",n);let r;try{r=await jd(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 ph(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 hh(e){let t=ph(e);if(t===null)throw new k(`mtime ${e} is outside DOS time, 1980 to 2107`);return t}function mh(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=ph(r);if(o===null||o.time!==t||o.date!==e)throw new k("an entry has an invalid DOS time",n);return r}var QE=new Set(["deflate","store"]),ev=788,tv=2048,gh=315532800,nv=2147483647,wh=65534,cu=4294967294;function yh(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 rv(e){let t=gi(e,nn);return{...t,mode:yh(e.mode??Qn[t.type],"mode",0,4095),mtime:yh(e.mtime??gh,"mtime",gh,nv)}}var ov=e=>Jr([[2,21589],[2,5],[1,1],[4,e]]);async function du(e,{method:t="deflate"}={}){if(!QE.has(t))throw new k(`method ${O(String(t))} is not deflate or store`);let n=new xt(!0),r=[],o=[],i=0,s=0;for(let l of e){let f=rv(l),c={...f,...Qt(f.name,f.type,f.linkname)};if(n.add(c),++s>wh)throw new k(`more than ${wh} entries would need zip64`);let d=Kt(mi(c),"entry name"),p=c.type==="symlink"?Kt(c.linkname,"symlink target"):c.data;if(p.length>cu||i>cu)throw new k(`${O(c.name)} would need zip64`);let h=p,m=0;if(t==="deflate"&&c.type==="file"&&p.length){let I=await ch(p);I.length<p.length&&(h=I,m=8)}let{time:g,date:w}=hh(c.mtime),y=ov(c.mtime),E=[[2,m===8?20:10],[2,Wr(d)?0:tv],[2,m],[2,g],[2,w],[4,Si(p)],[4,h.length],[4,p.length],[2,d.length],[2,y.length]];r.push(Jr([[4,Ai],...E]),d,y,h);let S=(nn[c.type]|c.mode)*65536+(c.type==="directory"?16:0);o.push(Jr([[4,Ni],[2,ev],...E,[2,0],[2,0],[2,0],[4,S],[4,i]]),d,y),i+=30+d.length+y.length+h.length}let a=yt(o);if(i+a.length>cu)throw new k("the archive would need zip64");let u=Jr([[4,Oi],[2,0],[2,0],[2,s],[2,s],[4,a.length],[4,i],[2,0]]);return yt([...r,a,u])}var iv=134695760,sv=117853008,av=1,uv=21589,lv=28789,fv=1,cv=8,dv=16;function pu(e,t=0){let n=Ti(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 pv(e){if(e instanceof Uint8Array){let t=pu(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)=>pu(await t(n,Math.min(r,e.size)),n)}}throw new k("the archive is not a Uint8Array or a Blob")}var hv=65536;function xh(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+hv,s,e.size)),t=await e.window(n,r)),t}}async function mv(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)===Oi&&r+22+n.u16(r+20)===t){if(r>=20&&n.u32(r-20)===sv)throw new k("zip64 is not supported",r-20);return{end:r,r:n}}throw new k("no end of central directory record")}function bh(e,t){let n=new Map,r=pu(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===av)throw new k("zip64 is not supported",t);if(i===lv)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 gv(e,t){let n=await e(t,46);if(n.u32(t)!==Ni)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&fv)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=mh(i.date,i.time,t);let s=bh(n.slice(t+46+r,o),t).get(uv);if(s!==void 0&&s[0]&1){if(s.length<5)throw new k("an extended timestamp is cut short",t);i.mtime=Ti(s).getInt32(1,!0)}return i}async function wv(e,t,n,r){let o=t.offset,i=await e(o,30,r);if(i.u32(o)!==Ai)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),!ci(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);bh(i.slice(o+30+s,a),o);let l=t.flags&cv,f=(d,p)=>i.u32(o+d)===p||l&&i.u32(o+d)===0;if(!f(14,t.crc)||!f(18,t.csize)||!f(22,t.usize))throw new k("the local header disagrees with the central directory",o);t.dataAt=o+30+s+a;let c=t.dataAt+t.csize;if(l){let d=await e(c,16,n),p=m=>d.u32(m)===t.crc&&d.u32(m+4)===t.csize&&d.u32(m+8)===t.usize,h=d.u32(c)===iv&&p(c+4);if(p(c)&&!(h&&c+16===n))c+=12;else if(h)c+=16;else throw new k("the data descriptor disagrees with the central directory",c)}return c}function yv(e,t,n){let r=n&fh;if(t.endsWith("/")){if(r!==0&&r!==nn.directory)throw new k(`${O(t)} is a directory by its name but not by its mode`,e.at);return"directory"}if(r===nn.directory)throw new k(`${O(t)} is a directory by its mode but not by its name`,e.at);if(e.attributes&dv)throw new k(`${O(t)} is a directory by its attributes but not by its name`,e.at);if(r===nn.symlink)return"symlink";if(r===0||r===nn.file)return"file";throw new k(`the mode of ${O(t)} (${n.toString(8)}) is not one this package reads`,e.at)}async function xv(e,t,n){let{at:r,method:o,csize:i,usize:s}=t,a=Ze(t.name,"entry name",r),u=t.madeBy>>8===3?t.attributes>>>16:0,l=yv(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 f=await e.read(t.dataAt,t.dataAt+i);if(f.length!==i)throw new k("the archive is truncated",t.dataAt);let c=o===8?await dh(f,s,r):f;if(Si(c)!==t.crc)throw new k("the data does not match its CRC-32",r);let d=l==="symlink"?Ze(c,"symlink target",r):"",h={...Kn(()=>Qt(a,l,d),r),type:l,mode:u===0?Qn[l]:u&4095,mtime:t.mtime,data:l==="file"?c:Ne,storedName:a};return Kn(()=>n.add(h),r),h}async function*bv(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 mv(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=xh(e),l=[],f=a,c=0;for(let y=0;y<i;y++){let E=await gv(u,f);if(c+=E.usize,c>t)throw new k(`the entries come to more than ${t} bytes`,f);l.push(E),f=E.next}if(f!==r)throw new k("the central directory does not hold what the end record counts",f);let d=0,p=l.toSorted((y,E)=>y.offset-E.offset),h=p.map((y,E)=>p[E+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=xh(e);for(let[y,E]of p.entries()){if(E.offset!==d)throw new k(E.offset>d?"bytes belong to no entry":"two entries overlap",d);d=await wv(g,E,h[y],m[y])}if(d!==a)throw new k("bytes belong to no entry",d);let w=new xt(n);for(let y of l)yield await xv(e,y,w)}async function hu(e,t){if(!(e instanceof Uint8Array))throw new k("the archive is not a Uint8Array");return await Array.fromAsync(bv(pv(e),t,!0))}var kv=(e,t)=>e===null?t:`${e.endsWith("/")?e.slice(0,-1):e}/${t}`;function kh(e,t,n){let r=$v(t.exdir,n);if(r===null)return!1;let o=[],i=Ev(e,r,o,t,n);for(let s of o)vv(s,n);return i}function Ev(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?Ce(s.name):s.name,l=H(t,u),f=kv(r.exdir,a?`${u}/`:u),c=Eh(l,i)?Sv(se(l),i):"read-only";if(c==="read-only")return Ii(f,o);if(c!==null)return o.refuse("feature","name taken",`${f}: extracting under a name that is not a directory is not supported`),!1;if(a){if(!Av(l,f,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=Nv(l,f,r,o);if(d===null)return!1;if(d==="skip")continue;let p=i.fs.openWritable("/",l);if(!p)return Ii(f,o);let h=s.type==="symlink";p.writeBytes(h?T(s.linkname):s.data),h&&n.push({path:l,shown:f,target:s.linkname})}return!0}function vv({path:e,shown:t,target:n},r){let{fs:o}=r.ctx,i=$("/",e,o),s=i.path!==null&&o.isFile(i.path)?ce(o,i.path):null,a=T(n);if(s===null||s.length!==a.length||s.some((u,l)=>u!==a[l])){r.say(2,`warning: deferred symlink (${t}) failed:
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
55
  invalid placeholder file
56
- `);return}o.removeWritable("/",e),o.makeWritableLink("/",e,n)}var Eh=(e,t)=>t.writable&&te(e);function Ii(e,t){return t.refuse("feature","read-only target",`${e}: Read-only file system`),!1}function $v(e,t){let{ctx:n}=t;if(e===null)return n.cwd;let r=H(n.cwd,e),o=$("/",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=$("/",se(r),n.fs);return i.error!==null?(t.say(2,`checkdir: cannot create extraction directory: ${e}
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
57
  ${i.error}
58
- `),t.status=2,null):!Eh(r,n)||!n.fs.makeWritableDir("/",r)?(Ii(e,t),null):r}function Sv(e,t){let n=[],r=e;for(;$("/",r,t.fs).path===null;r=se(r)){if($("/",r,t.fs,{follow:!1}).path!==null)return"File exists";n.push(r)}if(!t.fs.isDir($("/",r,t.fs).path))return"Not a directory";for(let o of n.toReversed())if(!te(o)||!t.fs.makeWritableDir("/",o))return"read-only";return null}function Av(e,t,n){let{fs:r}=n.ctx,o=$("/",e,r,{follow:!1});return o.path===null?r.makeWritableDir("/",e)?(n.quiet===0&&n.say(1,` creating: ${t}
59
- `),!0):Ii(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 Nv(e,t,n,r){let{fs:o}=r.ctx,i=$("/",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&&Ov(t,n,r),n.overwrite==="none"?"skip":(n.overwrite==="all"&&o.removeWritable("/",e),n.overwrite==="all"?"write":null))}function Ov(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
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
60
  (EOF or read error, treating as "[N]one" ...)
61
- `),t.overwrite="none",n.status=1}var vh={__proto__:null,l:"list",t:"test",p:"pipe",c:"crt",v:"verbose"},$h={usage:{text:`error: must specify directory to which to extract with -d option
62
- `,status:10}};function Sh(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 $h;break}if(l==="l"&&t.lists++,vh[l])t.modes.add(vh[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 $h}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 ir(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?ir(e,t,n,r+1):0;if(o===42){if(t>=e.length)return 1;for(;r<n.length;r++){let i=ir(e,t,n,r);if(i!==0)return i}return 2}if(o===91)return Tv(e,t,n,r);if(o===92){if(t>=e.length)return 0;o=e[t++]}return r<n.length&&n[r]===o?ir(e,t,n,r+1):0}function Tv(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:ir(e,s+1,n,r+1);a=0,u=!1}return o?ir(e,s+1,n,r+1):0}var Ah=(e,t)=>ir(e,0,t,0)===1;var Iv=[" 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(`
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
63
  `)+`
64
- `;async function Nh(e,t,n){let r=Sh(t);if(r.usage)return{stdout:"",stderr:r.usage.text,exitCode:r.usage.status};let o=Pv(n,r);if(r.bothOverwrites&&o.say(2,`caution: both -n and -o specified; ignoring -o
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
65
  `),r.exdir!==null&&r.mode!=="extract"&&o.say(2,`caution: not extracting; -d ignored
66
- `),r.mode==="crt"||r.mode==="verbose"){let f=r.mode==="crt"?"-c":r.lists>1?"-ll":"-v";return o.refuse("option",f,"how each entry is stored is not known here, which this listing prints")}let i=Cv(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=ce(n.fs,i.path),a;try{a=await hu(s)}catch(f){if(!(f instanceof k))throw f;return _v(s)?o.refuse("feature","archive",`this archive is not one this terminal reads: ${f.message}`):(o.heading(i.name,!0),o.say(2,Iv),r.mode!=="pipe"&&o.say(2,`unzip: cannot find zipfile directory in one of ${r.archive} or
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
68
  ${r.archive}.zip, and cannot find ${r.archive}.ZIP, period.
69
- `),o.end(9))}let u=a.map(pi).find(f=>f!==null);if(u!==void 0){let[f,c]=di(u);return o.refuse("feature",f,`${u}: ${c}`)}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=Lv(a,r);if(r.mode==="list")return Uv(l,i.name,o);if(o.heading(i.name,!1),r.mode==="test")Mv(l,i.name,o);else if(r.mode==="pipe")for(let f of l.entries)o.bytes(f.type==="symlink"?T(f.linkname):f.data);else if(!kh(l.entries,r,o))return o.end(o.gap?1:o.status);return Fv(l,o),r.mode==="test"&&Dv(l,i.name,o),o.end(l.missed?11:o.status)}function Cv(e,t){for(let n of[e,`${e}.zip`,`${e}.ZIP`]){let r=n===e?U(t,"unzip",n):U({...t,notes:null},"unzip",n);if(!r.error&&!t.fs.isDir(r.path))return{name:n,path:r.path}}return null}function _v(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=>T(e);function Lv(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)Ah(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 Fv(e,t){for(let n of e.include)n.hit||t.say(2,`caution: filename not matched: ${n.text}
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
71
  `);for(let n of e.exclude)n.hit||t.say(2,`caution: excluded filename not matched: ${n.text}
72
- `)}var Rv=(e,t)=>e+" ".repeat(Math.max(0,t-Qr(e).length));function Mv(e,t,n){if(n.quiet===0)for(let r of e.entries)n.say(1,` testing: ${Rv(_t(r),22)} OK
73
- `)}function Dv(e,t,n){n.quiet>1||(e.missed?n.say(1,`At least one error was detected in ${t}.
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
74
  `):e.all?n.say(1,`No errors detected in compressed data of ${t}.
75
75
  `):n.say(1,`No errors detected in ${t} for the ${e.entries.length} file${e.entries.length===1?"":"s"} tested.
76
- `))}function Uv(e,t,n){let{ctx:r}=n,o=r.vars.has("TZ"),i=l=>en(new Date(l.mtime*1e3),"%Y-%m-%d %H:%M",o);if(!o&&e.entries.some(l=>i(l)!==en(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
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
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)}
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
79
  `);let u=e.entries.length;return n.quiet<2&&n.say(1,`--------- -------
80
80
  ${String(a).padStart(9)} ${u} file${u===1?"":"s"}
81
- `),n.end(u===0&&e.include.length>0?11:0)}function Pv(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}
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
82
  `):i&&r.say(2,`[${o}]
83
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?Z(s,r.gap.kind,"unzip",r.gap.detail,r.gap.message):s}};return r}var zv={file:384,directory:448,symlink:511},Oh={__proto__:null,r:"recurse",q:"quiet",j:"junk",0:"store",y:"symlinks",D:"noDirectories"};function Bv(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(!Oh[r])throw new x("option",`-${r}`,`unknown option: -${r}`);t[Oh[r]]=!0}else t.archive===null?t.archive=n:t.names.push(n)}return t}async function Ih(e,t,n){let r=Bv(t);if(r.archive===null||r.archive==="-"){if(t.length>0&&Nt(n))return{stdout:"",stderr:`
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
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=Ce(r.archive).includes(".")?r.archive:`${r.archive}.zip`;if($(n.cwd,s,n.fs,{follow:!1}).path!==null)return sr(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 sr(o,"feature","stdin input","adding what stdin holds, as the entry `-`, is not supported");if(Yv(g,u),u.gap)return sr(o,...u.gap)}if(u.entries.length===0)return i(`
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
87
  zip error: Nothing to do! (${s})
88
- `),eo(o,12);let l=Vv(u);if(l)return i(l),eo(o,16);let f=r.store?new Map:await Hv(u.entries.filter(g=>g.type==="file")),c=[...f.keys()].filter(qv);if(c.length>0&&c.length<f.size)return sr(o,"feature","stored suffix",`${c[0].name}: storing a file as Info-ZIP stores one by its suffix, beside files it deflates, is not supported`);for(let g of c)f.delete(g);let d=u.entries.map(g=>Gv(g,f.get(g))),p;try{p=await du(u.entries,{method:f.size>0?"deflate":"store"})}catch(g){if(!(g instanceof k))throw g;return sr(o,"feature","archive",`this archive cannot be written here: ${g.message}`)}let h=H(n.cwd,s),m=n.writable&&te(h)?jv(n,s):null;if(m===null)return sr(o,"feature","read-only target",`${s}: Read-only file system`);if(m.error)return i(`zip I/O error: ${m.error}
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
89
  zip error: Could not create output file (${s})
90
- `),eo(o,15);if(!r.quiet)for(let g of d)i(g);return m.writeBytes(p),eo(o,0)}function jv(e,t){try{return e.fs.openWritable(e.cwd,t)}catch(n){return{error:n.fsError??"No such file or directory"}}}var Wv=[".Z",".zip",".zoo",".arc",".lzh",".arj"],qv=e=>Wv.some(t=>e.name.endsWith(t));async function Hv(e){let t=await Promise.all(e.map(async n=>n.data.length===0?0:(await Xe(n.data,"deflate-raw")).length));return new Map(e.flatMap((n,r)=>t[r]<n.data.length?[[n,t[r]]]:[]))}function Gv(e,t){let n=e.type==="directory"?`${e.name}/`:e.name;return t===void 0?` adding: ${n} (stored 0%)
91
- `:` adding: ${n} (deflated ${Xv(e.data.length,t)}%)
92
- `}function Xv(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 Zv(e,t){if(t.junk)return Ce(e);let n=e.replace(/^\/+/u,"");for(;n.startsWith("./");)n=n.slice(2);return n==="."?"":n}function Yv(e,t){let{ctx:n,opts:r}=t,o=$(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=Zv(i,r);Ch(o.path,s,!r.junk&&s===""?"":i,t)}function Ch(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 Th(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:zv[l],mtime:Math.floor(o.createdAt/1e3),linkname:a?s.readLink(e):"",data:l==="file"?ce(s,e):void 0}),!u||!i.recurse)return;if(r.seen.has(e))return Th(r,"link loop",`${t}: a directory inside itself through a link is not supported`);r.seen.add(e);let{dirs:f,files:c,links:d=[]}=s.listDir(e);for(let p of[...new Set([...f,...c,...d])].sort(G)){let h=he(e,p),m=$("/",h,s,{follow:!i.symlinks});if(m.error?r.out(` zip warning: name not matched: ${t}/${p}
94
- `):Ch(m.path,i.junk||t===""?p:`${t}/${p}`,n===""?p:`${n}/${p}`,r),r.gap)break}r.seen.delete(e)}function Vv(e){let t=e.entries.toSorted((o,i)=>G(o.name,i.name)||G(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
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
95
  `:"";return` zip warning: first full name: ${i.full}
96
96
  second full name: ${o.full}
97
97
  name in zip file repeated: ${s}
98
98
  ${a}
99
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 Th(e,t,n){e.gap??=["feature",t,n]}function sr(e,t,n,r){return e.events.push({fd:2,text:`zip: ${r}
101
- `}),Z(eo(e,1),t,"zip",n,`zip: ${r}`)}function eo(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 _h={tar:uh,...Be("deflate-raw")?{zip:Ih,unzip:Nh}:{}};var mu="brotli",Ci=".br",Fh=Be(mu)?{brotli:Jv}:{},Rh="con",Mh=Object.freeze(["0","1","2","3","4","5","6","7","8","9"]),Kv=`Usage: brotli [OPTION]... [FILE]...
102
- `;async function Jv(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:[...Mh,"d","c","k","j","f","Z"],long:["decompress","stdout","keep","rm","force","best"],valueShort:["q"],valueLong:["quality"]}),s=Qv(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:Kv,stderr:"",exitCode:1};let u={ctx:n,events:[],stderr:"",status:0,gap:null};for(let f of i.length===0?["-"]:i)if(!await e$(f,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 Qv(e,t){let n=[...Mh,"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 e$(e,t,n,r){let{ctx:o}=r;if(e==="-"){if(!n.force&&(n.decompressing?hn(o):Nt(o)))return Rt(r,`Use -h help. Use -f to force ${n.decompressing?"input from":"output to"} a terminal.`);let a=o.stdinBytes,u=o.stdinLeft;return j(o,"",!0),Lh(a??T(u),Rh,null,n,r)}let i=null;if(!n.stdout)if(!n.decompressing)i=e+Ci;else{if(e.length<=Ci.length)return Rt(r,`empty output file name for [${e}] input file`);if(e.endsWith(Ci))i=e.slice(0,-Ci.length);else return Rt(r,`input file [${e}] suffix mismatch`)}let s=U(o,"brotli",e);return s.error?Rt(r,`failed to open input file [${e}]: ${s.error}`):i!==null&&!n.force&&U(o,"brotli",i).error===null?Rt(r,`failed to open output file [${i}]: File exists`):i===null&&!n.decompressing&&!n.force&&Nt(o)?Rt(r,"Use -h help. Use -f to force output to a terminal."):o.fs.isDir(s.path)?Rt(r,`failed to read input [${e}]: Is a directory`):Lh(ce(o.fs,s.path),e,i,n,r)}async function Lh(e,t,n,r,o){let{ctx:i}=o,s=r.decompressing?await Xr(e,mu):{bytes:await Xe(e,mu),error:null};if(s.error)return Rt(o,`corrupt input [${t}]`);if(n===null)o.events.push({fd:1,bytes:s.bytes});else if(!t$(n,s.bytes,o))return!1;return r.remove&&t!==Rh&&i.fs.removeWritable(i.cwd,t),!0}function t$(e,t,n){let{ctx:r}=n,o;try{o=r.writable&&r.fs.openWritable?.(r.cwd,e)}catch(i){return Rt(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 Rt(e,t){return e.stderr+=`${t}
103
- `,e.status=1,!1}var n$=Object.freeze({__proto__:null,1:"SHA-1",256:"SHA-256",384:"SHA-384",512:"SHA-512"}),r$=Object.freeze(["1","224","256","384","512","512224","512256"]),o$=()=>{try{return typeof crypto?.subtle?.digest=="function"}catch{return!1}};async function i$(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 s$(e,t,n){let r=e==="shasum"?n.get("a")??"1":String(t);if(e==="shasum"&&!r$.includes(r))return{error:b(`${e}: Unrecognized algorithm
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
104
  Type shasum -h for help
105
- `,1)};let o=n$[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 to(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:f}=s$(e,t,u);if(f)return f;let{mode:c,error:d}=f$(e,i,s);if(d)return d;let p=le(e,a,n,o,{read:"bytes"}),h=await Promise.all(p.inputs.map(g=>i$(l,g.bytes))),m=c$(l,i,c);return fe(p.inputs.map((g,w)=>m(h[w],g.name??"-")).join(""),p)}}var a$=new Set(["b","binary"]),u$=new Set(["t","text"]);function l$(e,t){let n=!1,r=null,o=!1;for(let{name:i}of t)a$.has(i)?(n=!0,r="binary"):u$.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 f$(e,t,n){let r=l$(e,n),o=e==="shasum"?`Type ${e} -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
106
  `:`Try '${e} --help' for more information.
107
107
  `;return r.ambiguous?{error:b(`${e}: Ambiguous file mode
108
108
  ${o}`,1)}:t.has("tag")&&r.text?{error:b(`${e}: --tag does not support --text mode
109
- ${o}`,1)}:{mode:r}}function c$(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 Dh=o$()?{sha1sum:to("sha1sum",1),sha256sum:to("sha256sum",256),sha384sum:to("sha384sum",384),sha512sum:to("sha512sum",512),shasum:to("shasum",1)}:{};var Uh=()=>typeof fetch=="function";function Ph(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 d$=Object.freeze(["http:","https:"]),p$=/^[a-zA-Z][a-zA-Z0-9+.-]*:/u;function zh(e){let t=p$.test(e)?e:"http://"+e,n;try{n=new URL(t)}catch{return{malformed:!0}}return d$.includes(n.protocol)?n.hostname===""?{malformed:!0}:{url:n}:{protocol:n.protocol.slice(0,-1)}}var h$=new Set(["ENOTFOUND","EAI_AGAIN"]),m$=new Set(["ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT"]),g$=new Set(["ECONNRESET","ECONNABORTED","EPIPE"]),w$=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"]),y$=new Set(["TimeoutError","AbortError"]);function Bh(e,t,n){let r=b$(e),o=jh(e),i=`Failed to connect to ${t.hostname} port ${x$(t)}`;return y$.has(e?.name)||m$.has(r)?{code:28,message:n===null?`Operation timed out: ${o}`:`Operation timed out after ${n} milliseconds`}:h$.has(r)?{code:6,message:`Could not resolve host: ${t.hostname}`}:w$.has(r)?{code:60,message:`SSL certificate problem: ${o}`}:g$.has(r)?{code:56,message:`Recv failure: ${o}`}:{code:7,message:`${i}: ${o}`}}var x$=e=>e.port===""?e.protocol==="https:"?443:80:e.port;function b$(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 jh(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 Wh(e,t,n=null){try{return{response:await fetch(e.href,t)}}catch(r){return{failed:Bh(r,e,n)}}}async function qh(e,t,n=null){try{return{bytes:new Uint8Array(await e.arrayBuffer())}}catch(r){let{code:o,message:i}=Bh(r,t,n);return{failed:o===7?{code:56,message:`Recv failure: ${jh(r)}`}:{code:o,message:i}}}}async function _i(e){try{await e.body?.cancel()}catch{}}var k$={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"]},E$=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"]]),v$=new Map([["d","text"],["data","text"],["data-ascii","text"],["data-raw","raw"],["data-binary","binary"],["json","json"]]),$$=new Set(["H","header"]),S$=new Set(["o","output"]),A$=new Set(["O","remote-name"]),N$="application/x-www-form-urlencoded",Hh="application/json",O$=50,T$=new Set([10,13]);function Zh(e,t,n){let{flags:r,values:o,positional:i,order:s}=N(e,k$);if(r.has("h")||r.has("help"))return{help:!0};let a=I$(r,o);return a?{refusal:a}:{opts:C$(r,o,s,t,n),urls:i,targets:U$(s)}}function I$(e,t){for(let[n,r]of E$){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 C$(e,t,n,r,o){o.quiet=(e.has("s")||e.has("silent"))&&!e.has("S")&&!e.has("show-error");let i=_$(n,r,o);if(i===null)return null;let s=M$(t,n,i,o);if(s===null)return null;let a=Gh(t.get("max-redirs"),"--max-redirs",o),u=Gh(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 En(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?O$:a<0?1/0:a,timeout:u===void 0?null:Math.round(u*1e3)}}function Gh(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 _$(e,t,n){let r=[],o=new Set;for(let{name:a,value:u}of e){let l=v$.get(a);if(l===void 0)continue;let f=L$(l,u,t,n);if(f===null)return null;o.add(l==="json"?"json":"form"),r.push(f)}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(T("&")),s.push(u);return{bytes:et([...s,new Uint8Array]),json:i}}function L$(e,t,n,r){if(e==="raw"||!t.startsWith("@"))return T(t);let o=t.slice(1),i=o==="-"?F$(n,r.ctx):R$(o,r);return i===null?null:e==="text"?i.filter(s=>!T$.has(s)):i}function F$(e,t){let n=t.stdinBytes,r=t.stdinLeft===""?e:t.stdinLeft;return j(t,"",!0),n??T(r)}function R$(e,t){let{ctx:n}=t,r=U(n,"curl",e);return r.error||n.fs.isDir(r.path)?(bt(t,26,"Failed to open/read local data from file/application"),null):ce(n.fs,r.path)}function M$(e,t,n,r){let o=new Headers;n.bytes!==null&&o.set("content-type",n.json?Hh:N$),n.json&&o.set("accept",Hh);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 En(r,"feature","-u",2,"there is no interactive input here to read a password from");o.set("authorization",`Basic ${Tr(T(s))}`)}for(let{name:a,value:u}of t)if($$.has(a)&&!D$(o,u,r))return null;return o}function D$(e,t,n){let r=t.indexOf(":");if(r===-1)return t.endsWith(";")?Xh(e,t.slice(0,-1),"",n):Yh(n,t);let o=t.slice(r+1).trim();return o===""?(En(n,"option","-H",2,`-H "${t}": taking away a header the runtime sends is not supported`),!1):Xh(e,t.slice(0,r),o,n)}function Xh(e,t,n,r){try{e.set(t.trim(),n)}catch{return Yh(r,t.trim())}return!0}function Yh(e,t){return e.stderr+=`curl: -H: not a header: ${t}
113
- `,e.status=2,!1}function U$(e){let t=[];for(let{name:n,value:r}of e)S$.has(n)?t.push(r==="-"?null:{file:r}):A$.has(n)&&t.push({remote:!0});return t}function bt(e,t,n){return e.quiet||(e.stderr+=`curl: (${t}) ${n}
114
- `),e.status=t,!1}function En(e,t,n,r,o){return e.gap??={kind:t,detail:n,message:`curl: (${r}) ${o}`},bt(e,r,o),null}var P$=new Set([301,302,303,307,308]),z$=new Set([301,302,303]);async function Qh(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}=Zh(t,e,r);if(o)return{stdout:j$,stderr:"",exitCode:0};if(i)return i;if(s===null)return Vh(r);if(a.length===0)return B$();for(let[l,f]of a.entries())await W$(f,u[l]??null,s,r);return Vh(r)}var B$=()=>({stdout:"",stderr:`curl: try 'curl --help' for more information
115
- `,exitCode:2}),j$=`Usage: curl [options...] <url>
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
116
  -d, --data <data> send data in a POST body; @file reads a file, @- the pipe
117
117
  --data-raw <data> the same, taking a leading @ as data rather than a name
118
118
  --data-binary <data> the same, keeping a file's line endings
@@ -135,129 +135,113 @@ ${o}`,1)}:{mode:r}}function c$(e,t,n){let r=t.has("z")||t.has("zero")?"\0":`
135
135
 
136
136
  Every other option curl carries is refused by name, and says what would have
137
137
  to exist here for it to work.
138
- `;function Vh(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?Z(n,e.gap.kind,"curl",e.gap.detail,e.gap.message):n}async function W$(e,t,n,r){let o=zh(e);if(o.protocol)return En(r,"feature","protocol",1,Kh(o.protocol));if(o.malformed)return bt(r,3,"URL using bad/illegal format or missing URL");let i=t?.remote?q$(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:f,failed:c}=await Wh(s.url,H$(s,a),n.timeout);if(c)return bt(r,c.code,c.message);(n.include||n.head)&&(u+=J$(f,r.ctx));let d=G$(f,s,n);if(d===null)return V$(f,s.url,u,i,n,r);if(await _i(f),l>=n.redirects)return bt(r,47,`Maximum (${n.redirects}) redirects followed`);if(d.protocol)return En(r,"feature","protocol",1,Kh(d.protocol));Object.assign(s,d)}}var Kh=e=>`Protocol "${e}" not supported or disabled in libcurl`,q$=e=>e.pathname.slice(e.pathname.lastIndexOf("/")+1),H$=(e,t)=>({method:e.method,headers:e.headers,redirect:"manual",...e.body===null?{}:{body:e.body},...t===null?{}:{signal:t}});function G$(e,t,n){if(!n.location||!P$.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=z$.has(e.status)&&t.method!=="HEAD"&&t.method!=="GET";return{url:o,method:i?"GET":t.method,body:i?null:t.body,headers:Y$(t.headers,i,o.origin!==t.url.origin)}}var X$=Object.freeze(["content-type","content-length"]),Z$=Object.freeze(["authorization","cookie","proxy-authorization"]);function Y$(e,t,n){if(!t&&!n)return e;let r=new Headers(e);if(t)for(let o of X$)r.delete(o);if(n)for(let o of Z$)r.delete(o);return r}async function V$(e,t,n,r,o,i){if(o.failEarly&&e.status>=400)return await _i(e),bt(i,22,`The requested URL returned error: ${e.status}`);if(o.head)return await _i(e),Jh(n,null,r,i);let s=await qh(e,t,o.timeout);return s.failed?bt(i,s.failed.code,s.failed.message):Jh(n,s.bytes,r,i)}function Jh(e,t,n,r){return n!==null?K$(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 K$(e,t,n,r){let{ctx:o}=r;if(e==="")return bt(r,23,"Remote filename has no length");let i;try{i=o.writable&&o.fs.openWritable?.(o.cwd,e)}catch(s){return bt(r,23,`Failure writing output to destination: ${s.message}`)}return i?(i.writeBytes(et([T(t),n??new Uint8Array])),!0):En(r,"feature","read-only target",23,`${e}: file system is read-only`)}function J$(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
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
139
  `)+`\r
140
140
  \r
141
- `}var e1={...Lp,...Fh,...Dh,..._h},t1=Object.freeze({__proto__:null,curl:Qh}),gu=Object.freeze(Object.keys(t1)),wu=e=>e===!0&&Uh()?t1:null;var Li,kt;function n1(e){Li||(Li=Array.from({length:256},(n,r)=>r.toString(16).padStart(2,"0")));let t=e.length;if(Se){if(!kt){kt=new Uint16Array(256);let o=new Uint8Array(kt.buffer,kt.byteOffset,kt.byteLength);for(let i=0;i<256;i++){let s=Li[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]=kt[i],n[r+1]=kt[s],n[r+2]=kt[a],n[r+3]=kt[u]}for(;r<t;r++)n[r]=kt[e[r]];return Un(n)}return Kf(e,0,t,Li)}var{toHex:r1}=Uint8Array.prototype;function o1(e){return at(e),e.length===0?"":r1&&e.toHex===r1?e.toHex():n1(e)}var eS=new Uint8Array;function Fi(e,t,n,r,o){let i=i1(e,o.skip,o.skipFlag,0),s=i1(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,f=n,c=r.stdinBytes,d=[],p={stderr:"",failed:!1};for(let g of t.length?t:[null]){let w=le(e,g===null?[]:[g],f,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 E=w.inputs[0],S=E&&(E.shared||E.name===null);if(e==="hexdump"&&u&&S&&!r.stdinFile)return j(r,f,!0,c),{error:b("hexdump: standard input: Illegal seek")};let I=S&&r.stdinFile&&o.skip!==void 0&&(e==="xxd"||e==="hexdump"&&i.value>0),B=I?_(r.stdinOrigin):E?.bytes??eS,L=Math.min(u,B.length);u-=L,l+=L;let V=Math.min(a,B.length-L);if(d.push(B.subarray(L,L+V)),a-=V,S){let Q=B.subarray(L+V),q=c!==null&&!I&&Q.length>0?Q:null;f=q===null?X(Q):$e(Q)??"",j(r,f,!0,q)}if(I&&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 i1(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 ba(BigInt(i),o[2],`${e}: ${n}`,t)}var no=16,tS=47,nS=39;function u1(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=Fi("hexdump",i,e,n,{skip:o.get("s"),len:o.get("n"),skipFlag:"-s",lenFlag:"-n"});return s.error?s.error:fe(yu(s.bytes,s.start,r.has("v"),r.has("C")?oS:rS),s.r)}function l1(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=Fi("od",i,e,n,{skip:o.get("j"),len:o.get("N"),skipFlag:"-j",lenFlag:"-N",skipPastEofErrors:!0});return s.error?s.error:fe(yu(s.bytes,s.start,r.has("v"),iS),s.r)}function f1(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=Fi("xxd",o.slice(0,1),e,n,{skip:r.get("s"),len:r.get("l"),skipFlag:"-s",lenFlag:"-l"});return i.error?i.error:fe(yu(i.bytes,i.start,!1,sS),i.r)}function yu(e,t,n,r){let o=r.hex?o1(e):"",i=[],s=null,a=!1;for(let l=0;l<e.length;l+=no){let f=e.subarray(l,l+no),c=r.hex?o.slice(l*2,(l+no)*2):"";r.compress&&!n&&s!==null&&f.length===no&&lS(f,s)?a||(i.push("*"),a=!0):(i.push(r.row(t+l,f,c)),a=!1),s=f}let u=t+e.length;return(r.trailer==="always"||r.trailer==="nonzero"&&u>0)&&i.push(r.addr(u)),Ae(i)}var rS={compress:!0,trailer:"nonzero",addr:s1,row:(e,t)=>(s1(e)+" "+c1(t).map(fS).join(" ")).padEnd(tS)},oS={compress:!0,trailer:"nonzero",addr:xu,hex:!0,row:aS},iS={compress:!0,trailer:"always",addr:a1,row:(e,t)=>a1(e)+" "+c1(t).map(cS).join(" ")},sS={compress:!1,trailer:"never",hex:!0,row:(e,t,n)=>`${xu(e)}: ${uS(t,n).join(" ").padEnd(nS)} ${d1(t)}`};function s1(e){return e.toString(16).padStart(7,"0")}function xu(e){return e.toString(16).padStart(8,"0")}function a1(e){return e.toString(8).padStart(7,"0")}function aS(e,t,n){let r=[];for(let s=0;s<no;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`${xu(e)} ${o} ${i} |${d1(t)}|`}function c1(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 uS(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 d1(e){let t="";for(let n of e)t+=n>=32&&n<=126?String.fromCodePoint(n):".";return t}function lS(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}var fS=e=>e.toString(16).padStart(4,"0"),cS=e=>e.toString(8).padStart(6,"0");var dS=76;function Ri(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=dS;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 f=le(e,a,r,i,{read:"as-held"});if(f.failed)return b(f.stderr);let{content:c,bytes:d}=f.inputs[0];return s.has("d")||s.has("decode")?hS(e,n(c??fa(d),s.has("i")||s.has("ignore-garbage"))):pS(t(d??T(c)),l)}}function pS(e,t){if(!t||e==="")return M(e);let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return M(n.join(`
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
142
  `)+`
143
- `)}function hS(e,{bytes:t,valid:n}){let r=$e(t),o=n?"":`${e}: invalid input
144
- `;if(r!==void 0&&n)return M(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 p1=[{},{},{}],h1=[[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],[..."0123456789ABCDEFGHIJKLMNOPQRSTUV"],[..."0123456789ABCDEFGHJKMNPQRSTVWXYZ"]],vn="Invalid character in base32 input",bu="Invalid base32 padding",mS="Invalid base32 length",Mi="Invalid last chunk",gS=Qe;function m1(e,t,n){at(e);let r=Math.floor(e.length/5),o=r*5,i="",s=0,a=h1[t],u=p1[t];if(!u.pairs)if(u.pairs=[],Se){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:f}=u;if(Se){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=e[s+4],S=m<<2|g>>6,I=(g&63)<<4|w>>4,B=(w&15)<<6|y>>2,L=(y&3)<<8|E;p[h]=f[S],p[h+1]=f[I],p[h+2]=f[B],p[h+3]=f[L],h+=4}i=Un(p)}else if(gS)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,E=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,I=(g&3)<<8|w;i+=`${l[y]}${l[E]}${l[S]}${l[I]}`}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,E=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,I=(g&3)<<8|w;i+=l[y],i+=l[E],i+=l[S],i+=l[I]}let c=0,d=3;for(;s<e.length;s++){let p=e[s];i+=a[c|p>>d],d>=5&&(d-=5,i+=a[p>>d&31]),c=p<<5-d&31,d+=3}return d!==3&&(i+=a[c]),n&&(i+=["","======","====","===","="][e.length-o]),i}var wS=Ie?128:65536;function g1(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(mS);if(r>7||r!==0&&e.length%8!==0)throw new SyntaxError(bu);let s=h1[t],a=p1[t];if(!a.fromMap){a.fromMap=new Int8Array(wS).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)),f=0,c=0;if(Ie){let g=Sr(e,vn);for(;c<i;c+=8){let w=g[c],y=g[c+1],E=g[c+2],S=g[c+3],I=g[c+4],B=g[c+5],L=g[c+6],V=g[c+7],Q=u[w]<<15|u[y]<<10|u[E]<<5|u[S],q=u[I]<<15|u[B]<<10|u[L]<<5|u[V];if(Q<0||q<0)throw new SyntaxError(vn);l[f]=Q>>12,l[f+1]=Q>>4&255,l[f+2]=Q<<4&255|q>>16,l[f+3]=q>>8&255,l[f+4]=q&255,f+=5}}else for(;c<i;c+=8){let g=e.charCodeAt(c),w=e.charCodeAt(c+1),y=e.charCodeAt(c+2),E=e.charCodeAt(c+3),S=e.charCodeAt(c+4),I=e.charCodeAt(c+5),B=e.charCodeAt(c+6),L=e.charCodeAt(c+7),V=u[g]<<15|u[w]<<10|u[y]<<5|u[E],Q=u[S]<<15|u[I]<<10|u[B]<<5|u[L];if(V<0||Q<0)throw new SyntaxError(vn);l[f]=V>>12,l[f+1]=V>>4&255,l[f+2]=V<<4&255|Q>>16,l[f+3]=Q>>8&255,l[f+4]=Q&255,f+=5}if(o<2)return l;let d=u[e.charCodeAt(c++)]<<5|u[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(vn);if(l[f++]=d>>2,o<4){if(d&3)throw new SyntaxError(Mi);return l}let p=u[e.charCodeAt(c++)]<<5|u[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(vn);if(l[f++]=d<<6&255|p>>4,o<5){if(p&15)throw new SyntaxError(Mi);return l}let h=u[e.charCodeAt(c++)];if(h<0)throw new SyntaxError(vn);if(l[f++]=p<<4&255|h>>1,o<7){if(h&1)throw new SyntaxError(Mi);return l}let m=u[e.charCodeAt(c++)]<<5|u[e.charCodeAt(c++)];if(m<0)throw new SyntaxError(vn);if(l[f++]=h<<7&255|m>>3,m&7)throw new SyntaxError(Mi);return l}function w1(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Dn);if(o!==null&&Yo(o),n===!0){if(e.length%8!==0)throw new SyntaxError(bu)}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 ut(g1(e,t),r)}var ku=e=>(t,n)=>{if(!n)return w1(t,e,"both","uint8",null);let{format:r="uint8",padding:o="both",...i}=n;return w1(t,e,o,r,i)},y1=ku(0),r5=ku(1),o5=ku(2),x1=(e,{padding:t=!1}={})=>m1(e,0,t);var xS="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",ro=8,bS=Object.freeze([2,4,5,7,8]),b1=Ri("base32",{encode:e=>x1(e,{padding:!0}),decode:ES}),kS=/[a-z]/u;function ES(e,t=!1){let n=e.replace(t?/[^A-Z2-7=]/gu:/\n/gu,"");try{let r=y1(n,{padding:!0});if(!kS.test(n))return{bytes:r,valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r}return vS(n)}function vS(e){let t=new Uint8Array(Math.ceil(e.length/ro)*5),n=0,r=0,o=!0;for(;r<e.length;){if(e.length-r<ro){o=!1;break}let i=e.slice(r,r+ro),s=/^[A-Z2-7]*/u.exec(i)[0];if(n+=$S(i,s,t.subarray(n)),!bS.includes(s.length)||i.slice(s.length)!=="=".repeat(ro-s.length)){o=!1;break}r+=ro}return{bytes:t.subarray(0,n),valid:o}}function $S(e,t,n){let r=0,o=0,i=0;for(let s of t)o=o<<5|xS.indexOf(s),r+=5,!(r<8)&&(r-=8,n[i++]=o>>r&255);return i}var Eu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k1=Ri("base64",{encode:Tr,decode:SS});function SS(e,t=!1){let n=e.replace(t?/[^A-Za-z0-9+/=]/gu:/\n/gu,"");try{return{bytes:Ir(n,{padding:!0}),valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r;return AS(n)}}function AS(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=Ir(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=Eu.indexOf(e[o]),f=Eu.indexOf(e[o+1]),c=u===3?Eu.indexOf(e[o+2]):0;t[r++]=l<<2|f>>4,u===3&&(t[r++]=f<<4|c>>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 NS=["n","N","i","s","w","F","v","l","c","q","u","a","H","I"],OS=["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"],v1={short:NS,long:OS,valueShort:["A","B","C"],valueLong:["after-context","before-context","context"],repeatable:["e","regexp"]},TS=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"})),IS=new Set(["no-heading","no-ignore"]),oo=(e,t)=>new x("feature",e,`rg: ${t}`);function $1(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)IS.has(o)||CS(t,TS.get(o)??o,i,vu(o));let n=o=>t.context.findLast(([i])=>i===o)?.[1],r=o=>t.context.findLast(([i])=>i===o)?.[2]??"-"+o;if(t.after=E1(n("A")??n("C"),n("A")===void 0?r("C"):r("A")),t.before=E1(n("B")??n("C"),n("B")===void 0?r("C"):r("B")),t.unrestricted>=2&&(t.hidden=!0),t.unrestricted>=3)throw oo("-uuu","searching binary files is not supported");return t}function CS(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 oo(vu(t),`${vu(t)} is not supported`)}}function E1(e,t){if(e===void 0)return 0;if(!/^\d+$/u.test(e))throw oo(`${t} value`,`error parsing flag ${t}: value is not a valid number`);return Number(e)}var vu=e=>(e.length===1?"-":"--")+e;function S1(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,String.raw`\Q…\E literal span`]];function LS(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 A1(e,t){if(!t)for(let n of e){for(let[r,o]of _S)if(r.test(n))throw oo(o,`${o} is not supported; ripgrep's regex engine rejects it too`);if(LS(n))throw oo("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}},N1=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"]),$u={__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]},Di=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)"]]),O1=new Set([...Object.keys($u),...Di.keys()]),io=5e6,Su=100,je=1e6,Ui="this terminal runs no processes";function Pi(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 T1={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},FS='^$.[]|()*+?{}\\/"',Au=1e3,I1=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),C1=e=>e!==void 0&&e>="0"&&e<="7",Nu=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+=nt(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>Au||s!==null&&s>Au)throw new A(`interval count above ${Au} 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 T1)return T1[t];if(C1(t)){let o=t;for(;o.length<3&&C1(this.peek());)o+=this.src[this.i++];return _1(o,8)}if(t==="x"&&I1(this.peek())){let o="";for(;o.length<2&&I1(this.peek());)o+=this.src[this.i++];return _1(o,16)}let r=this.src.codePointAt(this.i-1);return!FS.includes(t)&&n&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(r)}' is not a known regexp operator`),this.i+=nt(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?ii(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+=nt(n),n}};function Bi(e,t=null,n=ue(ae),r=!1){let o=new Nu(e,t,n,r);return{ast:o.parse(),groups:o.groups}}function _1(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 RS=e=>`\\u{${e.toString(16)}}`,zi=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):RS(e);function MS(e,t){if(e==="^"||e==="$")return e;let n=t.assertions();return e==="y"?n.boundary:e==="B"?n.inside:n[e]}function Ou(e,t=ue(ae)){let n=r=>Ou(r,t);switch(e.type){case"char":return zi(e.code);case"any":return".";case"set":return`[${e.negate?"^":""}${e.items.map(([r,o])=>r===o?zi(r):`${zi(r)}-${zi(o)}`).join("")}]`;case"assert":return MS(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 DS=5e4;function US(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 ji(e,t=ue(ae)){let n=[],r=l=>{if(n.length>=DS)throw new A("regex too large",null,"regex state limit");return n.push(l),n.length-1};function o(l,f){switch(l.type){case"char":return r({op:"char",codes:[l.code],next:f});case"any":return r({op:"any",next:f});case"set":return r({op:"set",test:US(l.items,l.negate),next:f});case"assert":return r({op:"assert",kind:l.kind,next:f});case"group":return o(l.node,f);case"cat":{let c=f;for(let d=l.nodes.length-1;d>=0;d--)c=o(l.nodes[d],c);return c}case"alt":{let c=l.nodes.map(p=>o(p,f)),d=c.at(-1);for(let p=c.length-2;p>=0;p--)d=r({op:"split",x:c[p],y:d});return d}case"rep":return i(l,f);default:throw new A(`internal: unknown regex node ${l.type}`)}}function i(l,f){let c=f;if(l.max===null){let d=r({op:"split",x:-1,y:f});n[d].x=o(l.node,d),c=d}else for(let d=l.max-l.min;d>0;d--)c=r({op:"split",x:o(l.node,c),y:f});for(let d=0;d<l.min;d++)c=o(l.node,c);return c}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 PS(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 zS(e,t,n,r){if(e==="^")return n===0;if(e==="$")return n===t.length;let o=r(PS(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 BS(e,t){return e.op==="char"?e.codes.includes(t):e.op==="any"?!0:e.test(t)}function Wi(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 E=r[y];E.op==="split"?s.push(E.y,E.x):E.op==="assert"?zS(E.kind,t,g,e.isWord)&&s.push(E.next):p.push(y,m)}},u=[],l=[],f=null,c=n,d=++e.stamp;for(;;){f===null&&a(u,e.start,c,c,d);let p=c<i?t.codePointAt(c):-1,h=nt(p);if(u.length===0){if(f!==null||c>=i)break;c+=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(f!==null&&y>f.start)continue;let E=r[w];if(E.op==="match"){(f===null||y<f.start||y===f.start&&c>f.end)&&(f={start:y,end:c});continue}p!==-1&&BS(E,p)&&a(l,E.next,y,c+h,m)}if(u.length=0,[u,l]=[l,u],d=m,c>=i)break;c+=h}return f}var qi=new Map,Mt=class{constructor(t,n,r,o=ue(ae)){let{ast:i,groups:s}=Bi(t,r,o,n);this.src=t,this.ignoreCase=n,this.tables=o,this.groupCount=s,this.source=Ou(i,o),this.flags="su";try{this.js=new RegExp(Gn(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=L1(i)}test(t){return this.checkCase(t),this.js.test(t)}checkCase(t){if(this.ignoreCase&&pn.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=ji(this.ast,this.tables)),Wi(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 L1(e){let n=(e.nodes??(e.node?[e.node]:[])).map(L1),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 Ye(e,t=!1,n=null,r=ue(ae)){let o=(t?"i":"c")+r.name+"\0"+e,i=qi.get(o);if(i)return i;qi.size>=500&&qi.clear();let s=new Mt(e,t,n,r);return qi.set(o,s),s}function Tu(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+He(e,r.end)}}function Iu(e,t){let n=[],r=0;for(;;){let o=Tu(e,t,r);if(!o)break;n.push(e.slice(r,o.start)),r=o.end}return n.push(e.slice(r)),n}function so(e,t,n,r){let o=r!=="first",i=e.length,s="",a=0,u=-1,l=0;for(;a<=i;){let f=t.search(e,a);if(!f)break;let c=f.start===f.end;if(c&&f.start===u&&r!=="nth"){if(f.start>=i)break;let p=He(e,f.start);s+=e.slice(a,f.start+p),a=f.start+p;continue}l++;let d=n(f.start,f.end,l);if(s+=e.slice(a,f.start)+(d===null?e.slice(f.start,f.end):d),u=f.end,c){if(f.end>=i){a=i;break}let p=He(e,f.end);s+=e.slice(f.end,f.end+p),a=f.end+p}else a=f.end;if(!o)break}return{out:s+e.slice(a),count:l}}function Hi(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=jn(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=!jS(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 jS(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 Gi(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 f=0;f<e.length;f++){let c=e[f];if(c==="\\"){let d=e[++f];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){c==="]"&&(o=!1);continue}if(c==="["){o=!0,a=[];continue}if(c==="(")n.push({id:++i,entry:new Set(u),branches:[],start:f}),a=[];else if(c==="|"){let d=n.at(-1);d&&d.branches.push(u),u=new Set(d?.entry),a=[]}else if(c===")"){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=WS(e.slice(d.start,f+1))}else if(c==="*"||c==="?"||c==="+"){if(c!=="?"&&l)for(let d of a)r.add(d);if(c!=="+")for(let d of a)u.delete(d)}else if(c==="{"){let d=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(f));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)),f+=d[0].length-1}else a=[]}else a=[]}return s}function WS(e){try{return new RegExp(`^(?:${e})$`,"su").test("")}catch{return!0}}var qS="bBsSwW";function ao(e,t){let n="";for(let r=0;r<e.length;){let o=e[r];if(o==="["){let l=HS(e,r,t);n+=l.text,r=l.end;continue}let i=o==="\\",s=e.codePointAt(r+(i?1:0)),a=(i?1:0)+nt(s),u=i&&qS.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 F1(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 HS(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],f=e.indexOf(l+"]",r+2);o+=l===":"?`[:${ii(e.slice(r+2,f))}:]`:e.slice(r,f+2),r=f+2;continue}let a=e.codePointAt(r),u=r+nt(a);if(e[u]==="-"&&e[u+1]!==void 0&&e[u+1]!=="]"){let l=e.codePointAt(u+1),f=u+1+nt(l);o+=GS(a,l,e.slice(r,f),n),r=f;continue}o+=String.fromCodePoint(...n.fold(a)),r=u}}function GS(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 M1({pattern:e,tables:t},n){return[...e].map(r=>(n?t.fold(r.codePointAt(0)):[r.codePointAt(0)]).map(i=>T(String.fromCodePoint(i))))}function Lu(e,t){return t.every(n=>n.literal?(n.literalMask??=M1(n.literal,n.folded),!U1(e,n.literalMask)):!1)}function D1(e,t,n,r=ae){let o=ue(r);return t.every(i=>(n||!z1.test(i))&&i.isWellFormed()&&!U1(e,M1({pattern:i,tables:o},!1)))}function U1(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(P1(e,r,t,0))return!0;return!1}function P1(e,t,n,r){return r===n.length?!0:n[r].some(o=>o.every((i,s)=>e[t+s]===i)&&P1(e,t+o.length,n,r+1))}var z1=/[\\.^$*+?()[\]{}|]/u,XS=new Set("\\.[*^$"),ZS=new Set("\\.[*^$+?(){}|");function B1(e,t){if(t.has("F"))return e;if(t.has("P"))return z1.test(e)?null:e;let n=t.has("E")?ZS:XS,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 Cu=new Map;function j1(e){if(Cu.has(e))return Cu.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=wa(e.body("word")+n),o={"<":r["<"],">":r[">"],b:r.boundary,B:r.inside,W:Xi(t.nonWord),S:Xi(t.nonSpace)};return Cu.set(e,o),o}var Xi=e=>`(?:(?![${cn}])${e})`;function W1(e){let t=ji(e.ast,e.tables),n=t.states.map(o=>o.op==="any"?{op:"set",test:i=>!Bt(i),next:o.next}:o.op==="set"?{...o,test:i=>!Bt(i)&&o.test(i)}:o),r={...t,states:n,isWord:o=>e.tables.has("word",Bt(o)?o-56320:o)};return{search:(o,i)=>Wi(r,o,i)}}var YS=[0,0,0,0,1114112,2097152,67108864],R1=(e,t)=>Bt(e.codePointAt(t))?e.codePointAt(t)-56320:-1;function q1(e,t){let n=R1(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=R1(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>=YS[r]?r:0}function H1(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>65535&&t++,!Bt(n))continue;let r=q1(e,t);if(r===0||r===3)return!0;t+=r-1}return!1}var VS=/[\uDCED\uDCF0-\uDCFD][\uDC80-\uDCBF]{2,5}/gu;function G1(e){let t={long:!1,surrogate:!1};for(let[n]of e.matchAll(VS)){let r=q1(n,0);if(r===3?t.surrogate=!0:r&&(t.long=!0),t.long&&t.surrogate)break}return t}function X1(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=ti(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 Z1(e,t,n){return t.long||t.surrogate?e.wordEdge||(e.dot||e.negated)&&(e.regex||n)?!0:t.long&&e.negated:!1}var _u=new Map;function Y1(e){return _u.has(e)||_u.set(e,new RegExp(`[^\\x00-\\x7f${cn}${e.body("word")}]`,"u")),_u.get(e)}function We(e){throw new x("feature","PCRE "+e,`PCRE ${e} is not supported`)}function V1(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=K1(e,r,t,!1);n+=i.source,r=i.end;continue}if(o==="["){let i=QS(e,r,t);n+=i.source,r=i.end;continue}if(o==="("){let i=KS(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&&We("variable-length lookbehind"),e[r+1]==="+"&&We("possessive repetition"),o!=="+"&&(t.risky=!0)),o==="|"&&(t.risky=!0),o==="{"){let i=JS(e,r,t);n+=i.source,r=i.end;continue}n+=o==="]"||o==="}"?"\\"+o:o,r++}return t.references&&t.risky&&We("conditional backreference"),n}function KS(e,t,n){let r=!1,o=null,i="(";if(e[t+1]==="*"&&We("control verb"),e[t+1]==="?"){let s=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(s||We("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 JS(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&We("repetition"),{source:"\\{",end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&We("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]==="+"&&We("possessive repetition"),{source:r[0],end:t+r[0].length}}function QS(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]??"")&&We("character class"),e[r]==="\\"){let i=K1(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 K1(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 eA(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)))&&We("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])))&&We("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)&&We("escape \\"+o);let i=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(i),end:t+1+i.length}}function eA(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 ht(i)||We("character escape"),{source:`\\u{${i.toString(16)}}`,end:t+r[0].length}}function Ru(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:tA(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=jn(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 tA(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?"\\"+e:RegExp.escape(e)}function nA(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 $n(e,t="js",n=ue(ae)){let r=t==="extent",o=t==="marked",i=r?{b:"\\y"}:o?{...J1(n),...j1(n)}:J1(n),s="",a=!1;for(let u=0;u<e.length;u++){let l=e[u];if(l==="\\"){let f=e[++u];s+=!a&&Object.hasOwn(i,f)?i[f]:l+f,!r&&!a&&/[1-9]/u.test(f)&&/\d/u.test(e[u+1]??"")&&(s+="(?:)")}else if(o&&l==="["){let f=om(e,u);s+=Xi(e.slice(u,f+1)),u=f}else o&&l==="."?s+=`[^${cn}]`:(l==="["&&(a=!0),l==="]"&&(a=!1),s+=l)}return s}function J1(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 Mu=e=>e.plain??=new RegExp(e.source,e.flags);function rm(e){return e.markedSource===void 0?Mu(e):(e.marked??=new RegExp(Gn($n(e.markedSource,"marked",e.tables)),e.flags),e.marked)}var Du=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,rA=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function Q1(e,t,n){let r=(n?Du:rA).exec(e.slice(t));if(!r&&!n)throw new Error("invalid repetition count");r&&_c(Number(r[1]),r[2]===void 0||r[2]===""?void 0:Number(r[2]))}var em={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function oA(e){if(em[e])return em[e];let t=Du.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===""?1/0:Number(t[2])}}var tm=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function iA(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=tm(t.max,e.max);return r!==1/0&&r>ei?null:{min:tm(t.min,e.min),max:r}}function Fu(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 sA=e=>!e.startsWith("(")&&!/^\\[1-9]/u.test(e);function aA(e,t){if(t.length===1)return e+Fu(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?iA(n,i):null;if(a){n=a;continue}if(!(r===null&&n.min===n.max&&sA(e))&&i.max>1)throw new Error("stacked quantifier needs ambiguous nesting");r=`(?:${r??e+Fu(n)})${s}`}return r??e+Fu(n)}function om(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 nm(e){let t="",n=-1,r=-1,o=[],i=()=>{o.length>0&&(t=t.slice(0,n)+aA(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 c=om(e,u);s(e.slice(u,c+1)),u=c;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 f=l==="{"?Du.exec(e.slice(u)):null;if(l==="*"||l==="+"||l==="?"||f){let c=f?f[0]:l;if(u+=c.length-1,n<0){t+=c;continue}o.length===0&&(r=t.length),o.push({bounds:oA(c),text:c});continue}s(l)}return i(),t}function Uu(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==="{"&&Q1(e,o-1,!1)}else if(s==="["&&!i)r=ti(e,o,n);else{if(i)continue;if(t&&s==="{")Q1(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 uA(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"&&/[1-9]/u.test(e[++t]??""))return!0;return!1}function lA(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 im(e,t,n=ae){let r=ue(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&&Uu(a,t.has("E"),r.multibyte);let l=u&&uA(a),f=t.has("i")&&!t.has("P")&&!l,c=t.has("i")&&!f?"isu":"su",d;if(t.has("F"))d=f?F1(a,r):RegExp.escape(a);else if(t.has("P"))d=V1(a);else if(t.has("E"))d=Ru(f?ao(a,r):a,r);else{let h=Hi(f?ao(a,r):a,r);if(h.error)return{error:b(`grep: ${h.error}`,2)};d=h.source}let p=d;if(u&&Gi(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?nm(d):d,m=new RegExp(Gn(u?$n(h,"js",r):d),c);u&&Object.assign(m,{markedSource:h,tables:r,shape:X1(a,l)}),m.pcre=t.has("P"),m.localeSensitive=m.pcre?t.has("i")||s||nA(p)||/\\[dD]/u.test(p):t.has("i")&&l,m.folded=f,m.extendedC=f&&pn.test(a),m.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(a),m.wellFormed=a.isWellFormed(),m.emptyWord=s&&!m.pcre&&new RegExp(u?$n(nm(p),"js",r):p,c).test(""),m.anyCharacter=lA(p);let g=B1(a,t);if(g?.isWellFormed()&&(f||!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 Mt($n(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")&&fA(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 /${c}`:t.has("P")?`PCRE subset /${c}`:t.has("E")?`ERE / ECMAScript /${c}`:`BRE /${c}`;return{error:b(`grep: invalid pattern (${m}): ${h.message}`,2)}}}return{res:o}}function fA(e,t){if(!t.has("E")&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return Bi($n(e,"extent")),!0}catch(n){return!!n.gap}}function Pu(e,t,n=ae,r=!1){let o=(f,c)=>v("feature","grep",f,`grep: ${c}`,2);if(e.marked){if(t.some(f=>f.pcre))return o("binary input","PCRE matching over bytes that spell no text is not supported");if(t.some(f=>!f.wellFormed))return o("unpaired surrogate","a pattern holding an unpaired UTF-16 surrogate cannot be matched against bytes")}if(t.some(f=>f.emptyWord)&&Y1(ue(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(f=>f.shape&&(f.shape.wordEdge||f.shape.dot||f.shape.negated)):[],s=i.length?G1(e.content):null;if(i.some(f=>Z1(f.shape,s,r)))return o("binary input","matching this pattern beside bytes glibc reads as a character is not supported");let a=()=>t.some(f=>f.unicodePattern)||/[\u0080-\u{10FFFF}]/u.test(e.content);if(n!==ae&&t.some(f=>f.localeSensitive||f.folded||f.anyCharacter)&&a())return o("locale",`matching non-ASCII text in the ${n} locale is not supported`);if(t.some(f=>f.extendedC)||t.some(f=>f.folded)&&pn.test(e.content))return o("locale-sensitive regex","case-insensitive matching over Cyrillic Extended-C letters is not supported");let u=t.filter(f=>f.localeSensitive);if(u.length===0||!a())return null;let l=u.some(f=>f.pcre)?"PCRE matching":"case-insensitive matching with backreferences";return o("non-ASCII regex semantics",`${l} on non-ASCII input is not supported`)}var zu=/[*?[]/u,Bu=/\P{ASCII}/u,cA=/[.+*?^${}()|[\]\\/]/u;function Ve(e,t={}){try{return dA(e,t)}catch(n){throw n instanceof x?n:new x("feature","glob pattern",`unsupported glob pattern: ${n.message}`)}}function dA(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+=sm(s,t.ignoreCase),o++}else if(i==="*"){for(;e[o+1]==="*";)o++;n+=".*"}else if(i==="?")n+=".";else if(i==="["){let s=am(e,o,t);if(s?.voided)return/^(?!)$/u;s?(n+=s.source,o=s.end,r||=s.nonAsciiRange):n+="\\["}else n+=sm(i,t.ignoreCase)}return hA(new RegExp(n+"(?![\\s\\S])","us"),e,t,r)}function sm(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:cA.test(e)?"\\"+e:e}function pA(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 hA(e,t,n,r){let o=/[?[]/u.test(t),i=Bu.test(t);return{test(s){if(r||n.ignoreCase&&i||(o||n.ignoreCase)&&Bu.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 am(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,f=!1,c=!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?mA(e,o):jn(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&&(c=!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&&Bu.test(h+w)&&(f=!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:c?{voided:!0,end:o}:{source:r?pA(s,a,i):`[${i?"^":""}${s}]`,end:o,nonAsciiRange:f}}function mA(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":dn[r]??"",end:n+2}}function um(e,t){return Ve(t).test(e)}function lm(e){let{value:t,mask:n}=e;if(n===null)return zu.test(t);for(let r=0;r<t.length;r++)if(n[r]==="0"&&zu.test(t[r]))return!0;return!1}function uo(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=gA(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]==="("&&t(n+1))return!0}}return!1}function gA(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 wA=/[*?[\]^!\\:.=-]/u;function ar(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"&&wA.test(i)?"\\"+i:i}return r}function fm(e,t){let n=ar(e),r=n.match(/[^/]+|\/+/gu)??[],o=Wn(),i=new Set,s=[{path:"",marks:null}],a;try{for(let l=0;l<r.length;l++){let f=r[l];if(f.startsWith("/")||!zu.test(f)){s=s.map(c=>({...c,path:c.path+xA(f)}));continue}s=bA(s,f,l===r.length-1,t,i)}let u=s.filter(l=>$(t.cwd,l.path,t.fs,{follow:!1}).path!==null);for(let l of u)for(let f of l.marks??[])o.add(f);return a=u.filter(l=>l.marks===null).map(l=>l.path).sort(G),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(yA)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function yA(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(am(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var xA=e=>e.replace(/\\(.)/gu,"$1");function bA(e,t,n,r,o){let i=Ve(t,{bash:!0}),s=t.startsWith(".")||t.startsWith("\\."),a=[];for(let u of e){let l=$(r.cwd,u.path||".",r.fs).path;if(!r.fs.isDir(l))continue;let{dirs:f,files:c,links:d}=r.fs.listDir(l),p=n?d:d.filter(h=>r.fs.isDir($(l,h,r.fs).path));for(let h of n?[...f,...c,...p]:[...f,...p]){let m=!s&&h.startsWith(".");if(!m&&u.marks===null)i.test(h)&&a.push({path:u.path+h,marks:null});else if(kA(i,h)){if(!m){a.push({path:u.path+h,marks:u.marks});continue}let g=H(l,h);o.add(g),a.push({path:u.path+h,marks:[...u.marks??[],g]})}}}return a}function kA(e,t){try{return e.test(t)}catch{return!0}}var lo=(e,t)=>e.some(n=>n.test(t)),pm=()=>({stdout:"",stderr:"",exitCode:1}),Sn=e=>e.failure!==void 0,Yi=e=>e.name??"(standard input)",hm=e=>e.binaryLine===void 0?e.content:e.content.replaceAll("\0",`
146
- `),Ki=(e,t)=>t.map(e.marked?rm:Mu);function Ji(e,t,n,r){if(r===0)return 0;let o=Ki(e,t),i=hm(e),s=0;if(r===1/0){for(let u of we(i))lo(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),lo(o,i.slice(a,u))!==n&&s++,a=u+1}return s}function mm(){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||!zn.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:da(n)})},err(n){n&&t(2,n)}}}function gm(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 wm(e,t,n){let r={used:!1,write:mm(),selected:!1};for(let o of e)Sn(o)?r.write.err(o.failure):EA(o,t,n,r);return gm(r.write.events,r.selected)}function EA(e,t,n,r){if(e.binaryLine===0)return vA(e,t,n,r);let o=hm(e),i={input:e,opts:n,run:r,lines:we(o),res:t,tests:Ki(e,t),bufbeg:0,name:n.showName??e.recursive?Yi(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=cm(i,0,a);if(i.pending>0&&Vi(i,a),a<s&&!(i.outleft===0&&i.pending===0)&&!i.quiet){let l=a;for(let f=0;f<n.before&&l>0&&l!==i.lastout;f++)l--;l!==i.lastout&&(i.lastout=null),i.bufbeg=l,i.outleft>0&&(u+=cm(i,a,s)),i.pending>0&&Vi(i,s)}r.write.lines(Ae(i.out),e.marked,i.name??""),u>0&&(r.selected=!0),(i.heldBack||i.quiet)&&ym(e,n,r)}function vA(e,t,n,r){Ji(e,t,n.invert,1)!==0&&(r.used=r.selected=!0,ym(e,n,r))}function ym(e,t,n){t.binaryFiles==="binary"&&n.write.err(`grep: ${Yi(e)}: binary file matches
149
- `)}function cm(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&&!lo(e.tests,e.lines[a]);)a++;if(a===n&&!r)break;if(!r||s<a){if(r&&s<o&&a>o){if(i+=ju(e,s,o),e.outleft===0)break;s=o}if(!e.quiet&&(r?s:a)>=o&&(e.pending>0&&Vi(e,o),e.quiet=!0),i+=r?ju(e,s,a):ju(e,a,a+1),e.outleft===0||e.quiet)break}s=a+1}return i}function ju(e,t,n){let{before:r,after:o,hasContext:i,invert:s}=e.opts;!e.quiet&&e.pending>0&&Vi(e,t);let a=t;if(!e.quiet){let l=e.lastout??e.bufbeg;for(let f=0;f<r;f++)a>l&&a--;for(i&&e.run.used&&a!==e.lastout&&e.out.push("--");a<t;a++)Zi(e,a,!1)}let u;if(s)for(u=0;a<n&&u<e.outleft;u++,a++)e.quiet||Zi(e,a,!0);else e.quiet||Zi(e,t,!0),u=1;return e.pending=e.quiet?0:o,e.run.used=!0,e.outleft-=u,u}function Vi(e,t){for(e.lastout??=e.bufbeg;e.pending>0&&e.lastout<t;e.pending--)Zi(e,e.lastout,!1)}function Zi(e,t,n){let r=e.lines[t];if(e.opts.only)n!==e.opts.invert&&$A(e,r,t,n);else{if(e.input.marked&&e.opts.binaryFiles!=="text"&&zn.test(r)&&H1(r)){e.heldBack=!0;return}e.out.push(xm(e,r,t,n))}e.lastout=t+1}function $A(e,t,n,r){let o=e.input.marked&&zn.test(t),i=0;for(;i<t.length;){let s=null;for(let a=0;a<e.res.length;a++){let u=SA(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+He(t,s.end);continue}e.out.push(xm(e,t.slice(s.start,s.end),n,r)),i=s.end}}var dm=new WeakMap;function SA(e,t,n,r,o){if(e.extent)return(o?e.markedExtent??=W1(e.extent):e.extent).search(n,r);let i=dm.get(t);i||dm.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 xm(e,t,n,r){let o=r?":":"-";return(e.name===null?"":e.name+o)+(e.opts.showLine?n+1+o:"")+t}function bm(e,t,{mode:n,invert:r,showName:o,max:i=1/0}){let s=mm(),a=!1,u=n==="c"?i:Math.min(1,i);for(let l of e){if(Sn(l)){s.err(l.failure);continue}let f=Ji(l,t,r,u);f>0&&(a=!0),n==="c"?s.out((o??l.recursive?Yi(l)+":"+f:String(f))+`
150
- `):f>0==(n==="l")&&s.out(Yi(l)+`
151
- `)}return gm(s.events,a)}function km(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 f of a.split(`
153
- `))i.add(f);continue}let u=Ot("grep",[a],n,t);if(u.failed)return{error:b(u.stderr,2)};let l=u.inputs[0];for(let f of we(l.content))i.add(f);l.shared&&(t="")}return{patterns:[...i],rest:o,stdin:t}}var Em="[-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]",AA=`grep ${Em} PATTERN [PATH...]
154
- or: grep ${Em} [-e PATTERN] [-f FILE] ... [PATH...]`,NA=["i","v","n","r","R","l","L","c","w","x","h","H","o","E","F","G","P","q","I","a","s"],OA=["A","B","C","m"],Am={short:NA,long:["text","no-messages"],valueShort:OA,repeatable:["e","f","file","include","exclude","exclude-dir"]};function Nm(e){try{return N(e,Am).flags.has("q")}catch{return!1}}function Qi(e,t,n){let r;try{r=N(t,Am)}catch(m){return ne(m,"grep",`grep: ${m.message}`,2)}let{flags:o,values:i}=r,s=km(r,e,n);if(!s)return xe(AA,2);if(s.error)return s.error;let{patterns:a,rest:u}=s;e=s.stdin;let l=FA(o);if(l)return l;let f;try{f=im(a,o,n.locale)}catch(m){return ne(m,"grep",`grep: ${m.message}`,2)}if(f.error)return f.error;let c=MA(i);if(c.error)return c.error;if((c.max===0||RA(a,o))&&(!o.has("L")||o.has("q")))return pm();if(c.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=PA(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 TA(e,u,n,d,p,f,o,c)}finally{LA(p,n.notes)}}function TA(e,t,n,r,o,i,s,a){if(s.has("q"))return IA(e,t,n,r,o,i.res,s.has("v"));let u=Cm(r,e,t,n,o);a.max===0&&j(n,e);let l=s.has("v"),f=["l","L","c"].find(g=>s.has(g)),c=u.items;o.name.length>0&&(c=c.filter(g=>Sn(g)||_m(g,o)));let d=null;if(a.max!==0&&(c=c.flatMap(g=>{if(Sn(g))return[g];let w=Om(g,o,i.res,l,n),y=Pu(w,i.res,n.locale,!f&&s.has("o"))??(f?null:CA(w,i.res,l,a.after)??_A(w,a,s,o,n));return d??=y,y?[]:[w]}),d&&c.every(Sn)))return d;let h={showName:DA(s,t.length),invert:l,showLine:s.has("n"),only:s.has("o"),binaryFiles:o.binaryFiles,...a},m;try{m=f?bm(c,i.res,{...h,mode:f}):wm(c,i.res,h)}catch(g){return g instanceof A&&g.gap?v("feature","grep",g.gap,`grep: ${g.message}`,2):ne(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 Z(w,g.kind,g.command,g.detail,g.message)}return u.failed?{...m,exitCode:2}:m}function IA(e,t,n,r,o,i,s){let a="",u=!1;for(let l of t.length?t.map(f=>[f]):[[]]){let f=Cm(r,e,l,n,o);u||=f.failed,(l.includes("-")||l.includes("/dev/stdin")&&!n.stdinFile)&&(e="");for(let c of f.items){if(Sn(c)){a+=c.failure;continue}if(!_m(c,o))continue;let d=Om(c,o,i,s,n),p=Pu(d,i,n.locale);if(p)return p.stderr=a+p.stderr,p;if(Ji(d,i,s,1)>0)return{stdout:"",stderr:a,exitCode:0}}}return{stdout:"",stderr:a,exitCode:u?2:1}}function Om(e,t,n,r,o){let i=Im(e,o),s=t.binaryFiles==="without-match",a=t.binaryFiles==="text";if(e.content===void 0){if(!r&&Lu(e.bytes,n))return{...e,content:""};let f=a?-1:e.bytes.indexOf(0);if(f>=0&&s)return $m(e,t,f>=i);let c={...e,content:ca(e.bytes),marked:!0};return f<0?c:vm(c,e.bytes,f,i)}let u=a?-1:e.content.indexOf("\0");if(u<0)return e;let l=_(e.content.slice(0,Math.min(u,i)));return s?$m(e,t,l.length>=i):vm(e,l,l.length,i)}function vm(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:Fr(t.subarray(0,r)),binaryLine:Fr(e.content.slice(0,o))}}var Tm=e=>e.name===null||e.name==="/dev/stdin",Im=(e,t)=>Tm(e)&&!t.stdinFile?64*1024:96*1024;function CA(e,t,n,r){if(e.readLines===void 0)return null;let o=we(e.content.slice(0,e.lineStart)),i=Ki(e,t),s=(a,u)=>o.slice(a,u).some(l=>lo(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 _A(e,t,n,r,o){return!e.marked||e.binaryLine!==void 0||!t.hasContext||n.has("o")||r.binaryFiles==="text"||e.bytes.length<=Im(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 $m(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=Tm(e)?t.stdinPath:H(t.cwd,e.name);return r?t.binary.add(r):t.binaryStdin=!0,{...e,content:""}}function LA(e,t){let n="Binary input is treated as text with -a.";Wt(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),Wt(t,{command:"grep",action:"excluded",noun:["entry","entries"],paths:e.excluded,context:" by --include/--exclude/--exclude-dir rules"})}function FA(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 RA(e,t){return e.length===0?!t.has("v"):t.has("v")&&!t.has("x")&&!t.has("w")&&e.every(n=>n==="")}function MA(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=_e(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 DA(e,t){return e.has("h")?!1:e.has("H")||t>1?!0:void 0}function Cm(e,t,n,r,o){let i=l=>o.silent?[]:[{failure:l}];if(!e){let l=le("grep",n,t,r,{read:"maybe-text"});return{items:l.entries.flatMap(c=>c.kind==="file"?[c.name==="-"?{...c,name:null}:c]:i(c.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=Ot("grep",[l],r,t);s.push(...p.inputs.map(h=>({...h,name:l==="-"?null:l}))),(l==="-"||l==="/dev/stdin")&&(t="");continue}let{path:f,error:c}=U(r,"grep",l);if(r.fs.isFile(f)){s.push({name:l,...Wu(r,f)});continue}if(c){u(`grep: ${l}: ${c}
156
- `);continue}if(zA(l,o.dir)){o.excluded.add(f);continue}let d=p=>p===f||o.dir.length===0||!qu(o.dir,Ce(p))?!0:(o.excluded.add(p),!1);for(let p of ct(r.fs,f,1/0,d)){if(p.kind==="link"){if(!o.follow)continue;let m=UA(p.path,Sm(n.length?l:"",f,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:Sm(n.length?l:"",f,h),...Wu(r,h),recursive:!0})}}return{items:s,failed:a}}function UA(e,t,n,r){let o=$(n.cwd,e,n.fs),i=n.fs.isDir(o.path);if(!(i?r.dir.length===0||!qu(r.dir,Ce(e)):Lm(Ce(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,...Wu(n,o.path),recursive:!0}}}function Wu(e,t){let{text:n,bytes:r}=pt(e.fs,t);return n===void 0?{content:void 0,bytes:r}:{content:n}}function PA(e,t){let n=e.order.filter(o=>o.name==="include"||o.name==="exclude").map(o=>({include:o.name==="include",re:Ve(o.value)})),r=(e.values.get("exclude-dir")??[]).map(o=>Ve(o));return{name:n,dir:r,binary:new Set,excluded:new Set,cwd:t.cwd,stdinPath:t.stdinHandle?.path}}function qu(e,t){return e.some(n=>n.test(t))}function _m(e,t){return e.name===null||Lm(Ce(e.name),t.name)?!0:(t.excluded.add(H(t.cwd,e.name)),!1)}function Lm(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 zA(e,t){return t.length===0||e.endsWith("/")?!1:qu(t,e.slice(e.lastIndexOf("/")+1))}function Sm(e,t,n){let r=ft(t,n);return e===""?r:e.endsWith("/")?e+r:e+"/"+r}var fo=(e,t)=>v("feature","rg",e,`rg: ${t}`,2);function Fm(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 Mm(e,t,n){let r,o;try{o=N(t,v1),r=$1(o)}catch(d){return Fm(d,d.message.startsWith("rg: ")?d.message:`rg: ${d.message}`,"option")}let i=[...o.positional];if(!r.patterns.length){if(!i.length)return fo("usage","a pattern is required");r.patterns.push(i.shift())}try{A1(r.patterns,r.literal)}catch(d){return Fm(d,d.message,"feature")}let a=!i.length&&!!n.stdinPiped?{roots:[],recursive:!1,stdin:!0}:qA(i,n,r.hidden);if(a.error)return a.error;if(!o.flags.has("no-ignore")&&!r.unrestricted&&a.recursive){let d=HA(a.roots,n);if(d)return fo("ignore rules",`${JSON.stringify(d)} would change which files are searched, and its rules are not implemented`)}let u=BA(i,a,r,n),l=r.text?null:GA(i,n);if(l)return fo("named binary file",`${JSON.stringify(l)} is binary, and reporting a binary match is not supported`);let f=jA(u,r,n)??(a.stdin?WA(r,n):null);return f?fo(f.detail,f.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.
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
158
  Running with --debug will show why files are being skipped.
159
- `}:XA(e,r,i,a,n)}function BA(e,t,n,r){let o=e.map(i=>$(r.cwd,i,r.fs).path).filter(Boolean).map(i=>({path:i,named:!0}));for(let i of t.roots)for(let s of ct(r.fs,i)){if(s.kind!=="file")continue;let a=ft(i==="/"?"/":i,s.path).split("/");(n.hidden||a.every(u=>!u.startsWith(".")))&&o.push({path:s.path,named:!1})}return o}function jA(e,t,n){for(let{path:r,named:o}of e){if(n.fs.isDir(r))continue;let{text:i,bytes:s}=pt(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(ft(n.cwd==="/"?"/":n.cwd,r)||r);if(i===void 0){let l=Dm(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 Dm(e,t,n,r){return!n.invert&&!n.ignoreCase&&D1(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 WA(e,t){let n=t.stdinBytes;return!n||!e.text&&n.includes(0)||$e(n)!==void 0?null:Dm(n,qn(null,t),e,t)}function qA(e,t,n){let r=[],o=!1;for(let s of e){let a=$(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:fo("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 HA(e,t){let n=l=>ft(t.cwd==="/"?"/":t.cwd,l)||l,r=(l,f=!0)=>{for(let c of e){for(let d of ct(t.fs,c))if(Ce(d.path)===l&&Hu(d.path,f,t))return d.path;for(let d=c;d!=="/";d=se(d)){let p=$(se(d),l,t.fs);if(p.path!==null&&Hu(p.path,f,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=$(i,"info/exclude",t.fs).path,a=s!==null&&Hu(s,!0,t)?s:null,u=r(".gitignore")??a;return u?n(u):null}function Hu(e,t,n){if(!t||n.fs.isDir(e))return!0;let r=$("/",e,n.fs).path,{text:o}=pt(n.fs,r??e);return(o??" ").split(`
160
- `).some(i=>i.trim()!==""&&!i.trimStart().startsWith("#"))}function GA(e,t){for(let n of e){let r=$(t.cwd,n,t.fs);if(r.path===null||t.fs.isDir(r.path))continue;let{text:o,bytes:i}=pt(t.fs,r.path);if(i===void 0?o?.includes("\0"):i.includes(0))return n}return null}function XA(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(...S1(t.patterns,t.literal)),r.stdin||i.push("--",...n.length?n:["."]);let s=new Set(o.notes),a=Qi(e,i,o);return delete a.events,JA(o.notes,s,r),KA(ZA(a,t),n,t.patterns)}function ZA(e,t){if(t.mode!=="c")return e;let n=e.stdout.split(`
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
161
  `).filter(r=>r!==""&&r!=="0"&&!r.endsWith(":0"));return{...e,stdout:n.length?n.join(`
162
162
  `)+`
163
- `:""}}var Rm=new Map([["No such file or directory",2],["Not a directory",20],["Is a directory",21]]),YA=e=>e.replaceAll(/^(rg: .*: )([A-Z][a-z].*)$/gmu,(t,n,r)=>Rm.has(r)?`${n}${r} (os error ${Rm.get(r)})`:t),VA=/^rg: (?:invalid pattern[^\n]*|trailing backslash)$/mu;function KA(e,t,n){let r=s=>t.length?s:s.replaceAll(/^\.\//gmu,""),o={...e,stdout:r(e.stdout),stderr:YA(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):VA.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 JA(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 zm=6,Bm=" ",QA=" ".repeat(zm+Bm.length);function jm(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 f=`nl: -b: only \`a\`, \`t\` and \`n\` are supported (got \`${s}\`)`;return s.startsWith("p")?v("option","nl","-b p",f):b(f)}let a=1n;for(let{name:f,value:c}of i)if(!(f!=="v"&&f!=="starting-line-number")){if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(c))return b(`nl: invalid starting line number: ${c}`);if(a=BigInt(c),a<St||a>ge)return b(`nl: invalid starting line number: ${c}`)}let u=le("nl",o,e,n);if(u.inputs.some(({content:f})=>/(?:^|\n)(?:\\:){1,3}(?:\n|$)/u.test(f)))return v("feature","nl","logical pages","nl: logical page delimiters are not supported");let l=[];for(let{content:f}of u.inputs)for(let c of we(f))if(s==="a"||s==="t"&&c!==""){if(a>ge)return{stdout:Ae(l),stderr:u.stderr+`nl: line number overflow
164
- `,exitCode:1};l.push(`${String(a).padStart(zm)}${Bm}${c}`),a++}else l.push(QA+c);return fe(Ae(l),u)}function Wm(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=rN(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&&_(l).length!==1)return b("cut: -d delimiter must be a single byte");let f=le("cut",i,e,n),c=[];for(let{content:d}of f.inputs)for(let p of s&&l===`
165
- `?d===""?[]:[d]:we(d)){if(s&&!p.includes(l)){r.has("s")||c.push(p);continue}c.push(s?oN(p,l,u.ranges):eN(p,u.ranges))}return fe(Ae(c),f)}function eN(e,t){let n=_(e);return X(Uint8Array.from(qm(n,t)))}var tN={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`}},nN=/^(\d*)(-?)(\d*)/u;function rN(e,t){let n=tN[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,f]=nN.exec(s),c=s.slice(a.length);if(c!=="")return r(c.startsWith("-")?n.range:n.value(c));for(let h of[u,f])if(h!==""&&BigInt(h)>At)return r(n.large(h));if(u===""&&f===""&&l==="")return r(n.value(s));let d=u===""?1:Number(u),p=l===""?d:f===""?1/0:Number(f);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 qm(e,t){return t.flatMap(([n,r])=>Array.from(e.slice(n-1,r)))}function oN(e,t,n){let r=t===`
166
- `?we(e):e.split(t);return qm(r,n).join(t)}function Hm(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=Pm(o[0]);if(l.error)return l.error;let f=new Set(l.chars),c=w=>a!==f.has(w);if(i)return j(n),M([...e].filter(w=>!c(w)).join(""));if(s)return j(n),M(uN(e,c));let d=Pm(o[1]);if(d.error)return d.error;let p=aN(l,d,a);if(p)return p;if(d.chars.length===0)return b("tr: when not truncating set1, string2 must be non-empty");j(n);let h=a?Array.from({length:256},(w,y)=>String.fromCodePoint(y)).filter(w=>!f.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 M([...e].map(w=>m.get(w)??w).join(""))}var iN=Object.freeze(Object.fromEntries(Object.entries(Lr).filter(([e])=>e!=="word").map(([e,t])=>[e,t.flatMap(([n,r])=>Array.from({length:r-n+1},(o,i)=>String.fromCodePoint(n+i)))]))),Um={__proto__:null,lower:"upper",upper:"lower"};function sN(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 aN(e,t,n){if(t.classes.find(s=>Um[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===Um[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,
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
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 Pm(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=sN(e,r);if(i){if(i.name==="")return{error:b(`tr: missing character class name '${i.text}'`)};let a=iN[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 f=u;f<=l;f++)t.push(String.fromCodePoint(f))}else t.push(s)}return{chars:t,classes:n}}function uN(e,t){let n="",r=null;for(let o of e)t(o)&&o===r||(n+=o,r=o);return n}var Gm=e=>e.text??X(e.bytes),Xu=(e,t)=>{e.bytes===void 0?t.write(e.text):t.writeBytes(e.bytes)},ur=e=>e.events??[...e.stdout?[{fd:1,text:e.stdout}]:[],...e.stderr?[{fd:2,text:e.stderr}]:[]],Gu=e=>e.unordered??(!e.events&&e.stdout!==""&&e.stderr!==""),W=(e="")=>({stdout:"",stderr:e,exitCode:0,ignored:!1,events:e?[{fd:2,text:e}]:[],unordered:!1});function P(e,t){e.stdout+=t.stdout,e.stderr+=t.stderr,e.exitCode=t.exitCode,e.ignored=t.ignored??!1,e.events.push(...ur(t)),e.unordered||=Gu(t)}function es(e,t){t&&P(e.expansionOutput,lr(W(t),{fds:e.expansionFds},e))}function lr(e,t,n){let r=o=>lN(e,t,n,o);return n.io?n.io.output(e,t,r):r(Xu)}function lN(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))&&Gu(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="",f="";for(let c of ur(o)){let d=t.fds[c.fd];if(typeof d=="object"){r(c,d);continue}if(t.deferred?.[c.fd]&&c.bytes!==void 0){u.push(c);continue}if(d!=="out"&&d!=="err"){c.fd===2&&jc(n,Gm(c));continue}let p=Gm(c);u.push({fd:d==="out"?1:2,text:p}),d==="out"?f+=p:l+=p}return{...o,stdout:f,stderr:l,events:u,unordered:Gu(o)&&f!==""&&l!==""}}var fN=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]]),cN=e=>e.stdout!==""||ur(e).some(t=>t.fd===1&&(t.bytes?.length??0)>0);function Zu(e,t,n){return n.closed.out&&cN(t)?dN(e,t,n):t}function dN(e,t,n){let r=fN.get(n.registry.resolveCommand(e))??1,o=ur(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?Z(s,a.kind,a.command,a.detail,a.message):s}var pN=new Map([["\0","0"],["\x07","a"],["\b","b"],["\f","f"],[`
172
- `,"n"],["\r","r"],[" ","t"],["\v","v"]]);function J(e,t){let n=re(t),r=n?Array.from(T(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=pN.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 hN=/^[#%+,\-./0-9@A-Z\]_a-z{}~]+$/u;function pe(e,t){return hN.test(e)&&!"#~".includes(e[0])?e:J(e,t)}var mN=new Map([["\x07","a"],["\b","b"],["\f","f"],[`
173
- `,"n"],["\r","r"],[" ","t"],["\v","v"],['"','"'],["\\","\\"]]);function Yu(e,t){let n=re(t),r="",o=!1;for(let i of e){let s=i.codePointAt(0),a=mN.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 _(i))r+="\\"+u.toString(8).padStart(3,"0");o=!0}else r+=i}return o?`"${r}"`:e}var gN=new Set(["/dev/null","/dev/stdin","/dev/stdout","/dev/stderr"]);function Zm(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=wN(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"),f=u.has("r")||u.has("R")||u.has("recursive"),c=i.map(h=>[h,a?s.replace(/\/+$/u,"")+"/"+bN(h):s]),d=u.has("n")||u.has("no-clobber"),p={ctx:n,result:W(),failed:!1,sources:new Set,copied:new Set,noClobber:d,force:u.has("f")||u.has("force"),verbose:l,recursive:f,outputOverlap:l&&vN(c,n,{recursive:f,noClobber:d})};for(let[h,m]of c){n.io.setReads([]);try{Jm(h,m,p)}catch(g){z(n,"cp",g?.path,g?.fsError);let w=C(g),y="cp: "+ee(g);if(w)return n.unsupported.add({...w,command:w.command??"cp",message:y}),P(p.result,b(y)),p.result;An(p,y+`
174
- `,!0)}}return p.result.exitCode=p.failed?1:0,p.result}function wN({positional:e,flags:t,order:n},r){let o=n.filter(({name:f})=>f==="t"||f==="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 "+J(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 "+J(e[2],r)};let a=i??e.at(-1),u=$(r.cwd,a,r.fs),l=!s&&r.fs.isDir(u.path);return!l&&(i!==void 0||e.length>2)?(z(r,"cp",a,u.error),{error:`${i===void 0?"target":"target directory"} ${J(a,r)}: ${u.error??"Not a directory"}`}):{target:a,directory:l,sources:i===void 0?e.slice(0,-1):e}}function yN(e,t,n){let{ctx:r}=n,o=$(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 ct(r.fs,o)){if(a.kind!=="link")continue;let u=a.path===o?null:ft(o,a.path);if(!Ym(u===null?t:`${s}/${u}`,n)&&!(u!==null&&xN(s,u,n)))throw Vm(u===null?e:`${i}/${u}`)}}var Ym=(e,t)=>t.noClobber&&$(t.ctx.cwd,e,t.ctx.fs,{follow:!1}).path!==null;function xN(e,t,n){let{ctx:r}=n,o=t.split("/");for(let i=1;i<o.length;i++){let s=$(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 Vm=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)`),Km=(e,t,n)=>n.path===null&&e.fs.isLink?.($(e.cwd,t,e.fs,{follow:!1}).path)===!0,bN=e=>{let t=e.replace(/\/+$/u,"").split("/").at(-1);return t===".."?".":t};function Jm(e,t,n,r=null){let{ctx:o}=n;if(Xm(e,o.cwd)||Xm(t,o.cwd))throw new x("feature","special file","copying special files is not supported");let i=J(e,o),s=J(t,o);if(n.recursive&&o.fs.isLink?.($(o.cwd,e,o.fs,{follow:!1}).path)){if(!Ym(t,n))throw Vm(e);return}let a=U(o,"cp",e),u=d=>An(n,"cp: "+d+`
175
- `,!0);if(a.error)return u(`cannot stat ${i}: ${a.error}`);if(o.fs.isDir(a.path))return n.recursive?kN(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 An(n,`cp: warning: source file ${i} specified more than once
176
- `,!1,!0);n.sources.add(a.path)}let l=$(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(t0(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 f=me(o.fs,o.cwd,t);if(r===null&&n.copied.has(f))return u(`will not overwrite just-created ${s} with ${i}`);let c=$t(o.cwd,t,o.fs,l);if(Qm(i,s,n),Km(o,t,l))return u(`not writing through dangling symlink ${s}`);if(c)return z(o,"cp",t,c),u(`cannot create regular file ${s}: ${c}`);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;z(o,"cp",d?.path,d?.fsError);let p=ee(d);return u(`cannot create regular file ${s}: ${p.startsWith(t+": ")?p.slice(t.length+2):p}`)}r===null&&n.copied.add(f)}function kN(e,t,n,r,o,i){let{ctx:s}=r,a=J(e,s),u=J(n,s),l=y=>An(r,"cp: "+y+`
177
- `,!0),f=$(s.cwd,n,s.fs,{follow:!1});if(f.error&&f.error!=="No such file or directory")return l(`cannot stat ${u}: ${f.error}`);let c=n.replace(/\/+$/u,"")||n;if(me(s.fs,s.cwd,c,!0)===t)return l(`${a} and ${u} are the same file`);if(f.path!==null&&!s.fs.isDir(f.path))return l(`cannot overwrite non-directory ${u} with directory ${a}`);let d=me(s.fs,s.cwd,c,!1);if(f.path===null){let y=$t(s.cwd,c,s.fs);if(y)return z(s,"cp",c,y),l(`cannot create directory ${u}: ${y}`);if(!s.writable||!te(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 An(r,`cp: warning: source directory ${a} specified more than once
178
- `,!1,!0);r.sources.add(t)}i&&yN(e,n,r);let{dirs:p,files:h,links:m}=s.fs.listDir(t);if(f.path===null&&!EN(e,n,c,d,r))return;let g=e.replace(/\/+$/u,""),w=n.replace(/\/+$/u,"");for(let y of[...p,...h,...m].sort(G))s.io.setReads([]),Jm(`${g}/${y}`,`${w}/${y}`,r,o)}function EN(e,t,n,r,o){let{ctx:i}=o,s=J(t,i),a=l=>(An(o,"cp: cannot create directory "+s+": "+l+`
179
- `,!0),!1),u=i.writable&&te(r);u&&e0(o);try{if(!u||!i.fs.makeWritableDir?.(i.cwd,n))return a("Read-only file system")}catch(l){if(C(l))throw l;z(i,"cp",l?.path,l?.fsError);let f=ee(l);return a(f.startsWith(n+": ")?f.slice(n.length+2):f)}return Qm(J(e,i),s,o),!0}function Qm(e,t,n){n.verbose&&(e0(n),An(n,`${e} -> ${t}
180
- `))}function e0(e){if(e.outputOverlap)throw new x("feature","copy output buffering","buffered verbose output sharing a copied file is not supported")}function t0(e,t,n){if(e===t)return!0;let r=n.fileIdentity?.(e);return r!==void 0&&r===n.fileIdentity(t)}function vN(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])=>$N(s,a,i))}function $N(e,t,n){let{ctx:r}=n,o=$(r.cwd,e,r.fs),i=o.path??H(r.cwd,e),s=o.error==="No such file or directory"&&(n.made.has(i)||NN(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||!TN(i,t,r)||n.sources.has(i)?!1:(n.sources.add(i),SN(i,a,n)):n.sources.has(i)||(n.sources.add(i),n.copied.has(a)||!ON(i,a,t,r,n.noClobber))?!1:(n.copied.add(a),n.made.add(a),n.holds(i)||n.holds(a))}function SN(e,t,n){let{ctx:r}=n,o=e==="/"?0:e.length;for(let i of AN(e,n)){let s=t+i.slice(o);if(!n0(i,s,$(r.cwd,s,r.fs),r,n.noClobber)&&(n.made.add(s),n.holds(i)||n.holds(s)))return!0}return!1}function AN(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 NN=(e,t)=>[...t.made].some(n=>n.startsWith(e+"/"));function n0(e,t,n,r,o){return n.error&&n.error!=="No such file or directory"||o&&n.path!==null||t0(e,n.path,r.fs)||r.fs.isDir(n.path)?!0:!r.writable||!te(t)}function ON(e,t,n,r,o){let i=$(r.cwd,n,r.fs);return!n0(e,t,i,r,o)&&!Km(r,n,i)&&!$t(r.cwd,n,r.fs,i)}function TN(e,t,n){let r=$(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&&$t(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&&te(i)}function Xm(e,t){let n=e.startsWith("/")?e:t+"/"+e;return gN.has(n.replace(/\/\.(?=\/)/gu,"").replace(/\/+/gu,"/"))}function An(e,t,n=!1,r=!1){let o=n||r?W(t):{...W(),stdout:t,events:[{fd:1,text:t}]};P(e.result,e.ctx.flushOutput(o)),e.failed||=n}function r0(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?M(""):b("rm: missing operand");let u={ctx:n,force:i,verbose:s,recursive:a,events:[],stdout:"",stderr:""};try{for(let l of o)IN(l,u)}catch(l){z(n,"rm",l?.path,l?.fsError);let f=ne(l,"rm","rm: "+ee(l));return f.events=[...u.events,{fd:2,text:f.stderr}],f.stdout=u.stdout,f.stderr=u.stderr+f.stderr,f}return{stdout:u.stdout,stderr:u.stderr,events:u.events,exitCode:u.stderr?1:0}}function IN(e,t){let{ctx:n}=t,r=$(n.cwd,e,n.fs,{follow:!1}),o=r.error;if(!(t.force&&(o==="No such file or directory"||o==="Not a directory"))){if(z(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 Ku(t,`rm: refusing to remove '.' or '..' directory: skipping ${J(e,n)}
181
- `);if(r.path==="/tmp")o="Device or resource busy";else if(!n.writable||!te(r.path))o="Read-only file system";else return o0(e,r.path,t,CN(n,e)?"Not a directory":null)}Vu(e,r.path,t,!1,o)}}function CN(e,t){let n=t.replace(/\/+$/u,"");return n===t||n===""?!1:e.fs.isLink?.($(e.cwd,n,e.fs,{follow:!1}).path)===!0}function o0(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(G)){let f=he(t,l);o.fs.isDir(f)?o0(`${u}/${l}`,f,n):Vu(`${u}/${l}`,f,n,!1,null)}Vu(e,t,n,!0,r)}function Vu(e,t,n,r,o){let{ctx:i}=n,s=n.verbose||o!==null||!i.writable||!t?.startsWith("/tmp/")?J(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;z(i,"rm",u?.path,u?.fsError);let l=ee(u);o=u?.fsError??(l.startsWith(e+": ")?l.slice(e.length+2):l)}if(o)return Ku(n,`rm: cannot remove ${s}: ${o}
182
- `);n.verbose&&Ku(n,`removed ${r?"directory ":""}${s}
183
- `,1)}function Ku(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function s0(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?_N(s,i):Ju(s,i,!0)}catch(s){z(n,"mkdir",s?.path,s?.fsError);let a=ne(s,"mkdir","mkdir: "+ee(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 _N(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===""&&Ju(e,t,!0);return}r[r.length-1]=e;for(let[o,i]of r.entries())if(!Ju(i,t,o===r.length-1))return}function Ju(e,t,n){let{ctx:r}=t,o=J(e,r),i=l=>(i0(t,`mkdir: cannot create directory ${o}: ${l}
184
- `),!1),s=e.replace(/\/+$/u,"")||e,a=$(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($(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=$t(r.cwd,s,r.fs,a);if(u)return z(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;z(r,"mkdir",l?.path,l?.fsError);let f=ee(l);return i(f.startsWith(s+": ")?f.slice(s.length+2):f)}return t.verbose&&i0(t,`mkdir: created directory ${o}
185
- `,1),!0}function i0(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function a0(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)LN(u,i,s);let a={stdout:"",stderr:s.stderr,exitCode:s.failed?1:0};return s.gap?Z(a,"feature","touch","times",s.gap):a}function LN(e,t,n){let{ctx:r}=n,o=J(e,r),i=$(r.cwd,e,r.fs);if(i.error===null)return FN(e,o,i.path,n);let s=t||e.endsWith("/");if(t&&i.error==="No such file or directory")return;if(z(r,"touch",e,i.error),s)return co(n,`setting times of ${o}: ${i.error}`);let a=$t(r.cwd,e,r.fs,i);if(a)return co(n,`cannot touch ${o}: ${a}`);try{r.fs.openWritable?.(r.cwd,e,!0)||co(n,`cannot touch ${o}: Read-only file system`)}catch(u){if(C(u))throw u;z(r,"touch",u?.path,u?.fsError);let l=ee(u);co(n,`cannot touch ${o}: ${l.startsWith(e+": ")?l.slice(e.length+2):l}`)}}function FN(e,t,n,r){let{ctx:o}=r;if(!o.writable||!te(n))return co(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 co(e,t){e.stderr+=`touch: ${t}
187
- `,e.failed=!0}function po(e,t,n,r){if(t===""||t.includes("\0"))return{error:"No such file or directory"};if(r==="none")return RN(e,t,n);let o=t;if(r==="logical"){let s=n==="m"?{path:H(e.cwd,t)}:f0(e,t);if(s.error)return s;o=s.path+(t.endsWith("/")?"/":"")}let i=lt(e.cwd,o,e.fs,{lenient:n==="m"});return n==="m"?{path:i.rest.length?H(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 RN(e,t,n){if(n==="m")return{path:H(e.cwd,t)};let r=f0(e,t);if(r.error||n!=="e")return r;let o=$("/",r.path,e.fs);return o.error?{error:o.error}:r}function f0(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=se(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=$("/",r+(a?"/":""),e.fs);if(u.error&&!(u.error==="No such file or directory"&&o===n.length-1))return u}}}return{path:r}}function Qu(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 c0=(e,t)=>e==="/"||t===e||t.startsWith(e+"/"),u0={e:"e","canonicalize-existing":"e",m:"m","canonicalize-missing":"m"},l0={P:"physical",physical:"physical",L:"logical",logical:"logical",s:"none",strip:"none","no-symlinks":"none"};function MN(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=po(e,u,n,r),f=l.error??(n==="e"&&!e.fs.isDir(l.path)?"Not a directory":null);if(f)return z(e,"realpath",u,f),{error:b(`realpath: ${pe(u,e)}: ${f}`)};s[a]=l.path}return s.base&&!c0(s.base,s.target)&&delete s.target,s}function d0(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(u0,h)&&(u=u0[h]),Object.hasOwn(l0,h)&&(a=l0[h]);let l=MN(n,o,u,a);if(l.error)return l.error;let f=r.has("q")||r.has("quiet"),c=r.has("z")||r.has("zero")?"\0":`
188
- `,d=W(),p=!1;for(let h of i){let m=po(n,h,u,a);if(m.error)z(n,"realpath",h,m.error),f||P(d,b(`realpath: ${pe(h,n)}: ${m.error}`)),p=!0;else{let g=l.target&&(!l.base||c0(l.base,m.path))?Qu(l.target,m.path):m.path;P(d,M(g+c))}}return d.exitCode=p?1:0,d}var ts={symbolic:"s",force:"f","no-dereference":"n","no-target-directory":"T",verbose:"v",relative:"r",logical:"L",physical:"P"};function h0(e,t,n){let r=N(t,{short:Object.values(ts),long:Object.keys(ts),valueShort:["t"],valueLong:["target-directory"]}),o=l=>r.flags.has(l)||r.flags.has(Object.keys(ts).find(f=>ts[f]===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: ${J(a[0],n)} (ln -s makes a symbolic one)`);let u={ctx:n,events:[],stdout:"",stderr:""};try{let l=DN(a,s,i,n);if(l.error)return l.error;for(let[f,c,d]of l)UN(f,c,i,u,d)}catch(l){z(n,"ln",l?.path,l?.fsError);let f=ne(l,"ln","ln: "+ee(l));return f.events=[...u.events,{fd:2,text:f.stderr}],f.stdout=u.stdout,f.stderr=u.stderr+f.stderr,f}return{stdout:u.stdout,stderr:u.stderr,events:u.events,exitCode:u.stderr?1:0}}function DN(e,t,n,r){let o=u=>J(u,r);if(t!==null){let u=$(r.cwd,t,r.fs);return u.error?(z(r,"ln",t,u.error),{error:b(`ln: failed to access ${o(t)}: ${u.error}`)}):r.fs.isDir(u.path)?e.map(l=>el(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])}`)}:[el(".",e[0])];if(e.length===2){let u=$(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=$(r.cwd,i,r.fs),a=s.error??(r.fs.isDir(s.path)?null:"Not a directory");return a?(z(r,"ln",i,a),{error:b(`ln: target ${o(i)}: ${a}`)}):e.slice(0,-1).map(u=>el(i,u))}function el(e,t){let n=t.replace(/\/+$/u,"").split("/").at(-1);return[t,e+(e.endsWith("/")?"":"/")+n,n===""]}function UN(e,t,n,r,o=!1){let{ctx:i}=r,s=J(t,i),a=n.relative?zN(i,e,t):e,u=f=>tl(r,`ln: failed to create symbolic link ${s}${f}
189
- `);if(a==="")return u(` -> ${J(a,i)}: No such file or directory`);if(o)return u(": No such file or directory");if(n.force){let f=$(i.cwd,t,i.fs,{follow:!1});if(f.error===null){if(i.fs.isDir(f.path))return tl(r,`ln: ${pe(t,i)}: cannot overwrite directory
190
- `);try{if(!i.fs.removeWritable?.(i.cwd,t))return u(": Read-only file system")}catch(c){if(C(c))throw c;return u(`: ${p0(c,t)}`)}}}let l=PN(i,t);if(l)return z(i,"ln",t,l),u(`: ${l}`);try{if(!i.fs.makeWritableLink?.(i.cwd,t,a))return u(": Read-only file system")}catch(f){if(C(f))throw f;return z(i,"ln",f?.path,f?.fsError),u(`: ${p0(f,t)}`)}n.verbose&&tl(r,`${s} -> ${J(a,i)}
191
- `,1)}function PN(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.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=lt(e.cwd,n,e.fs);return o.rest.length>0?o.error:null}function zN(e,t,n){let r=po(e,se(n),"m","physical"),o=po(e,t,"m","physical");return r.error||o.error?t:Qu(r.path,o.path)}function p0(e,t){let n=ee(e);return e?.fsError??(n.startsWith(t+": ")?n.slice(t.length+2):n)}function tl(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function m0(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;j(n,"",!0);let a=s??T(e),u={stderr:"",status:0,gap:null};for(let d of o)BN(d,a,i,u,n);let l=[{fd:1,bytes:a},...u.stderr?[{fd:2,text:u.stderr}]:[]],f=s===null?{stdout:e,stderr:u.stderr,exitCode:u.status}:{stdout:"",stderr:u.stderr,exitCode:u.status,events:l};if(!u.gap)return f;let c=C(u.gap);return Z({...f,exitCode:1},c.kind,c.command,c.detail,c.message)}function BN(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}
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
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 g0={cp:Zm,rm:r0,mkdir:s0,touch:a0,ln:h0,tee:m0};function jN(e,t,n){let{positional:r}=N(t),o=le("tac",r,e,n),i=[];for(let{content:s}of o.inputs)i.push(...dt(s).toReversed());return fe(i.join(""),o)}var w0=1e6;function WN(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 f=(a>0?s<=u:s>=u)?(u>s?u-s:s-u)/(a>0n?a:-a)+1n:0;if(f>w0)return v("feature","seq","sequence limit",`seq: range too large: ${f} elements exceeds limit of ${w0}`);let c=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<f;p++,h+=a)d.push(qN(String(h),c));return M(d.length===0?"":d.join(r.get("s")??`
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
194
  `)+`
195
- `)}function qN(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 HN(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:Ae(o),stderr:"",exitCode:i}}function GN(e,t,n){let{positional:r}=N(t);return r.length>0?b(`whoami: extra operand: ${r[0]}`):M((n.user??"user")+`
196
- `)}function XN(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"):M(en(new Date,i,r.has("u")||n.vars.has("TZ"))+`
197
- `)}var ZN=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],YN=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],VN=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],KN=["January","February","March","April","May","June","July","August","September","October","November","December"];function en(e,t,n){let r="get"+(n?"UTC":""),[o,i,s,a,u,l,f]=["FullYear","Month","Date","Hours","Minutes","Seconds","Day"].map(p=>e[r+p]()),c=(p,h="0")=>String(p).padStart(2,h),d={__proto__:null,Y:String(o),m:c(i+1),d:c(s),e:c(s," "),H:c(a),M:c(u),S:c(l),T:[a,u,l].map(p=>c(p)).join(":"),F:[o,c(i+1),c(s)].join("-"),q:String(Math.floor(i/3)+1),s:String(Math.floor(e.getTime()/1e3)),a:ZN[f],A:YN[f],b:VN[i],B:KN[i],Z:()=>JN(e,n),z:()=>QN(e,n),n:`
198
- `,t:" ","%":"%"};return t.replace(/%./gu,p=>{let h=d[p[1]];return typeof h=="function"?h():h??p})}function JN(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 QN(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 y0={rg:Mm,cut:Wm,tac:jN,tr:Hm,seq:WN,nl:jm,which:HN,hexdump:u1,base64:k1,...g0},x0={whoami:GN,date:XN,od:l1,xxd:f1,base32:b1,...e1};var nl=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"})),b0={P:"none",D:"args",H:"args",L:"all"};function E0(e,t){let n=N(e,{short:["0","a","A","b","c","h","H","k","l","m","s","S","L","D","P"],long:[...nl.keys()].filter(i=>!["d","B"].includes(nl.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=nl.get(i)??i;r.flags.add(a),Object.hasOwn(b0,a)&&(r.links=b0[a]),a==="d"&&(r.depth=e3(s)),a==="B"&&(r.scale=k0(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
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
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}:k0(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&&ol(t,r.scale.base),r}function ol(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 e3(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=v0(t[2]);if(n>ge||t[1]==="-"&&n!==0n)throw new Error(`invalid maximum depth: ${e}`);return Number(n)}function v0(e){return BigInt(/^0[0-7]+$/u.test(e)?"0o"+e:e)}function k0(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]?v0(n[1]):1n)*i**BigInt(o);if(s===0n||s>At)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 Nn=4096,t3=60,ns=(e,t)=>t==="dir"?Nn:t==="link"&&e<t3?0:Math.ceil(e/Nn)*Nn,rl=(e,t)=>(e+t-1n)/t;function ho(e,{base:t,unit:n,suffix:r=""}){if(!t)return String(rl(e,n))+r;let o=1n,i=0;for(;e>=o*t;)o*=t,i++;if(!i)return String(e);let s=rl(e*10n,o),a;return s<100n?a=`${s/10n}.${s%10n}`:(s=rl(e,o),s===t?(i++,a="1.0"):a=String(s)),a+(i===1&&t===1000n?"k":"KMGTPEZYRQ"[i-1])}var n3=31556952*1e3/2;function $0(e,t){for(let f of["LS_BLOCK_SIZE","BLOCK_SIZE","BLOCKSIZE"])if(e.vars.has(f))throw new x("feature","block size environment",`${f} is not supported in a long listing`);let n=t?ol(e):null,r=e.user??"user",o=e.createdAt,i=Date.now(),s=o<=i&&i-o<n3,a=en(new Date(o),s?"%b %e %H:%M":"%b %e %Y",e.vars.has("TZ")),u=f=>n?ho(BigInt(f),n):String(f),l=f=>Math.max(0,...f.map(c=>c.length));return{lines(f,c){let d=f.map(({name:g,abs:w,kind:y,target:E})=>{let S=y==="dir",I=S?Nn:e.fs.fileSize(w)??T(e.fs.readFile(w)).length,B=S?"drwx------":y==="link"?"lrwxrwxrwx":"-rw-------",L=ns(I,y)/512;return{name:y==="link"?`${g} -> ${E}`:g,mode:B,units:L,links:String(S?2+e.fs.listDir(w).dirs.length:1),size:u(I)}}),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(c){let g=d.reduce((w,y)=>w+y.units,0);m.unshift("total "+(n?ho(BigInt(g)*512n,n):String(g/2)))}return m}}}var S0=Object.freeze({utf8:{down:"\u251C\u2500\u2500 ",last:"\u2514\u2500\u2500 ",through:"\u2502\xA0\xA0 ",past:" "},ascii:{down:"|-- ",last:"`-- ",through:"| ",past:" "}}),r3=e=>re(e)?S0.ascii:S0.utf8;function A0(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")?_e(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}=U(n,"tree",a),f=!l&&n.fs.isDir(u),c=$(n.cwd,a,n.fs,{follow:!1}),d=!!l&&!!c.error,p={dirs:f&&rs(n.fs,u,r).length?1:0,files:!d&&!f?1:0},h=[a+o3(n,r,c,f)+(f?"":" [error opening dir]")];if(f){let m=new Set,g=Wn();try{let w=i3(n.fs,u,h,r,s.value,p,m,g,r3(n));if(w)return w}finally{Wt(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(`
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
201
  `)+`
202
- `,stderr:"",exitCode:d?2:0}}function o3(e,t,n,r){return t.has("F")?!n.error&&e.fs.isLink?.(n.path)===!0?"@":r&&!t.has("d")?"/":"":""}function i3(e,t,n,r,o,i,s,a,u){let l=[{dir:t,prefix:"",items:rs(e,t,r,a),i:0,depth:0}];for(;l.length;){let f=l.at(-1);if(f.i>=f.items.length){l.pop();continue}let{n:c,isDir:d,target:p}=f.items[f.i++];if([...c+(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=f.i===f.items.length,m=d&&r.has("F")&&!r.has("d")?"/":"";if(n.push(f.prefix+(h?u.last:u.down)+c+(p===void 0?m:" -> "+p+m)),i[d?"dirs":"files"]++,!d||p!==void 0)continue;let g=he(f.dir,c);if(f.depth+1>=o){rs(e,g,r).length&&s.add(g);continue}let w=rs(e,g,r,a);l.push({dir:g,prefix:f.prefix+(h?u.past:u.through),items:w,i:0,depth:f.depth+1})}}function rs(e,t,n,r=null){let{dirs:o,files:i,links:s}=e.listDir(t),a=s.map(l=>{let f=$(t,l,e);return{n:l,isDir:!f.error&&e.isDir(f.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,f)=>G(l.n,f.n))}var s3=new Set(["name","iname","type","path","ipath","lname","ilname","size","mindepth","maxdepth"]),mo=(e,t)=>e==="-"+t||e==="--"+t;function O0(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=T0(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 T0(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"||mo(o,"and")||o==="-o"||mo(o,"or")){if(r||n.at(-1).length===0){e.error=b(`find: ${o} with no left-hand expression`);break}(o==="-o"||mo(o,"or"))&&n.push([]),e.i++,r=o;continue}let i=a3(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 a3(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:T0(e,t+1),negate:r};if(o===void 0||o===")"||o==="-a"||o==="-o"||mo(o,"and")||mo(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=h3(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(s3.has(i)){if(e.i===e.tokens.length)return e.error=b(`find: ${o} requires a value`),null;let s=u3(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 u3(e,t,n,r){if(e==="type"){let o=p3(t);return o.error?o:{kind:e,negate:n,types:o.types}}if(e==="size")return c3(t,n);if(e==="mindepth"||e==="maxdepth"){let o=_e(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:Ve(t,{ignoreCase:e.startsWith("i")})}}var l3={__proto__:null,b:512,c:1,w:2,k:1024,M:1048576,G:1073741824},f3=/^([+-]?)(\d+)([a-zA-Z]?)$/u;function c3(e,t){if(e==="")return{error:b("find: invalid null argument to -size")};let n=f3.exec(e);if(!n||!Number.isSafeInteger(Number(n[2])))return{error:b(`find: Invalid argument \`${e}' to -size`)};let[,r,o,i]=n,s=l3[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 N0="fdl",d3="bcps";function p3(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&&N0.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&&(N0+d3).includes(i))?v("option","find",`-type ${e}`,r):b(r)}}function h3(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 m3={file:"f",dir:"d",link:"l"},g3=(e,t)=>e.kind==="dir"?Nn:t.fs.fileSize?.(e.abs)??T(t.fs.readFile(e.abs)).length;async function I0(e,t,n){let r=O0(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,f=W(),c=new Set;try{for(let d of o){let{path:p,error:h}=U(n,"find",d,{follow:!1});if(h){il(f,n.flushOutput(W(`find: '${d}': ${h}
203
- `))),f.exitCode=1;continue}let m=new Set,g=ct(n.fs,p,s,w=>!m.has(w));for(let w of a?w3(g):g){let y=x3(d,p,w.path);if(w.depth>=i&&await C0(u,{kind:w.kind,path:y,abs:w.path,prune:m},n,f),w.kind!=="dir"||w.depth!==s||m.has(w.path))continue;let{dirs:E,files:S,links:I}=n.fs.listDir(w.path);(E.length||S.length||I.length)&&c.add(y)}}for(let d of l){if(d.collected.length===0)continue;let p=d.args.slice(0,-1).concat(d.collected);await _0(d.cmd,p,n,f)||(f.exitCode=1)}}finally{Wt(n.notes,{command:"find",action:"depth limit omitted contents of",noun:["directory","directories"],paths:c})}return f}function*w3(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 C0(e,t,n,r){for(let o of e){let i=!0;for(let s of o)if(await y3(s,t,n,r)===!!s.negate){i=!1;break}if(i)return!0}return!1}function y3(e,t,n,r){if(e.kind==="group")return C0(e.groups,t,n,r);if(e.kind==="true")return!0;if(e.kind==="type")return e.types.includes(m3[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(g3(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"?(il(r,n.flushOutput({stdout:t.path+(e.kind==="print"?`
204
- `:"\0"),stderr:"",exitCode:0})),!0):e.mode==="batch"?(e.collected.push(t.path),!0):_0(e.cmd,e.args.map(o=>o.replaceAll("{}",t.path)),n,r)}async function _0(e,t,n,r){let o=await n.dispatch(e,t,"");return il(r,o),o.exitCode===0}function il(e,t){let n=e.exitCode;P(e,t),e.exitCode=n}function x3(e,t,n){if(n===t)return e;let r=ft(t,n);return e.endsWith("/")?e+r:e+"/"+r}var al=1e5,b3=/^([+-]?\d+)\.\.([+-]?\d+)(?:\.\.([+-]?\d+))?$/u,k3=/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([+-]?\d+))?$/u,L0=2n**63n-1n,F0=-(2n**63n),sl=e=>{let t=BigInt(e);return t>L0||t<F0?null:t},R0=(e,t)=>e.mask===null?"0":e.mask[t];function ul(e,t=al){if(!e.value.includes("{"))return[e];let n=E3(e);for(let r=0;r<e.value.length;r++){if(e.value[r]!=="{"||R0(e,r)!=="0")continue;let o=n.get(r);if(!o)continue;let{end:i,commas:s}=o,a=s.length?[]:$3(Le(e,r+1,i));if(s.length){let c=r+1;for(let d of[...s,i])a.push(Le(e,c,d)),c=d+1}if(a===null)continue;let u=Le(e,0,r),l=Le(e,i+1),f=[];for(let c of a)if(f.push(...ul(rd(u,c,l),t)),f.length>t)throw new x("feature","brace expansion limit",`brace expansion \`${e.value}\` would produce more than ${t} words`);return f}return[e]}function E3(e){let t=[],n=new Map;for(let r=0;r<e.value.length;r++){if(R0(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 v3(e){if(e.mask!==null&&/[12]/u.test(e.mask))return null;let t=b3.exec(e.value),n=t??k3.exec(e.value);if(!n)return null;let[r,o]=t?[sl(t[1]),sl(t[2])]:[BigInt(n[1].codePointAt(0)),BigInt(n[2].codePointAt(0))],i=n[3]===void 0?1n:sl(n[3]);if(r===null||o===null||i===null||i===F0)return null;let s=o>=r?o-r:r-o;return s>L0?null:{num:t,range:n,from:r,to:o,step:(i<0n?-i:i)||1n,span:s}}function $3(e){let t=v3(e);if(t===null)return null;let{num:n,from:r,to:o,step:i,span:s}=t,a=s/i+1n;if(a>al)throw new x("feature","brace expansion limit",`brace expansion \`{${e.value}}\` would produce ${a} words (limit ${al})`);let u=n?S3(n[1],n[2]):0,l=[],f=o>=r?1n:-1n;for(let c=0n;c<a;c++){let d=r+f*c*i,p=n?A3(d,u):String.fromCodePoint(Number(d));l.push({value:p,mask:null})}return l}function S3(e,t){let n=r=>/^-?0\d/u.test(r);return n(e)||n(t)?Math.max(e.length,t.length):0}function A3(e,t){let n=String(e<0n?-e:e),r=e<0n?"-":"";return r+n.padStart(t-r.length,"0")}var ll=new Set(["CDPATH","GLOBIGNORE","GLOBSORT","BASH_COMPAT","POSIXLY_CORRECT","PATH","RANDOM","SRANDOM","SECONDS","EPOCHSECONDS","EPOCHREALTIME","BASHOPTS","SHELLOPTS","OPTIND"]),Et=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(ll.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_"))&&Uc(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 M0=new Set(["$","!","0","-","_"]),N3=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 rn(e,t){if(M0.has(e))throw fl(e);let n=cl(e,t);if(n)return n;if(D0(e))throw fl(e);return{value:"",set:!1}}var D0=e=>ll.has(e)||N3.has(e),fl=e=>new x("feature",`$${e}`,`shell parameter ${e} is not supported`),U0=(e,t)=>cl(e,t)?.value??"";function cl(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 dl(e,t){if(M0.has(e))throw new x("feature",`$${e}`,`shell parameter ${e} is not supported (this terminal runs no process)`);let n=cl(e,t);if(n)return n;if(D0(e))throw fl(e);return O3(t,`$${e}`,`warning: $${e} is unset (this shell has no environment variables; only \`for\` bindings and \`NAME=value\` assignments)`),{value:""}}function O3(e,t,n){es(e,n+`
206
- `),e.unsupported.add({kind:"feature",command:null,detail:t,message:n})}var P0=16e6,go=e=>new x("feature","${",e);function z0(e,t,n){if(uo(t))throw go("extended glob patterns in parameter expansion are not supported");let r=ar({value:t.value,mask:t.mask??null}),o=n[0]==="#",i=j0(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=Ve(r,{bash:!0}),a=n.length===2,u=o===a,l=u?e.length:0,f=0;for(;l>=0&&l<=e.length;){let c=o?e.slice(0,l):e.slice(l);if(f+=c.length+r.length,f>P0)throw go("parameter pattern removal exceeds the matching work limit");if(s.test(c))return o?e.slice(l):e.slice(0,l);l=os(e,l,u)}return e}function B0(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}),uo(t))throw go("extended glob patterns in parameter expansion are not supported");let i=ar({value:t.value,mask:t.mask??null}),s={work:0},a=C3(n,s);if(!i)return o==="#"?a("")+e:o==="%"?e+a(""):e;if((/\\+$/u.exec(i)?.[0].length??0)%2)throw go("unescaped trailing backslashes in replacement patterns are not supported");let u=j0(i),l=u===null?I3(e,i,o,s):T3(e,u,o),f=[],c=0;do{let d=l(c);if(!d)break;let[p,h]=d,m=a(e.slice(p,h));if(pl(s,p-c),f.push(e.slice(c,p),m),c=h,!r)break;if(p===h){let g=os(e,c,!1);f.push(e.slice(c,g)),c=g}}while(c<e.length);return f.push(e.slice(c)),f.join("")}function T3(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 I3(e,t,n,r){let o=Ve(t,{bash:!0});return i=>{for(let s=i;s<=e.length;s=os(e,s,!1)){for(let a=e.length;a>=s;a=os(e,a,!0)){if(pl(r,a-s+t.length),o.test(e.slice(s,a)))return[s,a];if(n==="%")break}if(n==="#")break}return null}}function pl(e,t){if(e.work+=t,e.work>P0)throw go("parameter replacement exceeds the matching work limit")}function C3(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;pl(t,a.length),o.push(a)}return o.join("")}}function os(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 j0(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 ot=e=>BigInt.asIntN(64,e),oe=(e,t)=>new x("feature","arithmetic "+e,"arithmetic expansion: "+t);function W0(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 oe("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 oe("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 oe("number","value too great for base in "+e.slice(0,40));r=ot(r*t+BigInt(a))}return r}function _3(e,t){if(t<0n)throw oe("exponent","exponent less than zero");let n=1n;for(let r=t,o=e;r!==0n;r>>=1n,o=ot(o*o))r&1n&&(n=ot(n*o));return n}function hl(e,t,n,r){switch(e){case"+":return ot(t+n);case"-":return ot(t-n);case"*":return ot(t*n);case"/":case"%":{if(n===0n&&r)throw oe("division","division by zero");let o=n===0n?1n:n;return ot(e==="/"?t/o:t%o)}case"**":return _3(t,n);case"<<":case">>":{if(n<0n||n>63n)throw oe("shift count","shift counts outside 0..63 are not supported");return ot(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 oe("operator","unsupported operator "+e)}}var L3=new Set(["=","+=","-=","*=","/=","%=","<<=",">>=","&=","^=","|="]),F3=[["||"],["&&"],["|"],["^"],["&"],["==","!="],["<","<=",">",">="],["<<",">>"],["+","-"],["*","/","%"],["**"]],R3=new Map(F3.flatMap((e,t)=>e.map(n=>[n,t+3]))),M3=/^(?:<<=|>>=|\+\+|--|\*\*|&&|\|\||<<|>>|[+\-*/%&^|=!<>]=|[+\-*/%&^|=!~<>?:,()])/u;function D3(e){let t=[];for(let n=0;n<e.length;){if(t.length>=1e4)throw oe("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=M3.exec(r);if(i)t.push({type:"number",value:W0(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 oe(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 q0(e){let t=new ml(D3(e));if(t.token.type==="end")return{type:"number",value:0n};let n=t.expression();if(t.token.type!=="end")throw oe("syntax","unexpected token "+t.token.value);return n}var ml=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 oe("syntax","expected "+t)}expression(t=0){if(++this.depth>128)throw oe("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=L3.has(r),i=r===","?0:o?1:R3.get(r);if(i===void 0||i<t)break;if(this.next(),o&&n.type!=="name")throw oe("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 oe("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 oe("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 On(e,t,n=0){return G0(e,{ctx:t,steps:1e4,characters:2e5},n,!0)}function G0(e,t,n,r){if(typeof e!="string")throw oe("value","expression must be a string");if(t.characters-=e.length,e.length>1e5||t.characters<0)throw oe("limit","expression size limit exceeded");if(n>128)throw oe("limit","variable recursion limit exceeded");return X0(q0(e),t,n+1,r)}function gl(e,t,n,r){if(!r)return 0n;let o;try{o=rn(e,t.ctx)}catch(i){throw oe("variable",ee(i))}return o.set&&o.value!==""?G0(o.value,t,n+1,!0):0n}function H0(e,t,n,r){if(r)try{rn(e,n.ctx),n.ctx.vars.set(e,t.toString())}catch(o){throw oe("assignment",ee(o))}return t}function X0(e,t,n,r){if(--t.steps<0||n>128)throw oe("limit","expression evaluation limit exceeded");let o=(i,s=r)=>X0(i,t,n+1,s);switch(e.type){case"number":return e.value;case"name":return gl(e.value,t,n,r);case"group":return o(e.value);case"unary":{let i=o(e.value);return e.op==="+"?i:e.op==="-"?ot(-i):e.op==="!"?BigInt(i===0n):~i}case"increment":{let i=gl(e.name,t,n,r),s=H0(e.name,ot(i+(e.op==="++"?1n:-1n)),t,r);return e.post?i:s}case"assignment":{let i=e.left.value,s=e.op==="="?0n:gl(i,t,n,r),a=o(e.right);return H0(i,e.op==="="?a:hl(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):hl(e.op,i,a,r)}default:throw oe("syntax","unsupported expression")}}var is=e=>new x("feature","${",e);async function Z0(e,t,n,r){if(e.name==="@"||e.name==="*")throw is("substring and replacement of positional parameter lists are not supported");if(!t.set)return t;if(e.operator===":")try{return{value:await U3(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=Y0(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:B0(t.value,a,u,e.operator==="//")}}async function U3(e,t,n,r){if(/\P{ASCII}/u.test(e))throw is("locale-dependent slicing of non-ASCII parameters is not supported");let o=Y0(t,":",r.readExpansion),i=async l=>On((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 is("substring length overflows the shell integer range");if(u<s){let f=new Error(`${t.slice(o+1)}: substring expression < 0`);throw f.exitCode=1,f.halt=!0,f}}return e.slice(Number(s),Number(u>a?a:u))}function Y0(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 is("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 f=a+1;for(;e[f]==="\\"&&e[f+1]===`
208
- `;)f+=2;if(!i&&e[f]==="'"){i="ansi",a=f;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 P3=/^[A-Za-z_][A-Za-z0-9_]*$/u;async function V0(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 z3(i,u.value,t);if(s===":"||s.startsWith("/"))return Z0(e,u,t,n);if(s[0]==="#"||s[0]==="%")return!u.value||!a?u:{value:z0(u.value,await o(a,{pattern:!0}),s)};let l=!u.set||s.startsWith(":")&&u.value==="",f=s[s.length-1];if(f==="+")return l?{value:"",...u.omit?{omit:!0}:{}}:o(a,{});if(!l)return u;if(f==="?")throw await B3(i,a,s.startsWith(":"),o,t);if(f!=="=")return o(a,{});if(!P3.test(i)){let d=new Error(`$${i}: cannot assign in this way`);throw d.exitCode=1,d.halt=!0,d}let c=await o(a,{assignment:!0});return t.vars.set(i,c.value),{value:t.vars.get(i)}}function z3(e,t,n){if(e==="*"||e==="@")return{value:"0"};if(re(n))return{value:String(_(t).length)};if(/\P{ASCII}/u.test(t))throw mn("#"+e,"locale-dependent length of non-ASCII parameters is not supported");return{value:String(t.length)}}async function B3(e,t,n,r,o){let i=t?j3(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 j3(e,t){let n=t.vars.get("IFS")??`
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
209
  `;if(n==="")return e.value;if(n!==`
210
- `)throw mn("?","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],f=!e.mask||e.mask[u]==="0";f&&/[ \t\n]/u.test(l)?a():(s+=l,i||=!f)}return a(),o.join(" ")}function on(e,t){return Ee(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new Et(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function Ee(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 wo(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 ul(i)){let a=o&&s===i&&Dr(i);if(a){let u=await q3(s,a.end,t);n.push({value:u,mask:"1".repeat(u.length),q:!0})}else n.push(...await J0(ss(s,t,s===i?!1:"word"),t,!0))}return{argv:W3(n,t)}}function W3(e,t){let n=[];for(let r of e){if(lm(r)){let o=fm(r,t);if(o.length>0){n.push(...o);continue}}(r.value!==""||r.q)&&n.push(r.value)}return n}async function wl(e,t){let{argv:n}=await wo([e],t);return n.length===1?{value:n[0]}:{error:`${e.value}: ambiguous redirect`}}async function q3(e,t,n){let r=Le(e,t);return e.value.slice(0,t)+await Tn(r,n,!0)}async function Tn(e,t,n=!1){return(await J0(ss(e,t,n),t,!1,n))[0].value}var cr=e=>e.vars.get("HOME")??e.home,K0=(e,t)=>e.mask===null?"0":e.mask[t];function ss(e,t,n=!1){let r=nd(e,n);if(r.size===0)return e;let o=e.value,i=cr(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 f=i==="/"&&o[l+1]==="/"?"":i;s+=f,a+="1".repeat(f.length);continue}s+=o[l],a+=K0(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 yl(e,t){return Ee(t,{strictExpansion:!0},()=>xl(ss(e,t),t))}async function J0(e,t,n,r=!1){let o=await xl(e,t,r);return n?X3(o,t):[o]}async function xl(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=K0(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]==="{",f=u?H3(e,i,a,s,l):null;if(!f){o(e.value[i],s);continue}i+=f.raw.length-1;let c=await G3(f,t,s==="2",n);if(c.literal){o(f.raw,s.repeat(f.raw.length));continue}if(!c.omit)if(s==="2")c.value===""&&r.empty.push(r.value.length),o(c.value,"2".repeat(c.value.length));else{r.split=!0;for(let d of c.empty??[])r.empty.push(r.value.length+d);c.q&&!c.value&&!c.empty?.length&&r.empty.push(r.value.length),o(c.value,c.mask??"0".repeat(c.value.length))}}return r.q=r.empty.length>0||/[12]/u.test(r.mask),r}function H3(e,t,n,r,o){return n==="`"?Tt(e.value,t):o?Ct(e.value,t,0,r==="2"):Na(e.value,t,e.mask)}async function G3(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 Ee(t,{strictExpansion:!0},()=>Tn(Ta(e.arithmetic,!0),t));return{value:String(On(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)?dl(e.parameter.name,t):V0(e.parameter,t,{lookup:o=>rn(o,t),readExpansion:Ct,expand:(o,i={})=>{let s=i.pattern||i.error||i.replacement||i.arithmetic,a=Ta(o,i.arithmetic||!s&&n),u=!s&&(i.assignment||r),l=i.assignment?"parameterAssign":u?!0:"parameter";return Ee(t,{strictExpansion:!0},()=>xl(i.arithmetic?a:ss(a,t,l),t,u))}}):t.strictExpansion?rn(e.name,t):dl(e.name,t)}function X3(e,t){if(!e.split)return e.value!==""||e.q?[e]:[];let n=t.vars.get("IFS")??`
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
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 Q0(e,t,n){let r=E0(t,n),o={ctx:n,options:r,seen:new Set,result:W(),total:0n,failed:!1};r.stderr&&P(o.result,n.flushOutput(W(r.stderr)));for(let i of r.operands){let s=i.length>2?i.replace(/\/+$/u,"/"):i,a=U(n,"du",s,{follow:r.links!=="none"});if(a.error){P(o.result,n.flushOutput(b(`du: cannot access ${J(s,n)}: ${a.error}`))),o.failed=!0;continue}try{Z3(a.path,s,o)}catch(u){let l=C(u),f="du: "+ee(u);if(l&&n.unsupported.add({...l,command:l.command??"du",message:f}),P(o.result,n.flushOutput(b(f))),o.failed=!0,l)return o.result}}return r.flags.has("c")&&bl(o.total,"total",o),o.result.exitCode=o.failed?1:0,o.result}function Z3(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&&bl(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",f=a?0:r.fs.fileSize(s.path),c=o.flags.has("inodes")?1n:o.flags.has("A")?BigInt(f):BigInt(ns(f,l));if(n.total+=c,a){s.total=c,i.push(s);let d=r.fs.listDir(s.path),p=[...new Set([...d.dirs,...d.files,...d.links])].sort(G),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+=c),(s.depth===0||o.flags.has("a")&&s.depth<=o.depth)&&bl(c,s.name,n)}}function bl(e,t,n){let r=`${ho(e,n.options.scale)} ${t}${n.options.flags.has("0")?"\0":`
213
- `}`;P(n.result,n.ctx.flushOutput({...W(),stdout:r,events:[{fd:1,text:r}]}))}var Y3=/^%([-+ 0#']*)(\d+|\*)?'?(?:\.(\d+|\*)?)?[hlL]?(.)?/su,V3="diouxXeEfFgGcs";function us(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=Y3.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||!V3.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 sn(e,t,n,r){let o=n.width??0;if(o>je)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 ng=e=>e.plus?"+":e.space?" ":"",rg=e=>e==="X"||e==="E"||e==="G"||e==="F";function In(e,t){if(t.precision>je)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 rg(n)?r.toUpperCase():r}return"ouxX".includes(n)&&(e>=2**64||e<-(2**63))?eg(e,{...t,conv:"g"}):"diouxX".includes(n)?K3(e,t):eg(e,t)}function K3(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!==""?ng(t):"";return t.alt&&!o&&(n==="o"&&(u="0"+u),(n==="x"||n==="X")&&(l+=n==="x"?"0x":"0X")),sn(l,u,t,t.precision===null)}var as=100;function eg(e,t){let{conv:n}=t;if(t.precision>as)throw new A(`floating-point precision above ${as} 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=ig(i,r):n==="f"||n==="F"?s=sg(i,r):s=J3(i,r,t.alt),t.alt&&r===0&&n!=="g"&&n!=="G"&&(s=n==="e"||n==="E"?s.replace("e",".e"):s+"."),rg(n)&&(s=s.toUpperCase()),sn(o?"-":ng(t),s,t,!0)}function og(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 ig(e,t){let n=e.toExponential(as),r=n.indexOf("."),o=n.indexOf("e"),[i,s]=e.toExponential(t).split("e"),a=og(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 sg(e,t){if(e>=1e21)return BigInt(e).toString()+(t>0?"."+"0".repeat(t):"");let n=e.toFixed(as),r=n.indexOf(".");return og(e.toFixed(t),n,t===0?r:r+1+t,r+1+t)}function J3(e,t,n){let r=t===0?1:t;if(e===0)return n?"0."+"0".repeat(r-1):"0";let o=ig(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):tg(o.slice(0,i))+o.slice(i);let a=sg(e,r-1-s);return n?a.includes(".")?a:a+".":tg(a)}var tg=e=>e.includes(".")?e.replace(/\.?0+$/u,""):e;var Q3=/^[+-]?(?:0[bB][01]+|0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)/u,eO=/^[+-]?(?:0[xX](?:[\da-fA-F]+(?:\.[\da-fA-F]*)?|\.[\da-fA-F]+)(?:[pP][+-]?\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|inf(?:inity)?|nan(?:\([\w]*\))?)/iu;function lg(e,t){if(e?.[0]!=="'"&&e?.[0]!=='"')return null;let n=e.slice(1);if(n==="")return null;let r=_(n),o=t.byteLocale?1:_(String.fromCodePoint(n.codePointAt(0))).length;return r.length>o&&(t.stderr+=`printf: warning: ${X(r.slice(o))}: character(s) following character constant have been ignored
214
- `),t.byteLocale?r[0]:n.codePointAt(0)}function fg(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: ${cg(e,n)}: ${o?"value not completely converted":"expected a numeric value"}
215
- `,n.failed=!0),o||"0"}var ag={"\x07":"\\a","\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r","\\":"\\\\","'":"\\'"},ug=e=>"\\"+e.toString(8).padStart(3,"0");function cg(e,t){let n="";for(let r of e){if(ag[r]!==void 0){n+=ag[r];continue}let o=r.codePointAt(0);if(o<32||o===127){n+=ug(o);continue}n+=o>127&&t.byteLocale?_(r).map(ug).join(""):r}return`'${n}'`}function ls(e,t,n){let r=lg(e,n);if(r!==null)return BigInt(r);let o=fg(e,Q3,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>At:u<St||u>ge)?(n.stderr+=`printf: ${cg(e,n)}: Numerical result out of range
216
- `,n.failed=!0,t?At:i?St:ge):t?BigInt.asUintN(64,u):u}function fs(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")),sn(a,s,t,t.precision===null)}function dg(e,t,n){let r=lg(e,n),o=r===null?fg(e,eO,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()),sn(u,l,t,!1)}let s=iO(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=In(a,t);if(!s.exact){let[l,f]=tO(s.value);for(let c of[l,f])if(In(o.startsWith("-")?-c:c,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 dr=new DataView(new ArrayBuffer(8));function pg(e){return dr.setFloat64(0,e),dr.getBigUint64(0)}function tO(e){let t=pg(e);dr.setBigUint64(0,t-1n);let n=dr.getFloat64(0);return dr.setBigUint64(0,t+1n),[n,dr.getFloat64(0)]}function nO(e){let t=pg(e),n=Number(t>>52n);return{coefficient:t&(1n<<52n)-1n|(n?1n<<52n:0n),exponent:n?n-1075:-1074}}function kl(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 rO({coefficient:e,exponent:t}){return t<0?kl((e*5n**BigInt(-t)).toString(),t):kl((e<<BigInt(t)).toString(),0)}function oO(e,t){let n=e.exponent-t.exponent;return n>=0?e.coefficient<<BigInt(n)===t.coefficient:e.coefficient===t.coefficient<<BigInt(-n)}function iO(e){let t=/^0x/iu.test(e),n,r;if(t)n=sO(e),r=aO(n);else{let[a,u="0"]=e.split(/[eE]/u),[l,f=""]=a.split(".");n=kl(l+f,Number(u)-f.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=nO(r),i=rO(o),s=t?oO(n,o):n.digits===i.digits&&n.exponent===i.exponent;return{value:r,exact:s&&i.exponent>=-100&&i.digits.length<=101}}function sO(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 aO({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 hg={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,'"':34,"\\":92};function gg(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>je||l.precision>je)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(hg,o))n.push([hg[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(T(e.slice(r,o))),r=o}return t||n.push([10]),n}function wg(e,t,n,r){let o=r.isDir(n),i=!o&&r.isLink?.(n)===!0,s,a=e.map(f=>{if(!f.field)return f;if(f.field==="n")return mg(t,f);if(f.field==="s"&&o)throw new x("feature","directory byte size",`directory byte sizes are not available: ${t}`);return s??=o?0:r.fileSize(n),f.field==="F"?mg(o?"directory":i?"symbolic link":s===0?"regular empty file":"regular file",f):T(fs(BigInt(s),f))}),u=new Uint8Array(a.reduce((f,c)=>f+c.length,0)),l=0;for(let f of a)u.set(f,l),l+=f.length;return X(u)}function mg(e,t){let n=T(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 yg(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:f})=>f==="L"||f==="dereference"),s;for(let f of r)if(f.name==="cached"){if(!f.value||!["always","never","default"].some(c=>c.startsWith(f.value)))return b(`stat: invalid cache mode: ${f.value}`)}else["c","format","printf"].includes(f.name)&&(s=f);if(!s)return v("feature","stat","default metadata","stat: default output requires filesystem metadata that is not available");let a=gg(s.value,s.name==="printf");if(a.some(f=>f.field==="s"||f.field==="F")&&lO(o,n,i))return v("feature","stat","metadata output overlap","stat: buffered output sharing a measured file is not supported");let u=W(),l=!1;for(let f of o){let c=uO(a,f,n,i);P(u,c),l||=c.exitCode!==0}return u.exitCode=l?1:0,u}function uO(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=U(n,"stat",t,{follow:r});if(o.error)return b(`stat: cannot statx ${J(t,n)}: ${o.error}`);try{return M(wg(e,t,o.path,n.fs))}catch(i){let s=ne(i,"stat","stat: "+ee(i)),a=C(s);return a&&n.unsupported.add(a),s}}function lO(e,t,n){let r=Object.values(t.outputFds).filter(o=>typeof o=="object");return r.length?e.some(o=>{let i=$(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 fO=/[ \t\n\v\f\r]/gu,cO=/[ \t\n\v\f\r]+/gu,xg=/[ \t\n\v\f\r]+$/u,bg=e=>e.replace(/[A-Z]/gu,t=>t.toLowerCase());function cs({ignoreCase:e=!1,whitespace:t="none"}={}){let n=null;return t==="all"?n=r=>r.replace(fO,""):t==="change"?n=r=>r.replace(xg,"").replace(cO," "):t==="trailing"&&(n=r=>r.replace(xg,"")),e?n?r=>bg(n(r)):bg:n}function an(e){let t=[];for(let n=0;n<e.length;){let r=e.indexOf(`
217
- `,n),o=r<0?e.length:r+1;t.push(e.slice(n,o)),n=o}return t}var pr=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: ?(.*?))?\n?$/u,Cn=/^\*{15,}(?: (.*?))?\n?$/u,ds=/^\*{3} (\d+)(?:,(\d+))? \*{4}\n?$/u,yo=/^--- (\d+)(?:,(\d+))? ----\n?$/u,hr=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n?$/u;var Ke=class extends Error{constructor(t,n){super(n===void 0?t:`${t} at line ${n+1}`),this.name="PatchError",this.line=n}},ps=(e,t)=>t===0?Number(e):Number(e)-1,El=e=>e!==void 0&&e.startsWith("\\"),vl=e=>e.replace(/\n$/u,"");function $l(e){let t=an(e),n=[],r={old:null,new:null},o=!1;for(let i=0;i<t.length;){let s=t[i],a=kg(s,o);if(o=s.startsWith("***************")?!1:s.startsWith("*** "),a){r=a.names??{...r,[a.slot]:a.name},i++;continue}let u=pr.test(s)?"unified":Cn.test(s)?"context":hr.test(s)?"normal":null;if(u===null){i++;continue}let l=[],f=wO[u];for(let c=f(t,i);c!==null&&(l.push(c.hunk),i=c.next,!(i>=t.length||kg(t[i],!1)));c=f(t,i));n.push({old:r.old,new:r.new,format:u,hunks:l,blocks:dO(l)}),r={old:null,new:null}}return n}function kg(e,t){let n=/^diff --git (\S+) (\S+)\n?$/u.exec(e);if(n)return{names:{old:n[1],new:n[2]}};if(ds.test(e)||yo.test(e))return null;let r=/^(\*\*\* |--- |\+\+\+ )(.*?)(?:\t.*)?\n?$/u.exec(e);return r?r[1]==="--- "?{slot:t?"new":"old",name:r[2]}:{slot:r[1]==="*** "?"old":"new",name:r[2]}:null}function dO(e){let t=[];for(let n of e){let r=n.oldStart,o=n.newStart,i=null,s=()=>{i&&(t.push(i),r=i.a1,o=i.b1,i=null)};for(let{tag:a,text:u}of n.lines){if(a===" "){s(),r++,o++;continue}a==="-"&&i?.insert.length&&s(),i??={a0:r,a1:r,b0:o,b1:o,remove:[],insert:[]},a==="-"?(i.a1++,i.remove.push(u)):(i.b1++,i.insert.push(u))}s()}return t}function pO(e,t){let n=pr.exec(e[t]??"");if(!n)return null;let r=n[2]===void 0?1:Number(n[2]),o=n[4]===void 0?1:Number(n[4]),i={oldStart:ps(n[1],r),newStart:ps(n[3],o),label:n[5]||null,lines:[]},s=0,a=t+1,u=0;for(;u<r||s<o;a++){let l=e[a];if(l===void 0)throw new Ke("the patch ends inside a hunk",a);let f=l===`
218
- `?" ":l[0];if(f!==" "&&f!=="-"&&f!=="+")throw new Ke(`a hunk line begins with ${JSON.stringify(f)}`,a);let c=l===`
219
- `?l:l.slice(1);if(El(e[a+1])&&(c=vl(c),a++),f!=="+"&&u++,f!=="-"&&s++,u>r||s>o)throw new Ke("a hunk has more lines than its header says",a);i.lines.push({tag:f,text:c})}return{hunk:i,next:a}}function hO(e,t){let n=hr.exec(e[t]??"");if(!n)return null;let[,r,o,i,s,a]=n,u=i==="a"?0:Number(o??r)-Number(r)+1,l=i==="d"?0:Number(a??s)-Number(s)+1;if(u<0||l<0)throw new Ke("a change command counts backwards",t);let f={oldStart:i==="a"?Number(r):Number(r)-1,newStart:i==="d"?Number(s):Number(s)-1,label:null,lines:[]},c=t+1,d=(p,h,m)=>{for(let g=0;g<p;g++,c++){let w=e[c];if(w===void 0)throw new Ke("the patch ends inside a hunk",c);if(w[0]!==h)throw new Ke(`${JSON.stringify(h)} expected`,c);let y=w.slice(2);El(e[c+1])&&(y=vl(y),c++),f.lines.push({tag:m,text:y})}};if(d(u,"<","-"),i==="c"){if(e[c]!==`---
220
- `)throw new Ke("'---' expected",c);c++}return d(l,">","+"),{hunk:f,next:c}}function mO(e,t){let n=Cn.exec(e[t]??"");if(!n)return null;let r=ds.exec(e[t+1]??"");if(!r)throw new Ke("'*** ' range expected",t+1);let o=t+2,i=Eg(e,o,yo,"-");o=i.next;let s=yo.exec(e[o]??"");if(!s)throw new Ke("'--- ' range expected",o);let a=Eg(e,o+1,null,"+"),u=i.lines.length===0?a.lines.filter(d=>d.tag===" "):i.lines,l=a.lines.length===0?i.lines.filter(d=>d.tag===" "):a.lines,f=ps(r[1],u.length),c=ps(s[1],l.length);return{hunk:{oldStart:f,newStart:c,label:n[1]||null,lines:gO(u,l)},next:a.next}}function Eg(e,t,n,r){let o=[],i=t;for(;i<e.length;i++){let s=e[i];if(n&&n.test(s)||Cn.test(s)||ds.test(s)||!n&&yo.test(s))break;if(El(s)){o[o.length-1].text=vl(o.at(-1).text);continue}let a=s===`
221
- `?" ":s[0];if(a!==" "&&a!=="!"&&a!=="-"&&a!=="+")break;o.push({tag:a===" "?" ":r,text:s===`
222
- `?s:s.slice(2)})}return{lines:o,next:i}}function gO(e,t){let n=[],r=0,o=0;for(;r<e.length||o<t.length;){if(e[r]?.tag===" "&&t[o]?.tag===" "){n.push(e[r]),r++,o++;continue}for(;r<e.length&&e[r].tag!==" ";)n.push(e[r]),r++;for(;o<t.length&&t[o].tag!==" ";)n.push(t[o]),o++;e[r]?.tag===" "&&t[o]===void 0?(n.push(e[r]),r++):t[o]?.tag===" "&&e[r]===void 0&&(n.push(t[o]),o++)}return n}var wO={unified:pO,context:mO,normal:hO};var it=class extends Error{constructor(t){super(`the rendered diff does not say what the change set says (${t})`),this.name="FormatError"}};function Ng(e,t,n,r){if(n.length===0){if(r!=="")throw new it("there was nothing to print, and something was printed");return}let o;try{o=$l(r)}catch(s){throw new it(`it does not read back (${s.message})`)}if(o.length!==1)throw new it(`${o.length} files read back, not one`);let i=o[0].blocks;if(i.length!==n.length)throw new it(`${i.length} blocks read back, not ${n.length}`);for(let[s,a]of i.entries()){let u=n[s];if(a.a0!==u.a0||a.a1!==u.a1||a.b0!==u.b0||a.b1!==u.b1)throw new it(`block ${s+1} reads back somewhere else`)}for(let s of o[0].hunks){let a=s.oldStart,u=s.newStart;for(let{tag:l,text:f}of s.lines){let c=l==="+"?t[u]:e[a];if(f!==c)throw new it(`a ${l==="+"?"added":l==="-"?"removed":"kept"} line is not the line it stands for`);l!=="+"&&a++,l!=="-"&&u++}}}function yO(e,t,n,r){let o=[],i=0;for(;i<e.length;){let s=i;for(;s+1<e.length&&e[s+1].a0-e[s].a1<=2*t;)s++;let a=e[i],u=e[s];o.push({blocks:e.slice(i,s+1),a0:Math.max(0,a.a0-t),a1:Math.min(n,u.a1+t),b0:Math.max(0,a.b0-t),b1:Math.min(r,u.b1+t)}),i=s+1}return o}var Og=e=>(t,n,r,{context:o,label:i=null})=>{let s="";for(let a of yO(r,o,t.length,n.length))s+=e(t,n,a,i?i(a.a0):null);return Ng(t,n,r,s),s},xO=`
223
- \
224
- `,Dt=(e,t)=>e+t+(t.endsWith(`
225
- `)?"":xO);function vg(e,t){return t>e+1?`${e+1},${t}`:`${t>e?e+1:e}`}function Tg(e,t,n){let r="";for(let{a0:o,a1:i,b0:s,b1:a}of n){let u=o===i?"a":s===a?"d":"c";r+=vg(o,i)+u+vg(s,a)+`
226
- `;for(let l=o;l<i;l++)r+=Dt("< ",e[l]);u==="c"&&(r+=`---
227
- `);for(let l=s;l<a;l++)r+=Dt("> ",t[l])}return Ng(e,t,n,r),r}function $g(e,t){return t<=e?`${e},0`:t===e+1?`${e+1}`:`${e+1},${t-e}`}var Ig=Og((e,t,n,r)=>{let o=`@@ -${$g(n.a0,n.a1)} +${$g(n.b0,n.b1)} @@${r===null?"":" "+r}
228
- `,i=n.a0,s=n.b0;for(let{a0:a,a1:u,b1:l}of n.blocks){for(;i<a;i++,s++)o+=Dt(" ",e[i]);for(;i<u;i++)o+=Dt("-",e[i]);for(;s<l;s++)o+=Dt("+",t[s])}for(;i<n.a1;i++,s++)o+=Dt(" ",e[i]);return o});function Sg(e,t){return t<=e?`${e}`:t===e+1?`${e+1}`:`${e+1},${t}`}var Cg=Og((e,t,n,r)=>{let o=`***************${r===null?"":" "+r}
229
- `;return o+=`*** ${Sg(n.a0,n.a1)} ****
230
- `,n.blocks.some(i=>i.a0<i.a1)&&(o+=Ag(e,n.a0,n.a1,n.blocks,"a")),o+=`--- ${Sg(n.b0,n.b1)} ----
231
- `,n.blocks.some(i=>i.b0<i.b1)&&(o+=Ag(t,n.b0,n.b1,n.blocks,"b")),o});function Ag(e,t,n,r,o){let i=o+"1",s=o+"0",a=o==="a"?"b":"a",u="",l=t;for(let f of r){for(;l<f[s];l++)u+=Dt(" ",e[l]);let c=f[a+"0"]<f[a+"1"]?"! ":o==="a"?"- ":"+ ";for(;l<f[i];l++)u+=Dt(c,e[l])}for(;l<n;l++)u+=Dt(" ",e[l]);return u}function bO(e){let t=[];for(let n=0;;){let r=n;for(;n<e.length&&e[n];)n++;if(t.push(n>r),n===e.length)return t;n++}}function Sl(e,t,n){let r=t.length,o=bO(n),i=0,s=0,a=0,u=()=>{if(i===r||e[a]!==e[i])return!1;for(t[a++]=0,t[i++]=1,s++;i<r&&t[i];)i++;return!0},l=()=>{if(a===0||e[a-1]!==e[i-1])return!1;for(t[--a]=1,t[--i]=0,s--;a>0&&t[a-1];)a--;return!0};for(let f=0;f<r;f++){if(!t[f]){s++;continue}for(a=f,i=f;i<r&&t[i];i++);let c=-1;for(let d=-1;d!==i-a;){for(d=i-a;l(););for(c=o[s]?i:-1;u();)o[s]&&(c=i)}if(c!==-1)for(let d=i-c;d>0;d--)l();f=i-1}}function kO(e){let t=1;for(let n=e;n!==0;n>>=2)t<<=1;return Math.max(256,t)}function _g(e,t,{ignoreCase:n=!1,whitespace:r="none",minimal:o=!1,slide:i=!0}={}){let s=cs({ignoreCase:n,whitespace:r});if(s===null&&Al(e,t,null))return[];let{A:a,B:u}=EO(e,t,s),l=new Uint8Array(a.length),f=new Uint8Array(u.length);vO(a,u,l,f,o),i&&(Sl(a,l,f),Sl(u,f,l));let c=AO(l,f);return NO(e,t,c,s),c}function Al(e,t,n=null){if(e.length!==t.length)return!1;let r=n?(o,i)=>n(o)===n(i):(o,i)=>o===i;for(let o=0;o<e.length;o++)if(!r(e[o],t[o]))return!1;return!0}function EO(e,t,n){let r=new Map,o=s=>{let a=n?n(s):s,u=r.get(a);return u===void 0&&(u=r.size,r.set(a,u)),u};return{A:Int32Array.from(e,o),B:Int32Array.from(t,o)}}function vO(e,t,n,r,o){let i=e.length+t.length+3,s={A:e,B:t,fd:new Int32Array(i),bd:new Int32Array(i),base:t.length+1,limit:kO(e.length+t.length)},a=[{xoff:0,xlim:e.length,yoff:0,ylim:t.length,minimal:o}],u={xmid:0,ymid:0,loMinimal:!1,hiMinimal:!1};for(;a.length;){let{xoff:l,xlim:f,yoff:c,ylim:d,minimal:p}=a.pop();for(;l<f&&c<d&&e[l]===t[c];)l++,c++;for(;l<f&&c<d&&e[f-1]===t[d-1];)f--,d--;if(l===f){for(;c<d;c++)r[c]=1;continue}if(c===d){for(;l<f;l++)n[l]=1;continue}$O(s,l,f,c,d,p,u),a.push({xoff:u.xmid,xlim:f,yoff:u.ymid,ylim:d,minimal:u.hiMinimal}),a.push({xoff:l,xlim:u.xmid,yoff:c,ylim:u.ymid,minimal:u.loMinimal})}}function $O(e,t,n,r,o,i,s){let{A:a,B:u,fd:l,bd:f,base:c,limit:d}=e,p=n-r,h=t-o,m=n-o,g=t-r,w=m,y=m,E=g,S=g,I=(g-m&1)!==0;l[c+g]=t,f[c+m]=n;for(let B=1;;B++){S>h?l[c+--S-1]=-1:++S,E<p?l[c+ ++E+1]=-1:--E;for(let L=E;L>=S;L-=2){let V=l[c+L+1],Q=l[c+L-1],q=Q<V?V:Q+1,ve=q-L;for(;q<n&&ve<o&&a[q]===u[ve];)q++,ve++;if(l[c+L]=q,I&&y<=L&&L<=w&&f[c+L]<=q){s.xmid=q,s.ymid=ve,s.loMinimal=s.hiMinimal=!0;return}}y>h?f[c+--y-1]=2147483647:++y,w<p?f[c+ ++w+1]=2147483647:--w;for(let L=w;L>=y;L-=2){let V=f[c+L+1],Q=f[c+L-1],q=Q<V?Q:V-1,ve=q-L;for(;t<q&&r<ve&&a[q-1]===u[ve-1];)q--,ve--;if(f[c+L]=q,!I&&S<=L&&L<=E&&q<=l[c+L]){s.xmid=q,s.ymid=ve,s.loMinimal=s.hiMinimal=!0;return}}if(!(i||B<d)){SO(e,{xoff:t,xlim:n,yoff:r,ylim:o,fmin:S,fmax:E,bmin:y,bmax:w},s);return}}}function SO(e,t,n){let{fd:r,bd:o,base:i}=e,{xoff:s,xlim:a,yoff:u,ylim:l,fmin:f,fmax:c,bmin:d,bmax:p}=t,h=0,m=-1;for(let y=c;y>=f;y-=2){let E=Math.min(r[i+y],a),S=E-y;l<S&&(E=l+y,S=l),m<E+S&&(m=E+S,h=E)}let g=0,w=2147483647;for(let y=p;y>=d;y-=2){let E=Math.max(s,o[i+y]),S=E-y;S<u&&(E=u+y,S=u),E+S<w&&(w=E+S,g=E)}a+l-w<m-(s+u)?(n.xmid=h,n.ymid=m-h,n.loMinimal=!0,n.hiMinimal=!1):(n.xmid=g,n.ymid=w-g,n.loMinimal=!1,n.hiMinimal=!0)}function AO(e,t){let n=[],r=t.length,o=e.length,i=0,s=0;for(;i<o||s<r;){if(i<o&&s<r&&!e[i]&&!t[s]){i++,s++;continue}let a=i,u=s;for(;i<o&&e[i];)i++;for(;s<r&&t[s];)s++;if(a===i&&u===s)throw new Me("a kept line has no counterpart");n.push({a0:a,a1:i,b0:u,b1:s})}return n}function NO(e,t,n,r=null){let o=r?(a,u)=>r(a)===r(u):(a,u)=>a===u,i=0,s=0;for(let{a0:a,a1:u,b0:l,b1:f}of n){if(a<i||l<s||u<a||f<l||u>e.length||f>t.length)throw new Me("a block is out of order or out of range");if(a===u&&l===f)throw new Me("a block changes nothing");if(a-i!==l-s)throw new Me("the kept lines before a block differ in count");for(;i<a;i++,s++)if(!o(e[i],t[s]))throw new Me(`kept line ${i+1} does not match`);i=u,s=f}if(e.length-i!==t.length-s)throw new Me("the kept lines after the last block differ in count");for(;i<e.length;i++,s++)if(!o(e[i],t[s]))throw new Me(`kept line ${i+1} does not match`)}var Me=class extends Error{constructor(t){super(`the computed change set does not reconstruct the second file (${t})`),this.name="DiffError"}};var OO={unified:Ig,context:Cg,normal:Tg},Lg=`Files differ
232
- `;function TO(e,t,n){if(e===t)return"";let r=cs(n);return r===null?Lg:Al(an(e),an(t),r)?"":Lg}function xo(e,t,{format:n="unified",context:r=3,label:o=null,...i}={}){if(n==="brief")return TO(e,t,i);let s=an(e),a=an(t),{slide:u=n!=="normal"&&r>0,...l}=i,f=_g(s,a,{...l,slide:u});return f.length===0?"":OO[n](s,a,f,{context:r,label:o})}var IO=[" 1970-01-01 00:00:00.000000000 +0000"," Thu Jan 1 00:00:00 1970"];function Fg(e,t,n,r,o){let{ctx:i,opts:s}=e,a=CO(s,t);if(a==="")return"";let u=c=>s.labels[c]??Yu(n[c],i)+(r[c]?IO[s.style==="context"?1:0]:""),l=c=>s.labels[c]??Yu(n[c],i),f=o?`diff${s.switches} ${l(0)} ${l(1)}
233
- `:"";return s.style==="unified"?`${f}--- ${u(0)}
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)}
234
218
  +++ ${u(1)}
235
- ${a}`:s.style==="context"?`${f}*** ${u(0)}
219
+ ${a}`:s.style==="context"?`${c}*** ${u(0)}
236
220
  --- ${u(1)}
237
- ${a}`:f+a}function CO(e,t){let n=e.showFunction?dt(t[0]):null;return xo(t[0],t[1],{format:e.style??"normal",context:e.context,label:n?r=>LO(n,r):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace})}var _O=/^[A-Za-z$_]/u;function LO(e,t){for(let n=t-1;n>=0;n--){if(!_O.test(e[n]))continue;let r=_(e[n].replace(/\n$/u,"")),o=Math.min(40,r.length);for(;o>0&&FO(r[o-1]);)o--;return RO(r.subarray(0,o))}return null}var FO=e=>e===32||e>=9&&e<=13;function RO(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return X(e.subarray(0,t))}catch{}return""}var MO=["q","s","r","N","a","i","w","b","Z","p","d","u","c","e","n","y","t","T","l","E","B","P","v","H"],DO=["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"],Rg=["U","C","x","X","S","F","W","I","D"],Mg=["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"],UO=["L","label","x","exclude"],PO=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"],["horizon-lines","the horizon setting"],["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"]]),bo=e=>b(`diff: ${e}
238
- diff: Try 'diff --help' for more information.`,2);function zO(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 Dg(e){let t=zO(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:MO,long:DO,valueShort:Rg,valueLong:Mg,repeatable:UO})}catch(o){let i=C(o);return i?{refused:v(i.kind,"diff",i.detail,`diff: ${o.message}`,2)}:{error:bo(o.message)}}let r={style:null,context:-1,labels:[],excludes:[],whitespace:"none",switches:WO(e)};for(let{name:o,value:i}of n.order){let s=PO.get(o),a=(o.length===1?"-":"--")+o;if(s)return{refused:v("option","diff",a,`diff: ${a}: ${s} is not supported`,2)};let u=BO(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:bo(`missing operand after '${n.positional[0]??"diff"}'`)}:n.positional.length>2?{error:bo(`extra operand '${n.positional[2]}'`)}:{opts:r,operands:n.positional}}function BO(e,t,n){let r=o=>e.style!==null&&e.style!==o?bo("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=jO(n);if(o===null)return bo(`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"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 jO(e){if(e==="")return 0;let t=_e(e,"diff");return t.error?null:t.value}function WO(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--")break;!r.startsWith("-")||r==="-"||(t.push(r),qO(r)&&n+1<e.length&&t.push(e[++n]))}return t.map(n=>" "+pe(n,{vars:new Map})).join("")}function qO(e){if(e.startsWith("--"))return!e.includes("=")&&(Mg.includes(e.slice(2))||e==="--label"||e==="--exclude");for(let t=1;t<e.length;t++){let n=e[t];if(Rg.includes(n)||n==="L")return t+1===e.length}return!1}function gs(e,t,n){let{ctx:r,opts:o}=e,i=XO(zg(e,t),zg(e,n));for(let[s,a,u]of i){let l=ms(t,s),f=ms(n,s),c=a?Pg(r,l):null,d=u?Pg(r,f):null;if(a&&u){GO(e,[l,f],[c,d]);continue}o.newFile?HO(e,[l,f],c??d,[a,u]):De(e,`Only in ${a?t:n}: ${s}
239
- `,1)}}function HO(e,[t,n],r,o){hs(r)?e.opts.recursive?Bg(e,[t,n],o.map(i=>i?r:null)):De(e,`Common subdirectories: ${t} and ${n}
240
- `):ko(e,t,n,!0,o)}function GO(e,[t,n],[r,o]){let{opts:i}=e,s=[r,o].indexOf("gone");if(s!==-1&&hs([r,o][1-s])){let a=[t,n][s];return De(e,`diff: ${a}: ${$(e.ctx.cwd,a,e.ctx.fs).error}
241
- `,2,!0)}if(hs(r)&&hs(o))i.recursive?Bg(e,[t,n],[r,o]):De(e,`Common subdirectories: ${t} and ${n}
242
- `);else if(r===o||s!==-1)ko(e,t,n,!0,[!0,!0]);else{let a=(u,l)=>i.labels[u]??l;De(e,`File ${a(0,t)} is a ${Ug[r]} while file ${a(1,n)} is a ${Ug[o]}
243
- `,1)}}var Ug={dir:"directory",link:"directory",file:"regular file"},hs=e=>e==="dir"||e==="link";function Pg(e,t){let n=$(e.cwd,t,e.fs);return n.error?"gone":e.fs.isDir(n.path)?e.fs.isLink?.($(e.cwd,t,e.fs,{follow:!1}).path)?"link":"dir":"file"}function Bg(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}`);gs(e,t,n)}function zg(e,t){let{ctx:n,opts:r}=e,o=$(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(G);return r.excludes.length?u.filter(l=>!r.excludes.some(f=>um(l,f))):u}function XO(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:G(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 Hg(e,t,n){let r=Dg(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:W(),status:0},[a,u]=i,l=i.map(f=>jg(s,f));if(l[0]==="dir"&&l[1]==="dir"&&ZO(s,a,u))return s.out;if(l[0]==="dir"&&l[1]==="dir")gs(s,a,u);else if(l[0]==="dir"||l[1]==="dir"){let f=l[0]==="dir"?0:1,c=i[1-f];if(c==="-")return b("diff: cannot compare '-' to a directory",2);if(l[1-f]==="missing"){let d=$(s.ctx.cwd,c,s.ctx.fs).error;o.newFile&&d==="No such file or directory"?gs(s,a,u):De(s,`diff: ${c}: ${d}
244
- `,2,!0)}else{let d=ms(i[f],Ce(c)),p=f===0?[d,c]:[c,d];jg(s,d)==="missing"?De(s,`diff: ${d}: No such file or directory
245
- `,2,!0):ko(s,p[0],p[1],!1)}}else ko(s,a,u,!1);return s.out.exitCode=s.status,s.out}function ms(e,t){let n=e.replace(/\/+$/u,"");return(n===""?"/":n+"/")+t}function ZO(e,t,n){return $(e.ctx.cwd,t,e.ctx.fs).path===$(e.ctx.cwd,n,e.ctx.fs).path}function jg(e,t){if(t==="-")return"stdin";let n=$(e.ctx.cwd,t,e.ctx.fs);return n.error?"missing":e.ctx.fs.isDir(n.path)?"dir":"file"}function De(e,t,n=0,r=!1){P(e.out,r?W(t):{...W(),stdout:t,events:[{fd:1,text:t}]}),e.status=Math.max(e.status,n)}function ko(e,t,n,r,o=null){let{opts:i}=e,s=[t,n].map(p=>KO(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)||(De(e,`diff: ${[t,n][p]}: ${s[p].error??"No such file or directory"}
246
- `,2,!0),l=!0);if(l)return;if(s[0].identity!==void 0&&s[0].identity===s[1].identity&&!a[0])return Eo(e,t,n);let f=p=>i.labels[p]??[t,n][p];if(!i.text&&s.some(VO))return Wg(s)?Eo(e,t,n):De(e,`${i.brief?"Files":"Binary files"} ${f(0)} and ${f(1)} differ
247
- `,1);if(s.some(p=>p.content===void 0)){if(Wg(s))return Eo(e,t,n);if(i.brief&&!i.ignoreCase&&!i.stripCr&&i.whitespace==="none")return De(e,`Files ${f(0)} and ${f(1)} differ
248
- `,1)}for(let[p,h]of s.entries())h.content===void 0&&jt(h.bytes,JSON.stringify(f(p)));let c=s.map(p=>p.content??"");if(i.stripCr&&(c=c.map(YO)),i.brief)return xo(c[0],c[1],{format:"brief",ignoreCase:i.ignoreCase,whitespace:i.whitespace})===""?Eo(e,t,n):De(e,`Files ${f(0)} and ${f(1)} differ
249
- `,1);let d;try{d=Fg(e,c,[t,n],a,r)}catch(p){if(!(p instanceof Me)&&!(p instanceof it))throw p;let h=`diff: ${t} ${n}: ${p.message}`,m=p instanceof Me?"change set verification":"diff rendering verification";P(e.out,v("feature","diff",m,h,2)),e.status=2;return}if(d==="")return Eo(e,t,n);De(e,d,1)}function Eo(e,t,n){e.opts.identical&&De(e,`Files ${t} and ${n} are identical
250
- `)}var YO=e=>e.replace(/\r\n/gu,`
251
- `),VO=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes("\0")===!0,Wg=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:_r(e.bytes??qg,t.bytes??qg),qg=new Uint8Array;function KO(e,t){let{ctx:n}=e;if(t==="-")return j(n),{content:e.stdin,identity:n.stdinHandle?.identity??Symbol("stdin")};let r=U(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}=pt(n.fs,r.path);return{content:o,bytes:i,identity:n.fs.fileIdentity?.(r.path)??r.path}}var mr=(e,t,n)=>{throw new ie(`malformed patch at line ${Math.min(t,e.lines.length-1)+1}: ${n??""}`)};function vo(e,t){return!!e.lines[t+1]?.startsWith("\\")}function Zg(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=[],f=[],c=0,d=n,p=-1;for(n++;f.length<a||l.length<u;n+=1){let h=t[n]!==void 0;if(!h&&u-l.length>3)throw new ie("unexpected end of file in patch");let m=h?t[n]:`
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]:`
252
236
  `;h&&(d=n);let g=m[0],w=m;g===" "||g===`
253
- `?g=" ":w=m.slice(1),g!=="-"&&g!=="+"&&g!==" "&&mr(e,n,m);let y=!1;g!=="+"&&(f.length>=a&&mr(e,n,m),y=h&&f.length+1===a&&vo(e,n),y&&(w=w.replace(/\n$/u,"")),f.push({tag:g,text:w}),g===" "&&c++),g!=="-"&&(l.length>=u&&mr(e,n,m),!y&&h&&l.length+1===u&&vo(e,n)&&(y=!0,w=w.replace(/\n$/u,"")),l.push({tag:g,text:w})),g!==" "&&(p===-1&&(p=c),c=0),y&&n++}return p===-1&&mr(e,d,t[d]),e.pos=n,{oldStart:s,oldLines:f,newStart:i,newLines:l,prefix:p,suffix:c,fn:r[5]===void 0?null:" "+r[5],marks:null,line:o}}function Nl(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 ie(`unexpected '***' at line ${n+1}: ${t[n]??""}`);let s=Gg(i),a=[],u=c=>/^--- (\d+)(?:,(\d+))? ----/u.exec(t[c]??"")??/^--- (\d+)(?:,(\d+))?/u.exec(t[c]??"");for(n++;!u(n);n++){if(t[n]===void 0||a.length>=s.count)throw new ie(`no '---' found in patch at line ${r+1}`);a.push(Xg(e,n,a.length+1===s.count)),a.at(-1).skip&&n++}let l=Gg(u(n)),f=[];for(n++;f.length<l.count;n++){let c=t[n];if(c===void 0||!/^[ !+\-\t\n]/u.test(c)||c.startsWith("***"))break;f.push(Xg(e,n,f.length+1===l.count)),f.at(-1).skip&&n++}return f.length!==0&&f.length<l.count&&mr(e,n,t[n]),e.pos=n,JO({oldRange:s,oldSide:a,newRange:l,newSide:f,fn:o,line:r})}function Gg(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 Xg(e,t,n){let r=e.lines[t],o=r[0];o===" "||o===`
254
- `?o=" ":(r=r.slice(1),(r[0]===" "||r[0]===" ")&&(r=r.slice(1)));let i=n&&vo(e,t);return{mark:o,text:i?r.replace(/\n$/u,""):r,skip:i}}function JO({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 ie(`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})),f=p=>{let h=0;for(let m of p){if(m.tag!==" ")break;h++}return h},c=Math.min(f(u),f(l)),d=Math.min(f(u.toReversed()),f(l.toReversed()));if(u.every(p=>p.tag===" ")&&l.every(p=>p.tag===" "))throw new ie(`replacement text or line numbers mangled in hunk at line ${i+1}`);return{oldStart:e.first,oldLines:u,newStart:n.first,newLines:l,prefix:c,suffix:d,fn:o,marks:{old:a.map(p=>p.mark),new:s.map(p=>p.mark)},line:i}}function Yg(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)&&mr(e,n,t[n]);let f=[],c=[];n++;for(let d=0;d<s;d++,n++){if(t[n]===void 0)throw new ie(`unexpected end of file in patch at line ${n}`);if(!/^<[ \t]/u.test(t[n]))throw new ie(`'<' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===s&&vo(e,n);c.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 ie(`unexpected end of file in patch at line ${n}`);if(!t[n].startsWith("-"))throw new ie(`'---' expected at line ${n+1} of patch`);n++}for(let d=0;d<l;d++,n++){if(t[n]===void 0)throw new ie(`unexpected end of file in patch at line ${n}`);if(!/^>[ \t]/u.test(t[n]))throw new ie(`'>' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===l&&vo(e,n);f.push({tag:"+",text:p?t[n].slice(2).replace(/\n$/u,""):t[n].slice(2)}),p&&n++}return e.pos=n,{oldStart:i,oldLines:c,newStart:a,newLines:f,prefix:0,suffix:0,fn:null,marks:null,line:o}}function ws(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 ie=class extends Error{constructor(t){super(t),this.name="PatchFatal"}},gr=(e,t)=>{throw new x("feature",e,t)};function ew(e){let t=dt(e);return t.length&&!t.at(-1).endsWith(`
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(`
255
239
  `)&&(t[t.length-1]+=`
256
- `),{lines:t,pos:0,base:0,empty:e===""}}var QO=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u,Vg=/^(?:\d+(?:,\d+)?)?(?:[acdi]|s\/\.\/\/)[ \t]*\n$/u,Kg=/^[0-9a-fA-F]+/u;function tw(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,f=!1;for(let c=e.pos;;c++){if(c>=o.length)return a&&gr("ed script","ed scripts are not supported"),i.extended?{...i,type:"unified",start:c,hunkLine:c,empty:!0}:null;let d=o[c],p=d.replace(/^[ \tX]+/u,""),h=/^\d/u.test(p)&&QO.test(p);!s&&u<0&&(Vg.test(p)||h)&&(u=c,a=Vg.test(p));let m=eT(d,i,n,f);if(m==="binary"&&gr("git binary patch","git binary diffs are not supported"),m==="prereq"&&gr("Prereq","Prereq: lines are not supported"),m==="git"&&i.extended)return{...i,type:"unified",start:c,hunkLine:c,empty:!0};m&&(s=!1);let g=d.startsWith("********");if(/^[ \t]+(?:@@ -\d|\*{8})/u.test(d)&&gr("indented patch","indented patches are not supported"),!s){if(d.endsWith(`\r
257
- `)&&(d.startsWith("@@ -")||f)&&gr("CRLF patch","patches with CRLF line endings are not supported"),(r===null||r==="ed")&&u>=0&&d===`.
258
- `&&gr("ed script","ed scripts are not supported"),(r===null||r==="unified")&&d.startsWith("@@ -"))return nT(i,c,d);if((r===null||r==="context")&&f&&d.startsWith("*** "))return rT(e,i,c,d);if((r===null||r==="normal")&&l&&(d.startsWith("< ")||d.startsWith("> ")))return{...i,type:"normal",start:c-1,hunkLine:c-1}}f=g,l=h}}function eT(e,t,n,r){if(!r&&e.startsWith("*** ")||e.startsWith("+++ "))return Ol(t,"old",e.slice(4),n);if(e.startsWith("Index:"))return t.names.index=rw(e.slice(6),n,!1).name,"index";if(e.startsWith("Prereq:"))return"prereq";if(e.startsWith("diff --git ")){let i=Jg(e.slice(11),n),s=i.name===null?null:Jg(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=tT(e,t);if(i)return i}let o=e;for(;o.startsWith("- ");)o=o.slice(2);return o.startsWith("--- ")?Ol(t,"new",o.slice(4),n):null}function tT(e,t){if(e.startsWith("index ")){let n=Kg.exec(e.slice(6)),r=n?e.slice(6+n[0].length):"",o=r.startsWith("..")?Kg.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 Ol(e,t,n,r){let o=rw(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 nT(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 rT(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=Nl(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 nw(e,t){return t==="unified"?Zg(e):t==="context"?Nl(e):Yg(e)}function rw(e,t,n){let r=e.replace(/^[ \t\n\v\f\r]+/u,""),o,i;if(r.startsWith('"')){let u=iw(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?" ":`
259
- `,l+1)!==-1))break}o=r.slice(0,u),i=r.slice(u)}if(o==="/dev/null")return{stamp:0};let s=ow(o,t);if(s===null)return{};let a=i.replace(/\r?\n$/u,"");return{name:s,timestr:a,stamp:n&&a!==""?oT(a):-1}}function oT(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,f,c]=t;n=Date.UTC(Number(r),Number(o)-1,Number(i),Number(s),Number(a),Number(u))/1e3,l&&(n-=(l==="-"?-1:1)*(Number(f)*3600+Number(c)*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,f]=r;n=Date.UTC(Number(f),o.indexOf(i),Number(s),Number(a),Number(u),Number(l))/1e3}return n>-25*3600&&n<26*3600?0:n}function ow(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 Jg(e,t){let n=e.replace(/^[ \t\n\v\f\r]+/u,""),r,o;if(n.startsWith('"')){let i=iw(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:ow(r,t),rest:o}}var Qg={a:"\x07",b:"\b",f:"\f",n:`
260
- `,r:"\r",t:" ",v:"\v","\\":"\\",'"':'"'};function iw(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 Qg)t+=Qg[o];else return null}return null}function sw(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,f]=[r(s),r(e[o])];if(l!==f){l<f&&(o=i);continue}s.length<e[o].length&&(o=i)}return o}function Tl(e,t){let{opts:n}=e;return(n.noReverse||!(n.force&&n.silent))&&e.say(t),n.noReverse?(e.say(` Skipping patch.
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.
261
245
  `),e.skipRest=!0,!1):n.force?(n.silent||e.say(` Applying it anyway.
262
246
  `),!1):n.batch?(e.say(e.reverse?` Ignoring -R.
263
247
  `:` Assuming -R.
@@ -265,23 +249,23 @@ diff: Try 'diff --help' for more information.`,2);function zO(e){let t=[];for(le
265
249
  `:` Assume -R? [n]
266
250
  `),e.say(`Apply anyway? [n]
267
251
  `),n.silent||e.say(`Skipping patch.
268
- `),e.skipRest=!0,!1)}function aw(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";Tl(e,`The next patch${e.reverse?", when reversed,":""} would ${u} the file ${e.quote(n)},
269
- which ${l}!`)&&(e.reverse=!e.reverse)}return a}function uw(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(f=>f===null?null:r(f)),u=a.map(f=>f===null||!f.exists);i=sw(o,u);let l=o.findIndex(f=>f!==null);if(l!==-1&&(i===-1||!a[i].isDir)){let f=i===-1;aw(e,t,o[f?l:i],f,f||a[i].size===0)&&f&&(i=l)}i===-1&&t.says[e.reverse?1:0]&&(i=sw(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
270
- `),e.skipRest=!0),i===-1){if(n===null)return null;let a=r(n);return(!a.exists||!a.isDir)&&aw(e,t,n,!a.exists,!a.exists||a.size===0),n}return o[i]}function fw(e){return{input:e,frozen:0,inOffset:0,outOffset:0,out:[]}}var iT=(e,t)=>t<1||t>e.input.length?"":e.input[t-1];function sT(e,t){let n=r=>r.replace(/\n$/u,"").replace(/[ \t]+$/u,"").replace(/[ \t]+/gu," ");return n(e)===n(t)}function ys(e,t,n,r,o,i,s){let a=t.oldLines,u=a.length-i;for(let l=n+r+o,f=o;f<u;f++,l++){let c=iT(e,l),d=a[f].text;if(s?!sT(c,d):c!==d)return!1}return!0}function lw(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,f=l-(i-u)+1,c=e.frozen+1,d=f-o,p=o-c,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&&ys(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&&ys(e,t,o,-w,a,0,r)?m(-w):0}let g=d<0?o-f:p<0?o-c:0;for(let w=g;w<=h;w++){if(w<=d&&ys(e,t,o,w,a,u,r))return m(w);if(w<=p&&ys(e,t,o,-w,a,u,r))return m(-w)}return 0}function xs(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 aT(e,t,n){let r=n-1,o=t.newLines,i=t.oldLines,s=0,a=0,u=()=>{throw new ie(`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(!xs(e,r+a))return!1;e.frozen++,a++}else{if(s>=o.length)break;if(o[s].tag==="+"){if(!xs(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(!xs(e,r+a))return!1;e.out.push(o[s].text)}return e.outOffset+=o.length-i.length,!0}var cw=e=>e.frozen>=e.input.length||xs(e,e.input.length),dw=e=>e.map((t,n)=>n<e.length-1&&!t.endsWith(`
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(`
271
255
  `)?t+`
272
- `:t).join("");function pw(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?ws(a):a,where:0,fuzz:0}:uT(e,r,e.reverse?ws(a):a,s),{hunk:l,where:f,fuzz:c}=u,d=(f||l.oldStart)+r.outOffset,p=f===1&&t.says[e.reverse?1:0]===2&&r.input.length>0;if(e.skipRest||p||!f||!aT(r,l,f))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}.
273
- `);else if(!i.silent&&(c||r.inOffset)){let h=r.inOffset?` (offset ${r.inOffset} line${r.inOffset===1?"":"s"})`:"";e.say(`Hunk #${s.count} succeeded at ${d}${c?` with fuzz ${c}`:""}${h}.
274
- `)}}return s}function uT(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=lw(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=ws(s);a=lw(t,l,i,o.loose),a&&Tl(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 $o=(e,t)=>e+t;function gw(e,t){let n="",r=(i,s)=>`${i} ${e.names[s]??"/dev/null"}${e.timestrs[s]??""}
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]??""}
275
259
  `,o=e.names.index===null?"":`Index: ${e.names.index}
276
- `;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+=lT(i,a)):(s&&(n+=o+r("***",l[0])+r("---",l[1])),n+=fT(i,a,t))}}}var hw=(e,t)=>t===0?`${e-1},0`:t===1?`${e}`:`${e},${t}`;function lT(e,t){let n=e.newLines,r=e.oldLines,o=`@@ -${hw(e.oldStart+t,r.length)} +${hw(e.newStart+t,n.length)} @@${e.fn??""}
277
- `,i=0,s=0;for(;;s++,i++){for(;s<r.length&&r[s].tag==="-";s++)o+=$o("-",r[s].text);for(;i<n.length&&n[i].tag==="+";i++)o+=$o("+",n[i].text);if(s>=r.length)break;o+=$o(" ",r[s].text)}return o}function mw(e,t){let n=e+t-1;return n<e?"0":n===e?`${e}`:`${e},${n}`}function fT(e,t,n){let r=n!=="normal",o=e.marks??(n==="normal"?cT(e):dT(e)),i=`***************${e.fn??""}
278
- `;return i+=`*** ${mw(e.oldStart+t,e.oldLines.length)}${r?" ****":""}
279
- `,e.oldLines.forEach((s,a)=>{i+=$o(o.old[a]+" ",s.text)}),i+=`--- ${mw(e.newStart+t,e.newLines.length)}${r?" ----":" -----"}
280
- `,e.newLines.forEach((s,a)=>{i+=$o(o.new[a]+" ",s.text)}),i}var cT=e=>({old:e.oldLines.map(t=>t.tag),new:e.newLines.map(t=>t.tag)});function dT(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 pT=["R","N","f","t","s","b","l","E","T","Z","e","u","c","n","v"],hT=["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"],mT=["p","i","o","d","r","F","z","B","Y","V","g","D","x"],gT=["strip","input","output","directory","reject-file","fuzz","suffix","prefix","basename-prefix","version-control","get","reject-format","quoting-style","read-only","merge","debug"],ww=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"]]),yw=e=>b(`patch: ${e}
281
- patch: Try 'patch --help' for more information.`,2);function bw(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}: ${ww.get(o.slice(2))} is not supported`,2)}}let t;try{t=N(e,{short:pT,long:hT,valueShort:mT,valueLong:gT})}catch(r){let o=C(r);return o?{refused:v(o.kind,"patch",o.detail,`patch: ${r.message}`,2)}:{error:yw(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=ww.get(r);if(s)return{refused:v("option","patch",i,`patch: ${i}: ${s} is not supported`,2)};let a=wT(n,r,o);if(a)return{error:a}}return t.positional.length>2?{error:yw(`${t.positional[2]}: extra operand`)}:{opts:n,operands:t.positional}}function xw(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 wT(e,t,n){switch(t){case"p":case"strip":{let r=xw(n,"strip count");return r.error?r.error:(e.strip=r.value,null)}case"F":case"fuzz":{let r=xw(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 Ew(e,t,n){let r=bw(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=$(n.cwd,o.directory,n.fs);if(l.error||!n.fs.isDir(l.path))throw new ie(`Can't change to directory ${pe(o.directory,n)} : ${l.error??"Not a directory"}`);s.dir=l.path}let u=yT(s,e,o.input??i[1]??null);xT(s,ew(u),i[0]??null),o.output!==null&&o.output!=="-"&&ks(s,o.output,s.output,!1)}catch(u){if(!(u instanceof ie)){let f=C(u);if(!f)throw u;let c=`patch: ${u.message}`,d={stdout:s.stdout,stderr:s.stderr+c+`
282
- `,events:[...s.events,{fd:2,text:c+`
283
- `}],exitCode:2};return Z(d,f.kind,"patch",f.detail,c)}let l=`patch: **** ${u.message}
284
- `;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 yT(e,t,n){if(n===null)return j(e.ctx),t;if(n==="-")return j(e.ctx),t;let r=U(e.ctx,"patch",n);if(r.error||e.ctx.fs.isDir(r.path))throw new ie(`Can't open patch file ${pe(n,e.ctx)} : ${r.error??"Is a directory"}`);return e.ctx.fs.readFile(r.path)}function xT(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let o=tw(t,{needHeader:n===null,strip:r.strip,format:r.format});if(o===null){if(t.base===0&&!t.empty)throw new ie("Only garbage was found in the patch input.");return}e.skipRest=!1,e.skipRejectFile=!1,e.reverse=e.reverseFlag;let i=uw(e,o,n,s=>Es(e,s));i===null&&(i=bT(e,t,o)),e.skipRest&&(e.someFailed=!0),t.pos=o.start,kT(e,t,o,i),t.base=t.pos}}function bT(e,t,n){let{opts:r}=e;if(r.silent||(e.say(`can't find file to patch at input line ${n.hunkLine+1}
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}
285
269
  `),n.type!=="normal"&&e.say(r.strip===-1?`Perhaps you should have used the -p or --strip option?
286
270
  `:`Perhaps you used the wrong -p or --strip option?
287
271
  `)),t.base<n.start){e.say(`The text leading up to this was:
@@ -291,91 +275,91 @@ patch: Try 'patch --help' for more information.`,2);function bw(e){for(let r of
291
275
  `):(e.say(`File to patch:
292
276
  `),e.say(`Skip this patch? [y]
293
277
  `),r.silent||e.say(`Skipping patch.
294
- `)),e.skipRest=!0,null}function kT(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=Es(e,r),(a.isDir||a.link)&&(e.say(`File ${pe(r,e.ctx)} is not a regular file -- refusing to patch
295
- `),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!o.dryRun&&o.output===null&&(So(e,s),i&&r!==s&&So(e,r));let u=fw(dt(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}
296
- `)}let l=gw(n,o.rejectFormat??n.type),c=pw(e,n,()=>n.empty?null:nw(t,n.type),u,l);!e.skipRest&&!cw(u)&&(e.say(`misordered hunks! output would be garbled
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
297
281
  Skipping patch.
298
- `),e.skipRest=!0);let d=dw(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&&ET(e,n,{inname:r,outname:s,input:a,content:d,result:c,empty:u.out.length===0,renaming:i}),c.failed&&!e.skipRejectFile&&vT(e,s,c,l.text)}function ET(e,t,n){let{opts:r}=e,{inname:o,outname:i,input:s,content:a,result:u,empty:l,renaming:f}=n,c=r.backup||r.backupIfMismatch&&(u.mismatch||u.failed>0),d=t.says[e.reverse?0:1]===2;if(l&&(r.removeEmpty||d)){r.dryRun||kw(e,i,c);return}if(!l&&d&&(e.someFailed=!0,r.silent||e.say(`Not deleting file ${pe(i,e.ctx)} as content differs from patch
299
- `)),!r.dryRun){if(u.failed<u.count||f)ks(e,i,a,c),f&&o!==i&&(t.rename[0]||t.rename[1])&&kw(e,o,!1);else if(c){if(!s.exists)throw new ie(`Can't reopen file ${pe(i,e.ctx)} : No such file or directory`);ks(e,bs(e,i),s.content,!1)}}}function vT(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(`
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(`
300
284
  `);return}let i=o.rejectFile??t+".rej";if(o.dryRun){e.say(`
301
285
  `);return}e.say(` -- saving rejects to file ${pe(i,e.ctx)}
302
- `),So(e,i);let s=e.rejectsMade.has(H(e.dir,i));e.rejectsMade.add(H(e.dir,i));let a=s?Es(e,i).content:"";ks(e,i,a+r,!1)}var bs=(e,t)=>t+e.opts.suffix;function Es(e,t){let n=$(e.dir,t,e.ctx.fs,{follow:!1}),r=!n.error&&e.ctx.fs.isLink?.(n.path)===!0,o=$(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 So(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 ks(e,t,n,r){let{ctx:o}=e;So(e,t);let i=$(e.dir,t,o.fs);try{if(!i.error){o.fs.replaceWritable(e.dir,t,n,r?bs(e,t):void 0);return}r&&o.fs.openWritable(e.dir,bs(e,t)),o.fs.openWritable(e.dir,t).write(n)}catch(s){throw new ie(`Can't create file ${pe(t,e.ctx)} : ${s?.fsError??s.message}`)}}function kw(e,t,n){let{ctx:r}=e;So(e,t);let o=Es(e,t);o.exists&&(n&&r.fs.openWritable(e.dir,bs(e,t)).write(o.content),r.fs.removeWritable(e.dir,t))}var vw={du:Q0,stat:yg,realpath:d0,diff:Hg,patch:Ew};function $T(e,t,n){return N(t),M(n.cwd+`
303
- `)}function ST(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]??cr(n);if(o==="-"){if(!n.vars.has("OLDPWD"))return b("cd: OLDPWD not set");o=n.vars.get("OLDPWD")}let i=r[0]==="-"?o+`
304
- `:"";if(o==="")return M(i);let{path:s,error:a}=U(n,"cd",o);return a?b(`cd: ${o}: ${a}`):n.fs.isDir(s)?s!==H(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,M(i)):b(`cd: ${o}: Not a directory`)}var AT={dir:"/",link:"@",file:""};function NT(e,t,n){let{flags:r,positional:o}=N(t,{short:["1","l","a","A","R","d","r","F","h"]}),i=r.has("l")?$0(n,r.has("h")):null,s=(o.length?o:["."]).toSorted(G);r.has("r")&&s.reverse();let a=[],u=[],l=[],f=Wn(),c=r.has("a")||r.has("A"),d=y=>n.fs.isDir(y)?"dir":n.fs.isLink?.(y)?"link":"file",p=y=>r.has("F")?AT[y]:"",h=(y,E,S)=>({raw:y,abs:E,kind:S,name:S==="link"&&i?y:y+(y.endsWith("/")?"":p(S)),target:S==="link"?n.fs.readLink(E)+p(d($(n.cwd,E,n.fs).path??"")):null}),m=(y,E)=>i?i.lines(y,E):y.map(S=>S.name),g=!(r.has("l")||r.has("F")||r.has("d"));for(let y of s){let{path:E,error:S}=U(n,"ls",y,{follow:!1}),I=S||!g||!n.fs.isLink?.(E)?E:$(n.cwd,y,n.fs).path;S?u.push(`ls: cannot access '${y}': ${S}`):r.has("d")||n.fs.isFile(E)||!n.fs.isDir(I)?l.push(h(y,E,d(E))):a.push({path:y,abs:I})}let w=l.length?[m(l,!1).join(`
305
- `)]:[];for(let y of a){let E=[y];for(;E.length;){let{path:S,abs:I}=E.pop(),B=n.fs.listDir(I);c||f.collect(I,[...B.dirs,...B.files,...B.links]);let L=(q,ve)=>q.filter(Rn=>c||!Rn.startsWith(".")).map(Rn=>h(Rn,H(I,Rn),ve)),V=[...L(B.dirs,"dir"),...L(B.files,"file"),...L(B.links,"link")];r.has("a")&&V.push(h(".",I,"dir"),h("..",H(I,".."),"dir")),V.sort((q,ve)=>G(q.raw,ve.raw)),r.has("r")&&V.reverse();let Q=m(V,!0);if((s.length>1||r.has("R"))&&Q.unshift(S+":"),Q.length&&w.push(Q.join(`
306
- `)),!!r.has("R"))for(let q of V.toReversed())q.raw==="."||q.raw===".."||!n.fs.isDir(q.abs)||E.push({path:S.endsWith("/")?S+q.raw:S+"/"+q.raw,abs:q.abs})}}return f.emit(n.notes,"ls","Hidden entries are included with -a."),{stdout:w.length?w.join(`
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(`
307
291
 
308
292
  `)+`
309
293
  `:"",stderr:u.length?u.join(`
310
294
  `)+`
311
- `:"",exitCode:u.length?2:0}}function OT(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 M(TT(o,n[1])+`
312
- `)}function TT(e,t){return!t||t===e||!e.endsWith(t)?e:e.slice(0,-t.length)}function IT(e,t){let{positional:n}=N(t);return n.length===0?xe("dirname PATH"):M(n.map(r=>{let o=r.replace(/\/+$/u,""),i=o.lastIndexOf("/");return i<0?r.startsWith("/")?"/":".":o.slice(0,i).replace(/\/+$/u,"")||"/"}).join(`
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(`
313
297
  `)+`
314
- `)}var $w={pwd:$T,cd:ST,ls:NT,find:I0,tree:A0,basename:OT,dirname:IT,...vw};function Ow(e,t,n){let{flags:r,positional:o}=N(t,{short:["n","b","s","v","E","T","A","e","t"]}),i=a=>LT(a,r),s=CT(o,e,n,i,r.size!==0);if(s.bytes===void 0)return fe(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 Sw(e,t,n){let r=le("cat",e,t,n,{read:"maybe-text"});return{parts:r.inputs.map(o=>o.content??o.bytes),stderr:r.stderr,failed:r.failed}}var Aw=e=>e.every(t=>typeof t=="string")?{content:e.join("")}:{bytes:et([...e.map(t=>typeof t=="string"?T(t):t),new Uint8Array])};function CT(e,t,n,r,o){let i=n.outputFds[1];if(!i?.path&&!n.outputFds[2]?.path){let f=Sw(e,t,n);return{...Aw(f.parts),stderr:f.stderr,failed:f.failed}}let s=[],a="",u=t,l="";for(let f of e.length?e:["-"]){let c=f==="-",d=c||f==="/dev/stdin",p=d?n.stdinHandle?.path:$(n.cwd,f,n.fs).path,h=d?n.stdinHandle?.identity:n.fs.fileIdentity?.(p);if(l&&Nw(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(Nw(p,h,i)){if((c?_(n.stdinHandle.content).length-_(u).length:0)<i.position+_T(s,a,r)){l+=`cat: ${f}: input file is output file
315
- `;continue}let w=c?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=Sw([f],u,n);s.push(...m.parts),a+=m.parts.filter(g=>typeof g=="string").join(""),l+=m.stderr,(c||f==="/dev/stdin"&&!n.stdinFile)&&(u="")}return{...Aw(s),stderr:l,failed:l!==""}}var _T=(e,t,n)=>e.every(r=>typeof r=="string")?_(n(t)).length:e.reduce((r,o)=>r+(typeof o=="string"?_(o).length:o.length),0);function Nw(e,t,n){return!e||!n?.path?!1:t!==void 0&&n.identity!==void 0?t===n.identity:e===n.path}function LT(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")?FT(e):e,s=0;return dt(i).map(u=>{let l=u.endsWith(`
316
- `),f=l?u.slice(0,-1):u,c=(t.has("b")?f!=="":t.has("n"))?`${String(++s).padStart(6)} `:"";return o?f=[..._(f)].map(d=>Tw(d,r)).join(""):(r&&(f=f.replaceAll(" ","^I")),n&&l&&f.endsWith("\r")&&(f=f.slice(0,-1)+"^M")),c+f+(l?n?`$
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?`$
317
301
  `:`
318
- `:"")}).join("")}function Tw(e,t){return e===9?t?"^I":" ":e>=128?"M-"+Tw(e-128,!0):e<32?"^"+String.fromCodePoint(e+64):e===127?"^?":String.fromCodePoint(e)}function FT(e){return e.replace(/(^|\n)\n+/gu,`$1
319
- `)}var vs="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]",Il=1e6,$s=16*1024*1024,Iw=64*1024*1024;function Ue(e="script"){throw new x("feature",e,vs)}function Ss(e){return e.gap?v("feature","sed",e.gap,`sed: ${e.message}`):e instanceof RangeError?v("feature","sed","regex runtime limit",`sed: ${e.message}`):ne(e,"sed",`sed: ${e.message.replace(/^sed: /u,"")}`,e.exitCode)}function Cw(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 _w(e,t,n,r,o){if(e.files.length===0)return b("sed: no input files",4);let i=W(),s=new Set([...t,"s"]),a=!1;for(let u of e.files){let l=RT(u,n);if(l.error){if(P(i,n.flushOutput(l.error)),l.error.exitCode!==2)return As(i,l.error);a=!0;continue}let f=o({...e,files:[l.path]},s),{content:c,...d}=f;if(P(i,d),f.failed||C(f))return As(i,f);let p=MT(u,r),h;try{h=n.fs.replaceWritable(n.cwd,u,c,p)}catch(m){z(n,"sed",m?.path,m?.fsError);let g=ne(m,"sed",`sed: ${m.message}`,4);return P(i,g),As(i,g)}if(!h){let m=Cl(p??u);return P(i,m),As(i,m)}if(f.quit)break}return a&&(i.exitCode=2),i}function RT(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=U(t,"sed",e);if(n.error)return{error:b(xa("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=$(t.cwd,e,t.fs,{follow:!1}).path;return!t.writable||!r.startsWith("/tmp/")?{error:Cl(e)}:n}function MT(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 As(e,t){let n=C(t);return n?Z(e,n.kind,n.command,n.detail,n.message):e}function _l(e,t){let n=!1;return(r,o)=>{e((n?t:"")+r+(o??"")),n=o===""}}function Lw(e,t){let n=new Map,r=0,o,i,s,a=()=>e.io.setReads([o,i?.identity]);function u(f,c){if(c==="")return;l(c),a();let d=e.outputFds[f];if(d?.path){d.write(c);return}if(d==="closed"){let p=new Error("write error: Bad file descriptor");throw p.exitCode=4,p}s[f===1?"stdout":"stderr"]+=c,s.events.push({fd:f,text:c})}function l(f){if(r+=f.length,r>Iw)throw new x("feature","output limit","sed: output limit exceeded")}return{start(f){return s=W(),i=f,o=void 0,a(),s},record(f){o=f?.identity,a()},finish(){o=void 0,i=null,a()},stream:u,account:l,openWrite(f){if(n.has(f))return n.get(f);let c;if(f==="/dev/null")c=()=>{};else if(f==="/dev/stdout"||f==="/dev/stderr")c=p=>u(f==="/dev/stdout"?1:2,p);else{let p;try{p=e.writable&&e.fs.openWritable(e.cwd,f)}catch(h){throw z(e,"sed",h?.path,h?.fsError),h.exitCode=4,h}if(!p)throw new x("feature","output file",`sed: ${f}: Read-only file system`);c=h=>{l(h),a(),p.write(h)}}let d=_l(c,t);return n.set(f,d),d}}}function Ao(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 Fw(e,t,n,r,o,i){let s=e.length?e:["-"],a={stderr:"",failed:!1},u=0,l=0,f=t,c=null;function d(){for(;c===null||c.pos===c.content.length;){if(u===s.length)return!1;c=null;let h=s[u++];h==="-"?f=Ao(f,n):h==="/dev/stdin"&&n.stdinHandle&&(n.stdinOrigin=n.io.bufferReads(()=>n.fs.readIdentity(n.stdinHandle.identity)));let m=Ot("sed",[h],n,f);if(a.stderr+=m.stderr,a.failed||=m.failed,c=m.inputs.length?{...m.inputs[0],identity:DT(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;c?.shared&&j(n,f),o&&(l=0)}return!0}function p(){if(!d())return null;let h=c.pos,m=c.content.indexOf(r,h),g=m<0?"":r,w=c.content.slice(h,m<0?c.content.length:m);c.pos=m<0?c.content.length:m+r.length,c.shared&&(f=c.content.slice(c.pos),j(n,f));let y=c.first;c.first=!1;let E;return{text:w,terminator:g,line:++l,reset:y,identity:c.identity,last:()=>E??=c.pos<c.content.length?!1:o||!d()}}return{next:p,status:a,get identity(){return c?.identity}}}function DT(e,t){return e==="-"||e==="/dev/stdin"?t.stdinHandle?.identity:t.fs.fileIdentity?.($(t.cwd,e,t.fs).path??H(t.cwd,e))}var Ns={n:`
320
- `,t:" ",r:"\r",a:"\x07",f:"\f",v:"\v"};function No(e,t="substitute command"){let n=e.script[e.i++];if(n===void 0||n===`
321
- `)throw new Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw new Error("delimiter character is not a single-byte character");return n}function Os(e,t,n,r="substitute command"){let o="",i=!1;for(;e.i<e.script.length;){let s=e.script[e.i++];if(s===`
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===`
322
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===`
323
307
  `&&i)throw new Error(`unterminated ${r}`);if(a===`
324
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(`
325
- `))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 Rw(e){let t=No(e),n=Os(e,t,!0),r=Os(e,t,!1),o=zT(r),i=UT(e);if(n===""&&(i.ignoreCase||i.multiline))throw new Error("cannot specify modifiers on empty regexp");i.multiline&&Mw(i.multiline);let s=Fl(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 UT(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]===`
326
- `)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)||Ue("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,Ll(e));break}else if(n==="i"||n==="I")t.ignoreCase=!0;else if(n==="m"||n==="M")t.multiline=n;else if(n==="e")Mw(n);else throw new Error(`unknown option to substitute command: '${n}'`)}}return t}function Mw(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 Ll(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 Fl(e,t,n=!1,r=!1,o=ae){if(!e){if(r)throw new Error("cannot specify modifiers on empty regexp");return{re:null}}let i=ue(o);Uu(e,t,i.multibyte);let s=e.replace(/\\(.)/gu,(f,c)=>(c==="o"&&Ue("regex escape"),Object.hasOwn(Ns,c)?Ns[c]:f)),a=r?ao(s,i):s,u=t?{source:Ru(a,i)}:Hi(a,i);if(u.error)throw new Error(u.error);PT(u.source,t),Gi(u.source);for(let[,f]of u.source.matchAll(/\\(.)/gu))/[1-9]/u.test(f)&&Ue("regex backreferences");return{re:new Mt($n(u.source,"extent",i),!1,null,i),noSub:n,locale:o,ignoreCase:r,pattern:s}}function PT(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 zT(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(Ns,o)?t.push(Ns[o]):Ue("replacement escape")}return t}function Rl(e,t){if(/[\u0080-\u{10FFFF}]/u.test(e+t.re.src)){if(t.locale!==ae)throw new x("feature","locale",`matching non-ASCII text in the ${t.locale} locale is not supported`);t.ignoreCase&&pn.test(e+t.pattern)&&Ue("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 Dl(e,t,n){let r=t.parts.reduce((l,f)=>typeof f=="number"?Math.max(l,f):l,0),o=Ml(t,n,r);Rl(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,f)=>s?null:o.re.search(l,f)}:o.re;return{out:so(e,a,(l,f,c)=>{if(t.nth&&c<t.nth)return null;s++;let d=i?o.re.groups(e,l,f):null;return t.parts.map(p=>typeof p=="string"?p:p===0?e.slice(l,f):d?.[p]?.text??"").join("")},t.global||t.nth?"global":"first").out,count:s}}var Dw={a:7,f:12,n:10,r:13,t:9,v:11,"\n":10},Uw={d:10,o:8,x:16};function zw(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!==`
327
- `&&(e.textState.pending.raw=n)}Pl(e)}function Pl(e){let t=e.textState.pending;if(!t)return;let n=t.raw;for(;e.i<e.script.length&&e.script[e.i]!==`
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]!==`
328
312
  `;){let r=e.script[e.i++];if(r==="\\"){if(e.i===e.script.length){t.raw=n+`
329
- `;return}n+=r+e.script[e.i++]}else n+=r}t.command.text=BT(n+`
330
- `),e.textState.pending=null}function zl(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function BT(e){return X(Ul(e))}function Ul(e){let 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(Dw,i)){n.push(Dw[i]);continue}if(Object.hasOwn(Uw,i)){let s=Uw[i],a=s===16?2:3,u=0,l=0;for(;u<a&&r+1<t.length;){let f=t[r+1],c=f>=48&&f<=57?f-48:(f|32)>=97&&(f|32)<=102?(f|32)-87:-1;if(c<0||c>=s)break;l=l*s+c,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 Bw(e){let t=No(e,"'y' command"),n=Ul(Pw(e,t)),r=Ul(Pw(e,t)),o=e.byteLocale?n:[...X(n)],i=e.byteLocale?r:[...X(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 Pw(e,t){let n="";for(;e.i<e.script.length;){let r=e.script[e.i++];if(r===`
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===`
331
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===`
332
- `?o:r+o}throw new Error("unterminated 'y' command")}function jw(e,t){if(t.byteLocale)return X(_(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=ae,r=null){let o={script:e,i:0,extended:t,locale:n,byteLocale:oi(n),textState:r??{},openWrite:r?.openWrite},i=[];for(Pl(o);o.i<e.length;){if(/[;\n\r\f\v \t]/u.test(e[o.i])){o.i++;continue}e[o.i]==="#"&&Ue("comments");let s=Ww(o),a=null;if(s&&e[o.i]===","&&(o.i++,a=Ww(o,!0),a===null))throw new Error("missing second address");e[o.i]==="~"&&Ue("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 f=e[o.i++],c={kind:f,start:s,end:a,active:u,negated:l};if(f&&"pPnNdD=gGhHx".includes(f))i.push(c);else if(f==="w"){i.push({...c,...Ll(o)});continue}else if(f===":"||f==="b"||f==="t"||f==="T"){i.push({...c,label:jT(o,c)});continue}else if(f==="s")i.push({...c,...Rw(o)});else if(f==="a"||f==="i"||f==="c")zw(o,c),i.push(c);else if(f==="y")i.push({...c,...Bw(o)});else if(f==="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({...c,exitCode:p===-1n?0:Number(BigInt.asUintN(8,p))})}else if(f==="{"){o.textState.blockDepth=(o.textState.blockDepth??0)+1,i.push(c);continue}else if(f==="}"){if(!o.textState.blockDepth)throw new Error("unexpected '}'");if(s!==null)throw new Error("'}' doesn't want any addresses");o.textState.blockDepth--,i.push(c)}else{if(f===void 0)throw new Error("missing command");if("QlLFzrRWev".includes(f))Ue();else throw new Error(`unknown command: '${f}'`)}for(;/[ \t]/u.test(e[o.i]??"");)o.i++;if(e[o.i]==="#"&&Ue("comments"),o.i<e.length&&!/[;\n}]/u.test(e[o.i]))throw new Error("extra characters after command")}return r===null&&zl(o.textState),i}function jl(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 zl(t),WT(e),e}function jT(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 WT(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 Ww(e,t=!1){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;e.script[e.i]==="~"&&Ue("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)||Ue("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=No(e,"address regex"),i=Os(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"&&Ue("address regex flags"),s=!0,e.i++}r={type:"regex",...Fl(i,e.extended,!0,s,e.locale)}}for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;return r}function qw(e,t,n,r,o){let{start:i,end:s}=e;if(i===null)return!0;if(s===null)return Ts(i,t,n,r,o);if(!e.active){if(i.type==="line"){if(e.closed||n<i.value)return!1}else if(!Ts(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||Ts(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:Ts(s,t,n,r,o))&&(e.active=!1,e.closed=!0),!0)}function Ts(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 Rl(t,i),i.re.search(t)!==null}function Wl(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=Fw(e.files,e.stdin,n,i,a,p=>o.stream(2,p)),l=o.start(u),f=[],c=_l(r?p=>{o.account(p),f.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:c,input:u,output:o};try{let p=qT(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=Ss(p);P(l,h);let m=C(h);m&&Z(l,m.kind,m.command,m.detail,m.message),l.failed=!0}finally{o.finish()}return r&&(l.content=f.join("")),l}function qT(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=HT(e,o);if(!t.quiet&&!i&&t.emit(o.text,o.terminator),o.exitCode!==null&&t.emit(""),Hw(o),o.exitCode!==null)return o.exitCode;t.output.record(null)}return null}function HT(e,t){for(let n=0;n<e.length;n++){if(++t.budget.steps>Il)throw new x("feature","execution limit",`sed: execution limit reached after ${Il} commands (infinite loop?)`);let r=e[n];if(r.kind==="}"||r.kind===":")continue;if(qw(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(!ZT(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(GT(r,t),t.text.length>$s)throw new x("feature","pattern space limit","sed: pattern space limit exceeded")}}return!1}function GT(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))XT(n,t);else if(n==="y")t.text=jw(t.text,e);else{let r=Dl(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 XT(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>$s)throw new x("feature","hold space limit","sed: hold space limit exceeded")}function ZT(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;Hw(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>$s)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 Hw(e){if(e.append.length!==0){e.emit("");for(let t of e.append)e.emit(t??"");e.append.length=0}}function Gw(e,t,n){try{let{tokens:r,inPlace:o}=Cw(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":`
333
- `,a=Lw(n,s),u=YT(i,e,n,a.openWrite);return u===null?b(vs):u.error?u.error:(Object.assign(u,{output:a,delimiter:s,hold:{text:"",terminator:s},regexState:{last:null},budget:{steps:0}}),u.stdin=Ao(u.stdin,n),o===null?Wl(u,i.flags,n):_w(u,i.flags,n,o,(l,f)=>Wl(l,f,n,!0)))}catch(r){return Ss(r)}}function YT({order:e,positional:t},n,r,o){let i=[],s={openWrite:o},a=!1,u=!1;for(let{name:l,value:f}of e){if((l==="E"||l==="r"||l==="regexp-extended")&&(a=!0),!["e","expression","f","file"].includes(l))continue;u=!0;let c=f;if(l==="f"||l==="file"){n=Ao(n,r);let d=n,p=r.io.bufferReads(()=>Ot("sed",[f],r,d));if(p.failed)return{error:b(p.stderr,4)};c=p.inputs[0].content,p.inputs[0].shared&&(n="")}for(let d of Bl(c,a,r.locale,s))i.push(d)}return u?{commands:jl(i,s),files:t,stdin:n}:t.length===0?null:{commands:jl(Bl(t[0],a,r.locale,s),s),files:t.slice(1),stdin:n}}var VT=new Set(["-b","-c","-g","-k","-p","-r","-t","-u","-v","-w","-x","-G","-N","-O","-R","-S","-o"]),KT=new Set(["-nt","-ot","-ef","<",">"]),To={__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},JT=String(ge).length,QT=new Set(["/dev/stdin","/dev/stdout","/dev/stderr"]);function Yw(e,t,n){return Kw("test",t,n)}function Vw(e,t,n){return t.at(-1)!=="]"?b("[: missing `]'",2):Kw("[",t.slice(0,-1),n)}function Kw(e,t,n){try{return{...M(),exitCode:ql(t,n)?0:1}}catch(r){return ne(r,e,`${e}: ${r.message}`,2)}}function ql(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 Hl(n,r,t);throw VT.has(n)&&Oo(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(To,r))return To[r](Xw(n),Xw(o));KT.has(r)&&Oo(r),(r==="-a"||r==="-o")&&Oo("compound expressions")}if(e.length<=4){if(n==="!")return!ql(e.slice(1),t);if(n==="("&&e.at(-1)===")")return ql(e.slice(1,-1),t)}throw e.some(i=>["-a","-o","!","(",")"].includes(i))&&Oo("compound expressions"),new Error(e.length>3?"too many arguments":`${r}: binary operator expected`)}function Xw(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<=JT){let r=BigInt(t[1]+n);if(r>=St&&r<=ge)return r}}throw new Error(`${e}: integer expression expected`)}function Hl(e,t,n){let r={isDir:a=>a==="/dev"||a==="/dev/fd"||n.fs.isDir(a),isFile:a=>a==="/dev/null"||Zw(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}=$(n.cwd,t,r,{follow:!o});return s?!1:(Zw(i)&&Oo("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"&&eI(n,i)>0:i!=="/dev/null"&&n.fs.isFile(i))}var eI=(e,t)=>e.fs.fileSize?.(t)??T(e.fs.readFile(t)).length;function Zw(e){return QT.has(e)||/^\/dev\/fd\/\d+$/u.test(e)}function Oo(e){throw new x("feature",e,`${e} is not supported`)}function ey(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>=St&&n<=ge?n:null;return{arg:t,n:r}}var wr=e=>({...e,halt:!0});function tI(e,t,n){let r=t[0]==="--"?t.slice(1):t;if(r.length===0)return wr({...M(),exitCode:n.lastExit});let{arg:o,n:i}=ey(r[0]);return i===null?wr(b(`exit: ${o}: numeric argument required`,2)):r.length>1?wr(b("exit: too many arguments")):wr({...M(),exitCode:Number((i%256n+256n)%256n)})}function Jw(e){return(t,n,r)=>{let o=n[0]==="--"?n.slice(1):n;if(o.length>1)return wr(b(`${e}: too many arguments`));let{arg:i,n:s}=ey(o[0]??"1");return s===null?wr(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):{...M(),control:{type:e,levels:Number(s>BigInt(r.loopDepth)?BigInt(r.loopDepth):s)}}}}function nI(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(!gn.test(l)){i+=`export: \`${l}': not a valid identifier
334
- `;continue}a!==-1?n.vars.set(l,(u?U0(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 rI(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: ${ri}`);n.vars.delete(s)}return M()}function oI(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 Qw()}return r===null?Qw():(n.errexit=r,M())}var Qw=()=>v("feature","set","set","set: `set` is supported only as `set -e` or `set +e`",127),Gl={exit:tI,break:Jw("break"),continue:Jw("continue"),export:nI,set:oI,unset:rI},ty=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 ny(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=iI(i);i=s.text,s.stop&&(r=!1)}return M(r?i+`
335
- `:i)}function iI(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 _(i))n.push(s)},o=i=>({text:X(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),f=l<0?e.length:l;r(e.slice(i,f)),i=f-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 f=parseInt(l,16);if(s==="x")n.push(f);else{if(!ht(f))throw new x("feature","echo Unicode escape","echo: escapes outside Unicode scalar values are not supported");r(String.fromCodePoint(f))}continue}let u=i+He(e,i);r("\\"+e.slice(i,u)),i=u-1}return o(!1)}var ry={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92};function Xl(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(ry,o))return{bytes:[ry[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
336
- `,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(!ht(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:_(String.fromCodePoint(a)),end:i}}return i=t+1+He(e,t+1),{bytes:_(e.slice(t,i)),end:i}}function oy(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]==="\\"){let o=Xl(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 _(e.slice(r,i)))n.push(s);r=i}return Uint8Array.from(n)}var aI=/^%([-+ #0']*)(\d+|\*)?(?:\.(-?\d+|\*)?)?([hlLjzt]*)(.)?/su,uI=8e6;function iy(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:re(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(fI(r[0],o),o.index===s)break}while(!o.stop&&o.index<o.args.length);i=M()}catch(s){i=ne(s,"printf",`printf: ${s.message}`)}try{i.stdout=lI(o)}catch(s){let a=C(i);a&&n.unsupported.add(a,"printf");let u=ne(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 _n(e,t){if(e.size+t.length>uI)throw new x("feature","format size limit","formatted output exceeds the output limit");t.length&&e.chunks.push(t),e.size+=t.length}function lI(e){let t=new Uint8Array(e.size),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return X(t)}var Zl=e=>e.args[e.index++];function fI(e,t){for(let n=0;n<e.length&&!t.stop;)if(e[n]==="\\"){let r=Xl(e,n,!1,t);_n(t,r.bytes),n=r.end}else if(e[n]==="%"){if(e[n+1]==="%"){_n(t,[37]),n+=2;continue}let r=cI(e.slice(n),t);n+=r.length;let o=Zl(t);if("sbc".includes(r.conv))dI(o??"",r,t);else{let i="diouxX".includes(r.conv)?fs(ls(o,"ouxX".includes(r.conv),t),r):dg(o,r,t);_n(t,_(i))}}else{let r=n+1;for(;r<e.length&&e[r]!=="%"&&e[r]!=="\\";)r++;_n(t,_(e.slice(n,r))),n=r}}function cI(e,t){if(/^%[-+ #0'\d.*]*\$/u.test(e))throw new x("feature","positional format arguments","positional format arguments are not supported");let n=aI.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==="*"?ls(Zl(t),!1,t):o??0),precision:i==="*"?Number(ls(Zl(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>je||u.precision>je)throw new x("feature","format size limit","format width or precision exceeds the output limit");return u}function dI(e,t,n){let r=t.conv==="b"?oy(e,n):_(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||_n(n,i),_n(n,r),t.minus&&_n(n,i)}function pI(e,t){if(!e.includes(`
337
- `))return e;let n=re(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(_(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 sy(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?" "+pI(t,o):"")}var hI=["**=","**","++","--","+=","-=","*=","/=","%=","^=","==","!=","<=",">=","&&","||","!~",">>","|&","+","-","*","/","%","^","!",">","<","|","?",":","~","$","=","(",")","{","}","[","]",";",","],mI=new Set(["number","string","name","builtin"]),gI=new Set([")","]","++","--"]),wI=/^(?:0[xX][0-9a-fA-F]+|\d+\.?\d*(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/u,yI=e=>e!==void 0&&/[A-Za-z_]/u.test(e),xI=e=>e!==void 0&&/[A-Za-z0-9_]/u.test(e),ay=e=>e!==void 0&&e>="0"&&e<="9";function fy(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?mI.has(a.type)?!1:!(a.type==="punct"&&gI.has(a.value)):!0};for(;o<e.length;){let a=e[o];if(a===`
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===`
338
322
  `){n.at(-1)?.type!=="newline"&&i("newline",`
339
323
  `),r++,o++;continue}if(a===" "||a===" "||a==="\r"){o++;continue}if(a==="\\"&&(e[o+1]===`
340
324
  `||e[o+1]==="\r"&&e[o+2]===`
341
325
  `)){o+=e[o+1]===`
342
326
  `?2:3,r++;continue}if(a==="#"){for(;o<e.length&&e[o]!==`
343
- `;)o++;continue}if(a==='"'){let f=cy(e,o+1,t,r);i("string",f.value),o=f.end;continue}if(a==="/"&&s()){let f=EI(e,o+1,r);i("regex",f.value),o=f.end;continue}if(ay(a)||a==="."&&ay(e[o+1])){let f=bI(e,o);i("number",f.value),o=f.end;continue}if(yI(a)){let f=o+1;for(;xI(e[f]);)f++;let c=e.slice(o,f);if(e.slice(f,f+2)==="::")throw new A("namespaces are not supported",r,"namespaces");o=f,N1.has(c)?i("keyword",c==="func"?"function":c):O1.has(c)?i("builtin",c):i(e[f]==="("?"funcname":"name",c);continue}let u=o,l=hI.find(f=>e.startsWith(f,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 bI(e,t){let n=wI.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 uy={__proto__:null,n:`
344
- `,t:" ",r:"\r",a:"\x07",b:"\b",f:"\f",v:"\v",'"':'"',"\\":"\\"};function kI(e,t,n){let r=e[t+1];if(r===void 0)return{text:"\\",end:t+1};if(r in uy)return{text:uy[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 cy(e,t,n,r=null){let o=[],i=t;for(;i<e.length;){let s=e[i];if(r!==null){if(s==='"')return{value:X(Uint8Array.from(o)),end:i+1};if(s===`
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===`
345
329
  `)break;if(s==="\\"&&e[i+1]===`
346
- `){i+=2;continue}}if(s==="\\"){let a=kI(e,i,n);ly(o,a),i=a.end}else{let a=String.fromCodePoint(e.codePointAt(i));ly(o,{text:a}),i+=a.length}}if(r!==null)throw new A("unterminated string",r);return{value:X(Uint8Array.from(o)),end:i}}function EI(e,t,n){let r=t,o=!1;for(;r<e.length;){let i=e[r];if(i===`
347
- `)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 Io(e,t=null){return cy(e,0,t).value}function ly(e,t){if(t.byte===void 0)for(let n of _(t.text))e.push(n);else e.push(t.byte)}var vI=new Set(["=","+=","-=","*=","/=","%=","^=","**="]),dy=new Set(["<","<=","==","!=",">",">="]),_o=e=>e.type==="var"||e.type==="index"||e.type==="field";function py(e){let t=e.tok;return my(e)||t.type==="regex"||t.type==="keyword"&&t.value==="getline"||t.type==="punct"&&["!","-","+"].includes(t.value)}function yr(e,t){let n=[Pe(e,t)];for(;e.accept(",");)e.skipNewlines(),n.push(Pe(e,t));return n}function Pe(e,t){let n=$I(e,t),r=e.tok;if(r.type==="punct"&&vI.has(r.value)){_o(n)||e.fail(`cannot assign to ${n.type==="regex"?"a regex":"a non-variable"} (left side of \`${r.value}\`)`),e.next();let o=Pe(e,t);return{type:"assign",op:r.value==="**="?"^=":r.value,target:n,value:o}}return n}function $I(e,t){let n=Yl(e,t);if(!e.accept("?"))return n;e.skipNewlines();let r=Pe(e,t);return e.skipNewlines(),e.expect(":"),e.skipNewlines(),{type:"cond",test:n,consequent:r,alternate:Pe(e,t)}}var SI=[["or",["||"]],["and",["&&"]],["in",["in"]],["match",["~","!~"]],["compare",[...dy]],["concat",[]],["binary",["+","-"]],["binary",["*","/","%"]]],AI=new Map(SI.flatMap(([e,t],n)=>t.map(r=>[r,{type:e,precedence:n}]))),NI={type:"concat",precedence:5};function Yl(e,t,n=0){let r=Is(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: ${Ui}`,'"cmd" | getline');let s=my(e)?NI:i.type==="punct"||i.type==="keyword"&&i.value==="in"?AI.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:hy(e)};continue}let f=Yl(e,t,u+1);(l==="/"||l==="%")&&Co(f)===0&&Co(r)!==null&&e.fail(l==="/"?"division by zero attempted":"division by zero attempted in `%`",null,"error"),a==="compare"&&OI(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:f}:a==="match"?r={type:a,negate:l==="!~",left:r,right:f}:r={type:a,left:r,right:f}}}function hy(e){return e.tok.type!=="name"&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var OI=(e,t)=>e.tok.type==="punct"&&dy.has(e.tok.value)&&!(t.noGt&&e.tok.value===">");function my(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 gy(e,t){return Yl(e,t,5)}function Co(e){if(e.type==="num")return e.value;if(e.type==="neg"||e.type==="plus"){let r=Co(e.expr);return r===null?null:e.type==="neg"?-r:r}if(e.type!=="binary")return null;let t=Co(e.left),n=Co(e.right);return t===null||n===null?null:Pi(e.op,t,n)}var TI={__proto__:null,"!":"not","-":"neg","+":"plus"};function Is(e,t,n=!1){if(n&&(e.is("$")||e.is("++")||e.is("--")))return Cs(e,t);let r=e.tok.type==="punct"&&TI[e.tok.value];return r?(e.next(),{type:r,expr:Is(e,t,n)}):n?yy(e,t):II(e,t)}function II(e,t){let n=wy(e,t);return!e.is("^")&&!e.is("**")?n:(e.next(),{type:"binary",op:"^",left:n,right:Is(e,t)})}function wy(e,t){let n=Cs(e,t);for(;(e.is("++")||e.is("--"))&&_o(n);)n={type:"postinc",op:e.next().value,target:n};return n}function Cs(e,t){if(e.accept("$"))return{type:"field",index:Is(e,t,!0)};if(e.is("++")||e.is("--")){let n=e.next().value,r=Cs(e,t);return _o(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:"preinc",op:n,target:r}}return yy(e,t)}function yy(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:CI(e,n.value)};case"name":return _I(e);case"funcname":return LI(e);case"builtin":return RI(e);case"keyword":return n.value==="getline"?MI(e,t):e.unexpected();case"punct":return n.value==="("?FI(e):e.unexpected();default:return e.unexpected()}}function CI(e,t){try{return Ye(t,!1,n=>e.warn(n))}catch(n){return e.fail(n.message,n.gap??null)}}function Vl(e){if(!e.accept("["))return null;let t=yr(e,{});return e.expect("]"),e.is("[")&&e.fail("arrays of arrays are not supported","arrays of arrays"),t}function _I(e){let t=e.next().value,n=Vl(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 LI(e){return{type:"call",name:e.next().value,args:xy(e)}}function xy(e){e.expect("(");let t=e.is(")")?[]:yr(e,{});return e.expect(")"),t}function FI(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=yr(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:hy(e)}}function RI(e){let t=e.next().value;if(Di.has(t)&&e.fail(Di.get(t),`${t}()`),!e.is("(")){if(t==="length")return{type:"builtin",name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=xy(e),[r,o]=$u[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]&&!_o(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 MI(e,t){e.next();let n=null;(e.tok.type==="name"||e.is("$"))&&(n=Cs(e,t),_o(n)||e.fail("getline: target must be a variable, field or array element"));let r=null;return e.accept("<")&&(r=wy(e,t)),{type:"getline",target:n,file:r}}var DI=new Set(["/dev/stdout","/dev/stderr","/dev/null"]),Kl=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 ${Ln(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 ${Ln(this.tok)}`)}};function Ln(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 by={__proto__:null,BEGIN:"begin",END:"end",BEGINFILE:"beginFile",ENDFILE:"endFile"};function vy(e){let t=[],n=new Kl(fy(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"),UI(n,r),n.accept(";"),n.skipNewlines();return r}function UI(e,t){if(e.isKw("function")){PI(e,t);return}if(e.tok.type==="keyword"&&e.tok.value in by){let i=e.next().value;e.is("{")||e.fail(`${i} requires an action: ${i} { ... }`),t[by[i]].push(...Lo(e,i.toLowerCase()));return}if(e.is("{")){t.rules.push({pattern:null,action:Lo(e,"main")});return}let n=Pe(e,{}),r=n;e.accept(",")&&(e.skipNewlines(),r={type:"range",from:n,to:Pe(e,{})});let o=e.is("{")?Lo(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 PI(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 ${Ln(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 ${Ln(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:Lo(e,"function")})}function Lo(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(Jl(e)),e.skipTerminators();return e.next(),e.context=n,r}function Fo(e){if(e.is(";")||e.tok.type==="newline"){e.next();return}e.is("}")||e.tok.type==="eof"||e.unexpected()}var zI={__proto__:null,if:BI,while:jI,do:WI,for:qI,switch:HI,break:e=>xr(e,"break"),continue:e=>xr(e,"continue"),next:e=>xr(e,"next"),nextfile:e=>xr(e,"nextfile"),exit:e=>xr(e,"exit"),return:e=>xr(e,"return"),delete:XI,print:e=>Ey(e,"print"),printf:e=>Ey(e,"printf")};function Jl(e){if(e.is("{"))return{type:"block",body:Lo(e)};if(e.is(";"))return e.next(),{type:"empty"};let t=e.tok.type==="keyword"?zI[e.tok.value]:void 0;if(t)return t(e);let n=Pe(e,{});return Fo(e),{type:"expr",expr:n}}function br(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=Jl(e);return t&&e.loopDepth--,n}function _s(e){e.next(),e.expect("(");let t=Pe(e,{});return e.expect(")"),t}function BI(e){let t=_s(e),n=br(e,!1),r=e.i;return e.skipNewlines(),e.isKw("else")?(e.next(),{type:"if",test:t,consequent:n,alternate:br(e,!1)}):(e.i=r,{type:"if",test:t,consequent:n,alternate:null})}function jI(e){return{type:"while",test:_s(e),body:br(e,!0)}}function WI(e){e.next();let t=br(e,!0);e.skipTerminators(),e.isKw("while")||e.fail("`do` body must be followed by `while (...)`");let n=_s(e);return Fo(e),{type:"do",body:t,test:n}}function qI(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:br(e,!0)}}let t=e.is(";")?null:Pe(e,{});e.expect(";"),e.skipNewlines();let n=e.is(";")?null:Pe(e,{});e.expect(";"),e.skipNewlines();let r=e.is(")")?null:Pe(e,{});return e.expect(")"),{type:"for",init:t,test:n,step:r,body:br(e,!0)}}function HI(e){let t=_s(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=GI(e):e.accept("default","keyword")||e.fail(`expected \`case\` or \`default\` in switch body but found ${Ln(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(Jl(e)),e.skipTerminators();n.push({test:o,body:s})}return e.switchDepth--,e.next(),{type:"switch",expr:t,cases:n}}function GI(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:Ye(n.value,!1,r=>e.warn(r))}):e.fail(`case value must be a number, string or regex constant, found ${Ln(n)}`)}function xr(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=py(e)?Pe(e,{}):null),Fo(e),n}function XI(e){e.next(),e.tok.type!=="name"&&e.fail(`\`delete\` needs an array name but found ${Ln(e.tok)}`);let t=e.next().value,n=Vl(e);return Fo(e),{type:"delete",name:t,subs:n}}var ky=e=>e.is(";")||e.is("}")||e.is(">")||e.is(">>")||e.is("|")||e.is("|&")||e.tok.type==="newline"||e.tok.type==="eof";function Ey(e,t){e.next();let n=null;if(e.is("(")){let o=e.i;e.next();let i=e.is(")")?[]:yr(e,{});e.accept(")")&&ky(e)?n=i:e.i=o}n===null&&(n=ky(e)?[]:yr(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: ${Ui}`,`${t} | "cmd"`),(e.accept(">")||e.accept(">>"))&&(r=gy(e,{noGt:!0}),r.type==="str"&&!DI.has(r.value)&&e.fail(Ql(r.value),`${t} > FILE`)),Fo(e),{type:t,args:n,dest:r}}function Ql(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 K=class{constructor(t){this.s=t,this.number=void 0,this.numeric=void 0}},Ro="[ \\t\\n\\r\\f\\v]*",Ay="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",ZI=new RegExp(`^${Ro}${Ay}${Ro}$`,"u"),YI=new RegExp(`^${Ro}(${Ay})`,"u"),Ny=new RegExp(`^${Ro}([+-])(inf|nan)${Ro}$`,"iu"),ef=e=>ZI.test(e)||Ny.test(e);function $y(e){let t=YI.exec(e);if(t)return Number(t[1]);let n=Ny.exec(e);return n?n[2].toLowerCase()==="nan"?Number.NaN:n[1]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:0}var tf=()=>new A("attempt to use an array in a scalar context");function Y(e){if(typeof e=="number")return e;if(e===void 0)return 0;if(e instanceof K)return e.number??=$y(e.s);if(typeof e=="string")return $y(e);throw tf()}var Ls=new Map;function Oy(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=Ls.get(t);if(n===void 0){Ls.size>64&&Ls.clear(),n=us(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");Ls.set(t,n)}return n.map(r=>typeof r=="string"?r:In(e,r)).join("")}var Ty=e=>typeof e=="string"?e:e instanceof K?e.s:"%.6g",VI=e=>Ty(e.globals.get("CONVFMT")),KI=e=>Ty(e.globals.get("OFMT"));function D(e,t){if(typeof e=="string")return Ut(t,e);if(e instanceof K)return Ut(t,e.s);if(typeof e=="number")return Oy(e,VI(t));if(e===void 0)return"";throw tf()}function Ut(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 Fn(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 Iy(e,t){return typeof e=="number"?Oy(e,KI(t)):D(e,t)}var nf=e=>e.numeric??=ef(e.s),Sy=e=>typeof e=="number"||e===void 0||e instanceof K&&nf(e),st=e=>ze(e.globals.get("IGNORECASE"));function Fs(e,t,n){if(Sy(e)&&Sy(t)){let i=Y(e),s=Y(t);return i<s?-1:i>s?1:i===s?0:Number.NaN}let r=D(e,n),o=D(t,n);return st(n)&&(r=Fn(r),o=Fn(o)),G(r,o)}function ze(e){if(typeof e=="number")return e!==0&&!Number.isNaN(e);if(typeof e=="string")return e!=="";if(e instanceof K)return nf(e)?Y(e)!==0:e.s!=="";if(e===void 0)return!1;throw tf()}var rf=(e,t)=>Number.isSafeInteger(e)?String(e):D(e,t);function of(e){return e instanceof Map?"array":e===void 0?"untyped":typeof e=="number"?"number":e instanceof K&&nf(e)?"strnum":"string"}function Cy(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t==="")return JI(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=Tu(r,Ye(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 JI(e){let{text:t}=e,n=e.pos;for(;t[n]===`
348
- `;)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 uf(e,t,n,r){if(e==="")return[];if(t instanceof Mt)return Iu(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===`
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===`
349
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}
350
- ]`:t;return Iu(e,Ye(o,r))}function _y(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 QI(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 e6(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+=He(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 Ly(e,t){let n=st(e);return e.fieldMode==="FIELDWIDTHS"?QI(t,e.widths):e.fieldMode==="FPAT"?e6(t,Ye(D(e.globals.get("FPAT"),e),n,e.warn)):uf(t,D(e.globals.get("FS"),e),D(e.globals.get("RS"),e)==="",n)}var t6=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,af=e=>e!==void 0&&e.type==="exit",Rs=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=Cy(this.src,D(t.globals.get("RS"),t),st(t));if(n!==null)return t.globals.set("NR",Y(t.globals.get("NR"))+1),t.globals.set("FNR",Y(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(Y(t.globals.get("ARGC")));){if(++t.steps>io)throw new A("input operand scan exceeded execution limit",null,"execution limit");let n=D(t.globals.get("ARGV").get(String(this.idx++)),t);if(n==="")continue;t.globals.set("ARGIND",this.idx-1);let r=t6.exec(n);if(r){t.assign(r[1],new K(Io(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}=U(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="",j(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 af(o)?(this.exitSignal=o,this.src=null,!1):o!==void 0&&o.type==="nextfile"?(this.closeFile(t),!1):(Ut(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 af(o)&&(this.exitSignal=o),o}closeFile(t){this.src=null;let n=t.fileRule("end");af(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:Ut(t,i),pos:0},this.readers.set(n,r)}let o=Cy(r,D(t.globals.get("RS"),t),st(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 n6=(e,t)=>({isRef:!0,scope:e,name:t}),Mo=e=>typeof e=="object"&&e!==null&&e.isRef===!0,Do=class extends Error{constructor(t){super(t.type),this.signal=t}},My=e=>new A(`attempt to use array \`${e}\` in a scalar context`);function Ms(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function r6(e){let t=e;for(;Mo(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function kr(e,t){let n=Ms(e,t).get(t);return Mo(n)?r6(n):n}var o6=new Set(["FS","FIELDWIDTHS","FPAT"]);function Ds(e,t,n){let r=Ms(e,t);if(r.get(t)instanceof Map)throw My(t);if(r===e.globals){if(t==="NF"){s6(e,n);return}if(t==="FIELDWIDTHS"&&(e.widths=_y(D(n,e))),(t==="FPAT"||(t==="FS"||t==="RS")&&D(n,e).length>1)&&Ye(D(n,e),st(e),e.warn,e.tables),o6.has(t)){e.fieldMode=t;let o=e.globals.get("PROCINFO");o instanceof Map&&o.set("FS",t)}}r.set(t,n)}function Pt(e,t){let n=Ms(e,t),r=t,o=n,i=o.get(r);if(i instanceof Map)return i;let s=Mo(i);for(;Mo(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 Us(e,t,n=new K(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...Ly(e,t).map(r=>new K(r))],e.nf=e.fields.length-1,e.globals.set("NF",e.nf)}function Dy(e){let t=D(e.globals.get("OFS"),e);e.record=e.fields.slice(1).map(n=>D(n,e)).join(t),e.recordValue=e.record}function Uy(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function i6(e,t,n){if(t===0){let r=D(n,e);Us(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),Dy(e)}function s6(e,t){let n=Math.trunc(Y(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),Dy(e)}function Py(e,t){let n=Y(F(e,t));if(!(n>=0))throw new A(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function Uo(e,t){if(t.length===1)return rf(F(e,t[0]),e);let n=D(e.globals.get("SUBSEP"),e);return t.map(r=>rf(F(e,r),e)).join(n)}function lf(e,t){return t.type==="var"?t:t.type==="index"?{type:"index",arr:Pt(e,t.name),key:Uo(e,t.subs)}:{type:"field",i:Py(e,t.index)}}function zy(e,t){return t.type==="var"?By(kr(e,t.name),t.name):t.type==="index"?t.arr.get(t.key):Uy(e,t.i)}function ff(e,t,n){t.type==="var"?Ds(e,t.name,n):t.type==="index"?t.arr.set(t.key,n):i6(e,t.i,n)}function cf(e,t,n){ff(e,lf(e,t),n)}function Fy(e,t,n){if(n===0&&(e==="/"||e==="%"))throw new A(e==="/"?"division by zero attempted":"division by zero attempted in `%`");return Pi(e,t,n)}var a6={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function zt(e,t){let n=st(e);return t.type==="regex"?n?Ye(t.source,!0,null,e.tables):t.re:Ye(D(F(e,t),e),n,e.warn,e.tables)}function By(e,t){if(e instanceof Map)throw My(t);return e}function Ry(e,t,n){let r=lf(e,t.target),o=Y(zy(e,r)),i=t.op==="++"?o+1:o-1;return ff(e,r,i),n?o:i}function F(e,t){switch(t.type){case"num":case"str":return t.value;case"regex":return zt(e,t).test(e.record)?1:0;case"var":return By(kr(e,t.name),t.name);case"index":{let n=Pt(e,t.name),r=Uo(e,t.subs),o=n.get(r);return o===void 0&&n.set(r,void 0),o}case"field":return Uy(e,Py(e,t.index));case"assign":{let n=lf(e,t.target),r=F(e,t.value);if(r instanceof Map)throw new A("attempt to use an array in a scalar context");return t.op!=="="&&(r=Fy(t.op[0],Y(zy(e,n)),Y(r))),ff(e,n,r),r}case"cond":return F(e,ze(F(e,t.test))?t.consequent:t.alternate);case"or":return ze(F(e,t.left))||ze(F(e,t.right))?1:0;case"and":return ze(F(e,t.left))&&ze(F(e,t.right))?1:0;case"not":return ze(F(e,t.expr))?0:1;case"neg":return-Y(F(e,t.expr));case"plus":return Y(F(e,t.expr));case"binary":return Fy(t.op,Y(F(e,t.left)),Y(F(e,t.right)));case"concat":return D(F(e,t.left),e)+D(F(e,t.right),e);case"compare":return a6[t.op](Fs(F(e,t.left),F(e,t.right),e))?1:0;case"match":{let n=D(F(e,t.left),e);return zt(e,t.right).test(n)===t.negate?0:1}case"in":return Pt(e,t.array).has(Uo(e,t.keys))?1:0;case"preinc":return Ry(e,t,!1);case"postinc":return Ry(e,t,!0);case"call":return u6(e,t);case"builtin":return e.callBuiltin(e,t);case"getline":return f6(e,t);default:throw new A(`unknown expression: ${t.type}`)}}function u6(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>=Su)throw new A(`function call nesting deeper than ${Su} 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?l6(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 Do(i)}finally{e.frame=r,e.callDepth--}}function l6(e,t){if(t.type!=="var")return F(e,t);let n=Ms(e,t.name),r=n.get(t.name);return r instanceof Map||Mo(r)?r:r===void 0?n6(n,t.name):r}function f6(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,D(F(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?Us(e,n):cf(e,t.target,new K(n)),1}var vt=(e,t)=>Y(F(e,t)),df=2**32;function Wy(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var qy=()=>({seed:1,state:Wy(1)});function c6(e){e.rng.state=(e.rng.state+1831565813)%df;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+df:n)/df}function d6(e,t){let n=e.rng.seed,r=t.length>0?vt(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=Wy(r),n}function p6(e,t){let n=vt(e,t[0]);return n<0&&e.warn(`log: received negative argument ${D(n,e)}`),Math.log(n)}function h6(e,t){let n=vt(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${D(n,e)}`),Math.sqrt(n)}function m6(e,t){let n=vt(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${D(n,e)} is out of range`),r}function g6(e,t){let n=F(e,t[0]);if(typeof n=="number")return n;let r=n instanceof K?n.s:D(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):Y(new K(r))}function Po(e,t,n,r){let o=vt(e,n);if(o<0)throw new A(`${t}: argument ${r} negative value ${D(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 hf(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function pf(e,t){return(n,r)=>{if(r.length<2)throw new A(`${e}: called with less than two arguments`);let o=Po(n,e,r[0],1);for(let i=1;i<r.length;i++)o=t(o,Po(n,e,r[i],i+1));return hf(o)}}function jy(e,t){return(n,r)=>{let o=Po(n,e,r[0],1),i=Po(n,e,r[1],2)%64n;return hf(BigInt.asUintN(64,t?o<<i:o>>i))}}var Hy={__proto__:null,sin:(e,t)=>Math.sin(vt(e,t[0])),cos:(e,t)=>Math.cos(vt(e,t[0])),atan2:(e,t)=>Math.atan2(vt(e,t[0]),vt(e,t[1])),exp:m6,log:p6,sqrt:h6,int:(e,t)=>Math.trunc(vt(e,t[0])),rand:c6,srand:d6,systime:()=>Math.floor(Date.now()/1e3),strtonum:g6,and:pf("and",(e,t)=>e&t),or:pf("or",(e,t)=>e|t),xor:pf("xor",(e,t)=>e^t),lshift:jy("lshift",!0),rshift:jy("rshift",!1),compl:(e,t)=>hf(BigInt.asUintN(64,~Po(e,"compl",t[0],1)))};var Ps=new Map;function w6(e){let t=Ps.get(e);return t||(Ps.size>=256&&Ps.clear(),t=us(e),Ps.set(e,t)),t}function zs(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 w6(t)){if(typeof s=="string"){i+=s;continue}let a={...s};if(s.width==="*"){let u=Math.trunc(Y(o()));u<0?(a.minus=!0,a.width=-u):a.width=u}if(s.precision==="*"){let u=Math.trunc(Y(o()));a.precision=u<0?null:u}if(a.width>je||a.precision>je)throw new A(`printf: field width or precision above ${je} is not supported`,null,"format size limit");i+=y6(e,a,o())}return i}function y6(e,t,n){if(t.conv==="s"){let r=D(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join("")),sn("",r,t,!1)}return t.conv==="c"?sn("",Ut(e,x6(n)),t,!1):In(Y(n),t)}function x6(e){if(typeof e=="number"||e instanceof K&&ef(e.s)){let r=Math.trunc(Y(e));if(!ht(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 K?e.s:e??"";return n===""?"\0":String.fromCodePoint(n.codePointAt(0))}var Te=(e,t)=>D(F(e,t),e),Gy=(e,t)=>Y(F(e,t)),b6={type:"field",index:{type:"num",value:0}};function k6(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 Xy(e,t,n){let r=zt(e,t[0]),o=Te(e,t[1]),i=t[2]??b6,s=Te(e,i),{out:a,count:u}=so(s,r,(l,f)=>k6(o,s.slice(l,f)),n?"global":"first");return u>0&&cf(e,i,a),u}function E6(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 v6(e,t){let n=zt(e,t[0]),r=Te(e,t[1]),o=F(e,t[2]),i=D(o,e),s=i.startsWith("g")||i.startsWith("G"),a=0;s||(a=Math.trunc(Y(o)),a<1&&(e.warn(`gensub: third argument \`${i}' treated as 1`),a=1));let u=t[3]?Te(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return so(u,n,(f,c,d)=>!s&&d!==a?null:E6(r,l?n.groups(u,f,c):[{text:u.slice(f,c)}]),s?"global":"nth").out}function $6(e,t){let n=Te(e,t[0]),r=zt(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=Pt(e,t[2].name);if(s.clear(),o){let a=D(e.globals.get("SUBSEP"),e);r.groups(n,o.start,o.end).forEach((u,l)=>{u!==void 0&&(s.set(String(l),new K(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 S6(e,t){let n=Te(e,t[0]),r=Pt(e,t[1].name),o;t[2]===void 0?o=D(e.globals.get("FS"),e):t[2].type==="regex"?o=zt(e,t[2]):o=Te(e,t[2]);let i=uf(n,o,!1,st(e));return r.clear(),i.forEach((s,a)=>r.set(String(a+1),new K(s))),i.length}function A6(e,t){let n=[...Te(e,t[0])],r=Math.trunc(Gy(e,t[1])),o=Number.isNaN(r)?1:Math.max(r,1),i=n.length+1;if(t[2]){let s=Math.trunc(Gy(e,t[2]));if(!(s>=1))return"";i=Math.min(i,o+s)}return i>o?n.slice(o-1,i-1).join(""):""}function N6(e,t){if(t.length===0)return[...e.record].length;if(t[0].type==="var"){let n=kr(e,t[0].name);return n instanceof Map?n.size:[...D(n,e)].length}return[...Te(e,t[0])].length}function O6(e,t){let n=Te(e,t[0]),r=Te(e,t[1]);st(e)&&(n=Fn(n),r=Fn(r));let o=n.indexOf(r);return o<0?0:Array.from(n.slice(0,o)).length+1}function T6(e,t){let n=Te(e,t[0]);return n==="/dev/stdout"||n==="/dev/stderr"||n==="/dev/null"?0:e.input.close(e,n)}var I6=(e,t)=>t[0].type==="var"?of(kr(e,t[0].name)):of(F(e,t[0])),C6={__proto__:null,...Hy,length:N6,substr:A6,index:O6,split:S6,sub:(e,t)=>Xy(e,t,!1),gsub:(e,t)=>Xy(e,t,!0),gensub:v6,match:$6,sprintf:(e,t)=>zs(e,Te(e,t[0]),t.slice(1).map(n=>F(e,n))),tolower:(e,t)=>Fn(Te(e,t[0])),toupper:(e,t)=>Fn(Te(e,t[0]),!0),close:T6,fflush:()=>0,typeof:I6,isarray:(e,t)=>t[0].type==="var"&&kr(e,t[0].name)instanceof Map?1:0};function Zy(e,t){let n=C6[t.name];if(!n)throw new A(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var js={type:"break"},gf={type:"continue"},_6={type:"next"},L6={type:"nextfile"},F6={type:"exit"};function Yy(e,t,n,r){let o=new Map([["0","awk"]]);r.forEach((a,u)=>o.set(String(u+1),new K(a)));let i=new Map([["FS"," "],["OFS"," "],["ORS",`
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",`
351
335
  `],["RS",`
352
- `],["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 Bs("ENVIRON")],["PROCINFO",new Bs("PROCINFO",[["FS","FS"]])],["ARGC",r.length+1],["ARGV",o],["ARGIND",0]]),s={program:e,globals:i,frame:void 0,callDepth:0,record:"",recordValue:new K(""),fields:[void 0],nf:0,fieldMode:"FS",out:[],errOut:[],steps:0,exitCode:0,ranges:[],rng:qy(),input:new Rs(t,n),byteLocale:re(t),tables:ue(t.locale),hasFileRules:e.beginFile.length>0,callBuiltin:Zy,execStmts:Ws,assign:(a,u)=>Ds(s,a,u),warn:a=>s.errOut.push(`awk: warning: ${a}
353
- `),fileRule:a=>R6(s,a)};return s}var Bs=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 Vy(e){let{program:t}=e,n=mf(e,t.begin,"BEGIN"),r=t.rules.length>0||t.end.length>0||t.beginFile.length>0||t.endFile.length>0;return!Ky(n)&&r&&M6(e),mf(e,t.end,"END"),e.exitCode}var Ky=e=>e!==void 0&&e.type==="exit";function mf(e,t,n){let r=Jy(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 R6(e,t){let n=t==="begin"?e.program.beginFile:e.program.endFile;return n.length===0?void 0:mf(e,n,t==="begin"?"BEGINFILE":"ENDFILE")}function M6(e){for(;;){let t=e.input.next(e);if(t===null)return e.input.exitSignal;Us(e,t);let n=D6(e);if(Ky(n))return n;n!==void 0&&n.type==="nextfile"&&e.input.closeFile(e)}}function D6(e){let{rules:t}=e.program;for(let n=0;n<t.length;n++){let r=t[n];if(!U6(e,r,n))continue;if(r.action===null){wf(e,null,e.record+D(e.globals.get("ORS"),e));continue}let o=Jy(e,r.action);if(o!==void 0)return o}}function Jy(e,t){try{return Ws(e,t)}catch(n){if(!(n instanceof Do))throw n;return n.signal}}function U6(e,t,n){let{pattern:r}=t;if(r===null)return!0;if(r.type!=="range")return ze(F(e,r));if(!e.ranges[n]){if(!ze(F(e,r.from)))return!1;e.ranges[n]=!0}return ze(F(e,r.to))&&(e.ranges[n]=!1),!0}function Ws(e,t){for(let n of t){let r=zo(e,n);if(r!==void 0)return r}}function zo(e,t){if(++e.steps>io)throw new A(`execution stopped after ${io} statements (infinite loop?)`,null,"execution limit");switch(t.type){case"block":return Ws(e,t.body);case"empty":return;case"expr":F(e,t.expr);return;case"print":return j6(e,t);case"printf":return W6(e,t);case"if":return ze(F(e,t.test))?zo(e,t.consequent):t.alternate===null?void 0:zo(e,t.alternate);case"while":case"do":case"for":return P6(e,t);case"forin":return z6(e,t);case"switch":return B6(e,t);case"break":return js;case"continue":return gf;case"next":return _6;case"nextfile":return L6;case"exit":return q6(e,t);case"return":return{type:"return",value:t.value===null?void 0:F(e,t.value)};case"delete":{let n=Pt(e,t.name);t.subs===null?n.clear():n.delete(Uo(e,t.subs));return}default:throw new A(`unknown statement: ${t.type}`)}}function P6(e,t){t.init&&F(e,t.init);let n=!0;for(;t.type==="do"&&n||t.test===null||ze(F(e,t.test));){n=!1;let r=zo(e,t.body);if(r===js)return;if(r!==void 0&&r!==gf)return r;t.step&&F(e,t.step)}}function z6(e,t){let n=Pt(e,t.array);for(let r of Array.from(n.keys())){Ds(e,t.name,new K(r));let o=zo(e,t.body);if(o===js)return;if(o!==void 0&&o!==gf)return o}}function B6(e,t){let n=F(e,t.expr),r=i=>i.test.type==="regex"?zt(e,i.test).test(D(n,e)):Fs(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=Ws(e,t.cases[i].body);if(s===js)return;if(s!==void 0)return s}}function wf(e,t,n){if(t===null){e.out.push(n);return}let r=D(F(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(Ql(r),null,"output redirection")}function j6(e,t){let n=D(e.globals.get("ORS"),e),r;if(t.args.length===0)r=e.record;else{let o=D(e.globals.get("OFS"),e);r=t.args.map(i=>Iy(F(e,i),e)).join(o)}wf(e,t.dest,r+n)}function W6(e,t){let n=t.args.map(r=>F(e,r));wf(e,t.dest,zs(e,D(n[0],e),n.slice(1)))}function q6(e,t){if(t.value!==null){let n=Math.trunc(Y(F(e,t.value)));e.exitCode=(n%256+256)%256}return F6}var H6="awk [-F fs] [-v var=value] 'program' [file ...] | awk [-F fs] [-v var=value] -f progfile [file ...]",G6=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u;function Qy(e,t,n){let{values:r,positional:o}=N(Z6(t),{valueShort:["F"],repeatable:["v","f"],stopAtFirstPositional:!0}),i=Y6(r.get("f")??[],o,n);if(i.error)return i.error;let s;try{Ut({byteLocale:re(n)},i.text),s=vy(i.text)}catch(c){if(c instanceof RangeError)return v("feature","awk","parser depth limit",`awk: program too deeply nested (${c.message})`);if(C(c))return ne(c,"awk",`awk: ${c.message}`);if(!(c instanceof A))throw c;let d=c.line===null?`awk: ${c.message}`:`awk: ${c.kind} at line ${c.line}: ${c.message}`;return c.gap===null?b(d):v("feature","awk",c.gap,d)}let a=Yy(s,n,e,i.operands);for(let c of s.warnings)a.warn(c);let u,l=null;try{r.has("F")&&a.assign("FS",Io(r.get("F"),a.warn));for(let c of r.get("v")??[]){let d=G6.exec(c);if(!d)return b(`awk: -v: expected var=value but got \`${c}\``);a.assign(d[1],new K(Io(d[2],a.warn)))}u=Vy(a)}catch(c){let d=C(c);if(!(c instanceof A)&&!(c instanceof RangeError)&&!d)throw c;a.errOut.push(`awk: ${c.message}
354
- `),u=2,c instanceof RangeError&&(l={detail:"runtime limit",message:`awk: ${c.message}`}),c.gap&&(l={detail:c.gap,message:`awk: ${c.message}`}),d&&(l={detail:d.detail,message:`awk: ${c.message}`})}let f={stdout:a.out.join(""),stderr:a.errOut.join(""),exitCode:u};return l===null?f:Z(f,"feature","awk",l.detail,l.message)}var X6=/^-[Fvf]\S*\s/su;function Z6(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(X6.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 Y6(e,t,n){if(e.length===0)return t.length===0?{error:xe(H6,2)}:{text:t[0],operands:t.slice(1)};let r=[];for(let o of e){let{path:i,error:s}=U(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(`
355
- `),operands:t}}function tx(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&&_(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=n8(o.get("k")??[],u);if(l.error)return l.error;let f=le("sort",i,e,n,{stopOnError:!0});if(f.failed)return{stdout:"",stderr:f.stderr,exitCode:2};let c=r.has("z")?"\0":`
356
- `,d=f.inputs.flatMap(({content:g})=>we(g,c)),p=l.specs.length?l.specs:[{start:1,...u}],h=s8(d,p,a,r.has("u"),u.r),m=Ae(h,c);return s.length===0?fe(m,f):V6(s[0],m,n,f)}function V6(e,t,n,r){if(e==="/dev/null")return fe("",r);if(e==="/dev/stdout")return fe(t,r);n.io?.setReads([]);let o;try{o=n.writable&&n.fs.openWritable(n.cwd,e),o&&o.write(t)}catch(i){return z(n,"sort",i?.path,i?.fsError),ne(i,"sort",`sort: open failed: ${i.message}`,2)}return o?fe("",r):v("feature","sort","-o",`sort: open failed: ${e}: Read-only file system`,2)}var K6="nrfb",J6="bdfghiMnRrV",Q6=/^[ \t]*\+?(\d+)/u,e8=(e,t)=>b(`sort: ${e}: invalid count at start of '${t}'`,2),qs=(e,t)=>b(`sort: ${e}: invalid field specification '${t}'`,2);function t8(e){let t=0,n=null,r=a=>{let u=Q6.exec(e.slice(t));return u===null?(n=e8(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 f=t;for(;t<e.length&&/[a-zA-Z]/u.test(e[t]);)t++;return{field:u,offset:l,mods:e.slice(f,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:qs("field number is zero",e)}:i.offset===0?{error:qs("character offset is zero",e)}:t!==e.length?{error:qs("stray character in field spec",e)}:{from:i,to:s}}function n8(e,t){let n=[];for(let r of e){let o=t8(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(!K6.includes(l))return J6.includes(l)?{error:v("option","sort",`-k${r}`,`sort: unknown key option \`${l}\` in ${r}`,2)}:{error:qs("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 r8(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 o8(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 i8=e=>e.replace(/[a-z]/gu,t=>t.toUpperCase());function s8(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))?G:void 0),t[0].r&&e.reverse(),r?e.filter((l,f)=>f===0||l!==e[f-1]):e;let s=e.map(l=>{let f=i?[[0,l.length]]:r8(l,n);return{line:l,keys:t.map(c=>{let d=o8(l,c,f);return c.n?a8(d):c.f?i8(d):d})}}),a=(l,f)=>{for(let c=0;c<t.length;c++){let d=t[c],p=d.n?u8(l.keys[c],f.keys[c]):G(l.keys[c],f.keys[c]);if(p!==0)return d.r?-p:p}return r?0:(o?-1:1)*G(l.line,f.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 a8(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 ex=(e,t)=>e<t?-1:e>t?1:0;function u8(e,t){if(e.negative!==t.negative)return e.negative?-1:1;let n=e.integer.length-t.integer.length||ex(e.integer,t.integer)||ex(e.fraction,t.fraction);return e.negative?-n:n}async function rx(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")?_e(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(j(n),!r.has("0")&&e.includes("\0"))return v("feature","xargs","NUL input","xargs: NUL input requires -0");let f;if(r.has("0"))f=we(e,"\0");else if(u===void 0)f=l8(e);else{if(/["'\\]/u.test(e))return v("feature","xargs","-I input quoting","xargs: quoted or escaped replacement lines are not supported");f=we(e).map(h=>h.replace(/^[ \t\r\f\v]+/u,"")).filter(Boolean)}if(f.length===0&&(r.has("r")||u!==void 0))return M();let c=u===void 0?l.value??Math.max(1,f.length):1,d=W(),p=0;for(let h=0;h<Math.max(1,f.length);h+=c){let m=f[h],g=u===void 0?[...a,...f.slice(h,h+c)]:a.map(y=>y.replaceAll(u,m)),w=await n.dispatch(s,g,"",{devNull:!0});if(P(d,w),w.exitCode===255)return P(d,{...W(`xargs: ${s}: exited with status 255; aborting
357
- `),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 nx=e=>new Error(`unmatched ${e==="'"?"single":"double"} quote; by default quotes are special to xargs unless you use the -0 option`);function l8(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===`
358
- `)throw nx(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===`
359
- `?(r&&t.push(o),o="",r=!1):(o+=s,r=!0)}if(n)throw nx(n);return r&&t.push(o),t}function ox(e,t,n,r){let{values:o,positional:i,order:s}=N(c8(n),{short:["q","v"],valueShort:["c","n"]}),a=s.findLast(w=>w.name==="n"||w.name==="c")?.name??"n",u=Zc(o.get(a)??"10",e+": -"+a);if(u.error)return u.error;let l=s.findLast(w=>w.name==="q"||w.name==="v"),f=l?l.name==="v":null,c=e==="head",d=u.sign==="+";if(c&&u.value===0&&u.sign!=="-")return ix(e,t,i,r,()=>"",{unit:a,banner:f,leftover:w=>w,readOptions:{noRead:!0}});if(!c&&u.value===0&&!d){if(!r.stdinFile&&(!i.length||i.includes("-")||i.includes("/dev/stdin"))){let w=lx(e,t,"",a,"standard input");w&&r.notes.add(w)}return M()}let p=w=>c?[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 ux(w,p);let y=c?u.sign==="-":!d,E=c||y?u.value:Math.max(0,u.value-1),S=ax(w,E,y);return c?w.slice(0,S):w.slice(S)},m=c?f8(u,a,r):void 0;return ix(e,t,i,r,h,{unit:a,banner:f,leftover:m,readOptions:!c&&d?{stopOnDir:!0}:void 0})}function f8(e,t,n){return e.sign==="-"||t==="n"&&!n.stdinFile?()=>"":t==="c"?r=>ux(r,o=>[Math.min(e.value,o),o]):r=>r.slice(ax(r,e.value))}function ax(e,t,n=!1){if(n){if(t===0)return e.length;let o=e.length-Number(e.endsWith(`
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(`
360
344
  `));for(let i=0;i<t;i++)if(o<=0||(o=e.lastIndexOf(`
361
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(`
362
- `,r);r=i===-1?e.length:i+1}return r}function c8(e){return/^-\d+$/u.test(e[0]??"")?["-n",e[0].slice(1),...e.slice(1)]:e}function ux(e,t){let n=_(e),[r,o]=t(n.length);return r===0&&o>=n.length?e:X(n.subarray(r,o))}function ix(e,t,n,r,o,{unit:i,banner:s,leftover:a=()=>"",readOptions:u}){let l=le(e,n,t,r,u),f=s??n.length>1,c=l.entries.filter(m=>m.kind!=="missing"),d=[],p=[],h=null;for(let m=0;m<c.length;m++){let{name:g,kind:w,shared:y}=c[m],{content:E}=c[m];(y||g===null)&&(h!==null&&(E=h),h=a(E),j(r,h));let S=w==="dir"?"":o(E);if(w==="file"&&S!==E){let B=lx(e,E,S,i,qn(g,r));B&&p.push(B)}let I=g===null||g==="-"?"standard input":g;d.push(f?`${m>0?`
363
- `:""}==> ${I} <==
364
- ${S}`:S)}for(let m of p)r.notes.add(m);return fe(d.join(""),l)}function d8(e){let t=+(e.length>0&&!e.endsWith(`
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(`
365
349
  `));for(let n=e.indexOf(`
366
350
  `);n!==-1;n=e.indexOf(`
367
- `,n+1))t++;return t}function lx(e,t,n,r,o){let i=r==="c"?l=>_(l).length:d8,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 p8(e,t,n){let{flags:r,positional:o}=N(t,{short:["l","w","c","m"]}),i=m8(r),s=le("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:c,content:d,bytes:p,kind:h,shared:m}of s.entries.filter(g=>g.kind!=="missing")){let g=g8(p??d,n,i,a);u.push({counts:g,name:c,kind:h,shared:m}),l.l+=g.l,l.w+=g.w,l.m+=g.m,l.c+=g.c}let f=a?h8(u,n.stdinFile):1;return o.length>1&&u.push({counts:l,name:"total"}),fe(Ae(u.map(c=>sy(c.counts,c.name,i,f,n))),s)}function h8(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 m8(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 g8(e,t,n,r){let o=re(t),i=n.c||r||n.m&&o?w8(e):0;return{l:n.l?Fr(e):0,w:n.w?v8(e,t):0,m:n.m?o?i:y8(e):0,c:i}}var w8=e=>typeof e=="string"?_(e).length:e.length;function y8(e){if(typeof e=="string")return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of Ko(e))n>=0&&t++;return t}var x8=new Set([9,10,11,12,13,32]),b8=new Set([160,8199,8239,8288]),yf=1,xf=0,bf=2,k8=Uint8Array.from({length:128},(e,t)=>x8.has(t)?yf:t>32&&t<127?bf:xf),E8=(e,t)=>t.has("print",e)?t.has("space",e)||b8.has(e)?yf:bf:xf;function v8(e,t){let n=ue(t.locale),r=0,o=!1;for(let i of $8(e,t)){let s=i<0?xf:i<128?k8[i]:E8(i,n);s===yf?(o&&r++,o=!1):s===bf&&(o=!0)}return o?r+1:r}function*$8(e,t){if(typeof e!="string"){yield*re(t)?e:Ko(e);return}if(re(t)){yield*_(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 S8(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 A8(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=_e(o.get("f")??"0","uniq: -f");if(s.error)return s.error;let a=_e(o.get("s")??"0","uniq: -s");if(a.error)return a.error;let u=o.has("w")?_e(o.get("w"),"uniq: -w"):{value:void 0};if(u.error)return u.error;let l=r.has("D"),f=r.has("c");if(l&&f)return b("uniq: printing all duplicated lines and repeat counts is meaningless");let c=Xc("uniq",i.slice(0,1),e,n),d=r.has("d"),p=r.has("u"),h=r.has("i"),m=S=>{let I=s.value>0?S8(S,s.value):S;if(a.value===0&&u.value===void 0){let L=I.toWellFormed();return h?L.replace(/[A-Z]/gu,V=>V.toLowerCase()):L}let B=_(I).subarray(a.value,u.value===void 0?void 0:a.value+u.value);return(h?B.map(L=>L>=65&&L<=90?L+32:L):B).join(",")},g=we(c.content),w=[],y=0,E=g.length?m(g[0]):null;for(let S=1;S<=g.length;S++){let I=S===g.length?null:m(g[S]);if(S<g.length&&I===E)continue;let B=S-y,L=B>=2;(l?L:!(d&&p)&&(d?L:!p||!L))&&(l?w.push(...g.slice(y+(p?1:0),S)):w.push(f?String(B).padStart(7)+" "+g[y]:g[y])),y=S,E=I}return fe(Ae(w),c)}function sx(){return M()}function N8(){return{stdout:"",stderr:"",exitCode:1}}var kf={grep:Qi,head:(e,t,n)=>ox("head",e,t,n),tail:(e,t,n)=>ox("tail",e,t,n),wc:p8,sort:tx,uniq:A8,echo:ny,printf:iy,xargs:rx,awk:Qy},fx={true:sx,false:N8,":":sx};var mx={test:Yw,cat:Ow,...kf,...$w,...y0},cx=(e,t)=>(n,r,o)=>{let i=kf.grep(n,[t,...r],o),s=C(i);return s?Z(i,s.kind,e,s.detail,s.message):i},Ef={__proto__:null,sed:Gw,egrep:cx("egrep","-E"),fgrep:cx("fgrep","-F"),"[":Vw,...x0,...fx,...Gl,...mx},gx=new Set(["cd",":",...Object.keys(Gl)]),O8=e=>!!Ef[e],T8=new Set(["basename","cp","dirname","ln","mkdir","patch","rm","tee","touch"]),wx=Object.fromEntries(Object.entries(mx).filter(([e])=>!T8.has(e))),I8=["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"],dx=Object.keys(Ef).filter(e=>!gx.has(e)&&!Object.hasOwn(wx,e)).sort(),C8=new Set(["base32","brotli","egrep","fgrep","gunzip","gzcat","gzip","od","sed","sha1sum","sha256sum","sha384sum","sha512sum","shasum","tar","tee","xxd","zcat"]),px=L8(),_8=["grep","head","tail","wc","sort","uniq","cut","xargs","awk","tr","nl","tac","hexdump","cat","base64","diff","patch"];function L8(){let e=new Set(Object.keys(wx)),t=[];for(let n of I8)e.delete(n)&&t.push(n);return t.push(...[...e].sort()),t}var yx=Object.freeze(["/usr/local/bin/","/usr/bin/","/bin/","/sbin/"]);function xx(e,t){for(let n of yx)if(e.startsWith(n)){let r=e.slice(n.length);if(t(r))return r}return e}var F8=new Set(["test","[","true","false"]),R8=new Set(["grep","egrep","fgrep"]);function M8(e,t){let n=xx(e[0],t);return F8.has(n)?"status":R8.has(n)?Nm(e.slice(1))?"status":"search":"work"}function Hs(e,t=!1){let n=wu(t),r=n===null?[]:gu,o=Bd(e,u=>O8(u)||r.includes(u)),i=Object.freeze({__proto__:null,...Ef,...n,...o.handlers}),s=u=>!!i[u],a=Object.freeze([...px,...r,...dx,...o.names]);return Object.freeze({commands:i,names:a,pipeNames:Object.freeze([..._8,...r,...dx.filter(u=>C8.has(u)),...o.pipeNames]),binPrefixes:yx,has:s,shellOnly:u=>gx.has(u),resolveCommand:u=>xx(u,s),chainRole:u=>M8(u,s),known:[...px,...r,...o.names].join(", ")})}var D8=Hs(),hx=null,bx=e=>e?(hx??=Hs(void 0,!0),hx):D8;function kx(e,t){let n=ty.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 vx(e,t,n){let r=B8(e);if(!r)return[];let{start:o,pipe:i,quote:s,words:a}=r;for(;U8.has(a[0]);)a.shift();if(P8.has(a[0]))return[];if(a[0]==="for"&&a.length<=2)return[];let u=e.slice(o),l=Ex(u,s);if(!l)return[];let f=a.length===0,c=f?"":n.resolveCommand(Ex(a[0],null)?.value??""),d=f?z8(l.value,i,n,t.functions):i?[]:W8(l,t,c==="cd"),p=e.slice(0,o),h=i&&u===""&&p.endsWith("|")?" ":"";return d.map(m=>p+h+u+j8(m.slice(l.value.length),s))}var U8=new Set(["!","{","do","then","else","elif","if","while","until"]),P8=new Set(["done","fi","}","esac"]);function z8(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 B8(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]!==`
368
- `&&(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 c=e.indexOf(`
369
- `,a);if(c===-1)return null;a=c-1;continue}if(u===" "||u===" "){o&&s.push(e.slice(t,a)),t=a+1,o=!1;continue}let l=u==="|"&&e[a+1]==="|",f=u==="&"&&e[a+1]==="&";if(u==="|"||f||u===";"||u===`
370
- `||u==="("||u===")"&&i===a-1){(l||f)&&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 Ex(e,t){if(e==="")return{value:"",mask:null};try{let n=ai(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 j8(e,t){return t==="'"?e.replaceAll("'","'\\''")+"'":t==='"'?e.replace(/[\\$`"]/gu,"\\$&")+'"':e.replace(/[\s\\'"`$&|;()<>*?[\]{}!#~]/gu,n=>n===`
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===`
371
355
  `?`'
372
- '`:"\\"+n)}function W8(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($(t.cwd,cr(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?cr(t)+s.slice(1):s||".",l=$(t.cwd,u,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:f,files:c,links:d}=t.fs.listDir(l),p=f.map(h=>h+"/");for(let h of d)t.fs.isDir($(l,h,t.fs).path)?p.push(h+"/"):n||p.push(h);return n||p.push(...c),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 $x(e,t,n,r=!1){let o=(t.substitutionDepth??0)+1;if(o>Hn)throw new x("feature","command substitution nesting limit",`command substitution nesting beyond ${Hn} levels is not supported`);let i=t.expansionFds[2],a=await Ee(t,{substitutionDepth:o,outputFds:{1:"out",2:typeof i=="object"||i==="closed"?i:"err"},errexitOff:!0,closed:{out:!1,err:i==="closed"}},()=>on(t,()=>{let c;try{c=Dd(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=c.length===1&&!c[0].negate&&c[0].stages.length===1?c[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(c,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 c=u.length;u=u.replaceAll("\0","");let d=c-u.length;t.notes.add(`command substitution: discarded ${d} NUL ${d===1?"byte":"bytes"}.`),l+=`warning: command substitution: ignored null byte in input
373
- `}es(t,l);let f=u.length;for(;f>0&&u[f-1]===`
374
- `;)f--;return u.slice(0,f)}async function Sx(e,t){return{stdout:"",stderr:"",exitCode:await Er(e,t)?0:1}}var vf=async(e,t)=>(await yl(e,t)).value;async function Er(e,t){let{kind:n}=e;if(n==="not")return!await Er(e.expression,t);if(n==="and")return await Er(e.left,t)&&await Er(e.right,t);if(n==="or")return await Er(e.left,t)||await Er(e.right,t);let{op:r}=e;if(n==="unary"){let a=await vf(e.word,t);if(r==="-n")return a!=="";if(r==="-z")return a==="";if(["-a","-e","-f","-d"].includes(r))return Hl(r,a,t);if(r==="-v")return q8(a,t);Bo(r)}["<",">","-nt","-ot","-ef"].includes(r)&&Bo(r);let o=await vf(e.left,t);if(Object.hasOwn(To,r)){let a=await vf(e.right,t);return To[r](On(o,t),On(a,t))}let i=await yl(e.right,t);uo(i)&&Bo("extglob");let s=Ve(ar(i),{bash:!0}).test(o);return r==="!="?!s:s}function q8(e,t){return e.includes("[")&&Bo("-v array subscript"),/^[ \t\n\r\f\v]*[+-]?0+[ \t]*$/u.test(e)&&Bo("-v positional parameter"),/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?rn(e,t).set:!1}function Bo(e){throw new x("feature",`[[ ${e}`,`${e} in [[ is not supported`)}function Nx(e,t,n,r){return e.define?(t.functions.set(e.define.name,e.define.body),W()):e.test?Sx(e.test,t):e.group?Y8(e,t,n,r):e.loop?e.loop.words?X8(e.loop,t,r):H8(e.loop,t,r):Z8(e.conditional,t,n,r)}var Ox=1e4,Ax={kind:"feature",command:null,detail:"loop limit",message:`a loop running more than ${Ox} times is not supported`};async function H8(e,t,n){let r=W(),o={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let i=0;;i++){if(i===Ox){t.unsupported.add(Ax),P(r,b(`error: ${Ax.message}`,1));break}let s=r.ignored,a=r.exitCode,u=await n(e.condition,t,o,!0);if(P(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(P(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 G8={value:"for",mask:null};async function X8(e,t,n){let r=await wo([G8,...e.words],t),o=W(),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(P(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 Z8(e,t,n,r){let o=W(),i={text:n,bytes:t.stdinBytes};for(let a of e.branches){let u=await r(a.condition,t,i,!0);if(P(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 P(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 P(o,s),{...o,halt:s.halt,control:s.control,blame:s.blame}}async function Y8(e,t,n,r){let o={text:n,bytes:t.stdinBytes};return e.isolate?{...await on(t,()=>r(e.group,t,o)),halt:!1,control:void 0,ignored:!1}:r(e.group,t,o)}var V8=new Set(["sort","cat"]),K8=new Set(["wc","tac"]);function $f(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&&(V8.has(s.name)||K8.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=Z(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 ur(i))l.text!==""&&(n.fd=l.fd,o(s.fds[l.fd]?.identity));return a((l,f)=>{n.fd=l.fd,Xu(l,f)})}finally{n=u}}}}function Af(e,t){let n={1:t.outputFds[1]?.path?t.outputFds[1]:"out",2:t.outputFds[2]?.path?t.outputFds[2]:"err"},r={1:Tx(t.outputFds[1]),2:Tx(t.outputFds[2])};return lr(e,{fds:n,deferred:r},t)}var Tx=e=>e!=="out"&&e!=="err"&&!e?.path;async function jo(e,t,n,r=!1){if(e.some(a=>a.background))throw new x("feature","&","background processes (`&`) are not supported");let o=W(),i=null,s=null;for(let[a,u]of e.entries()){if(u.warnings&&P(o,lr({...W(u.warnings),exitCode:o.exitCode,ignored:o.ignored},{fds:t.outputFds},t)),u.gate==="and"&&o.exitCode!==0){(s??=qc()).skip(r?null:i,o.exitCode);continue}if(u.gate==="or"&&o.exitCode===0)continue;s?.flush(t.notes);let l=r||u.negate||J8(e,a),f=await(l?Ee(t,{errexitOff:!0},()=>Ix(u.stages,t,n)):Ix(u.stages,t,n));if(P(o,f),u.negate&&!f.halt&&(o.exitCode=f.exitCode===0?1:0),l&&(o.ignored=!0),i=u.negate?null:f.blame,t.lastExit=o.exitCode,f.halt||f.control){Object.assign(o,{halt:f.halt,control:f.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 J8=(e,t)=>["and","or"].includes(e[t+1]?.gate);async function Ix(e,t,n){let r=W(),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?Q8():null,f={...t.outputFds};l&&(f[1]=l);let c=i,d=o,p=()=>eC(a,t,{stdin:d,stdinBytes:c,stdinFile:u&&t.stdinFile,fds:f,stdinPiped:u?t.stdinPiped:!0,stdinTerminal:u&&t.stdinTerminal}),h=e.length>1?{...await on(t,p),ignored:!1}:await p();u&&(n.text=h.inputLeft,n.bytes=h.bytesLeft??null),P(r,h);let m=l?.carried()??{text:""};i=m.bytes??null,o=m.text??$e(m.bytes)??"",r.blame=h.blame,e.length===1&&(r.halt=h.halt,r.control=h.control)}return r}function Q8(){let e="",t=null;return{write(n){t===null?e+=n:n!==""&&t.push(T(n))},writeBytes(n){t===null&&(t=e===""?[]:[T(e)],e=""),t.push(n)},carried:()=>t===null?{text:e}:{bytes:et([...t,new Uint8Array])}}}function eC(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 Ee(t,{substitutionExit:null,expansionOutput:W(),expansionFds:i},()=>Sf(u,t,async()=>{let l=!e.group&&!e.loop&&!e.conditional&&!e.test&&!e.define,f,c;try{l&&(f=await wo(e.words,t),f.argv.length===0?await sC(e.assigns,t):f.temps=await aC(e.assigns,t))}catch(y){c=Gs(t,y)}if(c)return P(t.expansionOutput,Cx(c,u,t)),{...t.expansionOutput,inputLeft:t.stdinLeft,bytesLeft:t.stdinBytes,halt:c.halt};let d=await tC(e,t,t.stdinLeft,o,i);t.expansionFds=d.fds;let p=!1,h=null,m=await Sf(d,t,()=>nC(t,async()=>{if(d.error)return d.error;if(!l){let I=await Nx(e,t,d.stdin,jo);return p=!0,h=I.blame??null,I}let y=f.argv.length>0?f.argv[0]:null,E=y===null?void 0:t.functions.get(y);if(E){if(p=!0,t.calling.has(y)){let I=v("feature",y,"function recursion",`${y}: a function calling itself is not supported`);return t.unsupported.add(C(I)),I}t.calling.add(y);try{return await Ee(t,{loopDepth:0},async()=>({...await _x(f.temps,t,()=>jo(E,t,{text:d.stdin,bytes:d.stdinBytes})),ignored:!1}))}finally{t.calling.delete(y)}}let S=await iC(t,f);return f.argv.length&&(h=Wc(t.registry.chainRole(f.argv),f.argv[0])),S})),g=d.inherited?t.stdinLeft:d.parentLeft,w=d.inherited?t.stdinBytes:d.parentBytes;return P(t.expansionOutput,p?m:Cx(m,d,t)),{...t.expansionOutput,inputLeft:g,bytesLeft:w,halt:m.halt,control:m.control,blame:h}}))}function Cx(e,t,n){try{return lr(e,t,n)}catch(r){return lr(Gs(n,r),t,n)}}async function tC(e,t,n,r,o){let i={...o},s=n,a=r,u=a?t.stdinOrigin:null,l=a?t.stdinHandle:null,f=!0,c=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:f,parentLeft:c,parentBytes:m}),w=async y=>{let E=await Ee(t,{expansionFds:i},()=>Sf({fds:i,stdin:s,stdinBytes:h,stdinFile:a,stdinOrigin:u,stdinHandle:l},t,y));return s=t.stdinLeft,h=t.stdinBytes,f&&(c=s,m=h),E};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 E=y.target===void 0?await w(()=>wl(y.word,t)):{value:y.target};if(E.error)return g(b(`error: ${E.error}`));let S=E.value==="/dev/null"?"null":E.value==="/dev/stdout"?i[1]:E.value==="/dev/stderr"?i[2]:t.writable?t.fs.openWritable(t.cwd,E.value,y.append):null;if(S===null){let I=Ra(y.label,E.value,t.writable);return t.unsupported.add(C(I)),g(b(`error: ${I.message}`))}if(S==="closed")return g(b(`error: ${E.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(()=>Tn(rC(y.body),t)):y.body,a=!1,f=!1,h=null,p=!1;else if(y.op==="herestring")s=await w(()=>Tn(y.word,t))+`
375
- `,a=!1,f=!1,h=null,p=!1;else{let E=await w(()=>wl(y.word,t)),S=E.error?{error:b(`error: ${E.error}`)}:oC(E.value,t,a?u:s);if(S.error)return g(S.error);s=S.content,E.value!=="/dev/stdin"&&(h=S.bytes??null),(E.value!=="/dev/stdin"||a)&&(f=!1),E.value!=="/dev/stdin"&&(a=E.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(f||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(Gs(t,y))}return g()}function Gs(e,t){z(e,"shell",t?.path,t?.fsError);let n=C(t);return n&&e.unsupported.add(n),{...b(`error: ${ee(t)}`,1),...t?.halt?{halt:!0}:{}}}async function nC(e,t){try{return await t()}catch(n){return Gs(e,n)}}function Sf(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,Ee(t,r,n)}function rC(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=Tt(e,r);t+=s.raw,n+="2"+"1".repeat(s.raw.length-1),r+=s.raw.length-1;continue}if(o==="$"){let s=Ct(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 oC(e,t,n){if(e==="/dev/null")return{content:""};if(e==="/dev/stdin")return{content:n};let{path:r,error:o}=U(t,"shell",e);if(o)return{error:b(`error: ${e}: ${o}`)};if(t.fs.isFile(r)){let{text:i,bytes:s}=pt(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 iC(e,t){let{argv:n}=t;return n.length===0?{stdout:"",stderr:"",exitCode:e.substitutionExit??0}:_x(t.temps,e,()=>e.invoke(n[0],n.slice(1),e.stdinLeft))}async function sC(e,t){for(let n of e)t.vars.set(n.name,await Tn(n.word,t,!0))}async function aC(e,t){if(e.length===0)return null;let n=t.vars,r=new Et(n),o=new Set(e.map(i=>i.name));r.bound=new Set;try{await Ee(t,{vars:r},async()=>{for(let i of e){r.expansionTargets=o;let s=await Tn(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 _x(e,t,n){if(!e)return n();let r=t.vars,o=new Et(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 Fx(e,t={}){let{fs:n,cwd:r,home:o,mount:i,writable:s,locale:a}=Qc(e,t),u=Ph(t),l=t.commands===void 0?bx(u):Hs(t.commands,u),f={fs:n,io:$f(n),mount:i,writable:s,registry:l,createdAt:Date.now(),lock:{turn:Promise.resolve()}};return Dx(Mx(f,{cwd:r,home:o,user:t.user??"user",locale:a,...Rx()}),"createTerminal")}var Rx=()=>({vars:new Et,functions:new Map,lastExit:0,errexit:!1}),uC=e=>({vars:new Et(e.vars),functions:new Map(e.functions),lastExit:e.lastExit,errexit:e.errexit});function lC(e,t={}){let{cwd:n,home:r,user:o,locale:i,inherit:s}=ed(e,t),a=s?uC(e):Rx();return Dx(Mx(e,{cwd:n,home:r,user:o,locale:i,...a}),"fork")}function Mx({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:aa(),notes:new Set};return u.dispatch=(l,f,c,{devNull:d=!1}={})=>Ee(u,{stdinLeft:u.stdinLeft,stdinBytes:u.stdinBytes,stdinFile:!1,stdinPiped:!1,stdinTerminal:u.stdinTerminal&&!d,stdinOrigin:null,stdinHandle:null},()=>on(u,()=>Lx(l,f,c,u,!0))),u.flushOutput=l=>Af(l,u),u.hasCommand=l=>o.has(l)&&!o.shellOnly(l),u.invoke=(l,f,c)=>Lx(l,f,c,u),u.substitute=(l,f)=>$x(l,u,jo,f),u.runLine=l=>Ux(l,u),u}function Dx(e,t){if(!e.fs.isDir(e.cwd))throw new Error(`${t}: cwd is not a directory: ${e.cwd}`);return{run:n=>cC(e,n),cwd:()=>e.cwd,complete:n=>vx(n,e,e.registry),fork:n=>lC(e,n)}}async function Lx(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):kx(e,i)},u=l=>Af(fC(r,Zu(e,l,r),s),r);try{return await r.io.run(s,async()=>u(await a()))}catch(l){z(r,e,l?.path,l?.fsError);let f=`${e}: ${ee(l)}`,c=C(l);return c&&r.unsupported.add({...c,command:c.command??e,message:f},c.command??s),u(b(f))}}function fC(e,t,n){let r=C(t);return r&&e.unsupported.add(r,n),t}function cC(e,t){let{lock:n}=e,r=n.turn.then(()=>Ux(t,e));return n.turn=r.then(()=>null,()=>null),r}function Ux(e,t){let n=aa();return Ee(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 Ud(e,t.writable,t.registry.has)){let s=await jo(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}
376
- `,r.exitCode=t.lastExit}return dC(r,t,n)})}var dC=(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,...ya(t.discarded,e.stderr,t.notes)])});var pC={unified:[[/^--- /u,"bold"],[/^\+\+\+ /u,"bold"],[pr,"cyan"],[/^\+/u,"green"],[/^-/u,"red"],[/^\\ /u,"gray"]],context:[[Cn,"cyan"],[/^\*{3} \d/u,"cyan"],[/^--- \d/u,"cyan"],[/^\*{3} /u,"bold"],[/^--- /u,"bold"],[/^! /u,"yellow"],[/^\+ /u,"green"],[/^- /u,"red"]],normal:[[hr,"cyan"],[/^< /u,"red"],[/^> /u,"green"],[/^---$/u,"gray"]]};function hC(e){return e.some(t=>Cn.test(t))?"context":e.some(t=>pr.test(t))?"unified":e.some(t=>hr.test(t))?"normal":null}function Px(e){let t=e.split(`
377
- `),n=pC[hC(t)];return n===void 0?null:t.map(r=>n.find(([o])=>o.test(r))?.[1]??null)}var mC={bold:"head",cyan:"hunk",green:"add",red:"del",yellow:"chg",gray:"meta"};function zx(e){let t=Px(e);return t===null?null:e.split(`
378
- `).map((n,r)=>({text:n,kind:t[r]===null?"":mC[t[r]]??""}))}function Bx({stdout:e,stderr:t,unsupported:n}){return n.filter(r=>!t.includes(r.message)&&!e.includes(r.message)).map(r=>r.message)}var jx=`: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}}
379
- `;var Of="/sources",wC={mount:Of,home:"/",writable:"/tmp/"};function yC(e){let n=["ls","find /",`grep -r ${xC(e)} .`];if(!e||e.size===0)return n;let r=null;for(let[o,i]of e){if(typeof i!="string")continue;let s=bC(o);(r===null||s.length<r.length)&&(r=s)}return r&&n.push(`cat ${r} | head -n 20`),n}var Nf=["TODO","FIXME","XXX","HACK","NOTE","BUG","export","import","require","//"];function xC(e){if(!e||e.size===0)return Nf[0];for(let t of Nf)for(let n of e.values())if(typeof n=="string"&&n.includes(t))return t;return Nf[0]}function bC(e){return e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e}var Tf=class e extends Cf{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=_f(jx);#t=null;#s=null;#n=[];#e=-1;#i="";#r=null;#o=null;static#u=200;#a=new Map;#l=0;static#f=3;static#c=400;constructor(){super(),this.sources=null,this._lines=[],this._input="",this._cwd=Of,this._ghost="",this._notes=[],this._running=!1}willUpdate(t){t.has("sources")&&this.sources!==this.#s&&(this.#t=this.sources?Fx(this.sources,wC):null,this._cwd=this.#t?this.#t.cwd():Of,this._lines=[{kind:"banner",commands:yC(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}
380
- `}];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:zx(i.stdout)}),i.stderr&&s.push({kind:"stderr",text:i.stderr}),this._lines=s,this.#E(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))}#E(t){let n=t.notes.map(r=>({text:r,kind:"note"}));for(let r of Bx(t))n.push({text:`silenced: ${r}`,kind:"gap"});this.#v(n)}#v(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.#f;)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])}#T=t=>{this._input=t.target.value};#I=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 Je`<div class="notes" role="log" aria-atomic="false">${Lf(this._notes,t=>t.id,t=>Je`<div class="note ${t.kind==="gap"?"note-gap":""}" style="--dwell-out: ${t.dwell-e.#c}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?Je`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:Xs} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#T}" @keydown="${this.#m}"></div></form>`}#_(t){return t.kind==="banner"?Je`<div class="banner">Virtual shell over the bundle source tree. Try ${t.commands.map((n,r)=>Je`${r>0?", ":""}\`<span class="cmd" @click="${()=>this.#I(n)}">${n}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:t.kind==="prompt"?Je`<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"?Je`<pre class="stderr">${t.text}</pre>`:Xs}#L(t){if(!t.diff)return Je`<pre class="stdout">${t.text}</pre>`;let n=t.diff.flatMap((r,o)=>{let i=r.kind?Je`<span class="diff-${r.kind}">${r.text}</span>`:r.text;return o===0?[i]:[`
381
- `,i]});return Je`<pre class="stdout">${n}</pre>`}};customElements.define("bundle-terminal",Tf);function NH(e,t){let n=document.createElement("bundle-terminal");return n.dataset.integrity=t??"",n.sources=e,n}export{NH as createTerminalElement};
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};