@preventive/triage 1.0.0-alpha.52 → 1.0.0-alpha.54

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 (112) hide show
  1. package/common/bundle-compare-diff.js +28 -9
  2. package/common/bundle-compare-inputs.d.ts +1 -0
  3. package/common/bundle-compare-inputs.js +91 -15
  4. package/common/bundle-comparison.js +14 -7
  5. package/common/default-scan-models.ts +3 -0
  6. package/common/dependency-reviews.d.ts +1 -1
  7. package/common/dependency-reviews.js +1 -1
  8. package/common/managed/finding-detail.d.ts +4 -2
  9. package/common/managed/finding-detail.js +27 -15
  10. package/common/managed/team-app.d.ts +9 -0
  11. package/common/managed/team-app.js +59 -6
  12. package/common/workspace-app.js +38 -6
  13. package/out/activity.js +4 -4
  14. package/out/chunk-4EMM6UCD.js +1 -0
  15. package/out/chunk-4ISO5F7Y.js +7 -0
  16. package/out/chunk-4XIH7YTX.js +1 -0
  17. package/out/chunk-6W5BMATD.js +1 -0
  18. package/out/{chunk-WFYLMF6Z.js → chunk-74AEKRES.js} +1 -1
  19. package/out/chunk-DEVAORP2.js +1 -0
  20. package/out/{chunk-KOGNQDSJ.js → chunk-DTM47KGS.js} +1 -1
  21. package/out/chunk-E3LFSUDJ.js +9 -0
  22. package/out/chunk-FHIVVVUA.js +6 -0
  23. package/out/chunk-G3LY2FV4.js +1 -0
  24. package/out/chunk-HAZKDK4M.js +4 -0
  25. package/out/chunk-HOB3YPS5.js +1 -0
  26. package/out/chunk-I47TYPXO.js +52 -0
  27. package/out/chunk-J7A5OSZE.js +244 -0
  28. package/out/chunk-JFL7WLRV.js +1 -0
  29. package/out/chunk-JMG5DXII.js +2 -0
  30. package/out/chunk-JOXLZXMI.js +1 -0
  31. package/out/chunk-L4CTEMRG.js +2 -0
  32. package/out/chunk-M37X4LCF.js +14 -0
  33. package/out/chunk-M3Y6SLC4.js +1 -0
  34. package/out/chunk-NXATZJQ2.js +1 -0
  35. package/out/{chunk-MYGJBYYJ.js → chunk-ORIP5INC.js} +1 -1
  36. package/out/chunk-PAD2JHZT.js +1 -0
  37. package/out/chunk-QMVOEBWC.js +13 -0
  38. package/out/{chunk-SXV2T5C4.js → chunk-QRKFPLA4.js} +1 -1
  39. package/out/chunk-RRBIJL2B.js +1 -0
  40. package/out/{chunk-GDPCLSOS.js → chunk-SYXT3SFP.js} +1 -1
  41. package/out/chunk-TOXMUOIW.js +5 -0
  42. package/out/chunk-UBOCLLF2.js +1 -0
  43. package/out/chunk-UCP3JRE2.js +1 -0
  44. package/out/{chunk-NCN3M5EP.js → chunk-VC72ZO3P.js} +2 -2
  45. package/out/chunk-VRX2APNA.js +9 -0
  46. package/out/{chunk-IMM274IW.js → chunk-VZMELPVL.js} +4 -3
  47. package/out/{chunk-CHRBUGVN.js → chunk-WHVXTJHK.js} +1 -1
  48. package/out/chunk-WMFDQS2L.js +11 -0
  49. package/out/chunk-WNSVBOSO.js +41 -0
  50. package/out/chunk-WREU7JAG.js +1 -0
  51. package/out/chunk-Y5ZHFNBD.js +2 -0
  52. package/out/chunk-YF4M5OCI.js +1 -0
  53. package/out/chunk-Z667U2UJ.js +1 -0
  54. package/out/chunk-ZQHLECTI.js +1 -0
  55. package/out/client-managed-import.js +1 -1
  56. package/out/client-managed.js +27 -26
  57. package/out/compare.js +14 -14
  58. package/out/dialogs.js +36 -51
  59. package/out/graph.js +17 -15
  60. package/out/index.html +26 -10
  61. package/out/prism.js +1 -1
  62. package/out/scan.js +2 -2
  63. package/out/terminal.js +232 -232
  64. package/out/view.css +1 -1
  65. package/out/view.js +15 -15
  66. package/package.json +12 -7
  67. package/risk/actions/resolve.js +36 -5
  68. package/risk/index.d.ts +20 -2
  69. package/risk/npm/malware.js +6 -4
  70. package/risk/npm/registry.js +8 -6
  71. package/server-managed/bundle-advisories.ts +56 -74
  72. package/server-managed/bundle-build-worker.js +61 -4
  73. package/server-managed/bundle-build.ts +13 -4
  74. package/server-managed/bundle-dependency-reviews.ts +74 -0
  75. package/server-managed/bundle-validation.ts +32 -0
  76. package/server-managed/db-methods.ts +51 -16
  77. package/server-managed/db-neon.ts +18 -2
  78. package/server-managed/db.ts +11 -2
  79. package/server-managed/github-issue-links.ts +151 -47
  80. package/server-managed/github-pulls.ts +34 -15
  81. package/server-managed/history-windows.ts +172 -0
  82. package/server-managed/http.ts +227 -12
  83. package/server-managed/index.ts +13 -1
  84. package/server-managed/managed-issues.ts +29 -15
  85. package/server-managed/npm-insights.ts +4 -3
  86. package/server-managed/npm-kept.ts +4 -0
  87. package/server-managed/package-entry-points.ts +37 -9
  88. package/server-managed/pretty-print.ts +7 -5
  89. package/server-managed/public-workspace.ts +2 -2
  90. package/server-managed/repository-actions.ts +7 -4
  91. package/server-managed/repository-browser.ts +11 -4
  92. package/server-managed/repository-history.ts +2 -2
  93. package/server-managed/repository-pulse.ts +11 -2
  94. package/server-managed/repository-risk-audit.ts +4 -5
  95. package/server-managed/repository-risk.ts +4 -4
  96. package/server-managed/sql.ts +2 -1
  97. package/server-managed/stasis-config.ts +46 -0
  98. package/server-managed/team-app-summaries.ts +54 -0
  99. package/server-managed/team-app.ts +52 -31
  100. package/server-managed/team-reports.ts +34 -13
  101. package/server-managed/upstream-cache.ts +41 -32
  102. package/server-managed/workspace-shares.ts +3 -1
  103. package/out/chunk-2ZDZWLFY.js +0 -1
  104. package/out/chunk-7VAWINQF.js +0 -6
  105. package/out/chunk-FMXWXDR4.js +0 -36
  106. package/out/chunk-IZ7POWI3.js +0 -18
  107. package/out/chunk-LJ7XRXFU.js +0 -52
  108. package/out/chunk-OGAYMEER.js +0 -232
  109. package/out/chunk-QB4CBOX2.js +0 -1
  110. package/out/chunk-TQJDYHVE.js +0 -2
  111. package/out/chunk-VH4XMZIW.js +0 -2
  112. package/out/chunk-WYLQWYLA.js +0 -1
package/out/terminal.js CHANGED
@@ -1,118 +1,118 @@
1
- import{a as e}from"./chunk-GO7FT4OD.js";import{a as t,b as n,c as r,e as i,f as a}from"./chunk-2ZDZWLFY.js";import{a as o,b as s,c,d as l,e as u,h as d,i as f,j as p,k as m,l as h}from"./chunk-4HI2MSAV.js";import"./chunk-PXK7EU4V.js";import{a as g,d as _}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import{a as ee,c as v,g as te,j as ne}from"./chunk-2XUEZHIP.js";import"./chunk-OOJM4CTU.js";var re={__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`},ie=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/gu,ae=e=>`${e}`.replaceAll(ie,e=>`\\u${e.codePointAt(0).toString(16).padStart(4,`0`)}`),oe=(e,t,n=`a string`)=>TypeError(`${e} must be ${n}, not ${t===null?`null`:typeof t}`),y=class extends Error{constructor(e,t){super(`${ae(t)}: ${re[e]??e}`),this.name=`VfsError`,this.code=e,this.path=t}},se=(e,t=`path`)=>{if(typeof e!=`string`)throw oe(t,e);return e};function ce(e,t){let n=Math.min(se(e).length,se(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 le=e=>[...e.entries.keys()].sort(ce),ue=(e,t)=>t===``?e:e===`/`?`/${t}`:`${e}/${t}`;function*de(e,t=e=>e,n=()=>!0){let r=[{name:``,node:e,depth:0}];for(;r.length>0;){let e=r.pop();if(yield t(e),e.node.type!==`directory`||!n(e))continue;let i=le(e.node);for(let t=i.length-1;t>=0;t--){let n=e.name===``?i[t]:`${e.name}/${i[t]}`;r.push({name:n,leaf:i[t],parent:e.node,node:e.node.entries.get(i[t]),depth:e.depth+1})}}}var fe=new Set([`error`,`keep`,`replace`]);function pe(e,t,n=`'error', 'keep' or 'replace'`){if(typeof e!=`string`)throw oe(t,e,n);if(!fe.has(e))throw RangeError(`${t} must be ${n}, not ${JSON.stringify(e)}`);return e}function me({clash:e=`error`,fold:t}){if(typeof e!=`function`&&pe(e,`clash`,`'error', 'keep', 'replace' or a function`),t!==void 0&&typeof t!=`function`)throw oe(`fold`,t,`a function`);return{fold:t,settle:typeof e==`function`?(t,n)=>pe(e(t,n),`what clash returns`):()=>e}}function he(e,t,n,{settle:r,fold:i},a){let o=_e(t,a.copy),s=new Map([[o,{into:e}]]),c=[];for(let{name:e,leaf:t,parent:a,node:l}of de(o,void 0,e=>s.has(e.node))){if(a===void 0)continue;let o=s.get(a),u=o.into.entries.get(t);if(u?.type===`directory`&&l.type===`directory`){s.set(l,{into:u});continue}let d=u===void 0?ve(o,a,t,i):[t];if(d.length>0){let i=ue(n,e),a=r(i,d.map(e=>i.slice(0,-t.length)+e));if(a===`error`)throw new y(`EEXIST`,i);if(a===`keep`)continue}c.push({dir:o.into,name:t,node:l,taken:d})}for(let{dir:e,name:t,node:n,taken:r}of c){for(let e of de(n))a.number(e.node);for(let t of r)e.entries.delete(t);e.entries.set(t,n)}}function*ge(e,t,n){for(let{name:r,node:i}of de(e))if(i.type===`directory`)for(let e of Map.groupBy(le(i),e=>n(e)).values())e.length>1&&(yield{path:ue(t,r),names:e})}function _e(e,t){let n=new Map;for(let{node:r,parent:i,leaf:a}of de(e))n.has(r)||n.set(r,t(r)),i!==void 0&&n.get(i).entries.set(a,n.get(r));return n.get(e)}function ve(e,t,n,r){return r===void 0?[]:(e.keys??=Map.groupBy(le(e.into).filter(e=>!t.entries.has(e)),e=>r(e)),e.keys.get(r(n))??[])}var ye=40,be=255,xe=4096,Se=new Uint8Array,Ce={file:420,directory:493,symlink:511},we=new TextEncoder,Te=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),Ee=e=>typeof e==`string`&&e.endsWith(`/`),De=class{#e;#t=0;constructor(){this.#e=this.#r()}#n(e,t,n=Ce[e],r=0){return{ino:++this.#t,type:e,mode:ze(n),mtime:Be(r),...t}}#r(e,t){return this.#n(`directory`,{entries:new Map},e,t)}#i(e,{follow:t=!0,mkdirs:n=!1,create:r=!1}={}){if(typeof e!=`string`)throw oe(`a path`,e);if(e.includes(`\0`))throw new y(`EINVAL`,e);if(e===``)throw new y(`ENOENT`,e);let i=e.endsWith(`/`),a=[Oe(e)],o=[{name:``,node:this.#e}],s=ye,c,l,u,d;for(;;){for(;a.length>1&&Ae(a.at(-1));)a.pop();if(Ae(a.at(-1))){({name:u,node:d}=o.pop()),c=void 0;break}if(l=a.length>1,u=Me(a.at(-1)),u===`.`)continue;if(u===`..`){o.length>1&&o.pop();continue}c=o.at(-1).node;let f=a.every(Ae);if(d=c.entries.get(u),r&&!f&&a.every(ke)){i=!0;break}if(d===void 0){if(f)break;if(!n||l)throw new y(`ENOENT`,e);Ie(u,e),d=this.#r(),c.entries.set(u,d)}if(d.type===`symlink`&&(!f||t)){if(s--===0)throw new y(`ELOOP`,e);d.target.startsWith(`/`)&&(o.length=1),a.push(Oe(d.target,!0));continue}if(f){if(i&&!r&&d.type!==`directory`)throw new y(`ENOTDIR`,e);break}if(d.type!==`directory`)throw new y(`ENOTDIR`,e);o.push({name:u,node:d})}return{dir:c,name:u,node:d,trailing:i,chain:o,linked:l}}#a(e,t=!0){let n=this.#i(e,{follow:t});if(n.node===void 0)throw new y(`ENOENT`,e);return n}#o(e,t){return this.#a(e,t).node}#s(e,t,n){Ie(e.name,n),e.dir.entries.set(e.name,t)}#c(e,t){if(e.dir!==void 0)return e.dir;throw new y(je(t,0)===t.length?`EBUSY`:`EINVAL`,t)}#l(e,t,n){try{return this.#o(e,n).type===t}catch(e){if(e instanceof y)return!1;throw e}}stat(e){return Pe(this.#o(e,!0))}lstat(e){return Pe(this.#o(e,Ee(e)))}isFile(e){return this.#l(e,`file`,!0)}isDirectory(e){return this.#l(e,`directory`,!0)}isSymlink(e){return this.#l(e,`symlink`,!1)}realpath(e){return Ne(this.#a(e))}readFile(e){let t=this.#o(e,!0);if(t.type===`directory`)throw new y(`EISDIR`,e);return t.bytes}readText(e){let t=this.readFile(e);try{return Te.decode(t)}catch{throw new y(`EILSEQ`,e)}}readlink(e){let t=this.#o(e,Ee(e));if(t.type!==`symlink`)throw new y(`EINVAL`,e);return t.target}readdir(e){let t=this.#o(e,!0);if(t.type!==`directory`)throw new y(`ENOTDIR`,e);return le(t)}#u(e,t,n,r,i){let a=Ve(t,e),o=this.#i(e,{follow:!Ee(e),create:!0});if(o.trailing||o.node?.type===`directory`)throw new y(`EISDIR`,e);o.node===void 0?this.#s(o,this.#n(`file`,{bytes:a},r,i),e):n(o.node,a)}writeFile(e,t,{mode:n,mtime:r}={}){this.#u(e,t,(e,t)=>Object.assign(e,{bytes:t,...Fe(e,n,r)}),n,r)}appendFile(e,t){this.#u(e,t,(e,t)=>{e.bytes=Ue(e.bytes,t)})}mkdir(e,{recursive:t=!1,mode:n,mtime:r}={}){let i=this.#i(e,{follow:t,mkdirs:t,create:!t});if(i.node===void 0){if(i.linked)throw new y(`ENOENT`,e);this.#s(i,this.#r(n,r),e)}else if(!t||i.node.type!==`directory`)throw new y(`EEXIST`,e)}symlink(e,t,{mode:n,mtime:r}={}){if(typeof e!=`string`)throw oe(`a link target`,e);if(e===``||e.includes(`\0`))throw new y(`EINVAL`,t);Ie(e,t,xe),this.#s(this.#d(t),this.#n(`symlink`,{target:e,size:Le(e)},n,r),t)}hardlink(e,t){let n=this.#o(e,Ee(e)),r=this.#d(t);if(n.type===`directory`)throw new y(`EPERM`,e);this.#s(r,n,t)}#d(e){let t=this.#i(e,{follow:!1,create:!0});if(t.node!==void 0)throw new y(`EEXIST`,e);if(t.trailing)throw new y(`ENOENT`,e);return t}unlink(e){this.rm(e)}rmdir(e){let t=this.#a(e,!1);if(t.node.type!==`directory`)throw new y(`ENOTDIR`,e);let n=this.#c(t,e);if(t.node.entries.size>0)throw new y(`ENOTEMPTY`,e);n.entries.delete(t.name)}rm(e,{recursive:t=!1}={}){let n=this.#a(e,!1);if(n.node.type===`directory`&&!t)throw new y(`EISDIR`,e);this.#c(n,e).entries.delete(n.name)}rename(e,t){let n=this.#i(e,{follow:!1,create:!0}),r=this.#i(t,{follow:!1,create:!0}),i=this.#c(n,e),a=this.#c(r,t);if(n.node===void 0)throw new y(`ENOENT`,e);Ie(r.name,t);let o=n.node.type===`directory`;if(!o&&(n.trailing||r.trailing))throw new y(`ENOTDIR`,n.trailing?e:t);if(r.chain.some(e=>e.node===n.node))throw new y(`EINVAL`,t);if(n.chain.some(e=>e.node===r.node))throw new y(`ENOTEMPTY`,t);if(r.node!==n.node){if(r.node!==void 0&&r.node.type===`directory`!==o)throw new y(o?`ENOTDIR`:`EISDIR`,t);if(r.node?.type===`directory`&&r.node.entries.size>0)throw new y(`ENOTEMPTY`,t);i.entries.delete(n.name),a.entries.set(r.name,n.node)}}chmod(e,t){this.#o(e,!0).mode=ze(t)}utimes(e,t){this.#o(e,!0).mtime=Be(t)}mount(e,t=`/`,n={}){if(typeof e!=`object`||!e||!(#e in e))throw oe(`a tree`,e,`a Vfs`);let r=me(n),i=this.#a(t);if(i.node.type!==`directory`)throw new y(`ENOTDIR`,t);he(i.node,e.#e,Ne(i),r,{copy:He,number:e=>{e.ino||=++this.#t}})}walk(e=`/`){let t=this.#a(e),n=Ne(t);return de(t.node,({name:e,node:t,depth:r})=>({path:ue(n,e),type:t.type,depth:r}))}collisions(e,t=`/`){if(typeof e!=`function`)throw oe(`fold`,e,`a function`);let n=this.#a(t);return ge(n.node,Ne(n),e)}entries(e=`/`){let t=this.#a(e),n=t.node.type===`directory`?`.`:t.name,r=new Map;return de(t.node,({name:e,node:t})=>{let i=e===``?n:e,a={name:i,type:t.type,mode:t.mode,mtime:t.mtime,linkname:``,data:Se},o=r.get(t);return o===void 0?t.type===`symlink`?(r.set(t,i),a.linkname=t.target):t.type===`file`&&(r.set(t,i),a.data=t.bytes):(a.type=`hardlink`,a.linkname=o),a})}},Oe=(e,t=!1)=>({text:e,at:je(e,0),dot:t&&e.endsWith(`/`)}),ke=e=>e.at===e.text.length,Ae=e=>ke(e)&&!e.dot,je=(e,t)=>{let n=t;for(;e[n]===`/`;)n++;return n};function Me(e){if(ke(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=je(e.text,n),r}var Ne=({chain:e,name:t})=>`/${[...e.slice(1).map(e=>e.name),t].filter(Boolean).join(`/`)}`,Pe=e=>({type:e.type,ino:e.ino,mode:e.mode,mtime:e.mtime,size:e.bytes?.length??e.size??0}),Fe=(e,t=e.mode,n=e.mtime)=>({mode:ze(t),mtime:Be(n)});function Ie(e,t,n=be){if(!e.isWellFormed())throw new y(`EILSEQ`,t);if(Re(e,n))throw new y(`ENAMETOOLONG`,t)}function Le(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}var Re=(e,t)=>e.length>t||e.length*3>t&&Le(e)>t;function ze(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`);return e}function Be(e){if(!Number.isSafeInteger(e))throw RangeError(`an mtime must be an integer of whole seconds, not ${e}`);return e}function Ve(e,t){if(typeof e==`string`){if(!e.isWellFormed())throw new y(`EILSEQ`,t);return we.encode(e)}if(e instanceof Uint8Array)return new Uint8Array(e);throw oe(`file contents`,e,`a string or a Uint8Array`)}function He({type:e,mode:t,mtime:n,bytes:r,target:i,size:a}){let o={ino:0,type:e,mode:t,mtime:n};return e===`directory`?o.entries=new Map:e===`symlink`?Object.assign(o,{target:i,size:a}):o.bytes=r.byteOffset+r.length===r.buffer.byteLength?r:r.slice(),o}function Ue(e,t){let n=e.length+t.length,r=e.byteOffset+n<=e.buffer.byteLength,i=r?new Uint8Array(e.buffer,e.byteOffset,n):new Uint8Array(Math.max(n,e.length*2)).subarray(0,n);return r||i.set(e),i.set(t,e.length),i}var b=(e=``)=>({stdout:e,stderr:``,exitCode:0}),x=(e,t=1)=>({stdout:``,stderr:e.endsWith(`
1
+ import{a as e}from"./chunk-GO7FT4OD.js";import{a as t,b as n}from"./chunk-Z667U2UJ.js";import{a as r}from"./chunk-DEVAORP2.js";import{d as i,e as a}from"./chunk-ZQHLECTI.js";import{a as o,b as s,c,d as l,e as u,h as d,i as f,j as p,k as m,l as h}from"./chunk-4HI2MSAV.js";import"./chunk-PXK7EU4V.js";import{a as g,d as _}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import{a as ee,c as v,g as te,j as ne}from"./chunk-2XUEZHIP.js";import"./chunk-OOJM4CTU.js";var re={__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`},ie=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/gu,ae=e=>`${e}`.replaceAll(ie,e=>`\\u${e.codePointAt(0).toString(16).padStart(4,`0`)}`),oe=(e,t,n=`a string`)=>TypeError(`${e} must be ${n}, not ${t===null?`null`:typeof t}`),y=class extends Error{constructor(e,t){super(`${ae(t)}: ${re[e]??e}`),this.name=`VfsError`,this.code=e,this.path=t}},se=(e,t=`path`)=>{if(typeof e!=`string`)throw oe(t,e);return e};function ce(e,t){let n=Math.min(se(e).length,se(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 le=e=>[...e.entries.keys()].sort(ce),ue=(e,t)=>t===``?e:e===`/`?`/${t}`:`${e}/${t}`;function*de(e,t=e=>e,n=()=>!0){let r=[{name:``,node:e,depth:0}];for(;r.length>0;){let e=r.pop();if(yield t(e),e.node.type!==`directory`||!n(e))continue;let i=le(e.node);for(let t=i.length-1;t>=0;t--){let n=e.name===``?i[t]:`${e.name}/${i[t]}`;r.push({name:n,leaf:i[t],parent:e.node,node:e.node.entries.get(i[t]),depth:e.depth+1})}}}var fe=new Set([`error`,`keep`,`replace`]);function pe(e,t,n=`'error', 'keep' or 'replace'`){if(typeof e!=`string`)throw oe(t,e,n);if(!fe.has(e))throw RangeError(`${t} must be ${n}, not ${JSON.stringify(e)}`);return e}function me({clash:e=`error`,fold:t}){if(typeof e!=`function`&&pe(e,`clash`,`'error', 'keep', 'replace' or a function`),t!==void 0&&typeof t!=`function`)throw oe(`fold`,t,`a function`);return{fold:t,settle:typeof e==`function`?(t,n)=>pe(e(t,n),`what clash returns`):()=>e}}function he(e,t,n,{settle:r,fold:i},a){let o=_e(t,a.copy),s=new Map([[o,{into:e}]]),c=[];for(let{name:e,leaf:t,parent:a,node:l}of de(o,void 0,e=>s.has(e.node))){if(a===void 0)continue;let o=s.get(a),u=o.into.entries.get(t);if(u?.type===`directory`&&l.type===`directory`){s.set(l,{into:u});continue}let d=u===void 0?ve(o,a,t,i):[t];if(d.length>0){let i=ue(n,e),a=r(i,d.map(e=>i.slice(0,-t.length)+e));if(a===`error`)throw new y(`EEXIST`,i);if(a===`keep`)continue}c.push({dir:o.into,name:t,node:l,taken:d})}for(let{dir:e,name:t,node:n,taken:r}of c){for(let e of de(n))a.number(e.node);for(let t of r)e.entries.delete(t);e.entries.set(t,n)}}function*ge(e,t,n){for(let{name:r,node:i}of de(e))if(i.type===`directory`)for(let e of Map.groupBy(le(i),e=>n(e)).values())e.length>1&&(yield{path:ue(t,r),names:e})}function _e(e,t){let n=new Map;for(let{node:r,parent:i,leaf:a}of de(e))n.has(r)||n.set(r,t(r)),i!==void 0&&n.get(i).entries.set(a,n.get(r));return n.get(e)}function ve(e,t,n,r){return r===void 0?[]:(e.keys??=Map.groupBy(le(e.into).filter(e=>!t.entries.has(e)),e=>r(e)),e.keys.get(r(n))??[])}var ye=40,be=255,xe=4096,Se=new Uint8Array,Ce={file:420,directory:493,symlink:511},we=new TextEncoder,Te=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),Ee=e=>typeof e==`string`&&e.endsWith(`/`),De=class{#e;#t=0;constructor(){this.#e=this.#r()}#n(e,t,n=Ce[e],r=0){return{ino:++this.#t,type:e,mode:ze(n),mtime:Be(r),...t}}#r(e,t){return this.#n(`directory`,{entries:new Map},e,t)}#i(e,{follow:t=!0,mkdirs:n=!1,create:r=!1}={}){if(typeof e!=`string`)throw oe(`a path`,e);if(e.includes(`\0`))throw new y(`EINVAL`,e);if(e===``)throw new y(`ENOENT`,e);let i=e.endsWith(`/`),a=[Oe(e)],o=[{name:``,node:this.#e}],s=ye,c,l,u,d;for(;;){for(;a.length>1&&Ae(a.at(-1));)a.pop();if(Ae(a.at(-1))){({name:u,node:d}=o.pop()),c=void 0;break}if(l=a.length>1,u=Me(a.at(-1)),u===`.`)continue;if(u===`..`){o.length>1&&o.pop();continue}c=o.at(-1).node;let f=a.every(Ae);if(d=c.entries.get(u),r&&!f&&a.every(ke)){i=!0;break}if(d===void 0){if(f)break;if(!n||l)throw new y(`ENOENT`,e);Ie(u,e),d=this.#r(),c.entries.set(u,d)}if(d.type===`symlink`&&(!f||t)){if(s--===0)throw new y(`ELOOP`,e);d.target.startsWith(`/`)&&(o.length=1),a.push(Oe(d.target,!0));continue}if(f){if(i&&!r&&d.type!==`directory`)throw new y(`ENOTDIR`,e);break}if(d.type!==`directory`)throw new y(`ENOTDIR`,e);o.push({name:u,node:d})}return{dir:c,name:u,node:d,trailing:i,chain:o,linked:l}}#a(e,t=!0){let n=this.#i(e,{follow:t});if(n.node===void 0)throw new y(`ENOENT`,e);return n}#o(e,t){return this.#a(e,t).node}#s(e,t,n){Ie(e.name,n),e.dir.entries.set(e.name,t)}#c(e,t){if(e.dir!==void 0)return e.dir;throw new y(je(t,0)===t.length?`EBUSY`:`EINVAL`,t)}#l(e,t,n){try{return this.#i(e,{follow:n}).node?.type===t}catch(e){if(e instanceof y)return!1;throw e}}stat(e){return Pe(this.#o(e,!0))}lstat(e){return Pe(this.#o(e,Ee(e)))}isFile(e){return this.#l(e,`file`,!0)}isDirectory(e){return this.#l(e,`directory`,!0)}isSymlink(e){return this.#l(e,`symlink`,!1)}realpath(e){return Ne(this.#a(e))}readFile(e){let t=this.#o(e,!0);if(t.type===`directory`)throw new y(`EISDIR`,e);return t.bytes}readText(e){let t=this.readFile(e);try{return Te.decode(t)}catch{throw new y(`EILSEQ`,e)}}readlink(e){let t=this.#o(e,Ee(e));if(t.type!==`symlink`)throw new y(`EINVAL`,e);return t.target}readdir(e){let t=this.#o(e,!0);if(t.type!==`directory`)throw new y(`ENOTDIR`,e);return le(t)}#u(e,t,n,r,i,a=!1){let o=a&&t instanceof Uint8Array?Ve(t):He(t,e),s=this.#i(e,{follow:!Ee(e),create:!0});if(s.trailing||s.node?.type===`directory`)throw new y(`EISDIR`,e);s.node===void 0?this.#s(s,this.#n(`file`,{bytes:o},r,i),e):n(s.node,o)}writeFile(e,t,{mode:n,mtime:r,adopt:i=!1}={}){if(typeof i!=`boolean`)throw oe(`adopt`,i,`a boolean`);this.#u(e,t,(e,t)=>Object.assign(e,{bytes:t,grows:!1,...Fe(e,n,r)}),n,r,i)}appendFile(e,t){this.#u(e,t,We)}mkdir(e,{recursive:t=!1,mode:n,mtime:r}={}){let i=this.#i(e,{follow:t,mkdirs:t,create:!t});if(i.node===void 0){if(i.linked)throw new y(`ENOENT`,e);this.#s(i,this.#r(n,r),e)}else if(!t||i.node.type!==`directory`)throw new y(`EEXIST`,e)}symlink(e,t,{mode:n,mtime:r}={}){if(typeof e!=`string`)throw oe(`a link target`,e);if(e===``||e.includes(`\0`))throw new y(`EINVAL`,t);Ie(e,t,xe),this.#s(this.#d(t),this.#n(`symlink`,{target:e,size:Le(e)},n,r),t)}hardlink(e,t){let n=this.#o(e,Ee(e)),r=this.#d(t);if(n.type===`directory`)throw new y(`EPERM`,e);this.#s(r,n,t)}#d(e){let t=this.#i(e,{follow:!1,create:!0});if(t.node!==void 0)throw new y(`EEXIST`,e);if(t.trailing)throw new y(`ENOENT`,e);return t}unlink(e){this.rm(e)}rmdir(e){let t=this.#a(e,!1);if(t.node.type!==`directory`)throw new y(`ENOTDIR`,e);let n=this.#c(t,e);if(t.node.entries.size>0)throw new y(`ENOTEMPTY`,e);n.entries.delete(t.name)}rm(e,{recursive:t=!1}={}){let n=this.#a(e,!1);if(n.node.type===`directory`&&!t)throw new y(`EISDIR`,e);this.#c(n,e).entries.delete(n.name)}rename(e,t){let n=this.#i(e,{follow:!1,create:!0}),r=this.#i(t,{follow:!1,create:!0}),i=this.#c(n,e),a=this.#c(r,t);if(n.node===void 0)throw new y(`ENOENT`,e);Ie(r.name,t);let o=n.node.type===`directory`;if(!o&&(n.trailing||r.trailing))throw new y(`ENOTDIR`,n.trailing?e:t);if(r.chain.some(e=>e.node===n.node))throw new y(`EINVAL`,t);if(n.chain.some(e=>e.node===r.node))throw new y(`ENOTEMPTY`,t);if(r.node!==n.node){if(r.node!==void 0&&r.node.type===`directory`!==o)throw new y(o?`ENOTDIR`:`EISDIR`,t);if(r.node?.type===`directory`&&r.node.entries.size>0)throw new y(`ENOTEMPTY`,t);i.entries.delete(n.name),a.entries.set(r.name,n.node)}}chmod(e,t){this.#o(e,!0).mode=ze(t)}utimes(e,t){this.#o(e,!0).mtime=Be(t)}mount(e,t=`/`,n={}){if(typeof e!=`object`||!e||!(#e in e))throw oe(`a tree`,e,`a Vfs`);let r=me(n),i=this.#a(t);if(i.node.type!==`directory`)throw new y(`ENOTDIR`,t);he(i.node,e.#e,Ne(i),r,{copy:Ue,number:e=>{e.ino||=++this.#t}})}walk(e=`/`){let t=this.#a(e),n=Ne(t);return de(t.node,({name:e,node:t,depth:r})=>({path:ue(n,e),type:t.type,depth:r}))}collisions(e,t=`/`){if(typeof e!=`function`)throw oe(`fold`,e,`a function`);let n=this.#a(t);return ge(n.node,Ne(n),e)}entries(e=`/`){let t=this.#a(e),n=t.node.type===`directory`?`.`:t.name,r=new Map;return de(t.node,({name:e,node:t})=>{let i=e===``?n:e,a={name:i,type:t.type,mode:t.mode,mtime:t.mtime,linkname:``,data:Se},o=r.get(t);return o===void 0?t.type===`symlink`?(r.set(t,i),a.linkname=t.target):t.type===`file`&&(r.set(t,i),a.data=t.bytes):(a.type=`hardlink`,a.linkname=o),a})}},Oe=(e,t=!1)=>({text:e,at:je(e,0),dot:t&&e.endsWith(`/`)}),ke=e=>e.at===e.text.length,Ae=e=>ke(e)&&!e.dot,je=(e,t)=>{let n=t;for(;e[n]===`/`;)n++;return n};function Me(e){if(ke(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=je(e.text,n),r}var Ne=({chain:e,name:t})=>`/${[...e.slice(1).map(e=>e.name),t].filter(Boolean).join(`/`)}`,Pe=e=>({type:e.type,ino:e.ino,mode:e.mode,mtime:e.mtime,size:e.bytes?.length??e.size??0}),Fe=(e,t=e.mode,n=e.mtime)=>({mode:ze(t),mtime:Be(n)});function Ie(e,t,n=be){if(!e.isWellFormed())throw new y(`EILSEQ`,t);if(Re(e,n))throw new y(`ENAMETOOLONG`,t)}function Le(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}var Re=(e,t)=>e.length>t||e.length*3>t&&Le(e)>t;function ze(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`);return e}function Be(e){if(!Number.isSafeInteger(e))throw RangeError(`an mtime must be an integer of whole seconds, not ${e}`);return e}var Ve=e=>e.constructor===Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.length);function He(e,t){if(typeof e==`string`){if(!e.isWellFormed())throw new y(`EILSEQ`,t);return we.encode(e)}if(e instanceof Uint8Array)return new Uint8Array(e);throw oe(`file contents`,e,`a string or a Uint8Array`)}function Ue({type:e,mode:t,mtime:n,bytes:r,target:i,size:a}){let o={ino:0,type:e,mode:t,mtime:n};return e===`directory`?o.entries=new Map:e===`symlink`?Object.assign(o,{target:i,size:a}):o.bytes=r,o}function We(e,t){let n=e.bytes,r=n.length+t.length,i=e.grows===!0&&n.byteOffset+r<=n.buffer.byteLength,a=i?new Uint8Array(n.buffer,n.byteOffset,r):new Uint8Array(Math.max(r,n.length*2)).subarray(0,r);i||a.set(n),a.set(t,n.length),e.bytes=a,e.grows=!0}var b=(e=``)=>({stdout:e,stderr:``,exitCode:0}),x=(e,t=1)=>({stdout:``,stderr:e.endsWith(`
2
2
  `)?e:e+`
3
- `,exitCode:t}),We=(e,t=1)=>x(`usage: ${e}`,t),Ge=Symbol(`unsupported`);function S(e){if(e==null)return null;try{return e[Ge]??null}catch{return null}}function C(e,t,n,r,i=1){return w(x(r,i),e,t,n,r)}function w(e,t,n,r,i){return Object.defineProperty(e,Ge,{value:{kind:t,command:n,detail:r,message:i},enumerable:!1,configurable:!0}),e}function Ke(e,t,n,r){let i=S(e);return i?C(i.kind,t,i.detail,n,r):x(n,r)}var T=class extends Error{constructor(e,t,n){super(n),this.name=`UnsupportedError`,w(this,e,null,t,n)}};function qe(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let i=JSON.stringify([n.kind,r,n.detail]);e.has(i)||(e.add(i),t.push(Object.freeze(n)))}}}function E(e){try{return f(e)}catch(e){throw e instanceof TypeError?new T(`feature`,`unpaired surrogate`,`unpaired UTF-16 surrogates cannot be encoded as UTF-8`):e}}var Je=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Ye(e){for(let t=0;t<e.length;){let n=nt[e[t]],r=n===1?e[t]:n===0?-1:Ze(e,t,n);yield r,t+=r<0?1:n}}var Xe=[0,0,128,2048,65536];function Ze(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let i=1;i<n;i++){if((e[t+i]&192)!=128)return-1;r=r<<6|e[t+i]&63}return r<Xe[n]||r>1114111||r>=55296&&r<=57343?-1:r}var Qe=e=>h(e);function $e(e){let t;try{t=m(e)}catch{}return t}function et(e){let t=$e(e);if(t!==void 0)return t;let n=new Uint16Array(e.length),r=0;for(let t=0;t<e.length;){let i=nt[e[t]],a=i===1?e[t]:i===0?-1:Ze(e,t,i);if(a<0){n[r++]=56320+e[t++];continue}a>65535?(n[r++]=55232+(a>>10),n[r++]=56320+(a&1023)):n[r++]=a,t+=i}let i=``;for(let e=0;e<r;e+=tt)i+=String.fromCharCode.apply(null,n.subarray(e,Math.min(r,e+tt)));return i}var tt=4096,nt=Uint8Array.from({length:256},(e,t)=>Je(t)),rt=`\\uDC80-\\uDCFF`,it=RegExp(`[${rt}]`,`u`),at=e=>e>=56448&&e<=56575;function ot(e){if(!it.test(e))return E(e);let t=new Uint8Array(e.length*3),n=0;for(let r=0;r<e.length;r++){let i=e.codePointAt(r);if(i<128)t[n++]=i;else if(at(i))t[n++]=i-56320;else if(i<2048)n=st(t,n,192|i>>6,i,1);else if(i<65536){if(i>=55296&&i<=57343)return E(e);n=st(t,n,224|i>>12,i,2)}else n=st(t,n,240|i>>18,i,3),r++}return t.slice(0,n)}function st(e,t,n,r,i){e[t++]=n;for(let n=i-1;n>=0;n--)e[t++]=128|r>>6*n&63;return t}function ct(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function D(e){try{return m(e)}catch{throw new T(`feature`,`partial UTF-8 byte sequence`,`byte output that is not valid UTF-8 cannot be represented by this string-based terminal`)}}function lt(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(Boolean),r=[];for(let e of n)if(e!==`.`){if(e===`..`){r.length>0&&r.at(-1)!==`..`?r.pop():t||r.push(`..`);continue}r.push(e)}return t?`/`+r.join(`/`):r.length===0?`.`:r.join(`/`)}function O(e,t){return t.startsWith(`/`)?lt(t):lt(e+`/`+t)}var ut=40,dt=(e,t)=>e.isLink?.(t)===!0;function k(e,t,n,{follow:r=!0}={}){let i=ft(e,t,n,{follow:r});return i.error?{path:null,error:i.error}:t.endsWith(`/`)&&!n.isDir(i.path)?{path:null,error:`Not a directory`}:{path:i.path,error:null}}function ft(e,t,n,{follow:r=!0,lenient:i=!1}={}){if(t===``||t.includes(`\0`))return{path:`/`,error:`No such file or directory`,rest:[]};let a=(t.startsWith(`/`)?t:e+`/`+t).split(`/`).filter(Boolean),o=r||t.endsWith(`/`),s=ut,c=`/`;for(;a.length>0;){let e=a.shift();if(!n.isDir(c)){if(!i){let t=n.isFile(c)||dt(n,c)?`Not a directory`:`No such file or directory`;return{path:c,error:t,rest:[e,...a]}}e===`..`?c=A(c):e!==`.`&&(c=gt(c,e));continue}if(e===`..`){c=A(c);continue}if(e!==`.`&&(c=gt(c,e)),!dt(n,c)||a.length===0&&!o)continue;if(s--===0)return{path:c,error:`Too many levels of symbolic links`,rest:[...a]};let t=n.readLink(c);c=t.startsWith(`/`)?`/`:A(c),a.unshift(...t.split(`/`).filter(Boolean),...t.endsWith(`/`)?[`.`]:[])}let l=!n.isDir(c)&&!n.isFile(c)&&!dt(n,c);return{path:c,error:l?`No such file or directory`:null,rest:[]}}var pt=(e,t,n,r=!0)=>n===``||n.includes(`\0`)?O(t,n):ft(t,n,e,{follow:r,lenient:!0}).path;function mt(e,t,n,r=k(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 i=ft(e,t,n);return i.rest.length>0?i.error:n.isDir(A(i.path))?null:`Not a directory`}function A(e){let t=lt(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n<0?`.`:n===0?`/`:t.slice(0,n)}function ht(e){let t=lt(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return t.slice(n+1)}function j(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 gt(e,t){return e===`/`?`/`+t:e+`/`+t}function _t(e,t){return e===`/`?t.slice(1):t.slice(e.length+1)}function vt(e,t,n=`reading them as text`){let r=$e(e);if(r===void 0)throw new T(`feature`,`binary file`,`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var yt=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>e===t[n]);function*bt(e,t,n=1/0,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:`file`,depth:0};return}if(!e.isDir(t)){dt(e,t)&&(yield{path:t,kind:`link`,depth:0});return}let i=[{path:t,kind:`dir`,depth:0}];for(;i.length;){let t=i.pop();if(yield t,t.kind!==`dir`||t.depth>=n||!r(t.path))continue;let{dirs:a,files:o,links:s=[]}=e.listDir(t.path),c=a.length-1,l=o.length-1,u=s.length-1;for(;c>=0||l>=0||u>=0;){let e=c>=0?`dir`:null,n=c>=0?a[c]:null;l>=0&&(n===null||j(o[l],n)>=0)&&(e=`file`,n=o[l]),u>=0&&(n===null||j(s[u],n)>=0)&&(e=`link`,n=s[u]),e===`dir`?c--:e===`file`?l--:u--,i.push({path:gt(t.path,n),kind:e,depth:t.depth+1})}}}function*xt(e,t){for(let n of bt(e,t))n.kind===`file`&&(yield n.path)}function St(e,t=`/`){let n=new De;try{n.mkdir(t,{recursive:!0})}catch(e){throw Tt(e,`mount ${JSON.stringify(t)}`)}let r={declared:new Map,made:new Set([`/`,t])};for(let[i,a]of Mt(e)){let e=String(i);if(e.includes(`\0`))throw TypeError(`createTerminal: source paths must not contain NUL characters`);let o=Ft(a,e),s=lt(`/`+e);Ct(n,r,t===`/`?s:s===`/`?t:t+s,o,e)}return At(n)}function Ct(e,t,n,r,i){let a=t.declared.get(n);if(a!==void 0){if(a===r.type&&Et(e,n,r))return;throw TypeError(`createTerminal: source ${JSON.stringify(i)} names the same path as an earlier source, which declared something else there`)}t.declared.set(n,r.type);let o=n.slice(0,n.lastIndexOf(`/`))||`/`;if(!t.made.has(o)){try{e.mkdir(o,{recursive:!0})}catch(e){throw e?.code===`ENOENT`?wt(i):Tt(e?.code===`EEXIST`?new y(`ENOTDIR`,o):e,`source ${JSON.stringify(i)}`)}if(e.realpath(o)!==o)throw wt(i);t.made.add(o)}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(t){if(t?.code!==`EEXIST`||e.lstat(n).type!==`directory`)throw t}t.made.add(n)}}catch(e){throw Tt(e,`source ${JSON.stringify(i)}`)}}var wt=e=>TypeError(`createTerminal: source ${JSON.stringify(e)} is declared through a symbolic link; declare it where the link leads`);function Tt(e,t){return e instanceof y?TypeError(`createTerminal: ${t}: ${e.message}`,{cause:e}):e}function Et(e,t,n){return n.type===`directory`?!0:n.type===`symlink`?e.readlink(t)===n.target:yt(e.readFile(t),typeof n.data==`string`?E(n.data):n.data)}var Dt={directory:`dirs`,file:`files`,symlink:`links`},Ot=e=>e.slice(0,e.lastIndexOf(`/`))||`/`,kt=()=>({dirs:[],files:[],links:[]});function At(e){let t=null,n=null,r={children:new Map,types:new Map},i=()=>n??=jt(e,o),a=new WeakMap,o=e=>t!==null&&(e===t||e.startsWith(t+`/`)),s=t=>{let n=r.children.get(t);if(n!==void 0)return n;n={listing:kt(),types:new Map};for(let r of e.readdir(t)){let{type:i}=e.lstat(gt(t,r));n.types.set(r,i),n.listing[Dt[i]].push(r)}return r.children.set(t,n),n},c=e=>{if(typeof e!=`string`||!e.startsWith(`/`))return;if(e===`/`)return`directory`;let t=[],n=e;for(;o(Ot(n))&&!r.types.has(n);)t.push(n),n=Ot(n);let a=o(Ot(n))?r.types.get(n):i().types.get(n)??``;for(let e=t.length-1;e>=0;e--){let n=t[e];a=a===`directory`?s(Ot(n)).types.get(n.slice(n.lastIndexOf(`/`)+1))??``:``,r.types.set(n,a)}return a||void 0},l=t=>c(t)===void 0?void 0:e.lstat(t),u=t=>c(t)===`file`?e.readFile(t):void 0,d={vfs:e,writableAt:e=>{t=e,n=null,r={children:new Map,types:new Map}},reshaped:()=>{r={children:new Map,types:new Map}},isFile:e=>c(e)===`file`,isDir:e=>c(e)===`directory`,isLink:e=>c(e)===`symlink`,readLink:t=>c(t)===`symlink`?e.readlink(t):void 0,readFile:e=>{let t=u(e),n=t&&a.get(t);return t&&n===void 0&&a.set(t,n=vt(t,JSON.stringify(e))),n},readBytes:e=>u(e),fileSize:e=>{let t=l(e);return t===void 0||t.type===`directory`?void 0:t.size},sameFileContents:(e,t)=>yt(u(e),u(t)),exactBytes:u,isBytes:e=>c(e)===`file`,isEmptyFile:e=>{let t=l(e);return t?.type===`file`&&t.size===0},listDir:e=>{if(c(e)!==`directory`)throw Error(`not a directory: ${e}`);return o(e)?s(e).listing:i().children.get(e)},walkFiles:e=>xt(d,e)};return d}function jt(e,t){let n=new Map([[`/`,kt()]]),r=new Map([[`/`,`directory`]]),i=[`/`];for(let{path:a,type:o,depth:s}of e.walk(`/`)){if(s===0)continue;let e=i[s-1];o===`directory`&&(i[s]=a),!t(e)&&(o===`directory`&&n.set(a,kt()),n.get(e)[Dt[o]].push(a.slice(e.length+(e===`/`?0:1))),r.set(a,o))}return{children:n,types:r}}function Mt(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}var Nt={file:[`data`],directory:[],symlink:[`target`]},Pt=new Set([`mode`,`mtime`]);function Ft(e,t){let n=JSON.stringify(t);if(typeof e==`string`)return{type:`file`,data:It(e,t)};if(ArrayBuffer.isView(e))return{type:`file`,data:Rt(e,t)};if(e instanceof ArrayBuffer)throw TypeError(`createTerminal: source ${n} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`createTerminal: source ${n} is ${e===null?`null`:Array.isArray(e)?`an array`:e===void 0?`undefined`:`a ${typeof e}`}; a source is text, a Uint8Array, or an object declaring its type`);if(e.format!==void 0)return{type:`file`,data:Lt(e,t)};let{type:r}=e;if(r===`link`)throw TypeError(`createTerminal: source ${n} declares type "link"; a symbolic link is declared as { type: 'symlink', target }`);if(r===`hardlink`)throw TypeError(`createTerminal: source ${n} declares a hard link, which is not supported: each file here has the one name`);if(r===void 0)throw TypeError(`createTerminal: source ${n} declares no type; an object declares { type: 'file' | 'directory' | 'symlink' } or { format: 'base64', data }`);if(!Object.hasOwn(Nt,r))throw TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(r)}; the types are 'file', 'directory' and 'symlink'`);for(let t of Object.keys(e))if(!(t===`type`||Nt[r].includes(t)))throw TypeError(Pt.has(t)?`createTerminal: source ${n} declares \`${t}\`, which this terminal does not keep yet`:`createTerminal: source ${n} declares \`${t}\`, which a ${r} does not have`);if(r===`directory`)return{type:r};if(r===`symlink`){let{target:t}=e;if(typeof t!=`string`||t===``||t.includes(`\0`))throw TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{type:r,target:t}}let{data:i=``}=e;if(typeof i==`string`)return{type:r,data:It(i,t)};if(ArrayBuffer.isView(i))return{type:r,data:Rt(i,t)};throw TypeError(`createTerminal: source ${n} declares \`data\` that is neither text nor a Uint8Array`)}function It(e,t){if(!e.isWellFormed())throw 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 Lt(e,t){let r=JSON.stringify(t);if(e.format!==`base64`)throw TypeError(`createTerminal: source ${r} declares format ${JSON.stringify(e.format)}; the only format is { format: 'base64', data }`);let i=Object.keys(e).find(e=>e!==`format`&&e!==`data`);if(i!==void 0)throw TypeError(`createTerminal: source ${r} declares \`${i}\`, which base64 contents do not have`);if(typeof e.data!=`string`)throw TypeError(`createTerminal: source ${r} must declare its base64 as a string in \`data\``);try{return n(e.data)}catch(e){throw e instanceof SyntaxError?TypeError(`createTerminal: source ${r} declares base64 that does not decode`,{cause:e}):e}}function Rt(e,t){if(e.BYTES_PER_ELEMENT!==1)throw 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 zt={__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_`},Bt={__proto__:null};for(let[e,t]of Object.entries(zt)){let n=RegExp(`[${t}]`,`u`),r=[];for(let e=0;e<128;e++){if(!n.test(String.fromCodePoint(e)))continue;let t=r.at(-1);t&&t[1]===e-1?t[1]=e:r.push([e,e])}Bt[e]=r}var Vt=32767;function Ht(e,t){if(e>Vt||t!==void 0&&t>Vt)throw Error(`Regular expression too big`)}function Ut(e,t,n=!1){let r=t+1;e[r]===`^`&&r++;let i=!0,a=!1;for(;r<e.length;){let t=e[r];if(t===`]`&&!i)return r;if(i=!1,t===`[`&&`:.=`.includes(e[r+1]??``)){let t=e[r+1],i=e.indexOf(t+`]`,r+2);if(i===-1)throw Error(`Unmatched [, [^, [:, [., or [=`);if(t===`:`&&!(e.slice(r+2,i)in zt))throw Error(`Invalid character class name`);if(t!==`:`&&n&&/\P{ASCII}/u.test(e.slice(r+2,i)))throw Error(`Invalid collation character`);r=i+2,a=t!==`.`;continue}if(t===`-`&&a&&r+1<e.length&&e[r+1]!==`]`)throw Error(`Invalid range end`);let o=t===`\\`&&r+1<e.length?2:1;if(e[r+o]===`-`&&e[r+o+1]!==void 0&&e[r+o+1]!==`]`){let t=r+o+1,i=e[t]===`[`?e[t+1]:void 0;if(i===`:`||i===`=`)throw Error(`Invalid range end`);let s=i===`.`?e.indexOf(`.]`,t+2):-1;if(i===`.`&&s===-1)throw Error(`Unmatched [, [^, [:, [., or [=`);let c=i===`.`?t+2:t+ +(e[t]===`\\`);if(n&&(e.codePointAt(r+o-1)>127||e.codePointAt(c)>127))throw Error(`Invalid collation character`);r=s===-1?t+(e[t]===`\\`?2:1):s+2,a=!0;continue}r+=o,a=!1}throw Error(`Unmatched [, [^, [:, [., or [=`)}function Wt(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let i=n.classes?n.classes.body(r[1]):zt[r[1]];if(i===void 0){if(n?.unknown!==`empty`)throw Error(`invalid character class \`[:${r[1]}:]\``);return{body:``,end:t+r[0].length}}return{body:i,end:t+r[0].length}}var Gt={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`},Kt=`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`,qt=`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`,M=`C.UTF-8`,Jt=`only the C.UTF-8 locale is supported`,Yt=e=>typeof e==`string`&&/^C\.UTF-?8$/iu.test(e),Xt=new Set([`LANG`,`LC_ALL`,`LC_CTYPE`]);function Zt(e){if(e.locale===void 0||Yt(e.locale))return M;throw TypeError(`createTerminal: ${Jt} (got ${JSON.stringify(e.locale)})`)}function Qt(e,t){if(!(Xt.has(e)?Yt(t)||e!==`LANG`&&t===``:Yt(t)||t===`C`||t===`POSIX`||t===``))throw new T(`feature`,e,`${e}: ${Jt}`)}var $t=e=>e===`C`||e===`POSIX`,en=e=>$t(e.locale);function tn(e){let t=[],n=-1;for(let r of e.split(`,`)){let[e,i]=r.split(`:`).map(e=>parseInt(e,36)),a=n+1+e;t.push([a,a+i]),n=a+i}return t}function nn(e){let t=e.findIndex(([e])=>e>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function rn(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 an=e=>e.map(([e,t])=>e===t?rn(e):`${rn(e)}-${rn(t)}`).join(``);function on(e,t){let n=e.length-1,r=0;for(;r<=n;){let i=r+n>>1;if(t<e[i][0])n=i-1;else if(t>e[i][1])r=i+1;else return!0}return!1}var sn=e=>e===`upper`||e===`lower`?`alpha`:e,cn=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],ln=/[\u1C80-\u1C88]/u;function un(e){let t=new Map;for(let n of e.split(`,`)){let[e,r,i,a]=n.split(`:`).map(e=>parseInt(e,36));for(let n=0;n<r;n++)t.set(e+n*a,e+n*a+i)}return t}var dn=(e,t)=>({up:e,low:t,folds:new Map});function fn(){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 dn(e,t)}function pn(e){let t=[];for(let[n,r]of e.sort((e,t)=>e[0]-t[0])){let e=t.at(-1);e&&n<=e[1]+1?e[1]=Math.max(e[1],r):t.push([n,r])}return t}function mn(e){let t=`[${e}]`;return{"<":`(?<!${t})(?=${t})`,">":`(?<=${t})(?!${t})`,boundary:`(?:(?<!${t})(?=${t})|(?<=${t})(?!${t}))`,inside:`(?:(?<=${t})(?=${t})|(?<!${t})(?!${t}))`}}function hn(e,t,n,r,i){let a=new Map,o=new Map,s=null,c=e=>(o.has(e)||o.set(e,n(e)),o.get(e)),l=()=>s??=i(),u={name:e,multibyte:t,ranges:c,body(e){return a.has(e)||a.set(e,r(e,c(e))),a.get(e)},has(e,t){let n=c(e);return n!==void 0&&on(n,t)},assertions(){if(u.js)return u.js;let e=u.body(`space`);return u.js={__proto__:null,...mn(u.body(`word`)),word:`[${u.body(`word`)}]`,nonWord:`[^${u.body(`word`)}]`,space:`[${e}]`,nonSpace:`[^${e}]`},u.js},up:e=>l().up.get(e)??e,low:e=>l().low.get(e)??e,fold(e){let{folds:t}=l(),n=t.get(e);if(n===void 0){let r=u.up(e),i=u.low(r),a=new Set([e,r]);i!==r&&u.up(i)===r&&a.add(i);for(let e of cn)u.up(e)===r&&a.add(e);n=[...a].sort((e,t)=>e-t),t.set(e,n)}return n},foldRange(e,t){let{up:n}=l(),r=n.get(e)??e,i=n.get(t)??t;if(r>i)return null;let a=[],o=[];for(let[e,t]of n){let n=e>=r&&e<=i;n!==(t>=r&&t<=i)&&(n?a:o).push(e)}let s=[],c=r;for(let e of a.sort((e,t)=>e-t))e>c&&s.push([c,e-1]),c=e+1;return c<=i&&s.push([c,i]),pn([...s,...o.map(e=>[e,e])])}};return u}var gn=hn(`C`,!1,e=>Bt[e],e=>zt[e],fn),_n=hn(M,!0,e=>e===`word`?nn(tn(Gt.alnum)):Object.hasOwn(Gt,e)?tn(Gt[e]):void 0,(e,t)=>t===void 0?void 0:an(t),()=>dn(un(Kt),un(qt)));function vn(e){if(e===M)return _n;if($t(e))return gn;throw new T(`feature`,`locale`,`matching in the ${e} locale is not supported`)}var yn=(1n<<63n)-1n,bn=-yn-1n,xn=(1n<<64n)-1n;function N(e,t,n,r){let i=k(e.cwd,n,e.fs,r);return P(e,t,n,i.error),i}function P(e,t,n,r){if(r!==`No such file or directory`||typeof n!=`string`)return;let i=n.startsWith(`/`),a=i?`/`:e.cwd,o=n.replace(/^\/+/u,``),s=new Set;for(let t of new Set([`/`,e.mount??`/`,e.home??`/`])){if(t===a)continue;let n=k(t,o,e.fs);n.error||s.add(n.path)}if(!s.size)return;let c=i?``:` from cwd ${JSON.stringify(e.cwd)}`,l=`${i?`absolute`:`relative`} path ${JSON.stringify(n)} was not found${c}`;e.notes?.add(`${t}: ${l}. ${Sn(e,s)}`)}function Sn(e,t){let n=[...t].sort(j),r=n.map(e=>JSON.stringify(e));if(n.length===1)return`A ${e.fs.isDir(n[0])?`dir`:`file`} exists at ${r[0]}.`;let i=n.every(t=>!e.fs.isDir(t)&&e.fs.isFile(t))&&n.some(t=>!e.fs.sameFileContents(n[0],t)),a=`${r.slice(0,-1).join(`, `)} and ${r.at(-1)}`;return`${n.length===2?`Both`:`All`} of ${a} exist${i?`, and they differ in contents`:``}.`}function Cn(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(`.`)&&e.add(O(t,r))},emit(t,n,r,i=``){kn(t,{command:n,action:`omitted`,noun:[`hidden entry`,`hidden entries`],explanation:r,context:i,paths:e})}}}var wn=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function Tn(e,t){for(let n of t.split(`
4
- `))wn.test(n)&&e.discarded?.add(n)}function En(e,t,n){let r=new Map;for(let i of e){if(t.includes(i))continue;let{command:e,operand:a,reason:o}=wn.exec(i).groups,s=/'([^']*)'$/u.exec(a)?.[1]??a;if([...n].some(e=>e.includes(JSON.stringify(s))))continue;let c=`${e}: ${o}`;r.has(c)||r.set(c,new Set),r.get(c).add(s)}return[...r].map(([e,t])=>`${e}: ${[...t].map(e=>JSON.stringify(e)).join(`, `)}.`)}function Dn(e,t){return e===`status`?null:{name:t,search:e===`search`}}function On(){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`,i=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.${i}`)}e=null,t=0}}}function kn(e,t){An(e,t,t.paths.size,t.paths)}function An(e,{command:t,action:n,noun:r,explanation:i=``,context:a=``},o,s){if(!o)return;let c=o<10?`: `+[...s].sort(j).map(e=>JSON.stringify(e)).join(`, `):``,l=Array.isArray(r)?r[o===1?0:1]:r;e.add(`${t}: ${n} ${o} ${l}${a}${c}.${i?` `+i:``}`)}function jn(e,t=`
5
- `){if(e===``)return[];let n=e.split(t);return n.at(-1)===``&&n.pop(),n}function Mn(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 Nn=(e,t=`
7
- `)=>e.length===0?``:e.join(t)+t;function Pn(e,t=`
8
- `){let n=[];for(let r=0;r<e.length;){let i=e.indexOf(t,r),a=i<0?e.length:i+t.length;n.push(e.slice(r,a)),r=a}return n}var Fn=e=>e.stdinTerminal===!0,In=e=>(e.outputFds?.[1]===`out`||e.outputFds?.[1]===`err`)&&!e.substitutionDepth;function F(e,t=``,n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&vt(e.stdinBytes,Gn(null,e)),e.stdinLeft=t,e.stdinBytes=r}function Ln(e,t,n,r=``,i={}){let a=[],o=``,s=r,c=i.read??`text`,l=c===`bytes`||c===`loose-bytes`,u=l?`bytes`:`content`,d=e=>l?c===`loose-bytes`?p(e):E(e):e,f=(e,t)=>{if(l){e.bytes=Bn(n.fs,t,c===`loose-bytes`);return}if(c===`text`||n.fs.isBytes?.(t)!==!0){e.content=n.fs.readFile(t);return}e.bytes=n.fs.readBytes(t),e.content=c===`maybe-text`?$e(e.bytes):void 0};for(let p of t){let t={name:p,[u]:d(``),kind:`file`},m;if(p===`/dev/stdin`&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),t[u]=d(n.stdinOrigin);else if(p===`-`||p===`/dev/stdin`){let i=s===r?n.stdinBytes??null:null;Object.assign(t,i===null?Un(s,c,l):Wn(i,c,l,e,n)),t.shared=!0,s=``,F(n,``,!0)}else if(p!==`/dev/null`){let r=N(n,e,p);r.error?(t.kind=`missing`,m=r.error):n.fs.isDir(r.path)?(t.kind=`dir`,i.noRead||(m=`Is a directory`)):f(t,r.path)}if(a.push(t),m&&(o+=t.failure=zn(e,p,m,t.kind===`dir`)),t.kind!==`file`&&(i.stopOnError||t.kind===`dir`&&i.stopOnDir))break}return{inputs:a.filter(e=>e.kind===`file`),entries:a,stderr:o,failed:o!==``}}var Rn={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 zn(e,t,n,r=!1){let i=Rn[e]?.[+!!r];return`${e}: ${i?i.replace(/%[sr]/gu,e=>e===`%s`?t:n):`${t}: ${n}`}
9
- `}function Bn(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let i=e.readFile(t);if(i!==void 0)return n?p(i):E(i)}function Vn(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 Hn(e,t,n,r,i){if(t.length===0){let t=r.stdinBytes??null;F(r,``,!0);let a=i?.read,o=a===`bytes`||a===`loose-bytes`,s=[{name:null,kind:`file`,...t===null?Un(n,a,o):Wn(t,a,o,e,r)}];return{inputs:s,entries:s,stderr:``,failed:!1}}return Ln(e,t,r,n,i)}var Un=(e,t,n)=>n?{bytes:t===`loose-bytes`?p(e):E(e)}:{content:e};function Wn(e,t,n,r,i){return n||t===`as-held`?{bytes:e}:t===`maybe-text`?{bytes:e,content:$e(e)}:{content:vt(e,Gn(null,i))}}function Gn(e,t){return e===null||e===`-`||e===`/dev/stdin`?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):`standard input`:JSON.stringify(k(t.cwd,e,t.fs).path??e)}function Kn(e,t,n,r){let i=Hn(e,t,n,r);return{content:i.inputs.map(e=>e.content).join(``),stderr:i.stderr,failed:i.failed}}var I=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:+!!t.failed});function qn(e,t,n=e,{max:r=1/0,digitsOnly:i=!1}={}){if(typeof e!=`string`||!(i?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:x(`${t}: invalid count: ${n}`)};let a=Number(e);return a>r?{error:x(`${t}: out of range: ${n}`)}:{value:Math.min(a,2**53-1)}}function Jn(e,t){if(typeof e!=`string`)return{error:x(`${t}: invalid count: ${e}`)};let n=e[0]===`+`||e[0]===`-`?e[0]:``,r=n===`-`?e.slice(1):e,i=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),a=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!i&&!a)return{error:x(`${t}: invalid count: ${e}`)};let o=i?.[2]??(a?r:``),s=Yn(BigInt(i?.[1]??`1`),o,t,e);return s.error?s:{...s,sign:n}}function Yn(e,t,n,r){let i=1n;t===`b`?i=512n:t&&(i=(t.length===2?1000n:1024n)**BigInt(`KMGTPEZYRQ`.indexOf(t[0].toUpperCase())+1));let a=e*i;return a>xn?{error:x(`${n}: count out of range: ${r}`)}:{value:Number(a>BigInt(2**53-1)?BigInt(2**53-1):a)}}function L(e){try{let t=e?.message;return typeof t==`string`&&t!==``?t:String(e)}catch{return`threw a value with no message`}}var R=e=>e===`/tmp`||e.startsWith(`/tmp/`),Xn=new Uint8Array;function Zn(e){e.vfs.mkdir(`/tmp`,{recursive:!0}),e.writableAt(`/tmp`);let t=Qn(e),n=e=>t.observer?.read(t.identity(e)??e),r={...e,observeIo:e=>{t.observer=e},fileIdentity:t.identity,readIdentity:n=>(t.observer?.read(n),D(er(e.vfs,n))),readFile:t=>(n(t),e.readFile(t)),readBytes:t=>(n(t),e.readBytes(t)),openWritable:(e,n,i=!1)=>tr(r,t,e,n,i),makeWritableDir:(e,n)=>nr(r,t,e,n),makeWritableLink:(e,n,i)=>rr(r,t,e,n,i),removeWritableDir:(e,n)=>sr(r,t,e,n),copyWritable:(e,n,i)=>ir(r,t,e,n,i),replaceWritable:(e,n,i,a)=>ar(r,t,e,n,i,a),removeWritable:(e,n)=>or(r,t,e,n)};return r}function Qn(e){let{vfs:t}=e,n=new Map;return{base:e,vfs:t,observer:void 0,identity:r=>{if(!R(String(r))||!e.isFile(r))return;let{ino:i}=t.lstat(r),a=n.get(i);return a===void 0&&n.set(i,a={path:t.realpath(r),detached:void 0}),a},leaving:r=>{let i=e.isFile(r)?t.lstat(r).ino:void 0,a=n.get(i);return a&&{cell:a,ino:i,bytes:t.readFile(r)}},release:e=>{e&&(e.cell.detached=e.bytes,n.delete(e.ino))},change:(t,n)=>{try{return n()}catch(e){throw e instanceof y?ur(t,$n(e.code)):e}finally{e.reshaped()}}}}var $n=e=>new y(e,``).message.slice(2),er=(e,t)=>t.detached??e.readFile(t.path);function tr(e,t,n,r,i){let a=pt(e,n,r);if(!R(a))return null;cr(e,n,r);let o=t.identity(a);return o===void 0?(t.change(r,()=>t.vfs.writeFile(a,Xn)),o=t.identity(a)):i||(t.observer?.write(o),t.vfs.writeFile(a,Xn)),dr(t.vfs,a,o,i,()=>t.observer?.write(o))}function nr(e,t,n,r){let i=pt(e,n,r,!1);if(!R(i))return!1;if(e.isDir(i))return!0;if(cr(e,n,r),e.isFile(i)||e.isLink(i))throw Error(`${r}: File exists`);return t.change(r,()=>t.vfs.mkdir(i)),!0}function rr(e,t,n,r,i){let a=pt(e,n,r,!1);return a.startsWith(`/tmp/`)?(lr(e,n,r),t.change(r,()=>t.vfs.symlink(i,a)),!0):!1}function ir(e,t,n,r,i){let a=pt(e,n,i);if(!a.startsWith(`/tmp/`))return!1;cr(e,n,i);let o=t.identity(r);if(r===a||o!==void 0&&o===t.identity(a))throw Error(`source and destination are the same file`);return t.observer?.read(o??r),e.openWritable(n,i).writeBytes(t.base.readBytes(r)),!0}function ar(e,t,n,r,i,a){let o=pt(e,n,r,!1),s=a===void 0?null:pt(e,n,a,!1);if(!o.startsWith(`/tmp/`)||s!==null&&!s.startsWith(`/tmp/`))return!1;if(cr(e,n,r),!e.isFile(o)&&!e.isLink(o))throw ur(r,`No such file or directory`);s!==null&&cr(e,n,a);let c=E(i),{vfs:l}=t;return t.change(r,()=>{if(s!==null&&s!==o){let e=t.leaving(o),n=t.leaving(s);l.rename(o,s),t.release(n),e&&(e.cell.path=s)}else{let e=t.leaving(o);l.unlink(o),t.release(e)}l.writeFile(o,c)}),!0}function or(e,t,n,r){if(!R(pt(e,n,r,!1)))return!1;let i=k(n,r,e,{follow:!1});if(i.error)throw ur(r,i.error);if(e.isDir(i.path))throw Error(`${r}: Is a directory`);if(!R(i.path))return!1;let a=t.leaving(i.path);return t.change(r,()=>t.vfs.unlink(i.path)),t.release(a),!0}function sr(e,t,n,r){if(!R(pt(e,n,r,!1)))return!1;let i=k(n,r,e);if(i.error)throw ur(r,i.error);if(!R(i.path)||!e.isDir(i.path))throw Error(`${r}: Not a directory`);if(i.path===`/tmp`)throw Error(`${r}: Device or resource busy`);let{dirs:a,files:o,links:s}=e.listDir(i.path);if(a.length||o.length||s.length)throw Error(`${r}: Directory not empty`);return t.change(r,()=>t.vfs.rmdir(i.path)),!0}function cr(e,t,n){let r=ft(t,n,e);if(r.error===null){if(e.isDir(r.path))throw Error(`${n}: Is a directory`);if(n.endsWith(`/`))throw ur(n,`Not a directory`);return}if(r.rest.length>0||n.endsWith(`/`)||n.includes(`\0`))throw ur(n,r.error);if(!e.isDir(A(r.path)))throw ur(n,`No such file or directory`)}function lr(e,t,n){if(n===``||n.includes(`\0`))throw ur(n,`No such file or directory`);let r=ft(t,n,e,{follow:!1});if(r.error===null)throw ur(n,`File exists`);if(r.rest.length>0||n.endsWith(`/`))throw ur(n,r.error);if(!e.isDir(A(r.path)))throw ur(n,`Not a directory`)}function ur(e,t){return Object.assign(Error(`${e}: ${t}`),{path:e,fsError:t})}function dr(e,t,n,r,i){let a=0,o=t=>{let i=er(e,n),o=r?i.length:a;n.detached===void 0?o===i.length?e.appendFile(n.path,t):e.writeFile(n.path,fr(i,o,t)):n.detached=fr(i,o,t),a=o+t.length};return{path:t,identity:n,get position(){return r?er(e,n).length:a},write(e){e!==``&&(i(),o(E(e)))},writeBytes(e){e.length!==0&&(i(),o(e))}}}function fr(e,t,n){let r=Math.max(e.length,t+n.length),i=t===e.length&&e.byteOffset+r<=e.buffer.byteLength,a=i?new Uint8Array(e.buffer,e.byteOffset,r):new Uint8Array(Math.max(r,e.length*2)).subarray(0,r);return i||a.set(e),a.set(n,t),a}var pr=[`cwd`,`home`,`user`,`inherit`];function mr(e,t){let n=gr(t,`mount`,`/`),r=gr(t,`home`,n),i=gr(t,`cwd`,n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!==`/tmp/`)throw TypeError(`createTerminal: writable must be '/tmp/', false, or undefined`);let a=t.writable===`/tmp/`;if(a&&(n===`/`||n===`/tmp`||n.startsWith(`/tmp/`)))throw Error(`createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'`);let o=St(e,n);return{fs:a?Zn(o):o,cwd:i,home:r,mount:n,writable:a,locale:Zt(t)}}function hr(e,t){if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`fork: options must be an object (got ${t===null?`null`:Array.isArray(t)?`an array`:typeof t})`);for(let e of Object.keys(t))if(!pr.includes(e))throw Error(`fork: unknown option \`${e}\` (known: ${pr.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 TypeError(`fork: inherit must be true or false (got ${t.inherit===null?`null`:typeof t.inherit})`);return{cwd:gr(t,`cwd`,e.cwd,`fork`,e.cwd),home:gr(t,`home`,e.home,`fork`,e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function gr(e,t,n,r=`createTerminal`,i=`/`){let a=e[t]===void 0?n:e[t];if(typeof a!=`string`||a.includes(`\0`))throw TypeError(`${r}: ${t} must be a string without NUL characters`);return O(i,a)}function _r(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(e=>e>=t&&e<=n).map(e=>e-t)}:{}}}function vr(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(e=>e<t[0].length)?null:{name:t[1],end:t[0].length}}var yr=(e,t)=>e.mask===null?`0`:e.mask[t];function br(e,t=!1){let n=new Set;if(!e.value.includes(`~`))return n;let r=e.value,i=t=>yr(e,t)===`0`,a=t?null:vr(e)?.end??null,o=e=>t===!0||a!==null&&e>=a;for(let s=0;s<r.length;s++){let c=s===0||s===a||o(s)&&r[s-1]===`:`&&i(s-1),l=o(s)||t===`parameterAssign`;if(!c||r[s]!==`~`||!i(s)||!xr(e,s,l))continue;let u=r[s+1];if(u&&u!==`/`&&u!==`:`&&i(s+1))throw new T(`feature`,`tilde prefix`,`named-user and directory-stack tilde prefixes are not supported`);(u===void 0||i(s+1)&&(u===`/`||u===`:`&&l))&&n.add(s)}return n}function xr(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(yr(e,r)!==`0`)return!1;if(e.value[r]===`/`||n&&e.value[r]===`:`)return!0}return!0}function Sr(...e){let t=``,n=``,r=[];for(let i of e){for(let e of i.empty??[])r.push(t.length+e);t+=i.value,n+=i.mask??`0`.repeat(i.value.length)}return{value:t,mask:e.every(e=>e.mask===null)?null:n,...r.length?{empty:r}:{}}}var Cr=64;function wr(e,t){let n=``;for(let r=t+1;r<e.length;r++){let i=e[r];if(i==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(i!==`\\`){n+=i;continue}let a=e[r+1];if(a==="`")throw new T(`feature`,"\\`","nested backtick command substitution is not supported; use `$( )` instead");if(a===`$`||a===`\\`){n+=a,r++;continue}if(a===`
10
- `){r++;continue}n+=i}throw Error(`unterminated backtick substitution`)}var Tr=()=>({value:``,quoted:!1,started:!1}),Er=()=>new T(`feature`,`command substitution depth`,`command substitution nesting above ${Cr} is not supported`);function Dr(e,t,n,r,i){if(r>=Cr)throw Er();let a={line:e,i:n+1,depth:r,helpers:i,parens:0,quote:null,word:Tr(),command:!0,target:null,heredocs:[]};for(;a.i<e.length;)if(Ar(a))return{raw:e.slice(t,a.i+1),command:e.slice(n+1,a.i)};throw a.quote?Error(`unterminated ${a.quote===`'`?`single`:`double`} quote`):Error(`unterminated command substitution`)}function Or(e,t,n=!1){e.word.value+=t,e.word.quoted||=n,e.word.started=!0}function kr(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 T(`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=Tr()}}function Ar(e){let{line:t,i:n,quote:r}=e,i=t[n];if(r&&i===r)return e.quote=null,e.word.quoted=!0,e.i++,!1;if(r===`'`)return Or(e,i,!0),e.i++,!1;if(i===`\\`)return jr(e),!1;if(i===`$`)return Mr(e),!1;if(i==="`")return Nr(e),!1;if(r)return Or(e,i,!0),e.i++,!1;if(i===`'`||i===`"`)return e.quote=i,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 r=e.helpers.readConditional(t,n,e.helpers,e.depth+e.parens+1);return e.i+=r.raw.length,e.command=!1,!1}if(i===`#`&&!e.word.started){let r=t.indexOf(`
3
+ `,exitCode:t}),Ge=(e,t=1)=>x(`usage: ${e}`,t),Ke=Symbol(`unsupported`);function S(e){if(e==null)return null;try{return e[Ke]??null}catch{return null}}function C(e,t,n,r,i=1){return w(x(r,i),e,t,n,r)}function w(e,t,n,r,i){return Object.defineProperty(e,Ke,{value:{kind:t,command:n,detail:r,message:i},enumerable:!1,configurable:!0}),e}function qe(e,t,n,r){let i=S(e);return i?C(i.kind,t,i.detail,n,r):x(n,r)}var T=class extends Error{constructor(e,t,n){super(n),this.name=`UnsupportedError`,w(this,e,null,t,n)}};function Je(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let i=JSON.stringify([n.kind,r,n.detail]);e.has(i)||(e.add(i),t.push(Object.freeze(n)))}}}function E(e){try{return f(e)}catch(e){throw e instanceof TypeError?new T(`feature`,`unpaired surrogate`,`unpaired UTF-16 surrogates cannot be encoded as UTF-8`):e}}var Ye=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Xe(e){for(let t=0;t<e.length;){let n=rt[e[t]],r=n===1?e[t]:n===0?-1:Qe(e,t,n);yield r,t+=r<0?1:n}}var Ze=[0,0,128,2048,65536];function Qe(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let i=1;i<n;i++){if((e[t+i]&192)!=128)return-1;r=r<<6|e[t+i]&63}return r<Ze[n]||r>1114111||r>=55296&&r<=57343?-1:r}var $e=e=>h(e);function et(e){let t;try{t=m(e)}catch{}return t}function tt(e){let t=et(e);if(t!==void 0)return t;let n=new Uint16Array(e.length),r=0;for(let t=0;t<e.length;){let i=rt[e[t]],a=i===1?e[t]:i===0?-1:Qe(e,t,i);if(a<0){n[r++]=56320+e[t++];continue}a>65535?(n[r++]=55232+(a>>10),n[r++]=56320+(a&1023)):n[r++]=a,t+=i}let i=``;for(let e=0;e<r;e+=nt)i+=String.fromCharCode.apply(null,n.subarray(e,Math.min(r,e+nt)));return i}var nt=4096,rt=Uint8Array.from({length:256},(e,t)=>Ye(t)),it=`\\uDC80-\\uDCFF`,at=RegExp(`[${it}]`,`u`),ot=e=>e>=56448&&e<=56575;function st(e){if(!at.test(e))return E(e);let t=new Uint8Array(e.length*3),n=0;for(let r=0;r<e.length;r++){let i=e.codePointAt(r);if(i<128)t[n++]=i;else if(ot(i))t[n++]=i-56320;else if(i<2048)n=ct(t,n,192|i>>6,i,1);else if(i<65536){if(i>=55296&&i<=57343)return E(e);n=ct(t,n,224|i>>12,i,2)}else n=ct(t,n,240|i>>18,i,3),r++}return t.slice(0,n)}function ct(e,t,n,r,i){e[t++]=n;for(let n=i-1;n>=0;n--)e[t++]=128|r>>6*n&63;return t}function lt(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function D(e){try{return m(e)}catch{throw new T(`feature`,`partial UTF-8 byte sequence`,`byte output that is not valid UTF-8 cannot be represented by this string-based terminal`)}}function ut(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(Boolean),r=[];for(let e of n)if(e!==`.`){if(e===`..`){r.length>0&&r.at(-1)!==`..`?r.pop():t||r.push(`..`);continue}r.push(e)}return t?`/`+r.join(`/`):r.length===0?`.`:r.join(`/`)}function O(e,t){return t.startsWith(`/`)?ut(t):ut(e+`/`+t)}var dt=40,ft=(e,t)=>e.isLink?.(t)===!0;function k(e,t,n,{follow:r=!0}={}){let i=pt(e,t,n,{follow:r});return i.error?{path:null,error:i.error}:t.endsWith(`/`)&&!n.isDir(i.path)?{path:null,error:`Not a directory`}:{path:i.path,error:null}}function pt(e,t,n,{follow:r=!0,lenient:i=!1}={}){if(t===``||t.includes(`\0`))return{path:`/`,error:`No such file or directory`,rest:[]};let a=(t.startsWith(`/`)?t:e+`/`+t).split(`/`).filter(Boolean),o=r||t.endsWith(`/`),s=dt,c=`/`;for(;a.length>0;){let e=a.shift();if(!n.isDir(c)){if(!i){let t=n.isFile(c)||ft(n,c)?`Not a directory`:`No such file or directory`;return{path:c,error:t,rest:[e,...a]}}e===`..`?c=A(c):e!==`.`&&(c=_t(c,e));continue}if(e===`..`){c=A(c);continue}if(e!==`.`&&(c=_t(c,e)),!ft(n,c)||a.length===0&&!o)continue;if(s--===0)return{path:c,error:`Too many levels of symbolic links`,rest:[...a]};let t=n.readLink(c);c=t.startsWith(`/`)?`/`:A(c),a.unshift(...t.split(`/`).filter(Boolean),...t.endsWith(`/`)?[`.`]:[])}let l=!n.isDir(c)&&!n.isFile(c)&&!ft(n,c);return{path:c,error:l?`No such file or directory`:null,rest:[]}}var mt=(e,t,n,r=!0)=>n===``||n.includes(`\0`)?O(t,n):pt(t,n,e,{follow:r,lenient:!0}).path;function ht(e,t,n,r=k(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 i=pt(e,t,n);return i.rest.length>0?i.error:n.isDir(A(i.path))?null:`Not a directory`}function A(e){let t=ut(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n<0?`.`:n===0?`/`:t.slice(0,n)}function gt(e){let t=ut(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return t.slice(n+1)}function j(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 _t(e,t){return e===`/`?`/`+t:e+`/`+t}function vt(e,t){return e===`/`?t.slice(1):t.slice(e.length+1)}function yt(e,t,n=`reading them as text`){let r=et(e);if(r===void 0)throw new T(`feature`,`binary file`,`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var bt=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>e===t[n]);function*xt(e,t,n=1/0,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:`file`,depth:0};return}if(!e.isDir(t)){ft(e,t)&&(yield{path:t,kind:`link`,depth:0});return}let i=[{path:t,kind:`dir`,depth:0}];for(;i.length;){let t=i.pop();if(yield t,t.kind!==`dir`||t.depth>=n||!r(t.path))continue;let{dirs:a,files:o,links:s=[]}=e.listDir(t.path),c=a.length-1,l=o.length-1,u=s.length-1;for(;c>=0||l>=0||u>=0;){let e=c>=0?`dir`:null,n=c>=0?a[c]:null;l>=0&&(n===null||j(o[l],n)>=0)&&(e=`file`,n=o[l]),u>=0&&(n===null||j(s[u],n)>=0)&&(e=`link`,n=s[u]),e===`dir`?c--:e===`file`?l--:u--,i.push({path:_t(t.path,n),kind:e,depth:t.depth+1})}}}function*St(e,t){for(let n of xt(e,t))n.kind===`file`&&(yield n.path)}function Ct(e,t=`/`){let n=new De;try{n.mkdir(t,{recursive:!0})}catch(e){throw Et(e,`mount ${JSON.stringify(t)}`)}let r={declared:new Map,made:new Set([`/`,t])};for(let[i,a]of Nt(e)){let e=String(i);if(e.includes(`\0`))throw TypeError(`createTerminal: source paths must not contain NUL characters`);let o=It(a,e),s=ut(`/`+e);wt(n,r,t===`/`?s:s===`/`?t:t+s,o,e)}return jt(n)}function wt(e,t,n,r,i){let a=t.declared.get(n);if(a!==void 0){if(a===r.type&&Dt(e,n,r))return;throw TypeError(`createTerminal: source ${JSON.stringify(i)} names the same path as an earlier source, which declared something else there`)}t.declared.set(n,r.type);let o=n.slice(0,n.lastIndexOf(`/`))||`/`;if(!t.made.has(o)){try{e.mkdir(o,{recursive:!0})}catch(e){throw e?.code===`ENOENT`?Tt(i):Et(e?.code===`EEXIST`?new y(`ENOTDIR`,o):e,`source ${JSON.stringify(i)}`)}if(e.realpath(o)!==o)throw Tt(i);t.made.add(o)}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(t){if(t?.code!==`EEXIST`||e.lstat(n).type!==`directory`)throw t}t.made.add(n)}}catch(e){throw Et(e,`source ${JSON.stringify(i)}`)}}var Tt=e=>TypeError(`createTerminal: source ${JSON.stringify(e)} is declared through a symbolic link; declare it where the link leads`);function Et(e,t){return e instanceof y?TypeError(`createTerminal: ${t}: ${e.message}`,{cause:e}):e}function Dt(e,t,n){return n.type===`directory`?!0:n.type===`symlink`?e.readlink(t)===n.target:bt(e.readFile(t),typeof n.data==`string`?E(n.data):n.data)}var Ot={directory:`dirs`,file:`files`,symlink:`links`},kt=e=>e.slice(0,e.lastIndexOf(`/`))||`/`,At=()=>({dirs:[],files:[],links:[]});function jt(e){let t=null,n=null,r={children:new Map,types:new Map},i=()=>n??=Mt(e,o),a=new WeakMap,o=e=>t!==null&&(e===t||e.startsWith(t+`/`)),s=t=>{let n=r.children.get(t);if(n!==void 0)return n;n={listing:At(),types:new Map};for(let r of e.readdir(t)){let{type:i}=e.lstat(_t(t,r));n.types.set(r,i),n.listing[Ot[i]].push(r)}return r.children.set(t,n),n},c=e=>{if(typeof e!=`string`||!e.startsWith(`/`))return;if(e===`/`)return`directory`;let t=[],n=e;for(;o(kt(n))&&!r.types.has(n);)t.push(n),n=kt(n);let a=o(kt(n))?r.types.get(n):i().types.get(n)??``;for(let e=t.length-1;e>=0;e--){let n=t[e];a=a===`directory`?s(kt(n)).types.get(n.slice(n.lastIndexOf(`/`)+1))??``:``,r.types.set(n,a)}return a||void 0},l=t=>c(t)===void 0?void 0:e.lstat(t),u=t=>c(t)===`file`?e.readFile(t):void 0,d={vfs:e,writableAt:e=>{t=e,n=null,r={children:new Map,types:new Map}},reshaped:()=>{r={children:new Map,types:new Map}},isFile:e=>c(e)===`file`,isDir:e=>c(e)===`directory`,isLink:e=>c(e)===`symlink`,readLink:t=>c(t)===`symlink`?e.readlink(t):void 0,readFile:e=>{let t=u(e),n=t&&a.get(t);return t&&n===void 0&&a.set(t,n=yt(t,JSON.stringify(e))),n},readBytes:e=>u(e),fileSize:e=>{let t=l(e);return t===void 0||t.type===`directory`?void 0:t.size},sameFileContents:(e,t)=>bt(u(e),u(t)),exactBytes:u,isBytes:e=>c(e)===`file`,isEmptyFile:e=>{let t=l(e);return t?.type===`file`&&t.size===0},listDir:e=>{if(c(e)!==`directory`)throw Error(`not a directory: ${e}`);return o(e)?s(e).listing:i().children.get(e)},walkFiles:e=>St(d,e)};return d}function Mt(e,t){let n=new Map([[`/`,At()]]),r=new Map([[`/`,`directory`]]),i=[`/`];for(let{path:a,type:o,depth:s}of e.walk(`/`)){if(s===0)continue;let e=i[s-1];o===`directory`&&(i[s]=a),!t(e)&&(o===`directory`&&n.set(a,At()),n.get(e)[Ot[o]].push(a.slice(e.length+(e===`/`?0:1))),r.set(a,o))}return{children:n,types:r}}function Nt(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}var Pt={file:[`data`],directory:[],symlink:[`target`]},Ft=new Set([`mode`,`mtime`]);function It(e,t){let n=JSON.stringify(t);if(typeof e==`string`)return{type:`file`,data:Lt(e,t)};if(ArrayBuffer.isView(e))return{type:`file`,data:zt(e,t)};if(e instanceof ArrayBuffer)throw TypeError(`createTerminal: source ${n} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`createTerminal: source ${n} is ${e===null?`null`:Array.isArray(e)?`an array`:e===void 0?`undefined`:`a ${typeof e}`}; a source is text, a Uint8Array, or an object declaring its type`);if(e.format!==void 0)return{type:`file`,data:Rt(e,t)};let{type:r}=e;if(r===`link`)throw TypeError(`createTerminal: source ${n} declares type "link"; a symbolic link is declared as { type: 'symlink', target }`);if(r===`hardlink`)throw TypeError(`createTerminal: source ${n} declares a hard link, which is not supported: each file here has the one name`);if(r===void 0)throw TypeError(`createTerminal: source ${n} declares no type; an object declares { type: 'file' | 'directory' | 'symlink' } or { format: 'base64', data }`);if(!Object.hasOwn(Pt,r))throw TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(r)}; the types are 'file', 'directory' and 'symlink'`);for(let t of Object.keys(e))if(!(t===`type`||Pt[r].includes(t)))throw TypeError(Ft.has(t)?`createTerminal: source ${n} declares \`${t}\`, which this terminal does not keep yet`:`createTerminal: source ${n} declares \`${t}\`, which a ${r} does not have`);if(r===`directory`)return{type:r};if(r===`symlink`){let{target:t}=e;if(typeof t!=`string`||t===``||t.includes(`\0`))throw TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{type:r,target:t}}let{data:i=``}=e;if(typeof i==`string`)return{type:r,data:Lt(i,t)};if(ArrayBuffer.isView(i))return{type:r,data:zt(i,t)};throw TypeError(`createTerminal: source ${n} declares \`data\` that is neither text nor a Uint8Array`)}function Lt(e,t){if(!e.isWellFormed())throw 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 Rt(e,t){let n=JSON.stringify(t);if(e.format!==`base64`)throw TypeError(`createTerminal: source ${n} declares format ${JSON.stringify(e.format)}; the only format is { format: 'base64', data }`);let r=Object.keys(e).find(e=>e!==`format`&&e!==`data`);if(r!==void 0)throw TypeError(`createTerminal: source ${n} declares \`${r}\`, which base64 contents do not have`);if(typeof e.data!=`string`)throw TypeError(`createTerminal: source ${n} must declare its base64 as a string in \`data\``);try{return a(e.data)}catch(e){throw e instanceof SyntaxError?TypeError(`createTerminal: source ${n} declares base64 that does not decode`,{cause:e}):e}}function zt(e,t){if(e.BYTES_PER_ELEMENT!==1)throw 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 Bt={__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_`},Vt={__proto__:null};for(let[e,t]of Object.entries(Bt)){let n=RegExp(`[${t}]`,`u`),r=[];for(let e=0;e<128;e++){if(!n.test(String.fromCodePoint(e)))continue;let t=r.at(-1);t&&t[1]===e-1?t[1]=e:r.push([e,e])}Vt[e]=r}var Ht=32767;function Ut(e,t){if(e>Ht||t!==void 0&&t>Ht)throw Error(`Regular expression too big`)}function Wt(e,t,n=!1){let r=t+1;e[r]===`^`&&r++;let i=!0,a=!1;for(;r<e.length;){let t=e[r];if(t===`]`&&!i)return r;if(i=!1,t===`[`&&`:.=`.includes(e[r+1]??``)){let t=e[r+1],i=e.indexOf(t+`]`,r+2);if(i===-1)throw Error(`Unmatched [, [^, [:, [., or [=`);if(t===`:`&&!(e.slice(r+2,i)in Bt))throw Error(`Invalid character class name`);if(t!==`:`&&n&&/\P{ASCII}/u.test(e.slice(r+2,i)))throw Error(`Invalid collation character`);r=i+2,a=t!==`.`;continue}if(t===`-`&&a&&r+1<e.length&&e[r+1]!==`]`)throw Error(`Invalid range end`);let o=t===`\\`&&r+1<e.length?2:1;if(e[r+o]===`-`&&e[r+o+1]!==void 0&&e[r+o+1]!==`]`){let t=r+o+1,i=e[t]===`[`?e[t+1]:void 0;if(i===`:`||i===`=`)throw Error(`Invalid range end`);let s=i===`.`?e.indexOf(`.]`,t+2):-1;if(i===`.`&&s===-1)throw Error(`Unmatched [, [^, [:, [., or [=`);let c=i===`.`?t+2:t+ +(e[t]===`\\`);if(n&&(e.codePointAt(r+o-1)>127||e.codePointAt(c)>127))throw Error(`Invalid collation character`);r=s===-1?t+(e[t]===`\\`?2:1):s+2,a=!0;continue}r+=o,a=!1}throw Error(`Unmatched [, [^, [:, [., or [=`)}function Gt(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let i=n.classes?n.classes.body(r[1]):Bt[r[1]];if(i===void 0){if(n?.unknown!==`empty`)throw Error(`invalid character class \`[:${r[1]}:]\``);return{body:``,end:t+r[0].length}}return{body:i,end:t+r[0].length}}var Kt={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`},qt=`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`,Jt=`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`,M=`C.UTF-8`,Yt=`only the C.UTF-8 locale is supported`,Xt=e=>typeof e==`string`&&/^C\.UTF-?8$/iu.test(e),Zt=new Set([`LANG`,`LC_ALL`,`LC_CTYPE`]);function Qt(e){if(e.locale===void 0||Xt(e.locale))return M;throw TypeError(`createTerminal: ${Yt} (got ${JSON.stringify(e.locale)})`)}function $t(e,t){if(!(Zt.has(e)?Xt(t)||e!==`LANG`&&t===``:Xt(t)||t===`C`||t===`POSIX`||t===``))throw new T(`feature`,e,`${e}: ${Yt}`)}var en=e=>e===`C`||e===`POSIX`,tn=e=>en(e.locale);function nn(e){let t=[],n=-1;for(let r of e.split(`,`)){let[e,i]=r.split(`:`).map(e=>parseInt(e,36)),a=n+1+e;t.push([a,a+i]),n=a+i}return t}function rn(e){let t=e.findIndex(([e])=>e>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function an(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 on=e=>e.map(([e,t])=>e===t?an(e):`${an(e)}-${an(t)}`).join(``);function sn(e,t){let n=e.length-1,r=0;for(;r<=n;){let i=r+n>>1;if(t<e[i][0])n=i-1;else if(t>e[i][1])r=i+1;else return!0}return!1}var cn=e=>e===`upper`||e===`lower`?`alpha`:e,ln=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],un=/[\u1C80-\u1C88]/u;function dn(e){let t=new Map;for(let n of e.split(`,`)){let[e,r,i,a]=n.split(`:`).map(e=>parseInt(e,36));for(let n=0;n<r;n++)t.set(e+n*a,e+n*a+i)}return t}var fn=(e,t)=>({up:e,low:t,folds:new Map});function pn(){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 fn(e,t)}function mn(e){let t=[];for(let[n,r]of e.sort((e,t)=>e[0]-t[0])){let e=t.at(-1);e&&n<=e[1]+1?e[1]=Math.max(e[1],r):t.push([n,r])}return t}function hn(e){let t=`[${e}]`;return{"<":`(?<!${t})(?=${t})`,">":`(?<=${t})(?!${t})`,boundary:`(?:(?<!${t})(?=${t})|(?<=${t})(?!${t}))`,inside:`(?:(?<=${t})(?=${t})|(?<!${t})(?!${t}))`}}function gn(e,t,n,r,i){let a=new Map,o=new Map,s=null,c=e=>(o.has(e)||o.set(e,n(e)),o.get(e)),l=()=>s??=i(),u={name:e,multibyte:t,ranges:c,body(e){return a.has(e)||a.set(e,r(e,c(e))),a.get(e)},has(e,t){let n=c(e);return n!==void 0&&sn(n,t)},assertions(){if(u.js)return u.js;let e=u.body(`space`);return u.js={__proto__:null,...hn(u.body(`word`)),word:`[${u.body(`word`)}]`,nonWord:`[^${u.body(`word`)}]`,space:`[${e}]`,nonSpace:`[^${e}]`},u.js},up:e=>l().up.get(e)??e,low:e=>l().low.get(e)??e,fold(e){let{folds:t}=l(),n=t.get(e);if(n===void 0){let r=u.up(e),i=u.low(r),a=new Set([e,r]);i!==r&&u.up(i)===r&&a.add(i);for(let e of ln)u.up(e)===r&&a.add(e);n=[...a].sort((e,t)=>e-t),t.set(e,n)}return n},foldRange(e,t){let{up:n}=l(),r=n.get(e)??e,i=n.get(t)??t;if(r>i)return null;let a=[],o=[];for(let[e,t]of n){let n=e>=r&&e<=i;n!==(t>=r&&t<=i)&&(n?a:o).push(e)}let s=[],c=r;for(let e of a.sort((e,t)=>e-t))e>c&&s.push([c,e-1]),c=e+1;return c<=i&&s.push([c,i]),mn([...s,...o.map(e=>[e,e])])}};return u}var _n=gn(`C`,!1,e=>Vt[e],e=>Bt[e],pn),vn=gn(M,!0,e=>e===`word`?rn(nn(Kt.alnum)):Object.hasOwn(Kt,e)?nn(Kt[e]):void 0,(e,t)=>t===void 0?void 0:on(t),()=>fn(dn(qt),dn(Jt)));function yn(e){if(e===M)return vn;if(en(e))return _n;throw new T(`feature`,`locale`,`matching in the ${e} locale is not supported`)}var bn=(1n<<63n)-1n,xn=-bn-1n,Sn=(1n<<64n)-1n;function N(e,t,n,r){let i=k(e.cwd,n,e.fs,r);return P(e,t,n,i.error),i}function P(e,t,n,r){if(r!==`No such file or directory`||typeof n!=`string`)return;let i=n.startsWith(`/`),a=i?`/`:e.cwd,o=n.replace(/^\/+/u,``),s=new Set;for(let t of new Set([`/`,e.mount??`/`,e.home??`/`])){if(t===a)continue;let n=k(t,o,e.fs);n.error||s.add(n.path)}if(!s.size)return;let c=i?``:` from cwd ${JSON.stringify(e.cwd)}`,l=`${i?`absolute`:`relative`} path ${JSON.stringify(n)} was not found${c}`;e.notes?.add(`${t}: ${l}. ${Cn(e,s)}`)}function Cn(e,t){let n=[...t].sort(j),r=n.map(e=>JSON.stringify(e));if(n.length===1)return`A ${e.fs.isDir(n[0])?`dir`:`file`} exists at ${r[0]}.`;let i=n.every(t=>!e.fs.isDir(t)&&e.fs.isFile(t))&&n.some(t=>!e.fs.sameFileContents(n[0],t)),a=`${r.slice(0,-1).join(`, `)} and ${r.at(-1)}`;return`${n.length===2?`Both`:`All`} of ${a} 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(O(t,r))},emit(t,n,r,i=``){An(t,{command:n,action:`omitted`,noun:[`hidden entry`,`hidden entries`],explanation:r,context:i,paths:e})}}}var Tn=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function En(e,t){for(let n of t.split(`
4
+ `))Tn.test(n)&&e.discarded?.add(n)}function Dn(e,t,n){let r=new Map;for(let i of e){if(t.includes(i))continue;let{command:e,operand:a,reason:o}=Tn.exec(i).groups,s=/'([^']*)'$/u.exec(a)?.[1]??a;if([...n].some(e=>e.includes(JSON.stringify(s))))continue;let c=`${e}: ${o}`;r.has(c)||r.set(c,new Set),r.get(c).add(s)}return[...r].map(([e,t])=>`${e}: ${[...t].map(e=>JSON.stringify(e)).join(`, `)}.`)}function On(e,t){return e===`status`?null:{name:t,search:e===`search`}}function kn(){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`,i=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.${i}`)}e=null,t=0}}}function An(e,t){jn(e,t,t.paths.size,t.paths)}function jn(e,{command:t,action:n,noun:r,explanation:i=``,context:a=``},o,s){if(!o)return;let c=o<10?`: `+[...s].sort(j).map(e=>JSON.stringify(e)).join(`, `):``,l=Array.isArray(r)?r[o===1?0:1]:r;e.add(`${t}: ${n} ${o} ${l}${a}${c}.${i?` `+i:``}`)}function Mn(e,t=`
5
+ `){if(e===``)return[];let n=e.split(t);return n.at(-1)===``&&n.pop(),n}function Nn(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 Pn=(e,t=`
7
+ `)=>e.length===0?``:e.join(t)+t;function Fn(e,t=`
8
+ `){let n=[];for(let r=0;r<e.length;){let i=e.indexOf(t,r),a=i<0?e.length:i+t.length;n.push(e.slice(r,a)),r=a}return n}var In=e=>e.stdinTerminal===!0,Ln=e=>(e.outputFds?.[1]===`out`||e.outputFds?.[1]===`err`)&&!e.substitutionDepth;function F(e,t=``,n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&yt(e.stdinBytes,Kn(null,e)),e.stdinLeft=t,e.stdinBytes=r}function Rn(e,t,n,r=``,i={}){let a=[],o=``,s=r,c=i.read??`text`,l=c===`bytes`||c===`loose-bytes`,u=l?`bytes`:`content`,d=e=>l?c===`loose-bytes`?p(e):E(e):e,f=(e,t)=>{if(l){e.bytes=Vn(n.fs,t,c===`loose-bytes`);return}if(c===`text`||n.fs.isBytes?.(t)!==!0){e.content=n.fs.readFile(t);return}e.bytes=n.fs.readBytes(t),e.content=c===`maybe-text`?et(e.bytes):void 0};for(let p of t){let t={name:p,[u]:d(``),kind:`file`},m;if(p===`/dev/stdin`&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),t[u]=d(n.stdinOrigin);else if(p===`-`||p===`/dev/stdin`){let i=s===r?n.stdinBytes??null:null;Object.assign(t,i===null?Wn(s,c,l):Gn(i,c,l,e,n)),t.shared=!0,s=``,F(n,``,!0)}else if(p!==`/dev/null`){let r=N(n,e,p);r.error?(t.kind=`missing`,m=r.error):n.fs.isDir(r.path)?(t.kind=`dir`,i.noRead||(m=`Is a directory`)):f(t,r.path)}if(a.push(t),m&&(o+=t.failure=Bn(e,p,m,t.kind===`dir`)),t.kind!==`file`&&(i.stopOnError||t.kind===`dir`&&i.stopOnDir))break}return{inputs:a.filter(e=>e.kind===`file`),entries:a,stderr:o,failed:o!==``}}var zn={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 Bn(e,t,n,r=!1){let i=zn[e]?.[+!!r];return`${e}: ${i?i.replace(/%[sr]/gu,e=>e===`%s`?t:n):`${t}: ${n}`}
9
+ `}function Vn(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let i=e.readFile(t);if(i!==void 0)return n?p(i):E(i)}function Hn(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:et(n),bytes:n}}function Un(e,t,n,r,i){if(t.length===0){let t=r.stdinBytes??null;F(r,``,!0);let a=i?.read,o=a===`bytes`||a===`loose-bytes`,s=[{name:null,kind:`file`,...t===null?Wn(n,a,o):Gn(t,a,o,e,r)}];return{inputs:s,entries:s,stderr:``,failed:!1}}return Rn(e,t,r,n,i)}var Wn=(e,t,n)=>n?{bytes:t===`loose-bytes`?p(e):E(e)}:{content:e};function Gn(e,t,n,r,i){return n||t===`as-held`?{bytes:e}:t===`maybe-text`?{bytes:e,content:et(e)}:{content:yt(e,Kn(null,i))}}function Kn(e,t){return e===null||e===`-`||e===`/dev/stdin`?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):`standard input`:JSON.stringify(k(t.cwd,e,t.fs).path??e)}function qn(e,t,n,r){let i=Un(e,t,n,r);return{content:i.inputs.map(e=>e.content).join(``),stderr:i.stderr,failed:i.failed}}var Jn=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:+!!t.failed});function Yn(e,t,n=e,{max:r=1/0,digitsOnly:i=!1}={}){if(typeof e!=`string`||!(i?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:x(`${t}: invalid count: ${n}`)};let a=Number(e);return a>r?{error:x(`${t}: out of range: ${n}`)}:{value:Math.min(a,2**53-1)}}function Xn(e,t){if(typeof e!=`string`)return{error:x(`${t}: invalid count: ${e}`)};let n=e[0]===`+`||e[0]===`-`?e[0]:``,r=n===`-`?e.slice(1):e,i=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),a=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!i&&!a)return{error:x(`${t}: invalid count: ${e}`)};let o=i?.[2]??(a?r:``),s=Zn(BigInt(i?.[1]??`1`),o,t,e);return s.error?s:{...s,sign:n}}function Zn(e,t,n,r){let i=1n;t===`b`?i=512n:t&&(i=(t.length===2?1000n:1024n)**BigInt(`KMGTPEZYRQ`.indexOf(t[0].toUpperCase())+1));let a=e*i;return a>Sn?{error:x(`${n}: count out of range: ${r}`)}:{value:Number(a>BigInt(2**53-1)?BigInt(2**53-1):a)}}function I(e){try{let t=e?.message;return typeof t==`string`&&t!==``?t:String(e)}catch{return`threw a value with no message`}}var L=e=>e===`/tmp`||e.startsWith(`/tmp/`),Qn=new Uint8Array;function $n(e){e.vfs.mkdir(`/tmp`,{recursive:!0}),e.writableAt(`/tmp`);let t=er(e),n=e=>t.observer?.read(t.identity(e)??e),r={...e,observeIo:e=>{t.observer=e},fileIdentity:t.identity,readIdentity:n=>(t.observer?.read(n),D(nr(e.vfs,n))),readFile:t=>(n(t),e.readFile(t)),readBytes:t=>(n(t),e.readBytes(t)),openWritable:(e,n,i=!1)=>rr(r,t,e,n,i),makeWritableDir:(e,n)=>ir(r,t,e,n),makeWritableLink:(e,n,i)=>ar(r,t,e,n,i),removeWritableDir:(e,n)=>lr(r,t,e,n),copyWritable:(e,n,i)=>or(r,t,e,n,i),replaceWritable:(e,n,i,a)=>sr(r,t,e,n,i,a),removeWritable:(e,n)=>cr(r,t,e,n)};return r}function er(e){let{vfs:t}=e,n=new Map;return{base:e,vfs:t,observer:void 0,identity:r=>{if(!L(String(r))||!e.isFile(r))return;let{ino:i}=t.lstat(r),a=n.get(i);return a===void 0&&n.set(i,a={path:t.realpath(r),detached:void 0}),a},leaving:r=>{let i=e.isFile(r)?t.lstat(r).ino:void 0,a=n.get(i);return a&&{cell:a,ino:i,bytes:t.readFile(r)}},release:e=>{e&&(e.cell.detached=e.bytes,n.delete(e.ino))},change:(t,n)=>{try{return n()}catch(e){throw e instanceof y?fr(t,tr(e.code)):e}finally{e.reshaped()}}}}var tr=e=>new y(e,``).message.slice(2),nr=(e,t)=>t.detached??e.readFile(t.path);function rr(e,t,n,r,i){let a=mt(e,n,r);if(!L(a))return null;ur(e,n,r);let o=t.identity(a);return o===void 0?(t.change(r,()=>t.vfs.writeFile(a,Qn)),o=t.identity(a)):i||(t.observer?.write(o),t.vfs.writeFile(a,Qn)),pr(t.vfs,a,o,i,()=>t.observer?.write(o))}function ir(e,t,n,r){let i=mt(e,n,r,!1);if(!L(i))return!1;if(e.isDir(i))return!0;if(ur(e,n,r),e.isFile(i)||e.isLink(i))throw Error(`${r}: File exists`);return t.change(r,()=>t.vfs.mkdir(i)),!0}function ar(e,t,n,r,i){let a=mt(e,n,r,!1);return a.startsWith(`/tmp/`)?(dr(e,n,r),t.change(r,()=>t.vfs.symlink(i,a)),!0):!1}function or(e,t,n,r,i){let a=mt(e,n,i);if(!a.startsWith(`/tmp/`))return!1;ur(e,n,i);let o=t.identity(r);if(r===a||o!==void 0&&o===t.identity(a))throw Error(`source and destination are the same file`);return t.observer?.read(o??r),e.openWritable(n,i).writeBytes(t.base.readBytes(r)),!0}function sr(e,t,n,r,i,a){let o=mt(e,n,r,!1),s=a===void 0?null:mt(e,n,a,!1);if(!o.startsWith(`/tmp/`)||s!==null&&!s.startsWith(`/tmp/`))return!1;if(ur(e,n,r),!e.isFile(o)&&!e.isLink(o))throw fr(r,`No such file or directory`);s!==null&&ur(e,n,a);let c=E(i),{vfs:l}=t;return t.change(r,()=>{if(s!==null&&s!==o){let e=t.leaving(o),n=t.leaving(s);l.rename(o,s),t.release(n),e&&(e.cell.path=s)}else{let e=t.leaving(o);l.unlink(o),t.release(e)}l.writeFile(o,c)}),!0}function cr(e,t,n,r){if(!L(mt(e,n,r,!1)))return!1;let i=k(n,r,e,{follow:!1});if(i.error)throw fr(r,i.error);if(e.isDir(i.path))throw Error(`${r}: Is a directory`);if(!L(i.path))return!1;let a=t.leaving(i.path);return t.change(r,()=>t.vfs.unlink(i.path)),t.release(a),!0}function lr(e,t,n,r){if(!L(mt(e,n,r,!1)))return!1;let i=k(n,r,e);if(i.error)throw fr(r,i.error);if(!L(i.path)||!e.isDir(i.path))throw Error(`${r}: Not a directory`);if(i.path===`/tmp`)throw Error(`${r}: Device or resource busy`);let{dirs:a,files:o,links:s}=e.listDir(i.path);if(a.length||o.length||s.length)throw Error(`${r}: Directory not empty`);return t.change(r,()=>t.vfs.rmdir(i.path)),!0}function ur(e,t,n){let r=pt(t,n,e);if(r.error===null){if(e.isDir(r.path))throw Error(`${n}: Is a directory`);if(n.endsWith(`/`))throw fr(n,`Not a directory`);return}if(r.rest.length>0||n.endsWith(`/`)||n.includes(`\0`))throw fr(n,r.error);if(!e.isDir(A(r.path)))throw fr(n,`No such file or directory`)}function dr(e,t,n){if(n===``||n.includes(`\0`))throw fr(n,`No such file or directory`);let r=pt(t,n,e,{follow:!1});if(r.error===null)throw fr(n,`File exists`);if(r.rest.length>0||n.endsWith(`/`))throw fr(n,r.error);if(!e.isDir(A(r.path)))throw fr(n,`Not a directory`)}function fr(e,t){return Object.assign(Error(`${e}: ${t}`),{path:e,fsError:t})}function pr(e,t,n,r,i){let a=0,o=t=>{let i=nr(e,n),o=r?i.length:a;n.detached===void 0?o===i.length?e.appendFile(n.path,t):e.writeFile(n.path,mr(i,o,t)):n.detached=mr(i,o,t),a=o+t.length};return{path:t,identity:n,get position(){return r?nr(e,n).length:a},write(e){e!==``&&(i(),o(E(e)))},writeBytes(e){e.length!==0&&(i(),o(e))}}}function mr(e,t,n){let r=Math.max(e.length,t+n.length),i=t===e.length&&e.byteOffset+r<=e.buffer.byteLength,a=i?new Uint8Array(e.buffer,e.byteOffset,r):new Uint8Array(Math.max(r,e.length*2)).subarray(0,r);return i||a.set(e),a.set(n,t),a}var hr=[`cwd`,`home`,`user`,`inherit`];function gr(e,t){let n=vr(t,`mount`,`/`),r=vr(t,`home`,n),i=vr(t,`cwd`,n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!==`/tmp/`)throw TypeError(`createTerminal: writable must be '/tmp/', false, or undefined`);let a=t.writable===`/tmp/`;if(a&&(n===`/`||n===`/tmp`||n.startsWith(`/tmp/`)))throw Error(`createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'`);let o=Ct(e,n);return{fs:a?$n(o):o,cwd:i,home:r,mount:n,writable:a,locale:Qt(t)}}function _r(e,t){if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`fork: options must be an object (got ${t===null?`null`:Array.isArray(t)?`an array`:typeof t})`);for(let e of Object.keys(t))if(!hr.includes(e))throw Error(`fork: unknown option \`${e}\` (known: ${hr.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 TypeError(`fork: inherit must be true or false (got ${t.inherit===null?`null`:typeof t.inherit})`);return{cwd:vr(t,`cwd`,e.cwd,`fork`,e.cwd),home:vr(t,`home`,e.home,`fork`,e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function vr(e,t,n,r=`createTerminal`,i=`/`){let a=e[t]===void 0?n:e[t];if(typeof a!=`string`||a.includes(`\0`))throw TypeError(`${r}: ${t} must be a string without NUL characters`);return O(i,a)}function yr(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(e=>e>=t&&e<=n).map(e=>e-t)}:{}}}function br(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(e=>e<t[0].length)?null:{name:t[1],end:t[0].length}}var xr=(e,t)=>e.mask===null?`0`:e.mask[t];function Sr(e,t=!1){let n=new Set;if(!e.value.includes(`~`))return n;let r=e.value,i=t=>xr(e,t)===`0`,a=t?null:br(e)?.end??null,o=e=>t===!0||a!==null&&e>=a;for(let s=0;s<r.length;s++){let c=s===0||s===a||o(s)&&r[s-1]===`:`&&i(s-1),l=o(s)||t===`parameterAssign`;if(!c||r[s]!==`~`||!i(s)||!Cr(e,s,l))continue;let u=r[s+1];if(u&&u!==`/`&&u!==`:`&&i(s+1))throw new T(`feature`,`tilde prefix`,`named-user and directory-stack tilde prefixes are not supported`);(u===void 0||i(s+1)&&(u===`/`||u===`:`&&l))&&n.add(s)}return n}function Cr(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(xr(e,r)!==`0`)return!1;if(e.value[r]===`/`||n&&e.value[r]===`:`)return!0}return!0}function wr(...e){let t=``,n=``,r=[];for(let i of e){for(let e of i.empty??[])r.push(t.length+e);t+=i.value,n+=i.mask??`0`.repeat(i.value.length)}return{value:t,mask:e.every(e=>e.mask===null)?null:n,...r.length?{empty:r}:{}}}var Tr=64;function Er(e,t){let n=``;for(let r=t+1;r<e.length;r++){let i=e[r];if(i==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(i!==`\\`){n+=i;continue}let a=e[r+1];if(a==="`")throw new T(`feature`,"\\`","nested backtick command substitution is not supported; use `$( )` instead");if(a===`$`||a===`\\`){n+=a,r++;continue}if(a===`
10
+ `){r++;continue}n+=i}throw Error(`unterminated backtick substitution`)}var Dr=()=>({value:``,quoted:!1,started:!1}),Or=()=>new T(`feature`,`command substitution depth`,`command substitution nesting above ${Tr} is not supported`);function kr(e,t,n,r,i){if(r>=Tr)throw Or();let a={line:e,i:n+1,depth:r,helpers:i,parens:0,quote:null,word:Dr(),command:!0,target:null,heredocs:[]};for(;a.i<e.length;)if(Mr(a))return{raw:e.slice(t,a.i+1),command:e.slice(n+1,a.i)};throw a.quote?Error(`unterminated ${a.quote===`'`?`single`:`double`} quote`):Error(`unterminated command substitution`)}function Ar(e,t,n=!1){e.word.value+=t,e.word.quoted||=n,e.word.started=!0}function jr(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 T(`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=Dr()}}function Mr(e){let{line:t,i:n,quote:r}=e,i=t[n];if(r&&i===r)return e.quote=null,e.word.quoted=!0,e.i++,!1;if(r===`'`)return Ar(e,i,!0),e.i++,!1;if(i===`\\`)return Nr(e),!1;if(i===`$`)return Pr(e),!1;if(i==="`")return Fr(e),!1;if(r)return Ar(e,i,!0),e.i++,!1;if(i===`'`||i===`"`)return e.quote=i,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 r=e.helpers.readConditional(t,n,e.helpers,e.depth+e.parens+1);return e.i+=r.raw.length,e.command=!1,!1}if(i===`#`&&!e.word.started){let r=t.indexOf(`
11
11
  `,n);return e.i=r===-1?t.length:r,!1}if(i===`
12
- `)return Fr(e),!1;if(i===` `||i===` `)return kr(e),e.i++,!1;let a;try{a=e.helpers.readOperator(t,n,!e.word.started)}catch(t){if(!(t instanceof T))throw t;return e.i++,!1}return a?Pr(e,a):(Or(e,i),e.i++,!1)}function jr(e){let t=e.line[e.i+1];if(t===`
13
- `){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(Or(e,t,!0),e.i+=2):(Or(e,`\\`,!!e.quote),e.i++)}function Mr(e){let{line:t,i:n}=e,r=e.helpers.skipContinuations(t,n+1);if(!e.quote&&t[r]===`'`){let n=e.helpers.decodeAnsiC(t,r+1);Or(e,n.text,!0),e.i=n.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??`$`;Or(e,i,!!e.quote),e.i+=i.length}function Nr(e){let t=e.i++;for(;e.i<e.line.length;){let n=e.line[e.i++];if(n==="`"){Or(e,e.line.slice(t,e.i),!!e.quote);return}n===`\\`&&e.i<e.line.length&&e.i++}throw Error(`unterminated backtick substitution`)}function Pr(e,t){kr(e);let n=t.token;if(n.kind===`paren_close`){if(e.parens===0){if(e.heredocs.length)throw new T(`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>=Cr)throw Er();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 Fr(e){if(kr(e),e.heredocs.some(e=>e.delim===null))throw 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 Ir(e){return Number.isInteger(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)}var Lr=e=>e>65535?2:1,Rr=(e,t)=>Lr(e.codePointAt(t)),zr=e=>`(?:^|(?<=[^]))(?:${e})`,Br=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])(?![\s\S])/u,Vr=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])/u;function Hr(e,t=`unsupported or malformed parameter expansion`){return new T(`feature`,"${",`${t}: \${${e}}`)}var Ur=e=>/^[0-9]+$/u.test(e)?e.replace(/^0+(?=[0-9])/u,``):e;function Wr(e){let t=e.replaceAll(`\\
14
- `,``);if(t.startsWith(`#`)&&t.length>1&&Br.test(t.slice(1)))return{name:Ur(t.slice(1)),operator:`length`};if(/^#[A-Za-z_0-9]/u.test(t))throw Hr(e);let n=Vr.exec(t)?.[0];if(!n)throw Hr(e);let r=t.slice(n.length);if(!r)return{name:Ur(n),operator:``};if(n===`#`&&/^[%:=+/]$/u.test(r))throw Hr(e);let i=/^(?::[-+=?]|[-+=?]|##?|%%?|:|\/\/?)/u.exec(r)?.[0];if(!i)throw Hr(e);return{name:Ur(n),operator:i,word:e.slice(Gr(e,n.length+i.length))}}function Gr(e,t){let n=0;for(;t>0;)e[n]===`\\`&&e[n+1]===`
15
- `?n+=2:(t--,n++);return n}var Kr=(e,t)=>new T(`feature`,e,t),qr=e=>{if(e>=64)throw Kr(`expansion depth`,`shell expansion nesting above 64 levels is not supported`)};function Jr(e,t,n,r,i,a){qr(r);let o=n+1,s=null;for(let n=o;n<e.length;n++){let c=e[n];if(s===`'`){c===`'`&&(s=null);continue}if(c===`\\`){n++;continue}if(c===`"`){s=s===`"`?null:`"`;continue}if(c===`'`&&!s){s=`'`;continue}if(c==="`")throw Kr("`",`command substitution (backticks) is not supported`);if(c===`$`){let t=n+1;for(;e[t]===`\\`&&e[t+1]===`
16
- `;)t+=2;if(e[t]===`'`&&!s){let r=a.decodeAnsiC(e,t+1),s=Wr(e.slice(o,n)).operator;if(i&&/[-+?=]/u.test(s)&&/[$`"'\\}]/u.test(r.text))throw Kr("${",`active characters in ANSI-C quoted parameter operands are not supported`);n=r.end-1;continue}let c=a.readExpansion(e,n,r+1,i||s===`"`);if(c){n+=c.raw.length-1;continue}}if(c===`}`&&!s){let r=Wr(e.slice(o,n));return{raw:e.slice(t,n+1),parameter:r}}}throw Kr("${",`unterminated parameter expansion`)}function Yr(e,t,n,r,i){qr(r);let a=0;for(let o=n+1;o<e.length;o++){let s=e[o];if(s===`\\`){o++;continue}if(s===`$`){let t=i.readExpansion(e,o,r+1,!0);if(t){o+=t.raw.length-1;continue}}if(s==="`")throw Kr("`",`command substitution (backticks) is not supported`);if(s===`"`||s===`'`)throw Kr(`$((`,`quotes in arithmetic expressions are not supported`);if(s===`(`&&a++,s!==`)`)continue;if(a){a--;continue}let c=o+1;for(;e[c]===`\\`&&e[c+1]===`
17
- `;)c+=2;if(e[c]!==`)`)throw Kr(`$((`,"arithmetic expansion requires a closing `))`");return{raw:e.slice(t,c+1),arithmetic:e.slice(n+1,o)}}throw Kr(`$((`,`unterminated arithmetic expansion`)}var Xr=/^-[abcdefghknoprstuvwxzGLNORS]$/u,Zr=new Set([`=`,`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`]),Qr=new Set([`end`,`&&`,`||`,`)`]),$r=/^[A-Za-z_][A-Za-z0-9_]*$/u;function ei(e,t,n,r=0){let i={line:e,i:t+2,helpers:n,token:null,depth:0,terms:0,removed:0,expansionDepth:r};try{si(i,!0);let n=ti(i);return i.token.kind!==`end`&&ai(`unexpected token \`${i.token.value??i.token.kind}\``),{raw:e.slice(t,i.i+i.removed),expression:n}}catch(e){if(e instanceof T||e.conditional)throw e;ai(e.message)}}function ti(e){let t=ni(e);for(;e.token.kind===`||`;)si(e,!0),t={kind:`or`,left:t,right:ni(e)};return t}function ni(e){let t=ri(e);for(;e.token.kind===`&&`;)si(e,!0),t={kind:`and`,left:t,right:ri(e)};return t}function ri(e){if(++e.terms>128)throw new T(`feature`,`[[ complexity`,`conditional expressions above 128 terms are not supported`);if(++e.depth>64)throw new T(`feature`,`[[ nesting`,`conditional nesting above 64 levels is not supported`);try{let t=e.token;if(t.kind===`(`){si(e,!0);let t=ti(e);return e.token.kind!==`)`&&ai("expected `)`"),si(e,!0),t}if(ii(t,`!`))return si(e,!0),{kind:`not`,expression:ri(e)};if(t.kind!==`word`&&ai(`expected an operand`),si(e),!t.quoted&&Xr.test(t.value)){let n=oi(e);return si(e,!0),{kind:`unary`,op:t.value,word:n}}if(Qr.has(e.token.kind))return{kind:`unary`,op:`-n`,word:t};let n=e.token;if((n.quoted||!Zr.has(n.value))&&ai(`conditional binary operator expected`),n.value===`=~`)throw new T(`feature`,`[[ =~`,`regular expression comparisons in [[ are not supported`);si(e);let r=oi(e);return si(e,!0),{kind:`binary`,op:n.value,left:t,right:r}}finally{e.depth--}}var ii=(e,t)=>e.kind===`word`&&!e.quoted&&e.value===t,ai=e=>{throw Object.assign(Error(`[[ ${e}`),{conditional:!0})};function oi(e){return e.token.kind!==`word`&&ai(`expected an operand`),e.token}function si(e,t=!1){if(e.token=ci(e),t)for(;e.token.kind===`newline`;)e.token=ci(e)}function ci(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 Lr(e),!1;if(i===` `||i===` `)return jr(e),e.i++,!1;let a;try{a=e.helpers.readOperator(t,n,!e.word.started)}catch(t){if(!(t instanceof T))throw t;return e.i++,!1}return a?Ir(e,a):(Ar(e,i),e.i++,!1)}function Nr(e){let t=e.line[e.i+1];if(t===`
13
+ `){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(Ar(e,t,!0),e.i+=2):(Ar(e,`\\`,!!e.quote),e.i++)}function Pr(e){let{line:t,i:n}=e,r=e.helpers.skipContinuations(t,n+1);if(!e.quote&&t[r]===`'`){let n=e.helpers.decodeAnsiC(t,r+1);Ar(e,n.text,!0),e.i=n.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??`$`;Ar(e,i,!!e.quote),e.i+=i.length}function Fr(e){let t=e.i++;for(;e.i<e.line.length;){let n=e.line[e.i++];if(n==="`"){Ar(e,e.line.slice(t,e.i),!!e.quote);return}n===`\\`&&e.i<e.line.length&&e.i++}throw Error(`unterminated backtick substitution`)}function Ir(e,t){jr(e);let n=t.token;if(n.kind===`paren_close`){if(e.parens===0){if(e.heredocs.length)throw new T(`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>=Tr)throw Or();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 Lr(e){if(jr(e),e.heredocs.some(e=>e.delim===null))throw 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 Rr(e){return Number.isInteger(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)}var zr=e=>e>65535?2:1,Br=(e,t)=>zr(e.codePointAt(t)),Vr=e=>`(?:^|(?<=[^]))(?:${e})`,Hr=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])(?![\s\S])/u,Ur=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])/u;function Wr(e,t=`unsupported or malformed parameter expansion`){return new T(`feature`,"${",`${t}: \${${e}}`)}var Gr=e=>/^[0-9]+$/u.test(e)?e.replace(/^0+(?=[0-9])/u,``):e;function Kr(e){let t=e.replaceAll(`\\
14
+ `,``);if(t.startsWith(`#`)&&t.length>1&&Hr.test(t.slice(1)))return{name:Gr(t.slice(1)),operator:`length`};if(/^#[A-Za-z_0-9]/u.test(t))throw Wr(e);let n=Ur.exec(t)?.[0];if(!n)throw Wr(e);let r=t.slice(n.length);if(!r)return{name:Gr(n),operator:``};if(n===`#`&&/^[%:=+/]$/u.test(r))throw Wr(e);let i=/^(?::[-+=?]|[-+=?]|##?|%%?|:|\/\/?)/u.exec(r)?.[0];if(!i)throw Wr(e);return{name:Gr(n),operator:i,word:e.slice(qr(e,n.length+i.length))}}function qr(e,t){let n=0;for(;t>0;)e[n]===`\\`&&e[n+1]===`
15
+ `?n+=2:(t--,n++);return n}var Jr=(e,t)=>new T(`feature`,e,t),Yr=e=>{if(e>=64)throw Jr(`expansion depth`,`shell expansion nesting above 64 levels is not supported`)};function Xr(e,t,n,r,i,a){Yr(r);let o=n+1,s=null;for(let n=o;n<e.length;n++){let c=e[n];if(s===`'`){c===`'`&&(s=null);continue}if(c===`\\`){n++;continue}if(c===`"`){s=s===`"`?null:`"`;continue}if(c===`'`&&!s){s=`'`;continue}if(c==="`")throw Jr("`",`command substitution (backticks) is not supported`);if(c===`$`){let t=n+1;for(;e[t]===`\\`&&e[t+1]===`
16
+ `;)t+=2;if(e[t]===`'`&&!s){let r=a.decodeAnsiC(e,t+1),s=Kr(e.slice(o,n)).operator;if(i&&/[-+?=]/u.test(s)&&/[$`"'\\}]/u.test(r.text))throw Jr("${",`active characters in ANSI-C quoted parameter operands are not supported`);n=r.end-1;continue}let c=a.readExpansion(e,n,r+1,i||s===`"`);if(c){n+=c.raw.length-1;continue}}if(c===`}`&&!s){let r=Kr(e.slice(o,n));return{raw:e.slice(t,n+1),parameter:r}}}throw Jr("${",`unterminated parameter expansion`)}function Zr(e,t,n,r,i){Yr(r);let a=0;for(let o=n+1;o<e.length;o++){let s=e[o];if(s===`\\`){o++;continue}if(s===`$`){let t=i.readExpansion(e,o,r+1,!0);if(t){o+=t.raw.length-1;continue}}if(s==="`")throw Jr("`",`command substitution (backticks) is not supported`);if(s===`"`||s===`'`)throw Jr(`$((`,`quotes in arithmetic expressions are not supported`);if(s===`(`&&a++,s!==`)`)continue;if(a){a--;continue}let c=o+1;for(;e[c]===`\\`&&e[c+1]===`
17
+ `;)c+=2;if(e[c]!==`)`)throw Jr(`$((`,"arithmetic expansion requires a closing `))`");return{raw:e.slice(t,c+1),arithmetic:e.slice(n+1,o)}}throw Jr(`$((`,`unterminated arithmetic expansion`)}var Qr=/^-[abcdefghknoprstuvwxzGLNORS]$/u,$r=new Set([`=`,`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`]),ei=new Set([`end`,`&&`,`||`,`)`]),ti=/^[A-Za-z_][A-Za-z0-9_]*$/u;function ni(e,t,n,r=0){let i={line:e,i:t+2,helpers:n,token:null,depth:0,terms:0,removed:0,expansionDepth:r};try{li(i,!0);let n=ri(i);return i.token.kind!==`end`&&si(`unexpected token \`${i.token.value??i.token.kind}\``),{raw:e.slice(t,i.i+i.removed),expression:n}}catch(e){if(e instanceof T||e.conditional)throw e;si(e.message)}}function ri(e){let t=ii(e);for(;e.token.kind===`||`;)li(e,!0),t={kind:`or`,left:t,right:ii(e)};return t}function ii(e){let t=ai(e);for(;e.token.kind===`&&`;)li(e,!0),t={kind:`and`,left:t,right:ai(e)};return t}function ai(e){if(++e.terms>128)throw new T(`feature`,`[[ complexity`,`conditional expressions above 128 terms are not supported`);if(++e.depth>64)throw new T(`feature`,`[[ nesting`,`conditional nesting above 64 levels is not supported`);try{let t=e.token;if(t.kind===`(`){li(e,!0);let t=ri(e);return e.token.kind!==`)`&&si("expected `)`"),li(e,!0),t}if(oi(t,`!`))return li(e,!0),{kind:`not`,expression:ai(e)};if(t.kind!==`word`&&si(`expected an operand`),li(e),!t.quoted&&Qr.test(t.value)){let n=ci(e);return li(e,!0),{kind:`unary`,op:t.value,word:n}}if(ei.has(e.token.kind))return{kind:`unary`,op:`-n`,word:t};let n=e.token;if((n.quoted||!$r.has(n.value))&&si(`conditional binary operator expected`),n.value===`=~`)throw new T(`feature`,`[[ =~`,`regular expression comparisons in [[ are not supported`);li(e);let r=ci(e);return li(e,!0),{kind:`binary`,op:n.value,left:t,right:r}}finally{e.depth--}}var oi=(e,t)=>e.kind===`word`&&!e.quoted&&e.value===t,si=e=>{throw Object.assign(Error(`[[ ${e}`),{conditional:!0})};function ci(e){return e.token.kind!==`word`&&si(`expected an operand`),e.token}function li(e,t=!1){if(e.token=ui(e),t)for(;e.token.kind===`newline`;)e.token=ui(e)}function ui(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 t=e.line.indexOf(`
19
19
  `,e.i);e.i=t<0?e.line.length:t;continue}if(t===`
20
- `)return e.i++,{kind:`newline`};let n=e.line.slice(e.i,e.i+2);if(n===`<(`||n===`>(`)throw new T(`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=li(e);return ii(r,`]]`)?{kind:`end`}:r}ai("missing `]]`")}function li(e){let t={kind:`word`,value:``,mask:``,quoted:!1,empty:[]},n=null,r=0;for(;e.i<e.line.length;){let i=e.line[e.i];if(n&&i===n){t.value.length===r&&t.empty.push(r),t.quoted=!0,n=null,e.i++;continue}if(n===`'`){ui(t,i,`1`),e.i++;continue}if(i===`\\`){di(e,t,n);continue}if(i===`$`){if(fi(e),!n&&e.line[e.i+1]===`"`){n=`"`,r=t.value.length,e.i+=2;continue}pi(e,t,n);continue}if(i==="`"){let r=wr(e.line,e.i);ui(t,"`",n?`2`:`0`),ui(t,r.raw.slice(1),`1`),e.i+=r.raw.length;continue}if(n){ui(t,i,`2`),e.i++;continue}if(i===`'`||i===`"`){n=i,r=t.value.length,e.i++;continue}if(i===`(`&&t.mask.at(-1)===`0`&&/[?*+@!]/u.test(t.value.at(-1))&&!t.empty.includes(t.value.length))throw new T(`feature`,`[[ extglob`,`extended glob patterns in [[ are not supported`);if(/[ \t\n()<>;&|]/u.test(i))break;ui(t,i,`0`),e.i++}return n&&ai(`unterminated ${n===`'`?`single`:`double`} quote`),!t.quoted&&!/[12]/u.test(t.mask)&&(t.mask=null),t.empty.length===0&&delete t.empty,t}function ui(e,t,n,r=n!==`0`){e.value+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function di(e,t,n){let r=e.line[e.i+1];if(r===`
21
- `){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(ui(t,r,`1`),e.i+=2):(ui(t,`\\`,n?`2`:`1`),e.i++)}function fi(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 pi(e,t,n){let r=n?`2`:`0`;if(!n&&e.line[e.i+1]===`'`){let n=e.helpers.decodeAnsiC(e.line,e.i+2);n.text===``&&t.empty.push(t.value.length),ui(t,n.text,`1`),e.i=n.end;return}let i=e.helpers.readExpansion(e.line,e.i,e.expansionDepth+1,!!n);if(!i){ui(t,`$`,`1`),e.i++;return}if(i.command!==void 0||i.parameter!==void 0||i.arithmetic!==void 0)ui(t,`$`,r),ui(t,i.raw.slice(1),`1`,!1);else{let n=e.line[e.i+i.raw.length];ui(t,$r.test(i.name)&&(n===`'`||n===`"`)?"${"+i.name+`}`:i.raw,r)}e.i+=i.raw.length}var mi=/^[A-Za-z_][A-Za-z0-9_]*$/u,hi=/[A-Za-z0-9_]/u,gi=/[?#@*$!0-9-]/u;function z(e,t){for(;e[t]===`\\`&&e[t+1]===`
23
- `;)t+=2;return t}function _i(e,t,n=null){let r=r=>r<e.length&&(n===null||n[r]===n[t]);if(!r(t+1))return null;let i=e[t+1];if(gi.test(i))return{name:i,raw:e.slice(t,t+2)};if(!/[A-Za-z_]/u.test(i))return null;let a=t+2;for(;r(a)&&hi.test(e[a]);)a++;return{name:e.slice(t+1,a),raw:e.slice(t,a)}}function vi(e,t,n=0,r=!1,i={}){let a=(e,t,n,r)=>vi(e,t,n,r,i),o=z(e,t+1),s=e[o];if(s===`(`){let r=z(e,o+1);if(e[r]===`(`)return Yr(e,t,r,n,{readExpansion:a});let s=Dr(e,t,o,n,{readExpansion:a,decodeAnsiC:Si,readHeredocBodies:ji,readOperator:Ci,readConditional:ei,skipContinuations:z});return i.validateSubstitution?.(s.command),s}if(s===`{`)return Jr(e,t,o,n,r,{readExpansion:a,decodeAnsiC:Si});if(s===`[`)throw new T(`feature`,`$[`,"arithmetic expansion (`$[…]`) is not supported");return _i(e,t)}function yi(e,t,n={}){let r=Dr(e,t,z(e,t+1),0,{readExpansion:(e,t,r,i)=>vi(e,t,r,i,n),decodeAnsiC:Si,readHeredocBodies:ji,readOperator:Ci,readConditional:ei,skipContinuations:z});return n.validateSubstitution?.(r.command),r}var bi={a:`\x07`,b:`\b`,e:`\x1B`,E:`\x1B`,f:`\f`,n:`
24
- `,r:`\r`,t:` `,v:`\v`,"\\":`\\`,"'":`'`,'"':`"`,"?":`?`};function xi(e,t){for(let n=t;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`'`)return n;throw Error(`unterminated single quote`)}function Si(e,t){let n=xi(e,t),r=[],i=e=>{for(let t of p(e))r.push(t)};for(let a=t;a<n;a++){if(e[a]!==`\\`){let t=String.fromCodePoint(e.codePointAt(a));i(t),a+=t.length-1;continue}let t=e[a+1];if(t in bi){i(bi[t]),a++;continue}if(t===`x`&&e[a+2]===`{`)throw new T(`feature`,`ANSI-C hexadecimal escape`,`braced hexadecimal escapes in ANSI-C quotes are not supported`);let o=/^(?:[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(a+1,n));if(o){let e=o[0],t=/^[0-7]/u.test(e),n=t?parseInt(e,8):parseInt(e.slice(1),16);if(t||e[0]===`x`)r.push(n&255);else{if(!Ir(n))throw new T(`feature`,`ANSI-C Unicode escape`,`ANSI-C escapes outside Unicode scalar values are not supported`);i(String.fromCodePoint(n))}a+=e.length;continue}if(t===`c`&&a+2<n){let t=e.codePointAt(a+2);if(t>127)throw new T(`feature`,`ANSI-C control escape`,`ANSI-C control escapes require an ASCII character`);r.push(t===63?127:t&31),a+=2,t===92&&e[a+1]===`\\`&&a++;continue}i(`\\`)}let a=r.indexOf(0);return{text:D(Uint8Array.from(a===-1?r:r.slice(0,a))),end:n+1}}function Ci(e,t,n){let r=e[t];if(n&&/[0-9]/u.test(r)){let n=``,r=t;for(;/[0-9]/u.test(e[r]??``);)n+=e[r],r=z(e,r+1);return e[r]!==`>`&&e[r]!==`<`||e[z(e,r+1)]===`(`?null:ki(e,r,Number(n))}let i=z(e,t+1),a=e[i];switch(r){case`|`:return a===`|`?Di(`or`,i+1):a===`&`?Di(`pipe_err`,i+1):Di(`pipe`,t+1);case`&`:if(a===`&`)return Di(`and`,i+1);if(a===`>`){let t=z(e,i+1),n=e[t]===`>`;return Oi(1,n?`bothAppend`:`both`,(n?t:i)+1)}return Di(`amp`,t+1);case`;`:return a===`;`?Di(`dsemi`,i+1):Di(`semi`,t+1);case`(`:return Di(`paren_open`,t+1);case`)`:return Di(`paren_close`,t+1);case`<`:case`>`:return ki(e,t,r===`<`?0:1);default:return null}}var wi={semi:`;`,dsemi:`;;`,pipe:`|`,pipe_err:`|&`,and:`&&`,or:`||`,amp:`&`,paren_open:`(`,paren_close:`)`},Ti={write:`>`,append:`>>`,read:`<`,heredoc:`<<`,herestring:`<<<`,both:`&>`,bothAppend:`&>>`,dup:`>&`,close:`>&-`};function Ei(e){if(e.kind===`word`)return e.quoted?`"${e.value}"`:e.value;if(e.kind===`redir`){let t=Ti[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 wi[e.kind]}var Di=(e,t)=>({token:{kind:e},end:t}),Oi=(e,t,n,r)=>({token:{kind:`redir`,fd:e,op:t,...r},end:n});function ki(e,t,n){let r=e[t],i=z(e,t+1),a=e[i];if(a===`&`)return Ai(e,i,n,r===`<`?`<&`:`${n===1&&r===`>`?``:n}>&`);if(r===`<`){if(a===`>`)throw new T(`feature`,`<>`,`read/write file redirects are not supported`);if(a===`<`){let t=z(e,i+1);if(e[t]===`<`)return Oi(n,`herestring`,t+1);let r=e[t]===`-`;return Oi(n,`heredoc`,(r?t:i)+1,{strip:r,delim:null,body:null})}return Oi(n,`read`,t+1)}return a===`>`?Oi(n,`append`,i+1):Oi(n,`write`,(a===`|`?i:t)+1)}function Ai(e,t,n,r){let i=z(e,t+1),a=e[i],o=e[z(e,i+1)],s=o===void 0||/[ \t\n|&>;()<]/u.test(o);if(/[0-9]/u.test(a??``)&&s)return Oi(n,`dup`,i+1,{toFd:Number(a)});if(a===`-`&&s)return Oi(n,`close`,i+1);throw new T(`feature`,`redirect target`,`redirect \`${r}\` requires a file descriptor number (or \`-\`) followed by a token boundary`)}function ji(e,t,n){let r=t+1;for(let t of n){let n=[],i=!1;for(;r<e.length;){let a,o=``;for(;;){a=e.indexOf(`
25
- `,r);let n=a===-1?e.length:a;if(o+=e.slice(r,n),r=n+1,t.quotedDelim||a===-1||!Mi(o))break;o=o.slice(0,-1)}if(a===-1&&o===``)break;if(t.strip&&(o=o.replace(/^\t+/u,``)),o===t.delim){i=!0;break}if(n.push(o),a===-1)break}t.body=n.length===0?``:n.join(`
20
+ `)return e.i++,{kind:`newline`};let n=e.line.slice(e.i,e.i+2);if(n===`<(`||n===`>(`)throw new T(`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=di(e);return oi(r,`]]`)?{kind:`end`}:r}si("missing `]]`")}function di(e){let t={kind:`word`,value:``,mask:``,quoted:!1,empty:[]},n=null,r=0;for(;e.i<e.line.length;){let i=e.line[e.i];if(n&&i===n){t.value.length===r&&t.empty.push(r),t.quoted=!0,n=null,e.i++;continue}if(n===`'`){fi(t,i,`1`),e.i++;continue}if(i===`\\`){pi(e,t,n);continue}if(i===`$`){if(mi(e),!n&&e.line[e.i+1]===`"`){n=`"`,r=t.value.length,e.i+=2;continue}hi(e,t,n);continue}if(i==="`"){let r=Er(e.line,e.i);fi(t,"`",n?`2`:`0`),fi(t,r.raw.slice(1),`1`),e.i+=r.raw.length;continue}if(n){fi(t,i,`2`),e.i++;continue}if(i===`'`||i===`"`){n=i,r=t.value.length,e.i++;continue}if(i===`(`&&t.mask.at(-1)===`0`&&/[?*+@!]/u.test(t.value.at(-1))&&!t.empty.includes(t.value.length))throw new T(`feature`,`[[ extglob`,`extended glob patterns in [[ are not supported`);if(/[ \t\n()<>;&|]/u.test(i))break;fi(t,i,`0`),e.i++}return n&&si(`unterminated ${n===`'`?`single`:`double`} quote`),!t.quoted&&!/[12]/u.test(t.mask)&&(t.mask=null),t.empty.length===0&&delete t.empty,t}function fi(e,t,n,r=n!==`0`){e.value+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function pi(e,t,n){let r=e.line[e.i+1];if(r===`
21
+ `){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(fi(t,r,`1`),e.i+=2):(fi(t,`\\`,n?`2`:`1`),e.i++)}function mi(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 hi(e,t,n){let r=n?`2`:`0`;if(!n&&e.line[e.i+1]===`'`){let n=e.helpers.decodeAnsiC(e.line,e.i+2);n.text===``&&t.empty.push(t.value.length),fi(t,n.text,`1`),e.i=n.end;return}let i=e.helpers.readExpansion(e.line,e.i,e.expansionDepth+1,!!n);if(!i){fi(t,`$`,`1`),e.i++;return}if(i.command!==void 0||i.parameter!==void 0||i.arithmetic!==void 0)fi(t,`$`,r),fi(t,i.raw.slice(1),`1`,!1);else{let n=e.line[e.i+i.raw.length];fi(t,ti.test(i.name)&&(n===`'`||n===`"`)?"${"+i.name+`}`:i.raw,r)}e.i+=i.raw.length}var gi=/^[A-Za-z_][A-Za-z0-9_]*$/u,_i=/[A-Za-z0-9_]/u,vi=/[?#@*$!0-9-]/u;function R(e,t){for(;e[t]===`\\`&&e[t+1]===`
23
+ `;)t+=2;return t}function yi(e,t,n=null){let r=r=>r<e.length&&(n===null||n[r]===n[t]);if(!r(t+1))return null;let i=e[t+1];if(vi.test(i))return{name:i,raw:e.slice(t,t+2)};if(!/[A-Za-z_]/u.test(i))return null;let a=t+2;for(;r(a)&&_i.test(e[a]);)a++;return{name:e.slice(t+1,a),raw:e.slice(t,a)}}function bi(e,t,n=0,r=!1,i={}){let a=(e,t,n,r)=>bi(e,t,n,r,i),o=R(e,t+1),s=e[o];if(s===`(`){let r=R(e,o+1);if(e[r]===`(`)return Zr(e,t,r,n,{readExpansion:a});let s=kr(e,t,o,n,{readExpansion:a,decodeAnsiC:wi,readHeredocBodies:Ni,readOperator:Ti,readConditional:ni,skipContinuations:R});return i.validateSubstitution?.(s.command),s}if(s===`{`)return Xr(e,t,o,n,r,{readExpansion:a,decodeAnsiC:wi});if(s===`[`)throw new T(`feature`,`$[`,"arithmetic expansion (`$[…]`) is not supported");return yi(e,t)}function xi(e,t,n={}){let r=kr(e,t,R(e,t+1),0,{readExpansion:(e,t,r,i)=>bi(e,t,r,i,n),decodeAnsiC:wi,readHeredocBodies:Ni,readOperator:Ti,readConditional:ni,skipContinuations:R});return n.validateSubstitution?.(r.command),r}var Si={a:`\x07`,b:`\b`,e:`\x1B`,E:`\x1B`,f:`\f`,n:`
24
+ `,r:`\r`,t:` `,v:`\v`,"\\":`\\`,"'":`'`,'"':`"`,"?":`?`};function Ci(e,t){for(let n=t;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`'`)return n;throw Error(`unterminated single quote`)}function wi(e,t){let n=Ci(e,t),r=[],i=e=>{for(let t of p(e))r.push(t)};for(let a=t;a<n;a++){if(e[a]!==`\\`){let t=String.fromCodePoint(e.codePointAt(a));i(t),a+=t.length-1;continue}let t=e[a+1];if(t in Si){i(Si[t]),a++;continue}if(t===`x`&&e[a+2]===`{`)throw new T(`feature`,`ANSI-C hexadecimal escape`,`braced hexadecimal escapes in ANSI-C quotes are not supported`);let o=/^(?:[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(a+1,n));if(o){let e=o[0],t=/^[0-7]/u.test(e),n=t?parseInt(e,8):parseInt(e.slice(1),16);if(t||e[0]===`x`)r.push(n&255);else{if(!Rr(n))throw new T(`feature`,`ANSI-C Unicode escape`,`ANSI-C escapes outside Unicode scalar values are not supported`);i(String.fromCodePoint(n))}a+=e.length;continue}if(t===`c`&&a+2<n){let t=e.codePointAt(a+2);if(t>127)throw new T(`feature`,`ANSI-C control escape`,`ANSI-C control escapes require an ASCII character`);r.push(t===63?127:t&31),a+=2,t===92&&e[a+1]===`\\`&&a++;continue}i(`\\`)}let a=r.indexOf(0);return{text:D(Uint8Array.from(a===-1?r:r.slice(0,a))),end:n+1}}function Ti(e,t,n){let r=e[t];if(n&&/[0-9]/u.test(r)){let n=``,r=t;for(;/[0-9]/u.test(e[r]??``);)n+=e[r],r=R(e,r+1);return e[r]!==`>`&&e[r]!==`<`||e[R(e,r+1)]===`(`?null:ji(e,r,Number(n))}let i=R(e,t+1),a=e[i];switch(r){case`|`:return a===`|`?ki(`or`,i+1):a===`&`?ki(`pipe_err`,i+1):ki(`pipe`,t+1);case`&`:if(a===`&`)return ki(`and`,i+1);if(a===`>`){let t=R(e,i+1),n=e[t]===`>`;return Ai(1,n?`bothAppend`:`both`,(n?t:i)+1)}return ki(`amp`,t+1);case`;`:return a===`;`?ki(`dsemi`,i+1):ki(`semi`,t+1);case`(`:return ki(`paren_open`,t+1);case`)`:return ki(`paren_close`,t+1);case`<`:case`>`:return ji(e,t,r===`<`?0:1);default:return null}}var Ei={semi:`;`,dsemi:`;;`,pipe:`|`,pipe_err:`|&`,and:`&&`,or:`||`,amp:`&`,paren_open:`(`,paren_close:`)`},Di={write:`>`,append:`>>`,read:`<`,heredoc:`<<`,herestring:`<<<`,both:`&>`,bothAppend:`&>>`,dup:`>&`,close:`>&-`};function Oi(e){if(e.kind===`word`)return e.quoted?`"${e.value}"`:e.value;if(e.kind===`redir`){let t=Di[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 Ei[e.kind]}var ki=(e,t)=>({token:{kind:e},end:t}),Ai=(e,t,n,r)=>({token:{kind:`redir`,fd:e,op:t,...r},end:n});function ji(e,t,n){let r=e[t],i=R(e,t+1),a=e[i];if(a===`&`)return Mi(e,i,n,r===`<`?`<&`:`${n===1&&r===`>`?``:n}>&`);if(r===`<`){if(a===`>`)throw new T(`feature`,`<>`,`read/write file redirects are not supported`);if(a===`<`){let t=R(e,i+1);if(e[t]===`<`)return Ai(n,`herestring`,t+1);let r=e[t]===`-`;return Ai(n,`heredoc`,(r?t:i)+1,{strip:r,delim:null,body:null})}return Ai(n,`read`,t+1)}return a===`>`?Ai(n,`append`,i+1):Ai(n,`write`,(a===`|`?i:t)+1)}function Mi(e,t,n,r){let i=R(e,t+1),a=e[i],o=e[R(e,i+1)],s=o===void 0||/[ \t\n|&>;()<]/u.test(o);if(/[0-9]/u.test(a??``)&&s)return Ai(n,`dup`,i+1,{toFd:Number(a)});if(a===`-`&&s)return Ai(n,`close`,i+1);throw new T(`feature`,`redirect target`,`redirect \`${r}\` requires a file descriptor number (or \`-\`) followed by a token boundary`)}function Ni(e,t,n){let r=t+1;for(let t of n){let n=[],i=!1;for(;r<e.length;){let a,o=``;for(;;){a=e.indexOf(`
25
+ `,r);let n=a===-1?e.length:a;if(o+=e.slice(r,n),r=n+1,t.quotedDelim||a===-1||!Pi(o))break;o=o.slice(0,-1)}if(a===-1&&o===``)break;if(t.strip&&(o=o.replace(/^\t+/u,``)),o===t.delim){i=!0;break}if(n.push(o),a===-1)break}t.body=n.length===0?``:n.join(`
26
26
  `)+`
27
27
  `,i||(t.warning=`warning: here-document delimited by end-of-file (wanted \`${t.delim}')
28
- `)}return r-1}function Mi(e){let t=0;for(;t<e.length&&e[e.length-1-t]===`\\`;)t++;return t%2==1}var Ni=new Set([`semi`,`amp`,`and`,`or`,`pipe`,`pipe_err`,`paren_open`]),Pi=e=>e===` `||e===` `;function Fi(e,t={}){return Li(Ri(e,t),!1).tokens}function Ii(e,t={}){let n=Ri(e,t);return{read:()=>Li(n,!0),reset:()=>{n.tokens=[]}}}function Li(e,t){for(;e.i<e.line.length;){let n=e.line[e.i];if(e.quote&&n===e.quote){Wi(e),e.i++;continue}if(e.quote===`'`){B(e,n,`1`),e.i++;continue}if(n===`\\`){qi(e);continue}if(n===`$`){Yi(e);continue}if(n==="`"){Zi(e);continue}if(e.quote){B(e,n,`2`),e.i++;continue}if(n===`'`||n===`"`){Ui(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]??``)&&Hi(e.tokens)){let t=ei(e.line,e.i,{readExpansion:e.readExpansion,decodeAnsiC:Si});Ki(e,{kind:`condition`,expression:t.expression}),e.i+=t.raw.length;continue}if(n===`#`&&!r){Qi(e);continue}if(n===`
29
- `){if($i(e),t)return{tokens:e.tokens,done:e.i>=e.line.length};continue}if(Pi(n)){Gi(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 T(`feature`,`extglob`,`extended glob patterns are not supported`);if((n===`<`||n===`>`)&&e.line[z(e.line,e.i+1)]===`(`){Xi(e);continue}let i=Ci(e.line,e.i,!r);if(i?.token.kind===`paren_open`&&(i.token.wordAdjacent=r),i){Gi(e),Ki(e,i.token),e.i=i.end;continue}B(e,n,`0`),e.i++}if(e.quote)throw Error(`unterminated ${e.quote===`'`?`single`:`double`} quote`);return Gi(e),e.heredocs.length>0&&ji(e.line,e.line.length,e.heredocs),{tokens:e.tokens,done:!0}}function Ri(e,t={}){return{line:e,i:0,tokens:[],cur:``,mask:``,empty:[],quoted:!1,quoteStart:0,quote:null,heredocs:[],lastParenAt:-2,readExpansion:(e,n,r=0,i=!1)=>vi(e,n,r,i,t),readProcess:(e,n)=>yi(e,n,t)}}function zi(e,t=!1){let n={...Ri(e),fragment:!0,fragmentQuoted:t};for(;n.i<n.line.length;){let e=n.line[n.i];if(n.quote&&e===n.quote){Wi(n),n.i++;continue}if(n.quote===`'`){B(n,e,`1`),n.i++;continue}if(e===`\\`){qi(n);continue}if(e===`$`){Yi(n);continue}if(e==="`"){Zi(n);continue}if(n.quote){B(n,e,`2`),n.i++;continue}if(e===`"`||e===`'`&&!t){Ui(n,e),n.i++;continue}if(!t&&(e===`<`||e===`>`)&&n.line[z(n.line,n.i+1)]===`(`)throw new T(`feature`,`${e}(`,`process substitution in parameter operands is not supported`);B(n,e,t?`2`:`0`),n.i++}if(n.quote)throw new T(`feature`,"${",`unterminated quote in parameter operand`);return Gi(n),n.tokens[0]??{value:``,mask:t?``:null}}var Bi=new Set([`semi`,`and`,`or`,`pipe`,`pipe_err`,`amp`,`paren_open`]),Vi=new Set([`!`,`{`,`if`,`then`,`else`,`elif`,`while`,`until`,`do`]);function Hi(e){let t=!0,n=null,r=!1;for(let i of e){let e=Bi.has(i.kind)||i.kind===`paren_close`&&n?.kind===`paren_open`;if(n=i,e){t=!0,r=!1;continue}if(i.kind===`redir`){t=!1,r=![`dup`,`close`].includes(i.op);continue}if(r){r=!1;continue}(!t||i.kind!==`word`||i.quoted||!Vi.has(i.value))&&(t=!1)}return t&&!r}function Ui(e,t){e.quoteStart=e.cur.length,e.quote=t}function Wi(e){e.cur.length===e.quoteStart&&e.empty.push(e.cur.length),e.quote=null}function B(e,t,n,r=n!==`0`){e.cur+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function Gi(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(e=>e.delim===null);r&&(r.delim=n.value,r.quotedDelim=t)}e.cur=``,e.mask=``,e.empty=[],e.quoted=!1}function Ki(e,t){t.kind===`paren_open`&&(t.adjacent=z(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 qi(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===`}`)?(B(e,t,`1`),e.i+=2):(B(e,`\\`,e.quote||e.fragmentQuoted?`2`:`1`),e.i++)}function Ji(e,t){let n=z(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function Yi(e){Ji(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 n=Si(t,e.i+2);if(e.fragmentQuoted&&/[$`"\\]/u.test(n.text))throw new T(`feature`,"${",`active characters in ANSI-C quoted parameter operands are not supported`);n.text===``&&e.empty.push(e.cur.length),B(e,n.text,`1`),e.i=n.end;return}if((n===`0`||e.fragmentQuoted&&!e.quote)&&r===`"`){Ui(e,`"`),e.i+=2;return}let i=e.readExpansion(t,e.i,0,n===`2`);if(!i){B(e,`$`,`1`),e.i++;return}if(i.command!==void 0||i.parameter!==void 0||i.arithmetic!==void 0){B(e,`$`,n),B(e,i.raw.slice(1),`1`,!1),e.i+=i.raw.length;return}let a=t[e.i+i.raw.length];B(e,mi.test(i.name)&&(a===`"`||a===`'`)?"${"+i.name+`}`:i.raw,n),e.i+=i.raw.length}function Xi(e){Ji(e,e.i+1);let{raw:t}=e.readProcess(e.line,e.i);B(e,e.line[e.i],`0`),B(e,t.slice(1),`1`,!1),e.i+=t.length}function Zi(e){let t=e.quote===`"`||e.fragmentQuoted?`2`:`0`,{raw:n}=wr(e.line,e.i);B(e,"`",t),B(e,n.slice(1),`1`,!1),e.i+=n.length}function Qi(e){for(;e.i<e.line.length&&e.line[e.i]!==`
31
- `;)e.i++}function $i(e){Gi(e),e.heredocs.length>0&&(e.i=ji(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!Ni.has(t.kind)?e.tokens.push({kind:`semi`,newline:!0}):(t?.kind===`semi`||t?.kind===`amp`)&&(t.lineEnd=!0),e.i++}function ea(e,t,n){let r={aliases:new Set(t),hasCommand:n};return na(e,r),r.aliases}var ta=(e,t)=>new Set([...e,...t]);function na(e,t){let n=null;for(let r of e){let e=r.gate===`and`||r.gate===`or`;if(e&&n!==null&&r.gate===`and`!=(n===0))continue;let i=e&&n===null?new Set(t.aliases):null,a=r.stages.length===1?r.stages[0]:null;n=a&&!a.isolate?ra(a,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=ta(i,t.aliases),n=null)}return n}function ra(e,t){if(e.group)return na(e.group,t);if(e.conditional)return ia(e.conditional,t);if(e.loop){if(e.loop.condition&&na(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let n=new Set(t.aliases);na(e.loop.body,t),t.aliases=ta(n,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(e=>e.value);for(;r[0]?.startsWith(`-`)&&r[0]!==`-`;){let e=r.shift();if(e===`--`)break;if(!(n===`alias`?/^-p+$/u:/^-a+$/u).test(e))return null;if(n===`unalias`)return t.aliases.clear(),null}for(let e of r)if(n===`unalias`)t.aliases.delete(e);else{let n=e.indexOf(`=`),r=e.slice(0,n);n>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(r)&&t.aliases.add(r)}return null}function ia(e,t){let n=new Set;for(let r of e.branches){let e=na(r.condition,t);if(e===0)return na(r.body,t),t.aliases=ta(n,t.aliases),null;if(e===null){let e={...t,aliases:new Set(t.aliases)};na(r.body,e),n=ta(n,e.aliases)}}return e.otherwise&&na(e.otherwise,t),t.aliases=ta(n,t.aliases),null}var aa=class extends Error{constructor(e){super(e.message),this.finalError=e}},oa=e=>new aa(Error(e));function sa(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let t=e.read();e.raw=t.tokens,e.done=t.done}return e.raw[t]}function ca(e,t,n){let r=t.validation??new Map;return{validateSubstitution(t){r.has(t)||(la(t,!0,e,{validation:r,syntaxOnly:!0},n),r.set(t,!0))}}}function la(e,t,n,r,i){try{return i(Fi(e,ca(n,r,i)),t,n,r)}catch(e){throw e instanceof aa?e.finalError:e}}function ua(e,t,n,r){let i=Ii(e,ca(n,{},r)),a=new Set,o=!1;return()=>{let e={aliases:a,aliasUsed:o,read:i.read,unit:!0},s=r([],t,n,e);return o=e.aliasUsed,a=ea(s,a,n),i.reset(),{steps:s,done:e.done}}}function*da(e,t,n,r){let i=ua(e,t,n,r);for(;;){let e;try{e=i()}catch(e){throw e instanceof aa?e.finalError:e}if(e.steps.length>0&&(yield e.steps),e.done)return}}var fa=[`elif`,`else`,`fi`];function pa(e,t){let n=[],r;do{Sa(e);let i=t(e,`then`);Sa(e);let a=t(e,fa);n.push({condition:i,body:a}),r=e.raw[e.i-1].value}while(r===`elif`);let i=null;return r===`else`&&(Sa(e),i=t(e,`fi`)),{branches:n,otherwise:i}}function ma(e,t){let{raw:n}=e,r=e.loop;e.loop=`for`;let i=sa(e);if(i?.kind===`paren_open`)throw new T(`feature`,`for ((`,"arithmetic `for ((…))` loops are not supported; use `for NAME in WORD...`");if(i===void 0||i.kind!==`word`)throw Error(`for: expected a variable name`);let a=i.value;if(i.quoted||!mi.test(a))throw Error(`for: \`${a}\` is not a valid variable name`);e.i++;let o=sa(e);o?.kind===`semi`&&e.i++;let s=sa(e);if(o?.kind===`semi`&&!o.newline&&Ca(s,`in`))throw Error("for: unexpected `in` after `;`");if(!Ca(s,`in`)){if(Ca(s,`do`)||s===void 0){let e=new T(`feature`,`for NAME; do`,`\`for ${a}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${a} in WORD...\``);throw s===void 0?new aa(e):e}throw Error(`for: expected \`in\` after \`${a}\``)}e.i++;let c=[],l=!1;for(let t;(t=sa(e))&&t.kind!==`semi`;e.i++){if(t.kind!==`word`)throw Error(`for: unexpected \`${Ei(t)}\` in word list`);Ca(t,`do`)&&(l=!0),c.push(_r(t))}n[e.i]?.kind===`semi`&&e.i++;let u=sa(e);if(!Ca(u,`do`))throw u===void 0?oa(l?"for: expected `;` or newline before `do`":"for: missing `do`"):Error(l?"for: expected `;` or newline before `do`":`for: expected \`do\`, got \`${Ei(u)}\``);e.i++,Sa(e);let d={name:a,words:c,body:t(e,`done`)};return e.loop=r,d}function ha(e,t,n){let r=e.loop;e.loop=t,Sa(e);let i=n(e,`do`);Sa(e);let a={until:t===`until`,condition:i,body:n(e,`done`)};return e.loop=r,a}function ga(e,t,n){if(t.quoted||!mi.test(t.value))throw new T(`feature`,`function`,`shell functions named \`${t.value}\` are not supported`);if(e.i+=2,Sa(e),!Ca(sa(e),`{`))throw new T(`feature`,`function`,`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,Sa(e);let r=n(e,`}`);if(!_a(r))throw new T(`feature`,`function`,`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:r}}var _a=e=>e.every(e=>e.stages.every(va));function va(e){return e.assigns.length>0||e.define?!1:e.test?ya(e.test)&&e.redirs.every(ba):e.group?_a(e.group):e.conditional?e.conditional.branches.every(e=>_a(e.condition)&&_a(e.body))&&_a(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(xa)&&_a(e.loop.condition??[])&&_a(e.loop.body):e.words.every(xa)&&e.redirs.every(ba)}function ya(e){return e.kind===`and`||e.kind===`or`?ya(e.left)&&ya(e.right):e.kind===`not`?ya(e.expression):e.kind===`unary`?xa(e.word):xa(e.left)&&xa(e.right)}var ba=e=>e.op===`text`?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||xa(e.word);function xa(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 Sa(e){for(let t;(t=sa(e))?.kind===`semi`&&t.newline;)e.i++}function Ca(e,t){return e!==void 0&&e.kind===`word`&&!e.quoted&&e.value===t}var wa=(e,t=!1,n=()=>!1,r={})=>la(e,t,n,r,Ea),Ta=(e,t=!1,n=()=>!1)=>da(e,t,n,Ea);function Ea(e,t,n,r){let i={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 e=sa(i)?Ba(i,null):[];if(i.emptyStage)throw Error(`empty pipeline stage`);return r.aliasUsed=i.aliasUsed,r.done=i.done,e}catch(e){if(i.aliasUsed&&!(e instanceof T)){let t=new T(`feature`,`alias expansion`,`alias expansion is not supported; input using aliases cannot be parsed`);throw e instanceof aa?new aa(t):t}throw e}}function Da(e,t,n){t.stages.push(n),!ka(n)&&!Oa(n)&&(e.emptyStage=!0)}var Oa=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,ka=e=>e.group||e.loop||e.conditional||e.test||e.define,Aa=()=>({words:[],assigns:[],redirs:[]}),ja=e=>({gate:e,stages:[],negate:!1,bang:!1}),Ma=(e,t)=>e.bang&&e.stages.length===0&&Na(t)&&t.redirs.length===0,Na=e=>!ka(e)&&e.words.length===0&&e.assigns.length===0,Pa=new Set([`for`,`while`,`until`,`do`,`done`,`if`,`{`,`}`,`!`]),Fa=new Set([`then`,`else`,`elif`,`fi`,`esac`,`in`]),Ia=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"]]),La=new Set([`alias`,`declare`,`typeset`,`local`,`readonly`,`export`,`eval`,`let`]),Ra=new Set([`pipe`,`pipe_err`,`and`,`or`,`semi`,`amp`]),za=new Set([`semi`,`amp`]);function Ba(e,t){let{raw:n}=e,r=[ja(`first`)];t===null&&(e.unit=r[0]);let i=0,a=Aa();for(let n;n=sa(e);){if(n.kind===`condition`){if(!Na(a))throw Error("unexpected `[[`");a.test=n.expression,e.i++;continue}if(n.kind===`paren_close`){if(t!==`)`)throw Error("unexpected `)`");return e.i++,Ga(e,r,a,t)}if(n.kind===`paren_open`){Va(e,a);continue}if(Ra.has(n.kind)){if(n.kind===`pipe_err`&&(Oa(a)||ka(a))&&a.redirs.push({fd:2,op:`dup`,toFd:1}),n.kind===`semi`&&Ma(r.at(-1),a)||Da(e,r.at(-1),a),n.kind===`amp`&&(r.at(-1).background=!0),a=Aa(),n.kind===`and`||n.kind===`or`?r.push(ja(n.kind)):za.has(n.kind)&&r.push(ja(`seq`)),t===null&&(n.newline||n.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=ea(r.slice(i,-1),e.aliases,e.hasCommand),i=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(n.kind===`dsemi`)throw Error("syntax error near unexpected token `;;`");if(n.kind===`redir`){if(n.warning&&(e.unit.warnings=(e.unit.warnings??``)+n.warning),a.define)throw new T(`feature`,`function`,`\`${a.define.name}()\` with a redirect of its own is not supported`);let t=qa(e);t&&a.redirs.push(t);continue}if(a.group||a.define)throw Error(`unexpected token after \`${a.isolate?`)`:`}`}\``);if(a.loop)throw Error("unexpected token after `done`");if(a.conditional)throw Error("unexpected token after `fi`");if(a.test)throw Error("unexpected token after `]]`");if(!n.quoted&&a.words.length===0&&e.aliases.has(n.value)&&(e.aliasUsed=!0),!n.quoted&&Na(a)){if(Array.isArray(t)?t.includes(n.value):n.value===t)return e.i++,Ga(e,r,a,t);if(Ha(n,e,r.at(-1),a))continue}let o=a.words.length===0?vr(n):null;o===null?a.words.push(_r(n)):a.assigns.push({name:o.name,word:_r(n,o.end)}),e.i++}if(t===`)`)throw oa("unmatched `(`");if(t===`}`)throw oa("unmatched `{`");if(t===`do`||t===`done`)throw oa(`${e.loop}: missing \`${t}\``);if(t)throw oa(`if: missing \`${t===`then`?`then`:`fi`}\``);if(!e.emptyStage&&!ka(a)&&!Oa(a)&&[`and`,`or`,`pipe`,`pipe_err`].includes(n.at(-1)?.kind))throw oa(`empty pipeline stage`);return za.has(n.at(-1)?.kind)?r.pop():Ma(r.at(-1),a)||Da(e,r.at(-1),a),r}function Va(e,t){let{raw:n,i:r}=e,i=sa(e,r+1),a=n[r-1],o=t.words[0],s=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||s&&s.value===a?.value&&(t.words.length===1||o.mask===null&&La.has(o.value)))&&n[r].wordAdjacent&&a?.kind===`word`&&!a.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(a.value))throw new T(`feature`,`array assignment`,`shell array assignments are not supported`);if(i?.kind===`paren_open`&&i.adjacent&&Na(t))throw new T(`feature`,`((`,"arithmetic evaluation (`((…))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&i?.kind===`paren_close`){t.define=ga(e,t.words.pop(),Ba);return}if(!Na(t))throw Error("unexpected `(`");e.i++,t.group=Ba(e,`)`),t.isolate=!0}function Ha(e,t,n,r){let i=e.value;if(Ia.has(i))throw new T(`feature`,i,Ia.get(i));if(Fa.has(i))throw Error(`syntax error near unexpected token \`${i}\``);if(!Pa.has(i))return!1;if(t.i++,i===`!`){if(n.stages.length>0||r.redirs.length>0)throw Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(i===`{`)return Sa(t),r.group=Ba(t,`}`),r.isolate=!1,!0;if(i===`}`)throw Error("syntax error near unexpected token `}`");if(i===`done`)throw Error("unexpected `done`");if(i===`do`)throw Error("unexpected `do`");return i===`if`?r.conditional=pa(t,Ba):r.loop=i===`for`?ma(t,Ba):ha(t,i,Ba),!0}var Ua={")":"empty subshell `()`","}":"empty group `{ }`"},Wa=(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 Ga(e,t,n,r){let i=t.at(-1),a=Na(n)&&n.redirs.length===0&&i.stages.length===0;if(a&&t.length===1)throw Error(Ua[r]??Wa(e,r));if(a&&i.bang)throw Error("syntax error near unexpected token after `!`");return a&&i.gate===`seq`?t.pop():Da(e,i,n),t}var Ka=new Set([`/dev/null`,`/dev/stdout`,`/dev/stderr`]);function qa(e){let t=e.raw[e.i++],n=Ei(t);if(e.syntaxOnly){if(![`dup`,`close`].includes(t.op)){let t=sa(e,e.i++);if(!t||t.kind!==`word`)throw Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new T(`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 T(`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 T(`feature`,`0<&-`,`closing standard input is not supported`);return{fd:t.fd,op:`close`}}let r=sa(e,e.i++);if(!r||r.kind!==`word`)throw Error(`redirect \`${n}\` requires a target`);if(t.op===`heredoc`||t.op===`herestring`||t.op===`read`){if(t.fd!==0)throw new T(`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:_r(r)}}if(t.fd===0)throw new T(`feature`,n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let i=t.op===`both`||t.op===`bothAppend`,a=t.op===`append`||t.op===`bothAppend`,o=_r(r);if(Ja(o))return{fd:t.fd,op:`to`,word:o,both:i,append:a,label:n};if(!e.writable&&!Ka.has(o.value))throw Ya(n,o.value,e.writable);return{fd:t.fd,op:`to`,target:o.value,both:i,append:a,label:n}}function Ja(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 Ya(e,t,n){return new T(`feature`,e,`\`${e}\` cannot write to \`${t}\`: ${n?"only `/tmp/` is writable":`the filesystem is read-only`}`)}var Xa=/^[a-zA-Z0-9][\w.+-]*$/u,Za=[`run`,`pipe`,`hidden`],Qa=[`stdout`,`stderr`,`exitCode`];function $a(e,t){let n={__proto__:null},r=[],i=[];for(let[a,o]of eo(e)){let{run:e,pipe:s,hidden:c}=to(a,o,t);c&&r.includes(a)||(n[a]=(t,n,r)=>no(a,e,t,n,r),!c&&(r.push(a),s&&i.push(a)))}return{handlers:n,names:r,pipeNames:i}}function eo(e){if(e==null)return[];if(Array.isArray(e))throw TypeError(`createTerminal: opts.commands must be an object or a Map (got an array)`);if(typeof e!=`object`)throw 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 TypeError(`createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)`);return Object.entries(e)}function to(e,t,n){if(typeof e!=`string`)throw TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!Xa.test(e))throw Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t==`function`){for(let n of Object.keys(t))if(Za.includes(n))throw Error(`createTerminal: ${e}: \`${n}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(typeof t!=`object`||!t)throw TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!=`function`)throw TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let n of Object.keys(t))if(!Za.includes(n))throw Error(`createTerminal: ${e}: unknown option \`${n}\` (known: ${Za.join(`, `)})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function no(e,t,n,r,i){i.io?.bufferOutput(),F(i);let a={cwd:i.cwd,fs:i.fs,mount:i.mount,home:i.home,get notes(){return i.notes},command:e,stdinFile:i.stdinFile,stdinOrigin:i.stdinOrigin},o=!0,s=()=>{o=!1},c=t({name:e,args:r,stdin:n,cwd:a.cwd,fs:ro(a),readInputs:(t=[])=>{if(typeof t==`string`)throw TypeError(`readInputs: expected an array of paths, got a string: ${t}`);return Hn(e,[...t],n,a)},run:e=>{if(!o)throw Error(`run: the command this belongs to has finished, and its turn with it`);return i.runLine(e)}});return typeof c?.then==`function`?c.then(io).finally(s):(s(),io(c))}function ro(e){let t=t=>k(e.cwd,t,e.fs).path;return{resolve:t=>O(e.cwd,t),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:t=>e.fs.isLink?.(k(e.cwd,t,e.fs,{follow:!1}).path)===!0,readLink:t=>e.fs.readLink?.(k(e.cwd,t,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>Bn(e.fs,t(n))?.slice(),listDir:t=>{let{path:n,error:r}=N(e,e.command,t);if(!e.fs.isDir(n))throw Error(`${t}: ${r??`Not a directory`}`);let{dirs:i,files:a,links:o=[]}=e.fs.listDir(n);return{dirs:[...i],files:[...a],links:[...o]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function io(e){if(e==null)return b();if(typeof e==`string`)return b(e);if(typeof e!=`object`)throw TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw TypeError(`invalid result: expected a string or an object, got an array (join the lines first)`);let t=Object.keys(e);for(let e of t)if(!Qa.includes(e))throw TypeError(`invalid result: unknown field \`${e}\` (known: ${Qa.join(`, `)})`);if(t.length===0)throw TypeError(`invalid result: an object with none of ${Qa.join(`, `)} \u2014 return a string for plain output`);let{stdout:n=``,stderr:r=``,exitCode:i=0}=e;if(typeof n!=`string`)throw TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!=`string`)throw TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(i)||i<0)throw TypeError(`invalid result: exitCode must be a non-negative integer (got ${i})`);return{stdout:n,stderr:r===``||r.endsWith(`
28
+ `)}return r-1}function Pi(e){let t=0;for(;t<e.length&&e[e.length-1-t]===`\\`;)t++;return t%2==1}var Fi=new Set([`semi`,`amp`,`and`,`or`,`pipe`,`pipe_err`,`paren_open`]),Ii=e=>e===` `||e===` `;function Li(e,t={}){return zi(Bi(e,t),!1).tokens}function Ri(e,t={}){let n=Bi(e,t);return{read:()=>zi(n,!0),reset:()=>{n.tokens=[]}}}function zi(e,t){for(;e.i<e.line.length;){let n=e.line[e.i];if(e.quote&&n===e.quote){Ki(e),e.i++;continue}if(e.quote===`'`){z(e,n,`1`),e.i++;continue}if(n===`\\`){Yi(e);continue}if(n===`$`){Zi(e);continue}if(n==="`"){$i(e);continue}if(e.quote){z(e,n,`2`),e.i++;continue}if(n===`'`||n===`"`){Gi(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]??``)&&Wi(e.tokens)){let t=ni(e.line,e.i,{readExpansion:e.readExpansion,decodeAnsiC:wi});Ji(e,{kind:`condition`,expression:t.expression}),e.i+=t.raw.length;continue}if(n===`#`&&!r){ea(e);continue}if(n===`
29
+ `){if(ta(e),t)return{tokens:e.tokens,done:e.i>=e.line.length};continue}if(Ii(n)){qi(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 T(`feature`,`extglob`,`extended glob patterns are not supported`);if((n===`<`||n===`>`)&&e.line[R(e.line,e.i+1)]===`(`){Qi(e);continue}let i=Ti(e.line,e.i,!r);if(i?.token.kind===`paren_open`&&(i.token.wordAdjacent=r),i){qi(e),Ji(e,i.token),e.i=i.end;continue}z(e,n,`0`),e.i++}if(e.quote)throw Error(`unterminated ${e.quote===`'`?`single`:`double`} quote`);return qi(e),e.heredocs.length>0&&Ni(e.line,e.line.length,e.heredocs),{tokens:e.tokens,done:!0}}function Bi(e,t={}){return{line:e,i:0,tokens:[],cur:``,mask:``,empty:[],quoted:!1,quoteStart:0,quote:null,heredocs:[],lastParenAt:-2,readExpansion:(e,n,r=0,i=!1)=>bi(e,n,r,i,t),readProcess:(e,n)=>xi(e,n,t)}}function Vi(e,t=!1){let n={...Bi(e),fragment:!0,fragmentQuoted:t};for(;n.i<n.line.length;){let e=n.line[n.i];if(n.quote&&e===n.quote){Ki(n),n.i++;continue}if(n.quote===`'`){z(n,e,`1`),n.i++;continue}if(e===`\\`){Yi(n);continue}if(e===`$`){Zi(n);continue}if(e==="`"){$i(n);continue}if(n.quote){z(n,e,`2`),n.i++;continue}if(e===`"`||e===`'`&&!t){Gi(n,e),n.i++;continue}if(!t&&(e===`<`||e===`>`)&&n.line[R(n.line,n.i+1)]===`(`)throw new T(`feature`,`${e}(`,`process substitution in parameter operands is not supported`);z(n,e,t?`2`:`0`),n.i++}if(n.quote)throw new T(`feature`,"${",`unterminated quote in parameter operand`);return qi(n),n.tokens[0]??{value:``,mask:t?``:null}}var Hi=new Set([`semi`,`and`,`or`,`pipe`,`pipe_err`,`amp`,`paren_open`]),Ui=new Set([`!`,`{`,`if`,`then`,`else`,`elif`,`while`,`until`,`do`]);function Wi(e){let t=!0,n=null,r=!1;for(let i of e){let e=Hi.has(i.kind)||i.kind===`paren_close`&&n?.kind===`paren_open`;if(n=i,e){t=!0,r=!1;continue}if(i.kind===`redir`){t=!1,r=![`dup`,`close`].includes(i.op);continue}if(r){r=!1;continue}(!t||i.kind!==`word`||i.quoted||!Ui.has(i.value))&&(t=!1)}return t&&!r}function Gi(e,t){e.quoteStart=e.cur.length,e.quote=t}function Ki(e){e.cur.length===e.quoteStart&&e.empty.push(e.cur.length),e.quote=null}function z(e,t,n,r=n!==`0`){e.cur+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function qi(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(e=>e.delim===null);r&&(r.delim=n.value,r.quotedDelim=t)}e.cur=``,e.mask=``,e.empty=[],e.quoted=!1}function Ji(e,t){t.kind===`paren_open`&&(t.adjacent=R(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 Yi(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===`}`)?(z(e,t,`1`),e.i+=2):(z(e,`\\`,e.quote||e.fragmentQuoted?`2`:`1`),e.i++)}function Xi(e,t){let n=R(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function Zi(e){Xi(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 n=wi(t,e.i+2);if(e.fragmentQuoted&&/[$`"\\]/u.test(n.text))throw new T(`feature`,"${",`active characters in ANSI-C quoted parameter operands are not supported`);n.text===``&&e.empty.push(e.cur.length),z(e,n.text,`1`),e.i=n.end;return}if((n===`0`||e.fragmentQuoted&&!e.quote)&&r===`"`){Gi(e,`"`),e.i+=2;return}let i=e.readExpansion(t,e.i,0,n===`2`);if(!i){z(e,`$`,`1`),e.i++;return}if(i.command!==void 0||i.parameter!==void 0||i.arithmetic!==void 0){z(e,`$`,n),z(e,i.raw.slice(1),`1`,!1),e.i+=i.raw.length;return}let a=t[e.i+i.raw.length];z(e,gi.test(i.name)&&(a===`"`||a===`'`)?"${"+i.name+`}`:i.raw,n),e.i+=i.raw.length}function Qi(e){Xi(e,e.i+1);let{raw:t}=e.readProcess(e.line,e.i);z(e,e.line[e.i],`0`),z(e,t.slice(1),`1`,!1),e.i+=t.length}function $i(e){let t=e.quote===`"`||e.fragmentQuoted?`2`:`0`,{raw:n}=Er(e.line,e.i);z(e,"`",t),z(e,n.slice(1),`1`,!1),e.i+=n.length}function ea(e){for(;e.i<e.line.length&&e.line[e.i]!==`
31
+ `;)e.i++}function ta(e){qi(e),e.heredocs.length>0&&(e.i=Ni(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!Fi.has(t.kind)?e.tokens.push({kind:`semi`,newline:!0}):(t?.kind===`semi`||t?.kind===`amp`)&&(t.lineEnd=!0),e.i++}function na(e,t,n){let r={aliases:new Set(t),hasCommand:n};return ia(e,r),r.aliases}var ra=(e,t)=>new Set([...e,...t]);function ia(e,t){let n=null;for(let r of e){let e=r.gate===`and`||r.gate===`or`;if(e&&n!==null&&r.gate===`and`!=(n===0))continue;let i=e&&n===null?new Set(t.aliases):null,a=r.stages.length===1?r.stages[0]:null;n=a&&!a.isolate?aa(a,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=ra(i,t.aliases),n=null)}return n}function aa(e,t){if(e.group)return ia(e.group,t);if(e.conditional)return oa(e.conditional,t);if(e.loop){if(e.loop.condition&&ia(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let n=new Set(t.aliases);ia(e.loop.body,t),t.aliases=ra(n,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(e=>e.value);for(;r[0]?.startsWith(`-`)&&r[0]!==`-`;){let e=r.shift();if(e===`--`)break;if(!(n===`alias`?/^-p+$/u:/^-a+$/u).test(e))return null;if(n===`unalias`)return t.aliases.clear(),null}for(let e of r)if(n===`unalias`)t.aliases.delete(e);else{let n=e.indexOf(`=`),r=e.slice(0,n);n>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(r)&&t.aliases.add(r)}return null}function oa(e,t){let n=new Set;for(let r of e.branches){let e=ia(r.condition,t);if(e===0)return ia(r.body,t),t.aliases=ra(n,t.aliases),null;if(e===null){let e={...t,aliases:new Set(t.aliases)};ia(r.body,e),n=ra(n,e.aliases)}}return e.otherwise&&ia(e.otherwise,t),t.aliases=ra(n,t.aliases),null}var sa=class extends Error{constructor(e){super(e.message),this.finalError=e}},ca=e=>new sa(Error(e));function la(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let t=e.read();e.raw=t.tokens,e.done=t.done}return e.raw[t]}function ua(e,t,n){let r=t.validation??new Map;return{validateSubstitution(t){r.has(t)||(da(t,!0,e,{validation:r,syntaxOnly:!0},n),r.set(t,!0))}}}function da(e,t,n,r,i){try{return i(Li(e,ua(n,r,i)),t,n,r)}catch(e){throw e instanceof sa?e.finalError:e}}function fa(e,t,n,r){let i=Ri(e,ua(n,{},r)),a=new Set,o=!1;return()=>{let e={aliases:a,aliasUsed:o,read:i.read,unit:!0},s=r([],t,n,e);return o=e.aliasUsed,a=na(s,a,n),i.reset(),{steps:s,done:e.done}}}function*pa(e,t,n,r){let i=fa(e,t,n,r);for(;;){let e;try{e=i()}catch(e){throw e instanceof sa?e.finalError:e}if(e.steps.length>0&&(yield e.steps),e.done)return}}var ma=[`elif`,`else`,`fi`];function ha(e,t){let n=[],r;do{wa(e);let i=t(e,`then`);wa(e);let a=t(e,ma);n.push({condition:i,body:a}),r=e.raw[e.i-1].value}while(r===`elif`);let i=null;return r===`else`&&(wa(e),i=t(e,`fi`)),{branches:n,otherwise:i}}function ga(e,t){let{raw:n}=e,r=e.loop;e.loop=`for`;let i=la(e);if(i?.kind===`paren_open`)throw new T(`feature`,`for ((`,"arithmetic `for ((…))` loops are not supported; use `for NAME in WORD...`");if(i===void 0||i.kind!==`word`)throw Error(`for: expected a variable name`);let a=i.value;if(i.quoted||!gi.test(a))throw Error(`for: \`${a}\` is not a valid variable name`);e.i++;let o=la(e);o?.kind===`semi`&&e.i++;let s=la(e);if(o?.kind===`semi`&&!o.newline&&Ta(s,`in`))throw Error("for: unexpected `in` after `;`");if(!Ta(s,`in`)){if(Ta(s,`do`)||s===void 0){let e=new T(`feature`,`for NAME; do`,`\`for ${a}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${a} in WORD...\``);throw s===void 0?new sa(e):e}throw Error(`for: expected \`in\` after \`${a}\``)}e.i++;let c=[],l=!1;for(let t;(t=la(e))&&t.kind!==`semi`;e.i++){if(t.kind!==`word`)throw Error(`for: unexpected \`${Oi(t)}\` in word list`);Ta(t,`do`)&&(l=!0),c.push(yr(t))}n[e.i]?.kind===`semi`&&e.i++;let u=la(e);if(!Ta(u,`do`))throw u===void 0?ca(l?"for: expected `;` or newline before `do`":"for: missing `do`"):Error(l?"for: expected `;` or newline before `do`":`for: expected \`do\`, got \`${Oi(u)}\``);e.i++,wa(e);let d={name:a,words:c,body:t(e,`done`)};return e.loop=r,d}function _a(e,t,n){let r=e.loop;e.loop=t,wa(e);let i=n(e,`do`);wa(e);let a={until:t===`until`,condition:i,body:n(e,`done`)};return e.loop=r,a}function va(e,t,n){if(t.quoted||!gi.test(t.value))throw new T(`feature`,`function`,`shell functions named \`${t.value}\` are not supported`);if(e.i+=2,wa(e),!Ta(la(e),`{`))throw new T(`feature`,`function`,`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,wa(e);let r=n(e,`}`);if(!ya(r))throw new T(`feature`,`function`,`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:r}}var ya=e=>e.every(e=>e.stages.every(ba));function ba(e){return e.assigns.length>0||e.define?!1:e.test?xa(e.test)&&e.redirs.every(Sa):e.group?ya(e.group):e.conditional?e.conditional.branches.every(e=>ya(e.condition)&&ya(e.body))&&ya(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(Ca)&&ya(e.loop.condition??[])&&ya(e.loop.body):e.words.every(Ca)&&e.redirs.every(Sa)}function xa(e){return e.kind===`and`||e.kind===`or`?xa(e.left)&&xa(e.right):e.kind===`not`?xa(e.expression):e.kind===`unary`?Ca(e.word):Ca(e.left)&&Ca(e.right)}var Sa=e=>e.op===`text`?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||Ca(e.word);function Ca(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 wa(e){for(let t;(t=la(e))?.kind===`semi`&&t.newline;)e.i++}function Ta(e,t){return e!==void 0&&e.kind===`word`&&!e.quoted&&e.value===t}var Ea=(e,t=!1,n=()=>!1,r={})=>da(e,t,n,r,Oa),Da=(e,t=!1,n=()=>!1)=>pa(e,t,n,Oa);function Oa(e,t,n,r){let i={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 e=la(i)?Ha(i,null):[];if(i.emptyStage)throw Error(`empty pipeline stage`);return r.aliasUsed=i.aliasUsed,r.done=i.done,e}catch(e){if(i.aliasUsed&&!(e instanceof T)){let t=new T(`feature`,`alias expansion`,`alias expansion is not supported; input using aliases cannot be parsed`);throw e instanceof sa?new sa(t):t}throw e}}function ka(e,t,n){t.stages.push(n),!ja(n)&&!Aa(n)&&(e.emptyStage=!0)}var Aa=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,ja=e=>e.group||e.loop||e.conditional||e.test||e.define,Ma=()=>({words:[],assigns:[],redirs:[]}),Na=e=>({gate:e,stages:[],negate:!1,bang:!1}),Pa=(e,t)=>e.bang&&e.stages.length===0&&Fa(t)&&t.redirs.length===0,Fa=e=>!ja(e)&&e.words.length===0&&e.assigns.length===0,Ia=new Set([`for`,`while`,`until`,`do`,`done`,`if`,`{`,`}`,`!`]),La=new Set([`then`,`else`,`elif`,`fi`,`esac`,`in`]),Ra=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"]]),za=new Set([`alias`,`declare`,`typeset`,`local`,`readonly`,`export`,`eval`,`let`]),Ba=new Set([`pipe`,`pipe_err`,`and`,`or`,`semi`,`amp`]),Va=new Set([`semi`,`amp`]);function Ha(e,t){let{raw:n}=e,r=[Na(`first`)];t===null&&(e.unit=r[0]);let i=0,a=Ma();for(let n;n=la(e);){if(n.kind===`condition`){if(!Fa(a))throw Error("unexpected `[[`");a.test=n.expression,e.i++;continue}if(n.kind===`paren_close`){if(t!==`)`)throw Error("unexpected `)`");return e.i++,qa(e,r,a,t)}if(n.kind===`paren_open`){Ua(e,a);continue}if(Ba.has(n.kind)){if(n.kind===`pipe_err`&&(Aa(a)||ja(a))&&a.redirs.push({fd:2,op:`dup`,toFd:1}),n.kind===`semi`&&Pa(r.at(-1),a)||ka(e,r.at(-1),a),n.kind===`amp`&&(r.at(-1).background=!0),a=Ma(),n.kind===`and`||n.kind===`or`?r.push(Na(n.kind)):Va.has(n.kind)&&r.push(Na(`seq`)),t===null&&(n.newline||n.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=na(r.slice(i,-1),e.aliases,e.hasCommand),i=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(n.kind===`dsemi`)throw Error("syntax error near unexpected token `;;`");if(n.kind===`redir`){if(n.warning&&(e.unit.warnings=(e.unit.warnings??``)+n.warning),a.define)throw new T(`feature`,`function`,`\`${a.define.name}()\` with a redirect of its own is not supported`);let t=Ya(e);t&&a.redirs.push(t);continue}if(a.group||a.define)throw Error(`unexpected token after \`${a.isolate?`)`:`}`}\``);if(a.loop)throw Error("unexpected token after `done`");if(a.conditional)throw Error("unexpected token after `fi`");if(a.test)throw Error("unexpected token after `]]`");if(!n.quoted&&a.words.length===0&&e.aliases.has(n.value)&&(e.aliasUsed=!0),!n.quoted&&Fa(a)){if(Array.isArray(t)?t.includes(n.value):n.value===t)return e.i++,qa(e,r,a,t);if(Wa(n,e,r.at(-1),a))continue}let o=a.words.length===0?br(n):null;o===null?a.words.push(yr(n)):a.assigns.push({name:o.name,word:yr(n,o.end)}),e.i++}if(t===`)`)throw ca("unmatched `(`");if(t===`}`)throw ca("unmatched `{`");if(t===`do`||t===`done`)throw ca(`${e.loop}: missing \`${t}\``);if(t)throw ca(`if: missing \`${t===`then`?`then`:`fi`}\``);if(!e.emptyStage&&!ja(a)&&!Aa(a)&&[`and`,`or`,`pipe`,`pipe_err`].includes(n.at(-1)?.kind))throw ca(`empty pipeline stage`);return Va.has(n.at(-1)?.kind)?r.pop():Pa(r.at(-1),a)||ka(e,r.at(-1),a),r}function Ua(e,t){let{raw:n,i:r}=e,i=la(e,r+1),a=n[r-1],o=t.words[0],s=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||s&&s.value===a?.value&&(t.words.length===1||o.mask===null&&za.has(o.value)))&&n[r].wordAdjacent&&a?.kind===`word`&&!a.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(a.value))throw new T(`feature`,`array assignment`,`shell array assignments are not supported`);if(i?.kind===`paren_open`&&i.adjacent&&Fa(t))throw new T(`feature`,`((`,"arithmetic evaluation (`((…))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&i?.kind===`paren_close`){t.define=va(e,t.words.pop(),Ha);return}if(!Fa(t))throw Error("unexpected `(`");e.i++,t.group=Ha(e,`)`),t.isolate=!0}function Wa(e,t,n,r){let i=e.value;if(Ra.has(i))throw new T(`feature`,i,Ra.get(i));if(La.has(i))throw Error(`syntax error near unexpected token \`${i}\``);if(!Ia.has(i))return!1;if(t.i++,i===`!`){if(n.stages.length>0||r.redirs.length>0)throw Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(i===`{`)return wa(t),r.group=Ha(t,`}`),r.isolate=!1,!0;if(i===`}`)throw Error("syntax error near unexpected token `}`");if(i===`done`)throw Error("unexpected `done`");if(i===`do`)throw Error("unexpected `do`");return i===`if`?r.conditional=ha(t,Ha):r.loop=i===`for`?ga(t,Ha):_a(t,i,Ha),!0}var Ga={")":"empty subshell `()`","}":"empty group `{ }`"},Ka=(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 qa(e,t,n,r){let i=t.at(-1),a=Fa(n)&&n.redirs.length===0&&i.stages.length===0;if(a&&t.length===1)throw Error(Ga[r]??Ka(e,r));if(a&&i.bang)throw Error("syntax error near unexpected token after `!`");return a&&i.gate===`seq`?t.pop():ka(e,i,n),t}var Ja=new Set([`/dev/null`,`/dev/stdout`,`/dev/stderr`]);function Ya(e){let t=e.raw[e.i++],n=Oi(t);if(e.syntaxOnly){if(![`dup`,`close`].includes(t.op)){let t=la(e,e.i++);if(!t||t.kind!==`word`)throw Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new T(`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 T(`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 T(`feature`,`0<&-`,`closing standard input is not supported`);return{fd:t.fd,op:`close`}}let r=la(e,e.i++);if(!r||r.kind!==`word`)throw Error(`redirect \`${n}\` requires a target`);if(t.op===`heredoc`||t.op===`herestring`||t.op===`read`){if(t.fd!==0)throw new T(`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:yr(r)}}if(t.fd===0)throw new T(`feature`,n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let i=t.op===`both`||t.op===`bothAppend`,a=t.op===`append`||t.op===`bothAppend`,o=yr(r);if(Xa(o))return{fd:t.fd,op:`to`,word:o,both:i,append:a,label:n};if(!e.writable&&!Ja.has(o.value))throw Za(n,o.value,e.writable);return{fd:t.fd,op:`to`,target:o.value,both:i,append:a,label:n}}function Xa(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 Za(e,t,n){return new T(`feature`,e,`\`${e}\` cannot write to \`${t}\`: ${n?"only `/tmp/` is writable":`the filesystem is read-only`}`)}var Qa=/^[a-zA-Z0-9][\w.+-]*$/u,$a=[`run`,`pipe`,`hidden`],eo=[`stdout`,`stderr`,`exitCode`];function to(e,t){let n={__proto__:null},r=[],i=[];for(let[a,o]of no(e)){let{run:e,pipe:s,hidden:c}=ro(a,o,t);c&&r.includes(a)||(n[a]=(t,n,r)=>io(a,e,t,n,r),!c&&(r.push(a),s&&i.push(a)))}return{handlers:n,names:r,pipeNames:i}}function no(e){if(e==null)return[];if(Array.isArray(e))throw TypeError(`createTerminal: opts.commands must be an object or a Map (got an array)`);if(typeof e!=`object`)throw 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 TypeError(`createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)`);return Object.entries(e)}function ro(e,t,n){if(typeof e!=`string`)throw TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!Qa.test(e))throw Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t==`function`){for(let n of Object.keys(t))if($a.includes(n))throw Error(`createTerminal: ${e}: \`${n}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(typeof t!=`object`||!t)throw TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!=`function`)throw TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let n of Object.keys(t))if(!$a.includes(n))throw Error(`createTerminal: ${e}: unknown option \`${n}\` (known: ${$a.join(`, `)})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function io(e,t,n,r,i){i.io?.bufferOutput(),F(i);let a={cwd:i.cwd,fs:i.fs,mount:i.mount,home:i.home,get notes(){return i.notes},command:e,stdinFile:i.stdinFile,stdinOrigin:i.stdinOrigin},o=!0,s=()=>{o=!1},c=t({name:e,args:r,stdin:n,cwd:a.cwd,fs:ao(a),readInputs:(t=[])=>{if(typeof t==`string`)throw TypeError(`readInputs: expected an array of paths, got a string: ${t}`);return Un(e,[...t],n,a)},run:e=>{if(!o)throw Error(`run: the command this belongs to has finished, and its turn with it`);return i.runLine(e)}});return typeof c?.then==`function`?c.then(oo).finally(s):(s(),oo(c))}function ao(e){let t=t=>k(e.cwd,t,e.fs).path;return{resolve:t=>O(e.cwd,t),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:t=>e.fs.isLink?.(k(e.cwd,t,e.fs,{follow:!1}).path)===!0,readLink:t=>e.fs.readLink?.(k(e.cwd,t,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>Vn(e.fs,t(n))?.slice(),listDir:t=>{let{path:n,error:r}=N(e,e.command,t);if(!e.fs.isDir(n))throw Error(`${t}: ${r??`Not a directory`}`);let{dirs:i,files:a,links:o=[]}=e.fs.listDir(n);return{dirs:[...i],files:[...a],links:[...o]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function oo(e){if(e==null)return b();if(typeof e==`string`)return b(e);if(typeof e!=`object`)throw TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw TypeError(`invalid result: expected a string or an object, got an array (join the lines first)`);let t=Object.keys(e);for(let e of t)if(!eo.includes(e))throw TypeError(`invalid result: unknown field \`${e}\` (known: ${eo.join(`, `)})`);if(t.length===0)throw TypeError(`invalid result: an object with none of ${eo.join(`, `)} \u2014 return a string for plain output`);let{stdout:n=``,stderr:r=``,exitCode:i=0}=e;if(typeof n!=`string`)throw TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!=`string`)throw TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(i)||i<0)throw TypeError(`invalid result: exitCode must be a non-negative integer (got ${i})`);return{stdout:n,stderr:r===``||r.endsWith(`
32
32
  `)?r:r+`
33
- `,exitCode:i}}var ao=new Uint8Array,oo=e=>e.every(e=>e<128),so=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);function co(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}var V=class extends Error{constructor(e,t,{limited:n=!1}={}){super(t===void 0?e:`${e} at byte ${t}`),this.name=`ArchiveError`,this.offset=t,this.limited=n}};function lo(e,t){try{return e()}catch(e){throw!(e instanceof V)||e.offset!==void 0?e:new V(e.message,t,{limited:e.limited})}}var uo=class extends V{constructor(e,{bytes:t,limited:n=!1,cause:r}){super(e,void 0,{limited:n}),this.name=`CompressionError`,this.bytes=t,this.cause=r}};function fo(e){try{return[new CompressionStream(e),new DecompressionStream(e)].every(Boolean)}catch{return!1}}async function*po(e){if(Symbol.asyncIterator in e)return yield*e;let t=e.getReader();for(let e=await t.read();!e.done;e=await t.read())yield e.value}function mo(e){let t=0;return new TransformStream({transform(n,r){t+=n.length,t<=e?r.enqueue(n):r.error(RangeError(`output past ${e} bytes`))}})}async function ho(e,t,n,r,i,a){if(!(e instanceof Uint8Array))throw new V(`the data is not a Uint8Array`);let o=new t(n),s=[],c=0,l=()=>a===void 0?s.length===1?s[0]:co(s):a.subarray(0,c);try{for await(let t of po(new Blob([e]).stream().pipeThrough(o).pipeThrough(mo(r))))a===void 0?s.push(t):a.set(t,c),c+=t.length}catch(e){let t=e instanceof RangeError;throw new uo(t?`the data ${i}es past ${r} bytes`:`the data does not ${i}`,{bytes:l(),limited:t,cause:e})}return l()}var go=(e,t,{limit:n=1/0}={})=>ho(e,CompressionStream,t,n,`compress`),_o=(e,t,n)=>ho(e,DecompressionStream,t,n,`decompress`);async function vo(e,t,{limit:n=1/0}={}){try{return await _o(e,t,n)}catch(r){if(t!==`gzip`||!(r instanceof uo)||r.limited||e.at(-1)!==0)throw r;let i=e.findLastIndex(e=>e!==0);for(let r=i+1;r<=Math.min(i+10,e.length-1);r++)try{return await _o(e.subarray(0,r),t,n)}catch(e){if(!(e instanceof uo)||e.limited)throw e}throw r}}var yo=(e,t,n)=>ho(e,DecompressionStream,t,n.length,`decompress`,n),bo=e=>e.type===`directory`?`${e.name}/`:e.name,xo=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 So(e){return e.name===`.`||e.storedName!==bo(e)?e.storedName:e.storedLinkname!==void 0&&e.storedLinkname!==e.linkname?e.storedLinkname:null}function H(e){return e.length<=200?JSON.stringify(e):JSON.stringify(`${e.slice(0,e.codePointAt(199)>65535?199:200)}\u2026`)}var Co=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/u,wo=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\\]/u,To=(e,t)=>(t?wo:Co).test(e);function Eo(e,t){if(typeof e!=`string`)throw new V(`${t} is not a string`);if(!e.isWellFormed())throw new V(`${t} is not well-formed Unicode`)}function Do(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}var Oo=(e,t)=>e.length>t||e.length*3>t&&Do(e)>t;function ko(e,t){try{return f(e)}catch{throw new V(`${t} is not well-formed Unicode`)}}function Ao(e,t,n){try{return m(e)}catch{throw new V(`${t} is not valid UTF-8`,n)}}var jo={file:420,directory:493,symlink:511},Mo=e=>e===`file`||e===`contiguous-file`,No=e=>e.type===`directory`?`${e.name}/`:e.name;function Po(e,t){if(typeof e!=`object`||!e)throw new V(`an entry is not an object`);let n=e.type??`file`;if(typeof n!=`string`)throw new V(`entry type is not a string`);if(!Object.hasOwn(t,n))throw new V(`entry type ${H(n)} is not one this package writes`);let{name:r}=e;Eo(r,`entry name`);let i=e.data??ao;if(!(i instanceof Uint8Array))throw new V(`data of ${H(r)} is not a Uint8Array`);if(i.length!==0&&!Mo(n))throw new V(`a ${n} cannot carry data (${H(r)})`);let a=e.linkname??``;if(Eo(a,`link target of ${H(r)}`),a!==``&&n!==`hardlink`&&n!==`symlink`)throw new V(`a ${n} cannot have a link target (${H(r)})`);return{name:r,type:n,data:i,linkname:a}}var Fo=512,Io=e=>e===`character-device`||e===`block-device`,Lo={file:48,hardlink:49,symlink:50,"character-device":51,"block-device":52,directory:53,fifo:54,"contiguous-file":55},Ro={pax:120,global:103,longname:76,longlink:75},zo=100,Bo=155,Vo=32,Ho=0,Uo=[[`mode`,100,8],[`uid`,108,8],[`gid`,116,8],[`size`,124,12],[`mtime`,136,12]],Wo=148,Go=156,Ko=157,qo=257,Jo=265,Yo=297,Xo=329,Zo=337,Qo=345,$o=386,es=495,ts=`ustar\x0000`,ns=`ustar \0`,rs=e=>Uint8Array.from(e,e=>e.codePointAt(0)),is=e=>String.fromCodePoint(...e),as=(e,t,n,r)=>e.subarray(t,t+n).set(r),os=e=>8**(e-1)-1,ss=(e,t)=>e>=0&&e<=os(t);function cs(e,t,n,r,i){if(ss(r,n)){as(e,t,n,rs(r.toString(8).padStart(n-1,`0`)));return}if(!i)throw new V(`${r} does not fit an octal field of ${n-1} digits`);e[t]=r<0?255:128;let a=BigInt.asUintN((n-1)*8,BigInt(r));for(let r=t+n-1;r>t;r--)e[r]=Number(a&255n),a>>=8n}function ls(e,t,n,r,i,a=!1){let o=e[t];if(o===128||o===255){let s=0n;for(let r=t+1;r<t+n;r++)s=s<<8n|BigInt(e[r]);if(o===255&&(s=BigInt.asIntN((n-1)*8,s)),s<0n&&!a)throw new V(`the ${r} field is negative`,i);if(s>BigInt(2**53-1)||s<-BigInt(2**53-1))throw new V(`the ${r} field is too large`,i);return Number(s)}let s=/^ *([0-7]*) *$/u.exec(is(us(e.subarray(t,t+n))));if(!s)throw new V(`the ${r} field is not an octal number`,i);return s[1]===``?0:Number.parseInt(s[1],8)}function us(e){let t=e.indexOf(0);return t===-1?e:e.subarray(0,t)}var ds=(e,t,n)=>us(e.subarray(t,t+n));function fs(e){let t=256;for(let n=0;n<Wo;n++)t+=e[n];for(let n=Wo+8;n<Fo;n++)t+=e[n];return t}var ps=e=>e.every(e=>e===0);function ms(e){let t=new Uint8Array(Fo);as(t,Ho,zo,e.name);for(let[n,r,i]of Uo)cs(t,r,i,e[n],e.gnu);return t[Go]=e.typeflag,as(t,Ko,zo,e.linkname),as(t,qo,8,rs(e.gnu?ns:ts)),as(t,Jo,Vo-1,e.uname),as(t,Yo,Vo-1,e.gname),e.devmajor!==null&&cs(t,Xo,8,e.devmajor,e.gnu),e.devminor!==null&&cs(t,Zo,8,e.devminor,e.gnu),as(t,Qo,Bo,e.prefix),as(t,Wo,8,rs(`${fs(t).toString(8).padStart(6,`0`)}\0 `)),t}var hs=(e,t,n)=>/^ *[0-7]+ *$/u.test(is(us(e.subarray(t,t+n))));function gs(e,t){if(fs(e)!==ls(e,Wo,8,`checksum`,t))throw new V(`header checksum does not match`,t);let n=is(e.subarray(qo,qo+8)),r=n===ns;if(!r&&n!==ts)throw new V(`header is not in the ustar, pax or gnu format`,t);if(r&&!ps(e.subarray($o,es)))throw new V(`header carries an old GNU sparse map or real size`,t);let i=e[Go],a=i===Lo[`character-device`]||i===Lo[`block-device`];return{gnu:r,typeflag:i,name:ds(e,Ho,zo),prefix:r?ao:ds(e,Qo,Bo),linkname:ds(e,Ko,zo),uname:ds(e,Jo,Vo),gname:ds(e,Yo,Vo),...Object.fromEntries(Uo.map(([n,r,i])=>[n,ls(e,r,i,n,t,n===`mtime`)])),devmajor:a?ls(e,Xo,8,`devmajor`,t):0,devminor:a?ls(e,Zo,8,`devminor`,t):0,octal:[[`checksum`,Wo,8],...Uo,...a?[[`devmajor`,Xo,8],[`devminor`,Zo,8]]:[]].every(([,t,n])=>hs(e,t,n))}}var _s=4096,vs=255;function ys(e,t){if(Eo(e,t),e===``)throw new V(`${t} is empty`);if(To(e,!0))throw new V(`${t} ${H(e)} holds a control or formatting character, or a backslash`);if(e.startsWith(`/`))throw new V(`${t} ${H(e)} is absolute`);let n=e.split(`/`);if(/^[a-zA-Z]:/u.test(n.find(e=>e!==`.`)??``))throw new V(`${t} ${H(e)} starts with a drive letter`);if(Oo(e,_s))throw new V(`${t} ${H(e)} is longer than ${_s} bytes`);for(let r of n)if(Oo(r,vs))throw new V(`${t} ${H(e)} has a segment longer than ${vs} bytes`);return n}function bs(e,t,n=!1){let r=ys(e,t),i=r.at(-1)===``;if(i){if(!n)throw new V(`${t} ${H(e)} ends in a slash but is not a directory`);r.pop()}let a=r.filter(e=>e!==`.`);for(let n of a){if(n===``)throw new V(`${t} ${H(e)} has an empty segment`);if(n===`..`)throw new V(`${t} ${H(e)} has a .. segment`)}if(a.length===0){if(!n)throw new V(`${t} ${H(e)} names the archive root but is not a directory`);return`.`}let o=i||a.length<r.length?a.join(`/`):e;if(Oo(o,_s-+!!n))throw new V(`${t} ${H(e)} is longer than ${_s} bytes`);return o}function xs(e=0){if(!(Number.isSafeInteger(e)&&e>=0))throw new V(`symlinksAbove ${String(e)} is not a whole number of levels`);return e}function Ss(e,t,n=0){let r=ys(t,`symlink target of ${H(e)}`).filter(e=>e!==``&&e!==`.`),i=e.split(`/`).length-1;for(let a of r)if(i+=a===`..`?-1:1,i<-n){let r=n===0?`outside the archive`:`more than ${n} level${n===1?``:`s`} above the archive`;throw new V(`symlink ${H(e)} points ${r}, to ${H(t)}`)}return r}function Cs(e,t,n,r=0){let i=bs(e,`entry name`,t===`directory`),a=n;return t===`symlink`?Ss(i,n,r):t===`hardlink`&&(a=bs(n,`hard link target of ${H(i)}`)),{name:i,linkname:a}}var ws=()=>({kind:void 0,entry:void 0,symlink:void 0,first:void 0,firstNode:void 0,rest:void 0});function Ts(e,t,n=!0){if(e.first===t)return e.firstNode;let r=e.rest?.get(t);return r!==void 0||!n||(r=ws(),e.first===void 0?(e.first=t,e.firstNode=r):(e.rest??=new Map,e.rest.set(t,r))),r}var Es=[`type`,`mode`,`uid`,`gid`,`mtime`,`uname`,`gname`,`linkname`,`devmajor`,`devminor`],Ds=class{#e=ws();#t;#n;constructor(e=!1,t=0){this.#t=e,this.#n=t}get above(){return this.#n}add(e){let{name:t,type:n}=e,r=n===`symlink`?e.linkname:void 0;if(n===`hardlink`){let n=this.#o(e.linkname);if(n?.kind!==`entry`)throw new V(`hard link ${H(t)} targets ${H(e.linkname)}, which is not an earlier non-directory entry`);r=n.symlink,r!==void 0&&this.#r(t,r,`hard link ${H(t)} to symlink ${H(e.linkname)}`)}let i=t.split(`/`),a=this.#a(i),o=a.at(-1);if(o.kind!==void 0&&o.kind!==`implied`){let n=Es.find(t=>o.entry[t]!==e[t]);if(n!==void 0)throw new V(`duplicate entry ${H(t)} differs in ${n}`);if(o.entry.data===void 0)throw new V(`duplicate entry ${H(t)}, which only the in-memory call can compare with the earlier one`);if(!so(o.entry.data,e.data))throw new V(`duplicate entry ${H(t)} differs in data`);return}let s=n===`directory`?`directory`:`entry`;if(o.kind!==void 0&&s!==`directory`)throw new V(`${H(t)} is already a directory, so it cannot be a ${n}`);for(let e=1;e<i.length;e++)this.#i(a[e],()=>`${H(t)} is inside ${H(i.slice(0,e).join(`/`))}, which is not a directory`);o.kind=s,o.symlink=r,o.entry=this.#t?e:Object.fromEntries(Es.map(t=>[t,e[t]])),n===`symlink`&&this.#r(t,e.linkname,`symlink ${H(t)}`)}#r(e,t,n){let r=Ss(e,t,this.#n),i=e.split(`/`).slice(0,-1),a=this.#a(i);for(let[e,t]of r.entries()){if(t===`..`){if(i.length===0)return;i.pop(),a.pop()}else i.push(t),a.push(Ts(a.at(-1),t));e<r.length-1&&i.length&&this.#i(a.at(-1),()=>`the target of ${n} passes through ${H(i.join(`/`))}, which is not a directory`)}}#i(e,t){if(e.kind===`entry`)throw new V(t());e.kind??=`implied`}#a(e){let t=[this.#e];for(let n of e)t.push(Ts(t.at(-1),n));return t}#o(e){let t=this.#e;for(let n of e.split(`/`))if(t=Ts(t,n,!1),t===void 0)return;return t}};function Os(e,t){let n=f(` ${e}=${t}
34
- `),r=String(n.length).length,i=n.length+r+ +(String(n.length+r).length>r);return co([f(String(i)),n])}var ks=e=>co(e.map(([e,t])=>Os(e,t))),As=`pax records cannot be changed`,js=class extends Map{set(){throw TypeError(As)}delete(){throw TypeError(As)}clear(){throw TypeError(As)}},Ms=(e,t,n)=>Map.prototype.set.call(e,t,n);function Ns(e,t){let n=new js;for(let r=0;r<e.length;){let i=r,a=0;for(;i<e.length&&e[i]>=48&&e[i]<=57;i++)a=a*10+(e[i]-48);if(i===r||e[r]===48||e[i]!==32)throw new V(`a pax record does not begin with its length`,t);let o=r+a;if(o>e.length||e[o-1]!==10)throw new V(`a pax record is not as long as it says`,t);let s=e.indexOf(61,i+1);if(s===-1||s>=o-1)throw new V(`a pax record has no keyword=value`,t);let c=Ao(e.subarray(i+1,s),`a pax record`,t);if(c===``||To(c,!1)||c.includes(` `))throw new V(`pax keyword ${H(c)} is malformed`,t);if(n.has(c))throw new V(`pax keyword ${c} repeats`,t);Ms(n,c,Ao(e.subarray(s+1,o-1),`a pax record`,t)),r=o}return n}var Ps=new Set([`gnu`,`ustar`,`pax`]),Fs=47;function Is(e,t,n=!1){if(!Number.isSafeInteger(e)||!n&&e<0)throw new V(`${t} ${String(e)} is not ${n?`an integer`:`a non-negative integer`}`);return e}function Ls(e,t){if(Eo(e,t),To(e,!1))throw new V(`${t} ${H(e)} holds a control or formatting character`);return e}function Rs(e){let t=Po(e,Lo),{name:n,type:r}=t,i=Is(e.devmajor??0,`devmajor`),a=Is(e.devminor??0,`devminor`);if((i!==0||a!==0)&&!Io(r))throw new V(`a ${r} cannot have device numbers (${H(n)})`);let o=Is(e.mode??jo[r]??420,`mode`);if(o>4095)throw new V(`mode ${o.toString(8)} has bits beyond the permission bits`);return{...t,mode:o,uid:Is(e.uid??0,`uid`),gid:Is(e.gid??0,`gid`),mtime:Is(e.mtime??0,`mtime`,!0),uname:Ls(e.uname??``,`uname`),gname:Ls(e.gname??``,`gname`),devmajor:i,devminor:a}}function zs(e,t=e.length){let n=new Uint8Array(Math.ceil(t/Fo)*Fo);return n.set(e),n}var Bs=(e,t,n,r,i)=>ms({gnu:i,name:ko(e,`header name`).subarray(0,zo),prefix:ao,linkname:ao,uname:ao,gname:ao,typeflag:r,mode:420,uid:0,gid:0,size:t,mtime:n,devmajor:null,devminor:null}),Vs=(e,t)=>[Bs(`././@LongLink`,e.length+1,0,t,!0),zs(e,e.length+1)];function Hs(e,t){let n=ks(t),r=e.name.lastIndexOf(`/`);return[Bs(r===-1?`./PaxHeaders/${e.name}`:`${e.name.slice(0,r)}/PaxHeaders/${e.name.slice(r+1)}`,n.length,Math.max(0,Math.min(e.mtime,os(12))),Ro.pax,!1),zs(n)]}function Us(e,t){let{length:n}=e;if(n>Bo+zo+1)throw new V(`name ${H(t)} is longer than 256 bytes, which ustar cannot hold`);let r=n;r>Bo+1?r=Bo+1:e[r-1]===Fs&&r--;let i=r-1;for(;i>0&&e[i]!==Fs;)i--;let a=n-i-1;if(i===0||a>zo||a===0)throw new V(`name ${H(t)} cannot be split into ustar's prefix and name fields`);return{prefix:e.subarray(0,i),name:e.subarray(i+1)}}function Ws(e,t){let n=t===`gnu`,r=[],i=[],a=No(e),o=ko(a,`entry name`),s=ao,c=ko(e.linkname,`link target of ${H(e.name)}`);if(c.length>zo){if(n)i.push(...Vs(c,Ro.longlink));else if(t===`pax`)r.push([`linkpath`,e.linkname]);else throw new V(`link target of ${H(e.name)} is longer than 100 bytes, which ustar cannot hold`);c=c.subarray(0,zo)}t===`pax`&&(o.length>zo||!oo(o))&&r.push([`path`,a]),o.length>zo&&(n?i.push(...Vs(o,Ro.longname)):t===`ustar`&&({prefix:s,name:o}=Us(o,e.name)),o.length>zo&&(o=o.subarray(0,zo)));let l=(i,a,o)=>{if(n||ss(a,o))return a;if(t===`pax`)return r.push([i,String(a)]),0;throw new V(`${i} ${a} of ${H(e.name)} does not fit the ustar format`)},u=(n,i)=>{let a=ko(i,n);if(a.length<Vo&&(t!==`pax`||oo(a)))return a;if(t!==`pax`)throw new V(`${n} of ${H(e.name)} is longer than 31 bytes, which the ${t} format cannot hold`);return r.push([n,i]),a.subarray(0,Vo-1)},d=Io(e.type),f={gnu:n,name:o,prefix:s,linkname:c,typeflag:Lo[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:d?l(`devmajor`,e.devmajor,8):null,devminor:d?l(`devminor`,e.devminor,8):null,uname:u(`uname`,e.uname),gname:u(`gname`,e.gname)};r.length&&i.push(...Hs(e,r)),i.push(ms(f));let p=e.data.length%Fo;return e.data.length&&i.push(e.data),p&&i.push(new Uint8Array(Fo-p)),i}function Gs({format:e=`gnu`,blocking:t=20,symlinksAbove:n}={},r=!1){if(!Ps.has(e))throw new V(`format ${H(String(e))} is not gnu, ustar or pax`);if(!Number.isSafeInteger(t)||t<1)throw new V(`blocking is not a positive integer`);let i=new Ds(r,xs(n)),a=0;return{add(t){let n=Rs(t),r={...n,...Cs(n.name,n.type,n.linkname,i.above)};i.add(r);let o=Ws(r,e);for(let e of o)a+=e.length;return o},end(){let e=t*Fo,n=(a+2*Fo)%e;return[new Uint8Array(2*Fo+(n?e-n:0))]}}}function Ks(e,t){let n=Gs(t,!0),r=[];for(let t of e)r.push(...n.add(t));return co([...r,...n.end()])}var qs=e=>Object.entries(e).map(([e,t])=>[t,e]),Js=new Map([...qs(Lo),[0,`file`]]),Ys=new Map(qs(Ro)),Xs=1<<20,Zs=new Set([`SCHILY.realsize`,`SUN.holesdata`]);function Qs(e,t){for(let n of e)if(n.startsWith(`GNU.sparse.`)||Zs.has(n))throw new V(`sparse entries are not supported`,t)}function $s(e,t,n){if(!/^(?:0|[1-9][0-9]*)$/u.test(e)||!Number.isSafeInteger(Number(e)))throw new V(`pax ${t}=${H(e)} is not a whole number this package can hold`,n);return Number(e)}function ec(e,t,n){let r=/^(-?)([0-9]+)(?:\.([0-9]+))?$/u.exec(e);if(!r)throw new V(`pax ${t}=${H(e)} is not a time`,n);let[,i,a,o=``]=r,s=Number(i+a)-(i&&/[1-9]/u.test(o)?1:0);if(!Number.isSafeInteger(s))throw new V(`pax ${t}=${H(e)} is out of range`,n);return s}var tc=()=>({pax:null,longname:null,longlink:null}),nc=new js,rc=Object.freeze([]),ic=e=>e.gnu?`gnu`:`ustar`,ac=class{#e=[];#t=0;#n=0;#r=0;#i;#a=tc();#o=[];#s=null;#c=null;#l=0;#u=!1;#d=0;#f;constructor(e,{symlinksAbove:t,maxEntries:n=1/0}={}){if(n!==1/0&&!(Number.isSafeInteger(n)&&n>=0))throw new V(`maxEntries ${String(n)} is not a whole number of entries`);this.#i=new Ds(e,xs(t)),this.#f=n}*push(e){if(!(e instanceof Uint8Array))throw new V(`a chunk is not a Uint8Array`);if(this.#u){this.#m(e,this.#r),this.#r+=e.length;return}e.length&&(this.#e.push(e),this.#n+=e.length);let t=[],n=!0;for(;n&&!this.#u;)n=this.#c===null?this.#h():this.#g(t),yield*t.splice(0)}end(){if(!this.#u)throw this.#r===0&&this.#n===0?new V(`the archive is empty`):this.#c===null&&this.#n===0?new V(this.#l?`the archive ends with a lone zero block`:`the archive has no end marker`,this.#r):new V(`the archive is truncated`,this.#r)}#p(e){if(this.#n<e)return null;if(e===0)return ao;let t;if(this.#t+e<=this.#e[0].length)t=this.#e[0].subarray(this.#t,this.#t+e),this.#t+=e;else{t=new Uint8Array(e);let n=0;for(let r=0,i=this.#t;r<e;n++,i=0){let a=this.#e[n].subarray(i,i+e-r);t.set(a,r),r+=a.length,this.#t=i+a.length}this.#e=this.#e.slice(n-1)}return this.#t===this.#e[0].length&&(this.#e.shift(),this.#t=0),this.#n-=e,this.#r+=e,t}#m(e,t){if(!ps(e))throw new V(`data after the end of the archive`,t)}#h(){let e=this.#p(Fo);if(e===null)return!1;let t=this.#r-Fo;if(ps(e)){if(this.#o.length>0)throw new V(`an extended header is not followed by an entry`,t);if(++this.#l===2){this.#u=!0;let e=this.#r;this.#m(this.#p(this.#n),e)}return!0}if(this.#l)throw new V(`a lone zero block where a header should be`,t);let n=gs(e,t),r=Ys.get(n.typeflag);if(r===void 0){if(++this.#d>this.#f)throw new V(`the archive holds more than ${this.#f} entries`,t,{limited:!0});this.#c={extended:null,at:t,...this.#_(n,t)}}else{if(n.size>Xs)throw new V(`a ${r} header of ${n.size} bytes is longer than any tar writes`,t);this.#c={extended:r,size:n.size,at:t,entry:null,magic:ic(n),octal:n.octal}}return!0}#g(e){let{extended:t,size:n,at:r,entry:i,magic:a,octal:o}=this.#c,s=Math.ceil(n/Fo)*Fo,c=this.#p(s);if(c===null)return!1;if(!ps(c.subarray(n)))throw new V(`the padding after an entry is not zero`,r);this.#c=null;let l=c.subarray(0,n);if(t===null)i.data=l,lo(()=>this.#i.add(i),r),e.push(i);else if(t===`global`){this.#s=Ns(l,r);for(let e of[`path`,`linkpath`,`size`])if(this.#s.has(e))throw new V(`a global header sets ${e}`,r);Qs(this.#s.keys(),r),this.#o.push(Object.freeze({kind:t,magic:a,octal:o}))}else{if(this.#a[t]!==null)throw new V(`two ${t} headers ahead of one entry`,r);this.#a[t]=t===`pax`?Ns(l,r):Ao(us(l),`a ${t} header`,r),this.#o.push(Object.freeze({kind:t,magic:a,octal:o}))}return!0}#_(e,t){let n=Js.get(e.typeflag);if(n===void 0)throw new V(`entry type ${H(String.fromCodePoint(e.typeflag))} is not one this package reads`,t);let{pax:r,longname:i,longlink:a}=this.#a;this.#a=tc();let o=e=>r?.get(e)??this.#s?.get(e);if(r!==null&&Qs(r.keys(),t),i!==null&&o(`path`)!==void 0)throw new V(`both a long name header and a pax path name one entry`,t);if(a!==null&&o(`linkpath`)!==void 0)throw new V(`both a long link header and a pax linkpath name one entry`,t);let s=i??o(`path`)??this.#v(e,t),c=a??o(`linkpath`)??Ao(e.linkname,`link target`,t),{name:l,linkname:u}=lo(()=>Cs(s,n,c,this.#i.above),t),d=(n,r=$s)=>{let i=o(n);return i===void 0?e[n]:r(i,n,t)},f=d(`size`);if(f!==0&&!Mo(n))throw new V(`a ${n} entry has a size`,t);if(u!==``&&n!==`hardlink`&&n!==`symlink`)throw new V(`a ${n} entry has a link target`,t);let p=n=>{let r=o(n)??Ao(e[n],n,t);if(To(r,!1))throw new V(`${n} ${H(r)} holds a control or formatting character`,t);return r},m={name:l,type:n,mode:e.mode&4095,uid:d(`uid`),gid:d(`gid`),mtime:d(`mtime`,ec),uname:p(`uname`),gname:p(`gname`),linkname:u,devmajor:Io(n)?d(`devmajor`):0,devminor:Io(n)?d(`devminor`):0,data:ao,storedName:s,storedLinkname:c,pax:r??nc,globalPax:this.#s??nc,extended:this.#o.length?Object.freeze(this.#o):rc,magic:ic(e),typeflag:String.fromCodePoint(e.typeflag),storedMode:e.mode,octal:e.octal};return this.#o=[],{entry:m,size:f}}#v(e,t){let n=Ao(e.name,`entry name`,t);return e.prefix.length?`${Ao(e.prefix,`name prefix`,t)}/${n}`:n}};function oc(e,t){let n=new ac(!0,t),r=[...n.push(e)];return n.end(),r}var sc=new Map([[7,`a`],[8,`b`],[12,`f`],[10,`n`],[13,`r`],[9,`t`],[11,`v`]]),cc=e=>`\\`+e.toString(8).padStart(3,`0`);function lc(e,t){let n=en(t),r=vn(t.locale),i=``;for(let t of e){let e=t.codePointAt(0);if(t===`\\`)i+=`\\\\`;else if(sc.has(e))i+=`\\`+sc.get(e);else if(e<128?e>=32&&e<127:!n&&r.has(`print`,e))i+=t;else for(let e of E(t))i+=cc(e)}return i}var uc={__proto__:null,file:`-`,"contiguous-file":`C`,directory:`d`,symlink:`l`,hardlink:`h`,fifo:`p`,"character-device":`c`,"block-device":`b`};function dc(e,t){let n=[...`rwxrwxrwx`].map((e,n)=>t&256>>n?e:`-`),r=(e,r,i)=>{(t&e)!==0&&(n[r]=n[r]===`x`?i:i.toUpperCase())};return r(2048,2,`s`),r(1024,5,`s`),r(512,8,`t`),uc[e]+n.join(``)}var fc=e=>E(e).length,pc=new Set([`character-device`,`block-device`]);function mc(e,{numericOwner:t=!1,utc:n=!1}={}){let r=19,i=16,a=n||e.vars.has(`TZ`),o=n=>{let o=!t&&n.uname!==``?n.uname:String(n.uid),s=!t&&n.gname!==``?n.gname:String(n.gid),c=pc.has(n.type)?`${n.devmajor},${n.devminor}`:String(n.data.length),l=fc(o)+1+fc(s)+1+c.length;l>r&&(r=l);let u=gc(n.mtime,a);return u.length>i&&(i=u.length),`${dc(n.type,n.mode)} ${o}/${s} ${` `.repeat(r-l)}${c} ${u.padEnd(i)} `+lc(bo(n),e)+hc(n,e)};return o.mkdir=t=>`${dc(`directory`,448)} ${`Creating directory:`.padStart(r+1+i)} ${lc(t,e)}`,o}function hc(e,t){return e.type===`symlink`?` -> ${lc(e.linkname,t)}`:e.type===`hardlink`?` link to ${lc(e.linkname,t)}`:``}function gc(e,t){let n=new Date(e*1e3);if(Number.isNaN(n.getTime()))throw new T(`feature`,`archive time`,`a modification time of ${e} seconds is past what this terminal can print`);return wb(n,`%Y-%m-%d %H:%M`,t)}var _c=(e,t)=>lc(e,t).replaceAll(`:`,`\\:`);function vc(e,t){let n=lc(e,t);return en(t)?`'${n.replaceAll(`'`,`\\'`)}'`:`\u2018${n}\u2019`}function yc(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)t--;return e.slice(0,t)}function bc(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`)t++;else if(`?*[]`.includes(e[t]))return!0;return!1}var xc=(e,t)=>t===e||t.startsWith(e)&&t[e.length]===`/`;function Sc(e){let t=[],n=[];for(let r of e)r.dir===void 0?r.name!==``&&t.push({given:r.name,operand:yc(r.name),dirs:[...n],found:!1}):n.push(r.dir);let r={dirs:n};return{names:t,match(e){if(t.length===0)return r;let n=t.find(t=>xc(t.operand,e));return n!==void 0&&(n.found=!0),n??null}}}function Cc(e,t,n){for(let r of e.names)r.found||(!n&&bc(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(`${_c(r.operand,t.ctx)}: Not found in archive`))}function wc(e,t,n){let{ctx:r}=n,i=k(e,t,r.fs),a=i.error??(r.fs.isDir(i.path)?null:`Not a directory`);return a===null?i.path:(n.fatal(`${_c(t,r)}: Cannot open: ${a}`),null)}async function Tc(e,t){try{return{bytes:await vo(e,t),error:null}}catch(e){if(!(e instanceof uo))throw e;return{bytes:e.bytes,error:e.cause?.cause?.message??e.cause?.message??`corrupt input`}}}var Ec=10,Dc=8,Oc=8,kc=16,Ac=4,jc=2,Mc=8,Nc=`gzip`,Pc=`deflate-raw`,Fc=(e,t)=>e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216;function Ic(e,t){if(e[t]!==31||e[t+1]!==139||e[t+2]!==Oc)return-1;let n=e[t+3],r=t+Ec;if((n&Ac)!==0){if(r+2>e.length)return-1;r+=2+e[r]+e[r+1]*256}for(let t of[Mc,kc])if((n&t)!==0){for(;r<e.length&&e[r]!==0;)r++;r++}return(n&jc)!==0&&(r+=2),r<=e.length?r-t:-1}var Lc=64;async function Rc(e,t){let n=Ic(e,t);if(n<0)return null;let r=(await Tc(e.subarray(t+n),Pc)).bytes.length%4294967296,i=Lc;for(let a=t+n+Dc;a<=e.length&&i>0;a++){if(Fc(e,a-4)!==r)continue;i--;let n=await Tc(e.subarray(t,a),Nc);if(n.error===null)return{bytes:n.bytes,end:a}}return null}async function zc(e){let t=await Tc(e,Nc);if(t.error===null||!fo(Pc))return{...t,rest:null};let n=[],r=0;for(;;){let t=await Rc(e,r);if(t===null)break;n.push(t.bytes),r=t.end}return r===0||r===e.length?{...t,rest:null}:{bytes:ct(n),error:t.error,rest:e.subarray(r)}}function U(e,t={}){let n=Vc(t.short),r=Vc(t.long),i=Vc(t.valueShort),a=Vc(t.valueLong),o=Vc(t.repeatable),s=new Set,c=new Map,l=[],u=[],d=0;function f(t,l,f=!1){let p=(f?`--`:`-`)+t,m=(f?a:i).has(t)||o.has(t)&&(!f||t.length>1);if(m){let n=l??e[++d];if(l===null&&d>=e.length)throw Error(p+` requires an argument`);if(o.has(t)){let e=c.get(t);e?e.push(n):c.set(t,[n])}else c.set(t,n);u.push({name:t,value:n})}else{if(!(f?r:n).has(t))throw new T(`option`,p,`unknown option: `+p);if(f&&l!==null)throw Error(`option `+p+` doesn't allow an argument`);s.add(t),u.push({name:t})}return m}for(;d<e.length;d++){let r=e[d];if(r===`--`){l.push(...e.slice(d+1));break}if(r.startsWith(`--`)&&r.length>2){let e=r.indexOf(`=`);f(e===-1?r.slice(2):r.slice(2,e),e===-1?null:r.slice(e+1),!0);continue}if(r.startsWith(`-`)&&r.length>1&&!(t.numericOperands&&Bc(r,n,i,o))){for(let e=1;e<r.length&&!f(r[e],e+1<r.length?r.slice(e+1):null);e++);continue}if(t.stopAtFirstPositional){l.push(...e.slice(d));break}l.push(r)}return{flags:s,values:c,positional:l,order:u}}function Bc(e,t,n,r){if(!/^-\d/u.test(e))return!1;let i=e[1];return!t.has(i)&&!n.has(i)&&!r.has(i)}function Vc(e){return e instanceof Set?e:new Set(e??[])}var Hc=`gzip`,Uc=(e,t,n)=>sl(e,[`-d`,...t],n),Wc=(e,t,n)=>sl(e,[`-d`,`-c`,...t],n),Gc=fo(Hc)?{gzip:sl,gunzip:Uc,zcat:Wc,gzcat:Wc}:{},Kc=Object.freeze([31,139]),qc=e=>e!==void 0&&e.length>=2&&e[0]===Kc[0]&&e[1]===Kc[1],Jc=Object.freeze([[31,158],[31,30],[31,157],[31,160]]),Yc=Object.freeze([80,75,3,4]),Xc=(e,t)=>e.length>=t.length&&t.every((t,n)=>e[n]===t),Zc=(e,t)=>Jc.some(t=>Xc(e,t))||t&&Xc(e,Yc);function Qc(e,t){return t.gap??=C(`feature`,`gzip`,`other formats`,`gzip: ${e}: data compressed other than by gzip is not supported`,1),!1}var $c={__proto__:null,"unexpected end of file":`unexpected end of file`,"incorrect data check":`invalid compressed data--crc error`},el=e=>$c[e]??`invalid compressed data--format violated`,tl=8;function nl(e,t){let n=t.rest,r=t=>({text:`
33
+ `,exitCode:i}}var so=new Uint8Array,co=e=>e.every(e=>e<128),lo=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);function uo(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}var B=class extends Error{constructor(e,t,{limited:n=!1}={}){super(t===void 0?e:`${e} at byte ${t}`),this.name=`ArchiveError`,this.offset=t,this.limited=n}};function fo(e,t){try{return e()}catch(e){throw!(e instanceof B)||e.offset!==void 0?e:new B(e.message,t,{limited:e.limited})}}var po=class extends B{constructor(e,{bytes:t,limited:n=!1,cause:r}){super(e,void 0,{limited:n}),this.name=`CompressionError`,this.bytes=t,this.cause=r}};function mo(e){try{return[new CompressionStream(e),new DecompressionStream(e)].every(Boolean)}catch{return!1}}async function*ho(e){let t=e.getReader();try{for(let e=await t.read();!e.done;e=await t.read())yield e.value}finally{t.cancel().catch(()=>{})}}var go=e=>Symbol.asyncIterator in e?e:ho(e);async function _o(e,t,n,r,i,a,o=0){if(!(e instanceof Uint8Array))throw new B(`the data is not a Uint8Array`);let s=new t(n),c=[],l=0,u=a??(o>0?new Uint8Array(o):void 0),d=0,f=()=>a===void 0?u===void 0?c.length===1?c[0]:uo(c):d===u.length?u:u.subarray(0,d):a.subarray(0,l),p=s.writable.getWriter();p.write(e).catch(()=>{}),p.close().catch(()=>{});try{for await(let e of go(s.readable)){if(!(l+e.length<=r))throw RangeError(`output past ${r} bytes`);u!==void 0&&d+e.length>u.length&&a===void 0&&(c.push(u.subarray(0,d)),u=void 0),u===void 0?c.push(e):(u.set(e,d),d+=e.length),l+=e.length}}catch(e){let t=e instanceof RangeError;throw new po(t?`the data ${i}es past ${r} bytes`:`the data does not ${i}`,{bytes:f(),limited:t,cause:e})}return f()}var vo=(e,t,{limit:n=1/0}={})=>_o(e,CompressionStream,t,n,`compress`),yo=16;function bo(e,t){if(e.length<18)return 0;let n=new DataView(e.buffer,e.byteOffset+e.length-4,4).getUint32(0,!0);return n<=t&&n<=e.length*yo?n:0}var xo=(e,t,n,r)=>_o(e,DecompressionStream,t,n,`decompress`,void 0,r&&t===`gzip`?bo(e,n):0);async function So(e,t,{limit:n=1/0}={}){try{return await xo(e,t,n,!0)}catch(r){if(t!==`gzip`||!(r instanceof po)||r.limited||e.at(-1)!==0)throw r;let i=e.findLastIndex(e=>e!==0);for(let r=i+1;r<=Math.min(i+10,e.length-1);r++)try{return await xo(e.subarray(0,r),t,n,!1)}catch(e){if(!(e instanceof po)||e.limited)throw e}throw r}}var Co=(e,t,n)=>_o(e,DecompressionStream,t,n.length,`decompress`,n),wo=e=>e.type===`directory`?`${e.name}/`:e.name,To=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 Eo(e){return e.name===`.`||e.storedName!==wo(e)?e.storedName:e.storedLinkname!==void 0&&e.storedLinkname!==e.linkname?e.storedLinkname:null}function V(e){return e.length<=200?JSON.stringify(e):JSON.stringify(`${e.slice(0,e.codePointAt(199)>65535?199:200)}\u2026`)}var Do=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/u,Oo=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}\\]/u,ko=(e,t)=>(t?Oo:Do).test(e);function Ao(e,t){if(typeof e!=`string`)throw new B(`${t} is not a string`);if(!e.isWellFormed())throw new B(`${t} is not well-formed Unicode`)}function jo(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}var Mo=(e,t)=>e.length>t||e.length*3>t&&jo(e)>t;function No(e,t){try{return f(e)}catch{throw new B(`${t} is not well-formed Unicode`)}}function Po(e,t,n){try{return m(e)}catch{throw new B(`${t} is not valid UTF-8`,n)}}var Fo={file:420,directory:493,symlink:511},Io=e=>e===`file`||e===`contiguous-file`,Lo=e=>e.type===`directory`?`${e.name}/`:e.name;function Ro(e,t){if(typeof e!=`object`||!e)throw new B(`an entry is not an object`);let n=e.type??`file`;if(typeof n!=`string`)throw new B(`entry type is not a string`);if(!Object.hasOwn(t,n))throw new B(`entry type ${V(n)} is not one this package writes`);let{name:r}=e;Ao(r,`entry name`);let i=e.data??so;if(!(i instanceof Uint8Array))throw new B(`data of ${V(r)} is not a Uint8Array`);if(i.length!==0&&!Io(n))throw new B(`a ${n} cannot carry data (${V(r)})`);let a=e.linkname??``;if(Ao(a,`link target of ${V(r)}`),a!==``&&n!==`hardlink`&&n!==`symlink`)throw new B(`a ${n} cannot have a link target (${V(r)})`);return{name:r,type:n,data:i,linkname:a}}var zo=512,Bo=e=>e===`character-device`||e===`block-device`,Vo={file:48,hardlink:49,symlink:50,"character-device":51,"block-device":52,directory:53,fifo:54,"contiguous-file":55},Ho={pax:120,global:103,longname:76,longlink:75},Uo=100,Wo=155,Go=32,Ko=0,qo=[[`mode`,100,8],[`uid`,108,8],[`gid`,116,8],[`size`,124,12],[`mtime`,136,12]],Jo=148,Yo=156,Xo=157,Zo=257,Qo=265,$o=297,es=329,ts=337,ns=345,rs=386,is=495,as=`ustar\x0000`,os=`ustar \0`,ss=e=>Uint8Array.from(e,e=>e.codePointAt(0)),cs=e=>String.fromCodePoint(...e),ls=(e,t,n,r)=>e.subarray(t,t+n).set(r),us=(e,t,n)=>hs(e.subarray(t,t+n)),ds=e=>8**(e-1)-1,fs=(e,t)=>e>=0&&e<=ds(t);function ps(e,t,n,r,i){if(fs(r,n)){ls(e,t,n,ss(r.toString(8).padStart(n-1,`0`)));return}if(!i)throw new B(`${r} does not fit an octal field of ${n-1} digits`);e[t]=r<0?255:128;let a=BigInt.asUintN((n-1)*8,BigInt(r));for(let r=t+n-1;r>t;r--)e[r]=Number(a&255n),a>>=8n}function ms(e,t,n,r,i,a=!1){let o=e[t];if(o===128||o===255){let s=0n;for(let r=t+1;r<t+n;r++)s=s<<8n|BigInt(e[r]);if(o===255&&(s=BigInt.asIntN((n-1)*8,s)),s<0n&&!a)throw new B(`the ${r} field is negative`,i);if(s>BigInt(2**53-1)||s<-BigInt(2**53-1))throw new B(`the ${r} field is too large`,i);return Number(s)}let s=/^ *([0-7]*) *$/u.exec(cs(us(e,t,n)));if(!s)throw new B(`the ${r} field is not an octal number`,i);return s[1]===``?0:Number.parseInt(s[1],8)}function hs(e){let t=e.indexOf(0);return t===-1?e:e.subarray(0,t)}function gs(e){let t=256;for(let n=0;n<Jo;n++)t+=e[n];for(let n=Jo+8;n<zo;n++)t+=e[n];return t}var _s=e=>e.every(e=>e===0);function vs(e){let t=new Uint8Array(zo);ls(t,Ko,Uo,e.name);for(let[n,r,i]of qo)ps(t,r,i,e[n],e.gnu);return t[Yo]=e.typeflag,ls(t,Xo,Uo,e.linkname),ls(t,Zo,8,ss(e.gnu?os:as)),ls(t,Qo,Go-1,e.uname),ls(t,$o,Go-1,e.gname),e.devmajor!==null&&ps(t,es,8,e.devmajor,e.gnu),e.devminor!==null&&ps(t,ts,8,e.devminor,e.gnu),ls(t,ns,Wo,e.prefix),ls(t,Jo,8,ss(`${gs(t).toString(8).padStart(6,`0`)}\0 `)),t}var ys=(e,t,n)=>/^ *[0-7]+ *$/u.test(cs(us(e,t,n)));function bs(e,t){if(gs(e)!==ms(e,Jo,8,`checksum`,t))throw new B(`header checksum does not match`,t);let n=cs(e.subarray(Zo,Zo+8)),r=n===os;if(!r&&n!==as)throw new B(`header is not in the ustar, pax or gnu format`,t);if(r&&!_s(e.subarray(rs,is)))throw new B(`header carries an old GNU sparse map or real size`,t);let i=e[Yo],a=i===Vo[`character-device`]||i===Vo[`block-device`];return{gnu:r,typeflag:i,name:us(e,Ko,Uo),prefix:r?so:us(e,ns,Wo),linkname:us(e,Xo,Uo),uname:us(e,Qo,Go),gname:us(e,$o,Go),...Object.fromEntries(qo.map(([n,r,i])=>[n,ms(e,r,i,n,t,n===`mtime`)])),devmajor:a?ms(e,es,8,`devmajor`,t):0,devminor:a?ms(e,ts,8,`devminor`,t):0,octal:[[`checksum`,Jo,8],...qo,...a?[[`devmajor`,es,8],[`devminor`,ts,8]]:[]].every(([,t,n])=>ys(e,t,n))}}var xs=4096,Ss=255;function Cs(e,t){if(Ao(e,t),e===``)throw new B(`${t} is empty`);if(ko(e,!0))throw new B(`${t} ${V(e)} holds a control or formatting character, or a backslash`);if(e.startsWith(`/`))throw new B(`${t} ${V(e)} is absolute`);let n=e.split(`/`);if(/^[a-zA-Z]:/u.test(n.find(e=>e!==`.`)??``))throw new B(`${t} ${V(e)} starts with a drive letter`);if(Mo(e,xs))throw new B(`${t} ${V(e)} is longer than ${xs} bytes`);if(n.some(e=>Mo(e,Ss)))throw new B(`${t} ${V(e)} has a segment longer than ${Ss} bytes`);return n}function ws(e,t,n=!1){let r=Cs(e,t),i=r.at(-1)===``;if(i){if(!n)throw new B(`${t} ${V(e)} ends in a slash but is not a directory`);r.pop()}let a=r.filter(e=>e!==`.`);for(let n of a){if(n===``)throw new B(`${t} ${V(e)} has an empty segment`);if(n===`..`)throw new B(`${t} ${V(e)} has a .. segment`)}if(a.length===0){if(!n)throw new B(`${t} ${V(e)} names the archive root but is not a directory`);return`.`}let o=i||a.length<r.length?a.join(`/`):e;if(Mo(o,xs-+!!n))throw new B(`${t} ${V(e)} is longer than ${xs} bytes`);return o}function Ts(e=0){if(!(Number.isSafeInteger(e)&&e>=0))throw new B(`symlinksAbove ${String(e)} is not a whole number of levels`);return e}function Es(e,t,n=0){let r=Cs(t,`symlink target of ${V(e)}`).filter(e=>e!==``&&e!==`.`),i=e.split(`/`).length-1;for(let a of r)if(i+=a===`..`?-1:1,i<-n){let r=n===0?`outside the archive`:`more than ${n} level${n===1?``:`s`} above the archive`;throw new B(`symlink ${V(e)} points ${r}, to ${V(t)}`)}return r}function Ds(e,t,n,r=0){let i=ws(e,`entry name`,t===`directory`),a=n;return t===`symlink`?Es(i,n,r):t===`hardlink`&&(a=ws(n,`hard link target of ${V(i)}`)),{name:i,linkname:a}}var Os=()=>({kind:void 0,entry:void 0,symlink:void 0,first:void 0,firstNode:void 0,rest:void 0});function ks(e,t,n=!0){if(e.first===t)return e.firstNode;let r=e.rest?.get(t);return r!==void 0||!n||(r=Os(),e.first===void 0?(e.first=t,e.firstNode=r):(e.rest??=new Map,e.rest.set(t,r))),r}var As=[`type`,`mode`,`uid`,`gid`,`mtime`,`uname`,`gname`,`linkname`,`devmajor`,`devminor`],js=class{#e=Os();#t;#n;constructor(e=!1,t=0){this.#t=e,this.#n=t}get above(){return this.#n}add(e){let{name:t,type:n}=e,r=n===`symlink`?e.linkname:void 0;if(n===`hardlink`){let n=this.#o(e.linkname);if(n?.kind!==`entry`)throw new B(`hard link ${V(t)} targets ${V(e.linkname)}, which is not an earlier non-directory entry`);r=n.symlink,r!==void 0&&this.#r(t,r,`hard link ${V(t)} to symlink ${V(e.linkname)}`)}let i=t.split(`/`),a=this.#a(i),o=a.at(-1);if(o.kind!==void 0&&o.kind!==`implied`){let n=As.find(t=>o.entry[t]!==e[t]);if(n!==void 0)throw new B(`duplicate entry ${V(t)} differs in ${n}`);if(o.entry.data===void 0)throw new B(`duplicate entry ${V(t)}, which only the in-memory call can compare with the earlier one`);if(!lo(o.entry.data,e.data))throw new B(`duplicate entry ${V(t)} differs in data`);return}let s=n===`directory`?`directory`:`entry`;if(o.kind!==void 0&&s!==`directory`)throw new B(`${V(t)} is already a directory, so it cannot be a ${n}`);for(let e=1;e<i.length;e++)this.#i(a[e],()=>`${V(t)} is inside ${V(i.slice(0,e).join(`/`))}, which is not a directory`);o.kind=s,o.symlink=r,o.entry=this.#t?e:Object.fromEntries(As.map(t=>[t,e[t]])),n===`symlink`&&this.#r(t,e.linkname,`symlink ${V(t)}`)}#r(e,t,n){let r=Es(e,t,this.#n),i=e.split(`/`).slice(0,-1),a=this.#a(i);for(let[e,t]of r.entries()){if(t===`..`){if(i.length===0)return;i.pop(),a.pop()}else i.push(t),a.push(ks(a.at(-1),t));e<r.length-1&&i.length&&this.#i(a.at(-1),()=>`the target of ${n} passes through ${V(i.join(`/`))}, which is not a directory`)}}#i(e,t){if(e.kind===`entry`)throw new B(t());e.kind??=`implied`}#a(e){let t=[this.#e];for(let n of e)t.push(ks(t.at(-1),n));return t}#o(e){let t=this.#e;for(let n of e.split(`/`))if(t=ks(t,n,!1),t===void 0)return;return t}};function Ms(e,t){let n=f(` ${e}=${t}
34
+ `),r=String(n.length).length,i=n.length+r+ +(String(n.length+r).length>r);return uo([f(String(i)),n])}var Ns=e=>uo(e.map(([e,t])=>Ms(e,t))),Ps=`pax records cannot be changed`,Fs=class extends Map{set(){throw TypeError(Ps)}delete(){throw TypeError(Ps)}clear(){throw TypeError(Ps)}},Is=(e,t,n)=>Map.prototype.set.call(e,t,n);function Ls(e,t){let n=new Fs;for(let r=0;r<e.length;){let i=r,a=0;for(;i<e.length&&e[i]>=48&&e[i]<=57;i++)a=a*10+(e[i]-48);if(i===r||e[r]===48||e[i]!==32)throw new B(`a pax record does not begin with its length`,t);let o=r+a;if(o>e.length||e[o-1]!==10)throw new B(`a pax record is not as long as it says`,t);let s=e.indexOf(61,i+1);if(s===-1||s>=o-1)throw new B(`a pax record has no keyword=value`,t);let c=Po(e.subarray(i+1,s),`a pax record`,t);if(c===``||ko(c,!1)||c.includes(` `))throw new B(`pax keyword ${V(c)} is malformed`,t);if(n.has(c))throw new B(`pax keyword ${c} repeats`,t);Is(n,c,Po(e.subarray(s+1,o-1),`a pax record`,t)),r=o}return n}var Rs=new Set([`gnu`,`ustar`,`pax`]),zs=47;function Bs(e,t,n=!1){if(!Number.isSafeInteger(e)||!n&&e<0)throw new B(`${t} ${String(e)} is not ${n?`an integer`:`a non-negative integer`}`);return e}function Vs(e,t){if(Ao(e,t),ko(e,!1))throw new B(`${t} ${V(e)} holds a control or formatting character`);return e}function Hs(e){let t=Ro(e,Vo),{name:n,type:r}=t,i=Bs(e.devmajor??0,`devmajor`),a=Bs(e.devminor??0,`devminor`);if((i!==0||a!==0)&&!Bo(r))throw new B(`a ${r} cannot have device numbers (${V(n)})`);let o=Bs(e.mode??Fo[r]??420,`mode`);if(o>4095)throw new B(`mode ${o.toString(8)} has bits beyond the permission bits`);return{...t,mode:o,uid:Bs(e.uid??0,`uid`),gid:Bs(e.gid??0,`gid`),mtime:Bs(e.mtime??0,`mtime`,!0),uname:Vs(e.uname??``,`uname`),gname:Vs(e.gname??``,`gname`),devmajor:i,devminor:a}}function Us(e,t=e.length){let n=new Uint8Array(Math.ceil(t/zo)*zo);return n.set(e),n}var Ws=(e,t,n,r,i)=>vs({gnu:i,name:No(e,`header name`).subarray(0,Uo),prefix:so,linkname:so,uname:so,gname:so,typeflag:r,mode:420,uid:0,gid:0,size:t,mtime:n,devmajor:null,devminor:null}),Gs=(e,t)=>[Ws(`././@LongLink`,e.length+1,0,t,!0),Us(e,e.length+1)];function Ks(e,t){let n=Ns(t),r=e.name.lastIndexOf(`/`);return[Ws(r===-1?`./PaxHeaders/${e.name}`:`${e.name.slice(0,r)}/PaxHeaders/${e.name.slice(r+1)}`,n.length,Math.max(0,Math.min(e.mtime,ds(12))),Ho.pax,!1),Us(n)]}function qs(e,t){let{length:n}=e;if(n>Wo+Uo+1)throw new B(`name ${V(t)} is longer than 256 bytes, which ustar cannot hold`);let r=n;r>Wo+1?r=Wo+1:e[r-1]===zs&&r--;let i=r-1;for(;i>0&&e[i]!==zs;)i--;let a=n-i-1;if(i===0||a>Uo||a===0)throw new B(`name ${V(t)} cannot be split into ustar's prefix and name fields`);return{prefix:e.subarray(0,i),name:e.subarray(i+1)}}function Js(e,t){let n=t===`gnu`,r=[],i=[],a=Lo(e),o=No(a,`entry name`),s=so,c=No(e.linkname,`link target of ${V(e.name)}`);if(c.length>Uo){if(n)i.push(...Gs(c,Ho.longlink));else if(t===`pax`)r.push([`linkpath`,e.linkname]);else throw new B(`link target of ${V(e.name)} is longer than 100 bytes, which ustar cannot hold`);c=c.subarray(0,Uo)}t===`pax`&&(o.length>Uo||!co(o))&&r.push([`path`,a]),o.length>Uo&&(n?i.push(...Gs(o,Ho.longname)):t===`ustar`&&({prefix:s,name:o}=qs(o,e.name)),o.length>Uo&&(o=o.subarray(0,Uo)));let l=(i,a,o)=>{if(n||fs(a,o))return a;if(t===`pax`)return r.push([i,String(a)]),0;throw new B(`${i} ${a} of ${V(e.name)} does not fit the ustar format`)},u=(n,i)=>{let a=No(i,n);if(a.length<Go&&(t!==`pax`||co(a)))return a;if(t!==`pax`)throw new B(`${n} of ${V(e.name)} is longer than 31 bytes, which the ${t} format cannot hold`);return r.push([n,i]),a.subarray(0,Go-1)},d=Bo(e.type),f={gnu:n,name:o,prefix:s,linkname:c,typeflag:Vo[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:d?l(`devmajor`,e.devmajor,8):null,devminor:d?l(`devminor`,e.devminor,8):null,uname:u(`uname`,e.uname),gname:u(`gname`,e.gname)};r.length&&i.push(...Ks(e,r)),i.push(vs(f));let p=e.data.length%zo;return e.data.length&&i.push(e.data),p&&i.push(new Uint8Array(zo-p)),i}function Ys({format:e=`gnu`,blocking:t=20,symlinksAbove:n}={},r=!1){if(!Rs.has(e))throw new B(`format ${V(String(e))} is not gnu, ustar or pax`);if(!Number.isSafeInteger(t)||t<1)throw new B(`blocking is not a positive integer`);let i=new js(r,Ts(n)),a=0;return{add(t){let n=Hs(t),r={...n,...Ds(n.name,n.type,n.linkname,i.above)};i.add(r);let o=Js(r,e);for(let e of o)a+=e.length;return o},end(){let e=t*zo,n=(a+2*zo)%e;return[new Uint8Array(2*zo+(n?e-n:0))]}}}function Xs(e,t){let n=Ys(t,!0),r=[];for(let t of e)r.push(...n.add(t));return uo([...r,...n.end()])}var Zs=e=>Object.entries(e).map(([e,t])=>[t,e]),Qs=new Map([...Zs(Vo),[0,`file`]]),$s=new Map(Zs(Ho)),ec=1<<20,tc=new Set([`SCHILY.realsize`,`SUN.holesdata`]);function nc(e,t){if(e.some(e=>e.startsWith(`GNU.sparse.`)||tc.has(e)))throw new B(`sparse entries are not supported`,t)}function rc(e,t,n){if(!/^(?:0|[1-9][0-9]*)$/u.test(e)||!Number.isSafeInteger(Number(e)))throw new B(`pax ${t}=${V(e)} is not a whole number this package can hold`,n);return Number(e)}function ic(e,t,n){let r=/^(-?)([0-9]+)(?:\.([0-9]+))?$/u.exec(e);if(!r)throw new B(`pax ${t}=${V(e)} is not a time`,n);let[,i,a,o=``]=r,s=Number(i+a)-(i&&/[1-9]/u.test(o)?1:0);if(!Number.isSafeInteger(s))throw new B(`pax ${t}=${V(e)} is out of range`,n);return s}var ac=()=>({pax:null,longname:null,longlink:null}),oc=new Fs,sc=Object.freeze([]),cc=e=>e.gnu?`gnu`:`ustar`,lc=class{#e=[];#t=0;#n=0;#r=0;#i;#a=ac();#o=[];#s=null;#c=null;#l=0;#u=!1;#d=0;#f;#p;constructor(e,{symlinksAbove:t,maxEntries:n=1/0,trailingGlobal:r=!1}={}){if(n!==1/0&&!(Number.isSafeInteger(n)&&n>=0))throw new B(`maxEntries ${String(n)} is not a whole number of entries`);if(typeof r!=`boolean`)throw new B(`trailingGlobal ${String(r)} is not a boolean`);this.#i=new js(e,Ts(t)),this.#f=n,this.#p=r}*push(e){if(!(e instanceof Uint8Array))throw new B(`a chunk is not a Uint8Array`);if(this.#u){this.#h(e,this.#r),this.#r+=e.length;return}e.length&&(this.#e.push(e),this.#n+=e.length);let t=[],n=!0;for(;n&&!this.#u;)n=this.#c===null?this.#g():this.#_(t),yield*t.splice(0)}end(){if(!this.#u)throw this.#r===0&&this.#n===0?new B(`the archive is empty`):this.#c===null&&this.#n===0?new B(this.#l?`the archive ends with a lone zero block`:`the archive has no end marker`,this.#r):new B(`the archive is truncated`,this.#r)}#m(e){if(this.#n<e)return null;if(e===0)return so;let t;if(this.#t+e<=this.#e[0].length)t=this.#e[0].subarray(this.#t,this.#t+e),this.#t+=e;else{t=new Uint8Array(e);let n=0;for(let r=0,i=this.#t;r<e;n++,i=0){let a=this.#e[n].subarray(i,i+e-r);t.set(a,r),r+=a.length,this.#t=i+a.length}this.#e=this.#e.slice(n-1)}return this.#t===this.#e[0].length&&(this.#e.shift(),this.#t=0),this.#n-=e,this.#r+=e,t}#h(e,t){if(!_s(e))throw new B(`data after the end of the archive`,t)}#g(){let e=this.#m(zo);if(e===null)return!1;let t=this.#r-zo;if(_s(e)){if(this.#o.some(({kind:e})=>e!==`global`||!this.#p))throw new B(`an extended header is not followed by an entry`,t);if(++this.#l===2){this.#u=!0;let e=this.#r;this.#h(this.#m(this.#n),e)}return!0}if(this.#l)throw new B(`a lone zero block where a header should be`,t);let n=bs(e,t),r=$s.get(n.typeflag);if(r===void 0){if(++this.#d>this.#f)throw new B(`the archive holds more than ${this.#f} entries`,t,{limited:!0});this.#c={extended:null,at:t,...this.#v(n,t)}}else{if(n.size>ec)throw new B(`a ${r} header of ${n.size} bytes is longer than any tar writes`,t);this.#c={extended:r,size:n.size,at:t,entry:null,magic:cc(n),octal:n.octal}}return!0}#_(e){let{extended:t,size:n,at:r,entry:i,magic:a,octal:o}=this.#c,s=Math.ceil(n/zo)*zo,c=this.#m(s);if(c===null)return!1;if(!_s(c.subarray(n)))throw new B(`the padding after an entry is not zero`,r);this.#c=null;let l=c.subarray(0,n);if(t===null)return i.data=l,fo(()=>this.#i.add(i),r),e.push(i),!0;if(t===`global`){this.#s=Ls(l,r);let e=[`path`,`linkpath`,`size`].find(e=>this.#s.has(e));if(e!==void 0)throw new B(`a global header sets ${e}`,r);nc(this.#s.keys(),r)}else{if(this.#a[t]!==null)throw new B(`two ${t} headers ahead of one entry`,r);this.#a[t]=t===`pax`?Ls(l,r):Po(hs(l),`a ${t} header`,r)}return this.#o.push(Object.freeze({kind:t,magic:a,octal:o})),!0}#v(e,t){let n=Qs.get(e.typeflag);if(n===void 0)throw new B(`entry type ${V(String.fromCodePoint(e.typeflag))} is not one this package reads`,t);let{pax:r,longname:i,longlink:a}=this.#a;this.#a=ac();let o=e=>r?.get(e)??this.#s?.get(e);if(r!==null&&nc(r.keys(),t),i!==null&&o(`path`)!==void 0)throw new B(`both a long name header and a pax path name one entry`,t);if(a!==null&&o(`linkpath`)!==void 0)throw new B(`both a long link header and a pax linkpath name one entry`,t);let s=i??o(`path`)??this.#y(e,t),c=a??o(`linkpath`)??Po(e.linkname,`link target`,t),{name:l,linkname:u}=fo(()=>Ds(s,n,c,this.#i.above),t),d=(n,r=rc)=>{let i=o(n);return i===void 0?e[n]:r(i,n,t)},f=d(`size`);if(f!==0&&!Io(n))throw new B(`a ${n} entry has a size`,t);if(u!==``&&n!==`hardlink`&&n!==`symlink`)throw new B(`a ${n} entry has a link target`,t);let p=n=>{let r=o(n)??Po(e[n],n,t);if(ko(r,!1))throw new B(`${n} ${V(r)} holds a control or formatting character`,t);return r},m=Bo(n),h={name:l,type:n,mode:e.mode&4095,uid:d(`uid`),gid:d(`gid`),mtime:d(`mtime`,ic),uname:p(`uname`),gname:p(`gname`),linkname:u,devmajor:m?d(`devmajor`):0,devminor:m?d(`devminor`):0,data:so,storedName:s,storedLinkname:c,pax:r??oc,globalPax:this.#s??oc,extended:this.#o.length?Object.freeze(this.#o):sc,magic:cc(e),typeflag:String.fromCodePoint(e.typeflag),storedMode:e.mode,octal:e.octal};return this.#o=[],{entry:h,size:f}}#y(e,t){let n=Po(e.name,`entry name`,t);return e.prefix.length?`${Po(e.prefix,`name prefix`,t)}/${n}`:n}};function uc(e,t){let n=new lc(!0,t),r=[...n.push(e)];return n.end(),r}var dc=new Map([[7,`a`],[8,`b`],[12,`f`],[10,`n`],[13,`r`],[9,`t`],[11,`v`]]),fc=e=>`\\`+e.toString(8).padStart(3,`0`);function pc(e,t){let n=tn(t),r=yn(t.locale),i=``;for(let t of e){let e=t.codePointAt(0);if(t===`\\`)i+=`\\\\`;else if(dc.has(e))i+=`\\`+dc.get(e);else if(e<128?e>=32&&e<127:!n&&r.has(`print`,e))i+=t;else for(let e of E(t))i+=fc(e)}return i}var mc={__proto__:null,file:`-`,"contiguous-file":`C`,directory:`d`,symlink:`l`,hardlink:`h`,fifo:`p`,"character-device":`c`,"block-device":`b`};function hc(e,t){let n=[...`rwxrwxrwx`].map((e,n)=>t&256>>n?e:`-`),r=(e,r,i)=>{(t&e)!==0&&(n[r]=n[r]===`x`?i:i.toUpperCase())};return r(2048,2,`s`),r(1024,5,`s`),r(512,8,`t`),mc[e]+n.join(``)}var gc=e=>E(e).length,_c=new Set([`character-device`,`block-device`]);function vc(e,{numericOwner:t=!1,utc:n=!1}={}){let r=19,i=16,a=n||e.vars.has(`TZ`),o=n=>{let o=!t&&n.uname!==``?n.uname:String(n.uid),s=!t&&n.gname!==``?n.gname:String(n.gid),c=_c.has(n.type)?`${n.devmajor},${n.devminor}`:String(n.data.length),l=gc(o)+1+gc(s)+1+c.length;l>r&&(r=l);let u=bc(n.mtime,a);return u.length>i&&(i=u.length),`${hc(n.type,n.mode)} ${o}/${s} ${` `.repeat(r-l)}${c} ${u.padEnd(i)} `+pc(wo(n),e)+yc(n,e)};return o.mkdir=t=>`${hc(`directory`,448)} ${`Creating directory:`.padStart(r+1+i)} ${pc(t,e)}`,o}function yc(e,t){return e.type===`symlink`?` -> ${pc(e.linkname,t)}`:e.type===`hardlink`?` link to ${pc(e.linkname,t)}`:``}function bc(e,t){let n=new Date(e*1e3);if(Number.isNaN(n.getTime()))throw new T(`feature`,`archive time`,`a modification time of ${e} seconds is past what this terminal can print`);return Db(n,`%Y-%m-%d %H:%M`,t)}var H=(e,t)=>pc(e,t).replaceAll(`:`,`\\:`);function xc(e,t){let n=pc(e,t);return tn(t)?`'${n.replaceAll(`'`,`\\'`)}'`:`\u2018${n}\u2019`}function Sc(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)t--;return e.slice(0,t)}function Cc(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`)t++;else if(`?*[]`.includes(e[t]))return!0;return!1}var wc=(e,t)=>t===e||t.startsWith(e)&&t[e.length]===`/`;function Tc(e){let t=[],n=[];for(let r of e)r.dir===void 0?r.name!==``&&t.push({given:r.name,operand:Sc(r.name),dirs:[...n],found:!1}):n.push(r.dir);let r={dirs:n};return{names:t,match(e){if(t.length===0)return r;let n=t.find(t=>wc(t.operand,e));return n!==void 0&&(n.found=!0),n??null}}}function Ec(e,t,n){for(let r of e.names)r.found||(!n&&Cc(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(`${H(r.operand,t.ctx)}: Not found in archive`))}function Dc(e,t,n){let{ctx:r}=n,i=k(e,t,r.fs),a=i.error??(r.fs.isDir(i.path)?null:`Not a directory`);return a===null?i.path:(n.fatal(`${H(t,r)}: Cannot open: ${a}`),null)}async function Oc(e,t){try{return{bytes:await So(e,t),error:null}}catch(e){if(!(e instanceof po))throw e;return{bytes:e.bytes,error:e.cause?.cause?.message??e.cause?.message??`corrupt input`}}}var kc=10,Ac=8,jc=8,Mc=16,Nc=4,Pc=2,Fc=8,Ic=`gzip`,Lc=`deflate-raw`,Rc=(e,t)=>e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216;function zc(e,t){if(e[t]!==31||e[t+1]!==139||e[t+2]!==jc)return-1;let n=e[t+3],r=t+kc;if((n&Nc)!==0){if(r+2>e.length)return-1;r+=2+e[r]+e[r+1]*256}for(let t of[Fc,Mc])if((n&t)!==0){for(;r<e.length&&e[r]!==0;)r++;r++}return(n&Pc)!==0&&(r+=2),r<=e.length?r-t:-1}var Bc=64;async function Vc(e,t){let n=zc(e,t);if(n<0)return null;let r=(await Oc(e.subarray(t+n),Lc)).bytes.length%4294967296,i=Bc;for(let a=t+n+Ac;a<=e.length&&i>0;a++){if(Rc(e,a-4)!==r)continue;i--;let n=await Oc(e.subarray(t,a),Ic);if(n.error===null)return{bytes:n.bytes,end:a}}return null}async function Hc(e){let t=await Oc(e,Ic);if(t.error===null||!mo(Lc))return{...t,rest:null};let n=[],r=0;for(;;){let t=await Vc(e,r);if(t===null)break;n.push(t.bytes),r=t.end}return r===0||r===e.length?{...t,rest:null}:{bytes:lt(n),error:t.error,rest:e.subarray(r)}}function U(e,t={}){let n=Wc(t.short),r=Wc(t.long),i=Wc(t.valueShort),a=Wc(t.valueLong),o=Wc(t.repeatable),s=new Set,c=new Map,l=[],u=[],d=0;function f(t,l,f=!1){let p=(f?`--`:`-`)+t,m=(f?a:i).has(t)||o.has(t)&&(!f||t.length>1);if(m){let n=l??e[++d];if(l===null&&d>=e.length)throw Error(p+` requires an argument`);if(o.has(t)){let e=c.get(t);e?e.push(n):c.set(t,[n])}else c.set(t,n);u.push({name:t,value:n})}else{if(!(f?r:n).has(t))throw new T(`option`,p,`unknown option: `+p);if(f&&l!==null)throw Error(`option `+p+` doesn't allow an argument`);s.add(t),u.push({name:t})}return m}for(;d<e.length;d++){let r=e[d];if(r===`--`){l.push(...e.slice(d+1));break}if(r.startsWith(`--`)&&r.length>2){let e=r.indexOf(`=`);f(e===-1?r.slice(2):r.slice(2,e),e===-1?null:r.slice(e+1),!0);continue}if(r.startsWith(`-`)&&r.length>1&&!(t.numericOperands&&Uc(r,n,i,o))){for(let e=1;e<r.length&&!f(r[e],e+1<r.length?r.slice(e+1):null);e++);continue}if(t.stopAtFirstPositional){l.push(...e.slice(d));break}l.push(r)}return{flags:s,values:c,positional:l,order:u}}function Uc(e,t,n,r){if(!/^-\d/u.test(e))return!1;let i=e[1];return!t.has(i)&&!n.has(i)&&!r.has(i)}function Wc(e){return e instanceof Set?e:new Set(e??[])}var Gc=`gzip`,Kc=(e,t,n)=>ul(e,[`-d`,...t],n),qc=(e,t,n)=>ul(e,[`-d`,`-c`,...t],n),Jc=mo(Gc)?{gzip:ul,gunzip:Kc,zcat:qc,gzcat:qc}:{},Yc=Object.freeze([31,139]),Xc=e=>e!==void 0&&e.length>=2&&e[0]===Yc[0]&&e[1]===Yc[1],Zc=Object.freeze([[31,158],[31,30],[31,157],[31,160]]),Qc=Object.freeze([80,75,3,4]),$c=(e,t)=>e.length>=t.length&&t.every((t,n)=>e[n]===t),el=(e,t)=>Zc.some(t=>$c(e,t))||t&&$c(e,Qc);function tl(e,t){return t.gap??=C(`feature`,`gzip`,`other formats`,`gzip: ${e}: data compressed other than by gzip is not supported`,1),!1}var nl={__proto__:null,"unexpected end of file":`unexpected end of file`,"incorrect data check":`invalid compressed data--crc error`},rl=e=>nl[e]??`invalid compressed data--format violated`,il=8;function al(e,t){let n=t.rest,r=t=>({text:`
35
35
  gzip: ${e}: ${t}
36
- `,status:1,whole:!1});return n===null?r(el(t.error)):n.every(e=>e===0)?null:n.length>=2&&!qc(n)?{text:`
36
+ `,status:1,whole:!1});return n===null?r(rl(t.error)):n.every(e=>e===0)?null:n.length>=2&&!Xc(n)?{text:`
37
37
  gzip: ${e}: decompression OK, trailing garbage ignored
38
- `,status:2,whole:!0}:n.length>2&&n[2]!==tl?{text:`gzip: ${e}: unknown method ${n[2]} -- not supported
39
- `,status:1,whole:!0}:r(el(t.error))}function rl(e,t,n){let r=nl(t,n);return r===null||(e.stderr+=r.text,e.status=e.status===1?1:r.status),!1}var il=Object.freeze({__proto__:null,".gz":``,".tgz":`.tar`,".taz":`.tar`,"-gz":``,".z":``,"-z":``,_z:``}),al=`.gz`,ol=Object.freeze([`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]);async function sl(e,t,n){let{flags:r,positional:i}=U(t,{short:[...ol,`d`,`c`,`k`,`f`],long:[`decompress`,`uncompress`,`stdout`,`to-stdout`,`keep`,`force`]}),a=ol.find(e=>r.has(e));if(a!==void 0)return C(`option`,`gzip`,`-${a}`,`gzip: -${a}: choosing a compression level is not supported`,1);let o={decompressing:[`d`,`decompress`,`uncompress`].some(e=>r.has(e)),stdout:[`c`,`stdout`,`to-stdout`].some(e=>r.has(e)),keep:r.has(`k`)||r.has(`keep`),force:r.has(`f`)||r.has(`force`)},s={ctx:n,events:[],stderr:``,status:0,gap:null,stopped:!1};if(i.length===0)await cl(o,s);else for(let e of i)if(await ll(e,o,s),s.stopped)break;if(s.gap)return s.gap;let c=[...s.events,...s.stderr?[{fd:2,text:s.stderr}]:[]];return{stdout:``,stderr:s.stderr,exitCode:s.status,events:c}}async function cl(e,t){if(!e.force&&(e.decompressing?Fn(t.ctx):In(t.ctx))){let[n,r]=e.decompressing?[`read from`,`decompression`]:[`written to`,`compression`];t.stderr+=`gzip: compressed data not ${n} a terminal. Use -f to force ${r}.
38
+ `,status:2,whole:!0}:n.length>2&&n[2]!==il?{text:`gzip: ${e}: unknown method ${n[2]} -- not supported
39
+ `,status:1,whole:!0}:r(rl(t.error))}function ol(e,t,n){let r=al(t,n);return r===null||(e.stderr+=r.text,e.status=e.status===1?1:r.status),!1}var sl=Object.freeze({__proto__:null,".gz":``,".tgz":`.tar`,".taz":`.tar`,"-gz":``,".z":``,"-z":``,_z:``}),cl=`.gz`,ll=Object.freeze([`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]);async function ul(e,t,n){let{flags:r,positional:i}=U(t,{short:[...ll,`d`,`c`,`k`,`f`],long:[`decompress`,`uncompress`,`stdout`,`to-stdout`,`keep`,`force`]}),a=ll.find(e=>r.has(e));if(a!==void 0)return C(`option`,`gzip`,`-${a}`,`gzip: -${a}: choosing a compression level is not supported`,1);let o={decompressing:[`d`,`decompress`,`uncompress`].some(e=>r.has(e)),stdout:[`c`,`stdout`,`to-stdout`].some(e=>r.has(e)),keep:r.has(`k`)||r.has(`keep`),force:r.has(`f`)||r.has(`force`)},s={ctx:n,events:[],stderr:``,status:0,gap:null,stopped:!1};if(i.length===0)await dl(o,s);else for(let e of i)if(await fl(e,o,s),s.stopped)break;if(s.gap)return s.gap;let c=[...s.events,...s.stderr?[{fd:2,text:s.stderr}]:[]];return{stdout:``,stderr:s.stderr,exitCode:s.status,events:c}}async function dl(e,t){if(!e.force&&(e.decompressing?In(t.ctx):Ln(t.ctx))){let[n,r]=e.decompressing?[`read from`,`decompression`]:[`written to`,`compression`];t.stderr+=`gzip: compressed data not ${n} a terminal. Use -f to force ${r}.
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 F(t.ctx,``,!0),e.decompressing?_l(`stdin`,r??E(n),{...e,stdout:!0},t):bl(await go(r??E(n),Hc),t)}function ll(e,t,n){let{ctx:r}=n;if(e===`-`)return cl(t,n);if(!t.stdout&&!t.force&&ul(e,r))return wl(n,`${e}: Too many levels of symbolic links`,1);let i=N(r,`gzip`,e);return i.error?wl(n,`${e}: ${i.error}`,1):r.fs.isDir(i.path)?wl(n,`${e} is a directory -- ignored`,2):t.decompressing?gl(e,i.path,t,n):dl(e,i.path,t,n)}function ul(e,t){let n=k(t.cwd,e,t.fs,{follow:!1});return n.path!==null&&t.fs.isLink?.(n.path)===!0}async function dl(e,t,n,r){let{ctx:i}=r,a=vl(e);if(!n.stdout&&!n.force&&a!==void 0)return Cl(r,`${e} already has ${a} suffix -- unchanged`);let o=hl(await go(Bn(i.fs,t),Hc),e.slice(e.lastIndexOf(`/`)+1),fl(i));return n.stdout?bl(o,r):xl(e+al,o,e,n,r)}var fl=e=>Math.floor(e.createdAt/1e3),pl=10,ml=8;function hl(e,t,n){let r=E(t);if(e.length<pl||e[3]!==0||r.includes(0))return e;let i=new Uint8Array(e.length+r.length+1);i.set(e.subarray(0,pl)),i[3]=ml;for(let e=0;e<4;e++)i[4+e]=n>>>8*e&255;return i.set(r,pl),i.set(e.subarray(pl),pl+r.length+1),i}function gl(e,t,n,r){let{ctx:i}=r;return!n.stdout&&vl(e)===void 0?wl(r,`${e}: unknown suffix -- ignored`,2):_l(e,Bn(i.fs,t),n,r,t)}async function _l(e,t,n,r,i=null){let{ctx:a}=r,o=n.force&&n.stdout;if(t!==void 0&&Zc(t,!0))return Qc(e,r);if(!qc(t))return o?bl(t,r):Sl(r,`${e}: ${yl(t,i,a)?`unexpected end of file`:`not in gzip format`}`);let s=await zc(t),c=s.rest,l=c!==null&&c.length>0&&!qc(c)?c:null;if(l!==null&&Zc(l,!1))return Qc(e,r);let u=vl(e);if(n.stdout?bl(s.bytes,r):xl(e.slice(0,-u.length)+il[u],s.bytes,e,n,r)){if(l!==null&&o)return bl(l,r);s.error&&rl(r,e,s)}}var vl=e=>Object.keys(il).find(t=>e.length>t.length&&e.endsWith(t));function yl(e,t,n){let r=e??p(n.fs.readFile(t).slice(0,2));return r.length===0||r.length===1&&r[0]!==0}var bl=(e,t)=>(t.events.push({fd:1,bytes:e}),!0);function xl(e,t,n,r,i){let{ctx:a}=i,o=k(a.cwd,e,a.fs,{follow:!1}).path;if(o!==null&&!r.force)return wl(i,`${e} already exists;${Fn(a)?` do you wish to overwrite (y or n)? `:``} not overwritten`,2);if(o!==null&&a.fs.isLink?.(o)!==!0&&a.fs.isDir(o))return wl(i,`${e}: Is a directory`,1);o!==null&&a.fs.removeWritable(a.cwd,e);let s;try{s=a.writable&&a.fs.openWritable?.(a.cwd,e)}catch(t){return wl(i,`${e}: ${t.message}`,1)}return s?(s.writeBytes(t),r.keep||a.fs.removeWritable(a.cwd,n),!0):(i.gap??=C(`feature`,`gzip`,`read-only target`,`gzip: ${e}: file system is read-only`,1),!1)}var Sl=(e,t)=>wl(e,t,1,`
42
- `),Cl=(e,t)=>wl(e,t,e.status);function wl(e,t,n,r=``){return e.stderr+=`${r}gzip: ${t}
43
- `,e.status=e.status===1?1:n,!1}var Tl=new Set([`atime`,`charset`,`comment`,`ctime`,`gid`,`gname`,`linkpath`,`mtime`,`path`,`size`,`uid`,`uname`,`RHT.security.selinux`,`SCHILY.acl.access`,`SCHILY.acl.default`]),El=e=>Tl.has(e)||e.startsWith(`SCHILY.xattr.`),Dl=e=>e===`GNU.dumpdir`||e.startsWith(`GNU.volume.`),Ol=-(2n**63n),kl=2n**63n-1n;function Al(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>=Ol&&n<=kl}function jl(e,t){for(let[n,r]of e){if(Dl(n))return[`extended header`,`${t(n)}: records of multi-volume and incremental archives are not supported`];if((n===`atime`||n===`ctime`)&&!Al(r))return[`extended header`,`${t(`${n}=${r}`)}: extended header times GNU would reject are not supported`]}return null}function Ml(e,t){let n=[],r=[],i=null;for(let a of e){let e=(a.globalPax===i?null:jl(a.globalPax,t))??jl(a.pax,t);if(e!==null)return{gap:e};i=a.globalPax;let o=So(a);if(o!==null){let[e,n]=xo(o);return{gap:[e,`${t(o)}: ${n}`]}}n.push([...a.pax.keys()].filter(e=>!El(e)).map(e=>`Ignoring unknown extended header keyword '${e}'`));let s=a.pax.get(`mtime`)??a.globalPax.get(`mtime`);r.push(s===void 0?a.mtime:Number(s))}return{warnings:n,mtimes:r}}var Nl=512,Pl=10,Fl=e=>({entries:[],child:e,warnings:[],mtimes:[]}),Il=[{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`}],Ll=e=>Il.find(({bytes:t})=>t.length<=e.length&&t.every((t,n)=>e[n]===t)),Rl={__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 zl(e){let t=e.lastIndexOf(`.`);return t===-1?void 0:Rl[e.slice(t+1)]}function Bl(e,t){return e.refuse(`option`,t,`${t}: archives compressed other than with gzip are not supported`),null}var Vl=e=>{let t=e.indexOf(`:`);return t!==-1&&!e.slice(0,t).includes(`/`)};function Hl(e,t){let{ctx:n}=t,r=e.archive;if(r===`-`){if(Fn(n))return t.fatal(`Refusing to read archive contents from terminal (missing -f option?)`);let e=n.stdinBytes??E(n.stdinLeft);return F(n,``,!0),{bytes:e,name:r,stdin:!0}}if(Vl(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 i=N(n,`tar`,r);return i.error?t.fatal(`${_c(r,n)}: Cannot open: ${i.error}`):n.fs.isDir(i.path)?(t.warn(`${_c(r,n)}: Cannot read: Is a directory`),t.fatal(`At beginning of tape, quitting now`)):{bytes:Bn(n.fs,i.path),name:r,stdin:!1}}function Ul(e,t){let n=Hl(e,t);if(!n)return null;let r=n.bytes;if(e.gzip)return Wl(r,t);let i=r.length>=Nl?Gl(r):null;if(i?.entries!==void 0)return ql(i.entries,t,0);let a=Ll(r);if(a!==void 0)return n.stdin?t.fatal(`Archive is compressed. Use ${a.option} option`):a.option===`-z`?Wl(r,t):Bl(t,a.option);let o=r.length<Nl;o&&t.error(`This does not look like a tar archive`);let s=n.stdin?void 0:zl(n.name);return s!==void 0&&s!==`-z`?Bl(t,s):o?s===void 0?Fl(0):Wl(r,t):Kl(i.error,t)}async function Wl(e,t){if(!fo(`gzip`))return t.refuse(`option`,`-z`,`this runtime has no gzip stream`);if(!qc(e))return t.say(2,`
41
+ `,t.status=1,t.stopped=!0;return}let n=t.ctx.stdinLeft,r=t.ctx.stdinBytes;return F(t.ctx,``,!0),e.decompressing?bl(`stdin`,r??E(n),{...e,stdout:!0},t):Cl(await vo(r??E(n),Gc),t)}function fl(e,t,n){let{ctx:r}=n;if(e===`-`)return dl(t,n);if(!t.stdout&&!t.force&&pl(e,r))return Dl(n,`${e}: Too many levels of symbolic links`,1);let i=N(r,`gzip`,e);return i.error?Dl(n,`${e}: ${i.error}`,1):r.fs.isDir(i.path)?Dl(n,`${e} is a directory -- ignored`,2):t.decompressing?yl(e,i.path,t,n):ml(e,i.path,t,n)}function pl(e,t){let n=k(t.cwd,e,t.fs,{follow:!1});return n.path!==null&&t.fs.isLink?.(n.path)===!0}async function ml(e,t,n,r){let{ctx:i}=r,a=xl(e);if(!n.stdout&&!n.force&&a!==void 0)return El(r,`${e} already has ${a} suffix -- unchanged`);let o=vl(await vo(Vn(i.fs,t),Gc),e.slice(e.lastIndexOf(`/`)+1),hl(i));return n.stdout?Cl(o,r):wl(e+cl,o,e,n,r)}var hl=e=>Math.floor(e.createdAt/1e3),gl=10,_l=8;function vl(e,t,n){let r=E(t);if(e.length<gl||e[3]!==0||r.includes(0))return e;let i=new Uint8Array(e.length+r.length+1);i.set(e.subarray(0,gl)),i[3]=_l;for(let e=0;e<4;e++)i[4+e]=n>>>8*e&255;return i.set(r,gl),i.set(e.subarray(gl),gl+r.length+1),i}function yl(e,t,n,r){let{ctx:i}=r;return!n.stdout&&xl(e)===void 0?Dl(r,`${e}: unknown suffix -- ignored`,2):bl(e,Vn(i.fs,t),n,r,t)}async function bl(e,t,n,r,i=null){let{ctx:a}=r,o=n.force&&n.stdout;if(t!==void 0&&el(t,!0))return tl(e,r);if(!Xc(t))return o?Cl(t,r):Tl(r,`${e}: ${Sl(t,i,a)?`unexpected end of file`:`not in gzip format`}`);let s=await Hc(t),c=s.rest,l=c!==null&&c.length>0&&!Xc(c)?c:null;if(l!==null&&el(l,!1))return tl(e,r);let u=xl(e);if(n.stdout?Cl(s.bytes,r):wl(e.slice(0,-u.length)+sl[u],s.bytes,e,n,r)){if(l!==null&&o)return Cl(l,r);s.error&&ol(r,e,s)}}var xl=e=>Object.keys(sl).find(t=>e.length>t.length&&e.endsWith(t));function Sl(e,t,n){let r=e??p(n.fs.readFile(t).slice(0,2));return r.length===0||r.length===1&&r[0]!==0}var Cl=(e,t)=>(t.events.push({fd:1,bytes:e}),!0);function wl(e,t,n,r,i){let{ctx:a}=i,o=k(a.cwd,e,a.fs,{follow:!1}).path;if(o!==null&&!r.force)return Dl(i,`${e} already exists;${In(a)?` do you wish to overwrite (y or n)? `:``} not overwritten`,2);if(o!==null&&a.fs.isLink?.(o)!==!0&&a.fs.isDir(o))return Dl(i,`${e}: Is a directory`,1);o!==null&&a.fs.removeWritable(a.cwd,e);let s;try{s=a.writable&&a.fs.openWritable?.(a.cwd,e)}catch(t){return Dl(i,`${e}: ${t.message}`,1)}return s?(s.writeBytes(t),r.keep||a.fs.removeWritable(a.cwd,n),!0):(i.gap??=C(`feature`,`gzip`,`read-only target`,`gzip: ${e}: file system is read-only`,1),!1)}var Tl=(e,t)=>Dl(e,t,1,`
42
+ `),El=(e,t)=>Dl(e,t,e.status);function Dl(e,t,n,r=``){return e.stderr+=`${r}gzip: ${t}
43
+ `,e.status=e.status===1?1:n,!1}var Ol=new Set([`atime`,`charset`,`comment`,`ctime`,`gid`,`gname`,`linkpath`,`mtime`,`path`,`size`,`uid`,`uname`,`RHT.security.selinux`,`SCHILY.acl.access`,`SCHILY.acl.default`]),kl=e=>Ol.has(e)||e.startsWith(`SCHILY.xattr.`),Al=e=>e===`GNU.dumpdir`||e.startsWith(`GNU.volume.`),jl=-(2n**63n),Ml=2n**63n-1n;function Nl(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>=jl&&n<=Ml}function Pl(e,t){for(let[n,r]of e){if(Al(n))return[`extended header`,`${t(n)}: records of multi-volume and incremental archives are not supported`];if((n===`atime`||n===`ctime`)&&!Nl(r))return[`extended header`,`${t(`${n}=${r}`)}: extended header times GNU would reject are not supported`]}return null}function Fl(e,t){let n=[],r=[],i=null;for(let a of e){let e=(a.globalPax===i?null:Pl(a.globalPax,t))??Pl(a.pax,t);if(e!==null)return{gap:e};i=a.globalPax;let o=Eo(a);if(o!==null){let[e,n]=To(o);return{gap:[e,`${t(o)}: ${n}`]}}n.push([...a.pax.keys()].filter(e=>!kl(e)).map(e=>`Ignoring unknown extended header keyword '${e}'`));let s=a.pax.get(`mtime`)??a.globalPax.get(`mtime`);r.push(s===void 0?a.mtime:Number(s))}return{warnings:n,mtimes:r}}var Il=512,Ll=10,Rl=e=>({entries:[],child:e,warnings:[],mtimes:[]}),zl=[{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`}],Bl=e=>zl.find(({bytes:t})=>t.length<=e.length&&t.every((t,n)=>e[n]===t)),Vl={__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 Hl(e){let t=e.lastIndexOf(`.`);return t===-1?void 0:Vl[e.slice(t+1)]}function Ul(e,t){return e.refuse(`option`,t,`${t}: archives compressed other than with gzip are not supported`),null}var Wl=e=>{let t=e.indexOf(`:`);return t!==-1&&!e.slice(0,t).includes(`/`)};function Gl(e,t){let{ctx:n}=t,r=e.archive;if(r===`-`){if(In(n))return t.fatal(`Refusing to read archive contents from terminal (missing -f option?)`);let e=n.stdinBytes??E(n.stdinLeft);return F(n,``,!0),{bytes:e,name:r,stdin:!0}}if(Wl(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 i=N(n,`tar`,r);return i.error?t.fatal(`${H(r,n)}: Cannot open: ${i.error}`):n.fs.isDir(i.path)?(t.warn(`${H(r,n)}: Cannot read: Is a directory`),t.fatal(`At beginning of tape, quitting now`)):{bytes:Vn(n.fs,i.path),name:r,stdin:!1}}function Kl(e,t){let n=Gl(e,t);if(!n)return null;let r=n.bytes;if(e.gzip)return ql(r,t);let i=r.length>=Il?Jl(r):null;if(i?.entries!==void 0)return Xl(i.entries,t,0);let a=Bl(r);if(a!==void 0)return n.stdin?t.fatal(`Archive is compressed. Use ${a.option} option`):a.option===`-z`?ql(r,t):Ul(t,a.option);let o=r.length<Il;o&&t.error(`This does not look like a tar archive`);let s=n.stdin?void 0:Hl(n.name);return s!==void 0&&s!==`-z`?Ul(t,s):o?s===void 0?Rl(0):ql(r,t):Yl(i.error,t)}async function ql(e,t){if(!mo(`gzip`))return t.refuse(`option`,`-z`,`this runtime has no gzip stream`);if(!Xc(e))return t.say(2,`
44
44
  gzip: stdin: ${e.length<2?`unexpected end of file`:`not in gzip format`}
45
- `),Fl(1);let n=await zc(e),r=n.error===null?null:nl(`stdin`,n);if(r!==null&&!r.whole&&e.length>Pl)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 i=r?.status??0;if(n.bytes.length<Nl)return Fl(i);let a=Gl(n.bytes);return a.entries===void 0?Kl(a.error,t):ql(a.entries,t,i)}function Gl(e){try{return{entries:oc(e)}}catch(e){if(!(e instanceof V))throw e;return{error:e}}}function Kl(e,t){return t.refuse(`feature`,`archive`,`this archive is not one this terminal reads: ${e.message}`),null}function ql(e,t,n){let r=Ml(e,e=>_c(e,t.ctx));return r.gap===void 0?{entries:e,child:n,...r}:(t.refuse(`feature`,...r.gap),null)}var Jl=512,Yl={file:384,directory:448,symlink:511};async function Xl(e,t){let{ctx:n}=t;if(e.archive===`-`&&In(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=Zl(e,t),i=r&&Ql(e,t);if(i===null||!r)return;if(i&&!fo(`gzip`))return t.refuse(`option`,`-z`,`this runtime has no gzip stream`);let a=$l(e.archive,t);if(!a)return;if(i&&a.kind===`stdout`&&t.closedOut)return t.refuse(`feature`,`closed stdout`,`writing a compressed archive to a closed stdout is not supported`);(a.kind===`stdout`||e.toStdout)&&(t.listTo=2);let o={state:t,owners:r,target:a,entries:[],verbose:e.verbose,many:e.items.filter(e=>e.name!==void 0).length>1,mtime:Math.floor(n.createdAt/1e3),members:new Set,links:new Set,line:e.verbose>1?mc(n,e):null,archived:new Map},s=n.cwd,c=[];for(let n of e.items){if(n.dir!==void 0){c.push(n.dir);continue}for(let n of c)if(s=wc(s,n,t),s===null)return ru(o,e,i,!0);if(c=[],tu(n.name,s,o),t.stopped)return}if(c.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 e of c)t.error(`-C ${vc(e,n)} has no effect`)}await ru(o,e,i,!1)}function Zl(e,t){let{owner:n,group:r,numericOwner:i}=e,a=e=>e!==void 0&&e.id!==null&&(e.name!==null||i);return!a(n)||!a(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:i?``:n.name,gname:i?``:r.name}}function Ql(e,t){if(e.gzip)return!0;let n=e.auto&&e.archive!==`-`?zl(e.archive):void 0;return n===void 0?!1:n===`-z`||Bl(t,n)}function $l(e,t){let{ctx:n}=t;if(e===`-`)return{kind:`stdout`};if(e===`/dev/null`)return{kind:`null`};if(Vl(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=_c(e,n),i=O(n.cwd,e),a=k(n.cwd,e,n.fs);if(a.path!==null&&n.fs.isDir(a.path))return t.fatal(`${r}: Cannot open: Is a directory`);let o=k(n.cwd,A(i),n.fs);if(a.path===null&&(o.error||!n.fs.isDir(o.path)))return t.fatal(`${r}: Cannot open: ${o.error??`Not a directory`}`);let s=n.writable&&R(a.path??i)?n.fs.openWritable(n.cwd,e):null;return s?{kind:`file`,handle:s,path:s.path}:t.refuse(`feature`,`read-only target`,`${r}: Cannot open: Read-only file system`)}function eu(e,t){let n=0;for(let t=0;t<e.length;){e.startsWith(`..`,t)&&(t+2===e.length||e[t+2]===`/`)&&(n=t+2);let r=e.indexOf(`/`,t);t=r===-1?e.length:r+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 tu(e,t,n){let{ctx:r}=n.state,i=yc(e);if(i===`/dev`||i.startsWith(`/dev/`)){n.state.refuse(`feature`,`special file`,`${_c(i,r)}: archiving special files is not supported`);return}let a=eu(i,n),o=k(t,i,r.fs,{follow:!1});o.error?n.state.error(`${_c(i,r)}: Cannot stat: ${o.error}`):nu(o.path,i,a,n)}function nu(e,t,n,r){let{state:i}=r,{fs:a}=i.ctx,o=a.isDir(e),s=!o&&a.isLink?.(e)===!0;if(r.target.kind===`file`&&r.target.path===e)return i.warn(`${_c(t,i.ctx)}: archive cannot contain itself; not dumped`);if(n.name!==`.`&&n.name.split(`/`).some(e=>e===`.`||e===``))return i.refuse(`feature`,`dot-segment names`,`${_c(t,i.ctx)}: member names with \`.' or empty segments are not supported`);let c=o?`directory`:s?`symlink`:`file`,l=r.many&&!o?r.archived.get(e):void 0;if(l===n.name)return i.refuse(`feature`,`repeated name`,`${_c(t,i.ctx)}: storing a name again, as a hard link to itself, is not supported`);r.many&&!o&&l===void 0&&r.archived.set(e,n.name);let u=l===void 0?{name:n.name,type:c,mode:Yl[c],mtime:r.mtime,...r.owners,linkname:s?a.readLink(e):``,data:c===`file`?Bn(a,e):void 0}:{name:n.name,type:`hardlink`,mode:Yl[c],mtime:r.mtime,...r.owners,linkname:l};if(r.entries.push(u),r.verbose&&i.list(r.line?r.line({...u,name:t,data:u.data??new Uint8Array}):o?`${t}/`:t),r.many&&!o&&l===void 0&&n.prefix!==``&&!r.links.has(n.prefix)&&(r.links.add(n.prefix),i.warn(`Removing leading \`${n.prefix}' from hard link targets`)),!o)return;let{dirs:d,files:f,links:p=[]}=a.listDir(e);for(let n of[...new Set([...d,...f,...p])].sort(j)){let a=t===`/`?`/${n}`:`${t}/${n}`;if(nu(gt(e,n),a,eu(a,r),r),i.stopped)return}}async function ru(e,t,n,r){let{state:i,target:a}=e,o;try{o=Ks(e.entries,{format:t.format,blocking:r?1:t.blocking})}catch(e){if(!(e instanceof V))throw e;return i.refuse(`feature`,`archive`,`this archive cannot be written here: ${e.message}`)}if(r){let e=t.blocking*Jl;o=o.subarray(0,Math.floor((o.length-2*Jl)/e)*e)}n&&(o=await go(o,`gzip`)),a.kind===`stdout`&&!i.closedOut?i.bytes(o):a.kind===`file`&&a.handle.writeBytes(o)}var iu=new Set([`file`,`contiguous-file`,`directory`,`symlink`]);function au(e,t){let n=e.split(`/`).filter(e=>e!==``);return n.length<=t?null:n.slice(t).join(`/`)}var ou=(e,t)=>O(e,t);function su(e,t,n,r,i,a=()=>{}){let{ctx:o}=r,s=_c(t,o);if(!iu.has(e.type)){let t=e.type===`hardlink`?`hard links`:`special files`;return r.refuse(`feature`,e.type,`${s}: extracting ${t} is not supported`)}let c=e.type===`directory`?`mkdir`:`open`,l=()=>r.refuse(`feature`,`read-only target`,`${s}: Cannot ${c}: Read-only file system`);if(!o.writable||!R(n))return l();let u=cu(A(n),r);if(u===`read-only`)return l();if(typeof u==`string`)return r.error(`${s}: Cannot ${c}: ${u}`);if(u>0&&a(u),e.type===`directory`)return lu(n,s,r);let d=e.type===`symlink`?`Cannot create symlink to ${vc(e.linkname,o)}`:`Cannot open`;if(k(`/`,n,o.fs,{follow:!1}).path!==null&&(i||!uu(n,o.fs)))return r.error(`${s}: ${d}: File exists`);if(e.type===`symlink`)return o.fs.makeWritableLink(`/`,n,e.linkname)||l();let f=o.fs.openWritable(`/`,n);return f?(f.writeBytes(e.data),!0):l()}function cu(e,t){let{fs:n}=t.ctx,r=[];for(let t=e;;t=A(t)){let e=k(`/`,t,n);if(e.path!==null){if(!n.isDir(e.path))return`Not a directory`;break}if(k(`/`,t,n,{follow:!1}).path!==null)return`File exists`;r.push(t)}for(let e of r.toReversed())if(!R(e)||!n.makeWritableDir(`/`,e))return`read-only`;return r.length}function lu(e,t,n){let{fs:r}=n.ctx,i=k(`/`,e,r,{follow:!1});return i.path!==null&&r.isDir(i.path)&&!r.isLink?.(i.path)?!0:i.path!==null&&!uu(e,r)?n.error(`${t}: Cannot mkdir: File exists`):(r.makeWritableDir(`/`,e),!0)}function uu(e,t){let n=k(`/`,e,t,{follow:!1});if(t.isDir(n.path)&&!t.isLink?.(n.path)){let{dirs:r,files:i,links:a}=t.listDir(n.path);return r.length||i.length||a.length?!1:(t.removeWritableDir(`/`,e),!0)}return t.removeWritable(`/`,e),!0}var du=new Set([`create`,`list`,`extract`]),fu={__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`},pu={__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`},mu=new Set([`file`,`directory`,`format`,`blocking-factor`,`strip-components`,`owner`,`group`,`sort`]),hu=`Try 'tar --help' or 'tar --usage' for more information.`,gu=(e,t=2)=>({usage:{text:`tar: ${e}
46
- ${hu}
47
- `,status:t}});function _u(e){if(e.length===0||e[0].startsWith(`-`))return{words:e};let t=e.slice(1),n=[],r=0;for(let i of e[0])if(n.push(`-`+i),mu.has(fu[i])){if(r>=t.length)return gu(`Old option '${i}' requires an argument.`);n.push(t[r++])}return{words:[...n,...t.slice(r)],old:!0}}function vu(e,t){let n=_u(e);if(n.usage)return n;let{words:r}=n,i={mode:null,items:[],verbose:0,values:new Map,flags:new Set,files:0};for(let e=0;e<r.length;e++){let n=r[e];if(n===`--`){for(let t of r.slice(e+1))i.items.push({name:t});break}let a=null;if(n.startsWith(`--`)){let o=n.indexOf(`=`),s=o===-1?n.slice(2):n.slice(2,o),c=pu[s];if(c===void 0)throw new T(`option`,`--${s}`,`unknown option: --${s}`);a=mu.has(c)?o===-1?e+1<r.length?yu(i,c,r[++e],t):gu(`option '--${s}' requires an argument`,64):yu(i,c,n.slice(o+1),t):o===-1?yu(i,c,void 0,t):gu(`option '--${s}' doesn't allow an argument`,64)}else if(n.startsWith(`-`)&&n.length>1)for(let o=1;o<n.length&&a===null;o++){let s=n[o],c=fu[s];if(c===void 0)throw new T(`option`,`-${s}`,`unknown option: -${s}`);if(!mu.has(c)){a=yu(i,c,void 0,t);continue}a=o+1<n.length?yu(i,c,n.slice(o+1),t):e+1<r.length?yu(i,c,r[++e],t):gu(`option requires an argument -- '${s}'`,64);break}else i.items.push({name:n});if(a!==null)return a}return Cu(i)}function yu(e,t,n,r){if(du.has(t)){if(e.mode!==null&&e.mode!==t)return gu(`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 i=bu[t]?.(n,r)??{value:n};if(i.gap)throw new T(`option`,i.gap.detail,i.gap.message);if(i.usage)return i;t===`file`&&e.files++,e.values.set(t,i.value)}return null}var bu={__proto__:null,"strip-components":e=>{let t=Ou(e);return t===null||t<0?gu(`${e}: Invalid number of elements`):{value:t}},"blocking-factor":e=>{let t=Ou(e);return t===null||t<1||t>2147483647?gu(`${e}: Invalid blocking factor`):{value:t}},format:e=>{let t=wu[e];return t===void 0?gu(`${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=Eu(e,Tu);if(n.error){let r=Tu.map(e=>` - ${vc(e,t)}
48
- `).join(``);return{usage:{text:`tar: ${n.error} argument ${vc(e,t)} for ${vc(`--sort`,t)}
45
+ `),Rl(1);let n=await Hc(e),r=n.error===null?null:al(`stdin`,n);if(r!==null&&!r.whole&&e.length>Ll)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 i=r?.status??0;if(n.bytes.length<Il)return Rl(i);let a=Jl(n.bytes);return a.entries===void 0?Yl(a.error,t):Xl(a.entries,t,i)}function Jl(e){try{return{entries:uc(e)}}catch(e){if(!(e instanceof B))throw e;return{error:e}}}function Yl(e,t){return t.refuse(`feature`,`archive`,`this archive is not one this terminal reads: ${e.message}`),null}function Xl(e,t,n){let r=Fl(e,e=>H(e,t.ctx));return r.gap===void 0?{entries:e,child:n,...r}:(t.refuse(`feature`,...r.gap),null)}var Zl=512,Ql={file:384,directory:448,symlink:511};async function $l(e,t){let{ctx:n}=t;if(e.archive===`-`&&Ln(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=eu(e,t),i=r&&tu(e,t);if(i===null||!r)return;if(i&&!mo(`gzip`))return t.refuse(`option`,`-z`,`this runtime has no gzip stream`);let a=nu(e.archive,t);if(!a)return;if(i&&a.kind===`stdout`&&t.closedOut)return t.refuse(`feature`,`closed stdout`,`writing a compressed archive to a closed stdout is not supported`);(a.kind===`stdout`||e.toStdout)&&(t.listTo=2);let o={state:t,owners:r,target:a,entries:[],verbose:e.verbose,many:e.items.filter(e=>e.name!==void 0).length>1,mtime:Math.floor(n.createdAt/1e3),members:new Set,links:new Set,line:e.verbose>1?vc(n,e):null,archived:new Map},s=n.cwd,c=[];for(let n of e.items){if(n.dir!==void 0){c.push(n.dir);continue}for(let n of c)if(s=Dc(s,n,t),s===null)return ou(o,e,i,!0);if(c=[],iu(n.name,s,o),t.stopped)return}if(c.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 e of c)t.error(`-C ${xc(e,n)} has no effect`)}await ou(o,e,i,!1)}function eu(e,t){let{owner:n,group:r,numericOwner:i}=e,a=e=>e!==void 0&&e.id!==null&&(e.name!==null||i);return!a(n)||!a(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:i?``:n.name,gname:i?``:r.name}}function tu(e,t){if(e.gzip)return!0;let n=e.auto&&e.archive!==`-`?Hl(e.archive):void 0;return n===void 0?!1:n===`-z`||Ul(t,n)}function nu(e,t){let{ctx:n}=t;if(e===`-`)return{kind:`stdout`};if(e===`/dev/null`)return{kind:`null`};if(Wl(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=H(e,n),i=O(n.cwd,e),a=k(n.cwd,e,n.fs);if(a.path!==null&&n.fs.isDir(a.path))return t.fatal(`${r}: Cannot open: Is a directory`);let o=k(n.cwd,A(i),n.fs);if(a.path===null&&(o.error||!n.fs.isDir(o.path)))return t.fatal(`${r}: Cannot open: ${o.error??`Not a directory`}`);let s=n.writable&&L(a.path??i)?n.fs.openWritable(n.cwd,e):null;return s?{kind:`file`,handle:s,path:s.path}:t.refuse(`feature`,`read-only target`,`${r}: Cannot open: Read-only file system`)}function ru(e,t){let n=0;for(let t=0;t<e.length;){e.startsWith(`..`,t)&&(t+2===e.length||e[t+2]===`/`)&&(n=t+2);let r=e.indexOf(`/`,t);t=r===-1?e.length:r+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 iu(e,t,n){let{ctx:r}=n.state,i=Sc(e);if(i===`/dev`||i.startsWith(`/dev/`)){n.state.refuse(`feature`,`special file`,`${H(i,r)}: archiving special files is not supported`);return}let a=ru(i,n),o=k(t,i,r.fs,{follow:!1});o.error?n.state.error(`${H(i,r)}: Cannot stat: ${o.error}`):au(o.path,i,a,n)}function au(e,t,n,r){let{state:i}=r,{fs:a}=i.ctx,o=a.isDir(e),s=!o&&a.isLink?.(e)===!0;if(r.target.kind===`file`&&r.target.path===e)return i.warn(`${H(t,i.ctx)}: archive cannot contain itself; not dumped`);if(n.name!==`.`&&n.name.split(`/`).some(e=>e===`.`||e===``))return i.refuse(`feature`,`dot-segment names`,`${H(t,i.ctx)}: member names with \`.' or empty segments are not supported`);let c=o?`directory`:s?`symlink`:`file`,l=r.many&&!o?r.archived.get(e):void 0;if(l===n.name)return i.refuse(`feature`,`repeated name`,`${H(t,i.ctx)}: storing a name again, as a hard link to itself, is not supported`);r.many&&!o&&l===void 0&&r.archived.set(e,n.name);let u=l===void 0?{name:n.name,type:c,mode:Ql[c],mtime:r.mtime,...r.owners,linkname:s?a.readLink(e):``,data:c===`file`?Vn(a,e):void 0}:{name:n.name,type:`hardlink`,mode:Ql[c],mtime:r.mtime,...r.owners,linkname:l};if(r.entries.push(u),r.verbose&&i.list(r.line?r.line({...u,name:t,data:u.data??new Uint8Array}):o?`${t}/`:t),r.many&&!o&&l===void 0&&n.prefix!==``&&!r.links.has(n.prefix)&&(r.links.add(n.prefix),i.warn(`Removing leading \`${n.prefix}' from hard link targets`)),!o)return;let{dirs:d,files:f,links:p=[]}=a.listDir(e);for(let n of[...new Set([...d,...f,...p])].sort(j)){let a=t===`/`?`/${n}`:`${t}/${n}`;if(au(_t(e,n),a,ru(a,r),r),i.stopped)return}}async function ou(e,t,n,r){let{state:i,target:a}=e,o;try{o=Xs(e.entries,{format:t.format,blocking:r?1:t.blocking})}catch(e){if(!(e instanceof B))throw e;return i.refuse(`feature`,`archive`,`this archive cannot be written here: ${e.message}`)}if(r){let e=t.blocking*Zl;o=o.subarray(0,Math.floor((o.length-2*Zl)/e)*e)}n&&(o=await vo(o,`gzip`)),a.kind===`stdout`&&!i.closedOut?i.bytes(o):a.kind===`file`&&a.handle.writeBytes(o)}var su=new Set([`file`,`contiguous-file`,`directory`,`symlink`]);function cu(e,t){let n=e.split(`/`).filter(e=>e!==``);return n.length<=t?null:n.slice(t).join(`/`)}var lu=(e,t)=>O(e,t);function uu(e,t,n,r,i,a=()=>{}){let{ctx:o}=r,s=H(t,o);if(!su.has(e.type)){let t=e.type===`hardlink`?`hard links`:`special files`;return r.refuse(`feature`,e.type,`${s}: extracting ${t} is not supported`)}let c=e.type===`directory`?`mkdir`:`open`,l=()=>r.refuse(`feature`,`read-only target`,`${s}: Cannot ${c}: Read-only file system`);if(!o.writable||!L(n))return l();let u=du(A(n),r);if(u===`read-only`)return l();if(typeof u==`string`)return r.error(`${s}: Cannot ${c}: ${u}`);if(u>0&&a(u),e.type===`directory`)return fu(n,s,r);let d=e.type===`symlink`?`Cannot create symlink to ${xc(e.linkname,o)}`:`Cannot open`;if(k(`/`,n,o.fs,{follow:!1}).path!==null&&(i||!pu(n,o.fs)))return r.error(`${s}: ${d}: File exists`);if(e.type===`symlink`)return o.fs.makeWritableLink(`/`,n,e.linkname)||l();let f=o.fs.openWritable(`/`,n);return f?(f.writeBytes(e.data),!0):l()}function du(e,t){let{fs:n}=t.ctx,r=[];for(let t=e;;t=A(t)){let e=k(`/`,t,n);if(e.path!==null){if(!n.isDir(e.path))return`Not a directory`;break}if(k(`/`,t,n,{follow:!1}).path!==null)return`File exists`;r.push(t)}for(let e of r.toReversed())if(!L(e)||!n.makeWritableDir(`/`,e))return`read-only`;return r.length}function fu(e,t,n){let{fs:r}=n.ctx,i=k(`/`,e,r,{follow:!1});return i.path!==null&&r.isDir(i.path)&&!r.isLink?.(i.path)?!0:i.path!==null&&!pu(e,r)?n.error(`${t}: Cannot mkdir: File exists`):(r.makeWritableDir(`/`,e),!0)}function pu(e,t){let n=k(`/`,e,t,{follow:!1});if(t.isDir(n.path)&&!t.isLink?.(n.path)){let{dirs:r,files:i,links:a}=t.listDir(n.path);return r.length||i.length||a.length?!1:(t.removeWritableDir(`/`,e),!0)}return t.removeWritable(`/`,e),!0}var mu=new Set([`create`,`list`,`extract`]),hu={__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`},gu={__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`},_u=new Set([`file`,`directory`,`format`,`blocking-factor`,`strip-components`,`owner`,`group`,`sort`]),vu=`Try 'tar --help' or 'tar --usage' for more information.`,yu=(e,t=2)=>({usage:{text:`tar: ${e}
46
+ ${vu}
47
+ `,status:t}});function bu(e){if(e.length===0||e[0].startsWith(`-`))return{words:e};let t=e.slice(1),n=[],r=0;for(let i of e[0])if(n.push(`-`+i),_u.has(hu[i])){if(r>=t.length)return yu(`Old option '${i}' requires an argument.`);n.push(t[r++])}return{words:[...n,...t.slice(r)],old:!0}}function xu(e,t){let n=bu(e);if(n.usage)return n;let{words:r}=n,i={mode:null,items:[],verbose:0,values:new Map,flags:new Set,files:0};for(let e=0;e<r.length;e++){let n=r[e];if(n===`--`){for(let t of r.slice(e+1))i.items.push({name:t});break}let a=null;if(n.startsWith(`--`)){let o=n.indexOf(`=`),s=o===-1?n.slice(2):n.slice(2,o),c=gu[s];if(c===void 0)throw new T(`option`,`--${s}`,`unknown option: --${s}`);a=_u.has(c)?o===-1?e+1<r.length?Su(i,c,r[++e],t):yu(`option '--${s}' requires an argument`,64):Su(i,c,n.slice(o+1),t):o===-1?Su(i,c,void 0,t):yu(`option '--${s}' doesn't allow an argument`,64)}else if(n.startsWith(`-`)&&n.length>1)for(let o=1;o<n.length&&a===null;o++){let s=n[o],c=hu[s];if(c===void 0)throw new T(`option`,`-${s}`,`unknown option: -${s}`);if(!_u.has(c)){a=Su(i,c,void 0,t);continue}a=o+1<n.length?Su(i,c,n.slice(o+1),t):e+1<r.length?Su(i,c,r[++e],t):yu(`option requires an argument -- '${s}'`,64);break}else i.items.push({name:n});if(a!==null)return a}return Eu(i)}function Su(e,t,n,r){if(mu.has(t)){if(e.mode!==null&&e.mode!==t)return yu(`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 i=Cu[t]?.(n,r)??{value:n};if(i.gap)throw new T(`option`,i.gap.detail,i.gap.message);if(i.usage)return i;t===`file`&&e.files++,e.values.set(t,i.value)}return null}var Cu={__proto__:null,"strip-components":e=>{let t=ju(e);return t===null||t<0?yu(`${e}: Invalid number of elements`):{value:t}},"blocking-factor":e=>{let t=ju(e);return t===null||t<1||t>2147483647?yu(`${e}: Invalid blocking factor`):{value:t}},format:e=>{let t=Du[e];return t===void 0?yu(`${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=ku(e,Ou);if(n.error){let r=Ou.map(e=>` - ${xc(e,t)}
48
+ `).join(``);return{usage:{text:`tar: ${n.error} argument ${xc(e,t)} for ${xc(`--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)=>Su(e,t),group:(e,t)=>Su(e,t)},xu=4294967295;function Su(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(n+1),i=n===-1?/^\d+$/u.exec(e):/^[ \t\n\v\f\r]*\+?(\d+)$/u.exec(r);if(n===-1&&i===null)return{value:{name:e,id:null}};let a=i===null?null:Number(BigInt(i.at(-1))>BigInt(xu)?-1:i.at(-1));return a===null||a<0?{usage:{text:`tar: ${_c(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)=>Tu(e,t),group:(e,t)=>Tu(e,t)},wu=4294967295;function Tu(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(n+1),i=n===-1?/^\d+$/u.exec(e):/^[ \t\n\v\f\r]*\+?(\d+)$/u.exec(r);if(n===-1&&i===null)return{value:{name:e,id:null}};let a=i===null?null:Number(BigInt(i.at(-1))>BigInt(wu)?-1:i.at(-1));return a===null||a<0?{usage:{text:`tar: ${H(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:a}}}function Cu(e){return e.mode===null?gu(`You must specify one of the '-Acdtrux', '--delete' or '--test-label' options`):e.files>1?gu(`Multiple archive files require '-M' option`):e.mode===`create`&&!e.items.some(e=>e.name!==void 0)?gu(`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 wu={__proto__:null,gnu:`gnu`,ustar:`ustar`,pax:`pax`,posix:`pax`,oldgnu:null,v7:null},Tu=[`none`,`name`,`inode`];function Eu(e,t){if(t.includes(e))return{value:e};let n=t.filter(t=>t.startsWith(e));return n.length===1?{value:n[0]}:{error:n.length?`ambiguous`:`invalid`}}var Du=2n**63n-1n;function Ou(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>Du||n<-Du-1n?null:n<0n?-1:Number(n>BigInt(2**53-1)?2**53-1:n)}function ku(e){let t={ctx:e,events:[],status:0,stopped:!1,gap:null,listTo:1,closedOut:e.closed?.out===!0,lostListing:null,say(e,n){t.events.push({fd:e,text:n})},list(e,n=!0){t.listTo===1&&t.closedOut?t.lostListing=n?`flushed`:`pending`:t.say(t.listTo,e+`
52
+ `,status:2}}:{value:{name:n>0?e.slice(0,n):null,id:a}}}function Eu(e){return e.mode===null?yu(`You must specify one of the '-Acdtrux', '--delete' or '--test-label' options`):e.files>1?yu(`Multiple archive files require '-M' option`):e.mode===`create`&&!e.items.some(e=>e.name!==void 0)?yu(`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 Du={__proto__:null,gnu:`gnu`,ustar:`ustar`,pax:`pax`,posix:`pax`,oldgnu:null,v7:null},Ou=[`none`,`name`,`inode`];function ku(e,t){if(t.includes(e))return{value:e};let n=t.filter(t=>t.startsWith(e));return n.length===1?{value:n[0]}:{error:n.length?`ambiguous`:`invalid`}}var Au=2n**63n-1n;function ju(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>Au||n<-Au-1n?null:n<0n?-1:Number(n>BigInt(2**53-1)?2**53-1:n)}function Mu(e){let t={ctx:e,events:[],status:0,stopped:!1,gap:null,listTo:1,closedOut:e.closed?.out===!0,lostListing:null,say(e,n){t.events.push({fd:e,text:n})},list(e,n=!0){t.listTo===1&&t.closedOut?t.lostListing=n?`flushed`:`pending`:t.say(t.listTo,e+`
53
53
  `)},bytes(e){t.events.push({fd:1,bytes:e})},warn(e){t.say(2,`tar: ${e}
54
- `)},error(e){t.warn(e),t.status=2},fatal(e){t.warn(e),t.warn(`Error is not recoverable: exiting now`),t.status=2,t.stopped=!0},refuse(e,n,r){t.warn(r),t.gap={kind:e,detail:n,message:`tar: ${r}`},t.status=2,t.stopped=!0}};return t}function Au(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=t=>e.events.filter(e=>e.fd===t&&e.text!==void 0).map(e=>e.text).join(``),n={stdout:t(1),stderr:t(2),exitCode:e.status,events:e.events};return e.gap===null?n:w(n,e.gap.kind,`tar`,e.gap.detail,e.gap.message)}var ju=32768;async function Mu(e,t,n){let r=vu(t,n);if(r.usage)return{stdout:``,stderr:r.usage.text,exitCode:r.usage.status};let i=ku(n);return r.blocking>ju?i.refuse(`option`,`--blocking-factor`,`${r.blocking}: a record of that many blocks is more than this terminal holds`):r.mode===`create`?await Xl(r,i):await Nu(r,i),Au(i)}async function Nu(e,t){let{ctx:n}=t,r=Date.now(),i=await Ul(e,t);if(!i)return;let a=Sc(e.items),o=e.mode===`extract`;e.toStdout&&(t.listTo=2);let s=e.verbose>1?mc(n,e):null,c=new Map;for(let[l,u]of i.entries.entries()){for(let e of i.warnings[l])t.warn(e);let d=bo(u),f=a.match(d);if(f===null)continue;let p=Lu(f,c,t);if(p===null)return;let m=o?au(d,e.strip):d;if(m!==null&&(e.verbose>0&&t.list(s?s(u):lc(d,n)),o&&e.toStdout?(u.type===`file`||u.type===`contiguous-file`)&&Pu(u.data,m,t):o&&su(u,m,ou(p,m),t,e.keepOld,e=>Fu(m,e,s,t))&&Iu(i.mtimes[l],m,r,t),t.stopped))return}if(i.child)return t.fatal(`Child returned status ${i.child}`);Cc(a,t,e.noWildcards)}function Pu(e,t,n){n.closedOut?e.length>0&&n.error(`${_c(t,n.ctx)}: Cannot write: Bad file descriptor`):n.bytes(e)}function Fu(e,t,n,r){if(!n)return;let i=e.split(`/`).slice(0,-1);for(let e=i.length-t;e<i.length;e++)r.list(n.mkdir(i.slice(0,e+1).join(`/`)),!1)}function Iu(e,t,n,r){e>=0&&e*1e3<=n||r.refuse(`feature`,`archive times`,`${_c(t,r.ctx)}: extracting an entry dated before 1970 or in the future is not supported`)}function Lu(e,t,n){if(t.has(e))return t.get(e);let r=n.ctx.cwd;for(let t of e.dirs)if(r=wc(r,t,n),r===null)return null;return t.set(e,r),r}var Ru=67324752,zu=33639248,Bu=101010256,Vu=61440,Hu={file:32768,directory:16384,symlink:40960},Uu=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function Wu(e){let t=new Uint8Array(e.reduce((e,[t])=>e+t,0)),n=Uu(t),r=0;for(let[t,i]of e){if(!Number.isInteger(i)||i<0||i>=2**(8*t))throw RangeError(`${i} does not fit ${t} bytes`);t===1?n.setUint8(r,i):t===2?n.setUint16(r,i,!0):n.setUint32(r,i,!0),r+=t}return t}var Gu=e=>go(e,`deflate-raw`),Ku=1032;async function qu(e,t,n){if(t>e.length*Ku)throw new V(`an entry declares more than its data can inflate to`,n);let r;try{r=await yo(e,`deflate-raw`,new Uint8Array(t))}catch(e){throw new V(e.limited?`an entry inflates to more than its declared size`:`an entry does not inflate`,n)}if(r.length!==t)throw new V(`an entry inflates to less than its declared size`,n);return r}function Ju(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 Yu(e){let t=Ju(e);if(t===null)throw new V(`mtime ${e} is outside DOS time, 1980 to 2107`);return t}function Xu(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,i=Ju(r);if(i===null||i.time!==t||i.date!==e)throw new V(`an entry has an invalid DOS time`,n);return r}var Zu=new Set([`deflate`,`store`]),Qu=788,$u=2048,ed=315532800,td=2147483647,nd=65534,rd=4294967294;function id(e,t,n,r){if(!Number.isSafeInteger(e)||e<n||e>r)throw new V(`${t} ${String(e)} is not an integer from ${n} to ${r}`);return e}function ad(e){let t=Po(e,Hu);return{...t,mode:id(e.mode??jo[t.type],`mode`,0,4095),mtime:id(e.mtime??ed,`mtime`,ed,td)}}var od=e=>Wu([[2,21589],[2,5],[1,1],[4,e]]);async function sd(t,{method:n=`deflate`,symlinksAbove:r}={}){if(!Zu.has(n))throw new V(`method ${H(String(n))} is not deflate or store`);let i=new Ds(!0,xs(r)),a=[],o=[],s=0,c=0;for(let r of t){let t=ad(r),l={...t,...Cs(t.name,t.type,t.linkname,i.above)};if(i.add(l),++c>nd)throw new V(`more than ${nd} entries would need zip64`);let u=ko(No(l),`entry name`),d=l.type===`symlink`?ko(l.linkname,`symlink target`):l.data;if(d.length>rd||s>rd)throw new V(`${H(l.name)} would need zip64`);let f=d,p=0;if(n===`deflate`&&l.type===`file`&&d.length){let e=await Gu(d);e.length<d.length&&(f=e,p=8)}let{time:m,date:h}=Yu(l.mtime),g=od(l.mtime),_=[[2,p===8?20:10],[2,oo(u)?0:$u],[2,p],[2,m],[2,h],[4,e(d)],[4,f.length],[4,d.length],[2,u.length],[2,g.length]];a.push(Wu([[4,Ru],..._]),u,g,f);let ee=(Hu[l.type]|l.mode)*65536+(l.type===`directory`?16:0);o.push(Wu([[4,zu],[2,Qu],..._,[2,0],[2,0],[2,0],[4,ee],[4,s]]),u,g),s+=30+u.length+g.length+f.length}let l=co(o);if(s+l.length>rd)throw new V(`the archive would need zip64`);let u=Wu([[4,Bu],[2,0],[2,0],[2,c],[2,c],[4,l.length],[4,s],[2,0]]);return co([...a,l,u])}var cd=134695760,ld=117853008,ud=1,dd=21589,fd=28789,pd=1,md=8,hd=16;function gd(e,t=0){let n=Uu(e),r=(n,r)=>{if(n<t||n+r>t+e.length)throw new V(`the archive is truncated`,n)};return{u16:e=>(r(e,2),n.getUint16(e-t,!0)),u32:e=>(r(e,4),n.getUint32(e-t,!0)),slice:(n,i)=>(r(n,i),e.subarray(n-t,n-t+i))}}function _d(e){if(e instanceof Uint8Array){let t=gd(e);return{size:e.length,read:(t,n)=>e.subarray(t,n),window:()=>t}}if(e instanceof Blob){let t=async(t,n)=>new Uint8Array(await e.slice(t,n).arrayBuffer());return{size:e.size,read:t,window:async(n,r)=>gd(await t(n,Math.min(r,e.size)),n)}}throw new V(`the archive is not a Uint8Array or a Blob`)}var vd=65536;function yd(e){let t,n=0,r=0;return async(i,a,o=1/0)=>{let s=Math.min(i+a,e.size);return(t===void 0||i<n||s>r)&&(n=i,r=Math.max(s,Math.min(i+vd,o,e.size)),t=await e.window(n,r)),t}}async function bd(e){let{size:t}=e,n=await e.window(Math.max(0,t-22-65535-20),t);for(let e=t-22;e>=Math.max(0,t-22-65535);e--)if(n.u32(e)===Bu&&e+22+n.u16(e+20)===t){if(e>=20&&n.u32(e-20)===ld)throw new V(`zip64 is not supported`,e-20);return{end:e,r:n}}throw new V(`no end of central directory record`)}function xd(e,t){let n=new Map,r=gd(e);for(let i=0;i<e.length;){let a=r.u16(i),o=r.u16(i+2);if(i+4+o>e.length)throw new V(`an extra field runs past its room`,t);if(a===ud)throw new V(`zip64 is not supported`,t);if(a===fd)throw new V(`an entry carries a second name in a Unicode path extra field`,t);n.has(a)||n.set(a,e.subarray(i+4,i+4+o)),i+=4+o}return n}async function Sd(e,t){let n=await e(t,46);if(n.u32(t)!==zu)throw new V(`no central directory entry where one is counted`,t);let r=n.u16(t+28),i=n.u16(t+30);n=await e(t,46+r+i);let a={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+i+n.u16(t+32)};if(n.u16(t+34)!==0)throw new V(`the archive spans several disks`,t);if(a.flags&pd)throw new V(`an entry is encrypted`,t);if(a.method!==0&&a.method!==8)throw new V(`compression method ${a.method} is not stored or deflate`,t);if(a.csize===4294967295||a.usize===4294967295||a.offset===4294967295)throw new V(`zip64 is not supported`,t);a.mtime=Xu(a.date,a.time,t);let o=xd(n.slice(t+46+r,i),t).get(dd);if(o!==void 0&&o[0]&1){if(o.length<5)throw new V(`an extended timestamp is cut short`,t);a.mtime=Uu(o).getInt32(1,!0)}return a}async function Cd(e,t,n,r){let i=t.offset,a=await e(i,30,r);if(a.u32(i)!==Ru)throw new V(`no local header where the central directory points`,i);let o=a.u16(i+26),s=a.u16(i+28);if(a=await e(i,30+o+s,r),!so(a.slice(i+30,o),t.name))throw new V(`the local header names a different entry`,i);for(let[e,n,r]of[[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`]])if(a.u16(i+e)!==t[n])throw new V(`the local header has ${r}`,i);xd(a.slice(i+30+o,s),i);let c=t.flags&md,l=(e,t)=>a.u32(i+e)===t||c&&a.u32(i+e)===0;if(!l(14,t.crc)||!l(18,t.csize)||!l(22,t.usize))throw new V(`the local header disagrees with the central directory`,i);t.dataAt=i+30+o+s;let u=t.dataAt+t.csize;if(c){let r=await e(u,16,n),i=e=>r.u32(e)===t.crc&&r.u32(e+4)===t.csize&&r.u32(e+8)===t.usize,a=r.u32(u)===cd&&i(u+4);if(i(u)&&!(a&&u+16===n))u+=12;else if(a)u+=16;else throw new V(`the data descriptor disagrees with the central directory`,u)}return u}function wd(e,t,n){let r=n&Vu;if(t.endsWith(`/`)){if(r!==0&&r!==Hu.directory)throw new V(`${H(t)} is a directory by its name but not by its mode`,e.at);return`directory`}if(r===Hu.directory)throw new V(`${H(t)} is a directory by its mode but not by its name`,e.at);if(e.attributes&hd)throw new V(`${H(t)} is a directory by its attributes but not by its name`,e.at);if(r===Hu.symlink)return`symlink`;if(r===0||r===Hu.file)return`file`;throw new V(`the mode of ${H(t)} (${n.toString(8)}) is not one this package reads`,e.at)}async function Td(t,n,r){let{at:i,method:a,csize:o,usize:s}=n,c=Ao(n.name,`entry name`,i),l=n.madeBy>>8==3?n.attributes>>>16:0,u=wd(n,c,l);if(u===`directory`&&s!==0)throw new V(`directory ${H(c)} has data`,i);if(a===0&&o!==s)throw new V(`a stored entry has two sizes`,i);let d=await t.read(n.dataAt,n.dataAt+o);if(d.length!==o)throw new V(`the archive is truncated`,n.dataAt);let f=a===8?await qu(d,s,i):d;if(e(f)!==n.crc)throw new V(`the data does not match its CRC-32`,i);let p=u===`symlink`?Ao(f,`symlink target`,i):``,m={...lo(()=>Cs(c,u,p,r.above),i),type:u,mode:l===0?jo[u]:l&4095,mtime:n.mtime,data:u===`file`?f:ao,storedName:c};return lo(()=>r.add(m),i),m}async function*Ed(e,{limit:t=1/0,symlinksAbove:n}={},r=!1){if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw new V(`limit ${String(t)} is not a whole number of bytes`);let i=xs(n),{end:a,r:o}=await bd(e),s=o.u16(a+8);if(o.u16(a+4)!==0||o.u16(a+6)!==0||s!==o.u16(a+10))throw new V(`the archive spans several disks`,a);let c=o.u32(a+12),l=o.u32(a+16);if(s===65535||c===4294967295||l===4294967295)throw new V(`zip64 is not supported`,a);if(l+c!==a)throw new V(`the central directory does not end at the end record`,a);let u=yd(e),d=[],f=l,p=0;for(let e=0;e<s;e++){let e=await Sd(u,f);if(p+=e.usize,p>t)throw new V(`the entries come to more than ${t} bytes`,f,{limited:!0});d.push(e),f=e.next}if(f!==a)throw new V(`the central directory does not hold what the end record counts`,f);let m=0,h=d.toSorted((e,t)=>e.offset-t.offset),g=h.map((e,t)=>h[t+1]?.offset??l),_=[];for(let e=h.length-1;e>=0;e--)_[e]=h[e].csize===0&&e+1<h.length?_[e+1]:g[e]-h[e].csize;let ee=yd(e);for(let[e,t]of h.entries()){if(t.offset!==m)throw new V(t.offset>m?`bytes belong to no entry`:`two entries overlap`,m);m=await Cd(ee,t,g[e],_[e])}if(m!==l)throw new V(`bytes belong to no entry`,m);let v=new Ds(r,i);for(let t of d)yield await Td(e,t,v)}async function Dd(e,t){if(!(e instanceof Uint8Array))throw new V(`the archive is not a Uint8Array`);return await Array.fromAsync(Ed(_d(e),t,!0))}var Od=(e,t)=>e===null?t:`${e.endsWith(`/`)?e.slice(0,-1):e}/${t}`;function kd(e,t,n){let r=Pd(t.exdir,n);if(r===null)return!1;let i=[],a=Ad(e,r,i,t,n);for(let e of i)jd(e,n);return a}function Ad(e,t,n,r,i){let{ctx:a}=i;for(let o of e){let e=o.type===`directory`;if(r.junk&&e)continue;let s=r.junk?ht(o.name):o.name,c=O(t,s),l=Od(r.exdir,e?`${s}/`:s),u=Md(c,a)?Fd(A(c),a):`read-only`;if(u===`read-only`)return Nd(l,i);if(u!==null)return i.refuse(`feature`,`name taken`,`${l}: extracting under a name that is not a directory is not supported`),!1;if(e){if(!Id(c,l,i))return!1;continue}if(i.quiet===0)return i.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=Ld(c,l,r,i);if(d===null)return!1;if(d===`skip`)continue;let f=a.fs.openWritable(`/`,c);if(!f)return Nd(l,i);let p=o.type===`symlink`;f.writeBytes(p?E(o.linkname):o.data),p&&n.push({path:c,shown:l,target:o.linkname})}return!0}function jd({path:e,shown:t,target:n},r){let{fs:i}=r.ctx,a=k(`/`,e,i),o=a.path!==null&&i.isFile(a.path)?Bn(i,a.path):null,s=E(n);if(o===null||o.length!==s.length||o.some((e,t)=>e!==s[t])){r.say(2,`warning: deferred symlink (${t}) failed:
54
+ `)},error(e){t.warn(e),t.status=2},fatal(e){t.warn(e),t.warn(`Error is not recoverable: exiting now`),t.status=2,t.stopped=!0},refuse(e,n,r){t.warn(r),t.gap={kind:e,detail:n,message:`tar: ${r}`},t.status=2,t.stopped=!0}};return t}function Nu(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=t=>e.events.filter(e=>e.fd===t&&e.text!==void 0).map(e=>e.text).join(``),n={stdout:t(1),stderr:t(2),exitCode:e.status,events:e.events};return e.gap===null?n:w(n,e.gap.kind,`tar`,e.gap.detail,e.gap.message)}var Pu=32768;async function Fu(e,t,n){let r=xu(t,n);if(r.usage)return{stdout:``,stderr:r.usage.text,exitCode:r.usage.status};let i=Mu(n);return r.blocking>Pu?i.refuse(`option`,`--blocking-factor`,`${r.blocking}: a record of that many blocks is more than this terminal holds`):r.mode===`create`?await $l(r,i):await Iu(r,i),Nu(i)}async function Iu(e,t){let{ctx:n}=t,r=Date.now(),i=await Kl(e,t);if(!i)return;let a=Tc(e.items),o=e.mode===`extract`;e.toStdout&&(t.listTo=2);let s=e.verbose>1?vc(n,e):null,c=new Map;for(let[l,u]of i.entries.entries()){for(let e of i.warnings[l])t.warn(e);let d=wo(u),f=a.match(d);if(f===null)continue;let p=Bu(f,c,t);if(p===null)return;let m=o?cu(d,e.strip):d;if(m!==null&&(e.verbose>0&&t.list(s?s(u):pc(d,n)),o&&e.toStdout?(u.type===`file`||u.type===`contiguous-file`)&&Lu(u.data,m,t):o&&uu(u,m,lu(p,m),t,e.keepOld,e=>Ru(m,e,s,t))&&zu(i.mtimes[l],m,r,t),t.stopped))return}if(i.child)return t.fatal(`Child returned status ${i.child}`);Ec(a,t,e.noWildcards)}function Lu(e,t,n){n.closedOut?e.length>0&&n.error(`${H(t,n.ctx)}: Cannot write: Bad file descriptor`):n.bytes(e)}function Ru(e,t,n,r){if(!n)return;let i=e.split(`/`).slice(0,-1);for(let e=i.length-t;e<i.length;e++)r.list(n.mkdir(i.slice(0,e+1).join(`/`)),!1)}function zu(e,t,n,r){e>=0&&e*1e3<=n||r.refuse(`feature`,`archive times`,`${H(t,r.ctx)}: extracting an entry dated before 1970 or in the future is not supported`)}function Bu(e,t,n){if(t.has(e))return t.get(e);let r=n.ctx.cwd;for(let t of e.dirs)if(r=Dc(r,t,n),r===null)return null;return t.set(e,r),r}var Vu=67324752,Hu=33639248,Uu=101010256,Wu=61440,Gu={file:32768,directory:16384,symlink:40960},Ku=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function qu(e){let t=new Uint8Array(e.reduce((e,[t])=>e+t,0)),n=Ku(t),r=0;for(let[t,i]of e){if(!Number.isInteger(i)||i<0||i>=2**(8*t))throw RangeError(`${i} does not fit ${t} bytes`);t===1?n.setUint8(r,i):t===2?n.setUint16(r,i,!0):n.setUint32(r,i,!0),r+=t}return t}var Ju=e=>vo(e,`deflate-raw`),Yu=1032;async function Xu(e,t,n){if(t>e.length*Yu)throw new B(`an entry declares more than its data can inflate to`,n);let r;try{r=await Co(e,`deflate-raw`,new Uint8Array(t))}catch(e){throw new B(e.limited?`an entry inflates to more than its declared size`:`an entry does not inflate`,n)}if(r.length!==t)throw new B(`an entry inflates to less than its declared size`,n);return r}function Zu(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 Qu(e){let t=Zu(e);if(t===null)throw new B(`mtime ${e} is outside DOS time, 1980 to 2107`);return t}function $u(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,i=Zu(r);if(i===null||i.time!==t||i.date!==e)throw new B(`an entry has an invalid DOS time`,n);return r}var ed=new Set([`deflate`,`store`]),td=788,nd=2048,rd=315532800,id=2147483647,ad=65534,od=4294967294;function sd(e,t,n,r){if(!Number.isSafeInteger(e)||e<n||e>r)throw new B(`${t} ${String(e)} is not an integer from ${n} to ${r}`);return e}function cd(e){let t=Ro(e,Gu);return{...t,mode:sd(e.mode??Fo[t.type],`mode`,0,4095),mtime:sd(e.mtime??rd,`mtime`,rd,id)}}var ld=e=>qu([[2,21589],[2,5],[1,1],[4,e]]);async function ud(t,{method:n=`deflate`,symlinksAbove:r}={}){if(!ed.has(n))throw new B(`method ${V(String(n))} is not deflate or store`);let i=new js(!0,Ts(r)),a=[],o=[],s=0,c=0;for(let r of t){let t=cd(r),l={...t,...Ds(t.name,t.type,t.linkname,i.above)};if(i.add(l),++c>ad)throw new B(`more than ${ad} entries would need zip64`);let u=No(Lo(l),`entry name`),d=l.type===`symlink`?No(l.linkname,`symlink target`):l.data;if(d.length>od||s>od)throw new B(`${V(l.name)} would need zip64`);let f=d,p=0;if(n===`deflate`&&l.type===`file`&&d.length){let e=await Ju(d);e.length<d.length&&(f=e,p=8)}let{time:m,date:h}=Qu(l.mtime),g=ld(l.mtime),_=[[2,p===8?20:10],[2,co(u)?0:nd],[2,p],[2,m],[2,h],[4,e(d)],[4,f.length],[4,d.length],[2,u.length],[2,g.length]];a.push(qu([[4,Vu],..._]),u,g,f);let ee=(Gu[l.type]|l.mode)*65536+(l.type===`directory`?16:0);o.push(qu([[4,Hu],[2,td],..._,[2,0],[2,0],[2,0],[4,ee],[4,s]]),u,g),s+=30+u.length+g.length+f.length}let l=uo(o);if(s+l.length>od)throw new B(`the archive would need zip64`);let u=qu([[4,Uu],[2,0],[2,0],[2,c],[2,c],[4,l.length],[4,s],[2,0]]);return uo([...a,l,u])}var dd=134695760,fd=117853008,pd=1,md=21589,hd=28789,gd=1,_d=8,vd=16;function yd(e,t=0){let n=Ku(e),r=(n,r)=>{if(n<t||n+r>t+e.length)throw new B(`the archive is truncated`,n)};return{u16:e=>(r(e,2),n.getUint16(e-t,!0)),u32:e=>(r(e,4),n.getUint32(e-t,!0)),slice:(n,i)=>(r(n,i),e.subarray(n-t,n-t+i))}}function bd(e){if(e instanceof Uint8Array){let t=yd(e);return{size:e.length,read:(t,n)=>e.subarray(t,n),window:()=>t}}if(e instanceof Blob){let t=async(t,n)=>new Uint8Array(await e.slice(t,n).arrayBuffer());return{size:e.size,read:t,window:async(n,r)=>yd(await t(n,Math.min(r,e.size)),n)}}throw new B(`the archive is not a Uint8Array or a Blob`)}var xd=65536;function Sd(e){let t,n=0,r=0;return async(i,a,o=1/0)=>{let s=Math.min(i+a,e.size);return(t===void 0||i<n||s>r)&&(n=i,r=Math.max(s,Math.min(i+xd,o,e.size)),t=await e.window(n,r)),t}}async function Cd(e){let{size:t}=e,n=await e.window(Math.max(0,t-22-65535-20),t);for(let e=t-22;e>=Math.max(0,t-22-65535);e--)if(n.u32(e)===Uu&&e+22+n.u16(e+20)===t){if(e>=20&&n.u32(e-20)===fd)throw new B(`zip64 is not supported`,e-20);return{end:e,r:n}}throw new B(`no end of central directory record`)}function wd(e,t){let n=[],r=yd(e);for(let i=0;i<e.length;){let a=r.u16(i),o=r.u16(i+2);if(i+4+o>e.length)throw new B(`an extra field runs past its room`,t);if(a===pd)throw new B(`zip64 is not supported`,t);if(a===hd)throw new B(`an entry carries a second name in a Unicode path extra field`,t);n.push({id:a,data:e.slice(i+4,i+4+o)}),i+=4+o}return n}async function Td(e,t){let n=await e(t,46);if(n.u32(t)!==Hu)throw new B(`no central directory entry where one is counted`,t);let r=n.u16(t+28),i=n.u16(t+30);n=await e(t,46+r+i);let a={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),internal:n.u16(t+36),attributes:n.u32(t+38),offset:n.u32(t+42),name:n.slice(t+46,r).slice(),next:t+46+r+i+n.u16(t+32)};if(n.u16(t+34)!==0)throw new B(`the archive spans several disks`,t);if(a.flags&gd)throw new B(`an entry is encrypted`,t);if(a.method!==0&&a.method!==8)throw new B(`compression method ${a.method} is not stored or deflate`,t);if(a.csize===4294967295||a.usize===4294967295||a.offset===4294967295)throw new B(`zip64 is not supported`,t);a.mtime=$u(a.date,a.time,t),a.extra=wd(n.slice(t+46+r,i),t);let o=a.extra.find(e=>e.id===md)?.data;if(o!==void 0&&o[0]&1){if(o.length<5)throw new B(`an extended timestamp is cut short`,t);a.mtime=Ku(o).getInt32(1,!0)}return a}async function Ed(e,t,n,r){let i=t.offset,a=await e(i,30,r);if(a.u32(i)!==Vu)throw new B(`no local header where the central directory points`,i);let o=a.u16(i+26),s=a.u16(i+28);if(a=await e(i,30+o+s,r),!lo(a.slice(i+30,o),t.name))throw new B(`the local header names a different entry`,i);for(let[e,n,r]of[[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`]])if(a.u16(i+e)!==t[n])throw new B(`the local header has ${r}`,i);wd(a.slice(i+30+o,s),i);let c=t.flags&_d,l=(e,t)=>a.u32(i+e)===t||c&&a.u32(i+e)===0;if(!l(14,t.crc)||!l(18,t.csize)||!l(22,t.usize))throw new B(`the local header disagrees with the central directory`,i);t.dataAt=i+30+o+s;let u=t.dataAt+t.csize;if(c){let r=await e(u,16,n),i=e=>r.u32(e)===t.crc&&r.u32(e+4)===t.csize&&r.u32(e+8)===t.usize,a=r.u32(u)===dd&&i(u+4);if(i(u)&&!(a&&u+16===n))u+=12;else if(a)u+=16;else throw new B(`the data descriptor disagrees with the central directory`,u)}return u}function Dd(e,t,n){let r=n&Wu;if(t.endsWith(`/`)){if(r!==0&&r!==Gu.directory)throw new B(`${V(t)} is a directory by its name but not by its mode`,e.at);return`directory`}if(r===Gu.directory)throw new B(`${V(t)} is a directory by its mode but not by its name`,e.at);if(e.attributes&vd)throw new B(`${V(t)} is a directory by its attributes but not by its name`,e.at);if(r===Gu.symlink)return`symlink`;if(r===0||r===Gu.file)return`file`;throw new B(`the mode of ${V(t)} (${n.toString(8)}) is not one this package reads`,e.at)}async function Od(t,n,r){let{at:i,method:a,csize:o,usize:s}=n,c=Po(n.name,`entry name`,i),l=n.madeBy>>8==3?n.attributes>>>16:0,u=Dd(n,c,l);if(u===`directory`&&s!==0)throw new B(`directory ${V(c)} has data`,i);if(a===0&&o!==s)throw new B(`a stored entry has two sizes`,i);let d=await t.read(n.dataAt,n.dataAt+o);if(d.length!==o)throw new B(`the archive is truncated`,n.dataAt);let f=a===8?await Xu(d,s,i):d;if(e(f)!==n.crc)throw new B(`the data does not match its CRC-32`,i);let p=u===`symlink`?Po(f,`symlink target`,i):``,m={...fo(()=>Ds(c,u,p,r.above),i),type:u,mode:l===0?Fo[u]:l&4095,mtime:n.mtime,data:u===`file`?f:so,storedName:c,system:n.madeBy>>8,version:n.version,flags:n.flags,internalAttributes:n.internal,attributes:n.attributes,extra:n.extra};return fo(()=>r.add(m),i),m}async function*kd(e,{limit:t=1/0,symlinksAbove:n}={},r=!1){if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw new B(`limit ${String(t)} is not a whole number of bytes`);let i=Ts(n),{end:a,r:o}=await Cd(e),s=o.u16(a+8);if(o.u16(a+4)!==0||o.u16(a+6)!==0||s!==o.u16(a+10))throw new B(`the archive spans several disks`,a);let c=o.u32(a+12),l=o.u32(a+16);if(s===65535||c===4294967295||l===4294967295)throw new B(`zip64 is not supported`,a);if(l+c!==a)throw new B(`the central directory does not end at the end record`,a);let u=Sd(e),d=[],f=l,p=0;for(let e=0;e<s;e++){let e=await Td(u,f);if(p+=e.usize,p>t)throw new B(`the entries come to more than ${t} bytes`,f,{limited:!0});d.push(e),f=e.next}if(f!==a)throw new B(`the central directory does not hold what the end record counts`,f);let m=0,h=d.toSorted((e,t)=>e.offset-t.offset),g=[],_=[];for(let e=h.length-1;e>=0;e--)g[e]=h[e+1]?.offset??l,_[e]=h[e].csize===0&&e+1<h.length?_[e+1]:g[e]-h[e].csize;let ee=Sd(e);for(let[e,t]of h.entries()){if(t.offset!==m)throw new B(t.offset>m?`bytes belong to no entry`:`two entries overlap`,m);m=await Ed(ee,t,g[e],_[e])}if(m!==l)throw new B(`bytes belong to no entry`,m);let v=new js(r,i);for(let t of d)yield await Od(e,t,v)}async function Ad(e,t){if(!(e instanceof Uint8Array))throw new B(`the archive is not a Uint8Array`);return await Array.fromAsync(kd(bd(e),t,!0))}var jd=(e,t)=>e===null?t:`${e.endsWith(`/`)?e.slice(0,-1):e}/${t}`;function Md(e,t,n){let r=Ld(t.exdir,n);if(r===null)return!1;let i=[],a=Nd(e,r,i,t,n);for(let e of i)Pd(e,n);return a}function Nd(e,t,n,r,i){let{ctx:a}=i;for(let o of e){let e=o.type===`directory`;if(r.junk&&e)continue;let s=r.junk?gt(o.name):o.name,c=O(t,s),l=jd(r.exdir,e?`${s}/`:s),u=Fd(c,a)?Rd(A(c),a):`read-only`;if(u===`read-only`)return Id(l,i);if(u!==null)return i.refuse(`feature`,`name taken`,`${l}: extracting under a name that is not a directory is not supported`),!1;if(e){if(!zd(c,l,i))return!1;continue}if(i.quiet===0)return i.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=Bd(c,l,r,i);if(d===null)return!1;if(d===`skip`)continue;let f=a.fs.openWritable(`/`,c);if(!f)return Id(l,i);let p=o.type===`symlink`;f.writeBytes(p?E(o.linkname):o.data),p&&n.push({path:c,shown:l,target:o.linkname})}return!0}function Pd({path:e,shown:t,target:n},r){let{fs:i}=r.ctx,a=k(`/`,e,i),o=a.path!==null&&i.isFile(a.path)?Vn(i,a.path):null,s=E(n);if(o===null||o.length!==s.length||o.some((e,t)=>e!==s[t])){r.say(2,`warning: deferred symlink (${t}) failed:
55
55
  invalid placeholder file
56
- `);return}i.removeWritable(`/`,e),i.makeWritableLink(`/`,e,n)}var Md=(e,t)=>t.writable&&R(e);function Nd(e,t){return t.refuse(`feature`,`read-only target`,`${e}: Read-only file system`),!1}function Pd(e,t){let{ctx:n}=t;if(e===null)return n.cwd;let r=O(n.cwd,e),i=k(`/`,r,n.fs);if(i.path!==null&&n.fs.isDir(i.path))return i.path;if(i.path!==null)return t.refuse(`feature`,`extraction directory`,`${e}: an extraction directory that is not a directory is not supported`),null;let a=k(`/`,A(r),n.fs);return a.error===null?!Md(r,n)||!n.fs.makeWritableDir(`/`,r)?(Nd(e,t),null):r:(t.say(2,`checkdir: cannot create extraction directory: ${e}
56
+ `);return}i.removeWritable(`/`,e),i.makeWritableLink(`/`,e,n)}var Fd=(e,t)=>t.writable&&L(e);function Id(e,t){return t.refuse(`feature`,`read-only target`,`${e}: Read-only file system`),!1}function Ld(e,t){let{ctx:n}=t;if(e===null)return n.cwd;let r=O(n.cwd,e),i=k(`/`,r,n.fs);if(i.path!==null&&n.fs.isDir(i.path))return i.path;if(i.path!==null)return t.refuse(`feature`,`extraction directory`,`${e}: an extraction directory that is not a directory is not supported`),null;let a=k(`/`,A(r),n.fs);return a.error===null?!Fd(r,n)||!n.fs.makeWritableDir(`/`,r)?(Id(e,t),null):r:(t.say(2,`checkdir: cannot create extraction directory: ${e}
57
57
  ${a.error}
58
- `),t.status=2,null)}function Fd(e,t){let n=[],r=e;for(;k(`/`,r,t.fs).path===null;r=A(r)){if(k(`/`,r,t.fs,{follow:!1}).path!==null)return`File exists`;n.push(r)}if(!t.fs.isDir(k(`/`,r,t.fs).path))return`Not a directory`;for(let e of n.toReversed())if(!R(e)||!t.fs.makeWritableDir(`/`,e))return`read-only`;return null}function Id(e,t,n){let{fs:r}=n.ctx,i=k(`/`,e,r,{follow:!1});return i.path===null?r.makeWritableDir(`/`,e)?(n.quiet===0&&n.say(1,` creating: ${t}
59
- `),!0):Nd(t,n):r.isDir(i.path)?!0:(n.refuse(`feature`,`name taken`,`${t}: a directory entry over a file already there is not supported`),!1)}function Ld(e,t,n,r){let{fs:i}=r.ctx,a=k(`/`,e,i,{follow:!1});return a.path===null?`write`:i.isDir(a.path)?(r.refuse(`feature`,`name taken`,`${t}: a file entry over a directory already there is not supported`),null):(n.overwrite===null&&Rd(t,n,r),n.overwrite===`none`?`skip`:(n.overwrite===`all`&&i.removeWritable(`/`,e),n.overwrite===`all`?`write`:null))}function Rd(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)}function Rd(e,t){let n=[],r=e;for(;k(`/`,r,t.fs).path===null;r=A(r)){if(k(`/`,r,t.fs,{follow:!1}).path!==null)return`File exists`;n.push(r)}if(!t.fs.isDir(k(`/`,r,t.fs).path))return`Not a directory`;for(let e of n.toReversed())if(!L(e)||!t.fs.makeWritableDir(`/`,e))return`read-only`;return null}function zd(e,t,n){let{fs:r}=n.ctx,i=k(`/`,e,r,{follow:!1});return i.path===null?r.makeWritableDir(`/`,e)?(n.quiet===0&&n.say(1,` creating: ${t}
59
+ `),!0):Id(t,n):r.isDir(i.path)?!0:(n.refuse(`feature`,`name taken`,`${t}: a directory entry over a file already there is not supported`),!1)}function Bd(e,t,n,r){let{fs:i}=r.ctx,a=k(`/`,e,i,{follow:!1});return a.path===null?`write`:i.isDir(a.path)?(r.refuse(`feature`,`name taken`,`${t}: a file entry over a directory already there is not supported`),null):(n.overwrite===null&&Vd(t,n,r),n.overwrite===`none`?`skip`:(n.overwrite===`all`&&i.removeWritable(`/`,e),n.overwrite===`all`?`write`:null))}function Vd(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 zd={__proto__:null,l:`list`,t:`test`,p:`pipe`,c:`crt`,v:`verbose`},Bd={usage:{text:`error: must specify directory to which to extract with -d option
62
- `,status:10}};function Vd(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 r=e[n];for(let i=1;i<r.length;i++){let a=r[i];if(a===`d`){if(t.exdir=i+1<r.length?r.slice(i+1):e[++n],t.exdir===void 0)return Bd;break}if(a===`l`&&t.lists++,zd[a])t.modes.add(zd[a]);else if(a===`q`)t.quiet++;else if(a===`o`)t.overwriteAll=!0;else if(a===`n`)t.overwriteNone=!0;else if(a===`j`)t.junk=!0;else throw new T(`option`,`-${a}`,`unknown option: -${a}`)}}if(t.modes.size>1)throw new T(`option`,`modes`,`combining -c, -l, -p, -t and -v is not supported`);if(n>=e.length)throw new T(`feature`,`usage`,`printing the usage summary is not supported`);t.archive=e[n++];let r=!1;for(;n<e.length;n++){let i=e[n];if(i===`-x`)r=!0;else if(i.startsWith(`-d`)){if(t.exdir=i.length>2?i.slice(2):e[++n],t.exdir===void 0)return Bd}else(r?t.excludes:t.members).push(i)}let[i=`extract`]=t.modes,a=i===`list`&&t.lists>1?`verbose`:i,o=t.overwriteNone?`none`:t.overwriteAll?`all`:null;return{...t,mode:a,overwrite:o,bothOverwrites:t.overwriteAll&&t.overwriteNone}}function Hd(e,t,n,r){if(t>=e.length)return+(r>=n.length);let i=e[t++];if(i===63)return r<n.length?Hd(e,t,n,r+1):0;if(i===42){if(t>=e.length)return 1;for(;r<n.length;r++){let i=Hd(e,t,n,r);if(i!==0)return i}return 2}if(i===91)return Ud(e,t,n,r);if(i===92){if(t>=e.length)return 0;i=e[t++]}return r<n.length&&n[r]===i?Hd(e,t,n,r+1):0}function Ud(e,t,n,r){if(r>=n.length)return 0;let i=e[t]===33||e[t]===94,a=t+ +!!i,o=a;for(let t=!1;o<e.length;o++)if(t)t=!1;else if(e[o]===92)t=!0;else if(e[o]===93)break;if(o>=e.length)return 0;let s=0,c=e[a]===45;for(;a<o;a++)if(!c&&e[a]===92)c=!0;else if(!c&&e[a]===45)s=e[a-1];else{if(e[a+1]!==45&&n[r]>=(s||e[a])&&n[r]<=e[a])return i?0:Hd(e,o+1,n,r+1);s=0,c=!1}return i?Hd(e,o+1,n,r+1):0}var Wd=(e,t)=>Hd(e,0,t,0)===1,Gd=[` 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 Hd={__proto__:null,l:`list`,t:`test`,p:`pipe`,c:`crt`,v:`verbose`},Ud={usage:{text:`error: must specify directory to which to extract with -d option
62
+ `,status:10}};function Wd(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 r=e[n];for(let i=1;i<r.length;i++){let a=r[i];if(a===`d`){if(t.exdir=i+1<r.length?r.slice(i+1):e[++n],t.exdir===void 0)return Ud;break}if(a===`l`&&t.lists++,Hd[a])t.modes.add(Hd[a]);else if(a===`q`)t.quiet++;else if(a===`o`)t.overwriteAll=!0;else if(a===`n`)t.overwriteNone=!0;else if(a===`j`)t.junk=!0;else throw new T(`option`,`-${a}`,`unknown option: -${a}`)}}if(t.modes.size>1)throw new T(`option`,`modes`,`combining -c, -l, -p, -t and -v is not supported`);if(n>=e.length)throw new T(`feature`,`usage`,`printing the usage summary is not supported`);t.archive=e[n++];let r=!1;for(;n<e.length;n++){let i=e[n];if(i===`-x`)r=!0;else if(i.startsWith(`-d`)){if(t.exdir=i.length>2?i.slice(2):e[++n],t.exdir===void 0)return Ud}else(r?t.excludes:t.members).push(i)}let[i=`extract`]=t.modes,a=i===`list`&&t.lists>1?`verbose`:i,o=t.overwriteNone?`none`:t.overwriteAll?`all`:null;return{...t,mode:a,overwrite:o,bothOverwrites:t.overwriteAll&&t.overwriteNone}}function Gd(e,t,n,r){if(t>=e.length)return+(r>=n.length);let i=e[t++];if(i===63)return r<n.length?Gd(e,t,n,r+1):0;if(i===42){if(t>=e.length)return 1;for(;r<n.length;r++){let i=Gd(e,t,n,r);if(i!==0)return i}return 2}if(i===91)return Kd(e,t,n,r);if(i===92){if(t>=e.length)return 0;i=e[t++]}return r<n.length&&n[r]===i?Gd(e,t,n,r+1):0}function Kd(e,t,n,r){if(r>=n.length)return 0;let i=e[t]===33||e[t]===94,a=t+ +!!i,o=a;for(let t=!1;o<e.length;o++)if(t)t=!1;else if(e[o]===92)t=!0;else if(e[o]===93)break;if(o>=e.length)return 0;let s=0,c=e[a]===45;for(;a<o;a++)if(!c&&e[a]===92)c=!0;else if(!c&&e[a]===45)s=e[a-1];else{if(e[a+1]!==45&&n[r]>=(s||e[a])&&n[r]<=e[a])return i?0:Gd(e,o+1,n,r+1);s=0,c=!1}return i?Gd(e,o+1,n,r+1):0}var qd=(e,t)=>Gd(e,0,t,0)===1,Jd=[` 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 Kd(e,t,n){let r=Vd(t);if(r.usage)return{stdout:``,stderr:r.usage.text,exitCode:r.usage.status};let i=nf(n,r);if(r.bothOverwrites&&i.say(2,`caution: both -n and -o specified; ignoring -o
64
+ `;async function Yd(e,t,n){let r=Wd(t);if(r.usage)return{stdout:``,stderr:r.usage.text,exitCode:r.usage.status};let i=of(n,r);if(r.bothOverwrites&&i.say(2,`caution: both -n and -o specified; ignoring -o
65
65
  `),r.exdir!==null&&r.mode!==`extract`&&i.say(2,`caution: not extracting; -d ignored
66
- `),r.mode===`crt`||r.mode===`verbose`){let e=r.mode===`crt`?`-c`:r.lists>1?`-ll`:`-v`;return i.refuse(`option`,e,`how each entry is stored is not known here, which this listing prints`)}let a=qd(r.archive,n);if(!a)return i.say(2,`unzip: cannot find or open ${r.archive}, ${r.archive}.zip or ${r.archive}.ZIP.
67
- `),i.end(9);let o=Bn(n.fs,a.path),s;try{s=await Dd(o)}catch(e){if(!(e instanceof V))throw e;return Jd(o)?i.refuse(`feature`,`archive`,`this archive is not one this terminal reads: ${e.message}`):(i.heading(a.name,!0),i.say(2,Gd),r.mode!==`pipe`&&i.say(2,`unzip: cannot find zipfile directory in one of ${r.archive} or
66
+ `),r.mode===`crt`||r.mode===`verbose`){let e=r.mode===`crt`?`-c`:r.lists>1?`-ll`:`-v`;return i.refuse(`option`,e,`how each entry is stored is not known here, which this listing prints`)}let a=Xd(r.archive,n);if(!a)return i.say(2,`unzip: cannot find or open ${r.archive}, ${r.archive}.zip or ${r.archive}.ZIP.
67
+ `),i.end(9);let o=Vn(n.fs,a.path),s;try{s=await Ad(o)}catch(e){if(!(e instanceof B))throw e;return Zd(o)?i.refuse(`feature`,`archive`,`this archive is not one this terminal reads: ${e.message}`):(i.heading(a.name,!0),i.say(2,Jd),r.mode!==`pipe`&&i.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
- `),i.end(9))}let c=s.map(So).find(e=>e!==null);if(c!==void 0){let[e,t]=xo(c);return i.refuse(`feature`,e,`${c}: ${t}`)}if(s.length===0)return i.heading(a.name,!1),i.say(2,`warning [${a.name}]: zipfile is empty
70
- `),i.end(1);let l=Xd(s,r);if(r.mode===`list`)return tf(l,a.name,i);if(i.heading(a.name,!1),r.mode===`test`)$d(l,a.name,i);else if(r.mode===`pipe`)for(let e of l.entries)i.bytes(e.type===`symlink`?E(e.linkname):e.data);else if(!kd(l.entries,r,i))return i.end(i.gap?1:i.status);return Zd(l,i),r.mode===`test`&&ef(l,a.name,i),i.end(l.missed?11:i.status)}function qd(e,t){for(let n of[e,`${e}.zip`,`${e}.ZIP`]){let r=N(n===e?t:{...t,notes:null},`unzip`,n);if(!r.error&&!t.fs.isDir(r.path))return{name:n,path:r.path}}return null}function Jd(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 Yd=e=>E(e);function Xd(e,t){let n=t.members.map(e=>({text:e,pattern:Yd(e),hit:!1})),r=t.excludes.map(e=>({text:e,pattern:Yd(e),hit:!1})),i=(e,t)=>{let n=!1;for(let r of e)Wd(r.pattern,t)&&(r.hit=!0,n=!0);return n};return{entries:e.filter(e=>{let t=Yd(bo(e)),a=n.length===0||i(n,t);return!i(r,t)&&a}),include:n,exclude:r,all:n.length===0&&r.length===0,missed:n.some(e=>!e.hit)}}function Zd(e,t){for(let n of e.include)n.hit||t.say(2,`caution: filename not matched: ${n.text}
69
+ `),i.end(9))}let c=s.map(Eo).find(e=>e!==null);if(c!==void 0){let[e,t]=To(c);return i.refuse(`feature`,e,`${c}: ${t}`)}if(s.length===0)return i.heading(a.name,!1),i.say(2,`warning [${a.name}]: zipfile is empty
70
+ `),i.end(1);let l=$d(s,r);if(r.mode===`list`)return af(l,a.name,i);if(i.heading(a.name,!1),r.mode===`test`)nf(l,a.name,i);else if(r.mode===`pipe`)for(let e of l.entries)i.bytes(e.type===`symlink`?E(e.linkname):e.data);else if(!Md(l.entries,r,i))return i.end(i.gap?1:i.status);return ef(l,i),r.mode===`test`&&rf(l,a.name,i),i.end(l.missed?11:i.status)}function Xd(e,t){for(let n of[e,`${e}.zip`,`${e}.ZIP`]){let r=N(n===e?t:{...t,notes:null},`unzip`,n);if(!r.error&&!t.fs.isDir(r.path))return{name:n,path:r.path}}return null}function Zd(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 Qd=e=>E(e);function $d(e,t){let n=t.members.map(e=>({text:e,pattern:Qd(e),hit:!1})),r=t.excludes.map(e=>({text:e,pattern:Qd(e),hit:!1})),i=(e,t)=>{let n=!1;for(let r of e)qd(r.pattern,t)&&(r.hit=!0,n=!0);return n};return{entries:e.filter(e=>{let t=Qd(wo(e)),a=n.length===0||i(n,t);return!i(r,t)&&a}),include:n,exclude:r,all:n.length===0&&r.length===0,missed:n.some(e=>!e.hit)}}function ef(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 Qd=(e,t)=>e+` `.repeat(Math.max(0,t-Yd(e).length));function $d(e,t,n){if(n.quiet===0)for(let t of e.entries)n.say(1,` testing: ${Qd(bo(t),22)} OK
73
- `)}function ef(e,t,n){n.quiet>1||(e.missed?n.say(1,`At least one error was detected in ${t}.
72
+ `)}var tf=(e,t)=>e+` `.repeat(Math.max(0,t-Qd(e).length));function nf(e,t,n){if(n.quiet===0)for(let t of e.entries)n.say(1,` testing: ${tf(wo(t),22)} OK
73
+ `)}function rf(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 tf(e,t,n){let{ctx:r}=n,i=r.vars.has(`TZ`),a=e=>wb(new Date(e.mtime*1e3),`%Y-%m-%d %H:%M`,i);if(!i&&e.entries.some(e=>a(e)!==wb(new Date(e.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 o=e=>e.type===`symlink`?Yd(e.linkname).length:e.data.length;n.heading(t,!1),n.quiet<2&&n.say(1,` Length Date Time Name
76
+ `))}function af(e,t,n){let{ctx:r}=n,i=r.vars.has(`TZ`),a=e=>Db(new Date(e.mtime*1e3),`%Y-%m-%d %H:%M`,i);if(!i&&e.entries.some(e=>a(e)!==Db(new Date(e.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 o=e=>e.type===`symlink`?Qd(e.linkname).length:e.data.length;n.heading(t,!1),n.quiet<2&&n.say(1,` Length Date Time Name
77
77
  --------- ---------- ----- ----
78
- `);let s=0;for(let t of e.entries)s+=o(t),n.say(1,`${String(o(t)).padStart(9)} ${a(t)} ${bo(t)}
78
+ `);let s=0;for(let t of e.entries)s+=o(t),n.say(1,`${String(o(t)).padStart(9)} ${a(t)} ${wo(t)}
79
79
  `);let c=e.entries.length;return n.quiet<2&&n.say(1,`--------- -------
80
80
  ${String(s).padStart(9)} ${c} file${c===1?``:`s`}
81
- `),n.end(c===0&&e.include.length>0?11:0)}function nf(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(e,t){r.events.push({fd:n?1:e,text:t})},bytes(e){r.events.push({fd:1,bytes:e})},heading(e,t){r.quiet===0?r.say(1,`Archive: ${e}
81
+ `),n.end(c===0&&e.include.length>0?11:0)}function of(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(e,t){r.events.push({fd:n?1:e,text:t})},bytes(e){r.events.push({fd:1,bytes:e})},heading(e,t){r.quiet===0?r.say(1,`Archive: ${e}
82
82
  `):t&&r.say(2,`[${e}]
83
83
  `)},refuse(e,t,n){return r.say(2,`unzip: ${n}
84
- `),r.gap={kind:e,detail:t,message:`unzip: ${n}`},r.end(1)},end(e=r.status){let t=e=>r.events.filter(t=>t.fd===e&&t.text!==void 0).map(e=>e.text).join(``),n={stdout:t(1),stderr:t(2),exitCode:e,events:r.events};return r.gap?w(n,r.gap.kind,`unzip`,r.gap.detail,r.gap.message):n}};return r}var rf={file:384,directory:448,symlink:511},af={__proto__:null,r:`recurse`,q:`quiet`,j:`junk`,0:`store`,y:`symlinks`,D:`noDirectories`};function of(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 T(`option`,n.split(`=`)[0],`unknown option: ${n.split(`=`)[0]}`);if(n.startsWith(`-`)&&n.length>1)for(let e of n.slice(1)){if(!af[e])throw new T(`option`,`-${e}`,`unknown option: -${e}`);t[af[e]]=!0}else t.archive===null?t.archive=n:t.names.push(n)}return t}async function sf(e,t,n){let r=of(t);if(r.archive===null||r.archive===`-`){if(t.length>0&&In(n))return{stdout:``,stderr:`
84
+ `),r.gap={kind:e,detail:t,message:`unzip: ${n}`},r.end(1)},end(e=r.status){let t=e=>r.events.filter(t=>t.fd===e&&t.text!==void 0).map(e=>e.text).join(``),n={stdout:t(1),stderr:t(2),exitCode:e,events:r.events};return r.gap?w(n,r.gap.kind,`unzip`,r.gap.detail,r.gap.message):n}};return r}var sf={file:384,directory:448,symlink:511},cf={__proto__:null,r:`recurse`,q:`quiet`,j:`junk`,0:`store`,y:`symlinks`,D:`noDirectories`};function lf(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 T(`option`,n.split(`=`)[0],`unknown option: ${n.split(`=`)[0]}`);if(n.startsWith(`-`)&&n.length>1)for(let e of n.slice(1)){if(!cf[e])throw new T(`option`,`-${e}`,`unknown option: -${e}`);t[cf[e]]=!0}else t.archive===null?t.archive=n:t.names.push(n)}return t}async function uf(e,t,n){let r=lf(t);if(r.archive===null||r.archive===`-`){if(t.length>0&&Ln(n))return{stdout:``,stderr:`
85
85
  zip error: Invalid command arguments (cannot write zip file to terminal)
86
- `,exitCode:16};throw new T(`feature`,`streamed archive`,`writing an archive to stdout is not supported`)}let i={events:[],status:0},a=e=>i.events.push({fd:1,text:e}),o=ht(r.archive).includes(`.`)?r.archive:`${r.archive}.zip`;if(k(n.cwd,o,n.fs,{follow:!1}).path!==null)return yf(i,`feature`,`existing archive`,`${o}: adding to an archive that is already there is not supported`);let s={ctx:n,opts:r,entries:[],seen:new Set,out:a,gap:null};for(let e of r.names){if(e===`-`)return yf(i,`feature`,`stdin input`,"adding what stdin holds, as the entry `-`, is not supported");if(hf(e,s),s.gap)return yf(i,...s.gap)}if(s.entries.length===0)return a(`
86
+ `,exitCode:16};throw new T(`feature`,`streamed archive`,`writing an archive to stdout is not supported`)}let i={events:[],status:0},a=e=>i.events.push({fd:1,text:e}),o=gt(r.archive).includes(`.`)?r.archive:`${r.archive}.zip`;if(k(n.cwd,o,n.fs,{follow:!1}).path!==null)return Sf(i,`feature`,`existing archive`,`${o}: adding to an archive that is already there is not supported`);let s={ctx:n,opts:r,entries:[],seen:new Set,out:a,gap:null};for(let e of r.names){if(e===`-`)return Sf(i,`feature`,`stdin input`,"adding what stdin holds, as the entry `-`, is not supported");if(vf(e,s),s.gap)return Sf(i,...s.gap)}if(s.entries.length===0)return a(`
87
87
  zip error: Nothing to do! (${o})
88
- `),bf(i,12);let c=_f(s);if(c)return a(c),bf(i,16);let l=r.store?new Map:await df(s.entries.filter(e=>e.type===`file`)),u=[...l.keys()].filter(uf);if(u.length>0&&u.length<l.size)return yf(i,`feature`,`stored suffix`,`${u[0].name}: storing a file as Info-ZIP stores one by its suffix, beside files it deflates, is not supported`);for(let e of u)l.delete(e);let d=s.entries.map(e=>ff(e,l.get(e))),f;try{f=await sd(s.entries,{method:l.size>0?`deflate`:`store`})}catch(e){if(!(e instanceof V))throw e;return yf(i,`feature`,`archive`,`this archive cannot be written here: ${e.message}`)}let p=O(n.cwd,o),m=n.writable&&R(p)?cf(n,o):null;if(m===null)return yf(i,`feature`,`read-only target`,`${o}: Read-only file system`);if(m.error)return a(`zip I/O error: ${m.error}
88
+ `),Cf(i,12);let c=bf(s);if(c)return a(c),Cf(i,16);let l=r.store?new Map:await mf(s.entries.filter(e=>e.type===`file`)),u=[...l.keys()].filter(pf);if(u.length>0&&u.length<l.size)return Sf(i,`feature`,`stored suffix`,`${u[0].name}: storing a file as Info-ZIP stores one by its suffix, beside files it deflates, is not supported`);for(let e of u)l.delete(e);let d=s.entries.map(e=>hf(e,l.get(e))),f;try{f=await ud(s.entries,{method:l.size>0?`deflate`:`store`})}catch(e){if(!(e instanceof B))throw e;return Sf(i,`feature`,`archive`,`this archive cannot be written here: ${e.message}`)}let p=O(n.cwd,o),m=n.writable&&L(p)?df(n,o):null;if(m===null)return Sf(i,`feature`,`read-only target`,`${o}: Read-only file system`);if(m.error)return a(`zip I/O error: ${m.error}
89
89
  zip error: Could not create output file (${o})
90
- `),bf(i,15);if(!r.quiet)for(let e of d)a(e);return m.writeBytes(f),bf(i,0)}function cf(e,t){try{return e.fs.openWritable(e.cwd,t)}catch(e){return{error:e.fsError??`No such file or directory`}}}var lf=[`.Z`,`.zip`,`.zoo`,`.arc`,`.lzh`,`.arj`],uf=e=>lf.some(t=>e.name.endsWith(t));async function df(e){let t=await Promise.all(e.map(async e=>e.data.length===0?0:(await go(e.data,`deflate-raw`)).length));return new Map(e.flatMap((e,n)=>t[n]<e.data.length?[[e,t[n]]]:[]))}function ff(e,t){let n=e.type===`directory`?`${e.name}/`:e.name;return t===void 0?` adding: ${n} (stored 0%)
91
- `:` adding: ${n} (deflated ${pf(e.data.length,t)}%)
92
- `}function pf(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 mf(e,t){if(t.junk)return ht(e);let n=e.replace(/^\/+/u,``);for(;n.startsWith(`./`);)n=n.slice(2);return n===`.`?``:n}function hf(e,t){let{ctx:n,opts:r}=t,i=k(n.cwd,e,n.fs,{follow:!r.symlinks});if(i.error){t.out(` zip warning: name not matched: ${e}
93
- `);return}let a=e.length>1?e.replace(/\/+$/u,``):e,o=mf(a,r);gf(i.path,o,!r.junk&&o===``?``:a,t)}function gf(e,t,n,r){let{ctx:i,opts:a}=r,{fs:o}=i,s=a.symlinks&&o.isLink?.(e)===!0,c=!s&&o.isDir(e);if(t!==``&&t.split(`/`).some(e=>e===`.`||e===`..`||e===``))return vf(r,`dot-segment names`,`${t}: names with \`.', \`..' or empty segments are not supported`);let l=s?`symlink`:c?`directory`:`file`;if(t!==``&&(!c||!(a.junk||a.noDirectories))&&r.entries.push({name:t,full:c?`${n}/`:n,type:l,mode:rf[l],mtime:Math.floor(i.createdAt/1e3),linkname:s?o.readLink(e):``,data:l===`file`?Bn(o,e):void 0}),!c||!a.recurse)return;if(r.seen.has(e))return vf(r,`link loop`,`${t}: a directory inside itself through a link is not supported`);r.seen.add(e);let{dirs:u,files:d,links:f=[]}=o.listDir(e);for(let i of[...new Set([...u,...d,...f])].sort(j)){let s=k(`/`,gt(e,i),o,{follow:!a.symlinks});if(s.error?r.out(` zip warning: name not matched: ${t}/${i}
94
- `):gf(s.path,a.junk||t===``?i:`${t}/${i}`,n===``?i:`${n}/${i}`,r),r.gap)break}r.seen.delete(e)}function _f(e){let t=e.entries.toSorted((e,t)=>j(e.name,t.name)||j(e.full,t.full)),n=[];for(let r of t){let t=n.at(-1);if(t?.name!==r.name)n.push(r);else if(t.full!==r.full){let n=r.type===`directory`?`${r.name}/`:r.name,i=e.opts.junk?` this may be a result of using -j
90
+ `),Cf(i,15);if(!r.quiet)for(let e of d)a(e);return m.writeBytes(f),Cf(i,0)}function df(e,t){try{return e.fs.openWritable(e.cwd,t)}catch(e){return{error:e.fsError??`No such file or directory`}}}var ff=[`.Z`,`.zip`,`.zoo`,`.arc`,`.lzh`,`.arj`],pf=e=>ff.some(t=>e.name.endsWith(t));async function mf(e){let t=await Promise.all(e.map(async e=>e.data.length===0?0:(await vo(e.data,`deflate-raw`)).length));return new Map(e.flatMap((e,n)=>t[n]<e.data.length?[[e,t[n]]]:[]))}function hf(e,t){let n=e.type===`directory`?`${e.name}/`:e.name;return t===void 0?` adding: ${n} (stored 0%)
91
+ `:` adding: ${n} (deflated ${gf(e.data.length,t)}%)
92
+ `}function gf(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 _f(e,t){if(t.junk)return gt(e);let n=e.replace(/^\/+/u,``);for(;n.startsWith(`./`);)n=n.slice(2);return n===`.`?``:n}function vf(e,t){let{ctx:n,opts:r}=t,i=k(n.cwd,e,n.fs,{follow:!r.symlinks});if(i.error){t.out(` zip warning: name not matched: ${e}
93
+ `);return}let a=e.length>1?e.replace(/\/+$/u,``):e,o=_f(a,r);yf(i.path,o,!r.junk&&o===``?``:a,t)}function yf(e,t,n,r){let{ctx:i,opts:a}=r,{fs:o}=i,s=a.symlinks&&o.isLink?.(e)===!0,c=!s&&o.isDir(e);if(t!==``&&t.split(`/`).some(e=>e===`.`||e===`..`||e===``))return xf(r,`dot-segment names`,`${t}: names with \`.', \`..' or empty segments are not supported`);let l=s?`symlink`:c?`directory`:`file`;if(t!==``&&(!c||!(a.junk||a.noDirectories))&&r.entries.push({name:t,full:c?`${n}/`:n,type:l,mode:sf[l],mtime:Math.floor(i.createdAt/1e3),linkname:s?o.readLink(e):``,data:l===`file`?Vn(o,e):void 0}),!c||!a.recurse)return;if(r.seen.has(e))return xf(r,`link loop`,`${t}: a directory inside itself through a link is not supported`);r.seen.add(e);let{dirs:u,files:d,links:f=[]}=o.listDir(e);for(let i of[...new Set([...u,...d,...f])].sort(j)){let s=k(`/`,_t(e,i),o,{follow:!a.symlinks});if(s.error?r.out(` zip warning: name not matched: ${t}/${i}
94
+ `):yf(s.path,a.junk||t===``?i:`${t}/${i}`,n===``?i:`${n}/${i}`,r),r.gap)break}r.seen.delete(e)}function bf(e){let t=e.entries.toSorted((e,t)=>j(e.name,t.name)||j(e.full,t.full)),n=[];for(let r of t){let t=n.at(-1);if(t?.name!==r.name)n.push(r);else if(t.full!==r.full){let n=r.type===`directory`?`${r.name}/`:r.name,i=e.opts.junk?` this may be a result of using -j
95
95
  `:``;return` zip warning: first full name: ${t.full}
96
96
  second full name: ${r.full}
97
97
  name in zip file repeated: ${n}
98
98
  ${i}
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(e=>r.has(e)),null}function vf(e,t,n){e.gap??=[`feature`,t,n]}function yf(e,t,n,r){return e.events.push({fd:2,text:`zip: ${r}
101
- `}),w(bf(e,1),t,`zip`,n,`zip: ${r}`)}function bf(e,t){let n=t=>e.events.filter(e=>e.fd===t).map(e=>e.text).join(``);return{stdout:n(1),stderr:n(2),exitCode:t,events:e.events}}var xf={tar:Mu,...fo(`deflate-raw`)?{zip:sf,unzip:Kd}:{}},Sf=`brotli`,Cf=`.br`,wf=fo(Sf)?{brotli:Of}:{},Tf=`con`,Ef=Object.freeze([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),Df=`Usage: brotli [OPTION]... [FILE]...
102
- `;async function Of(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[...Ef,`d`,`c`,`k`,`j`,`f`,`Z`],long:[`decompress`,`stdout`,`keep`,`rm`,`force`,`best`],valueShort:[`q`],valueLong:[`quality`]}),o=kf(r,i);if(o!==void 0)return C(`option`,`brotli`,o,`brotli: ${o}: choosing a compression level is not supported`,1);let s={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(s.stdout&&a.length>1)return{stdout:Df,stderr:``,exitCode:1};let c={ctx:n,events:[],stderr:``,status:0,gap:null};for(let t of a.length===0?[`-`]:a)if(!await Af(t,e,s,c))break;if(c.gap)return c.gap;let l=[...c.events,...c.stderr?[{fd:2,text:c.stderr}]:[]];return{stdout:``,stderr:c.stderr,exitCode:c.status,events:l}}function kf(e,t){let n=[...Ef,`Z`].find(t=>e.has(t));return n===void 0?e.has(`best`)?`--best`:t.has(`q`)?`-q`:t.has(`quality`)?`--quality`:void 0:`-`+n}function Af(e,t,n,r){let{ctx:i}=r;if(e===`-`){if(!n.force&&(n.decompressing?Fn(i):In(i)))return Nf(r,`Use -h help. Use -f to force ${n.decompressing?`input from`:`output to`} a terminal.`);let e=i.stdinBytes,t=i.stdinLeft;return F(i,``,!0),jf(e??E(t),Tf,null,n,r)}let a=null;if(!n.stdout){if(!n.decompressing)a=e+Cf;else{if(e.length<=Cf.length)return Nf(r,`empty output file name for [${e}] input file`);if(e.endsWith(Cf))a=e.slice(0,-Cf.length);else return Nf(r,`input file [${e}] suffix mismatch`)}}let o=N(i,`brotli`,e);return o.error?Nf(r,`failed to open input file [${e}]: ${o.error}`):a!==null&&!n.force&&N(i,`brotli`,a).error===null?Nf(r,`failed to open output file [${a}]: File exists`):a===null&&!n.decompressing&&!n.force&&In(i)?Nf(r,`Use -h help. Use -f to force output to a terminal.`):i.fs.isDir(o.path)?Nf(r,`failed to read input [${e}]: Is a directory`):jf(Bn(i.fs,o.path),e,a,n,r)}async function jf(e,t,n,r,i){let{ctx:a}=i,o=r.decompressing?await Tc(e,Sf):{bytes:await go(e,Sf),error:null};if(o.error)return Nf(i,`corrupt input [${t}]`);if(n===null)i.events.push({fd:1,bytes:o.bytes});else if(!Mf(n,o.bytes,i))return!1;return r.remove&&t!==Tf&&a.fs.removeWritable(a.cwd,t),!0}function Mf(e,t,n){let{ctx:r}=n,i;try{i=r.writable&&r.fs.openWritable?.(r.cwd,e)}catch(t){return Nf(n,`failed to open output file [${e}]: ${t.message}`)}return i?(i.writeBytes(t),!0):(n.gap??=C(`feature`,`brotli`,`read-only target`,`brotli: ${e}: file system is read-only`,1),!1)}function Nf(e,t){return e.stderr+=`${t}
103
- `,e.status=1,!1}var Pf=Object.freeze({__proto__:null,1:`SHA-1`,256:`SHA-256`,384:`SHA-384`,512:`SHA-512`}),Ff=Object.freeze([`1`,`224`,`256`,`384`,`512`,`512224`,`512256`]),If=()=>{try{return typeof crypto?.subtle?.digest==`function`}catch{return!1}};async function Lf(e,t){let n=new Uint8Array(await crypto.subtle.digest(e,t));return Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``)}function Rf(e,t,n){let r=e===`shasum`?n.get(`a`)??`1`:String(t);if(e===`shasum`&&!Ff.includes(r))return{error:x(`${e}: Unrecognized algorithm
100
+ `}}let r=new Set(n);return e.entries=e.entries.filter(e=>r.has(e)),null}function xf(e,t,n){e.gap??=[`feature`,t,n]}function Sf(e,t,n,r){return e.events.push({fd:2,text:`zip: ${r}
101
+ `}),w(Cf(e,1),t,`zip`,n,`zip: ${r}`)}function Cf(e,t){let n=t=>e.events.filter(e=>e.fd===t).map(e=>e.text).join(``);return{stdout:n(1),stderr:n(2),exitCode:t,events:e.events}}var wf={tar:Fu,...mo(`deflate-raw`)?{zip:uf,unzip:Yd}:{}},Tf=`brotli`,Ef=`.br`,Df=mo(Tf)?{brotli:jf}:{},Of=`con`,kf=Object.freeze([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),Af=`Usage: brotli [OPTION]... [FILE]...
102
+ `;async function jf(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[...kf,`d`,`c`,`k`,`j`,`f`,`Z`],long:[`decompress`,`stdout`,`keep`,`rm`,`force`,`best`],valueShort:[`q`],valueLong:[`quality`]}),o=Mf(r,i);if(o!==void 0)return C(`option`,`brotli`,o,`brotli: ${o}: choosing a compression level is not supported`,1);let s={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(s.stdout&&a.length>1)return{stdout:Af,stderr:``,exitCode:1};let c={ctx:n,events:[],stderr:``,status:0,gap:null};for(let t of a.length===0?[`-`]:a)if(!await Nf(t,e,s,c))break;if(c.gap)return c.gap;let l=[...c.events,...c.stderr?[{fd:2,text:c.stderr}]:[]];return{stdout:``,stderr:c.stderr,exitCode:c.status,events:l}}function Mf(e,t){let n=[...kf,`Z`].find(t=>e.has(t));return n===void 0?e.has(`best`)?`--best`:t.has(`q`)?`-q`:t.has(`quality`)?`--quality`:void 0:`-`+n}function Nf(e,t,n,r){let{ctx:i}=r;if(e===`-`){if(!n.force&&(n.decompressing?In(i):Ln(i)))return If(r,`Use -h help. Use -f to force ${n.decompressing?`input from`:`output to`} a terminal.`);let e=i.stdinBytes,t=i.stdinLeft;return F(i,``,!0),Pf(e??E(t),Of,null,n,r)}let a=null;if(!n.stdout){if(!n.decompressing)a=e+Ef;else{if(e.length<=Ef.length)return If(r,`empty output file name for [${e}] input file`);if(e.endsWith(Ef))a=e.slice(0,-Ef.length);else return If(r,`input file [${e}] suffix mismatch`)}}let o=N(i,`brotli`,e);return o.error?If(r,`failed to open input file [${e}]: ${o.error}`):a!==null&&!n.force&&N(i,`brotli`,a).error===null?If(r,`failed to open output file [${a}]: File exists`):a===null&&!n.decompressing&&!n.force&&Ln(i)?If(r,`Use -h help. Use -f to force output to a terminal.`):i.fs.isDir(o.path)?If(r,`failed to read input [${e}]: Is a directory`):Pf(Vn(i.fs,o.path),e,a,n,r)}async function Pf(e,t,n,r,i){let{ctx:a}=i,o=r.decompressing?await Oc(e,Tf):{bytes:await vo(e,Tf),error:null};if(o.error)return If(i,`corrupt input [${t}]`);if(n===null)i.events.push({fd:1,bytes:o.bytes});else if(!Ff(n,o.bytes,i))return!1;return r.remove&&t!==Of&&a.fs.removeWritable(a.cwd,t),!0}function Ff(e,t,n){let{ctx:r}=n,i;try{i=r.writable&&r.fs.openWritable?.(r.cwd,e)}catch(t){return If(n,`failed to open output file [${e}]: ${t.message}`)}return i?(i.writeBytes(t),!0):(n.gap??=C(`feature`,`brotli`,`read-only target`,`brotli: ${e}: file system is read-only`,1),!1)}function If(e,t){return e.stderr+=`${t}
103
+ `,e.status=1,!1}var Lf=Object.freeze({__proto__:null,1:`SHA-1`,256:`SHA-256`,384:`SHA-384`,512:`SHA-512`}),Rf=Object.freeze([`1`,`224`,`256`,`384`,`512`,`512224`,`512256`]),zf=()=>{try{return typeof crypto?.subtle?.digest==`function`}catch{return!1}};async function Bf(e,t){let n=new Uint8Array(await crypto.subtle.digest(e,t));return Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``)}function Vf(e,t,n){let r=e===`shasum`?n.get(`a`)??`1`:String(t);if(e===`shasum`&&!Rf.includes(r))return{error:x(`${e}: Unrecognized algorithm
104
104
  Type shasum -h for help
105
- `,1)};let i=Pf[r];return i===void 0?{error:C(`feature`,e,`SHA-${r}`,`${e}: this runtime's crypto does not digest SHA-${r}`,1)}:{algorithm:i}}function zf(e,t){return async(n,r,i)=>{let{flags:a,order:o,positional:s,values:c}=U(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(a.has(`c`)||a.has(`check`))return C(`feature`,e,`-c`,`${e}: reading a list of digests back is not supported`,1);let{algorithm:l,error:u}=Rf(e,t,c);if(u)return u;let{mode:d,error:f}=Uf(e,a,o);if(f)return f;let p=Hn(e,s,n,i,{read:`bytes`}),m=await Promise.all(p.inputs.map(e=>Lf(l,e.bytes))),h=Wf(l,a,d);return I(p.inputs.map((e,t)=>h(m[t],e.name??`-`)).join(``),p)}}var Bf=new Set([`b`,`binary`]),Vf=new Set([`t`,`text`]);function Hf(e,t){let n=!1,r=null,i=!1;for(let{name:e}of t)Bf.has(e)?(n=!0,r=`binary`):Vf.has(e)?(i=!0,r=`text`):e===`tag`&&(r=`binary`);return e===`shasum`?{binary:n,text:i&&!n,ambiguous:n&&i}:{binary:r===`binary`,text:r===`text`,ambiguous:!1}}function Uf(e,t,n){let r=Hf(e,n),i=e===`shasum`?`Type ${e} -h for help
105
+ `,1)};let i=Lf[r];return i===void 0?{error:C(`feature`,e,`SHA-${r}`,`${e}: this runtime's crypto does not digest SHA-${r}`,1)}:{algorithm:i}}function Hf(e,t){return async(n,r,i)=>{let{flags:a,order:o,positional:s,values:c}=U(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(a.has(`c`)||a.has(`check`))return C(`feature`,e,`-c`,`${e}: reading a list of digests back is not supported`,1);let{algorithm:l,error:u}=Vf(e,t,c);if(u)return u;let{mode:d,error:f}=Kf(e,a,o);if(f)return f;let p=Un(e,s,n,i,{read:`bytes`}),m=await Promise.all(p.inputs.map(e=>Bf(l,e.bytes))),h=qf(l,a,d);return Jn(p.inputs.map((e,t)=>h(m[t],e.name??`-`)).join(``),p)}}var Uf=new Set([`b`,`binary`]),Wf=new Set([`t`,`text`]);function Gf(e,t){let n=!1,r=null,i=!1;for(let{name:e}of t)Uf.has(e)?(n=!0,r=`binary`):Wf.has(e)?(i=!0,r=`text`):e===`tag`&&(r=`binary`);return e===`shasum`?{binary:n,text:i&&!n,ambiguous:n&&i}:{binary:r===`binary`,text:r===`text`,ambiguous:!1}}function Kf(e,t,n){let r=Gf(e,n),i=e===`shasum`?`Type ${e} -h for help
106
106
  `:`Try '${e} --help' for more information.
107
107
  `;return r.ambiguous?{error:x(`${e}: Ambiguous file mode
108
108
  ${i}`,1)}:t.has(`tag`)&&r.text?{error:x(`${e}: --tag does not support --text mode
109
- ${i}`,1)}:{mode:r}}function Wf(e,t,n){let r=t.has(`z`)||t.has(`zero`)?`\0`:`
110
- `;if(t.has(`tag`)){let t=e.replace(`-`,``);return(e,n)=>`${t} (${n}) = ${e}${r}`}return(e,t)=>`${e}${n.binary?` *`:` `}${t}${r}`}var Gf=If()?{sha1sum:zf(`sha1sum`,1),sha256sum:zf(`sha256sum`,256),sha384sum:zf(`sha384sum`,384),sha512sum:zf(`sha512sum`,512),shasum:zf(`shasum`,1)}:{},Kf=()=>typeof fetch==`function`;function qf(e){if(e.network!==void 0&&typeof e.network!=`boolean`)throw TypeError(`createTerminal: network must be true or false (got ${e.network===null?`null`:typeof e.network})`);return e.network===!0}var Jf=Object.freeze([`http:`,`https:`]),Yf=/^[a-zA-Z][a-zA-Z0-9+.-]*:/u;function Xf(e){let t=Yf.test(e)?e:`http://`+e,n;try{n=new URL(t)}catch{return{malformed:!0}}return Jf.includes(n.protocol)?n.hostname===``?{malformed:!0}:{url:n}:{protocol:n.protocol.slice(0,-1)}}var Zf=new Set([`ENOTFOUND`,`EAI_AGAIN`]),Qf=new Set([`ETIMEDOUT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`]),$f=new Set([`ECONNRESET`,`ECONNABORTED`,`EPIPE`]),ep=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`]),tp=new Set([`TimeoutError`,`AbortError`]);function np(e,t,n){let r=ip(e),i=ap(e),a=`Failed to connect to ${t.hostname} port ${rp(t)}`;return tp.has(e?.name)||Qf.has(r)?{code:28,message:n===null?`Operation timed out: ${i}`:`Operation timed out after ${n} milliseconds`}:Zf.has(r)?{code:6,message:`Could not resolve host: ${t.hostname}`}:ep.has(r)?{code:60,message:`SSL certificate problem: ${i}`}:$f.has(r)?{code:56,message:`Recv failure: ${i}`}:{code:7,message:`${a}: ${i}`}}var rp=e=>e.port===``?e.protocol===`https:`?443:80:e.port;function ip(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 ap(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 op(e,t,n=null){try{return{response:await fetch(e.href,t)}}catch(t){return{failed:np(t,e,n)}}}async function sp(e,t,n=null){try{return{bytes:new Uint8Array(await e.arrayBuffer())}}catch(e){let{code:r,message:i}=np(e,t,n);return{failed:r===7?{code:56,message:`Recv failure: ${ap(e)}`}:{code:r,message:i}}}}async function cp(e){try{await e.body?.cancel()}catch{}}var lp={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`]},up=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: …"`'],[`cookie`,'there is no cookie jar here; a cookie to send is `-H "Cookie: …"`'],[`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=…"`'],[`range`,'a ranged request is `-H "Range: bytes=…"`'],[`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: …"`'],[`referer`,'a referer is `-H "Referer: …"`'],[`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`]]),dp=new Map([[`d`,`text`],[`data`,`text`],[`data-ascii`,`text`],[`data-raw`,`raw`],[`data-binary`,`binary`],[`json`,`json`]]),fp=new Set([`H`,`header`]),pp=new Set([`o`,`output`]),mp=new Set([`O`,`remote-name`]),hp=`application/x-www-form-urlencoded`,gp=`application/json`,_p=50,vp=new Set([10,13]);function yp(e,t,n){let{flags:r,values:i,positional:a,order:o}=U(e,lp);if(r.has(`h`)||r.has(`help`))return{help:!0};let s=bp(r,i);return s?{refusal:s}:{opts:xp(r,i,o,t,n),urls:a,targets:jp(o)}}function bp(e,t){for(let[n,r]of up){if(!e.has(n)&&!t.has(n))continue;let i=(n.length===1?`-`:`--`)+n;return C(`option`,`curl`,i,`curl: ${i}: ${r}`,2)}return null}function xp(e,t,n,r,i){i.quiet=(e.has(`s`)||e.has(`silent`))&&!e.has(`S`)&&!e.has(`show-error`);let a=Cp(n,r,i);if(a===null)return null;let o=Dp(t,n,a,i);if(o===null)return null;let s=Sp(t.get(`max-redirs`),`--max-redirs`,i),c=Sp(t.get(`m`)??t.get(`max-time`),`--max-time`,i);if(s===null||c===null)return null;if(c!==void 0&&typeof AbortSignal?.timeout!=`function`)return Np(i,`feature`,`--max-time`,2,`this runtime cannot put a deadline on a request`);let l=e.has(`I`)||e.has(`head`);return{headers:o,body:a.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`:a.bytes===null?`GET`:`POST`),redirects:s===void 0?_p:s<0?1/0:s,timeout:c===void 0?null:Math.round(c*1e3)}}function Sp(e,t,n){if(e===void 0)return;let r=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/u.test(e.trim())?Number(e.trim()):NaN;return Number.isFinite(r)?r:(n.stderr+=`curl: option ${t}: expected a proper numerical parameter
111
- `,n.status=2,null)}function Cp(e,t,n){let r=[],i=new Set;for(let{name:a,value:o}of e){let e=dp.get(a);if(e===void 0)continue;let s=wp(e,o,t,n);if(s===null)return null;i.add(e===`json`?`json`:`form`),r.push(s)}if(r.length===0)return{bytes:null,json:!1};if(i.size>1)return n.stderr+=`curl: --json cannot be mixed with --data
112
- `,n.status=2,null;let a=i.has(`json`),o=[];for(let[e,t]of r.entries())e>0&&!a&&o.push(E(`&`)),o.push(t);return{bytes:ct([...o,new Uint8Array]),json:a}}function wp(e,t,n,r){if(e===`raw`||!t.startsWith(`@`))return E(t);let i=t.slice(1),a=i===`-`?Tp(n,r.ctx):Ep(i,r);return a===null?null:e===`text`?a.filter(e=>!vp.has(e)):a}function Tp(e,t){let n=t.stdinBytes,r=t.stdinLeft===``?e:t.stdinLeft;return F(t,``,!0),n??E(r)}function Ep(e,t){let{ctx:n}=t,r=N(n,`curl`,e);return r.error||n.fs.isDir(r.path)?(Mp(t,26,`Failed to open/read local data from file/application`),null):Bn(n.fs,r.path)}function Dp(e,n,r,i){let a=new Headers;r.bytes!==null&&a.set(`content-type`,r.json?gp:hp),r.json&&a.set(`accept`,gp);let o=e.get(`A`)??e.get(`user-agent`);o!==void 0&&a.set(`user-agent`,o);let s=e.get(`u`)??e.get(`user`);if(s!==void 0){if(!s.includes(`:`))return Np(i,`feature`,`-u`,2,`there is no interactive input here to read a password from`);a.set(`authorization`,`Basic ${t(E(s))}`)}for(let{name:e,value:t}of n)if(fp.has(e)&&!Op(a,t,i))return null;return a}function Op(e,t,n){let r=t.indexOf(`:`);if(r===-1)return t.endsWith(`;`)?kp(e,t.slice(0,-1),``,n):Ap(n,t);let i=t.slice(r+1).trim();return i===``?(Np(n,`option`,`-H`,2,`-H "${t}": taking away a header the runtime sends is not supported`),!1):kp(e,t.slice(0,r),i,n)}function kp(e,t,n,r){try{e.set(t.trim(),n)}catch{return Ap(r,t.trim())}return!0}function Ap(e,t){return e.stderr+=`curl: -H: not a header: ${t}
113
- `,e.status=2,!1}function jp(e){let t=[];for(let{name:n,value:r}of e)pp.has(n)?t.push(r===`-`?null:{file:r}):mp.has(n)&&t.push({remote:!0});return t}function Mp(e,t,n){return e.quiet||(e.stderr+=`curl: (${t}) ${n}
114
- `),e.status=t,!1}function Np(e,t,n,r,i){return e.gap??={kind:t,detail:n,message:`curl: (${r}) ${i}`},Mp(e,r,i),null}var Pp=new Set([301,302,303,307,308]),Fp=new Set([301,302,303]);async function Ip(e,t,n){let r={ctx:n,events:[],stderr:``,status:0,gap:null,quiet:!1},{help:i,refusal:a,opts:o,urls:s,targets:c}=yp(t,e,r);if(i)return{stdout:Rp,stderr:``,exitCode:0};if(a)return a;if(o===null)return zp(r);if(s.length===0)return Lp();for(let[e,t]of s.entries())await Bp(t,c[e]??null,o,r);return zp(r)}var Lp=()=>({stdout:``,stderr:`curl: try 'curl --help' for more information
115
- `,exitCode:2}),Rp=`Usage: curl [options...] <url>
109
+ ${i}`,1)}:{mode:r}}function qf(e,t,n){let r=t.has(`z`)||t.has(`zero`)?`\0`:`
110
+ `;if(t.has(`tag`)){let t=e.replace(`-`,``);return(e,n)=>`${t} (${n}) = ${e}${r}`}return(e,t)=>`${e}${n.binary?` *`:` `}${t}${r}`}var Jf=zf()?{sha1sum:Hf(`sha1sum`,1),sha256sum:Hf(`sha256sum`,256),sha384sum:Hf(`sha384sum`,384),sha512sum:Hf(`sha512sum`,512),shasum:Hf(`shasum`,1)}:{},Yf=()=>typeof fetch==`function`;function Xf(e){if(e.network!==void 0&&typeof e.network!=`boolean`)throw TypeError(`createTerminal: network must be true or false (got ${e.network===null?`null`:typeof e.network})`);return e.network===!0}var Zf=Object.freeze([`http:`,`https:`]),Qf=/^[a-zA-Z][a-zA-Z0-9+.-]*:/u;function $f(e){let t=Qf.test(e)?e:`http://`+e,n;try{n=new URL(t)}catch{return{malformed:!0}}return Zf.includes(n.protocol)?n.hostname===``?{malformed:!0}:{url:n}:{protocol:n.protocol.slice(0,-1)}}var ep=new Set([`ENOTFOUND`,`EAI_AGAIN`]),tp=new Set([`ETIMEDOUT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`]),np=new Set([`ECONNRESET`,`ECONNABORTED`,`EPIPE`]),rp=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`]),ip=new Set([`TimeoutError`,`AbortError`]);function ap(e,t,n){let r=sp(e),i=cp(e),a=`Failed to connect to ${t.hostname} port ${op(t)}`;return ip.has(e?.name)||tp.has(r)?{code:28,message:n===null?`Operation timed out: ${i}`:`Operation timed out after ${n} milliseconds`}:ep.has(r)?{code:6,message:`Could not resolve host: ${t.hostname}`}:rp.has(r)?{code:60,message:`SSL certificate problem: ${i}`}:np.has(r)?{code:56,message:`Recv failure: ${i}`}:{code:7,message:`${a}: ${i}`}}var op=e=>e.port===``?e.protocol===`https:`?443:80:e.port;function sp(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 cp(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 lp(e,t,n=null){try{return{response:await fetch(e.href,t)}}catch(t){return{failed:ap(t,e,n)}}}async function up(e,t,n=null){try{return{bytes:new Uint8Array(await e.arrayBuffer())}}catch(e){let{code:r,message:i}=ap(e,t,n);return{failed:r===7?{code:56,message:`Recv failure: ${cp(e)}`}:{code:r,message:i}}}}async function dp(e){try{await e.body?.cancel()}catch{}}var fp={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`]},pp=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: …"`'],[`cookie`,'there is no cookie jar here; a cookie to send is `-H "Cookie: …"`'],[`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=…"`'],[`range`,'a ranged request is `-H "Range: bytes=…"`'],[`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: …"`'],[`referer`,'a referer is `-H "Referer: …"`'],[`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`]]),mp=new Map([[`d`,`text`],[`data`,`text`],[`data-ascii`,`text`],[`data-raw`,`raw`],[`data-binary`,`binary`],[`json`,`json`]]),hp=new Set([`H`,`header`]),gp=new Set([`o`,`output`]),_p=new Set([`O`,`remote-name`]),vp=`application/x-www-form-urlencoded`,yp=`application/json`,bp=50,xp=new Set([10,13]);function Sp(e,t,n){let{flags:r,values:i,positional:a,order:o}=U(e,fp);if(r.has(`h`)||r.has(`help`))return{help:!0};let s=Cp(r,i);return s?{refusal:s}:{opts:wp(r,i,o,t,n),urls:a,targets:Pp(o)}}function Cp(e,t){for(let[n,r]of pp){if(!e.has(n)&&!t.has(n))continue;let i=(n.length===1?`-`:`--`)+n;return C(`option`,`curl`,i,`curl: ${i}: ${r}`,2)}return null}function wp(e,t,n,r,i){i.quiet=(e.has(`s`)||e.has(`silent`))&&!e.has(`S`)&&!e.has(`show-error`);let a=Ep(n,r,i);if(a===null)return null;let o=Ap(t,n,a,i);if(o===null)return null;let s=Tp(t.get(`max-redirs`),`--max-redirs`,i),c=Tp(t.get(`m`)??t.get(`max-time`),`--max-time`,i);if(s===null||c===null)return null;if(c!==void 0&&typeof AbortSignal?.timeout!=`function`)return Ip(i,`feature`,`--max-time`,2,`this runtime cannot put a deadline on a request`);let l=e.has(`I`)||e.has(`head`);return{headers:o,body:a.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`:a.bytes===null?`GET`:`POST`),redirects:s===void 0?bp:s<0?1/0:s,timeout:c===void 0?null:Math.round(c*1e3)}}function Tp(e,t,n){if(e===void 0)return;let r=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/u.test(e.trim())?Number(e.trim()):NaN;return Number.isFinite(r)?r:(n.stderr+=`curl: option ${t}: expected a proper numerical parameter
111
+ `,n.status=2,null)}function Ep(e,t,n){let r=[],i=new Set;for(let{name:a,value:o}of e){let e=mp.get(a);if(e===void 0)continue;let s=Dp(e,o,t,n);if(s===null)return null;i.add(e===`json`?`json`:`form`),r.push(s)}if(r.length===0)return{bytes:null,json:!1};if(i.size>1)return n.stderr+=`curl: --json cannot be mixed with --data
112
+ `,n.status=2,null;let a=i.has(`json`),o=[];for(let[e,t]of r.entries())e>0&&!a&&o.push(E(`&`)),o.push(t);return{bytes:lt([...o,new Uint8Array]),json:a}}function Dp(e,t,n,r){if(e===`raw`||!t.startsWith(`@`))return E(t);let i=t.slice(1),a=i===`-`?Op(n,r.ctx):kp(i,r);return a===null?null:e===`text`?a.filter(e=>!xp.has(e)):a}function Op(e,t){let n=t.stdinBytes,r=t.stdinLeft===``?e:t.stdinLeft;return F(t,``,!0),n??E(r)}function kp(e,t){let{ctx:n}=t,r=N(n,`curl`,e);return r.error||n.fs.isDir(r.path)?(Fp(t,26,`Failed to open/read local data from file/application`),null):Vn(n.fs,r.path)}function Ap(e,t,n,r){let a=new Headers;n.bytes!==null&&a.set(`content-type`,n.json?yp:vp),n.json&&a.set(`accept`,yp);let o=e.get(`A`)??e.get(`user-agent`);o!==void 0&&a.set(`user-agent`,o);let s=e.get(`u`)??e.get(`user`);if(s!==void 0){if(!s.includes(`:`))return Ip(r,`feature`,`-u`,2,`there is no interactive input here to read a password from`);a.set(`authorization`,`Basic ${i(E(s))}`)}for(let{name:e,value:n}of t)if(hp.has(e)&&!jp(a,n,r))return null;return a}function jp(e,t,n){let r=t.indexOf(`:`);if(r===-1)return t.endsWith(`;`)?Mp(e,t.slice(0,-1),``,n):Np(n,t);let i=t.slice(r+1).trim();return i===``?(Ip(n,`option`,`-H`,2,`-H "${t}": taking away a header the runtime sends is not supported`),!1):Mp(e,t.slice(0,r),i,n)}function Mp(e,t,n,r){try{e.set(t.trim(),n)}catch{return Np(r,t.trim())}return!0}function Np(e,t){return e.stderr+=`curl: -H: not a header: ${t}
113
+ `,e.status=2,!1}function Pp(e){let t=[];for(let{name:n,value:r}of e)gp.has(n)?t.push(r===`-`?null:{file:r}):_p.has(n)&&t.push({remote:!0});return t}function Fp(e,t,n){return e.quiet||(e.stderr+=`curl: (${t}) ${n}
114
+ `),e.status=t,!1}function Ip(e,t,n,r,i){return e.gap??={kind:t,detail:n,message:`curl: (${r}) ${i}`},Fp(e,r,i),null}var Lp=new Set([301,302,303,307,308]),Rp=new Set([301,302,303]);async function zp(e,t,n){let r={ctx:n,events:[],stderr:``,status:0,gap:null,quiet:!1},{help:i,refusal:a,opts:o,urls:s,targets:c}=Sp(t,e,r);if(i)return{stdout:Vp,stderr:``,exitCode:0};if(a)return a;if(o===null)return Hp(r);if(s.length===0)return Bp();for(let[e,t]of s.entries())await Up(t,c[e]??null,o,r);return Hp(r)}var Bp=()=>({stdout:``,stderr:`curl: try 'curl --help' for more information
115
+ `,exitCode:2}),Vp=`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,113 +135,113 @@ ${i}`,1)}:{mode:r}}function Wf(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 zp(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?w(n,e.gap.kind,`curl`,e.gap.detail,e.gap.message):n}async function Bp(e,t,n,r){let i=Xf(e);if(i.protocol)return Np(r,`feature`,`protocol`,1,Vp(i.protocol));if(i.malformed)return Mp(r,3,`URL using bad/illegal format or missing URL`);let a=t?.remote?Hp(i.url):t?.file??null,o={url:i.url,method:n.method,body:n.body,headers:n.headers},s=n.timeout===null?null:AbortSignal.timeout(n.timeout),c=``;for(let e=0;;e++){let{response:t,failed:i}=await op(o.url,Up(o,s),n.timeout);if(i)return Mp(r,i.code,i.message);(n.include||n.head)&&(c+=Zp(t,r.ctx));let l=Wp(t,o,n);if(l===null)return Jp(t,o.url,c,a,n,r);if(await cp(t),e>=n.redirects)return Mp(r,47,`Maximum (${n.redirects}) redirects followed`);if(l.protocol)return Np(r,`feature`,`protocol`,1,Vp(l.protocol));Object.assign(o,l)}}var Vp=e=>`Protocol "${e}" not supported or disabled in libcurl`,Hp=e=>e.pathname.slice(e.pathname.lastIndexOf(`/`)+1),Up=(e,t)=>({method:e.method,headers:e.headers,redirect:`manual`,...e.body===null?{}:{body:e.body},...t===null?{}:{signal:t}});function Wp(e,t,n){if(!n.location||!Pp.has(e.status))return null;let r=e.headers.get(`location`);if(r===null||r===``)return null;let i;try{i=new URL(r,t.url)}catch{return null}if(i.protocol!==`http:`&&i.protocol!==`https:`)return{protocol:i.protocol.slice(0,-1)};let a=Fp.has(e.status)&&t.method!==`HEAD`&&t.method!==`GET`;return{url:i,method:a?`GET`:t.method,body:a?null:t.body,headers:qp(t.headers,a,i.origin!==t.url.origin)}}var Gp=Object.freeze([`content-type`,`content-length`]),Kp=Object.freeze([`authorization`,`cookie`,`proxy-authorization`]);function qp(e,t,n){if(!t&&!n)return e;let r=new Headers(e);if(t)for(let e of Gp)r.delete(e);if(n)for(let e of Kp)r.delete(e);return r}async function Jp(e,t,n,r,i,a){if(i.failEarly&&e.status>=400)return await cp(e),Mp(a,22,`The requested URL returned error: ${e.status}`);if(i.head)return await cp(e),Yp(n,null,r,a);let o=await sp(e,t,i.timeout);return o.failed?Mp(a,o.failed.code,o.failed.message):Yp(n,o.bytes,r,a)}function Yp(e,t,n,r){return n===null?(e!==``&&r.events.push({fd:1,text:e}),t!==null&&t.length>0&&r.events.push({fd:1,bytes:t}),!0):Xp(n,e,t,r)}function Xp(e,t,n,r){let{ctx:i}=r;if(e===``)return Mp(r,23,`Remote filename has no length`);let a;try{a=i.writable&&i.fs.openWritable?.(i.cwd,e)}catch(e){return Mp(r,23,`Failure writing output to destination: ${e.message}`)}return a?(a.writeBytes(ct([E(t),n??new Uint8Array])),!0):Np(r,`feature`,`read-only target`,23,`${e}: file system is read-only`)}function Zp(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?.()??[],i=!1;for(let[t,a]of e.headers){if(t!==`set-cookie`){n.push(`${t}: ${a}`);continue}if(r.length===0){n.push(`${t}: ${a}`);continue}if(!i){i=!0;for(let e of r)n.push(`${t}: ${e}`)}}return n.join(`\r
138
+ `;function Hp(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?w(n,e.gap.kind,`curl`,e.gap.detail,e.gap.message):n}async function Up(e,t,n,r){let i=$f(e);if(i.protocol)return Ip(r,`feature`,`protocol`,1,Wp(i.protocol));if(i.malformed)return Fp(r,3,`URL using bad/illegal format or missing URL`);let a=t?.remote?Gp(i.url):t?.file??null,o={url:i.url,method:n.method,body:n.body,headers:n.headers},s=n.timeout===null?null:AbortSignal.timeout(n.timeout),c=``;for(let e=0;;e++){let{response:t,failed:i}=await lp(o.url,Kp(o,s),n.timeout);if(i)return Fp(r,i.code,i.message);(n.include||n.head)&&(c+=em(t,r.ctx));let l=qp(t,o,n);if(l===null)return Zp(t,o.url,c,a,n,r);if(await dp(t),e>=n.redirects)return Fp(r,47,`Maximum (${n.redirects}) redirects followed`);if(l.protocol)return Ip(r,`feature`,`protocol`,1,Wp(l.protocol));Object.assign(o,l)}}var Wp=e=>`Protocol "${e}" not supported or disabled in libcurl`,Gp=e=>e.pathname.slice(e.pathname.lastIndexOf(`/`)+1),Kp=(e,t)=>({method:e.method,headers:e.headers,redirect:`manual`,...e.body===null?{}:{body:e.body},...t===null?{}:{signal:t}});function qp(e,t,n){if(!n.location||!Lp.has(e.status))return null;let r=e.headers.get(`location`);if(r===null||r===``)return null;let i;try{i=new URL(r,t.url)}catch{return null}if(i.protocol!==`http:`&&i.protocol!==`https:`)return{protocol:i.protocol.slice(0,-1)};let a=Rp.has(e.status)&&t.method!==`HEAD`&&t.method!==`GET`;return{url:i,method:a?`GET`:t.method,body:a?null:t.body,headers:Xp(t.headers,a,i.origin!==t.url.origin)}}var Jp=Object.freeze([`content-type`,`content-length`]),Yp=Object.freeze([`authorization`,`cookie`,`proxy-authorization`]);function Xp(e,t,n){if(!t&&!n)return e;let r=new Headers(e);if(t)for(let e of Jp)r.delete(e);if(n)for(let e of Yp)r.delete(e);return r}async function Zp(e,t,n,r,i,a){if(i.failEarly&&e.status>=400)return await dp(e),Fp(a,22,`The requested URL returned error: ${e.status}`);if(i.head)return await dp(e),Qp(n,null,r,a);let o=await up(e,t,i.timeout);return o.failed?Fp(a,o.failed.code,o.failed.message):Qp(n,o.bytes,r,a)}function Qp(e,t,n,r){return n===null?(e!==``&&r.events.push({fd:1,text:e}),t!==null&&t.length>0&&r.events.push({fd:1,bytes:t}),!0):$p(n,e,t,r)}function $p(e,t,n,r){let{ctx:i}=r;if(e===``)return Fp(r,23,`Remote filename has no length`);let a;try{a=i.writable&&i.fs.openWritable?.(i.cwd,e)}catch(e){return Fp(r,23,`Failure writing output to destination: ${e.message}`)}return a?(a.writeBytes(lt([E(t),n??new Uint8Array])),!0):Ip(r,`feature`,`read-only target`,23,`${e}: file system is read-only`)}function em(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?.()??[],i=!1;for(let[t,a]of e.headers){if(t!==`set-cookie`){n.push(`${t}: ${a}`);continue}if(r.length===0){n.push(`${t}: ${a}`);continue}if(!i){i=!0;for(let e of r)n.push(`${t}: ${e}`)}}return n.join(`\r
139
139
  `)+`\r
140
140
  \r
141
- `}var Qp={...Gc,...wf,...Gf,...xf},$p=Object.freeze({__proto__:null,curl:Ip}),em=Object.freeze(Object.keys($p)),tm=e=>e===!0&&Kf()?$p:null,nm=new Uint8Array;function rm(e,t,n,r,i){let a=im(e,i.skip,i.skipFlag,0),o=im(e,i.len,i.lenFlag,1/0);if(a.error||o.error)return{error:a.error??o.error};let s=o.value,c=a.value,l=0,u=n,d=r.stdinBytes,f=[],m={stderr:``,failed:!1};for(let n of t.length?t:[null]){let t=Hn(e,n===null?[]:[n],u,r,{read:`loose-bytes`,noRead:s===0&&c===0}),o=t.entries[0]?.kind===`dir`;if(m.stderr+=t.stderr,m.failed||=t.failed&&!(e===`hexdump`&&o),c&&o)return{error:C(`feature`,e,`skip across unreadable input`,`${e}: skipping across a directory operand is not supported`)};if(o&&e===`xxd`)return{error:x(m.stderr,2)};if(!t.inputs.length&&!o)continue;let h=t.inputs[0],g=h&&(h.shared||h.name===null);if(e===`hexdump`&&c&&g&&!r.stdinFile)return F(r,u,!0,d),{error:x(`hexdump: standard input: Illegal seek`)};let _=g&&r.stdinFile&&i.skip!==void 0&&(e===`xxd`||e===`hexdump`&&a.value>0),ee=_?p(r.stdinOrigin):h?.bytes??nm,v=Math.min(c,ee.length);c-=v,l+=v;let te=Math.min(s,ee.length-v);if(f.push(ee.subarray(v,v+te)),s-=te,g){let e=ee.subarray(v+te),t=d!==null&&!_&&e.length>0?e:null;u=t===null?D(e):$e(e)??``,F(r,u,!0,t)}if(_&&c&&(l=a.value,c=0),s===0&&c===0)break}if(c&&i.skipPastEofErrors)return{error:x(m.stderr+`${e}: cannot skip past end of combined input`)};let h=new Uint8Array(f.reduce((e,t)=>e+t.length,0)),g=0;for(let e of f)h.set(e,g),g+=e.length;return{bytes:h,start:l,r:m}}function im(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:C(`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:C(`feature`,e,`${n} ${t}`,`hexdump: this offset/count spelling is not supported: ${t}`)}:BigInt(t)>BigInt(2**53-1)?{error:C(`feature`,e,`large byte count`,`hexdump: counts beyond exact integer precision are not supported`)}:{value:Number(t)}:{error:x(`${e}: ${n}: invalid count: ${t}`)};let i=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(t);if(!i)return{error:x(`${e}: ${n}: invalid count: ${t}`)};let a=/^0\d/u.test(i[1])?`0o`+i[1].slice(1):i[1];return Yn(BigInt(a),i[2],`${e}: ${n}`,t)}var am=16,om=47,sm=39;function cm(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`C`,`v`],valueShort:[`n`,`s`]});if(a.includes(`-`))return C(`feature`,`hexdump`,`hyphen input operand`,`hexdump: a hyphen input operand is not supported; omit operands to read stdin`);let o=rm(`hexdump`,a,e,n,{skip:i.get(`s`),len:i.get(`n`),skipFlag:`-s`,lenFlag:`-n`});return o.error?o.error:I(dm(o.bytes,o.start,r.has(`v`),r.has(`C`)?pm:fm),o.r)}function lm(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`v`],valueShort:[`j`,`N`]});if(!r.size&&!i.size&&(a.length===1&&/^\+\d/u.test(a[0])||a.length===2&&/^\+?\d/u.test(a[1])))return C(`feature`,`od`,`legacy offset operand`,`od: legacy offset operands are not supported; use -j OFFSET`);let o=rm(`od`,a,e,n,{skip:i.get(`j`),len:i.get(`N`),skipFlag:`-j`,lenFlag:`-N`,skipPastEofErrors:!0});return o.error?o.error:I(dm(o.bytes,o.start,r.has(`v`),mm),o.r)}function um(e,t,n){let{values:r,positional:i}=U(t,{valueShort:[`s`,`l`]});if(i.length>2)return x(`xxd: too many operands`);if(i.length===2&&i[1]!==`-`)return C(`feature`,`xxd`,`output file`,`xxd: output files are not supported (filesystem is read-only)`);let a=rm(`xxd`,i.slice(0,1),e,n,{skip:r.get(`s`),len:r.get(`l`),skipFlag:`-s`,lenFlag:`-l`});return a.error?a.error:I(dm(a.bytes,a.start,!1,hm),a.r)}function dm(e,t,n,i){let a=i.hex?r(e):``,o=[],s=null,c=!1;for(let r=0;r<e.length;r+=am){let l=e.subarray(r,r+am),u=i.hex?a.slice(r*2,(r+am)*2):``;i.compress&&!n&&s!==null&&l.length===am&&Cm(l,s)?c||=(o.push(`*`),!0):(o.push(i.row(t+r,l,u)),c=!1),s=l}let l=t+e.length;return(i.trailer===`always`||i.trailer===`nonzero`&&l>0)&&o.push(i.addr(l)),Nn(o)}var fm={compress:!0,trailer:`nonzero`,addr:gm,row:(e,t)=>(gm(e)+` `+bm(t).map(wm).join(` `)).padEnd(om)},pm={compress:!0,trailer:`nonzero`,addr:_m,hex:!0,row:ym},mm={compress:!0,trailer:`always`,addr:vm,row:(e,t)=>vm(e)+` `+bm(t).map(Tm).join(` `)},hm={compress:!1,trailer:`never`,hex:!0,row:(e,t,n)=>`${_m(e)}: ${xm(t,n).join(` `).padEnd(sm)} ${Sm(t)}`};function gm(e){return e.toString(16).padStart(7,`0`)}function _m(e){return e.toString(16).padStart(8,`0`)}function vm(e){return e.toString(8).padStart(7,`0`)}function ym(e,t,n){let r=[];for(let e=0;e<am;e++)r.push(e<t.length?n.slice(e*2,e*2+2):` `);let i=r.slice(0,8).join(` `),a=r.slice(8).join(` `);return`${_m(e)} ${i} ${a} |${Sm(t)}|`}function bm(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 xm(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 Sm(e){let t=``;for(let n of e)t+=n>=32&&n<=126?String.fromCodePoint(n):`.`;return t}function Cm(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var wm=e=>e.toString(16).padStart(4,`0`),Tm=e=>e.toString(8).padStart(6,`0`),Em=76;function Dm(e,{encode:t,decode:n}){return(r,i,a)=>{let{flags:o,positional:s,order:c}=U(i,{short:[`d`,`i`],long:[`decode`,`ignore-garbage`],valueShort:[`w`],valueLong:[`wrap`]}),l=Em;for(let{name:t,value:n}of c){if(t!==`w`&&t!==`wrap`)continue;if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(n)||BigInt(n)<0n)return x(`${e}: invalid wrap size: ${n}`);let r=BigInt(n);l=r>yn?0:Number(r)}if(s.length>1)return x(`${e}: extra operand: ${s[1]}`);let u=Hn(e,s,r,a,{read:`as-held`});if(u.failed)return x(u.stderr);let{content:d,bytes:f}=u.inputs[0];return o.has(`d`)||o.has(`decode`)?km(e,n(d??Qe(f),o.has(`i`)||o.has(`ignore-garbage`))):Om(t(f??E(d)),l)}}function Om(e,t){if(!t||e===``)return b(e);let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return b(n.join(`
141
+ `}var tm={...Jc,...Df,...Jf,...wf},nm=Object.freeze({__proto__:null,curl:zp}),rm=Object.freeze(Object.keys(nm)),im=e=>e===!0&&Yf()?nm:null,am=new Uint8Array;function om(e,t,n,r,i){let a=sm(e,i.skip,i.skipFlag,0),o=sm(e,i.len,i.lenFlag,1/0);if(a.error||o.error)return{error:a.error??o.error};let s=o.value,c=a.value,l=0,u=n,d=r.stdinBytes,f=[],m={stderr:``,failed:!1};for(let n of t.length?t:[null]){let t=Un(e,n===null?[]:[n],u,r,{read:`loose-bytes`,noRead:s===0&&c===0}),o=t.entries[0]?.kind===`dir`;if(m.stderr+=t.stderr,m.failed||=t.failed&&!(e===`hexdump`&&o),c&&o)return{error:C(`feature`,e,`skip across unreadable input`,`${e}: skipping across a directory operand is not supported`)};if(o&&e===`xxd`)return{error:x(m.stderr,2)};if(!t.inputs.length&&!o)continue;let h=t.inputs[0],g=h&&(h.shared||h.name===null);if(e===`hexdump`&&c&&g&&!r.stdinFile)return F(r,u,!0,d),{error:x(`hexdump: standard input: Illegal seek`)};let _=g&&r.stdinFile&&i.skip!==void 0&&(e===`xxd`||e===`hexdump`&&a.value>0),ee=_?p(r.stdinOrigin):h?.bytes??am,v=Math.min(c,ee.length);c-=v,l+=v;let te=Math.min(s,ee.length-v);if(f.push(ee.subarray(v,v+te)),s-=te,g){let e=ee.subarray(v+te),t=d!==null&&!_&&e.length>0?e:null;u=t===null?D(e):et(e)??``,F(r,u,!0,t)}if(_&&c&&(l=a.value,c=0),s===0&&c===0)break}if(c&&i.skipPastEofErrors)return{error:x(m.stderr+`${e}: cannot skip past end of combined input`)};let h=new Uint8Array(f.reduce((e,t)=>e+t.length,0)),g=0;for(let e of f)h.set(e,g),g+=e.length;return{bytes:h,start:l,r:m}}function sm(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:C(`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:C(`feature`,e,`${n} ${t}`,`hexdump: this offset/count spelling is not supported: ${t}`)}:BigInt(t)>BigInt(2**53-1)?{error:C(`feature`,e,`large byte count`,`hexdump: counts beyond exact integer precision are not supported`)}:{value:Number(t)}:{error:x(`${e}: ${n}: invalid count: ${t}`)};let i=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(t);if(!i)return{error:x(`${e}: ${n}: invalid count: ${t}`)};let a=/^0\d/u.test(i[1])?`0o`+i[1].slice(1):i[1];return Zn(BigInt(a),i[2],`${e}: ${n}`,t)}var cm=16,lm=47,um=39;function dm(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`C`,`v`],valueShort:[`n`,`s`]});if(a.includes(`-`))return C(`feature`,`hexdump`,`hyphen input operand`,`hexdump: a hyphen input operand is not supported; omit operands to read stdin`);let o=om(`hexdump`,a,e,n,{skip:i.get(`s`),len:i.get(`n`),skipFlag:`-s`,lenFlag:`-n`});return o.error?o.error:Jn(mm(o.bytes,o.start,r.has(`v`),r.has(`C`)?gm:hm),o.r)}function fm(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`v`],valueShort:[`j`,`N`]});if(!r.size&&!i.size&&(a.length===1&&/^\+\d/u.test(a[0])||a.length===2&&/^\+?\d/u.test(a[1])))return C(`feature`,`od`,`legacy offset operand`,`od: legacy offset operands are not supported; use -j OFFSET`);let o=om(`od`,a,e,n,{skip:i.get(`j`),len:i.get(`N`),skipFlag:`-j`,lenFlag:`-N`,skipPastEofErrors:!0});return o.error?o.error:Jn(mm(o.bytes,o.start,r.has(`v`),_m),o.r)}function pm(e,t,n){let{values:r,positional:i}=U(t,{valueShort:[`s`,`l`]});if(i.length>2)return x(`xxd: too many operands`);if(i.length===2&&i[1]!==`-`)return C(`feature`,`xxd`,`output file`,`xxd: output files are not supported (filesystem is read-only)`);let a=om(`xxd`,i.slice(0,1),e,n,{skip:r.get(`s`),len:r.get(`l`),skipFlag:`-s`,lenFlag:`-l`});return a.error?a.error:Jn(mm(a.bytes,a.start,!1,vm),a.r)}function mm(e,t,n,i){let a=i.hex?r(e):``,o=[],s=null,c=!1;for(let r=0;r<e.length;r+=cm){let l=e.subarray(r,r+cm),u=i.hex?a.slice(r*2,(r+cm)*2):``;i.compress&&!n&&s!==null&&l.length===cm&&Em(l,s)?c||=(o.push(`*`),!0):(o.push(i.row(t+r,l,u)),c=!1),s=l}let l=t+e.length;return(i.trailer===`always`||i.trailer===`nonzero`&&l>0)&&o.push(i.addr(l)),Pn(o)}var hm={compress:!0,trailer:`nonzero`,addr:ym,row:(e,t)=>(ym(e)+` `+Cm(t).map(Dm).join(` `)).padEnd(lm)},gm={compress:!0,trailer:`nonzero`,addr:bm,hex:!0,row:Sm},_m={compress:!0,trailer:`always`,addr:xm,row:(e,t)=>xm(e)+` `+Cm(t).map(Om).join(` `)},vm={compress:!1,trailer:`never`,hex:!0,row:(e,t,n)=>`${bm(e)}: ${wm(t,n).join(` `).padEnd(um)} ${Tm(t)}`};function ym(e){return e.toString(16).padStart(7,`0`)}function bm(e){return e.toString(16).padStart(8,`0`)}function xm(e){return e.toString(8).padStart(7,`0`)}function Sm(e,t,n){let r=[];for(let e=0;e<cm;e++)r.push(e<t.length?n.slice(e*2,e*2+2):` `);let i=r.slice(0,8).join(` `),a=r.slice(8).join(` `);return`${bm(e)} ${i} ${a} |${Tm(t)}|`}function Cm(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 wm(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 Tm(e){let t=``;for(let n of e)t+=n>=32&&n<=126?String.fromCodePoint(n):`.`;return t}function Em(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var Dm=e=>e.toString(16).padStart(4,`0`),Om=e=>e.toString(8).padStart(6,`0`),km=76;function Am(e,{encode:t,decode:n}){return(r,i,a)=>{let{flags:o,positional:s,order:c}=U(i,{short:[`d`,`i`],long:[`decode`,`ignore-garbage`],valueShort:[`w`],valueLong:[`wrap`]}),l=km;for(let{name:t,value:n}of c){if(t!==`w`&&t!==`wrap`)continue;if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(n)||BigInt(n)<0n)return x(`${e}: invalid wrap size: ${n}`);let r=BigInt(n);l=r>bn?0:Number(r)}if(s.length>1)return x(`${e}: extra operand: ${s[1]}`);let u=Un(e,s,r,a,{read:`as-held`});if(u.failed)return x(u.stderr);let{content:d,bytes:f}=u.inputs[0];return o.has(`d`)||o.has(`decode`)?Mm(e,n(d??$e(f),o.has(`i`)||o.has(`ignore-garbage`))):jm(t(f??E(d)),l)}}function jm(e,t){if(!t||e===``)return b(e);let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return b(n.join(`
142
142
  `)+`
143
- `)}function km(e,{bytes:t,valid:n}){let r=$e(t),i=n?``:`${e}: invalid input
144
- `;if(r!==void 0&&n)return b(r);let a=r===void 0?{fd:1,bytes:t}:{fd:1,text:r};return{stdout:r??``,stderr:i,exitCode:+!n,events:[...t.length?[a]:[],...i?[{fd:2,text:i}]:[]]}}var Am=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,jm=8,Mm=Object.freeze([2,4,5,7,8]),Nm=Dm(`base32`,{encode:e=>a(e,{padding:!0}),decode:Fm}),Pm=/[a-z]/u;function Fm(e,t=!1){let n=e.replace(t?/[^A-Z2-7=]/gu:/\n/gu,``);try{let e=i(n,{padding:!0});if(!Pm.test(n))return{bytes:e,valid:!0}}catch(e){if(!(e instanceof SyntaxError))throw e}return Im(n)}function Im(e){let t=new Uint8Array(Math.ceil(e.length/jm)*5),n=0,r=0,i=!0;for(;r<e.length;){if(e.length-r<jm){i=!1;break}let a=e.slice(r,r+jm),o=/^[A-Z2-7]*/u.exec(a)[0];if(n+=Lm(a,o,t.subarray(n)),!Mm.includes(o.length)||a.slice(o.length)!==`=`.repeat(jm-o.length)){i=!1;break}r+=jm}return{bytes:t.subarray(0,n),valid:i}}function Lm(e,t,n){let r=0,i=0,a=0;for(let e of t)i=i<<5|Am.indexOf(e),r+=5,!(r<8)&&(r-=8,n[a++]=i>>r&255);return a}var Rm=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,zm=Dm(`base64`,{encode:t,decode:Bm});function Bm(e,t=!1){let r=e.replace(t?/[^A-Za-z0-9+/=]/gu:/\n/gu,``);try{return{bytes:n(r,{padding:!0}),valid:!0}}catch(e){if(!(e instanceof SyntaxError))throw e;return Vm(r)}}function Vm(e){let t=new Uint8Array(Math.ceil(e.length/4)*3),r=/[A-Za-z0-9+/]*/uy,i=0,a=0,o=!0;for(;a<e.length;){r.lastIndex=a;let s=r.exec(e)[0].length,c=s-s%4;if(c){let r=n(e.slice(a,a+c));t.set(r,i),i+=r.length,a+=c}if(a===e.length)break;let l=s%4;if(l<2){o=!1;break}let u=Rm.indexOf(e[a]),d=Rm.indexOf(e[a+1]),f=l===3?Rm.indexOf(e[a+2]):0;t[i++]=u<<2|d>>4,l===3&&(t[i++]=d<<4|f>>2);let p=4-l;if(a+=l,e.slice(a,a+p)!==`=`.repeat(p)){o=!1;break}a+=p}return{bytes:t.subarray(0,i),valid:o}}var Hm={short:[`n`,`N`,`i`,`s`,`w`,`F`,`v`,`l`,`c`,`q`,`u`,`a`,`H`,`I`],long:[`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`],valueShort:[`A`,`B`,`C`],valueLong:[`after-context`,`before-context`,`context`],repeatable:[`e`,`regexp`]},Um=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`})),Wm=new Set([`no-heading`,`no-ignore`]),Gm=(e,t)=>new T(`feature`,e,`rg: ${t}`);function Km(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:n,value:r}of e.order)Wm.has(n)||qm(t,Um.get(n)??n,r,Ym(n));let n=e=>t.context.findLast(([t])=>t===e)?.[1],r=e=>t.context.findLast(([t])=>t===e)?.[2]??`-`+e;if(t.after=Jm(n(`A`)??n(`C`),n(`A`)===void 0?r(`C`):r(`A`)),t.before=Jm(n(`B`)??n(`C`),n(`B`)===void 0?r(`C`):r(`B`)),t.unrestricted>=2&&(t.hidden=!0),t.unrestricted>=3)throw Gm(`-uuu`,`searching binary files is not supported`);return t}function qm(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 Gm(Ym(t),`${Ym(t)} is not supported`)}}function Jm(e,t){if(e===void 0)return 0;if(!/^\d+$/u.test(e))throw Gm(`${t} value`,`error parsing flag ${t}: value is not a valid number`);return Number(e)}var Ym=e=>(e.length===1?`-`:`--`)+e;function Xm(e,t){return t?e.flatMap(e=>[`-e`,e]):[`-e`,e.length===1?e[0]:e.map(e=>`(?:${e})`).join(`|`)]}var Zm=[[/\\[1-9]/u,`backreference`],[/\(\?<?[=!]/u,`look-around`],[/\\[QE]/u,`\\Q…\\E literal span`]];function Qm(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 $m(e,t){if(!t)for(let t of e){for(let[e,n]of Zm)if(e.test(t))throw Gm(n,`${n} is not supported; ripgrep's regex engine rejects it too`);if(Qm(t))throw Gm(`newline in a pattern`,`a newline in a pattern is not supported; ripgrep rejects one outside multiline mode`)}}var W=class extends Error{constructor(e,t=null,n=null,r=`syntax error`){super(e),this.line=t,this.gap=n,this.kind=r}},eh=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`]),th={__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]},nh=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)`]]),rh=new Set([...Object.keys(th),...nh.keys()]),ih=5e6,ah=100,oh=1e6,sh=`this terminal runs no processes`;function ch(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 lh={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},uh=`^$.[]|()*+?{}\\/"`,dh=1e3,fh=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),ph=e=>e!==void 0&&e>=`0`&&e<=`7`,mh=class{constructor(e,t,n,r){this.src=e,this.i=0,this.warn=t,this.tables=n,this.ignoreCase=r,this.groups=0}fail(e){throw new W(`invalid regex /${this.src}/: ${e}`)}peek(){return this.src[this.i]}literal(){let e=this.src.codePointAt(this.i);return this.i+=Lr(e),this.charNode(e)}charNode(e){let t=this.ignoreCase?this.tables.fold(e):[e];return t.length===1?{type:`char`,code:e}:{type:`set`,negate:!1,items:t.map(e=>[e,e])}}parse(){return this.alternation(0)}alternation(e){let t=[this.concatenation(e)];for(;this.peek()===`|`;)this.i++,t.push(this.concatenation(e));return t.length===1?t[0]:{type:`alt`,nodes:t}}concatenation(e){let t=[];for(;!this.endsConcatenation(e);)t.push(this.quantified(this.atom(t.length===0,e)));return t.length===1?t[0]:{type:`cat`,nodes:t}}endsConcatenation(e){let t=this.peek();return t===void 0||t===`|`||t===`)`&&e>0}quantified(e){let t=e;for(;;){let e=this.peek();if(e===`*`){this.i++,t={type:`rep`,node:t,min:0,max:null};continue}if(e===`+`){this.i++,t={type:`rep`,node:t,min:1,max:null};continue}if(e===`?`){this.i++,t={type:`rep`,node:t,min:0,max:1};continue}if(e===`{`){let e=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!e&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail(`invalid content of {}`),!e||e[1]===``&&e[2]===void 0)return t;let n=e[1]===``?0:Number(e[1]),r=e[2]===void 0?n:e[3]===``?null:Number(e[3]);if(r!==null&&r<n&&this.fail(`invalid interval {${n},${r}}`),n>dh||r!==null&&r>dh)throw new W(`interval count above ${dh} is not supported`,null,`regex interval limit`);this.i+=e[0].length,t={type:`rep`,node:t,min:n,max:r};continue}return t}}atom(e,t){let n=this.peek();if(n===`(`){this.i++;let e=++this.groups,n=this.alternation(t+1);return this.peek()!==`)`&&this.fail("missing `)`"),this.i++,{type:`group`,index:e,node:n}}return n===`[`?this.bracket():n===`\\`?this.escape():(this.i++,n===`.`?{type:`any`}:n===`^`||n===`$`?{type:`assert`,kind:n}:((n===`*`||n===`+`||n===`?`)&&!e&&this.fail(`unexpected \`${n}\``),this.i--,this.literal()))}escape(){this.i++;let e=this.peek();return e===void 0&&this.fail(`trailing backslash`),this.i++,e===`y`?{type:`assert`,kind:`y`}:e===`<`||e===`>`||e===`B`?{type:`assert`,kind:e}:e==="`"?{type:`assert`,kind:`^`}:e===`'`?{type:`assert`,kind:`$`}:e===`s`||e===`S`?{type:`set`,negate:e===`S`,items:this.tables.ranges(`space`)}:e===`w`||e===`W`?{type:`set`,negate:e===`W`,items:this.tables.ranges(`word`)}:(e===`b`&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(e,!0)))}escapedCode(e,t){if(e in lh)return lh[e];if(ph(e)){let t=e;for(;t.length<3&&ph(this.peek());)t+=this.src[this.i++];return gh(t,8)}if(e===`x`&&fh(this.peek())){let e=``;for(;e.length<2&&fh(this.peek());)e+=this.src[this.i++];return gh(e,16)}let n=this.src.codePointAt(this.i-1);return!uh.includes(e)&&t&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(n)}' is not a known regexp operator`),this.i+=Lr(n)-1,n}bracket(){this.i++;let e=!1;this.peek()===`^`&&(e=!0,this.i++);let t=[],n=!0;for(;;){this.i>=this.src.length&&this.fail(`unterminated bracket expression`);let e=this.peek();if(e===`]`&&!n){this.i++;break}if(n=!1,e===`[`&&this.src[this.i+1]===`:`){let e=this.src.indexOf(`:]`,this.i+2);if(e!==-1){let n=this.src.slice(this.i+2,e),r=this.tables.ranges(this.ignoreCase?sn(n):n);r===void 0&&this.fail(`invalid character class \`[:${n}:]\``),t.push(...r),this.i=e+2;continue}}let r=this.bracketChar();if(this.peek()===`-`&&this.src[this.i+1]!==`]`&&this.src[this.i+1]!==void 0){this.i++;let e=this.bracketChar(),n=this.ignoreCase?this.tables.foldRange(r,e):e<r?null:[[r,e]];n===null&&this.fail(`invalid range end`),t.push(...n)}else this.ignoreCase?t.push(...this.tables.fold(r).map(e=>[e,e])):t.push([r,r])}return{type:`set`,negate:e,items:t}}bracketChar(){let e=this.peek();if(e===`[`&&(this.src[this.i+1]===`.`||this.src[this.i+1]===`=`)){let e=this.src.indexOf(this.src[this.i+1]+`]`,this.i+2);if(e!==-1&&e>this.i+2){Array.from(this.src.slice(this.i+2,e)).length!==1&&this.fail(`invalid collation character`);let t=this.src.codePointAt(this.i+2);return this.i=e+2,t}}if(e===`\\`){this.i++,this.peek()===void 0&&this.fail(`trailing backslash`);let e=this.src[this.i++];return this.escapedCode(e,!1)}let t=this.src.codePointAt(this.i);return this.i+=Lr(t),t}};function hh(e,t=null,n=vn(M),r=!1){let i=new mh(e,t,n,r);return{ast:i.parse(),groups:i.groups}}function gh(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new W(`non-ASCII regex byte escapes are not supported`,null,`regex byte escapes`);return n}var _h=e=>`\\u{${e.toString(16)}}`,vh=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):_h(e);function yh(e,t){if(e===`^`||e===`$`)return e;let n=t.assertions();return e===`y`?n.boundary:e===`B`?n.inside:n[e]}function bh(e,t=vn(M)){let n=e=>bh(e,t);switch(e.type){case`char`:return vh(e.code);case`any`:return`.`;case`set`:return`[${e.negate?`^`:``}${e.items.map(([e,t])=>e===t?vh(e):`${vh(e)}-${vh(t)}`).join(``)}]`;case`assert`:return yh(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 t=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${t}*`:e.min===1?`${t}+`:`${t}{${e.min},}`:e.min===0&&e.max===1?`${t}?`:`${t}{${e.min},${e.max}}`}default:throw new W(`internal: unknown regex node ${e.type}`)}}var xh=5e4;function Sh(e,t){let n=t=>{for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1};return t?e=>!n(e):n}function Ch(e,t=vn(M)){let n=[],r=e=>{if(n.length>=xh)throw new W(`regex too large`,null,`regex state limit`);return n.push(e),n.length-1};function i(e,t){switch(e.type){case`char`:return r({op:`char`,codes:[e.code],next:t});case`any`:return r({op:`any`,next:t});case`set`:return r({op:`set`,test:Sh(e.items,e.negate),next:t});case`assert`:return r({op:`assert`,kind:e.kind,next:t});case`group`:return i(e.node,t);case`cat`:{let n=t;for(let t=e.nodes.length-1;t>=0;t--)n=i(e.nodes[t],n);return n}case`alt`:{let n=e.nodes.map(e=>i(e,t)),a=n.at(-1);for(let e=n.length-2;e>=0;e--)a=r({op:`split`,x:n[e],y:a});return a}case`rep`:return a(e,t);default:throw new W(`internal: unknown regex node ${e.type}`)}}function a(e,t){let a=t;if(e.max===null){let o=r({op:`split`,x:-1,y:t});n[o].x=i(e.node,o),a=o}else for(let n=e.max-e.min;n>0;n--)a=r({op:`split`,x:i(e.node,a),y:t});for(let t=0;t<e.min;t++)a=i(e.node,a);return a}let o=i(e,r({op:`match`})),s=``,c=o;for(;n[c].op===`char`&&n[c].codes.length===1&&n[c].codes[0]<128;)s+=String.fromCodePoint(n[c].codes[0]),c=n[c].next;return(n[c].op!==`match`||s===``)&&(s=null),{states:n,start:o,literal:s,isWord:e=>t.has(`word`,e),gen:new Int32Array(n.length).fill(-1),stamp:0}}function wh(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 Th(e,t,n,r){if(e===`^`)return n===0;if(e===`$`)return n===t.length;let i=r(wh(t,n)),a=n<t.length&&r(t.codePointAt(n));return e===`y`?i!==a:e===`B`?i===a:e===`<`?!i&&a:i&&!a}function Eh(e,t){return e.op===`char`?e.codes.includes(t):e.op===`any`||e.test(t)}function Dh(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let r=t.indexOf(e.literal,n);return r<0?null:{start:r,end:r+e.literal.length}}let{states:r,gen:i}=e,a=t.length,o=[],s=(n,a,s,c,l)=>{for(o.push(a);o.length>0;){let a=o.pop();if(i[a]===l)continue;i[a]=l;let u=r[a];u.op===`split`?o.push(u.y,u.x):u.op===`assert`?Th(u.kind,t,c,e.isWord)&&o.push(u.next):n.push(a,s)}},c=[],l=[],u=null,d=n,f=++e.stamp;for(;;){u===null&&s(c,e.start,d,d,f);let n=d<a?t.codePointAt(d):-1,i=Lr(n);if(c.length===0){if(u!==null||d>=a)break;d+=i,f=++e.stamp;continue}let o=++e.stamp;for(let e=0;e<c.length;e+=2){let t=c[e],a=c[e+1];if(u!==null&&a>u.start)continue;let f=r[t];if(f.op===`match`){(u===null||a<u.start||a===u.start&&d>u.end)&&(u={start:a,end:d});continue}n!==-1&&Eh(f,n)&&s(l,f.next,a,d+i,o)}if(c.length=0,[c,l]=[l,c],f=o,d>=a)break;d+=i}return u}var Oh=new Map,kh=class{constructor(e,t,n,r=vn(M)){let{ast:i,groups:a}=hh(e,n,r,t);this.src=e,this.ignoreCase=t,this.tables=r,this.groupCount=a,this.source=bh(i,r),this.flags=`su`;try{this.js=new RegExp(zr(this.source),this.flags)}catch(t){throw new W(`cannot compile regex /${e}/: ${t.message}`,null,`regex engine limit`)}this.ast=i,this.nfa=null,this.capture=null,this.captureShape=Ah(i)}test(e){return this.checkCase(e),this.js.test(e)}checkCase(e){if(this.ignoreCase&&ln.test(e+this.src))throw new W(`case-insensitive matching over Cyrillic Extended-C letters is not supported`,null,`locale-sensitive regex`)}search(e,t=0){return this.checkCase(e),this.nfa===null&&(this.nfa=Ch(this.ast,this.tables)),Dh(this.nfa,e,t)}groups(e,t,n){if(this.captureShape.unsafe)throw new W(`capture extraction across repeated or alternative groups is not supported`,null,`regex capture semantics`);let r=this.capture??=new RegExp(this.source,this.flags+`dy`);r.lastIndex=t;let i=r.exec(e);if(!i||i.index!==t||t+i[0].length!==n){let r=Array.from(e.slice(n)).length,a=RegExp(`(?:${this.source})(?=.{${r}}(?![^]))`,this.flags+`dy`);a.lastIndex=t,i=a.exec(e)}if(!i)throw new W(`capture extraction for this match is not supported`,null,`regex capture semantics`);return i.indices.map((e,t)=>e===void 0?void 0:{text:i[t],start:e[0],end:e[1]})}};function Ah(e){let t=(e.nodes??(e.node?[e.node]:[])).map(Ah),n=t.reduce((e,t)=>e+t.groups,+(e.type===`group`));return{groups:n,nullable:e.type===`assert`||(e.type===`group`||e.type===`cat`)&&t.every(e=>e.nullable)||e.type===`alt`&&t.some(e=>e.nullable)||e.type===`rep`&&(e.min===0||t[0].nullable),unsafe:e.type===`rep`&&(e.max===null||e.max>1)&&(n>1||n>0&&t[0].nullable)||e.type===`alt`&&n>0||t.some(e=>e.unsafe)}}function jh(e,t=!1,n=null,r=vn(M)){let i=(t?`i`:`c`)+r.name+`\0`+e,a=Oh.get(i);if(a)return a;Oh.size>=500&&Oh.clear();let o=new kh(e,t,n,r);return Oh.set(i,o),o}function Mh(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+Rr(e,r.end)}}function Nh(e,t){let n=[],r=0;for(;;){let i=Mh(e,t,r);if(!i)break;n.push(e.slice(r,i.start)),r=i.end}return n.push(e.slice(r)),n}function Ph(e,t,n,r){let i=r!==`first`,a=e.length,o=``,s=0,c=-1,l=0;for(;s<=a;){let u=t.search(e,s);if(!u)break;let d=u.start===u.end;if(d&&u.start===c&&r!==`nth`){if(u.start>=a)break;let t=Rr(e,u.start);o+=e.slice(s,u.start+t),s=u.start+t;continue}l++;let f=n(u.start,u.end,l);if(o+=e.slice(s,u.start)+(f===null?e.slice(u.start,u.end):f),c=u.end,d){if(u.end>=a){s=a;break}let t=Rr(e,u.end);o+=e.slice(u.end,u.end+t),s=u.end+t}else s=u.end;if(!i)break}return{out:o+e.slice(s),count:l}}function Fh(e,t){let n=`(){}+?|`,r=!1,i=0,a=!1,o=``;for(let s=0;s<e.length;s++){let c=e[s];if(a){if(c===`[`&&(e[s+1]===`.`||e[s+1]===`=`))throw new T(`feature`,`regex collating or equivalence class`,`grep: collating and equivalence classes are not supported`);if(c===`[`){let n=Wt(e,s,{classes:t});if(n){o+=n.body,s=n.end-1;continue}}o+=c,c===`]`&&(a=!1,r=!0);continue}if(c===`[`){o+=c,a=!0,e[s+1]===`^`&&(o+=`^`,s++),e[s+1]===`]`&&(o+=`\\]`,s++);continue}if(c===`\\`){let t=e[++s];if(t===void 0)return{error:`trailing backslash (\\)`};if(n.includes(t)){if((t===`+`||t===`?`)&&!r){o+=`\\`+t,r=!0;continue}if(t===`(`&&i++,t===`)`&&i--===0)return{error:`Unmatched ) or \\)`};(t===`(`||t===`|`)&&(r=!1),(t===`)`||t===`}`)&&(r=!0),o+=t}else o+="^$\\.*[]/bBsSwW<>`'123456789".includes(t)?`\\`+t:t,r=!"bB<>`'".includes(t);continue}if(c===`*`){o+=r?`*`:`\\*`,r=!0;continue}if(c===`^`){r=!Ih(e,s),o+=r?`\\^`:`^`;continue}if(c===`$`){r=s!==e.length-1&&(e[s+1]!==`\\`||e[s+2]!==`)`&&e[s+2]!==`|`),o+=r?`\\$`:`$`;continue}o+=n.includes(c)?`\\`+c:c,r=!0}return i>0?{error:`Unmatched ( or \\(`}:{source:o}}function Ih(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 Lh(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,i=!1,a=0,o=!1,s=[],c=new Set,l=!1;for(let u=0;u<e.length;u++){let d=e[u];if(d===`\\`){let n=e[++u];if(!i&&/[1-9]/u.test(n??``)){let e=Number(n);if(!t.has(e))throw Error(`Invalid back reference`);(!c.has(e)||r.has(e))&&(o=!0)}s=[];continue}if(i){d===`]`&&(i=!1);continue}if(d===`[`){i=!0,s=[];continue}if(d===`(`)n.push({id:++a,entry:new Set(c),branches:[],start:u}),s=[];else if(d===`|`){let e=n.at(-1);e&&e.branches.push(c),c=new Set(e?.entry),s=[]}else if(d===`)`){let r=n.pop();if(!r)continue;c=r.branches.reduce((e,t)=>e.intersection(t),c),c.add(r.id),t.add(r.id),s=[...c.difference(r.entry)],l=Rh(e.slice(r.start,u+1))}else if(d===`*`||d===`?`||d===`+`){if(d!==`?`&&l)for(let e of s)r.add(e);if(d!==`+`)for(let e of s)c.delete(e)}else if(d===`{`){let t=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(u));if(t){Number(t[1])===0&&(c=c.difference(new Set(s)));let e=t[2]===void 0?Number(t[1]):t[2]===``?1/0:Number(t[2]);l&&e>1&&s.forEach(e=>r.add(e)),u+=t[0].length-1}else s=[]}else s=[]}return o}function Rh(e){try{return RegExp(`^(?:${e})$`,`su`).test(``)}catch{return!0}}var zh=`bBsSwW`;function Bh(e,t){let n=``;for(let r=0;r<e.length;){let i=e[r];if(i===`[`){let i=Hh(e,r,t);n+=i.text,r=i.end;continue}let a=i===`\\`,o=e.codePointAt(r+ +!!a),s=+!!a+Lr(o),c=a&&zh.includes(e[r+1])?null:t.fold(o);n+=c===null||c.length===1?e.slice(r,r+s):`[${String.fromCodePoint(...c)}]`,r+=s}return n}function Vh(e,t){let n=``;for(let r of e){let e=t.fold(r.codePointAt(0));n+=e.length===1?RegExp.escape(r):`[${String.fromCodePoint(...e)}]`}return n}function Hh(e,t,n){let r=t+1,i=`[`;e[r]===`^`&&(i+=`^`,r++);let a=!0;for(;;){let t=e[r];if(t===`]`&&!a)return{text:i+`]`,end:r+1};if(a=!1,t===`[`&&`:.=`.includes(e[r+1])){let t=e[r+1],n=e.indexOf(t+`]`,r+2);i+=t===`:`?`[:${sn(e.slice(r+2,n))}:]`:e.slice(r,n+2),r=n+2;continue}let o=e.codePointAt(r),s=r+Lr(o);if(e[s]===`-`&&e[s+1]!==void 0&&e[s+1]!==`]`){let t=e.codePointAt(s+1),a=s+1+Lr(t);i+=Uh(o,t,e.slice(r,a),n),r=a;continue}i+=String.fromCodePoint(...n.fold(o)),r=s}}function Uh(e,t,n,r){let i=r.foldRange(e,t);if(i===null)throw Error(`Invalid range end`);return i.length===1&&i[0][0]===e&&i[0][1]===t?n:i.map(([e,t])=>e===t?String.fromCodePoint(e):`${String.fromCodePoint(e)}-${String.fromCodePoint(t)}`).join(``)}function Wh({pattern:e,tables:t},n){return[...e].map(e=>(n?t.fold(e.codePointAt(0)):[e.codePointAt(0)]).map(e=>E(String.fromCodePoint(e))))}function Gh(e,t){return t.every(t=>t.literal?(t.literalMask??=Wh(t.literal,t.folded),!qh(e,t.literalMask)):!1)}function Kh(e,t,n,r=M){let i=vn(r);return t.every(t=>(n||!Yh.test(t))&&t.isWellFormed()&&!qh(e,Wh({pattern:t,tables:i},!1)))}function qh(e,t){if(t.length===0)return!0;for(let n of new Set(t[0].map(e=>e[0])))for(let r=e.indexOf(n);r>=0&&r+t.length<=e.length;r=e.indexOf(n,r+1))if(Jh(e,r,t,0))return!0;return!1}function Jh(e,t,n,r){return r===n.length||n[r].some(i=>i.every((n,r)=>e[t+r]===n)&&Jh(e,t+i.length,n,r+1))}var Yh=/[\\.^$*+?()[\]{}|]/u,Xh=new Set(`\\.[*^$`),Zh=new Set(`\\.[*^$+?(){}|`);function Qh(e,t){if(t.has(`F`))return e;if(t.has(`P`))return Yh.test(e)?null:e;let n=t.has(`E`)?Zh:Xh,r=``;for(let t=0;t<e.length;t++){let i=e[t]===`\\`,a=i?e[++t]:e[t];if(n.has(a)!==i)return null;r+=a}return r}var $h=new Map;function eg(e){if($h.has(e))return $h.get(e);let t=e.assertions(),n=``;for(let t=128;t<=255;t++)e.has(`word`,t)&&(n+=`\\u${(56320+t).toString(16)}`);let r=mn(e.body(`word`)+n),i={"<":r[`<`],">":r[`>`],b:r.boundary,B:r.inside,W:tg(t.nonWord),S:tg(t.nonSpace)};return $h.set(e,i),i}var tg=e=>`(?:(?![${rt}])${e})`;function ng(e){let t=Ch(e.ast,e.tables),n=t.states.map(e=>e.op===`any`?{op:`set`,test:e=>!at(e),next:e.next}:e.op===`set`?{...e,test:t=>!at(t)&&e.test(t)}:e),r={...t,states:n,isWord:t=>e.tables.has(`word`,at(t)?t-56320:t)};return{search:(e,t)=>Dh(r,e,t)}}var rg=[0,0,0,0,1114112,2097152,67108864],ig=(e,t)=>at(e.codePointAt(t))?e.codePointAt(t)-56320:-1;function ag(e,t){let n=ig(e,t),r=n===237?3:n>=240&&n<=247?4:n>=248&&n<=251?5:n===252||n===253?6:0,i=n&127>>r;for(let n=1;n<r;n++){let r=ig(e,t+n);if(r<128||r>191)return 0;i=i<<6|r&63}return r===3?i>=55296&&i<=57343?3:0:r&&i>=rg[r]?r:0}function og(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>65535&&t++,!at(n))continue;let r=ag(e,t);if(r===0||r===3)return!0;t+=r-1}return!1}var sg=/[\uDCED\uDCF0-\uDCFD][\uDC80-\uDCBF]{2,5}/gu;function cg(e){let t={long:!1,surrogate:!1};for(let[n]of e.matchAll(sg)){let e=ag(n,0);if(e===3?t.surrogate=!0:e&&(t.long=!0),t.long&&t.surrogate)break}return t}function lg(e,t){let n={negated:!1,dot:!1,regex:t,wordEdge:!1};for(let t=0;t<e.length;t++){let r=e[t];if(r===`\\`){let r=e[++t]??``;`<>bB`.includes(r)&&(n.wordEdge=!0),`<>bBwsWS`.includes(r)&&(n.regex=!0),`WS`.includes(r)&&(n.negated=!0)}else if(r===`.`)n.dot=!0;else if(r===`[`){let r=Ut(e,t),i=e.slice(t+1,r);i.startsWith(`^`)&&(n.negated=!0),/\[:|.-./u.test(i.replace(/^\^?\]?/u,``))&&(n.regex=!0),t=r}}return n}function ug(e,t,n){return t.long||t.surrogate?e.wordEdge||(e.dot||e.negated)&&(e.regex||n)?!0:t.long&&e.negated:!1}var dg=new Map;function fg(e){return dg.has(e)||dg.set(e,RegExp(`[^\\x00-\\x7f${rt}${e.body(`word`)}]`,`u`)),dg.get(e)}function pg(e){throw new T(`feature`,`PCRE `+e,`PCRE ${e} is not supported`)}function mg(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 i=e[r];if(i===`\\`){let i=vg(e,r,t,!1);n+=i.source,r=i.end;continue}if(i===`[`){let i=_g(e,r,t);n+=i.source,r=i.end;continue}if(i===`(`){let i=hg(e,r,t);n+=i.source,r=i.end;continue}if(i===`)`){let e=t.stack.pop();e?.capture&&t.closed.add(e.capture),e?.behind&&t.behind--}if(`*+?`.includes(i)&&(t.behind&&pg(`variable-length lookbehind`),e[r+1]===`+`&&pg(`possessive repetition`),i!==`+`&&(t.risky=!0)),i===`|`&&(t.risky=!0),i===`{`){let i=gg(e,r,t);n+=i.source,r=i.end;continue}n+=i===`]`||i===`}`?`\\`+i:i,r++}return t.references&&t.risky&&pg(`conditional backreference`),n}function hg(e,t,n){let r=!1,i=null,a=`(`;if(e[t+1]===`*`&&pg(`control verb`),e[t+1]===`?`){let o=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(o||pg(`group`),a=o[0],r=a===`(?<=`||a===`(?<!`,!o[1]&&a!==`(?:`&&(n.risky=!0),o[1]){if(i=++n.captures,n.names.has(o[1]))throw Error(`duplicate PCRE capture name`);n.names.set(o[1],i)}}else i=++n.captures;return r&&n.behind++,n.stack.push({capture:i,behind:r}),{source:a,end:t+a.length}}function gg(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&pg(`repetition`),{source:`\\{`,end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&pg(`variable-length lookbehind`),Number(r[1])>65535||Number(r[2])>65535)throw Error(`PCRE repetition count exceeds 65535`);return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]===`+`&&pg(`possessive repetition`),{source:r[0],end:t+r[0].length}}function _g(e,t,n){let r=t+1,i=`[`;for(e[r]===`^`&&(i+=`^`,r++),e[r]===`]`&&(i+=`\\]`,r++);r<e.length&&e[r]!==`]`;)if(e[r]===`[`&&`:.=`.includes(e[r+1]??``)&&pg(`character class`),e[r]===`\\`){let t=vg(e,r,n,!0);i+=t.source,r=t.end}else i+=e[r]===`[`?`\\[`:e[r],r++;return{source:i+(e[r]===`]`?`]`:``),end:r+1}}function vg(e,t,n,r){let i=e[t+1];if(i===void 0)throw Error(`trailing backslash`);if(i===`Q`){let n=e.indexOf(`\\E`,t+2);return{source:RegExp.escape(e.slice(t+2,n<0?void 0:n)),end:n<0?e.length:n+2}}if(i===`E`)return{source:``,end:t+2};if(i===`x`||i===`0`||r&&/[1-7]/u.test(i))return yg(e,t);if(i===`a`||i===`e`)return{source:i===`a`?`\\u0007`:`\\u001B`,end:t+2};if(`AzZ`.includes(i)&&!r)return{source:i===`A`?`^`:`$`,end:t+2};if(/[1-9]/u.test(i)&&!r)return(/\d/u.test(e[t+2]??``)||!n.closed.has(Number(i)))&&pg(`forward or ambiguous backreference`),n.references=!0,{source:`\\`+i,end:t+2};if(i===`k`&&!r){let r=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return(!r||!n.closed.has(n.names.get(r[1])))&&pg(`named backreference`),n.references=!0,{source:r[0],end:t+r[0].length}}if(`dDsSwWfnrtbB`.includes(i))return{source:`\\`+i,end:t+2};/[A-Za-z0-9]/u.test(i)&&pg(`escape \\`+i);let a=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(a),end:t+1+a.length}}function yg(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 Error(`invalid PCRE character escape`);let i=n?16:8,a=parseInt(r[1]??r[2],i);return Ir(a)||pg(`character escape`),{source:`\\u{${a.toString(16)}}`,end:t+r[0].length}}function bg(e,t){let n=``,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`){let t=e[++i]??``;n+=r?a+t:xg(t);continue}if(r&&a===`[`){if(e[i+1]===`.`||e[i+1]===`=`)throw new T(`feature`,`regex collating or equivalence class`,`grep: collating and equivalence classes are not supported`);let r=Wt(e,i,{classes:t});if(r){n+=r.body,i=r.end-1;continue}}if(a===`[`&&!r){n+=`[`,r=!0,e[i+1]===`^`&&(n+=`^`,i++),e[i+1]===`]`&&(n+=`\\]`,i++);continue}a===`]`&&(r=!1),n+=a}return n}function xg(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?`\\`+e:RegExp.escape(e)}function Sg(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 Cg(e,t=`js`,n=vn(M)){let r=t===`extent`,i=t===`marked`,a=r?{b:`\\y`}:i?{...wg(n),...eg(n)}:wg(n),o=``,s=!1;for(let t=0;t<e.length;t++){let n=e[t];if(n===`\\`){let i=e[++t];o+=!s&&Object.hasOwn(a,i)?a[i]:n+i,!r&&!s&&/[1-9]/u.test(i)&&/\d/u.test(e[t+1]??``)&&(o+=`(?:)`)}else if(i&&n===`[`){let n=Lg(e,t);o+=tg(e.slice(t,n+1)),t=n}else i&&n===`.`?o+=`[^${rt}]`:(n===`[`&&(s=!0),n===`]`&&(s=!1),o+=n)}return o}function wg(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 Tg=e=>e.plain??=new RegExp(e.source,e.flags);function Eg(e){return e.markedSource===void 0?Tg(e):(e.marked??=new RegExp(zr(Cg(e.markedSource,`marked`,e.tables)),e.flags),e.marked)}var Dg=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,Og=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function kg(e,t,n){let r=(n?Dg:Og).exec(e.slice(t));if(!r&&!n)throw Error(`invalid repetition count`);r&&Ht(Number(r[1]),r[2]===void 0||r[2]===``?void 0:Number(r[2]))}var Ag={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function jg(e){if(Ag[e])return Ag[e];let t=Dg.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===``?1/0:Number(t[2])}}var Mg=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function Ng(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=Mg(t.max,e.max);return r!==1/0&&r>Vt?null:{min:Mg(t.min,e.min),max:r}}function Pg(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 Fg=e=>!e.startsWith(`(`)&&!/^\\[1-9]/u.test(e);function Ig(e,t){if(t.length===1)return e+Pg(t[0].bounds);let n=t[0].bounds,r=null;for(let i=1;i<t.length;i++){let{bounds:a,text:o}=t[i],s=r===null?Ng(n,a):null;if(s){n=s;continue}if(!(r===null&&n.min===n.max&&Fg(e))&&a.max>1)throw Error(`stacked quantifier needs ambiguous nesting`);r=`(?:${r??e+Pg(n)})${o}`}return r??e+Pg(n)}function Lg(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 Rg(e){let t=``,n=-1,r=-1,i=[],a=()=>{i.length>0&&(t=t.slice(0,n)+Ig(t.slice(n,r),i)),i=[]},o=e=>{a(),n=t.length,r=-1,t+=e},s=[];for(let c=0;c<e.length;c++){let l=e[c];if(l===`\\`){o(l+(e[++c]??``));continue}if(l===`[`){let t=Lg(e,c);o(e.slice(c,t+1)),c=t;continue}if(l===`(`){a(),s.push(t.length),n=-1,t+=l;continue}if(l===`)`){a(),t+=l,n=s.pop()??-1,r=-1;continue}if(l===`|`||l===`^`||l===`$`){a(),t+=l,n=-1;continue}let u=l===`{`?Dg.exec(e.slice(c)):null;if(l===`*`||l===`+`||l===`?`||u){let e=u?u[0]:l;if(c+=e.length-1,n<0){t+=e;continue}i.length===0&&(r=t.length),i.push({bounds:jg(e),text:e});continue}o(l)}return a(),t}function zg(e,t,n=!1){let r=-1;for(let i=0;i<e.length;i++){let a=i<=r,o=e[i];if(o===`\\`){let n=e[++i];if(n===void 0)throw Error(`trailing backslash`);if(a||n&&`dDxXuUpPkKcC`.includes(n))throw new T(`feature`,`regex escape`,`grep: this regex escape is not supported with GNU semantics`);!t&&n===`{`&&kg(e,i-1,!1)}else if(o===`[`&&!a)r=Ut(e,i,n);else{if(a)continue;if(t&&o===`{`)kg(e,i,!0);else if(t&&o===`(`&&e[i+1]===`?`)throw new T(`feature`,`regex extension`,`grep: ECMAScript group extensions are not supported in ERE`)}}}function Bg(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`&&/[1-9]/u.test(e[++t]??``))return!0;return!1}function Vg(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 Hg(e,t,n=M){let r=vn(n),i=[],a=t.has(`x`),o=t.has(`w`)&&!a;if(t.has(`P`)&&new Set(e).size>1)return{error:x(`grep: -P only supports a single pattern`,2)};for(let n of e){let e=!t.has(`F`)&&!t.has(`P`);e&&zg(n,t.has(`E`),r.multibyte);let s=e&&Bg(n),c=t.has(`i`)&&!t.has(`P`)&&!s,l=t.has(`i`)&&!c?`isu`:`su`,u;if(t.has(`F`))u=c?Vh(n,r):RegExp.escape(n);else if(t.has(`P`))u=mg(n);else if(t.has(`E`))u=bg(c?Bh(n,r):n,r);else{let e=Fh(c?Bh(n,r):n,r);if(e.error)return{error:x(`grep: ${e.error}`,2)};u=e.source}let d=u;if(e&&Lh(d))return{error:C(`feature`,`grep`,`conditional backreference`,`grep: backreferences with conditional or repeated-empty captures are not supported`,2)};o&&(u=`(?<!${r.assertions().word})(?:${u})(?!${r.assertions().word})`),a&&(u=`^(?:${u})$`);try{let f=e?Rg(u):u,p=new RegExp(zr(e?Cg(f,`js`,r):u),l);e&&Object.assign(p,{markedSource:f,tables:r,shape:lg(n,s)}),p.pcre=t.has(`P`),p.localeSensitive=p.pcre?t.has(`i`)||o||Sg(d)||/\\[dD]/u.test(d):t.has(`i`)&&s,p.folded=c,p.extendedC=c&&ln.test(n),p.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(n),p.wellFormed=n.isWellFormed(),p.emptyWord=o&&!p.pcre&&new RegExp(e?Cg(Rg(d),`js`,r):d,l).test(``),p.anyCharacter=Vg(d);let m=Qh(n,t);if(m?.isWellFormed()&&(c||!t.has(`i`))&&(p.literal={pattern:m,tables:r}),t.has(`o`)&&e&&!a){if(o||/\\[1-9]|\(\?/u.test(u))return{error:C(`feature`,`grep`,`-o regex extent`,`grep: only-matching with backreferences, lookarounds or word constraints is not supported`,2)};try{p.extent=new kh(Cg(u,`extent`,r),!1,null,r)}catch{return{error:C(`feature`,`grep`,`-o regex extent`,`grep: POSIX match extent for this pattern is not supported`,2)}}}i.push(p)}catch(e){return!t.has(`P`)&&Ug(d,t)?{error:C(`feature`,`grep`,`GNU regex syntax`,`grep: this GNU regular expression cannot be represented by the JavaScript matcher`,2)}:{error:x(`grep: invalid pattern (${t.has(`F`)?`fixed-string /${l}`:t.has(`P`)?`PCRE subset /${l}`:t.has(`E`)?`ERE / ECMAScript /${l}`:`BRE /${l}`}): ${e.message}`,2)}}}return{res:i}}function Ug(e,t){if(!t.has(`E`)&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return hh(Cg(e,`extent`)),!0}catch(e){return!!e.gap}}function Wg(e,t,n=M,r=!1){let i=(e,t)=>C(`feature`,`grep`,e,`grep: ${t}`,2);if(e.marked){if(t.some(e=>e.pcre))return i(`binary input`,`PCRE matching over bytes that spell no text is not supported`);if(t.some(e=>!e.wellFormed))return i(`unpaired surrogate`,`a pattern holding an unpaired UTF-16 surrogate cannot be matched against bytes`)}if(t.some(e=>e.emptyWord)&&fg(vn(n)).test(e.content))return i(`empty word match`,`-w with a pattern that can match nothing, over non-ASCII text that is not word characters, is not supported`);let a=e.marked?t.filter(e=>e.shape&&(e.shape.wordEdge||e.shape.dot||e.shape.negated)):[],o=a.length?cg(e.content):null;if(a.some(e=>ug(e.shape,o,r)))return i(`binary input`,`matching this pattern beside bytes glibc reads as a character is not supported`);let s=()=>t.some(e=>e.unicodePattern)||/[\u0080-\u{10FFFF}]/u.test(e.content);if(n!==M&&t.some(e=>e.localeSensitive||e.folded||e.anyCharacter)&&s())return i(`locale`,`matching non-ASCII text in the ${n} locale is not supported`);if(t.some(e=>e.extendedC)||t.some(e=>e.folded)&&ln.test(e.content))return i(`locale-sensitive regex`,`case-insensitive matching over Cyrillic Extended-C letters is not supported`);let c=t.filter(e=>e.localeSensitive);return c.length===0||!s()?null:i(`non-ASCII regex semantics`,`${c.some(e=>e.pcre)?`PCRE matching`:`case-insensitive matching with backreferences`} on non-ASCII input is not supported`)}var Gg=/[*?[]/u,Kg=/\P{ASCII}/u,qg=/[.+*?^${}()|[\]\\/]/u;function Jg(e,t={}){try{return Yg(e,t)}catch(e){throw e instanceof T?e:new T(`feature`,`glob pattern`,`unsupported glob pattern: ${e.message}`)}}function Yg(e,t){let n=`^`,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`&&i+1<e.length){let r=e[i+1];n+=Xg(r,t.ignoreCase),i++}else if(a===`*`){for(;e[i+1]===`*`;)i++;n+=`.*`}else if(a===`?`)n+=`.`;else if(a===`[`){let a=$g(e,i,t);if(a?.voided)return/^(?!)$/u;a?(n+=a.source,i=a.end,r||=a.nonAsciiRange):n+=`\\[`}else n+=Xg(a,t.ignoreCase)}return Qg(RegExp(n+`(?![\\s\\S])`,`us`),e,t,r)}function Xg(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:qg.test(e)?`\\`+e:e}function Zg(e,t,n){let r=RegExp(`[${e}]`,`ui`),i=RegExp(`[${t}]`,`u`),a=``;for(let e=0;e<128;e++){let t=String.fromCodePoint(e);(r.test(t)||i.test(t))&&(a+=`\\x`+e.toString(16).padStart(2,`0`))}return`[${n?`^`:``}${a}]`}function Qg(e,t,n,r){let i=/[?[]/u.test(t),a=Kg.test(t);return{test(t){if(r||n.ignoreCase&&a||(i||n.ignoreCase)&&Kg.test(t))throw new T(`feature`,`non-ASCII glob matching`,`locale-dependent glob matching of non-ASCII names is not supported`);return e.test(t)}}}function $g(e,t,n){let{ignoreCase:r}=n,i=t+1,a=!1;(e[i]===`!`||e[i]===`^`)&&(a=!0,i++);let o=``,s=``,c=!1,l=!1,u=!1,d=!1,f=``,p=0,m=``,h=0;for(e[i]===`]`&&(o+=`\\]`,i++,c=!0,f=`]`);i<e.length&&e[i]!==`]`;i++){let t=e[i];if(t===`[`&&(e[i+1]===`.`||e[i+1]===`=`))throw new T(`feature`,`glob collating or equivalence class`,`glob collating symbols and equivalence classes are not supported`);if(t===`[`&&e[i+1]===`:`){let t=n.bash?e_(e,i):Wt(e,i,{unknown:`empty`});if(t){if(!n.bash&&t.body===``)throw new T(`feature`,`glob character class`,`unknown POSIX classes in command filename patterns are not supported`);l&&(d=!0),r?s+=t.body:o+=t.body,i=t.end-1,c=!1,l=!1;continue}if(n.bash)continue}if(t===`-`&&c)h=p,m=f,o+=`-`,l=!0,c=!1;else{let n=t===`\\`&&i+1<e.length?e[++i]:t;p=o.length,f=n,l&&Kg.test(m+n)&&(u=!0),l&&n.codePointAt(0)<m.codePointAt(0)?o=o.slice(0,h):o+=/[\]\\^[-]/u.test(n)?`\\${n}`:n,c=!l,l=!1}}return i>=e.length?null:d?{voided:!0,end:i}:{source:r?Zg(o,s,a):`[${a?`^`:``}${o}]`,end:i,nonAsciiRange:u}}function e_(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`:zt[r]??``,end:n+2}}function t_(e,t){return Jg(t).test(e)}function n_(e){let{value:t,mask:n}=e;if(n===null)return Gg.test(t);for(let e=0;e<t.length;e++)if(n[e]===`0`&&Gg.test(t[e]))return!0;return!1}function r_(e){let t=t=>!e.mask||e.mask[t]===`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=i_(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]===`(`&&t(n+1))return!0}}return!1}function i_(e,t,n){let{value:r}=e,i=t+1;for(/[!^]/u.test(r[i])&&n(i)&&i++,r[i]===`]`&&n(i)&&i++;i<r.length;i++)if(n(i)){if(r[i]===`\\`)i++;else{if(r[i]===`]`)return i;if(r[i]===`[`&&/[.:=]/u.test(r[i+1])&&n(i+1)){let e=r.indexOf(r[i+1]+`]`,i+2);e!==-1&&(i=e+1)}}}return t}var a_=/[*?[\]^!\\:.=-]/u;function o_(e){let{value:t,mask:n}=e;if(n===null)return t;let r=``;for(let e=0;e<t.length;e++){let i=t[e];r+=n[e]!==`0`&&a_.test(i)?`\\`+i:i}return r}function s_(e,t){let n=o_(e),r=n.match(/[^/]+|\/+/gu)??[],i=Cn(),a=new Set,o=[{path:``,marks:null}],s;try{for(let e=0;e<r.length;e++){let n=r[e];if(n.startsWith(`/`)||!Gg.test(n)){o=o.map(e=>({...e,path:e.path+l_(n)}));continue}o=u_(o,n,e===r.length-1,t,a)}let e=o.filter(e=>k(t.cwd,e.path,t.fs,{follow:!1}).path!==null);for(let t of e)for(let e of t.marks??[])i.add(e);return s=e.filter(e=>e.marks===null).map(e=>e.path).sort(j),s}finally{if(s===void 0)for(let e of a)i.add(e);i.emit(t.notes,`glob`,``,` while expanding ${JSON.stringify(n)}`),s?.length===0&&r.some(c_)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function c_(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($g(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var l_=e=>e.replace(/\\(.)/gu,`$1`);function u_(e,t,n,r,i){let a=Jg(t,{bash:!0}),o=t.startsWith(`.`)||t.startsWith(`\\.`),s=[];for(let t of e){let e=k(r.cwd,t.path||`.`,r.fs).path;if(!r.fs.isDir(e))continue;let{dirs:c,files:l,links:u}=r.fs.listDir(e),d=n?u:u.filter(t=>r.fs.isDir(k(e,t,r.fs).path));for(let r of n?[...c,...l,...d]:[...c,...d]){let n=!o&&r.startsWith(`.`);if(!n&&t.marks===null)a.test(r)&&s.push({path:t.path+r,marks:null});else if(d_(a,r)){if(!n){s.push({path:t.path+r,marks:t.marks});continue}let a=O(e,r);i.add(a),s.push({path:t.path+r,marks:[...t.marks??[],a]})}}}return s}function d_(e,t){try{return e.test(t)}catch{return!0}}var f_=(e,t)=>e.some(e=>e.test(t)),p_=()=>({stdout:``,stderr:``,exitCode:1}),m_=e=>e.failure!==void 0,h_=e=>e.name??`(standard input)`,g_=e=>e.binaryLine===void 0?e.content:e.content.replaceAll(`\0`,`
146
- `),__=(e,t)=>t.map(e.marked?Eg:Tg);function v_(e,t,n,r){if(r===0)return 0;let i=__(e,t),a=g_(e),o=0;if(r===1/0){for(let e of jn(a))f_(i,e)!==n&&o++;return o}let s=0;for(;s<a.length&&o<r;){let e=a.indexOf(`
147
- `,s);e<0&&(e=a.length),f_(i,a.slice(s,e))!==n&&o++,s=e+1}return o}function y_(){let e=[],t=(t,n)=>{let r=e.at(-1);r?.fd===t&&r.text!==void 0?r.text+=n:e.push({fd:t,text:n})};return{events:e,out(e){e&&t(1,e)},lines(t,n,r){if(!n||!it.test(t))return this.out(t);if(!r.isWellFormed())throw new T(`feature`,`unpaired surrogate`,`unpaired UTF-16 surrogates cannot be encoded as UTF-8`);e.push({fd:1,bytes:ot(t)})},err(e){e&&t(2,e)}}}function b_(e,t){let n=t=>e.filter(e=>e.fd===t&&e.text!==void 0).map(e=>e.text).join(``);return{stdout:e.some(e=>e.bytes!==void 0)?``:n(1),stderr:n(2),exitCode:+!t,events:e}}function x_(e,t,n){let r={used:!1,write:y_(),selected:!1};for(let i of e)m_(i)?r.write.err(i.failure):S_(i,t,n,r);return b_(r.write.events,r.selected)}function S_(e,t,n,r){if(e.binaryLine===0)return C_(e,t,n,r);let i=g_(e),a={input:e,opts:n,run:r,lines:jn(i),res:t,tests:__(e,t),bufbeg:0,name:n.showName??e.recursive?h_(e):null,out:[],lastout:null,pending:0,outleft:n.max??1/0,quiet:!1,heldBack:!1},o=a.lines.length,s=o>0&&!i.endsWith(`
148
- `)?o-1:o,c=T_(a,0,s);if(a.pending>0&&D_(a,s),s<o&&(a.outleft!==0||a.pending!==0)&&!a.quiet){let e=s;for(let t=0;t<n.before&&e>0&&e!==a.lastout;t++)e--;e!==a.lastout&&(a.lastout=null),a.bufbeg=e,a.outleft>0&&(c+=T_(a,s,o)),a.pending>0&&D_(a,o)}r.write.lines(Nn(a.out),e.marked,a.name??``),c>0&&(r.selected=!0),(a.heldBack||a.quiet)&&w_(e,n,r)}function C_(e,t,n,r){v_(e,t,n.invert,1)!==0&&(r.used=r.selected=!0,w_(e,n,r))}function w_(e,t,n){t.binaryFiles===`binary`&&n.write.err(`grep: ${h_(e)}: binary file matches
149
- `)}function T_(e,t,n){let{invert:r}=e.opts,i=e.input.binaryLine??1/0,a=0;for(let o=t;o<n;){let t=o;for(;t<n&&!f_(e.tests,e.lines[t]);)t++;if(t===n&&!r)break;if(!r||o<t){if(r&&o<i&&t>i){if(a+=E_(e,o,i),e.outleft===0)break;o=i}if(!e.quiet&&(r?o:t)>=i&&(e.pending>0&&D_(e,i),e.quiet=!0),a+=r?E_(e,o,t):E_(e,t,t+1),e.outleft===0||e.quiet)break}o=t+1}return a}function E_(e,t,n){let{before:r,after:i,hasContext:a,invert:o}=e.opts;!e.quiet&&e.pending>0&&D_(e,t);let s=t;if(!e.quiet){let n=e.lastout??e.bufbeg;for(let e=0;e<r;e++)s>n&&s--;for(a&&e.run.used&&s!==e.lastout&&e.out.push(`--`);s<t;s++)O_(e,s,!1)}let c;if(o)for(c=0;s<n&&c<e.outleft;c++,s++)e.quiet||O_(e,s,!0);else e.quiet||O_(e,t,!0),c=1;return e.pending=e.quiet?0:i,e.run.used=!0,e.outleft-=c,c}function D_(e,t){for(e.lastout??=e.bufbeg;e.pending>0&&e.lastout<t;e.pending--)O_(e,e.lastout,!1)}function O_(e,t,n){let r=e.lines[t];if(e.opts.only)n!==e.opts.invert&&k_(e,r,t,n);else{if(e.input.marked&&e.opts.binaryFiles!==`text`&&it.test(r)&&og(r)){e.heldBack=!0;return}e.out.push(M_(e,r,t,n))}e.lastout=t+1}function k_(e,t,n,r){let i=e.input.marked&&it.test(t),a=0;for(;a<t.length;){let o=null;for(let n=0;n<e.res.length;n++){let r=j_(e.res[n],e.tests[n],t,a,i);r&&(!o||r.start<o.start||r.start===o.start&&r.end>o.end)&&(o=r)}if(!o)break;if(o.end===o.start){a=o.end+Rr(t,o.end);continue}e.out.push(M_(e,t.slice(o.start,o.end),n,r)),a=o.end}}var A_=new WeakMap;function j_(e,t,n,r,i){if(e.extent)return(i?e.markedExtent??=ng(e.extent):e.extent).search(n,r);let a=A_.get(t);a||A_.set(t,a=new RegExp(t.source,t.flags+`g`)),a.lastIndex=r;let o=a.exec(n);if(o&&o[0]===``&&e.pcre)throw new T(`feature`,`PCRE empty match extent`,`only-matching with empty PCRE matches is not supported`);return o?{start:o.index,end:o.index+o[0].length}:null}function M_(e,t,n,r){let i=r?`:`:`-`;return(e.name===null?``:e.name+i)+(e.opts.showLine?n+1+i:``)+t}function N_(e,t,{mode:n,invert:r,showName:i,max:a=1/0}){let o=y_(),s=!1,c=n===`c`?a:Math.min(1,a);for(let a of e){if(m_(a)){o.err(a.failure);continue}let e=v_(a,t,r,c);e>0&&(s=!0),n===`c`?o.out((i??a.recursive?h_(a)+`:`+e:String(e))+`
150
- `):e>0==(n===`l`)&&o.out(h_(a)+`
151
- `)}return b_(o.events,s)}function P_(e,t,n){let r=e.order.filter(e=>[`e`,`f`,`file`].includes(e.name)),i=e.positional;if(r.length===0)return i.length?{patterns:i[0].split(`
143
+ `)}function Mm(e,{bytes:t,valid:n}){let r=et(t),i=n?``:`${e}: invalid input
144
+ `;if(r!==void 0&&n)return b(r);let a=r===void 0?{fd:1,bytes:t}:{fd:1,text:r};return{stdout:r??``,stderr:i,exitCode:+!n,events:[...t.length?[a]:[],...i?[{fd:2,text:i}]:[]]}}var Nm=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,Pm=8,Fm=Object.freeze([2,4,5,7,8]),Im=Am(`base32`,{encode:e=>n(e,{padding:!0}),decode:Rm}),Lm=/[a-z]/u;function Rm(e,n=!1){let r=e.replace(n?/[^A-Z2-7=]/gu:/\n/gu,``);try{let e=t(r,{padding:!0});if(!Lm.test(r))return{bytes:e,valid:!0}}catch(e){if(!(e instanceof SyntaxError))throw e}return zm(r)}function zm(e){let t=new Uint8Array(Math.ceil(e.length/Pm)*5),n=0,r=0,i=!0;for(;r<e.length;){if(e.length-r<Pm){i=!1;break}let a=e.slice(r,r+Pm),o=/^[A-Z2-7]*/u.exec(a)[0];if(n+=Bm(a,o,t.subarray(n)),!Fm.includes(o.length)||a.slice(o.length)!==`=`.repeat(Pm-o.length)){i=!1;break}r+=Pm}return{bytes:t.subarray(0,n),valid:i}}function Bm(e,t,n){let r=0,i=0,a=0;for(let e of t)i=i<<5|Nm.indexOf(e),r+=5,!(r<8)&&(r-=8,n[a++]=i>>r&255);return a}var Vm=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Hm=Am(`base64`,{encode:i,decode:Um});function Um(e,t=!1){let n=e.replace(t?/[^A-Za-z0-9+/=]/gu:/\n/gu,``);try{return{bytes:a(n,{padding:!0}),valid:!0}}catch(e){if(!(e instanceof SyntaxError))throw e;return Wm(n)}}function Wm(e){let t=new Uint8Array(Math.ceil(e.length/4)*3),n=/[A-Za-z0-9+/]*/uy,r=0,i=0,o=!0;for(;i<e.length;){n.lastIndex=i;let s=n.exec(e)[0].length,c=s-s%4;if(c){let n=a(e.slice(i,i+c));t.set(n,r),r+=n.length,i+=c}if(i===e.length)break;let l=s%4;if(l<2){o=!1;break}let u=Vm.indexOf(e[i]),d=Vm.indexOf(e[i+1]),f=l===3?Vm.indexOf(e[i+2]):0;t[r++]=u<<2|d>>4,l===3&&(t[r++]=d<<4|f>>2);let p=4-l;if(i+=l,e.slice(i,i+p)!==`=`.repeat(p)){o=!1;break}i+=p}return{bytes:t.subarray(0,r),valid:o}}var Gm={short:[`n`,`N`,`i`,`s`,`w`,`F`,`v`,`l`,`c`,`q`,`u`,`a`,`H`,`I`],long:[`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`],valueShort:[`A`,`B`,`C`],valueLong:[`after-context`,`before-context`,`context`],repeatable:[`e`,`regexp`]},Km=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`})),qm=new Set([`no-heading`,`no-ignore`]),Jm=(e,t)=>new T(`feature`,e,`rg: ${t}`);function Ym(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:n,value:r}of e.order)qm.has(n)||Xm(t,Km.get(n)??n,r,Qm(n));let n=e=>t.context.findLast(([t])=>t===e)?.[1],r=e=>t.context.findLast(([t])=>t===e)?.[2]??`-`+e;if(t.after=Zm(n(`A`)??n(`C`),n(`A`)===void 0?r(`C`):r(`A`)),t.before=Zm(n(`B`)??n(`C`),n(`B`)===void 0?r(`C`):r(`B`)),t.unrestricted>=2&&(t.hidden=!0),t.unrestricted>=3)throw Jm(`-uuu`,`searching binary files is not supported`);return t}function Xm(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 Jm(Qm(t),`${Qm(t)} is not supported`)}}function Zm(e,t){if(e===void 0)return 0;if(!/^\d+$/u.test(e))throw Jm(`${t} value`,`error parsing flag ${t}: value is not a valid number`);return Number(e)}var Qm=e=>(e.length===1?`-`:`--`)+e;function $m(e,t){return t?e.flatMap(e=>[`-e`,e]):[`-e`,e.length===1?e[0]:e.map(e=>`(?:${e})`).join(`|`)]}var eh=[[/\\[1-9]/u,`backreference`],[/\(\?<?[=!]/u,`look-around`],[/\\[QE]/u,`\\Q…\\E literal span`]];function th(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 nh(e,t){if(!t)for(let t of e){for(let[e,n]of eh)if(e.test(t))throw Jm(n,`${n} is not supported; ripgrep's regex engine rejects it too`);if(th(t))throw Jm(`newline in a pattern`,`a newline in a pattern is not supported; ripgrep rejects one outside multiline mode`)}}var W=class extends Error{constructor(e,t=null,n=null,r=`syntax error`){super(e),this.line=t,this.gap=n,this.kind=r}},rh=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`]),ih={__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]},ah=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)`]]),oh=new Set([...Object.keys(ih),...ah.keys()]),sh=5e6,ch=100,lh=1e6,uh=`this terminal runs no processes`;function dh(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 fh={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},ph=`^$.[]|()*+?{}\\/"`,mh=1e3,hh=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),gh=e=>e!==void 0&&e>=`0`&&e<=`7`,_h=class{constructor(e,t,n,r){this.src=e,this.i=0,this.warn=t,this.tables=n,this.ignoreCase=r,this.groups=0}fail(e){throw new W(`invalid regex /${this.src}/: ${e}`)}peek(){return this.src[this.i]}literal(){let e=this.src.codePointAt(this.i);return this.i+=zr(e),this.charNode(e)}charNode(e){let t=this.ignoreCase?this.tables.fold(e):[e];return t.length===1?{type:`char`,code:e}:{type:`set`,negate:!1,items:t.map(e=>[e,e])}}parse(){return this.alternation(0)}alternation(e){let t=[this.concatenation(e)];for(;this.peek()===`|`;)this.i++,t.push(this.concatenation(e));return t.length===1?t[0]:{type:`alt`,nodes:t}}concatenation(e){let t=[];for(;!this.endsConcatenation(e);)t.push(this.quantified(this.atom(t.length===0,e)));return t.length===1?t[0]:{type:`cat`,nodes:t}}endsConcatenation(e){let t=this.peek();return t===void 0||t===`|`||t===`)`&&e>0}quantified(e){let t=e;for(;;){let e=this.peek();if(e===`*`){this.i++,t={type:`rep`,node:t,min:0,max:null};continue}if(e===`+`){this.i++,t={type:`rep`,node:t,min:1,max:null};continue}if(e===`?`){this.i++,t={type:`rep`,node:t,min:0,max:1};continue}if(e===`{`){let e=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!e&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail(`invalid content of {}`),!e||e[1]===``&&e[2]===void 0)return t;let n=e[1]===``?0:Number(e[1]),r=e[2]===void 0?n:e[3]===``?null:Number(e[3]);if(r!==null&&r<n&&this.fail(`invalid interval {${n},${r}}`),n>mh||r!==null&&r>mh)throw new W(`interval count above ${mh} is not supported`,null,`regex interval limit`);this.i+=e[0].length,t={type:`rep`,node:t,min:n,max:r};continue}return t}}atom(e,t){let n=this.peek();if(n===`(`){this.i++;let e=++this.groups,n=this.alternation(t+1);return this.peek()!==`)`&&this.fail("missing `)`"),this.i++,{type:`group`,index:e,node:n}}return n===`[`?this.bracket():n===`\\`?this.escape():(this.i++,n===`.`?{type:`any`}:n===`^`||n===`$`?{type:`assert`,kind:n}:((n===`*`||n===`+`||n===`?`)&&!e&&this.fail(`unexpected \`${n}\``),this.i--,this.literal()))}escape(){this.i++;let e=this.peek();return e===void 0&&this.fail(`trailing backslash`),this.i++,e===`y`?{type:`assert`,kind:`y`}:e===`<`||e===`>`||e===`B`?{type:`assert`,kind:e}:e==="`"?{type:`assert`,kind:`^`}:e===`'`?{type:`assert`,kind:`$`}:e===`s`||e===`S`?{type:`set`,negate:e===`S`,items:this.tables.ranges(`space`)}:e===`w`||e===`W`?{type:`set`,negate:e===`W`,items:this.tables.ranges(`word`)}:(e===`b`&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(e,!0)))}escapedCode(e,t){if(e in fh)return fh[e];if(gh(e)){let t=e;for(;t.length<3&&gh(this.peek());)t+=this.src[this.i++];return yh(t,8)}if(e===`x`&&hh(this.peek())){let e=``;for(;e.length<2&&hh(this.peek());)e+=this.src[this.i++];return yh(e,16)}let n=this.src.codePointAt(this.i-1);return!ph.includes(e)&&t&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(n)}' is not a known regexp operator`),this.i+=zr(n)-1,n}bracket(){this.i++;let e=!1;this.peek()===`^`&&(e=!0,this.i++);let t=[],n=!0;for(;;){this.i>=this.src.length&&this.fail(`unterminated bracket expression`);let e=this.peek();if(e===`]`&&!n){this.i++;break}if(n=!1,e===`[`&&this.src[this.i+1]===`:`){let e=this.src.indexOf(`:]`,this.i+2);if(e!==-1){let n=this.src.slice(this.i+2,e),r=this.tables.ranges(this.ignoreCase?cn(n):n);r===void 0&&this.fail(`invalid character class \`[:${n}:]\``),t.push(...r),this.i=e+2;continue}}let r=this.bracketChar();if(this.peek()===`-`&&this.src[this.i+1]!==`]`&&this.src[this.i+1]!==void 0){this.i++;let e=this.bracketChar(),n=this.ignoreCase?this.tables.foldRange(r,e):e<r?null:[[r,e]];n===null&&this.fail(`invalid range end`),t.push(...n)}else this.ignoreCase?t.push(...this.tables.fold(r).map(e=>[e,e])):t.push([r,r])}return{type:`set`,negate:e,items:t}}bracketChar(){let e=this.peek();if(e===`[`&&(this.src[this.i+1]===`.`||this.src[this.i+1]===`=`)){let e=this.src.indexOf(this.src[this.i+1]+`]`,this.i+2);if(e!==-1&&e>this.i+2){Array.from(this.src.slice(this.i+2,e)).length!==1&&this.fail(`invalid collation character`);let t=this.src.codePointAt(this.i+2);return this.i=e+2,t}}if(e===`\\`){this.i++,this.peek()===void 0&&this.fail(`trailing backslash`);let e=this.src[this.i++];return this.escapedCode(e,!1)}let t=this.src.codePointAt(this.i);return this.i+=zr(t),t}};function vh(e,t=null,n=yn(M),r=!1){let i=new _h(e,t,n,r);return{ast:i.parse(),groups:i.groups}}function yh(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new W(`non-ASCII regex byte escapes are not supported`,null,`regex byte escapes`);return n}var bh=e=>`\\u{${e.toString(16)}}`,xh=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):bh(e);function Sh(e,t){if(e===`^`||e===`$`)return e;let n=t.assertions();return e===`y`?n.boundary:e===`B`?n.inside:n[e]}function Ch(e,t=yn(M)){let n=e=>Ch(e,t);switch(e.type){case`char`:return xh(e.code);case`any`:return`.`;case`set`:return`[${e.negate?`^`:``}${e.items.map(([e,t])=>e===t?xh(e):`${xh(e)}-${xh(t)}`).join(``)}]`;case`assert`:return Sh(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 t=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${t}*`:e.min===1?`${t}+`:`${t}{${e.min},}`:e.min===0&&e.max===1?`${t}?`:`${t}{${e.min},${e.max}}`}default:throw new W(`internal: unknown regex node ${e.type}`)}}var wh=5e4;function Th(e,t){let n=t=>{for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1};return t?e=>!n(e):n}function Eh(e,t=yn(M)){let n=[],r=e=>{if(n.length>=wh)throw new W(`regex too large`,null,`regex state limit`);return n.push(e),n.length-1};function i(e,t){switch(e.type){case`char`:return r({op:`char`,codes:[e.code],next:t});case`any`:return r({op:`any`,next:t});case`set`:return r({op:`set`,test:Th(e.items,e.negate),next:t});case`assert`:return r({op:`assert`,kind:e.kind,next:t});case`group`:return i(e.node,t);case`cat`:{let n=t;for(let t=e.nodes.length-1;t>=0;t--)n=i(e.nodes[t],n);return n}case`alt`:{let n=e.nodes.map(e=>i(e,t)),a=n.at(-1);for(let e=n.length-2;e>=0;e--)a=r({op:`split`,x:n[e],y:a});return a}case`rep`:return a(e,t);default:throw new W(`internal: unknown regex node ${e.type}`)}}function a(e,t){let a=t;if(e.max===null){let o=r({op:`split`,x:-1,y:t});n[o].x=i(e.node,o),a=o}else for(let n=e.max-e.min;n>0;n--)a=r({op:`split`,x:i(e.node,a),y:t});for(let t=0;t<e.min;t++)a=i(e.node,a);return a}let o=i(e,r({op:`match`})),s=``,c=o;for(;n[c].op===`char`&&n[c].codes.length===1&&n[c].codes[0]<128;)s+=String.fromCodePoint(n[c].codes[0]),c=n[c].next;return(n[c].op!==`match`||s===``)&&(s=null),{states:n,start:o,literal:s,isWord:e=>t.has(`word`,e),gen:new Int32Array(n.length).fill(-1),stamp:0}}function Dh(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 Oh(e,t,n,r){if(e===`^`)return n===0;if(e===`$`)return n===t.length;let i=r(Dh(t,n)),a=n<t.length&&r(t.codePointAt(n));return e===`y`?i!==a:e===`B`?i===a:e===`<`?!i&&a:i&&!a}function kh(e,t){return e.op===`char`?e.codes.includes(t):e.op===`any`||e.test(t)}function Ah(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let r=t.indexOf(e.literal,n);return r<0?null:{start:r,end:r+e.literal.length}}let{states:r,gen:i}=e,a=t.length,o=[],s=(n,a,s,c,l)=>{for(o.push(a);o.length>0;){let a=o.pop();if(i[a]===l)continue;i[a]=l;let u=r[a];u.op===`split`?o.push(u.y,u.x):u.op===`assert`?Oh(u.kind,t,c,e.isWord)&&o.push(u.next):n.push(a,s)}},c=[],l=[],u=null,d=n,f=++e.stamp;for(;;){u===null&&s(c,e.start,d,d,f);let n=d<a?t.codePointAt(d):-1,i=zr(n);if(c.length===0){if(u!==null||d>=a)break;d+=i,f=++e.stamp;continue}let o=++e.stamp;for(let e=0;e<c.length;e+=2){let t=c[e],a=c[e+1];if(u!==null&&a>u.start)continue;let f=r[t];if(f.op===`match`){(u===null||a<u.start||a===u.start&&d>u.end)&&(u={start:a,end:d});continue}n!==-1&&kh(f,n)&&s(l,f.next,a,d+i,o)}if(c.length=0,[c,l]=[l,c],f=o,d>=a)break;d+=i}return u}var jh=new Map,Mh=class{constructor(e,t,n,r=yn(M)){let{ast:i,groups:a}=vh(e,n,r,t);this.src=e,this.ignoreCase=t,this.tables=r,this.groupCount=a,this.source=Ch(i,r),this.flags=`su`;try{this.js=new RegExp(Vr(this.source),this.flags)}catch(t){throw new W(`cannot compile regex /${e}/: ${t.message}`,null,`regex engine limit`)}this.ast=i,this.nfa=null,this.capture=null,this.captureShape=Nh(i)}test(e){return this.checkCase(e),this.js.test(e)}checkCase(e){if(this.ignoreCase&&un.test(e+this.src))throw new W(`case-insensitive matching over Cyrillic Extended-C letters is not supported`,null,`locale-sensitive regex`)}search(e,t=0){return this.checkCase(e),this.nfa===null&&(this.nfa=Eh(this.ast,this.tables)),Ah(this.nfa,e,t)}groups(e,t,n){if(this.captureShape.unsafe)throw new W(`capture extraction across repeated or alternative groups is not supported`,null,`regex capture semantics`);let r=this.capture??=new RegExp(this.source,this.flags+`dy`);r.lastIndex=t;let i=r.exec(e);if(!i||i.index!==t||t+i[0].length!==n){let r=Array.from(e.slice(n)).length,a=RegExp(`(?:${this.source})(?=.{${r}}(?![^]))`,this.flags+`dy`);a.lastIndex=t,i=a.exec(e)}if(!i)throw new W(`capture extraction for this match is not supported`,null,`regex capture semantics`);return i.indices.map((e,t)=>e===void 0?void 0:{text:i[t],start:e[0],end:e[1]})}};function Nh(e){let t=(e.nodes??(e.node?[e.node]:[])).map(Nh),n=t.reduce((e,t)=>e+t.groups,+(e.type===`group`));return{groups:n,nullable:e.type===`assert`||(e.type===`group`||e.type===`cat`)&&t.every(e=>e.nullable)||e.type===`alt`&&t.some(e=>e.nullable)||e.type===`rep`&&(e.min===0||t[0].nullable),unsafe:e.type===`rep`&&(e.max===null||e.max>1)&&(n>1||n>0&&t[0].nullable)||e.type===`alt`&&n>0||t.some(e=>e.unsafe)}}function Ph(e,t=!1,n=null,r=yn(M)){let i=(t?`i`:`c`)+r.name+`\0`+e,a=jh.get(i);if(a)return a;jh.size>=500&&jh.clear();let o=new Mh(e,t,n,r);return jh.set(i,o),o}function Fh(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+Br(e,r.end)}}function Ih(e,t){let n=[],r=0;for(;;){let i=Fh(e,t,r);if(!i)break;n.push(e.slice(r,i.start)),r=i.end}return n.push(e.slice(r)),n}function Lh(e,t,n,r){let i=r!==`first`,a=e.length,o=``,s=0,c=-1,l=0;for(;s<=a;){let u=t.search(e,s);if(!u)break;let d=u.start===u.end;if(d&&u.start===c&&r!==`nth`){if(u.start>=a)break;let t=Br(e,u.start);o+=e.slice(s,u.start+t),s=u.start+t;continue}l++;let f=n(u.start,u.end,l);if(o+=e.slice(s,u.start)+(f===null?e.slice(u.start,u.end):f),c=u.end,d){if(u.end>=a){s=a;break}let t=Br(e,u.end);o+=e.slice(u.end,u.end+t),s=u.end+t}else s=u.end;if(!i)break}return{out:o+e.slice(s),count:l}}function Rh(e,t){let n=`(){}+?|`,r=!1,i=0,a=!1,o=``;for(let s=0;s<e.length;s++){let c=e[s];if(a){if(c===`[`&&(e[s+1]===`.`||e[s+1]===`=`))throw new T(`feature`,`regex collating or equivalence class`,`grep: collating and equivalence classes are not supported`);if(c===`[`){let n=Gt(e,s,{classes:t});if(n){o+=n.body,s=n.end-1;continue}}o+=c,c===`]`&&(a=!1,r=!0);continue}if(c===`[`){o+=c,a=!0,e[s+1]===`^`&&(o+=`^`,s++),e[s+1]===`]`&&(o+=`\\]`,s++);continue}if(c===`\\`){let t=e[++s];if(t===void 0)return{error:`trailing backslash (\\)`};if(n.includes(t)){if((t===`+`||t===`?`)&&!r){o+=`\\`+t,r=!0;continue}if(t===`(`&&i++,t===`)`&&i--===0)return{error:`Unmatched ) or \\)`};(t===`(`||t===`|`)&&(r=!1),(t===`)`||t===`}`)&&(r=!0),o+=t}else o+="^$\\.*[]/bBsSwW<>`'123456789".includes(t)?`\\`+t:t,r=!"bB<>`'".includes(t);continue}if(c===`*`){o+=r?`*`:`\\*`,r=!0;continue}if(c===`^`){r=!zh(e,s),o+=r?`\\^`:`^`;continue}if(c===`$`){r=s!==e.length-1&&(e[s+1]!==`\\`||e[s+2]!==`)`&&e[s+2]!==`|`),o+=r?`\\$`:`$`;continue}o+=n.includes(c)?`\\`+c:c,r=!0}return i>0?{error:`Unmatched ( or \\(`}:{source:o}}function zh(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 Bh(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,i=!1,a=0,o=!1,s=[],c=new Set,l=!1;for(let u=0;u<e.length;u++){let d=e[u];if(d===`\\`){let n=e[++u];if(!i&&/[1-9]/u.test(n??``)){let e=Number(n);if(!t.has(e))throw Error(`Invalid back reference`);(!c.has(e)||r.has(e))&&(o=!0)}s=[];continue}if(i){d===`]`&&(i=!1);continue}if(d===`[`){i=!0,s=[];continue}if(d===`(`)n.push({id:++a,entry:new Set(c),branches:[],start:u}),s=[];else if(d===`|`){let e=n.at(-1);e&&e.branches.push(c),c=new Set(e?.entry),s=[]}else if(d===`)`){let r=n.pop();if(!r)continue;c=r.branches.reduce((e,t)=>e.intersection(t),c),c.add(r.id),t.add(r.id),s=[...c.difference(r.entry)],l=Vh(e.slice(r.start,u+1))}else if(d===`*`||d===`?`||d===`+`){if(d!==`?`&&l)for(let e of s)r.add(e);if(d!==`+`)for(let e of s)c.delete(e)}else if(d===`{`){let t=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(u));if(t){Number(t[1])===0&&(c=c.difference(new Set(s)));let e=t[2]===void 0?Number(t[1]):t[2]===``?1/0:Number(t[2]);l&&e>1&&s.forEach(e=>r.add(e)),u+=t[0].length-1}else s=[]}else s=[]}return o}function Vh(e){try{return RegExp(`^(?:${e})$`,`su`).test(``)}catch{return!0}}var Hh=`bBsSwW`;function Uh(e,t){let n=``;for(let r=0;r<e.length;){let i=e[r];if(i===`[`){let i=Gh(e,r,t);n+=i.text,r=i.end;continue}let a=i===`\\`,o=e.codePointAt(r+ +!!a),s=+!!a+zr(o),c=a&&Hh.includes(e[r+1])?null:t.fold(o);n+=c===null||c.length===1?e.slice(r,r+s):`[${String.fromCodePoint(...c)}]`,r+=s}return n}function Wh(e,t){let n=``;for(let r of e){let e=t.fold(r.codePointAt(0));n+=e.length===1?RegExp.escape(r):`[${String.fromCodePoint(...e)}]`}return n}function Gh(e,t,n){let r=t+1,i=`[`;e[r]===`^`&&(i+=`^`,r++);let a=!0;for(;;){let t=e[r];if(t===`]`&&!a)return{text:i+`]`,end:r+1};if(a=!1,t===`[`&&`:.=`.includes(e[r+1])){let t=e[r+1],n=e.indexOf(t+`]`,r+2);i+=t===`:`?`[:${cn(e.slice(r+2,n))}:]`:e.slice(r,n+2),r=n+2;continue}let o=e.codePointAt(r),s=r+zr(o);if(e[s]===`-`&&e[s+1]!==void 0&&e[s+1]!==`]`){let t=e.codePointAt(s+1),a=s+1+zr(t);i+=Kh(o,t,e.slice(r,a),n),r=a;continue}i+=String.fromCodePoint(...n.fold(o)),r=s}}function Kh(e,t,n,r){let i=r.foldRange(e,t);if(i===null)throw Error(`Invalid range end`);return i.length===1&&i[0][0]===e&&i[0][1]===t?n:i.map(([e,t])=>e===t?String.fromCodePoint(e):`${String.fromCodePoint(e)}-${String.fromCodePoint(t)}`).join(``)}function qh({pattern:e,tables:t},n){return[...e].map(e=>(n?t.fold(e.codePointAt(0)):[e.codePointAt(0)]).map(e=>E(String.fromCodePoint(e))))}function Jh(e,t){return t.every(t=>t.literal?(t.literalMask??=qh(t.literal,t.folded),!Xh(e,t.literalMask)):!1)}function Yh(e,t,n,r=M){let i=yn(r);return t.every(t=>(n||!Qh.test(t))&&t.isWellFormed()&&!Xh(e,qh({pattern:t,tables:i},!1)))}function Xh(e,t){if(t.length===0)return!0;for(let n of new Set(t[0].map(e=>e[0])))for(let r=e.indexOf(n);r>=0&&r+t.length<=e.length;r=e.indexOf(n,r+1))if(Zh(e,r,t,0))return!0;return!1}function Zh(e,t,n,r){return r===n.length||n[r].some(i=>i.every((n,r)=>e[t+r]===n)&&Zh(e,t+i.length,n,r+1))}var Qh=/[\\.^$*+?()[\]{}|]/u,$h=new Set(`\\.[*^$`),eg=new Set(`\\.[*^$+?(){}|`);function tg(e,t){if(t.has(`F`))return e;if(t.has(`P`))return Qh.test(e)?null:e;let n=t.has(`E`)?eg:$h,r=``;for(let t=0;t<e.length;t++){let i=e[t]===`\\`,a=i?e[++t]:e[t];if(n.has(a)!==i)return null;r+=a}return r}var ng=new Map;function rg(e){if(ng.has(e))return ng.get(e);let t=e.assertions(),n=``;for(let t=128;t<=255;t++)e.has(`word`,t)&&(n+=`\\u${(56320+t).toString(16)}`);let r=hn(e.body(`word`)+n),i={"<":r[`<`],">":r[`>`],b:r.boundary,B:r.inside,W:ig(t.nonWord),S:ig(t.nonSpace)};return ng.set(e,i),i}var ig=e=>`(?:(?![${it}])${e})`;function ag(e){let t=Eh(e.ast,e.tables),n=t.states.map(e=>e.op===`any`?{op:`set`,test:e=>!ot(e),next:e.next}:e.op===`set`?{...e,test:t=>!ot(t)&&e.test(t)}:e),r={...t,states:n,isWord:t=>e.tables.has(`word`,ot(t)?t-56320:t)};return{search:(e,t)=>Ah(r,e,t)}}var og=[0,0,0,0,1114112,2097152,67108864],sg=(e,t)=>ot(e.codePointAt(t))?e.codePointAt(t)-56320:-1;function cg(e,t){let n=sg(e,t),r=n===237?3:n>=240&&n<=247?4:n>=248&&n<=251?5:n===252||n===253?6:0,i=n&127>>r;for(let n=1;n<r;n++){let r=sg(e,t+n);if(r<128||r>191)return 0;i=i<<6|r&63}return r===3?i>=55296&&i<=57343?3:0:r&&i>=og[r]?r:0}function lg(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>65535&&t++,!ot(n))continue;let r=cg(e,t);if(r===0||r===3)return!0;t+=r-1}return!1}var ug=/[\uDCED\uDCF0-\uDCFD][\uDC80-\uDCBF]{2,5}/gu;function dg(e){let t={long:!1,surrogate:!1};for(let[n]of e.matchAll(ug)){let e=cg(n,0);if(e===3?t.surrogate=!0:e&&(t.long=!0),t.long&&t.surrogate)break}return t}function fg(e,t){let n={negated:!1,dot:!1,regex:t,wordEdge:!1};for(let t=0;t<e.length;t++){let r=e[t];if(r===`\\`){let r=e[++t]??``;`<>bB`.includes(r)&&(n.wordEdge=!0),`<>bBwsWS`.includes(r)&&(n.regex=!0),`WS`.includes(r)&&(n.negated=!0)}else if(r===`.`)n.dot=!0;else if(r===`[`){let r=Wt(e,t),i=e.slice(t+1,r);i.startsWith(`^`)&&(n.negated=!0),/\[:|.-./u.test(i.replace(/^\^?\]?/u,``))&&(n.regex=!0),t=r}}return n}function pg(e,t,n){return t.long||t.surrogate?e.wordEdge||(e.dot||e.negated)&&(e.regex||n)?!0:t.long&&e.negated:!1}var mg=new Map;function hg(e){return mg.has(e)||mg.set(e,RegExp(`[^\\x00-\\x7f${it}${e.body(`word`)}]`,`u`)),mg.get(e)}function gg(e){throw new T(`feature`,`PCRE `+e,`PCRE ${e} is not supported`)}function _g(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 i=e[r];if(i===`\\`){let i=xg(e,r,t,!1);n+=i.source,r=i.end;continue}if(i===`[`){let i=bg(e,r,t);n+=i.source,r=i.end;continue}if(i===`(`){let i=vg(e,r,t);n+=i.source,r=i.end;continue}if(i===`)`){let e=t.stack.pop();e?.capture&&t.closed.add(e.capture),e?.behind&&t.behind--}if(`*+?`.includes(i)&&(t.behind&&gg(`variable-length lookbehind`),e[r+1]===`+`&&gg(`possessive repetition`),i!==`+`&&(t.risky=!0)),i===`|`&&(t.risky=!0),i===`{`){let i=yg(e,r,t);n+=i.source,r=i.end;continue}n+=i===`]`||i===`}`?`\\`+i:i,r++}return t.references&&t.risky&&gg(`conditional backreference`),n}function vg(e,t,n){let r=!1,i=null,a=`(`;if(e[t+1]===`*`&&gg(`control verb`),e[t+1]===`?`){let o=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(o||gg(`group`),a=o[0],r=a===`(?<=`||a===`(?<!`,!o[1]&&a!==`(?:`&&(n.risky=!0),o[1]){if(i=++n.captures,n.names.has(o[1]))throw Error(`duplicate PCRE capture name`);n.names.set(o[1],i)}}else i=++n.captures;return r&&n.behind++,n.stack.push({capture:i,behind:r}),{source:a,end:t+a.length}}function yg(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&gg(`repetition`),{source:`\\{`,end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&gg(`variable-length lookbehind`),Number(r[1])>65535||Number(r[2])>65535)throw Error(`PCRE repetition count exceeds 65535`);return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]===`+`&&gg(`possessive repetition`),{source:r[0],end:t+r[0].length}}function bg(e,t,n){let r=t+1,i=`[`;for(e[r]===`^`&&(i+=`^`,r++),e[r]===`]`&&(i+=`\\]`,r++);r<e.length&&e[r]!==`]`;)if(e[r]===`[`&&`:.=`.includes(e[r+1]??``)&&gg(`character class`),e[r]===`\\`){let t=xg(e,r,n,!0);i+=t.source,r=t.end}else i+=e[r]===`[`?`\\[`:e[r],r++;return{source:i+(e[r]===`]`?`]`:``),end:r+1}}function xg(e,t,n,r){let i=e[t+1];if(i===void 0)throw Error(`trailing backslash`);if(i===`Q`){let n=e.indexOf(`\\E`,t+2);return{source:RegExp.escape(e.slice(t+2,n<0?void 0:n)),end:n<0?e.length:n+2}}if(i===`E`)return{source:``,end:t+2};if(i===`x`||i===`0`||r&&/[1-7]/u.test(i))return Sg(e,t);if(i===`a`||i===`e`)return{source:i===`a`?`\\u0007`:`\\u001B`,end:t+2};if(`AzZ`.includes(i)&&!r)return{source:i===`A`?`^`:`$`,end:t+2};if(/[1-9]/u.test(i)&&!r)return(/\d/u.test(e[t+2]??``)||!n.closed.has(Number(i)))&&gg(`forward or ambiguous backreference`),n.references=!0,{source:`\\`+i,end:t+2};if(i===`k`&&!r){let r=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return(!r||!n.closed.has(n.names.get(r[1])))&&gg(`named backreference`),n.references=!0,{source:r[0],end:t+r[0].length}}if(`dDsSwWfnrtbB`.includes(i))return{source:`\\`+i,end:t+2};/[A-Za-z0-9]/u.test(i)&&gg(`escape \\`+i);let a=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(a),end:t+1+a.length}}function Sg(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 Error(`invalid PCRE character escape`);let i=n?16:8,a=parseInt(r[1]??r[2],i);return Rr(a)||gg(`character escape`),{source:`\\u{${a.toString(16)}}`,end:t+r[0].length}}function Cg(e,t){let n=``,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`){let t=e[++i]??``;n+=r?a+t:wg(t);continue}if(r&&a===`[`){if(e[i+1]===`.`||e[i+1]===`=`)throw new T(`feature`,`regex collating or equivalence class`,`grep: collating and equivalence classes are not supported`);let r=Gt(e,i,{classes:t});if(r){n+=r.body,i=r.end-1;continue}}if(a===`[`&&!r){n+=`[`,r=!0,e[i+1]===`^`&&(n+=`^`,i++),e[i+1]===`]`&&(n+=`\\]`,i++);continue}a===`]`&&(r=!1),n+=a}return n}function wg(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?`\\`+e:RegExp.escape(e)}function Tg(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 Eg(e,t=`js`,n=yn(M)){let r=t===`extent`,i=t===`marked`,a=r?{b:`\\y`}:i?{...Dg(n),...rg(n)}:Dg(n),o=``,s=!1;for(let t=0;t<e.length;t++){let n=e[t];if(n===`\\`){let i=e[++t];o+=!s&&Object.hasOwn(a,i)?a[i]:n+i,!r&&!s&&/[1-9]/u.test(i)&&/\d/u.test(e[t+1]??``)&&(o+=`(?:)`)}else if(i&&n===`[`){let n=Bg(e,t);o+=ig(e.slice(t,n+1)),t=n}else i&&n===`.`?o+=`[^${it}]`:(n===`[`&&(s=!0),n===`]`&&(s=!1),o+=n)}return o}function Dg(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 Og=e=>e.plain??=new RegExp(e.source,e.flags);function kg(e){return e.markedSource===void 0?Og(e):(e.marked??=new RegExp(Vr(Eg(e.markedSource,`marked`,e.tables)),e.flags),e.marked)}var Ag=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,jg=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function Mg(e,t,n){let r=(n?Ag:jg).exec(e.slice(t));if(!r&&!n)throw Error(`invalid repetition count`);r&&Ut(Number(r[1]),r[2]===void 0||r[2]===``?void 0:Number(r[2]))}var Ng={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function Pg(e){if(Ng[e])return Ng[e];let t=Ag.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===``?1/0:Number(t[2])}}var Fg=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function Ig(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=Fg(t.max,e.max);return r!==1/0&&r>Ht?null:{min:Fg(t.min,e.min),max:r}}function Lg(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 Rg=e=>!e.startsWith(`(`)&&!/^\\[1-9]/u.test(e);function zg(e,t){if(t.length===1)return e+Lg(t[0].bounds);let n=t[0].bounds,r=null;for(let i=1;i<t.length;i++){let{bounds:a,text:o}=t[i],s=r===null?Ig(n,a):null;if(s){n=s;continue}if(!(r===null&&n.min===n.max&&Rg(e))&&a.max>1)throw Error(`stacked quantifier needs ambiguous nesting`);r=`(?:${r??e+Lg(n)})${o}`}return r??e+Lg(n)}function Bg(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 Vg(e){let t=``,n=-1,r=-1,i=[],a=()=>{i.length>0&&(t=t.slice(0,n)+zg(t.slice(n,r),i)),i=[]},o=e=>{a(),n=t.length,r=-1,t+=e},s=[];for(let c=0;c<e.length;c++){let l=e[c];if(l===`\\`){o(l+(e[++c]??``));continue}if(l===`[`){let t=Bg(e,c);o(e.slice(c,t+1)),c=t;continue}if(l===`(`){a(),s.push(t.length),n=-1,t+=l;continue}if(l===`)`){a(),t+=l,n=s.pop()??-1,r=-1;continue}if(l===`|`||l===`^`||l===`$`){a(),t+=l,n=-1;continue}let u=l===`{`?Ag.exec(e.slice(c)):null;if(l===`*`||l===`+`||l===`?`||u){let e=u?u[0]:l;if(c+=e.length-1,n<0){t+=e;continue}i.length===0&&(r=t.length),i.push({bounds:Pg(e),text:e});continue}o(l)}return a(),t}function Hg(e,t,n=!1){let r=-1;for(let i=0;i<e.length;i++){let a=i<=r,o=e[i];if(o===`\\`){let n=e[++i];if(n===void 0)throw Error(`trailing backslash`);if(a||n&&`dDxXuUpPkKcC`.includes(n))throw new T(`feature`,`regex escape`,`grep: this regex escape is not supported with GNU semantics`);!t&&n===`{`&&Mg(e,i-1,!1)}else if(o===`[`&&!a)r=Wt(e,i,n);else{if(a)continue;if(t&&o===`{`)Mg(e,i,!0);else if(t&&o===`(`&&e[i+1]===`?`)throw new T(`feature`,`regex extension`,`grep: ECMAScript group extensions are not supported in ERE`)}}}function Ug(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`&&/[1-9]/u.test(e[++t]??``))return!0;return!1}function Wg(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 Gg(e,t,n=M){let r=yn(n),i=[],a=t.has(`x`),o=t.has(`w`)&&!a;if(t.has(`P`)&&new Set(e).size>1)return{error:x(`grep: -P only supports a single pattern`,2)};for(let n of e){let e=!t.has(`F`)&&!t.has(`P`);e&&Hg(n,t.has(`E`),r.multibyte);let s=e&&Ug(n),c=t.has(`i`)&&!t.has(`P`)&&!s,l=t.has(`i`)&&!c?`isu`:`su`,u;if(t.has(`F`))u=c?Wh(n,r):RegExp.escape(n);else if(t.has(`P`))u=_g(n);else if(t.has(`E`))u=Cg(c?Uh(n,r):n,r);else{let e=Rh(c?Uh(n,r):n,r);if(e.error)return{error:x(`grep: ${e.error}`,2)};u=e.source}let d=u;if(e&&Bh(d))return{error:C(`feature`,`grep`,`conditional backreference`,`grep: backreferences with conditional or repeated-empty captures are not supported`,2)};o&&(u=`(?<!${r.assertions().word})(?:${u})(?!${r.assertions().word})`),a&&(u=`^(?:${u})$`);try{let f=e?Vg(u):u,p=new RegExp(Vr(e?Eg(f,`js`,r):u),l);e&&Object.assign(p,{markedSource:f,tables:r,shape:fg(n,s)}),p.pcre=t.has(`P`),p.localeSensitive=p.pcre?t.has(`i`)||o||Tg(d)||/\\[dD]/u.test(d):t.has(`i`)&&s,p.folded=c,p.extendedC=c&&un.test(n),p.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(n),p.wellFormed=n.isWellFormed(),p.emptyWord=o&&!p.pcre&&new RegExp(e?Eg(Vg(d),`js`,r):d,l).test(``),p.anyCharacter=Wg(d);let m=tg(n,t);if(m?.isWellFormed()&&(c||!t.has(`i`))&&(p.literal={pattern:m,tables:r}),t.has(`o`)&&e&&!a){if(o||/\\[1-9]|\(\?/u.test(u))return{error:C(`feature`,`grep`,`-o regex extent`,`grep: only-matching with backreferences, lookarounds or word constraints is not supported`,2)};try{p.extent=new Mh(Eg(u,`extent`,r),!1,null,r)}catch{return{error:C(`feature`,`grep`,`-o regex extent`,`grep: POSIX match extent for this pattern is not supported`,2)}}}i.push(p)}catch(e){return!t.has(`P`)&&Kg(d,t)?{error:C(`feature`,`grep`,`GNU regex syntax`,`grep: this GNU regular expression cannot be represented by the JavaScript matcher`,2)}:{error:x(`grep: invalid pattern (${t.has(`F`)?`fixed-string /${l}`:t.has(`P`)?`PCRE subset /${l}`:t.has(`E`)?`ERE / ECMAScript /${l}`:`BRE /${l}`}): ${e.message}`,2)}}}return{res:i}}function Kg(e,t){if(!t.has(`E`)&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return vh(Eg(e,`extent`)),!0}catch(e){return!!e.gap}}function qg(e,t,n=M,r=!1){let i=(e,t)=>C(`feature`,`grep`,e,`grep: ${t}`,2);if(e.marked){if(t.some(e=>e.pcre))return i(`binary input`,`PCRE matching over bytes that spell no text is not supported`);if(t.some(e=>!e.wellFormed))return i(`unpaired surrogate`,`a pattern holding an unpaired UTF-16 surrogate cannot be matched against bytes`)}if(t.some(e=>e.emptyWord)&&hg(yn(n)).test(e.content))return i(`empty word match`,`-w with a pattern that can match nothing, over non-ASCII text that is not word characters, is not supported`);let a=e.marked?t.filter(e=>e.shape&&(e.shape.wordEdge||e.shape.dot||e.shape.negated)):[],o=a.length?dg(e.content):null;if(a.some(e=>pg(e.shape,o,r)))return i(`binary input`,`matching this pattern beside bytes glibc reads as a character is not supported`);let s=()=>t.some(e=>e.unicodePattern)||/[\u0080-\u{10FFFF}]/u.test(e.content);if(n!==M&&t.some(e=>e.localeSensitive||e.folded||e.anyCharacter)&&s())return i(`locale`,`matching non-ASCII text in the ${n} locale is not supported`);if(t.some(e=>e.extendedC)||t.some(e=>e.folded)&&un.test(e.content))return i(`locale-sensitive regex`,`case-insensitive matching over Cyrillic Extended-C letters is not supported`);let c=t.filter(e=>e.localeSensitive);return c.length===0||!s()?null:i(`non-ASCII regex semantics`,`${c.some(e=>e.pcre)?`PCRE matching`:`case-insensitive matching with backreferences`} on non-ASCII input is not supported`)}var Jg=/[*?[]/u,Yg=/\P{ASCII}/u,Xg=/[.+*?^${}()|[\]\\/]/u;function Zg(e,t={}){try{return Qg(e,t)}catch(e){throw e instanceof T?e:new T(`feature`,`glob pattern`,`unsupported glob pattern: ${e.message}`)}}function Qg(e,t){let n=`^`,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`&&i+1<e.length){let r=e[i+1];n+=$g(r,t.ignoreCase),i++}else if(a===`*`){for(;e[i+1]===`*`;)i++;n+=`.*`}else if(a===`?`)n+=`.`;else if(a===`[`){let a=n_(e,i,t);if(a?.voided)return/^(?!)$/u;a?(n+=a.source,i=a.end,r||=a.nonAsciiRange):n+=`\\[`}else n+=$g(a,t.ignoreCase)}return t_(RegExp(n+`(?![\\s\\S])`,`us`),e,t,r)}function $g(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:Xg.test(e)?`\\`+e:e}function e_(e,t,n){let r=RegExp(`[${e}]`,`ui`),i=RegExp(`[${t}]`,`u`),a=``;for(let e=0;e<128;e++){let t=String.fromCodePoint(e);(r.test(t)||i.test(t))&&(a+=`\\x`+e.toString(16).padStart(2,`0`))}return`[${n?`^`:``}${a}]`}function t_(e,t,n,r){let i=/[?[]/u.test(t),a=Yg.test(t);return{test(t){if(r||n.ignoreCase&&a||(i||n.ignoreCase)&&Yg.test(t))throw new T(`feature`,`non-ASCII glob matching`,`locale-dependent glob matching of non-ASCII names is not supported`);return e.test(t)}}}function n_(e,t,n){let{ignoreCase:r}=n,i=t+1,a=!1;(e[i]===`!`||e[i]===`^`)&&(a=!0,i++);let o=``,s=``,c=!1,l=!1,u=!1,d=!1,f=``,p=0,m=``,h=0;for(e[i]===`]`&&(o+=`\\]`,i++,c=!0,f=`]`);i<e.length&&e[i]!==`]`;i++){let t=e[i];if(t===`[`&&(e[i+1]===`.`||e[i+1]===`=`))throw new T(`feature`,`glob collating or equivalence class`,`glob collating symbols and equivalence classes are not supported`);if(t===`[`&&e[i+1]===`:`){let t=n.bash?r_(e,i):Gt(e,i,{unknown:`empty`});if(t){if(!n.bash&&t.body===``)throw new T(`feature`,`glob character class`,`unknown POSIX classes in command filename patterns are not supported`);l&&(d=!0),r?s+=t.body:o+=t.body,i=t.end-1,c=!1,l=!1;continue}if(n.bash)continue}if(t===`-`&&c)h=p,m=f,o+=`-`,l=!0,c=!1;else{let n=t===`\\`&&i+1<e.length?e[++i]:t;p=o.length,f=n,l&&Yg.test(m+n)&&(u=!0),l&&n.codePointAt(0)<m.codePointAt(0)?o=o.slice(0,h):o+=/[\]\\^[-]/u.test(n)?`\\${n}`:n,c=!l,l=!1}}return i>=e.length?null:d?{voided:!0,end:i}:{source:r?e_(o,s,a):`[${a?`^`:``}${o}]`,end:i,nonAsciiRange:u}}function r_(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`:Bt[r]??``,end:n+2}}function i_(e,t){return Zg(t).test(e)}function a_(e){let{value:t,mask:n}=e;if(n===null)return Jg.test(t);for(let e=0;e<t.length;e++)if(n[e]===`0`&&Jg.test(t[e]))return!0;return!1}function o_(e){let t=t=>!e.mask||e.mask[t]===`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=s_(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]===`(`&&t(n+1))return!0}}return!1}function s_(e,t,n){let{value:r}=e,i=t+1;for(/[!^]/u.test(r[i])&&n(i)&&i++,r[i]===`]`&&n(i)&&i++;i<r.length;i++)if(n(i)){if(r[i]===`\\`)i++;else{if(r[i]===`]`)return i;if(r[i]===`[`&&/[.:=]/u.test(r[i+1])&&n(i+1)){let e=r.indexOf(r[i+1]+`]`,i+2);e!==-1&&(i=e+1)}}}return t}var c_=/[*?[\]^!\\:.=-]/u;function l_(e){let{value:t,mask:n}=e;if(n===null)return t;let r=``;for(let e=0;e<t.length;e++){let i=t[e];r+=n[e]!==`0`&&c_.test(i)?`\\`+i:i}return r}function u_(e,t){let n=l_(e),r=n.match(/[^/]+|\/+/gu)??[],i=wn(),a=new Set,o=[{path:``,marks:null}],s;try{for(let e=0;e<r.length;e++){let n=r[e];if(n.startsWith(`/`)||!Jg.test(n)){o=o.map(e=>({...e,path:e.path+f_(n)}));continue}o=p_(o,n,e===r.length-1,t,a)}let e=o.filter(e=>k(t.cwd,e.path,t.fs,{follow:!1}).path!==null);for(let t of e)for(let e of t.marks??[])i.add(e);return s=e.filter(e=>e.marks===null).map(e=>e.path).sort(j),s}finally{if(s===void 0)for(let e of a)i.add(e);i.emit(t.notes,`glob`,``,` while expanding ${JSON.stringify(n)}`),s?.length===0&&r.some(d_)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function d_(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(n_(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var f_=e=>e.replace(/\\(.)/gu,`$1`);function p_(e,t,n,r,i){let a=Zg(t,{bash:!0}),o=t.startsWith(`.`)||t.startsWith(`\\.`),s=[];for(let t of e){let e=k(r.cwd,t.path||`.`,r.fs).path;if(!r.fs.isDir(e))continue;let{dirs:c,files:l,links:u}=r.fs.listDir(e),d=n?u:u.filter(t=>r.fs.isDir(k(e,t,r.fs).path));for(let r of n?[...c,...l,...d]:[...c,...d]){let n=!o&&r.startsWith(`.`);if(!n&&t.marks===null)a.test(r)&&s.push({path:t.path+r,marks:null});else if(m_(a,r)){if(!n){s.push({path:t.path+r,marks:t.marks});continue}let a=O(e,r);i.add(a),s.push({path:t.path+r,marks:[...t.marks??[],a]})}}}return s}function m_(e,t){try{return e.test(t)}catch{return!0}}var h_=(e,t)=>e.some(e=>e.test(t)),g_=()=>({stdout:``,stderr:``,exitCode:1}),__=e=>e.failure!==void 0,v_=e=>e.name??`(standard input)`,y_=e=>e.binaryLine===void 0?e.content:e.content.replaceAll(`\0`,`
146
+ `),b_=(e,t)=>t.map(e.marked?kg:Og);function x_(e,t,n,r){if(r===0)return 0;let i=b_(e,t),a=y_(e),o=0;if(r===1/0){for(let e of Mn(a))h_(i,e)!==n&&o++;return o}let s=0;for(;s<a.length&&o<r;){let e=a.indexOf(`
147
+ `,s);e<0&&(e=a.length),h_(i,a.slice(s,e))!==n&&o++,s=e+1}return o}function S_(){let e=[],t=(t,n)=>{let r=e.at(-1);r?.fd===t&&r.text!==void 0?r.text+=n:e.push({fd:t,text:n})};return{events:e,out(e){e&&t(1,e)},lines(t,n,r){if(!n||!at.test(t))return this.out(t);if(!r.isWellFormed())throw new T(`feature`,`unpaired surrogate`,`unpaired UTF-16 surrogates cannot be encoded as UTF-8`);e.push({fd:1,bytes:st(t)})},err(e){e&&t(2,e)}}}function C_(e,t){let n=t=>e.filter(e=>e.fd===t&&e.text!==void 0).map(e=>e.text).join(``);return{stdout:e.some(e=>e.bytes!==void 0)?``:n(1),stderr:n(2),exitCode:+!t,events:e}}function w_(e,t,n){let r={used:!1,write:S_(),selected:!1};for(let i of e)__(i)?r.write.err(i.failure):T_(i,t,n,r);return C_(r.write.events,r.selected)}function T_(e,t,n,r){if(e.binaryLine===0)return E_(e,t,n,r);let i=y_(e),a={input:e,opts:n,run:r,lines:Mn(i),res:t,tests:b_(e,t),bufbeg:0,name:n.showName??e.recursive?v_(e):null,out:[],lastout:null,pending:0,outleft:n.max??1/0,quiet:!1,heldBack:!1},o=a.lines.length,s=o>0&&!i.endsWith(`
148
+ `)?o-1:o,c=O_(a,0,s);if(a.pending>0&&A_(a,s),s<o&&(a.outleft!==0||a.pending!==0)&&!a.quiet){let e=s;for(let t=0;t<n.before&&e>0&&e!==a.lastout;t++)e--;e!==a.lastout&&(a.lastout=null),a.bufbeg=e,a.outleft>0&&(c+=O_(a,s,o)),a.pending>0&&A_(a,o)}r.write.lines(Pn(a.out),e.marked,a.name??``),c>0&&(r.selected=!0),(a.heldBack||a.quiet)&&D_(e,n,r)}function E_(e,t,n,r){x_(e,t,n.invert,1)!==0&&(r.used=r.selected=!0,D_(e,n,r))}function D_(e,t,n){t.binaryFiles===`binary`&&n.write.err(`grep: ${v_(e)}: binary file matches
149
+ `)}function O_(e,t,n){let{invert:r}=e.opts,i=e.input.binaryLine??1/0,a=0;for(let o=t;o<n;){let t=o;for(;t<n&&!h_(e.tests,e.lines[t]);)t++;if(t===n&&!r)break;if(!r||o<t){if(r&&o<i&&t>i){if(a+=k_(e,o,i),e.outleft===0)break;o=i}if(!e.quiet&&(r?o:t)>=i&&(e.pending>0&&A_(e,i),e.quiet=!0),a+=r?k_(e,o,t):k_(e,t,t+1),e.outleft===0||e.quiet)break}o=t+1}return a}function k_(e,t,n){let{before:r,after:i,hasContext:a,invert:o}=e.opts;!e.quiet&&e.pending>0&&A_(e,t);let s=t;if(!e.quiet){let n=e.lastout??e.bufbeg;for(let e=0;e<r;e++)s>n&&s--;for(a&&e.run.used&&s!==e.lastout&&e.out.push(`--`);s<t;s++)j_(e,s,!1)}let c;if(o)for(c=0;s<n&&c<e.outleft;c++,s++)e.quiet||j_(e,s,!0);else e.quiet||j_(e,t,!0),c=1;return e.pending=e.quiet?0:i,e.run.used=!0,e.outleft-=c,c}function A_(e,t){for(e.lastout??=e.bufbeg;e.pending>0&&e.lastout<t;e.pending--)j_(e,e.lastout,!1)}function j_(e,t,n){let r=e.lines[t];if(e.opts.only)n!==e.opts.invert&&M_(e,r,t,n);else{if(e.input.marked&&e.opts.binaryFiles!==`text`&&at.test(r)&&lg(r)){e.heldBack=!0;return}e.out.push(F_(e,r,t,n))}e.lastout=t+1}function M_(e,t,n,r){let i=e.input.marked&&at.test(t),a=0;for(;a<t.length;){let o=null;for(let n=0;n<e.res.length;n++){let r=P_(e.res[n],e.tests[n],t,a,i);r&&(!o||r.start<o.start||r.start===o.start&&r.end>o.end)&&(o=r)}if(!o)break;if(o.end===o.start){a=o.end+Br(t,o.end);continue}e.out.push(F_(e,t.slice(o.start,o.end),n,r)),a=o.end}}var N_=new WeakMap;function P_(e,t,n,r,i){if(e.extent)return(i?e.markedExtent??=ag(e.extent):e.extent).search(n,r);let a=N_.get(t);a||N_.set(t,a=new RegExp(t.source,t.flags+`g`)),a.lastIndex=r;let o=a.exec(n);if(o&&o[0]===``&&e.pcre)throw new T(`feature`,`PCRE empty match extent`,`only-matching with empty PCRE matches is not supported`);return o?{start:o.index,end:o.index+o[0].length}:null}function F_(e,t,n,r){let i=r?`:`:`-`;return(e.name===null?``:e.name+i)+(e.opts.showLine?n+1+i:``)+t}function I_(e,t,{mode:n,invert:r,showName:i,max:a=1/0}){let o=S_(),s=!1,c=n===`c`?a:Math.min(1,a);for(let a of e){if(__(a)){o.err(a.failure);continue}let e=x_(a,t,r,c);e>0&&(s=!0),n===`c`?o.out((i??a.recursive?v_(a)+`:`+e:String(e))+`
150
+ `):e>0==(n===`l`)&&o.out(v_(a)+`
151
+ `)}return C_(o.events,s)}function L_(e,t,n){let r=e.order.filter(e=>[`e`,`f`,`file`].includes(e.name)),i=e.positional;if(r.length===0)return i.length?{patterns:i[0].split(`
152
152
  `),rest:i.slice(1),stdin:t}:null;let a=new Set;for(let{name:e,value:i}of r){if(e===`e`){for(let e of i.split(`
153
- `))a.add(e);continue}let r=Ln(`grep`,[i],n,t);if(r.failed)return{error:x(r.stderr,2)};let o=r.inputs[0];for(let e of jn(o.content))a.add(e);o.shared&&(t=``)}return{patterns:[...a],rest:i,stdin:t}}var F_=`[-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]`,I_=`grep ${F_} PATTERN [PATH...]
154
- or: grep ${F_} [-e PATTERN] [-f FILE] ... [PATH...]`,L_={short:[`i`,`v`,`n`,`r`,`R`,`l`,`L`,`c`,`w`,`x`,`h`,`H`,`o`,`E`,`F`,`G`,`P`,`q`,`I`,`a`,`s`],long:[`text`,`no-messages`],valueShort:[`A`,`B`,`C`,`m`],repeatable:[`e`,`f`,`file`,`include`,`exclude`,`exclude-dir`]};function R_(e){try{return U(e,L_).flags.has(`q`)}catch{return!1}}function z_(e,t,n){let r;try{r=U(t,L_)}catch(e){return Ke(e,`grep`,`grep: ${e.message}`,2)}let{flags:i,values:a}=r,o=P_(r,e,n);if(!o)return We(I_,2);if(o.error)return o.error;let{patterns:s,rest:c}=o;e=o.stdin;let l=X_(i);if(l)return l;let u;try{u=Hg(s,i,n.locale)}catch(e){return Ke(e,`grep`,`grep: ${e.message}`,2)}if(u.error)return u.error;let d=Q_(a);if(d.error)return d.error;if((d.max===0||Z_(s,i))&&(!i.has(`L`)||i.has(`q`)))return p_();if(d.max!==0&&n.stdinFile&&(i.has(`q`)||i.has(`l`)||i.has(`L`)||a.has(`m`))&&(c.length===0||c.includes(`-`)))return C(`feature`,`grep`,`partial stdin reads`,`grep: early termination on shared file input is not supported`,2);let f=i.has(`r`)||i.has(`R`),p=rv(r,n),m=r.order.findLast(e=>[`a`,`I`,`text`].includes(e.name))?.name;p.binaryFiles=m===`a`||m===`text`?`text`:m===`I`?`without-match`:`binary`,p.silent=i.has(`s`)||i.has(`no-messages`),p.follow=i.has(`R`);try{return B_(e,c,n,f,p,u,i,d)}finally{Y_(p,n.notes)}}function B_(e,t,n,r,i,a,o,s){if(o.has(`q`))return V_(e,t,n,r,i,a.res,o.has(`v`));let c=ev(r,e,t,n,i);s.max===0&&F(n,e);let l=o.has(`v`),u=[`l`,`L`,`c`].find(e=>o.has(e)),d=c.items;i.name.length>0&&(d=d.filter(e=>m_(e)||av(e,i)));let f=null;if(s.max!==0&&(d=d.flatMap(e=>{if(m_(e))return[e];let t=H_(e,i,a.res,l,n),r=Wg(t,a.res,n.locale,!u&&o.has(`o`))??(u?null:K_(t,a.res,l,s.after)??q_(t,s,o,i,n));return f??=r,r?[]:[t]}),f&&d.every(m_)))return f;let p={showName:$_(o,t.length),invert:l,showLine:o.has(`n`),only:o.has(`o`),binaryFiles:i.binaryFiles,...s},m;try{m=u?N_(d,a.res,{...p,mode:u}):x_(d,a.res,p)}catch(e){return e instanceof W&&e.gap?C(`feature`,`grep`,e.gap,`grep: ${e.message}`,2):Ke(e,`grep`,`grep: ${e.message}`,2)}if(f){let e=S(f);return w({...m,stderr:m.stderr+f.stderr,exitCode:2,events:[...m.events,{fd:2,text:f.stderr}]},e.kind,e.command,e.detail,e.message)}return c.failed?{...m,exitCode:2}:m}function V_(e,t,n,r,i,a,o){let s=``,c=!1;for(let l of t.length?t.map(e=>[e]):[[]]){let t=ev(r,e,l,n,i);c||=t.failed,(l.includes(`-`)||l.includes(`/dev/stdin`)&&!n.stdinFile)&&(e=``);for(let e of t.items){if(m_(e)){s+=e.failure;continue}if(!av(e,i))continue;let t=H_(e,i,a,o,n),r=Wg(t,a,n.locale);if(r)return r.stderr=s+r.stderr,r;if(v_(t,a,o,1)>0)return{stdout:``,stderr:s,exitCode:0}}}return{stdout:``,stderr:s,exitCode:c?2:1}}function H_(e,t,n,r,i){let a=G_(e,i),o=t.binaryFiles===`without-match`,s=t.binaryFiles===`text`;if(e.content===void 0){if(!r&&Gh(e.bytes,n))return{...e,content:``};let i=s?-1:e.bytes.indexOf(0);if(i>=0&&o)return J_(e,t,i>=a);let c={...e,content:et(e.bytes),marked:!0};return i<0?c:U_(c,e.bytes,i,a)}let c=s?-1:e.content.indexOf(`\0`);if(c<0)return e;let l=p(e.content.slice(0,Math.min(c,a)));return o?J_(e,t,l.length>=a):U_(e,l,l.length,a)}function U_(e,t,n,r){if(n<r)return{...e,binaryLine:0};let i=e.content.lastIndexOf(`
155
- `,e.content.indexOf(`\0`))+1;return{...e,lineStart:i,readLines:Mn(t.subarray(0,r)),binaryLine:Mn(e.content.slice(0,i))}}var W_=e=>e.name===null||e.name===`/dev/stdin`,G_=(e,t)=>W_(e)&&!t.stdinFile?65536:98304;function K_(e,t,n,r){if(e.readLines===void 0)return null;let i=jn(e.content.slice(0,e.lineStart)),a=__(e,t),o=(e,t)=>i.slice(e,t).some(e=>f_(a,e)!==n);return!o(e.readLines)&&!(r>0&&o(Math.max(0,e.readLines-r),e.readLines))?null:C(`feature`,`grep`,`late binary detection`,`grep: binary detection after the initial input buffer is not supported`,2)}function q_(e,t,n,r,i){return!e.marked||e.binaryLine!==void 0||!t.hasContext||n.has(`o`)||r.binaryFiles===`text`||e.bytes.length<=G_(e,i)?null:C(`feature`,`grep`,`binary context across reads`,`grep: context around lines held back past the first read is not supported`,2)}function J_(e,t,n){if(n)throw new T(`feature`,`late binary detection`,`grep: binary detection after the initial input buffer is not supported`);let r=W_(e)?t.stdinPath:O(t.cwd,e.name);return r?t.binary.add(r):t.binaryStdin=!0,{...e,content:``}}function Y_(e,t){let n=`Binary input is treated as text with -a.`;kn(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),kn(t,{command:`grep`,action:`excluded`,noun:[`entry`,`entries`],paths:e.excluded,context:` by --include/--exclude/--exclude-dir rules`})}function X_(e){if(e.has(`h`)&&e.has(`H`))return C(`option`,`grep`,`-h -H`,`grep: combining -h and -H is not supported`);let t=[`l`,`L`,`c`].filter(t=>e.has(t));if(t.length>1)return C(`option`,`grep`,`combined output modes`,`grep: ${t.map(e=>`-${e}`).join(` / `)} are mutually exclusive`);let n=[`E`,`F`,`G`,`P`].filter(t=>e.has(t));return n.length>1?x(`grep: ${n.map(e=>`-${e}`).join(` / `)} are mutually exclusive`,2):null}function Z_(e,t){return e.length===0?!t.has(`v`):t.has(`v`)&&!t.has(`x`)&&!t.has(`w`)&&e.every(e=>e===``)}function Q_(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=qn(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(t=>e.has(t))}}function $_(e,t){return e.has(`h`)?!1:e.has(`H`)||t>1?!0:void 0}function ev(e,t,n,r,i){let a=e=>i.silent?[]:[{failure:e}];if(!e){let e=Hn(`grep`,n,t,r,{read:`maybe-text`});return{items:e.entries.flatMap(e=>e.kind===`file`?[e.name===`-`?{...e,name:null}:e]:a(e.failure)),failed:e.failed}}let o=[],s=!1,c=e=>{o.push(...a(e)),s=!0};for(let e of n.length?n:[`.`]){if(e===`-`||e===`/dev/stdin`||e===`/dev/null`){let n=Ln(`grep`,[e],r,t);o.push(...n.inputs.map(t=>({...t,name:e===`-`?null:e}))),(e===`-`||e===`/dev/stdin`)&&(t=``);continue}let{path:a,error:s}=N(r,`grep`,e);if(r.fs.isFile(a)){o.push({name:e,...nv(r,a)});continue}if(s){c(`grep: ${e}: ${s}
156
- `);continue}if(sv(e,i.dir)){i.excluded.add(a);continue}let l=e=>e===a||i.dir.length===0||!iv(i.dir,ht(e))||(i.excluded.add(e),!1);for(let t of bt(r.fs,a,1/0,l)){if(t.kind===`link`){if(!i.follow)continue;let s=tv(t.path,cv(n.length?e:``,a,t.path),r,i);s?.input&&o.push(s.input),s?.error&&c(s.error);continue}if(t.kind!==`file`)continue;let s=t.path;o.push({name:cv(n.length?e:``,a,s),...nv(r,s),recursive:!0})}}return{items:o,failed:s}}function tv(e,t,n,r){let i=k(n.cwd,e,n.fs),a=n.fs.isDir(i.path);if(!(a?r.dir.length===0||!iv(r.dir,ht(e)):ov(ht(e),r.name)))return r.excluded.add(e),null;if(a)throw new T(`option`,`-R`,`following a symbolic link to a directory is not supported: ${t}`);return i.error?{error:`grep: ${t}: ${i.error}
157
- `}:{input:{name:t,...nv(n,i.path),recursive:!0}}}function nv(e,t){let{text:n,bytes:r}=Vn(e.fs,t);return n===void 0?{content:void 0,bytes:r}:{content:n}}function rv(e,t){return{name:e.order.filter(e=>e.name===`include`||e.name===`exclude`).map(e=>({include:e.name===`include`,re:Jg(e.value)})),dir:(e.values.get(`exclude-dir`)??[]).map(e=>Jg(e)),binary:new Set,excluded:new Set,cwd:t.cwd,stdinPath:t.stdinHandle?.path}}function iv(e,t){return e.some(e=>e.test(t))}function av(e,t){return e.name===null||ov(ht(e.name),t.name)?!0:(t.excluded.add(O(t.cwd,e.name)),!1)}function ov(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 sv(e,t){return t.length===0||e.endsWith(`/`)?!1:iv(t,e.slice(e.lastIndexOf(`/`)+1))}function cv(e,t,n){let r=_t(t,n);return e===``?r:e.endsWith(`/`)?e+r:e+`/`+r}var lv=(e,t)=>C(`feature`,`rg`,e,`rg: ${t}`,2);function uv(e,t,n){let r=S(e)??e.note;return r?C(r.kind,`rg`,r.detail,t,2):C(n,`rg`,e.detail??t.replace(/^rg: /u,``),t,2)}function dv(e,t,n){let r,i;try{i=U(t,Hm),r=Km(i)}catch(e){return uv(e,e.message.startsWith(`rg: `)?e.message:`rg: ${e.message}`,`option`)}let a=[...i.positional];if(!r.patterns.length){if(!a.length)return lv(`usage`,`a pattern is required`);r.patterns.push(a.shift())}try{$m(r.patterns,r.literal)}catch(e){return uv(e,e.message,`feature`)}let o=!a.length&&n.stdinPiped?{roots:[],recursive:!1,stdin:!0}:gv(a,n,r.hidden);if(o.error)return o.error;if(!i.flags.has(`no-ignore`)&&!r.unrestricted&&o.recursive){let e=_v(o.roots,n);if(e)return lv(`ignore rules`,`${JSON.stringify(e)} would change which files are searched, and its rules are not implemented`)}let s=fv(a,o,r,n),c=r.text?null:yv(a,n);if(c)return lv(`named binary file`,`${JSON.stringify(c)} is binary, and reporting a binary match is not supported`);let l=pv(s,r,n)??(o.stdin?hv(r,n):null);return l?lv(l.detail,l.message):(o.stdin||a.length?1:s.length)===0?{stdout:``,exitCode:2,stderr:`rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
153
+ `))a.add(e);continue}let r=Rn(`grep`,[i],n,t);if(r.failed)return{error:x(r.stderr,2)};let o=r.inputs[0];for(let e of Mn(o.content))a.add(e);o.shared&&(t=``)}return{patterns:[...a],rest:i,stdin:t}}var R_=`[-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]`,z_=`grep ${R_} PATTERN [PATH...]
154
+ or: grep ${R_} [-e PATTERN] [-f FILE] ... [PATH...]`,B_={short:[`i`,`v`,`n`,`r`,`R`,`l`,`L`,`c`,`w`,`x`,`h`,`H`,`o`,`E`,`F`,`G`,`P`,`q`,`I`,`a`,`s`],long:[`text`,`no-messages`],valueShort:[`A`,`B`,`C`,`m`],repeatable:[`e`,`f`,`file`,`include`,`exclude`,`exclude-dir`]};function V_(e){try{return U(e,B_).flags.has(`q`)}catch{return!1}}function H_(e,t,n){let r;try{r=U(t,B_)}catch(e){return qe(e,`grep`,`grep: ${e.message}`,2)}let{flags:i,values:a}=r,o=L_(r,e,n);if(!o)return Ge(z_,2);if(o.error)return o.error;let{patterns:s,rest:c}=o;e=o.stdin;let l=$_(i);if(l)return l;let u;try{u=Gg(s,i,n.locale)}catch(e){return qe(e,`grep`,`grep: ${e.message}`,2)}if(u.error)return u.error;let d=tv(a);if(d.error)return d.error;if((d.max===0||ev(s,i))&&(!i.has(`L`)||i.has(`q`)))return g_();if(d.max!==0&&n.stdinFile&&(i.has(`q`)||i.has(`l`)||i.has(`L`)||a.has(`m`))&&(c.length===0||c.includes(`-`)))return C(`feature`,`grep`,`partial stdin reads`,`grep: early termination on shared file input is not supported`,2);let f=i.has(`r`)||i.has(`R`),p=ov(r,n),m=r.order.findLast(e=>[`a`,`I`,`text`].includes(e.name))?.name;p.binaryFiles=m===`a`||m===`text`?`text`:m===`I`?`without-match`:`binary`,p.silent=i.has(`s`)||i.has(`no-messages`),p.follow=i.has(`R`);try{return U_(e,c,n,f,p,u,i,d)}finally{Q_(p,n.notes)}}function U_(e,t,n,r,i,a,o,s){if(o.has(`q`))return W_(e,t,n,r,i,a.res,o.has(`v`));let c=rv(r,e,t,n,i);s.max===0&&F(n,e);let l=o.has(`v`),u=[`l`,`L`,`c`].find(e=>o.has(e)),d=c.items;i.name.length>0&&(d=d.filter(e=>__(e)||cv(e,i)));let f=null;if(s.max!==0&&(d=d.flatMap(e=>{if(__(e))return[e];let t=G_(e,i,a.res,l,n),r=qg(t,a.res,n.locale,!u&&o.has(`o`))??(u?null:Y_(t,a.res,l,s.after)??X_(t,s,o,i,n));return f??=r,r?[]:[t]}),f&&d.every(__)))return f;let p={showName:nv(o,t.length),invert:l,showLine:o.has(`n`),only:o.has(`o`),binaryFiles:i.binaryFiles,...s},m;try{m=u?I_(d,a.res,{...p,mode:u}):w_(d,a.res,p)}catch(e){return e instanceof W&&e.gap?C(`feature`,`grep`,e.gap,`grep: ${e.message}`,2):qe(e,`grep`,`grep: ${e.message}`,2)}if(f){let e=S(f);return w({...m,stderr:m.stderr+f.stderr,exitCode:2,events:[...m.events,{fd:2,text:f.stderr}]},e.kind,e.command,e.detail,e.message)}return c.failed?{...m,exitCode:2}:m}function W_(e,t,n,r,i,a,o){let s=``,c=!1;for(let l of t.length?t.map(e=>[e]):[[]]){let t=rv(r,e,l,n,i);c||=t.failed,(l.includes(`-`)||l.includes(`/dev/stdin`)&&!n.stdinFile)&&(e=``);for(let e of t.items){if(__(e)){s+=e.failure;continue}if(!cv(e,i))continue;let t=G_(e,i,a,o,n),r=qg(t,a,n.locale);if(r)return r.stderr=s+r.stderr,r;if(x_(t,a,o,1)>0)return{stdout:``,stderr:s,exitCode:0}}}return{stdout:``,stderr:s,exitCode:c?2:1}}function G_(e,t,n,r,i){let a=J_(e,i),o=t.binaryFiles===`without-match`,s=t.binaryFiles===`text`;if(e.content===void 0){if(!r&&Jh(e.bytes,n))return{...e,content:``};let i=s?-1:e.bytes.indexOf(0);if(i>=0&&o)return Z_(e,t,i>=a);let c={...e,content:tt(e.bytes),marked:!0};return i<0?c:K_(c,e.bytes,i,a)}let c=s?-1:e.content.indexOf(`\0`);if(c<0)return e;let l=p(e.content.slice(0,Math.min(c,a)));return o?Z_(e,t,l.length>=a):K_(e,l,l.length,a)}function K_(e,t,n,r){if(n<r)return{...e,binaryLine:0};let i=e.content.lastIndexOf(`
155
+ `,e.content.indexOf(`\0`))+1;return{...e,lineStart:i,readLines:Nn(t.subarray(0,r)),binaryLine:Nn(e.content.slice(0,i))}}var q_=e=>e.name===null||e.name===`/dev/stdin`,J_=(e,t)=>q_(e)&&!t.stdinFile?65536:98304;function Y_(e,t,n,r){if(e.readLines===void 0)return null;let i=Mn(e.content.slice(0,e.lineStart)),a=b_(e,t),o=(e,t)=>i.slice(e,t).some(e=>h_(a,e)!==n);return!o(e.readLines)&&!(r>0&&o(Math.max(0,e.readLines-r),e.readLines))?null:C(`feature`,`grep`,`late binary detection`,`grep: binary detection after the initial input buffer is not supported`,2)}function X_(e,t,n,r,i){return!e.marked||e.binaryLine!==void 0||!t.hasContext||n.has(`o`)||r.binaryFiles===`text`||e.bytes.length<=J_(e,i)?null:C(`feature`,`grep`,`binary context across reads`,`grep: context around lines held back past the first read is not supported`,2)}function Z_(e,t,n){if(n)throw new T(`feature`,`late binary detection`,`grep: binary detection after the initial input buffer is not supported`);let r=q_(e)?t.stdinPath:O(t.cwd,e.name);return r?t.binary.add(r):t.binaryStdin=!0,{...e,content:``}}function Q_(e,t){let n=`Binary input is treated as text with -a.`;An(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),An(t,{command:`grep`,action:`excluded`,noun:[`entry`,`entries`],paths:e.excluded,context:` by --include/--exclude/--exclude-dir rules`})}function $_(e){if(e.has(`h`)&&e.has(`H`))return C(`option`,`grep`,`-h -H`,`grep: combining -h and -H is not supported`);let t=[`l`,`L`,`c`].filter(t=>e.has(t));if(t.length>1)return C(`option`,`grep`,`combined output modes`,`grep: ${t.map(e=>`-${e}`).join(` / `)} are mutually exclusive`);let n=[`E`,`F`,`G`,`P`].filter(t=>e.has(t));return n.length>1?x(`grep: ${n.map(e=>`-${e}`).join(` / `)} are mutually exclusive`,2):null}function ev(e,t){return e.length===0?!t.has(`v`):t.has(`v`)&&!t.has(`x`)&&!t.has(`w`)&&e.every(e=>e===``)}function tv(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=Yn(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(t=>e.has(t))}}function nv(e,t){return e.has(`h`)?!1:e.has(`H`)||t>1?!0:void 0}function rv(e,t,n,r,i){let a=e=>i.silent?[]:[{failure:e}];if(!e){let e=Un(`grep`,n,t,r,{read:`maybe-text`});return{items:e.entries.flatMap(e=>e.kind===`file`?[e.name===`-`?{...e,name:null}:e]:a(e.failure)),failed:e.failed}}let o=[],s=!1,c=e=>{o.push(...a(e)),s=!0};for(let e of n.length?n:[`.`]){if(e===`-`||e===`/dev/stdin`||e===`/dev/null`){let n=Rn(`grep`,[e],r,t);o.push(...n.inputs.map(t=>({...t,name:e===`-`?null:e}))),(e===`-`||e===`/dev/stdin`)&&(t=``);continue}let{path:a,error:s}=N(r,`grep`,e);if(r.fs.isFile(a)){o.push({name:e,...av(r,a)});continue}if(s){c(`grep: ${e}: ${s}
156
+ `);continue}if(uv(e,i.dir)){i.excluded.add(a);continue}let l=e=>e===a||i.dir.length===0||!sv(i.dir,gt(e))||(i.excluded.add(e),!1);for(let t of xt(r.fs,a,1/0,l)){if(t.kind===`link`){if(!i.follow)continue;let s=iv(t.path,dv(n.length?e:``,a,t.path),r,i);s?.input&&o.push(s.input),s?.error&&c(s.error);continue}if(t.kind!==`file`)continue;let s=t.path;o.push({name:dv(n.length?e:``,a,s),...av(r,s),recursive:!0})}}return{items:o,failed:s}}function iv(e,t,n,r){let i=k(n.cwd,e,n.fs),a=n.fs.isDir(i.path);if(!(a?r.dir.length===0||!sv(r.dir,gt(e)):lv(gt(e),r.name)))return r.excluded.add(e),null;if(a)throw new T(`option`,`-R`,`following a symbolic link to a directory is not supported: ${t}`);return i.error?{error:`grep: ${t}: ${i.error}
157
+ `}:{input:{name:t,...av(n,i.path),recursive:!0}}}function av(e,t){let{text:n,bytes:r}=Hn(e.fs,t);return n===void 0?{content:void 0,bytes:r}:{content:n}}function ov(e,t){return{name:e.order.filter(e=>e.name===`include`||e.name===`exclude`).map(e=>({include:e.name===`include`,re:Zg(e.value)})),dir:(e.values.get(`exclude-dir`)??[]).map(e=>Zg(e)),binary:new Set,excluded:new Set,cwd:t.cwd,stdinPath:t.stdinHandle?.path}}function sv(e,t){return e.some(e=>e.test(t))}function cv(e,t){return e.name===null||lv(gt(e.name),t.name)?!0:(t.excluded.add(O(t.cwd,e.name)),!1)}function lv(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 uv(e,t){return t.length===0||e.endsWith(`/`)?!1:sv(t,e.slice(e.lastIndexOf(`/`)+1))}function dv(e,t,n){let r=vt(t,n);return e===``?r:e.endsWith(`/`)?e+r:e+`/`+r}var fv=(e,t)=>C(`feature`,`rg`,e,`rg: ${t}`,2);function pv(e,t,n){let r=S(e)??e.note;return r?C(r.kind,`rg`,r.detail,t,2):C(n,`rg`,e.detail??t.replace(/^rg: /u,``),t,2)}function mv(e,t,n){let r,i;try{i=U(t,Gm),r=Ym(i)}catch(e){return pv(e,e.message.startsWith(`rg: `)?e.message:`rg: ${e.message}`,`option`)}let a=[...i.positional];if(!r.patterns.length){if(!a.length)return fv(`usage`,`a pattern is required`);r.patterns.push(a.shift())}try{nh(r.patterns,r.literal)}catch(e){return pv(e,e.message,`feature`)}let o=!a.length&&n.stdinPiped?{roots:[],recursive:!1,stdin:!0}:yv(a,n,r.hidden);if(o.error)return o.error;if(!i.flags.has(`no-ignore`)&&!r.unrestricted&&o.recursive){let e=bv(o.roots,n);if(e)return fv(`ignore rules`,`${JSON.stringify(e)} would change which files are searched, and its rules are not implemented`)}let s=hv(a,o,r,n),c=r.text?null:Sv(a,n);if(c)return fv(`named binary file`,`${JSON.stringify(c)} is binary, and reporting a binary match is not supported`);let l=gv(s,r,n)??(o.stdin?vv(r,n):null);return l?fv(l.detail,l.message):(o.stdin||a.length?1:s.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
- `}:bv(e,r,a,o,n)}function fv(e,t,n,r){let i=e.map(e=>k(r.cwd,e,r.fs).path).filter(Boolean).map(e=>({path:e,named:!0}));for(let e of t.roots)for(let t of bt(r.fs,e)){if(t.kind!==`file`)continue;let r=_t(e===`/`?`/`:e,t.path).split(`/`);(n.hidden||r.every(e=>!e.startsWith(`.`)))&&i.push({path:t.path,named:!1})}return i}function pv(e,t,n){for(let{path:r,named:i}of e){if(n.fs.isDir(r))continue;let{text:e,bytes:a}=Vn(n.fs,r);if(e!==void 0&&!e.startsWith(``)||(a===void 0?e.includes(`\0`):a.includes(0))&&!i&&!t.text)continue;let o=JSON.stringify(_t(n.cwd===`/`?`/`:n.cwd,r)||r);if(e===void 0){let e=mv(a,o,t,n);if(e)return e;continue}if(e.startsWith(``))return{detail:`byte-order mark`,message:`${o} begins with a byte-order mark, which ripgrep strips before matching`}}return null}function mv(e,t,n,r){return!n.invert&&!n.ignoreCase&&Kh(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 hv(e,t){let n=t.stdinBytes;return!n||!e.text&&n.includes(0)||$e(n)!==void 0?null:mv(n,Gn(null,t),e,t)}function gv(e,t,n){let r=[],i=!1;for(let n of e){let e=k(t.cwd,n,t.fs);e.path!==null&&t.fs.isDir(e.path)&&r.push(e.path),n.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`&&e!==`..`)&&(i=!0)}e.length||r.push(t.cwd);let a=r.length>0;return!n&&a&&i&&e.length?{error:lv(`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:a}}function _v(e,t){let n=e=>_t(t.cwd===`/`?`/`:t.cwd,e)||e,r=(n,r=!0)=>{for(let i of e){for(let e of bt(t.fs,i))if(ht(e.path)===n&&vv(e.path,r,t))return e.path;for(let e=i;e!==`/`;e=A(e)){let i=k(A(e),n,t.fs);if(i.path!==null&&vv(i.path,r,t))return i.path}}return null},i=r(`.ignore`)??r(`.rgignore`);if(i)return n(i);let a=r(`.git`,!1);if(!a)return null;let o=k(a,`info/exclude`,t.fs).path,s=o!==null&&vv(o,!0,t)?o:null,c=r(`.gitignore`)??s;return c?n(c):null}function vv(e,t,n){if(!t||n.fs.isDir(e))return!0;let r=k(`/`,e,n.fs).path,{text:i}=Vn(n.fs,r??e);return(i??` `).split(`
160
- `).some(e=>e.trim()!==``&&!e.trimStart().startsWith(`#`))}function yv(e,t){for(let n of e){let e=k(t.cwd,n,t.fs);if(e.path===null||t.fs.isDir(e.path))continue;let{text:r,bytes:i}=Vn(t.fs,e.path);if(i===void 0?r?.includes(`\0`):i.includes(0))return n}return null}function bv(e,t,n,r,i){let a=t.literal?[`-F`]:[`-P`];t.ignoreCase&&a.push(`-i`),t.lineNumbers&&a.push(`-n`),t.word&&a.push(`-w`),t.invert&&a.push(`-v`),t.quiet&&a.push(`-q`),t.mode&&a.push(`-`+t.mode),t.showName&&a.push(`-`+t.showName),a.push(t.text?`-a`:`-I`),t.after&&a.push(`-A`,String(t.after)),t.before&&a.push(`-B`,String(t.before)),r.recursive&&a.push(`-r`),r.recursive&&!t.hidden&&a.push(`--exclude=.*`,`--exclude-dir=.[!.]*`,`--exclude-dir=..?*`),a.push(...Xm(t.patterns,t.literal)),r.stdin||a.push(`--`,...n.length?n:[`.`]);let o=new Set(i.notes),s=z_(e,a,i);return delete s.events,Ev(i.notes,o,r),Tv(xv(s,t),n,t.patterns)}function xv(e,t){if(t.mode!==`c`)return e;let n=e.stdout.split(`
159
+ `}:Cv(e,r,a,o,n)}function hv(e,t,n,r){let i=e.map(e=>k(r.cwd,e,r.fs).path).filter(Boolean).map(e=>({path:e,named:!0}));for(let e of t.roots)for(let t of xt(r.fs,e)){if(t.kind!==`file`)continue;let r=vt(e===`/`?`/`:e,t.path).split(`/`);(n.hidden||r.every(e=>!e.startsWith(`.`)))&&i.push({path:t.path,named:!1})}return i}function gv(e,t,n){for(let{path:r,named:i}of e){if(n.fs.isDir(r))continue;let{text:e,bytes:a}=Hn(n.fs,r);if(e!==void 0&&!e.startsWith(``)||(a===void 0?e.includes(`\0`):a.includes(0))&&!i&&!t.text)continue;let o=JSON.stringify(vt(n.cwd===`/`?`/`:n.cwd,r)||r);if(e===void 0){let e=_v(a,o,t,n);if(e)return e;continue}if(e.startsWith(``))return{detail:`byte-order mark`,message:`${o} begins with a byte-order mark, which ripgrep strips before matching`}}return null}function _v(e,t,n,r){return!n.invert&&!n.ignoreCase&&Yh(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 vv(e,t){let n=t.stdinBytes;return!n||!e.text&&n.includes(0)||et(n)!==void 0?null:_v(n,Kn(null,t),e,t)}function yv(e,t,n){let r=[],i=!1;for(let n of e){let e=k(t.cwd,n,t.fs);e.path!==null&&t.fs.isDir(e.path)&&r.push(e.path),n.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`&&e!==`..`)&&(i=!0)}e.length||r.push(t.cwd);let a=r.length>0;return!n&&a&&i&&e.length?{error:fv(`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:a}}function bv(e,t){let n=e=>vt(t.cwd===`/`?`/`:t.cwd,e)||e,r=(n,r=!0)=>{for(let i of e){for(let e of xt(t.fs,i))if(gt(e.path)===n&&xv(e.path,r,t))return e.path;for(let e=i;e!==`/`;e=A(e)){let i=k(A(e),n,t.fs);if(i.path!==null&&xv(i.path,r,t))return i.path}}return null},i=r(`.ignore`)??r(`.rgignore`);if(i)return n(i);let a=r(`.git`,!1);if(!a)return null;let o=k(a,`info/exclude`,t.fs).path,s=o!==null&&xv(o,!0,t)?o:null,c=r(`.gitignore`)??s;return c?n(c):null}function xv(e,t,n){if(!t||n.fs.isDir(e))return!0;let r=k(`/`,e,n.fs).path,{text:i}=Hn(n.fs,r??e);return(i??` `).split(`
160
+ `).some(e=>e.trim()!==``&&!e.trimStart().startsWith(`#`))}function Sv(e,t){for(let n of e){let e=k(t.cwd,n,t.fs);if(e.path===null||t.fs.isDir(e.path))continue;let{text:r,bytes:i}=Hn(t.fs,e.path);if(i===void 0?r?.includes(`\0`):i.includes(0))return n}return null}function Cv(e,t,n,r,i){let a=t.literal?[`-F`]:[`-P`];t.ignoreCase&&a.push(`-i`),t.lineNumbers&&a.push(`-n`),t.word&&a.push(`-w`),t.invert&&a.push(`-v`),t.quiet&&a.push(`-q`),t.mode&&a.push(`-`+t.mode),t.showName&&a.push(`-`+t.showName),a.push(t.text?`-a`:`-I`),t.after&&a.push(`-A`,String(t.after)),t.before&&a.push(`-B`,String(t.before)),r.recursive&&a.push(`-r`),r.recursive&&!t.hidden&&a.push(`--exclude=.*`,`--exclude-dir=.[!.]*`,`--exclude-dir=..?*`),a.push(...$m(t.patterns,t.literal)),r.stdin||a.push(`--`,...n.length?n:[`.`]);let o=new Set(i.notes),s=H_(e,a,i);return delete s.events,kv(i.notes,o,r),Ov(wv(s,t),n,t.patterns)}function wv(e,t){if(t.mode!==`c`)return e;let n=e.stdout.split(`
161
161
  `).filter(e=>e!==``&&e!==`0`&&!e.endsWith(`:0`));return{...e,stdout:n.length?n.join(`
162
162
  `)+`
163
- `:``}}var Sv=new Map([[`No such file or directory`,2],[`Not a directory`,20],[`Is a directory`,21]]),Cv=e=>e.replaceAll(/^(rg: .*: )([A-Z][a-z].*)$/gmu,(e,t,n)=>Sv.has(n)?`${t}${n} (os error ${Sv.get(n)})`:e),wv=/^rg: (?:invalid pattern[^\n]*|trailing backslash)$/mu;function Tv(e,t,n){let r=e=>t.length?e:e.replaceAll(/^\.\//gmu,``),i={...e,stdout:r(e.stdout),stderr:Cv(r(e.stderr).replaceAll(/^grep: /gmu,`rg: `))},a=S(e);return a?.detail===`non-ASCII regex semantics`?C(`feature`,`rg`,`non-ASCII matching`,`rg: Unicode-aware matching on non-ASCII input is not supported`,2):a?C(a.kind,`rg`,a.detail,i.stderr.trimEnd()||a.message,e.exitCode):wv.test(i.stderr)?C(`feature`,`rg`,`regex parse error`,`rg: regex parse error in ${JSON.stringify(n.join(` `))}; the reason ripgrep gives is not reproduced here`,2):i}function Ev(e,t,n){let r=[];for(let n of e)!t.has(n)&&n.startsWith(`grep: excluded `)&&r.push(n);for(let t of r)e.delete(t),n.recursive&&e.add(t.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 Dv=6,Ov=` `,kv=` `.repeat(Dv+Ov.length);function Av(e,t,n){let{values:r,positional:i,order:a}=U(t,{valueShort:[`b`,`v`],valueLong:[`starting-line-number`]}),o=r.get(`b`)??`t`;if(![`a`,`t`,`n`].includes(o)){let e=`nl: -b: only \`a\`, \`t\` and \`n\` are supported (got \`${o}\`)`;return o.startsWith(`p`)?C(`option`,`nl`,`-b p`,e):x(e)}let s=1n;for(let{name:e,value:t}of a)if((e===`v`||e===`starting-line-number`)&&(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(t)||(s=BigInt(t),s<bn||s>yn)))return x(`nl: invalid starting line number: ${t}`);let c=Hn(`nl`,i,e,n);if(c.inputs.some(({content:e})=>/(?:^|\n)(?:\\:){1,3}(?:\n|$)/u.test(e)))return C(`feature`,`nl`,`logical pages`,`nl: logical page delimiters are not supported`);let l=[];for(let{content:e}of c.inputs)for(let t of jn(e))if(o===`a`||o===`t`&&t!==``){if(s>yn)return{stdout:Nn(l),stderr:c.stderr+`nl: line number overflow
164
- `,exitCode:1};l.push(`${String(s).padStart(Dv)}${Ov}${t}`),s++}else l.push(kv+t);return I(Nn(l),c)}function jv(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`s`],valueShort:[`d`,`f`,`c`]}),o=i.has(`f`),s=i.has(`c`);if(o===s)return We(`cut -f LIST [-d DELIM] [-s] [file...] | cut -c LIST [file...]`);if(s&&i.has(`d`))return x(`cut: -d is only valid with -f`);if(s&&r.has(`s`))return x(`cut: -s is only valid with -f`);let c=Fv(o?i.get(`f`):i.get(`c`),o?`field`:`position`);if(c.error)return c.error;let l=i.get(`d`)===``?`\0`:i.get(`d`)??` `;if(o&&p(l).length!==1)return x(`cut: -d delimiter must be a single byte`);let u=Hn(`cut`,a,e,n),d=[];for(let{content:e}of u.inputs)for(let t of o&&l===`
165
- `?e===``?[]:[e]:jn(e)){if(o&&!t.includes(l)){r.has(`s`)||d.push(t);continue}d.push(o?Lv(t,l,c.ranges):Mv(t,c.ranges))}return I(Nn(d),u)}function Mv(e,t){let n=p(e);return D(Uint8Array.from(Iv(n,t)))}var Nv={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`}},Pv=/^(\d*)(-?)(\d*)/u;function Fv(e,t){let n=Nv[t],r=e=>({error:x(`cut: ${e}`)}),i=[];for(let t of e.split(/[, \t]/u)){if(t===``)return r(n.zero);let[e,a,o,s]=Pv.exec(t),c=t.slice(e.length);if(c!==``)return r(c.startsWith(`-`)?n.range:n.value(c));for(let e of[a,s])if(e!==``&&BigInt(e)>xn)return r(n.large(e));if(a===``&&s===``&&o===``)return r(n.value(t));let l=a===``?1:Number(a),u=o===``?l:s===``?1/0:Number(s);if(l<1)return r(n.zero);if(u<l)return r(`invalid decreasing range`);i.push([l,u])}i.sort((e,t)=>e[0]-t[0]);let a=[];for(let e of i){let t=a.at(-1);t&&e[0]<=t[1]+1?t[1]=Math.max(t[1],e[1]):a.push(e)}return{ranges:a}}function Iv(e,t){return t.flatMap(([t,n])=>Array.from(e.slice(t-1,n)))}function Lv(e,t,n){return Iv(t===`
166
- `?jn(e):e.split(t),n).join(t)}function Rv(e,t,n){let{flags:r,positional:i}=U(t,{short:[`c`,`d`,`s`]}),a=r.has(`d`),o=r.has(`s`),s=r.has(`c`);if(a&&o)return C(`option`,`tr`,`-d -s`,`tr: -d combined with -s is not supported`);if(o&&!a&&i.length===2)return C(`feature`,`tr`,`translate and squeeze`,`tr: combined translation and squeezing is not supported`);let c=a||o?1:2;if(i.length!==c)return We(`tr [-c] SET1 SET2 | tr [-c] -d SET | tr [-c] -s SET`);if(/\P{ASCII}/u.test(e+i.join(``)))return C(`feature`,`tr`,`non-ASCII bytes`,`tr: translation of non-ASCII bytes is not supported`);if(i.some(e=>/\[[.=]/u.test(e)))return C(`feature`,`tr`,`set expressions`,`tr: equivalence classes and collating symbols are not supported`);if(i.some(e=>/\[[^\]]*\*/u.test(e)))return C(`feature`,`tr`,`repeat expressions`,`tr: repetition expressions in a set are not supported`);if(i.some(e=>/\\[0-7]{2}|\\[1-7abfrv]/u.test(e)))return C(`feature`,`tr`,`set escapes`,`tr: these set escape sequences are not supported`);if(i.some(e=>/(?:^|[^\\])(?:\\\\)*\\$/u.test(e)))return C(`feature`,`tr`,`trailing backslash`,`tr: an unescaped trailing backslash in a set is not supported`);let l=Uv(i[0]);if(l.error)return l.error;let u=new Set(l.chars),d=e=>s!==u.has(e);if(a)return F(n),b([...e].filter(e=>!d(e)).join(``));if(o)return F(n),b(Wv(e,d));let f=Uv(i[1]);if(f.error)return f.error;let p=Hv(l,f,s);if(p)return p;if(f.chars.length===0)return x(`tr: when not truncating set1, string2 must be non-empty`);F(n);let m=s?Array.from({length:256},(e,t)=>String.fromCodePoint(t)).filter(e=>!u.has(e)):l.chars,h=new Map,g=f.chars.at(-1);for(let e=0;e<m.length;e++)h.set(m[e],f.chars[e]??g);return b([...e].map(e=>h.get(e)??e).join(``))}var zv=Object.freeze(Object.fromEntries(Object.entries(Bt).filter(([e])=>e!==`word`).map(([e,t])=>[e,t.flatMap(([e,t])=>Array.from({length:t-e+1},(t,n)=>String.fromCodePoint(e+n)))]))),Bv={__proto__:null,lower:`upper`,upper:`lower`};function Vv(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 Hv(e,t,n){if(t.classes.find(e=>Bv[e.name]===void 0))return x(`tr: when translating, the only character classes that may appear in
167
- string2 are 'upper' and 'lower'`);let r=t=>e.classes.some(e=>e.name===Bv[t.name]&&e.start===t.start&&e.end===t.end);return!n&&t.classes.find(e=>!r(e))?x(`tr: misaligned [:upper:] and/or [:lower:] construct`):t.classes.some(e=>e.end===t.chars.length)&&(n||e.chars.length>t.chars.length)?x(`tr: when translating with string1 longer than string2,
163
+ `:``}}var Tv=new Map([[`No such file or directory`,2],[`Not a directory`,20],[`Is a directory`,21]]),Ev=e=>e.replaceAll(/^(rg: .*: )([A-Z][a-z].*)$/gmu,(e,t,n)=>Tv.has(n)?`${t}${n} (os error ${Tv.get(n)})`:e),Dv=/^rg: (?:invalid pattern[^\n]*|trailing backslash)$/mu;function Ov(e,t,n){let r=e=>t.length?e:e.replaceAll(/^\.\//gmu,``),i={...e,stdout:r(e.stdout),stderr:Ev(r(e.stderr).replaceAll(/^grep: /gmu,`rg: `))},a=S(e);return a?.detail===`non-ASCII regex semantics`?C(`feature`,`rg`,`non-ASCII matching`,`rg: Unicode-aware matching on non-ASCII input is not supported`,2):a?C(a.kind,`rg`,a.detail,i.stderr.trimEnd()||a.message,e.exitCode):Dv.test(i.stderr)?C(`feature`,`rg`,`regex parse error`,`rg: regex parse error in ${JSON.stringify(n.join(` `))}; the reason ripgrep gives is not reproduced here`,2):i}function kv(e,t,n){let r=[];for(let n of e)!t.has(n)&&n.startsWith(`grep: excluded `)&&r.push(n);for(let t of r)e.delete(t),n.recursive&&e.add(t.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 Av=6,jv=` `,Mv=` `.repeat(Av+jv.length);function Nv(e,t,n){let{values:r,positional:i,order:a}=U(t,{valueShort:[`b`,`v`],valueLong:[`starting-line-number`]}),o=r.get(`b`)??`t`;if(![`a`,`t`,`n`].includes(o)){let e=`nl: -b: only \`a\`, \`t\` and \`n\` are supported (got \`${o}\`)`;return o.startsWith(`p`)?C(`option`,`nl`,`-b p`,e):x(e)}let s=1n;for(let{name:e,value:t}of a)if((e===`v`||e===`starting-line-number`)&&(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(t)||(s=BigInt(t),s<xn||s>bn)))return x(`nl: invalid starting line number: ${t}`);let c=Un(`nl`,i,e,n);if(c.inputs.some(({content:e})=>/(?:^|\n)(?:\\:){1,3}(?:\n|$)/u.test(e)))return C(`feature`,`nl`,`logical pages`,`nl: logical page delimiters are not supported`);let l=[];for(let{content:e}of c.inputs)for(let t of Mn(e))if(o===`a`||o===`t`&&t!==``){if(s>bn)return{stdout:Pn(l),stderr:c.stderr+`nl: line number overflow
164
+ `,exitCode:1};l.push(`${String(s).padStart(Av)}${jv}${t}`),s++}else l.push(Mv+t);return Jn(Pn(l),c)}function Pv(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`s`],valueShort:[`d`,`f`,`c`]}),o=i.has(`f`),s=i.has(`c`);if(o===s)return Ge(`cut -f LIST [-d DELIM] [-s] [file...] | cut -c LIST [file...]`);if(s&&i.has(`d`))return x(`cut: -d is only valid with -f`);if(s&&r.has(`s`))return x(`cut: -s is only valid with -f`);let c=Rv(o?i.get(`f`):i.get(`c`),o?`field`:`position`);if(c.error)return c.error;let l=i.get(`d`)===``?`\0`:i.get(`d`)??` `;if(o&&p(l).length!==1)return x(`cut: -d delimiter must be a single byte`);let u=Un(`cut`,a,e,n),d=[];for(let{content:e}of u.inputs)for(let t of o&&l===`
165
+ `?e===``?[]:[e]:Mn(e)){if(o&&!t.includes(l)){r.has(`s`)||d.push(t);continue}d.push(o?Bv(t,l,c.ranges):Fv(t,c.ranges))}return Jn(Pn(d),u)}function Fv(e,t){let n=p(e);return D(Uint8Array.from(zv(n,t)))}var Iv={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`}},Lv=/^(\d*)(-?)(\d*)/u;function Rv(e,t){let n=Iv[t],r=e=>({error:x(`cut: ${e}`)}),i=[];for(let t of e.split(/[, \t]/u)){if(t===``)return r(n.zero);let[e,a,o,s]=Lv.exec(t),c=t.slice(e.length);if(c!==``)return r(c.startsWith(`-`)?n.range:n.value(c));for(let e of[a,s])if(e!==``&&BigInt(e)>Sn)return r(n.large(e));if(a===``&&s===``&&o===``)return r(n.value(t));let l=a===``?1:Number(a),u=o===``?l:s===``?1/0:Number(s);if(l<1)return r(n.zero);if(u<l)return r(`invalid decreasing range`);i.push([l,u])}i.sort((e,t)=>e[0]-t[0]);let a=[];for(let e of i){let t=a.at(-1);t&&e[0]<=t[1]+1?t[1]=Math.max(t[1],e[1]):a.push(e)}return{ranges:a}}function zv(e,t){return t.flatMap(([t,n])=>Array.from(e.slice(t-1,n)))}function Bv(e,t,n){return zv(t===`
166
+ `?Mn(e):e.split(t),n).join(t)}function Vv(e,t,n){let{flags:r,positional:i}=U(t,{short:[`c`,`d`,`s`]}),a=r.has(`d`),o=r.has(`s`),s=r.has(`c`);if(a&&o)return C(`option`,`tr`,`-d -s`,`tr: -d combined with -s is not supported`);if(o&&!a&&i.length===2)return C(`feature`,`tr`,`translate and squeeze`,`tr: combined translation and squeezing is not supported`);let c=a||o?1:2;if(i.length!==c)return Ge(`tr [-c] SET1 SET2 | tr [-c] -d SET | tr [-c] -s SET`);if(/\P{ASCII}/u.test(e+i.join(``)))return C(`feature`,`tr`,`non-ASCII bytes`,`tr: translation of non-ASCII bytes is not supported`);if(i.some(e=>/\[[.=]/u.test(e)))return C(`feature`,`tr`,`set expressions`,`tr: equivalence classes and collating symbols are not supported`);if(i.some(e=>/\[[^\]]*\*/u.test(e)))return C(`feature`,`tr`,`repeat expressions`,`tr: repetition expressions in a set are not supported`);if(i.some(e=>/\\[0-7]{2}|\\[1-7abfrv]/u.test(e)))return C(`feature`,`tr`,`set escapes`,`tr: these set escape sequences are not supported`);if(i.some(e=>/(?:^|[^\\])(?:\\\\)*\\$/u.test(e)))return C(`feature`,`tr`,`trailing backslash`,`tr: an unescaped trailing backslash in a set is not supported`);let l=Kv(i[0]);if(l.error)return l.error;let u=new Set(l.chars),d=e=>s!==u.has(e);if(a)return F(n),b([...e].filter(e=>!d(e)).join(``));if(o)return F(n),b(qv(e,d));let f=Kv(i[1]);if(f.error)return f.error;let p=Gv(l,f,s);if(p)return p;if(f.chars.length===0)return x(`tr: when not truncating set1, string2 must be non-empty`);F(n);let m=s?Array.from({length:256},(e,t)=>String.fromCodePoint(t)).filter(e=>!u.has(e)):l.chars,h=new Map,g=f.chars.at(-1);for(let e=0;e<m.length;e++)h.set(m[e],f.chars[e]??g);return b([...e].map(e=>h.get(e)??e).join(``))}var Hv=Object.freeze(Object.fromEntries(Object.entries(Vt).filter(([e])=>e!==`word`).map(([e,t])=>[e,t.flatMap(([e,t])=>Array.from({length:t-e+1},(t,n)=>String.fromCodePoint(e+n)))]))),Uv={__proto__:null,lower:`upper`,upper:`lower`};function Wv(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 Gv(e,t,n){if(t.classes.find(e=>Uv[e.name]===void 0))return x(`tr: when translating, the only character classes that may appear in
167
+ string2 are 'upper' and 'lower'`);let r=t=>e.classes.some(e=>e.name===Uv[t.name]&&e.start===t.start&&e.end===t.end);return!n&&t.classes.find(e=>!r(e))?x(`tr: misaligned [:upper:] and/or [:lower:] construct`):t.classes.some(e=>e.end===t.chars.length)&&(n||e.chars.length>t.chars.length)?x(`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?x(`tr: when translating with complemented character classes,
169
- string2 must map all characters in the domain to one`):null}function Uv(e){let t=[],n=[],r=0,i=()=>{if(e[r]!==`\\`)return e[r++];if(r+1>=e.length)return null;let t=e[r+1];return r+=2,t===`n`?`
170
- `:t===`t`?` `:t===`\\`?`\\`:t===`0`?`\0`:t};for(;r<e.length;){let a=Vv(e,r);if(a){if(a.name===``)return{error:x(`tr: missing character class name '${a.text}'`)};let e=zv[a.name];if(e===void 0)return{error:x(`tr: invalid character class '${a.name}'`)};n.push({name:a.name,start:t.length,end:t.length+e.length}),t.push(...e),r=a.next;continue}let o=i();if(e[r]===`-`&&r+1<e.length){r++;let e=i();if(e===null)return{error:x(`tr: trailing backslash in set`)};let n=o.codePointAt(0),a=e.codePointAt(0);if(a<n)return{error:x(`tr: range-endpoints of '${o}-${e}' are in reverse collating sequence order`)};for(let e=n;e<=a;e++)t.push(String.fromCodePoint(e))}else t.push(o)}return{chars:t,classes:n}}function Wv(e,t){let n=``,r=null;for(let i of e)t(i)&&i===r||(n+=i,r=i);return n}var Gv=e=>e.text??D(e.bytes),Kv=(e,t)=>{e.bytes===void 0?t.write(e.text):t.writeBytes(e.bytes)},qv=e=>e.events??[...e.stdout?[{fd:1,text:e.stdout}]:[],...e.stderr?[{fd:2,text:e.stderr}]:[]],Jv=e=>e.unordered??(!e.events&&e.stdout!==``&&e.stderr!==``),G=(e=``)=>({stdout:``,stderr:e,exitCode:0,ignored:!1,events:e?[{fd:2,text:e}]:[],unordered:!1});function K(e,t){e.stdout+=t.stdout,e.stderr+=t.stderr,e.exitCode=t.exitCode,e.ignored=t.ignored??!1,e.events.push(...qv(t)),e.unordered||=Jv(t)}function Yv(e,t){t&&K(e.expansionOutput,Xv(G(t),{fds:e.expansionFds},e))}function Xv(e,t,n){let r=r=>Zv(e,t,n,r);return n.io?n.io.output(e,t,r):r(Kv)}function Zv(e,t,n,r){let i=e,a=t.fds[1],o=t.fds[2];(a===o&&a!==`null`&&a!==`closed`||(a?.identity&&o?.identity?a.identity===o.identity:a?.path&&a.path===o?.path))&&Jv(i)&&(i=C(`feature`,null,`combined output ordering`,`error: merging this command’s stdout and stderr in order is not supported`),n.unsupported.add(S(i)));let s=[],c=``,l=``;for(let e of qv(i)){let i=t.fds[e.fd];if(typeof i==`object`){r(e,i);continue}if(t.deferred?.[e.fd]&&e.bytes!==void 0){s.push(e);continue}if(i!==`out`&&i!==`err`){e.fd===2&&Tn(n,Gv(e));continue}let a=Gv(e);s.push({fd:i===`out`?1:2,text:a}),i===`out`?l+=a:c+=a}return{...i,stdout:l,stderr:c,events:s,unordered:Jv(i)&&l!==``&&c!==``}}var Qv=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]]),$v=e=>e.stdout!==``||qv(e).some(e=>e.fd===1&&(e.bytes?.length??0)>0);function ey(e,t,n){return n.closed.out&&$v(t)?ty(e,t,n):t}function ty(e,t,n){let r=Qv.get(n.registry.resolveCommand(e))??1,i=qv(t).filter(e=>e.fd!==1),a=r===0?``:`${e}: write error: Bad file descriptor
171
- `;a&&i.push({fd:2,text:a});let o={...t,stdout:``,stderr:t.stderr+a,exitCode:r||t.exitCode,events:i,unordered:!1},s=S(t);return s?w(o,s.kind,s.command,s.detail,s.message):o}var ny=new Map([[`\0`,`0`],[`\x07`,`a`],[`\b`,`b`],[`\f`,`f`],[`
172
- `,`n`],[`\r`,`r`],[` `,`t`],[`\v`,`v`]]);function q(e,t){let n=en(t),r=n?Array.from(E(e),e=>String.fromCodePoint(e)):[...e];if(!n&&r.some(e=>e.codePointAt(0)>127&&/[\p{C}\p{Zl}\p{Zp}]/u.test(e)))throw new T(`feature`,`filename quoting`,`quoting nonprinting Unicode filenames is not supported`);if(e.includes(`'`)&&r.every(e=>/[-a-zA-Z0-9 %+,./:_\]']/u.test(e)||!n&&e.codePointAt(0)>127))return`"`+e+`"`;let i=!1,a=`'`;for(let e of r){let t=e.codePointAt(0),r=ny.get(e)??(t<32||t===127||n&&t>127?t.toString(8).padStart(3,`0`):null);r===null?e===`'`?(a+=`'\\''`,i=!1):(i&&(a+=`''`),i=!1,a+=e):(i||(a+=`'$'`),i=!0,a+=`\\`+r)}return a+`'`}var ry=/^[#%+,\-./0-9@A-Z\]_a-z{}~]+$/u;function iy(e,t){return ry.test(e)&&!`#~`.includes(e[0])?e:q(e,t)}var ay=new Map([[`\x07`,`a`],[`\b`,`b`],[`\f`,`f`],[`
173
- `,`n`],[`\r`,`r`],[` `,`t`],[`\v`,`v`],[`"`,`"`],[`\\`,`\\`]]);function oy(e,t){let n=en(t),r=``,i=!1;for(let t of e){let e=t.codePointAt(0),a=ay.get(t);if(a!==void 0)r+=`\\`+a,i=!0;else if(t===` `)r+=t,i=!0;else if(e<32||e===127||e>127&&(n||/[\p{C}\p{Zl}\p{Zp}]/u.test(t))){for(let e of p(t))r+=`\\`+e.toString(8).padStart(3,`0`);i=!0}else r+=t}return i?`"${r}"`:e}var sy=new Set([`/dev/null`,`/dev/stdin`,`/dev/stdout`,`/dev/stderr`]);function cy(e,t,n){let r=U(t,{short:[`f`,`n`,`v`,`T`,`r`,`R`],long:[`force`,`no-clobber`,`verbose`,`no-target-directory`,`recursive`],valueShort:[`t`],valueLong:[`target-directory`]}),i=ly(r,n);if(i.error)return x(`cp: `+i.error);let{sources:a,target:o,directory:s}=i,{flags:c}=r,l=c.has(`v`)||c.has(`verbose`),u=c.has(`r`)||c.has(`R`)||c.has(`recursive`),d=a.map(e=>[e,s?o.replace(/\/+$/u,``)+`/`+hy(e):o]),f=c.has(`n`)||c.has(`no-clobber`),p={ctx:n,result:G(),failed:!1,sources:new Set,copied:new Set,noClobber:f,force:c.has(`f`)||c.has(`force`),verbose:l,recursive:u,outputOverlap:l&&Sy(d,n,{recursive:u,noClobber:f})};for(let[e,t]of d){n.io.setReads([]);try{gy(e,t,p)}catch(e){P(n,`cp`,e?.path,e?.fsError);let t=S(e),r=`cp: `+L(e);if(t)return n.unsupported.add({...t,command:t.command??`cp`,message:r}),K(p.result,x(r)),p.result;jy(p,r+`
174
- `,!0)}}return p.result.exitCode=+!!p.failed,p.result}function ly({positional:e,flags:t,order:n},r){let i=n.filter(({name:e})=>e===`t`||e===`target-directory`);if(i.length>1)return{error:`multiple target directories specified`};let a=i[0]?.value,o=t.has(`T`)||t.has(`no-target-directory`);if(e.length===0)return{error:`missing file operand`};if(a===void 0&&e.length===1)return{error:`missing destination file operand after `+q(e[0],r)};if(a!==void 0&&o)return{error:`cannot combine --target-directory (-t) and --no-target-directory (-T)`};if(o&&e.length>2)return{error:`extra operand `+q(e[2],r)};let s=a??e.at(-1),c=k(r.cwd,s,r.fs),l=!o&&r.fs.isDir(c.path);return!l&&(a!==void 0||e.length>2)?(P(r,`cp`,s,c.error),{error:`${a===void 0?`target`:`target directory`} ${q(s,r)}: ${c.error??`Not a directory`}`}):{target:s,directory:l,sources:a===void 0?e.slice(0,-1):e}}function uy(e,t,n){let{ctx:r}=n,i=k(r.cwd,e,r.fs,{follow:!1}).path;if(i===null)return;let a=e.replace(/\/+$/u,``),o=t.replace(/\/+$/u,``);for(let s of bt(r.fs,i)){if(s.kind!==`link`)continue;let r=s.path===i?null:_t(i,s.path);if(!dy(r===null?t:`${o}/${r}`,n)&&!(r!==null&&fy(o,r,n)))throw py(r===null?e:`${a}/${r}`)}}var dy=(e,t)=>t.noClobber&&k(t.ctx.cwd,e,t.ctx.fs,{follow:!1}).path!==null;function fy(e,t,n){let{ctx:r}=n,i=t.split(`/`);for(let t=1;t<i.length;t++){let n=k(r.cwd,`${e}/${i.slice(0,t).join(`/`)}`,r.fs,{follow:!1});if(n.path!==null&&!r.fs.isDir(n.path))return!0}return!1}var py=e=>new T(`feature`,`symbolic link`,`copying a symbolic link is not supported: ${e} (a recursive copy keeps the link, which cp does not make here)`),my=(e,t,n)=>n.path===null&&e.fs.isLink?.(k(e.cwd,t,e.fs,{follow:!1}).path)===!0,hy=e=>{let t=e.replace(/\/+$/u,``).split(`/`).at(-1);return t===`..`?`.`:t};function gy(e,t,n,r=null){let{ctx:i}=n;if(Ay(e,i.cwd)||Ay(t,i.cwd))throw new T(`feature`,`special file`,`copying special files is not supported`);let a=q(e,i),o=q(t,i);if(n.recursive&&i.fs.isLink?.(k(i.cwd,e,i.fs,{follow:!1}).path)){if(!dy(t,n))throw py(e);return}let s=N(i,`cp`,e),c=e=>jy(n,`cp: `+e+`
175
- `,!0);if(s.error)return c(`cannot stat ${a}: ${s.error}`);if(i.fs.isDir(s.path))return n.recursive?_y(e,s.path,t,n,r??{source:a,target:o},r===null):c(`-r not specified; omitting directory ${a}`);if(r===null){if(n.sources.has(s.path))return jy(n,`cp: warning: source file ${a} specified more than once
176
- `,!1,!0);n.sources.add(s.path)}let l=k(i.cwd,t,i.fs);if(l.error&&l.error!==`No such file or directory`)return c(`cannot stat ${o}: ${l.error}`);if(n.noClobber&&l.path!==null)return;if(xy(s.path,l.path,i.fs))return c(`${a} and ${o} are the same file`);if(i.fs.isDir(l.path))return c(`cannot overwrite directory ${o} with non-directory ${a}`);let u=pt(i.fs,i.cwd,t);if(r===null&&n.copied.has(u))return c(`will not overwrite just-created ${o} with ${a}`);let d=mt(i.cwd,t,i.fs,l);if(yy(a,o,n),my(i,t,l))return c(`not writing through dangling symlink ${o}`);if(d)return P(i,`cp`,t,d),c(`cannot create regular file ${o}: ${d}`);try{if(!i.fs.copyWritable?.(i.cwd,s.path,t))return c(`${n.force&&l.path!==null?`cannot remove`:`cannot create regular file`} ${o}: Read-only file system`)}catch(e){if(S(e))throw e;P(i,`cp`,e?.path,e?.fsError);let n=L(e);return c(`cannot create regular file ${o}: ${n.startsWith(t+`: `)?n.slice(t.length+2):n}`)}r===null&&n.copied.add(u)}function _y(e,t,n,r,i,a){let{ctx:o}=r,s=q(e,o),c=q(n,o),l=e=>jy(r,`cp: `+e+`
177
- `,!0),u=k(o.cwd,n,o.fs,{follow:!1});if(u.error&&u.error!==`No such file or directory`)return l(`cannot stat ${c}: ${u.error}`);let d=n.replace(/\/+$/u,``)||n;if(pt(o.fs,o.cwd,d,!0)===t)return l(`${s} and ${c} are the same file`);if(u.path!==null&&!o.fs.isDir(u.path))return l(`cannot overwrite non-directory ${c} with directory ${s}`);let f=pt(o.fs,o.cwd,d,!1);if(u.path===null){let e=mt(o.cwd,d,o.fs);if(e)return P(o,`cp`,d,e),l(`cannot create directory ${c}: ${e}`);if(!o.writable||!R(f))return l(`cannot create directory ${c}: Read-only file system`)}if(f.startsWith(t===`/`?`/`:t+`/`))return l(`cannot copy a directory, ${i.source}, into itself, ${i.target}`);if(a){if(r.sources.has(t))return jy(r,`cp: warning: source directory ${s} specified more than once
178
- `,!1,!0);r.sources.add(t)}a&&uy(e,n,r);let{dirs:p,files:m,links:h}=o.fs.listDir(t);if(u.path===null&&!vy(e,n,d,f,r))return;let g=e.replace(/\/+$/u,``),_=n.replace(/\/+$/u,``);for(let e of[...p,...m,...h].sort(j))o.io.setReads([]),gy(`${g}/${e}`,`${_}/${e}`,r,i)}function vy(e,t,n,r,i){let{ctx:a}=i,o=q(t,a),s=e=>(jy(i,`cp: cannot create directory `+o+`: `+e+`
179
- `,!0),!1),c=a.writable&&R(r);c&&by(i);try{if(!c||!a.fs.makeWritableDir?.(a.cwd,n))return s(`Read-only file system`)}catch(e){if(S(e))throw e;P(a,`cp`,e?.path,e?.fsError);let t=L(e);return s(t.startsWith(n+`: `)?t.slice(n.length+2):t)}return yy(q(e,a),o,i),!0}function yy(e,t,n){n.verbose&&(by(n),jy(n,`${e} -> ${t}
180
- `))}function by(e){if(e.outputOverlap)throw new T(`feature`,`copy output buffering`,`buffered verbose output sharing a copied file is not supported`)}function xy(e,t,n){if(e===t)return!0;let r=n.fileIdentity?.(e);return r!==void 0&&r===n.fileIdentity(t)}function Sy(e,t,{recursive:n,noClobber:r}){let i=t.outputFds[1];if(typeof i!=`object`)return!1;let a={ctx:t,recursive:n,noClobber:r,holds:e=>i.identity===void 0?i.path===e:i.identity===t.fs.fileIdentity?.(e),made:new Set,sources:new Set,copied:new Set};return e.some(([e,t])=>Cy(e,t,a))}function Cy(e,t,n){let{ctx:r}=n,i=k(r.cwd,e,r.fs),a=i.path??O(r.cwd,e),o=i.error===`No such file or directory`&&(n.made.has(a)||Ey(a,n));if(i.error&&!o)return!1;let s=pt(r.fs,r.cwd,t);return(i.error===null?r.fs.isDir(i.path):!n.made.has(a))?!n.recursive||!ky(a,t,r)||n.sources.has(a)?!1:(n.sources.add(a),wy(a,s,n)):n.sources.has(a)||(n.sources.add(a),n.copied.has(s)||!Oy(a,s,t,r,n.noClobber))?!1:(n.copied.add(s),n.made.add(s),n.holds(a)||n.holds(s))}function wy(e,t,n){let{ctx:r}=n,i=e===`/`?0:e.length;for(let a of Ty(e,n)){let e=t+a.slice(i);if(!Dy(a,e,k(r.cwd,e,r.fs),r,n.noClobber)&&(n.made.add(e),n.holds(a)||n.holds(e)))return!0}return!1}function Ty(e,t){let n=e===`/`?`/`:e+`/`,r=t.ctx.fs.isDir(e)?[...t.ctx.fs.walkFiles(e)]:[];return new Set([...r,...[...t.made].filter(e=>e.startsWith(n))])}var Ey=(e,t)=>[...t.made].some(t=>t.startsWith(e+`/`));function Dy(e,t,n,r,i){return n.error&&n.error!==`No such file or directory`||i&&n.path!==null||xy(e,n.path,r.fs)||r.fs.isDir(n.path)?!0:!r.writable||!R(t)}function Oy(e,t,n,r,i){let a=k(r.cwd,n,r.fs);return!Dy(e,t,a,r,i)&&!my(r,n,a)&&!mt(r.cwd,n,r.fs,a)}function ky(e,t,n){let r=k(n.cwd,t,n.fs,{follow:!1});if(r.error&&r.error!==`No such file or directory`)return!1;let i=t.replace(/\/+$/u,``)||t;if(r.path!==null&&!n.fs.isDir(r.path)||r.path===null&&mt(n.cwd,i,n.fs))return!1;let a=pt(n.fs,n.cwd,i,!1);return pt(n.fs,n.cwd,i,!0)===e||a.startsWith(e===`/`?`/`:e+`/`)?!1:!!n.writable&&R(a)}function Ay(e,t){let n=e.startsWith(`/`)?e:t+`/`+e;return sy.has(n.replace(/\/\.(?=\/)/gu,``).replace(/\/+/gu,`/`))}function jy(e,t,n=!1,r=!1){let i=n||r?G(t):{...G(),stdout:t,events:[{fd:1,text:t}]};K(e.result,e.ctx.flushOutput(i)),e.failed||=n}function My(e,t,n){let{flags:r,positional:i}=U(t,{short:[`f`,`v`,`r`,`R`],long:[`force`,`verbose`,`recursive`]}),a=r.has(`f`)||r.has(`force`),o=r.has(`v`)||r.has(`verbose`),s=r.has(`r`)||r.has(`R`)||r.has(`recursive`);if(i.length===0)return a?b(``):x(`rm: missing operand`);let c={ctx:n,force:a,verbose:o,recursive:s,events:[],stdout:``,stderr:``};try{for(let e of i)Ny(e,c)}catch(e){P(n,`rm`,e?.path,e?.fsError);let t=Ke(e,`rm`,`rm: `+L(e));return t.events=[...c.events,{fd:2,text:t.stderr}],t.stdout=c.stdout,t.stderr=c.stderr+t.stderr,t}return{stdout:c.stdout,stderr:c.stderr,events:c.events,exitCode:+!!c.stderr}}function Ny(e,t){let{ctx:n}=t,r=k(n.cwd,e,n.fs,{follow:!1}),i=r.error;if(!t.force||i!==`No such file or directory`&&i!==`Not a directory`){if(P(n,`rm`,e,i),i===null&&n.fs.isDir(r.path)){if(!t.recursive)i=`Is a directory`;else{if([`.`,`..`].includes(e.replace(/\/+$/u,``).split(`/`).at(-1)))return Ly(t,`rm: refusing to remove '.' or '..' directory: skipping ${q(e,n)}
181
- `);if(r.path===`/tmp`)i=`Device or resource busy`;else if(!n.writable||!R(r.path))i=`Read-only file system`;else return Fy(e,r.path,t,Py(n,e)?`Not a directory`:null)}}Iy(e,r.path,t,!1,i)}}function Py(e,t){let n=t.replace(/\/+$/u,``);return n===t||n===``?!1:e.fs.isLink?.(k(e.cwd,n,e.fs,{follow:!1}).path)===!0}function Fy(e,t,n,r=null){let{ctx:i}=n,{dirs:a,files:o,links:s=[]}=i.fs.listDir(t),c=e.replace(/\/+$/u,``);for(let e of[...a,...o,...s].sort(j)){let r=gt(t,e);i.fs.isDir(r)?Fy(`${c}/${e}`,r,n):Iy(`${c}/${e}`,r,n,!1,null)}Iy(e,t,n,!0,r)}function Iy(e,t,n,r,i){let{ctx:a}=n,o=n.verbose||i!==null||!a.writable||!t?.startsWith(`/tmp/`)?q(e,a):``,s=()=>r?a.fs.removeWritableDir?.(a.cwd,e):a.fs.removeWritable?.(a.cwd,e);try{i===null&&!s()&&(i=`Read-only file system`)}catch(t){if(S(t))throw t;P(a,`rm`,t?.path,t?.fsError);let n=L(t);i=t?.fsError??(n.startsWith(e+`: `)?n.slice(e.length+2):n)}if(i)return Ly(n,`rm: cannot remove ${o}: ${i}
182
- `);n.verbose&&Ly(n,`removed ${r?`directory `:``}${o}
183
- `,1)}function Ly(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Ry(e,t,n){let{flags:r,positional:i}=U(t,{short:[`p`,`v`],long:[`parents`,`verbose`]});if(i.length===0)return x(`mkdir: missing operand`);let a={ctx:n,events:[],stdout:``,stderr:``,parents:r.has(`p`)||r.has(`parents`),verbose:r.has(`v`)||r.has(`verbose`)};try{for(let e of i)a.parents?zy(e,a):By(e,a,!0)}catch(e){P(n,`mkdir`,e?.path,e?.fsError);let t=Ke(e,`mkdir`,`mkdir: `+L(e));return t.events=[...a.events,{fd:2,text:t.stderr}],t.stdout=a.stdout,t.stderr=a.stderr+t.stderr,t}return{stdout:a.stdout,stderr:a.stderr,events:a.events,exitCode:+!!a.stderr}}function zy(e,t){let n=e.split(`/`),r=[];for(let e=0;e<n.length;e++)n[e]!==``&&r.push(n.slice(0,e+1).join(`/`));if(r.length===0){e===``&&By(e,t,!0);return}r[r.length-1]=e;for(let[e,n]of r.entries())if(!By(n,t,e===r.length-1))return}function By(e,t,n){let{ctx:r}=t,i=q(e,r),a=e=>(Vy(t,`mkdir: cannot create directory ${i}: ${e}
184
- `),!1),o=e.replace(/\/+$/u,``)||e,s=k(r.cwd,o,r.fs);if(s.error===null)return t.parents?r.fs.isDir(s.path)?!0:a(n?`File exists`:`Not a directory`):a(`File exists`);if(k(r.cwd,o,r.fs,{follow:!1}).error===null)return a(!t.parents||n||s.error!==`Not a directory`?`File exists`:`Not a directory`);let c=mt(r.cwd,o,r.fs,s);if(c)return P(r,`mkdir`,o,c),a(c);try{if(!r.fs.makeWritableDir?.(r.cwd,o))return a(`Read-only file system`)}catch(e){if(S(e))throw e;P(r,`mkdir`,e?.path,e?.fsError);let t=L(e);return a(t.startsWith(o+`: `)?t.slice(o.length+2):t)}return t.verbose&&Vy(t,`mkdir: created directory ${i}
185
- `,1),!0}function Vy(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Hy(e,t,n){let{flags:r,positional:i}=U(t,{short:[`c`],long:[`no-create`]});if(i.length===0)return x(`touch: missing file operand`);let a=r.has(`c`)||r.has(`no-create`),o={ctx:n,stderr:``,failed:!1,gap:null};for(let e of i)Uy(e,a,o);let s={stdout:``,stderr:o.stderr,exitCode:+!!o.failed};return o.gap?w(s,`feature`,`touch`,`times`,o.gap):s}function Uy(e,t,n){let{ctx:r}=n,i=q(e,r),a=k(r.cwd,e,r.fs);if(a.error===null)return Wy(e,i,a.path,n);let o=t||e.endsWith(`/`);if(t&&a.error===`No such file or directory`)return;if(P(r,`touch`,e,a.error),o)return Gy(n,`setting times of ${i}: ${a.error}`);let s=mt(r.cwd,e,r.fs,a);if(s)return Gy(n,`cannot touch ${i}: ${s}`);try{r.fs.openWritable?.(r.cwd,e,!0)||Gy(n,`cannot touch ${i}: Read-only file system`)}catch(t){if(S(t))throw t;P(r,`touch`,t?.path,t?.fsError);let a=L(t);Gy(n,`cannot touch ${i}: ${a.startsWith(e+`: `)?a.slice(e.length+2):a}`)}}function Wy(e,t,n,r){let{ctx:i}=r;if(!i.writable||!R(n))return Gy(r,`setting times of ${t}: Read-only file system`);let a=`touch: setting the times of ${t} is not supported (every entry here carries the one time this filesystem keeps)`;r.gap??=a,r.stderr+=a+`
186
- `,r.failed=!0}function Gy(e,t){e.stderr+=`touch: ${t}
187
- `,e.failed=!0}function Ky(e,t,n,r){if(t===``||t.includes(`\0`))return{error:`No such file or directory`};if(r===`none`)return qy(e,t,n);let i=t;if(r===`logical`){let r=n===`m`?{path:O(e.cwd,t)}:Jy(e,t);if(r.error)return r;i=r.path+(t.endsWith(`/`)?`/`:``)}let a=ft(e.cwd,i,e.fs,{lenient:n===`m`});return n===`m`?{path:a.rest.length?O(a.path,a.rest.join(`/`)):a.path}:a.error===`No such file or directory`&&a.rest.length===0&&n!==`e`?{path:a.path}:a.error?{error:a.error}:t.endsWith(`/`)&&!e.fs.isDir(a.path)?{error:`Not a directory`}:{path:a.path}}function qy(e,t,n){if(n===`m`)return{path:O(e.cwd,t)};let r=Jy(e,t);if(r.error||n!==`e`)return r;let i=k(`/`,r.path,e.fs);return i.error?{error:i.error}:r}function Jy(e,t){let n=(t.startsWith(`/`)?t:e.cwd+`/`+t).split(`/`).filter(Boolean),r=`/`;for(let i=0;i<n.length;i++){let a=n[i];if(a===`..`)r=A(r);else if(a!==`.`){r=gt(r,a);let o=i+1;for(;n[o]===`.`;)o++;let s=n[o]===`..`||o===n.length&&(i<n.length-1||t.endsWith(`/`));if(s||i===n.length-1){let t=k(`/`,r+(s?`/`:``),e.fs);if(t.error&&(t.error!==`No such file or directory`||i!==n.length-1))return t}}}return{path:r}}function Yy(e,t){let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return[...n.slice(i).map(()=>`..`),...r.slice(i)].join(`/`)||`.`}var Xy=(e,t)=>e===`/`||t===e||t.startsWith(e+`/`),Zy={e:`e`,"canonicalize-existing":`e`,m:`m`,"canonicalize-missing":`m`},Qy={P:`physical`,physical:`physical`,L:`logical`,logical:`logical`,s:`none`,strip:`none`,"no-symlinks":`none`};function $y(e,t,n,r){let i=t.get(`relative-base`),a=t.get(`relative-to`)??i,o={};for(let[t,s]of[[`target`,a],[`base`,i]]){if(s===void 0)continue;let i=Ky(e,s,n,r),a=i.error??(n===`e`&&!e.fs.isDir(i.path)?`Not a directory`:null);if(a)return P(e,`realpath`,s,a),{error:x(`realpath: ${iy(s,e)}: ${a}`)};o[t]=i.path}return o.base&&!Xy(o.base,o.target)&&delete o.target,o}function eb(e,t,n){let{flags:r,values:i,positional:a,order:o}=U(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(!a.length)return x(`realpath: missing operand`);let s=`physical`,c=`E`;for(let{name:e}of o)Object.hasOwn(Zy,e)&&(c=Zy[e]),Object.hasOwn(Qy,e)&&(s=Qy[e]);let l=$y(n,i,c,s);if(l.error)return l.error;let u=r.has(`q`)||r.has(`quiet`),d=r.has(`z`)||r.has(`zero`)?`\0`:`
188
- `,f=G(),p=!1;for(let e of a){let t=Ky(n,e,c,s);t.error?(P(n,`realpath`,e,t.error),u||K(f,x(`realpath: ${iy(e,n)}: ${t.error}`)),p=!0):K(f,b((l.target&&(!l.base||Xy(l.base,t.path))?Yy(l.target,t.path):t.path)+d))}return f.exitCode=+!!p,f}var tb={symbolic:`s`,force:`f`,"no-dereference":`n`,"no-target-directory":`T`,verbose:`v`,relative:`r`,logical:`L`,physical:`P`};function nb(e,t,n){let r=U(t,{short:Object.values(tb),long:Object.keys(tb),valueShort:[`t`],valueLong:[`target-directory`]}),i=e=>r.flags.has(e)||r.flags.has(Object.keys(tb).find(t=>tb[t]===e)),a={force:i(`f`),noDereference:i(`n`),noTargetDirectory:i(`T`),verbose:i(`v`),relative:i(`r`)},o=r.order.findLast(({name:e})=>e===`t`||e===`target-directory`)?.value??null,s=r.positional;if(o!==null&&a.noTargetDirectory)return x(`ln: cannot combine --target-directory and --no-target-directory`);if(a.relative&&!i(`s`))return x(`ln: cannot do --relative without --symbolic`);if(s.length===0)return x(`ln: missing file operand`);if(!i(`s`))return C(`feature`,`ln`,`hard link`,`ln: hard links are not supported: ${q(s[0],n)} (ln -s makes a symbolic one)`);let c={ctx:n,events:[],stdout:``,stderr:``};try{let e=rb(s,o,a,n);if(e.error)return e.error;for(let[t,n,r]of e)ab(t,n,a,c,r)}catch(e){P(n,`ln`,e?.path,e?.fsError);let t=Ke(e,`ln`,`ln: `+L(e));return t.events=[...c.events,{fd:2,text:t.stderr}],t.stdout=c.stdout,t.stderr=c.stderr+t.stderr,t}return{stdout:c.stdout,stderr:c.stderr,events:c.events,exitCode:+!!c.stderr}}function rb(e,t,n,r){let i=e=>q(e,r);if(t!==null){let n=k(r.cwd,t,r.fs);return n.error?(P(r,`ln`,t,n.error),{error:x(`ln: failed to access ${i(t)}: ${n.error}`)}):r.fs.isDir(n.path)?e.map(e=>ib(t,e)):{error:x(`ln: target ${i(t)} is not a directory`)}}if(e.length===1)return n.noTargetDirectory?{error:x(`ln: missing destination file operand after ${i(e[0])}`)}:[ib(`.`,e[0])];if(e.length===2){let t=k(r.cwd,e[1],r.fs,{follow:!n.noDereference});if(n.noTargetDirectory||t.error!==null||!r.fs.isDir(t.path))return[[e[0],e[1]]]}if(n.noTargetDirectory)return{error:x(`ln: extra operand ${i(e[2])}`)};let a=e.at(-1),o=k(r.cwd,a,r.fs),s=o.error??(r.fs.isDir(o.path)?null:`Not a directory`);return s?(P(r,`ln`,a,s),{error:x(`ln: target ${i(a)}: ${s}`)}):e.slice(0,-1).map(e=>ib(a,e))}function ib(e,t){let n=t.replace(/\/+$/u,``).split(`/`).at(-1);return[t,e+(e.endsWith(`/`)?``:`/`)+n,n===``]}function ab(e,t,n,r,i=!1){let{ctx:a}=r,o=q(t,a),s=n.relative?sb(a,e,t):e,c=e=>lb(r,`ln: failed to create symbolic link ${o}${e}
189
- `);if(s===``)return c(` -> ${q(s,a)}: No such file or directory`);if(i)return c(`: No such file or directory`);if(n.force){let e=k(a.cwd,t,a.fs,{follow:!1});if(e.error===null){if(a.fs.isDir(e.path))return lb(r,`ln: ${iy(t,a)}: cannot overwrite directory
190
- `);try{if(!a.fs.removeWritable?.(a.cwd,t))return c(`: Read-only file system`)}catch(e){if(S(e))throw e;return c(`: ${cb(e,t)}`)}}}let l=ob(a,t);if(l)return P(a,`ln`,t,l),c(`: ${l}`);try{if(!a.fs.makeWritableLink?.(a.cwd,t,s))return c(`: Read-only file system`)}catch(e){if(S(e))throw e;return P(a,`ln`,e?.path,e?.fsError),c(`: ${cb(e,t)}`)}n.verbose&&lb(r,`${o} -> ${q(s,a)}
191
- `,1)}function ob(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=k(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 i=ft(e.cwd,n,e.fs);return i.rest.length>0?i.error:null}function sb(e,t,n){let r=Ky(e,A(n),`m`,`physical`),i=Ky(e,t,`m`,`physical`);return r.error||i.error?t:Yy(r.path,i.path)}function cb(e,t){let n=L(e);return e?.fsError??(n.startsWith(t+`: `)?n.slice(t.length+2):n)}function lb(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function ub(e,t,n){let{flags:r,positional:i}=U(t,{short:[`a`,`i`,`p`],long:[`append`,`ignore-interrupts`]}),a=r.has(`a`)||r.has(`append`),o=n.stdinBytes;F(n,``,!0);let s=o??E(e),c={stderr:``,status:0,gap:null};for(let e of i)db(e,s,a,c,n);let l=[{fd:1,bytes:s},...c.stderr?[{fd:2,text:c.stderr}]:[]],u=o===null?{stdout:e,stderr:c.stderr,exitCode:c.status}:{stdout:``,stderr:c.stderr,exitCode:c.status,events:l};if(!c.gap)return u;let d=S(c.gap);return w({...u,exitCode:1},d.kind,d.command,d.detail,d.message)}function db(e,t,n,r,i){if(e===`/dev/null`)return;let a;try{a=i.writable&&i.fs.openWritable?.(i.cwd,e,n)}catch(e){r.stderr+=`tee: ${e.message}
169
+ string2 must map all characters in the domain to one`):null}function Kv(e){let t=[],n=[],r=0,i=()=>{if(e[r]!==`\\`)return e[r++];if(r+1>=e.length)return null;let t=e[r+1];return r+=2,t===`n`?`
170
+ `:t===`t`?` `:t===`\\`?`\\`:t===`0`?`\0`:t};for(;r<e.length;){let a=Wv(e,r);if(a){if(a.name===``)return{error:x(`tr: missing character class name '${a.text}'`)};let e=Hv[a.name];if(e===void 0)return{error:x(`tr: invalid character class '${a.name}'`)};n.push({name:a.name,start:t.length,end:t.length+e.length}),t.push(...e),r=a.next;continue}let o=i();if(e[r]===`-`&&r+1<e.length){r++;let e=i();if(e===null)return{error:x(`tr: trailing backslash in set`)};let n=o.codePointAt(0),a=e.codePointAt(0);if(a<n)return{error:x(`tr: range-endpoints of '${o}-${e}' are in reverse collating sequence order`)};for(let e=n;e<=a;e++)t.push(String.fromCodePoint(e))}else t.push(o)}return{chars:t,classes:n}}function qv(e,t){let n=``,r=null;for(let i of e)t(i)&&i===r||(n+=i,r=i);return n}var Jv=e=>e.text??D(e.bytes),Yv=(e,t)=>{e.bytes===void 0?t.write(e.text):t.writeBytes(e.bytes)},Xv=e=>e.events??[...e.stdout?[{fd:1,text:e.stdout}]:[],...e.stderr?[{fd:2,text:e.stderr}]:[]],Zv=e=>e.unordered??(!e.events&&e.stdout!==``&&e.stderr!==``),G=(e=``)=>({stdout:``,stderr:e,exitCode:0,ignored:!1,events:e?[{fd:2,text:e}]:[],unordered:!1});function K(e,t){e.stdout+=t.stdout,e.stderr+=t.stderr,e.exitCode=t.exitCode,e.ignored=t.ignored??!1,e.events.push(...Xv(t)),e.unordered||=Zv(t)}function Qv(e,t){t&&K(e.expansionOutput,$v(G(t),{fds:e.expansionFds},e))}function $v(e,t,n){let r=r=>ey(e,t,n,r);return n.io?n.io.output(e,t,r):r(Yv)}function ey(e,t,n,r){let i=e,a=t.fds[1],o=t.fds[2];(a===o&&a!==`null`&&a!==`closed`||(a?.identity&&o?.identity?a.identity===o.identity:a?.path&&a.path===o?.path))&&Zv(i)&&(i=C(`feature`,null,`combined output ordering`,`error: merging this command’s stdout and stderr in order is not supported`),n.unsupported.add(S(i)));let s=[],c=``,l=``;for(let e of Xv(i)){let i=t.fds[e.fd];if(typeof i==`object`){r(e,i);continue}if(t.deferred?.[e.fd]&&e.bytes!==void 0){s.push(e);continue}if(i!==`out`&&i!==`err`){e.fd===2&&En(n,Jv(e));continue}let a=Jv(e);s.push({fd:i===`out`?1:2,text:a}),i===`out`?l+=a:c+=a}return{...i,stdout:l,stderr:c,events:s,unordered:Zv(i)&&l!==``&&c!==``}}var ty=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]]),ny=e=>e.stdout!==``||Xv(e).some(e=>e.fd===1&&(e.bytes?.length??0)>0);function ry(e,t,n){return n.closed.out&&ny(t)?iy(e,t,n):t}function iy(e,t,n){let r=ty.get(n.registry.resolveCommand(e))??1,i=Xv(t).filter(e=>e.fd!==1),a=r===0?``:`${e}: write error: Bad file descriptor
171
+ `;a&&i.push({fd:2,text:a});let o={...t,stdout:``,stderr:t.stderr+a,exitCode:r||t.exitCode,events:i,unordered:!1},s=S(t);return s?w(o,s.kind,s.command,s.detail,s.message):o}var ay=new Map([[`\0`,`0`],[`\x07`,`a`],[`\b`,`b`],[`\f`,`f`],[`
172
+ `,`n`],[`\r`,`r`],[` `,`t`],[`\v`,`v`]]);function q(e,t){let n=tn(t),r=n?Array.from(E(e),e=>String.fromCodePoint(e)):[...e];if(!n&&r.some(e=>e.codePointAt(0)>127&&/[\p{C}\p{Zl}\p{Zp}]/u.test(e)))throw new T(`feature`,`filename quoting`,`quoting nonprinting Unicode filenames is not supported`);if(e.includes(`'`)&&r.every(e=>/[-a-zA-Z0-9 %+,./:_\]']/u.test(e)||!n&&e.codePointAt(0)>127))return`"`+e+`"`;let i=!1,a=`'`;for(let e of r){let t=e.codePointAt(0),r=ay.get(e)??(t<32||t===127||n&&t>127?t.toString(8).padStart(3,`0`):null);r===null?e===`'`?(a+=`'\\''`,i=!1):(i&&(a+=`''`),i=!1,a+=e):(i||(a+=`'$'`),i=!0,a+=`\\`+r)}return a+`'`}var oy=/^[#%+,\-./0-9@A-Z\]_a-z{}~]+$/u;function sy(e,t){return oy.test(e)&&!`#~`.includes(e[0])?e:q(e,t)}var cy=new Map([[`\x07`,`a`],[`\b`,`b`],[`\f`,`f`],[`
173
+ `,`n`],[`\r`,`r`],[` `,`t`],[`\v`,`v`],[`"`,`"`],[`\\`,`\\`]]);function ly(e,t){let n=tn(t),r=``,i=!1;for(let t of e){let e=t.codePointAt(0),a=cy.get(t);if(a!==void 0)r+=`\\`+a,i=!0;else if(t===` `)r+=t,i=!0;else if(e<32||e===127||e>127&&(n||/[\p{C}\p{Zl}\p{Zp}]/u.test(t))){for(let e of p(t))r+=`\\`+e.toString(8).padStart(3,`0`);i=!0}else r+=t}return i?`"${r}"`:e}var uy=new Set([`/dev/null`,`/dev/stdin`,`/dev/stdout`,`/dev/stderr`]);function dy(e,t,n){let r=U(t,{short:[`f`,`n`,`v`,`T`,`r`,`R`],long:[`force`,`no-clobber`,`verbose`,`no-target-directory`,`recursive`],valueShort:[`t`],valueLong:[`target-directory`]}),i=fy(r,n);if(i.error)return x(`cp: `+i.error);let{sources:a,target:o,directory:s}=i,{flags:c}=r,l=c.has(`v`)||c.has(`verbose`),u=c.has(`r`)||c.has(`R`)||c.has(`recursive`),d=a.map(e=>[e,s?o.replace(/\/+$/u,``)+`/`+vy(e):o]),f=c.has(`n`)||c.has(`no-clobber`),p={ctx:n,result:G(),failed:!1,sources:new Set,copied:new Set,noClobber:f,force:c.has(`f`)||c.has(`force`),verbose:l,recursive:u,outputOverlap:l&&Ty(d,n,{recursive:u,noClobber:f})};for(let[e,t]of d){n.io.setReads([]);try{yy(e,t,p)}catch(e){P(n,`cp`,e?.path,e?.fsError);let t=S(e),r=`cp: `+I(e);if(t)return n.unsupported.add({...t,command:t.command??`cp`,message:r}),K(p.result,x(r)),p.result;Py(p,r+`
174
+ `,!0)}}return p.result.exitCode=+!!p.failed,p.result}function fy({positional:e,flags:t,order:n},r){let i=n.filter(({name:e})=>e===`t`||e===`target-directory`);if(i.length>1)return{error:`multiple target directories specified`};let a=i[0]?.value,o=t.has(`T`)||t.has(`no-target-directory`);if(e.length===0)return{error:`missing file operand`};if(a===void 0&&e.length===1)return{error:`missing destination file operand after `+q(e[0],r)};if(a!==void 0&&o)return{error:`cannot combine --target-directory (-t) and --no-target-directory (-T)`};if(o&&e.length>2)return{error:`extra operand `+q(e[2],r)};let s=a??e.at(-1),c=k(r.cwd,s,r.fs),l=!o&&r.fs.isDir(c.path);return!l&&(a!==void 0||e.length>2)?(P(r,`cp`,s,c.error),{error:`${a===void 0?`target`:`target directory`} ${q(s,r)}: ${c.error??`Not a directory`}`}):{target:s,directory:l,sources:a===void 0?e.slice(0,-1):e}}function py(e,t,n){let{ctx:r}=n,i=k(r.cwd,e,r.fs,{follow:!1}).path;if(i===null)return;let a=e.replace(/\/+$/u,``),o=t.replace(/\/+$/u,``);for(let s of xt(r.fs,i)){if(s.kind!==`link`)continue;let r=s.path===i?null:vt(i,s.path);if(!my(r===null?t:`${o}/${r}`,n)&&!(r!==null&&hy(o,r,n)))throw gy(r===null?e:`${a}/${r}`)}}var my=(e,t)=>t.noClobber&&k(t.ctx.cwd,e,t.ctx.fs,{follow:!1}).path!==null;function hy(e,t,n){let{ctx:r}=n,i=t.split(`/`);for(let t=1;t<i.length;t++){let n=k(r.cwd,`${e}/${i.slice(0,t).join(`/`)}`,r.fs,{follow:!1});if(n.path!==null&&!r.fs.isDir(n.path))return!0}return!1}var gy=e=>new T(`feature`,`symbolic link`,`copying a symbolic link is not supported: ${e} (a recursive copy keeps the link, which cp does not make here)`),_y=(e,t,n)=>n.path===null&&e.fs.isLink?.(k(e.cwd,t,e.fs,{follow:!1}).path)===!0,vy=e=>{let t=e.replace(/\/+$/u,``).split(`/`).at(-1);return t===`..`?`.`:t};function yy(e,t,n,r=null){let{ctx:i}=n;if(Ny(e,i.cwd)||Ny(t,i.cwd))throw new T(`feature`,`special file`,`copying special files is not supported`);let a=q(e,i),o=q(t,i);if(n.recursive&&i.fs.isLink?.(k(i.cwd,e,i.fs,{follow:!1}).path)){if(!my(t,n))throw gy(e);return}let s=N(i,`cp`,e),c=e=>Py(n,`cp: `+e+`
175
+ `,!0);if(s.error)return c(`cannot stat ${a}: ${s.error}`);if(i.fs.isDir(s.path))return n.recursive?by(e,s.path,t,n,r??{source:a,target:o},r===null):c(`-r not specified; omitting directory ${a}`);if(r===null){if(n.sources.has(s.path))return Py(n,`cp: warning: source file ${a} specified more than once
176
+ `,!1,!0);n.sources.add(s.path)}let l=k(i.cwd,t,i.fs);if(l.error&&l.error!==`No such file or directory`)return c(`cannot stat ${o}: ${l.error}`);if(n.noClobber&&l.path!==null)return;if(wy(s.path,l.path,i.fs))return c(`${a} and ${o} are the same file`);if(i.fs.isDir(l.path))return c(`cannot overwrite directory ${o} with non-directory ${a}`);let u=mt(i.fs,i.cwd,t);if(r===null&&n.copied.has(u))return c(`will not overwrite just-created ${o} with ${a}`);let d=ht(i.cwd,t,i.fs,l);if(Sy(a,o,n),_y(i,t,l))return c(`not writing through dangling symlink ${o}`);if(d)return P(i,`cp`,t,d),c(`cannot create regular file ${o}: ${d}`);try{if(!i.fs.copyWritable?.(i.cwd,s.path,t))return c(`${n.force&&l.path!==null?`cannot remove`:`cannot create regular file`} ${o}: Read-only file system`)}catch(e){if(S(e))throw e;P(i,`cp`,e?.path,e?.fsError);let n=I(e);return c(`cannot create regular file ${o}: ${n.startsWith(t+`: `)?n.slice(t.length+2):n}`)}r===null&&n.copied.add(u)}function by(e,t,n,r,i,a){let{ctx:o}=r,s=q(e,o),c=q(n,o),l=e=>Py(r,`cp: `+e+`
177
+ `,!0),u=k(o.cwd,n,o.fs,{follow:!1});if(u.error&&u.error!==`No such file or directory`)return l(`cannot stat ${c}: ${u.error}`);let d=n.replace(/\/+$/u,``)||n;if(mt(o.fs,o.cwd,d,!0)===t)return l(`${s} and ${c} are the same file`);if(u.path!==null&&!o.fs.isDir(u.path))return l(`cannot overwrite non-directory ${c} with directory ${s}`);let f=mt(o.fs,o.cwd,d,!1);if(u.path===null){let e=ht(o.cwd,d,o.fs);if(e)return P(o,`cp`,d,e),l(`cannot create directory ${c}: ${e}`);if(!o.writable||!L(f))return l(`cannot create directory ${c}: Read-only file system`)}if(f.startsWith(t===`/`?`/`:t+`/`))return l(`cannot copy a directory, ${i.source}, into itself, ${i.target}`);if(a){if(r.sources.has(t))return Py(r,`cp: warning: source directory ${s} specified more than once
178
+ `,!1,!0);r.sources.add(t)}a&&py(e,n,r);let{dirs:p,files:m,links:h}=o.fs.listDir(t);if(u.path===null&&!xy(e,n,d,f,r))return;let g=e.replace(/\/+$/u,``),_=n.replace(/\/+$/u,``);for(let e of[...p,...m,...h].sort(j))o.io.setReads([]),yy(`${g}/${e}`,`${_}/${e}`,r,i)}function xy(e,t,n,r,i){let{ctx:a}=i,o=q(t,a),s=e=>(Py(i,`cp: cannot create directory `+o+`: `+e+`
179
+ `,!0),!1),c=a.writable&&L(r);c&&Cy(i);try{if(!c||!a.fs.makeWritableDir?.(a.cwd,n))return s(`Read-only file system`)}catch(e){if(S(e))throw e;P(a,`cp`,e?.path,e?.fsError);let t=I(e);return s(t.startsWith(n+`: `)?t.slice(n.length+2):t)}return Sy(q(e,a),o,i),!0}function Sy(e,t,n){n.verbose&&(Cy(n),Py(n,`${e} -> ${t}
180
+ `))}function Cy(e){if(e.outputOverlap)throw new T(`feature`,`copy output buffering`,`buffered verbose output sharing a copied file is not supported`)}function wy(e,t,n){if(e===t)return!0;let r=n.fileIdentity?.(e);return r!==void 0&&r===n.fileIdentity(t)}function Ty(e,t,{recursive:n,noClobber:r}){let i=t.outputFds[1];if(typeof i!=`object`)return!1;let a={ctx:t,recursive:n,noClobber:r,holds:e=>i.identity===void 0?i.path===e:i.identity===t.fs.fileIdentity?.(e),made:new Set,sources:new Set,copied:new Set};return e.some(([e,t])=>Ey(e,t,a))}function Ey(e,t,n){let{ctx:r}=n,i=k(r.cwd,e,r.fs),a=i.path??O(r.cwd,e),o=i.error===`No such file or directory`&&(n.made.has(a)||ky(a,n));if(i.error&&!o)return!1;let s=mt(r.fs,r.cwd,t);return(i.error===null?r.fs.isDir(i.path):!n.made.has(a))?!n.recursive||!My(a,t,r)||n.sources.has(a)?!1:(n.sources.add(a),Dy(a,s,n)):n.sources.has(a)||(n.sources.add(a),n.copied.has(s)||!jy(a,s,t,r,n.noClobber))?!1:(n.copied.add(s),n.made.add(s),n.holds(a)||n.holds(s))}function Dy(e,t,n){let{ctx:r}=n,i=e===`/`?0:e.length;for(let a of Oy(e,n)){let e=t+a.slice(i);if(!Ay(a,e,k(r.cwd,e,r.fs),r,n.noClobber)&&(n.made.add(e),n.holds(a)||n.holds(e)))return!0}return!1}function Oy(e,t){let n=e===`/`?`/`:e+`/`,r=t.ctx.fs.isDir(e)?[...t.ctx.fs.walkFiles(e)]:[];return new Set([...r,...[...t.made].filter(e=>e.startsWith(n))])}var ky=(e,t)=>[...t.made].some(t=>t.startsWith(e+`/`));function Ay(e,t,n,r,i){return n.error&&n.error!==`No such file or directory`||i&&n.path!==null||wy(e,n.path,r.fs)||r.fs.isDir(n.path)?!0:!r.writable||!L(t)}function jy(e,t,n,r,i){let a=k(r.cwd,n,r.fs);return!Ay(e,t,a,r,i)&&!_y(r,n,a)&&!ht(r.cwd,n,r.fs,a)}function My(e,t,n){let r=k(n.cwd,t,n.fs,{follow:!1});if(r.error&&r.error!==`No such file or directory`)return!1;let i=t.replace(/\/+$/u,``)||t;if(r.path!==null&&!n.fs.isDir(r.path)||r.path===null&&ht(n.cwd,i,n.fs))return!1;let a=mt(n.fs,n.cwd,i,!1);return mt(n.fs,n.cwd,i,!0)===e||a.startsWith(e===`/`?`/`:e+`/`)?!1:!!n.writable&&L(a)}function Ny(e,t){let n=e.startsWith(`/`)?e:t+`/`+e;return uy.has(n.replace(/\/\.(?=\/)/gu,``).replace(/\/+/gu,`/`))}function Py(e,t,n=!1,r=!1){let i=n||r?G(t):{...G(),stdout:t,events:[{fd:1,text:t}]};K(e.result,e.ctx.flushOutput(i)),e.failed||=n}function Fy(e,t,n){let{flags:r,positional:i}=U(t,{short:[`f`,`v`,`r`,`R`],long:[`force`,`verbose`,`recursive`]}),a=r.has(`f`)||r.has(`force`),o=r.has(`v`)||r.has(`verbose`),s=r.has(`r`)||r.has(`R`)||r.has(`recursive`);if(i.length===0)return a?b(``):x(`rm: missing operand`);let c={ctx:n,force:a,verbose:o,recursive:s,events:[],stdout:``,stderr:``};try{for(let e of i)Iy(e,c)}catch(e){P(n,`rm`,e?.path,e?.fsError);let t=qe(e,`rm`,`rm: `+I(e));return t.events=[...c.events,{fd:2,text:t.stderr}],t.stdout=c.stdout,t.stderr=c.stderr+t.stderr,t}return{stdout:c.stdout,stderr:c.stderr,events:c.events,exitCode:+!!c.stderr}}function Iy(e,t){let{ctx:n}=t,r=k(n.cwd,e,n.fs,{follow:!1}),i=r.error;if(!t.force||i!==`No such file or directory`&&i!==`Not a directory`){if(P(n,`rm`,e,i),i===null&&n.fs.isDir(r.path)){if(!t.recursive)i=`Is a directory`;else{if([`.`,`..`].includes(e.replace(/\/+$/u,``).split(`/`).at(-1)))return By(t,`rm: refusing to remove '.' or '..' directory: skipping ${q(e,n)}
181
+ `);if(r.path===`/tmp`)i=`Device or resource busy`;else if(!n.writable||!L(r.path))i=`Read-only file system`;else return Ry(e,r.path,t,Ly(n,e)?`Not a directory`:null)}}zy(e,r.path,t,!1,i)}}function Ly(e,t){let n=t.replace(/\/+$/u,``);return n===t||n===``?!1:e.fs.isLink?.(k(e.cwd,n,e.fs,{follow:!1}).path)===!0}function Ry(e,t,n,r=null){let{ctx:i}=n,{dirs:a,files:o,links:s=[]}=i.fs.listDir(t),c=e.replace(/\/+$/u,``);for(let e of[...a,...o,...s].sort(j)){let r=_t(t,e);i.fs.isDir(r)?Ry(`${c}/${e}`,r,n):zy(`${c}/${e}`,r,n,!1,null)}zy(e,t,n,!0,r)}function zy(e,t,n,r,i){let{ctx:a}=n,o=n.verbose||i!==null||!a.writable||!t?.startsWith(`/tmp/`)?q(e,a):``,s=()=>r?a.fs.removeWritableDir?.(a.cwd,e):a.fs.removeWritable?.(a.cwd,e);try{i===null&&!s()&&(i=`Read-only file system`)}catch(t){if(S(t))throw t;P(a,`rm`,t?.path,t?.fsError);let n=I(t);i=t?.fsError??(n.startsWith(e+`: `)?n.slice(e.length+2):n)}if(i)return By(n,`rm: cannot remove ${o}: ${i}
182
+ `);n.verbose&&By(n,`removed ${r?`directory `:``}${o}
183
+ `,1)}function By(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Vy(e,t,n){let{flags:r,positional:i}=U(t,{short:[`p`,`v`],long:[`parents`,`verbose`]});if(i.length===0)return x(`mkdir: missing operand`);let a={ctx:n,events:[],stdout:``,stderr:``,parents:r.has(`p`)||r.has(`parents`),verbose:r.has(`v`)||r.has(`verbose`)};try{for(let e of i)a.parents?Hy(e,a):Uy(e,a,!0)}catch(e){P(n,`mkdir`,e?.path,e?.fsError);let t=qe(e,`mkdir`,`mkdir: `+I(e));return t.events=[...a.events,{fd:2,text:t.stderr}],t.stdout=a.stdout,t.stderr=a.stderr+t.stderr,t}return{stdout:a.stdout,stderr:a.stderr,events:a.events,exitCode:+!!a.stderr}}function Hy(e,t){let n=e.split(`/`),r=[];for(let e=0;e<n.length;e++)n[e]!==``&&r.push(n.slice(0,e+1).join(`/`));if(r.length===0){e===``&&Uy(e,t,!0);return}r[r.length-1]=e;for(let[e,n]of r.entries())if(!Uy(n,t,e===r.length-1))return}function Uy(e,t,n){let{ctx:r}=t,i=q(e,r),a=e=>(Wy(t,`mkdir: cannot create directory ${i}: ${e}
184
+ `),!1),o=e.replace(/\/+$/u,``)||e,s=k(r.cwd,o,r.fs);if(s.error===null)return t.parents?r.fs.isDir(s.path)?!0:a(n?`File exists`:`Not a directory`):a(`File exists`);if(k(r.cwd,o,r.fs,{follow:!1}).error===null)return a(!t.parents||n||s.error!==`Not a directory`?`File exists`:`Not a directory`);let c=ht(r.cwd,o,r.fs,s);if(c)return P(r,`mkdir`,o,c),a(c);try{if(!r.fs.makeWritableDir?.(r.cwd,o))return a(`Read-only file system`)}catch(e){if(S(e))throw e;P(r,`mkdir`,e?.path,e?.fsError);let t=I(e);return a(t.startsWith(o+`: `)?t.slice(o.length+2):t)}return t.verbose&&Wy(t,`mkdir: created directory ${i}
185
+ `,1),!0}function Wy(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Gy(e,t,n){let{flags:r,positional:i}=U(t,{short:[`c`],long:[`no-create`]});if(i.length===0)return x(`touch: missing file operand`);let a=r.has(`c`)||r.has(`no-create`),o={ctx:n,stderr:``,failed:!1,gap:null};for(let e of i)Ky(e,a,o);let s={stdout:``,stderr:o.stderr,exitCode:+!!o.failed};return o.gap?w(s,`feature`,`touch`,`times`,o.gap):s}function Ky(e,t,n){let{ctx:r}=n,i=q(e,r),a=k(r.cwd,e,r.fs);if(a.error===null)return qy(e,i,a.path,n);let o=t||e.endsWith(`/`);if(t&&a.error===`No such file or directory`)return;if(P(r,`touch`,e,a.error),o)return Jy(n,`setting times of ${i}: ${a.error}`);let s=ht(r.cwd,e,r.fs,a);if(s)return Jy(n,`cannot touch ${i}: ${s}`);try{r.fs.openWritable?.(r.cwd,e,!0)||Jy(n,`cannot touch ${i}: Read-only file system`)}catch(t){if(S(t))throw t;P(r,`touch`,t?.path,t?.fsError);let a=I(t);Jy(n,`cannot touch ${i}: ${a.startsWith(e+`: `)?a.slice(e.length+2):a}`)}}function qy(e,t,n,r){let{ctx:i}=r;if(!i.writable||!L(n))return Jy(r,`setting times of ${t}: Read-only file system`);let a=`touch: setting the times of ${t} is not supported (every entry here carries the one time this filesystem keeps)`;r.gap??=a,r.stderr+=a+`
186
+ `,r.failed=!0}function Jy(e,t){e.stderr+=`touch: ${t}
187
+ `,e.failed=!0}function Yy(e,t,n,r){if(t===``||t.includes(`\0`))return{error:`No such file or directory`};if(r===`none`)return Xy(e,t,n);let i=t;if(r===`logical`){let r=n===`m`?{path:O(e.cwd,t)}:Zy(e,t);if(r.error)return r;i=r.path+(t.endsWith(`/`)?`/`:``)}let a=pt(e.cwd,i,e.fs,{lenient:n===`m`});return n===`m`?{path:a.rest.length?O(a.path,a.rest.join(`/`)):a.path}:a.error===`No such file or directory`&&a.rest.length===0&&n!==`e`?{path:a.path}:a.error?{error:a.error}:t.endsWith(`/`)&&!e.fs.isDir(a.path)?{error:`Not a directory`}:{path:a.path}}function Xy(e,t,n){if(n===`m`)return{path:O(e.cwd,t)};let r=Zy(e,t);if(r.error||n!==`e`)return r;let i=k(`/`,r.path,e.fs);return i.error?{error:i.error}:r}function Zy(e,t){let n=(t.startsWith(`/`)?t:e.cwd+`/`+t).split(`/`).filter(Boolean),r=`/`;for(let i=0;i<n.length;i++){let a=n[i];if(a===`..`)r=A(r);else if(a!==`.`){r=_t(r,a);let o=i+1;for(;n[o]===`.`;)o++;let s=n[o]===`..`||o===n.length&&(i<n.length-1||t.endsWith(`/`));if(s||i===n.length-1){let t=k(`/`,r+(s?`/`:``),e.fs);if(t.error&&(t.error!==`No such file or directory`||i!==n.length-1))return t}}}return{path:r}}function Qy(e,t){let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return[...n.slice(i).map(()=>`..`),...r.slice(i)].join(`/`)||`.`}var $y=(e,t)=>e===`/`||t===e||t.startsWith(e+`/`),eb={e:`e`,"canonicalize-existing":`e`,m:`m`,"canonicalize-missing":`m`},tb={P:`physical`,physical:`physical`,L:`logical`,logical:`logical`,s:`none`,strip:`none`,"no-symlinks":`none`};function nb(e,t,n,r){let i=t.get(`relative-base`),a=t.get(`relative-to`)??i,o={};for(let[t,s]of[[`target`,a],[`base`,i]]){if(s===void 0)continue;let i=Yy(e,s,n,r),a=i.error??(n===`e`&&!e.fs.isDir(i.path)?`Not a directory`:null);if(a)return P(e,`realpath`,s,a),{error:x(`realpath: ${sy(s,e)}: ${a}`)};o[t]=i.path}return o.base&&!$y(o.base,o.target)&&delete o.target,o}function rb(e,t,n){let{flags:r,values:i,positional:a,order:o}=U(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(!a.length)return x(`realpath: missing operand`);let s=`physical`,c=`E`;for(let{name:e}of o)Object.hasOwn(eb,e)&&(c=eb[e]),Object.hasOwn(tb,e)&&(s=tb[e]);let l=nb(n,i,c,s);if(l.error)return l.error;let u=r.has(`q`)||r.has(`quiet`),d=r.has(`z`)||r.has(`zero`)?`\0`:`
188
+ `,f=G(),p=!1;for(let e of a){let t=Yy(n,e,c,s);t.error?(P(n,`realpath`,e,t.error),u||K(f,x(`realpath: ${sy(e,n)}: ${t.error}`)),p=!0):K(f,b((l.target&&(!l.base||$y(l.base,t.path))?Qy(l.target,t.path):t.path)+d))}return f.exitCode=+!!p,f}var ib={symbolic:`s`,force:`f`,"no-dereference":`n`,"no-target-directory":`T`,verbose:`v`,relative:`r`,logical:`L`,physical:`P`};function ab(e,t,n){let r=U(t,{short:Object.values(ib),long:Object.keys(ib),valueShort:[`t`],valueLong:[`target-directory`]}),i=e=>r.flags.has(e)||r.flags.has(Object.keys(ib).find(t=>ib[t]===e)),a={force:i(`f`),noDereference:i(`n`),noTargetDirectory:i(`T`),verbose:i(`v`),relative:i(`r`)},o=r.order.findLast(({name:e})=>e===`t`||e===`target-directory`)?.value??null,s=r.positional;if(o!==null&&a.noTargetDirectory)return x(`ln: cannot combine --target-directory and --no-target-directory`);if(a.relative&&!i(`s`))return x(`ln: cannot do --relative without --symbolic`);if(s.length===0)return x(`ln: missing file operand`);if(!i(`s`))return C(`feature`,`ln`,`hard link`,`ln: hard links are not supported: ${q(s[0],n)} (ln -s makes a symbolic one)`);let c={ctx:n,events:[],stdout:``,stderr:``};try{let e=ob(s,o,a,n);if(e.error)return e.error;for(let[t,n,r]of e)cb(t,n,a,c,r)}catch(e){P(n,`ln`,e?.path,e?.fsError);let t=qe(e,`ln`,`ln: `+I(e));return t.events=[...c.events,{fd:2,text:t.stderr}],t.stdout=c.stdout,t.stderr=c.stderr+t.stderr,t}return{stdout:c.stdout,stderr:c.stderr,events:c.events,exitCode:+!!c.stderr}}function ob(e,t,n,r){let i=e=>q(e,r);if(t!==null){let n=k(r.cwd,t,r.fs);return n.error?(P(r,`ln`,t,n.error),{error:x(`ln: failed to access ${i(t)}: ${n.error}`)}):r.fs.isDir(n.path)?e.map(e=>sb(t,e)):{error:x(`ln: target ${i(t)} is not a directory`)}}if(e.length===1)return n.noTargetDirectory?{error:x(`ln: missing destination file operand after ${i(e[0])}`)}:[sb(`.`,e[0])];if(e.length===2){let t=k(r.cwd,e[1],r.fs,{follow:!n.noDereference});if(n.noTargetDirectory||t.error!==null||!r.fs.isDir(t.path))return[[e[0],e[1]]]}if(n.noTargetDirectory)return{error:x(`ln: extra operand ${i(e[2])}`)};let a=e.at(-1),o=k(r.cwd,a,r.fs),s=o.error??(r.fs.isDir(o.path)?null:`Not a directory`);return s?(P(r,`ln`,a,s),{error:x(`ln: target ${i(a)}: ${s}`)}):e.slice(0,-1).map(e=>sb(a,e))}function sb(e,t){let n=t.replace(/\/+$/u,``).split(`/`).at(-1);return[t,e+(e.endsWith(`/`)?``:`/`)+n,n===``]}function cb(e,t,n,r,i=!1){let{ctx:a}=r,o=q(t,a),s=n.relative?ub(a,e,t):e,c=e=>fb(r,`ln: failed to create symbolic link ${o}${e}
189
+ `);if(s===``)return c(` -> ${q(s,a)}: No such file or directory`);if(i)return c(`: No such file or directory`);if(n.force){let e=k(a.cwd,t,a.fs,{follow:!1});if(e.error===null){if(a.fs.isDir(e.path))return fb(r,`ln: ${sy(t,a)}: cannot overwrite directory
190
+ `);try{if(!a.fs.removeWritable?.(a.cwd,t))return c(`: Read-only file system`)}catch(e){if(S(e))throw e;return c(`: ${db(e,t)}`)}}}let l=lb(a,t);if(l)return P(a,`ln`,t,l),c(`: ${l}`);try{if(!a.fs.makeWritableLink?.(a.cwd,t,s))return c(`: Read-only file system`)}catch(e){if(S(e))throw e;return P(a,`ln`,e?.path,e?.fsError),c(`: ${db(e,t)}`)}n.verbose&&fb(r,`${o} -> ${q(s,a)}
191
+ `,1)}function lb(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=k(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 i=pt(e.cwd,n,e.fs);return i.rest.length>0?i.error:null}function ub(e,t,n){let r=Yy(e,A(n),`m`,`physical`),i=Yy(e,t,`m`,`physical`);return r.error||i.error?t:Qy(r.path,i.path)}function db(e,t){let n=I(e);return e?.fsError??(n.startsWith(t+`: `)?n.slice(t.length+2):n)}function fb(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function pb(e,t,n){let{flags:r,positional:i}=U(t,{short:[`a`,`i`,`p`],long:[`append`,`ignore-interrupts`]}),a=r.has(`a`)||r.has(`append`),o=n.stdinBytes;F(n,``,!0);let s=o??E(e),c={stderr:``,status:0,gap:null};for(let e of i)mb(e,s,a,c,n);let l=[{fd:1,bytes:s},...c.stderr?[{fd:2,text:c.stderr}]:[]],u=o===null?{stdout:e,stderr:c.stderr,exitCode:c.status}:{stdout:``,stderr:c.stderr,exitCode:c.status,events:l};if(!c.gap)return u;let d=S(c.gap);return w({...u,exitCode:1},d.kind,d.command,d.detail,d.message)}function mb(e,t,n,r,i){if(e===`/dev/null`)return;let a;try{a=i.writable&&i.fs.openWritable?.(i.cwd,e,n)}catch(e){r.stderr+=`tee: ${e.message}
192
192
  `,r.status=1;return}if(!a){r.gap??=C(`feature`,`tee`,`read-only target`,`tee: ${e}: Read-only file system`,1),r.stderr+=`tee: ${e}: Read-only file system
193
- `;return}a.writeBytes(t)}var fb={cp:cy,rm:My,mkdir:Ry,touch:Hy,ln:nb,tee:ub};function pb(e,t,n){let{positional:r}=U(t),i=Hn(`tac`,r,e,n),a=[];for(let{content:e}of i.inputs)a.push(...Pn(e).toReversed());return I(a.join(``),i)}var mb=1e6;function hb(e,t){let{flags:n,values:r,positional:i}=U(t,{short:[`w`],valueShort:[`s`],numericOperands:!0});if(i.length===0||i.length>3)return We(`seq [-w] [-s SEP] LAST | seq FIRST LAST | seq FIRST INCR LAST`);let a=[];for(let e of i){if(!/^[+-]?\d+$/u.test(e))return Number.isFinite(Number(e))&&e.trim()!==``||/^[+-]?inf(?:inity)?$/iu.test(e)?C(`feature`,`seq`,`non-integer operands`,`seq: non-integer operands are not supported`):x(`seq: invalid integer: ${e}`);a.push(BigInt(e))}let o=a.length===1?1n:a[0],s=a.length===3?a[1]:1n,c=a.at(-1);if(s===0n)return x(`seq: increment must be non-zero`);let l=(s>0?o<=c:o>=c)?(c>o?c-o:o-c)/(s>0n?s:-s)+1n:0;if(l>mb)return C(`feature`,`seq`,`sequence limit`,`seq: range too large: ${l} elements exceeds limit of ${mb}`);let u=n.has(`w`)?Math.max(...[i[0],i.at(-1)].map(e=>e.replace(/^\+/u,``).length)):0,d=[];for(let e=0,t=o;e<l;e++,t+=s)d.push(gb(String(t),u));return b(d.length===0?``:d.join(r.get(`s`)??`
193
+ `;return}a.writeBytes(t)}var hb={cp:dy,rm:Fy,mkdir:Vy,touch:Gy,ln:ab,tee:pb};function gb(e,t,n){let{positional:r}=U(t),i=Un(`tac`,r,e,n),a=[];for(let{content:e}of i.inputs)a.push(...Fn(e).toReversed());return Jn(a.join(``),i)}var _b=1e6;function vb(e,t){let{flags:n,values:r,positional:i}=U(t,{short:[`w`],valueShort:[`s`],numericOperands:!0});if(i.length===0||i.length>3)return Ge(`seq [-w] [-s SEP] LAST | seq FIRST LAST | seq FIRST INCR LAST`);let a=[];for(let e of i){if(!/^[+-]?\d+$/u.test(e))return Number.isFinite(Number(e))&&e.trim()!==``||/^[+-]?inf(?:inity)?$/iu.test(e)?C(`feature`,`seq`,`non-integer operands`,`seq: non-integer operands are not supported`):x(`seq: invalid integer: ${e}`);a.push(BigInt(e))}let o=a.length===1?1n:a[0],s=a.length===3?a[1]:1n,c=a.at(-1);if(s===0n)return x(`seq: increment must be non-zero`);let l=(s>0?o<=c:o>=c)?(c>o?c-o:o-c)/(s>0n?s:-s)+1n:0;if(l>_b)return C(`feature`,`seq`,`sequence limit`,`seq: range too large: ${l} elements exceeds limit of ${_b}`);let u=n.has(`w`)?Math.max(...[i[0],i.at(-1)].map(e=>e.replace(/^\+/u,``).length)):0,d=[];for(let e=0,t=o;e<l;e++,t+=s)d.push(yb(String(t),u));return b(d.length===0?``:d.join(r.get(`s`)??`
194
194
  `)+`
195
- `)}function gb(e,t){if(e.length>=t)return e;let n=e.startsWith(`-`),r=n?e.slice(1):e;return(n?`-`:``)+r.padStart(t-+!!n,`0`)}function _b(e,t,n){let{positional:r}=U(t);if(r.length===0)return We(`which COMMAND...`);let i=[],a=0;for(let e of r)n.hasCommand(e)?i.push(`/usr/bin/${e}`):(i.push(`${e} not found`),a=1);return{stdout:Nn(i),stderr:``,exitCode:a}}function vb(e,t,n){let{positional:r}=U(t);return r.length>0?x(`whoami: extra operand: ${r[0]}`):b((n.user??`user`)+`
196
- `)}function yb(e,t,n){let{flags:r,positional:i}=U(t,{short:[`u`]});if(i.length>1)return x(`date: at most one +FORMAT argument is supported (got: ${i[1]})`);let a=`%a %b %e %T %Z %Y`;if(i.length===1){if(!i[0].startsWith(`+`))return We(`date [-u] [+FORMAT]`);a=i[0].slice(1)}return(a.match(/%./gu)??[]).some(e=>/%[-_0^#0-9:EOcCDgGhIjklNpPrRuUVwWxXy+]/u.test(e))?C(`feature`,`date`,`format`,`date: this format directive or modifier is not supported`):b(wb(new Date,a,r.has(`u`)||n.vars.has(`TZ`))+`
197
- `)}var bb=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],xb=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Sb=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Cb=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function wb(e,t,n){let r=`get`+(n?`UTC`:``),[i,a,o,s,c,l,u]=[`FullYear`,`Month`,`Date`,`Hours`,`Minutes`,`Seconds`,`Day`].map(t=>e[r+t]()),d=(e,t=`0`)=>String(e).padStart(2,t),f={__proto__:null,Y:String(i),m:d(a+1),d:d(o),e:d(o,` `),H:d(s),M:d(c),S:d(l),T:[s,c,l].map(e=>d(e)).join(`:`),F:[i,d(a+1),d(o)].join(`-`),q:String(Math.floor(a/3)+1),s:String(Math.floor(e.getTime()/1e3)),a:bb[u],A:xb[u],b:Sb[a],B:Cb[a],Z:()=>Tb(e,n),z:()=>Eb(e,n),n:`
198
- `,t:` `,"%":`%`};return t.replace(/%./gu,e=>{let t=f[e[1]];return typeof t==`function`?t():t??e})}function Tb(e,t){if(t)return`UTC`;try{return new Intl.DateTimeFormat(`en-US`,{timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??`Local`}catch{return`Local`}}function Eb(e,t){if(t)return`+0000`;let n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`,i=Math.abs(n);return`${r}${String(Math.floor(i/60)).padStart(2,`0`)}${String(i%60).padStart(2,`0`)}`}var Db={rg:dv,cut:jv,tac:pb,tr:Rv,seq:hb,nl:Av,which:_b,hexdump:cm,base64:zm,...fb},Ob={whoami:vb,date:yb,od:lm,xxd:um,base32:Nm,...Qp},kb=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`})),Ab={P:`none`,D:`args`,H:`args`,L:`all`};function jb(e,t){let n=U(e,{short:[`0`,`a`,`A`,`b`,`c`,`h`,`H`,`k`,`l`,`m`,`s`,`S`,`L`,`D`,`P`],long:[...kb.keys()].filter(e=>![`d`,`B`].includes(kb.get(e))).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:e,value:t}of n.order){let n=kb.get(e)??e;r.flags.add(n),Object.hasOwn(Ab,n)&&(r.links=Ab[n]),n===`d`&&(r.depth=Nb(t)),n===`B`&&(r.scale=Fb(t)),n===`b`&&(r.flags.add(`A`),r.scale={unit:1n}),(n===`k`||n===`m`)&&(r.scale={unit:n===`k`?1024n:1024n**2n}),(n===`h`||n===`si`)&&(r.scale={base:n===`h`?1024n:1000n,unit:1n})}let{flags:i}=r;if(i.has(`a`)&&i.has(`s`))throw Error(`cannot both summarize and show all entries`);if(i.has(`s`)&&i.has(`d`)){if(r.depth!==0)throw Error(`summarizing conflicts with --max-depth=${r.depth}`);r.stderr+=`du: warning: summarizing is the same as using --max-depth=0
195
+ `)}function yb(e,t){if(e.length>=t)return e;let n=e.startsWith(`-`),r=n?e.slice(1):e;return(n?`-`:``)+r.padStart(t-+!!n,`0`)}function bb(e,t,n){let{positional:r}=U(t);if(r.length===0)return Ge(`which COMMAND...`);let i=[],a=0;for(let e of r)n.hasCommand(e)?i.push(`/usr/bin/${e}`):(i.push(`${e} not found`),a=1);return{stdout:Pn(i),stderr:``,exitCode:a}}function xb(e,t,n){let{positional:r}=U(t);return r.length>0?x(`whoami: extra operand: ${r[0]}`):b((n.user??`user`)+`
196
+ `)}function Sb(e,t,n){let{flags:r,positional:i}=U(t,{short:[`u`]});if(i.length>1)return x(`date: at most one +FORMAT argument is supported (got: ${i[1]})`);let a=`%a %b %e %T %Z %Y`;if(i.length===1){if(!i[0].startsWith(`+`))return Ge(`date [-u] [+FORMAT]`);a=i[0].slice(1)}return(a.match(/%./gu)??[]).some(e=>/%[-_0^#0-9:EOcCDgGhIjklNpPrRuUVwWxXy+]/u.test(e))?C(`feature`,`date`,`format`,`date: this format directive or modifier is not supported`):b(Db(new Date,a,r.has(`u`)||n.vars.has(`TZ`))+`
197
+ `)}var Cb=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wb=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Tb=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Eb=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Db(e,t,n){let r=`get`+(n?`UTC`:``),[i,a,o,s,c,l,u]=[`FullYear`,`Month`,`Date`,`Hours`,`Minutes`,`Seconds`,`Day`].map(t=>e[r+t]()),d=(e,t=`0`)=>String(e).padStart(2,t),f={__proto__:null,Y:String(i),m:d(a+1),d:d(o),e:d(o,` `),H:d(s),M:d(c),S:d(l),T:[s,c,l].map(e=>d(e)).join(`:`),F:[i,d(a+1),d(o)].join(`-`),q:String(Math.floor(a/3)+1),s:String(Math.floor(e.getTime()/1e3)),a:Cb[u],A:wb[u],b:Tb[a],B:Eb[a],Z:()=>Ob(e,n),z:()=>kb(e,n),n:`
198
+ `,t:` `,"%":`%`};return t.replace(/%./gu,e=>{let t=f[e[1]];return typeof t==`function`?t():t??e})}function Ob(e,t){if(t)return`UTC`;try{return new Intl.DateTimeFormat(`en-US`,{timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??`Local`}catch{return`Local`}}function kb(e,t){if(t)return`+0000`;let n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`,i=Math.abs(n);return`${r}${String(Math.floor(i/60)).padStart(2,`0`)}${String(i%60).padStart(2,`0`)}`}var Ab={rg:mv,cut:Pv,tac:gb,tr:Vv,seq:vb,nl:Nv,which:bb,hexdump:dm,base64:Hm,...hb},jb={whoami:xb,date:Sb,od:fm,xxd:pm,base32:Im,...tm},Mb=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`})),Nb={P:`none`,D:`args`,H:`args`,L:`all`};function Pb(e,t){let n=U(e,{short:[`0`,`a`,`A`,`b`,`c`,`h`,`H`,`k`,`l`,`m`,`s`,`S`,`L`,`D`,`P`],long:[...Mb.keys()].filter(e=>![`d`,`B`].includes(Mb.get(e))).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:e,value:t}of n.order){let n=Mb.get(e)??e;r.flags.add(n),Object.hasOwn(Nb,n)&&(r.links=Nb[n]),n===`d`&&(r.depth=Ib(t)),n===`B`&&(r.scale=Rb(t)),n===`b`&&(r.flags.add(`A`),r.scale={unit:1n}),(n===`k`||n===`m`)&&(r.scale={unit:n===`k`?1024n:1024n**2n}),(n===`h`||n===`si`)&&(r.scale={base:n===`h`?1024n:1000n,unit:1n})}let{flags:i}=r;if(i.has(`a`)&&i.has(`s`))throw Error(`cannot both summarize and show all entries`);if(i.has(`s`)&&i.has(`d`)){if(r.depth!==0)throw Error(`summarizing conflicts with --max-depth=${r.depth}`);r.stderr+=`du: warning: summarizing is the same as using --max-depth=0
199
199
  `}if(i.has(`s`)&&(r.depth=0),i.has(`inodes`)&&i.has(`A`)&&(r.stderr+=`du: warning: options --apparent-size and -b are ineffective with --inodes
200
- `),!r.scale){let e=t.vars.get(`DU_BLOCK_SIZE`)??t.vars.get(`BLOCK_SIZE`)??t.vars.get(`BLOCKSIZE`);try{r.scale=e===void 0?{unit:t.vars.has(`POSIXLY_CORRECT`)?512n:1024n}:Fb(e)}catch(e){throw e instanceof T?e:new T(`feature`,`invalid block size environment`,`invalid block size environment settings are not supported`)}}return i.has(`inodes`)&&(r.scale={...r.scale,unit:1n,suffix:r.scale.suffix?.endsWith(`B`)?`B`:``}),r.scale.base&&Mb(t,r.scale.base),r}function Mb(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 T(`feature`,`numeric locale`,`human-readable sizes in this numeric locale are not supported`);return{base:t,unit:1n}}function Nb(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 Error(`invalid maximum depth: ${e}`);let n=Pb(t[2]);if(n>yn||t[1]===`-`&&n!==0n)throw Error(`invalid maximum depth: ${e}`);return Number(n)}function Pb(e){return BigInt(/^0[0-7]+$/u.test(e)?`0o`+e:e)}function Fb(e){let t=e&&[`human-readable`,`si`].find(t=>t.startsWith(e));if(t)return{base:t===`si`?1000n:1024n,unit:1n};if(e.startsWith(`'`))throw new T(`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 Error(`invalid block size: ${e}`);let r=n[2]??``,i=r?`KMGTPEZYRQ`.indexOf(r[0].toUpperCase())+1:0,a=/[BD]$/u.test(r)&&!r.endsWith(`iB`)?1000n:1024n,o=(n[1]?Pb(n[1]):1n)*a**BigInt(i);if(o===0n||o>xn)throw Error(`invalid block size: ${e}`);return{unit:o,suffix:n[1]||!r?``:(i===1&&r.endsWith(`B`)&&a===1000n?`k`:r[0].toUpperCase())+(r.endsWith(`B`)?a===1000n?`B`:`iB`:``)}}var Ib=4096,Lb=60,Rb=(e,t)=>t===`dir`?Ib:t===`link`&&e<Lb?0:Math.ceil(e/Ib)*Ib,zb=(e,t)=>(e+t-1n)/t;function Bb(e,{base:t,unit:n,suffix:r=``}){if(!t)return String(zb(e,n))+r;let i=1n,a=0;for(;e>=i*t;)i*=t,a++;if(!a)return String(e);let o=zb(e*10n,i),s;return o<100n?s=`${o/10n}.${o%10n}`:(o=zb(e,i),o===t?(a++,s=`1.0`):s=String(o)),s+(a===1&&t===1000n?`k`:`KMGTPEZYRQ`[a-1])}var Vb=15778476e3;function Hb(e,t){for(let t of[`LS_BLOCK_SIZE`,`BLOCK_SIZE`,`BLOCKSIZE`])if(e.vars.has(t))throw new T(`feature`,`block size environment`,`${t} is not supported in a long listing`);let n=t?Mb(e):null,r=e.user??`user`,i=e.createdAt,a=Date.now(),o=i<=a&&a-i<Vb,s=wb(new Date(i),o?`%b %e %H:%M`:`%b %e %Y`,e.vars.has(`TZ`)),c=e=>n?Bb(BigInt(e),n):String(e),l=e=>Math.max(0,...e.map(e=>e.length));return{lines(t,i){let a=t.map(({name:t,abs:n,kind:r,target:i})=>{let a=r===`dir`,o=a?Ib:e.fs.fileSize(n)??E(e.fs.readFile(n)).length,s=a?`drwx------`:r===`link`?`lrwxrwxrwx`:`-rw-------`,l=Rb(o,r)/512;return{name:r===`link`?`${t} -> ${i}`:t,mode:s,units:l,links:String(a?2+e.fs.listDir(n).dirs.length:1),size:c(o)}}),o=l(a.map(e=>e.links)),u=l(a.map(e=>e.size)),d=a.map(e=>`${e.mode} ${e.links.padStart(o)} ${r} ${r} ${e.size.padStart(u)} ${s} ${e.name}`);if(i){let e=a.reduce((e,t)=>e+t.units,0);d.unshift(`total `+(n?Bb(BigInt(e)*512n,n):String(e/2)))}return d}}}var Ub=Object.freeze({utf8:{down:`├── `,last:`└── `,through:`│\xA0\xA0 `,past:` `},ascii:{down:`|-- `,last:"`-- ",through:`| `,past:` `}}),Wb=e=>en(e)?Ub.ascii:Ub.utf8;function Gb(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`a`,`d`,`F`],long:[`noreport`],valueShort:[`L`]});if(a.length>1)return C(`feature`,`tree`,`multiple roots`,`tree: multiple roots are not supported`);let o=i.has(`L`)?qn(i.get(`L`),`tree: -L`,i.get(`L`),{max:2147483647}):{value:1/0};if(o.error)return o.error;if(!o.value)return x(`tree: -L must be greater than zero`);let s=a[0]??`.`,{path:c,error:l}=N(n,`tree`,s),u=!l&&n.fs.isDir(c),d=k(n.cwd,s,n.fs,{follow:!1}),f=!!l&&!!d.error,p={dirs:u&&Jb(n.fs,c,r).length?1:0,files:+(!f&&!u)},m=[s+Kb(n,r,d,u)+(u?``:` [error opening dir]`)];if(u){let e=new Set,t=Cn();try{let i=qb(n.fs,c,m,r,o.value,p,e,t,Wb(n));if(i)return i}finally{kn(n.notes,{command:`tree`,action:`depth limit omitted contents of`,noun:[`directory`,`directories`],paths:e}),t.emit(n.notes,`tree`,`Hidden entries are included with -a.`)}}if(!r.has(`noreport`)){let e=`${p.dirs} ${p.dirs===1?`directory`:`directories`}`,t=`${p.files} ${p.files===1?`file`:`files`}`;m.push(``,r.has(`d`)?e:`${e}, ${t}`)}return{stdout:m.join(`
200
+ `),!r.scale){let e=t.vars.get(`DU_BLOCK_SIZE`)??t.vars.get(`BLOCK_SIZE`)??t.vars.get(`BLOCKSIZE`);try{r.scale=e===void 0?{unit:t.vars.has(`POSIXLY_CORRECT`)?512n:1024n}:Rb(e)}catch(e){throw e instanceof T?e:new T(`feature`,`invalid block size environment`,`invalid block size environment settings are not supported`)}}return i.has(`inodes`)&&(r.scale={...r.scale,unit:1n,suffix:r.scale.suffix?.endsWith(`B`)?`B`:``}),r.scale.base&&Fb(t,r.scale.base),r}function Fb(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 T(`feature`,`numeric locale`,`human-readable sizes in this numeric locale are not supported`);return{base:t,unit:1n}}function Ib(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 Error(`invalid maximum depth: ${e}`);let n=Lb(t[2]);if(n>bn||t[1]===`-`&&n!==0n)throw Error(`invalid maximum depth: ${e}`);return Number(n)}function Lb(e){return BigInt(/^0[0-7]+$/u.test(e)?`0o`+e:e)}function Rb(e){let t=e&&[`human-readable`,`si`].find(t=>t.startsWith(e));if(t)return{base:t===`si`?1000n:1024n,unit:1n};if(e.startsWith(`'`))throw new T(`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 Error(`invalid block size: ${e}`);let r=n[2]??``,i=r?`KMGTPEZYRQ`.indexOf(r[0].toUpperCase())+1:0,a=/[BD]$/u.test(r)&&!r.endsWith(`iB`)?1000n:1024n,o=(n[1]?Lb(n[1]):1n)*a**BigInt(i);if(o===0n||o>Sn)throw Error(`invalid block size: ${e}`);return{unit:o,suffix:n[1]||!r?``:(i===1&&r.endsWith(`B`)&&a===1000n?`k`:r[0].toUpperCase())+(r.endsWith(`B`)?a===1000n?`B`:`iB`:``)}}var zb=4096,Bb=60,Vb=(e,t)=>t===`dir`?zb:t===`link`&&e<Bb?0:Math.ceil(e/zb)*zb,Hb=(e,t)=>(e+t-1n)/t;function Ub(e,{base:t,unit:n,suffix:r=``}){if(!t)return String(Hb(e,n))+r;let i=1n,a=0;for(;e>=i*t;)i*=t,a++;if(!a)return String(e);let o=Hb(e*10n,i),s;return o<100n?s=`${o/10n}.${o%10n}`:(o=Hb(e,i),o===t?(a++,s=`1.0`):s=String(o)),s+(a===1&&t===1000n?`k`:`KMGTPEZYRQ`[a-1])}var Wb=15778476e3;function Gb(e,t){for(let t of[`LS_BLOCK_SIZE`,`BLOCK_SIZE`,`BLOCKSIZE`])if(e.vars.has(t))throw new T(`feature`,`block size environment`,`${t} is not supported in a long listing`);let n=t?Fb(e):null,r=e.user??`user`,i=e.createdAt,a=Date.now(),o=i<=a&&a-i<Wb,s=Db(new Date(i),o?`%b %e %H:%M`:`%b %e %Y`,e.vars.has(`TZ`)),c=e=>n?Ub(BigInt(e),n):String(e),l=e=>Math.max(0,...e.map(e=>e.length));return{lines(t,i){let a=t.map(({name:t,abs:n,kind:r,target:i})=>{let a=r===`dir`,o=a?zb:e.fs.fileSize(n)??E(e.fs.readFile(n)).length,s=a?`drwx------`:r===`link`?`lrwxrwxrwx`:`-rw-------`,l=Vb(o,r)/512;return{name:r===`link`?`${t} -> ${i}`:t,mode:s,units:l,links:String(a?2+e.fs.listDir(n).dirs.length:1),size:c(o)}}),o=l(a.map(e=>e.links)),u=l(a.map(e=>e.size)),d=a.map(e=>`${e.mode} ${e.links.padStart(o)} ${r} ${r} ${e.size.padStart(u)} ${s} ${e.name}`);if(i){let e=a.reduce((e,t)=>e+t.units,0);d.unshift(`total `+(n?Ub(BigInt(e)*512n,n):String(e/2)))}return d}}}var Kb=Object.freeze({utf8:{down:`├── `,last:`└── `,through:`│\xA0\xA0 `,past:` `},ascii:{down:`|-- `,last:"`-- ",through:`| `,past:` `}}),qb=e=>tn(e)?Kb.ascii:Kb.utf8;function Jb(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`a`,`d`,`F`],long:[`noreport`],valueShort:[`L`]});if(a.length>1)return C(`feature`,`tree`,`multiple roots`,`tree: multiple roots are not supported`);let o=i.has(`L`)?Yn(i.get(`L`),`tree: -L`,i.get(`L`),{max:2147483647}):{value:1/0};if(o.error)return o.error;if(!o.value)return x(`tree: -L must be greater than zero`);let s=a[0]??`.`,{path:c,error:l}=N(n,`tree`,s),u=!l&&n.fs.isDir(c),d=k(n.cwd,s,n.fs,{follow:!1}),f=!!l&&!!d.error,p={dirs:u&&Zb(n.fs,c,r).length?1:0,files:+(!f&&!u)},m=[s+Yb(n,r,d,u)+(u?``:` [error opening dir]`)];if(u){let e=new Set,t=wn();try{let i=Xb(n.fs,c,m,r,o.value,p,e,t,qb(n));if(i)return i}finally{An(n.notes,{command:`tree`,action:`depth limit omitted contents of`,noun:[`directory`,`directories`],paths:e}),t.emit(n.notes,`tree`,`Hidden entries are included with -a.`)}}if(!r.has(`noreport`)){let e=`${p.dirs} ${p.dirs===1?`directory`:`directories`}`,t=`${p.files} ${p.files===1?`file`:`files`}`;m.push(``,r.has(`d`)?e:`${e}, ${t}`)}return{stdout:m.join(`
201
201
  `)+`
202
- `,stderr:``,exitCode:f?2:0}}function Kb(e,t,n,r){return t.has(`F`)?!n.error&&e.fs.isLink?.(n.path)===!0?`@`:r&&!t.has(`d`)?`/`:``:``}function qb(e,t,n,r,i,a,o,s,c){let l=[{dir:t,prefix:``,items:Jb(e,t,r,s),i:0,depth:0}];for(;l.length;){let t=l.at(-1);if(t.i>=t.items.length){l.pop();continue}let{n:u,isDir:d,target:f}=t.items[t.i++];if([...u+(f??``)].some(e=>e.codePointAt(0)<32||e.codePointAt(0)===127||e===`\\`))return C(`feature`,`tree`,`filename escaping`,`tree: listing names requiring escaping is not supported`);let p=t.i===t.items.length,m=d&&r.has(`F`)&&!r.has(`d`)?`/`:``;if(n.push(t.prefix+(p?c.last:c.down)+u+(f===void 0?m:` -> `+f+m)),a[d?`dirs`:`files`]++,!d||f!==void 0)continue;let h=gt(t.dir,u);if(t.depth+1>=i){Jb(e,h,r).length&&o.add(h);continue}let g=Jb(e,h,r,s);l.push({dir:h,prefix:t.prefix+(p?c.past:c.through),items:g,i:0,depth:t.depth+1})}}function Jb(e,t,n,r=null){let{dirs:i,files:a,links:o}=e.listDir(t),s=o.map(n=>{let r=k(t,n,e);return{n,isDir:!r.error&&e.isDir(r.path),target:e.readLink(gt(t,n))}}),c=n.has(`d`)?s.filter(({isDir:e})=>e):[...a.map(e=>({n:e,isDir:!1})),...s];return r&&!n.has(`a`)&&r.collect(t,[...i,...c.map(({n:e})=>e)]),[...i.map(e=>({n:e,isDir:!0})),...c].filter(({n:e})=>n.has(`a`)||!e.startsWith(`.`)).sort((e,t)=>j(e.n,t.n))}var Yb=new Set([`name`,`iname`,`type`,`path`,`ipath`,`lname`,`ilname`,`size`,`mindepth`,`maxdepth`]),Xb=(e,t)=>e===`-`+t||e===`--`+t;function Zb(e){let t={tokens:e,i:0,depth:{minDepth:0,maxDepth:1/0,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=Qb(t,0);if(t.error)return{error:t.error};if(!t.hasAction)for(let e of r)e.push({kind:`print`});return{starts:n.length?n:[`.`],...t.depth,groups:r,batches:t.batches}}function Qb(e,t){let n=[[]],r=!1;if(t>128)return e.error=C(`feature`,`find`,`expression depth`,`find: expression nesting above 128 is not supported`),n;for(;e.i<e.tokens.length&&!e.error;){let i=e.tokens[e.i];if(i===`)`){t||(e.error=x(`find: unexpected closing parenthesis`));break}if(i===`-a`||Xb(i,`and`)||i===`-o`||Xb(i,`or`)){if(r||n.at(-1).length===0){e.error=x(`find: ${i} with no left-hand expression`);break}(i===`-o`||Xb(i,`or`))&&n.push([]),e.i++,r=i;continue}let a=$b(e,t);a&&n.at(-1).push(a),r=!1}return!e.error&&r&&(e.error=x(`find: ${r} with no right-hand expression`)),!e.error&&t&&n.at(-1).length===0&&(e.error=x(`find: expected an expression`)),!e.error&&t&&(e.tokens[e.i]===`)`?e.i++:e.error=x(`find: missing closing parenthesis`)),n}function $b(e,t){let n=e.i,r=!1;for(;e.tokens[e.i]===`!`||e.tokens[e.i]===`-not`;)r=!r,e.i++;let i=e.tokens[e.i++];if(i===`(`)return{kind:`group`,groups:Qb(e,t+1),negate:r};if(i===void 0||i===`)`||i===`-a`||i===`-o`||Xb(i,`and`)||Xb(i,`or`))return e.error=x(`find: -not or operator ${i??``} must be followed by a primary`),null;let a=i.startsWith(`--`)?i.slice(2):i.startsWith(`-`)?i.slice(1):null;if([`print`,`print0`,`prune`,`empty`].includes(a))return(a===`print`||a===`print0`)&&(e.hasAction=!0),{kind:a,negate:r};if(a===`depth`||a===`d`)return e.depth.deepestFirst=!0,{kind:`true`,negate:r};if(a===`exec`){let t=sx(e.tokens,e.i-1,r);return t.error?(e.error=t.error,null):(e.i=t.nextI+1,e.hasAction=!0,t.pred.mode===`batch`&&e.batches.push(t.pred),t.pred)}if(Yb.has(a)){if(e.i===e.tokens.length)return e.error=x(`find: ${i} requires a value`),null;let t=ex(a,e.tokens[e.i++],r,e.depth);return t.error?(e.error=t.error,null):t}return i===`,`?(e.error=C(`feature`,`find`,`comma operator`,`find: comma expressions are not supported`),null):e.i-1>n&&!i.startsWith(`-`)?(e.error=x(`find: -not must be followed by a primary, got: ${i}`),null):(e.error=i===`--`||!i.startsWith(`-`)?x(`find: paths must precede expression: ${i}`):C(`option`,`find`,i,`find: unknown option: ${i}`),null)}function ex(e,t,n,r){if(e===`type`){let r=ox(t);return r.error?r:{kind:e,negate:n,types:r.types}}if(e===`size`)return rx(t,n);if(e===`mindepth`||e===`maxdepth`){let i=qn(t,`find: -${e}`,t,{max:2147483647,digitsOnly:!0});return i.error?i:(r[e===`mindepth`?`minDepth`:`maxDepth`]=i.value,{kind:`true`,negate:n})}return{kind:e,negate:n,re:Jg(t,{ignoreCase:e.startsWith(`i`)})}}var tx={__proto__:null,b:512,c:1,w:2,k:1024,M:1048576,G:1073741824},nx=/^([+-]?)(\d+)([a-zA-Z]?)$/u;function rx(e,t){if(e===``)return{error:x(`find: invalid null argument to -size`)};let n=nx.exec(e);if(!n||!Number.isSafeInteger(Number(n[2])))return{error:x(`find: Invalid argument \`${e}' to -size`)};let[,r,i,a]=n,o=tx[a===``?`b`:a];return o===void 0?{error:x(`find: invalid -size type \`${a}'`)}:{kind:`size`,negate:t,sign:r,count:Number(i),unit:o}}var ix=`fdl`,ax=`bcps`;function ox(e){let t=e.split(`,`),n=t.find((e,n)=>t.indexOf(e)!==n);if(n!==void 0)return{error:x(`find: Duplicate file type '${n}' in the argument list to -type.`)};if(t.every(e=>e.length===1&&ix.includes(e)))return{types:t};let r=`find: -type/--type expects 'f', 'd' or 'l', got: ${e}`;return{error:t.every(e=>e.length===1&&(ix+ax).includes(e))?C(`option`,`find`,`-type ${e}`,r):x(r)}}function sx(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:x("find: -exec: missing terminator (`;` or `{} +`); quote or escape `;`")};if(r===t+1)return{error:x(`find: -exec: requires a command`)};let i=e.slice(t+1,r),a=e[r]===`;`?`each`:`batch`;if(a===`batch`){if(i.slice(0,-1).some(e=>e.includes(`{}`)))return{error:x("find: -exec ... +: only one instance of `{}` is supported")};if(n)return{error:C(`feature`,`find`,`-not -exec ... +`,"find: `-not -exec ... +` is not supported (the `+` form has no meaningful negation)")}}let o={kind:`exec`,mode:a,cmd:i[0],args:i.slice(1),negate:n};return a===`batch`&&(o.collected=[]),{pred:o,nextI:r}}var cx={file:`f`,dir:`d`,link:`l`},lx=(e,t)=>e.kind===`dir`?Ib:t.fs.fileSize?.(e.abs)??E(t.fs.readFile(e.abs)).length;async function ux(e,t,n){let r=Zb(t);if(r.error)return r.error;if(e!==``&&t.some(e=>e===`-exec`||e===`--exec`))return C(`feature`,`find`,`-exec stdin`,`find: passing shared standard input to -exec is not supported`);let{starts:i,minDepth:a,maxDepth:o,deepestFirst:s,groups:c,batches:l}=r,u=G(),d=new Set;try{for(let e of i){let{path:t,error:r}=N(n,`find`,e,{follow:!1});if(r){hx(u,n.flushOutput(G(`find: '${e}': ${r}
203
- `))),u.exitCode=1;continue}let i=new Set,l=bt(n.fs,t,o,e=>!i.has(e));for(let r of s?dx(l):l){let s=gx(e,t,r.path);if(r.depth>=a&&await fx(c,{kind:r.kind,path:s,abs:r.path,prune:i},n,u),r.kind!==`dir`||r.depth!==o||i.has(r.path))continue;let{dirs:l,files:f,links:p}=n.fs.listDir(r.path);(l.length||f.length||p.length)&&d.add(s)}}for(let e of l){if(e.collected.length===0)continue;let t=e.args.slice(0,-1).concat(e.collected);await mx(e.cmd,t,n,u)||(u.exitCode=1)}}finally{kn(n.notes,{command:`find`,action:`depth limit omitted contents of`,noun:[`directory`,`directories`],paths:d})}return u}function*dx(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 fx(e,t,n,r){for(let i of e){let e=!0;for(let a of i)if(await px(a,t,n,r)===!!a.negate){e=!1;break}if(e)return!0}return!1}function px(e,t,n,r){if(e.kind===`group`)return fx(e.groups,t,n,r);if(e.kind===`true`)return!0;if(e.kind===`type`)return e.types.includes(cx[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:e,files:r,links:i}=n.fs.listDir(t.abs);return e.length+r.length+i.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 r=Math.ceil(lx(t,n)/e.unit);return e.sign===`+`?r>e.count:e.sign===`-`?r<e.count:r===e.count}return e.kind===`print`||e.kind===`print0`?(hx(r,n.flushOutput({stdout:t.path+(e.kind===`print`?`
204
- `:`\0`),stderr:``,exitCode:0})),!0):e.mode===`batch`?(e.collected.push(t.path),!0):mx(e.cmd,e.args.map(e=>e.replaceAll(`{}`,t.path)),n,r)}async function mx(e,t,n,r){let i=await n.dispatch(e,t,``);return hx(r,i),i.exitCode===0}function hx(e,t){let n=e.exitCode;K(e,t),e.exitCode=n}function gx(e,t,n){if(n===t)return e;let r=_t(t,n);return e.endsWith(`/`)?e+r:e+`/`+r}var _x=1e5,vx=/^([+-]?\d+)\.\.([+-]?\d+)(?:\.\.([+-]?\d+))?$/u,yx=/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([+-]?\d+))?$/u,bx=2n**63n-1n,xx=-(2n**63n),Sx=e=>{let t=BigInt(e);return t>bx||t<xx?null:t},Cx=(e,t)=>e.mask===null?`0`:e.mask[t];function wx(e,t=_x){if(!e.value.includes(`{`))return[e];let n=Tx(e);for(let r=0;r<e.value.length;r++){if(e.value[r]!==`{`||Cx(e,r)!==`0`)continue;let i=n.get(r);if(!i)continue;let{end:a,commas:o}=i,s=o.length?[]:Dx(_r(e,r+1,a));if(o.length){let t=r+1;for(let n of[...o,a])s.push(_r(e,t,n)),t=n+1}if(s===null)continue;let c=_r(e,0,r),l=_r(e,a+1),u=[];for(let n of s)if(u.push(...wx(Sr(c,n,l),t)),u.length>t)throw new T(`feature`,`brace expansion limit`,`brace expansion \`${e.value}\` would produce more than ${t} words`);return u}return[e]}function Tx(e){let t=[],n=new Map;for(let r=0;r<e.value.length;r++){if(Cx(e,r)!==`0`)continue;let i=e.value[r];if(i===`{`)t.push({start:r,commas:[]});else if(i===`}`&&t.length){let{start:e,commas:i}=t.pop();n.set(e,{end:r,commas:i})}else i===`,`&&t.length&&t.at(-1).commas.push(r)}return n}function Ex(e){if(e.mask!==null&&/[12]/u.test(e.mask))return null;let t=vx.exec(e.value),n=t??yx.exec(e.value);if(!n)return null;let[r,i]=t?[Sx(t[1]),Sx(t[2])]:[BigInt(n[1].codePointAt(0)),BigInt(n[2].codePointAt(0))],a=n[3]===void 0?1n:Sx(n[3]);if(r===null||i===null||a===null||a===xx)return null;let o=i>=r?i-r:r-i;return o>bx?null:{num:t,range:n,from:r,to:i,step:(a<0n?-a:a)||1n,span:o}}function Dx(e){let t=Ex(e);if(t===null)return null;let{num:n,from:r,to:i,step:a,span:o}=t,s=o/a+1n;if(s>_x)throw new T(`feature`,`brace expansion limit`,`brace expansion \`{${e.value}}\` would produce ${s} words (limit ${_x})`);let c=n?Ox(n[1],n[2]):0,l=[],u=i>=r?1n:-1n;for(let e=0n;e<s;e++){let t=r+u*e*a,i=n?kx(t,c):String.fromCodePoint(Number(t));l.push({value:i,mask:null})}return l}function Ox(e,t){let n=e=>/^-?0\d/u.test(e);return n(e)||n(t)?Math.max(e.length,t.length):0}function kx(e,t){let n=String(e<0n?-e:e),r=e<0n?`-`:``;return r+n.padStart(t-r.length,`0`)}var Ax=new Set([`CDPATH`,`GLOBIGNORE`,`GLOBSORT`,`BASH_COMPAT`,`POSIXLY_CORRECT`,`PATH`,`RANDOM`,`SRANDOM`,`SECONDS`,`EPOCHSECONDS`,`EPOCHREALTIME`,`BASHOPTS`,`SHELLOPTS`,`OPTIND`]),jx=class extends Map{constructor(e){super(e),this.unsetNames=new Set(e?.unsetNames)}set(e,t){if(this.expansionTargets?.has(e))throw new T(`feature`,`temporary assignment side effects`,`modifying a temporary assignment target while expanding assignment values is not supported`);if(Ax.has(e)||e===`TZ`&&![`UTC`,`UTC0`,``].includes(t))throw new T(`feature`,e,`shell variable ${e} is not supported with this value`);return(e===`LANG`||e.startsWith(`LC_`))&&Qt(e,t),this.bound?.add(e),this.unsetNames?.delete(e),super.set(e,t)}delete(e){return this.unsetNames.add(e),super.delete(e)}},Mx=new Set([`$`,`!`,`0`,`-`,`_`]),Nx=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`.split(`.`));function Px(e,t){if(Mx.has(e))throw Ix(e);let n=Rx(e,t);if(n)return n;if(Fx(e))throw Ix(e);return{value:``,set:!1}}var Fx=e=>Ax.has(e)||Nx.has(e),Ix=e=>new T(`feature`,`$${e}`,`shell parameter ${e} is not supported`),Lx=(e,t)=>Rx(e,t)?.value??``;function Rx(e,t){return e===`?`?{value:String(t.lastExit),set:!0}:e===`#`?{value:`0`,set:!0}:e===`@`?{value:``,set:!1,omit:!0}:e===`*`||/^[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 zx(e,t){if(Mx.has(e))throw new T(`feature`,`$${e}`,`shell parameter ${e} is not supported (this terminal runs no process)`);let n=Rx(e,t);if(n)return n;if(Fx(e))throw Ix(e);return Bx(t,`$${e}`,`warning: $${e} is unset (this shell has no environment variables; only \`for\` bindings and \`NAME=value\` assignments)`),{value:``}}function Bx(e,t,n){Yv(e,n+`
206
- `),e.unsupported.add({kind:`feature`,command:null,detail:t,message:n})}var Vx=16e6,Hx=e=>new T(`feature`,"${",e);function Ux(e,t,n){if(r_(t))throw Hx(`extended glob patterns in parameter expansion are not supported`);let r=o_({value:t.value,mask:t.mask??null}),i=n[0]===`#`,a=Xx(r);if(a!==null)return i?e.startsWith(a)?e.slice(a.length):e:e.endsWith(a)?e.slice(0,e.length-a.length):e;let o=Jg(r,{bash:!0}),s=i===(n.length===2),c=s?e.length:0,l=0;for(;c>=0&&c<=e.length;){let t=i?e.slice(0,c):e.slice(c);if(l+=t.length+r.length,l>Vx)throw Hx(`parameter pattern removal exceeds the matching work limit`);if(o.test(t))return i?e.slice(c):e.slice(0,c);c=Yx(e,c,s)}return e}function Wx(e,t,n,r){let i=``;if(!r&&/^[#%]/u.test(t.value)&&(!t.mask||t.mask[0]===`0`)&&(i=t.value[0],t={value:t.value.slice(1),mask:t.mask?.slice(1)??null}),r_(t))throw Hx(`extended glob patterns in parameter expansion are not supported`);let a=o_({value:t.value,mask:t.mask??null}),o={work:0},s=Jx(n,o);if(!a)return i===`#`?s(``)+e:i===`%`?e+s(``):e;if((/\\+$/u.exec(a)?.[0].length??0)%2)throw Hx(`unescaped trailing backslashes in replacement patterns are not supported`);let c=Xx(a),l=c===null?Kx(e,a,i,o):Gx(e,c,i),u=[],d=0;do{let t=l(d);if(!t)break;let[n,i]=t,a=s(e.slice(n,i));if(qx(o,n-d),u.push(e.slice(d,n),a),d=i,!r)break;if(n===i){let t=Yx(e,d,!1);u.push(e.slice(d,t)),d=t}}while(d<e.length);return u.push(e.slice(d)),u.join(``)}function Gx(e,t,n){return r=>{let i=n===`%`?e.length-t.length:e.indexOf(t,r);return i<r||n===`#`&&i!==0||e.slice(i,i+t.length)!==t?null:[i,i+t.length]}}function Kx(e,t,n,r){let i=Jg(t,{bash:!0});return a=>{for(let o=a;o<=e.length;o=Yx(e,o,!1)){for(let a=e.length;a>=o;a=Yx(e,a,!0)){if(qx(r,a-o+t.length),i.test(e.slice(o,a)))return[o,a];if(n===`%`)break}if(n===`#`)break}return null}}function qx(e,t){if(e.work+=t,e.work>Vx)throw Hx(`parameter replacement exceeds the matching work limit`)}function Jx(e,t){let n=``;for(let t=0;t<e.value.length;t++){let r=e.value[t];e.mask?.[t]!==void 0&&e.mask[t]!==`0`&&(r===`&`||r===`\\`)&&(n+=`\\`),n+=r}return e=>{let r=[];for(let i=0;i<n.length;i++){let a=n[i],o=a===`\\`&&/[&\\]/u.test(n[i+1]??``)?n[++i]:a===`&`?e:a;qx(t,o.length),r.push(o)}return r.join(``)}}function Yx(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 Xx(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 Zx=e=>BigInt.asIntN(64,e),J=(e,t)=>new T(`feature`,`arithmetic `+e,`arithmetic expansion: `+t);function Qx(e){let t=10n,n=!1,r=0n,i=0;if(e[0]===`0`&&(i=1,t=8n,n=!0,(e[1]===`x`||e[1]===`X`)&&(t=16n,i=2)),i===2&&e.length===2)throw J(`number`,`hexadecimal constant has no digits`);for(;i<e.length;i++){let a=e[i];if(a===`#`){if(n||r<2n||r>64n||i===e.length-1)throw J(`number`,`invalid arithmetic base or integer constant`);t=r,r=0n,n=!0;continue}let o=a.codePointAt(0),s=o>=48&&o<=57?o-48:o>=97&&o<=122?o-87:o>=65&&o<=90?o-(t<=36n?55:29):a===`@`?62:a===`_`?63:-1;if(s<0||BigInt(s)>=t)throw J(`number`,`value too great for base in `+e.slice(0,40));r=Zx(r*t+BigInt(s))}return r}function $x(e,t){if(t<0n)throw J(`exponent`,`exponent less than zero`);let n=1n;for(let r=t,i=e;r!==0n;r>>=1n,i=Zx(i*i))r&1n&&(n=Zx(n*i));return n}function eS(e,t,n,r){switch(e){case`+`:return Zx(t+n);case`-`:return Zx(t-n);case`*`:return Zx(t*n);case`/`:case`%`:{if(n===0n&&r)throw J(`division`,`division by zero`);let i=n===0n?1n:n;return Zx(e===`/`?t/i:t%i)}case`**`:return $x(t,n);case`<<`:case`>>`:if(n<0n||n>63n)throw J(`shift count`,`shift counts outside 0..63 are not supported`);return Zx(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 J(`operator`,`unsupported operator `+e)}}var tS=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`^=`,`|=`]),nS=new Map([[`||`],[`&&`],[`|`],[`^`],[`&`],[`==`,`!=`],[`<`,`<=`,`>`,`>=`],[`<<`,`>>`],[`+`,`-`],[`*`,`/`,`%`],[`**`]].flatMap((e,t)=>e.map(e=>[e,t+3]))),rS=/^(?:<<=|>>=|\+\+|--|\*\*|&&|\|\||<<|>>|[+\-*/%&^|=!<>]=|[+\-*/%&^|=!~<>?:,()])/u;function iS(e){let t=[];for(let n=0;n<e.length;){if(t.length>=1e4)throw J(`limit`,`expression token limit exceeded`);let r=e.slice(n),i=/^[ \t\n]+/u.exec(r);if(i){n+=i[0].length;continue}let a=/^[0-9][A-Za-z0-9#@_]*/u.exec(r),o=/^[A-Za-z_][A-Za-z0-9_]*/u.exec(r),s=rS.exec(r);if(a)t.push({type:`number`,value:Qx(a[0]),raw:a[0]});else if(o)t.push({type:`name`,value:o[0],raw:o[0]});else if(s)t.push({type:`operator`,value:s[0],raw:s[0]});else throw J(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 aS(e){let t=new oS(iS(e));if(t.token.type===`end`)return{type:`number`,value:0n};let n=t.expression();if(t.token.type!==`end`)throw J(`syntax`,`unexpected token `+t.token.value);return n}var oS=class{constructor(e){this.tokens=e,this.at=0,this.depth=0}get token(){return this.tokens[this.at]}next(){return this.tokens[this.at++]}accept(e){return this.token.value===e?this.next():null}expect(e){if(!this.accept(e))throw J(`syntax`,`expected `+e)}expression(e=0){if(++this.depth>128)throw J(`limit`,`expression nesting limit exceeded`);let t=this.prefix();for(;;){let n=this.token.value;if(n===`?`&&e<=2){this.next();let e=this.expression();this.expect(`:`),t={type:`condition`,test:t,consequent:e,alternate:this.expression(2)};continue}let r=tS.has(n),i=n===`,`?0:r?1:nS.get(n);if(i===void 0||i<e)break;if(this.next(),r&&t.type!==`name`)throw J(`assignment`,`attempted assignment to non-variable`);let a=this.expression(i+(r||n===`**`?0:1));t={type:r?`assignment`:`binary`,op:n,left:t,right:a}}return this.depth--,t}prefix(){let e=this.next();if([`+`,`-`,`!`,`~`].includes(e.value))return{type:`unary`,op:e.value,value:this.expression(14)};if(e.value===`++`||e.value===`--`){let t=this.next();if(t.type!==`name`)throw J(`increment`,`increment requires a scalar variable`);return{type:`increment`,op:e.value,name:t.value,post:!1}}if(e.value===`(`){let e=this.expression();return this.expect(`)`),{type:`group`,value:e}}if(e.type!==`number`&&e.type!==`name`)throw J(`syntax`,`operand expected`);return e.type===`name`&&(this.token.value===`++`||this.token.value===`--`)?{type:`increment`,op:this.next().value,name:e.value,post:!0}:e}};function sS(e,t,n=0){return cS(e,{ctx:t,steps:1e4,characters:2e5},n,!0)}function cS(e,t,n,r){if(typeof e!=`string`)throw J(`value`,`expression must be a string`);if(t.characters-=e.length,e.length>1e5||t.characters<0)throw J(`limit`,`expression size limit exceeded`);if(n>128)throw J(`limit`,`variable recursion limit exceeded`);return dS(aS(e),t,n+1,r)}function lS(e,t,n,r){if(!r)return 0n;let i;try{i=Px(e,t.ctx)}catch(e){throw J(`variable`,L(e))}return i.set&&i.value!==``?cS(i.value,t,n+1,!0):0n}function uS(e,t,n,r){if(r)try{Px(e,n.ctx),n.ctx.vars.set(e,t.toString())}catch(e){throw J(`assignment`,L(e))}return t}function dS(e,t,n,r){if(--t.steps<0||n>128)throw J(`limit`,`expression evaluation limit exceeded`);let i=(e,i=r)=>dS(e,t,n+1,i);switch(e.type){case`number`:return e.value;case`name`:return lS(e.value,t,n,r);case`group`:return i(e.value);case`unary`:{let t=i(e.value);return e.op===`+`?t:e.op===`-`?Zx(-t):e.op===`!`?BigInt(t===0n):~t}case`increment`:{let i=lS(e.name,t,n,r),a=uS(e.name,Zx(i+(e.op===`++`?1n:-1n)),t,r);return e.post?i:a}case`assignment`:{let a=e.left.value,o=e.op===`=`?0n:lS(a,t,n,r),s=i(e.right);return uS(a,e.op===`=`?s:eS(e.op.slice(0,-1),o,s,r),t,r)}case`condition`:{let t=i(e.test)!==0n,n=i(e.consequent,r&&t),a=i(e.alternate,r&&!t);return t?n:a}case`binary`:{let t=i(e.left),n=r&&(e.op===`&&`?t!==0n:e.op!==`||`||t===0n),a=i(e.right,n);return e.op===`,`?a:e.op===`&&`?BigInt(t!==0n&&a!==0n):e.op===`||`?BigInt(t!==0n||a!==0n):eS(e.op,t,a,r)}default:throw J(`syntax`,`unsupported expression`)}}var fS=e=>new T(`feature`,"${",e);async function pS(e,t,n,r){if(e.name===`@`||e.name===`*`)throw fS(`substring and replacement of positional parameter lists are not supported`);if(!t.set)return t;if(e.operator===`:`)try{return{value:await mS(t.value,e.word,n,r)}}catch(e){throw e.halt=!0,e}let i=e.word,a=0;for(;i[a]===`\\`&&i[a+1]===`
207
- `;)a+=2;let o=hS(i,`/`,r.readExpansion,i[a]===`/`?a+1:0),s=await r.expand(i.slice(0,o),{pattern:!0}),c=await r.expand(o<i.length?i.slice(o+1):``,{replacement:!0});return{value:Wx(t.value,s,c,e.operator===`//`)}}async function mS(e,t,n,r){if(/\P{ASCII}/u.test(e))throw fS(`locale-dependent slicing of non-ASCII parameters is not supported`);let i=hS(t,`:`,r.readExpansion),a=async e=>sS((await r.expand(e,{arithmetic:!0})).value,n),o=await a(t.slice(0,i)),s=BigInt(e.length);if(o<0n&&(o+=s),o<0n||o>s)return``;let c=s;if(i<t.length){let e=await a(t.slice(i+1));if(c=e<0n?s+e:o+e,c>yn)throw fS(`substring length overflows the shell integer range`);if(c<o){let e=Error(`${t.slice(i+1)}: substring expression < 0`);throw e.exitCode=1,e.halt=!0,e}}return e.slice(Number(o),Number(c>s?s:c))}function hS(e,t,n,r=0){let i=0,a=null,o=0;for(let s=r;s<e.length;s++){let r=e[s];if(a===`'`){r===`'`&&(a=null);continue}if(a===`ansi`){r===`\\`?s++:r===`'`&&(a=null);continue}if(r===`\\`){s++;continue}if(t===`:`&&(r===`'`||r===`"`))throw fS(`quoted substring arithmetic is not supported`);if(r===`"`){a=a===`"`?null:`"`;continue}if(r===`'`&&!a){a=r;continue}if(r===`$`){let r=n(e,s,0,t===`:`||a===`"`);if(r){s+=r.raw.length-1;continue}let i=s+1;for(;e[i]===`\\`&&e[i+1]===`
208
- `;)i+=2;if(!a&&e[i]===`'`){a=`ansi`,s=i;continue}}if(!a){if(t===`:`){if(r===`(`)i++;else if(r===`)`)i--;else if(i===0&&r===`?`)o++;else if(i===0&&r===`:`&&o){o--;continue}if(i!==0)continue}if(r===t)return s}}return e.length}var gS=/^[A-Za-z_][A-Za-z0-9_]*$/u;async function _S(e,t,n){let{lookup:r,expand:i}=n,{name:a,operator:o,word:s=``}=e,c=r(a,{quiet:o!==``});if(!o)return c;if(o===`length`)return vS(a,c.value,t);if(o===`:`||o.startsWith(`/`))return pS(e,c,t,n);if(o[0]===`#`||o[0]===`%`)return!c.value||!s?c:{value:Ux(c.value,await i(s,{pattern:!0}),o)};let l=!c.set||o.startsWith(`:`)&&c.value===``,u=o[o.length-1];if(u===`+`)return l?{value:``,...c.omit?{omit:!0}:{}}:i(s,{});if(!l)return c;if(u===`?`)throw await yS(a,s,o.startsWith(`:`),i,t);if(u!==`=`)return i(s,{});if(!gS.test(a)){let e=Error(`$${a}: cannot assign in this way`);throw e.exitCode=1,e.halt=!0,e}let d=await i(s,{assignment:!0});return t.vars.set(a,d.value),{value:t.vars.get(a)}}function vS(e,t,n){if(e===`*`||e===`@`)return{value:`0`};if(en(n))return{value:String(p(t).length)};if(/\P{ASCII}/u.test(t))throw Hr(`#`+e,`locale-dependent length of non-ASCII parameters is not supported`);return{value:String(t.length)}}async function yS(e,t,n,r,i){let a=t?bS(await r(t,{error:!0}),i):n?`parameter null or not set`:`parameter not set`,o=Error(`${e}: ${a}`);return o.exitCode=1,o.halt=!0,o}function bS(e,t){let n=t.vars.get(`IFS`)??`
202
+ `,stderr:``,exitCode:f?2:0}}function Yb(e,t,n,r){return t.has(`F`)?!n.error&&e.fs.isLink?.(n.path)===!0?`@`:r&&!t.has(`d`)?`/`:``:``}function Xb(e,t,n,r,i,a,o,s,c){let l=[{dir:t,prefix:``,items:Zb(e,t,r,s),i:0,depth:0}];for(;l.length;){let t=l.at(-1);if(t.i>=t.items.length){l.pop();continue}let{n:u,isDir:d,target:f}=t.items[t.i++];if([...u+(f??``)].some(e=>e.codePointAt(0)<32||e.codePointAt(0)===127||e===`\\`))return C(`feature`,`tree`,`filename escaping`,`tree: listing names requiring escaping is not supported`);let p=t.i===t.items.length,m=d&&r.has(`F`)&&!r.has(`d`)?`/`:``;if(n.push(t.prefix+(p?c.last:c.down)+u+(f===void 0?m:` -> `+f+m)),a[d?`dirs`:`files`]++,!d||f!==void 0)continue;let h=_t(t.dir,u);if(t.depth+1>=i){Zb(e,h,r).length&&o.add(h);continue}let g=Zb(e,h,r,s);l.push({dir:h,prefix:t.prefix+(p?c.past:c.through),items:g,i:0,depth:t.depth+1})}}function Zb(e,t,n,r=null){let{dirs:i,files:a,links:o}=e.listDir(t),s=o.map(n=>{let r=k(t,n,e);return{n,isDir:!r.error&&e.isDir(r.path),target:e.readLink(_t(t,n))}}),c=n.has(`d`)?s.filter(({isDir:e})=>e):[...a.map(e=>({n:e,isDir:!1})),...s];return r&&!n.has(`a`)&&r.collect(t,[...i,...c.map(({n:e})=>e)]),[...i.map(e=>({n:e,isDir:!0})),...c].filter(({n:e})=>n.has(`a`)||!e.startsWith(`.`)).sort((e,t)=>j(e.n,t.n))}var Qb=new Set([`name`,`iname`,`type`,`path`,`ipath`,`lname`,`ilname`,`size`,`mindepth`,`maxdepth`]),$b=(e,t)=>e===`-`+t||e===`--`+t;function ex(e){let t={tokens:e,i:0,depth:{minDepth:0,maxDepth:1/0,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=tx(t,0);if(t.error)return{error:t.error};if(!t.hasAction)for(let e of r)e.push({kind:`print`});return{starts:n.length?n:[`.`],...t.depth,groups:r,batches:t.batches}}function tx(e,t){let n=[[]],r=!1;if(t>128)return e.error=C(`feature`,`find`,`expression depth`,`find: expression nesting above 128 is not supported`),n;for(;e.i<e.tokens.length&&!e.error;){let i=e.tokens[e.i];if(i===`)`){t||(e.error=x(`find: unexpected closing parenthesis`));break}if(i===`-a`||$b(i,`and`)||i===`-o`||$b(i,`or`)){if(r||n.at(-1).length===0){e.error=x(`find: ${i} with no left-hand expression`);break}(i===`-o`||$b(i,`or`))&&n.push([]),e.i++,r=i;continue}let a=nx(e,t);a&&n.at(-1).push(a),r=!1}return!e.error&&r&&(e.error=x(`find: ${r} with no right-hand expression`)),!e.error&&t&&n.at(-1).length===0&&(e.error=x(`find: expected an expression`)),!e.error&&t&&(e.tokens[e.i]===`)`?e.i++:e.error=x(`find: missing closing parenthesis`)),n}function nx(e,t){let n=e.i,r=!1;for(;e.tokens[e.i]===`!`||e.tokens[e.i]===`-not`;)r=!r,e.i++;let i=e.tokens[e.i++];if(i===`(`)return{kind:`group`,groups:tx(e,t+1),negate:r};if(i===void 0||i===`)`||i===`-a`||i===`-o`||$b(i,`and`)||$b(i,`or`))return e.error=x(`find: -not or operator ${i??``} must be followed by a primary`),null;let a=i.startsWith(`--`)?i.slice(2):i.startsWith(`-`)?i.slice(1):null;if([`print`,`print0`,`prune`,`empty`].includes(a))return(a===`print`||a===`print0`)&&(e.hasAction=!0),{kind:a,negate:r};if(a===`depth`||a===`d`)return e.depth.deepestFirst=!0,{kind:`true`,negate:r};if(a===`exec`){let t=ux(e.tokens,e.i-1,r);return t.error?(e.error=t.error,null):(e.i=t.nextI+1,e.hasAction=!0,t.pred.mode===`batch`&&e.batches.push(t.pred),t.pred)}if(Qb.has(a)){if(e.i===e.tokens.length)return e.error=x(`find: ${i} requires a value`),null;let t=rx(a,e.tokens[e.i++],r,e.depth);return t.error?(e.error=t.error,null):t}return i===`,`?(e.error=C(`feature`,`find`,`comma operator`,`find: comma expressions are not supported`),null):e.i-1>n&&!i.startsWith(`-`)?(e.error=x(`find: -not must be followed by a primary, got: ${i}`),null):(e.error=i===`--`||!i.startsWith(`-`)?x(`find: paths must precede expression: ${i}`):C(`option`,`find`,i,`find: unknown option: ${i}`),null)}function rx(e,t,n,r){if(e===`type`){let r=lx(t);return r.error?r:{kind:e,negate:n,types:r.types}}if(e===`size`)return ox(t,n);if(e===`mindepth`||e===`maxdepth`){let i=Yn(t,`find: -${e}`,t,{max:2147483647,digitsOnly:!0});return i.error?i:(r[e===`mindepth`?`minDepth`:`maxDepth`]=i.value,{kind:`true`,negate:n})}return{kind:e,negate:n,re:Zg(t,{ignoreCase:e.startsWith(`i`)})}}var ix={__proto__:null,b:512,c:1,w:2,k:1024,M:1048576,G:1073741824},ax=/^([+-]?)(\d+)([a-zA-Z]?)$/u;function ox(e,t){if(e===``)return{error:x(`find: invalid null argument to -size`)};let n=ax.exec(e);if(!n||!Number.isSafeInteger(Number(n[2])))return{error:x(`find: Invalid argument \`${e}' to -size`)};let[,r,i,a]=n,o=ix[a===``?`b`:a];return o===void 0?{error:x(`find: invalid -size type \`${a}'`)}:{kind:`size`,negate:t,sign:r,count:Number(i),unit:o}}var sx=`fdl`,cx=`bcps`;function lx(e){let t=e.split(`,`),n=t.find((e,n)=>t.indexOf(e)!==n);if(n!==void 0)return{error:x(`find: Duplicate file type '${n}' in the argument list to -type.`)};if(t.every(e=>e.length===1&&sx.includes(e)))return{types:t};let r=`find: -type/--type expects 'f', 'd' or 'l', got: ${e}`;return{error:t.every(e=>e.length===1&&(sx+cx).includes(e))?C(`option`,`find`,`-type ${e}`,r):x(r)}}function ux(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:x("find: -exec: missing terminator (`;` or `{} +`); quote or escape `;`")};if(r===t+1)return{error:x(`find: -exec: requires a command`)};let i=e.slice(t+1,r),a=e[r]===`;`?`each`:`batch`;if(a===`batch`){if(i.slice(0,-1).some(e=>e.includes(`{}`)))return{error:x("find: -exec ... +: only one instance of `{}` is supported")};if(n)return{error:C(`feature`,`find`,`-not -exec ... +`,"find: `-not -exec ... +` is not supported (the `+` form has no meaningful negation)")}}let o={kind:`exec`,mode:a,cmd:i[0],args:i.slice(1),negate:n};return a===`batch`&&(o.collected=[]),{pred:o,nextI:r}}var dx={file:`f`,dir:`d`,link:`l`},fx=(e,t)=>e.kind===`dir`?zb:t.fs.fileSize?.(e.abs)??E(t.fs.readFile(e.abs)).length;async function px(e,t,n){let r=ex(t);if(r.error)return r.error;if(e!==``&&t.some(e=>e===`-exec`||e===`--exec`))return C(`feature`,`find`,`-exec stdin`,`find: passing shared standard input to -exec is not supported`);let{starts:i,minDepth:a,maxDepth:o,deepestFirst:s,groups:c,batches:l}=r,u=G(),d=new Set;try{for(let e of i){let{path:t,error:r}=N(n,`find`,e,{follow:!1});if(r){vx(u,n.flushOutput(G(`find: '${e}': ${r}
203
+ `))),u.exitCode=1;continue}let i=new Set,l=xt(n.fs,t,o,e=>!i.has(e));for(let r of s?mx(l):l){let s=yx(e,t,r.path);if(r.depth>=a&&await hx(c,{kind:r.kind,path:s,abs:r.path,prune:i},n,u),r.kind!==`dir`||r.depth!==o||i.has(r.path))continue;let{dirs:l,files:f,links:p}=n.fs.listDir(r.path);(l.length||f.length||p.length)&&d.add(s)}}for(let e of l){if(e.collected.length===0)continue;let t=e.args.slice(0,-1).concat(e.collected);await _x(e.cmd,t,n,u)||(u.exitCode=1)}}finally{An(n.notes,{command:`find`,action:`depth limit omitted contents of`,noun:[`directory`,`directories`],paths:d})}return u}function*mx(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 hx(e,t,n,r){for(let i of e){let e=!0;for(let a of i)if(await gx(a,t,n,r)===!!a.negate){e=!1;break}if(e)return!0}return!1}function gx(e,t,n,r){if(e.kind===`group`)return hx(e.groups,t,n,r);if(e.kind===`true`)return!0;if(e.kind===`type`)return e.types.includes(dx[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:e,files:r,links:i}=n.fs.listDir(t.abs);return e.length+r.length+i.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 r=Math.ceil(fx(t,n)/e.unit);return e.sign===`+`?r>e.count:e.sign===`-`?r<e.count:r===e.count}return e.kind===`print`||e.kind===`print0`?(vx(r,n.flushOutput({stdout:t.path+(e.kind===`print`?`
204
+ `:`\0`),stderr:``,exitCode:0})),!0):e.mode===`batch`?(e.collected.push(t.path),!0):_x(e.cmd,e.args.map(e=>e.replaceAll(`{}`,t.path)),n,r)}async function _x(e,t,n,r){let i=await n.dispatch(e,t,``);return vx(r,i),i.exitCode===0}function vx(e,t){let n=e.exitCode;K(e,t),e.exitCode=n}function yx(e,t,n){if(n===t)return e;let r=vt(t,n);return e.endsWith(`/`)?e+r:e+`/`+r}var bx=1e5,xx=/^([+-]?\d+)\.\.([+-]?\d+)(?:\.\.([+-]?\d+))?$/u,Sx=/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([+-]?\d+))?$/u,Cx=2n**63n-1n,wx=-(2n**63n),Tx=e=>{let t=BigInt(e);return t>Cx||t<wx?null:t},Ex=(e,t)=>e.mask===null?`0`:e.mask[t];function Dx(e,t=bx){if(!e.value.includes(`{`))return[e];let n=Ox(e);for(let r=0;r<e.value.length;r++){if(e.value[r]!==`{`||Ex(e,r)!==`0`)continue;let i=n.get(r);if(!i)continue;let{end:a,commas:o}=i,s=o.length?[]:Ax(yr(e,r+1,a));if(o.length){let t=r+1;for(let n of[...o,a])s.push(yr(e,t,n)),t=n+1}if(s===null)continue;let c=yr(e,0,r),l=yr(e,a+1),u=[];for(let n of s)if(u.push(...Dx(wr(c,n,l),t)),u.length>t)throw new T(`feature`,`brace expansion limit`,`brace expansion \`${e.value}\` would produce more than ${t} words`);return u}return[e]}function Ox(e){let t=[],n=new Map;for(let r=0;r<e.value.length;r++){if(Ex(e,r)!==`0`)continue;let i=e.value[r];if(i===`{`)t.push({start:r,commas:[]});else if(i===`}`&&t.length){let{start:e,commas:i}=t.pop();n.set(e,{end:r,commas:i})}else i===`,`&&t.length&&t.at(-1).commas.push(r)}return n}function kx(e){if(e.mask!==null&&/[12]/u.test(e.mask))return null;let t=xx.exec(e.value),n=t??Sx.exec(e.value);if(!n)return null;let[r,i]=t?[Tx(t[1]),Tx(t[2])]:[BigInt(n[1].codePointAt(0)),BigInt(n[2].codePointAt(0))],a=n[3]===void 0?1n:Tx(n[3]);if(r===null||i===null||a===null||a===wx)return null;let o=i>=r?i-r:r-i;return o>Cx?null:{num:t,range:n,from:r,to:i,step:(a<0n?-a:a)||1n,span:o}}function Ax(e){let t=kx(e);if(t===null)return null;let{num:n,from:r,to:i,step:a,span:o}=t,s=o/a+1n;if(s>bx)throw new T(`feature`,`brace expansion limit`,`brace expansion \`{${e.value}}\` would produce ${s} words (limit ${bx})`);let c=n?jx(n[1],n[2]):0,l=[],u=i>=r?1n:-1n;for(let e=0n;e<s;e++){let t=r+u*e*a,i=n?Mx(t,c):String.fromCodePoint(Number(t));l.push({value:i,mask:null})}return l}function jx(e,t){let n=e=>/^-?0\d/u.test(e);return n(e)||n(t)?Math.max(e.length,t.length):0}function Mx(e,t){let n=String(e<0n?-e:e),r=e<0n?`-`:``;return r+n.padStart(t-r.length,`0`)}var Nx=new Set([`CDPATH`,`GLOBIGNORE`,`GLOBSORT`,`BASH_COMPAT`,`POSIXLY_CORRECT`,`PATH`,`RANDOM`,`SRANDOM`,`SECONDS`,`EPOCHSECONDS`,`EPOCHREALTIME`,`BASHOPTS`,`SHELLOPTS`,`OPTIND`]),Px=class extends Map{constructor(e){super(e),this.unsetNames=new Set(e?.unsetNames)}set(e,t){if(this.expansionTargets?.has(e))throw new T(`feature`,`temporary assignment side effects`,`modifying a temporary assignment target while expanding assignment values is not supported`);if(Nx.has(e)||e===`TZ`&&![`UTC`,`UTC0`,``].includes(t))throw new T(`feature`,e,`shell variable ${e} is not supported with this value`);return(e===`LANG`||e.startsWith(`LC_`))&&$t(e,t),this.bound?.add(e),this.unsetNames?.delete(e),super.set(e,t)}delete(e){return this.unsetNames.add(e),super.delete(e)}},Fx=new Set([`$`,`!`,`0`,`-`,`_`]),Ix=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`.split(`.`));function Lx(e,t){if(Fx.has(e))throw zx(e);let n=Vx(e,t);if(n)return n;if(Rx(e))throw zx(e);return{value:``,set:!1}}var Rx=e=>Nx.has(e)||Ix.has(e),zx=e=>new T(`feature`,`$${e}`,`shell parameter ${e} is not supported`),Bx=(e,t)=>Vx(e,t)?.value??``;function Vx(e,t){return e===`?`?{value:String(t.lastExit),set:!0}:e===`#`?{value:`0`,set:!0}:e===`@`?{value:``,set:!1,omit:!0}:e===`*`||/^[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 Hx(e,t){if(Fx.has(e))throw new T(`feature`,`$${e}`,`shell parameter ${e} is not supported (this terminal runs no process)`);let n=Vx(e,t);if(n)return n;if(Rx(e))throw zx(e);return Ux(t,`$${e}`,`warning: $${e} is unset (this shell has no environment variables; only \`for\` bindings and \`NAME=value\` assignments)`),{value:``}}function Ux(e,t,n){Qv(e,n+`
206
+ `),e.unsupported.add({kind:`feature`,command:null,detail:t,message:n})}var Wx=16e6,Gx=e=>new T(`feature`,"${",e);function Kx(e,t,n){if(o_(t))throw Gx(`extended glob patterns in parameter expansion are not supported`);let r=l_({value:t.value,mask:t.mask??null}),i=n[0]===`#`,a=$x(r);if(a!==null)return i?e.startsWith(a)?e.slice(a.length):e:e.endsWith(a)?e.slice(0,e.length-a.length):e;let o=Zg(r,{bash:!0}),s=i===(n.length===2),c=s?e.length:0,l=0;for(;c>=0&&c<=e.length;){let t=i?e.slice(0,c):e.slice(c);if(l+=t.length+r.length,l>Wx)throw Gx(`parameter pattern removal exceeds the matching work limit`);if(o.test(t))return i?e.slice(c):e.slice(0,c);c=Qx(e,c,s)}return e}function qx(e,t,n,r){let i=``;if(!r&&/^[#%]/u.test(t.value)&&(!t.mask||t.mask[0]===`0`)&&(i=t.value[0],t={value:t.value.slice(1),mask:t.mask?.slice(1)??null}),o_(t))throw Gx(`extended glob patterns in parameter expansion are not supported`);let a=l_({value:t.value,mask:t.mask??null}),o={work:0},s=Zx(n,o);if(!a)return i===`#`?s(``)+e:i===`%`?e+s(``):e;if((/\\+$/u.exec(a)?.[0].length??0)%2)throw Gx(`unescaped trailing backslashes in replacement patterns are not supported`);let c=$x(a),l=c===null?Yx(e,a,i,o):Jx(e,c,i),u=[],d=0;do{let t=l(d);if(!t)break;let[n,i]=t,a=s(e.slice(n,i));if(Xx(o,n-d),u.push(e.slice(d,n),a),d=i,!r)break;if(n===i){let t=Qx(e,d,!1);u.push(e.slice(d,t)),d=t}}while(d<e.length);return u.push(e.slice(d)),u.join(``)}function Jx(e,t,n){return r=>{let i=n===`%`?e.length-t.length:e.indexOf(t,r);return i<r||n===`#`&&i!==0||e.slice(i,i+t.length)!==t?null:[i,i+t.length]}}function Yx(e,t,n,r){let i=Zg(t,{bash:!0});return a=>{for(let o=a;o<=e.length;o=Qx(e,o,!1)){for(let a=e.length;a>=o;a=Qx(e,a,!0)){if(Xx(r,a-o+t.length),i.test(e.slice(o,a)))return[o,a];if(n===`%`)break}if(n===`#`)break}return null}}function Xx(e,t){if(e.work+=t,e.work>Wx)throw Gx(`parameter replacement exceeds the matching work limit`)}function Zx(e,t){let n=``;for(let t=0;t<e.value.length;t++){let r=e.value[t];e.mask?.[t]!==void 0&&e.mask[t]!==`0`&&(r===`&`||r===`\\`)&&(n+=`\\`),n+=r}return e=>{let r=[];for(let i=0;i<n.length;i++){let a=n[i],o=a===`\\`&&/[&\\]/u.test(n[i+1]??``)?n[++i]:a===`&`?e:a;Xx(t,o.length),r.push(o)}return r.join(``)}}function Qx(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 $x(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 eS=e=>BigInt.asIntN(64,e),J=(e,t)=>new T(`feature`,`arithmetic `+e,`arithmetic expansion: `+t);function tS(e){let t=10n,n=!1,r=0n,i=0;if(e[0]===`0`&&(i=1,t=8n,n=!0,(e[1]===`x`||e[1]===`X`)&&(t=16n,i=2)),i===2&&e.length===2)throw J(`number`,`hexadecimal constant has no digits`);for(;i<e.length;i++){let a=e[i];if(a===`#`){if(n||r<2n||r>64n||i===e.length-1)throw J(`number`,`invalid arithmetic base or integer constant`);t=r,r=0n,n=!0;continue}let o=a.codePointAt(0),s=o>=48&&o<=57?o-48:o>=97&&o<=122?o-87:o>=65&&o<=90?o-(t<=36n?55:29):a===`@`?62:a===`_`?63:-1;if(s<0||BigInt(s)>=t)throw J(`number`,`value too great for base in `+e.slice(0,40));r=eS(r*t+BigInt(s))}return r}function nS(e,t){if(t<0n)throw J(`exponent`,`exponent less than zero`);let n=1n;for(let r=t,i=e;r!==0n;r>>=1n,i=eS(i*i))r&1n&&(n=eS(n*i));return n}function rS(e,t,n,r){switch(e){case`+`:return eS(t+n);case`-`:return eS(t-n);case`*`:return eS(t*n);case`/`:case`%`:{if(n===0n&&r)throw J(`division`,`division by zero`);let i=n===0n?1n:n;return eS(e===`/`?t/i:t%i)}case`**`:return nS(t,n);case`<<`:case`>>`:if(n<0n||n>63n)throw J(`shift count`,`shift counts outside 0..63 are not supported`);return eS(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 J(`operator`,`unsupported operator `+e)}}var iS=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`^=`,`|=`]),aS=new Map([[`||`],[`&&`],[`|`],[`^`],[`&`],[`==`,`!=`],[`<`,`<=`,`>`,`>=`],[`<<`,`>>`],[`+`,`-`],[`*`,`/`,`%`],[`**`]].flatMap((e,t)=>e.map(e=>[e,t+3]))),oS=/^(?:<<=|>>=|\+\+|--|\*\*|&&|\|\||<<|>>|[+\-*/%&^|=!<>]=|[+\-*/%&^|=!~<>?:,()])/u;function sS(e){let t=[];for(let n=0;n<e.length;){if(t.length>=1e4)throw J(`limit`,`expression token limit exceeded`);let r=e.slice(n),i=/^[ \t\n]+/u.exec(r);if(i){n+=i[0].length;continue}let a=/^[0-9][A-Za-z0-9#@_]*/u.exec(r),o=/^[A-Za-z_][A-Za-z0-9_]*/u.exec(r),s=oS.exec(r);if(a)t.push({type:`number`,value:tS(a[0]),raw:a[0]});else if(o)t.push({type:`name`,value:o[0],raw:o[0]});else if(s)t.push({type:`operator`,value:s[0],raw:s[0]});else throw J(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 cS(e){let t=new lS(sS(e));if(t.token.type===`end`)return{type:`number`,value:0n};let n=t.expression();if(t.token.type!==`end`)throw J(`syntax`,`unexpected token `+t.token.value);return n}var lS=class{constructor(e){this.tokens=e,this.at=0,this.depth=0}get token(){return this.tokens[this.at]}next(){return this.tokens[this.at++]}accept(e){return this.token.value===e?this.next():null}expect(e){if(!this.accept(e))throw J(`syntax`,`expected `+e)}expression(e=0){if(++this.depth>128)throw J(`limit`,`expression nesting limit exceeded`);let t=this.prefix();for(;;){let n=this.token.value;if(n===`?`&&e<=2){this.next();let e=this.expression();this.expect(`:`),t={type:`condition`,test:t,consequent:e,alternate:this.expression(2)};continue}let r=iS.has(n),i=n===`,`?0:r?1:aS.get(n);if(i===void 0||i<e)break;if(this.next(),r&&t.type!==`name`)throw J(`assignment`,`attempted assignment to non-variable`);let a=this.expression(i+(r||n===`**`?0:1));t={type:r?`assignment`:`binary`,op:n,left:t,right:a}}return this.depth--,t}prefix(){let e=this.next();if([`+`,`-`,`!`,`~`].includes(e.value))return{type:`unary`,op:e.value,value:this.expression(14)};if(e.value===`++`||e.value===`--`){let t=this.next();if(t.type!==`name`)throw J(`increment`,`increment requires a scalar variable`);return{type:`increment`,op:e.value,name:t.value,post:!1}}if(e.value===`(`){let e=this.expression();return this.expect(`)`),{type:`group`,value:e}}if(e.type!==`number`&&e.type!==`name`)throw J(`syntax`,`operand expected`);return e.type===`name`&&(this.token.value===`++`||this.token.value===`--`)?{type:`increment`,op:this.next().value,name:e.value,post:!0}:e}};function uS(e,t,n=0){return dS(e,{ctx:t,steps:1e4,characters:2e5},n,!0)}function dS(e,t,n,r){if(typeof e!=`string`)throw J(`value`,`expression must be a string`);if(t.characters-=e.length,e.length>1e5||t.characters<0)throw J(`limit`,`expression size limit exceeded`);if(n>128)throw J(`limit`,`variable recursion limit exceeded`);return mS(cS(e),t,n+1,r)}function fS(e,t,n,r){if(!r)return 0n;let i;try{i=Lx(e,t.ctx)}catch(e){throw J(`variable`,I(e))}return i.set&&i.value!==``?dS(i.value,t,n+1,!0):0n}function pS(e,t,n,r){if(r)try{Lx(e,n.ctx),n.ctx.vars.set(e,t.toString())}catch(e){throw J(`assignment`,I(e))}return t}function mS(e,t,n,r){if(--t.steps<0||n>128)throw J(`limit`,`expression evaluation limit exceeded`);let i=(e,i=r)=>mS(e,t,n+1,i);switch(e.type){case`number`:return e.value;case`name`:return fS(e.value,t,n,r);case`group`:return i(e.value);case`unary`:{let t=i(e.value);return e.op===`+`?t:e.op===`-`?eS(-t):e.op===`!`?BigInt(t===0n):~t}case`increment`:{let i=fS(e.name,t,n,r),a=pS(e.name,eS(i+(e.op===`++`?1n:-1n)),t,r);return e.post?i:a}case`assignment`:{let a=e.left.value,o=e.op===`=`?0n:fS(a,t,n,r),s=i(e.right);return pS(a,e.op===`=`?s:rS(e.op.slice(0,-1),o,s,r),t,r)}case`condition`:{let t=i(e.test)!==0n,n=i(e.consequent,r&&t),a=i(e.alternate,r&&!t);return t?n:a}case`binary`:{let t=i(e.left),n=r&&(e.op===`&&`?t!==0n:e.op!==`||`||t===0n),a=i(e.right,n);return e.op===`,`?a:e.op===`&&`?BigInt(t!==0n&&a!==0n):e.op===`||`?BigInt(t!==0n||a!==0n):rS(e.op,t,a,r)}default:throw J(`syntax`,`unsupported expression`)}}var hS=e=>new T(`feature`,"${",e);async function gS(e,t,n,r){if(e.name===`@`||e.name===`*`)throw hS(`substring and replacement of positional parameter lists are not supported`);if(!t.set)return t;if(e.operator===`:`)try{return{value:await _S(t.value,e.word,n,r)}}catch(e){throw e.halt=!0,e}let i=e.word,a=0;for(;i[a]===`\\`&&i[a+1]===`
207
+ `;)a+=2;let o=vS(i,`/`,r.readExpansion,i[a]===`/`?a+1:0),s=await r.expand(i.slice(0,o),{pattern:!0}),c=await r.expand(o<i.length?i.slice(o+1):``,{replacement:!0});return{value:qx(t.value,s,c,e.operator===`//`)}}async function _S(e,t,n,r){if(/\P{ASCII}/u.test(e))throw hS(`locale-dependent slicing of non-ASCII parameters is not supported`);let i=vS(t,`:`,r.readExpansion),a=async e=>uS((await r.expand(e,{arithmetic:!0})).value,n),o=await a(t.slice(0,i)),s=BigInt(e.length);if(o<0n&&(o+=s),o<0n||o>s)return``;let c=s;if(i<t.length){let e=await a(t.slice(i+1));if(c=e<0n?s+e:o+e,c>bn)throw hS(`substring length overflows the shell integer range`);if(c<o){let e=Error(`${t.slice(i+1)}: substring expression < 0`);throw e.exitCode=1,e.halt=!0,e}}return e.slice(Number(o),Number(c>s?s:c))}function vS(e,t,n,r=0){let i=0,a=null,o=0;for(let s=r;s<e.length;s++){let r=e[s];if(a===`'`){r===`'`&&(a=null);continue}if(a===`ansi`){r===`\\`?s++:r===`'`&&(a=null);continue}if(r===`\\`){s++;continue}if(t===`:`&&(r===`'`||r===`"`))throw hS(`quoted substring arithmetic is not supported`);if(r===`"`){a=a===`"`?null:`"`;continue}if(r===`'`&&!a){a=r;continue}if(r===`$`){let r=n(e,s,0,t===`:`||a===`"`);if(r){s+=r.raw.length-1;continue}let i=s+1;for(;e[i]===`\\`&&e[i+1]===`
208
+ `;)i+=2;if(!a&&e[i]===`'`){a=`ansi`,s=i;continue}}if(!a){if(t===`:`){if(r===`(`)i++;else if(r===`)`)i--;else if(i===0&&r===`?`)o++;else if(i===0&&r===`:`&&o){o--;continue}if(i!==0)continue}if(r===t)return s}}return e.length}var yS=/^[A-Za-z_][A-Za-z0-9_]*$/u;async function bS(e,t,n){let{lookup:r,expand:i}=n,{name:a,operator:o,word:s=``}=e,c=r(a,{quiet:o!==``});if(!o)return c;if(o===`length`)return xS(a,c.value,t);if(o===`:`||o.startsWith(`/`))return gS(e,c,t,n);if(o[0]===`#`||o[0]===`%`)return!c.value||!s?c:{value:Kx(c.value,await i(s,{pattern:!0}),o)};let l=!c.set||o.startsWith(`:`)&&c.value===``,u=o[o.length-1];if(u===`+`)return l?{value:``,...c.omit?{omit:!0}:{}}:i(s,{});if(!l)return c;if(u===`?`)throw await SS(a,s,o.startsWith(`:`),i,t);if(u!==`=`)return i(s,{});if(!yS.test(a)){let e=Error(`$${a}: cannot assign in this way`);throw e.exitCode=1,e.halt=!0,e}let d=await i(s,{assignment:!0});return t.vars.set(a,d.value),{value:t.vars.get(a)}}function xS(e,t,n){if(e===`*`||e===`@`)return{value:`0`};if(tn(n))return{value:String(p(t).length)};if(/\P{ASCII}/u.test(t))throw Wr(`#`+e,`locale-dependent length of non-ASCII parameters is not supported`);return{value:String(t.length)}}async function SS(e,t,n,r,i){let a=t?CS(await r(t,{error:!0}),i):n?`parameter null or not set`:`parameter not set`,o=Error(`${e}: ${a}`);return o.exitCode=1,o.halt=!0,o}function CS(e,t){let n=t.vars.get(`IFS`)??`
209
209
  `;if(n===``)return e.value;if(n!==`
210
- `)throw Hr(`?`,`custom IFS separators in parameter errors are not supported`);let r=new Set(e.empty),i=[],a=!1,o=``,s=()=>{(o||a)&&i.push(o),o=``,a=!1};for(let t=0;t<=e.value.length&&(r.has(t)&&(a=!0),t!==e.value.length);t++){let n=e.value[t],r=!e.mask||e.mask[t]===`0`;r&&/[ \t\n]/u.test(n)?s():(o+=n,a||=!r)}return s(),i.join(` `)}function xS(e,t){return SS(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new jx(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function SS(e,t,n){let r=Object.fromEntries(Object.keys(t).map(t=>[t,e[t]]));Object.assign(e,t);try{return await n()}finally{Object.assign(e,r)}}async function CS(e,t){let n=[],r=e[0],i=r?.value===`export`&&!/[12]/u.test(r.mask??``)&&!r.empty?.length;for(let r of e)for(let e of wx(r)){let a=i&&e===r&&vr(r);if(a){let r=await ES(e,a.end,t);n.push({value:r,mask:`1`.repeat(r.length),q:!0})}else n.push(...await MS(AS(e,t,e!==r&&`word`),t,!0))}return{argv:wS(n,t)}}function wS(e,t){let n=[];for(let r of e){if(n_(r)){let e=s_(r,t);if(e.length>0){n.push(...e);continue}}(r.value!==``||r.q)&&n.push(r.value)}return n}async function TS(e,t){let{argv:n}=await CS([e],t);return n.length===1?{value:n[0]}:{error:`${e.value}: ambiguous redirect`}}async function ES(e,t,n){let r=_r(e,t);return e.value.slice(0,t)+await DS(r,n,!0)}async function DS(e,t,n=!1){return(await MS(AS(e,t,n),t,!1,n))[0].value}var OS=e=>e.vars.get(`HOME`)??e.home,kS=(e,t)=>e.mask===null?`0`:e.mask[t];function AS(e,t,n=!1){let r=br(e,n);if(r.size===0)return e;let i=e.value,a=OS(t),o=``,s=``,c=[];for(let t=0;t<i.length;t++){if(e.empty?.includes(t)&&c.push(o.length),r.has(t)){let e=a===`/`&&i[t+1]===`/`?``:a;o+=e,s+=`1`.repeat(e.length);continue}o+=i[t],s+=kS(e,t)}return e.empty?.includes(i.length)&&c.push(o.length),{value:o,mask:/[12]/u.test(s)?s:null,...c.length?{empty:c}:{}}}function jS(e,t){return SS(t,{strictExpansion:!0},()=>NS(AS(e,t),t))}async function MS(e,t,n,r=!1){let i=await NS(e,t,r);return n?IS(i,t):[i]}async function NS(e,t,n=!1){let r={value:``,mask:``,empty:[],split:!1},i=(e,t)=>{r.value+=e,r.mask+=t};e.value===``&&e.mask!==null&&r.empty.push(0);for(let a=0;a<=e.value.length&&(e.empty?.includes(a)&&r.empty.push(r.value.length),a!==e.value.length);a++){let o=kS(e,a),s=e.value[a];if(o===`0`&&(s===`<`||s===`>`)&&e.value[a+1]===`(`)throw new T(`feature`,`${s}(`,`process substitution (\`${s}(\u2026)\`) is not supported`);let c=o!==`1`&&(s===`$`||s==="`"),l=e.value[a+1]===`(`||e.value[a+1]===`{`,u=c?PS(e,a,s,o,l):null;if(!u){i(e.value[a],o);continue}a+=u.raw.length-1;let d=await FS(u,t,o===`2`,n);if(d.literal){i(u.raw,o.repeat(u.raw.length));continue}if(!d.omit){if(o===`2`)d.value===``&&r.empty.push(r.value.length),i(d.value,`2`.repeat(d.value.length));else{r.split=!0;for(let e of d.empty??[])r.empty.push(r.value.length+e);d.q&&!d.value&&!d.empty?.length&&r.empty.push(r.value.length),i(d.value,d.mask??`0`.repeat(d.value.length))}}}return r.q=r.empty.length>0||/[12]/u.test(r.mask),r}function PS(e,t,n,r,i){return n==="`"?wr(e.value,t):i?vi(e.value,t,0,r===`2`):_i(e.value,t,e.mask)}async function FS(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 n=await SS(t,{strictExpansion:!0},()=>DS(zi(e.arithmetic,!0),t));return{value:String(sS(n,t))}}catch(e){throw e.halt=!0,e}return e.parameter===void 0?t.strictExpansion?Px(e.name,t):zx(e.name,t):e.parameter.operator===``&&!t.strictExpansion&&!/^[0-9]{2,}$/u.test(e.parameter.name)?zx(e.parameter.name,t):_S(e.parameter,t,{lookup:e=>Px(e,t),readExpansion:vi,expand:(e,i={})=>{let a=i.pattern||i.error||i.replacement||i.arithmetic,o=zi(e,i.arithmetic||!a&&n),s=!a&&(i.assignment||r),c=i.assignment?`parameterAssign`:s?!0:`parameter`;return SS(t,{strictExpansion:!0},()=>NS(i.arithmetic?o:AS(o,t,c),t,s))}})}function IS(e,t){if(!e.split)return e.value!==``||e.q?[e]:[];let n=t.vars.get(`IFS`)??`
210
+ `)throw Wr(`?`,`custom IFS separators in parameter errors are not supported`);let r=new Set(e.empty),i=[],a=!1,o=``,s=()=>{(o||a)&&i.push(o),o=``,a=!1};for(let t=0;t<=e.value.length&&(r.has(t)&&(a=!0),t!==e.value.length);t++){let n=e.value[t],r=!e.mask||e.mask[t]===`0`;r&&/[ \t\n]/u.test(n)?s():(o+=n,a||=!r)}return s(),i.join(` `)}function wS(e,t){return TS(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new Px(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function TS(e,t,n){let r=Object.fromEntries(Object.keys(t).map(t=>[t,e[t]]));Object.assign(e,t);try{return await n()}finally{Object.assign(e,r)}}async function ES(e,t){let n=[],r=e[0],i=r?.value===`export`&&!/[12]/u.test(r.mask??``)&&!r.empty?.length;for(let r of e)for(let e of Dx(r)){let a=i&&e===r&&br(r);if(a){let r=await kS(e,a.end,t);n.push({value:r,mask:`1`.repeat(r.length),q:!0})}else n.push(...await FS(NS(e,t,e!==r&&`word`),t,!0))}return{argv:DS(n,t)}}function DS(e,t){let n=[];for(let r of e){if(a_(r)){let e=u_(r,t);if(e.length>0){n.push(...e);continue}}(r.value!==``||r.q)&&n.push(r.value)}return n}async function OS(e,t){let{argv:n}=await ES([e],t);return n.length===1?{value:n[0]}:{error:`${e.value}: ambiguous redirect`}}async function kS(e,t,n){let r=yr(e,t);return e.value.slice(0,t)+await AS(r,n,!0)}async function AS(e,t,n=!1){return(await FS(NS(e,t,n),t,!1,n))[0].value}var jS=e=>e.vars.get(`HOME`)??e.home,MS=(e,t)=>e.mask===null?`0`:e.mask[t];function NS(e,t,n=!1){let r=Sr(e,n);if(r.size===0)return e;let i=e.value,a=jS(t),o=``,s=``,c=[];for(let t=0;t<i.length;t++){if(e.empty?.includes(t)&&c.push(o.length),r.has(t)){let e=a===`/`&&i[t+1]===`/`?``:a;o+=e,s+=`1`.repeat(e.length);continue}o+=i[t],s+=MS(e,t)}return e.empty?.includes(i.length)&&c.push(o.length),{value:o,mask:/[12]/u.test(s)?s:null,...c.length?{empty:c}:{}}}function PS(e,t){return TS(t,{strictExpansion:!0},()=>IS(NS(e,t),t))}async function FS(e,t,n,r=!1){let i=await IS(e,t,r);return n?zS(i,t):[i]}async function IS(e,t,n=!1){let r={value:``,mask:``,empty:[],split:!1},i=(e,t)=>{r.value+=e,r.mask+=t};e.value===``&&e.mask!==null&&r.empty.push(0);for(let a=0;a<=e.value.length&&(e.empty?.includes(a)&&r.empty.push(r.value.length),a!==e.value.length);a++){let o=MS(e,a),s=e.value[a];if(o===`0`&&(s===`<`||s===`>`)&&e.value[a+1]===`(`)throw new T(`feature`,`${s}(`,`process substitution (\`${s}(\u2026)\`) is not supported`);let c=o!==`1`&&(s===`$`||s==="`"),l=e.value[a+1]===`(`||e.value[a+1]===`{`,u=c?LS(e,a,s,o,l):null;if(!u){i(e.value[a],o);continue}a+=u.raw.length-1;let d=await RS(u,t,o===`2`,n);if(d.literal){i(u.raw,o.repeat(u.raw.length));continue}if(!d.omit){if(o===`2`)d.value===``&&r.empty.push(r.value.length),i(d.value,`2`.repeat(d.value.length));else{r.split=!0;for(let e of d.empty??[])r.empty.push(r.value.length+e);d.q&&!d.value&&!d.empty?.length&&r.empty.push(r.value.length),i(d.value,d.mask??`0`.repeat(d.value.length))}}}return r.q=r.empty.length>0||/[12]/u.test(r.mask),r}function LS(e,t,n,r,i){return n==="`"?Er(e.value,t):i?bi(e.value,t,0,r===`2`):yi(e.value,t,e.mask)}async function RS(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 n=await TS(t,{strictExpansion:!0},()=>AS(Vi(e.arithmetic,!0),t));return{value:String(uS(n,t))}}catch(e){throw e.halt=!0,e}return e.parameter===void 0?t.strictExpansion?Lx(e.name,t):Hx(e.name,t):e.parameter.operator===``&&!t.strictExpansion&&!/^[0-9]{2,}$/u.test(e.parameter.name)?Hx(e.parameter.name,t):bS(e.parameter,t,{lookup:e=>Lx(e,t),readExpansion:bi,expand:(e,i={})=>{let a=i.pattern||i.error||i.replacement||i.arithmetic,o=Vi(e,i.arithmetic||!a&&n),s=!a&&(i.assignment||r),c=i.assignment?`parameterAssign`:s?!0:`parameter`;return TS(t,{strictExpansion:!0},()=>IS(i.arithmetic?o:NS(o,t,c),t,s))}})}function zS(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 T(`feature`,`IFS`,`custom IFS separators are not supported`);let r=[],i={value:``,mask:``,q:!1},a=()=>{(i.value!==``||i.q)&&r.push(i),i={value:``,mask:``,q:!1}},o=new Set(e.empty);for(let t=0;t<=e.value.length&&(o.has(t)&&(i.q=!0),t!==e.value.length);t++){let r=e.value[t],o=e.mask[t];if(n!==``&&o===`0`&&/[ \t\n]/u.test(r)){a();continue}i.value+=r,i.mask+=o,i.q||=o!==`0`}return a(),r}function LS(e,t,n){let r=jb(t,n),i={ctx:n,options:r,seen:new Set,result:G(),total:0n,failed:!1};r.stderr&&K(i.result,n.flushOutput(G(r.stderr)));for(let e of r.operands){let t=e.length>2?e.replace(/\/+$/u,`/`):e,a=N(n,`du`,t,{follow:r.links!==`none`});if(a.error){K(i.result,n.flushOutput(x(`du: cannot access ${q(t,n)}: ${a.error}`))),i.failed=!0;continue}try{RS(a.path,t,i)}catch(e){let t=S(e),r=`du: `+L(e);if(t&&n.unsupported.add({...t,command:t.command??`du`,message:r}),K(i.result,n.flushOutput(x(r))),i.failed=!0,t)return i.result}}return r.flags.has(`c`)&&zS(i.total,`total`,i),i.result.exitCode=+!!i.failed,i.result}function RS(e,t,n){let{ctx:r,options:i}=n;if(!i.flags.has(`inodes`)&&r.fs.isDir(e)&&Object.values(r.outputFds??{}).some(t=>typeof t==`object`&&t.path?.startsWith(e===`/`?`/`:e+`/`)))throw new T(`feature`,`recursive metadata output overlap`,`output within a measured directory is not supported`);let a=[{path:e,name:t,depth:0}];for(;a.length;){let e=a.pop();if(e.total!==void 0){e.depth<=i.depth&&zS(e.total,e.name,n),e.parent&&!i.flags.has(`S`)&&(e.parent.total+=e.total);continue}let t=r.fs.isDir(e.path);if(!t&&i.links===`all`&&r.fs.isLink?.(e.path))throw new T(`option`,`dereference`,`following symbolic links is not supported: ${e.name}`);let o=t?e.path:r.fs.fileIdentity?.(e.path)??e.path;if(!i.flags.has(`l`)&&n.seen.has(o))continue;n.seen.add(o);let s=t?`dir`:r.fs.isLink?.(e.path)?`link`:`file`,c=t?0:r.fs.fileSize(e.path),l=i.flags.has(`inodes`)?1n:i.flags.has(`A`)?BigInt(c):BigInt(Rb(c,s));if(n.total+=l,t){e.total=l,a.push(e);let t=r.fs.listDir(e.path),n=[...new Set([...t.dirs,...t.files,...t.links])].sort(j),i=e.name.endsWith(`/`)?e.name:e.name+`/`;for(let t=n.length-1;t>=0;t--)a.push({path:gt(e.path,n[t]),name:i+n[t],depth:e.depth+1,parent:e})}else e.parent&&(e.parent.total+=l),(e.depth===0||i.flags.has(`a`)&&e.depth<=i.depth)&&zS(l,e.name,n)}}function zS(e,t,n){let r=`${Bb(e,n.options.scale)} ${t}${n.options.flags.has(`0`)?`\0`:`
213
- `}`;K(n.result,n.ctx.flushOutput({...G(),stdout:r,events:[{fd:1,text:r}]}))}var BS=/^%([-+ 0#']*)(\d+|\*)?'?(?:\.(\d+|\*)?)?[hlL]?(.)?/su,VS=`diouxXeEfFgGcs`;function HS(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 W(`positional printf arguments are not supported`,null,`positional format arguments`);let i=BS.exec(e.slice(r)),a=i[4];if(a===`a`||a===`A`)throw new W(`hexadecimal floating-point formats are not supported`,null,`hexadecimal float format`);if(a===`%`){n+=`%`,r+=i[0].length-1;continue}if(a===void 0||!VS.includes(a)){n+=i[0],r+=i[0].length-1;continue}n!==``&&(t.push(n),n=``);let o=i[1];t.push({minus:o.includes(`-`),plus:o.includes(`+`),space:o.includes(` `),zero:o.includes(`0`),alt:o.includes(`#`),width:i[2]===void 0?null:i[2]===`*`?`*`:Number(i[2]),precision:i[3]===void 0?i[0].includes(`.`)?0:null:i[3]===`*`?`*`:Number(i[3]),conv:a}),r+=i[0].length-1}return n!==``&&t.push(n),t}function US(e,t,n,r){let i=n.width??0;if(i>oh)throw new W(`format width exceeds the output limit`,null,`format size limit`);let a=i-e.length-[...t].length;return a<=0?e+t:n.minus?e+t+` `.repeat(a):n.zero&&r?e+`0`.repeat(a)+t:` `.repeat(a)+e+t}var WS=e=>e.plus?`+`:e.space?` `:``,GS=e=>e===`X`||e===`E`||e===`G`||e===`F`;function KS(e,t){if(t.precision>oh)throw new W(`format precision exceeds the output limit`,null,`format size limit`);let{conv:n}=t;if(!Number.isFinite(e)){if(Number.isNaN(e))throw new W(`formatting signed NaN is not supported`,null,`signed NaN`);let t=e<0?`-inf`:`+inf`;return GS(n)?t.toUpperCase():t}return`ouxX`.includes(n)&&(e>=2**64||e<-(2**63))?YS(e,{...t,conv:`g`}):`diouxX`.includes(n)?qS(e,t):YS(e,t)}function qS(e,t){let{conv:n}=t,r=n===`d`||n===`i`,i=r?Math.trunc(e)===0:e===0,a=BigInt(Math.trunc(e)),o=!1;a<0n&&(r?(o=!0,a=-a):a=BigInt.asUintN(64,a));let s=n===`o`?8:n===`x`||n===`X`?16:10,c=a.toString(s);n===`X`&&(c=c.toUpperCase()),t.precision!==null&&(c=t.precision===0&&i?t.alt&&!r?`0`:``:c.padStart(t.precision,`0`));let l=o?`-`:r&&c!==``?WS(t):``;return t.alt&&!i&&(n===`o`&&(c=`0`+c),(n===`x`||n===`X`)&&(l+=n===`x`?`0x`:`0X`)),US(l,c,t,t.precision===null)}var JS=100;function YS(e,t){let{conv:n}=t;if(t.precision>JS)throw new W(`floating-point precision above ${JS} is not supported`,null,`float precision limit`);let r=t.precision??6,i=e<0||Object.is(e,-0),a=Math.abs(e),o;return o=n===`e`||n===`E`?ZS(a,r):n===`f`||n===`F`?QS(a,r):$S(a,r,t.alt),t.alt&&r===0&&n!==`g`&&n!==`G`&&(o=n===`e`||n===`E`?o.replace(`e`,`.e`):o+`.`),GS(n)&&(o=o.toUpperCase()),US(i?`-`:WS(t),o,t,!0)}function XS(e,t,n,r){let i=t.slice(r);if(!/^50*$/u.test(i))return e;let a=t.slice(0,n),o=a.at(-1);return Number(o)%2==0?a:e}function ZS(e,t){let n=e.toExponential(JS),r=n.indexOf(`.`),i=n.indexOf(`e`),[a,o]=e.toExponential(t).split(`e`),s=XS(a,n.slice(0,i),t===0?r:r+1+t,r+1+t),c=Number(s===a?o:n.slice(i+1));return`${s}e${c<0?`-`:`+`}${String(Math.abs(c)).padStart(2,`0`)}`}function QS(e,t){if(e>=1e21)return BigInt(e).toString()+(t>0?`.`+`0`.repeat(t):``);let n=e.toFixed(JS),r=n.indexOf(`.`);return XS(e.toFixed(t),n,t===0?r:r+1+t,r+1+t)}function $S(e,t,n){let r=t===0?1:t;if(e===0)return n?`0.`+`0`.repeat(r-1):`0`;let i=ZS(e,r-1),a=i.indexOf(`e`),o=Number(i.slice(a+1));if(o<-4||o>=r)return n?i.includes(`.`)?i:i.slice(0,a)+`.`+i.slice(a):eC(i.slice(0,a))+i.slice(a);let s=QS(e,r-1-o);return n?s.includes(`.`)?s:s+`.`:eC(s)}var eC=e=>e.includes(`.`)?e.replace(/\.?0+$/u,``):e,tC=/^[+-]?(?:0[bB][01]+|0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)/u,nC=/^[+-]?(?:0[xX](?:[\da-fA-F]+(?:\.[\da-fA-F]*)?|\.[\da-fA-F]+)(?:[pP][+-]?\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|inf(?:inity)?|nan(?:\([\w]*\))?)/iu;function rC(e,t){if(e?.[0]!==`'`&&e?.[0]!==`"`)return null;let n=e.slice(1);if(n===``)return null;let r=p(n),i=t.byteLocale?1:p(String.fromCodePoint(n.codePointAt(0))).length;return r.length>i&&(t.stderr+=`printf: warning: ${D(r.slice(i))}: character(s) following character constant have been ignored
214
- `),t.byteLocale?r[0]:n.codePointAt(0)}function iC(e,t,n){if(e===void 0||e===``)return`0`;let r=e.replace(/^[ \t\n\r\f\v]+/u,``),i=t.exec(r)?.[0]??``;return(i.length!==r.length||i===``)&&(n.stderr+=`printf: ${sC(e,n)}: ${i?`value not completely converted`:`expected a numeric value`}
215
- `,n.failed=!0),i||`0`}var aC={"\x07":`\\a`,"\b":`\\b`," ":`\\t`,"\n":`\\n`,"\v":`\\v`,"\f":`\\f`,"\r":`\\r`,"\\":`\\\\`,"'":`\\'`},oC=e=>`\\`+e.toString(8).padStart(3,`0`);function sC(e,t){let n=``;for(let r of e){if(aC[r]!==void 0){n+=aC[r];continue}let e=r.codePointAt(0);if(e<32||e===127){n+=oC(e);continue}n+=e>127&&t.byteLocale?p(r).map(oC).join(``):r}return`'${n}'`}function cC(e,t,n){let r=rC(e,n);if(r!==null)return BigInt(r);let i=iC(e,tC,n),a=i[0]===`-`,o=i.replace(/^[+-]/u,``),s=BigInt(/^0[0-7]+$/u.test(o)?`0o`+o:o),c=a?-s:s;return(t?s>xn:c<bn||c>yn)?(n.stderr+=`printf: ${sC(e,n)}: Numerical result out of range
216
- `,n.failed=!0,t?xn:a?bn:yn):t?BigInt.asUintN(64,c):c}function lC(e,t){let{conv:n}=t,r=n===`d`||n===`i`,i=e<0n,a=n===`o`?8:n===`x`||n===`X`?16:10,o=(i?-e:e).toString(a);n===`X`&&(o=o.toUpperCase()),e===0n&&t.precision===0&&(o=``),o=o.padStart(t.precision??0,`0`);let s=i?`-`:r?t.plus?`+`:t.space?` `:``:``;return t.alt&&(n===`o`&&!o.startsWith(`0`)&&(o=`0`+o),e!==0n&&(n===`x`||n===`X`)&&(s=n===`x`?`0x`:`0X`)),US(s,o,t,t.precision===null)}function uC(e,t,n){let r=rC(e,n),i=r===null?iC(e,nC,n):String(r),a=i.replace(/^[+-]/u,``);if(/^(?:inf|nan)/iu.test(a)){let e=i.startsWith(`-`)?`-`:t.plus?`+`:t.space?` `:``,n=/^nan/iu.test(a)?`nan`:`inf`;return t.conv===t.conv.toUpperCase()&&(n=n.toUpperCase()),US(e,n,t,!1)}let o=vC(a),s=i.startsWith(`-`)?-o.value:o.value;if(t.precision>100||`gG`.includes(t.conv)&&t.precision>96)throw new T(`feature`,`float precision limit`,`floating-point precision exceeds the supported limit`);try{let e=KS(s,t);if(!o.exact){let[n,r]=pC(o.value);for(let a of[n,r])if(KS(i.startsWith(`-`)?-a:a,t)!==e)throw new T(`feature`,`floating-point precision`,`floating-point formatting at this precision is not supported`)}return e}catch(e){throw e.gap?new T(`feature`,e.gap,e.message):e}}var dC=new DataView(new ArrayBuffer(8));function fC(e){return dC.setFloat64(0,e),dC.getBigUint64(0)}function pC(e){let t=fC(e);dC.setBigUint64(0,t-1n);let n=dC.getFloat64(0);return dC.setBigUint64(0,t+1n),[n,dC.getFloat64(0)]}function mC(e){let t=fC(e),n=Number(t>>52n);return{coefficient:t&(1n<<52n)-1n|(n?1n<<52n:0n),exponent:n?n-1075:-1074}}function hC(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 gC({coefficient:e,exponent:t}){return t<0?hC((e*5n**BigInt(-t)).toString(),t):hC((e<<BigInt(t)).toString(),0)}function _C(e,t){let n=e.exponent-t.exponent;return n>=0?e.coefficient<<BigInt(n)===t.coefficient:e.coefficient===t.coefficient<<BigInt(-n)}function vC(e){let t=/^0x/iu.test(e),n,r;if(t)n=yC(e),r=bC(n);else{let[t,i=`0`]=e.split(/[eE]/u),[a,o=``]=t.split(`.`);n=hC(a+o,Number(i)-o.length),r=Number(e)}if(!Number.isFinite(r))throw new T(`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 T(`feature`,`floating-point range`,`floating-point underflow is not supported`);return{value:r,exact:!0}}let i=mC(r),a=gC(i),o=t?_C(n,i):n.digits===a.digits&&n.exponent===a.exponent;return{value:r,exact:o&&a.exponent>=-100&&a.digits.length<=101}}function yC(e){let[t,n=`0`]=e.slice(2).split(/[pP]/u),[r,i=``]=t.split(`.`),a=(r+i).replace(/^0+/u,``)||`0`;if(a.length>4096)throw new T(`feature`,`floating-point input limit`,`hexadecimal floating-point significands above 4096 digits are not supported`);return{coefficient:BigInt(`0x`+a),exponent:Number(n)-4*i.length}}function bC({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 i=Math.max(0,n-53,-1074-t),a=e>>BigInt(i);if(i>0){let t=e-(a<<BigInt(i)),n=1n<<BigInt(i-1);(t>n||t===n&&a%2n!=0n)&&a++}return Number(a)*2**(t+i)}var xC={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,'"':34,"\\":92};function SC(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 t=/^%([-+ #0']*)(\d+)?(?:\.(\d*))?([\s\S])?/u.exec(e.slice(r)),[,i,a,o,s]=t;if(!s||s===`%`)throw Error(`invalid directive: ${t[0]}`);if(!`nsF`.includes(s))throw new T(`feature`,`%`+s,`format %${s} is not supported`);if(i.includes(`'`))throw new T(`feature`,`grouped format`,`digit grouping in stat formats is not supported`);let c={field:s,conv:`u`,width:Number(a??0),precision:o===void 0?null:Number(o||0),minus:i.includes(`-`),zero:i.includes(`0`),plus:i.includes(`+`),space:i.includes(` `),alt:i.includes(`#`)};if(c.width>oh||c.precision>oh)throw new T(`feature`,`format size limit`,`format width or precision exceeds the output limit`);n.push(c),r+=t[0].length}else if(e[r]===`\\`&&t){let t=e[r+1],i=/^(?:[0-7]{1,3}|x[\da-fA-F]{1,2})/u.exec(e.slice(r+1))?.[0];if(i){let e=i[0]===`x`?16:8;n.push([parseInt(e===16?i.slice(1):i,e)&255]),r+=i.length+1}else if(Object.hasOwn(xC,t))n.push([xC[t]]),r+=2;else throw new T(`feature`,`format escape`,`format escape ${JSON.stringify(e.slice(r,r+2))} is not supported`)}else{let i=r+1;for(;i<e.length&&e[i]!==`%`&&!(t&&e[i]===`\\`);)i++;n.push(E(e.slice(r,i))),r=i}return t||n.push([10]),n}function CC(e,t,n,r){let i=r.isDir(n),a=!i&&r.isLink?.(n)===!0,o,s=e.map(e=>{if(!e.field)return e;if(e.field===`n`)return wC(t,e);if(e.field===`s`&&i)throw new T(`feature`,`directory byte size`,`directory byte sizes are not available: ${t}`);return o??=i?0:r.fileSize(n),e.field===`F`?wC(i?`directory`:a?`symbolic link`:o===0?`regular empty file`:`regular file`,e):E(lC(BigInt(o),e))}),c=new Uint8Array(s.reduce((e,t)=>e+t.length,0)),l=0;for(let e of s)c.set(e,l),l+=e.length;return D(c)}function wC(e,t){let n=E(e);t.precision!==null&&(n=n.subarray(0,t.precision));let r=Math.max(0,t.width-n.length);if(!r)return n;let i=new Uint8Array(n.length+r).fill(32);return i.set(n,t.minus?0:r),i}function TC(e,t,n){let{order:r,positional:i}=U(t,{short:[`L`,`t`],long:[`dereference`,`terse`],valueShort:[`c`],valueLong:[`format`,`printf`,`cached`]});if(!i.length)return x(`stat: missing operand`);let a=r.some(({name:e})=>e===`L`||e===`dereference`),o;for(let e of r)if(e.name===`cached`){if(!e.value||![`always`,`never`,`default`].some(t=>t.startsWith(e.value)))return x(`stat: invalid cache mode: ${e.value}`)}else[`c`,`format`,`printf`].includes(e.name)&&(o=e);if(!o)return C(`feature`,`stat`,`default metadata`,`stat: default output requires filesystem metadata that is not available`);let s=SC(o.value,o.name===`printf`);if(s.some(e=>e.field===`s`||e.field===`F`)&&DC(i,n,a))return C(`feature`,`stat`,`metadata output overlap`,`stat: buffered output sharing a measured file is not supported`);let c=G(),l=!1;for(let e of i){let t=EC(s,e,n,a);K(c,t),l||=t.exitCode!==0}return c.exitCode=+!!l,c}function EC(e,t,n,r){if(t===`-`){let e=C(`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:e.stderr.trimEnd()}),e}let i=N(n,`stat`,t,{follow:r});if(i.error)return x(`stat: cannot statx ${q(t,n)}: ${i.error}`);try{return b(CC(e,t,i.path,n.fs))}catch(e){let t=Ke(e,`stat`,`stat: `+L(e)),r=S(t);return r&&n.unsupported.add(r),t}}function DC(e,t,n){let r=Object.values(t.outputFds).filter(e=>typeof e==`object`);return r.length?e.some(e=>{let i=k(t.cwd,e,t.fs,{follow:n});return!i.error&&r.some(e=>e.path===i.path||e.identity!==void 0&&e.identity===t.fs.fileIdentity?.(i.path))}):!1}var OC=[` 1970-01-01 00:00:00.000000000 +0000`,` Thu Jan 1 00:00:00 1970`];function kC(e,t,n,r,i){let{ctx:a,opts:o}=e,s=AC(o,t);if(s===``)return``;let c=e=>o.labels[e]??oy(n[e],a)+(r[e]?OC[+(o.style===`context`)]:``),l=e=>o.labels[e]??oy(n[e],a),u=i?`diff${o.switches} ${l(0)} ${l(1)}
212
+ `)throw new T(`feature`,`IFS`,`custom IFS separators are not supported`);let r=[],i={value:``,mask:``,q:!1},a=()=>{(i.value!==``||i.q)&&r.push(i),i={value:``,mask:``,q:!1}},o=new Set(e.empty);for(let t=0;t<=e.value.length&&(o.has(t)&&(i.q=!0),t!==e.value.length);t++){let r=e.value[t],o=e.mask[t];if(n!==``&&o===`0`&&/[ \t\n]/u.test(r)){a();continue}i.value+=r,i.mask+=o,i.q||=o!==`0`}return a(),r}function BS(e,t,n){let r=Pb(t,n),i={ctx:n,options:r,seen:new Set,result:G(),total:0n,failed:!1};r.stderr&&K(i.result,n.flushOutput(G(r.stderr)));for(let e of r.operands){let t=e.length>2?e.replace(/\/+$/u,`/`):e,a=N(n,`du`,t,{follow:r.links!==`none`});if(a.error){K(i.result,n.flushOutput(x(`du: cannot access ${q(t,n)}: ${a.error}`))),i.failed=!0;continue}try{VS(a.path,t,i)}catch(e){let t=S(e),r=`du: `+I(e);if(t&&n.unsupported.add({...t,command:t.command??`du`,message:r}),K(i.result,n.flushOutput(x(r))),i.failed=!0,t)return i.result}}return r.flags.has(`c`)&&HS(i.total,`total`,i),i.result.exitCode=+!!i.failed,i.result}function VS(e,t,n){let{ctx:r,options:i}=n;if(!i.flags.has(`inodes`)&&r.fs.isDir(e)&&Object.values(r.outputFds??{}).some(t=>typeof t==`object`&&t.path?.startsWith(e===`/`?`/`:e+`/`)))throw new T(`feature`,`recursive metadata output overlap`,`output within a measured directory is not supported`);let a=[{path:e,name:t,depth:0}];for(;a.length;){let e=a.pop();if(e.total!==void 0){e.depth<=i.depth&&HS(e.total,e.name,n),e.parent&&!i.flags.has(`S`)&&(e.parent.total+=e.total);continue}let t=r.fs.isDir(e.path);if(!t&&i.links===`all`&&r.fs.isLink?.(e.path))throw new T(`option`,`dereference`,`following symbolic links is not supported: ${e.name}`);let o=t?e.path:r.fs.fileIdentity?.(e.path)??e.path;if(!i.flags.has(`l`)&&n.seen.has(o))continue;n.seen.add(o);let s=t?`dir`:r.fs.isLink?.(e.path)?`link`:`file`,c=t?0:r.fs.fileSize(e.path),l=i.flags.has(`inodes`)?1n:i.flags.has(`A`)?BigInt(c):BigInt(Vb(c,s));if(n.total+=l,t){e.total=l,a.push(e);let t=r.fs.listDir(e.path),n=[...new Set([...t.dirs,...t.files,...t.links])].sort(j),i=e.name.endsWith(`/`)?e.name:e.name+`/`;for(let t=n.length-1;t>=0;t--)a.push({path:_t(e.path,n[t]),name:i+n[t],depth:e.depth+1,parent:e})}else e.parent&&(e.parent.total+=l),(e.depth===0||i.flags.has(`a`)&&e.depth<=i.depth)&&HS(l,e.name,n)}}function HS(e,t,n){let r=`${Ub(e,n.options.scale)} ${t}${n.options.flags.has(`0`)?`\0`:`
213
+ `}`;K(n.result,n.ctx.flushOutput({...G(),stdout:r,events:[{fd:1,text:r}]}))}var US=/^%([-+ 0#']*)(\d+|\*)?'?(?:\.(\d+|\*)?)?[hlL]?(.)?/su,WS=`diouxXeEfFgGcs`;function GS(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 W(`positional printf arguments are not supported`,null,`positional format arguments`);let i=US.exec(e.slice(r)),a=i[4];if(a===`a`||a===`A`)throw new W(`hexadecimal floating-point formats are not supported`,null,`hexadecimal float format`);if(a===`%`){n+=`%`,r+=i[0].length-1;continue}if(a===void 0||!WS.includes(a)){n+=i[0],r+=i[0].length-1;continue}n!==``&&(t.push(n),n=``);let o=i[1];t.push({minus:o.includes(`-`),plus:o.includes(`+`),space:o.includes(` `),zero:o.includes(`0`),alt:o.includes(`#`),width:i[2]===void 0?null:i[2]===`*`?`*`:Number(i[2]),precision:i[3]===void 0?i[0].includes(`.`)?0:null:i[3]===`*`?`*`:Number(i[3]),conv:a}),r+=i[0].length-1}return n!==``&&t.push(n),t}function KS(e,t,n,r){let i=n.width??0;if(i>lh)throw new W(`format width exceeds the output limit`,null,`format size limit`);let a=i-e.length-[...t].length;return a<=0?e+t:n.minus?e+t+` `.repeat(a):n.zero&&r?e+`0`.repeat(a)+t:` `.repeat(a)+e+t}var qS=e=>e.plus?`+`:e.space?` `:``,JS=e=>e===`X`||e===`E`||e===`G`||e===`F`;function YS(e,t){if(t.precision>lh)throw new W(`format precision exceeds the output limit`,null,`format size limit`);let{conv:n}=t;if(!Number.isFinite(e)){if(Number.isNaN(e))throw new W(`formatting signed NaN is not supported`,null,`signed NaN`);let t=e<0?`-inf`:`+inf`;return JS(n)?t.toUpperCase():t}return`ouxX`.includes(n)&&(e>=2**64||e<-(2**63))?QS(e,{...t,conv:`g`}):`diouxX`.includes(n)?XS(e,t):QS(e,t)}function XS(e,t){let{conv:n}=t,r=n===`d`||n===`i`,i=r?Math.trunc(e)===0:e===0,a=BigInt(Math.trunc(e)),o=!1;a<0n&&(r?(o=!0,a=-a):a=BigInt.asUintN(64,a));let s=n===`o`?8:n===`x`||n===`X`?16:10,c=a.toString(s);n===`X`&&(c=c.toUpperCase()),t.precision!==null&&(c=t.precision===0&&i?t.alt&&!r?`0`:``:c.padStart(t.precision,`0`));let l=o?`-`:r&&c!==``?qS(t):``;return t.alt&&!i&&(n===`o`&&(c=`0`+c),(n===`x`||n===`X`)&&(l+=n===`x`?`0x`:`0X`)),KS(l,c,t,t.precision===null)}var ZS=100;function QS(e,t){let{conv:n}=t;if(t.precision>ZS)throw new W(`floating-point precision above ${ZS} is not supported`,null,`float precision limit`);let r=t.precision??6,i=e<0||Object.is(e,-0),a=Math.abs(e),o;return o=n===`e`||n===`E`?eC(a,r):n===`f`||n===`F`?tC(a,r):nC(a,r,t.alt),t.alt&&r===0&&n!==`g`&&n!==`G`&&(o=n===`e`||n===`E`?o.replace(`e`,`.e`):o+`.`),JS(n)&&(o=o.toUpperCase()),KS(i?`-`:qS(t),o,t,!0)}function $S(e,t,n,r){let i=t.slice(r);if(!/^50*$/u.test(i))return e;let a=t.slice(0,n),o=a.at(-1);return Number(o)%2==0?a:e}function eC(e,t){let n=e.toExponential(ZS),r=n.indexOf(`.`),i=n.indexOf(`e`),[a,o]=e.toExponential(t).split(`e`),s=$S(a,n.slice(0,i),t===0?r:r+1+t,r+1+t),c=Number(s===a?o:n.slice(i+1));return`${s}e${c<0?`-`:`+`}${String(Math.abs(c)).padStart(2,`0`)}`}function tC(e,t){if(e>=1e21)return BigInt(e).toString()+(t>0?`.`+`0`.repeat(t):``);let n=e.toFixed(ZS),r=n.indexOf(`.`);return $S(e.toFixed(t),n,t===0?r:r+1+t,r+1+t)}function nC(e,t,n){let r=t===0?1:t;if(e===0)return n?`0.`+`0`.repeat(r-1):`0`;let i=eC(e,r-1),a=i.indexOf(`e`),o=Number(i.slice(a+1));if(o<-4||o>=r)return n?i.includes(`.`)?i:i.slice(0,a)+`.`+i.slice(a):rC(i.slice(0,a))+i.slice(a);let s=tC(e,r-1-o);return n?s.includes(`.`)?s:s+`.`:rC(s)}var rC=e=>e.includes(`.`)?e.replace(/\.?0+$/u,``):e,iC=/^[+-]?(?:0[bB][01]+|0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)/u,aC=/^[+-]?(?:0[xX](?:[\da-fA-F]+(?:\.[\da-fA-F]*)?|\.[\da-fA-F]+)(?:[pP][+-]?\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|inf(?:inity)?|nan(?:\([\w]*\))?)/iu;function oC(e,t){if(e?.[0]!==`'`&&e?.[0]!==`"`)return null;let n=e.slice(1);if(n===``)return null;let r=p(n),i=t.byteLocale?1:p(String.fromCodePoint(n.codePointAt(0))).length;return r.length>i&&(t.stderr+=`printf: warning: ${D(r.slice(i))}: character(s) following character constant have been ignored
214
+ `),t.byteLocale?r[0]:n.codePointAt(0)}function sC(e,t,n){if(e===void 0||e===``)return`0`;let r=e.replace(/^[ \t\n\r\f\v]+/u,``),i=t.exec(r)?.[0]??``;return(i.length!==r.length||i===``)&&(n.stderr+=`printf: ${uC(e,n)}: ${i?`value not completely converted`:`expected a numeric value`}
215
+ `,n.failed=!0),i||`0`}var cC={"\x07":`\\a`,"\b":`\\b`," ":`\\t`,"\n":`\\n`,"\v":`\\v`,"\f":`\\f`,"\r":`\\r`,"\\":`\\\\`,"'":`\\'`},lC=e=>`\\`+e.toString(8).padStart(3,`0`);function uC(e,t){let n=``;for(let r of e){if(cC[r]!==void 0){n+=cC[r];continue}let e=r.codePointAt(0);if(e<32||e===127){n+=lC(e);continue}n+=e>127&&t.byteLocale?p(r).map(lC).join(``):r}return`'${n}'`}function dC(e,t,n){let r=oC(e,n);if(r!==null)return BigInt(r);let i=sC(e,iC,n),a=i[0]===`-`,o=i.replace(/^[+-]/u,``),s=BigInt(/^0[0-7]+$/u.test(o)?`0o`+o:o),c=a?-s:s;return(t?s>Sn:c<xn||c>bn)?(n.stderr+=`printf: ${uC(e,n)}: Numerical result out of range
216
+ `,n.failed=!0,t?Sn:a?xn:bn):t?BigInt.asUintN(64,c):c}function fC(e,t){let{conv:n}=t,r=n===`d`||n===`i`,i=e<0n,a=n===`o`?8:n===`x`||n===`X`?16:10,o=(i?-e:e).toString(a);n===`X`&&(o=o.toUpperCase()),e===0n&&t.precision===0&&(o=``),o=o.padStart(t.precision??0,`0`);let s=i?`-`:r?t.plus?`+`:t.space?` `:``:``;return t.alt&&(n===`o`&&!o.startsWith(`0`)&&(o=`0`+o),e!==0n&&(n===`x`||n===`X`)&&(s=n===`x`?`0x`:`0X`)),KS(s,o,t,t.precision===null)}function pC(e,t,n){let r=oC(e,n),i=r===null?sC(e,aC,n):String(r),a=i.replace(/^[+-]/u,``);if(/^(?:inf|nan)/iu.test(a)){let e=i.startsWith(`-`)?`-`:t.plus?`+`:t.space?` `:``,n=/^nan/iu.test(a)?`nan`:`inf`;return t.conv===t.conv.toUpperCase()&&(n=n.toUpperCase()),KS(e,n,t,!1)}let o=xC(a),s=i.startsWith(`-`)?-o.value:o.value;if(t.precision>100||`gG`.includes(t.conv)&&t.precision>96)throw new T(`feature`,`float precision limit`,`floating-point precision exceeds the supported limit`);try{let e=YS(s,t);if(!o.exact){let[n,r]=gC(o.value);for(let a of[n,r])if(YS(i.startsWith(`-`)?-a:a,t)!==e)throw new T(`feature`,`floating-point precision`,`floating-point formatting at this precision is not supported`)}return e}catch(e){throw e.gap?new T(`feature`,e.gap,e.message):e}}var mC=new DataView(new ArrayBuffer(8));function hC(e){return mC.setFloat64(0,e),mC.getBigUint64(0)}function gC(e){let t=hC(e);mC.setBigUint64(0,t-1n);let n=mC.getFloat64(0);return mC.setBigUint64(0,t+1n),[n,mC.getFloat64(0)]}function _C(e){let t=hC(e),n=Number(t>>52n);return{coefficient:t&(1n<<52n)-1n|(n?1n<<52n:0n),exponent:n?n-1075:-1074}}function vC(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 yC({coefficient:e,exponent:t}){return t<0?vC((e*5n**BigInt(-t)).toString(),t):vC((e<<BigInt(t)).toString(),0)}function bC(e,t){let n=e.exponent-t.exponent;return n>=0?e.coefficient<<BigInt(n)===t.coefficient:e.coefficient===t.coefficient<<BigInt(-n)}function xC(e){let t=/^0x/iu.test(e),n,r;if(t)n=SC(e),r=CC(n);else{let[t,i=`0`]=e.split(/[eE]/u),[a,o=``]=t.split(`.`);n=vC(a+o,Number(i)-o.length),r=Number(e)}if(!Number.isFinite(r))throw new T(`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 T(`feature`,`floating-point range`,`floating-point underflow is not supported`);return{value:r,exact:!0}}let i=_C(r),a=yC(i),o=t?bC(n,i):n.digits===a.digits&&n.exponent===a.exponent;return{value:r,exact:o&&a.exponent>=-100&&a.digits.length<=101}}function SC(e){let[t,n=`0`]=e.slice(2).split(/[pP]/u),[r,i=``]=t.split(`.`),a=(r+i).replace(/^0+/u,``)||`0`;if(a.length>4096)throw new T(`feature`,`floating-point input limit`,`hexadecimal floating-point significands above 4096 digits are not supported`);return{coefficient:BigInt(`0x`+a),exponent:Number(n)-4*i.length}}function CC({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 i=Math.max(0,n-53,-1074-t),a=e>>BigInt(i);if(i>0){let t=e-(a<<BigInt(i)),n=1n<<BigInt(i-1);(t>n||t===n&&a%2n!=0n)&&a++}return Number(a)*2**(t+i)}var wC={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,'"':34,"\\":92};function TC(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 t=/^%([-+ #0']*)(\d+)?(?:\.(\d*))?([\s\S])?/u.exec(e.slice(r)),[,i,a,o,s]=t;if(!s||s===`%`)throw Error(`invalid directive: ${t[0]}`);if(!`nsF`.includes(s))throw new T(`feature`,`%`+s,`format %${s} is not supported`);if(i.includes(`'`))throw new T(`feature`,`grouped format`,`digit grouping in stat formats is not supported`);let c={field:s,conv:`u`,width:Number(a??0),precision:o===void 0?null:Number(o||0),minus:i.includes(`-`),zero:i.includes(`0`),plus:i.includes(`+`),space:i.includes(` `),alt:i.includes(`#`)};if(c.width>lh||c.precision>lh)throw new T(`feature`,`format size limit`,`format width or precision exceeds the output limit`);n.push(c),r+=t[0].length}else if(e[r]===`\\`&&t){let t=e[r+1],i=/^(?:[0-7]{1,3}|x[\da-fA-F]{1,2})/u.exec(e.slice(r+1))?.[0];if(i){let e=i[0]===`x`?16:8;n.push([parseInt(e===16?i.slice(1):i,e)&255]),r+=i.length+1}else if(Object.hasOwn(wC,t))n.push([wC[t]]),r+=2;else throw new T(`feature`,`format escape`,`format escape ${JSON.stringify(e.slice(r,r+2))} is not supported`)}else{let i=r+1;for(;i<e.length&&e[i]!==`%`&&!(t&&e[i]===`\\`);)i++;n.push(E(e.slice(r,i))),r=i}return t||n.push([10]),n}function EC(e,t,n,r){let i=r.isDir(n),a=!i&&r.isLink?.(n)===!0,o,s=e.map(e=>{if(!e.field)return e;if(e.field===`n`)return DC(t,e);if(e.field===`s`&&i)throw new T(`feature`,`directory byte size`,`directory byte sizes are not available: ${t}`);return o??=i?0:r.fileSize(n),e.field===`F`?DC(i?`directory`:a?`symbolic link`:o===0?`regular empty file`:`regular file`,e):E(fC(BigInt(o),e))}),c=new Uint8Array(s.reduce((e,t)=>e+t.length,0)),l=0;for(let e of s)c.set(e,l),l+=e.length;return D(c)}function DC(e,t){let n=E(e);t.precision!==null&&(n=n.subarray(0,t.precision));let r=Math.max(0,t.width-n.length);if(!r)return n;let i=new Uint8Array(n.length+r).fill(32);return i.set(n,t.minus?0:r),i}function OC(e,t,n){let{order:r,positional:i}=U(t,{short:[`L`,`t`],long:[`dereference`,`terse`],valueShort:[`c`],valueLong:[`format`,`printf`,`cached`]});if(!i.length)return x(`stat: missing operand`);let a=r.some(({name:e})=>e===`L`||e===`dereference`),o;for(let e of r)if(e.name===`cached`){if(!e.value||![`always`,`never`,`default`].some(t=>t.startsWith(e.value)))return x(`stat: invalid cache mode: ${e.value}`)}else[`c`,`format`,`printf`].includes(e.name)&&(o=e);if(!o)return C(`feature`,`stat`,`default metadata`,`stat: default output requires filesystem metadata that is not available`);let s=TC(o.value,o.name===`printf`);if(s.some(e=>e.field===`s`||e.field===`F`)&&AC(i,n,a))return C(`feature`,`stat`,`metadata output overlap`,`stat: buffered output sharing a measured file is not supported`);let c=G(),l=!1;for(let e of i){let t=kC(s,e,n,a);K(c,t),l||=t.exitCode!==0}return c.exitCode=+!!l,c}function kC(e,t,n,r){if(t===`-`){let e=C(`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:e.stderr.trimEnd()}),e}let i=N(n,`stat`,t,{follow:r});if(i.error)return x(`stat: cannot statx ${q(t,n)}: ${i.error}`);try{return b(EC(e,t,i.path,n.fs))}catch(e){let t=qe(e,`stat`,`stat: `+I(e)),r=S(t);return r&&n.unsupported.add(r),t}}function AC(e,t,n){let r=Object.values(t.outputFds).filter(e=>typeof e==`object`);return r.length?e.some(e=>{let i=k(t.cwd,e,t.fs,{follow:n});return!i.error&&r.some(e=>e.path===i.path||e.identity!==void 0&&e.identity===t.fs.fileIdentity?.(i.path))}):!1}var jC=[` 1970-01-01 00:00:00.000000000 +0000`,` Thu Jan 1 00:00:00 1970`];function MC(e,t,n,r,i){let{ctx:a,opts:o}=e,s=NC(o,t);if(s===``)return``;let c=e=>o.labels[e]??ly(n[e],a)+(r[e]?jC[+(o.style===`context`)]:``),l=e=>o.labels[e]??ly(n[e],a),u=i?`diff${o.switches} ${l(0)} ${l(1)}
217
217
  `:``;return o.style===`unified`?`${u}--- ${c(0)}
218
218
  +++ ${c(1)}
219
219
  ${s}`:o.style===`context`?`${u}*** ${c(0)}
220
220
  --- ${c(1)}
221
- ${s}`:u+s}function AC(e,t){let n=e.showFunction?Pn(t[0]):null;return d(t[0],t[1],{format:e.style??`normal`,context:e.context,label:n?e=>MC(n,e):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace,horizon:e.horizon})}var jC=/^[A-Za-z$_]/u;function MC(e,t){for(let n=t-1;n>=0;n--){if(!jC.test(e[n]))continue;let t=p(e[n].replace(/\n$/u,``)),r=Math.min(40,t.length);for(;r>0&&NC(t[r-1]);)r--;return PC(t.subarray(0,r))}return null}var NC=e=>e===32||e>=9&&e<=13;function PC(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return D(e.subarray(0,t))}catch{}return``}var FC=[`q`,`s`,`r`,`N`,`a`,`i`,`w`,`b`,`Z`,`p`,`d`,`u`,`c`,`e`,`n`,`y`,`t`,`T`,`l`,`E`,`B`,`P`,`v`,`H`],IC=`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`.split(`.`),LC=[`U`,`C`,`x`,`X`,`S`,`F`,`W`,`I`,`D`],RC=[`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`],zC=[`L`,`label`,`x`,`exclude`],BC=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`]]),VC=e=>x(`diff: ${e}
222
- diff: Try 'diff --help' for more information.`,2);function HC(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 UC(e){let t=HC(e);if(t.refused)return{refused:C(`option`,`diff`,t.label.replace(/=.*/u,``),`diff: ${t.label}: ${t.refused} is not supported`,2)};let n;try{n=U(t.tokens,{short:FC,long:IC,valueShort:LC,valueLong:RC,repeatable:zC})}catch(e){let t=S(e);return t?{refused:C(t.kind,`diff`,t.detail,`diff: ${e.message}`,2)}:{error:VC(e.message)}}let r={style:null,context:-1,horizon:0,labels:[],excludes:[],whitespace:`none`,switches:KC(e)};for(let{name:e,value:t}of n.order){let n=BC.get(e),i=(e.length===1?`-`:`--`)+e;if(n)return{refused:C(`option`,`diff`,i,`diff: ${i}: ${n} is not supported`,2)};let a=WC(r,e,t);if(a)return{error:a}}return r.showFunction&&r.style===null&&(r.style=`context`),r.context<0&&(r.context=3),n.positional.length<2?{error:VC(`missing operand after '${n.positional[0]??`diff`}'`)}:n.positional.length>2?{error:VC(`extra operand '${n.positional[2]}'`)}:{opts:r,operands:n.positional}}function WC(e,t,n){let r=t=>e.style!==null&&e.style!==t?VC(`conflicting output style options`):(e.style=t,null);switch(t){case`u`:case`c`:{let n=r(t===`u`?`unified`:`context`);return e.context<3&&(e.context=3),n}case`U`:case`C`:{let i=GC(n);if(i===null)return VC(`invalid context length '${n}'`);let a=r(t===`U`?`unified`:`context`);return e.context<i&&(e.context=i),a}case`normal`:return r(`normal`);case`horizon-lines`:{let t=GC(n);return t===null?VC(`invalid horizon length '${n}'`):(e.horizon=Math.max(e.horizon,t),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?x(`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 GC(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]),2**53-1)}function KC(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)break;!r.startsWith(`-`)||r===`-`||(t.push(r),qC(r)&&n+1<e.length&&t.push(e[++n]))}return t.map(e=>` `+iy(e,{vars:new Map})).join(``)}function qC(e){if(e.startsWith(`--`))return!e.includes(`=`)&&(RC.includes(e.slice(2))||e===`--label`||e===`--exclude`);for(let t=1;t<e.length;t++){let n=e[t];if(LC.includes(n)||n===`L`)return t+1===e.length}return!1}function JC(e,t,n){let{ctx:r,opts:i}=e,a=nw(tw(e,t),tw(e,n));for(let[o,s,c]of a){let a=iw(t,o),l=iw(n,o),u=s?$C(r,a):null,d=c?$C(r,l):null;if(s&&c){XC(e,[a,l],[u,d]);continue}i.newFile?YC(e,[a,l],u??d,[s,c]):sw(e,`Only in ${s?t:n}: ${o}
223
- `,1)}}function YC(e,[t,n],r,i){QC(r)?e.opts.recursive?ew(e,[t,n],i.map(e=>e?r:null)):sw(e,`Common subdirectories: ${t} and ${n}
224
- `):cw(e,t,n,!0,i)}function XC(e,[t,n],[r,i]){let{opts:a}=e,o=[r,i].indexOf(`gone`);if(o!==-1&&QC([r,i][1-o])){let r=[t,n][o];return sw(e,`diff: ${r}: ${k(e.ctx.cwd,r,e.ctx.fs).error}
225
- `,2,!0)}if(QC(r)&&QC(i))a.recursive?ew(e,[t,n],[r,i]):sw(e,`Common subdirectories: ${t} and ${n}
226
- `);else if(r===i||o!==-1)cw(e,t,n,!0,[!0,!0]);else{let o=(e,t)=>a.labels[e]??t;sw(e,`File ${o(0,t)} is a ${ZC[r]} while file ${o(1,n)} is a ${ZC[i]}
227
- `,1)}}var ZC={dir:`directory`,link:`directory`,file:`regular file`},QC=e=>e===`dir`||e===`link`;function $C(e,t){let n=k(e.cwd,t,e.fs);return n.error?`gone`:e.fs.isDir(n.path)?e.fs.isLink?.(k(e.cwd,t,e.fs,{follow:!1}).path)?`link`:`dir`:`file`}function ew(e,[t,n],[r,i]){for(let[e,a]of[[r,t],[i,n]])if(e===`link`)throw new T(`feature`,`symbolic link to a directory`,`comparing what a symbolic link to a directory holds is not supported: ${a}`);JC(e,t,n)}function tw(e,t){let{ctx:n,opts:r}=e,i=k(n.cwd,t,n.fs);if(i.error||!n.fs.isDir(i.path))return[];let{dirs:a,files:o,links:s}=n.fs.listDir(i.path),c=[...a,...o,...s].sort(j);return r.excludes.length?c.filter(e=>!r.excludes.some(t=>t_(e,t))):c}function nw(e,t){let n=[],r=0,i=0;for(;r<e.length||i<t.length;){let a=r===e.length?1:i===t.length?-1:j(e[r],t[i]);a===0?(n.push([e[r++],!0,!0]),i++):a<0?n.push([e[r++],!0,!1]):n.push([t[i++],!1,!0])}return n}function rw(e,t,n){let r=UC(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:i,operands:a}=r,o={ctx:n,opts:i,stdin:e,out:G(),status:0},[s,c]=a,l=a.map(e=>ow(o,e));if(l[0]===`dir`&&l[1]===`dir`&&aw(o,s,c))return o.out;if(l[0]===`dir`&&l[1]===`dir`)JC(o,s,c);else if(l[0]===`dir`||l[1]===`dir`){let e=l[0]===`dir`?0:1,t=a[1-e];if(t===`-`)return x(`diff: cannot compare '-' to a directory`,2);if(l[1-e]===`missing`){let e=k(o.ctx.cwd,t,o.ctx.fs).error;i.newFile&&e===`No such file or directory`?JC(o,s,c):sw(o,`diff: ${t}: ${e}
228
- `,2,!0)}else{let n=iw(a[e],ht(t)),r=e===0?[n,t]:[t,n];ow(o,n)===`missing`?sw(o,`diff: ${n}: No such file or directory
229
- `,2,!0):cw(o,r[0],r[1],!1)}}else cw(o,s,c,!1);return o.out.exitCode=o.status,o.out}function iw(e,t){let n=e.replace(/\/+$/u,``);return(n===``?`/`:n+`/`)+t}function aw(e,t,n){return k(e.ctx.cwd,t,e.ctx.fs).path===k(e.ctx.cwd,n,e.ctx.fs).path}function ow(e,t){if(t===`-`)return`stdin`;let n=k(e.ctx.cwd,t,e.ctx.fs);return n.error?`missing`:e.ctx.fs.isDir(n.path)?`dir`:`file`}function sw(e,t,n=0,r=!1){K(e.out,r?G(t):{...G(),stdout:t,events:[{fd:1,text:t}]}),e.status=Math.max(e.status,n)}function cw(e,t,n,r,i=null){let{opts:a}=e,o=[t,n].map(t=>mw(e,t)),s=o.map(e=>e.content===null),c=a.newFile&&!(s[0]&&s[1]),f=!1;for(let r=0;r<2;r++)!s[r]||(i?!i[r]:c)||(sw(e,`diff: ${[t,n][r]}: ${o[r].error??`No such file or directory`}
230
- `,2,!0),f=!0);if(f)return;if(o[0].identity!==void 0&&o[0].identity===o[1].identity&&!s[0])return lw(e,t,n);let p=e=>a.labels[e]??[t,n][e];if(!a.text&&o.some(dw))return fw(o)?lw(e,t,n):sw(e,`${a.brief?`Files`:`Binary files`} ${p(0)} and ${p(1)} differ
231
- `,1);if(o.some(e=>e.content===void 0)){if(fw(o))return lw(e,t,n);if(a.brief&&!a.ignoreCase&&!a.stripCr&&a.whitespace===`none`)return sw(e,`Files ${p(0)} and ${p(1)} differ
232
- `,1)}for(let[e,t]of o.entries())t.content===void 0&&vt(t.bytes,JSON.stringify(p(e)));let m=o.map(e=>e.content??``);if(a.stripCr&&(m=m.map(uw)),a.brief)return d(m[0],m[1],{format:`brief`,ignoreCase:a.ignoreCase,whitespace:a.whitespace})===``?lw(e,t,n):sw(e,`Files ${p(0)} and ${p(1)} differ
233
- `,1);let h;try{h=kC(e,m,[t,n],s,r)}catch(r){if(!(r instanceof u)&&!(r instanceof l))throw r;let i=`diff: ${t} ${n}: ${r.message}`,a=r instanceof u?`change set verification`:`diff rendering verification`;K(e.out,C(`feature`,`diff`,a,i,2)),e.status=2;return}if(h===``)return lw(e,t,n);sw(e,h,1)}function lw(e,t,n){e.opts.identical&&sw(e,`Files ${t} and ${n} are identical
234
- `)}var uw=e=>e.replace(/\r\n/gu,`
235
- `),dw=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes(`\0`)===!0,fw=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:yt(e.bytes??pw,t.bytes??pw),pw=new Uint8Array;function mw(e,t){let{ctx:n}=e;if(t===`-`)return F(n),{content:e.stdin,identity:n.stdinHandle?.identity??Symbol(`stdin`)};let r=N(n,`diff`,t);if(r.error||n.fs.isDir(r.path))return{content:null,bytes:null,identity:void 0,error:r.error};let{text:i,bytes:a}=Vn(n.fs,r.path);return{content:i,bytes:a,identity:n.fs.fileIdentity?.(r.path)??r.path}}var hw=(e,t,n)=>{throw new Y(`malformed patch at line ${Math.min(t,e.lines.length-1)+1}: ${n??``}`)};function gw(e,t){return!!e.lines[t+1]?.startsWith(`\\`)}function _w(e){let{lines:t}=e,n=e.pos,r=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: (.*))?\n$/u.exec(t[n]??``);if(!r)return null;let i=n,a=Number(r[3]),o=Number(r[1]),s=r[2]===void 0?1:Number(r[2]),c=r[4]===void 0?1:Number(r[4]);s===0&&o++,c===0&&a++;let l=[],u=[],d=0,f=n,p=-1;for(n++;u.length<s||l.length<c;n+=1){let r=t[n]!==void 0;if(!r&&c-l.length>3)throw new Y(`unexpected end of file in patch`);let i=r?t[n]:`
221
+ ${s}`:u+s}function NC(e,t){let n=e.showFunction?Fn(t[0]):null;return d(t[0],t[1],{format:e.style??`normal`,context:e.context,label:n?e=>FC(n,e):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace,horizon:e.horizon})}var PC=/^[A-Za-z$_]/u;function FC(e,t){for(let n=t-1;n>=0;n--){if(!PC.test(e[n]))continue;let t=p(e[n].replace(/\n$/u,``)),r=Math.min(40,t.length);for(;r>0&&IC(t[r-1]);)r--;return LC(t.subarray(0,r))}return null}var IC=e=>e===32||e>=9&&e<=13;function LC(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return D(e.subarray(0,t))}catch{}return``}var RC=[`q`,`s`,`r`,`N`,`a`,`i`,`w`,`b`,`Z`,`p`,`d`,`u`,`c`,`e`,`n`,`y`,`t`,`T`,`l`,`E`,`B`,`P`,`v`,`H`],zC=`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`.split(`.`),BC=[`U`,`C`,`x`,`X`,`S`,`F`,`W`,`I`,`D`],VC=[`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`],HC=[`L`,`label`,`x`,`exclude`],UC=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`]]),WC=e=>x(`diff: ${e}
222
+ diff: Try 'diff --help' for more information.`,2);function GC(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 KC(e){let t=GC(e);if(t.refused)return{refused:C(`option`,`diff`,t.label.replace(/=.*/u,``),`diff: ${t.label}: ${t.refused} is not supported`,2)};let n;try{n=U(t.tokens,{short:RC,long:zC,valueShort:BC,valueLong:VC,repeatable:HC})}catch(e){let t=S(e);return t?{refused:C(t.kind,`diff`,t.detail,`diff: ${e.message}`,2)}:{error:WC(e.message)}}let r={style:null,context:-1,horizon:0,labels:[],excludes:[],whitespace:`none`,switches:YC(e)};for(let{name:e,value:t}of n.order){let n=UC.get(e),i=(e.length===1?`-`:`--`)+e;if(n)return{refused:C(`option`,`diff`,i,`diff: ${i}: ${n} is not supported`,2)};let a=qC(r,e,t);if(a)return{error:a}}return r.showFunction&&r.style===null&&(r.style=`context`),r.context<0&&(r.context=3),n.positional.length<2?{error:WC(`missing operand after '${n.positional[0]??`diff`}'`)}:n.positional.length>2?{error:WC(`extra operand '${n.positional[2]}'`)}:{opts:r,operands:n.positional}}function qC(e,t,n){let r=t=>e.style!==null&&e.style!==t?WC(`conflicting output style options`):(e.style=t,null);switch(t){case`u`:case`c`:{let n=r(t===`u`?`unified`:`context`);return e.context<3&&(e.context=3),n}case`U`:case`C`:{let i=JC(n);if(i===null)return WC(`invalid context length '${n}'`);let a=r(t===`U`?`unified`:`context`);return e.context<i&&(e.context=i),a}case`normal`:return r(`normal`);case`horizon-lines`:{let t=JC(n);return t===null?WC(`invalid horizon length '${n}'`):(e.horizon=Math.max(e.horizon,t),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?x(`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 JC(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]),2**53-1)}function YC(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)break;!r.startsWith(`-`)||r===`-`||(t.push(r),XC(r)&&n+1<e.length&&t.push(e[++n]))}return t.map(e=>` `+sy(e,{vars:new Map})).join(``)}function XC(e){if(e.startsWith(`--`))return!e.includes(`=`)&&(VC.includes(e.slice(2))||e===`--label`||e===`--exclude`);for(let t=1;t<e.length;t++){let n=e[t];if(BC.includes(n)||n===`L`)return t+1===e.length}return!1}function ZC(e,t,n){let{ctx:r,opts:i}=e,a=aw(iw(e,t),iw(e,n));for(let[o,s,c]of a){let a=sw(t,o),l=sw(n,o),u=s?nw(r,a):null,d=c?nw(r,l):null;if(s&&c){$C(e,[a,l],[u,d]);continue}i.newFile?QC(e,[a,l],u??d,[s,c]):uw(e,`Only in ${s?t:n}: ${o}
223
+ `,1)}}function QC(e,[t,n],r,i){tw(r)?e.opts.recursive?rw(e,[t,n],i.map(e=>e?r:null)):uw(e,`Common subdirectories: ${t} and ${n}
224
+ `):dw(e,t,n,!0,i)}function $C(e,[t,n],[r,i]){let{opts:a}=e,o=[r,i].indexOf(`gone`);if(o!==-1&&tw([r,i][1-o])){let r=[t,n][o];return uw(e,`diff: ${r}: ${k(e.ctx.cwd,r,e.ctx.fs).error}
225
+ `,2,!0)}if(tw(r)&&tw(i))a.recursive?rw(e,[t,n],[r,i]):uw(e,`Common subdirectories: ${t} and ${n}
226
+ `);else if(r===i||o!==-1)dw(e,t,n,!0,[!0,!0]);else{let o=(e,t)=>a.labels[e]??t;uw(e,`File ${o(0,t)} is a ${ew[r]} while file ${o(1,n)} is a ${ew[i]}
227
+ `,1)}}var ew={dir:`directory`,link:`directory`,file:`regular file`},tw=e=>e===`dir`||e===`link`;function nw(e,t){let n=k(e.cwd,t,e.fs);return n.error?`gone`:e.fs.isDir(n.path)?e.fs.isLink?.(k(e.cwd,t,e.fs,{follow:!1}).path)?`link`:`dir`:`file`}function rw(e,[t,n],[r,i]){for(let[e,a]of[[r,t],[i,n]])if(e===`link`)throw new T(`feature`,`symbolic link to a directory`,`comparing what a symbolic link to a directory holds is not supported: ${a}`);ZC(e,t,n)}function iw(e,t){let{ctx:n,opts:r}=e,i=k(n.cwd,t,n.fs);if(i.error||!n.fs.isDir(i.path))return[];let{dirs:a,files:o,links:s}=n.fs.listDir(i.path),c=[...a,...o,...s].sort(j);return r.excludes.length?c.filter(e=>!r.excludes.some(t=>i_(e,t))):c}function aw(e,t){let n=[],r=0,i=0;for(;r<e.length||i<t.length;){let a=r===e.length?1:i===t.length?-1:j(e[r],t[i]);a===0?(n.push([e[r++],!0,!0]),i++):a<0?n.push([e[r++],!0,!1]):n.push([t[i++],!1,!0])}return n}function ow(e,t,n){let r=KC(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:i,operands:a}=r,o={ctx:n,opts:i,stdin:e,out:G(),status:0},[s,c]=a,l=a.map(e=>lw(o,e));if(l[0]===`dir`&&l[1]===`dir`&&cw(o,s,c))return o.out;if(l[0]===`dir`&&l[1]===`dir`)ZC(o,s,c);else if(l[0]===`dir`||l[1]===`dir`){let e=l[0]===`dir`?0:1,t=a[1-e];if(t===`-`)return x(`diff: cannot compare '-' to a directory`,2);if(l[1-e]===`missing`){let e=k(o.ctx.cwd,t,o.ctx.fs).error;i.newFile&&e===`No such file or directory`?ZC(o,s,c):uw(o,`diff: ${t}: ${e}
228
+ `,2,!0)}else{let n=sw(a[e],gt(t)),r=e===0?[n,t]:[t,n];lw(o,n)===`missing`?uw(o,`diff: ${n}: No such file or directory
229
+ `,2,!0):dw(o,r[0],r[1],!1)}}else dw(o,s,c,!1);return o.out.exitCode=o.status,o.out}function sw(e,t){let n=e.replace(/\/+$/u,``);return(n===``?`/`:n+`/`)+t}function cw(e,t,n){return k(e.ctx.cwd,t,e.ctx.fs).path===k(e.ctx.cwd,n,e.ctx.fs).path}function lw(e,t){if(t===`-`)return`stdin`;let n=k(e.ctx.cwd,t,e.ctx.fs);return n.error?`missing`:e.ctx.fs.isDir(n.path)?`dir`:`file`}function uw(e,t,n=0,r=!1){K(e.out,r?G(t):{...G(),stdout:t,events:[{fd:1,text:t}]}),e.status=Math.max(e.status,n)}function dw(e,t,n,r,i=null){let{opts:a}=e,o=[t,n].map(t=>_w(e,t)),s=o.map(e=>e.content===null),c=a.newFile&&!(s[0]&&s[1]),f=!1;for(let r=0;r<2;r++)!s[r]||(i?!i[r]:c)||(uw(e,`diff: ${[t,n][r]}: ${o[r].error??`No such file or directory`}
230
+ `,2,!0),f=!0);if(f)return;if(o[0].identity!==void 0&&o[0].identity===o[1].identity&&!s[0])return fw(e,t,n);let p=e=>a.labels[e]??[t,n][e];if(!a.text&&o.some(mw))return hw(o)?fw(e,t,n):uw(e,`${a.brief?`Files`:`Binary files`} ${p(0)} and ${p(1)} differ
231
+ `,1);if(o.some(e=>e.content===void 0)){if(hw(o))return fw(e,t,n);if(a.brief&&!a.ignoreCase&&!a.stripCr&&a.whitespace===`none`)return uw(e,`Files ${p(0)} and ${p(1)} differ
232
+ `,1)}for(let[e,t]of o.entries())t.content===void 0&&yt(t.bytes,JSON.stringify(p(e)));let m=o.map(e=>e.content??``);if(a.stripCr&&(m=m.map(pw)),a.brief)return d(m[0],m[1],{format:`brief`,ignoreCase:a.ignoreCase,whitespace:a.whitespace})===``?fw(e,t,n):uw(e,`Files ${p(0)} and ${p(1)} differ
233
+ `,1);let h;try{h=MC(e,m,[t,n],s,r)}catch(r){if(!(r instanceof u)&&!(r instanceof l))throw r;let i=`diff: ${t} ${n}: ${r.message}`,a=r instanceof u?`change set verification`:`diff rendering verification`;K(e.out,C(`feature`,`diff`,a,i,2)),e.status=2;return}if(h===``)return fw(e,t,n);uw(e,h,1)}function fw(e,t,n){e.opts.identical&&uw(e,`Files ${t} and ${n} are identical
234
+ `)}var pw=e=>e.replace(/\r\n/gu,`
235
+ `),mw=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes(`\0`)===!0,hw=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:bt(e.bytes??gw,t.bytes??gw),gw=new Uint8Array;function _w(e,t){let{ctx:n}=e;if(t===`-`)return F(n),{content:e.stdin,identity:n.stdinHandle?.identity??Symbol(`stdin`)};let r=N(n,`diff`,t);if(r.error||n.fs.isDir(r.path))return{content:null,bytes:null,identity:void 0,error:r.error};let{text:i,bytes:a}=Hn(n.fs,r.path);return{content:i,bytes:a,identity:n.fs.fileIdentity?.(r.path)??r.path}}var vw=(e,t,n)=>{throw new Y(`malformed patch at line ${Math.min(t,e.lines.length-1)+1}: ${n??``}`)};function yw(e,t){return!!e.lines[t+1]?.startsWith(`\\`)}function bw(e){let{lines:t}=e,n=e.pos,r=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: (.*))?\n$/u.exec(t[n]??``);if(!r)return null;let i=n,a=Number(r[3]),o=Number(r[1]),s=r[2]===void 0?1:Number(r[2]),c=r[4]===void 0?1:Number(r[4]);s===0&&o++,c===0&&a++;let l=[],u=[],d=0,f=n,p=-1;for(n++;u.length<s||l.length<c;n+=1){let r=t[n]!==void 0;if(!r&&c-l.length>3)throw new Y(`unexpected end of file in patch`);let i=r?t[n]:`
236
236
  `;r&&(f=n);let a=i[0],o=i;a===` `||a===`
237
- `?a=` `:o=i.slice(1),a!==`-`&&a!==`+`&&a!==` `&&hw(e,n,i);let m=!1;a!==`+`&&(u.length>=s&&hw(e,n,i),m=r&&u.length+1===s&&gw(e,n),m&&(o=o.replace(/\n$/u,``)),u.push({tag:a,text:o}),a===` `&&d++),a!==`-`&&(l.length>=c&&hw(e,n,i),!m&&r&&l.length+1===c&&gw(e,n)&&(m=!0,o=o.replace(/\n$/u,``)),l.push({tag:a,text:o})),a!==` `&&(p===-1&&(p=d),d=0),m&&n++}return p===-1&&hw(e,f,t[f]),e.pos=n,{oldStart:o,oldLines:u,newStart:a,newLines:l,prefix:p,suffix:d,fn:r[5]===void 0?null:` `+r[5],marks:null,line:i}}function vw(e){let{lines:t}=e,n=e.pos;if(!t[n]?.startsWith(`********`))return null;let r=n,i=/^\*+( .*)?\n$/u.exec(t[n])?.[1]??null,a=/^\*\*\* (\d+)(?:,(\d+))?/u.exec(t[++n]??``);if(!a)throw new Y(`unexpected '***' at line ${n+1}: ${t[n]??``}`);let o=yw(a),s=[],c=e=>/^--- (\d+)(?:,(\d+))? ----/u.exec(t[e]??``)??/^--- (\d+)(?:,(\d+))?/u.exec(t[e]??``);for(n++;!c(n);n++){if(t[n]===void 0||s.length>=o.count)throw new Y(`no '---' found in patch at line ${r+1}`);s.push(bw(e,n,s.length+1===o.count)),s.at(-1).skip&&n++}let l=yw(c(n)),u=[];for(n++;u.length<l.count;n++){let r=t[n];if(r===void 0||!/^[ !+\-\t\n]/u.test(r)||r.startsWith(`***`))break;u.push(bw(e,n,u.length+1===l.count)),u.at(-1).skip&&n++}return u.length!==0&&u.length<l.count&&hw(e,n,t[n]),e.pos=n,xw({oldRange:o,oldSide:s,newRange:l,newSide:u,fn:i,line:r})}function yw(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 bw(e,t,n){let r=e.lines[t],i=r[0];i===` `||i===`
238
- `?i=` `:(r=r.slice(1),(r[0]===` `||r[0]===` `)&&(r=r.slice(1)));let a=n&&gw(e,t);return{mark:i,text:a?r.replace(/\n$/u,``):r,skip:a}}function xw({oldRange:e,oldSide:t,newRange:n,newSide:r,fn:i,line:a}){let o=r,s=t;if(t.length===0&&e.count&&(s=r.filter(e=>e.mark===` `)),r.length===0&&n.count&&(o=t.filter(e=>e.mark===` `)),s.length!==e.count||o.length!==n.count)throw new Y(`replacement text or line numbers mangled in hunk at line ${a+1}`);let c=s.map(e=>({tag:e.mark===` `?` `:`-`,text:e.text})),l=o.map(e=>({tag:e.mark===` `?` `:`+`,text:e.text})),u=e=>{let t=0;for(let n of e){if(n.tag!==` `)break;t++}return t},d=Math.min(u(c),u(l)),f=Math.min(u(c.toReversed()),u(l.toReversed()));if(c.every(e=>e.tag===` `)&&l.every(e=>e.tag===` `))throw new Y(`replacement text or line numbers mangled in hunk at line ${a+1}`);return{oldStart:e.first,oldLines:c,newStart:n.first,newLines:l,prefix:d,suffix:f,fn:i,marks:{old:s.map(e=>e.mark),new:o.map(e=>e.mark)},line:a}}function Sw(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 i=n,a=Number(r[1]),o=r[3]===`a`?0:r[2]===void 0?1:Number(r[2])-a+1;r[3]===`a`&&a++;let s=Number(r[4]),c=r[5]===void 0?s:Number(r[5]);r[3]===`d`&&s++;let l=c-s+1;(o<0||l<0)&&hw(e,n,t[n]);let u=[],d=[];n++;for(let r=0;r<o;r++,n++){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!/^<[ \t]/u.test(t[n]))throw new Y(`'<' followed by space or tab expected at line ${n+1} of patch`);let i=r+1===o&&gw(e,n);d.push({tag:`-`,text:i?t[n].slice(2).replace(/\n$/u,``):t[n].slice(2)}),i&&n++}if(r[3]===`c`){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!t[n].startsWith(`-`))throw new Y(`'---' expected at line ${n+1} of patch`);n++}for(let r=0;r<l;r++,n++){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!/^>[ \t]/u.test(t[n]))throw new Y(`'>' followed by space or tab expected at line ${n+1} of patch`);let i=r+1===l&&gw(e,n);u.push({tag:`+`,text:i?t[n].slice(2).replace(/\n$/u,``):t[n].slice(2)}),i&&n++}return e.pos=n,{oldStart:a,oldLines:d,newStart:s,newLines:u,prefix:0,suffix:0,fn:null,marks:null,line:i}}function Cw(e){let t=(e,t,n)=>e.map(e=>({tag:e.tag===t?n:e.tag,text:e.text})),n=(e,t,n)=>e.map(e=>e===t?n:e);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 Y=class extends Error{constructor(e){super(e),this.name=`PatchFatal`}},ww=(e,t)=>{throw new T(`feature`,e,t)};function Tw(e){let t=Pn(e);return t.length&&!t.at(-1).endsWith(`
237
+ `?a=` `:o=i.slice(1),a!==`-`&&a!==`+`&&a!==` `&&vw(e,n,i);let m=!1;a!==`+`&&(u.length>=s&&vw(e,n,i),m=r&&u.length+1===s&&yw(e,n),m&&(o=o.replace(/\n$/u,``)),u.push({tag:a,text:o}),a===` `&&d++),a!==`-`&&(l.length>=c&&vw(e,n,i),!m&&r&&l.length+1===c&&yw(e,n)&&(m=!0,o=o.replace(/\n$/u,``)),l.push({tag:a,text:o})),a!==` `&&(p===-1&&(p=d),d=0),m&&n++}return p===-1&&vw(e,f,t[f]),e.pos=n,{oldStart:o,oldLines:u,newStart:a,newLines:l,prefix:p,suffix:d,fn:r[5]===void 0?null:` `+r[5],marks:null,line:i}}function xw(e){let{lines:t}=e,n=e.pos;if(!t[n]?.startsWith(`********`))return null;let r=n,i=/^\*+( .*)?\n$/u.exec(t[n])?.[1]??null,a=/^\*\*\* (\d+)(?:,(\d+))?/u.exec(t[++n]??``);if(!a)throw new Y(`unexpected '***' at line ${n+1}: ${t[n]??``}`);let o=Sw(a),s=[],c=e=>/^--- (\d+)(?:,(\d+))? ----/u.exec(t[e]??``)??/^--- (\d+)(?:,(\d+))?/u.exec(t[e]??``);for(n++;!c(n);n++){if(t[n]===void 0||s.length>=o.count)throw new Y(`no '---' found in patch at line ${r+1}`);s.push(Cw(e,n,s.length+1===o.count)),s.at(-1).skip&&n++}let l=Sw(c(n)),u=[];for(n++;u.length<l.count;n++){let r=t[n];if(r===void 0||!/^[ !+\-\t\n]/u.test(r)||r.startsWith(`***`))break;u.push(Cw(e,n,u.length+1===l.count)),u.at(-1).skip&&n++}return u.length!==0&&u.length<l.count&&vw(e,n,t[n]),e.pos=n,ww({oldRange:o,oldSide:s,newRange:l,newSide:u,fn:i,line:r})}function Sw(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 Cw(e,t,n){let r=e.lines[t],i=r[0];i===` `||i===`
238
+ `?i=` `:(r=r.slice(1),(r[0]===` `||r[0]===` `)&&(r=r.slice(1)));let a=n&&yw(e,t);return{mark:i,text:a?r.replace(/\n$/u,``):r,skip:a}}function ww({oldRange:e,oldSide:t,newRange:n,newSide:r,fn:i,line:a}){let o=r,s=t;if(t.length===0&&e.count&&(s=r.filter(e=>e.mark===` `)),r.length===0&&n.count&&(o=t.filter(e=>e.mark===` `)),s.length!==e.count||o.length!==n.count)throw new Y(`replacement text or line numbers mangled in hunk at line ${a+1}`);let c=s.map(e=>({tag:e.mark===` `?` `:`-`,text:e.text})),l=o.map(e=>({tag:e.mark===` `?` `:`+`,text:e.text})),u=e=>{let t=0;for(let n of e){if(n.tag!==` `)break;t++}return t},d=Math.min(u(c),u(l)),f=Math.min(u(c.toReversed()),u(l.toReversed()));if(c.every(e=>e.tag===` `)&&l.every(e=>e.tag===` `))throw new Y(`replacement text or line numbers mangled in hunk at line ${a+1}`);return{oldStart:e.first,oldLines:c,newStart:n.first,newLines:l,prefix:d,suffix:f,fn:i,marks:{old:s.map(e=>e.mark),new:o.map(e=>e.mark)},line:a}}function Tw(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 i=n,a=Number(r[1]),o=r[3]===`a`?0:r[2]===void 0?1:Number(r[2])-a+1;r[3]===`a`&&a++;let s=Number(r[4]),c=r[5]===void 0?s:Number(r[5]);r[3]===`d`&&s++;let l=c-s+1;(o<0||l<0)&&vw(e,n,t[n]);let u=[],d=[];n++;for(let r=0;r<o;r++,n++){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!/^<[ \t]/u.test(t[n]))throw new Y(`'<' followed by space or tab expected at line ${n+1} of patch`);let i=r+1===o&&yw(e,n);d.push({tag:`-`,text:i?t[n].slice(2).replace(/\n$/u,``):t[n].slice(2)}),i&&n++}if(r[3]===`c`){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!t[n].startsWith(`-`))throw new Y(`'---' expected at line ${n+1} of patch`);n++}for(let r=0;r<l;r++,n++){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!/^>[ \t]/u.test(t[n]))throw new Y(`'>' followed by space or tab expected at line ${n+1} of patch`);let i=r+1===l&&yw(e,n);u.push({tag:`+`,text:i?t[n].slice(2).replace(/\n$/u,``):t[n].slice(2)}),i&&n++}return e.pos=n,{oldStart:a,oldLines:d,newStart:s,newLines:u,prefix:0,suffix:0,fn:null,marks:null,line:i}}function Ew(e){let t=(e,t,n)=>e.map(e=>({tag:e.tag===t?n:e.tag,text:e.text})),n=(e,t,n)=>e.map(e=>e===t?n:e);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 Y=class extends Error{constructor(e){super(e),this.name=`PatchFatal`}},Dw=(e,t)=>{throw new T(`feature`,e,t)};function Ow(e){let t=Fn(e);return t.length&&!t.at(-1).endsWith(`
239
239
  `)&&(t[t.length-1]+=`
240
- `),{lines:t,pos:0,base:0,empty:e===``}}var Ew=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u,Dw=/^(?:\d+(?:,\d+)?)?(?:[acdi]|s\/\.\/\/)[ \t]*\n$/u,Ow=/^[0-9a-fA-F]+/u;function kw(e,{needHeader:t,strip:n,format:r}){let{lines:i}=e,a={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},o=t&&r!==`normal`&&r!==`ed`,s=!1,c=-1,l=!1,u=!1;for(let t=e.pos;;t++){if(t>=i.length)return s&&ww(`ed script`,`ed scripts are not supported`),a.extended?{...a,type:`unified`,start:t,hunkLine:t,empty:!0}:null;let d=i[t],f=d.replace(/^[ \tX]+/u,``),p=/^\d/u.test(f)&&Ew.test(f);!o&&c<0&&(Dw.test(f)||p)&&(c=t,s=Dw.test(f));let m=Aw(d,a,n,u);if(m===`binary`&&ww(`git binary patch`,`git binary diffs are not supported`),m===`prereq`&&ww(`Prereq`,`Prereq: lines are not supported`),m===`git`&&a.extended)return{...a,type:`unified`,start:t,hunkLine:t,empty:!0};m&&(o=!1);let h=d.startsWith(`********`);if(/^[ \t]+(?:@@ -\d|\*{8})/u.test(d)&&ww(`indented patch`,`indented patches are not supported`),!o){if(d.endsWith(`\r
241
- `)&&(d.startsWith(`@@ -`)||u)&&ww(`CRLF patch`,`patches with CRLF line endings are not supported`),(r===null||r===`ed`)&&c>=0&&d===`.
242
- `&&ww(`ed script`,`ed scripts are not supported`),(r===null||r===`unified`)&&d.startsWith(`@@ -`))return Nw(a,t,d);if((r===null||r===`context`)&&u&&d.startsWith(`*** `))return Pw(e,a,t,d);if((r===null||r===`normal`)&&l&&(d.startsWith(`< `)||d.startsWith(`> `)))return{...a,type:`normal`,start:t-1,hunkLine:t-1}}u=h,l=p}}function Aw(e,t,n,r){if(!r&&e.startsWith(`*** `)||e.startsWith(`+++ `))return Mw(t,`old`,e.slice(4),n);if(e.startsWith(`Index:`))return t.names.index=Iw(e.slice(6),n,!1).name,`index`;if(e.startsWith(`Prereq:`))return`prereq`;if(e.startsWith(`diff --git `)){let r=zw(e.slice(11),n),i=r.name===null?null:zw(r.rest,n);return t.names.old=i&&i.rest.trim()===``?r.name:null,t.names.new=t.names.old===null?null:i.name,t.git=!0,t.stamps.old=t.stamps.new=-1,`git`}if(t.git){let n=jw(e,t);if(n)return n}let i=e;for(;i.startsWith(`- `);)i=i.slice(2);return i.startsWith(`--- `)?Mw(t,`new`,i.slice(4),n):null}function jw(e,t){if(e.startsWith(`index `)){let n=Ow.exec(e.slice(6)),r=n?e.slice(6+n[0].length):``,i=r.startsWith(`..`)?Ow.exec(r.slice(2)):null;return i?(t.says[0]=/^0+$/u.test(n[0])?2:0,t.says[1]=/^0+$/u.test(i[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 Mw(e,t,n,r){let i=Iw(n,r,!0);return i.stamp!==void 0&&(e.stamps[t]=i.stamp),i.name!==void 0&&(e.names[t]=i.name,e.timestrs[t]=i.timestr),`name`}function Nw(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}},i=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/u.exec(n),a=[...e.says];return i&&i[1]===`0`&&(a[0]=1+ +(r.stamps.old===0)),i&&i[3]===`0`&&(a[1]=1+ +(r.stamps.new===0)),{...e,...r,says:a,type:`unified`,start:t,hunkLine:t}}function Pw(e,t,n,r){let i=[...t.says];/^\*\*\* 0(?!\d)/u.test(r)&&(i[0]=1+ +(t.stamps.old===0));let a={...e,pos:n-1};try{let e=vw(a);e&&e.newLines.length===0&&e.newStart===1&&(i[1]=1+ +(t.stamps.new===0))}catch{}return{...t,says:i,type:`context`,start:n-1,hunkLine:n-1}}function Fw(e,t){return t===`unified`?_w(e):t===`context`?vw(e):Sw(e)}function Iw(e,t,n){let r=e.replace(/^[ \t\n\v\f\r]+/u,``),i,a;if(r.startsWith(`"`)){let e=Vw(r);if(!e)return{};i=e.value,a=e.rest}else{let e=0;for(;e<r.length;e++){if(!/[ \t\n\v\f\r]/u.test(r[e]))continue;let t=e;for(;r[t]!==` `&&/[ \t\n\v\f\r]/u.test(r[t+1]??``);)t++;if(r[t]===` `||r.indexOf(n?` `:`
243
- `,t+1)===-1)break}i=r.slice(0,e),a=r.slice(e)}if(i===`/dev/null`)return{stamp:0};let o=Rw(i,t);if(o===null)return{};let s=a.replace(/\r?\n$/u,``);return{name:o,timestr:s,stamp:n&&s!==``?Lw(s):-1}}function Lw(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[,e,r,i,a,o,s,c,l,u]=t;n=Date.UTC(Number(e),Number(r)-1,Number(i),Number(a),Number(o),Number(s))/1e3,c&&(n-=(c===`-`?-1:1)*(Number(l)*3600+Number(u)*60))}else{let t=/^\s*[A-Z][a-z]{2} ([A-Z][a-z]{2}) +(\d+) (\d\d):(\d\d):(\d\d) (\d{4})/u.exec(e);if(!t)return-1;let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[,i,a,o,s,c,l]=t;n=Date.UTC(Number(l),r.indexOf(i),Number(a),Number(o),Number(s),Number(c))/1e3}return n>-9e4&&n<93600?0:n}function Rw(e,t){let n=t,r=0;for(let i=0;i<e.length;i++)if(e[i]===`/`){for(;e[i+1]===`/`;)i++;(t<0||--n>=0)&&(r=i+1)}return(t<0||n<=0)&&r<e.length?e.slice(r):null}function zw(e,t){let n=e.replace(/^[ \t\n\v\f\r]+/u,``),r,i;if(n.startsWith(`"`)){let e=Vw(n);if(!e)return{name:null,rest:``};r=e.value,i=e.rest}else{let e=n.search(/[ \t\n\v\f\r]/u);r=e<0?n:n.slice(0,e),i=e<0?``:n.slice(e)}return{name:Rw(r,t),rest:i}}var Bw={a:`\x07`,b:`\b`,f:`\f`,n:`
244
- `,r:`\r`,t:` `,v:`\v`,"\\":`\\`,'"':`"`};function Vw(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 i=e[++n];if(i===void 0)return null;if(/[0-7]/u.test(i)){let r=/^[0-7]{1,3}/u.exec(e.slice(n))[0];t+=String.fromCodePoint(Number.parseInt(r,8)),n+=r.length-1}else if(i in Bw)t+=Bw[i];else return null}return null}function Hw(e,t){let n=e=>e.split(`/`).length-1,r=e=>e.slice(e.lastIndexOf(`/`)+1).length,i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o===null||t[a])continue;if(i===-1){i=a;continue}let[s,c]=[n(o),n(e[i])];if(s!==c){s<c&&(i=a);continue}let[l,u]=[r(o),r(e[i])];if(l!==u){l<u&&(i=a);continue}o.length<e[i].length&&(i=a)}return i}function Uw(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 kw=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u,Aw=/^(?:\d+(?:,\d+)?)?(?:[acdi]|s\/\.\/\/)[ \t]*\n$/u,jw=/^[0-9a-fA-F]+/u;function Mw(e,{needHeader:t,strip:n,format:r}){let{lines:i}=e,a={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},o=t&&r!==`normal`&&r!==`ed`,s=!1,c=-1,l=!1,u=!1;for(let t=e.pos;;t++){if(t>=i.length)return s&&Dw(`ed script`,`ed scripts are not supported`),a.extended?{...a,type:`unified`,start:t,hunkLine:t,empty:!0}:null;let d=i[t],f=d.replace(/^[ \tX]+/u,``),p=/^\d/u.test(f)&&kw.test(f);!o&&c<0&&(Aw.test(f)||p)&&(c=t,s=Aw.test(f));let m=Nw(d,a,n,u);if(m===`binary`&&Dw(`git binary patch`,`git binary diffs are not supported`),m===`prereq`&&Dw(`Prereq`,`Prereq: lines are not supported`),m===`git`&&a.extended)return{...a,type:`unified`,start:t,hunkLine:t,empty:!0};m&&(o=!1);let h=d.startsWith(`********`);if(/^[ \t]+(?:@@ -\d|\*{8})/u.test(d)&&Dw(`indented patch`,`indented patches are not supported`),!o){if(d.endsWith(`\r
241
+ `)&&(d.startsWith(`@@ -`)||u)&&Dw(`CRLF patch`,`patches with CRLF line endings are not supported`),(r===null||r===`ed`)&&c>=0&&d===`.
242
+ `&&Dw(`ed script`,`ed scripts are not supported`),(r===null||r===`unified`)&&d.startsWith(`@@ -`))return Iw(a,t,d);if((r===null||r===`context`)&&u&&d.startsWith(`*** `))return Lw(e,a,t,d);if((r===null||r===`normal`)&&l&&(d.startsWith(`< `)||d.startsWith(`> `)))return{...a,type:`normal`,start:t-1,hunkLine:t-1}}u=h,l=p}}function Nw(e,t,n,r){if(!r&&e.startsWith(`*** `)||e.startsWith(`+++ `))return Fw(t,`old`,e.slice(4),n);if(e.startsWith(`Index:`))return t.names.index=zw(e.slice(6),n,!1).name,`index`;if(e.startsWith(`Prereq:`))return`prereq`;if(e.startsWith(`diff --git `)){let r=Hw(e.slice(11),n),i=r.name===null?null:Hw(r.rest,n);return t.names.old=i&&i.rest.trim()===``?r.name:null,t.names.new=t.names.old===null?null:i.name,t.git=!0,t.stamps.old=t.stamps.new=-1,`git`}if(t.git){let n=Pw(e,t);if(n)return n}let i=e;for(;i.startsWith(`- `);)i=i.slice(2);return i.startsWith(`--- `)?Fw(t,`new`,i.slice(4),n):null}function Pw(e,t){if(e.startsWith(`index `)){let n=jw.exec(e.slice(6)),r=n?e.slice(6+n[0].length):``,i=r.startsWith(`..`)?jw.exec(r.slice(2)):null;return i?(t.says[0]=/^0+$/u.test(n[0])?2:0,t.says[1]=/^0+$/u.test(i[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 Fw(e,t,n,r){let i=zw(n,r,!0);return i.stamp!==void 0&&(e.stamps[t]=i.stamp),i.name!==void 0&&(e.names[t]=i.name,e.timestrs[t]=i.timestr),`name`}function Iw(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}},i=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/u.exec(n),a=[...e.says];return i&&i[1]===`0`&&(a[0]=1+ +(r.stamps.old===0)),i&&i[3]===`0`&&(a[1]=1+ +(r.stamps.new===0)),{...e,...r,says:a,type:`unified`,start:t,hunkLine:t}}function Lw(e,t,n,r){let i=[...t.says];/^\*\*\* 0(?!\d)/u.test(r)&&(i[0]=1+ +(t.stamps.old===0));let a={...e,pos:n-1};try{let e=xw(a);e&&e.newLines.length===0&&e.newStart===1&&(i[1]=1+ +(t.stamps.new===0))}catch{}return{...t,says:i,type:`context`,start:n-1,hunkLine:n-1}}function Rw(e,t){return t===`unified`?bw(e):t===`context`?xw(e):Tw(e)}function zw(e,t,n){let r=e.replace(/^[ \t\n\v\f\r]+/u,``),i,a;if(r.startsWith(`"`)){let e=Ww(r);if(!e)return{};i=e.value,a=e.rest}else{let e=0;for(;e<r.length;e++){if(!/[ \t\n\v\f\r]/u.test(r[e]))continue;let t=e;for(;r[t]!==` `&&/[ \t\n\v\f\r]/u.test(r[t+1]??``);)t++;if(r[t]===` `||r.indexOf(n?` `:`
243
+ `,t+1)===-1)break}i=r.slice(0,e),a=r.slice(e)}if(i===`/dev/null`)return{stamp:0};let o=Vw(i,t);if(o===null)return{};let s=a.replace(/\r?\n$/u,``);return{name:o,timestr:s,stamp:n&&s!==``?Bw(s):-1}}function Bw(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[,e,r,i,a,o,s,c,l,u]=t;n=Date.UTC(Number(e),Number(r)-1,Number(i),Number(a),Number(o),Number(s))/1e3,c&&(n-=(c===`-`?-1:1)*(Number(l)*3600+Number(u)*60))}else{let t=/^\s*[A-Z][a-z]{2} ([A-Z][a-z]{2}) +(\d+) (\d\d):(\d\d):(\d\d) (\d{4})/u.exec(e);if(!t)return-1;let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[,i,a,o,s,c,l]=t;n=Date.UTC(Number(l),r.indexOf(i),Number(a),Number(o),Number(s),Number(c))/1e3}return n>-9e4&&n<93600?0:n}function Vw(e,t){let n=t,r=0;for(let i=0;i<e.length;i++)if(e[i]===`/`){for(;e[i+1]===`/`;)i++;(t<0||--n>=0)&&(r=i+1)}return(t<0||n<=0)&&r<e.length?e.slice(r):null}function Hw(e,t){let n=e.replace(/^[ \t\n\v\f\r]+/u,``),r,i;if(n.startsWith(`"`)){let e=Ww(n);if(!e)return{name:null,rest:``};r=e.value,i=e.rest}else{let e=n.search(/[ \t\n\v\f\r]/u);r=e<0?n:n.slice(0,e),i=e<0?``:n.slice(e)}return{name:Vw(r,t),rest:i}}var Uw={a:`\x07`,b:`\b`,f:`\f`,n:`
244
+ `,r:`\r`,t:` `,v:`\v`,"\\":`\\`,'"':`"`};function Ww(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 i=e[++n];if(i===void 0)return null;if(/[0-7]/u.test(i)){let r=/^[0-7]{1,3}/u.exec(e.slice(n))[0];t+=String.fromCodePoint(Number.parseInt(r,8)),n+=r.length-1}else if(i in Uw)t+=Uw[i];else return null}return null}function Gw(e,t){let n=e=>e.split(`/`).length-1,r=e=>e.slice(e.lastIndexOf(`/`)+1).length,i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o===null||t[a])continue;if(i===-1){i=a;continue}let[s,c]=[n(o),n(e[i])];if(s!==c){s<c&&(i=a);continue}let[l,u]=[r(o),r(e[i])];if(l!==u){l<u&&(i=a);continue}o.length<e[i].length&&(i=a)}return i}function Kw(e,t){let{opts:n}=e;return(n.noReverse||!(n.force&&n.silent))&&e.say(t),n.noReverse?(e.say(` Skipping patch.
245
245
  `),e.skipRest=!0,!1):n.force?(n.silent||e.say(` Applying it anyway.
246
246
  `),!1):n.batch?(e.say(e.reverse?` Ignoring -R.
247
247
  `:` Assuming -R.
@@ -249,23 +249,23 @@ diff: Try 'diff --help' for more information.`,2);function HC(e){let t=[];for(le
249
249
  `:` Assume -R? [n]
250
250
  `),e.say(`Apply anyway? [n]
251
251
  `),n.silent||e.say(`Skipping patch.
252
- `),e.skipRest=!0,!1)}function Ww(e,t,n,r,i){let a=+!!e.reverse,o=t.says,s=+!i<o[a^+!!i];if(i&&o[a^+!!r]===1&&o[1-a^!!r]===2)return!1;if(s){let t=r?`delete`:i?`empty out`:`create`,a=r?`does not exist`:i?`is already empty`:`already exists`;Uw(e,`The next patch${e.reverse?`, when reversed,`:``} would ${t} the file ${e.quote(n)},
253
- which ${a}!`)&&(e.reverse=!e.reverse)}return s}function Gw(e,t,n,r){let i=[t.names.old,t.names.new,t.names.index];(i[0]!==null||i[1]!==null)&&i[2]!==null&&(i[2]=null);let a=-1;if(n===null){let n=i.map(e=>e===null?null:r(e));a=Hw(i,n.map(e=>e===null||!e.exists));let o=i.findIndex(e=>e!==null);if(o!==-1&&(a===-1||!n[a].isDir)){let r=a===-1;Ww(e,t,i[r?o:a],r,r||n[a].size===0)&&r&&(a=o)}a===-1&&t.says[+!!e.reverse]&&(a=Hw(i,i.map(()=>!1)))}if((t.rename[0]||t.rename[1]||t.copy[0]||t.copy[1])&&n===null&&(a!==0&&a!==1||i[0]===null||i[1]===null)&&(e.say(`Cannot ${t.rename[0]||t.rename[1]?`rename`:`copy`} file without two valid file names
254
- `),e.skipRest=!0),a===-1){if(n===null)return null;let i=r(n);return(!i.exists||!i.isDir)&&Ww(e,t,n,!i.exists,!i.exists||i.size===0),n}return i[a]}function Kw(e){return{input:e,frozen:0,inOffset:0,outOffset:0,out:[]}}var qw=(e,t)=>t<1||t>e.input.length?``:e.input[t-1];function Jw(e,t){let n=e=>e.replace(/\n$/u,``).replace(/[ \t]+$/u,``).replace(/[ \t]+/gu,` `);return n(e)===n(t)}function Yw(e,t,n,r,i,a,o){let s=t.oldLines,c=s.length-a;for(let t=n+r+i,a=i;a<c;a++,t++){let n=qw(e,t),r=s[a].text;if(o?!Jw(n,r):n!==r)return!1}return!0}function Xw(e,t,n,r){let i=t.oldStart+e.inOffset,a=t.oldLines.length,o=Math.max(t.prefix,t.suffix),s=n+t.prefix-o,c=n+t.suffix-o,l=e.input.length,u=l-(a-c)+1,d=e.frozen+1,f=u-i,p=i-d,m=Math.max(f,p);if(!a)return i;i<=p&&(p=i-1);let h=t=>(e.inOffset+=t,i+t);if(s<0&&t.oldStart<=1){if(c<0&&(a!==l||t.prefix<e.frozen))return 0;let n=1-i;return e.frozen<=t.prefix&&n<=f&&Yw(e,t,i,n,0,c,r)?h(n):0}if(s<0&&(s=0),c<0){let n=i-(l-a+1);return n<=p&&Yw(e,t,i,-n,s,0,r)?h(-n):0}let g=f<0?i-u:p<0?i-d:0;for(let n=g;n<=m;n++){if(n<=f&&Yw(e,t,i,n,s,c,r))return h(n);if(n<=p&&Yw(e,t,i,-n,s,c,r))return h(-n)}return 0}function Zw(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 Qw(e,t,n){let r=n-1,i=t.newLines,a=t.oldLines,o=0,s=0,c=()=>{throw new Y(`Out-of-sync patch, lines ${t.line+1+s+1},${t.line+1+a.length+o+1} -- mangled text or line numbers, maybe?`)};for(;s<a.length;)if(a[s].tag===`-`){if(!Zw(e,r+s))return!1;e.frozen++,s++}else{if(o>=i.length)break;if(i[o].tag===`+`){if(!Zw(e,r+s))return!1;e.out.push(i[o++].text)}else i[o].tag===a[s].tag?(s++,o++):c()}for(;o<i.length&&i[o].tag===`+`;o++){if(!Zw(e,r+s))return!1;e.out.push(i[o].text)}return e.outOffset+=i.length-a.length,!0}var $w=e=>e.frozen>=e.input.length||Zw(e,e.input.length),eT=e=>e.map((t,n)=>n<e.length-1&&!t.endsWith(`
252
+ `),e.skipRest=!0,!1)}function qw(e,t,n,r,i){let a=+!!e.reverse,o=t.says,s=+!i<o[a^+!!i];if(i&&o[a^+!!r]===1&&o[1-a^!!r]===2)return!1;if(s){let t=r?`delete`:i?`empty out`:`create`,a=r?`does not exist`:i?`is already empty`:`already exists`;Kw(e,`The next patch${e.reverse?`, when reversed,`:``} would ${t} the file ${e.quote(n)},
253
+ which ${a}!`)&&(e.reverse=!e.reverse)}return s}function Jw(e,t,n,r){let i=[t.names.old,t.names.new,t.names.index];(i[0]!==null||i[1]!==null)&&i[2]!==null&&(i[2]=null);let a=-1;if(n===null){let n=i.map(e=>e===null?null:r(e));a=Gw(i,n.map(e=>e===null||!e.exists));let o=i.findIndex(e=>e!==null);if(o!==-1&&(a===-1||!n[a].isDir)){let r=a===-1;qw(e,t,i[r?o:a],r,r||n[a].size===0)&&r&&(a=o)}a===-1&&t.says[+!!e.reverse]&&(a=Gw(i,i.map(()=>!1)))}if((t.rename[0]||t.rename[1]||t.copy[0]||t.copy[1])&&n===null&&(a!==0&&a!==1||i[0]===null||i[1]===null)&&(e.say(`Cannot ${t.rename[0]||t.rename[1]?`rename`:`copy`} file without two valid file names
254
+ `),e.skipRest=!0),a===-1){if(n===null)return null;let i=r(n);return(!i.exists||!i.isDir)&&qw(e,t,n,!i.exists,!i.exists||i.size===0),n}return i[a]}function Yw(e){return{input:e,frozen:0,inOffset:0,outOffset:0,out:[]}}var Xw=(e,t)=>t<1||t>e.input.length?``:e.input[t-1];function Zw(e,t){let n=e=>e.replace(/\n$/u,``).replace(/[ \t]+$/u,``).replace(/[ \t]+/gu,` `);return n(e)===n(t)}function Qw(e,t,n,r,i,a,o){let s=t.oldLines,c=s.length-a;for(let t=n+r+i,a=i;a<c;a++,t++){let n=Xw(e,t),r=s[a].text;if(o?!Zw(n,r):n!==r)return!1}return!0}function $w(e,t,n,r){let i=t.oldStart+e.inOffset,a=t.oldLines.length,o=Math.max(t.prefix,t.suffix),s=n+t.prefix-o,c=n+t.suffix-o,l=e.input.length,u=l-(a-c)+1,d=e.frozen+1,f=u-i,p=i-d,m=Math.max(f,p);if(!a)return i;i<=p&&(p=i-1);let h=t=>(e.inOffset+=t,i+t);if(s<0&&t.oldStart<=1){if(c<0&&(a!==l||t.prefix<e.frozen))return 0;let n=1-i;return e.frozen<=t.prefix&&n<=f&&Qw(e,t,i,n,0,c,r)?h(n):0}if(s<0&&(s=0),c<0){let n=i-(l-a+1);return n<=p&&Qw(e,t,i,-n,s,0,r)?h(-n):0}let g=f<0?i-u:p<0?i-d:0;for(let n=g;n<=m;n++){if(n<=f&&Qw(e,t,i,n,s,c,r))return h(n);if(n<=p&&Qw(e,t,i,-n,s,c,r))return h(-n)}return 0}function eT(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 tT(e,t,n){let r=n-1,i=t.newLines,a=t.oldLines,o=0,s=0,c=()=>{throw new Y(`Out-of-sync patch, lines ${t.line+1+s+1},${t.line+1+a.length+o+1} -- mangled text or line numbers, maybe?`)};for(;s<a.length;)if(a[s].tag===`-`){if(!eT(e,r+s))return!1;e.frozen++,s++}else{if(o>=i.length)break;if(i[o].tag===`+`){if(!eT(e,r+s))return!1;e.out.push(i[o++].text)}else i[o].tag===a[s].tag?(s++,o++):c()}for(;o<i.length&&i[o].tag===`+`;o++){if(!eT(e,r+s))return!1;e.out.push(i[o].text)}return e.outOffset+=i.length-a.length,!0}var nT=e=>e.frozen>=e.input.length||eT(e,e.input.length),rT=e=>e.map((t,n)=>n<e.length-1&&!t.endsWith(`
255
255
  `)?t+`
256
- `:t).join(``);function tT(e,t,n,r,i){let{opts:a}=e,o={count:0,failed:0,mismatch:!1,applyAnyway:!1};for(let s=n();s;s=n()){o.count++;let{hunk:n,where:c,fuzz:l}=e.skipRest?{hunk:e.reverse?Cw(s):s,where:0,fuzz:0}:nT(e,r,e.reverse?Cw(s):s,o),u=(c||n.oldStart)+r.outOffset,d=c===1&&t.says[+!!e.reverse]===2&&r.input.length>0;if(e.skipRest||d||!c||!Qw(r,n,c))e.skipRejectFile||i.add(n,o.failed===0,r.outOffset,e.reverse),o.failed++,!e.skipRest&&!a.silent&&e.say(`Hunk #${o.count} FAILED at ${u}.
256
+ `:t).join(``);function iT(e,t,n,r,i){let{opts:a}=e,o={count:0,failed:0,mismatch:!1,applyAnyway:!1};for(let s=n();s;s=n()){o.count++;let{hunk:n,where:c,fuzz:l}=e.skipRest?{hunk:e.reverse?Ew(s):s,where:0,fuzz:0}:aT(e,r,e.reverse?Ew(s):s,o),u=(c||n.oldStart)+r.outOffset,d=c===1&&t.says[+!!e.reverse]===2&&r.input.length>0;if(e.skipRest||d||!c||!tT(r,n,c))e.skipRejectFile||i.add(n,o.failed===0,r.outOffset,e.reverse),o.failed++,!e.skipRest&&!a.silent&&e.say(`Hunk #${o.count} FAILED at ${u}.
257
257
  `);else if(!a.silent&&(l||r.inOffset)){let t=r.inOffset?` (offset ${r.inOffset} line${r.inOffset===1?``:`s`})`:``;e.say(`Hunk #${o.count} succeeded at ${u}${l?` with fuzz ${l}`:``}${t}.
258
- `)}}return o}function nT(e,t,n,r){let{opts:i}=e,a=0,o=n,s=0,c=Math.min(i.fuzz,Math.max(o.prefix,o.suffix));do if(s=Xw(t,o,a,i.loose),(!s||a||t.inOffset)&&(r.mismatch=!0),r.count===1&&!s&&!(i.force||r.applyAnyway)&&e.reverse===e.reverseFlag){let n=Cw(o);s=Xw(t,n,a,i.loose),s&&Uw(e,`${e.reverse?`Unreversed`:`Reversed (or previously applied)`} patch detected!`)?(e.reverse=!e.reverse,o=n):s&&=(r.applyAnyway=!0,a--,0)}while(!e.skipRest&&!s&&++a<=c);return{hunk:o,where:s,fuzz:a}}var rT=(e,t)=>e+t;function iT(e,t){let n=``,r=(t,n)=>`${t} ${e.names[n]??`/dev/null`}${e.timestrs[n]??``}
258
+ `)}}return o}function aT(e,t,n,r){let{opts:i}=e,a=0,o=n,s=0,c=Math.min(i.fuzz,Math.max(o.prefix,o.suffix));do if(s=$w(t,o,a,i.loose),(!s||a||t.inOffset)&&(r.mismatch=!0),r.count===1&&!s&&!(i.force||r.applyAnyway)&&e.reverse===e.reverseFlag){let n=Ew(o);s=$w(t,n,a,i.loose),s&&Kw(e,`${e.reverse?`Unreversed`:`Reversed (or previously applied)`} patch detected!`)?(e.reverse=!e.reverse,o=n):s&&=(r.applyAnyway=!0,a--,0)}while(!e.skipRest&&!s&&++a<=c);return{hunk:o,where:s,fuzz:a}}var oT=(e,t)=>e+t;function sT(e,t){let n=``,r=(t,n)=>`${t} ${e.names[n]??`/dev/null`}${e.timestrs[n]??``}
259
259
  `,i=e.names.index===null?``:`Index: ${e.names.index}
260
- `;return{get text(){return n},add(e,a,o,s){let c=s?[`new`,`old`]:[`old`,`new`];t===`unified`?(a&&(n+=i+r(`---`,c[0])+r(`+++`,c[1])),n+=oT(e,o)):(a&&(n+=i+r(`***`,c[0])+r(`---`,c[1])),n+=cT(e,o,t))}}}var aT=(e,t)=>t===0?`${e-1},0`:t===1?`${e}`:`${e},${t}`;function oT(e,t){let n=e.newLines,r=e.oldLines,i=`@@ -${aT(e.oldStart+t,r.length)} +${aT(e.newStart+t,n.length)} @@${e.fn??``}
261
- `,a=0,o=0;for(;;o++,a++){for(;o<r.length&&r[o].tag===`-`;o++)i+=rT(`-`,r[o].text);for(;a<n.length&&n[a].tag===`+`;a++)i+=rT(`+`,n[a].text);if(o>=r.length)break;i+=rT(` `,r[o].text)}return i}function sT(e,t){let n=e+t-1;return n<e?`0`:n===e?`${e}`:`${e},${n}`}function cT(e,t,n){let r=n!==`normal`,i=e.marks??(n===`normal`?lT(e):uT(e)),a=`***************${e.fn??``}
262
- `;return a+=`*** ${sT(e.oldStart+t,e.oldLines.length)}${r?` ****`:``}
263
- `,e.oldLines.forEach((e,t)=>{a+=rT(i.old[t]+` `,e.text)}),a+=`--- ${sT(e.newStart+t,e.newLines.length)}${r?` ----`:` -----`}
264
- `,e.newLines.forEach((e,t)=>{a+=rT(i.new[t]+` `,e.text)}),a}var lT=e=>({old:e.oldLines.map(e=>e.tag),new:e.newLines.map(e=>e.tag)});function uT(e){let t=e.newLines.map(e=>e.tag),n=e.oldLines.map(e=>e.tag),r=0,i=0;for(;i<n.length;)if(n[i]===`-`){if(r<t.length&&t[r]===`+`){do n[i++]=`!`;while(i<n.length&&n[i]===`-`);do t[r++]=`!`;while(r<t.length&&t[r]===`+`)}else do i++;while(i<n.length&&n[i]===`-`)}else if(r<t.length&&t[r]===`+`)do r++;while(r<t.length&&t[r]===`+`);else i++,r++;return{old:n,new:t}}var dT=[`R`,`N`,`f`,`t`,`s`,`b`,`l`,`E`,`T`,`Z`,`e`,`u`,`c`,`n`,`v`],fT=[`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`],pT=[`p`,`i`,`o`,`d`,`r`,`F`,`z`,`B`,`Y`,`V`,`g`,`D`,`x`],mT=[`strip`,`input`,`output`,`directory`,`reject-file`,`fuzz`,`suffix`,`prefix`,`basename-prefix`,`version-control`,`get`,`reject-format`,`quoting-style`,`read-only`,`merge`,`debug`],hT=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`]]),gT=e=>x(`patch: ${e}
265
- patch: Try 'patch --help' for more information.`,2);function _T(e){for(let t of e){if(t===`--`)break;let e=t.replace(/=.*/u,``);if(e===`--merge`||e===`--read-only`)return{refused:C(`option`,`patch`,e,`patch: ${e}: ${hT.get(e.slice(2))} is not supported`,2)}}let t;try{t=U(e,{short:dT,long:fT,valueShort:pT,valueLong:mT})}catch(e){let t=S(e);return t?{refused:C(t.kind,`patch`,t.detail,`patch: ${e.message}`,2)}:{error:gT(e.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:e,value:r}of t.order){let t=(e.length===1?`-`:`--`)+e,i=hT.get(e);if(i)return{refused:C(`option`,`patch`,t,`patch: ${t}: ${i} is not supported`,2)};let a=yT(n,e,r);if(a)return{error:a}}return t.positional.length>2?{error:gT(`${t.positional[2]}: extra operand`)}:{opts:n,operands:t.positional}}function vT(e,t){if(!/^[+-]?\d+$/u.test(e))return{error:x(`patch: **** ${t} ${iy(e,{vars:new Map})} is not a number`,2)};let n=Number(e);return n<0?{error:x(`patch: **** ${t} ${e} is negative`,2)}:{value:Math.min(n,2**53-1)}}function yT(e,t,n){switch(t){case`p`:case`strip`:{let t=vT(n,`strip count`);return t.error?t.error:(e.strip=t.value,null)}case`F`:case`fuzz`:{let t=vT(n,`fuzz factor`);return t.error?t.error:(e.fuzz=t.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===``?x(`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`?x(`patch: **** unknown reject format ${n}`,2):(e.rejectFormat=n,null);default:return null}}function bT(e,t,n){let r=_T(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:i,operands:a}=r,o={ctx:n,opts:i,dir:n.cwd,events:[],stdout:``,stderr:``,skipRest:!1,skipRejectFile:!1,reverse:i.reverse,reverseFlag:i.reverse,someFailed:!1,rejectsMade:new Set,output:``},s=i.output===`-`?2:1;o.quote=e=>iy(e,n),o.say=e=>{s===1?o.stdout+=e:o.stderr+=e,o.events.push({fd:s,text:e})};try{if(i.directory!==null){let e=k(n.cwd,i.directory,n.fs);if(e.error||!n.fs.isDir(e.path))throw new Y(`Can't change to directory ${iy(i.directory,n)} : ${e.error??`Not a directory`}`);o.dir=e.path}ST(o,Tw(xT(o,e,i.input??a[1]??null)),a[0]??null),i.output!==null&&i.output!==`-`&&AT(o,i.output,o.output,!1)}catch(e){if(!(e instanceof Y)){let t=S(e);if(!t)throw e;let n=`patch: ${e.message}`;return w({stdout:o.stdout,stderr:o.stderr+n+`
260
+ `;return{get text(){return n},add(e,a,o,s){let c=s?[`new`,`old`]:[`old`,`new`];t===`unified`?(a&&(n+=i+r(`---`,c[0])+r(`+++`,c[1])),n+=lT(e,o)):(a&&(n+=i+r(`***`,c[0])+r(`---`,c[1])),n+=dT(e,o,t))}}}var cT=(e,t)=>t===0?`${e-1},0`:t===1?`${e}`:`${e},${t}`;function lT(e,t){let n=e.newLines,r=e.oldLines,i=`@@ -${cT(e.oldStart+t,r.length)} +${cT(e.newStart+t,n.length)} @@${e.fn??``}
261
+ `,a=0,o=0;for(;;o++,a++){for(;o<r.length&&r[o].tag===`-`;o++)i+=oT(`-`,r[o].text);for(;a<n.length&&n[a].tag===`+`;a++)i+=oT(`+`,n[a].text);if(o>=r.length)break;i+=oT(` `,r[o].text)}return i}function uT(e,t){let n=e+t-1;return n<e?`0`:n===e?`${e}`:`${e},${n}`}function dT(e,t,n){let r=n!==`normal`,i=e.marks??(n===`normal`?fT(e):pT(e)),a=`***************${e.fn??``}
262
+ `;return a+=`*** ${uT(e.oldStart+t,e.oldLines.length)}${r?` ****`:``}
263
+ `,e.oldLines.forEach((e,t)=>{a+=oT(i.old[t]+` `,e.text)}),a+=`--- ${uT(e.newStart+t,e.newLines.length)}${r?` ----`:` -----`}
264
+ `,e.newLines.forEach((e,t)=>{a+=oT(i.new[t]+` `,e.text)}),a}var fT=e=>({old:e.oldLines.map(e=>e.tag),new:e.newLines.map(e=>e.tag)});function pT(e){let t=e.newLines.map(e=>e.tag),n=e.oldLines.map(e=>e.tag),r=0,i=0;for(;i<n.length;)if(n[i]===`-`){if(r<t.length&&t[r]===`+`){do n[i++]=`!`;while(i<n.length&&n[i]===`-`);do t[r++]=`!`;while(r<t.length&&t[r]===`+`)}else do i++;while(i<n.length&&n[i]===`-`)}else if(r<t.length&&t[r]===`+`)do r++;while(r<t.length&&t[r]===`+`);else i++,r++;return{old:n,new:t}}var mT=[`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`],gT=[`p`,`i`,`o`,`d`,`r`,`F`,`z`,`B`,`Y`,`V`,`g`,`D`,`x`],_T=[`strip`,`input`,`output`,`directory`,`reject-file`,`fuzz`,`suffix`,`prefix`,`basename-prefix`,`version-control`,`get`,`reject-format`,`quoting-style`,`read-only`,`merge`,`debug`],vT=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`]]),yT=e=>x(`patch: ${e}
265
+ patch: Try 'patch --help' for more information.`,2);function bT(e){for(let t of e){if(t===`--`)break;let e=t.replace(/=.*/u,``);if(e===`--merge`||e===`--read-only`)return{refused:C(`option`,`patch`,e,`patch: ${e}: ${vT.get(e.slice(2))} is not supported`,2)}}let t;try{t=U(e,{short:mT,long:hT,valueShort:gT,valueLong:_T})}catch(e){let t=S(e);return t?{refused:C(t.kind,`patch`,t.detail,`patch: ${e.message}`,2)}:{error:yT(e.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:e,value:r}of t.order){let t=(e.length===1?`-`:`--`)+e,i=vT.get(e);if(i)return{refused:C(`option`,`patch`,t,`patch: ${t}: ${i} is not supported`,2)};let a=ST(n,e,r);if(a)return{error:a}}return t.positional.length>2?{error:yT(`${t.positional[2]}: extra operand`)}:{opts:n,operands:t.positional}}function xT(e,t){if(!/^[+-]?\d+$/u.test(e))return{error:x(`patch: **** ${t} ${sy(e,{vars:new Map})} is not a number`,2)};let n=Number(e);return n<0?{error:x(`patch: **** ${t} ${e} is negative`,2)}:{value:Math.min(n,2**53-1)}}function ST(e,t,n){switch(t){case`p`:case`strip`:{let t=xT(n,`strip count`);return t.error?t.error:(e.strip=t.value,null)}case`F`:case`fuzz`:{let t=xT(n,`fuzz factor`);return t.error?t.error:(e.fuzz=t.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===``?x(`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`?x(`patch: **** unknown reject format ${n}`,2):(e.rejectFormat=n,null);default:return null}}function CT(e,t,n){let r=bT(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:i,operands:a}=r,o={ctx:n,opts:i,dir:n.cwd,events:[],stdout:``,stderr:``,skipRest:!1,skipRejectFile:!1,reverse:i.reverse,reverseFlag:i.reverse,someFailed:!1,rejectsMade:new Set,output:``},s=i.output===`-`?2:1;o.quote=e=>sy(e,n),o.say=e=>{s===1?o.stdout+=e:o.stderr+=e,o.events.push({fd:s,text:e})};try{if(i.directory!==null){let e=k(n.cwd,i.directory,n.fs);if(e.error||!n.fs.isDir(e.path))throw new Y(`Can't change to directory ${sy(i.directory,n)} : ${e.error??`Not a directory`}`);o.dir=e.path}TT(o,Ow(wT(o,e,i.input??a[1]??null)),a[0]??null),i.output!==null&&i.output!==`-`&&NT(o,i.output,o.output,!1)}catch(e){if(!(e instanceof Y)){let t=S(e);if(!t)throw e;let n=`patch: ${e.message}`;return w({stdout:o.stdout,stderr:o.stderr+n+`
266
266
  `,events:[...o.events,{fd:2,text:n+`
267
267
  `}],exitCode:2},t.kind,`patch`,t.detail,n)}let t=`patch: **** ${e.message}
268
- `;return{stdout:o.stdout,stderr:o.stderr+t,events:[...o.events,{fd:2,text:t}],exitCode:2}}return{stdout:o.stdout,stderr:o.stderr,events:o.events,exitCode:+!!o.someFailed}}function xT(e,t,n){if(n===null||n===`-`)return F(e.ctx),t;let r=N(e.ctx,`patch`,n);if(r.error||e.ctx.fs.isDir(r.path))throw new Y(`Can't open patch file ${iy(n,e.ctx)} : ${r.error??`Is a directory`}`);return e.ctx.fs.readFile(r.path)}function ST(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let i=kw(t,{needHeader:n===null,strip:r.strip,format:r.format});if(i===null){if(t.base===0&&!t.empty)throw new Y(`Only garbage was found in the patch input.`);return}e.skipRest=!1,e.skipRejectFile=!1,e.reverse=e.reverseFlag;let a=Gw(e,i,n,t=>OT(e,t));a===null&&(a=CT(e,t,i)),e.skipRest&&(e.someFailed=!0),t.pos=i.start,wT(e,t,i,a),t.base=t.pos}}function CT(e,t,n){let{opts:r}=e;if(r.silent||(e.say(`can't find file to patch at input line ${n.hunkLine+1}
268
+ `;return{stdout:o.stdout,stderr:o.stderr+t,events:[...o.events,{fd:2,text:t}],exitCode:2}}return{stdout:o.stdout,stderr:o.stderr,events:o.events,exitCode:+!!o.someFailed}}function wT(e,t,n){if(n===null||n===`-`)return F(e.ctx),t;let r=N(e.ctx,`patch`,n);if(r.error||e.ctx.fs.isDir(r.path))throw new Y(`Can't open patch file ${sy(n,e.ctx)} : ${r.error??`Is a directory`}`);return e.ctx.fs.readFile(r.path)}function TT(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let i=Mw(t,{needHeader:n===null,strip:r.strip,format:r.format});if(i===null){if(t.base===0&&!t.empty)throw new Y(`Only garbage was found in the patch input.`);return}e.skipRest=!1,e.skipRejectFile=!1,e.reverse=e.reverseFlag;let a=Jw(e,i,n,t=>jT(e,t));a===null&&(a=ET(e,t,i)),e.skipRest&&(e.someFailed=!0),t.pos=i.start,DT(e,t,i,a),t.base=t.pos}}function ET(e,t,n){let{opts:r}=e;if(r.silent||(e.say(`can't find file to patch at input line ${n.hunkLine+1}
269
269
  `),n.type!==`normal`&&e.say(r.strip===-1?`Perhaps you should have used the -p or --strip option?
270
270
  `:`Perhaps you used the wrong -p or --strip option?
271
271
  `)),t.base<n.start){e.say(`The text leading up to this was:
@@ -275,92 +275,92 @@ patch: Try 'patch --help' for more information.`,2);function _T(e){for(let t of
275
275
  `):(e.say(`File to patch:
276
276
  `),e.say(`Skip this patch? [y]
277
277
  `),r.silent||e.say(`Skipping patch.
278
- `)),e.skipRest=!0,null}function wT(e,t,n,r){let{opts:i}=e,a=n.copy[0]||n.copy[1]||n.rename[0]||n.rename[1],o=null;e.skipRest||(o=i.output??(a?n.names[e.reverse?`old`:`new`]:r));let s={exists:!1,isDir:!1,content:``};e.skipRest||(s=OT(e,r),(s.isDir||s.link)&&(e.say(`File ${iy(r,e.ctx)} is not a regular file -- refusing to patch
279
- `),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!i.dryRun&&i.output===null&&(kT(e,o),a&&r!==o&&kT(e,r));let c=Kw(Pn(s.exists?s.content:``));if(!e.skipRest&&!i.silent){let t=r!==o,a=!t&&(n.rename[0]||n.rename[1]),s=n.copy[0]||n.copy[1]?`copied`:n.rename[0]||n.rename[1]?`renamed`:`read`,c=a?n.names[r===n.names.old?`new`:`old`]:r,l=t||a?` (${a?`already `:``}${s} from ${c})`:``;e.say(`${i.dryRun?`checking`:`patching`} file ${iy(o,e.ctx)}${l}
280
- `)}let l=iT(n,i.rejectFormat??n.type),u=tT(e,n,()=>n.empty?null:Fw(t,n.type),c,l);!e.skipRest&&!$w(c)&&(e.say(`misordered hunks! output would be garbled
278
+ `)),e.skipRest=!0,null}function DT(e,t,n,r){let{opts:i}=e,a=n.copy[0]||n.copy[1]||n.rename[0]||n.rename[1],o=null;e.skipRest||(o=i.output??(a?n.names[e.reverse?`old`:`new`]:r));let s={exists:!1,isDir:!1,content:``};e.skipRest||(s=jT(e,r),(s.isDir||s.link)&&(e.say(`File ${sy(r,e.ctx)} is not a regular file -- refusing to patch
279
+ `),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!i.dryRun&&i.output===null&&(MT(e,o),a&&r!==o&&MT(e,r));let c=Yw(Fn(s.exists?s.content:``));if(!e.skipRest&&!i.silent){let t=r!==o,a=!t&&(n.rename[0]||n.rename[1]),s=n.copy[0]||n.copy[1]?`copied`:n.rename[0]||n.rename[1]?`renamed`:`read`,c=a?n.names[r===n.names.old?`new`:`old`]:r,l=t||a?` (${a?`already `:``}${s} from ${c})`:``;e.say(`${i.dryRun?`checking`:`patching`} file ${sy(o,e.ctx)}${l}
280
+ `)}let l=sT(n,i.rejectFormat??n.type),u=iT(e,n,()=>n.empty?null:Rw(t,n.type),c,l);!e.skipRest&&!nT(c)&&(e.say(`misordered hunks! output would be garbled
281
281
  Skipping patch.
282
- `),e.skipRest=!0);let d=eT(c.out);i.output!==null&&!e.skipRest&&(i.output===`-`?(e.stdout+=d,e.events.push({fd:1,text:d})):e.output+=d),!e.skipRest&&i.output===null&&TT(e,n,{inname:r,outname:o,input:s,content:d,result:u,empty:c.out.length===0,renaming:a}),u.failed&&!e.skipRejectFile&&ET(e,o,u,l.text)}function TT(e,t,n){let{opts:r}=e,{inname:i,outname:a,input:o,content:s,result:c,empty:l,renaming:u}=n,d=r.backup||r.backupIfMismatch&&(c.mismatch||c.failed>0),f=t.says[+!e.reverse]===2;if(l&&(r.removeEmpty||f)){r.dryRun||jT(e,a,d);return}if(!l&&f&&(e.someFailed=!0,r.silent||e.say(`Not deleting file ${iy(a,e.ctx)} as content differs from patch
283
- `)),!r.dryRun){if(c.failed<c.count||u)AT(e,a,s,d),u&&i!==a&&(t.rename[0]||t.rename[1])&&jT(e,i,!1);else if(d){if(!o.exists)throw new Y(`Can't reopen file ${iy(a,e.ctx)} : No such file or directory`);AT(e,DT(e,a),o.content,!1)}}}function ET(e,t,n,r){let{opts:i}=e;if(e.someFailed=!0,e.say(`${n.failed} out of ${n.count} hunk${n.count===1?``:`s`} ${e.skipRest?`ignored`:`FAILED`}`),t===null||i.rejectFile===`-`){e.say(`
282
+ `),e.skipRest=!0);let d=rT(c.out);i.output!==null&&!e.skipRest&&(i.output===`-`?(e.stdout+=d,e.events.push({fd:1,text:d})):e.output+=d),!e.skipRest&&i.output===null&&OT(e,n,{inname:r,outname:o,input:s,content:d,result:u,empty:c.out.length===0,renaming:a}),u.failed&&!e.skipRejectFile&&kT(e,o,u,l.text)}function OT(e,t,n){let{opts:r}=e,{inname:i,outname:a,input:o,content:s,result:c,empty:l,renaming:u}=n,d=r.backup||r.backupIfMismatch&&(c.mismatch||c.failed>0),f=t.says[+!e.reverse]===2;if(l&&(r.removeEmpty||f)){r.dryRun||PT(e,a,d);return}if(!l&&f&&(e.someFailed=!0,r.silent||e.say(`Not deleting file ${sy(a,e.ctx)} as content differs from patch
283
+ `)),!r.dryRun){if(c.failed<c.count||u)NT(e,a,s,d),u&&i!==a&&(t.rename[0]||t.rename[1])&&PT(e,i,!1);else if(d){if(!o.exists)throw new Y(`Can't reopen file ${sy(a,e.ctx)} : No such file or directory`);NT(e,AT(e,a),o.content,!1)}}}function kT(e,t,n,r){let{opts:i}=e;if(e.someFailed=!0,e.say(`${n.failed} out of ${n.count} hunk${n.count===1?``:`s`} ${e.skipRest?`ignored`:`FAILED`}`),t===null||i.rejectFile===`-`){e.say(`
284
284
  `);return}let a=i.rejectFile??t+`.rej`;if(i.dryRun){e.say(`
285
- `);return}e.say(` -- saving rejects to file ${iy(a,e.ctx)}
286
- `),kT(e,a);let o=e.rejectsMade.has(O(e.dir,a));e.rejectsMade.add(O(e.dir,a)),AT(e,a,(o?OT(e,a).content:``)+r,!1)}var DT=(e,t)=>t+e.opts.suffix;function OT(e,t){let n=k(e.dir,t,e.ctx.fs,{follow:!1}),r=!n.error&&e.ctx.fs.isLink?.(n.path)===!0,i=k(e.dir,t,e.ctx.fs);if(i.error)return{exists:!1,isDir:!1,link:r,size:0,content:``};if(e.ctx.fs.isDir(i.path))return{exists:!0,isDir:!0,link:r,size:0,content:``};let a=e.ctx.fs.readFile(i.path);return{exists:!0,isDir:!1,link:r,size:a.length,content:a}}function kT(e,t){let n=pt(e.ctx.fs,e.dir,t,!1);if(!(e.ctx.writable&&n.startsWith(`/tmp/`)))throw new T(`feature`,`read-only target`,`${t}: file system is read-only`)}function AT(e,t,n,r){let{ctx:i}=e;kT(e,t);let a=k(e.dir,t,i.fs);try{if(!a.error){i.fs.replaceWritable(e.dir,t,n,r?DT(e,t):void 0);return}r&&i.fs.openWritable(e.dir,DT(e,t)),i.fs.openWritable(e.dir,t).write(n)}catch(n){throw new Y(`Can't create file ${iy(t,e.ctx)} : ${n?.fsError??n.message}`)}}function jT(e,t,n){let{ctx:r}=e;kT(e,t);let i=OT(e,t);i.exists&&(n&&r.fs.openWritable(e.dir,DT(e,t)).write(i.content),r.fs.removeWritable(e.dir,t))}var MT={du:LS,stat:TC,realpath:eb,diff:rw,patch:bT};function NT(e,t,n){return U(t),b(n.cwd+`
287
- `)}function PT(e,t,n){let{positional:r}=U(t);if(r.length>1)return x(`cd: too many arguments`);if(!r.length&&n.vars.unsetNames.has(`HOME`))return x(`cd: HOME not set`);let i=r[0]??OS(n);if(i===`-`){if(!n.vars.has(`OLDPWD`))return x(`cd: OLDPWD not set`);i=n.vars.get(`OLDPWD`)}let a=r[0]===`-`?i+`
288
- `:``;if(i===``)return b(a);let{path:o,error:s}=N(n,`cd`,i);return s?x(`cd: ${i}: ${s}`):n.fs.isDir(o)?o===O(n.cwd,i)?(n.vars.set(`OLDPWD`,n.cwd),n.vars.set(`PWD`,o),n.cwd=o,b(a)):C(`feature`,`cd`,`symbolic link cwd`,`cd: ${i}: a working directory reached through a symbolic link is not supported (it leads to ${o})`):x(`cd: ${i}: Not a directory`)}var FT={dir:`/`,link:`@`,file:``};function IT(e,t,n){let{flags:r,positional:i}=U(t,{short:[`1`,`l`,`a`,`A`,`R`,`d`,`r`,`F`,`h`]}),a=r.has(`l`)?Hb(n,r.has(`h`)):null,o=(i.length?i:[`.`]).toSorted(j);r.has(`r`)&&o.reverse();let s=[],c=[],l=[],u=Cn(),d=r.has(`a`)||r.has(`A`),f=e=>n.fs.isDir(e)?`dir`:n.fs.isLink?.(e)?`link`:`file`,p=e=>r.has(`F`)?FT[e]:``,m=(e,t,r)=>({raw:e,abs:t,kind:r,name:r===`link`&&a?e:e+(e.endsWith(`/`)?``:p(r)),target:r===`link`?n.fs.readLink(t)+p(f(k(n.cwd,t,n.fs).path??``)):null}),h=(e,t)=>a?a.lines(e,t):e.map(e=>e.name),g=!(r.has(`l`)||r.has(`F`)||r.has(`d`));for(let e of o){let{path:t,error:i}=N(n,`ls`,e,{follow:!1}),a=i||!g||!n.fs.isLink?.(t)?t:k(n.cwd,e,n.fs).path;i?c.push(`ls: cannot access '${e}': ${i}`):r.has(`d`)||n.fs.isFile(t)||!n.fs.isDir(a)?l.push(m(e,t,f(t))):s.push({path:e,abs:a})}let _=l.length?[h(l,!1).join(`
285
+ `);return}e.say(` -- saving rejects to file ${sy(a,e.ctx)}
286
+ `),MT(e,a);let o=e.rejectsMade.has(O(e.dir,a));e.rejectsMade.add(O(e.dir,a)),NT(e,a,(o?jT(e,a).content:``)+r,!1)}var AT=(e,t)=>t+e.opts.suffix;function jT(e,t){let n=k(e.dir,t,e.ctx.fs,{follow:!1}),r=!n.error&&e.ctx.fs.isLink?.(n.path)===!0,i=k(e.dir,t,e.ctx.fs);if(i.error)return{exists:!1,isDir:!1,link:r,size:0,content:``};if(e.ctx.fs.isDir(i.path))return{exists:!0,isDir:!0,link:r,size:0,content:``};let a=e.ctx.fs.readFile(i.path);return{exists:!0,isDir:!1,link:r,size:a.length,content:a}}function MT(e,t){let n=mt(e.ctx.fs,e.dir,t,!1);if(!(e.ctx.writable&&n.startsWith(`/tmp/`)))throw new T(`feature`,`read-only target`,`${t}: file system is read-only`)}function NT(e,t,n,r){let{ctx:i}=e;MT(e,t);let a=k(e.dir,t,i.fs);try{if(!a.error){i.fs.replaceWritable(e.dir,t,n,r?AT(e,t):void 0);return}r&&i.fs.openWritable(e.dir,AT(e,t)),i.fs.openWritable(e.dir,t).write(n)}catch(n){throw new Y(`Can't create file ${sy(t,e.ctx)} : ${n?.fsError??n.message}`)}}function PT(e,t,n){let{ctx:r}=e;MT(e,t);let i=jT(e,t);i.exists&&(n&&r.fs.openWritable(e.dir,AT(e,t)).write(i.content),r.fs.removeWritable(e.dir,t))}var FT={du:BS,stat:OC,realpath:rb,diff:ow,patch:CT};function IT(e,t,n){return U(t),b(n.cwd+`
287
+ `)}function LT(e,t,n){let{positional:r}=U(t);if(r.length>1)return x(`cd: too many arguments`);if(!r.length&&n.vars.unsetNames.has(`HOME`))return x(`cd: HOME not set`);let i=r[0]??jS(n);if(i===`-`){if(!n.vars.has(`OLDPWD`))return x(`cd: OLDPWD not set`);i=n.vars.get(`OLDPWD`)}let a=r[0]===`-`?i+`
288
+ `:``;if(i===``)return b(a);let{path:o,error:s}=N(n,`cd`,i);return s?x(`cd: ${i}: ${s}`):n.fs.isDir(o)?o===O(n.cwd,i)?(n.vars.set(`OLDPWD`,n.cwd),n.vars.set(`PWD`,o),n.cwd=o,b(a)):C(`feature`,`cd`,`symbolic link cwd`,`cd: ${i}: a working directory reached through a symbolic link is not supported (it leads to ${o})`):x(`cd: ${i}: Not a directory`)}var RT={dir:`/`,link:`@`,file:``};function zT(e,t,n){let{flags:r,positional:i}=U(t,{short:[`1`,`l`,`a`,`A`,`R`,`d`,`r`,`F`,`h`]}),a=r.has(`l`)?Gb(n,r.has(`h`)):null,o=(i.length?i:[`.`]).toSorted(j);r.has(`r`)&&o.reverse();let s=[],c=[],l=[],u=wn(),d=r.has(`a`)||r.has(`A`),f=e=>n.fs.isDir(e)?`dir`:n.fs.isLink?.(e)?`link`:`file`,p=e=>r.has(`F`)?RT[e]:``,m=(e,t,r)=>({raw:e,abs:t,kind:r,name:r===`link`&&a?e:e+(e.endsWith(`/`)?``:p(r)),target:r===`link`?n.fs.readLink(t)+p(f(k(n.cwd,t,n.fs).path??``)):null}),h=(e,t)=>a?a.lines(e,t):e.map(e=>e.name),g=!(r.has(`l`)||r.has(`F`)||r.has(`d`));for(let e of o){let{path:t,error:i}=N(n,`ls`,e,{follow:!1}),a=i||!g||!n.fs.isLink?.(t)?t:k(n.cwd,e,n.fs).path;i?c.push(`ls: cannot access '${e}': ${i}`):r.has(`d`)||n.fs.isFile(t)||!n.fs.isDir(a)?l.push(m(e,t,f(t))):s.push({path:e,abs:a})}let _=l.length?[h(l,!1).join(`
289
289
  `)]:[];for(let e of s){let t=[e];for(;t.length;){let{path:e,abs:i}=t.pop(),a=n.fs.listDir(i);d||u.collect(i,[...a.dirs,...a.files,...a.links]);let s=(e,t)=>e.filter(e=>d||!e.startsWith(`.`)).map(e=>m(e,O(i,e),t)),c=[...s(a.dirs,`dir`),...s(a.files,`file`),...s(a.links,`link`)];r.has(`a`)&&c.push(m(`.`,i,`dir`),m(`..`,O(i,`..`),`dir`)),c.sort((e,t)=>j(e.raw,t.raw)),r.has(`r`)&&c.reverse();let l=h(c,!0);if((o.length>1||r.has(`R`))&&l.unshift(e+`:`),l.length&&_.push(l.join(`
290
290
  `)),r.has(`R`))for(let r of c.toReversed())r.raw===`.`||r.raw===`..`||!n.fs.isDir(r.abs)||t.push({path:e.endsWith(`/`)?e+r.raw:e+`/`+r.raw,abs:r.abs})}}return u.emit(n.notes,`ls`,`Hidden entries are included with -a.`),{stdout:_.length?_.join(`
291
291
 
292
292
  `)+`
293
293
  `:``,stderr:c.length?c.join(`
294
294
  `)+`
295
- `:``,exitCode:c.length?2:0}}function LT(e,t){let{positional:n}=U(t);if(n.length===0)return We(`basename PATH [SUFFIX]`);if(n.length>2)return x(`basename: extra operand: ${n[2]}`);let r=n[0].replace(/\/+$/u,``);return b(RT(r===``?n[0]===``?``:`/`:r.slice(r.lastIndexOf(`/`)+1),n[1])+`
296
- `)}function RT(e,t){return!t||t===e||!e.endsWith(t)?e:e.slice(0,-t.length)}function zT(e,t){let{positional:n}=U(t);return n.length===0?We(`dirname PATH`):b(n.map(e=>{let t=e.replace(/\/+$/u,``),n=t.lastIndexOf(`/`);return n<0?e.startsWith(`/`)?`/`:`.`:t.slice(0,n).replace(/\/+$/u,``)||`/`}).join(`
295
+ `:``,exitCode:c.length?2:0}}function BT(e,t){let{positional:n}=U(t);if(n.length===0)return Ge(`basename PATH [SUFFIX]`);if(n.length>2)return x(`basename: extra operand: ${n[2]}`);let r=n[0].replace(/\/+$/u,``);return b(VT(r===``?n[0]===``?``:`/`:r.slice(r.lastIndexOf(`/`)+1),n[1])+`
296
+ `)}function VT(e,t){return!t||t===e||!e.endsWith(t)?e:e.slice(0,-t.length)}function HT(e,t){let{positional:n}=U(t);return n.length===0?Ge(`dirname PATH`):b(n.map(e=>{let t=e.replace(/\/+$/u,``),n=t.lastIndexOf(`/`);return n<0?e.startsWith(`/`)?`/`:`.`:t.slice(0,n).replace(/\/+$/u,``)||`/`}).join(`
297
297
  `)+`
298
- `)}var BT={pwd:NT,cd:PT,ls:IT,find:ux,tree:Gb,basename:LT,dirname:zT,...MT};function VT(e,t,n){let{flags:r,positional:i}=U(t,{short:[`n`,`b`,`s`,`v`,`E`,`T`,`A`,`e`,`t`]}),a=e=>qT(e,r),o=WT(i,e,n,a,r.size!==0);if(o.bytes===void 0)return I(a(o.content),o);if(r.size)throw new T(`feature`,`binary file`,`cat: formatting bytes that spell no text is not supported`);return{stdout:``,stderr:o.stderr,exitCode:+!!o.failed,events:[{fd:1,bytes:o.bytes},...o.stderr?[{fd:2,text:o.stderr}]:[]]}}function HT(e,t,n){let r=Hn(`cat`,e,t,n,{read:`maybe-text`});return{parts:r.inputs.map(e=>e.content??e.bytes),stderr:r.stderr,failed:r.failed}}var UT=e=>e.every(e=>typeof e==`string`)?{content:e.join(``)}:{bytes:ct([...e.map(e=>typeof e==`string`?E(e):e),new Uint8Array])};function WT(e,t,n,r,i){let a=n.outputFds[1];if(!a?.path&&!n.outputFds[2]?.path){let r=HT(e,t,n);return{...UT(r.parts),stderr:r.stderr,failed:r.failed}}let o=[],s=``,c=t,l=``;for(let t of e.length?e:[`-`]){let e=t===`-`,u=e||t===`/dev/stdin`,d=u?n.stdinHandle?.path:k(n.cwd,t,n.fs).path,f=u?n.stdinHandle?.identity:n.fs.fileIdentity?.(d);if(l&&KT(d,f,n.outputFds[2]))throw new T(`feature`,`cat input modified by diagnostics`,`cat: reading an input after writing diagnostics to the same file is not supported`);if(KT(d,f,a)){if((e?p(n.stdinHandle.content).length-p(c).length:0)<a.position+GT(o,s,r)){l+=`cat: ${t}: input file is output file
299
- `;continue}let f=e?c:u?n.stdinOrigin:n.fs.readFile(d);if(i&&f!==``)throw new T(`feature`,`cat transforms its input file`,`cat: transforming an input file through its own output descriptor is not supported`)}let m=HT([t],c,n);o.push(...m.parts),s+=m.parts.filter(e=>typeof e==`string`).join(``),l+=m.stderr,(e||t===`/dev/stdin`&&!n.stdinFile)&&(c=``)}return{...UT(o),stderr:l,failed:l!==``}}var GT=(e,t,n)=>e.every(e=>typeof e==`string`)?p(n(t)).length:e.reduce((e,t)=>e+(typeof t==`string`?p(t).length:t.length),0);function KT(e,t,n){return!e||!n?.path?!1:t!==void 0&&n.identity!==void 0?t===n.identity:e===n.path}function qT(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`),i=t.has(`v`)||t.has(`A`)||t.has(`e`)||t.has(`t`),a=t.has(`s`)?YT(e):e,o=0;return Pn(a).map(e=>{let a=e.endsWith(`
300
- `),s=a?e.slice(0,-1):e,c=(t.has(`b`)?s!==``:t.has(`n`))?`${String(++o).padStart(6)} `:``;return i?s=[...p(s)].map(e=>JT(e,r)).join(``):(r&&(s=s.replaceAll(` `,`^I`)),n&&a&&s.endsWith(`\r`)&&(s=s.slice(0,-1)+`^M`)),c+s+(a?n?`$
298
+ `)}var UT={pwd:IT,cd:LT,ls:zT,find:px,tree:Jb,basename:BT,dirname:HT,...FT};function WT(e,t,n){let{flags:r,positional:i}=U(t,{short:[`n`,`b`,`s`,`v`,`E`,`T`,`A`,`e`,`t`]}),a=e=>XT(e,r),o=qT(i,e,n,a,r.size!==0);if(o.bytes===void 0)return Jn(a(o.content),o);if(r.size)throw new T(`feature`,`binary file`,`cat: formatting bytes that spell no text is not supported`);return{stdout:``,stderr:o.stderr,exitCode:+!!o.failed,events:[{fd:1,bytes:o.bytes},...o.stderr?[{fd:2,text:o.stderr}]:[]]}}function GT(e,t,n){let r=Un(`cat`,e,t,n,{read:`maybe-text`});return{parts:r.inputs.map(e=>e.content??e.bytes),stderr:r.stderr,failed:r.failed}}var KT=e=>e.every(e=>typeof e==`string`)?{content:e.join(``)}:{bytes:lt([...e.map(e=>typeof e==`string`?E(e):e),new Uint8Array])};function qT(e,t,n,r,i){let a=n.outputFds[1];if(!a?.path&&!n.outputFds[2]?.path){let r=GT(e,t,n);return{...KT(r.parts),stderr:r.stderr,failed:r.failed}}let o=[],s=``,c=t,l=``;for(let t of e.length?e:[`-`]){let e=t===`-`,u=e||t===`/dev/stdin`,d=u?n.stdinHandle?.path:k(n.cwd,t,n.fs).path,f=u?n.stdinHandle?.identity:n.fs.fileIdentity?.(d);if(l&&YT(d,f,n.outputFds[2]))throw new T(`feature`,`cat input modified by diagnostics`,`cat: reading an input after writing diagnostics to the same file is not supported`);if(YT(d,f,a)){if((e?p(n.stdinHandle.content).length-p(c).length:0)<a.position+JT(o,s,r)){l+=`cat: ${t}: input file is output file
299
+ `;continue}let f=e?c:u?n.stdinOrigin:n.fs.readFile(d);if(i&&f!==``)throw new T(`feature`,`cat transforms its input file`,`cat: transforming an input file through its own output descriptor is not supported`)}let m=GT([t],c,n);o.push(...m.parts),s+=m.parts.filter(e=>typeof e==`string`).join(``),l+=m.stderr,(e||t===`/dev/stdin`&&!n.stdinFile)&&(c=``)}return{...KT(o),stderr:l,failed:l!==``}}var JT=(e,t,n)=>e.every(e=>typeof e==`string`)?p(n(t)).length:e.reduce((e,t)=>e+(typeof t==`string`?p(t).length:t.length),0);function YT(e,t,n){return!e||!n?.path?!1:t!==void 0&&n.identity!==void 0?t===n.identity:e===n.path}function XT(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`),i=t.has(`v`)||t.has(`A`)||t.has(`e`)||t.has(`t`),a=t.has(`s`)?QT(e):e,o=0;return Fn(a).map(e=>{let a=e.endsWith(`
300
+ `),s=a?e.slice(0,-1):e,c=(t.has(`b`)?s!==``:t.has(`n`))?`${String(++o).padStart(6)} `:``;return i?s=[...p(s)].map(e=>ZT(e,r)).join(``):(r&&(s=s.replaceAll(` `,`^I`)),n&&a&&s.endsWith(`\r`)&&(s=s.slice(0,-1)+`^M`)),c+s+(a?n?`$
301
301
  `:`
302
- `:``)}).join(``)}function JT(e,t){return e===9?t?`^I`:` `:e>=128?`M-`+JT(e-128,!0):e<32?`^`+String.fromCodePoint(e+64):e===127?`^?`:String.fromCodePoint(e)}function YT(e){return e.replace(/(^|\n)\n+/gu,`$1
303
- `)}var XT=`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]`,ZT=1e6,QT=16777216,$T=67108864;function eE(e=`script`){throw new T(`feature`,e,XT)}function tE(e){return e.gap?C(`feature`,`sed`,e.gap,`sed: ${e.message}`):e instanceof RangeError?C(`feature`,`sed`,`regex runtime limit`,`sed: ${e.message}`):Ke(e,`sed`,`sed: ${e.message.replace(/^sed: /u,``)}`,e.exitCode)}function nE(e){let t=[],n=null;for(let r=0;r<e.length;r++){let i=e[r];if(i===`--`){t.push(...e.slice(r));break}if(i===`--in-place`||i.startsWith(`--in-place=`)){n=i===`--in-place`?``:i.slice(11);continue}if(i.startsWith(`--`)||!i.startsWith(`-`)){t.push(i),(i===`--expression`||i===`--file`)&&r+1<e.length&&t.push(e[++r]);continue}let a=i;for(let o=1;o<i.length;o++){let s=i[o];if(s===`i`){n=i.slice(o+1),a=i.slice(0,o);break}if(s===`e`||s===`f`){t.push(i),o+1===i.length&&r+1<e.length&&t.push(e[++r]),a=``;break}if(!`nErsz`.includes(s))break}a&&(a!==`-`||i===`-`)&&t.push(a)}return{tokens:t,inPlace:n}}function rE(e,t,n,r,i){if(e.files.length===0)return x(`sed: no input files`,4);let a=G(),o=new Set([...t,`s`]),s=!1;for(let t of e.files){let c=iE(t,n);if(c.error){if(K(a,n.flushOutput(c.error)),c.error.exitCode!==2)return sE(a,c.error);s=!0;continue}let l=i({...e,files:[c.path]},o),{content:u,...d}=l;if(K(a,d),l.failed||S(l))return sE(a,l);let f=aE(t,r),p;try{p=n.fs.replaceWritable(n.cwd,t,u,f)}catch(e){P(n,`sed`,e?.path,e?.fsError);let t=Ke(e,`sed`,`sed: ${e.message}`,4);return K(a,t),sE(a,t)}if(!p){let e=oE(f??t);return K(a,e),sE(a,e)}if(l.quit)break}return s&&(a.exitCode=2),a}function iE(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:x(`sed: couldn't edit ${e}: not a regular file`,4)};if(e===`/dev/stdin`||e===`/dev/stdout`||e===`/dev/stderr`)return{error:oE(e)};let n=N(t,`sed`,e);if(n.error)return{error:x(zn(`sed`,e,n.error).trimEnd(),2)};if(t.fs.isDir(n.path))return{error:x(`sed: couldn't edit ${e}: not a regular file`,4)};let r=k(t.cwd,e,t.fs,{follow:!1}).path;return!t.writable||!r.startsWith(`/tmp/`)?{error:oE(e)}:n}function aE(e,t){if(t!==``&&t!==`*`)return t.includes(`*`)?t.replaceAll(`*`,()=>e):e+t}function oE(e){return C(`feature`,`sed`,`-i`,`sed: ${e}: file system is read-only`)}function sE(e,t){let n=S(t);return n?w(e,n.kind,n.command,n.detail,n.message):e}function cE(e,t){let n=!1;return(r,i)=>{e((n?t:``)+r+(i??``)),n=i===``}}function lE(e,t){let n=new Map,r=0,i,a,o,s=()=>e.io.setReads([i,a?.identity]);function c(t,n){if(n===``)return;l(n),s();let r=e.outputFds[t];if(r?.path){r.write(n);return}if(r===`closed`){let e=Error(`write error: Bad file descriptor`);throw e.exitCode=4,e}o[t===1?`stdout`:`stderr`]+=n,o.events.push({fd:t,text:n})}function l(e){if(r+=e.length,r>$T)throw new T(`feature`,`output limit`,`sed: output limit exceeded`)}return{start(e){return o=G(),a=e,i=void 0,s(),o},record(e){i=e?.identity,s()},finish(){i=void 0,a=null,s()},stream:c,account:l,openWrite(r){if(n.has(r))return n.get(r);let i;if(r===`/dev/null`)i=()=>{};else if(r===`/dev/stdout`||r===`/dev/stderr`)i=e=>c(r===`/dev/stdout`?1:2,e);else{let t;try{t=e.writable&&e.fs.openWritable(e.cwd,r)}catch(t){throw P(e,`sed`,t?.path,t?.fsError),t.exitCode=4,t}if(!t)throw new T(`feature`,`output file`,`sed: ${r}: Read-only file system`);i=e=>{l(e),s(),t.write(e)}}let a=cE(i,t);return n.set(r,a),a}}}function uE(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 T(`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 dE(e,t,n,r,i,a){let o=e.length?e:[`-`],s={stderr:``,failed:!1},c=0,l=0,u=t,d=null;function f(){for(;d===null||d.pos===d.content.length;){if(c===o.length)return!1;d=null;let e=o[c++];e===`-`?u=uE(u,n):e===`/dev/stdin`&&n.stdinHandle&&(n.stdinOrigin=n.io.bufferReads(()=>n.fs.readIdentity(n.stdinHandle.identity)));let t=Ln(`sed`,[e],n,u);if(s.stderr+=t.stderr,s.failed||=t.failed,d=t.inputs.length?{...t.inputs[0],identity:fE(e,n),pos:0,first:!0}:null,t.stderr&&a&&a(t.stderr),t.entries.some(e=>e.kind===`dir`))return s.directory=!0,c=o.length,!1;d?.shared&&F(n,u),i&&(l=0)}return!0}function p(){if(!f())return null;let e=d.pos,t=d.content.indexOf(r,e),a=t<0?``:r,o=d.content.slice(e,t<0?d.content.length:t);d.pos=t<0?d.content.length:t+r.length,d.shared&&(u=d.content.slice(d.pos),F(n,u));let s=d.first;d.first=!1;let c;return{text:o,terminator:a,line:++l,reset:s,identity:d.identity,last:()=>c??=d.pos<d.content.length?!1:i||!f()}}return{next:p,status:s,get identity(){return d?.identity}}}function fE(e,t){return e===`-`||e===`/dev/stdin`?t.stdinHandle?.identity:t.fs.fileIdentity?.(k(t.cwd,e,t.fs).path??O(t.cwd,e))}var pE={n:`
304
- `,t:` `,r:`\r`,a:`\x07`,f:`\f`,v:`\v`};function mE(e,t=`substitute command`){let n=e.script[e.i++];if(n===void 0||n===`
305
- `)throw Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw Error(`delimiter character is not a single-byte character`);return n}function hE(e,t,n,r=`substitute command`){let i=``,a=!1;for(;e.i<e.script.length;){let o=e.script[e.i++];if(o===`
302
+ `:``)}).join(``)}function ZT(e,t){return e===9?t?`^I`:` `:e>=128?`M-`+ZT(e-128,!0):e<32?`^`+String.fromCodePoint(e+64):e===127?`^?`:String.fromCodePoint(e)}function QT(e){return e.replace(/(^|\n)\n+/gu,`$1
303
+ `)}var $T=`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]`,eE=1e6,tE=16777216,nE=67108864;function rE(e=`script`){throw new T(`feature`,e,$T)}function iE(e){return e.gap?C(`feature`,`sed`,e.gap,`sed: ${e.message}`):e instanceof RangeError?C(`feature`,`sed`,`regex runtime limit`,`sed: ${e.message}`):qe(e,`sed`,`sed: ${e.message.replace(/^sed: /u,``)}`,e.exitCode)}function aE(e){let t=[],n=null;for(let r=0;r<e.length;r++){let i=e[r];if(i===`--`){t.push(...e.slice(r));break}if(i===`--in-place`||i.startsWith(`--in-place=`)){n=i===`--in-place`?``:i.slice(11);continue}if(i.startsWith(`--`)||!i.startsWith(`-`)){t.push(i),(i===`--expression`||i===`--file`)&&r+1<e.length&&t.push(e[++r]);continue}let a=i;for(let o=1;o<i.length;o++){let s=i[o];if(s===`i`){n=i.slice(o+1),a=i.slice(0,o);break}if(s===`e`||s===`f`){t.push(i),o+1===i.length&&r+1<e.length&&t.push(e[++r]),a=``;break}if(!`nErsz`.includes(s))break}a&&(a!==`-`||i===`-`)&&t.push(a)}return{tokens:t,inPlace:n}}function oE(e,t,n,r,i){if(e.files.length===0)return x(`sed: no input files`,4);let a=G(),o=new Set([...t,`s`]),s=!1;for(let t of e.files){let c=sE(t,n);if(c.error){if(K(a,n.flushOutput(c.error)),c.error.exitCode!==2)return uE(a,c.error);s=!0;continue}let l=i({...e,files:[c.path]},o),{content:u,...d}=l;if(K(a,d),l.failed||S(l))return uE(a,l);let f=cE(t,r),p;try{p=n.fs.replaceWritable(n.cwd,t,u,f)}catch(e){P(n,`sed`,e?.path,e?.fsError);let t=qe(e,`sed`,`sed: ${e.message}`,4);return K(a,t),uE(a,t)}if(!p){let e=lE(f??t);return K(a,e),uE(a,e)}if(l.quit)break}return s&&(a.exitCode=2),a}function sE(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:x(`sed: couldn't edit ${e}: not a regular file`,4)};if(e===`/dev/stdin`||e===`/dev/stdout`||e===`/dev/stderr`)return{error:lE(e)};let n=N(t,`sed`,e);if(n.error)return{error:x(Bn(`sed`,e,n.error).trimEnd(),2)};if(t.fs.isDir(n.path))return{error:x(`sed: couldn't edit ${e}: not a regular file`,4)};let r=k(t.cwd,e,t.fs,{follow:!1}).path;return!t.writable||!r.startsWith(`/tmp/`)?{error:lE(e)}:n}function cE(e,t){if(t!==``&&t!==`*`)return t.includes(`*`)?t.replaceAll(`*`,()=>e):e+t}function lE(e){return C(`feature`,`sed`,`-i`,`sed: ${e}: file system is read-only`)}function uE(e,t){let n=S(t);return n?w(e,n.kind,n.command,n.detail,n.message):e}function dE(e,t){let n=!1;return(r,i)=>{e((n?t:``)+r+(i??``)),n=i===``}}function fE(e,t){let n=new Map,r=0,i,a,o,s=()=>e.io.setReads([i,a?.identity]);function c(t,n){if(n===``)return;l(n),s();let r=e.outputFds[t];if(r?.path){r.write(n);return}if(r===`closed`){let e=Error(`write error: Bad file descriptor`);throw e.exitCode=4,e}o[t===1?`stdout`:`stderr`]+=n,o.events.push({fd:t,text:n})}function l(e){if(r+=e.length,r>nE)throw new T(`feature`,`output limit`,`sed: output limit exceeded`)}return{start(e){return o=G(),a=e,i=void 0,s(),o},record(e){i=e?.identity,s()},finish(){i=void 0,a=null,s()},stream:c,account:l,openWrite(r){if(n.has(r))return n.get(r);let i;if(r===`/dev/null`)i=()=>{};else if(r===`/dev/stdout`||r===`/dev/stderr`)i=e=>c(r===`/dev/stdout`?1:2,e);else{let t;try{t=e.writable&&e.fs.openWritable(e.cwd,r)}catch(t){throw P(e,`sed`,t?.path,t?.fsError),t.exitCode=4,t}if(!t)throw new T(`feature`,`output file`,`sed: ${r}: Read-only file system`);i=e=>{l(e),s(),t.write(e)}}let a=dE(i,t);return n.set(r,a),a}}}function pE(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 T(`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 mE(e,t,n,r,i,a){let o=e.length?e:[`-`],s={stderr:``,failed:!1},c=0,l=0,u=t,d=null;function f(){for(;d===null||d.pos===d.content.length;){if(c===o.length)return!1;d=null;let e=o[c++];e===`-`?u=pE(u,n):e===`/dev/stdin`&&n.stdinHandle&&(n.stdinOrigin=n.io.bufferReads(()=>n.fs.readIdentity(n.stdinHandle.identity)));let t=Rn(`sed`,[e],n,u);if(s.stderr+=t.stderr,s.failed||=t.failed,d=t.inputs.length?{...t.inputs[0],identity:hE(e,n),pos:0,first:!0}:null,t.stderr&&a&&a(t.stderr),t.entries.some(e=>e.kind===`dir`))return s.directory=!0,c=o.length,!1;d?.shared&&F(n,u),i&&(l=0)}return!0}function p(){if(!f())return null;let e=d.pos,t=d.content.indexOf(r,e),a=t<0?``:r,o=d.content.slice(e,t<0?d.content.length:t);d.pos=t<0?d.content.length:t+r.length,d.shared&&(u=d.content.slice(d.pos),F(n,u));let s=d.first;d.first=!1;let c;return{text:o,terminator:a,line:++l,reset:s,identity:d.identity,last:()=>c??=d.pos<d.content.length?!1:i||!f()}}return{next:p,status:s,get identity(){return d?.identity}}}function hE(e,t){return e===`-`||e===`/dev/stdin`?t.stdinHandle?.identity:t.fs.fileIdentity?.(k(t.cwd,e,t.fs).path??O(t.cwd,e))}var gE={n:`
304
+ `,t:` `,r:`\r`,a:`\x07`,f:`\f`,v:`\v`};function _E(e,t=`substitute command`){let n=e.script[e.i++];if(n===void 0||n===`
305
+ `)throw Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw Error(`delimiter character is not a single-byte character`);return n}function vE(e,t,n,r=`substitute command`){let i=``,a=!1;for(;e.i<e.script.length;){let o=e.script[e.i++];if(o===`
306
306
  `)throw Error(`unterminated ${r}`);if(o===t&&!a)return i;if(o===`\\`){let s=e.script[e.i++];if(s===void 0||s===`
307
307
  `&&a)throw Error(`unterminated ${r}`);if(s===`
308
308
  `){i+=s;continue}i+=!a&&s===t&&(n||s!==`&`)?s:o+s;continue}if(n&&o===`[`&&!a){a=!0,i+=o,e.script[e.i]===`^`&&(i+=e.script[e.i++]),e.script[e.i]===`]`&&(i+=e.script[e.i++]);continue}if(n&&a&&o===`[`&&/[:.=]/u.test(e.script[e.i]??``)){let t=e.script.indexOf(e.script[e.i]+`]`,e.i+1);if(t<0)throw Error(`unterminated character class`);if(e.script.slice(e.i,t).includes(`
309
- `))throw Error(`unterminated ${r}`);i+=o+e.script.slice(e.i,t+2),e.i=t+2;continue}n&&o===`]`&&(a=!1),i+=o}throw Error(`unterminated ${r}`)}function gE(e){let t=mE(e),n=hE(e,t,!0),r=SE(hE(e,t,!1)),i=_E(e);if(n===``&&(i.ignoreCase||i.multiline))throw Error(`cannot specify modifiers on empty regexp`);i.multiline&&vE(i.multiline);let a=bE(n,e.extended,!1,i.ignoreCase,e.locale);for(let e of r)if(typeof e==`number`&&e>a.re?.groupCount)throw Error(`invalid reference \\${e} in replacement`);return{...a,parts:r,...i}}function _E(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 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 Error(`number option to substitute command may not be zero`);Number.isSafeInteger(t.nth)||eE(`substitution occurrence limit`)}else if(n===`g`||n===`p`){let e=n===`g`?`global`:`print`;if(t[e])throw Error(`multiple substitution flags`);t[e]=!0}else if(n===`w`){Object.assign(t,yE(e));break}else if(n===`i`||n===`I`)t.ignoreCase=!0;else if(n===`m`||n===`M`)t.multiline=n;else if(n===`e`)vE(n);else throw Error(`unknown option to substitute command: '${n}'`)}}return t}function vE(e){let t=e===`e`?`command evaluation`:`multiline regex matching`;throw new T(`feature`,`substitution flag ${e}`,`sed: substitution flag '${e}' (${t}) is not supported`)}function yE(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 Error(`missing filename in r/R/w/W commands`);return e.openWrite?{writer:e.openWrite(n)}:{writeName:n}}function bE(e,t,n=!1,r=!1,i=M){if(!e){if(r)throw Error(`cannot specify modifiers on empty regexp`);return{re:null}}let a=vn(i);zg(e,t,a.multibyte);let o=e.replace(/\\(.)/gu,(e,t)=>(t===`o`&&eE(`regex escape`),Object.hasOwn(pE,t)?pE[t]:e)),s=r?Bh(o,a):o,c=t?{source:bg(s,a)}:Fh(s,a);if(c.error)throw Error(c.error);xE(c.source,t),Lh(c.source);for(let[,e]of c.source.matchAll(/\\(.)/gu))/[1-9]/u.test(e)&&eE(`regex backreferences`);return{re:new kh(Cg(c.source,`extent`,a),!1,null,a),noSub:n,locale:i,ignoreCase:r,pattern:o}}function xE(e,t){let n=!1,r=0,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(s===`\\`){let t=e[++o];n||(i=!"bB<>`'".includes(t),a=!1);continue}if(n){s===`]`&&(n=!1,i=!0,a=!1);continue}if(s===`[`){n=!0;continue}if(s===`(`){r++,i=!1,a=!1;continue}if(s===`)`){if(--r<0)throw Error(`unmatched )`)}else if(s===`|`||s===`^`||s===`$`){i=!1,a=!1;continue}else if(`*+?{`.includes(s)){let n=s===`{`?/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u.exec(e.slice(o)):null;if(s===`{`&&n===null)throw Error(`invalid repetition count`);if(!i||!t&&a&&(s===`*`||s===`{`))throw Error(`Invalid preceding regular expression`);n&&(o+=n[0].length-1),a=!0;continue}i=!0,a=!1}if(r>0)throw Error(`unmatched (`)}function SE(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 i=e[++n];/[0-9]/u.test(i)?t.push(Number(i)):i===`\\`||i===`&`?t.push(i):Object.hasOwn(pE,i)?t.push(pE[i]):eE(`replacement escape`)}return t}function CE(e,t){if(/[\u0080-\u{10FFFF}]/u.test(e+t.re.src)){if(t.locale!==M)throw new T(`feature`,`locale`,`matching non-ASCII text in the ${t.locale} locale is not supported`);t.ignoreCase&&ln.test(e+t.pattern)&&eE(`case folding of Cyrillic Extended-C letters`)}}function wE(e,t,n=null){let r=e.re===null?t.last:e;if(!r)throw Error(`no previous regular expression`);if(t.last=r,n!==null&&r.noSub){if(n>r.re.groupCount)throw Error(`invalid reference \\${n} in replacement`);r.noSub=!1}return r}function TE(e,t,n){let r=wE(t,n,t.parts.reduce((e,t)=>typeof t==`number`?Math.max(e,t):e,0));CE(e,r);let i=t.parts.some(e=>typeof e==`number`&&e>0&&e<=r.re.groupCount),a=0;return{out:Ph(e,t.nth&&!t.global?{search:(e,t)=>a?null:r.re.search(e,t)}:r.re,(n,o,s)=>{if(t.nth&&s<t.nth)return null;a++;let c=i?r.re.groups(e,n,o):null;return t.parts.map(t=>typeof t==`string`?t:t===0?e.slice(n,o):c?.[t]?.text??``).join(``)},t.global||t.nth?`global`:`first`).out,count:a}}var EE={a:7,f:12,n:10,r:13,t:9,v:11,"\n":10},DE={d:10,o:8,x:16};function OE(e,t){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;if(e.i===e.script.length)throw Error(`expected \\ after 'a', 'c' or 'i'`);if(t.text=null,e.textState.pending={command:t,raw:``},e.script[e.i]===`\\`){let t=e.script[++e.i];if(t===void 0)return;e.i++,t!==`
311
- `&&(e.textState.pending.raw=t)}kE(e)}function kE(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 Error(`unterminated ${r}`);i+=o+e.script.slice(e.i,t+2),e.i=t+2;continue}n&&o===`]`&&(a=!1),i+=o}throw Error(`unterminated ${r}`)}function yE(e){let t=_E(e),n=vE(e,t,!0),r=TE(vE(e,t,!1)),i=bE(e);if(n===``&&(i.ignoreCase||i.multiline))throw Error(`cannot specify modifiers on empty regexp`);i.multiline&&xE(i.multiline);let a=CE(n,e.extended,!1,i.ignoreCase,e.locale);for(let e of r)if(typeof e==`number`&&e>a.re?.groupCount)throw Error(`invalid reference \\${e} in replacement`);return{...a,parts:r,...i}}function bE(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 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 Error(`number option to substitute command may not be zero`);Number.isSafeInteger(t.nth)||rE(`substitution occurrence limit`)}else if(n===`g`||n===`p`){let e=n===`g`?`global`:`print`;if(t[e])throw Error(`multiple substitution flags`);t[e]=!0}else if(n===`w`){Object.assign(t,SE(e));break}else if(n===`i`||n===`I`)t.ignoreCase=!0;else if(n===`m`||n===`M`)t.multiline=n;else if(n===`e`)xE(n);else throw Error(`unknown option to substitute command: '${n}'`)}}return t}function xE(e){let t=e===`e`?`command evaluation`:`multiline regex matching`;throw new T(`feature`,`substitution flag ${e}`,`sed: substitution flag '${e}' (${t}) is not supported`)}function SE(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 Error(`missing filename in r/R/w/W commands`);return e.openWrite?{writer:e.openWrite(n)}:{writeName:n}}function CE(e,t,n=!1,r=!1,i=M){if(!e){if(r)throw Error(`cannot specify modifiers on empty regexp`);return{re:null}}let a=yn(i);Hg(e,t,a.multibyte);let o=e.replace(/\\(.)/gu,(e,t)=>(t===`o`&&rE(`regex escape`),Object.hasOwn(gE,t)?gE[t]:e)),s=r?Uh(o,a):o,c=t?{source:Cg(s,a)}:Rh(s,a);if(c.error)throw Error(c.error);wE(c.source,t),Bh(c.source);for(let[,e]of c.source.matchAll(/\\(.)/gu))/[1-9]/u.test(e)&&rE(`regex backreferences`);return{re:new Mh(Eg(c.source,`extent`,a),!1,null,a),noSub:n,locale:i,ignoreCase:r,pattern:o}}function wE(e,t){let n=!1,r=0,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(s===`\\`){let t=e[++o];n||(i=!"bB<>`'".includes(t),a=!1);continue}if(n){s===`]`&&(n=!1,i=!0,a=!1);continue}if(s===`[`){n=!0;continue}if(s===`(`){r++,i=!1,a=!1;continue}if(s===`)`){if(--r<0)throw Error(`unmatched )`)}else if(s===`|`||s===`^`||s===`$`){i=!1,a=!1;continue}else if(`*+?{`.includes(s)){let n=s===`{`?/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u.exec(e.slice(o)):null;if(s===`{`&&n===null)throw Error(`invalid repetition count`);if(!i||!t&&a&&(s===`*`||s===`{`))throw Error(`Invalid preceding regular expression`);n&&(o+=n[0].length-1),a=!0;continue}i=!0,a=!1}if(r>0)throw Error(`unmatched (`)}function TE(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 i=e[++n];/[0-9]/u.test(i)?t.push(Number(i)):i===`\\`||i===`&`?t.push(i):Object.hasOwn(gE,i)?t.push(gE[i]):rE(`replacement escape`)}return t}function EE(e,t){if(/[\u0080-\u{10FFFF}]/u.test(e+t.re.src)){if(t.locale!==M)throw new T(`feature`,`locale`,`matching non-ASCII text in the ${t.locale} locale is not supported`);t.ignoreCase&&un.test(e+t.pattern)&&rE(`case folding of Cyrillic Extended-C letters`)}}function DE(e,t,n=null){let r=e.re===null?t.last:e;if(!r)throw Error(`no previous regular expression`);if(t.last=r,n!==null&&r.noSub){if(n>r.re.groupCount)throw Error(`invalid reference \\${n} in replacement`);r.noSub=!1}return r}function OE(e,t,n){let r=DE(t,n,t.parts.reduce((e,t)=>typeof t==`number`?Math.max(e,t):e,0));EE(e,r);let i=t.parts.some(e=>typeof e==`number`&&e>0&&e<=r.re.groupCount),a=0;return{out:Lh(e,t.nth&&!t.global?{search:(e,t)=>a?null:r.re.search(e,t)}:r.re,(n,o,s)=>{if(t.nth&&s<t.nth)return null;a++;let c=i?r.re.groups(e,n,o):null;return t.parts.map(t=>typeof t==`string`?t:t===0?e.slice(n,o):c?.[t]?.text??``).join(``)},t.global||t.nth?`global`:`first`).out,count:a}}var kE={a:7,f:12,n:10,r:13,t:9,v:11,"\n":10},AE={d:10,o:8,x:16};function jE(e,t){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;if(e.i===e.script.length)throw Error(`expected \\ after 'a', 'c' or 'i'`);if(t.text=null,e.textState.pending={command:t,raw:``},e.script[e.i]===`\\`){let t=e.script[++e.i];if(t===void 0)return;e.i++,t!==`
311
+ `&&(e.textState.pending.raw=t)}ME(e)}function ME(e){let t=e.textState.pending;if(!t)return;let n=t.raw;for(;e.i<e.script.length&&e.script[e.i]!==`
312
312
  `;){let r=e.script[e.i++];if(r===`\\`){if(e.i===e.script.length){t.raw=n+`
313
- `;return}n+=r+e.script[e.i++]}else n+=r}t.command.text=jE(n+`
314
- `),e.textState.pending=null}function AE(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function jE(e){return D(ME(e))}function ME(e){let t=p(e),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r!==92||e+1===t.length){n.push(r);continue}let i=String.fromCodePoint(t[++e]);if(Object.hasOwn(EE,i)){n.push(EE[i]);continue}if(Object.hasOwn(DE,i)){let r=DE[i],a=r===16?2:3,o=0,s=0;for(;o<a&&e+1<t.length;){let n=t[e+1],i=n>=48&&n<=57?n-48:(n|32)>=97&&(n|32)<=102?(n|32)-87:-1;if(i<0||i>=r)break;s=s*r+i,o++,e++}n.push(o?s&255:i.codePointAt(0))}else if(i===`c`){if(++e===t.length)continue;let r=t[e];if(r===92&&t[++e]!==92)throw Error(`recursive escaping after \\c not allowed`);n.push((r>=97&&r<=122?r-32:r)^64)}else n.push(i.codePointAt(0))}return Uint8Array.from(n)}function NE(e){let t=mE(e,`'y' command`),n=ME(PE(e,t)),r=ME(PE(e,t)),i=e.byteLocale?n:[...D(n)],a=e.byteLocale?r:[...D(r)];if(i.length!==a.length)throw Error(`'y' command strings have different lengths`);let o=e.byteLocale?Uint8Array.from({length:256},(e,t)=>t):new Map;for(let t=0;t<i.length;t++)e.byteLocale?o[i[t]]=a[t]:o.has(i[t])||o.set(i[t],a[t]);return{translation:o,byteLocale:e.byteLocale}}function PE(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=PE(n+`
314
+ `),e.textState.pending=null}function NE(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function PE(e){return D(FE(e))}function FE(e){let t=p(e),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r!==92||e+1===t.length){n.push(r);continue}let i=String.fromCodePoint(t[++e]);if(Object.hasOwn(kE,i)){n.push(kE[i]);continue}if(Object.hasOwn(AE,i)){let r=AE[i],a=r===16?2:3,o=0,s=0;for(;o<a&&e+1<t.length;){let n=t[e+1],i=n>=48&&n<=57?n-48:(n|32)>=97&&(n|32)<=102?(n|32)-87:-1;if(i<0||i>=r)break;s=s*r+i,o++,e++}n.push(o?s&255:i.codePointAt(0))}else if(i===`c`){if(++e===t.length)continue;let r=t[e];if(r===92&&t[++e]!==92)throw Error(`recursive escaping after \\c not allowed`);n.push((r>=97&&r<=122?r-32:r)^64)}else n.push(i.codePointAt(0))}return Uint8Array.from(n)}function IE(e){let t=_E(e,`'y' command`),n=FE(LE(e,t)),r=FE(LE(e,t)),i=e.byteLocale?n:[...D(n)],a=e.byteLocale?r:[...D(r)];if(i.length!==a.length)throw Error(`'y' command strings have different lengths`);let o=e.byteLocale?Uint8Array.from({length:256},(e,t)=>t):new Map;for(let t=0;t<i.length;t++)e.byteLocale?o[i[t]]=a[t]:o.has(i[t])||o.set(i[t],a[t]);return{translation:o,byteLocale:e.byteLocale}}function LE(e,t){let n=``;for(;e.i<e.script.length;){let r=e.script[e.i++];if(r===`
315
315
  `)break;if(r===t)return n;if(r!==`\\`){n+=r;continue}let i=e.script[e.i++];if(i===void 0)break;n+=i===t||i===`
316
- `?i:r+i}throw Error(`unterminated 'y' command`)}function FE(e,t){if(t.byteLocale)return D(p(e).map(e=>t.translation[e]));let n=``;for(let r of e)n+=t.translation.get(r)??r;return n}function IE(e,t=!1,n=M,r=null){let i={script:e,i:0,extended:t,locale:n,byteLocale:$t(n),textState:r??{},openWrite:r?.openWrite},a=[];for(kE(i);i.i<e.length;){if(/[;\n\r\f\v \t]/u.test(e[i.i])){i.i++;continue}e[i.i]===`#`&&eE(`comments`);let t=BE(i),n=null;if(t&&e[i.i]===`,`&&(i.i++,n=BE(i,!0),n===null))throw Error(`missing second address`);e[i.i]===`~`&&eE(`step address`);let r=t?.type===`line`&&t.value===0;if(r&&n?.type!==`regex`)throw Error(`line numbers must be >= 1`);let o=!1;if(e[i.i]===`!`){for(o=!0,i.i++;/[ \t]/u.test(e[i.i]??``);)i.i++;if(e[i.i]===`!`)throw Error(`multiple '!'s`)}let s=e[i.i++],c={kind:s,start:t,end:n,active:r,negated:o};if(s&&`pPnNdD=gGhHx`.includes(s))a.push(c);else if(s===`w`){a.push({...c,...yE(i)});continue}else if(s===`:`||s===`b`||s===`t`||s===`T`){a.push({...c,label:RE(i,c)});continue}else if(s===`s`)a.push({...c,...gE(i)});else if(s===`a`||s===`i`||s===`c`)OE(i,c),a.push(c);else if(s===`y`)a.push({...c,...NE(i)});else if(s===`q`){if(n!==null)throw Error(`command only uses one address`);let t=/^[ \t]*(\d*)/u.exec(e.slice(i.i));i.i+=t[0].length;let r=BigInt.asIntN(32,BigInt(t[1]||`0`));a.push({...c,exitCode:r===-1n?0:Number(BigInt.asUintN(8,r))})}else if(s===`{`){i.textState.blockDepth=(i.textState.blockDepth??0)+1,a.push(c);continue}else if(s===`}`){if(!i.textState.blockDepth)throw Error(`unexpected '}'`);if(t!==null)throw Error(`'}' doesn't want any addresses`);i.textState.blockDepth--,a.push(c)}else{if(s===void 0)throw Error(`missing command`);if(`QlLFzrRWev`.includes(s))eE();else throw Error(`unknown command: '${s}'`)}for(;/[ \t]/u.test(e[i.i]??``);)i.i++;if(e[i.i]===`#`&&eE(`comments`),i.i<e.length&&!/[;\n}]/u.test(e[i.i]))throw Error(`extra characters after command`)}return r===null&&AE(i.textState),a}function LE(e,t){let n=[];for(let t=0;t<e.length;t++){let r=e[t];if(r.kind===`{`&&n.push(r),r.kind===`}`){if(n.length===0)throw Error(`unexpected '}'`);n.pop().jump=t}}if(n.length)throw Error(`unmatched '{'`);return AE(t),zE(e),e}function RE(e,t){if(t.kind===`:`&&t.start!==null)throw 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 Error(`':' lacks a label`);return r}function zE(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 i=r.label===``?e.length:t.get(r.label);if(i===void 0)throw Object.assign(Error(`can't find label for jump to \`${r.label}'`),{exitCode:4});r.jump=i}}function BE(e,t=!1){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;e.script[e.i]===`~`&&eE(`step address`);let n=/^(\d+|\+[ \t]*\d+)/u.exec(e.script.slice(e.i)),r=null;if(n){let i=n[0][0]===`+`;if(i&&!t)throw Error(`relative address requires a range`);let a=Number(n[0].replace(/[ \t]/gu,``));Number.isSafeInteger(a)||eE(`address limit`),e.i+=n[0].length,r={type:i?`offset`:`line`,value:a}}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 t=hE(e,mE(e,`address regex`),!0,`address regex`),n=!1;for(;;){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;let r=e.script[e.i];if(r!==`I`&&r!==`M`)break;if(t===``)throw Error(`cannot specify modifiers on empty regexp`);r===`M`&&eE(`address regex flags`),n=!0,e.i++}r={type:`regex`,...bE(t,e.extended,!0,n,e.locale)}}for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;return r}function VE(e,t,n,r,i){let{start:a,end:o}=e;if(a===null)return!0;if(o===null)return HE(a,t,n,r,i);if(!e.active){if(a.type===`line`){if(e.closed||n<a.value)return!1}else if(!HE(a,t,n,r,i))return!1;if(e.active=!0,o.type===`regex`)return!0;if(o.type===`offset`&&(e.until=n+o.value),o.type===`line`)return e.active=n<o.value,e.closed=!e.active,n<=o.value||HE(a,t,n,r,i)}return o.type===`line`?(e.active=n<o.value,e.closed=!e.active,n<=o.value):((o.type===`offset`?n>=e.until:HE(o,t,n,r,i))&&(e.active=!1,e.closed=!0),!0)}function HE(e,t,n,r,i){if(e.type===`line`)return n===e.value;if(e.type===`last`)return typeof r==`function`?r():r;let a=wE(e,i);return CE(t,a),a.re.search(t)!==null}function UE(e,t,n,r=!1){let{output:i,delimiter:a}=e,o=t.has(`n`)||t.has(`quiet`)||t.has(`silent`),s=t.has(`s`)||t.has(`separate`),c=dE(e.files,e.stdin,n,a,s,e=>i.stream(2,e)),l=i.start(c),u=[],d=cE(r?e=>{i.account(e),u.push(e)}:e=>i.stream(1,e),a),f={delimiter:a,quiet:o,separate:s,hold:e.hold,regexState:e.regexState,budget:e.budget,emit:d,input:c,output:i};try{let t=WE(e.commands,f);l.quit=t!==null,l.exitCode=c.status.failed?c.status.directory?4:2:t??0,l.failed=c.status.failed}catch(e){let t=tE(e);K(l,t);let n=S(t);n&&w(l,n.kind,n.command,n.detail,n.message),l.failed=!0}finally{i.finish()}return r&&(l.content=u.join(``)),l}function WE(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 t of e)t.active=t.start?.type===`line`&&t.start.value===0,t.closed=!1;n=!1}t.output.record(r);let i={...r,...t,append:[],exitCode:null,replaced:!1},a=GE(e,i);if(!t.quiet&&!a&&t.emit(i.text,i.terminator),i.exitCode!==null&&t.emit(``),YE(i),i.exitCode!==null)return i.exitCode;t.output.record(null)}return null}function GE(e,t){for(let n=0;n<e.length;n++){if(++t.budget.steps>ZT)throw new T(`feature`,`execution limit`,`sed: execution limit reached after ${ZT} commands (infinite loop?)`);let r=e[n];if(r.kind===`}`||r.kind===`:`)continue;if(VE(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 e=i===`b`||(i===`t`?t.replaced:!t.replaced);i!==`b`&&(t.replaced=!1),e&&(n=r.jump-1);continue}if(i===`q`){t.exitCode=r.exitCode;break}if(i===`d`)return!0;if(i===`D`){let e=t.text.indexOf(t.delimiter);if(e<0)return!0;t.text=t.text.slice(e+t.delimiter.length),n=-1;continue}if(i===`n`||i===`N`){if(!JE(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(KE(r,t),t.text.length>QT)throw new T(`feature`,`pattern space limit`,`sed: pattern space limit exceeded`)}}return!1}function KE(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 e=t.text.indexOf(t.delimiter);t.emit(e<0?t.text:t.text.slice(0,e),e<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))qE(n,t);else if(n===`y`)t.text=FE(t.text,e);else{let n=TE(t.text,e,t.regexState);if(t.text=n.out,!n.count)return;t.replaced=!0,e.print&&t.emit(t.text,t.terminator),e.writer&&e.writer(t.text,t.terminator)}}function qE(e,t){let n=t.hold;if(e===`x`){let{text:e,terminator:r}=t;Object.assign(t,n),Object.assign(n,{text:e,terminator:r})}else{let r=e===`h`||e===`H`?t:n,i=r===n?t:n;i.text=e===`G`||e===`H`?i.text+t.delimiter+r.text:r.text,i.terminator=r.terminator}if(n.text.length>QT)throw new T(`feature`,`hold space limit`,`sed: hold space limit exceeded`)}function JE(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;YE(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>QT)throw new T(`feature`,`pattern space limit`,`sed: pattern space limit exceeded`);return Object.assign(e,n,{text:r,replaced:!1}),e.output.record(n),!0}function YE(e){if(e.append.length!==0){e.emit(``);for(let t of e.append)e.emit(t??``);e.append.length=0}}function XE(e,t,n){try{let{tokens:r,inPlace:i}=nE(t),a=U(r,{short:[`n`,`E`,`r`,`s`,`z`],long:[`regexp-extended`,`quiet`,`silent`,`separate`,`null-data`,`zero-terminated`],repeatable:[`e`,`expression`,`f`,`file`]}),o=a.flags.has(`z`)||a.flags.has(`null-data`)||a.flags.has(`zero-terminated`)?`\0`:`
317
- `,s=lE(n,o),c=ZE(a,e,n,s.openWrite);return c===null?x(XT):c.error?c.error:(Object.assign(c,{output:s,delimiter:o,hold:{text:``,terminator:o},regexState:{last:null},budget:{steps:0}}),c.stdin=uE(c.stdin,n),i===null?UE(c,a.flags,n):rE(c,a.flags,n,i,(e,t)=>UE(e,t,n,!0)))}catch(e){return tE(e)}}function ZE({order:e,positional:t},n,r,i){let a=[],o={openWrite:i},s=!1,c=!1;for(let{name:t,value:i}of e){if((t===`E`||t===`r`||t===`regexp-extended`)&&(s=!0),![`e`,`expression`,`f`,`file`].includes(t))continue;c=!0;let e=i;if(t===`f`||t===`file`){n=uE(n,r);let t=n,a=r.io.bufferReads(()=>Ln(`sed`,[i],r,t));if(a.failed)return{error:x(a.stderr,4)};e=a.inputs[0].content,a.inputs[0].shared&&(n=``)}for(let t of IE(e,s,r.locale,o))a.push(t)}return c?{commands:LE(a,o),files:t,stdin:n}:t.length===0?null:{commands:LE(IE(t[0],s,r.locale,o),o),files:t.slice(1),stdin:n}}var QE=new Set([`-b`,`-c`,`-g`,`-k`,`-p`,`-r`,`-t`,`-u`,`-v`,`-w`,`-x`,`-G`,`-N`,`-O`,`-R`,`-S`,`-o`]),$E=new Set([`-nt`,`-ot`,`-ef`,`<`,`>`]),eD={__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},tD=String(yn).length,nD=new Set([`/dev/stdin`,`/dev/stdout`,`/dev/stderr`]);function rD(e,t,n){return aD(`test`,t,n)}function iD(e,t,n){return t.at(-1)===`]`?aD(`[`,t.slice(0,-1),n):x("[: missing `]'",2)}function aD(e,t,n){try{return{...b(),exitCode:+!oD(t,n)}}catch(t){return Ke(t,e,`${e}: ${t.message}`,2)}}function oD(e,t){let[n,r,i]=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 cD(n,r,t);throw QE.has(n)&&dD(n),Error(`${n}: unary operator expected`)}if(e.length===3){if(r===`=`||r===`==`)return n===i;if(r===`!=`)return n!==i;if(Object.hasOwn(eD,r))return eD[r](sD(n),sD(i));$E.has(r)&&dD(r),(r===`-a`||r===`-o`)&&dD(`compound expressions`)}if(e.length<=4){if(n===`!`)return!oD(e.slice(1),t);if(n===`(`&&e.at(-1)===`)`)return oD(e.slice(1,-1),t)}throw e.some(e=>[`-a`,`-o`,`!`,`(`,`)`].includes(e))&&dD(`compound expressions`),Error(e.length>3?`too many arguments`:`${r}: binary operator expected`)}function sD(e){let t=/^[ \t\n\r\f\v]*([+-]?)(\d+)[ \t]*$/u.exec(e);if(t&&t[0].length===e.length){let e=t[2].replace(/^0+/u,``)||`0`;if(e.length<=tD){let n=BigInt(t[1]+e);if(n>=bn&&n<=yn)return n}}throw Error(`${e}: integer expression expected`)}function cD(e,t,n){let r={isDir:e=>e===`/dev`||e===`/dev/fd`||n.fs.isDir(e),isFile:e=>e===`/dev/null`||uD(e)||n.fs.isFile(e),isLink:e=>n.fs.isLink?.(e)===!0,readLink:e=>n.fs.readLink?.(e)},i=e===`-h`||e===`-L`,{path:a,error:o}=k(n.cwd,t,r,{follow:!i});return!o&&(uD(a)&&dD(`stream device metadata`),i?r.isLink(a):e===`-e`||e===`-a`?!0:e===`-d`?r.isDir(a):e===`-s`?r.isDir(a)||a!==`/dev/null`&&lD(n,a)>0:a!==`/dev/null`&&n.fs.isFile(a))}var lD=(e,t)=>e.fs.fileSize?.(t)??E(e.fs.readFile(t)).length;function uD(e){return nD.has(e)||/^\/dev\/fd\/\d+$/u.test(e)}function dD(e){throw new T(`feature`,e,`${e} is not supported`)}function fD(e){let t=e.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/gu,``),n=/^[+-]?\d+$/u.test(t)?BigInt(t):null;return{arg:t,n:n!==null&&n>=bn&&n<=yn?n:null}}var pD=e=>({...e,halt:!0});function mD(e,t,n){let r=t[0]===`--`?t.slice(1):t;if(r.length===0)return pD({...b(),exitCode:n.lastExit});let{arg:i,n:a}=fD(r[0]);return a===null?pD(x(`exit: ${i}: numeric argument required`,2)):r.length>1?pD(x(`exit: too many arguments`)):pD({...b(),exitCode:Number((a%256n+256n)%256n)})}function hD(e){return(t,n,r)=>{let i=n[0]===`--`?n.slice(1):n;if(i.length>1)return pD(x(`${e}: too many arguments`));let{arg:a,n:o}=fD(i[0]??`1`);return o===null?pD(x(`${e}: ${a}: numeric argument required`,128)):o<=0?{...x(`${e}: ${a}: loop count out of range`),control:r.loopDepth?{type:`break`,levels:r.loopDepth}:void 0}:r.loopDepth===0?x(`${e}: only meaningful in a \`for\`, \`while\` or \`until\` loop`,0):{...b(),control:{type:e,levels:Number(o>BigInt(r.loopDepth)?BigInt(r.loopDepth):o)}}}}function gD(e,t,n){let r=t[0]===`--`,i=r?t.slice(1):t;if(i.length===0||!r&&i[0]===`-p`)return C(`option`,`export`,`-p`,`export: listing the environment is not supported (there is none)`);let a=``;for(let e of i){let t=e.indexOf(`=`),i=t>0&&e[t-1]===`+`,o=t===-1?e:e.slice(0,i?t-1:t);if(!r&&e.startsWith(`-`))return C(`option`,`export`,e,`export: option \`${e}\` is not supported`);if(!mi.test(o)){a+=`export: \`${o}': not a valid identifier
318
- `;continue}t===-1?n.vars.has(o)&&n.vars.set(o,n.vars.get(o)):n.vars.set(o,(i?Lx(o,n):``)+e.slice(t+1))}return{stdout:``,stderr:a,exitCode:+!!a}}function _D(e,t,n){let r=+(t[0]===`-v`),i=t[r]===`--`;i&&r++;let a=t.slice(r);for(let e of a){if(!i&&e.startsWith(`-`))return C(`option`,`unset`,e,`unset: option \`${e}\` is not supported`);if(e.includes(`[`))return C(`feature`,`unset`,`array subscript`,`unset: array subscripts are not supported`);if(e===`LANG`)return C(`feature`,`unset`,`LANG`,`unset: LANG: ${Jt}`);n.vars.delete(e)}return b()}function vD(e,t,n){let r=null;for(let e=0;e<t.length;e++){let n=t[e];if(n===`-e`||n===`+e`)r=n===`-e`;else if((n===`-o`||n===`+o`)&&t[e+1]===`errexit`)r=n===`-o`,e++;else return yD()}return r===null?yD():(n.errexit=r,b())}var yD=()=>C(`feature`,`set`,`set`,"set: `set` is supported only as `set -e` or `set +e`",127),bD={exit:mD,break:hD(`break`),continue:hD(`continue`),export:gD,set:vD,unset:_D},xD=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 SD(e,t){let n=0,r=!0,i=!1;for(;n<t.length&&/^-[neE]+$/u.test(t[n]);n++)for(let e of t[n].slice(1))e===`n`?r=!1:i=e===`e`;let a=t.slice(n).join(` `);if(i){let e=CD(a);a=e.text,e.stop&&(r=!1)}return b(r?a+`
319
- `:a)}function CD(e){let t={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92},n=[],r=e=>{for(let t of p(e))n.push(t)},i=e=>({text:D(Uint8Array.from(n)),stop:e});for(let a=0;a<e.length;a++){if(e[a]!==`\\`||a+1>=e.length){let t=e.indexOf(`\\`,a+1),n=t<0?e.length:t;r(e.slice(a,n)),a=n-1;continue}let o=e[++a];if(o===`c`)return i(!0);if(o in t){n.push(t[o]);continue}if(o===`0`){let t=``;for(;t.length<3&&/[0-7]/u.test(e[a+1]??``);)t+=e[++a];n.push(t===``?0:parseInt(t,8)&255);continue}let s=o===`x`?2:o===`u`?4:o===`U`?8:0;if(s>0&&/[0-9a-fA-F]/u.test(e[a+1]??``)){let t=``;for(;t.length<s&&/[0-9a-fA-F]/u.test(e[a+1]??``);)t+=e[++a];let i=parseInt(t,16);if(o===`x`)n.push(i);else{if(!Ir(i))throw new T(`feature`,`echo Unicode escape`,`echo: escapes outside Unicode scalar values are not supported`);r(String.fromCodePoint(i))}continue}let c=a+Rr(e,a);r(`\\`+e.slice(a,c)),a=c-1}return i(!1)}var wD={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92};function TD(e,t,n,r){let i=e[t+1],a=t+2;if(i===void 0)return{bytes:[92],end:t+1};if(n&&i===`c`)return{bytes:[],end:a,stop:!0};if(Object.hasOwn(wD,i))return{bytes:[wD[i]],end:a};if(!n&&`'"?`.includes(i))return{bytes:[i.codePointAt(0)],end:a};if(/[0-7]/u.test(i)){let r=n&&i===`0`?4:3;for(;a<t+1+r&&/[0-7]/u.test(e[a]??``);)a++;return{bytes:[parseInt(e.slice(t+1,a),8)&255],end:a}}let o=i===`x`?2:i===`u`?4:i===`U`?8:0;if(o){for(;a<t+2+o&&/[\da-fA-F]/u.test(e[a]??``);)a++;if(a===t+2||i!==`x`&&a!==t+2+o)return r.stderr+=`printf: missing hexadecimal number in escape
320
- `,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let n=parseInt(e.slice(t+2,a),16);if(i===`x`)return{bytes:[n],end:a};if(!Ir(n))throw new T(`feature`,`Unicode escape`,`escapes outside Unicode scalar values are not supported`);if(r.byteLocale&&n>127)throw new T(`feature`,`Unicode escape in C locale`,`non-ASCII Unicode escapes in the C locale are not supported`);return{bytes:p(String.fromCodePoint(n)),end:a}}return a=t+1+Rr(e,t+1),{bytes:p(e.slice(t,a)),end:a}}function ED(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]===`\\`){let i=TD(e,r,!0,t);for(let e of i.bytes)n.push(e);if(r=i.end,i.stop){t.stop=!0;break}}else{let t=e.indexOf(`\\`,r),i=t<0?e.length:t;for(let t of p(e.slice(r,i)))n.push(t);r=i}return Uint8Array.from(n)}var DD=/^%([-+ #0']*)(\d+|\*)?(?:\.(-?\d+|\*)?)?([hlLjzt]*)(.)?/su,OD=8e6;function kD(e,t,n){let r=t[0]===`--`?t.slice(1):t;if(r.length===0)return We(`printf format [arguments]`);if(t[0]!==`--`&&/^-./su.test(t[0])){let e=t[0].startsWith(`-v`)?`-v`:t[0];return C(`option`,`printf`,e,`printf: option ${e} is not supported`,2)}let i={args:r.slice(1),index:0,chunks:[],size:0,stderr:``,failed:!1,stop:!1,byteLocale:en(n)},a;try{if(r.some(e=>e.includes(`\0`)))throw new T(`feature`,`NUL in argument`,`NUL bytes in command arguments are not supported`);do{let e=i.index;if(ND(r[0],i),i.index===e)break}while(!i.stop&&i.index<i.args.length);a=b()}catch(e){a=Ke(e,`printf`,`printf: ${e.message}`)}try{a.stdout=jD(i)}catch(e){let t=S(a);t&&n.unsupported.add(t,`printf`);let r=Ke(e,`printf`,`printf: ${e.message}`);r.stderr=a.stderr+r.stderr,a=r}return a.stderr=i.stderr+a.stderr,i.failed&&a.exitCode===0&&(a.exitCode=1),a}function AD(e,t){if(e.size+t.length>OD)throw new T(`feature`,`format size limit`,`formatted output exceeds the output limit`);t.length&&e.chunks.push(t),e.size+=t.length}function jD(e){let t=new Uint8Array(e.size),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return D(t)}var MD=e=>e.args[e.index++];function ND(e,t){for(let n=0;n<e.length&&!t.stop;)if(e[n]===`\\`){let r=TD(e,n,!1,t);AD(t,r.bytes),n=r.end}else if(e[n]===`%`){if(e[n+1]===`%`){AD(t,[37]),n+=2;continue}let r=PD(e.slice(n),t);n+=r.length;let i=MD(t);if(`sbc`.includes(r.conv))FD(i??``,r,t);else{let e=`diouxX`.includes(r.conv)?lC(cC(i,`ouxX`.includes(r.conv),t),r):uC(i,r,t);AD(t,p(e))}}else{let r=n+1;for(;r<e.length&&e[r]!==`%`&&e[r]!==`\\`;)r++;AD(t,p(e.slice(n,r))),n=r}}function PD(e,t){if(/^%[-+ #0'\d.*]*\$/u.test(e))throw new T(`feature`,`positional format arguments`,`positional format arguments are not supported`);let n=DD.exec(e),[,r,i,a,o,s]=n;if(s===void 0)throw Error(`missing format character`);if(!`sbcdiouxXeEfFgG`.includes(s))throw`aAqQnCS(p%I`.includes(s)?new T(`feature`,`%`+s,`format %${s} is not supported`):Error(`invalid format character: ${s}`);if(o&&`sbc`.includes(s))throw new T(`feature`,`format length modifier`,`length modifiers on string and character formats are not supported`);let c={conv:s,length:n[0].length,minus:r.includes(`-`),plus:r.includes(`+`),space:r.includes(` `),zero:r.includes(`0`),alt:r.includes(`#`),width:Number(i===`*`?cC(MD(t),!1,t):i??0),precision:a===`*`?Number(cC(MD(t),!1,t)):a===void 0?n[0].includes(`.`)?0:null:Number(a)};if(i===`*`&&Math.abs(c.width)>2147483647||a===`*`&&(c.precision<-2147483648||c.precision>2147483647))throw new T(`feature`,`format size limit`,`star width or precision outside the signed 32-bit range is not supported`);if(c.width<0&&(c.minus=!0,c.width=-c.width),c.precision<0&&(c.precision=null),c.width>oh||c.precision>oh)throw new T(`feature`,`format size limit`,`format width or precision exceeds the output limit`);return c}function FD(e,t,n){let r=t.conv===`b`?ED(e,n):p(e);t.conv===`c`?r=r.length?r.subarray(0,1):new Uint8Array(1):t.precision!==null&&(r=r.subarray(0,t.precision));let i=Math.max(0,t.width-r.length),a=i?new Uint8Array(i).fill(32):[];t.minus||AD(n,a),AD(n,r),t.minus&&AD(n,a)}function ID(e,t){if(!e.includes(`
321
- `))return e;let n=en(t);if(!n&&/[\u0080-\u009F\u2028\u2029]/u.test(e))throw new T(`feature`,`filename quoting`,`wc: locale-sensitive filename quoting is not supported`);let r=n?Array.from(p(e),e=>String.fromCodePoint(e)):[...e],i={7:`\\a`,8:`\\b`,9:`\\t`,10:`\\n`,11:`\\v`,12:`\\f`,13:`\\r`},a=!1,o=`'`;for(let e of r){let t=e.codePointAt(0);t<32||t===127||n&&t>127?(a||(o+=`'$'`),o+=i[t]??`\\`+t.toString(8).padStart(3,`0`),a=!0):(o+=e===`'`?`'\\''`:(a?`''`:``)+e,a=!1)}return o+`'`}function LD(e,t,n,r,i){let a=[];for(let t of[`l`,`w`,`m`,`c`])n[t]&&a.push(String(e[t]).padStart(r));return a.join(` `)+(t?` `+ID(t,i):``)}var RD=`**=.**.++.--.+=.-=.*=./=.%=.^=.==.!=.<=.>=.&&.||.!~.>>.|&.+.-.*./.%.^.!.>.<.|.?.:.~.$.=.(.).{.}.[.].;.,`.split(`.`),zD=new Set([`number`,`string`,`name`,`builtin`]),BD=new Set([`)`,`]`,`++`,`--`]),VD=/^(?:0[xX][0-9a-fA-F]+|\d+\.?\d*(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/u,HD=e=>e!==void 0&&/[A-Za-z_]/u.test(e),UD=e=>e!==void 0&&/[A-Za-z0-9_]/u.test(e),WD=e=>e!==void 0&&e>=`0`&&e<=`9`;function GD(e,t=null){let n=[],r=1,i=0,a=(e,t)=>n.push({type:e,value:t,line:r}),o=()=>{let e=n.at(-1);return!e||!zD.has(e.type)&&!(e.type===`punct`&&BD.has(e.value))};for(;i<e.length;){let s=e[i];if(s===`
316
+ `?i:r+i}throw Error(`unterminated 'y' command`)}function RE(e,t){if(t.byteLocale)return D(p(e).map(e=>t.translation[e]));let n=``;for(let r of e)n+=t.translation.get(r)??r;return n}function zE(e,t=!1,n=M,r=null){let i={script:e,i:0,extended:t,locale:n,byteLocale:en(n),textState:r??{},openWrite:r?.openWrite},a=[];for(ME(i);i.i<e.length;){if(/[;\n\r\f\v \t]/u.test(e[i.i])){i.i++;continue}e[i.i]===`#`&&rE(`comments`);let t=UE(i),n=null;if(t&&e[i.i]===`,`&&(i.i++,n=UE(i,!0),n===null))throw Error(`missing second address`);e[i.i]===`~`&&rE(`step address`);let r=t?.type===`line`&&t.value===0;if(r&&n?.type!==`regex`)throw Error(`line numbers must be >= 1`);let o=!1;if(e[i.i]===`!`){for(o=!0,i.i++;/[ \t]/u.test(e[i.i]??``);)i.i++;if(e[i.i]===`!`)throw Error(`multiple '!'s`)}let s=e[i.i++],c={kind:s,start:t,end:n,active:r,negated:o};if(s&&`pPnNdD=gGhHx`.includes(s))a.push(c);else if(s===`w`){a.push({...c,...SE(i)});continue}else if(s===`:`||s===`b`||s===`t`||s===`T`){a.push({...c,label:VE(i,c)});continue}else if(s===`s`)a.push({...c,...yE(i)});else if(s===`a`||s===`i`||s===`c`)jE(i,c),a.push(c);else if(s===`y`)a.push({...c,...IE(i)});else if(s===`q`){if(n!==null)throw Error(`command only uses one address`);let t=/^[ \t]*(\d*)/u.exec(e.slice(i.i));i.i+=t[0].length;let r=BigInt.asIntN(32,BigInt(t[1]||`0`));a.push({...c,exitCode:r===-1n?0:Number(BigInt.asUintN(8,r))})}else if(s===`{`){i.textState.blockDepth=(i.textState.blockDepth??0)+1,a.push(c);continue}else if(s===`}`){if(!i.textState.blockDepth)throw Error(`unexpected '}'`);if(t!==null)throw Error(`'}' doesn't want any addresses`);i.textState.blockDepth--,a.push(c)}else{if(s===void 0)throw Error(`missing command`);if(`QlLFzrRWev`.includes(s))rE();else throw Error(`unknown command: '${s}'`)}for(;/[ \t]/u.test(e[i.i]??``);)i.i++;if(e[i.i]===`#`&&rE(`comments`),i.i<e.length&&!/[;\n}]/u.test(e[i.i]))throw Error(`extra characters after command`)}return r===null&&NE(i.textState),a}function BE(e,t){let n=[];for(let t=0;t<e.length;t++){let r=e[t];if(r.kind===`{`&&n.push(r),r.kind===`}`){if(n.length===0)throw Error(`unexpected '}'`);n.pop().jump=t}}if(n.length)throw Error(`unmatched '{'`);return NE(t),HE(e),e}function VE(e,t){if(t.kind===`:`&&t.start!==null)throw 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 Error(`':' lacks a label`);return r}function HE(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 i=r.label===``?e.length:t.get(r.label);if(i===void 0)throw Object.assign(Error(`can't find label for jump to \`${r.label}'`),{exitCode:4});r.jump=i}}function UE(e,t=!1){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;e.script[e.i]===`~`&&rE(`step address`);let n=/^(\d+|\+[ \t]*\d+)/u.exec(e.script.slice(e.i)),r=null;if(n){let i=n[0][0]===`+`;if(i&&!t)throw Error(`relative address requires a range`);let a=Number(n[0].replace(/[ \t]/gu,``));Number.isSafeInteger(a)||rE(`address limit`),e.i+=n[0].length,r={type:i?`offset`:`line`,value:a}}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 t=vE(e,_E(e,`address regex`),!0,`address regex`),n=!1;for(;;){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;let r=e.script[e.i];if(r!==`I`&&r!==`M`)break;if(t===``)throw Error(`cannot specify modifiers on empty regexp`);r===`M`&&rE(`address regex flags`),n=!0,e.i++}r={type:`regex`,...CE(t,e.extended,!0,n,e.locale)}}for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;return r}function WE(e,t,n,r,i){let{start:a,end:o}=e;if(a===null)return!0;if(o===null)return GE(a,t,n,r,i);if(!e.active){if(a.type===`line`){if(e.closed||n<a.value)return!1}else if(!GE(a,t,n,r,i))return!1;if(e.active=!0,o.type===`regex`)return!0;if(o.type===`offset`&&(e.until=n+o.value),o.type===`line`)return e.active=n<o.value,e.closed=!e.active,n<=o.value||GE(a,t,n,r,i)}return o.type===`line`?(e.active=n<o.value,e.closed=!e.active,n<=o.value):((o.type===`offset`?n>=e.until:GE(o,t,n,r,i))&&(e.active=!1,e.closed=!0),!0)}function GE(e,t,n,r,i){if(e.type===`line`)return n===e.value;if(e.type===`last`)return typeof r==`function`?r():r;let a=DE(e,i);return EE(t,a),a.re.search(t)!==null}function KE(e,t,n,r=!1){let{output:i,delimiter:a}=e,o=t.has(`n`)||t.has(`quiet`)||t.has(`silent`),s=t.has(`s`)||t.has(`separate`),c=mE(e.files,e.stdin,n,a,s,e=>i.stream(2,e)),l=i.start(c),u=[],d=dE(r?e=>{i.account(e),u.push(e)}:e=>i.stream(1,e),a),f={delimiter:a,quiet:o,separate:s,hold:e.hold,regexState:e.regexState,budget:e.budget,emit:d,input:c,output:i};try{let t=qE(e.commands,f);l.quit=t!==null,l.exitCode=c.status.failed?c.status.directory?4:2:t??0,l.failed=c.status.failed}catch(e){let t=iE(e);K(l,t);let n=S(t);n&&w(l,n.kind,n.command,n.detail,n.message),l.failed=!0}finally{i.finish()}return r&&(l.content=u.join(``)),l}function qE(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 t of e)t.active=t.start?.type===`line`&&t.start.value===0,t.closed=!1;n=!1}t.output.record(r);let i={...r,...t,append:[],exitCode:null,replaced:!1},a=JE(e,i);if(!t.quiet&&!a&&t.emit(i.text,i.terminator),i.exitCode!==null&&t.emit(``),QE(i),i.exitCode!==null)return i.exitCode;t.output.record(null)}return null}function JE(e,t){for(let n=0;n<e.length;n++){if(++t.budget.steps>eE)throw new T(`feature`,`execution limit`,`sed: execution limit reached after ${eE} commands (infinite loop?)`);let r=e[n];if(r.kind===`}`||r.kind===`:`)continue;if(WE(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 e=i===`b`||(i===`t`?t.replaced:!t.replaced);i!==`b`&&(t.replaced=!1),e&&(n=r.jump-1);continue}if(i===`q`){t.exitCode=r.exitCode;break}if(i===`d`)return!0;if(i===`D`){let e=t.text.indexOf(t.delimiter);if(e<0)return!0;t.text=t.text.slice(e+t.delimiter.length),n=-1;continue}if(i===`n`||i===`N`){if(!ZE(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(YE(r,t),t.text.length>tE)throw new T(`feature`,`pattern space limit`,`sed: pattern space limit exceeded`)}}return!1}function YE(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 e=t.text.indexOf(t.delimiter);t.emit(e<0?t.text:t.text.slice(0,e),e<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))XE(n,t);else if(n===`y`)t.text=RE(t.text,e);else{let n=OE(t.text,e,t.regexState);if(t.text=n.out,!n.count)return;t.replaced=!0,e.print&&t.emit(t.text,t.terminator),e.writer&&e.writer(t.text,t.terminator)}}function XE(e,t){let n=t.hold;if(e===`x`){let{text:e,terminator:r}=t;Object.assign(t,n),Object.assign(n,{text:e,terminator:r})}else{let r=e===`h`||e===`H`?t:n,i=r===n?t:n;i.text=e===`G`||e===`H`?i.text+t.delimiter+r.text:r.text,i.terminator=r.terminator}if(n.text.length>tE)throw new T(`feature`,`hold space limit`,`sed: hold space limit exceeded`)}function ZE(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;QE(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>tE)throw new T(`feature`,`pattern space limit`,`sed: pattern space limit exceeded`);return Object.assign(e,n,{text:r,replaced:!1}),e.output.record(n),!0}function QE(e){if(e.append.length!==0){e.emit(``);for(let t of e.append)e.emit(t??``);e.append.length=0}}function $E(e,t,n){try{let{tokens:r,inPlace:i}=aE(t),a=U(r,{short:[`n`,`E`,`r`,`s`,`z`],long:[`regexp-extended`,`quiet`,`silent`,`separate`,`null-data`,`zero-terminated`],repeatable:[`e`,`expression`,`f`,`file`]}),o=a.flags.has(`z`)||a.flags.has(`null-data`)||a.flags.has(`zero-terminated`)?`\0`:`
317
+ `,s=fE(n,o),c=eD(a,e,n,s.openWrite);return c===null?x($T):c.error?c.error:(Object.assign(c,{output:s,delimiter:o,hold:{text:``,terminator:o},regexState:{last:null},budget:{steps:0}}),c.stdin=pE(c.stdin,n),i===null?KE(c,a.flags,n):oE(c,a.flags,n,i,(e,t)=>KE(e,t,n,!0)))}catch(e){return iE(e)}}function eD({order:e,positional:t},n,r,i){let a=[],o={openWrite:i},s=!1,c=!1;for(let{name:t,value:i}of e){if((t===`E`||t===`r`||t===`regexp-extended`)&&(s=!0),![`e`,`expression`,`f`,`file`].includes(t))continue;c=!0;let e=i;if(t===`f`||t===`file`){n=pE(n,r);let t=n,a=r.io.bufferReads(()=>Rn(`sed`,[i],r,t));if(a.failed)return{error:x(a.stderr,4)};e=a.inputs[0].content,a.inputs[0].shared&&(n=``)}for(let t of zE(e,s,r.locale,o))a.push(t)}return c?{commands:BE(a,o),files:t,stdin:n}:t.length===0?null:{commands:BE(zE(t[0],s,r.locale,o),o),files:t.slice(1),stdin:n}}var tD=new Set([`-b`,`-c`,`-g`,`-k`,`-p`,`-r`,`-t`,`-u`,`-v`,`-w`,`-x`,`-G`,`-N`,`-O`,`-R`,`-S`,`-o`]),nD=new Set([`-nt`,`-ot`,`-ef`,`<`,`>`]),rD={__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},iD=String(bn).length,aD=new Set([`/dev/stdin`,`/dev/stdout`,`/dev/stderr`]);function oD(e,t,n){return cD(`test`,t,n)}function sD(e,t,n){return t.at(-1)===`]`?cD(`[`,t.slice(0,-1),n):x("[: missing `]'",2)}function cD(e,t,n){try{return{...b(),exitCode:+!lD(t,n)}}catch(t){return qe(t,e,`${e}: ${t.message}`,2)}}function lD(e,t){let[n,r,i]=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 dD(n,r,t);throw tD.has(n)&&mD(n),Error(`${n}: unary operator expected`)}if(e.length===3){if(r===`=`||r===`==`)return n===i;if(r===`!=`)return n!==i;if(Object.hasOwn(rD,r))return rD[r](uD(n),uD(i));nD.has(r)&&mD(r),(r===`-a`||r===`-o`)&&mD(`compound expressions`)}if(e.length<=4){if(n===`!`)return!lD(e.slice(1),t);if(n===`(`&&e.at(-1)===`)`)return lD(e.slice(1,-1),t)}throw e.some(e=>[`-a`,`-o`,`!`,`(`,`)`].includes(e))&&mD(`compound expressions`),Error(e.length>3?`too many arguments`:`${r}: binary operator expected`)}function uD(e){let t=/^[ \t\n\r\f\v]*([+-]?)(\d+)[ \t]*$/u.exec(e);if(t&&t[0].length===e.length){let e=t[2].replace(/^0+/u,``)||`0`;if(e.length<=iD){let n=BigInt(t[1]+e);if(n>=xn&&n<=bn)return n}}throw Error(`${e}: integer expression expected`)}function dD(e,t,n){let r={isDir:e=>e===`/dev`||e===`/dev/fd`||n.fs.isDir(e),isFile:e=>e===`/dev/null`||pD(e)||n.fs.isFile(e),isLink:e=>n.fs.isLink?.(e)===!0,readLink:e=>n.fs.readLink?.(e)},i=e===`-h`||e===`-L`,{path:a,error:o}=k(n.cwd,t,r,{follow:!i});return!o&&(pD(a)&&mD(`stream device metadata`),i?r.isLink(a):e===`-e`||e===`-a`?!0:e===`-d`?r.isDir(a):e===`-s`?r.isDir(a)||a!==`/dev/null`&&fD(n,a)>0:a!==`/dev/null`&&n.fs.isFile(a))}var fD=(e,t)=>e.fs.fileSize?.(t)??E(e.fs.readFile(t)).length;function pD(e){return aD.has(e)||/^\/dev\/fd\/\d+$/u.test(e)}function mD(e){throw new T(`feature`,e,`${e} is not supported`)}function hD(e){let t=e.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/gu,``),n=/^[+-]?\d+$/u.test(t)?BigInt(t):null;return{arg:t,n:n!==null&&n>=xn&&n<=bn?n:null}}var gD=e=>({...e,halt:!0});function _D(e,t,n){let r=t[0]===`--`?t.slice(1):t;if(r.length===0)return gD({...b(),exitCode:n.lastExit});let{arg:i,n:a}=hD(r[0]);return a===null?gD(x(`exit: ${i}: numeric argument required`,2)):r.length>1?gD(x(`exit: too many arguments`)):gD({...b(),exitCode:Number((a%256n+256n)%256n)})}function vD(e){return(t,n,r)=>{let i=n[0]===`--`?n.slice(1):n;if(i.length>1)return gD(x(`${e}: too many arguments`));let{arg:a,n:o}=hD(i[0]??`1`);return o===null?gD(x(`${e}: ${a}: numeric argument required`,128)):o<=0?{...x(`${e}: ${a}: loop count out of range`),control:r.loopDepth?{type:`break`,levels:r.loopDepth}:void 0}:r.loopDepth===0?x(`${e}: only meaningful in a \`for\`, \`while\` or \`until\` loop`,0):{...b(),control:{type:e,levels:Number(o>BigInt(r.loopDepth)?BigInt(r.loopDepth):o)}}}}function yD(e,t,n){let r=t[0]===`--`,i=r?t.slice(1):t;if(i.length===0||!r&&i[0]===`-p`)return C(`option`,`export`,`-p`,`export: listing the environment is not supported (there is none)`);let a=``;for(let e of i){let t=e.indexOf(`=`),i=t>0&&e[t-1]===`+`,o=t===-1?e:e.slice(0,i?t-1:t);if(!r&&e.startsWith(`-`))return C(`option`,`export`,e,`export: option \`${e}\` is not supported`);if(!gi.test(o)){a+=`export: \`${o}': not a valid identifier
318
+ `;continue}t===-1?n.vars.has(o)&&n.vars.set(o,n.vars.get(o)):n.vars.set(o,(i?Bx(o,n):``)+e.slice(t+1))}return{stdout:``,stderr:a,exitCode:+!!a}}function bD(e,t,n){let r=+(t[0]===`-v`),i=t[r]===`--`;i&&r++;let a=t.slice(r);for(let e of a){if(!i&&e.startsWith(`-`))return C(`option`,`unset`,e,`unset: option \`${e}\` is not supported`);if(e.includes(`[`))return C(`feature`,`unset`,`array subscript`,`unset: array subscripts are not supported`);if(e===`LANG`)return C(`feature`,`unset`,`LANG`,`unset: LANG: ${Yt}`);n.vars.delete(e)}return b()}function xD(e,t,n){let r=null;for(let e=0;e<t.length;e++){let n=t[e];if(n===`-e`||n===`+e`)r=n===`-e`;else if((n===`-o`||n===`+o`)&&t[e+1]===`errexit`)r=n===`-o`,e++;else return SD()}return r===null?SD():(n.errexit=r,b())}var SD=()=>C(`feature`,`set`,`set`,"set: `set` is supported only as `set -e` or `set +e`",127),CD={exit:_D,break:vD(`break`),continue:vD(`continue`),export:yD,set:xD,unset:bD},wD=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 TD(e,t){let n=0,r=!0,i=!1;for(;n<t.length&&/^-[neE]+$/u.test(t[n]);n++)for(let e of t[n].slice(1))e===`n`?r=!1:i=e===`e`;let a=t.slice(n).join(` `);if(i){let e=ED(a);a=e.text,e.stop&&(r=!1)}return b(r?a+`
319
+ `:a)}function ED(e){let t={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92},n=[],r=e=>{for(let t of p(e))n.push(t)},i=e=>({text:D(Uint8Array.from(n)),stop:e});for(let a=0;a<e.length;a++){if(e[a]!==`\\`||a+1>=e.length){let t=e.indexOf(`\\`,a+1),n=t<0?e.length:t;r(e.slice(a,n)),a=n-1;continue}let o=e[++a];if(o===`c`)return i(!0);if(o in t){n.push(t[o]);continue}if(o===`0`){let t=``;for(;t.length<3&&/[0-7]/u.test(e[a+1]??``);)t+=e[++a];n.push(t===``?0:parseInt(t,8)&255);continue}let s=o===`x`?2:o===`u`?4:o===`U`?8:0;if(s>0&&/[0-9a-fA-F]/u.test(e[a+1]??``)){let t=``;for(;t.length<s&&/[0-9a-fA-F]/u.test(e[a+1]??``);)t+=e[++a];let i=parseInt(t,16);if(o===`x`)n.push(i);else{if(!Rr(i))throw new T(`feature`,`echo Unicode escape`,`echo: escapes outside Unicode scalar values are not supported`);r(String.fromCodePoint(i))}continue}let c=a+Br(e,a);r(`\\`+e.slice(a,c)),a=c-1}return i(!1)}var DD={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92};function OD(e,t,n,r){let i=e[t+1],a=t+2;if(i===void 0)return{bytes:[92],end:t+1};if(n&&i===`c`)return{bytes:[],end:a,stop:!0};if(Object.hasOwn(DD,i))return{bytes:[DD[i]],end:a};if(!n&&`'"?`.includes(i))return{bytes:[i.codePointAt(0)],end:a};if(/[0-7]/u.test(i)){let r=n&&i===`0`?4:3;for(;a<t+1+r&&/[0-7]/u.test(e[a]??``);)a++;return{bytes:[parseInt(e.slice(t+1,a),8)&255],end:a}}let o=i===`x`?2:i===`u`?4:i===`U`?8:0;if(o){for(;a<t+2+o&&/[\da-fA-F]/u.test(e[a]??``);)a++;if(a===t+2||i!==`x`&&a!==t+2+o)return r.stderr+=`printf: missing hexadecimal number in escape
320
+ `,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let n=parseInt(e.slice(t+2,a),16);if(i===`x`)return{bytes:[n],end:a};if(!Rr(n))throw new T(`feature`,`Unicode escape`,`escapes outside Unicode scalar values are not supported`);if(r.byteLocale&&n>127)throw new T(`feature`,`Unicode escape in C locale`,`non-ASCII Unicode escapes in the C locale are not supported`);return{bytes:p(String.fromCodePoint(n)),end:a}}return a=t+1+Br(e,t+1),{bytes:p(e.slice(t,a)),end:a}}function kD(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]===`\\`){let i=OD(e,r,!0,t);for(let e of i.bytes)n.push(e);if(r=i.end,i.stop){t.stop=!0;break}}else{let t=e.indexOf(`\\`,r),i=t<0?e.length:t;for(let t of p(e.slice(r,i)))n.push(t);r=i}return Uint8Array.from(n)}var AD=/^%([-+ #0']*)(\d+|\*)?(?:\.(-?\d+|\*)?)?([hlLjzt]*)(.)?/su,jD=8e6;function MD(e,t,n){let r=t[0]===`--`?t.slice(1):t;if(r.length===0)return Ge(`printf format [arguments]`);if(t[0]!==`--`&&/^-./su.test(t[0])){let e=t[0].startsWith(`-v`)?`-v`:t[0];return C(`option`,`printf`,e,`printf: option ${e} is not supported`,2)}let i={args:r.slice(1),index:0,chunks:[],size:0,stderr:``,failed:!1,stop:!1,byteLocale:tn(n)},a;try{if(r.some(e=>e.includes(`\0`)))throw new T(`feature`,`NUL in argument`,`NUL bytes in command arguments are not supported`);do{let e=i.index;if(ID(r[0],i),i.index===e)break}while(!i.stop&&i.index<i.args.length);a=b()}catch(e){a=qe(e,`printf`,`printf: ${e.message}`)}try{a.stdout=PD(i)}catch(e){let t=S(a);t&&n.unsupported.add(t,`printf`);let r=qe(e,`printf`,`printf: ${e.message}`);r.stderr=a.stderr+r.stderr,a=r}return a.stderr=i.stderr+a.stderr,i.failed&&a.exitCode===0&&(a.exitCode=1),a}function ND(e,t){if(e.size+t.length>jD)throw new T(`feature`,`format size limit`,`formatted output exceeds the output limit`);t.length&&e.chunks.push(t),e.size+=t.length}function PD(e){let t=new Uint8Array(e.size),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return D(t)}var FD=e=>e.args[e.index++];function ID(e,t){for(let n=0;n<e.length&&!t.stop;)if(e[n]===`\\`){let r=OD(e,n,!1,t);ND(t,r.bytes),n=r.end}else if(e[n]===`%`){if(e[n+1]===`%`){ND(t,[37]),n+=2;continue}let r=LD(e.slice(n),t);n+=r.length;let i=FD(t);if(`sbc`.includes(r.conv))RD(i??``,r,t);else{let e=`diouxX`.includes(r.conv)?fC(dC(i,`ouxX`.includes(r.conv),t),r):pC(i,r,t);ND(t,p(e))}}else{let r=n+1;for(;r<e.length&&e[r]!==`%`&&e[r]!==`\\`;)r++;ND(t,p(e.slice(n,r))),n=r}}function LD(e,t){if(/^%[-+ #0'\d.*]*\$/u.test(e))throw new T(`feature`,`positional format arguments`,`positional format arguments are not supported`);let n=AD.exec(e),[,r,i,a,o,s]=n;if(s===void 0)throw Error(`missing format character`);if(!`sbcdiouxXeEfFgG`.includes(s))throw`aAqQnCS(p%I`.includes(s)?new T(`feature`,`%`+s,`format %${s} is not supported`):Error(`invalid format character: ${s}`);if(o&&`sbc`.includes(s))throw new T(`feature`,`format length modifier`,`length modifiers on string and character formats are not supported`);let c={conv:s,length:n[0].length,minus:r.includes(`-`),plus:r.includes(`+`),space:r.includes(` `),zero:r.includes(`0`),alt:r.includes(`#`),width:Number(i===`*`?dC(FD(t),!1,t):i??0),precision:a===`*`?Number(dC(FD(t),!1,t)):a===void 0?n[0].includes(`.`)?0:null:Number(a)};if(i===`*`&&Math.abs(c.width)>2147483647||a===`*`&&(c.precision<-2147483648||c.precision>2147483647))throw new T(`feature`,`format size limit`,`star width or precision outside the signed 32-bit range is not supported`);if(c.width<0&&(c.minus=!0,c.width=-c.width),c.precision<0&&(c.precision=null),c.width>lh||c.precision>lh)throw new T(`feature`,`format size limit`,`format width or precision exceeds the output limit`);return c}function RD(e,t,n){let r=t.conv===`b`?kD(e,n):p(e);t.conv===`c`?r=r.length?r.subarray(0,1):new Uint8Array(1):t.precision!==null&&(r=r.subarray(0,t.precision));let i=Math.max(0,t.width-r.length),a=i?new Uint8Array(i).fill(32):[];t.minus||ND(n,a),ND(n,r),t.minus&&ND(n,a)}function zD(e,t){if(!e.includes(`
321
+ `))return e;let n=tn(t);if(!n&&/[\u0080-\u009F\u2028\u2029]/u.test(e))throw new T(`feature`,`filename quoting`,`wc: locale-sensitive filename quoting is not supported`);let r=n?Array.from(p(e),e=>String.fromCodePoint(e)):[...e],i={7:`\\a`,8:`\\b`,9:`\\t`,10:`\\n`,11:`\\v`,12:`\\f`,13:`\\r`},a=!1,o=`'`;for(let e of r){let t=e.codePointAt(0);t<32||t===127||n&&t>127?(a||(o+=`'$'`),o+=i[t]??`\\`+t.toString(8).padStart(3,`0`),a=!0):(o+=e===`'`?`'\\''`:(a?`''`:``)+e,a=!1)}return o+`'`}function BD(e,t,n,r,i){let a=[];for(let t of[`l`,`w`,`m`,`c`])n[t]&&a.push(String(e[t]).padStart(r));return a.join(` `)+(t?` `+zD(t,i):``)}var VD=`**=.**.++.--.+=.-=.*=./=.%=.^=.==.!=.<=.>=.&&.||.!~.>>.|&.+.-.*./.%.^.!.>.<.|.?.:.~.$.=.(.).{.}.[.].;.,`.split(`.`),HD=new Set([`number`,`string`,`name`,`builtin`]),UD=new Set([`)`,`]`,`++`,`--`]),WD=/^(?:0[xX][0-9a-fA-F]+|\d+\.?\d*(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/u,GD=e=>e!==void 0&&/[A-Za-z_]/u.test(e),KD=e=>e!==void 0&&/[A-Za-z0-9_]/u.test(e),qD=e=>e!==void 0&&e>=`0`&&e<=`9`;function JD(e,t=null){let n=[],r=1,i=0,a=(e,t)=>n.push({type:e,value:t,line:r}),o=()=>{let e=n.at(-1);return!e||!HD.has(e.type)&&!(e.type===`punct`&&UD.has(e.value))};for(;i<e.length;){let s=e[i];if(s===`
322
322
  `){n.at(-1)?.type!==`newline`&&a(`newline`,`
323
323
  `),r++,i++;continue}if(s===` `||s===` `||s===`\r`){i++;continue}if(s===`\\`&&(e[i+1]===`
324
324
  `||e[i+1]===`\r`&&e[i+2]===`
325
325
  `)){i+=e[i+1]===`
326
326
  `?2:3,r++;continue}if(s===`#`){for(;i<e.length&&e[i]!==`
327
- `;)i++;continue}if(s===`"`){let n=YD(e,i+1,t,r);a(`string`,n.value),i=n.end;continue}if(s===`/`&&o()){let t=XD(e,i+1,r);a(`regex`,t.value),i=t.end;continue}if(WD(s)||s===`.`&&WD(e[i+1])){let t=KD(e,i);a(`number`,t.value),i=t.end;continue}if(HD(s)){let t=i+1;for(;UD(e[t]);)t++;let n=e.slice(i,t);if(e.slice(t,t+2)===`::`)throw new W(`namespaces are not supported`,r,`namespaces`);i=t,eh.has(n)?a(`keyword`,n===`func`?`function`:n):rh.has(n)?a(`builtin`,n):a(e[t]===`(`?`funcname`:`name`,n);continue}let c=i,l=RD.find(t=>e.startsWith(t,c));if(s===`@`)throw new W(`typed regexes, indirect calls and source directives are not supported`,r,`@ extensions`);if(!l)throw new W(`unexpected character \`${s}\``,r);a(`punct`,l),i+=l.length}return a(`eof`,``),n}function KD(e,t){let n=VD.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 qD={__proto__:null,n:`
328
- `,t:` `,r:`\r`,a:`\x07`,b:`\b`,f:`\f`,v:`\v`,'"':`"`,"\\":`\\`};function JD(e,t,n){let r=e[t+1];if(r===void 0)return{text:`\\`,end:t+1};if(r in qD)return{text:qD[r],end:t+2};if(r>=`0`&&r<=`7`){let n=t+1;for(;n<t+4&&e[n]>=`0`&&e[n]<=`7`;)n++;return{byte:Number.parseInt(e.slice(t+1,n),8)&255,end:n}}if(r===`x`&&/[0-9a-fA-F]/u.test(e[t+2]??``)){let n=t+2;for(;n<t+4&&/[0-9a-fA-F]/u.test(e[n]??``);)n++;return{byte:Number.parseInt(e.slice(t+2,n),16),end:n}}if(r.codePointAt(0)>127)throw new W(`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 YD(e,t,n,r=null){let i=[],a=t;for(;a<e.length;){let t=e[a];if(r!==null){if(t===`"`)return{value:D(Uint8Array.from(i)),end:a+1};if(t===`
327
+ `;)i++;continue}if(s===`"`){let n=QD(e,i+1,t,r);a(`string`,n.value),i=n.end;continue}if(s===`/`&&o()){let t=$D(e,i+1,r);a(`regex`,t.value),i=t.end;continue}if(qD(s)||s===`.`&&qD(e[i+1])){let t=YD(e,i);a(`number`,t.value),i=t.end;continue}if(GD(s)){let t=i+1;for(;KD(e[t]);)t++;let n=e.slice(i,t);if(e.slice(t,t+2)===`::`)throw new W(`namespaces are not supported`,r,`namespaces`);i=t,rh.has(n)?a(`keyword`,n===`func`?`function`:n):oh.has(n)?a(`builtin`,n):a(e[t]===`(`?`funcname`:`name`,n);continue}let c=i,l=VD.find(t=>e.startsWith(t,c));if(s===`@`)throw new W(`typed regexes, indirect calls and source directives are not supported`,r,`@ extensions`);if(!l)throw new W(`unexpected character \`${s}\``,r);a(`punct`,l),i+=l.length}return a(`eof`,``),n}function YD(e,t){let n=WD.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 XD={__proto__:null,n:`
328
+ `,t:` `,r:`\r`,a:`\x07`,b:`\b`,f:`\f`,v:`\v`,'"':`"`,"\\":`\\`};function ZD(e,t,n){let r=e[t+1];if(r===void 0)return{text:`\\`,end:t+1};if(r in XD)return{text:XD[r],end:t+2};if(r>=`0`&&r<=`7`){let n=t+1;for(;n<t+4&&e[n]>=`0`&&e[n]<=`7`;)n++;return{byte:Number.parseInt(e.slice(t+1,n),8)&255,end:n}}if(r===`x`&&/[0-9a-fA-F]/u.test(e[t+2]??``)){let n=t+2;for(;n<t+4&&/[0-9a-fA-F]/u.test(e[n]??``);)n++;return{byte:Number.parseInt(e.slice(t+2,n),16),end:n}}if(r.codePointAt(0)>127)throw new W(`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 QD(e,t,n,r=null){let i=[],a=t;for(;a<e.length;){let t=e[a];if(r!==null){if(t===`"`)return{value:D(Uint8Array.from(i)),end:a+1};if(t===`
329
329
  `)break;if(t===`\\`&&e[a+1]===`
330
- `){a+=2;continue}}if(t===`\\`){let t=JD(e,a,n);QD(i,t),a=t.end}else{let t=String.fromCodePoint(e.codePointAt(a));QD(i,{text:t}),a+=t.length}}if(r!==null)throw new W(`unterminated string`,r);return{value:D(Uint8Array.from(i)),end:a}}function XD(e,t,n){let r=t,i=!1;for(;r<e.length;){let n=e[r];if(n===`
331
- `)break;if(n===`\\`){r+=2;continue}if(i){if(n===`[`&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){r=t+2;continue}}n===`]`&&(i=!1),r++;continue}if(n===`[`){i=!0,r++,e[r]===`^`&&r++,e[r]===`]`&&r++;continue}if(n===`/`)return{value:e.slice(t,r),end:r+1};r++}throw new W(`unterminated regexp`,n)}function ZD(e,t=null){return YD(e,0,t).value}function QD(e,t){if(t.byte===void 0)for(let n of p(t.text))e.push(n);else e.push(t.byte)}var $D=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`^=`,`**=`]),eO=new Set([`<`,`<=`,`==`,`!=`,`>`,`>=`]),tO=e=>e.type===`var`||e.type===`index`||e.type===`field`;function nO(e){let t=e.tok;return fO(e)||t.type===`regex`||t.type===`keyword`&&t.value===`getline`||t.type===`punct`&&[`!`,`-`,`+`].includes(t.value)}function rO(e,t){let n=[iO(e,t)];for(;e.accept(`,`);)e.skipNewlines(),n.push(iO(e,t));return n}function iO(e,t){let n=aO(e,t),r=e.tok;if(r.type===`punct`&&$D.has(r.value)){tO(n)||e.fail(`cannot assign to ${n.type===`regex`?`a regex`:`a non-variable`} (left side of \`${r.value}\`)`),e.next();let i=iO(e,t);return{type:`assign`,op:r.value===`**=`?`^=`:r.value,target:n,value:i}}return n}function aO(e,t){let n=lO(e,t);if(!e.accept(`?`))return n;e.skipNewlines();let r=iO(e,t);return e.skipNewlines(),e.expect(`:`),e.skipNewlines(),{type:`cond`,test:n,consequent:r,alternate:iO(e,t)}}var oO=[[`or`,[`||`]],[`and`,[`&&`]],[`in`,[`in`]],[`match`,[`~`,`!~`]],[`compare`,[...eO]],[`concat`,[]],[`binary`,[`+`,`-`]],[`binary`,[`*`,`/`,`%`]]],sO=new Map(oO.flatMap(([e,t],n)=>t.map(t=>[t,{type:e,precedence:n}]))),cO={type:`concat`,precedence:5};function lO(e,t,n=0){let r=gO(e,t),i=1/0;for(;;){let a=e.tok;n<=4&&i>4&&!t.noGt&&(e.is(`|`)||e.is(`|&`))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${sh}`,`"cmd" | getline`);let o=fO(e)?cO:a.type===`punct`||a.type===`keyword`&&a.value===`in`?sO.get(a.value):void 0;if(!o||o.precedence<n||o.precedence>i||t.noGt&&e.is(`>`))return r;let{type:s,precedence:c}=o,l=s===`concat`?null:e.next().value;if(i=c,(s===`or`||s===`and`)&&e.skipNewlines(),s===`in`){r={type:s,keys:[r],array:uO(e)};continue}let u=lO(e,t,c+1);(l===`/`||l===`%`)&&mO(u)===0&&mO(r)!==null&&e.fail(l===`/`?`division by zero attempted`:"division by zero attempted in `%`",null,`error`),s===`compare`&&dO(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),r=s===`binary`||s===`compare`?{type:s,op:l,left:r,right:u}:s===`match`?{type:s,negate:l===`!~`,left:r,right:u}:{type:s,left:r,right:u}}}function uO(e){return e.tok.type!==`name`&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var dO=(e,t)=>e.tok.type===`punct`&&eO.has(e.tok.value)&&!(t.noGt&&e.tok.value===`>`);function fO(e){let t=e.tok;return t.type===`number`||t.type===`string`||t.type===`name`||t.type===`funcname`||t.type===`builtin`||t.type===`punct`&&[`$`,`(`,`++`,`--`].includes(t.value)}function pO(e,t){return lO(e,t,5)}function mO(e){if(e.type===`num`)return e.value;if(e.type===`neg`||e.type===`plus`){let t=mO(e.expr);return t===null?null:e.type===`neg`?-t:t}if(e.type!==`binary`)return null;let t=mO(e.left),n=mO(e.right);return t===null||n===null?null:ch(e.op,t,n)}var hO={__proto__:null,"!":`not`,"-":`neg`,"+":`plus`};function gO(e,t,n=!1){if(n&&(e.is(`$`)||e.is(`++`)||e.is(`--`)))return yO(e,t);let r=e.tok.type===`punct`&&hO[e.tok.value];return r?(e.next(),{type:r,expr:gO(e,t,n)}):n?bO(e,t):_O(e,t)}function _O(e,t){let n=vO(e,t);return!e.is(`^`)&&!e.is(`**`)?n:(e.next(),{type:`binary`,op:`^`,left:n,right:gO(e,t)})}function vO(e,t){let n=yO(e,t);for(;(e.is(`++`)||e.is(`--`))&&tO(n);)n={type:`postinc`,op:e.next().value,target:n};return n}function yO(e,t){if(e.accept(`$`))return{type:`field`,index:gO(e,t,!0)};if(e.is(`++`)||e.is(`--`)){let n=e.next().value,r=yO(e,t);return tO(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:`preinc`,op:n,target:r}}return bO(e,t)}function bO(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:xO(e,n.value)};case`name`:return CO(e);case`funcname`:return wO(e);case`builtin`:return DO(e);case`keyword`:return n.value===`getline`?OO(e,t):e.unexpected();case`punct`:return n.value===`(`?EO(e):e.unexpected();default:return e.unexpected()}}function xO(e,t){try{return jh(t,!1,t=>e.warn(t))}catch(t){return e.fail(t.message,t.gap??null)}}function SO(e){if(!e.accept(`[`))return null;let t=rO(e,{});return e.expect(`]`),e.is(`[`)&&e.fail(`arrays of arrays are not supported`,`arrays of arrays`),t}function CO(e){let t=e.next().value,n=SO(e);return n===null?(e.is(`(`)&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:`var`,name:t}):{type:`index`,name:t,subs:n}}function wO(e){return{type:`call`,name:e.next().value,args:TO(e)}}function TO(e){e.expect(`(`);let t=e.is(`)`)?[]:rO(e,{});return e.expect(`)`),t}function EO(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=rO(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:uO(e)}}function DO(e){let t=e.next().value;if(nh.has(t)&&e.fail(nh.get(t),`${t}()`),!e.is(`(`)){if(t===`length`)return{type:`builtin`,name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=TO(e),[r,i]=th[t];return(n.length<r||n.length>i)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?``:`s`}; it takes ${r===i?r:`${r} to ${i===1/0?`any number`:i}`}`),(t===`sub`||t===`gsub`)&&n[2]&&!tO(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 OO(e,t){e.next();let n=null;(e.tok.type===`name`||e.is(`$`))&&(n=yO(e,t),tO(n)||e.fail(`getline: target must be a variable, field or array element`));let r=null;return e.accept(`<`)&&(r=vO(e,t)),{type:`getline`,target:n,file:r}}var kO=new Set([`/dev/stdout`,`/dev/stderr`,`/dev/null`]),AO=class{constructor(e,t){this.toks=e,this.i=0,this.warnings=t,this.funcs=new Set,this.parens=new Map;let n=[];for(let t=0;t+1<e.length;t++){let r=e[t],i=e[t+1];r.type===`punct`&&(r.value===`(`?n.push(t):r.value===`)`&&n.length>0&&this.parens.set(n.pop(),t)),r.type===`keyword`&&r.value===`function`&&(i.type===`name`||i.type===`funcname`)&&this.funcs.add(i.value)}this.loopDepth=0,this.switchDepth=0,this.context=`main`}get tok(){return this.toks[this.i]}peek(e){return this.toks[Math.min(this.i+e,this.toks.length-1)]}is(e,t=`punct`){return this.tok.type===t&&this.tok.value===e}isKw(e){return this.is(e,`keyword`)}next(){return this.toks[this.i++]}accept(e,t=`punct`){return this.is(e,t)?this.next():null}expect(e,t=`punct`){return this.is(e,t)||this.fail(`expected \`${e}\` but found ${jO(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type===`newline`;)this.i++}skipTerminators(){for(;this.tok.type===`newline`||this.is(`;`);)this.i++}fail(e,t=null,n=`syntax error`){throw new W(e,this.tok.line,t,n)}warn(e){this.warnings.push(e)}unexpected(){this.fail(`unexpected ${jO(this.tok)}`)}};function jO(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 MO={__proto__:null,BEGIN:`begin`,END:`end`,BEGINFILE:`beginFile`,ENDFILE:`endFile`};function NO(e){let t=[],n=new AO(GD(e,e=>t.push(e)),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`),PO(n,r),n.accept(`;`),n.skipNewlines();return r}function PO(e,t){if(e.isKw(`function`)){FO(e,t);return}if(e.tok.type===`keyword`&&e.tok.value in MO){let n=e.next().value;e.is(`{`)||e.fail(`${n} requires an action: ${n} { ... }`),t[MO[n]].push(...IO(e,n.toLowerCase()));return}if(e.is(`{`)){t.rules.push({pattern:null,action:IO(e,`main`)});return}let n=iO(e,{}),r=n;e.accept(`,`)&&(e.skipNewlines(),r={type:`range`,from:n,to:iO(e,{})});let i=e.is(`{`)?IO(e,`main`):null;i===null&&!(e.tok.type===`newline`||e.tok.type===`eof`||e.is(`;`))&&e.unexpected(),t.rules.push({pattern:r,action:i})}function FO(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 ${jO(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect(`(`);let i=[];for(;!e.is(`)`);){let t=e.tok;if(t.type!==`name`&&e.fail(`expected a parameter name but found ${jO(t)}`),(t.value===r||i.includes(t.value))&&e.fail(`duplicate parameter \`${t.value}\` in function \`${r}\``),i.push(e.next().value),!e.accept(`,`))break;e.skipNewlines()}e.expect(`)`),e.skipNewlines(),t.functions.set(r,{params:i,body:IO(e,`function`)})}function IO(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(zO(e)),e.skipTerminators();return e.next(),e.context=n,r}function LO(e){if(e.is(`;`)||e.tok.type===`newline`){e.next();return}e.is(`}`)||e.tok.type===`eof`||e.unexpected()}var RO={__proto__:null,if:HO,while:UO,do:WO,for:GO,switch:KO,break:e=>JO(e,`break`),continue:e=>JO(e,`continue`),next:e=>JO(e,`next`),nextfile:e=>JO(e,`nextfile`),exit:e=>JO(e,`exit`),return:e=>JO(e,`return`),delete:YO,print:e=>ZO(e,`print`),printf:e=>ZO(e,`printf`)};function zO(e){if(e.is(`{`))return{type:`block`,body:IO(e)};if(e.is(`;`))return e.next(),{type:`empty`};let t=e.tok.type===`keyword`?RO[e.tok.value]:void 0;if(t)return t(e);let n=iO(e,{});return LO(e),{type:`expr`,expr:n}}function BO(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=zO(e);return t&&e.loopDepth--,n}function VO(e){e.next(),e.expect(`(`);let t=iO(e,{});return e.expect(`)`),t}function HO(e){let t=VO(e),n=BO(e,!1),r=e.i;return e.skipNewlines(),e.isKw(`else`)?(e.next(),{type:`if`,test:t,consequent:n,alternate:BO(e,!1)}):(e.i=r,{type:`if`,test:t,consequent:n,alternate:null})}function UO(e){return{type:`while`,test:VO(e),body:BO(e,!0)}}function WO(e){e.next();let t=BO(e,!0);e.skipTerminators(),e.isKw(`while`)||e.fail("`do` body must be followed by `while (...)`");let n=VO(e);return LO(e),{type:`do`,body:t,test:n}}function GO(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 t=e.next().value;e.next();let n=e.next().value;return e.next(),{type:`forin`,name:t,array:n,body:BO(e,!0)}}let t=e.is(`;`)?null:iO(e,{});e.expect(`;`),e.skipNewlines();let n=e.is(`;`)?null:iO(e,{});e.expect(`;`),e.skipNewlines();let r=e.is(`)`)?null:iO(e,{});return e.expect(`)`),{type:`for`,init:t,test:n,step:r,body:BO(e,!0)}}function KO(e){let t=VO(e);e.skipNewlines(),e.expect(`{`);let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is(`}`);e.skipTerminators()){let t=null;e.accept(`case`,`keyword`)?t=qO(e):e.accept(`default`,`keyword`)||e.fail(`expected \`case\` or \`default\` in switch body but found ${jO(e.tok)}`);let i=t===null?`default`:t.type===`regex`?`/${t.source}/`:String(t.value);r.has(i)&&e.fail(`duplicate case values in switch body: ${i}`),r.add(i),e.expect(`:`);let a=[];for(e.skipTerminators();!e.is(`}`)&&!e.isKw(`case`)&&!e.isKw(`default`);)e.tok.type===`eof`&&e.fail("missing `}` at end of program"),a.push(zO(e)),e.skipTerminators();n.push({test:t,body:a})}return e.switchDepth--,e.next(),{type:`switch`,expr:t,cases:n}}function qO(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:jh(n.value,!1,t=>e.warn(t))}):e.fail(`case value must be a number, string or regex constant, found ${jO(n)}`)}function JO(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=nO(e)?iO(e,{}):null),LO(e),n}function YO(e){e.next(),e.tok.type!==`name`&&e.fail(`\`delete\` needs an array name but found ${jO(e.tok)}`);let t=e.next().value,n=SO(e);return LO(e),{type:`delete`,name:t,subs:n}}var XO=e=>e.is(`;`)||e.is(`}`)||e.is(`>`)||e.is(`>>`)||e.is(`|`)||e.is(`|&`)||e.tok.type===`newline`||e.tok.type===`eof`;function ZO(e,t){e.next();let n=null;if(e.is(`(`)){let t=e.i;e.next();let r=e.is(`)`)?[]:rO(e,{});e.accept(`)`)&&XO(e)?n=r:e.i=t}n===null&&(n=XO(e)?[]:rO(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: ${sh}`,`${t} | "cmd"`),(e.accept(`>`)||e.accept(`>>`))&&(r=pO(e,{noGt:!0}),r.type===`str`&&!kO.has(r.value)&&e.fail(QO(r.value),`${t} > FILE`)),LO(e),{type:t,args:n,dest:r}}function QO(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 X=class{constructor(e){this.s=e,this.number=void 0,this.numeric=void 0}},$O=`[ \\t\\n\\r\\f\\v]*`,ek=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?`,tk=RegExp(`^${$O}${ek}${$O}$`,`u`),nk=RegExp(`^${$O}(${ek})`,`u`),rk=RegExp(`^${$O}([+-])(inf|nan)${$O}$`,`iu`),ik=e=>tk.test(e)||rk.test(e);function ak(e){let t=nk.exec(e);if(t)return Number(t[1]);let n=rk.exec(e);return n?n[2].toLowerCase()===`nan`?NaN:n[1]===`-`?-1/0:1/0:0}var ok=()=>new W(`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 X)return e.number??=ak(e.s);if(typeof e==`string`)return ak(e);throw ok()}var sk=new Map;function ck(e,t){if(Number.isNaN(e))throw new W(`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=sk.get(t);if(n===void 0){sk.size>64&&sk.clear(),n=HS(t);let e=n.filter(e=>typeof e!=`string`);if(e.length>1||e.some(e=>!`diouxXeEfFgG`.includes(e.conv)||e.width===`*`||e.precision===`*`))throw new W(`this numeric conversion format is not supported`,null,`numeric conversion format`);sk.set(t,n)}return n.map(t=>typeof t==`string`?t:KS(e,t)).join(``)}var lk=e=>typeof e==`string`?e:e instanceof X?e.s:`%.6g`,uk=e=>lk(e.globals.get(`CONVFMT`)),dk=e=>lk(e.globals.get(`OFMT`));function Q(e,t){if(typeof e==`string`)return fk(t,e);if(e instanceof X)return fk(t,e.s);if(typeof e==`number`)return ck(e,uk(t));if(e===void 0)return``;throw ok()}function fk(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new W(`non-ASCII AWK text in a byte locale is not supported`,null,`byte locale text`);return t}function pk(e,t=!1){return[...e].map(e=>{let n=t?e.toUpperCase():e.toLowerCase();if([...n].length!==1)throw new W(`Unicode case expansion is not supported`,null,`Unicode case mapping`);return n}).join(``)}function mk(e,t){return typeof e==`number`?ck(e,dk(t)):Q(e,t)}var hk=e=>e.numeric??=ik(e.s),gk=e=>typeof e==`number`||e===void 0||e instanceof X&&hk(e),_k=e=>yk(e.globals.get(`IGNORECASE`));function vk(e,t,n){if(gk(e)&&gk(t)){let n=Z(e),r=Z(t);return n<r?-1:n>r?1:n===r?0:NaN}let r=Q(e,n),i=Q(t,n);return _k(n)&&(r=pk(r),i=pk(i)),j(r,i)}function yk(e){if(typeof e==`number`)return e!==0&&!Number.isNaN(e);if(typeof e==`string`)return e!==``;if(e instanceof X)return hk(e)?Z(e)!==0:e.s!==``;if(e===void 0)return!1;throw ok()}var bk=(e,t)=>Number.isSafeInteger(e)?String(e):Q(e,t);function xk(e){return e instanceof Map?`array`:e===void 0?`untyped`:typeof e==`number`?`number`:e instanceof X&&hk(e)?`strnum`:`string`}function Sk(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t===``)return Ck(e);let i,a;if(t.length===1){let n=r.indexOf(t,e.pos);a=n===-1?r.length:n,i=n===-1?r.length:n+1}else{let o=Mh(r,jh(t,n),e.pos);a=o?.start??r.length,i=o?.end??r.length}let o=r.slice(e.pos,a);return e.pos=i,{rec:o,rt:r.slice(a,i)}}function Ck(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 i=r.exec(t);if(!i){e.pos=t.length;let r=t.slice(n).replace(/\n+$/u,``);return{rec:r,rt:t.slice(n+r.length)}}return e.pos=i.index+i[0].length,{rec:t.slice(n,i.index),rt:i[0]}}function wk(e,t,n,r){if(e===``)return[];if(t instanceof kh)return Nh(e,t);if(t===` `){let t=e.replace(/^[ \t\n]+|[ \t\n]+$/gu,``);return t===``?[]:t.split(/[ \t\n]+/u)}if(t===``)return[...e];if(t.length===1&&(!n||t===`
333
- `))return e.split(t);if(n&&t===`^`)throw new W(`paragraph splitting with FS="^" is not supported`,null,`paragraph FS caret`);return Nh(e,jh(t.length===1?`[${`^$.[]|()*+?{}\\`.includes(t)?`\\`+t:t}
334
- ]`:t,r))}function Tk(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let i=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),a=i?.[1]===void 0?0:Number(i[1]),o=i?.[2]===`*`?4294967295:Number(i?.[2]);if(!i||i[1]!==void 0&&a===0||a>4294967295||!(o>0&&o<=4294967295)||i[2]===`*`&&r!==t.length-1)throw new W(`invalid FIELDWIDTHS value \`${e}'`);return{skip:a,width:o}})}function Ek(e,t){let n=[...e],r=[],i=0;for(let{skip:e,width:a}of t){if(i>=n.length)break;i+=e,r.push(n.slice(i,i+a).join(``)),i+=a}return r}function Dk(e,t){let n=[],r=0;for(;r<e.length;){let i=t.search(e.slice(r));if(n.length>0&&i?.end===0&&(r+=Rr(e,r),i=t.search(e.slice(r))),!i)break;n.push(e.slice(r+i.start,r+i.end)),r+=i.end}return n}function Ok(e,t){let n=_k(e);return e.fieldMode===`FIELDWIDTHS`?Ek(t,e.widths):e.fieldMode===`FPAT`?Dk(t,jh(Q(e.globals.get(`FPAT`),e),n,e.warn)):wk(t,Q(e.globals.get(`FS`),e),Q(e.globals.get(`RS`),e)===``,n)}var kk=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,Ak=e=>e!==void 0&&e.type===`exit`,jk=class{constructor(e,t){this.ctx=e,this.stdin=t,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(e){for(;this.exitSignal===void 0;){if(this.src){let t=Sk(this.src,Q(e.globals.get(`RS`),e),_k(e));if(t!==null)return e.globals.set(`NR`,Z(e.globals.get(`NR`))+1),e.globals.set(`FNR`,Z(e.globals.get(`FNR`))+1),e.globals.set(`RT`,t.rt),t.rec;this.closeFile(e);continue}if(!this.open(e))return null}return null}open(e){for(;this.idx<Math.trunc(Z(e.globals.get(`ARGC`)));){if(++e.steps>ih)throw new W(`input operand scan exceeded execution limit`,null,`execution limit`);let t=Q(e.globals.get(`ARGV`).get(String(this.idx++)),e);if(t===``)continue;e.globals.set(`ARGIND`,this.idx-1);let n=kk.exec(t);if(n){e.assign(n[1],new X(ZD(n[2],e.warn)));continue}this.sawFile=!0;let{text:r,error:i}=this.readOperand(t);if(i===`Is a directory`){this.failFile(e,t,i),this.exitSignal===void 0&&e.warn(`command line argument \`${t}' is a directory: skipped`);continue}if(i){let n=this.failFile(e,t,i);if(n!==void 0&&n.type===`nextfile`)continue;if(this.exitSignal!==void 0)return!1;throw new W(`${t}: ${i}`)}if(this.use(e,t,r))return!0}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(e,`-`,this.takeStdin()))}readOperand(e){if(e===`/dev/null`)return{text:``};if(e===`-`||e===`/dev/stdin`)return{text:e===`/dev/stdin`&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:t,error:n}=N(this.ctx,`awk`,e);return this.ctx.fs.isDir(t)?{error:`Is a directory`}:n?{error:n}:{text:this.ctx.fs.readFile(t)}}takeStdin(){let e=this.stdin;return this.stdin=``,F(this.ctx),e}use(e,t,n){this.src={text:n,pos:0},e.globals.set(`FILENAME`,t),e.globals.set(`FNR`,0),e.globals.set(`ERRNO`,``);let r=e.fileRule(`begin`);return Ak(r)?(this.exitSignal=r,this.src=null,!1):r!==void 0&&r.type===`nextfile`?(this.closeFile(e),!1):(fk(e,n),!0)}failFile(e,t,n){if(e.globals.set(`ERRNO`,n),!e.hasFileRules)return;e.globals.set(`FILENAME`,t),e.globals.set(`FNR`,0);let r=e.fileRule(`begin`);return Ak(r)&&(this.exitSignal=r),r}closeFile(e){this.src=null;let t=e.fileRule(`end`);Ak(t)&&(this.exitSignal=t)}readNamed(e,t){let n=this.readers.get(t);if(!n){let{text:r,error:i}=this.readOperand(t);if(i)return e.globals.set(`ERRNO`,i),{status:-1};n={text:fk(e,r),pos:0},this.readers.set(t,n)}let r=Sk(n,Q(e.globals.get(`RS`),e),_k(e));return r===null?{status:0}:(e.globals.set(`RT`,r.rt),{status:1,record:r.rec})}close(e,t){return this.readers.delete(t)?0:(e.globals.set(`ERRNO`,`close of redirection that was never opened`),-1)}},Mk=(e,t)=>({isRef:!0,scope:e,name:t}),Nk=e=>typeof e==`object`&&!!e&&e.isRef===!0,Pk=class extends Error{constructor(e){super(e.type),this.signal=e}},Fk=e=>new W(`attempt to use array \`${e}\` in a scalar context`);function Ik(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function Lk(e){let t=e;for(;Nk(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function Rk(e,t){let n=Ik(e,t).get(t);return Nk(n)?Lk(n):n}var zk=new Set([`FS`,`FIELDWIDTHS`,`FPAT`]);function Bk(e,t,n){let r=Ik(e,t);if(r.get(t)instanceof Map)throw Fk(t);if(r===e.globals){if(t===`NF`){Kk(e,n);return}if(t===`FIELDWIDTHS`&&(e.widths=Tk(Q(n,e))),(t===`FPAT`||(t===`FS`||t===`RS`)&&Q(n,e).length>1)&&jh(Q(n,e),_k(e),e.warn,e.tables),zk.has(t)){e.fieldMode=t;let n=e.globals.get(`PROCINFO`);n instanceof Map&&n.set(`FS`,t)}}r.set(t,n)}function Vk(e,t){let n=Ik(e,t),r=t,i=n,a=i.get(r);if(a instanceof Map)return a;let o=Nk(a);for(;Nk(a);)i=a.scope,r=a.name,a=i.get(r);if(!(a instanceof Map)){if(a!==void 0)throw new W(`attempt to use scalar \`${r}\` as an array`);a=new Map,i.set(r,a)}return o&&n.set(t,a),a}function Hk(e,t,n=new X(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...Ok(e,t).map(e=>new X(e))],e.nf=e.fields.length-1,e.globals.set(`NF`,e.nf)}function Uk(e){let t=Q(e.globals.get(`OFS`),e);e.record=e.fields.slice(1).map(t=>Q(t,e)).join(t),e.recordValue=e.record}function Wk(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function Gk(e,t,n){if(t===0){let t=Q(n,e);Hk(e,t,typeof n==`number`?t:n);return}for(;e.nf<t;)e.fields[++e.nf]=``;e.fields[t]=n,e.globals.set(`NF`,e.nf),Uk(e)}function Kk(e,t){let n=Math.trunc(Z(t));if(n<0)throw new W(`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),Uk(e)}function qk(e,t){let n=Z($(e,t));if(!(n>=0))throw new W(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function Jk(e,t){if(t.length===1)return bk($(e,t[0]),e);let n=Q(e.globals.get(`SUBSEP`),e);return t.map(t=>bk($(e,t),e)).join(n)}function Yk(e,t){return t.type===`var`?t:t.type===`index`?{type:`index`,arr:Vk(e,t.name),key:Jk(e,t.subs)}:{type:`field`,i:qk(e,t.index)}}function Xk(e,t){return t.type===`var`?nA(Rk(e,t.name),t.name):t.type===`index`?t.arr.get(t.key):Wk(e,t.i)}function Zk(e,t,n){t.type===`var`?Bk(e,t.name,n):t.type===`index`?t.arr.set(t.key,n):Gk(e,t.i,n)}function Qk(e,t,n){Zk(e,Yk(e,t),n)}function $k(e,t,n){if(n===0&&(e===`/`||e===`%`))throw new W(e===`/`?`division by zero attempted`:"division by zero attempted in `%`");return ch(e,t,n)}var eA={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function tA(e,t){let n=_k(e);return t.type===`regex`?n?jh(t.source,!0,null,e.tables):t.re:jh(Q($(e,t),e),n,e.warn,e.tables)}function nA(e,t){if(e instanceof Map)throw Fk(t);return e}function rA(e,t,n){let r=Yk(e,t.target),i=Z(Xk(e,r)),a=t.op===`++`?i+1:i-1;return Zk(e,r,a),n?i:a}function $(e,t){switch(t.type){case`num`:case`str`:return t.value;case`regex`:return+!!tA(e,t).test(e.record);case`var`:return nA(Rk(e,t.name),t.name);case`index`:{let n=Vk(e,t.name),r=Jk(e,t.subs),i=n.get(r);return i===void 0&&n.set(r,void 0),i}case`field`:return Wk(e,qk(e,t.index));case`assign`:{let n=Yk(e,t.target),r=$(e,t.value);if(r instanceof Map)throw new W(`attempt to use an array in a scalar context`);return t.op!==`=`&&(r=$k(t.op[0],Z(Xk(e,n)),Z(r))),Zk(e,n,r),r}case`cond`:return $(e,yk($(e,t.test))?t.consequent:t.alternate);case`or`:return yk($(e,t.left))||yk($(e,t.right))?1:0;case`and`:return yk($(e,t.left))&&yk($(e,t.right))?1:0;case`not`:return+!yk($(e,t.expr));case`neg`:return-Z($(e,t.expr));case`plus`:return Z($(e,t.expr));case`binary`:return $k(t.op,Z($(e,t.left)),Z($(e,t.right)));case`concat`:return Q($(e,t.left),e)+Q($(e,t.right),e);case`compare`:return+!!eA[t.op](vk($(e,t.left),$(e,t.right),e));case`match`:{let n=Q($(e,t.left),e);return tA(e,t.right).test(n)===t.negate?0:1}case`in`:return+!!Vk(e,t.array).has(Jk(e,t.keys));case`preinc`:return rA(e,t,!1);case`postinc`:return rA(e,t,!0);case`call`:return iA(e,t);case`builtin`:return e.callBuiltin(e,t);case`getline`:return oA(e,t);default:throw new W(`unknown expression: ${t.type}`)}}function iA(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new W(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new W(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=ah)throw new W(`function call nesting deeper than ${ah} levels (runaway recursion?)`,null,`call depth limit`);let r=e.frame,i=new Map;for(let r=0;r<n.params.length;r++)i.set(n.params[r],r<t.args.length?aA(e,t.args[r]):void 0);e.frame=i,e.callDepth++;try{let t=e.execStmts(e,n.body);if(t===void 0||t.type===`return`)return t?.value;throw new Pk(t)}finally{e.frame=r,e.callDepth--}}function aA(e,t){if(t.type!==`var`)return $(e,t);let n=Ik(e,t.name),r=n.get(t.name);return r instanceof Map||Nk(r)?r:r===void 0?Mk(n,t.name):r}function oA(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,Q($(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?Hk(e,n):Qk(e,t.target,new X(n)),1}var sA=(e,t)=>Z($(e,t)),cA=2**32;function lA(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var uA=()=>({seed:1,state:lA(1)});function dA(e){e.rng.state=(e.rng.state+1831565813)%cA;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+cA:n)/cA}function fA(e,t){let n=e.rng.seed,r=t.length>0?sA(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=lA(r),n}function pA(e,t){let n=sA(e,t[0]);return n<0&&e.warn(`log: received negative argument ${Q(n,e)}`),Math.log(n)}function mA(e,t){let n=sA(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${Q(n,e)}`),Math.sqrt(n)}function hA(e,t){let n=sA(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${Q(n,e)} is out of range`),r}function gA(e,t){let n=$(e,t[0]);if(typeof n==`number`)return n;let r=n instanceof X?n.s:Q(n,e),i=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(i)return i[1]===``?0:Number.parseInt(i[1],16);let a=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return a?Number.parseInt(a[0],8):Z(new X(r))}function _A(e,t,n,r){let i=sA(e,n);if(i<0)throw new W(`${t}: argument ${r} negative value ${Q(i,e)} is not allowed`);if(!Number.isFinite(i))throw new W(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(i)))}function vA(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function yA(e,t){return(n,r)=>{if(r.length<2)throw new W(`${e}: called with less than two arguments`);let i=_A(n,e,r[0],1);for(let a=1;a<r.length;a++)i=t(i,_A(n,e,r[a],a+1));return vA(i)}}function bA(e,t){return(n,r)=>{let i=_A(n,e,r[0],1),a=_A(n,e,r[1],2)%64n;return vA(BigInt.asUintN(64,t?i<<a:i>>a))}}var xA={__proto__:null,sin:(e,t)=>Math.sin(sA(e,t[0])),cos:(e,t)=>Math.cos(sA(e,t[0])),atan2:(e,t)=>Math.atan2(sA(e,t[0]),sA(e,t[1])),exp:hA,log:pA,sqrt:mA,int:(e,t)=>Math.trunc(sA(e,t[0])),rand:dA,srand:fA,systime:()=>Math.floor(Date.now()/1e3),strtonum:gA,and:yA(`and`,(e,t)=>e&t),or:yA(`or`,(e,t)=>e|t),xor:yA(`xor`,(e,t)=>e^t),lshift:bA(`lshift`,!0),rshift:bA(`rshift`,!1),compl:(e,t)=>vA(BigInt.asUintN(64,~_A(e,`compl`,t[0],1)))},SA=new Map;function CA(e){let t=SA.get(e);return t||(SA.size>=256&&SA.clear(),t=HS(e),SA.set(e,t)),t}function wA(e,t,n){let r=0,i=()=>{if(r>=n.length)throw new W(`printf: not enough arguments to satisfy format string`);return n[r++]},a=``;for(let n of CA(t)){if(typeof n==`string`){a+=n;continue}let t={...n};if(n.width===`*`){let e=Math.trunc(Z(i()));e<0?(t.minus=!0,t.width=-e):t.width=e}if(n.precision===`*`){let e=Math.trunc(Z(i()));t.precision=e<0?null:e}if(t.width>oh||t.precision>oh)throw new W(`printf: field width or precision above ${oh} is not supported`,null,`format size limit`);a+=TA(e,t,i())}return a}function TA(e,t,n){if(t.conv===`s`){let r=Q(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join(``)),US(``,r,t,!1)}return t.conv===`c`?US(``,fk(e,EA(n)),t,!1):KS(Z(n),t)}function EA(e){if(typeof e==`number`||e instanceof X&&ik(e.s)){let t=Math.trunc(Z(e));if(!Ir(t))throw new W(`printf: character code outside Unicode scalar values is not supported`,null,`character code`);return String.fromCodePoint(t)}let t=e instanceof X?e.s:e??``;return t===``?`\0`:String.fromCodePoint(t.codePointAt(0))}var DA=(e,t)=>Q($(e,t),e),OA=(e,t)=>Z($(e,t)),kA={type:`field`,index:{type:`num`,value:0}};function AA(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`){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+=i===`&`?t:i}return n}function jA(e,t,n){let r=tA(e,t[0]),i=DA(e,t[1]),a=t[2]??kA,o=DA(e,a),{out:s,count:c}=Ph(o,r,(e,t)=>AA(i,o.slice(e,t)),n?`global`:`first`);return c>0&&Qk(e,a,s),c}function MA(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`&&r+1===e.length)throw new W(`gensub with a trailing replacement backslash is not supported`,null,`gensub trailing backslash`);if(i===`\\`&&r+1<e.length){let i=e[++r];n+=i>=`0`&&i<=`9`?t[Number(i)]?.text??``:i;continue}n+=i===`&`?t[0].text:i}return n}function NA(e,t){let n=tA(e,t[0]),r=DA(e,t[1]),i=$(e,t[2]),a=Q(i,e),o=a.startsWith(`g`)||a.startsWith(`G`),s=0;o||(s=Math.trunc(Z(i)),s<1&&(e.warn(`gensub: third argument \`${a}' treated as 1`),s=1));let c=t[3]?DA(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return Ph(c,n,(e,t,i)=>!o&&i!==s?null:MA(r,l?n.groups(c,e,t):[{text:c.slice(e,t)}]),o?`global`:`nth`).out}function PA(e,t){let n=DA(e,t[0]),r=tA(e,t[1]),i=r.search(n,0),a=i?Array.from(n.slice(0,i.start)).length+1:0;if(e.globals.set(`RSTART`,a),e.globals.set(`RLENGTH`,i?Array.from(n.slice(i.start,i.end)).length:-1),t[2]){let a=Vk(e,t[2].name);if(a.clear(),i){let t=Q(e.globals.get(`SUBSEP`),e);r.groups(n,i.start,i.end).forEach((e,r)=>{e!==void 0&&(a.set(String(r),new X(e.text)),a.set(`${r}${t}start`,Array.from(n.slice(0,e.start)).length+1),a.set(`${r}${t}length`,[...e.text].length))})}}return a}function FA(e,t){let n=DA(e,t[0]),r=Vk(e,t[1].name),i;i=t[2]===void 0?Q(e.globals.get(`FS`),e):t[2].type===`regex`?tA(e,t[2]):DA(e,t[2]);let a=wk(n,i,!1,_k(e));return r.clear(),a.forEach((e,t)=>r.set(String(t+1),new X(e))),a.length}function IA(e,t){let n=[...DA(e,t[0])],r=Math.trunc(OA(e,t[1])),i=Number.isNaN(r)?1:Math.max(r,1),a=n.length+1;if(t[2]){let n=Math.trunc(OA(e,t[2]));if(!(n>=1))return``;a=Math.min(a,i+n)}return a>i?n.slice(i-1,a-1).join(``):``}function LA(e,t){if(t.length===0)return[...e.record].length;if(t[0].type===`var`){let n=Rk(e,t[0].name);return n instanceof Map?n.size:[...Q(n,e)].length}return[...DA(e,t[0])].length}function RA(e,t){let n=DA(e,t[0]),r=DA(e,t[1]);_k(e)&&(n=pk(n),r=pk(r));let i=n.indexOf(r);return i<0?0:Array.from(n.slice(0,i)).length+1}function zA(e,t){let n=DA(e,t[0]);return n===`/dev/stdout`||n===`/dev/stderr`||n===`/dev/null`?0:e.input.close(e,n)}var BA=(e,t)=>t[0].type===`var`?xk(Rk(e,t[0].name)):xk($(e,t[0])),VA={__proto__:null,...xA,length:LA,substr:IA,index:RA,split:FA,sub:(e,t)=>jA(e,t,!1),gsub:(e,t)=>jA(e,t,!0),gensub:NA,match:PA,sprintf:(e,t)=>wA(e,DA(e,t[0]),t.slice(1).map(t=>$(e,t))),tolower:(e,t)=>pk(DA(e,t[0])),toupper:(e,t)=>pk(DA(e,t[0]),!0),close:zA,fflush:()=>0,typeof:BA,isarray:(e,t)=>+(t[0].type===`var`&&Rk(e,t[0].name)instanceof Map)};function HA(e,t){let n=VA[t.name];if(!n)throw new W(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var UA={type:`break`},WA={type:`continue`},GA={type:`next`},KA={type:`nextfile`},qA={type:`exit`};function JA(e,t,n,r){let i=new Map([[`0`,`awk`]]);r.forEach((e,t)=>i.set(String(t+1),new X(e)));let a={program:e,globals:new Map([[`FS`,` `],[`OFS`,` `],[`ORS`,`
330
+ `){a+=2;continue}}if(t===`\\`){let t=ZD(e,a,n);tO(i,t),a=t.end}else{let t=String.fromCodePoint(e.codePointAt(a));tO(i,{text:t}),a+=t.length}}if(r!==null)throw new W(`unterminated string`,r);return{value:D(Uint8Array.from(i)),end:a}}function $D(e,t,n){let r=t,i=!1;for(;r<e.length;){let n=e[r];if(n===`
331
+ `)break;if(n===`\\`){r+=2;continue}if(i){if(n===`[`&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){r=t+2;continue}}n===`]`&&(i=!1),r++;continue}if(n===`[`){i=!0,r++,e[r]===`^`&&r++,e[r]===`]`&&r++;continue}if(n===`/`)return{value:e.slice(t,r),end:r+1};r++}throw new W(`unterminated regexp`,n)}function eO(e,t=null){return QD(e,0,t).value}function tO(e,t){if(t.byte===void 0)for(let n of p(t.text))e.push(n);else e.push(t.byte)}var nO=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`^=`,`**=`]),rO=new Set([`<`,`<=`,`==`,`!=`,`>`,`>=`]),iO=e=>e.type===`var`||e.type===`index`||e.type===`field`;function aO(e){let t=e.tok;return hO(e)||t.type===`regex`||t.type===`keyword`&&t.value===`getline`||t.type===`punct`&&[`!`,`-`,`+`].includes(t.value)}function oO(e,t){let n=[sO(e,t)];for(;e.accept(`,`);)e.skipNewlines(),n.push(sO(e,t));return n}function sO(e,t){let n=cO(e,t),r=e.tok;if(r.type===`punct`&&nO.has(r.value)){iO(n)||e.fail(`cannot assign to ${n.type===`regex`?`a regex`:`a non-variable`} (left side of \`${r.value}\`)`),e.next();let i=sO(e,t);return{type:`assign`,op:r.value===`**=`?`^=`:r.value,target:n,value:i}}return n}function cO(e,t){let n=fO(e,t);if(!e.accept(`?`))return n;e.skipNewlines();let r=sO(e,t);return e.skipNewlines(),e.expect(`:`),e.skipNewlines(),{type:`cond`,test:n,consequent:r,alternate:sO(e,t)}}var lO=[[`or`,[`||`]],[`and`,[`&&`]],[`in`,[`in`]],[`match`,[`~`,`!~`]],[`compare`,[...rO]],[`concat`,[]],[`binary`,[`+`,`-`]],[`binary`,[`*`,`/`,`%`]]],uO=new Map(lO.flatMap(([e,t],n)=>t.map(t=>[t,{type:e,precedence:n}]))),dO={type:`concat`,precedence:5};function fO(e,t,n=0){let r=yO(e,t),i=1/0;for(;;){let a=e.tok;n<=4&&i>4&&!t.noGt&&(e.is(`|`)||e.is(`|&`))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${uh}`,`"cmd" | getline`);let o=hO(e)?dO:a.type===`punct`||a.type===`keyword`&&a.value===`in`?uO.get(a.value):void 0;if(!o||o.precedence<n||o.precedence>i||t.noGt&&e.is(`>`))return r;let{type:s,precedence:c}=o,l=s===`concat`?null:e.next().value;if(i=c,(s===`or`||s===`and`)&&e.skipNewlines(),s===`in`){r={type:s,keys:[r],array:pO(e)};continue}let u=fO(e,t,c+1);(l===`/`||l===`%`)&&_O(u)===0&&_O(r)!==null&&e.fail(l===`/`?`division by zero attempted`:"division by zero attempted in `%`",null,`error`),s===`compare`&&mO(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),r=s===`binary`||s===`compare`?{type:s,op:l,left:r,right:u}:s===`match`?{type:s,negate:l===`!~`,left:r,right:u}:{type:s,left:r,right:u}}}function pO(e){return e.tok.type!==`name`&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var mO=(e,t)=>e.tok.type===`punct`&&rO.has(e.tok.value)&&!(t.noGt&&e.tok.value===`>`);function hO(e){let t=e.tok;return t.type===`number`||t.type===`string`||t.type===`name`||t.type===`funcname`||t.type===`builtin`||t.type===`punct`&&[`$`,`(`,`++`,`--`].includes(t.value)}function gO(e,t){return fO(e,t,5)}function _O(e){if(e.type===`num`)return e.value;if(e.type===`neg`||e.type===`plus`){let t=_O(e.expr);return t===null?null:e.type===`neg`?-t:t}if(e.type!==`binary`)return null;let t=_O(e.left),n=_O(e.right);return t===null||n===null?null:dh(e.op,t,n)}var vO={__proto__:null,"!":`not`,"-":`neg`,"+":`plus`};function yO(e,t,n=!1){if(n&&(e.is(`$`)||e.is(`++`)||e.is(`--`)))return SO(e,t);let r=e.tok.type===`punct`&&vO[e.tok.value];return r?(e.next(),{type:r,expr:yO(e,t,n)}):n?CO(e,t):bO(e,t)}function bO(e,t){let n=xO(e,t);return!e.is(`^`)&&!e.is(`**`)?n:(e.next(),{type:`binary`,op:`^`,left:n,right:yO(e,t)})}function xO(e,t){let n=SO(e,t);for(;(e.is(`++`)||e.is(`--`))&&iO(n);)n={type:`postinc`,op:e.next().value,target:n};return n}function SO(e,t){if(e.accept(`$`))return{type:`field`,index:yO(e,t,!0)};if(e.is(`++`)||e.is(`--`)){let n=e.next().value,r=SO(e,t);return iO(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:`preinc`,op:n,target:r}}return CO(e,t)}function CO(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:wO(e,n.value)};case`name`:return EO(e);case`funcname`:return DO(e);case`builtin`:return AO(e);case`keyword`:return n.value===`getline`?jO(e,t):e.unexpected();case`punct`:return n.value===`(`?kO(e):e.unexpected();default:return e.unexpected()}}function wO(e,t){try{return Ph(t,!1,t=>e.warn(t))}catch(t){return e.fail(t.message,t.gap??null)}}function TO(e){if(!e.accept(`[`))return null;let t=oO(e,{});return e.expect(`]`),e.is(`[`)&&e.fail(`arrays of arrays are not supported`,`arrays of arrays`),t}function EO(e){let t=e.next().value,n=TO(e);return n===null?(e.is(`(`)&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:`var`,name:t}):{type:`index`,name:t,subs:n}}function DO(e){return{type:`call`,name:e.next().value,args:OO(e)}}function OO(e){e.expect(`(`);let t=e.is(`)`)?[]:oO(e,{});return e.expect(`)`),t}function kO(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=oO(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:pO(e)}}function AO(e){let t=e.next().value;if(ah.has(t)&&e.fail(ah.get(t),`${t}()`),!e.is(`(`)){if(t===`length`)return{type:`builtin`,name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=OO(e),[r,i]=ih[t];return(n.length<r||n.length>i)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?``:`s`}; it takes ${r===i?r:`${r} to ${i===1/0?`any number`:i}`}`),(t===`sub`||t===`gsub`)&&n[2]&&!iO(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 jO(e,t){e.next();let n=null;(e.tok.type===`name`||e.is(`$`))&&(n=SO(e,t),iO(n)||e.fail(`getline: target must be a variable, field or array element`));let r=null;return e.accept(`<`)&&(r=xO(e,t)),{type:`getline`,target:n,file:r}}var MO=new Set([`/dev/stdout`,`/dev/stderr`,`/dev/null`]),NO=class{constructor(e,t){this.toks=e,this.i=0,this.warnings=t,this.funcs=new Set,this.parens=new Map;let n=[];for(let t=0;t+1<e.length;t++){let r=e[t],i=e[t+1];r.type===`punct`&&(r.value===`(`?n.push(t):r.value===`)`&&n.length>0&&this.parens.set(n.pop(),t)),r.type===`keyword`&&r.value===`function`&&(i.type===`name`||i.type===`funcname`)&&this.funcs.add(i.value)}this.loopDepth=0,this.switchDepth=0,this.context=`main`}get tok(){return this.toks[this.i]}peek(e){return this.toks[Math.min(this.i+e,this.toks.length-1)]}is(e,t=`punct`){return this.tok.type===t&&this.tok.value===e}isKw(e){return this.is(e,`keyword`)}next(){return this.toks[this.i++]}accept(e,t=`punct`){return this.is(e,t)?this.next():null}expect(e,t=`punct`){return this.is(e,t)||this.fail(`expected \`${e}\` but found ${PO(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type===`newline`;)this.i++}skipTerminators(){for(;this.tok.type===`newline`||this.is(`;`);)this.i++}fail(e,t=null,n=`syntax error`){throw new W(e,this.tok.line,t,n)}warn(e){this.warnings.push(e)}unexpected(){this.fail(`unexpected ${PO(this.tok)}`)}};function PO(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 FO={__proto__:null,BEGIN:`begin`,END:`end`,BEGINFILE:`beginFile`,ENDFILE:`endFile`};function IO(e){let t=[],n=new NO(JD(e,e=>t.push(e)),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`),LO(n,r),n.accept(`;`),n.skipNewlines();return r}function LO(e,t){if(e.isKw(`function`)){RO(e,t);return}if(e.tok.type===`keyword`&&e.tok.value in FO){let n=e.next().value;e.is(`{`)||e.fail(`${n} requires an action: ${n} { ... }`),t[FO[n]].push(...zO(e,n.toLowerCase()));return}if(e.is(`{`)){t.rules.push({pattern:null,action:zO(e,`main`)});return}let n=sO(e,{}),r=n;e.accept(`,`)&&(e.skipNewlines(),r={type:`range`,from:n,to:sO(e,{})});let i=e.is(`{`)?zO(e,`main`):null;i===null&&!(e.tok.type===`newline`||e.tok.type===`eof`||e.is(`;`))&&e.unexpected(),t.rules.push({pattern:r,action:i})}function RO(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 ${PO(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect(`(`);let i=[];for(;!e.is(`)`);){let t=e.tok;if(t.type!==`name`&&e.fail(`expected a parameter name but found ${PO(t)}`),(t.value===r||i.includes(t.value))&&e.fail(`duplicate parameter \`${t.value}\` in function \`${r}\``),i.push(e.next().value),!e.accept(`,`))break;e.skipNewlines()}e.expect(`)`),e.skipNewlines(),t.functions.set(r,{params:i,body:zO(e,`function`)})}function zO(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(HO(e)),e.skipTerminators();return e.next(),e.context=n,r}function BO(e){if(e.is(`;`)||e.tok.type===`newline`){e.next();return}e.is(`}`)||e.tok.type===`eof`||e.unexpected()}var VO={__proto__:null,if:GO,while:KO,do:qO,for:JO,switch:YO,break:e=>ZO(e,`break`),continue:e=>ZO(e,`continue`),next:e=>ZO(e,`next`),nextfile:e=>ZO(e,`nextfile`),exit:e=>ZO(e,`exit`),return:e=>ZO(e,`return`),delete:QO,print:e=>ek(e,`print`),printf:e=>ek(e,`printf`)};function HO(e){if(e.is(`{`))return{type:`block`,body:zO(e)};if(e.is(`;`))return e.next(),{type:`empty`};let t=e.tok.type===`keyword`?VO[e.tok.value]:void 0;if(t)return t(e);let n=sO(e,{});return BO(e),{type:`expr`,expr:n}}function UO(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=HO(e);return t&&e.loopDepth--,n}function WO(e){e.next(),e.expect(`(`);let t=sO(e,{});return e.expect(`)`),t}function GO(e){let t=WO(e),n=UO(e,!1),r=e.i;return e.skipNewlines(),e.isKw(`else`)?(e.next(),{type:`if`,test:t,consequent:n,alternate:UO(e,!1)}):(e.i=r,{type:`if`,test:t,consequent:n,alternate:null})}function KO(e){return{type:`while`,test:WO(e),body:UO(e,!0)}}function qO(e){e.next();let t=UO(e,!0);e.skipTerminators(),e.isKw(`while`)||e.fail("`do` body must be followed by `while (...)`");let n=WO(e);return BO(e),{type:`do`,body:t,test:n}}function JO(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 t=e.next().value;e.next();let n=e.next().value;return e.next(),{type:`forin`,name:t,array:n,body:UO(e,!0)}}let t=e.is(`;`)?null:sO(e,{});e.expect(`;`),e.skipNewlines();let n=e.is(`;`)?null:sO(e,{});e.expect(`;`),e.skipNewlines();let r=e.is(`)`)?null:sO(e,{});return e.expect(`)`),{type:`for`,init:t,test:n,step:r,body:UO(e,!0)}}function YO(e){let t=WO(e);e.skipNewlines(),e.expect(`{`);let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is(`}`);e.skipTerminators()){let t=null;e.accept(`case`,`keyword`)?t=XO(e):e.accept(`default`,`keyword`)||e.fail(`expected \`case\` or \`default\` in switch body but found ${PO(e.tok)}`);let i=t===null?`default`:t.type===`regex`?`/${t.source}/`:String(t.value);r.has(i)&&e.fail(`duplicate case values in switch body: ${i}`),r.add(i),e.expect(`:`);let a=[];for(e.skipTerminators();!e.is(`}`)&&!e.isKw(`case`)&&!e.isKw(`default`);)e.tok.type===`eof`&&e.fail("missing `}` at end of program"),a.push(HO(e)),e.skipTerminators();n.push({test:t,body:a})}return e.switchDepth--,e.next(),{type:`switch`,expr:t,cases:n}}function XO(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:Ph(n.value,!1,t=>e.warn(t))}):e.fail(`case value must be a number, string or regex constant, found ${PO(n)}`)}function ZO(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=aO(e)?sO(e,{}):null),BO(e),n}function QO(e){e.next(),e.tok.type!==`name`&&e.fail(`\`delete\` needs an array name but found ${PO(e.tok)}`);let t=e.next().value,n=TO(e);return BO(e),{type:`delete`,name:t,subs:n}}var $O=e=>e.is(`;`)||e.is(`}`)||e.is(`>`)||e.is(`>>`)||e.is(`|`)||e.is(`|&`)||e.tok.type===`newline`||e.tok.type===`eof`;function ek(e,t){e.next();let n=null;if(e.is(`(`)){let t=e.i;e.next();let r=e.is(`)`)?[]:oO(e,{});e.accept(`)`)&&$O(e)?n=r:e.i=t}n===null&&(n=$O(e)?[]:oO(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: ${uh}`,`${t} | "cmd"`),(e.accept(`>`)||e.accept(`>>`))&&(r=gO(e,{noGt:!0}),r.type===`str`&&!MO.has(r.value)&&e.fail(tk(r.value),`${t} > FILE`)),BO(e),{type:t,args:n,dest:r}}function tk(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 X=class{constructor(e){this.s=e,this.number=void 0,this.numeric=void 0}},nk=`[ \\t\\n\\r\\f\\v]*`,rk=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?`,ik=RegExp(`^${nk}${rk}${nk}$`,`u`),ak=RegExp(`^${nk}(${rk})`,`u`),ok=RegExp(`^${nk}([+-])(inf|nan)${nk}$`,`iu`),sk=e=>ik.test(e)||ok.test(e);function ck(e){let t=ak.exec(e);if(t)return Number(t[1]);let n=ok.exec(e);return n?n[2].toLowerCase()===`nan`?NaN:n[1]===`-`?-1/0:1/0:0}var lk=()=>new W(`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 X)return e.number??=ck(e.s);if(typeof e==`string`)return ck(e);throw lk()}var uk=new Map;function dk(e,t){if(Number.isNaN(e))throw new W(`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=uk.get(t);if(n===void 0){uk.size>64&&uk.clear(),n=GS(t);let e=n.filter(e=>typeof e!=`string`);if(e.length>1||e.some(e=>!`diouxXeEfFgG`.includes(e.conv)||e.width===`*`||e.precision===`*`))throw new W(`this numeric conversion format is not supported`,null,`numeric conversion format`);uk.set(t,n)}return n.map(t=>typeof t==`string`?t:YS(e,t)).join(``)}var fk=e=>typeof e==`string`?e:e instanceof X?e.s:`%.6g`,pk=e=>fk(e.globals.get(`CONVFMT`)),mk=e=>fk(e.globals.get(`OFMT`));function Q(e,t){if(typeof e==`string`)return hk(t,e);if(e instanceof X)return hk(t,e.s);if(typeof e==`number`)return dk(e,pk(t));if(e===void 0)return``;throw lk()}function hk(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new W(`non-ASCII AWK text in a byte locale is not supported`,null,`byte locale text`);return t}function gk(e,t=!1){return[...e].map(e=>{let n=t?e.toUpperCase():e.toLowerCase();if([...n].length!==1)throw new W(`Unicode case expansion is not supported`,null,`Unicode case mapping`);return n}).join(``)}function _k(e,t){return typeof e==`number`?dk(e,mk(t)):Q(e,t)}var vk=e=>e.numeric??=sk(e.s),yk=e=>typeof e==`number`||e===void 0||e instanceof X&&vk(e),bk=e=>Sk(e.globals.get(`IGNORECASE`));function xk(e,t,n){if(yk(e)&&yk(t)){let n=Z(e),r=Z(t);return n<r?-1:n>r?1:n===r?0:NaN}let r=Q(e,n),i=Q(t,n);return bk(n)&&(r=gk(r),i=gk(i)),j(r,i)}function Sk(e){if(typeof e==`number`)return e!==0&&!Number.isNaN(e);if(typeof e==`string`)return e!==``;if(e instanceof X)return vk(e)?Z(e)!==0:e.s!==``;if(e===void 0)return!1;throw lk()}var Ck=(e,t)=>Number.isSafeInteger(e)?String(e):Q(e,t);function wk(e){return e instanceof Map?`array`:e===void 0?`untyped`:typeof e==`number`?`number`:e instanceof X&&vk(e)?`strnum`:`string`}function Tk(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t===``)return Ek(e);let i,a;if(t.length===1){let n=r.indexOf(t,e.pos);a=n===-1?r.length:n,i=n===-1?r.length:n+1}else{let o=Fh(r,Ph(t,n),e.pos);a=o?.start??r.length,i=o?.end??r.length}let o=r.slice(e.pos,a);return e.pos=i,{rec:o,rt:r.slice(a,i)}}function Ek(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 i=r.exec(t);if(!i){e.pos=t.length;let r=t.slice(n).replace(/\n+$/u,``);return{rec:r,rt:t.slice(n+r.length)}}return e.pos=i.index+i[0].length,{rec:t.slice(n,i.index),rt:i[0]}}function Dk(e,t,n,r){if(e===``)return[];if(t instanceof Mh)return Ih(e,t);if(t===` `){let t=e.replace(/^[ \t\n]+|[ \t\n]+$/gu,``);return t===``?[]:t.split(/[ \t\n]+/u)}if(t===``)return[...e];if(t.length===1&&(!n||t===`
333
+ `))return e.split(t);if(n&&t===`^`)throw new W(`paragraph splitting with FS="^" is not supported`,null,`paragraph FS caret`);return Ih(e,Ph(t.length===1?`[${`^$.[]|()*+?{}\\`.includes(t)?`\\`+t:t}
334
+ ]`:t,r))}function Ok(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let i=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),a=i?.[1]===void 0?0:Number(i[1]),o=i?.[2]===`*`?4294967295:Number(i?.[2]);if(!i||i[1]!==void 0&&a===0||a>4294967295||!(o>0&&o<=4294967295)||i[2]===`*`&&r!==t.length-1)throw new W(`invalid FIELDWIDTHS value \`${e}'`);return{skip:a,width:o}})}function kk(e,t){let n=[...e],r=[],i=0;for(let{skip:e,width:a}of t){if(i>=n.length)break;i+=e,r.push(n.slice(i,i+a).join(``)),i+=a}return r}function Ak(e,t){let n=[],r=0;for(;r<e.length;){let i=t.search(e.slice(r));if(n.length>0&&i?.end===0&&(r+=Br(e,r),i=t.search(e.slice(r))),!i)break;n.push(e.slice(r+i.start,r+i.end)),r+=i.end}return n}function jk(e,t){let n=bk(e);return e.fieldMode===`FIELDWIDTHS`?kk(t,e.widths):e.fieldMode===`FPAT`?Ak(t,Ph(Q(e.globals.get(`FPAT`),e),n,e.warn)):Dk(t,Q(e.globals.get(`FS`),e),Q(e.globals.get(`RS`),e)===``,n)}var Mk=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,Nk=e=>e!==void 0&&e.type===`exit`,Pk=class{constructor(e,t){this.ctx=e,this.stdin=t,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(e){for(;this.exitSignal===void 0;){if(this.src){let t=Tk(this.src,Q(e.globals.get(`RS`),e),bk(e));if(t!==null)return e.globals.set(`NR`,Z(e.globals.get(`NR`))+1),e.globals.set(`FNR`,Z(e.globals.get(`FNR`))+1),e.globals.set(`RT`,t.rt),t.rec;this.closeFile(e);continue}if(!this.open(e))return null}return null}open(e){for(;this.idx<Math.trunc(Z(e.globals.get(`ARGC`)));){if(++e.steps>sh)throw new W(`input operand scan exceeded execution limit`,null,`execution limit`);let t=Q(e.globals.get(`ARGV`).get(String(this.idx++)),e);if(t===``)continue;e.globals.set(`ARGIND`,this.idx-1);let n=Mk.exec(t);if(n){e.assign(n[1],new X(eO(n[2],e.warn)));continue}this.sawFile=!0;let{text:r,error:i}=this.readOperand(t);if(i===`Is a directory`){this.failFile(e,t,i),this.exitSignal===void 0&&e.warn(`command line argument \`${t}' is a directory: skipped`);continue}if(i){let n=this.failFile(e,t,i);if(n!==void 0&&n.type===`nextfile`)continue;if(this.exitSignal!==void 0)return!1;throw new W(`${t}: ${i}`)}if(this.use(e,t,r))return!0}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(e,`-`,this.takeStdin()))}readOperand(e){if(e===`/dev/null`)return{text:``};if(e===`-`||e===`/dev/stdin`)return{text:e===`/dev/stdin`&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:t,error:n}=N(this.ctx,`awk`,e);return this.ctx.fs.isDir(t)?{error:`Is a directory`}:n?{error:n}:{text:this.ctx.fs.readFile(t)}}takeStdin(){let e=this.stdin;return this.stdin=``,F(this.ctx),e}use(e,t,n){this.src={text:n,pos:0},e.globals.set(`FILENAME`,t),e.globals.set(`FNR`,0),e.globals.set(`ERRNO`,``);let r=e.fileRule(`begin`);return Nk(r)?(this.exitSignal=r,this.src=null,!1):r!==void 0&&r.type===`nextfile`?(this.closeFile(e),!1):(hk(e,n),!0)}failFile(e,t,n){if(e.globals.set(`ERRNO`,n),!e.hasFileRules)return;e.globals.set(`FILENAME`,t),e.globals.set(`FNR`,0);let r=e.fileRule(`begin`);return Nk(r)&&(this.exitSignal=r),r}closeFile(e){this.src=null;let t=e.fileRule(`end`);Nk(t)&&(this.exitSignal=t)}readNamed(e,t){let n=this.readers.get(t);if(!n){let{text:r,error:i}=this.readOperand(t);if(i)return e.globals.set(`ERRNO`,i),{status:-1};n={text:hk(e,r),pos:0},this.readers.set(t,n)}let r=Tk(n,Q(e.globals.get(`RS`),e),bk(e));return r===null?{status:0}:(e.globals.set(`RT`,r.rt),{status:1,record:r.rec})}close(e,t){return this.readers.delete(t)?0:(e.globals.set(`ERRNO`,`close of redirection that was never opened`),-1)}},Fk=(e,t)=>({isRef:!0,scope:e,name:t}),Ik=e=>typeof e==`object`&&!!e&&e.isRef===!0,Lk=class extends Error{constructor(e){super(e.type),this.signal=e}},Rk=e=>new W(`attempt to use array \`${e}\` in a scalar context`);function zk(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function Bk(e){let t=e;for(;Ik(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function Vk(e,t){let n=zk(e,t).get(t);return Ik(n)?Bk(n):n}var Hk=new Set([`FS`,`FIELDWIDTHS`,`FPAT`]);function Uk(e,t,n){let r=zk(e,t);if(r.get(t)instanceof Map)throw Rk(t);if(r===e.globals){if(t===`NF`){Yk(e,n);return}if(t===`FIELDWIDTHS`&&(e.widths=Ok(Q(n,e))),(t===`FPAT`||(t===`FS`||t===`RS`)&&Q(n,e).length>1)&&Ph(Q(n,e),bk(e),e.warn,e.tables),Hk.has(t)){e.fieldMode=t;let n=e.globals.get(`PROCINFO`);n instanceof Map&&n.set(`FS`,t)}}r.set(t,n)}function Wk(e,t){let n=zk(e,t),r=t,i=n,a=i.get(r);if(a instanceof Map)return a;let o=Ik(a);for(;Ik(a);)i=a.scope,r=a.name,a=i.get(r);if(!(a instanceof Map)){if(a!==void 0)throw new W(`attempt to use scalar \`${r}\` as an array`);a=new Map,i.set(r,a)}return o&&n.set(t,a),a}function Gk(e,t,n=new X(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...jk(e,t).map(e=>new X(e))],e.nf=e.fields.length-1,e.globals.set(`NF`,e.nf)}function Kk(e){let t=Q(e.globals.get(`OFS`),e);e.record=e.fields.slice(1).map(t=>Q(t,e)).join(t),e.recordValue=e.record}function qk(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function Jk(e,t,n){if(t===0){let t=Q(n,e);Gk(e,t,typeof n==`number`?t:n);return}for(;e.nf<t;)e.fields[++e.nf]=``;e.fields[t]=n,e.globals.set(`NF`,e.nf),Kk(e)}function Yk(e,t){let n=Math.trunc(Z(t));if(n<0)throw new W(`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),Kk(e)}function Xk(e,t){let n=Z($(e,t));if(!(n>=0))throw new W(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function Zk(e,t){if(t.length===1)return Ck($(e,t[0]),e);let n=Q(e.globals.get(`SUBSEP`),e);return t.map(t=>Ck($(e,t),e)).join(n)}function Qk(e,t){return t.type===`var`?t:t.type===`index`?{type:`index`,arr:Wk(e,t.name),key:Zk(e,t.subs)}:{type:`field`,i:Xk(e,t.index)}}function $k(e,t){return t.type===`var`?aA(Vk(e,t.name),t.name):t.type===`index`?t.arr.get(t.key):qk(e,t.i)}function eA(e,t,n){t.type===`var`?Uk(e,t.name,n):t.type===`index`?t.arr.set(t.key,n):Jk(e,t.i,n)}function tA(e,t,n){eA(e,Qk(e,t),n)}function nA(e,t,n){if(n===0&&(e===`/`||e===`%`))throw new W(e===`/`?`division by zero attempted`:"division by zero attempted in `%`");return dh(e,t,n)}var rA={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function iA(e,t){let n=bk(e);return t.type===`regex`?n?Ph(t.source,!0,null,e.tables):t.re:Ph(Q($(e,t),e),n,e.warn,e.tables)}function aA(e,t){if(e instanceof Map)throw Rk(t);return e}function oA(e,t,n){let r=Qk(e,t.target),i=Z($k(e,r)),a=t.op===`++`?i+1:i-1;return eA(e,r,a),n?i:a}function $(e,t){switch(t.type){case`num`:case`str`:return t.value;case`regex`:return+!!iA(e,t).test(e.record);case`var`:return aA(Vk(e,t.name),t.name);case`index`:{let n=Wk(e,t.name),r=Zk(e,t.subs),i=n.get(r);return i===void 0&&n.set(r,void 0),i}case`field`:return qk(e,Xk(e,t.index));case`assign`:{let n=Qk(e,t.target),r=$(e,t.value);if(r instanceof Map)throw new W(`attempt to use an array in a scalar context`);return t.op!==`=`&&(r=nA(t.op[0],Z($k(e,n)),Z(r))),eA(e,n,r),r}case`cond`:return $(e,Sk($(e,t.test))?t.consequent:t.alternate);case`or`:return Sk($(e,t.left))||Sk($(e,t.right))?1:0;case`and`:return Sk($(e,t.left))&&Sk($(e,t.right))?1:0;case`not`:return+!Sk($(e,t.expr));case`neg`:return-Z($(e,t.expr));case`plus`:return Z($(e,t.expr));case`binary`:return nA(t.op,Z($(e,t.left)),Z($(e,t.right)));case`concat`:return Q($(e,t.left),e)+Q($(e,t.right),e);case`compare`:return+!!rA[t.op](xk($(e,t.left),$(e,t.right),e));case`match`:{let n=Q($(e,t.left),e);return iA(e,t.right).test(n)===t.negate?0:1}case`in`:return+!!Wk(e,t.array).has(Zk(e,t.keys));case`preinc`:return oA(e,t,!1);case`postinc`:return oA(e,t,!0);case`call`:return sA(e,t);case`builtin`:return e.callBuiltin(e,t);case`getline`:return lA(e,t);default:throw new W(`unknown expression: ${t.type}`)}}function sA(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new W(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new W(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=ch)throw new W(`function call nesting deeper than ${ch} levels (runaway recursion?)`,null,`call depth limit`);let r=e.frame,i=new Map;for(let r=0;r<n.params.length;r++)i.set(n.params[r],r<t.args.length?cA(e,t.args[r]):void 0);e.frame=i,e.callDepth++;try{let t=e.execStmts(e,n.body);if(t===void 0||t.type===`return`)return t?.value;throw new Lk(t)}finally{e.frame=r,e.callDepth--}}function cA(e,t){if(t.type!==`var`)return $(e,t);let n=zk(e,t.name),r=n.get(t.name);return r instanceof Map||Ik(r)?r:r===void 0?Fk(n,t.name):r}function lA(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,Q($(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?Gk(e,n):tA(e,t.target,new X(n)),1}var uA=(e,t)=>Z($(e,t)),dA=2**32;function fA(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var pA=()=>({seed:1,state:fA(1)});function mA(e){e.rng.state=(e.rng.state+1831565813)%dA;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+dA:n)/dA}function hA(e,t){let n=e.rng.seed,r=t.length>0?uA(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=fA(r),n}function gA(e,t){let n=uA(e,t[0]);return n<0&&e.warn(`log: received negative argument ${Q(n,e)}`),Math.log(n)}function _A(e,t){let n=uA(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${Q(n,e)}`),Math.sqrt(n)}function vA(e,t){let n=uA(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${Q(n,e)} is out of range`),r}function yA(e,t){let n=$(e,t[0]);if(typeof n==`number`)return n;let r=n instanceof X?n.s:Q(n,e),i=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(i)return i[1]===``?0:Number.parseInt(i[1],16);let a=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return a?Number.parseInt(a[0],8):Z(new X(r))}function bA(e,t,n,r){let i=uA(e,n);if(i<0)throw new W(`${t}: argument ${r} negative value ${Q(i,e)} is not allowed`);if(!Number.isFinite(i))throw new W(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(i)))}function xA(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function SA(e,t){return(n,r)=>{if(r.length<2)throw new W(`${e}: called with less than two arguments`);let i=bA(n,e,r[0],1);for(let a=1;a<r.length;a++)i=t(i,bA(n,e,r[a],a+1));return xA(i)}}function CA(e,t){return(n,r)=>{let i=bA(n,e,r[0],1),a=bA(n,e,r[1],2)%64n;return xA(BigInt.asUintN(64,t?i<<a:i>>a))}}var wA={__proto__:null,sin:(e,t)=>Math.sin(uA(e,t[0])),cos:(e,t)=>Math.cos(uA(e,t[0])),atan2:(e,t)=>Math.atan2(uA(e,t[0]),uA(e,t[1])),exp:vA,log:gA,sqrt:_A,int:(e,t)=>Math.trunc(uA(e,t[0])),rand:mA,srand:hA,systime:()=>Math.floor(Date.now()/1e3),strtonum:yA,and:SA(`and`,(e,t)=>e&t),or:SA(`or`,(e,t)=>e|t),xor:SA(`xor`,(e,t)=>e^t),lshift:CA(`lshift`,!0),rshift:CA(`rshift`,!1),compl:(e,t)=>xA(BigInt.asUintN(64,~bA(e,`compl`,t[0],1)))},TA=new Map;function EA(e){let t=TA.get(e);return t||(TA.size>=256&&TA.clear(),t=GS(e),TA.set(e,t)),t}function DA(e,t,n){let r=0,i=()=>{if(r>=n.length)throw new W(`printf: not enough arguments to satisfy format string`);return n[r++]},a=``;for(let n of EA(t)){if(typeof n==`string`){a+=n;continue}let t={...n};if(n.width===`*`){let e=Math.trunc(Z(i()));e<0?(t.minus=!0,t.width=-e):t.width=e}if(n.precision===`*`){let e=Math.trunc(Z(i()));t.precision=e<0?null:e}if(t.width>lh||t.precision>lh)throw new W(`printf: field width or precision above ${lh} is not supported`,null,`format size limit`);a+=OA(e,t,i())}return a}function OA(e,t,n){if(t.conv===`s`){let r=Q(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join(``)),KS(``,r,t,!1)}return t.conv===`c`?KS(``,hk(e,kA(n)),t,!1):YS(Z(n),t)}function kA(e){if(typeof e==`number`||e instanceof X&&sk(e.s)){let t=Math.trunc(Z(e));if(!Rr(t))throw new W(`printf: character code outside Unicode scalar values is not supported`,null,`character code`);return String.fromCodePoint(t)}let t=e instanceof X?e.s:e??``;return t===``?`\0`:String.fromCodePoint(t.codePointAt(0))}var AA=(e,t)=>Q($(e,t),e),jA=(e,t)=>Z($(e,t)),MA={type:`field`,index:{type:`num`,value:0}};function NA(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`){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+=i===`&`?t:i}return n}function PA(e,t,n){let r=iA(e,t[0]),i=AA(e,t[1]),a=t[2]??MA,o=AA(e,a),{out:s,count:c}=Lh(o,r,(e,t)=>NA(i,o.slice(e,t)),n?`global`:`first`);return c>0&&tA(e,a,s),c}function FA(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`&&r+1===e.length)throw new W(`gensub with a trailing replacement backslash is not supported`,null,`gensub trailing backslash`);if(i===`\\`&&r+1<e.length){let i=e[++r];n+=i>=`0`&&i<=`9`?t[Number(i)]?.text??``:i;continue}n+=i===`&`?t[0].text:i}return n}function IA(e,t){let n=iA(e,t[0]),r=AA(e,t[1]),i=$(e,t[2]),a=Q(i,e),o=a.startsWith(`g`)||a.startsWith(`G`),s=0;o||(s=Math.trunc(Z(i)),s<1&&(e.warn(`gensub: third argument \`${a}' treated as 1`),s=1));let c=t[3]?AA(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return Lh(c,n,(e,t,i)=>!o&&i!==s?null:FA(r,l?n.groups(c,e,t):[{text:c.slice(e,t)}]),o?`global`:`nth`).out}function LA(e,t){let n=AA(e,t[0]),r=iA(e,t[1]),i=r.search(n,0),a=i?Array.from(n.slice(0,i.start)).length+1:0;if(e.globals.set(`RSTART`,a),e.globals.set(`RLENGTH`,i?Array.from(n.slice(i.start,i.end)).length:-1),t[2]){let a=Wk(e,t[2].name);if(a.clear(),i){let t=Q(e.globals.get(`SUBSEP`),e);r.groups(n,i.start,i.end).forEach((e,r)=>{e!==void 0&&(a.set(String(r),new X(e.text)),a.set(`${r}${t}start`,Array.from(n.slice(0,e.start)).length+1),a.set(`${r}${t}length`,[...e.text].length))})}}return a}function RA(e,t){let n=AA(e,t[0]),r=Wk(e,t[1].name),i;i=t[2]===void 0?Q(e.globals.get(`FS`),e):t[2].type===`regex`?iA(e,t[2]):AA(e,t[2]);let a=Dk(n,i,!1,bk(e));return r.clear(),a.forEach((e,t)=>r.set(String(t+1),new X(e))),a.length}function zA(e,t){let n=[...AA(e,t[0])],r=Math.trunc(jA(e,t[1])),i=Number.isNaN(r)?1:Math.max(r,1),a=n.length+1;if(t[2]){let n=Math.trunc(jA(e,t[2]));if(!(n>=1))return``;a=Math.min(a,i+n)}return a>i?n.slice(i-1,a-1).join(``):``}function BA(e,t){if(t.length===0)return[...e.record].length;if(t[0].type===`var`){let n=Vk(e,t[0].name);return n instanceof Map?n.size:[...Q(n,e)].length}return[...AA(e,t[0])].length}function VA(e,t){let n=AA(e,t[0]),r=AA(e,t[1]);bk(e)&&(n=gk(n),r=gk(r));let i=n.indexOf(r);return i<0?0:Array.from(n.slice(0,i)).length+1}function HA(e,t){let n=AA(e,t[0]);return n===`/dev/stdout`||n===`/dev/stderr`||n===`/dev/null`?0:e.input.close(e,n)}var UA=(e,t)=>t[0].type===`var`?wk(Vk(e,t[0].name)):wk($(e,t[0])),WA={__proto__:null,...wA,length:BA,substr:zA,index:VA,split:RA,sub:(e,t)=>PA(e,t,!1),gsub:(e,t)=>PA(e,t,!0),gensub:IA,match:LA,sprintf:(e,t)=>DA(e,AA(e,t[0]),t.slice(1).map(t=>$(e,t))),tolower:(e,t)=>gk(AA(e,t[0])),toupper:(e,t)=>gk(AA(e,t[0]),!0),close:HA,fflush:()=>0,typeof:UA,isarray:(e,t)=>+(t[0].type===`var`&&Vk(e,t[0].name)instanceof Map)};function GA(e,t){let n=WA[t.name];if(!n)throw new W(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var KA={type:`break`},qA={type:`continue`},JA={type:`next`},YA={type:`nextfile`},XA={type:`exit`};function ZA(e,t,n,r){let i=new Map([[`0`,`awk`]]);r.forEach((e,t)=>i.set(String(t+1),new X(e)));let a={program:e,globals:new Map([[`FS`,` `],[`OFS`,` `],[`ORS`,`
335
335
  `],[`RS`,`
336
- `],[`RT`,``],[`NR`,0],[`NF`,0],[`FNR`,0],[`FILENAME`,``],[`SUBSEP`,`\x1C`],[`CONVFMT`,`%.6g`],[`OFMT`,`%.6g`],[`RSTART`,0],[`RLENGTH`,-1],[`ERRNO`,``],[`IGNORECASE`,0],[`FIELDWIDTHS`,``],[`FPAT`,`[^[:space:]]+`],[`ENVIRON`,new YA(`ENVIRON`)],[`PROCINFO`,new YA(`PROCINFO`,[[`FS`,`FS`]])],[`ARGC`,r.length+1],[`ARGV`,i],[`ARGIND`,0]]),frame:void 0,callDepth:0,record:``,recordValue:new X(``),fields:[void 0],nf:0,fieldMode:`FS`,out:[],errOut:[],steps:0,exitCode:0,ranges:[],rng:uA(),input:new jk(t,n),byteLocale:en(t),tables:vn(t.locale),hasFileRules:e.beginFile.length>0,callBuiltin:HA,execStmts:ij,assign:(e,t)=>Bk(a,e,t),warn:e=>a.errOut.push(`awk: warning: ${e}
337
- `),fileRule:e=>$A(a,e)};return a}var YA=class extends Map{constructor(e,t=[]){super(t),this.systemName=e}check(e){if(!this.systemName||this.systemName===`PROCINFO`&&e===`FS`)return;let t=this.systemName===`ENVIRON`?`ENVIRON`:`PROCINFO[${e??`*`}]`;throw new W(`${t} is not supported without the corresponding environment or process metadata`,null,t)}get(e){return this.check(e),super.get(e)}has(e){return this.check(e),super.has(e)}set(e,t){return this.check(e),super.set(e,t)}delete(e){return this.check(e),super.delete(e)}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 XA(e){let{program:t}=e,n=QA(e,t.begin,`BEGIN`),r=t.rules.length>0||t.end.length>0||t.beginFile.length>0||t.endFile.length>0;return!ZA(n)&&r&&ej(e),QA(e,t.end,`END`),e.exitCode}var ZA=e=>e!==void 0&&e.type===`exit`;function QA(e,t,n){let r=nj(e,t);if(r!==void 0&&(r.type===`next`||r.type===`nextfile`&&(n===`BEGIN`||n===`END`)))throw new W(`\`${r.type}' cannot be called from a ${n} rule`);return r}function $A(e,t){let n=t===`begin`?e.program.beginFile:e.program.endFile;return n.length===0?void 0:QA(e,n,t===`begin`?`BEGINFILE`:`ENDFILE`)}function ej(e){for(;;){let t=e.input.next(e);if(t===null)return e.input.exitSignal;Hk(e,t);let n=tj(e);if(ZA(n))return n;n!==void 0&&n.type===`nextfile`&&e.input.closeFile(e)}}function tj(e){let{rules:t}=e.program;for(let n=0;n<t.length;n++){let r=t[n];if(!rj(e,r,n))continue;if(r.action===null){lj(e,null,e.record+Q(e.globals.get(`ORS`),e));continue}let i=nj(e,r.action);if(i!==void 0)return i}}function nj(e,t){try{return ij(e,t)}catch(e){if(!(e instanceof Pk))throw e;return e.signal}}function rj(e,t,n){let{pattern:r}=t;if(r===null)return!0;if(r.type!==`range`)return yk($(e,r));if(!e.ranges[n]){if(!yk($(e,r.from)))return!1;e.ranges[n]=!0}return yk($(e,r.to))&&(e.ranges[n]=!1),!0}function ij(e,t){for(let n of t){let t=aj(e,n);if(t!==void 0)return t}}function aj(e,t){if(++e.steps>ih)throw new W(`execution stopped after ${ih} statements (infinite loop?)`,null,`execution limit`);switch(t.type){case`block`:return ij(e,t.body);case`empty`:return;case`expr`:$(e,t.expr);return;case`print`:return uj(e,t);case`printf`:return dj(e,t);case`if`:return yk($(e,t.test))?aj(e,t.consequent):t.alternate===null?void 0:aj(e,t.alternate);case`while`:case`do`:case`for`:return oj(e,t);case`forin`:return sj(e,t);case`switch`:return cj(e,t);case`break`:return UA;case`continue`:return WA;case`next`:return GA;case`nextfile`:return KA;case`exit`:return fj(e,t);case`return`:return{type:`return`,value:t.value===null?void 0:$(e,t.value)};case`delete`:{let n=Vk(e,t.name);t.subs===null?n.clear():n.delete(Jk(e,t.subs));return}default:throw new W(`unknown statement: ${t.type}`)}}function oj(e,t){t.init&&$(e,t.init);let n=!0;for(;t.type===`do`&&n||t.test===null||yk($(e,t.test));){n=!1;let r=aj(e,t.body);if(r===UA)return;if(r!==void 0&&r!==WA)return r;t.step&&$(e,t.step)}}function sj(e,t){let n=Vk(e,t.array);for(let r of Array.from(n.keys())){Bk(e,t.name,new X(r));let n=aj(e,t.body);if(n===UA)return;if(n!==void 0&&n!==WA)return n}}function cj(e,t){let n=$(e,t.expr),r=t=>t.test.type===`regex`?tA(e,t.test).test(Q(n,e)):vk(n,t.test.value,e)===0,i=t.cases.findIndex(e=>e.test!==null&&r(e));if(i===-1&&(i=t.cases.findIndex(e=>e.test===null)),i!==-1)for(let n=i;n<t.cases.length;n++){let r=ij(e,t.cases[n].body);if(r===UA)return;if(r!==void 0)return r}}function lj(e,t,n){if(t===null){e.out.push(n);return}let r=Q($(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 W(QO(r),null,`output redirection`)}function uj(e,t){let n=Q(e.globals.get(`ORS`),e),r;if(t.args.length===0)r=e.record;else{let n=Q(e.globals.get(`OFS`),e);r=t.args.map(t=>mk($(e,t),e)).join(n)}lj(e,t.dest,r+n)}function dj(e,t){let n=t.args.map(t=>$(e,t));lj(e,t.dest,wA(e,Q(n[0],e),n.slice(1)))}function fj(e,t){return t.value!==null&&(e.exitCode=(Math.trunc(Z($(e,t.value)))%256+256)%256),qA}var pj=`awk [-F fs] [-v var=value] 'program' [file ...] | awk [-F fs] [-v var=value] -f progfile [file ...]`,mj=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u;function hj(e,t,n){let{values:r,positional:i}=U(_j(t),{valueShort:[`F`],repeatable:[`v`,`f`],stopAtFirstPositional:!0}),a=vj(r.get(`f`)??[],i,n);if(a.error)return a.error;let o;try{fk({byteLocale:en(n)},a.text),o=NO(a.text)}catch(e){if(e instanceof RangeError)return C(`feature`,`awk`,`parser depth limit`,`awk: program too deeply nested (${e.message})`);if(S(e))return Ke(e,`awk`,`awk: ${e.message}`);if(!(e instanceof W))throw e;let t=e.line===null?`awk: ${e.message}`:`awk: ${e.kind} at line ${e.line}: ${e.message}`;return e.gap===null?x(t):C(`feature`,`awk`,e.gap,t)}let s=JA(o,n,e,a.operands);for(let e of o.warnings)s.warn(e);let c,l=null;try{r.has(`F`)&&s.assign(`FS`,ZD(r.get(`F`),s.warn));for(let e of r.get(`v`)??[]){let t=mj.exec(e);if(!t)return x(`awk: -v: expected var=value but got \`${e}\``);s.assign(t[1],new X(ZD(t[2],s.warn)))}c=XA(s)}catch(e){let t=S(e);if(!(e instanceof W)&&!(e instanceof RangeError)&&!t)throw e;s.errOut.push(`awk: ${e.message}
338
- `),c=2,e instanceof RangeError&&(l={detail:`runtime limit`,message:`awk: ${e.message}`}),e.gap&&(l={detail:e.gap,message:`awk: ${e.message}`}),t&&(l={detail:t.detail,message:`awk: ${e.message}`})}let u={stdout:s.out.join(``),stderr:s.errOut.join(``),exitCode:c};return l===null?u:w(u,`feature`,`awk`,l.detail,l.message)}var gj=/^-[Fvf]\S*\s/su;function _j(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(gj.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 vj(e,t,n){if(e.length===0)return t.length===0?{error:We(pj,2)}:{text:t[0],operands:t.slice(1)};let r=[];for(let t of e){let{path:e,error:i}=N(n,`awk`,t);if(i||!n.fs.isFile(e))return{error:x(`awk: cannot open program file \`${t}\`: ${i??`Is a directory`}`,2)};r.push(n.fs.readFile(e))}return{text:r.join(`
339
- `),operands:t}}function yj(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`n`,`r`,`u`,`f`,`b`,`z`],valueShort:[`t`,`o`],valueLong:[`output`],repeatable:[`k`,`o`,`output`]}),o=[...i.get(`o`)??[],...i.get(`output`)??[]];if(o.length>1)return x(`sort: multiple output files specified`,2);let s=i.get(`t`);if(s!==void 0&&p(s).length!==1)return x(`sort: multi-character tab '${s}'`,2);let c={n:r.has(`n`),f:r.has(`f`),b:r.has(`b`),r:r.has(`r`)},l=Dj(i.get(`k`)??[],c);if(l.error)return l.error;let u=Hn(`sort`,a,e,n,{stopOnError:!0});if(u.failed)return{stdout:``,stderr:u.stderr,exitCode:2};let d=r.has(`z`)?`\0`:`
340
- `,f=Nn(jj(u.inputs.flatMap(({content:e})=>jn(e,d)),l.specs.length?l.specs:[{start:1,...c}],s,r.has(`u`),c.r),d);return o.length===0?I(f,u):bj(o[0],f,n,u)}function bj(e,t,n,r){if(e===`/dev/null`)return I(``,r);if(e===`/dev/stdout`)return I(t,r);n.io?.setReads([]);let i;try{i=n.writable&&n.fs.openWritable(n.cwd,e),i&&i.write(t)}catch(e){return P(n,`sort`,e?.path,e?.fsError),Ke(e,`sort`,`sort: open failed: ${e.message}`,2)}return i?I(``,r):C(`feature`,`sort`,`-o`,`sort: open failed: ${e}: Read-only file system`,2)}var xj=`nrfb`,Sj=`bdfghiMnRrV`,Cj=/^[ \t]*\+?(\d+)/u,wj=(e,t)=>x(`sort: ${e}: invalid count at start of '${t}'`,2),Tj=(e,t)=>x(`sort: ${e}: invalid field specification '${t}'`,2);function Ej(e){let t=0,n=null,r=r=>{let i=Cj.exec(e.slice(t));return i===null?(n=wj(r,e.slice(t)),null):(t+=i[0].length,Number(i[1]))},i=n=>{let i=r(n);if(i===null)return null;let a=null;if(e[t]===`.`&&(t++,a=r(`invalid number after '.'`),a===null))return null;let o=t;for(;t<e.length&&/[a-zA-Z]/u.test(e[t]);)t++;return{field:i,offset:a,mods:e.slice(o,t)}},a=i(`invalid number at field start`);if(a===null)return{error:n};let o=null;return e[t]===`,`&&(t++,o=i(`invalid number after ','`),o===null)?{error:n}:a.field===0||o?.field===0?{error:Tj(`field number is zero`,e)}:a.offset===0?{error:Tj(`character offset is zero`,e)}:t===e.length?{from:a,to:o}:{error:Tj(`stray character in field spec`,e)}}function Dj(e,t){let n=[];for(let r of e){let e=Ej(r);if(e.error)return{error:e.error};let{from:i,to:a}=e,o=i.mods+(a?.mods??``);for(let e of o)if(!xj.includes(e))return Sj.includes(e)?{error:C(`option`,`sort`,`-k${r}`,`sort: unknown key option \`${e}\` in ${r}`,2)}:{error:Tj(`stray character in field spec`,r)};if(i.offset!==null||(a?.offset??0)!==0)return{error:C(`option`,`sort`,`-k${r}`,`sort: invalid key specification: ${r} (character offsets are not supported)`,2)};let s=o.length>0;n.push({start:i.field,end:a?.field,n:s?o.includes(`n`):t.n,r:s?o.includes(`r`):t.r,f:s?o.includes(`f`):t.f,b:s?i.mods.includes(`b`):t.b})}return{specs:n}}function Oj(e,t){let n=[];if(t!==void 0){let r=0;for(;;){let i=e.indexOf(t,r);if(i===-1){n.push([r,e.length]);break}n.push([r,i]),r=i+t.length}return n}let r=0;do{let t=r;for(;r<e.length&&/[ \t]/u.test(e[r]);)r++;for(;r<e.length&&!/[ \t]/u.test(e[r]);)r++;n.push([t,r])}while(r<e.length);return n}function kj(e,t,n){if(t.start>n.length)return``;let r=n[t.start-1][0],i=t.end===void 0||t.end>n.length?e.length:n[t.end-1][1];if(t.b)for(;r<i&&/[ \t]/u.test(e[r]);)r++;return e.slice(r,Math.max(r,i))}var Aj=e=>e.replace(/[a-z]/gu,e=>e.toUpperCase());function jj(e,t,n,r,i){let a=t.every(e=>e.start===1&&e.end===void 0);if(a&&t.length===1&&!t[0].n&&!t[0].f&&!t[0].b)return e.sort(e.some(e=>/[\u{10000}-\u{10FFFF}]/u.test(e))?j:void 0),t[0].r&&e.reverse(),r?e.filter((t,n)=>n===0||t!==e[n-1]):e;let o=e.map(e=>{let r=a?[[0,e.length]]:Oj(e,n);return{line:e,keys:t.map(t=>{let n=kj(e,t,r);return t.n?Mj(n):t.f?Aj(n):n})}}),s=(e,n)=>{for(let r=0;r<t.length;r++){let i=t[r],a=i.n?Pj(e.keys[r],n.keys[r]):j(e.keys[r],n.keys[r]);if(a!==0)return i.r?-a:a}return r?0:(i?-1:1)*j(e.line,n.line)};o.sort(s);let c=[];for(let e=0;e<o.length;e++)r&&e>0&&s(o[e-1],o[e])===0||c.push(o[e].line);return c}function Mj(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 Nj=(e,t)=>e<t?-1:+(e>t);function Pj(e,t){if(e.negative!==t.negative)return e.negative?-1:1;let n=e.integer.length-t.integer.length||Nj(e.integer,t.integer)||Nj(e.fraction,t.fraction);return e.negative?-n:n}async function Fj(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`r`,`0`],valueShort:[`n`,`I`],stopAtFirstPositional:!0}),[o=`echo`,...s]=a,c=i.get(`I`),l=i.has(`n`)?qn(i.get(`n`),`xargs: -n`):{value:void 0};if(l.error)return l.error;if(l.value===0)return x(`xargs: -n: must be at least 1`);if(c===``)return x(`xargs: -I: replacement string must not be empty`);if(c!==void 0&&l.value!==void 0)return C(`option`,`xargs`,`-I -n`,`xargs: combining replacement and chunk limits is not supported`);if(F(n),!r.has(`0`)&&e.includes(`\0`))return C(`feature`,`xargs`,`NUL input`,`xargs: NUL input requires -0`);let u;if(r.has(`0`))u=jn(e,`\0`);else if(c===void 0)u=Lj(e);else{if(/["'\\]/u.test(e))return C(`feature`,`xargs`,`-I input quoting`,`xargs: quoted or escaped replacement lines are not supported`);u=jn(e).map(e=>e.replace(/^[ \t\r\f\v]+/u,``)).filter(Boolean)}if(u.length===0&&(r.has(`r`)||c!==void 0))return b();let d=c===void 0?l.value??Math.max(1,u.length):1,f=G(),p=0;for(let e=0;e<Math.max(1,u.length);e+=d){let t=u[e],r=c===void 0?[...s,...u.slice(e,e+d)]:s.map(e=>e.replaceAll(c,t)),i=await n.dispatch(o,r,``,{devNull:!0});if(K(f,i),i.exitCode===255)return K(f,{...G(`xargs: ${o}: exited with status 255; aborting
341
- `),exitCode:124}),f;if(i.exitCode===127&&!n.hasCommand(n.registry.resolveCommand(o)))return{...f,exitCode:127};i.exitCode!==0&&(p=123)}return{...f,exitCode:p,ignored:!1}}var Ij=e=>Error(`unmatched ${e===`'`?`single`:`double`} quote; by default quotes are special to xargs unless you use the -0 option`);function Lj(e){let t=[],n=null,r=!1,i=``;for(let a=0;a<e.length;a++){let o=e[a];if(r||!/[ \t\n\r\f\v]/u.test(o)){if(n){if(o===n)n=null;else{if(o===`
342
- `)throw Ij(n);i+=o}}else if(o===`"`||o===`'`)n=o,r=!0;else if(o===`\\`){if(a+1>=e.length)break;i+=e[++a],r=!0}else o===` `||o===` `||o===`
343
- `?(r&&t.push(i),i=``,r=!1):(i+=o,r=!0)}}if(n)throw Ij(n);return r&&t.push(i),t}function Rj(e,t,n,r){let{values:i,positional:a,order:o}=U(Vj(n),{short:[`q`,`v`],valueShort:[`c`,`n`]}),s=o.findLast(e=>e.name===`n`||e.name===`c`)?.name??`n`,c=Jn(i.get(s)??`10`,e+`: -`+s);if(c.error)return c.error;let l=o.findLast(e=>e.name===`q`||e.name===`v`),u=l?l.name===`v`:null,d=e===`head`,f=c.sign===`+`;if(d&&c.value===0&&c.sign!==`-`)return Uj(e,t,a,r,()=>``,{unit:s,banner:u,leftover:e=>e,readOptions:{noRead:!0}});if(!d&&c.value===0&&!f){if(!r.stdinFile&&(!a.length||a.includes(`-`)||a.includes(`/dev/stdin`))){let n=Gj(e,t,``,s,`standard input`);n&&r.notes.add(n)}return b()}let p=e=>d?[0,c.sign===`-`?Math.max(0,e-c.value):c.value]:[f?Math.min(e,Math.max(0,c.value-1)):Math.max(0,e-c.value),e];return Uj(e,t,a,r,e=>{if(s===`c`)return Hj(e,p);let t=d?c.sign===`-`:!f,n=Bj(e,d||t?c.value:Math.max(0,c.value-1),t);return d?e.slice(0,n):e.slice(n)},{unit:s,banner:u,leftover:d?zj(c,s,r):void 0,readOptions:!d&&f?{stopOnDir:!0}:void 0})}function zj(e,t,n){return e.sign===`-`||t===`n`&&!n.stdinFile?()=>``:t===`c`?t=>Hj(t,t=>[Math.min(e.value,t),t]):t=>t.slice(Bj(t,e.value))}function Bj(e,t,n=!1){if(n){if(t===0)return e.length;let n=e.length-Number(e.endsWith(`
336
+ `],[`RT`,``],[`NR`,0],[`NF`,0],[`FNR`,0],[`FILENAME`,``],[`SUBSEP`,`\x1C`],[`CONVFMT`,`%.6g`],[`OFMT`,`%.6g`],[`RSTART`,0],[`RLENGTH`,-1],[`ERRNO`,``],[`IGNORECASE`,0],[`FIELDWIDTHS`,``],[`FPAT`,`[^[:space:]]+`],[`ENVIRON`,new QA(`ENVIRON`)],[`PROCINFO`,new QA(`PROCINFO`,[[`FS`,`FS`]])],[`ARGC`,r.length+1],[`ARGV`,i],[`ARGIND`,0]]),frame:void 0,callDepth:0,record:``,recordValue:new X(``),fields:[void 0],nf:0,fieldMode:`FS`,out:[],errOut:[],steps:0,exitCode:0,ranges:[],rng:pA(),input:new Pk(t,n),byteLocale:tn(t),tables:yn(t.locale),hasFileRules:e.beginFile.length>0,callBuiltin:GA,execStmts:sj,assign:(e,t)=>Uk(a,e,t),warn:e=>a.errOut.push(`awk: warning: ${e}
337
+ `),fileRule:e=>nj(a,e)};return a}var QA=class extends Map{constructor(e,t=[]){super(t),this.systemName=e}check(e){if(!this.systemName||this.systemName===`PROCINFO`&&e===`FS`)return;let t=this.systemName===`ENVIRON`?`ENVIRON`:`PROCINFO[${e??`*`}]`;throw new W(`${t} is not supported without the corresponding environment or process metadata`,null,t)}get(e){return this.check(e),super.get(e)}has(e){return this.check(e),super.has(e)}set(e,t){return this.check(e),super.set(e,t)}delete(e){return this.check(e),super.delete(e)}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 $A(e){let{program:t}=e,n=tj(e,t.begin,`BEGIN`),r=t.rules.length>0||t.end.length>0||t.beginFile.length>0||t.endFile.length>0;return!ej(n)&&r&&rj(e),tj(e,t.end,`END`),e.exitCode}var ej=e=>e!==void 0&&e.type===`exit`;function tj(e,t,n){let r=aj(e,t);if(r!==void 0&&(r.type===`next`||r.type===`nextfile`&&(n===`BEGIN`||n===`END`)))throw new W(`\`${r.type}' cannot be called from a ${n} rule`);return r}function nj(e,t){let n=t===`begin`?e.program.beginFile:e.program.endFile;return n.length===0?void 0:tj(e,n,t===`begin`?`BEGINFILE`:`ENDFILE`)}function rj(e){for(;;){let t=e.input.next(e);if(t===null)return e.input.exitSignal;Gk(e,t);let n=ij(e);if(ej(n))return n;n!==void 0&&n.type===`nextfile`&&e.input.closeFile(e)}}function ij(e){let{rules:t}=e.program;for(let n=0;n<t.length;n++){let r=t[n];if(!oj(e,r,n))continue;if(r.action===null){fj(e,null,e.record+Q(e.globals.get(`ORS`),e));continue}let i=aj(e,r.action);if(i!==void 0)return i}}function aj(e,t){try{return sj(e,t)}catch(e){if(!(e instanceof Lk))throw e;return e.signal}}function oj(e,t,n){let{pattern:r}=t;if(r===null)return!0;if(r.type!==`range`)return Sk($(e,r));if(!e.ranges[n]){if(!Sk($(e,r.from)))return!1;e.ranges[n]=!0}return Sk($(e,r.to))&&(e.ranges[n]=!1),!0}function sj(e,t){for(let n of t){let t=cj(e,n);if(t!==void 0)return t}}function cj(e,t){if(++e.steps>sh)throw new W(`execution stopped after ${sh} statements (infinite loop?)`,null,`execution limit`);switch(t.type){case`block`:return sj(e,t.body);case`empty`:return;case`expr`:$(e,t.expr);return;case`print`:return pj(e,t);case`printf`:return mj(e,t);case`if`:return Sk($(e,t.test))?cj(e,t.consequent):t.alternate===null?void 0:cj(e,t.alternate);case`while`:case`do`:case`for`:return lj(e,t);case`forin`:return uj(e,t);case`switch`:return dj(e,t);case`break`:return KA;case`continue`:return qA;case`next`:return JA;case`nextfile`:return YA;case`exit`:return hj(e,t);case`return`:return{type:`return`,value:t.value===null?void 0:$(e,t.value)};case`delete`:{let n=Wk(e,t.name);t.subs===null?n.clear():n.delete(Zk(e,t.subs));return}default:throw new W(`unknown statement: ${t.type}`)}}function lj(e,t){t.init&&$(e,t.init);let n=!0;for(;t.type===`do`&&n||t.test===null||Sk($(e,t.test));){n=!1;let r=cj(e,t.body);if(r===KA)return;if(r!==void 0&&r!==qA)return r;t.step&&$(e,t.step)}}function uj(e,t){let n=Wk(e,t.array);for(let r of Array.from(n.keys())){Uk(e,t.name,new X(r));let n=cj(e,t.body);if(n===KA)return;if(n!==void 0&&n!==qA)return n}}function dj(e,t){let n=$(e,t.expr),r=t=>t.test.type===`regex`?iA(e,t.test).test(Q(n,e)):xk(n,t.test.value,e)===0,i=t.cases.findIndex(e=>e.test!==null&&r(e));if(i===-1&&(i=t.cases.findIndex(e=>e.test===null)),i!==-1)for(let n=i;n<t.cases.length;n++){let r=sj(e,t.cases[n].body);if(r===KA)return;if(r!==void 0)return r}}function fj(e,t,n){if(t===null){e.out.push(n);return}let r=Q($(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 W(tk(r),null,`output redirection`)}function pj(e,t){let n=Q(e.globals.get(`ORS`),e),r;if(t.args.length===0)r=e.record;else{let n=Q(e.globals.get(`OFS`),e);r=t.args.map(t=>_k($(e,t),e)).join(n)}fj(e,t.dest,r+n)}function mj(e,t){let n=t.args.map(t=>$(e,t));fj(e,t.dest,DA(e,Q(n[0],e),n.slice(1)))}function hj(e,t){return t.value!==null&&(e.exitCode=(Math.trunc(Z($(e,t.value)))%256+256)%256),XA}var gj=`awk [-F fs] [-v var=value] 'program' [file ...] | awk [-F fs] [-v var=value] -f progfile [file ...]`,_j=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u;function vj(e,t,n){let{values:r,positional:i}=U(bj(t),{valueShort:[`F`],repeatable:[`v`,`f`],stopAtFirstPositional:!0}),a=xj(r.get(`f`)??[],i,n);if(a.error)return a.error;let o;try{hk({byteLocale:tn(n)},a.text),o=IO(a.text)}catch(e){if(e instanceof RangeError)return C(`feature`,`awk`,`parser depth limit`,`awk: program too deeply nested (${e.message})`);if(S(e))return qe(e,`awk`,`awk: ${e.message}`);if(!(e instanceof W))throw e;let t=e.line===null?`awk: ${e.message}`:`awk: ${e.kind} at line ${e.line}: ${e.message}`;return e.gap===null?x(t):C(`feature`,`awk`,e.gap,t)}let s=ZA(o,n,e,a.operands);for(let e of o.warnings)s.warn(e);let c,l=null;try{r.has(`F`)&&s.assign(`FS`,eO(r.get(`F`),s.warn));for(let e of r.get(`v`)??[]){let t=_j.exec(e);if(!t)return x(`awk: -v: expected var=value but got \`${e}\``);s.assign(t[1],new X(eO(t[2],s.warn)))}c=$A(s)}catch(e){let t=S(e);if(!(e instanceof W)&&!(e instanceof RangeError)&&!t)throw e;s.errOut.push(`awk: ${e.message}
338
+ `),c=2,e instanceof RangeError&&(l={detail:`runtime limit`,message:`awk: ${e.message}`}),e.gap&&(l={detail:e.gap,message:`awk: ${e.message}`}),t&&(l={detail:t.detail,message:`awk: ${e.message}`})}let u={stdout:s.out.join(``),stderr:s.errOut.join(``),exitCode:c};return l===null?u:w(u,`feature`,`awk`,l.detail,l.message)}var yj=/^-[Fvf]\S*\s/su;function bj(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(yj.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 xj(e,t,n){if(e.length===0)return t.length===0?{error:Ge(gj,2)}:{text:t[0],operands:t.slice(1)};let r=[];for(let t of e){let{path:e,error:i}=N(n,`awk`,t);if(i||!n.fs.isFile(e))return{error:x(`awk: cannot open program file \`${t}\`: ${i??`Is a directory`}`,2)};r.push(n.fs.readFile(e))}return{text:r.join(`
339
+ `),operands:t}}function Sj(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`n`,`r`,`u`,`f`,`b`,`z`],valueShort:[`t`,`o`],valueLong:[`output`],repeatable:[`k`,`o`,`output`]}),o=[...i.get(`o`)??[],...i.get(`output`)??[]];if(o.length>1)return x(`sort: multiple output files specified`,2);let s=i.get(`t`);if(s!==void 0&&p(s).length!==1)return x(`sort: multi-character tab '${s}'`,2);let c={n:r.has(`n`),f:r.has(`f`),b:r.has(`b`),r:r.has(`r`)},l=Aj(i.get(`k`)??[],c);if(l.error)return l.error;let u=Un(`sort`,a,e,n,{stopOnError:!0});if(u.failed)return{stdout:``,stderr:u.stderr,exitCode:2};let d=r.has(`z`)?`\0`:`
340
+ `,f=Pn(Pj(u.inputs.flatMap(({content:e})=>Mn(e,d)),l.specs.length?l.specs:[{start:1,...c}],s,r.has(`u`),c.r),d);return o.length===0?Jn(f,u):Cj(o[0],f,n,u)}function Cj(e,t,n,r){if(e===`/dev/null`)return Jn(``,r);if(e===`/dev/stdout`)return Jn(t,r);n.io?.setReads([]);let i;try{i=n.writable&&n.fs.openWritable(n.cwd,e),i&&i.write(t)}catch(e){return P(n,`sort`,e?.path,e?.fsError),qe(e,`sort`,`sort: open failed: ${e.message}`,2)}return i?Jn(``,r):C(`feature`,`sort`,`-o`,`sort: open failed: ${e}: Read-only file system`,2)}var wj=`nrfb`,Tj=`bdfghiMnRrV`,Ej=/^[ \t]*\+?(\d+)/u,Dj=(e,t)=>x(`sort: ${e}: invalid count at start of '${t}'`,2),Oj=(e,t)=>x(`sort: ${e}: invalid field specification '${t}'`,2);function kj(e){let t=0,n=null,r=r=>{let i=Ej.exec(e.slice(t));return i===null?(n=Dj(r,e.slice(t)),null):(t+=i[0].length,Number(i[1]))},i=n=>{let i=r(n);if(i===null)return null;let a=null;if(e[t]===`.`&&(t++,a=r(`invalid number after '.'`),a===null))return null;let o=t;for(;t<e.length&&/[a-zA-Z]/u.test(e[t]);)t++;return{field:i,offset:a,mods:e.slice(o,t)}},a=i(`invalid number at field start`);if(a===null)return{error:n};let o=null;return e[t]===`,`&&(t++,o=i(`invalid number after ','`),o===null)?{error:n}:a.field===0||o?.field===0?{error:Oj(`field number is zero`,e)}:a.offset===0?{error:Oj(`character offset is zero`,e)}:t===e.length?{from:a,to:o}:{error:Oj(`stray character in field spec`,e)}}function Aj(e,t){let n=[];for(let r of e){let e=kj(r);if(e.error)return{error:e.error};let{from:i,to:a}=e,o=i.mods+(a?.mods??``);for(let e of o)if(!wj.includes(e))return Tj.includes(e)?{error:C(`option`,`sort`,`-k${r}`,`sort: unknown key option \`${e}\` in ${r}`,2)}:{error:Oj(`stray character in field spec`,r)};if(i.offset!==null||(a?.offset??0)!==0)return{error:C(`option`,`sort`,`-k${r}`,`sort: invalid key specification: ${r} (character offsets are not supported)`,2)};let s=o.length>0;n.push({start:i.field,end:a?.field,n:s?o.includes(`n`):t.n,r:s?o.includes(`r`):t.r,f:s?o.includes(`f`):t.f,b:s?i.mods.includes(`b`):t.b})}return{specs:n}}function jj(e,t){let n=[];if(t!==void 0){let r=0;for(;;){let i=e.indexOf(t,r);if(i===-1){n.push([r,e.length]);break}n.push([r,i]),r=i+t.length}return n}let r=0;do{let t=r;for(;r<e.length&&/[ \t]/u.test(e[r]);)r++;for(;r<e.length&&!/[ \t]/u.test(e[r]);)r++;n.push([t,r])}while(r<e.length);return n}function Mj(e,t,n){if(t.start>n.length)return``;let r=n[t.start-1][0],i=t.end===void 0||t.end>n.length?e.length:n[t.end-1][1];if(t.b)for(;r<i&&/[ \t]/u.test(e[r]);)r++;return e.slice(r,Math.max(r,i))}var Nj=e=>e.replace(/[a-z]/gu,e=>e.toUpperCase());function Pj(e,t,n,r,i){let a=t.every(e=>e.start===1&&e.end===void 0);if(a&&t.length===1&&!t[0].n&&!t[0].f&&!t[0].b)return e.sort(e.some(e=>/[\u{10000}-\u{10FFFF}]/u.test(e))?j:void 0),t[0].r&&e.reverse(),r?e.filter((t,n)=>n===0||t!==e[n-1]):e;let o=e.map(e=>{let r=a?[[0,e.length]]:jj(e,n);return{line:e,keys:t.map(t=>{let n=Mj(e,t,r);return t.n?Fj(n):t.f?Nj(n):n})}}),s=(e,n)=>{for(let r=0;r<t.length;r++){let i=t[r],a=i.n?Lj(e.keys[r],n.keys[r]):j(e.keys[r],n.keys[r]);if(a!==0)return i.r?-a:a}return r?0:(i?-1:1)*j(e.line,n.line)};o.sort(s);let c=[];for(let e=0;e<o.length;e++)r&&e>0&&s(o[e-1],o[e])===0||c.push(o[e].line);return c}function Fj(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 Ij=(e,t)=>e<t?-1:+(e>t);function Lj(e,t){if(e.negative!==t.negative)return e.negative?-1:1;let n=e.integer.length-t.integer.length||Ij(e.integer,t.integer)||Ij(e.fraction,t.fraction);return e.negative?-n:n}async function Rj(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`r`,`0`],valueShort:[`n`,`I`],stopAtFirstPositional:!0}),[o=`echo`,...s]=a,c=i.get(`I`),l=i.has(`n`)?Yn(i.get(`n`),`xargs: -n`):{value:void 0};if(l.error)return l.error;if(l.value===0)return x(`xargs: -n: must be at least 1`);if(c===``)return x(`xargs: -I: replacement string must not be empty`);if(c!==void 0&&l.value!==void 0)return C(`option`,`xargs`,`-I -n`,`xargs: combining replacement and chunk limits is not supported`);if(F(n),!r.has(`0`)&&e.includes(`\0`))return C(`feature`,`xargs`,`NUL input`,`xargs: NUL input requires -0`);let u;if(r.has(`0`))u=Mn(e,`\0`);else if(c===void 0)u=Bj(e);else{if(/["'\\]/u.test(e))return C(`feature`,`xargs`,`-I input quoting`,`xargs: quoted or escaped replacement lines are not supported`);u=Mn(e).map(e=>e.replace(/^[ \t\r\f\v]+/u,``)).filter(Boolean)}if(u.length===0&&(r.has(`r`)||c!==void 0))return b();let d=c===void 0?l.value??Math.max(1,u.length):1,f=G(),p=0;for(let e=0;e<Math.max(1,u.length);e+=d){let t=u[e],r=c===void 0?[...s,...u.slice(e,e+d)]:s.map(e=>e.replaceAll(c,t)),i=await n.dispatch(o,r,``,{devNull:!0});if(K(f,i),i.exitCode===255)return K(f,{...G(`xargs: ${o}: exited with status 255; aborting
341
+ `),exitCode:124}),f;if(i.exitCode===127&&!n.hasCommand(n.registry.resolveCommand(o)))return{...f,exitCode:127};i.exitCode!==0&&(p=123)}return{...f,exitCode:p,ignored:!1}}var zj=e=>Error(`unmatched ${e===`'`?`single`:`double`} quote; by default quotes are special to xargs unless you use the -0 option`);function Bj(e){let t=[],n=null,r=!1,i=``;for(let a=0;a<e.length;a++){let o=e[a];if(r||!/[ \t\n\r\f\v]/u.test(o)){if(n){if(o===n)n=null;else{if(o===`
342
+ `)throw zj(n);i+=o}}else if(o===`"`||o===`'`)n=o,r=!0;else if(o===`\\`){if(a+1>=e.length)break;i+=e[++a],r=!0}else o===` `||o===` `||o===`
343
+ `?(r&&t.push(i),i=``,r=!1):(i+=o,r=!0)}}if(n)throw zj(n);return r&&t.push(i),t}function Vj(e,t,n,r){let{values:i,positional:a,order:o}=U(Wj(n),{short:[`q`,`v`],valueShort:[`c`,`n`]}),s=o.findLast(e=>e.name===`n`||e.name===`c`)?.name??`n`,c=Xn(i.get(s)??`10`,e+`: -`+s);if(c.error)return c.error;let l=o.findLast(e=>e.name===`q`||e.name===`v`),u=l?l.name===`v`:null,d=e===`head`,f=c.sign===`+`;if(d&&c.value===0&&c.sign!==`-`)return Kj(e,t,a,r,()=>``,{unit:s,banner:u,leftover:e=>e,readOptions:{noRead:!0}});if(!d&&c.value===0&&!f){if(!r.stdinFile&&(!a.length||a.includes(`-`)||a.includes(`/dev/stdin`))){let n=Jj(e,t,``,s,`standard input`);n&&r.notes.add(n)}return b()}let p=e=>d?[0,c.sign===`-`?Math.max(0,e-c.value):c.value]:[f?Math.min(e,Math.max(0,c.value-1)):Math.max(0,e-c.value),e];return Kj(e,t,a,r,e=>{if(s===`c`)return Gj(e,p);let t=d?c.sign===`-`:!f,n=Uj(e,d||t?c.value:Math.max(0,c.value-1),t);return d?e.slice(0,n):e.slice(n)},{unit:s,banner:u,leftover:d?Hj(c,s,r):void 0,readOptions:!d&&f?{stopOnDir:!0}:void 0})}function Hj(e,t,n){return e.sign===`-`||t===`n`&&!n.stdinFile?()=>``:t===`c`?t=>Gj(t,t=>[Math.min(e.value,t),t]):t=>t.slice(Uj(t,e.value))}function Uj(e,t,n=!1){if(n){if(t===0)return e.length;let n=e.length-Number(e.endsWith(`
344
344
  `));for(let r=0;r<t;r++)if(n<=0||(n=e.lastIndexOf(`
345
345
  `,n-1),n<0))return 0;return n+1}let r=0;for(let n=0;n<t&&r<e.length;n++){let t=e.indexOf(`
346
- `,r);r=t===-1?e.length:t+1}return r}function Vj(e){return/^-\d+$/u.test(e[0]??``)?[`-n`,e[0].slice(1),...e.slice(1)]:e}function Hj(e,t){let n=p(e),[r,i]=t(n.length);return r===0&&i>=n.length?e:D(n.subarray(r,i))}function Uj(e,t,n,r,i,{unit:a,banner:o,leftover:s=()=>``,readOptions:c}){let l=Hn(e,n,t,r,c),u=o??n.length>1,d=l.entries.filter(e=>e.kind!==`missing`),f=[],p=[],m=null;for(let t=0;t<d.length;t++){let{name:n,kind:o,shared:c}=d[t],{content:l}=d[t];(c||n===null)&&(m!==null&&(l=m),m=s(l),F(r,m));let h=o===`dir`?``:i(l);if(o===`file`&&h!==l){let t=Gj(e,l,h,a,Gn(n,r));t&&p.push(t)}let g=n===null||n===`-`?`standard input`:n;f.push(u?`${t>0?`
346
+ `,r);r=t===-1?e.length:t+1}return r}function Wj(e){return/^-\d+$/u.test(e[0]??``)?[`-n`,e[0].slice(1),...e.slice(1)]:e}function Gj(e,t){let n=p(e),[r,i]=t(n.length);return r===0&&i>=n.length?e:D(n.subarray(r,i))}function Kj(e,t,n,r,i,{unit:a,banner:o,leftover:s=()=>``,readOptions:c}){let l=Un(e,n,t,r,c),u=o??n.length>1,d=l.entries.filter(e=>e.kind!==`missing`),f=[],p=[],m=null;for(let t=0;t<d.length;t++){let{name:n,kind:o,shared:c}=d[t],{content:l}=d[t];(c||n===null)&&(m!==null&&(l=m),m=s(l),F(r,m));let h=o===`dir`?``:i(l);if(o===`file`&&h!==l){let t=Jj(e,l,h,a,Kn(n,r));t&&p.push(t)}let g=n===null||n===`-`?`standard input`:n;f.push(u?`${t>0?`
347
347
  `:``}==> ${g} <==
348
- ${h}`:h)}for(let e of p)r.notes.add(e);return I(f.join(``),l)}function Wj(e){let t=+(e.length>0&&!e.endsWith(`
348
+ ${h}`:h)}for(let e of p)r.notes.add(e);return Jn(f.join(``),l)}function qj(e){let t=+(e.length>0&&!e.endsWith(`
349
349
  `));for(let n=e.indexOf(`
350
350
  `);n!==-1;n=e.indexOf(`
351
- `,n+1))t++;return t}function Gj(e,t,n,r,i){let a=r===`c`?e=>p(e).length:Wj,o=a(n),s=a(t);return o>=s?null:`${e}: selected ${o} of ${s} ${(r===`c`?`byte`:`line`)+(s===1?``:`s`)} from ${i}.`}function Kj(e,t,n){let{flags:r,positional:i}=U(t,{short:[`l`,`w`,`c`,`m`]}),a=Jj(r),o=Hn(`wc`,i,e,n,{read:`as-held`}),s=i.length>1||Object.values(a).filter(Boolean).length>1,c=[],l={l:0,w:0,m:0,c:0};for(let{name:e,content:t,bytes:r,kind:i,shared:u}of o.entries.filter(e=>e.kind!==`missing`)){let o=Yj(r??t,n,a,s);c.push({counts:o,name:e,kind:i,shared:u}),l.l+=o.l,l.w+=o.w,l.m+=o.m,l.c+=o.c}let u=s?qj(c,n.stdinFile):1;return i.length>1&&c.push({counts:l,name:`total`}),I(Nn(c.map(e=>LD(e.counts,e.name,a,u,n))),o)}function qj(e,t){let n=0,r=1;for(let{name:i,kind:a,shared:o,counts:s}of e)a===`dir`||(i===null||o)&&!t?r=7:n+=s.c;return Math.max(r,String(n).length)}function Jj(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 Yj(e,t,n,r){let i=en(t),a=n.c||r||n.m&&i?Xj(e):0;return{l:n.l?Mn(e):0,w:n.w?aM(e,t):0,m:n.m?i?a:Zj(e):0,c:a}}var Xj=e=>typeof e==`string`?p(e).length:e.length;function Zj(e){if(typeof e==`string`)return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of Ye(e))n>=0&&t++;return t}var Qj=new Set([9,10,11,12,13,32]),$j=new Set([160,8199,8239,8288]),eM=1,tM=0,nM=2,rM=Uint8Array.from({length:128},(e,t)=>Qj.has(t)?eM:t>32&&t<127?nM:tM),iM=(e,t)=>t.has(`print`,e)?t.has(`space`,e)||$j.has(e)?eM:nM:tM;function aM(e,t){let n=vn(t.locale),r=0,i=!1;for(let a of oM(e,t)){let e=a<0?tM:a<128?rM[a]:iM(a,n);e===eM?(i&&r++,i=!1):e===nM&&(i=!0)}return i?r+1:r}function*oM(e,t){if(typeof e!=`string`){yield*en(t)?e:Ye(e);return}if(en(t)){yield*p(e);return}for(let t=0;t<e.length;){let n=e.codePointAt(t);yield n>=55296&&n<=57343?65533:n,t+=n>65535?2:1}}function sM(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 cM(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`c`,`d`,`u`,`i`,`D`],valueShort:[`f`,`s`,`w`]});if(a.length>2)return x(`uniq: extra operand: ${a[2]}`);if(a.length===2&&a[1]!==`-`)return C(`feature`,`uniq`,`output file`,`uniq: output files are not supported (filesystem is read-only)`);let o=qn(i.get(`f`)??`0`,`uniq: -f`);if(o.error)return o.error;let s=qn(i.get(`s`)??`0`,`uniq: -s`);if(s.error)return s.error;let c=i.has(`w`)?qn(i.get(`w`),`uniq: -w`):{value:void 0};if(c.error)return c.error;let l=r.has(`D`),u=r.has(`c`);if(l&&u)return x(`uniq: printing all duplicated lines and repeat counts is meaningless`);let d=Kn(`uniq`,a.slice(0,1),e,n),f=r.has(`d`),m=r.has(`u`),h=r.has(`i`),g=e=>{let t=o.value>0?sM(e,o.value):e;if(s.value===0&&c.value===void 0){let e=t.toWellFormed();return h?e.replace(/[A-Z]/gu,e=>e.toLowerCase()):e}let n=p(t).subarray(s.value,c.value===void 0?void 0:s.value+c.value);return(h?n.map(e=>e>=65&&e<=90?e+32:e):n).join(`,`)},_=jn(d.content),ee=[],v=0,te=_.length?g(_[0]):null;for(let e=1;e<=_.length;e++){let t=e===_.length?null:g(_[e]);if(e<_.length&&t===te)continue;let n=e-v,r=n>=2;(l?r:!(f&&m)&&(f?r:!m||!r))&&(l?ee.push(..._.slice(v+ +!!m,e)):ee.push(u?String(n).padStart(7)+` `+_[v]:_[v])),v=e,te=t}return I(Nn(ee),d)}function lM(){return b()}function uM(){return{stdout:``,stderr:``,exitCode:1}}var dM={grep:z_,head:(e,t,n)=>Rj(`head`,e,t,n),tail:(e,t,n)=>Rj(`tail`,e,t,n),wc:Kj,sort:yj,uniq:cM,echo:SD,printf:kD,xargs:Fj,awk:hj},fM={true:lM,false:uM,":":lM},pM={test:rD,cat:VT,...dM,...BT,...Db},mM=(e,t)=>(n,r,i)=>{let a=dM.grep(n,[t,...r],i),o=S(a);return o?w(a,o.kind,e,o.detail,o.message):a},hM={__proto__:null,sed:XE,egrep:mM(`egrep`,`-E`),fgrep:mM(`fgrep`,`-F`),"[":iD,...Ob,...fM,...bD,...pM},gM=new Set([`cd`,`:`,...Object.keys(bD)]),_M=e=>!!hM[e],vM=new Set([`basename`,`cp`,`dirname`,`ln`,`mkdir`,`patch`,`rm`,`tee`,`touch`]),yM=Object.fromEntries(Object.entries(pM).filter(([e])=>!vM.has(e))),bM=`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`.split(`.`),xM=Object.keys(hM).filter(e=>!gM.has(e)&&!Object.hasOwn(yM,e)).sort(),SM=new Set([`base32`,`brotli`,`egrep`,`fgrep`,`gunzip`,`gzcat`,`gzip`,`od`,`sed`,`sha1sum`,`sha256sum`,`sha384sum`,`sha512sum`,`shasum`,`tar`,`tee`,`xxd`,`zcat`]),CM=TM(),wM=[`grep`,`head`,`tail`,`wc`,`sort`,`uniq`,`cut`,`xargs`,`awk`,`tr`,`nl`,`tac`,`hexdump`,`cat`,`base64`,`diff`,`patch`];function TM(){let e=new Set(Object.keys(yM)),t=[];for(let n of bM)e.delete(n)&&t.push(n);return t.push(...[...e].sort()),t}var EM=Object.freeze([`/usr/local/bin/`,`/usr/bin/`,`/bin/`,`/sbin/`]);function DM(e,t){for(let n of EM)if(e.startsWith(n)){let r=e.slice(n.length);if(t(r))return r}return e}var OM=new Set([`test`,`[`,`true`,`false`]),kM=new Set([`grep`,`egrep`,`fgrep`]);function AM(e,t){let n=DM(e[0],t);return OM.has(n)?`status`:kM.has(n)?R_(e.slice(1))?`status`:`search`:`work`}function jM(e,t=!1){let n=tm(t),r=n===null?[]:em,i=$a(e,e=>_M(e)||r.includes(e)),a=Object.freeze({__proto__:null,...hM,...n,...i.handlers}),o=e=>!!a[e],s=Object.freeze([...CM,...r,...xM,...i.names]);return Object.freeze({commands:a,names:s,pipeNames:Object.freeze([...wM,...r,...xM.filter(e=>SM.has(e)),...i.pipeNames]),binPrefixes:EM,has:o,shellOnly:e=>gM.has(e),resolveCommand:e=>DM(e,o),chainRole:e=>AM(e,o),known:[...CM,...r,...i.names].join(`, `)})}var MM=jM(),NM=null,PM=e=>e?(NM??=jM(void 0,!0),NM):MM;function FM(e,t){let n=xD.get(e);return n===void 0?C(`command`,e,e,`${e}: command not found. Available: ${t.known}`,127):C(`feature`,e,e,`${e}: ${n}`,127)}function IM(e,t,n){let r=BM(e);if(!r)return[];let{start:i,pipe:a,quote:o,words:s}=r;for(;LM.has(s[0]);)s.shift();if(RM.has(s[0])||s[0]===`for`&&s.length<=2)return[];let c=e.slice(i),l=VM(c,o);if(!l)return[];let u=s.length===0,d=u?``:n.resolveCommand(VM(s[0],null)?.value??``),f=u?zM(l.value,a,n,t.functions):a?[]:UM(l,t,d===`cd`),p=e.slice(0,i),m=a&&c===``&&p.endsWith(`|`)?` `:``;return f.map(e=>p+m+c+HM(e.slice(l.value.length),o))}var LM=new Set([`!`,`{`,`do`,`then`,`else`,`elif`,`if`,`while`,`until`]),RM=new Set([`done`,`fi`,`}`,`esac`]);function zM(e,t,n,r){let i=t?n.pipeNames:n.names;for(let t of n.binPrefixes)if(e.startsWith(t))return i.filter(n=>n.startsWith(e.slice(t.length))).map(e=>t+e);if(e.startsWith(`/`)||e.startsWith(`./`))return[];let a=[...r.keys()].filter(e=>!i.includes(e));return[...i,...a].filter(t=>t.startsWith(e))}function BM(e){let t=0,n=!1,r=null,i=!1,a=-1,o=[];for(let s=0;s<e.length;s++){let c=e[s];if(r===`'`){c===r&&(r=null);continue}if(c===`\\`&&(!r||`$\`"\\
351
+ `,n+1))t++;return t}function Jj(e,t,n,r,i){let a=r===`c`?e=>p(e).length:qj,o=a(n),s=a(t);return o>=s?null:`${e}: selected ${o} of ${s} ${(r===`c`?`byte`:`line`)+(s===1?``:`s`)} from ${i}.`}function Yj(e,t,n){let{flags:r,positional:i}=U(t,{short:[`l`,`w`,`c`,`m`]}),a=Zj(r),o=Un(`wc`,i,e,n,{read:`as-held`}),s=i.length>1||Object.values(a).filter(Boolean).length>1,c=[],l={l:0,w:0,m:0,c:0};for(let{name:e,content:t,bytes:r,kind:i,shared:u}of o.entries.filter(e=>e.kind!==`missing`)){let o=Qj(r??t,n,a,s);c.push({counts:o,name:e,kind:i,shared:u}),l.l+=o.l,l.w+=o.w,l.m+=o.m,l.c+=o.c}let u=s?Xj(c,n.stdinFile):1;return i.length>1&&c.push({counts:l,name:`total`}),Jn(Pn(c.map(e=>BD(e.counts,e.name,a,u,n))),o)}function Xj(e,t){let n=0,r=1;for(let{name:i,kind:a,shared:o,counts:s}of e)a===`dir`||(i===null||o)&&!t?r=7:n+=s.c;return Math.max(r,String(n).length)}function Zj(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 Qj(e,t,n,r){let i=tn(t),a=n.c||r||n.m&&i?$j(e):0;return{l:n.l?Nn(e):0,w:n.w?cM(e,t):0,m:n.m?i?a:eM(e):0,c:a}}var $j=e=>typeof e==`string`?p(e).length:e.length;function eM(e){if(typeof e==`string`)return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of Xe(e))n>=0&&t++;return t}var tM=new Set([9,10,11,12,13,32]),nM=new Set([160,8199,8239,8288]),rM=1,iM=0,aM=2,oM=Uint8Array.from({length:128},(e,t)=>tM.has(t)?rM:t>32&&t<127?aM:iM),sM=(e,t)=>t.has(`print`,e)?t.has(`space`,e)||nM.has(e)?rM:aM:iM;function cM(e,t){let n=yn(t.locale),r=0,i=!1;for(let a of lM(e,t)){let e=a<0?iM:a<128?oM[a]:sM(a,n);e===rM?(i&&r++,i=!1):e===aM&&(i=!0)}return i?r+1:r}function*lM(e,t){if(typeof e!=`string`){yield*tn(t)?e:Xe(e);return}if(tn(t)){yield*p(e);return}for(let t=0;t<e.length;){let n=e.codePointAt(t);yield n>=55296&&n<=57343?65533:n,t+=n>65535?2:1}}function uM(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 dM(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`c`,`d`,`u`,`i`,`D`],valueShort:[`f`,`s`,`w`]});if(a.length>2)return x(`uniq: extra operand: ${a[2]}`);if(a.length===2&&a[1]!==`-`)return C(`feature`,`uniq`,`output file`,`uniq: output files are not supported (filesystem is read-only)`);let o=Yn(i.get(`f`)??`0`,`uniq: -f`);if(o.error)return o.error;let s=Yn(i.get(`s`)??`0`,`uniq: -s`);if(s.error)return s.error;let c=i.has(`w`)?Yn(i.get(`w`),`uniq: -w`):{value:void 0};if(c.error)return c.error;let l=r.has(`D`),u=r.has(`c`);if(l&&u)return x(`uniq: printing all duplicated lines and repeat counts is meaningless`);let d=qn(`uniq`,a.slice(0,1),e,n),f=r.has(`d`),m=r.has(`u`),h=r.has(`i`),g=e=>{let t=o.value>0?uM(e,o.value):e;if(s.value===0&&c.value===void 0){let e=t.toWellFormed();return h?e.replace(/[A-Z]/gu,e=>e.toLowerCase()):e}let n=p(t).subarray(s.value,c.value===void 0?void 0:s.value+c.value);return(h?n.map(e=>e>=65&&e<=90?e+32:e):n).join(`,`)},_=Mn(d.content),ee=[],v=0,te=_.length?g(_[0]):null;for(let e=1;e<=_.length;e++){let t=e===_.length?null:g(_[e]);if(e<_.length&&t===te)continue;let n=e-v,r=n>=2;(l?r:!(f&&m)&&(f?r:!m||!r))&&(l?ee.push(..._.slice(v+ +!!m,e)):ee.push(u?String(n).padStart(7)+` `+_[v]:_[v])),v=e,te=t}return Jn(Pn(ee),d)}function fM(){return b()}function pM(){return{stdout:``,stderr:``,exitCode:1}}var mM={grep:H_,head:(e,t,n)=>Vj(`head`,e,t,n),tail:(e,t,n)=>Vj(`tail`,e,t,n),wc:Yj,sort:Sj,uniq:dM,echo:TD,printf:MD,xargs:Rj,awk:vj},hM={true:fM,false:pM,":":fM},gM={test:oD,cat:WT,...mM,...UT,...Ab},_M=(e,t)=>(n,r,i)=>{let a=mM.grep(n,[t,...r],i),o=S(a);return o?w(a,o.kind,e,o.detail,o.message):a},vM={__proto__:null,sed:$E,egrep:_M(`egrep`,`-E`),fgrep:_M(`fgrep`,`-F`),"[":sD,...jb,...hM,...CD,...gM},yM=new Set([`cd`,`:`,...Object.keys(CD)]),bM=e=>!!vM[e],xM=new Set([`basename`,`cp`,`dirname`,`ln`,`mkdir`,`patch`,`rm`,`tee`,`touch`]),SM=Object.fromEntries(Object.entries(gM).filter(([e])=>!xM.has(e))),CM=`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`.split(`.`),wM=Object.keys(vM).filter(e=>!yM.has(e)&&!Object.hasOwn(SM,e)).sort(),TM=new Set([`base32`,`brotli`,`egrep`,`fgrep`,`gunzip`,`gzcat`,`gzip`,`od`,`sed`,`sha1sum`,`sha256sum`,`sha384sum`,`sha512sum`,`shasum`,`tar`,`tee`,`xxd`,`zcat`]),EM=OM(),DM=[`grep`,`head`,`tail`,`wc`,`sort`,`uniq`,`cut`,`xargs`,`awk`,`tr`,`nl`,`tac`,`hexdump`,`cat`,`base64`,`diff`,`patch`];function OM(){let e=new Set(Object.keys(SM)),t=[];for(let n of CM)e.delete(n)&&t.push(n);return t.push(...[...e].sort()),t}var kM=Object.freeze([`/usr/local/bin/`,`/usr/bin/`,`/bin/`,`/sbin/`]);function AM(e,t){for(let n of kM)if(e.startsWith(n)){let r=e.slice(n.length);if(t(r))return r}return e}var jM=new Set([`test`,`[`,`true`,`false`]),MM=new Set([`grep`,`egrep`,`fgrep`]);function NM(e,t){let n=AM(e[0],t);return jM.has(n)?`status`:MM.has(n)?V_(e.slice(1))?`status`:`search`:`work`}function PM(e,t=!1){let n=im(t),r=n===null?[]:rm,i=to(e,e=>bM(e)||r.includes(e)),a=Object.freeze({__proto__:null,...vM,...n,...i.handlers}),o=e=>!!a[e],s=Object.freeze([...EM,...r,...wM,...i.names]);return Object.freeze({commands:a,names:s,pipeNames:Object.freeze([...DM,...r,...wM.filter(e=>TM.has(e)),...i.pipeNames]),binPrefixes:kM,has:o,shellOnly:e=>yM.has(e),resolveCommand:e=>AM(e,o),chainRole:e=>NM(e,o),known:[...EM,...r,...i.names].join(`, `)})}var FM=PM(),IM=null,LM=e=>e?(IM??=PM(void 0,!0),IM):FM;function RM(e,t){let n=wD.get(e);return n===void 0?C(`command`,e,e,`${e}: command not found. Available: ${t.known}`,127):C(`feature`,e,e,`${e}: ${n}`,127)}function zM(e,t,n){let r=UM(e);if(!r)return[];let{start:i,pipe:a,quote:o,words:s}=r;for(;BM.has(s[0]);)s.shift();if(VM.has(s[0])||s[0]===`for`&&s.length<=2)return[];let c=e.slice(i),l=WM(c,o);if(!l)return[];let u=s.length===0,d=u?``:n.resolveCommand(WM(s[0],null)?.value??``),f=u?HM(l.value,a,n,t.functions):a?[]:KM(l,t,d===`cd`),p=e.slice(0,i),m=a&&c===``&&p.endsWith(`|`)?` `:``;return f.map(e=>p+m+c+GM(e.slice(l.value.length),o))}var BM=new Set([`!`,`{`,`do`,`then`,`else`,`elif`,`if`,`while`,`until`]),VM=new Set([`done`,`fi`,`}`,`esac`]);function HM(e,t,n,r){let i=t?n.pipeNames:n.names;for(let t of n.binPrefixes)if(e.startsWith(t))return i.filter(n=>n.startsWith(e.slice(t.length))).map(e=>t+e);if(e.startsWith(`/`)||e.startsWith(`./`))return[];let a=[...r.keys()].filter(e=>!i.includes(e));return[...i,...a].filter(t=>t.startsWith(e))}function UM(e){let t=0,n=!1,r=null,i=!1,a=-1,o=[];for(let s=0;s<e.length;s++){let c=e[s];if(r===`'`){c===r&&(r=null);continue}if(c===`\\`&&(!r||`$\`"\\
352
352
  `.includes(e[s+1]))){if(s+1===e.length)return null;e[++s]!==`
353
353
  `&&(i=!0);continue}if(c==="`"||c===`$`&&e[s+1]===`(`)return null;if(r){c===r&&(r=null);continue}if(c===`'`||c===`"`){r=c,i=!0;continue}if(c===`#`&&!i){let t=e.indexOf(`
354
354
  `,s);if(t===-1)return null;s=t-1;continue}if(c===` `||c===` `){i&&o.push(e.slice(t,s)),t=s+1,i=!1;continue}let l=c===`|`&&e[s+1]===`|`,u=c===`&`&&e[s+1]===`&`;if(c===`|`||u||c===`;`||c===`
355
- `||c===`(`||c===`)`&&a===s-1){(l||u)&&s++,c===`(`&&(a=s),t=s+1,n=c===`|`&&!l,o.length=0,i=!1;continue}i=!0}return{start:t,pipe:n,quote:r,words:o}}function VM(e,t){if(e===``)return{value:``,mask:null};try{let n=Fi(e+(t??``));if(n.length!==1||n[0].kind!==`word`)return null;let r=n[0];for(let e=0;e<r.value.length;e++){let t=r.mask?.[e]??`0`;if(t!==`1`&&r.value[e]===`$`||t===`0`&&`*?[{`.includes(r.value[e]))return null}return r}catch{return null}}function HM(e,t){return t===`'`?e.replaceAll(`'`,`'\\''`)+`'`:t===`"`?e.replace(/[\\$`"]/gu,`\\$&`)+`"`:e.replace(/[\s\\'"`$&|;()<>*?[\]{}!#~]/gu,e=>e===`
355
+ `||c===`(`||c===`)`&&a===s-1){(l||u)&&s++,c===`(`&&(a=s),t=s+1,n=c===`|`&&!l,o.length=0,i=!1;continue}i=!0}return{start:t,pipe:n,quote:r,words:o}}function WM(e,t){if(e===``)return{value:``,mask:null};try{let n=Li(e+(t??``));if(n.length!==1||n[0].kind!==`word`)return null;let r=n[0];for(let e=0;e<r.value.length;e++){let t=r.mask?.[e]??`0`;if(t!==`1`&&r.value[e]===`$`||t===`0`&&`*?[{`.includes(r.value[e]))return null}return r}catch{return null}}function GM(e,t){return t===`'`?e.replaceAll(`'`,`'\\''`)+`'`:t===`"`?e.replace(/[\\$`"]/gu,`\\$&`)+`"`:e.replace(/[\s\\'"`$&|;()<>*?[\]{}!#~]/gu,e=>e===`
356
356
  `?`'
357
- '`:`\\`+e)}function UM(e,t,n=!1){let r=e.value,i=r.startsWith(`~`)&&(e.mask?.[0]??`0`)===`0`&&!e.empty?.some(e=>e<=1)&&(r.length===1||(e.mask?.[1]??`0`)===`0`);if(i&&r===`~`)return t.fs.isDir(k(t.cwd,OS(t),t.fs).path)?[`~/`]:[];if(i&&!r.startsWith(`~/`))return[];let a=r.lastIndexOf(`/`),o=r.slice(0,a+1),s=r.slice(a+1),c=i?OS(t)+o.slice(1):o||`.`,l=k(t.cwd,c,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:u,files:d,links:f}=t.fs.listDir(l),p=u.map(e=>e+`/`);for(let e of f)t.fs.isDir(k(l,e,t.fs).path)?p.push(e+`/`):n||p.push(e);return n||p.push(...d),p.filter(e=>e.startsWith(s)&&(s.startsWith(`.`)||!e.startsWith(`.`))).filter(e=>o!==``||s===``||!e.startsWith(`-`)).map(e=>o===``&&e.startsWith(`-`)?`./`+e:o+e)}async function WM(e,t,n,r=!1){let i=(t.substitutionDepth??0)+1;if(i>Cr)throw new T(`feature`,`command substitution nesting limit`,`command substitution nesting beyond ${Cr} levels is not supported`);let a=t.expansionFds[2],o=await SS(t,{substitutionDepth:i,outputFds:{1:`out`,2:typeof a==`object`||a===`closed`?a:`err`},errexitOff:!0,closed:{out:!1,err:a===`closed`}},()=>xS(t,()=>{let i;try{i=wa(e,t.writable,t.registry.has)}catch(e){let n=S(e);if(!n){if(r)return x(`error: command substitution: ${e.message}`,2);throw new T(`feature`,`command substitution syntax`,`runtime command substitution syntax errors are not supported: ${e.message}`)}return t.unsupported.add(n),x(`error: ${e.message}`,1)}let a=i.length===1&&!i[0].negate&&i[0].stages.length===1?i[0].stages[0]:null;return a&&!a.group&&!a.loop&&!a.conditional&&!a.test&&a.words.length===0&&a.assigns.length===0&&a.redirs.length===1&&a.redirs[0].op===`read`&&a.words.push({value:`cat`,mask:null}),n(i,t,{text:t.stdinLeft,bytes:t.stdinBytes})}));t.lastExit=t.substitutionExit=o.exitCode;let s=o.stdout,c=o.stderr;if(s.includes(`\0`)){let e=s.length;s=s.replaceAll(`\0`,``);let n=e-s.length;t.notes.add(`command substitution: discarded ${n} NUL ${n===1?`byte`:`bytes`}.`),c+=`warning: command substitution: ignored null byte in input
358
- `}Yv(t,c);let l=s.length;for(;l>0&&s[l-1]===`
359
- `;)l--;return s.slice(0,l)}async function GM(e,t){return{stdout:``,stderr:``,exitCode:+!await qM(e,t)}}var KM=async(e,t)=>(await jS(e,t)).value;async function qM(e,t){let{kind:n}=e;if(n===`not`)return!await qM(e.expression,t);if(n===`and`)return await qM(e.left,t)&&await qM(e.right,t);if(n===`or`)return await qM(e.left,t)||await qM(e.right,t);let{op:r}=e;if(n===`unary`){let n=await KM(e.word,t);if(r===`-n`)return n!==``;if(r===`-z`)return n===``;if([`-a`,`-e`,`-f`,`-d`].includes(r))return cD(r,n,t);if(r===`-v`)return JM(n,t);YM(r)}[`<`,`>`,`-nt`,`-ot`,`-ef`].includes(r)&&YM(r);let i=await KM(e.left,t);if(Object.hasOwn(eD,r)){let n=await KM(e.right,t);return eD[r](sS(i,t),sS(n,t))}let a=await jS(e.right,t);r_(a)&&YM(`extglob`);let o=Jg(o_(a),{bash:!0}).test(i);return r===`!=`?!o:o}function JM(e,t){return e.includes(`[`)&&YM(`-v array subscript`),/^[ \t\n\r\f\v]*[+-]?0+[ \t]*$/u.test(e)&&YM(`-v positional parameter`),/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?Px(e,t).set:!1}function YM(e){throw new T(`feature`,`[[ ${e}`,`${e} in [[ is not supported`)}function XM(e,t,n,r){return e.define?(t.functions.set(e.define.name,e.define.body),G()):e.test?GM(e.test,t):e.group?rN(e,t,n,r):e.loop?e.loop.words?tN(e.loop,t,r):$M(e.loop,t,r):nN(e.conditional,t,n,r)}var ZM=1e4,QM={kind:`feature`,command:null,detail:`loop limit`,message:`a loop running more than ${ZM} times is not supported`};async function $M(e,t,n){let r=G(),i={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let a=0;;a++){if(a===ZM){t.unsupported.add(QM),K(r,x(`error: ${QM.message}`,1));break}let o=r.ignored,s=r.exitCode,c=await n(e.condition,t,i,!0);if(K(r,c),r.exitCode=s,r.ignored=o,c.halt||c.control)return{...r,halt:c.halt,control:c.control,blame:c.blame};if(c.exitCode===0==!!e.until)break;let l=await n(e.body,t,i);if(K(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 eN={value:`for`,mask:null};async function tN(e,t,n){let r=await CS([eN,...e.words],t),i=G(),a={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let o of r.argv.slice(1)){t.vars.set(e.name,o);let r=await n(e.body,t,a);if(K(i,r),i.blame=r.blame,r.halt)return{...i,halt:!0};if(r.control?.levels>1)return{...i,control:{...r.control,levels:r.control.levels-1}};if(r.control?.type===`break`)break}}finally{t.loopDepth--}return i}async function nN(e,t,n,r){let i=G(),a={text:n,bytes:t.stdinBytes};for(let n of e.branches){let e=await r(n.condition,t,a,!0);if(K(i,e),e.halt||e.control)return{...i,halt:e.halt,control:e.control,blame:e.blame};if(e.exitCode!==0)continue;let o=await r(n.body,t,a);return K(i,o),{...i,halt:o.halt,control:o.control,blame:o.blame}}if(!e.otherwise)return i.exitCode=0,i.ignored=!1,i;let o=await r(e.otherwise,t,a);return K(i,o),{...i,halt:o.halt,control:o.control,blame:o.blame}}async function rN(e,t,n,r){let i={text:n,bytes:t.stdinBytes};return e.isolate?{...await xS(t,()=>r(e.group,t,i)),halt:!1,control:void 0,ignored:!1}:r(e.group,t,i)}var iN=new Set([`sort`,`cat`]),aN=new Set([`wc`,`tac`]);function oN(e){let t=null,n=null,r=e=>{t&&!t.bufferReads&&t.reads.push(e)},i=e=>{if(e!==void 0)for(let r=t;r;r=r.parent){if(!r.reads.includes(e)||r===t&&n?.scope===r&&(n.unsupported||r.buffered||n.fd===1&&(iN.has(r.name)||aN.has(r.name)&&!r.reads.slice(1).includes(e))))continue;if(r.failure)throw r.failure;let i=r===t&&n?.fd===2,a=i?`input modified by diagnostics`:`streaming self-output`,o=i?`reading input while diagnostics write to the same file is not supported`:`writing to an actively read input file is not supported`;throw r.failure=w(new T(`feature`,a,o),`feature`,r.name,a,o),r.failure}};return e.observeIo?.({read:r,write:i}),{read:r,bufferOutput(){t&&(t.buffered=!0)},bufferReads(e){if(!t)return e();let n=t,r=n.bufferReads;n.bufferReads=!0;try{return e()}finally{n.bufferReads=r}},setReads(e){t&&(t.reads=e)},async run(e,n){let r=t;t={name:e,reads:[],parent:r};try{return await n()}finally{t=r}},output(e,r,a){let o=n;n={scope:t,fd:null,unsupported:!!S(e)};try{for(let t of qv(e))t.text!==``&&(n.fd=t.fd,i(r.fds[t.fd]?.identity));return a((e,t)=>{n.fd=e.fd,Kv(e,t)})}finally{n=o}}}}function sN(e,t){return Xv(e,{fds:{1:t.outputFds[1]?.path?t.outputFds[1]:`out`,2:t.outputFds[2]?.path?t.outputFds[2]:`err`},deferred:{1:cN(t.outputFds[1]),2:cN(t.outputFds[2])}},t)}var cN=e=>e!==`out`&&e!==`err`&&!e?.path;async function lN(e,t,n,r=!1){if(e.some(e=>e.background))throw new T(`feature`,`&`,"background processes (`&`) are not supported");let i=G(),a=null,o=null;for(let[s,c]of e.entries()){if(c.warnings&&K(i,Xv({...G(c.warnings),exitCode:i.exitCode,ignored:i.ignored},{fds:t.outputFds},t)),c.gate===`and`&&i.exitCode!==0){(o??=On()).skip(r?null:a,i.exitCode);continue}if(c.gate===`or`&&i.exitCode===0)continue;o?.flush(t.notes);let l=r||c.negate||uN(e,s),u=await(l?SS(t,{errexitOff:!0},()=>dN(c.stages,t,n)):dN(c.stages,t,n));if(K(i,u),c.negate&&!u.halt&&(i.exitCode=+(u.exitCode===0)),l&&(i.ignored=!0),a=c.negate?null:u.blame,t.lastExit=i.exitCode,u.halt||u.control){Object.assign(i,{halt:u.halt,control:u.control});break}if(i.exitCode!==0&&!i.ignored&&t.errexit&&!t.errexitOff){i.halt=!0;break}}return o?.flush(t.notes),t.stdinLeft=n.text,t.stdinBytes=n.bytes??null,Object.assign(i,{blame:a})}var uN=(e,t)=>[`and`,`or`].includes(e[t+1]?.gate);async function dN(e,t,n){let r=G(),i=n.text,a=n.bytes??null;for(let o=0;o<e.length;o++){let s=e[o],c=o===0,l=o<e.length-1?fN():null,u={...t.outputFds};l&&(u[1]=l);let d=a,f=i,p=()=>pN(s,t,{stdin:f,stdinBytes:d,stdinFile:c&&t.stdinFile,fds:u,stdinPiped:!c||t.stdinPiped,stdinTerminal:c&&t.stdinTerminal}),m=e.length>1?{...await xS(t,p),ignored:!1}:await p();c&&(n.text=m.inputLeft,n.bytes=m.bytesLeft??null),K(r,m);let h=l?.carried()??{text:``};a=h.bytes??null,i=h.text??$e(h.bytes)??``,r.blame=m.blame,e.length===1&&(r.halt=m.halt,r.control=m.control)}return r}function fN(){let e=``,t=null;return{write(n){t===null?e+=n:n!==``&&t.push(E(n))},writeBytes(n){t===null&&(t=e===``?[]:[E(e)],e=``),t.push(n)},carried:()=>t===null?{text:e}:{bytes:ct([...t,new Uint8Array])}}}function pN(e,t,{stdin:n,stdinBytes:r,stdinFile:i,fds:a,stdinPiped:o,stdinTerminal:s}){let c={fds:a,stdin:n,stdinBytes:r,stdinFile:i,stdinPiped:o,stdinTerminal:s,stdinOrigin:i?t.stdinOrigin:null,stdinHandle:i?t.stdinHandle:null};return SS(t,{substitutionExit:null,expansionOutput:G(),expansionFds:a},()=>vN(c,t,async()=>{let n=!e.group&&!e.loop&&!e.conditional&&!e.test&&!e.define,r,o;try{n&&(r=await CS(e.words,t),r.argv.length===0?await SN(e.assigns,t):r.temps=await CN(e.assigns,t))}catch(e){o=gN(t,e)}if(o)return K(t.expansionOutput,mN(o,c,t)),{...t.expansionOutput,inputLeft:t.stdinLeft,bytesLeft:t.stdinBytes,halt:o.halt};let s=await hN(e,t,t.stdinLeft,i,a);t.expansionFds=s.fds;let l=!1,u=null,d=await vN(s,t,()=>_N(t,async()=>{if(s.error)return s.error;if(!n){let n=await XM(e,t,s.stdin,lN);return l=!0,u=n.blame??null,n}let i=r.argv.length>0?r.argv[0]:null,a=i===null?void 0:t.functions.get(i);if(a){if(l=!0,t.calling.has(i)){let e=C(`feature`,i,`function recursion`,`${i}: a function calling itself is not supported`);return t.unsupported.add(S(e)),e}t.calling.add(i);try{return await SS(t,{loopDepth:0},async()=>({...await wN(r.temps,t,()=>lN(a,t,{text:s.stdin,bytes:s.stdinBytes})),ignored:!1}))}finally{t.calling.delete(i)}}let o=await xN(t,r);return r.argv.length&&(u=Dn(t.registry.chainRole(r.argv),r.argv[0])),o})),f=s.inherited?t.stdinLeft:s.parentLeft,p=s.inherited?t.stdinBytes:s.parentBytes;return K(t.expansionOutput,l?d:mN(d,s,t)),{...t.expansionOutput,inputLeft:f,bytesLeft:p,halt:d.halt,control:d.control,blame:u}}))}function mN(e,t,n){try{return Xv(e,t,n)}catch(e){return Xv(gN(n,e),t,n)}}async function hN(e,t,n,r,i){let a={...i},o=n,s=r,c=s?t.stdinOrigin:null,l=s?t.stdinHandle:null,u=!0,d=n,f=!1,p=t.stdinTerminal,m=t.stdinBytes,h=m,g=e=>({error:e,fds:a,stdin:o,stdinBytes:m,stdinFile:s,stdinPiped:f||t.stdinPiped,stdinTerminal:p,stdinOrigin:s?c:null,stdinHandle:s?l:null,inherited:u,parentLeft:d,parentBytes:h}),_=async e=>{let n=await SS(t,{expansionFds:a},()=>vN({fds:a,stdin:o,stdinBytes:m,stdinFile:s,stdinOrigin:c,stdinHandle:l},t,e));return o=t.stdinLeft,m=t.stdinBytes,u&&(d=o,h=m),n};try{for(let n of e.redirs)if(n.op===`dup`){if(a[n.toFd]===void 0||a[n.toFd]===`closed`)return g(x(`error: ${n.toFd}: Bad file descriptor`));a[n.fd]=a[n.toFd]}else if(n.op===`close`)a[n.fd]=`closed`;else if(n.op===`to`){let e=n.target===void 0?await _(()=>TS(n.word,t)):{value:n.target};if(e.error)return g(x(`error: ${e.error}`));let r=e.value===`/dev/null`?`null`:e.value===`/dev/stdout`?a[1]:e.value===`/dev/stderr`?a[2]:t.writable?t.fs.openWritable(t.cwd,e.value,n.append):null;if(r===null){let r=Ya(n.label,e.value,t.writable);return t.unsupported.add(S(r)),g(x(`error: ${r.message}`))}if(r===`closed`)return g(x(`error: ${e.value}: No such file or directory`));a[n.fd]=r,n.both&&(a[2]=r)}else if(n.op===`text`)o=n.expand?await _(()=>DS(yN(n.body),t)):n.body,s=!1,u=!1,m=null,p=!1;else if(n.op===`herestring`)o=await _(()=>DS(n.word,t))+`
360
- `,s=!1,u=!1,m=null,p=!1;else{let e=await _(()=>TS(n.word,t)),r=e.error?{error:x(`error: ${e.error}`)}:bN(e.value,t,s?c:o);if(r.error)return g(r.error);o=r.content,e.value!==`/dev/stdin`&&(m=r.bytes??null),(e.value!==`/dev/stdin`||s)&&(u=!1),e.value!==`/dev/stdin`&&(s=e.value!==`/dev/null`,c=s?o:null,l=r.handle,f=s,p=!1)}if(s&&l){let e=t.io.bufferReads(()=>t.fs.readIdentity(l.identity));if(e!==l.content){if(u||o!==l.content)throw new T(`feature`,`modified redirected input`,`reading an inherited input file after it changes is not supported`);o=c=e,l={...l,content:e}}}}catch(e){return g(gN(t,e))}return g()}function gN(e,t){P(e,`shell`,t?.path,t?.fsError);let n=S(t);return n&&e.unsupported.add(n),{...x(`error: ${L(t)}`,1),...t?.halt?{halt:!0}:{}}}async function _N(e,t){try{return await t()}catch(t){return gN(e,t)}}function vN(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,SS(t,r,n)}function yN(e){let t=``,n=``;for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(i===`\\`&&(a===`$`||a===`\\`||a==="`")){t+=a,n+=`1`,r++;continue}if(i==="`"){let i=wr(e,r);t+=i.raw,n+=`2`+`1`.repeat(i.raw.length-1),r+=i.raw.length-1;continue}if(i===`$`){let i=vi(e,r,0,!0);if(i?.command!==void 0||i?.parameter!==void 0||i?.arithmetic!==void 0){t+=i.raw,n+=`2`+`1`.repeat(i.raw.length-1),r+=i.raw.length-1;continue}}t+=i,n+=`2`}return{value:t,mask:n}}function bN(e,t,n){if(e===`/dev/null`)return{content:``};if(e===`/dev/stdin`)return{content:n};let{path:r,error:i}=N(t,`shell`,e);if(i)return{error:x(`error: ${e}: ${i}`)};if(t.fs.isFile(r)){let{text:e,bytes:n}=Vn(t.fs,r),i=e??``;return{content:i,bytes:e===void 0?n:void 0,handle:t.writable&&r.startsWith(`/tmp/`)?{path:r,content:i,identity:t.fs.fileIdentity(r)}:null}}return{error:x(`error: ${e}: Is a directory`)}}function xN(e,t){let{argv:n}=t;return n.length===0?{stdout:``,stderr:``,exitCode:e.substitutionExit??0}:wN(t.temps,e,()=>e.invoke(n[0],n.slice(1),e.stdinLeft))}async function SN(e,t){for(let n of e)t.vars.set(n.name,await DS(n.word,t,!0))}async function CN(e,t){if(e.length===0)return null;let n=t.vars,r=new jx(n),i=new Set(e.map(e=>e.name));r.bound=new Set;try{await SS(t,{vars:r},async()=>{for(let n of e){r.expansionTargets=i;let e=await DS(n.word,t,!0);r.expansionTargets=null,r.set(n.name,e)}})}finally{r.expansionTargets=null;for(let e of r.bound)i.has(e)||n.set(e,r.get(e))}return{vars:r,names:i}}async function wN(e,t,n){if(!e)return n();let r=t.vars,i=new jx(r),a=e.names;for(let t of a)i.set(t,e.vars.get(t));t.vars=i;try{return i.bound=new Set,await n()}finally{t.vars=r;for(let[e,t]of i)(!a.has(e)||i.bound?.has(e))&&r.set(e,t);for(let e of i.unsetNames)a.has(e)||r.delete(e)}}function TN(e,t={}){let{fs:n,cwd:r,home:i,mount:a,writable:o,locale:s}=mr(e,t),c=qf(t),l=t.commands===void 0?PM(c):jM(t.commands,c);return AN(kN({fs:n,io:oN(n),mount:a,writable:o,registry:l,createdAt:Date.now(),lock:{turn:Promise.resolve()}},{cwd:r,home:i,user:t.user??`user`,locale:s,...EN()}),`createTerminal`)}var EN=()=>({vars:new jx,functions:new Map,lastExit:0,errexit:!1}),DN=e=>({vars:new jx(e.vars),functions:new Map(e.functions),lastExit:e.lastExit,errexit:e.errexit});function ON(e,t={}){let{cwd:n,home:r,user:i,locale:a,inherit:o}=hr(e,t);return AN(kN(e,{cwd:n,home:r,user:i,locale:a,...o?DN(e):EN()}),`fork`)}function kN({fs:e,io:t,mount:n,writable:r,registry:i,createdAt:a,lock:o},s){let c={fs:e,io:t,mount:n,writable:r,registry:i,createdAt:a,lock:o,...s,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:qe(),notes:new Set};return c.dispatch=(e,t,n,{devNull:r=!1}={})=>SS(c,{stdinLeft:c.stdinLeft,stdinBytes:c.stdinBytes,stdinFile:!1,stdinPiped:!1,stdinTerminal:c.stdinTerminal&&!r,stdinOrigin:null,stdinHandle:null},()=>xS(c,()=>jN(e,t,n,c,!0))),c.flushOutput=e=>sN(e,c),c.hasCommand=e=>i.has(e)&&!i.shellOnly(e),c.invoke=(e,t,n)=>jN(e,t,n,c),c.substitute=(e,t)=>WM(e,c,lN,t),c.runLine=e=>PN(e,c),c}function AN(e,t){if(!e.fs.isDir(e.cwd))throw Error(`${t}: cwd is not a directory: ${e.cwd}`);return{run:t=>NN(e,t),cwd:()=>e.cwd,complete:t=>IM(t,e,e.registry),fork:t=>ON(e,t)}}async function jN(e,t,n,r,i=!1){let a=r.registry,o=a.resolveCommand(e),s=()=>{if((i||e!==o)&&a.shellOnly(o))return C(`command`,e,e,`${e}: shell builtin cannot be invoked as an external command`,127);let s=a.commands[o];return s?s(n,t,r):FM(e,a)},c=t=>sN(MN(r,ey(e,t,r),o),r);try{return await r.io.run(o,async()=>c(await s()))}catch(t){P(r,e,t?.path,t?.fsError);let n=`${e}: ${L(t)}`,i=S(t);return i&&r.unsupported.add({...i,command:i.command??e,message:n},i.command??o),c(x(n))}}function MN(e,t,n){let r=S(t);return r&&e.unsupported.add(r,n),t}function NN(e,t){let{lock:n}=e,r=n.turn.then(()=>PN(t,e));return n.turn=r.then(()=>null,()=>null),r}function PN(e,t){let n=qe();return SS(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},i={text:``};try{for(let n of Ta(e,t.writable,t.registry.has)){let e=await lN(n,t,i);if(r.stdout+=e.stdout,r.stderr+=e.stderr,r.exitCode=e.exitCode,e.halt||e.control)break}}catch(e){let i=S(e);i&&n.add(i),t.lastExit=e.exitCode??(i?1:2),r.stderr+=`error: ${e.message}
361
- `,r.exitCode=t.lastExit}return FN(r,t,n)})}var FN=(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,...En(t.discarded,e.stderr,t.notes)])}),IN={unified:[[/^--- /u,`bold`],[/^\+\+\+ /u,`bold`],[o,`cyan`],[/^\+/u,`green`],[/^-/u,`red`],[/^\\ /u,`gray`]],context:[[s,`cyan`],[/^\*{3} \d/u,`cyan`],[/^--- \d/u,`cyan`],[/^\*{3} /u,`bold`],[/^--- /u,`bold`],[/^! /u,`yellow`],[/^\+ /u,`green`],[/^- /u,`red`]],normal:[[c,`cyan`],[/^< /u,`red`],[/^> /u,`green`],[/^---$/u,`gray`]]};function LN(e){return e.some(e=>s.test(e))?`context`:e.some(e=>o.test(e))?`unified`:e.some(e=>c.test(e))?`normal`:null}function RN(e){let t=e.split(`
362
- `),n=IN[LN(t)];return n===void 0?null:t.map(e=>n.find(([t])=>t.test(e))?.[1]??null)}var zN={bold:`head`,cyan:`hunk`,green:`add`,red:`del`,yellow:`chg`,gray:`meta`};function BN(e){let t=RN(e);return t===null?null:e.split(`
363
- `).map((e,n)=>({text:e,kind:t[n]===null?``:zN[t[n]]??``}))}function VN({stdout:e,stderr:t,unsupported:n}){return n.filter(n=>!t.includes(n.message)&&!e.includes(n.message)).map(e=>e.message)}var HN=`: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}}:host-context(body.theme-w95) *{overscroll-behavior:none}
364
- `,UN=`/sources`,WN={mount:UN,home:`/`,writable:`/tmp/`};function GN(e){let t=[`ls`,`find /`,`grep -r ${qN(e)} .`];if(!e||e.size===0)return t;let n=null;for(let[t,r]of e){if(typeof r!=`string`)continue;let e=JN(t);(n===null||e.length<n.length)&&(n=e)}return n&&t.push(`cat ${n} | head -n 20`),t}var KN=[`TODO`,`FIXME`,`XXX`,`HACK`,`NOTE`,`BUG`,`export`,`import`,`require`,`//`];function qN(e){if(!e||e.size===0)return KN[0];for(let t of KN)for(let n of e.values())if(typeof n==`string`&&n.includes(t))return t;return KN[0]}function JN(e){return e.startsWith(`./`)?e.slice(2):e.startsWith(`/`)?e.slice(1):e}var YN=class e extends ne{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=ee(HN);#e=null;#t=null;#n=[];#r=-1;#i=``;#a=null;#o=null;static#s=200;#c=new Map;#l=0;static#u=3;static#d=400;constructor(){super(),this.sources=null,this._lines=[],this._input=``,this._cwd=UN,this._ghost=``,this._notes=[],this._running=!1}willUpdate(e){e.has(`sources`)&&this.sources!==this.#t&&(this.#e=this.sources?TN(this.sources,WN):null,this._cwd=this.#e?this.#e.cwd():UN,this._lines=[{kind:`banner`,commands:GN(this.sources)}],this.#n=[],this.#r=-1,this.#i=``,this.#a=null,this._input=``,this.#T(),this.#t=this.sources),e.has(`_input`)&&(this.#g(),this.#_())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#f())}disconnectedCallback(){super.disconnectedCallback(),this.#g(),this.#T()}firstUpdated(){this.focusInput()}updated(e){(e.has(`_lines`)||e.has(`sources`))&&this.#f()}focusInput(){let e=this.renderRoot.querySelector(`.input`);e&&e.focus()}#f(){let e=this.renderRoot.querySelector(`.output`);e&&(e.scrollTop=e.scrollHeight)}#p=async e=>{if(e.preventDefault(),!this.#e||this._running)return;let t=this._input,n=t.trim();if(n===`clear`){this._lines=[],this.#T(),this._input=``,n.length>0&&(this.#n=[...this.#n,t]),this.#r=-1;return}let r=this._cwd;n.length>0&&(this.#n=[...this.#n,t]),this.#r=-1,this._input=``;let i;this._running=!0;try{i=await this.#e.run(t)}catch(e){this._lines=[...this._lines,{kind:`prompt`,cwd:r,text:t},{kind:`stderr`,text:`${e?.message??e}
365
- `}];return}finally{this._running=!1}this._cwd=i.cwd;let a=[...this._lines,{kind:`prompt`,cwd:r,text:t}];i.stdout&&a.push({kind:`stdout`,text:i.stdout,diff:BN(i.stdout)}),i.stderr&&a.push({kind:`stderr`,text:i.stderr}),this._lines=a,this.#y(i)};#m=e=>{if(e.key===`Tab`&&!e.shiftKey){e.preventDefault(),this.#h();return}this.#a=null,e.key===`ArrowUp`?(e.preventDefault(),this.#E()):e.key===`ArrowDown`&&(e.preventDefault(),this.#D()),this.#g(),this.#_()};#h(){if(!this.#e)return;let e=this.#a;if(e&&e.items[e.index]===this._input){e.index=(e.index+1)%e.items.length,this._input=e.items[e.index];return}let t=this.#e.complete(this._input);if(t.length===0){this.#a=null;return}this._input=t[0],this.#a=t.length>1?{items:t,index:0}:null}#g(){this._ghost=``,this.#o!==null&&(clearTimeout(this.#o),this.#o=null)}#_(){this.#o=setTimeout(()=>{this.#o=null,this.#v()},e.#s)}#v(){if(!this.#e||this.#a)return;let e=this._input,t=e.slice(-1),n=e===``||t===` `||t===`|`,r=/[\w./]/u.test(t);if(!n&&!r)return;let i=this.#e.complete(e);if(i.length===0)return;let a=i[0];!a.startsWith(e)||a===e||r&&i.includes(e)||(this._ghost=a.slice(e.length))}#y(e){let t=e.notes.map(e=>({text:e,kind:`note`}));for(let n of VN(e))t.push({text:`silenced: ${n}`,kind:`gap`});this.#b(t)}#b(t){if(t.length===0)return;let n=[...this._notes];for(let{text:r,kind:i}of t){let t=n.findIndex(e=>e.text===r);t!==-1&&this.#S(n,t),n.push({id:++this.#l,text:r,kind:i,dwell:e.#x(r)})}for(;n.length>e.#u;)this.#S(n,0);for(let e of n)this.#c.has(e.id)||this.#c.set(e.id,setTimeout(()=>this.#w(e.id),e.dwell));this._notes=n}static#x(e){return Math.min(1e4,3200+e.length*55)}#S(e,t){let[n]=e.splice(t,1);this.#C(n.id)}#C(e){let t=this.#c.get(e);t!==void 0&&(clearTimeout(t),this.#c.delete(e))}#w(e){this.#c.delete(e),this._notes=this._notes.filter(t=>t.id!==e)}#T(){for(let e of this.#c.values())clearTimeout(e);this.#c.clear(),this._notes=[]}#E(){this.#n.length!==0&&(this.#r<0?(this.#i=this._input,this.#r=this.#n.length-1):this.#r=Math.max(0,this.#r-1),this._input=this.#n[this.#r])}#D(){if(this.#r<0)return;let e=this.#r+1;e>=this.#n.length?(this.#r=-1,this._input=this.#i,this.#i=``):(this.#r=e,this._input=this.#n[e])}#O=e=>{this._input=e.target.value};#k=e=>{this._input=e,this.#r=-1,this.#i=``,this.focusInput()};#A=()=>{let e=this.renderRoot.getSelection?.()??document.getSelection();e&&!e.isCollapsed||this.focusInput()};render(){return v`<div class="notes" role="log" aria-atomic="false">${_(this._notes,e=>e.id,t=>v`<div class="note ${t.kind===`gap`?`note-gap`:``}" style="${g({"--dwell-out":`${t.dwell-e.#d}ms`})}">${t.text}</div>`)}</div><div class="output" @click="${this.#A}">${this._lines.map(e=>this.#j(e))}</div><form class="form" @submit="${this.#p}" aria-busy="${this._running?`true`:`false`}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?v`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:te} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#O}" @keydown="${this.#m}"></div></form>`}#j(e){return e.kind===`banner`?v`<div class="banner">Virtual shell over the bundle source tree. Try ${e.commands.map((e,t)=>v`${t>0?`, `:``}\`<span class="cmd" @click="${()=>this.#k(e)}">${e}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:e.kind===`prompt`?v`<div class="line"><span class="cwd">${e.cwd}</span>${` `}<span class="sigil">$</span>${` `}${e.text}</div>`:e.kind===`stdout`?this.#M(e):e.kind===`stderr`?v`<pre class="stderr">${e.text}</pre>`:te}#M(e){if(!e.diff)return v`<pre class="stdout">${e.text}</pre>`;let t=e.diff.flatMap((e,t)=>{let n=e.kind?v`<span class="diff-${e.kind}">${e.text}</span>`:e.text;return t===0?[n]:[`
366
- `,n]});return v`<pre class="stdout">${t}</pre>`}};customElements.define(`bundle-terminal`,YN);function XN(e,t){let n=document.createElement(`bundle-terminal`);return n.dataset.integrity=t??``,n.sources=e,n}export{XN as createTerminalElement};
357
+ '`:`\\`+e)}function KM(e,t,n=!1){let r=e.value,i=r.startsWith(`~`)&&(e.mask?.[0]??`0`)===`0`&&!e.empty?.some(e=>e<=1)&&(r.length===1||(e.mask?.[1]??`0`)===`0`);if(i&&r===`~`)return t.fs.isDir(k(t.cwd,jS(t),t.fs).path)?[`~/`]:[];if(i&&!r.startsWith(`~/`))return[];let a=r.lastIndexOf(`/`),o=r.slice(0,a+1),s=r.slice(a+1),c=i?jS(t)+o.slice(1):o||`.`,l=k(t.cwd,c,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:u,files:d,links:f}=t.fs.listDir(l),p=u.map(e=>e+`/`);for(let e of f)t.fs.isDir(k(l,e,t.fs).path)?p.push(e+`/`):n||p.push(e);return n||p.push(...d),p.filter(e=>e.startsWith(s)&&(s.startsWith(`.`)||!e.startsWith(`.`))).filter(e=>o!==``||s===``||!e.startsWith(`-`)).map(e=>o===``&&e.startsWith(`-`)?`./`+e:o+e)}async function qM(e,t,n,r=!1){let i=(t.substitutionDepth??0)+1;if(i>Tr)throw new T(`feature`,`command substitution nesting limit`,`command substitution nesting beyond ${Tr} levels is not supported`);let a=t.expansionFds[2],o=await TS(t,{substitutionDepth:i,outputFds:{1:`out`,2:typeof a==`object`||a===`closed`?a:`err`},errexitOff:!0,closed:{out:!1,err:a===`closed`}},()=>wS(t,()=>{let i;try{i=Ea(e,t.writable,t.registry.has)}catch(e){let n=S(e);if(!n){if(r)return x(`error: command substitution: ${e.message}`,2);throw new T(`feature`,`command substitution syntax`,`runtime command substitution syntax errors are not supported: ${e.message}`)}return t.unsupported.add(n),x(`error: ${e.message}`,1)}let a=i.length===1&&!i[0].negate&&i[0].stages.length===1?i[0].stages[0]:null;return a&&!a.group&&!a.loop&&!a.conditional&&!a.test&&a.words.length===0&&a.assigns.length===0&&a.redirs.length===1&&a.redirs[0].op===`read`&&a.words.push({value:`cat`,mask:null}),n(i,t,{text:t.stdinLeft,bytes:t.stdinBytes})}));t.lastExit=t.substitutionExit=o.exitCode;let s=o.stdout,c=o.stderr;if(s.includes(`\0`)){let e=s.length;s=s.replaceAll(`\0`,``);let n=e-s.length;t.notes.add(`command substitution: discarded ${n} NUL ${n===1?`byte`:`bytes`}.`),c+=`warning: command substitution: ignored null byte in input
358
+ `}Qv(t,c);let l=s.length;for(;l>0&&s[l-1]===`
359
+ `;)l--;return s.slice(0,l)}async function JM(e,t){return{stdout:``,stderr:``,exitCode:+!await XM(e,t)}}var YM=async(e,t)=>(await PS(e,t)).value;async function XM(e,t){let{kind:n}=e;if(n===`not`)return!await XM(e.expression,t);if(n===`and`)return await XM(e.left,t)&&await XM(e.right,t);if(n===`or`)return await XM(e.left,t)||await XM(e.right,t);let{op:r}=e;if(n===`unary`){let n=await YM(e.word,t);if(r===`-n`)return n!==``;if(r===`-z`)return n===``;if([`-a`,`-e`,`-f`,`-d`].includes(r))return dD(r,n,t);if(r===`-v`)return ZM(n,t);QM(r)}[`<`,`>`,`-nt`,`-ot`,`-ef`].includes(r)&&QM(r);let i=await YM(e.left,t);if(Object.hasOwn(rD,r)){let n=await YM(e.right,t);return rD[r](uS(i,t),uS(n,t))}let a=await PS(e.right,t);o_(a)&&QM(`extglob`);let o=Zg(l_(a),{bash:!0}).test(i);return r===`!=`?!o:o}function ZM(e,t){return e.includes(`[`)&&QM(`-v array subscript`),/^[ \t\n\r\f\v]*[+-]?0+[ \t]*$/u.test(e)&&QM(`-v positional parameter`),/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?Lx(e,t).set:!1}function QM(e){throw new T(`feature`,`[[ ${e}`,`${e} in [[ is not supported`)}function $M(e,t,n,r){return e.define?(t.functions.set(e.define.name,e.define.body),G()):e.test?JM(e.test,t):e.group?oN(e,t,n,r):e.loop?e.loop.words?iN(e.loop,t,r):nN(e.loop,t,r):aN(e.conditional,t,n,r)}var eN=1e4,tN={kind:`feature`,command:null,detail:`loop limit`,message:`a loop running more than ${eN} times is not supported`};async function nN(e,t,n){let r=G(),i={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let a=0;;a++){if(a===eN){t.unsupported.add(tN),K(r,x(`error: ${tN.message}`,1));break}let o=r.ignored,s=r.exitCode,c=await n(e.condition,t,i,!0);if(K(r,c),r.exitCode=s,r.ignored=o,c.halt||c.control)return{...r,halt:c.halt,control:c.control,blame:c.blame};if(c.exitCode===0==!!e.until)break;let l=await n(e.body,t,i);if(K(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 rN={value:`for`,mask:null};async function iN(e,t,n){let r=await ES([rN,...e.words],t),i=G(),a={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let o of r.argv.slice(1)){t.vars.set(e.name,o);let r=await n(e.body,t,a);if(K(i,r),i.blame=r.blame,r.halt)return{...i,halt:!0};if(r.control?.levels>1)return{...i,control:{...r.control,levels:r.control.levels-1}};if(r.control?.type===`break`)break}}finally{t.loopDepth--}return i}async function aN(e,t,n,r){let i=G(),a={text:n,bytes:t.stdinBytes};for(let n of e.branches){let e=await r(n.condition,t,a,!0);if(K(i,e),e.halt||e.control)return{...i,halt:e.halt,control:e.control,blame:e.blame};if(e.exitCode!==0)continue;let o=await r(n.body,t,a);return K(i,o),{...i,halt:o.halt,control:o.control,blame:o.blame}}if(!e.otherwise)return i.exitCode=0,i.ignored=!1,i;let o=await r(e.otherwise,t,a);return K(i,o),{...i,halt:o.halt,control:o.control,blame:o.blame}}async function oN(e,t,n,r){let i={text:n,bytes:t.stdinBytes};return e.isolate?{...await wS(t,()=>r(e.group,t,i)),halt:!1,control:void 0,ignored:!1}:r(e.group,t,i)}var sN=new Set([`sort`,`cat`]),cN=new Set([`wc`,`tac`]);function lN(e){let t=null,n=null,r=e=>{t&&!t.bufferReads&&t.reads.push(e)},i=e=>{if(e!==void 0)for(let r=t;r;r=r.parent){if(!r.reads.includes(e)||r===t&&n?.scope===r&&(n.unsupported||r.buffered||n.fd===1&&(sN.has(r.name)||cN.has(r.name)&&!r.reads.slice(1).includes(e))))continue;if(r.failure)throw r.failure;let i=r===t&&n?.fd===2,a=i?`input modified by diagnostics`:`streaming self-output`,o=i?`reading input while diagnostics write to the same file is not supported`:`writing to an actively read input file is not supported`;throw r.failure=w(new T(`feature`,a,o),`feature`,r.name,a,o),r.failure}};return e.observeIo?.({read:r,write:i}),{read:r,bufferOutput(){t&&(t.buffered=!0)},bufferReads(e){if(!t)return e();let n=t,r=n.bufferReads;n.bufferReads=!0;try{return e()}finally{n.bufferReads=r}},setReads(e){t&&(t.reads=e)},async run(e,n){let r=t;t={name:e,reads:[],parent:r};try{return await n()}finally{t=r}},output(e,r,a){let o=n;n={scope:t,fd:null,unsupported:!!S(e)};try{for(let t of Xv(e))t.text!==``&&(n.fd=t.fd,i(r.fds[t.fd]?.identity));return a((e,t)=>{n.fd=e.fd,Yv(e,t)})}finally{n=o}}}}function uN(e,t){return $v(e,{fds:{1:t.outputFds[1]?.path?t.outputFds[1]:`out`,2:t.outputFds[2]?.path?t.outputFds[2]:`err`},deferred:{1:dN(t.outputFds[1]),2:dN(t.outputFds[2])}},t)}var dN=e=>e!==`out`&&e!==`err`&&!e?.path;async function fN(e,t,n,r=!1){if(e.some(e=>e.background))throw new T(`feature`,`&`,"background processes (`&`) are not supported");let i=G(),a=null,o=null;for(let[s,c]of e.entries()){if(c.warnings&&K(i,$v({...G(c.warnings),exitCode:i.exitCode,ignored:i.ignored},{fds:t.outputFds},t)),c.gate===`and`&&i.exitCode!==0){(o??=kn()).skip(r?null:a,i.exitCode);continue}if(c.gate===`or`&&i.exitCode===0)continue;o?.flush(t.notes);let l=r||c.negate||pN(e,s),u=await(l?TS(t,{errexitOff:!0},()=>mN(c.stages,t,n)):mN(c.stages,t,n));if(K(i,u),c.negate&&!u.halt&&(i.exitCode=+(u.exitCode===0)),l&&(i.ignored=!0),a=c.negate?null:u.blame,t.lastExit=i.exitCode,u.halt||u.control){Object.assign(i,{halt:u.halt,control:u.control});break}if(i.exitCode!==0&&!i.ignored&&t.errexit&&!t.errexitOff){i.halt=!0;break}}return o?.flush(t.notes),t.stdinLeft=n.text,t.stdinBytes=n.bytes??null,Object.assign(i,{blame:a})}var pN=(e,t)=>[`and`,`or`].includes(e[t+1]?.gate);async function mN(e,t,n){let r=G(),i=n.text,a=n.bytes??null;for(let o=0;o<e.length;o++){let s=e[o],c=o===0,l=o<e.length-1?hN():null,u={...t.outputFds};l&&(u[1]=l);let d=a,f=i,p=()=>gN(s,t,{stdin:f,stdinBytes:d,stdinFile:c&&t.stdinFile,fds:u,stdinPiped:!c||t.stdinPiped,stdinTerminal:c&&t.stdinTerminal}),m=e.length>1?{...await wS(t,p),ignored:!1}:await p();c&&(n.text=m.inputLeft,n.bytes=m.bytesLeft??null),K(r,m);let h=l?.carried()??{text:``};a=h.bytes??null,i=h.text??et(h.bytes)??``,r.blame=m.blame,e.length===1&&(r.halt=m.halt,r.control=m.control)}return r}function hN(){let e=``,t=null;return{write(n){t===null?e+=n:n!==``&&t.push(E(n))},writeBytes(n){t===null&&(t=e===``?[]:[E(e)],e=``),t.push(n)},carried:()=>t===null?{text:e}:{bytes:lt([...t,new Uint8Array])}}}function gN(e,t,{stdin:n,stdinBytes:r,stdinFile:i,fds:a,stdinPiped:o,stdinTerminal:s}){let c={fds:a,stdin:n,stdinBytes:r,stdinFile:i,stdinPiped:o,stdinTerminal:s,stdinOrigin:i?t.stdinOrigin:null,stdinHandle:i?t.stdinHandle:null};return TS(t,{substitutionExit:null,expansionOutput:G(),expansionFds:a},()=>xN(c,t,async()=>{let n=!e.group&&!e.loop&&!e.conditional&&!e.test&&!e.define,r,o;try{n&&(r=await ES(e.words,t),r.argv.length===0?await TN(e.assigns,t):r.temps=await EN(e.assigns,t))}catch(e){o=yN(t,e)}if(o)return K(t.expansionOutput,_N(o,c,t)),{...t.expansionOutput,inputLeft:t.stdinLeft,bytesLeft:t.stdinBytes,halt:o.halt};let s=await vN(e,t,t.stdinLeft,i,a);t.expansionFds=s.fds;let l=!1,u=null,d=await xN(s,t,()=>bN(t,async()=>{if(s.error)return s.error;if(!n){let n=await $M(e,t,s.stdin,fN);return l=!0,u=n.blame??null,n}let i=r.argv.length>0?r.argv[0]:null,a=i===null?void 0:t.functions.get(i);if(a){if(l=!0,t.calling.has(i)){let e=C(`feature`,i,`function recursion`,`${i}: a function calling itself is not supported`);return t.unsupported.add(S(e)),e}t.calling.add(i);try{return await TS(t,{loopDepth:0},async()=>({...await DN(r.temps,t,()=>fN(a,t,{text:s.stdin,bytes:s.stdinBytes})),ignored:!1}))}finally{t.calling.delete(i)}}let o=await wN(t,r);return r.argv.length&&(u=On(t.registry.chainRole(r.argv),r.argv[0])),o})),f=s.inherited?t.stdinLeft:s.parentLeft,p=s.inherited?t.stdinBytes:s.parentBytes;return K(t.expansionOutput,l?d:_N(d,s,t)),{...t.expansionOutput,inputLeft:f,bytesLeft:p,halt:d.halt,control:d.control,blame:u}}))}function _N(e,t,n){try{return $v(e,t,n)}catch(e){return $v(yN(n,e),t,n)}}async function vN(e,t,n,r,i){let a={...i},o=n,s=r,c=s?t.stdinOrigin:null,l=s?t.stdinHandle:null,u=!0,d=n,f=!1,p=t.stdinTerminal,m=t.stdinBytes,h=m,g=e=>({error:e,fds:a,stdin:o,stdinBytes:m,stdinFile:s,stdinPiped:f||t.stdinPiped,stdinTerminal:p,stdinOrigin:s?c:null,stdinHandle:s?l:null,inherited:u,parentLeft:d,parentBytes:h}),_=async e=>{let n=await TS(t,{expansionFds:a},()=>xN({fds:a,stdin:o,stdinBytes:m,stdinFile:s,stdinOrigin:c,stdinHandle:l},t,e));return o=t.stdinLeft,m=t.stdinBytes,u&&(d=o,h=m),n};try{for(let n of e.redirs)if(n.op===`dup`){if(a[n.toFd]===void 0||a[n.toFd]===`closed`)return g(x(`error: ${n.toFd}: Bad file descriptor`));a[n.fd]=a[n.toFd]}else if(n.op===`close`)a[n.fd]=`closed`;else if(n.op===`to`){let e=n.target===void 0?await _(()=>OS(n.word,t)):{value:n.target};if(e.error)return g(x(`error: ${e.error}`));let r=e.value===`/dev/null`?`null`:e.value===`/dev/stdout`?a[1]:e.value===`/dev/stderr`?a[2]:t.writable?t.fs.openWritable(t.cwd,e.value,n.append):null;if(r===null){let r=Za(n.label,e.value,t.writable);return t.unsupported.add(S(r)),g(x(`error: ${r.message}`))}if(r===`closed`)return g(x(`error: ${e.value}: No such file or directory`));a[n.fd]=r,n.both&&(a[2]=r)}else if(n.op===`text`)o=n.expand?await _(()=>AS(SN(n.body),t)):n.body,s=!1,u=!1,m=null,p=!1;else if(n.op===`herestring`)o=await _(()=>AS(n.word,t))+`
360
+ `,s=!1,u=!1,m=null,p=!1;else{let e=await _(()=>OS(n.word,t)),r=e.error?{error:x(`error: ${e.error}`)}:CN(e.value,t,s?c:o);if(r.error)return g(r.error);o=r.content,e.value!==`/dev/stdin`&&(m=r.bytes??null),(e.value!==`/dev/stdin`||s)&&(u=!1),e.value!==`/dev/stdin`&&(s=e.value!==`/dev/null`,c=s?o:null,l=r.handle,f=s,p=!1)}if(s&&l){let e=t.io.bufferReads(()=>t.fs.readIdentity(l.identity));if(e!==l.content){if(u||o!==l.content)throw new T(`feature`,`modified redirected input`,`reading an inherited input file after it changes is not supported`);o=c=e,l={...l,content:e}}}}catch(e){return g(yN(t,e))}return g()}function yN(e,t){P(e,`shell`,t?.path,t?.fsError);let n=S(t);return n&&e.unsupported.add(n),{...x(`error: ${I(t)}`,1),...t?.halt?{halt:!0}:{}}}async function bN(e,t){try{return await t()}catch(t){return yN(e,t)}}function xN(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,TS(t,r,n)}function SN(e){let t=``,n=``;for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(i===`\\`&&(a===`$`||a===`\\`||a==="`")){t+=a,n+=`1`,r++;continue}if(i==="`"){let i=Er(e,r);t+=i.raw,n+=`2`+`1`.repeat(i.raw.length-1),r+=i.raw.length-1;continue}if(i===`$`){let i=bi(e,r,0,!0);if(i?.command!==void 0||i?.parameter!==void 0||i?.arithmetic!==void 0){t+=i.raw,n+=`2`+`1`.repeat(i.raw.length-1),r+=i.raw.length-1;continue}}t+=i,n+=`2`}return{value:t,mask:n}}function CN(e,t,n){if(e===`/dev/null`)return{content:``};if(e===`/dev/stdin`)return{content:n};let{path:r,error:i}=N(t,`shell`,e);if(i)return{error:x(`error: ${e}: ${i}`)};if(t.fs.isFile(r)){let{text:e,bytes:n}=Hn(t.fs,r),i=e??``;return{content:i,bytes:e===void 0?n:void 0,handle:t.writable&&r.startsWith(`/tmp/`)?{path:r,content:i,identity:t.fs.fileIdentity(r)}:null}}return{error:x(`error: ${e}: Is a directory`)}}function wN(e,t){let{argv:n}=t;return n.length===0?{stdout:``,stderr:``,exitCode:e.substitutionExit??0}:DN(t.temps,e,()=>e.invoke(n[0],n.slice(1),e.stdinLeft))}async function TN(e,t){for(let n of e)t.vars.set(n.name,await AS(n.word,t,!0))}async function EN(e,t){if(e.length===0)return null;let n=t.vars,r=new Px(n),i=new Set(e.map(e=>e.name));r.bound=new Set;try{await TS(t,{vars:r},async()=>{for(let n of e){r.expansionTargets=i;let e=await AS(n.word,t,!0);r.expansionTargets=null,r.set(n.name,e)}})}finally{r.expansionTargets=null;for(let e of r.bound)i.has(e)||n.set(e,r.get(e))}return{vars:r,names:i}}async function DN(e,t,n){if(!e)return n();let r=t.vars,i=new Px(r),a=e.names;for(let t of a)i.set(t,e.vars.get(t));t.vars=i;try{return i.bound=new Set,await n()}finally{t.vars=r;for(let[e,t]of i)(!a.has(e)||i.bound?.has(e))&&r.set(e,t);for(let e of i.unsetNames)a.has(e)||r.delete(e)}}function ON(e,t={}){let{fs:n,cwd:r,home:i,mount:a,writable:o,locale:s}=gr(e,t),c=Xf(t),l=t.commands===void 0?LM(c):PM(t.commands,c);return NN(MN({fs:n,io:lN(n),mount:a,writable:o,registry:l,createdAt:Date.now(),lock:{turn:Promise.resolve()}},{cwd:r,home:i,user:t.user??`user`,locale:s,...kN()}),`createTerminal`)}var kN=()=>({vars:new Px,functions:new Map,lastExit:0,errexit:!1}),AN=e=>({vars:new Px(e.vars),functions:new Map(e.functions),lastExit:e.lastExit,errexit:e.errexit});function jN(e,t={}){let{cwd:n,home:r,user:i,locale:a,inherit:o}=_r(e,t);return NN(MN(e,{cwd:n,home:r,user:i,locale:a,...o?AN(e):kN()}),`fork`)}function MN({fs:e,io:t,mount:n,writable:r,registry:i,createdAt:a,lock:o},s){let c={fs:e,io:t,mount:n,writable:r,registry:i,createdAt:a,lock:o,...s,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:Je(),notes:new Set};return c.dispatch=(e,t,n,{devNull:r=!1}={})=>TS(c,{stdinLeft:c.stdinLeft,stdinBytes:c.stdinBytes,stdinFile:!1,stdinPiped:!1,stdinTerminal:c.stdinTerminal&&!r,stdinOrigin:null,stdinHandle:null},()=>wS(c,()=>PN(e,t,n,c,!0))),c.flushOutput=e=>uN(e,c),c.hasCommand=e=>i.has(e)&&!i.shellOnly(e),c.invoke=(e,t,n)=>PN(e,t,n,c),c.substitute=(e,t)=>qM(e,c,fN,t),c.runLine=e=>LN(e,c),c}function NN(e,t){if(!e.fs.isDir(e.cwd))throw Error(`${t}: cwd is not a directory: ${e.cwd}`);return{run:t=>IN(e,t),cwd:()=>e.cwd,complete:t=>zM(t,e,e.registry),fork:t=>jN(e,t)}}async function PN(e,t,n,r,i=!1){let a=r.registry,o=a.resolveCommand(e),s=()=>{if((i||e!==o)&&a.shellOnly(o))return C(`command`,e,e,`${e}: shell builtin cannot be invoked as an external command`,127);let s=a.commands[o];return s?s(n,t,r):RM(e,a)},c=t=>uN(FN(r,ry(e,t,r),o),r);try{return await r.io.run(o,async()=>c(await s()))}catch(t){P(r,e,t?.path,t?.fsError);let n=`${e}: ${I(t)}`,i=S(t);return i&&r.unsupported.add({...i,command:i.command??e,message:n},i.command??o),c(x(n))}}function FN(e,t,n){let r=S(t);return r&&e.unsupported.add(r,n),t}function IN(e,t){let{lock:n}=e,r=n.turn.then(()=>LN(t,e));return n.turn=r.then(()=>null,()=>null),r}function LN(e,t){let n=Je();return TS(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},i={text:``};try{for(let n of Da(e,t.writable,t.registry.has)){let e=await fN(n,t,i);if(r.stdout+=e.stdout,r.stderr+=e.stderr,r.exitCode=e.exitCode,e.halt||e.control)break}}catch(e){let i=S(e);i&&n.add(i),t.lastExit=e.exitCode??(i?1:2),r.stderr+=`error: ${e.message}
361
+ `,r.exitCode=t.lastExit}return RN(r,t,n)})}var RN=(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,...Dn(t.discarded,e.stderr,t.notes)])}),zN={unified:[[/^--- /u,`bold`],[/^\+\+\+ /u,`bold`],[o,`cyan`],[/^\+/u,`green`],[/^-/u,`red`],[/^\\ /u,`gray`]],context:[[s,`cyan`],[/^\*{3} \d/u,`cyan`],[/^--- \d/u,`cyan`],[/^\*{3} /u,`bold`],[/^--- /u,`bold`],[/^! /u,`yellow`],[/^\+ /u,`green`],[/^- /u,`red`]],normal:[[c,`cyan`],[/^< /u,`red`],[/^> /u,`green`],[/^---$/u,`gray`]]};function BN(e){return e.some(e=>s.test(e))?`context`:e.some(e=>o.test(e))?`unified`:e.some(e=>c.test(e))?`normal`:null}function VN(e){let t=e.split(`
362
+ `),n=zN[BN(t)];return n===void 0?null:t.map(e=>n.find(([t])=>t.test(e))?.[1]??null)}var HN={bold:`head`,cyan:`hunk`,green:`add`,red:`del`,yellow:`chg`,gray:`meta`};function UN(e){let t=VN(e);return t===null?null:e.split(`
363
+ `).map((e,n)=>({text:e,kind:t[n]===null?``:HN[t[n]]??``}))}function WN({stdout:e,stderr:t,unsupported:n}){return n.filter(n=>!t.includes(n.message)&&!e.includes(n.message)).map(e=>e.message)}var GN=`: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}}:host-context(body.theme-w95) *{overscroll-behavior:none}
364
+ `,KN=`/sources`,qN={mount:KN,home:`/`,writable:`/tmp/`};function JN(e){let t=[`ls`,`find /`,`grep -r ${XN(e)} .`];if(!e||e.size===0)return t;let n=null;for(let[t,r]of e){if(typeof r!=`string`)continue;let e=ZN(t);(n===null||e.length<n.length)&&(n=e)}return n&&t.push(`cat ${n} | head -n 20`),t}var YN=[`TODO`,`FIXME`,`XXX`,`HACK`,`NOTE`,`BUG`,`export`,`import`,`require`,`//`];function XN(e){if(!e||e.size===0)return YN[0];for(let t of YN)for(let n of e.values())if(typeof n==`string`&&n.includes(t))return t;return YN[0]}function ZN(e){return e.startsWith(`./`)?e.slice(2):e.startsWith(`/`)?e.slice(1):e}var QN=class e extends ne{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=ee(GN);#e=null;#t=null;#n=[];#r=-1;#i=``;#a=null;#o=null;static#s=200;#c=new Map;#l=0;static#u=3;static#d=400;constructor(){super(),this.sources=null,this._lines=[],this._input=``,this._cwd=KN,this._ghost=``,this._notes=[],this._running=!1}willUpdate(e){e.has(`sources`)&&this.sources!==this.#t&&(this.#e=this.sources?ON(this.sources,qN):null,this._cwd=this.#e?this.#e.cwd():KN,this._lines=[{kind:`banner`,commands:JN(this.sources)}],this.#n=[],this.#r=-1,this.#i=``,this.#a=null,this._input=``,this.#T(),this.#t=this.sources),e.has(`_input`)&&(this.#g(),this.#_())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#f())}disconnectedCallback(){super.disconnectedCallback(),this.#g(),this.#T()}firstUpdated(){this.focusInput()}updated(e){(e.has(`_lines`)||e.has(`sources`))&&this.#f()}focusInput(){let e=this.renderRoot.querySelector(`.input`);e&&e.focus()}#f(){let e=this.renderRoot.querySelector(`.output`);e&&(e.scrollTop=e.scrollHeight)}#p=async e=>{if(e.preventDefault(),!this.#e||this._running)return;let t=this._input,n=t.trim();if(n===`clear`){this._lines=[],this.#T(),this._input=``,n.length>0&&(this.#n=[...this.#n,t]),this.#r=-1;return}let r=this._cwd;n.length>0&&(this.#n=[...this.#n,t]),this.#r=-1,this._input=``;let i;this._running=!0;try{i=await this.#e.run(t)}catch(e){this._lines=[...this._lines,{kind:`prompt`,cwd:r,text:t},{kind:`stderr`,text:`${e?.message??e}
365
+ `}];return}finally{this._running=!1}this._cwd=i.cwd;let a=[...this._lines,{kind:`prompt`,cwd:r,text:t}];i.stdout&&a.push({kind:`stdout`,text:i.stdout,diff:UN(i.stdout)}),i.stderr&&a.push({kind:`stderr`,text:i.stderr}),this._lines=a,this.#y(i)};#m=e=>{if(e.key===`Tab`&&!e.shiftKey){e.preventDefault(),this.#h();return}this.#a=null,e.key===`ArrowUp`?(e.preventDefault(),this.#E()):e.key===`ArrowDown`&&(e.preventDefault(),this.#D()),this.#g(),this.#_()};#h(){if(!this.#e)return;let e=this.#a;if(e&&e.items[e.index]===this._input){e.index=(e.index+1)%e.items.length,this._input=e.items[e.index];return}let t=this.#e.complete(this._input);if(t.length===0){this.#a=null;return}this._input=t[0],this.#a=t.length>1?{items:t,index:0}:null}#g(){this._ghost=``,this.#o!==null&&(clearTimeout(this.#o),this.#o=null)}#_(){this.#o=setTimeout(()=>{this.#o=null,this.#v()},e.#s)}#v(){if(!this.#e||this.#a)return;let e=this._input,t=e.slice(-1),n=e===``||t===` `||t===`|`,r=/[\w./]/u.test(t);if(!n&&!r)return;let i=this.#e.complete(e);if(i.length===0)return;let a=i[0];!a.startsWith(e)||a===e||r&&i.includes(e)||(this._ghost=a.slice(e.length))}#y(e){let t=e.notes.map(e=>({text:e,kind:`note`}));for(let n of WN(e))t.push({text:`silenced: ${n}`,kind:`gap`});this.#b(t)}#b(t){if(t.length===0)return;let n=[...this._notes];for(let{text:r,kind:i}of t){let t=n.findIndex(e=>e.text===r);t!==-1&&this.#S(n,t),n.push({id:++this.#l,text:r,kind:i,dwell:e.#x(r)})}for(;n.length>e.#u;)this.#S(n,0);for(let e of n)this.#c.has(e.id)||this.#c.set(e.id,setTimeout(()=>this.#w(e.id),e.dwell));this._notes=n}static#x(e){return Math.min(1e4,3200+e.length*55)}#S(e,t){let[n]=e.splice(t,1);this.#C(n.id)}#C(e){let t=this.#c.get(e);t!==void 0&&(clearTimeout(t),this.#c.delete(e))}#w(e){this.#c.delete(e),this._notes=this._notes.filter(t=>t.id!==e)}#T(){for(let e of this.#c.values())clearTimeout(e);this.#c.clear(),this._notes=[]}#E(){this.#n.length!==0&&(this.#r<0?(this.#i=this._input,this.#r=this.#n.length-1):this.#r=Math.max(0,this.#r-1),this._input=this.#n[this.#r])}#D(){if(this.#r<0)return;let e=this.#r+1;e>=this.#n.length?(this.#r=-1,this._input=this.#i,this.#i=``):(this.#r=e,this._input=this.#n[e])}#O=e=>{this._input=e.target.value};#k=e=>{this._input=e,this.#r=-1,this.#i=``,this.focusInput()};#A=()=>{let e=this.renderRoot.getSelection?.()??document.getSelection();e&&!e.isCollapsed||this.focusInput()};render(){return v`<div class="notes" role="log" aria-atomic="false">${_(this._notes,e=>e.id,t=>v`<div class="note ${t.kind===`gap`?`note-gap`:``}" style="${g({"--dwell-out":`${t.dwell-e.#d}ms`})}">${t.text}</div>`)}</div><div class="output" @click="${this.#A}">${this._lines.map(e=>this.#j(e))}</div><form class="form" @submit="${this.#p}" aria-busy="${this._running?`true`:`false`}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?v`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:te} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#O}" @keydown="${this.#m}"></div></form>`}#j(e){return e.kind===`banner`?v`<div class="banner">Virtual shell over the bundle source tree. Try ${e.commands.map((e,t)=>v`${t>0?`, `:``}\`<span class="cmd" @click="${()=>this.#k(e)}">${e}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:e.kind===`prompt`?v`<div class="line"><span class="cwd">${e.cwd}</span>${` `}<span class="sigil">$</span>${` `}${e.text}</div>`:e.kind===`stdout`?this.#M(e):e.kind===`stderr`?v`<pre class="stderr">${e.text}</pre>`:te}#M(e){if(!e.diff)return v`<pre class="stdout">${e.text}</pre>`;let t=e.diff.flatMap((e,t)=>{let n=e.kind?v`<span class="diff-${e.kind}">${e.text}</span>`:e.text;return t===0?[n]:[`
366
+ `,n]});return v`<pre class="stdout">${t}</pre>`}};customElements.define(`bundle-terminal`,QN);function $N(e,t){let n=document.createElement(`bundle-terminal`);return n.dataset.integrity=t??``,n.sources=e,n}export{$N as createTerminalElement};